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
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to