Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Oct 2016 07:30:59 +0000 (UTC)
From:      Sepherosa Ziehau <sephe@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r307022 - in stable/10/sys: dev/hyperv/include dev/hyperv/netvsc dev/hyperv/storvsc dev/hyperv/utilities dev/hyperv/vmbus modules/hyperv/utilities
Message-ID:  <201610110730.u9B7Uxon009572@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Tue Oct 11 07:30:59 2016
New Revision: 307022
URL: https://svnweb.freebsd.org/changeset/base/307022

Log:
  MFC 302698-302704,302706
  
  302698
      hyperv/vmbus: Add vmbus method for GUID base device probing.
  
      Reduce the exposure of hv_device.
  
      Sponsored by:   Microsoft OSTC
      Differential Revision:  https://reviews.freebsd.org/D7024
  
  302699
      hyperv/vmbus: All ivars are read-only; nuke unnecessary write_ivar
  
      Sponsored by:   Microsoft OSTC
      Differential Revision:  https://reviews.freebsd.org/D7025
  
  302700
      hyperv/vmbus: Add channel ivar accessor.
  
      This makes life easier during the transition period to nuke the hv_device.
  
      Sponsored by:   Microsoft OSTC
      Differential Revision:  https://reviews.freebsd.org/D7026
  
  302701
      hyperv/stor: Avoid the hv_device and nuke the broken get_stor_device
  
      This paves way to nuke the hv_device, which is actually an unncessary
      indirection.
  
      Sponsored by:   Microsoft OSTC
      Differential Revision:  https://reviews.freebsd.org/D7027
  
  302702
      hyperv/util: Avoid the hv_device
  
      This paves way to nuke the hv_device, which is actually an unncessary
      indirection.
  
      Sponsored by:   Microsoft OSTC
      Differential Revision:  https://reviews.freebsd.org/D7028
  
  302703
      hyperv/vmbus: Deprecate the usage of hv_device.
  
      This paves way to nuke the hv_device, which is actually an unncessary
      indirection.
  
      Sponsored by:   Microsoft OSTC
      Differential Revision:  https://reviews.freebsd.org/D7032
  
  302704
      hyperv/hn: Avoid the hv_device
  
      This paves way to nuke the hv_device, which is actually an unncessary
      indirection.
  
      Sponsored by:   Microsoft OSTC
      Differential Revision:  https://reviews.freebsd.org/D7033
  
  302706
      hyperv: Get rid of hv_device, which is unnecessary indirection.
  
      Sponsored by:   Microsoft OSTC
      Differential Revision:  https://reviews.freebsd.org/D7034

Modified:
  stable/10/sys/dev/hyperv/include/hyperv.h
  stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c
  stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h
  stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c
  stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h
  stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
  stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c
  stable/10/sys/dev/hyperv/utilities/hv_kvp.c
  stable/10/sys/dev/hyperv/utilities/hv_shutdown.c
  stable/10/sys/dev/hyperv/utilities/hv_timesync.c
  stable/10/sys/dev/hyperv/utilities/hv_util.c
  stable/10/sys/dev/hyperv/utilities/hv_util.h
  stable/10/sys/dev/hyperv/vmbus/hv_channel.c
  stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
  stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
  stable/10/sys/dev/hyperv/vmbus/vmbus.c
  stable/10/sys/dev/hyperv/vmbus/vmbus_if.m
  stable/10/sys/modules/hyperv/utilities/Makefile
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/hyperv/include/hyperv.h
==============================================================================
--- stable/10/sys/dev/hyperv/include/hyperv.h	Tue Oct 11 07:10:12 2016	(r307021)
+++ stable/10/sys/dev/hyperv/include/hyperv.h	Tue Oct 11 07:30:59 2016	(r307022)
@@ -399,20 +399,6 @@ typedef struct {
 
 #define HW_MACADDR_LEN	6
 
-enum {
-	HV_VMBUS_IVAR_TYPE,
-	HV_VMBUS_IVAR_INSTANCE,
-	HV_VMBUS_IVAR_NODE,
-	HV_VMBUS_IVAR_DEVCTX
-};
-
-#define HV_VMBUS_ACCESSOR(var, ivar, type) \
-		__BUS_ACCESSOR(vmbus, var, HV_VMBUS, ivar, type)
-
-HV_VMBUS_ACCESSOR(type, TYPE,  const char *)
-HV_VMBUS_ACCESSOR(devctx, DEVCTX,  struct hv_device *)
-
-
 /*
  * Common defines for Hyper-V ICs
  */
@@ -534,7 +520,7 @@ typedef union {
 } __packed hv_vmbus_connection_id;
 
 typedef struct hv_vmbus_channel {
-	struct hv_device*		device;
+	device_t			ch_dev;
 	struct vmbus_softc		*vmbus_sc;
 	hv_vmbus_channel_state		state;
 	uint32_t			ch_flags;	/* VMBUS_CHAN_FLAG_ */
@@ -647,15 +633,6 @@ hv_set_channel_read_state(hv_vmbus_chann
 	channel->batched_reading = state;
 }
 
-typedef struct hv_device {
-	hv_guid		    class_id;
-	hv_guid		    device_id;
-	device_t	    device;
-	hv_vmbus_channel*   channel;
-} hv_device;
-
-
-
 int		hv_vmbus_channel_recv_packet(
 				hv_vmbus_channel*	channel,
 				void*			buffer,
@@ -737,4 +714,10 @@ hv_get_phys_addr(void *virt)
 	return (ret);
 }
 
+static __inline struct hv_vmbus_channel *
+vmbus_get_channel(device_t dev)
+{
+	return device_get_ivars(dev);
+}
+
 #endif  /* __HYPERV_H__ */

Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c
==============================================================================
--- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c	Tue Oct 11 07:10:12 2016	(r307021)
+++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c	Tue Oct 11 07:30:59 2016	(r307022)
@@ -57,31 +57,30 @@ MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper
  * Forward declarations
  */
 static void hv_nv_on_channel_callback(void *xchan);
-static int  hv_nv_init_send_buffer_with_net_vsp(struct hv_device *device);
-static int  hv_nv_init_rx_buffer_with_net_vsp(struct hv_device *device);
+static int  hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc);
+static int  hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *);
 static int  hv_nv_destroy_send_buffer(netvsc_dev *net_dev);
 static int  hv_nv_destroy_rx_buffer(netvsc_dev *net_dev);
-static int  hv_nv_connect_to_vsp(struct hv_device *device);
+static int  hv_nv_connect_to_vsp(struct hn_softc *sc);
 static void hv_nv_on_send_completion(netvsc_dev *net_dev,
-    struct hv_device *device, struct hv_vmbus_channel *, hv_vm_packet_descriptor *pkt);
+    struct hv_vmbus_channel *, hv_vm_packet_descriptor *pkt);
 static void hv_nv_on_receive_completion(struct hv_vmbus_channel *chan,
     uint64_t tid, uint32_t status);
 static void hv_nv_on_receive(netvsc_dev *net_dev,
-    struct hv_device *device, struct hv_vmbus_channel *chan,
+    struct hn_softc *sc, struct hv_vmbus_channel *chan,
     hv_vm_packet_descriptor *pkt);
 
 /*
  *
  */
 static inline netvsc_dev *
-hv_nv_alloc_net_device(struct hv_device *device)
+hv_nv_alloc_net_device(struct hn_softc *sc)
 {
 	netvsc_dev *net_dev;
-	hn_softc_t *sc = device_get_softc(device->device);
 
 	net_dev = malloc(sizeof(netvsc_dev), M_NETVSC, M_WAITOK | M_ZERO);
 
-	net_dev->dev = device;
+	net_dev->sc = sc;
 	net_dev->destroy = FALSE;
 	sc->net_dev = net_dev;
 
@@ -89,43 +88,21 @@ hv_nv_alloc_net_device(struct hv_device 
 }
 
 /*
- *
+ * XXX unnecessary; nuke it.
  */
 static inline netvsc_dev *
-hv_nv_get_outbound_net_device(struct hv_device *device)
+hv_nv_get_outbound_net_device(struct hn_softc *sc)
 {
-	hn_softc_t *sc = device_get_softc(device->device);
-	netvsc_dev *net_dev = sc->net_dev;;
-
-	if ((net_dev != NULL) && net_dev->destroy) {
-		return (NULL);
-	}
-
-	return (net_dev);
+	return sc->net_dev;
 }
 
 /*
- *
+ * XXX unnecessary; nuke it.
  */
 static inline netvsc_dev *
-hv_nv_get_inbound_net_device(struct hv_device *device)
+hv_nv_get_inbound_net_device(struct hn_softc *sc)
 {
-	hn_softc_t *sc = device_get_softc(device->device);
-	netvsc_dev *net_dev = sc->net_dev;;
-
-	if (net_dev == NULL) {
-		return (net_dev);
-	}
-	/*
-	 * When the device is being destroyed; we only
-	 * permit incoming packets if and only if there
-	 * are outstanding sends.
-	 */
-	if (net_dev->destroy) {
-		return (NULL);
-	}
-
-	return (net_dev);
+	return sc->net_dev;
 }
 
 int
@@ -163,13 +140,13 @@ hv_nv_get_next_send_section(netvsc_dev *
  *     Hyper-V extensible switch and the synthetic data path.
  */
 static int 
-hv_nv_init_rx_buffer_with_net_vsp(struct hv_device *device)
+hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc)
 {
 	netvsc_dev *net_dev;
 	nvsp_msg *init_pkt;
 	int ret = 0;
 
-	net_dev = hv_nv_get_outbound_net_device(device);
+	net_dev = hv_nv_get_outbound_net_device(sc);
 	if (!net_dev) {
 		return (ENODEV);
 	}
@@ -184,7 +161,7 @@ hv_nv_init_rx_buffer_with_net_vsp(struct
 	 * GPADL:  Guest physical address descriptor list.
 	 */
 	ret = hv_vmbus_channel_establish_gpadl(
-		device->channel, net_dev->rx_buf,
+		sc->hn_prichan, net_dev->rx_buf,
 		net_dev->rx_buf_size, &net_dev->rx_buf_gpadl_handle);
 	if (ret != 0) {
 		goto cleanup;
@@ -205,7 +182,7 @@ hv_nv_init_rx_buffer_with_net_vsp(struct
 
 	/* Send the gpadl notification request */
 
-	ret = hv_vmbus_channel_send_packet(device->channel, init_pkt,
+	ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt,
 	    sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt,
 	    HV_VMBUS_PACKET_TYPE_DATA_IN_BAND,
 	    HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
@@ -255,13 +232,13 @@ exit:
  * Net VSC initialize send buffer with net VSP
  */
 static int 
-hv_nv_init_send_buffer_with_net_vsp(struct hv_device *device)
+hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc)
 {
 	netvsc_dev *net_dev;
 	nvsp_msg *init_pkt;
 	int ret = 0;
 
-	net_dev = hv_nv_get_outbound_net_device(device);
+	net_dev = hv_nv_get_outbound_net_device(sc);
 	if (!net_dev) {
 		return (ENODEV);
 	}
@@ -278,7 +255,7 @@ hv_nv_init_send_buffer_with_net_vsp(stru
 	 * Note:  This call uses the vmbus connection rather than the
 	 * channel to establish the gpadl handle. 
 	 */
-	ret = hv_vmbus_channel_establish_gpadl(device->channel,
+	ret = hv_vmbus_channel_establish_gpadl(sc->hn_prichan,
   	    net_dev->send_buf, net_dev->send_buf_size,
 	    &net_dev->send_buf_gpadl_handle);
 	if (ret != 0) {
@@ -299,7 +276,7 @@ hv_nv_init_send_buffer_with_net_vsp(stru
 
 	/* Send the gpadl notification request */
 
-	ret = hv_vmbus_channel_send_packet(device->channel, init_pkt,
+	ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt,
   	    sizeof(nvsp_msg), (uint64_t)init_pkt,
 	    HV_VMBUS_PACKET_TYPE_DATA_IN_BAND,
 	    HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
@@ -359,7 +336,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_
 		revoke_pkt->msgs.vers_1_msgs.revoke_rx_buf.id =
 		    NETVSC_RECEIVE_BUFFER_ID;
 
-		ret = hv_vmbus_channel_send_packet(net_dev->dev->channel,
+		ret = hv_vmbus_channel_send_packet(net_dev->sc->hn_prichan,
 		    revoke_pkt, sizeof(nvsp_msg),
 		    (uint64_t)(uintptr_t)revoke_pkt,
 		    HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0);
@@ -375,7 +352,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_
 		
 	/* Tear down the gpadl on the vsp end */
 	if (net_dev->rx_buf_gpadl_handle) {
-		ret = hv_vmbus_channel_teardown_gpdal(net_dev->dev->channel,
+		ret = hv_vmbus_channel_teardown_gpdal(net_dev->sc->hn_prichan,
 		    net_dev->rx_buf_gpadl_handle);
 		/*
 		 * If we failed here, we might as well return and have a leak 
@@ -427,7 +404,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne
 		revoke_pkt->msgs.vers_1_msgs.revoke_send_buf.id =
 		    NETVSC_SEND_BUFFER_ID;
 
-		ret = hv_vmbus_channel_send_packet(net_dev->dev->channel,
+		ret = hv_vmbus_channel_send_packet(net_dev->sc->hn_prichan,
 		    revoke_pkt, sizeof(nvsp_msg),
 		    (uint64_t)(uintptr_t)revoke_pkt,
 		    HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0);
@@ -442,7 +419,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne
 		
 	/* Tear down the gpadl on the vsp end */
 	if (net_dev->send_buf_gpadl_handle) {
-		ret = hv_vmbus_channel_teardown_gpdal(net_dev->dev->channel,
+		ret = hv_vmbus_channel_teardown_gpdal(net_dev->sc->hn_prichan,
 		    net_dev->send_buf_gpadl_handle);
 
 		/*
@@ -477,7 +454,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne
  * to the negotiated version, so we cannot rely on that.
  */
 static int
-hv_nv_negotiate_nvsp_protocol(struct hv_device *device, netvsc_dev *net_dev,
+hv_nv_negotiate_nvsp_protocol(struct hn_softc *sc, netvsc_dev *net_dev,
     uint32_t nvsp_ver)
 {
 	nvsp_msg *init_pkt;
@@ -494,7 +471,7 @@ hv_nv_negotiate_nvsp_protocol(struct hv_
 	init_pkt->msgs.init_msgs.init.protocol_version_2 = nvsp_ver;
 
 	/* Send the init request */
-	ret = hv_vmbus_channel_send_packet(device->channel, init_pkt,
+	ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt,
 	    sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt,
 	    HV_VMBUS_PACKET_TYPE_DATA_IN_BAND,
 	    HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
@@ -515,13 +492,13 @@ hv_nv_negotiate_nvsp_protocol(struct hv_
  * Not valid for NDIS version 1.
  */
 static int
-hv_nv_send_ndis_config(struct hv_device *device, uint32_t mtu)
+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(device);
+	net_dev = hv_nv_get_outbound_net_device(sc);
 	if (!net_dev)
 		return (-ENODEV);
 
@@ -538,7 +515,7 @@ hv_nv_send_ndis_config(struct hv_device 
 		= 1;
 
 	/* Send the configuration packet */
-	ret = hv_vmbus_channel_send_packet(device->channel, init_pkt,
+	ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt,
 	    sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt,
 	    HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0);
 	if (ret != 0)
@@ -551,7 +528,7 @@ hv_nv_send_ndis_config(struct hv_device 
  * Net VSC connect to VSP
  */
 static int
-hv_nv_connect_to_vsp(struct hv_device *device)
+hv_nv_connect_to_vsp(struct hn_softc *sc)
 {
 	netvsc_dev *net_dev;
 	nvsp_msg *init_pkt;
@@ -563,20 +540,16 @@ hv_nv_connect_to_vsp(struct hv_device *d
 	int i;
 	int protocol_number = nitems(protocol_list);
 	int ret = 0;
-	device_t dev = device->device;
-	hn_softc_t *sc = device_get_softc(dev);
+	device_t dev = sc->hn_dev;
 	struct ifnet *ifp = sc->arpcom.ac_ifp;
 
-	net_dev = hv_nv_get_outbound_net_device(device);
-	if (!net_dev) {
-		return (ENODEV);
-	}
+	net_dev = hv_nv_get_outbound_net_device(sc);
 
 	/*
 	 * Negotiate the NVSP version.  Try the latest NVSP first.
 	 */
 	for (i = protocol_number - 1; i >= 0; i--) {
-		if (hv_nv_negotiate_nvsp_protocol(device, net_dev,
+		if (hv_nv_negotiate_nvsp_protocol(sc, net_dev,
 		    protocol_list[i]) == 0) {
 			net_dev->nvsp_version = protocol_list[i];
 			if (bootverbose)
@@ -598,7 +571,7 @@ hv_nv_connect_to_vsp(struct hv_device *d
 	 * This needs to be right after the NVSP init message per Haiyang
 	 */
 	if (net_dev->nvsp_version >= NVSP_PROTOCOL_VERSION_2)
-		ret = hv_nv_send_ndis_config(device, ifp->if_mtu);
+		ret = hv_nv_send_ndis_config(sc, ifp->if_mtu);
 
 	/*
 	 * Send the NDIS version
@@ -621,7 +594,7 @@ hv_nv_connect_to_vsp(struct hv_device *d
 
 	/* Send the init request */
 
-	ret = hv_vmbus_channel_send_packet(device->channel, init_pkt,
+	ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt,
 	    sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt,
 	    HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0);
 	if (ret != 0) {
@@ -642,9 +615,9 @@ hv_nv_connect_to_vsp(struct hv_device *d
 		net_dev->rx_buf_size = NETVSC_RECEIVE_BUFFER_SIZE;
 	net_dev->send_buf_size = NETVSC_SEND_BUFFER_SIZE;
 
-	ret = hv_nv_init_rx_buffer_with_net_vsp(device);
+	ret = hv_nv_init_rx_buffer_with_net_vsp(sc);
 	if (ret == 0)
-		ret = hv_nv_init_send_buffer_with_net_vsp(device);
+		ret = hv_nv_init_send_buffer_with_net_vsp(sc);
 
 cleanup:
 	return (ret);
@@ -676,13 +649,13 @@ hv_nv_subchan_attach(struct hv_vmbus_cha
  * Callback when the device belonging to this driver is added
  */
 netvsc_dev *
-hv_nv_on_device_add(struct hv_device *device, void *additional_info)
+hv_nv_on_device_add(struct hn_softc *sc, void *additional_info)
 {
-	struct hv_vmbus_channel *chan = device->channel;
+	struct hv_vmbus_channel *chan = sc->hn_prichan;
 	netvsc_dev *net_dev;
 	int ret = 0;
 
-	net_dev = hv_nv_alloc_net_device(device);
+	net_dev = hv_nv_alloc_net_device(sc);
 	if (net_dev == NULL)
 		return NULL;
 
@@ -706,7 +679,7 @@ hv_nv_on_device_add(struct hv_device *de
 	/*
 	 * Connect with the NetVsp
 	 */
-	ret = hv_nv_connect_to_vsp(device);
+	ret = hv_nv_connect_to_vsp(sc);
 	if (ret != 0)
 		goto close;
 
@@ -732,9 +705,8 @@ cleanup:
  * Net VSC on device remove
  */
 int
-hv_nv_on_device_remove(struct hv_device *device, boolean_t destroy_channel)
+hv_nv_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel)
 {
-	hn_softc_t *sc = device_get_softc(device->device);
 	netvsc_dev *net_dev = sc->net_dev;;
 	
 	/* Stop outbound traffic ie sends and receives completions */
@@ -747,12 +719,12 @@ hv_nv_on_device_remove(struct hv_device 
 	/* Now, we can close the channel safely */
 
 	if (!destroy_channel) {
-		device->channel->state =
+		sc->hn_prichan->state =
 		    HV_CHANNEL_CLOSING_NONDESTRUCTIVE_STATE;
 	}
 
-	free(device->channel->hv_chan_rdbuf, M_NETVSC);
-	hv_vmbus_channel_close(device->channel);
+	free(sc->hn_prichan->hv_chan_rdbuf, M_NETVSC);
+	hv_vmbus_channel_close(sc->hn_prichan);
 
 	sema_destroy(&net_dev->channel_init_sema);
 	free(net_dev, M_NETVSC);
@@ -764,8 +736,7 @@ hv_nv_on_device_remove(struct hv_device 
  * Net VSC on send completion
  */
 static void
-hv_nv_on_send_completion(netvsc_dev *net_dev,
-    struct hv_device *device, struct hv_vmbus_channel *chan,
+hv_nv_on_send_completion(netvsc_dev *net_dev, struct hv_vmbus_channel *chan,
     hv_vm_packet_descriptor *pkt)
 {
 	nvsp_msg *nvsp_msg_pkt;
@@ -870,14 +841,14 @@ hv_nv_on_send(struct hv_vmbus_channel *c
  * with virtual addresses.
  */
 static void
-hv_nv_on_receive(netvsc_dev *net_dev, struct hv_device *device,
+hv_nv_on_receive(netvsc_dev *net_dev, struct hn_softc *sc,
     struct hv_vmbus_channel *chan, hv_vm_packet_descriptor *pkt)
 {
 	hv_vm_transfer_page_packet_header *vm_xfer_page_pkt;
 	nvsp_msg *nvsp_msg_pkt;
 	netvsc_packet vsc_pkt;
 	netvsc_packet *net_vsc_pkt = &vsc_pkt;
-	device_t dev = device->device;
+	device_t dev = sc->hn_dev;
 	int count = 0;
 	int i = 0;
 	int status = nvsp_status_success;
@@ -911,7 +882,6 @@ hv_nv_on_receive(netvsc_dev *net_dev, st
 	}
 
 	count = vm_xfer_page_pkt->range_count;
-	net_vsc_pkt->device = device;
 
 	/* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */
 	for (i = 0; i < count; i++) {
@@ -921,7 +891,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st
 		net_vsc_pkt->tot_data_buf_len = 
 		    vm_xfer_page_pkt->ranges[i].byte_count;
 
-		hv_rf_on_receive(net_dev, device, chan, net_vsc_pkt);
+		hv_rf_on_receive(net_dev, chan, net_vsc_pkt);
 		if (net_vsc_pkt->status != nvsp_status_success) {
 			status = nvsp_status_failure;
 		}
@@ -977,14 +947,14 @@ retry_send_cmplt:
  * Net VSC receiving vRSS send table from VSP
  */
 static void
-hv_nv_send_table(struct hv_device *device, hv_vm_packet_descriptor *pkt)
+hv_nv_send_table(struct hn_softc *sc, hv_vm_packet_descriptor *pkt)
 {
 	netvsc_dev *net_dev;
 	nvsp_msg *nvsp_msg_pkt;
 	int i;
 	uint32_t count, *table;
 
-	net_dev = hv_nv_get_inbound_net_device(device);
+	net_dev = hv_nv_get_inbound_net_device(sc);
 	if (!net_dev)
         	return;
 
@@ -1020,9 +990,9 @@ static void
 hv_nv_on_channel_callback(void *xchan)
 {
 	struct hv_vmbus_channel *chan = xchan;
-	struct hv_device *device = chan->device;
+	device_t dev = chan->ch_dev;
+	struct hn_softc *sc = device_get_softc(dev);
 	netvsc_dev *net_dev;
-	device_t dev = device->device;
 	uint32_t bytes_rxed;
 	uint64_t request_id;
  	hv_vm_packet_descriptor *desc;
@@ -1030,7 +1000,7 @@ hv_nv_on_channel_callback(void *xchan)
 	int bufferlen = NETVSC_PACKET_SIZE;
 	int ret = 0;
 
-	net_dev = hv_nv_get_inbound_net_device(device);
+	net_dev = hv_nv_get_inbound_net_device(sc);
 	if (net_dev == NULL)
 		return;
 
@@ -1044,14 +1014,14 @@ hv_nv_on_channel_callback(void *xchan)
 				desc = (hv_vm_packet_descriptor *)buffer;
 				switch (desc->type) {
 				case HV_VMBUS_PACKET_TYPE_COMPLETION:
-					hv_nv_on_send_completion(net_dev, device,
-					    chan, desc);
+					hv_nv_on_send_completion(net_dev, chan,
+					    desc);
 					break;
 				case HV_VMBUS_PACKET_TYPE_DATA_USING_TRANSFER_PAGES:
-					hv_nv_on_receive(net_dev, device, chan, desc);
+					hv_nv_on_receive(net_dev, sc, chan, desc);
 					break;
 				case HV_VMBUS_PACKET_TYPE_DATA_IN_BAND:
-					hv_nv_send_table(device, desc);
+					hv_nv_send_table(sc, desc);
 					break;
 				default:
 					device_printf(dev,

Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h
==============================================================================
--- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h	Tue Oct 11 07:10:12 2016	(r307021)
+++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h	Tue Oct 11 07:30:59 2016	(r307022)
@@ -1040,7 +1040,7 @@ typedef struct nvsp_msg_ {
  * Per netvsc channel-specific
  */
 typedef struct netvsc_dev_ {
-	struct hv_device			*dev;
+	struct hn_softc				*sc;
 
 	/* Send buffer allocated by us but manages by NetVSP */
 	void					*send_buf;
@@ -1107,7 +1107,6 @@ typedef void (*pfn_on_send_rx_completion
 #endif
 
 typedef struct netvsc_packet_ {
-	struct hv_device           *device;
 	hv_bool_uint8_t            is_data_pkt;      /* One byte */
 	uint16_t		   vlan_tci;
 	uint32_t status;
@@ -1240,8 +1239,8 @@ typedef struct hn_softc {
 	int             hn_initdone;
 	/* See hv_netvsc_drv_freebsd.c for rules on how to use */
 	int             temp_unusable;
-	struct hv_device  *hn_dev_obj;
 	netvsc_dev  	*net_dev;
+	struct hv_vmbus_channel *hn_prichan;
 
 	int		hn_rx_ring_cnt;
 	int		hn_rx_ring_inuse;
@@ -1263,10 +1262,10 @@ typedef struct hn_softc {
  */
 extern int hv_promisc_mode;
 
-void netvsc_linkstatus_callback(struct hv_device *device_obj, uint32_t status);
-netvsc_dev *hv_nv_on_device_add(struct hv_device *device,
+void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status);
+netvsc_dev *hv_nv_on_device_add(struct hn_softc *sc,
     void *additional_info);
-int hv_nv_on_device_remove(struct hv_device *device,
+int hv_nv_on_device_remove(struct hn_softc *sc,
     boolean_t destroy_channel);
 int hv_nv_on_send(struct hv_vmbus_channel *chan, netvsc_packet *pkt);
 int hv_nv_get_next_send_section(netvsc_dev *net_dev);

Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==============================================================================
--- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c	Tue Oct 11 07:10:12 2016	(r307021)
+++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c	Tue Oct 11 07:30:59 2016	(r307022)
@@ -415,18 +415,12 @@ static const hv_guid g_net_vsc_device_ty
 static int
 netvsc_probe(device_t dev)
 {
-	const char *p;
-
-	p = vmbus_get_type(dev);
-	if (!memcmp(p, &g_net_vsc_device_type.data, sizeof(hv_guid))) {
+	if (VMBUS_PROBE_GUID(device_get_parent(dev), dev,
+	    &g_net_vsc_device_type) == 0) {
 		device_set_desc(dev, "Hyper-V Network Interface");
-		if (bootverbose)
-			printf("Netvsc probe... DONE \n");
-
-		return (BUS_PROBE_DEFAULT);
+		return BUS_PROBE_DEFAULT;
 	}
-
-	return (ENXIO);
+	return ENXIO;
 }
 
 static void
@@ -451,8 +445,6 @@ hn_cpuset_setthread_task(void *xmask, in
 static int
 netvsc_attach(device_t dev)
 {
-	struct hv_device *device_ctx = vmbus_get_devctx(dev);
-	struct hv_vmbus_channel *pri_chan;
 	netvsc_device_info device_info;
 	hn_softc_t *sc;
 	int unit = device_get_unit(dev);
@@ -464,6 +456,7 @@ netvsc_attach(device_t dev)
 
 	sc->hn_unit = unit;
 	sc->hn_dev = dev;
+	sc->hn_prichan = vmbus_get_channel(dev);
 
 	if (hn_tx_taskq == NULL) {
 		sc->hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK,
@@ -488,8 +481,6 @@ netvsc_attach(device_t dev)
 	}
 	NV_LOCK_INIT(sc, "NetVSCLock");
 
-	sc->hn_dev_obj = device_ctx;
-
 	ifp = sc->hn_ifp = sc->arpcom.ac_ifp = if_alloc(IFT_ETHER);
 	ifp->if_softc = sc;
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
@@ -532,12 +523,7 @@ netvsc_attach(device_t dev)
 	/*
 	 * Associate the first TX/RX ring w/ the primary channel.
 	 */
-	pri_chan = device_ctx->channel;
-	KASSERT(HV_VMBUS_CHAN_ISPRIMARY(pri_chan), ("not primary channel"));
-	KASSERT(pri_chan->ch_subidx == 0,
-	    ("primary channel subidx %u",
-	     pri_chan->ch_subidx));
-	hn_channel_attach(sc, pri_chan);
+	hn_channel_attach(sc, sc->hn_prichan);
 
 	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp->if_ioctl = hn_ioctl;
@@ -574,7 +560,7 @@ netvsc_attach(device_t dev)
 	    IFCAP_LRO;
 	ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist | CSUM_TSO;
 
-	error = hv_rf_on_device_add(device_ctx, &device_info, ring_cnt);
+	error = hv_rf_on_device_add(sc, &device_info, ring_cnt);
 	if (error)
 		goto failed;
 	KASSERT(sc->net_dev->num_channel > 0 &&
@@ -644,7 +630,6 @@ static int
 netvsc_detach(device_t dev)
 {
 	struct hn_softc *sc = device_get_softc(dev);
-	struct hv_device *hv_device = vmbus_get_devctx(dev); 
 
 	if (bootverbose)
 		printf("netvsc_detach\n");
@@ -660,7 +645,7 @@ netvsc_detach(device_t dev)
 	 * the netdevice.
 	 */
 
-	hv_rf_on_device_remove(hv_device, HV_RF_NV_DESTROY_CHANNEL);
+	hv_rf_on_device_remove(sc, HV_RF_NV_DESTROY_CHANNEL);
 
 	hn_stop_tx_tasks(sc);
 
@@ -1224,10 +1209,8 @@ hn_start_locked(struct hn_tx_ring *txr, 
  * Link up/down notification
  */
 void
-netvsc_linkstatus_callback(struct hv_device *device_obj, uint32_t status)
+netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status)
 {
-	hn_softc_t *sc = device_get_softc(device_obj->device);
-
 	if (status == 1) {
 		sc->hn_carrier = 1;
 	} else {
@@ -1548,7 +1531,6 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
 	struct ifaddr *ifa = (struct ifaddr *)data;
 #endif
 	netvsc_device_info device_info;
-	struct hv_device *hn_dev;
 	int mask, error = 0;
 	int retry_cnt = 500;
 	
@@ -1566,8 +1548,6 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
 		error = ether_ioctl(ifp, cmd, data);
 		break;
 	case SIOCSIFMTU:
-		hn_dev = vmbus_get_devctx(sc->hn_dev);
-
 		/* Check MTU value change */
 		if (ifp->if_mtu == ifr->ifr_mtu)
 			break;
@@ -1614,7 +1594,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
 		 * MTU to take effect.  This includes tearing down, but not
 		 * deleting the channel, then bringing it back up.
 		 */
-		error = hv_rf_on_device_remove(hn_dev, HV_RF_NV_RETAIN_CHANNEL);
+		error = hv_rf_on_device_remove(sc, HV_RF_NV_RETAIN_CHANNEL);
 		if (error) {
 			NV_LOCK(sc);
 			sc->temp_unusable = FALSE;
@@ -1623,9 +1603,9 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
 		}
 
 		/* Wait for subchannels to be destroyed */
-		vmbus_drain_subchan(hn_dev->channel);
+		vmbus_drain_subchan(sc->hn_prichan);
 
-		error = hv_rf_on_device_add(hn_dev, &device_info,
+		error = hv_rf_on_device_add(sc, &device_info,
 		    sc->hn_rx_ring_inuse);
 		if (error) {
 			NV_LOCK(sc);
@@ -1790,7 +1770,6 @@ hn_stop(hn_softc_t *sc)
 {
 	struct ifnet *ifp;
 	int ret, i;
-	struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev);
 
 	ifp = sc->hn_ifp;
 
@@ -1805,7 +1784,7 @@ hn_stop(hn_softc_t *sc)
 	if_link_state_change(ifp, LINK_STATE_DOWN);
 	sc->hn_initdone = 0;
 
-	ret = hv_rf_on_close(device_ctx);
+	ret = hv_rf_on_close(sc);
 }
 
 /*
@@ -1873,7 +1852,6 @@ static void
 hn_ifinit_locked(hn_softc_t *sc)
 {
 	struct ifnet *ifp;
-	struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev);
 	int ret, i;
 
 	ifp = sc->hn_ifp;
@@ -1884,7 +1862,7 @@ hn_ifinit_locked(hn_softc_t *sc)
 
 	hv_promisc_mode = 1;
 
-	ret = hv_rf_on_open(device_ctx);
+	ret = hv_rf_on_open(sc);
 	if (ret != 0) {
 		return;
 	} else {
@@ -3046,13 +3024,12 @@ hn_subchan_attach(struct hn_softc *sc, s
 static void
 hn_subchan_setup(struct hn_softc *sc)
 {
-	struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev);
 	struct hv_vmbus_channel **subchan;
 	int subchan_cnt = sc->net_dev->num_channel - 1;
 	int i;
 
 	/* Wait for sub-channels setup to complete. */
-	subchan = vmbus_get_subchan(device_ctx->channel, subchan_cnt);
+	subchan = vmbus_get_subchan(sc->hn_prichan, subchan_cnt);
 
 	/* Attach the sub-channels. */
 	for (i = 0; i < subchan_cnt; ++i) {

Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c
==============================================================================
--- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c	Tue Oct 11 07:10:12 2016	(r307021)
+++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c	Tue Oct 11 07:30:59 2016	(r307022)
@@ -89,7 +89,7 @@ static int  hv_rf_close_device(rndis_dev
 static void hv_rf_on_send_request_completion(struct hv_vmbus_channel *, void *context);
 static void hv_rf_on_send_request_halt_completion(struct hv_vmbus_channel *, void *context);
 int
-hv_rf_send_offload_request(struct hv_device *device,
+hv_rf_send_offload_request(struct hn_softc *sc,
     rndis_offload_params *offloads);
 /*
  * Set the Per-Packet-Info with the specified type
@@ -299,7 +299,7 @@ hv_rf_send_request(rndis_device *device,
 	packet->send_buf_section_size = 0;
 
 sendit:
-	ret = hv_nv_on_send(device->net_dev->dev->channel, packet);
+	ret = hv_nv_on_send(device->net_dev->sc->hn_prichan, packet);
 
 	return (ret);
 }
@@ -351,7 +351,7 @@ hv_rf_receive_response(rndis_device *dev
 }
 
 int
-hv_rf_send_offload_request(struct hv_device *device,
+hv_rf_send_offload_request(struct hn_softc *sc,
     rndis_offload_params *offloads)
 {
 	rndis_request *request;
@@ -359,8 +359,7 @@ hv_rf_send_offload_request(struct hv_dev
 	rndis_offload_params *offload_req;
 	rndis_set_complete *set_complete;	
 	rndis_device *rndis_dev;
-	hn_softc_t *sc = device_get_softc(device->device);
-	device_t dev = device->device;
+	device_t dev = sc->hn_dev;
 	netvsc_dev *net_dev = sc->net_dev;
 	uint32_t vsp_version = net_dev->nvsp_version;
 	uint32_t extlen = sizeof(rndis_offload_params);
@@ -437,14 +436,14 @@ hv_rf_receive_indicate_status(rndis_devi
 		
 	switch(indicate->status) {
 	case RNDIS_STATUS_MEDIA_CONNECT:
-		netvsc_linkstatus_callback(device->net_dev->dev, 1);
+		netvsc_linkstatus_callback(device->net_dev->sc, 1);
 		break;
 	case RNDIS_STATUS_MEDIA_DISCONNECT:
-		netvsc_linkstatus_callback(device->net_dev->dev, 0);
+		netvsc_linkstatus_callback(device->net_dev->sc, 0);
 		break;
 	default:
 		/* TODO: */
-		device_printf(device->net_dev->dev->device,
+		device_printf(device->net_dev->sc->hn_dev,
 		    "unknown status %d received\n", indicate->status);
 		break;
 	}
@@ -537,7 +536,7 @@ hv_rf_receive_data(rndis_device *device,
 {
 	rndis_packet *rndis_pkt;
 	uint32_t data_offset;
-	device_t dev = device->net_dev->dev->device;
+	device_t dev = device->net_dev->sc->hn_dev;
 	struct hv_rf_recvinfo info;
 
 	rndis_pkt = &message->msg.packet;
@@ -580,7 +579,7 @@ hv_rf_receive_data(rndis_device *device,
  * RNDIS filter on receive
  */
 int
-hv_rf_on_receive(netvsc_dev *net_dev, struct hv_device *device,
+hv_rf_on_receive(netvsc_dev *net_dev,
     struct hv_vmbus_channel *chan, netvsc_packet *pkt)
 {
 	rndis_device *rndis_dev;
@@ -1062,7 +1061,7 @@ hv_rf_close_device(rndis_device *device)
  * RNDIS filter on device add
  */
 int
-hv_rf_on_device_add(struct hv_device *device, void *additl_info,
+hv_rf_on_device_add(struct hn_softc *sc, void *additl_info,
     int nchan)
 {
 	int ret;
@@ -1073,7 +1072,7 @@ hv_rf_on_device_add(struct hv_device *de
 	struct rndis_recv_scale_cap rsscaps;
 	uint32_t rsscaps_size = sizeof(struct rndis_recv_scale_cap);
 	netvsc_device_info *dev_info = (netvsc_device_info *)additl_info;
-	device_t dev = device->device;
+	device_t dev = sc->hn_dev;
 
 	rndis_dev = hv_get_rndis_device();
 	if (rndis_dev == NULL) {
@@ -1086,7 +1085,7 @@ hv_rf_on_device_add(struct hv_device *de
 	 * (hv_rf_on_receive()) before this call is completed.
 	 * Note:  Earlier code used a function pointer here.
 	 */
-	net_dev = hv_nv_on_device_add(device, additl_info);
+	net_dev = hv_nv_on_device_add(sc, additl_info);
 	if (!net_dev) {
 		hv_put_rndis_device(rndis_dev);
 
@@ -1124,7 +1123,7 @@ hv_rf_on_device_add(struct hv_device *de
 	offloads.udp_ipv6_csum = RNDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED;
 	offloads.lso_v2_ipv4 = RNDIS_OFFLOAD_PARAMETERS_LSOV2_ENABLED;
 
-	ret = hv_rf_send_offload_request(device, &offloads);
+	ret = hv_rf_send_offload_request(sc, &offloads);
 	if (ret != 0) {
 		/* TODO: shut down rndis device and the channel */
 		device_printf(dev,
@@ -1171,7 +1170,7 @@ hv_rf_on_device_add(struct hv_device *de
 	init_pkt->msgs.vers_5_msgs.subchannel_request.num_subchannels =
 	    net_dev->num_channel - 1;
 
-	ret = hv_vmbus_channel_send_packet(device->channel, init_pkt,
+	ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt,
 	    sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt,
 	    HV_VMBUS_PACKET_TYPE_DATA_IN_BAND,
 	    HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
@@ -1205,9 +1204,8 @@ out:
  * RNDIS filter on device remove
  */
 int
-hv_rf_on_device_remove(struct hv_device *device, boolean_t destroy_channel)
+hv_rf_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel)
 {
-	hn_softc_t *sc = device_get_softc(device->device);
 	netvsc_dev *net_dev = sc->net_dev;
 	rndis_device *rndis_dev = (rndis_device *)net_dev->extension;
 	int ret;
@@ -1219,7 +1217,7 @@ hv_rf_on_device_remove(struct hv_device 
 	net_dev->extension = NULL;
 
 	/* Pass control to inner driver to remove the device */
-	ret |= hv_nv_on_device_remove(device, destroy_channel);
+	ret |= hv_nv_on_device_remove(sc, destroy_channel);
 
 	return (ret);
 }
@@ -1228,9 +1226,8 @@ hv_rf_on_device_remove(struct hv_device 
  * RNDIS filter on open
  */
 int
-hv_rf_on_open(struct hv_device *device)
+hv_rf_on_open(struct hn_softc *sc)
 {
-	hn_softc_t *sc = device_get_softc(device->device);	
 	netvsc_dev *net_dev = sc->net_dev;
 
 	return (hv_rf_open_device((rndis_device *)net_dev->extension));
@@ -1240,9 +1237,8 @@ hv_rf_on_open(struct hv_device *device)
  * RNDIS filter on close
  */
 int 
-hv_rf_on_close(struct hv_device *device)
+hv_rf_on_close(struct hn_softc *sc)
 {
-	hn_softc_t *sc = device_get_softc(device->device);	
 	netvsc_dev *net_dev = sc->net_dev;
 
 	return (hv_rf_close_device((rndis_device *)net_dev->extension));

Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h
==============================================================================
--- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h	Tue Oct 11 07:10:12 2016	(r307021)
+++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h	Tue Oct 11 07:30:59 2016	(r307022)
@@ -111,15 +111,16 @@ typedef struct rndis_device_ {
  * Externs
  */
 struct hv_vmbus_channel;
+struct hn_softc;
 
-int hv_rf_on_receive(netvsc_dev *net_dev, struct hv_device *device,
+int hv_rf_on_receive(netvsc_dev *net_dev,
     struct hv_vmbus_channel *chan, netvsc_packet *pkt);
 void hv_rf_receive_rollup(netvsc_dev *net_dev);
 void hv_rf_channel_rollup(struct hv_vmbus_channel *chan);
-int hv_rf_on_device_add(struct hv_device *device, void *additl_info, int nchan);
-int hv_rf_on_device_remove(struct hv_device *device, boolean_t destroy_channel);
-int hv_rf_on_open(struct hv_device *device);
-int hv_rf_on_close(struct hv_device *device);
+int hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, int nchan);
+int hv_rf_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel);
+int hv_rf_on_open(struct hn_softc *sc);
+int hv_rf_on_close(struct hn_softc *sc);
 
 #endif  /* __HV_RNDIS_FILTER_H__ */
 

Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
==============================================================================
--- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c	Tue Oct 11 07:10:12 2016	(r307021)
+++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c	Tue Oct 11 07:30:59 2016	(r307022)
@@ -125,7 +125,7 @@ struct hv_storvsc_request {
 };
 
 struct storvsc_softc {
-	struct hv_device		*hs_dev;
+	struct hv_vmbus_channel		*hs_chan;
 	LIST_HEAD(, hv_storvsc_request)	hs_free_list;
 	struct mtx			hs_lock;
 	struct storvsc_driver_props	*hs_drv_props;
@@ -139,6 +139,7 @@ struct storvsc_softc {
 	struct sema 			hs_drain_sema;	
 	struct hv_storvsc_request	hs_init_req;
 	struct hv_storvsc_request	hs_reset_req;
+	device_t			hs_dev;
 };
 
 
@@ -264,11 +265,11 @@ static int create_storvsc_request(union 
 static void storvsc_free_request(struct storvsc_softc *sc, struct hv_storvsc_request *reqp);
 static enum hv_storage_type storvsc_get_storage_type(device_t dev);
 static void hv_storvsc_rescan_target(struct storvsc_softc *sc);
-static void hv_storvsc_on_channel_callback(void *context);
+static void hv_storvsc_on_channel_callback(void *xchan);
 static void hv_storvsc_on_iocompletion( struct storvsc_softc *sc,
 					struct vstor_packet *vstor_packet,
 					struct hv_storvsc_request *request);
-static int hv_storvsc_connect_vsp(struct hv_device *device);
+static int hv_storvsc_connect_vsp(struct storvsc_softc *);
 static void storvsc_io_done(struct hv_storvsc_request *reqp);
 static void storvsc_copy_sgl_to_bounce_buf(struct sglist *bounce_sgl,
 				bus_dma_segment_t *orig_sgl,
@@ -297,72 +298,16 @@ DRIVER_MODULE(storvsc, vmbus, storvsc_dr
 MODULE_VERSION(storvsc, 1);
 MODULE_DEPEND(storvsc, vmbus, 1, 1, 1);
 
-
-/**
- * The host is capable of sending messages to us that are
- * completely unsolicited. So, we need to address the race
- * condition where we may be in the process of unloading the
- * driver when the host may send us an unsolicited message.
- * We address this issue by implementing a sequentially
- * consistent protocol:
- *
- * 1. Channel callback is invoked while holding the the channel lock
- *    and an unloading driver will reset the channel callback under
- *    the protection of this channel lock.
- *
- * 2. To ensure bounded wait time for unloading a driver, we don't
- *    permit outgoing traffic once the device is marked as being
- *    destroyed.
- *
- * 3. Once the device is marked as being destroyed, we only
- *    permit incoming traffic to properly account for
- *    packets already sent out.
- */
-static inline struct storvsc_softc *
-get_stor_device(struct hv_device *device,
-				boolean_t outbound)
-{
-	struct storvsc_softc *sc;
-
-	sc = device_get_softc(device->device);
-
-	if (outbound) {

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201610110730.u9B7Uxon009572>