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 <netinet/in.h>
48 #include <netinet/tcp_lro.h>
51 #include <net/if_media.h>
53 #include <dev/hyperv/include/hyperv.h>
55 MALLOC_DECLARE(M_NETVSC);
57 #define NVSP_INVALID_PROTOCOL_VERSION (0xFFFFFFFF)
59 #define NVSP_PROTOCOL_VERSION_1 2
60 #define NVSP_PROTOCOL_VERSION_2 0x30002
61 #define NVSP_PROTOCOL_VERSION_4 0x40000
62 #define NVSP_PROTOCOL_VERSION_5 0x50000
63 #define NVSP_MIN_PROTOCOL_VERSION (NVSP_PROTOCOL_VERSION_1)
64 #define NVSP_MAX_PROTOCOL_VERSION (NVSP_PROTOCOL_VERSION_2)
66 #define NVSP_PROTOCOL_VERSION_CURRENT NVSP_PROTOCOL_VERSION_2
68 #define VERSION_4_OFFLOAD_SIZE 22
70 #define NVSP_OPERATIONAL_STATUS_OK (0x00000000)
71 #define NVSP_OPERATIONAL_STATUS_DEGRADED (0x00000001)
72 #define NVSP_OPERATIONAL_STATUS_NONRECOVERABLE (0x00000002)
73 #define NVSP_OPERATIONAL_STATUS_NO_CONTACT (0x00000003)
74 #define NVSP_OPERATIONAL_STATUS_LOST_COMMUNICATION (0x00000004)
77 * Maximun number of transfer pages (packets) the VSP will use on a receive
79 #define NVSP_MAX_PACKETS_PER_RECEIVE 375
82 typedef enum nvsp_msg_type_ {
83 nvsp_msg_type_none = 0,
88 nvsp_msg_type_init = 1,
89 nvsp_msg_type_init_complete = 2,
91 nvsp_version_msg_start = 100,
96 nvsp_msg_1_type_send_ndis_vers = nvsp_version_msg_start,
98 nvsp_msg_1_type_send_rx_buf,
99 nvsp_msg_1_type_send_rx_buf_complete,
100 nvsp_msg_1_type_revoke_rx_buf,
102 nvsp_msg_1_type_send_send_buf,
103 nvsp_msg_1_type_send_send_buf_complete,
104 nvsp_msg_1_type_revoke_send_buf,
106 nvsp_msg_1_type_send_rndis_pkt,
107 nvsp_msg_1_type_send_rndis_pkt_complete,
112 nvsp_msg_2_type_send_chimney_delegated_buf,
113 nvsp_msg_2_type_send_chimney_delegated_buf_complete,
114 nvsp_msg_2_type_revoke_chimney_delegated_buf,
116 nvsp_msg_2_type_resume_chimney_rx_indication,
118 nvsp_msg_2_type_terminate_chimney,
119 nvsp_msg_2_type_terminate_chimney_complete,
121 nvsp_msg_2_type_indicate_chimney_event,
123 nvsp_msg_2_type_send_chimney_packet,
124 nvsp_msg_2_type_send_chimney_packet_complete,
126 nvsp_msg_2_type_post_chimney_rx_request,
127 nvsp_msg_2_type_post_chimney_rx_request_complete,
129 nvsp_msg_2_type_alloc_rx_buf,
130 nvsp_msg_2_type_alloc_rx_buf_complete,
132 nvsp_msg_2_type_free_rx_buf,
134 nvsp_msg_2_send_vmq_rndis_pkt,
135 nvsp_msg_2_send_vmq_rndis_pkt_complete,
137 nvsp_msg_2_type_send_ndis_config,
139 nvsp_msg_2_type_alloc_chimney_handle,
140 nvsp_msg_2_type_alloc_chimney_handle_complete,
143 typedef enum nvsp_status_ {
144 nvsp_status_none = 0,
148 nvsp_status_prot_vers_range_too_new,
150 nvsp_status_prot_vers_range_too_old,
151 nvsp_status_invalid_rndis_pkt,
156 typedef struct nvsp_msg_hdr_ {
158 } __packed nvsp_msg_hdr;
165 * This message is used by the VSC to initialize the channel
166 * after the channels has been opened. This message should
167 * never include anything other then versioning (i.e. this
168 * message will be the same for ever).
170 * Forever is a long time. The values have been redefined
171 * in Win7 to indicate major and minor protocol version
174 typedef struct nvsp_msg_init_ {
177 uint16_t minor_protocol_version;
178 uint16_t major_protocol_version;
180 /* Formerly min_protocol_version */
181 uint32_t protocol_version;
183 /* Formerly max_protocol_version */
184 uint32_t protocol_version_2;
185 } __packed nvsp_msg_init;
188 * This message is used by the VSP to complete the initialization
189 * of the channel. This message should never include anything other
190 * then versioning (i.e. this message will be the same forever).
192 typedef struct nvsp_msg_init_complete_ {
194 uint32_t negotiated_prot_vers;
195 uint32_t max_mdl_chain_len;
197 } __packed nvsp_msg_init_complete;
199 typedef union nvsp_msg_init_uber_ {
201 nvsp_msg_init_complete init_compl;
202 } __packed nvsp_msg_init_uber;
209 * This message is used by the VSC to send the NDIS version
210 * to the VSP. The VSP can use this information when handling
211 * OIDs sent by the VSC.
213 typedef struct nvsp_1_msg_send_ndis_version_ {
214 uint32_t ndis_major_vers;
216 uint32_t ndis_minor_vers;
217 } __packed nvsp_1_msg_send_ndis_version;
220 * This message is used by the VSC to send a receive buffer
221 * to the VSP. The VSP can then use the receive buffer to
222 * send data to the VSC.
224 typedef struct nvsp_1_msg_send_rx_buf_ {
225 uint32_t gpadl_handle;
227 } __packed nvsp_1_msg_send_rx_buf;
229 typedef struct nvsp_1_rx_buf_section_ {
231 uint32_t sub_allocation_size;
232 uint32_t num_sub_allocations;
234 } __packed nvsp_1_rx_buf_section;
237 * This message is used by the VSP to acknowledge a receive
238 * buffer send by the VSC. This message must be sent by the
239 * VSP before the VSP uses the receive buffer.
241 typedef struct nvsp_1_msg_send_rx_buf_complete_ {
243 uint32_t num_sections;
246 * The receive buffer is split into two parts, a large
247 * suballocation section and a small suballocation
248 * section. These sections are then suballocated by a
251 * For example, the following break up of the receive
252 * buffer has 6 large suballocations and 10 small
255 * | Large Section | | Small Section |
256 * ------------------------------------------------------------
257 * | | | | | | | | | | | | | | | | | |
259 * LargeOffset SmallOffset
261 nvsp_1_rx_buf_section sections[1];
263 } __packed nvsp_1_msg_send_rx_buf_complete;
266 * This message is sent by the VSC to revoke the receive buffer.
267 * After the VSP completes this transaction, the VSP should never
268 * use the receive buffer again.
270 typedef struct nvsp_1_msg_revoke_rx_buf_ {
272 } __packed nvsp_1_msg_revoke_rx_buf;
275 * This message is used by the VSC to send a send buffer
276 * to the VSP. The VSC can then use the send buffer to
277 * send data to the VSP.
279 typedef struct nvsp_1_msg_send_send_buf_ {
280 uint32_t gpadl_handle;
282 } __packed nvsp_1_msg_send_send_buf;
285 * This message is used by the VSP to acknowledge a send
286 * buffer sent by the VSC. This message must be sent by the
287 * VSP before the VSP uses the sent buffer.
289 typedef struct nvsp_1_msg_send_send_buf_complete_ {
293 * The VSC gets to choose the size of the send buffer and
294 * the VSP gets to choose the sections size of the buffer.
295 * This was done to enable dynamic reconfigurations when
296 * the cost of GPA-direct buffers decreases.
298 uint32_t section_size;
299 } __packed nvsp_1_msg_send_send_buf_complete;
302 * This message is sent by the VSC to revoke the send buffer.
303 * After the VSP completes this transaction, the vsp should never
304 * use the send buffer again.
306 typedef struct nvsp_1_msg_revoke_send_buf_ {
308 } __packed nvsp_1_msg_revoke_send_buf;
311 * This message is used by both the VSP and the VSC to send
312 * an RNDIS message to the opposite channel endpoint.
314 typedef struct nvsp_1_msg_send_rndis_pkt_ {
316 * This field is specified by RNIDS. They assume there's
317 * two different channels of communication. However,
318 * the Network VSP only has one. Therefore, the channel
319 * travels with the RNDIS packet.
324 * This field is used to send part or all of the data
325 * through a send buffer. This values specifies an
326 * index into the send buffer. If the index is
327 * 0xFFFFFFFF, then the send buffer is not being used
328 * and all of the data was sent through other VMBus
331 uint32_t send_buf_section_idx;
332 uint32_t send_buf_section_size;
333 } __packed nvsp_1_msg_send_rndis_pkt;
336 * This message is used by both the VSP and the VSC to complete
337 * a RNDIS message to the opposite channel endpoint. At this
338 * point, the initiator of this message cannot use any resources
339 * associated with the original RNDIS packet.
341 typedef struct nvsp_1_msg_send_rndis_pkt_complete_ {
343 } __packed nvsp_1_msg_send_rndis_pkt_complete;
351 * This message is used by the VSC to send the NDIS version
352 * to the VSP. The VSP can use this information when handling
353 * OIDs sent by the VSC.
355 typedef struct nvsp_2_netvsc_capabilities_ {
360 uint64_t chimney : 1;
362 uint64_t ieee8021q : 1;
363 uint64_t correlationid : 1;
364 uint64_t teaming : 1;
367 } __packed nvsp_2_netvsc_capabilities;
369 typedef struct nvsp_2_msg_send_ndis_config_ {
372 nvsp_2_netvsc_capabilities capabilities;
373 } __packed nvsp_2_msg_send_ndis_config;
376 * NvspMessage2TypeSendChimneyDelegatedBuffer
378 typedef struct nvsp_2_msg_send_chimney_buf_
381 * On WIN7 beta, delegated_obj_max_size is defined as a uint32_t
382 * Since WIN7 RC, it was split into two uint16_t. To have the same
383 * struct layout, delegated_obj_max_size shall be the first field.
385 uint16_t delegated_obj_max_size;
388 * The revision # of chimney protocol used between NVSC and NVSP.
390 * This revision is NOT related to the chimney revision between
391 * NDIS protocol and miniport drivers.
395 uint32_t gpadl_handle;
396 } __packed nvsp_2_msg_send_chimney_buf;
399 /* Unsupported chimney revision 0 (only present in WIN7 beta) */
400 #define NVSP_CHIMNEY_REVISION_0 0
402 /* WIN7 Beta Chimney QFE */
403 #define NVSP_CHIMNEY_REVISION_1 1
405 /* The chimney revision since WIN7 RC */
406 #define NVSP_CHIMNEY_REVISION_2 2
410 * NvspMessage2TypeSendChimneyDelegatedBufferComplete
412 typedef struct nvsp_2_msg_send_chimney_buf_complete_ {
416 * Maximum number outstanding sends and pre-posted receives.
418 * NVSC should not post more than SendQuota/ReceiveQuota packets.
419 * Otherwise, it can block the non-chimney path for an indefinite
421 * (since chimney sends/receives are affected by the remote peer).
423 * Note: NVSP enforces the quota restrictions on a per-VMBCHANNEL
424 * basis. It doesn't enforce the restriction separately for chimney
425 * send/receive. If NVSC doesn't voluntarily enforce "SendQuota",
426 * it may kill its own network connectivity.
430 } __packed nvsp_2_msg_send_chimney_buf_complete;
433 * NvspMessage2TypeRevokeChimneyDelegatedBuffer
435 typedef struct nvsp_2_msg_revoke_chimney_buf_ {
436 uint32_t gpadl_handle;
437 } __packed nvsp_2_msg_revoke_chimney_buf;
440 #define NVSP_CHIMNEY_OBJECT_TYPE_NEIGHBOR 0
441 #define NVSP_CHIMNEY_OBJECT_TYPE_PATH4 1
442 #define NVSP_CHIMNEY_OBJECT_TYPE_PATH6 2
443 #define NVSP_CHIMNEY_OBJECT_TYPE_TCP 3
446 * NvspMessage2TypeAllocateChimneyHandle
448 typedef struct nvsp_2_msg_alloc_chimney_handle_ {
449 uint64_t vsc_context;
450 uint32_t object_type;
451 } __packed nvsp_2_msg_alloc_chimney_handle;
454 * NvspMessage2TypeAllocateChimneyHandleComplete
456 typedef struct nvsp_2_msg_alloc_chimney_handle_complete_ {
458 } __packed nvsp_2_msg_alloc_chimney_handle_complete;
462 * NvspMessage2TypeResumeChimneyRXIndication
464 typedef struct nvsp_2_msg_resume_chimney_rx_indication {
466 * Handle identifying the offloaded connection
468 uint32_t vsp_tcp_handle;
469 } __packed nvsp_2_msg_resume_chimney_rx_indication;
472 #define NVSP_2_MSG_TERMINATE_CHIMNEY_FLAGS_FIRST_STAGE (0x01u)
473 #define NVSP_2_MSG_TERMINATE_CHIMNEY_FLAGS_RESERVED (~(0x01u))
476 * NvspMessage2TypeTerminateChimney
478 typedef struct nvsp_2_msg_terminate_chimney_ {
480 * Handle identifying the offloaded object
485 * Terminate Offload Flags
487 * When set to 0, terminate the offload at the destination NIC
488 * Bit 1-31: Reserved, shall be zero
494 * This field is valid only when bit 0 of flags is clear.
495 * It specifies the index into the premapped delegated
496 * object buffer. The buffer was sent through the
497 * NvspMessage2TypeSendChimneyDelegatedBuffer
498 * message at initialization time.
500 * NVSP will write the delegated state into the delegated
501 * buffer upon upload completion.
506 * This field is valid only when bit 0 of flags is set.
508 * The seqence number of the most recently accepted RX
509 * indication when VSC sets its TCP context into
510 * "terminating" state.
512 * This allows NVSP to determines if there are any in-flight
513 * RX indications for which the acceptance state is still
516 uint64_t last_accepted_rx_seq_no;
518 } __packed nvsp_2_msg_terminate_chimney;
521 #define NVSP_TERMINATE_CHIMNEY_COMPLETE_FLAG_DATA_CORRUPTED 0x0000001u
524 * NvspMessage2TypeTerminateChimneyComplete
526 typedef struct nvsp_2_msg_terminate_chimney_complete_ {
527 uint64_t vsc_context;
529 } __packed nvsp_2_msg_terminate_chimney_complete;
532 * NvspMessage2TypeIndicateChimneyEvent
534 typedef struct nvsp_2_msg_indicate_chimney_event_ {
536 * When VscTcpContext is 0, event_type is an NDIS_STATUS event code
537 * Otherwise, EventType is an TCP connection event (defined in
538 * NdisTcpOffloadEventHandler chimney DDK document).
543 * When VscTcpContext is 0, EventType is an NDIS_STATUS event code
544 * Otherwise, EventType is an TCP connection event specific information
545 * (defined in NdisTcpOffloadEventHandler chimney DDK document).
547 uint32_t event_specific_info;
550 * If not 0, the event is per-TCP connection event. This field
551 * contains the VSC's TCP context.
552 * If 0, the event indication is global.
554 uint64_t vsc_tcp_context;
555 } __packed nvsp_2_msg_indicate_chimney_event;
558 #define NVSP_1_CHIMNEY_SEND_INVALID_OOB_INDEX 0xffffu
559 #define NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX 0xffffffff
562 * NvspMessage2TypeSendChimneyPacket
564 typedef struct nvsp_2_msg_send_chimney_pkt_ {
566 * Identify the TCP connection for which this chimney send is
568 uint32_t vsp_tcp_handle;
571 * This field is used to send part or all of the data
572 * through a send buffer. This values specifies an
573 * index into the send buffer. If the index is
574 * 0xFFFF, then the send buffer is not being used
575 * and all of the data was sent through other VMBus
578 uint16_t send_buf_section_index;
579 uint16_t send_buf_section_size;
583 * This an index to the OOB data buffer. If the index is 0xFFFFFFFF,
584 * then there is no OOB data.
586 * This field shall be always 0xFFFFFFFF for now. It is reserved for
589 uint16_t oob_data_index;
592 * DisconnectFlags = 0
593 * Normal chimney send. See MiniportTcpOffloadSend for details.
595 * DisconnectFlags = TCP_DISCONNECT_GRACEFUL_CLOSE (0x01)
596 * Graceful disconnect. See MiniportTcpOffloadDisconnect for details.
598 * DisconnectFlags = TCP_DISCONNECT_ABORTIVE_CLOSE (0x02)
599 * Abortive disconnect. See MiniportTcpOffloadDisconnect for details.
601 uint16_t disconnect_flags;
604 } __packed nvsp_2_msg_send_chimney_pkt;
607 * NvspMessage2TypeSendChimneyPacketComplete
609 typedef struct nvsp_2_msg_send_chimney_pkt_complete_ {
611 * The NDIS_STATUS for the chimney send
616 * Number of bytes that have been sent to the peer (and ACKed by the peer).
618 uint32_t bytes_transferred;
619 } __packed nvsp_2_msg_send_chimney_pkt_complete;
622 #define NVSP_1_CHIMNEY_RECV_FLAG_NO_PUSH 0x0001u
623 #define NVSP_1_CHIMNEY_RECV_INVALID_OOB_INDEX 0xffffu
626 * NvspMessage2TypePostChimneyRecvRequest
628 typedef struct nvsp_2_msg_post_chimney_rx_request_ {
630 * Identify the TCP connection which this chimney receive request
633 uint32_t vsp_tcp_handle;
637 * This an index to the OOB data buffer. If the index is 0xFFFFFFFF,
638 * then there is no OOB data.
640 * This field shall be always 0xFFFFFFFF for now. It is reserved for
643 uint32_t oob_data_index;
647 * When it is set, this is a "no-push" receive.
648 * When it is clear, this is a "push" receive.
650 * Bit 1-15: Reserved and shall be zero
655 * For debugging and diagnoses purpose.
656 * The SeqNo is per TCP connection and starts from 0.
659 } __packed nvsp_2_msg_post_chimney_rx_request;
662 * NvspMessage2TypePostChimneyRecvRequestComplete
664 typedef struct nvsp_2_msg_post_chimney_rx_request_complete_ {
666 * The NDIS_STATUS for the chimney send
671 * Number of bytes that have been sent to the peer (and ACKed by
674 uint32_t bytes_xferred;
675 } __packed nvsp_2_msg_post_chimney_rx_request_complete;
678 * NvspMessage2TypeAllocateReceiveBuffer
680 typedef struct nvsp_2_msg_alloc_rx_buf_ {
682 * Allocation ID to match the allocation request and response
684 uint32_t allocation_id;
687 * Length of the VM shared memory receive buffer that needs to
691 } __packed nvsp_2_msg_alloc_rx_buf;
694 * NvspMessage2TypeAllocateReceiveBufferComplete
696 typedef struct nvsp_2_msg_alloc_rx_buf_complete_ {
698 * The NDIS_STATUS code for buffer allocation
703 * Allocation ID from NVSP_2_MESSAGE_ALLOCATE_RECEIVE_BUFFER
705 uint32_t allocation_id;
708 * GPADL handle for the allocated receive buffer
710 uint32_t gpadl_handle;
713 * Receive buffer ID that is further used in
714 * NvspMessage2SendVmqRndisPacket
717 } __packed nvsp_2_msg_alloc_rx_buf_complete;
720 * NvspMessage2TypeFreeReceiveBuffer
722 typedef struct nvsp_2_msg_free_rx_buf_ {
724 * Receive buffer ID previous returned in
725 * NvspMessage2TypeAllocateReceiveBufferComplete message
728 } __packed nvsp_2_msg_free_rx_buf;
731 * This structure is used in defining the buffers in
732 * NVSP_2_MESSAGE_SEND_VMQ_RNDIS_PACKET structure
734 typedef struct nvsp_xfer_page_range_ {
736 * Specifies the ID of the receive buffer that has the buffer. This
737 * ID can be the general receive buffer ID specified in
738 * NvspMessage1TypeSendReceiveBuffer or it can be the shared memory
739 * receive buffer ID allocated by the VSC and specified in
740 * NvspMessage2TypeAllocateReceiveBufferComplete message
742 uint64_t xfer_page_set_id;
750 * Offset in bytes from the beginning of the buffer
752 uint32_t byte_offset;
753 } __packed nvsp_xfer_page_range;
756 * NvspMessage2SendVmqRndisPacket
758 typedef struct nvsp_2_msg_send_vmq_rndis_pkt_ {
760 * This field is specified by RNIDS. They assume there's
761 * two different channels of communication. However,
762 * the Network VSP only has one. Therefore, the channel
763 * travels with the RNDIS packet. It must be RMC_DATA
765 uint32_t channel_type;
768 * Only the Range element corresponding to the RNDIS header of
769 * the first RNDIS message in the multiple RNDIS messages sent
770 * in one NVSP message. Information about the data portions as well
771 * as the subsequent RNDIS messages in the same NVSP message are
772 * embedded in the RNDIS header itself
774 nvsp_xfer_page_range range;
775 } __packed nvsp_2_msg_send_vmq_rndis_pkt;
778 * This message is used by the VSC to complete
779 * a RNDIS VMQ message to the VSP. At this point,
780 * the initiator of this message can use any resources
781 * associated with the original RNDIS VMQ packet.
783 typedef struct nvsp_2_msg_send_vmq_rndis_pkt_complete_
786 } __packed nvsp_2_msg_send_vmq_rndis_pkt_complete;
789 typedef union nvsp_1_msg_uber_ {
790 nvsp_1_msg_send_ndis_version send_ndis_vers;
792 nvsp_1_msg_send_rx_buf send_rx_buf;
793 nvsp_1_msg_send_rx_buf_complete send_rx_buf_complete;
794 nvsp_1_msg_revoke_rx_buf revoke_rx_buf;
796 nvsp_1_msg_send_send_buf send_send_buf;
797 nvsp_1_msg_send_send_buf_complete send_send_buf_complete;
798 nvsp_1_msg_revoke_send_buf revoke_send_buf;
800 nvsp_1_msg_send_rndis_pkt send_rndis_pkt;
801 nvsp_1_msg_send_rndis_pkt_complete send_rndis_pkt_complete;
802 } __packed nvsp_1_msg_uber;
805 typedef union nvsp_2_msg_uber_ {
806 nvsp_2_msg_send_ndis_config send_ndis_config;
808 nvsp_2_msg_send_chimney_buf send_chimney_buf;
809 nvsp_2_msg_send_chimney_buf_complete send_chimney_buf_complete;
810 nvsp_2_msg_revoke_chimney_buf revoke_chimney_buf;
812 nvsp_2_msg_resume_chimney_rx_indication resume_chimney_rx_indication;
813 nvsp_2_msg_terminate_chimney terminate_chimney;
814 nvsp_2_msg_terminate_chimney_complete terminate_chimney_complete;
815 nvsp_2_msg_indicate_chimney_event indicate_chimney_event;
817 nvsp_2_msg_send_chimney_pkt send_chimney_packet;
818 nvsp_2_msg_send_chimney_pkt_complete send_chimney_packet_complete;
819 nvsp_2_msg_post_chimney_rx_request post_chimney_rx_request;
820 nvsp_2_msg_post_chimney_rx_request_complete
821 post_chimney_rx_request_complete;
823 nvsp_2_msg_alloc_rx_buf alloc_rx_buffer;
824 nvsp_2_msg_alloc_rx_buf_complete alloc_rx_buffer_complete;
825 nvsp_2_msg_free_rx_buf free_rx_buffer;
827 nvsp_2_msg_send_vmq_rndis_pkt send_vmq_rndis_pkt;
828 nvsp_2_msg_send_vmq_rndis_pkt_complete send_vmq_rndis_pkt_complete;
829 nvsp_2_msg_alloc_chimney_handle alloc_chimney_handle;
830 nvsp_2_msg_alloc_chimney_handle_complete alloc_chimney_handle_complete;
831 } __packed nvsp_2_msg_uber;
834 typedef union nvsp_all_msgs_ {
835 nvsp_msg_init_uber init_msgs;
836 nvsp_1_msg_uber vers_1_msgs;
837 nvsp_2_msg_uber vers_2_msgs;
838 } __packed nvsp_all_msgs;
843 typedef struct nvsp_msg_ {
850 * The following arguably belongs in a separate header file
857 #define NETVSC_SEND_BUFFER_SIZE (1024*1024*15) /* 15M */
858 #define NETVSC_SEND_BUFFER_ID 0xface
861 #define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024*16) /* 16MB */
863 #define NETVSC_RECEIVE_BUFFER_ID 0xcafe
865 #define NETVSC_RECEIVE_SG_COUNT 1
867 /* Preallocated receive packets */
868 #define NETVSC_RECEIVE_PACKETLIST_COUNT 256
871 * Maximum MTU we permit to be configured for a netvsc interface.
872 * When the code was developed, a max MTU of 12232 was tested and
873 * proven to work. 9K is a reasonable maximum for an Ethernet.
875 #define NETVSC_MAX_CONFIGURABLE_MTU (9 * 1024)
877 #define NETVSC_PACKET_SIZE PAGE_SIZE
884 * Per netvsc channel-specific
886 typedef struct netvsc_dev_ {
887 struct hv_device *dev;
888 int num_outstanding_sends;
890 /* Send buffer allocated by us but manages by NetVSP */
892 uint32_t send_buf_size;
893 uint32_t send_buf_gpadl_handle;
894 uint32_t send_section_size;
895 uint32_t send_section_count;
896 unsigned long bitsmap_words;
897 unsigned long *send_section_bitsmap;
899 /* Receive buffer allocated by us but managed by NetVSP */
901 uint32_t rx_buf_size;
902 uint32_t rx_buf_gpadl_handle;
903 uint32_t rx_section_count;
904 nvsp_1_rx_buf_section *rx_sections;
906 /* Used for NetVSP initialization protocol */
907 struct sema channel_init_sema;
908 nvsp_msg channel_init_packet;
910 nvsp_msg revoke_packet;
911 /*uint8_t hw_mac_addr[HW_MACADDR_LEN];*/
913 /* Holds rndis device info */
916 hv_bool_uint8_t destroy;
917 /* Negotiated NVSP version */
918 uint32_t nvsp_version;
920 uint8_t callback_buf[NETVSC_PACKET_SIZE];
924 typedef void (*pfn_on_send_rx_completion)(void *);
926 #define NETVSC_DEVICE_RING_BUFFER_SIZE (128 * PAGE_SIZE)
927 #define NETVSC_PACKET_MAXPAGE 32
930 #define NETVSC_VLAN_PRIO_MASK 0xe000
931 #define NETVSC_VLAN_PRIO_SHIFT 13
932 #define NETVSC_VLAN_VID_MASK 0x0fff
939 #define TRANSPORT_TYPE_NOT_IP 0
940 #define TRANSPORT_TYPE_IPV4_TCP ((TYPE_IPV4 << 16) | TYPE_TCP)
941 #define TRANSPORT_TYPE_IPV4_UDP ((TYPE_IPV4 << 16) | TYPE_UDP)
942 #define TRANSPORT_TYPE_IPV6_TCP ((TYPE_IPV6 << 16) | TYPE_TCP)
943 #define TRANSPORT_TYPE_IPV6_UDP ((TYPE_IPV6 << 16) | TYPE_UDP)
946 #define BITS_PER_LONG 64
948 #define BITS_PER_LONG 32
951 typedef struct netvsc_packet_ {
952 struct hv_device *device;
953 hv_bool_uint8_t is_data_pkt; /* One byte */
960 uint64_t rx_completion_tid;
961 void *rx_completion_context;
962 /* This is no longer used */
963 pfn_on_send_rx_completion on_rx_completion;
966 uint64_t send_completion_tid;
967 void *send_completion_context;
968 /* Still used in netvsc and filter code */
969 pfn_on_send_rx_completion on_send_completion;
972 uint32_t send_buf_section_idx;
973 uint32_t send_buf_section_size;
976 uint32_t tot_data_buf_len;
978 uint32_t page_buf_count;
979 hv_vmbus_page_buffer page_buffers[NETVSC_PACKET_MAXPAGE];
983 uint8_t mac_addr[6]; /* Assumption unsigned long */
984 hv_bool_uint8_t link_state;
985 } netvsc_device_info;
988 * Device-specific softc structure
990 typedef struct hn_softc {
991 struct ifnet *hn_ifp;
992 struct ifmedia hn_media;
999 /* See hv_netvsc_drv_freebsd.c for rules on how to use */
1001 struct hv_device *hn_dev_obj;
1002 netvsc_dev *net_dev;
1004 struct lro_ctrl hn_lro;
1007 /* Trust tcp segments verification on host side */
1008 int hn_trust_hosttcp;
1012 u_long hn_csum_trusted;
1013 u_long hn_lro_tried;
1014 u_long hn_small_pkts;
1021 extern int hv_promisc_mode;
1023 void netvsc_linkstatus_callback(struct hv_device *device_obj, uint32_t status);
1024 void netvsc_xmit_completion(void *context);
1025 void hv_nv_on_receive_completion(struct hv_device *device,
1026 uint64_t tid, uint32_t status);
1027 netvsc_dev *hv_nv_on_device_add(struct hv_device *device,
1028 void *additional_info);
1029 int hv_nv_on_device_remove(struct hv_device *device,
1030 boolean_t destroy_channel);
1031 int hv_nv_on_send(struct hv_device *device, netvsc_packet *pkt);
1032 int hv_nv_get_next_send_section(netvsc_dev *net_dev);
1034 #endif /* __HV_NET_VSC_H__ */