Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Jun 2009 00:27:45 +0000 (UTC)
From:      Kip Macy <kmacy@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r193599 - user/kmacy/releng_7_2_fcs/sys/dev/cxgb
Message-ID:  <200906070027.n570RjcP076344@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kmacy
Date: Sun Jun  7 00:27:45 2009
New Revision: 193599
URL: http://svn.freebsd.org/changeset/base/193599

Log:
  don't free mbuf if it is part of a chain

Modified:
  user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_sge.c

Modified: user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_sge.c
==============================================================================
--- user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_sge.c	Sun Jun  7 00:02:52 2009	(r193598)
+++ user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_sge.c	Sun Jun  7 00:27:45 2009	(r193599)
@@ -266,6 +266,56 @@ set_wr_hdr(struct work_request_hdr *wrp,
 }
 #endif
 
+struct coalesce_info {
+	int count;
+	int nbytes;
+};
+
+static int
+coalesce_check(struct mbuf *m, void *arg)
+{
+	struct coalesce_info *ci = arg;
+	int *count = &ci->count;
+	int *nbytes = &ci->nbytes;
+
+	if ((*nbytes + m->m_len <= 10500) && (*count < 7) &&
+	    (m->m_next == NULL)){
+		*count += 1;
+		*nbytes += m->m_len;
+		return (1);
+	}
+	return (0);
+}
+
+static struct mbuf *
+cxgb_dequeue(struct sge_qset *qs)
+{
+	struct mbuf *m, *m_head, *m_tail;
+	struct coalesce_info ci;
+
+	if (qs->port->adapter->tunq_coalesce) {
+		m = TXQ_RING_DEQUEUE(qs);
+		if (m != NULL && m->m_nextpkt != NULL)
+			panic("dequeued regular packet with nextpkt set!");
+	}
+
+	m_head = m_tail = NULL;
+	ci.count = ci.nbytes = 0;
+	do {
+		m = TXQ_RING_DEQUEUE_COND(qs, coalesce_check, &ci);
+		if (m_head == NULL) {
+			m_tail = m_head = m;
+		} else if (m != NULL) {
+			m_tail->m_nextpkt = m;
+			m_tail = m;
+			m->m_nextpkt = NULL;
+		}
+	} while (m != NULL);
+	if (ci.count > 7)
+		panic("trying to coalesce %d packets in to one WR", ci.count);
+	return (m_head);
+}
+	
 /**
  *	reclaim_completed_tx - reclaims completed Tx descriptors
  *	@adapter: the adapter
@@ -1502,7 +1552,6 @@ cxgb_tx_watchdog(void *arg)
 		    qs, txq->txq_watchdog.c_cpu);
 }
 
-	
 static void
 cxgb_tx_timeout(void *arg)
 {
@@ -1516,56 +1565,6 @@ cxgb_tx_timeout(void *arg)
 	}
 }
 
-struct coalesce_info {
-	int count;
-	int nbytes;
-};
-
-static int
-coalesce_check(struct mbuf *m, void *arg)
-{
-	struct coalesce_info *ci = arg;
-	int *count = &ci->count;
-	int *nbytes = &ci->nbytes;
-
-	if ((*nbytes + m->m_len <= 10500) && (*count < 7) &&
-	    (m->m_next == NULL)){
-		*count += 1;
-		*nbytes += m->m_len;
-		return (1);
-	}
-	return (0);
-}
-
-static struct mbuf *
-cxgb_dequeue(struct sge_qset *qs)
-{
-	struct mbuf *m, *m_head, *m_tail;
-	struct coalesce_info ci;
-
-	if (qs->port->adapter->tunq_coalesce) {
-		m = TXQ_RING_DEQUEUE(qs);
-		if (m != NULL && m->m_nextpkt != NULL)
-			panic("dequeued regular packet with nextpkt set!");
-	}
-
-	m_head = m_tail = NULL;
-	ci.count = ci.nbytes = 0;
-	do {
-		m = TXQ_RING_DEQUEUE_COND(qs, coalesce_check, &ci);
-		if (m_head == NULL) {
-			m_tail = m_head = m;
-		} else if (m != NULL) {
-			m_tail->m_nextpkt = m;
-			m_tail = m;
-			m->m_nextpkt = NULL;
-		}
-	} while (m != NULL);
-	if (ci.count > 7)
-		panic("trying to coalesce %d packets in to one WR", ci.count);
-	return (m_head);
-}
-	
 static void
 cxgb_start_locked(struct sge_qset *qs)
 {
@@ -1596,7 +1595,7 @@ cxgb_start_locked(struct sge_qset *qs)
 		 *  Encapsulation can modify our pointer, and or make it
 		 *  NULL on failure.  In that event, we can't requeue.
 		 */
-		if (t3_encap(qs, &m_head))
+		if (t3_encap(qs, &m_head) || m_head == NULL)
 			break;
 		
 		/* Send a copy of the frame to the BPF listener */
@@ -1605,7 +1604,8 @@ cxgb_start_locked(struct sge_qset *qs)
 		/*
 		 * We sent via PIO, no longer need a copy
 		 */
-		if (m_head->m_pkthdr.len <= PIO_LEN)
+		if (m->head->m_nextpkt == NULL &&
+		    m_head->m_pkthdr.len <= PIO_LEN)
 			m_freem(m_head);
 
 		m_head = NULL;



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