Commit | Line | Data |
---|---|---|
5ca7252a S |
1 | /* |
2 | * | |
3 | * Copyright (c) 2011, Microsoft Corporation. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify it | |
6 | * under the terms and conditions of the GNU General Public License, | |
7 | * version 2, as published by the Free Software Foundation. | |
8 | * | |
9 | * This program is distributed in the hope it will be useful, but WITHOUT | |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | * more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License along with | |
15 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | |
16 | * Place - Suite 330, Boston, MA 02111-1307 USA. | |
17 | * | |
18 | * Authors: | |
19 | * Haiyang Zhang <haiyangz@microsoft.com> | |
20 | * Hank Janssen <hjanssen@microsoft.com> | |
21 | * K. Y. Srinivasan <kys@microsoft.com> | |
22 | * | |
23 | */ | |
24 | ||
25 | #ifndef _HYPERV_NET_H | |
26 | #define _HYPERV_NET_H | |
27 | ||
8a079411 | 28 | #include <linux/list.h> |
46a97191 | 29 | #include <linux/hyperv.h> |
7591157e | 30 | #include <linux/rndis.h> |
41308862 S |
31 | |
32 | /* Fwd declaration */ | |
33 | struct hv_netvsc_packet; | |
34 | ||
35 | /* Represent the xfer page packet which contains 1 or more netvsc packet */ | |
36 | struct xferpage_packet { | |
37 | struct list_head list_ent; | |
63f6921d | 38 | u32 status; |
41308862 S |
39 | |
40 | /* # of netvsc packets this xfer packet contains */ | |
41 | u32 count; | |
42 | }; | |
43 | ||
41308862 S |
44 | /* |
45 | * Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame | |
46 | * within the RNDIS | |
47 | */ | |
48 | struct hv_netvsc_packet { | |
49 | /* Bookkeeping stuff */ | |
50 | struct list_head list_ent; | |
63f6921d | 51 | u32 status; |
41308862 S |
52 | |
53 | struct hv_device *device; | |
54 | bool is_data_pkt; | |
1f5f3a75 | 55 | u16 vlan_tci; |
41308862 S |
56 | |
57 | /* | |
58 | * Valid only for receives when we break a xfer page packet | |
59 | * into multiple netvsc packets | |
60 | */ | |
61 | struct xferpage_packet *xfer_page_pkt; | |
62 | ||
63 | union { | |
64 | struct { | |
65 | u64 recv_completion_tid; | |
66 | void *recv_completion_ctx; | |
67 | void (*recv_completion)(void *context); | |
68 | } recv; | |
69 | struct { | |
70 | u64 send_completion_tid; | |
71 | void *send_completion_ctx; | |
72 | void (*send_completion)(void *context); | |
73 | } send; | |
74 | } completion; | |
75 | ||
76 | /* This points to the memory after page_buf */ | |
77 | void *extension; | |
78 | ||
79 | u32 total_data_buflen; | |
80 | /* Points to the send/receive buffer where the ethernet frame is */ | |
45326342 | 81 | void *data; |
41308862 | 82 | u32 page_buf_cnt; |
45326342 | 83 | struct hv_page_buffer page_buf[0]; |
41308862 | 84 | }; |
41308862 | 85 | |
41308862 | 86 | struct netvsc_device_info { |
9a4c831e | 87 | unsigned char mac_adr[ETH_ALEN]; |
41308862 | 88 | bool link_state; /* 0 - link up, 1 - link down */ |
78001df3 | 89 | int ring_size; |
41308862 S |
90 | }; |
91 | ||
d426b2e3 HZ |
92 | enum rndis_device_state { |
93 | RNDIS_DEV_UNINITIALIZED = 0, | |
94 | RNDIS_DEV_INITIALIZING, | |
95 | RNDIS_DEV_INITIALIZED, | |
96 | RNDIS_DEV_DATAINITIALIZED, | |
97 | }; | |
98 | ||
99 | struct rndis_device { | |
100 | struct netvsc_device *net_dev; | |
101 | ||
102 | enum rndis_device_state state; | |
103 | bool link_state; | |
104 | atomic_t new_req_id; | |
105 | ||
106 | spinlock_t request_lock; | |
107 | struct list_head req_list; | |
108 | ||
109 | unsigned char hw_mac_adr[ETH_ALEN]; | |
110 | }; | |
111 | ||
112 | ||
41308862 S |
113 | /* Interface */ |
114 | int netvsc_device_add(struct hv_device *device, void *additional_info); | |
115 | int netvsc_device_remove(struct hv_device *device); | |
f9819f05 S |
116 | int netvsc_send(struct hv_device *device, |
117 | struct hv_netvsc_packet *packet); | |
90ef117a S |
118 | void netvsc_linkstatus_callback(struct hv_device *device_obj, |
119 | unsigned int status); | |
f79adf8f S |
120 | int netvsc_recv_callback(struct hv_device *device_obj, |
121 | struct hv_netvsc_packet *packet); | |
41308862 S |
122 | int rndis_filter_open(struct hv_device *dev); |
123 | int rndis_filter_close(struct hv_device *dev); | |
bdbad576 | 124 | int rndis_filter_device_add(struct hv_device *dev, |
41308862 | 125 | void *additional_info); |
df06bcff | 126 | void rndis_filter_device_remove(struct hv_device *dev); |
5fcc4115 S |
127 | int rndis_filter_receive(struct hv_device *dev, |
128 | struct hv_netvsc_packet *pkt); | |
41308862 | 129 | |
52584904 | 130 | |
52584904 | 131 | |
0652aebc S |
132 | int rndis_filter_send(struct hv_device *dev, |
133 | struct hv_netvsc_packet *pkt); | |
134 | ||
d426b2e3 | 135 | int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter); |
1ce09e89 | 136 | int rndis_filter_set_device_mac(struct hv_device *hdev, char *mac); |
d426b2e3 HZ |
137 | |
138 | ||
52584904 S |
139 | #define NVSP_INVALID_PROTOCOL_VERSION ((u32)0xFFFFFFFF) |
140 | ||
141 | #define NVSP_PROTOCOL_VERSION_1 2 | |
f157e78d | 142 | #define NVSP_PROTOCOL_VERSION_2 0x30002 |
52584904 S |
143 | |
144 | enum { | |
145 | NVSP_MSG_TYPE_NONE = 0, | |
146 | ||
147 | /* Init Messages */ | |
148 | NVSP_MSG_TYPE_INIT = 1, | |
149 | NVSP_MSG_TYPE_INIT_COMPLETE = 2, | |
150 | ||
151 | NVSP_VERSION_MSG_START = 100, | |
152 | ||
153 | /* Version 1 Messages */ | |
154 | NVSP_MSG1_TYPE_SEND_NDIS_VER = NVSP_VERSION_MSG_START, | |
155 | ||
156 | NVSP_MSG1_TYPE_SEND_RECV_BUF, | |
157 | NVSP_MSG1_TYPE_SEND_RECV_BUF_COMPLETE, | |
158 | NVSP_MSG1_TYPE_REVOKE_RECV_BUF, | |
159 | ||
160 | NVSP_MSG1_TYPE_SEND_SEND_BUF, | |
161 | NVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE, | |
162 | NVSP_MSG1_TYPE_REVOKE_SEND_BUF, | |
163 | ||
164 | NVSP_MSG1_TYPE_SEND_RNDIS_PKT, | |
165 | NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE, | |
166 | ||
f157e78d HZ |
167 | /* Version 2 messages */ |
168 | NVSP_MSG2_TYPE_SEND_CHIMNEY_DELEGATED_BUF, | |
169 | NVSP_MSG2_TYPE_SEND_CHIMNEY_DELEGATED_BUF_COMP, | |
170 | NVSP_MSG2_TYPE_REVOKE_CHIMNEY_DELEGATED_BUF, | |
171 | ||
172 | NVSP_MSG2_TYPE_RESUME_CHIMNEY_RX_INDICATION, | |
173 | ||
174 | NVSP_MSG2_TYPE_TERMINATE_CHIMNEY, | |
175 | NVSP_MSG2_TYPE_TERMINATE_CHIMNEY_COMP, | |
176 | ||
177 | NVSP_MSG2_TYPE_INDICATE_CHIMNEY_EVENT, | |
178 | ||
179 | NVSP_MSG2_TYPE_SEND_CHIMNEY_PKT, | |
180 | NVSP_MSG2_TYPE_SEND_CHIMNEY_PKT_COMP, | |
181 | ||
182 | NVSP_MSG2_TYPE_POST_CHIMNEY_RECV_REQ, | |
183 | NVSP_MSG2_TYPE_POST_CHIMNEY_RECV_REQ_COMP, | |
184 | ||
185 | NVSP_MSG2_TYPE_ALLOC_RXBUF, | |
186 | NVSP_MSG2_TYPE_ALLOC_RXBUF_COMP, | |
187 | ||
188 | NVSP_MSG2_TYPE_FREE_RXBUF, | |
189 | ||
190 | NVSP_MSG2_TYPE_SEND_VMQ_RNDIS_PKT, | |
191 | NVSP_MSG2_TYPE_SEND_VMQ_RNDIS_PKT_COMP, | |
192 | ||
193 | NVSP_MSG2_TYPE_SEND_NDIS_CONFIG, | |
194 | ||
195 | NVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE, | |
196 | NVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE_COMP, | |
52584904 S |
197 | }; |
198 | ||
199 | enum { | |
200 | NVSP_STAT_NONE = 0, | |
201 | NVSP_STAT_SUCCESS, | |
202 | NVSP_STAT_FAIL, | |
203 | NVSP_STAT_PROTOCOL_TOO_NEW, | |
204 | NVSP_STAT_PROTOCOL_TOO_OLD, | |
205 | NVSP_STAT_INVALID_RNDIS_PKT, | |
206 | NVSP_STAT_BUSY, | |
f157e78d | 207 | NVSP_STAT_PROTOCOL_UNSUPPORTED, |
52584904 S |
208 | NVSP_STAT_MAX, |
209 | }; | |
210 | ||
211 | struct nvsp_message_header { | |
212 | u32 msg_type; | |
213 | }; | |
214 | ||
215 | /* Init Messages */ | |
216 | ||
217 | /* | |
218 | * This message is used by the VSC to initialize the channel after the channels | |
219 | * has been opened. This message should never include anything other then | |
220 | * versioning (i.e. this message will be the same for ever). | |
221 | */ | |
222 | struct nvsp_message_init { | |
223 | u32 min_protocol_ver; | |
224 | u32 max_protocol_ver; | |
225 | } __packed; | |
226 | ||
227 | /* | |
228 | * This message is used by the VSP to complete the initialization of the | |
229 | * channel. This message should never include anything other then versioning | |
230 | * (i.e. this message will be the same for ever). | |
231 | */ | |
232 | struct nvsp_message_init_complete { | |
233 | u32 negotiated_protocol_ver; | |
234 | u32 max_mdl_chain_len; | |
235 | u32 status; | |
236 | } __packed; | |
237 | ||
238 | union nvsp_message_init_uber { | |
239 | struct nvsp_message_init init; | |
240 | struct nvsp_message_init_complete init_complete; | |
241 | } __packed; | |
242 | ||
243 | /* Version 1 Messages */ | |
244 | ||
245 | /* | |
246 | * This message is used by the VSC to send the NDIS version to the VSP. The VSP | |
247 | * can use this information when handling OIDs sent by the VSC. | |
248 | */ | |
249 | struct nvsp_1_message_send_ndis_version { | |
250 | u32 ndis_major_ver; | |
251 | u32 ndis_minor_ver; | |
252 | } __packed; | |
253 | ||
254 | /* | |
255 | * This message is used by the VSC to send a receive buffer to the VSP. The VSP | |
256 | * can then use the receive buffer to send data to the VSC. | |
257 | */ | |
258 | struct nvsp_1_message_send_receive_buffer { | |
259 | u32 gpadl_handle; | |
260 | u16 id; | |
261 | } __packed; | |
262 | ||
263 | struct nvsp_1_receive_buffer_section { | |
264 | u32 offset; | |
265 | u32 sub_alloc_size; | |
266 | u32 num_sub_allocs; | |
267 | u32 end_offset; | |
268 | } __packed; | |
269 | ||
270 | /* | |
271 | * This message is used by the VSP to acknowledge a receive buffer send by the | |
272 | * VSC. This message must be sent by the VSP before the VSP uses the receive | |
273 | * buffer. | |
274 | */ | |
275 | struct nvsp_1_message_send_receive_buffer_complete { | |
276 | u32 status; | |
277 | u32 num_sections; | |
278 | ||
279 | /* | |
280 | * The receive buffer is split into two parts, a large suballocation | |
281 | * section and a small suballocation section. These sections are then | |
282 | * suballocated by a certain size. | |
283 | */ | |
284 | ||
285 | /* | |
286 | * For example, the following break up of the receive buffer has 6 | |
287 | * large suballocations and 10 small suballocations. | |
288 | */ | |
289 | ||
290 | /* | |
291 | * | Large Section | | Small Section | | |
292 | * ------------------------------------------------------------ | |
293 | * | | | | | | | | | | | | | | | | | | | |
294 | * | | | |
295 | * LargeOffset SmallOffset | |
296 | */ | |
297 | ||
298 | struct nvsp_1_receive_buffer_section sections[1]; | |
299 | } __packed; | |
300 | ||
301 | /* | |
302 | * This message is sent by the VSC to revoke the receive buffer. After the VSP | |
303 | * completes this transaction, the vsp should never use the receive buffer | |
304 | * again. | |
305 | */ | |
306 | struct nvsp_1_message_revoke_receive_buffer { | |
307 | u16 id; | |
308 | }; | |
309 | ||
310 | /* | |
311 | * This message is used by the VSC to send a send buffer to the VSP. The VSC | |
312 | * can then use the send buffer to send data to the VSP. | |
313 | */ | |
314 | struct nvsp_1_message_send_send_buffer { | |
315 | u32 gpadl_handle; | |
316 | u16 id; | |
317 | } __packed; | |
318 | ||
319 | /* | |
320 | * This message is used by the VSP to acknowledge a send buffer sent by the | |
321 | * VSC. This message must be sent by the VSP before the VSP uses the sent | |
322 | * buffer. | |
323 | */ | |
324 | struct nvsp_1_message_send_send_buffer_complete { | |
325 | u32 status; | |
326 | ||
327 | /* | |
328 | * The VSC gets to choose the size of the send buffer and the VSP gets | |
329 | * to choose the sections size of the buffer. This was done to enable | |
330 | * dynamic reconfigurations when the cost of GPA-direct buffers | |
331 | * decreases. | |
332 | */ | |
333 | u32 section_size; | |
334 | } __packed; | |
335 | ||
336 | /* | |
337 | * This message is sent by the VSC to revoke the send buffer. After the VSP | |
338 | * completes this transaction, the vsp should never use the send buffer again. | |
339 | */ | |
340 | struct nvsp_1_message_revoke_send_buffer { | |
341 | u16 id; | |
342 | }; | |
343 | ||
344 | /* | |
345 | * This message is used by both the VSP and the VSC to send a RNDIS message to | |
346 | * the opposite channel endpoint. | |
347 | */ | |
348 | struct nvsp_1_message_send_rndis_packet { | |
349 | /* | |
350 | * This field is specified by RNIDS. They assume there's two different | |
351 | * channels of communication. However, the Network VSP only has one. | |
352 | * Therefore, the channel travels with the RNDIS packet. | |
353 | */ | |
354 | u32 channel_type; | |
355 | ||
356 | /* | |
357 | * This field is used to send part or all of the data through a send | |
358 | * buffer. This values specifies an index into the send buffer. If the | |
359 | * index is 0xFFFFFFFF, then the send buffer is not being used and all | |
360 | * of the data was sent through other VMBus mechanisms. | |
361 | */ | |
362 | u32 send_buf_section_index; | |
363 | u32 send_buf_section_size; | |
364 | } __packed; | |
365 | ||
366 | /* | |
367 | * This message is used by both the VSP and the VSC to complete a RNDIS message | |
368 | * to the opposite channel endpoint. At this point, the initiator of this | |
369 | * message cannot use any resources associated with the original RNDIS packet. | |
370 | */ | |
371 | struct nvsp_1_message_send_rndis_packet_complete { | |
372 | u32 status; | |
373 | }; | |
374 | ||
375 | union nvsp_1_message_uber { | |
376 | struct nvsp_1_message_send_ndis_version send_ndis_ver; | |
377 | ||
378 | struct nvsp_1_message_send_receive_buffer send_recv_buf; | |
379 | struct nvsp_1_message_send_receive_buffer_complete | |
380 | send_recv_buf_complete; | |
381 | struct nvsp_1_message_revoke_receive_buffer revoke_recv_buf; | |
382 | ||
383 | struct nvsp_1_message_send_send_buffer send_send_buf; | |
384 | struct nvsp_1_message_send_send_buffer_complete send_send_buf_complete; | |
385 | struct nvsp_1_message_revoke_send_buffer revoke_send_buf; | |
386 | ||
387 | struct nvsp_1_message_send_rndis_packet send_rndis_pkt; | |
388 | struct nvsp_1_message_send_rndis_packet_complete | |
389 | send_rndis_pkt_complete; | |
390 | } __packed; | |
391 | ||
f157e78d HZ |
392 | |
393 | /* | |
394 | * Network VSP protocol version 2 messages: | |
395 | */ | |
396 | struct nvsp_2_vsc_capability { | |
397 | union { | |
398 | u64 data; | |
399 | struct { | |
400 | u64 vmq:1; | |
401 | u64 chimney:1; | |
402 | u64 sriov:1; | |
403 | u64 ieee8021q:1; | |
404 | u64 correlation_id:1; | |
405 | }; | |
406 | }; | |
407 | } __packed; | |
408 | ||
409 | struct nvsp_2_send_ndis_config { | |
410 | u32 mtu; | |
411 | u32 reserved; | |
412 | struct nvsp_2_vsc_capability capability; | |
413 | } __packed; | |
414 | ||
415 | /* Allocate receive buffer */ | |
416 | struct nvsp_2_alloc_rxbuf { | |
417 | /* Allocation ID to match the allocation request and response */ | |
418 | u32 alloc_id; | |
419 | ||
420 | /* Length of the VM shared memory receive buffer that needs to | |
421 | * be allocated | |
422 | */ | |
423 | u32 len; | |
424 | } __packed; | |
425 | ||
426 | /* Allocate receive buffer complete */ | |
427 | struct nvsp_2_alloc_rxbuf_comp { | |
428 | /* The NDIS_STATUS code for buffer allocation */ | |
429 | u32 status; | |
430 | ||
431 | u32 alloc_id; | |
432 | ||
433 | /* GPADL handle for the allocated receive buffer */ | |
434 | u32 gpadl_handle; | |
435 | ||
436 | /* Receive buffer ID */ | |
437 | u64 recv_buf_id; | |
438 | } __packed; | |
439 | ||
440 | struct nvsp_2_free_rxbuf { | |
441 | u64 recv_buf_id; | |
442 | } __packed; | |
443 | ||
444 | union nvsp_2_message_uber { | |
445 | struct nvsp_2_send_ndis_config send_ndis_config; | |
446 | struct nvsp_2_alloc_rxbuf alloc_rxbuf; | |
447 | struct nvsp_2_alloc_rxbuf_comp alloc_rxbuf_comp; | |
448 | struct nvsp_2_free_rxbuf free_rxbuf; | |
449 | } __packed; | |
450 | ||
52584904 S |
451 | union nvsp_all_messages { |
452 | union nvsp_message_init_uber init_msg; | |
453 | union nvsp_1_message_uber v1_msg; | |
f157e78d | 454 | union nvsp_2_message_uber v2_msg; |
52584904 S |
455 | } __packed; |
456 | ||
457 | /* ALL Messages */ | |
458 | struct nvsp_message { | |
459 | struct nvsp_message_header hdr; | |
460 | union nvsp_all_messages msg; | |
461 | } __packed; | |
462 | ||
463 | ||
4d447c9a | 464 | #define NETVSC_MTU 65536 |
52584904 | 465 | |
4d447c9a | 466 | #define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024*2) /* 2MB */ |
52584904 S |
467 | |
468 | #define NETVSC_RECEIVE_BUFFER_ID 0xcafe | |
469 | ||
52584904 S |
470 | /* Preallocated receive packets */ |
471 | #define NETVSC_RECEIVE_PACKETLIST_COUNT 256 | |
472 | ||
473 | #define NETVSC_PACKET_SIZE 2048 | |
474 | ||
475 | /* Per netvsc channel-specific */ | |
476 | struct netvsc_device { | |
477 | struct hv_device *dev; | |
478 | ||
f157e78d HZ |
479 | u32 nvsp_version; |
480 | ||
52584904 | 481 | atomic_t num_outstanding_sends; |
dc5cd894 | 482 | wait_queue_head_t wait_drain; |
4d447c9a | 483 | bool start_remove; |
c38b9c71 | 484 | bool destroy; |
52584904 S |
485 | /* |
486 | * List of free preallocated hv_netvsc_packet to represent receive | |
487 | * packet | |
488 | */ | |
489 | struct list_head recv_pkt_list; | |
490 | spinlock_t recv_pkt_list_lock; | |
491 | ||
52584904 S |
492 | /* Receive buffer allocated by us but manages by NetVSP */ |
493 | void *recv_buf; | |
494 | u32 recv_buf_size; | |
495 | u32 recv_buf_gpadl_handle; | |
496 | u32 recv_section_cnt; | |
497 | struct nvsp_1_receive_buffer_section *recv_section; | |
498 | ||
499 | /* Used for NetVSP initialization protocol */ | |
500 | struct completion channel_init_wait; | |
501 | struct nvsp_message channel_init_pkt; | |
502 | ||
503 | struct nvsp_message revoke_packet; | |
504 | /* unsigned char HwMacAddr[HW_MACADDR_LEN]; */ | |
505 | ||
2ddd5e5f S |
506 | struct net_device *ndev; |
507 | ||
52584904 S |
508 | /* Holds rndis device info */ |
509 | void *extension; | |
510 | }; | |
511 | ||
4a5cea39 S |
512 | /* NdisInitialize message */ |
513 | struct rndis_initialize_request { | |
514 | u32 req_id; | |
515 | u32 major_ver; | |
516 | u32 minor_ver; | |
517 | u32 max_xfer_size; | |
518 | }; | |
519 | ||
520 | /* Response to NdisInitialize */ | |
521 | struct rndis_initialize_complete { | |
522 | u32 req_id; | |
523 | u32 status; | |
524 | u32 major_ver; | |
525 | u32 minor_ver; | |
526 | u32 dev_flags; | |
527 | u32 medium; | |
528 | u32 max_pkt_per_msg; | |
529 | u32 max_xfer_size; | |
530 | u32 pkt_alignment_factor; | |
531 | u32 af_list_offset; | |
532 | u32 af_list_size; | |
533 | }; | |
534 | ||
535 | /* Call manager devices only: Information about an address family */ | |
536 | /* supported by the device is appended to the response to NdisInitialize. */ | |
537 | struct rndis_co_address_family { | |
538 | u32 address_family; | |
539 | u32 major_ver; | |
540 | u32 minor_ver; | |
541 | }; | |
542 | ||
543 | /* NdisHalt message */ | |
544 | struct rndis_halt_request { | |
545 | u32 req_id; | |
546 | }; | |
547 | ||
548 | /* NdisQueryRequest message */ | |
549 | struct rndis_query_request { | |
550 | u32 req_id; | |
551 | u32 oid; | |
552 | u32 info_buflen; | |
553 | u32 info_buf_offset; | |
554 | u32 dev_vc_handle; | |
555 | }; | |
556 | ||
557 | /* Response to NdisQueryRequest */ | |
558 | struct rndis_query_complete { | |
559 | u32 req_id; | |
560 | u32 status; | |
561 | u32 info_buflen; | |
562 | u32 info_buf_offset; | |
563 | }; | |
564 | ||
565 | /* NdisSetRequest message */ | |
566 | struct rndis_set_request { | |
567 | u32 req_id; | |
568 | u32 oid; | |
569 | u32 info_buflen; | |
570 | u32 info_buf_offset; | |
571 | u32 dev_vc_handle; | |
572 | }; | |
573 | ||
574 | /* Response to NdisSetRequest */ | |
575 | struct rndis_set_complete { | |
576 | u32 req_id; | |
577 | u32 status; | |
578 | }; | |
579 | ||
580 | /* NdisReset message */ | |
581 | struct rndis_reset_request { | |
582 | u32 reserved; | |
583 | }; | |
584 | ||
585 | /* Response to NdisReset */ | |
586 | struct rndis_reset_complete { | |
587 | u32 status; | |
588 | u32 addressing_reset; | |
589 | }; | |
590 | ||
591 | /* NdisMIndicateStatus message */ | |
592 | struct rndis_indicate_status { | |
593 | u32 status; | |
594 | u32 status_buflen; | |
595 | u32 status_buf_offset; | |
596 | }; | |
597 | ||
598 | /* Diagnostic information passed as the status buffer in */ | |
599 | /* struct rndis_indicate_status messages signifying error conditions. */ | |
600 | struct rndis_diagnostic_info { | |
601 | u32 diag_status; | |
602 | u32 error_offset; | |
603 | }; | |
604 | ||
605 | /* NdisKeepAlive message */ | |
606 | struct rndis_keepalive_request { | |
607 | u32 req_id; | |
608 | }; | |
609 | ||
610 | /* Response to NdisKeepAlive */ | |
611 | struct rndis_keepalive_complete { | |
612 | u32 req_id; | |
613 | u32 status; | |
614 | }; | |
615 | ||
616 | /* | |
617 | * Data message. All Offset fields contain byte offsets from the beginning of | |
618 | * struct rndis_packet. All Length fields are in bytes. VcHandle is set | |
619 | * to 0 for connectionless data, otherwise it contains the VC handle. | |
620 | */ | |
621 | struct rndis_packet { | |
622 | u32 data_offset; | |
623 | u32 data_len; | |
624 | u32 oob_data_offset; | |
625 | u32 oob_data_len; | |
626 | u32 num_oob_data_elements; | |
627 | u32 per_pkt_info_offset; | |
628 | u32 per_pkt_info_len; | |
629 | u32 vc_handle; | |
630 | u32 reserved; | |
631 | }; | |
632 | ||
633 | /* Optional Out of Band data associated with a Data message. */ | |
634 | struct rndis_oobd { | |
635 | u32 size; | |
636 | u32 type; | |
637 | u32 class_info_offset; | |
638 | }; | |
639 | ||
640 | /* Packet extension field contents associated with a Data message. */ | |
641 | struct rndis_per_packet_info { | |
642 | u32 size; | |
643 | u32 type; | |
1f5f3a75 HZ |
644 | u32 ppi_offset; |
645 | }; | |
646 | ||
647 | enum ndis_per_pkt_info_type { | |
648 | TCPIP_CHKSUM_PKTINFO, | |
649 | IPSEC_PKTINFO, | |
650 | TCP_LARGESEND_PKTINFO, | |
651 | CLASSIFICATION_HANDLE_PKTINFO, | |
652 | NDIS_RESERVED, | |
653 | SG_LIST_PKTINFO, | |
654 | IEEE_8021Q_INFO, | |
655 | ORIGINAL_PKTINFO, | |
656 | PACKET_CANCEL_ID, | |
657 | ORIGINAL_NET_BUFLIST, | |
658 | CACHED_NET_BUFLIST, | |
659 | SHORT_PKT_PADINFO, | |
660 | MAX_PER_PKT_INFO | |
661 | }; | |
662 | ||
663 | struct ndis_pkt_8021q_info { | |
664 | union { | |
665 | struct { | |
666 | u32 pri:3; /* User Priority */ | |
667 | u32 cfi:1; /* Canonical Format ID */ | |
668 | u32 vlanid:12; /* VLAN ID */ | |
669 | u32 reserved:16; | |
670 | }; | |
671 | u32 value; | |
672 | }; | |
4a5cea39 S |
673 | }; |
674 | ||
1f5f3a75 HZ |
675 | #define NDIS_VLAN_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \ |
676 | sizeof(struct ndis_pkt_8021q_info)) | |
677 | ||
4a5cea39 S |
678 | /* Format of Information buffer passed in a SetRequest for the OID */ |
679 | /* OID_GEN_RNDIS_CONFIG_PARAMETER. */ | |
680 | struct rndis_config_parameter_info { | |
681 | u32 parameter_name_offset; | |
682 | u32 parameter_name_length; | |
683 | u32 parameter_type; | |
684 | u32 parameter_value_offset; | |
685 | u32 parameter_value_length; | |
686 | }; | |
687 | ||
688 | /* Values for ParameterType in struct rndis_config_parameter_info */ | |
689 | #define RNDIS_CONFIG_PARAM_TYPE_INTEGER 0 | |
690 | #define RNDIS_CONFIG_PARAM_TYPE_STRING 2 | |
691 | ||
692 | /* CONDIS Miniport messages for connection oriented devices */ | |
693 | /* that do not implement a call manager. */ | |
694 | ||
695 | /* CoNdisMiniportCreateVc message */ | |
696 | struct rcondis_mp_create_vc { | |
697 | u32 req_id; | |
698 | u32 ndis_vc_handle; | |
699 | }; | |
700 | ||
701 | /* Response to CoNdisMiniportCreateVc */ | |
702 | struct rcondis_mp_create_vc_complete { | |
703 | u32 req_id; | |
704 | u32 dev_vc_handle; | |
705 | u32 status; | |
706 | }; | |
707 | ||
708 | /* CoNdisMiniportDeleteVc message */ | |
709 | struct rcondis_mp_delete_vc { | |
710 | u32 req_id; | |
711 | u32 dev_vc_handle; | |
712 | }; | |
713 | ||
714 | /* Response to CoNdisMiniportDeleteVc */ | |
715 | struct rcondis_mp_delete_vc_complete { | |
716 | u32 req_id; | |
717 | u32 status; | |
718 | }; | |
719 | ||
720 | /* CoNdisMiniportQueryRequest message */ | |
721 | struct rcondis_mp_query_request { | |
722 | u32 req_id; | |
723 | u32 request_type; | |
724 | u32 oid; | |
725 | u32 dev_vc_handle; | |
726 | u32 info_buflen; | |
727 | u32 info_buf_offset; | |
728 | }; | |
729 | ||
730 | /* CoNdisMiniportSetRequest message */ | |
731 | struct rcondis_mp_set_request { | |
732 | u32 req_id; | |
733 | u32 request_type; | |
734 | u32 oid; | |
735 | u32 dev_vc_handle; | |
736 | u32 info_buflen; | |
737 | u32 info_buf_offset; | |
738 | }; | |
739 | ||
740 | /* CoNdisIndicateStatus message */ | |
741 | struct rcondis_indicate_status { | |
742 | u32 ndis_vc_handle; | |
743 | u32 status; | |
744 | u32 status_buflen; | |
745 | u32 status_buf_offset; | |
746 | }; | |
747 | ||
748 | /* CONDIS Call/VC parameters */ | |
749 | struct rcondis_specific_parameters { | |
750 | u32 parameter_type; | |
751 | u32 parameter_length; | |
752 | u32 parameter_lffset; | |
753 | }; | |
754 | ||
755 | struct rcondis_media_parameters { | |
756 | u32 flags; | |
757 | u32 reserved1; | |
758 | u32 reserved2; | |
759 | struct rcondis_specific_parameters media_specific; | |
760 | }; | |
761 | ||
762 | struct rndis_flowspec { | |
763 | u32 token_rate; | |
764 | u32 token_bucket_size; | |
765 | u32 peak_bandwidth; | |
766 | u32 latency; | |
767 | u32 delay_variation; | |
768 | u32 service_type; | |
769 | u32 max_sdu_size; | |
770 | u32 minimum_policed_size; | |
771 | }; | |
772 | ||
773 | struct rcondis_call_manager_parameters { | |
774 | struct rndis_flowspec transmit; | |
775 | struct rndis_flowspec receive; | |
776 | struct rcondis_specific_parameters call_mgr_specific; | |
777 | }; | |
778 | ||
779 | /* CoNdisMiniportActivateVc message */ | |
780 | struct rcondis_mp_activate_vc_request { | |
781 | u32 req_id; | |
782 | u32 flags; | |
783 | u32 dev_vc_handle; | |
784 | u32 media_params_offset; | |
785 | u32 media_params_length; | |
786 | u32 call_mgr_params_offset; | |
787 | u32 call_mgr_params_length; | |
788 | }; | |
789 | ||
790 | /* Response to CoNdisMiniportActivateVc */ | |
791 | struct rcondis_mp_activate_vc_complete { | |
792 | u32 req_id; | |
793 | u32 status; | |
794 | }; | |
795 | ||
796 | /* CoNdisMiniportDeactivateVc message */ | |
797 | struct rcondis_mp_deactivate_vc_request { | |
798 | u32 req_id; | |
799 | u32 flags; | |
800 | u32 dev_vc_handle; | |
801 | }; | |
802 | ||
803 | /* Response to CoNdisMiniportDeactivateVc */ | |
804 | struct rcondis_mp_deactivate_vc_complete { | |
805 | u32 req_id; | |
806 | u32 status; | |
807 | }; | |
808 | ||
809 | ||
810 | /* union with all of the RNDIS messages */ | |
811 | union rndis_message_container { | |
812 | struct rndis_packet pkt; | |
813 | struct rndis_initialize_request init_req; | |
814 | struct rndis_halt_request halt_req; | |
815 | struct rndis_query_request query_req; | |
816 | struct rndis_set_request set_req; | |
817 | struct rndis_reset_request reset_req; | |
818 | struct rndis_keepalive_request keep_alive_req; | |
819 | struct rndis_indicate_status indicate_status; | |
820 | struct rndis_initialize_complete init_complete; | |
821 | struct rndis_query_complete query_complete; | |
822 | struct rndis_set_complete set_complete; | |
823 | struct rndis_reset_complete reset_complete; | |
824 | struct rndis_keepalive_complete keep_alive_complete; | |
825 | struct rcondis_mp_create_vc co_miniport_create_vc; | |
826 | struct rcondis_mp_delete_vc co_miniport_delete_vc; | |
827 | struct rcondis_indicate_status co_indicate_status; | |
828 | struct rcondis_mp_activate_vc_request co_miniport_activate_vc; | |
829 | struct rcondis_mp_deactivate_vc_request co_miniport_deactivate_vc; | |
830 | struct rcondis_mp_create_vc_complete co_miniport_create_vc_complete; | |
831 | struct rcondis_mp_delete_vc_complete co_miniport_delete_vc_complete; | |
832 | struct rcondis_mp_activate_vc_complete co_miniport_activate_vc_complete; | |
833 | struct rcondis_mp_deactivate_vc_complete | |
834 | co_miniport_deactivate_vc_complete; | |
835 | }; | |
836 | ||
837 | /* Remote NDIS message format */ | |
838 | struct rndis_message { | |
839 | u32 ndis_msg_type; | |
840 | ||
841 | /* Total length of this message, from the beginning */ | |
842 | /* of the sruct rndis_message, in bytes. */ | |
843 | u32 msg_len; | |
844 | ||
845 | /* Actual message */ | |
846 | union rndis_message_container msg; | |
847 | }; | |
848 | ||
9dbfd150 S |
849 | |
850 | struct rndis_filter_packet { | |
851 | void *completion_ctx; | |
852 | void (*completion)(void *context); | |
853 | struct rndis_message msg; | |
854 | }; | |
855 | ||
4a5cea39 S |
856 | /* Handy macros */ |
857 | ||
858 | /* get the size of an RNDIS message. Pass in the message type, */ | |
859 | /* struct rndis_set_request, struct rndis_packet for example */ | |
860 | #define RNDIS_MESSAGE_SIZE(msg) \ | |
861 | (sizeof(msg) + (sizeof(struct rndis_message) - \ | |
862 | sizeof(union rndis_message_container))) | |
863 | ||
864 | /* get pointer to info buffer with message pointer */ | |
865 | #define MESSAGE_TO_INFO_BUFFER(msg) \ | |
866 | (((unsigned char *)(msg)) + msg->info_buf_offset) | |
867 | ||
868 | /* get pointer to status buffer with message pointer */ | |
869 | #define MESSAGE_TO_STATUS_BUFFER(msg) \ | |
870 | (((unsigned char *)(msg)) + msg->status_buf_offset) | |
871 | ||
872 | /* get pointer to OOBD buffer with message pointer */ | |
873 | #define MESSAGE_TO_OOBD_BUFFER(msg) \ | |
874 | (((unsigned char *)(msg)) + msg->oob_data_offset) | |
875 | ||
876 | /* get pointer to data buffer with message pointer */ | |
877 | #define MESSAGE_TO_DATA_BUFFER(msg) \ | |
878 | (((unsigned char *)(msg)) + msg->per_pkt_info_offset) | |
879 | ||
880 | /* get pointer to contained message from NDIS_MESSAGE pointer */ | |
881 | #define RNDIS_MESSAGE_PTR_TO_MESSAGE_PTR(rndis_msg) \ | |
882 | ((void *) &rndis_msg->msg) | |
883 | ||
884 | /* get pointer to contained message from NDIS_MESSAGE pointer */ | |
885 | #define RNDIS_MESSAGE_RAW_PTR_TO_MESSAGE_PTR(rndis_msg) \ | |
886 | ((void *) rndis_msg) | |
887 | ||
299d0925 S |
888 | |
889 | #define __struct_bcount(x) | |
890 | ||
891 | ||
892 | ||
893 | #define RNDIS_HEADER_SIZE (sizeof(struct rndis_message) - \ | |
894 | sizeof(union rndis_message_container)) | |
895 | ||
896 | #define NDIS_PACKET_TYPE_DIRECTED 0x00000001 | |
897 | #define NDIS_PACKET_TYPE_MULTICAST 0x00000002 | |
898 | #define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004 | |
899 | #define NDIS_PACKET_TYPE_BROADCAST 0x00000008 | |
900 | #define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010 | |
901 | #define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020 | |
902 | #define NDIS_PACKET_TYPE_SMT 0x00000040 | |
903 | #define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080 | |
904 | #define NDIS_PACKET_TYPE_GROUP 0x00000100 | |
905 | #define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00000200 | |
906 | #define NDIS_PACKET_TYPE_FUNCTIONAL 0x00000400 | |
907 | #define NDIS_PACKET_TYPE_MAC_FRAME 0x00000800 | |
908 | ||
909 | ||
299d0925 | 910 | |
5ca7252a | 911 | #endif /* _HYPERV_NET_H */ |