mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-02 12:20:51 +00:00
hyperv/vmbus: Move bus related message processing into vmbus.
MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7125
This commit is contained in:
parent
1daad8f5ad
commit
e11f3043cd
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=302823
@ -37,13 +37,8 @@
|
||||
#include <dev/hyperv/vmbus/vmbus_reg.h>
|
||||
#include <dev/hyperv/vmbus/vmbus_var.h>
|
||||
|
||||
typedef void (*vmbus_chanmsg_proc_t)
|
||||
(struct vmbus_softc *, const struct vmbus_message *);
|
||||
|
||||
static void vmbus_chan_detach_task(void *, int);
|
||||
|
||||
static void vmbus_channel_on_offers_delivered(struct vmbus_softc *,
|
||||
const struct vmbus_message *);
|
||||
static void vmbus_chan_msgproc_choffer(struct vmbus_softc *,
|
||||
const struct vmbus_message *);
|
||||
static void vmbus_chan_msgproc_chrescind(struct vmbus_softc *,
|
||||
@ -52,27 +47,16 @@ static void vmbus_chan_msgproc_chrescind(struct vmbus_softc *,
|
||||
/*
|
||||
* Vmbus channel message processing.
|
||||
*/
|
||||
|
||||
#define VMBUS_CHANMSG_PROC(name, func) \
|
||||
[VMBUS_CHANMSG_TYPE_##name] = func
|
||||
#define VMBUS_CHANMSG_PROC_WAKEUP(name) \
|
||||
VMBUS_CHANMSG_PROC(name, vmbus_msghc_wakeup)
|
||||
|
||||
static const vmbus_chanmsg_proc_t
|
||||
vmbus_chanmsg_process[VMBUS_CHANMSG_TYPE_MAX] = {
|
||||
vmbus_chan_msgprocs[VMBUS_CHANMSG_TYPE_MAX] = {
|
||||
VMBUS_CHANMSG_PROC(CHOFFER, vmbus_chan_msgproc_choffer),
|
||||
VMBUS_CHANMSG_PROC(CHRESCIND, vmbus_chan_msgproc_chrescind),
|
||||
VMBUS_CHANMSG_PROC(CHOFFER_DONE,vmbus_channel_on_offers_delivered),
|
||||
|
||||
VMBUS_CHANMSG_PROC_WAKEUP(CHOPEN_RESP),
|
||||
VMBUS_CHANMSG_PROC_WAKEUP(GPADL_CONNRESP),
|
||||
VMBUS_CHANMSG_PROC_WAKEUP(GPADL_DISCONNRESP),
|
||||
VMBUS_CHANMSG_PROC_WAKEUP(CONNECT_RESP)
|
||||
VMBUS_CHANMSG_PROC_WAKEUP(GPADL_DISCONNRESP)
|
||||
};
|
||||
|
||||
#undef VMBUS_CHANMSG_PROC_WAKEUP
|
||||
#undef VMBUS_CHANMSG_PROC
|
||||
|
||||
static struct hv_vmbus_channel *
|
||||
vmbus_chan_alloc(struct vmbus_softc *sc)
|
||||
{
|
||||
@ -390,19 +374,6 @@ vmbus_chan_detach_task(void *xchan, int pending __unused)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Invoked when all offers have been delivered.
|
||||
*/
|
||||
static void
|
||||
vmbus_channel_on_offers_delivered(struct vmbus_softc *sc,
|
||||
const struct vmbus_message *msg __unused)
|
||||
{
|
||||
|
||||
/* No more new channels for the channel request. */
|
||||
vmbus_scan_done(sc);
|
||||
}
|
||||
|
||||
/*
|
||||
* Detach all devices and destroy the corresponding primary channels.
|
||||
*/
|
||||
@ -538,13 +509,10 @@ vmbus_chan_msgproc(struct vmbus_softc *sc, const struct vmbus_message *msg)
|
||||
uint32_t msg_type;
|
||||
|
||||
msg_type = ((const struct vmbus_chanmsg_hdr *)msg->msg_data)->chm_type;
|
||||
if (msg_type >= VMBUS_CHANMSG_TYPE_MAX) {
|
||||
device_printf(sc->vmbus_dev, "unknown message type 0x%x\n",
|
||||
msg_type);
|
||||
return;
|
||||
}
|
||||
KASSERT(msg_type < VMBUS_CHANMSG_TYPE_MAX,
|
||||
("invalid message type %u", msg_type));
|
||||
|
||||
msg_proc = vmbus_chanmsg_process[msg_type];
|
||||
msg_proc = vmbus_chan_msgprocs[msg_type];
|
||||
if (msg_proc != NULL)
|
||||
msg_proc(sc, msg);
|
||||
}
|
||||
|
@ -98,7 +98,12 @@ static int vmbus_req_channels(struct vmbus_softc *sc);
|
||||
static void vmbus_disconnect(struct vmbus_softc *);
|
||||
static int vmbus_scan(struct vmbus_softc *);
|
||||
static void vmbus_scan_wait(struct vmbus_softc *);
|
||||
static void vmbus_scan_newchan(struct vmbus_softc *);
|
||||
static void vmbus_scan_newdev(struct vmbus_softc *);
|
||||
static void vmbus_scan_done(struct vmbus_softc *,
|
||||
const struct vmbus_message *);
|
||||
static void vmbus_chanmsg_handle(struct vmbus_softc *,
|
||||
const struct vmbus_message *);
|
||||
|
||||
static int vmbus_sysctl_version(SYSCTL_HANDLER_ARGS);
|
||||
|
||||
@ -122,6 +127,12 @@ static const uint32_t vmbus_version[] = {
|
||||
VMBUS_VERSION_WS2008
|
||||
};
|
||||
|
||||
static const vmbus_chanmsg_proc_t
|
||||
vmbus_chanmsg_handlers[VMBUS_CHANMSG_TYPE_MAX] = {
|
||||
VMBUS_CHANMSG_PROC(CHOFFER_DONE, vmbus_scan_done),
|
||||
VMBUS_CHANMSG_PROC_WAKEUP(CONNECT_RESP)
|
||||
};
|
||||
|
||||
static struct vmbus_msghc *
|
||||
vmbus_msghc_alloc(bus_dma_tag_t parent_dtag)
|
||||
{
|
||||
@ -480,7 +491,7 @@ vmbus_req_channels(struct vmbus_softc *sc)
|
||||
return error;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
vmbus_scan_newchan(struct vmbus_softc *sc)
|
||||
{
|
||||
mtx_lock(&sc->vmbus_scan_lock);
|
||||
@ -489,8 +500,9 @@ vmbus_scan_newchan(struct vmbus_softc *sc)
|
||||
mtx_unlock(&sc->vmbus_scan_lock);
|
||||
}
|
||||
|
||||
void
|
||||
vmbus_scan_done(struct vmbus_softc *sc)
|
||||
static void
|
||||
vmbus_scan_done(struct vmbus_softc *sc,
|
||||
const struct vmbus_message *msg __unused)
|
||||
{
|
||||
mtx_lock(&sc->vmbus_scan_lock);
|
||||
sc->vmbus_scan_chcnt |= VMBUS_SCAN_CHCNT_DONE;
|
||||
@ -559,6 +571,27 @@ vmbus_scan(struct vmbus_softc *sc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
vmbus_chanmsg_handle(struct vmbus_softc *sc, const struct vmbus_message *msg)
|
||||
{
|
||||
vmbus_chanmsg_proc_t msg_proc;
|
||||
uint32_t msg_type;
|
||||
|
||||
msg_type = ((const struct vmbus_chanmsg_hdr *)msg->msg_data)->chm_type;
|
||||
if (msg_type >= VMBUS_CHANMSG_TYPE_MAX) {
|
||||
device_printf(sc->vmbus_dev, "unknown message type 0x%x\n",
|
||||
msg_type);
|
||||
return;
|
||||
}
|
||||
|
||||
msg_proc = vmbus_chanmsg_handlers[msg_type];
|
||||
if (msg_proc != NULL)
|
||||
msg_proc(sc, msg);
|
||||
|
||||
/* Channel specific processing */
|
||||
vmbus_chan_msgproc(sc, msg);
|
||||
}
|
||||
|
||||
static void
|
||||
vmbus_msg_task(void *xsc, int pending __unused)
|
||||
{
|
||||
@ -572,7 +605,7 @@ vmbus_msg_task(void *xsc, int pending __unused)
|
||||
break;
|
||||
} else if (msg->msg_type == HYPERV_MSGTYPE_CHANNEL) {
|
||||
/* Channel message */
|
||||
vmbus_chan_msgproc(sc,
|
||||
vmbus_chanmsg_handle(sc,
|
||||
__DEVOLATILE(const struct vmbus_message *, msg));
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,17 @@
|
||||
#define VMBUS_CONNID_MESSAGE 1
|
||||
#define VMBUS_CONNID_EVENT 2
|
||||
|
||||
struct vmbus_message;
|
||||
struct vmbus_softc;
|
||||
|
||||
typedef void (*vmbus_chanmsg_proc_t)(struct vmbus_softc *,
|
||||
const struct vmbus_message *);
|
||||
|
||||
#define VMBUS_CHANMSG_PROC(name, func) \
|
||||
[VMBUS_CHANMSG_TYPE_##name] = func
|
||||
#define VMBUS_CHANMSG_PROC_WAKEUP(name) \
|
||||
VMBUS_CHANMSG_PROC(name, vmbus_msghc_wakeup)
|
||||
|
||||
struct vmbus_pcpu_data {
|
||||
u_long *intr_cnt; /* Hyper-V interrupt counter */
|
||||
struct vmbus_message *message; /* shared messages */
|
||||
@ -151,9 +162,6 @@ const struct vmbus_message *vmbus_msghc_wait_result(struct vmbus_softc *,
|
||||
void vmbus_msghc_wakeup(struct vmbus_softc *, const struct vmbus_message *);
|
||||
void vmbus_msghc_reset(struct vmbus_msghc *, size_t);
|
||||
|
||||
void vmbus_scan_done(struct vmbus_softc *);
|
||||
void vmbus_scan_newchan(struct vmbus_softc *);
|
||||
|
||||
uint32_t vmbus_gpadl_alloc(struct vmbus_softc *);
|
||||
|
||||
#endif /* !_VMBUS_VAR_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user