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>
44 #include <sys/malloc.h>
47 #include <dev/hyperv/include/hyperv.h>
49 MALLOC_DECLARE(M_NETVSC);
51 #define NVSP_INVALID_PROTOCOL_VERSION (0xFFFFFFFF)
53 #define NVSP_PROTOCOL_VERSION_1 2
54 #define NVSP_PROTOCOL_VERSION_2 0x30002
55 #define NVSP_PROTOCOL_VERSION_4 0x40000
56 #define NVSP_PROTOCOL_VERSION_5 0x50000
57 #define NVSP_MIN_PROTOCOL_VERSION (NVSP_PROTOCOL_VERSION_1)
58 #define NVSP_MAX_PROTOCOL_VERSION (NVSP_PROTOCOL_VERSION_2)
60 #define NVSP_PROTOCOL_VERSION_CURRENT NVSP_PROTOCOL_VERSION_2
62 #define VERSION_4_OFFLOAD_SIZE 22
64 #define NVSP_OPERATIONAL_STATUS_OK (0x00000000)
65 #define NVSP_OPERATIONAL_STATUS_DEGRADED (0x00000001)
66 #define NVSP_OPERATIONAL_STATUS_NONRECOVERABLE (0x00000002)
67 #define NVSP_OPERATIONAL_STATUS_NO_CONTACT (0x00000003)
68 #define NVSP_OPERATIONAL_STATUS_LOST_COMMUNICATION (0x00000004)
71 * Maximun number of transfer pages (packets) the VSP will use on a receive
73 #define NVSP_MAX_PACKETS_PER_RECEIVE 375
76 typedef enum nvsp_msg_type_ {
77 nvsp_msg_type_none = 0,
82 nvsp_msg_type_init = 1,
83 nvsp_msg_type_init_complete = 2,
85 nvsp_version_msg_start = 100,
90 nvsp_msg_1_type_send_ndis_vers = nvsp_version_msg_start,
92 nvsp_msg_1_type_send_rx_buf,
93 nvsp_msg_1_type_send_rx_buf_complete,
94 nvsp_msg_1_type_revoke_rx_buf,
96 nvsp_msg_1_type_send_send_buf,
97 nvsp_msg_1_type_send_send_buf_complete,
98 nvsp_msg_1_type_revoke_send_buf,
100 nvsp_msg_1_type_send_rndis_pkt,
101 nvsp_msg_1_type_send_rndis_pkt_complete,
106 nvsp_msg_2_type_send_chimney_delegated_buf,
107 nvsp_msg_2_type_send_chimney_delegated_buf_complete,
108 nvsp_msg_2_type_revoke_chimney_delegated_buf,
110 nvsp_msg_2_type_resume_chimney_rx_indication,
112 nvsp_msg_2_type_terminate_chimney,
113 nvsp_msg_2_type_terminate_chimney_complete,
115 nvsp_msg_2_type_indicate_chimney_event,
117 nvsp_msg_2_type_send_chimney_packet,
118 nvsp_msg_2_type_send_chimney_packet_complete,
120 nvsp_msg_2_type_post_chimney_rx_request,
121 nvsp_msg_2_type_post_chimney_rx_request_complete,
123 nvsp_msg_2_type_alloc_rx_buf,
124 nvsp_msg_2_type_alloc_rx_buf_complete,
126 nvsp_msg_2_type_free_rx_buf,
128 nvsp_msg_2_send_vmq_rndis_pkt,
129 nvsp_msg_2_send_vmq_rndis_pkt_complete,
131 nvsp_msg_2_type_send_ndis_config,
133 nvsp_msg_2_type_alloc_chimney_handle,
134 nvsp_msg_2_type_alloc_chimney_handle_complete,
137 typedef enum nvsp_status_ {
138 nvsp_status_none = 0,
142 nvsp_status_prot_vers_range_too_new,
144 nvsp_status_prot_vers_range_too_old,
145 nvsp_status_invalid_rndis_pkt,
150 typedef struct nvsp_msg_hdr_ {
152 } __packed nvsp_msg_hdr;
159 * This message is used by the VSC to initialize the channel
160 * after the channels has been opened. This message should
161 * never include anything other then versioning (i.e. this
162 * message will be the same for ever).
164 * Forever is a long time. The values have been redefined
165 * in Win7 to indicate major and minor protocol version
168 typedef struct nvsp_msg_init_ {
171 uint16_t minor_protocol_version;
172 uint16_t major_protocol_version;
174 /* Formerly min_protocol_version */
175 uint32_t protocol_version;
177 /* Formerly max_protocol_version */
178 uint32_t protocol_version_2;
179 } __packed nvsp_msg_init;
182 * This message is used by the VSP to complete the initialization
183 * of the channel. This message should never include anything other
184 * then versioning (i.e. this message will be the same forever).
186 typedef struct nvsp_msg_init_complete_ {
188 uint32_t negotiated_prot_vers;
189 uint32_t max_mdl_chain_len;
191 } __packed nvsp_msg_init_complete;
193 typedef union nvsp_msg_init_uber_ {
195 nvsp_msg_init_complete init_compl;
196 } __packed nvsp_msg_init_uber;
203 * This message is used by the VSC to send the NDIS version
204 * to the VSP. The VSP can use this information when handling
205 * OIDs sent by the VSC.
207 typedef struct nvsp_1_msg_send_ndis_version_ {
208 uint32_t ndis_major_vers;
210 uint32_t ndis_minor_vers;
211 } __packed nvsp_1_msg_send_ndis_version;
214 * This message is used by the VSC to send a receive buffer
215 * to the VSP. The VSP can then use the receive buffer to
216 * send data to the VSC.
218 typedef struct nvsp_1_msg_send_rx_buf_ {
219 uint32_t gpadl_handle;
221 } __packed nvsp_1_msg_send_rx_buf;
223 typedef struct nvsp_1_rx_buf_section_ {
225 uint32_t sub_allocation_size;
226 uint32_t num_sub_allocations;
228 } __packed nvsp_1_rx_buf_section;
231 * This message is used by the VSP to acknowledge a receive
232 * buffer send by the VSC. This message must be sent by the
233 * VSP before the VSP uses the receive buffer.
235 typedef struct nvsp_1_msg_send_rx_buf_complete_ {
237 uint32_t num_sections;
240 * The receive buffer is split into two parts, a large
241 * suballocation section and a small suballocation
242 * section. These sections are then suballocated by a
245 * For example, the following break up of the receive
246 * buffer has 6 large suballocations and 10 small
249 * | Large Section | | Small Section |
250 * ------------------------------------------------------------
251 * | | | | | | | | | | | | | | | | | |
253 * LargeOffset SmallOffset
255 nvsp_1_rx_buf_section sections[1];
257 } __packed nvsp_1_msg_send_rx_buf_complete;
260 * This message is sent by the VSC to revoke the receive buffer.
261 * After the VSP completes this transaction, the VSP should never
262 * use the receive buffer again.
264 typedef struct nvsp_1_msg_revoke_rx_buf_ {
266 } __packed nvsp_1_msg_revoke_rx_buf;
269 * This message is used by the VSC to send a send buffer
270 * to the VSP. The VSC can then use the send buffer to
271 * send data to the VSP.
273 typedef struct nvsp_1_msg_send_send_buf_ {
274 uint32_t gpadl_handle;
276 } __packed nvsp_1_msg_send_send_buf;
279 * This message is used by the VSP to acknowledge a send
280 * buffer sent by the VSC. This message must be sent by the
281 * VSP before the VSP uses the sent buffer.
283 typedef struct nvsp_1_msg_send_send_buf_complete_ {
287 * The VSC gets to choose the size of the send buffer and
288 * the VSP gets to choose the sections size of the buffer.
289 * This was done to enable dynamic reconfigurations when
290 * the cost of GPA-direct buffers decreases.
292 uint32_t section_size;
293 } __packed nvsp_1_msg_send_send_buf_complete;
296 * This message is sent by the VSC to revoke the send buffer.
297 * After the VSP completes this transaction, the vsp should never
298 * use the send buffer again.
300 typedef struct nvsp_1_msg_revoke_send_buf_ {
302 } __packed nvsp_1_msg_revoke_send_buf;
305 * This message is used by both the VSP and the VSC to send
306 * an RNDIS message to the opposite channel endpoint.
308 typedef struct nvsp_1_msg_send_rndis_pkt_ {
310 * This field is specified by RNIDS. They assume there's
311 * two different channels of communication. However,
312 * the Network VSP only has one. Therefore, the channel
313 * travels with the RNDIS packet.
318 * This field is used to send part or all of the data
319 * through a send buffer. This values specifies an
320 * index into the send buffer. If the index is
321 * 0xFFFFFFFF, then the send buffer is not being used
322 * and all of the data was sent through other VMBus
325 uint32_t send_buf_section_idx;
326 uint32_t send_buf_section_size;
327 } __packed nvsp_1_msg_send_rndis_pkt;
330 * This message is used by both the VSP and the VSC to complete
331 * a RNDIS message to the opposite channel endpoint. At this
332 * point, the initiator of this message cannot use any resources
333 * associated with the original RNDIS packet.
335 typedef struct nvsp_1_msg_send_rndis_pkt_complete_ {
337 } __packed nvsp_1_msg_send_rndis_pkt_complete;
345 * This message is used by the VSC to send the NDIS version
346 * to the VSP. The VSP can use this information when handling
347 * OIDs sent by the VSC.
349 typedef struct nvsp_2_netvsc_capabilities_ {
354 uint64_t chimney : 1;
356 uint64_t ieee8021q : 1;
357 uint64_t correlationid : 1;
358 uint64_t teaming : 1;
361 } __packed nvsp_2_netvsc_capabilities;
363 typedef struct nvsp_2_msg_send_ndis_config_ {
366 nvsp_2_netvsc_capabilities capabilities;
367 } __packed nvsp_2_msg_send_ndis_config;
370 * NvspMessage2TypeSendChimneyDelegatedBuffer
372 typedef struct nvsp_2_msg_send_chimney_buf_
375 * On WIN7 beta, delegated_obj_max_size is defined as a uint32_t
376 * Since WIN7 RC, it was split into two uint16_t. To have the same
377 * struct layout, delegated_obj_max_size shall be the first field.
379 uint16_t delegated_obj_max_size;
382 * The revision # of chimney protocol used between NVSC and NVSP.
384 * This revision is NOT related to the chimney revision between
385 * NDIS protocol and miniport drivers.
389 uint32_t gpadl_handle;
390 } __packed nvsp_2_msg_send_chimney_buf;
393 /* Unsupported chimney revision 0 (only present in WIN7 beta) */
394 #define NVSP_CHIMNEY_REVISION_0 0
396 /* WIN7 Beta Chimney QFE */
397 #define NVSP_CHIMNEY_REVISION_1 1
399 /* The chimney revision since WIN7 RC */
400 #define NVSP_CHIMNEY_REVISION_2 2
404 * NvspMessage2TypeSendChimneyDelegatedBufferComplete
406 typedef struct nvsp_2_msg_send_chimney_buf_complete_ {
410 * Maximum number outstanding sends and pre-posted receives.
412 * NVSC should not post more than SendQuota/ReceiveQuota packets.
413 * Otherwise, it can block the non-chimney path for an indefinite
415 * (since chimney sends/receives are affected by the remote peer).
417 * Note: NVSP enforces the quota restrictions on a per-VMBCHANNEL
418 * basis. It doesn't enforce the restriction separately for chimney
419 * send/receive. If NVSC doesn't voluntarily enforce "SendQuota",
420 * it may kill its own network connectivity.
424 } __packed nvsp_2_msg_send_chimney_buf_complete;
427 * NvspMessage2TypeRevokeChimneyDelegatedBuffer
429 typedef struct nvsp_2_msg_revoke_chimney_buf_ {
430 uint32_t gpadl_handle;
431 } __packed nvsp_2_msg_revoke_chimney_buf;
434 #define NVSP_CHIMNEY_OBJECT_TYPE_NEIGHBOR 0
435 #define NVSP_CHIMNEY_OBJECT_TYPE_PATH4 1
436 #define NVSP_CHIMNEY_OBJECT_TYPE_PATH6 2
437 #define NVSP_CHIMNEY_OBJECT_TYPE_TCP 3
440 * NvspMessage2TypeAllocateChimneyHandle
442 typedef struct nvsp_2_msg_alloc_chimney_handle_ {
443 uint64_t vsc_context;
444 uint32_t object_type;
445 } __packed nvsp_2_msg_alloc_chimney_handle;
448 * NvspMessage2TypeAllocateChimneyHandleComplete
450 typedef struct nvsp_2_msg_alloc_chimney_handle_complete_ {
452 } __packed nvsp_2_msg_alloc_chimney_handle_complete;
456 * NvspMessage2TypeResumeChimneyRXIndication
458 typedef struct nvsp_2_msg_resume_chimney_rx_indication {
460 * Handle identifying the offloaded connection
462 uint32_t vsp_tcp_handle;
463 } __packed nvsp_2_msg_resume_chimney_rx_indication;
466 #define NVSP_2_MSG_TERMINATE_CHIMNEY_FLAGS_FIRST_STAGE (0x01u)
467 #define NVSP_2_MSG_TERMINATE_CHIMNEY_FLAGS_RESERVED (~(0x01u))
470 * NvspMessage2TypeTerminateChimney
472 typedef struct nvsp_2_msg_terminate_chimney_ {
474 * Handle identifying the offloaded object
479 * Terminate Offload Flags
481 * When set to 0, terminate the offload at the destination NIC
482 * Bit 1-31: Reserved, shall be zero
488 * This field is valid only when bit 0 of flags is clear.
489 * It specifies the index into the premapped delegated
490 * object buffer. The buffer was sent through the
491 * NvspMessage2TypeSendChimneyDelegatedBuffer
492 * message at initialization time.
494 * NVSP will write the delegated state into the delegated
495 * buffer upon upload completion.
500 * This field is valid only when bit 0 of flags is set.
502 * The seqence number of the most recently accepted RX
503 * indication when VSC sets its TCP context into
504 * "terminating" state.
506 * This allows NVSP to determines if there are any in-flight
507 * RX indications for which the acceptance state is still
510 uint64_t last_accepted_rx_seq_no;
512 } __packed nvsp_2_msg_terminate_chimney;
515 #define NVSP_TERMINATE_CHIMNEY_COMPLETE_FLAG_DATA_CORRUPTED 0x0000001u
518 * NvspMessage2TypeTerminateChimneyComplete
520 typedef struct nvsp_2_msg_terminate_chimney_complete_ {
521 uint64_t vsc_context;
523 } __packed nvsp_2_msg_terminate_chimney_complete;
526 * NvspMessage2TypeIndicateChimneyEvent
528 typedef struct nvsp_2_msg_indicate_chimney_event_ {
530 * When VscTcpContext is 0, event_type is an NDIS_STATUS event code
531 * Otherwise, EventType is an TCP connection event (defined in
532 * NdisTcpOffloadEventHandler chimney DDK document).
537 * When VscTcpContext is 0, EventType is an NDIS_STATUS event code
538 * Otherwise, EventType is an TCP connection event specific information
539 * (defined in NdisTcpOffloadEventHandler chimney DDK document).
541 uint32_t event_specific_info;
544 * If not 0, the event is per-TCP connection event. This field
545 * contains the VSC's TCP context.
546 * If 0, the event indication is global.
548 uint64_t vsc_tcp_context;
549 } __packed nvsp_2_msg_indicate_chimney_event;
552 #define NVSP_1_CHIMNEY_SEND_INVALID_OOB_INDEX 0xffffu
553 #define NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX 0xffffffff
556 * NvspMessage2TypeSendChimneyPacket
558 typedef struct nvsp_2_msg_send_chimney_pkt_ {
560 * Identify the TCP connection for which this chimney send is
562 uint32_t vsp_tcp_handle;
565 * This field is used to send part or all of the data
566 * through a send buffer. This values specifies an
567 * index into the send buffer. If the index is
568 * 0xFFFF, then the send buffer is not being used
569 * and all of the data was sent through other VMBus
572 uint16_t send_buf_section_index;
573 uint16_t send_buf_section_size;
577 * This an index to the OOB data buffer. If the index is 0xFFFFFFFF,
578 * then there is no OOB data.
580 * This field shall be always 0xFFFFFFFF for now. It is reserved for
583 uint16_t oob_data_index;
586 * DisconnectFlags = 0
587 * Normal chimney send. See MiniportTcpOffloadSend for details.
589 * DisconnectFlags = TCP_DISCONNECT_GRACEFUL_CLOSE (0x01)
590 * Graceful disconnect. See MiniportTcpOffloadDisconnect for details.
592 * DisconnectFlags = TCP_DISCONNECT_ABORTIVE_CLOSE (0x02)
593 * Abortive disconnect. See MiniportTcpOffloadDisconnect for details.
595 uint16_t disconnect_flags;
598 } __packed nvsp_2_msg_send_chimney_pkt;
601 * NvspMessage2TypeSendChimneyPacketComplete
603 typedef struct nvsp_2_msg_send_chimney_pkt_complete_ {
605 * The NDIS_STATUS for the chimney send
610 * Number of bytes that have been sent to the peer (and ACKed by the peer).
612 uint32_t bytes_transferred;
613 } __packed nvsp_2_msg_send_chimney_pkt_complete;
616 #define NVSP_1_CHIMNEY_RECV_FLAG_NO_PUSH 0x0001u
617 #define NVSP_1_CHIMNEY_RECV_INVALID_OOB_INDEX 0xffffu
620 * NvspMessage2TypePostChimneyRecvRequest
622 typedef struct nvsp_2_msg_post_chimney_rx_request_ {
624 * Identify the TCP connection which this chimney receive request
627 uint32_t vsp_tcp_handle;
631 * This an index to the OOB data buffer. If the index is 0xFFFFFFFF,
632 * then there is no OOB data.
634 * This field shall be always 0xFFFFFFFF for now. It is reserved for
637 uint32_t oob_data_index;
641 * When it is set, this is a "no-push" receive.
642 * When it is clear, this is a "push" receive.
644 * Bit 1-15: Reserved and shall be zero
649 * For debugging and diagnoses purpose.
650 * The SeqNo is per TCP connection and starts from 0.
653 } __packed nvsp_2_msg_post_chimney_rx_request;
656 * NvspMessage2TypePostChimneyRecvRequestComplete
658 typedef struct nvsp_2_msg_post_chimney_rx_request_complete_ {
660 * The NDIS_STATUS for the chimney send
665 * Number of bytes that have been sent to the peer (and ACKed by
668 uint32_t bytes_xferred;
669 } __packed nvsp_2_msg_post_chimney_rx_request_complete;
672 * NvspMessage2TypeAllocateReceiveBuffer
674 typedef struct nvsp_2_msg_alloc_rx_buf_ {
676 * Allocation ID to match the allocation request and response
678 uint32_t allocation_id;
681 * Length of the VM shared memory receive buffer that needs to
685 } __packed nvsp_2_msg_alloc_rx_buf;
688 * NvspMessage2TypeAllocateReceiveBufferComplete
690 typedef struct nvsp_2_msg_alloc_rx_buf_complete_ {
692 * The NDIS_STATUS code for buffer allocation
697 * Allocation ID from NVSP_2_MESSAGE_ALLOCATE_RECEIVE_BUFFER
699 uint32_t allocation_id;
702 * GPADL handle for the allocated receive buffer
704 uint32_t gpadl_handle;
707 * Receive buffer ID that is further used in
708 * NvspMessage2SendVmqRndisPacket
711 } __packed nvsp_2_msg_alloc_rx_buf_complete;
714 * NvspMessage2TypeFreeReceiveBuffer
716 typedef struct nvsp_2_msg_free_rx_buf_ {
718 * Receive buffer ID previous returned in
719 * NvspMessage2TypeAllocateReceiveBufferComplete message
722 } __packed nvsp_2_msg_free_rx_buf;
725 * This structure is used in defining the buffers in
726 * NVSP_2_MESSAGE_SEND_VMQ_RNDIS_PACKET structure
728 typedef struct nvsp_xfer_page_range_ {
730 * Specifies the ID of the receive buffer that has the buffer. This
731 * ID can be the general receive buffer ID specified in
732 * NvspMessage1TypeSendReceiveBuffer or it can be the shared memory
733 * receive buffer ID allocated by the VSC and specified in
734 * NvspMessage2TypeAllocateReceiveBufferComplete message
736 uint64_t xfer_page_set_id;
744 * Offset in bytes from the beginning of the buffer
746 uint32_t byte_offset;
747 } __packed nvsp_xfer_page_range;
750 * NvspMessage2SendVmqRndisPacket
752 typedef struct nvsp_2_msg_send_vmq_rndis_pkt_ {
754 * This field is specified by RNIDS. They assume there's
755 * two different channels of communication. However,
756 * the Network VSP only has one. Therefore, the channel
757 * travels with the RNDIS packet. It must be RMC_DATA
759 uint32_t channel_type;
762 * Only the Range element corresponding to the RNDIS header of
763 * the first RNDIS message in the multiple RNDIS messages sent
764 * in one NVSP message. Information about the data portions as well
765 * as the subsequent RNDIS messages in the same NVSP message are
766 * embedded in the RNDIS header itself
768 nvsp_xfer_page_range range;
769 } __packed nvsp_2_msg_send_vmq_rndis_pkt;
772 * This message is used by the VSC to complete
773 * a RNDIS VMQ message to the VSP. At this point,
774 * the initiator of this message can use any resources
775 * associated with the original RNDIS VMQ packet.
777 typedef struct nvsp_2_msg_send_vmq_rndis_pkt_complete_
780 } __packed nvsp_2_msg_send_vmq_rndis_pkt_complete;
783 typedef union nvsp_1_msg_uber_ {
784 nvsp_1_msg_send_ndis_version send_ndis_vers;
786 nvsp_1_msg_send_rx_buf send_rx_buf;
787 nvsp_1_msg_send_rx_buf_complete send_rx_buf_complete;
788 nvsp_1_msg_revoke_rx_buf revoke_rx_buf;
790 nvsp_1_msg_send_send_buf send_send_buf;
791 nvsp_1_msg_send_send_buf_complete send_send_buf_complete;
792 nvsp_1_msg_revoke_send_buf revoke_send_buf;
794 nvsp_1_msg_send_rndis_pkt send_rndis_pkt;
795 nvsp_1_msg_send_rndis_pkt_complete send_rndis_pkt_complete;
796 } __packed nvsp_1_msg_uber;
799 typedef union nvsp_2_msg_uber_ {
800 nvsp_2_msg_send_ndis_config send_ndis_config;
802 nvsp_2_msg_send_chimney_buf send_chimney_buf;
803 nvsp_2_msg_send_chimney_buf_complete send_chimney_buf_complete;
804 nvsp_2_msg_revoke_chimney_buf revoke_chimney_buf;
806 nvsp_2_msg_resume_chimney_rx_indication resume_chimney_rx_indication;
807 nvsp_2_msg_terminate_chimney terminate_chimney;
808 nvsp_2_msg_terminate_chimney_complete terminate_chimney_complete;
809 nvsp_2_msg_indicate_chimney_event indicate_chimney_event;
811 nvsp_2_msg_send_chimney_pkt send_chimney_packet;
812 nvsp_2_msg_send_chimney_pkt_complete send_chimney_packet_complete;
813 nvsp_2_msg_post_chimney_rx_request post_chimney_rx_request;
814 nvsp_2_msg_post_chimney_rx_request_complete
815 post_chimney_rx_request_complete;
817 nvsp_2_msg_alloc_rx_buf alloc_rx_buffer;
818 nvsp_2_msg_alloc_rx_buf_complete alloc_rx_buffer_complete;
819 nvsp_2_msg_free_rx_buf free_rx_buffer;
821 nvsp_2_msg_send_vmq_rndis_pkt send_vmq_rndis_pkt;
822 nvsp_2_msg_send_vmq_rndis_pkt_complete send_vmq_rndis_pkt_complete;
823 nvsp_2_msg_alloc_chimney_handle alloc_chimney_handle;
824 nvsp_2_msg_alloc_chimney_handle_complete alloc_chimney_handle_complete;
825 } __packed nvsp_2_msg_uber;
828 typedef union nvsp_all_msgs_ {
829 nvsp_msg_init_uber init_msgs;
830 nvsp_1_msg_uber vers_1_msgs;
831 nvsp_2_msg_uber vers_2_msgs;
832 } __packed nvsp_all_msgs;
837 typedef struct nvsp_msg_ {
844 * The following arguably belongs in a separate header file
851 #define NETVSC_SEND_BUFFER_SIZE (1024*1024*15) /* 15M */
852 #define NETVSC_SEND_BUFFER_ID 0xface
855 #define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024*16) /* 16MB */
857 #define NETVSC_RECEIVE_BUFFER_ID 0xcafe
859 #define NETVSC_RECEIVE_SG_COUNT 1
861 /* Preallocated receive packets */
862 #define NETVSC_RECEIVE_PACKETLIST_COUNT 256
865 * Maximum MTU we permit to be configured for a netvsc interface.
866 * When the code was developed, a max MTU of 12232 was tested and
867 * proven to work. 9K is a reasonable maximum for an Ethernet.
869 #define NETVSC_MAX_CONFIGURABLE_MTU (9 * 1024)
871 #define NETVSC_PACKET_SIZE PAGE_SIZE
878 * Per netvsc channel-specific
880 typedef struct netvsc_dev_ {
881 struct hv_device *dev;
882 int num_outstanding_sends;
884 /* Send buffer allocated by us but manages by NetVSP */
886 uint32_t send_buf_size;
887 uint32_t send_buf_gpadl_handle;
888 uint32_t send_section_size;
889 uint32_t send_section_count;
890 unsigned long bitsmap_words;
891 unsigned long *send_section_bitsmap;
893 /* Receive buffer allocated by us but managed by NetVSP */
895 uint32_t rx_buf_size;
896 uint32_t rx_buf_gpadl_handle;
897 uint32_t rx_section_count;
898 nvsp_1_rx_buf_section *rx_sections;
900 /* Used for NetVSP initialization protocol */
901 struct sema channel_init_sema;
902 nvsp_msg channel_init_packet;
904 nvsp_msg revoke_packet;
905 /*uint8_t hw_mac_addr[HW_MACADDR_LEN];*/
907 /* Holds rndis device info */
910 hv_bool_uint8_t destroy;
911 /* Negotiated NVSP version */
912 uint32_t nvsp_version;
914 uint8_t callback_buf[NETVSC_PACKET_SIZE];
918 typedef void (*pfn_on_send_rx_completion)(void *);
920 #define NETVSC_DEVICE_RING_BUFFER_SIZE (128 * PAGE_SIZE)
921 #define NETVSC_PACKET_MAXPAGE 32
924 #define NETVSC_VLAN_PRIO_MASK 0xe000
925 #define NETVSC_VLAN_PRIO_SHIFT 13
926 #define NETVSC_VLAN_VID_MASK 0x0fff
933 #define TRANSPORT_TYPE_NOT_IP 0
934 #define TRANSPORT_TYPE_IPV4_TCP ((TYPE_IPV4 << 16) | TYPE_TCP)
935 #define TRANSPORT_TYPE_IPV4_UDP ((TYPE_IPV4 << 16) | TYPE_UDP)
936 #define TRANSPORT_TYPE_IPV6_TCP ((TYPE_IPV6 << 16) | TYPE_TCP)
937 #define TRANSPORT_TYPE_IPV6_UDP ((TYPE_IPV6 << 16) | TYPE_UDP)
940 #define BITS_PER_LONG 64
942 #define BITS_PER_LONG 32
945 typedef struct netvsc_packet_ {
946 struct hv_device *device;
947 hv_bool_uint8_t is_data_pkt; /* One byte */
954 uint64_t rx_completion_tid;
955 void *rx_completion_context;
956 /* This is no longer used */
957 pfn_on_send_rx_completion on_rx_completion;
960 uint64_t send_completion_tid;
961 void *send_completion_context;
962 /* Still used in netvsc and filter code */
963 pfn_on_send_rx_completion on_send_completion;
966 uint32_t send_buf_section_idx;
967 uint32_t send_buf_section_size;
970 uint32_t tot_data_buf_len;
972 uint32_t page_buf_count;
973 hv_vmbus_page_buffer page_buffers[NETVSC_PACKET_MAXPAGE];
977 uint8_t mac_addr[6]; /* Assumption unsigned long */
978 hv_bool_uint8_t link_state;
979 } netvsc_device_info;
982 * Device-specific softc structure
984 typedef struct hn_softc {
985 struct ifnet *hn_ifp;
986 struct arpcom arpcom;
993 /* See hv_netvsc_drv_freebsd.c for rules on how to use */
995 struct hv_device *hn_dev_obj;
1003 extern int hv_promisc_mode;
1005 void netvsc_linkstatus_callback(struct hv_device *device_obj, uint32_t status);
1006 void netvsc_xmit_completion(void *context);
1007 void hv_nv_on_receive_completion(struct hv_device *device,
1008 uint64_t tid, uint32_t status);
1009 netvsc_dev *hv_nv_on_device_add(struct hv_device *device,
1010 void *additional_info);
1011 int hv_nv_on_device_remove(struct hv_device *device,
1012 boolean_t destroy_channel);
1013 int hv_nv_on_send(struct hv_device *device, netvsc_packet *pkt);
1014 int hv_nv_get_next_send_section(netvsc_dev *net_dev);
1016 #endif /* __HV_NET_VSC_H__ */