]> xenbits.xensource.com Git - qemu-upstream-4.6-testing.git/commitdiff
net/cadence_gem: Fix rx multi-fragment packets
authorPeter Crosthwaite <peter.crosthwaite@xilinx.com>
Wed, 4 Dec 2013 05:59:43 +0000 (21:59 -0800)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 10 Dec 2013 13:28:50 +0000 (13:28 +0000)
Bytes_to_copy was being updated before its final use where it
advances the rx buffer pointer. This was causing total mayhem,
where packet data for any subsequent fragments was being fetched
from the wrong place.

Reported-by: Deepika Dhamija <deepika@xilinx.com>
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: c2a1c65c1fd06eb274442a0fa4a6839d940e145e.1386136219.git.peter.crosthwaite@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
hw/net/cadence_gem.c

index 8cfad0401790c5df231211d3d61d00e25bfe9723..2afafdfb2b19e69b60d0a0f8be54ea595470a8b9 100644 (file)
@@ -733,8 +733,8 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
         /* Copy packet data to emulated DMA buffer */
         cpu_physical_memory_write(rx_desc_get_buffer(s->rx_desc) + rxbuf_offset,
                                   rxbuf_ptr, MIN(bytes_to_copy, rxbufsize));
-        bytes_to_copy -= MIN(bytes_to_copy, rxbufsize);
         rxbuf_ptr += MIN(bytes_to_copy, rxbufsize);
+        bytes_to_copy -= MIN(bytes_to_copy, rxbufsize);
 
         /* Update the descriptor.  */
         if (first_desc) {