Author: np
Date: Sat Mar 14 02:11:34 2020
New Revision: 358983
URL: https://svnweb.freebsd.org/changeset/base/358983

Log:
  MFC r357606:
  
  cxgbe(4): Add native netmap support to the main interface.
  
  This means that extra virtual interfaces (VIs) created with
  hw.cxgbe.num_vis are no longer required to use netmap.  Use this
  tunable to enable native netmap support on the main interface:
  
  hw.cxgbe.native_netmap="3"
  
  There is no change in default behavior.
  
  Suggested by: jch@
  Sponsored by: Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/t4_main.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/t4_main.c
==============================================================================
--- stable/12/sys/dev/cxgbe/t4_main.c   Sat Mar 14 02:05:12 2020        
(r358982)
+++ stable/12/sys/dev/cxgbe/t4_main.c   Sat Mar 14 02:11:34 2020        
(r358983)
@@ -389,6 +389,22 @@ SYSCTL_INT(_hw_cxgbe_toe_rexmt_backoff, OID_AUTO, 15, 
 #endif
 
 #ifdef DEV_NETMAP
+#define NN_MAIN_VI     (1 << 0)        /* Native netmap on the main VI */
+#define NN_EXTRA_VI    (1 << 1)        /* Native netmap on the extra VI(s) */
+static int t4_native_netmap = NN_EXTRA_VI;
+SYSCTL_INT(_hw_cxgbe, OID_AUTO, native_netmap, CTLFLAG_RDTUN, 
&t4_native_netmap,
+    0, "Native netmap support.  bit 0 = main VI, bit 1 = extra VIs");
+
+#define NNMTXQ 8
+static int t4_nnmtxq = -NNMTXQ;
+SYSCTL_INT(_hw_cxgbe, OID_AUTO, nnmtxq, CTLFLAG_RDTUN, &t4_nnmtxq, 0,
+    "Number of netmap TX queues");
+
+#define NNMRXQ 8
+static int t4_nnmrxq = -NNMRXQ;
+SYSCTL_INT(_hw_cxgbe, OID_AUTO, nnmrxq, CTLFLAG_RDTUN, &t4_nnmrxq, 0,
+    "Number of netmap RX queues");
+
 #define NNMTXQ_VI 2
 static int t4_nnmtxq_vi = -NNMTXQ_VI;
 SYSCTL_INT(_hw_cxgbe, OID_AUTO, nnmtxq_vi, CTLFLAG_RDTUN, &t4_nnmtxq_vi, 0,
@@ -587,6 +603,8 @@ struct intrs_and_queues {
        uint16_t nrxq;          /* # of NIC rxq's for each port */
        uint16_t nofldtxq;      /* # of TOE/ETHOFLD txq's for each port */
        uint16_t nofldrxq;      /* # of TOE rxq's for each port */
+       uint16_t nnmtxq;        /* # of netmap txq's */
+       uint16_t nnmrxq;        /* # of netmap rxq's */
 
        /* The vcxgbe/vcxl interfaces use these and not the ones above. */
        uint16_t ntxq_vi;       /* # of NIC txq's */
@@ -1209,10 +1227,16 @@ t4_attach(device_t dev)
        }
 #endif
 #ifdef DEV_NETMAP
-       if (num_vis > 1) {
-               s->nnmrxq = nports * (num_vis - 1) * iaq.nnmrxq_vi;
-               s->nnmtxq = nports * (num_vis - 1) * iaq.nnmtxq_vi;
+       s->nnmrxq = 0;
+       s->nnmtxq = 0;
+       if (t4_native_netmap & NN_MAIN_VI) {
+               s->nnmrxq += nports * iaq.nnmrxq;
+               s->nnmtxq += nports * iaq.nnmtxq;
        }
+       if (num_vis > 1 && t4_native_netmap & NN_EXTRA_VI) {
+               s->nnmrxq += nports * (num_vis - 1) * iaq.nnmrxq_vi;
+               s->nnmtxq += nports * (num_vis - 1) * iaq.nnmtxq_vi;
+       }
        s->neq += s->nnmtxq + s->nnmrxq;
        s->niq += s->nnmrxq;
 
@@ -1305,14 +1329,17 @@ t4_attach(device_t dev)
                        ofld_rqidx += vi->nofldrxq;
 #endif
 #ifdef DEV_NETMAP
-                       if (j > 0) {
-                               vi->first_nm_rxq = nm_rqidx;
-                               vi->first_nm_txq = nm_tqidx;
+                       vi->first_nm_rxq = nm_rqidx;
+                       vi->first_nm_txq = nm_tqidx;
+                       if (j == 0) {
+                               vi->nnmrxq = iaq.nnmrxq;
+                               vi->nnmtxq = iaq.nnmtxq;
+                       } else {
                                vi->nnmrxq = iaq.nnmrxq_vi;
                                vi->nnmtxq = iaq.nnmtxq_vi;
-                               nm_rqidx += vi->nnmrxq;
-                               nm_tqidx += vi->nnmtxq;
                        }
+                       nm_rqidx += vi->nnmrxq;
+                       nm_tqidx += vi->nnmtxq;
 #endif
                }
        }
@@ -3151,10 +3178,10 @@ fixup_devlog_params(struct adapter *sc)
 static void
 update_nirq(struct intrs_and_queues *iaq, int nports)
 {
-       int extra = T4_EXTRA_INTR;
 
-       iaq->nirq = extra;
-       iaq->nirq += nports * (iaq->nrxq + iaq->nofldrxq);
+       iaq->nirq = T4_EXTRA_INTR;
+       iaq->nirq += nports * max(iaq->nrxq, iaq->nnmrxq);
+       iaq->nirq += nports * iaq->nofldrxq;
        iaq->nirq += nports * (iaq->num_vis - 1) *
            max(iaq->nrxq_vi, iaq->nnmrxq_vi);
        iaq->nirq += nports * (iaq->num_vis - 1) * iaq->nofldrxq_vi;
@@ -3193,8 +3220,14 @@ calculate_iaq(struct adapter *sc, struct intrs_and_que
        }
 #endif
 #ifdef DEV_NETMAP
-       iaq->nnmtxq_vi = t4_nnmtxq_vi;
-       iaq->nnmrxq_vi = t4_nnmrxq_vi;
+       if (t4_native_netmap & NN_MAIN_VI) {
+               iaq->nnmtxq = t4_nnmtxq;
+               iaq->nnmrxq = t4_nnmrxq;
+       }
+       if (t4_native_netmap & NN_EXTRA_VI) {
+               iaq->nnmtxq_vi = t4_nnmtxq_vi;
+               iaq->nnmrxq_vi = t4_nnmrxq_vi;
+       }
 #endif
 
        update_nirq(iaq, nports);
@@ -3252,6 +3285,8 @@ calculate_iaq(struct adapter *sc, struct intrs_and_que
                        do {
                                iaq->nrxq--;
                        } while (!powerof2(iaq->nrxq));
+                       if (iaq->nnmrxq > iaq->nrxq)
+                               iaq->nnmrxq = iaq->nrxq;
                }
                if (iaq->nofldrxq > 1)
                        iaq->nofldrxq >>= 1;
@@ -3273,10 +3308,14 @@ calculate_iaq(struct adapter *sc, struct intrs_and_que
        device_printf(sc->dev, "running with minimal number of queues.  "
            "itype %d, navail %u.\n", itype, navail);
        iaq->nirq = 1;
-       MPASS(iaq->nrxq == 1);
+       iaq->nrxq = 1;
        iaq->ntxq = 1;
-       if (iaq->nofldrxq > 1)
+       if (iaq->nofldrxq > 0) {
+               iaq->nofldrxq = 1;
                iaq->nofldtxq = 1;
+       }
+       iaq->nnmtxq = 0;
+       iaq->nnmrxq = 0;
 done:
        MPASS(iaq->num_vis > 0);
        if (iaq->num_vis > 1) {
@@ -10591,6 +10630,8 @@ tweak_tunables(void)
 #endif
 
 #ifdef DEV_NETMAP
+       calculate_nqueues(&t4_nnmtxq, nc, NNMTXQ);
+       calculate_nqueues(&t4_nnmrxq, nc, NNMRXQ);
        calculate_nqueues(&t4_nnmtxq_vi, nc, NNMTXQ_VI);
        calculate_nqueues(&t4_nnmrxq_vi, nc, NNMRXQ_VI);
 #endif
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to