Hi, with further encouragement, I decided to give tl(4) a try.
It's a very interesting ethernet chip, and even under heavy tcpbench
the mbuf usage is at most 6. As usual, feedback and comments are welcomed.
//Logan
C-x-C-c
Index: src/sys/dev/pci/if_tl.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_tl.c,v
retrieving revision 1.50
diff -u -p -r1.50 if_tl.c
--- src/sys/dev/pci/if_tl.c 19 May 2010 15:27:35 -0000 1.50
+++ src/sys/dev/pci/if_tl.c 14 Dec 2010 19:15:28 -0000
@@ -252,8 +252,8 @@ int tl_intvec_rxeof(void *, u_int32_t);
int tl_intvec_adchk(void *, u_int32_t);
int tl_intvec_netsts(void *, u_int32_t);
-int tl_newbuf(struct tl_softc *,
- struct tl_chain_onefrag *);
+int tl_newbuf(struct tl_softc *, struct tl_chain_onefrag *);
+void tl_fill_rx_ring(struct tl_softc *);
void tl_stats_update(void *);
int tl_encap(struct tl_softc *, struct tl_chain *,
struct mbuf *);
@@ -1034,8 +1034,6 @@ int tl_list_rx_init(sc)
for (i = 0; i < TL_RX_LIST_CNT; i++) {
cd->tl_rx_chain[i].tl_ptr =
(struct tl_list_onefrag *)&ld->tl_rx_list[i];
- if (tl_newbuf(sc, &cd->tl_rx_chain[i]) == ENOBUFS)
- return(ENOBUFS);
if (i == (TL_RX_LIST_CNT - 1)) {
cd->tl_rx_chain[i].tl_next = NULL;
ld->tl_rx_list[i].tlist_fptr = 0;
@@ -1047,34 +1045,45 @@ int tl_list_rx_init(sc)
}
cd->tl_rx_head = &cd->tl_rx_chain[0];
+ cd->tl_rx_cons = &cd->tl_rx_chain[0];
cd->tl_rx_tail = &cd->tl_rx_chain[TL_RX_LIST_CNT - 1];
-
+ cd->tl_rx_cnt = 0;
+ tl_fill_rx_ring(sc);
return(0);
}
+void tl_fill_rx_ring(sc)
+ struct tl_softc *sc;
+{
+ struct tl_list_data *ld;
+ struct tl_chain_data *cd;
+
+ cd = &sc->tl_cdata;
+ ld = sc->tl_ldata;
+
+ while (cd->tl_rx_cnt < TL_RX_LIST_CNT) {
+ if(tl_newbuf(sc, cd->tl_rx_head) == ENOBUFS)
+ break;
+ cd->tl_rx_head = cd->tl_rx_head->tl_next;
+ cd->tl_rx_cnt++;
+ }
+}
+
int tl_newbuf(sc, c)
struct tl_softc *sc;
struct ...