Author: sephe
Date: Fri Aug 12 07:14:40 2016
New Revision: 303989
URL: https://svnweb.freebsd.org/changeset/base/303989

Log:
  hyperv/hn: Simplify NDIS configuration.
  
  MFC after:    1 week
  Sponsored by: Microsoft
  Differential Revision:        https://reviews.freebsd.org/D7466

Modified:
  head/sys/dev/hyperv/netvsc/hv_net_vsc.c
  head/sys/dev/hyperv/netvsc/if_hnreg.h

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.c
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.c     Fri Aug 12 07:03:58 2016        
(r303988)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.c     Fri Aug 12 07:14:40 2016        
(r303989)
@@ -536,33 +536,19 @@ hv_nv_negotiate_nvsp_protocol(struct hn_
 static int
 hv_nv_send_ndis_config(struct hn_softc *sc, uint32_t mtu)
 {
-       netvsc_dev *net_dev;
-       nvsp_msg *init_pkt;
-       int ret;
-
-       net_dev = hv_nv_get_outbound_net_device(sc);
-       if (!net_dev)
-               return (-ENODEV);
-
-       /*
-        * Set up configuration packet, write MTU
-        * Indicate we are capable of handling VLAN tags
-        */
-       init_pkt = &net_dev->channel_init_packet;
-       memset(init_pkt, 0, sizeof(nvsp_msg));
-       init_pkt->hdr.msg_type = nvsp_msg_2_type_send_ndis_config;
-       init_pkt->msgs.vers_2_msgs.send_ndis_config.mtu = mtu;
-       init_pkt->
-               msgs.vers_2_msgs.send_ndis_config.capabilities.u1.u2.ieee8021q
-               = 1;
-
-       /* Send the configuration packet */
-       ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0,
-           init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&hn_send_ctx_none);
-       if (ret != 0)
-               return (-EINVAL);
+       struct hn_nvs_ndis_conf conf;
+       int error;
 
-       return (0);
+       memset(&conf, 0, sizeof(conf));
+       conf.nvs_type = HN_NVS_TYPE_NDIS_CONF;
+       conf.nvs_mtu = mtu;
+       conf.nvs_caps = HN_NVS_NDIS_CONF_VLAN;
+
+       error = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0,
+           &conf, sizeof(conf), (uint64_t)(uintptr_t)&hn_send_ctx_none);
+       if (error)
+               if_printf(sc->hn_ifp, "send nvs ndis conf failed: %d\n", error);
+       return (error);
 }
 
 /*

Modified: head/sys/dev/hyperv/netvsc/if_hnreg.h
==============================================================================
--- head/sys/dev/hyperv/netvsc/if_hnreg.h       Fri Aug 12 07:03:58 2016        
(r303988)
+++ head/sys/dev/hyperv/netvsc/if_hnreg.h       Fri Aug 12 07:14:40 2016        
(r303989)
@@ -36,6 +36,7 @@
 
 #define HN_NVS_TYPE_INIT               1
 #define HN_NVS_TYPE_INIT_RESP          2
+#define HN_NVS_TYPE_NDIS_CONF          125
 
 /*
  * Any size less than this one will _not_ work, e.g. hn_nvs_init
@@ -59,4 +60,17 @@ struct hn_nvs_init_resp {
        uint32_t        nvs_status;     /* HN_NVS_STATUS_ */
 } __packed;
 
+/* No reponse */
+struct hn_nvs_ndis_conf {
+       uint32_t        nvs_type;       /* HN_NVS_TYPE_NDIS_CONF */
+       uint32_t        nvs_mtu;
+       uint32_t        nvs_rsvd;
+       uint64_t        nvs_caps;       /* HN_NVS_NDIS_CONF_ */
+       uint8_t         nvs_rsvd1[12];
+} __packed;
+CTASSERT(sizeof(struct hn_nvs_ndis_conf) >= HN_NVS_REQSIZE_MIN);
+
+#define HN_NVS_NDIS_CONF_SRIOV         0x0004
+#define HN_NVS_NDIS_CONF_VLAN          0x0008
+
 #endif /* !_IF_HNREG_H_ */
_______________________________________________
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