Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 05 Apr 2007 23:10:53 +0400
From:      Vladimir Ivanov <wawa@yandex-team.ru>
To:        freebsd-net@freebsd.org
Subject:   Serious bug in most (?) ethernet drivers (bge, bce, ixgb etc.).
Message-ID:  <461549BD.1020800@yandex-team.ru>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------040209070900020908020409
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

We have reported serious bug with em driver 
(http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/87418) one year and 
half ago.
It's very funny but most freebsd ethernet drivers cloned this bug I seem.
You can see same bug in bce, bge, ixgb and so on.

I've attached draft patch for bce driver to illustrate the problem.

WBR,
Vladimir Ivanov
Yandex LLC

--------------040209070900020908020409
Content-Type: text/x-patch;
 name="if_bce.c.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="if_bce.c.patch"

--- if_bce.c.orig	Fri Mar 16 00:58:25 2007
+++ if_bce.c	Thu Apr  5 02:57:39 2007
@@ -3943,6 +3943,8 @@ bce_rx_intr(struct bce_softc *sc)
 		unsigned int len;
 		u32 status;
 
+		m = NULL;
+
 		/* Convert the producer/consumer indices to an actual rx_bd index. */
 		sw_chain_cons = RX_CHAIN_IDX(sw_cons);
 		sw_chain_prod = RX_CHAIN_IDX(sw_prod);
@@ -4131,16 +4133,30 @@ bce_rx_intr(struct bce_softc *sc)
 			ifp->if_ipackets++;
 			DBPRINT(sc, BCE_VERBOSE_RECV, "%s(): Passing received frame up.\n",
 				__FUNCTION__);
-			BCE_UNLOCK(sc);
-			(*ifp->if_input)(ifp, m);
-			DBRUNIF(1, sc->rx_mbuf_alloc--);
-			BCE_LOCK(sc);
 
 bce_rx_int_next_rx:
 			sw_prod = NEXT_RX_BD(sw_prod);
 		}
 
 		sw_cons = NEXT_RX_BD(sw_cons);
+
+		if (m) {
+			sc->rx_cons = sw_cons;
+			sc->rx_prod = sw_prod;
+			sc->rx_prod_bseq = sw_prod_bseq;
+
+			BCE_UNLOCK(sc);
+			(*ifp->if_input)(ifp, m);
+			BCE_LOCK(sc);
+                        DBRUNIF(1, sc->rx_mbuf_alloc--);
+
+		        sw_cons = sc->rx_cons;
+      			sw_prod = sc->rx_prod;
+		        sw_prod_bseq = sc->rx_prod_bseq;
+			hw_cons = sc->hw_rx_cons = sblk->status_rx_quick_consumer_index0;
+			if ((hw_cons & USABLE_RX_BD_PER_PAGE) == USABLE_RX_BD_PER_PAGE)
+				hw_cons++;
+		}
 
 		/* Refresh hw_cons to see if there's new work */
 		if (sw_cons == hw_cons) {

--------------040209070900020908020409--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?461549BD.1020800>