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 "i40e_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 hw
->mac
.type
= I40E_MAC_XL710
;
58 case I40E_DEV_ID_KX_X722
:
59 case I40E_DEV_ID_QSFP_X722
:
60 case I40E_DEV_ID_SFP_X722
:
61 case I40E_DEV_ID_1G_BASE_T_X722
:
62 case I40E_DEV_ID_10G_BASE_T_X722
:
63 case I40E_DEV_ID_SFP_I_X722
:
64 hw
->mac
.type
= I40E_MAC_X722
;
67 hw
->mac
.type
= I40E_MAC_GENERIC
;
71 status
= I40E_ERR_DEVICE_NOT_SUPPORTED
;
74 hw_dbg(hw
, "i40e_set_mac_type found mac: %d, returns: %d\n",
75 hw
->mac
.type
, status
);
80 * i40e_aq_str - convert AQ err code to a string
81 * @hw: pointer to the HW structure
82 * @aq_err: the AQ error code to convert
84 const char *i40e_aq_str(struct i40e_hw
*hw
, enum i40e_admin_queue_err aq_err
)
89 case I40E_AQ_RC_EPERM
:
90 return "I40E_AQ_RC_EPERM";
91 case I40E_AQ_RC_ENOENT
:
92 return "I40E_AQ_RC_ENOENT";
93 case I40E_AQ_RC_ESRCH
:
94 return "I40E_AQ_RC_ESRCH";
95 case I40E_AQ_RC_EINTR
:
96 return "I40E_AQ_RC_EINTR";
98 return "I40E_AQ_RC_EIO";
99 case I40E_AQ_RC_ENXIO
:
100 return "I40E_AQ_RC_ENXIO";
101 case I40E_AQ_RC_E2BIG
:
102 return "I40E_AQ_RC_E2BIG";
103 case I40E_AQ_RC_EAGAIN
:
104 return "I40E_AQ_RC_EAGAIN";
105 case I40E_AQ_RC_ENOMEM
:
106 return "I40E_AQ_RC_ENOMEM";
107 case I40E_AQ_RC_EACCES
:
108 return "I40E_AQ_RC_EACCES";
109 case I40E_AQ_RC_EFAULT
:
110 return "I40E_AQ_RC_EFAULT";
111 case I40E_AQ_RC_EBUSY
:
112 return "I40E_AQ_RC_EBUSY";
113 case I40E_AQ_RC_EEXIST
:
114 return "I40E_AQ_RC_EEXIST";
115 case I40E_AQ_RC_EINVAL
:
116 return "I40E_AQ_RC_EINVAL";
117 case I40E_AQ_RC_ENOTTY
:
118 return "I40E_AQ_RC_ENOTTY";
119 case I40E_AQ_RC_ENOSPC
:
120 return "I40E_AQ_RC_ENOSPC";
121 case I40E_AQ_RC_ENOSYS
:
122 return "I40E_AQ_RC_ENOSYS";
123 case I40E_AQ_RC_ERANGE
:
124 return "I40E_AQ_RC_ERANGE";
125 case I40E_AQ_RC_EFLUSHED
:
126 return "I40E_AQ_RC_EFLUSHED";
127 case I40E_AQ_RC_BAD_ADDR
:
128 return "I40E_AQ_RC_BAD_ADDR";
129 case I40E_AQ_RC_EMODE
:
130 return "I40E_AQ_RC_EMODE";
131 case I40E_AQ_RC_EFBIG
:
132 return "I40E_AQ_RC_EFBIG";
135 snprintf(hw
->err_str
, sizeof(hw
->err_str
), "%d", aq_err
);
140 * i40e_stat_str - convert status err code to a string
141 * @hw: pointer to the HW structure
142 * @stat_err: the status error code to convert
144 const char *i40e_stat_str(struct i40e_hw
*hw
, i40e_status stat_err
)
150 return "I40E_ERR_NVM";
151 case I40E_ERR_NVM_CHECKSUM
:
152 return "I40E_ERR_NVM_CHECKSUM";
154 return "I40E_ERR_PHY";
155 case I40E_ERR_CONFIG
:
156 return "I40E_ERR_CONFIG";
158 return "I40E_ERR_PARAM";
159 case I40E_ERR_MAC_TYPE
:
160 return "I40E_ERR_MAC_TYPE";
161 case I40E_ERR_UNKNOWN_PHY
:
162 return "I40E_ERR_UNKNOWN_PHY";
163 case I40E_ERR_LINK_SETUP
:
164 return "I40E_ERR_LINK_SETUP";
165 case I40E_ERR_ADAPTER_STOPPED
:
166 return "I40E_ERR_ADAPTER_STOPPED";
167 case I40E_ERR_INVALID_MAC_ADDR
:
168 return "I40E_ERR_INVALID_MAC_ADDR";
169 case I40E_ERR_DEVICE_NOT_SUPPORTED
:
170 return "I40E_ERR_DEVICE_NOT_SUPPORTED";
171 case I40E_ERR_MASTER_REQUESTS_PENDING
:
172 return "I40E_ERR_MASTER_REQUESTS_PENDING";
173 case I40E_ERR_INVALID_LINK_SETTINGS
:
174 return "I40E_ERR_INVALID_LINK_SETTINGS";
175 case I40E_ERR_AUTONEG_NOT_COMPLETE
:
176 return "I40E_ERR_AUTONEG_NOT_COMPLETE";
177 case I40E_ERR_RESET_FAILED
:
178 return "I40E_ERR_RESET_FAILED";
179 case I40E_ERR_SWFW_SYNC
:
180 return "I40E_ERR_SWFW_SYNC";
181 case I40E_ERR_NO_AVAILABLE_VSI
:
182 return "I40E_ERR_NO_AVAILABLE_VSI";
183 case I40E_ERR_NO_MEMORY
:
184 return "I40E_ERR_NO_MEMORY";
185 case I40E_ERR_BAD_PTR
:
186 return "I40E_ERR_BAD_PTR";
187 case I40E_ERR_RING_FULL
:
188 return "I40E_ERR_RING_FULL";
189 case I40E_ERR_INVALID_PD_ID
:
190 return "I40E_ERR_INVALID_PD_ID";
191 case I40E_ERR_INVALID_QP_ID
:
192 return "I40E_ERR_INVALID_QP_ID";
193 case I40E_ERR_INVALID_CQ_ID
:
194 return "I40E_ERR_INVALID_CQ_ID";
195 case I40E_ERR_INVALID_CEQ_ID
:
196 return "I40E_ERR_INVALID_CEQ_ID";
197 case I40E_ERR_INVALID_AEQ_ID
:
198 return "I40E_ERR_INVALID_AEQ_ID";
199 case I40E_ERR_INVALID_SIZE
:
200 return "I40E_ERR_INVALID_SIZE";
201 case I40E_ERR_INVALID_ARP_INDEX
:
202 return "I40E_ERR_INVALID_ARP_INDEX";
203 case I40E_ERR_INVALID_FPM_FUNC_ID
:
204 return "I40E_ERR_INVALID_FPM_FUNC_ID";
205 case I40E_ERR_QP_INVALID_MSG_SIZE
:
206 return "I40E_ERR_QP_INVALID_MSG_SIZE";
207 case I40E_ERR_QP_TOOMANY_WRS_POSTED
:
208 return "I40E_ERR_QP_TOOMANY_WRS_POSTED";
209 case I40E_ERR_INVALID_FRAG_COUNT
:
210 return "I40E_ERR_INVALID_FRAG_COUNT";
211 case I40E_ERR_QUEUE_EMPTY
:
212 return "I40E_ERR_QUEUE_EMPTY";
213 case I40E_ERR_INVALID_ALIGNMENT
:
214 return "I40E_ERR_INVALID_ALIGNMENT";
215 case I40E_ERR_FLUSHED_QUEUE
:
216 return "I40E_ERR_FLUSHED_QUEUE";
217 case I40E_ERR_INVALID_PUSH_PAGE_INDEX
:
218 return "I40E_ERR_INVALID_PUSH_PAGE_INDEX";
219 case I40E_ERR_INVALID_IMM_DATA_SIZE
:
220 return "I40E_ERR_INVALID_IMM_DATA_SIZE";
221 case I40E_ERR_TIMEOUT
:
222 return "I40E_ERR_TIMEOUT";
223 case I40E_ERR_OPCODE_MISMATCH
:
224 return "I40E_ERR_OPCODE_MISMATCH";
225 case I40E_ERR_CQP_COMPL_ERROR
:
226 return "I40E_ERR_CQP_COMPL_ERROR";
227 case I40E_ERR_INVALID_VF_ID
:
228 return "I40E_ERR_INVALID_VF_ID";
229 case I40E_ERR_INVALID_HMCFN_ID
:
230 return "I40E_ERR_INVALID_HMCFN_ID";
231 case I40E_ERR_BACKING_PAGE_ERROR
:
232 return "I40E_ERR_BACKING_PAGE_ERROR";
233 case I40E_ERR_NO_PBLCHUNKS_AVAILABLE
:
234 return "I40E_ERR_NO_PBLCHUNKS_AVAILABLE";
235 case I40E_ERR_INVALID_PBLE_INDEX
:
236 return "I40E_ERR_INVALID_PBLE_INDEX";
237 case I40E_ERR_INVALID_SD_INDEX
:
238 return "I40E_ERR_INVALID_SD_INDEX";
239 case I40E_ERR_INVALID_PAGE_DESC_INDEX
:
240 return "I40E_ERR_INVALID_PAGE_DESC_INDEX";
241 case I40E_ERR_INVALID_SD_TYPE
:
242 return "I40E_ERR_INVALID_SD_TYPE";
243 case I40E_ERR_MEMCPY_FAILED
:
244 return "I40E_ERR_MEMCPY_FAILED";
245 case I40E_ERR_INVALID_HMC_OBJ_INDEX
:
246 return "I40E_ERR_INVALID_HMC_OBJ_INDEX";
247 case I40E_ERR_INVALID_HMC_OBJ_COUNT
:
248 return "I40E_ERR_INVALID_HMC_OBJ_COUNT";
249 case I40E_ERR_INVALID_SRQ_ARM_LIMIT
:
250 return "I40E_ERR_INVALID_SRQ_ARM_LIMIT";
251 case I40E_ERR_SRQ_ENABLED
:
252 return "I40E_ERR_SRQ_ENABLED";
253 case I40E_ERR_ADMIN_QUEUE_ERROR
:
254 return "I40E_ERR_ADMIN_QUEUE_ERROR";
255 case I40E_ERR_ADMIN_QUEUE_TIMEOUT
:
256 return "I40E_ERR_ADMIN_QUEUE_TIMEOUT";
257 case I40E_ERR_BUF_TOO_SHORT
:
258 return "I40E_ERR_BUF_TOO_SHORT";
259 case I40E_ERR_ADMIN_QUEUE_FULL
:
260 return "I40E_ERR_ADMIN_QUEUE_FULL";
261 case I40E_ERR_ADMIN_QUEUE_NO_WORK
:
262 return "I40E_ERR_ADMIN_QUEUE_NO_WORK";
263 case I40E_ERR_BAD_IWARP_CQE
:
264 return "I40E_ERR_BAD_IWARP_CQE";
265 case I40E_ERR_NVM_BLANK_MODE
:
266 return "I40E_ERR_NVM_BLANK_MODE";
267 case I40E_ERR_NOT_IMPLEMENTED
:
268 return "I40E_ERR_NOT_IMPLEMENTED";
269 case I40E_ERR_PE_DOORBELL_NOT_ENABLED
:
270 return "I40E_ERR_PE_DOORBELL_NOT_ENABLED";
271 case I40E_ERR_DIAG_TEST_FAILED
:
272 return "I40E_ERR_DIAG_TEST_FAILED";
273 case I40E_ERR_NOT_READY
:
274 return "I40E_ERR_NOT_READY";
275 case I40E_NOT_SUPPORTED
:
276 return "I40E_NOT_SUPPORTED";
277 case I40E_ERR_FIRMWARE_API_VERSION
:
278 return "I40E_ERR_FIRMWARE_API_VERSION";
281 snprintf(hw
->err_str
, sizeof(hw
->err_str
), "%d", stat_err
);
287 * @hw: debug mask related to admin queue
289 * @desc: pointer to admin queue descriptor
290 * @buffer: pointer to command buffer
291 * @buf_len: max length of buffer
293 * Dumps debug log about adminq command with descriptor contents.
295 void i40e_debug_aq(struct i40e_hw
*hw
, enum i40e_debug_mask mask
, void *desc
,
296 void *buffer
, u16 buf_len
)
298 struct i40e_aq_desc
*aq_desc
= (struct i40e_aq_desc
*)desc
;
299 u16 len
= le16_to_cpu(aq_desc
->datalen
);
300 u8
*buf
= (u8
*)buffer
;
303 if ((!(mask
& hw
->debug_mask
)) || (desc
== NULL
))
307 "AQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n",
308 le16_to_cpu(aq_desc
->opcode
),
309 le16_to_cpu(aq_desc
->flags
),
310 le16_to_cpu(aq_desc
->datalen
),
311 le16_to_cpu(aq_desc
->retval
));
312 i40e_debug(hw
, mask
, "\tcookie (h,l) 0x%08X 0x%08X\n",
313 le32_to_cpu(aq_desc
->cookie_high
),
314 le32_to_cpu(aq_desc
->cookie_low
));
315 i40e_debug(hw
, mask
, "\tparam (0,1) 0x%08X 0x%08X\n",
316 le32_to_cpu(aq_desc
->params
.internal
.param0
),
317 le32_to_cpu(aq_desc
->params
.internal
.param1
));
318 i40e_debug(hw
, mask
, "\taddr (h,l) 0x%08X 0x%08X\n",
319 le32_to_cpu(aq_desc
->params
.external
.addr_high
),
320 le32_to_cpu(aq_desc
->params
.external
.addr_low
));
322 if ((buffer
!= NULL
) && (aq_desc
->datalen
!= 0)) {
323 i40e_debug(hw
, mask
, "AQ CMD Buffer:\n");
326 /* write the full 16-byte chunks */
327 for (i
= 0; i
< (len
- 16); i
+= 16)
328 i40e_debug(hw
, mask
, "\t0x%04X %16ph\n", i
, buf
+ i
);
329 /* write whatever's left over without overrunning the buffer */
331 i40e_debug(hw
, mask
, "\t0x%04X %*ph\n",
332 i
, len
- i
, buf
+ i
);
337 * i40e_check_asq_alive
338 * @hw: pointer to the hw struct
340 * Returns true if Queue is enabled else false.
342 bool i40e_check_asq_alive(struct i40e_hw
*hw
)
345 return !!(rd32(hw
, hw
->aq
.asq
.len
) &
346 I40E_PF_ATQLEN_ATQENABLE_MASK
);
352 * i40e_aq_queue_shutdown
353 * @hw: pointer to the hw struct
354 * @unloading: is the driver unloading itself
356 * Tell the Firmware that we're shutting down the AdminQ and whether
357 * or not the driver is unloading as well.
359 i40e_status
i40e_aq_queue_shutdown(struct i40e_hw
*hw
,
362 struct i40e_aq_desc desc
;
363 struct i40e_aqc_queue_shutdown
*cmd
=
364 (struct i40e_aqc_queue_shutdown
*)&desc
.params
.raw
;
367 i40e_fill_default_direct_cmd_desc(&desc
,
368 i40e_aqc_opc_queue_shutdown
);
371 cmd
->driver_unloading
= cpu_to_le32(I40E_AQ_DRIVER_UNLOADING
);
372 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, NULL
);
378 * i40e_aq_get_set_rss_lut
379 * @hw: pointer to the hardware structure
380 * @vsi_id: vsi fw index
381 * @pf_lut: for PF table set true, for VSI table set false
382 * @lut: pointer to the lut buffer provided by the caller
383 * @lut_size: size of the lut buffer
384 * @set: set true to set the table, false to get the table
386 * Internal function to get or set RSS look up table
388 static i40e_status
i40e_aq_get_set_rss_lut(struct i40e_hw
*hw
,
389 u16 vsi_id
, bool pf_lut
,
390 u8
*lut
, u16 lut_size
,
394 struct i40e_aq_desc desc
;
395 struct i40e_aqc_get_set_rss_lut
*cmd_resp
=
396 (struct i40e_aqc_get_set_rss_lut
*)&desc
.params
.raw
;
399 i40e_fill_default_direct_cmd_desc(&desc
,
400 i40e_aqc_opc_set_rss_lut
);
402 i40e_fill_default_direct_cmd_desc(&desc
,
403 i40e_aqc_opc_get_rss_lut
);
405 /* Indirect command */
406 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_BUF
);
407 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_RD
);
410 cpu_to_le16((u16
)((vsi_id
<<
411 I40E_AQC_SET_RSS_LUT_VSI_ID_SHIFT
) &
412 I40E_AQC_SET_RSS_LUT_VSI_ID_MASK
));
413 cmd_resp
->vsi_id
|= cpu_to_le16((u16
)I40E_AQC_SET_RSS_LUT_VSI_VALID
);
416 cmd_resp
->flags
|= cpu_to_le16((u16
)
417 ((I40E_AQC_SET_RSS_LUT_TABLE_TYPE_PF
<<
418 I40E_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT
) &
419 I40E_AQC_SET_RSS_LUT_TABLE_TYPE_MASK
));
421 cmd_resp
->flags
|= cpu_to_le16((u16
)
422 ((I40E_AQC_SET_RSS_LUT_TABLE_TYPE_VSI
<<
423 I40E_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT
) &
424 I40E_AQC_SET_RSS_LUT_TABLE_TYPE_MASK
));
426 status
= i40e_asq_send_command(hw
, &desc
, lut
, lut_size
, NULL
);
432 * i40e_aq_get_rss_lut
433 * @hw: pointer to the hardware structure
434 * @vsi_id: vsi fw index
435 * @pf_lut: for PF table set true, for VSI table set false
436 * @lut: pointer to the lut buffer provided by the caller
437 * @lut_size: size of the lut buffer
439 * get the RSS lookup table, PF or VSI type
441 i40e_status
i40e_aq_get_rss_lut(struct i40e_hw
*hw
, u16 vsi_id
,
442 bool pf_lut
, u8
*lut
, u16 lut_size
)
444 return i40e_aq_get_set_rss_lut(hw
, vsi_id
, pf_lut
, lut
, lut_size
,
449 * i40e_aq_set_rss_lut
450 * @hw: pointer to the hardware structure
451 * @vsi_id: vsi fw index
452 * @pf_lut: for PF table set true, for VSI table set false
453 * @lut: pointer to the lut buffer provided by the caller
454 * @lut_size: size of the lut buffer
456 * set the RSS lookup table, PF or VSI type
458 i40e_status
i40e_aq_set_rss_lut(struct i40e_hw
*hw
, u16 vsi_id
,
459 bool pf_lut
, u8
*lut
, u16 lut_size
)
461 return i40e_aq_get_set_rss_lut(hw
, vsi_id
, pf_lut
, lut
, lut_size
, true);
465 * i40e_aq_get_set_rss_key
466 * @hw: pointer to the hw struct
467 * @vsi_id: vsi fw index
468 * @key: pointer to key info struct
469 * @set: set true to set the key, false to get the key
471 * get the RSS key per VSI
473 static i40e_status
i40e_aq_get_set_rss_key(struct i40e_hw
*hw
,
475 struct i40e_aqc_get_set_rss_key_data
*key
,
479 struct i40e_aq_desc desc
;
480 struct i40e_aqc_get_set_rss_key
*cmd_resp
=
481 (struct i40e_aqc_get_set_rss_key
*)&desc
.params
.raw
;
482 u16 key_size
= sizeof(struct i40e_aqc_get_set_rss_key_data
);
485 i40e_fill_default_direct_cmd_desc(&desc
,
486 i40e_aqc_opc_set_rss_key
);
488 i40e_fill_default_direct_cmd_desc(&desc
,
489 i40e_aqc_opc_get_rss_key
);
491 /* Indirect command */
492 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_BUF
);
493 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_RD
);
496 cpu_to_le16((u16
)((vsi_id
<<
497 I40E_AQC_SET_RSS_KEY_VSI_ID_SHIFT
) &
498 I40E_AQC_SET_RSS_KEY_VSI_ID_MASK
));
499 cmd_resp
->vsi_id
|= cpu_to_le16((u16
)I40E_AQC_SET_RSS_KEY_VSI_VALID
);
501 status
= i40e_asq_send_command(hw
, &desc
, key
, key_size
, NULL
);
507 * i40e_aq_get_rss_key
508 * @hw: pointer to the hw struct
509 * @vsi_id: vsi fw index
510 * @key: pointer to key info struct
513 i40e_status
i40e_aq_get_rss_key(struct i40e_hw
*hw
,
515 struct i40e_aqc_get_set_rss_key_data
*key
)
517 return i40e_aq_get_set_rss_key(hw
, vsi_id
, key
, false);
521 * i40e_aq_set_rss_key
522 * @hw: pointer to the hw struct
523 * @vsi_id: vsi fw index
524 * @key: pointer to key info struct
526 * set the RSS key per VSI
528 i40e_status
i40e_aq_set_rss_key(struct i40e_hw
*hw
,
530 struct i40e_aqc_get_set_rss_key_data
*key
)
532 return i40e_aq_get_set_rss_key(hw
, vsi_id
, key
, true);
535 /* The i40e_ptype_lookup table is used to convert from the 8-bit ptype in the
536 * hardware to a bit-field that can be used by SW to more easily determine the
539 * Macros are used to shorten the table lines and make this table human
542 * We store the PTYPE in the top byte of the bit field - this is just so that
543 * we can check that the table doesn't have a row missing, as the index into
544 * the table should be the PTYPE.
548 * IF NOT i40e_ptype_lookup[ptype].known
551 * ELSE IF i40e_ptype_lookup[ptype].outer_ip == I40E_RX_PTYPE_OUTER_IP
552 * Use the rest of the fields to look at the tunnels, inner protocols, etc
554 * Use the enum i40e_rx_l2_ptype to decode the packet type
558 /* macro to make the table lines short */
559 #define I40E_PTT(PTYPE, OUTER_IP, OUTER_IP_VER, OUTER_FRAG, T, TE, TEF, I, PL)\
562 I40E_RX_PTYPE_OUTER_##OUTER_IP, \
563 I40E_RX_PTYPE_OUTER_##OUTER_IP_VER, \
564 I40E_RX_PTYPE_##OUTER_FRAG, \
565 I40E_RX_PTYPE_TUNNEL_##T, \
566 I40E_RX_PTYPE_TUNNEL_END_##TE, \
567 I40E_RX_PTYPE_##TEF, \
568 I40E_RX_PTYPE_INNER_PROT_##I, \
569 I40E_RX_PTYPE_PAYLOAD_LAYER_##PL }
571 #define I40E_PTT_UNUSED_ENTRY(PTYPE) \
572 { PTYPE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
574 /* shorter macros makes the table fit but are terse */
575 #define I40E_RX_PTYPE_NOF I40E_RX_PTYPE_NOT_FRAG
576 #define I40E_RX_PTYPE_FRG I40E_RX_PTYPE_FRAG
577 #define I40E_RX_PTYPE_INNER_PROT_TS I40E_RX_PTYPE_INNER_PROT_TIMESYNC
579 /* Lookup table mapping the HW PTYPE to the bit field for decoding */
580 struct i40e_rx_ptype_decoded i40e_ptype_lookup
[] = {
581 /* L2 Packet types */
582 I40E_PTT_UNUSED_ENTRY(0),
583 I40E_PTT(1, L2
, NONE
, NOF
, NONE
, NONE
, NOF
, NONE
, PAY2
),
584 I40E_PTT(2, L2
, NONE
, NOF
, NONE
, NONE
, NOF
, TS
, PAY2
),
585 I40E_PTT(3, L2
, NONE
, NOF
, NONE
, NONE
, NOF
, NONE
, PAY2
),
586 I40E_PTT_UNUSED_ENTRY(4),
587 I40E_PTT_UNUSED_ENTRY(5),
588 I40E_PTT(6, L2
, NONE
, NOF
, NONE
, NONE
, NOF
, NONE
, PAY2
),
589 I40E_PTT(7, L2
, NONE
, NOF
, NONE
, NONE
, NOF
, NONE
, PAY2
),
590 I40E_PTT_UNUSED_ENTRY(8),
591 I40E_PTT_UNUSED_ENTRY(9),
592 I40E_PTT(10, L2
, NONE
, NOF
, NONE
, NONE
, NOF
, NONE
, PAY2
),
593 I40E_PTT(11, L2
, NONE
, NOF
, NONE
, NONE
, NOF
, NONE
, NONE
),
594 I40E_PTT(12, L2
, NONE
, NOF
, NONE
, NONE
, NOF
, NONE
, PAY3
),
595 I40E_PTT(13, L2
, NONE
, NOF
, NONE
, NONE
, NOF
, NONE
, PAY3
),
596 I40E_PTT(14, L2
, NONE
, NOF
, NONE
, NONE
, NOF
, NONE
, PAY3
),
597 I40E_PTT(15, L2
, NONE
, NOF
, NONE
, NONE
, NOF
, NONE
, PAY3
),
598 I40E_PTT(16, L2
, NONE
, NOF
, NONE
, NONE
, NOF
, NONE
, PAY3
),
599 I40E_PTT(17, L2
, NONE
, NOF
, NONE
, NONE
, NOF
, NONE
, PAY3
),
600 I40E_PTT(18, L2
, NONE
, NOF
, NONE
, NONE
, NOF
, NONE
, PAY3
),
601 I40E_PTT(19, L2
, NONE
, NOF
, NONE
, NONE
, NOF
, NONE
, PAY3
),
602 I40E_PTT(20, L2
, NONE
, NOF
, NONE
, NONE
, NOF
, NONE
, PAY3
),
603 I40E_PTT(21, L2
, NONE
, NOF
, NONE
, NONE
, NOF
, NONE
, PAY3
),
605 /* Non Tunneled IPv4 */
606 I40E_PTT(22, IP
, IPV4
, FRG
, NONE
, NONE
, NOF
, NONE
, PAY3
),
607 I40E_PTT(23, IP
, IPV4
, NOF
, NONE
, NONE
, NOF
, NONE
, PAY3
),
608 I40E_PTT(24, IP
, IPV4
, NOF
, NONE
, NONE
, NOF
, UDP
, PAY4
),
609 I40E_PTT_UNUSED_ENTRY(25),
610 I40E_PTT(26, IP
, IPV4
, NOF
, NONE
, NONE
, NOF
, TCP
, PAY4
),
611 I40E_PTT(27, IP
, IPV4
, NOF
, NONE
, NONE
, NOF
, SCTP
, PAY4
),
612 I40E_PTT(28, IP
, IPV4
, NOF
, NONE
, NONE
, NOF
, ICMP
, PAY4
),
615 I40E_PTT(29, IP
, IPV4
, NOF
, IP_IP
, IPV4
, FRG
, NONE
, PAY3
),
616 I40E_PTT(30, IP
, IPV4
, NOF
, IP_IP
, IPV4
, NOF
, NONE
, PAY3
),
617 I40E_PTT(31, IP
, IPV4
, NOF
, IP_IP
, IPV4
, NOF
, UDP
, PAY4
),
618 I40E_PTT_UNUSED_ENTRY(32),
619 I40E_PTT(33, IP
, IPV4
, NOF
, IP_IP
, IPV4
, NOF
, TCP
, PAY4
),
620 I40E_PTT(34, IP
, IPV4
, NOF
, IP_IP
, IPV4
, NOF
, SCTP
, PAY4
),
621 I40E_PTT(35, IP
, IPV4
, NOF
, IP_IP
, IPV4
, NOF
, ICMP
, PAY4
),
624 I40E_PTT(36, IP
, IPV4
, NOF
, IP_IP
, IPV6
, FRG
, NONE
, PAY3
),
625 I40E_PTT(37, IP
, IPV4
, NOF
, IP_IP
, IPV6
, NOF
, NONE
, PAY3
),
626 I40E_PTT(38, IP
, IPV4
, NOF
, IP_IP
, IPV6
, NOF
, UDP
, PAY4
),
627 I40E_PTT_UNUSED_ENTRY(39),
628 I40E_PTT(40, IP
, IPV4
, NOF
, IP_IP
, IPV6
, NOF
, TCP
, PAY4
),
629 I40E_PTT(41, IP
, IPV4
, NOF
, IP_IP
, IPV6
, NOF
, SCTP
, PAY4
),
630 I40E_PTT(42, IP
, IPV4
, NOF
, IP_IP
, IPV6
, NOF
, ICMP
, PAY4
),
632 /* IPv4 --> GRE/NAT */
633 I40E_PTT(43, IP
, IPV4
, NOF
, IP_GRENAT
, NONE
, NOF
, NONE
, PAY3
),
635 /* IPv4 --> GRE/NAT --> IPv4 */
636 I40E_PTT(44, IP
, IPV4
, NOF
, IP_GRENAT
, IPV4
, FRG
, NONE
, PAY3
),
637 I40E_PTT(45, IP
, IPV4
, NOF
, IP_GRENAT
, IPV4
, NOF
, NONE
, PAY3
),
638 I40E_PTT(46, IP
, IPV4
, NOF
, IP_GRENAT
, IPV4
, NOF
, UDP
, PAY4
),
639 I40E_PTT_UNUSED_ENTRY(47),
640 I40E_PTT(48, IP
, IPV4
, NOF
, IP_GRENAT
, IPV4
, NOF
, TCP
, PAY4
),
641 I40E_PTT(49, IP
, IPV4
, NOF
, IP_GRENAT
, IPV4
, NOF
, SCTP
, PAY4
),
642 I40E_PTT(50, IP
, IPV4
, NOF
, IP_GRENAT
, IPV4
, NOF
, ICMP
, PAY4
),
644 /* IPv4 --> GRE/NAT --> IPv6 */
645 I40E_PTT(51, IP
, IPV4
, NOF
, IP_GRENAT
, IPV6
, FRG
, NONE
, PAY3
),
646 I40E_PTT(52, IP
, IPV4
, NOF
, IP_GRENAT
, IPV6
, NOF
, NONE
, PAY3
),
647 I40E_PTT(53, IP
, IPV4
, NOF
, IP_GRENAT
, IPV6
, NOF
, UDP
, PAY4
),
648 I40E_PTT_UNUSED_ENTRY(54),
649 I40E_PTT(55, IP
, IPV4
, NOF
, IP_GRENAT
, IPV6
, NOF
, TCP
, PAY4
),
650 I40E_PTT(56, IP
, IPV4
, NOF
, IP_GRENAT
, IPV6
, NOF
, SCTP
, PAY4
),
651 I40E_PTT(57, IP
, IPV4
, NOF
, IP_GRENAT
, IPV6
, NOF
, ICMP
, PAY4
),
653 /* IPv4 --> GRE/NAT --> MAC */
654 I40E_PTT(58, IP
, IPV4
, NOF
, IP_GRENAT_MAC
, NONE
, NOF
, NONE
, PAY3
),
656 /* IPv4 --> GRE/NAT --> MAC --> IPv4 */
657 I40E_PTT(59, IP
, IPV4
, NOF
, IP_GRENAT_MAC
, IPV4
, FRG
, NONE
, PAY3
),
658 I40E_PTT(60, IP
, IPV4
, NOF
, IP_GRENAT_MAC
, IPV4
, NOF
, NONE
, PAY3
),
659 I40E_PTT(61, IP
, IPV4
, NOF
, IP_GRENAT_MAC
, IPV4
, NOF
, UDP
, PAY4
),
660 I40E_PTT_UNUSED_ENTRY(62),
661 I40E_PTT(63, IP
, IPV4
, NOF
, IP_GRENAT_MAC
, IPV4
, NOF
, TCP
, PAY4
),
662 I40E_PTT(64, IP
, IPV4
, NOF
, IP_GRENAT_MAC
, IPV4
, NOF
, SCTP
, PAY4
),
663 I40E_PTT(65, IP
, IPV4
, NOF
, IP_GRENAT_MAC
, IPV4
, NOF
, ICMP
, PAY4
),
665 /* IPv4 --> GRE/NAT -> MAC --> IPv6 */
666 I40E_PTT(66, IP
, IPV4
, NOF
, IP_GRENAT_MAC
, IPV6
, FRG
, NONE
, PAY3
),
667 I40E_PTT(67, IP
, IPV4
, NOF
, IP_GRENAT_MAC
, IPV6
, NOF
, NONE
, PAY3
),
668 I40E_PTT(68, IP
, IPV4
, NOF
, IP_GRENAT_MAC
, IPV6
, NOF
, UDP
, PAY4
),
669 I40E_PTT_UNUSED_ENTRY(69),
670 I40E_PTT(70, IP
, IPV4
, NOF
, IP_GRENAT_MAC
, IPV6
, NOF
, TCP
, PAY4
),
671 I40E_PTT(71, IP
, IPV4
, NOF
, IP_GRENAT_MAC
, IPV6
, NOF
, SCTP
, PAY4
),
672 I40E_PTT(72, IP
, IPV4
, NOF
, IP_GRENAT_MAC
, IPV6
, NOF
, ICMP
, PAY4
),
674 /* IPv4 --> GRE/NAT --> MAC/VLAN */
675 I40E_PTT(73, IP
, IPV4
, NOF
, IP_GRENAT_MAC_VLAN
, NONE
, NOF
, NONE
, PAY3
),
677 /* IPv4 ---> GRE/NAT -> MAC/VLAN --> IPv4 */
678 I40E_PTT(74, IP
, IPV4
, NOF
, IP_GRENAT_MAC_VLAN
, IPV4
, FRG
, NONE
, PAY3
),
679 I40E_PTT(75, IP
, IPV4
, NOF
, IP_GRENAT_MAC_VLAN
, IPV4
, NOF
, NONE
, PAY3
),
680 I40E_PTT(76, IP
, IPV4
, NOF
, IP_GRENAT_MAC_VLAN
, IPV4
, NOF
, UDP
, PAY4
),
681 I40E_PTT_UNUSED_ENTRY(77),
682 I40E_PTT(78, IP
, IPV4
, NOF
, IP_GRENAT_MAC_VLAN
, IPV4
, NOF
, TCP
, PAY4
),
683 I40E_PTT(79, IP
, IPV4
, NOF
, IP_GRENAT_MAC_VLAN
, IPV4
, NOF
, SCTP
, PAY4
),
684 I40E_PTT(80, IP
, IPV4
, NOF
, IP_GRENAT_MAC_VLAN
, IPV4
, NOF
, ICMP
, PAY4
),
686 /* IPv4 -> GRE/NAT -> MAC/VLAN --> IPv6 */
687 I40E_PTT(81, IP
, IPV4
, NOF
, IP_GRENAT_MAC_VLAN
, IPV6
, FRG
, NONE
, PAY3
),
688 I40E_PTT(82, IP
, IPV4
, NOF
, IP_GRENAT_MAC_VLAN
, IPV6
, NOF
, NONE
, PAY3
),
689 I40E_PTT(83, IP
, IPV4
, NOF
, IP_GRENAT_MAC_VLAN
, IPV6
, NOF
, UDP
, PAY4
),
690 I40E_PTT_UNUSED_ENTRY(84),
691 I40E_PTT(85, IP
, IPV4
, NOF
, IP_GRENAT_MAC_VLAN
, IPV6
, NOF
, TCP
, PAY4
),
692 I40E_PTT(86, IP
, IPV4
, NOF
, IP_GRENAT_MAC_VLAN
, IPV6
, NOF
, SCTP
, PAY4
),
693 I40E_PTT(87, IP
, IPV4
, NOF
, IP_GRENAT_MAC_VLAN
, IPV6
, NOF
, ICMP
, PAY4
),
695 /* Non Tunneled IPv6 */
696 I40E_PTT(88, IP
, IPV6
, FRG
, NONE
, NONE
, NOF
, NONE
, PAY3
),
697 I40E_PTT(89, IP
, IPV6
, NOF
, NONE
, NONE
, NOF
, NONE
, PAY3
),
698 I40E_PTT(90, IP
, IPV6
, NOF
, NONE
, NONE
, NOF
, UDP
, PAY3
),
699 I40E_PTT_UNUSED_ENTRY(91),
700 I40E_PTT(92, IP
, IPV6
, NOF
, NONE
, NONE
, NOF
, TCP
, PAY4
),
701 I40E_PTT(93, IP
, IPV6
, NOF
, NONE
, NONE
, NOF
, SCTP
, PAY4
),
702 I40E_PTT(94, IP
, IPV6
, NOF
, NONE
, NONE
, NOF
, ICMP
, PAY4
),
705 I40E_PTT(95, IP
, IPV6
, NOF
, IP_IP
, IPV4
, FRG
, NONE
, PAY3
),
706 I40E_PTT(96, IP
, IPV6
, NOF
, IP_IP
, IPV4
, NOF
, NONE
, PAY3
),
707 I40E_PTT(97, IP
, IPV6
, NOF
, IP_IP
, IPV4
, NOF
, UDP
, PAY4
),
708 I40E_PTT_UNUSED_ENTRY(98),
709 I40E_PTT(99, IP
, IPV6
, NOF
, IP_IP
, IPV4
, NOF
, TCP
, PAY4
),
710 I40E_PTT(100, IP
, IPV6
, NOF
, IP_IP
, IPV4
, NOF
, SCTP
, PAY4
),
711 I40E_PTT(101, IP
, IPV6
, NOF
, IP_IP
, IPV4
, NOF
, ICMP
, PAY4
),
714 I40E_PTT(102, IP
, IPV6
, NOF
, IP_IP
, IPV6
, FRG
, NONE
, PAY3
),
715 I40E_PTT(103, IP
, IPV6
, NOF
, IP_IP
, IPV6
, NOF
, NONE
, PAY3
),
716 I40E_PTT(104, IP
, IPV6
, NOF
, IP_IP
, IPV6
, NOF
, UDP
, PAY4
),
717 I40E_PTT_UNUSED_ENTRY(105),
718 I40E_PTT(106, IP
, IPV6
, NOF
, IP_IP
, IPV6
, NOF
, TCP
, PAY4
),
719 I40E_PTT(107, IP
, IPV6
, NOF
, IP_IP
, IPV6
, NOF
, SCTP
, PAY4
),
720 I40E_PTT(108, IP
, IPV6
, NOF
, IP_IP
, IPV6
, NOF
, ICMP
, PAY4
),
722 /* IPv6 --> GRE/NAT */
723 I40E_PTT(109, IP
, IPV6
, NOF
, IP_GRENAT
, NONE
, NOF
, NONE
, PAY3
),
725 /* IPv6 --> GRE/NAT -> IPv4 */
726 I40E_PTT(110, IP
, IPV6
, NOF
, IP_GRENAT
, IPV4
, FRG
, NONE
, PAY3
),
727 I40E_PTT(111, IP
, IPV6
, NOF
, IP_GRENAT
, IPV4
, NOF
, NONE
, PAY3
),
728 I40E_PTT(112, IP
, IPV6
, NOF
, IP_GRENAT
, IPV4
, NOF
, UDP
, PAY4
),
729 I40E_PTT_UNUSED_ENTRY(113),
730 I40E_PTT(114, IP
, IPV6
, NOF
, IP_GRENAT
, IPV4
, NOF
, TCP
, PAY4
),
731 I40E_PTT(115, IP
, IPV6
, NOF
, IP_GRENAT
, IPV4
, NOF
, SCTP
, PAY4
),
732 I40E_PTT(116, IP
, IPV6
, NOF
, IP_GRENAT
, IPV4
, NOF
, ICMP
, PAY4
),
734 /* IPv6 --> GRE/NAT -> IPv6 */
735 I40E_PTT(117, IP
, IPV6
, NOF
, IP_GRENAT
, IPV6
, FRG
, NONE
, PAY3
),
736 I40E_PTT(118, IP
, IPV6
, NOF
, IP_GRENAT
, IPV6
, NOF
, NONE
, PAY3
),
737 I40E_PTT(119, IP
, IPV6
, NOF
, IP_GRENAT
, IPV6
, NOF
, UDP
, PAY4
),
738 I40E_PTT_UNUSED_ENTRY(120),
739 I40E_PTT(121, IP
, IPV6
, NOF
, IP_GRENAT
, IPV6
, NOF
, TCP
, PAY4
),
740 I40E_PTT(122, IP
, IPV6
, NOF
, IP_GRENAT
, IPV6
, NOF
, SCTP
, PAY4
),
741 I40E_PTT(123, IP
, IPV6
, NOF
, IP_GRENAT
, IPV6
, NOF
, ICMP
, PAY4
),
743 /* IPv6 --> GRE/NAT -> MAC */
744 I40E_PTT(124, IP
, IPV6
, NOF
, IP_GRENAT_MAC
, NONE
, NOF
, NONE
, PAY3
),
746 /* IPv6 --> GRE/NAT -> MAC -> IPv4 */
747 I40E_PTT(125, IP
, IPV6
, NOF
, IP_GRENAT_MAC
, IPV4
, FRG
, NONE
, PAY3
),
748 I40E_PTT(126, IP
, IPV6
, NOF
, IP_GRENAT_MAC
, IPV4
, NOF
, NONE
, PAY3
),
749 I40E_PTT(127, IP
, IPV6
, NOF
, IP_GRENAT_MAC
, IPV4
, NOF
, UDP
, PAY4
),
750 I40E_PTT_UNUSED_ENTRY(128),
751 I40E_PTT(129, IP
, IPV6
, NOF
, IP_GRENAT_MAC
, IPV4
, NOF
, TCP
, PAY4
),
752 I40E_PTT(130, IP
, IPV6
, NOF
, IP_GRENAT_MAC
, IPV4
, NOF
, SCTP
, PAY4
),
753 I40E_PTT(131, IP
, IPV6
, NOF
, IP_GRENAT_MAC
, IPV4
, NOF
, ICMP
, PAY4
),
755 /* IPv6 --> GRE/NAT -> MAC -> IPv6 */
756 I40E_PTT(132, IP
, IPV6
, NOF
, IP_GRENAT_MAC
, IPV6
, FRG
, NONE
, PAY3
),
757 I40E_PTT(133, IP
, IPV6
, NOF
, IP_GRENAT_MAC
, IPV6
, NOF
, NONE
, PAY3
),
758 I40E_PTT(134, IP
, IPV6
, NOF
, IP_GRENAT_MAC
, IPV6
, NOF
, UDP
, PAY4
),
759 I40E_PTT_UNUSED_ENTRY(135),
760 I40E_PTT(136, IP
, IPV6
, NOF
, IP_GRENAT_MAC
, IPV6
, NOF
, TCP
, PAY4
),
761 I40E_PTT(137, IP
, IPV6
, NOF
, IP_GRENAT_MAC
, IPV6
, NOF
, SCTP
, PAY4
),
762 I40E_PTT(138, IP
, IPV6
, NOF
, IP_GRENAT_MAC
, IPV6
, NOF
, ICMP
, PAY4
),
764 /* IPv6 --> GRE/NAT -> MAC/VLAN */
765 I40E_PTT(139, IP
, IPV6
, NOF
, IP_GRENAT_MAC_VLAN
, NONE
, NOF
, NONE
, PAY3
),
767 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv4 */
768 I40E_PTT(140, IP
, IPV6
, NOF
, IP_GRENAT_MAC_VLAN
, IPV4
, FRG
, NONE
, PAY3
),
769 I40E_PTT(141, IP
, IPV6
, NOF
, IP_GRENAT_MAC_VLAN
, IPV4
, NOF
, NONE
, PAY3
),
770 I40E_PTT(142, IP
, IPV6
, NOF
, IP_GRENAT_MAC_VLAN
, IPV4
, NOF
, UDP
, PAY4
),
771 I40E_PTT_UNUSED_ENTRY(143),
772 I40E_PTT(144, IP
, IPV6
, NOF
, IP_GRENAT_MAC_VLAN
, IPV4
, NOF
, TCP
, PAY4
),
773 I40E_PTT(145, IP
, IPV6
, NOF
, IP_GRENAT_MAC_VLAN
, IPV4
, NOF
, SCTP
, PAY4
),
774 I40E_PTT(146, IP
, IPV6
, NOF
, IP_GRENAT_MAC_VLAN
, IPV4
, NOF
, ICMP
, PAY4
),
776 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv6 */
777 I40E_PTT(147, IP
, IPV6
, NOF
, IP_GRENAT_MAC_VLAN
, IPV6
, FRG
, NONE
, PAY3
),
778 I40E_PTT(148, IP
, IPV6
, NOF
, IP_GRENAT_MAC_VLAN
, IPV6
, NOF
, NONE
, PAY3
),
779 I40E_PTT(149, IP
, IPV6
, NOF
, IP_GRENAT_MAC_VLAN
, IPV6
, NOF
, UDP
, PAY4
),
780 I40E_PTT_UNUSED_ENTRY(150),
781 I40E_PTT(151, IP
, IPV6
, NOF
, IP_GRENAT_MAC_VLAN
, IPV6
, NOF
, TCP
, PAY4
),
782 I40E_PTT(152, IP
, IPV6
, NOF
, IP_GRENAT_MAC_VLAN
, IPV6
, NOF
, SCTP
, PAY4
),
783 I40E_PTT(153, IP
, IPV6
, NOF
, IP_GRENAT_MAC_VLAN
, IPV6
, NOF
, ICMP
, PAY4
),
786 I40E_PTT_UNUSED_ENTRY(154),
787 I40E_PTT_UNUSED_ENTRY(155),
788 I40E_PTT_UNUSED_ENTRY(156),
789 I40E_PTT_UNUSED_ENTRY(157),
790 I40E_PTT_UNUSED_ENTRY(158),
791 I40E_PTT_UNUSED_ENTRY(159),
793 I40E_PTT_UNUSED_ENTRY(160),
794 I40E_PTT_UNUSED_ENTRY(161),
795 I40E_PTT_UNUSED_ENTRY(162),
796 I40E_PTT_UNUSED_ENTRY(163),
797 I40E_PTT_UNUSED_ENTRY(164),
798 I40E_PTT_UNUSED_ENTRY(165),
799 I40E_PTT_UNUSED_ENTRY(166),
800 I40E_PTT_UNUSED_ENTRY(167),
801 I40E_PTT_UNUSED_ENTRY(168),
802 I40E_PTT_UNUSED_ENTRY(169),
804 I40E_PTT_UNUSED_ENTRY(170),
805 I40E_PTT_UNUSED_ENTRY(171),
806 I40E_PTT_UNUSED_ENTRY(172),
807 I40E_PTT_UNUSED_ENTRY(173),
808 I40E_PTT_UNUSED_ENTRY(174),
809 I40E_PTT_UNUSED_ENTRY(175),
810 I40E_PTT_UNUSED_ENTRY(176),
811 I40E_PTT_UNUSED_ENTRY(177),
812 I40E_PTT_UNUSED_ENTRY(178),
813 I40E_PTT_UNUSED_ENTRY(179),
815 I40E_PTT_UNUSED_ENTRY(180),
816 I40E_PTT_UNUSED_ENTRY(181),
817 I40E_PTT_UNUSED_ENTRY(182),
818 I40E_PTT_UNUSED_ENTRY(183),
819 I40E_PTT_UNUSED_ENTRY(184),
820 I40E_PTT_UNUSED_ENTRY(185),
821 I40E_PTT_UNUSED_ENTRY(186),
822 I40E_PTT_UNUSED_ENTRY(187),
823 I40E_PTT_UNUSED_ENTRY(188),
824 I40E_PTT_UNUSED_ENTRY(189),
826 I40E_PTT_UNUSED_ENTRY(190),
827 I40E_PTT_UNUSED_ENTRY(191),
828 I40E_PTT_UNUSED_ENTRY(192),
829 I40E_PTT_UNUSED_ENTRY(193),
830 I40E_PTT_UNUSED_ENTRY(194),
831 I40E_PTT_UNUSED_ENTRY(195),
832 I40E_PTT_UNUSED_ENTRY(196),
833 I40E_PTT_UNUSED_ENTRY(197),
834 I40E_PTT_UNUSED_ENTRY(198),
835 I40E_PTT_UNUSED_ENTRY(199),
837 I40E_PTT_UNUSED_ENTRY(200),
838 I40E_PTT_UNUSED_ENTRY(201),
839 I40E_PTT_UNUSED_ENTRY(202),
840 I40E_PTT_UNUSED_ENTRY(203),
841 I40E_PTT_UNUSED_ENTRY(204),
842 I40E_PTT_UNUSED_ENTRY(205),
843 I40E_PTT_UNUSED_ENTRY(206),
844 I40E_PTT_UNUSED_ENTRY(207),
845 I40E_PTT_UNUSED_ENTRY(208),
846 I40E_PTT_UNUSED_ENTRY(209),
848 I40E_PTT_UNUSED_ENTRY(210),
849 I40E_PTT_UNUSED_ENTRY(211),
850 I40E_PTT_UNUSED_ENTRY(212),
851 I40E_PTT_UNUSED_ENTRY(213),
852 I40E_PTT_UNUSED_ENTRY(214),
853 I40E_PTT_UNUSED_ENTRY(215),
854 I40E_PTT_UNUSED_ENTRY(216),
855 I40E_PTT_UNUSED_ENTRY(217),
856 I40E_PTT_UNUSED_ENTRY(218),
857 I40E_PTT_UNUSED_ENTRY(219),
859 I40E_PTT_UNUSED_ENTRY(220),
860 I40E_PTT_UNUSED_ENTRY(221),
861 I40E_PTT_UNUSED_ENTRY(222),
862 I40E_PTT_UNUSED_ENTRY(223),
863 I40E_PTT_UNUSED_ENTRY(224),
864 I40E_PTT_UNUSED_ENTRY(225),
865 I40E_PTT_UNUSED_ENTRY(226),
866 I40E_PTT_UNUSED_ENTRY(227),
867 I40E_PTT_UNUSED_ENTRY(228),
868 I40E_PTT_UNUSED_ENTRY(229),
870 I40E_PTT_UNUSED_ENTRY(230),
871 I40E_PTT_UNUSED_ENTRY(231),
872 I40E_PTT_UNUSED_ENTRY(232),
873 I40E_PTT_UNUSED_ENTRY(233),
874 I40E_PTT_UNUSED_ENTRY(234),
875 I40E_PTT_UNUSED_ENTRY(235),
876 I40E_PTT_UNUSED_ENTRY(236),
877 I40E_PTT_UNUSED_ENTRY(237),
878 I40E_PTT_UNUSED_ENTRY(238),
879 I40E_PTT_UNUSED_ENTRY(239),
881 I40E_PTT_UNUSED_ENTRY(240),
882 I40E_PTT_UNUSED_ENTRY(241),
883 I40E_PTT_UNUSED_ENTRY(242),
884 I40E_PTT_UNUSED_ENTRY(243),
885 I40E_PTT_UNUSED_ENTRY(244),
886 I40E_PTT_UNUSED_ENTRY(245),
887 I40E_PTT_UNUSED_ENTRY(246),
888 I40E_PTT_UNUSED_ENTRY(247),
889 I40E_PTT_UNUSED_ENTRY(248),
890 I40E_PTT_UNUSED_ENTRY(249),
892 I40E_PTT_UNUSED_ENTRY(250),
893 I40E_PTT_UNUSED_ENTRY(251),
894 I40E_PTT_UNUSED_ENTRY(252),
895 I40E_PTT_UNUSED_ENTRY(253),
896 I40E_PTT_UNUSED_ENTRY(254),
897 I40E_PTT_UNUSED_ENTRY(255)
901 * i40e_init_shared_code - Initialize the shared code
902 * @hw: pointer to hardware structure
904 * This assigns the MAC type and PHY code and inits the NVM.
905 * Does not touch the hardware. This function must be called prior to any
906 * other function in the shared code. The i40e_hw structure should be
907 * memset to 0 prior to calling this function. The following fields in
908 * hw structure should be filled in prior to calling this function:
909 * hw_addr, back, device_id, vendor_id, subsystem_device_id,
910 * subsystem_vendor_id, and revision_id
912 i40e_status
i40e_init_shared_code(struct i40e_hw
*hw
)
914 i40e_status status
= 0;
915 u32 port
, ari
, func_rid
;
917 i40e_set_mac_type(hw
);
919 switch (hw
->mac
.type
) {
924 return I40E_ERR_DEVICE_NOT_SUPPORTED
;
927 hw
->phy
.get_link_info
= true;
929 /* Determine port number and PF number*/
930 port
= (rd32(hw
, I40E_PFGEN_PORTNUM
) & I40E_PFGEN_PORTNUM_PORT_NUM_MASK
)
931 >> I40E_PFGEN_PORTNUM_PORT_NUM_SHIFT
;
933 ari
= (rd32(hw
, I40E_GLPCI_CAPSUP
) & I40E_GLPCI_CAPSUP_ARI_EN_MASK
) >>
934 I40E_GLPCI_CAPSUP_ARI_EN_SHIFT
;
935 func_rid
= rd32(hw
, I40E_PF_FUNC_RID
);
937 hw
->pf_id
= (u8
)(func_rid
& 0xff);
939 hw
->pf_id
= (u8
)(func_rid
& 0x7);
941 if (hw
->mac
.type
== I40E_MAC_X722
)
942 hw
->flags
|= I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE
;
944 status
= i40e_init_nvm(hw
);
949 * i40e_aq_mac_address_read - Retrieve the MAC addresses
950 * @hw: pointer to the hw struct
951 * @flags: a return indicator of what addresses were added to the addr store
952 * @addrs: the requestor's mac addr store
953 * @cmd_details: pointer to command details structure or NULL
955 static i40e_status
i40e_aq_mac_address_read(struct i40e_hw
*hw
,
957 struct i40e_aqc_mac_address_read_data
*addrs
,
958 struct i40e_asq_cmd_details
*cmd_details
)
960 struct i40e_aq_desc desc
;
961 struct i40e_aqc_mac_address_read
*cmd_data
=
962 (struct i40e_aqc_mac_address_read
*)&desc
.params
.raw
;
965 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_mac_address_read
);
966 desc
.flags
|= cpu_to_le16(I40E_AQ_FLAG_BUF
);
968 status
= i40e_asq_send_command(hw
, &desc
, addrs
,
969 sizeof(*addrs
), cmd_details
);
970 *flags
= le16_to_cpu(cmd_data
->command_flags
);
976 * i40e_aq_mac_address_write - Change the MAC addresses
977 * @hw: pointer to the hw struct
978 * @flags: indicates which MAC to be written
979 * @mac_addr: address to write
980 * @cmd_details: pointer to command details structure or NULL
982 i40e_status
i40e_aq_mac_address_write(struct i40e_hw
*hw
,
983 u16 flags
, u8
*mac_addr
,
984 struct i40e_asq_cmd_details
*cmd_details
)
986 struct i40e_aq_desc desc
;
987 struct i40e_aqc_mac_address_write
*cmd_data
=
988 (struct i40e_aqc_mac_address_write
*)&desc
.params
.raw
;
991 i40e_fill_default_direct_cmd_desc(&desc
,
992 i40e_aqc_opc_mac_address_write
);
993 cmd_data
->command_flags
= cpu_to_le16(flags
);
994 cmd_data
->mac_sah
= cpu_to_le16((u16
)mac_addr
[0] << 8 | mac_addr
[1]);
995 cmd_data
->mac_sal
= cpu_to_le32(((u32
)mac_addr
[2] << 24) |
996 ((u32
)mac_addr
[3] << 16) |
997 ((u32
)mac_addr
[4] << 8) |
1000 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
1006 * i40e_get_mac_addr - get MAC address
1007 * @hw: pointer to the HW structure
1008 * @mac_addr: pointer to MAC address
1010 * Reads the adapter's MAC address from register
1012 i40e_status
i40e_get_mac_addr(struct i40e_hw
*hw
, u8
*mac_addr
)
1014 struct i40e_aqc_mac_address_read_data addrs
;
1018 status
= i40e_aq_mac_address_read(hw
, &flags
, &addrs
, NULL
);
1020 if (flags
& I40E_AQC_LAN_ADDR_VALID
)
1021 ether_addr_copy(mac_addr
, addrs
.pf_lan_mac
);
1027 * i40e_get_port_mac_addr - get Port MAC address
1028 * @hw: pointer to the HW structure
1029 * @mac_addr: pointer to Port MAC address
1031 * Reads the adapter's Port MAC address
1033 i40e_status
i40e_get_port_mac_addr(struct i40e_hw
*hw
, u8
*mac_addr
)
1035 struct i40e_aqc_mac_address_read_data addrs
;
1039 status
= i40e_aq_mac_address_read(hw
, &flags
, &addrs
, NULL
);
1043 if (flags
& I40E_AQC_PORT_ADDR_VALID
)
1044 ether_addr_copy(mac_addr
, addrs
.port_mac
);
1046 status
= I40E_ERR_INVALID_MAC_ADDR
;
1052 * i40e_pre_tx_queue_cfg - pre tx queue configure
1053 * @hw: pointer to the HW structure
1054 * @queue: target PF queue index
1055 * @enable: state change request
1057 * Handles hw requirement to indicate intention to enable
1058 * or disable target queue.
1060 void i40e_pre_tx_queue_cfg(struct i40e_hw
*hw
, u32 queue
, bool enable
)
1062 u32 abs_queue_idx
= hw
->func_caps
.base_queue
+ queue
;
1066 if (abs_queue_idx
>= 128) {
1067 reg_block
= abs_queue_idx
/ 128;
1068 abs_queue_idx
%= 128;
1071 reg_val
= rd32(hw
, I40E_GLLAN_TXPRE_QDIS(reg_block
));
1072 reg_val
&= ~I40E_GLLAN_TXPRE_QDIS_QINDX_MASK
;
1073 reg_val
|= (abs_queue_idx
<< I40E_GLLAN_TXPRE_QDIS_QINDX_SHIFT
);
1076 reg_val
|= I40E_GLLAN_TXPRE_QDIS_CLEAR_QDIS_MASK
;
1078 reg_val
|= I40E_GLLAN_TXPRE_QDIS_SET_QDIS_MASK
;
1080 wr32(hw
, I40E_GLLAN_TXPRE_QDIS(reg_block
), reg_val
);
1085 * i40e_get_san_mac_addr - get SAN MAC address
1086 * @hw: pointer to the HW structure
1087 * @mac_addr: pointer to SAN MAC address
1089 * Reads the adapter's SAN MAC address from NVM
1091 i40e_status
i40e_get_san_mac_addr(struct i40e_hw
*hw
, u8
*mac_addr
)
1093 struct i40e_aqc_mac_address_read_data addrs
;
1097 status
= i40e_aq_mac_address_read(hw
, &flags
, &addrs
, NULL
);
1101 if (flags
& I40E_AQC_SAN_ADDR_VALID
)
1102 ether_addr_copy(mac_addr
, addrs
.pf_san_mac
);
1104 status
= I40E_ERR_INVALID_MAC_ADDR
;
1111 * i40e_read_pba_string - Reads part number string from EEPROM
1112 * @hw: pointer to hardware structure
1113 * @pba_num: stores the part number string from the EEPROM
1114 * @pba_num_size: part number string buffer length
1116 * Reads the part number string from the EEPROM.
1118 i40e_status
i40e_read_pba_string(struct i40e_hw
*hw
, u8
*pba_num
,
1121 i40e_status status
= 0;
1127 status
= i40e_read_nvm_word(hw
, I40E_SR_PBA_FLAGS
, &pba_word
);
1128 if (status
|| (pba_word
!= 0xFAFA)) {
1129 hw_dbg(hw
, "Failed to read PBA flags or flag is invalid.\n");
1133 status
= i40e_read_nvm_word(hw
, I40E_SR_PBA_BLOCK_PTR
, &pba_ptr
);
1135 hw_dbg(hw
, "Failed to read PBA Block pointer.\n");
1139 status
= i40e_read_nvm_word(hw
, pba_ptr
, &pba_size
);
1141 hw_dbg(hw
, "Failed to read PBA Block size.\n");
1145 /* Subtract one to get PBA word count (PBA Size word is included in
1149 if (pba_num_size
< (((u32
)pba_size
* 2) + 1)) {
1150 hw_dbg(hw
, "Buffer to small for PBA data.\n");
1151 return I40E_ERR_PARAM
;
1154 for (i
= 0; i
< pba_size
; i
++) {
1155 status
= i40e_read_nvm_word(hw
, (pba_ptr
+ 1) + i
, &pba_word
);
1157 hw_dbg(hw
, "Failed to read PBA Block word %d.\n", i
);
1161 pba_num
[(i
* 2)] = (pba_word
>> 8) & 0xFF;
1162 pba_num
[(i
* 2) + 1] = pba_word
& 0xFF;
1164 pba_num
[(pba_size
* 2)] = '\0';
1170 * i40e_get_media_type - Gets media type
1171 * @hw: pointer to the hardware structure
1173 static enum i40e_media_type
i40e_get_media_type(struct i40e_hw
*hw
)
1175 enum i40e_media_type media
;
1177 switch (hw
->phy
.link_info
.phy_type
) {
1178 case I40E_PHY_TYPE_10GBASE_SR
:
1179 case I40E_PHY_TYPE_10GBASE_LR
:
1180 case I40E_PHY_TYPE_1000BASE_SX
:
1181 case I40E_PHY_TYPE_1000BASE_LX
:
1182 case I40E_PHY_TYPE_40GBASE_SR4
:
1183 case I40E_PHY_TYPE_40GBASE_LR4
:
1184 media
= I40E_MEDIA_TYPE_FIBER
;
1186 case I40E_PHY_TYPE_100BASE_TX
:
1187 case I40E_PHY_TYPE_1000BASE_T
:
1188 case I40E_PHY_TYPE_10GBASE_T
:
1189 media
= I40E_MEDIA_TYPE_BASET
;
1191 case I40E_PHY_TYPE_10GBASE_CR1_CU
:
1192 case I40E_PHY_TYPE_40GBASE_CR4_CU
:
1193 case I40E_PHY_TYPE_10GBASE_CR1
:
1194 case I40E_PHY_TYPE_40GBASE_CR4
:
1195 case I40E_PHY_TYPE_10GBASE_SFPP_CU
:
1196 case I40E_PHY_TYPE_40GBASE_AOC
:
1197 case I40E_PHY_TYPE_10GBASE_AOC
:
1198 media
= I40E_MEDIA_TYPE_DA
;
1200 case I40E_PHY_TYPE_1000BASE_KX
:
1201 case I40E_PHY_TYPE_10GBASE_KX4
:
1202 case I40E_PHY_TYPE_10GBASE_KR
:
1203 case I40E_PHY_TYPE_40GBASE_KR4
:
1204 case I40E_PHY_TYPE_20GBASE_KR2
:
1205 media
= I40E_MEDIA_TYPE_BACKPLANE
;
1207 case I40E_PHY_TYPE_SGMII
:
1208 case I40E_PHY_TYPE_XAUI
:
1209 case I40E_PHY_TYPE_XFI
:
1210 case I40E_PHY_TYPE_XLAUI
:
1211 case I40E_PHY_TYPE_XLPPI
:
1213 media
= I40E_MEDIA_TYPE_UNKNOWN
;
1220 #define I40E_PF_RESET_WAIT_COUNT_A0 200
1221 #define I40E_PF_RESET_WAIT_COUNT 200
1223 * i40e_pf_reset - Reset the PF
1224 * @hw: pointer to the hardware structure
1226 * Assuming someone else has triggered a global reset,
1227 * assure the global reset is complete and then reset the PF
1229 i40e_status
i40e_pf_reset(struct i40e_hw
*hw
)
1236 /* Poll for Global Reset steady state in case of recent GRST.
1237 * The grst delay value is in 100ms units, and we'll wait a
1238 * couple counts longer to be sure we don't just miss the end.
1240 grst_del
= (rd32(hw
, I40E_GLGEN_RSTCTL
) &
1241 I40E_GLGEN_RSTCTL_GRSTDEL_MASK
) >>
1242 I40E_GLGEN_RSTCTL_GRSTDEL_SHIFT
;
1244 /* It can take upto 15 secs for GRST steady state.
1245 * Bump it to 16 secs max to be safe.
1247 grst_del
= grst_del
* 20;
1249 for (cnt
= 0; cnt
< grst_del
; cnt
++) {
1250 reg
= rd32(hw
, I40E_GLGEN_RSTAT
);
1251 if (!(reg
& I40E_GLGEN_RSTAT_DEVSTATE_MASK
))
1255 if (reg
& I40E_GLGEN_RSTAT_DEVSTATE_MASK
) {
1256 hw_dbg(hw
, "Global reset polling failed to complete.\n");
1257 return I40E_ERR_RESET_FAILED
;
1260 /* Now Wait for the FW to be ready */
1261 for (cnt1
= 0; cnt1
< I40E_PF_RESET_WAIT_COUNT
; cnt1
++) {
1262 reg
= rd32(hw
, I40E_GLNVM_ULD
);
1263 reg
&= (I40E_GLNVM_ULD_CONF_CORE_DONE_MASK
|
1264 I40E_GLNVM_ULD_CONF_GLOBAL_DONE_MASK
);
1265 if (reg
== (I40E_GLNVM_ULD_CONF_CORE_DONE_MASK
|
1266 I40E_GLNVM_ULD_CONF_GLOBAL_DONE_MASK
)) {
1267 hw_dbg(hw
, "Core and Global modules ready %d\n", cnt1
);
1270 usleep_range(10000, 20000);
1272 if (!(reg
& (I40E_GLNVM_ULD_CONF_CORE_DONE_MASK
|
1273 I40E_GLNVM_ULD_CONF_GLOBAL_DONE_MASK
))) {
1274 hw_dbg(hw
, "wait for FW Reset complete timedout\n");
1275 hw_dbg(hw
, "I40E_GLNVM_ULD = 0x%x\n", reg
);
1276 return I40E_ERR_RESET_FAILED
;
1279 /* If there was a Global Reset in progress when we got here,
1280 * we don't need to do the PF Reset
1283 if (hw
->revision_id
== 0)
1284 cnt
= I40E_PF_RESET_WAIT_COUNT_A0
;
1286 cnt
= I40E_PF_RESET_WAIT_COUNT
;
1287 reg
= rd32(hw
, I40E_PFGEN_CTRL
);
1288 wr32(hw
, I40E_PFGEN_CTRL
,
1289 (reg
| I40E_PFGEN_CTRL_PFSWR_MASK
));
1290 for (; cnt
; cnt
--) {
1291 reg
= rd32(hw
, I40E_PFGEN_CTRL
);
1292 if (!(reg
& I40E_PFGEN_CTRL_PFSWR_MASK
))
1294 usleep_range(1000, 2000);
1296 if (reg
& I40E_PFGEN_CTRL_PFSWR_MASK
) {
1297 hw_dbg(hw
, "PF reset polling failed to complete.\n");
1298 return I40E_ERR_RESET_FAILED
;
1302 i40e_clear_pxe_mode(hw
);
1308 * i40e_clear_hw - clear out any left over hw state
1309 * @hw: pointer to the hw struct
1311 * Clear queues and interrupts, typically called at init time,
1312 * but after the capabilities have been found so we know how many
1313 * queues and msix vectors have been allocated.
1315 void i40e_clear_hw(struct i40e_hw
*hw
)
1317 u32 num_queues
, base_queue
;
1325 /* get number of interrupts, queues, and VFs */
1326 val
= rd32(hw
, I40E_GLPCI_CNF2
);
1327 num_pf_int
= (val
& I40E_GLPCI_CNF2_MSI_X_PF_N_MASK
) >>
1328 I40E_GLPCI_CNF2_MSI_X_PF_N_SHIFT
;
1329 num_vf_int
= (val
& I40E_GLPCI_CNF2_MSI_X_VF_N_MASK
) >>
1330 I40E_GLPCI_CNF2_MSI_X_VF_N_SHIFT
;
1332 val
= rd32(hw
, I40E_PFLAN_QALLOC
);
1333 base_queue
= (val
& I40E_PFLAN_QALLOC_FIRSTQ_MASK
) >>
1334 I40E_PFLAN_QALLOC_FIRSTQ_SHIFT
;
1335 j
= (val
& I40E_PFLAN_QALLOC_LASTQ_MASK
) >>
1336 I40E_PFLAN_QALLOC_LASTQ_SHIFT
;
1337 if (val
& I40E_PFLAN_QALLOC_VALID_MASK
)
1338 num_queues
= (j
- base_queue
) + 1;
1342 val
= rd32(hw
, I40E_PF_VT_PFALLOC
);
1343 i
= (val
& I40E_PF_VT_PFALLOC_FIRSTVF_MASK
) >>
1344 I40E_PF_VT_PFALLOC_FIRSTVF_SHIFT
;
1345 j
= (val
& I40E_PF_VT_PFALLOC_LASTVF_MASK
) >>
1346 I40E_PF_VT_PFALLOC_LASTVF_SHIFT
;
1347 if (val
& I40E_PF_VT_PFALLOC_VALID_MASK
)
1348 num_vfs
= (j
- i
) + 1;
1352 /* stop all the interrupts */
1353 wr32(hw
, I40E_PFINT_ICR0_ENA
, 0);
1354 val
= 0x3 << I40E_PFINT_DYN_CTLN_ITR_INDX_SHIFT
;
1355 for (i
= 0; i
< num_pf_int
- 2; i
++)
1356 wr32(hw
, I40E_PFINT_DYN_CTLN(i
), val
);
1358 /* Set the FIRSTQ_INDX field to 0x7FF in PFINT_LNKLSTx */
1359 val
= eol
<< I40E_PFINT_LNKLST0_FIRSTQ_INDX_SHIFT
;
1360 wr32(hw
, I40E_PFINT_LNKLST0
, val
);
1361 for (i
= 0; i
< num_pf_int
- 2; i
++)
1362 wr32(hw
, I40E_PFINT_LNKLSTN(i
), val
);
1363 val
= eol
<< I40E_VPINT_LNKLST0_FIRSTQ_INDX_SHIFT
;
1364 for (i
= 0; i
< num_vfs
; i
++)
1365 wr32(hw
, I40E_VPINT_LNKLST0(i
), val
);
1366 for (i
= 0; i
< num_vf_int
- 2; i
++)
1367 wr32(hw
, I40E_VPINT_LNKLSTN(i
), val
);
1369 /* warn the HW of the coming Tx disables */
1370 for (i
= 0; i
< num_queues
; i
++) {
1371 u32 abs_queue_idx
= base_queue
+ i
;
1374 if (abs_queue_idx
>= 128) {
1375 reg_block
= abs_queue_idx
/ 128;
1376 abs_queue_idx
%= 128;
1379 val
= rd32(hw
, I40E_GLLAN_TXPRE_QDIS(reg_block
));
1380 val
&= ~I40E_GLLAN_TXPRE_QDIS_QINDX_MASK
;
1381 val
|= (abs_queue_idx
<< I40E_GLLAN_TXPRE_QDIS_QINDX_SHIFT
);
1382 val
|= I40E_GLLAN_TXPRE_QDIS_SET_QDIS_MASK
;
1384 wr32(hw
, I40E_GLLAN_TXPRE_QDIS(reg_block
), val
);
1388 /* stop all the queues */
1389 for (i
= 0; i
< num_queues
; i
++) {
1390 wr32(hw
, I40E_QINT_TQCTL(i
), 0);
1391 wr32(hw
, I40E_QTX_ENA(i
), 0);
1392 wr32(hw
, I40E_QINT_RQCTL(i
), 0);
1393 wr32(hw
, I40E_QRX_ENA(i
), 0);
1396 /* short wait for all queue disables to settle */
1401 * i40e_clear_pxe_mode - clear pxe operations mode
1402 * @hw: pointer to the hw struct
1404 * Make sure all PXE mode settings are cleared, including things
1405 * like descriptor fetch/write-back mode.
1407 void i40e_clear_pxe_mode(struct i40e_hw
*hw
)
1411 if (i40e_check_asq_alive(hw
))
1412 i40e_aq_clear_pxe_mode(hw
, NULL
);
1414 /* Clear single descriptor fetch/write-back mode */
1415 reg
= rd32(hw
, I40E_GLLAN_RCTL_0
);
1417 if (hw
->revision_id
== 0) {
1418 /* As a work around clear PXE_MODE instead of setting it */
1419 wr32(hw
, I40E_GLLAN_RCTL_0
, (reg
& (~I40E_GLLAN_RCTL_0_PXE_MODE_MASK
)));
1421 wr32(hw
, I40E_GLLAN_RCTL_0
, (reg
| I40E_GLLAN_RCTL_0_PXE_MODE_MASK
));
1426 * i40e_led_is_mine - helper to find matching led
1427 * @hw: pointer to the hw struct
1428 * @idx: index into GPIO registers
1430 * returns: 0 if no match, otherwise the value of the GPIO_CTL register
1432 static u32
i40e_led_is_mine(struct i40e_hw
*hw
, int idx
)
1437 if (!hw
->func_caps
.led
[idx
])
1440 gpio_val
= rd32(hw
, I40E_GLGEN_GPIO_CTL(idx
));
1441 port
= (gpio_val
& I40E_GLGEN_GPIO_CTL_PRT_NUM_MASK
) >>
1442 I40E_GLGEN_GPIO_CTL_PRT_NUM_SHIFT
;
1444 /* if PRT_NUM_NA is 1 then this LED is not port specific, OR
1445 * if it is not our port then ignore
1447 if ((gpio_val
& I40E_GLGEN_GPIO_CTL_PRT_NUM_NA_MASK
) ||
1454 #define I40E_COMBINED_ACTIVITY 0xA
1455 #define I40E_FILTER_ACTIVITY 0xE
1456 #define I40E_LINK_ACTIVITY 0xC
1457 #define I40E_MAC_ACTIVITY 0xD
1458 #define I40E_LED0 22
1461 * i40e_led_get - return current on/off mode
1462 * @hw: pointer to the hw struct
1464 * The value returned is the 'mode' field as defined in the
1465 * GPIO register definitions: 0x0 = off, 0xf = on, and other
1466 * values are variations of possible behaviors relating to
1467 * blink, link, and wire.
1469 u32
i40e_led_get(struct i40e_hw
*hw
)
1471 u32 current_mode
= 0;
1475 /* as per the documentation GPIO 22-29 are the LED
1476 * GPIO pins named LED0..LED7
1478 for (i
= I40E_LED0
; i
<= I40E_GLGEN_GPIO_CTL_MAX_INDEX
; i
++) {
1479 u32 gpio_val
= i40e_led_is_mine(hw
, i
);
1484 /* ignore gpio LED src mode entries related to the activity
1487 current_mode
= ((gpio_val
& I40E_GLGEN_GPIO_CTL_LED_MODE_MASK
)
1488 >> I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT
);
1489 switch (current_mode
) {
1490 case I40E_COMBINED_ACTIVITY
:
1491 case I40E_FILTER_ACTIVITY
:
1492 case I40E_MAC_ACTIVITY
:
1498 mode
= (gpio_val
& I40E_GLGEN_GPIO_CTL_LED_MODE_MASK
) >>
1499 I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT
;
1507 * i40e_led_set - set new on/off mode
1508 * @hw: pointer to the hw struct
1509 * @mode: 0=off, 0xf=on (else see manual for mode details)
1510 * @blink: true if the LED should blink when on, false if steady
1512 * if this function is used to turn on the blink it should
1513 * be used to disable the blink when restoring the original state.
1515 void i40e_led_set(struct i40e_hw
*hw
, u32 mode
, bool blink
)
1517 u32 current_mode
= 0;
1520 if (mode
& 0xfffffff0)
1521 hw_dbg(hw
, "invalid mode passed in %X\n", mode
);
1523 /* as per the documentation GPIO 22-29 are the LED
1524 * GPIO pins named LED0..LED7
1526 for (i
= I40E_LED0
; i
<= I40E_GLGEN_GPIO_CTL_MAX_INDEX
; i
++) {
1527 u32 gpio_val
= i40e_led_is_mine(hw
, i
);
1532 /* ignore gpio LED src mode entries related to the activity
1535 current_mode
= ((gpio_val
& I40E_GLGEN_GPIO_CTL_LED_MODE_MASK
)
1536 >> I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT
);
1537 switch (current_mode
) {
1538 case I40E_COMBINED_ACTIVITY
:
1539 case I40E_FILTER_ACTIVITY
:
1540 case I40E_MAC_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
);
1551 if (mode
== I40E_LINK_ACTIVITY
)
1555 gpio_val
|= BIT(I40E_GLGEN_GPIO_CTL_LED_BLINK_SHIFT
);
1557 gpio_val
&= ~BIT(I40E_GLGEN_GPIO_CTL_LED_BLINK_SHIFT
);
1559 wr32(hw
, I40E_GLGEN_GPIO_CTL(i
), gpio_val
);
1564 /* Admin command wrappers */
1567 * i40e_aq_get_phy_capabilities
1568 * @hw: pointer to the hw struct
1569 * @abilities: structure for PHY capabilities to be filled
1570 * @qualified_modules: report Qualified Modules
1571 * @report_init: report init capabilities (active are default)
1572 * @cmd_details: pointer to command details structure or NULL
1574 * Returns the various PHY abilities supported on the Port.
1576 i40e_status
i40e_aq_get_phy_capabilities(struct i40e_hw
*hw
,
1577 bool qualified_modules
, bool report_init
,
1578 struct i40e_aq_get_phy_abilities_resp
*abilities
,
1579 struct i40e_asq_cmd_details
*cmd_details
)
1581 struct i40e_aq_desc desc
;
1583 u16 abilities_size
= sizeof(struct i40e_aq_get_phy_abilities_resp
);
1586 return I40E_ERR_PARAM
;
1588 i40e_fill_default_direct_cmd_desc(&desc
,
1589 i40e_aqc_opc_get_phy_abilities
);
1591 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_BUF
);
1592 if (abilities_size
> I40E_AQ_LARGE_BUF
)
1593 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_LB
);
1595 if (qualified_modules
)
1596 desc
.params
.external
.param0
|=
1597 cpu_to_le32(I40E_AQ_PHY_REPORT_QUALIFIED_MODULES
);
1600 desc
.params
.external
.param0
|=
1601 cpu_to_le32(I40E_AQ_PHY_REPORT_INITIAL_VALUES
);
1603 status
= i40e_asq_send_command(hw
, &desc
, abilities
, abilities_size
,
1606 if (hw
->aq
.asq_last_status
== I40E_AQ_RC_EIO
)
1607 status
= I40E_ERR_UNKNOWN_PHY
;
1610 hw
->phy
.phy_types
= le32_to_cpu(abilities
->phy_type
);
1616 * i40e_aq_set_phy_config
1617 * @hw: pointer to the hw struct
1618 * @config: structure with PHY configuration to be set
1619 * @cmd_details: pointer to command details structure or NULL
1621 * Set the various PHY configuration parameters
1622 * supported on the Port.One or more of the Set PHY config parameters may be
1623 * ignored in an MFP mode as the PF may not have the privilege to set some
1624 * of the PHY Config parameters. This status will be indicated by the
1627 enum i40e_status_code
i40e_aq_set_phy_config(struct i40e_hw
*hw
,
1628 struct i40e_aq_set_phy_config
*config
,
1629 struct i40e_asq_cmd_details
*cmd_details
)
1631 struct i40e_aq_desc desc
;
1632 struct i40e_aq_set_phy_config
*cmd
=
1633 (struct i40e_aq_set_phy_config
*)&desc
.params
.raw
;
1634 enum i40e_status_code status
;
1637 return I40E_ERR_PARAM
;
1639 i40e_fill_default_direct_cmd_desc(&desc
,
1640 i40e_aqc_opc_set_phy_config
);
1644 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
1651 * @hw: pointer to the hw struct
1653 * Set the requested flow control mode using set_phy_config.
1655 enum i40e_status_code
i40e_set_fc(struct i40e_hw
*hw
, u8
*aq_failures
,
1656 bool atomic_restart
)
1658 enum i40e_fc_mode fc_mode
= hw
->fc
.requested_mode
;
1659 struct i40e_aq_get_phy_abilities_resp abilities
;
1660 struct i40e_aq_set_phy_config config
;
1661 enum i40e_status_code status
;
1662 u8 pause_mask
= 0x0;
1668 pause_mask
|= I40E_AQ_PHY_FLAG_PAUSE_TX
;
1669 pause_mask
|= I40E_AQ_PHY_FLAG_PAUSE_RX
;
1671 case I40E_FC_RX_PAUSE
:
1672 pause_mask
|= I40E_AQ_PHY_FLAG_PAUSE_RX
;
1674 case I40E_FC_TX_PAUSE
:
1675 pause_mask
|= I40E_AQ_PHY_FLAG_PAUSE_TX
;
1681 /* Get the current phy config */
1682 status
= i40e_aq_get_phy_capabilities(hw
, false, false, &abilities
,
1685 *aq_failures
|= I40E_SET_FC_AQ_FAIL_GET
;
1689 memset(&config
, 0, sizeof(struct i40e_aq_set_phy_config
));
1690 /* clear the old pause settings */
1691 config
.abilities
= abilities
.abilities
& ~(I40E_AQ_PHY_FLAG_PAUSE_TX
) &
1692 ~(I40E_AQ_PHY_FLAG_PAUSE_RX
);
1693 /* set the new abilities */
1694 config
.abilities
|= pause_mask
;
1695 /* If the abilities have changed, then set the new config */
1696 if (config
.abilities
!= abilities
.abilities
) {
1697 /* Auto restart link so settings take effect */
1699 config
.abilities
|= I40E_AQ_PHY_ENABLE_ATOMIC_LINK
;
1700 /* Copy over all the old settings */
1701 config
.phy_type
= abilities
.phy_type
;
1702 config
.link_speed
= abilities
.link_speed
;
1703 config
.eee_capability
= abilities
.eee_capability
;
1704 config
.eeer
= abilities
.eeer_val
;
1705 config
.low_power_ctrl
= abilities
.d3_lpan
;
1706 status
= i40e_aq_set_phy_config(hw
, &config
, NULL
);
1709 *aq_failures
|= I40E_SET_FC_AQ_FAIL_SET
;
1711 /* Update the link info */
1712 status
= i40e_update_link_info(hw
);
1714 /* Wait a little bit (on 40G cards it sometimes takes a really
1715 * long time for link to come back from the atomic reset)
1719 status
= i40e_update_link_info(hw
);
1722 *aq_failures
|= I40E_SET_FC_AQ_FAIL_UPDATE
;
1728 * i40e_aq_clear_pxe_mode
1729 * @hw: pointer to the hw struct
1730 * @cmd_details: pointer to command details structure or NULL
1732 * Tell the firmware that the driver is taking over from PXE
1734 i40e_status
i40e_aq_clear_pxe_mode(struct i40e_hw
*hw
,
1735 struct i40e_asq_cmd_details
*cmd_details
)
1738 struct i40e_aq_desc desc
;
1739 struct i40e_aqc_clear_pxe
*cmd
=
1740 (struct i40e_aqc_clear_pxe
*)&desc
.params
.raw
;
1742 i40e_fill_default_direct_cmd_desc(&desc
,
1743 i40e_aqc_opc_clear_pxe_mode
);
1747 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
1749 wr32(hw
, I40E_GLLAN_RCTL_0
, 0x1);
1755 * i40e_aq_set_link_restart_an
1756 * @hw: pointer to the hw struct
1757 * @enable_link: if true: enable link, if false: disable link
1758 * @cmd_details: pointer to command details structure or NULL
1760 * Sets up the link and restarts the Auto-Negotiation over the link.
1762 i40e_status
i40e_aq_set_link_restart_an(struct i40e_hw
*hw
,
1764 struct i40e_asq_cmd_details
*cmd_details
)
1766 struct i40e_aq_desc desc
;
1767 struct i40e_aqc_set_link_restart_an
*cmd
=
1768 (struct i40e_aqc_set_link_restart_an
*)&desc
.params
.raw
;
1771 i40e_fill_default_direct_cmd_desc(&desc
,
1772 i40e_aqc_opc_set_link_restart_an
);
1774 cmd
->command
= I40E_AQ_PHY_RESTART_AN
;
1776 cmd
->command
|= I40E_AQ_PHY_LINK_ENABLE
;
1778 cmd
->command
&= ~I40E_AQ_PHY_LINK_ENABLE
;
1780 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
1786 * i40e_aq_get_link_info
1787 * @hw: pointer to the hw struct
1788 * @enable_lse: enable/disable LinkStatusEvent reporting
1789 * @link: pointer to link status structure - optional
1790 * @cmd_details: pointer to command details structure or NULL
1792 * Returns the link status of the adapter.
1794 i40e_status
i40e_aq_get_link_info(struct i40e_hw
*hw
,
1795 bool enable_lse
, struct i40e_link_status
*link
,
1796 struct i40e_asq_cmd_details
*cmd_details
)
1798 struct i40e_aq_desc desc
;
1799 struct i40e_aqc_get_link_status
*resp
=
1800 (struct i40e_aqc_get_link_status
*)&desc
.params
.raw
;
1801 struct i40e_link_status
*hw_link_info
= &hw
->phy
.link_info
;
1803 bool tx_pause
, rx_pause
;
1806 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_get_link_status
);
1809 command_flags
= I40E_AQ_LSE_ENABLE
;
1811 command_flags
= I40E_AQ_LSE_DISABLE
;
1812 resp
->command_flags
= cpu_to_le16(command_flags
);
1814 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
1817 goto aq_get_link_info_exit
;
1819 /* save off old link status information */
1820 hw
->phy
.link_info_old
= *hw_link_info
;
1822 /* update link status */
1823 hw_link_info
->phy_type
= (enum i40e_aq_phy_type
)resp
->phy_type
;
1824 hw
->phy
.media_type
= i40e_get_media_type(hw
);
1825 hw_link_info
->link_speed
= (enum i40e_aq_link_speed
)resp
->link_speed
;
1826 hw_link_info
->link_info
= resp
->link_info
;
1827 hw_link_info
->an_info
= resp
->an_info
;
1828 hw_link_info
->ext_info
= resp
->ext_info
;
1829 hw_link_info
->loopback
= resp
->loopback
;
1830 hw_link_info
->max_frame_size
= le16_to_cpu(resp
->max_frame_size
);
1831 hw_link_info
->pacing
= resp
->config
& I40E_AQ_CONFIG_PACING_MASK
;
1833 /* update fc info */
1834 tx_pause
= !!(resp
->an_info
& I40E_AQ_LINK_PAUSE_TX
);
1835 rx_pause
= !!(resp
->an_info
& I40E_AQ_LINK_PAUSE_RX
);
1836 if (tx_pause
& rx_pause
)
1837 hw
->fc
.current_mode
= I40E_FC_FULL
;
1839 hw
->fc
.current_mode
= I40E_FC_TX_PAUSE
;
1841 hw
->fc
.current_mode
= I40E_FC_RX_PAUSE
;
1843 hw
->fc
.current_mode
= I40E_FC_NONE
;
1845 if (resp
->config
& I40E_AQ_CONFIG_CRC_ENA
)
1846 hw_link_info
->crc_enable
= true;
1848 hw_link_info
->crc_enable
= false;
1850 if (resp
->command_flags
& cpu_to_le16(I40E_AQ_LSE_ENABLE
))
1851 hw_link_info
->lse_enable
= true;
1853 hw_link_info
->lse_enable
= false;
1855 if ((hw
->aq
.fw_maj_ver
< 4 || (hw
->aq
.fw_maj_ver
== 4 &&
1856 hw
->aq
.fw_min_ver
< 40)) && hw_link_info
->phy_type
== 0xE)
1857 hw_link_info
->phy_type
= I40E_PHY_TYPE_10GBASE_SFPP_CU
;
1859 /* save link status information */
1861 *link
= *hw_link_info
;
1863 /* flag cleared so helper functions don't call AQ again */
1864 hw
->phy
.get_link_info
= false;
1866 aq_get_link_info_exit
:
1871 * i40e_aq_set_phy_int_mask
1872 * @hw: pointer to the hw struct
1873 * @mask: interrupt mask to be set
1874 * @cmd_details: pointer to command details structure or NULL
1876 * Set link interrupt mask.
1878 i40e_status
i40e_aq_set_phy_int_mask(struct i40e_hw
*hw
,
1880 struct i40e_asq_cmd_details
*cmd_details
)
1882 struct i40e_aq_desc desc
;
1883 struct i40e_aqc_set_phy_int_mask
*cmd
=
1884 (struct i40e_aqc_set_phy_int_mask
*)&desc
.params
.raw
;
1887 i40e_fill_default_direct_cmd_desc(&desc
,
1888 i40e_aqc_opc_set_phy_int_mask
);
1890 cmd
->event_mask
= cpu_to_le16(mask
);
1892 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
1898 * i40e_aq_set_phy_debug
1899 * @hw: pointer to the hw struct
1900 * @cmd_flags: debug command flags
1901 * @cmd_details: pointer to command details structure or NULL
1903 * Reset the external PHY.
1905 i40e_status
i40e_aq_set_phy_debug(struct i40e_hw
*hw
, u8 cmd_flags
,
1906 struct i40e_asq_cmd_details
*cmd_details
)
1908 struct i40e_aq_desc desc
;
1909 struct i40e_aqc_set_phy_debug
*cmd
=
1910 (struct i40e_aqc_set_phy_debug
*)&desc
.params
.raw
;
1913 i40e_fill_default_direct_cmd_desc(&desc
,
1914 i40e_aqc_opc_set_phy_debug
);
1916 cmd
->command_flags
= cmd_flags
;
1918 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
1925 * @hw: pointer to the hw struct
1926 * @vsi_ctx: pointer to a vsi context struct
1927 * @cmd_details: pointer to command details structure or NULL
1929 * Add a VSI context to the hardware.
1931 i40e_status
i40e_aq_add_vsi(struct i40e_hw
*hw
,
1932 struct i40e_vsi_context
*vsi_ctx
,
1933 struct i40e_asq_cmd_details
*cmd_details
)
1935 struct i40e_aq_desc desc
;
1936 struct i40e_aqc_add_get_update_vsi
*cmd
=
1937 (struct i40e_aqc_add_get_update_vsi
*)&desc
.params
.raw
;
1938 struct i40e_aqc_add_get_update_vsi_completion
*resp
=
1939 (struct i40e_aqc_add_get_update_vsi_completion
*)
1943 i40e_fill_default_direct_cmd_desc(&desc
,
1944 i40e_aqc_opc_add_vsi
);
1946 cmd
->uplink_seid
= cpu_to_le16(vsi_ctx
->uplink_seid
);
1947 cmd
->connection_type
= vsi_ctx
->connection_type
;
1948 cmd
->vf_id
= vsi_ctx
->vf_num
;
1949 cmd
->vsi_flags
= cpu_to_le16(vsi_ctx
->flags
);
1951 desc
.flags
|= cpu_to_le16((u16
)(I40E_AQ_FLAG_BUF
| I40E_AQ_FLAG_RD
));
1953 status
= i40e_asq_send_command(hw
, &desc
, &vsi_ctx
->info
,
1954 sizeof(vsi_ctx
->info
), cmd_details
);
1957 goto aq_add_vsi_exit
;
1959 vsi_ctx
->seid
= le16_to_cpu(resp
->seid
);
1960 vsi_ctx
->vsi_number
= le16_to_cpu(resp
->vsi_number
);
1961 vsi_ctx
->vsis_allocated
= le16_to_cpu(resp
->vsi_used
);
1962 vsi_ctx
->vsis_unallocated
= le16_to_cpu(resp
->vsi_free
);
1969 * i40e_aq_set_vsi_unicast_promiscuous
1970 * @hw: pointer to the hw struct
1972 * @set: set unicast promiscuous enable/disable
1973 * @cmd_details: pointer to command details structure or NULL
1975 i40e_status
i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw
*hw
,
1977 struct i40e_asq_cmd_details
*cmd_details
)
1979 struct i40e_aq_desc desc
;
1980 struct i40e_aqc_set_vsi_promiscuous_modes
*cmd
=
1981 (struct i40e_aqc_set_vsi_promiscuous_modes
*)&desc
.params
.raw
;
1985 i40e_fill_default_direct_cmd_desc(&desc
,
1986 i40e_aqc_opc_set_vsi_promiscuous_modes
);
1989 flags
|= I40E_AQC_SET_VSI_PROMISC_UNICAST
;
1990 if (((hw
->aq
.api_maj_ver
== 1) && (hw
->aq
.api_min_ver
>= 5)) ||
1991 (hw
->aq
.api_maj_ver
> 1))
1992 flags
|= I40E_AQC_SET_VSI_PROMISC_TX
;
1995 cmd
->promiscuous_flags
= cpu_to_le16(flags
);
1997 cmd
->valid_flags
= cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_UNICAST
);
1998 if (((hw
->aq
.api_maj_ver
>= 1) && (hw
->aq
.api_min_ver
>= 5)) ||
1999 (hw
->aq
.api_maj_ver
> 1))
2000 cmd
->valid_flags
|= cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_TX
);
2002 cmd
->seid
= cpu_to_le16(seid
);
2003 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
2009 * i40e_aq_set_vsi_multicast_promiscuous
2010 * @hw: pointer to the hw struct
2012 * @set: set multicast promiscuous enable/disable
2013 * @cmd_details: pointer to command details structure or NULL
2015 i40e_status
i40e_aq_set_vsi_multicast_promiscuous(struct i40e_hw
*hw
,
2016 u16 seid
, bool set
, struct i40e_asq_cmd_details
*cmd_details
)
2018 struct i40e_aq_desc desc
;
2019 struct i40e_aqc_set_vsi_promiscuous_modes
*cmd
=
2020 (struct i40e_aqc_set_vsi_promiscuous_modes
*)&desc
.params
.raw
;
2024 i40e_fill_default_direct_cmd_desc(&desc
,
2025 i40e_aqc_opc_set_vsi_promiscuous_modes
);
2028 flags
|= I40E_AQC_SET_VSI_PROMISC_MULTICAST
;
2030 cmd
->promiscuous_flags
= cpu_to_le16(flags
);
2032 cmd
->valid_flags
= cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_MULTICAST
);
2034 cmd
->seid
= cpu_to_le16(seid
);
2035 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
2041 * i40e_aq_set_vsi_broadcast
2042 * @hw: pointer to the hw struct
2044 * @set_filter: true to set filter, false to clear filter
2045 * @cmd_details: pointer to command details structure or NULL
2047 * Set or clear the broadcast promiscuous flag (filter) for a given VSI.
2049 i40e_status
i40e_aq_set_vsi_broadcast(struct i40e_hw
*hw
,
2050 u16 seid
, bool set_filter
,
2051 struct i40e_asq_cmd_details
*cmd_details
)
2053 struct i40e_aq_desc desc
;
2054 struct i40e_aqc_set_vsi_promiscuous_modes
*cmd
=
2055 (struct i40e_aqc_set_vsi_promiscuous_modes
*)&desc
.params
.raw
;
2058 i40e_fill_default_direct_cmd_desc(&desc
,
2059 i40e_aqc_opc_set_vsi_promiscuous_modes
);
2062 cmd
->promiscuous_flags
2063 |= cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_BROADCAST
);
2065 cmd
->promiscuous_flags
2066 &= cpu_to_le16(~I40E_AQC_SET_VSI_PROMISC_BROADCAST
);
2068 cmd
->valid_flags
= cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_BROADCAST
);
2069 cmd
->seid
= cpu_to_le16(seid
);
2070 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
2076 * i40e_aq_set_vsi_vlan_promisc - control the VLAN promiscuous setting
2077 * @hw: pointer to the hw struct
2079 * @enable: set MAC L2 layer unicast promiscuous enable/disable for a given VLAN
2080 * @cmd_details: pointer to command details structure or NULL
2082 i40e_status
i40e_aq_set_vsi_vlan_promisc(struct i40e_hw
*hw
,
2083 u16 seid
, bool enable
,
2084 struct i40e_asq_cmd_details
*cmd_details
)
2086 struct i40e_aq_desc desc
;
2087 struct i40e_aqc_set_vsi_promiscuous_modes
*cmd
=
2088 (struct i40e_aqc_set_vsi_promiscuous_modes
*)&desc
.params
.raw
;
2092 i40e_fill_default_direct_cmd_desc(&desc
,
2093 i40e_aqc_opc_set_vsi_promiscuous_modes
);
2095 flags
|= I40E_AQC_SET_VSI_PROMISC_VLAN
;
2097 cmd
->promiscuous_flags
= cpu_to_le16(flags
);
2098 cmd
->valid_flags
= cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_VLAN
);
2099 cmd
->seid
= cpu_to_le16(seid
);
2101 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
2107 * i40e_get_vsi_params - get VSI configuration info
2108 * @hw: pointer to the hw struct
2109 * @vsi_ctx: pointer to a vsi context struct
2110 * @cmd_details: pointer to command details structure or NULL
2112 i40e_status
i40e_aq_get_vsi_params(struct i40e_hw
*hw
,
2113 struct i40e_vsi_context
*vsi_ctx
,
2114 struct i40e_asq_cmd_details
*cmd_details
)
2116 struct i40e_aq_desc desc
;
2117 struct i40e_aqc_add_get_update_vsi
*cmd
=
2118 (struct i40e_aqc_add_get_update_vsi
*)&desc
.params
.raw
;
2119 struct i40e_aqc_add_get_update_vsi_completion
*resp
=
2120 (struct i40e_aqc_add_get_update_vsi_completion
*)
2124 i40e_fill_default_direct_cmd_desc(&desc
,
2125 i40e_aqc_opc_get_vsi_parameters
);
2127 cmd
->uplink_seid
= cpu_to_le16(vsi_ctx
->seid
);
2129 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_BUF
);
2131 status
= i40e_asq_send_command(hw
, &desc
, &vsi_ctx
->info
,
2132 sizeof(vsi_ctx
->info
), NULL
);
2135 goto aq_get_vsi_params_exit
;
2137 vsi_ctx
->seid
= le16_to_cpu(resp
->seid
);
2138 vsi_ctx
->vsi_number
= le16_to_cpu(resp
->vsi_number
);
2139 vsi_ctx
->vsis_allocated
= le16_to_cpu(resp
->vsi_used
);
2140 vsi_ctx
->vsis_unallocated
= le16_to_cpu(resp
->vsi_free
);
2142 aq_get_vsi_params_exit
:
2147 * i40e_aq_update_vsi_params
2148 * @hw: pointer to the hw struct
2149 * @vsi_ctx: pointer to a vsi context struct
2150 * @cmd_details: pointer to command details structure or NULL
2152 * Update a VSI context.
2154 i40e_status
i40e_aq_update_vsi_params(struct i40e_hw
*hw
,
2155 struct i40e_vsi_context
*vsi_ctx
,
2156 struct i40e_asq_cmd_details
*cmd_details
)
2158 struct i40e_aq_desc desc
;
2159 struct i40e_aqc_add_get_update_vsi
*cmd
=
2160 (struct i40e_aqc_add_get_update_vsi
*)&desc
.params
.raw
;
2161 struct i40e_aqc_add_get_update_vsi_completion
*resp
=
2162 (struct i40e_aqc_add_get_update_vsi_completion
*)
2166 i40e_fill_default_direct_cmd_desc(&desc
,
2167 i40e_aqc_opc_update_vsi_parameters
);
2168 cmd
->uplink_seid
= cpu_to_le16(vsi_ctx
->seid
);
2170 desc
.flags
|= cpu_to_le16((u16
)(I40E_AQ_FLAG_BUF
| I40E_AQ_FLAG_RD
));
2172 status
= i40e_asq_send_command(hw
, &desc
, &vsi_ctx
->info
,
2173 sizeof(vsi_ctx
->info
), cmd_details
);
2175 vsi_ctx
->vsis_allocated
= le16_to_cpu(resp
->vsi_used
);
2176 vsi_ctx
->vsis_unallocated
= le16_to_cpu(resp
->vsi_free
);
2182 * i40e_aq_get_switch_config
2183 * @hw: pointer to the hardware structure
2184 * @buf: pointer to the result buffer
2185 * @buf_size: length of input buffer
2186 * @start_seid: seid to start for the report, 0 == beginning
2187 * @cmd_details: pointer to command details structure or NULL
2189 * Fill the buf with switch configuration returned from AdminQ command
2191 i40e_status
i40e_aq_get_switch_config(struct i40e_hw
*hw
,
2192 struct i40e_aqc_get_switch_config_resp
*buf
,
2193 u16 buf_size
, u16
*start_seid
,
2194 struct i40e_asq_cmd_details
*cmd_details
)
2196 struct i40e_aq_desc desc
;
2197 struct i40e_aqc_switch_seid
*scfg
=
2198 (struct i40e_aqc_switch_seid
*)&desc
.params
.raw
;
2201 i40e_fill_default_direct_cmd_desc(&desc
,
2202 i40e_aqc_opc_get_switch_config
);
2203 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_BUF
);
2204 if (buf_size
> I40E_AQ_LARGE_BUF
)
2205 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_LB
);
2206 scfg
->seid
= cpu_to_le16(*start_seid
);
2208 status
= i40e_asq_send_command(hw
, &desc
, buf
, buf_size
, cmd_details
);
2209 *start_seid
= le16_to_cpu(scfg
->seid
);
2215 * i40e_aq_get_firmware_version
2216 * @hw: pointer to the hw struct
2217 * @fw_major_version: firmware major version
2218 * @fw_minor_version: firmware minor version
2219 * @fw_build: firmware build number
2220 * @api_major_version: major queue version
2221 * @api_minor_version: minor queue version
2222 * @cmd_details: pointer to command details structure or NULL
2224 * Get the firmware version from the admin queue commands
2226 i40e_status
i40e_aq_get_firmware_version(struct i40e_hw
*hw
,
2227 u16
*fw_major_version
, u16
*fw_minor_version
,
2229 u16
*api_major_version
, u16
*api_minor_version
,
2230 struct i40e_asq_cmd_details
*cmd_details
)
2232 struct i40e_aq_desc desc
;
2233 struct i40e_aqc_get_version
*resp
=
2234 (struct i40e_aqc_get_version
*)&desc
.params
.raw
;
2237 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_get_version
);
2239 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
2242 if (fw_major_version
)
2243 *fw_major_version
= le16_to_cpu(resp
->fw_major
);
2244 if (fw_minor_version
)
2245 *fw_minor_version
= le16_to_cpu(resp
->fw_minor
);
2247 *fw_build
= le32_to_cpu(resp
->fw_build
);
2248 if (api_major_version
)
2249 *api_major_version
= le16_to_cpu(resp
->api_major
);
2250 if (api_minor_version
)
2251 *api_minor_version
= le16_to_cpu(resp
->api_minor
);
2258 * i40e_aq_send_driver_version
2259 * @hw: pointer to the hw struct
2260 * @dv: driver's major, minor version
2261 * @cmd_details: pointer to command details structure or NULL
2263 * Send the driver version to the firmware
2265 i40e_status
i40e_aq_send_driver_version(struct i40e_hw
*hw
,
2266 struct i40e_driver_version
*dv
,
2267 struct i40e_asq_cmd_details
*cmd_details
)
2269 struct i40e_aq_desc desc
;
2270 struct i40e_aqc_driver_version
*cmd
=
2271 (struct i40e_aqc_driver_version
*)&desc
.params
.raw
;
2276 return I40E_ERR_PARAM
;
2278 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_driver_version
);
2280 desc
.flags
|= cpu_to_le16(I40E_AQ_FLAG_BUF
| I40E_AQ_FLAG_RD
);
2281 cmd
->driver_major_ver
= dv
->major_version
;
2282 cmd
->driver_minor_ver
= dv
->minor_version
;
2283 cmd
->driver_build_ver
= dv
->build_version
;
2284 cmd
->driver_subbuild_ver
= dv
->subbuild_version
;
2287 while (len
< sizeof(dv
->driver_string
) &&
2288 (dv
->driver_string
[len
] < 0x80) &&
2289 dv
->driver_string
[len
])
2291 status
= i40e_asq_send_command(hw
, &desc
, dv
->driver_string
,
2298 * i40e_get_link_status - get status of the HW network link
2299 * @hw: pointer to the hw struct
2300 * @link_up: pointer to bool (true/false = linkup/linkdown)
2302 * Variable link_up true if link is up, false if link is down.
2303 * The variable link_up is invalid if returned value of status != 0
2305 * Side effect: LinkStatusEvent reporting becomes enabled
2307 i40e_status
i40e_get_link_status(struct i40e_hw
*hw
, bool *link_up
)
2309 i40e_status status
= 0;
2311 if (hw
->phy
.get_link_info
) {
2312 status
= i40e_update_link_info(hw
);
2315 i40e_debug(hw
, I40E_DEBUG_LINK
, "get link failed: status %d\n",
2319 *link_up
= hw
->phy
.link_info
.link_info
& I40E_AQ_LINK_UP
;
2325 * i40e_updatelink_status - update status of the HW network link
2326 * @hw: pointer to the hw struct
2328 i40e_status
i40e_update_link_info(struct i40e_hw
*hw
)
2330 struct i40e_aq_get_phy_abilities_resp abilities
;
2331 i40e_status status
= 0;
2333 status
= i40e_aq_get_link_info(hw
, true, NULL
, NULL
);
2337 if (hw
->phy
.link_info
.link_info
& I40E_AQ_MEDIA_AVAILABLE
) {
2338 status
= i40e_aq_get_phy_capabilities(hw
, false, false,
2343 memcpy(hw
->phy
.link_info
.module_type
, &abilities
.module_type
,
2344 sizeof(hw
->phy
.link_info
.module_type
));
2351 * i40e_aq_add_veb - Insert a VEB between the VSI and the MAC
2352 * @hw: pointer to the hw struct
2353 * @uplink_seid: the MAC or other gizmo SEID
2354 * @downlink_seid: the VSI SEID
2355 * @enabled_tc: bitmap of TCs to be enabled
2356 * @default_port: true for default port VSI, false for control port
2357 * @veb_seid: pointer to where to put the resulting VEB SEID
2358 * @enable_stats: true to turn on VEB stats
2359 * @cmd_details: pointer to command details structure or NULL
2361 * This asks the FW to add a VEB between the uplink and downlink
2362 * elements. If the uplink SEID is 0, this will be a floating VEB.
2364 i40e_status
i40e_aq_add_veb(struct i40e_hw
*hw
, u16 uplink_seid
,
2365 u16 downlink_seid
, u8 enabled_tc
,
2366 bool default_port
, u16
*veb_seid
,
2368 struct i40e_asq_cmd_details
*cmd_details
)
2370 struct i40e_aq_desc desc
;
2371 struct i40e_aqc_add_veb
*cmd
=
2372 (struct i40e_aqc_add_veb
*)&desc
.params
.raw
;
2373 struct i40e_aqc_add_veb_completion
*resp
=
2374 (struct i40e_aqc_add_veb_completion
*)&desc
.params
.raw
;
2378 /* SEIDs need to either both be set or both be 0 for floating VEB */
2379 if (!!uplink_seid
!= !!downlink_seid
)
2380 return I40E_ERR_PARAM
;
2382 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_add_veb
);
2384 cmd
->uplink_seid
= cpu_to_le16(uplink_seid
);
2385 cmd
->downlink_seid
= cpu_to_le16(downlink_seid
);
2386 cmd
->enable_tcs
= enabled_tc
;
2388 veb_flags
|= I40E_AQC_ADD_VEB_FLOATING
;
2390 veb_flags
|= I40E_AQC_ADD_VEB_PORT_TYPE_DEFAULT
;
2392 veb_flags
|= I40E_AQC_ADD_VEB_PORT_TYPE_DATA
;
2394 /* reverse logic here: set the bitflag to disable the stats */
2396 veb_flags
|= I40E_AQC_ADD_VEB_ENABLE_DISABLE_STATS
;
2398 cmd
->veb_flags
= cpu_to_le16(veb_flags
);
2400 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
2402 if (!status
&& veb_seid
)
2403 *veb_seid
= le16_to_cpu(resp
->veb_seid
);
2409 * i40e_aq_get_veb_parameters - Retrieve VEB parameters
2410 * @hw: pointer to the hw struct
2411 * @veb_seid: the SEID of the VEB to query
2412 * @switch_id: the uplink switch id
2413 * @floating: set to true if the VEB is floating
2414 * @statistic_index: index of the stats counter block for this VEB
2415 * @vebs_used: number of VEB's used by function
2416 * @vebs_free: total VEB's not reserved by any function
2417 * @cmd_details: pointer to command details structure or NULL
2419 * This retrieves the parameters for a particular VEB, specified by
2420 * uplink_seid, and returns them to the caller.
2422 i40e_status
i40e_aq_get_veb_parameters(struct i40e_hw
*hw
,
2423 u16 veb_seid
, u16
*switch_id
,
2424 bool *floating
, u16
*statistic_index
,
2425 u16
*vebs_used
, u16
*vebs_free
,
2426 struct i40e_asq_cmd_details
*cmd_details
)
2428 struct i40e_aq_desc desc
;
2429 struct i40e_aqc_get_veb_parameters_completion
*cmd_resp
=
2430 (struct i40e_aqc_get_veb_parameters_completion
*)
2435 return I40E_ERR_PARAM
;
2437 i40e_fill_default_direct_cmd_desc(&desc
,
2438 i40e_aqc_opc_get_veb_parameters
);
2439 cmd_resp
->seid
= cpu_to_le16(veb_seid
);
2441 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
2446 *switch_id
= le16_to_cpu(cmd_resp
->switch_id
);
2447 if (statistic_index
)
2448 *statistic_index
= le16_to_cpu(cmd_resp
->statistic_index
);
2450 *vebs_used
= le16_to_cpu(cmd_resp
->vebs_used
);
2452 *vebs_free
= le16_to_cpu(cmd_resp
->vebs_free
);
2454 u16 flags
= le16_to_cpu(cmd_resp
->veb_flags
);
2456 if (flags
& I40E_AQC_ADD_VEB_FLOATING
)
2467 * i40e_aq_add_macvlan
2468 * @hw: pointer to the hw struct
2469 * @seid: VSI for the mac address
2470 * @mv_list: list of macvlans to be added
2471 * @count: length of the list
2472 * @cmd_details: pointer to command details structure or NULL
2474 * Add MAC/VLAN addresses to the HW filtering
2476 i40e_status
i40e_aq_add_macvlan(struct i40e_hw
*hw
, u16 seid
,
2477 struct i40e_aqc_add_macvlan_element_data
*mv_list
,
2478 u16 count
, struct i40e_asq_cmd_details
*cmd_details
)
2480 struct i40e_aq_desc desc
;
2481 struct i40e_aqc_macvlan
*cmd
=
2482 (struct i40e_aqc_macvlan
*)&desc
.params
.raw
;
2487 if (count
== 0 || !mv_list
|| !hw
)
2488 return I40E_ERR_PARAM
;
2490 buf_size
= count
* sizeof(*mv_list
);
2492 /* prep the rest of the request */
2493 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_add_macvlan
);
2494 cmd
->num_addresses
= cpu_to_le16(count
);
2495 cmd
->seid
[0] = cpu_to_le16(I40E_AQC_MACVLAN_CMD_SEID_VALID
| seid
);
2499 for (i
= 0; i
< count
; i
++)
2500 if (is_multicast_ether_addr(mv_list
[i
].mac_addr
))
2502 cpu_to_le16(I40E_AQC_MACVLAN_ADD_USE_SHARED_MAC
);
2504 desc
.flags
|= cpu_to_le16((u16
)(I40E_AQ_FLAG_BUF
| I40E_AQ_FLAG_RD
));
2505 if (buf_size
> I40E_AQ_LARGE_BUF
)
2506 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_LB
);
2508 status
= i40e_asq_send_command(hw
, &desc
, mv_list
, buf_size
,
2515 * i40e_aq_remove_macvlan
2516 * @hw: pointer to the hw struct
2517 * @seid: VSI for the mac address
2518 * @mv_list: list of macvlans to be removed
2519 * @count: length of the list
2520 * @cmd_details: pointer to command details structure or NULL
2522 * Remove MAC/VLAN addresses from the HW filtering
2524 i40e_status
i40e_aq_remove_macvlan(struct i40e_hw
*hw
, u16 seid
,
2525 struct i40e_aqc_remove_macvlan_element_data
*mv_list
,
2526 u16 count
, struct i40e_asq_cmd_details
*cmd_details
)
2528 struct i40e_aq_desc desc
;
2529 struct i40e_aqc_macvlan
*cmd
=
2530 (struct i40e_aqc_macvlan
*)&desc
.params
.raw
;
2534 if (count
== 0 || !mv_list
|| !hw
)
2535 return I40E_ERR_PARAM
;
2537 buf_size
= count
* sizeof(*mv_list
);
2539 /* prep the rest of the request */
2540 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_remove_macvlan
);
2541 cmd
->num_addresses
= cpu_to_le16(count
);
2542 cmd
->seid
[0] = cpu_to_le16(I40E_AQC_MACVLAN_CMD_SEID_VALID
| seid
);
2546 desc
.flags
|= cpu_to_le16((u16
)(I40E_AQ_FLAG_BUF
| I40E_AQ_FLAG_RD
));
2547 if (buf_size
> I40E_AQ_LARGE_BUF
)
2548 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_LB
);
2550 status
= i40e_asq_send_command(hw
, &desc
, mv_list
, buf_size
,
2557 * i40e_mirrorrule_op - Internal helper function to add/delete mirror rule
2558 * @hw: pointer to the hw struct
2559 * @opcode: AQ opcode for add or delete mirror rule
2560 * @sw_seid: Switch SEID (to which rule refers)
2561 * @rule_type: Rule Type (ingress/egress/VLAN)
2562 * @id: Destination VSI SEID or Rule ID
2563 * @count: length of the list
2564 * @mr_list: list of mirrored VSI SEIDs or VLAN IDs
2565 * @cmd_details: pointer to command details structure or NULL
2566 * @rule_id: Rule ID returned from FW
2567 * @rule_used: Number of rules used in internal switch
2568 * @rule_free: Number of rules free in internal switch
2570 * Add/Delete a mirror rule to a specific switch. Mirror rules are supported for
2571 * VEBs/VEPA elements only
2573 static i40e_status
i40e_mirrorrule_op(struct i40e_hw
*hw
,
2574 u16 opcode
, u16 sw_seid
, u16 rule_type
, u16 id
,
2575 u16 count
, __le16
*mr_list
,
2576 struct i40e_asq_cmd_details
*cmd_details
,
2577 u16
*rule_id
, u16
*rules_used
, u16
*rules_free
)
2579 struct i40e_aq_desc desc
;
2580 struct i40e_aqc_add_delete_mirror_rule
*cmd
=
2581 (struct i40e_aqc_add_delete_mirror_rule
*)&desc
.params
.raw
;
2582 struct i40e_aqc_add_delete_mirror_rule_completion
*resp
=
2583 (struct i40e_aqc_add_delete_mirror_rule_completion
*)&desc
.params
.raw
;
2587 buf_size
= count
* sizeof(*mr_list
);
2589 /* prep the rest of the request */
2590 i40e_fill_default_direct_cmd_desc(&desc
, opcode
);
2591 cmd
->seid
= cpu_to_le16(sw_seid
);
2592 cmd
->rule_type
= cpu_to_le16(rule_type
&
2593 I40E_AQC_MIRROR_RULE_TYPE_MASK
);
2594 cmd
->num_entries
= cpu_to_le16(count
);
2595 /* Dest VSI for add, rule_id for delete */
2596 cmd
->destination
= cpu_to_le16(id
);
2598 desc
.flags
|= cpu_to_le16((u16
)(I40E_AQ_FLAG_BUF
|
2600 if (buf_size
> I40E_AQ_LARGE_BUF
)
2601 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_LB
);
2604 status
= i40e_asq_send_command(hw
, &desc
, mr_list
, buf_size
,
2607 hw
->aq
.asq_last_status
== I40E_AQ_RC_ENOSPC
) {
2609 *rule_id
= le16_to_cpu(resp
->rule_id
);
2611 *rules_used
= le16_to_cpu(resp
->mirror_rules_used
);
2613 *rules_free
= le16_to_cpu(resp
->mirror_rules_free
);
2619 * i40e_aq_add_mirrorrule - add a mirror rule
2620 * @hw: pointer to the hw struct
2621 * @sw_seid: Switch SEID (to which rule refers)
2622 * @rule_type: Rule Type (ingress/egress/VLAN)
2623 * @dest_vsi: SEID of VSI to which packets will be mirrored
2624 * @count: length of the list
2625 * @mr_list: list of mirrored VSI SEIDs or VLAN IDs
2626 * @cmd_details: pointer to command details structure or NULL
2627 * @rule_id: Rule ID returned from FW
2628 * @rule_used: Number of rules used in internal switch
2629 * @rule_free: Number of rules free in internal switch
2631 * Add mirror rule. Mirror rules are supported for VEBs or VEPA elements only
2633 i40e_status
i40e_aq_add_mirrorrule(struct i40e_hw
*hw
, u16 sw_seid
,
2634 u16 rule_type
, u16 dest_vsi
, u16 count
, __le16
*mr_list
,
2635 struct i40e_asq_cmd_details
*cmd_details
,
2636 u16
*rule_id
, u16
*rules_used
, u16
*rules_free
)
2638 if (!(rule_type
== I40E_AQC_MIRROR_RULE_TYPE_ALL_INGRESS
||
2639 rule_type
== I40E_AQC_MIRROR_RULE_TYPE_ALL_EGRESS
)) {
2640 if (count
== 0 || !mr_list
)
2641 return I40E_ERR_PARAM
;
2644 return i40e_mirrorrule_op(hw
, i40e_aqc_opc_add_mirror_rule
, sw_seid
,
2645 rule_type
, dest_vsi
, count
, mr_list
,
2646 cmd_details
, rule_id
, rules_used
, rules_free
);
2650 * i40e_aq_delete_mirrorrule - delete a mirror rule
2651 * @hw: pointer to the hw struct
2652 * @sw_seid: Switch SEID (to which rule refers)
2653 * @rule_type: Rule Type (ingress/egress/VLAN)
2654 * @count: length of the list
2655 * @rule_id: Rule ID that is returned in the receive desc as part of
2657 * @mr_list: list of mirrored VLAN IDs to be removed
2658 * @cmd_details: pointer to command details structure or NULL
2659 * @rule_used: Number of rules used in internal switch
2660 * @rule_free: Number of rules free in internal switch
2662 * Delete a mirror rule. Mirror rules are supported for VEBs/VEPA elements only
2664 i40e_status
i40e_aq_delete_mirrorrule(struct i40e_hw
*hw
, u16 sw_seid
,
2665 u16 rule_type
, u16 rule_id
, u16 count
, __le16
*mr_list
,
2666 struct i40e_asq_cmd_details
*cmd_details
,
2667 u16
*rules_used
, u16
*rules_free
)
2669 /* Rule ID has to be valid except rule_type: INGRESS VLAN mirroring */
2670 if (rule_type
!= I40E_AQC_MIRROR_RULE_TYPE_VLAN
) {
2672 return I40E_ERR_PARAM
;
2674 /* count and mr_list shall be valid for rule_type INGRESS VLAN
2675 * mirroring. For other rule_type, count and rule_type should
2678 if (count
== 0 || !mr_list
)
2679 return I40E_ERR_PARAM
;
2682 return i40e_mirrorrule_op(hw
, i40e_aqc_opc_delete_mirror_rule
, sw_seid
,
2683 rule_type
, rule_id
, count
, mr_list
,
2684 cmd_details
, NULL
, rules_used
, rules_free
);
2688 * i40e_aq_send_msg_to_vf
2689 * @hw: pointer to the hardware structure
2690 * @vfid: VF id to send msg
2691 * @v_opcode: opcodes for VF-PF communication
2692 * @v_retval: return error code
2693 * @msg: pointer to the msg buffer
2694 * @msglen: msg length
2695 * @cmd_details: pointer to command details
2699 i40e_status
i40e_aq_send_msg_to_vf(struct i40e_hw
*hw
, u16 vfid
,
2700 u32 v_opcode
, u32 v_retval
, u8
*msg
, u16 msglen
,
2701 struct i40e_asq_cmd_details
*cmd_details
)
2703 struct i40e_aq_desc desc
;
2704 struct i40e_aqc_pf_vf_message
*cmd
=
2705 (struct i40e_aqc_pf_vf_message
*)&desc
.params
.raw
;
2708 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_send_msg_to_vf
);
2709 cmd
->id
= cpu_to_le32(vfid
);
2710 desc
.cookie_high
= cpu_to_le32(v_opcode
);
2711 desc
.cookie_low
= cpu_to_le32(v_retval
);
2712 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_SI
);
2714 desc
.flags
|= cpu_to_le16((u16
)(I40E_AQ_FLAG_BUF
|
2716 if (msglen
> I40E_AQ_LARGE_BUF
)
2717 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_LB
);
2718 desc
.datalen
= cpu_to_le16(msglen
);
2720 status
= i40e_asq_send_command(hw
, &desc
, msg
, msglen
, cmd_details
);
2726 * i40e_aq_debug_read_register
2727 * @hw: pointer to the hw struct
2728 * @reg_addr: register address
2729 * @reg_val: register value
2730 * @cmd_details: pointer to command details structure or NULL
2732 * Read the register using the admin queue commands
2734 i40e_status
i40e_aq_debug_read_register(struct i40e_hw
*hw
,
2735 u32 reg_addr
, u64
*reg_val
,
2736 struct i40e_asq_cmd_details
*cmd_details
)
2738 struct i40e_aq_desc desc
;
2739 struct i40e_aqc_debug_reg_read_write
*cmd_resp
=
2740 (struct i40e_aqc_debug_reg_read_write
*)&desc
.params
.raw
;
2743 if (reg_val
== NULL
)
2744 return I40E_ERR_PARAM
;
2746 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_debug_read_reg
);
2748 cmd_resp
->address
= cpu_to_le32(reg_addr
);
2750 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
2753 *reg_val
= ((u64
)le32_to_cpu(cmd_resp
->value_high
) << 32) |
2754 (u64
)le32_to_cpu(cmd_resp
->value_low
);
2761 * i40e_aq_debug_write_register
2762 * @hw: pointer to the hw struct
2763 * @reg_addr: register address
2764 * @reg_val: register value
2765 * @cmd_details: pointer to command details structure or NULL
2767 * Write to a register using the admin queue commands
2769 i40e_status
i40e_aq_debug_write_register(struct i40e_hw
*hw
,
2770 u32 reg_addr
, u64 reg_val
,
2771 struct i40e_asq_cmd_details
*cmd_details
)
2773 struct i40e_aq_desc desc
;
2774 struct i40e_aqc_debug_reg_read_write
*cmd
=
2775 (struct i40e_aqc_debug_reg_read_write
*)&desc
.params
.raw
;
2778 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_debug_write_reg
);
2780 cmd
->address
= cpu_to_le32(reg_addr
);
2781 cmd
->value_high
= cpu_to_le32((u32
)(reg_val
>> 32));
2782 cmd
->value_low
= cpu_to_le32((u32
)(reg_val
& 0xFFFFFFFF));
2784 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
2790 * i40e_aq_set_hmc_resource_profile
2791 * @hw: pointer to the hw struct
2792 * @profile: type of profile the HMC is to be set as
2793 * @pe_vf_enabled_count: the number of PE enabled VFs the system has
2794 * @cmd_details: pointer to command details structure or NULL
2796 * set the HMC profile of the device.
2798 i40e_status
i40e_aq_set_hmc_resource_profile(struct i40e_hw
*hw
,
2799 enum i40e_aq_hmc_profile profile
,
2800 u8 pe_vf_enabled_count
,
2801 struct i40e_asq_cmd_details
*cmd_details
)
2803 struct i40e_aq_desc desc
;
2804 struct i40e_aq_get_set_hmc_resource_profile
*cmd
=
2805 (struct i40e_aq_get_set_hmc_resource_profile
*)&desc
.params
.raw
;
2808 i40e_fill_default_direct_cmd_desc(&desc
,
2809 i40e_aqc_opc_set_hmc_resource_profile
);
2811 cmd
->pm_profile
= (u8
)profile
;
2812 cmd
->pe_vf_enabled
= pe_vf_enabled_count
;
2814 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
2820 * i40e_aq_request_resource
2821 * @hw: pointer to the hw struct
2822 * @resource: resource id
2823 * @access: access type
2824 * @sdp_number: resource number
2825 * @timeout: the maximum time in ms that the driver may hold the resource
2826 * @cmd_details: pointer to command details structure or NULL
2828 * requests common resource using the admin queue commands
2830 i40e_status
i40e_aq_request_resource(struct i40e_hw
*hw
,
2831 enum i40e_aq_resources_ids resource
,
2832 enum i40e_aq_resource_access_type access
,
2833 u8 sdp_number
, u64
*timeout
,
2834 struct i40e_asq_cmd_details
*cmd_details
)
2836 struct i40e_aq_desc desc
;
2837 struct i40e_aqc_request_resource
*cmd_resp
=
2838 (struct i40e_aqc_request_resource
*)&desc
.params
.raw
;
2841 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_request_resource
);
2843 cmd_resp
->resource_id
= cpu_to_le16(resource
);
2844 cmd_resp
->access_type
= cpu_to_le16(access
);
2845 cmd_resp
->resource_number
= cpu_to_le32(sdp_number
);
2847 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
2848 /* The completion specifies the maximum time in ms that the driver
2849 * may hold the resource in the Timeout field.
2850 * If the resource is held by someone else, the command completes with
2851 * busy return value and the timeout field indicates the maximum time
2852 * the current owner of the resource has to free it.
2854 if (!status
|| hw
->aq
.asq_last_status
== I40E_AQ_RC_EBUSY
)
2855 *timeout
= le32_to_cpu(cmd_resp
->timeout
);
2861 * i40e_aq_release_resource
2862 * @hw: pointer to the hw struct
2863 * @resource: resource id
2864 * @sdp_number: resource number
2865 * @cmd_details: pointer to command details structure or NULL
2867 * release common resource using the admin queue commands
2869 i40e_status
i40e_aq_release_resource(struct i40e_hw
*hw
,
2870 enum i40e_aq_resources_ids resource
,
2872 struct i40e_asq_cmd_details
*cmd_details
)
2874 struct i40e_aq_desc desc
;
2875 struct i40e_aqc_request_resource
*cmd
=
2876 (struct i40e_aqc_request_resource
*)&desc
.params
.raw
;
2879 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_release_resource
);
2881 cmd
->resource_id
= cpu_to_le16(resource
);
2882 cmd
->resource_number
= cpu_to_le32(sdp_number
);
2884 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
2891 * @hw: pointer to the hw struct
2892 * @module_pointer: module pointer location in words from the NVM beginning
2893 * @offset: byte offset from the module beginning
2894 * @length: length of the section to be read (in bytes from the offset)
2895 * @data: command buffer (size [bytes] = length)
2896 * @last_command: tells if this is the last command in a series
2897 * @cmd_details: pointer to command details structure or NULL
2899 * Read the NVM using the admin queue commands
2901 i40e_status
i40e_aq_read_nvm(struct i40e_hw
*hw
, u8 module_pointer
,
2902 u32 offset
, u16 length
, void *data
,
2904 struct i40e_asq_cmd_details
*cmd_details
)
2906 struct i40e_aq_desc desc
;
2907 struct i40e_aqc_nvm_update
*cmd
=
2908 (struct i40e_aqc_nvm_update
*)&desc
.params
.raw
;
2911 /* In offset the highest byte must be zeroed. */
2912 if (offset
& 0xFF000000) {
2913 status
= I40E_ERR_PARAM
;
2914 goto i40e_aq_read_nvm_exit
;
2917 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_nvm_read
);
2919 /* If this is the last command in a series, set the proper flag. */
2921 cmd
->command_flags
|= I40E_AQ_NVM_LAST_CMD
;
2922 cmd
->module_pointer
= module_pointer
;
2923 cmd
->offset
= cpu_to_le32(offset
);
2924 cmd
->length
= cpu_to_le16(length
);
2926 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_BUF
);
2927 if (length
> I40E_AQ_LARGE_BUF
)
2928 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_LB
);
2930 status
= i40e_asq_send_command(hw
, &desc
, data
, length
, cmd_details
);
2932 i40e_aq_read_nvm_exit
:
2938 * @hw: pointer to the hw struct
2939 * @module_pointer: module pointer location in words from the NVM beginning
2940 * @offset: offset in the module (expressed in 4 KB from module's beginning)
2941 * @length: length of the section to be erased (expressed in 4 KB)
2942 * @last_command: tells if this is the last command in a series
2943 * @cmd_details: pointer to command details structure or NULL
2945 * Erase the NVM sector using the admin queue commands
2947 i40e_status
i40e_aq_erase_nvm(struct i40e_hw
*hw
, u8 module_pointer
,
2948 u32 offset
, u16 length
, bool last_command
,
2949 struct i40e_asq_cmd_details
*cmd_details
)
2951 struct i40e_aq_desc desc
;
2952 struct i40e_aqc_nvm_update
*cmd
=
2953 (struct i40e_aqc_nvm_update
*)&desc
.params
.raw
;
2956 /* In offset the highest byte must be zeroed. */
2957 if (offset
& 0xFF000000) {
2958 status
= I40E_ERR_PARAM
;
2959 goto i40e_aq_erase_nvm_exit
;
2962 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_nvm_erase
);
2964 /* If this is the last command in a series, set the proper flag. */
2966 cmd
->command_flags
|= I40E_AQ_NVM_LAST_CMD
;
2967 cmd
->module_pointer
= module_pointer
;
2968 cmd
->offset
= cpu_to_le32(offset
);
2969 cmd
->length
= cpu_to_le16(length
);
2971 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
2973 i40e_aq_erase_nvm_exit
:
2978 * i40e_parse_discover_capabilities
2979 * @hw: pointer to the hw struct
2980 * @buff: pointer to a buffer containing device/function capability records
2981 * @cap_count: number of capability records in the list
2982 * @list_type_opc: type of capabilities list to parse
2984 * Parse the device/function capabilities list.
2986 static void i40e_parse_discover_capabilities(struct i40e_hw
*hw
, void *buff
,
2988 enum i40e_admin_queue_opc list_type_opc
)
2990 struct i40e_aqc_list_capabilities_element_resp
*cap
;
2991 u32 valid_functions
, num_functions
;
2992 u32 number
, logical_id
, phys_id
;
2993 struct i40e_hw_capabilities
*p
;
2998 cap
= (struct i40e_aqc_list_capabilities_element_resp
*) buff
;
3000 if (list_type_opc
== i40e_aqc_opc_list_dev_capabilities
)
3002 else if (list_type_opc
== i40e_aqc_opc_list_func_capabilities
)
3007 for (i
= 0; i
< cap_count
; i
++, cap
++) {
3008 id
= le16_to_cpu(cap
->id
);
3009 number
= le32_to_cpu(cap
->number
);
3010 logical_id
= le32_to_cpu(cap
->logical_id
);
3011 phys_id
= le32_to_cpu(cap
->phys_id
);
3012 major_rev
= cap
->major_rev
;
3015 case I40E_AQ_CAP_ID_SWITCH_MODE
:
3016 p
->switch_mode
= number
;
3018 case I40E_AQ_CAP_ID_MNG_MODE
:
3019 p
->management_mode
= number
;
3021 case I40E_AQ_CAP_ID_NPAR_ACTIVE
:
3022 p
->npar_enable
= number
;
3024 case I40E_AQ_CAP_ID_OS2BMC_CAP
:
3027 case I40E_AQ_CAP_ID_FUNCTIONS_VALID
:
3028 p
->valid_functions
= number
;
3030 case I40E_AQ_CAP_ID_SRIOV
:
3032 p
->sr_iov_1_1
= true;
3034 case I40E_AQ_CAP_ID_VF
:
3035 p
->num_vfs
= number
;
3036 p
->vf_base_id
= logical_id
;
3038 case I40E_AQ_CAP_ID_VMDQ
:
3042 case I40E_AQ_CAP_ID_8021QBG
:
3044 p
->evb_802_1_qbg
= true;
3046 case I40E_AQ_CAP_ID_8021QBR
:
3048 p
->evb_802_1_qbh
= true;
3050 case I40E_AQ_CAP_ID_VSI
:
3051 p
->num_vsis
= number
;
3053 case I40E_AQ_CAP_ID_DCB
:
3056 p
->enabled_tcmap
= logical_id
;
3060 case I40E_AQ_CAP_ID_FCOE
:
3064 case I40E_AQ_CAP_ID_ISCSI
:
3068 case I40E_AQ_CAP_ID_RSS
:
3070 p
->rss_table_size
= number
;
3071 p
->rss_table_entry_width
= logical_id
;
3073 case I40E_AQ_CAP_ID_RXQ
:
3074 p
->num_rx_qp
= number
;
3075 p
->base_queue
= phys_id
;
3077 case I40E_AQ_CAP_ID_TXQ
:
3078 p
->num_tx_qp
= number
;
3079 p
->base_queue
= phys_id
;
3081 case I40E_AQ_CAP_ID_MSIX
:
3082 p
->num_msix_vectors
= number
;
3083 i40e_debug(hw
, I40E_DEBUG_INIT
,
3084 "HW Capability: MSIX vector count = %d\n",
3085 p
->num_msix_vectors
);
3087 case I40E_AQ_CAP_ID_VF_MSIX
:
3088 p
->num_msix_vectors_vf
= number
;
3090 case I40E_AQ_CAP_ID_FLEX10
:
3091 if (major_rev
== 1) {
3093 p
->flex10_enable
= true;
3094 p
->flex10_capable
= true;
3097 /* Capability revision >= 2 */
3099 p
->flex10_enable
= true;
3101 p
->flex10_capable
= true;
3103 p
->flex10_mode
= logical_id
;
3104 p
->flex10_status
= phys_id
;
3106 case I40E_AQ_CAP_ID_CEM
:
3110 case I40E_AQ_CAP_ID_IWARP
:
3114 case I40E_AQ_CAP_ID_LED
:
3115 if (phys_id
< I40E_HW_CAP_MAX_GPIO
)
3116 p
->led
[phys_id
] = true;
3118 case I40E_AQ_CAP_ID_SDP
:
3119 if (phys_id
< I40E_HW_CAP_MAX_GPIO
)
3120 p
->sdp
[phys_id
] = true;
3122 case I40E_AQ_CAP_ID_MDIO
:
3124 p
->mdio_port_num
= phys_id
;
3125 p
->mdio_port_mode
= logical_id
;
3128 case I40E_AQ_CAP_ID_1588
:
3130 p
->ieee_1588
= true;
3132 case I40E_AQ_CAP_ID_FLOW_DIRECTOR
:
3134 p
->fd_filters_guaranteed
= number
;
3135 p
->fd_filters_best_effort
= logical_id
;
3137 case I40E_AQ_CAP_ID_WSR_PROT
:
3138 p
->wr_csr_prot
= (u64
)number
;
3139 p
->wr_csr_prot
|= (u64
)logical_id
<< 32;
3147 i40e_debug(hw
, I40E_DEBUG_ALL
, "device is FCoE capable\n");
3149 /* Software override ensuring FCoE is disabled if npar or mfp
3150 * mode because it is not supported in these modes.
3152 if (p
->npar_enable
|| p
->flex10_enable
)
3155 /* count the enabled ports (aka the "not disabled" ports) */
3157 for (i
= 0; i
< 4; i
++) {
3158 u32 port_cfg_reg
= I40E_PRTGEN_CNF
+ (4 * i
);
3161 /* use AQ read to get the physical register offset instead
3162 * of the port relative offset
3164 i40e_aq_debug_read_register(hw
, port_cfg_reg
, &port_cfg
, NULL
);
3165 if (!(port_cfg
& I40E_PRTGEN_CNF_PORT_DIS_MASK
))
3169 valid_functions
= p
->valid_functions
;
3171 while (valid_functions
) {
3172 if (valid_functions
& 1)
3174 valid_functions
>>= 1;
3177 /* partition id is 1-based, and functions are evenly spread
3178 * across the ports as partitions
3180 hw
->partition_id
= (hw
->pf_id
/ hw
->num_ports
) + 1;
3181 hw
->num_partitions
= num_functions
/ hw
->num_ports
;
3183 /* additional HW specific goodies that might
3184 * someday be HW version specific
3186 p
->rx_buf_chain_len
= I40E_MAX_CHAINED_RX_BUFFERS
;
3190 * i40e_aq_discover_capabilities
3191 * @hw: pointer to the hw struct
3192 * @buff: a virtual buffer to hold the capabilities
3193 * @buff_size: Size of the virtual buffer
3194 * @data_size: Size of the returned data, or buff size needed if AQ err==ENOMEM
3195 * @list_type_opc: capabilities type to discover - pass in the command opcode
3196 * @cmd_details: pointer to command details structure or NULL
3198 * Get the device capabilities descriptions from the firmware
3200 i40e_status
i40e_aq_discover_capabilities(struct i40e_hw
*hw
,
3201 void *buff
, u16 buff_size
, u16
*data_size
,
3202 enum i40e_admin_queue_opc list_type_opc
,
3203 struct i40e_asq_cmd_details
*cmd_details
)
3205 struct i40e_aqc_list_capabilites
*cmd
;
3206 struct i40e_aq_desc desc
;
3207 i40e_status status
= 0;
3209 cmd
= (struct i40e_aqc_list_capabilites
*)&desc
.params
.raw
;
3211 if (list_type_opc
!= i40e_aqc_opc_list_func_capabilities
&&
3212 list_type_opc
!= i40e_aqc_opc_list_dev_capabilities
) {
3213 status
= I40E_ERR_PARAM
;
3217 i40e_fill_default_direct_cmd_desc(&desc
, list_type_opc
);
3219 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_BUF
);
3220 if (buff_size
> I40E_AQ_LARGE_BUF
)
3221 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_LB
);
3223 status
= i40e_asq_send_command(hw
, &desc
, buff
, buff_size
, cmd_details
);
3224 *data_size
= le16_to_cpu(desc
.datalen
);
3229 i40e_parse_discover_capabilities(hw
, buff
, le32_to_cpu(cmd
->count
),
3237 * i40e_aq_update_nvm
3238 * @hw: pointer to the hw struct
3239 * @module_pointer: module pointer location in words from the NVM beginning
3240 * @offset: byte offset from the module beginning
3241 * @length: length of the section to be written (in bytes from the offset)
3242 * @data: command buffer (size [bytes] = length)
3243 * @last_command: tells if this is the last command in a series
3244 * @cmd_details: pointer to command details structure or NULL
3246 * Update the NVM using the admin queue commands
3248 i40e_status
i40e_aq_update_nvm(struct i40e_hw
*hw
, u8 module_pointer
,
3249 u32 offset
, u16 length
, void *data
,
3251 struct i40e_asq_cmd_details
*cmd_details
)
3253 struct i40e_aq_desc desc
;
3254 struct i40e_aqc_nvm_update
*cmd
=
3255 (struct i40e_aqc_nvm_update
*)&desc
.params
.raw
;
3258 /* In offset the highest byte must be zeroed. */
3259 if (offset
& 0xFF000000) {
3260 status
= I40E_ERR_PARAM
;
3261 goto i40e_aq_update_nvm_exit
;
3264 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_nvm_update
);
3266 /* If this is the last command in a series, set the proper flag. */
3268 cmd
->command_flags
|= I40E_AQ_NVM_LAST_CMD
;
3269 cmd
->module_pointer
= module_pointer
;
3270 cmd
->offset
= cpu_to_le32(offset
);
3271 cmd
->length
= cpu_to_le16(length
);
3273 desc
.flags
|= cpu_to_le16((u16
)(I40E_AQ_FLAG_BUF
| I40E_AQ_FLAG_RD
));
3274 if (length
> I40E_AQ_LARGE_BUF
)
3275 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_LB
);
3277 status
= i40e_asq_send_command(hw
, &desc
, data
, length
, cmd_details
);
3279 i40e_aq_update_nvm_exit
:
3284 * i40e_aq_get_lldp_mib
3285 * @hw: pointer to the hw struct
3286 * @bridge_type: type of bridge requested
3287 * @mib_type: Local, Remote or both Local and Remote MIBs
3288 * @buff: pointer to a user supplied buffer to store the MIB block
3289 * @buff_size: size of the buffer (in bytes)
3290 * @local_len : length of the returned Local LLDP MIB
3291 * @remote_len: length of the returned Remote LLDP MIB
3292 * @cmd_details: pointer to command details structure or NULL
3294 * Requests the complete LLDP MIB (entire packet).
3296 i40e_status
i40e_aq_get_lldp_mib(struct i40e_hw
*hw
, u8 bridge_type
,
3297 u8 mib_type
, void *buff
, u16 buff_size
,
3298 u16
*local_len
, u16
*remote_len
,
3299 struct i40e_asq_cmd_details
*cmd_details
)
3301 struct i40e_aq_desc desc
;
3302 struct i40e_aqc_lldp_get_mib
*cmd
=
3303 (struct i40e_aqc_lldp_get_mib
*)&desc
.params
.raw
;
3304 struct i40e_aqc_lldp_get_mib
*resp
=
3305 (struct i40e_aqc_lldp_get_mib
*)&desc
.params
.raw
;
3308 if (buff_size
== 0 || !buff
)
3309 return I40E_ERR_PARAM
;
3311 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_lldp_get_mib
);
3312 /* Indirect Command */
3313 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_BUF
);
3315 cmd
->type
= mib_type
& I40E_AQ_LLDP_MIB_TYPE_MASK
;
3316 cmd
->type
|= ((bridge_type
<< I40E_AQ_LLDP_BRIDGE_TYPE_SHIFT
) &
3317 I40E_AQ_LLDP_BRIDGE_TYPE_MASK
);
3319 desc
.datalen
= cpu_to_le16(buff_size
);
3321 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_BUF
);
3322 if (buff_size
> I40E_AQ_LARGE_BUF
)
3323 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_LB
);
3325 status
= i40e_asq_send_command(hw
, &desc
, buff
, buff_size
, cmd_details
);
3327 if (local_len
!= NULL
)
3328 *local_len
= le16_to_cpu(resp
->local_len
);
3329 if (remote_len
!= NULL
)
3330 *remote_len
= le16_to_cpu(resp
->remote_len
);
3337 * i40e_aq_cfg_lldp_mib_change_event
3338 * @hw: pointer to the hw struct
3339 * @enable_update: Enable or Disable event posting
3340 * @cmd_details: pointer to command details structure or NULL
3342 * Enable or Disable posting of an event on ARQ when LLDP MIB
3343 * associated with the interface changes
3345 i40e_status
i40e_aq_cfg_lldp_mib_change_event(struct i40e_hw
*hw
,
3347 struct i40e_asq_cmd_details
*cmd_details
)
3349 struct i40e_aq_desc desc
;
3350 struct i40e_aqc_lldp_update_mib
*cmd
=
3351 (struct i40e_aqc_lldp_update_mib
*)&desc
.params
.raw
;
3354 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_lldp_update_mib
);
3357 cmd
->command
|= I40E_AQ_LLDP_MIB_UPDATE_DISABLE
;
3359 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
3366 * @hw: pointer to the hw struct
3367 * @shutdown_agent: True if LLDP Agent needs to be Shutdown
3368 * @cmd_details: pointer to command details structure or NULL
3370 * Stop or Shutdown the embedded LLDP Agent
3372 i40e_status
i40e_aq_stop_lldp(struct i40e_hw
*hw
, bool shutdown_agent
,
3373 struct i40e_asq_cmd_details
*cmd_details
)
3375 struct i40e_aq_desc desc
;
3376 struct i40e_aqc_lldp_stop
*cmd
=
3377 (struct i40e_aqc_lldp_stop
*)&desc
.params
.raw
;
3380 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_lldp_stop
);
3383 cmd
->command
|= I40E_AQ_LLDP_AGENT_SHUTDOWN
;
3385 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
3391 * i40e_aq_start_lldp
3392 * @hw: pointer to the hw struct
3393 * @cmd_details: pointer to command details structure or NULL
3395 * Start the embedded LLDP Agent on all ports.
3397 i40e_status
i40e_aq_start_lldp(struct i40e_hw
*hw
,
3398 struct i40e_asq_cmd_details
*cmd_details
)
3400 struct i40e_aq_desc desc
;
3401 struct i40e_aqc_lldp_start
*cmd
=
3402 (struct i40e_aqc_lldp_start
*)&desc
.params
.raw
;
3405 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_lldp_start
);
3407 cmd
->command
= I40E_AQ_LLDP_AGENT_START
;
3409 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
3415 * i40e_aq_get_cee_dcb_config
3416 * @hw: pointer to the hw struct
3417 * @buff: response buffer that stores CEE operational configuration
3418 * @buff_size: size of the buffer passed
3419 * @cmd_details: pointer to command details structure or NULL
3421 * Get CEE DCBX mode operational configuration from firmware
3423 i40e_status
i40e_aq_get_cee_dcb_config(struct i40e_hw
*hw
,
3424 void *buff
, u16 buff_size
,
3425 struct i40e_asq_cmd_details
*cmd_details
)
3427 struct i40e_aq_desc desc
;
3430 if (buff_size
== 0 || !buff
)
3431 return I40E_ERR_PARAM
;
3433 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_get_cee_dcb_cfg
);
3435 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_BUF
);
3436 status
= i40e_asq_send_command(hw
, &desc
, (void *)buff
, buff_size
,
3443 * i40e_aq_add_udp_tunnel
3444 * @hw: pointer to the hw struct
3445 * @udp_port: the UDP port to add
3446 * @header_len: length of the tunneling header length in DWords
3447 * @protocol_index: protocol index type
3448 * @filter_index: pointer to filter index
3449 * @cmd_details: pointer to command details structure or NULL
3451 i40e_status
i40e_aq_add_udp_tunnel(struct i40e_hw
*hw
,
3452 u16 udp_port
, u8 protocol_index
,
3454 struct i40e_asq_cmd_details
*cmd_details
)
3456 struct i40e_aq_desc desc
;
3457 struct i40e_aqc_add_udp_tunnel
*cmd
=
3458 (struct i40e_aqc_add_udp_tunnel
*)&desc
.params
.raw
;
3459 struct i40e_aqc_del_udp_tunnel_completion
*resp
=
3460 (struct i40e_aqc_del_udp_tunnel_completion
*)&desc
.params
.raw
;
3463 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_add_udp_tunnel
);
3465 cmd
->udp_port
= cpu_to_le16(udp_port
);
3466 cmd
->protocol_type
= protocol_index
;
3468 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
3470 if (!status
&& filter_index
)
3471 *filter_index
= resp
->index
;
3477 * i40e_aq_del_udp_tunnel
3478 * @hw: pointer to the hw struct
3479 * @index: filter index
3480 * @cmd_details: pointer to command details structure or NULL
3482 i40e_status
i40e_aq_del_udp_tunnel(struct i40e_hw
*hw
, u8 index
,
3483 struct i40e_asq_cmd_details
*cmd_details
)
3485 struct i40e_aq_desc desc
;
3486 struct i40e_aqc_remove_udp_tunnel
*cmd
=
3487 (struct i40e_aqc_remove_udp_tunnel
*)&desc
.params
.raw
;
3490 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_del_udp_tunnel
);
3494 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
3500 * i40e_aq_delete_element - Delete switch element
3501 * @hw: pointer to the hw struct
3502 * @seid: the SEID to delete from the switch
3503 * @cmd_details: pointer to command details structure or NULL
3505 * This deletes a switch element from the switch.
3507 i40e_status
i40e_aq_delete_element(struct i40e_hw
*hw
, u16 seid
,
3508 struct i40e_asq_cmd_details
*cmd_details
)
3510 struct i40e_aq_desc desc
;
3511 struct i40e_aqc_switch_seid
*cmd
=
3512 (struct i40e_aqc_switch_seid
*)&desc
.params
.raw
;
3516 return I40E_ERR_PARAM
;
3518 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_delete_element
);
3520 cmd
->seid
= cpu_to_le16(seid
);
3522 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
3528 * i40e_aq_dcb_updated - DCB Updated Command
3529 * @hw: pointer to the hw struct
3530 * @cmd_details: pointer to command details structure or NULL
3532 * EMP will return when the shared RPB settings have been
3533 * recomputed and modified. The retval field in the descriptor
3534 * will be set to 0 when RPB is modified.
3536 i40e_status
i40e_aq_dcb_updated(struct i40e_hw
*hw
,
3537 struct i40e_asq_cmd_details
*cmd_details
)
3539 struct i40e_aq_desc desc
;
3542 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_dcb_updated
);
3544 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
3550 * i40e_aq_tx_sched_cmd - generic Tx scheduler AQ command handler
3551 * @hw: pointer to the hw struct
3552 * @seid: seid for the physical port/switching component/vsi
3553 * @buff: Indirect buffer to hold data parameters and response
3554 * @buff_size: Indirect buffer size
3555 * @opcode: Tx scheduler AQ command opcode
3556 * @cmd_details: pointer to command details structure or NULL
3558 * Generic command handler for Tx scheduler AQ commands
3560 static i40e_status
i40e_aq_tx_sched_cmd(struct i40e_hw
*hw
, u16 seid
,
3561 void *buff
, u16 buff_size
,
3562 enum i40e_admin_queue_opc opcode
,
3563 struct i40e_asq_cmd_details
*cmd_details
)
3565 struct i40e_aq_desc desc
;
3566 struct i40e_aqc_tx_sched_ind
*cmd
=
3567 (struct i40e_aqc_tx_sched_ind
*)&desc
.params
.raw
;
3569 bool cmd_param_flag
= false;
3572 case i40e_aqc_opc_configure_vsi_ets_sla_bw_limit
:
3573 case i40e_aqc_opc_configure_vsi_tc_bw
:
3574 case i40e_aqc_opc_enable_switching_comp_ets
:
3575 case i40e_aqc_opc_modify_switching_comp_ets
:
3576 case i40e_aqc_opc_disable_switching_comp_ets
:
3577 case i40e_aqc_opc_configure_switching_comp_ets_bw_limit
:
3578 case i40e_aqc_opc_configure_switching_comp_bw_config
:
3579 cmd_param_flag
= true;
3581 case i40e_aqc_opc_query_vsi_bw_config
:
3582 case i40e_aqc_opc_query_vsi_ets_sla_config
:
3583 case i40e_aqc_opc_query_switching_comp_ets_config
:
3584 case i40e_aqc_opc_query_port_ets_config
:
3585 case i40e_aqc_opc_query_switching_comp_bw_config
:
3586 cmd_param_flag
= false;
3589 return I40E_ERR_PARAM
;
3592 i40e_fill_default_direct_cmd_desc(&desc
, opcode
);
3594 /* Indirect command */
3595 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_BUF
);
3597 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_RD
);
3598 if (buff_size
> I40E_AQ_LARGE_BUF
)
3599 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_LB
);
3601 desc
.datalen
= cpu_to_le16(buff_size
);
3603 cmd
->vsi_seid
= cpu_to_le16(seid
);
3605 status
= i40e_asq_send_command(hw
, &desc
, buff
, buff_size
, cmd_details
);
3611 * i40e_aq_config_vsi_bw_limit - Configure VSI BW Limit
3612 * @hw: pointer to the hw struct
3614 * @credit: BW limit credits (0 = disabled)
3615 * @max_credit: Max BW limit credits
3616 * @cmd_details: pointer to command details structure or NULL
3618 i40e_status
i40e_aq_config_vsi_bw_limit(struct i40e_hw
*hw
,
3619 u16 seid
, u16 credit
, u8 max_credit
,
3620 struct i40e_asq_cmd_details
*cmd_details
)
3622 struct i40e_aq_desc desc
;
3623 struct i40e_aqc_configure_vsi_bw_limit
*cmd
=
3624 (struct i40e_aqc_configure_vsi_bw_limit
*)&desc
.params
.raw
;
3627 i40e_fill_default_direct_cmd_desc(&desc
,
3628 i40e_aqc_opc_configure_vsi_bw_limit
);
3630 cmd
->vsi_seid
= cpu_to_le16(seid
);
3631 cmd
->credit
= cpu_to_le16(credit
);
3632 cmd
->max_credit
= max_credit
;
3634 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
3640 * i40e_aq_config_vsi_tc_bw - Config VSI BW Allocation per TC
3641 * @hw: pointer to the hw struct
3643 * @bw_data: Buffer holding enabled TCs, relative TC BW limit/credits
3644 * @cmd_details: pointer to command details structure or NULL
3646 i40e_status
i40e_aq_config_vsi_tc_bw(struct i40e_hw
*hw
,
3648 struct i40e_aqc_configure_vsi_tc_bw_data
*bw_data
,
3649 struct i40e_asq_cmd_details
*cmd_details
)
3651 return i40e_aq_tx_sched_cmd(hw
, seid
, (void *)bw_data
, sizeof(*bw_data
),
3652 i40e_aqc_opc_configure_vsi_tc_bw
,
3657 * i40e_aq_config_switch_comp_ets - Enable/Disable/Modify ETS on the port
3658 * @hw: pointer to the hw struct
3659 * @seid: seid of the switching component connected to Physical Port
3660 * @ets_data: Buffer holding ETS parameters
3661 * @cmd_details: pointer to command details structure or NULL
3663 i40e_status
i40e_aq_config_switch_comp_ets(struct i40e_hw
*hw
,
3665 struct i40e_aqc_configure_switching_comp_ets_data
*ets_data
,
3666 enum i40e_admin_queue_opc opcode
,
3667 struct i40e_asq_cmd_details
*cmd_details
)
3669 return i40e_aq_tx_sched_cmd(hw
, seid
, (void *)ets_data
,
3670 sizeof(*ets_data
), opcode
, cmd_details
);
3674 * i40e_aq_config_switch_comp_bw_config - Config Switch comp BW Alloc per TC
3675 * @hw: pointer to the hw struct
3676 * @seid: seid of the switching component
3677 * @bw_data: Buffer holding enabled TCs, relative/absolute TC BW limit/credits
3678 * @cmd_details: pointer to command details structure or NULL
3680 i40e_status
i40e_aq_config_switch_comp_bw_config(struct i40e_hw
*hw
,
3682 struct i40e_aqc_configure_switching_comp_bw_config_data
*bw_data
,
3683 struct i40e_asq_cmd_details
*cmd_details
)
3685 return i40e_aq_tx_sched_cmd(hw
, seid
, (void *)bw_data
, sizeof(*bw_data
),
3686 i40e_aqc_opc_configure_switching_comp_bw_config
,
3691 * i40e_aq_query_vsi_bw_config - Query VSI BW configuration
3692 * @hw: pointer to the hw struct
3693 * @seid: seid of the VSI
3694 * @bw_data: Buffer to hold VSI BW configuration
3695 * @cmd_details: pointer to command details structure or NULL
3697 i40e_status
i40e_aq_query_vsi_bw_config(struct i40e_hw
*hw
,
3699 struct i40e_aqc_query_vsi_bw_config_resp
*bw_data
,
3700 struct i40e_asq_cmd_details
*cmd_details
)
3702 return i40e_aq_tx_sched_cmd(hw
, seid
, (void *)bw_data
, sizeof(*bw_data
),
3703 i40e_aqc_opc_query_vsi_bw_config
,
3708 * i40e_aq_query_vsi_ets_sla_config - Query VSI BW configuration per TC
3709 * @hw: pointer to the hw struct
3710 * @seid: seid of the VSI
3711 * @bw_data: Buffer to hold VSI BW configuration per TC
3712 * @cmd_details: pointer to command details structure or NULL
3714 i40e_status
i40e_aq_query_vsi_ets_sla_config(struct i40e_hw
*hw
,
3716 struct i40e_aqc_query_vsi_ets_sla_config_resp
*bw_data
,
3717 struct i40e_asq_cmd_details
*cmd_details
)
3719 return i40e_aq_tx_sched_cmd(hw
, seid
, (void *)bw_data
, sizeof(*bw_data
),
3720 i40e_aqc_opc_query_vsi_ets_sla_config
,
3725 * i40e_aq_query_switch_comp_ets_config - Query Switch comp BW config per TC
3726 * @hw: pointer to the hw struct
3727 * @seid: seid of the switching component
3728 * @bw_data: Buffer to hold switching component's per TC BW config
3729 * @cmd_details: pointer to command details structure or NULL
3731 i40e_status
i40e_aq_query_switch_comp_ets_config(struct i40e_hw
*hw
,
3733 struct i40e_aqc_query_switching_comp_ets_config_resp
*bw_data
,
3734 struct i40e_asq_cmd_details
*cmd_details
)
3736 return i40e_aq_tx_sched_cmd(hw
, seid
, (void *)bw_data
, sizeof(*bw_data
),
3737 i40e_aqc_opc_query_switching_comp_ets_config
,
3742 * i40e_aq_query_port_ets_config - Query Physical Port ETS configuration
3743 * @hw: pointer to the hw struct
3744 * @seid: seid of the VSI or switching component connected to Physical Port
3745 * @bw_data: Buffer to hold current ETS configuration for the Physical Port
3746 * @cmd_details: pointer to command details structure or NULL
3748 i40e_status
i40e_aq_query_port_ets_config(struct i40e_hw
*hw
,
3750 struct i40e_aqc_query_port_ets_config_resp
*bw_data
,
3751 struct i40e_asq_cmd_details
*cmd_details
)
3753 return i40e_aq_tx_sched_cmd(hw
, seid
, (void *)bw_data
, sizeof(*bw_data
),
3754 i40e_aqc_opc_query_port_ets_config
,
3759 * i40e_aq_query_switch_comp_bw_config - Query Switch comp BW configuration
3760 * @hw: pointer to the hw struct
3761 * @seid: seid of the switching component
3762 * @bw_data: Buffer to hold switching component's BW configuration
3763 * @cmd_details: pointer to command details structure or NULL
3765 i40e_status
i40e_aq_query_switch_comp_bw_config(struct i40e_hw
*hw
,
3767 struct i40e_aqc_query_switching_comp_bw_config_resp
*bw_data
,
3768 struct i40e_asq_cmd_details
*cmd_details
)
3770 return i40e_aq_tx_sched_cmd(hw
, seid
, (void *)bw_data
, sizeof(*bw_data
),
3771 i40e_aqc_opc_query_switching_comp_bw_config
,
3776 * i40e_validate_filter_settings
3777 * @hw: pointer to the hardware structure
3778 * @settings: Filter control settings
3780 * Check and validate the filter control settings passed.
3781 * The function checks for the valid filter/context sizes being
3782 * passed for FCoE and PE.
3784 * Returns 0 if the values passed are valid and within
3785 * range else returns an error.
3787 static i40e_status
i40e_validate_filter_settings(struct i40e_hw
*hw
,
3788 struct i40e_filter_control_settings
*settings
)
3790 u32 fcoe_cntx_size
, fcoe_filt_size
;
3791 u32 pe_cntx_size
, pe_filt_size
;
3795 /* Validate FCoE settings passed */
3796 switch (settings
->fcoe_filt_num
) {
3797 case I40E_HASH_FILTER_SIZE_1K
:
3798 case I40E_HASH_FILTER_SIZE_2K
:
3799 case I40E_HASH_FILTER_SIZE_4K
:
3800 case I40E_HASH_FILTER_SIZE_8K
:
3801 case I40E_HASH_FILTER_SIZE_16K
:
3802 case I40E_HASH_FILTER_SIZE_32K
:
3803 fcoe_filt_size
= I40E_HASH_FILTER_BASE_SIZE
;
3804 fcoe_filt_size
<<= (u32
)settings
->fcoe_filt_num
;
3807 return I40E_ERR_PARAM
;
3810 switch (settings
->fcoe_cntx_num
) {
3811 case I40E_DMA_CNTX_SIZE_512
:
3812 case I40E_DMA_CNTX_SIZE_1K
:
3813 case I40E_DMA_CNTX_SIZE_2K
:
3814 case I40E_DMA_CNTX_SIZE_4K
:
3815 fcoe_cntx_size
= I40E_DMA_CNTX_BASE_SIZE
;
3816 fcoe_cntx_size
<<= (u32
)settings
->fcoe_cntx_num
;
3819 return I40E_ERR_PARAM
;
3822 /* Validate PE settings passed */
3823 switch (settings
->pe_filt_num
) {
3824 case I40E_HASH_FILTER_SIZE_1K
:
3825 case I40E_HASH_FILTER_SIZE_2K
:
3826 case I40E_HASH_FILTER_SIZE_4K
:
3827 case I40E_HASH_FILTER_SIZE_8K
:
3828 case I40E_HASH_FILTER_SIZE_16K
:
3829 case I40E_HASH_FILTER_SIZE_32K
:
3830 case I40E_HASH_FILTER_SIZE_64K
:
3831 case I40E_HASH_FILTER_SIZE_128K
:
3832 case I40E_HASH_FILTER_SIZE_256K
:
3833 case I40E_HASH_FILTER_SIZE_512K
:
3834 case I40E_HASH_FILTER_SIZE_1M
:
3835 pe_filt_size
= I40E_HASH_FILTER_BASE_SIZE
;
3836 pe_filt_size
<<= (u32
)settings
->pe_filt_num
;
3839 return I40E_ERR_PARAM
;
3842 switch (settings
->pe_cntx_num
) {
3843 case I40E_DMA_CNTX_SIZE_512
:
3844 case I40E_DMA_CNTX_SIZE_1K
:
3845 case I40E_DMA_CNTX_SIZE_2K
:
3846 case I40E_DMA_CNTX_SIZE_4K
:
3847 case I40E_DMA_CNTX_SIZE_8K
:
3848 case I40E_DMA_CNTX_SIZE_16K
:
3849 case I40E_DMA_CNTX_SIZE_32K
:
3850 case I40E_DMA_CNTX_SIZE_64K
:
3851 case I40E_DMA_CNTX_SIZE_128K
:
3852 case I40E_DMA_CNTX_SIZE_256K
:
3853 pe_cntx_size
= I40E_DMA_CNTX_BASE_SIZE
;
3854 pe_cntx_size
<<= (u32
)settings
->pe_cntx_num
;
3857 return I40E_ERR_PARAM
;
3860 /* FCHSIZE + FCDSIZE should not be greater than PMFCOEFMAX */
3861 val
= rd32(hw
, I40E_GLHMC_FCOEFMAX
);
3862 fcoe_fmax
= (val
& I40E_GLHMC_FCOEFMAX_PMFCOEFMAX_MASK
)
3863 >> I40E_GLHMC_FCOEFMAX_PMFCOEFMAX_SHIFT
;
3864 if (fcoe_filt_size
+ fcoe_cntx_size
> fcoe_fmax
)
3865 return I40E_ERR_INVALID_SIZE
;
3871 * i40e_set_filter_control
3872 * @hw: pointer to the hardware structure
3873 * @settings: Filter control settings
3875 * Set the Queue Filters for PE/FCoE and enable filters required
3876 * for a single PF. It is expected that these settings are programmed
3877 * at the driver initialization time.
3879 i40e_status
i40e_set_filter_control(struct i40e_hw
*hw
,
3880 struct i40e_filter_control_settings
*settings
)
3882 i40e_status ret
= 0;
3883 u32 hash_lut_size
= 0;
3887 return I40E_ERR_PARAM
;
3889 /* Validate the input settings */
3890 ret
= i40e_validate_filter_settings(hw
, settings
);
3894 /* Read the PF Queue Filter control register */
3895 val
= i40e_read_rx_ctl(hw
, I40E_PFQF_CTL_0
);
3897 /* Program required PE hash buckets for the PF */
3898 val
&= ~I40E_PFQF_CTL_0_PEHSIZE_MASK
;
3899 val
|= ((u32
)settings
->pe_filt_num
<< I40E_PFQF_CTL_0_PEHSIZE_SHIFT
) &
3900 I40E_PFQF_CTL_0_PEHSIZE_MASK
;
3901 /* Program required PE contexts for the PF */
3902 val
&= ~I40E_PFQF_CTL_0_PEDSIZE_MASK
;
3903 val
|= ((u32
)settings
->pe_cntx_num
<< I40E_PFQF_CTL_0_PEDSIZE_SHIFT
) &
3904 I40E_PFQF_CTL_0_PEDSIZE_MASK
;
3906 /* Program required FCoE hash buckets for the PF */
3907 val
&= ~I40E_PFQF_CTL_0_PFFCHSIZE_MASK
;
3908 val
|= ((u32
)settings
->fcoe_filt_num
<<
3909 I40E_PFQF_CTL_0_PFFCHSIZE_SHIFT
) &
3910 I40E_PFQF_CTL_0_PFFCHSIZE_MASK
;
3911 /* Program required FCoE DDP contexts for the PF */
3912 val
&= ~I40E_PFQF_CTL_0_PFFCDSIZE_MASK
;
3913 val
|= ((u32
)settings
->fcoe_cntx_num
<<
3914 I40E_PFQF_CTL_0_PFFCDSIZE_SHIFT
) &
3915 I40E_PFQF_CTL_0_PFFCDSIZE_MASK
;
3917 /* Program Hash LUT size for the PF */
3918 val
&= ~I40E_PFQF_CTL_0_HASHLUTSIZE_MASK
;
3919 if (settings
->hash_lut_size
== I40E_HASH_LUT_SIZE_512
)
3921 val
|= (hash_lut_size
<< I40E_PFQF_CTL_0_HASHLUTSIZE_SHIFT
) &
3922 I40E_PFQF_CTL_0_HASHLUTSIZE_MASK
;
3924 /* Enable FDIR, Ethertype and MACVLAN filters for PF and VFs */
3925 if (settings
->enable_fdir
)
3926 val
|= I40E_PFQF_CTL_0_FD_ENA_MASK
;
3927 if (settings
->enable_ethtype
)
3928 val
|= I40E_PFQF_CTL_0_ETYPE_ENA_MASK
;
3929 if (settings
->enable_macvlan
)
3930 val
|= I40E_PFQF_CTL_0_MACVLAN_ENA_MASK
;
3932 i40e_write_rx_ctl(hw
, I40E_PFQF_CTL_0
, val
);
3938 * i40e_aq_add_rem_control_packet_filter - Add or Remove Control Packet Filter
3939 * @hw: pointer to the hw struct
3940 * @mac_addr: MAC address to use in the filter
3941 * @ethtype: Ethertype to use in the filter
3942 * @flags: Flags that needs to be applied to the filter
3943 * @vsi_seid: seid of the control VSI
3944 * @queue: VSI queue number to send the packet to
3945 * @is_add: Add control packet filter if True else remove
3946 * @stats: Structure to hold information on control filter counts
3947 * @cmd_details: pointer to command details structure or NULL
3949 * This command will Add or Remove control packet filter for a control VSI.
3950 * In return it will update the total number of perfect filter count in
3953 i40e_status
i40e_aq_add_rem_control_packet_filter(struct i40e_hw
*hw
,
3954 u8
*mac_addr
, u16 ethtype
, u16 flags
,
3955 u16 vsi_seid
, u16 queue
, bool is_add
,
3956 struct i40e_control_filter_stats
*stats
,
3957 struct i40e_asq_cmd_details
*cmd_details
)
3959 struct i40e_aq_desc desc
;
3960 struct i40e_aqc_add_remove_control_packet_filter
*cmd
=
3961 (struct i40e_aqc_add_remove_control_packet_filter
*)
3963 struct i40e_aqc_add_remove_control_packet_filter_completion
*resp
=
3964 (struct i40e_aqc_add_remove_control_packet_filter_completion
*)
3969 return I40E_ERR_PARAM
;
3972 i40e_fill_default_direct_cmd_desc(&desc
,
3973 i40e_aqc_opc_add_control_packet_filter
);
3974 cmd
->queue
= cpu_to_le16(queue
);
3976 i40e_fill_default_direct_cmd_desc(&desc
,
3977 i40e_aqc_opc_remove_control_packet_filter
);
3981 ether_addr_copy(cmd
->mac
, mac_addr
);
3983 cmd
->etype
= cpu_to_le16(ethtype
);
3984 cmd
->flags
= cpu_to_le16(flags
);
3985 cmd
->seid
= cpu_to_le16(vsi_seid
);
3987 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
3989 if (!status
&& stats
) {
3990 stats
->mac_etype_used
= le16_to_cpu(resp
->mac_etype_used
);
3991 stats
->etype_used
= le16_to_cpu(resp
->etype_used
);
3992 stats
->mac_etype_free
= le16_to_cpu(resp
->mac_etype_free
);
3993 stats
->etype_free
= le16_to_cpu(resp
->etype_free
);
4000 * i40e_add_filter_to_drop_tx_flow_control_frames- filter to drop flow control
4001 * @hw: pointer to the hw struct
4002 * @seid: VSI seid to add ethertype filter from
4004 #define I40E_FLOW_CONTROL_ETHTYPE 0x8808
4005 void i40e_add_filter_to_drop_tx_flow_control_frames(struct i40e_hw
*hw
,
4008 u16 flag
= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC
|
4009 I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP
|
4010 I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TX
;
4011 u16 ethtype
= I40E_FLOW_CONTROL_ETHTYPE
;
4014 status
= i40e_aq_add_rem_control_packet_filter(hw
, NULL
, ethtype
, flag
,
4015 seid
, 0, true, NULL
,
4018 hw_dbg(hw
, "Ethtype Filter Add failed: Error pruning Tx flow control frames\n");
4022 * i40e_aq_alternate_read
4023 * @hw: pointer to the hardware structure
4024 * @reg_addr0: address of first dword to be read
4025 * @reg_val0: pointer for data read from 'reg_addr0'
4026 * @reg_addr1: address of second dword to be read
4027 * @reg_val1: pointer for data read from 'reg_addr1'
4029 * Read one or two dwords from alternate structure. Fields are indicated
4030 * by 'reg_addr0' and 'reg_addr1' register numbers. If 'reg_val1' pointer
4031 * is not passed then only register at 'reg_addr0' is read.
4034 static i40e_status
i40e_aq_alternate_read(struct i40e_hw
*hw
,
4035 u32 reg_addr0
, u32
*reg_val0
,
4036 u32 reg_addr1
, u32
*reg_val1
)
4038 struct i40e_aq_desc desc
;
4039 struct i40e_aqc_alternate_write
*cmd_resp
=
4040 (struct i40e_aqc_alternate_write
*)&desc
.params
.raw
;
4044 return I40E_ERR_PARAM
;
4046 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_alternate_read
);
4047 cmd_resp
->address0
= cpu_to_le32(reg_addr0
);
4048 cmd_resp
->address1
= cpu_to_le32(reg_addr1
);
4050 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, NULL
);
4053 *reg_val0
= le32_to_cpu(cmd_resp
->data0
);
4056 *reg_val1
= le32_to_cpu(cmd_resp
->data1
);
4063 * i40e_aq_resume_port_tx
4064 * @hw: pointer to the hardware structure
4065 * @cmd_details: pointer to command details structure or NULL
4067 * Resume port's Tx traffic
4069 i40e_status
i40e_aq_resume_port_tx(struct i40e_hw
*hw
,
4070 struct i40e_asq_cmd_details
*cmd_details
)
4072 struct i40e_aq_desc desc
;
4075 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_resume_port_tx
);
4077 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
4083 * i40e_set_pci_config_data - store PCI bus info
4084 * @hw: pointer to hardware structure
4085 * @link_status: the link status word from PCI config space
4087 * Stores the PCI bus info (speed, width, type) within the i40e_hw structure
4089 void i40e_set_pci_config_data(struct i40e_hw
*hw
, u16 link_status
)
4091 hw
->bus
.type
= i40e_bus_type_pci_express
;
4093 switch (link_status
& PCI_EXP_LNKSTA_NLW
) {
4094 case PCI_EXP_LNKSTA_NLW_X1
:
4095 hw
->bus
.width
= i40e_bus_width_pcie_x1
;
4097 case PCI_EXP_LNKSTA_NLW_X2
:
4098 hw
->bus
.width
= i40e_bus_width_pcie_x2
;
4100 case PCI_EXP_LNKSTA_NLW_X4
:
4101 hw
->bus
.width
= i40e_bus_width_pcie_x4
;
4103 case PCI_EXP_LNKSTA_NLW_X8
:
4104 hw
->bus
.width
= i40e_bus_width_pcie_x8
;
4107 hw
->bus
.width
= i40e_bus_width_unknown
;
4111 switch (link_status
& PCI_EXP_LNKSTA_CLS
) {
4112 case PCI_EXP_LNKSTA_CLS_2_5GB
:
4113 hw
->bus
.speed
= i40e_bus_speed_2500
;
4115 case PCI_EXP_LNKSTA_CLS_5_0GB
:
4116 hw
->bus
.speed
= i40e_bus_speed_5000
;
4118 case PCI_EXP_LNKSTA_CLS_8_0GB
:
4119 hw
->bus
.speed
= i40e_bus_speed_8000
;
4122 hw
->bus
.speed
= i40e_bus_speed_unknown
;
4128 * i40e_aq_debug_dump
4129 * @hw: pointer to the hardware structure
4130 * @cluster_id: specific cluster to dump
4131 * @table_id: table id within cluster
4132 * @start_index: index of line in the block to read
4133 * @buff_size: dump buffer size
4134 * @buff: dump buffer
4135 * @ret_buff_size: actual buffer size returned
4136 * @ret_next_table: next block to read
4137 * @ret_next_index: next index to read
4139 * Dump internal FW/HW data for debug purposes.
4142 i40e_status
i40e_aq_debug_dump(struct i40e_hw
*hw
, u8 cluster_id
,
4143 u8 table_id
, u32 start_index
, u16 buff_size
,
4144 void *buff
, u16
*ret_buff_size
,
4145 u8
*ret_next_table
, u32
*ret_next_index
,
4146 struct i40e_asq_cmd_details
*cmd_details
)
4148 struct i40e_aq_desc desc
;
4149 struct i40e_aqc_debug_dump_internals
*cmd
=
4150 (struct i40e_aqc_debug_dump_internals
*)&desc
.params
.raw
;
4151 struct i40e_aqc_debug_dump_internals
*resp
=
4152 (struct i40e_aqc_debug_dump_internals
*)&desc
.params
.raw
;
4155 if (buff_size
== 0 || !buff
)
4156 return I40E_ERR_PARAM
;
4158 i40e_fill_default_direct_cmd_desc(&desc
,
4159 i40e_aqc_opc_debug_dump_internals
);
4160 /* Indirect Command */
4161 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_BUF
);
4162 if (buff_size
> I40E_AQ_LARGE_BUF
)
4163 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_LB
);
4165 cmd
->cluster_id
= cluster_id
;
4166 cmd
->table_id
= table_id
;
4167 cmd
->idx
= cpu_to_le32(start_index
);
4169 desc
.datalen
= cpu_to_le16(buff_size
);
4171 status
= i40e_asq_send_command(hw
, &desc
, buff
, buff_size
, cmd_details
);
4174 *ret_buff_size
= le16_to_cpu(desc
.datalen
);
4176 *ret_next_table
= resp
->table_id
;
4178 *ret_next_index
= le32_to_cpu(resp
->idx
);
4185 * i40e_read_bw_from_alt_ram
4186 * @hw: pointer to the hardware structure
4187 * @max_bw: pointer for max_bw read
4188 * @min_bw: pointer for min_bw read
4189 * @min_valid: pointer for bool that is true if min_bw is a valid value
4190 * @max_valid: pointer for bool that is true if max_bw is a valid value
4192 * Read bw from the alternate ram for the given pf
4194 i40e_status
i40e_read_bw_from_alt_ram(struct i40e_hw
*hw
,
4195 u32
*max_bw
, u32
*min_bw
,
4196 bool *min_valid
, bool *max_valid
)
4199 u32 max_bw_addr
, min_bw_addr
;
4201 /* Calculate the address of the min/max bw registers */
4202 max_bw_addr
= I40E_ALT_STRUCT_FIRST_PF_OFFSET
+
4203 I40E_ALT_STRUCT_MAX_BW_OFFSET
+
4204 (I40E_ALT_STRUCT_DWORDS_PER_PF
* hw
->pf_id
);
4205 min_bw_addr
= I40E_ALT_STRUCT_FIRST_PF_OFFSET
+
4206 I40E_ALT_STRUCT_MIN_BW_OFFSET
+
4207 (I40E_ALT_STRUCT_DWORDS_PER_PF
* hw
->pf_id
);
4209 /* Read the bandwidths from alt ram */
4210 status
= i40e_aq_alternate_read(hw
, max_bw_addr
, max_bw
,
4211 min_bw_addr
, min_bw
);
4213 if (*min_bw
& I40E_ALT_BW_VALID_MASK
)
4218 if (*max_bw
& I40E_ALT_BW_VALID_MASK
)
4227 * i40e_aq_configure_partition_bw
4228 * @hw: pointer to the hardware structure
4229 * @bw_data: Buffer holding valid pfs and bw limits
4230 * @cmd_details: pointer to command details
4232 * Configure partitions guaranteed/max bw
4234 i40e_status
i40e_aq_configure_partition_bw(struct i40e_hw
*hw
,
4235 struct i40e_aqc_configure_partition_bw_data
*bw_data
,
4236 struct i40e_asq_cmd_details
*cmd_details
)
4239 struct i40e_aq_desc desc
;
4240 u16 bwd_size
= sizeof(*bw_data
);
4242 i40e_fill_default_direct_cmd_desc(&desc
,
4243 i40e_aqc_opc_configure_partition_bw
);
4245 /* Indirect command */
4246 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_BUF
);
4247 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_RD
);
4249 if (bwd_size
> I40E_AQ_LARGE_BUF
)
4250 desc
.flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_LB
);
4252 desc
.datalen
= cpu_to_le16(bwd_size
);
4254 status
= i40e_asq_send_command(hw
, &desc
, bw_data
, bwd_size
,
4261 * i40e_read_phy_register
4262 * @hw: pointer to the HW structure
4263 * @page: registers page number
4264 * @reg: register address in the page
4265 * @phy_adr: PHY address on MDIO interface
4266 * @value: PHY register value
4268 * Reads specified PHY register value
4270 i40e_status
i40e_read_phy_register(struct i40e_hw
*hw
,
4271 u8 page
, u16 reg
, u8 phy_addr
,
4274 i40e_status status
= I40E_ERR_TIMEOUT
;
4277 u8 port_num
= hw
->func_caps
.mdio_port_num
;
4279 command
= (reg
<< I40E_GLGEN_MSCA_MDIADD_SHIFT
) |
4280 (page
<< I40E_GLGEN_MSCA_DEVADD_SHIFT
) |
4281 (phy_addr
<< I40E_GLGEN_MSCA_PHYADD_SHIFT
) |
4282 (I40E_MDIO_OPCODE_ADDRESS
) |
4283 (I40E_MDIO_STCODE
) |
4284 (I40E_GLGEN_MSCA_MDICMD_MASK
) |
4285 (I40E_GLGEN_MSCA_MDIINPROGEN_MASK
);
4286 wr32(hw
, I40E_GLGEN_MSCA(port_num
), command
);
4288 command
= rd32(hw
, I40E_GLGEN_MSCA(port_num
));
4289 if (!(command
& I40E_GLGEN_MSCA_MDICMD_MASK
)) {
4293 usleep_range(10, 20);
4298 i40e_debug(hw
, I40E_DEBUG_PHY
,
4299 "PHY: Can't write command to external PHY.\n");
4303 command
= (page
<< I40E_GLGEN_MSCA_DEVADD_SHIFT
) |
4304 (phy_addr
<< I40E_GLGEN_MSCA_PHYADD_SHIFT
) |
4305 (I40E_MDIO_OPCODE_READ
) |
4306 (I40E_MDIO_STCODE
) |
4307 (I40E_GLGEN_MSCA_MDICMD_MASK
) |
4308 (I40E_GLGEN_MSCA_MDIINPROGEN_MASK
);
4309 status
= I40E_ERR_TIMEOUT
;
4311 wr32(hw
, I40E_GLGEN_MSCA(port_num
), command
);
4313 command
= rd32(hw
, I40E_GLGEN_MSCA(port_num
));
4314 if (!(command
& I40E_GLGEN_MSCA_MDICMD_MASK
)) {
4318 usleep_range(10, 20);
4323 command
= rd32(hw
, I40E_GLGEN_MSRWD(port_num
));
4324 *value
= (command
& I40E_GLGEN_MSRWD_MDIRDDATA_MASK
) >>
4325 I40E_GLGEN_MSRWD_MDIRDDATA_SHIFT
;
4327 i40e_debug(hw
, I40E_DEBUG_PHY
,
4328 "PHY: Can't read register value from external PHY.\n");
4336 * i40e_write_phy_register
4337 * @hw: pointer to the HW structure
4338 * @page: registers page number
4339 * @reg: register address in the page
4340 * @phy_adr: PHY address on MDIO interface
4341 * @value: PHY register value
4343 * Writes value to specified PHY register
4345 i40e_status
i40e_write_phy_register(struct i40e_hw
*hw
,
4346 u8 page
, u16 reg
, u8 phy_addr
,
4349 i40e_status status
= I40E_ERR_TIMEOUT
;
4352 u8 port_num
= hw
->func_caps
.mdio_port_num
;
4354 command
= (reg
<< I40E_GLGEN_MSCA_MDIADD_SHIFT
) |
4355 (page
<< I40E_GLGEN_MSCA_DEVADD_SHIFT
) |
4356 (phy_addr
<< I40E_GLGEN_MSCA_PHYADD_SHIFT
) |
4357 (I40E_MDIO_OPCODE_ADDRESS
) |
4358 (I40E_MDIO_STCODE
) |
4359 (I40E_GLGEN_MSCA_MDICMD_MASK
) |
4360 (I40E_GLGEN_MSCA_MDIINPROGEN_MASK
);
4361 wr32(hw
, I40E_GLGEN_MSCA(port_num
), command
);
4363 command
= rd32(hw
, I40E_GLGEN_MSCA(port_num
));
4364 if (!(command
& I40E_GLGEN_MSCA_MDICMD_MASK
)) {
4368 usleep_range(10, 20);
4372 i40e_debug(hw
, I40E_DEBUG_PHY
,
4373 "PHY: Can't write command to external PHY.\n");
4377 command
= value
<< I40E_GLGEN_MSRWD_MDIWRDATA_SHIFT
;
4378 wr32(hw
, I40E_GLGEN_MSRWD(port_num
), command
);
4380 command
= (page
<< I40E_GLGEN_MSCA_DEVADD_SHIFT
) |
4381 (phy_addr
<< I40E_GLGEN_MSCA_PHYADD_SHIFT
) |
4382 (I40E_MDIO_OPCODE_WRITE
) |
4383 (I40E_MDIO_STCODE
) |
4384 (I40E_GLGEN_MSCA_MDICMD_MASK
) |
4385 (I40E_GLGEN_MSCA_MDIINPROGEN_MASK
);
4386 status
= I40E_ERR_TIMEOUT
;
4388 wr32(hw
, I40E_GLGEN_MSCA(port_num
), command
);
4390 command
= rd32(hw
, I40E_GLGEN_MSCA(port_num
));
4391 if (!(command
& I40E_GLGEN_MSCA_MDICMD_MASK
)) {
4395 usleep_range(10, 20);
4404 * i40e_get_phy_address
4405 * @hw: pointer to the HW structure
4406 * @dev_num: PHY port num that address we want
4407 * @phy_addr: Returned PHY address
4409 * Gets PHY address for current port
4411 u8
i40e_get_phy_address(struct i40e_hw
*hw
, u8 dev_num
)
4413 u8 port_num
= hw
->func_caps
.mdio_port_num
;
4414 u32 reg_val
= rd32(hw
, I40E_GLGEN_MDIO_I2C_SEL(port_num
));
4416 return (u8
)(reg_val
>> ((dev_num
+ 1) * 5)) & 0x1f;
4420 * i40e_blink_phy_led
4421 * @hw: pointer to the HW structure
4422 * @time: time how long led will blinks in secs
4423 * @interval: gap between LED on and off in msecs
4425 * Blinks PHY link LED
4427 i40e_status
i40e_blink_phy_link_led(struct i40e_hw
*hw
,
4428 u32 time
, u32 interval
)
4430 i40e_status status
= 0;
4435 u16 led_addr
= I40E_PHY_LED_PROV_REG_1
;
4439 i
= rd32(hw
, I40E_PFGEN_PORTNUM
);
4440 port_num
= (u8
)(i
& I40E_PFGEN_PORTNUM_PORT_NUM_MASK
);
4441 phy_addr
= i40e_get_phy_address(hw
, port_num
);
4443 for (gpio_led_port
= 0; gpio_led_port
< 3; gpio_led_port
++,
4445 status
= i40e_read_phy_register(hw
, I40E_PHY_COM_REG_PAGE
,
4446 led_addr
, phy_addr
, &led_reg
);
4448 goto phy_blinking_end
;
4450 if (led_reg
& I40E_PHY_LED_LINK_MODE_MASK
) {
4452 status
= i40e_write_phy_register(hw
,
4453 I40E_PHY_COM_REG_PAGE
,
4457 goto phy_blinking_end
;
4462 if (time
> 0 && interval
> 0) {
4463 for (i
= 0; i
< time
* 1000; i
+= interval
) {
4464 status
= i40e_read_phy_register(hw
,
4465 I40E_PHY_COM_REG_PAGE
,
4469 goto restore_config
;
4470 if (led_reg
& I40E_PHY_LED_MANUAL_ON
)
4473 led_reg
= I40E_PHY_LED_MANUAL_ON
;
4474 status
= i40e_write_phy_register(hw
,
4475 I40E_PHY_COM_REG_PAGE
,
4479 goto restore_config
;
4485 status
= i40e_write_phy_register(hw
, I40E_PHY_COM_REG_PAGE
, led_addr
,
4493 * i40e_led_get_phy - return current on/off mode
4494 * @hw: pointer to the hw struct
4495 * @led_addr: address of led register to use
4496 * @val: original value of register to use
4499 i40e_status
i40e_led_get_phy(struct i40e_hw
*hw
, u16
*led_addr
,
4502 i40e_status status
= 0;
4510 temp_addr
= I40E_PHY_LED_PROV_REG_1
;
4511 i
= rd32(hw
, I40E_PFGEN_PORTNUM
);
4512 port_num
= (u8
)(i
& I40E_PFGEN_PORTNUM_PORT_NUM_MASK
);
4513 phy_addr
= i40e_get_phy_address(hw
, port_num
);
4515 for (gpio_led_port
= 0; gpio_led_port
< 3; gpio_led_port
++,
4517 status
= i40e_read_phy_register(hw
, I40E_PHY_COM_REG_PAGE
,
4518 temp_addr
, phy_addr
, ®_val
);
4522 if (reg_val
& I40E_PHY_LED_LINK_MODE_MASK
) {
4523 *led_addr
= temp_addr
;
4532 * @hw: pointer to the HW structure
4533 * @on: true or false
4534 * @mode: original val plus bit for set or ignore
4535 * Set led's on or off when controlled by the PHY
4538 i40e_status
i40e_led_set_phy(struct i40e_hw
*hw
, bool on
,
4539 u16 led_addr
, u32 mode
)
4541 i40e_status status
= 0;
4548 i
= rd32(hw
, I40E_PFGEN_PORTNUM
);
4549 port_num
= (u8
)(i
& I40E_PFGEN_PORTNUM_PORT_NUM_MASK
);
4550 phy_addr
= i40e_get_phy_address(hw
, port_num
);
4552 status
= i40e_read_phy_register(hw
, I40E_PHY_COM_REG_PAGE
, led_addr
,
4553 phy_addr
, &led_reg
);
4557 if (led_reg
& I40E_PHY_LED_LINK_MODE_MASK
) {
4559 status
= i40e_write_phy_register(hw
, I40E_PHY_COM_REG_PAGE
,
4560 led_addr
, phy_addr
, led_reg
);
4564 status
= i40e_read_phy_register(hw
, I40E_PHY_COM_REG_PAGE
,
4565 led_addr
, phy_addr
, &led_reg
);
4567 goto restore_config
;
4569 led_reg
= I40E_PHY_LED_MANUAL_ON
;
4572 status
= i40e_write_phy_register(hw
, I40E_PHY_COM_REG_PAGE
,
4573 led_addr
, phy_addr
, led_reg
);
4575 goto restore_config
;
4576 if (mode
& I40E_PHY_LED_MODE_ORIG
) {
4577 led_ctl
= (mode
& I40E_PHY_LED_MODE_MASK
);
4578 status
= i40e_write_phy_register(hw
,
4579 I40E_PHY_COM_REG_PAGE
,
4580 led_addr
, phy_addr
, led_ctl
);
4584 status
= i40e_write_phy_register(hw
, I40E_PHY_COM_REG_PAGE
, led_addr
,
4590 * i40e_aq_rx_ctl_read_register - use FW to read from an Rx control register
4591 * @hw: pointer to the hw struct
4592 * @reg_addr: register address
4593 * @reg_val: ptr to register value
4594 * @cmd_details: pointer to command details structure or NULL
4596 * Use the firmware to read the Rx control register,
4597 * especially useful if the Rx unit is under heavy pressure
4599 i40e_status
i40e_aq_rx_ctl_read_register(struct i40e_hw
*hw
,
4600 u32 reg_addr
, u32
*reg_val
,
4601 struct i40e_asq_cmd_details
*cmd_details
)
4603 struct i40e_aq_desc desc
;
4604 struct i40e_aqc_rx_ctl_reg_read_write
*cmd_resp
=
4605 (struct i40e_aqc_rx_ctl_reg_read_write
*)&desc
.params
.raw
;
4609 return I40E_ERR_PARAM
;
4611 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_rx_ctl_reg_read
);
4613 cmd_resp
->address
= cpu_to_le32(reg_addr
);
4615 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
4618 *reg_val
= le32_to_cpu(cmd_resp
->value
);
4624 * i40e_read_rx_ctl - read from an Rx control register
4625 * @hw: pointer to the hw struct
4626 * @reg_addr: register address
4628 u32
i40e_read_rx_ctl(struct i40e_hw
*hw
, u32 reg_addr
)
4630 i40e_status status
= 0;
4635 use_register
= (hw
->aq
.api_maj_ver
== 1) && (hw
->aq
.api_min_ver
< 5);
4636 if (!use_register
) {
4638 status
= i40e_aq_rx_ctl_read_register(hw
, reg_addr
, &val
, NULL
);
4639 if (hw
->aq
.asq_last_status
== I40E_AQ_RC_EAGAIN
&& retry
) {
4640 usleep_range(1000, 2000);
4646 /* if the AQ access failed, try the old-fashioned way */
4647 if (status
|| use_register
)
4648 val
= rd32(hw
, reg_addr
);
4654 * i40e_aq_rx_ctl_write_register
4655 * @hw: pointer to the hw struct
4656 * @reg_addr: register address
4657 * @reg_val: register value
4658 * @cmd_details: pointer to command details structure or NULL
4660 * Use the firmware to write to an Rx control register,
4661 * especially useful if the Rx unit is under heavy pressure
4663 i40e_status
i40e_aq_rx_ctl_write_register(struct i40e_hw
*hw
,
4664 u32 reg_addr
, u32 reg_val
,
4665 struct i40e_asq_cmd_details
*cmd_details
)
4667 struct i40e_aq_desc desc
;
4668 struct i40e_aqc_rx_ctl_reg_read_write
*cmd
=
4669 (struct i40e_aqc_rx_ctl_reg_read_write
*)&desc
.params
.raw
;
4672 i40e_fill_default_direct_cmd_desc(&desc
, i40e_aqc_opc_rx_ctl_reg_write
);
4674 cmd
->address
= cpu_to_le32(reg_addr
);
4675 cmd
->value
= cpu_to_le32(reg_val
);
4677 status
= i40e_asq_send_command(hw
, &desc
, NULL
, 0, cmd_details
);
4683 * i40e_write_rx_ctl - write to an Rx control register
4684 * @hw: pointer to the hw struct
4685 * @reg_addr: register address
4686 * @reg_val: register value
4688 void i40e_write_rx_ctl(struct i40e_hw
*hw
, u32 reg_addr
, u32 reg_val
)
4690 i40e_status status
= 0;
4694 use_register
= (hw
->aq
.api_maj_ver
== 1) && (hw
->aq
.api_min_ver
< 5);
4695 if (!use_register
) {
4697 status
= i40e_aq_rx_ctl_write_register(hw
, reg_addr
,
4699 if (hw
->aq
.asq_last_status
== I40E_AQ_RC_EAGAIN
&& retry
) {
4700 usleep_range(1000, 2000);
4706 /* if the AQ access failed, try the old-fashioned way */
4707 if (status
|| use_register
)
4708 wr32(hw
, reg_addr
, reg_val
);