Commit | Line | Data |
---|---|---|
dcc4086d | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
43fc70a2 | 2 | /* Copyright (c) 2013-2022, Intel Corporation. */ |
62683ab5 | 3 | |
310a2ad9 JB |
4 | #ifndef _VIRTCHNL_H_ |
5 | #define _VIRTCHNL_H_ | |
62683ab5 | 6 | |
7151d87a IV |
7 | #include <linux/bitops.h> |
8 | #include <linux/overflow.h> | |
9 | #include <uapi/linux/if_ether.h> | |
10 | ||
62683ab5 | 11 | /* Description: |
43fc70a2 JB |
12 | * This header file describes the Virtual Function (VF) - Physical Function |
13 | * (PF) communication protocol used by the drivers for all devices starting | |
14 | * from our 40G product line | |
62683ab5 GR |
15 | * |
16 | * Admin queue buffer usage: | |
ff3f4cc2 | 17 | * desc->opcode is always aqc_opc_send_msg_to_pf |
62683ab5 | 18 | * flags, retval, datalen, and data addr are all used normally. |
ff3f4cc2 JB |
19 | * The Firmware copies the cookie fields when sending messages between the |
20 | * PF and VF, but uses all other fields internally. Due to this limitation, | |
21 | * we must send all messages as "indirect", i.e. using an external buffer. | |
62683ab5 | 22 | * |
ff3f4cc2 | 23 | * All the VSI indexes are relative to the VF. Each VF can have maximum of |
62683ab5 GR |
24 | * three VSIs. All the queue indexes are relative to the VSI. Each VF can |
25 | * have a maximum of sixteen queues for all of its VSIs. | |
26 | * | |
27 | * The PF is required to return a status code in v_retval for all messages | |
43fc70a2 JB |
28 | * except RESET_VF, which does not require any response. The returned value |
29 | * is of virtchnl_status_code type, defined here. | |
62683ab5 | 30 | * |
ff3f4cc2 JB |
31 | * In general, VF driver initialization should roughly follow the order of |
32 | * these opcodes. The VF driver must first validate the API version of the | |
33 | * PF driver, then request a reset, then get resources, then configure | |
34 | * queues and interrupts. After these operations are complete, the VF | |
35 | * driver may start its queues, optionally add MAC and VLAN filters, and | |
36 | * process traffic. | |
62683ab5 GR |
37 | */ |
38 | ||
764430ce JB |
39 | /* START GENERIC DEFINES |
40 | * Need to ensure the following enums and defines hold the same meaning and | |
41 | * value in current and future projects | |
42 | */ | |
43 | ||
44 | /* Error Codes */ | |
45 | enum virtchnl_status_code { | |
46 | VIRTCHNL_STATUS_SUCCESS = 0, | |
bb58fd7e MW |
47 | VIRTCHNL_STATUS_ERR_PARAM = -5, |
48 | VIRTCHNL_STATUS_ERR_NO_MEMORY = -18, | |
764430ce JB |
49 | VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH = -38, |
50 | VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR = -39, | |
51 | VIRTCHNL_STATUS_ERR_INVALID_VF_ID = -40, | |
bb58fd7e MW |
52 | VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR = -53, |
53 | VIRTCHNL_STATUS_ERR_NOT_SUPPORTED = -64, | |
764430ce JB |
54 | }; |
55 | ||
bb58fd7e MW |
56 | /* Backward compatibility */ |
57 | #define VIRTCHNL_ERR_PARAM VIRTCHNL_STATUS_ERR_PARAM | |
58 | #define VIRTCHNL_STATUS_NOT_SUPPORTED VIRTCHNL_STATUS_ERR_NOT_SUPPORTED | |
59 | ||
4ae4916b | 60 | #define VIRTCHNL_LINK_SPEED_2_5GB_SHIFT 0x0 |
ff3f4cc2 JB |
61 | #define VIRTCHNL_LINK_SPEED_100MB_SHIFT 0x1 |
62 | #define VIRTCHNL_LINK_SPEED_1000MB_SHIFT 0x2 | |
63 | #define VIRTCHNL_LINK_SPEED_10GB_SHIFT 0x3 | |
64 | #define VIRTCHNL_LINK_SPEED_40GB_SHIFT 0x4 | |
65 | #define VIRTCHNL_LINK_SPEED_20GB_SHIFT 0x5 | |
66 | #define VIRTCHNL_LINK_SPEED_25GB_SHIFT 0x6 | |
4ae4916b | 67 | #define VIRTCHNL_LINK_SPEED_5GB_SHIFT 0x7 |
ff3f4cc2 JB |
68 | |
69 | enum virtchnl_link_speed { | |
70 | VIRTCHNL_LINK_SPEED_UNKNOWN = 0, | |
71 | VIRTCHNL_LINK_SPEED_100MB = BIT(VIRTCHNL_LINK_SPEED_100MB_SHIFT), | |
72 | VIRTCHNL_LINK_SPEED_1GB = BIT(VIRTCHNL_LINK_SPEED_1000MB_SHIFT), | |
73 | VIRTCHNL_LINK_SPEED_10GB = BIT(VIRTCHNL_LINK_SPEED_10GB_SHIFT), | |
74 | VIRTCHNL_LINK_SPEED_40GB = BIT(VIRTCHNL_LINK_SPEED_40GB_SHIFT), | |
75 | VIRTCHNL_LINK_SPEED_20GB = BIT(VIRTCHNL_LINK_SPEED_20GB_SHIFT), | |
76 | VIRTCHNL_LINK_SPEED_25GB = BIT(VIRTCHNL_LINK_SPEED_25GB_SHIFT), | |
4ae4916b AL |
77 | VIRTCHNL_LINK_SPEED_2_5GB = BIT(VIRTCHNL_LINK_SPEED_2_5GB_SHIFT), |
78 | VIRTCHNL_LINK_SPEED_5GB = BIT(VIRTCHNL_LINK_SPEED_5GB_SHIFT), | |
ff3f4cc2 JB |
79 | }; |
80 | ||
81 | /* for hsplit_0 field of Rx HMC context */ | |
82 | /* deprecated with AVF 1.0 */ | |
83 | enum virtchnl_rx_hsplit { | |
84 | VIRTCHNL_RX_HSPLIT_NO_SPLIT = 0, | |
85 | VIRTCHNL_RX_HSPLIT_SPLIT_L2 = 1, | |
86 | VIRTCHNL_RX_HSPLIT_SPLIT_IP = 2, | |
87 | VIRTCHNL_RX_HSPLIT_SPLIT_TCP_UDP = 4, | |
88 | VIRTCHNL_RX_HSPLIT_SPLIT_SCTP = 8, | |
89 | }; | |
90 | ||
764430ce JB |
91 | /* END GENERIC DEFINES */ |
92 | ||
62683ab5 GR |
93 | /* Opcodes for VF-PF communication. These are placed in the v_opcode field |
94 | * of the virtchnl_msg structure. | |
95 | */ | |
310a2ad9 | 96 | enum virtchnl_ops { |
396642a6 | 97 | /* The PF sends status change events to VFs using |
310a2ad9 | 98 | * the VIRTCHNL_OP_EVENT opcode. |
396642a6 | 99 | * VFs send requests to the PF using the other ops. |
ff3f4cc2 JB |
100 | * Use of "advanced opcode" features must be negotiated as part of capabilities |
101 | * exchange and are not considered part of base mode feature set. | |
62683ab5 | 102 | */ |
310a2ad9 JB |
103 | VIRTCHNL_OP_UNKNOWN = 0, |
104 | VIRTCHNL_OP_VERSION = 1, /* must ALWAYS be 1 */ | |
105 | VIRTCHNL_OP_RESET_VF = 2, | |
106 | VIRTCHNL_OP_GET_VF_RESOURCES = 3, | |
107 | VIRTCHNL_OP_CONFIG_TX_QUEUE = 4, | |
108 | VIRTCHNL_OP_CONFIG_RX_QUEUE = 5, | |
109 | VIRTCHNL_OP_CONFIG_VSI_QUEUES = 6, | |
110 | VIRTCHNL_OP_CONFIG_IRQ_MAP = 7, | |
111 | VIRTCHNL_OP_ENABLE_QUEUES = 8, | |
112 | VIRTCHNL_OP_DISABLE_QUEUES = 9, | |
113 | VIRTCHNL_OP_ADD_ETH_ADDR = 10, | |
114 | VIRTCHNL_OP_DEL_ETH_ADDR = 11, | |
115 | VIRTCHNL_OP_ADD_VLAN = 12, | |
116 | VIRTCHNL_OP_DEL_VLAN = 13, | |
117 | VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE = 14, | |
118 | VIRTCHNL_OP_GET_STATS = 15, | |
119 | VIRTCHNL_OP_RSVD = 16, | |
120 | VIRTCHNL_OP_EVENT = 17, /* must ALWAYS be 17 */ | |
2723f3b5 | 121 | /* opcode 19 is reserved */ |
ff3f4cc2 | 122 | VIRTCHNL_OP_IWARP = 20, /* advanced opcode */ |
2723f3b5 | 123 | VIRTCHNL_OP_RDMA = VIRTCHNL_OP_IWARP, |
ff3f4cc2 | 124 | VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP = 21, /* advanced opcode */ |
2723f3b5 | 125 | VIRTCHNL_OP_CONFIG_RDMA_IRQ_MAP = VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP, |
ff3f4cc2 | 126 | VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP = 22, /* advanced opcode */ |
2723f3b5 | 127 | VIRTCHNL_OP_RELEASE_RDMA_IRQ_MAP = VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP, |
310a2ad9 JB |
128 | VIRTCHNL_OP_CONFIG_RSS_KEY = 23, |
129 | VIRTCHNL_OP_CONFIG_RSS_LUT = 24, | |
130 | VIRTCHNL_OP_GET_RSS_HENA_CAPS = 25, | |
131 | VIRTCHNL_OP_SET_RSS_HENA = 26, | |
8774370d MS |
132 | VIRTCHNL_OP_ENABLE_VLAN_STRIPPING = 27, |
133 | VIRTCHNL_OP_DISABLE_VLAN_STRIPPING = 28, | |
a3f5aa90 | 134 | VIRTCHNL_OP_REQUEST_QUEUES = 29, |
eb09f1fe HR |
135 | VIRTCHNL_OP_ENABLE_CHANNELS = 30, |
136 | VIRTCHNL_OP_DISABLE_CHANNELS = 31, | |
3872c8d4 HR |
137 | VIRTCHNL_OP_ADD_CLOUD_FILTER = 32, |
138 | VIRTCHNL_OP_DEL_CLOUD_FILTER = 33, | |
e753df8f MJ |
139 | /* opcode 34 - 43 are reserved */ |
140 | VIRTCHNL_OP_GET_SUPPORTED_RXDIDS = 44, | |
222a8ab0 QZ |
141 | VIRTCHNL_OP_ADD_RSS_CFG = 45, |
142 | VIRTCHNL_OP_DEL_RSS_CFG = 46, | |
1f7ea1cd QZ |
143 | VIRTCHNL_OP_ADD_FDIR_FILTER = 47, |
144 | VIRTCHNL_OP_DEL_FDIR_FILTER = 48, | |
bd0b536d BC |
145 | VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS = 51, |
146 | VIRTCHNL_OP_ADD_VLAN_V2 = 52, | |
147 | VIRTCHNL_OP_DEL_VLAN_V2 = 53, | |
148 | VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 = 54, | |
149 | VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 = 55, | |
150 | VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 = 56, | |
151 | VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 = 57, | |
c0dcaa55 | 152 | VIRTCHNL_OP_MAX, |
62683ab5 GR |
153 | }; |
154 | ||
0718e560 | 155 | /* These macros are used to generate compilation errors if a structure/union |
73556269 | 156 | * is not exactly the correct length. It gives a divide by zero error if the |
0718e560 HR |
157 | * structure/union is not of the correct size, otherwise it creates an enum |
158 | * that is never used. | |
73556269 SS |
159 | */ |
160 | #define VIRTCHNL_CHECK_STRUCT_LEN(n, X) enum virtchnl_static_assert_enum_##X \ | |
161 | { virtchnl_static_assert_##X = (n)/((sizeof(struct X) == (n)) ? 1 : 0) } | |
0718e560 HR |
162 | #define VIRTCHNL_CHECK_UNION_LEN(n, X) enum virtchnl_static_asset_enum_##X \ |
163 | { virtchnl_static_assert_##X = (n)/((sizeof(union X) == (n)) ? 1 : 0) } | |
73556269 | 164 | |
c9a98305 | 165 | /* Message descriptions and data structures. */ |
62683ab5 | 166 | |
310a2ad9 | 167 | /* VIRTCHNL_OP_VERSION |
62683ab5 GR |
168 | * VF posts its version number to the PF. PF responds with its version number |
169 | * in the same format, along with a return code. | |
170 | * Reply from PF has its major/minor versions also in param0 and param1. | |
171 | * If there is a major version mismatch, then the VF cannot operate. | |
172 | * If there is a minor version mismatch, then the VF can operate but should | |
173 | * add a warning to the system log. | |
174 | * | |
175 | * This enum element MUST always be specified as == 1, regardless of other | |
176 | * changes in the API. The PF must always respond to this message without | |
177 | * error regardless of version mismatch. | |
178 | */ | |
310a2ad9 JB |
179 | #define VIRTCHNL_VERSION_MAJOR 1 |
180 | #define VIRTCHNL_VERSION_MINOR 1 | |
181 | #define VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0 | |
1b53c2fb | 182 | |
310a2ad9 | 183 | struct virtchnl_version_info { |
62683ab5 GR |
184 | u32 major; |
185 | u32 minor; | |
186 | }; | |
187 | ||
73556269 SS |
188 | VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_version_info); |
189 | ||
eedcfef8 JB |
190 | #define VF_IS_V10(_v) (((_v)->major == 1) && ((_v)->minor == 0)) |
191 | #define VF_IS_V11(_ver) (((_ver)->major == 1) && ((_ver)->minor == 1)) | |
192 | ||
310a2ad9 | 193 | /* VIRTCHNL_OP_RESET_VF |
62683ab5 GR |
194 | * VF sends this request to PF with no parameters |
195 | * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register | |
196 | * until reset completion is indicated. The admin queue must be reinitialized | |
197 | * after this operation. | |
198 | * | |
199 | * When reset is complete, PF must ensure that all queues in all VSIs associated | |
200 | * with the VF are stopped, all queue configurations in the HMC are set to 0, | |
201 | * and all MAC and VLAN filters (except the default MAC address) on all VSIs | |
202 | * are cleared. | |
203 | */ | |
204 | ||
ff3f4cc2 JB |
205 | /* VSI types that use VIRTCHNL interface for VF-PF communication. VSI_SRIOV |
206 | * vsi_type should always be 6 for backward compatibility. Add other fields | |
207 | * as needed. | |
208 | */ | |
209 | enum virtchnl_vsi_type { | |
210 | VIRTCHNL_VSI_TYPE_INVALID = 0, | |
211 | VIRTCHNL_VSI_SRIOV = 6, | |
212 | }; | |
213 | ||
310a2ad9 | 214 | /* VIRTCHNL_OP_GET_VF_RESOURCES |
1b53c2fb MW |
215 | * Version 1.0 VF sends this request to PF with no parameters |
216 | * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities | |
62683ab5 | 217 | * PF responds with an indirect message containing |
310a2ad9 JB |
218 | * virtchnl_vf_resource and one or more |
219 | * virtchnl_vsi_resource structures. | |
62683ab5 GR |
220 | */ |
221 | ||
310a2ad9 | 222 | struct virtchnl_vsi_resource { |
62683ab5 GR |
223 | u16 vsi_id; |
224 | u16 num_queue_pairs; | |
4e4df559 JB |
225 | |
226 | /* see enum virtchnl_vsi_type */ | |
227 | s32 vsi_type; | |
62683ab5 GR |
228 | u16 qset_handle; |
229 | u8 default_mac_addr[ETH_ALEN]; | |
230 | }; | |
ff3f4cc2 | 231 | |
73556269 SS |
232 | VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource); |
233 | ||
fbb113f7 | 234 | /* VF capability flags |
ff3f4cc2 JB |
235 | * VIRTCHNL_VF_OFFLOAD_L2 flag is inclusive of base mode L2 offloads including |
236 | * TX/RX Checksum offloading and TSO for non-tunnelled packets. | |
237 | */ | |
4a15022f | 238 | #define VIRTCHNL_VF_OFFLOAD_L2 BIT(0) |
2723f3b5 JB |
239 | #define VIRTCHNL_VF_OFFLOAD_RDMA BIT(1) |
240 | #define VIRTCHNL_VF_CAP_RDMA VIRTCHNL_VF_OFFLOAD_RDMA | |
4a15022f BC |
241 | #define VIRTCHNL_VF_OFFLOAD_RSS_AQ BIT(3) |
242 | #define VIRTCHNL_VF_OFFLOAD_RSS_REG BIT(4) | |
243 | #define VIRTCHNL_VF_OFFLOAD_WB_ON_ITR BIT(5) | |
244 | #define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6) | |
245 | /* used to negotiate communicating link speeds in Mbps */ | |
246 | #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7) | |
89de9921 | 247 | #define VIRTCHNL_VF_OFFLOAD_CRC BIT(10) |
bd0b536d | 248 | #define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15) |
4a15022f BC |
249 | #define VIRTCHNL_VF_OFFLOAD_VLAN BIT(16) |
250 | #define VIRTCHNL_VF_OFFLOAD_RX_POLLING BIT(17) | |
251 | #define VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 BIT(18) | |
252 | #define VIRTCHNL_VF_OFFLOAD_RSS_PF BIT(19) | |
253 | #define VIRTCHNL_VF_OFFLOAD_ENCAP BIT(20) | |
254 | #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM BIT(21) | |
255 | #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM BIT(22) | |
256 | #define VIRTCHNL_VF_OFFLOAD_ADQ BIT(23) | |
257 | #define VIRTCHNL_VF_OFFLOAD_USO BIT(25) | |
e753df8f | 258 | #define VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC BIT(26) |
4a15022f BC |
259 | #define VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF BIT(27) |
260 | #define VIRTCHNL_VF_OFFLOAD_FDIR_PF BIT(28) | |
261 | ||
ff3f4cc2 JB |
262 | #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \ |
263 | VIRTCHNL_VF_OFFLOAD_VLAN | \ | |
264 | VIRTCHNL_VF_OFFLOAD_RSS_PF) | |
310a2ad9 JB |
265 | |
266 | struct virtchnl_vf_resource { | |
62683ab5 GR |
267 | u16 num_vsis; |
268 | u16 num_queue_pairs; | |
269 | u16 max_vectors; | |
270 | u16 max_mtu; | |
271 | ||
fbb113f7 | 272 | u32 vf_cap_flags; |
585954f8 MW |
273 | u32 rss_key_size; |
274 | u32 rss_lut_size; | |
62683ab5 | 275 | |
5e7f59fa | 276 | struct virtchnl_vsi_resource vsi_res[]; |
62683ab5 GR |
277 | }; |
278 | ||
5e7f59fa AL |
279 | VIRTCHNL_CHECK_STRUCT_LEN(20, virtchnl_vf_resource); |
280 | #define virtchnl_vf_resource_LEGACY_SIZEOF 36 | |
73556269 | 281 | |
310a2ad9 | 282 | /* VIRTCHNL_OP_CONFIG_TX_QUEUE |
62683ab5 | 283 | * VF sends this message to set up parameters for one TX queue. |
310a2ad9 | 284 | * External data buffer contains one instance of virtchnl_txq_info. |
62683ab5 GR |
285 | * PF configures requested queue and returns a status code. |
286 | */ | |
287 | ||
288 | /* Tx queue config info */ | |
310a2ad9 | 289 | struct virtchnl_txq_info { |
62683ab5 GR |
290 | u16 vsi_id; |
291 | u16 queue_id; | |
292 | u16 ring_len; /* number of descriptors, multiple of 8 */ | |
ff3f4cc2 | 293 | u16 headwb_enabled; /* deprecated with AVF 1.0 */ |
62683ab5 | 294 | u64 dma_ring_addr; |
ff3f4cc2 | 295 | u64 dma_headwb_addr; /* deprecated with AVF 1.0 */ |
62683ab5 GR |
296 | }; |
297 | ||
73556269 SS |
298 | VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_txq_info); |
299 | ||
310a2ad9 | 300 | /* VIRTCHNL_OP_CONFIG_RX_QUEUE |
62683ab5 | 301 | * VF sends this message to set up parameters for one RX queue. |
310a2ad9 | 302 | * External data buffer contains one instance of virtchnl_rxq_info. |
89de9921 PSJ |
303 | * PF configures requested queue and returns a status code. The |
304 | * crc_disable flag disables CRC stripping on the VF. Setting | |
305 | * the crc_disable flag to 1 will disable CRC stripping for each | |
306 | * queue in the VF where the flag is set. The VIRTCHNL_VF_OFFLOAD_CRC | |
307 | * offload must have been set prior to sending this info or the PF | |
308 | * will ignore the request. This flag should be set the same for | |
309 | * all of the queues for a VF. | |
62683ab5 GR |
310 | */ |
311 | ||
312 | /* Rx queue config info */ | |
310a2ad9 | 313 | struct virtchnl_rxq_info { |
62683ab5 GR |
314 | u16 vsi_id; |
315 | u16 queue_id; | |
316 | u32 ring_len; /* number of descriptors, multiple of 32 */ | |
317 | u16 hdr_size; | |
ff3f4cc2 | 318 | u16 splithdr_enabled; /* deprecated with AVF 1.0 */ |
62683ab5 GR |
319 | u32 databuffer_size; |
320 | u32 max_pkt_size; | |
89de9921 | 321 | u8 crc_disable; |
e753df8f MJ |
322 | u8 rxdid; |
323 | u8 pad1[2]; | |
62683ab5 | 324 | u64 dma_ring_addr; |
4e4df559 JB |
325 | |
326 | /* see enum virtchnl_rx_hsplit; deprecated with AVF 1.0 */ | |
327 | s32 rx_split_pos; | |
a33c83c4 | 328 | u32 pad2; |
62683ab5 GR |
329 | }; |
330 | ||
73556269 SS |
331 | VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_rxq_info); |
332 | ||
310a2ad9 | 333 | /* VIRTCHNL_OP_CONFIG_VSI_QUEUES |
62683ab5 GR |
334 | * VF sends this message to set parameters for all active TX and RX queues |
335 | * associated with the specified VSI. | |
336 | * PF configures queues and returns status. | |
337 | * If the number of queues specified is greater than the number of queues | |
338 | * associated with the VSI, an error is returned and no queues are configured. | |
43fc70a2 JB |
339 | * NOTE: The VF is not required to configure all queues in a single request. |
340 | * It may send multiple messages. PF drivers must correctly handle all VF | |
341 | * requests. | |
62683ab5 | 342 | */ |
310a2ad9 | 343 | struct virtchnl_queue_pair_info { |
62683ab5 | 344 | /* NOTE: vsi_id and queue_id should be identical for both queues. */ |
310a2ad9 JB |
345 | struct virtchnl_txq_info txq; |
346 | struct virtchnl_rxq_info rxq; | |
62683ab5 GR |
347 | }; |
348 | ||
73556269 SS |
349 | VIRTCHNL_CHECK_STRUCT_LEN(64, virtchnl_queue_pair_info); |
350 | ||
310a2ad9 | 351 | struct virtchnl_vsi_queue_config_info { |
62683ab5 GR |
352 | u16 vsi_id; |
353 | u16 num_queue_pairs; | |
a33c83c4 | 354 | u32 pad; |
5e7f59fa | 355 | struct virtchnl_queue_pair_info qpair[]; |
62683ab5 GR |
356 | }; |
357 | ||
5e7f59fa AL |
358 | VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_vsi_queue_config_info); |
359 | #define virtchnl_vsi_queue_config_info_LEGACY_SIZEOF 72 | |
c9a98305 | 360 | |
a3f5aa90 AB |
361 | /* VIRTCHNL_OP_REQUEST_QUEUES |
362 | * VF sends this message to request the PF to allocate additional queues to | |
363 | * this VF. Each VF gets a guaranteed number of queues on init but asking for | |
364 | * additional queues must be negotiated. This is a best effort request as it | |
365 | * is possible the PF does not have enough queues left to support the request. | |
366 | * If the PF cannot support the number requested it will respond with the | |
17a9422d AB |
367 | * maximum number it is able to support. If the request is successful, PF will |
368 | * then reset the VF to institute required changes. | |
a3f5aa90 AB |
369 | */ |
370 | ||
371 | /* VF resource request */ | |
372 | struct virtchnl_vf_res_request { | |
373 | u16 num_queue_pairs; | |
374 | }; | |
375 | ||
310a2ad9 | 376 | /* VIRTCHNL_OP_CONFIG_IRQ_MAP |
62683ab5 GR |
377 | * VF uses this message to map vectors to queues. |
378 | * The rxq_map and txq_map fields are bitmaps used to indicate which queues | |
379 | * are to be associated with the specified vector. | |
43fc70a2 JB |
380 | * The "other" causes are always mapped to vector 0. The VF may not request |
381 | * that vector 0 be used for traffic. | |
62683ab5 | 382 | * PF configures interrupt mapping and returns status. |
43fc70a2 JB |
383 | * NOTE: due to hardware requirements, all active queues (both TX and RX) |
384 | * should be mapped to interrupts, even if the driver intends to operate | |
385 | * only in polling mode. In this case the interrupt may be disabled, but | |
386 | * the ITR timer will still run to trigger writebacks. | |
62683ab5 | 387 | */ |
310a2ad9 | 388 | struct virtchnl_vector_map { |
62683ab5 GR |
389 | u16 vsi_id; |
390 | u16 vector_id; | |
391 | u16 rxq_map; | |
392 | u16 txq_map; | |
393 | u16 rxitr_idx; | |
394 | u16 txitr_idx; | |
395 | }; | |
396 | ||
73556269 SS |
397 | VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_vector_map); |
398 | ||
310a2ad9 | 399 | struct virtchnl_irq_map_info { |
62683ab5 | 400 | u16 num_vectors; |
5e7f59fa | 401 | struct virtchnl_vector_map vecmap[]; |
62683ab5 GR |
402 | }; |
403 | ||
5e7f59fa AL |
404 | VIRTCHNL_CHECK_STRUCT_LEN(2, virtchnl_irq_map_info); |
405 | #define virtchnl_irq_map_info_LEGACY_SIZEOF 14 | |
73556269 | 406 | |
310a2ad9 JB |
407 | /* VIRTCHNL_OP_ENABLE_QUEUES |
408 | * VIRTCHNL_OP_DISABLE_QUEUES | |
62683ab5 GR |
409 | * VF sends these message to enable or disable TX/RX queue pairs. |
410 | * The queues fields are bitmaps indicating which queues to act upon. | |
411 | * (Currently, we only support 16 queues per VF, but we make the field | |
412 | * u32 to allow for expansion.) | |
413 | * PF performs requested action and returns status. | |
43fc70a2 JB |
414 | * NOTE: The VF is not required to enable/disable all queues in a single |
415 | * request. It may send multiple messages. | |
416 | * PF drivers must correctly handle all VF requests. | |
62683ab5 | 417 | */ |
310a2ad9 | 418 | struct virtchnl_queue_select { |
62683ab5 GR |
419 | u16 vsi_id; |
420 | u16 pad; | |
421 | u32 rx_queues; | |
422 | u32 tx_queues; | |
423 | }; | |
424 | ||
73556269 SS |
425 | VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_select); |
426 | ||
310a2ad9 | 427 | /* VIRTCHNL_OP_ADD_ETH_ADDR |
62683ab5 GR |
428 | * VF sends this message in order to add one or more unicast or multicast |
429 | * address filters for the specified VSI. | |
430 | * PF adds the filters and returns status. | |
431 | */ | |
432 | ||
310a2ad9 | 433 | /* VIRTCHNL_OP_DEL_ETH_ADDR |
62683ab5 GR |
434 | * VF sends this message in order to remove one or more unicast or multicast |
435 | * filters for the specified VSI. | |
436 | * PF removes the filters and returns status. | |
437 | */ | |
438 | ||
eb550f53 BC |
439 | /* VIRTCHNL_ETHER_ADDR_LEGACY |
440 | * Prior to adding the @type member to virtchnl_ether_addr, there were 2 pad | |
441 | * bytes. Moving forward all VF drivers should not set type to | |
442 | * VIRTCHNL_ETHER_ADDR_LEGACY. This is only here to not break previous/legacy | |
443 | * behavior. The control plane function (i.e. PF) can use a best effort method | |
444 | * of tracking the primary/device unicast in this case, but there is no | |
445 | * guarantee and functionality depends on the implementation of the PF. | |
446 | */ | |
447 | ||
448 | /* VIRTCHNL_ETHER_ADDR_PRIMARY | |
449 | * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_PRIMARY for the | |
450 | * primary/device unicast MAC address filter for VIRTCHNL_OP_ADD_ETH_ADDR and | |
451 | * VIRTCHNL_OP_DEL_ETH_ADDR. This allows for the underlying control plane | |
452 | * function (i.e. PF) to accurately track and use this MAC address for | |
453 | * displaying on the host and for VM/function reset. | |
454 | */ | |
455 | ||
456 | /* VIRTCHNL_ETHER_ADDR_EXTRA | |
457 | * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_EXTRA for any extra | |
458 | * unicast and/or multicast filters that are being added/deleted via | |
459 | * VIRTCHNL_OP_DEL_ETH_ADDR/VIRTCHNL_OP_ADD_ETH_ADDR respectively. | |
460 | */ | |
310a2ad9 | 461 | struct virtchnl_ether_addr { |
62683ab5 | 462 | u8 addr[ETH_ALEN]; |
eb550f53 BC |
463 | u8 type; |
464 | #define VIRTCHNL_ETHER_ADDR_LEGACY 0 | |
465 | #define VIRTCHNL_ETHER_ADDR_PRIMARY 1 | |
466 | #define VIRTCHNL_ETHER_ADDR_EXTRA 2 | |
467 | #define VIRTCHNL_ETHER_ADDR_TYPE_MASK 3 /* first two bits of type are valid */ | |
468 | u8 pad; | |
62683ab5 GR |
469 | }; |
470 | ||
73556269 SS |
471 | VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_ether_addr); |
472 | ||
310a2ad9 | 473 | struct virtchnl_ether_addr_list { |
62683ab5 GR |
474 | u16 vsi_id; |
475 | u16 num_elements; | |
5e7f59fa | 476 | struct virtchnl_ether_addr list[]; |
62683ab5 GR |
477 | }; |
478 | ||
5e7f59fa AL |
479 | VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_ether_addr_list); |
480 | #define virtchnl_ether_addr_list_LEGACY_SIZEOF 12 | |
73556269 | 481 | |
310a2ad9 | 482 | /* VIRTCHNL_OP_ADD_VLAN |
62683ab5 GR |
483 | * VF sends this message to add one or more VLAN tag filters for receives. |
484 | * PF adds the filters and returns status. | |
485 | * If a port VLAN is configured by the PF, this operation will return an | |
486 | * error to the VF. | |
487 | */ | |
488 | ||
310a2ad9 | 489 | /* VIRTCHNL_OP_DEL_VLAN |
62683ab5 GR |
490 | * VF sends this message to remove one or more VLAN tag filters for receives. |
491 | * PF removes the filters and returns status. | |
492 | * If a port VLAN is configured by the PF, this operation will return an | |
493 | * error to the VF. | |
494 | */ | |
495 | ||
310a2ad9 | 496 | struct virtchnl_vlan_filter_list { |
62683ab5 GR |
497 | u16 vsi_id; |
498 | u16 num_elements; | |
5e7f59fa | 499 | u16 vlan_id[]; |
62683ab5 GR |
500 | }; |
501 | ||
5e7f59fa AL |
502 | VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_vlan_filter_list); |
503 | #define virtchnl_vlan_filter_list_LEGACY_SIZEOF 6 | |
73556269 | 504 | |
bd0b536d BC |
505 | /* This enum is used for all of the VIRTCHNL_VF_OFFLOAD_VLAN_V2_CAPS related |
506 | * structures and opcodes. | |
507 | * | |
508 | * VIRTCHNL_VLAN_UNSUPPORTED - This field is not supported and if a VF driver | |
509 | * populates it the PF should return VIRTCHNL_STATUS_ERR_NOT_SUPPORTED. | |
510 | * | |
511 | * VIRTCHNL_VLAN_ETHERTYPE_8100 - This field supports 0x8100 ethertype. | |
512 | * VIRTCHNL_VLAN_ETHERTYPE_88A8 - This field supports 0x88A8 ethertype. | |
513 | * VIRTCHNL_VLAN_ETHERTYPE_9100 - This field supports 0x9100 ethertype. | |
514 | * | |
515 | * VIRTCHNL_VLAN_ETHERTYPE_AND - Used when multiple ethertypes can be supported | |
516 | * by the PF concurrently. For example, if the PF can support | |
517 | * VIRTCHNL_VLAN_ETHERTYPE_8100 AND VIRTCHNL_VLAN_ETHERTYPE_88A8 filters it | |
518 | * would OR the following bits: | |
519 | * | |
520 | * VIRTHCNL_VLAN_ETHERTYPE_8100 | | |
521 | * VIRTCHNL_VLAN_ETHERTYPE_88A8 | | |
522 | * VIRTCHNL_VLAN_ETHERTYPE_AND; | |
523 | * | |
524 | * The VF would interpret this as VLAN filtering can be supported on both 0x8100 | |
525 | * and 0x88A8 VLAN ethertypes. | |
526 | * | |
527 | * VIRTCHNL_ETHERTYPE_XOR - Used when only a single ethertype can be supported | |
528 | * by the PF concurrently. For example if the PF can support | |
529 | * VIRTCHNL_VLAN_ETHERTYPE_8100 XOR VIRTCHNL_VLAN_ETHERTYPE_88A8 stripping | |
530 | * offload it would OR the following bits: | |
531 | * | |
532 | * VIRTCHNL_VLAN_ETHERTYPE_8100 | | |
533 | * VIRTCHNL_VLAN_ETHERTYPE_88A8 | | |
534 | * VIRTCHNL_VLAN_ETHERTYPE_XOR; | |
535 | * | |
536 | * The VF would interpret this as VLAN stripping can be supported on either | |
537 | * 0x8100 or 0x88a8 VLAN ethertypes. So when requesting VLAN stripping via | |
538 | * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 the specified ethertype will override | |
539 | * the previously set value. | |
540 | * | |
541 | * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 - Used to tell the VF to insert and/or | |
542 | * strip the VLAN tag using the L2TAG1 field of the Tx/Rx descriptors. | |
543 | * | |
544 | * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to insert hardware | |
545 | * offloaded VLAN tags using the L2TAG2 field of the Tx descriptor. | |
546 | * | |
547 | * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to strip hardware | |
548 | * offloaded VLAN tags using the L2TAG2_2 field of the Rx descriptor. | |
549 | * | |
550 | * VIRTCHNL_VLAN_PRIO - This field supports VLAN priority bits. This is used for | |
551 | * VLAN filtering if the underlying PF supports it. | |
552 | * | |
553 | * VIRTCHNL_VLAN_TOGGLE_ALLOWED - This field is used to say whether a | |
554 | * certain VLAN capability can be toggled. For example if the underlying PF/CP | |
555 | * allows the VF to toggle VLAN filtering, stripping, and/or insertion it should | |
556 | * set this bit along with the supported ethertypes. | |
557 | */ | |
558 | enum virtchnl_vlan_support { | |
559 | VIRTCHNL_VLAN_UNSUPPORTED = 0, | |
560 | VIRTCHNL_VLAN_ETHERTYPE_8100 = BIT(0), | |
561 | VIRTCHNL_VLAN_ETHERTYPE_88A8 = BIT(1), | |
562 | VIRTCHNL_VLAN_ETHERTYPE_9100 = BIT(2), | |
563 | VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 = BIT(8), | |
564 | VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 = BIT(9), | |
565 | VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2_2 = BIT(10), | |
566 | VIRTCHNL_VLAN_PRIO = BIT(24), | |
567 | VIRTCHNL_VLAN_FILTER_MASK = BIT(28), | |
568 | VIRTCHNL_VLAN_ETHERTYPE_AND = BIT(29), | |
569 | VIRTCHNL_VLAN_ETHERTYPE_XOR = BIT(30), | |
570 | VIRTCHNL_VLAN_TOGGLE = BIT(31), | |
571 | }; | |
572 | ||
573 | /* This structure is used as part of the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS | |
574 | * for filtering, insertion, and stripping capabilities. | |
575 | * | |
576 | * If only outer capabilities are supported (for filtering, insertion, and/or | |
577 | * stripping) then this refers to the outer most or single VLAN from the VF's | |
578 | * perspective. | |
579 | * | |
580 | * If only inner capabilities are supported (for filtering, insertion, and/or | |
581 | * stripping) then this refers to the outer most or single VLAN from the VF's | |
582 | * perspective. Functionally this is the same as if only outer capabilities are | |
583 | * supported. The VF driver is just forced to use the inner fields when | |
584 | * adding/deleting filters and enabling/disabling offloads (if supported). | |
585 | * | |
586 | * If both outer and inner capabilities are supported (for filtering, insertion, | |
587 | * and/or stripping) then outer refers to the outer most or single VLAN and | |
588 | * inner refers to the second VLAN, if it exists, in the packet. | |
589 | * | |
590 | * There is no support for tunneled VLAN offloads, so outer or inner are never | |
591 | * referring to a tunneled packet from the VF's perspective. | |
592 | */ | |
593 | struct virtchnl_vlan_supported_caps { | |
594 | u32 outer; | |
595 | u32 inner; | |
596 | }; | |
597 | ||
598 | /* The PF populates these fields based on the supported VLAN filtering. If a | |
599 | * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will | |
600 | * reject any VIRTCHNL_OP_ADD_VLAN_V2 or VIRTCHNL_OP_DEL_VLAN_V2 messages using | |
601 | * the unsupported fields. | |
602 | * | |
603 | * Also, a VF is only allowed to toggle its VLAN filtering setting if the | |
604 | * VIRTCHNL_VLAN_TOGGLE bit is set. | |
605 | * | |
606 | * The ethertype(s) specified in the ethertype_init field are the ethertypes | |
607 | * enabled for VLAN filtering. VLAN filtering in this case refers to the outer | |
608 | * most VLAN from the VF's perspective. If both inner and outer filtering are | |
609 | * allowed then ethertype_init only refers to the outer most VLAN as only | |
610 | * VLAN ethertype supported for inner VLAN filtering is | |
611 | * VIRTCHNL_VLAN_ETHERTYPE_8100. By default, inner VLAN filtering is disabled | |
612 | * when both inner and outer filtering are allowed. | |
613 | * | |
614 | * The max_filters field tells the VF how many VLAN filters it's allowed to have | |
615 | * at any one time. If it exceeds this amount and tries to add another filter, | |
616 | * then the request will be rejected by the PF. To prevent failures, the VF | |
617 | * should keep track of how many VLAN filters it has added and not attempt to | |
618 | * add more than max_filters. | |
619 | */ | |
620 | struct virtchnl_vlan_filtering_caps { | |
621 | struct virtchnl_vlan_supported_caps filtering_support; | |
622 | u32 ethertype_init; | |
623 | u16 max_filters; | |
624 | u8 pad[2]; | |
625 | }; | |
626 | ||
627 | VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_filtering_caps); | |
628 | ||
629 | /* This enum is used for the virtchnl_vlan_offload_caps structure to specify | |
630 | * if the PF supports a different ethertype for stripping and insertion. | |
631 | * | |
632 | * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION - The ethertype(s) specified | |
633 | * for stripping affect the ethertype(s) specified for insertion and visa versa | |
634 | * as well. If the VF tries to configure VLAN stripping via | |
635 | * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 with VIRTCHNL_VLAN_ETHERTYPE_8100 then | |
636 | * that will be the ethertype for both stripping and insertion. | |
637 | * | |
638 | * VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED - The ethertype(s) specified for | |
639 | * stripping do not affect the ethertype(s) specified for insertion and visa | |
640 | * versa. | |
641 | */ | |
642 | enum virtchnl_vlan_ethertype_match { | |
643 | VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION = 0, | |
644 | VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED = 1, | |
645 | }; | |
646 | ||
647 | /* The PF populates these fields based on the supported VLAN offloads. If a | |
648 | * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will | |
649 | * reject any VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 or | |
650 | * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 messages using the unsupported fields. | |
651 | * | |
652 | * Also, a VF is only allowed to toggle its VLAN offload setting if the | |
653 | * VIRTCHNL_VLAN_TOGGLE_ALLOWED bit is set. | |
654 | * | |
655 | * The VF driver needs to be aware of how the tags are stripped by hardware and | |
656 | * inserted by the VF driver based on the level of offload support. The PF will | |
657 | * populate these fields based on where the VLAN tags are expected to be | |
658 | * offloaded via the VIRTHCNL_VLAN_TAG_LOCATION_* bits. The VF will need to | |
659 | * interpret these fields. See the definition of the | |
660 | * VIRTCHNL_VLAN_TAG_LOCATION_* bits above the virtchnl_vlan_support | |
661 | * enumeration. | |
662 | */ | |
663 | struct virtchnl_vlan_offload_caps { | |
664 | struct virtchnl_vlan_supported_caps stripping_support; | |
665 | struct virtchnl_vlan_supported_caps insertion_support; | |
666 | u32 ethertype_init; | |
667 | u8 ethertype_match; | |
668 | u8 pad[3]; | |
669 | }; | |
670 | ||
671 | VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_vlan_offload_caps); | |
672 | ||
673 | /* VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS | |
674 | * VF sends this message to determine its VLAN capabilities. | |
675 | * | |
676 | * PF will mark which capabilities it supports based on hardware support and | |
677 | * current configuration. For example, if a port VLAN is configured the PF will | |
678 | * not allow outer VLAN filtering, stripping, or insertion to be configured so | |
679 | * it will block these features from the VF. | |
680 | * | |
681 | * The VF will need to cross reference its capabilities with the PFs | |
682 | * capabilities in the response message from the PF to determine the VLAN | |
683 | * support. | |
684 | */ | |
685 | struct virtchnl_vlan_caps { | |
686 | struct virtchnl_vlan_filtering_caps filtering; | |
687 | struct virtchnl_vlan_offload_caps offloads; | |
688 | }; | |
689 | ||
690 | VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_caps); | |
691 | ||
692 | struct virtchnl_vlan { | |
693 | u16 tci; /* tci[15:13] = PCP and tci[11:0] = VID */ | |
694 | u16 tci_mask; /* only valid if VIRTCHNL_VLAN_FILTER_MASK set in | |
695 | * filtering caps | |
696 | */ | |
697 | u16 tpid; /* 0x8100, 0x88a8, etc. and only type(s) set in | |
698 | * filtering caps. Note that tpid here does not refer to | |
699 | * VIRTCHNL_VLAN_ETHERTYPE_*, but it refers to the | |
700 | * actual 2-byte VLAN TPID | |
701 | */ | |
702 | u8 pad[2]; | |
703 | }; | |
704 | ||
705 | VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_vlan); | |
706 | ||
707 | struct virtchnl_vlan_filter { | |
708 | struct virtchnl_vlan inner; | |
709 | struct virtchnl_vlan outer; | |
710 | u8 pad[16]; | |
711 | }; | |
712 | ||
713 | VIRTCHNL_CHECK_STRUCT_LEN(32, virtchnl_vlan_filter); | |
714 | ||
715 | /* VIRTCHNL_OP_ADD_VLAN_V2 | |
716 | * VIRTCHNL_OP_DEL_VLAN_V2 | |
717 | * | |
718 | * VF sends these messages to add/del one or more VLAN tag filters for Rx | |
719 | * traffic. | |
720 | * | |
721 | * The PF attempts to add the filters and returns status. | |
722 | * | |
723 | * The VF should only ever attempt to add/del virtchnl_vlan_filter(s) using the | |
724 | * supported fields negotiated via VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS. | |
725 | */ | |
726 | struct virtchnl_vlan_filter_list_v2 { | |
727 | u16 vport_id; | |
728 | u16 num_elements; | |
729 | u8 pad[4]; | |
b0654e64 | 730 | struct virtchnl_vlan_filter filters[]; |
bd0b536d BC |
731 | }; |
732 | ||
b0654e64 AL |
733 | VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_vlan_filter_list_v2); |
734 | #define virtchnl_vlan_filter_list_v2_LEGACY_SIZEOF 40 | |
bd0b536d BC |
735 | |
736 | /* VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 | |
737 | * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 | |
738 | * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 | |
739 | * VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 | |
740 | * | |
741 | * VF sends this message to enable or disable VLAN stripping or insertion. It | |
742 | * also needs to specify an ethertype. The VF knows which VLAN ethertypes are | |
743 | * allowed and whether or not it's allowed to enable/disable the specific | |
744 | * offload via the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to | |
745 | * parse the virtchnl_vlan_caps.offloads fields to determine which offload | |
746 | * messages are allowed. | |
747 | * | |
748 | * For example, if the PF populates the virtchnl_vlan_caps.offloads in the | |
749 | * following manner the VF will be allowed to enable and/or disable 0x8100 inner | |
750 | * VLAN insertion and/or stripping via the opcodes listed above. Inner in this | |
751 | * case means the outer most or single VLAN from the VF's perspective. This is | |
752 | * because no outer offloads are supported. See the comments above the | |
753 | * virtchnl_vlan_supported_caps structure for more details. | |
754 | * | |
755 | * virtchnl_vlan_caps.offloads.stripping_support.inner = | |
756 | * VIRTCHNL_VLAN_TOGGLE | | |
757 | * VIRTCHNL_VLAN_ETHERTYPE_8100; | |
758 | * | |
759 | * virtchnl_vlan_caps.offloads.insertion_support.inner = | |
760 | * VIRTCHNL_VLAN_TOGGLE | | |
761 | * VIRTCHNL_VLAN_ETHERTYPE_8100; | |
762 | * | |
763 | * In order to enable inner (again note that in this case inner is the outer | |
764 | * most or single VLAN from the VF's perspective) VLAN stripping for 0x8100 | |
765 | * VLANs, the VF would populate the virtchnl_vlan_setting structure in the | |
766 | * following manner and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message. | |
767 | * | |
768 | * virtchnl_vlan_setting.inner_ethertype_setting = | |
769 | * VIRTCHNL_VLAN_ETHERTYPE_8100; | |
770 | * | |
771 | * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on | |
772 | * initialization. | |
773 | * | |
774 | * The reason that VLAN TPID(s) are not being used for the | |
775 | * outer_ethertype_setting and inner_ethertype_setting fields is because it's | |
776 | * possible a device could support VLAN insertion and/or stripping offload on | |
777 | * multiple ethertypes concurrently, so this method allows a VF to request | |
778 | * multiple ethertypes in one message using the virtchnl_vlan_support | |
779 | * enumeration. | |
780 | * | |
781 | * For example, if the PF populates the virtchnl_vlan_caps.offloads in the | |
782 | * following manner the VF will be allowed to enable 0x8100 and 0x88a8 outer | |
783 | * VLAN insertion and stripping simultaneously. The | |
784 | * virtchnl_vlan_caps.offloads.ethertype_match field will also have to be | |
785 | * populated based on what the PF can support. | |
786 | * | |
787 | * virtchnl_vlan_caps.offloads.stripping_support.outer = | |
788 | * VIRTCHNL_VLAN_TOGGLE | | |
789 | * VIRTCHNL_VLAN_ETHERTYPE_8100 | | |
790 | * VIRTCHNL_VLAN_ETHERTYPE_88A8 | | |
791 | * VIRTCHNL_VLAN_ETHERTYPE_AND; | |
792 | * | |
793 | * virtchnl_vlan_caps.offloads.insertion_support.outer = | |
794 | * VIRTCHNL_VLAN_TOGGLE | | |
795 | * VIRTCHNL_VLAN_ETHERTYPE_8100 | | |
796 | * VIRTCHNL_VLAN_ETHERTYPE_88A8 | | |
797 | * VIRTCHNL_VLAN_ETHERTYPE_AND; | |
798 | * | |
799 | * In order to enable outer VLAN stripping for 0x8100 and 0x88a8 VLANs, the VF | |
800 | * would populate the virthcnl_vlan_offload_structure in the following manner | |
801 | * and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message. | |
802 | * | |
803 | * virtchnl_vlan_setting.outer_ethertype_setting = | |
804 | * VIRTHCNL_VLAN_ETHERTYPE_8100 | | |
805 | * VIRTHCNL_VLAN_ETHERTYPE_88A8; | |
806 | * | |
807 | * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on | |
808 | * initialization. | |
809 | * | |
810 | * There is also the case where a PF and the underlying hardware can support | |
811 | * VLAN offloads on multiple ethertypes, but not concurrently. For example, if | |
812 | * the PF populates the virtchnl_vlan_caps.offloads in the following manner the | |
813 | * VF will be allowed to enable and/or disable 0x8100 XOR 0x88a8 outer VLAN | |
814 | * offloads. The ethertypes must match for stripping and insertion. | |
815 | * | |
816 | * virtchnl_vlan_caps.offloads.stripping_support.outer = | |
817 | * VIRTCHNL_VLAN_TOGGLE | | |
818 | * VIRTCHNL_VLAN_ETHERTYPE_8100 | | |
819 | * VIRTCHNL_VLAN_ETHERTYPE_88A8 | | |
820 | * VIRTCHNL_VLAN_ETHERTYPE_XOR; | |
821 | * | |
822 | * virtchnl_vlan_caps.offloads.insertion_support.outer = | |
823 | * VIRTCHNL_VLAN_TOGGLE | | |
824 | * VIRTCHNL_VLAN_ETHERTYPE_8100 | | |
825 | * VIRTCHNL_VLAN_ETHERTYPE_88A8 | | |
826 | * VIRTCHNL_VLAN_ETHERTYPE_XOR; | |
827 | * | |
828 | * virtchnl_vlan_caps.offloads.ethertype_match = | |
829 | * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION; | |
830 | * | |
831 | * In order to enable outer VLAN stripping for 0x88a8 VLANs, the VF would | |
832 | * populate the virtchnl_vlan_setting structure in the following manner and send | |
833 | * the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2. Also, this will change the | |
834 | * ethertype for VLAN insertion if it's enabled. So, for completeness, a | |
835 | * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 with the same ethertype should be sent. | |
836 | * | |
837 | * virtchnl_vlan_setting.outer_ethertype_setting = VIRTHCNL_VLAN_ETHERTYPE_88A8; | |
838 | * | |
839 | * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on | |
840 | * initialization. | |
841 | */ | |
842 | struct virtchnl_vlan_setting { | |
843 | u32 outer_ethertype_setting; | |
844 | u32 inner_ethertype_setting; | |
845 | u16 vport_id; | |
846 | u8 pad[6]; | |
847 | }; | |
848 | ||
849 | VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_setting); | |
850 | ||
310a2ad9 | 851 | /* VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE |
62683ab5 GR |
852 | * VF sends VSI id and flags. |
853 | * PF returns status code in retval. | |
854 | * Note: we assume that broadcast accept mode is always enabled. | |
855 | */ | |
310a2ad9 | 856 | struct virtchnl_promisc_info { |
62683ab5 GR |
857 | u16 vsi_id; |
858 | u16 flags; | |
859 | }; | |
860 | ||
73556269 SS |
861 | VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_promisc_info); |
862 | ||
ff3f4cc2 JB |
863 | #define FLAG_VF_UNICAST_PROMISC 0x00000001 |
864 | #define FLAG_VF_MULTICAST_PROMISC 0x00000002 | |
62683ab5 | 865 | |
310a2ad9 | 866 | /* VIRTCHNL_OP_GET_STATS |
62683ab5 | 867 | * VF sends this message to request stats for the selected VSI. VF uses |
310a2ad9 | 868 | * the virtchnl_queue_select struct to specify the VSI. The queue_id |
62683ab5 GR |
869 | * field is ignored by the PF. |
870 | * | |
ff3f4cc2 | 871 | * PF replies with struct eth_stats in an external buffer. |
62683ab5 GR |
872 | */ |
873 | ||
310a2ad9 JB |
874 | /* VIRTCHNL_OP_CONFIG_RSS_KEY |
875 | * VIRTCHNL_OP_CONFIG_RSS_LUT | |
585954f8 | 876 | * VF sends these messages to configure RSS. Only supported if both PF |
310a2ad9 | 877 | * and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during |
585954f8 MW |
878 | * configuration negotiation. If this is the case, then the RSS fields in |
879 | * the VF resource struct are valid. | |
880 | * Both the key and LUT are initialized to 0 by the PF, meaning that | |
881 | * RSS is effectively disabled until set up by the VF. | |
882 | */ | |
310a2ad9 | 883 | struct virtchnl_rss_key { |
585954f8 MW |
884 | u16 vsi_id; |
885 | u16 key_len; | |
dd2e84bb | 886 | u8 key[]; /* RSS hash key, packed bytes */ |
585954f8 MW |
887 | }; |
888 | ||
dd2e84bb AL |
889 | VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_rss_key); |
890 | #define virtchnl_rss_key_LEGACY_SIZEOF 6 | |
73556269 | 891 | |
310a2ad9 | 892 | struct virtchnl_rss_lut { |
585954f8 MW |
893 | u16 vsi_id; |
894 | u16 lut_entries; | |
dd2e84bb | 895 | u8 lut[]; /* RSS lookup table */ |
585954f8 MW |
896 | }; |
897 | ||
dd2e84bb AL |
898 | VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_rss_lut); |
899 | #define virtchnl_rss_lut_LEGACY_SIZEOF 6 | |
73556269 | 900 | |
310a2ad9 JB |
901 | /* VIRTCHNL_OP_GET_RSS_HENA_CAPS |
902 | * VIRTCHNL_OP_SET_RSS_HENA | |
585954f8 MW |
903 | * VF sends these messages to get and set the hash filter enable bits for RSS. |
904 | * By default, the PF sets these to all possible traffic types that the | |
905 | * hardware supports. The VF can query this value if it wants to change the | |
906 | * traffic types that are hashed by the hardware. | |
585954f8 | 907 | */ |
310a2ad9 | 908 | struct virtchnl_rss_hena { |
585954f8 MW |
909 | u64 hena; |
910 | }; | |
911 | ||
73556269 SS |
912 | VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_rss_hena); |
913 | ||
dc6e44c9 QZ |
914 | /* Type of RSS algorithm */ |
915 | enum virtchnl_rss_algorithm { | |
916 | VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC = 0, | |
917 | VIRTCHNL_RSS_ALG_R_ASYMMETRIC = 1, | |
918 | VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC = 2, | |
919 | VIRTCHNL_RSS_ALG_XOR_SYMMETRIC = 3, | |
920 | }; | |
921 | ||
eb09f1fe HR |
922 | /* VIRTCHNL_OP_ENABLE_CHANNELS |
923 | * VIRTCHNL_OP_DISABLE_CHANNELS | |
924 | * VF sends these messages to enable or disable channels based on | |
925 | * the user specified queue count and queue offset for each traffic class. | |
926 | * This struct encompasses all the information that the PF needs from | |
927 | * VF to create a channel. | |
928 | */ | |
929 | struct virtchnl_channel_info { | |
930 | u16 count; /* number of queues in a channel */ | |
931 | u16 offset; /* queues in a channel start from 'offset' */ | |
932 | u32 pad; | |
933 | u64 max_tx_rate; | |
934 | }; | |
935 | ||
936 | VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_channel_info); | |
937 | ||
938 | struct virtchnl_tc_info { | |
939 | u32 num_tc; | |
940 | u32 pad; | |
b0654e64 | 941 | struct virtchnl_channel_info list[]; |
eb09f1fe HR |
942 | }; |
943 | ||
b0654e64 AL |
944 | VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_tc_info); |
945 | #define virtchnl_tc_info_LEGACY_SIZEOF 24 | |
eb09f1fe | 946 | |
3872c8d4 HR |
947 | /* VIRTCHNL_ADD_CLOUD_FILTER |
948 | * VIRTCHNL_DEL_CLOUD_FILTER | |
949 | * VF sends these messages to add or delete a cloud filter based on the | |
950 | * user specified match and action filters. These structures encompass | |
951 | * all the information that the PF needs from the VF to add/delete a | |
952 | * cloud filter. | |
953 | */ | |
954 | ||
955 | struct virtchnl_l4_spec { | |
956 | u8 src_mac[ETH_ALEN]; | |
957 | u8 dst_mac[ETH_ALEN]; | |
958 | __be16 vlan_id; | |
959 | __be16 pad; /* reserved for future use */ | |
960 | __be32 src_ip[4]; | |
961 | __be32 dst_ip[4]; | |
962 | __be16 src_port; | |
963 | __be16 dst_port; | |
964 | }; | |
965 | ||
966 | VIRTCHNL_CHECK_STRUCT_LEN(52, virtchnl_l4_spec); | |
967 | ||
968 | union virtchnl_flow_spec { | |
969 | struct virtchnl_l4_spec tcp_spec; | |
970 | u8 buffer[128]; /* reserved for future use */ | |
971 | }; | |
972 | ||
973 | VIRTCHNL_CHECK_UNION_LEN(128, virtchnl_flow_spec); | |
974 | ||
975 | enum virtchnl_action { | |
976 | /* action types */ | |
977 | VIRTCHNL_ACTION_DROP = 0, | |
978 | VIRTCHNL_ACTION_TC_REDIRECT, | |
1f7ea1cd QZ |
979 | VIRTCHNL_ACTION_PASSTHRU, |
980 | VIRTCHNL_ACTION_QUEUE, | |
981 | VIRTCHNL_ACTION_Q_REGION, | |
982 | VIRTCHNL_ACTION_MARK, | |
983 | VIRTCHNL_ACTION_COUNT, | |
3872c8d4 HR |
984 | }; |
985 | ||
986 | enum virtchnl_flow_type { | |
987 | /* flow types */ | |
988 | VIRTCHNL_TCP_V4_FLOW = 0, | |
989 | VIRTCHNL_TCP_V6_FLOW, | |
990 | }; | |
991 | ||
992 | struct virtchnl_filter { | |
993 | union virtchnl_flow_spec data; | |
994 | union virtchnl_flow_spec mask; | |
4e4df559 JB |
995 | |
996 | /* see enum virtchnl_flow_type */ | |
997 | s32 flow_type; | |
998 | ||
999 | /* see enum virtchnl_action */ | |
1000 | s32 action; | |
3872c8d4 | 1001 | u32 action_meta; |
a4e0109a | 1002 | u8 field_flags; |
65ece6de | 1003 | u8 pad[3]; |
3872c8d4 HR |
1004 | }; |
1005 | ||
1006 | VIRTCHNL_CHECK_STRUCT_LEN(272, virtchnl_filter); | |
1007 | ||
e753df8f MJ |
1008 | struct virtchnl_supported_rxdids { |
1009 | u64 supported_rxdids; | |
1010 | }; | |
1011 | ||
310a2ad9 | 1012 | /* VIRTCHNL_OP_EVENT |
62683ab5 GR |
1013 | * PF sends this message to inform the VF driver of events that may affect it. |
1014 | * No direct response is expected from the VF, though it may generate other | |
1015 | * messages in response to this one. | |
1016 | */ | |
310a2ad9 JB |
1017 | enum virtchnl_event_codes { |
1018 | VIRTCHNL_EVENT_UNKNOWN = 0, | |
1019 | VIRTCHNL_EVENT_LINK_CHANGE, | |
1020 | VIRTCHNL_EVENT_RESET_IMPENDING, | |
1021 | VIRTCHNL_EVENT_PF_DRIVER_CLOSE, | |
62683ab5 | 1022 | }; |
ff3f4cc2 JB |
1023 | |
1024 | #define PF_EVENT_SEVERITY_INFO 0 | |
1025 | #define PF_EVENT_SEVERITY_CERTAIN_DOOM 255 | |
62683ab5 | 1026 | |
310a2ad9 | 1027 | struct virtchnl_pf_event { |
4e4df559 JB |
1028 | /* see enum virtchnl_event_codes */ |
1029 | s32 event; | |
62683ab5 | 1030 | union { |
16fc087b YRPB |
1031 | /* If the PF driver does not support the new speed reporting |
1032 | * capabilities then use link_event else use link_event_adv to | |
1033 | * get the speed and link information. The ability to understand | |
1034 | * new speeds is indicated by setting the capability flag | |
1035 | * VIRTCHNL_VF_CAP_ADV_LINK_SPEED in vf_cap_flags parameter | |
1036 | * in virtchnl_vf_resource struct and can be used to determine | |
1037 | * which link event struct to use below. | |
1038 | */ | |
62683ab5 | 1039 | struct { |
ff3f4cc2 | 1040 | enum virtchnl_link_speed link_speed; |
62683ab5 | 1041 | bool link_status; |
4e4df559 | 1042 | u8 pad[3]; |
62683ab5 | 1043 | } link_event; |
16fc087b YRPB |
1044 | struct { |
1045 | /* link_speed provided in Mbps */ | |
1046 | u32 link_speed; | |
1047 | u8 link_status; | |
65ece6de | 1048 | u8 pad[3]; |
16fc087b | 1049 | } link_event_adv; |
62683ab5 GR |
1050 | } event_data; |
1051 | ||
4e4df559 | 1052 | s32 severity; |
62683ab5 GR |
1053 | }; |
1054 | ||
73556269 SS |
1055 | VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_pf_event); |
1056 | ||
2723f3b5 JB |
1057 | /* used to specify if a ceq_idx or aeq_idx is invalid */ |
1058 | #define VIRTCHNL_RDMA_INVALID_QUEUE_IDX 0xFFFF | |
1059 | /* VIRTCHNL_OP_CONFIG_RDMA_IRQ_MAP | |
1060 | * VF uses this message to request PF to map RDMA vectors to RDMA queues. | |
1061 | * The request for this originates from the VF RDMA driver through | |
1062 | * a client interface between VF LAN and VF RDMA driver. | |
ed0e894d | 1063 | * A vector could have an AEQ and CEQ attached to it although |
2723f3b5 JB |
1064 | * there is a single AEQ per VF RDMA instance in which case |
1065 | * most vectors will have an VIRTCHNL_RDMA_INVALID_QUEUE_IDX for aeq and valid | |
1066 | * idx for ceqs There will never be a case where there will be multiple CEQs | |
1067 | * attached to a single vector. | |
ed0e894d MW |
1068 | * PF configures interrupt mapping and returns status. |
1069 | */ | |
1070 | ||
2723f3b5 | 1071 | struct virtchnl_rdma_qv_info { |
ed0e894d | 1072 | u32 v_idx; /* msix_vector */ |
2723f3b5 JB |
1073 | u16 ceq_idx; /* set to VIRTCHNL_RDMA_INVALID_QUEUE_IDX if invalid */ |
1074 | u16 aeq_idx; /* set to VIRTCHNL_RDMA_INVALID_QUEUE_IDX if invalid */ | |
ed0e894d | 1075 | u8 itr_idx; |
65ece6de | 1076 | u8 pad[3]; |
ed0e894d MW |
1077 | }; |
1078 | ||
2723f3b5 | 1079 | VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_rdma_qv_info); |
73556269 | 1080 | |
2723f3b5 | 1081 | struct virtchnl_rdma_qvlist_info { |
ed0e894d | 1082 | u32 num_vectors; |
b0654e64 | 1083 | struct virtchnl_rdma_qv_info qv_info[]; |
ed0e894d MW |
1084 | }; |
1085 | ||
b0654e64 AL |
1086 | VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_rdma_qvlist_info); |
1087 | #define virtchnl_rdma_qvlist_info_LEGACY_SIZEOF 16 | |
73556269 | 1088 | |
62683ab5 | 1089 | /* VF reset states - these are written into the RSTAT register: |
ff3f4cc2 | 1090 | * VFGEN_RSTAT on the VF |
62683ab5 GR |
1091 | * When the PF initiates a reset, it writes 0 |
1092 | * When the reset is complete, it writes 1 | |
1093 | * When the PF detects that the VF has recovered, it writes 2 | |
1094 | * VF checks this register periodically to determine if a reset has occurred, | |
1095 | * then polls it to know when the reset is complete. | |
1096 | * If either the PF or VF reads the register while the hardware | |
1097 | * is in a reset state, it will return DEADBEEF, which, when masked | |
1098 | * will result in 3. | |
1099 | */ | |
310a2ad9 JB |
1100 | enum virtchnl_vfr_states { |
1101 | VIRTCHNL_VFR_INPROGRESS = 0, | |
1102 | VIRTCHNL_VFR_COMPLETED, | |
1103 | VIRTCHNL_VFR_VFACTIVE, | |
62683ab5 GR |
1104 | }; |
1105 | ||
1f7ea1cd QZ |
1106 | #define VIRTCHNL_MAX_NUM_PROTO_HDRS 32 |
1107 | #define PROTO_HDR_SHIFT 5 | |
1108 | #define PROTO_HDR_FIELD_START(proto_hdr_type) ((proto_hdr_type) << PROTO_HDR_SHIFT) | |
1109 | #define PROTO_HDR_FIELD_MASK ((1UL << PROTO_HDR_SHIFT) - 1) | |
1110 | ||
1111 | /* VF use these macros to configure each protocol header. | |
1112 | * Specify which protocol headers and protocol header fields base on | |
1113 | * virtchnl_proto_hdr_type and virtchnl_proto_hdr_field. | |
1114 | * @param hdr: a struct of virtchnl_proto_hdr | |
1115 | * @param hdr_type: ETH/IPV4/TCP, etc | |
1116 | * @param field: SRC/DST/TEID/SPI, etc | |
1117 | */ | |
1118 | #define VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, field) \ | |
1119 | ((hdr)->field_selector |= BIT((field) & PROTO_HDR_FIELD_MASK)) | |
1120 | #define VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, field) \ | |
1121 | ((hdr)->field_selector &= ~BIT((field) & PROTO_HDR_FIELD_MASK)) | |
1122 | #define VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val) \ | |
1123 | ((hdr)->field_selector & BIT((val) & PROTO_HDR_FIELD_MASK)) | |
1124 | #define VIRTCHNL_GET_PROTO_HDR_FIELD(hdr) ((hdr)->field_selector) | |
1125 | ||
1126 | #define VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \ | |
1127 | (VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, \ | |
1128 | VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field)) | |
1129 | #define VIRTCHNL_DEL_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \ | |
1130 | (VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, \ | |
1131 | VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field)) | |
1132 | ||
1133 | #define VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, hdr_type) \ | |
1134 | ((hdr)->type = VIRTCHNL_PROTO_HDR_ ## hdr_type) | |
1135 | #define VIRTCHNL_GET_PROTO_HDR_TYPE(hdr) \ | |
1136 | (((hdr)->type) >> PROTO_HDR_SHIFT) | |
1137 | #define VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) \ | |
4e4df559 | 1138 | ((hdr)->type == ((s32)((val) >> PROTO_HDR_SHIFT))) |
1f7ea1cd QZ |
1139 | #define VIRTCHNL_TEST_PROTO_HDR(hdr, val) \ |
1140 | (VIRTCHNL_TEST_PROTO_HDR_TYPE((hdr), (val)) && \ | |
1141 | VIRTCHNL_TEST_PROTO_HDR_FIELD((hdr), (val))) | |
1142 | ||
1143 | /* Protocol header type within a packet segment. A segment consists of one or | |
1144 | * more protocol headers that make up a logical group of protocol headers. Each | |
1145 | * logical group of protocol headers encapsulates or is encapsulated using/by | |
1146 | * tunneling or encapsulation protocols for network virtualization. | |
1147 | */ | |
1148 | enum virtchnl_proto_hdr_type { | |
1149 | VIRTCHNL_PROTO_HDR_NONE, | |
1150 | VIRTCHNL_PROTO_HDR_ETH, | |
1151 | VIRTCHNL_PROTO_HDR_S_VLAN, | |
1152 | VIRTCHNL_PROTO_HDR_C_VLAN, | |
1153 | VIRTCHNL_PROTO_HDR_IPV4, | |
1154 | VIRTCHNL_PROTO_HDR_IPV6, | |
1155 | VIRTCHNL_PROTO_HDR_TCP, | |
1156 | VIRTCHNL_PROTO_HDR_UDP, | |
1157 | VIRTCHNL_PROTO_HDR_SCTP, | |
1158 | VIRTCHNL_PROTO_HDR_GTPU_IP, | |
1159 | VIRTCHNL_PROTO_HDR_GTPU_EH, | |
1160 | VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN, | |
1161 | VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP, | |
1162 | VIRTCHNL_PROTO_HDR_PPPOE, | |
1163 | VIRTCHNL_PROTO_HDR_L2TPV3, | |
1164 | VIRTCHNL_PROTO_HDR_ESP, | |
1165 | VIRTCHNL_PROTO_HDR_AH, | |
1166 | VIRTCHNL_PROTO_HDR_PFCP, | |
1167 | }; | |
1168 | ||
1169 | /* Protocol header field within a protocol header. */ | |
1170 | enum virtchnl_proto_hdr_field { | |
1171 | /* ETHER */ | |
1172 | VIRTCHNL_PROTO_HDR_ETH_SRC = | |
1173 | PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ETH), | |
1174 | VIRTCHNL_PROTO_HDR_ETH_DST, | |
1175 | VIRTCHNL_PROTO_HDR_ETH_ETHERTYPE, | |
1176 | /* S-VLAN */ | |
1177 | VIRTCHNL_PROTO_HDR_S_VLAN_ID = | |
1178 | PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_S_VLAN), | |
1179 | /* C-VLAN */ | |
1180 | VIRTCHNL_PROTO_HDR_C_VLAN_ID = | |
1181 | PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_C_VLAN), | |
1182 | /* IPV4 */ | |
1183 | VIRTCHNL_PROTO_HDR_IPV4_SRC = | |
1184 | PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4), | |
1185 | VIRTCHNL_PROTO_HDR_IPV4_DST, | |
1186 | VIRTCHNL_PROTO_HDR_IPV4_DSCP, | |
1187 | VIRTCHNL_PROTO_HDR_IPV4_TTL, | |
1188 | VIRTCHNL_PROTO_HDR_IPV4_PROT, | |
1189 | /* IPV6 */ | |
1190 | VIRTCHNL_PROTO_HDR_IPV6_SRC = | |
1191 | PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6), | |
1192 | VIRTCHNL_PROTO_HDR_IPV6_DST, | |
1193 | VIRTCHNL_PROTO_HDR_IPV6_TC, | |
1194 | VIRTCHNL_PROTO_HDR_IPV6_HOP_LIMIT, | |
1195 | VIRTCHNL_PROTO_HDR_IPV6_PROT, | |
1196 | /* TCP */ | |
1197 | VIRTCHNL_PROTO_HDR_TCP_SRC_PORT = | |
1198 | PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_TCP), | |
1199 | VIRTCHNL_PROTO_HDR_TCP_DST_PORT, | |
1200 | /* UDP */ | |
1201 | VIRTCHNL_PROTO_HDR_UDP_SRC_PORT = | |
1202 | PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_UDP), | |
1203 | VIRTCHNL_PROTO_HDR_UDP_DST_PORT, | |
1204 | /* SCTP */ | |
1205 | VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT = | |
1206 | PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_SCTP), | |
1207 | VIRTCHNL_PROTO_HDR_SCTP_DST_PORT, | |
1208 | /* GTPU_IP */ | |
1209 | VIRTCHNL_PROTO_HDR_GTPU_IP_TEID = | |
1210 | PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_IP), | |
1211 | /* GTPU_EH */ | |
1212 | VIRTCHNL_PROTO_HDR_GTPU_EH_PDU = | |
1213 | PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH), | |
1214 | VIRTCHNL_PROTO_HDR_GTPU_EH_QFI, | |
1215 | /* PPPOE */ | |
1216 | VIRTCHNL_PROTO_HDR_PPPOE_SESS_ID = | |
1217 | PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PPPOE), | |
1218 | /* L2TPV3 */ | |
1219 | VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID = | |
1220 | PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_L2TPV3), | |
1221 | /* ESP */ | |
1222 | VIRTCHNL_PROTO_HDR_ESP_SPI = | |
1223 | PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ESP), | |
1224 | /* AH */ | |
1225 | VIRTCHNL_PROTO_HDR_AH_SPI = | |
1226 | PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_AH), | |
1227 | /* PFCP */ | |
1228 | VIRTCHNL_PROTO_HDR_PFCP_S_FIELD = | |
1229 | PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PFCP), | |
1230 | VIRTCHNL_PROTO_HDR_PFCP_SEID, | |
1231 | }; | |
1232 | ||
1233 | struct virtchnl_proto_hdr { | |
4e4df559 JB |
1234 | /* see enum virtchnl_proto_hdr_type */ |
1235 | s32 type; | |
1f7ea1cd QZ |
1236 | u32 field_selector; /* a bit mask to select field for header type */ |
1237 | u8 buffer[64]; | |
1238 | /** | |
1239 | * binary buffer in network order for specific header type. | |
1240 | * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4 | |
1241 | * header is expected to be copied into the buffer. | |
1242 | */ | |
1243 | }; | |
1244 | ||
1245 | VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr); | |
1246 | ||
1247 | struct virtchnl_proto_hdrs { | |
1248 | u8 tunnel_level; | |
519d8ab1 | 1249 | u8 pad[3]; |
1f7ea1cd QZ |
1250 | /** |
1251 | * specify where protocol header start from. | |
1252 | * 0 - from the outer layer | |
1253 | * 1 - from the first inner layer | |
1254 | * 2 - from the second inner layer | |
1255 | * .... | |
1256 | **/ | |
1257 | int count; /* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */ | |
1258 | struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS]; | |
1259 | }; | |
1260 | ||
1261 | VIRTCHNL_CHECK_STRUCT_LEN(2312, virtchnl_proto_hdrs); | |
1262 | ||
222a8ab0 QZ |
1263 | struct virtchnl_rss_cfg { |
1264 | struct virtchnl_proto_hdrs proto_hdrs; /* protocol headers */ | |
4e4df559 JB |
1265 | |
1266 | /* see enum virtchnl_rss_algorithm; rss algorithm type */ | |
1267 | s32 rss_algorithm; | |
1268 | u8 reserved[128]; /* reserve for future */ | |
222a8ab0 QZ |
1269 | }; |
1270 | ||
1271 | VIRTCHNL_CHECK_STRUCT_LEN(2444, virtchnl_rss_cfg); | |
1272 | ||
1f7ea1cd QZ |
1273 | /* action configuration for FDIR */ |
1274 | struct virtchnl_filter_action { | |
4e4df559 JB |
1275 | /* see enum virtchnl_action type */ |
1276 | s32 type; | |
1f7ea1cd QZ |
1277 | union { |
1278 | /* used for queue and qgroup action */ | |
1279 | struct { | |
1280 | u16 index; | |
1281 | u8 region; | |
1282 | } queue; | |
1283 | /* used for count action */ | |
1284 | struct { | |
1285 | /* share counter ID with other flow rules */ | |
1286 | u8 shared; | |
1287 | u32 id; /* counter ID */ | |
1288 | } count; | |
1289 | /* used for mark action */ | |
1290 | u32 mark_id; | |
1291 | u8 reserve[32]; | |
1292 | } act_conf; | |
1293 | }; | |
1294 | ||
1295 | VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action); | |
1296 | ||
1297 | #define VIRTCHNL_MAX_NUM_ACTIONS 8 | |
1298 | ||
1299 | struct virtchnl_filter_action_set { | |
1300 | /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */ | |
1301 | int count; | |
1302 | struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS]; | |
1303 | }; | |
1304 | ||
1305 | VIRTCHNL_CHECK_STRUCT_LEN(292, virtchnl_filter_action_set); | |
1306 | ||
1307 | /* pattern and action for FDIR rule */ | |
1308 | struct virtchnl_fdir_rule { | |
1309 | struct virtchnl_proto_hdrs proto_hdrs; | |
1310 | struct virtchnl_filter_action_set action_set; | |
1311 | }; | |
1312 | ||
1313 | VIRTCHNL_CHECK_STRUCT_LEN(2604, virtchnl_fdir_rule); | |
1314 | ||
1315 | /* Status returned to VF after VF requests FDIR commands | |
1316 | * VIRTCHNL_FDIR_SUCCESS | |
1317 | * VF FDIR related request is successfully done by PF | |
2723f3b5 | 1318 | * The request can be OP_ADD/DEL/QUERY_FDIR_FILTER. |
1f7ea1cd QZ |
1319 | * |
1320 | * VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE | |
1321 | * OP_ADD_FDIR_FILTER request is failed due to no Hardware resource. | |
1322 | * | |
1323 | * VIRTCHNL_FDIR_FAILURE_RULE_EXIST | |
1324 | * OP_ADD_FDIR_FILTER request is failed due to the rule is already existed. | |
1325 | * | |
1326 | * VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT | |
1327 | * OP_ADD_FDIR_FILTER request is failed due to conflict with existing rule. | |
1328 | * | |
1329 | * VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST | |
1330 | * OP_DEL_FDIR_FILTER request is failed due to this rule doesn't exist. | |
1331 | * | |
1332 | * VIRTCHNL_FDIR_FAILURE_RULE_INVALID | |
1333 | * OP_ADD_FDIR_FILTER request is failed due to parameters validation | |
1334 | * or HW doesn't support. | |
1335 | * | |
1336 | * VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT | |
1337 | * OP_ADD/DEL_FDIR_FILTER request is failed due to timing out | |
1338 | * for programming. | |
2723f3b5 JB |
1339 | * |
1340 | * VIRTCHNL_FDIR_FAILURE_QUERY_INVALID | |
1341 | * OP_QUERY_FDIR_FILTER request is failed due to parameters validation, | |
1342 | * for example, VF query counter of a rule who has no counter action. | |
1f7ea1cd QZ |
1343 | */ |
1344 | enum virtchnl_fdir_prgm_status { | |
1345 | VIRTCHNL_FDIR_SUCCESS = 0, | |
1346 | VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE, | |
1347 | VIRTCHNL_FDIR_FAILURE_RULE_EXIST, | |
1348 | VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT, | |
1349 | VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST, | |
1350 | VIRTCHNL_FDIR_FAILURE_RULE_INVALID, | |
1351 | VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT, | |
2723f3b5 | 1352 | VIRTCHNL_FDIR_FAILURE_QUERY_INVALID, |
1f7ea1cd QZ |
1353 | }; |
1354 | ||
1355 | /* VIRTCHNL_OP_ADD_FDIR_FILTER | |
1356 | * VF sends this request to PF by filling out vsi_id, | |
1357 | * validate_only and rule_cfg. PF will return flow_id | |
1358 | * if the request is successfully done and return add_status to VF. | |
1359 | */ | |
1360 | struct virtchnl_fdir_add { | |
1361 | u16 vsi_id; /* INPUT */ | |
1362 | /* | |
1363 | * 1 for validating a fdir rule, 0 for creating a fdir rule. | |
1364 | * Validate and create share one ops: VIRTCHNL_OP_ADD_FDIR_FILTER. | |
1365 | */ | |
1366 | u16 validate_only; /* INPUT */ | |
1367 | u32 flow_id; /* OUTPUT */ | |
1368 | struct virtchnl_fdir_rule rule_cfg; /* INPUT */ | |
4e4df559 JB |
1369 | |
1370 | /* see enum virtchnl_fdir_prgm_status; OUTPUT */ | |
1371 | s32 status; | |
1f7ea1cd QZ |
1372 | }; |
1373 | ||
1374 | VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_fdir_add); | |
1375 | ||
1376 | /* VIRTCHNL_OP_DEL_FDIR_FILTER | |
1377 | * VF sends this request to PF by filling out vsi_id | |
1378 | * and flow_id. PF will return del_status to VF. | |
1379 | */ | |
1380 | struct virtchnl_fdir_del { | |
1381 | u16 vsi_id; /* INPUT */ | |
1382 | u16 pad; | |
1383 | u32 flow_id; /* INPUT */ | |
4e4df559 JB |
1384 | |
1385 | /* see enum virtchnl_fdir_prgm_status; OUTPUT */ | |
1386 | s32 status; | |
1f7ea1cd QZ |
1387 | }; |
1388 | ||
1389 | VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del); | |
1390 | ||
dd2e84bb AL |
1391 | #define __vss_byone(p, member, count, old) \ |
1392 | (struct_size(p, member, count) + (old - 1 - struct_size(p, member, 0))) | |
1393 | ||
b0654e64 AL |
1394 | #define __vss_byelem(p, member, count, old) \ |
1395 | (struct_size(p, member, count - 1) + (old - struct_size(p, member, 0))) | |
1396 | ||
5e7f59fa AL |
1397 | #define __vss_full(p, member, count, old) \ |
1398 | (struct_size(p, member, count) + (old - struct_size(p, member, 0))) | |
1399 | ||
dd2e84bb AL |
1400 | #define __vss(type, func, p, member, count) \ |
1401 | struct type: func(p, member, count, type##_LEGACY_SIZEOF) | |
1402 | ||
1403 | #define virtchnl_struct_size(p, m, c) \ | |
1404 | _Generic(*p, \ | |
5e7f59fa AL |
1405 | __vss(virtchnl_vf_resource, __vss_full, p, m, c), \ |
1406 | __vss(virtchnl_vsi_queue_config_info, __vss_full, p, m, c), \ | |
1407 | __vss(virtchnl_irq_map_info, __vss_full, p, m, c), \ | |
1408 | __vss(virtchnl_ether_addr_list, __vss_full, p, m, c), \ | |
1409 | __vss(virtchnl_vlan_filter_list, __vss_full, p, m, c), \ | |
b0654e64 AL |
1410 | __vss(virtchnl_vlan_filter_list_v2, __vss_byelem, p, m, c), \ |
1411 | __vss(virtchnl_tc_info, __vss_byelem, p, m, c), \ | |
1412 | __vss(virtchnl_rdma_qvlist_info, __vss_byelem, p, m, c), \ | |
dd2e84bb AL |
1413 | __vss(virtchnl_rss_key, __vss_byone, p, m, c), \ |
1414 | __vss(virtchnl_rss_lut, __vss_byone, p, m, c)) | |
1415 | ||
735e35c5 JB |
1416 | /** |
1417 | * virtchnl_vc_validate_vf_msg | |
1418 | * @ver: Virtchnl version info | |
1419 | * @v_opcode: Opcode for the message | |
1420 | * @msg: pointer to the msg buffer | |
1421 | * @msglen: msg length | |
1422 | * | |
1423 | * validate msg format against struct for each opcode | |
1424 | */ | |
1425 | static inline int | |
1426 | virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode, | |
1427 | u8 *msg, u16 msglen) | |
1428 | { | |
1429 | bool err_msg_format = false; | |
4e4df559 | 1430 | u32 valid_len = 0; |
735e35c5 JB |
1431 | |
1432 | /* Validate message length. */ | |
1433 | switch (v_opcode) { | |
1434 | case VIRTCHNL_OP_VERSION: | |
1435 | valid_len = sizeof(struct virtchnl_version_info); | |
1436 | break; | |
1437 | case VIRTCHNL_OP_RESET_VF: | |
1438 | break; | |
1439 | case VIRTCHNL_OP_GET_VF_RESOURCES: | |
1440 | if (VF_IS_V11(ver)) | |
1441 | valid_len = sizeof(u32); | |
1442 | break; | |
1443 | case VIRTCHNL_OP_CONFIG_TX_QUEUE: | |
1444 | valid_len = sizeof(struct virtchnl_txq_info); | |
1445 | break; | |
1446 | case VIRTCHNL_OP_CONFIG_RX_QUEUE: | |
1447 | valid_len = sizeof(struct virtchnl_rxq_info); | |
1448 | break; | |
1449 | case VIRTCHNL_OP_CONFIG_VSI_QUEUES: | |
5e7f59fa | 1450 | valid_len = virtchnl_vsi_queue_config_info_LEGACY_SIZEOF; |
735e35c5 JB |
1451 | if (msglen >= valid_len) { |
1452 | struct virtchnl_vsi_queue_config_info *vqc = | |
1453 | (struct virtchnl_vsi_queue_config_info *)msg; | |
5e7f59fa AL |
1454 | valid_len = virtchnl_struct_size(vqc, qpair, |
1455 | vqc->num_queue_pairs); | |
735e35c5 JB |
1456 | if (vqc->num_queue_pairs == 0) |
1457 | err_msg_format = true; | |
1458 | } | |
1459 | break; | |
1460 | case VIRTCHNL_OP_CONFIG_IRQ_MAP: | |
5e7f59fa | 1461 | valid_len = virtchnl_irq_map_info_LEGACY_SIZEOF; |
735e35c5 JB |
1462 | if (msglen >= valid_len) { |
1463 | struct virtchnl_irq_map_info *vimi = | |
1464 | (struct virtchnl_irq_map_info *)msg; | |
5e7f59fa AL |
1465 | valid_len = virtchnl_struct_size(vimi, vecmap, |
1466 | vimi->num_vectors); | |
735e35c5 JB |
1467 | if (vimi->num_vectors == 0) |
1468 | err_msg_format = true; | |
1469 | } | |
1470 | break; | |
1471 | case VIRTCHNL_OP_ENABLE_QUEUES: | |
1472 | case VIRTCHNL_OP_DISABLE_QUEUES: | |
1473 | valid_len = sizeof(struct virtchnl_queue_select); | |
1474 | break; | |
1475 | case VIRTCHNL_OP_ADD_ETH_ADDR: | |
1476 | case VIRTCHNL_OP_DEL_ETH_ADDR: | |
5e7f59fa | 1477 | valid_len = virtchnl_ether_addr_list_LEGACY_SIZEOF; |
735e35c5 JB |
1478 | if (msglen >= valid_len) { |
1479 | struct virtchnl_ether_addr_list *veal = | |
1480 | (struct virtchnl_ether_addr_list *)msg; | |
5e7f59fa AL |
1481 | valid_len = virtchnl_struct_size(veal, list, |
1482 | veal->num_elements); | |
735e35c5 JB |
1483 | if (veal->num_elements == 0) |
1484 | err_msg_format = true; | |
1485 | } | |
1486 | break; | |
1487 | case VIRTCHNL_OP_ADD_VLAN: | |
1488 | case VIRTCHNL_OP_DEL_VLAN: | |
5e7f59fa | 1489 | valid_len = virtchnl_vlan_filter_list_LEGACY_SIZEOF; |
735e35c5 JB |
1490 | if (msglen >= valid_len) { |
1491 | struct virtchnl_vlan_filter_list *vfl = | |
1492 | (struct virtchnl_vlan_filter_list *)msg; | |
5e7f59fa AL |
1493 | valid_len = virtchnl_struct_size(vfl, vlan_id, |
1494 | vfl->num_elements); | |
735e35c5 JB |
1495 | if (vfl->num_elements == 0) |
1496 | err_msg_format = true; | |
1497 | } | |
1498 | break; | |
1499 | case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE: | |
1500 | valid_len = sizeof(struct virtchnl_promisc_info); | |
1501 | break; | |
1502 | case VIRTCHNL_OP_GET_STATS: | |
1503 | valid_len = sizeof(struct virtchnl_queue_select); | |
1504 | break; | |
2723f3b5 | 1505 | case VIRTCHNL_OP_RDMA: |
735e35c5 JB |
1506 | /* These messages are opaque to us and will be validated in |
1507 | * the RDMA client code. We just need to check for nonzero | |
1508 | * length. The firmware will enforce max length restrictions. | |
1509 | */ | |
1510 | if (msglen) | |
1511 | valid_len = msglen; | |
1512 | else | |
1513 | err_msg_format = true; | |
1514 | break; | |
2723f3b5 | 1515 | case VIRTCHNL_OP_RELEASE_RDMA_IRQ_MAP: |
735e35c5 | 1516 | break; |
2723f3b5 | 1517 | case VIRTCHNL_OP_CONFIG_RDMA_IRQ_MAP: |
b0654e64 | 1518 | valid_len = virtchnl_rdma_qvlist_info_LEGACY_SIZEOF; |
735e35c5 | 1519 | if (msglen >= valid_len) { |
2723f3b5 JB |
1520 | struct virtchnl_rdma_qvlist_info *qv = |
1521 | (struct virtchnl_rdma_qvlist_info *)msg; | |
1522 | ||
b0654e64 AL |
1523 | valid_len = virtchnl_struct_size(qv, qv_info, |
1524 | qv->num_vectors); | |
735e35c5 JB |
1525 | } |
1526 | break; | |
1527 | case VIRTCHNL_OP_CONFIG_RSS_KEY: | |
dd2e84bb | 1528 | valid_len = virtchnl_rss_key_LEGACY_SIZEOF; |
735e35c5 JB |
1529 | if (msglen >= valid_len) { |
1530 | struct virtchnl_rss_key *vrk = | |
1531 | (struct virtchnl_rss_key *)msg; | |
dd2e84bb AL |
1532 | valid_len = virtchnl_struct_size(vrk, key, |
1533 | vrk->key_len); | |
735e35c5 JB |
1534 | } |
1535 | break; | |
1536 | case VIRTCHNL_OP_CONFIG_RSS_LUT: | |
dd2e84bb | 1537 | valid_len = virtchnl_rss_lut_LEGACY_SIZEOF; |
735e35c5 JB |
1538 | if (msglen >= valid_len) { |
1539 | struct virtchnl_rss_lut *vrl = | |
1540 | (struct virtchnl_rss_lut *)msg; | |
dd2e84bb AL |
1541 | valid_len = virtchnl_struct_size(vrl, lut, |
1542 | vrl->lut_entries); | |
735e35c5 JB |
1543 | } |
1544 | break; | |
1545 | case VIRTCHNL_OP_GET_RSS_HENA_CAPS: | |
1546 | break; | |
1547 | case VIRTCHNL_OP_SET_RSS_HENA: | |
1548 | valid_len = sizeof(struct virtchnl_rss_hena); | |
1549 | break; | |
8774370d MS |
1550 | case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING: |
1551 | case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING: | |
1552 | break; | |
a3f5aa90 AB |
1553 | case VIRTCHNL_OP_REQUEST_QUEUES: |
1554 | valid_len = sizeof(struct virtchnl_vf_res_request); | |
1555 | break; | |
eb09f1fe | 1556 | case VIRTCHNL_OP_ENABLE_CHANNELS: |
b0654e64 | 1557 | valid_len = virtchnl_tc_info_LEGACY_SIZEOF; |
eb09f1fe HR |
1558 | if (msglen >= valid_len) { |
1559 | struct virtchnl_tc_info *vti = | |
1560 | (struct virtchnl_tc_info *)msg; | |
b0654e64 AL |
1561 | valid_len = virtchnl_struct_size(vti, list, |
1562 | vti->num_tc); | |
eb09f1fe HR |
1563 | if (vti->num_tc == 0) |
1564 | err_msg_format = true; | |
1565 | } | |
1566 | break; | |
1567 | case VIRTCHNL_OP_DISABLE_CHANNELS: | |
1568 | break; | |
3872c8d4 | 1569 | case VIRTCHNL_OP_ADD_CLOUD_FILTER: |
3872c8d4 HR |
1570 | case VIRTCHNL_OP_DEL_CLOUD_FILTER: |
1571 | valid_len = sizeof(struct virtchnl_filter); | |
1572 | break; | |
e753df8f MJ |
1573 | case VIRTCHNL_OP_GET_SUPPORTED_RXDIDS: |
1574 | break; | |
222a8ab0 QZ |
1575 | case VIRTCHNL_OP_ADD_RSS_CFG: |
1576 | case VIRTCHNL_OP_DEL_RSS_CFG: | |
1577 | valid_len = sizeof(struct virtchnl_rss_cfg); | |
1578 | break; | |
1f7ea1cd QZ |
1579 | case VIRTCHNL_OP_ADD_FDIR_FILTER: |
1580 | valid_len = sizeof(struct virtchnl_fdir_add); | |
1581 | break; | |
1582 | case VIRTCHNL_OP_DEL_FDIR_FILTER: | |
1583 | valid_len = sizeof(struct virtchnl_fdir_del); | |
1584 | break; | |
bd0b536d BC |
1585 | case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS: |
1586 | break; | |
1587 | case VIRTCHNL_OP_ADD_VLAN_V2: | |
1588 | case VIRTCHNL_OP_DEL_VLAN_V2: | |
b0654e64 | 1589 | valid_len = virtchnl_vlan_filter_list_v2_LEGACY_SIZEOF; |
bd0b536d BC |
1590 | if (msglen >= valid_len) { |
1591 | struct virtchnl_vlan_filter_list_v2 *vfl = | |
1592 | (struct virtchnl_vlan_filter_list_v2 *)msg; | |
1593 | ||
b0654e64 AL |
1594 | valid_len = virtchnl_struct_size(vfl, filters, |
1595 | vfl->num_elements); | |
bd0b536d BC |
1596 | |
1597 | if (vfl->num_elements == 0) { | |
1598 | err_msg_format = true; | |
1599 | break; | |
1600 | } | |
1601 | } | |
1602 | break; | |
1603 | case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2: | |
1604 | case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2: | |
1605 | case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2: | |
1606 | case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2: | |
1607 | valid_len = sizeof(struct virtchnl_vlan_setting); | |
1608 | break; | |
735e35c5 JB |
1609 | /* These are always errors coming from the VF. */ |
1610 | case VIRTCHNL_OP_EVENT: | |
1611 | case VIRTCHNL_OP_UNKNOWN: | |
1612 | default: | |
bb58fd7e | 1613 | return VIRTCHNL_STATUS_ERR_PARAM; |
735e35c5 JB |
1614 | } |
1615 | /* few more checks */ | |
0fccb85a | 1616 | if (err_msg_format || valid_len != msglen) |
735e35c5 JB |
1617 | return VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH; |
1618 | ||
1619 | return 0; | |
1620 | } | |
310a2ad9 | 1621 | #endif /* _VIRTCHNL_H_ */ |