1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2013 - 2018 Intel Corporation. */
3
4 #include "iavf_type.h"
5 #include "iavf_adminq.h"
6 #include "iavf_prototype.h"
7 #include <linux/avf/virtchnl.h>
8
9 /**
10 * iavf_set_mac_type - Sets MAC type
11 * @hw: pointer to the HW structure
12 *
13 * This function sets the mac type of the adapter based on the
14 * vendor ID and device ID stored in the hw structure.
15 **/
iavf_set_mac_type(struct iavf_hw * hw)16 enum iavf_status iavf_set_mac_type(struct iavf_hw *hw)
17 {
18 enum iavf_status status = 0;
19
20 if (hw->vendor_id == PCI_VENDOR_ID_INTEL) {
21 switch (hw->device_id) {
22 case IAVF_DEV_ID_X722_VF:
23 hw->mac.type = IAVF_MAC_X722_VF;
24 break;
25 case IAVF_DEV_ID_VF:
26 case IAVF_DEV_ID_VF_HV:
27 case IAVF_DEV_ID_ADAPTIVE_VF:
28 hw->mac.type = IAVF_MAC_VF;
29 break;
30 default:
31 hw->mac.type = IAVF_MAC_GENERIC;
32 break;
33 }
34 } else {
35 status = IAVF_ERR_DEVICE_NOT_SUPPORTED;
36 }
37
38 return status;
39 }
40
41 /**
42 * iavf_aq_str - convert AQ err code to a string
43 * @hw: pointer to the HW structure
44 * @aq_err: the AQ error code to convert
45 **/
iavf_aq_str(struct iavf_hw * hw,enum iavf_admin_queue_err aq_err)46 const char *iavf_aq_str(struct iavf_hw *hw, enum iavf_admin_queue_err aq_err)
47 {
48 switch (aq_err) {
49 case IAVF_AQ_RC_OK:
50 return "OK";
51 case IAVF_AQ_RC_EPERM:
52 return "IAVF_AQ_RC_EPERM";
53 case IAVF_AQ_RC_ENOENT:
54 return "IAVF_AQ_RC_ENOENT";
55 case IAVF_AQ_RC_ESRCH:
56 return "IAVF_AQ_RC_ESRCH";
57 case IAVF_AQ_RC_EINTR:
58 return "IAVF_AQ_RC_EINTR";
59 case IAVF_AQ_RC_EIO:
60 return "IAVF_AQ_RC_EIO";
61 case IAVF_AQ_RC_ENXIO:
62 return "IAVF_AQ_RC_ENXIO";
63 case IAVF_AQ_RC_E2BIG:
64 return "IAVF_AQ_RC_E2BIG";
65 case IAVF_AQ_RC_EAGAIN:
66 return "IAVF_AQ_RC_EAGAIN";
67 case IAVF_AQ_RC_ENOMEM:
68 return "IAVF_AQ_RC_ENOMEM";
69 case IAVF_AQ_RC_EACCES:
70 return "IAVF_AQ_RC_EACCES";
71 case IAVF_AQ_RC_EFAULT:
72 return "IAVF_AQ_RC_EFAULT";
73 case IAVF_AQ_RC_EBUSY:
74 return "IAVF_AQ_RC_EBUSY";
75 case IAVF_AQ_RC_EEXIST:
76 return "IAVF_AQ_RC_EEXIST";
77 case IAVF_AQ_RC_EINVAL:
78 return "IAVF_AQ_RC_EINVAL";
79 case IAVF_AQ_RC_ENOTTY:
80 return "IAVF_AQ_RC_ENOTTY";
81 case IAVF_AQ_RC_ENOSPC:
82 return "IAVF_AQ_RC_ENOSPC";
83 case IAVF_AQ_RC_ENOSYS:
84 return "IAVF_AQ_RC_ENOSYS";
85 case IAVF_AQ_RC_ERANGE:
86 return "IAVF_AQ_RC_ERANGE";
87 case IAVF_AQ_RC_EFLUSHED:
88 return "IAVF_AQ_RC_EFLUSHED";
89 case IAVF_AQ_RC_BAD_ADDR:
90 return "IAVF_AQ_RC_BAD_ADDR";
91 case IAVF_AQ_RC_EMODE:
92 return "IAVF_AQ_RC_EMODE";
93 case IAVF_AQ_RC_EFBIG:
94 return "IAVF_AQ_RC_EFBIG";
95 }
96
97 snprintf(hw->err_str, sizeof(hw->err_str), "%d", aq_err);
98 return hw->err_str;
99 }
100
101 /**
102 * iavf_stat_str - convert status err code to a string
103 * @hw: pointer to the HW structure
104 * @stat_err: the status error code to convert
105 **/
iavf_stat_str(struct iavf_hw * hw,enum iavf_status stat_err)106 const char *iavf_stat_str(struct iavf_hw *hw, enum iavf_status stat_err)
107 {
108 switch (stat_err) {
109 case 0:
110 return "OK";
111 case IAVF_ERR_NVM:
112 return "IAVF_ERR_NVM";
113 case IAVF_ERR_NVM_CHECKSUM:
114 return "IAVF_ERR_NVM_CHECKSUM";
115 case IAVF_ERR_PHY:
116 return "IAVF_ERR_PHY";
117 case IAVF_ERR_CONFIG:
118 return "IAVF_ERR_CONFIG";
119 case IAVF_ERR_PARAM:
120 return "IAVF_ERR_PARAM";
121 case IAVF_ERR_MAC_TYPE:
122 return "IAVF_ERR_MAC_TYPE";
123 case IAVF_ERR_UNKNOWN_PHY:
124 return "IAVF_ERR_UNKNOWN_PHY";
125 case IAVF_ERR_LINK_SETUP:
126 return "IAVF_ERR_LINK_SETUP";
127 case IAVF_ERR_ADAPTER_STOPPED:
128 return "IAVF_ERR_ADAPTER_STOPPED";
129 case IAVF_ERR_INVALID_MAC_ADDR:
130 return "IAVF_ERR_INVALID_MAC_ADDR";
131 case IAVF_ERR_DEVICE_NOT_SUPPORTED:
132 return "IAVF_ERR_DEVICE_NOT_SUPPORTED";
133 case IAVF_ERR_PRIMARY_REQUESTS_PENDING:
134 return "IAVF_ERR_PRIMARY_REQUESTS_PENDING";
135 case IAVF_ERR_INVALID_LINK_SETTINGS:
136 return "IAVF_ERR_INVALID_LINK_SETTINGS";
137 case IAVF_ERR_AUTONEG_NOT_COMPLETE:
138 return "IAVF_ERR_AUTONEG_NOT_COMPLETE";
139 case IAVF_ERR_RESET_FAILED:
140 return "IAVF_ERR_RESET_FAILED";
141 case IAVF_ERR_SWFW_SYNC:
142 return "IAVF_ERR_SWFW_SYNC";
143 case IAVF_ERR_NO_AVAILABLE_VSI:
144 return "IAVF_ERR_NO_AVAILABLE_VSI";
145 case IAVF_ERR_NO_MEMORY:
146 return "IAVF_ERR_NO_MEMORY";
147 case IAVF_ERR_BAD_PTR:
148 return "IAVF_ERR_BAD_PTR";
149 case IAVF_ERR_RING_FULL:
150 return "IAVF_ERR_RING_FULL";
151 case IAVF_ERR_INVALID_PD_ID:
152 return "IAVF_ERR_INVALID_PD_ID";
153 case IAVF_ERR_INVALID_QP_ID:
154 return "IAVF_ERR_INVALID_QP_ID";
155 case IAVF_ERR_INVALID_CQ_ID:
156 return "IAVF_ERR_INVALID_CQ_ID";
157 case IAVF_ERR_INVALID_CEQ_ID:
158 return "IAVF_ERR_INVALID_CEQ_ID";
159 case IAVF_ERR_INVALID_AEQ_ID:
160 return "IAVF_ERR_INVALID_AEQ_ID";
161 case IAVF_ERR_INVALID_SIZE:
162 return "IAVF_ERR_INVALID_SIZE";
163 case IAVF_ERR_INVALID_ARP_INDEX:
164 return "IAVF_ERR_INVALID_ARP_INDEX";
165 case IAVF_ERR_INVALID_FPM_FUNC_ID:
166 return "IAVF_ERR_INVALID_FPM_FUNC_ID";
167 case IAVF_ERR_QP_INVALID_MSG_SIZE:
168 return "IAVF_ERR_QP_INVALID_MSG_SIZE";
169 case IAVF_ERR_QP_TOOMANY_WRS_POSTED:
170 return "IAVF_ERR_QP_TOOMANY_WRS_POSTED";
171 case IAVF_ERR_INVALID_FRAG_COUNT:
172 return "IAVF_ERR_INVALID_FRAG_COUNT";
173 case IAVF_ERR_QUEUE_EMPTY:
174 return "IAVF_ERR_QUEUE_EMPTY";
175 case IAVF_ERR_INVALID_ALIGNMENT:
176 return "IAVF_ERR_INVALID_ALIGNMENT";
177 case IAVF_ERR_FLUSHED_QUEUE:
178 return "IAVF_ERR_FLUSHED_QUEUE";
179 case IAVF_ERR_INVALID_PUSH_PAGE_INDEX:
180 return "IAVF_ERR_INVALID_PUSH_PAGE_INDEX";
181 case IAVF_ERR_INVALID_IMM_DATA_SIZE:
182 return "IAVF_ERR_INVALID_IMM_DATA_SIZE";
183 case IAVF_ERR_TIMEOUT:
184 return "IAVF_ERR_TIMEOUT";
185 case IAVF_ERR_OPCODE_MISMATCH:
186 return "IAVF_ERR_OPCODE_MISMATCH";
187 case IAVF_ERR_CQP_COMPL_ERROR:
188 return "IAVF_ERR_CQP_COMPL_ERROR";
189 case IAVF_ERR_INVALID_VF_ID:
190 return "IAVF_ERR_INVALID_VF_ID";
191 case IAVF_ERR_INVALID_HMCFN_ID:
192 return "IAVF_ERR_INVALID_HMCFN_ID";
193 case IAVF_ERR_BACKING_PAGE_ERROR:
194 return "IAVF_ERR_BACKING_PAGE_ERROR";
195 case IAVF_ERR_NO_PBLCHUNKS_AVAILABLE:
196 return "IAVF_ERR_NO_PBLCHUNKS_AVAILABLE";
197 case IAVF_ERR_INVALID_PBLE_INDEX:
198 return "IAVF_ERR_INVALID_PBLE_INDEX";
199 case IAVF_ERR_INVALID_SD_INDEX:
200 return "IAVF_ERR_INVALID_SD_INDEX";
201 case IAVF_ERR_INVALID_PAGE_DESC_INDEX:
202 return "IAVF_ERR_INVALID_PAGE_DESC_INDEX";
203 case IAVF_ERR_INVALID_SD_TYPE:
204 return "IAVF_ERR_INVALID_SD_TYPE";
205 case IAVF_ERR_MEMCPY_FAILED:
206 return "IAVF_ERR_MEMCPY_FAILED";
207 case IAVF_ERR_INVALID_HMC_OBJ_INDEX:
208 return "IAVF_ERR_INVALID_HMC_OBJ_INDEX";
209 case IAVF_ERR_INVALID_HMC_OBJ_COUNT:
210 return "IAVF_ERR_INVALID_HMC_OBJ_COUNT";
211 case IAVF_ERR_INVALID_SRQ_ARM_LIMIT:
212 return "IAVF_ERR_INVALID_SRQ_ARM_LIMIT";
213 case IAVF_ERR_SRQ_ENABLED:
214 return "IAVF_ERR_SRQ_ENABLED";
215 case IAVF_ERR_ADMIN_QUEUE_ERROR:
216 return "IAVF_ERR_ADMIN_QUEUE_ERROR";
217 case IAVF_ERR_ADMIN_QUEUE_TIMEOUT:
218 return "IAVF_ERR_ADMIN_QUEUE_TIMEOUT";
219 case IAVF_ERR_BUF_TOO_SHORT:
220 return "IAVF_ERR_BUF_TOO_SHORT";
221 case IAVF_ERR_ADMIN_QUEUE_FULL:
222 return "IAVF_ERR_ADMIN_QUEUE_FULL";
223 case IAVF_ERR_ADMIN_QUEUE_NO_WORK:
224 return "IAVF_ERR_ADMIN_QUEUE_NO_WORK";
225 case IAVF_ERR_BAD_RDMA_CQE:
226 return "IAVF_ERR_BAD_RDMA_CQE";
227 case IAVF_ERR_NVM_BLANK_MODE:
228 return "IAVF_ERR_NVM_BLANK_MODE";
229 case IAVF_ERR_NOT_IMPLEMENTED:
230 return "IAVF_ERR_NOT_IMPLEMENTED";
231 case IAVF_ERR_PE_DOORBELL_NOT_ENABLED:
232 return "IAVF_ERR_PE_DOORBELL_NOT_ENABLED";
233 case IAVF_ERR_DIAG_TEST_FAILED:
234 return "IAVF_ERR_DIAG_TEST_FAILED";
235 case IAVF_ERR_NOT_READY:
236 return "IAVF_ERR_NOT_READY";
237 case IAVF_NOT_SUPPORTED:
238 return "IAVF_NOT_SUPPORTED";
239 case IAVF_ERR_FIRMWARE_API_VERSION:
240 return "IAVF_ERR_FIRMWARE_API_VERSION";
241 case IAVF_ERR_ADMIN_QUEUE_CRITICAL_ERROR:
242 return "IAVF_ERR_ADMIN_QUEUE_CRITICAL_ERROR";
243 }
244
245 snprintf(hw->err_str, sizeof(hw->err_str), "%d", stat_err);
246 return hw->err_str;
247 }
248
249 /**
250 * iavf_debug_aq
251 * @hw: debug mask related to admin queue
252 * @mask: debug mask
253 * @desc: pointer to admin queue descriptor
254 * @buffer: pointer to command buffer
255 * @buf_len: max length of buffer
256 *
257 * Dumps debug log about adminq command with descriptor contents.
258 **/
iavf_debug_aq(struct iavf_hw * hw,enum iavf_debug_mask mask,void * desc,void * buffer,u16 buf_len)259 void iavf_debug_aq(struct iavf_hw *hw, enum iavf_debug_mask mask, void *desc,
260 void *buffer, u16 buf_len)
261 {
262 struct iavf_aq_desc *aq_desc = (struct iavf_aq_desc *)desc;
263 u8 *buf = (u8 *)buffer;
264
265 if ((!(mask & hw->debug_mask)) || !desc)
266 return;
267
268 iavf_debug(hw, mask,
269 "AQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n",
270 le16_to_cpu(aq_desc->opcode),
271 le16_to_cpu(aq_desc->flags),
272 le16_to_cpu(aq_desc->datalen),
273 le16_to_cpu(aq_desc->retval));
274 iavf_debug(hw, mask, "\tcookie (h,l) 0x%08X 0x%08X\n",
275 le32_to_cpu(aq_desc->cookie_high),
276 le32_to_cpu(aq_desc->cookie_low));
277 iavf_debug(hw, mask, "\tparam (0,1) 0x%08X 0x%08X\n",
278 le32_to_cpu(aq_desc->params.internal.param0),
279 le32_to_cpu(aq_desc->params.internal.param1));
280 iavf_debug(hw, mask, "\taddr (h,l) 0x%08X 0x%08X\n",
281 le32_to_cpu(aq_desc->params.external.addr_high),
282 le32_to_cpu(aq_desc->params.external.addr_low));
283
284 if (buffer && aq_desc->datalen) {
285 u16 len = le16_to_cpu(aq_desc->datalen);
286
287 iavf_debug(hw, mask, "AQ CMD Buffer:\n");
288 if (buf_len < len)
289 len = buf_len;
290 /* write the full 16-byte chunks */
291 if (hw->debug_mask & mask) {
292 char prefix[27];
293
294 snprintf(prefix, sizeof(prefix),
295 "iavf %02x:%02x.%x: \t0x",
296 hw->bus.bus_id,
297 hw->bus.device,
298 hw->bus.func);
299
300 print_hex_dump(KERN_INFO, prefix, DUMP_PREFIX_OFFSET,
301 16, 1, buf, len, false);
302 }
303 }
304 }
305
306 /**
307 * iavf_check_asq_alive
308 * @hw: pointer to the hw struct
309 *
310 * Returns true if Queue is enabled else false.
311 **/
iavf_check_asq_alive(struct iavf_hw * hw)312 bool iavf_check_asq_alive(struct iavf_hw *hw)
313 {
314 if (hw->aq.asq.len)
315 return !!(rd32(hw, hw->aq.asq.len) &
316 IAVF_VF_ATQLEN1_ATQENABLE_MASK);
317 else
318 return false;
319 }
320
321 /**
322 * iavf_aq_queue_shutdown
323 * @hw: pointer to the hw struct
324 * @unloading: is the driver unloading itself
325 *
326 * Tell the Firmware that we're shutting down the AdminQ and whether
327 * or not the driver is unloading as well.
328 **/
iavf_aq_queue_shutdown(struct iavf_hw * hw,bool unloading)329 enum iavf_status iavf_aq_queue_shutdown(struct iavf_hw *hw, bool unloading)
330 {
331 struct iavf_aq_desc desc;
332 struct iavf_aqc_queue_shutdown *cmd =
333 (struct iavf_aqc_queue_shutdown *)&desc.params.raw;
334 enum iavf_status status;
335
336 iavf_fill_default_direct_cmd_desc(&desc, iavf_aqc_opc_queue_shutdown);
337
338 if (unloading)
339 cmd->driver_unloading = cpu_to_le32(IAVF_AQ_DRIVER_UNLOADING);
340 status = iavf_asq_send_command(hw, &desc, NULL, 0, NULL);
341
342 return status;
343 }
344
345 /**
346 * iavf_aq_get_set_rss_lut
347 * @hw: pointer to the hardware structure
348 * @vsi_id: vsi fw index
349 * @pf_lut: for PF table set true, for VSI table set false
350 * @lut: pointer to the lut buffer provided by the caller
351 * @lut_size: size of the lut buffer
352 * @set: set true to set the table, false to get the table
353 *
354 * Internal function to get or set RSS look up table
355 **/
iavf_aq_get_set_rss_lut(struct iavf_hw * hw,u16 vsi_id,bool pf_lut,u8 * lut,u16 lut_size,bool set)356 static enum iavf_status iavf_aq_get_set_rss_lut(struct iavf_hw *hw,
357 u16 vsi_id, bool pf_lut,
358 u8 *lut, u16 lut_size,
359 bool set)
360 {
361 enum iavf_status status;
362 struct iavf_aq_desc desc;
363 struct iavf_aqc_get_set_rss_lut *cmd_resp =
364 (struct iavf_aqc_get_set_rss_lut *)&desc.params.raw;
365
366 if (set)
367 iavf_fill_default_direct_cmd_desc(&desc,
368 iavf_aqc_opc_set_rss_lut);
369 else
370 iavf_fill_default_direct_cmd_desc(&desc,
371 iavf_aqc_opc_get_rss_lut);
372
373 /* Indirect command */
374 desc.flags |= cpu_to_le16((u16)IAVF_AQ_FLAG_BUF);
375 desc.flags |= cpu_to_le16((u16)IAVF_AQ_FLAG_RD);
376
377 cmd_resp->vsi_id =
378 cpu_to_le16((u16)((vsi_id <<
379 IAVF_AQC_SET_RSS_LUT_VSI_ID_SHIFT) &
380 IAVF_AQC_SET_RSS_LUT_VSI_ID_MASK));
381 cmd_resp->vsi_id |= cpu_to_le16((u16)IAVF_AQC_SET_RSS_LUT_VSI_VALID);
382
383 if (pf_lut)
384 cmd_resp->flags |= cpu_to_le16((u16)
385 ((IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_PF <<
386 IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) &
387 IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_MASK));
388 else
389 cmd_resp->flags |= cpu_to_le16((u16)
390 ((IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_VSI <<
391 IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) &
392 IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_MASK));
393
394 status = iavf_asq_send_command(hw, &desc, lut, lut_size, NULL);
395
396 return status;
397 }
398
399 /**
400 * iavf_aq_set_rss_lut
401 * @hw: pointer to the hardware structure
402 * @vsi_id: vsi fw index
403 * @pf_lut: for PF table set true, for VSI table set false
404 * @lut: pointer to the lut buffer provided by the caller
405 * @lut_size: size of the lut buffer
406 *
407 * set the RSS lookup table, PF or VSI type
408 **/
iavf_aq_set_rss_lut(struct iavf_hw * hw,u16 vsi_id,bool pf_lut,u8 * lut,u16 lut_size)409 enum iavf_status iavf_aq_set_rss_lut(struct iavf_hw *hw, u16 vsi_id,
410 bool pf_lut, u8 *lut, u16 lut_size)
411 {
412 return iavf_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size, true);
413 }
414
415 /**
416 * iavf_aq_get_set_rss_key
417 * @hw: pointer to the hw struct
418 * @vsi_id: vsi fw index
419 * @key: pointer to key info struct
420 * @set: set true to set the key, false to get the key
421 *
422 * get the RSS key per VSI
423 **/
424 static enum
iavf_aq_get_set_rss_key(struct iavf_hw * hw,u16 vsi_id,struct iavf_aqc_get_set_rss_key_data * key,bool set)425 iavf_status iavf_aq_get_set_rss_key(struct iavf_hw *hw, u16 vsi_id,
426 struct iavf_aqc_get_set_rss_key_data *key,
427 bool set)
428 {
429 enum iavf_status status;
430 struct iavf_aq_desc desc;
431 struct iavf_aqc_get_set_rss_key *cmd_resp =
432 (struct iavf_aqc_get_set_rss_key *)&desc.params.raw;
433 u16 key_size = sizeof(struct iavf_aqc_get_set_rss_key_data);
434
435 if (set)
436 iavf_fill_default_direct_cmd_desc(&desc,
437 iavf_aqc_opc_set_rss_key);
438 else
439 iavf_fill_default_direct_cmd_desc(&desc,
440 iavf_aqc_opc_get_rss_key);
441
442 /* Indirect command */
443 desc.flags |= cpu_to_le16((u16)IAVF_AQ_FLAG_BUF);
444 desc.flags |= cpu_to_le16((u16)IAVF_AQ_FLAG_RD);
445
446 cmd_resp->vsi_id =
447 cpu_to_le16((u16)((vsi_id <<
448 IAVF_AQC_SET_RSS_KEY_VSI_ID_SHIFT) &
449 IAVF_AQC_SET_RSS_KEY_VSI_ID_MASK));
450 cmd_resp->vsi_id |= cpu_to_le16((u16)IAVF_AQC_SET_RSS_KEY_VSI_VALID);
451
452 status = iavf_asq_send_command(hw, &desc, key, key_size, NULL);
453
454 return status;
455 }
456
457 /**
458 * iavf_aq_set_rss_key
459 * @hw: pointer to the hw struct
460 * @vsi_id: vsi fw index
461 * @key: pointer to key info struct
462 *
463 * set the RSS key per VSI
464 **/
iavf_aq_set_rss_key(struct iavf_hw * hw,u16 vsi_id,struct iavf_aqc_get_set_rss_key_data * key)465 enum iavf_status iavf_aq_set_rss_key(struct iavf_hw *hw, u16 vsi_id,
466 struct iavf_aqc_get_set_rss_key_data *key)
467 {
468 return iavf_aq_get_set_rss_key(hw, vsi_id, key, true);
469 }
470
471 /* The iavf_ptype_lookup table is used to convert from the 8-bit ptype in the
472 * hardware to a bit-field that can be used by SW to more easily determine the
473 * packet type.
474 *
475 * Macros are used to shorten the table lines and make this table human
476 * readable.
477 *
478 * We store the PTYPE in the top byte of the bit field - this is just so that
479 * we can check that the table doesn't have a row missing, as the index into
480 * the table should be the PTYPE.
481 *
482 * Typical work flow:
483 *
484 * IF NOT iavf_ptype_lookup[ptype].known
485 * THEN
486 * Packet is unknown
487 * ELSE IF iavf_ptype_lookup[ptype].outer_ip == IAVF_RX_PTYPE_OUTER_IP
488 * Use the rest of the fields to look at the tunnels, inner protocols, etc
489 * ELSE
490 * Use the enum iavf_rx_l2_ptype to decode the packet type
491 * ENDIF
492 */
493
494 /* macro to make the table lines short, use explicit indexing with [PTYPE] */
495 #define IAVF_PTT(PTYPE, OUTER_IP, OUTER_IP_VER, OUTER_FRAG, T, TE, TEF, I, PL)\
496 [PTYPE] = { \
497 1, \
498 IAVF_RX_PTYPE_OUTER_##OUTER_IP, \
499 IAVF_RX_PTYPE_OUTER_##OUTER_IP_VER, \
500 IAVF_RX_PTYPE_##OUTER_FRAG, \
501 IAVF_RX_PTYPE_TUNNEL_##T, \
502 IAVF_RX_PTYPE_TUNNEL_END_##TE, \
503 IAVF_RX_PTYPE_##TEF, \
504 IAVF_RX_PTYPE_INNER_PROT_##I, \
505 IAVF_RX_PTYPE_PAYLOAD_LAYER_##PL }
506
507 #define IAVF_PTT_UNUSED_ENTRY(PTYPE) [PTYPE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }
508
509 /* shorter macros makes the table fit but are terse */
510 #define IAVF_RX_PTYPE_NOF IAVF_RX_PTYPE_NOT_FRAG
511 #define IAVF_RX_PTYPE_FRG IAVF_RX_PTYPE_FRAG
512 #define IAVF_RX_PTYPE_INNER_PROT_TS IAVF_RX_PTYPE_INNER_PROT_TIMESYNC
513
514 /* Lookup table mapping the 8-bit HW PTYPE to the bit field for decoding */
515 struct iavf_rx_ptype_decoded iavf_ptype_lookup[BIT(8)] = {
516 /* L2 Packet types */
517 IAVF_PTT_UNUSED_ENTRY(0),
518 IAVF_PTT(1, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
519 IAVF_PTT(2, L2, NONE, NOF, NONE, NONE, NOF, TS, PAY2),
520 IAVF_PTT(3, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
521 IAVF_PTT_UNUSED_ENTRY(4),
522 IAVF_PTT_UNUSED_ENTRY(5),
523 IAVF_PTT(6, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
524 IAVF_PTT(7, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
525 IAVF_PTT_UNUSED_ENTRY(8),
526 IAVF_PTT_UNUSED_ENTRY(9),
527 IAVF_PTT(10, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
528 IAVF_PTT(11, L2, NONE, NOF, NONE, NONE, NOF, NONE, NONE),
529 IAVF_PTT(12, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
530 IAVF_PTT(13, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
531 IAVF_PTT(14, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
532 IAVF_PTT(15, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
533 IAVF_PTT(16, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
534 IAVF_PTT(17, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
535 IAVF_PTT(18, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
536 IAVF_PTT(19, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
537 IAVF_PTT(20, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
538 IAVF_PTT(21, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
539
540 /* Non Tunneled IPv4 */
541 IAVF_PTT(22, IP, IPV4, FRG, NONE, NONE, NOF, NONE, PAY3),
542 IAVF_PTT(23, IP, IPV4, NOF, NONE, NONE, NOF, NONE, PAY3),
543 IAVF_PTT(24, IP, IPV4, NOF, NONE, NONE, NOF, UDP, PAY4),
544 IAVF_PTT_UNUSED_ENTRY(25),
545 IAVF_PTT(26, IP, IPV4, NOF, NONE, NONE, NOF, TCP, PAY4),
546 IAVF_PTT(27, IP, IPV4, NOF, NONE, NONE, NOF, SCTP, PAY4),
547 IAVF_PTT(28, IP, IPV4, NOF, NONE, NONE, NOF, ICMP, PAY4),
548
549 /* IPv4 --> IPv4 */
550 IAVF_PTT(29, IP, IPV4, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
551 IAVF_PTT(30, IP, IPV4, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
552 IAVF_PTT(31, IP, IPV4, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
553 IAVF_PTT_UNUSED_ENTRY(32),
554 IAVF_PTT(33, IP, IPV4, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
555 IAVF_PTT(34, IP, IPV4, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
556 IAVF_PTT(35, IP, IPV4, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
557
558 /* IPv4 --> IPv6 */
559 IAVF_PTT(36, IP, IPV4, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
560 IAVF_PTT(37, IP, IPV4, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
561 IAVF_PTT(38, IP, IPV4, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
562 IAVF_PTT_UNUSED_ENTRY(39),
563 IAVF_PTT(40, IP, IPV4, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
564 IAVF_PTT(41, IP, IPV4, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
565 IAVF_PTT(42, IP, IPV4, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
566
567 /* IPv4 --> GRE/NAT */
568 IAVF_PTT(43, IP, IPV4, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
569
570 /* IPv4 --> GRE/NAT --> IPv4 */
571 IAVF_PTT(44, IP, IPV4, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
572 IAVF_PTT(45, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
573 IAVF_PTT(46, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
574 IAVF_PTT_UNUSED_ENTRY(47),
575 IAVF_PTT(48, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
576 IAVF_PTT(49, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
577 IAVF_PTT(50, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
578
579 /* IPv4 --> GRE/NAT --> IPv6 */
580 IAVF_PTT(51, IP, IPV4, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
581 IAVF_PTT(52, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
582 IAVF_PTT(53, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
583 IAVF_PTT_UNUSED_ENTRY(54),
584 IAVF_PTT(55, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
585 IAVF_PTT(56, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
586 IAVF_PTT(57, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
587
588 /* IPv4 --> GRE/NAT --> MAC */
589 IAVF_PTT(58, IP, IPV4, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
590
591 /* IPv4 --> GRE/NAT --> MAC --> IPv4 */
592 IAVF_PTT(59, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
593 IAVF_PTT(60, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
594 IAVF_PTT(61, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
595 IAVF_PTT_UNUSED_ENTRY(62),
596 IAVF_PTT(63, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
597 IAVF_PTT(64, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
598 IAVF_PTT(65, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
599
600 /* IPv4 --> GRE/NAT -> MAC --> IPv6 */
601 IAVF_PTT(66, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
602 IAVF_PTT(67, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
603 IAVF_PTT(68, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
604 IAVF_PTT_UNUSED_ENTRY(69),
605 IAVF_PTT(70, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
606 IAVF_PTT(71, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
607 IAVF_PTT(72, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
608
609 /* IPv4 --> GRE/NAT --> MAC/VLAN */
610 IAVF_PTT(73, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
611
612 /* IPv4 ---> GRE/NAT -> MAC/VLAN --> IPv4 */
613 IAVF_PTT(74, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
614 IAVF_PTT(75, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
615 IAVF_PTT(76, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
616 IAVF_PTT_UNUSED_ENTRY(77),
617 IAVF_PTT(78, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
618 IAVF_PTT(79, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
619 IAVF_PTT(80, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
620
621 /* IPv4 -> GRE/NAT -> MAC/VLAN --> IPv6 */
622 IAVF_PTT(81, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
623 IAVF_PTT(82, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
624 IAVF_PTT(83, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
625 IAVF_PTT_UNUSED_ENTRY(84),
626 IAVF_PTT(85, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
627 IAVF_PTT(86, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
628 IAVF_PTT(87, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
629
630 /* Non Tunneled IPv6 */
631 IAVF_PTT(88, IP, IPV6, FRG, NONE, NONE, NOF, NONE, PAY3),
632 IAVF_PTT(89, IP, IPV6, NOF, NONE, NONE, NOF, NONE, PAY3),
633 IAVF_PTT(90, IP, IPV6, NOF, NONE, NONE, NOF, UDP, PAY4),
634 IAVF_PTT_UNUSED_ENTRY(91),
635 IAVF_PTT(92, IP, IPV6, NOF, NONE, NONE, NOF, TCP, PAY4),
636 IAVF_PTT(93, IP, IPV6, NOF, NONE, NONE, NOF, SCTP, PAY4),
637 IAVF_PTT(94, IP, IPV6, NOF, NONE, NONE, NOF, ICMP, PAY4),
638
639 /* IPv6 --> IPv4 */
640 IAVF_PTT(95, IP, IPV6, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
641 IAVF_PTT(96, IP, IPV6, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
642 IAVF_PTT(97, IP, IPV6, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
643 IAVF_PTT_UNUSED_ENTRY(98),
644 IAVF_PTT(99, IP, IPV6, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
645 IAVF_PTT(100, IP, IPV6, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
646 IAVF_PTT(101, IP, IPV6, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
647
648 /* IPv6 --> IPv6 */
649 IAVF_PTT(102, IP, IPV6, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
650 IAVF_PTT(103, IP, IPV6, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
651 IAVF_PTT(104, IP, IPV6, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
652 IAVF_PTT_UNUSED_ENTRY(105),
653 IAVF_PTT(106, IP, IPV6, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
654 IAVF_PTT(107, IP, IPV6, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
655 IAVF_PTT(108, IP, IPV6, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
656
657 /* IPv6 --> GRE/NAT */
658 IAVF_PTT(109, IP, IPV6, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
659
660 /* IPv6 --> GRE/NAT -> IPv4 */
661 IAVF_PTT(110, IP, IPV6, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
662 IAVF_PTT(111, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
663 IAVF_PTT(112, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
664 IAVF_PTT_UNUSED_ENTRY(113),
665 IAVF_PTT(114, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
666 IAVF_PTT(115, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
667 IAVF_PTT(116, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
668
669 /* IPv6 --> GRE/NAT -> IPv6 */
670 IAVF_PTT(117, IP, IPV6, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
671 IAVF_PTT(118, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
672 IAVF_PTT(119, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
673 IAVF_PTT_UNUSED_ENTRY(120),
674 IAVF_PTT(121, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
675 IAVF_PTT(122, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
676 IAVF_PTT(123, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
677
678 /* IPv6 --> GRE/NAT -> MAC */
679 IAVF_PTT(124, IP, IPV6, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
680
681 /* IPv6 --> GRE/NAT -> MAC -> IPv4 */
682 IAVF_PTT(125, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
683 IAVF_PTT(126, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
684 IAVF_PTT(127, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
685 IAVF_PTT_UNUSED_ENTRY(128),
686 IAVF_PTT(129, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
687 IAVF_PTT(130, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
688 IAVF_PTT(131, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
689
690 /* IPv6 --> GRE/NAT -> MAC -> IPv6 */
691 IAVF_PTT(132, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
692 IAVF_PTT(133, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
693 IAVF_PTT(134, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
694 IAVF_PTT_UNUSED_ENTRY(135),
695 IAVF_PTT(136, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
696 IAVF_PTT(137, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
697 IAVF_PTT(138, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
698
699 /* IPv6 --> GRE/NAT -> MAC/VLAN */
700 IAVF_PTT(139, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
701
702 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv4 */
703 IAVF_PTT(140, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
704 IAVF_PTT(141, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
705 IAVF_PTT(142, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
706 IAVF_PTT_UNUSED_ENTRY(143),
707 IAVF_PTT(144, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
708 IAVF_PTT(145, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
709 IAVF_PTT(146, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
710
711 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv6 */
712 IAVF_PTT(147, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
713 IAVF_PTT(148, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
714 IAVF_PTT(149, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
715 IAVF_PTT_UNUSED_ENTRY(150),
716 IAVF_PTT(151, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
717 IAVF_PTT(152, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
718 IAVF_PTT(153, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
719
720 /* unused entries */
721 [154 ... 255] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }
722 };
723
724 /**
725 * iavf_aq_send_msg_to_pf
726 * @hw: pointer to the hardware structure
727 * @v_opcode: opcodes for VF-PF communication
728 * @v_retval: return error code
729 * @msg: pointer to the msg buffer
730 * @msglen: msg length
731 * @cmd_details: pointer to command details
732 *
733 * Send message to PF driver using admin queue. By default, this message
734 * is sent asynchronously, i.e. iavf_asq_send_command() does not wait for
735 * completion before returning.
736 **/
iavf_aq_send_msg_to_pf(struct iavf_hw * hw,enum virtchnl_ops v_opcode,enum iavf_status v_retval,u8 * msg,u16 msglen,struct iavf_asq_cmd_details * cmd_details)737 enum iavf_status iavf_aq_send_msg_to_pf(struct iavf_hw *hw,
738 enum virtchnl_ops v_opcode,
739 enum iavf_status v_retval,
740 u8 *msg, u16 msglen,
741 struct iavf_asq_cmd_details *cmd_details)
742 {
743 struct iavf_asq_cmd_details details;
744 struct iavf_aq_desc desc;
745 enum iavf_status status;
746
747 iavf_fill_default_direct_cmd_desc(&desc, iavf_aqc_opc_send_msg_to_pf);
748 desc.flags |= cpu_to_le16((u16)IAVF_AQ_FLAG_SI);
749 desc.cookie_high = cpu_to_le32(v_opcode);
750 desc.cookie_low = cpu_to_le32(v_retval);
751 if (msglen) {
752 desc.flags |= cpu_to_le16((u16)(IAVF_AQ_FLAG_BUF
753 | IAVF_AQ_FLAG_RD));
754 if (msglen > IAVF_AQ_LARGE_BUF)
755 desc.flags |= cpu_to_le16((u16)IAVF_AQ_FLAG_LB);
756 desc.datalen = cpu_to_le16(msglen);
757 }
758 if (!cmd_details) {
759 memset(&details, 0, sizeof(details));
760 details.async = true;
761 cmd_details = &details;
762 }
763 status = iavf_asq_send_command(hw, &desc, msg, msglen, cmd_details);
764 return status;
765 }
766
767 /**
768 * iavf_vf_parse_hw_config
769 * @hw: pointer to the hardware structure
770 * @msg: pointer to the virtual channel VF resource structure
771 *
772 * Given a VF resource message from the PF, populate the hw struct
773 * with appropriate information.
774 **/
iavf_vf_parse_hw_config(struct iavf_hw * hw,struct virtchnl_vf_resource * msg)775 void iavf_vf_parse_hw_config(struct iavf_hw *hw,
776 struct virtchnl_vf_resource *msg)
777 {
778 struct virtchnl_vsi_resource *vsi_res;
779 int i;
780
781 vsi_res = &msg->vsi_res[0];
782
783 hw->dev_caps.num_vsis = msg->num_vsis;
784 hw->dev_caps.num_rx_qp = msg->num_queue_pairs;
785 hw->dev_caps.num_tx_qp = msg->num_queue_pairs;
786 hw->dev_caps.num_msix_vectors_vf = msg->max_vectors;
787 hw->dev_caps.dcb = msg->vf_cap_flags &
788 VIRTCHNL_VF_OFFLOAD_L2;
789 hw->dev_caps.fcoe = 0;
790 for (i = 0; i < msg->num_vsis; i++) {
791 if (vsi_res->vsi_type == VIRTCHNL_VSI_SRIOV) {
792 ether_addr_copy(hw->mac.perm_addr,
793 vsi_res->default_mac_addr);
794 ether_addr_copy(hw->mac.addr,
795 vsi_res->default_mac_addr);
796 }
797 vsi_res++;
798 }
799 }
800