summaryrefslogtreecommitdiffstats
path: root/sys/dev/hyperv/utilities
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/hyperv/utilities')
-rw-r--r--sys/dev/hyperv/utilities/hv_heartbeat.c10
-rw-r--r--sys/dev/hyperv/utilities/hv_kvp.c32
-rw-r--r--sys/dev/hyperv/utilities/hv_shutdown.c10
-rw-r--r--sys/dev/hyperv/utilities/hv_timesync.c10
-rw-r--r--sys/dev/hyperv/utilities/hv_util.c18
-rw-r--r--sys/dev/hyperv/utilities/hv_util.h2
6 files changed, 35 insertions, 47 deletions
diff --git a/sys/dev/hyperv/utilities/hv_heartbeat.c b/sys/dev/hyperv/utilities/hv_heartbeat.c
index 5f4fcf6..91561eb 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} };
@@ -60,7 +61,7 @@ hv_heartbeat_cb(void *context)
softc = (hv_util_sc*)context;
buf = softc->receive_buffer;;
- channel = softc->hv_dev->channel;
+ channel = softc->channel;
ret = hv_vmbus_channel_recv_packet(channel, buf, PAGE_SIZE, &recvlen,
&requestid);
@@ -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 ebf948c..9a6d1f8 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} };
@@ -307,10 +308,6 @@ hv_kvp_convert_utf16_ipinfo_to_utf8(struct hv_kvp_ip_msg *host_ip_msg,
{
int err_ip, err_subnet, err_gway, err_dns, err_adap;
int UNUSED_FLAG = 1;
- struct hv_device *hv_dev; /* GUID Data Structure */
- hn_softc_t *sc; /* hn softc structure */
- char buf[HYPERV_GUID_STRLEN];
-
device_t *devs;
int devcnt;
@@ -332,12 +329,18 @@ hv_kvp_convert_utf16_ipinfo_to_utf8(struct hv_kvp_ip_msg *host_ip_msg,
if (devclass_get_devices(devclass_find("hn"), &devs, &devcnt) == 0) {
for (devcnt = devcnt - 1; devcnt >= 0; devcnt--) {
- sc = device_get_softc(devs[devcnt]);
-
- /* Trying to find GUID of Network Device */
- hv_dev = sc->hn_dev_obj;
+ /* XXX access other driver's softc? are you kidding? */
+ device_t dev = devs[devcnt];
+ struct hn_softc *sc = device_get_softc(dev);
+ struct hv_vmbus_channel *chan;
+ char buf[HYPERV_GUID_STRLEN];
- hyperv_guid2str(&hv_dev->device_id, buf, sizeof(buf));
+ /*
+ * Trying to find GUID of Network Device
+ * TODO: need vmbus interface.
+ */
+ chan = vmbus_get_channel(dev);
+ hyperv_guid2str(&chan->ch_guid_inst, buf, sizeof(buf));
if (strncmp(buf, (char *)umsg->body.kvp_ip_val.adapter_id,
HYPERV_GUID_STRLEN - 1) == 0) {
@@ -572,7 +575,7 @@ hv_kvp_respond_host(hv_kvp_sc *sc, int error)
hv_icmsg_hdrp->status = error;
hv_icmsg_hdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION | HV_ICMSGHDRFLAG_RESPONSE;
- error = hv_vmbus_channel_send_packet(sc->util_sc.hv_dev->channel,
+ error = hv_vmbus_channel_send_packet(sc->util_sc.channel,
sc->rcv_buf,
sc->host_msg_len, sc->host_msg_id,
HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0);
@@ -623,7 +626,7 @@ hv_kvp_process_request(void *context, int pending)
sc = (hv_kvp_sc*)context;
kvp_buf = sc->util_sc.receive_buffer;;
- channel = sc->util_sc.hv_dev->channel;
+ channel = sc->util_sc.channel;
ret = hv_vmbus_channel_recv_packet(channel, kvp_buf, 2 * PAGE_SIZE,
&recvlen, &requestid);
@@ -865,16 +868,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 3dfbf13..336e911 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} };
@@ -64,7 +65,7 @@ hv_shutdown_cb(void *context)
softc = (hv_util_sc*)context;
buf = softc->receive_buffer;;
- channel = softc->hv_dev->channel;
+ channel = softc->channel;
ret = hv_vmbus_channel_recv_packet(channel, buf, PAGE_SIZE,
&recv_len, &request_id);
@@ -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 eeb0434..c114858 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 } };
@@ -139,7 +140,7 @@ hv_timesync_cb(void *context)
hv_timesync_sc *softc;
softc = (hv_timesync_sc*)context;
- channel = softc->util_sc.hv_dev->channel;
+ channel = softc->util_sc.channel;
time_buf = softc->util_sc.receive_buffer;
ret = hv_vmbus_channel_recv_packet(channel, time_buf,
@@ -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/utilities/hv_util.c b/sys/dev/hyperv/utilities/hv_util.c
index 3119e3f..f7cbd3c 100644
--- a/sys/dev/hyperv/utilities/hv_util.c
+++ b/sys/dev/hyperv/utilities/hv_util.c
@@ -74,13 +74,11 @@ hv_negotiate_version(
int
hv_util_attach(device_t dev)
{
- struct hv_device* hv_dev;
struct hv_util_sc* softc;
int ret;
- hv_dev = vmbus_get_devctx(dev);
softc = device_get_softc(dev);
- softc->hv_dev = hv_dev;
+ softc->channel = vmbus_get_channel(dev);
softc->receive_buffer =
malloc(4 * PAGE_SIZE, M_DEVBUF, M_WAITOK | M_ZERO);
@@ -91,9 +89,9 @@ hv_util_attach(device_t dev)
* Turn off batched reading for all util drivers before we open the
* channel.
*/
- hv_set_channel_read_state(hv_dev->channel, FALSE);
+ hv_set_channel_read_state(softc->channel, FALSE);
- ret = hv_vmbus_channel_open(hv_dev->channel, 4 * PAGE_SIZE,
+ ret = hv_vmbus_channel_open(softc->channel, 4 * PAGE_SIZE,
4 * PAGE_SIZE, NULL, 0,
softc->callback, softc);
@@ -110,14 +108,10 @@ error0:
int
hv_util_detach(device_t dev)
{
- struct hv_device* hv_dev;
- struct hv_util_sc* softc;
-
- hv_dev = vmbus_get_devctx(dev);
+ struct hv_util_sc *sc = device_get_softc(dev);
- hv_vmbus_channel_close(hv_dev->channel);
- softc = device_get_softc(dev);
+ hv_vmbus_channel_close(sc->channel);
+ free(sc->receive_buffer, M_DEVBUF);
- free(softc->receive_buffer, M_DEVBUF);
return (0);
}
diff --git a/sys/dev/hyperv/utilities/hv_util.h b/sys/dev/hyperv/utilities/hv_util.h
index e202784..1be5a61 100644
--- a/sys/dev/hyperv/utilities/hv_util.h
+++ b/sys/dev/hyperv/utilities/hv_util.h
@@ -41,7 +41,7 @@ typedef struct hv_util_sc {
*/
void (*callback)(void *);
- struct hv_device* hv_dev;
+ struct hv_vmbus_channel *channel;
uint8_t *receive_buffer;
} hv_util_sc;
OpenPOWER on IntegriCloud