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,17 +590,22 @@ jme_disable_rx_engine(struct jme_adapter *jme)
590 590
 }
591 591
 
592 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 595
 	struct jme_ring *rxring = &jme->rxring;
596 596
 	int i = rxring->next_to_fill;
597 597
 	struct io_buffer **bufinf = rxring->bufinf;
598 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 609
 		i = (i + 1) & mask;
605 610
 	}
606 611
 	rxring->next_to_fill = i;
@@ -622,7 +627,7 @@ jme_alloc_and_feed_iob(struct jme_adapter *jme, int idx)
622 627
 	netdev_rx(netdev, rxbi);
623 628
 
624 629
 	rxring->bufinf[idx] = NULL;
625
-	jme_refill_rx_ring(jme);
630
+	jme_refill_rx_ring(jme, idx);
626 631
 }
627 632
 
628 633
 static void
@@ -636,7 +641,8 @@ jme_process_receive(struct jme_adapter *jme)
636 641
 
637 642
 	i = rxring->next_to_clean;
638 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 646
 		(rxdesc->descwb.desccnt & RXWBDCNT_WBCPL) &&
641 647
 		limit--) {
642 648
 

Loading…
Cancel
Save