From owner-svn-src-all@freebsd.org Sat Mar 14 02:11:35 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 74C80273761; Sat, 14 Mar 2020 02:11:35 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48fQzV6rL8z4Rt0; Sat, 14 Mar 2020 02:11:34 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A3CF5FC06; Sat, 14 Mar 2020 02:11:34 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02E2BYkC063743; Sat, 14 Mar 2020 02:11:34 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02E2BYYb063742; Sat, 14 Mar 2020 02:11:34 GMT (envelope-from np@FreeBSD.org) Message-Id: <202003140211.02E2BYYb063742@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Sat, 14 Mar 2020 02:11:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r358983 - stable/12/sys/dev/cxgbe X-SVN-Group: stable-12 X-SVN-Commit-Author: np X-SVN-Commit-Paths: stable/12/sys/dev/cxgbe X-SVN-Commit-Revision: 358983 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Mar 2020 02:11:35 -0000 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