2 * Copyright (c) 2009-2012,2016 Microsoft Corp.
3 * Copyright (c) 2012 NetApp Inc.
4 * Copyright (c) 2012 Citrix Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice unmodified, this list of conditions, and the following
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef __HYPERV_PRIV_H__
32 #define __HYPERV_PRIV_H__
34 #include <sys/param.h>
36 #include <sys/mutex.h>
39 #include <dev/hyperv/include/hyperv.h>
46 } hv_vmbus_sg_buffer_list;
49 uint32_t current_interrupt_mask;
50 uint32_t current_read_index;
51 uint32_t current_write_index;
52 uint32_t bytes_avail_to_read;
53 uint32_t bytes_avail_to_write;
54 } hv_vmbus_ring_buffer_debug_info;
58 hv_vmbus_channel_state state;
59 struct hyperv_guid interface_type;
60 struct hyperv_guid interface_instance;
62 uint32_t server_monitor_pending;
63 uint32_t server_monitor_latency;
64 uint32_t server_monitor_connection_id;
65 uint32_t client_monitor_pending;
66 uint32_t client_monitor_latency;
67 uint32_t client_monitor_connection_id;
68 hv_vmbus_ring_buffer_debug_info inbound;
69 hv_vmbus_ring_buffer_debug_info outbound;
70 } hv_vmbus_channel_debug_info;
73 * The format must be the same as hv_vm_data_gpa_direct
75 typedef struct hv_vmbus_channel_packet_page_buffer {
77 uint16_t data_offset8;
80 uint64_t transaction_id;
83 hv_vmbus_page_buffer range[HV_MAX_PAGE_BUFFER_COUNT];
84 } __packed hv_vmbus_channel_packet_page_buffer;
87 * The format must be the same as hv_vm_data_gpa_direct
89 typedef struct hv_vmbus_channel_packet_multipage_buffer {
91 uint16_t data_offset8;
94 uint64_t transaction_id;
96 uint32_t range_count; /* Always 1 in this case */
97 hv_vmbus_multipage_buffer range;
98 } __packed hv_vmbus_channel_packet_multipage_buffer;
101 * Private, VM Bus functions
103 struct sysctl_ctx_list;
104 struct sysctl_oid_list;
106 void hv_ring_buffer_stat(
107 struct sysctl_ctx_list *ctx,
108 struct sysctl_oid_list *tree_node,
109 hv_vmbus_ring_buffer_info *rbi,
112 int hv_vmbus_ring_buffer_init(
113 hv_vmbus_ring_buffer_info *ring_info,
115 uint32_t buffer_len);
117 void hv_ring_buffer_cleanup(
118 hv_vmbus_ring_buffer_info *ring_info);
120 int hv_ring_buffer_write(
121 hv_vmbus_ring_buffer_info *ring_info,
122 hv_vmbus_sg_buffer_list sg_buffers[],
123 uint32_t sg_buff_count,
124 boolean_t *need_sig);
126 int hv_ring_buffer_peek(
127 hv_vmbus_ring_buffer_info *ring_info,
129 uint32_t buffer_len);
131 int hv_ring_buffer_read(
132 hv_vmbus_ring_buffer_info *ring_info,
137 uint32_t hv_vmbus_get_ring_buffer_interrupt_mask(
138 hv_vmbus_ring_buffer_info *ring_info);
140 void hv_vmbus_dump_ring_info(
141 hv_vmbus_ring_buffer_info *ring_info,
144 void hv_ring_buffer_read_begin(
145 hv_vmbus_ring_buffer_info *ring_info);
147 uint32_t hv_ring_buffer_read_end(
148 hv_vmbus_ring_buffer_info *ring_info);
150 void hv_vmbus_free_vmbus_channel(hv_vmbus_channel *channel);
151 void hv_vmbus_release_unattached_channels(
152 struct vmbus_softc *);
154 int hv_vmbus_child_device_register(
155 struct hv_vmbus_channel *chan);
156 int hv_vmbus_child_device_unregister(
157 struct hv_vmbus_channel *chan);
159 #endif /* __HYPERV_PRIV_H__ */