1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2013 - 2015 Intel Corporation
6 #include "iavf_adminq.h"
7 #include "iavf_prototype.h"
12 * iavf_set_mac_type - Sets MAC type
13 * @hw: pointer to the HW structure
15 * This function sets the mac type of the adapter based on the
16 * vendor ID and device ID stored in the hw structure.
18 enum iavf_status iavf_set_mac_type(struct iavf_hw *hw)
20 enum iavf_status status = IAVF_SUCCESS;
22 DEBUGFUNC("iavf_set_mac_type\n");
24 if (hw->vendor_id == IAVF_INTEL_VENDOR_ID) {
25 switch (hw->device_id) {
26 /* TODO: remove undefined device ID now, need to think how to
27 * remove them in share code
29 case IAVF_DEV_ID_ADAPTIVE_VF:
30 hw->mac.type = IAVF_MAC_VF;
33 hw->mac.type = IAVF_MAC_GENERIC;
37 status = IAVF_ERR_DEVICE_NOT_SUPPORTED;
40 DEBUGOUT2("iavf_set_mac_type found mac: %d, returns: %d\n",
41 hw->mac.type, status);
46 * iavf_aq_str - convert AQ err code to a string
47 * @hw: pointer to the HW structure
48 * @aq_err: the AQ error code to convert
50 const char *iavf_aq_str(struct iavf_hw *hw, enum iavf_admin_queue_err aq_err)
55 case IAVF_AQ_RC_EPERM:
56 return "IAVF_AQ_RC_EPERM";
57 case IAVF_AQ_RC_ENOENT:
58 return "IAVF_AQ_RC_ENOENT";
59 case IAVF_AQ_RC_ESRCH:
60 return "IAVF_AQ_RC_ESRCH";
61 case IAVF_AQ_RC_EINTR:
62 return "IAVF_AQ_RC_EINTR";
64 return "IAVF_AQ_RC_EIO";
65 case IAVF_AQ_RC_ENXIO:
66 return "IAVF_AQ_RC_ENXIO";
67 case IAVF_AQ_RC_E2BIG:
68 return "IAVF_AQ_RC_E2BIG";
69 case IAVF_AQ_RC_EAGAIN:
70 return "IAVF_AQ_RC_EAGAIN";
71 case IAVF_AQ_RC_ENOMEM:
72 return "IAVF_AQ_RC_ENOMEM";
73 case IAVF_AQ_RC_EACCES:
74 return "IAVF_AQ_RC_EACCES";
75 case IAVF_AQ_RC_EFAULT:
76 return "IAVF_AQ_RC_EFAULT";
77 case IAVF_AQ_RC_EBUSY:
78 return "IAVF_AQ_RC_EBUSY";
79 case IAVF_AQ_RC_EEXIST:
80 return "IAVF_AQ_RC_EEXIST";
81 case IAVF_AQ_RC_EINVAL:
82 return "IAVF_AQ_RC_EINVAL";
83 case IAVF_AQ_RC_ENOTTY:
84 return "IAVF_AQ_RC_ENOTTY";
85 case IAVF_AQ_RC_ENOSPC:
86 return "IAVF_AQ_RC_ENOSPC";
87 case IAVF_AQ_RC_ENOSYS:
88 return "IAVF_AQ_RC_ENOSYS";
89 case IAVF_AQ_RC_ERANGE:
90 return "IAVF_AQ_RC_ERANGE";
91 case IAVF_AQ_RC_EFLUSHED:
92 return "IAVF_AQ_RC_EFLUSHED";
93 case IAVF_AQ_RC_BAD_ADDR:
94 return "IAVF_AQ_RC_BAD_ADDR";
95 case IAVF_AQ_RC_EMODE:
96 return "IAVF_AQ_RC_EMODE";
97 case IAVF_AQ_RC_EFBIG:
98 return "IAVF_AQ_RC_EFBIG";
101 snprintf(hw->err_str, sizeof(hw->err_str), "%d", aq_err);
106 * iavf_stat_str - convert status err code to a string
107 * @hw: pointer to the HW structure
108 * @stat_err: the status error code to convert
110 const char *iavf_stat_str(struct iavf_hw *hw, enum iavf_status stat_err)
116 return "IAVF_ERR_NVM";
117 case IAVF_ERR_NVM_CHECKSUM:
118 return "IAVF_ERR_NVM_CHECKSUM";
120 return "IAVF_ERR_PHY";
121 case IAVF_ERR_CONFIG:
122 return "IAVF_ERR_CONFIG";
124 return "IAVF_ERR_PARAM";
125 case IAVF_ERR_MAC_TYPE:
126 return "IAVF_ERR_MAC_TYPE";
127 case IAVF_ERR_UNKNOWN_PHY:
128 return "IAVF_ERR_UNKNOWN_PHY";
129 case IAVF_ERR_LINK_SETUP:
130 return "IAVF_ERR_LINK_SETUP";
131 case IAVF_ERR_ADAPTER_STOPPED:
132 return "IAVF_ERR_ADAPTER_STOPPED";
133 case IAVF_ERR_INVALID_MAC_ADDR:
134 return "IAVF_ERR_INVALID_MAC_ADDR";
135 case IAVF_ERR_DEVICE_NOT_SUPPORTED:
136 return "IAVF_ERR_DEVICE_NOT_SUPPORTED";
137 case IAVF_ERR_MASTER_REQUESTS_PENDING:
138 return "IAVF_ERR_MASTER_REQUESTS_PENDING";
139 case IAVF_ERR_INVALID_LINK_SETTINGS:
140 return "IAVF_ERR_INVALID_LINK_SETTINGS";
141 case IAVF_ERR_AUTONEG_NOT_COMPLETE:
142 return "IAVF_ERR_AUTONEG_NOT_COMPLETE";
143 case IAVF_ERR_RESET_FAILED:
144 return "IAVF_ERR_RESET_FAILED";
145 case IAVF_ERR_SWFW_SYNC:
146 return "IAVF_ERR_SWFW_SYNC";
147 case IAVF_ERR_NO_AVAILABLE_VSI:
148 return "IAVF_ERR_NO_AVAILABLE_VSI";
149 case IAVF_ERR_NO_MEMORY:
150 return "IAVF_ERR_NO_MEMORY";
151 case IAVF_ERR_BAD_PTR:
152 return "IAVF_ERR_BAD_PTR";
153 case IAVF_ERR_RING_FULL:
154 return "IAVF_ERR_RING_FULL";
155 case IAVF_ERR_INVALID_PD_ID:
156 return "IAVF_ERR_INVALID_PD_ID";
157 case IAVF_ERR_INVALID_QP_ID:
158 return "IAVF_ERR_INVALID_QP_ID";
159 case IAVF_ERR_INVALID_CQ_ID:
160 return "IAVF_ERR_INVALID_CQ_ID";
161 case IAVF_ERR_INVALID_CEQ_ID:
162 return "IAVF_ERR_INVALID_CEQ_ID";
163 case IAVF_ERR_INVALID_AEQ_ID:
164 return "IAVF_ERR_INVALID_AEQ_ID";
165 case IAVF_ERR_INVALID_SIZE:
166 return "IAVF_ERR_INVALID_SIZE";
167 case IAVF_ERR_INVALID_ARP_INDEX:
168 return "IAVF_ERR_INVALID_ARP_INDEX";
169 case IAVF_ERR_INVALID_FPM_FUNC_ID:
170 return "IAVF_ERR_INVALID_FPM_FUNC_ID";
171 case IAVF_ERR_QP_INVALID_MSG_SIZE:
172 return "IAVF_ERR_QP_INVALID_MSG_SIZE";
173 case IAVF_ERR_QP_TOOMANY_WRS_POSTED:
174 return "IAVF_ERR_QP_TOOMANY_WRS_POSTED";
175 case IAVF_ERR_INVALID_FRAG_COUNT:
176 return "IAVF_ERR_INVALID_FRAG_COUNT";
177 case IAVF_ERR_QUEUE_EMPTY:
178 return "IAVF_ERR_QUEUE_EMPTY";
179 case IAVF_ERR_INVALID_ALIGNMENT:
180 return "IAVF_ERR_INVALID_ALIGNMENT";
181 case IAVF_ERR_FLUSHED_QUEUE:
182 return "IAVF_ERR_FLUSHED_QUEUE";
183 case IAVF_ERR_INVALID_PUSH_PAGE_INDEX:
184 return "IAVF_ERR_INVALID_PUSH_PAGE_INDEX";
185 case IAVF_ERR_INVALID_IMM_DATA_SIZE:
186 return "IAVF_ERR_INVALID_IMM_DATA_SIZE";
187 case IAVF_ERR_TIMEOUT:
188 return "IAVF_ERR_TIMEOUT";
189 case IAVF_ERR_OPCODE_MISMATCH:
190 return "IAVF_ERR_OPCODE_MISMATCH";
191 case IAVF_ERR_CQP_COMPL_ERROR:
192 return "IAVF_ERR_CQP_COMPL_ERROR";
193 case IAVF_ERR_INVALID_VF_ID:
194 return "IAVF_ERR_INVALID_VF_ID";
195 case IAVF_ERR_INVALID_HMCFN_ID:
196 return "IAVF_ERR_INVALID_HMCFN_ID";
197 case IAVF_ERR_BACKING_PAGE_ERROR:
198 return "IAVF_ERR_BACKING_PAGE_ERROR";
199 case IAVF_ERR_NO_PBLCHUNKS_AVAILABLE:
200 return "IAVF_ERR_NO_PBLCHUNKS_AVAILABLE";
201 case IAVF_ERR_INVALID_PBLE_INDEX:
202 return "IAVF_ERR_INVALID_PBLE_INDEX";
203 case IAVF_ERR_INVALID_SD_INDEX:
204 return "IAVF_ERR_INVALID_SD_INDEX";
205 case IAVF_ERR_INVALID_PAGE_DESC_INDEX:
206 return "IAVF_ERR_INVALID_PAGE_DESC_INDEX";
207 case IAVF_ERR_INVALID_SD_TYPE:
208 return "IAVF_ERR_INVALID_SD_TYPE";
209 case IAVF_ERR_MEMCPY_FAILED:
210 return "IAVF_ERR_MEMCPY_FAILED";
211 case IAVF_ERR_INVALID_HMC_OBJ_INDEX:
212 return "IAVF_ERR_INVALID_HMC_OBJ_INDEX";
213 case IAVF_ERR_INVALID_HMC_OBJ_COUNT:
214 return "IAVF_ERR_INVALID_HMC_OBJ_COUNT";
215 case IAVF_ERR_INVALID_SRQ_ARM_LIMIT:
216 return "IAVF_ERR_INVALID_SRQ_ARM_LIMIT";
217 case IAVF_ERR_SRQ_ENABLED:
218 return "IAVF_ERR_SRQ_ENABLED";
219 case IAVF_ERR_ADMIN_QUEUE_ERROR:
220 return "IAVF_ERR_ADMIN_QUEUE_ERROR";
221 case IAVF_ERR_ADMIN_QUEUE_TIMEOUT:
222 return "IAVF_ERR_ADMIN_QUEUE_TIMEOUT";
223 case IAVF_ERR_BUF_TOO_SHORT:
224 return "IAVF_ERR_BUF_TOO_SHORT";
225 case IAVF_ERR_ADMIN_QUEUE_FULL:
226 return "IAVF_ERR_ADMIN_QUEUE_FULL";
227 case IAVF_ERR_ADMIN_QUEUE_NO_WORK:
228 return "IAVF_ERR_ADMIN_QUEUE_NO_WORK";
229 case IAVF_ERR_BAD_IWARP_CQE:
230 return "IAVF_ERR_BAD_IWARP_CQE";
231 case IAVF_ERR_NVM_BLANK_MODE:
232 return "IAVF_ERR_NVM_BLANK_MODE";
233 case IAVF_ERR_NOT_IMPLEMENTED:
234 return "IAVF_ERR_NOT_IMPLEMENTED";
235 case IAVF_ERR_PE_DOORBELL_NOT_ENABLED:
236 return "IAVF_ERR_PE_DOORBELL_NOT_ENABLED";
237 case IAVF_ERR_DIAG_TEST_FAILED:
238 return "IAVF_ERR_DIAG_TEST_FAILED";
239 case IAVF_ERR_NOT_READY:
240 return "IAVF_ERR_NOT_READY";
241 case IAVF_NOT_SUPPORTED:
242 return "IAVF_NOT_SUPPORTED";
243 case IAVF_ERR_FIRMWARE_API_VERSION:
244 return "IAVF_ERR_FIRMWARE_API_VERSION";
245 case IAVF_ERR_ADMIN_QUEUE_CRITICAL_ERROR:
246 return "IAVF_ERR_ADMIN_QUEUE_CRITICAL_ERROR";
249 snprintf(hw->err_str, sizeof(hw->err_str), "%d", stat_err);
255 * @hw: debug mask related to admin queue
257 * @desc: pointer to admin queue descriptor
258 * @buffer: pointer to command buffer
259 * @buf_len: max length of buffer
261 * Dumps debug log about adminq command with descriptor contents.
263 void iavf_debug_aq(struct iavf_hw *hw, enum iavf_debug_mask mask, void *desc,
264 void *buffer, u16 buf_len)
266 struct iavf_aq_desc *aq_desc = (struct iavf_aq_desc *)desc;
267 u8 *buf = (u8 *)buffer;
271 if ((!(mask & hw->debug_mask)) || (desc == NULL))
274 len = LE16_TO_CPU(aq_desc->datalen);
277 "AQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n",
278 LE16_TO_CPU(aq_desc->opcode),
279 LE16_TO_CPU(aq_desc->flags),
280 LE16_TO_CPU(aq_desc->datalen),
281 LE16_TO_CPU(aq_desc->retval));
282 iavf_debug(hw, mask, "\tcookie (h,l) 0x%08X 0x%08X\n",
283 LE32_TO_CPU(aq_desc->cookie_high),
284 LE32_TO_CPU(aq_desc->cookie_low));
285 iavf_debug(hw, mask, "\tparam (0,1) 0x%08X 0x%08X\n",
286 LE32_TO_CPU(aq_desc->params.internal.param0),
287 LE32_TO_CPU(aq_desc->params.internal.param1));
288 iavf_debug(hw, mask, "\taddr (h,l) 0x%08X 0x%08X\n",
289 LE32_TO_CPU(aq_desc->params.external.addr_high),
290 LE32_TO_CPU(aq_desc->params.external.addr_low));
292 if ((buffer != NULL) && (aq_desc->datalen != 0)) {
293 iavf_debug(hw, mask, "AQ CMD Buffer:\n");
296 /* write the full 16-byte chunks */
297 for (i = 0; i < (len - 16); i += 16)
299 "\t0x%04X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n",
300 i, buf[i], buf[i+1], buf[i+2], buf[i+3],
301 buf[i+4], buf[i+5], buf[i+6], buf[i+7],
302 buf[i+8], buf[i+9], buf[i+10], buf[i+11],
303 buf[i+12], buf[i+13], buf[i+14], buf[i+15]);
304 /* the most we could have left is 16 bytes, pad with zeros */
310 memset(d_buf, 0, sizeof(d_buf));
311 for (j = 0; i < len; j++, i++)
314 "\t0x%04X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n",
315 i_sav, d_buf[0], d_buf[1], d_buf[2], d_buf[3],
316 d_buf[4], d_buf[5], d_buf[6], d_buf[7],
317 d_buf[8], d_buf[9], d_buf[10], d_buf[11],
318 d_buf[12], d_buf[13], d_buf[14], d_buf[15]);
324 * iavf_check_asq_alive
325 * @hw: pointer to the hw struct
327 * Returns true if Queue is enabled else false.
329 bool iavf_check_asq_alive(struct iavf_hw *hw)
334 return !!(rd32(hw, hw->aq.asq.len) &
335 IAVF_VF_ATQLEN1_ATQENABLE_MASK);
337 return !!(rd32(hw, hw->aq.asq.len) &
338 IAVF_VF_ATQLEN1_ATQENABLE_MASK);
339 #endif /* INTEGRATED_VF */
344 * iavf_aq_queue_shutdown
345 * @hw: pointer to the hw struct
346 * @unloading: is the driver unloading itself
348 * Tell the Firmware that we're shutting down the AdminQ and whether
349 * or not the driver is unloading as well.
351 enum iavf_status iavf_aq_queue_shutdown(struct iavf_hw *hw,
354 struct iavf_aq_desc desc;
355 struct iavf_aqc_queue_shutdown *cmd =
356 (struct iavf_aqc_queue_shutdown *)&desc.params.raw;
357 enum iavf_status status;
359 iavf_fill_default_direct_cmd_desc(&desc,
360 iavf_aqc_opc_queue_shutdown);
363 cmd->driver_unloading = CPU_TO_LE32(IAVF_AQ_DRIVER_UNLOADING);
364 status = iavf_asq_send_command(hw, &desc, NULL, 0, NULL);
370 * iavf_aq_get_set_rss_lut
371 * @hw: pointer to the hardware structure
372 * @vsi_id: vsi fw index
373 * @pf_lut: for PF table set true, for VSI table set false
374 * @lut: pointer to the lut buffer provided by the caller
375 * @lut_size: size of the lut buffer
376 * @set: set true to set the table, false to get the table
378 * Internal function to get or set RSS look up table
380 STATIC enum iavf_status iavf_aq_get_set_rss_lut(struct iavf_hw *hw,
381 u16 vsi_id, bool pf_lut,
382 u8 *lut, u16 lut_size,
385 enum iavf_status status;
386 struct iavf_aq_desc desc;
387 struct iavf_aqc_get_set_rss_lut *cmd_resp =
388 (struct iavf_aqc_get_set_rss_lut *)&desc.params.raw;
391 iavf_fill_default_direct_cmd_desc(&desc,
392 iavf_aqc_opc_set_rss_lut);
394 iavf_fill_default_direct_cmd_desc(&desc,
395 iavf_aqc_opc_get_rss_lut);
397 /* Indirect command */
398 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_BUF);
399 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_RD);
402 CPU_TO_LE16((u16)((vsi_id <<
403 IAVF_AQC_SET_RSS_LUT_VSI_ID_SHIFT) &
404 IAVF_AQC_SET_RSS_LUT_VSI_ID_MASK));
405 cmd_resp->vsi_id |= CPU_TO_LE16((u16)IAVF_AQC_SET_RSS_LUT_VSI_VALID);
408 cmd_resp->flags |= CPU_TO_LE16((u16)
409 ((IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_PF <<
410 IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) &
411 IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_MASK));
413 cmd_resp->flags |= CPU_TO_LE16((u16)
414 ((IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_VSI <<
415 IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) &
416 IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_MASK));
418 status = iavf_asq_send_command(hw, &desc, lut, lut_size, NULL);
424 * iavf_aq_get_rss_lut
425 * @hw: pointer to the hardware structure
426 * @vsi_id: vsi fw index
427 * @pf_lut: for PF table set true, for VSI table set false
428 * @lut: pointer to the lut buffer provided by the caller
429 * @lut_size: size of the lut buffer
431 * get the RSS lookup table, PF or VSI type
433 enum iavf_status iavf_aq_get_rss_lut(struct iavf_hw *hw, u16 vsi_id,
434 bool pf_lut, u8 *lut, u16 lut_size)
436 return iavf_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size,
441 * iavf_aq_set_rss_lut
442 * @hw: pointer to the hardware structure
443 * @vsi_id: vsi fw index
444 * @pf_lut: for PF table set true, for VSI table set false
445 * @lut: pointer to the lut buffer provided by the caller
446 * @lut_size: size of the lut buffer
448 * set the RSS lookup table, PF or VSI type
450 enum iavf_status iavf_aq_set_rss_lut(struct iavf_hw *hw, u16 vsi_id,
451 bool pf_lut, u8 *lut, u16 lut_size)
453 return iavf_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size, true);
457 * iavf_aq_get_set_rss_key
458 * @hw: pointer to the hw struct
459 * @vsi_id: vsi fw index
460 * @key: pointer to key info struct
461 * @set: set true to set the key, false to get the key
463 * get the RSS key per VSI
465 STATIC enum iavf_status iavf_aq_get_set_rss_key(struct iavf_hw *hw,
467 struct iavf_aqc_get_set_rss_key_data *key,
470 enum iavf_status status;
471 struct iavf_aq_desc desc;
472 struct iavf_aqc_get_set_rss_key *cmd_resp =
473 (struct iavf_aqc_get_set_rss_key *)&desc.params.raw;
474 u16 key_size = sizeof(struct iavf_aqc_get_set_rss_key_data);
477 iavf_fill_default_direct_cmd_desc(&desc,
478 iavf_aqc_opc_set_rss_key);
480 iavf_fill_default_direct_cmd_desc(&desc,
481 iavf_aqc_opc_get_rss_key);
483 /* Indirect command */
484 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_BUF);
485 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_RD);
488 CPU_TO_LE16((u16)((vsi_id <<
489 IAVF_AQC_SET_RSS_KEY_VSI_ID_SHIFT) &
490 IAVF_AQC_SET_RSS_KEY_VSI_ID_MASK));
491 cmd_resp->vsi_id |= CPU_TO_LE16((u16)IAVF_AQC_SET_RSS_KEY_VSI_VALID);
493 status = iavf_asq_send_command(hw, &desc, key, key_size, NULL);
499 * iavf_aq_get_rss_key
500 * @hw: pointer to the hw struct
501 * @vsi_id: vsi fw index
502 * @key: pointer to key info struct
505 enum iavf_status iavf_aq_get_rss_key(struct iavf_hw *hw,
507 struct iavf_aqc_get_set_rss_key_data *key)
509 return iavf_aq_get_set_rss_key(hw, vsi_id, key, false);
513 * iavf_aq_set_rss_key
514 * @hw: pointer to the hw struct
515 * @vsi_id: vsi fw index
516 * @key: pointer to key info struct
518 * set the RSS key per VSI
520 enum iavf_status iavf_aq_set_rss_key(struct iavf_hw *hw,
522 struct iavf_aqc_get_set_rss_key_data *key)
524 return iavf_aq_get_set_rss_key(hw, vsi_id, key, true);
527 /* The iavf_ptype_lookup table is used to convert from the 8-bit ptype in the
528 * hardware to a bit-field that can be used by SW to more easily determine the
531 * Macros are used to shorten the table lines and make this table human
534 * We store the PTYPE in the top byte of the bit field - this is just so that
535 * we can check that the table doesn't have a row missing, as the index into
536 * the table should be the PTYPE.
540 * IF NOT iavf_ptype_lookup[ptype].known
543 * ELSE IF iavf_ptype_lookup[ptype].outer_ip == IAVF_RX_PTYPE_OUTER_IP
544 * Use the rest of the fields to look at the tunnels, inner protocols, etc
546 * Use the enum iavf_rx_l2_ptype to decode the packet type
550 /* macro to make the table lines short */
551 #define IAVF_PTT(PTYPE, OUTER_IP, OUTER_IP_VER, OUTER_FRAG, T, TE, TEF, I, PL)\
554 IAVF_RX_PTYPE_OUTER_##OUTER_IP, \
555 IAVF_RX_PTYPE_OUTER_##OUTER_IP_VER, \
556 IAVF_RX_PTYPE_##OUTER_FRAG, \
557 IAVF_RX_PTYPE_TUNNEL_##T, \
558 IAVF_RX_PTYPE_TUNNEL_END_##TE, \
559 IAVF_RX_PTYPE_##TEF, \
560 IAVF_RX_PTYPE_INNER_PROT_##I, \
561 IAVF_RX_PTYPE_PAYLOAD_LAYER_##PL }
563 #define IAVF_PTT_UNUSED_ENTRY(PTYPE) \
564 { PTYPE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
566 /* shorter macros makes the table fit but are terse */
567 #define IAVF_RX_PTYPE_NOF IAVF_RX_PTYPE_NOT_FRAG
568 #define IAVF_RX_PTYPE_FRG IAVF_RX_PTYPE_FRAG
569 #define IAVF_RX_PTYPE_INNER_PROT_TS IAVF_RX_PTYPE_INNER_PROT_TIMESYNC
571 /* Lookup table mapping the HW PTYPE to the bit field for decoding */
572 struct iavf_rx_ptype_decoded iavf_ptype_lookup[] = {
573 /* L2 Packet types */
574 IAVF_PTT_UNUSED_ENTRY(0),
575 IAVF_PTT(1, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
576 IAVF_PTT(2, L2, NONE, NOF, NONE, NONE, NOF, TS, PAY2),
577 IAVF_PTT(3, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
578 IAVF_PTT_UNUSED_ENTRY(4),
579 IAVF_PTT_UNUSED_ENTRY(5),
580 IAVF_PTT(6, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
581 IAVF_PTT(7, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
582 IAVF_PTT_UNUSED_ENTRY(8),
583 IAVF_PTT_UNUSED_ENTRY(9),
584 IAVF_PTT(10, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
585 IAVF_PTT(11, L2, NONE, NOF, NONE, NONE, NOF, NONE, NONE),
586 IAVF_PTT(12, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
587 IAVF_PTT(13, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
588 IAVF_PTT(14, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
589 IAVF_PTT(15, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
590 IAVF_PTT(16, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
591 IAVF_PTT(17, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
592 IAVF_PTT(18, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
593 IAVF_PTT(19, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
594 IAVF_PTT(20, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
595 IAVF_PTT(21, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
597 /* Non Tunneled IPv4 */
598 IAVF_PTT(22, IP, IPV4, FRG, NONE, NONE, NOF, NONE, PAY3),
599 IAVF_PTT(23, IP, IPV4, NOF, NONE, NONE, NOF, NONE, PAY3),
600 IAVF_PTT(24, IP, IPV4, NOF, NONE, NONE, NOF, UDP, PAY4),
601 IAVF_PTT_UNUSED_ENTRY(25),
602 IAVF_PTT(26, IP, IPV4, NOF, NONE, NONE, NOF, TCP, PAY4),
603 IAVF_PTT(27, IP, IPV4, NOF, NONE, NONE, NOF, SCTP, PAY4),
604 IAVF_PTT(28, IP, IPV4, NOF, NONE, NONE, NOF, ICMP, PAY4),
607 IAVF_PTT(29, IP, IPV4, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
608 IAVF_PTT(30, IP, IPV4, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
609 IAVF_PTT(31, IP, IPV4, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
610 IAVF_PTT_UNUSED_ENTRY(32),
611 IAVF_PTT(33, IP, IPV4, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
612 IAVF_PTT(34, IP, IPV4, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
613 IAVF_PTT(35, IP, IPV4, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
616 IAVF_PTT(36, IP, IPV4, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
617 IAVF_PTT(37, IP, IPV4, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
618 IAVF_PTT(38, IP, IPV4, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
619 IAVF_PTT_UNUSED_ENTRY(39),
620 IAVF_PTT(40, IP, IPV4, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
621 IAVF_PTT(41, IP, IPV4, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
622 IAVF_PTT(42, IP, IPV4, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
624 /* IPv4 --> GRE/NAT */
625 IAVF_PTT(43, IP, IPV4, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
627 /* IPv4 --> GRE/NAT --> IPv4 */
628 IAVF_PTT(44, IP, IPV4, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
629 IAVF_PTT(45, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
630 IAVF_PTT(46, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
631 IAVF_PTT_UNUSED_ENTRY(47),
632 IAVF_PTT(48, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
633 IAVF_PTT(49, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
634 IAVF_PTT(50, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
636 /* IPv4 --> GRE/NAT --> IPv6 */
637 IAVF_PTT(51, IP, IPV4, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
638 IAVF_PTT(52, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
639 IAVF_PTT(53, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
640 IAVF_PTT_UNUSED_ENTRY(54),
641 IAVF_PTT(55, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
642 IAVF_PTT(56, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
643 IAVF_PTT(57, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
645 /* IPv4 --> GRE/NAT --> MAC */
646 IAVF_PTT(58, IP, IPV4, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
648 /* IPv4 --> GRE/NAT --> MAC --> IPv4 */
649 IAVF_PTT(59, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
650 IAVF_PTT(60, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
651 IAVF_PTT(61, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
652 IAVF_PTT_UNUSED_ENTRY(62),
653 IAVF_PTT(63, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
654 IAVF_PTT(64, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
655 IAVF_PTT(65, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
657 /* IPv4 --> GRE/NAT -> MAC --> IPv6 */
658 IAVF_PTT(66, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
659 IAVF_PTT(67, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
660 IAVF_PTT(68, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
661 IAVF_PTT_UNUSED_ENTRY(69),
662 IAVF_PTT(70, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
663 IAVF_PTT(71, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
664 IAVF_PTT(72, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
666 /* IPv4 --> GRE/NAT --> MAC/VLAN */
667 IAVF_PTT(73, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
669 /* IPv4 ---> GRE/NAT -> MAC/VLAN --> IPv4 */
670 IAVF_PTT(74, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
671 IAVF_PTT(75, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
672 IAVF_PTT(76, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
673 IAVF_PTT_UNUSED_ENTRY(77),
674 IAVF_PTT(78, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
675 IAVF_PTT(79, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
676 IAVF_PTT(80, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
678 /* IPv4 -> GRE/NAT -> MAC/VLAN --> IPv6 */
679 IAVF_PTT(81, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
680 IAVF_PTT(82, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
681 IAVF_PTT(83, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
682 IAVF_PTT_UNUSED_ENTRY(84),
683 IAVF_PTT(85, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
684 IAVF_PTT(86, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
685 IAVF_PTT(87, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
687 /* Non Tunneled IPv6 */
688 IAVF_PTT(88, IP, IPV6, FRG, NONE, NONE, NOF, NONE, PAY3),
689 IAVF_PTT(89, IP, IPV6, NOF, NONE, NONE, NOF, NONE, PAY3),
690 IAVF_PTT(90, IP, IPV6, NOF, NONE, NONE, NOF, UDP, PAY4),
691 IAVF_PTT_UNUSED_ENTRY(91),
692 IAVF_PTT(92, IP, IPV6, NOF, NONE, NONE, NOF, TCP, PAY4),
693 IAVF_PTT(93, IP, IPV6, NOF, NONE, NONE, NOF, SCTP, PAY4),
694 IAVF_PTT(94, IP, IPV6, NOF, NONE, NONE, NOF, ICMP, PAY4),
697 IAVF_PTT(95, IP, IPV6, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
698 IAVF_PTT(96, IP, IPV6, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
699 IAVF_PTT(97, IP, IPV6, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
700 IAVF_PTT_UNUSED_ENTRY(98),
701 IAVF_PTT(99, IP, IPV6, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
702 IAVF_PTT(100, IP, IPV6, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
703 IAVF_PTT(101, IP, IPV6, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
706 IAVF_PTT(102, IP, IPV6, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
707 IAVF_PTT(103, IP, IPV6, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
708 IAVF_PTT(104, IP, IPV6, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
709 IAVF_PTT_UNUSED_ENTRY(105),
710 IAVF_PTT(106, IP, IPV6, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
711 IAVF_PTT(107, IP, IPV6, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
712 IAVF_PTT(108, IP, IPV6, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
714 /* IPv6 --> GRE/NAT */
715 IAVF_PTT(109, IP, IPV6, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
717 /* IPv6 --> GRE/NAT -> IPv4 */
718 IAVF_PTT(110, IP, IPV6, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
719 IAVF_PTT(111, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
720 IAVF_PTT(112, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
721 IAVF_PTT_UNUSED_ENTRY(113),
722 IAVF_PTT(114, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
723 IAVF_PTT(115, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
724 IAVF_PTT(116, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
726 /* IPv6 --> GRE/NAT -> IPv6 */
727 IAVF_PTT(117, IP, IPV6, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
728 IAVF_PTT(118, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
729 IAVF_PTT(119, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
730 IAVF_PTT_UNUSED_ENTRY(120),
731 IAVF_PTT(121, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
732 IAVF_PTT(122, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
733 IAVF_PTT(123, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
735 /* IPv6 --> GRE/NAT -> MAC */
736 IAVF_PTT(124, IP, IPV6, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
738 /* IPv6 --> GRE/NAT -> MAC -> IPv4 */
739 IAVF_PTT(125, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
740 IAVF_PTT(126, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
741 IAVF_PTT(127, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
742 IAVF_PTT_UNUSED_ENTRY(128),
743 IAVF_PTT(129, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
744 IAVF_PTT(130, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
745 IAVF_PTT(131, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
747 /* IPv6 --> GRE/NAT -> MAC -> IPv6 */
748 IAVF_PTT(132, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
749 IAVF_PTT(133, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
750 IAVF_PTT(134, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
751 IAVF_PTT_UNUSED_ENTRY(135),
752 IAVF_PTT(136, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
753 IAVF_PTT(137, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
754 IAVF_PTT(138, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
756 /* IPv6 --> GRE/NAT -> MAC/VLAN */
757 IAVF_PTT(139, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
759 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv4 */
760 IAVF_PTT(140, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
761 IAVF_PTT(141, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
762 IAVF_PTT(142, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
763 IAVF_PTT_UNUSED_ENTRY(143),
764 IAVF_PTT(144, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
765 IAVF_PTT(145, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
766 IAVF_PTT(146, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
768 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv6 */
769 IAVF_PTT(147, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
770 IAVF_PTT(148, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
771 IAVF_PTT(149, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
772 IAVF_PTT_UNUSED_ENTRY(150),
773 IAVF_PTT(151, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
774 IAVF_PTT(152, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
775 IAVF_PTT(153, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
778 IAVF_PTT_UNUSED_ENTRY(154),
779 IAVF_PTT_UNUSED_ENTRY(155),
780 IAVF_PTT_UNUSED_ENTRY(156),
781 IAVF_PTT_UNUSED_ENTRY(157),
782 IAVF_PTT_UNUSED_ENTRY(158),
783 IAVF_PTT_UNUSED_ENTRY(159),
785 IAVF_PTT_UNUSED_ENTRY(160),
786 IAVF_PTT_UNUSED_ENTRY(161),
787 IAVF_PTT_UNUSED_ENTRY(162),
788 IAVF_PTT_UNUSED_ENTRY(163),
789 IAVF_PTT_UNUSED_ENTRY(164),
790 IAVF_PTT_UNUSED_ENTRY(165),
791 IAVF_PTT_UNUSED_ENTRY(166),
792 IAVF_PTT_UNUSED_ENTRY(167),
793 IAVF_PTT_UNUSED_ENTRY(168),
794 IAVF_PTT_UNUSED_ENTRY(169),
796 IAVF_PTT_UNUSED_ENTRY(170),
797 IAVF_PTT_UNUSED_ENTRY(171),
798 IAVF_PTT_UNUSED_ENTRY(172),
799 IAVF_PTT_UNUSED_ENTRY(173),
800 IAVF_PTT_UNUSED_ENTRY(174),
801 IAVF_PTT_UNUSED_ENTRY(175),
802 IAVF_PTT_UNUSED_ENTRY(176),
803 IAVF_PTT_UNUSED_ENTRY(177),
804 IAVF_PTT_UNUSED_ENTRY(178),
805 IAVF_PTT_UNUSED_ENTRY(179),
807 IAVF_PTT_UNUSED_ENTRY(180),
808 IAVF_PTT_UNUSED_ENTRY(181),
809 IAVF_PTT_UNUSED_ENTRY(182),
810 IAVF_PTT_UNUSED_ENTRY(183),
811 IAVF_PTT_UNUSED_ENTRY(184),
812 IAVF_PTT_UNUSED_ENTRY(185),
813 IAVF_PTT_UNUSED_ENTRY(186),
814 IAVF_PTT_UNUSED_ENTRY(187),
815 IAVF_PTT_UNUSED_ENTRY(188),
816 IAVF_PTT_UNUSED_ENTRY(189),
818 IAVF_PTT_UNUSED_ENTRY(190),
819 IAVF_PTT_UNUSED_ENTRY(191),
820 IAVF_PTT_UNUSED_ENTRY(192),
821 IAVF_PTT_UNUSED_ENTRY(193),
822 IAVF_PTT_UNUSED_ENTRY(194),
823 IAVF_PTT_UNUSED_ENTRY(195),
824 IAVF_PTT_UNUSED_ENTRY(196),
825 IAVF_PTT_UNUSED_ENTRY(197),
826 IAVF_PTT_UNUSED_ENTRY(198),
827 IAVF_PTT_UNUSED_ENTRY(199),
829 IAVF_PTT_UNUSED_ENTRY(200),
830 IAVF_PTT_UNUSED_ENTRY(201),
831 IAVF_PTT_UNUSED_ENTRY(202),
832 IAVF_PTT_UNUSED_ENTRY(203),
833 IAVF_PTT_UNUSED_ENTRY(204),
834 IAVF_PTT_UNUSED_ENTRY(205),
835 IAVF_PTT_UNUSED_ENTRY(206),
836 IAVF_PTT_UNUSED_ENTRY(207),
837 IAVF_PTT_UNUSED_ENTRY(208),
838 IAVF_PTT_UNUSED_ENTRY(209),
840 IAVF_PTT_UNUSED_ENTRY(210),
841 IAVF_PTT_UNUSED_ENTRY(211),
842 IAVF_PTT_UNUSED_ENTRY(212),
843 IAVF_PTT_UNUSED_ENTRY(213),
844 IAVF_PTT_UNUSED_ENTRY(214),
845 IAVF_PTT_UNUSED_ENTRY(215),
846 IAVF_PTT_UNUSED_ENTRY(216),
847 IAVF_PTT_UNUSED_ENTRY(217),
848 IAVF_PTT_UNUSED_ENTRY(218),
849 IAVF_PTT_UNUSED_ENTRY(219),
851 IAVF_PTT_UNUSED_ENTRY(220),
852 IAVF_PTT_UNUSED_ENTRY(221),
853 IAVF_PTT_UNUSED_ENTRY(222),
854 IAVF_PTT_UNUSED_ENTRY(223),
855 IAVF_PTT_UNUSED_ENTRY(224),
856 IAVF_PTT_UNUSED_ENTRY(225),
857 IAVF_PTT_UNUSED_ENTRY(226),
858 IAVF_PTT_UNUSED_ENTRY(227),
859 IAVF_PTT_UNUSED_ENTRY(228),
860 IAVF_PTT_UNUSED_ENTRY(229),
862 IAVF_PTT_UNUSED_ENTRY(230),
863 IAVF_PTT_UNUSED_ENTRY(231),
864 IAVF_PTT_UNUSED_ENTRY(232),
865 IAVF_PTT_UNUSED_ENTRY(233),
866 IAVF_PTT_UNUSED_ENTRY(234),
867 IAVF_PTT_UNUSED_ENTRY(235),
868 IAVF_PTT_UNUSED_ENTRY(236),
869 IAVF_PTT_UNUSED_ENTRY(237),
870 IAVF_PTT_UNUSED_ENTRY(238),
871 IAVF_PTT_UNUSED_ENTRY(239),
873 IAVF_PTT_UNUSED_ENTRY(240),
874 IAVF_PTT_UNUSED_ENTRY(241),
875 IAVF_PTT_UNUSED_ENTRY(242),
876 IAVF_PTT_UNUSED_ENTRY(243),
877 IAVF_PTT_UNUSED_ENTRY(244),
878 IAVF_PTT_UNUSED_ENTRY(245),
879 IAVF_PTT_UNUSED_ENTRY(246),
880 IAVF_PTT_UNUSED_ENTRY(247),
881 IAVF_PTT_UNUSED_ENTRY(248),
882 IAVF_PTT_UNUSED_ENTRY(249),
884 IAVF_PTT_UNUSED_ENTRY(250),
885 IAVF_PTT_UNUSED_ENTRY(251),
886 IAVF_PTT_UNUSED_ENTRY(252),
887 IAVF_PTT_UNUSED_ENTRY(253),
888 IAVF_PTT_UNUSED_ENTRY(254),
889 IAVF_PTT_UNUSED_ENTRY(255)
894 * iavf_validate_mac_addr - Validate unicast MAC address
895 * @mac_addr: pointer to MAC address
897 * Tests a MAC address to ensure it is a valid Individual Address
899 enum iavf_status iavf_validate_mac_addr(u8 *mac_addr)
901 enum iavf_status status = IAVF_SUCCESS;
903 DEBUGFUNC("iavf_validate_mac_addr");
905 /* Broadcast addresses ARE multicast addresses
906 * Make sure it is not a multicast address
907 * Reject the zero address
909 if (IAVF_IS_MULTICAST(mac_addr) ||
910 (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&
911 mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0))
912 status = IAVF_ERR_INVALID_MAC_ADDR;
918 * iavf_aq_rx_ctl_read_register - use FW to read from an Rx control register
919 * @hw: pointer to the hw struct
920 * @reg_addr: register address
921 * @reg_val: ptr to register value
922 * @cmd_details: pointer to command details structure or NULL
924 * Use the firmware to read the Rx control register,
925 * especially useful if the Rx unit is under heavy pressure
927 enum iavf_status iavf_aq_rx_ctl_read_register(struct iavf_hw *hw,
928 u32 reg_addr, u32 *reg_val,
929 struct iavf_asq_cmd_details *cmd_details)
931 struct iavf_aq_desc desc;
932 struct iavf_aqc_rx_ctl_reg_read_write *cmd_resp =
933 (struct iavf_aqc_rx_ctl_reg_read_write *)&desc.params.raw;
934 enum iavf_status status;
937 return IAVF_ERR_PARAM;
939 iavf_fill_default_direct_cmd_desc(&desc, iavf_aqc_opc_rx_ctl_reg_read);
941 cmd_resp->address = CPU_TO_LE32(reg_addr);
943 status = iavf_asq_send_command(hw, &desc, NULL, 0, cmd_details);
945 if (status == IAVF_SUCCESS)
946 *reg_val = LE32_TO_CPU(cmd_resp->value);
952 * iavf_read_rx_ctl - read from an Rx control register
953 * @hw: pointer to the hw struct
954 * @reg_addr: register address
956 u32 iavf_read_rx_ctl(struct iavf_hw *hw, u32 reg_addr)
958 enum iavf_status status = IAVF_SUCCESS;
963 use_register = (((hw->aq.api_maj_ver == 1) &&
964 (hw->aq.api_min_ver < 5)) ||
965 (hw->mac.type == IAVF_MAC_X722));
968 status = iavf_aq_rx_ctl_read_register(hw, reg_addr, &val, NULL);
969 if (hw->aq.asq_last_status == IAVF_AQ_RC_EAGAIN && retry) {
976 /* if the AQ access failed, try the old-fashioned way */
977 if (status || use_register)
978 val = rd32(hw, reg_addr);
984 * iavf_aq_rx_ctl_write_register
985 * @hw: pointer to the hw struct
986 * @reg_addr: register address
987 * @reg_val: register value
988 * @cmd_details: pointer to command details structure or NULL
990 * Use the firmware to write to an Rx control register,
991 * especially useful if the Rx unit is under heavy pressure
993 enum iavf_status iavf_aq_rx_ctl_write_register(struct iavf_hw *hw,
994 u32 reg_addr, u32 reg_val,
995 struct iavf_asq_cmd_details *cmd_details)
997 struct iavf_aq_desc desc;
998 struct iavf_aqc_rx_ctl_reg_read_write *cmd =
999 (struct iavf_aqc_rx_ctl_reg_read_write *)&desc.params.raw;
1000 enum iavf_status status;
1002 iavf_fill_default_direct_cmd_desc(&desc, iavf_aqc_opc_rx_ctl_reg_write);
1004 cmd->address = CPU_TO_LE32(reg_addr);
1005 cmd->value = CPU_TO_LE32(reg_val);
1007 status = iavf_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1013 * iavf_write_rx_ctl - write to an Rx control register
1014 * @hw: pointer to the hw struct
1015 * @reg_addr: register address
1016 * @reg_val: register value
1018 void iavf_write_rx_ctl(struct iavf_hw *hw, u32 reg_addr, u32 reg_val)
1020 enum iavf_status status = IAVF_SUCCESS;
1024 use_register = (((hw->aq.api_maj_ver == 1) &&
1025 (hw->aq.api_min_ver < 5)) ||
1026 (hw->mac.type == IAVF_MAC_X722));
1027 if (!use_register) {
1029 status = iavf_aq_rx_ctl_write_register(hw, reg_addr,
1031 if (hw->aq.asq_last_status == IAVF_AQ_RC_EAGAIN && retry) {
1038 /* if the AQ access failed, try the old-fashioned way */
1039 if (status || use_register)
1040 wr32(hw, reg_addr, reg_val);
1044 * iavf_aq_set_phy_register
1045 * @hw: pointer to the hw struct
1046 * @phy_select: select which phy should be accessed
1047 * @dev_addr: PHY device address
1048 * @reg_addr: PHY register address
1049 * @reg_val: new register value
1050 * @cmd_details: pointer to command details structure or NULL
1052 * Write the external PHY register.
1054 enum iavf_status iavf_aq_set_phy_register(struct iavf_hw *hw,
1055 u8 phy_select, u8 dev_addr,
1056 u32 reg_addr, u32 reg_val,
1057 struct iavf_asq_cmd_details *cmd_details)
1059 struct iavf_aq_desc desc;
1060 struct iavf_aqc_phy_register_access *cmd =
1061 (struct iavf_aqc_phy_register_access *)&desc.params.raw;
1062 enum iavf_status status;
1064 iavf_fill_default_direct_cmd_desc(&desc,
1065 iavf_aqc_opc_set_phy_register);
1067 cmd->phy_interface = phy_select;
1068 cmd->dev_addres = dev_addr;
1069 cmd->reg_address = CPU_TO_LE32(reg_addr);
1070 cmd->reg_value = CPU_TO_LE32(reg_val);
1072 status = iavf_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1078 * iavf_aq_get_phy_register
1079 * @hw: pointer to the hw struct
1080 * @phy_select: select which phy should be accessed
1081 * @dev_addr: PHY device address
1082 * @reg_addr: PHY register address
1083 * @reg_val: read register value
1084 * @cmd_details: pointer to command details structure or NULL
1086 * Read the external PHY register.
1088 enum iavf_status iavf_aq_get_phy_register(struct iavf_hw *hw,
1089 u8 phy_select, u8 dev_addr,
1090 u32 reg_addr, u32 *reg_val,
1091 struct iavf_asq_cmd_details *cmd_details)
1093 struct iavf_aq_desc desc;
1094 struct iavf_aqc_phy_register_access *cmd =
1095 (struct iavf_aqc_phy_register_access *)&desc.params.raw;
1096 enum iavf_status status;
1098 iavf_fill_default_direct_cmd_desc(&desc,
1099 iavf_aqc_opc_get_phy_register);
1101 cmd->phy_interface = phy_select;
1102 cmd->dev_addres = dev_addr;
1103 cmd->reg_address = CPU_TO_LE32(reg_addr);
1105 status = iavf_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1107 *reg_val = LE32_TO_CPU(cmd->reg_value);
1114 * iavf_aq_send_msg_to_pf
1115 * @hw: pointer to the hardware structure
1116 * @v_opcode: opcodes for VF-PF communication
1117 * @v_retval: return error code
1118 * @msg: pointer to the msg buffer
1119 * @msglen: msg length
1120 * @cmd_details: pointer to command details
1122 * Send message to PF driver using admin queue. By default, this message
1123 * is sent asynchronously, i.e. iavf_asq_send_command() does not wait for
1124 * completion before returning.
1126 enum iavf_status iavf_aq_send_msg_to_pf(struct iavf_hw *hw,
1127 enum virtchnl_ops v_opcode,
1128 enum iavf_status v_retval,
1129 u8 *msg, u16 msglen,
1130 struct iavf_asq_cmd_details *cmd_details)
1132 struct iavf_aq_desc desc;
1133 struct iavf_asq_cmd_details details;
1134 enum iavf_status status;
1136 iavf_fill_default_direct_cmd_desc(&desc, iavf_aqc_opc_send_msg_to_pf);
1137 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_SI);
1138 desc.cookie_high = CPU_TO_LE32(v_opcode);
1139 desc.cookie_low = CPU_TO_LE32(v_retval);
1141 desc.flags |= CPU_TO_LE16((u16)(IAVF_AQ_FLAG_BUF
1142 | IAVF_AQ_FLAG_RD));
1143 if (msglen > IAVF_AQ_LARGE_BUF)
1144 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_LB);
1145 desc.datalen = CPU_TO_LE16(msglen);
1148 iavf_memset(&details, 0, sizeof(details), IAVF_NONDMA_MEM);
1149 details.async = true;
1150 cmd_details = &details;
1152 status = iavf_asq_send_command(hw, (struct iavf_aq_desc *)&desc, msg,
1153 msglen, cmd_details);
1158 * iavf_parse_hw_config
1159 * @hw: pointer to the hardware structure
1160 * @msg: pointer to the virtual channel VF resource structure
1162 * Given a VF resource message from the PF, populate the hw struct
1163 * with appropriate information.
1165 void iavf_parse_hw_config(struct iavf_hw *hw,
1166 struct virtchnl_vf_resource *msg)
1168 struct virtchnl_vsi_resource *vsi_res;
1171 vsi_res = &msg->vsi_res[0];
1173 hw->dev_caps.num_vsis = msg->num_vsis;
1174 hw->dev_caps.num_rx_qp = msg->num_queue_pairs;
1175 hw->dev_caps.num_tx_qp = msg->num_queue_pairs;
1176 hw->dev_caps.num_msix_vectors_vf = msg->max_vectors;
1177 hw->dev_caps.dcb = msg->vf_cap_flags &
1178 VIRTCHNL_VF_OFFLOAD_L2;
1179 hw->dev_caps.iwarp = (msg->vf_cap_flags &
1180 VIRTCHNL_VF_OFFLOAD_IWARP) ? 1 : 0;
1181 for (i = 0; i < msg->num_vsis; i++) {
1182 if (vsi_res->vsi_type == VIRTCHNL_VSI_SRIOV) {
1183 iavf_memcpy(hw->mac.perm_addr,
1184 vsi_res->default_mac_addr,
1186 IAVF_NONDMA_TO_NONDMA);
1187 iavf_memcpy(hw->mac.addr, vsi_res->default_mac_addr,
1189 IAVF_NONDMA_TO_NONDMA);
1197 * @hw: pointer to the hardware structure
1199 * Send a VF_RESET message to the PF. Does not wait for response from PF
1200 * as none will be forthcoming. Immediately after calling this function,
1201 * the admin queue should be shut down and (optionally) reinitialized.
1203 enum iavf_status iavf_reset(struct iavf_hw *hw)
1205 return iavf_aq_send_msg_to_pf(hw, VIRTCHNL_OP_RESET_VF,
1206 IAVF_SUCCESS, NULL, 0, NULL);
1210 * iavf_aq_set_arp_proxy_config
1211 * @hw: pointer to the HW structure
1212 * @proxy_config: pointer to proxy config command table struct
1213 * @cmd_details: pointer to command details
1215 * Set ARP offload parameters from pre-populated
1216 * iavf_aqc_arp_proxy_data struct
1218 enum iavf_status iavf_aq_set_arp_proxy_config(struct iavf_hw *hw,
1219 struct iavf_aqc_arp_proxy_data *proxy_config,
1220 struct iavf_asq_cmd_details *cmd_details)
1222 struct iavf_aq_desc desc;
1223 enum iavf_status status;
1226 return IAVF_ERR_PARAM;
1228 iavf_fill_default_direct_cmd_desc(&desc, iavf_aqc_opc_set_proxy_config);
1230 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_BUF);
1231 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_RD);
1232 desc.params.external.addr_high =
1233 CPU_TO_LE32(IAVF_HI_DWORD((u64)proxy_config));
1234 desc.params.external.addr_low =
1235 CPU_TO_LE32(IAVF_LO_DWORD((u64)proxy_config));
1236 desc.datalen = CPU_TO_LE16(sizeof(struct iavf_aqc_arp_proxy_data));
1238 status = iavf_asq_send_command(hw, &desc, proxy_config,
1239 sizeof(struct iavf_aqc_arp_proxy_data),
1246 * iavf_aq_opc_set_ns_proxy_table_entry
1247 * @hw: pointer to the HW structure
1248 * @ns_proxy_table_entry: pointer to NS table entry command struct
1249 * @cmd_details: pointer to command details
1251 * Set IPv6 Neighbor Solicitation (NS) protocol offload parameters
1252 * from pre-populated iavf_aqc_ns_proxy_data struct
1254 enum iavf_status iavf_aq_set_ns_proxy_table_entry(struct iavf_hw *hw,
1255 struct iavf_aqc_ns_proxy_data *ns_proxy_table_entry,
1256 struct iavf_asq_cmd_details *cmd_details)
1258 struct iavf_aq_desc desc;
1259 enum iavf_status status;
1261 if (!ns_proxy_table_entry)
1262 return IAVF_ERR_PARAM;
1264 iavf_fill_default_direct_cmd_desc(&desc,
1265 iavf_aqc_opc_set_ns_proxy_table_entry);
1267 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_BUF);
1268 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_RD);
1269 desc.params.external.addr_high =
1270 CPU_TO_LE32(IAVF_HI_DWORD((u64)ns_proxy_table_entry));
1271 desc.params.external.addr_low =
1272 CPU_TO_LE32(IAVF_LO_DWORD((u64)ns_proxy_table_entry));
1273 desc.datalen = CPU_TO_LE16(sizeof(struct iavf_aqc_ns_proxy_data));
1275 status = iavf_asq_send_command(hw, &desc, ns_proxy_table_entry,
1276 sizeof(struct iavf_aqc_ns_proxy_data),
1283 * iavf_aq_set_clear_wol_filter
1284 * @hw: pointer to the hw struct
1285 * @filter_index: index of filter to modify (0-7)
1286 * @filter: buffer containing filter to be set
1287 * @set_filter: true to set filter, false to clear filter
1288 * @no_wol_tco: if true, pass through packets cannot cause wake-up
1289 * if false, pass through packets may cause wake-up
1290 * @filter_valid: true if filter action is valid
1291 * @no_wol_tco_valid: true if no WoL in TCO traffic action valid
1292 * @cmd_details: pointer to command details structure or NULL
1294 * Set or clear WoL filter for port attached to the PF
1296 enum iavf_status iavf_aq_set_clear_wol_filter(struct iavf_hw *hw,
1298 struct iavf_aqc_set_wol_filter_data *filter,
1299 bool set_filter, bool no_wol_tco,
1300 bool filter_valid, bool no_wol_tco_valid,
1301 struct iavf_asq_cmd_details *cmd_details)
1303 struct iavf_aq_desc desc;
1304 struct iavf_aqc_set_wol_filter *cmd =
1305 (struct iavf_aqc_set_wol_filter *)&desc.params.raw;
1306 enum iavf_status status;
1308 u16 valid_flags = 0;
1311 iavf_fill_default_direct_cmd_desc(&desc, iavf_aqc_opc_set_wol_filter);
1313 if (filter_index >= IAVF_AQC_MAX_NUM_WOL_FILTERS)
1314 return IAVF_ERR_PARAM;
1315 cmd->filter_index = CPU_TO_LE16(filter_index);
1319 return IAVF_ERR_PARAM;
1321 cmd_flags |= IAVF_AQC_SET_WOL_FILTER;
1322 cmd_flags |= IAVF_AQC_SET_WOL_FILTER_WOL_PRESERVE_ON_PFR;
1326 cmd_flags |= IAVF_AQC_SET_WOL_FILTER_NO_TCO_WOL;
1327 cmd->cmd_flags = CPU_TO_LE16(cmd_flags);
1330 valid_flags |= IAVF_AQC_SET_WOL_FILTER_ACTION_VALID;
1331 if (no_wol_tco_valid)
1332 valid_flags |= IAVF_AQC_SET_WOL_FILTER_NO_TCO_ACTION_VALID;
1333 cmd->valid_flags = CPU_TO_LE16(valid_flags);
1335 buff_len = sizeof(*filter);
1336 desc.datalen = CPU_TO_LE16(buff_len);
1338 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_BUF);
1339 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_RD);
1341 cmd->address_high = CPU_TO_LE32(IAVF_HI_DWORD((u64)filter));
1342 cmd->address_low = CPU_TO_LE32(IAVF_LO_DWORD((u64)filter));
1344 status = iavf_asq_send_command(hw, &desc, filter,
1345 buff_len, cmd_details);
1351 * iavf_aq_get_wake_event_reason
1352 * @hw: pointer to the hw struct
1353 * @wake_reason: return value, index of matching filter
1354 * @cmd_details: pointer to command details structure or NULL
1356 * Get information for the reason of a Wake Up event
1358 enum iavf_status iavf_aq_get_wake_event_reason(struct iavf_hw *hw,
1360 struct iavf_asq_cmd_details *cmd_details)
1362 struct iavf_aq_desc desc;
1363 struct iavf_aqc_get_wake_reason_completion *resp =
1364 (struct iavf_aqc_get_wake_reason_completion *)&desc.params.raw;
1365 enum iavf_status status;
1367 iavf_fill_default_direct_cmd_desc(&desc, iavf_aqc_opc_get_wake_reason);
1369 status = iavf_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1371 if (status == IAVF_SUCCESS)
1372 *wake_reason = LE16_TO_CPU(resp->wake_reason);
1378 * iavf_aq_clear_all_wol_filters
1379 * @hw: pointer to the hw struct
1380 * @cmd_details: pointer to command details structure or NULL
1382 * Get information for the reason of a Wake Up event
1384 enum iavf_status iavf_aq_clear_all_wol_filters(struct iavf_hw *hw,
1385 struct iavf_asq_cmd_details *cmd_details)
1387 struct iavf_aq_desc desc;
1388 enum iavf_status status;
1390 iavf_fill_default_direct_cmd_desc(&desc,
1391 iavf_aqc_opc_clear_all_wol_filters);
1393 status = iavf_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1399 * iavf_aq_write_ddp - Write dynamic device personalization (ddp)
1400 * @hw: pointer to the hw struct
1401 * @buff: command buffer (size in bytes = buff_size)
1402 * @buff_size: buffer size in bytes
1403 * @track_id: package tracking id
1404 * @error_offset: returns error offset
1405 * @error_info: returns error information
1406 * @cmd_details: pointer to command details structure or NULL
1409 iavf_status iavf_aq_write_ddp(struct iavf_hw *hw, void *buff,
1410 u16 buff_size, u32 track_id,
1411 u32 *error_offset, u32 *error_info,
1412 struct iavf_asq_cmd_details *cmd_details)
1414 struct iavf_aq_desc desc;
1415 struct iavf_aqc_write_personalization_profile *cmd =
1416 (struct iavf_aqc_write_personalization_profile *)
1418 struct iavf_aqc_write_ddp_resp *resp;
1419 enum iavf_status status;
1421 iavf_fill_default_direct_cmd_desc(&desc,
1422 iavf_aqc_opc_write_personalization_profile);
1424 desc.flags |= CPU_TO_LE16(IAVF_AQ_FLAG_BUF | IAVF_AQ_FLAG_RD);
1425 if (buff_size > IAVF_AQ_LARGE_BUF)
1426 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_LB);
1428 desc.datalen = CPU_TO_LE16(buff_size);
1430 cmd->profile_track_id = CPU_TO_LE32(track_id);
1432 status = iavf_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
1434 resp = (struct iavf_aqc_write_ddp_resp *)&desc.params.raw;
1436 *error_offset = LE32_TO_CPU(resp->error_offset);
1438 *error_info = LE32_TO_CPU(resp->error_info);
1445 * iavf_aq_get_ddp_list - Read dynamic device personalization (ddp)
1446 * @hw: pointer to the hw struct
1447 * @buff: command buffer (size in bytes = buff_size)
1448 * @buff_size: buffer size in bytes
1449 * @flags: AdminQ command flags
1450 * @cmd_details: pointer to command details structure or NULL
1453 iavf_status iavf_aq_get_ddp_list(struct iavf_hw *hw, void *buff,
1454 u16 buff_size, u8 flags,
1455 struct iavf_asq_cmd_details *cmd_details)
1457 struct iavf_aq_desc desc;
1458 struct iavf_aqc_get_applied_profiles *cmd =
1459 (struct iavf_aqc_get_applied_profiles *)&desc.params.raw;
1460 enum iavf_status status;
1462 iavf_fill_default_direct_cmd_desc(&desc,
1463 iavf_aqc_opc_get_personalization_profile_list);
1465 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_BUF);
1466 if (buff_size > IAVF_AQ_LARGE_BUF)
1467 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_LB);
1468 desc.datalen = CPU_TO_LE16(buff_size);
1472 status = iavf_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
1478 * iavf_find_segment_in_package
1479 * @segment_type: the segment type to search for (i.e., SEGMENT_TYPE_IAVF)
1480 * @pkg_hdr: pointer to the package header to be searched
1482 * This function searches a package file for a particular segment type. On
1483 * success it returns a pointer to the segment header, otherwise it will
1486 struct iavf_generic_seg_header *
1487 iavf_find_segment_in_package(u32 segment_type,
1488 struct iavf_package_header *pkg_hdr)
1490 struct iavf_generic_seg_header *segment;
1493 /* Search all package segments for the requested segment type */
1494 for (i = 0; i < pkg_hdr->segment_count; i++) {
1496 (struct iavf_generic_seg_header *)((u8 *)pkg_hdr +
1497 pkg_hdr->segment_offset[i]);
1499 if (segment->type == segment_type)
1506 /* Get section table in profile */
1507 #define IAVF_SECTION_TABLE(profile, sec_tbl) \
1509 struct iavf_profile_segment *p = (profile); \
1512 count = p->device_table_count; \
1513 nvm = (u32 *)&p->device_table[count]; \
1514 sec_tbl = (struct iavf_section_table *)&nvm[nvm[0] + 1]; \
1517 /* Get section header in profile */
1518 #define IAVF_SECTION_HEADER(profile, offset) \
1519 (struct iavf_profile_section_header *)((u8 *)(profile) + (offset))
1522 * iavf_find_section_in_profile
1523 * @section_type: the section type to search for (i.e., SECTION_TYPE_NOTE)
1524 * @profile: pointer to the iavf segment header to be searched
1526 * This function searches iavf segment for a particular section type. On
1527 * success it returns a pointer to the section header, otherwise it will
1530 struct iavf_profile_section_header *
1531 iavf_find_section_in_profile(u32 section_type,
1532 struct iavf_profile_segment *profile)
1534 struct iavf_profile_section_header *sec;
1535 struct iavf_section_table *sec_tbl;
1539 if (profile->header.type != SEGMENT_TYPE_IAVF)
1542 IAVF_SECTION_TABLE(profile, sec_tbl);
1544 for (i = 0; i < sec_tbl->section_count; i++) {
1545 sec_off = sec_tbl->section_offset[i];
1546 sec = IAVF_SECTION_HEADER(profile, sec_off);
1547 if (sec->section.type == section_type)
1555 * iavf_ddp_exec_aq_section - Execute generic AQ for DDP
1556 * @hw: pointer to the hw struct
1557 * @aq: command buffer containing all data to execute AQ
1560 iavf_status iavf_ddp_exec_aq_section(struct iavf_hw *hw,
1561 struct iavf_profile_aq_section *aq)
1563 enum iavf_status status;
1564 struct iavf_aq_desc desc;
1568 iavf_fill_default_direct_cmd_desc(&desc, aq->opcode);
1569 desc.flags |= CPU_TO_LE16(aq->flags);
1570 iavf_memcpy(desc.params.raw, aq->param, sizeof(desc.params.raw),
1571 IAVF_NONDMA_TO_NONDMA);
1573 msglen = aq->datalen;
1575 desc.flags |= CPU_TO_LE16((u16)(IAVF_AQ_FLAG_BUF |
1577 if (msglen > IAVF_AQ_LARGE_BUF)
1578 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_LB);
1579 desc.datalen = CPU_TO_LE16(msglen);
1583 status = iavf_asq_send_command(hw, &desc, msg, msglen, NULL);
1585 if (status != IAVF_SUCCESS) {
1586 iavf_debug(hw, IAVF_DEBUG_PACKAGE,
1587 "unable to exec DDP AQ opcode %u, error %d\n",
1588 aq->opcode, status);
1592 /* copy returned desc to aq_buf */
1593 iavf_memcpy(aq->param, desc.params.raw, sizeof(desc.params.raw),
1594 IAVF_NONDMA_TO_NONDMA);
1596 return IAVF_SUCCESS;
1600 * iavf_validate_profile
1601 * @hw: pointer to the hardware structure
1602 * @profile: pointer to the profile segment of the package to be validated
1603 * @track_id: package tracking id
1604 * @rollback: flag if the profile is for rollback.
1606 * Validates supported devices and profile's sections.
1608 STATIC enum iavf_status
1609 iavf_validate_profile(struct iavf_hw *hw, struct iavf_profile_segment *profile,
1610 u32 track_id, bool rollback)
1612 struct iavf_profile_section_header *sec = NULL;
1613 enum iavf_status status = IAVF_SUCCESS;
1614 struct iavf_section_table *sec_tbl;
1620 if (track_id == IAVF_DDP_TRACKID_INVALID) {
1621 iavf_debug(hw, IAVF_DEBUG_PACKAGE, "Invalid track_id\n");
1622 return IAVF_NOT_SUPPORTED;
1625 dev_cnt = profile->device_table_count;
1626 for (i = 0; i < dev_cnt; i++) {
1627 vendor_dev_id = profile->device_table[i].vendor_dev_id;
1628 if ((vendor_dev_id >> 16) == IAVF_INTEL_VENDOR_ID &&
1629 hw->device_id == (vendor_dev_id & 0xFFFF))
1632 if (dev_cnt && (i == dev_cnt)) {
1633 iavf_debug(hw, IAVF_DEBUG_PACKAGE,
1634 "Device doesn't support DDP\n");
1635 return IAVF_ERR_DEVICE_NOT_SUPPORTED;
1638 IAVF_SECTION_TABLE(profile, sec_tbl);
1640 /* Validate sections types */
1641 for (i = 0; i < sec_tbl->section_count; i++) {
1642 sec_off = sec_tbl->section_offset[i];
1643 sec = IAVF_SECTION_HEADER(profile, sec_off);
1645 if (sec->section.type == SECTION_TYPE_MMIO ||
1646 sec->section.type == SECTION_TYPE_AQ ||
1647 sec->section.type == SECTION_TYPE_RB_AQ) {
1648 iavf_debug(hw, IAVF_DEBUG_PACKAGE,
1649 "Not a roll-back package\n");
1650 return IAVF_NOT_SUPPORTED;
1653 if (sec->section.type == SECTION_TYPE_RB_AQ ||
1654 sec->section.type == SECTION_TYPE_RB_MMIO) {
1655 iavf_debug(hw, IAVF_DEBUG_PACKAGE,
1656 "Not an original package\n");
1657 return IAVF_NOT_SUPPORTED;
1666 * iavf_write_profile
1667 * @hw: pointer to the hardware structure
1668 * @profile: pointer to the profile segment of the package to be downloaded
1669 * @track_id: package tracking id
1671 * Handles the download of a complete package.
1674 iavf_write_profile(struct iavf_hw *hw, struct iavf_profile_segment *profile,
1677 enum iavf_status status = IAVF_SUCCESS;
1678 struct iavf_section_table *sec_tbl;
1679 struct iavf_profile_section_header *sec = NULL;
1680 struct iavf_profile_aq_section *ddp_aq;
1681 u32 section_size = 0;
1682 u32 offset = 0, info = 0;
1686 status = iavf_validate_profile(hw, profile, track_id, false);
1690 IAVF_SECTION_TABLE(profile, sec_tbl);
1692 for (i = 0; i < sec_tbl->section_count; i++) {
1693 sec_off = sec_tbl->section_offset[i];
1694 sec = IAVF_SECTION_HEADER(profile, sec_off);
1695 /* Process generic admin command */
1696 if (sec->section.type == SECTION_TYPE_AQ) {
1697 ddp_aq = (struct iavf_profile_aq_section *)&sec[1];
1698 status = iavf_ddp_exec_aq_section(hw, ddp_aq);
1700 iavf_debug(hw, IAVF_DEBUG_PACKAGE,
1701 "Failed to execute aq: section %d, opcode %u\n",
1705 sec->section.type = SECTION_TYPE_RB_AQ;
1708 /* Skip any non-mmio sections */
1709 if (sec->section.type != SECTION_TYPE_MMIO)
1712 section_size = sec->section.size +
1713 sizeof(struct iavf_profile_section_header);
1715 /* Write MMIO section */
1716 status = iavf_aq_write_ddp(hw, (void *)sec, (u16)section_size,
1717 track_id, &offset, &info, NULL);
1719 iavf_debug(hw, IAVF_DEBUG_PACKAGE,
1720 "Failed to write profile: section %d, offset %d, info %d\n",
1729 * iavf_rollback_profile
1730 * @hw: pointer to the hardware structure
1731 * @profile: pointer to the profile segment of the package to be removed
1732 * @track_id: package tracking id
1734 * Rolls back previously loaded package.
1737 iavf_rollback_profile(struct iavf_hw *hw, struct iavf_profile_segment *profile,
1740 struct iavf_profile_section_header *sec = NULL;
1741 enum iavf_status status = IAVF_SUCCESS;
1742 struct iavf_section_table *sec_tbl;
1743 u32 offset = 0, info = 0;
1744 u32 section_size = 0;
1748 status = iavf_validate_profile(hw, profile, track_id, true);
1752 IAVF_SECTION_TABLE(profile, sec_tbl);
1754 /* For rollback write sections in reverse */
1755 for (i = sec_tbl->section_count - 1; i >= 0; i--) {
1756 sec_off = sec_tbl->section_offset[i];
1757 sec = IAVF_SECTION_HEADER(profile, sec_off);
1759 /* Skip any non-rollback sections */
1760 if (sec->section.type != SECTION_TYPE_RB_MMIO)
1763 section_size = sec->section.size +
1764 sizeof(struct iavf_profile_section_header);
1766 /* Write roll-back MMIO section */
1767 status = iavf_aq_write_ddp(hw, (void *)sec, (u16)section_size,
1768 track_id, &offset, &info, NULL);
1770 iavf_debug(hw, IAVF_DEBUG_PACKAGE,
1771 "Failed to write profile: section %d, offset %d, info %d\n",
1780 * iavf_add_pinfo_to_list
1781 * @hw: pointer to the hardware structure
1782 * @profile: pointer to the profile segment of the package
1783 * @profile_info_sec: buffer for information section
1784 * @track_id: package tracking id
1786 * Register a profile to the list of loaded profiles.
1789 iavf_add_pinfo_to_list(struct iavf_hw *hw,
1790 struct iavf_profile_segment *profile,
1791 u8 *profile_info_sec, u32 track_id)
1793 enum iavf_status status = IAVF_SUCCESS;
1794 struct iavf_profile_section_header *sec = NULL;
1795 struct iavf_profile_info *pinfo;
1796 u32 offset = 0, info = 0;
1798 sec = (struct iavf_profile_section_header *)profile_info_sec;
1800 sec->data_end = sizeof(struct iavf_profile_section_header) +
1801 sizeof(struct iavf_profile_info);
1802 sec->section.type = SECTION_TYPE_INFO;
1803 sec->section.offset = sizeof(struct iavf_profile_section_header);
1804 sec->section.size = sizeof(struct iavf_profile_info);
1805 pinfo = (struct iavf_profile_info *)(profile_info_sec +
1806 sec->section.offset);
1807 pinfo->track_id = track_id;
1808 pinfo->version = profile->version;
1809 pinfo->op = IAVF_DDP_ADD_TRACKID;
1810 iavf_memcpy(pinfo->name, profile->name, IAVF_DDP_NAME_SIZE,
1811 IAVF_NONDMA_TO_NONDMA);
1813 status = iavf_aq_write_ddp(hw, (void *)sec, sec->data_end,
1814 track_id, &offset, &info, NULL);