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.
32 * HyperV vmbus (virtual machine bus) network VSC (virtual services client)
35 * (Updated from unencumbered NvspProtocol.h)
38 #ifndef __HV_NET_VSC_H__
39 #define __HV_NET_VSC_H__
41 #include <sys/types.h>
42 #include <sys/param.h>
46 #include <dev/hyperv/include/hyperv.h>
49 #define NVSP_INVALID_PROTOCOL_VERSION (0xFFFFFFFF)
51 #define NVSP_PROTOCOL_VERSION_1 2
52 #define NVSP_PROTOCOL_VERSION_2 0x30002
53 #define NVSP_MIN_PROTOCOL_VERSION (NVSP_PROTOCOL_VERSION_1)
54 #define NVSP_MAX_PROTOCOL_VERSION (NVSP_PROTOCOL_VERSION_2)
56 #define NVSP_PROTOCOL_VERSION_CURRENT NVSP_PROTOCOL_VERSION_2
58 #define NVSP_OPERATIONAL_STATUS_OK (0x00000000)
59 #define NVSP_OPERATIONAL_STATUS_DEGRADED (0x00000001)
60 #define NVSP_OPERATIONAL_STATUS_NONRECOVERABLE (0x00000002)
61 #define NVSP_OPERATIONAL_STATUS_NO_CONTACT (0x00000003)
62 #define NVSP_OPERATIONAL_STATUS_LOST_COMMUNICATION (0x00000004)
65 * Maximun number of transfer pages (packets) the VSP will use on a receive
67 #define NVSP_MAX_PACKETS_PER_RECEIVE 375
70 typedef enum nvsp_msg_type_ {
71 nvsp_msg_type_none = 0,
76 nvsp_msg_type_init = 1,
77 nvsp_msg_type_init_complete = 2,
79 nvsp_version_msg_start = 100,
84 nvsp_msg_1_type_send_ndis_vers = nvsp_version_msg_start,
86 nvsp_msg_1_type_send_rx_buf,
87 nvsp_msg_1_type_send_rx_buf_complete,
88 nvsp_msg_1_type_revoke_rx_buf,
90 nvsp_msg_1_type_send_send_buf,
91 nvsp_msg_1_type_send_send_buf_complete,
92 nvsp_msg_1_type_revoke_send_buf,
94 nvsp_msg_1_type_send_rndis_pkt,
95 nvsp_msg_1_type_send_rndis_pkt_complete,
100 nvsp_msg_2_type_send_chimney_delegated_buf,
101 nvsp_msg_2_type_send_chimney_delegated_buf_complete,
102 nvsp_msg_2_type_revoke_chimney_delegated_buf,
104 nvsp_msg_2_type_resume_chimney_rx_indication,
106 nvsp_msg_2_type_terminate_chimney,
107 nvsp_msg_2_type_terminate_chimney_complete,
109 nvsp_msg_2_type_indicate_chimney_event,
111 nvsp_msg_2_type_send_chimney_packet,
112 nvsp_msg_2_type_send_chimney_packet_complete,
114 nvsp_msg_2_type_post_chimney_rx_request,
115 nvsp_msg_2_type_post_chimney_rx_request_complete,
117 nvsp_msg_2_type_alloc_rx_buf,
118 nvsp_msg_2_type_alloc_rx_buf_complete,
120 nvsp_msg_2_type_free_rx_buf,
122 nvsp_msg_2_send_vmq_rndis_pkt,
123 nvsp_msg_2_send_vmq_rndis_pkt_complete,
125 nvsp_msg_2_type_send_ndis_config,
127 nvsp_msg_2_type_alloc_chimney_handle,
128 nvsp_msg_2_type_alloc_chimney_handle_complete,
131 typedef enum nvsp_status_ {
132 nvsp_status_none = 0,
136 nvsp_status_prot_vers_range_too_new,
138 nvsp_status_prot_vers_range_too_old,
139 nvsp_status_invalid_rndis_pkt,
144 typedef struct nvsp_msg_hdr_ {
146 } __packed nvsp_msg_hdr;
153 * This message is used by the VSC to initialize the channel
154 * after the channels has been opened. This message should
155 * never include anything other then versioning (i.e. this
156 * message will be the same for ever).
158 * Forever is a long time. The values have been redefined
159 * in Win7 to indicate major and minor protocol version
162 typedef struct nvsp_msg_init_ {
165 uint16_t minor_protocol_version;
166 uint16_t major_protocol_version;
168 /* Formerly min_protocol_version */
169 uint32_t protocol_version;
171 /* Formerly max_protocol_version */
172 uint32_t protocol_version_2;
173 } __packed nvsp_msg_init;
176 * This message is used by the VSP to complete the initialization
177 * of the channel. This message should never include anything other
178 * then versioning (i.e. this message will be the same forever).
180 typedef struct nvsp_msg_init_complete_ {
182 uint32_t negotiated_prot_vers;
183 uint32_t max_mdl_chain_len;
185 } __packed nvsp_msg_init_complete;
187 typedef union nvsp_msg_init_uber_ {
189 nvsp_msg_init_complete init_compl;
190 } __packed nvsp_msg_init_uber;
197 * This message is used by the VSC to send the NDIS version
198 * to the VSP. The VSP can use this information when handling
199 * OIDs sent by the VSC.
201 typedef struct nvsp_1_msg_send_ndis_version_ {
202 uint32_t ndis_major_vers;
204 uint32_t ndis_minor_vers;
205 } __packed nvsp_1_msg_send_ndis_version;
208 * This message is used by the VSC to send a receive buffer
209 * to the VSP. The VSP can then use the receive buffer to
210 * send data to the VSC.
212 typedef struct nvsp_1_msg_send_rx_buf_ {
213 uint32_t gpadl_handle;
215 } __packed nvsp_1_msg_send_rx_buf;
217 typedef struct nvsp_1_rx_buf_section_ {
219 uint32_t sub_allocation_size;
220 uint32_t num_sub_allocations;
222 } __packed nvsp_1_rx_buf_section;
225 * This message is used by the VSP to acknowledge a receive
226 * buffer send by the VSC. This message must be sent by the
227 * VSP before the VSP uses the receive buffer.
229 typedef struct nvsp_1_msg_send_rx_buf_complete_ {
231 uint32_t num_sections;
234 * The receive buffer is split into two parts, a large
235 * suballocation section and a small suballocation
236 * section. These sections are then suballocated by a
239 * For example, the following break up of the receive
240 * buffer has 6 large suballocations and 10 small
243 * | Large Section | | Small Section |
244 * ------------------------------------------------------------
245 * | | | | | | | | | | | | | | | | | |
247 * LargeOffset SmallOffset
249 nvsp_1_rx_buf_section sections[1];
251 } __packed nvsp_1_msg_send_rx_buf_complete;
254 * This message is sent by the VSC to revoke the receive buffer.
255 * After the VSP completes this transaction, the VSP should never
256 * use the receive buffer again.
258 typedef struct nvsp_1_msg_revoke_rx_buf_ {
260 } __packed nvsp_1_msg_revoke_rx_buf;
263 * This message is used by the VSC to send a send buffer
264 * to the VSP. The VSC can then use the send buffer to
265 * send data to the VSP.
267 typedef struct nvsp_1_msg_send_send_buf_ {
268 uint32_t gpadl_handle;
270 } __packed nvsp_1_msg_send_send_buf;
273 * This message is used by the VSP to acknowledge a send
274 * buffer sent by the VSC. This message must be sent by the
275 * VSP before the VSP uses the sent buffer.
277 typedef struct nvsp_1_msg_send_send_buf_complete_ {
281 * The VSC gets to choose the size of the send buffer and
282 * the VSP gets to choose the sections size of the buffer.
283 * This was done to enable dynamic reconfigurations when
284 * the cost of GPA-direct buffers decreases.
286 uint32_t section_size;
287 } __packed nvsp_1_msg_send_send_buf_complete;
290 * This message is sent by the VSC to revoke the send buffer.
291 * After the VSP completes this transaction, the vsp should never
292 * use the send buffer again.
294 typedef struct nvsp_1_msg_revoke_send_buf_ {
296 } __packed nvsp_1_msg_revoke_send_buf;
299 * This message is used by both the VSP and the VSC to send
300 * an RNDIS message to the opposite channel endpoint.
302 typedef struct nvsp_1_msg_send_rndis_pkt_ {
304 * This field is specified by RNIDS. They assume there's
305 * two different channels of communication. However,
306 * the Network VSP only has one. Therefore, the channel
307 * travels with the RNDIS packet.
312 * This field is used to send part or all of the data
313 * through a send buffer. This values specifies an
314 * index into the send buffer. If the index is
315 * 0xFFFFFFFF, then the send buffer is not being used
316 * and all of the data was sent through other VMBus
319 uint32_t send_buf_section_idx;
320 uint32_t send_buf_section_size;
321 } __packed nvsp_1_msg_send_rndis_pkt;
324 * This message is used by both the VSP and the VSC to complete
325 * a RNDIS message to the opposite channel endpoint. At this
326 * point, the initiator of this message cannot use any resources
327 * associated with the original RNDIS packet.
329 typedef struct nvsp_1_msg_send_rndis_pkt_complete_ {
331 } __packed nvsp_1_msg_send_rndis_pkt_complete;
339 * This message is used by the VSC to send the NDIS version
340 * to the VSP. The VSP can use this information when handling
341 * OIDs sent by the VSC.
343 typedef struct nvsp_2_netvsc_capabilities_ {
348 uint64_t chimney : 1;
350 uint64_t ieee8021q : 1;
351 uint64_t correlationid : 1;
352 uint64_t teaming : 1;
355 } __packed nvsp_2_netvsc_capabilities;
357 typedef struct nvsp_2_msg_send_ndis_config_ {
360 nvsp_2_netvsc_capabilities capabilities;
361 } __packed nvsp_2_msg_send_ndis_config;
364 * NvspMessage2TypeSendChimneyDelegatedBuffer
366 typedef struct nvsp_2_msg_send_chimney_buf_
369 * On WIN7 beta, delegated_obj_max_size is defined as a uint32_t
370 * Since WIN7 RC, it was split into two uint16_t. To have the same
371 * struct layout, delegated_obj_max_size shall be the first field.
373 uint16_t delegated_obj_max_size;
376 * The revision # of chimney protocol used between NVSC and NVSP.
378 * This revision is NOT related to the chimney revision between
379 * NDIS protocol and miniport drivers.
383 uint32_t gpadl_handle;
384 } __packed nvsp_2_msg_send_chimney_buf;
387 /* Unsupported chimney revision 0 (only present in WIN7 beta) */
388 #define NVSP_CHIMNEY_REVISION_0 0
390 /* WIN7 Beta Chimney QFE */
391 #define NVSP_CHIMNEY_REVISION_1 1
393 /* The chimney revision since WIN7 RC */
394 #define NVSP_CHIMNEY_REVISION_2 2
398 * NvspMessage2TypeSendChimneyDelegatedBufferComplete
400 typedef struct nvsp_2_msg_send_chimney_buf_complete_ {
404 * Maximum number outstanding sends and pre-posted receives.
406 * NVSC should not post more than SendQuota/ReceiveQuota packets.
407 * Otherwise, it can block the non-chimney path for an indefinite
409 * (since chimney sends/receives are affected by the remote peer).
411 * Note: NVSP enforces the quota restrictions on a per-VMBCHANNEL
412 * basis. It doesn't enforce the restriction separately for chimney
413 * send/receive. If NVSC doesn't voluntarily enforce "SendQuota",
414 * it may kill its own network connectivity.
418 } __packed nvsp_2_msg_send_chimney_buf_complete;
421 * NvspMessage2TypeRevokeChimneyDelegatedBuffer
423 typedef struct nvsp_2_msg_revoke_chimney_buf_ {
424 uint32_t gpadl_handle;
425 } __packed nvsp_2_msg_revoke_chimney_buf;
428 #define NVSP_CHIMNEY_OBJECT_TYPE_NEIGHBOR 0
429 #define NVSP_CHIMNEY_OBJECT_TYPE_PATH4 1
430 #define NVSP_CHIMNEY_OBJECT_TYPE_PATH6 2
431 #define NVSP_CHIMNEY_OBJECT_TYPE_TCP 3
434 * NvspMessage2TypeAllocateChimneyHandle
436 typedef struct nvsp_2_msg_alloc_chimney_handle_ {
437 uint64_t vsc_context;
438 uint32_t object_type;
439 } __packed nvsp_2_msg_alloc_chimney_handle;
442 * NvspMessage2TypeAllocateChimneyHandleComplete
444 typedef struct nvsp_2_msg_alloc_chimney_handle_complete_ {
446 } __packed nvsp_2_msg_alloc_chimney_handle_complete;
450 * NvspMessage2TypeResumeChimneyRXIndication
452 typedef struct nvsp_2_msg_resume_chimney_rx_indication {
454 * Handle identifying the offloaded connection
456 uint32_t vsp_tcp_handle;
457 } __packed nvsp_2_msg_resume_chimney_rx_indication;
460 #define NVSP_2_MSG_TERMINATE_CHIMNEY_FLAGS_FIRST_STAGE (0x01u)
461 #define NVSP_2_MSG_TERMINATE_CHIMNEY_FLAGS_RESERVED (~(0x01u))
464 * NvspMessage2TypeTerminateChimney
466 typedef struct nvsp_2_msg_terminate_chimney_ {
468 * Handle identifying the offloaded object
473 * Terminate Offload Flags
475 * When set to 0, terminate the offload at the destination NIC
476 * Bit 1-31: Reserved, shall be zero
482 * This field is valid only when bit 0 of flags is clear.
483 * It specifies the index into the premapped delegated
484 * object buffer. The buffer was sent through the
485 * NvspMessage2TypeSendChimneyDelegatedBuffer
486 * message at initialization time.
488 * NVSP will write the delegated state into the delegated
489 * buffer upon upload completion.
494 * This field is valid only when bit 0 of flags is set.
496 * The seqence number of the most recently accepted RX
497 * indication when VSC sets its TCP context into
498 * "terminating" state.
500 * This allows NVSP to determines if there are any in-flight
501 * RX indications for which the acceptance state is still
504 uint64_t last_accepted_rx_seq_no;
506 } __packed nvsp_2_msg_terminate_chimney;
509 #define NVSP_TERMINATE_CHIMNEY_COMPLETE_FLAG_DATA_CORRUPTED 0x0000001u
512 * NvspMessage2TypeTerminateChimneyComplete
514 typedef struct nvsp_2_msg_terminate_chimney_complete_ {
515 uint64_t vsc_context;
517 } __packed nvsp_2_msg_terminate_chimney_complete;
520 * NvspMessage2TypeIndicateChimneyEvent
522 typedef struct nvsp_2_msg_indicate_chimney_event_ {
524 * When VscTcpContext is 0, event_type is an NDIS_STATUS event code
525 * Otherwise, EventType is an TCP connection event (defined in
526 * NdisTcpOffloadEventHandler chimney DDK document).
531 * When VscTcpContext is 0, EventType is an NDIS_STATUS event code
532 * Otherwise, EventType is an TCP connection event specific information
533 * (defined in NdisTcpOffloadEventHandler chimney DDK document).
535 uint32_t event_specific_info;
538 * If not 0, the event is per-TCP connection event. This field
539 * contains the VSC's TCP context.
540 * If 0, the event indication is global.
542 uint64_t vsc_tcp_context;
543 } __packed nvsp_2_msg_indicate_chimney_event;
546 #define NVSP_1_CHIMNEY_SEND_INVALID_OOB_INDEX 0xffffu
547 #define NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX 0xffffu
550 * NvspMessage2TypeSendChimneyPacket
552 typedef struct nvsp_2_msg_send_chimney_pkt_ {
554 * Identify the TCP connection for which this chimney send is
556 uint32_t vsp_tcp_handle;
559 * This field is used to send part or all of the data
560 * through a send buffer. This values specifies an
561 * index into the send buffer. If the index is
562 * 0xFFFF, then the send buffer is not being used
563 * and all of the data was sent through other VMBus
566 uint16_t send_buf_section_index;
567 uint16_t send_buf_section_size;
571 * This an index to the OOB data buffer. If the index is 0xFFFFFFFF,
572 * then there is no OOB data.
574 * This field shall be always 0xFFFFFFFF for now. It is reserved for
577 uint16_t oob_data_index;
580 * DisconnectFlags = 0
581 * Normal chimney send. See MiniportTcpOffloadSend for details.
583 * DisconnectFlags = TCP_DISCONNECT_GRACEFUL_CLOSE (0x01)
584 * Graceful disconnect. See MiniportTcpOffloadDisconnect for details.
586 * DisconnectFlags = TCP_DISCONNECT_ABORTIVE_CLOSE (0x02)
587 * Abortive disconnect. See MiniportTcpOffloadDisconnect for details.
589 uint16_t disconnect_flags;
592 } __packed nvsp_2_msg_send_chimney_pkt;
595 * NvspMessage2TypeSendChimneyPacketComplete
597 typedef struct nvsp_2_msg_send_chimney_pkt_complete_ {
599 * The NDIS_STATUS for the chimney send
604 * Number of bytes that have been sent to the peer (and ACKed by the peer).
606 uint32_t bytes_transferred;
607 } __packed nvsp_2_msg_send_chimney_pkt_complete;
610 #define NVSP_1_CHIMNEY_RECV_FLAG_NO_PUSH 0x0001u
611 #define NVSP_1_CHIMNEY_RECV_INVALID_OOB_INDEX 0xffffu
614 * NvspMessage2TypePostChimneyRecvRequest
616 typedef struct nvsp_2_msg_post_chimney_rx_request_ {
618 * Identify the TCP connection which this chimney receive request
621 uint32_t vsp_tcp_handle;
625 * This an index to the OOB data buffer. If the index is 0xFFFFFFFF,
626 * then there is no OOB data.
628 * This field shall be always 0xFFFFFFFF for now. It is reserved for
631 uint32_t oob_data_index;
635 * When it is set, this is a "no-push" receive.
636 * When it is clear, this is a "push" receive.
638 * Bit 1-15: Reserved and shall be zero
643 * For debugging and diagnoses purpose.
644 * The SeqNo is per TCP connection and starts from 0.
647 } __packed nvsp_2_msg_post_chimney_rx_request;
650 * NvspMessage2TypePostChimneyRecvRequestComplete
652 typedef struct nvsp_2_msg_post_chimney_rx_request_complete_ {
654 * The NDIS_STATUS for the chimney send
659 * Number of bytes that have been sent to the peer (and ACKed by
662 uint32_t bytes_xferred;
663 } __packed nvsp_2_msg_post_chimney_rx_request_complete;
666 * NvspMessage2TypeAllocateReceiveBuffer
668 typedef struct nvsp_2_msg_alloc_rx_buf_ {
670 * Allocation ID to match the allocation request and response
672 uint32_t allocation_id;
675 * Length of the VM shared memory receive buffer that needs to
679 } __packed nvsp_2_msg_alloc_rx_buf;
682 * NvspMessage2TypeAllocateReceiveBufferComplete
684 typedef struct nvsp_2_msg_alloc_rx_buf_complete_ {
686 * The NDIS_STATUS code for buffer allocation
691 * Allocation ID from NVSP_2_MESSAGE_ALLOCATE_RECEIVE_BUFFER
693 uint32_t allocation_id;
696 * GPADL handle for the allocated receive buffer
698 uint32_t gpadl_handle;
701 * Receive buffer ID that is further used in
702 * NvspMessage2SendVmqRndisPacket
705 } __packed nvsp_2_msg_alloc_rx_buf_complete;
708 * NvspMessage2TypeFreeReceiveBuffer
710 typedef struct nvsp_2_msg_free_rx_buf_ {
712 * Receive buffer ID previous returned in
713 * NvspMessage2TypeAllocateReceiveBufferComplete message
716 } __packed nvsp_2_msg_free_rx_buf;
719 * This structure is used in defining the buffers in
720 * NVSP_2_MESSAGE_SEND_VMQ_RNDIS_PACKET structure
722 typedef struct nvsp_xfer_page_range_ {
724 * Specifies the ID of the receive buffer that has the buffer. This
725 * ID can be the general receive buffer ID specified in
726 * NvspMessage1TypeSendReceiveBuffer or it can be the shared memory
727 * receive buffer ID allocated by the VSC and specified in
728 * NvspMessage2TypeAllocateReceiveBufferComplete message
730 uint64_t xfer_page_set_id;
738 * Offset in bytes from the beginning of the buffer
740 uint32_t byte_offset;
741 } __packed nvsp_xfer_page_range;
744 * NvspMessage2SendVmqRndisPacket
746 typedef struct nvsp_2_msg_send_vmq_rndis_pkt_ {
748 * This field is specified by RNIDS. They assume there's
749 * two different channels of communication. However,
750 * the Network VSP only has one. Therefore, the channel
751 * travels with the RNDIS packet. It must be RMC_DATA
753 uint32_t channel_type;
756 * Only the Range element corresponding to the RNDIS header of
757 * the first RNDIS message in the multiple RNDIS messages sent
758 * in one NVSP message. Information about the data portions as well
759 * as the subsequent RNDIS messages in the same NVSP message are
760 * embedded in the RNDIS header itself
762 nvsp_xfer_page_range range;
763 } __packed nvsp_2_msg_send_vmq_rndis_pkt;
766 * This message is used by the VSC to complete
767 * a RNDIS VMQ message to the VSP. At this point,
768 * the initiator of this message can use any resources
769 * associated with the original RNDIS VMQ packet.
771 typedef struct nvsp_2_msg_send_vmq_rndis_pkt_complete_
774 } __packed nvsp_2_msg_send_vmq_rndis_pkt_complete;
777 typedef union nvsp_1_msg_uber_ {
778 nvsp_1_msg_send_ndis_version send_ndis_vers;
780 nvsp_1_msg_send_rx_buf send_rx_buf;
781 nvsp_1_msg_send_rx_buf_complete send_rx_buf_complete;
782 nvsp_1_msg_revoke_rx_buf revoke_rx_buf;
784 nvsp_1_msg_send_send_buf send_send_buf;
785 nvsp_1_msg_send_send_buf_complete send_send_buf_complete;
786 nvsp_1_msg_revoke_send_buf revoke_send_buf;
788 nvsp_1_msg_send_rndis_pkt send_rndis_pkt;
789 nvsp_1_msg_send_rndis_pkt_complete send_rndis_pkt_complete;
790 } __packed nvsp_1_msg_uber;
793 typedef union nvsp_2_msg_uber_ {
794 nvsp_2_msg_send_ndis_config send_ndis_config;
796 nvsp_2_msg_send_chimney_buf send_chimney_buf;
797 nvsp_2_msg_send_chimney_buf_complete send_chimney_buf_complete;
798 nvsp_2_msg_revoke_chimney_buf revoke_chimney_buf;
800 nvsp_2_msg_resume_chimney_rx_indication resume_chimney_rx_indication;
801 nvsp_2_msg_terminate_chimney terminate_chimney;
802 nvsp_2_msg_terminate_chimney_complete terminate_chimney_complete;
803 nvsp_2_msg_indicate_chimney_event indicate_chimney_event;
805 nvsp_2_msg_send_chimney_pkt send_chimney_packet;
806 nvsp_2_msg_send_chimney_pkt_complete send_chimney_packet_complete;
807 nvsp_2_msg_post_chimney_rx_request post_chimney_rx_request;
808 nvsp_2_msg_post_chimney_rx_request_complete
809 post_chimney_rx_request_complete;
811 nvsp_2_msg_alloc_rx_buf alloc_rx_buffer;
812 nvsp_2_msg_alloc_rx_buf_complete alloc_rx_buffer_complete;
813 nvsp_2_msg_free_rx_buf free_rx_buffer;
815 nvsp_2_msg_send_vmq_rndis_pkt send_vmq_rndis_pkt;
816 nvsp_2_msg_send_vmq_rndis_pkt_complete send_vmq_rndis_pkt_complete;
817 nvsp_2_msg_alloc_chimney_handle alloc_chimney_handle;
818 nvsp_2_msg_alloc_chimney_handle_complete alloc_chimney_handle_complete;
819 } __packed nvsp_2_msg_uber;
822 typedef union nvsp_all_msgs_ {
823 nvsp_msg_init_uber init_msgs;
824 nvsp_1_msg_uber vers_1_msgs;
825 nvsp_2_msg_uber vers_2_msgs;
826 } __packed nvsp_all_msgs;
831 typedef struct nvsp_msg_ {
838 * The following arguably belongs in a separate header file
845 #define NETVSC_SEND_BUFFER_SIZE (64*1024) /* 64K */
846 #define NETVSC_SEND_BUFFER_ID 0xface
849 #define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024) /* 1MB */
851 #define NETVSC_RECEIVE_BUFFER_ID 0xcafe
853 #define NETVSC_RECEIVE_SG_COUNT 1
855 /* Preallocated receive packets */
856 #define NETVSC_RECEIVE_PACKETLIST_COUNT 256
859 * Maximum MTU we permit to be configured for a netvsc interface.
860 * When the code was developed, a max MTU of 12232 was tested and
861 * proven to work. 9K is a reasonable maximum for an Ethernet.
863 #define NETVSC_MAX_CONFIGURABLE_MTU (9 * 1024)
870 * Per netvsc channel-specific
872 typedef struct netvsc_dev_ {
873 struct hv_device *dev;
874 int num_outstanding_sends;
876 /* List of free preallocated NETVSC_PACKET to represent RX packet */
877 STAILQ_HEAD(PQ, netvsc_packet_) myrx_packet_list;
878 struct mtx rx_pkt_list_lock;
880 /* Send buffer allocated by us but manages by NetVSP */
882 uint32_t send_buf_size;
883 uint32_t send_buf_gpadl_handle;
884 uint32_t send_section_size;
886 /* Receive buffer allocated by us but managed by NetVSP */
888 uint32_t rx_buf_size;
889 uint32_t rx_buf_gpadl_handle;
890 uint32_t rx_section_count;
891 nvsp_1_rx_buf_section *rx_sections;
893 /* Used for NetVSP initialization protocol */
894 struct sema channel_init_sema;
895 nvsp_msg channel_init_packet;
897 nvsp_msg revoke_packet;
898 /*uint8_t hw_mac_addr[HW_MACADDR_LEN];*/
900 /* Holds rndis device info */
903 hv_bool_uint8_t destroy;
904 /* Negotiated NVSP version */
905 uint32_t nvsp_version;
909 typedef void (*pfn_on_send_rx_completion)(void *);
911 #define NETVSC_DEVICE_RING_BUFFER_SIZE (64 * PAGE_SIZE)
912 #define NETVSC_PACKET_MAXPAGE 16
915 typedef struct xfer_page_packet_ {
917 * This needs to be here because the network RX code casts
918 * an instantiation of this structure to a netvsc_packet.
920 STAILQ_ENTRY(netvsc_packet_) mylist_entry;
925 typedef struct netvsc_packet_ {
927 * List used when enqueued on &net_dev->rx_packet_list,
928 * and when enqueued within the netvsc code
930 STAILQ_ENTRY(netvsc_packet_) mylist_entry;
931 struct hv_device *device;
932 hv_bool_uint8_t is_data_pkt; /* One byte */
934 xfer_page_packet *xfer_page_pkt;
939 uint64_t rx_completion_tid;
940 void *rx_completion_context;
941 /* This is no longer used */
942 pfn_on_send_rx_completion on_rx_completion;
945 uint64_t send_completion_tid;
946 void *send_completion_context;
947 /* Still used in netvsc and filter code */
948 pfn_on_send_rx_completion on_send_completion;
953 uint32_t tot_data_buf_len;
954 uint32_t page_buf_count;
955 hv_vmbus_page_buffer page_buffers[NETVSC_PACKET_MAXPAGE];
959 uint8_t mac_addr[6]; /* Assumption unsigned long */
960 hv_bool_uint8_t link_state;
961 } netvsc_device_info;
964 * Device-specific softc structure
966 typedef struct hn_softc {
967 struct ifnet *hn_ifp;
968 struct arpcom arpcom;
975 /* See hv_netvsc_drv_freebsd.c for rules on how to use */
977 struct hv_device *hn_dev_obj;
985 extern int hv_promisc_mode;
987 extern void netvsc_linkstatus_callback(struct hv_device *device_obj,
989 extern int netvsc_recv(struct hv_device *device_obj, netvsc_packet *packet);
990 extern void netvsc_xmit_completion(void *context);
992 extern void hv_nv_on_receive_completion(void *context);
993 extern netvsc_dev *hv_nv_on_device_add(struct hv_device *device, void *additional_info);
994 extern int hv_nv_on_device_remove(struct hv_device *device,
995 boolean_t destroy_channel);
996 extern int hv_nv_on_send(struct hv_device *device, netvsc_packet *pkt);
998 #endif /* __HV_NET_VSC_H__ */