]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - sys/dev/hyperv/netvsc/hv_net_vsc.h
MFC 303603-303605,303764
[FreeBSD/stable/10.git] / sys / dev / hyperv / netvsc / hv_net_vsc.h
1 /*-
2  * Copyright (c) 2009-2012,2016 Microsoft Corp.
3  * Copyright (c) 2010-2012 Citrix Inc.
4  * Copyright (c) 2012 NetApp Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice unmodified, this list of conditions, and the following
12  *    disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * $FreeBSD$
29  */
30
31 /*
32  * HyperV vmbus (virtual machine bus) network VSC (virtual services client)
33  * header file
34  *
35  * (Updated from unencumbered NvspProtocol.h)
36  */
37
38 #ifndef __HV_NET_VSC_H__
39 #define __HV_NET_VSC_H__
40
41 #include <sys/param.h>
42 #include <sys/kernel.h>
43 #include <sys/lock.h>
44 #include <sys/malloc.h>
45 #include <sys/queue.h>
46 #include <sys/taskqueue.h>
47 #include <sys/sema.h>
48 #include <sys/sx.h>
49
50 #include <machine/bus.h>
51 #include <sys/bus.h>
52 #include <sys/bus_dma.h>
53
54 #include <netinet/in.h>
55 #include <netinet/tcp_lro.h>
56
57 #include <net/ethernet.h>
58 #include <net/if.h>
59 #include <net/if_media.h>
60
61 #include <dev/hyperv/include/hyperv.h>
62 #include <dev/hyperv/include/hyperv_busdma.h>
63 #include <dev/hyperv/include/vmbus.h>
64
65 #define HN_USE_TXDESC_BUFRING
66
67 MALLOC_DECLARE(M_NETVSC);
68
69 #define NVSP_INVALID_PROTOCOL_VERSION           (0xFFFFFFFF)
70
71 #define NVSP_PROTOCOL_VERSION_1                 2
72 #define NVSP_PROTOCOL_VERSION_2                 0x30002
73 #define NVSP_PROTOCOL_VERSION_4                 0x40000
74 #define NVSP_PROTOCOL_VERSION_5                 0x50000
75 #define NVSP_MIN_PROTOCOL_VERSION               (NVSP_PROTOCOL_VERSION_1)
76 #define NVSP_MAX_PROTOCOL_VERSION               (NVSP_PROTOCOL_VERSION_2)
77
78 #define NVSP_PROTOCOL_VERSION_CURRENT           NVSP_PROTOCOL_VERSION_2
79
80 #define VERSION_4_OFFLOAD_SIZE                  22
81
82 #define NVSP_OPERATIONAL_STATUS_OK              (0x00000000)
83 #define NVSP_OPERATIONAL_STATUS_DEGRADED        (0x00000001)
84 #define NVSP_OPERATIONAL_STATUS_NONRECOVERABLE  (0x00000002)
85 #define NVSP_OPERATIONAL_STATUS_NO_CONTACT      (0x00000003)
86 #define NVSP_OPERATIONAL_STATUS_LOST_COMMUNICATION (0x00000004)
87
88 /*
89  * Maximun number of transfer pages (packets) the VSP will use on a receive
90  */
91 #define NVSP_MAX_PACKETS_PER_RECEIVE            375
92
93 /* vRSS stuff */
94 #define RNDIS_OBJECT_TYPE_RSS_CAPABILITIES      0x88
95 #define RNDIS_OBJECT_TYPE_RSS_PARAMETERS        0x89
96
97 #define RNDIS_RECEIVE_SCALE_CAPABILITIES_REVISION_2     2
98 #define RNDIS_RECEIVE_SCALE_PARAMETERS_REVISION_2       2
99
100 struct rndis_obj_header {
101         uint8_t type;
102         uint8_t rev;
103         uint16_t size;
104 } __packed;
105
106 /* rndis_recv_scale_cap/cap_flag */
107 #define RNDIS_RSS_CAPS_MESSAGE_SIGNALED_INTERRUPTS      0x01000000
108 #define RNDIS_RSS_CAPS_CLASSIFICATION_AT_ISR            0x02000000
109 #define RNDIS_RSS_CAPS_CLASSIFICATION_AT_DPC            0x04000000
110 #define RNDIS_RSS_CAPS_USING_MSI_X                      0x08000000
111 #define RNDIS_RSS_CAPS_RSS_AVAILABLE_ON_PORTS           0x10000000
112 #define RNDIS_RSS_CAPS_SUPPORTS_MSI_X                   0x20000000
113 #define RNDIS_RSS_CAPS_HASH_TYPE_TCP_IPV4               0x00000100
114 #define RNDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6               0x00000200
115 #define RNDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6_EX            0x00000400
116
117 /* RNDIS_RECEIVE_SCALE_CAPABILITIES */
118 struct rndis_recv_scale_cap {
119         struct rndis_obj_header hdr;
120         uint32_t cap_flag;
121         uint32_t num_int_msg;
122         uint32_t num_recv_que;
123         uint16_t num_indirect_tabent;
124 } __packed;
125
126 /* rndis_recv_scale_param flags */
127 #define RNDIS_RSS_PARAM_FLAG_BASE_CPU_UNCHANGED         0x0001
128 #define RNDIS_RSS_PARAM_FLAG_HASH_INFO_UNCHANGED        0x0002
129 #define RNDIS_RSS_PARAM_FLAG_ITABLE_UNCHANGED           0x0004
130 #define RNDIS_RSS_PARAM_FLAG_HASH_KEY_UNCHANGED         0x0008
131 #define RNDIS_RSS_PARAM_FLAG_DISABLE_RSS                0x0010
132
133 /* Hash info bits */
134 #define RNDIS_HASH_FUNC_TOEPLITZ                0x00000001
135 #define RNDIS_HASH_IPV4                         0x00000100
136 #define RNDIS_HASH_TCP_IPV4                     0x00000200
137 #define RNDIS_HASH_IPV6                         0x00000400
138 #define RNDIS_HASH_IPV6_EX                      0x00000800
139 #define RNDIS_HASH_TCP_IPV6                     0x00001000
140 #define RNDIS_HASH_TCP_IPV6_EX                  0x00002000
141
142 #define RNDIS_RSS_INDIRECTION_TABLE_MAX_SIZE_REVISION_2 (128 * 4)
143 #define RNDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2   40
144
145 #define ITAB_NUM                                        128
146 #define HASH_KEYLEN RNDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2
147
148 /* RNDIS_RECEIVE_SCALE_PARAMETERS */
149 typedef struct rndis_recv_scale_param_ {
150         struct rndis_obj_header hdr;
151
152         /* Qualifies the rest of the information */
153         uint16_t flag;
154
155         /* The base CPU number to do receive processing. not used */
156         uint16_t base_cpu_number;
157
158         /* This describes the hash function and type being enabled */
159         uint32_t hashinfo;
160
161         /* The size of indirection table array */
162         uint16_t indirect_tabsize;
163
164         /* The offset of the indirection table from the beginning of this
165          * structure
166          */
167         uint32_t indirect_taboffset;
168
169         /* The size of the hash secret key */
170         uint16_t hashkey_size;
171
172         /* The offset of the secret key from the beginning of this structure */
173         uint32_t hashkey_offset;
174
175         uint32_t processor_masks_offset;
176         uint32_t num_processor_masks;
177         uint32_t processor_masks_entry_size;
178 } rndis_recv_scale_param;
179
180 typedef enum nvsp_msg_type_ {
181         nvsp_msg_type_none                      = 0,
182
183         /*
184          * Init Messages
185          */
186         nvsp_msg_type_init                      = 1,
187         nvsp_msg_type_init_complete             = 2,
188
189         nvsp_version_msg_start                  = 100,
190
191         /*
192          * Version 1 Messages
193          */
194         nvsp_msg_1_type_send_ndis_vers          = nvsp_version_msg_start,
195
196         nvsp_msg_1_type_send_rx_buf,
197         nvsp_msg_1_type_send_rx_buf_complete,
198         nvsp_msg_1_type_revoke_rx_buf,
199
200         nvsp_msg_1_type_send_send_buf,
201         nvsp_msg_1_type_send_send_buf_complete,
202         nvsp_msg_1_type_revoke_send_buf,
203
204         nvsp_msg_1_type_send_rndis_pkt,
205         nvsp_msg_1_type_send_rndis_pkt_complete,
206     
207         /*
208          * Version 2 Messages
209          */
210         nvsp_msg_2_type_send_chimney_delegated_buf,
211         nvsp_msg_2_type_send_chimney_delegated_buf_complete,
212         nvsp_msg_2_type_revoke_chimney_delegated_buf,
213
214         nvsp_msg_2_type_resume_chimney_rx_indication,
215
216         nvsp_msg_2_type_terminate_chimney,
217         nvsp_msg_2_type_terminate_chimney_complete,
218
219         nvsp_msg_2_type_indicate_chimney_event,
220
221         nvsp_msg_2_type_send_chimney_packet,
222         nvsp_msg_2_type_send_chimney_packet_complete,
223
224         nvsp_msg_2_type_post_chimney_rx_request,
225         nvsp_msg_2_type_post_chimney_rx_request_complete,
226
227         nvsp_msg_2_type_alloc_rx_buf,
228         nvsp_msg_2_type_alloc_rx_buf_complete,
229
230         nvsp_msg_2_type_free_rx_buf,
231
232         nvsp_msg_2_send_vmq_rndis_pkt,
233         nvsp_msg_2_send_vmq_rndis_pkt_complete,
234
235         nvsp_msg_2_type_send_ndis_config,
236
237         nvsp_msg_2_type_alloc_chimney_handle,
238         nvsp_msg_2_type_alloc_chimney_handle_complete,
239
240         nvsp_msg2_max = nvsp_msg_2_type_alloc_chimney_handle_complete,
241
242         /*
243          * Version 4 Messages
244          */
245         nvsp_msg4_type_send_vf_association,
246         nvsp_msg4_type_switch_data_path,
247         nvsp_msg4_type_uplink_connect_state_deprecated,
248
249         nvsp_msg4_max = nvsp_msg4_type_uplink_connect_state_deprecated,
250
251         /*
252          * Version 5 Messages
253          */
254         nvsp_msg5_type_oid_query_ex,
255         nvsp_msg5_type_oid_query_ex_comp,
256         nvsp_msg5_type_subchannel,
257         nvsp_msg5_type_send_indirection_table,
258
259         nvsp_msg5_max = nvsp_msg5_type_send_indirection_table,
260 } nvsp_msg_type;
261
262 typedef enum nvsp_status_ {
263         nvsp_status_none = 0,
264         nvsp_status_success,
265         nvsp_status_failure,
266         /* Deprecated */
267         nvsp_status_prot_vers_range_too_new,
268         /* Deprecated */
269         nvsp_status_prot_vers_range_too_old,
270         nvsp_status_invalid_rndis_pkt,
271         nvsp_status_busy,
272         nvsp_status_max,
273 } nvsp_status;
274
275 typedef struct nvsp_msg_hdr_ {
276         uint32_t                                msg_type;
277 } __packed nvsp_msg_hdr;
278
279 /*
280  * Init Messages
281  */
282
283 /*
284  * This message is used by the VSC to initialize the channel
285  * after the channels has been opened. This message should 
286  * never include anything other then versioning (i.e. this
287  * message will be the same for ever).
288  *
289  * Forever is a long time.  The values have been redefined
290  * in Win7 to indicate major and minor protocol version
291  * number.
292  */
293 typedef struct nvsp_msg_init_ {
294         union {
295                 struct {
296                         uint16_t                minor_protocol_version;
297                         uint16_t                major_protocol_version;
298                 } s;
299                 /* Formerly min_protocol_version */
300                 uint32_t                        protocol_version;
301         } p1;
302         /* Formerly max_protocol_version */
303         uint32_t                                protocol_version_2;
304 } __packed nvsp_msg_init;
305
306 /*
307  * This message is used by the VSP to complete the initialization
308  * of the channel. This message should never include anything other 
309  * then versioning (i.e. this message will be the same forever).
310  */
311 typedef struct nvsp_msg_init_complete_ {
312         /* Deprecated */
313         uint32_t                                negotiated_prot_vers;
314         uint32_t                                max_mdl_chain_len;
315         uint32_t                                status;
316 } __packed nvsp_msg_init_complete;
317
318 typedef union nvsp_msg_init_uber_ {
319         nvsp_msg_init                           init;
320         nvsp_msg_init_complete                  init_compl;
321 } __packed nvsp_msg_init_uber;
322
323 /*
324  * Version 1 Messages
325  */
326
327 /*
328  * This message is used by the VSC to send the NDIS version
329  * to the VSP.  The VSP can use this information when handling
330  * OIDs sent by the VSC.
331  */
332 typedef struct nvsp_1_msg_send_ndis_version_ {
333         uint32_t                                ndis_major_vers;
334         /* Deprecated */
335         uint32_t                                ndis_minor_vers;
336 } __packed nvsp_1_msg_send_ndis_version;
337
338 /*
339  * This message is used by the VSC to send a receive buffer
340  * to the VSP. The VSP can then use the receive buffer to
341  * send data to the VSC.
342  */
343 typedef struct nvsp_1_msg_send_rx_buf_ {
344         uint32_t                                gpadl_handle;
345         uint16_t                                id;
346 } __packed nvsp_1_msg_send_rx_buf;
347
348 typedef struct nvsp_1_rx_buf_section_ {
349         uint32_t                                offset;
350         uint32_t                                sub_allocation_size;
351         uint32_t                                num_sub_allocations;
352         uint32_t                                end_offset;
353 } __packed nvsp_1_rx_buf_section;
354
355 /*
356  * This message is used by the VSP to acknowledge a receive 
357  * buffer send by the VSC.  This message must be sent by the 
358  * VSP before the VSP uses the receive buffer.
359  */
360 typedef struct nvsp_1_msg_send_rx_buf_complete_ {
361         uint32_t                                status;
362         uint32_t                                num_sections;
363
364         /*
365          * The receive buffer is split into two parts, a large
366          * suballocation section and a small suballocation
367          * section. These sections are then suballocated by a 
368          * certain size.
369          *
370          * For example, the following break up of the receive
371          * buffer has 6 large suballocations and 10 small
372          * suballocations.
373          *
374          * |            Large Section          |  |   Small Section   |
375          * ------------------------------------------------------------
376          * |     |     |     |     |     |     |  | | | | | | | | | | |
377          * |                                      |  
378          * LargeOffset                            SmallOffset
379          */
380         nvsp_1_rx_buf_section                   sections[1];
381
382 } __packed nvsp_1_msg_send_rx_buf_complete;
383
384 /*
385  * This message is sent by the VSC to revoke the receive buffer.
386  * After the VSP completes this transaction, the VSP should never
387  * use the receive buffer again.
388  */
389 typedef struct nvsp_1_msg_revoke_rx_buf_ {
390         uint16_t                                id;
391 } __packed nvsp_1_msg_revoke_rx_buf;
392
393 /*
394  * This message is used by the VSC to send a send buffer
395  * to the VSP. The VSC can then use the send buffer to
396  * send data to the VSP.
397  */
398 typedef struct nvsp_1_msg_send_send_buf_ {
399         uint32_t                                gpadl_handle;
400         uint16_t                                id;
401 } __packed nvsp_1_msg_send_send_buf;
402
403 /*
404  * This message is used by the VSP to acknowledge a send 
405  * buffer sent by the VSC. This message must be sent by the 
406  * VSP before the VSP uses the sent buffer.
407  */
408 typedef struct nvsp_1_msg_send_send_buf_complete_ {
409         uint32_t                                status;
410
411         /*
412          * The VSC gets to choose the size of the send buffer and
413          * the VSP gets to choose the sections size of the buffer.
414          * This was done to enable dynamic reconfigurations when
415          * the cost of GPA-direct buffers decreases.
416          */
417         uint32_t                                section_size;
418 } __packed nvsp_1_msg_send_send_buf_complete;
419
420 /*
421  * This message is sent by the VSC to revoke the send buffer.
422  * After the VSP completes this transaction, the vsp should never
423  * use the send buffer again.
424  */
425 typedef struct nvsp_1_msg_revoke_send_buf_ {
426         uint16_t                                id;
427 } __packed nvsp_1_msg_revoke_send_buf;
428
429 /*
430  * This message is used by both the VSP and the VSC to send
431  * an RNDIS message to the opposite channel endpoint.
432  */
433 typedef struct nvsp_1_msg_send_rndis_pkt_ {
434         /*
435          * This field is specified by RNIDS.  They assume there's
436          * two different channels of communication. However, 
437          * the Network VSP only has one.  Therefore, the channel
438          * travels with the RNDIS packet.
439          */
440         uint32_t                                chan_type;
441
442         /*
443          * This field is used to send part or all of the data
444          * through a send buffer. This values specifies an 
445          * index into the send buffer.  If the index is 
446          * 0xFFFFFFFF, then the send buffer is not being used
447          * and all of the data was sent through other VMBus
448          * mechanisms.
449          */
450         uint32_t                                send_buf_section_idx;
451         uint32_t                                send_buf_section_size;
452 } __packed nvsp_1_msg_send_rndis_pkt;
453
454 /*
455  * This message is used by both the VSP and the VSC to complete
456  * a RNDIS message to the opposite channel endpoint.  At this
457  * point, the initiator of this message cannot use any resources
458  * associated with the original RNDIS packet.
459  */
460 typedef struct nvsp_1_msg_send_rndis_pkt_complete_ {
461         uint32_t                                status;
462 } __packed nvsp_1_msg_send_rndis_pkt_complete;
463
464
465 /*
466  * Version 2 Messages
467  */
468
469 /*
470  * This message is used by the VSC to send the NDIS version
471  * to the VSP.  The VSP can use this information when handling
472  * OIDs sent by the VSC.
473  */
474 typedef struct nvsp_2_netvsc_capabilities_ {
475         union {
476                 uint64_t                        as_uint64;
477                 struct {
478                         uint64_t                vmq           : 1;
479                         uint64_t                chimney       : 1;
480                         uint64_t                sriov         : 1;
481                         uint64_t                ieee8021q     : 1;
482                         uint64_t                correlationid : 1;
483                         uint64_t                teaming       : 1;
484                 } u2;
485         } u1;
486 } __packed nvsp_2_netvsc_capabilities;
487
488 typedef struct nvsp_2_msg_send_ndis_config_ {
489         uint32_t                                mtu;
490         uint32_t                                reserved;
491         nvsp_2_netvsc_capabilities              capabilities;
492 } __packed nvsp_2_msg_send_ndis_config;
493
494 /*
495  * NvspMessage2TypeSendChimneyDelegatedBuffer
496  */
497 typedef struct nvsp_2_msg_send_chimney_buf_
498 {
499         /*
500          * On WIN7 beta, delegated_obj_max_size is defined as a uint32_t
501          * Since WIN7 RC, it was split into two uint16_t.  To have the same
502          * struct layout, delegated_obj_max_size shall be the first field.
503          */
504         uint16_t                                delegated_obj_max_size;
505
506         /*
507          * The revision # of chimney protocol used between NVSC and NVSP.
508          *
509          * This revision is NOT related to the chimney revision between
510          * NDIS protocol and miniport drivers.
511          */
512         uint16_t                                revision;
513
514         uint32_t                                gpadl_handle;
515 } __packed nvsp_2_msg_send_chimney_buf;
516
517
518 /* Unsupported chimney revision 0 (only present in WIN7 beta) */
519 #define NVSP_CHIMNEY_REVISION_0                 0
520
521 /* WIN7 Beta Chimney QFE */
522 #define NVSP_CHIMNEY_REVISION_1                 1
523
524 /* The chimney revision since WIN7 RC */
525 #define NVSP_CHIMNEY_REVISION_2                 2
526
527
528 /*
529  * NvspMessage2TypeSendChimneyDelegatedBufferComplete
530  */
531 typedef struct nvsp_2_msg_send_chimney_buf_complete_ {
532         uint32_t                                status;
533
534         /*
535          * Maximum number outstanding sends and pre-posted receives.
536          *
537          * NVSC should not post more than SendQuota/ReceiveQuota packets.
538          * Otherwise, it can block the non-chimney path for an indefinite
539          * amount of time.
540          * (since chimney sends/receives are affected by the remote peer).
541          *
542          * Note: NVSP enforces the quota restrictions on a per-VMBCHANNEL
543          * basis.  It doesn't enforce the restriction separately for chimney
544          * send/receive.  If NVSC doesn't voluntarily enforce "SendQuota",
545          * it may kill its own network connectivity.
546          */
547         uint32_t                                send_quota;
548         uint32_t                                rx_quota;
549 } __packed nvsp_2_msg_send_chimney_buf_complete;
550
551 /*
552  * NvspMessage2TypeRevokeChimneyDelegatedBuffer
553  */
554 typedef struct nvsp_2_msg_revoke_chimney_buf_ {
555         uint32_t                                gpadl_handle;
556 } __packed nvsp_2_msg_revoke_chimney_buf;
557
558
559 #define NVSP_CHIMNEY_OBJECT_TYPE_NEIGHBOR       0
560 #define NVSP_CHIMNEY_OBJECT_TYPE_PATH4          1
561 #define NVSP_CHIMNEY_OBJECT_TYPE_PATH6          2
562 #define NVSP_CHIMNEY_OBJECT_TYPE_TCP            3
563
564 /*
565  * NvspMessage2TypeAllocateChimneyHandle
566  */
567 typedef struct nvsp_2_msg_alloc_chimney_handle_ {
568         uint64_t                                vsc_context;
569         uint32_t                                object_type;
570 } __packed nvsp_2_msg_alloc_chimney_handle;
571
572 /*
573  * NvspMessage2TypeAllocateChimneyHandleComplete
574  */
575 typedef struct nvsp_2_msg_alloc_chimney_handle_complete_ {
576         uint32_t                                vsp_handle;
577 } __packed nvsp_2_msg_alloc_chimney_handle_complete;
578
579
580 /*
581  * NvspMessage2TypeResumeChimneyRXIndication
582  */
583 typedef struct nvsp_2_msg_resume_chimney_rx_indication {
584         /*
585          * Handle identifying the offloaded connection
586          */
587         uint32_t                                vsp_tcp_handle;
588 } __packed nvsp_2_msg_resume_chimney_rx_indication;
589
590
591 #define NVSP_2_MSG_TERMINATE_CHIMNEY_FLAGS_FIRST_STAGE      (0x01u)
592 #define NVSP_2_MSG_TERMINATE_CHIMNEY_FLAGS_RESERVED         (~(0x01u))
593
594 /*
595  * NvspMessage2TypeTerminateChimney
596  */
597 typedef struct nvsp_2_msg_terminate_chimney_ {
598         /*
599         * Handle identifying the offloaded object
600         */
601         uint32_t                                vsp_handle;
602
603         /*
604          * Terminate Offload Flags
605          *     Bit 0:
606          *         When set to 0, terminate the offload at the destination NIC
607          *     Bit 1-31:  Reserved, shall be zero
608          */
609         uint32_t                                flags;
610
611         union {
612                 /*
613                  * This field is valid only when bit 0 of flags is clear.
614                  * It specifies the index into the premapped delegated
615                  * object buffer.  The buffer was sent through the
616                  * NvspMessage2TypeSendChimneyDelegatedBuffer
617                  * message at initialization time.
618                  *
619                  * NVSP will write the delegated state into the delegated
620                  * buffer upon upload completion.
621                  */
622                 uint32_t                        index;
623
624                 /*
625                  * This field is valid only when bit 0 of flags is set.
626                  *
627                  * The seqence number of the most recently accepted RX
628                  * indication when VSC sets its TCP context into
629                  * "terminating" state.
630                  *
631                  * This allows NVSP to determines if there are any in-flight
632                  * RX indications for which the acceptance state is still
633                  * undefined.
634                  */
635                 uint64_t                        last_accepted_rx_seq_no;
636         } f0;
637 } __packed nvsp_2_msg_terminate_chimney;
638
639
640 #define NVSP_TERMINATE_CHIMNEY_COMPLETE_FLAG_DATA_CORRUPTED     0x0000001u
641
642 /*
643  * NvspMessage2TypeTerminateChimneyComplete
644  */
645 typedef struct nvsp_2_msg_terminate_chimney_complete_ {
646         uint64_t                                vsc_context;
647         uint32_t                                flags;
648 } __packed nvsp_2_msg_terminate_chimney_complete;
649
650 /*
651  * NvspMessage2TypeIndicateChimneyEvent
652  */
653 typedef struct nvsp_2_msg_indicate_chimney_event_ {
654         /*
655          * When VscTcpContext is 0, event_type is an NDIS_STATUS event code
656          * Otherwise, EventType is an TCP connection event (defined in
657          * NdisTcpOffloadEventHandler chimney DDK document).
658          */
659         uint32_t                                event_type;
660
661         /*
662          * When VscTcpContext is 0, EventType is an NDIS_STATUS event code
663          * Otherwise, EventType is an TCP connection event specific information
664          * (defined in NdisTcpOffloadEventHandler chimney DDK document).
665          */
666         uint32_t                                event_specific_info;
667
668         /*
669          * If not 0, the event is per-TCP connection event.  This field
670          * contains the VSC's TCP context.
671          * If 0, the event indication is global.
672          */
673         uint64_t                                vsc_tcp_context;
674 } __packed nvsp_2_msg_indicate_chimney_event;
675
676
677 #define NVSP_1_CHIMNEY_SEND_INVALID_OOB_INDEX       0xffffu
678 #define NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX   0xffffffff
679
680 /*
681  * NvspMessage2TypeSendChimneyPacket
682  */
683 typedef struct nvsp_2_msg_send_chimney_pkt_ {
684     /*
685      * Identify the TCP connection for which this chimney send is
686      */
687     uint32_t                                    vsp_tcp_handle;
688
689     /*
690      * This field is used to send part or all of the data
691      * through a send buffer. This values specifies an
692      * index into the send buffer. If the index is
693      * 0xFFFF, then the send buffer is not being used
694      * and all of the data was sent through other VMBus
695      * mechanisms.
696      */
697     uint16_t                                    send_buf_section_index;
698     uint16_t                                    send_buf_section_size;
699
700     /*
701      * OOB Data Index
702      * This an index to the OOB data buffer. If the index is 0xFFFFFFFF,
703      * then there is no OOB data.
704      *
705      * This field shall be always 0xFFFFFFFF for now. It is reserved for
706      * the future.
707      */
708     uint16_t                                    oob_data_index;
709
710     /*
711      * DisconnectFlags = 0
712      *      Normal chimney send. See MiniportTcpOffloadSend for details.
713      *
714      * DisconnectFlags = TCP_DISCONNECT_GRACEFUL_CLOSE (0x01)
715      *      Graceful disconnect. See MiniportTcpOffloadDisconnect for details.
716      *
717      * DisconnectFlags = TCP_DISCONNECT_ABORTIVE_CLOSE (0x02)
718      *      Abortive disconnect. See MiniportTcpOffloadDisconnect for details.
719      */
720     uint16_t                                    disconnect_flags;
721
722     uint32_t                                    seq_no;
723 } __packed nvsp_2_msg_send_chimney_pkt;
724
725 /*
726  * NvspMessage2TypeSendChimneyPacketComplete
727  */
728 typedef struct nvsp_2_msg_send_chimney_pkt_complete_ {
729     /*
730      * The NDIS_STATUS for the chimney send
731      */
732     uint32_t                                    status;
733
734     /*
735      * Number of bytes that have been sent to the peer (and ACKed by the peer).
736      */
737     uint32_t                                    bytes_transferred;
738 } __packed nvsp_2_msg_send_chimney_pkt_complete;
739
740
741 #define NVSP_1_CHIMNEY_RECV_FLAG_NO_PUSH        0x0001u
742 #define NVSP_1_CHIMNEY_RECV_INVALID_OOB_INDEX   0xffffu
743
744 /*
745  * NvspMessage2TypePostChimneyRecvRequest
746  */
747 typedef struct nvsp_2_msg_post_chimney_rx_request_ {
748         /*
749          * Identify the TCP connection which this chimney receive request
750          * is for.
751          */
752         uint32_t                                vsp_tcp_handle;
753
754         /*
755          * OOB Data Index
756          * This an index to the OOB data buffer. If the index is 0xFFFFFFFF,
757          * then there is no OOB data.
758          *
759          * This field shall be always 0xFFFFFFFF for now. It is reserved for
760          * the future.
761          */
762         uint32_t                                oob_data_index;
763
764         /*
765          * Bit 0
766          *      When it is set, this is a "no-push" receive.
767          *      When it is clear, this is a "push" receive.
768          *
769          * Bit 1-15:  Reserved and shall be zero
770          */
771         uint16_t                                flags;
772
773         /*
774          * For debugging and diagnoses purpose.
775          * The SeqNo is per TCP connection and starts from 0.
776          */
777         uint32_t                                seq_no;
778 } __packed nvsp_2_msg_post_chimney_rx_request;
779
780 /*
781  * NvspMessage2TypePostChimneyRecvRequestComplete
782  */
783 typedef struct nvsp_2_msg_post_chimney_rx_request_complete_ {
784         /*
785          * The NDIS_STATUS for the chimney send
786          */
787         uint32_t                                status;
788
789         /*
790          * Number of bytes that have been sent to the peer (and ACKed by
791          * the peer).
792          */
793         uint32_t                                bytes_xferred;
794 } __packed nvsp_2_msg_post_chimney_rx_request_complete;
795
796 /*
797  * NvspMessage2TypeAllocateReceiveBuffer
798  */
799 typedef struct nvsp_2_msg_alloc_rx_buf_ {
800         /*
801          * Allocation ID to match the allocation request and response
802          */
803         uint32_t                                allocation_id;
804
805         /*
806          * Length of the VM shared memory receive buffer that needs to
807          * be allocated
808          */
809         uint32_t                                length;
810 } __packed nvsp_2_msg_alloc_rx_buf;
811
812 /*
813  * NvspMessage2TypeAllocateReceiveBufferComplete
814  */
815 typedef struct nvsp_2_msg_alloc_rx_buf_complete_ {
816         /*
817          * The NDIS_STATUS code for buffer allocation
818          */
819         uint32_t                                status;
820
821         /*
822          * Allocation ID from NVSP_2_MESSAGE_ALLOCATE_RECEIVE_BUFFER
823          */
824         uint32_t                                allocation_id;
825
826         /*
827          * GPADL handle for the allocated receive buffer
828          */
829         uint32_t                                gpadl_handle;
830
831         /*
832          * Receive buffer ID that is further used in
833          * NvspMessage2SendVmqRndisPacket
834          */
835         uint64_t                                rx_buf_id;
836 } __packed nvsp_2_msg_alloc_rx_buf_complete;
837
838 /*
839  * NvspMessage2TypeFreeReceiveBuffer
840  */
841 typedef struct nvsp_2_msg_free_rx_buf_ {
842         /*
843          * Receive buffer ID previous returned in
844          * NvspMessage2TypeAllocateReceiveBufferComplete message
845          */
846         uint64_t                                rx_buf_id;
847 } __packed nvsp_2_msg_free_rx_buf;
848
849 /*
850  * This structure is used in defining the buffers in
851  * NVSP_2_MESSAGE_SEND_VMQ_RNDIS_PACKET structure
852  */
853 typedef struct nvsp_xfer_page_range_ {
854         /*
855          * Specifies the ID of the receive buffer that has the buffer. This
856          * ID can be the general receive buffer ID specified in
857          * NvspMessage1TypeSendReceiveBuffer or it can be the shared memory
858          * receive buffer ID allocated by the VSC and specified in
859          * NvspMessage2TypeAllocateReceiveBufferComplete message
860          */
861         uint64_t                                xfer_page_set_id;
862
863         /*
864          * Number of bytes
865          */
866         uint32_t                                byte_count;
867
868         /*
869          * Offset in bytes from the beginning of the buffer
870          */
871         uint32_t                                byte_offset;
872 } __packed nvsp_xfer_page_range;
873
874 /*
875  * NvspMessage2SendVmqRndisPacket
876  */
877 typedef struct nvsp_2_msg_send_vmq_rndis_pkt_ {
878         /*
879          * This field is specified by RNIDS. They assume there's
880          * two different channels of communication. However,
881          * the Network VSP only has one. Therefore, the channel
882          * travels with the RNDIS packet. It must be RMC_DATA
883          */
884         uint32_t                                channel_type;
885
886         /*
887          * Only the Range element corresponding to the RNDIS header of
888          * the first RNDIS message in the multiple RNDIS messages sent
889          * in one NVSP message.  Information about the data portions as well
890          * as the subsequent RNDIS messages in the same NVSP message are
891          * embedded in the RNDIS header itself
892          */
893         nvsp_xfer_page_range                    range;
894 } __packed nvsp_2_msg_send_vmq_rndis_pkt;
895
896 /*
897  * This message is used by the VSC to complete
898  * a RNDIS VMQ message to the VSP.  At this point,
899  * the initiator of this message can use any resources
900  * associated with the original RNDIS VMQ packet.
901  */
902 typedef struct nvsp_2_msg_send_vmq_rndis_pkt_complete_
903 {
904         uint32_t                                status;
905 } __packed nvsp_2_msg_send_vmq_rndis_pkt_complete;
906
907 /*
908  * Version 5 messages
909  */
910 enum nvsp_subchannel_operation {
911         NVSP_SUBCHANNEL_NONE = 0,
912         NVSP_SUBCHANNE_ALLOCATE,
913         NVSP_SUBCHANNE_MAX
914 };
915
916 typedef struct nvsp_5_subchannel_request_
917 {
918         uint32_t                                op;
919         uint32_t                                num_subchannels;
920 } __packed nvsp_5_subchannel_request;
921
922 typedef struct nvsp_5_subchannel_complete_
923 {
924         uint32_t                                status;
925         /* Actual number of subchannels allocated */
926         uint32_t                                num_subchannels;
927 } __packed nvsp_5_subchannel_complete;
928
929 typedef struct nvsp_5_send_indirect_table_
930 {
931         /* The number of entries in the send indirection table */
932         uint32_t                                count;
933         /*
934          * The offset of the send indireciton table from top of
935          * this struct. The send indirection table tells which channel
936          * to put the send traffic on. Each entry is a channel number.
937          */
938         uint32_t                                offset;
939 } __packed nvsp_5_send_indirect_table;
940
941 typedef union nvsp_1_msg_uber_ {
942         nvsp_1_msg_send_ndis_version            send_ndis_vers;
943
944         nvsp_1_msg_send_rx_buf                  send_rx_buf;
945         nvsp_1_msg_send_rx_buf_complete         send_rx_buf_complete;
946         nvsp_1_msg_revoke_rx_buf                revoke_rx_buf;
947
948         nvsp_1_msg_send_send_buf                send_send_buf;
949         nvsp_1_msg_send_send_buf_complete       send_send_buf_complete;
950         nvsp_1_msg_revoke_send_buf              revoke_send_buf;
951
952         nvsp_1_msg_send_rndis_pkt               send_rndis_pkt;
953         nvsp_1_msg_send_rndis_pkt_complete      send_rndis_pkt_complete;
954 } __packed nvsp_1_msg_uber;
955
956
957 typedef union nvsp_2_msg_uber_ {
958         nvsp_2_msg_send_ndis_config             send_ndis_config;
959
960         nvsp_2_msg_send_chimney_buf             send_chimney_buf;
961         nvsp_2_msg_send_chimney_buf_complete    send_chimney_buf_complete;
962         nvsp_2_msg_revoke_chimney_buf           revoke_chimney_buf;
963
964         nvsp_2_msg_resume_chimney_rx_indication resume_chimney_rx_indication;
965         nvsp_2_msg_terminate_chimney            terminate_chimney;
966         nvsp_2_msg_terminate_chimney_complete   terminate_chimney_complete;
967         nvsp_2_msg_indicate_chimney_event       indicate_chimney_event;
968
969         nvsp_2_msg_send_chimney_pkt             send_chimney_packet;
970         nvsp_2_msg_send_chimney_pkt_complete    send_chimney_packet_complete;
971         nvsp_2_msg_post_chimney_rx_request      post_chimney_rx_request;
972         nvsp_2_msg_post_chimney_rx_request_complete
973                                                post_chimney_rx_request_complete;
974
975         nvsp_2_msg_alloc_rx_buf                 alloc_rx_buffer;
976         nvsp_2_msg_alloc_rx_buf_complete        alloc_rx_buffer_complete;
977         nvsp_2_msg_free_rx_buf                  free_rx_buffer;
978
979         nvsp_2_msg_send_vmq_rndis_pkt           send_vmq_rndis_pkt;
980         nvsp_2_msg_send_vmq_rndis_pkt_complete  send_vmq_rndis_pkt_complete;
981         nvsp_2_msg_alloc_chimney_handle         alloc_chimney_handle;
982         nvsp_2_msg_alloc_chimney_handle_complete alloc_chimney_handle_complete;
983 } __packed nvsp_2_msg_uber;
984
985 typedef union nvsp_5_msg_uber_
986 {
987         nvsp_5_subchannel_request               subchannel_request;
988         nvsp_5_subchannel_complete              subchn_complete;
989         nvsp_5_send_indirect_table              send_table;
990 } __packed nvsp_5_msg_uber;
991
992 typedef union nvsp_all_msgs_ {
993         nvsp_msg_init_uber                      init_msgs;
994         nvsp_1_msg_uber                         vers_1_msgs;
995         nvsp_2_msg_uber                         vers_2_msgs;
996         nvsp_5_msg_uber                         vers_5_msgs;
997 } __packed nvsp_all_msgs;
998
999 /*
1000  * ALL Messages
1001  */
1002 typedef struct nvsp_msg_ {
1003         nvsp_msg_hdr                            hdr; 
1004         nvsp_all_msgs                           msgs;
1005 } __packed nvsp_msg;
1006
1007
1008 /*
1009  * The following arguably belongs in a separate header file
1010  */
1011
1012 /*
1013  * Defines
1014  */
1015
1016 #define NETVSC_SEND_BUFFER_SIZE                 (1024*1024*15)   /* 15M */
1017 #define NETVSC_SEND_BUFFER_ID                   0xface
1018
1019 #define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY       (1024*1024*15) /* 15MB */
1020 #define NETVSC_RECEIVE_BUFFER_SIZE              (1024*1024*16) /* 16MB */
1021
1022 #define NETVSC_RECEIVE_BUFFER_ID                0xcafe
1023
1024 #define NETVSC_RECEIVE_SG_COUNT                 1
1025
1026 /* Preallocated receive packets */
1027 #define NETVSC_RECEIVE_PACKETLIST_COUNT         256
1028
1029 /*
1030  * Maximum MTU we permit to be configured for a netvsc interface.
1031  * When the code was developed, a max MTU of 12232 was tested and
1032  * proven to work.  9K is a reasonable maximum for an Ethernet.
1033  */
1034 #define NETVSC_MAX_CONFIGURABLE_MTU             (9 * 1024)
1035
1036 #define NETVSC_PACKET_SIZE                      PAGE_SIZE
1037 #define VRSS_SEND_TABLE_SIZE                    16
1038
1039 /*
1040  * Data types
1041  */
1042
1043 /*
1044  * Per netvsc channel-specific
1045  */
1046 typedef struct netvsc_dev_ {
1047         struct hn_softc                         *sc;
1048
1049         /* Send buffer allocated by us but manages by NetVSP */
1050         void                                    *send_buf;
1051         uint32_t                                send_buf_size;
1052         uint32_t                                send_buf_gpadl_handle;
1053         uint32_t                                send_section_size;
1054         uint32_t                                send_section_count;
1055         unsigned long                           bitsmap_words;
1056         unsigned long                           *send_section_bitsmap;
1057
1058         /* Receive buffer allocated by us but managed by NetVSP */
1059         void                                    *rx_buf;
1060         uint32_t                                rx_buf_size;
1061         uint32_t                                rx_buf_gpadl_handle;
1062         uint32_t                                rx_section_count;
1063         nvsp_1_rx_buf_section                   *rx_sections;
1064
1065         /* Used for NetVSP initialization protocol */
1066         struct sema                             channel_init_sema;
1067         nvsp_msg                                channel_init_packet;
1068
1069         nvsp_msg                                revoke_packet;
1070         /*uint8_t                               hw_mac_addr[ETHER_ADDR_LEN];*/
1071
1072         /* Holds rndis device info */
1073         void                                    *extension;
1074
1075         uint8_t                                 destroy;
1076         /* Negotiated NVSP version */
1077         uint32_t                                nvsp_version;
1078
1079         uint32_t                                num_channel;
1080
1081         struct hyperv_dma                       rxbuf_dma;
1082         struct hyperv_dma                       txbuf_dma;
1083         uint32_t                                vrss_send_table[VRSS_SEND_TABLE_SIZE];
1084 } netvsc_dev;
1085
1086 struct vmbus_channel;
1087
1088 typedef void (*pfn_on_send_rx_completion)(struct vmbus_channel *, void *);
1089
1090 #define NETVSC_DEVICE_RING_BUFFER_SIZE  (128 * PAGE_SIZE)
1091 #define NETVSC_PACKET_MAXPAGE           32
1092
1093 #define NETVSC_VLAN_PRIO_MASK           0xe000
1094 #define NETVSC_VLAN_PRIO_SHIFT          13
1095 #define NETVSC_VLAN_VID_MASK            0x0fff
1096
1097 #define TYPE_IPV4                       2
1098 #define TYPE_IPV6                       4
1099 #define TYPE_TCP                        2
1100 #define TYPE_UDP                        4
1101
1102 #define TRANSPORT_TYPE_NOT_IP           0
1103 #define TRANSPORT_TYPE_IPV4_TCP         ((TYPE_IPV4 << 16) | TYPE_TCP)
1104 #define TRANSPORT_TYPE_IPV4_UDP         ((TYPE_IPV4 << 16) | TYPE_UDP)
1105 #define TRANSPORT_TYPE_IPV6_TCP         ((TYPE_IPV6 << 16) | TYPE_TCP)
1106 #define TRANSPORT_TYPE_IPV6_UDP         ((TYPE_IPV6 << 16) | TYPE_UDP)
1107
1108 #ifdef __LP64__
1109 #define BITS_PER_LONG 64
1110 #else
1111 #define BITS_PER_LONG 32
1112 #endif
1113
1114 typedef struct netvsc_packet_ {
1115         uint8_t                    is_data_pkt;      /* One byte */
1116         uint16_t                   vlan_tci;
1117         uint32_t status;
1118
1119         /* Completion */
1120         union {
1121                 struct {
1122                         uint64_t   rx_completion_tid;
1123                         void       *rx_completion_context;
1124                         /* This is no longer used */
1125                         pfn_on_send_rx_completion   on_rx_completion;
1126                 } rx;
1127                 struct {
1128                         uint64_t    send_completion_tid;
1129                         void        *send_completion_context;
1130                         /* Still used in netvsc and filter code */
1131                         pfn_on_send_rx_completion   on_send_completion;
1132                 } send;
1133         } compl;
1134         uint32_t        send_buf_section_idx;
1135         uint32_t        send_buf_section_size;
1136
1137         void            *rndis_mesg;
1138         uint32_t        tot_data_buf_len;
1139         void            *data;
1140         uint32_t        gpa_cnt;
1141         struct vmbus_gpa gpa[NETVSC_PACKET_MAXPAGE];
1142 } netvsc_packet;
1143
1144 typedef struct {
1145         uint8_t         mac_addr[6];  /* Assumption unsigned long */
1146         uint8_t         link_state;
1147 } netvsc_device_info;
1148
1149 #ifndef HN_USE_TXDESC_BUFRING
1150 struct hn_txdesc;
1151 SLIST_HEAD(hn_txdesc_list, hn_txdesc);
1152 #else
1153 struct buf_ring;
1154 #endif
1155
1156 struct hn_tx_ring;
1157
1158 struct hn_rx_ring {
1159         struct ifnet    *hn_ifp;
1160         struct hn_tx_ring *hn_txr;
1161         void            *hn_rdbuf;
1162         int             hn_rx_idx;
1163
1164         /* Trust csum verification on host side */
1165         int             hn_trust_hcsum; /* HN_TRUST_HCSUM_ */
1166         struct lro_ctrl hn_lro;
1167
1168         u_long          hn_csum_ip;
1169         u_long          hn_csum_tcp;
1170         u_long          hn_csum_udp;
1171         u_long          hn_csum_trusted;
1172         u_long          hn_lro_tried;
1173         u_long          hn_small_pkts;
1174         u_long          hn_pkts;
1175         u_long          hn_rss_pkts;
1176
1177         /* Rarely used stuffs */
1178         struct sysctl_oid *hn_rx_sysctl_tree;
1179         int             hn_rx_flags;
1180 } __aligned(CACHE_LINE_SIZE);
1181
1182 #define HN_TRUST_HCSUM_IP       0x0001
1183 #define HN_TRUST_HCSUM_TCP      0x0002
1184 #define HN_TRUST_HCSUM_UDP      0x0004
1185
1186 #define HN_RX_FLAG_ATTACHED     0x1
1187
1188 struct hn_tx_ring {
1189 #ifndef HN_USE_TXDESC_BUFRING
1190         struct mtx      hn_txlist_spin;
1191         struct hn_txdesc_list hn_txlist;
1192 #else
1193         struct buf_ring *hn_txdesc_br;
1194 #endif
1195         int             hn_txdesc_cnt;
1196         int             hn_txdesc_avail;
1197         u_short         hn_has_txeof;
1198         u_short         hn_txdone_cnt;
1199
1200         int             hn_sched_tx;
1201         void            (*hn_txeof)(struct hn_tx_ring *);
1202         struct taskqueue *hn_tx_taskq;
1203         struct task     hn_tx_task;
1204         struct task     hn_txeof_task;
1205
1206         struct buf_ring *hn_mbuf_br;
1207         int             hn_oactive;
1208         int             hn_tx_idx;
1209
1210         struct mtx      hn_tx_lock;
1211         struct hn_softc *hn_sc;
1212         struct vmbus_channel *hn_chan;
1213
1214         int             hn_direct_tx_size;
1215         int             hn_tx_chimney_size;
1216         bus_dma_tag_t   hn_tx_data_dtag;
1217         uint64_t        hn_csum_assist;
1218
1219         u_long          hn_no_txdescs;
1220         u_long          hn_send_failed;
1221         u_long          hn_txdma_failed;
1222         u_long          hn_tx_collapsed;
1223         u_long          hn_tx_chimney_tried;
1224         u_long          hn_tx_chimney;
1225         u_long          hn_pkts;
1226
1227         /* Rarely used stuffs */
1228         struct hn_txdesc *hn_txdesc;
1229         bus_dma_tag_t   hn_tx_rndis_dtag;
1230         struct sysctl_oid *hn_tx_sysctl_tree;
1231         int             hn_tx_flags;
1232 } __aligned(CACHE_LINE_SIZE);
1233
1234 #define HN_TX_FLAG_ATTACHED     0x1
1235
1236 /*
1237  * Device-specific softc structure
1238  */
1239 typedef struct hn_softc {
1240         struct ifnet    *hn_ifp;
1241         struct arpcom   arpcom;
1242         struct ifmedia  hn_media;
1243         device_t        hn_dev;
1244         uint8_t         hn_unit;
1245         int             hn_carrier;
1246         int             hn_if_flags;
1247         struct mtx      hn_lock;
1248         int             hn_initdone;
1249         /* See hv_netvsc_drv_freebsd.c for rules on how to use */
1250         int             temp_unusable;
1251         netvsc_dev      *net_dev;
1252         struct vmbus_channel *hn_prichan;
1253
1254         int             hn_rx_ring_cnt;
1255         int             hn_rx_ring_inuse;
1256         struct hn_rx_ring *hn_rx_ring;
1257
1258         int             hn_tx_ring_cnt;
1259         int             hn_tx_ring_inuse;
1260         struct hn_tx_ring *hn_tx_ring;
1261
1262         int             hn_cpu;
1263         int             hn_tx_chimney_max;
1264         struct taskqueue *hn_tx_taskq;
1265         struct sysctl_oid *hn_tx_sysctl_tree;
1266         struct sysctl_oid *hn_rx_sysctl_tree;
1267 } hn_softc_t;
1268
1269 /*
1270  * Externs
1271  */
1272 extern int hv_promisc_mode;
1273
1274 void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status);
1275 netvsc_dev *hv_nv_on_device_add(struct hn_softc *sc,
1276     void *additional_info, struct hn_rx_ring *rxr);
1277 int hv_nv_on_device_remove(struct hn_softc *sc,
1278     boolean_t destroy_channel);
1279 int hv_nv_on_send(struct vmbus_channel *chan, netvsc_packet *pkt);
1280 int hv_nv_get_next_send_section(netvsc_dev *net_dev);
1281 void hv_nv_subchan_attach(struct vmbus_channel *chan,
1282     struct hn_rx_ring *rxr);
1283
1284 #endif  /* __HV_NET_VSC_H__ */
1285