Browse Source

[jme] Fix refill behavior

After changing the driver to refill after feed, if any error occurs a
non-contiguous empty buffer will be introduced in the ring due to my
reuse-buffer-when-error implementation.

Reported-by: Marty Connor <mdc@etherboot.org>
Signed-off-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Guo-Fu Tseng 14 years ago
parent
commit
1798e04ebb
1 changed files with 13 additions and 7 deletions
  1. 13
    7
      src/drivers/net/jme.c

+ 13
- 7
src/drivers/net/jme.c View File

590
 }
590
 }
591
 
591
 
592
 static void
592
 static void
593
-jme_refill_rx_ring(struct jme_adapter *jme)
593
+jme_refill_rx_ring(struct jme_adapter *jme, int curhole)
594
 {
594
 {
595
 	struct jme_ring *rxring = &jme->rxring;
595
 	struct jme_ring *rxring = &jme->rxring;
596
 	int i = rxring->next_to_fill;
596
 	int i = rxring->next_to_fill;
597
 	struct io_buffer **bufinf = rxring->bufinf;
597
 	struct io_buffer **bufinf = rxring->bufinf;
598
 	int mask = jme->rx_ring_mask;
598
 	int mask = jme->rx_ring_mask;
599
+	int limit = jme->rx_ring_size;
599
 
600
 
600
-	while (!bufinf[i]) {
601
-		if (jme_make_new_rx_buf(bufinf + i))
602
-			break;
603
-		jme_set_clean_rxdesc(jme, i);
601
+	while (limit--) {
602
+		if (!bufinf[i]) {
603
+			if (jme_make_new_rx_buf(bufinf + i))
604
+				break;
605
+			jme_set_clean_rxdesc(jme, i);
606
+		}
607
+		if (i == curhole)
608
+			limit = 0;
604
 		i = (i + 1) & mask;
609
 		i = (i + 1) & mask;
605
 	}
610
 	}
606
 	rxring->next_to_fill = i;
611
 	rxring->next_to_fill = i;
622
 	netdev_rx(netdev, rxbi);
627
 	netdev_rx(netdev, rxbi);
623
 
628
 
624
 	rxring->bufinf[idx] = NULL;
629
 	rxring->bufinf[idx] = NULL;
625
-	jme_refill_rx_ring(jme);
630
+	jme_refill_rx_ring(jme, idx);
626
 }
631
 }
627
 
632
 
628
 static void
633
 static void
636
 
641
 
637
 	i = rxring->next_to_clean;
642
 	i = rxring->next_to_clean;
638
 	rxdesc += i;
643
 	rxdesc += i;
639
-	while (!(rxdesc->descwb.flags & cpu_to_le16(RXWBFLAG_OWN)) &&
644
+	while (rxring->bufinf[i] &&
645
+		!(rxdesc->descwb.flags & cpu_to_le16(RXWBFLAG_OWN)) &&
640
 		(rxdesc->descwb.desccnt & RXWBDCNT_WBCPL) &&
646
 		(rxdesc->descwb.desccnt & RXWBDCNT_WBCPL) &&
641
 		limit--) {
647
 		limit--) {
642
 
648
 

Loading…
Cancel
Save