Author: arybchik
Date: Wed Feb 18 06:19:35 2015
New Revision: 278938
URL: https://svnweb.freebsd.org/changeset/base/278938

Log:
  sfxge: add driver context member with number of transmit queues
  
  Sponsored by:   Solarflare Communications, Inc.
  Approved by:    gnn (mentor)

Modified:
  head/sys/dev/sfxge/sfxge.h
  head/sys/dev/sfxge/sfxge_tx.c
  head/sys/dev/sfxge/sfxge_tx.h

Modified: head/sys/dev/sfxge/sfxge.h
==============================================================================
--- head/sys/dev/sfxge/sfxge.h  Wed Feb 18 06:18:51 2015        (r278937)
+++ head/sys/dev/sfxge/sfxge.h  Wed Feb 18 06:19:35 2015        (r278938)
@@ -259,6 +259,8 @@ struct sfxge_softc {
        struct mtx                      tx_lock __aligned(CACHE_LINE_SIZE);
        char                            tx_lock_name[SFXGE_LOCK_NAME_MAX];
 #endif
+
+       unsigned int                    txq_count;
 };
 
 #define        SFXGE_LINK_UP(sc) ((sc)->port.link_mode != EFX_LINK_DOWN)

Modified: head/sys/dev/sfxge/sfxge_tx.c
==============================================================================
--- head/sys/dev/sfxge/sfxge_tx.c       Wed Feb 18 06:18:51 2015        
(r278937)
+++ head/sys/dev/sfxge/sfxge_tx.c       Wed Feb 18 06:19:35 2015        
(r278938)
@@ -649,7 +649,7 @@ sfxge_if_qflush(struct ifnet *ifp)
 
        sc = ifp->if_softc;
 
-       for (i = 0; i < SFXGE_TXQ_IP_TCP_UDP_CKSUM + SFXGE_TX_SCALE(sc); i++)
+       for (i = 0; i < sc->txq_count; i++)
                sfxge_tx_qdpl_flush(sc->txq[i]);
 }
 
@@ -1280,13 +1280,9 @@ sfxge_tx_stop(struct sfxge_softc *sc)
 {
        int index;
 
-       index = SFXGE_TX_SCALE(sc);
+       index = sc->txq_count;
        while (--index >= 0)
-               sfxge_tx_qstop(sc, SFXGE_TXQ_IP_TCP_UDP_CKSUM + index);
-
-       sfxge_tx_qstop(sc, SFXGE_TXQ_IP_CKSUM);
-
-       sfxge_tx_qstop(sc, SFXGE_TXQ_NON_CKSUM);
+               sfxge_tx_qstop(sc, index);
 
        /* Tear down the transmit module */
        efx_tx_fini(sc->enp);
@@ -1302,30 +1298,17 @@ sfxge_tx_start(struct sfxge_softc *sc)
        if ((rc = efx_tx_init(sc->enp)) != 0)
                return (rc);
 
-       if ((rc = sfxge_tx_qstart(sc, SFXGE_TXQ_NON_CKSUM)) != 0)
-               goto fail;
-
-       if ((rc = sfxge_tx_qstart(sc, SFXGE_TXQ_IP_CKSUM)) != 0)
-               goto fail2;
-
-       for (index = 0; index < SFXGE_TX_SCALE(sc); index++) {
-               if ((rc = sfxge_tx_qstart(sc, SFXGE_TXQ_IP_TCP_UDP_CKSUM +
-                   index)) != 0)
-                       goto fail3;
+       for (index = 0; index < sc->txq_count; index++) {
+               if ((rc = sfxge_tx_qstart(sc, index)) != 0)
+                       goto fail;
        }
 
        return (0);
 
-fail3:
+fail:
        while (--index >= 0)
-               sfxge_tx_qstop(sc, SFXGE_TXQ_IP_TCP_UDP_CKSUM + index);
-
-       sfxge_tx_qstop(sc, SFXGE_TXQ_IP_CKSUM);
-
-fail2:
-       sfxge_tx_qstop(sc, SFXGE_TXQ_NON_CKSUM);
+               sfxge_tx_qstop(sc, index);
 
-fail:
        efx_tx_fini(sc->enp);
 
        return (rc);
@@ -1536,9 +1519,7 @@ sfxge_tx_stat_handler(SYSCTL_HANDLER_ARG
 
        /* Sum across all TX queues */
        sum = 0;
-       for (index = 0;
-            index < SFXGE_TXQ_IP_TCP_UDP_CKSUM + SFXGE_TX_SCALE(sc);
-            index++)
+       for (index = 0; index < sc->txq_count; index++)
                sum += *(unsigned long *)((caddr_t)sc->txq[index] +
                                          sfxge_tx_stats[id].offset);
 
@@ -1571,12 +1552,11 @@ sfxge_tx_fini(struct sfxge_softc *sc)
 {
        int index;
 
-       index = SFXGE_TX_SCALE(sc);
+       index = sc->txq_count;
        while (--index >= 0)
-               sfxge_tx_qfini(sc, SFXGE_TXQ_IP_TCP_UDP_CKSUM + index);
+               sfxge_tx_qfini(sc, index);
 
-       sfxge_tx_qfini(sc, SFXGE_TXQ_IP_CKSUM);
-       sfxge_tx_qfini(sc, SFXGE_TXQ_NON_CKSUM);
+       sc->txq_count = 0;
 }
 
 
@@ -1592,6 +1572,12 @@ sfxge_tx_init(struct sfxge_softc *sc)
        KASSERT(intr->state == SFXGE_INTR_INITIALIZED,
            ("intr->state != SFXGE_INTR_INITIALIZED"));
 
+#ifdef SFXGE_HAVE_MQ
+       sc->txq_count = SFXGE_TXQ_NTYPES - 1 + sc->intr.n_alloc;
+#else
+       sc->txq_count = SFXGE_TXQ_NTYPES;
+#endif
+
        sc->txqs_node = SYSCTL_ADD_NODE(
                device_get_sysctl_ctx(sc->dev),
                SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)),
@@ -1610,8 +1596,10 @@ sfxge_tx_init(struct sfxge_softc *sc)
            SFXGE_TXQ_IP_CKSUM, 0)) != 0)
                goto fail2;
 
-       for (index = 0; index < SFXGE_TX_SCALE(sc); index++) {
-               if ((rc = sfxge_tx_qinit(sc, SFXGE_TXQ_IP_TCP_UDP_CKSUM + index,
+       for (index = 0;
+            index < sc->txq_count - SFXGE_TXQ_NTYPES + 1;
+            index++) {
+               if ((rc = sfxge_tx_qinit(sc, SFXGE_TXQ_NTYPES - 1 + index,
                    SFXGE_TXQ_IP_TCP_UDP_CKSUM, index)) != 0)
                        goto fail3;
        }
@@ -1621,15 +1609,16 @@ sfxge_tx_init(struct sfxge_softc *sc)
        return (0);
 
 fail3:
-       sfxge_tx_qfini(sc, SFXGE_TXQ_IP_CKSUM);
-
        while (--index >= 0)
                sfxge_tx_qfini(sc, SFXGE_TXQ_IP_TCP_UDP_CKSUM + index);
 
+       sfxge_tx_qfini(sc, SFXGE_TXQ_IP_CKSUM);
+
 fail2:
        sfxge_tx_qfini(sc, SFXGE_TXQ_NON_CKSUM);
 
 fail:
 fail_txq_node:
+       sc->txq_count = 0;
        return (rc);
 }

Modified: head/sys/dev/sfxge/sfxge_tx.h
==============================================================================
--- head/sys/dev/sfxge/sfxge_tx.h       Wed Feb 18 06:18:51 2015        
(r278937)
+++ head/sys/dev/sfxge/sfxge_tx.h       Wed Feb 18 06:19:35 2015        
(r278938)
@@ -124,10 +124,8 @@ enum sfxge_txq_type {
 
 #ifdef SFXGE_HAVE_MQ
 #define        SFXGE_TX_LOCK(txq)              (&(txq)->lock)
-#define        SFXGE_TX_SCALE(sc)              ((sc)->intr.n_alloc)
 #else
 #define        SFXGE_TX_LOCK(txq)              (&(txq)->sc->tx_lock)
-#define        SFXGE_TX_SCALE(sc)              1
 #endif
 
 #define        SFXGE_TXQ_LOCK_INIT(_txq, _ifname, _txq_index)                  
\
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to