3 * Copyright (c) 2011, Microsoft Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 * Place - Suite 330, Boston, MA 02111-1307 USA.
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
21 * K. Y. Srinivasan <kys@microsoft.com>
28 #include <linux/list.h>
32 struct hv_netvsc_packet
;
34 /* Represent the xfer page packet which contains 1 or more netvsc packet */
35 struct xferpage_packet
{
36 struct list_head list_ent
;
38 /* # of netvsc packets this xfer packet contains */
42 /* The number of pages which are enough to cover jumbo frame buffer. */
43 #define NETVSC_PACKET_MAXPAGE 4
46 * Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame
49 struct hv_netvsc_packet
{
50 /* Bookkeeping stuff */
51 struct list_head list_ent
;
53 struct hv_device
*device
;
57 * Valid only for receives when we break a xfer page packet
58 * into multiple netvsc packets
60 struct xferpage_packet
*xfer_page_pkt
;
64 u64 recv_completion_tid
;
65 void *recv_completion_ctx
;
66 void (*recv_completion
)(void *context
);
69 u64 send_completion_tid
;
70 void *send_completion_ctx
;
71 void (*send_completion
)(void *context
);
75 /* This points to the memory after page_buf */
78 u32 total_data_buflen
;
79 /* Points to the send/receive buffer where the ethernet frame is */
81 struct hv_page_buffer page_buf
[NETVSC_PACKET_MAXPAGE
];
84 /* Represents the net vsc driver */
85 struct netvsc_driver
{
86 /* Must be the first field */
87 /* Which is a bug FIXME! */
88 struct hv_driver base
;
94 * This is set by the caller to allow us to callback when we
95 * receive a packet from the "wire"
97 int (*recv_cb
)(struct hv_device
*dev
,
98 struct hv_netvsc_packet
*packet
);
99 void (*link_status_change
)(struct hv_device
*dev
, u32 status
);
101 /* Specific to this driver */
102 int (*send
)(struct hv_device
*dev
, struct hv_netvsc_packet
*packet
);
107 struct netvsc_driver
*drv_to_netvscdrv(struct device_driver
*d
)
109 struct hv_driver
*hvdrv
= drv_to_hv_drv(d
);
110 return container_of(hvdrv
, struct netvsc_driver
, base
);
113 struct netvsc_device_info
{
114 unsigned char mac_adr
[6];
115 bool link_state
; /* 0 - link up, 1 - link down */
119 int netvsc_device_add(struct hv_device
*device
, void *additional_info
);
120 int netvsc_device_remove(struct hv_device
*device
);
121 int netvsc_send(struct hv_device
*device
,
122 struct hv_netvsc_packet
*packet
);
123 void netvsc_linkstatus_callback(struct hv_device
*device_obj
,
124 unsigned int status
);
125 int netvsc_recv_callback(struct hv_device
*device_obj
,
126 struct hv_netvsc_packet
*packet
);
127 int netvsc_initialize(struct hv_driver
*drv
);
128 int rndis_filter_open(struct hv_device
*dev
);
129 int rndis_filter_close(struct hv_device
*dev
);
130 int rndis_filte_device_add(struct hv_device
*dev
,
131 void *additional_info
);
132 int rndis_filter_device_remove(struct hv_device
*dev
);
133 int rndis_filter_receive(struct hv_device
*dev
,
134 struct hv_netvsc_packet
*pkt
);
138 int rndis_filter_send(struct hv_device
*dev
,
139 struct hv_netvsc_packet
*pkt
);
141 #define NVSP_INVALID_PROTOCOL_VERSION ((u32)0xFFFFFFFF)
143 #define NVSP_PROTOCOL_VERSION_1 2
144 #define NVSP_MIN_PROTOCOL_VERSION NVSP_PROTOCOL_VERSION_1
145 #define NVSP_MAX_PROTOCOL_VERSION NVSP_PROTOCOL_VERSION_1
148 NVSP_MSG_TYPE_NONE
= 0,
151 NVSP_MSG_TYPE_INIT
= 1,
152 NVSP_MSG_TYPE_INIT_COMPLETE
= 2,
154 NVSP_VERSION_MSG_START
= 100,
156 /* Version 1 Messages */
157 NVSP_MSG1_TYPE_SEND_NDIS_VER
= NVSP_VERSION_MSG_START
,
159 NVSP_MSG1_TYPE_SEND_RECV_BUF
,
160 NVSP_MSG1_TYPE_SEND_RECV_BUF_COMPLETE
,
161 NVSP_MSG1_TYPE_REVOKE_RECV_BUF
,
163 NVSP_MSG1_TYPE_SEND_SEND_BUF
,
164 NVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE
,
165 NVSP_MSG1_TYPE_REVOKE_SEND_BUF
,
167 NVSP_MSG1_TYPE_SEND_RNDIS_PKT
,
168 NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE
,
171 * This should be set to the number of messages for the version with
172 * the maximum number of messages.
174 NVSP_NUM_MSG_PER_VERSION
= 9,
181 NVSP_STAT_PROTOCOL_TOO_NEW
,
182 NVSP_STAT_PROTOCOL_TOO_OLD
,
183 NVSP_STAT_INVALID_RNDIS_PKT
,
188 struct nvsp_message_header
{
195 * This message is used by the VSC to initialize the channel after the channels
196 * has been opened. This message should never include anything other then
197 * versioning (i.e. this message will be the same for ever).
199 struct nvsp_message_init
{
200 u32 min_protocol_ver
;
201 u32 max_protocol_ver
;
205 * This message is used by the VSP to complete the initialization of the
206 * channel. This message should never include anything other then versioning
207 * (i.e. this message will be the same for ever).
209 struct nvsp_message_init_complete
{
210 u32 negotiated_protocol_ver
;
211 u32 max_mdl_chain_len
;
215 union nvsp_message_init_uber
{
216 struct nvsp_message_init init
;
217 struct nvsp_message_init_complete init_complete
;
220 /* Version 1 Messages */
223 * This message is used by the VSC to send the NDIS version to the VSP. The VSP
224 * can use this information when handling OIDs sent by the VSC.
226 struct nvsp_1_message_send_ndis_version
{
232 * This message is used by the VSC to send a receive buffer to the VSP. The VSP
233 * can then use the receive buffer to send data to the VSC.
235 struct nvsp_1_message_send_receive_buffer
{
240 struct nvsp_1_receive_buffer_section
{
248 * This message is used by the VSP to acknowledge a receive buffer send by the
249 * VSC. This message must be sent by the VSP before the VSP uses the receive
252 struct nvsp_1_message_send_receive_buffer_complete
{
257 * The receive buffer is split into two parts, a large suballocation
258 * section and a small suballocation section. These sections are then
259 * suballocated by a certain size.
263 * For example, the following break up of the receive buffer has 6
264 * large suballocations and 10 small suballocations.
268 * | Large Section | | Small Section |
269 * ------------------------------------------------------------
270 * | | | | | | | | | | | | | | | | | |
272 * LargeOffset SmallOffset
275 struct nvsp_1_receive_buffer_section sections
[1];
279 * This message is sent by the VSC to revoke the receive buffer. After the VSP
280 * completes this transaction, the vsp should never use the receive buffer
283 struct nvsp_1_message_revoke_receive_buffer
{
288 * This message is used by the VSC to send a send buffer to the VSP. The VSC
289 * can then use the send buffer to send data to the VSP.
291 struct nvsp_1_message_send_send_buffer
{
297 * This message is used by the VSP to acknowledge a send buffer sent by the
298 * VSC. This message must be sent by the VSP before the VSP uses the sent
301 struct nvsp_1_message_send_send_buffer_complete
{
305 * The VSC gets to choose the size of the send buffer and the VSP gets
306 * to choose the sections size of the buffer. This was done to enable
307 * dynamic reconfigurations when the cost of GPA-direct buffers
314 * This message is sent by the VSC to revoke the send buffer. After the VSP
315 * completes this transaction, the vsp should never use the send buffer again.
317 struct nvsp_1_message_revoke_send_buffer
{
322 * This message is used by both the VSP and the VSC to send a RNDIS message to
323 * the opposite channel endpoint.
325 struct nvsp_1_message_send_rndis_packet
{
327 * This field is specified by RNIDS. They assume there's two different
328 * channels of communication. However, the Network VSP only has one.
329 * Therefore, the channel travels with the RNDIS packet.
334 * This field is used to send part or all of the data through a send
335 * buffer. This values specifies an index into the send buffer. If the
336 * index is 0xFFFFFFFF, then the send buffer is not being used and all
337 * of the data was sent through other VMBus mechanisms.
339 u32 send_buf_section_index
;
340 u32 send_buf_section_size
;
344 * This message is used by both the VSP and the VSC to complete a RNDIS message
345 * to the opposite channel endpoint. At this point, the initiator of this
346 * message cannot use any resources associated with the original RNDIS packet.
348 struct nvsp_1_message_send_rndis_packet_complete
{
352 union nvsp_1_message_uber
{
353 struct nvsp_1_message_send_ndis_version send_ndis_ver
;
355 struct nvsp_1_message_send_receive_buffer send_recv_buf
;
356 struct nvsp_1_message_send_receive_buffer_complete
357 send_recv_buf_complete
;
358 struct nvsp_1_message_revoke_receive_buffer revoke_recv_buf
;
360 struct nvsp_1_message_send_send_buffer send_send_buf
;
361 struct nvsp_1_message_send_send_buffer_complete send_send_buf_complete
;
362 struct nvsp_1_message_revoke_send_buffer revoke_send_buf
;
364 struct nvsp_1_message_send_rndis_packet send_rndis_pkt
;
365 struct nvsp_1_message_send_rndis_packet_complete
366 send_rndis_pkt_complete
;
369 union nvsp_all_messages
{
370 union nvsp_message_init_uber init_msg
;
371 union nvsp_1_message_uber v1_msg
;
375 struct nvsp_message
{
376 struct nvsp_message_header hdr
;
377 union nvsp_all_messages msg
;
383 /* #define NVSC_MIN_PROTOCOL_VERSION 1 */
384 /* #define NVSC_MAX_PROTOCOL_VERSION 1 */
386 #define NETVSC_SEND_BUFFER_SIZE (64*1024) /* 64K */
387 #define NETVSC_SEND_BUFFER_ID 0xface
390 #define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024) /* 1MB */
392 #define NETVSC_RECEIVE_BUFFER_ID 0xcafe
394 #define NETVSC_RECEIVE_SG_COUNT 1
396 /* Preallocated receive packets */
397 #define NETVSC_RECEIVE_PACKETLIST_COUNT 256
399 #define NETVSC_PACKET_SIZE 2048
401 /* Per netvsc channel-specific */
402 struct netvsc_device
{
403 struct hv_device
*dev
;
406 atomic_t num_outstanding_sends
;
408 * List of free preallocated hv_netvsc_packet to represent receive
411 struct list_head recv_pkt_list
;
412 spinlock_t recv_pkt_list_lock
;
414 /* Send buffer allocated by us but manages by NetVSP */
417 u32 send_buf_gpadl_handle
;
418 u32 send_section_size
;
420 /* Receive buffer allocated by us but manages by NetVSP */
423 u32 recv_buf_gpadl_handle
;
424 u32 recv_section_cnt
;
425 struct nvsp_1_receive_buffer_section
*recv_section
;
427 /* Used for NetVSP initialization protocol */
428 struct completion channel_init_wait
;
429 struct nvsp_message channel_init_pkt
;
431 struct nvsp_message revoke_packet
;
432 /* unsigned char HwMacAddr[HW_MACADDR_LEN]; */
434 /* Holds rndis device info */
442 #ifndef STATUS_SUCCESS
443 #define STATUS_SUCCESS (0x00000000L)
446 #ifndef STATUS_UNSUCCESSFUL
447 #define STATUS_UNSUCCESSFUL (0xC0000001L)
450 #ifndef STATUS_PENDING
451 #define STATUS_PENDING (0x00000103L)
454 #ifndef STATUS_INSUFFICIENT_RESOURCES
455 #define STATUS_INSUFFICIENT_RESOURCES (0xC000009AL)
458 #ifndef STATUS_BUFFER_OVERFLOW
459 #define STATUS_BUFFER_OVERFLOW (0x80000005L)
462 #ifndef STATUS_NOT_SUPPORTED
463 #define STATUS_NOT_SUPPORTED (0xC00000BBL)
466 #define RNDIS_STATUS_SUCCESS (STATUS_SUCCESS)
467 #define RNDIS_STATUS_PENDING (STATUS_PENDING)
468 #define RNDIS_STATUS_NOT_RECOGNIZED (0x00010001L)
469 #define RNDIS_STATUS_NOT_COPIED (0x00010002L)
470 #define RNDIS_STATUS_NOT_ACCEPTED (0x00010003L)
471 #define RNDIS_STATUS_CALL_ACTIVE (0x00010007L)
473 #define RNDIS_STATUS_ONLINE (0x40010003L)
474 #define RNDIS_STATUS_RESET_START (0x40010004L)
475 #define RNDIS_STATUS_RESET_END (0x40010005L)
476 #define RNDIS_STATUS_RING_STATUS (0x40010006L)
477 #define RNDIS_STATUS_CLOSED (0x40010007L)
478 #define RNDIS_STATUS_WAN_LINE_UP (0x40010008L)
479 #define RNDIS_STATUS_WAN_LINE_DOWN (0x40010009L)
480 #define RNDIS_STATUS_WAN_FRAGMENT (0x4001000AL)
481 #define RNDIS_STATUS_MEDIA_CONNECT (0x4001000BL)
482 #define RNDIS_STATUS_MEDIA_DISCONNECT (0x4001000CL)
483 #define RNDIS_STATUS_HARDWARE_LINE_UP (0x4001000DL)
484 #define RNDIS_STATUS_HARDWARE_LINE_DOWN (0x4001000EL)
485 #define RNDIS_STATUS_INTERFACE_UP (0x4001000FL)
486 #define RNDIS_STATUS_INTERFACE_DOWN (0x40010010L)
487 #define RNDIS_STATUS_MEDIA_BUSY (0x40010011L)
488 #define RNDIS_STATUS_MEDIA_SPECIFIC_INDICATION (0x40010012L)
489 #define RNDIS_STATUS_WW_INDICATION RDIA_SPECIFIC_INDICATION
490 #define RNDIS_STATUS_LINK_SPEED_CHANGE (0x40010013L)
492 #define RNDIS_STATUS_NOT_RESETTABLE (0x80010001L)
493 #define RNDIS_STATUS_SOFT_ERRORS (0x80010003L)
494 #define RNDIS_STATUS_HARD_ERRORS (0x80010004L)
495 #define RNDIS_STATUS_BUFFER_OVERFLOW (STATUS_BUFFER_OVERFLOW)
497 #define RNDIS_STATUS_FAILURE (STATUS_UNSUCCESSFUL)
498 #define RNDIS_STATUS_RESOURCES (STATUS_INSUFFICIENT_RESOURCES)
499 #define RNDIS_STATUS_CLOSING (0xC0010002L)
500 #define RNDIS_STATUS_BAD_VERSION (0xC0010004L)
501 #define RNDIS_STATUS_BAD_CHARACTERISTICS (0xC0010005L)
502 #define RNDIS_STATUS_ADAPTER_NOT_FOUND (0xC0010006L)
503 #define RNDIS_STATUS_OPEN_FAILED (0xC0010007L)
504 #define RNDIS_STATUS_DEVICE_FAILED (0xC0010008L)
505 #define RNDIS_STATUS_MULTICAST_FULL (0xC0010009L)
506 #define RNDIS_STATUS_MULTICAST_EXISTS (0xC001000AL)
507 #define RNDIS_STATUS_MULTICAST_NOT_FOUND (0xC001000BL)
508 #define RNDIS_STATUS_REQUEST_ABORTED (0xC001000CL)
509 #define RNDIS_STATUS_RESET_IN_PROGRESS (0xC001000DL)
510 #define RNDIS_STATUS_CLOSING_INDICATING (0xC001000EL)
511 #define RNDIS_STATUS_NOT_SUPPORTED (STATUS_NOT_SUPPORTED)
512 #define RNDIS_STATUS_INVALID_PACKET (0xC001000FL)
513 #define RNDIS_STATUS_OPEN_LIST_FULL (0xC0010010L)
514 #define RNDIS_STATUS_ADAPTER_NOT_READY (0xC0010011L)
515 #define RNDIS_STATUS_ADAPTER_NOT_OPEN (0xC0010012L)
516 #define RNDIS_STATUS_NOT_INDICATING (0xC0010013L)
517 #define RNDIS_STATUS_INVALID_LENGTH (0xC0010014L)
518 #define RNDIS_STATUS_INVALID_DATA (0xC0010015L)
519 #define RNDIS_STATUS_BUFFER_TOO_SHORT (0xC0010016L)
520 #define RNDIS_STATUS_INVALID_OID (0xC0010017L)
521 #define RNDIS_STATUS_ADAPTER_REMOVED (0xC0010018L)
522 #define RNDIS_STATUS_UNSUPPORTED_MEDIA (0xC0010019L)
523 #define RNDIS_STATUS_GROUP_ADDRESS_IN_USE (0xC001001AL)
524 #define RNDIS_STATUS_FILE_NOT_FOUND (0xC001001BL)
525 #define RNDIS_STATUS_ERROR_READING_FILE (0xC001001CL)
526 #define RNDIS_STATUS_ALREADY_MAPPED (0xC001001DL)
527 #define RNDIS_STATUS_RESOURCE_CONFLICT (0xC001001EL)
528 #define RNDIS_STATUS_NO_CABLE (0xC001001FL)
530 #define RNDIS_STATUS_INVALID_SAP (0xC0010020L)
531 #define RNDIS_STATUS_SAP_IN_USE (0xC0010021L)
532 #define RNDIS_STATUS_INVALID_ADDRESS (0xC0010022L)
533 #define RNDIS_STATUS_VC_NOT_ACTIVATED (0xC0010023L)
534 #define RNDIS_STATUS_DEST_OUT_OF_ORDER (0xC0010024L)
535 #define RNDIS_STATUS_VC_NOT_AVAILABLE (0xC0010025L)
536 #define RNDIS_STATUS_CELLRATE_NOT_AVAILABLE (0xC0010026L)
537 #define RNDIS_STATUS_INCOMPATABLE_QOS (0xC0010027L)
538 #define RNDIS_STATUS_AAL_PARAMS_UNSUPPORTED (0xC0010028L)
539 #define RNDIS_STATUS_NO_ROUTE_TO_DESTINATION (0xC0010029L)
541 #define RNDIS_STATUS_TOKEN_RING_OPEN_ERROR (0xC0011000L)
543 /* Object Identifiers used by NdisRequest Query/Set Information */
544 /* General Objects */
545 #define RNDIS_OID_GEN_SUPPORTED_LIST 0x00010101
546 #define RNDIS_OID_GEN_HARDWARE_STATUS 0x00010102
547 #define RNDIS_OID_GEN_MEDIA_SUPPORTED 0x00010103
548 #define RNDIS_OID_GEN_MEDIA_IN_USE 0x00010104
549 #define RNDIS_OID_GEN_MAXIMUM_LOOKAHEAD 0x00010105
550 #define RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106
551 #define RNDIS_OID_GEN_LINK_SPEED 0x00010107
552 #define RNDIS_OID_GEN_TRANSMIT_BUFFER_SPACE 0x00010108
553 #define RNDIS_OID_GEN_RECEIVE_BUFFER_SPACE 0x00010109
554 #define RNDIS_OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010A
555 #define RNDIS_OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010B
556 #define RNDIS_OID_GEN_VENDOR_ID 0x0001010C
557 #define RNDIS_OID_GEN_VENDOR_DESCRIPTION 0x0001010D
558 #define RNDIS_OID_GEN_CURRENT_PACKET_FILTER 0x0001010E
559 #define RNDIS_OID_GEN_CURRENT_LOOKAHEAD 0x0001010F
560 #define RNDIS_OID_GEN_DRIVER_VERSION 0x00010110
561 #define RNDIS_OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111
562 #define RNDIS_OID_GEN_PROTOCOL_OPTIONS 0x00010112
563 #define RNDIS_OID_GEN_MAC_OPTIONS 0x00010113
564 #define RNDIS_OID_GEN_MEDIA_CONNECT_STATUS 0x00010114
565 #define RNDIS_OID_GEN_MAXIMUM_SEND_PACKETS 0x00010115
566 #define RNDIS_OID_GEN_VENDOR_DRIVER_VERSION 0x00010116
567 #define RNDIS_OID_GEN_NETWORK_LAYER_ADDRESSES 0x00010118
568 #define RNDIS_OID_GEN_TRANSPORT_HEADER_OFFSET 0x00010119
569 #define RNDIS_OID_GEN_MACHINE_NAME 0x0001021A
570 #define RNDIS_OID_GEN_RNDIS_CONFIG_PARAMETER 0x0001021B
572 #define RNDIS_OID_GEN_XMIT_OK 0x00020101
573 #define RNDIS_OID_GEN_RCV_OK 0x00020102
574 #define RNDIS_OID_GEN_XMIT_ERROR 0x00020103
575 #define RNDIS_OID_GEN_RCV_ERROR 0x00020104
576 #define RNDIS_OID_GEN_RCV_NO_BUFFER 0x00020105
578 #define RNDIS_OID_GEN_DIRECTED_BYTES_XMIT 0x00020201
579 #define RNDIS_OID_GEN_DIRECTED_FRAMES_XMIT 0x00020202
580 #define RNDIS_OID_GEN_MULTICAST_BYTES_XMIT 0x00020203
581 #define RNDIS_OID_GEN_MULTICAST_FRAMES_XMIT 0x00020204
582 #define RNDIS_OID_GEN_BROADCAST_BYTES_XMIT 0x00020205
583 #define RNDIS_OID_GEN_BROADCAST_FRAMES_XMIT 0x00020206
584 #define RNDIS_OID_GEN_DIRECTED_BYTES_RCV 0x00020207
585 #define RNDIS_OID_GEN_DIRECTED_FRAMES_RCV 0x00020208
586 #define RNDIS_OID_GEN_MULTICAST_BYTES_RCV 0x00020209
587 #define RNDIS_OID_GEN_MULTICAST_FRAMES_RCV 0x0002020A
588 #define RNDIS_OID_GEN_BROADCAST_BYTES_RCV 0x0002020B
589 #define RNDIS_OID_GEN_BROADCAST_FRAMES_RCV 0x0002020C
591 #define RNDIS_OID_GEN_RCV_CRC_ERROR 0x0002020D
592 #define RNDIS_OID_GEN_TRANSMIT_QUEUE_LENGTH 0x0002020E
594 #define RNDIS_OID_GEN_GET_TIME_CAPS 0x0002020F
595 #define RNDIS_OID_GEN_GET_NETCARD_TIME 0x00020210
597 /* These are connection-oriented general OIDs. */
598 /* These replace the above OIDs for connection-oriented media. */
599 #define RNDIS_OID_GEN_CO_SUPPORTED_LIST 0x00010101
600 #define RNDIS_OID_GEN_CO_HARDWARE_STATUS 0x00010102
601 #define RNDIS_OID_GEN_CO_MEDIA_SUPPORTED 0x00010103
602 #define RNDIS_OID_GEN_CO_MEDIA_IN_USE 0x00010104
603 #define RNDIS_OID_GEN_CO_LINK_SPEED 0x00010105
604 #define RNDIS_OID_GEN_CO_VENDOR_ID 0x00010106
605 #define RNDIS_OID_GEN_CO_VENDOR_DESCRIPTION 0x00010107
606 #define RNDIS_OID_GEN_CO_DRIVER_VERSION 0x00010108
607 #define RNDIS_OID_GEN_CO_PROTOCOL_OPTIONS 0x00010109
608 #define RNDIS_OID_GEN_CO_MAC_OPTIONS 0x0001010A
609 #define RNDIS_OID_GEN_CO_MEDIA_CONNECT_STATUS 0x0001010B
610 #define RNDIS_OID_GEN_CO_VENDOR_DRIVER_VERSION 0x0001010C
611 #define RNDIS_OID_GEN_CO_MINIMUM_LINK_SPEED 0x0001010D
613 #define RNDIS_OID_GEN_CO_GET_TIME_CAPS 0x00010201
614 #define RNDIS_OID_GEN_CO_GET_NETCARD_TIME 0x00010202
616 /* These are connection-oriented statistics OIDs. */
617 #define RNDIS_OID_GEN_CO_XMIT_PDUS_OK 0x00020101
618 #define RNDIS_OID_GEN_CO_RCV_PDUS_OK 0x00020102
619 #define RNDIS_OID_GEN_CO_XMIT_PDUS_ERROR 0x00020103
620 #define RNDIS_OID_GEN_CO_RCV_PDUS_ERROR 0x00020104
621 #define RNDIS_OID_GEN_CO_RCV_PDUS_NO_BUFFER 0x00020105
624 #define RNDIS_OID_GEN_CO_RCV_CRC_ERROR 0x00020201
625 #define RNDIS_OID_GEN_CO_TRANSMIT_QUEUE_LENGTH 0x00020202
626 #define RNDIS_OID_GEN_CO_BYTES_XMIT 0x00020203
627 #define RNDIS_OID_GEN_CO_BYTES_RCV 0x00020204
628 #define RNDIS_OID_GEN_CO_BYTES_XMIT_OUTSTANDING 0x00020205
629 #define RNDIS_OID_GEN_CO_NETCARD_LOAD 0x00020206
631 /* These are objects for Connection-oriented media call-managers. */
632 #define RNDIS_OID_CO_ADD_PVC 0xFF000001
633 #define RNDIS_OID_CO_DELETE_PVC 0xFF000002
634 #define RNDIS_OID_CO_GET_CALL_INFORMATION 0xFF000003
635 #define RNDIS_OID_CO_ADD_ADDRESS 0xFF000004
636 #define RNDIS_OID_CO_DELETE_ADDRESS 0xFF000005
637 #define RNDIS_OID_CO_GET_ADDRESSES 0xFF000006
638 #define RNDIS_OID_CO_ADDRESS_CHANGE 0xFF000007
639 #define RNDIS_OID_CO_SIGNALING_ENABLED 0xFF000008
640 #define RNDIS_OID_CO_SIGNALING_DISABLED 0xFF000009
642 /* 802.3 Objects (Ethernet) */
643 #define RNDIS_OID_802_3_PERMANENT_ADDRESS 0x01010101
644 #define RNDIS_OID_802_3_CURRENT_ADDRESS 0x01010102
645 #define RNDIS_OID_802_3_MULTICAST_LIST 0x01010103
646 #define RNDIS_OID_802_3_MAXIMUM_LIST_SIZE 0x01010104
647 #define RNDIS_OID_802_3_MAC_OPTIONS 0x01010105
649 #define NDIS_802_3_MAC_OPTION_PRIORITY 0x00000001
651 #define RNDIS_OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101
652 #define RNDIS_OID_802_3_XMIT_ONE_COLLISION 0x01020102
653 #define RNDIS_OID_802_3_XMIT_MORE_COLLISIONS 0x01020103
655 #define RNDIS_OID_802_3_XMIT_DEFERRED 0x01020201
656 #define RNDIS_OID_802_3_XMIT_MAX_COLLISIONS 0x01020202
657 #define RNDIS_OID_802_3_RCV_OVERRUN 0x01020203
658 #define RNDIS_OID_802_3_XMIT_UNDERRUN 0x01020204
659 #define RNDIS_OID_802_3_XMIT_HEARTBEAT_FAILURE 0x01020205
660 #define RNDIS_OID_802_3_XMIT_TIMES_CRS_LOST 0x01020206
661 #define RNDIS_OID_802_3_XMIT_LATE_COLLISIONS 0x01020207
663 /* Remote NDIS message types */
664 #define REMOTE_NDIS_PACKET_MSG 0x00000001
665 #define REMOTE_NDIS_INITIALIZE_MSG 0x00000002
666 #define REMOTE_NDIS_HALT_MSG 0x00000003
667 #define REMOTE_NDIS_QUERY_MSG 0x00000004
668 #define REMOTE_NDIS_SET_MSG 0x00000005
669 #define REMOTE_NDIS_RESET_MSG 0x00000006
670 #define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007
671 #define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008
673 #define REMOTE_CONDIS_MP_CREATE_VC_MSG 0x00008001
674 #define REMOTE_CONDIS_MP_DELETE_VC_MSG 0x00008002
675 #define REMOTE_CONDIS_MP_ACTIVATE_VC_MSG 0x00008005
676 #define REMOTE_CONDIS_MP_DEACTIVATE_VC_MSG 0x00008006
677 #define REMOTE_CONDIS_INDICATE_STATUS_MSG 0x00008007
679 /* Remote NDIS message completion types */
680 #define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002
681 #define REMOTE_NDIS_QUERY_CMPLT 0x80000004
682 #define REMOTE_NDIS_SET_CMPLT 0x80000005
683 #define REMOTE_NDIS_RESET_CMPLT 0x80000006
684 #define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008
686 #define REMOTE_CONDIS_MP_CREATE_VC_CMPLT 0x80008001
687 #define REMOTE_CONDIS_MP_DELETE_VC_CMPLT 0x80008002
688 #define REMOTE_CONDIS_MP_ACTIVATE_VC_CMPLT 0x80008005
689 #define REMOTE_CONDIS_MP_DEACTIVATE_VC_CMPLT 0x80008006
692 * Reserved message type for private communication between lower-layer host
693 * driver and remote device, if necessary.
695 #define REMOTE_NDIS_BUS_MSG 0xff000001
697 /* Defines for DeviceFlags in struct rndis_initialize_complete */
698 #define RNDIS_DF_CONNECTIONLESS 0x00000001
699 #define RNDIS_DF_CONNECTION_ORIENTED 0x00000002
700 #define RNDIS_DF_RAW_DATA 0x00000004
702 /* Remote NDIS medium types. */
703 #define RNDIS_MEDIUM_802_3 0x00000000
704 #define RNDIS_MEDIUM_802_5 0x00000001
705 #define RNDIS_MEDIUM_FDDI 0x00000002
706 #define RNDIS_MEDIUM_WAN 0x00000003
707 #define RNDIS_MEDIUM_LOCAL_TALK 0x00000004
708 #define RNDIS_MEDIUM_ARCNET_RAW 0x00000006
709 #define RNDIS_MEDIUM_ARCNET_878_2 0x00000007
710 #define RNDIS_MEDIUM_ATM 0x00000008
711 #define RNDIS_MEDIUM_WIRELESS_WAN 0x00000009
712 #define RNDIS_MEDIUM_IRDA 0x0000000a
713 #define RNDIS_MEDIUM_CO_WAN 0x0000000b
714 /* Not a real medium, defined as an upper-bound */
715 #define RNDIS_MEDIUM_MAX 0x0000000d
718 /* Remote NDIS medium connection states. */
719 #define RNDIS_MEDIA_STATE_CONNECTED 0x00000000
720 #define RNDIS_MEDIA_STATE_DISCONNECTED 0x00000001
722 /* Remote NDIS version numbers */
723 #define RNDIS_MAJOR_VERSION 0x00000001
724 #define RNDIS_MINOR_VERSION 0x00000000
727 /* NdisInitialize message */
728 struct rndis_initialize_request
{
735 /* Response to NdisInitialize */
736 struct rndis_initialize_complete
{
745 u32 pkt_alignment_factor
;
750 /* Call manager devices only: Information about an address family */
751 /* supported by the device is appended to the response to NdisInitialize. */
752 struct rndis_co_address_family
{
758 /* NdisHalt message */
759 struct rndis_halt_request
{
763 /* NdisQueryRequest message */
764 struct rndis_query_request
{
772 /* Response to NdisQueryRequest */
773 struct rndis_query_complete
{
780 /* NdisSetRequest message */
781 struct rndis_set_request
{
789 /* Response to NdisSetRequest */
790 struct rndis_set_complete
{
795 /* NdisReset message */
796 struct rndis_reset_request
{
800 /* Response to NdisReset */
801 struct rndis_reset_complete
{
803 u32 addressing_reset
;
806 /* NdisMIndicateStatus message */
807 struct rndis_indicate_status
{
810 u32 status_buf_offset
;
813 /* Diagnostic information passed as the status buffer in */
814 /* struct rndis_indicate_status messages signifying error conditions. */
815 struct rndis_diagnostic_info
{
820 /* NdisKeepAlive message */
821 struct rndis_keepalive_request
{
825 /* Response to NdisKeepAlive */
826 struct rndis_keepalive_complete
{
832 * Data message. All Offset fields contain byte offsets from the beginning of
833 * struct rndis_packet. All Length fields are in bytes. VcHandle is set
834 * to 0 for connectionless data, otherwise it contains the VC handle.
836 struct rndis_packet
{
841 u32 num_oob_data_elements
;
842 u32 per_pkt_info_offset
;
843 u32 per_pkt_info_len
;
848 /* Optional Out of Band data associated with a Data message. */
852 u32 class_info_offset
;
855 /* Packet extension field contents associated with a Data message. */
856 struct rndis_per_packet_info
{
859 u32 per_pkt_info_offset
;
862 /* Format of Information buffer passed in a SetRequest for the OID */
863 /* OID_GEN_RNDIS_CONFIG_PARAMETER. */
864 struct rndis_config_parameter_info
{
865 u32 parameter_name_offset
;
866 u32 parameter_name_length
;
868 u32 parameter_value_offset
;
869 u32 parameter_value_length
;
872 /* Values for ParameterType in struct rndis_config_parameter_info */
873 #define RNDIS_CONFIG_PARAM_TYPE_INTEGER 0
874 #define RNDIS_CONFIG_PARAM_TYPE_STRING 2
876 /* CONDIS Miniport messages for connection oriented devices */
877 /* that do not implement a call manager. */
879 /* CoNdisMiniportCreateVc message */
880 struct rcondis_mp_create_vc
{
885 /* Response to CoNdisMiniportCreateVc */
886 struct rcondis_mp_create_vc_complete
{
892 /* CoNdisMiniportDeleteVc message */
893 struct rcondis_mp_delete_vc
{
898 /* Response to CoNdisMiniportDeleteVc */
899 struct rcondis_mp_delete_vc_complete
{
904 /* CoNdisMiniportQueryRequest message */
905 struct rcondis_mp_query_request
{
914 /* CoNdisMiniportSetRequest message */
915 struct rcondis_mp_set_request
{
924 /* CoNdisIndicateStatus message */
925 struct rcondis_indicate_status
{
929 u32 status_buf_offset
;
932 /* CONDIS Call/VC parameters */
933 struct rcondis_specific_parameters
{
935 u32 parameter_length
;
936 u32 parameter_lffset
;
939 struct rcondis_media_parameters
{
943 struct rcondis_specific_parameters media_specific
;
946 struct rndis_flowspec
{
948 u32 token_bucket_size
;
954 u32 minimum_policed_size
;
957 struct rcondis_call_manager_parameters
{
958 struct rndis_flowspec transmit
;
959 struct rndis_flowspec receive
;
960 struct rcondis_specific_parameters call_mgr_specific
;
963 /* CoNdisMiniportActivateVc message */
964 struct rcondis_mp_activate_vc_request
{
968 u32 media_params_offset
;
969 u32 media_params_length
;
970 u32 call_mgr_params_offset
;
971 u32 call_mgr_params_length
;
974 /* Response to CoNdisMiniportActivateVc */
975 struct rcondis_mp_activate_vc_complete
{
980 /* CoNdisMiniportDeactivateVc message */
981 struct rcondis_mp_deactivate_vc_request
{
987 /* Response to CoNdisMiniportDeactivateVc */
988 struct rcondis_mp_deactivate_vc_complete
{
994 /* union with all of the RNDIS messages */
995 union rndis_message_container
{
996 struct rndis_packet pkt
;
997 struct rndis_initialize_request init_req
;
998 struct rndis_halt_request halt_req
;
999 struct rndis_query_request query_req
;
1000 struct rndis_set_request set_req
;
1001 struct rndis_reset_request reset_req
;
1002 struct rndis_keepalive_request keep_alive_req
;
1003 struct rndis_indicate_status indicate_status
;
1004 struct rndis_initialize_complete init_complete
;
1005 struct rndis_query_complete query_complete
;
1006 struct rndis_set_complete set_complete
;
1007 struct rndis_reset_complete reset_complete
;
1008 struct rndis_keepalive_complete keep_alive_complete
;
1009 struct rcondis_mp_create_vc co_miniport_create_vc
;
1010 struct rcondis_mp_delete_vc co_miniport_delete_vc
;
1011 struct rcondis_indicate_status co_indicate_status
;
1012 struct rcondis_mp_activate_vc_request co_miniport_activate_vc
;
1013 struct rcondis_mp_deactivate_vc_request co_miniport_deactivate_vc
;
1014 struct rcondis_mp_create_vc_complete co_miniport_create_vc_complete
;
1015 struct rcondis_mp_delete_vc_complete co_miniport_delete_vc_complete
;
1016 struct rcondis_mp_activate_vc_complete co_miniport_activate_vc_complete
;
1017 struct rcondis_mp_deactivate_vc_complete
1018 co_miniport_deactivate_vc_complete
;
1021 /* Remote NDIS message format */
1022 struct rndis_message
{
1025 /* Total length of this message, from the beginning */
1026 /* of the sruct rndis_message, in bytes. */
1029 /* Actual message */
1030 union rndis_message_container msg
;
1035 /* get the size of an RNDIS message. Pass in the message type, */
1036 /* struct rndis_set_request, struct rndis_packet for example */
1037 #define RNDIS_MESSAGE_SIZE(msg) \
1038 (sizeof(msg) + (sizeof(struct rndis_message) - \
1039 sizeof(union rndis_message_container)))
1041 /* get pointer to info buffer with message pointer */
1042 #define MESSAGE_TO_INFO_BUFFER(msg) \
1043 (((unsigned char *)(msg)) + msg->info_buf_offset)
1045 /* get pointer to status buffer with message pointer */
1046 #define MESSAGE_TO_STATUS_BUFFER(msg) \
1047 (((unsigned char *)(msg)) + msg->status_buf_offset)
1049 /* get pointer to OOBD buffer with message pointer */
1050 #define MESSAGE_TO_OOBD_BUFFER(msg) \
1051 (((unsigned char *)(msg)) + msg->oob_data_offset)
1053 /* get pointer to data buffer with message pointer */
1054 #define MESSAGE_TO_DATA_BUFFER(msg) \
1055 (((unsigned char *)(msg)) + msg->per_pkt_info_offset)
1057 /* get pointer to contained message from NDIS_MESSAGE pointer */
1058 #define RNDIS_MESSAGE_PTR_TO_MESSAGE_PTR(rndis_msg) \
1059 ((void *) &rndis_msg->msg)
1061 /* get pointer to contained message from NDIS_MESSAGE pointer */
1062 #define RNDIS_MESSAGE_RAW_PTR_TO_MESSAGE_PTR(rndis_msg) \
1063 ((void *) rndis_msg)
1066 #define __struct_bcount(x)
1070 #define RNDIS_HEADER_SIZE (sizeof(struct rndis_message) - \
1071 sizeof(union rndis_message_container))
1073 #define NDIS_PACKET_TYPE_DIRECTED 0x00000001
1074 #define NDIS_PACKET_TYPE_MULTICAST 0x00000002
1075 #define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004
1076 #define NDIS_PACKET_TYPE_BROADCAST 0x00000008
1077 #define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010
1078 #define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020
1079 #define NDIS_PACKET_TYPE_SMT 0x00000040
1080 #define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080
1081 #define NDIS_PACKET_TYPE_GROUP 0x00000100
1082 #define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00000200
1083 #define NDIS_PACKET_TYPE_FUNCTIONAL 0x00000400
1084 #define NDIS_PACKET_TYPE_MAC_FRAME 0x00000800
1089 extern int rndis_filter_init(struct netvsc_driver
*driver
);
1091 #endif /* _HYPERV_NET_H */