Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Jun 2016 01:49: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: r302166 - in stable/10/sys/dev/hyperv: include utilities vmbus vmbus/i386
Message-ID:  <201606240149.u5O1nxAR050000@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Fri Jun 24 01:49:59 2016
New Revision: 302166
URL: https://svnweb.freebsd.org/changeset/base/302166

Log:
  MFC 301017,301018,301019,301020,301021,301022,301106
  
  301017
      hyperv/vmbus: Indentation cleanup
  
      No functional changes.
  
      MFC after:  1 week
      Sponsored by:       Microsoft OSTC
      Differential Revision:      https://reviews.freebsd.org/D6602
  
  301018
      hyperv/vmbus: Move global vmbus id array to stack.
  
      MFC after:  1 week
      Sponsored by:       Microsoft OSTC
      Differential Revision:      https://reviews.freebsd.org/D6603
  
  301019
      hyperv/vmbus: Redefine SynIC message.
  
      - Avoid unnecessary indirection.
      - Avoid bit fields.
      - Use __packed.
  
      Reviewed by:        Jun Su <junsu microsoft com>
      MFC after:  1 week
      Sponsored by:       Microsoft OSTC
      Differential Revision:      https://reviews.freebsd.org/D6636
  
  301020
      hyperv/vmbus: White space cleanup
  
      No functional changes
  
      MFC after:  1 week
      Sponsored by:       Microsoft OSTC
      Differential Revision:      https://reviews.freebsd.org/D6637
  
  301021
      hyperv: Move guid2str from vmbus file to hyperv file
  
      - Use uint8_t for GUID byte array.
      - Define GUID string length.
      - Break long lines.
      - Nuke unnecessary stack variable.
  
      MFC after:  1 week
      Sponsored by:       Microsoft OSTC
      Differential Revision:      https://reviews.freebsd.org/D6640
  
  301022
      hyperv/kvp: Use if_xname.
  
      MFC after:  1 week
      Sponsored by:       Microsoft OSTC
      Differential Revision:      https://reviews.freebsd.org/D6641
  
  301106
      hyperv/vmbus: Redefine event flags.
  
      - Nuke unnecessary union.
      - Avoid convoluted macro indirection.
  
      MFC after:  1 week
      Sponsored by:       Microsoft OSTC
      Differential Revision:      https://reviews.freebsd.org/D6671

Added:
  stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h
     - copied, changed from r301019, head/sys/dev/hyperv/vmbus/vmbus_reg.h
Modified:
  stable/10/sys/dev/hyperv/include/hyperv.h
  stable/10/sys/dev/hyperv/utilities/hv_kvp.c
  stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
  stable/10/sys/dev/hyperv/vmbus/hv_connection.c
  stable/10/sys/dev/hyperv/vmbus/hv_hv.c
  stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
  stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
  stable/10/sys/dev/hyperv/vmbus/i386/hv_vector.S
  stable/10/sys/dev/hyperv/vmbus/vmbus_var.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/hyperv/include/hyperv.h
==============================================================================
--- stable/10/sys/dev/hyperv/include/hyperv.h	Fri Jun 24 01:20:33 2016	(r302165)
+++ stable/10/sys/dev/hyperv/include/hyperv.h	Fri Jun 24 01:49:59 2016	(r302166)
@@ -121,10 +121,12 @@ typedef uint8_t	hv_bool_uint8_t;
 		    HV_ALIGN_DOWN(addr, PAGE_SIZE)) >> PAGE_SHIFT )
 
 typedef struct hv_guid {
-	 unsigned char data[16];
+	uint8_t data[16];
 } __packed hv_guid;
 
-int snprintf_hv_guid(char *, size_t, const hv_guid *);
+#define HYPERV_GUID_STRLEN	40
+
+int	hyperv_guid2str(const struct hv_guid *, char *, size_t);
 
 #define HV_NIC_GUID							\
 	.data = {0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46,	\

Modified: stable/10/sys/dev/hyperv/utilities/hv_kvp.c
==============================================================================
--- stable/10/sys/dev/hyperv/utilities/hv_kvp.c	Fri Jun 24 01:20:33 2016	(r302165)
+++ stable/10/sys/dev/hyperv/utilities/hv_kvp.c	Fri Jun 24 01:49:59 2016	(r302166)
@@ -58,7 +58,10 @@ __FBSDID("$FreeBSD$");
 #include <sys/syslog.h>
 #include <sys/systm.h>
 #include <sys/mutex.h>
+
+#include <net/if.h>
 #include <net/if_arp.h>
+#include <net/if_var.h>
 
 #include <dev/hyperv/include/hyperv.h>
 #include <dev/hyperv/netvsc/hv_net_vsc.h>
@@ -306,8 +309,7 @@ hv_kvp_convert_utf16_ipinfo_to_utf8(stru
 	int UNUSED_FLAG = 1;
 	struct hv_device *hv_dev;       /* GUID Data Structure */
 	hn_softc_t *sc;                 /* hn softc structure  */
-	char if_name[4];
-	char buf[39];
+	char buf[HYPERV_GUID_STRLEN];
 
 	device_t *devs;
 	int devcnt;
@@ -335,11 +337,12 @@ hv_kvp_convert_utf16_ipinfo_to_utf8(stru
 			/* Trying to find GUID of Network Device */
 			hv_dev = sc->hn_dev_obj;
 
-			snprintf_hv_guid(buf, sizeof(buf), &hv_dev->device_id);
-			sprintf(if_name, "%s%d", "hn", device_get_unit(devs[devcnt]));
+			hyperv_guid2str(&hv_dev->device_id, buf, sizeof(buf));
 
-			if (strncmp(buf, (char *)umsg->body.kvp_ip_val.adapter_id, 39) == 0) {
-				strcpy((char *)umsg->body.kvp_ip_val.adapter_id, if_name);
+			if (strncmp(buf, (char *)umsg->body.kvp_ip_val.adapter_id,
+			    HYPERV_GUID_STRLEN - 1) == 0) {
+				strlcpy((char *)umsg->body.kvp_ip_val.adapter_id,
+				    sc->hn_ifp->if_xname, MAX_ADAPTER_ID_SIZE);
 				break;
 			}
 		}

Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
==============================================================================
--- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c	Fri Jun 24 01:20:33 2016	(r302165)
+++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c	Fri Jun 24 01:49:59 2016	(r302166)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/mutex.h>
 
 #include <dev/hyperv/vmbus/hv_vmbus_priv.h>
+#include <dev/hyperv/vmbus/vmbus_reg.h>
 #include <dev/hyperv/vmbus/vmbus_var.h>
 
 /*
@@ -720,8 +721,8 @@ hv_vmbus_release_unattached_channels(voi
 	    }
 	    hv_vmbus_free_vmbus_channel(channel);
 	}
-	bzero(hv_vmbus_g_connection.channels, 
-		sizeof(hv_vmbus_channel*) * HV_CHANNEL_MAX_COUNT);
+	bzero(hv_vmbus_g_connection.channels,
+	    sizeof(hv_vmbus_channel*) * VMBUS_CHAN_MAX);
 	mtx_unlock(&hv_vmbus_g_connection.channel_lock);
 }
 

Modified: stable/10/sys/dev/hyperv/vmbus/hv_connection.c
==============================================================================
--- stable/10/sys/dev/hyperv/vmbus/hv_connection.c	Fri Jun 24 01:20:33 2016	(r302165)
+++ stable/10/sys/dev/hyperv/vmbus/hv_connection.c	Fri Jun 24 01:49:59 2016	(r302166)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/pmap.h>
 
 #include <dev/hyperv/vmbus/hv_vmbus_priv.h>
+#include <dev/hyperv/vmbus/vmbus_reg.h>
 #include <dev/hyperv/vmbus/vmbus_var.h>
 
 /*
@@ -212,8 +213,7 @@ hv_vmbus_connect(void)
 			M_DEVBUF, M_WAITOK | M_ZERO);
 
 	hv_vmbus_g_connection.channels = malloc(sizeof(hv_vmbus_channel*) *
-		HV_CHANNEL_MAX_COUNT,
-		M_DEVBUF, M_WAITOK | M_ZERO);
+	    VMBUS_CHAN_MAX, M_DEVBUF, M_WAITOK | M_ZERO);
 	/*
 	 * Find the highest vmbus version number we can support.
 	 */
@@ -295,20 +295,20 @@ hv_vmbus_disconnect(void)
 }
 
 static __inline void
-vmbus_event_flags_proc(unsigned long *event_flags, int flag_cnt)
+vmbus_event_flags_proc(volatile u_long *event_flags, int flag_cnt)
 {
 	int f;
 
 	for (f = 0; f < flag_cnt; ++f) {
 		uint32_t rel_id_base;
-		unsigned long flags;
+		u_long flags;
 		int bit;
 
 		if (event_flags[f] == 0)
 			continue;
 
 		flags = atomic_swap_long(&event_flags[f], 0);
-		rel_id_base = f << HV_CHANNEL_ULONG_SHIFT;
+		rel_id_base = f << VMBUS_EVTFLAG_SHIFT;
 
 		while ((bit = ffsl(flags)) != 0) {
 			struct hv_vmbus_channel *channel;
@@ -334,27 +334,27 @@ vmbus_event_flags_proc(unsigned long *ev
 void
 vmbus_event_proc(struct vmbus_softc *sc, int cpu)
 {
-	hv_vmbus_synic_event_flags *event;
+	struct vmbus_evtflags *eventf;
 
 	/*
 	 * On Host with Win8 or above, the event page can be checked directly
 	 * to get the id of the channel that has the pending interrupt.
 	 */
-	event = VMBUS_PCPU_GET(sc, event_flag, cpu) + VMBUS_SINT_MESSAGE;
-	vmbus_event_flags_proc(event->flagsul,
-	    VMBUS_PCPU_GET(sc, event_flag_cnt, cpu));
+	eventf = VMBUS_PCPU_GET(sc, event_flags, cpu) + VMBUS_SINT_MESSAGE;
+	vmbus_event_flags_proc(eventf->evt_flags,
+	    VMBUS_PCPU_GET(sc, event_flags_cnt, cpu));
 }
 
 void
 vmbus_event_proc_compat(struct vmbus_softc *sc __unused, int cpu)
 {
-	hv_vmbus_synic_event_flags *event;
+	struct vmbus_evtflags *eventf;
 
-	event = VMBUS_PCPU_GET(sc, event_flag, cpu) + VMBUS_SINT_MESSAGE;
-	if (atomic_testandclear_int(&event->flags32[0], 0)) {
+	eventf = VMBUS_PCPU_GET(sc, event_flags, cpu) + VMBUS_SINT_MESSAGE;
+	if (atomic_testandclear_long(&eventf->evt_flags[0], 0)) {
 		vmbus_event_flags_proc(
 		    hv_vmbus_g_connection.recv_interrupt_page,
-		    HV_MAX_NUM_CHANNELS_SUPPORTED >> HV_CHANNEL_ULONG_SHIFT);
+		    VMBUS_CHAN_MAX_COMPAT >> VMBUS_EVTFLAG_SHIFT);
 	}
 }
 
@@ -417,8 +417,8 @@ vmbus_on_channel_open(const struct hv_vm
 	volatile int *flag_cnt_ptr;
 	int flag_cnt;
 
-	flag_cnt = (chan->offer_msg.child_rel_id / HV_CHANNEL_ULONG_LEN) + 1;
-	flag_cnt_ptr = VMBUS_PCPU_PTR(vmbus_get_softc(), event_flag_cnt,
+	flag_cnt = (chan->offer_msg.child_rel_id / VMBUS_EVTFLAG_LEN) + 1;
+	flag_cnt_ptr = VMBUS_PCPU_PTR(vmbus_get_softc(), event_flags_cnt,
 	    chan->target_cpu);
 
 	for (;;) {

Modified: stable/10/sys/dev/hyperv/vmbus/hv_hv.c
==============================================================================
--- stable/10/sys/dev/hyperv/vmbus/hv_hv.c	Fri Jun 24 01:20:33 2016	(r302165)
+++ stable/10/sys/dev/hyperv/vmbus/hv_hv.c	Fri Jun 24 01:49:59 2016	(r302166)
@@ -202,6 +202,18 @@ hv_vmbus_signal_event(void *con_id)
 	return (status);
 }
 
+int
+hyperv_guid2str(const struct hv_guid *guid, char *buf, size_t sz)
+{
+	const uint8_t *d = guid->data;
+
+	return snprintf(buf, sz, "%02x%02x%02x%02x-"
+	    "%02x%02x-%02x%02x-%02x%02x-"
+	    "%02x%02x%02x%02x%02x%02x",
+	    d[3], d[2], d[1], d[0],
+	    d[5], d[4], d[7], d[6], d[8], d[9],
+	    d[10], d[11], d[12], d[13], d[14], d[15]);
+}
 
 static bool
 hyperv_identify(void)

Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
==============================================================================
--- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c	Fri Jun 24 01:20:33 2016	(r302165)
+++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c	Fri Jun 24 01:49:59 2016	(r302166)
@@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$");
 #include <dev/hyperv/vmbus/hv_vmbus_priv.h>
 #include <dev/hyperv/vmbus/hyperv_reg.h>
 #include <dev/hyperv/vmbus/hyperv_var.h>
+#include <dev/hyperv/vmbus/vmbus_reg.h>
 #include <dev/hyperv/vmbus/vmbus_var.h>
 
 #include <contrib/dev/acpica/include/acpi.h>
@@ -70,15 +71,13 @@ __FBSDID("$FreeBSD$");
 
 struct vmbus_softc	*vmbus_sc;
 
-static char *vmbus_ids[] = { "VMBUS", NULL };
-
 extern inthand_t IDTVEC(rsvd), IDTVEC(vmbus_isr);
 
 static void
 vmbus_msg_task(void *xsc, int pending __unused)
 {
 	struct vmbus_softc *sc = xsc;
-	hv_vmbus_message *msg;
+	volatile struct vmbus_message *msg;
 
 	msg = VMBUS_PCPU_GET(sc, message, curcpu) + VMBUS_SINT_MESSAGE;
 	for (;;) {
@@ -86,10 +85,12 @@ vmbus_msg_task(void *xsc, int pending __
 		hv_vmbus_channel_msg_header *hdr;
 		hv_vmbus_channel_msg_type msg_type;
 
-		if (msg->header.message_type == HV_MESSAGE_TYPE_NONE)
+		if (msg->msg_type == VMBUS_MSGTYPE_NONE)
 			break; /* no message */
 
-		hdr = (hv_vmbus_channel_msg_header *)msg->u.payload;
+		/* XXX: update messageHandler interface */
+		hdr = __DEVOLATILE(hv_vmbus_channel_msg_header *,
+		    msg->msg_data);
 		msg_type = hdr->message_type;
 
 		if (msg_type >= HV_CHANNEL_MESSAGE_COUNT) {
@@ -101,20 +102,20 @@ vmbus_msg_task(void *xsc, int pending __
 		if (entry->messageHandler)
 			entry->messageHandler(hdr);
 handled:
-		msg->header.message_type = HV_MESSAGE_TYPE_NONE;
+		msg->msg_type = VMBUS_MSGTYPE_NONE;
 		/*
-		 * Make sure the write to message_type (ie set to
-		 * HV_MESSAGE_TYPE_NONE) happens before we read the
-		 * message_pending and EOMing. Otherwise, the EOMing will
-		 * not deliver any more messages
-		 * since there is no empty slot
+		 * Make sure the write to msg_type (i.e. set to
+		 * VMBUS_MSGTYPE_NONE) happens before we read the
+		 * msg_flags and EOMing. Otherwise, the EOMing will
+		 * not deliver any more messages since there is no
+		 * empty slot
 		 *
 		 * NOTE:
 		 * mb() is used here, since atomic_thread_fence_seq_cst()
 		 * will become compiler fence on UP kernel.
 		 */
 		mb();
-		if (msg->header.message_flags.u.message_pending) {
+		if (msg->msg_flags & VMBUS_MSGFLAG_PENDING) {
 			/*
 			 * This will cause message queue rescan to possibly
 			 * deliver another msg from the hypervisor
@@ -127,7 +128,8 @@ handled:
 static __inline int
 vmbus_handle_intr1(struct vmbus_softc *sc, struct trapframe *frame, int cpu)
 {
-	hv_vmbus_message *msg, *msg_base;
+	volatile struct vmbus_message *msg;
+	struct vmbus_message *msg_base;
 
 	msg_base = VMBUS_PCPU_GET(sc, message, cpu);
 
@@ -137,25 +139,24 @@ vmbus_handle_intr1(struct vmbus_softc *s
 	 * TODO: move this to independent IDT vector.
 	 */
 	msg = msg_base + VMBUS_SINT_TIMER;
-	if (msg->header.message_type == HV_MESSAGE_TIMER_EXPIRED) {
-		msg->header.message_type = HV_MESSAGE_TYPE_NONE;
+	if (msg->msg_type == VMBUS_MSGTYPE_TIMER_EXPIRED) {
+		msg->msg_type = VMBUS_MSGTYPE_NONE;
 
 		vmbus_et_intr(frame);
 
 		/*
-		 * Make sure the write to message_type (ie set to
-		 * HV_MESSAGE_TYPE_NONE) happens before we read the
-		 * message_pending and EOMing. Otherwise, the EOMing will
-		 * not deliver any more messages
-		 * since there is no empty slot
+		 * Make sure the write to msg_type (i.e. set to
+		 * VMBUS_MSGTYPE_NONE) happens before we read the
+		 * msg_flags and EOMing. Otherwise, the EOMing will
+		 * not deliver any more messages since there is no
+		 * empty slot
 		 *
 		 * NOTE:
 		 * mb() is used here, since atomic_thread_fence_seq_cst()
 		 * will become compiler fence on UP kernel.
 		 */
 		mb();
-
-		if (msg->header.message_flags.u.message_pending) {
+		if (msg->msg_flags & VMBUS_MSGFLAG_PENDING) {
 			/*
 			 * This will cause message queue rescan to possibly
 			 * deliver another msg from the hypervisor
@@ -177,7 +178,7 @@ vmbus_handle_intr1(struct vmbus_softc *s
 	 * Check messages.  Mainly management stuffs; ultra low rate.
 	 */
 	msg = msg_base + VMBUS_SINT_MESSAGE;
-	if (__predict_false(msg->header.message_type != HV_MESSAGE_TYPE_NONE)) {
+	if (__predict_false(msg->msg_type != VMBUS_MSGTYPE_NONE)) {
 		taskqueue_enqueue(VMBUS_PCPU_GET(sc, message_tq, cpu),
 		    VMBUS_PCPU_PTR(sc, message_task, cpu));
 	}
@@ -247,8 +248,8 @@ vmbus_synic_setup(void *xsc)
 	 */
 	orig = rdmsr(MSR_HV_SIEFP);
 	val = MSR_HV_SIEFP_ENABLE | (orig & MSR_HV_SIEFP_RSVD_MASK) |
-	    ((VMBUS_PCPU_GET(sc, event_flag_dma.hv_paddr, cpu) >> PAGE_SHIFT) <<
-	     MSR_HV_SIEFP_PGSHIFT);
+	    ((VMBUS_PCPU_GET(sc, event_flags_dma.hv_paddr, cpu)
+	      >> PAGE_SHIFT) << MSR_HV_SIEFP_PGSHIFT);
 	wrmsr(MSR_HV_SIEFP, val);
 
 
@@ -338,11 +339,11 @@ vmbus_dma_alloc(struct vmbus_softc *sc)
 
 		ptr = hyperv_dmamem_alloc(bus_get_dma_tag(sc->vmbus_dev),
 		    PAGE_SIZE, 0, PAGE_SIZE,
-		    VMBUS_PCPU_PTR(sc, event_flag_dma, cpu),
+		    VMBUS_PCPU_PTR(sc, event_flags_dma, cpu),
 		    BUS_DMA_WAITOK | BUS_DMA_ZERO);
 		if (ptr == NULL)
 			return ENOMEM;
-		VMBUS_PCPU_GET(sc, event_flag, cpu) = ptr;
+		VMBUS_PCPU_GET(sc, event_flags, cpu) = ptr;
 	}
 	return 0;
 }
@@ -359,11 +360,11 @@ vmbus_dma_free(struct vmbus_softc *sc)
 			    VMBUS_PCPU_GET(sc, message, cpu));
 			VMBUS_PCPU_GET(sc, message, cpu) = NULL;
 		}
-		if (VMBUS_PCPU_GET(sc, event_flag, cpu) != NULL) {
+		if (VMBUS_PCPU_GET(sc, event_flags, cpu) != NULL) {
 			hyperv_dmamem_free(
-			    VMBUS_PCPU_PTR(sc, event_flag_dma, cpu),
-			    VMBUS_PCPU_GET(sc, event_flag, cpu));
-			VMBUS_PCPU_GET(sc, event_flag, cpu) = NULL;
+			    VMBUS_PCPU_PTR(sc, event_flags_dma, cpu),
+			    VMBUS_PCPU_GET(sc, event_flags, cpu));
+			VMBUS_PCPU_GET(sc, event_flags, cpu) = NULL;
 		}
 	}
 }
@@ -534,16 +535,19 @@ vmbus_read_ivar(device_t dev, device_t c
 
 	switch (index) {
 	case HV_VMBUS_IVAR_TYPE:
-		*result = (uintptr_t) &child_dev_ctx->class_id;
+		*result = (uintptr_t)&child_dev_ctx->class_id;
 		return (0);
+
 	case HV_VMBUS_IVAR_INSTANCE:
-		*result = (uintptr_t) &child_dev_ctx->device_id;
+		*result = (uintptr_t)&child_dev_ctx->device_id;
 		return (0);
+
 	case HV_VMBUS_IVAR_DEVCTX:
-		*result = (uintptr_t) child_dev_ctx;
+		*result = (uintptr_t)child_dev_ctx;
 		return (0);
+
 	case HV_VMBUS_IVAR_NODE:
-		*result = (uintptr_t) child_dev_ctx->device;
+		*result = (uintptr_t)child_dev_ctx->device;
 		return (0);
 	}
 	return (ENOENT);
@@ -566,18 +570,18 @@ vmbus_write_ivar(device_t dev, device_t 
 static int
 vmbus_child_pnpinfo_str(device_t dev, device_t child, char *buf, size_t buflen)
 {
-	char guidbuf[40];
 	struct hv_device *dev_ctx = device_get_ivars(child);
+	char guidbuf[HYPERV_GUID_STRLEN];
 
 	if (dev_ctx == NULL)
 		return (0);
 
 	strlcat(buf, "classid=", buflen);
-	snprintf_hv_guid(guidbuf, sizeof(guidbuf), &dev_ctx->class_id);
+	hyperv_guid2str(&dev_ctx->class_id, guidbuf, sizeof(guidbuf));
 	strlcat(buf, guidbuf, buflen);
 
 	strlcat(buf, " deviceid=", buflen);
-	snprintf_hv_guid(guidbuf, sizeof(guidbuf), &dev_ctx->device_id);
+	hyperv_guid2str(&dev_ctx->device_id, guidbuf, sizeof(guidbuf));
 	strlcat(buf, guidbuf, buflen);
 
 	return (0);
@@ -602,30 +606,19 @@ hv_vmbus_child_device_create(hv_guid typ
 }
 
 int
-snprintf_hv_guid(char *buf, size_t sz, const hv_guid *guid)
-{
-	int cnt;
-	const unsigned char *d = guid->data;
-
-	cnt = snprintf(buf, sz,
-		"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
-		d[3], d[2], d[1], d[0], d[5], d[4], d[7], d[6],
-		d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]);
-	return (cnt);
-}
-
-int
 hv_vmbus_child_device_register(struct hv_device *child_dev)
 {
-	device_t child;
+	device_t child, parent;
 
+	parent = vmbus_get_device();
 	if (bootverbose) {
-		char name[40];
-		snprintf_hv_guid(name, sizeof(name), &child_dev->class_id);
-		printf("VMBUS: Class ID: %s\n", name);
+		char name[HYPERV_GUID_STRLEN];
+
+		hyperv_guid2str(&child_dev->class_id, name, sizeof(name));
+		device_printf(parent, "add device, classid: %s\n", name);
 	}
 
-	child = device_add_child(vmbus_get_device(), NULL, -1);
+	child = device_add_child(parent, NULL, -1);
 	child_dev->device = child;
 	device_set_ivars(child, child_dev);
 
@@ -649,7 +642,9 @@ hv_vmbus_child_device_unregister(struct 
 static int
 vmbus_probe(device_t dev)
 {
-	if (ACPI_ID_PROBE(device_get_parent(dev), dev, vmbus_ids) == NULL ||
+	char *id[] = { "VMBUS", NULL };
+
+	if (ACPI_ID_PROBE(device_get_parent(dev), dev, id) == NULL ||
 	    device_get_unit(dev) != 0 || vm_guest != VM_GUEST_HV ||
 	    (hyperv_features & CPUID_HV_MSR_SYNIC) == 0)
 		return (ENXIO);

Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
==============================================================================
--- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h	Fri Jun 24 01:20:33 2016	(r302165)
+++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h	Fri Jun 24 01:49:59 2016	(r302166)
@@ -51,28 +51,6 @@ typedef uint16_t hv_vmbus_status;
 #define HV_ANY_VP                       (0xFFFFFFFF)
 
 /*
- * Synthetic interrupt controller flag constants.
- */
-
-#define HV_EVENT_FLAGS_COUNT        (256 * 8)
-#define HV_EVENT_FLAGS_BYTE_COUNT   (256)
-#define HV_EVENT_FLAGS_DWORD_COUNT  (256 / sizeof(uint32_t))
-#define HV_EVENT_FLAGS_ULONG_COUNT  (256 / sizeof(unsigned long))
-
-/**
- * max channel count <== event_flags_dword_count * bit_of_dword
- */
-#ifdef __LP64__
-#define HV_CHANNEL_ULONG_LEN	    (64)
-#define HV_CHANNEL_ULONG_SHIFT	    (6)
-#else
-#define HV_CHANNEL_ULONG_LEN	    (32)
-#define HV_CHANNEL_ULONG_SHIFT	    (5)
-#endif
-#define HV_CHANNEL_DWORD_LEN        (32)
-#define HV_CHANNEL_MAX_COUNT        \
-	((HV_EVENT_FLAGS_DWORD_COUNT) * HV_CHANNEL_DWORD_LEN)
-/*
  * MessageId: HV_STATUS_INSUFFICIENT_BUFFERS
  * MessageText:
  *    You did not supply enough message buffers to send a message.
@@ -195,9 +173,6 @@ enum {
 
 #define HV_HYPERCALL_PARAM_ALIGN sizeof(uint64_t)
 
-struct vmbus_message;
-union vmbus_event_flags;
-
 /*
  * Define hypervisor message types
  */
@@ -251,59 +226,9 @@ typedef union _hv_vmbus_port_id {
 	} u ;
 } hv_vmbus_port_id;
 
-/*
- * Define synthetic interrupt controller message flag
- */
-typedef union {
-	uint8_t	as_uint8_t;
-	struct {
-		uint8_t	message_pending:1;
-		uint8_t	reserved:7;
-	} u;
-} hv_vmbus_msg_flags;
-
 typedef uint64_t hv_vmbus_partition_id;
 
 /*
- * Define synthetic interrupt controller message header
- */
-typedef struct {
-	hv_vmbus_msg_type	message_type;
-	uint8_t			payload_size;
-	hv_vmbus_msg_flags	message_flags;
-	uint8_t			reserved[2];
-	union {
-		hv_vmbus_partition_id	sender;
-		hv_vmbus_port_id	port;
-	} u;
-} hv_vmbus_msg_header;
-
-/*
- *  Define synthetic interrupt controller message format
- */
-typedef struct vmbus_message {
-	hv_vmbus_msg_header	header;
-	union {
-		uint64_t	payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
-	} u ;
-} hv_vmbus_message;
-
-/*
- *  Maximum channels is determined by the size of the interrupt
- *  page which is PAGE_SIZE. 1/2 of PAGE_SIZE is for
- *  send endpoint interrupt and the other is receive
- *  endpoint interrupt.
- *
- *   Note: (PAGE_SIZE >> 1) << 3 allocates 16348 channels
- */
-#define HV_MAX_NUM_CHANNELS			(PAGE_SIZE >> 1) << 3
-
-/*
- * (The value here must be in multiple of 32)
- */
-#define HV_MAX_NUM_CHANNELS_SUPPORTED		256
-
-/*
  * VM Bus connection states
  */
 typedef enum {
@@ -426,16 +351,6 @@ typedef struct {
 } hv_vmbus_input_post_message;
 
 /*
- * Define the synthetic interrupt controller event flags format
- */
-typedef union vmbus_event_flags {
-	uint8_t		flags8[HV_EVENT_FLAGS_BYTE_COUNT];
-	uint32_t	flags32[HV_EVENT_FLAGS_DWORD_COUNT];
-	unsigned long	flagsul[HV_EVENT_FLAGS_ULONG_COUNT];
-} hv_vmbus_synic_event_flags;
-CTASSERT(sizeof(hv_vmbus_synic_event_flags) == HV_EVENT_FLAGS_BYTE_COUNT);
-
-/*
  * Declare the various hypercall operations
  */
 typedef enum {

Modified: stable/10/sys/dev/hyperv/vmbus/i386/hv_vector.S
==============================================================================
--- stable/10/sys/dev/hyperv/vmbus/i386/hv_vector.S	Fri Jun 24 01:20:33 2016	(r302165)
+++ stable/10/sys/dev/hyperv/vmbus/i386/hv_vector.S	Fri Jun 24 01:49:59 2016	(r302166)
@@ -35,15 +35,15 @@
  * This is the Hyper-V vmbus channel direct callback interrupt.
  * Only used when it is running on Hyper-V.
  */
-        .text
-        SUPERALIGN_TEXT
+	.text
+	SUPERALIGN_TEXT
 IDTVEC(vmbus_isr)
-        PUSH_FRAME
-        SET_KERNEL_SREGS
-        cld
-        FAKE_MCOUNT(TF_EIP(%esp))
-        pushl   %esp
-        call    vmbus_handle_intr
-        add     $4, %esp
-        MEXITCOUNT
-        jmp     doreti
+	PUSH_FRAME
+	SET_KERNEL_SREGS
+	cld
+	FAKE_MCOUNT(TF_EIP(%esp))
+	pushl	%esp
+	call	vmbus_handle_intr
+	add	$4, %esp
+	MEXITCOUNT
+	jmp	doreti

Copied and modified: stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h (from r301019, head/sys/dev/hyperv/vmbus/vmbus_reg.h)
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus_reg.h	Tue May 31 05:18:55 2016	(r301019, copy source)
+++ stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h	Fri Jun 24 01:49:59 2016	(r302166)
@@ -53,4 +53,30 @@ CTASSERT(sizeof(struct vmbus_message) ==
 
 #define VMBUS_MSGFLAG_PENDING		0x01
 
+/*
+ * Hyper-V SynIC event flags
+ */
+
+#ifdef __LP64__
+#define VMBUS_EVTFLAGS_MAX	32
+#define VMBUS_EVTFLAG_SHIFT	6
+#else
+#define VMBUS_EVTFLAGS_MAX	64
+#define VMBUS_EVTFLAG_SHIFT	5
+#endif
+#define VMBUS_EVTFLAG_LEN	(1 << VMBUS_EVTFLAG_SHIFT)
+#define VMBUS_EVTFLAGS_SIZE	256
+
+struct vmbus_evtflags {
+	u_long		evt_flags[VMBUS_EVTFLAGS_MAX];
+} __packed;
+CTASSERT(sizeof(struct vmbus_evtflags) == VMBUS_EVTFLAGS_SIZE);
+
+/*
+ * Channel
+ */
+
+#define VMBUS_CHAN_MAX_COMPAT	256
+#define VMBUS_CHAN_MAX		(VMBUS_EVTFLAG_LEN * VMBUS_EVTFLAGS_MAX)
+
 #endif	/* !_VMBUS_REG_H_ */

Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_var.h
==============================================================================
--- stable/10/sys/dev/hyperv/vmbus/vmbus_var.h	Fri Jun 24 01:20:33 2016	(r302165)
+++ stable/10/sys/dev/hyperv/vmbus/vmbus_var.h	Fri Jun 24 01:49:59 2016	(r302166)
@@ -49,12 +49,12 @@ struct vmbus_pcpu_data {
 	u_long			*intr_cnt;	/* Hyper-V interrupt counter */
 	struct vmbus_message	*message;	/* shared messages */
 	uint32_t		vcpuid;		/* virtual cpuid */
-	int			event_flag_cnt;	/* # of event flags */
-	union vmbus_event_flags	*event_flag;	/* shared event flags */
+	int			event_flags_cnt;/* # of event flags */
+	struct vmbus_evtflags	*event_flags;	/* shared event flags */
 
 	/* Rarely used fields */
 	struct hyperv_dma	message_dma;	/* busdma glue */
-	struct hyperv_dma	event_flag_dma;	/* busdma glue */
+	struct hyperv_dma	event_flags_dma;/* busdma glue */
 	struct taskqueue	*event_tq;	/* event taskq */
 	struct taskqueue	*message_tq;	/* message taskq */
 	struct task		message_task;	/* message task */



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