Skip to content

Commit 5d3d62d

Browse files
committed
[realtek] Fix reopening of legacy-mode 8139 NIC
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>
1 parent c4bce43 commit 5d3d62d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/drivers/net/realtek.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,11 @@ static int realtek_create_ring ( struct realtek_nic *rtl,
549549
static void realtek_destroy_ring ( struct realtek_nic *rtl,
550550
struct realtek_ring *ring ) {
551551

552-
/* Do nothing in legacy mode */
552+
/* Reset producer and consumer counters */
553+
ring->prod = 0;
554+
ring->cons = 0;
555+
556+
/* Do nothing more if in legacy mode */
553557
if ( rtl->legacy )
554558
return;
555559

@@ -560,8 +564,6 @@ static void realtek_destroy_ring ( struct realtek_nic *rtl,
560564
/* Free descriptor ring */
561565
free_dma ( ring->desc, ring->len );
562566
ring->desc = NULL;
563-
ring->prod = 0;
564-
ring->cons = 0;
565567
}
566568

567569
/**

0 commit comments

Comments
 (0)