svn commit: r357606 - head/sys/dev/cxgbe
Navdeep Parhar
np at FreeBSD.org
Wed Feb 5 22:29:02 UTC 2020
Author: np
Date: Wed Feb 5 22:29:01 2020
New Revision: 357606
URL: https://svnweb.freebsd.org/changeset/base/357606
Log:
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@
MFC after: 2 weeks
Sponsored by: Chelsio Communications
Modified:
head/sys/dev/cxgbe/t4_main.c
Modified: head/sys/dev/cxgbe/t4_main.c
==============================================================================
--- head/sys/dev/cxgbe/t4_main.c Wed Feb 5 21:30:31 2020 (r357605)
+++ head/sys/dev/cxgbe/t4_main.c Wed Feb 5 22:29:01 2020 (r357606)
@@ -401,6 +401,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,
@@ -621,6 +637,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 */
@@ -1247,10 +1265,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;
@@ -1344,14 +1368,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
}
}
@@ -3316,10 +3343,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;
@@ -3358,8 +3385,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);
@@ -3417,6 +3450,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;
@@ -3438,10 +3473,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) {
@@ -10892,6 +10931,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
More information about the svn-src-head
mailing list