Date: Mon, 11 Jul 2016 06:11:25 +0000 (UTC) From: Sepherosa Ziehau <sephe@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302543 - head/sys/dev/hyperv/vmbus Message-ID: <201607110611.u6B6BPD8036989@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: sephe Date: Mon Jul 11 06:11:24 2016 New Revision: 302543 URL: https://svnweb.freebsd.org/changeset/base/302543 Log: 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 Modified: head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h head/sys/dev/hyperv/vmbus/vmbus.c head/sys/dev/hyperv/vmbus/vmbus_reg.h Modified: head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Mon Jul 11 05:44:58 2016 (r302542) +++ head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Mon Jul 11 06:11:24 2016 (r302543) @@ -675,36 +675,6 @@ vmbus_channel_on_version_response(struct } /** - * @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) */ void Modified: head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Mon Jul 11 05:44:58 2016 (r302542) +++ head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Mon Jul 11 06:11:24 2016 (r302543) @@ -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( Modified: head/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- head/sys/dev/hyperv/vmbus/vmbus.c Mon Jul 11 05:44:58 2016 (r302542) +++ head/sys/dev/hyperv/vmbus/vmbus.c Mon Jul 11 06:11:24 2016 (r302543) @@ -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); Modified: head/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- head/sys/dev/hyperv/vmbus/vmbus_reg.h Mon Jul 11 05:44:58 2016 (r302542) +++ head/sys/dev/hyperv/vmbus/vmbus_reg.h Mon Jul 11 06:11:24 2016 (r302543) @@ -83,6 +83,7 @@ CTASSERT(sizeof(struct vmbus_evtflags) = * - 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_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607110611.u6B6BPD8036989>