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