1 /*******************************************************************************
3 * Intel Ethernet Controller XL710 Family Linux Driver
4 * Copyright(c) 2013 - 2016 Intel Corporation.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 * The full GNU General Public License is included in this distribution in
19 * the file called "COPYING".
21 * Contact Information:
22 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 ******************************************************************************/
27 #include "i40e_type.h"
28 #include "i40e_adminq.h"
29 #include "i40e_prototype.h"
30 #include <linux/avf/virtchnl.h>
33 * i40e_set_mac_type - Sets MAC type
34 * @hw: pointer to the HW structure
36 * This function sets the mac type of the adapter based on the
37 * vendor ID and device ID stored in the hw structure.
39 static i40e_status i40e_set_mac_type(struct i40e_hw *hw)
41 i40e_status status = 0;
43 if (hw->vendor_id == PCI_VENDOR_ID_INTEL) {
44 switch (hw->device_id) {
45 case I40E_DEV_ID_SFP_XL710:
46 case I40E_DEV_ID_QEMU:
47 case I40E_DEV_ID_KX_B:
48 case I40E_DEV_ID_KX_C:
49 case I40E_DEV_ID_QSFP_A:
50 case I40E_DEV_ID_QSFP_B:
51 case I40E_DEV_ID_QSFP_C:
52 case I40E_DEV_ID_10G_BASE_T:
53 case I40E_DEV_ID_10G_BASE_T4:
54 case I40E_DEV_ID_20G_KR2:
55 case I40E_DEV_ID_20G_KR2_A:
56 case I40E_DEV_ID_25G_B:
57 case I40E_DEV_ID_25G_SFP28:
58 hw->mac.type = I40E_MAC_XL710;
60 case I40E_DEV_ID_KX_X722:
61 case I40E_DEV_ID_QSFP_X722:
62 case I40E_DEV_ID_SFP_X722:
63 case I40E_DEV_ID_1G_BASE_T_X722:
64 case I40E_DEV_ID_10G_BASE_T_X722:
65 case I40E_DEV_ID_SFP_I_X722:
66 hw->mac.type = I40E_MAC_X722;
69 hw->mac.type = I40E_MAC_GENERIC;
73 status = I40E_ERR_DEVICE_NOT_SUPPORTED;
76 hw_dbg(hw, "i40e_set_mac_type found mac: %d, returns: %d\n",
77 hw->mac.type, status);
82 * i40e_aq_str - convert AQ err code to a string
83 * @hw: pointer to the HW structure
84 * @aq_err: the AQ error code to convert
86 const char *i40e_aq_str(struct i40e_hw *hw, enum i40e_admin_queue_err aq_err)
91 case I40E_AQ_RC_EPERM:
92 return "I40E_AQ_RC_EPERM";
93 case I40E_AQ_RC_ENOENT:
94 return "I40E_AQ_RC_ENOENT";
95 case I40E_AQ_RC_ESRCH:
96 return "I40E_AQ_RC_ESRCH";
97 case I40E_AQ_RC_EINTR:
98 return "I40E_AQ_RC_EINTR";
100 return "I40E_AQ_RC_EIO";
101 case I40E_AQ_RC_ENXIO:
102 return "I40E_AQ_RC_ENXIO";
103 case I40E_AQ_RC_E2BIG:
104 return "I40E_AQ_RC_E2BIG";
105 case I40E_AQ_RC_EAGAIN:
106 return "I40E_AQ_RC_EAGAIN";
107 case I40E_AQ_RC_ENOMEM:
108 return "I40E_AQ_RC_ENOMEM";
109 case I40E_AQ_RC_EACCES:
110 return "I40E_AQ_RC_EACCES";
111 case I40E_AQ_RC_EFAULT:
112 return "I40E_AQ_RC_EFAULT";
113 case I40E_AQ_RC_EBUSY:
114 return "I40E_AQ_RC_EBUSY";
115 case I40E_AQ_RC_EEXIST:
116 return "I40E_AQ_RC_EEXIST";
117 case I40E_AQ_RC_EINVAL:
118 return "I40E_AQ_RC_EINVAL";
119 case I40E_AQ_RC_ENOTTY:
120 return "I40E_AQ_RC_ENOTTY";
121 case I40E_AQ_RC_ENOSPC:
122 return "I40E_AQ_RC_ENOSPC";
123 case I40E_AQ_RC_ENOSYS:
124 return "I40E_AQ_RC_ENOSYS";
125 case I40E_AQ_RC_ERANGE:
126 return "I40E_AQ_RC_ERANGE";
127 case I40E_AQ_RC_EFLUSHED:
128 return "I40E_AQ_RC_EFLUSHED";
129 case I40E_AQ_RC_BAD_ADDR:
130 return "I40E_AQ_RC_BAD_ADDR";
131 case I40E_AQ_RC_EMODE:
132 return "I40E_AQ_RC_EMODE";
133 case I40E_AQ_RC_EFBIG:
134 return "I40E_AQ_RC_EFBIG";
137 snprintf(hw->err_str, sizeof(hw->err_str), "%d", aq_err);
142 * i40e_stat_str - convert status err code to a string
143 * @hw: pointer to the HW structure
144 * @stat_err: the status error code to convert
146 const char *i40e_stat_str(struct i40e_hw *hw, i40e_status stat_err)
152 return "I40E_ERR_NVM";
153 case I40E_ERR_NVM_CHECKSUM:
154 return "I40E_ERR_NVM_CHECKSUM";
156 return "I40E_ERR_PHY";
157 case I40E_ERR_CONFIG:
158 return "I40E_ERR_CONFIG";
160 return "I40E_ERR_PARAM";
161 case I40E_ERR_MAC_TYPE:
162 return "I40E_ERR_MAC_TYPE";
163 case I40E_ERR_UNKNOWN_PHY:
164 return "I40E_ERR_UNKNOWN_PHY";
165 case I40E_ERR_LINK_SETUP:
166 return "I40E_ERR_LINK_SETUP";
167 case I40E_ERR_ADAPTER_STOPPED:
168 return "I40E_ERR_ADAPTER_STOPPED";
169 case I40E_ERR_INVALID_MAC_ADDR:
170 return "I40E_ERR_INVALID_MAC_ADDR";
171 case I40E_ERR_DEVICE_NOT_SUPPORTED:
172 return "I40E_ERR_DEVICE_NOT_SUPPORTED";
173 case I40E_ERR_MASTER_REQUESTS_PENDING:
174 return "I40E_ERR_MASTER_REQUESTS_PENDING";
175 case I40E_ERR_INVALID_LINK_SETTINGS:
176 return "I40E_ERR_INVALID_LINK_SETTINGS";
177 case I40E_ERR_AUTONEG_NOT_COMPLETE:
178 return "I40E_ERR_AUTONEG_NOT_COMPLETE";
179 case I40E_ERR_RESET_FAILED:
180 return "I40E_ERR_RESET_FAILED";
181 case I40E_ERR_SWFW_SYNC:
182 return "I40E_ERR_SWFW_SYNC";
183 case I40E_ERR_NO_AVAILABLE_VSI:
184 return "I40E_ERR_NO_AVAILABLE_VSI";
185 case I40E_ERR_NO_MEMORY:
186 return "I40E_ERR_NO_MEMORY";
187 case I40E_ERR_BAD_PTR:
188 return "I40E_ERR_BAD_PTR";
189 case I40E_ERR_RING_FULL:
190 return "I40E_ERR_RING_FULL";
191 case I40E_ERR_INVALID_PD_ID:
192 return "I40E_ERR_INVALID_PD_ID";
193 case I40E_ERR_INVALID_QP_ID:
194 return "I40E_ERR_INVALID_QP_ID";
195 case I40E_ERR_INVALID_CQ_ID:
196 return "I40E_ERR_INVALID_CQ_ID";
197 case I40E_ERR_INVALID_CEQ_ID:
198 return "I40E_ERR_INVALID_CEQ_ID";
199 case I40E_ERR_INVALID_AEQ_ID:
200 return "I40E_ERR_INVALID_AEQ_ID";
201 case I40E_ERR_INVALID_SIZE:
202 return "I40E_ERR_INVALID_SIZE";
203 case I40E_ERR_INVALID_ARP_INDEX:
204 return "I40E_ERR_INVALID_ARP_INDEX";
205 case I40E_ERR_INVALID_FPM_FUNC_ID:
206 return "I40E_ERR_INVALID_FPM_FUNC_ID";
207 case I40E_ERR_QP_INVALID_MSG_SIZE:
208 return "I40E_ERR_QP_INVALID_MSG_SIZE";
209 case I40E_ERR_QP_TOOMANY_WRS_POSTED:
210 return "I40E_ERR_QP_TOOMANY_WRS_POSTED";
211 case I40E_ERR_INVALID_FRAG_COUNT:
212 return "I40E_ERR_INVALID_FRAG_COUNT";
213 case I40E_ERR_QUEUE_EMPTY:
214 return "I40E_ERR_QUEUE_EMPTY";
215 case I40E_ERR_INVALID_ALIGNMENT:
216 return "I40E_ERR_INVALID_ALIGNMENT";
217 case I40E_ERR_FLUSHED_QUEUE:
218 return "I40E_ERR_FLUSHED_QUEUE";
219 case I40E_ERR_INVALID_PUSH_PAGE_INDEX:
220 return "I40E_ERR_INVALID_PUSH_PAGE_INDEX";
221 case I40E_ERR_INVALID_IMM_DATA_SIZE:
222 return "I40E_ERR_INVALID_IMM_DATA_SIZE";
223 case I40E_ERR_TIMEOUT:
224 return "I40E_ERR_TIMEOUT";
225 case I40E_ERR_OPCODE_MISMATCH:
226 return "I40E_ERR_OPCODE_MISMATCH";
227 case I40E_ERR_CQP_COMPL_ERROR:
228 return "I40E_ERR_CQP_COMPL_ERROR";
229 case I40E_ERR_INVALID_VF_ID:
230 return "I40E_ERR_INVALID_VF_ID";
231 case I40E_ERR_INVALID_HMCFN_ID:
232 return "I40E_ERR_INVALID_HMCFN_ID";
233 case I40E_ERR_BACKING_PAGE_ERROR:
234 return "I40E_ERR_BACKING_PAGE_ERROR";
235 case I40E_ERR_NO_PBLCHUNKS_AVAILABLE:
236 return "I40E_ERR_NO_PBLCHUNKS_AVAILABLE";
237 case I40E_ERR_INVALID_PBLE_INDEX:
238 return "I40E_ERR_INVALID_PBLE_INDEX";
239 case I40E_ERR_INVALID_SD_INDEX:
240 return "I40E_ERR_INVALID_SD_INDEX";
241 case I40E_ERR_INVALID_PAGE_DESC_INDEX:
242 return "I40E_ERR_INVALID_PAGE_DESC_INDEX";
243 case I40E_ERR_INVALID_SD_TYPE:
244 return "I40E_ERR_INVALID_SD_TYPE";
245 case I40E_ERR_MEMCPY_FAILED:
246 return "I40E_ERR_MEMCPY_FAILED";
247 case I40E_ERR_INVALID_HMC_OBJ_INDEX:
248 return "I40E_ERR_INVALID_HMC_OBJ_INDEX";
249 case I40E_ERR_INVALID_HMC_OBJ_COUNT:
250 return "I40E_ERR_INVALID_HMC_OBJ_COUNT";
251 case I40E_ERR_INVALID_SRQ_ARM_LIMIT:
252 return "I40E_ERR_INVALID_SRQ_ARM_LIMIT";
253 case I40E_ERR_SRQ_ENABLED:
254 return "I40E_ERR_SRQ_ENABLED";
255 case I40E_ERR_ADMIN_QUEUE_ERROR:
256 return "I40E_ERR_ADMIN_QUEUE_ERROR";
257 case I40E_ERR_ADMIN_QUEUE_TIMEOUT:
258 return "I40E_ERR_ADMIN_QUEUE_TIMEOUT";
259 case I40E_ERR_BUF_TOO_SHORT:
260 return "I40E_ERR_BUF_TOO_SHORT";
261 case I40E_ERR_ADMIN_QUEUE_FULL:
262 return "I40E_ERR_ADMIN_QUEUE_FULL";
263 case I40E_ERR_ADMIN_QUEUE_NO_WORK:
264 return "I40E_ERR_ADMIN_QUEUE_NO_WORK";
265 case I40E_ERR_BAD_IWARP_CQE:
266 return "I40E_ERR_BAD_IWARP_CQE";
267 case I40E_ERR_NVM_BLANK_MODE:
268 return "I40E_ERR_NVM_BLANK_MODE";
269 case I40E_ERR_NOT_IMPLEMENTED:
270 return "I40E_ERR_NOT_IMPLEMENTED";
271 case I40E_ERR_PE_DOORBELL_NOT_ENABLED:
272 return "I40E_ERR_PE_DOORBELL_NOT_ENABLED";
273 case I40E_ERR_DIAG_TEST_FAILED:
274 return "I40E_ERR_DIAG_TEST_FAILED";
275 case I40E_ERR_NOT_READY:
276 return "I40E_ERR_NOT_READY";
277 case I40E_NOT_SUPPORTED:
278 return "I40E_NOT_SUPPORTED";
279 case I40E_ERR_FIRMWARE_API_VERSION:
280 return "I40E_ERR_FIRMWARE_API_VERSION";
281 case I40E_ERR_ADMIN_QUEUE_CRITICAL_ERROR:
282 return "I40E_ERR_ADMIN_QUEUE_CRITICAL_ERROR";
285 snprintf(hw->err_str, sizeof(hw->err_str), "%d", stat_err);
291 * @hw: debug mask related to admin queue
293 * @desc: pointer to admin queue descriptor
294 * @buffer: pointer to command buffer
295 * @buf_len: max length of buffer
297 * Dumps debug log about adminq command with descriptor contents.
299 void i40e_debug_aq(struct i40e_hw *hw, enum i40e_debug_mask mask, void *desc,
300 void *buffer, u16 buf_len)
302 struct i40e_aq_desc *aq_desc = (struct i40e_aq_desc *)desc;
304 u8 *buf = (u8 *)buffer;
306 if ((!(mask & hw->debug_mask)) || (desc == NULL))
309 len = le16_to_cpu(aq_desc->datalen);
312 "AQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n",
313 le16_to_cpu(aq_desc->opcode),
314 le16_to_cpu(aq_desc->flags),
315 le16_to_cpu(aq_desc->datalen),
316 le16_to_cpu(aq_desc->retval));
317 i40e_debug(hw, mask, "\tcookie (h,l) 0x%08X 0x%08X\n",
318 le32_to_cpu(aq_desc->cookie_high),
319 le32_to_cpu(aq_desc->cookie_low));
320 i40e_debug(hw, mask, "\tparam (0,1) 0x%08X 0x%08X\n",
321 le32_to_cpu(aq_desc->params.internal.param0),
322 le32_to_cpu(aq_desc->params.internal.param1));
323 i40e_debug(hw, mask, "\taddr (h,l) 0x%08X 0x%08X\n",
324 le32_to_cpu(aq_desc->params.external.addr_high),
325 le32_to_cpu(aq_desc->params.external.addr_low));
327 if ((buffer != NULL) && (aq_desc->datalen != 0)) {
328 i40e_debug(hw, mask, "AQ CMD Buffer:\n");
331 /* write the full 16-byte chunks */
332 if (hw->debug_mask & mask) {
335 snprintf(prefix, sizeof(prefix),
336 "i40e %02x:%02x.%x: \t0x",
341 print_hex_dump(KERN_INFO, prefix, DUMP_PREFIX_OFFSET,
342 16, 1, buf, len, false);
348 * i40e_check_asq_alive
349 * @hw: pointer to the hw struct
351 * Returns true if Queue is enabled else false.
353 bool i40e_check_asq_alive(struct i40e_hw *hw)
356 return !!(rd32(hw, hw->aq.asq.len) &
357 I40E_PF_ATQLEN_ATQENABLE_MASK);
363 * i40e_aq_queue_shutdown
364 * @hw: pointer to the hw struct
365 * @unloading: is the driver unloading itself
367 * Tell the Firmware that we're shutting down the AdminQ and whether
368 * or not the driver is unloading as well.
370 i40e_status i40e_aq_queue_shutdown(struct i40e_hw *hw,
373 struct i40e_aq_desc desc;
374 struct i40e_aqc_queue_shutdown *cmd =
375 (struct i40e_aqc_queue_shutdown *)&desc.params.raw;
378 i40e_fill_default_direct_cmd_desc(&desc,
379 i40e_aqc_opc_queue_shutdown);
382 cmd->driver_unloading = cpu_to_le32(I40E_AQ_DRIVER_UNLOADING);
383 status = i40e_asq_send_command(hw, &desc, NULL, 0, NULL);
389 * i40e_aq_get_set_rss_lut
390 * @hw: pointer to the hardware structure
391 * @vsi_id: vsi fw index
392 * @pf_lut: for PF table set true, for VSI table set false
393 * @lut: pointer to the lut buffer provided by the caller
394 * @lut_size: size of the lut buffer
395 * @set: set true to set the table, false to get the table
397 * Internal function to get or set RSS look up table
399 static i40e_status i40e_aq_get_set_rss_lut(struct i40e_hw *hw,
400 u16 vsi_id, bool pf_lut,
401 u8 *lut, u16 lut_size,
405 struct i40e_aq_desc desc;
406 struct i40e_aqc_get_set_rss_lut *cmd_resp =
407 (struct i40e_aqc_get_set_rss_lut *)&desc.params.raw;
410 i40e_fill_default_direct_cmd_desc(&desc,
411 i40e_aqc_opc_set_rss_lut);
413 i40e_fill_default_direct_cmd_desc(&desc,
414 i40e_aqc_opc_get_rss_lut);
416 /* Indirect command */
417 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
418 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_RD);
421 cpu_to_le16((u16)((vsi_id <<
422 I40E_AQC_SET_RSS_LUT_VSI_ID_SHIFT) &
423 I40E_AQC_SET_RSS_LUT_VSI_ID_MASK));
424 cmd_resp->vsi_id |= cpu_to_le16((u16)I40E_AQC_SET_RSS_LUT_VSI_VALID);
427 cmd_resp->flags |= cpu_to_le16((u16)
428 ((I40E_AQC_SET_RSS_LUT_TABLE_TYPE_PF <<
429 I40E_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) &
430 I40E_AQC_SET_RSS_LUT_TABLE_TYPE_MASK));
432 cmd_resp->flags |= cpu_to_le16((u16)
433 ((I40E_AQC_SET_RSS_LUT_TABLE_TYPE_VSI <<
434 I40E_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) &
435 I40E_AQC_SET_RSS_LUT_TABLE_TYPE_MASK));
437 status = i40e_asq_send_command(hw, &desc, lut, lut_size, NULL);
443 * i40e_aq_get_rss_lut
444 * @hw: pointer to the hardware structure
445 * @vsi_id: vsi fw index
446 * @pf_lut: for PF table set true, for VSI table set false
447 * @lut: pointer to the lut buffer provided by the caller
448 * @lut_size: size of the lut buffer
450 * get the RSS lookup table, PF or VSI type
452 i40e_status i40e_aq_get_rss_lut(struct i40e_hw *hw, u16 vsi_id,
453 bool pf_lut, u8 *lut, u16 lut_size)
455 return i40e_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size,
460 * i40e_aq_set_rss_lut
461 * @hw: pointer to the hardware structure
462 * @vsi_id: vsi fw index
463 * @pf_lut: for PF table set true, for VSI table set false
464 * @lut: pointer to the lut buffer provided by the caller
465 * @lut_size: size of the lut buffer
467 * set the RSS lookup table, PF or VSI type
469 i40e_status i40e_aq_set_rss_lut(struct i40e_hw *hw, u16 vsi_id,
470 bool pf_lut, u8 *lut, u16 lut_size)
472 return i40e_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size, true);
476 * i40e_aq_get_set_rss_key
477 * @hw: pointer to the hw struct
478 * @vsi_id: vsi fw index
479 * @key: pointer to key info struct
480 * @set: set true to set the key, false to get the key
482 * get the RSS key per VSI
484 static i40e_status i40e_aq_get_set_rss_key(struct i40e_hw *hw,
486 struct i40e_aqc_get_set_rss_key_data *key,
490 struct i40e_aq_desc desc;
491 struct i40e_aqc_get_set_rss_key *cmd_resp =
492 (struct i40e_aqc_get_set_rss_key *)&desc.params.raw;
493 u16 key_size = sizeof(struct i40e_aqc_get_set_rss_key_data);
496 i40e_fill_default_direct_cmd_desc(&desc,
497 i40e_aqc_opc_set_rss_key);
499 i40e_fill_default_direct_cmd_desc(&desc,
500 i40e_aqc_opc_get_rss_key);
502 /* Indirect command */
503 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
504 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_RD);
507 cpu_to_le16((u16)((vsi_id <<
508 I40E_AQC_SET_RSS_KEY_VSI_ID_SHIFT) &
509 I40E_AQC_SET_RSS_KEY_VSI_ID_MASK));
510 cmd_resp->vsi_id |= cpu_to_le16((u16)I40E_AQC_SET_RSS_KEY_VSI_VALID);
512 status = i40e_asq_send_command(hw, &desc, key, key_size, NULL);
518 * i40e_aq_get_rss_key
519 * @hw: pointer to the hw struct
520 * @vsi_id: vsi fw index
521 * @key: pointer to key info struct
524 i40e_status i40e_aq_get_rss_key(struct i40e_hw *hw,
526 struct i40e_aqc_get_set_rss_key_data *key)
528 return i40e_aq_get_set_rss_key(hw, vsi_id, key, false);
532 * i40e_aq_set_rss_key
533 * @hw: pointer to the hw struct
534 * @vsi_id: vsi fw index
535 * @key: pointer to key info struct
537 * set the RSS key per VSI
539 i40e_status i40e_aq_set_rss_key(struct i40e_hw *hw,
541 struct i40e_aqc_get_set_rss_key_data *key)
543 return i40e_aq_get_set_rss_key(hw, vsi_id, key, true);
546 /* The i40e_ptype_lookup table is used to convert from the 8-bit ptype in the
547 * hardware to a bit-field that can be used by SW to more easily determine the
550 * Macros are used to shorten the table lines and make this table human
553 * We store the PTYPE in the top byte of the bit field - this is just so that
554 * we can check that the table doesn't have a row missing, as the index into
555 * the table should be the PTYPE.
559 * IF NOT i40e_ptype_lookup[ptype].known
562 * ELSE IF i40e_ptype_lookup[ptype].outer_ip == I40E_RX_PTYPE_OUTER_IP
563 * Use the rest of the fields to look at the tunnels, inner protocols, etc
565 * Use the enum i40e_rx_l2_ptype to decode the packet type
569 /* macro to make the table lines short */
570 #define I40E_PTT(PTYPE, OUTER_IP, OUTER_IP_VER, OUTER_FRAG, T, TE, TEF, I, PL)\
573 I40E_RX_PTYPE_OUTER_##OUTER_IP, \
574 I40E_RX_PTYPE_OUTER_##OUTER_IP_VER, \
575 I40E_RX_PTYPE_##OUTER_FRAG, \
576 I40E_RX_PTYPE_TUNNEL_##T, \
577 I40E_RX_PTYPE_TUNNEL_END_##TE, \
578 I40E_RX_PTYPE_##TEF, \
579 I40E_RX_PTYPE_INNER_PROT_##I, \
580 I40E_RX_PTYPE_PAYLOAD_LAYER_##PL }
582 #define I40E_PTT_UNUSED_ENTRY(PTYPE) \
583 { PTYPE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
585 /* shorter macros makes the table fit but are terse */
586 #define I40E_RX_PTYPE_NOF I40E_RX_PTYPE_NOT_FRAG
587 #define I40E_RX_PTYPE_FRG I40E_RX_PTYPE_FRAG
588 #define I40E_RX_PTYPE_INNER_PROT_TS I40E_RX_PTYPE_INNER_PROT_TIMESYNC
590 /* Lookup table mapping the HW PTYPE to the bit field for decoding */
591 struct i40e_rx_ptype_decoded i40e_ptype_lookup[] = {
592 /* L2 Packet types */
593 I40E_PTT_UNUSED_ENTRY(0),
594 I40E_PTT(1, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
595 I40E_PTT(2, L2, NONE, NOF, NONE, NONE, NOF, TS, PAY2),
596 I40E_PTT(3, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
597 I40E_PTT_UNUSED_ENTRY(4),
598 I40E_PTT_UNUSED_ENTRY(5),
599 I40E_PTT(6, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
600 I40E_PTT(7, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
601 I40E_PTT_UNUSED_ENTRY(8),
602 I40E_PTT_UNUSED_ENTRY(9),
603 I40E_PTT(10, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
604 I40E_PTT(11, L2, NONE, NOF, NONE, NONE, NOF, NONE, NONE),
605 I40E_PTT(12, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
606 I40E_PTT(13, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
607 I40E_PTT(14, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
608 I40E_PTT(15, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
609 I40E_PTT(16, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
610 I40E_PTT(17, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
611 I40E_PTT(18, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
612 I40E_PTT(19, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
613 I40E_PTT(20, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
614 I40E_PTT(21, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
616 /* Non Tunneled IPv4 */
617 I40E_PTT(22, IP, IPV4, FRG, NONE, NONE, NOF, NONE, PAY3),
618 I40E_PTT(23, IP, IPV4, NOF, NONE, NONE, NOF, NONE, PAY3),
619 I40E_PTT(24, IP, IPV4, NOF, NONE, NONE, NOF, UDP, PAY4),
620 I40E_PTT_UNUSED_ENTRY(25),
621 I40E_PTT(26, IP, IPV4, NOF, NONE, NONE, NOF, TCP, PAY4),
622 I40E_PTT(27, IP, IPV4, NOF, NONE, NONE, NOF, SCTP, PAY4),
623 I40E_PTT(28, IP, IPV4, NOF, NONE, NONE, NOF, ICMP, PAY4),
626 I40E_PTT(29, IP, IPV4, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
627 I40E_PTT(30, IP, IPV4, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
628 I40E_PTT(31, IP, IPV4, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
629 I40E_PTT_UNUSED_ENTRY(32),
630 I40E_PTT(33, IP, IPV4, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
631 I40E_PTT(34, IP, IPV4, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
632 I40E_PTT(35, IP, IPV4, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
635 I40E_PTT(36, IP, IPV4, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
636 I40E_PTT(37, IP, IPV4, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
637 I40E_PTT(38, IP, IPV4, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
638 I40E_PTT_UNUSED_ENTRY(39),
639 I40E_PTT(40, IP, IPV4, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
640 I40E_PTT(41, IP, IPV4, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
641 I40E_PTT(42, IP, IPV4, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
643 /* IPv4 --> GRE/NAT */
644 I40E_PTT(43, IP, IPV4, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
646 /* IPv4 --> GRE/NAT --> IPv4 */
647 I40E_PTT(44, IP, IPV4, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
648 I40E_PTT(45, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
649 I40E_PTT(46, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
650 I40E_PTT_UNUSED_ENTRY(47),
651 I40E_PTT(48, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
652 I40E_PTT(49, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
653 I40E_PTT(50, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
655 /* IPv4 --> GRE/NAT --> IPv6 */
656 I40E_PTT(51, IP, IPV4, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
657 I40E_PTT(52, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
658 I40E_PTT(53, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
659 I40E_PTT_UNUSED_ENTRY(54),
660 I40E_PTT(55, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
661 I40E_PTT(56, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
662 I40E_PTT(57, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
664 /* IPv4 --> GRE/NAT --> MAC */
665 I40E_PTT(58, IP, IPV4, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
667 /* IPv4 --> GRE/NAT --> MAC --> IPv4 */
668 I40E_PTT(59, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
669 I40E_PTT(60, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
670 I40E_PTT(61, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
671 I40E_PTT_UNUSED_ENTRY(62),
672 I40E_PTT(63, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
673 I40E_PTT(64, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
674 I40E_PTT(65, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
676 /* IPv4 --> GRE/NAT -> MAC --> IPv6 */
677 I40E_PTT(66, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
678 I40E_PTT(67, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
679 I40E_PTT(68, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
680 I40E_PTT_UNUSED_ENTRY(69),
681 I40E_PTT(70, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
682 I40E_PTT(71, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
683 I40E_PTT(72, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
685 /* IPv4 --> GRE/NAT --> MAC/VLAN */
686 I40E_PTT(73, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
688 /* IPv4 ---> GRE/NAT -> MAC/VLAN --> IPv4 */
689 I40E_PTT(74, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
690 I40E_PTT(75, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
691 I40E_PTT(76, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
692 I40E_PTT_UNUSED_ENTRY(77),
693 I40E_PTT(78, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
694 I40E_PTT(79, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
695 I40E_PTT(80, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
697 /* IPv4 -> GRE/NAT -> MAC/VLAN --> IPv6 */
698 I40E_PTT(81, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
699 I40E_PTT(82, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
700 I40E_PTT(83, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
701 I40E_PTT_UNUSED_ENTRY(84),
702 I40E_PTT(85, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
703 I40E_PTT(86, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
704 I40E_PTT(87, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
706 /* Non Tunneled IPv6 */
707 I40E_PTT(88, IP, IPV6, FRG, NONE, NONE, NOF, NONE, PAY3),
708 I40E_PTT(89, IP, IPV6, NOF, NONE, NONE, NOF, NONE, PAY3),
709 I40E_PTT(90, IP, IPV6, NOF, NONE, NONE, NOF, UDP, PAY4),
710 I40E_PTT_UNUSED_ENTRY(91),
711 I40E_PTT(92, IP, IPV6, NOF, NONE, NONE, NOF, TCP, PAY4),
712 I40E_PTT(93, IP, IPV6, NOF, NONE, NONE, NOF, SCTP, PAY4),
713 I40E_PTT(94, IP, IPV6, NOF, NONE, NONE, NOF, ICMP, PAY4),
716 I40E_PTT(95, IP, IPV6, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
717 I40E_PTT(96, IP, IPV6, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
718 I40E_PTT(97, IP, IPV6, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
719 I40E_PTT_UNUSED_ENTRY(98),
720 I40E_PTT(99, IP, IPV6, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
721 I40E_PTT(100, IP, IPV6, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
722 I40E_PTT(101, IP, IPV6, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
725 I40E_PTT(102, IP, IPV6, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
726 I40E_PTT(103, IP, IPV6, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
727 I40E_PTT(104, IP, IPV6, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
728 I40E_PTT_UNUSED_ENTRY(105),
729 I40E_PTT(106, IP, IPV6, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
730 I40E_PTT(107, IP, IPV6, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
731 I40E_PTT(108, IP, IPV6, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
733 /* IPv6 --> GRE/NAT */
734 I40E_PTT(109, IP, IPV6, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
736 /* IPv6 --> GRE/NAT -> IPv4 */
737 I40E_PTT(110, IP, IPV6, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
738 I40E_PTT(111, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
739 I40E_PTT(112, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
740 I40E_PTT_UNUSED_ENTRY(113),
741 I40E_PTT(114, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
742 I40E_PTT(115, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
743 I40E_PTT(116, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
745 /* IPv6 --> GRE/NAT -> IPv6 */
746 I40E_PTT(117, IP, IPV6, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
747 I40E_PTT(118, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
748 I40E_PTT(119, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
749 I40E_PTT_UNUSED_ENTRY(120),
750 I40E_PTT(121, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
751 I40E_PTT(122, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
752 I40E_PTT(123, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
754 /* IPv6 --> GRE/NAT -> MAC */
755 I40E_PTT(124, IP, IPV6, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
757 /* IPv6 --> GRE/NAT -> MAC -> IPv4 */
758 I40E_PTT(125, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
759 I40E_PTT(126, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
760 I40E_PTT(127, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
761 I40E_PTT_UNUSED_ENTRY(128),
762 I40E_PTT(129, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
763 I40E_PTT(130, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
764 I40E_PTT(131, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
766 /* IPv6 --> GRE/NAT -> MAC -> IPv6 */
767 I40E_PTT(132, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
768 I40E_PTT(133, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
769 I40E_PTT(134, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
770 I40E_PTT_UNUSED_ENTRY(135),
771 I40E_PTT(136, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
772 I40E_PTT(137, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
773 I40E_PTT(138, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
775 /* IPv6 --> GRE/NAT -> MAC/VLAN */
776 I40E_PTT(139, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
778 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv4 */
779 I40E_PTT(140, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
780 I40E_PTT(141, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
781 I40E_PTT(142, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
782 I40E_PTT_UNUSED_ENTRY(143),
783 I40E_PTT(144, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
784 I40E_PTT(145, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
785 I40E_PTT(146, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
787 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv6 */
788 I40E_PTT(147, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
789 I40E_PTT(148, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
790 I40E_PTT(149, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
791 I40E_PTT_UNUSED_ENTRY(150),
792 I40E_PTT(151, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
793 I40E_PTT(152, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
794 I40E_PTT(153, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
797 I40E_PTT_UNUSED_ENTRY(154),
798 I40E_PTT_UNUSED_ENTRY(155),
799 I40E_PTT_UNUSED_ENTRY(156),
800 I40E_PTT_UNUSED_ENTRY(157),
801 I40E_PTT_UNUSED_ENTRY(158),
802 I40E_PTT_UNUSED_ENTRY(159),
804 I40E_PTT_UNUSED_ENTRY(160),
805 I40E_PTT_UNUSED_ENTRY(161),
806 I40E_PTT_UNUSED_ENTRY(162),
807 I40E_PTT_UNUSED_ENTRY(163),
808 I40E_PTT_UNUSED_ENTRY(164),
809 I40E_PTT_UNUSED_ENTRY(165),
810 I40E_PTT_UNUSED_ENTRY(166),
811 I40E_PTT_UNUSED_ENTRY(167),
812 I40E_PTT_UNUSED_ENTRY(168),
813 I40E_PTT_UNUSED_ENTRY(169),
815 I40E_PTT_UNUSED_ENTRY(170),
816 I40E_PTT_UNUSED_ENTRY(171),
817 I40E_PTT_UNUSED_ENTRY(172),
818 I40E_PTT_UNUSED_ENTRY(173),
819 I40E_PTT_UNUSED_ENTRY(174),
820 I40E_PTT_UNUSED_ENTRY(175),
821 I40E_PTT_UNUSED_ENTRY(176),
822 I40E_PTT_UNUSED_ENTRY(177),
823 I40E_PTT_UNUSED_ENTRY(178),
824 I40E_PTT_UNUSED_ENTRY(179),
826 I40E_PTT_UNUSED_ENTRY(180),
827 I40E_PTT_UNUSED_ENTRY(181),
828 I40E_PTT_UNUSED_ENTRY(182),
829 I40E_PTT_UNUSED_ENTRY(183),
830 I40E_PTT_UNUSED_ENTRY(184),
831 I40E_PTT_UNUSED_ENTRY(185),
832 I40E_PTT_UNUSED_ENTRY(186),
833 I40E_PTT_UNUSED_ENTRY(187),
834 I40E_PTT_UNUSED_ENTRY(188),
835 I40E_PTT_UNUSED_ENTRY(189),
837 I40E_PTT_UNUSED_ENTRY(190),
838 I40E_PTT_UNUSED_ENTRY(191),
839 I40E_PTT_UNUSED_ENTRY(192),
840 I40E_PTT_UNUSED_ENTRY(193),
841 I40E_PTT_UNUSED_ENTRY(194),
842 I40E_PTT_UNUSED_ENTRY(195),
843 I40E_PTT_UNUSED_ENTRY(196),
844 I40E_PTT_UNUSED_ENTRY(197),
845 I40E_PTT_UNUSED_ENTRY(198),
846 I40E_PTT_UNUSED_ENTRY(199),
848 I40E_PTT_UNUSED_ENTRY(200),
849 I40E_PTT_UNUSED_ENTRY(201),
850 I40E_PTT_UNUSED_ENTRY(202),
851 I40E_PTT_UNUSED_ENTRY(203),
852 I40E_PTT_UNUSED_ENTRY(204),
853 I40E_PTT_UNUSED_ENTRY(205),
854 I40E_PTT_UNUSED_ENTRY(206),
855 I40E_PTT_UNUSED_ENTRY(207),
856 I40E_PTT_UNUSED_ENTRY(208),
857 I40E_PTT_UNUSED_ENTRY(209),
859 I40E_PTT_UNUSED_ENTRY(210),
860 I40E_PTT_UNUSED_ENTRY(211),
861 I40E_PTT_UNUSED_ENTRY(212),
862 I40E_PTT_UNUSED_ENTRY(213),
863 I40E_PTT_UNUSED_ENTRY(214),
864 I40E_PTT_UNUSED_ENTRY(215),
865 I40E_PTT_UNUSED_ENTRY(216),
866 I40E_PTT_UNUSED_ENTRY(217),
867 I40E_PTT_UNUSED_ENTRY(218),
868 I40E_PTT_UNUSED_ENTRY(219),
870 I40E_PTT_UNUSED_ENTRY(220),
871 I40E_PTT_UNUSED_ENTRY(221),
872 I40E_PTT_UNUSED_ENTRY(222),
873 I40E_PTT_UNUSED_ENTRY(223),
874 I40E_PTT_UNUSED_ENTRY(224),
875 I40E_PTT_UNUSED_ENTRY(225),
876 I40E_PTT_UNUSED_ENTRY(226),
877 I40E_PTT_UNUSED_ENTRY(227),
878 I40E_PTT_UNUSED_ENTRY(228),
879 I40E_PTT_UNUSED_ENTRY(229),
881 I40E_PTT_UNUSED_ENTRY(230),
882 I40E_PTT_UNUSED_ENTRY(231),
883 I40E_PTT_UNUSED_ENTRY(232),
884 I40E_PTT_UNUSED_ENTRY(233),
885 I40E_PTT_UNUSED_ENTRY(234),
886 I40E_PTT_UNUSED_ENTRY(235),
887 I40E_PTT_UNUSED_ENTRY(236),
888 I40E_PTT_UNUSED_ENTRY(237),
889 I40E_PTT_UNUSED_ENTRY(238),
890 I40E_PTT_UNUSED_ENTRY(239),
892 I40E_PTT_UNUSED_ENTRY(240),
893 I40E_PTT_UNUSED_ENTRY(241),
894 I40E_PTT_UNUSED_ENTRY(242),
895 I40E_PTT_UNUSED_ENTRY(243),
896 I40E_PTT_UNUSED_ENTRY(244),
897 I40E_PTT_UNUSED_ENTRY(245),
898 I40E_PTT_UNUSED_ENTRY(246),
899 I40E_PTT_UNUSED_ENTRY(247),
900 I40E_PTT_UNUSED_ENTRY(248),
901 I40E_PTT_UNUSED_ENTRY(249),
903 I40E_PTT_UNUSED_ENTRY(250),
904 I40E_PTT_UNUSED_ENTRY(251),
905 I40E_PTT_UNUSED_ENTRY(252),
906 I40E_PTT_UNUSED_ENTRY(253),
907 I40E_PTT_UNUSED_ENTRY(254),
908 I40E_PTT_UNUSED_ENTRY(255)
912 * i40e_init_shared_code - Initialize the shared code
913 * @hw: pointer to hardware structure
915 * This assigns the MAC type and PHY code and inits the NVM.
916 * Does not touch the hardware. This function must be called prior to any
917 * other function in the shared code. The i40e_hw structure should be
918 * memset to 0 prior to calling this function. The following fields in
919 * hw structure should be filled in prior to calling this function:
920 * hw_addr, back, device_id, vendor_id, subsystem_device_id,
921 * subsystem_vendor_id, and revision_id
923 i40e_status i40e_init_shared_code(struct i40e_hw *hw)
925 i40e_status status = 0;
926 u32 port, ari, func_rid;
928 i40e_set_mac_type(hw);
930 switch (hw->mac.type) {
935 return I40E_ERR_DEVICE_NOT_SUPPORTED;
938 hw->phy.get_link_info = true;
940 /* Determine port number and PF number*/
941 port = (rd32(hw, I40E_PFGEN_PORTNUM) & I40E_PFGEN_PORTNUM_PORT_NUM_MASK)
942 >> I40E_PFGEN_PORTNUM_PORT_NUM_SHIFT;
944 ari = (rd32(hw, I40E_GLPCI_CAPSUP) & I40E_GLPCI_CAPSUP_ARI_EN_MASK) >>
945 I40E_GLPCI_CAPSUP_ARI_EN_SHIFT;
946 func_rid = rd32(hw, I40E_PF_FUNC_RID);
948 hw->pf_id = (u8)(func_rid & 0xff);
950 hw->pf_id = (u8)(func_rid & 0x7);
952 if (hw->mac.type == I40E_MAC_X722)
953 hw->flags |= I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE |
954 I40E_HW_FLAG_NVM_READ_REQUIRES_LOCK;
956 status = i40e_init_nvm(hw);
961 * i40e_aq_mac_address_read - Retrieve the MAC addresses
962 * @hw: pointer to the hw struct
963 * @flags: a return indicator of what addresses were added to the addr store
964 * @addrs: the requestor's mac addr store
965 * @cmd_details: pointer to command details structure or NULL
967 static i40e_status i40e_aq_mac_address_read(struct i40e_hw *hw,
969 struct i40e_aqc_mac_address_read_data *addrs,
970 struct i40e_asq_cmd_details *cmd_details)
972 struct i40e_aq_desc desc;
973 struct i40e_aqc_mac_address_read *cmd_data =
974 (struct i40e_aqc_mac_address_read *)&desc.params.raw;
977 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_mac_address_read);
978 desc.flags |= cpu_to_le16(I40E_AQ_FLAG_BUF);
980 status = i40e_asq_send_command(hw, &desc, addrs,
981 sizeof(*addrs), cmd_details);
982 *flags = le16_to_cpu(cmd_data->command_flags);
988 * i40e_aq_mac_address_write - Change the MAC addresses
989 * @hw: pointer to the hw struct
990 * @flags: indicates which MAC to be written
991 * @mac_addr: address to write
992 * @cmd_details: pointer to command details structure or NULL
994 i40e_status i40e_aq_mac_address_write(struct i40e_hw *hw,
995 u16 flags, u8 *mac_addr,
996 struct i40e_asq_cmd_details *cmd_details)
998 struct i40e_aq_desc desc;
999 struct i40e_aqc_mac_address_write *cmd_data =
1000 (struct i40e_aqc_mac_address_write *)&desc.params.raw;
1003 i40e_fill_default_direct_cmd_desc(&desc,
1004 i40e_aqc_opc_mac_address_write);
1005 cmd_data->command_flags = cpu_to_le16(flags);
1006 cmd_data->mac_sah = cpu_to_le16((u16)mac_addr[0] << 8 | mac_addr[1]);
1007 cmd_data->mac_sal = cpu_to_le32(((u32)mac_addr[2] << 24) |
1008 ((u32)mac_addr[3] << 16) |
1009 ((u32)mac_addr[4] << 8) |
1012 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1018 * i40e_get_mac_addr - get MAC address
1019 * @hw: pointer to the HW structure
1020 * @mac_addr: pointer to MAC address
1022 * Reads the adapter's MAC address from register
1024 i40e_status i40e_get_mac_addr(struct i40e_hw *hw, u8 *mac_addr)
1026 struct i40e_aqc_mac_address_read_data addrs;
1030 status = i40e_aq_mac_address_read(hw, &flags, &addrs, NULL);
1032 if (flags & I40E_AQC_LAN_ADDR_VALID)
1033 ether_addr_copy(mac_addr, addrs.pf_lan_mac);
1039 * i40e_get_port_mac_addr - get Port MAC address
1040 * @hw: pointer to the HW structure
1041 * @mac_addr: pointer to Port MAC address
1043 * Reads the adapter's Port MAC address
1045 i40e_status i40e_get_port_mac_addr(struct i40e_hw *hw, u8 *mac_addr)
1047 struct i40e_aqc_mac_address_read_data addrs;
1051 status = i40e_aq_mac_address_read(hw, &flags, &addrs, NULL);
1055 if (flags & I40E_AQC_PORT_ADDR_VALID)
1056 ether_addr_copy(mac_addr, addrs.port_mac);
1058 status = I40E_ERR_INVALID_MAC_ADDR;
1064 * i40e_pre_tx_queue_cfg - pre tx queue configure
1065 * @hw: pointer to the HW structure
1066 * @queue: target PF queue index
1067 * @enable: state change request
1069 * Handles hw requirement to indicate intention to enable
1070 * or disable target queue.
1072 void i40e_pre_tx_queue_cfg(struct i40e_hw *hw, u32 queue, bool enable)
1074 u32 abs_queue_idx = hw->func_caps.base_queue + queue;
1078 if (abs_queue_idx >= 128) {
1079 reg_block = abs_queue_idx / 128;
1080 abs_queue_idx %= 128;
1083 reg_val = rd32(hw, I40E_GLLAN_TXPRE_QDIS(reg_block));
1084 reg_val &= ~I40E_GLLAN_TXPRE_QDIS_QINDX_MASK;
1085 reg_val |= (abs_queue_idx << I40E_GLLAN_TXPRE_QDIS_QINDX_SHIFT);
1088 reg_val |= I40E_GLLAN_TXPRE_QDIS_CLEAR_QDIS_MASK;
1090 reg_val |= I40E_GLLAN_TXPRE_QDIS_SET_QDIS_MASK;
1092 wr32(hw, I40E_GLLAN_TXPRE_QDIS(reg_block), reg_val);
1096 * i40e_read_pba_string - Reads part number string from EEPROM
1097 * @hw: pointer to hardware structure
1098 * @pba_num: stores the part number string from the EEPROM
1099 * @pba_num_size: part number string buffer length
1101 * Reads the part number string from the EEPROM.
1103 i40e_status i40e_read_pba_string(struct i40e_hw *hw, u8 *pba_num,
1106 i40e_status status = 0;
1112 status = i40e_read_nvm_word(hw, I40E_SR_PBA_FLAGS, &pba_word);
1113 if (status || (pba_word != 0xFAFA)) {
1114 hw_dbg(hw, "Failed to read PBA flags or flag is invalid.\n");
1118 status = i40e_read_nvm_word(hw, I40E_SR_PBA_BLOCK_PTR, &pba_ptr);
1120 hw_dbg(hw, "Failed to read PBA Block pointer.\n");
1124 status = i40e_read_nvm_word(hw, pba_ptr, &pba_size);
1126 hw_dbg(hw, "Failed to read PBA Block size.\n");
1130 /* Subtract one to get PBA word count (PBA Size word is included in
1134 if (pba_num_size < (((u32)pba_size * 2) + 1)) {
1135 hw_dbg(hw, "Buffer to small for PBA data.\n");
1136 return I40E_ERR_PARAM;
1139 for (i = 0; i < pba_size; i++) {
1140 status = i40e_read_nvm_word(hw, (pba_ptr + 1) + i, &pba_word);
1142 hw_dbg(hw, "Failed to read PBA Block word %d.\n", i);
1146 pba_num[(i * 2)] = (pba_word >> 8) & 0xFF;
1147 pba_num[(i * 2) + 1] = pba_word & 0xFF;
1149 pba_num[(pba_size * 2)] = '\0';
1155 * i40e_get_media_type - Gets media type
1156 * @hw: pointer to the hardware structure
1158 static enum i40e_media_type i40e_get_media_type(struct i40e_hw *hw)
1160 enum i40e_media_type media;
1162 switch (hw->phy.link_info.phy_type) {
1163 case I40E_PHY_TYPE_10GBASE_SR:
1164 case I40E_PHY_TYPE_10GBASE_LR:
1165 case I40E_PHY_TYPE_1000BASE_SX:
1166 case I40E_PHY_TYPE_1000BASE_LX:
1167 case I40E_PHY_TYPE_40GBASE_SR4:
1168 case I40E_PHY_TYPE_40GBASE_LR4:
1169 case I40E_PHY_TYPE_25GBASE_LR:
1170 case I40E_PHY_TYPE_25GBASE_SR:
1171 media = I40E_MEDIA_TYPE_FIBER;
1173 case I40E_PHY_TYPE_100BASE_TX:
1174 case I40E_PHY_TYPE_1000BASE_T:
1175 case I40E_PHY_TYPE_10GBASE_T:
1176 media = I40E_MEDIA_TYPE_BASET;
1178 case I40E_PHY_TYPE_10GBASE_CR1_CU:
1179 case I40E_PHY_TYPE_40GBASE_CR4_CU:
1180 case I40E_PHY_TYPE_10GBASE_CR1:
1181 case I40E_PHY_TYPE_40GBASE_CR4:
1182 case I40E_PHY_TYPE_10GBASE_SFPP_CU:
1183 case I40E_PHY_TYPE_40GBASE_AOC:
1184 case I40E_PHY_TYPE_10GBASE_AOC:
1185 case I40E_PHY_TYPE_25GBASE_CR:
1186 case I40E_PHY_TYPE_25GBASE_AOC:
1187 case I40E_PHY_TYPE_25GBASE_ACC:
1188 media = I40E_MEDIA_TYPE_DA;
1190 case I40E_PHY_TYPE_1000BASE_KX:
1191 case I40E_PHY_TYPE_10GBASE_KX4:
1192 case I40E_PHY_TYPE_10GBASE_KR:
1193 case I40E_PHY_TYPE_40GBASE_KR4:
1194 case I40E_PHY_TYPE_20GBASE_KR2:
1195 case I40E_PHY_TYPE_25GBASE_KR:
1196 media = I40E_MEDIA_TYPE_BACKPLANE;
1198 case I40E_PHY_TYPE_SGMII:
1199 case I40E_PHY_TYPE_XAUI:
1200 case I40E_PHY_TYPE_XFI:
1201 case I40E_PHY_TYPE_XLAUI:
1202 case I40E_PHY_TYPE_XLPPI:
1204 media = I40E_MEDIA_TYPE_UNKNOWN;
1211 #define I40E_PF_RESET_WAIT_COUNT_A0 200
1212 #define I40E_PF_RESET_WAIT_COUNT 200
1214 * i40e_pf_reset - Reset the PF
1215 * @hw: pointer to the hardware structure
1217 * Assuming someone else has triggered a global reset,
1218 * assure the global reset is complete and then reset the PF
1220 i40e_status i40e_pf_reset(struct i40e_hw *hw)
1227 /* Poll for Global Reset steady state in case of recent GRST.
1228 * The grst delay value is in 100ms units, and we'll wait a
1229 * couple counts longer to be sure we don't just miss the end.
1231 grst_del = (rd32(hw, I40E_GLGEN_RSTCTL) &
1232 I40E_GLGEN_RSTCTL_GRSTDEL_MASK) >>
1233 I40E_GLGEN_RSTCTL_GRSTDEL_SHIFT;
1235 /* It can take upto 15 secs for GRST steady state.
1236 * Bump it to 16 secs max to be safe.
1238 grst_del = grst_del * 20;
1240 for (cnt = 0; cnt < grst_del; cnt++) {
1241 reg = rd32(hw, I40E_GLGEN_RSTAT);
1242 if (!(reg & I40E_GLGEN_RSTAT_DEVSTATE_MASK))
1246 if (reg & I40E_GLGEN_RSTAT_DEVSTATE_MASK) {
1247 hw_dbg(hw, "Global reset polling failed to complete.\n");
1248 return I40E_ERR_RESET_FAILED;
1251 /* Now Wait for the FW to be ready */
1252 for (cnt1 = 0; cnt1 < I40E_PF_RESET_WAIT_COUNT; cnt1++) {
1253 reg = rd32(hw, I40E_GLNVM_ULD);
1254 reg &= (I40E_GLNVM_ULD_CONF_CORE_DONE_MASK |
1255 I40E_GLNVM_ULD_CONF_GLOBAL_DONE_MASK);
1256 if (reg == (I40E_GLNVM_ULD_CONF_CORE_DONE_MASK |
1257 I40E_GLNVM_ULD_CONF_GLOBAL_DONE_MASK)) {
1258 hw_dbg(hw, "Core and Global modules ready %d\n", cnt1);
1261 usleep_range(10000, 20000);
1263 if (!(reg & (I40E_GLNVM_ULD_CONF_CORE_DONE_MASK |
1264 I40E_GLNVM_ULD_CONF_GLOBAL_DONE_MASK))) {
1265 hw_dbg(hw, "wait for FW Reset complete timedout\n");
1266 hw_dbg(hw, "I40E_GLNVM_ULD = 0x%x\n", reg);
1267 return I40E_ERR_RESET_FAILED;
1270 /* If there was a Global Reset in progress when we got here,
1271 * we don't need to do the PF Reset
1275 if (hw->revision_id == 0)
1276 cnt = I40E_PF_RESET_WAIT_COUNT_A0;
1278 cnt = I40E_PF_RESET_WAIT_COUNT;
1279 reg = rd32(hw, I40E_PFGEN_CTRL);
1280 wr32(hw, I40E_PFGEN_CTRL,
1281 (reg | I40E_PFGEN_CTRL_PFSWR_MASK));
1282 for (; cnt; cnt--) {
1283 reg = rd32(hw, I40E_PFGEN_CTRL);
1284 if (!(reg & I40E_PFGEN_CTRL_PFSWR_MASK))
1286 reg2 = rd32(hw, I40E_GLGEN_RSTAT);
1287 if (reg2 & I40E_GLGEN_RSTAT_DEVSTATE_MASK) {
1288 hw_dbg(hw, "Core reset upcoming. Skipping PF reset request.\n");
1289 hw_dbg(hw, "I40E_GLGEN_RSTAT = 0x%x\n", reg2);
1290 return I40E_ERR_NOT_READY;
1292 usleep_range(1000, 2000);
1294 if (reg & I40E_PFGEN_CTRL_PFSWR_MASK) {
1295 hw_dbg(hw, "PF reset polling failed to complete.\n");
1296 return I40E_ERR_RESET_FAILED;
1300 i40e_clear_pxe_mode(hw);
1306 * i40e_clear_hw - clear out any left over hw state
1307 * @hw: pointer to the hw struct
1309 * Clear queues and interrupts, typically called at init time,
1310 * but after the capabilities have been found so we know how many
1311 * queues and msix vectors have been allocated.
1313 void i40e_clear_hw(struct i40e_hw *hw)
1315 u32 num_queues, base_queue;
1323 /* get number of interrupts, queues, and VFs */
1324 val = rd32(hw, I40E_GLPCI_CNF2);
1325 num_pf_int = (val & I40E_GLPCI_CNF2_MSI_X_PF_N_MASK) >>
1326 I40E_GLPCI_CNF2_MSI_X_PF_N_SHIFT;
1327 num_vf_int = (val & I40E_GLPCI_CNF2_MSI_X_VF_N_MASK) >>
1328 I40E_GLPCI_CNF2_MSI_X_VF_N_SHIFT;
1330 val = rd32(hw, I40E_PFLAN_QALLOC);
1331 base_queue = (val & I40E_PFLAN_QALLOC_FIRSTQ_MASK) >>
1332 I40E_PFLAN_QALLOC_FIRSTQ_SHIFT;
1333 j = (val & I40E_PFLAN_QALLOC_LASTQ_MASK) >>
1334 I40E_PFLAN_QALLOC_LASTQ_SHIFT;
1335 if (val & I40E_PFLAN_QALLOC_VALID_MASK)
1336 num_queues = (j - base_queue) + 1;
1340 val = rd32(hw, I40E_PF_VT_PFALLOC);
1341 i = (val & I40E_PF_VT_PFALLOC_FIRSTVF_MASK) >>
1342 I40E_PF_VT_PFALLOC_FIRSTVF_SHIFT;
1343 j = (val & I40E_PF_VT_PFALLOC_LASTVF_MASK) >>
1344 I40E_PF_VT_PFALLOC_LASTVF_SHIFT;
1345 if (val & I40E_PF_VT_PFALLOC_VALID_MASK)
1346 num_vfs = (j - i) + 1;
1350 /* stop all the interrupts */
1351 wr32(hw, I40E_PFINT_ICR0_ENA, 0);
1352 val = 0x3 << I40E_PFINT_DYN_CTLN_ITR_INDX_SHIFT;
1353 for (i = 0; i < num_pf_int - 2; i++)
1354 wr32(hw, I40E_PFINT_DYN_CTLN(i), val);
1356 /* Set the FIRSTQ_INDX field to 0x7FF in PFINT_LNKLSTx */
1357 val = eol << I40E_PFINT_LNKLST0_FIRSTQ_INDX_SHIFT;
1358 wr32(hw, I40E_PFINT_LNKLST0, val);
1359 for (i = 0; i < num_pf_int - 2; i++)
1360 wr32(hw, I40E_PFINT_LNKLSTN(i), val);
1361 val = eol << I40E_VPINT_LNKLST0_FIRSTQ_INDX_SHIFT;
1362 for (i = 0; i < num_vfs; i++)
1363 wr32(hw, I40E_VPINT_LNKLST0(i), val);
1364 for (i = 0; i < num_vf_int - 2; i++)
1365 wr32(hw, I40E_VPINT_LNKLSTN(i), val);
1367 /* warn the HW of the coming Tx disables */
1368 for (i = 0; i < num_queues; i++) {
1369 u32 abs_queue_idx = base_queue + i;
1372 if (abs_queue_idx >= 128) {
1373 reg_block = abs_queue_idx / 128;
1374 abs_queue_idx %= 128;
1377 val = rd32(hw, I40E_GLLAN_TXPRE_QDIS(reg_block));
1378 val &= ~I40E_GLLAN_TXPRE_QDIS_QINDX_MASK;
1379 val |= (abs_queue_idx << I40E_GLLAN_TXPRE_QDIS_QINDX_SHIFT);
1380 val |= I40E_GLLAN_TXPRE_QDIS_SET_QDIS_MASK;
1382 wr32(hw, I40E_GLLAN_TXPRE_QDIS(reg_block), val);
1386 /* stop all the queues */
1387 for (i = 0; i < num_queues; i++) {
1388 wr32(hw, I40E_QINT_TQCTL(i), 0);
1389 wr32(hw, I40E_QTX_ENA(i), 0);
1390 wr32(hw, I40E_QINT_RQCTL(i), 0);
1391 wr32(hw, I40E_QRX_ENA(i), 0);
1394 /* short wait for all queue disables to settle */
1399 * i40e_clear_pxe_mode - clear pxe operations mode
1400 * @hw: pointer to the hw struct
1402 * Make sure all PXE mode settings are cleared, including things
1403 * like descriptor fetch/write-back mode.
1405 void i40e_clear_pxe_mode(struct i40e_hw *hw)
1409 if (i40e_check_asq_alive(hw))
1410 i40e_aq_clear_pxe_mode(hw, NULL);
1412 /* Clear single descriptor fetch/write-back mode */
1413 reg = rd32(hw, I40E_GLLAN_RCTL_0);
1415 if (hw->revision_id == 0) {
1416 /* As a work around clear PXE_MODE instead of setting it */
1417 wr32(hw, I40E_GLLAN_RCTL_0, (reg & (~I40E_GLLAN_RCTL_0_PXE_MODE_MASK)));
1419 wr32(hw, I40E_GLLAN_RCTL_0, (reg | I40E_GLLAN_RCTL_0_PXE_MODE_MASK));
1424 * i40e_led_is_mine - helper to find matching led
1425 * @hw: pointer to the hw struct
1426 * @idx: index into GPIO registers
1428 * returns: 0 if no match, otherwise the value of the GPIO_CTL register
1430 static u32 i40e_led_is_mine(struct i40e_hw *hw, int idx)
1435 if (!hw->func_caps.led[idx])
1438 gpio_val = rd32(hw, I40E_GLGEN_GPIO_CTL(idx));
1439 port = (gpio_val & I40E_GLGEN_GPIO_CTL_PRT_NUM_MASK) >>
1440 I40E_GLGEN_GPIO_CTL_PRT_NUM_SHIFT;
1442 /* if PRT_NUM_NA is 1 then this LED is not port specific, OR
1443 * if it is not our port then ignore
1445 if ((gpio_val & I40E_GLGEN_GPIO_CTL_PRT_NUM_NA_MASK) ||
1452 #define I40E_COMBINED_ACTIVITY 0xA
1453 #define I40E_FILTER_ACTIVITY 0xE
1454 #define I40E_LINK_ACTIVITY 0xC
1455 #define I40E_MAC_ACTIVITY 0xD
1456 #define I40E_LED0 22
1459 * i40e_led_get - return current on/off mode
1460 * @hw: pointer to the hw struct
1462 * The value returned is the 'mode' field as defined in the
1463 * GPIO register definitions: 0x0 = off, 0xf = on, and other
1464 * values are variations of possible behaviors relating to
1465 * blink, link, and wire.
1467 u32 i40e_led_get(struct i40e_hw *hw)
1469 u32 current_mode = 0;
1473 /* as per the documentation GPIO 22-29 are the LED
1474 * GPIO pins named LED0..LED7
1476 for (i = I40E_LED0; i <= I40E_GLGEN_GPIO_CTL_MAX_INDEX; i++) {
1477 u32 gpio_val = i40e_led_is_mine(hw, i);
1482 /* ignore gpio LED src mode entries related to the activity
1485 current_mode = ((gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK)
1486 >> I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT);
1487 switch (current_mode) {
1488 case I40E_COMBINED_ACTIVITY:
1489 case I40E_FILTER_ACTIVITY:
1490 case I40E_MAC_ACTIVITY:
1491 case I40E_LINK_ACTIVITY:
1497 mode = (gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK) >>
1498 I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT;
1506 * i40e_led_set - set new on/off mode
1507 * @hw: pointer to the hw struct
1508 * @mode: 0=off, 0xf=on (else see manual for mode details)
1509 * @blink: true if the LED should blink when on, false if steady
1511 * if this function is used to turn on the blink it should
1512 * be used to disable the blink when restoring the original state.
1514 void i40e_led_set(struct i40e_hw *hw, u32 mode, bool blink)
1516 u32 current_mode = 0;
1519 if (mode & 0xfffffff0)
1520 hw_dbg(hw, "invalid mode passed in %X\n", mode);
1522 /* as per the documentation GPIO 22-29 are the LED
1523 * GPIO pins named LED0..LED7
1525 for (i = I40E_LED0; i <= I40E_GLGEN_GPIO_CTL_MAX_INDEX; i++) {
1526 u32 gpio_val = i40e_led_is_mine(hw, i);
1531 /* ignore gpio LED src mode entries related to the activity
1534 current_mode = ((gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK)
1535 >> I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT);
1536 switch (current_mode) {
1537 case I40E_COMBINED_ACTIVITY:
1538 case I40E_FILTER_ACTIVITY:
1539 case I40E_MAC_ACTIVITY:
1540 case I40E_LINK_ACTIVITY:
1546 gpio_val &= ~I40E_GLGEN_GPIO_CTL_LED_MODE_MASK;
1547 /* this & is a bit of paranoia, but serves as a range check */
1548 gpio_val |= ((mode << I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT) &
1549 I40E_GLGEN_GPIO_CTL_LED_MODE_MASK);
1552 gpio_val |= BIT(I40E_GLGEN_GPIO_CTL_LED_BLINK_SHIFT);
1554 gpio_val &= ~BIT(I40E_GLGEN_GPIO_CTL_LED_BLINK_SHIFT);
1556 wr32(hw, I40E_GLGEN_GPIO_CTL(i), gpio_val);
1561 /* Admin command wrappers */
1564 * i40e_aq_get_phy_capabilities
1565 * @hw: pointer to the hw struct
1566 * @abilities: structure for PHY capabilities to be filled
1567 * @qualified_modules: report Qualified Modules
1568 * @report_init: report init capabilities (active are default)
1569 * @cmd_details: pointer to command details structure or NULL
1571 * Returns the various PHY abilities supported on the Port.
1573 i40e_status i40e_aq_get_phy_capabilities(struct i40e_hw *hw,
1574 bool qualified_modules, bool report_init,
1575 struct i40e_aq_get_phy_abilities_resp *abilities,
1576 struct i40e_asq_cmd_details *cmd_details)
1578 struct i40e_aq_desc desc;
1580 u16 abilities_size = sizeof(struct i40e_aq_get_phy_abilities_resp);
1581 u16 max_delay = I40E_MAX_PHY_TIMEOUT, total_delay = 0;
1584 return I40E_ERR_PARAM;
1587 i40e_fill_default_direct_cmd_desc(&desc,
1588 i40e_aqc_opc_get_phy_abilities);
1590 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
1591 if (abilities_size > I40E_AQ_LARGE_BUF)
1592 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
1594 if (qualified_modules)
1595 desc.params.external.param0 |=
1596 cpu_to_le32(I40E_AQ_PHY_REPORT_QUALIFIED_MODULES);
1599 desc.params.external.param0 |=
1600 cpu_to_le32(I40E_AQ_PHY_REPORT_INITIAL_VALUES);
1602 status = i40e_asq_send_command(hw, &desc, abilities,
1603 abilities_size, cmd_details);
1608 if (hw->aq.asq_last_status == I40E_AQ_RC_EIO) {
1609 status = I40E_ERR_UNKNOWN_PHY;
1611 } else if (hw->aq.asq_last_status == I40E_AQ_RC_EAGAIN) {
1612 usleep_range(1000, 2000);
1614 status = I40E_ERR_TIMEOUT;
1616 } while ((hw->aq.asq_last_status != I40E_AQ_RC_OK) &&
1617 (total_delay < max_delay));
1623 if (hw->mac.type == I40E_MAC_XL710 &&
1624 hw->aq.api_maj_ver == I40E_FW_API_VERSION_MAJOR &&
1625 hw->aq.api_min_ver >= I40E_MINOR_VER_GET_LINK_INFO_XL710) {
1626 status = i40e_aq_get_link_info(hw, true, NULL, NULL);
1628 hw->phy.phy_types = le32_to_cpu(abilities->phy_type);
1629 hw->phy.phy_types |=
1630 ((u64)abilities->phy_type_ext << 32);
1638 * i40e_aq_set_phy_config
1639 * @hw: pointer to the hw struct
1640 * @config: structure with PHY configuration to be set
1641 * @cmd_details: pointer to command details structure or NULL
1643 * Set the various PHY configuration parameters
1644 * supported on the Port.One or more of the Set PHY config parameters may be
1645 * ignored in an MFP mode as the PF may not have the privilege to set some
1646 * of the PHY Config parameters. This status will be indicated by the
1649 enum i40e_status_code i40e_aq_set_phy_config(struct i40e_hw *hw,
1650 struct i40e_aq_set_phy_config *config,
1651 struct i40e_asq_cmd_details *cmd_details)
1653 struct i40e_aq_desc desc;
1654 struct i40e_aq_set_phy_config *cmd =
1655 (struct i40e_aq_set_phy_config *)&desc.params.raw;
1656 enum i40e_status_code status;
1659 return I40E_ERR_PARAM;
1661 i40e_fill_default_direct_cmd_desc(&desc,
1662 i40e_aqc_opc_set_phy_config);
1666 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1673 * @hw: pointer to the hw struct
1675 * Set the requested flow control mode using set_phy_config.
1677 enum i40e_status_code i40e_set_fc(struct i40e_hw *hw, u8 *aq_failures,
1678 bool atomic_restart)
1680 enum i40e_fc_mode fc_mode = hw->fc.requested_mode;
1681 struct i40e_aq_get_phy_abilities_resp abilities;
1682 struct i40e_aq_set_phy_config config;
1683 enum i40e_status_code status;
1684 u8 pause_mask = 0x0;
1690 pause_mask |= I40E_AQ_PHY_FLAG_PAUSE_TX;
1691 pause_mask |= I40E_AQ_PHY_FLAG_PAUSE_RX;
1693 case I40E_FC_RX_PAUSE:
1694 pause_mask |= I40E_AQ_PHY_FLAG_PAUSE_RX;
1696 case I40E_FC_TX_PAUSE:
1697 pause_mask |= I40E_AQ_PHY_FLAG_PAUSE_TX;
1703 /* Get the current phy config */
1704 status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities,
1707 *aq_failures |= I40E_SET_FC_AQ_FAIL_GET;
1711 memset(&config, 0, sizeof(struct i40e_aq_set_phy_config));
1712 /* clear the old pause settings */
1713 config.abilities = abilities.abilities & ~(I40E_AQ_PHY_FLAG_PAUSE_TX) &
1714 ~(I40E_AQ_PHY_FLAG_PAUSE_RX);
1715 /* set the new abilities */
1716 config.abilities |= pause_mask;
1717 /* If the abilities have changed, then set the new config */
1718 if (config.abilities != abilities.abilities) {
1719 /* Auto restart link so settings take effect */
1721 config.abilities |= I40E_AQ_PHY_ENABLE_ATOMIC_LINK;
1722 /* Copy over all the old settings */
1723 config.phy_type = abilities.phy_type;
1724 config.phy_type_ext = abilities.phy_type_ext;
1725 config.link_speed = abilities.link_speed;
1726 config.eee_capability = abilities.eee_capability;
1727 config.eeer = abilities.eeer_val;
1728 config.low_power_ctrl = abilities.d3_lpan;
1729 config.fec_config = abilities.fec_cfg_curr_mod_ext_info &
1730 I40E_AQ_PHY_FEC_CONFIG_MASK;
1731 status = i40e_aq_set_phy_config(hw, &config, NULL);
1734 *aq_failures |= I40E_SET_FC_AQ_FAIL_SET;
1736 /* Update the link info */
1737 status = i40e_update_link_info(hw);
1739 /* Wait a little bit (on 40G cards it sometimes takes a really
1740 * long time for link to come back from the atomic reset)
1744 status = i40e_update_link_info(hw);
1747 *aq_failures |= I40E_SET_FC_AQ_FAIL_UPDATE;
1753 * i40e_aq_clear_pxe_mode
1754 * @hw: pointer to the hw struct
1755 * @cmd_details: pointer to command details structure or NULL
1757 * Tell the firmware that the driver is taking over from PXE
1759 i40e_status i40e_aq_clear_pxe_mode(struct i40e_hw *hw,
1760 struct i40e_asq_cmd_details *cmd_details)
1763 struct i40e_aq_desc desc;
1764 struct i40e_aqc_clear_pxe *cmd =
1765 (struct i40e_aqc_clear_pxe *)&desc.params.raw;
1767 i40e_fill_default_direct_cmd_desc(&desc,
1768 i40e_aqc_opc_clear_pxe_mode);
1772 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1774 wr32(hw, I40E_GLLAN_RCTL_0, 0x1);
1780 * i40e_aq_set_link_restart_an
1781 * @hw: pointer to the hw struct
1782 * @enable_link: if true: enable link, if false: disable link
1783 * @cmd_details: pointer to command details structure or NULL
1785 * Sets up the link and restarts the Auto-Negotiation over the link.
1787 i40e_status i40e_aq_set_link_restart_an(struct i40e_hw *hw,
1789 struct i40e_asq_cmd_details *cmd_details)
1791 struct i40e_aq_desc desc;
1792 struct i40e_aqc_set_link_restart_an *cmd =
1793 (struct i40e_aqc_set_link_restart_an *)&desc.params.raw;
1796 i40e_fill_default_direct_cmd_desc(&desc,
1797 i40e_aqc_opc_set_link_restart_an);
1799 cmd->command = I40E_AQ_PHY_RESTART_AN;
1801 cmd->command |= I40E_AQ_PHY_LINK_ENABLE;
1803 cmd->command &= ~I40E_AQ_PHY_LINK_ENABLE;
1805 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1811 * i40e_aq_get_link_info
1812 * @hw: pointer to the hw struct
1813 * @enable_lse: enable/disable LinkStatusEvent reporting
1814 * @link: pointer to link status structure - optional
1815 * @cmd_details: pointer to command details structure or NULL
1817 * Returns the link status of the adapter.
1819 i40e_status i40e_aq_get_link_info(struct i40e_hw *hw,
1820 bool enable_lse, struct i40e_link_status *link,
1821 struct i40e_asq_cmd_details *cmd_details)
1823 struct i40e_aq_desc desc;
1824 struct i40e_aqc_get_link_status *resp =
1825 (struct i40e_aqc_get_link_status *)&desc.params.raw;
1826 struct i40e_link_status *hw_link_info = &hw->phy.link_info;
1828 bool tx_pause, rx_pause;
1831 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_get_link_status);
1834 command_flags = I40E_AQ_LSE_ENABLE;
1836 command_flags = I40E_AQ_LSE_DISABLE;
1837 resp->command_flags = cpu_to_le16(command_flags);
1839 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1842 goto aq_get_link_info_exit;
1844 /* save off old link status information */
1845 hw->phy.link_info_old = *hw_link_info;
1847 /* update link status */
1848 hw_link_info->phy_type = (enum i40e_aq_phy_type)resp->phy_type;
1849 hw->phy.media_type = i40e_get_media_type(hw);
1850 hw_link_info->link_speed = (enum i40e_aq_link_speed)resp->link_speed;
1851 hw_link_info->link_info = resp->link_info;
1852 hw_link_info->an_info = resp->an_info;
1853 hw_link_info->fec_info = resp->config & (I40E_AQ_CONFIG_FEC_KR_ENA |
1854 I40E_AQ_CONFIG_FEC_RS_ENA);
1855 hw_link_info->ext_info = resp->ext_info;
1856 hw_link_info->loopback = resp->loopback & I40E_AQ_LOOPBACK_MASK;
1857 hw_link_info->max_frame_size = le16_to_cpu(resp->max_frame_size);
1858 hw_link_info->pacing = resp->config & I40E_AQ_CONFIG_PACING_MASK;
1860 /* update fc info */
1861 tx_pause = !!(resp->an_info & I40E_AQ_LINK_PAUSE_TX);
1862 rx_pause = !!(resp->an_info & I40E_AQ_LINK_PAUSE_RX);
1863 if (tx_pause & rx_pause)
1864 hw->fc.current_mode = I40E_FC_FULL;
1866 hw->fc.current_mode = I40E_FC_TX_PAUSE;
1868 hw->fc.current_mode = I40E_FC_RX_PAUSE;
1870 hw->fc.current_mode = I40E_FC_NONE;
1872 if (resp->config & I40E_AQ_CONFIG_CRC_ENA)
1873 hw_link_info->crc_enable = true;
1875 hw_link_info->crc_enable = false;
1877 if (resp->command_flags & cpu_to_le16(I40E_AQ_LSE_IS_ENABLED))
1878 hw_link_info->lse_enable = true;
1880 hw_link_info->lse_enable = false;
1882 if ((hw->mac.type == I40E_MAC_XL710) &&
1883 (hw->aq.fw_maj_ver < 4 || (hw->aq.fw_maj_ver == 4 &&
1884 hw->aq.fw_min_ver < 40)) && hw_link_info->phy_type == 0xE)
1885 hw_link_info->phy_type = I40E_PHY_TYPE_10GBASE_SFPP_CU;
1887 if (hw->aq.api_maj_ver == I40E_FW_API_VERSION_MAJOR &&
1888 hw->aq.api_min_ver >= 7) {
1891 memcpy(&tmp, resp->link_type, sizeof(tmp));
1892 hw->phy.phy_types = le32_to_cpu(tmp);
1893 hw->phy.phy_types |= ((u64)resp->link_type_ext << 32);
1896 /* save link status information */
1898 *link = *hw_link_info;
1900 /* flag cleared so helper functions don't call AQ again */
1901 hw->phy.get_link_info = false;
1903 aq_get_link_info_exit:
1908 * i40e_aq_set_phy_int_mask
1909 * @hw: pointer to the hw struct
1910 * @mask: interrupt mask to be set
1911 * @cmd_details: pointer to command details structure or NULL
1913 * Set link interrupt mask.
1915 i40e_status i40e_aq_set_phy_int_mask(struct i40e_hw *hw,
1917 struct i40e_asq_cmd_details *cmd_details)
1919 struct i40e_aq_desc desc;
1920 struct i40e_aqc_set_phy_int_mask *cmd =
1921 (struct i40e_aqc_set_phy_int_mask *)&desc.params.raw;
1924 i40e_fill_default_direct_cmd_desc(&desc,
1925 i40e_aqc_opc_set_phy_int_mask);
1927 cmd->event_mask = cpu_to_le16(mask);
1929 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1935 * i40e_aq_set_phy_debug
1936 * @hw: pointer to the hw struct
1937 * @cmd_flags: debug command flags
1938 * @cmd_details: pointer to command details structure or NULL
1940 * Reset the external PHY.
1942 i40e_status i40e_aq_set_phy_debug(struct i40e_hw *hw, u8 cmd_flags,
1943 struct i40e_asq_cmd_details *cmd_details)
1945 struct i40e_aq_desc desc;
1946 struct i40e_aqc_set_phy_debug *cmd =
1947 (struct i40e_aqc_set_phy_debug *)&desc.params.raw;
1950 i40e_fill_default_direct_cmd_desc(&desc,
1951 i40e_aqc_opc_set_phy_debug);
1953 cmd->command_flags = cmd_flags;
1955 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1962 * @hw: pointer to the hw struct
1963 * @vsi_ctx: pointer to a vsi context struct
1964 * @cmd_details: pointer to command details structure or NULL
1966 * Add a VSI context to the hardware.
1968 i40e_status i40e_aq_add_vsi(struct i40e_hw *hw,
1969 struct i40e_vsi_context *vsi_ctx,
1970 struct i40e_asq_cmd_details *cmd_details)
1972 struct i40e_aq_desc desc;
1973 struct i40e_aqc_add_get_update_vsi *cmd =
1974 (struct i40e_aqc_add_get_update_vsi *)&desc.params.raw;
1975 struct i40e_aqc_add_get_update_vsi_completion *resp =
1976 (struct i40e_aqc_add_get_update_vsi_completion *)
1980 i40e_fill_default_direct_cmd_desc(&desc,
1981 i40e_aqc_opc_add_vsi);
1983 cmd->uplink_seid = cpu_to_le16(vsi_ctx->uplink_seid);
1984 cmd->connection_type = vsi_ctx->connection_type;
1985 cmd->vf_id = vsi_ctx->vf_num;
1986 cmd->vsi_flags = cpu_to_le16(vsi_ctx->flags);
1988 desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
1990 status = i40e_asq_send_command(hw, &desc, &vsi_ctx->info,
1991 sizeof(vsi_ctx->info), cmd_details);
1994 goto aq_add_vsi_exit;
1996 vsi_ctx->seid = le16_to_cpu(resp->seid);
1997 vsi_ctx->vsi_number = le16_to_cpu(resp->vsi_number);
1998 vsi_ctx->vsis_allocated = le16_to_cpu(resp->vsi_used);
1999 vsi_ctx->vsis_unallocated = le16_to_cpu(resp->vsi_free);
2006 * i40e_aq_set_default_vsi
2007 * @hw: pointer to the hw struct
2009 * @cmd_details: pointer to command details structure or NULL
2011 i40e_status i40e_aq_set_default_vsi(struct i40e_hw *hw,
2013 struct i40e_asq_cmd_details *cmd_details)
2015 struct i40e_aq_desc desc;
2016 struct i40e_aqc_set_vsi_promiscuous_modes *cmd =
2017 (struct i40e_aqc_set_vsi_promiscuous_modes *)
2021 i40e_fill_default_direct_cmd_desc(&desc,
2022 i40e_aqc_opc_set_vsi_promiscuous_modes);
2024 cmd->promiscuous_flags = cpu_to_le16(I40E_AQC_SET_VSI_DEFAULT);
2025 cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_DEFAULT);
2026 cmd->seid = cpu_to_le16(seid);
2028 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2034 * i40e_aq_clear_default_vsi
2035 * @hw: pointer to the hw struct
2037 * @cmd_details: pointer to command details structure or NULL
2039 i40e_status i40e_aq_clear_default_vsi(struct i40e_hw *hw,
2041 struct i40e_asq_cmd_details *cmd_details)
2043 struct i40e_aq_desc desc;
2044 struct i40e_aqc_set_vsi_promiscuous_modes *cmd =
2045 (struct i40e_aqc_set_vsi_promiscuous_modes *)
2049 i40e_fill_default_direct_cmd_desc(&desc,
2050 i40e_aqc_opc_set_vsi_promiscuous_modes);
2052 cmd->promiscuous_flags = cpu_to_le16(0);
2053 cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_DEFAULT);
2054 cmd->seid = cpu_to_le16(seid);
2056 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2062 * i40e_aq_set_vsi_unicast_promiscuous
2063 * @hw: pointer to the hw struct
2065 * @set: set unicast promiscuous enable/disable
2066 * @cmd_details: pointer to command details structure or NULL
2067 * @rx_only_promisc: flag to decide if egress traffic gets mirrored in promisc
2069 i40e_status i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw,
2071 struct i40e_asq_cmd_details *cmd_details,
2072 bool rx_only_promisc)
2074 struct i40e_aq_desc desc;
2075 struct i40e_aqc_set_vsi_promiscuous_modes *cmd =
2076 (struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw;
2080 i40e_fill_default_direct_cmd_desc(&desc,
2081 i40e_aqc_opc_set_vsi_promiscuous_modes);
2084 flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST;
2085 if (rx_only_promisc &&
2086 (((hw->aq.api_maj_ver == 1) && (hw->aq.api_min_ver >= 5)) ||
2087 (hw->aq.api_maj_ver > 1)))
2088 flags |= I40E_AQC_SET_VSI_PROMISC_TX;
2091 cmd->promiscuous_flags = cpu_to_le16(flags);
2093 cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_UNICAST);
2094 if (((hw->aq.api_maj_ver >= 1) && (hw->aq.api_min_ver >= 5)) ||
2095 (hw->aq.api_maj_ver > 1))
2096 cmd->valid_flags |= cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_TX);
2098 cmd->seid = cpu_to_le16(seid);
2099 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2105 * i40e_aq_set_vsi_multicast_promiscuous
2106 * @hw: pointer to the hw struct
2108 * @set: set multicast promiscuous enable/disable
2109 * @cmd_details: pointer to command details structure or NULL
2111 i40e_status i40e_aq_set_vsi_multicast_promiscuous(struct i40e_hw *hw,
2112 u16 seid, bool set, struct i40e_asq_cmd_details *cmd_details)
2114 struct i40e_aq_desc desc;
2115 struct i40e_aqc_set_vsi_promiscuous_modes *cmd =
2116 (struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw;
2120 i40e_fill_default_direct_cmd_desc(&desc,
2121 i40e_aqc_opc_set_vsi_promiscuous_modes);
2124 flags |= I40E_AQC_SET_VSI_PROMISC_MULTICAST;
2126 cmd->promiscuous_flags = cpu_to_le16(flags);
2128 cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_MULTICAST);
2130 cmd->seid = cpu_to_le16(seid);
2131 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2137 * i40e_aq_set_vsi_mc_promisc_on_vlan
2138 * @hw: pointer to the hw struct
2140 * @enable: set MAC L2 layer unicast promiscuous enable/disable for a given VLAN
2141 * @vid: The VLAN tag filter - capture any multicast packet with this VLAN tag
2142 * @cmd_details: pointer to command details structure or NULL
2144 enum i40e_status_code i40e_aq_set_vsi_mc_promisc_on_vlan(struct i40e_hw *hw,
2145 u16 seid, bool enable,
2147 struct i40e_asq_cmd_details *cmd_details)
2149 struct i40e_aq_desc desc;
2150 struct i40e_aqc_set_vsi_promiscuous_modes *cmd =
2151 (struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw;
2152 enum i40e_status_code status;
2155 i40e_fill_default_direct_cmd_desc(&desc,
2156 i40e_aqc_opc_set_vsi_promiscuous_modes);
2159 flags |= I40E_AQC_SET_VSI_PROMISC_MULTICAST;
2161 cmd->promiscuous_flags = cpu_to_le16(flags);
2162 cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_MULTICAST);
2163 cmd->seid = cpu_to_le16(seid);
2164 cmd->vlan_tag = cpu_to_le16(vid | I40E_AQC_SET_VSI_VLAN_VALID);
2166 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2172 * i40e_aq_set_vsi_uc_promisc_on_vlan
2173 * @hw: pointer to the hw struct
2175 * @enable: set MAC L2 layer unicast promiscuous enable/disable for a given VLAN
2176 * @vid: The VLAN tag filter - capture any unicast packet with this VLAN tag
2177 * @cmd_details: pointer to command details structure or NULL
2179 enum i40e_status_code i40e_aq_set_vsi_uc_promisc_on_vlan(struct i40e_hw *hw,
2180 u16 seid, bool enable,
2182 struct i40e_asq_cmd_details *cmd_details)
2184 struct i40e_aq_desc desc;
2185 struct i40e_aqc_set_vsi_promiscuous_modes *cmd =
2186 (struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw;
2187 enum i40e_status_code status;
2190 i40e_fill_default_direct_cmd_desc(&desc,
2191 i40e_aqc_opc_set_vsi_promiscuous_modes);
2194 flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST;
2196 cmd->promiscuous_flags = cpu_to_le16(flags);
2197 cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_UNICAST);
2198 cmd->seid = cpu_to_le16(seid);
2199 cmd->vlan_tag = cpu_to_le16(vid | I40E_AQC_SET_VSI_VLAN_VALID);
2201 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2207 * i40e_aq_set_vsi_bc_promisc_on_vlan
2208 * @hw: pointer to the hw struct
2210 * @enable: set broadcast promiscuous enable/disable for a given VLAN
2211 * @vid: The VLAN tag filter - capture any broadcast packet with this VLAN tag
2212 * @cmd_details: pointer to command details structure or NULL
2214 i40e_status i40e_aq_set_vsi_bc_promisc_on_vlan(struct i40e_hw *hw,
2215 u16 seid, bool enable, u16 vid,
2216 struct i40e_asq_cmd_details *cmd_details)
2218 struct i40e_aq_desc desc;
2219 struct i40e_aqc_set_vsi_promiscuous_modes *cmd =
2220 (struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw;
2224 i40e_fill_default_direct_cmd_desc(&desc,
2225 i40e_aqc_opc_set_vsi_promiscuous_modes);
2228 flags |= I40E_AQC_SET_VSI_PROMISC_BROADCAST;
2230 cmd->promiscuous_flags = cpu_to_le16(flags);
2231 cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_BROADCAST);
2232 cmd->seid = cpu_to_le16(seid);
2233 cmd->vlan_tag = cpu_to_le16(vid | I40E_AQC_SET_VSI_VLAN_VALID);
2235 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2241 * i40e_aq_set_vsi_broadcast
2242 * @hw: pointer to the hw struct
2244 * @set_filter: true to set filter, false to clear filter
2245 * @cmd_details: pointer to command details structure or NULL
2247 * Set or clear the broadcast promiscuous flag (filter) for a given VSI.
2249 i40e_status i40e_aq_set_vsi_broadcast(struct i40e_hw *hw,
2250 u16 seid, bool set_filter,
2251 struct i40e_asq_cmd_details *cmd_details)
2253 struct i40e_aq_desc desc;
2254 struct i40e_aqc_set_vsi_promiscuous_modes *cmd =
2255 (struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw;
2258 i40e_fill_default_direct_cmd_desc(&desc,
2259 i40e_aqc_opc_set_vsi_promiscuous_modes);
2262 cmd->promiscuous_flags
2263 |= cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_BROADCAST);
2265 cmd->promiscuous_flags
2266 &= cpu_to_le16(~I40E_AQC_SET_VSI_PROMISC_BROADCAST);
2268 cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_BROADCAST);
2269 cmd->seid = cpu_to_le16(seid);
2270 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2276 * i40e_aq_set_vsi_vlan_promisc - control the VLAN promiscuous setting
2277 * @hw: pointer to the hw struct
2279 * @enable: set MAC L2 layer unicast promiscuous enable/disable for a given VLAN
2280 * @cmd_details: pointer to command details structure or NULL
2282 i40e_status i40e_aq_set_vsi_vlan_promisc(struct i40e_hw *hw,
2283 u16 seid, bool enable,
2284 struct i40e_asq_cmd_details *cmd_details)
2286 struct i40e_aq_desc desc;
2287 struct i40e_aqc_set_vsi_promiscuous_modes *cmd =
2288 (struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw;
2292 i40e_fill_default_direct_cmd_desc(&desc,
2293 i40e_aqc_opc_set_vsi_promiscuous_modes);
2295 flags |= I40E_AQC_SET_VSI_PROMISC_VLAN;
2297 cmd->promiscuous_flags = cpu_to_le16(flags);
2298 cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_VLAN);
2299 cmd->seid = cpu_to_le16(seid);
2301 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2307 * i40e_get_vsi_params - get VSI configuration info
2308 * @hw: pointer to the hw struct
2309 * @vsi_ctx: pointer to a vsi context struct
2310 * @cmd_details: pointer to command details structure or NULL
2312 i40e_status i40e_aq_get_vsi_params(struct i40e_hw *hw,
2313 struct i40e_vsi_context *vsi_ctx,
2314 struct i40e_asq_cmd_details *cmd_details)
2316 struct i40e_aq_desc desc;
2317 struct i40e_aqc_add_get_update_vsi *cmd =
2318 (struct i40e_aqc_add_get_update_vsi *)&desc.params.raw;
2319 struct i40e_aqc_add_get_update_vsi_completion *resp =
2320 (struct i40e_aqc_add_get_update_vsi_completion *)
2324 i40e_fill_default_direct_cmd_desc(&desc,
2325 i40e_aqc_opc_get_vsi_parameters);
2327 cmd->uplink_seid = cpu_to_le16(vsi_ctx->seid);
2329 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
2331 status = i40e_asq_send_command(hw, &desc, &vsi_ctx->info,
2332 sizeof(vsi_ctx->info), NULL);
2335 goto aq_get_vsi_params_exit;
2337 vsi_ctx->seid = le16_to_cpu(resp->seid);
2338 vsi_ctx->vsi_number = le16_to_cpu(resp->vsi_number);
2339 vsi_ctx->vsis_allocated = le16_to_cpu(resp->vsi_used);
2340 vsi_ctx->vsis_unallocated = le16_to_cpu(resp->vsi_free);
2342 aq_get_vsi_params_exit:
2347 * i40e_aq_update_vsi_params
2348 * @hw: pointer to the hw struct
2349 * @vsi_ctx: pointer to a vsi context struct
2350 * @cmd_details: pointer to command details structure or NULL
2352 * Update a VSI context.
2354 i40e_status i40e_aq_update_vsi_params(struct i40e_hw *hw,
2355 struct i40e_vsi_context *vsi_ctx,
2356 struct i40e_asq_cmd_details *cmd_details)
2358 struct i40e_aq_desc desc;
2359 struct i40e_aqc_add_get_update_vsi *cmd =
2360 (struct i40e_aqc_add_get_update_vsi *)&desc.params.raw;
2361 struct i40e_aqc_add_get_update_vsi_completion *resp =
2362 (struct i40e_aqc_add_get_update_vsi_completion *)
2366 i40e_fill_default_direct_cmd_desc(&desc,
2367 i40e_aqc_opc_update_vsi_parameters);
2368 cmd->uplink_seid = cpu_to_le16(vsi_ctx->seid);
2370 desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
2372 status = i40e_asq_send_command(hw, &desc, &vsi_ctx->info,
2373 sizeof(vsi_ctx->info), cmd_details);
2375 vsi_ctx->vsis_allocated = le16_to_cpu(resp->vsi_used);
2376 vsi_ctx->vsis_unallocated = le16_to_cpu(resp->vsi_free);
2382 * i40e_aq_get_switch_config
2383 * @hw: pointer to the hardware structure
2384 * @buf: pointer to the result buffer
2385 * @buf_size: length of input buffer
2386 * @start_seid: seid to start for the report, 0 == beginning
2387 * @cmd_details: pointer to command details structure or NULL
2389 * Fill the buf with switch configuration returned from AdminQ command
2391 i40e_status i40e_aq_get_switch_config(struct i40e_hw *hw,
2392 struct i40e_aqc_get_switch_config_resp *buf,
2393 u16 buf_size, u16 *start_seid,
2394 struct i40e_asq_cmd_details *cmd_details)
2396 struct i40e_aq_desc desc;
2397 struct i40e_aqc_switch_seid *scfg =
2398 (struct i40e_aqc_switch_seid *)&desc.params.raw;
2401 i40e_fill_default_direct_cmd_desc(&desc,
2402 i40e_aqc_opc_get_switch_config);
2403 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
2404 if (buf_size > I40E_AQ_LARGE_BUF)
2405 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
2406 scfg->seid = cpu_to_le16(*start_seid);
2408 status = i40e_asq_send_command(hw, &desc, buf, buf_size, cmd_details);
2409 *start_seid = le16_to_cpu(scfg->seid);
2415 * i40e_aq_set_switch_config
2416 * @hw: pointer to the hardware structure
2417 * @flags: bit flag values to set
2418 * @valid_flags: which bit flags to set
2419 * @mode: cloud filter mode
2420 * @cmd_details: pointer to command details structure or NULL
2422 * Set switch configuration bits
2424 enum i40e_status_code i40e_aq_set_switch_config(struct i40e_hw *hw,
2426 u16 valid_flags, u8 mode,
2427 struct i40e_asq_cmd_details *cmd_details)
2429 struct i40e_aq_desc desc;
2430 struct i40e_aqc_set_switch_config *scfg =
2431 (struct i40e_aqc_set_switch_config *)&desc.params.raw;
2432 enum i40e_status_code status;
2434 i40e_fill_default_direct_cmd_desc(&desc,
2435 i40e_aqc_opc_set_switch_config);
2436 scfg->flags = cpu_to_le16(flags);
2437 scfg->valid_flags = cpu_to_le16(valid_flags);
2439 if (hw->flags & I40E_HW_FLAG_802_1AD_CAPABLE) {
2440 scfg->switch_tag = cpu_to_le16(hw->switch_tag);
2441 scfg->first_tag = cpu_to_le16(hw->first_tag);
2442 scfg->second_tag = cpu_to_le16(hw->second_tag);
2444 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2450 * i40e_aq_get_firmware_version
2451 * @hw: pointer to the hw struct
2452 * @fw_major_version: firmware major version
2453 * @fw_minor_version: firmware minor version
2454 * @fw_build: firmware build number
2455 * @api_major_version: major queue version
2456 * @api_minor_version: minor queue version
2457 * @cmd_details: pointer to command details structure or NULL
2459 * Get the firmware version from the admin queue commands
2461 i40e_status i40e_aq_get_firmware_version(struct i40e_hw *hw,
2462 u16 *fw_major_version, u16 *fw_minor_version,
2464 u16 *api_major_version, u16 *api_minor_version,
2465 struct i40e_asq_cmd_details *cmd_details)
2467 struct i40e_aq_desc desc;
2468 struct i40e_aqc_get_version *resp =
2469 (struct i40e_aqc_get_version *)&desc.params.raw;
2472 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_get_version);
2474 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2477 if (fw_major_version)
2478 *fw_major_version = le16_to_cpu(resp->fw_major);
2479 if (fw_minor_version)
2480 *fw_minor_version = le16_to_cpu(resp->fw_minor);
2482 *fw_build = le32_to_cpu(resp->fw_build);
2483 if (api_major_version)
2484 *api_major_version = le16_to_cpu(resp->api_major);
2485 if (api_minor_version)
2486 *api_minor_version = le16_to_cpu(resp->api_minor);
2493 * i40e_aq_send_driver_version
2494 * @hw: pointer to the hw struct
2495 * @dv: driver's major, minor version
2496 * @cmd_details: pointer to command details structure or NULL
2498 * Send the driver version to the firmware
2500 i40e_status i40e_aq_send_driver_version(struct i40e_hw *hw,
2501 struct i40e_driver_version *dv,
2502 struct i40e_asq_cmd_details *cmd_details)
2504 struct i40e_aq_desc desc;
2505 struct i40e_aqc_driver_version *cmd =
2506 (struct i40e_aqc_driver_version *)&desc.params.raw;
2511 return I40E_ERR_PARAM;
2513 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_driver_version);
2515 desc.flags |= cpu_to_le16(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD);
2516 cmd->driver_major_ver = dv->major_version;
2517 cmd->driver_minor_ver = dv->minor_version;
2518 cmd->driver_build_ver = dv->build_version;
2519 cmd->driver_subbuild_ver = dv->subbuild_version;
2522 while (len < sizeof(dv->driver_string) &&
2523 (dv->driver_string[len] < 0x80) &&
2524 dv->driver_string[len])
2526 status = i40e_asq_send_command(hw, &desc, dv->driver_string,
2533 * i40e_get_link_status - get status of the HW network link
2534 * @hw: pointer to the hw struct
2535 * @link_up: pointer to bool (true/false = linkup/linkdown)
2537 * Variable link_up true if link is up, false if link is down.
2538 * The variable link_up is invalid if returned value of status != 0
2540 * Side effect: LinkStatusEvent reporting becomes enabled
2542 i40e_status i40e_get_link_status(struct i40e_hw *hw, bool *link_up)
2544 i40e_status status = 0;
2546 if (hw->phy.get_link_info) {
2547 status = i40e_update_link_info(hw);
2550 i40e_debug(hw, I40E_DEBUG_LINK, "get link failed: status %d\n",
2554 *link_up = hw->phy.link_info.link_info & I40E_AQ_LINK_UP;
2560 * i40e_updatelink_status - update status of the HW network link
2561 * @hw: pointer to the hw struct
2563 i40e_status i40e_update_link_info(struct i40e_hw *hw)
2565 struct i40e_aq_get_phy_abilities_resp abilities;
2566 i40e_status status = 0;
2568 status = i40e_aq_get_link_info(hw, true, NULL, NULL);
2572 /* extra checking needed to ensure link info to user is timely */
2573 if ((hw->phy.link_info.link_info & I40E_AQ_MEDIA_AVAILABLE) &&
2574 ((hw->phy.link_info.link_info & I40E_AQ_LINK_UP) ||
2575 !(hw->phy.link_info_old.link_info & I40E_AQ_LINK_UP))) {
2576 status = i40e_aq_get_phy_capabilities(hw, false, false,
2581 hw->phy.link_info.req_fec_info =
2582 abilities.fec_cfg_curr_mod_ext_info &
2583 (I40E_AQ_REQUEST_FEC_KR | I40E_AQ_REQUEST_FEC_RS);
2585 memcpy(hw->phy.link_info.module_type, &abilities.module_type,
2586 sizeof(hw->phy.link_info.module_type));
2593 * i40e_aq_add_veb - Insert a VEB between the VSI and the MAC
2594 * @hw: pointer to the hw struct
2595 * @uplink_seid: the MAC or other gizmo SEID
2596 * @downlink_seid: the VSI SEID
2597 * @enabled_tc: bitmap of TCs to be enabled
2598 * @default_port: true for default port VSI, false for control port
2599 * @veb_seid: pointer to where to put the resulting VEB SEID
2600 * @enable_stats: true to turn on VEB stats
2601 * @cmd_details: pointer to command details structure or NULL
2603 * This asks the FW to add a VEB between the uplink and downlink
2604 * elements. If the uplink SEID is 0, this will be a floating VEB.
2606 i40e_status i40e_aq_add_veb(struct i40e_hw *hw, u16 uplink_seid,
2607 u16 downlink_seid, u8 enabled_tc,
2608 bool default_port, u16 *veb_seid,
2610 struct i40e_asq_cmd_details *cmd_details)
2612 struct i40e_aq_desc desc;
2613 struct i40e_aqc_add_veb *cmd =
2614 (struct i40e_aqc_add_veb *)&desc.params.raw;
2615 struct i40e_aqc_add_veb_completion *resp =
2616 (struct i40e_aqc_add_veb_completion *)&desc.params.raw;
2620 /* SEIDs need to either both be set or both be 0 for floating VEB */
2621 if (!!uplink_seid != !!downlink_seid)
2622 return I40E_ERR_PARAM;
2624 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_add_veb);
2626 cmd->uplink_seid = cpu_to_le16(uplink_seid);
2627 cmd->downlink_seid = cpu_to_le16(downlink_seid);
2628 cmd->enable_tcs = enabled_tc;
2630 veb_flags |= I40E_AQC_ADD_VEB_FLOATING;
2632 veb_flags |= I40E_AQC_ADD_VEB_PORT_TYPE_DEFAULT;
2634 veb_flags |= I40E_AQC_ADD_VEB_PORT_TYPE_DATA;
2636 /* reverse logic here: set the bitflag to disable the stats */
2638 veb_flags |= I40E_AQC_ADD_VEB_ENABLE_DISABLE_STATS;
2640 cmd->veb_flags = cpu_to_le16(veb_flags);
2642 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2644 if (!status && veb_seid)
2645 *veb_seid = le16_to_cpu(resp->veb_seid);
2651 * i40e_aq_get_veb_parameters - Retrieve VEB parameters
2652 * @hw: pointer to the hw struct
2653 * @veb_seid: the SEID of the VEB to query
2654 * @switch_id: the uplink switch id
2655 * @floating: set to true if the VEB is floating
2656 * @statistic_index: index of the stats counter block for this VEB
2657 * @vebs_used: number of VEB's used by function
2658 * @vebs_free: total VEB's not reserved by any function
2659 * @cmd_details: pointer to command details structure or NULL
2661 * This retrieves the parameters for a particular VEB, specified by
2662 * uplink_seid, and returns them to the caller.
2664 i40e_status i40e_aq_get_veb_parameters(struct i40e_hw *hw,
2665 u16 veb_seid, u16 *switch_id,
2666 bool *floating, u16 *statistic_index,
2667 u16 *vebs_used, u16 *vebs_free,
2668 struct i40e_asq_cmd_details *cmd_details)
2670 struct i40e_aq_desc desc;
2671 struct i40e_aqc_get_veb_parameters_completion *cmd_resp =
2672 (struct i40e_aqc_get_veb_parameters_completion *)
2677 return I40E_ERR_PARAM;
2679 i40e_fill_default_direct_cmd_desc(&desc,
2680 i40e_aqc_opc_get_veb_parameters);
2681 cmd_resp->seid = cpu_to_le16(veb_seid);
2683 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2688 *switch_id = le16_to_cpu(cmd_resp->switch_id);
2689 if (statistic_index)
2690 *statistic_index = le16_to_cpu(cmd_resp->statistic_index);
2692 *vebs_used = le16_to_cpu(cmd_resp->vebs_used);
2694 *vebs_free = le16_to_cpu(cmd_resp->vebs_free);
2696 u16 flags = le16_to_cpu(cmd_resp->veb_flags);
2698 if (flags & I40E_AQC_ADD_VEB_FLOATING)
2709 * i40e_aq_add_macvlan
2710 * @hw: pointer to the hw struct
2711 * @seid: VSI for the mac address
2712 * @mv_list: list of macvlans to be added
2713 * @count: length of the list
2714 * @cmd_details: pointer to command details structure or NULL
2716 * Add MAC/VLAN addresses to the HW filtering
2718 i40e_status i40e_aq_add_macvlan(struct i40e_hw *hw, u16 seid,
2719 struct i40e_aqc_add_macvlan_element_data *mv_list,
2720 u16 count, struct i40e_asq_cmd_details *cmd_details)
2722 struct i40e_aq_desc desc;
2723 struct i40e_aqc_macvlan *cmd =
2724 (struct i40e_aqc_macvlan *)&desc.params.raw;
2729 if (count == 0 || !mv_list || !hw)
2730 return I40E_ERR_PARAM;
2732 buf_size = count * sizeof(*mv_list);
2734 /* prep the rest of the request */
2735 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_add_macvlan);
2736 cmd->num_addresses = cpu_to_le16(count);
2737 cmd->seid[0] = cpu_to_le16(I40E_AQC_MACVLAN_CMD_SEID_VALID | seid);
2741 for (i = 0; i < count; i++)
2742 if (is_multicast_ether_addr(mv_list[i].mac_addr))
2744 cpu_to_le16(I40E_AQC_MACVLAN_ADD_USE_SHARED_MAC);
2746 desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
2747 if (buf_size > I40E_AQ_LARGE_BUF)
2748 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
2750 status = i40e_asq_send_command(hw, &desc, mv_list, buf_size,
2757 * i40e_aq_remove_macvlan
2758 * @hw: pointer to the hw struct
2759 * @seid: VSI for the mac address
2760 * @mv_list: list of macvlans to be removed
2761 * @count: length of the list
2762 * @cmd_details: pointer to command details structure or NULL
2764 * Remove MAC/VLAN addresses from the HW filtering
2766 i40e_status i40e_aq_remove_macvlan(struct i40e_hw *hw, u16 seid,
2767 struct i40e_aqc_remove_macvlan_element_data *mv_list,
2768 u16 count, struct i40e_asq_cmd_details *cmd_details)
2770 struct i40e_aq_desc desc;
2771 struct i40e_aqc_macvlan *cmd =
2772 (struct i40e_aqc_macvlan *)&desc.params.raw;
2776 if (count == 0 || !mv_list || !hw)
2777 return I40E_ERR_PARAM;
2779 buf_size = count * sizeof(*mv_list);
2781 /* prep the rest of the request */
2782 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_remove_macvlan);
2783 cmd->num_addresses = cpu_to_le16(count);
2784 cmd->seid[0] = cpu_to_le16(I40E_AQC_MACVLAN_CMD_SEID_VALID | seid);
2788 desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
2789 if (buf_size > I40E_AQ_LARGE_BUF)
2790 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
2792 status = i40e_asq_send_command(hw, &desc, mv_list, buf_size,
2799 * i40e_mirrorrule_op - Internal helper function to add/delete mirror rule
2800 * @hw: pointer to the hw struct
2801 * @opcode: AQ opcode for add or delete mirror rule
2802 * @sw_seid: Switch SEID (to which rule refers)
2803 * @rule_type: Rule Type (ingress/egress/VLAN)
2804 * @id: Destination VSI SEID or Rule ID
2805 * @count: length of the list
2806 * @mr_list: list of mirrored VSI SEIDs or VLAN IDs
2807 * @cmd_details: pointer to command details structure or NULL
2808 * @rule_id: Rule ID returned from FW
2809 * @rule_used: Number of rules used in internal switch
2810 * @rule_free: Number of rules free in internal switch
2812 * Add/Delete a mirror rule to a specific switch. Mirror rules are supported for
2813 * VEBs/VEPA elements only
2815 static i40e_status i40e_mirrorrule_op(struct i40e_hw *hw,
2816 u16 opcode, u16 sw_seid, u16 rule_type, u16 id,
2817 u16 count, __le16 *mr_list,
2818 struct i40e_asq_cmd_details *cmd_details,
2819 u16 *rule_id, u16 *rules_used, u16 *rules_free)
2821 struct i40e_aq_desc desc;
2822 struct i40e_aqc_add_delete_mirror_rule *cmd =
2823 (struct i40e_aqc_add_delete_mirror_rule *)&desc.params.raw;
2824 struct i40e_aqc_add_delete_mirror_rule_completion *resp =
2825 (struct i40e_aqc_add_delete_mirror_rule_completion *)&desc.params.raw;
2829 buf_size = count * sizeof(*mr_list);
2831 /* prep the rest of the request */
2832 i40e_fill_default_direct_cmd_desc(&desc, opcode);
2833 cmd->seid = cpu_to_le16(sw_seid);
2834 cmd->rule_type = cpu_to_le16(rule_type &
2835 I40E_AQC_MIRROR_RULE_TYPE_MASK);
2836 cmd->num_entries = cpu_to_le16(count);
2837 /* Dest VSI for add, rule_id for delete */
2838 cmd->destination = cpu_to_le16(id);
2840 desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF |
2842 if (buf_size > I40E_AQ_LARGE_BUF)
2843 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
2846 status = i40e_asq_send_command(hw, &desc, mr_list, buf_size,
2849 hw->aq.asq_last_status == I40E_AQ_RC_ENOSPC) {
2851 *rule_id = le16_to_cpu(resp->rule_id);
2853 *rules_used = le16_to_cpu(resp->mirror_rules_used);
2855 *rules_free = le16_to_cpu(resp->mirror_rules_free);
2861 * i40e_aq_add_mirrorrule - add a mirror rule
2862 * @hw: pointer to the hw struct
2863 * @sw_seid: Switch SEID (to which rule refers)
2864 * @rule_type: Rule Type (ingress/egress/VLAN)
2865 * @dest_vsi: SEID of VSI to which packets will be mirrored
2866 * @count: length of the list
2867 * @mr_list: list of mirrored VSI SEIDs or VLAN IDs
2868 * @cmd_details: pointer to command details structure or NULL
2869 * @rule_id: Rule ID returned from FW
2870 * @rule_used: Number of rules used in internal switch
2871 * @rule_free: Number of rules free in internal switch
2873 * Add mirror rule. Mirror rules are supported for VEBs or VEPA elements only
2875 i40e_status i40e_aq_add_mirrorrule(struct i40e_hw *hw, u16 sw_seid,
2876 u16 rule_type, u16 dest_vsi, u16 count, __le16 *mr_list,
2877 struct i40e_asq_cmd_details *cmd_details,
2878 u16 *rule_id, u16 *rules_used, u16 *rules_free)
2880 if (!(rule_type == I40E_AQC_MIRROR_RULE_TYPE_ALL_INGRESS ||
2881 rule_type == I40E_AQC_MIRROR_RULE_TYPE_ALL_EGRESS)) {
2882 if (count == 0 || !mr_list)
2883 return I40E_ERR_PARAM;
2886 return i40e_mirrorrule_op(hw, i40e_aqc_opc_add_mirror_rule, sw_seid,
2887 rule_type, dest_vsi, count, mr_list,
2888 cmd_details, rule_id, rules_used, rules_free);
2892 * i40e_aq_delete_mirrorrule - delete a mirror rule
2893 * @hw: pointer to the hw struct
2894 * @sw_seid: Switch SEID (to which rule refers)
2895 * @rule_type: Rule Type (ingress/egress/VLAN)
2896 * @count: length of the list
2897 * @rule_id: Rule ID that is returned in the receive desc as part of
2899 * @mr_list: list of mirrored VLAN IDs to be removed
2900 * @cmd_details: pointer to command details structure or NULL
2901 * @rule_used: Number of rules used in internal switch
2902 * @rule_free: Number of rules free in internal switch
2904 * Delete a mirror rule. Mirror rules are supported for VEBs/VEPA elements only
2906 i40e_status i40e_aq_delete_mirrorrule(struct i40e_hw *hw, u16 sw_seid,
2907 u16 rule_type, u16 rule_id, u16 count, __le16 *mr_list,
2908 struct i40e_asq_cmd_details *cmd_details,
2909 u16 *rules_used, u16 *rules_free)
2911 /* Rule ID has to be valid except rule_type: INGRESS VLAN mirroring */
2912 if (rule_type == I40E_AQC_MIRROR_RULE_TYPE_VLAN) {
2913 /* count and mr_list shall be valid for rule_type INGRESS VLAN
2914 * mirroring. For other rule_type, count and rule_type should
2917 if (count == 0 || !mr_list)
2918 return I40E_ERR_PARAM;
2921 return i40e_mirrorrule_op(hw, i40e_aqc_opc_delete_mirror_rule, sw_seid,
2922 rule_type, rule_id, count, mr_list,
2923 cmd_details, NULL, rules_used, rules_free);
2927 * i40e_aq_send_msg_to_vf
2928 * @hw: pointer to the hardware structure
2929 * @vfid: VF id to send msg
2930 * @v_opcode: opcodes for VF-PF communication
2931 * @v_retval: return error code
2932 * @msg: pointer to the msg buffer
2933 * @msglen: msg length
2934 * @cmd_details: pointer to command details
2938 i40e_status i40e_aq_send_msg_to_vf(struct i40e_hw *hw, u16 vfid,
2939 u32 v_opcode, u32 v_retval, u8 *msg, u16 msglen,
2940 struct i40e_asq_cmd_details *cmd_details)
2942 struct i40e_aq_desc desc;
2943 struct i40e_aqc_pf_vf_message *cmd =
2944 (struct i40e_aqc_pf_vf_message *)&desc.params.raw;
2947 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_send_msg_to_vf);
2948 cmd->id = cpu_to_le32(vfid);
2949 desc.cookie_high = cpu_to_le32(v_opcode);
2950 desc.cookie_low = cpu_to_le32(v_retval);
2951 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_SI);
2953 desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF |
2955 if (msglen > I40E_AQ_LARGE_BUF)
2956 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
2957 desc.datalen = cpu_to_le16(msglen);
2959 status = i40e_asq_send_command(hw, &desc, msg, msglen, cmd_details);
2965 * i40e_aq_debug_read_register
2966 * @hw: pointer to the hw struct
2967 * @reg_addr: register address
2968 * @reg_val: register value
2969 * @cmd_details: pointer to command details structure or NULL
2971 * Read the register using the admin queue commands
2973 i40e_status i40e_aq_debug_read_register(struct i40e_hw *hw,
2974 u32 reg_addr, u64 *reg_val,
2975 struct i40e_asq_cmd_details *cmd_details)
2977 struct i40e_aq_desc desc;
2978 struct i40e_aqc_debug_reg_read_write *cmd_resp =
2979 (struct i40e_aqc_debug_reg_read_write *)&desc.params.raw;
2982 if (reg_val == NULL)
2983 return I40E_ERR_PARAM;
2985 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_debug_read_reg);
2987 cmd_resp->address = cpu_to_le32(reg_addr);
2989 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2992 *reg_val = ((u64)le32_to_cpu(cmd_resp->value_high) << 32) |
2993 (u64)le32_to_cpu(cmd_resp->value_low);
3000 * i40e_aq_debug_write_register
3001 * @hw: pointer to the hw struct
3002 * @reg_addr: register address
3003 * @reg_val: register value
3004 * @cmd_details: pointer to command details structure or NULL
3006 * Write to a register using the admin queue commands
3008 i40e_status i40e_aq_debug_write_register(struct i40e_hw *hw,
3009 u32 reg_addr, u64 reg_val,
3010 struct i40e_asq_cmd_details *cmd_details)
3012 struct i40e_aq_desc desc;
3013 struct i40e_aqc_debug_reg_read_write *cmd =
3014 (struct i40e_aqc_debug_reg_read_write *)&desc.params.raw;
3017 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_debug_write_reg);
3019 cmd->address = cpu_to_le32(reg_addr);
3020 cmd->value_high = cpu_to_le32((u32)(reg_val >> 32));
3021 cmd->value_low = cpu_to_le32((u32)(reg_val & 0xFFFFFFFF));
3023 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3029 * i40e_aq_request_resource
3030 * @hw: pointer to the hw struct
3031 * @resource: resource id
3032 * @access: access type
3033 * @sdp_number: resource number
3034 * @timeout: the maximum time in ms that the driver may hold the resource
3035 * @cmd_details: pointer to command details structure or NULL
3037 * requests common resource using the admin queue commands
3039 i40e_status i40e_aq_request_resource(struct i40e_hw *hw,
3040 enum i40e_aq_resources_ids resource,
3041 enum i40e_aq_resource_access_type access,
3042 u8 sdp_number, u64 *timeout,
3043 struct i40e_asq_cmd_details *cmd_details)
3045 struct i40e_aq_desc desc;
3046 struct i40e_aqc_request_resource *cmd_resp =
3047 (struct i40e_aqc_request_resource *)&desc.params.raw;
3050 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_request_resource);
3052 cmd_resp->resource_id = cpu_to_le16(resource);
3053 cmd_resp->access_type = cpu_to_le16(access);
3054 cmd_resp->resource_number = cpu_to_le32(sdp_number);
3056 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3057 /* The completion specifies the maximum time in ms that the driver
3058 * may hold the resource in the Timeout field.
3059 * If the resource is held by someone else, the command completes with
3060 * busy return value and the timeout field indicates the maximum time
3061 * the current owner of the resource has to free it.
3063 if (!status || hw->aq.asq_last_status == I40E_AQ_RC_EBUSY)
3064 *timeout = le32_to_cpu(cmd_resp->timeout);
3070 * i40e_aq_release_resource
3071 * @hw: pointer to the hw struct
3072 * @resource: resource id
3073 * @sdp_number: resource number
3074 * @cmd_details: pointer to command details structure or NULL
3076 * release common resource using the admin queue commands
3078 i40e_status i40e_aq_release_resource(struct i40e_hw *hw,
3079 enum i40e_aq_resources_ids resource,
3081 struct i40e_asq_cmd_details *cmd_details)
3083 struct i40e_aq_desc desc;
3084 struct i40e_aqc_request_resource *cmd =
3085 (struct i40e_aqc_request_resource *)&desc.params.raw;
3088 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_release_resource);
3090 cmd->resource_id = cpu_to_le16(resource);
3091 cmd->resource_number = cpu_to_le32(sdp_number);
3093 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3100 * @hw: pointer to the hw struct
3101 * @module_pointer: module pointer location in words from the NVM beginning
3102 * @offset: byte offset from the module beginning
3103 * @length: length of the section to be read (in bytes from the offset)
3104 * @data: command buffer (size [bytes] = length)
3105 * @last_command: tells if this is the last command in a series
3106 * @cmd_details: pointer to command details structure or NULL
3108 * Read the NVM using the admin queue commands
3110 i40e_status i40e_aq_read_nvm(struct i40e_hw *hw, u8 module_pointer,
3111 u32 offset, u16 length, void *data,
3113 struct i40e_asq_cmd_details *cmd_details)
3115 struct i40e_aq_desc desc;
3116 struct i40e_aqc_nvm_update *cmd =
3117 (struct i40e_aqc_nvm_update *)&desc.params.raw;
3120 /* In offset the highest byte must be zeroed. */
3121 if (offset & 0xFF000000) {
3122 status = I40E_ERR_PARAM;
3123 goto i40e_aq_read_nvm_exit;
3126 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_nvm_read);
3128 /* If this is the last command in a series, set the proper flag. */
3130 cmd->command_flags |= I40E_AQ_NVM_LAST_CMD;
3131 cmd->module_pointer = module_pointer;
3132 cmd->offset = cpu_to_le32(offset);
3133 cmd->length = cpu_to_le16(length);
3135 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
3136 if (length > I40E_AQ_LARGE_BUF)
3137 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
3139 status = i40e_asq_send_command(hw, &desc, data, length, cmd_details);
3141 i40e_aq_read_nvm_exit:
3147 * @hw: pointer to the hw struct
3148 * @module_pointer: module pointer location in words from the NVM beginning
3149 * @offset: offset in the module (expressed in 4 KB from module's beginning)
3150 * @length: length of the section to be erased (expressed in 4 KB)
3151 * @last_command: tells if this is the last command in a series
3152 * @cmd_details: pointer to command details structure or NULL
3154 * Erase the NVM sector using the admin queue commands
3156 i40e_status i40e_aq_erase_nvm(struct i40e_hw *hw, u8 module_pointer,
3157 u32 offset, u16 length, bool last_command,
3158 struct i40e_asq_cmd_details *cmd_details)
3160 struct i40e_aq_desc desc;
3161 struct i40e_aqc_nvm_update *cmd =
3162 (struct i40e_aqc_nvm_update *)&desc.params.raw;
3165 /* In offset the highest byte must be zeroed. */
3166 if (offset & 0xFF000000) {
3167 status = I40E_ERR_PARAM;
3168 goto i40e_aq_erase_nvm_exit;
3171 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_nvm_erase);
3173 /* If this is the last command in a series, set the proper flag. */
3175 cmd->command_flags |= I40E_AQ_NVM_LAST_CMD;
3176 cmd->module_pointer = module_pointer;
3177 cmd->offset = cpu_to_le32(offset);
3178 cmd->length = cpu_to_le16(length);
3180 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3182 i40e_aq_erase_nvm_exit:
3187 * i40e_parse_discover_capabilities
3188 * @hw: pointer to the hw struct
3189 * @buff: pointer to a buffer containing device/function capability records
3190 * @cap_count: number of capability records in the list
3191 * @list_type_opc: type of capabilities list to parse
3193 * Parse the device/function capabilities list.
3195 static void i40e_parse_discover_capabilities(struct i40e_hw *hw, void *buff,
3197 enum i40e_admin_queue_opc list_type_opc)
3199 struct i40e_aqc_list_capabilities_element_resp *cap;
3200 u32 valid_functions, num_functions;
3201 u32 number, logical_id, phys_id;
3202 struct i40e_hw_capabilities *p;
3207 cap = (struct i40e_aqc_list_capabilities_element_resp *) buff;
3209 if (list_type_opc == i40e_aqc_opc_list_dev_capabilities)
3211 else if (list_type_opc == i40e_aqc_opc_list_func_capabilities)
3216 for (i = 0; i < cap_count; i++, cap++) {
3217 id = le16_to_cpu(cap->id);
3218 number = le32_to_cpu(cap->number);
3219 logical_id = le32_to_cpu(cap->logical_id);
3220 phys_id = le32_to_cpu(cap->phys_id);
3221 major_rev = cap->major_rev;
3224 case I40E_AQ_CAP_ID_SWITCH_MODE:
3225 p->switch_mode = number;
3227 case I40E_AQ_CAP_ID_MNG_MODE:
3228 p->management_mode = number;
3229 if (major_rev > 1) {
3230 p->mng_protocols_over_mctp = logical_id;
3231 i40e_debug(hw, I40E_DEBUG_INIT,
3232 "HW Capability: Protocols over MCTP = %d\n",
3233 p->mng_protocols_over_mctp);
3235 p->mng_protocols_over_mctp = 0;
3238 case I40E_AQ_CAP_ID_NPAR_ACTIVE:
3239 p->npar_enable = number;
3241 case I40E_AQ_CAP_ID_OS2BMC_CAP:
3244 case I40E_AQ_CAP_ID_FUNCTIONS_VALID:
3245 p->valid_functions = number;
3247 case I40E_AQ_CAP_ID_SRIOV:
3249 p->sr_iov_1_1 = true;
3251 case I40E_AQ_CAP_ID_VF:
3252 p->num_vfs = number;
3253 p->vf_base_id = logical_id;
3255 case I40E_AQ_CAP_ID_VMDQ:
3259 case I40E_AQ_CAP_ID_8021QBG:
3261 p->evb_802_1_qbg = true;
3263 case I40E_AQ_CAP_ID_8021QBR:
3265 p->evb_802_1_qbh = true;
3267 case I40E_AQ_CAP_ID_VSI:
3268 p->num_vsis = number;
3270 case I40E_AQ_CAP_ID_DCB:
3273 p->enabled_tcmap = logical_id;
3277 case I40E_AQ_CAP_ID_FCOE:
3281 case I40E_AQ_CAP_ID_ISCSI:
3285 case I40E_AQ_CAP_ID_RSS:
3287 p->rss_table_size = number;
3288 p->rss_table_entry_width = logical_id;
3290 case I40E_AQ_CAP_ID_RXQ:
3291 p->num_rx_qp = number;
3292 p->base_queue = phys_id;
3294 case I40E_AQ_CAP_ID_TXQ:
3295 p->num_tx_qp = number;
3296 p->base_queue = phys_id;
3298 case I40E_AQ_CAP_ID_MSIX:
3299 p->num_msix_vectors = number;
3300 i40e_debug(hw, I40E_DEBUG_INIT,
3301 "HW Capability: MSIX vector count = %d\n",
3302 p->num_msix_vectors);
3304 case I40E_AQ_CAP_ID_VF_MSIX:
3305 p->num_msix_vectors_vf = number;
3307 case I40E_AQ_CAP_ID_FLEX10:
3308 if (major_rev == 1) {
3310 p->flex10_enable = true;
3311 p->flex10_capable = true;
3314 /* Capability revision >= 2 */
3316 p->flex10_enable = true;
3318 p->flex10_capable = true;
3320 p->flex10_mode = logical_id;
3321 p->flex10_status = phys_id;
3323 case I40E_AQ_CAP_ID_CEM:
3327 case I40E_AQ_CAP_ID_IWARP:
3331 case I40E_AQ_CAP_ID_LED:
3332 if (phys_id < I40E_HW_CAP_MAX_GPIO)
3333 p->led[phys_id] = true;
3335 case I40E_AQ_CAP_ID_SDP:
3336 if (phys_id < I40E_HW_CAP_MAX_GPIO)
3337 p->sdp[phys_id] = true;
3339 case I40E_AQ_CAP_ID_MDIO:
3341 p->mdio_port_num = phys_id;
3342 p->mdio_port_mode = logical_id;
3345 case I40E_AQ_CAP_ID_1588:
3347 p->ieee_1588 = true;
3349 case I40E_AQ_CAP_ID_FLOW_DIRECTOR:
3351 p->fd_filters_guaranteed = number;
3352 p->fd_filters_best_effort = logical_id;
3354 case I40E_AQ_CAP_ID_WSR_PROT:
3355 p->wr_csr_prot = (u64)number;
3356 p->wr_csr_prot |= (u64)logical_id << 32;
3358 case I40E_AQ_CAP_ID_NVM_MGMT:
3359 if (number & I40E_NVM_MGMT_SEC_REV_DISABLED)
3360 p->sec_rev_disabled = true;
3361 if (number & I40E_NVM_MGMT_UPDATE_DISABLED)
3362 p->update_disabled = true;
3370 i40e_debug(hw, I40E_DEBUG_ALL, "device is FCoE capable\n");
3372 /* Software override ensuring FCoE is disabled if npar or mfp
3373 * mode because it is not supported in these modes.
3375 if (p->npar_enable || p->flex10_enable)
3378 /* count the enabled ports (aka the "not disabled" ports) */
3380 for (i = 0; i < 4; i++) {
3381 u32 port_cfg_reg = I40E_PRTGEN_CNF + (4 * i);
3384 /* use AQ read to get the physical register offset instead
3385 * of the port relative offset
3387 i40e_aq_debug_read_register(hw, port_cfg_reg, &port_cfg, NULL);
3388 if (!(port_cfg & I40E_PRTGEN_CNF_PORT_DIS_MASK))
3392 valid_functions = p->valid_functions;
3394 while (valid_functions) {
3395 if (valid_functions & 1)
3397 valid_functions >>= 1;
3400 /* partition id is 1-based, and functions are evenly spread
3401 * across the ports as partitions
3403 if (hw->num_ports != 0) {
3404 hw->partition_id = (hw->pf_id / hw->num_ports) + 1;
3405 hw->num_partitions = num_functions / hw->num_ports;
3408 /* additional HW specific goodies that might
3409 * someday be HW version specific
3411 p->rx_buf_chain_len = I40E_MAX_CHAINED_RX_BUFFERS;
3415 * i40e_aq_discover_capabilities
3416 * @hw: pointer to the hw struct
3417 * @buff: a virtual buffer to hold the capabilities
3418 * @buff_size: Size of the virtual buffer
3419 * @data_size: Size of the returned data, or buff size needed if AQ err==ENOMEM
3420 * @list_type_opc: capabilities type to discover - pass in the command opcode
3421 * @cmd_details: pointer to command details structure or NULL
3423 * Get the device capabilities descriptions from the firmware
3425 i40e_status i40e_aq_discover_capabilities(struct i40e_hw *hw,
3426 void *buff, u16 buff_size, u16 *data_size,
3427 enum i40e_admin_queue_opc list_type_opc,
3428 struct i40e_asq_cmd_details *cmd_details)
3430 struct i40e_aqc_list_capabilites *cmd;
3431 struct i40e_aq_desc desc;
3432 i40e_status status = 0;
3434 cmd = (struct i40e_aqc_list_capabilites *)&desc.params.raw;
3436 if (list_type_opc != i40e_aqc_opc_list_func_capabilities &&
3437 list_type_opc != i40e_aqc_opc_list_dev_capabilities) {
3438 status = I40E_ERR_PARAM;
3442 i40e_fill_default_direct_cmd_desc(&desc, list_type_opc);
3444 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
3445 if (buff_size > I40E_AQ_LARGE_BUF)
3446 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
3448 status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
3449 *data_size = le16_to_cpu(desc.datalen);
3454 i40e_parse_discover_capabilities(hw, buff, le32_to_cpu(cmd->count),
3462 * i40e_aq_update_nvm
3463 * @hw: pointer to the hw struct
3464 * @module_pointer: module pointer location in words from the NVM beginning
3465 * @offset: byte offset from the module beginning
3466 * @length: length of the section to be written (in bytes from the offset)
3467 * @data: command buffer (size [bytes] = length)
3468 * @last_command: tells if this is the last command in a series
3469 * @preservation_flags: Preservation mode flags
3470 * @cmd_details: pointer to command details structure or NULL
3472 * Update the NVM using the admin queue commands
3474 i40e_status i40e_aq_update_nvm(struct i40e_hw *hw, u8 module_pointer,
3475 u32 offset, u16 length, void *data,
3476 bool last_command, u8 preservation_flags,
3477 struct i40e_asq_cmd_details *cmd_details)
3479 struct i40e_aq_desc desc;
3480 struct i40e_aqc_nvm_update *cmd =
3481 (struct i40e_aqc_nvm_update *)&desc.params.raw;
3484 /* In offset the highest byte must be zeroed. */
3485 if (offset & 0xFF000000) {
3486 status = I40E_ERR_PARAM;
3487 goto i40e_aq_update_nvm_exit;
3490 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_nvm_update);
3492 /* If this is the last command in a series, set the proper flag. */
3494 cmd->command_flags |= I40E_AQ_NVM_LAST_CMD;
3495 if (hw->mac.type == I40E_MAC_X722) {
3496 if (preservation_flags == I40E_NVM_PRESERVATION_FLAGS_SELECTED)
3497 cmd->command_flags |=
3498 (I40E_AQ_NVM_PRESERVATION_FLAGS_SELECTED <<
3499 I40E_AQ_NVM_PRESERVATION_FLAGS_SHIFT);
3500 else if (preservation_flags == I40E_NVM_PRESERVATION_FLAGS_ALL)
3501 cmd->command_flags |=
3502 (I40E_AQ_NVM_PRESERVATION_FLAGS_ALL <<
3503 I40E_AQ_NVM_PRESERVATION_FLAGS_SHIFT);
3505 cmd->module_pointer = module_pointer;
3506 cmd->offset = cpu_to_le32(offset);
3507 cmd->length = cpu_to_le16(length);
3509 desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
3510 if (length > I40E_AQ_LARGE_BUF)
3511 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
3513 status = i40e_asq_send_command(hw, &desc, data, length, cmd_details);
3515 i40e_aq_update_nvm_exit:
3520 * i40e_aq_get_lldp_mib
3521 * @hw: pointer to the hw struct
3522 * @bridge_type: type of bridge requested
3523 * @mib_type: Local, Remote or both Local and Remote MIBs
3524 * @buff: pointer to a user supplied buffer to store the MIB block
3525 * @buff_size: size of the buffer (in bytes)
3526 * @local_len : length of the returned Local LLDP MIB
3527 * @remote_len: length of the returned Remote LLDP MIB
3528 * @cmd_details: pointer to command details structure or NULL
3530 * Requests the complete LLDP MIB (entire packet).
3532 i40e_status i40e_aq_get_lldp_mib(struct i40e_hw *hw, u8 bridge_type,
3533 u8 mib_type, void *buff, u16 buff_size,
3534 u16 *local_len, u16 *remote_len,
3535 struct i40e_asq_cmd_details *cmd_details)
3537 struct i40e_aq_desc desc;
3538 struct i40e_aqc_lldp_get_mib *cmd =
3539 (struct i40e_aqc_lldp_get_mib *)&desc.params.raw;
3540 struct i40e_aqc_lldp_get_mib *resp =
3541 (struct i40e_aqc_lldp_get_mib *)&desc.params.raw;
3544 if (buff_size == 0 || !buff)
3545 return I40E_ERR_PARAM;
3547 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_get_mib);
3548 /* Indirect Command */
3549 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
3551 cmd->type = mib_type & I40E_AQ_LLDP_MIB_TYPE_MASK;
3552 cmd->type |= ((bridge_type << I40E_AQ_LLDP_BRIDGE_TYPE_SHIFT) &
3553 I40E_AQ_LLDP_BRIDGE_TYPE_MASK);
3555 desc.datalen = cpu_to_le16(buff_size);
3557 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
3558 if (buff_size > I40E_AQ_LARGE_BUF)
3559 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
3561 status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
3563 if (local_len != NULL)
3564 *local_len = le16_to_cpu(resp->local_len);
3565 if (remote_len != NULL)
3566 *remote_len = le16_to_cpu(resp->remote_len);
3573 * i40e_aq_cfg_lldp_mib_change_event
3574 * @hw: pointer to the hw struct
3575 * @enable_update: Enable or Disable event posting
3576 * @cmd_details: pointer to command details structure or NULL
3578 * Enable or Disable posting of an event on ARQ when LLDP MIB
3579 * associated with the interface changes
3581 i40e_status i40e_aq_cfg_lldp_mib_change_event(struct i40e_hw *hw,
3583 struct i40e_asq_cmd_details *cmd_details)
3585 struct i40e_aq_desc desc;
3586 struct i40e_aqc_lldp_update_mib *cmd =
3587 (struct i40e_aqc_lldp_update_mib *)&desc.params.raw;
3590 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_update_mib);
3593 cmd->command |= I40E_AQ_LLDP_MIB_UPDATE_DISABLE;
3595 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3602 * @hw: pointer to the hw struct
3603 * @shutdown_agent: True if LLDP Agent needs to be Shutdown
3604 * @cmd_details: pointer to command details structure or NULL
3606 * Stop or Shutdown the embedded LLDP Agent
3608 i40e_status i40e_aq_stop_lldp(struct i40e_hw *hw, bool shutdown_agent,
3609 struct i40e_asq_cmd_details *cmd_details)
3611 struct i40e_aq_desc desc;
3612 struct i40e_aqc_lldp_stop *cmd =
3613 (struct i40e_aqc_lldp_stop *)&desc.params.raw;
3616 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_stop);
3619 cmd->command |= I40E_AQ_LLDP_AGENT_SHUTDOWN;
3621 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3627 * i40e_aq_start_lldp
3628 * @hw: pointer to the hw struct
3629 * @cmd_details: pointer to command details structure or NULL
3631 * Start the embedded LLDP Agent on all ports.
3633 i40e_status i40e_aq_start_lldp(struct i40e_hw *hw,
3634 struct i40e_asq_cmd_details *cmd_details)
3636 struct i40e_aq_desc desc;
3637 struct i40e_aqc_lldp_start *cmd =
3638 (struct i40e_aqc_lldp_start *)&desc.params.raw;
3641 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_start);
3643 cmd->command = I40E_AQ_LLDP_AGENT_START;
3644 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3650 * i40e_aq_set_dcb_parameters
3651 * @hw: pointer to the hw struct
3652 * @cmd_details: pointer to command details structure or NULL
3653 * @dcb_enable: True if DCB configuration needs to be applied
3656 enum i40e_status_code
3657 i40e_aq_set_dcb_parameters(struct i40e_hw *hw, bool dcb_enable,
3658 struct i40e_asq_cmd_details *cmd_details)
3660 struct i40e_aq_desc desc;
3661 struct i40e_aqc_set_dcb_parameters *cmd =
3662 (struct i40e_aqc_set_dcb_parameters *)&desc.params.raw;
3665 i40e_fill_default_direct_cmd_desc(&desc,
3666 i40e_aqc_opc_set_dcb_parameters);
3669 cmd->valid_flags = I40E_DCB_VALID;
3670 cmd->command = I40E_AQ_DCB_SET_AGENT;
3672 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3678 * i40e_aq_get_cee_dcb_config
3679 * @hw: pointer to the hw struct
3680 * @buff: response buffer that stores CEE operational configuration
3681 * @buff_size: size of the buffer passed
3682 * @cmd_details: pointer to command details structure or NULL
3684 * Get CEE DCBX mode operational configuration from firmware
3686 i40e_status i40e_aq_get_cee_dcb_config(struct i40e_hw *hw,
3687 void *buff, u16 buff_size,
3688 struct i40e_asq_cmd_details *cmd_details)
3690 struct i40e_aq_desc desc;
3693 if (buff_size == 0 || !buff)
3694 return I40E_ERR_PARAM;
3696 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_get_cee_dcb_cfg);
3698 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
3699 status = i40e_asq_send_command(hw, &desc, (void *)buff, buff_size,
3706 * i40e_aq_add_udp_tunnel
3707 * @hw: pointer to the hw struct
3708 * @udp_port: the UDP port to add in Host byte order
3709 * @header_len: length of the tunneling header length in DWords
3710 * @protocol_index: protocol index type
3711 * @filter_index: pointer to filter index
3712 * @cmd_details: pointer to command details structure or NULL
3714 * Note: Firmware expects the udp_port value to be in Little Endian format,
3715 * and this function will call cpu_to_le16 to convert from Host byte order to
3716 * Little Endian order.
3718 i40e_status i40e_aq_add_udp_tunnel(struct i40e_hw *hw,
3719 u16 udp_port, u8 protocol_index,
3721 struct i40e_asq_cmd_details *cmd_details)
3723 struct i40e_aq_desc desc;
3724 struct i40e_aqc_add_udp_tunnel *cmd =
3725 (struct i40e_aqc_add_udp_tunnel *)&desc.params.raw;
3726 struct i40e_aqc_del_udp_tunnel_completion *resp =
3727 (struct i40e_aqc_del_udp_tunnel_completion *)&desc.params.raw;
3730 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_add_udp_tunnel);
3732 cmd->udp_port = cpu_to_le16(udp_port);
3733 cmd->protocol_type = protocol_index;
3735 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3737 if (!status && filter_index)
3738 *filter_index = resp->index;
3744 * i40e_aq_del_udp_tunnel
3745 * @hw: pointer to the hw struct
3746 * @index: filter index
3747 * @cmd_details: pointer to command details structure or NULL
3749 i40e_status i40e_aq_del_udp_tunnel(struct i40e_hw *hw, u8 index,
3750 struct i40e_asq_cmd_details *cmd_details)
3752 struct i40e_aq_desc desc;
3753 struct i40e_aqc_remove_udp_tunnel *cmd =
3754 (struct i40e_aqc_remove_udp_tunnel *)&desc.params.raw;
3757 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_del_udp_tunnel);
3761 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3767 * i40e_aq_delete_element - Delete switch element
3768 * @hw: pointer to the hw struct
3769 * @seid: the SEID to delete from the switch
3770 * @cmd_details: pointer to command details structure or NULL
3772 * This deletes a switch element from the switch.
3774 i40e_status i40e_aq_delete_element(struct i40e_hw *hw, u16 seid,
3775 struct i40e_asq_cmd_details *cmd_details)
3777 struct i40e_aq_desc desc;
3778 struct i40e_aqc_switch_seid *cmd =
3779 (struct i40e_aqc_switch_seid *)&desc.params.raw;
3783 return I40E_ERR_PARAM;
3785 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_delete_element);
3787 cmd->seid = cpu_to_le16(seid);
3789 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3795 * i40e_aq_dcb_updated - DCB Updated Command
3796 * @hw: pointer to the hw struct
3797 * @cmd_details: pointer to command details structure or NULL
3799 * EMP will return when the shared RPB settings have been
3800 * recomputed and modified. The retval field in the descriptor
3801 * will be set to 0 when RPB is modified.
3803 i40e_status i40e_aq_dcb_updated(struct i40e_hw *hw,
3804 struct i40e_asq_cmd_details *cmd_details)
3806 struct i40e_aq_desc desc;
3809 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_dcb_updated);
3811 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3817 * i40e_aq_tx_sched_cmd - generic Tx scheduler AQ command handler
3818 * @hw: pointer to the hw struct
3819 * @seid: seid for the physical port/switching component/vsi
3820 * @buff: Indirect buffer to hold data parameters and response
3821 * @buff_size: Indirect buffer size
3822 * @opcode: Tx scheduler AQ command opcode
3823 * @cmd_details: pointer to command details structure or NULL
3825 * Generic command handler for Tx scheduler AQ commands
3827 static i40e_status i40e_aq_tx_sched_cmd(struct i40e_hw *hw, u16 seid,
3828 void *buff, u16 buff_size,
3829 enum i40e_admin_queue_opc opcode,
3830 struct i40e_asq_cmd_details *cmd_details)
3832 struct i40e_aq_desc desc;
3833 struct i40e_aqc_tx_sched_ind *cmd =
3834 (struct i40e_aqc_tx_sched_ind *)&desc.params.raw;
3836 bool cmd_param_flag = false;
3839 case i40e_aqc_opc_configure_vsi_ets_sla_bw_limit:
3840 case i40e_aqc_opc_configure_vsi_tc_bw:
3841 case i40e_aqc_opc_enable_switching_comp_ets:
3842 case i40e_aqc_opc_modify_switching_comp_ets:
3843 case i40e_aqc_opc_disable_switching_comp_ets:
3844 case i40e_aqc_opc_configure_switching_comp_ets_bw_limit:
3845 case i40e_aqc_opc_configure_switching_comp_bw_config:
3846 cmd_param_flag = true;
3848 case i40e_aqc_opc_query_vsi_bw_config:
3849 case i40e_aqc_opc_query_vsi_ets_sla_config:
3850 case i40e_aqc_opc_query_switching_comp_ets_config:
3851 case i40e_aqc_opc_query_port_ets_config:
3852 case i40e_aqc_opc_query_switching_comp_bw_config:
3853 cmd_param_flag = false;
3856 return I40E_ERR_PARAM;
3859 i40e_fill_default_direct_cmd_desc(&desc, opcode);
3861 /* Indirect command */
3862 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
3864 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_RD);
3865 if (buff_size > I40E_AQ_LARGE_BUF)
3866 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
3868 desc.datalen = cpu_to_le16(buff_size);
3870 cmd->vsi_seid = cpu_to_le16(seid);
3872 status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
3878 * i40e_aq_config_vsi_bw_limit - Configure VSI BW Limit
3879 * @hw: pointer to the hw struct
3881 * @credit: BW limit credits (0 = disabled)
3882 * @max_credit: Max BW limit credits
3883 * @cmd_details: pointer to command details structure or NULL
3885 i40e_status i40e_aq_config_vsi_bw_limit(struct i40e_hw *hw,
3886 u16 seid, u16 credit, u8 max_credit,
3887 struct i40e_asq_cmd_details *cmd_details)
3889 struct i40e_aq_desc desc;
3890 struct i40e_aqc_configure_vsi_bw_limit *cmd =
3891 (struct i40e_aqc_configure_vsi_bw_limit *)&desc.params.raw;
3894 i40e_fill_default_direct_cmd_desc(&desc,
3895 i40e_aqc_opc_configure_vsi_bw_limit);
3897 cmd->vsi_seid = cpu_to_le16(seid);
3898 cmd->credit = cpu_to_le16(credit);
3899 cmd->max_credit = max_credit;
3901 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3907 * i40e_aq_config_vsi_tc_bw - Config VSI BW Allocation per TC
3908 * @hw: pointer to the hw struct
3910 * @bw_data: Buffer holding enabled TCs, relative TC BW limit/credits
3911 * @cmd_details: pointer to command details structure or NULL
3913 i40e_status i40e_aq_config_vsi_tc_bw(struct i40e_hw *hw,
3915 struct i40e_aqc_configure_vsi_tc_bw_data *bw_data,
3916 struct i40e_asq_cmd_details *cmd_details)
3918 return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data),
3919 i40e_aqc_opc_configure_vsi_tc_bw,
3924 * i40e_aq_config_switch_comp_ets - Enable/Disable/Modify ETS on the port
3925 * @hw: pointer to the hw struct
3926 * @seid: seid of the switching component connected to Physical Port
3927 * @ets_data: Buffer holding ETS parameters
3928 * @cmd_details: pointer to command details structure or NULL
3930 i40e_status i40e_aq_config_switch_comp_ets(struct i40e_hw *hw,
3932 struct i40e_aqc_configure_switching_comp_ets_data *ets_data,
3933 enum i40e_admin_queue_opc opcode,
3934 struct i40e_asq_cmd_details *cmd_details)
3936 return i40e_aq_tx_sched_cmd(hw, seid, (void *)ets_data,
3937 sizeof(*ets_data), opcode, cmd_details);
3941 * i40e_aq_config_switch_comp_bw_config - Config Switch comp BW Alloc per TC
3942 * @hw: pointer to the hw struct
3943 * @seid: seid of the switching component
3944 * @bw_data: Buffer holding enabled TCs, relative/absolute TC BW limit/credits
3945 * @cmd_details: pointer to command details structure or NULL
3947 i40e_status i40e_aq_config_switch_comp_bw_config(struct i40e_hw *hw,
3949 struct i40e_aqc_configure_switching_comp_bw_config_data *bw_data,
3950 struct i40e_asq_cmd_details *cmd_details)
3952 return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data),
3953 i40e_aqc_opc_configure_switching_comp_bw_config,
3958 * i40e_aq_query_vsi_bw_config - Query VSI BW configuration
3959 * @hw: pointer to the hw struct
3960 * @seid: seid of the VSI
3961 * @bw_data: Buffer to hold VSI BW configuration
3962 * @cmd_details: pointer to command details structure or NULL
3964 i40e_status i40e_aq_query_vsi_bw_config(struct i40e_hw *hw,
3966 struct i40e_aqc_query_vsi_bw_config_resp *bw_data,
3967 struct i40e_asq_cmd_details *cmd_details)
3969 return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data),
3970 i40e_aqc_opc_query_vsi_bw_config,
3975 * i40e_aq_query_vsi_ets_sla_config - Query VSI BW configuration per TC
3976 * @hw: pointer to the hw struct
3977 * @seid: seid of the VSI
3978 * @bw_data: Buffer to hold VSI BW configuration per TC
3979 * @cmd_details: pointer to command details structure or NULL
3981 i40e_status i40e_aq_query_vsi_ets_sla_config(struct i40e_hw *hw,
3983 struct i40e_aqc_query_vsi_ets_sla_config_resp *bw_data,
3984 struct i40e_asq_cmd_details *cmd_details)
3986 return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data),
3987 i40e_aqc_opc_query_vsi_ets_sla_config,
3992 * i40e_aq_query_switch_comp_ets_config - Query Switch comp BW config per TC
3993 * @hw: pointer to the hw struct
3994 * @seid: seid of the switching component
3995 * @bw_data: Buffer to hold switching component's per TC BW config
3996 * @cmd_details: pointer to command details structure or NULL
3998 i40e_status i40e_aq_query_switch_comp_ets_config(struct i40e_hw *hw,
4000 struct i40e_aqc_query_switching_comp_ets_config_resp *bw_data,
4001 struct i40e_asq_cmd_details *cmd_details)
4003 return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data),
4004 i40e_aqc_opc_query_switching_comp_ets_config,
4009 * i40e_aq_query_port_ets_config - Query Physical Port ETS configuration
4010 * @hw: pointer to the hw struct
4011 * @seid: seid of the VSI or switching component connected to Physical Port
4012 * @bw_data: Buffer to hold current ETS configuration for the Physical Port
4013 * @cmd_details: pointer to command details structure or NULL
4015 i40e_status i40e_aq_query_port_ets_config(struct i40e_hw *hw,
4017 struct i40e_aqc_query_port_ets_config_resp *bw_data,
4018 struct i40e_asq_cmd_details *cmd_details)
4020 return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data),
4021 i40e_aqc_opc_query_port_ets_config,
4026 * i40e_aq_query_switch_comp_bw_config - Query Switch comp BW configuration
4027 * @hw: pointer to the hw struct
4028 * @seid: seid of the switching component
4029 * @bw_data: Buffer to hold switching component's BW configuration
4030 * @cmd_details: pointer to command details structure or NULL
4032 i40e_status i40e_aq_query_switch_comp_bw_config(struct i40e_hw *hw,
4034 struct i40e_aqc_query_switching_comp_bw_config_resp *bw_data,
4035 struct i40e_asq_cmd_details *cmd_details)
4037 return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data),
4038 i40e_aqc_opc_query_switching_comp_bw_config,
4043 * i40e_validate_filter_settings
4044 * @hw: pointer to the hardware structure
4045 * @settings: Filter control settings
4047 * Check and validate the filter control settings passed.
4048 * The function checks for the valid filter/context sizes being
4049 * passed for FCoE and PE.
4051 * Returns 0 if the values passed are valid and within
4052 * range else returns an error.
4054 static i40e_status i40e_validate_filter_settings(struct i40e_hw *hw,
4055 struct i40e_filter_control_settings *settings)
4057 u32 fcoe_cntx_size, fcoe_filt_size;
4058 u32 pe_cntx_size, pe_filt_size;
4062 /* Validate FCoE settings passed */
4063 switch (settings->fcoe_filt_num) {
4064 case I40E_HASH_FILTER_SIZE_1K:
4065 case I40E_HASH_FILTER_SIZE_2K:
4066 case I40E_HASH_FILTER_SIZE_4K:
4067 case I40E_HASH_FILTER_SIZE_8K:
4068 case I40E_HASH_FILTER_SIZE_16K:
4069 case I40E_HASH_FILTER_SIZE_32K:
4070 fcoe_filt_size = I40E_HASH_FILTER_BASE_SIZE;
4071 fcoe_filt_size <<= (u32)settings->fcoe_filt_num;
4074 return I40E_ERR_PARAM;
4077 switch (settings->fcoe_cntx_num) {
4078 case I40E_DMA_CNTX_SIZE_512:
4079 case I40E_DMA_CNTX_SIZE_1K:
4080 case I40E_DMA_CNTX_SIZE_2K:
4081 case I40E_DMA_CNTX_SIZE_4K:
4082 fcoe_cntx_size = I40E_DMA_CNTX_BASE_SIZE;
4083 fcoe_cntx_size <<= (u32)settings->fcoe_cntx_num;
4086 return I40E_ERR_PARAM;
4089 /* Validate PE settings passed */
4090 switch (settings->pe_filt_num) {
4091 case I40E_HASH_FILTER_SIZE_1K:
4092 case I40E_HASH_FILTER_SIZE_2K:
4093 case I40E_HASH_FILTER_SIZE_4K:
4094 case I40E_HASH_FILTER_SIZE_8K:
4095 case I40E_HASH_FILTER_SIZE_16K:
4096 case I40E_HASH_FILTER_SIZE_32K:
4097 case I40E_HASH_FILTER_SIZE_64K:
4098 case I40E_HASH_FILTER_SIZE_128K:
4099 case I40E_HASH_FILTER_SIZE_256K:
4100 case I40E_HASH_FILTER_SIZE_512K:
4101 case I40E_HASH_FILTER_SIZE_1M:
4102 pe_filt_size = I40E_HASH_FILTER_BASE_SIZE;
4103 pe_filt_size <<= (u32)settings->pe_filt_num;
4106 return I40E_ERR_PARAM;
4109 switch (settings->pe_cntx_num) {
4110 case I40E_DMA_CNTX_SIZE_512:
4111 case I40E_DMA_CNTX_SIZE_1K:
4112 case I40E_DMA_CNTX_SIZE_2K:
4113 case I40E_DMA_CNTX_SIZE_4K:
4114 case I40E_DMA_CNTX_SIZE_8K:
4115 case I40E_DMA_CNTX_SIZE_16K:
4116 case I40E_DMA_CNTX_SIZE_32K:
4117 case I40E_DMA_CNTX_SIZE_64K:
4118 case I40E_DMA_CNTX_SIZE_128K:
4119 case I40E_DMA_CNTX_SIZE_256K:
4120 pe_cntx_size = I40E_DMA_CNTX_BASE_SIZE;
4121 pe_cntx_size <<= (u32)settings->pe_cntx_num;
4124 return I40E_ERR_PARAM;
4127 /* FCHSIZE + FCDSIZE should not be greater than PMFCOEFMAX */
4128 val = rd32(hw, I40E_GLHMC_FCOEFMAX);
4129 fcoe_fmax = (val & I40E_GLHMC_FCOEFMAX_PMFCOEFMAX_MASK)
4130 >> I40E_GLHMC_FCOEFMAX_PMFCOEFMAX_SHIFT;
4131 if (fcoe_filt_size + fcoe_cntx_size > fcoe_fmax)
4132 return I40E_ERR_INVALID_SIZE;
4138 * i40e_set_filter_control
4139 * @hw: pointer to the hardware structure
4140 * @settings: Filter control settings
4142 * Set the Queue Filters for PE/FCoE and enable filters required
4143 * for a single PF. It is expected that these settings are programmed
4144 * at the driver initialization time.
4146 i40e_status i40e_set_filter_control(struct i40e_hw *hw,
4147 struct i40e_filter_control_settings *settings)
4149 i40e_status ret = 0;
4150 u32 hash_lut_size = 0;
4154 return I40E_ERR_PARAM;
4156 /* Validate the input settings */
4157 ret = i40e_validate_filter_settings(hw, settings);
4161 /* Read the PF Queue Filter control register */
4162 val = i40e_read_rx_ctl(hw, I40E_PFQF_CTL_0);
4164 /* Program required PE hash buckets for the PF */
4165 val &= ~I40E_PFQF_CTL_0_PEHSIZE_MASK;
4166 val |= ((u32)settings->pe_filt_num << I40E_PFQF_CTL_0_PEHSIZE_SHIFT) &
4167 I40E_PFQF_CTL_0_PEHSIZE_MASK;
4168 /* Program required PE contexts for the PF */
4169 val &= ~I40E_PFQF_CTL_0_PEDSIZE_MASK;
4170 val |= ((u32)settings->pe_cntx_num << I40E_PFQF_CTL_0_PEDSIZE_SHIFT) &
4171 I40E_PFQF_CTL_0_PEDSIZE_MASK;
4173 /* Program required FCoE hash buckets for the PF */
4174 val &= ~I40E_PFQF_CTL_0_PFFCHSIZE_MASK;
4175 val |= ((u32)settings->fcoe_filt_num <<
4176 I40E_PFQF_CTL_0_PFFCHSIZE_SHIFT) &
4177 I40E_PFQF_CTL_0_PFFCHSIZE_MASK;
4178 /* Program required FCoE DDP contexts for the PF */
4179 val &= ~I40E_PFQF_CTL_0_PFFCDSIZE_MASK;
4180 val |= ((u32)settings->fcoe_cntx_num <<
4181 I40E_PFQF_CTL_0_PFFCDSIZE_SHIFT) &
4182 I40E_PFQF_CTL_0_PFFCDSIZE_MASK;
4184 /* Program Hash LUT size for the PF */
4185 val &= ~I40E_PFQF_CTL_0_HASHLUTSIZE_MASK;
4186 if (settings->hash_lut_size == I40E_HASH_LUT_SIZE_512)
4188 val |= (hash_lut_size << I40E_PFQF_CTL_0_HASHLUTSIZE_SHIFT) &
4189 I40E_PFQF_CTL_0_HASHLUTSIZE_MASK;
4191 /* Enable FDIR, Ethertype and MACVLAN filters for PF and VFs */
4192 if (settings->enable_fdir)
4193 val |= I40E_PFQF_CTL_0_FD_ENA_MASK;
4194 if (settings->enable_ethtype)
4195 val |= I40E_PFQF_CTL_0_ETYPE_ENA_MASK;
4196 if (settings->enable_macvlan)
4197 val |= I40E_PFQF_CTL_0_MACVLAN_ENA_MASK;
4199 i40e_write_rx_ctl(hw, I40E_PFQF_CTL_0, val);
4205 * i40e_aq_add_rem_control_packet_filter - Add or Remove Control Packet Filter
4206 * @hw: pointer to the hw struct
4207 * @mac_addr: MAC address to use in the filter
4208 * @ethtype: Ethertype to use in the filter
4209 * @flags: Flags that needs to be applied to the filter
4210 * @vsi_seid: seid of the control VSI
4211 * @queue: VSI queue number to send the packet to
4212 * @is_add: Add control packet filter if True else remove
4213 * @stats: Structure to hold information on control filter counts
4214 * @cmd_details: pointer to command details structure or NULL
4216 * This command will Add or Remove control packet filter for a control VSI.
4217 * In return it will update the total number of perfect filter count in
4220 i40e_status i40e_aq_add_rem_control_packet_filter(struct i40e_hw *hw,
4221 u8 *mac_addr, u16 ethtype, u16 flags,
4222 u16 vsi_seid, u16 queue, bool is_add,
4223 struct i40e_control_filter_stats *stats,
4224 struct i40e_asq_cmd_details *cmd_details)
4226 struct i40e_aq_desc desc;
4227 struct i40e_aqc_add_remove_control_packet_filter *cmd =
4228 (struct i40e_aqc_add_remove_control_packet_filter *)
4230 struct i40e_aqc_add_remove_control_packet_filter_completion *resp =
4231 (struct i40e_aqc_add_remove_control_packet_filter_completion *)
4236 return I40E_ERR_PARAM;
4239 i40e_fill_default_direct_cmd_desc(&desc,
4240 i40e_aqc_opc_add_control_packet_filter);
4241 cmd->queue = cpu_to_le16(queue);
4243 i40e_fill_default_direct_cmd_desc(&desc,
4244 i40e_aqc_opc_remove_control_packet_filter);
4248 ether_addr_copy(cmd->mac, mac_addr);
4250 cmd->etype = cpu_to_le16(ethtype);
4251 cmd->flags = cpu_to_le16(flags);
4252 cmd->seid = cpu_to_le16(vsi_seid);
4254 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
4256 if (!status && stats) {
4257 stats->mac_etype_used = le16_to_cpu(resp->mac_etype_used);
4258 stats->etype_used = le16_to_cpu(resp->etype_used);
4259 stats->mac_etype_free = le16_to_cpu(resp->mac_etype_free);
4260 stats->etype_free = le16_to_cpu(resp->etype_free);
4267 * i40e_add_filter_to_drop_tx_flow_control_frames- filter to drop flow control
4268 * @hw: pointer to the hw struct
4269 * @seid: VSI seid to add ethertype filter from
4271 #define I40E_FLOW_CONTROL_ETHTYPE 0x8808
4272 void i40e_add_filter_to_drop_tx_flow_control_frames(struct i40e_hw *hw,
4275 u16 flag = I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC |
4276 I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP |
4277 I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TX;
4278 u16 ethtype = I40E_FLOW_CONTROL_ETHTYPE;
4281 status = i40e_aq_add_rem_control_packet_filter(hw, NULL, ethtype, flag,
4282 seid, 0, true, NULL,
4285 hw_dbg(hw, "Ethtype Filter Add failed: Error pruning Tx flow control frames\n");
4289 * i40e_aq_alternate_read
4290 * @hw: pointer to the hardware structure
4291 * @reg_addr0: address of first dword to be read
4292 * @reg_val0: pointer for data read from 'reg_addr0'
4293 * @reg_addr1: address of second dword to be read
4294 * @reg_val1: pointer for data read from 'reg_addr1'
4296 * Read one or two dwords from alternate structure. Fields are indicated
4297 * by 'reg_addr0' and 'reg_addr1' register numbers. If 'reg_val1' pointer
4298 * is not passed then only register at 'reg_addr0' is read.
4301 static i40e_status i40e_aq_alternate_read(struct i40e_hw *hw,
4302 u32 reg_addr0, u32 *reg_val0,
4303 u32 reg_addr1, u32 *reg_val1)
4305 struct i40e_aq_desc desc;
4306 struct i40e_aqc_alternate_write *cmd_resp =
4307 (struct i40e_aqc_alternate_write *)&desc.params.raw;
4311 return I40E_ERR_PARAM;
4313 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_alternate_read);
4314 cmd_resp->address0 = cpu_to_le32(reg_addr0);
4315 cmd_resp->address1 = cpu_to_le32(reg_addr1);
4317 status = i40e_asq_send_command(hw, &desc, NULL, 0, NULL);
4320 *reg_val0 = le32_to_cpu(cmd_resp->data0);
4323 *reg_val1 = le32_to_cpu(cmd_resp->data1);
4330 * i40e_aq_resume_port_tx
4331 * @hw: pointer to the hardware structure
4332 * @cmd_details: pointer to command details structure or NULL
4334 * Resume port's Tx traffic
4336 i40e_status i40e_aq_resume_port_tx(struct i40e_hw *hw,
4337 struct i40e_asq_cmd_details *cmd_details)
4339 struct i40e_aq_desc desc;
4342 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_resume_port_tx);
4344 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
4350 * i40e_set_pci_config_data - store PCI bus info
4351 * @hw: pointer to hardware structure
4352 * @link_status: the link status word from PCI config space
4354 * Stores the PCI bus info (speed, width, type) within the i40e_hw structure
4356 void i40e_set_pci_config_data(struct i40e_hw *hw, u16 link_status)
4358 hw->bus.type = i40e_bus_type_pci_express;
4360 switch (link_status & PCI_EXP_LNKSTA_NLW) {
4361 case PCI_EXP_LNKSTA_NLW_X1:
4362 hw->bus.width = i40e_bus_width_pcie_x1;
4364 case PCI_EXP_LNKSTA_NLW_X2:
4365 hw->bus.width = i40e_bus_width_pcie_x2;
4367 case PCI_EXP_LNKSTA_NLW_X4:
4368 hw->bus.width = i40e_bus_width_pcie_x4;
4370 case PCI_EXP_LNKSTA_NLW_X8:
4371 hw->bus.width = i40e_bus_width_pcie_x8;
4374 hw->bus.width = i40e_bus_width_unknown;
4378 switch (link_status & PCI_EXP_LNKSTA_CLS) {
4379 case PCI_EXP_LNKSTA_CLS_2_5GB:
4380 hw->bus.speed = i40e_bus_speed_2500;
4382 case PCI_EXP_LNKSTA_CLS_5_0GB:
4383 hw->bus.speed = i40e_bus_speed_5000;
4385 case PCI_EXP_LNKSTA_CLS_8_0GB:
4386 hw->bus.speed = i40e_bus_speed_8000;
4389 hw->bus.speed = i40e_bus_speed_unknown;
4395 * i40e_aq_debug_dump
4396 * @hw: pointer to the hardware structure
4397 * @cluster_id: specific cluster to dump
4398 * @table_id: table id within cluster
4399 * @start_index: index of line in the block to read
4400 * @buff_size: dump buffer size
4401 * @buff: dump buffer
4402 * @ret_buff_size: actual buffer size returned
4403 * @ret_next_table: next block to read
4404 * @ret_next_index: next index to read
4406 * Dump internal FW/HW data for debug purposes.
4409 i40e_status i40e_aq_debug_dump(struct i40e_hw *hw, u8 cluster_id,
4410 u8 table_id, u32 start_index, u16 buff_size,
4411 void *buff, u16 *ret_buff_size,
4412 u8 *ret_next_table, u32 *ret_next_index,
4413 struct i40e_asq_cmd_details *cmd_details)
4415 struct i40e_aq_desc desc;
4416 struct i40e_aqc_debug_dump_internals *cmd =
4417 (struct i40e_aqc_debug_dump_internals *)&desc.params.raw;
4418 struct i40e_aqc_debug_dump_internals *resp =
4419 (struct i40e_aqc_debug_dump_internals *)&desc.params.raw;
4422 if (buff_size == 0 || !buff)
4423 return I40E_ERR_PARAM;
4425 i40e_fill_default_direct_cmd_desc(&desc,
4426 i40e_aqc_opc_debug_dump_internals);
4427 /* Indirect Command */
4428 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
4429 if (buff_size > I40E_AQ_LARGE_BUF)
4430 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
4432 cmd->cluster_id = cluster_id;
4433 cmd->table_id = table_id;
4434 cmd->idx = cpu_to_le32(start_index);
4436 desc.datalen = cpu_to_le16(buff_size);
4438 status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
4441 *ret_buff_size = le16_to_cpu(desc.datalen);
4443 *ret_next_table = resp->table_id;
4445 *ret_next_index = le32_to_cpu(resp->idx);
4452 * i40e_read_bw_from_alt_ram
4453 * @hw: pointer to the hardware structure
4454 * @max_bw: pointer for max_bw read
4455 * @min_bw: pointer for min_bw read
4456 * @min_valid: pointer for bool that is true if min_bw is a valid value
4457 * @max_valid: pointer for bool that is true if max_bw is a valid value
4459 * Read bw from the alternate ram for the given pf
4461 i40e_status i40e_read_bw_from_alt_ram(struct i40e_hw *hw,
4462 u32 *max_bw, u32 *min_bw,
4463 bool *min_valid, bool *max_valid)
4466 u32 max_bw_addr, min_bw_addr;
4468 /* Calculate the address of the min/max bw registers */
4469 max_bw_addr = I40E_ALT_STRUCT_FIRST_PF_OFFSET +
4470 I40E_ALT_STRUCT_MAX_BW_OFFSET +
4471 (I40E_ALT_STRUCT_DWORDS_PER_PF * hw->pf_id);
4472 min_bw_addr = I40E_ALT_STRUCT_FIRST_PF_OFFSET +
4473 I40E_ALT_STRUCT_MIN_BW_OFFSET +
4474 (I40E_ALT_STRUCT_DWORDS_PER_PF * hw->pf_id);
4476 /* Read the bandwidths from alt ram */
4477 status = i40e_aq_alternate_read(hw, max_bw_addr, max_bw,
4478 min_bw_addr, min_bw);
4480 if (*min_bw & I40E_ALT_BW_VALID_MASK)
4485 if (*max_bw & I40E_ALT_BW_VALID_MASK)
4494 * i40e_aq_configure_partition_bw
4495 * @hw: pointer to the hardware structure
4496 * @bw_data: Buffer holding valid pfs and bw limits
4497 * @cmd_details: pointer to command details
4499 * Configure partitions guaranteed/max bw
4501 i40e_status i40e_aq_configure_partition_bw(struct i40e_hw *hw,
4502 struct i40e_aqc_configure_partition_bw_data *bw_data,
4503 struct i40e_asq_cmd_details *cmd_details)
4506 struct i40e_aq_desc desc;
4507 u16 bwd_size = sizeof(*bw_data);
4509 i40e_fill_default_direct_cmd_desc(&desc,
4510 i40e_aqc_opc_configure_partition_bw);
4512 /* Indirect command */
4513 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
4514 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_RD);
4516 if (bwd_size > I40E_AQ_LARGE_BUF)
4517 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
4519 desc.datalen = cpu_to_le16(bwd_size);
4521 status = i40e_asq_send_command(hw, &desc, bw_data, bwd_size,
4528 * i40e_read_phy_register_clause22
4529 * @hw: pointer to the HW structure
4530 * @reg: register address in the page
4531 * @phy_adr: PHY address on MDIO interface
4532 * @value: PHY register value
4534 * Reads specified PHY register value
4536 i40e_status i40e_read_phy_register_clause22(struct i40e_hw *hw,
4537 u16 reg, u8 phy_addr, u16 *value)
4539 i40e_status status = I40E_ERR_TIMEOUT;
4540 u8 port_num = (u8)hw->func_caps.mdio_port_num;
4544 command = (reg << I40E_GLGEN_MSCA_DEVADD_SHIFT) |
4545 (phy_addr << I40E_GLGEN_MSCA_PHYADD_SHIFT) |
4546 (I40E_MDIO_CLAUSE22_OPCODE_READ_MASK) |
4547 (I40E_MDIO_CLAUSE22_STCODE_MASK) |
4548 (I40E_GLGEN_MSCA_MDICMD_MASK);
4549 wr32(hw, I40E_GLGEN_MSCA(port_num), command);
4551 command = rd32(hw, I40E_GLGEN_MSCA(port_num));
4552 if (!(command & I40E_GLGEN_MSCA_MDICMD_MASK)) {
4561 i40e_debug(hw, I40E_DEBUG_PHY,
4562 "PHY: Can't write command to external PHY.\n");
4564 command = rd32(hw, I40E_GLGEN_MSRWD(port_num));
4565 *value = (command & I40E_GLGEN_MSRWD_MDIRDDATA_MASK) >>
4566 I40E_GLGEN_MSRWD_MDIRDDATA_SHIFT;
4573 * i40e_write_phy_register_clause22
4574 * @hw: pointer to the HW structure
4575 * @reg: register address in the page
4576 * @phy_adr: PHY address on MDIO interface
4577 * @value: PHY register value
4579 * Writes specified PHY register value
4581 i40e_status i40e_write_phy_register_clause22(struct i40e_hw *hw,
4582 u16 reg, u8 phy_addr, u16 value)
4584 i40e_status status = I40E_ERR_TIMEOUT;
4585 u8 port_num = (u8)hw->func_caps.mdio_port_num;
4589 command = value << I40E_GLGEN_MSRWD_MDIWRDATA_SHIFT;
4590 wr32(hw, I40E_GLGEN_MSRWD(port_num), command);
4592 command = (reg << I40E_GLGEN_MSCA_DEVADD_SHIFT) |
4593 (phy_addr << I40E_GLGEN_MSCA_PHYADD_SHIFT) |
4594 (I40E_MDIO_CLAUSE22_OPCODE_WRITE_MASK) |
4595 (I40E_MDIO_CLAUSE22_STCODE_MASK) |
4596 (I40E_GLGEN_MSCA_MDICMD_MASK);
4598 wr32(hw, I40E_GLGEN_MSCA(port_num), command);
4600 command = rd32(hw, I40E_GLGEN_MSCA(port_num));
4601 if (!(command & I40E_GLGEN_MSCA_MDICMD_MASK)) {
4613 * i40e_read_phy_register_clause45
4614 * @hw: pointer to the HW structure
4615 * @page: registers page number
4616 * @reg: register address in the page
4617 * @phy_adr: PHY address on MDIO interface
4618 * @value: PHY register value
4620 * Reads specified PHY register value
4622 i40e_status i40e_read_phy_register_clause45(struct i40e_hw *hw,
4623 u8 page, u16 reg, u8 phy_addr, u16 *value)
4625 i40e_status status = I40E_ERR_TIMEOUT;
4628 u8 port_num = hw->func_caps.mdio_port_num;
4630 command = (reg << I40E_GLGEN_MSCA_MDIADD_SHIFT) |
4631 (page << I40E_GLGEN_MSCA_DEVADD_SHIFT) |
4632 (phy_addr << I40E_GLGEN_MSCA_PHYADD_SHIFT) |
4633 (I40E_MDIO_CLAUSE45_OPCODE_ADDRESS_MASK) |
4634 (I40E_MDIO_CLAUSE45_STCODE_MASK) |
4635 (I40E_GLGEN_MSCA_MDICMD_MASK) |
4636 (I40E_GLGEN_MSCA_MDIINPROGEN_MASK);
4637 wr32(hw, I40E_GLGEN_MSCA(port_num), command);
4639 command = rd32(hw, I40E_GLGEN_MSCA(port_num));
4640 if (!(command & I40E_GLGEN_MSCA_MDICMD_MASK)) {
4644 usleep_range(10, 20);
4649 i40e_debug(hw, I40E_DEBUG_PHY,
4650 "PHY: Can't write command to external PHY.\n");
4654 command = (page << I40E_GLGEN_MSCA_DEVADD_SHIFT) |
4655 (phy_addr << I40E_GLGEN_MSCA_PHYADD_SHIFT) |
4656 (I40E_MDIO_CLAUSE45_OPCODE_READ_MASK) |
4657 (I40E_MDIO_CLAUSE45_STCODE_MASK) |
4658 (I40E_GLGEN_MSCA_MDICMD_MASK) |
4659 (I40E_GLGEN_MSCA_MDIINPROGEN_MASK);
4660 status = I40E_ERR_TIMEOUT;
4662 wr32(hw, I40E_GLGEN_MSCA(port_num), command);
4664 command = rd32(hw, I40E_GLGEN_MSCA(port_num));
4665 if (!(command & I40E_GLGEN_MSCA_MDICMD_MASK)) {
4669 usleep_range(10, 20);
4674 command = rd32(hw, I40E_GLGEN_MSRWD(port_num));
4675 *value = (command & I40E_GLGEN_MSRWD_MDIRDDATA_MASK) >>
4676 I40E_GLGEN_MSRWD_MDIRDDATA_SHIFT;
4678 i40e_debug(hw, I40E_DEBUG_PHY,
4679 "PHY: Can't read register value from external PHY.\n");
4687 * i40e_write_phy_register_clause45
4688 * @hw: pointer to the HW structure
4689 * @page: registers page number
4690 * @reg: register address in the page
4691 * @phy_adr: PHY address on MDIO interface
4692 * @value: PHY register value
4694 * Writes value to specified PHY register
4696 i40e_status i40e_write_phy_register_clause45(struct i40e_hw *hw,
4697 u8 page, u16 reg, u8 phy_addr, u16 value)
4699 i40e_status status = I40E_ERR_TIMEOUT;
4702 u8 port_num = hw->func_caps.mdio_port_num;
4704 command = (reg << I40E_GLGEN_MSCA_MDIADD_SHIFT) |
4705 (page << I40E_GLGEN_MSCA_DEVADD_SHIFT) |
4706 (phy_addr << I40E_GLGEN_MSCA_PHYADD_SHIFT) |
4707 (I40E_MDIO_CLAUSE45_OPCODE_ADDRESS_MASK) |
4708 (I40E_MDIO_CLAUSE45_STCODE_MASK) |
4709 (I40E_GLGEN_MSCA_MDICMD_MASK) |
4710 (I40E_GLGEN_MSCA_MDIINPROGEN_MASK);
4711 wr32(hw, I40E_GLGEN_MSCA(port_num), command);
4713 command = rd32(hw, I40E_GLGEN_MSCA(port_num));
4714 if (!(command & I40E_GLGEN_MSCA_MDICMD_MASK)) {
4718 usleep_range(10, 20);
4722 i40e_debug(hw, I40E_DEBUG_PHY,
4723 "PHY: Can't write command to external PHY.\n");
4727 command = value << I40E_GLGEN_MSRWD_MDIWRDATA_SHIFT;
4728 wr32(hw, I40E_GLGEN_MSRWD(port_num), command);
4730 command = (page << I40E_GLGEN_MSCA_DEVADD_SHIFT) |
4731 (phy_addr << I40E_GLGEN_MSCA_PHYADD_SHIFT) |
4732 (I40E_MDIO_CLAUSE45_OPCODE_WRITE_MASK) |
4733 (I40E_MDIO_CLAUSE45_STCODE_MASK) |
4734 (I40E_GLGEN_MSCA_MDICMD_MASK) |
4735 (I40E_GLGEN_MSCA_MDIINPROGEN_MASK);
4736 status = I40E_ERR_TIMEOUT;
4738 wr32(hw, I40E_GLGEN_MSCA(port_num), command);
4740 command = rd32(hw, I40E_GLGEN_MSCA(port_num));
4741 if (!(command & I40E_GLGEN_MSCA_MDICMD_MASK)) {
4745 usleep_range(10, 20);
4754 * i40e_write_phy_register
4755 * @hw: pointer to the HW structure
4756 * @page: registers page number
4757 * @reg: register address in the page
4758 * @phy_adr: PHY address on MDIO interface
4759 * @value: PHY register value
4761 * Writes value to specified PHY register
4763 i40e_status i40e_write_phy_register(struct i40e_hw *hw,
4764 u8 page, u16 reg, u8 phy_addr, u16 value)
4768 switch (hw->device_id) {
4769 case I40E_DEV_ID_1G_BASE_T_X722:
4770 status = i40e_write_phy_register_clause22(hw, reg, phy_addr,
4773 case I40E_DEV_ID_10G_BASE_T:
4774 case I40E_DEV_ID_10G_BASE_T4:
4775 case I40E_DEV_ID_10G_BASE_T_X722:
4776 case I40E_DEV_ID_25G_B:
4777 case I40E_DEV_ID_25G_SFP28:
4778 status = i40e_write_phy_register_clause45(hw, page, reg,
4782 status = I40E_ERR_UNKNOWN_PHY;
4790 * i40e_read_phy_register
4791 * @hw: pointer to the HW structure
4792 * @page: registers page number
4793 * @reg: register address in the page
4794 * @phy_adr: PHY address on MDIO interface
4795 * @value: PHY register value
4797 * Reads specified PHY register value
4799 i40e_status i40e_read_phy_register(struct i40e_hw *hw,
4800 u8 page, u16 reg, u8 phy_addr, u16 *value)
4804 switch (hw->device_id) {
4805 case I40E_DEV_ID_1G_BASE_T_X722:
4806 status = i40e_read_phy_register_clause22(hw, reg, phy_addr,
4809 case I40E_DEV_ID_10G_BASE_T:
4810 case I40E_DEV_ID_10G_BASE_T4:
4811 case I40E_DEV_ID_10G_BASE_T_X722:
4812 case I40E_DEV_ID_25G_B:
4813 case I40E_DEV_ID_25G_SFP28:
4814 status = i40e_read_phy_register_clause45(hw, page, reg,
4818 status = I40E_ERR_UNKNOWN_PHY;
4826 * i40e_get_phy_address
4827 * @hw: pointer to the HW structure
4828 * @dev_num: PHY port num that address we want
4829 * @phy_addr: Returned PHY address
4831 * Gets PHY address for current port
4833 u8 i40e_get_phy_address(struct i40e_hw *hw, u8 dev_num)
4835 u8 port_num = hw->func_caps.mdio_port_num;
4836 u32 reg_val = rd32(hw, I40E_GLGEN_MDIO_I2C_SEL(port_num));
4838 return (u8)(reg_val >> ((dev_num + 1) * 5)) & 0x1f;
4842 * i40e_blink_phy_led
4843 * @hw: pointer to the HW structure
4844 * @time: time how long led will blinks in secs
4845 * @interval: gap between LED on and off in msecs
4847 * Blinks PHY link LED
4849 i40e_status i40e_blink_phy_link_led(struct i40e_hw *hw,
4850 u32 time, u32 interval)
4852 i40e_status status = 0;
4857 u16 led_addr = I40E_PHY_LED_PROV_REG_1;
4861 i = rd32(hw, I40E_PFGEN_PORTNUM);
4862 port_num = (u8)(i & I40E_PFGEN_PORTNUM_PORT_NUM_MASK);
4863 phy_addr = i40e_get_phy_address(hw, port_num);
4865 for (gpio_led_port = 0; gpio_led_port < 3; gpio_led_port++,
4867 status = i40e_read_phy_register_clause45(hw,
4868 I40E_PHY_COM_REG_PAGE,
4872 goto phy_blinking_end;
4874 if (led_reg & I40E_PHY_LED_LINK_MODE_MASK) {
4876 status = i40e_write_phy_register_clause45(hw,
4877 I40E_PHY_COM_REG_PAGE,
4881 goto phy_blinking_end;
4886 if (time > 0 && interval > 0) {
4887 for (i = 0; i < time * 1000; i += interval) {
4888 status = i40e_read_phy_register_clause45(hw,
4889 I40E_PHY_COM_REG_PAGE,
4890 led_addr, phy_addr, &led_reg);
4892 goto restore_config;
4893 if (led_reg & I40E_PHY_LED_MANUAL_ON)
4896 led_reg = I40E_PHY_LED_MANUAL_ON;
4897 status = i40e_write_phy_register_clause45(hw,
4898 I40E_PHY_COM_REG_PAGE,
4899 led_addr, phy_addr, led_reg);
4901 goto restore_config;
4907 status = i40e_write_phy_register_clause45(hw,
4908 I40E_PHY_COM_REG_PAGE,
4909 led_addr, phy_addr, led_ctl);
4916 * i40e_led_get_reg - read LED register
4917 * @hw: pointer to the HW structure
4918 * @led_addr: LED register address
4919 * @reg_val: read register value
4921 static enum i40e_status_code i40e_led_get_reg(struct i40e_hw *hw, u16 led_addr,
4924 enum i40e_status_code status;
4930 if (hw->flags & I40E_HW_FLAG_AQ_PHY_ACCESS_CAPABLE) {
4932 i40e_aq_get_phy_register(hw,
4933 I40E_AQ_PHY_REG_ACCESS_EXTERNAL,
4934 I40E_PHY_COM_REG_PAGE,
4935 I40E_PHY_LED_PROV_REG_1,
4938 i = rd32(hw, I40E_PFGEN_PORTNUM);
4939 port_num = (u8)(i & I40E_PFGEN_PORTNUM_PORT_NUM_MASK);
4940 phy_addr = i40e_get_phy_address(hw, port_num);
4941 status = i40e_read_phy_register_clause45(hw,
4942 I40E_PHY_COM_REG_PAGE,
4950 * i40e_led_set_reg - write LED register
4951 * @hw: pointer to the HW structure
4952 * @led_addr: LED register address
4953 * @reg_val: register value to write
4955 static enum i40e_status_code i40e_led_set_reg(struct i40e_hw *hw, u16 led_addr,
4958 enum i40e_status_code status;
4963 if (hw->flags & I40E_HW_FLAG_AQ_PHY_ACCESS_CAPABLE) {
4965 i40e_aq_set_phy_register(hw,
4966 I40E_AQ_PHY_REG_ACCESS_EXTERNAL,
4967 I40E_PHY_COM_REG_PAGE,
4968 I40E_PHY_LED_PROV_REG_1,
4971 i = rd32(hw, I40E_PFGEN_PORTNUM);
4972 port_num = (u8)(i & I40E_PFGEN_PORTNUM_PORT_NUM_MASK);
4973 phy_addr = i40e_get_phy_address(hw, port_num);
4974 status = i40e_write_phy_register_clause45(hw,
4975 I40E_PHY_COM_REG_PAGE,
4984 * i40e_led_get_phy - return current on/off mode
4985 * @hw: pointer to the hw struct
4986 * @led_addr: address of led register to use
4987 * @val: original value of register to use
4990 i40e_status i40e_led_get_phy(struct i40e_hw *hw, u16 *led_addr,
4993 i40e_status status = 0;
5002 if (hw->flags & I40E_HW_FLAG_AQ_PHY_ACCESS_CAPABLE) {
5004 i40e_aq_get_phy_register(hw,
5005 I40E_AQ_PHY_REG_ACCESS_EXTERNAL,
5006 I40E_PHY_COM_REG_PAGE,
5007 I40E_PHY_LED_PROV_REG_1,
5009 if (status == I40E_SUCCESS)
5010 *val = (u16)reg_val_aq;
5013 temp_addr = I40E_PHY_LED_PROV_REG_1;
5014 i = rd32(hw, I40E_PFGEN_PORTNUM);
5015 port_num = (u8)(i & I40E_PFGEN_PORTNUM_PORT_NUM_MASK);
5016 phy_addr = i40e_get_phy_address(hw, port_num);
5018 for (gpio_led_port = 0; gpio_led_port < 3; gpio_led_port++,
5020 status = i40e_read_phy_register_clause45(hw,
5021 I40E_PHY_COM_REG_PAGE,
5022 temp_addr, phy_addr,
5027 if (reg_val & I40E_PHY_LED_LINK_MODE_MASK) {
5028 *led_addr = temp_addr;
5037 * @hw: pointer to the HW structure
5038 * @on: true or false
5039 * @mode: original val plus bit for set or ignore
5040 * Set led's on or off when controlled by the PHY
5043 i40e_status i40e_led_set_phy(struct i40e_hw *hw, bool on,
5044 u16 led_addr, u32 mode)
5046 i40e_status status = 0;
5050 status = i40e_led_get_reg(hw, led_addr, &led_reg);
5054 if (led_reg & I40E_PHY_LED_LINK_MODE_MASK) {
5056 status = i40e_led_set_reg(hw, led_addr, led_reg);
5060 status = i40e_led_get_reg(hw, led_addr, &led_reg);
5062 goto restore_config;
5064 led_reg = I40E_PHY_LED_MANUAL_ON;
5068 status = i40e_led_set_reg(hw, led_addr, led_reg);
5070 goto restore_config;
5071 if (mode & I40E_PHY_LED_MODE_ORIG) {
5072 led_ctl = (mode & I40E_PHY_LED_MODE_MASK);
5073 status = i40e_led_set_reg(hw, led_addr, led_ctl);
5078 status = i40e_led_set_reg(hw, led_addr, led_ctl);
5083 * i40e_aq_rx_ctl_read_register - use FW to read from an Rx control register
5084 * @hw: pointer to the hw struct
5085 * @reg_addr: register address
5086 * @reg_val: ptr to register value
5087 * @cmd_details: pointer to command details structure or NULL
5089 * Use the firmware to read the Rx control register,
5090 * especially useful if the Rx unit is under heavy pressure
5092 i40e_status i40e_aq_rx_ctl_read_register(struct i40e_hw *hw,
5093 u32 reg_addr, u32 *reg_val,
5094 struct i40e_asq_cmd_details *cmd_details)
5096 struct i40e_aq_desc desc;
5097 struct i40e_aqc_rx_ctl_reg_read_write *cmd_resp =
5098 (struct i40e_aqc_rx_ctl_reg_read_write *)&desc.params.raw;
5102 return I40E_ERR_PARAM;
5104 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_rx_ctl_reg_read);
5106 cmd_resp->address = cpu_to_le32(reg_addr);
5108 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
5111 *reg_val = le32_to_cpu(cmd_resp->value);
5117 * i40e_read_rx_ctl - read from an Rx control register
5118 * @hw: pointer to the hw struct
5119 * @reg_addr: register address
5121 u32 i40e_read_rx_ctl(struct i40e_hw *hw, u32 reg_addr)
5123 i40e_status status = 0;
5128 use_register = (((hw->aq.api_maj_ver == 1) &&
5129 (hw->aq.api_min_ver < 5)) ||
5130 (hw->mac.type == I40E_MAC_X722));
5131 if (!use_register) {
5133 status = i40e_aq_rx_ctl_read_register(hw, reg_addr, &val, NULL);
5134 if (hw->aq.asq_last_status == I40E_AQ_RC_EAGAIN && retry) {
5135 usleep_range(1000, 2000);
5141 /* if the AQ access failed, try the old-fashioned way */
5142 if (status || use_register)
5143 val = rd32(hw, reg_addr);
5149 * i40e_aq_rx_ctl_write_register
5150 * @hw: pointer to the hw struct
5151 * @reg_addr: register address
5152 * @reg_val: register value
5153 * @cmd_details: pointer to command details structure or NULL
5155 * Use the firmware to write to an Rx control register,
5156 * especially useful if the Rx unit is under heavy pressure
5158 i40e_status i40e_aq_rx_ctl_write_register(struct i40e_hw *hw,
5159 u32 reg_addr, u32 reg_val,
5160 struct i40e_asq_cmd_details *cmd_details)
5162 struct i40e_aq_desc desc;
5163 struct i40e_aqc_rx_ctl_reg_read_write *cmd =
5164 (struct i40e_aqc_rx_ctl_reg_read_write *)&desc.params.raw;
5167 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_rx_ctl_reg_write);
5169 cmd->address = cpu_to_le32(reg_addr);
5170 cmd->value = cpu_to_le32(reg_val);
5172 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
5178 * i40e_write_rx_ctl - write to an Rx control register
5179 * @hw: pointer to the hw struct
5180 * @reg_addr: register address
5181 * @reg_val: register value
5183 void i40e_write_rx_ctl(struct i40e_hw *hw, u32 reg_addr, u32 reg_val)
5185 i40e_status status = 0;
5189 use_register = (((hw->aq.api_maj_ver == 1) &&
5190 (hw->aq.api_min_ver < 5)) ||
5191 (hw->mac.type == I40E_MAC_X722));
5192 if (!use_register) {
5194 status = i40e_aq_rx_ctl_write_register(hw, reg_addr,
5196 if (hw->aq.asq_last_status == I40E_AQ_RC_EAGAIN && retry) {
5197 usleep_range(1000, 2000);
5203 /* if the AQ access failed, try the old-fashioned way */
5204 if (status || use_register)
5205 wr32(hw, reg_addr, reg_val);
5209 * i40e_aq_set_phy_register
5210 * @hw: pointer to the hw struct
5211 * @phy_select: select which phy should be accessed
5212 * @dev_addr: PHY device address
5213 * @reg_addr: PHY register address
5214 * @reg_val: new register value
5215 * @cmd_details: pointer to command details structure or NULL
5217 * Write the external PHY register.
5219 i40e_status i40e_aq_set_phy_register(struct i40e_hw *hw,
5220 u8 phy_select, u8 dev_addr,
5221 u32 reg_addr, u32 reg_val,
5222 struct i40e_asq_cmd_details *cmd_details)
5224 struct i40e_aq_desc desc;
5225 struct i40e_aqc_phy_register_access *cmd =
5226 (struct i40e_aqc_phy_register_access *)&desc.params.raw;
5229 i40e_fill_default_direct_cmd_desc(&desc,
5230 i40e_aqc_opc_set_phy_register);
5232 cmd->phy_interface = phy_select;
5233 cmd->dev_address = dev_addr;
5234 cmd->reg_address = cpu_to_le32(reg_addr);
5235 cmd->reg_value = cpu_to_le32(reg_val);
5237 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
5243 * i40e_aq_get_phy_register
5244 * @hw: pointer to the hw struct
5245 * @phy_select: select which phy should be accessed
5246 * @dev_addr: PHY device address
5247 * @reg_addr: PHY register address
5248 * @reg_val: read register value
5249 * @cmd_details: pointer to command details structure or NULL
5251 * Read the external PHY register.
5253 i40e_status i40e_aq_get_phy_register(struct i40e_hw *hw,
5254 u8 phy_select, u8 dev_addr,
5255 u32 reg_addr, u32 *reg_val,
5256 struct i40e_asq_cmd_details *cmd_details)
5258 struct i40e_aq_desc desc;
5259 struct i40e_aqc_phy_register_access *cmd =
5260 (struct i40e_aqc_phy_register_access *)&desc.params.raw;
5263 i40e_fill_default_direct_cmd_desc(&desc,
5264 i40e_aqc_opc_get_phy_register);
5266 cmd->phy_interface = phy_select;
5267 cmd->dev_address = dev_addr;
5268 cmd->reg_address = cpu_to_le32(reg_addr);
5270 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
5272 *reg_val = le32_to_cpu(cmd->reg_value);
5278 * i40e_aq_write_ddp - Write dynamic device personalization (ddp)
5279 * @hw: pointer to the hw struct
5280 * @buff: command buffer (size in bytes = buff_size)
5281 * @buff_size: buffer size in bytes
5282 * @track_id: package tracking id
5283 * @error_offset: returns error offset
5284 * @error_info: returns error information
5285 * @cmd_details: pointer to command details structure or NULL
5288 i40e_status_code i40e_aq_write_ddp(struct i40e_hw *hw, void *buff,
5289 u16 buff_size, u32 track_id,
5290 u32 *error_offset, u32 *error_info,
5291 struct i40e_asq_cmd_details *cmd_details)
5293 struct i40e_aq_desc desc;
5294 struct i40e_aqc_write_personalization_profile *cmd =
5295 (struct i40e_aqc_write_personalization_profile *)
5297 struct i40e_aqc_write_ddp_resp *resp;
5300 i40e_fill_default_direct_cmd_desc(&desc,
5301 i40e_aqc_opc_write_personalization_profile);
5303 desc.flags |= cpu_to_le16(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD);
5304 if (buff_size > I40E_AQ_LARGE_BUF)
5305 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
5307 desc.datalen = cpu_to_le16(buff_size);
5309 cmd->profile_track_id = cpu_to_le32(track_id);
5311 status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
5313 resp = (struct i40e_aqc_write_ddp_resp *)&desc.params.raw;
5315 *error_offset = le32_to_cpu(resp->error_offset);
5317 *error_info = le32_to_cpu(resp->error_info);
5324 * i40e_aq_get_ddp_list - Read dynamic device personalization (ddp)
5325 * @hw: pointer to the hw struct
5326 * @buff: command buffer (size in bytes = buff_size)
5327 * @buff_size: buffer size in bytes
5328 * @cmd_details: pointer to command details structure or NULL
5331 i40e_status_code i40e_aq_get_ddp_list(struct i40e_hw *hw, void *buff,
5332 u16 buff_size, u8 flags,
5333 struct i40e_asq_cmd_details *cmd_details)
5335 struct i40e_aq_desc desc;
5336 struct i40e_aqc_get_applied_profiles *cmd =
5337 (struct i40e_aqc_get_applied_profiles *)&desc.params.raw;
5340 i40e_fill_default_direct_cmd_desc(&desc,
5341 i40e_aqc_opc_get_personalization_profile_list);
5343 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
5344 if (buff_size > I40E_AQ_LARGE_BUF)
5345 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
5346 desc.datalen = cpu_to_le16(buff_size);
5350 status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
5356 * i40e_find_segment_in_package
5357 * @segment_type: the segment type to search for (i.e., SEGMENT_TYPE_I40E)
5358 * @pkg_hdr: pointer to the package header to be searched
5360 * This function searches a package file for a particular segment type. On
5361 * success it returns a pointer to the segment header, otherwise it will
5364 struct i40e_generic_seg_header *
5365 i40e_find_segment_in_package(u32 segment_type,
5366 struct i40e_package_header *pkg_hdr)
5368 struct i40e_generic_seg_header *segment;
5371 /* Search all package segments for the requested segment type */
5372 for (i = 0; i < pkg_hdr->segment_count; i++) {
5374 (struct i40e_generic_seg_header *)((u8 *)pkg_hdr +
5375 pkg_hdr->segment_offset[i]);
5377 if (segment->type == segment_type)
5385 * i40e_write_profile
5386 * @hw: pointer to the hardware structure
5387 * @profile: pointer to the profile segment of the package to be downloaded
5388 * @track_id: package tracking id
5390 * Handles the download of a complete package.
5392 enum i40e_status_code
5393 i40e_write_profile(struct i40e_hw *hw, struct i40e_profile_segment *profile,
5396 i40e_status status = 0;
5397 struct i40e_section_table *sec_tbl;
5398 struct i40e_profile_section_header *sec = NULL;
5402 u32 section_size = 0;
5403 u32 offset = 0, info = 0;
5406 dev_cnt = profile->device_table_count;
5408 for (i = 0; i < dev_cnt; i++) {
5409 vendor_dev_id = profile->device_table[i].vendor_dev_id;
5410 if ((vendor_dev_id >> 16) == PCI_VENDOR_ID_INTEL)
5411 if (hw->device_id == (vendor_dev_id & 0xFFFF))
5415 i40e_debug(hw, I40E_DEBUG_PACKAGE, "Device doesn't support DDP");
5416 return I40E_ERR_DEVICE_NOT_SUPPORTED;
5419 nvm = (u32 *)&profile->device_table[dev_cnt];
5420 sec_tbl = (struct i40e_section_table *)&nvm[nvm[0] + 1];
5422 for (i = 0; i < sec_tbl->section_count; i++) {
5423 sec = (struct i40e_profile_section_header *)((u8 *)profile +
5424 sec_tbl->section_offset[i]);
5426 /* Skip 'AQ', 'note' and 'name' sections */
5427 if (sec->section.type != SECTION_TYPE_MMIO)
5430 section_size = sec->section.size +
5431 sizeof(struct i40e_profile_section_header);
5434 status = i40e_aq_write_ddp(hw, (void *)sec, (u16)section_size,
5435 track_id, &offset, &info, NULL);
5437 i40e_debug(hw, I40E_DEBUG_PACKAGE,
5438 "Failed to write profile: offset %d, info %d",
5447 * i40e_add_pinfo_to_list
5448 * @hw: pointer to the hardware structure
5449 * @profile: pointer to the profile segment of the package
5450 * @profile_info_sec: buffer for information section
5451 * @track_id: package tracking id
5453 * Register a profile to the list of loaded profiles.
5455 enum i40e_status_code
5456 i40e_add_pinfo_to_list(struct i40e_hw *hw,
5457 struct i40e_profile_segment *profile,
5458 u8 *profile_info_sec, u32 track_id)
5460 i40e_status status = 0;
5461 struct i40e_profile_section_header *sec = NULL;
5462 struct i40e_profile_info *pinfo;
5463 u32 offset = 0, info = 0;
5465 sec = (struct i40e_profile_section_header *)profile_info_sec;
5467 sec->data_end = sizeof(struct i40e_profile_section_header) +
5468 sizeof(struct i40e_profile_info);
5469 sec->section.type = SECTION_TYPE_INFO;
5470 sec->section.offset = sizeof(struct i40e_profile_section_header);
5471 sec->section.size = sizeof(struct i40e_profile_info);
5472 pinfo = (struct i40e_profile_info *)(profile_info_sec +
5473 sec->section.offset);
5474 pinfo->track_id = track_id;
5475 pinfo->version = profile->version;
5476 pinfo->op = I40E_DDP_ADD_TRACKID;
5477 memcpy(pinfo->name, profile->name, I40E_DDP_NAME_SIZE);
5479 status = i40e_aq_write_ddp(hw, (void *)sec, sec->data_end,
5480 track_id, &offset, &info, NULL);
5486 * i40e_aq_add_cloud_filters
5487 * @hw: pointer to the hardware structure
5488 * @seid: VSI seid to add cloud filters from
5489 * @filters: Buffer which contains the filters to be added
5490 * @filter_count: number of filters contained in the buffer
5492 * Set the cloud filters for a given VSI. The contents of the
5493 * i40e_aqc_cloud_filters_element_data are filled in by the caller
5497 enum i40e_status_code
5498 i40e_aq_add_cloud_filters(struct i40e_hw *hw, u16 seid,
5499 struct i40e_aqc_cloud_filters_element_data *filters,
5502 struct i40e_aq_desc desc;
5503 struct i40e_aqc_add_remove_cloud_filters *cmd =
5504 (struct i40e_aqc_add_remove_cloud_filters *)&desc.params.raw;
5505 enum i40e_status_code status;
5508 i40e_fill_default_direct_cmd_desc(&desc,
5509 i40e_aqc_opc_add_cloud_filters);
5511 buff_len = filter_count * sizeof(*filters);
5512 desc.datalen = cpu_to_le16(buff_len);
5513 desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
5514 cmd->num_filters = filter_count;
5515 cmd->seid = cpu_to_le16(seid);
5517 status = i40e_asq_send_command(hw, &desc, filters, buff_len, NULL);
5523 * i40e_aq_add_cloud_filters_bb
5524 * @hw: pointer to the hardware structure
5525 * @seid: VSI seid to add cloud filters from
5526 * @filters: Buffer which contains the filters in big buffer to be added
5527 * @filter_count: number of filters contained in the buffer
5529 * Set the big buffer cloud filters for a given VSI. The contents of the
5530 * i40e_aqc_cloud_filters_element_bb are filled in by the caller of the
5535 i40e_aq_add_cloud_filters_bb(struct i40e_hw *hw, u16 seid,
5536 struct i40e_aqc_cloud_filters_element_bb *filters,
5539 struct i40e_aq_desc desc;
5540 struct i40e_aqc_add_remove_cloud_filters *cmd =
5541 (struct i40e_aqc_add_remove_cloud_filters *)&desc.params.raw;
5546 i40e_fill_default_direct_cmd_desc(&desc,
5547 i40e_aqc_opc_add_cloud_filters);
5549 buff_len = filter_count * sizeof(*filters);
5550 desc.datalen = cpu_to_le16(buff_len);
5551 desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
5552 cmd->num_filters = filter_count;
5553 cmd->seid = cpu_to_le16(seid);
5554 cmd->big_buffer_flag = I40E_AQC_ADD_CLOUD_CMD_BB;
5556 for (i = 0; i < filter_count; i++) {
5560 tnl_type = (le16_to_cpu(filters[i].element.flags) &
5561 I40E_AQC_ADD_CLOUD_TNL_TYPE_MASK) >>
5562 I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT;
5564 /* Due to hardware eccentricities, the VNI for Geneve is shifted
5565 * one more byte further than normally used for Tenant ID in
5566 * other tunnel types.
5568 if (tnl_type == I40E_AQC_ADD_CLOUD_TNL_TYPE_GENEVE) {
5569 ti = le32_to_cpu(filters[i].element.tenant_id);
5570 filters[i].element.tenant_id = cpu_to_le32(ti << 8);
5574 status = i40e_asq_send_command(hw, &desc, filters, buff_len, NULL);
5580 * i40e_aq_rem_cloud_filters
5581 * @hw: pointer to the hardware structure
5582 * @seid: VSI seid to remove cloud filters from
5583 * @filters: Buffer which contains the filters to be removed
5584 * @filter_count: number of filters contained in the buffer
5586 * Remove the cloud filters for a given VSI. The contents of the
5587 * i40e_aqc_cloud_filters_element_data are filled in by the caller
5591 enum i40e_status_code
5592 i40e_aq_rem_cloud_filters(struct i40e_hw *hw, u16 seid,
5593 struct i40e_aqc_cloud_filters_element_data *filters,
5596 struct i40e_aq_desc desc;
5597 struct i40e_aqc_add_remove_cloud_filters *cmd =
5598 (struct i40e_aqc_add_remove_cloud_filters *)&desc.params.raw;
5599 enum i40e_status_code status;
5602 i40e_fill_default_direct_cmd_desc(&desc,
5603 i40e_aqc_opc_remove_cloud_filters);
5605 buff_len = filter_count * sizeof(*filters);
5606 desc.datalen = cpu_to_le16(buff_len);
5607 desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
5608 cmd->num_filters = filter_count;
5609 cmd->seid = cpu_to_le16(seid);
5611 status = i40e_asq_send_command(hw, &desc, filters, buff_len, NULL);
5617 * i40e_aq_rem_cloud_filters_bb
5618 * @hw: pointer to the hardware structure
5619 * @seid: VSI seid to remove cloud filters from
5620 * @filters: Buffer which contains the filters in big buffer to be removed
5621 * @filter_count: number of filters contained in the buffer
5623 * Remove the big buffer cloud filters for a given VSI. The contents of the
5624 * i40e_aqc_cloud_filters_element_bb are filled in by the caller of the
5629 i40e_aq_rem_cloud_filters_bb(struct i40e_hw *hw, u16 seid,
5630 struct i40e_aqc_cloud_filters_element_bb *filters,
5633 struct i40e_aq_desc desc;
5634 struct i40e_aqc_add_remove_cloud_filters *cmd =
5635 (struct i40e_aqc_add_remove_cloud_filters *)&desc.params.raw;
5640 i40e_fill_default_direct_cmd_desc(&desc,
5641 i40e_aqc_opc_remove_cloud_filters);
5643 buff_len = filter_count * sizeof(*filters);
5644 desc.datalen = cpu_to_le16(buff_len);
5645 desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
5646 cmd->num_filters = filter_count;
5647 cmd->seid = cpu_to_le16(seid);
5648 cmd->big_buffer_flag = I40E_AQC_ADD_CLOUD_CMD_BB;
5650 for (i = 0; i < filter_count; i++) {
5654 tnl_type = (le16_to_cpu(filters[i].element.flags) &
5655 I40E_AQC_ADD_CLOUD_TNL_TYPE_MASK) >>
5656 I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT;
5658 /* Due to hardware eccentricities, the VNI for Geneve is shifted
5659 * one more byte further than normally used for Tenant ID in
5660 * other tunnel types.
5662 if (tnl_type == I40E_AQC_ADD_CLOUD_TNL_TYPE_GENEVE) {
5663 ti = le32_to_cpu(filters[i].element.tenant_id);
5664 filters[i].element.tenant_id = cpu_to_le32(ti << 8);
5668 status = i40e_asq_send_command(hw, &desc, filters, buff_len, NULL);