blob: 49b131f71d7a3d2d30f2cb621ef9c90f2e6c95df [file] [log] [blame]
K. Y. Srinivasan5ca72522011-05-12 19:34:37 -07001/*
2 *
3 * Copyright (c) 2011, Microsoft Corporation.
4 *
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.
8 *
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
12 * more details.
13 *
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.
17 *
18 * Authors:
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
21 * K. Y. Srinivasan <kys@microsoft.com>
22 *
23 */
24
25#ifndef _HYPERV_NET_H
26#define _HYPERV_NET_H
27
K. Y. Srinivasan8a079412011-05-12 19:34:42 -070028#include <linux/list.h>
Greg Kroah-Hartman46a97192011-10-04 12:29:52 -070029#include <linux/hyperv.h>
K. Y. Srinivasan41308862011-05-12 19:34:38 -070030
31/* Fwd declaration */
32struct hv_netvsc_packet;
33
34/* Represent the xfer page packet which contains 1 or more netvsc packet */
35struct xferpage_packet {
36 struct list_head list_ent;
37
38 /* # of netvsc packets this xfer packet contains */
39 u32 count;
40};
41
42/* The number of pages which are enough to cover jumbo frame buffer. */
43#define NETVSC_PACKET_MAXPAGE 4
44
45/*
46 * Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame
47 * within the RNDIS
48 */
49struct hv_netvsc_packet {
50 /* Bookkeeping stuff */
51 struct list_head list_ent;
52
53 struct hv_device *device;
54 bool is_data_pkt;
55
56 /*
57 * Valid only for receives when we break a xfer page packet
58 * into multiple netvsc packets
59 */
60 struct xferpage_packet *xfer_page_pkt;
61
62 union {
63 struct {
64 u64 recv_completion_tid;
65 void *recv_completion_ctx;
66 void (*recv_completion)(void *context);
67 } recv;
68 struct {
69 u64 send_completion_tid;
70 void *send_completion_ctx;
71 void (*send_completion)(void *context);
72 } send;
73 } completion;
74
75 /* This points to the memory after page_buf */
76 void *extension;
77
78 u32 total_data_buflen;
79 /* Points to the send/receive buffer where the ethernet frame is */
80 u32 page_buf_cnt;
81 struct hv_page_buffer page_buf[NETVSC_PACKET_MAXPAGE];
82};
83
K. Y. Srinivasan41308862011-05-12 19:34:38 -070084struct netvsc_device_info {
85 unsigned char mac_adr[6];
86 bool link_state; /* 0 - link up, 1 - link down */
K. Y. Srinivasan78001df2011-05-12 19:35:04 -070087 int ring_size;
K. Y. Srinivasan41308862011-05-12 19:34:38 -070088};
89
Haiyang Zhangd426b2e2011-11-30 07:19:08 -080090enum rndis_device_state {
91 RNDIS_DEV_UNINITIALIZED = 0,
92 RNDIS_DEV_INITIALIZING,
93 RNDIS_DEV_INITIALIZED,
94 RNDIS_DEV_DATAINITIALIZED,
95};
96
97struct rndis_device {
98 struct netvsc_device *net_dev;
99
100 enum rndis_device_state state;
101 bool link_state;
102 atomic_t new_req_id;
103
104 spinlock_t request_lock;
105 struct list_head req_list;
106
107 unsigned char hw_mac_adr[ETH_ALEN];
108};
109
110
K. Y. Srinivasan41308862011-05-12 19:34:38 -0700111/* Interface */
112int netvsc_device_add(struct hv_device *device, void *additional_info);
113int netvsc_device_remove(struct hv_device *device);
K. Y. Srinivasanf9819f02011-05-12 19:34:49 -0700114int netvsc_send(struct hv_device *device,
115 struct hv_netvsc_packet *packet);
K. Y. Srinivasan90ef1172011-05-12 19:34:50 -0700116void netvsc_linkstatus_callback(struct hv_device *device_obj,
117 unsigned int status);
K. Y. Srinivasanf79adf82011-05-12 19:34:51 -0700118int netvsc_recv_callback(struct hv_device *device_obj,
119 struct hv_netvsc_packet *packet);
K. Y. Srinivasan41308862011-05-12 19:34:38 -0700120int rndis_filter_open(struct hv_device *dev);
121int rndis_filter_close(struct hv_device *dev);
Haiyang Zhangbdbad572011-05-23 09:03:49 -0700122int rndis_filter_device_add(struct hv_device *dev,
K. Y. Srinivasan41308862011-05-12 19:34:38 -0700123 void *additional_info);
Haiyang Zhangdf06bcf2011-05-23 09:03:47 -0700124void rndis_filter_device_remove(struct hv_device *dev);
K. Y. Srinivasan5fcc4112011-05-12 19:34:52 -0700125int rndis_filter_receive(struct hv_device *dev,
126 struct hv_netvsc_packet *pkt);
K. Y. Srinivasan41308862011-05-12 19:34:38 -0700127
K. Y. Srinivasan52584902011-05-12 19:34:39 -0700128
K. Y. Srinivasan52584902011-05-12 19:34:39 -0700129
K. Y. Srinivasan0652aeb2011-05-12 19:34:53 -0700130int rndis_filter_send(struct hv_device *dev,
131 struct hv_netvsc_packet *pkt);
132
Haiyang Zhangd426b2e2011-11-30 07:19:08 -0800133int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter);
134
135
K. Y. Srinivasan52584902011-05-12 19:34:39 -0700136#define NVSP_INVALID_PROTOCOL_VERSION ((u32)0xFFFFFFFF)
137
138#define NVSP_PROTOCOL_VERSION_1 2
139#define NVSP_MIN_PROTOCOL_VERSION NVSP_PROTOCOL_VERSION_1
140#define NVSP_MAX_PROTOCOL_VERSION NVSP_PROTOCOL_VERSION_1
141
142enum {
143 NVSP_MSG_TYPE_NONE = 0,
144
145 /* Init Messages */
146 NVSP_MSG_TYPE_INIT = 1,
147 NVSP_MSG_TYPE_INIT_COMPLETE = 2,
148
149 NVSP_VERSION_MSG_START = 100,
150
151 /* Version 1 Messages */
152 NVSP_MSG1_TYPE_SEND_NDIS_VER = NVSP_VERSION_MSG_START,
153
154 NVSP_MSG1_TYPE_SEND_RECV_BUF,
155 NVSP_MSG1_TYPE_SEND_RECV_BUF_COMPLETE,
156 NVSP_MSG1_TYPE_REVOKE_RECV_BUF,
157
158 NVSP_MSG1_TYPE_SEND_SEND_BUF,
159 NVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE,
160 NVSP_MSG1_TYPE_REVOKE_SEND_BUF,
161
162 NVSP_MSG1_TYPE_SEND_RNDIS_PKT,
163 NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE,
164
165 /*
166 * This should be set to the number of messages for the version with
167 * the maximum number of messages.
168 */
169 NVSP_NUM_MSG_PER_VERSION = 9,
170};
171
172enum {
173 NVSP_STAT_NONE = 0,
174 NVSP_STAT_SUCCESS,
175 NVSP_STAT_FAIL,
176 NVSP_STAT_PROTOCOL_TOO_NEW,
177 NVSP_STAT_PROTOCOL_TOO_OLD,
178 NVSP_STAT_INVALID_RNDIS_PKT,
179 NVSP_STAT_BUSY,
180 NVSP_STAT_MAX,
181};
182
183struct nvsp_message_header {
184 u32 msg_type;
185};
186
187/* Init Messages */
188
189/*
190 * This message is used by the VSC to initialize the channel after the channels
191 * has been opened. This message should never include anything other then
192 * versioning (i.e. this message will be the same for ever).
193 */
194struct nvsp_message_init {
195 u32 min_protocol_ver;
196 u32 max_protocol_ver;
197} __packed;
198
199/*
200 * This message is used by the VSP to complete the initialization of the
201 * channel. This message should never include anything other then versioning
202 * (i.e. this message will be the same for ever).
203 */
204struct nvsp_message_init_complete {
205 u32 negotiated_protocol_ver;
206 u32 max_mdl_chain_len;
207 u32 status;
208} __packed;
209
210union nvsp_message_init_uber {
211 struct nvsp_message_init init;
212 struct nvsp_message_init_complete init_complete;
213} __packed;
214
215/* Version 1 Messages */
216
217/*
218 * This message is used by the VSC to send the NDIS version to the VSP. The VSP
219 * can use this information when handling OIDs sent by the VSC.
220 */
221struct nvsp_1_message_send_ndis_version {
222 u32 ndis_major_ver;
223 u32 ndis_minor_ver;
224} __packed;
225
226/*
227 * This message is used by the VSC to send a receive buffer to the VSP. The VSP
228 * can then use the receive buffer to send data to the VSC.
229 */
230struct nvsp_1_message_send_receive_buffer {
231 u32 gpadl_handle;
232 u16 id;
233} __packed;
234
235struct nvsp_1_receive_buffer_section {
236 u32 offset;
237 u32 sub_alloc_size;
238 u32 num_sub_allocs;
239 u32 end_offset;
240} __packed;
241
242/*
243 * This message is used by the VSP to acknowledge a receive buffer send by the
244 * VSC. This message must be sent by the VSP before the VSP uses the receive
245 * buffer.
246 */
247struct nvsp_1_message_send_receive_buffer_complete {
248 u32 status;
249 u32 num_sections;
250
251 /*
252 * The receive buffer is split into two parts, a large suballocation
253 * section and a small suballocation section. These sections are then
254 * suballocated by a certain size.
255 */
256
257 /*
258 * For example, the following break up of the receive buffer has 6
259 * large suballocations and 10 small suballocations.
260 */
261
262 /*
263 * | Large Section | | Small Section |
264 * ------------------------------------------------------------
265 * | | | | | | | | | | | | | | | | | |
266 * | |
267 * LargeOffset SmallOffset
268 */
269
270 struct nvsp_1_receive_buffer_section sections[1];
271} __packed;
272
273/*
274 * This message is sent by the VSC to revoke the receive buffer. After the VSP
275 * completes this transaction, the vsp should never use the receive buffer
276 * again.
277 */
278struct nvsp_1_message_revoke_receive_buffer {
279 u16 id;
280};
281
282/*
283 * This message is used by the VSC to send a send buffer to the VSP. The VSC
284 * can then use the send buffer to send data to the VSP.
285 */
286struct nvsp_1_message_send_send_buffer {
287 u32 gpadl_handle;
288 u16 id;
289} __packed;
290
291/*
292 * This message is used by the VSP to acknowledge a send buffer sent by the
293 * VSC. This message must be sent by the VSP before the VSP uses the sent
294 * buffer.
295 */
296struct nvsp_1_message_send_send_buffer_complete {
297 u32 status;
298
299 /*
300 * The VSC gets to choose the size of the send buffer and the VSP gets
301 * to choose the sections size of the buffer. This was done to enable
302 * dynamic reconfigurations when the cost of GPA-direct buffers
303 * decreases.
304 */
305 u32 section_size;
306} __packed;
307
308/*
309 * This message is sent by the VSC to revoke the send buffer. After the VSP
310 * completes this transaction, the vsp should never use the send buffer again.
311 */
312struct nvsp_1_message_revoke_send_buffer {
313 u16 id;
314};
315
316/*
317 * This message is used by both the VSP and the VSC to send a RNDIS message to
318 * the opposite channel endpoint.
319 */
320struct nvsp_1_message_send_rndis_packet {
321 /*
322 * This field is specified by RNIDS. They assume there's two different
323 * channels of communication. However, the Network VSP only has one.
324 * Therefore, the channel travels with the RNDIS packet.
325 */
326 u32 channel_type;
327
328 /*
329 * This field is used to send part or all of the data through a send
330 * buffer. This values specifies an index into the send buffer. If the
331 * index is 0xFFFFFFFF, then the send buffer is not being used and all
332 * of the data was sent through other VMBus mechanisms.
333 */
334 u32 send_buf_section_index;
335 u32 send_buf_section_size;
336} __packed;
337
338/*
339 * This message is used by both the VSP and the VSC to complete a RNDIS message
340 * to the opposite channel endpoint. At this point, the initiator of this
341 * message cannot use any resources associated with the original RNDIS packet.
342 */
343struct nvsp_1_message_send_rndis_packet_complete {
344 u32 status;
345};
346
347union nvsp_1_message_uber {
348 struct nvsp_1_message_send_ndis_version send_ndis_ver;
349
350 struct nvsp_1_message_send_receive_buffer send_recv_buf;
351 struct nvsp_1_message_send_receive_buffer_complete
352 send_recv_buf_complete;
353 struct nvsp_1_message_revoke_receive_buffer revoke_recv_buf;
354
355 struct nvsp_1_message_send_send_buffer send_send_buf;
356 struct nvsp_1_message_send_send_buffer_complete send_send_buf_complete;
357 struct nvsp_1_message_revoke_send_buffer revoke_send_buf;
358
359 struct nvsp_1_message_send_rndis_packet send_rndis_pkt;
360 struct nvsp_1_message_send_rndis_packet_complete
361 send_rndis_pkt_complete;
362} __packed;
363
364union nvsp_all_messages {
365 union nvsp_message_init_uber init_msg;
366 union nvsp_1_message_uber v1_msg;
367} __packed;
368
369/* ALL Messages */
370struct nvsp_message {
371 struct nvsp_message_header hdr;
372 union nvsp_all_messages msg;
373} __packed;
374
375
376
377
378/* #define NVSC_MIN_PROTOCOL_VERSION 1 */
379/* #define NVSC_MAX_PROTOCOL_VERSION 1 */
380
K. Y. Srinivasan52584902011-05-12 19:34:39 -0700381#define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024) /* 1MB */
382
383#define NETVSC_RECEIVE_BUFFER_ID 0xcafe
384
385#define NETVSC_RECEIVE_SG_COUNT 1
386
387/* Preallocated receive packets */
388#define NETVSC_RECEIVE_PACKETLIST_COUNT 256
389
390#define NETVSC_PACKET_SIZE 2048
391
392/* Per netvsc channel-specific */
393struct netvsc_device {
394 struct hv_device *dev;
395
K. Y. Srinivasan52584902011-05-12 19:34:39 -0700396 atomic_t num_outstanding_sends;
K. Y. Srinivasanc38b9c72011-08-27 11:31:12 -0700397 bool destroy;
K. Y. Srinivasan52584902011-05-12 19:34:39 -0700398 /*
399 * List of free preallocated hv_netvsc_packet to represent receive
400 * packet
401 */
402 struct list_head recv_pkt_list;
403 spinlock_t recv_pkt_list_lock;
404
K. Y. Srinivasan52584902011-05-12 19:34:39 -0700405 /* Receive buffer allocated by us but manages by NetVSP */
406 void *recv_buf;
407 u32 recv_buf_size;
408 u32 recv_buf_gpadl_handle;
409 u32 recv_section_cnt;
410 struct nvsp_1_receive_buffer_section *recv_section;
411
412 /* Used for NetVSP initialization protocol */
413 struct completion channel_init_wait;
414 struct nvsp_message channel_init_pkt;
415
416 struct nvsp_message revoke_packet;
417 /* unsigned char HwMacAddr[HW_MACADDR_LEN]; */
418
K. Y. Srinivasan2ddd5e5f2011-09-13 10:59:49 -0700419 struct net_device *ndev;
420
K. Y. Srinivasan52584902011-05-12 19:34:39 -0700421 /* Holds rndis device info */
422 void *extension;
423};
424
K. Y. Srinivasan4a5cea32011-05-12 19:34:40 -0700425
426/* Status codes */
427
428
429#ifndef STATUS_SUCCESS
430#define STATUS_SUCCESS (0x00000000L)
431#endif
432
433#ifndef STATUS_UNSUCCESSFUL
434#define STATUS_UNSUCCESSFUL (0xC0000001L)
435#endif
436
437#ifndef STATUS_PENDING
438#define STATUS_PENDING (0x00000103L)
439#endif
440
441#ifndef STATUS_INSUFFICIENT_RESOURCES
442#define STATUS_INSUFFICIENT_RESOURCES (0xC000009AL)
443#endif
444
445#ifndef STATUS_BUFFER_OVERFLOW
446#define STATUS_BUFFER_OVERFLOW (0x80000005L)
447#endif
448
449#ifndef STATUS_NOT_SUPPORTED
450#define STATUS_NOT_SUPPORTED (0xC00000BBL)
451#endif
452
453#define RNDIS_STATUS_SUCCESS (STATUS_SUCCESS)
454#define RNDIS_STATUS_PENDING (STATUS_PENDING)
455#define RNDIS_STATUS_NOT_RECOGNIZED (0x00010001L)
456#define RNDIS_STATUS_NOT_COPIED (0x00010002L)
457#define RNDIS_STATUS_NOT_ACCEPTED (0x00010003L)
458#define RNDIS_STATUS_CALL_ACTIVE (0x00010007L)
459
460#define RNDIS_STATUS_ONLINE (0x40010003L)
461#define RNDIS_STATUS_RESET_START (0x40010004L)
462#define RNDIS_STATUS_RESET_END (0x40010005L)
463#define RNDIS_STATUS_RING_STATUS (0x40010006L)
464#define RNDIS_STATUS_CLOSED (0x40010007L)
465#define RNDIS_STATUS_WAN_LINE_UP (0x40010008L)
466#define RNDIS_STATUS_WAN_LINE_DOWN (0x40010009L)
467#define RNDIS_STATUS_WAN_FRAGMENT (0x4001000AL)
468#define RNDIS_STATUS_MEDIA_CONNECT (0x4001000BL)
469#define RNDIS_STATUS_MEDIA_DISCONNECT (0x4001000CL)
470#define RNDIS_STATUS_HARDWARE_LINE_UP (0x4001000DL)
471#define RNDIS_STATUS_HARDWARE_LINE_DOWN (0x4001000EL)
472#define RNDIS_STATUS_INTERFACE_UP (0x4001000FL)
473#define RNDIS_STATUS_INTERFACE_DOWN (0x40010010L)
474#define RNDIS_STATUS_MEDIA_BUSY (0x40010011L)
475#define RNDIS_STATUS_MEDIA_SPECIFIC_INDICATION (0x40010012L)
476#define RNDIS_STATUS_WW_INDICATION RDIA_SPECIFIC_INDICATION
477#define RNDIS_STATUS_LINK_SPEED_CHANGE (0x40010013L)
478
479#define RNDIS_STATUS_NOT_RESETTABLE (0x80010001L)
480#define RNDIS_STATUS_SOFT_ERRORS (0x80010003L)
481#define RNDIS_STATUS_HARD_ERRORS (0x80010004L)
482#define RNDIS_STATUS_BUFFER_OVERFLOW (STATUS_BUFFER_OVERFLOW)
483
484#define RNDIS_STATUS_FAILURE (STATUS_UNSUCCESSFUL)
485#define RNDIS_STATUS_RESOURCES (STATUS_INSUFFICIENT_RESOURCES)
486#define RNDIS_STATUS_CLOSING (0xC0010002L)
487#define RNDIS_STATUS_BAD_VERSION (0xC0010004L)
488#define RNDIS_STATUS_BAD_CHARACTERISTICS (0xC0010005L)
489#define RNDIS_STATUS_ADAPTER_NOT_FOUND (0xC0010006L)
490#define RNDIS_STATUS_OPEN_FAILED (0xC0010007L)
491#define RNDIS_STATUS_DEVICE_FAILED (0xC0010008L)
492#define RNDIS_STATUS_MULTICAST_FULL (0xC0010009L)
493#define RNDIS_STATUS_MULTICAST_EXISTS (0xC001000AL)
494#define RNDIS_STATUS_MULTICAST_NOT_FOUND (0xC001000BL)
495#define RNDIS_STATUS_REQUEST_ABORTED (0xC001000CL)
496#define RNDIS_STATUS_RESET_IN_PROGRESS (0xC001000DL)
497#define RNDIS_STATUS_CLOSING_INDICATING (0xC001000EL)
498#define RNDIS_STATUS_NOT_SUPPORTED (STATUS_NOT_SUPPORTED)
499#define RNDIS_STATUS_INVALID_PACKET (0xC001000FL)
500#define RNDIS_STATUS_OPEN_LIST_FULL (0xC0010010L)
501#define RNDIS_STATUS_ADAPTER_NOT_READY (0xC0010011L)
502#define RNDIS_STATUS_ADAPTER_NOT_OPEN (0xC0010012L)
503#define RNDIS_STATUS_NOT_INDICATING (0xC0010013L)
504#define RNDIS_STATUS_INVALID_LENGTH (0xC0010014L)
505#define RNDIS_STATUS_INVALID_DATA (0xC0010015L)
506#define RNDIS_STATUS_BUFFER_TOO_SHORT (0xC0010016L)
507#define RNDIS_STATUS_INVALID_OID (0xC0010017L)
508#define RNDIS_STATUS_ADAPTER_REMOVED (0xC0010018L)
509#define RNDIS_STATUS_UNSUPPORTED_MEDIA (0xC0010019L)
510#define RNDIS_STATUS_GROUP_ADDRESS_IN_USE (0xC001001AL)
511#define RNDIS_STATUS_FILE_NOT_FOUND (0xC001001BL)
512#define RNDIS_STATUS_ERROR_READING_FILE (0xC001001CL)
513#define RNDIS_STATUS_ALREADY_MAPPED (0xC001001DL)
514#define RNDIS_STATUS_RESOURCE_CONFLICT (0xC001001EL)
515#define RNDIS_STATUS_NO_CABLE (0xC001001FL)
516
517#define RNDIS_STATUS_INVALID_SAP (0xC0010020L)
518#define RNDIS_STATUS_SAP_IN_USE (0xC0010021L)
519#define RNDIS_STATUS_INVALID_ADDRESS (0xC0010022L)
520#define RNDIS_STATUS_VC_NOT_ACTIVATED (0xC0010023L)
521#define RNDIS_STATUS_DEST_OUT_OF_ORDER (0xC0010024L)
522#define RNDIS_STATUS_VC_NOT_AVAILABLE (0xC0010025L)
523#define RNDIS_STATUS_CELLRATE_NOT_AVAILABLE (0xC0010026L)
524#define RNDIS_STATUS_INCOMPATABLE_QOS (0xC0010027L)
525#define RNDIS_STATUS_AAL_PARAMS_UNSUPPORTED (0xC0010028L)
526#define RNDIS_STATUS_NO_ROUTE_TO_DESTINATION (0xC0010029L)
527
528#define RNDIS_STATUS_TOKEN_RING_OPEN_ERROR (0xC0011000L)
529
530/* Object Identifiers used by NdisRequest Query/Set Information */
531/* General Objects */
532#define RNDIS_OID_GEN_SUPPORTED_LIST 0x00010101
533#define RNDIS_OID_GEN_HARDWARE_STATUS 0x00010102
534#define RNDIS_OID_GEN_MEDIA_SUPPORTED 0x00010103
535#define RNDIS_OID_GEN_MEDIA_IN_USE 0x00010104
536#define RNDIS_OID_GEN_MAXIMUM_LOOKAHEAD 0x00010105
537#define RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106
538#define RNDIS_OID_GEN_LINK_SPEED 0x00010107
539#define RNDIS_OID_GEN_TRANSMIT_BUFFER_SPACE 0x00010108
540#define RNDIS_OID_GEN_RECEIVE_BUFFER_SPACE 0x00010109
541#define RNDIS_OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010A
542#define RNDIS_OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010B
543#define RNDIS_OID_GEN_VENDOR_ID 0x0001010C
544#define RNDIS_OID_GEN_VENDOR_DESCRIPTION 0x0001010D
545#define RNDIS_OID_GEN_CURRENT_PACKET_FILTER 0x0001010E
546#define RNDIS_OID_GEN_CURRENT_LOOKAHEAD 0x0001010F
547#define RNDIS_OID_GEN_DRIVER_VERSION 0x00010110
548#define RNDIS_OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111
549#define RNDIS_OID_GEN_PROTOCOL_OPTIONS 0x00010112
550#define RNDIS_OID_GEN_MAC_OPTIONS 0x00010113
551#define RNDIS_OID_GEN_MEDIA_CONNECT_STATUS 0x00010114
552#define RNDIS_OID_GEN_MAXIMUM_SEND_PACKETS 0x00010115
553#define RNDIS_OID_GEN_VENDOR_DRIVER_VERSION 0x00010116
554#define RNDIS_OID_GEN_NETWORK_LAYER_ADDRESSES 0x00010118
555#define RNDIS_OID_GEN_TRANSPORT_HEADER_OFFSET 0x00010119
556#define RNDIS_OID_GEN_MACHINE_NAME 0x0001021A
557#define RNDIS_OID_GEN_RNDIS_CONFIG_PARAMETER 0x0001021B
558
559#define RNDIS_OID_GEN_XMIT_OK 0x00020101
560#define RNDIS_OID_GEN_RCV_OK 0x00020102
561#define RNDIS_OID_GEN_XMIT_ERROR 0x00020103
562#define RNDIS_OID_GEN_RCV_ERROR 0x00020104
563#define RNDIS_OID_GEN_RCV_NO_BUFFER 0x00020105
564
565#define RNDIS_OID_GEN_DIRECTED_BYTES_XMIT 0x00020201
566#define RNDIS_OID_GEN_DIRECTED_FRAMES_XMIT 0x00020202
567#define RNDIS_OID_GEN_MULTICAST_BYTES_XMIT 0x00020203
568#define RNDIS_OID_GEN_MULTICAST_FRAMES_XMIT 0x00020204
569#define RNDIS_OID_GEN_BROADCAST_BYTES_XMIT 0x00020205
570#define RNDIS_OID_GEN_BROADCAST_FRAMES_XMIT 0x00020206
571#define RNDIS_OID_GEN_DIRECTED_BYTES_RCV 0x00020207
572#define RNDIS_OID_GEN_DIRECTED_FRAMES_RCV 0x00020208
573#define RNDIS_OID_GEN_MULTICAST_BYTES_RCV 0x00020209
574#define RNDIS_OID_GEN_MULTICAST_FRAMES_RCV 0x0002020A
575#define RNDIS_OID_GEN_BROADCAST_BYTES_RCV 0x0002020B
576#define RNDIS_OID_GEN_BROADCAST_FRAMES_RCV 0x0002020C
577
578#define RNDIS_OID_GEN_RCV_CRC_ERROR 0x0002020D
579#define RNDIS_OID_GEN_TRANSMIT_QUEUE_LENGTH 0x0002020E
580
581#define RNDIS_OID_GEN_GET_TIME_CAPS 0x0002020F
582#define RNDIS_OID_GEN_GET_NETCARD_TIME 0x00020210
583
584/* These are connection-oriented general OIDs. */
585/* These replace the above OIDs for connection-oriented media. */
586#define RNDIS_OID_GEN_CO_SUPPORTED_LIST 0x00010101
587#define RNDIS_OID_GEN_CO_HARDWARE_STATUS 0x00010102
588#define RNDIS_OID_GEN_CO_MEDIA_SUPPORTED 0x00010103
589#define RNDIS_OID_GEN_CO_MEDIA_IN_USE 0x00010104
590#define RNDIS_OID_GEN_CO_LINK_SPEED 0x00010105
591#define RNDIS_OID_GEN_CO_VENDOR_ID 0x00010106
592#define RNDIS_OID_GEN_CO_VENDOR_DESCRIPTION 0x00010107
593#define RNDIS_OID_GEN_CO_DRIVER_VERSION 0x00010108
594#define RNDIS_OID_GEN_CO_PROTOCOL_OPTIONS 0x00010109
595#define RNDIS_OID_GEN_CO_MAC_OPTIONS 0x0001010A
596#define RNDIS_OID_GEN_CO_MEDIA_CONNECT_STATUS 0x0001010B
597#define RNDIS_OID_GEN_CO_VENDOR_DRIVER_VERSION 0x0001010C
598#define RNDIS_OID_GEN_CO_MINIMUM_LINK_SPEED 0x0001010D
599
600#define RNDIS_OID_GEN_CO_GET_TIME_CAPS 0x00010201
601#define RNDIS_OID_GEN_CO_GET_NETCARD_TIME 0x00010202
602
603/* These are connection-oriented statistics OIDs. */
604#define RNDIS_OID_GEN_CO_XMIT_PDUS_OK 0x00020101
605#define RNDIS_OID_GEN_CO_RCV_PDUS_OK 0x00020102
606#define RNDIS_OID_GEN_CO_XMIT_PDUS_ERROR 0x00020103
607#define RNDIS_OID_GEN_CO_RCV_PDUS_ERROR 0x00020104
608#define RNDIS_OID_GEN_CO_RCV_PDUS_NO_BUFFER 0x00020105
609
610
611#define RNDIS_OID_GEN_CO_RCV_CRC_ERROR 0x00020201
612#define RNDIS_OID_GEN_CO_TRANSMIT_QUEUE_LENGTH 0x00020202
613#define RNDIS_OID_GEN_CO_BYTES_XMIT 0x00020203
614#define RNDIS_OID_GEN_CO_BYTES_RCV 0x00020204
615#define RNDIS_OID_GEN_CO_BYTES_XMIT_OUTSTANDING 0x00020205
616#define RNDIS_OID_GEN_CO_NETCARD_LOAD 0x00020206
617
618/* These are objects for Connection-oriented media call-managers. */
619#define RNDIS_OID_CO_ADD_PVC 0xFF000001
620#define RNDIS_OID_CO_DELETE_PVC 0xFF000002
621#define RNDIS_OID_CO_GET_CALL_INFORMATION 0xFF000003
622#define RNDIS_OID_CO_ADD_ADDRESS 0xFF000004
623#define RNDIS_OID_CO_DELETE_ADDRESS 0xFF000005
624#define RNDIS_OID_CO_GET_ADDRESSES 0xFF000006
625#define RNDIS_OID_CO_ADDRESS_CHANGE 0xFF000007
626#define RNDIS_OID_CO_SIGNALING_ENABLED 0xFF000008
627#define RNDIS_OID_CO_SIGNALING_DISABLED 0xFF000009
628
629/* 802.3 Objects (Ethernet) */
630#define RNDIS_OID_802_3_PERMANENT_ADDRESS 0x01010101
631#define RNDIS_OID_802_3_CURRENT_ADDRESS 0x01010102
632#define RNDIS_OID_802_3_MULTICAST_LIST 0x01010103
633#define RNDIS_OID_802_3_MAXIMUM_LIST_SIZE 0x01010104
634#define RNDIS_OID_802_3_MAC_OPTIONS 0x01010105
635
636#define NDIS_802_3_MAC_OPTION_PRIORITY 0x00000001
637
638#define RNDIS_OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101
639#define RNDIS_OID_802_3_XMIT_ONE_COLLISION 0x01020102
640#define RNDIS_OID_802_3_XMIT_MORE_COLLISIONS 0x01020103
641
642#define RNDIS_OID_802_3_XMIT_DEFERRED 0x01020201
643#define RNDIS_OID_802_3_XMIT_MAX_COLLISIONS 0x01020202
644#define RNDIS_OID_802_3_RCV_OVERRUN 0x01020203
645#define RNDIS_OID_802_3_XMIT_UNDERRUN 0x01020204
646#define RNDIS_OID_802_3_XMIT_HEARTBEAT_FAILURE 0x01020205
647#define RNDIS_OID_802_3_XMIT_TIMES_CRS_LOST 0x01020206
648#define RNDIS_OID_802_3_XMIT_LATE_COLLISIONS 0x01020207
649
650/* Remote NDIS message types */
651#define REMOTE_NDIS_PACKET_MSG 0x00000001
652#define REMOTE_NDIS_INITIALIZE_MSG 0x00000002
653#define REMOTE_NDIS_HALT_MSG 0x00000003
654#define REMOTE_NDIS_QUERY_MSG 0x00000004
655#define REMOTE_NDIS_SET_MSG 0x00000005
656#define REMOTE_NDIS_RESET_MSG 0x00000006
657#define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007
658#define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008
659
660#define REMOTE_CONDIS_MP_CREATE_VC_MSG 0x00008001
661#define REMOTE_CONDIS_MP_DELETE_VC_MSG 0x00008002
662#define REMOTE_CONDIS_MP_ACTIVATE_VC_MSG 0x00008005
663#define REMOTE_CONDIS_MP_DEACTIVATE_VC_MSG 0x00008006
664#define REMOTE_CONDIS_INDICATE_STATUS_MSG 0x00008007
665
666/* Remote NDIS message completion types */
667#define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002
668#define REMOTE_NDIS_QUERY_CMPLT 0x80000004
669#define REMOTE_NDIS_SET_CMPLT 0x80000005
670#define REMOTE_NDIS_RESET_CMPLT 0x80000006
671#define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008
672
673#define REMOTE_CONDIS_MP_CREATE_VC_CMPLT 0x80008001
674#define REMOTE_CONDIS_MP_DELETE_VC_CMPLT 0x80008002
675#define REMOTE_CONDIS_MP_ACTIVATE_VC_CMPLT 0x80008005
676#define REMOTE_CONDIS_MP_DEACTIVATE_VC_CMPLT 0x80008006
677
678/*
679 * Reserved message type for private communication between lower-layer host
680 * driver and remote device, if necessary.
681 */
682#define REMOTE_NDIS_BUS_MSG 0xff000001
683
684/* Defines for DeviceFlags in struct rndis_initialize_complete */
685#define RNDIS_DF_CONNECTIONLESS 0x00000001
686#define RNDIS_DF_CONNECTION_ORIENTED 0x00000002
687#define RNDIS_DF_RAW_DATA 0x00000004
688
689/* Remote NDIS medium types. */
690#define RNDIS_MEDIUM_802_3 0x00000000
691#define RNDIS_MEDIUM_802_5 0x00000001
692#define RNDIS_MEDIUM_FDDI 0x00000002
693#define RNDIS_MEDIUM_WAN 0x00000003
694#define RNDIS_MEDIUM_LOCAL_TALK 0x00000004
695#define RNDIS_MEDIUM_ARCNET_RAW 0x00000006
696#define RNDIS_MEDIUM_ARCNET_878_2 0x00000007
697#define RNDIS_MEDIUM_ATM 0x00000008
698#define RNDIS_MEDIUM_WIRELESS_WAN 0x00000009
699#define RNDIS_MEDIUM_IRDA 0x0000000a
700#define RNDIS_MEDIUM_CO_WAN 0x0000000b
701/* Not a real medium, defined as an upper-bound */
702#define RNDIS_MEDIUM_MAX 0x0000000d
703
704
705/* Remote NDIS medium connection states. */
706#define RNDIS_MEDIA_STATE_CONNECTED 0x00000000
707#define RNDIS_MEDIA_STATE_DISCONNECTED 0x00000001
708
709/* Remote NDIS version numbers */
710#define RNDIS_MAJOR_VERSION 0x00000001
711#define RNDIS_MINOR_VERSION 0x00000000
712
713
714/* NdisInitialize message */
715struct rndis_initialize_request {
716 u32 req_id;
717 u32 major_ver;
718 u32 minor_ver;
719 u32 max_xfer_size;
720};
721
722/* Response to NdisInitialize */
723struct rndis_initialize_complete {
724 u32 req_id;
725 u32 status;
726 u32 major_ver;
727 u32 minor_ver;
728 u32 dev_flags;
729 u32 medium;
730 u32 max_pkt_per_msg;
731 u32 max_xfer_size;
732 u32 pkt_alignment_factor;
733 u32 af_list_offset;
734 u32 af_list_size;
735};
736
737/* Call manager devices only: Information about an address family */
738/* supported by the device is appended to the response to NdisInitialize. */
739struct rndis_co_address_family {
740 u32 address_family;
741 u32 major_ver;
742 u32 minor_ver;
743};
744
745/* NdisHalt message */
746struct rndis_halt_request {
747 u32 req_id;
748};
749
750/* NdisQueryRequest message */
751struct rndis_query_request {
752 u32 req_id;
753 u32 oid;
754 u32 info_buflen;
755 u32 info_buf_offset;
756 u32 dev_vc_handle;
757};
758
759/* Response to NdisQueryRequest */
760struct rndis_query_complete {
761 u32 req_id;
762 u32 status;
763 u32 info_buflen;
764 u32 info_buf_offset;
765};
766
767/* NdisSetRequest message */
768struct rndis_set_request {
769 u32 req_id;
770 u32 oid;
771 u32 info_buflen;
772 u32 info_buf_offset;
773 u32 dev_vc_handle;
774};
775
776/* Response to NdisSetRequest */
777struct rndis_set_complete {
778 u32 req_id;
779 u32 status;
780};
781
782/* NdisReset message */
783struct rndis_reset_request {
784 u32 reserved;
785};
786
787/* Response to NdisReset */
788struct rndis_reset_complete {
789 u32 status;
790 u32 addressing_reset;
791};
792
793/* NdisMIndicateStatus message */
794struct rndis_indicate_status {
795 u32 status;
796 u32 status_buflen;
797 u32 status_buf_offset;
798};
799
800/* Diagnostic information passed as the status buffer in */
801/* struct rndis_indicate_status messages signifying error conditions. */
802struct rndis_diagnostic_info {
803 u32 diag_status;
804 u32 error_offset;
805};
806
807/* NdisKeepAlive message */
808struct rndis_keepalive_request {
809 u32 req_id;
810};
811
812/* Response to NdisKeepAlive */
813struct rndis_keepalive_complete {
814 u32 req_id;
815 u32 status;
816};
817
818/*
819 * Data message. All Offset fields contain byte offsets from the beginning of
820 * struct rndis_packet. All Length fields are in bytes. VcHandle is set
821 * to 0 for connectionless data, otherwise it contains the VC handle.
822 */
823struct rndis_packet {
824 u32 data_offset;
825 u32 data_len;
826 u32 oob_data_offset;
827 u32 oob_data_len;
828 u32 num_oob_data_elements;
829 u32 per_pkt_info_offset;
830 u32 per_pkt_info_len;
831 u32 vc_handle;
832 u32 reserved;
833};
834
835/* Optional Out of Band data associated with a Data message. */
836struct rndis_oobd {
837 u32 size;
838 u32 type;
839 u32 class_info_offset;
840};
841
842/* Packet extension field contents associated with a Data message. */
843struct rndis_per_packet_info {
844 u32 size;
845 u32 type;
846 u32 per_pkt_info_offset;
847};
848
849/* Format of Information buffer passed in a SetRequest for the OID */
850/* OID_GEN_RNDIS_CONFIG_PARAMETER. */
851struct rndis_config_parameter_info {
852 u32 parameter_name_offset;
853 u32 parameter_name_length;
854 u32 parameter_type;
855 u32 parameter_value_offset;
856 u32 parameter_value_length;
857};
858
859/* Values for ParameterType in struct rndis_config_parameter_info */
860#define RNDIS_CONFIG_PARAM_TYPE_INTEGER 0
861#define RNDIS_CONFIG_PARAM_TYPE_STRING 2
862
863/* CONDIS Miniport messages for connection oriented devices */
864/* that do not implement a call manager. */
865
866/* CoNdisMiniportCreateVc message */
867struct rcondis_mp_create_vc {
868 u32 req_id;
869 u32 ndis_vc_handle;
870};
871
872/* Response to CoNdisMiniportCreateVc */
873struct rcondis_mp_create_vc_complete {
874 u32 req_id;
875 u32 dev_vc_handle;
876 u32 status;
877};
878
879/* CoNdisMiniportDeleteVc message */
880struct rcondis_mp_delete_vc {
881 u32 req_id;
882 u32 dev_vc_handle;
883};
884
885/* Response to CoNdisMiniportDeleteVc */
886struct rcondis_mp_delete_vc_complete {
887 u32 req_id;
888 u32 status;
889};
890
891/* CoNdisMiniportQueryRequest message */
892struct rcondis_mp_query_request {
893 u32 req_id;
894 u32 request_type;
895 u32 oid;
896 u32 dev_vc_handle;
897 u32 info_buflen;
898 u32 info_buf_offset;
899};
900
901/* CoNdisMiniportSetRequest message */
902struct rcondis_mp_set_request {
903 u32 req_id;
904 u32 request_type;
905 u32 oid;
906 u32 dev_vc_handle;
907 u32 info_buflen;
908 u32 info_buf_offset;
909};
910
911/* CoNdisIndicateStatus message */
912struct rcondis_indicate_status {
913 u32 ndis_vc_handle;
914 u32 status;
915 u32 status_buflen;
916 u32 status_buf_offset;
917};
918
919/* CONDIS Call/VC parameters */
920struct rcondis_specific_parameters {
921 u32 parameter_type;
922 u32 parameter_length;
923 u32 parameter_lffset;
924};
925
926struct rcondis_media_parameters {
927 u32 flags;
928 u32 reserved1;
929 u32 reserved2;
930 struct rcondis_specific_parameters media_specific;
931};
932
933struct rndis_flowspec {
934 u32 token_rate;
935 u32 token_bucket_size;
936 u32 peak_bandwidth;
937 u32 latency;
938 u32 delay_variation;
939 u32 service_type;
940 u32 max_sdu_size;
941 u32 minimum_policed_size;
942};
943
944struct rcondis_call_manager_parameters {
945 struct rndis_flowspec transmit;
946 struct rndis_flowspec receive;
947 struct rcondis_specific_parameters call_mgr_specific;
948};
949
950/* CoNdisMiniportActivateVc message */
951struct rcondis_mp_activate_vc_request {
952 u32 req_id;
953 u32 flags;
954 u32 dev_vc_handle;
955 u32 media_params_offset;
956 u32 media_params_length;
957 u32 call_mgr_params_offset;
958 u32 call_mgr_params_length;
959};
960
961/* Response to CoNdisMiniportActivateVc */
962struct rcondis_mp_activate_vc_complete {
963 u32 req_id;
964 u32 status;
965};
966
967/* CoNdisMiniportDeactivateVc message */
968struct rcondis_mp_deactivate_vc_request {
969 u32 req_id;
970 u32 flags;
971 u32 dev_vc_handle;
972};
973
974/* Response to CoNdisMiniportDeactivateVc */
975struct rcondis_mp_deactivate_vc_complete {
976 u32 req_id;
977 u32 status;
978};
979
980
981/* union with all of the RNDIS messages */
982union rndis_message_container {
983 struct rndis_packet pkt;
984 struct rndis_initialize_request init_req;
985 struct rndis_halt_request halt_req;
986 struct rndis_query_request query_req;
987 struct rndis_set_request set_req;
988 struct rndis_reset_request reset_req;
989 struct rndis_keepalive_request keep_alive_req;
990 struct rndis_indicate_status indicate_status;
991 struct rndis_initialize_complete init_complete;
992 struct rndis_query_complete query_complete;
993 struct rndis_set_complete set_complete;
994 struct rndis_reset_complete reset_complete;
995 struct rndis_keepalive_complete keep_alive_complete;
996 struct rcondis_mp_create_vc co_miniport_create_vc;
997 struct rcondis_mp_delete_vc co_miniport_delete_vc;
998 struct rcondis_indicate_status co_indicate_status;
999 struct rcondis_mp_activate_vc_request co_miniport_activate_vc;
1000 struct rcondis_mp_deactivate_vc_request co_miniport_deactivate_vc;
1001 struct rcondis_mp_create_vc_complete co_miniport_create_vc_complete;
1002 struct rcondis_mp_delete_vc_complete co_miniport_delete_vc_complete;
1003 struct rcondis_mp_activate_vc_complete co_miniport_activate_vc_complete;
1004 struct rcondis_mp_deactivate_vc_complete
1005 co_miniport_deactivate_vc_complete;
1006};
1007
1008/* Remote NDIS message format */
1009struct rndis_message {
1010 u32 ndis_msg_type;
1011
1012 /* Total length of this message, from the beginning */
1013 /* of the sruct rndis_message, in bytes. */
1014 u32 msg_len;
1015
1016 /* Actual message */
1017 union rndis_message_container msg;
1018};
1019
K. Y. Srinivasan9dbfd152011-05-12 19:35:00 -07001020
1021struct rndis_filter_packet {
1022 void *completion_ctx;
1023 void (*completion)(void *context);
1024 struct rndis_message msg;
1025};
1026
K. Y. Srinivasan4a5cea32011-05-12 19:34:40 -07001027/* Handy macros */
1028
1029/* get the size of an RNDIS message. Pass in the message type, */
1030/* struct rndis_set_request, struct rndis_packet for example */
1031#define RNDIS_MESSAGE_SIZE(msg) \
1032 (sizeof(msg) + (sizeof(struct rndis_message) - \
1033 sizeof(union rndis_message_container)))
1034
1035/* get pointer to info buffer with message pointer */
1036#define MESSAGE_TO_INFO_BUFFER(msg) \
1037 (((unsigned char *)(msg)) + msg->info_buf_offset)
1038
1039/* get pointer to status buffer with message pointer */
1040#define MESSAGE_TO_STATUS_BUFFER(msg) \
1041 (((unsigned char *)(msg)) + msg->status_buf_offset)
1042
1043/* get pointer to OOBD buffer with message pointer */
1044#define MESSAGE_TO_OOBD_BUFFER(msg) \
1045 (((unsigned char *)(msg)) + msg->oob_data_offset)
1046
1047/* get pointer to data buffer with message pointer */
1048#define MESSAGE_TO_DATA_BUFFER(msg) \
1049 (((unsigned char *)(msg)) + msg->per_pkt_info_offset)
1050
1051/* get pointer to contained message from NDIS_MESSAGE pointer */
1052#define RNDIS_MESSAGE_PTR_TO_MESSAGE_PTR(rndis_msg) \
1053 ((void *) &rndis_msg->msg)
1054
1055/* get pointer to contained message from NDIS_MESSAGE pointer */
1056#define RNDIS_MESSAGE_RAW_PTR_TO_MESSAGE_PTR(rndis_msg) \
1057 ((void *) rndis_msg)
1058
K. Y. Srinivasan299d09252011-05-12 19:34:41 -07001059
1060#define __struct_bcount(x)
1061
1062
1063
1064#define RNDIS_HEADER_SIZE (sizeof(struct rndis_message) - \
1065 sizeof(union rndis_message_container))
1066
1067#define NDIS_PACKET_TYPE_DIRECTED 0x00000001
1068#define NDIS_PACKET_TYPE_MULTICAST 0x00000002
1069#define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004
1070#define NDIS_PACKET_TYPE_BROADCAST 0x00000008
1071#define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010
1072#define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020
1073#define NDIS_PACKET_TYPE_SMT 0x00000040
1074#define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080
1075#define NDIS_PACKET_TYPE_GROUP 0x00000100
1076#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00000200
1077#define NDIS_PACKET_TYPE_FUNCTIONAL 0x00000400
1078#define NDIS_PACKET_TYPE_MAC_FRAME 0x00000800
1079
1080
K. Y. Srinivasan299d09252011-05-12 19:34:41 -07001081
K. Y. Srinivasan5ca72522011-05-12 19:34:37 -07001082#endif /* _HYPERV_NET_H */