]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[realtek] Fix reopening of legacy-mode 8139 NIC
authorMichael Brown <mcb30@ipxe.org>
Sun, 26 May 2013 17:26:48 +0000 (18:26 +0100)
committerMichael Brown <mcb30@ipxe.org>
Sun, 26 May 2013 17:31:46 +0000 (18:31 +0100)
realtek_destroy_ring() currently does nothing if the card is operating
in legacy (pre-RTL8139C+) mode.  In particular, the producer and
consumer counters are incorrectly left holding their current values.
Virtual hardware (e.g. the emulated RTL8139 in qemu and similar VMs)
is tolerant of this behaviour, but real hardware will fail to transmit
if the descriptors are not used in the correct order.

Fix by resetting the producer and consumer counters in
realtek_destroy_ring() even if the card is operating in legacy mode.

Reported-by: Gelip <mrgelip@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/net/realtek.c

index 1fd3931b68f09f033ab884a126e5031c7ba7bba3..498c233f854184fd181505419c7c2e1fb95cd69c 100644 (file)
@@ -549,7 +549,11 @@ static int realtek_create_ring ( struct realtek_nic *rtl,
 static void realtek_destroy_ring ( struct realtek_nic *rtl,
                                   struct realtek_ring *ring ) {
 
-       /* Do nothing in legacy mode */
+       /* Reset producer and consumer counters */
+       ring->prod = 0;
+       ring->cons = 0;
+
+       /* Do nothing more if in legacy mode */
        if ( rtl->legacy )
                return;
 
@@ -560,8 +564,6 @@ static void realtek_destroy_ring ( struct realtek_nic *rtl,
        /* Free descriptor ring */
        free_dma ( ring->desc, ring->len );
        ring->desc = NULL;
-       ring->prod = 0;
-       ring->cons = 0;
 }
 
 /**