2 * Copyright (c) 2009-2012 Microsoft Corp.
3 * Copyright (c) 2010-2012 Citrix Inc.
4 * Copyright (c) 2012 NetApp Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice unmodified, this list of conditions, and the following
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.
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.
30 * HyperV vmbus (virtual machine bus) network VSC (virtual services client)
33 * (Updated from unencumbered NvspProtocol.h)
36 #ifndef __HV_NET_VSC_H__
37 #define __HV_NET_VSC_H__
39 #include <sys/types.h>
40 #include <sys/param.h>
44 #include <dev/hyperv/include/hyperv.h>
47 #define NVSP_INVALID_PROTOCOL_VERSION (0xFFFFFFFF)
49 #define NVSP_PROTOCOL_VERSION_1 2
50 #define NVSP_PROTOCOL_VERSION_2 0x30002
51 #define NVSP_MIN_PROTOCOL_VERSION (NVSP_PROTOCOL_VERSION_1)
52 #define NVSP_MAX_PROTOCOL_VERSION (NVSP_PROTOCOL_VERSION_2)
54 #define NVSP_PROTOCOL_VERSION_CURRENT NVSP_PROTOCOL_VERSION_2
56 #define NVSP_OPERATIONAL_STATUS_OK (0x00000000)
57 #define NVSP_OPERATIONAL_STATUS_DEGRADED (0x00000001)
58 #define NVSP_OPERATIONAL_STATUS_NONRECOVERABLE (0x00000002)
59 #define NVSP_OPERATIONAL_STATUS_NO_CONTACT (0x00000003)
60 #define NVSP_OPERATIONAL_STATUS_LOST_COMMUNICATION (0x00000004)
63 * Maximun number of transfer pages (packets) the VSP will use on a receive
65 #define NVSP_MAX_PACKETS_PER_RECEIVE 375
68 typedef enum nvsp_msg_type_ {
69 nvsp_msg_type_none = 0,
74 nvsp_msg_type_init = 1,
75 nvsp_msg_type_init_complete = 2,
77 nvsp_version_msg_start = 100,
82 nvsp_msg_1_type_send_ndis_vers = nvsp_version_msg_start,
84 nvsp_msg_1_type_send_rx_buf,
85 nvsp_msg_1_type_send_rx_buf_complete,
86 nvsp_msg_1_type_revoke_rx_buf,
88 nvsp_msg_1_type_send_send_buf,
89 nvsp_msg_1_type_send_send_buf_complete,
90 nvsp_msg_1_type_revoke_send_buf,
92 nvsp_msg_1_type_send_rndis_pkt,
93 nvsp_msg_1_type_send_rndis_pkt_complete,
98 nvsp_msg_2_type_send_chimney_delegated_buf,
99 nvsp_msg_2_type_send_chimney_delegated_buf_complete,
100 nvsp_msg_2_type_revoke_chimney_delegated_buf,
102 nvsp_msg_2_type_resume_chimney_rx_indication,
104 nvsp_msg_2_type_terminate_chimney,
105 nvsp_msg_2_type_terminate_chimney_complete,
107 nvsp_msg_2_type_indicate_chimney_event,
109 nvsp_msg_2_type_send_chimney_packet,
110 nvsp_msg_2_type_send_chimney_packet_complete,
112 nvsp_msg_2_type_post_chimney_rx_request,
113 nvsp_msg_2_type_post_chimney_rx_request_complete,
115 nvsp_msg_2_type_alloc_rx_buf,
116 nvsp_msg_2_type_alloc_rx_buf_complete,
118 nvsp_msg_2_type_free_rx_buf,
120 nvsp_msg_2_send_vmq_rndis_pkt,
121 nvsp_msg_2_send_vmq_rndis_pkt_complete,
123 nvsp_msg_2_type_send_ndis_config,
125 nvsp_msg_2_type_alloc_chimney_handle,
126 nvsp_msg_2_type_alloc_chimney_handle_complete,
129 typedef enum nvsp_status_ {
130 nvsp_status_none = 0,
134 nvsp_status_prot_vers_range_too_new,
136 nvsp_status_prot_vers_range_too_old,
137 nvsp_status_invalid_rndis_pkt,
142 typedef struct nvsp_msg_hdr_ {
144 } __packed nvsp_msg_hdr;
151 * This message is used by the VSC to initialize the channel
152 * after the channels has been opened. This message should
153 * never include anything other then versioning (i.e. this
154 * message will be the same for ever).
156 * Forever is a long time. The values have been redefined
157 * in Win7 to indicate major and minor protocol version
160 typedef struct nvsp_msg_init_ {
163 uint16_t minor_protocol_version;
164 uint16_t major_protocol_version;
166 /* Formerly min_protocol_version */
167 uint32_t protocol_version;
169 /* Formerly max_protocol_version */
170 uint32_t protocol_version_2;
171 } __packed nvsp_msg_init;
174 * This message is used by the VSP to complete the initialization
175 * of the channel. This message should never include anything other
176 * then versioning (i.e. this message will be the same forever).
178 typedef struct nvsp_msg_init_complete_ {
180 uint32_t negotiated_prot_vers;
181 uint32_t max_mdl_chain_len;
183 } __packed nvsp_msg_init_complete;
185 typedef union nvsp_msg_init_uber_ {
187 nvsp_msg_init_complete init_compl;
188 } __packed nvsp_msg_init_uber;
195 * This message is used by the VSC to send the NDIS version
196 * to the VSP. The VSP can use this information when handling
197 * OIDs sent by the VSC.
199 typedef struct nvsp_1_msg_send_ndis_version_ {
200 uint32_t ndis_major_vers;
202 uint32_t ndis_minor_vers;
203 } __packed nvsp_1_msg_send_ndis_version;
206 * This message is used by the VSC to send a receive buffer
207 * to the VSP. The VSP can then use the receive buffer to
208 * send data to the VSC.
210 typedef struct nvsp_1_msg_send_rx_buf_ {
211 uint32_t gpadl_handle;
213 } __packed nvsp_1_msg_send_rx_buf;
215 typedef struct nvsp_1_rx_buf_section_ {
217 uint32_t sub_allocation_size;
218 uint32_t num_sub_allocations;
220 } __packed nvsp_1_rx_buf_section;
223 * This message is used by the VSP to acknowledge a receive
224 * buffer send by the VSC. This message must be sent by the
225 * VSP before the VSP uses the receive buffer.
227 typedef struct nvsp_1_msg_send_rx_buf_complete_ {
229 uint32_t num_sections;
232 * The receive buffer is split into two parts, a large
233 * suballocation section and a small suballocation
234 * section. These sections are then suballocated by a
237 * For example, the following break up of the receive
238 * buffer has 6 large suballocations and 10 small
241 * | Large Section | | Small Section |
242 * ------------------------------------------------------------
243 * | | | | | | | | | | | | | | | | | |
245 * LargeOffset SmallOffset
247 nvsp_1_rx_buf_section sections[1];
249 } __packed nvsp_1_msg_send_rx_buf_complete;
252 * This message is sent by the VSC to revoke the receive buffer.
253 * After the VSP completes this transaction, the VSP should never
254 * use the receive buffer again.
256 typedef struct nvsp_1_msg_revoke_rx_buf_ {
258 } __packed nvsp_1_msg_revoke_rx_buf;
261 * This message is used by the VSC to send a send buffer
262 * to the VSP. The VSC can then use the send buffer to
263 * send data to the VSP.
265 typedef struct nvsp_1_msg_send_send_buf_ {
266 uint32_t gpadl_handle;
268 } __packed nvsp_1_msg_send_send_buf;
271 * This message is used by the VSP to acknowledge a send
272 * buffer sent by the VSC. This message must be sent by the
273 * VSP before the VSP uses the sent buffer.
275 typedef struct nvsp_1_msg_send_send_buf_complete_ {
279 * The VSC gets to choose the size of the send buffer and
280 * the VSP gets to choose the sections size of the buffer.
281 * This was done to enable dynamic reconfigurations when
282 * the cost of GPA-direct buffers decreases.
284 uint32_t section_size;
285 } __packed nvsp_1_msg_send_send_buf_complete;
288 * This message is sent by the VSC to revoke the send buffer.
289 * After the VSP completes this transaction, the vsp should never
290 * use the send buffer again.
292 typedef struct nvsp_1_msg_revoke_send_buf_ {
294 } __packed nvsp_1_msg_revoke_send_buf;
297 * This message is used by both the VSP and the VSC to send
298 * an RNDIS message to the opposite channel endpoint.
300 typedef struct nvsp_1_msg_send_rndis_pkt_ {
302 * This field is specified by RNIDS. They assume there's
303 * two different channels of communication. However,
304 * the Network VSP only has one. Therefore, the channel
305 * travels with the RNDIS packet.
310 * This field is used to send part or all of the data
311 * through a send buffer. This values specifies an
312 * index into the send buffer. If the index is
313 * 0xFFFFFFFF, then the send buffer is not being used
314 * and all of the data was sent through other VMBus
317 uint32_t send_buf_section_idx;
318 uint32_t send_buf_section_size;
319 } __packed nvsp_1_msg_send_rndis_pkt;
322 * This message is used by both the VSP and the VSC to complete
323 * a RNDIS message to the opposite channel endpoint. At this
324 * point, the initiator of this message cannot use any resources
325 * associated with the original RNDIS packet.
327 typedef struct nvsp_1_msg_send_rndis_pkt_complete_ {
329 } __packed nvsp_1_msg_send_rndis_pkt_complete;
337 * This message is used by the VSC to send the NDIS version
338 * to the VSP. The VSP can use this information when handling
339 * OIDs sent by the VSC.
341 typedef struct nvsp_2_netvsc_capabilities_ {
346 uint64_t chimney : 1;
348 uint64_t ieee8021q : 1;
349 uint64_t correlationid : 1;
350 uint64_t teaming : 1;
353 } __packed nvsp_2_netvsc_capabilities;
355 typedef struct nvsp_2_msg_send_ndis_config_ {
358 nvsp_2_netvsc_capabilities capabilities;
359 } __packed nvsp_2_msg_send_ndis_config;
362 * NvspMessage2TypeSendChimneyDelegatedBuffer
364 typedef struct nvsp_2_msg_send_chimney_buf_
367 * On WIN7 beta, delegated_obj_max_size is defined as a uint32_t
368 * Since WIN7 RC, it was split into two uint16_t. To have the same
369 * struct layout, delegated_obj_max_size shall be the first field.
371 uint16_t delegated_obj_max_size;
374 * The revision # of chimney protocol used between NVSC and NVSP.
376 * This revision is NOT related to the chimney revision between
377 * NDIS protocol and miniport drivers.
381 uint32_t gpadl_handle;
382 } __packed nvsp_2_msg_send_chimney_buf;
385 /* Unsupported chimney revision 0 (only present in WIN7 beta) */
386 #define NVSP_CHIMNEY_REVISION_0 0
388 /* WIN7 Beta Chimney QFE */
389 #define NVSP_CHIMNEY_REVISION_1 1
391 /* The chimney revision since WIN7 RC */
392 #define NVSP_CHIMNEY_REVISION_2 2
396 * NvspMessage2TypeSendChimneyDelegatedBufferComplete
398 typedef struct nvsp_2_msg_send_chimney_buf_complete_ {
402 * Maximum number outstanding sends and pre-posted receives.
404 * NVSC should not post more than SendQuota/ReceiveQuota packets.
405 * Otherwise, it can block the non-chimney path for an indefinite
407 * (since chimney sends/receives are affected by the remote peer).
409 * Note: NVSP enforces the quota restrictions on a per-VMBCHANNEL
410 * basis. It doesn't enforce the restriction separately for chimney
411 * send/receive. If NVSC doesn't voluntarily enforce "SendQuota",
412 * it may kill its own network connectivity.
416 } __packed nvsp_2_msg_send_chimney_buf_complete;
419 * NvspMessage2TypeRevokeChimneyDelegatedBuffer
421 typedef struct nvsp_2_msg_revoke_chimney_buf_ {
422 uint32_t gpadl_handle;
423 } __packed nvsp_2_msg_revoke_chimney_buf;
426 #define NVSP_CHIMNEY_OBJECT_TYPE_NEIGHBOR 0
427 #define NVSP_CHIMNEY_OBJECT_TYPE_PATH4 1
428 #define NVSP_CHIMNEY_OBJECT_TYPE_PATH6 2
429 #define NVSP_CHIMNEY_OBJECT_TYPE_TCP 3
432 * NvspMessage2TypeAllocateChimneyHandle
434 typedef struct nvsp_2_msg_alloc_chimney_handle_ {
435 uint64_t vsc_context;
436 uint32_t object_type;
437 } __packed nvsp_2_msg_alloc_chimney_handle;
440 * NvspMessage2TypeAllocateChimneyHandleComplete
442 typedef struct nvsp_2_msg_alloc_chimney_handle_complete_ {
444 } __packed nvsp_2_msg_alloc_chimney_handle_complete;
448 * NvspMessage2TypeResumeChimneyRXIndication
450 typedef struct nvsp_2_msg_resume_chimney_rx_indication {
452 * Handle identifying the offloaded connection
454 uint32_t vsp_tcp_handle;
455 } __packed nvsp_2_msg_resume_chimney_rx_indication;
458 #define NVSP_2_MSG_TERMINATE_CHIMNEY_FLAGS_FIRST_STAGE (0x01u)
459 #define NVSP_2_MSG_TERMINATE_CHIMNEY_FLAGS_RESERVED (~(0x01u))
462 * NvspMessage2TypeTerminateChimney
464 typedef struct nvsp_2_msg_terminate_chimney_ {
466 * Handle identifying the offloaded object
471 * Terminate Offload Flags
473 * When set to 0, terminate the offload at the destination NIC
474 * Bit 1-31: Reserved, shall be zero
480 * This field is valid only when bit 0 of flags is clear.
481 * It specifies the index into the premapped delegated
482 * object buffer. The buffer was sent through the
483 * NvspMessage2TypeSendChimneyDelegatedBuffer
484 * message at initialization time.
486 * NVSP will write the delegated state into the delegated
487 * buffer upon upload completion.
492 * This field is valid only when bit 0 of flags is set.
494 * The seqence number of the most recently accepted RX
495 * indication when VSC sets its TCP context into
496 * "terminating" state.
498 * This allows NVSP to determines if there are any in-flight
499 * RX indications for which the acceptance state is still
502 uint64_t last_accepted_rx_seq_no;
504 } __packed nvsp_2_msg_terminate_chimney;
507 #define NVSP_TERMINATE_CHIMNEY_COMPLETE_FLAG_DATA_CORRUPTED 0x0000001u
510 * NvspMessage2TypeTerminateChimneyComplete
512 typedef struct nvsp_2_msg_terminate_chimney_complete_ {
513 uint64_t vsc_context;
515 } __packed nvsp_2_msg_terminate_chimney_complete;
518 * NvspMessage2TypeIndicateChimneyEvent
520 typedef struct nvsp_2_msg_indicate_chimney_event_ {
522 * When VscTcpContext is 0, event_type is an NDIS_STATUS event code
523 * Otherwise, EventType is an TCP connection event (defined in
524 * NdisTcpOffloadEventHandler chimney DDK document).
529 * When VscTcpContext is 0, EventType is an NDIS_STATUS event code
530 * Otherwise, EventType is an TCP connection event specific information
531 * (defined in NdisTcpOffloadEventHandler chimney DDK document).
533 uint32_t event_specific_info;
536 * If not 0, the event is per-TCP connection event. This field
537 * contains the VSC's TCP context.
538 * If 0, the event indication is global.
540 uint64_t vsc_tcp_context;
541 } __packed nvsp_2_msg_indicate_chimney_event;
544 #define NVSP_1_CHIMNEY_SEND_INVALID_OOB_INDEX 0xffffu
545 #define NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX 0xffffu
548 * NvspMessage2TypeSendChimneyPacket
550 typedef struct nvsp_2_msg_send_chimney_pkt_ {
552 * Identify the TCP connection for which this chimney send is
554 uint32_t vsp_tcp_handle;
557 * This field is used to send part or all of the data
558 * through a send buffer. This values specifies an
559 * index into the send buffer. If the index is
560 * 0xFFFF, then the send buffer is not being used
561 * and all of the data was sent through other VMBus
564 uint16_t send_buf_section_index;
565 uint16_t send_buf_section_size;
569 * This an index to the OOB data buffer. If the index is 0xFFFFFFFF,
570 * then there is no OOB data.
572 * This field shall be always 0xFFFFFFFF for now. It is reserved for
575 uint16_t oob_data_index;
578 * DisconnectFlags = 0
579 * Normal chimney send. See MiniportTcpOffloadSend for details.
581 * DisconnectFlags = TCP_DISCONNECT_GRACEFUL_CLOSE (0x01)
582 * Graceful disconnect. See MiniportTcpOffloadDisconnect for details.
584 * DisconnectFlags = TCP_DISCONNECT_ABORTIVE_CLOSE (0x02)
585 * Abortive disconnect. See MiniportTcpOffloadDisconnect for details.
587 uint16_t disconnect_flags;
590 } __packed nvsp_2_msg_send_chimney_pkt;
593 * NvspMessage2TypeSendChimneyPacketComplete
595 typedef struct nvsp_2_msg_send_chimney_pkt_complete_ {
597 * The NDIS_STATUS for the chimney send
602 * Number of bytes that have been sent to the peer (and ACKed by the peer).
604 uint32_t bytes_transferred;
605 } __packed nvsp_2_msg_send_chimney_pkt_complete;
608 #define NVSP_1_CHIMNEY_RECV_FLAG_NO_PUSH 0x0001u
609 #define NVSP_1_CHIMNEY_RECV_INVALID_OOB_INDEX 0xffffu
612 * NvspMessage2TypePostChimneyRecvRequest
614 typedef struct nvsp_2_msg_post_chimney_rx_request_ {
616 * Identify the TCP connection which this chimney receive request
619 uint32_t vsp_tcp_handle;
623 * This an index to the OOB data buffer. If the index is 0xFFFFFFFF,
624 * then there is no OOB data.
626 * This field shall be always 0xFFFFFFFF for now. It is reserved for
629 uint32_t oob_data_index;
633 * When it is set, this is a "no-push" receive.
634 * When it is clear, this is a "push" receive.
636 * Bit 1-15: Reserved and shall be zero
641 * For debugging and diagnoses purpose.
642 * The SeqNo is per TCP connection and starts from 0.
645 } __packed nvsp_2_msg_post_chimney_rx_request;
648 * NvspMessage2TypePostChimneyRecvRequestComplete
650 typedef struct nvsp_2_msg_post_chimney_rx_request_complete_ {
652 * The NDIS_STATUS for the chimney send
657 * Number of bytes that have been sent to the peer (and ACKed by
660 uint32_t bytes_xferred;
661 } __packed nvsp_2_msg_post_chimney_rx_request_complete;
664 * NvspMessage2TypeAllocateReceiveBuffer
666 typedef struct nvsp_2_msg_alloc_rx_buf_ {
668 * Allocation ID to match the allocation request and response
670 uint32_t allocation_id;
673 * Length of the VM shared memory receive buffer that needs to
677 } __packed nvsp_2_msg_alloc_rx_buf;
680 * NvspMessage2TypeAllocateReceiveBufferComplete
682 typedef struct nvsp_2_msg_alloc_rx_buf_complete_ {
684 * The NDIS_STATUS code for buffer allocation
689 * Allocation ID from NVSP_2_MESSAGE_ALLOCATE_RECEIVE_BUFFER
691 uint32_t allocation_id;
694 * GPADL handle for the allocated receive buffer
696 uint32_t gpadl_handle;
699 * Receive buffer ID that is further used in
700 * NvspMessage2SendVmqRndisPacket
703 } __packed nvsp_2_msg_alloc_rx_buf_complete;
706 * NvspMessage2TypeFreeReceiveBuffer
708 typedef struct nvsp_2_msg_free_rx_buf_ {
710 * Receive buffer ID previous returned in
711 * NvspMessage2TypeAllocateReceiveBufferComplete message
714 } __packed nvsp_2_msg_free_rx_buf;
717 * This structure is used in defining the buffers in
718 * NVSP_2_MESSAGE_SEND_VMQ_RNDIS_PACKET structure
720 typedef struct nvsp_xfer_page_range_ {
722 * Specifies the ID of the receive buffer that has the buffer. This
723 * ID can be the general receive buffer ID specified in
724 * NvspMessage1TypeSendReceiveBuffer or it can be the shared memory
725 * receive buffer ID allocated by the VSC and specified in
726 * NvspMessage2TypeAllocateReceiveBufferComplete message
728 uint64_t xfer_page_set_id;
736 * Offset in bytes from the beginning of the buffer
738 uint32_t byte_offset;
739 } __packed nvsp_xfer_page_range;
742 * NvspMessage2SendVmqRndisPacket
744 typedef struct nvsp_2_msg_send_vmq_rndis_pkt_ {
746 * This field is specified by RNIDS. They assume there's
747 * two different channels of communication. However,
748 * the Network VSP only has one. Therefore, the channel
749 * travels with the RNDIS packet. It must be RMC_DATA
751 uint32_t channel_type;
754 * Only the Range element corresponding to the RNDIS header of
755 * the first RNDIS message in the multiple RNDIS messages sent
756 * in one NVSP message. Information about the data portions as well
757 * as the subsequent RNDIS messages in the same NVSP message are
758 * embedded in the RNDIS header itself
760 nvsp_xfer_page_range range;
761 } __packed nvsp_2_msg_send_vmq_rndis_pkt;
764 * This message is used by the VSC to complete
765 * a RNDIS VMQ message to the VSP. At this point,
766 * the initiator of this message can use any resources
767 * associated with the original RNDIS VMQ packet.
769 typedef struct nvsp_2_msg_send_vmq_rndis_pkt_complete_
772 } __packed nvsp_2_msg_send_vmq_rndis_pkt_complete;
775 typedef union nvsp_1_msg_uber_ {
776 nvsp_1_msg_send_ndis_version send_ndis_vers;
778 nvsp_1_msg_send_rx_buf send_rx_buf;
779 nvsp_1_msg_send_rx_buf_complete send_rx_buf_complete;
780 nvsp_1_msg_revoke_rx_buf revoke_rx_buf;
782 nvsp_1_msg_send_send_buf send_send_buf;
783 nvsp_1_msg_send_send_buf_complete send_send_buf_complete;
784 nvsp_1_msg_revoke_send_buf revoke_send_buf;
786 nvsp_1_msg_send_rndis_pkt send_rndis_pkt;
787 nvsp_1_msg_send_rndis_pkt_complete send_rndis_pkt_complete;
788 } __packed nvsp_1_msg_uber;
791 typedef union nvsp_2_msg_uber_ {
792 nvsp_2_msg_send_ndis_config send_ndis_config;
794 nvsp_2_msg_send_chimney_buf send_chimney_buf;
795 nvsp_2_msg_send_chimney_buf_complete send_chimney_buf_complete;
796 nvsp_2_msg_revoke_chimney_buf revoke_chimney_buf;
798 nvsp_2_msg_resume_chimney_rx_indication resume_chimney_rx_indication;
799 nvsp_2_msg_terminate_chimney terminate_chimney;
800 nvsp_2_msg_terminate_chimney_complete terminate_chimney_complete;
801 nvsp_2_msg_indicate_chimney_event indicate_chimney_event;
803 nvsp_2_msg_send_chimney_pkt send_chimney_packet;
804 nvsp_2_msg_send_chimney_pkt_complete send_chimney_packet_complete;
805 nvsp_2_msg_post_chimney_rx_request post_chimney_rx_request;
806 nvsp_2_msg_post_chimney_rx_request_complete
807 post_chimney_rx_request_complete;
809 nvsp_2_msg_alloc_rx_buf alloc_rx_buffer;
810 nvsp_2_msg_alloc_rx_buf_complete alloc_rx_buffer_complete;
811 nvsp_2_msg_free_rx_buf free_rx_buffer;
813 nvsp_2_msg_send_vmq_rndis_pkt send_vmq_rndis_pkt;
814 nvsp_2_msg_send_vmq_rndis_pkt_complete send_vmq_rndis_pkt_complete;
815 nvsp_2_msg_alloc_chimney_handle alloc_chimney_handle;
816 nvsp_2_msg_alloc_chimney_handle_complete alloc_chimney_handle_complete;
817 } __packed nvsp_2_msg_uber;
820 typedef union nvsp_all_msgs_ {
821 nvsp_msg_init_uber init_msgs;
822 nvsp_1_msg_uber vers_1_msgs;
823 nvsp_2_msg_uber vers_2_msgs;
824 } __packed nvsp_all_msgs;
829 typedef struct nvsp_msg_ {
836 * The following arguably belongs in a separate header file
843 #define NETVSC_SEND_BUFFER_SIZE (64*1024) /* 64K */
844 #define NETVSC_SEND_BUFFER_ID 0xface
847 #define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024) /* 1MB */
849 #define NETVSC_RECEIVE_BUFFER_ID 0xcafe
851 #define NETVSC_RECEIVE_SG_COUNT 1
853 /* Preallocated receive packets */
854 #define NETVSC_RECEIVE_PACKETLIST_COUNT 256
857 * Maximum MTU we permit to be configured for a netvsc interface.
858 * When the code was developed, a max MTU of 12232 was tested and
859 * proven to work. 9K is a reasonable maximum for an Ethernet.
861 #define NETVSC_MAX_CONFIGURABLE_MTU (9 * 1024)
868 * Per netvsc channel-specific
870 typedef struct netvsc_dev_ {
871 struct hv_device *dev;
872 int num_outstanding_sends;
874 /* List of free preallocated NETVSC_PACKET to represent RX packet */
875 STAILQ_HEAD(PQ, netvsc_packet_) myrx_packet_list;
876 struct mtx rx_pkt_list_lock;
878 /* Send buffer allocated by us but manages by NetVSP */
880 uint32_t send_buf_size;
881 uint32_t send_buf_gpadl_handle;
882 uint32_t send_section_size;
884 /* Receive buffer allocated by us but managed by NetVSP */
886 uint32_t rx_buf_size;
887 uint32_t rx_buf_gpadl_handle;
888 uint32_t rx_section_count;
889 nvsp_1_rx_buf_section *rx_sections;
891 /* Used for NetVSP initialization protocol */
892 struct sema channel_init_sema;
893 nvsp_msg channel_init_packet;
895 nvsp_msg revoke_packet;
896 /*uint8_t hw_mac_addr[HW_MACADDR_LEN];*/
898 /* Holds rndis device info */
901 hv_bool_uint8_t destroy;
902 /* Negotiated NVSP version */
903 uint32_t nvsp_version;
907 typedef void (*pfn_on_send_rx_completion)(void *);
909 #define NETVSC_DEVICE_RING_BUFFER_SIZE (64 * PAGE_SIZE)
910 #define NETVSC_PACKET_MAXPAGE 16
913 typedef struct xfer_page_packet_ {
915 * This needs to be here because the network RX code casts
916 * an instantiation of this structure to a netvsc_packet.
918 STAILQ_ENTRY(netvsc_packet_) mylist_entry;
923 typedef struct netvsc_packet_ {
925 * List used when enqueued on &net_dev->rx_packet_list,
926 * and when enqueued within the netvsc code
928 STAILQ_ENTRY(netvsc_packet_) mylist_entry;
929 struct hv_device *device;
930 hv_bool_uint8_t is_data_pkt; /* One byte */
932 xfer_page_packet *xfer_page_pkt;
937 uint64_t rx_completion_tid;
938 void *rx_completion_context;
939 /* This is no longer used */
940 pfn_on_send_rx_completion on_rx_completion;
943 uint64_t send_completion_tid;
944 void *send_completion_context;
945 /* Still used in netvsc and filter code */
946 pfn_on_send_rx_completion on_send_completion;
951 uint32_t tot_data_buf_len;
952 uint32_t page_buf_count;
953 hv_vmbus_page_buffer page_buffers[NETVSC_PACKET_MAXPAGE];
957 uint8_t mac_addr[6]; /* Assumption unsigned long */
958 hv_bool_uint8_t link_state;
959 } netvsc_device_info;
962 * Device-specific softc structure
964 typedef struct hn_softc {
965 struct ifnet *hn_ifp;
966 struct arpcom arpcom;
973 struct hv_device *hn_dev_obj;
981 extern int hv_promisc_mode;
983 extern void netvsc_linkstatus_callback(struct hv_device *device_obj,
985 extern int netvsc_recv(struct hv_device *device_obj, netvsc_packet *packet);
986 extern void netvsc_xmit_completion(void *context);
988 extern void hv_nv_on_receive_completion(void *context);
989 extern netvsc_dev *hv_nv_on_device_add(struct hv_device *device, void *additional_info);
990 extern int hv_nv_on_device_remove(struct hv_device *device,
991 boolean_t destroy_channel);
992 extern int hv_nv_on_send(struct hv_device *device, netvsc_packet *pkt);
994 #endif /* __HV_NET_VSC_H__ */