Home | History | Annotate | Line # | Download | only in pci
      1 /*	$NetBSD: if_iavfvar.h,v 1.1 2020/09/08 10:05:47 yamaguchi Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2020 Internet Initiative Japan, Inc.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  * POSSIBILITY OF SUCH DAMAGE.
     27  */
     28 
     29 #ifndef _DEV_PCI_IF_IAVFVAR_H_
     30 #define _DEV_PCI_IF_IAVFVAR_H_
     31 
     32 /* aq commands */
     33 #define IAVF_AQ_OP_SEND_TO_PF		0x0801
     34 #define IAVF_AQ_OP_MSG_FROM_PF		0x0802
     35 #define IAVF_AQ_OP_SHUTDOWN		0x0803
     36 
     37 /* virt channel messages */
     38 #define IAVF_VC_OP_VERSION		1
     39 #define IAVF_VC_OP_RESET_VF		2
     40 #define IAVF_VC_OP_GET_VF_RESOURCES	3
     41 #define IAVF_VC_OP_CONFIG_TX_QUEUE	4
     42 #define IAVF_VC_OP_CONFIG_RX_QUEUE	5
     43 #define IAVF_VC_OP_CONFIG_VSI_QUEUES	6
     44 #define IAVF_VC_OP_CONFIG_IRQ_MAP	7
     45 #define IAVF_VC_OP_ENABLE_QUEUES	8
     46 #define IAVF_VC_OP_DISABLE_QUEUES	9
     47 #define IAVF_VC_OP_ADD_ETH_ADDR		10
     48 #define IAVF_VC_OP_DEL_ETH_ADDR		11
     49 #define IAVF_VC_OP_ADD_VLAN		12
     50 #define IAVF_VC_OP_DEL_VLAN		13
     51 #define IAVF_VC_OP_CONFIG_PROMISC	14
     52 #define IAVF_VC_OP_GET_STATS		15
     53 #define IAVF_VC_OP_EVENT		17
     54 #define IAVF_VC_OP_CONFIG_RSS_KEY	23
     55 #define IAVF_VC_OP_CONFIG_RSS_LUT	24
     56 #define IAVF_VC_OP_GET_RSS_HENA_CAPS	25
     57 #define IAVF_VC_OP_SET_RSS_HENA		26
     58 #define IAVF_VC_OP_ENABLE_VLAN_STRIP	27
     59 #define IAVF_VC_OP_DISABLE_VLAN_STRIP	28
     60 #define IAVF_VC_OP_REQUEST_QUEUES	29
     61 
     62 /* virt channel response codes */
     63 #define IAVF_VC_RC_SUCCESS		0
     64 #define IAVF_VC_RC_ERR_PARAM		-5
     65 #define IAVF_VC_RC_ERR_OPCODE		-38
     66 #define IAVF_VC_RC_ERR_CQP_COMPL	-39
     67 #define IAVF_VC_RC_ERR_VF_ID		-40
     68 #define IAVF_VC_RC_ERR_NOT_SUP		-64
     69 
     70 /* virt channel events */
     71 #define IAVF_VC_EVENT_LINK_CHANGE	1
     72 #define IAVF_VC_EVENT_RESET_IMPENDING	2
     73 #define IAVF_VC_EVENT_PF_DRIVER_CLOSE	3
     74 
     75 /* virt channel offloads */
     76 #define IAVF_VC_OFFLOAD_L2		0x00000001
     77 #define IAVF_VC_OFFLOAD_IWARP		0x00000002
     78 #define IAVF_VC_OFFLOAD_RSVD		0x00000004
     79 #define IAVF_VC_OFFLOAD_RSS_AQ		0x00000008
     80 #define IAVF_VC_OFFLOAD_RSS_REG		0x00000010
     81 #define IAVF_VC_OFFLOAD_WB_ON_ITR	0x00000020
     82 #define IAVF_VC_OFFLOAD_REQ_QUEUES	0x00000040
     83 #define IAVF_VC_OFFLOAD_VLAN		0x00010000
     84 #define IAVF_VC_OFFLOAD_RX_POLLING	0x00020000
     85 #define IAVF_VC_OFFLOAD_RSS_PCTYPE_V2	0x00040000
     86 #define IAVF_VC_OFFLOAD_RSS_PF		0x00080000
     87 #define IAVF_VC_OFFLOAD_ENCAP		0x00100000
     88 #define IAVF_VC_OFFLOAD_ENCAP_CSUM	0x00200000
     89 #define IAVF_VC_OFFLOAD_RX_ENCAP_CSUM	0x00400000
     90 
     91 #define IAVF_VC_OFFLOAD_FMT	"\020"					\
     92 				"\027RENCAP" "\026ENCAPC" "\025ENCAP"	\
     93 				"\024RSSPF" "\023RSSV2" "\022RPOLL"	\
     94 				"\021VLAN" "\007REQQ" "\006WB"		\
     95 				"\005RSSREG" "\004RSSAQ" "\003RSVD"	\
     96 				"\002IWARP" "\001L2"
     97 
     98 struct iavf_aq_vc {
     99 	uint32_t	 iaq_vc_opcode;
    100 	uint32_t	 iaq_vc_retval;
    101 } __packed;
    102 
    103 struct iavf_vc_version_info {
    104 	uint32_t	major;
    105 	uint32_t	minor;
    106 } __packed;
    107 
    108 struct iavf_vc_vsi_resource {
    109 	uint16_t	vsi_id;
    110 	uint16_t	num_queue_pairs;
    111 	uint32_t	vsi_type;
    112 	uint16_t	qset_handle;
    113 	uint8_t		default_mac[ETHER_ADDR_LEN];
    114 } __packed;
    115 
    116 struct iavf_vc_vf_resource {
    117 	uint16_t	num_vsis;
    118 	uint16_t	num_qp;
    119 	uint16_t	max_vectors;
    120 	uint16_t	max_mtu;
    121 	uint32_t	offload_flags;
    122 	uint32_t	rss_key_size;
    123 	uint32_t	rss_lut_size;
    124 	struct iavf_vc_vsi_resource
    125 			vsi_res[1];
    126 } __packed;
    127 
    128 struct iavf_vc_vector_map {
    129 	uint16_t	vsi_id;
    130 	uint16_t	vector_id;
    131 	uint16_t	rxq_map;
    132 	uint16_t	txq_map;
    133 	uint16_t	rxitr_idx;
    134 	uint16_t	txitr_idx;
    135 } __packed;
    136 
    137 struct iavf_vc_irq_map_info {
    138 	uint16_t	num_vectors;
    139 	struct iavf_vc_vector_map vecmap[1];
    140 } __packed;
    141 
    142 struct iavf_vc_txq_info {
    143 	uint16_t	vsi_id;
    144 	uint16_t	queue_id;
    145 	uint16_t	ring_len;
    146 	uint16_t	headwb_ena;		/* deprecated */
    147 	uint64_t	dma_ring_addr;
    148 	uint64_t	dma_headwb_addr;	/* deprecated */
    149 } __packed;
    150 
    151 struct iavf_vc_rxq_info {
    152 	uint16_t	vsi_id;
    153 	uint16_t	queue_id;
    154 	uint32_t	ring_len;
    155 	uint16_t	hdr_size;
    156 	uint16_t	splithdr_ena;
    157 	uint32_t	databuf_size;
    158 	uint32_t	max_pkt_size;
    159 	uint32_t	pad1;
    160 	uint64_t	dma_ring_addr;
    161 	uint32_t	rx_split_pos;
    162 	uint32_t	pad2;
    163 } __packed;
    164 
    165 struct iavf_vc_queue_pair_info {
    166 	struct iavf_vc_txq_info	txq;
    167 	struct iavf_vc_rxq_info	rxq;
    168 } __packed;
    169 
    170 struct iavf_vc_queue_config_info {
    171 	uint16_t	vsi_id;
    172 	uint16_t	num_queue_pairs;
    173 	uint32_t	pad;
    174 	struct iavf_vc_queue_pair_info qpair[1];
    175 } __packed;
    176 
    177 struct iavf_vc_queue_select {
    178 	uint16_t	vsi_id;
    179 	uint16_t	pad;
    180 	uint32_t	rx_queues;
    181 	uint32_t	tx_queues;
    182 } __packed;
    183 
    184 struct iavf_vc_promisc_info {
    185 	uint16_t	vsi_id;
    186 	uint16_t	flags;
    187 #define IAVF_FLAG_VF_UNICAST_PROMISC	0x0001
    188 #define IAVF_FLAG_VF_MULTICAST_PROMISC	0x0002
    189 } __packed;
    190 
    191 struct iavf_vc_eth_addr {
    192 	uint8_t		addr[ETHER_ADDR_LEN];
    193 	uint8_t		pad[2];
    194 } __packed;
    195 
    196 struct iavf_vc_eth_addr_list {
    197 	uint16_t	vsi_id;
    198 	uint16_t	num_elements;
    199 	struct iavf_vc_eth_addr list[1];
    200 } __packed;
    201 
    202 struct iavf_vc_pf_event {
    203 	uint32_t	event;
    204 	uint32_t	link_speed;
    205 	uint8_t		link_status;
    206 	uint8_t		pad[3];
    207 	uint32_t	severity;
    208 } __packed;
    209 
    210 struct iavf_vc_vlan_filter {
    211 	uint16_t	vsi_id;
    212 	uint16_t	num_vlan_id;
    213 	uint16_t	vlan_id[1];
    214 } __packed;
    215 
    216 struct iavf_vc_rss_key {
    217 	uint16_t	vsi_id;
    218 	uint16_t	key_len;
    219 	uint8_t		key[1];
    220 	uint8_t		pad[1];
    221 } __packed;
    222 
    223 struct iavf_vc_rss_lut {
    224 	uint16_t	vsi_id;
    225 	uint16_t	lut_entries;
    226 	uint8_t		lut[1];
    227 	uint8_t		pad[1];
    228 }__packed;
    229 
    230 #define IAVF_RSS_VSI_LUT_ENTRY_MASK	0x3F
    231 
    232 struct iavf_vc_res_request {
    233 	uint16_t	 num_queue_pairs;
    234 } __packed;
    235 
    236 #define I40E_MAX_VF_QUEUES	16
    237 
    238 #endif
    239