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>
29 #include <linux/hyperv.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 */
43 * Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame
46 struct hv_netvsc_packet {
47 /* Bookkeeping stuff */
48 struct list_head list_ent;
50 struct hv_device *device;
55 * Valid only for receives when we break a xfer page packet
56 * into multiple netvsc packets
58 struct xferpage_packet *xfer_page_pkt;
62 u64 recv_completion_tid;
63 void *recv_completion_ctx;
64 void (*recv_completion)(void *context);
67 u64 send_completion_tid;
68 void *send_completion_ctx;
69 void (*send_completion)(void *context);
73 /* This points to the memory after page_buf */
76 u32 total_data_buflen;
77 /* Points to the send/receive buffer where the ethernet frame is */
80 struct hv_page_buffer page_buf[0];
83 struct netvsc_device_info {
84 unsigned char mac_adr[6];
85 bool link_state; /* 0 - link up, 1 - link down */
89 enum rndis_device_state {
90 RNDIS_DEV_UNINITIALIZED = 0,
91 RNDIS_DEV_INITIALIZING,
92 RNDIS_DEV_INITIALIZED,
93 RNDIS_DEV_DATAINITIALIZED,
97 struct netvsc_device *net_dev;
99 enum rndis_device_state state;
103 spinlock_t request_lock;
104 struct list_head req_list;
106 unsigned char hw_mac_adr[ETH_ALEN];
111 int netvsc_device_add(struct hv_device *device, void *additional_info);
112 int netvsc_device_remove(struct hv_device *device);
113 int netvsc_send(struct hv_device *device,
114 struct hv_netvsc_packet *packet);
115 void netvsc_linkstatus_callback(struct hv_device *device_obj,
116 unsigned int status);
117 int netvsc_recv_callback(struct hv_device *device_obj,
118 struct hv_netvsc_packet *packet);
119 int rndis_filter_open(struct hv_device *dev);
120 int rndis_filter_close(struct hv_device *dev);
121 int rndis_filter_device_add(struct hv_device *dev,
122 void *additional_info);
123 void rndis_filter_device_remove(struct hv_device *dev);
124 int rndis_filter_receive(struct hv_device *dev,
125 struct hv_netvsc_packet *pkt);
129 int rndis_filter_send(struct hv_device *dev,
130 struct hv_netvsc_packet *pkt);
132 int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter);
135 #define NVSP_INVALID_PROTOCOL_VERSION ((u32)0xFFFFFFFF)
137 #define NVSP_PROTOCOL_VERSION_1 2
138 #define NVSP_PROTOCOL_VERSION_2 0x30002
141 NVSP_MSG_TYPE_NONE = 0,
144 NVSP_MSG_TYPE_INIT = 1,
145 NVSP_MSG_TYPE_INIT_COMPLETE = 2,
147 NVSP_VERSION_MSG_START = 100,
149 /* Version 1 Messages */
150 NVSP_MSG1_TYPE_SEND_NDIS_VER = NVSP_VERSION_MSG_START,
152 NVSP_MSG1_TYPE_SEND_RECV_BUF,
153 NVSP_MSG1_TYPE_SEND_RECV_BUF_COMPLETE,
154 NVSP_MSG1_TYPE_REVOKE_RECV_BUF,
156 NVSP_MSG1_TYPE_SEND_SEND_BUF,
157 NVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE,
158 NVSP_MSG1_TYPE_REVOKE_SEND_BUF,
160 NVSP_MSG1_TYPE_SEND_RNDIS_PKT,
161 NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE,
163 /* Version 2 messages */
164 NVSP_MSG2_TYPE_SEND_CHIMNEY_DELEGATED_BUF,
165 NVSP_MSG2_TYPE_SEND_CHIMNEY_DELEGATED_BUF_COMP,
166 NVSP_MSG2_TYPE_REVOKE_CHIMNEY_DELEGATED_BUF,
168 NVSP_MSG2_TYPE_RESUME_CHIMNEY_RX_INDICATION,
170 NVSP_MSG2_TYPE_TERMINATE_CHIMNEY,
171 NVSP_MSG2_TYPE_TERMINATE_CHIMNEY_COMP,
173 NVSP_MSG2_TYPE_INDICATE_CHIMNEY_EVENT,
175 NVSP_MSG2_TYPE_SEND_CHIMNEY_PKT,
176 NVSP_MSG2_TYPE_SEND_CHIMNEY_PKT_COMP,
178 NVSP_MSG2_TYPE_POST_CHIMNEY_RECV_REQ,
179 NVSP_MSG2_TYPE_POST_CHIMNEY_RECV_REQ_COMP,
181 NVSP_MSG2_TYPE_ALLOC_RXBUF,
182 NVSP_MSG2_TYPE_ALLOC_RXBUF_COMP,
184 NVSP_MSG2_TYPE_FREE_RXBUF,
186 NVSP_MSG2_TYPE_SEND_VMQ_RNDIS_PKT,
187 NVSP_MSG2_TYPE_SEND_VMQ_RNDIS_PKT_COMP,
189 NVSP_MSG2_TYPE_SEND_NDIS_CONFIG,
191 NVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE,
192 NVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE_COMP,
199 NVSP_STAT_PROTOCOL_TOO_NEW,
200 NVSP_STAT_PROTOCOL_TOO_OLD,
201 NVSP_STAT_INVALID_RNDIS_PKT,
203 NVSP_STAT_PROTOCOL_UNSUPPORTED,
207 struct nvsp_message_header {
214 * This message is used by the VSC to initialize the channel after the channels
215 * has been opened. This message should never include anything other then
216 * versioning (i.e. this message will be the same for ever).
218 struct nvsp_message_init {
219 u32 min_protocol_ver;
220 u32 max_protocol_ver;
224 * This message is used by the VSP to complete the initialization of the
225 * channel. This message should never include anything other then versioning
226 * (i.e. this message will be the same for ever).
228 struct nvsp_message_init_complete {
229 u32 negotiated_protocol_ver;
230 u32 max_mdl_chain_len;
234 union nvsp_message_init_uber {
235 struct nvsp_message_init init;
236 struct nvsp_message_init_complete init_complete;
239 /* Version 1 Messages */
242 * This message is used by the VSC to send the NDIS version to the VSP. The VSP
243 * can use this information when handling OIDs sent by the VSC.
245 struct nvsp_1_message_send_ndis_version {
251 * This message is used by the VSC to send a receive buffer to the VSP. The VSP
252 * can then use the receive buffer to send data to the VSC.
254 struct nvsp_1_message_send_receive_buffer {
259 struct nvsp_1_receive_buffer_section {
267 * This message is used by the VSP to acknowledge a receive buffer send by the
268 * VSC. This message must be sent by the VSP before the VSP uses the receive
271 struct nvsp_1_message_send_receive_buffer_complete {
276 * The receive buffer is split into two parts, a large suballocation
277 * section and a small suballocation section. These sections are then
278 * suballocated by a certain size.
282 * For example, the following break up of the receive buffer has 6
283 * large suballocations and 10 small suballocations.
287 * | Large Section | | Small Section |
288 * ------------------------------------------------------------
289 * | | | | | | | | | | | | | | | | | |
291 * LargeOffset SmallOffset
294 struct nvsp_1_receive_buffer_section sections[1];
298 * This message is sent by the VSC to revoke the receive buffer. After the VSP
299 * completes this transaction, the vsp should never use the receive buffer
302 struct nvsp_1_message_revoke_receive_buffer {
307 * This message is used by the VSC to send a send buffer to the VSP. The VSC
308 * can then use the send buffer to send data to the VSP.
310 struct nvsp_1_message_send_send_buffer {
316 * This message is used by the VSP to acknowledge a send buffer sent by the
317 * VSC. This message must be sent by the VSP before the VSP uses the sent
320 struct nvsp_1_message_send_send_buffer_complete {
324 * The VSC gets to choose the size of the send buffer and the VSP gets
325 * to choose the sections size of the buffer. This was done to enable
326 * dynamic reconfigurations when the cost of GPA-direct buffers
333 * This message is sent by the VSC to revoke the send buffer. After the VSP
334 * completes this transaction, the vsp should never use the send buffer again.
336 struct nvsp_1_message_revoke_send_buffer {
341 * This message is used by both the VSP and the VSC to send a RNDIS message to
342 * the opposite channel endpoint.
344 struct nvsp_1_message_send_rndis_packet {
346 * This field is specified by RNIDS. They assume there's two different
347 * channels of communication. However, the Network VSP only has one.
348 * Therefore, the channel travels with the RNDIS packet.
353 * This field is used to send part or all of the data through a send
354 * buffer. This values specifies an index into the send buffer. If the
355 * index is 0xFFFFFFFF, then the send buffer is not being used and all
356 * of the data was sent through other VMBus mechanisms.
358 u32 send_buf_section_index;
359 u32 send_buf_section_size;
363 * This message is used by both the VSP and the VSC to complete a RNDIS message
364 * to the opposite channel endpoint. At this point, the initiator of this
365 * message cannot use any resources associated with the original RNDIS packet.
367 struct nvsp_1_message_send_rndis_packet_complete {
371 union nvsp_1_message_uber {
372 struct nvsp_1_message_send_ndis_version send_ndis_ver;
374 struct nvsp_1_message_send_receive_buffer send_recv_buf;
375 struct nvsp_1_message_send_receive_buffer_complete
376 send_recv_buf_complete;
377 struct nvsp_1_message_revoke_receive_buffer revoke_recv_buf;
379 struct nvsp_1_message_send_send_buffer send_send_buf;
380 struct nvsp_1_message_send_send_buffer_complete send_send_buf_complete;
381 struct nvsp_1_message_revoke_send_buffer revoke_send_buf;
383 struct nvsp_1_message_send_rndis_packet send_rndis_pkt;
384 struct nvsp_1_message_send_rndis_packet_complete
385 send_rndis_pkt_complete;
390 * Network VSP protocol version 2 messages:
392 struct nvsp_2_vsc_capability {
400 u64 correlation_id:1;
405 struct nvsp_2_send_ndis_config {
408 struct nvsp_2_vsc_capability capability;
411 /* Allocate receive buffer */
412 struct nvsp_2_alloc_rxbuf {
413 /* Allocation ID to match the allocation request and response */
416 /* Length of the VM shared memory receive buffer that needs to
422 /* Allocate receive buffer complete */
423 struct nvsp_2_alloc_rxbuf_comp {
424 /* The NDIS_STATUS code for buffer allocation */
429 /* GPADL handle for the allocated receive buffer */
432 /* Receive buffer ID */
436 struct nvsp_2_free_rxbuf {
440 union nvsp_2_message_uber {
441 struct nvsp_2_send_ndis_config send_ndis_config;
442 struct nvsp_2_alloc_rxbuf alloc_rxbuf;
443 struct nvsp_2_alloc_rxbuf_comp alloc_rxbuf_comp;
444 struct nvsp_2_free_rxbuf free_rxbuf;
447 union nvsp_all_messages {
448 union nvsp_message_init_uber init_msg;
449 union nvsp_1_message_uber v1_msg;
450 union nvsp_2_message_uber v2_msg;
454 struct nvsp_message {
455 struct nvsp_message_header hdr;
456 union nvsp_all_messages msg;
460 #define NETVSC_MTU 65536
462 #define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024*2) /* 2MB */
464 #define NETVSC_RECEIVE_BUFFER_ID 0xcafe
466 #define NETVSC_RECEIVE_SG_COUNT 1
468 /* Preallocated receive packets */
469 #define NETVSC_RECEIVE_PACKETLIST_COUNT 256
471 #define NETVSC_PACKET_SIZE 2048
473 /* Per netvsc channel-specific */
474 struct netvsc_device {
475 struct hv_device *dev;
479 atomic_t num_outstanding_sends;
483 * List of free preallocated hv_netvsc_packet to represent receive
486 struct list_head recv_pkt_list;
487 spinlock_t recv_pkt_list_lock;
489 /* Receive buffer allocated by us but manages by NetVSP */
492 u32 recv_buf_gpadl_handle;
493 u32 recv_section_cnt;
494 struct nvsp_1_receive_buffer_section *recv_section;
496 /* Used for NetVSP initialization protocol */
497 struct completion channel_init_wait;
498 struct nvsp_message channel_init_pkt;
500 struct nvsp_message revoke_packet;
501 /* unsigned char HwMacAddr[HW_MACADDR_LEN]; */
503 struct net_device *ndev;
505 /* Holds rndis device info */
513 #ifndef STATUS_SUCCESS
514 #define STATUS_SUCCESS (0x00000000L)
517 #ifndef STATUS_UNSUCCESSFUL
518 #define STATUS_UNSUCCESSFUL (0xC0000001L)
521 #ifndef STATUS_PENDING
522 #define STATUS_PENDING (0x00000103L)
525 #ifndef STATUS_INSUFFICIENT_RESOURCES
526 #define STATUS_INSUFFICIENT_RESOURCES (0xC000009AL)
529 #ifndef STATUS_BUFFER_OVERFLOW
530 #define STATUS_BUFFER_OVERFLOW (0x80000005L)
533 #ifndef STATUS_NOT_SUPPORTED
534 #define STATUS_NOT_SUPPORTED (0xC00000BBL)
537 #define RNDIS_STATUS_SUCCESS (STATUS_SUCCESS)
538 #define RNDIS_STATUS_PENDING (STATUS_PENDING)
539 #define RNDIS_STATUS_NOT_RECOGNIZED (0x00010001L)
540 #define RNDIS_STATUS_NOT_COPIED (0x00010002L)
541 #define RNDIS_STATUS_NOT_ACCEPTED (0x00010003L)
542 #define RNDIS_STATUS_CALL_ACTIVE (0x00010007L)
544 #define RNDIS_STATUS_ONLINE (0x40010003L)
545 #define RNDIS_STATUS_RESET_START (0x40010004L)
546 #define RNDIS_STATUS_RESET_END (0x40010005L)
547 #define RNDIS_STATUS_RING_STATUS (0x40010006L)
548 #define RNDIS_STATUS_CLOSED (0x40010007L)
549 #define RNDIS_STATUS_WAN_LINE_UP (0x40010008L)
550 #define RNDIS_STATUS_WAN_LINE_DOWN (0x40010009L)
551 #define RNDIS_STATUS_WAN_FRAGMENT (0x4001000AL)
552 #define RNDIS_STATUS_MEDIA_CONNECT (0x4001000BL)
553 #define RNDIS_STATUS_MEDIA_DISCONNECT (0x4001000CL)
554 #define RNDIS_STATUS_HARDWARE_LINE_UP (0x4001000DL)
555 #define RNDIS_STATUS_HARDWARE_LINE_DOWN (0x4001000EL)
556 #define RNDIS_STATUS_INTERFACE_UP (0x4001000FL)
557 #define RNDIS_STATUS_INTERFACE_DOWN (0x40010010L)
558 #define RNDIS_STATUS_MEDIA_BUSY (0x40010011L)
559 #define RNDIS_STATUS_MEDIA_SPECIFIC_INDICATION (0x40010012L)
560 #define RNDIS_STATUS_WW_INDICATION RDIA_SPECIFIC_INDICATION
561 #define RNDIS_STATUS_LINK_SPEED_CHANGE (0x40010013L)
563 #define RNDIS_STATUS_NOT_RESETTABLE (0x80010001L)
564 #define RNDIS_STATUS_SOFT_ERRORS (0x80010003L)
565 #define RNDIS_STATUS_HARD_ERRORS (0x80010004L)
566 #define RNDIS_STATUS_BUFFER_OVERFLOW (STATUS_BUFFER_OVERFLOW)
568 #define RNDIS_STATUS_FAILURE (STATUS_UNSUCCESSFUL)
569 #define RNDIS_STATUS_RESOURCES (STATUS_INSUFFICIENT_RESOURCES)
570 #define RNDIS_STATUS_CLOSING (0xC0010002L)
571 #define RNDIS_STATUS_BAD_VERSION (0xC0010004L)
572 #define RNDIS_STATUS_BAD_CHARACTERISTICS (0xC0010005L)
573 #define RNDIS_STATUS_ADAPTER_NOT_FOUND (0xC0010006L)
574 #define RNDIS_STATUS_OPEN_FAILED (0xC0010007L)
575 #define RNDIS_STATUS_DEVICE_FAILED (0xC0010008L)
576 #define RNDIS_STATUS_MULTICAST_FULL (0xC0010009L)
577 #define RNDIS_STATUS_MULTICAST_EXISTS (0xC001000AL)
578 #define RNDIS_STATUS_MULTICAST_NOT_FOUND (0xC001000BL)
579 #define RNDIS_STATUS_REQUEST_ABORTED (0xC001000CL)
580 #define RNDIS_STATUS_RESET_IN_PROGRESS (0xC001000DL)
581 #define RNDIS_STATUS_CLOSING_INDICATING (0xC001000EL)
582 #define RNDIS_STATUS_NOT_SUPPORTED (STATUS_NOT_SUPPORTED)
583 #define RNDIS_STATUS_INVALID_PACKET (0xC001000FL)
584 #define RNDIS_STATUS_OPEN_LIST_FULL (0xC0010010L)
585 #define RNDIS_STATUS_ADAPTER_NOT_READY (0xC0010011L)
586 #define RNDIS_STATUS_ADAPTER_NOT_OPEN (0xC0010012L)
587 #define RNDIS_STATUS_NOT_INDICATING (0xC0010013L)
588 #define RNDIS_STATUS_INVALID_LENGTH (0xC0010014L)
589 #define RNDIS_STATUS_INVALID_DATA (0xC0010015L)
590 #define RNDIS_STATUS_BUFFER_TOO_SHORT (0xC0010016L)
591 #define RNDIS_STATUS_INVALID_OID (0xC0010017L)
592 #define RNDIS_STATUS_ADAPTER_REMOVED (0xC0010018L)
593 #define RNDIS_STATUS_UNSUPPORTED_MEDIA (0xC0010019L)
594 #define RNDIS_STATUS_GROUP_ADDRESS_IN_USE (0xC001001AL)
595 #define RNDIS_STATUS_FILE_NOT_FOUND (0xC001001BL)
596 #define RNDIS_STATUS_ERROR_READING_FILE (0xC001001CL)
597 #define RNDIS_STATUS_ALREADY_MAPPED (0xC001001DL)
598 #define RNDIS_STATUS_RESOURCE_CONFLICT (0xC001001EL)
599 #define RNDIS_STATUS_NO_CABLE (0xC001001FL)
601 #define RNDIS_STATUS_INVALID_SAP (0xC0010020L)
602 #define RNDIS_STATUS_SAP_IN_USE (0xC0010021L)
603 #define RNDIS_STATUS_INVALID_ADDRESS (0xC0010022L)
604 #define RNDIS_STATUS_VC_NOT_ACTIVATED (0xC0010023L)
605 #define RNDIS_STATUS_DEST_OUT_OF_ORDER (0xC0010024L)
606 #define RNDIS_STATUS_VC_NOT_AVAILABLE (0xC0010025L)
607 #define RNDIS_STATUS_CELLRATE_NOT_AVAILABLE (0xC0010026L)
608 #define RNDIS_STATUS_INCOMPATABLE_QOS (0xC0010027L)
609 #define RNDIS_STATUS_AAL_PARAMS_UNSUPPORTED (0xC0010028L)
610 #define RNDIS_STATUS_NO_ROUTE_TO_DESTINATION (0xC0010029L)
612 #define RNDIS_STATUS_TOKEN_RING_OPEN_ERROR (0xC0011000L)
614 /* Object Identifiers used by NdisRequest Query/Set Information */
615 /* General Objects */
616 #define RNDIS_OID_GEN_SUPPORTED_LIST 0x00010101
617 #define RNDIS_OID_GEN_HARDWARE_STATUS 0x00010102
618 #define RNDIS_OID_GEN_MEDIA_SUPPORTED 0x00010103
619 #define RNDIS_OID_GEN_MEDIA_IN_USE 0x00010104
620 #define RNDIS_OID_GEN_MAXIMUM_LOOKAHEAD 0x00010105
621 #define RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106
622 #define RNDIS_OID_GEN_LINK_SPEED 0x00010107
623 #define RNDIS_OID_GEN_TRANSMIT_BUFFER_SPACE 0x00010108
624 #define RNDIS_OID_GEN_RECEIVE_BUFFER_SPACE 0x00010109
625 #define RNDIS_OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010A
626 #define RNDIS_OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010B
627 #define RNDIS_OID_GEN_VENDOR_ID 0x0001010C
628 #define RNDIS_OID_GEN_VENDOR_DESCRIPTION 0x0001010D
629 #define RNDIS_OID_GEN_CURRENT_PACKET_FILTER 0x0001010E
630 #define RNDIS_OID_GEN_CURRENT_LOOKAHEAD 0x0001010F
631 #define RNDIS_OID_GEN_DRIVER_VERSION 0x00010110
632 #define RNDIS_OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111
633 #define RNDIS_OID_GEN_PROTOCOL_OPTIONS 0x00010112
634 #define RNDIS_OID_GEN_MAC_OPTIONS 0x00010113
635 #define RNDIS_OID_GEN_MEDIA_CONNECT_STATUS 0x00010114
636 #define RNDIS_OID_GEN_MAXIMUM_SEND_PACKETS 0x00010115
637 #define RNDIS_OID_GEN_VENDOR_DRIVER_VERSION 0x00010116
638 #define RNDIS_OID_GEN_NETWORK_LAYER_ADDRESSES 0x00010118
639 #define RNDIS_OID_GEN_TRANSPORT_HEADER_OFFSET 0x00010119
640 #define RNDIS_OID_GEN_MACHINE_NAME 0x0001021A
641 #define RNDIS_OID_GEN_RNDIS_CONFIG_PARAMETER 0x0001021B
643 #define RNDIS_OID_GEN_XMIT_OK 0x00020101
644 #define RNDIS_OID_GEN_RCV_OK 0x00020102
645 #define RNDIS_OID_GEN_XMIT_ERROR 0x00020103
646 #define RNDIS_OID_GEN_RCV_ERROR 0x00020104
647 #define RNDIS_OID_GEN_RCV_NO_BUFFER 0x00020105
649 #define RNDIS_OID_GEN_DIRECTED_BYTES_XMIT 0x00020201
650 #define RNDIS_OID_GEN_DIRECTED_FRAMES_XMIT 0x00020202
651 #define RNDIS_OID_GEN_MULTICAST_BYTES_XMIT 0x00020203
652 #define RNDIS_OID_GEN_MULTICAST_FRAMES_XMIT 0x00020204
653 #define RNDIS_OID_GEN_BROADCAST_BYTES_XMIT 0x00020205
654 #define RNDIS_OID_GEN_BROADCAST_FRAMES_XMIT 0x00020206
655 #define RNDIS_OID_GEN_DIRECTED_BYTES_RCV 0x00020207
656 #define RNDIS_OID_GEN_DIRECTED_FRAMES_RCV 0x00020208
657 #define RNDIS_OID_GEN_MULTICAST_BYTES_RCV 0x00020209
658 #define RNDIS_OID_GEN_MULTICAST_FRAMES_RCV 0x0002020A
659 #define RNDIS_OID_GEN_BROADCAST_BYTES_RCV 0x0002020B
660 #define RNDIS_OID_GEN_BROADCAST_FRAMES_RCV 0x0002020C
662 #define RNDIS_OID_GEN_RCV_CRC_ERROR 0x0002020D
663 #define RNDIS_OID_GEN_TRANSMIT_QUEUE_LENGTH 0x0002020E
665 #define RNDIS_OID_GEN_GET_TIME_CAPS 0x0002020F
666 #define RNDIS_OID_GEN_GET_NETCARD_TIME 0x00020210
668 /* These are connection-oriented general OIDs. */
669 /* These replace the above OIDs for connection-oriented media. */
670 #define RNDIS_OID_GEN_CO_SUPPORTED_LIST 0x00010101
671 #define RNDIS_OID_GEN_CO_HARDWARE_STATUS 0x00010102
672 #define RNDIS_OID_GEN_CO_MEDIA_SUPPORTED 0x00010103
673 #define RNDIS_OID_GEN_CO_MEDIA_IN_USE 0x00010104
674 #define RNDIS_OID_GEN_CO_LINK_SPEED 0x00010105
675 #define RNDIS_OID_GEN_CO_VENDOR_ID 0x00010106
676 #define RNDIS_OID_GEN_CO_VENDOR_DESCRIPTION 0x00010107
677 #define RNDIS_OID_GEN_CO_DRIVER_VERSION 0x00010108
678 #define RNDIS_OID_GEN_CO_PROTOCOL_OPTIONS 0x00010109
679 #define RNDIS_OID_GEN_CO_MAC_OPTIONS 0x0001010A
680 #define RNDIS_OID_GEN_CO_MEDIA_CONNECT_STATUS 0x0001010B
681 #define RNDIS_OID_GEN_CO_VENDOR_DRIVER_VERSION 0x0001010C
682 #define RNDIS_OID_GEN_CO_MINIMUM_LINK_SPEED 0x0001010D
684 #define RNDIS_OID_GEN_CO_GET_TIME_CAPS 0x00010201
685 #define RNDIS_OID_GEN_CO_GET_NETCARD_TIME 0x00010202
687 /* These are connection-oriented statistics OIDs. */
688 #define RNDIS_OID_GEN_CO_XMIT_PDUS_OK 0x00020101
689 #define RNDIS_OID_GEN_CO_RCV_PDUS_OK 0x00020102
690 #define RNDIS_OID_GEN_CO_XMIT_PDUS_ERROR 0x00020103
691 #define RNDIS_OID_GEN_CO_RCV_PDUS_ERROR 0x00020104
692 #define RNDIS_OID_GEN_CO_RCV_PDUS_NO_BUFFER 0x00020105
695 #define RNDIS_OID_GEN_CO_RCV_CRC_ERROR 0x00020201
696 #define RNDIS_OID_GEN_CO_TRANSMIT_QUEUE_LENGTH 0x00020202
697 #define RNDIS_OID_GEN_CO_BYTES_XMIT 0x00020203
698 #define RNDIS_OID_GEN_CO_BYTES_RCV 0x00020204
699 #define RNDIS_OID_GEN_CO_BYTES_XMIT_OUTSTANDING 0x00020205
700 #define RNDIS_OID_GEN_CO_NETCARD_LOAD 0x00020206
702 /* These are objects for Connection-oriented media call-managers. */
703 #define RNDIS_OID_CO_ADD_PVC 0xFF000001
704 #define RNDIS_OID_CO_DELETE_PVC 0xFF000002
705 #define RNDIS_OID_CO_GET_CALL_INFORMATION 0xFF000003
706 #define RNDIS_OID_CO_ADD_ADDRESS 0xFF000004
707 #define RNDIS_OID_CO_DELETE_ADDRESS 0xFF000005
708 #define RNDIS_OID_CO_GET_ADDRESSES 0xFF000006
709 #define RNDIS_OID_CO_ADDRESS_CHANGE 0xFF000007
710 #define RNDIS_OID_CO_SIGNALING_ENABLED 0xFF000008
711 #define RNDIS_OID_CO_SIGNALING_DISABLED 0xFF000009
713 /* 802.3 Objects (Ethernet) */
714 #define RNDIS_OID_802_3_PERMANENT_ADDRESS 0x01010101
715 #define RNDIS_OID_802_3_CURRENT_ADDRESS 0x01010102
716 #define RNDIS_OID_802_3_MULTICAST_LIST 0x01010103
717 #define RNDIS_OID_802_3_MAXIMUM_LIST_SIZE 0x01010104
718 #define RNDIS_OID_802_3_MAC_OPTIONS 0x01010105
720 #define NDIS_802_3_MAC_OPTION_PRIORITY 0x00000001
722 #define RNDIS_OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101
723 #define RNDIS_OID_802_3_XMIT_ONE_COLLISION 0x01020102
724 #define RNDIS_OID_802_3_XMIT_MORE_COLLISIONS 0x01020103
726 #define RNDIS_OID_802_3_XMIT_DEFERRED 0x01020201
727 #define RNDIS_OID_802_3_XMIT_MAX_COLLISIONS 0x01020202
728 #define RNDIS_OID_802_3_RCV_OVERRUN 0x01020203
729 #define RNDIS_OID_802_3_XMIT_UNDERRUN 0x01020204
730 #define RNDIS_OID_802_3_XMIT_HEARTBEAT_FAILURE 0x01020205
731 #define RNDIS_OID_802_3_XMIT_TIMES_CRS_LOST 0x01020206
732 #define RNDIS_OID_802_3_XMIT_LATE_COLLISIONS 0x01020207
734 /* Remote NDIS message types */
735 #define REMOTE_NDIS_PACKET_MSG 0x00000001
736 #define REMOTE_NDIS_INITIALIZE_MSG 0x00000002
737 #define REMOTE_NDIS_HALT_MSG 0x00000003
738 #define REMOTE_NDIS_QUERY_MSG 0x00000004
739 #define REMOTE_NDIS_SET_MSG 0x00000005
740 #define REMOTE_NDIS_RESET_MSG 0x00000006
741 #define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007
742 #define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008
744 #define REMOTE_CONDIS_MP_CREATE_VC_MSG 0x00008001
745 #define REMOTE_CONDIS_MP_DELETE_VC_MSG 0x00008002
746 #define REMOTE_CONDIS_MP_ACTIVATE_VC_MSG 0x00008005
747 #define REMOTE_CONDIS_MP_DEACTIVATE_VC_MSG 0x00008006
748 #define REMOTE_CONDIS_INDICATE_STATUS_MSG 0x00008007
750 /* Remote NDIS message completion types */
751 #define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002
752 #define REMOTE_NDIS_QUERY_CMPLT 0x80000004
753 #define REMOTE_NDIS_SET_CMPLT 0x80000005
754 #define REMOTE_NDIS_RESET_CMPLT 0x80000006
755 #define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008
757 #define REMOTE_CONDIS_MP_CREATE_VC_CMPLT 0x80008001
758 #define REMOTE_CONDIS_MP_DELETE_VC_CMPLT 0x80008002
759 #define REMOTE_CONDIS_MP_ACTIVATE_VC_CMPLT 0x80008005
760 #define REMOTE_CONDIS_MP_DEACTIVATE_VC_CMPLT 0x80008006
763 * Reserved message type for private communication between lower-layer host
764 * driver and remote device, if necessary.
766 #define REMOTE_NDIS_BUS_MSG 0xff000001
768 /* Defines for DeviceFlags in struct rndis_initialize_complete */
769 #define RNDIS_DF_CONNECTIONLESS 0x00000001
770 #define RNDIS_DF_CONNECTION_ORIENTED 0x00000002
771 #define RNDIS_DF_RAW_DATA 0x00000004
773 /* Remote NDIS medium types. */
774 #define RNDIS_MEDIUM_802_3 0x00000000
775 #define RNDIS_MEDIUM_802_5 0x00000001
776 #define RNDIS_MEDIUM_FDDI 0x00000002
777 #define RNDIS_MEDIUM_WAN 0x00000003
778 #define RNDIS_MEDIUM_LOCAL_TALK 0x00000004
779 #define RNDIS_MEDIUM_ARCNET_RAW 0x00000006
780 #define RNDIS_MEDIUM_ARCNET_878_2 0x00000007
781 #define RNDIS_MEDIUM_ATM 0x00000008
782 #define RNDIS_MEDIUM_WIRELESS_WAN 0x00000009
783 #define RNDIS_MEDIUM_IRDA 0x0000000a
784 #define RNDIS_MEDIUM_CO_WAN 0x0000000b
785 /* Not a real medium, defined as an upper-bound */
786 #define RNDIS_MEDIUM_MAX 0x0000000d
789 /* Remote NDIS medium connection states. */
790 #define RNDIS_MEDIA_STATE_CONNECTED 0x00000000
791 #define RNDIS_MEDIA_STATE_DISCONNECTED 0x00000001
793 /* Remote NDIS version numbers */
794 #define RNDIS_MAJOR_VERSION 0x00000001
795 #define RNDIS_MINOR_VERSION 0x00000000
798 /* NdisInitialize message */
799 struct rndis_initialize_request {
806 /* Response to NdisInitialize */
807 struct rndis_initialize_complete {
816 u32 pkt_alignment_factor;
821 /* Call manager devices only: Information about an address family */
822 /* supported by the device is appended to the response to NdisInitialize. */
823 struct rndis_co_address_family {
829 /* NdisHalt message */
830 struct rndis_halt_request {
834 /* NdisQueryRequest message */
835 struct rndis_query_request {
843 /* Response to NdisQueryRequest */
844 struct rndis_query_complete {
851 /* NdisSetRequest message */
852 struct rndis_set_request {
860 /* Response to NdisSetRequest */
861 struct rndis_set_complete {
866 /* NdisReset message */
867 struct rndis_reset_request {
871 /* Response to NdisReset */
872 struct rndis_reset_complete {
874 u32 addressing_reset;
877 /* NdisMIndicateStatus message */
878 struct rndis_indicate_status {
881 u32 status_buf_offset;
884 /* Diagnostic information passed as the status buffer in */
885 /* struct rndis_indicate_status messages signifying error conditions. */
886 struct rndis_diagnostic_info {
891 /* NdisKeepAlive message */
892 struct rndis_keepalive_request {
896 /* Response to NdisKeepAlive */
897 struct rndis_keepalive_complete {
903 * Data message. All Offset fields contain byte offsets from the beginning of
904 * struct rndis_packet. All Length fields are in bytes. VcHandle is set
905 * to 0 for connectionless data, otherwise it contains the VC handle.
907 struct rndis_packet {
912 u32 num_oob_data_elements;
913 u32 per_pkt_info_offset;
914 u32 per_pkt_info_len;
919 /* Optional Out of Band data associated with a Data message. */
923 u32 class_info_offset;
926 /* Packet extension field contents associated with a Data message. */
927 struct rndis_per_packet_info {
933 enum ndis_per_pkt_info_type {
934 TCPIP_CHKSUM_PKTINFO,
936 TCP_LARGESEND_PKTINFO,
937 CLASSIFICATION_HANDLE_PKTINFO,
943 ORIGINAL_NET_BUFLIST,
949 struct ndis_pkt_8021q_info {
952 u32 pri:3; /* User Priority */
953 u32 cfi:1; /* Canonical Format ID */
954 u32 vlanid:12; /* VLAN ID */
961 #define NDIS_VLAN_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \
962 sizeof(struct ndis_pkt_8021q_info))
964 /* Format of Information buffer passed in a SetRequest for the OID */
965 /* OID_GEN_RNDIS_CONFIG_PARAMETER. */
966 struct rndis_config_parameter_info {
967 u32 parameter_name_offset;
968 u32 parameter_name_length;
970 u32 parameter_value_offset;
971 u32 parameter_value_length;
974 /* Values for ParameterType in struct rndis_config_parameter_info */
975 #define RNDIS_CONFIG_PARAM_TYPE_INTEGER 0
976 #define RNDIS_CONFIG_PARAM_TYPE_STRING 2
978 /* CONDIS Miniport messages for connection oriented devices */
979 /* that do not implement a call manager. */
981 /* CoNdisMiniportCreateVc message */
982 struct rcondis_mp_create_vc {
987 /* Response to CoNdisMiniportCreateVc */
988 struct rcondis_mp_create_vc_complete {
994 /* CoNdisMiniportDeleteVc message */
995 struct rcondis_mp_delete_vc {
1000 /* Response to CoNdisMiniportDeleteVc */
1001 struct rcondis_mp_delete_vc_complete {
1006 /* CoNdisMiniportQueryRequest message */
1007 struct rcondis_mp_query_request {
1013 u32 info_buf_offset;
1016 /* CoNdisMiniportSetRequest message */
1017 struct rcondis_mp_set_request {
1023 u32 info_buf_offset;
1026 /* CoNdisIndicateStatus message */
1027 struct rcondis_indicate_status {
1031 u32 status_buf_offset;
1034 /* CONDIS Call/VC parameters */
1035 struct rcondis_specific_parameters {
1037 u32 parameter_length;
1038 u32 parameter_lffset;
1041 struct rcondis_media_parameters {
1045 struct rcondis_specific_parameters media_specific;
1048 struct rndis_flowspec {
1050 u32 token_bucket_size;
1053 u32 delay_variation;
1056 u32 minimum_policed_size;
1059 struct rcondis_call_manager_parameters {
1060 struct rndis_flowspec transmit;
1061 struct rndis_flowspec receive;
1062 struct rcondis_specific_parameters call_mgr_specific;
1065 /* CoNdisMiniportActivateVc message */
1066 struct rcondis_mp_activate_vc_request {
1070 u32 media_params_offset;
1071 u32 media_params_length;
1072 u32 call_mgr_params_offset;
1073 u32 call_mgr_params_length;
1076 /* Response to CoNdisMiniportActivateVc */
1077 struct rcondis_mp_activate_vc_complete {
1082 /* CoNdisMiniportDeactivateVc message */
1083 struct rcondis_mp_deactivate_vc_request {
1089 /* Response to CoNdisMiniportDeactivateVc */
1090 struct rcondis_mp_deactivate_vc_complete {
1096 /* union with all of the RNDIS messages */
1097 union rndis_message_container {
1098 struct rndis_packet pkt;
1099 struct rndis_initialize_request init_req;
1100 struct rndis_halt_request halt_req;
1101 struct rndis_query_request query_req;
1102 struct rndis_set_request set_req;
1103 struct rndis_reset_request reset_req;
1104 struct rndis_keepalive_request keep_alive_req;
1105 struct rndis_indicate_status indicate_status;
1106 struct rndis_initialize_complete init_complete;
1107 struct rndis_query_complete query_complete;
1108 struct rndis_set_complete set_complete;
1109 struct rndis_reset_complete reset_complete;
1110 struct rndis_keepalive_complete keep_alive_complete;
1111 struct rcondis_mp_create_vc co_miniport_create_vc;
1112 struct rcondis_mp_delete_vc co_miniport_delete_vc;
1113 struct rcondis_indicate_status co_indicate_status;
1114 struct rcondis_mp_activate_vc_request co_miniport_activate_vc;
1115 struct rcondis_mp_deactivate_vc_request co_miniport_deactivate_vc;
1116 struct rcondis_mp_create_vc_complete co_miniport_create_vc_complete;
1117 struct rcondis_mp_delete_vc_complete co_miniport_delete_vc_complete;
1118 struct rcondis_mp_activate_vc_complete co_miniport_activate_vc_complete;
1119 struct rcondis_mp_deactivate_vc_complete
1120 co_miniport_deactivate_vc_complete;
1123 /* Remote NDIS message format */
1124 struct rndis_message {
1127 /* Total length of this message, from the beginning */
1128 /* of the sruct rndis_message, in bytes. */
1131 /* Actual message */
1132 union rndis_message_container msg;
1136 struct rndis_filter_packet {
1137 void *completion_ctx;
1138 void (*completion)(void *context);
1139 struct rndis_message msg;
1144 /* get the size of an RNDIS message. Pass in the message type, */
1145 /* struct rndis_set_request, struct rndis_packet for example */
1146 #define RNDIS_MESSAGE_SIZE(msg) \
1147 (sizeof(msg) + (sizeof(struct rndis_message) - \
1148 sizeof(union rndis_message_container)))
1150 /* get pointer to info buffer with message pointer */
1151 #define MESSAGE_TO_INFO_BUFFER(msg) \
1152 (((unsigned char *)(msg)) + msg->info_buf_offset)
1154 /* get pointer to status buffer with message pointer */
1155 #define MESSAGE_TO_STATUS_BUFFER(msg) \
1156 (((unsigned char *)(msg)) + msg->status_buf_offset)
1158 /* get pointer to OOBD buffer with message pointer */
1159 #define MESSAGE_TO_OOBD_BUFFER(msg) \
1160 (((unsigned char *)(msg)) + msg->oob_data_offset)
1162 /* get pointer to data buffer with message pointer */
1163 #define MESSAGE_TO_DATA_BUFFER(msg) \
1164 (((unsigned char *)(msg)) + msg->per_pkt_info_offset)
1166 /* get pointer to contained message from NDIS_MESSAGE pointer */
1167 #define RNDIS_MESSAGE_PTR_TO_MESSAGE_PTR(rndis_msg) \
1168 ((void *) &rndis_msg->msg)
1170 /* get pointer to contained message from NDIS_MESSAGE pointer */
1171 #define RNDIS_MESSAGE_RAW_PTR_TO_MESSAGE_PTR(rndis_msg) \
1172 ((void *) rndis_msg)
1175 #define __struct_bcount(x)
1179 #define RNDIS_HEADER_SIZE (sizeof(struct rndis_message) - \
1180 sizeof(union rndis_message_container))
1182 #define NDIS_PACKET_TYPE_DIRECTED 0x00000001
1183 #define NDIS_PACKET_TYPE_MULTICAST 0x00000002
1184 #define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004
1185 #define NDIS_PACKET_TYPE_BROADCAST 0x00000008
1186 #define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010
1187 #define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020
1188 #define NDIS_PACKET_TYPE_SMT 0x00000040
1189 #define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080
1190 #define NDIS_PACKET_TYPE_GROUP 0x00000100
1191 #define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00000200
1192 #define NDIS_PACKET_TYPE_FUNCTIONAL 0x00000400
1193 #define NDIS_PACKET_TYPE_MAC_FRAME 0x00000800
1197 #endif /* _HYPERV_NET_H */