PERFORCE change 118764 for review

Kip Macy kmacy at FreeBSD.org
Wed Apr 25 00:28:13 UTC 2007


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

Change 118764 by kmacy at kmacy_vt-x:opentoe_init on 2007/04/25 00:27:27

	implement offload and ctrlq restart functions

Affected files ...

.. //depot/projects/opentoe/sys/dev/cxgb/cxgb_adapter.h#13 edit
.. //depot/projects/opentoe/sys/dev/cxgb/cxgb_sge.c#18 edit

Differences ...

==== //depot/projects/opentoe/sys/dev/cxgb/cxgb_adapter.h#13 (text+ko) ====

@@ -64,6 +64,57 @@
 struct sge_qset;
 extern int cxgb_debug;
 
+/*
+ * Put here for now until a more appropriate place is found
+ */
+struct mbuf_head {
+	struct mbuf *head;
+	struct mbuf *tail;
+	uint32_t     qlen;
+};
+
+static __inline void
+mbufq_init(struct mbuf_head *l)
+{
+	l->head = l->tail = NULL;
+}
+
+static __inline int
+mbufq_empty(struct mbuf_head *l)
+{
+	return (l->head == NULL);
+}
+
+static __inline void
+mbufq_tail(struct mbuf_head *l, struct mbuf *m)
+{
+	l->qlen++;
+	l->tail->m_nextpkt = m;
+	l->tail = m;
+}
+
+static __inline struct mbuf *
+mbufq_dequeue(struct mbuf_head *l)
+{
+	struct mbuf *m;
+
+	m = l->head;
+	if (m) {
+		if (m == l->tail) 
+			l->tail = NULL;
+		l->head = m->m_nextpkt;
+		l->qlen--;
+	}
+
+	return (m);
+}
+
+static __inline struct mbuf *
+mbufq_peek(struct mbuf_head *l)
+{
+	return (l->head);
+}
+	
 struct port_info {
 	struct adapter	*adapter;
 	struct ifnet	*ifp;
@@ -208,6 +259,7 @@
 	bus_dma_tag_t	desc_tag;
 	bus_dmamap_t	desc_map;
 	bus_dma_tag_t   entry_tag;
+	struct mbuf_head sendq;
 	struct mtx      lock;
 };
      	

==== //depot/projects/opentoe/sys/dev/cxgb/cxgb_sge.c#18 (text+ko) ====

@@ -1286,17 +1286,16 @@
 	 * the control queue is only used for binding qsets which happens
 	 * at init time so we are guaranteed enough descriptors
 	 */
-#if 0	
-	if (__predict_false(!skb_queue_empty(&q->sendq))) {
-addq_exit:	__skb_queue_tail(&q->sendq, skb);
+	if (__predict_false(!mbufq_empty(&q->sendq))) {
+addq_exit:	mbufq_tail(&q->sendq, m);
 		return 1;
 	}
 	if (__predict_false(q->size - q->in_use < ndesc)) {
 
 		struct sge_qset *qs = txq_to_qset(q, qid);
 
-		set_bit(qid, &qs->txq_stopped);
-		smp_mb__after_clear_bit();
+		setbit(&qs->txq_stopped, qid);
+		smp_mb();
 
 		if (should_restart_tx(q) &&
 		    test_and_clear_bit(qid, &qs->txq_stopped))
@@ -1305,7 +1304,6 @@
 		q->stops++;
 		goto addq_exit;
 	}
-#endif	
 	return 0;
 }
 
@@ -1401,14 +1399,12 @@
 	adapter_t *adap = qs->port->adapter;
 
 	mtx_lock(&q->lock);
-	m = NULL;
-#ifdef notyet	
 again:	reclaim_completed_tx_imm(q);
 
 	while (q->in_use < q->size &&
-	       (skb = __skb_dequeue(&q->sendq)) != NULL) {
+	       (m = mbufq_dequeue(&q->sendq)) != NULL) {
 
-		write_imm(&q->desc[q->pidx], skb, skb->len, q->gen);
+		write_imm(&q->desc[q->pidx], m, m->m_len, q->gen);
 
 		if (++q->pidx >= q->size) {
 			q->pidx = 0;
@@ -1416,16 +1412,15 @@
 		}
 		q->in_use++;
 	}
-	if (!skb_queue_empty(&q->sendq)) {
-		set_bit(TXQ_CTRL, &qs->txq_stopped);
-		smp_mb__after_clear_bit();
+	if (!mbufq_empty(&q->sendq)) {
+		setbit(&qs->txq_stopped, TXQ_CTRL);
+		smp_mb();
 
 		if (should_restart_tx(q) &&
 		    test_and_clear_bit(TXQ_CTRL, &qs->txq_stopped))
 			goto again;
 		q->stops++;
 	}
-#endif
 	mtx_unlock(&q->lock);
 	t3_write_reg(adap, A_SG_KDOORBELL,
 		     F_SELEGRCNTX | V_EGRCNTX(q->cntxt_id));
@@ -1788,15 +1783,14 @@
 	struct sge_txq *q = &qs->txq[TXQ_OFLD];
 	adapter_t *adap = qs->port->adapter;
 	struct mbuf *m_vec[TX_CLEAN_MAX_DESC];
-	int i, cleaned;
-	
+	bus_dma_segment_t segs[TX_MAX_SEGS];
+	int nsegs, i, cleaned;
+	struct tx_sw_desc *stx = &q->sdesc[q->pidx];
+		
 	mtx_lock(&q->lock);
-	m = NULL;
-	cleaned = 0;
-#ifdef notyet	
 again:	cleaned = reclaim_completed_tx(adap, q, TX_CLEAN_MAX_DESC, m_vec);
 
-	while ((skb = skb_peek(&q->sendq)) != NULL) {
+	while ((m = mbufq_peek(&q->sendq)) != NULL) {
 		unsigned int gen, pidx;
 		unsigned int ndesc = m->m_priority;
 
@@ -1820,13 +1814,12 @@
 			q->gen ^= 1;
 		}
 		
-		__skb_unlink(skb, &q->sendq);
-		
+		(void)mbufq_dequeue(&q->sendq);
+		busdma_map_mbufs(&m, q, stx, segs, &nsegs);
 		mtx_unlock(&q->lock);
-		write_ofld_wr(adap, skb, q, pidx, gen, ndesc, segs, nsegs);
+		write_ofld_wr(adap, m, q, pidx, gen, ndesc, segs, nsegs);
 		mtx_lock(&q->lock);
 	}
-#endif
 	mtx_unlock(&q->lock);
 	
 #if USE_GTS
@@ -2011,6 +2004,7 @@
 			printf("error %d from alloc ring tx %i\n", ret, i);
 			goto err;
 		}
+		mbufq_init(&q->txq[i].sendq);
 		q->txq[i].gen = 1;
 		q->txq[i].size = p->txq_size[i];
 		mtx_init(&q->txq[i].lock, "t3 txq lock", NULL, MTX_DEF);


More information about the p4-projects mailing list