Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108113307
D7243.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
10 KB
Referenced Files
None
Subscribers
None
D7243.diff
View Options
Index: head/sys/dev/hyperv/include/hyperv.h
===================================================================
--- head/sys/dev/hyperv/include/hyperv.h
+++ head/sys/dev/hyperv/include/hyperv.h
@@ -113,7 +113,9 @@
uint32_t ring_data_size; /* ring_size */
} hv_vmbus_ring_buffer_info;
-typedef void (*vmbus_chan_callback_t)(void *);
+struct hv_vmbus_channel;
+
+typedef void (*vmbus_chan_callback_t)(struct hv_vmbus_channel *, void *);
typedef struct hv_vmbus_channel {
device_t ch_dev;
Index: head/sys/dev/hyperv/netvsc/hv_net_vsc.c
===================================================================
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.c
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.c
@@ -57,7 +57,7 @@
/*
* Forward declarations
*/
-static void hv_nv_on_channel_callback(void *xchan);
+static void hv_nv_on_channel_callback(struct hv_vmbus_channel *chan, void *arg);
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);
@@ -647,7 +647,7 @@
chan->ch_dev_rdbuf = malloc(NETVSC_PACKET_SIZE, M_NETVSC, M_WAITOK);
vmbus_chan_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE,
NETVSC_DEVICE_RING_BUFFER_SIZE, NULL, 0,
- hv_nv_on_channel_callback, chan);
+ hv_nv_on_channel_callback, NULL);
}
/*
@@ -677,7 +677,7 @@
*/
ret = vmbus_chan_open(chan,
NETVSC_DEVICE_RING_BUFFER_SIZE, NETVSC_DEVICE_RING_BUFFER_SIZE,
- NULL, 0, hv_nv_on_channel_callback, chan);
+ NULL, 0, hv_nv_on_channel_callback, NULL);
if (ret != 0) {
free(chan->ch_dev_rdbuf, M_NETVSC);
goto cleanup;
@@ -973,9 +973,8 @@
* Net VSC on channel callback
*/
static void
-hv_nv_on_channel_callback(void *xchan)
+hv_nv_on_channel_callback(struct hv_vmbus_channel *chan, void *arg __unused)
{
- struct hv_vmbus_channel *chan = xchan;
device_t dev = chan->ch_dev;
struct hn_softc *sc = device_get_softc(dev);
netvsc_dev *net_dev;
Index: head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
===================================================================
--- head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
+++ head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
@@ -274,7 +274,7 @@
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 *xchan);
+static void hv_storvsc_on_channel_callback(struct hv_vmbus_channel *chan, void *xsc);
static void hv_storvsc_on_iocompletion( struct storvsc_softc *sc,
struct vstor_packet *vstor_packet,
struct hv_storvsc_request *request);
@@ -316,15 +316,13 @@
memset(&props, 0, sizeof(props));
- new_channel->ch_dev_priv1 = sc;
vmbus_chan_cpu_rr(new_channel);
ret = vmbus_chan_open(new_channel,
sc->hs_drv_props->drv_ringbuffer_size,
sc->hs_drv_props->drv_ringbuffer_size,
(void *)&props,
sizeof(struct vmstor_chan_props),
- hv_storvsc_on_channel_callback,
- new_channel);
+ hv_storvsc_on_channel_callback, sc);
}
/**
@@ -575,7 +573,6 @@
/*
* Open the channel
*/
- KASSERT(sc->hs_chan->ch_dev_priv1 == sc, ("invalid chan priv1"));
vmbus_chan_cpu_rr(sc->hs_chan);
ret = vmbus_chan_open(
sc->hs_chan,
@@ -583,8 +580,7 @@
sc->hs_drv_props->drv_ringbuffer_size,
(void *)&props,
sizeof(struct vmstor_chan_props),
- hv_storvsc_on_channel_callback,
- sc->hs_chan);
+ hv_storvsc_on_channel_callback, sc);
if (ret != 0) {
return ret;
@@ -769,11 +765,10 @@
}
static void
-hv_storvsc_on_channel_callback(void *xchan)
+hv_storvsc_on_channel_callback(struct hv_vmbus_channel *channel, void *xsc)
{
int ret = 0;
- hv_vmbus_channel *channel = xchan;
- struct storvsc_softc *sc = channel->ch_dev_priv1;
+ struct storvsc_softc *sc = xsc;
uint32_t bytes_recvd;
uint64_t request_id;
uint8_t packet[roundup2(sizeof(struct vstor_packet), 8)];
@@ -915,7 +910,6 @@
sc = device_get_softc(dev);
sc->hs_chan = vmbus_get_channel(dev);
- sc->hs_chan->ch_dev_priv1 = sc;
stor_type = storvsc_get_storage_type(dev);
@@ -1265,7 +1259,7 @@
mtx_assert(&sc->hs_lock, MA_OWNED);
mtx_unlock(&sc->hs_lock);
- hv_storvsc_on_channel_callback(sc->hs_chan);
+ hv_storvsc_on_channel_callback(sc->hs_chan, sc);
mtx_lock(&sc->hs_lock);
}
Index: head/sys/dev/hyperv/utilities/hv_heartbeat.c
===================================================================
--- head/sys/dev/hyperv/utilities/hv_heartbeat.c
+++ head/sys/dev/hyperv/utilities/hv_heartbeat.c
@@ -49,10 +49,9 @@
* Process heartbeat message
*/
static void
-hv_heartbeat_cb(void *context)
+hv_heartbeat_cb(struct hv_vmbus_channel *channel, void *context)
{
uint8_t* buf;
- hv_vmbus_channel* channel;
int recvlen;
uint64_t requestid;
int ret;
@@ -63,7 +62,6 @@
softc = (hv_util_sc*)context;
buf = softc->receive_buffer;
- channel = softc->channel;
recvlen = PAGE_SIZE;
ret = vmbus_chan_recv(channel, buf, &recvlen, &requestid);
Index: head/sys/dev/hyperv/utilities/hv_kvp.c
===================================================================
--- head/sys/dev/hyperv/utilities/hv_kvp.c
+++ head/sys/dev/hyperv/utilities/hv_kvp.c
@@ -121,6 +121,7 @@
*/
typedef struct hv_kvp_sc {
struct hv_util_sc util_sc;
+ device_t dev;
/* Unless specified the pending mutex should be
* used to alter the values of the following parameters:
@@ -576,7 +577,7 @@
hv_icmsg_hdrp->status = error;
hv_icmsg_hdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION | HV_ICMSGHDRFLAG_RESPONSE;
- error = vmbus_chan_send(sc->util_sc.channel,
+ error = vmbus_chan_send(vmbus_get_channel(sc->dev),
VMBUS_CHANPKT_TYPE_INBAND, 0, sc->rcv_buf, sc->host_msg_len,
sc->host_msg_id);
if (error)
@@ -625,7 +626,7 @@
sc = (hv_kvp_sc*)context;
kvp_buf = sc->util_sc.receive_buffer;
- channel = sc->util_sc.channel;
+ channel = vmbus_get_channel(sc->dev);
recvlen = 2 * PAGE_SIZE;
ret = vmbus_chan_recv(channel, kvp_buf, &recvlen, &requestid);
@@ -709,7 +710,7 @@
* Callback routine that gets called whenever there is a message from host
*/
static void
-hv_kvp_callback(void *context)
+hv_kvp_callback(struct hv_vmbus_channel *chan __unused, void *context)
{
hv_kvp_sc *sc = (hv_kvp_sc*)context;
/*
@@ -813,7 +814,7 @@
if (sc->register_done == false) {
if (sc->daemon_kvp_msg.kvp_hdr.operation == HV_KVP_OP_REGISTER) {
sc->register_done = true;
- hv_kvp_callback(dev->si_drv1);
+ hv_kvp_callback(vmbus_get_channel(sc->dev), dev->si_drv1);
}
else {
hv_kvp_log_info("%s, KVP Registration Failed\n", __func__);
@@ -891,6 +892,7 @@
hv_kvp_sc *sc = (hv_kvp_sc*)device_get_softc(dev);
sc->util_sc.callback = hv_kvp_callback;
+ sc->dev = dev;
sema_init(&sc->dev_sema, 0, "hv_kvp device semaphore");
mtx_init(&sc->pending_mutex, "hv-kvp pending mutex",
NULL, MTX_DEF);
Index: head/sys/dev/hyperv/utilities/hv_shutdown.c
===================================================================
--- head/sys/dev/hyperv/utilities/hv_shutdown.c
+++ head/sys/dev/hyperv/utilities/hv_shutdown.c
@@ -53,10 +53,9 @@
* Shutdown
*/
static void
-hv_shutdown_cb(void *context)
+hv_shutdown_cb(struct hv_vmbus_channel *channel, void *context)
{
uint8_t* buf;
- hv_vmbus_channel* channel;
uint8_t execute_shutdown = 0;
hv_vmbus_icmsg_hdr* icmsghdrp;
uint32_t recv_len;
@@ -67,7 +66,6 @@
softc = (hv_util_sc*)context;
buf = softc->receive_buffer;
- channel = softc->channel;
recv_len = PAGE_SIZE;
ret = vmbus_chan_recv(channel, buf, &recv_len, &request_id);
Index: head/sys/dev/hyperv/utilities/hv_timesync.c
===================================================================
--- head/sys/dev/hyperv/utilities/hv_timesync.c
+++ head/sys/dev/hyperv/utilities/hv_timesync.c
@@ -130,9 +130,8 @@
* Time Sync Channel message handler
*/
static void
-hv_timesync_cb(void *context)
+hv_timesync_cb(struct hv_vmbus_channel *channel, void *context)
{
- hv_vmbus_channel* channel;
hv_vmbus_icmsg_hdr* icmsghdrp;
uint32_t recvlen;
uint64_t requestId;
@@ -142,7 +141,6 @@
hv_timesync_sc *softc;
softc = (hv_timesync_sc*)context;
- channel = softc->util_sc.channel;
time_buf = softc->util_sc.receive_buffer;
recvlen = PAGE_SIZE;
Index: head/sys/dev/hyperv/utilities/hv_util.h
===================================================================
--- head/sys/dev/hyperv/utilities/hv_util.h
+++ head/sys/dev/hyperv/utilities/hv_util.h
@@ -39,9 +39,7 @@
/*
* function to process Hyper-V messages
*/
- void (*callback)(void *);
-
- struct hv_vmbus_channel *channel;
+ void (*callback)(struct hv_vmbus_channel *, void *);
uint8_t *receive_buffer;
} hv_util_sc;
Index: head/sys/dev/hyperv/utilities/hv_util.c
===================================================================
--- head/sys/dev/hyperv/utilities/hv_util.c
+++ head/sys/dev/hyperv/utilities/hv_util.c
@@ -77,12 +77,13 @@
hv_util_attach(device_t dev)
{
struct hv_util_sc* softc;
+ struct hv_vmbus_channel *chan;
int ret;
softc = device_get_softc(dev);
- softc->channel = vmbus_get_channel(dev);
softc->receive_buffer =
malloc(4 * PAGE_SIZE, M_DEVBUF, M_WAITOK | M_ZERO);
+ chan = vmbus_get_channel(dev);
/*
* These services are not performance critical and do not need
@@ -91,11 +92,10 @@
* Turn off batched reading for all util drivers before we open the
* channel.
*/
- vmbus_chan_set_readbatch(softc->channel, false);
+ vmbus_chan_set_readbatch(chan, false);
- ret = vmbus_chan_open(softc->channel, 4 * PAGE_SIZE,
- 4 * PAGE_SIZE, NULL, 0,
- softc->callback, softc);
+ ret = vmbus_chan_open(chan, 4 * PAGE_SIZE, 4 * PAGE_SIZE, NULL, 0,
+ softc->callback, softc);
if (ret)
goto error0;
@@ -112,7 +112,7 @@
{
struct hv_util_sc *sc = device_get_softc(dev);
- vmbus_chan_close(sc->channel);
+ vmbus_chan_close(vmbus_get_channel(dev));
free(sc->receive_buffer, M_DEVBUF);
return (0);
Index: head/sys/dev/hyperv/vmbus/vmbus_chan.c
===================================================================
--- head/sys/dev/hyperv/vmbus/vmbus_chan.c
+++ head/sys/dev/hyperv/vmbus/vmbus_chan.c
@@ -801,7 +801,7 @@
for (;;) {
uint32_t left;
- cb(cbarg);
+ cb(chan, cbarg);
left = hv_ring_buffer_read_end(&chan->ch_rxbr);
if (left == 0) {
@@ -817,7 +817,7 @@
{
struct hv_vmbus_channel *chan = xchan;
- chan->ch_cb(chan->ch_cbarg);
+ chan->ch_cb(chan, chan->ch_cbarg);
}
static __inline void
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 22, 12:46 PM (11 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16030020
Default Alt Text
D7243.diff (10 KB)
Attached To
Mode
D7243: hyperv/vmbus: Pass channel as the first argument for channel callback
Attached
Detach File
Event Timeline
Log In to Comment