From owner-dev-commits-src-branches@freebsd.org Mon Mar 15 05:05:30 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 312D156F663; Mon, 15 Mar 2021 05:05: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 4DzPWG0xSvz3nnl; Mon, 15 Mar 2021 05:05:30 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 0F16329AB; Mon, 15 Mar 2021 05:05:30 +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 12F55T3T061562; Mon, 15 Mar 2021 05:05:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 12F55T4E061561; Mon, 15 Mar 2021 05:05:29 GMT (envelope-from git) Date: Mon, 15 Mar 2021 05:05:29 GMT Message-Id: <202103150505.12F55T4E061561@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: c38b9b80149f - stable/12 - hyperv/vmbus: Update VMBus version 4.0 and 5.0 support. 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/12 X-Git-Reftype: branch X-Git-Commit: c38b9b80149f463b0c39a677e91b20925ec486d1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Mar 2021 05:05:30 -0000 The branch stable/12 has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=c38b9b80149f463b0c39a677e91b20925ec486d1 commit c38b9b80149f463b0c39a677e91b20925ec486d1 Author: Wei Hu AuthorDate: 2019-07-09 07:24:18 +0000 Commit: Wei Hu CommitDate: 2021-03-15 05:00:05 +0000 hyperv/vmbus: Update VMBus version 4.0 and 5.0 support. Add VMBus protocol version 4.0. and 5.0 to support Windows 10 and newer HyperV hosts. For VMBus 4.0 and newer HyperV, the netvsc gpadl teardown must be done after vmbus close. Submitted by: whu MFC after: 2 weeks Sponsored by: Microsoft (cherry picked from commit ace5ce7e701e5a98c23f820d4f126e5c265aa667) --- sys/dev/hyperv/include/hyperv.h | 5 +++++ sys/dev/hyperv/include/vmbus.h | 4 ++++ sys/dev/hyperv/netvsc/hn_nvs.c | 4 ++-- sys/dev/hyperv/netvsc/if_hn.c | 32 ++++++++++++++++++++++++++++++++ sys/dev/hyperv/vmbus/vmbus.c | 4 ++++ 5 files changed, 47 insertions(+), 2 deletions(-) diff --git a/sys/dev/hyperv/include/hyperv.h b/sys/dev/hyperv/include/hyperv.h index 3761b2864eef..8b985b2f31a7 100644 --- a/sys/dev/hyperv/include/hyperv.h +++ b/sys/dev/hyperv/include/hyperv.h @@ -94,6 +94,11 @@ extern hyperv_tc64_t hyperv_tc64; extern u_int hyperv_features; /* CPUID_HV_MSR_ */ extern u_int hyperv_ver_major; +/* + * Vmbus version after negotiation with host. + */ +extern uint32_t vmbus_current_version; + #endif /* _KERNEL */ #endif /* _HYPERV_H_ */ diff --git a/sys/dev/hyperv/include/vmbus.h b/sys/dev/hyperv/include/vmbus.h index 4b0060e9241d..6f9cb6459dce 100644 --- a/sys/dev/hyperv/include/vmbus.h +++ b/sys/dev/hyperv/include/vmbus.h @@ -40,11 +40,15 @@ * 1.1 -- Windows 7 * 2.4 -- Windows 8 * 3.0 -- Windows 8.1 + * 4.0 -- Windows 10 + * 5.0 -- Newer Windows 10 */ #define VMBUS_VERSION_WS2008 ((0 << 16) | (13)) #define VMBUS_VERSION_WIN7 ((1 << 16) | (1)) #define VMBUS_VERSION_WIN8 ((2 << 16) | (4)) #define VMBUS_VERSION_WIN8_1 ((3 << 16) | (0)) +#define VMBUS_VERSION_WIN10 ((4 << 16) | (0)) +#define VMBUS_VERSION_WIN10_V5 ((5 << 16) | (0)) #define VMBUS_VERSION_MAJOR(ver) (((uint32_t)(ver)) >> 16) #define VMBUS_VERSION_MINOR(ver) (((uint32_t)(ver)) & 0xffff) diff --git a/sys/dev/hyperv/netvsc/hn_nvs.c b/sys/dev/hyperv/netvsc/hn_nvs.c index f21f989d876a..73a112c4e5e1 100644 --- a/sys/dev/hyperv/netvsc/hn_nvs.c +++ b/sys/dev/hyperv/netvsc/hn_nvs.c @@ -365,7 +365,7 @@ hn_nvs_disconn_rxbuf(struct hn_softc *sc) pause("lingtx", (200 * hz) / 1000); } - if (sc->hn_rxbuf_gpadl != 0) { + if (vmbus_current_version < VMBUS_VERSION_WIN10 && sc->hn_rxbuf_gpadl != 0) { /* * Disconnect RXBUF from primary channel. */ @@ -426,7 +426,7 @@ hn_nvs_disconn_chim(struct hn_softc *sc) pause("lingtx", (200 * hz) / 1000); } - if (sc->hn_chim_gpadl != 0) { + if (vmbus_current_version < VMBUS_VERSION_WIN10 && sc->hn_chim_gpadl != 0) { /* * Disconnect chimney sending buffer from primary channel. */ diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c index 78e3bb36cf7c..e9d1b9439671 100644 --- a/sys/dev/hyperv/netvsc/if_hn.c +++ b/sys/dev/hyperv/netvsc/if_hn.c @@ -6630,6 +6630,38 @@ hn_synth_detach(struct hn_softc *sc) /* Detach all of the channels. */ hn_detach_allchans(sc); + if (vmbus_current_version >= VMBUS_VERSION_WIN10 && sc->hn_rxbuf_gpadl != 0) { + /* + * Host is post-Win2016, disconnect RXBUF from primary channel here. + */ + int error; + + error = vmbus_chan_gpadl_disconnect(sc->hn_prichan, + sc->hn_rxbuf_gpadl); + if (error) { + if_printf(sc->hn_ifp, + "rxbuf gpadl disconn failed: %d\n", error); + sc->hn_flags |= HN_FLAG_RXBUF_REF; + } + sc->hn_rxbuf_gpadl = 0; + } + + if (vmbus_current_version >= VMBUS_VERSION_WIN10 && sc->hn_chim_gpadl != 0) { + /* + * Host is post-Win2016, disconnect chimney sending buffer from + * primary channel here. + */ + int error; + + error = vmbus_chan_gpadl_disconnect(sc->hn_prichan, + sc->hn_chim_gpadl); + if (error) { + if_printf(sc->hn_ifp, + "chim gpadl disconn failed: %d\n", error); + sc->hn_flags |= HN_FLAG_CHIM_REF; + } + sc->hn_chim_gpadl = 0; + } sc->hn_flags &= ~HN_FLAG_SYNTH_ATTACHED; } diff --git a/sys/dev/hyperv/vmbus/vmbus.c b/sys/dev/hyperv/vmbus/vmbus.c index 9d58c5e3e680..d943fb5c8010 100644 --- a/sys/dev/hyperv/vmbus/vmbus.c +++ b/sys/dev/hyperv/vmbus/vmbus.c @@ -140,7 +140,10 @@ SYSCTL_INT(_hw_vmbus, OID_AUTO, pin_evttask, CTLFLAG_RDTUN, extern inthand_t IDTVEC(vmbus_isr), IDTVEC(vmbus_isr_pti); +uint32_t vmbus_current_version; + static const uint32_t vmbus_version[] = { + VMBUS_VERSION_WIN10, VMBUS_VERSION_WIN8_1, VMBUS_VERSION_WIN8, VMBUS_VERSION_WIN7, @@ -414,6 +417,7 @@ vmbus_init(struct vmbus_softc *sc) error = vmbus_connect(sc, vmbus_version[i]); if (!error) { + vmbus_current_version = vmbus_version[i]; sc->vmbus_version = vmbus_version[i]; device_printf(sc->vmbus_dev, "version %u.%u\n", VMBUS_VERSION_MAJOR(sc->vmbus_version),