mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
hyperv/vmbus: Add vmbus method for GUID base device probing.
Reduce the exposure of hv_device. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7024
This commit is contained in:
parent
abe9fa4996
commit
884d26c84c
9 changed files with 42 additions and 37 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1089,6 +1089,16 @@ vmbus_get_version_method(device_t bus, device_t dev)
|
|||
return sc->vmbus_version;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
@ -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
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue