PERFORCE change 126459 for review

Kip Macy kmacy at FreeBSD.org
Sat Sep 15 22:00:19 PDT 2007


http://perforce.freebsd.org/chv.cgi?CH=126459

Change 126459 by kmacy at kmacy_home:ethng on 2007/09/16 04:59:53

	defer freeing tx cleaned mbufs to the service thread if available or until after 
	the txq lock is dropped

Affected files ...

.. //depot/projects/ethng/src/sys/dev/cxgb/cxgb_multiq.c#17 edit
.. //depot/projects/ethng/src/sys/dev/cxgb/sys/mbufq.h#3 edit
.. //depot/projects/ethng/src/sys/modules/cxgb/Makefile#6 edit

Differences ...

==== //depot/projects/ethng/src/sys/dev/cxgb/cxgb_multiq.c#17 (text+ko) ====

@@ -87,7 +87,7 @@
 #endif
 
 extern struct sysctl_oid_list sysctl__hw_cxgb_children;
-static int cxgb_pcpu_tx_coalesce = 1;
+static int cxgb_pcpu_tx_coalesce = 0;
 TUNABLE_INT("hw.cxgb.tx_coalesce", &cxgb_pcpu_tx_coalesce);
 SYSCTL_UINT(_hw_cxgb, OID_AUTO, tx_coalesce, CTLFLAG_RDTUN, &cxgb_pcpu_tx_coalesce, 0,
     "coalesce small packets into a single work request");
@@ -383,12 +383,13 @@
 }
 
 static int
-cxgb_pcpu_reclaim_tx(struct sge_txq *txq)
+cxgb_pcpu_reclaim_tx(struct sge_txq *txq, struct mbuf_head *mbq)
 {
 	int reclaimable, total_reclaimed, reclaimed, freed, i, j, n;
 	struct mbuf *m_vec[TX_CLEAN_MAX_DESC];
 	struct sge_qset *qs = txq_to_qset(txq, TXQ_ETH);
-		
+
+	
 	KASSERT(qs->qs_cpuid == curcpu, ("cpu qset mismatch cpuid=%d curcpu=%d",
 			qs->qs_cpuid, curcpu));
 	
@@ -398,12 +399,18 @@
 		
 		total_reclaimed += reclaimed;
 		
-		if (j > 10 || cxgb_debug)
+		if (j > 20 || cxgb_debug)
 			printf("n=%d reclaimable=%d txq->processed=%d txq->cleaned=%d txq->in_use=%d\n",
 			    n, reclaimable, txq->processed, txq->cleaned, txq->in_use);
-		
-		for (i = 0; i < n; i++) 
-			m_freem_vec(m_vec[i]);
+
+		for (i = 0; i < n; i++)
+			prefetch(m_vec[i]);
+		/*
+		 * really want to use an mbuf_ring here to avoid touching touching the mbufs
+		 * when all we want to do is store them for later
+		 */
+		for (i = 0; i < n; i++)
+			mbufq_tail(mbq, m_vec[i]);
 		freed += n;
 		j++;
 		
@@ -418,14 +425,14 @@
 }
 
 static int
-cxgb_pcpu_start_(struct sge_qset *qs, struct mbuf *immpkt, int tx_flush)
+cxgb_pcpu_start_(struct sge_qset *qs, struct mbuf *immpkt, int tx_flush, struct mbuf_head *mbq)
 {
 	int i, err, initerr, flush, reclaimed, stopped;
 	struct port_info *pi; 
 	struct sge_txq *txq;
 	adapter_t *sc;
 	uint32_t max_desc;
-
+	
 	pi = qs->port;
 	initerr = err = i = reclaimed = 0;
 	sc = pi->adapter;
@@ -447,7 +454,7 @@
 			m_freem_vec(immpkt);
 		return (initerr);
 	}
-	
+
 	if ((tx_flush && (desc_reclaimable(txq) > 0)) || (desc_reclaimable(txq) > (TX_ETH_Q_SIZE>>1))) {
 		int reclaimed = 0;
 
@@ -457,7 +464,7 @@
 			    qs->qs_cpuid, curcpu, desc_reclaimable(txq),
 			    txq, txq->cidx, txq->pidx);
 		}
-		reclaimed = cxgb_pcpu_reclaim_tx(txq);
+		reclaimed = cxgb_pcpu_reclaim_tx(txq, mbq);
 		if (cxgb_debug)
 			printf("reclaimed=%d\n", reclaimed);
 	}
@@ -494,6 +501,8 @@
 	struct port_info *pi;
 	struct sge_qset *qs;
 	struct sge_txq *txq = NULL /* gcc is dumb */;
+	struct mbuf_head mbq;
+	struct mbuf *m;
 	
 	pi = ifp->if_softc;
 	qs = NULL;
@@ -508,10 +517,11 @@
 		qs = &pi->adapter->sge.qs[pi->first_qset];
 	
 	txq = &qs->txq[TXQ_ETH];
-	
+
+	mbufq_init(&mbq);
 	if (mtx_trylock(&txq->lock)) {
 		txq->flags |= TXQ_TRANSMITTING;
-		err = cxgb_pcpu_start_(qs, immpkt, FALSE);
+		err = cxgb_pcpu_start_(qs, immpkt, FALSE, &mbq);
 		txq->flags &= ~TXQ_TRANSMITTING;
 		resid = (mbufq_len(&txq->sendq) > 128) || (desc_reclaimable(txq) > 128);
 		mtx_unlock(&txq->lock);
@@ -521,6 +531,21 @@
 	if (resid && (txq->flags & TXQ_TRANSMITTING) == 0)
 		wakeup(qs);
 
+	critical_enter();
+	/*
+	 * Are we on a cpu with a service thread?
+	 */
+	if (curcpu < SGE_QSETS) {
+		qs = &pi->adapter->sge.qs[curcpu];
+		txq = &qs->txq[TXQ_ETH];
+		mbufq_append(&txq->cleanq, &mbq);
+		critical_exit();
+	} else {
+		critical_exit();
+		while ((m = mbufq_dequeue(&mbq)) != NULL) 
+			m_freem_vec(m);
+	}
+	
 	return ((err == ENOSPC) ? 0 : err);
 }
 
@@ -531,7 +556,9 @@
 	struct sge_qset *qs;
 	struct mbuf *m, *head, *tail, *lhead, *ltail;
 	int calc_cookie, qidx, i;
+	struct mbuf_head mbq;
 
+	mbufq_init(&mbq);
 	IFQ_LOCK(&ifp->if_snd);
 	IFQ_DEQUEUE_NOLOCK(&ifp->if_snd, m);
 	head = tail = m;
@@ -568,7 +595,7 @@
 		 * Assume one-to-one mapping of qset to CPU for now XXX 
 		 */
 
-		(void)cxgb_pcpu_start_(qs, NULL, TRUE);
+		(void)cxgb_pcpu_start_(qs, NULL, TRUE, &mbq);
 		/*
 			 * XXX multiple packets
 			 */
@@ -583,6 +610,9 @@
 	struct thread *td;
 	struct adapter *sc = qs->port->adapter;
 	struct sge_txq *txq = &qs->txq[TXQ_ETH];
+	struct mbuf_head mbq;
+	struct mbuf *m;
+	
 	int err = 0;
 	
 	td = curthread;
@@ -597,15 +627,18 @@
 		printf("bound to %d running on %d\n", qs->qs_cpuid, curcpu);
 	
 	for (;;) {
+		mbufq_init(&mbq);
+
 		if (qs->qs_flags & QS_EXITING)
 			break;
 
 		if ((qs->port->ifp->if_drv_flags && IFF_DRV_RUNNING) == 0)
 			goto done;
 
+
 		if (mtx_trylock(&txq->lock)) {
 			txq->flags |= TXQ_TRANSMITTING;
-			err = cxgb_pcpu_start_(qs, NULL, TRUE);
+			err = cxgb_pcpu_start_(qs, NULL, TRUE, &mbq);
 			txq->flags &= ~TXQ_TRANSMITTING;
 			mtx_unlock(&txq->lock);
 		} else
@@ -630,7 +663,14 @@
 				    txq->txq_mr.mr_prod);
 			continue;
 		}
-	done:
+	done:	
+		critical_enter();
+		mbufq_append(&mbq, &txq->cleanq);
+		mbufq_init(&txq->cleanq);
+		critical_exit();
+		while ((m = mbufq_dequeue(&mbq)) != NULL) 
+			m_freem_vec(m);
+
 		tsleep(qs, 1, "cxgbidle", sleep_ticks);
 	}
 

==== //depot/projects/ethng/src/sys/dev/cxgb/sys/mbufq.h#3 (text+ko) ====

@@ -44,6 +44,7 @@
 mbufq_init(struct mbuf_head *l)
 {
 	l->head = l->tail = NULL;
+	l->qlen = l->qsize = 0;
 }
 
 static __inline int
@@ -107,4 +108,16 @@
 	return (l->head);
 }
 
+static __inline void
+mbufq_append(struct mbuf_head *a, struct mbuf_head *b)
+{
+	if (a->tail) 
+		a->tail->m_nextpkt = b->head;
+	if (b->tail)
+		a->tail = b->tail;
+	a->qlen += b->qlen;
+	a->qsize += b->qsize;
+	
+	
+}
 #endif  /* CXGB_MBUFQ_H_ */

==== //depot/projects/ethng/src/sys/modules/cxgb/Makefile#6 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/modules/cxgb/Makefile,v 1.9 2007/07/17 06:50:35 kmacy Exp $
+# $FreeBSD: src/sys/modules/cxgb/Makefile,v 1.10 2007/09/09 01:28:02 kmacy Exp $
 
 CXGB = ${.CURDIR}/../../dev/cxgb
 .PATH: ${CXGB} ${CXGB}/common ${CXGB}/sys
@@ -7,24 +7,28 @@
 SRCS=	cxgb_mc5.c cxgb_vsc8211.c cxgb_ael1002.c cxgb_mv88e1xxx.c 
 SRCS+=	cxgb_xgmac.c cxgb_vsc7323.c cxgb_t3_hw.c cxgb_main.c 
 SRCS+=  cxgb_sge.c cxgb_lro.c cxgb_offload.c cxgb_l2t.c
-SRCS+=	device_if.h bus_if.h pci_if.h opt_zero.h 
+SRCS+=	device_if.h bus_if.h pci_if.h opt_zero.h opt_sched.h
 SRCS+=	uipc_mvec.c cxgb_multiq.c
 
 CFLAGS+= -DCONFIG_CHELSIO_T3_CORE -g -DCONFIG_DEFINED -DDEFAULT_JUMBO -I${CXGB} -DSMP
-#CFLAGS+= -DIFNET_MULTIQUEUE
-#CFLAGS+= -DINVARIANT_SUPPORT -DINVARIANTS 
+CFLAGS+= -DIFNET_MULTIQUEUE
+#CFLAGS+= -DDISABLE_MBUF_IOVEC
+#CFLAGS+= -DDEBUG -DDEBUG_PRINT
+#CFLAGS+= -DINVARIANT_SUPPORT -DINVARIANTS -DWITNESS
+#CFLAGS += -DLOCK_PROFILING
+
 #CFLAGS+= -DWITNESS
 #CFLAGS+= -DDEBUG -DDEBUG_PRINT
 
 
 .if ${MACHINE_ARCH} != "ia64"
 # ld is broken on ia64
-t3fw-4.5.0.bin: ${CXGB}/t3fw-4.5.0.bin.gz.uu
-	uudecode -p < ${CXGB}/t3fw-4.5.0.bin.gz.uu \
+t3fw-4.7.1.bin: ${CXGB}/t3fw-4.7.1.bin.gz.uu
+	uudecode -p < ${CXGB}/t3fw-4.7.1.bin.gz.uu \
 	| gzip -dc > ${.TARGET}
 
-FIRMWS= t3fw-4.5.0.bin:t3fw450
-CLEANFILES+= t3fw-4.5.0.bin
+FIRMWS= t3fw-4.7.1.bin:t3fw471
+CLEANFILES+= t3fw-4.7.1.bin
 
 t3b_protocol_sram-1.1.0.bin: ${CXGB}/t3b_protocol_sram-1.1.0.bin.gz.uu
 	uudecode -p < ${CXGB}/t3b_protocol_sram-1.1.0.bin.gz.uu \


More information about the p4-projects mailing list