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 hv_guid interface_type;
60 hv_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 uint32_t as_uint32_t;
103 uint32_t group_enable :4;
106 } hv_vmbus_monitor_trigger_state;
109 uint64_t as_uint64_t;
114 } hv_vmbus_monitor_trigger_group;
117 hv_vmbus_connection_id connection_id;
118 uint16_t flag_number;
120 } hv_vmbus_monitor_parameter;
123 * hv_vmbus_monitor_page Layout
124 * ------------------------------------------------------
125 * | 0 | trigger_state (4 bytes) | Rsvd1 (4 bytes) |
126 * | 8 | trigger_group[0] |
127 * | 10 | trigger_group[1] |
128 * | 18 | trigger_group[2] |
129 * | 20 | trigger_group[3] |
133 * | 40 | next_check_time[0][0] | next_check_time[0][1] |
135 * | 240 | latency[0][0..3] |
137 * | 440 | parameter[0][0] |
138 * | 448 | parameter[0][1] |
141 * ------------------------------------------------------
145 hv_vmbus_monitor_trigger_state trigger_state;
148 hv_vmbus_monitor_trigger_group trigger_group[4];
151 int32_t next_check_time[4][32];
153 uint16_t latency[4][32];
154 uint64_t rsvd_z3[32];
156 hv_vmbus_monitor_parameter parameter[4][32];
158 uint8_t rsvd_z4[1984];
159 } hv_vmbus_monitor_page;
162 * Private, VM Bus functions
164 struct sysctl_ctx_list;
165 struct sysctl_oid_list;
167 void hv_ring_buffer_stat(
168 struct sysctl_ctx_list *ctx,
169 struct sysctl_oid_list *tree_node,
170 hv_vmbus_ring_buffer_info *rbi,
173 int hv_vmbus_ring_buffer_init(
174 hv_vmbus_ring_buffer_info *ring_info,
176 uint32_t buffer_len);
178 void hv_ring_buffer_cleanup(
179 hv_vmbus_ring_buffer_info *ring_info);
181 int hv_ring_buffer_write(
182 hv_vmbus_ring_buffer_info *ring_info,
183 hv_vmbus_sg_buffer_list sg_buffers[],
184 uint32_t sg_buff_count,
185 boolean_t *need_sig);
187 int hv_ring_buffer_peek(
188 hv_vmbus_ring_buffer_info *ring_info,
190 uint32_t buffer_len);
192 int hv_ring_buffer_read(
193 hv_vmbus_ring_buffer_info *ring_info,
198 uint32_t hv_vmbus_get_ring_buffer_interrupt_mask(
199 hv_vmbus_ring_buffer_info *ring_info);
201 void hv_vmbus_dump_ring_info(
202 hv_vmbus_ring_buffer_info *ring_info,
205 void hv_ring_buffer_read_begin(
206 hv_vmbus_ring_buffer_info *ring_info);
208 uint32_t hv_ring_buffer_read_end(
209 hv_vmbus_ring_buffer_info *ring_info);
211 void hv_vmbus_free_vmbus_channel(hv_vmbus_channel *channel);
212 void hv_vmbus_release_unattached_channels(
213 struct vmbus_softc *);
215 struct hv_device* hv_vmbus_child_device_create(
217 hv_guid device_instance,
218 hv_vmbus_channel *channel);
220 void hv_vmbus_child_device_register(struct vmbus_softc *,
221 struct hv_device *child_dev);
222 int hv_vmbus_child_device_unregister(
223 struct hv_device *child_dev);
225 #endif /* __HYPERV_PRIV_H__ */