From nobody Sat Sep 9 13:52:30 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 4RjZDG53ztz4sZwb; Sat, 9 Sep 2023 13:52:30 +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 4RjZDG3T1vz3HQM; Sat, 9 Sep 2023 13:52:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694267550; 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=ZXOEaEGKa5bN/NmjnHgj0GLs4br8YblIV7H5s6Ivt/E=; b=aHuPXGvYIZz8IbVetCL4FhR9IztHFOSheC+DY6DYRMcF4t0i4OShSP8JNdaKyrf9N5HUHR x/BfZ5Bxz+fvItOP0qHVRhdfBYQ63yEIAiW0f9jzHvIFpxGuK3vTLoN4inmwA31AF1ZI1T ucBd00QR1SXCPhHjq/cDkxAboB5Wh/xdUgdkXIY/6oBIRoqvSJ4xJ6akNQWpgJkyJjsXWc +Bq5dYmpNzxAOcBHXHoqqDNmWzgFgSztdcCYXtfnivNIhXwx+5HssPX38NbUNHPxV40mcH KN0ZYcb9gBLPZPRK2aYbbtAyHP/bVh1g1jLLsPGR2IiVPq8KqbcrZDRAs3hhTw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694267550; a=rsa-sha256; cv=none; b=vk6/e3B2S+Jx4kY3Gv+R9nV31pvz/6Ppzvvdk0nuW5bNLicq9IB5SXOkPyjyjl7WDS7Hhm WW8aJVLQS2WL+ZB5KzPrns6CZ8GTHj6mAXsr6thKgB82plZkfRbWvzbFFFEVybijLrqyBr IbSIPv4qSzBg3Xaz4mzieShxjj08j+9250GAoLZhcbtS/iHSaQ2/WqKa7c4Smky3R9B5Rk NPkCKLoGZJyS8Y/3MpkmorMfxysFsythXBzRrrjQALWxswjRTDXlYf8725nHJ1MGAXEYCE mdKcb5yI27S3/0Yqbb480ayMxP3vbt5TDICvEqr4csNJM6iPb2zc+LH4V2TN3g== 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=1694267550; 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=ZXOEaEGKa5bN/NmjnHgj0GLs4br8YblIV7H5s6Ivt/E=; b=cxXaVEWJHJizjB66QowIZWy3mojnSISZ+GOjXQdrQ74vn6nnRxz7nQziDCLtcbTqKXXUmk LwKKgWgzWCt0TgdZCQ7PAjsVQD2q1yM1vzmLgtxzF6vMjkVAHW568W63dByd6Ol5gsOt0Z shVdDcnkuw3I9KPogRjDJX3VPvmCs/qS7mIucDBRDs8ayyqsZXVIpVHGkwSS0QZ5Ru+Qxf b/pgz+D+Yd/8d48EsfXUobEZhaQOHuuJ7hLOOtyNzX8yVFRXN6LB8ZBaRYtVL2sTgQT+CY 2GkNVNsbpqiTt4M8rcmmcq9T4Lt8Y6y/jOb0fV/kvQLpD7rZY7Dz3/6SZeXxfA== 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 4RjZDG2QJkzBj3; Sat, 9 Sep 2023 13:52:30 +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 389DqUL0000097; Sat, 9 Sep 2023 13:52:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 389DqU8Q000094; Sat, 9 Sep 2023 13:52:30 GMT (envelope-from git) Date: Sat, 9 Sep 2023 13:52:30 GMT Message-Id: <202309091352.389DqU8Q000094@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: c9b4782ec336 - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: c9b4782ec336c122d8ede81be0823969e0748332 Auto-Submitted: auto-generated The branch stable/14 has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=c9b4782ec336c122d8ede81be0823969e0748332 commit c9b4782ec336c122d8ede81be0823969e0748332 Author: Wei Hu AuthorDate: 2023-09-04 10:15:06 +0000 Commit: Wei Hu CommitDate: 2023-09-09 13:43:59 +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. Reported by: whu Tested by: whu MFC after: 3 days Sponsored by: Microsoft (cherry picked from commit 289ba6b870f79d8dbd9e8022c4fa23469be11a73) --- 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