1 /*******************************************************************************
3 Copyright (c) 2013 - 2015, Intel Corporation
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 3. Neither the name of the Intel Corporation nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
32 ***************************************************************************/
34 #include "iavf_type.h"
35 #include "iavf_adminq.h"
36 #include "iavf_prototype.h"
41 * iavf_set_mac_type - Sets MAC type
42 * @hw: pointer to the HW structure
44 * This function sets the mac type of the adapter based on the
45 * vendor ID and device ID stored in the hw structure.
47 enum iavf_status_code iavf_set_mac_type(struct iavf_hw *hw)
49 enum iavf_status_code status = IAVF_SUCCESS;
51 DEBUGFUNC("iavf_set_mac_type\n");
53 if (hw->vendor_id == IAVF_INTEL_VENDOR_ID) {
54 switch (hw->device_id) {
55 /* TODO: remove undefined device ID now, need to think how to
56 * remove them in share code
58 case IAVF_DEV_ID_ADAPTIVE_VF:
59 hw->mac.type = IAVF_MAC_VF;
62 hw->mac.type = IAVF_MAC_GENERIC;
66 status = IAVF_ERR_DEVICE_NOT_SUPPORTED;
69 DEBUGOUT2("iavf_set_mac_type found mac: %d, returns: %d\n",
70 hw->mac.type, status);
75 * iavf_aq_str - convert AQ err code to a string
76 * @hw: pointer to the HW structure
77 * @aq_err: the AQ error code to convert
79 const char *iavf_aq_str(struct iavf_hw *hw, enum iavf_admin_queue_err aq_err)
84 case IAVF_AQ_RC_EPERM:
85 return "IAVF_AQ_RC_EPERM";
86 case IAVF_AQ_RC_ENOENT:
87 return "IAVF_AQ_RC_ENOENT";
88 case IAVF_AQ_RC_ESRCH:
89 return "IAVF_AQ_RC_ESRCH";
90 case IAVF_AQ_RC_EINTR:
91 return "IAVF_AQ_RC_EINTR";
93 return "IAVF_AQ_RC_EIO";
94 case IAVF_AQ_RC_ENXIO:
95 return "IAVF_AQ_RC_ENXIO";
96 case IAVF_AQ_RC_E2BIG:
97 return "IAVF_AQ_RC_E2BIG";
98 case IAVF_AQ_RC_EAGAIN:
99 return "IAVF_AQ_RC_EAGAIN";
100 case IAVF_AQ_RC_ENOMEM:
101 return "IAVF_AQ_RC_ENOMEM";
102 case IAVF_AQ_RC_EACCES:
103 return "IAVF_AQ_RC_EACCES";
104 case IAVF_AQ_RC_EFAULT:
105 return "IAVF_AQ_RC_EFAULT";
106 case IAVF_AQ_RC_EBUSY:
107 return "IAVF_AQ_RC_EBUSY";
108 case IAVF_AQ_RC_EEXIST:
109 return "IAVF_AQ_RC_EEXIST";
110 case IAVF_AQ_RC_EINVAL:
111 return "IAVF_AQ_RC_EINVAL";
112 case IAVF_AQ_RC_ENOTTY:
113 return "IAVF_AQ_RC_ENOTTY";
114 case IAVF_AQ_RC_ENOSPC:
115 return "IAVF_AQ_RC_ENOSPC";
116 case IAVF_AQ_RC_ENOSYS:
117 return "IAVF_AQ_RC_ENOSYS";
118 case IAVF_AQ_RC_ERANGE:
119 return "IAVF_AQ_RC_ERANGE";
120 case IAVF_AQ_RC_EFLUSHED:
121 return "IAVF_AQ_RC_EFLUSHED";
122 case IAVF_AQ_RC_BAD_ADDR:
123 return "IAVF_AQ_RC_BAD_ADDR";
124 case IAVF_AQ_RC_EMODE:
125 return "IAVF_AQ_RC_EMODE";
126 case IAVF_AQ_RC_EFBIG:
127 return "IAVF_AQ_RC_EFBIG";
130 snprintf(hw->err_str, sizeof(hw->err_str), "%d", aq_err);
135 * iavf_stat_str - convert status err code to a string
136 * @hw: pointer to the HW structure
137 * @stat_err: the status error code to convert
139 const char *iavf_stat_str(struct iavf_hw *hw, enum iavf_status_code stat_err)
145 return "IAVF_ERR_NVM";
146 case IAVF_ERR_NVM_CHECKSUM:
147 return "IAVF_ERR_NVM_CHECKSUM";
149 return "IAVF_ERR_PHY";
150 case IAVF_ERR_CONFIG:
151 return "IAVF_ERR_CONFIG";
153 return "IAVF_ERR_PARAM";
154 case IAVF_ERR_MAC_TYPE:
155 return "IAVF_ERR_MAC_TYPE";
156 case IAVF_ERR_UNKNOWN_PHY:
157 return "IAVF_ERR_UNKNOWN_PHY";
158 case IAVF_ERR_LINK_SETUP:
159 return "IAVF_ERR_LINK_SETUP";
160 case IAVF_ERR_ADAPTER_STOPPED:
161 return "IAVF_ERR_ADAPTER_STOPPED";
162 case IAVF_ERR_INVALID_MAC_ADDR:
163 return "IAVF_ERR_INVALID_MAC_ADDR";
164 case IAVF_ERR_DEVICE_NOT_SUPPORTED:
165 return "IAVF_ERR_DEVICE_NOT_SUPPORTED";
166 case IAVF_ERR_MASTER_REQUESTS_PENDING:
167 return "IAVF_ERR_MASTER_REQUESTS_PENDING";
168 case IAVF_ERR_INVALID_LINK_SETTINGS:
169 return "IAVF_ERR_INVALID_LINK_SETTINGS";
170 case IAVF_ERR_AUTONEG_NOT_COMPLETE:
171 return "IAVF_ERR_AUTONEG_NOT_COMPLETE";
172 case IAVF_ERR_RESET_FAILED:
173 return "IAVF_ERR_RESET_FAILED";
174 case IAVF_ERR_SWFW_SYNC:
175 return "IAVF_ERR_SWFW_SYNC";
176 case IAVF_ERR_NO_AVAILABLE_VSI:
177 return "IAVF_ERR_NO_AVAILABLE_VSI";
178 case IAVF_ERR_NO_MEMORY:
179 return "IAVF_ERR_NO_MEMORY";
180 case IAVF_ERR_BAD_PTR:
181 return "IAVF_ERR_BAD_PTR";
182 case IAVF_ERR_RING_FULL:
183 return "IAVF_ERR_RING_FULL";
184 case IAVF_ERR_INVALID_PD_ID:
185 return "IAVF_ERR_INVALID_PD_ID";
186 case IAVF_ERR_INVALID_QP_ID:
187 return "IAVF_ERR_INVALID_QP_ID";
188 case IAVF_ERR_INVALID_CQ_ID:
189 return "IAVF_ERR_INVALID_CQ_ID";
190 case IAVF_ERR_INVALID_CEQ_ID:
191 return "IAVF_ERR_INVALID_CEQ_ID";
192 case IAVF_ERR_INVALID_AEQ_ID:
193 return "IAVF_ERR_INVALID_AEQ_ID";
194 case IAVF_ERR_INVALID_SIZE:
195 return "IAVF_ERR_INVALID_SIZE";
196 case IAVF_ERR_INVALID_ARP_INDEX:
197 return "IAVF_ERR_INVALID_ARP_INDEX";
198 case IAVF_ERR_INVALID_FPM_FUNC_ID:
199 return "IAVF_ERR_INVALID_FPM_FUNC_ID";
200 case IAVF_ERR_QP_INVALID_MSG_SIZE:
201 return "IAVF_ERR_QP_INVALID_MSG_SIZE";
202 case IAVF_ERR_QP_TOOMANY_WRS_POSTED:
203 return "IAVF_ERR_QP_TOOMANY_WRS_POSTED";
204 case IAVF_ERR_INVALID_FRAG_COUNT:
205 return "IAVF_ERR_INVALID_FRAG_COUNT";
206 case IAVF_ERR_QUEUE_EMPTY:
207 return "IAVF_ERR_QUEUE_EMPTY";
208 case IAVF_ERR_INVALID_ALIGNMENT:
209 return "IAVF_ERR_INVALID_ALIGNMENT";
210 case IAVF_ERR_FLUSHED_QUEUE:
211 return "IAVF_ERR_FLUSHED_QUEUE";
212 case IAVF_ERR_INVALID_PUSH_PAGE_INDEX:
213 return "IAVF_ERR_INVALID_PUSH_PAGE_INDEX";
214 case IAVF_ERR_INVALID_IMM_DATA_SIZE:
215 return "IAVF_ERR_INVALID_IMM_DATA_SIZE";
216 case IAVF_ERR_TIMEOUT:
217 return "IAVF_ERR_TIMEOUT";
218 case IAVF_ERR_OPCODE_MISMATCH:
219 return "IAVF_ERR_OPCODE_MISMATCH";
220 case IAVF_ERR_CQP_COMPL_ERROR:
221 return "IAVF_ERR_CQP_COMPL_ERROR";
222 case IAVF_ERR_INVALID_VF_ID:
223 return "IAVF_ERR_INVALID_VF_ID";
224 case IAVF_ERR_INVALID_HMCFN_ID:
225 return "IAVF_ERR_INVALID_HMCFN_ID";
226 case IAVF_ERR_BACKING_PAGE_ERROR:
227 return "IAVF_ERR_BACKING_PAGE_ERROR";
228 case IAVF_ERR_NO_PBLCHUNKS_AVAILABLE:
229 return "IAVF_ERR_NO_PBLCHUNKS_AVAILABLE";
230 case IAVF_ERR_INVALID_PBLE_INDEX:
231 return "IAVF_ERR_INVALID_PBLE_INDEX";
232 case IAVF_ERR_INVALID_SD_INDEX:
233 return "IAVF_ERR_INVALID_SD_INDEX";
234 case IAVF_ERR_INVALID_PAGE_DESC_INDEX:
235 return "IAVF_ERR_INVALID_PAGE_DESC_INDEX";
236 case IAVF_ERR_INVALID_SD_TYPE:
237 return "IAVF_ERR_INVALID_SD_TYPE";
238 case IAVF_ERR_MEMCPY_FAILED:
239 return "IAVF_ERR_MEMCPY_FAILED";
240 case IAVF_ERR_INVALID_HMC_OBJ_INDEX:
241 return "IAVF_ERR_INVALID_HMC_OBJ_INDEX";
242 case IAVF_ERR_INVALID_HMC_OBJ_COUNT:
243 return "IAVF_ERR_INVALID_HMC_OBJ_COUNT";
244 case IAVF_ERR_INVALID_SRQ_ARM_LIMIT:
245 return "IAVF_ERR_INVALID_SRQ_ARM_LIMIT";
246 case IAVF_ERR_SRQ_ENABLED:
247 return "IAVF_ERR_SRQ_ENABLED";
248 case IAVF_ERR_ADMIN_QUEUE_ERROR:
249 return "IAVF_ERR_ADMIN_QUEUE_ERROR";
250 case IAVF_ERR_ADMIN_QUEUE_TIMEOUT:
251 return "IAVF_ERR_ADMIN_QUEUE_TIMEOUT";
252 case IAVF_ERR_BUF_TOO_SHORT:
253 return "IAVF_ERR_BUF_TOO_SHORT";
254 case IAVF_ERR_ADMIN_QUEUE_FULL:
255 return "IAVF_ERR_ADMIN_QUEUE_FULL";
256 case IAVF_ERR_ADMIN_QUEUE_NO_WORK:
257 return "IAVF_ERR_ADMIN_QUEUE_NO_WORK";
258 case IAVF_ERR_BAD_IWARP_CQE:
259 return "IAVF_ERR_BAD_IWARP_CQE";
260 case IAVF_ERR_NVM_BLANK_MODE:
261 return "IAVF_ERR_NVM_BLANK_MODE";
262 case IAVF_ERR_NOT_IMPLEMENTED:
263 return "IAVF_ERR_NOT_IMPLEMENTED";
264 case IAVF_ERR_PE_DOORBELL_NOT_ENABLED:
265 return "IAVF_ERR_PE_DOORBELL_NOT_ENABLED";
266 case IAVF_ERR_DIAG_TEST_FAILED:
267 return "IAVF_ERR_DIAG_TEST_FAILED";
268 case IAVF_ERR_NOT_READY:
269 return "IAVF_ERR_NOT_READY";
270 case IAVF_NOT_SUPPORTED:
271 return "IAVF_NOT_SUPPORTED";
272 case IAVF_ERR_FIRMWARE_API_VERSION:
273 return "IAVF_ERR_FIRMWARE_API_VERSION";
274 case IAVF_ERR_ADMIN_QUEUE_CRITICAL_ERROR:
275 return "IAVF_ERR_ADMIN_QUEUE_CRITICAL_ERROR";
278 snprintf(hw->err_str, sizeof(hw->err_str), "%d", stat_err);
284 * @hw: debug mask related to admin queue
286 * @desc: pointer to admin queue descriptor
287 * @buffer: pointer to command buffer
288 * @buf_len: max length of buffer
290 * Dumps debug log about adminq command with descriptor contents.
292 void iavf_debug_aq(struct iavf_hw *hw, enum iavf_debug_mask mask, void *desc,
293 void *buffer, u16 buf_len)
295 struct iavf_aq_desc *aq_desc = (struct iavf_aq_desc *)desc;
296 u8 *buf = (u8 *)buffer;
300 if ((!(mask & hw->debug_mask)) || (desc == NULL))
303 len = LE16_TO_CPU(aq_desc->datalen);
306 "AQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n",
307 LE16_TO_CPU(aq_desc->opcode),
308 LE16_TO_CPU(aq_desc->flags),
309 LE16_TO_CPU(aq_desc->datalen),
310 LE16_TO_CPU(aq_desc->retval));
311 iavf_debug(hw, mask, "\tcookie (h,l) 0x%08X 0x%08X\n",
312 LE32_TO_CPU(aq_desc->cookie_high),
313 LE32_TO_CPU(aq_desc->cookie_low));
314 iavf_debug(hw, mask, "\tparam (0,1) 0x%08X 0x%08X\n",
315 LE32_TO_CPU(aq_desc->params.internal.param0),
316 LE32_TO_CPU(aq_desc->params.internal.param1));
317 iavf_debug(hw, mask, "\taddr (h,l) 0x%08X 0x%08X\n",
318 LE32_TO_CPU(aq_desc->params.external.addr_high),
319 LE32_TO_CPU(aq_desc->params.external.addr_low));
321 if ((buffer != NULL) && (aq_desc->datalen != 0)) {
322 iavf_debug(hw, mask, "AQ CMD Buffer:\n");
325 /* write the full 16-byte chunks */
326 for (i = 0; i < (len - 16); i += 16)
328 "\t0x%04X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n",
329 i, buf[i], buf[i+1], buf[i+2], buf[i+3],
330 buf[i+4], buf[i+5], buf[i+6], buf[i+7],
331 buf[i+8], buf[i+9], buf[i+10], buf[i+11],
332 buf[i+12], buf[i+13], buf[i+14], buf[i+15]);
333 /* the most we could have left is 16 bytes, pad with zeros */
339 memset(d_buf, 0, sizeof(d_buf));
340 for (j = 0; i < len; j++, i++)
343 "\t0x%04X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n",
344 i_sav, d_buf[0], d_buf[1], d_buf[2], d_buf[3],
345 d_buf[4], d_buf[5], d_buf[6], d_buf[7],
346 d_buf[8], d_buf[9], d_buf[10], d_buf[11],
347 d_buf[12], d_buf[13], d_buf[14], d_buf[15]);
353 * iavf_check_asq_alive
354 * @hw: pointer to the hw struct
356 * Returns true if Queue is enabled else false.
358 bool iavf_check_asq_alive(struct iavf_hw *hw)
363 return !!(rd32(hw, hw->aq.asq.len) &
364 IAVF_ATQLEN1_ATQENABLE_MASK);
366 return !!(rd32(hw, hw->aq.asq.len) &
367 IAVF_ATQLEN1_ATQENABLE_MASK);
368 #endif /* INTEGRATED_VF */
373 * iavf_aq_queue_shutdown
374 * @hw: pointer to the hw struct
375 * @unloading: is the driver unloading itself
377 * Tell the Firmware that we're shutting down the AdminQ and whether
378 * or not the driver is unloading as well.
380 enum iavf_status_code iavf_aq_queue_shutdown(struct iavf_hw *hw,
383 struct iavf_aq_desc desc;
384 struct iavf_aqc_queue_shutdown *cmd =
385 (struct iavf_aqc_queue_shutdown *)&desc.params.raw;
386 enum iavf_status_code status;
388 iavf_fill_default_direct_cmd_desc(&desc,
389 iavf_aqc_opc_queue_shutdown);
392 cmd->driver_unloading = CPU_TO_LE32(IAVF_AQ_DRIVER_UNLOADING);
393 status = iavf_asq_send_command(hw, &desc, NULL, 0, NULL);
399 * iavf_aq_get_set_rss_lut
400 * @hw: pointer to the hardware structure
401 * @vsi_id: vsi fw index
402 * @pf_lut: for PF table set true, for VSI table set false
403 * @lut: pointer to the lut buffer provided by the caller
404 * @lut_size: size of the lut buffer
405 * @set: set true to set the table, false to get the table
407 * Internal function to get or set RSS look up table
409 STATIC enum iavf_status_code iavf_aq_get_set_rss_lut(struct iavf_hw *hw,
410 u16 vsi_id, bool pf_lut,
411 u8 *lut, u16 lut_size,
414 enum iavf_status_code status;
415 struct iavf_aq_desc desc;
416 struct iavf_aqc_get_set_rss_lut *cmd_resp =
417 (struct iavf_aqc_get_set_rss_lut *)&desc.params.raw;
420 iavf_fill_default_direct_cmd_desc(&desc,
421 iavf_aqc_opc_set_rss_lut);
423 iavf_fill_default_direct_cmd_desc(&desc,
424 iavf_aqc_opc_get_rss_lut);
426 /* Indirect command */
427 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_BUF);
428 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_RD);
431 CPU_TO_LE16((u16)((vsi_id <<
432 IAVF_AQC_SET_RSS_LUT_VSI_ID_SHIFT) &
433 IAVF_AQC_SET_RSS_LUT_VSI_ID_MASK));
434 cmd_resp->vsi_id |= CPU_TO_LE16((u16)IAVF_AQC_SET_RSS_LUT_VSI_VALID);
437 cmd_resp->flags |= CPU_TO_LE16((u16)
438 ((IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_PF <<
439 IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) &
440 IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_MASK));
442 cmd_resp->flags |= CPU_TO_LE16((u16)
443 ((IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_VSI <<
444 IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) &
445 IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_MASK));
447 status = iavf_asq_send_command(hw, &desc, lut, lut_size, NULL);
453 * iavf_aq_get_rss_lut
454 * @hw: pointer to the hardware structure
455 * @vsi_id: vsi fw index
456 * @pf_lut: for PF table set true, for VSI table set false
457 * @lut: pointer to the lut buffer provided by the caller
458 * @lut_size: size of the lut buffer
460 * get the RSS lookup table, PF or VSI type
462 enum iavf_status_code iavf_aq_get_rss_lut(struct iavf_hw *hw, u16 vsi_id,
463 bool pf_lut, u8 *lut, u16 lut_size)
465 return iavf_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size,
470 * iavf_aq_set_rss_lut
471 * @hw: pointer to the hardware structure
472 * @vsi_id: vsi fw index
473 * @pf_lut: for PF table set true, for VSI table set false
474 * @lut: pointer to the lut buffer provided by the caller
475 * @lut_size: size of the lut buffer
477 * set the RSS lookup table, PF or VSI type
479 enum iavf_status_code iavf_aq_set_rss_lut(struct iavf_hw *hw, u16 vsi_id,
480 bool pf_lut, u8 *lut, u16 lut_size)
482 return iavf_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size, true);
486 * iavf_aq_get_set_rss_key
487 * @hw: pointer to the hw struct
488 * @vsi_id: vsi fw index
489 * @key: pointer to key info struct
490 * @set: set true to set the key, false to get the key
492 * get the RSS key per VSI
494 STATIC enum iavf_status_code iavf_aq_get_set_rss_key(struct iavf_hw *hw,
496 struct iavf_aqc_get_set_rss_key_data *key,
499 enum iavf_status_code status;
500 struct iavf_aq_desc desc;
501 struct iavf_aqc_get_set_rss_key *cmd_resp =
502 (struct iavf_aqc_get_set_rss_key *)&desc.params.raw;
503 u16 key_size = sizeof(struct iavf_aqc_get_set_rss_key_data);
506 iavf_fill_default_direct_cmd_desc(&desc,
507 iavf_aqc_opc_set_rss_key);
509 iavf_fill_default_direct_cmd_desc(&desc,
510 iavf_aqc_opc_get_rss_key);
512 /* Indirect command */
513 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_BUF);
514 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_RD);
517 CPU_TO_LE16((u16)((vsi_id <<
518 IAVF_AQC_SET_RSS_KEY_VSI_ID_SHIFT) &
519 IAVF_AQC_SET_RSS_KEY_VSI_ID_MASK));
520 cmd_resp->vsi_id |= CPU_TO_LE16((u16)IAVF_AQC_SET_RSS_KEY_VSI_VALID);
522 status = iavf_asq_send_command(hw, &desc, key, key_size, NULL);
528 * iavf_aq_get_rss_key
529 * @hw: pointer to the hw struct
530 * @vsi_id: vsi fw index
531 * @key: pointer to key info struct
534 enum iavf_status_code iavf_aq_get_rss_key(struct iavf_hw *hw,
536 struct iavf_aqc_get_set_rss_key_data *key)
538 return iavf_aq_get_set_rss_key(hw, vsi_id, key, false);
542 * iavf_aq_set_rss_key
543 * @hw: pointer to the hw struct
544 * @vsi_id: vsi fw index
545 * @key: pointer to key info struct
547 * set the RSS key per VSI
549 enum iavf_status_code iavf_aq_set_rss_key(struct iavf_hw *hw,
551 struct iavf_aqc_get_set_rss_key_data *key)
553 return iavf_aq_get_set_rss_key(hw, vsi_id, key, true);
556 /* The iavf_ptype_lookup table is used to convert from the 8-bit ptype in the
557 * hardware to a bit-field that can be used by SW to more easily determine the
560 * Macros are used to shorten the table lines and make this table human
563 * We store the PTYPE in the top byte of the bit field - this is just so that
564 * we can check that the table doesn't have a row missing, as the index into
565 * the table should be the PTYPE.
569 * IF NOT iavf_ptype_lookup[ptype].known
572 * ELSE IF iavf_ptype_lookup[ptype].outer_ip == IAVF_RX_PTYPE_OUTER_IP
573 * Use the rest of the fields to look at the tunnels, inner protocols, etc
575 * Use the enum iavf_rx_l2_ptype to decode the packet type
579 /* macro to make the table lines short */
580 #define IAVF_PTT(PTYPE, OUTER_IP, OUTER_IP_VER, OUTER_FRAG, T, TE, TEF, I, PL)\
583 IAVF_RX_PTYPE_OUTER_##OUTER_IP, \
584 IAVF_RX_PTYPE_OUTER_##OUTER_IP_VER, \
585 IAVF_RX_PTYPE_##OUTER_FRAG, \
586 IAVF_RX_PTYPE_TUNNEL_##T, \
587 IAVF_RX_PTYPE_TUNNEL_END_##TE, \
588 IAVF_RX_PTYPE_##TEF, \
589 IAVF_RX_PTYPE_INNER_PROT_##I, \
590 IAVF_RX_PTYPE_PAYLOAD_LAYER_##PL }
592 #define IAVF_PTT_UNUSED_ENTRY(PTYPE) \
593 { PTYPE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
595 /* shorter macros makes the table fit but are terse */
596 #define IAVF_RX_PTYPE_NOF IAVF_RX_PTYPE_NOT_FRAG
597 #define IAVF_RX_PTYPE_FRG IAVF_RX_PTYPE_FRAG
598 #define IAVF_RX_PTYPE_INNER_PROT_TS IAVF_RX_PTYPE_INNER_PROT_TIMESYNC
600 /* Lookup table mapping the HW PTYPE to the bit field for decoding */
601 struct iavf_rx_ptype_decoded iavf_ptype_lookup[] = {
602 /* L2 Packet types */
603 IAVF_PTT_UNUSED_ENTRY(0),
604 IAVF_PTT(1, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
605 IAVF_PTT(2, L2, NONE, NOF, NONE, NONE, NOF, TS, PAY2),
606 IAVF_PTT(3, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
607 IAVF_PTT_UNUSED_ENTRY(4),
608 IAVF_PTT_UNUSED_ENTRY(5),
609 IAVF_PTT(6, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
610 IAVF_PTT(7, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
611 IAVF_PTT_UNUSED_ENTRY(8),
612 IAVF_PTT_UNUSED_ENTRY(9),
613 IAVF_PTT(10, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
614 IAVF_PTT(11, L2, NONE, NOF, NONE, NONE, NOF, NONE, NONE),
615 IAVF_PTT(12, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
616 IAVF_PTT(13, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
617 IAVF_PTT(14, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
618 IAVF_PTT(15, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
619 IAVF_PTT(16, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
620 IAVF_PTT(17, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
621 IAVF_PTT(18, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
622 IAVF_PTT(19, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
623 IAVF_PTT(20, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
624 IAVF_PTT(21, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
626 /* Non Tunneled IPv4 */
627 IAVF_PTT(22, IP, IPV4, FRG, NONE, NONE, NOF, NONE, PAY3),
628 IAVF_PTT(23, IP, IPV4, NOF, NONE, NONE, NOF, NONE, PAY3),
629 IAVF_PTT(24, IP, IPV4, NOF, NONE, NONE, NOF, UDP, PAY4),
630 IAVF_PTT_UNUSED_ENTRY(25),
631 IAVF_PTT(26, IP, IPV4, NOF, NONE, NONE, NOF, TCP, PAY4),
632 IAVF_PTT(27, IP, IPV4, NOF, NONE, NONE, NOF, SCTP, PAY4),
633 IAVF_PTT(28, IP, IPV4, NOF, NONE, NONE, NOF, ICMP, PAY4),
636 IAVF_PTT(29, IP, IPV4, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
637 IAVF_PTT(30, IP, IPV4, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
638 IAVF_PTT(31, IP, IPV4, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
639 IAVF_PTT_UNUSED_ENTRY(32),
640 IAVF_PTT(33, IP, IPV4, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
641 IAVF_PTT(34, IP, IPV4, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
642 IAVF_PTT(35, IP, IPV4, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
645 IAVF_PTT(36, IP, IPV4, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
646 IAVF_PTT(37, IP, IPV4, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
647 IAVF_PTT(38, IP, IPV4, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
648 IAVF_PTT_UNUSED_ENTRY(39),
649 IAVF_PTT(40, IP, IPV4, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
650 IAVF_PTT(41, IP, IPV4, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
651 IAVF_PTT(42, IP, IPV4, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
653 /* IPv4 --> GRE/NAT */
654 IAVF_PTT(43, IP, IPV4, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
656 /* IPv4 --> GRE/NAT --> IPv4 */
657 IAVF_PTT(44, IP, IPV4, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
658 IAVF_PTT(45, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
659 IAVF_PTT(46, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
660 IAVF_PTT_UNUSED_ENTRY(47),
661 IAVF_PTT(48, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
662 IAVF_PTT(49, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
663 IAVF_PTT(50, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
665 /* IPv4 --> GRE/NAT --> IPv6 */
666 IAVF_PTT(51, IP, IPV4, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
667 IAVF_PTT(52, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
668 IAVF_PTT(53, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
669 IAVF_PTT_UNUSED_ENTRY(54),
670 IAVF_PTT(55, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
671 IAVF_PTT(56, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
672 IAVF_PTT(57, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
674 /* IPv4 --> GRE/NAT --> MAC */
675 IAVF_PTT(58, IP, IPV4, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
677 /* IPv4 --> GRE/NAT --> MAC --> IPv4 */
678 IAVF_PTT(59, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
679 IAVF_PTT(60, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
680 IAVF_PTT(61, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
681 IAVF_PTT_UNUSED_ENTRY(62),
682 IAVF_PTT(63, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
683 IAVF_PTT(64, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
684 IAVF_PTT(65, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
686 /* IPv4 --> GRE/NAT -> MAC --> IPv6 */
687 IAVF_PTT(66, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
688 IAVF_PTT(67, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
689 IAVF_PTT(68, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
690 IAVF_PTT_UNUSED_ENTRY(69),
691 IAVF_PTT(70, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
692 IAVF_PTT(71, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
693 IAVF_PTT(72, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
695 /* IPv4 --> GRE/NAT --> MAC/VLAN */
696 IAVF_PTT(73, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
698 /* IPv4 ---> GRE/NAT -> MAC/VLAN --> IPv4 */
699 IAVF_PTT(74, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
700 IAVF_PTT(75, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
701 IAVF_PTT(76, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
702 IAVF_PTT_UNUSED_ENTRY(77),
703 IAVF_PTT(78, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
704 IAVF_PTT(79, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
705 IAVF_PTT(80, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
707 /* IPv4 -> GRE/NAT -> MAC/VLAN --> IPv6 */
708 IAVF_PTT(81, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
709 IAVF_PTT(82, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
710 IAVF_PTT(83, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
711 IAVF_PTT_UNUSED_ENTRY(84),
712 IAVF_PTT(85, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
713 IAVF_PTT(86, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
714 IAVF_PTT(87, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
716 /* Non Tunneled IPv6 */
717 IAVF_PTT(88, IP, IPV6, FRG, NONE, NONE, NOF, NONE, PAY3),
718 IAVF_PTT(89, IP, IPV6, NOF, NONE, NONE, NOF, NONE, PAY3),
719 IAVF_PTT(90, IP, IPV6, NOF, NONE, NONE, NOF, UDP, PAY4),
720 IAVF_PTT_UNUSED_ENTRY(91),
721 IAVF_PTT(92, IP, IPV6, NOF, NONE, NONE, NOF, TCP, PAY4),
722 IAVF_PTT(93, IP, IPV6, NOF, NONE, NONE, NOF, SCTP, PAY4),
723 IAVF_PTT(94, IP, IPV6, NOF, NONE, NONE, NOF, ICMP, PAY4),
726 IAVF_PTT(95, IP, IPV6, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
727 IAVF_PTT(96, IP, IPV6, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
728 IAVF_PTT(97, IP, IPV6, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
729 IAVF_PTT_UNUSED_ENTRY(98),
730 IAVF_PTT(99, IP, IPV6, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
731 IAVF_PTT(100, IP, IPV6, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
732 IAVF_PTT(101, IP, IPV6, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
735 IAVF_PTT(102, IP, IPV6, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
736 IAVF_PTT(103, IP, IPV6, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
737 IAVF_PTT(104, IP, IPV6, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
738 IAVF_PTT_UNUSED_ENTRY(105),
739 IAVF_PTT(106, IP, IPV6, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
740 IAVF_PTT(107, IP, IPV6, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
741 IAVF_PTT(108, IP, IPV6, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
743 /* IPv6 --> GRE/NAT */
744 IAVF_PTT(109, IP, IPV6, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
746 /* IPv6 --> GRE/NAT -> IPv4 */
747 IAVF_PTT(110, IP, IPV6, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
748 IAVF_PTT(111, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
749 IAVF_PTT(112, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
750 IAVF_PTT_UNUSED_ENTRY(113),
751 IAVF_PTT(114, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
752 IAVF_PTT(115, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
753 IAVF_PTT(116, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
755 /* IPv6 --> GRE/NAT -> IPv6 */
756 IAVF_PTT(117, IP, IPV6, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
757 IAVF_PTT(118, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
758 IAVF_PTT(119, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
759 IAVF_PTT_UNUSED_ENTRY(120),
760 IAVF_PTT(121, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
761 IAVF_PTT(122, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
762 IAVF_PTT(123, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
764 /* IPv6 --> GRE/NAT -> MAC */
765 IAVF_PTT(124, IP, IPV6, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
767 /* IPv6 --> GRE/NAT -> MAC -> IPv4 */
768 IAVF_PTT(125, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
769 IAVF_PTT(126, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
770 IAVF_PTT(127, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
771 IAVF_PTT_UNUSED_ENTRY(128),
772 IAVF_PTT(129, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
773 IAVF_PTT(130, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
774 IAVF_PTT(131, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
776 /* IPv6 --> GRE/NAT -> MAC -> IPv6 */
777 IAVF_PTT(132, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
778 IAVF_PTT(133, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
779 IAVF_PTT(134, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
780 IAVF_PTT_UNUSED_ENTRY(135),
781 IAVF_PTT(136, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
782 IAVF_PTT(137, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
783 IAVF_PTT(138, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
785 /* IPv6 --> GRE/NAT -> MAC/VLAN */
786 IAVF_PTT(139, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
788 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv4 */
789 IAVF_PTT(140, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
790 IAVF_PTT(141, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
791 IAVF_PTT(142, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
792 IAVF_PTT_UNUSED_ENTRY(143),
793 IAVF_PTT(144, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
794 IAVF_PTT(145, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
795 IAVF_PTT(146, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
797 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv6 */
798 IAVF_PTT(147, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
799 IAVF_PTT(148, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
800 IAVF_PTT(149, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
801 IAVF_PTT_UNUSED_ENTRY(150),
802 IAVF_PTT(151, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
803 IAVF_PTT(152, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
804 IAVF_PTT(153, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
807 IAVF_PTT_UNUSED_ENTRY(154),
808 IAVF_PTT_UNUSED_ENTRY(155),
809 IAVF_PTT_UNUSED_ENTRY(156),
810 IAVF_PTT_UNUSED_ENTRY(157),
811 IAVF_PTT_UNUSED_ENTRY(158),
812 IAVF_PTT_UNUSED_ENTRY(159),
814 IAVF_PTT_UNUSED_ENTRY(160),
815 IAVF_PTT_UNUSED_ENTRY(161),
816 IAVF_PTT_UNUSED_ENTRY(162),
817 IAVF_PTT_UNUSED_ENTRY(163),
818 IAVF_PTT_UNUSED_ENTRY(164),
819 IAVF_PTT_UNUSED_ENTRY(165),
820 IAVF_PTT_UNUSED_ENTRY(166),
821 IAVF_PTT_UNUSED_ENTRY(167),
822 IAVF_PTT_UNUSED_ENTRY(168),
823 IAVF_PTT_UNUSED_ENTRY(169),
825 IAVF_PTT_UNUSED_ENTRY(170),
826 IAVF_PTT_UNUSED_ENTRY(171),
827 IAVF_PTT_UNUSED_ENTRY(172),
828 IAVF_PTT_UNUSED_ENTRY(173),
829 IAVF_PTT_UNUSED_ENTRY(174),
830 IAVF_PTT_UNUSED_ENTRY(175),
831 IAVF_PTT_UNUSED_ENTRY(176),
832 IAVF_PTT_UNUSED_ENTRY(177),
833 IAVF_PTT_UNUSED_ENTRY(178),
834 IAVF_PTT_UNUSED_ENTRY(179),
836 IAVF_PTT_UNUSED_ENTRY(180),
837 IAVF_PTT_UNUSED_ENTRY(181),
838 IAVF_PTT_UNUSED_ENTRY(182),
839 IAVF_PTT_UNUSED_ENTRY(183),
840 IAVF_PTT_UNUSED_ENTRY(184),
841 IAVF_PTT_UNUSED_ENTRY(185),
842 IAVF_PTT_UNUSED_ENTRY(186),
843 IAVF_PTT_UNUSED_ENTRY(187),
844 IAVF_PTT_UNUSED_ENTRY(188),
845 IAVF_PTT_UNUSED_ENTRY(189),
847 IAVF_PTT_UNUSED_ENTRY(190),
848 IAVF_PTT_UNUSED_ENTRY(191),
849 IAVF_PTT_UNUSED_ENTRY(192),
850 IAVF_PTT_UNUSED_ENTRY(193),
851 IAVF_PTT_UNUSED_ENTRY(194),
852 IAVF_PTT_UNUSED_ENTRY(195),
853 IAVF_PTT_UNUSED_ENTRY(196),
854 IAVF_PTT_UNUSED_ENTRY(197),
855 IAVF_PTT_UNUSED_ENTRY(198),
856 IAVF_PTT_UNUSED_ENTRY(199),
858 IAVF_PTT_UNUSED_ENTRY(200),
859 IAVF_PTT_UNUSED_ENTRY(201),
860 IAVF_PTT_UNUSED_ENTRY(202),
861 IAVF_PTT_UNUSED_ENTRY(203),
862 IAVF_PTT_UNUSED_ENTRY(204),
863 IAVF_PTT_UNUSED_ENTRY(205),
864 IAVF_PTT_UNUSED_ENTRY(206),
865 IAVF_PTT_UNUSED_ENTRY(207),
866 IAVF_PTT_UNUSED_ENTRY(208),
867 IAVF_PTT_UNUSED_ENTRY(209),
869 IAVF_PTT_UNUSED_ENTRY(210),
870 IAVF_PTT_UNUSED_ENTRY(211),
871 IAVF_PTT_UNUSED_ENTRY(212),
872 IAVF_PTT_UNUSED_ENTRY(213),
873 IAVF_PTT_UNUSED_ENTRY(214),
874 IAVF_PTT_UNUSED_ENTRY(215),
875 IAVF_PTT_UNUSED_ENTRY(216),
876 IAVF_PTT_UNUSED_ENTRY(217),
877 IAVF_PTT_UNUSED_ENTRY(218),
878 IAVF_PTT_UNUSED_ENTRY(219),
880 IAVF_PTT_UNUSED_ENTRY(220),
881 IAVF_PTT_UNUSED_ENTRY(221),
882 IAVF_PTT_UNUSED_ENTRY(222),
883 IAVF_PTT_UNUSED_ENTRY(223),
884 IAVF_PTT_UNUSED_ENTRY(224),
885 IAVF_PTT_UNUSED_ENTRY(225),
886 IAVF_PTT_UNUSED_ENTRY(226),
887 IAVF_PTT_UNUSED_ENTRY(227),
888 IAVF_PTT_UNUSED_ENTRY(228),
889 IAVF_PTT_UNUSED_ENTRY(229),
891 IAVF_PTT_UNUSED_ENTRY(230),
892 IAVF_PTT_UNUSED_ENTRY(231),
893 IAVF_PTT_UNUSED_ENTRY(232),
894 IAVF_PTT_UNUSED_ENTRY(233),
895 IAVF_PTT_UNUSED_ENTRY(234),
896 IAVF_PTT_UNUSED_ENTRY(235),
897 IAVF_PTT_UNUSED_ENTRY(236),
898 IAVF_PTT_UNUSED_ENTRY(237),
899 IAVF_PTT_UNUSED_ENTRY(238),
900 IAVF_PTT_UNUSED_ENTRY(239),
902 IAVF_PTT_UNUSED_ENTRY(240),
903 IAVF_PTT_UNUSED_ENTRY(241),
904 IAVF_PTT_UNUSED_ENTRY(242),
905 IAVF_PTT_UNUSED_ENTRY(243),
906 IAVF_PTT_UNUSED_ENTRY(244),
907 IAVF_PTT_UNUSED_ENTRY(245),
908 IAVF_PTT_UNUSED_ENTRY(246),
909 IAVF_PTT_UNUSED_ENTRY(247),
910 IAVF_PTT_UNUSED_ENTRY(248),
911 IAVF_PTT_UNUSED_ENTRY(249),
913 IAVF_PTT_UNUSED_ENTRY(250),
914 IAVF_PTT_UNUSED_ENTRY(251),
915 IAVF_PTT_UNUSED_ENTRY(252),
916 IAVF_PTT_UNUSED_ENTRY(253),
917 IAVF_PTT_UNUSED_ENTRY(254),
918 IAVF_PTT_UNUSED_ENTRY(255)
923 * iavf_validate_mac_addr - Validate unicast MAC address
924 * @mac_addr: pointer to MAC address
926 * Tests a MAC address to ensure it is a valid Individual Address
928 enum iavf_status_code iavf_validate_mac_addr(u8 *mac_addr)
930 enum iavf_status_code status = IAVF_SUCCESS;
932 DEBUGFUNC("iavf_validate_mac_addr");
934 /* Broadcast addresses ARE multicast addresses
935 * Make sure it is not a multicast address
936 * Reject the zero address
938 if (IAVF_IS_MULTICAST(mac_addr) ||
939 (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&
940 mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0))
941 status = IAVF_ERR_INVALID_MAC_ADDR;
947 * iavf_aq_rx_ctl_read_register - use FW to read from an Rx control register
948 * @hw: pointer to the hw struct
949 * @reg_addr: register address
950 * @reg_val: ptr to register value
951 * @cmd_details: pointer to command details structure or NULL
953 * Use the firmware to read the Rx control register,
954 * especially useful if the Rx unit is under heavy pressure
956 enum iavf_status_code iavf_aq_rx_ctl_read_register(struct iavf_hw *hw,
957 u32 reg_addr, u32 *reg_val,
958 struct iavf_asq_cmd_details *cmd_details)
960 struct iavf_aq_desc desc;
961 struct iavf_aqc_rx_ctl_reg_read_write *cmd_resp =
962 (struct iavf_aqc_rx_ctl_reg_read_write *)&desc.params.raw;
963 enum iavf_status_code status;
966 return IAVF_ERR_PARAM;
968 iavf_fill_default_direct_cmd_desc(&desc, iavf_aqc_opc_rx_ctl_reg_read);
970 cmd_resp->address = CPU_TO_LE32(reg_addr);
972 status = iavf_asq_send_command(hw, &desc, NULL, 0, cmd_details);
974 if (status == IAVF_SUCCESS)
975 *reg_val = LE32_TO_CPU(cmd_resp->value);
981 * iavf_read_rx_ctl - read from an Rx control register
982 * @hw: pointer to the hw struct
983 * @reg_addr: register address
985 u32 iavf_read_rx_ctl(struct iavf_hw *hw, u32 reg_addr)
987 enum iavf_status_code status = IAVF_SUCCESS;
992 use_register = (((hw->aq.api_maj_ver == 1) &&
993 (hw->aq.api_min_ver < 5)) ||
994 (hw->mac.type == IAVF_MAC_X722));
997 status = iavf_aq_rx_ctl_read_register(hw, reg_addr, &val, NULL);
998 if (hw->aq.asq_last_status == IAVF_AQ_RC_EAGAIN && retry) {
1005 /* if the AQ access failed, try the old-fashioned way */
1006 if (status || use_register)
1007 val = rd32(hw, reg_addr);
1013 * iavf_aq_rx_ctl_write_register
1014 * @hw: pointer to the hw struct
1015 * @reg_addr: register address
1016 * @reg_val: register value
1017 * @cmd_details: pointer to command details structure or NULL
1019 * Use the firmware to write to an Rx control register,
1020 * especially useful if the Rx unit is under heavy pressure
1022 enum iavf_status_code iavf_aq_rx_ctl_write_register(struct iavf_hw *hw,
1023 u32 reg_addr, u32 reg_val,
1024 struct iavf_asq_cmd_details *cmd_details)
1026 struct iavf_aq_desc desc;
1027 struct iavf_aqc_rx_ctl_reg_read_write *cmd =
1028 (struct iavf_aqc_rx_ctl_reg_read_write *)&desc.params.raw;
1029 enum iavf_status_code status;
1031 iavf_fill_default_direct_cmd_desc(&desc, iavf_aqc_opc_rx_ctl_reg_write);
1033 cmd->address = CPU_TO_LE32(reg_addr);
1034 cmd->value = CPU_TO_LE32(reg_val);
1036 status = iavf_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1042 * iavf_write_rx_ctl - write to an Rx control register
1043 * @hw: pointer to the hw struct
1044 * @reg_addr: register address
1045 * @reg_val: register value
1047 void iavf_write_rx_ctl(struct iavf_hw *hw, u32 reg_addr, u32 reg_val)
1049 enum iavf_status_code status = IAVF_SUCCESS;
1053 use_register = (((hw->aq.api_maj_ver == 1) &&
1054 (hw->aq.api_min_ver < 5)) ||
1055 (hw->mac.type == IAVF_MAC_X722));
1056 if (!use_register) {
1058 status = iavf_aq_rx_ctl_write_register(hw, reg_addr,
1060 if (hw->aq.asq_last_status == IAVF_AQ_RC_EAGAIN && retry) {
1067 /* if the AQ access failed, try the old-fashioned way */
1068 if (status || use_register)
1069 wr32(hw, reg_addr, reg_val);
1073 * iavf_aq_set_phy_register
1074 * @hw: pointer to the hw struct
1075 * @phy_select: select which phy should be accessed
1076 * @dev_addr: PHY device address
1077 * @reg_addr: PHY register address
1078 * @reg_val: new register value
1079 * @cmd_details: pointer to command details structure or NULL
1081 * Write the external PHY register.
1083 enum iavf_status_code iavf_aq_set_phy_register(struct iavf_hw *hw,
1084 u8 phy_select, u8 dev_addr,
1085 u32 reg_addr, u32 reg_val,
1086 struct iavf_asq_cmd_details *cmd_details)
1088 struct iavf_aq_desc desc;
1089 struct iavf_aqc_phy_register_access *cmd =
1090 (struct iavf_aqc_phy_register_access *)&desc.params.raw;
1091 enum iavf_status_code status;
1093 iavf_fill_default_direct_cmd_desc(&desc,
1094 iavf_aqc_opc_set_phy_register);
1096 cmd->phy_interface = phy_select;
1097 cmd->dev_addres = dev_addr;
1098 cmd->reg_address = CPU_TO_LE32(reg_addr);
1099 cmd->reg_value = CPU_TO_LE32(reg_val);
1101 status = iavf_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1107 * iavf_aq_get_phy_register
1108 * @hw: pointer to the hw struct
1109 * @phy_select: select which phy should be accessed
1110 * @dev_addr: PHY device address
1111 * @reg_addr: PHY register address
1112 * @reg_val: read register value
1113 * @cmd_details: pointer to command details structure or NULL
1115 * Read the external PHY register.
1117 enum iavf_status_code iavf_aq_get_phy_register(struct iavf_hw *hw,
1118 u8 phy_select, u8 dev_addr,
1119 u32 reg_addr, u32 *reg_val,
1120 struct iavf_asq_cmd_details *cmd_details)
1122 struct iavf_aq_desc desc;
1123 struct iavf_aqc_phy_register_access *cmd =
1124 (struct iavf_aqc_phy_register_access *)&desc.params.raw;
1125 enum iavf_status_code status;
1127 iavf_fill_default_direct_cmd_desc(&desc,
1128 iavf_aqc_opc_get_phy_register);
1130 cmd->phy_interface = phy_select;
1131 cmd->dev_addres = dev_addr;
1132 cmd->reg_address = CPU_TO_LE32(reg_addr);
1134 status = iavf_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1136 *reg_val = LE32_TO_CPU(cmd->reg_value);
1143 * iavf_aq_send_msg_to_pf
1144 * @hw: pointer to the hardware structure
1145 * @v_opcode: opcodes for VF-PF communication
1146 * @v_retval: return error code
1147 * @msg: pointer to the msg buffer
1148 * @msglen: msg length
1149 * @cmd_details: pointer to command details
1151 * Send message to PF driver using admin queue. By default, this message
1152 * is sent asynchronously, i.e. iavf_asq_send_command() does not wait for
1153 * completion before returning.
1155 enum iavf_status_code iavf_aq_send_msg_to_pf(struct iavf_hw *hw,
1156 enum virtchnl_ops v_opcode,
1157 enum iavf_status_code v_retval,
1158 u8 *msg, u16 msglen,
1159 struct iavf_asq_cmd_details *cmd_details)
1161 struct iavf_aq_desc desc;
1162 struct iavf_asq_cmd_details details;
1163 enum iavf_status_code status;
1165 iavf_fill_default_direct_cmd_desc(&desc, iavf_aqc_opc_send_msg_to_pf);
1166 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_SI);
1167 desc.cookie_high = CPU_TO_LE32(v_opcode);
1168 desc.cookie_low = CPU_TO_LE32(v_retval);
1170 desc.flags |= CPU_TO_LE16((u16)(IAVF_AQ_FLAG_BUF
1171 | IAVF_AQ_FLAG_RD));
1172 if (msglen > IAVF_AQ_LARGE_BUF)
1173 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_LB);
1174 desc.datalen = CPU_TO_LE16(msglen);
1177 iavf_memset(&details, 0, sizeof(details), IAVF_NONDMA_MEM);
1178 details.async = true;
1179 cmd_details = &details;
1181 status = iavf_asq_send_command(hw, (struct iavf_aq_desc *)&desc, msg,
1182 msglen, cmd_details);
1187 * iavf_parse_hw_config
1188 * @hw: pointer to the hardware structure
1189 * @msg: pointer to the virtual channel VF resource structure
1191 * Given a VF resource message from the PF, populate the hw struct
1192 * with appropriate information.
1194 void iavf_parse_hw_config(struct iavf_hw *hw,
1195 struct virtchnl_vf_resource *msg)
1197 struct virtchnl_vsi_resource *vsi_res;
1200 vsi_res = &msg->vsi_res[0];
1202 hw->dev_caps.num_vsis = msg->num_vsis;
1203 hw->dev_caps.num_rx_qp = msg->num_queue_pairs;
1204 hw->dev_caps.num_tx_qp = msg->num_queue_pairs;
1205 hw->dev_caps.num_msix_vectors_vf = msg->max_vectors;
1206 hw->dev_caps.dcb = msg->vf_cap_flags &
1207 VIRTCHNL_VF_OFFLOAD_L2;
1208 hw->dev_caps.iwarp = (msg->vf_cap_flags &
1209 VIRTCHNL_VF_OFFLOAD_IWARP) ? 1 : 0;
1210 for (i = 0; i < msg->num_vsis; i++) {
1211 if (vsi_res->vsi_type == VIRTCHNL_VSI_SRIOV) {
1212 iavf_memcpy(hw->mac.perm_addr,
1213 vsi_res->default_mac_addr,
1215 IAVF_NONDMA_TO_NONDMA);
1216 iavf_memcpy(hw->mac.addr, vsi_res->default_mac_addr,
1218 IAVF_NONDMA_TO_NONDMA);
1226 * @hw: pointer to the hardware structure
1228 * Send a VF_RESET message to the PF. Does not wait for response from PF
1229 * as none will be forthcoming. Immediately after calling this function,
1230 * the admin queue should be shut down and (optionally) reinitialized.
1232 enum iavf_status_code iavf_reset(struct iavf_hw *hw)
1234 return iavf_aq_send_msg_to_pf(hw, VIRTCHNL_OP_RESET_VF,
1235 IAVF_SUCCESS, NULL, 0, NULL);
1239 * iavf_aq_set_arp_proxy_config
1240 * @hw: pointer to the HW structure
1241 * @proxy_config: pointer to proxy config command table struct
1242 * @cmd_details: pointer to command details
1244 * Set ARP offload parameters from pre-populated
1245 * iavf_aqc_arp_proxy_data struct
1247 enum iavf_status_code iavf_aq_set_arp_proxy_config(struct iavf_hw *hw,
1248 struct iavf_aqc_arp_proxy_data *proxy_config,
1249 struct iavf_asq_cmd_details *cmd_details)
1251 struct iavf_aq_desc desc;
1252 enum iavf_status_code status;
1255 return IAVF_ERR_PARAM;
1257 iavf_fill_default_direct_cmd_desc(&desc, iavf_aqc_opc_set_proxy_config);
1259 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_BUF);
1260 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_RD);
1261 desc.params.external.addr_high =
1262 CPU_TO_LE32(IAVF_HI_DWORD((u64)proxy_config));
1263 desc.params.external.addr_low =
1264 CPU_TO_LE32(IAVF_LO_DWORD((u64)proxy_config));
1265 desc.datalen = CPU_TO_LE16(sizeof(struct iavf_aqc_arp_proxy_data));
1267 status = iavf_asq_send_command(hw, &desc, proxy_config,
1268 sizeof(struct iavf_aqc_arp_proxy_data),
1275 * iavf_aq_opc_set_ns_proxy_table_entry
1276 * @hw: pointer to the HW structure
1277 * @ns_proxy_table_entry: pointer to NS table entry command struct
1278 * @cmd_details: pointer to command details
1280 * Set IPv6 Neighbor Solicitation (NS) protocol offload parameters
1281 * from pre-populated iavf_aqc_ns_proxy_data struct
1283 enum iavf_status_code iavf_aq_set_ns_proxy_table_entry(struct iavf_hw *hw,
1284 struct iavf_aqc_ns_proxy_data *ns_proxy_table_entry,
1285 struct iavf_asq_cmd_details *cmd_details)
1287 struct iavf_aq_desc desc;
1288 enum iavf_status_code status;
1290 if (!ns_proxy_table_entry)
1291 return IAVF_ERR_PARAM;
1293 iavf_fill_default_direct_cmd_desc(&desc,
1294 iavf_aqc_opc_set_ns_proxy_table_entry);
1296 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_BUF);
1297 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_RD);
1298 desc.params.external.addr_high =
1299 CPU_TO_LE32(IAVF_HI_DWORD((u64)ns_proxy_table_entry));
1300 desc.params.external.addr_low =
1301 CPU_TO_LE32(IAVF_LO_DWORD((u64)ns_proxy_table_entry));
1302 desc.datalen = CPU_TO_LE16(sizeof(struct iavf_aqc_ns_proxy_data));
1304 status = iavf_asq_send_command(hw, &desc, ns_proxy_table_entry,
1305 sizeof(struct iavf_aqc_ns_proxy_data),
1312 * iavf_aq_set_clear_wol_filter
1313 * @hw: pointer to the hw struct
1314 * @filter_index: index of filter to modify (0-7)
1315 * @filter: buffer containing filter to be set
1316 * @set_filter: true to set filter, false to clear filter
1317 * @no_wol_tco: if true, pass through packets cannot cause wake-up
1318 * if false, pass through packets may cause wake-up
1319 * @filter_valid: true if filter action is valid
1320 * @no_wol_tco_valid: true if no WoL in TCO traffic action valid
1321 * @cmd_details: pointer to command details structure or NULL
1323 * Set or clear WoL filter for port attached to the PF
1325 enum iavf_status_code iavf_aq_set_clear_wol_filter(struct iavf_hw *hw,
1327 struct iavf_aqc_set_wol_filter_data *filter,
1328 bool set_filter, bool no_wol_tco,
1329 bool filter_valid, bool no_wol_tco_valid,
1330 struct iavf_asq_cmd_details *cmd_details)
1332 struct iavf_aq_desc desc;
1333 struct iavf_aqc_set_wol_filter *cmd =
1334 (struct iavf_aqc_set_wol_filter *)&desc.params.raw;
1335 enum iavf_status_code status;
1337 u16 valid_flags = 0;
1340 iavf_fill_default_direct_cmd_desc(&desc, iavf_aqc_opc_set_wol_filter);
1342 if (filter_index >= IAVF_AQC_MAX_NUM_WOL_FILTERS)
1343 return IAVF_ERR_PARAM;
1344 cmd->filter_index = CPU_TO_LE16(filter_index);
1348 return IAVF_ERR_PARAM;
1350 cmd_flags |= IAVF_AQC_SET_WOL_FILTER;
1351 cmd_flags |= IAVF_AQC_SET_WOL_FILTER_WOL_PRESERVE_ON_PFR;
1355 cmd_flags |= IAVF_AQC_SET_WOL_FILTER_NO_TCO_WOL;
1356 cmd->cmd_flags = CPU_TO_LE16(cmd_flags);
1359 valid_flags |= IAVF_AQC_SET_WOL_FILTER_ACTION_VALID;
1360 if (no_wol_tco_valid)
1361 valid_flags |= IAVF_AQC_SET_WOL_FILTER_NO_TCO_ACTION_VALID;
1362 cmd->valid_flags = CPU_TO_LE16(valid_flags);
1364 buff_len = sizeof(*filter);
1365 desc.datalen = CPU_TO_LE16(buff_len);
1367 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_BUF);
1368 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_RD);
1370 cmd->address_high = CPU_TO_LE32(IAVF_HI_DWORD((u64)filter));
1371 cmd->address_low = CPU_TO_LE32(IAVF_LO_DWORD((u64)filter));
1373 status = iavf_asq_send_command(hw, &desc, filter,
1374 buff_len, cmd_details);
1380 * iavf_aq_get_wake_event_reason
1381 * @hw: pointer to the hw struct
1382 * @wake_reason: return value, index of matching filter
1383 * @cmd_details: pointer to command details structure or NULL
1385 * Get information for the reason of a Wake Up event
1387 enum iavf_status_code iavf_aq_get_wake_event_reason(struct iavf_hw *hw,
1389 struct iavf_asq_cmd_details *cmd_details)
1391 struct iavf_aq_desc desc;
1392 struct iavf_aqc_get_wake_reason_completion *resp =
1393 (struct iavf_aqc_get_wake_reason_completion *)&desc.params.raw;
1394 enum iavf_status_code status;
1396 iavf_fill_default_direct_cmd_desc(&desc, iavf_aqc_opc_get_wake_reason);
1398 status = iavf_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1400 if (status == IAVF_SUCCESS)
1401 *wake_reason = LE16_TO_CPU(resp->wake_reason);
1407 * iavf_aq_clear_all_wol_filters
1408 * @hw: pointer to the hw struct
1409 * @cmd_details: pointer to command details structure or NULL
1411 * Get information for the reason of a Wake Up event
1413 enum iavf_status_code iavf_aq_clear_all_wol_filters(struct iavf_hw *hw,
1414 struct iavf_asq_cmd_details *cmd_details)
1416 struct iavf_aq_desc desc;
1417 enum iavf_status_code status;
1419 iavf_fill_default_direct_cmd_desc(&desc,
1420 iavf_aqc_opc_clear_all_wol_filters);
1422 status = iavf_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1428 * iavf_aq_write_ddp - Write dynamic device personalization (ddp)
1429 * @hw: pointer to the hw struct
1430 * @buff: command buffer (size in bytes = buff_size)
1431 * @buff_size: buffer size in bytes
1432 * @track_id: package tracking id
1433 * @error_offset: returns error offset
1434 * @error_info: returns error information
1435 * @cmd_details: pointer to command details structure or NULL
1438 iavf_status_code iavf_aq_write_ddp(struct iavf_hw *hw, void *buff,
1439 u16 buff_size, u32 track_id,
1440 u32 *error_offset, u32 *error_info,
1441 struct iavf_asq_cmd_details *cmd_details)
1443 struct iavf_aq_desc desc;
1444 struct iavf_aqc_write_personalization_profile *cmd =
1445 (struct iavf_aqc_write_personalization_profile *)
1447 struct iavf_aqc_write_ddp_resp *resp;
1448 enum iavf_status_code status;
1450 iavf_fill_default_direct_cmd_desc(&desc,
1451 iavf_aqc_opc_write_personalization_profile);
1453 desc.flags |= CPU_TO_LE16(IAVF_AQ_FLAG_BUF | IAVF_AQ_FLAG_RD);
1454 if (buff_size > IAVF_AQ_LARGE_BUF)
1455 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_LB);
1457 desc.datalen = CPU_TO_LE16(buff_size);
1459 cmd->profile_track_id = CPU_TO_LE32(track_id);
1461 status = iavf_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
1463 resp = (struct iavf_aqc_write_ddp_resp *)&desc.params.raw;
1465 *error_offset = LE32_TO_CPU(resp->error_offset);
1467 *error_info = LE32_TO_CPU(resp->error_info);
1474 * iavf_aq_get_ddp_list - Read dynamic device personalization (ddp)
1475 * @hw: pointer to the hw struct
1476 * @buff: command buffer (size in bytes = buff_size)
1477 * @buff_size: buffer size in bytes
1478 * @flags: AdminQ command flags
1479 * @cmd_details: pointer to command details structure or NULL
1482 iavf_status_code iavf_aq_get_ddp_list(struct iavf_hw *hw, void *buff,
1483 u16 buff_size, u8 flags,
1484 struct iavf_asq_cmd_details *cmd_details)
1486 struct iavf_aq_desc desc;
1487 struct iavf_aqc_get_applied_profiles *cmd =
1488 (struct iavf_aqc_get_applied_profiles *)&desc.params.raw;
1489 enum iavf_status_code status;
1491 iavf_fill_default_direct_cmd_desc(&desc,
1492 iavf_aqc_opc_get_personalization_profile_list);
1494 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_BUF);
1495 if (buff_size > IAVF_AQ_LARGE_BUF)
1496 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_LB);
1497 desc.datalen = CPU_TO_LE16(buff_size);
1501 status = iavf_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
1507 * iavf_find_segment_in_package
1508 * @segment_type: the segment type to search for (i.e., SEGMENT_TYPE_IAVF)
1509 * @pkg_hdr: pointer to the package header to be searched
1511 * This function searches a package file for a particular segment type. On
1512 * success it returns a pointer to the segment header, otherwise it will
1515 struct iavf_generic_seg_header *
1516 iavf_find_segment_in_package(u32 segment_type,
1517 struct iavf_package_header *pkg_hdr)
1519 struct iavf_generic_seg_header *segment;
1522 /* Search all package segments for the requested segment type */
1523 for (i = 0; i < pkg_hdr->segment_count; i++) {
1525 (struct iavf_generic_seg_header *)((u8 *)pkg_hdr +
1526 pkg_hdr->segment_offset[i]);
1528 if (segment->type == segment_type)
1535 /* Get section table in profile */
1536 #define IAVF_SECTION_TABLE(profile, sec_tbl) \
1538 struct iavf_profile_segment *p = (profile); \
1541 count = p->device_table_count; \
1542 nvm = (u32 *)&p->device_table[count]; \
1543 sec_tbl = (struct iavf_section_table *)&nvm[nvm[0] + 1]; \
1546 /* Get section header in profile */
1547 #define IAVF_SECTION_HEADER(profile, offset) \
1548 (struct iavf_profile_section_header *)((u8 *)(profile) + (offset))
1551 * iavf_find_section_in_profile
1552 * @section_type: the section type to search for (i.e., SECTION_TYPE_NOTE)
1553 * @profile: pointer to the iavf segment header to be searched
1555 * This function searches iavf segment for a particular section type. On
1556 * success it returns a pointer to the section header, otherwise it will
1559 struct iavf_profile_section_header *
1560 iavf_find_section_in_profile(u32 section_type,
1561 struct iavf_profile_segment *profile)
1563 struct iavf_profile_section_header *sec;
1564 struct iavf_section_table *sec_tbl;
1568 if (profile->header.type != SEGMENT_TYPE_IAVF)
1571 IAVF_SECTION_TABLE(profile, sec_tbl);
1573 for (i = 0; i < sec_tbl->section_count; i++) {
1574 sec_off = sec_tbl->section_offset[i];
1575 sec = IAVF_SECTION_HEADER(profile, sec_off);
1576 if (sec->section.type == section_type)
1584 * iavf_ddp_exec_aq_section - Execute generic AQ for DDP
1585 * @hw: pointer to the hw struct
1586 * @aq: command buffer containing all data to execute AQ
1589 iavf_status_code iavf_ddp_exec_aq_section(struct iavf_hw *hw,
1590 struct iavf_profile_aq_section *aq)
1592 enum iavf_status_code status;
1593 struct iavf_aq_desc desc;
1597 iavf_fill_default_direct_cmd_desc(&desc, aq->opcode);
1598 desc.flags |= CPU_TO_LE16(aq->flags);
1599 iavf_memcpy(desc.params.raw, aq->param, sizeof(desc.params.raw),
1600 IAVF_NONDMA_TO_NONDMA);
1602 msglen = aq->datalen;
1604 desc.flags |= CPU_TO_LE16((u16)(IAVF_AQ_FLAG_BUF |
1606 if (msglen > IAVF_AQ_LARGE_BUF)
1607 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_LB);
1608 desc.datalen = CPU_TO_LE16(msglen);
1612 status = iavf_asq_send_command(hw, &desc, msg, msglen, NULL);
1614 if (status != IAVF_SUCCESS) {
1615 iavf_debug(hw, IAVF_DEBUG_PACKAGE,
1616 "unable to exec DDP AQ opcode %u, error %d\n",
1617 aq->opcode, status);
1621 /* copy returned desc to aq_buf */
1622 iavf_memcpy(aq->param, desc.params.raw, sizeof(desc.params.raw),
1623 IAVF_NONDMA_TO_NONDMA);
1625 return IAVF_SUCCESS;
1629 * iavf_validate_profile
1630 * @hw: pointer to the hardware structure
1631 * @profile: pointer to the profile segment of the package to be validated
1632 * @track_id: package tracking id
1633 * @rollback: flag if the profile is for rollback.
1635 * Validates supported devices and profile's sections.
1637 STATIC enum iavf_status_code
1638 iavf_validate_profile(struct iavf_hw *hw, struct iavf_profile_segment *profile,
1639 u32 track_id, bool rollback)
1641 struct iavf_profile_section_header *sec = NULL;
1642 enum iavf_status_code status = IAVF_SUCCESS;
1643 struct iavf_section_table *sec_tbl;
1649 if (track_id == IAVF_DDP_TRACKID_INVALID) {
1650 iavf_debug(hw, IAVF_DEBUG_PACKAGE, "Invalid track_id\n");
1651 return IAVF_NOT_SUPPORTED;
1654 dev_cnt = profile->device_table_count;
1655 for (i = 0; i < dev_cnt; i++) {
1656 vendor_dev_id = profile->device_table[i].vendor_dev_id;
1657 if ((vendor_dev_id >> 16) == IAVF_INTEL_VENDOR_ID &&
1658 hw->device_id == (vendor_dev_id & 0xFFFF))
1661 if (dev_cnt && (i == dev_cnt)) {
1662 iavf_debug(hw, IAVF_DEBUG_PACKAGE,
1663 "Device doesn't support DDP\n");
1664 return IAVF_ERR_DEVICE_NOT_SUPPORTED;
1667 IAVF_SECTION_TABLE(profile, sec_tbl);
1669 /* Validate sections types */
1670 for (i = 0; i < sec_tbl->section_count; i++) {
1671 sec_off = sec_tbl->section_offset[i];
1672 sec = IAVF_SECTION_HEADER(profile, sec_off);
1674 if (sec->section.type == SECTION_TYPE_MMIO ||
1675 sec->section.type == SECTION_TYPE_AQ ||
1676 sec->section.type == SECTION_TYPE_RB_AQ) {
1677 iavf_debug(hw, IAVF_DEBUG_PACKAGE,
1678 "Not a roll-back package\n");
1679 return IAVF_NOT_SUPPORTED;
1682 if (sec->section.type == SECTION_TYPE_RB_AQ ||
1683 sec->section.type == SECTION_TYPE_RB_MMIO) {
1684 iavf_debug(hw, IAVF_DEBUG_PACKAGE,
1685 "Not an original package\n");
1686 return IAVF_NOT_SUPPORTED;
1695 * iavf_write_profile
1696 * @hw: pointer to the hardware structure
1697 * @profile: pointer to the profile segment of the package to be downloaded
1698 * @track_id: package tracking id
1700 * Handles the download of a complete package.
1702 enum iavf_status_code
1703 iavf_write_profile(struct iavf_hw *hw, struct iavf_profile_segment *profile,
1706 enum iavf_status_code status = IAVF_SUCCESS;
1707 struct iavf_section_table *sec_tbl;
1708 struct iavf_profile_section_header *sec = NULL;
1709 struct iavf_profile_aq_section *ddp_aq;
1710 u32 section_size = 0;
1711 u32 offset = 0, info = 0;
1715 status = iavf_validate_profile(hw, profile, track_id, false);
1719 IAVF_SECTION_TABLE(profile, sec_tbl);
1721 for (i = 0; i < sec_tbl->section_count; i++) {
1722 sec_off = sec_tbl->section_offset[i];
1723 sec = IAVF_SECTION_HEADER(profile, sec_off);
1724 /* Process generic admin command */
1725 if (sec->section.type == SECTION_TYPE_AQ) {
1726 ddp_aq = (struct iavf_profile_aq_section *)&sec[1];
1727 status = iavf_ddp_exec_aq_section(hw, ddp_aq);
1729 iavf_debug(hw, IAVF_DEBUG_PACKAGE,
1730 "Failed to execute aq: section %d, opcode %u\n",
1734 sec->section.type = SECTION_TYPE_RB_AQ;
1737 /* Skip any non-mmio sections */
1738 if (sec->section.type != SECTION_TYPE_MMIO)
1741 section_size = sec->section.size +
1742 sizeof(struct iavf_profile_section_header);
1744 /* Write MMIO section */
1745 status = iavf_aq_write_ddp(hw, (void *)sec, (u16)section_size,
1746 track_id, &offset, &info, NULL);
1748 iavf_debug(hw, IAVF_DEBUG_PACKAGE,
1749 "Failed to write profile: section %d, offset %d, info %d\n",
1758 * iavf_rollback_profile
1759 * @hw: pointer to the hardware structure
1760 * @profile: pointer to the profile segment of the package to be removed
1761 * @track_id: package tracking id
1763 * Rolls back previously loaded package.
1765 enum iavf_status_code
1766 iavf_rollback_profile(struct iavf_hw *hw, struct iavf_profile_segment *profile,
1769 struct iavf_profile_section_header *sec = NULL;
1770 enum iavf_status_code status = IAVF_SUCCESS;
1771 struct iavf_section_table *sec_tbl;
1772 u32 offset = 0, info = 0;
1773 u32 section_size = 0;
1777 status = iavf_validate_profile(hw, profile, track_id, true);
1781 IAVF_SECTION_TABLE(profile, sec_tbl);
1783 /* For rollback write sections in reverse */
1784 for (i = sec_tbl->section_count - 1; i >= 0; i--) {
1785 sec_off = sec_tbl->section_offset[i];
1786 sec = IAVF_SECTION_HEADER(profile, sec_off);
1788 /* Skip any non-rollback sections */
1789 if (sec->section.type != SECTION_TYPE_RB_MMIO)
1792 section_size = sec->section.size +
1793 sizeof(struct iavf_profile_section_header);
1795 /* Write roll-back MMIO section */
1796 status = iavf_aq_write_ddp(hw, (void *)sec, (u16)section_size,
1797 track_id, &offset, &info, NULL);
1799 iavf_debug(hw, IAVF_DEBUG_PACKAGE,
1800 "Failed to write profile: section %d, offset %d, info %d\n",
1809 * iavf_add_pinfo_to_list
1810 * @hw: pointer to the hardware structure
1811 * @profile: pointer to the profile segment of the package
1812 * @profile_info_sec: buffer for information section
1813 * @track_id: package tracking id
1815 * Register a profile to the list of loaded profiles.
1817 enum iavf_status_code
1818 iavf_add_pinfo_to_list(struct iavf_hw *hw,
1819 struct iavf_profile_segment *profile,
1820 u8 *profile_info_sec, u32 track_id)
1822 enum iavf_status_code status = IAVF_SUCCESS;
1823 struct iavf_profile_section_header *sec = NULL;
1824 struct iavf_profile_info *pinfo;
1825 u32 offset = 0, info = 0;
1827 sec = (struct iavf_profile_section_header *)profile_info_sec;
1829 sec->data_end = sizeof(struct iavf_profile_section_header) +
1830 sizeof(struct iavf_profile_info);
1831 sec->section.type = SECTION_TYPE_INFO;
1832 sec->section.offset = sizeof(struct iavf_profile_section_header);
1833 sec->section.size = sizeof(struct iavf_profile_info);
1834 pinfo = (struct iavf_profile_info *)(profile_info_sec +
1835 sec->section.offset);
1836 pinfo->track_id = track_id;
1837 pinfo->version = profile->version;
1838 pinfo->op = IAVF_DDP_ADD_TRACKID;
1839 iavf_memcpy(pinfo->name, profile->name, IAVF_DDP_NAME_SIZE,
1840 IAVF_NONDMA_TO_NONDMA);
1842 status = iavf_aq_write_ddp(hw, (void *)sec, sec->data_end,
1843 track_id, &offset, &info, NULL);