PERFORCE change 126871 for review

Kip Macy kmacy at FreeBSD.org
Thu Sep 27 12:18:07 PDT 2007


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

Change 126871 by kmacy at kmacy_home:ethng on 2007/09/27 19:17:19

	- free pending mbufs and tx descriptors when the port is 
	         down
	- reduce service thread priority to timeshare after first 
	  tx iteration to prevent starvation of ithread which we 
	  need to update the count of processed descriptors

Affected files ...

.. //depot/projects/ethng/src/sys/dev/cxgb/cxgb_multiq.c#20 edit

Differences ...

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

@@ -103,7 +103,7 @@
 SYSCTL_UINT(_hw_cxgb, OID_AUTO, sleep_ticks, CTLFLAG_RDTUN, &sleep_ticks, 0,
     "ticks to sleep between checking pcpu queues");
 
-int cxgb_txq_mbuf_ring_size = 2048;
+int cxgb_txq_mbuf_ring_size = TX_ETH_Q_SIZE;
 TUNABLE_INT("hw.cxgb.txq_mr_size", &cxgb_txq_mbuf_ring_size);
 SYSCTL_UINT(_hw_cxgb, OID_AUTO, txq_mr_size, CTLFLAG_RDTUN, &cxgb_txq_mbuf_ring_size, 0,
     "size of per-queue mbuf ring");
@@ -349,6 +349,8 @@
 		m_freem(m);
 	while ((m = mbuf_ring_dequeue(&txq->txq_mr)) != NULL) 
 		m_freem(m);
+
+	t3_free_tx_desc_all(txq);
 }
 
 static int
@@ -428,21 +430,23 @@
 
 	stopped = isset(&qs->txq_stopped, TXQ_ETH);
 	flush = ((!mbuf_ring_empty(&txq->txq_mr) && !stopped) || txq->immpkt); 
-	max_desc = tx_flush ? 0xffffff : TX_START_MAX_DESC;
+	max_desc = tx_flush ? TX_ETH_Q_SIZE : TX_START_MAX_DESC;
 	err = flush ? cxgb_tx_common(qs->port->ifp, qs, max_desc) : ENOSPC;
 	
 	if ((tx_flush && flush && err == 0) && !mbuf_ring_empty(&txq->txq_mr)) {
-#if 0		
 		struct thread *td = curthread;
-		thread_lock(td);
-		sched_prio(td, PRI_MIN_TIMESHARE);
-		thread_unlock(td);
-#endif		
-		if (i++ > 5000)
-			device_printf(qs->port->adapter->dev,
-			    "mbuf head=%p qsize=%d qlen=%d\n",
-			    txq->sendq.head, txq->sendq.qsize, txq->sendq.qlen);
 
+		if (++i > 1) {
+			thread_lock(td);
+			sched_prio(td, PRI_MIN_TIMESHARE);
+			thread_unlock(td);
+		}
+		if (i > 50) {
+			if (cxgb_debug)
+				device_printf(qs->port->adapter->dev,
+				    "exceeded max enqueue tries\n");
+			return (EBUSY);
+		}
 		goto retry;
 	}
 	err = (initerr != 0) ? initerr : err;
@@ -548,7 +552,7 @@
 	struct adapter *sc = qs->port->adapter;
 	struct sge_txq *txq = &qs->txq[TXQ_ETH];
 	
-	int err = 0;
+	int idleticks, err = 0;
 	
 	td = curthread;
 
@@ -565,9 +569,14 @@
 		if (qs->qs_flags & QS_EXITING)
 			break;
 
-		if ((qs->port->ifp->if_drv_flags && IFF_DRV_RUNNING) == 0)
+		if ((qs->port->ifp->if_drv_flags && IFF_DRV_RUNNING) == 0) {
+			idleticks = hz;
+			if (!mbuf_ring_empty(&txq->txq_mr) ||
+			    !mbufq_empty(&txq->sendq))
+				cxgb_pcpu_free(qs);
 			goto done;
-
+		} else
+			idleticks = sleep_ticks;
 		if (mtx_trylock(&txq->lock)) {
 			txq->flags |= TXQ_TRANSMITTING;
 			err = cxgb_pcpu_start_(qs, NULL, TRUE);
@@ -575,7 +584,8 @@
 			mtx_unlock(&txq->lock);
 		} else
 			err = EINPROGRESS;
-	 	
+
+
 		if (mtx_trylock(&qs->rspq.lock)) {
 			process_responses(sc, qs, -1);
 


More information about the p4-projects mailing list