svn commit: r302619 - in head/sys/dev/hyperv: include vmbus
Sepherosa Ziehau
sephe at FreeBSD.org
Tue Jul 12 05:09:10 UTC 2016
Author: sephe
Date: Tue Jul 12 05:09:07 2016
New Revision: 302619
URL: https://svnweb.freebsd.org/changeset/base/302619
Log:
hyperv/vmbus: Busdma-fy Hypercall signal event input parameter.
MFC after: 1 week
Sponsored by: Microsoft OSTC
Differential Revision: https://reviews.freebsd.org/D6916
Modified:
head/sys/dev/hyperv/include/hyperv.h
head/sys/dev/hyperv/include/hyperv_busdma.h
head/sys/dev/hyperv/vmbus/hv_channel.c
head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
head/sys/dev/hyperv/vmbus/hv_connection.c
head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
head/sys/dev/hyperv/vmbus/hyperv.c
head/sys/dev/hyperv/vmbus/hyperv_reg.h
head/sys/dev/hyperv/vmbus/hyperv_var.h
head/sys/dev/hyperv/vmbus/vmbus.c
head/sys/dev/hyperv/vmbus/vmbus_var.h
Modified: head/sys/dev/hyperv/include/hyperv.h
==============================================================================
--- head/sys/dev/hyperv/include/hyperv.h Tue Jul 12 04:58:21 2016 (r302618)
+++ head/sys/dev/hyperv/include/hyperv.h Tue Jul 12 05:09:07 2016 (r302619)
@@ -55,6 +55,7 @@
#include <amd64/include/xen/synch_bitops.h>
#include <amd64/include/atomic.h>
+#include <dev/hyperv/include/hyperv_busdma.h>
typedef uint8_t hv_bool_uint8_t;
@@ -528,20 +529,6 @@ typedef union {
} __packed hv_vmbus_connection_id;
-/*
- * Definition of the hv_vmbus_signal_event hypercall input structure
- */
-typedef struct {
- hv_vmbus_connection_id connection_id;
- uint16_t flag_number;
- uint16_t rsvd_z;
-} __packed hv_vmbus_input_signal_event;
-
-typedef struct {
- uint64_t align8;
- hv_vmbus_input_signal_event event;
-} __packed hv_vmbus_input_signal_event_buffer;
-
typedef struct hv_vmbus_channel {
TAILQ_ENTRY(hv_vmbus_channel) list_entry;
struct hv_device* device;
@@ -589,14 +576,8 @@ typedef struct hv_vmbus_channel {
boolean_t is_dedicated_interrupt;
- /*
- * Used as an input param for HV_CALL_SIGNAL_EVENT hypercall.
- */
- hv_vmbus_input_signal_event_buffer signal_event_buffer;
- /*
- * 8-bytes aligned of the buffer above
- */
- hv_vmbus_input_signal_event *signal_event_param;
+ struct hypercall_sigevt_in *ch_sigevt;
+ struct hyperv_dma ch_sigevt_dma;
/*
* From Win8, this field specifies the target virtual process
Modified: head/sys/dev/hyperv/include/hyperv_busdma.h
==============================================================================
--- head/sys/dev/hyperv/include/hyperv_busdma.h Tue Jul 12 04:58:21 2016 (r302618)
+++ head/sys/dev/hyperv/include/hyperv_busdma.h Tue Jul 12 05:09:07 2016 (r302619)
@@ -29,6 +29,10 @@
#ifndef _HYPERV_BUSDMA_H_
#define _HYPERV_BUSDMA_H_
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <machine/bus.h>
+
struct hyperv_dma {
bus_addr_t hv_paddr;
bus_dma_tag_t hv_dtag;
Modified: head/sys/dev/hyperv/vmbus/hv_channel.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_channel.c Tue Jul 12 04:58:21 2016 (r302618)
+++ head/sys/dev/hyperv/vmbus/hv_channel.c Tue Jul 12 05:09:07 2016 (r302619)
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
#include <vm/pmap.h>
#include <dev/hyperv/vmbus/hv_vmbus_priv.h>
+#include <dev/hyperv/vmbus/hyperv_var.h>
#include <dev/hyperv/vmbus/vmbus_reg.h>
#include <dev/hyperv/vmbus/vmbus_var.h>
@@ -72,7 +73,7 @@ vmbus_channel_set_event(hv_vmbus_channel
(uint32_t *)&monitor_page->
trigger_group[channel->monitor_group].u.pending);
} else {
- hv_vmbus_set_event(channel);
+ hypercall_signal_event(channel->ch_sigevt_dma.hv_paddr);
}
}
Modified: head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Jul 12 04:58:21 2016 (r302618)
+++ head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Jul 12 05:09:07 2016 (r302619)
@@ -32,6 +32,7 @@
#include <sys/mbuf.h>
#include <sys/mutex.h>
+#include <dev/hyperv/include/hyperv_busdma.h>
#include <dev/hyperv/vmbus/hv_vmbus_priv.h>
#include <dev/hyperv/vmbus/vmbus_reg.h>
#include <dev/hyperv/vmbus/vmbus_var.h>
@@ -327,23 +328,23 @@ vmbus_channel_on_offer_internal(struct v
*/
new_channel->batched_reading = TRUE;
- new_channel->signal_event_param =
- (hv_vmbus_input_signal_event *)
- (HV_ALIGN_UP((unsigned long)
- &new_channel->signal_event_buffer,
- HV_HYPERCALL_PARAM_ALIGN));
-
- new_channel->signal_event_param->connection_id.as_uint32_t = 0;
- new_channel->signal_event_param->connection_id.u.id =
- HV_VMBUS_EVENT_CONNECTION_ID;
- new_channel->signal_event_param->flag_number = 0;
- new_channel->signal_event_param->rsvd_z = 0;
+ new_channel->ch_sigevt = hyperv_dmamem_alloc(
+ bus_get_dma_tag(sc->vmbus_dev),
+ HYPERCALL_SIGEVTIN_ALIGN, 0, sizeof(struct hypercall_sigevt_in),
+ &new_channel->ch_sigevt_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO);
+ if (new_channel->ch_sigevt == NULL) {
+ device_printf(sc->vmbus_dev, "sigevt alloc failed\n");
+ /* XXX */
+ mtx_destroy(&new_channel->sc_lock);
+ free(new_channel, M_DEVBUF);
+ return;
+ }
+ new_channel->ch_sigevt->hc_connid = VMBUS_CONNID_EVENT;
if (hv_vmbus_protocal_version != HV_VMBUS_VERSION_WS2008) {
new_channel->is_dedicated_interrupt =
(offer->is_dedicated_interrupt != 0);
- new_channel->signal_event_param->connection_id.u.id =
- offer->connection_id;
+ new_channel->ch_sigevt->hc_connid = offer->connection_id;
}
memcpy(&new_channel->offer_msg, offer,
Modified: head/sys/dev/hyperv/vmbus/hv_connection.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_connection.c Tue Jul 12 04:58:21 2016 (r302618)
+++ head/sys/dev/hyperv/vmbus/hv_connection.c Tue Jul 12 05:09:07 2016 (r302619)
@@ -158,16 +158,6 @@ vmbus_event_proc_compat(struct vmbus_sof
}
}
-/**
- * Send an event notification to the parent
- */
-int
-hv_vmbus_set_event(hv_vmbus_channel *channel)
-{
-
- return hv_vmbus_signal_event(channel->signal_event_param);
-}
-
void
vmbus_on_channel_open(const struct hv_vmbus_channel *chan)
{
Modified: head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Jul 12 04:58:21 2016 (r302618)
+++ head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Jul 12 05:09:07 2016 (r302619)
@@ -363,6 +363,5 @@ int hv_vmbus_child_device_unregister(
*/
int hv_vmbus_connect(struct vmbus_softc *);
int hv_vmbus_disconnect(void);
-int hv_vmbus_set_event(hv_vmbus_channel *channel);
#endif /* __HYPERV_PRIV_H__ */
Modified: head/sys/dev/hyperv/vmbus/hyperv.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hyperv.c Tue Jul 12 04:58:21 2016 (r302618)
+++ head/sys/dev/hyperv/vmbus/hyperv.c Tue Jul 12 05:09:07 2016 (r302619)
@@ -125,6 +125,13 @@ hypercall_post_message(bus_addr_t msg_pa
HYPERCALL_POST_MESSAGE, msg_paddr, 0);
}
+uint64_t
+hypercall_signal_event(bus_addr_t sigevt_paddr)
+{
+ return hypercall_md(hypercall_context.hc_addr,
+ HYPERCALL_SIGNAL_EVENT, sigevt_paddr, 0);
+}
+
/**
* @brief Signal an event on the specified connection using the hypervisor
* event IPC. (This involves a hypercall.)
Modified: head/sys/dev/hyperv/vmbus/hyperv_reg.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/hyperv_reg.h Tue Jul 12 04:58:21 2016 (r302618)
+++ head/sys/dev/hyperv/vmbus/hyperv_reg.h Tue Jul 12 05:09:07 2016 (r302619)
@@ -148,6 +148,7 @@
* Hypercall input values
*/
#define HYPERCALL_POST_MESSAGE 0x005c
+#define HYPERCALL_SIGNAL_EVENT 0x005d
/*
* Hypercall input parameters
@@ -169,4 +170,15 @@ struct hypercall_postmsg_in {
} __packed;
CTASSERT(sizeof(struct hypercall_postmsg_in) == HYPERCALL_POSTMSGIN_SIZE);
+/*
+ * HYPERCALL_SIGNAL_EVENT
+ */
+#define HYPERCALL_SIGEVTIN_ALIGN 8
+
+struct hypercall_sigevt_in {
+ uint32_t hc_connid;
+ uint16_t hc_evtflag_ofs;
+ uint16_t hc_rsvd;
+} __packed;
+
#endif /* !_HYPERV_REG_H_ */
Modified: head/sys/dev/hyperv/vmbus/hyperv_var.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/hyperv_var.h Tue Jul 12 04:58:21 2016 (r302618)
+++ head/sys/dev/hyperv/vmbus/hyperv_var.h Tue Jul 12 05:09:07 2016 (r302619)
@@ -39,5 +39,6 @@ extern u_int hyperv_features;
extern u_int hyperv_recommends;
uint64_t hypercall_post_message(bus_addr_t msg_paddr);
+uint64_t hypercall_signal_event(bus_addr_t sigevt_paddr);
#endif /* !_HYPERV_VAR_H_ */
Modified: head/sys/dev/hyperv/vmbus/vmbus.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus.c Tue Jul 12 04:58:21 2016 (r302618)
+++ head/sys/dev/hyperv/vmbus/vmbus.c Tue Jul 12 05:09:07 2016 (r302619)
@@ -69,12 +69,6 @@ __FBSDID("$FreeBSD$");
#include <contrib/dev/acpica/include/acpi.h>
#include "acpi_if.h"
-/*
- * NOTE: DO NOT CHANGE THESE
- */
-#define VMBUS_CONNID_MESSAGE 1
-#define VMBUS_CONNID_EVENT 2
-
struct vmbus_msghc {
struct hypercall_postmsg_in *mh_inprm;
struct hypercall_postmsg_in mh_inprm_save;
Modified: head/sys/dev/hyperv/vmbus/vmbus_var.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus_var.h Tue Jul 12 04:58:21 2016 (r302618)
+++ head/sys/dev/hyperv/vmbus/vmbus_var.h Tue Jul 12 05:09:07 2016 (r302619)
@@ -46,6 +46,12 @@
*/
#define VMBUS_SINT_TIMER 4
+/*
+ * NOTE: DO NOT CHANGE THESE
+ */
+#define VMBUS_CONNID_MESSAGE 1
+#define VMBUS_CONNID_EVENT 2
+
struct vmbus_pcpu_data {
u_long *intr_cnt; /* Hyper-V interrupt counter */
struct vmbus_message *message; /* shared messages */
More information about the svn-src-all
mailing list