summaryrefslogtreecommitdiffstats
path: root/hw/net/stellaris_enet.c
Commit message (Collapse)AuthorAgeFilesLines
* net: remove all cleanup methods from NIC NetClientInfosPaolo Bonzini2015-01-121-8/+0
| | | | | | | | | | | | | | | | | All NICs have a cleanup function that, in most cases, zeroes the pointer to the NICState. In some cases, it frees data belonging to the NIC. However, this function is never called except when exiting from QEMU. It is not necessary to NULL pointers and free data here; the right place to do that would be in the device's unrealize function, after calling qemu_del_nic. Zeroing the NIC multiple times is also wrong for multiqueue devices. This cleanup function gets in the way of making the NetClientStates for the NIC hold an object_ref reference to the object, so get rid of it. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* memory: remove memory_region_destroyPaolo Bonzini2014-08-181-8/+0
| | | | | | | The function is empty after the previous patch, so remove it. Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* hw/net/stellaris_enet: Convert to vmstatePeter Maydell2014-05-131-68/+80
| | | | | | | | | | | | | | | Convert this device to use vmstate for its save/load, including providing a post_load function that sanitizes inbound data to avoid possible buffer overflows if it is malicious. The sanitizing fixes CVE-2013-4532 (though nobody should be relying on the security properties of most of the unmaintained ARM board models anyway, and migration doesn't actually work on this board due to issues in other device models). Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
* hw/net/stellaris_enet: Get rid of rx_fifo pointerPeter Maydell2014-05-131-21/+19
| | | | | | | | | | | | The rx_fifo pointer is awkward to migrate, and is actually redundant since it is always possible to determine it from the current rx[].len/.data and rx_fifo_len. Remove both rx_fifo and rx_fifo_len from the state, replacing them with a simple rx_fifo_offset which points at the current location in the RX fifo. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
* hw/net/stellaris_enet: Fix debug format stringsPeter Maydell2014-05-131-3/+3
| | | | | | | | Fix various debug format strings which were incorrect for the data type, so that building with debug enabled is possible. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
* hw/net/stellaris_enet: Correctly implement the TR and THR registersPeter Maydell2014-05-131-2/+15
| | | | | | | | | | | | | | | | | | | | | Packet transmission for the stellaris ethernet controller can be triggered in one of two ways: * by setting a threshold value in the THR register; when the FIFO fill level reaches the threshold, the h/w starts transmitting. Software has to finish filling the FIFO before the transmit process completes to avoid a (silent) underrun * by software writing to the TR register to explicitly trigger transmission Since QEMU transmits packets instantaneously (from the guest's point of view), implement "transmit based on threshold" with our existing mechanism of "transmit as soon as we have the whole packet", with the additional wrinkle that we don't transmit if the packet size is below the specified threshold, and implement "transmit by specific request" properly. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
* hw/net/stellaris_enet: Rewrite tx fifo handling codePeter Maydell2014-05-131-42/+77
| | | | | | | | | The datasheet is clear that the frame length written to the DATA register is actually stored in the TX FIFO; this means we don't need to keep both tx_frame_len and tx_fifo_len state separately. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
* hw/net/stellaris_enet: Correct handling of packet paddingPeter Maydell2014-05-131-1/+1
| | | | | | | | | | | The PADEN bit in the transmit control register enables padding of short data packets out to the required minimum length. However a typo here meant we were adjusting tx_fifo_len rather than tx_frame_len, so the padding didn't actually happen. Fix this bug. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Cc: qemu-stable@nongnu.org
* hw/net/stellaris_enet: Restructure tx_fifo code to avoid buffer overrunPeter Maydell2014-05-131-4/+6
| | | | | | | | | | | | | | | | | | | The current tx_fifo code has a corner case where the guest can overrun the fifo buffer: if automatic CRCs are disabled we allow the guest to write the CRC word even if there isn't actually space for it in the FIFO. The datasheet is unclear about exactly how the hardware deals with this situation; the most plausible answer seems to be that the CRC word is just lost. Implement this fix by separating the "can we stuff another word in the FIFO" logic from the "should we transmit the packet now" check. This also moves us closer to the real hardware, which has a number of ways it can be configured to trigger sending the packet, some of which we don't implement. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Cc: qemu-stable@nongnu.org
* hw/net/stellaris_enet: Avoid unintended sign extensionPeter Maydell2014-02-261-1/+2
| | | | | | | | | | | | | Add a cast to avoid an unintended sign extension that would mean we returned 0xffffffff in the high 32 bits for an IA0 read if bit 31 in the MAC address was 1. (This is harmless since we'll only be doing 4 byte reads, but it could be confusing, so best avoided.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Message-id: 1392647854-8067-3-git-send-email-peter.maydell@linaro.org
* stellaris_enet: Fix NetClientInfo::cleanupAndreas Färber2013-07-291-5/+11
| | | | | | | | | Drop freeing stellaris_enet_state - that is done by QOM later on unref. Both MemoryRegion init and savevm registration happen in SysBusDevice initfn currently, so move them into an unrealizefn for now. Signed-off-by: Andreas Färber <afaerber@suse.de>
* stellaris_enet: QOM cast cleanupAndreas Färber2013-07-291-9/+15
| | | | Signed-off-by: Andreas Färber <afaerber@suse.de>
* hw/n*: pass owner to memory_region_init* functionsPaolo Bonzini2013-07-041-2/+2
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* memory: add owner argument to initialization functionsPaolo Bonzini2013-07-041-1/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* hw: move NICs to hw/net/, configure via default-configs/Paolo Bonzini2013-04-081-0/+450
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
OpenPOWER on IntegriCloud