From nobody Tue Mar 15 08:16:27 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id DD80F1A2D699; Tue, 15 Mar 2022 08:16:27 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KHmT75xBpz4Yjg; Tue, 15 Mar 2022 08:16:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647332187; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C4KF+7++PAvjetjzPIbV/BMv00mnvgi1M5VqJZbo4os=; b=hCzqVN8MBY6wQPy/DL6I51Ua+pOCoK9jinOXc3Tjoi656ZGvrxiG2BBRu7zRz7w4io2mY5 dKKCPCPGL0x8kcHUh6nlqPKcO4o9bvLrgoatxgxZKVFAbkISFaEBWV9NteELQaoyUKwsfx JWlNN5BdnkZibeLIkowRw9sGh+nD2h+bXSyMy8MC2ATF+smPujcrejAdroglH3SrMIaI8N el3iyYRVW8BFPXuJr/FoUIeJ2qSHKZoba662sgVG8d8u2A5q1R0BT7bdJOQwGzqwH17GFn 7VXXYBubiEjMA1sX37/5rwewGoppt8oRNg+Rm5A0q+jxNDbLuvbXbappiRF0BQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A72D01DCD6; Tue, 15 Mar 2022 08:16:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22F8GRX8064456; Tue, 15 Mar 2022 08:16:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22F8GRwP064455; Tue, 15 Mar 2022 08:16:27 GMT (envelope-from git) Date: Tue, 15 Mar 2022 08:16:27 GMT Message-Id: <202203150816.22F8GRwP064455@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wei Hu Subject: git: 80c3eb7bc64b - main - Hyper-V: hn: add switch to turn on and off RSC List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: whu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 80c3eb7bc64b745b2a0bda953e29a26e32dff9d7 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647332187; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C4KF+7++PAvjetjzPIbV/BMv00mnvgi1M5VqJZbo4os=; b=BKL869f/zny9XIPxvOoJ9jSoNtK1aiz9yryOYOPLK0OvHgWI/ybSc5yWgo4qJPf2/7K22k vdiFwvpjkt2AzQ6F7tp45tpWPhTsi6noXOuovlGWlqPTjnJnWxFe28g6BWCpRaM3pHW+bm SNibbe2UTvVYQG57amQjEkQfzrnKkXbuXwKqnBtGqqdmsfVY+kKIZMiujl05PnOr2IuDIY wS7Iy0gzeR+Kej7Y61r3fQrZNXNJxvkSD8+XiLxI9bynOlHLPCNVL23GPX3KYuTJiuR+mJ 1D3O98LXiJmZrrZ6U0+pGBi7bjSHDZB0bV1mTSnrX2MuUchF8Gnc48W5dhzfZg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1647332187; a=rsa-sha256; cv=none; b=S5E61kddgt96xtLRyujac95npS69gD40MJWB12jxjapybt8PIBRI9hiT/Q6PWLEblPfPtv SufkPvyK9DV6NdK2RgoMoygiM+gQbRMMwekU9QY9UAK8qlvEBkcB27Z0JzX0vL6c+IUjdx ru1qYfOUFM0+1vC6cKNA3n7wpu0gMxwlu3qFIcZ2dswJTA07RWb08NUOQDnP6wd+MpQ4Xm nfEdtdpf6c2zv9F2/m6aWdOFP1S9jfiz+j8MQBmwumY/cA2gBp3mX73r5yMxVT9S0qymCP iL66wKfSoaTCZfJx/mp1LR2fZEA40JqpQLIFVzj8db0uLHZmGDGJyowHR+bKgg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=80c3eb7bc64b745b2a0bda953e29a26e32dff9d7 commit 80c3eb7bc64b745b2a0bda953e29a26e32dff9d7 Author: Wei Hu AuthorDate: 2022-03-15 07:56:38 +0000 Commit: Wei Hu CommitDate: 2022-03-15 08:12:22 +0000 Hyper-V: hn: add switch to turn on and off RSC Currently RSC offloading is enabled by default. With this new change rsc will be disabled by default. By using sysctl we can enable and disable it. Reviewed by: whu Signed-off-by: Souradeep Chakrabarti Fixes: a491581f3f8df Enable vSwitch RSC support in hn netvsc driver MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D34507 --- sys/dev/hyperv/netvsc/hn_rndis.c | 9 ++++++++- sys/dev/hyperv/netvsc/hn_rndis.h | 1 + sys/dev/hyperv/netvsc/if_hn.c | 30 ++++++++++++++++++++++++++++++ sys/dev/hyperv/netvsc/if_hnvar.h | 5 +++++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/sys/dev/hyperv/netvsc/hn_rndis.c b/sys/dev/hyperv/netvsc/hn_rndis.c index 108950aa3f9b..58167312c9f3 100644 --- a/sys/dev/hyperv/netvsc/hn_rndis.c +++ b/sys/dev/hyperv/netvsc/hn_rndis.c @@ -579,6 +579,12 @@ done: return (error); } +int +hn_rndis_reconf_offload(struct hn_softc *sc, int mtu) +{ + return(hn_rndis_conf_offload(sc, mtu)); +} + static int hn_rndis_conf_offload(struct hn_softc *sc, int mtu) { @@ -725,7 +731,8 @@ hn_rndis_conf_offload(struct hn_softc *sc, int mtu) /* RSC offload */ if (hwcaps.ndis_hdr.ndis_rev >= NDIS_OFFLOAD_PARAMS_REV_3) { - if (hwcaps.ndis_rsc.ndis_ip4 && hwcaps.ndis_rsc.ndis_ip6) { + if (hwcaps.ndis_rsc.ndis_ip4 && hwcaps.ndis_rsc.ndis_ip6 && + sc->hn_rsc_ctrl) { params.ndis_rsc_ip4 = NDIS_OFFLOAD_RSC_ON; params.ndis_rsc_ip6 = NDIS_OFFLOAD_RSC_ON; } else { diff --git a/sys/dev/hyperv/netvsc/hn_rndis.h b/sys/dev/hyperv/netvsc/hn_rndis.h index 4610d5a10526..6e4db9b0bb30 100644 --- a/sys/dev/hyperv/netvsc/hn_rndis.h +++ b/sys/dev/hyperv/netvsc/hn_rndis.h @@ -46,5 +46,6 @@ int hn_rndis_get_mtu(struct hn_softc *sc, uint32_t *mtu); int hn_rndis_set_rxfilter(struct hn_softc *sc, uint32_t filter); void hn_rndis_rx_ctrl(struct hn_softc *sc, const void *data, int dlen); +int hn_rndis_reconf_offload(struct hn_softc *sc, int mtu); #endif /* !_HN_RNDIS_H_ */ diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c index 3d13bd696c94..95f62902fe6b 100644 --- a/sys/dev/hyperv/netvsc/if_hn.c +++ b/sys/dev/hyperv/netvsc/if_hn.c @@ -454,6 +454,8 @@ static void hn_start_txeof(struct hn_tx_ring *); static void hn_start_txeof_taskfunc(void *, int); #endif +static int hn_rsc_sysctl(SYSCTL_HANDLER_ARGS); + SYSCTL_NODE(_hw, OID_AUTO, hn, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Hyper-V network interface"); @@ -2370,6 +2372,10 @@ hn_attach(device_t dev) "Accurate BPF for transparent VF"); } + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rsc_switch", + CTLTYPE_UINT | CTLFLAG_RW, sc, 0, hn_rsc_sysctl, "A", + "switch to rsc"); + /* * Setup the ifmedia, which has been initialized earlier. */ @@ -4567,6 +4573,30 @@ hn_rxfilter_sysctl(SYSCTL_HANDLER_ARGS) return sysctl_handle_string(oidp, filter_str, sizeof(filter_str), req); } +static int +hn_rsc_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + uint32_t mtu; + int error; + HN_LOCK(sc); + error = hn_rndis_get_mtu(sc, &mtu); + if (error) { + if_printf(sc->hn_ifp, "failed to get mtu\n"); + goto back; + } + error = SYSCTL_OUT(req, &(sc->hn_rsc_ctrl), sizeof(sc->hn_rsc_ctrl)); + if (error || req->newptr == NULL) + goto back; + + error = SYSCTL_IN(req, &(sc->hn_rsc_ctrl), sizeof(sc->hn_rsc_ctrl)); + if (error) + goto back; + error = hn_rndis_reconf_offload(sc, mtu); +back: + HN_UNLOCK(sc); + return (error); +} #ifndef RSS static int diff --git a/sys/dev/hyperv/netvsc/if_hnvar.h b/sys/dev/hyperv/netvsc/if_hnvar.h index 27d93db5395e..7b23f0ec7cbf 100644 --- a/sys/dev/hyperv/netvsc/if_hnvar.h +++ b/sys/dev/hyperv/netvsc/if_hnvar.h @@ -282,6 +282,11 @@ struct hn_softc { u_int hn_saved_tsomax; u_int hn_saved_tsosegcnt; u_int hn_saved_tsosegsz; + + /* + * RSC switch, default off + */ + u_int hn_rsc_ctrl; }; #define HN_FLAG_RXBUF_CONNECTED 0x0001