svn commit: r205283 - in stable/8/sys: dev/cxgb dev/e1000 dev/ixgbe dev/mxge net

Max Laier mlaier at FreeBSD.org
Thu Mar 18 17:00:44 UTC 2010


Author: mlaier
Date: Thu Mar 18 17:00:44 2010
New Revision: 205283
URL: http://svn.freebsd.org/changeset/base/205283

Log:
  MFC r203834 and r205197: Make ALTQ work for drbr consumers.

Modified:
  stable/8/sys/dev/cxgb/cxgb_sge.c
  stable/8/sys/dev/e1000/if_em.c
  stable/8/sys/dev/e1000/if_igb.c
  stable/8/sys/dev/ixgbe/ixgbe.c
  stable/8/sys/dev/mxge/if_mxge.c
  stable/8/sys/net/if_var.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/cxgb/cxgb_sge.c
==============================================================================
--- stable/8/sys/dev/cxgb/cxgb_sge.c	Thu Mar 18 16:55:47 2010	(r205282)
+++ stable/8/sys/dev/cxgb/cxgb_sge.c	Thu Mar 18 17:00:44 2010	(r205283)
@@ -228,6 +228,8 @@ static uint8_t flit_desc_map[] = {
 #define	TXQ_LOCK(qs)		mtx_lock(&(qs)->lock)	
 #define	TXQ_UNLOCK(qs)		mtx_unlock(&(qs)->lock)	
 #define	TXQ_RING_EMPTY(qs)	drbr_empty((qs)->port->ifp, (qs)->txq[TXQ_ETH].txq_mr)
+#define	TXQ_RING_NEEDS_ENQUEUE(qs)					\
+	drbr_needs_enqueue((qs)->port->ifp, (qs)->txq[TXQ_ETH].txq_mr)
 #define	TXQ_RING_FLUSH(qs)	drbr_flush((qs)->port->ifp, (qs)->txq[TXQ_ETH].txq_mr)
 #define	TXQ_RING_DEQUEUE_COND(qs, func, arg)				\
 	drbr_dequeue_cond((qs)->port->ifp, (qs)->txq[TXQ_ETH].txq_mr, func, arg)
@@ -1712,7 +1714,7 @@ cxgb_transmit_locked(struct ifnet *ifp, 
 	 * - there is space in hardware transmit queue 
 	 */
 	if (check_pkt_coalesce(qs) == 0 &&
-	    TXQ_RING_EMPTY(qs) && avail > 4) {
+	    !TXQ_RING_NEEDS_ENQUEUE(qs) && avail > 4) {
 		if (t3_encap(qs, &m)) {
 			if (m != NULL &&
 			    (error = drbr_enqueue(ifp, br, m)) != 0) 

Modified: stable/8/sys/dev/e1000/if_em.c
==============================================================================
--- stable/8/sys/dev/e1000/if_em.c	Thu Mar 18 16:55:47 2010	(r205282)
+++ stable/8/sys/dev/e1000/if_em.c	Thu Mar 18 17:00:44 2010	(r205283)
@@ -1032,7 +1032,7 @@ em_mq_start_locked(struct ifnet *ifp, st
 	    || (!adapter->link_active)) {
 		error = drbr_enqueue(ifp, adapter->br, m);
 		return (error);
-	} else if (drbr_empty(ifp, adapter->br) &&
+	} else if (!drbr_needs_enqueue(ifp, adapter->br) &&
 	    (adapter->num_tx_desc_avail > EM_TX_OP_THRESHOLD)) {
 		if ((error = em_xmit(adapter, &m)) != 0) {
 			if (m != NULL)

Modified: stable/8/sys/dev/e1000/if_igb.c
==============================================================================
--- stable/8/sys/dev/e1000/if_igb.c	Thu Mar 18 16:55:47 2010	(r205282)
+++ stable/8/sys/dev/e1000/if_igb.c	Thu Mar 18 17:00:44 2010	(r205283)
@@ -853,7 +853,7 @@ igb_mq_start_locked(struct ifnet *ifp, s
 		goto process;
 
 	/* If nothing queued go right to xmit */
-	if (drbr_empty(ifp, txr->br)) {
+	if (!drbr_needs_enqueue(ifp, txr->br)) {
 		if ((err = igb_xmit(txr, &m)) != 0) {
 			if (m != NULL)
 				err = drbr_enqueue(ifp, txr->br, m);

Modified: stable/8/sys/dev/ixgbe/ixgbe.c
==============================================================================
--- stable/8/sys/dev/ixgbe/ixgbe.c	Thu Mar 18 16:55:47 2010	(r205282)
+++ stable/8/sys/dev/ixgbe/ixgbe.c	Thu Mar 18 17:00:44 2010	(r205283)
@@ -768,7 +768,7 @@ ixgbe_mq_start_locked(struct ifnet *ifp,
 		goto process;
 
 	/* If nothing queued go right to xmit */
-	if (drbr_empty(ifp, txr->br)) {
+	if (!drbr_needs_enqueue(ifp, txr->br)) {
 		if (ixgbe_xmit(txr, &m)) {
 			if (m && (err = drbr_enqueue(ifp, txr->br, m)) != 0)
                                 return (err);

Modified: stable/8/sys/dev/mxge/if_mxge.c
==============================================================================
--- stable/8/sys/dev/mxge/if_mxge.c	Thu Mar 18 16:55:47 2010	(r205282)
+++ stable/8/sys/dev/mxge/if_mxge.c	Thu Mar 18 17:00:44 2010	(r205283)
@@ -2249,7 +2249,7 @@ mxge_transmit_locked(struct mxge_slice_s
 		return (err);
 	}
 
-	if (drbr_empty(ifp, tx->br) &&
+	if (!drbr_needs_enqueue(ifp, tx->br) &&
 	    ((tx->mask - (tx->req - tx->done)) > tx->max_desc)) {
 		/* let BPF see it */
 		BPF_MTAP(ifp, m);

Modified: stable/8/sys/net/if_var.h
==============================================================================
--- stable/8/sys/net/if_var.h	Thu Mar 18 16:55:47 2010	(r205282)
+++ stable/8/sys/net/if_var.h	Thu Mar 18 17:00:44 2010	(r205283)
@@ -602,12 +602,8 @@ drbr_flush(struct ifnet *ifp, struct buf
 	struct mbuf *m;
 
 #ifdef ALTQ
-	if (ifp != NULL && ALTQ_IS_ENABLED(&ifp->if_snd)) {
-		while (!IFQ_IS_EMPTY(&ifp->if_snd)) {
-			IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
-			m_freem(m);
-		}
-	}
+	if (ifp != NULL && ALTQ_IS_ENABLED(&ifp->if_snd))
+		IFQ_PURGE(&ifp->if_snd);
 #endif	
 	while ((m = buf_ring_dequeue_sc(br)) != NULL)
 		m_freem(m);
@@ -628,7 +624,7 @@ drbr_dequeue(struct ifnet *ifp, struct b
 	struct mbuf *m;
 
 	if (ALTQ_IS_ENABLED(&ifp->if_snd)) {	
-		IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
+		IFQ_DEQUEUE(&ifp->if_snd, m);
 		return (m);
 	}
 #endif
@@ -641,11 +637,15 @@ drbr_dequeue_cond(struct ifnet *ifp, str
 {
 	struct mbuf *m;
 #ifdef ALTQ
-	/*
-	 * XXX need to evaluate / requeue 
-	 */
-	if (ALTQ_IS_ENABLED(&ifp->if_snd)) {	
-		IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
+	if (ALTQ_IS_ENABLED(&ifp->if_snd)) {
+		IFQ_LOCK(&ifp->if_snd);
+		IFQ_POLL_NOLOCK(&ifp->if_snd, m);
+		if (m != NULL && func(m, arg) == 0) {
+			IFQ_UNLOCK(&ifp->if_snd);
+			return (NULL);
+		}
+		IFQ_DEQUEUE_NOLOCK(&ifp->if_snd, m);
+		IFQ_UNLOCK(&ifp->if_snd);
 		return (m);
 	}
 #endif
@@ -661,12 +661,22 @@ drbr_empty(struct ifnet *ifp, struct buf
 {
 #ifdef ALTQ
 	if (ALTQ_IS_ENABLED(&ifp->if_snd))
-		return (IFQ_DRV_IS_EMPTY(&ifp->if_snd));
+		return (IFQ_IS_EMPTY(&ifp->if_snd));
 #endif
 	return (buf_ring_empty(br));
 }
 
 static __inline int
+drbr_needs_enqueue(struct ifnet *ifp, struct buf_ring *br)
+{
+#ifdef ALTQ
+	if (ALTQ_IS_ENABLED(&ifp->if_snd))
+		return (1);
+#endif
+	return (!buf_ring_empty(br));
+}
+
+static __inline int
 drbr_inuse(struct ifnet *ifp, struct buf_ring *br)
 {
 #ifdef ALTQ


More information about the svn-src-stable-8 mailing list