From owner-svn-src-head@freebsd.org Fri Aug 26 05:15:10 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 26CF3BC58B0; Fri, 26 Aug 2016 05:15:10 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DB01A1806; Fri, 26 Aug 2016 05:15:09 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u7Q5F9pb038762; Fri, 26 Aug 2016 05:15:09 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u7Q5F81J038758; Fri, 26 Aug 2016 05:15:08 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201608260515.u7Q5F81J038758@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 26 Aug 2016 05:15:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r304833 - head/sys/dev/hyperv/netvsc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Aug 2016 05:15:10 -0000 Author: sephe Date: Fri Aug 26 05:15:08 2016 New Revision: 304833 URL: https://svnweb.freebsd.org/changeset/base/304833 Log: hyperv/hn: Save the adopted NDIS version for RNDIS to use later. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7640 Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.c head/sys/dev/hyperv/netvsc/hv_net_vsc.h head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c head/sys/dev/hyperv/netvsc/hv_rndis.h Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Aug 26 05:12:09 2016 (r304832) +++ head/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Aug 26 05:15:08 2016 (r304833) @@ -521,9 +521,15 @@ hv_nv_connect_to_vsp(struct hn_softc *sc for (i = protocol_number - 1; i >= 0; i--) { if (hv_nv_negotiate_nvsp_protocol(sc, protocol_list[i]) == 0) { sc->hn_nvs_ver = protocol_list[i]; + sc->hn_ndis_ver = NDIS_VERSION_6_30; + if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_4) + sc->hn_ndis_ver = NDIS_VERSION_6_1; if (bootverbose) { - device_printf(dev, "NVS version 0x%x\n", - sc->hn_nvs_ver); + if_printf(sc->hn_ifp, "NVS version 0x%x, " + "NDIS version %u.%u\n", + sc->hn_nvs_ver, + NDIS_VERSION_MAJOR(sc->hn_ndis_ver), + NDIS_VERSION_MINOR(sc->hn_ndis_ver)); } break; } @@ -549,11 +555,8 @@ hv_nv_connect_to_vsp(struct hn_softc *sc memset(&ndis, 0, sizeof(ndis)); ndis.nvs_type = HN_NVS_TYPE_NDIS_INIT; - ndis.nvs_ndis_major = NDIS_VERSION_MAJOR_6; - if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_4) - ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_1; - else - ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_30; + ndis.nvs_ndis_major = NDIS_VERSION_MAJOR(sc->hn_ndis_ver); + ndis.nvs_ndis_minor = NDIS_VERSION_MINOR(sc->hn_ndis_ver); /* NOTE: No response. */ ret = hn_nvs_req_send(sc, &ndis, sizeof(ndis)); Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_net_vsc.h Fri Aug 26 05:12:09 2016 (r304832) +++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h Fri Aug 26 05:15:08 2016 (r304833) @@ -382,6 +382,7 @@ typedef struct hn_softc { struct hyperv_dma hn_chim_dma; uint32_t hn_rndis_rid; + uint32_t hn_ndis_ver; } hn_softc_t; #define HN_FLAG_RXBUF_CONNECTED 0x0001 Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Aug 26 05:12:09 2016 (r304832) +++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Aug 26 05:15:08 2016 (r304833) @@ -330,6 +330,7 @@ static int hn_rx_stat_ulong_sysctl(SYSCT static int hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS); static int hn_check_iplen(const struct mbuf *, int); static int hn_create_tx_ring(struct hn_softc *, int); static void hn_destroy_tx_ring(struct hn_tx_ring *); @@ -427,6 +428,8 @@ netvsc_probe(device_t dev) static int netvsc_attach(device_t dev) { + struct sysctl_oid_list *child; + struct sysctl_ctx_list *ctx; netvsc_device_info device_info; hn_softc_t *sc; int unit = device_get_unit(dev); @@ -608,9 +611,13 @@ netvsc_attach(device_t dev) hn_tx_chimney_size < sc->hn_chim_szmax) hn_set_chim_size(sc, hn_tx_chimney_size); - SYSCTL_ADD_UINT(device_get_sysctl_ctx(dev), - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, - "nvs_version", CTLFLAG_RD, &sc->hn_nvs_ver, 0, "NVS version"); + ctx = device_get_sysctl_ctx(dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "nvs_version", CTLFLAG_RD, + &sc->hn_nvs_ver, 0, "NVS version"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "ndis_version", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_ndis_version_sysctl, "A", "NDIS version"); return (0); failed: @@ -2094,6 +2101,18 @@ hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARG } static int +hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + char verstr[16]; + + snprintf(verstr, sizeof(verstr), "%u.%u", + NDIS_VERSION_MAJOR(sc->hn_ndis_ver), + NDIS_VERSION_MINOR(sc->hn_ndis_ver)); + return sysctl_handle_string(oidp, verstr, sizeof(verstr), req); +} + +static int hn_check_iplen(const struct mbuf *m, int hoff) { const struct ip *ip; Modified: head/sys/dev/hyperv/netvsc/hv_rndis.h ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_rndis.h Fri Aug 26 05:12:09 2016 (r304832) +++ head/sys/dev/hyperv/netvsc/hv_rndis.h Fri Aug 26 05:15:08 2016 (r304833) @@ -42,11 +42,8 @@ #define NDIS_VERSION_6_1 0x00060001 #define NDIS_VERSION_6_30 0x0006001e -#define NDIS_VERSION_MAJOR_6 6 -#define NDIS_VERSION_MINOR_1 1 -#define NDIS_VERSION_MINOR_30 30 - -#define NDIS_VERSION (NDIS_VERSION_5_1) +#define NDIS_VERSION_MAJOR(ver) (((ver) & 0xffff0000) >> 16) +#define NDIS_VERSION_MINOR(ver) ((ver) & 0xffff) /* * Object Identifiers used by NdisRequest Query/Set Information