Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci/ixgbe TX multiqueue. If you want to disable it, ...



details:   https://anonhg.NetBSD.org/src/rev/e77bfa4c35c4
branches:  trunk
changeset: 821320:e77bfa4c35c4
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Feb 01 10:47:13 2017 +0000

description:
TX multiqueue. If you want to disable it, enable IXGBE_LEGACY_TX
in ixgbe_netbsd.h

diffstat:

 sys/dev/pci/ixgbe/ix_txrx.c      |  87 +++++++++++++--------------------------
 sys/dev/pci/ixgbe/ixgbe.c        |  58 ++++++++++++++++++++-----
 sys/dev/pci/ixgbe/ixgbe.h        |  20 ++++-----
 sys/dev/pci/ixgbe/ixgbe_netbsd.h |   4 +-
 sys/dev/pci/ixgbe/ixv.c          |  25 ++++++----
 5 files changed, 101 insertions(+), 93 deletions(-)

diffs (truncated from 516 to 300 lines):

diff -r 4e49f5986166 -r e77bfa4c35c4 sys/dev/pci/ixgbe/ix_txrx.c
--- a/sys/dev/pci/ixgbe/ix_txrx.c       Wed Feb 01 10:18:27 2017 +0000
+++ b/sys/dev/pci/ixgbe/ix_txrx.c       Wed Feb 01 10:47:13 2017 +0000
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /*$FreeBSD: head/sys/dev/ixgbe/ix_txrx.c 301538 2016-06-07 04:51:50Z sephe $*/
-/*$NetBSD: ix_txrx.c,v 1.17 2017/01/30 05:02:43 msaitoh Exp $*/
+/*$NetBSD: ix_txrx.c,v 1.18 2017/02/01 10:47:13 msaitoh Exp $*/
 
 #include "opt_inet.h"
 #include "opt_inet6.h"
@@ -126,7 +126,6 @@
 
 static void    ixgbe_setup_hw_rsc(struct rx_ring *);
 
-#ifdef IXGBE_LEGACY_TX
 /*********************************************************************
  *  Transmit entry point
  *
@@ -204,7 +203,7 @@
        return;
 }
 
-#else /* ! IXGBE_LEGACY_TX */
+#ifndef IXGBE_LEGACY_TX
 
 /*
 ** Multiqueue Transmit Entry Point
@@ -214,7 +213,6 @@
 ixgbe_mq_start(struct ifnet *ifp, struct mbuf *m)
 {
        struct adapter  *adapter = ifp->if_softc;
-       struct ix_queue *que;
        struct tx_ring  *txr;
        int             i, err = 0;
 #ifdef RSS
@@ -228,6 +226,7 @@
         * If everything is setup correctly, it should be the
         * same bucket that the current CPU we're on is.
         */
+#if 0
 #if __FreeBSD_version < 1100054
        if (m->m_flags & M_FLOWID) {
 #else
@@ -244,26 +243,29 @@
                                    "(%d)\n", bucket_id, adapter->num_queues);
 #endif
                } else
-#endif
+#endif /* RSS */
                        i = m->m_pkthdr.flowid % adapter->num_queues;
        } else
-               i = curcpu % adapter->num_queues;
+#endif
+               i = cpu_index(curcpu()) % adapter->num_queues;
 
        /* Check for a hung queue and pick alternative */
        if (((1 << i) & adapter->active_queues) == 0)
-               i = ffsl(adapter->active_queues);
+               i = ffs64(adapter->active_queues);
 
        txr = &adapter->tx_rings[i];
-       que = &adapter->queues[i];
 
-       err = drbr_enqueue(ifp, txr->br, m);
-       if (err)
+       err = pcq_put(txr->txr_interq, m);
+       if (err == false) {
+               m_freem(m);
+               txr->pcq_drops.ev_count++;
                return (err);
+       }
        if (IXGBE_TX_TRYLOCK(txr)) {
                ixgbe_mq_start_locked(ifp, txr);
                IXGBE_TX_UNLOCK(txr);
        } else
-               softint_schedule(txr->txq_si);
+               softint_schedule(txr->txr_si);
 
        return (0);
 }
@@ -280,26 +282,12 @@
                return (ENETDOWN);
 
        /* Process the queue */
-#if __FreeBSD_version < 901504
-       next = drbr_dequeue(ifp, txr->br);
-       while (next != NULL) {
-               if ((err = ixgbe_xmit(txr, &next)) != 0) {
-                       if (next != NULL)
-                               err = drbr_enqueue(ifp, txr->br, next);
-#else
-       while ((next = drbr_peek(ifp, txr->br)) != NULL) {
-               if ((err = ixgbe_xmit(txr, &next)) != 0) {
-                       if (next == NULL) {
-                               drbr_advance(ifp, txr->br);
-                       } else {
-                               drbr_putback(ifp, txr->br, next);
-                       }
-#endif
+       while ((next = pcq_get(txr->txr_interq)) != NULL) {
+               if ((err = ixgbe_xmit(txr, next)) != 0) {
+                       m_freem(next);
+                       /* All errors are counted in ixgbe_xmit() */
                        break;
                }
-#if __FreeBSD_version >= 901504
-               drbr_advance(ifp, txr->br);
-#endif
                enqueued++;
 #if 0 // this is VF-only
 #if __FreeBSD_version >= 1100036
@@ -311,14 +299,11 @@
                if (txr->tail < IXGBE_TDT(0) && next->m_flags & M_MCAST)
                        if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1);
 #endif
-#endif
+#endif /* 0 */
                /* Send a copy of the frame to the BPF listener */
                bpf_mtap(ifp, next);
                if ((ifp->if_flags & IFF_RUNNING) == 0)
                        break;
-#if __FreeBSD_version < 901504
-               next = drbr_dequeue(ifp, txr->br);
-#endif
        }
 
        if (txr->tx_avail < IXGBE_TX_CLEANUP_THRESHOLD)
@@ -331,36 +316,18 @@
  * Called from a taskqueue to drain queued transmit packets.
  */
 void
-ixgbe_deferred_mq_start(void *arg, int pending)
+ixgbe_deferred_mq_start(void *arg)
 {
        struct tx_ring *txr = arg;
        struct adapter *adapter = txr->adapter;
        struct ifnet *ifp = adapter->ifp;
 
        IXGBE_TX_LOCK(txr);
-       if (!drbr_empty(ifp, txr->br))
+       if (pcq_peek(txr->txr_interq) != NULL)
                ixgbe_mq_start_locked(ifp, txr);
        IXGBE_TX_UNLOCK(txr);
 }
 
-/*
- * Flush all ring buffers
- */
-void
-ixgbe_qflush(struct ifnet *ifp)
-{
-       struct adapter  *adapter = ifp->if_softc;
-       struct tx_ring  *txr = adapter->tx_rings;
-       struct mbuf     *m;
-
-       for (int i = 0; i < adapter->num_queues; i++, txr++) {
-               IXGBE_TX_LOCK(txr);
-               while ((m = buf_ring_dequeue_sc(txr->br)) != NULL)
-                       m_freem(m);
-               IXGBE_TX_UNLOCK(txr);
-       }
-       if_qflush(ifp);
-}
 #endif /* IXGBE_LEGACY_TX */
 
 
@@ -724,8 +691,13 @@
                }
        }
 #ifndef IXGBE_LEGACY_TX
-       if (txr->br != NULL)
-               buf_ring_free(txr->br, M_DEVBUF);
+       if (txr->txr_interq != NULL) {
+               struct mbuf *m;
+
+               while ((m = pcq_get(txr->txr_interq)) != NULL)
+                       m_freem(m);
+               pcq_destroy(txr->txr_interq);
+       }
 #endif
        if (txr->tx_buffers != NULL) {
                free(txr->tx_buffers, M_DEVBUF);
@@ -2325,9 +2297,8 @@
                }
 #ifndef IXGBE_LEGACY_TX
                /* Allocate a buf ring */
-               txr->br = buf_ring_alloc(IXGBE_BR_SIZE, M_DEVBUF,
-                   M_WAITOK, &txr->tx_mtx);
-               if (txr->br == NULL) {
+               txr->txr_interq = pcq_create(IXGBE_BR_SIZE, KM_SLEEP);
+               if (txr->txr_interq == NULL) {
                        aprint_error_dev(dev,
                            "Critical Failure setting up buf ring\n");
                        error = ENOMEM;
diff -r 4e49f5986166 -r e77bfa4c35c4 sys/dev/pci/ixgbe/ixgbe.c
--- a/sys/dev/pci/ixgbe/ixgbe.c Wed Feb 01 10:18:27 2017 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.c Wed Feb 01 10:47:13 2017 +0000
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /*$FreeBSD: head/sys/dev/ixgbe/if_ix.c 302384 2016-07-07 03:39:18Z sbruno $*/
-/*$NetBSD: ixgbe.c,v 1.66 2017/01/25 13:08:31 msaitoh Exp $*/
+/*$NetBSD: ixgbe.c,v 1.67 2017/02/01 10:47:13 msaitoh Exp $*/
 
 #include "opt_inet.h"
 #include "opt_inet6.h"
@@ -749,7 +749,7 @@
 
        for (int i = 0; i < adapter->num_queues; i++, que++, txr++) {
 #ifndef IXGBE_LEGACY_TX
-               softint_disestablish(txr->txq_si);
+               softint_disestablish(txr->txr_si);
 #endif
                softint_disestablish(que->que_si);
        }
@@ -1030,6 +1030,35 @@
        case SIOCSIFMTU:
                IOCTL_DEBUGOUT("ioctl: SIOCSIFMTU (Set Interface MTU)");
                break;
+#ifdef __NetBSD__
+       case SIOCINITIFADDR:
+               IOCTL_DEBUGOUT("ioctl: SIOCINITIFADDR");
+               break;
+       case SIOCGIFFLAGS:
+               IOCTL_DEBUGOUT("ioctl: SIOCGIFFLAGS");
+               break;
+       case SIOCGIFAFLAG_IN:
+               IOCTL_DEBUGOUT("ioctl: SIOCGIFAFLAG_IN");
+               break;
+       case SIOCGIFADDR:
+               IOCTL_DEBUGOUT("ioctl: SIOCGIFADDR");
+               break;
+       case SIOCGIFMTU:
+               IOCTL_DEBUGOUT("ioctl: SIOCGIFMTU (Get Interface MTU)");
+               break;
+       case SIOCGIFCAP:
+               IOCTL_DEBUGOUT("ioctl: SIOCGIFCAP (Get IF cap)");
+               break;
+       case SIOCGETHERCAP:
+               IOCTL_DEBUGOUT("ioctl: SIOCGETHERCAP (Get ethercap)");
+               break;
+       case SIOCGLIFADDR:
+               IOCTL_DEBUGOUT("ioctl: SIOCGLIFADDR (Get Interface addr)");
+               break;
+       case SIOCAIFADDR:
+               IOCTL_DEBUGOUT("ioctl: SIOCAIFADDR (add/chg IF alias)");
+               break;
+#endif
        default:
                IOCTL_DEBUGOUT1("ioctl: UNKNOWN (0x%X)", (int)command);
                break;
@@ -1540,7 +1569,7 @@
                IXGBE_TX_LOCK(txr);
                ixgbe_txeof(txr);
 #ifndef IXGBE_LEGACY_TX
-               if (!drbr_empty(ifp, txr->br))
+               if (pcq_peek(txr->txr_interq) != NULL)
                        ixgbe_mq_start_locked(ifp, txr);
 #else
                if (!IFQ_IS_EMPTY(&ifp->if_snd))
@@ -1601,7 +1630,7 @@
                if (!IFQ_IS_EMPTY(&ifp->if_snd))
                        ixgbe_start_locked(txr, ifp);
 #else
-               if (!drbr_empty(ifp, txr->br))
+               if (pcq_peek(txr->txr_interq) != NULL)
                        ixgbe_mq_start_locked(ifp, txr);
 #endif
                IXGBE_TX_UNLOCK(txr);
@@ -1626,7 +1655,7 @@
 
        if (more)
 #ifndef IXGBE_LEGACY_TX
-               softint_schedule(txr->txq_si);
+               softint_schedule(txr->txr_si);
 #else
                softint_schedule(que->que_si);
 #endif
@@ -1652,7 +1681,6 @@
        bool            more;
        u32             newitr = 0;
 
-
        /* Protect against spurious interrupts */
        if ((ifp->if_flags & IFF_RUNNING) == 0)
                return 0;
@@ -1673,7 +1701,7 @@
        if (!IFQ_IS_EMPTY(&adapter->ifp->if_snd))
                ixgbe_start_locked(txr, ifp);
 #else
-       if (!drbr_empty(ifp, txr->br))
+       if (pcq_peek(txr->txr_interq) != NULL)
                ixgbe_mq_start_locked(ifp, txr);
 #endif
        IXGBE_TX_UNLOCK(txr);
@@ -2562,7 +2590,7 @@
         * processing contexts.
         */



Home | Main Index | Thread Index | Old Index