From nobody Mon Sep 04 10:40:50 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 4RfQCQ3PT6z4rwN2; Mon, 4 Sep 2023 10:40:50 +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 4RfQCQ2zBwz3N2Q; Mon, 4 Sep 2023 10:40:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693824050; 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=tWGMjHf1iMgzWOmvfmNsxrSAB3nmkawLhp/2k4Ste1I=; b=Zp6ZrvQ9wQCRopdC6dqhmV25Ja99+1QkOtLqwIkFieKxx5qW/1G5+YDCzebes9qVEma1jm wSDMbS5bD5t30t2L5tGg1y78zORllnl4AsdA2Ll8zoUZzc2kbzqGXInUATglPU88M87YCp 5ZQitu8u3vH7S1ide3RR7DEOFrHF57LtqozyMKN5RIwHFGcNG8niRP3v4VWsdQcOwW+Tda rFg8mCs2RRORZcoonbfb727y2jrUsKXN7oA2tfhiPbsOc3xUpGFudbqM2Dh/UrS7JzL3jG a8dYPXKXVm8UvkcWHmFJw1/xrwhpU+g/NC9c9sykX6LM0lzutdU1nKuYoI6sTA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1693824050; a=rsa-sha256; cv=none; b=q2XMu2vEok0hxTofA6RjsWXPIgpLHFjkMpLNpTgb76imv+f9s7GRsTsHbk7/EGuiRahWfA CceUSf12J31ty+x9s4ej737v7djESjFpgCpDbaLkY/aonFmcB6+97Jt434msRihrz0F8io gVr7T/tHoopJ9vloKQ0Az4sqnjpsJnbvh3nmgiTpyx6Hs407zypyaZFz262PBtkjNB1teD umc8HTU8q0oURgLsvRiYNnmxqkYCi0IthpiuK8unbzoeTjlofIhL+tELNljy8vgp/cT5Yn ApxVkecY5nWpzUAQzbaqhCLNrKNjtvL3/0IZ1YXJCmePFqVlu6NA9+qzQFEMsA== 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=1693824050; 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=tWGMjHf1iMgzWOmvfmNsxrSAB3nmkawLhp/2k4Ste1I=; b=ygY42yI2N8qT8cTbPJG1wNzN1wTpW+ASut9F7Brqdb5+9GMUPmtAw5DpJWTWhernPD08eP 8rxbmJHd9AnFbCzhgG1EWTsnv2YTzmw0KZoI2QY6kCGYr4CkbYqOZNOxcQ1weeurCdn8F/ C/YxHBrZGZ58N0pTdC4TtMuhBNob/ENsSv9vSeX8CW2LdpUVD5wdeLdW5W3wSZSe3IBm/s 8SWriaHDItfjF/oc72015YaztYancD2k8vbNMNvyhDF9lUY3uSMwumeGzm3nb5VM4pErK/ 6q6sbVgjdIXlcmmc2VDLK+aMvtNFwBTIT6MtMmw4/mhOw+6qZS9s50TdNL64Eg== 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 4RfQCQ232dz12xc; Mon, 4 Sep 2023 10:40:50 +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 384Aeoo7011162; Mon, 4 Sep 2023 10:40:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 384Aeohp011159; Mon, 4 Sep 2023 10:40:50 GMT (envelope-from git) Date: Mon, 4 Sep 2023 10:40:50 GMT Message-Id: <202309041040.384Aeohp011159@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: 289ba6b870f7 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 289ba6b870f79d8dbd9e8022c4fa23469be11a73 Auto-Submitted: auto-generated The branch main has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=289ba6b870f79d8dbd9e8022c4fa23469be11a73 commit 289ba6b870f79d8dbd9e8022c4fa23469be11a73 Author: Wei Hu AuthorDate: 2023-09-04 10:15:06 +0000 Commit: Wei Hu CommitDate: 2023-09-04 10:40:11 +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 --- 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