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