aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c14
-rw-r--r--sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c10
-rw-r--r--sys/dev/hyperv/utilities/hv_heartbeat.c8
-rw-r--r--sys/dev/hyperv/utilities/hv_kvp.c8
-rw-r--r--sys/dev/hyperv/utilities/hv_shutdown.c8
-rw-r--r--sys/dev/hyperv/utilities/hv_timesync.c8
-rw-r--r--sys/dev/hyperv/vmbus/vmbus.c11
-rw-r--r--sys/dev/hyperv/vmbus/vmbus_if.m10
-rw-r--r--sys/modules/hyperv/utilities/Makefile2
9 files changed, 42 insertions, 37 deletions
diff --git a/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
index 53db98b0743c5..10d0c0b6fae07 100644
--- a/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
+++ b/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
@@ -411,18 +411,12 @@ static const hv_guid g_net_vsc_device_type = {
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;
}
/*
diff --git a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
index fb10924625164..68d61a6d70bee 100644
--- a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
+++ b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
@@ -2167,13 +2167,11 @@ storvsc_free_request(struct storvsc_softc *sc, struct hv_storvsc_request *reqp)
static enum hv_storage_type
storvsc_get_storage_type(device_t dev)
{
- const char *p = vmbus_get_type(dev);
+ device_t parent = device_get_parent(dev);
- if (!memcmp(p, &gBlkVscDeviceType, sizeof(hv_guid))) {
+ if (VMBUS_PROBE_GUID(parent, dev, &gBlkVscDeviceType) == 0)
return DRIVER_BLKVSC;
- } else if (!memcmp(p, &gStorVscDeviceType, sizeof(hv_guid))) {
+ if (VMBUS_PROBE_GUID(parent, dev, &gStorVscDeviceType) == 0)
return DRIVER_STORVSC;
- }
- return (DRIVER_UNKNOWN);
+ return DRIVER_UNKNOWN;
}
-
diff --git a/sys/dev/hyperv/utilities/hv_heartbeat.c b/sys/dev/hyperv/utilities/hv_heartbeat.c
index 07e8dc35f929e..da4d557c316ea 100644
--- a/sys/dev/hyperv/utilities/hv_heartbeat.c
+++ b/sys/dev/hyperv/utilities/hv_heartbeat.c
@@ -36,9 +36,10 @@
#include <dev/hyperv/include/hyperv.h>
#include "hv_util.h"
+#include "vmbus_if.h"
/* Heartbeat Service */
-static hv_guid service_guid = { .data =
+static const hv_guid service_guid = { .data =
{0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e,
0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d} };
@@ -93,16 +94,13 @@ hv_heartbeat_cb(void *context)
static int
hv_heartbeat_probe(device_t dev)
{
- const char *p = vmbus_get_type(dev);
-
if (resource_disabled("hvheartbeat", 0))
return ENXIO;
- if (!memcmp(p, &service_guid, sizeof(hv_guid))) {
+ if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, &service_guid) == 0) {
device_set_desc(dev, "Hyper-V Heartbeat Service");
return BUS_PROBE_DEFAULT;
}
-
return ENXIO;
}
diff --git a/sys/dev/hyperv/utilities/hv_kvp.c b/sys/dev/hyperv/utilities/hv_kvp.c
index e681f616a525d..200cec4f74aaa 100644
--- a/sys/dev/hyperv/utilities/hv_kvp.c
+++ b/sys/dev/hyperv/utilities/hv_kvp.c
@@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$");
#include "hv_util.h"
#include "unicode.h"
#include "hv_kvp.h"
+#include "vmbus_if.h"
/* hv_kvp defines */
#define BUFFERSIZE sizeof(struct hv_kvp_msg)
@@ -89,7 +90,7 @@ static int hv_kvp_log = 0;
log(LOG_INFO, "hv_kvp: " __VA_ARGS__); \
} while (0)
-static hv_guid service_guid = { .data =
+static const hv_guid service_guid = { .data =
{0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6} };
@@ -865,16 +866,13 @@ hv_kvp_dev_daemon_poll(struct cdev *dev, int events, struct thread *td)
static int
hv_kvp_probe(device_t dev)
{
- const char *p = vmbus_get_type(dev);
-
if (resource_disabled("hvkvp", 0))
return ENXIO;
- if (!memcmp(p, &service_guid, sizeof(hv_guid))) {
+ if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, &service_guid) == 0) {
device_set_desc(dev, "Hyper-V KVP Service");
return BUS_PROBE_DEFAULT;
}
-
return ENXIO;
}
diff --git a/sys/dev/hyperv/utilities/hv_shutdown.c b/sys/dev/hyperv/utilities/hv_shutdown.c
index 2e9bec011e35a..28c33335797b6 100644
--- a/sys/dev/hyperv/utilities/hv_shutdown.c
+++ b/sys/dev/hyperv/utilities/hv_shutdown.c
@@ -41,8 +41,9 @@
#include <dev/hyperv/include/hyperv.h>
#include "hv_util.h"
+#include "vmbus_if.h"
-static hv_guid service_guid = { .data =
+static const hv_guid service_guid = { .data =
{0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49,
0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB} };
@@ -115,16 +116,13 @@ hv_shutdown_cb(void *context)
static int
hv_shutdown_probe(device_t dev)
{
- const char *p = vmbus_get_type(dev);
-
if (resource_disabled("hvshutdown", 0))
return ENXIO;
- if (!memcmp(p, &service_guid, sizeof(hv_guid))) {
+ if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, &service_guid) == 0) {
device_set_desc(dev, "Hyper-V Shutdown Service");
return BUS_PROBE_DEFAULT;
}
-
return ENXIO;
}
diff --git a/sys/dev/hyperv/utilities/hv_timesync.c b/sys/dev/hyperv/utilities/hv_timesync.c
index eeb0434b0c58e..62ce868383723 100644
--- a/sys/dev/hyperv/utilities/hv_timesync.c
+++ b/sys/dev/hyperv/utilities/hv_timesync.c
@@ -41,6 +41,7 @@
#include <dev/hyperv/include/hyperv.h>
#include "hv_util.h"
+#include "vmbus_if.h"
#define HV_WLTIMEDELTA 116444736000000000L /* in 100ns unit */
#define HV_ICTIMESYNCFLAG_PROBE 0
@@ -54,7 +55,7 @@ typedef struct {
} time_sync_data;
/* Time Synch Service */
-static hv_guid service_guid = {.data =
+static const hv_guid service_guid = {.data =
{0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49,
0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf } };
@@ -170,16 +171,13 @@ hv_timesync_cb(void *context)
static int
hv_timesync_probe(device_t dev)
{
- const char *p = vmbus_get_type(dev);
-
if (resource_disabled("hvtimesync", 0))
return ENXIO;
- if (!memcmp(p, &service_guid, sizeof(hv_guid))) {
+ if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, &service_guid) == 0) {
device_set_desc(dev, "Hyper-V Time Synch Service");
return BUS_PROBE_DEFAULT;
}
-
return ENXIO;
}
diff --git a/sys/dev/hyperv/vmbus/vmbus.c b/sys/dev/hyperv/vmbus/vmbus.c
index 9cd9720ec0e44..70d2c449f0a8b 100644
--- a/sys/dev/hyperv/vmbus/vmbus.c
+++ b/sys/dev/hyperv/vmbus/vmbus.c
@@ -1090,6 +1090,16 @@ vmbus_get_version_method(device_t bus, device_t dev)
}
static int
+vmbus_probe_guid_method(device_t bus, device_t dev, const struct hv_guid *guid)
+{
+ struct hv_device *hv_dev = device_get_ivars(dev);
+
+ if (memcmp(&hv_dev->class_id, guid, sizeof(struct hv_guid)) == 0)
+ return 0;
+ return ENXIO;
+}
+
+static int
vmbus_probe(device_t dev)
{
char *id[] = { "VMBUS", NULL };
@@ -1306,6 +1316,7 @@ static device_method_t vmbus_methods[] = {
/* Vmbus interface */
DEVMETHOD(vmbus_get_version, vmbus_get_version_method),
+ DEVMETHOD(vmbus_probe_guid, vmbus_probe_guid_method),
DEVMETHOD_END
};
diff --git a/sys/dev/hyperv/vmbus/vmbus_if.m b/sys/dev/hyperv/vmbus/vmbus_if.m
index 0782d00bbdfa5..3281ad2f2043b 100644
--- a/sys/dev/hyperv/vmbus/vmbus_if.m
+++ b/sys/dev/hyperv/vmbus/vmbus_if.m
@@ -31,7 +31,17 @@
INTERFACE vmbus;
+HEADER {
+ struct hv_guid;
+};
+
METHOD uint32_t get_version {
device_t bus;
device_t dev;
};
+
+METHOD int probe_guid {
+ device_t bus;
+ device_t dev;
+ const struct hv_guid *guid;
+};
diff --git a/sys/modules/hyperv/utilities/Makefile b/sys/modules/hyperv/utilities/Makefile
index c1b6d4fa969a5..290bd2737ad55 100644
--- a/sys/modules/hyperv/utilities/Makefile
+++ b/sys/modules/hyperv/utilities/Makefile
@@ -4,7 +4,7 @@
KMOD= hv_utils
SRCS= hv_util.c hv_kvp.c hv_timesync.c hv_shutdown.c hv_heartbeat.c
-SRCS+= bus_if.h device_if.h
+SRCS+= bus_if.h device_if.h vmbus_if.h
CFLAGS+= -I${.CURDIR}/../../../dev/hyperv/include \
-I${.CURDIR}/../../../dev/hyperv/vmbus