From nobody Fri Sep 15 09:21:05 2023 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 4Rn7wK5VqVz4tSW9; Fri, 15 Sep 2023 09:21:05 +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 4Rn7wK53Kzz4ZLC; Fri, 15 Sep 2023 09:21:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694769665; 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=P8VFlfNh1DeBWIQ0g3Hm0eb2YE4iKgppzhhAXYvo3cQ=; b=Z1vorlauQLKrEIAxv/s6tjeQKW4iVjJ0TPly4qg99SvEfEcr8Kj+NrEMCf/mh/O2XxfL4A 4WkVmtH76gaA1/7vq9XRSGp9qPLCFStzbAos5lsx3SgoGal8BBYtGGfY7ggTk0Q6M6wo+U pgb2hk9uimuJGE82W4FPX5BvbO9iU1GAygaRl5Y4wFhWz+25tfOzVXiieeFRMa5utNeiQ3 RhHUqcn+4+6e5lMUFT3RW5NyQfROBcL5mPYt54SXZApnZY4yANBlGiO3UYw5oFe3M5Q2P6 RU0QuUMAWvrj6zC+WVAKkxYG1AWB5xELw5I83r6ITkSwRX8fl7yzQ6T+v5RxgQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694769665; a=rsa-sha256; cv=none; b=ntEu6yO2cCmnjwo8NVsCOE9ojlfAMgQhBiDF/dAy1msihtveZ1sm/9VA6c4rcrdqLhYoSY /m1dIEhRWYf4y7o+xx202PaLlSsvtShF1Zrgn6Bu7vfa01qz95B3RQsl53zL+Yga6+bp/P TV/6YVMcqPreaqKClhGpVeicoYwUNXzZatOp2wKLlDJ2JYvi0/2OGXXFfriYAsq4A2CN0D 09LXBaGMTZWnNjOGScpEJOz/EkfHqvs3XeLauUjEe8j53xgLRWUfEYJM7HcDh47bCpQVPZ 7oHxcDiM78xL/AgrhUwPJpi3V4ZXcPIvU8LBh9VdZz2tL/QxhKc6IXYfrjGEcg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694769665; 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=P8VFlfNh1DeBWIQ0g3Hm0eb2YE4iKgppzhhAXYvo3cQ=; b=NGsaljWOplD/Syf55IRlBb9CZ1D67I2UpnMXf5QB3NA/lqcCakvd+zcKrUjceY7Pxe3ldm tTqHDkJos3fy396Jsc0WKaKwASllPLewk6tS8ExKC7VMJVqpAFwBBqS5hAfym7HsrrVEUP 1i5EhYj+qu7zIo9yvCdZ2HRyCwGUTHZnF6QnKk7+7Z2JncpHXSAwWtq4O0+optTI5jrtx1 gPc4lMzQh9KEa1vpxpsczqXGOsL5NPQsfmLZdwF9FKcKeo3QmnNHD46AoSmKbN6oJepPao RSzPSEyvYuK3sVE1VUnMs74vPgjJnqgY4dYhryfa4aQ+438DYqhbmubNEuWy6A== 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 4Rn7wK475Sz3G4; Fri, 15 Sep 2023 09:21:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 38F9L5ED018545; Fri, 15 Sep 2023 09:21:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38F9L5Ia018542; Fri, 15 Sep 2023 09:21:05 GMT (envelope-from git) Date: Fri, 15 Sep 2023 09:21:05 GMT Message-Id: <202309150921.38F9L5Ia018542@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Wei Hu Subject: git: 2a95efe756c6 - releng/14.0 - Hyper-V: hn: use VF's capabilities when it is attached 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/releng/14.0 X-Git-Reftype: branch X-Git-Commit: 2a95efe756c65d459cacad89acdf7f90fe080cf6 Auto-Submitted: auto-generated The branch releng/14.0 has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=2a95efe756c65d459cacad89acdf7f90fe080cf6 commit 2a95efe756c65d459cacad89acdf7f90fe080cf6 Author: Wei Hu AuthorDate: 2023-09-04 10:15:06 +0000 Commit: Wei Hu CommitDate: 2023-09-15 09:20:37 +0000 Hyper-V: hn: use VF's capabilities when it is attached Current code in hn/netvsc tries to merge (logical AND) VF and its own capability bits when a VF is attached. This results in losing some key VF features, especially in tx path. For example, the VF's txcsum, rxcsum or tso bits could be lost if any of these are not in hn/netvsc's own capablility field. Actually when VF is attached, hn just needs to use VF's caps as all the tx packets would be forwarded to the VF interface. Fix this problem by doing so. Approved by: re (gjb) Reported by: whu Tested by: whu Sponsored by: Microsoft (cherry picked from commit 289ba6b870f79d8dbd9e8022c4fa23469be11a73) (cherry picked from commit c9b4782ec336c122d8ede81be0823969e0748332) --- sys/dev/hyperv/netvsc/if_hn.c | 63 +++++++--------------------------------- sys/dev/hyperv/netvsc/if_hnvar.h | 2 ++ 2 files changed, 13 insertions(+), 52 deletions(-) diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c index 206a35f7bac8..7d8e1914163e 100644 --- a/sys/dev/hyperv/netvsc/if_hn.c +++ b/sys/dev/hyperv/netvsc/if_hn.c @@ -1261,60 +1261,21 @@ hn_ifaddr_event(void *arg, if_t ifp) } static int -hn_xpnt_vf_iocsetcaps(struct hn_softc *sc, struct ifreq *ifr) +hn_xpnt_vf_iocsetcaps(struct hn_softc *sc, struct ifreq *ifr __unused) { if_t ifp, vf_ifp; - uint64_t tmp; - int error; HN_LOCK_ASSERT(sc); ifp = sc->hn_ifp; vf_ifp = sc->hn_vf_ifp; /* - * Fix up requested capabilities w/ supported capabilities, - * since the supported capabilities could have been changed. - */ - ifr->ifr_reqcap &= if_getcapabilities(ifp); - /* Pass SIOCSIFCAP to VF. */ - error = ifhwioctl(SIOCSIFCAP, vf_ifp, (caddr_t)ifr, curthread); - - /* - * NOTE: - * The error will be propagated to the callers, however, it - * is _not_ useful here. - */ - - /* - * Merge VF's enabled capabilities. + * Just sync up with VF's enabled capabilities. */ - if_setcapenable(ifp, if_getcapenable(vf_ifp) & if_getcapabilities(ifp)); - - tmp = if_gethwassist(vf_ifp) & HN_CSUM_IP_HWASSIST(sc); - if (if_getcapenable(ifp) & IFCAP_TXCSUM) - if_sethwassistbits(ifp, tmp, 0); - else - if_sethwassistbits(ifp, 0, tmp); - - tmp = if_gethwassist(vf_ifp) & HN_CSUM_IP6_HWASSIST(sc); - if (if_getcapenable(ifp) & IFCAP_TXCSUM_IPV6) - if_sethwassistbits(ifp, tmp, 0); - else - if_sethwassistbits(ifp, 0, tmp); + if_setcapenable(ifp, if_getcapenable(vf_ifp)); + if_sethwassist(ifp, if_gethwassist(vf_ifp)); - tmp = if_gethwassist(vf_ifp) & CSUM_IP_TSO; - if (if_getcapenable(ifp) & IFCAP_TSO4) - if_sethwassistbits(ifp, tmp, 0); - else - if_sethwassistbits(ifp, 0, tmp); - - tmp = if_gethwassist(vf_ifp) & CSUM_IP6_TSO; - if (if_getcapenable(ifp) & IFCAP_TSO6) - if_sethwassistbits(ifp, tmp, 0); - else - if_sethwassistbits(ifp, 0, tmp); - - return (error); + return (0); } static int @@ -1698,6 +1659,8 @@ hn_xpnt_vf_setready(struct hn_softc *sc) sc->hn_saved_tsomax = if_gethwtsomax(ifp); sc->hn_saved_tsosegcnt = if_gethwtsomaxsegcount(ifp); sc->hn_saved_tsosegsz = if_gethwtsomaxsegsize(ifp); + sc->hn_saved_capenable = if_getcapenable(ifp); + sc->hn_saved_hwassist = if_gethwassist(ifp); /* * Intersect supported/enabled capabilities. @@ -2017,18 +1980,14 @@ hn_ifnet_detevent(void *xsc, if_t ifp) * The VF was ready; restore some settings. */ if_setcapabilities(ifp, sc->hn_saved_caps); - /* - * NOTE: - * There is _no_ need to fixup if_capenable and - * if_hwassist, since the if_capabilities before - * restoration was an intersection of the VF's - * if_capabilites and the synthetic device's - * if_capabilites. - */ + if_sethwtsomax(ifp, sc->hn_saved_tsomax); if_sethwtsomaxsegcount(sc->hn_ifp, sc->hn_saved_tsosegcnt); if_sethwtsomaxsegsize(ifp, sc->hn_saved_tsosegsz); + + if_setcapenable(ifp, sc->hn_saved_capenable); + if_sethwassist(ifp, sc->hn_saved_hwassist); } if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) { diff --git a/sys/dev/hyperv/netvsc/if_hnvar.h b/sys/dev/hyperv/netvsc/if_hnvar.h index 0d8ed6bdef19..f46adcbf9245 100644 --- a/sys/dev/hyperv/netvsc/if_hnvar.h +++ b/sys/dev/hyperv/netvsc/if_hnvar.h @@ -277,6 +277,8 @@ struct hn_softc { u_int hn_saved_tsomax; u_int hn_saved_tsosegcnt; u_int hn_saved_tsosegsz; + u_int hn_saved_capenable; + u_int hn_saved_hwassist; /* * RSC switch, default off