]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/hyperv/netvsc/hv_rndis.h
hyperv/hn: Simplify per-packet-info construction.
[FreeBSD/FreeBSD.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 /*
573  * Format of Information buffer passed in a SetRequest for the OID
574  * OID_GEN_RNDIS_CONFIG_PARAMETER.
575  */
576 typedef struct rndis_config_parameter_info_ {
577     uint32_t                                parameter_name_offset;
578     uint32_t                                parameter_name_length;
579     uint32_t                                parameter_type;
580     uint32_t                                parameter_value_offset;
581     uint32_t                                parameter_value_length;
582 } rndis_config_parameter_info;
583
584 /*
585  * Values for ParameterType in rndis_config_parameter_info
586  */
587 #define RNDIS_CONFIG_PARAM_TYPE_INTEGER     0
588 #define RNDIS_CONFIG_PARAM_TYPE_STRING      2
589
590
591 /*
592  * CONDIS Miniport messages for connection oriented devices
593  * that do not implement a call manager.
594  */
595
596 /*
597  * CoNdisMiniportCreateVc message
598  */
599 typedef struct rcondis_mp_create_vc_ {
600     /* RNDIS request ID */
601     uint32_t                                request_id;
602     /* RNDIS handle */
603     uint32_t                                ndis_vc_handle;
604 } rcondis_mp_create_vc;
605
606 /*
607  * Response to CoNdisMiniportCreateVc
608  */
609 typedef struct rcondis_mp_create_vc_complete_ {
610     /* RNDIS request ID */
611     uint32_t                                request_id;
612     /* RNDIS handle */
613     uint32_t                                device_vc_handle;
614     /* RNDIS status */
615     uint32_t                                status;
616 } rcondis_mp_create_vc_complete;
617
618 /*
619  * CoNdisMiniportDeleteVc message
620  */
621 typedef struct rcondis_mp_delete_vc_ {
622     /* RNDIS request ID */
623     uint32_t                                request_id;
624     /* RNDIS handle */
625     uint32_t                                device_vc_handle;
626 } rcondis_mp_delete_vc;
627
628 /*
629  * Response to CoNdisMiniportDeleteVc
630  */
631 typedef struct rcondis_mp_delete_vc_complete_ {
632     /* RNDIS request ID */
633     uint32_t                                request_id;
634     /* RNDIS status */
635     uint32_t                                status;
636 } rcondis_mp_delete_vc_complete;
637
638 /*
639  * CoNdisMiniportQueryRequest message
640  */
641 typedef struct rcondis_mp_query_request_ {
642     /* RNDIS request ID */
643     uint32_t                                request_id;
644     /* RNDIS request type */
645     uint32_t                                request_type;
646     /* RNDIS OID */
647     uint32_t                                oid;
648     /* RNDIS handle */
649     uint32_t                                device_vc_handle;
650     uint32_t                                info_buf_length;
651     uint32_t                                info_buf_offset;
652 } rcondis_mp_query_request;
653
654 /*
655  * CoNdisMiniportSetRequest message
656  */
657 typedef struct rcondis_mp_set_request_ {
658     /* RNDIS request ID */
659     uint32_t                                request_id;
660     /* RNDIS request type */
661     uint32_t                                request_type;
662     /* RNDIS OID */
663     uint32_t                                oid;
664     /* RNDIS handle */
665     uint32_t                                device_vc_handle;
666     uint32_t                                info_buf_length;
667     uint32_t                                info_buf_offset;
668 } rcondis_mp_set_request;
669
670 /*
671  * CoNdisIndicateStatus message
672  */
673 typedef struct rcondis_indicate_status_ {
674     /* RNDIS handle */
675     uint32_t                                ndis_vc_handle;
676     /* RNDIS status */
677     uint32_t                                status;
678     uint32_t                                status_buf_length;
679     uint32_t                                status_buf_offset;
680 } rcondis_indicate_status;
681
682 /*
683  * CONDIS Call/VC parameters
684  */
685
686 typedef struct rcondis_specific_parameters_ {
687     uint32_t                                parameter_type;
688     uint32_t                                parameter_length;
689     uint32_t                                parameter_offset;
690 } rcondis_specific_parameters;
691
692 typedef struct rcondis_media_parameters_ {
693     uint32_t                                flags;
694     uint32_t                                reserved1;
695     uint32_t                                reserved2;
696     rcondis_specific_parameters             media_specific;
697 } rcondis_media_parameters;
698
699 typedef struct rndis_flowspec_ {
700     uint32_t                                token_rate;
701     uint32_t                                token_bucket_size;
702     uint32_t                                peak_bandwidth;
703     uint32_t                                latency;
704     uint32_t                                delay_variation;
705     uint32_t                                service_type;
706     uint32_t                                max_sdu_size;
707     uint32_t                                minimum_policed_size;
708 } rndis_flowspec;
709
710 typedef struct rcondis_call_manager_parameters_ {
711     rndis_flowspec                          transmit;
712     rndis_flowspec                          receive;
713     rcondis_specific_parameters             call_mgr_specific;
714 } rcondis_call_manager_parameters;
715
716 /*
717  * CoNdisMiniportActivateVc message
718  */
719 typedef struct rcondis_mp_activate_vc_request_ {
720     /* RNDIS request ID */
721     uint32_t                                request_id;
722     uint32_t                                flags;
723     /* RNDIS handle */
724     uint32_t                                device_vc_handle;
725     uint32_t                                media_params_offset;
726     uint32_t                                media_params_length;
727     uint32_t                                call_mgr_params_offset;
728     uint32_t                                call_mgr_params_length;
729 } rcondis_mp_activate_vc_request;
730
731 /*
732  * Response to CoNdisMiniportActivateVc
733  */
734 typedef struct rcondis_mp_activate_vc_complete_ {
735     /* RNDIS request ID */
736     uint32_t                                request_id;
737     /* RNDIS status */
738     uint32_t                                status;
739 } rcondis_mp_activate_vc_complete;
740
741 /*
742  * CoNdisMiniportDeactivateVc message
743  */
744 typedef struct rcondis_mp_deactivate_vc_request_ {
745     /* RNDIS request ID */
746     uint32_t                                request_id;
747     uint32_t                                flags;
748     /* RNDIS handle */
749     uint32_t                                device_vc_handle;
750 } rcondis_mp_deactivate_vc_request;
751
752 /*
753  * Response to CoNdisMiniportDeactivateVc
754  */
755 typedef struct rcondis_mp_deactivate_vc_complete_ {
756     /* RNDIS request ID */
757     uint32_t                                request_id;
758     /* RNDIS status */
759     uint32_t                                status;
760 } rcondis_mp_deactivate_vc_complete;
761
762 /*
763  * union with all of the RNDIS messages
764  */
765 typedef union rndis_msg_container_ {
766     rndis_packet                            packet;
767     rndis_initialize_request                init_request;
768     rndis_halt_request                      halt_request;
769     rndis_query_request                     query_request;
770     rndis_set_request                       set_request;
771     rndis_reset_request                     reset_request;
772     rndis_keepalive_request                 keepalive_request;
773     rndis_indicate_status                   indicate_status;
774     rndis_initialize_complete               init_complete;
775     rndis_query_complete                    query_complete;
776     rndis_set_complete                      set_complete;
777     rndis_reset_complete                    reset_complete;
778     rndis_keepalive_complete                keepalive_complete;
779     rcondis_mp_create_vc                    co_miniport_create_vc;
780     rcondis_mp_delete_vc                    co_miniport_delete_vc;
781     rcondis_indicate_status                 co_miniport_status;
782     rcondis_mp_activate_vc_request          co_miniport_activate_vc;
783     rcondis_mp_deactivate_vc_request        co_miniport_deactivate_vc;
784     rcondis_mp_create_vc_complete           co_miniport_create_vc_complete;
785     rcondis_mp_delete_vc_complete           co_miniport_delete_vc_complete;
786     rcondis_mp_activate_vc_complete         co_miniport_activate_vc_complete;
787     rcondis_mp_deactivate_vc_complete       co_miniport_deactivate_vc_complete;
788     rndis_packet_ex                         packet_ex;
789 } rndis_msg_container;
790
791 /*
792  * Remote NDIS message format
793  */
794 typedef struct rndis_msg_ {
795     uint32_t                                ndis_msg_type;
796
797     /*
798      * Total length of this message, from the beginning
799      * of the rndis_msg struct, in bytes.
800      */
801     uint32_t                                msg_len;
802
803     /* Actual message */
804     rndis_msg_container                     msg;
805 } rndis_msg;
806
807
808 /*
809  * Handy macros
810  */
811
812 /*
813  * get the size of an RNDIS message. Pass in the message type, 
814  * rndis_set_request, rndis_packet for example
815  */
816 #define RNDIS_MESSAGE_SIZE(message)                             \
817     (sizeof(message) + (sizeof(rndis_msg) - sizeof(rndis_msg_container)))
818
819 /*
820  * get pointer to info buffer with message pointer
821  */
822 #define MESSAGE_TO_INFO_BUFFER(message)                         \
823     (((PUCHAR)(message)) + message->InformationBufferOffset)
824
825 /*
826  * get pointer to status buffer with message pointer
827  */
828 #define MESSAGE_TO_STATUS_BUFFER(message)                       \
829     (((PUCHAR)(message)) + message->StatusBufferOffset)
830
831 /*
832  * get pointer to OOBD buffer with message pointer
833  */
834 #define MESSAGE_TO_OOBD_BUFFER(message)                         \
835     (((PUCHAR)(message)) + message->OOBDataOffset)
836
837 /*
838  * get pointer to data buffer with message pointer
839  */
840 #define MESSAGE_TO_DATA_BUFFER(message)                         \
841     (((PUCHAR)(message)) + message->PerPacketInfoOffset)
842
843 /*
844  * get pointer to contained message from NDIS_MESSAGE pointer
845  */
846 #define RNDIS_MESSAGE_PTR_TO_MESSAGE_PTR(rndis_message)         \
847     ((void *) &rndis_message->Message)
848
849 /*
850  * get pointer to contained message from NDIS_MESSAGE pointer
851  */
852 #define RNDIS_MESSAGE_RAW_PTR_TO_MESSAGE_PTR(rndis_message)     \
853     ((void *) rndis_message)
854
855
856
857 /*
858  * Structures used in OID_RNDISMP_GET_RECEIVE_BUFFERS
859  */
860
861 #define RNDISMP_RECEIVE_BUFFER_ELEM_FLAG_VMQ_RECEIVE_BUFFER 0x00000001
862
863 typedef struct rndismp_rx_buf_elem_ {
864     uint32_t                            flags;
865     uint32_t                            length;
866     uint64_t                            rx_buf_id;
867     uint32_t                            gpadl_handle;
868     void                                *rx_buf;
869 } rndismp_rx_buf_elem;
870
871 typedef struct rndismp_rx_bufs_info_ {
872     uint32_t                            num_rx_bufs;
873     rndismp_rx_buf_elem                 rx_buf_elems[1];
874 } rndismp_rx_bufs_info;
875
876
877
878 #define RNDIS_HEADER_SIZE (sizeof(rndis_msg) - sizeof(rndis_msg_container))
879
880 /*
881  * Externs
882  */
883 struct hn_rx_ring;
884 struct hn_tx_ring;
885 struct hn_recvinfo;
886
887 int netvsc_recv(struct hn_rx_ring *rxr, const void *data, int dlen,
888     const struct hn_recvinfo *info);
889 void netvsc_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr);
890
891 #endif  /* __HV_RNDIS_H__ */
892