]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - sys/dev/hyperv/netvsc/hv_rndis.h
MFC 304783-304785
[FreeBSD/stable/10.git] / sys / dev / hyperv / netvsc / hv_rndis.h
1 /*-
2  * Copyright (c) 2009-2012,2016 Microsoft Corp.
3  * Copyright (c) 2010-2012 Citrix Inc.
4  * Copyright (c) 2012 NetApp Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice unmodified, this list of conditions, and the following
12  *    disclaimer.
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.
16  *
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.
27  *
28  * $FreeBSD$
29  */
30
31 #ifndef __HV_RNDIS_H__
32 #define __HV_RNDIS_H__
33
34 #include <net/rndis.h>
35
36 /*
37  * NDIS protocol version numbers
38  */
39 #define NDIS_VERSION_5_0                        0x00050000
40 #define NDIS_VERSION_5_1                        0x00050001
41 #define NDIS_VERSION_6_0                        0x00060000
42 #define NDIS_VERSION_6_1                        0x00060001
43 #define NDIS_VERSION_6_30                       0x0006001e
44
45 #define NDIS_VERSION_MAJOR_6                    6
46 #define NDIS_VERSION_MINOR_1                    1
47 #define NDIS_VERSION_MINOR_30                   30
48
49 #define NDIS_VERSION                            (NDIS_VERSION_5_1)
50
51 /*
52  * Object Identifiers used by NdisRequest Query/Set Information
53  */
54
55 /*
56  * General Objects
57  */
58
59 #define RNDIS_OID_GEN_SUPPORTED_LIST                    0x00010101
60 #define RNDIS_OID_GEN_HARDWARE_STATUS                   0x00010102
61 #define RNDIS_OID_GEN_MEDIA_SUPPORTED                   0x00010103
62 #define RNDIS_OID_GEN_MEDIA_IN_USE                      0x00010104
63 #define RNDIS_OID_GEN_MAXIMUM_LOOKAHEAD                 0x00010105
64 #define RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE                0x00010106
65 #define RNDIS_OID_GEN_LINK_SPEED                        0x00010107
66 #define RNDIS_OID_GEN_TRANSMIT_BUFFER_SPACE             0x00010108
67 #define RNDIS_OID_GEN_RECEIVE_BUFFER_SPACE              0x00010109
68 #define RNDIS_OID_GEN_TRANSMIT_BLOCK_SIZE               0x0001010A
69 #define RNDIS_OID_GEN_RECEIVE_BLOCK_SIZE                0x0001010B
70 #define RNDIS_OID_GEN_VENDOR_ID                         0x0001010C
71 #define RNDIS_OID_GEN_VENDOR_DESCRIPTION                0x0001010D
72 #define RNDIS_OID_GEN_CURRENT_PACKET_FILTER             0x0001010E
73 #define RNDIS_OID_GEN_CURRENT_LOOKAHEAD                 0x0001010F
74 #define RNDIS_OID_GEN_DRIVER_VERSION                    0x00010110
75 #define RNDIS_OID_GEN_MAXIMUM_TOTAL_SIZE                0x00010111
76 #define RNDIS_OID_GEN_PROTOCOL_OPTIONS                  0x00010112
77 #define RNDIS_OID_GEN_MAC_OPTIONS                       0x00010113
78 #define RNDIS_OID_GEN_MEDIA_CONNECT_STATUS              0x00010114
79 #define RNDIS_OID_GEN_MAXIMUM_SEND_PACKETS              0x00010115
80 #define RNDIS_OID_GEN_VENDOR_DRIVER_VERSION             0x00010116
81 #define RNDIS_OID_GEN_NETWORK_LAYER_ADDRESSES           0x00010118
82 #define RNDIS_OID_GEN_TRANSPORT_HEADER_OFFSET           0x00010119
83 #define RNDIS_OID_GEN_MACHINE_NAME                      0x0001021A
84 #define RNDIS_OID_GEN_RNDIS_CONFIG_PARAMETER            0x0001021B
85
86 /*
87  * For receive side scale
88  */
89 /* Query only */
90 #define RNDIS_OID_GEN_RSS_CAPABILITIES                  0x00010203
91 /* Query and set */
92 #define RNDIS_OID_GEN_RSS_PARAMETERS                    0x00010204
93
94 #define RNDIS_OID_GEN_XMIT_OK                           0x00020101
95 #define RNDIS_OID_GEN_RCV_OK                            0x00020102
96 #define RNDIS_OID_GEN_XMIT_ERROR                        0x00020103
97 #define RNDIS_OID_GEN_RCV_ERROR                         0x00020104
98 #define RNDIS_OID_GEN_RCV_NO_BUFFER                     0x00020105
99
100 #define RNDIS_OID_GEN_DIRECTED_BYTES_XMIT               0x00020201
101 #define RNDIS_OID_GEN_DIRECTED_FRAMES_XMIT              0x00020202
102 #define RNDIS_OID_GEN_MULTICAST_BYTES_XMIT              0x00020203
103 #define RNDIS_OID_GEN_MULTICAST_FRAMES_XMIT             0x00020204
104 #define RNDIS_OID_GEN_BROADCAST_BYTES_XMIT              0x00020205
105 #define RNDIS_OID_GEN_BROADCAST_FRAMES_XMIT             0x00020206
106 #define RNDIS_OID_GEN_DIRECTED_BYTES_RCV                0x00020207
107 #define RNDIS_OID_GEN_DIRECTED_FRAMES_RCV               0x00020208
108 #define RNDIS_OID_GEN_MULTICAST_BYTES_RCV               0x00020209
109 #define RNDIS_OID_GEN_MULTICAST_FRAMES_RCV              0x0002020A
110 #define RNDIS_OID_GEN_BROADCAST_BYTES_RCV               0x0002020B
111 #define RNDIS_OID_GEN_BROADCAST_FRAMES_RCV              0x0002020C
112
113 #define RNDIS_OID_GEN_RCV_CRC_ERROR                     0x0002020D
114 #define RNDIS_OID_GEN_TRANSMIT_QUEUE_LENGTH             0x0002020E
115
116 #define RNDIS_OID_GEN_GET_TIME_CAPS                     0x0002020F
117 #define RNDIS_OID_GEN_GET_NETCARD_TIME                  0x00020210
118
119 /*
120  * These are connection-oriented general OIDs.
121  * These replace the above OIDs for connection-oriented media.
122  */
123 #define RNDIS_OID_GEN_CO_SUPPORTED_LIST                 0x00010101
124 #define RNDIS_OID_GEN_CO_HARDWARE_STATUS                0x00010102
125 #define RNDIS_OID_GEN_CO_MEDIA_SUPPORTED                0x00010103
126 #define RNDIS_OID_GEN_CO_MEDIA_IN_USE                   0x00010104
127 #define RNDIS_OID_GEN_CO_LINK_SPEED                     0x00010105
128 #define RNDIS_OID_GEN_CO_VENDOR_ID                      0x00010106
129 #define RNDIS_OID_GEN_CO_VENDOR_DESCRIPTION             0x00010107
130 #define RNDIS_OID_GEN_CO_DRIVER_VERSION                 0x00010108
131 #define RNDIS_OID_GEN_CO_PROTOCOL_OPTIONS               0x00010109
132 #define RNDIS_OID_GEN_CO_MAC_OPTIONS                    0x0001010A
133 #define RNDIS_OID_GEN_CO_MEDIA_CONNECT_STATUS           0x0001010B
134 #define RNDIS_OID_GEN_CO_VENDOR_DRIVER_VERSION          0x0001010C
135 #define RNDIS_OID_GEN_CO_MINIMUM_LINK_SPEED             0x0001010D
136
137 #define RNDIS_OID_GEN_CO_GET_TIME_CAPS                  0x00010201
138 #define RNDIS_OID_GEN_CO_GET_NETCARD_TIME               0x00010202
139
140 /*
141  * These are connection-oriented statistics OIDs.
142  */
143 #define RNDIS_OID_GEN_CO_XMIT_PDUS_OK                   0x00020101
144 #define RNDIS_OID_GEN_CO_RCV_PDUS_OK                    0x00020102
145 #define RNDIS_OID_GEN_CO_XMIT_PDUS_ERROR                0x00020103
146 #define RNDIS_OID_GEN_CO_RCV_PDUS_ERROR                 0x00020104
147 #define RNDIS_OID_GEN_CO_RCV_PDUS_NO_BUFFER             0x00020105
148
149
150 #define RNDIS_OID_GEN_CO_RCV_CRC_ERROR                  0x00020201
151 #define RNDIS_OID_GEN_CO_TRANSMIT_QUEUE_LENGTH          0x00020202
152 #define RNDIS_OID_GEN_CO_BYTES_XMIT                     0x00020203
153 #define RNDIS_OID_GEN_CO_BYTES_RCV                      0x00020204
154 #define RNDIS_OID_GEN_CO_BYTES_XMIT_OUTSTANDING         0x00020205
155 #define RNDIS_OID_GEN_CO_NETCARD_LOAD                   0x00020206
156
157 /*
158  * These are objects for Connection-oriented media call-managers.
159  */
160 #define RNDIS_OID_CO_ADD_PVC                            0xFF000001
161 #define RNDIS_OID_CO_DELETE_PVC                         0xFF000002
162 #define RNDIS_OID_CO_GET_CALL_INFORMATION               0xFF000003
163 #define RNDIS_OID_CO_ADD_ADDRESS                        0xFF000004
164 #define RNDIS_OID_CO_DELETE_ADDRESS                     0xFF000005
165 #define RNDIS_OID_CO_GET_ADDRESSES                      0xFF000006
166 #define RNDIS_OID_CO_ADDRESS_CHANGE                     0xFF000007
167 #define RNDIS_OID_CO_SIGNALING_ENABLED                  0xFF000008
168 #define RNDIS_OID_CO_SIGNALING_DISABLED                 0xFF000009
169
170
171 /*
172  * 802.3 Objects (Ethernet)
173  */
174
175 #define RNDIS_OID_802_3_PERMANENT_ADDRESS               0x01010101
176 #define RNDIS_OID_802_3_CURRENT_ADDRESS                 0x01010102
177 #define RNDIS_OID_802_3_MULTICAST_LIST                  0x01010103
178 #define RNDIS_OID_802_3_MAXIMUM_LIST_SIZE               0x01010104
179 #define RNDIS_OID_802_3_MAC_OPTIONS                     0x01010105
180
181 /*
182  *
183  */
184 #define NDIS_802_3_MAC_OPTION_PRIORITY                  0x00000001
185
186 #define RNDIS_OID_802_3_RCV_ERROR_ALIGNMENT             0x01020101
187 #define RNDIS_OID_802_3_XMIT_ONE_COLLISION              0x01020102
188 #define RNDIS_OID_802_3_XMIT_MORE_COLLISIONS            0x01020103
189
190 #define RNDIS_OID_802_3_XMIT_DEFERRED                   0x01020201
191 #define RNDIS_OID_802_3_XMIT_MAX_COLLISIONS             0x01020202
192 #define RNDIS_OID_802_3_RCV_OVERRUN                     0x01020203
193 #define RNDIS_OID_802_3_XMIT_UNDERRUN                   0x01020204
194 #define RNDIS_OID_802_3_XMIT_HEARTBEAT_FAILURE          0x01020205
195 #define RNDIS_OID_802_3_XMIT_TIMES_CRS_LOST             0x01020206
196 #define RNDIS_OID_802_3_XMIT_LATE_COLLISIONS            0x01020207
197
198
199 /*
200  * RNDIS MP custom OID for test
201  */
202 #define OID_RNDISMP_GET_RECEIVE_BUFFERS                 0xFFA0C90D // Query only
203
204 /*
205  * Remote NDIS offload parameters
206  */
207 #define RNDIS_OBJECT_TYPE_DEFAULT                       0x80
208  
209 #define RNDIS_OFFLOAD_PARAMETERS_REVISION_3             3
210 #define RNDIS_OFFLOAD_PARAMETERS_NO_CHANGE              0
211 #define RNDIS_OFFLOAD_PARAMETERS_LSOV2_DISABLED         1
212 #define RNDIS_OFFLOAD_PARAMETERS_LSOV2_ENABLED          2
213 #define RNDIS_OFFLOAD_PARAMETERS_LSOV1_ENABLED          2
214 #define RNDIS_OFFLOAD_PARAMETERS_RSC_DISABLED           1
215 #define RNDIS_OFFLOAD_PARAMETERS_RSC_ENABLED            2
216 #define RNDIS_OFFLOAD_PARAMETERS_TX_RX_DISABLED         1
217 #define RNDIS_OFFLOAD_PARAMETERS_TX_ENABLED_RX_DISABLED 2
218 #define RNDIS_OFFLOAD_PARAMETERS_RX_ENABLED_TX_DISABLED 3
219 #define RNDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED          4
220
221 #define RNDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE            1
222 #define RNDIS_TCP_LARGE_SEND_OFFLOAD_IPV4               0
223 #define RNDIS_TCP_LARGE_SEND_OFFLOAD_IPV6               1
224
225
226 #define RNDIS_OID_TCP_OFFLOAD_CURRENT_CONFIG            0xFC01020B /* query only */
227 #define RNDIS_OID_TCP_OFFLOAD_PARAMETERS                0xFC01020C /* set only */
228 #define RNDIS_OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES     0xFC01020D/* query only */
229 #define RNDIS_OID_TCP_CONNECTION_OFFLOAD_CURRENT_CONFIG 0xFC01020E /* query only */
230 #define RNDIS_OID_TCP_CONNECTION_OFFLOAD_HARDWARE_CAPABILITIES  0xFC01020F /* query */
231 #define RNDIS_OID_OFFLOAD_ENCAPSULATION                 0x0101010A /* set/query */
232
233 /*
234  * NdisInitialize message
235  */
236 typedef struct rndis_initialize_request_ {
237     /* RNDIS request ID */
238     uint32_t                                request_id;
239     uint32_t                                major_version;
240     uint32_t                                minor_version;
241     uint32_t                                max_xfer_size;
242 } rndis_initialize_request;
243
244 /*
245  * Response to NdisInitialize
246  */
247 typedef struct rndis_initialize_complete_ {
248     /* RNDIS request ID */
249     uint32_t                                request_id;
250     /* RNDIS status */
251     uint32_t                                status;
252     uint32_t                                major_version;
253     uint32_t                                minor_version;
254     uint32_t                                device_flags;
255     /* RNDIS medium */
256     uint32_t                                medium;
257     uint32_t                                max_pkts_per_msg;
258     uint32_t                                max_xfer_size;
259     uint32_t                                pkt_align_factor;
260     uint32_t                                af_list_offset;
261     uint32_t                                af_list_size;
262 } rndis_initialize_complete;
263
264 /*
265  * Call manager devices only: Information about an address family
266  * supported by the device is appended to the response to NdisInitialize.
267  */
268 typedef struct rndis_co_address_family_ {
269     /* RNDIS AF */
270     uint32_t                                address_family;
271     uint32_t                                major_version;
272     uint32_t                                minor_version;
273 } rndis_co_address_family;
274
275 /*
276  * NdisHalt message
277  */
278 typedef struct rndis_halt_request_ {
279     /* RNDIS request ID */
280     uint32_t                                request_id;
281 } rndis_halt_request;
282
283 /*
284  * NdisQueryRequest message
285  */
286 typedef struct rndis_query_request_ {
287     /* RNDIS request ID */
288     uint32_t                                request_id;
289     /* RNDIS OID */
290     uint32_t                                oid;
291     uint32_t                                info_buffer_length;
292     uint32_t                                info_buffer_offset;
293     /* RNDIS handle */
294     uint32_t                                device_vc_handle;
295 } rndis_query_request;
296
297 /*
298  * Response to NdisQueryRequest
299  */
300 typedef struct rndis_query_complete_ {
301     /* RNDIS request ID */
302     uint32_t                                request_id;
303     /* RNDIS status */
304     uint32_t                                status;
305     uint32_t                                info_buffer_length;
306     uint32_t                                info_buffer_offset;
307 } rndis_query_complete;
308
309 /*
310  * NdisSetRequest message
311  */
312 typedef struct rndis_set_request_ {
313     /* RNDIS request ID */
314     uint32_t                                request_id;
315     /* RNDIS OID */
316     uint32_t                                oid;
317     uint32_t                                info_buffer_length;
318     uint32_t                                info_buffer_offset;
319     /* RNDIS handle */
320     uint32_t                                device_vc_handle;
321 } rndis_set_request;
322
323 /*
324  * Response to NdisSetRequest
325  */
326 typedef struct rndis_set_complete_ {
327     /* RNDIS request ID */
328     uint32_t                                request_id;
329     /* RNDIS status */
330     uint32_t                                status;
331 } rndis_set_complete;
332
333 /*
334  * NdisReset message
335  */
336 typedef struct rndis_reset_request_ {
337     uint32_t                                reserved;
338 } rndis_reset_request;
339
340 /*
341  * Response to NdisReset
342  */
343 typedef struct rndis_reset_complete_ {
344     /* RNDIS status */
345     uint32_t                                status;
346     uint32_t                                addressing_reset;
347 } rndis_reset_complete;
348
349 /*
350  * NdisMIndicateStatus message
351  */
352 typedef struct rndis_indicate_status_ {
353     /* RNDIS status */
354     uint32_t                                status;
355     uint32_t                                status_buf_length;
356     uint32_t                                status_buf_offset;
357 } rndis_indicate_status;
358
359 /*
360  * Diagnostic information passed as the status buffer in
361  * rndis_indicate_status messages signifying error conditions.
362  */
363 typedef struct rndis_diagnostic_info_ {
364     /* RNDIS status */
365     uint32_t                                diag_status;
366     uint32_t                                error_offset;
367 } rndis_diagnostic_info;
368
369 /*
370  * NdisKeepAlive message
371  */
372 typedef struct rndis_keepalive_request_ {
373     /* RNDIS request ID */
374     uint32_t                                request_id;
375 } rndis_keepalive_request;
376
377 /*
378  * Response to NdisKeepAlive
379  */  
380 typedef struct rndis_keepalive_complete_ {
381     /* RNDIS request ID */
382     uint32_t                                request_id;
383     /* RNDIS status */
384     uint32_t                                status;
385 } rndis_keepalive_complete;
386
387 /*
388  * Data message. All offset fields contain byte offsets from the beginning
389  * of the rndis_packet structure. All length fields are in bytes.
390  * VcHandle is set to 0 for connectionless data, otherwise it
391  * contains the VC handle.
392  */
393 typedef struct rndis_packet_ {
394     uint32_t                                data_offset;
395     uint32_t                                data_length;
396     uint32_t                                oob_data_offset;
397     uint32_t                                oob_data_length;
398     uint32_t                                num_oob_data_elements;
399     uint32_t                                per_pkt_info_offset;
400     uint32_t                                per_pkt_info_length;
401     /* RNDIS handle */
402     uint32_t                                vc_handle;
403     uint32_t                                reserved;
404 } rndis_packet;
405
406 typedef struct rndis_packet_ex_ {
407     uint32_t                                data_offset;
408     uint32_t                                data_length;
409     uint32_t                                oob_data_offset;
410     uint32_t                                oob_data_length;
411     uint32_t                                num_oob_data_elements;
412     uint32_t                                per_pkt_info_offset;
413     uint32_t                                per_pkt_info_length;
414     /* RNDIS handle */
415     uint32_t                                vc_handle;
416     uint32_t                                reserved;
417     uint64_t                                data_buf_id;
418     uint32_t                                data_buf_offset;
419     uint64_t                                next_header_buf_id;
420     uint32_t                                next_header_byte_offset;
421     uint32_t                                next_header_byte_count;
422 } rndis_packet_ex;
423
424 /*
425  * Optional Out of Band data associated with a Data message.
426  */
427 typedef struct rndis_oobd_ {
428     uint32_t                                size;
429     /* RNDIS class ID */
430     uint32_t                                type;
431     uint32_t                                class_info_offset;
432 } rndis_oobd;
433
434 /*
435  * Packet extension field contents associated with a Data message.
436  */
437 typedef struct rndis_per_packet_info_ {
438     uint32_t                                size;
439     uint32_t                                type;
440     uint32_t                                per_packet_info_offset;
441 } rndis_per_packet_info;
442
443 typedef enum ndis_per_pkt_infotype_ {
444         tcpip_chksum_info,
445         ipsec_info,
446         tcp_large_send_info,
447         classification_handle_info,
448         ndis_reserved,
449         sgl_info,
450         ieee_8021q_info,
451         original_pkt_info,
452         pkt_cancel_id,
453         original_netbuf_list,
454         cached_netbuf_list,
455         short_pkt_padding_info,
456         max_perpkt_info
457 } ndis_per_pkt_infotype;
458
459 #define nbl_hash_value  pkt_cancel_id
460 #define nbl_hash_info   original_netbuf_list
461
462 typedef struct ndis_8021q_info_ {
463         union {
464                 struct {
465                         uint32_t   user_pri : 3;  /* User Priority */
466                         uint32_t   cfi      : 1;  /* Canonical Format ID */
467                         uint32_t   vlan_id  : 12;
468                         uint32_t   reserved : 16;
469                 } s1;
470                 uint32_t    value;
471         } u1;
472 } ndis_8021q_info;
473
474 struct rndis_object_header {
475         uint8_t type;
476         uint8_t revision;
477         uint16_t size;
478 };
479
480 typedef struct rndis_offload_params_ {
481         struct rndis_object_header header;
482         uint8_t ipv4_csum;
483         uint8_t tcp_ipv4_csum;
484         uint8_t udp_ipv4_csum;
485         uint8_t tcp_ipv6_csum;
486         uint8_t udp_ipv6_csum;
487         uint8_t lso_v1;
488         uint8_t ip_sec_v1;
489         uint8_t lso_v2_ipv4;
490         uint8_t lso_v2_ipv6;
491         uint8_t tcp_connection_ipv4;
492         uint8_t tcp_connection_ipv6;
493         uint32_t flags;
494         uint8_t ip_sec_v2;
495         uint8_t ip_sec_v2_ipv4;
496         struct {
497                 uint8_t rsc_ipv4;
498                 uint8_t rsc_ipv6;
499         };
500         struct {
501                 uint8_t encapsulated_packet_task_offload;
502                 uint8_t encapsulation_types;
503         };
504
505 } rndis_offload_params;
506
507
508 typedef struct rndis_tcp_ip_csum_info_ {
509         union {
510                 struct {
511                         uint32_t is_ipv4:1;
512                         uint32_t is_ipv6:1;
513                         uint32_t tcp_csum:1;
514                         uint32_t udp_csum:1;
515                         uint32_t ip_header_csum:1;
516                         uint32_t reserved:11;
517                         uint32_t tcp_header_offset:10;
518                 } xmit;
519                 struct {
520                         uint32_t tcp_csum_failed:1;
521                         uint32_t udp_csum_failed:1;
522                         uint32_t ip_csum_failed:1;
523                         uint32_t tcp_csum_succeeded:1;
524                         uint32_t udp_csum_succeeded:1;
525                         uint32_t ip_csum_succeeded:1;
526                         uint32_t loopback:1;
527                         uint32_t tcp_csum_value_invalid:1;
528                         uint32_t ip_csum_value_invalid:1;
529                 } receive;
530                 uint32_t  value;
531         };
532 } rndis_tcp_ip_csum_info;
533
534 struct rndis_hash_value {
535         uint32_t        hash_value;
536 } __packed;
537
538 struct rndis_hash_info {
539         uint32_t        hash_info;
540 } __packed;
541
542 #define NDIS_HASH_FUNCTION_MASK         0x000000FF      /* see hash function */
543 #define NDIS_HASH_TYPE_MASK             0x00FFFF00      /* see hash type */
544
545 /* hash function */
546 #define NDIS_HASH_FUNCTION_TOEPLITZ     0x00000001
547
548 /* hash type */
549 #define NDIS_HASH_IPV4                  0x00000100
550 #define NDIS_HASH_TCP_IPV4              0x00000200
551 #define NDIS_HASH_IPV6                  0x00000400
552 #define NDIS_HASH_IPV6_EX               0x00000800
553 #define NDIS_HASH_TCP_IPV6              0x00001000
554 #define NDIS_HASH_TCP_IPV6_EX           0x00002000
555
556 typedef struct rndis_tcp_tso_info_ {
557         union {
558                 struct {
559                         uint32_t unused:30;
560                         uint32_t type:1;
561                         uint32_t reserved2:1;
562                 } xmit;
563                 struct {
564                         uint32_t mss:20;
565                         uint32_t tcp_header_offset:10;
566                         uint32_t type:1;
567                         uint32_t reserved2:1;
568                 } lso_v1_xmit;
569                 struct {
570                         uint32_t tcp_payload:30;
571                         uint32_t type:1;
572                         uint32_t reserved2:1;
573                 } lso_v1_xmit_complete;
574                 struct {
575                         uint32_t mss:20;
576                         uint32_t tcp_header_offset:10;
577                         uint32_t type:1;
578                         uint32_t ip_version:1;
579                 } lso_v2_xmit;
580                 struct {
581                         uint32_t reserved:30;
582                         uint32_t type:1;
583                         uint32_t reserved2:1;
584                 } lso_v2_xmit_complete;
585                 uint32_t  value;
586         };
587 } rndis_tcp_tso_info;
588
589 #define RNDIS_HASHVAL_PPI_SIZE  (sizeof(rndis_per_packet_info) + \
590                                 sizeof(struct rndis_hash_value))
591
592 #define RNDIS_VLAN_PPI_SIZE     (sizeof(rndis_per_packet_info) + \
593                                 sizeof(ndis_8021q_info))
594
595 #define RNDIS_CSUM_PPI_SIZE     (sizeof(rndis_per_packet_info) + \
596                                 sizeof(rndis_tcp_ip_csum_info))
597
598 #define RNDIS_TSO_PPI_SIZE      (sizeof(rndis_per_packet_info) + \
599                                 sizeof(rndis_tcp_tso_info))
600
601 /*
602  * Format of Information buffer passed in a SetRequest for the OID
603  * OID_GEN_RNDIS_CONFIG_PARAMETER.
604  */
605 typedef struct rndis_config_parameter_info_ {
606     uint32_t                                parameter_name_offset;
607     uint32_t                                parameter_name_length;
608     uint32_t                                parameter_type;
609     uint32_t                                parameter_value_offset;
610     uint32_t                                parameter_value_length;
611 } rndis_config_parameter_info;
612
613 /*
614  * Values for ParameterType in rndis_config_parameter_info
615  */
616 #define RNDIS_CONFIG_PARAM_TYPE_INTEGER     0
617 #define RNDIS_CONFIG_PARAM_TYPE_STRING      2
618
619
620 /*
621  * CONDIS Miniport messages for connection oriented devices
622  * that do not implement a call manager.
623  */
624
625 /*
626  * CoNdisMiniportCreateVc message
627  */
628 typedef struct rcondis_mp_create_vc_ {
629     /* RNDIS request ID */
630     uint32_t                                request_id;
631     /* RNDIS handle */
632     uint32_t                                ndis_vc_handle;
633 } rcondis_mp_create_vc;
634
635 /*
636  * Response to CoNdisMiniportCreateVc
637  */
638 typedef struct rcondis_mp_create_vc_complete_ {
639     /* RNDIS request ID */
640     uint32_t                                request_id;
641     /* RNDIS handle */
642     uint32_t                                device_vc_handle;
643     /* RNDIS status */
644     uint32_t                                status;
645 } rcondis_mp_create_vc_complete;
646
647 /*
648  * CoNdisMiniportDeleteVc message
649  */
650 typedef struct rcondis_mp_delete_vc_ {
651     /* RNDIS request ID */
652     uint32_t                                request_id;
653     /* RNDIS handle */
654     uint32_t                                device_vc_handle;
655 } rcondis_mp_delete_vc;
656
657 /*
658  * Response to CoNdisMiniportDeleteVc
659  */
660 typedef struct rcondis_mp_delete_vc_complete_ {
661     /* RNDIS request ID */
662     uint32_t                                request_id;
663     /* RNDIS status */
664     uint32_t                                status;
665 } rcondis_mp_delete_vc_complete;
666
667 /*
668  * CoNdisMiniportQueryRequest message
669  */
670 typedef struct rcondis_mp_query_request_ {
671     /* RNDIS request ID */
672     uint32_t                                request_id;
673     /* RNDIS request type */
674     uint32_t                                request_type;
675     /* RNDIS OID */
676     uint32_t                                oid;
677     /* RNDIS handle */
678     uint32_t                                device_vc_handle;
679     uint32_t                                info_buf_length;
680     uint32_t                                info_buf_offset;
681 } rcondis_mp_query_request;
682
683 /*
684  * CoNdisMiniportSetRequest message
685  */
686 typedef struct rcondis_mp_set_request_ {
687     /* RNDIS request ID */
688     uint32_t                                request_id;
689     /* RNDIS request type */
690     uint32_t                                request_type;
691     /* RNDIS OID */
692     uint32_t                                oid;
693     /* RNDIS handle */
694     uint32_t                                device_vc_handle;
695     uint32_t                                info_buf_length;
696     uint32_t                                info_buf_offset;
697 } rcondis_mp_set_request;
698
699 /*
700  * CoNdisIndicateStatus message
701  */
702 typedef struct rcondis_indicate_status_ {
703     /* RNDIS handle */
704     uint32_t                                ndis_vc_handle;
705     /* RNDIS status */
706     uint32_t                                status;
707     uint32_t                                status_buf_length;
708     uint32_t                                status_buf_offset;
709 } rcondis_indicate_status;
710
711 /*
712  * CONDIS Call/VC parameters
713  */
714
715 typedef struct rcondis_specific_parameters_ {
716     uint32_t                                parameter_type;
717     uint32_t                                parameter_length;
718     uint32_t                                parameter_offset;
719 } rcondis_specific_parameters;
720
721 typedef struct rcondis_media_parameters_ {
722     uint32_t                                flags;
723     uint32_t                                reserved1;
724     uint32_t                                reserved2;
725     rcondis_specific_parameters             media_specific;
726 } rcondis_media_parameters;
727
728 typedef struct rndis_flowspec_ {
729     uint32_t                                token_rate;
730     uint32_t                                token_bucket_size;
731     uint32_t                                peak_bandwidth;
732     uint32_t                                latency;
733     uint32_t                                delay_variation;
734     uint32_t                                service_type;
735     uint32_t                                max_sdu_size;
736     uint32_t                                minimum_policed_size;
737 } rndis_flowspec;
738
739 typedef struct rcondis_call_manager_parameters_ {
740     rndis_flowspec                          transmit;
741     rndis_flowspec                          receive;
742     rcondis_specific_parameters             call_mgr_specific;
743 } rcondis_call_manager_parameters;
744
745 /*
746  * CoNdisMiniportActivateVc message
747  */
748 typedef struct rcondis_mp_activate_vc_request_ {
749     /* RNDIS request ID */
750     uint32_t                                request_id;
751     uint32_t                                flags;
752     /* RNDIS handle */
753     uint32_t                                device_vc_handle;
754     uint32_t                                media_params_offset;
755     uint32_t                                media_params_length;
756     uint32_t                                call_mgr_params_offset;
757     uint32_t                                call_mgr_params_length;
758 } rcondis_mp_activate_vc_request;
759
760 /*
761  * Response to CoNdisMiniportActivateVc
762  */
763 typedef struct rcondis_mp_activate_vc_complete_ {
764     /* RNDIS request ID */
765     uint32_t                                request_id;
766     /* RNDIS status */
767     uint32_t                                status;
768 } rcondis_mp_activate_vc_complete;
769
770 /*
771  * CoNdisMiniportDeactivateVc message
772  */
773 typedef struct rcondis_mp_deactivate_vc_request_ {
774     /* RNDIS request ID */
775     uint32_t                                request_id;
776     uint32_t                                flags;
777     /* RNDIS handle */
778     uint32_t                                device_vc_handle;
779 } rcondis_mp_deactivate_vc_request;
780
781 /*
782  * Response to CoNdisMiniportDeactivateVc
783  */
784 typedef struct rcondis_mp_deactivate_vc_complete_ {
785     /* RNDIS request ID */
786     uint32_t                                request_id;
787     /* RNDIS status */
788     uint32_t                                status;
789 } rcondis_mp_deactivate_vc_complete;
790
791 /*
792  * union with all of the RNDIS messages
793  */
794 typedef union rndis_msg_container_ {
795     rndis_packet                            packet;
796     rndis_initialize_request                init_request;
797     rndis_halt_request                      halt_request;
798     rndis_query_request                     query_request;
799     rndis_set_request                       set_request;
800     rndis_reset_request                     reset_request;
801     rndis_keepalive_request                 keepalive_request;
802     rndis_indicate_status                   indicate_status;
803     rndis_initialize_complete               init_complete;
804     rndis_query_complete                    query_complete;
805     rndis_set_complete                      set_complete;
806     rndis_reset_complete                    reset_complete;
807     rndis_keepalive_complete                keepalive_complete;
808     rcondis_mp_create_vc                    co_miniport_create_vc;
809     rcondis_mp_delete_vc                    co_miniport_delete_vc;
810     rcondis_indicate_status                 co_miniport_status;
811     rcondis_mp_activate_vc_request          co_miniport_activate_vc;
812     rcondis_mp_deactivate_vc_request        co_miniport_deactivate_vc;
813     rcondis_mp_create_vc_complete           co_miniport_create_vc_complete;
814     rcondis_mp_delete_vc_complete           co_miniport_delete_vc_complete;
815     rcondis_mp_activate_vc_complete         co_miniport_activate_vc_complete;
816     rcondis_mp_deactivate_vc_complete       co_miniport_deactivate_vc_complete;
817     rndis_packet_ex                         packet_ex;
818 } rndis_msg_container;
819
820 /*
821  * Remote NDIS message format
822  */
823 typedef struct rndis_msg_ {
824     uint32_t                                ndis_msg_type;
825
826     /*
827      * Total length of this message, from the beginning
828      * of the rndis_msg struct, in bytes.
829      */
830     uint32_t                                msg_len;
831
832     /* Actual message */
833     rndis_msg_container                     msg;
834 } rndis_msg;
835
836
837 /*
838  * Handy macros
839  */
840
841 /*
842  * get the size of an RNDIS message. Pass in the message type, 
843  * rndis_set_request, rndis_packet for example
844  */
845 #define RNDIS_MESSAGE_SIZE(message)                             \
846     (sizeof(message) + (sizeof(rndis_msg) - sizeof(rndis_msg_container)))
847
848 /*
849  * get pointer to info buffer with message pointer
850  */
851 #define MESSAGE_TO_INFO_BUFFER(message)                         \
852     (((PUCHAR)(message)) + message->InformationBufferOffset)
853
854 /*
855  * get pointer to status buffer with message pointer
856  */
857 #define MESSAGE_TO_STATUS_BUFFER(message)                       \
858     (((PUCHAR)(message)) + message->StatusBufferOffset)
859
860 /*
861  * get pointer to OOBD buffer with message pointer
862  */
863 #define MESSAGE_TO_OOBD_BUFFER(message)                         \
864     (((PUCHAR)(message)) + message->OOBDataOffset)
865
866 /*
867  * get pointer to data buffer with message pointer
868  */
869 #define MESSAGE_TO_DATA_BUFFER(message)                         \
870     (((PUCHAR)(message)) + message->PerPacketInfoOffset)
871
872 /*
873  * get pointer to contained message from NDIS_MESSAGE pointer
874  */
875 #define RNDIS_MESSAGE_PTR_TO_MESSAGE_PTR(rndis_message)         \
876     ((void *) &rndis_message->Message)
877
878 /*
879  * get pointer to contained message from NDIS_MESSAGE pointer
880  */
881 #define RNDIS_MESSAGE_RAW_PTR_TO_MESSAGE_PTR(rndis_message)     \
882     ((void *) rndis_message)
883
884
885
886 /*
887  * Structures used in OID_RNDISMP_GET_RECEIVE_BUFFERS
888  */
889
890 #define RNDISMP_RECEIVE_BUFFER_ELEM_FLAG_VMQ_RECEIVE_BUFFER 0x00000001
891
892 typedef struct rndismp_rx_buf_elem_ {
893     uint32_t                            flags;
894     uint32_t                            length;
895     uint64_t                            rx_buf_id;
896     uint32_t                            gpadl_handle;
897     void                                *rx_buf;
898 } rndismp_rx_buf_elem;
899
900 typedef struct rndismp_rx_bufs_info_ {
901     uint32_t                            num_rx_bufs;
902     rndismp_rx_buf_elem                 rx_buf_elems[1];
903 } rndismp_rx_bufs_info;
904
905
906
907 #define RNDIS_HEADER_SIZE (sizeof(rndis_msg) - sizeof(rndis_msg_container))
908
909 #define NDIS_PACKET_TYPE_DIRECTED       0x00000001
910 #define NDIS_PACKET_TYPE_MULTICAST      0x00000002
911 #define NDIS_PACKET_TYPE_ALL_MULTICAST  0x00000004
912 #define NDIS_PACKET_TYPE_BROADCAST      0x00000008
913 #define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010
914 #define NDIS_PACKET_TYPE_PROMISCUOUS    0x00000020
915 #define NDIS_PACKET_TYPE_SMT            0x00000040
916 #define NDIS_PACKET_TYPE_ALL_LOCAL      0x00000080
917 #define NDIS_PACKET_TYPE_GROUP          0x00000100
918 #define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00000200
919 #define NDIS_PACKET_TYPE_FUNCTIONAL     0x00000400
920 #define NDIS_PACKET_TYPE_MAC_FRAME      0x00000800
921
922 /*
923  * Externs
924  */
925 struct hn_rx_ring;
926 struct hn_tx_ring;
927 struct hn_recvinfo;
928
929 int netvsc_recv(struct hn_rx_ring *rxr, const void *data, int dlen,
930     const struct hn_recvinfo *info);
931 void netvsc_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr);
932
933 void* hv_set_rppi_data(rndis_msg *rndis_mesg,
934     uint32_t rppi_size,
935     int pkt_type);
936
937 void* hv_get_ppi_data(rndis_packet *rpkt, uint32_t type);
938
939 #endif  /* __HV_RNDIS_H__ */
940