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