hyperv/vmbus: Use post message Hypercall APIs for channel request
MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6831
This commit is contained in:
parent
56858424bb
commit
c1cc5bdfe8
@ -674,36 +674,6 @@ vmbus_channel_on_version_response(struct vmbus_softc *sc,
|
||||
vmbus_msghc_wakeup(sc, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Send a request to get all our pending offers.
|
||||
*/
|
||||
int
|
||||
hv_vmbus_request_channel_offers(void)
|
||||
{
|
||||
int ret;
|
||||
hv_vmbus_channel_msg_header* msg;
|
||||
hv_vmbus_channel_msg_info* msg_info;
|
||||
|
||||
msg_info = (hv_vmbus_channel_msg_info *)
|
||||
malloc(sizeof(hv_vmbus_channel_msg_info)
|
||||
+ sizeof(hv_vmbus_channel_msg_header), M_DEVBUF, M_NOWAIT);
|
||||
|
||||
if (msg_info == NULL) {
|
||||
if(bootverbose)
|
||||
printf("Error VMBUS: malloc failed for Request Offers\n");
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
msg = (hv_vmbus_channel_msg_header*) msg_info->msg;
|
||||
msg->message_type = HV_CHANNEL_MESSAGE_REQUEST_OFFERS;
|
||||
|
||||
ret = hv_vmbus_post_message(msg, sizeof(hv_vmbus_channel_msg_header));
|
||||
|
||||
free(msg_info, M_DEVBUF);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release channels that are unattached/unconnected (i.e., no drivers associated)
|
||||
*/
|
||||
|
@ -397,7 +397,6 @@ uint32_t hv_ring_buffer_read_end(
|
||||
|
||||
hv_vmbus_channel* hv_vmbus_allocate_channel(void);
|
||||
void hv_vmbus_free_vmbus_channel(hv_vmbus_channel *channel);
|
||||
int hv_vmbus_request_channel_offers(void);
|
||||
void hv_vmbus_release_unattached_channels(void);
|
||||
|
||||
uint16_t hv_vmbus_post_msg_via_msg_ipc(
|
||||
|
@ -98,6 +98,7 @@ struct vmbus_msghc_ctx {
|
||||
static int vmbus_init(struct vmbus_softc *);
|
||||
static int vmbus_init_contact(struct vmbus_softc *,
|
||||
uint32_t);
|
||||
static int vmbus_req_channels(struct vmbus_softc *sc);
|
||||
|
||||
static struct vmbus_msghc_ctx *vmbus_msghc_ctx_create(bus_dma_tag_t);
|
||||
static void vmbus_msghc_ctx_destroy(
|
||||
@ -417,6 +418,26 @@ vmbus_init(struct vmbus_softc *sc)
|
||||
return ENXIO;
|
||||
}
|
||||
|
||||
static int
|
||||
vmbus_req_channels(struct vmbus_softc *sc)
|
||||
{
|
||||
struct vmbus_chanmsg_channel_req *req;
|
||||
struct vmbus_msghc *mh;
|
||||
int error;
|
||||
|
||||
mh = vmbus_msghc_get(sc, sizeof(*req));
|
||||
if (mh == NULL)
|
||||
return ENXIO;
|
||||
|
||||
req = vmbus_msghc_dataptr(mh);
|
||||
req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHANNEL_REQ;
|
||||
|
||||
error = vmbus_msghc_exec_noresult(mh);
|
||||
vmbus_msghc_put(sc, mh);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
static void
|
||||
vmbus_msg_task(void *xsc, int pending __unused)
|
||||
{
|
||||
@ -1012,7 +1033,9 @@ vmbus_bus_init(void)
|
||||
else
|
||||
sc->vmbus_event_proc = vmbus_event_proc;
|
||||
|
||||
hv_vmbus_request_channel_offers();
|
||||
ret = vmbus_req_channels(sc);
|
||||
if (ret != 0)
|
||||
goto cleanup;
|
||||
|
||||
vmbus_scan();
|
||||
bus_generic_attach(sc->vmbus_dev);
|
||||
|
@ -83,6 +83,7 @@ CTASSERT(sizeof(struct vmbus_evtflags) == VMBUS_EVTFLAGS_SIZE);
|
||||
* - Embedded in hypercall_postmsg_in.hc_data, e.g. request.
|
||||
*/
|
||||
|
||||
#define VMBUS_CHANMSG_TYPE_CHANNEL_REQ 3 /* REQ */
|
||||
#define VMBUS_CHANMSG_TYPE_INIT_CONTACT 14 /* REQ */
|
||||
#define VMBUS_CHANMSG_TYPE_VERSION_RESP 15 /* RESP */
|
||||
|
||||
@ -107,4 +108,9 @@ struct vmbus_chanmsg_version_resp {
|
||||
uint8_t chm_supp;
|
||||
} __packed;
|
||||
|
||||
/* VMBUS_CHANMSG_TYPE_CHANNEL_REQ */
|
||||
struct vmbus_chanmsg_channel_req {
|
||||
struct vmbus_chanmsg_hdr chm_hdr;
|
||||
} __packed;
|
||||
|
||||
#endif /* !_VMBUS_REG_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user