1 /*******************************************************************************
3 Copyright (c) 2013 - 2014, Intel Corporation
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 3. Neither the name of the Intel Corporation nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
32 ***************************************************************************/
34 #include "i40e_type.h"
35 #include "i40e_adminq.h"
36 #include "i40e_prototype.h"
37 #include "i40e_virtchnl.h"
40 * i40e_set_mac_type - Sets MAC type
41 * @hw: pointer to the HW structure
43 * This function sets the mac type of the adapter based on the
44 * vendor ID and device ID stored in the hw structure.
47 enum i40e_status_code i40e_set_mac_type(struct i40e_hw *hw)
49 STATIC enum i40e_status_code i40e_set_mac_type(struct i40e_hw *hw)
52 enum i40e_status_code status = I40E_SUCCESS;
54 DEBUGFUNC("i40e_set_mac_type\n");
56 if (hw->vendor_id == I40E_INTEL_VENDOR_ID) {
57 switch (hw->device_id) {
58 case I40E_DEV_ID_SFP_XL710:
59 case I40E_DEV_ID_QEMU:
60 case I40E_DEV_ID_KX_A:
61 case I40E_DEV_ID_KX_B:
62 case I40E_DEV_ID_KX_C:
63 case I40E_DEV_ID_QSFP_A:
64 case I40E_DEV_ID_QSFP_B:
65 case I40E_DEV_ID_QSFP_C:
66 hw->mac.type = I40E_MAC_XL710;
69 case I40E_DEV_ID_VF_HV:
70 hw->mac.type = I40E_MAC_VF;
73 hw->mac.type = I40E_MAC_GENERIC;
77 status = I40E_ERR_DEVICE_NOT_SUPPORTED;
80 DEBUGOUT2("i40e_set_mac_type found mac: %d, returns: %d\n",
81 hw->mac.type, status);
87 * @hw: debug mask related to admin queue
89 * @desc: pointer to admin queue descriptor
90 * @buffer: pointer to command buffer
92 * Dumps debug log about adminq command with descriptor contents.
94 void i40e_debug_aq(struct i40e_hw *hw, enum i40e_debug_mask mask, void *desc,
97 struct i40e_aq_desc *aq_desc = (struct i40e_aq_desc *)desc;
98 u8 *aq_buffer = (u8 *)buffer;
102 if ((!(mask & hw->debug_mask)) || (desc == NULL))
106 "AQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n",
107 aq_desc->opcode, aq_desc->flags, aq_desc->datalen,
109 i40e_debug(hw, mask, "\tcookie (h,l) 0x%08X 0x%08X\n",
110 aq_desc->cookie_high, aq_desc->cookie_low);
111 i40e_debug(hw, mask, "\tparam (0,1) 0x%08X 0x%08X\n",
112 aq_desc->params.internal.param0,
113 aq_desc->params.internal.param1);
114 i40e_debug(hw, mask, "\taddr (h,l) 0x%08X 0x%08X\n",
115 aq_desc->params.external.addr_high,
116 aq_desc->params.external.addr_low);
118 if ((buffer != NULL) && (aq_desc->datalen != 0)) {
119 i40e_memset(data, 0, sizeof(data), I40E_NONDMA_MEM);
120 i40e_debug(hw, mask, "AQ CMD Buffer:\n");
121 for (i = 0; i < LE16_TO_CPU(aq_desc->datalen); i++) {
122 data[((i % 16) / 4)] |=
123 ((u32)aq_buffer[i]) << (8 * (i % 4));
124 if ((i % 16) == 15) {
126 "\t0x%04X %08X %08X %08X %08X\n",
127 i - 15, data[0], data[1], data[2],
129 i40e_memset(data, 0, sizeof(data),
134 i40e_debug(hw, mask, "\t0x%04X %08X %08X %08X %08X\n",
135 i - (i % 16), data[0], data[1], data[2],
141 * i40e_check_asq_alive
142 * @hw: pointer to the hw struct
144 * Returns true if Queue is enabled else false.
146 bool i40e_check_asq_alive(struct i40e_hw *hw)
149 return !!(rd32(hw, hw->aq.asq.len) & I40E_PF_ATQLEN_ATQENABLE_MASK);
155 * i40e_aq_queue_shutdown
156 * @hw: pointer to the hw struct
157 * @unloading: is the driver unloading itself
159 * Tell the Firmware that we're shutting down the AdminQ and whether
160 * or not the driver is unloading as well.
162 enum i40e_status_code i40e_aq_queue_shutdown(struct i40e_hw *hw,
165 struct i40e_aq_desc desc;
166 struct i40e_aqc_queue_shutdown *cmd =
167 (struct i40e_aqc_queue_shutdown *)&desc.params.raw;
168 enum i40e_status_code status;
170 i40e_fill_default_direct_cmd_desc(&desc,
171 i40e_aqc_opc_queue_shutdown);
174 cmd->driver_unloading = CPU_TO_LE32(I40E_AQ_DRIVER_UNLOADING);
175 status = i40e_asq_send_command(hw, &desc, NULL, 0, NULL);
180 /* The i40e_ptype_lookup table is used to convert from the 8-bit ptype in the
181 * hardware to a bit-field that can be used by SW to more easily determine the
184 * Macros are used to shorten the table lines and make this table human
187 * We store the PTYPE in the top byte of the bit field - this is just so that
188 * we can check that the table doesn't have a row missing, as the index into
189 * the table should be the PTYPE.
193 * IF NOT i40e_ptype_lookup[ptype].known
196 * ELSE IF i40e_ptype_lookup[ptype].outer_ip == I40E_RX_PTYPE_OUTER_IP
197 * Use the rest of the fields to look at the tunnels, inner protocols, etc
199 * Use the enum i40e_rx_l2_ptype to decode the packet type
203 /* macro to make the table lines short */
204 #define I40E_PTT(PTYPE, OUTER_IP, OUTER_IP_VER, OUTER_FRAG, T, TE, TEF, I, PL)\
207 I40E_RX_PTYPE_OUTER_##OUTER_IP, \
208 I40E_RX_PTYPE_OUTER_##OUTER_IP_VER, \
209 I40E_RX_PTYPE_##OUTER_FRAG, \
210 I40E_RX_PTYPE_TUNNEL_##T, \
211 I40E_RX_PTYPE_TUNNEL_END_##TE, \
212 I40E_RX_PTYPE_##TEF, \
213 I40E_RX_PTYPE_INNER_PROT_##I, \
214 I40E_RX_PTYPE_PAYLOAD_LAYER_##PL }
216 #define I40E_PTT_UNUSED_ENTRY(PTYPE) \
217 { PTYPE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
219 /* shorter macros makes the table fit but are terse */
220 #define I40E_RX_PTYPE_NOF I40E_RX_PTYPE_NOT_FRAG
221 #define I40E_RX_PTYPE_FRG I40E_RX_PTYPE_FRAG
222 #define I40E_RX_PTYPE_INNER_PROT_TS I40E_RX_PTYPE_INNER_PROT_TIMESYNC
224 /* Lookup table mapping the HW PTYPE to the bit field for decoding */
225 struct i40e_rx_ptype_decoded i40e_ptype_lookup[] = {
226 /* L2 Packet types */
227 I40E_PTT_UNUSED_ENTRY(0),
228 I40E_PTT(1, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
229 I40E_PTT(2, L2, NONE, NOF, NONE, NONE, NOF, TS, PAY2),
230 I40E_PTT(3, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
231 I40E_PTT_UNUSED_ENTRY(4),
232 I40E_PTT_UNUSED_ENTRY(5),
233 I40E_PTT(6, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
234 I40E_PTT(7, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
235 I40E_PTT_UNUSED_ENTRY(8),
236 I40E_PTT_UNUSED_ENTRY(9),
237 I40E_PTT(10, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
238 I40E_PTT(11, L2, NONE, NOF, NONE, NONE, NOF, NONE, NONE),
239 I40E_PTT(12, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
240 I40E_PTT(13, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
241 I40E_PTT(14, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
242 I40E_PTT(15, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
243 I40E_PTT(16, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
244 I40E_PTT(17, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
245 I40E_PTT(18, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
246 I40E_PTT(19, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
247 I40E_PTT(20, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
248 I40E_PTT(21, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
250 /* Non Tunneled IPv4 */
251 I40E_PTT(22, IP, IPV4, FRG, NONE, NONE, NOF, NONE, PAY3),
252 I40E_PTT(23, IP, IPV4, NOF, NONE, NONE, NOF, NONE, PAY3),
253 I40E_PTT(24, IP, IPV4, NOF, NONE, NONE, NOF, UDP, PAY4),
254 I40E_PTT_UNUSED_ENTRY(25),
255 I40E_PTT(26, IP, IPV4, NOF, NONE, NONE, NOF, TCP, PAY4),
256 I40E_PTT(27, IP, IPV4, NOF, NONE, NONE, NOF, SCTP, PAY4),
257 I40E_PTT(28, IP, IPV4, NOF, NONE, NONE, NOF, ICMP, PAY4),
260 I40E_PTT(29, IP, IPV4, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
261 I40E_PTT(30, IP, IPV4, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
262 I40E_PTT(31, IP, IPV4, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
263 I40E_PTT_UNUSED_ENTRY(32),
264 I40E_PTT(33, IP, IPV4, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
265 I40E_PTT(34, IP, IPV4, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
266 I40E_PTT(35, IP, IPV4, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
269 I40E_PTT(36, IP, IPV4, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
270 I40E_PTT(37, IP, IPV4, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
271 I40E_PTT(38, IP, IPV4, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
272 I40E_PTT_UNUSED_ENTRY(39),
273 I40E_PTT(40, IP, IPV4, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
274 I40E_PTT(41, IP, IPV4, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
275 I40E_PTT(42, IP, IPV4, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
277 /* IPv4 --> GRE/NAT */
278 I40E_PTT(43, IP, IPV4, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
280 /* IPv4 --> GRE/NAT --> IPv4 */
281 I40E_PTT(44, IP, IPV4, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
282 I40E_PTT(45, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
283 I40E_PTT(46, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
284 I40E_PTT_UNUSED_ENTRY(47),
285 I40E_PTT(48, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
286 I40E_PTT(49, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
287 I40E_PTT(50, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
289 /* IPv4 --> GRE/NAT --> IPv6 */
290 I40E_PTT(51, IP, IPV4, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
291 I40E_PTT(52, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
292 I40E_PTT(53, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
293 I40E_PTT_UNUSED_ENTRY(54),
294 I40E_PTT(55, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
295 I40E_PTT(56, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
296 I40E_PTT(57, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
298 /* IPv4 --> GRE/NAT --> MAC */
299 I40E_PTT(58, IP, IPV4, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
301 /* IPv4 --> GRE/NAT --> MAC --> IPv4 */
302 I40E_PTT(59, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
303 I40E_PTT(60, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
304 I40E_PTT(61, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
305 I40E_PTT_UNUSED_ENTRY(62),
306 I40E_PTT(63, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
307 I40E_PTT(64, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
308 I40E_PTT(65, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
310 /* IPv4 --> GRE/NAT -> MAC --> IPv6 */
311 I40E_PTT(66, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
312 I40E_PTT(67, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
313 I40E_PTT(68, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
314 I40E_PTT_UNUSED_ENTRY(69),
315 I40E_PTT(70, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
316 I40E_PTT(71, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
317 I40E_PTT(72, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
319 /* IPv4 --> GRE/NAT --> MAC/VLAN */
320 I40E_PTT(73, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
322 /* IPv4 ---> GRE/NAT -> MAC/VLAN --> IPv4 */
323 I40E_PTT(74, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
324 I40E_PTT(75, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
325 I40E_PTT(76, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
326 I40E_PTT_UNUSED_ENTRY(77),
327 I40E_PTT(78, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
328 I40E_PTT(79, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
329 I40E_PTT(80, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
331 /* IPv4 -> GRE/NAT -> MAC/VLAN --> IPv6 */
332 I40E_PTT(81, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
333 I40E_PTT(82, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
334 I40E_PTT(83, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
335 I40E_PTT_UNUSED_ENTRY(84),
336 I40E_PTT(85, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
337 I40E_PTT(86, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
338 I40E_PTT(87, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
340 /* Non Tunneled IPv6 */
341 I40E_PTT(88, IP, IPV6, FRG, NONE, NONE, NOF, NONE, PAY3),
342 I40E_PTT(89, IP, IPV6, NOF, NONE, NONE, NOF, NONE, PAY3),
343 I40E_PTT(90, IP, IPV6, NOF, NONE, NONE, NOF, UDP, PAY3),
344 I40E_PTT_UNUSED_ENTRY(91),
345 I40E_PTT(92, IP, IPV6, NOF, NONE, NONE, NOF, TCP, PAY4),
346 I40E_PTT(93, IP, IPV6, NOF, NONE, NONE, NOF, SCTP, PAY4),
347 I40E_PTT(94, IP, IPV6, NOF, NONE, NONE, NOF, ICMP, PAY4),
350 I40E_PTT(95, IP, IPV6, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
351 I40E_PTT(96, IP, IPV6, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
352 I40E_PTT(97, IP, IPV6, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
353 I40E_PTT_UNUSED_ENTRY(98),
354 I40E_PTT(99, IP, IPV6, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
355 I40E_PTT(100, IP, IPV6, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
356 I40E_PTT(101, IP, IPV6, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
359 I40E_PTT(102, IP, IPV6, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
360 I40E_PTT(103, IP, IPV6, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
361 I40E_PTT(104, IP, IPV6, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
362 I40E_PTT_UNUSED_ENTRY(105),
363 I40E_PTT(106, IP, IPV6, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
364 I40E_PTT(107, IP, IPV6, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
365 I40E_PTT(108, IP, IPV6, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
367 /* IPv6 --> GRE/NAT */
368 I40E_PTT(109, IP, IPV6, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
370 /* IPv6 --> GRE/NAT -> IPv4 */
371 I40E_PTT(110, IP, IPV6, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
372 I40E_PTT(111, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
373 I40E_PTT(112, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
374 I40E_PTT_UNUSED_ENTRY(113),
375 I40E_PTT(114, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
376 I40E_PTT(115, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
377 I40E_PTT(116, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
379 /* IPv6 --> GRE/NAT -> IPv6 */
380 I40E_PTT(117, IP, IPV6, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
381 I40E_PTT(118, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
382 I40E_PTT(119, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
383 I40E_PTT_UNUSED_ENTRY(120),
384 I40E_PTT(121, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
385 I40E_PTT(122, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
386 I40E_PTT(123, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
388 /* IPv6 --> GRE/NAT -> MAC */
389 I40E_PTT(124, IP, IPV6, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
391 /* IPv6 --> GRE/NAT -> MAC -> IPv4 */
392 I40E_PTT(125, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
393 I40E_PTT(126, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
394 I40E_PTT(127, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
395 I40E_PTT_UNUSED_ENTRY(128),
396 I40E_PTT(129, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
397 I40E_PTT(130, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
398 I40E_PTT(131, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
400 /* IPv6 --> GRE/NAT -> MAC -> IPv6 */
401 I40E_PTT(132, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
402 I40E_PTT(133, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
403 I40E_PTT(134, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
404 I40E_PTT_UNUSED_ENTRY(135),
405 I40E_PTT(136, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
406 I40E_PTT(137, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
407 I40E_PTT(138, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
409 /* IPv6 --> GRE/NAT -> MAC/VLAN */
410 I40E_PTT(139, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
412 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv4 */
413 I40E_PTT(140, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
414 I40E_PTT(141, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
415 I40E_PTT(142, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
416 I40E_PTT_UNUSED_ENTRY(143),
417 I40E_PTT(144, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
418 I40E_PTT(145, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
419 I40E_PTT(146, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
421 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv6 */
422 I40E_PTT(147, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
423 I40E_PTT(148, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
424 I40E_PTT(149, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
425 I40E_PTT_UNUSED_ENTRY(150),
426 I40E_PTT(151, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
427 I40E_PTT(152, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
428 I40E_PTT(153, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
431 I40E_PTT_UNUSED_ENTRY(154),
432 I40E_PTT_UNUSED_ENTRY(155),
433 I40E_PTT_UNUSED_ENTRY(156),
434 I40E_PTT_UNUSED_ENTRY(157),
435 I40E_PTT_UNUSED_ENTRY(158),
436 I40E_PTT_UNUSED_ENTRY(159),
438 I40E_PTT_UNUSED_ENTRY(160),
439 I40E_PTT_UNUSED_ENTRY(161),
440 I40E_PTT_UNUSED_ENTRY(162),
441 I40E_PTT_UNUSED_ENTRY(163),
442 I40E_PTT_UNUSED_ENTRY(164),
443 I40E_PTT_UNUSED_ENTRY(165),
444 I40E_PTT_UNUSED_ENTRY(166),
445 I40E_PTT_UNUSED_ENTRY(167),
446 I40E_PTT_UNUSED_ENTRY(168),
447 I40E_PTT_UNUSED_ENTRY(169),
449 I40E_PTT_UNUSED_ENTRY(170),
450 I40E_PTT_UNUSED_ENTRY(171),
451 I40E_PTT_UNUSED_ENTRY(172),
452 I40E_PTT_UNUSED_ENTRY(173),
453 I40E_PTT_UNUSED_ENTRY(174),
454 I40E_PTT_UNUSED_ENTRY(175),
455 I40E_PTT_UNUSED_ENTRY(176),
456 I40E_PTT_UNUSED_ENTRY(177),
457 I40E_PTT_UNUSED_ENTRY(178),
458 I40E_PTT_UNUSED_ENTRY(179),
460 I40E_PTT_UNUSED_ENTRY(180),
461 I40E_PTT_UNUSED_ENTRY(181),
462 I40E_PTT_UNUSED_ENTRY(182),
463 I40E_PTT_UNUSED_ENTRY(183),
464 I40E_PTT_UNUSED_ENTRY(184),
465 I40E_PTT_UNUSED_ENTRY(185),
466 I40E_PTT_UNUSED_ENTRY(186),
467 I40E_PTT_UNUSED_ENTRY(187),
468 I40E_PTT_UNUSED_ENTRY(188),
469 I40E_PTT_UNUSED_ENTRY(189),
471 I40E_PTT_UNUSED_ENTRY(190),
472 I40E_PTT_UNUSED_ENTRY(191),
473 I40E_PTT_UNUSED_ENTRY(192),
474 I40E_PTT_UNUSED_ENTRY(193),
475 I40E_PTT_UNUSED_ENTRY(194),
476 I40E_PTT_UNUSED_ENTRY(195),
477 I40E_PTT_UNUSED_ENTRY(196),
478 I40E_PTT_UNUSED_ENTRY(197),
479 I40E_PTT_UNUSED_ENTRY(198),
480 I40E_PTT_UNUSED_ENTRY(199),
482 I40E_PTT_UNUSED_ENTRY(200),
483 I40E_PTT_UNUSED_ENTRY(201),
484 I40E_PTT_UNUSED_ENTRY(202),
485 I40E_PTT_UNUSED_ENTRY(203),
486 I40E_PTT_UNUSED_ENTRY(204),
487 I40E_PTT_UNUSED_ENTRY(205),
488 I40E_PTT_UNUSED_ENTRY(206),
489 I40E_PTT_UNUSED_ENTRY(207),
490 I40E_PTT_UNUSED_ENTRY(208),
491 I40E_PTT_UNUSED_ENTRY(209),
493 I40E_PTT_UNUSED_ENTRY(210),
494 I40E_PTT_UNUSED_ENTRY(211),
495 I40E_PTT_UNUSED_ENTRY(212),
496 I40E_PTT_UNUSED_ENTRY(213),
497 I40E_PTT_UNUSED_ENTRY(214),
498 I40E_PTT_UNUSED_ENTRY(215),
499 I40E_PTT_UNUSED_ENTRY(216),
500 I40E_PTT_UNUSED_ENTRY(217),
501 I40E_PTT_UNUSED_ENTRY(218),
502 I40E_PTT_UNUSED_ENTRY(219),
504 I40E_PTT_UNUSED_ENTRY(220),
505 I40E_PTT_UNUSED_ENTRY(221),
506 I40E_PTT_UNUSED_ENTRY(222),
507 I40E_PTT_UNUSED_ENTRY(223),
508 I40E_PTT_UNUSED_ENTRY(224),
509 I40E_PTT_UNUSED_ENTRY(225),
510 I40E_PTT_UNUSED_ENTRY(226),
511 I40E_PTT_UNUSED_ENTRY(227),
512 I40E_PTT_UNUSED_ENTRY(228),
513 I40E_PTT_UNUSED_ENTRY(229),
515 I40E_PTT_UNUSED_ENTRY(230),
516 I40E_PTT_UNUSED_ENTRY(231),
517 I40E_PTT_UNUSED_ENTRY(232),
518 I40E_PTT_UNUSED_ENTRY(233),
519 I40E_PTT_UNUSED_ENTRY(234),
520 I40E_PTT_UNUSED_ENTRY(235),
521 I40E_PTT_UNUSED_ENTRY(236),
522 I40E_PTT_UNUSED_ENTRY(237),
523 I40E_PTT_UNUSED_ENTRY(238),
524 I40E_PTT_UNUSED_ENTRY(239),
526 I40E_PTT_UNUSED_ENTRY(240),
527 I40E_PTT_UNUSED_ENTRY(241),
528 I40E_PTT_UNUSED_ENTRY(242),
529 I40E_PTT_UNUSED_ENTRY(243),
530 I40E_PTT_UNUSED_ENTRY(244),
531 I40E_PTT_UNUSED_ENTRY(245),
532 I40E_PTT_UNUSED_ENTRY(246),
533 I40E_PTT_UNUSED_ENTRY(247),
534 I40E_PTT_UNUSED_ENTRY(248),
535 I40E_PTT_UNUSED_ENTRY(249),
537 I40E_PTT_UNUSED_ENTRY(250),
538 I40E_PTT_UNUSED_ENTRY(251),
539 I40E_PTT_UNUSED_ENTRY(252),
540 I40E_PTT_UNUSED_ENTRY(253),
541 I40E_PTT_UNUSED_ENTRY(254),
542 I40E_PTT_UNUSED_ENTRY(255)
545 #ifdef I40E_TPH_SUPPORT
549 * @hw: pointer to the hw struct
551 * Check to see if TPH capability is present.
553 bool i40e_tph_present(struct i40e_hw *hw)
555 u32 capsup = rd32(hw, I40E_GLPCI_CAPSUP);
557 return capsup & I40E_GLPCI_CAPSUP_TPH_EN_MASK;
562 * @hw: pointer to the hw struct
563 * @tph_control: contents of TPH Requester Control Register
565 * Check to see if TPH can be enabled; if so, enable it.
567 bool i40e_enable_tph(struct i40e_hw *hw, u32 tph_control)
569 u32 gltph, st_mode, permit;
571 /* check that TPH is permitted */
572 permit = (tph_control & I40E_TPH_REQ_ENA_MASK)
573 >> I40E_TPH_REQ_ENA_SHIFT;
574 if (!(permit & I40E_TPH_REQ_PERMIT))
577 /* check for valid ST mode */
578 st_mode = tph_control & I40E_TPH_ST_MODE_MASK;
579 if ((st_mode != I40E_TPH_MODE_NOTABLE) &&
580 (st_mode != I40E_TPH_MODE_DEVSPEC))
583 /* TPH may be enabled */
584 gltph = rd32(hw, I40E_GLTPH_CTRL);
586 /* turn off device-specific */
587 if (st_mode != I40E_TPH_MODE_DEVSPEC)
588 gltph &= ~I40E_GLTPH_CTRL_TPH_DEVSPEC_MASK;
590 /* This enables TPH for all queues for the given types of operation.
591 * Additional enabling is done per-queue in setup of the queue contexts.
593 gltph |= I40E_GLTPH_CTRL_DESC_PH_MASK; /* descriptor reads/writes */
594 gltph |= I40E_GLTPH_CTRL_DATA_PH_MASK; /* data reads/writes */
595 wr32(hw, I40E_GLTPH_CTRL, gltph);
599 #endif /* I40E_TPH_SUPPORT */
603 * i40e_init_shared_code - Initialize the shared code
604 * @hw: pointer to hardware structure
606 * This assigns the MAC type and PHY code and inits the NVM.
607 * Does not touch the hardware. This function must be called prior to any
608 * other function in the shared code. The i40e_hw structure should be
609 * memset to 0 prior to calling this function. The following fields in
610 * hw structure should be filled in prior to calling this function:
611 * hw_addr, back, device_id, vendor_id, subsystem_device_id,
612 * subsystem_vendor_id, and revision_id
614 enum i40e_status_code i40e_init_shared_code(struct i40e_hw *hw)
616 enum i40e_status_code status = I40E_SUCCESS;
619 DEBUGFUNC("i40e_init_shared_code");
621 i40e_set_mac_type(hw);
623 switch (hw->mac.type) {
627 return I40E_ERR_DEVICE_NOT_SUPPORTED;
631 hw->phy.get_link_info = true;
633 /* Determine port number */
634 reg = rd32(hw, I40E_PFGEN_PORTNUM);
635 reg = ((reg & I40E_PFGEN_PORTNUM_PORT_NUM_MASK) >>
636 I40E_PFGEN_PORTNUM_PORT_NUM_SHIFT);
639 /* Determine the PF number based on the PCI fn */
640 reg = rd32(hw, I40E_GLPCI_CAPSUP);
641 if (reg & I40E_GLPCI_CAPSUP_ARI_EN_MASK)
642 hw->pf_id = (u8)((hw->bus.device << 3) | hw->bus.func);
644 hw->pf_id = (u8)hw->bus.func;
646 status = i40e_init_nvm(hw);
651 * i40e_aq_mac_address_read - Retrieve the MAC addresses
652 * @hw: pointer to the hw struct
653 * @flags: a return indicator of what addresses were added to the addr store
654 * @addrs: the requestor's mac addr store
655 * @cmd_details: pointer to command details structure or NULL
657 STATIC enum i40e_status_code i40e_aq_mac_address_read(struct i40e_hw *hw,
659 struct i40e_aqc_mac_address_read_data *addrs,
660 struct i40e_asq_cmd_details *cmd_details)
662 struct i40e_aq_desc desc;
663 struct i40e_aqc_mac_address_read *cmd_data =
664 (struct i40e_aqc_mac_address_read *)&desc.params.raw;
665 enum i40e_status_code status;
667 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_mac_address_read);
668 desc.flags |= CPU_TO_LE16(I40E_AQ_FLAG_BUF);
670 status = i40e_asq_send_command(hw, &desc, addrs,
671 sizeof(*addrs), cmd_details);
672 *flags = LE16_TO_CPU(cmd_data->command_flags);
678 * i40e_aq_mac_address_write - Change the MAC addresses
679 * @hw: pointer to the hw struct
680 * @flags: indicates which MAC to be written
681 * @mac_addr: address to write
682 * @cmd_details: pointer to command details structure or NULL
684 enum i40e_status_code i40e_aq_mac_address_write(struct i40e_hw *hw,
685 u16 flags, u8 *mac_addr,
686 struct i40e_asq_cmd_details *cmd_details)
688 struct i40e_aq_desc desc;
689 struct i40e_aqc_mac_address_write *cmd_data =
690 (struct i40e_aqc_mac_address_write *)&desc.params.raw;
691 enum i40e_status_code status;
693 i40e_fill_default_direct_cmd_desc(&desc,
694 i40e_aqc_opc_mac_address_write);
695 cmd_data->command_flags = CPU_TO_LE16(flags);
696 cmd_data->mac_sah = CPU_TO_LE16((u16)mac_addr[0] << 8 | mac_addr[1]);
697 cmd_data->mac_sal = CPU_TO_LE32(((u32)mac_addr[2] << 24) |
698 ((u32)mac_addr[3] << 16) |
699 ((u32)mac_addr[4] << 8) |
702 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
708 * i40e_get_mac_addr - get MAC address
709 * @hw: pointer to the HW structure
710 * @mac_addr: pointer to MAC address
712 * Reads the adapter's MAC address from register
714 enum i40e_status_code i40e_get_mac_addr(struct i40e_hw *hw, u8 *mac_addr)
716 struct i40e_aqc_mac_address_read_data addrs;
717 enum i40e_status_code status;
720 status = i40e_aq_mac_address_read(hw, &flags, &addrs, NULL);
722 if (flags & I40E_AQC_LAN_ADDR_VALID)
723 memcpy(mac_addr, &addrs.pf_lan_mac, sizeof(addrs.pf_lan_mac));
729 * i40e_get_port_mac_addr - get Port MAC address
730 * @hw: pointer to the HW structure
731 * @mac_addr: pointer to Port MAC address
733 * Reads the adapter's Port MAC address
735 enum i40e_status_code i40e_get_port_mac_addr(struct i40e_hw *hw, u8 *mac_addr)
737 struct i40e_aqc_mac_address_read_data addrs;
738 enum i40e_status_code status;
741 status = i40e_aq_mac_address_read(hw, &flags, &addrs, NULL);
745 if (flags & I40E_AQC_PORT_ADDR_VALID)
746 memcpy(mac_addr, &addrs.port_mac, sizeof(addrs.port_mac));
748 status = I40E_ERR_INVALID_MAC_ADDR;
754 * i40e_pre_tx_queue_cfg - pre tx queue configure
755 * @hw: pointer to the HW structure
756 * @queue: target pf queue index
757 * @enable: state change request
759 * Handles hw requirement to indicate intention to enable
760 * or disable target queue.
762 void i40e_pre_tx_queue_cfg(struct i40e_hw *hw, u32 queue, bool enable)
764 u32 abs_queue_idx = hw->func_caps.base_queue + queue;
768 if (abs_queue_idx >= 128) {
769 reg_block = abs_queue_idx / 128;
770 abs_queue_idx %= 128;
773 reg_val = rd32(hw, I40E_GLLAN_TXPRE_QDIS(reg_block));
774 reg_val &= ~I40E_GLLAN_TXPRE_QDIS_QINDX_MASK;
775 reg_val |= (abs_queue_idx << I40E_GLLAN_TXPRE_QDIS_QINDX_SHIFT);
778 reg_val |= I40E_GLLAN_TXPRE_QDIS_CLEAR_QDIS_MASK;
780 reg_val |= I40E_GLLAN_TXPRE_QDIS_SET_QDIS_MASK;
782 wr32(hw, I40E_GLLAN_TXPRE_QDIS(reg_block), reg_val);
786 * i40e_validate_mac_addr - Validate unicast MAC address
787 * @mac_addr: pointer to MAC address
789 * Tests a MAC address to ensure it is a valid Individual Address
791 enum i40e_status_code i40e_validate_mac_addr(u8 *mac_addr)
793 enum i40e_status_code status = I40E_SUCCESS;
795 DEBUGFUNC("i40e_validate_mac_addr");
797 /* Broadcast addresses ARE multicast addresses
798 * Make sure it is not a multicast address
799 * Reject the zero address
801 if (I40E_IS_MULTICAST(mac_addr) ||
802 (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&
803 mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0))
804 status = I40E_ERR_INVALID_MAC_ADDR;
810 * i40e_get_media_type - Gets media type
811 * @hw: pointer to the hardware structure
813 STATIC enum i40e_media_type i40e_get_media_type(struct i40e_hw *hw)
815 enum i40e_media_type media;
817 switch (hw->phy.link_info.phy_type) {
818 case I40E_PHY_TYPE_10GBASE_SR:
819 case I40E_PHY_TYPE_10GBASE_LR:
820 case I40E_PHY_TYPE_40GBASE_SR4:
821 case I40E_PHY_TYPE_40GBASE_LR4:
822 media = I40E_MEDIA_TYPE_FIBER;
824 case I40E_PHY_TYPE_100BASE_TX:
825 case I40E_PHY_TYPE_1000BASE_T:
826 case I40E_PHY_TYPE_10GBASE_T:
827 media = I40E_MEDIA_TYPE_BASET;
829 case I40E_PHY_TYPE_10GBASE_CR1_CU:
830 case I40E_PHY_TYPE_40GBASE_CR4_CU:
831 case I40E_PHY_TYPE_10GBASE_CR1:
832 case I40E_PHY_TYPE_40GBASE_CR4:
833 case I40E_PHY_TYPE_10GBASE_SFPP_CU:
834 media = I40E_MEDIA_TYPE_DA;
836 case I40E_PHY_TYPE_1000BASE_KX:
837 case I40E_PHY_TYPE_10GBASE_KX4:
838 case I40E_PHY_TYPE_10GBASE_KR:
839 case I40E_PHY_TYPE_40GBASE_KR4:
840 media = I40E_MEDIA_TYPE_BACKPLANE;
842 case I40E_PHY_TYPE_SGMII:
843 case I40E_PHY_TYPE_XAUI:
844 case I40E_PHY_TYPE_XFI:
845 case I40E_PHY_TYPE_XLAUI:
846 case I40E_PHY_TYPE_XLPPI:
848 media = I40E_MEDIA_TYPE_UNKNOWN;
855 #define I40E_PF_RESET_WAIT_COUNT 100
857 * i40e_pf_reset - Reset the PF
858 * @hw: pointer to the hardware structure
860 * Assuming someone else has triggered a global reset,
861 * assure the global reset is complete and then reset the PF
863 enum i40e_status_code i40e_pf_reset(struct i40e_hw *hw)
870 /* Poll for Global Reset steady state in case of recent GRST.
871 * The grst delay value is in 100ms units, and we'll wait a
872 * couple counts longer to be sure we don't just miss the end.
874 grst_del = rd32(hw, I40E_GLGEN_RSTCTL) & I40E_GLGEN_RSTCTL_GRSTDEL_MASK
875 >> I40E_GLGEN_RSTCTL_GRSTDEL_SHIFT;
876 for (cnt = 0; cnt < grst_del + 2; cnt++) {
877 reg = rd32(hw, I40E_GLGEN_RSTAT);
878 if (!(reg & I40E_GLGEN_RSTAT_DEVSTATE_MASK))
880 i40e_msec_delay(100);
882 if (reg & I40E_GLGEN_RSTAT_DEVSTATE_MASK) {
883 DEBUGOUT("Global reset polling failed to complete.\n");
884 return I40E_ERR_RESET_FAILED;
887 /* Now Wait for the FW to be ready */
888 for (cnt1 = 0; cnt1 < I40E_PF_RESET_WAIT_COUNT; cnt1++) {
889 reg = rd32(hw, I40E_GLNVM_ULD);
890 reg &= (I40E_GLNVM_ULD_CONF_CORE_DONE_MASK |
891 I40E_GLNVM_ULD_CONF_GLOBAL_DONE_MASK);
892 if (reg == (I40E_GLNVM_ULD_CONF_CORE_DONE_MASK |
893 I40E_GLNVM_ULD_CONF_GLOBAL_DONE_MASK)) {
894 DEBUGOUT1("Core and Global modules ready %d\n", cnt1);
899 if (!(reg & (I40E_GLNVM_ULD_CONF_CORE_DONE_MASK |
900 I40E_GLNVM_ULD_CONF_GLOBAL_DONE_MASK))) {
901 DEBUGOUT("wait for FW Reset complete timedout\n");
902 DEBUGOUT1("I40E_GLNVM_ULD = 0x%x\n", reg);
903 return I40E_ERR_RESET_FAILED;
906 /* If there was a Global Reset in progress when we got here,
907 * we don't need to do the PF Reset
910 reg = rd32(hw, I40E_PFGEN_CTRL);
911 wr32(hw, I40E_PFGEN_CTRL,
912 (reg | I40E_PFGEN_CTRL_PFSWR_MASK));
913 for (cnt = 0; cnt < I40E_PF_RESET_WAIT_COUNT; cnt++) {
914 reg = rd32(hw, I40E_PFGEN_CTRL);
915 if (!(reg & I40E_PFGEN_CTRL_PFSWR_MASK))
919 if (reg & I40E_PFGEN_CTRL_PFSWR_MASK) {
920 DEBUGOUT("PF reset polling failed to complete.\n");
921 return I40E_ERR_RESET_FAILED;
925 #if !defined(QV_RELEASE) && !defined(PREBOOT_SUPPORT)
926 i40e_clear_pxe_mode(hw);
934 * i40e_clear_hw - clear out any left over hw state
935 * @hw: pointer to the hw struct
937 * Clear queues and interrupts, typically called at init time,
938 * but after the capabilities have been found so we know how many
939 * queues and msix vectors have been allocated.
941 void i40e_clear_hw(struct i40e_hw *hw)
943 u32 num_queues, base_queue;
951 /* get number of interrupts, queues, and vfs */
952 val = rd32(hw, I40E_GLPCI_CNF2);
953 num_pf_int = (val & I40E_GLPCI_CNF2_MSI_X_PF_N_MASK) >>
954 I40E_GLPCI_CNF2_MSI_X_PF_N_SHIFT;
955 num_vf_int = (val & I40E_GLPCI_CNF2_MSI_X_VF_N_MASK) >>
956 I40E_GLPCI_CNF2_MSI_X_VF_N_SHIFT;
958 val = rd32(hw, I40E_PFLAN_QALLOC);
959 base_queue = (val & I40E_PFLAN_QALLOC_FIRSTQ_MASK) >>
960 I40E_PFLAN_QALLOC_FIRSTQ_SHIFT;
961 j = (val & I40E_PFLAN_QALLOC_LASTQ_MASK) >>
962 I40E_PFLAN_QALLOC_LASTQ_SHIFT;
963 if (val & I40E_PFLAN_QALLOC_VALID_MASK)
964 num_queues = (j - base_queue) + 1;
968 val = rd32(hw, I40E_PF_VT_PFALLOC);
969 i = (val & I40E_PF_VT_PFALLOC_FIRSTVF_MASK) >>
970 I40E_PF_VT_PFALLOC_FIRSTVF_SHIFT;
971 j = (val & I40E_PF_VT_PFALLOC_LASTVF_MASK) >>
972 I40E_PF_VT_PFALLOC_LASTVF_SHIFT;
973 if (val & I40E_PF_VT_PFALLOC_VALID_MASK)
974 num_vfs = (j - i) + 1;
978 /* stop all the interrupts */
979 wr32(hw, I40E_PFINT_ICR0_ENA, 0);
980 val = 0x3 << I40E_PFINT_DYN_CTLN_ITR_INDX_SHIFT;
981 for (i = 0; i < num_pf_int - 2; i++)
982 wr32(hw, I40E_PFINT_DYN_CTLN(i), val);
984 /* Set the FIRSTQ_INDX field to 0x7FF in PFINT_LNKLSTx */
985 val = eol << I40E_PFINT_LNKLST0_FIRSTQ_INDX_SHIFT;
986 wr32(hw, I40E_PFINT_LNKLST0, val);
987 for (i = 0; i < num_pf_int - 2; i++)
988 wr32(hw, I40E_PFINT_LNKLSTN(i), val);
989 val = eol << I40E_VPINT_LNKLST0_FIRSTQ_INDX_SHIFT;
990 for (i = 0; i < num_vfs; i++)
991 wr32(hw, I40E_VPINT_LNKLST0(i), val);
992 for (i = 0; i < num_vf_int - 2; i++)
993 wr32(hw, I40E_VPINT_LNKLSTN(i), val);
995 /* warn the HW of the coming Tx disables */
996 for (i = 0; i < num_queues; i++) {
997 u32 abs_queue_idx = base_queue + i;
1000 if (abs_queue_idx >= 128) {
1001 reg_block = abs_queue_idx / 128;
1002 abs_queue_idx %= 128;
1005 val = rd32(hw, I40E_GLLAN_TXPRE_QDIS(reg_block));
1006 val &= ~I40E_GLLAN_TXPRE_QDIS_QINDX_MASK;
1007 val |= (abs_queue_idx << I40E_GLLAN_TXPRE_QDIS_QINDX_SHIFT);
1008 val |= I40E_GLLAN_TXPRE_QDIS_SET_QDIS_MASK;
1010 wr32(hw, I40E_GLLAN_TXPRE_QDIS(reg_block), val);
1012 i40e_usec_delay(400);
1014 /* stop all the queues */
1015 for (i = 0; i < num_queues; i++) {
1016 wr32(hw, I40E_QINT_TQCTL(i), 0);
1017 wr32(hw, I40E_QTX_ENA(i), 0);
1018 wr32(hw, I40E_QINT_RQCTL(i), 0);
1019 wr32(hw, I40E_QRX_ENA(i), 0);
1022 /* short wait for all queue disables to settle */
1023 i40e_usec_delay(50);
1027 * i40e_clear_pxe_mode - clear pxe operations mode
1028 * @hw: pointer to the hw struct
1030 * Make sure all PXE mode settings are cleared, including things
1031 * like descriptor fetch/write-back mode.
1033 void i40e_clear_pxe_mode(struct i40e_hw *hw)
1035 if (i40e_check_asq_alive(hw))
1036 i40e_aq_clear_pxe_mode(hw, NULL);
1040 * i40e_led_is_mine - helper to find matching led
1041 * @hw: pointer to the hw struct
1042 * @idx: index into GPIO registers
1044 * returns: 0 if no match, otherwise the value of the GPIO_CTL register
1046 static u32 i40e_led_is_mine(struct i40e_hw *hw, int idx)
1051 if (!hw->func_caps.led[idx])
1054 gpio_val = rd32(hw, I40E_GLGEN_GPIO_CTL(idx));
1055 port = (gpio_val & I40E_GLGEN_GPIO_CTL_PRT_NUM_MASK) >>
1056 I40E_GLGEN_GPIO_CTL_PRT_NUM_SHIFT;
1058 /* if PRT_NUM_NA is 1 then this LED is not port specific, OR
1059 * if it is not our port then ignore
1061 if ((gpio_val & I40E_GLGEN_GPIO_CTL_PRT_NUM_NA_MASK) ||
1068 #define I40E_LED0 22
1069 #define I40E_LINK_ACTIVITY 0xC
1072 * i40e_led_get - return current on/off mode
1073 * @hw: pointer to the hw struct
1075 * The value returned is the 'mode' field as defined in the
1076 * GPIO register definitions: 0x0 = off, 0xf = on, and other
1077 * values are variations of possible behaviors relating to
1078 * blink, link, and wire.
1080 u32 i40e_led_get(struct i40e_hw *hw)
1085 /* as per the documentation GPIO 22-29 are the LED
1086 * GPIO pins named LED0..LED7
1088 for (i = I40E_LED0; i <= I40E_GLGEN_GPIO_CTL_MAX_INDEX; i++) {
1089 u32 gpio_val = i40e_led_is_mine(hw, i);
1094 mode = (gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK) >>
1095 I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT;
1103 * i40e_led_set - set new on/off mode
1104 * @hw: pointer to the hw struct
1105 * @mode: 0=off, 0xf=on (else see manual for mode details)
1106 * @blink: true if the LED should blink when on, false if steady
1108 * if this function is used to turn on the blink it should
1109 * be used to disable the blink when restoring the original state.
1111 void i40e_led_set(struct i40e_hw *hw, u32 mode, bool blink)
1115 if (mode & 0xfffffff0)
1116 DEBUGOUT1("invalid mode passed in %X\n", mode);
1118 /* as per the documentation GPIO 22-29 are the LED
1119 * GPIO pins named LED0..LED7
1121 for (i = I40E_LED0; i <= I40E_GLGEN_GPIO_CTL_MAX_INDEX; i++) {
1122 u32 gpio_val = i40e_led_is_mine(hw, i);
1127 gpio_val &= ~I40E_GLGEN_GPIO_CTL_LED_MODE_MASK;
1128 /* this & is a bit of paranoia, but serves as a range check */
1129 gpio_val |= ((mode << I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT) &
1130 I40E_GLGEN_GPIO_CTL_LED_MODE_MASK);
1132 if (mode == I40E_LINK_ACTIVITY)
1135 gpio_val |= (blink ? 1 : 0) <<
1136 I40E_GLGEN_GPIO_CTL_LED_BLINK_SHIFT;
1138 wr32(hw, I40E_GLGEN_GPIO_CTL(i), gpio_val);
1143 /* Admin command wrappers */
1146 * i40e_aq_get_phy_capabilities
1147 * @hw: pointer to the hw struct
1148 * @abilities: structure for PHY capabilities to be filled
1149 * @qualified_modules: report Qualified Modules
1150 * @report_init: report init capabilities (active are default)
1151 * @cmd_details: pointer to command details structure or NULL
1153 * Returns the various PHY abilities supported on the Port.
1155 enum i40e_status_code i40e_aq_get_phy_capabilities(struct i40e_hw *hw,
1156 bool qualified_modules, bool report_init,
1157 struct i40e_aq_get_phy_abilities_resp *abilities,
1158 struct i40e_asq_cmd_details *cmd_details)
1160 struct i40e_aq_desc desc;
1161 enum i40e_status_code status;
1162 u16 abilities_size = sizeof(struct i40e_aq_get_phy_abilities_resp);
1165 return I40E_ERR_PARAM;
1167 i40e_fill_default_direct_cmd_desc(&desc,
1168 i40e_aqc_opc_get_phy_abilities);
1170 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_BUF);
1171 if (abilities_size > I40E_AQ_LARGE_BUF)
1172 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
1174 if (qualified_modules)
1175 desc.params.external.param0 |=
1176 CPU_TO_LE32(I40E_AQ_PHY_REPORT_QUALIFIED_MODULES);
1179 desc.params.external.param0 |=
1180 CPU_TO_LE32(I40E_AQ_PHY_REPORT_INITIAL_VALUES);
1182 status = i40e_asq_send_command(hw, &desc, abilities, abilities_size,
1185 if (hw->aq.asq_last_status == I40E_AQ_RC_EIO)
1186 status = I40E_ERR_UNKNOWN_PHY;
1192 * i40e_aq_set_phy_config
1193 * @hw: pointer to the hw struct
1194 * @config: structure with PHY configuration to be set
1195 * @cmd_details: pointer to command details structure or NULL
1197 * Set the various PHY configuration parameters
1198 * supported on the Port.One or more of the Set PHY config parameters may be
1199 * ignored in an MFP mode as the PF may not have the privilege to set some
1200 * of the PHY Config parameters. This status will be indicated by the
1203 enum i40e_status_code i40e_aq_set_phy_config(struct i40e_hw *hw,
1204 struct i40e_aq_set_phy_config *config,
1205 struct i40e_asq_cmd_details *cmd_details)
1207 struct i40e_aq_desc desc;
1208 struct i40e_aq_set_phy_config *cmd =
1209 (struct i40e_aq_set_phy_config *)&desc.params.raw;
1210 enum i40e_status_code status;
1213 return I40E_ERR_PARAM;
1215 i40e_fill_default_direct_cmd_desc(&desc,
1216 i40e_aqc_opc_set_phy_config);
1220 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1227 * @hw: pointer to the hw struct
1229 * Set the requested flow control mode using set_phy_config.
1231 enum i40e_status_code i40e_set_fc(struct i40e_hw *hw, u8 *aq_failures,
1232 bool atomic_restart)
1234 enum i40e_fc_mode fc_mode = hw->fc.requested_mode;
1235 struct i40e_aq_get_phy_abilities_resp abilities;
1236 struct i40e_aq_set_phy_config config;
1237 enum i40e_status_code status;
1238 u8 pause_mask = 0x0;
1244 pause_mask |= I40E_AQ_PHY_FLAG_PAUSE_TX;
1245 pause_mask |= I40E_AQ_PHY_FLAG_PAUSE_RX;
1247 case I40E_FC_RX_PAUSE:
1248 pause_mask |= I40E_AQ_PHY_FLAG_PAUSE_RX;
1250 case I40E_FC_TX_PAUSE:
1251 pause_mask |= I40E_AQ_PHY_FLAG_PAUSE_TX;
1257 /* Get the current phy config */
1258 status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities,
1261 *aq_failures |= I40E_SET_FC_AQ_FAIL_GET1;
1265 memset(&config, 0, sizeof(struct i40e_aq_set_phy_config));
1266 /* clear the old pause settings */
1267 config.abilities = abilities.abilities & ~(I40E_AQ_PHY_FLAG_PAUSE_TX) &
1268 ~(I40E_AQ_PHY_FLAG_PAUSE_RX);
1269 /* set the new abilities */
1270 config.abilities |= pause_mask;
1271 /* If the abilities have changed, then set the new config */
1272 if (config.abilities != abilities.abilities) {
1273 /* Auto restart link so settings take effect */
1275 config.abilities |= I40E_AQ_PHY_ENABLE_ATOMIC_LINK;
1276 /* Copy over all the old settings */
1277 config.phy_type = abilities.phy_type;
1278 config.link_speed = abilities.link_speed;
1279 config.eee_capability = abilities.eee_capability;
1280 config.eeer = abilities.eeer_val;
1281 config.low_power_ctrl = abilities.d3_lpan;
1282 status = i40e_aq_set_phy_config(hw, &config, NULL);
1285 *aq_failures |= I40E_SET_FC_AQ_FAIL_SET;
1287 /* Get the abilities to set hw->fc.current_mode correctly */
1288 status = i40e_aq_get_phy_capabilities(hw, false, false,
1291 /* Wait a little bit and try once more */
1292 i40e_msec_delay(1000);
1293 status = i40e_aq_get_phy_capabilities(hw, false, false,
1297 *aq_failures |= I40E_SET_FC_AQ_FAIL_GET2;
1301 /* Copy the what was returned from get capabilities into fc */
1302 if ((abilities.abilities & I40E_AQ_PHY_FLAG_PAUSE_TX) &&
1303 (abilities.abilities & I40E_AQ_PHY_FLAG_PAUSE_RX))
1304 hw->fc.current_mode = I40E_FC_FULL;
1305 else if (abilities.abilities & I40E_AQ_PHY_FLAG_PAUSE_TX)
1306 hw->fc.current_mode = I40E_FC_TX_PAUSE;
1307 else if (abilities.abilities & I40E_AQ_PHY_FLAG_PAUSE_RX)
1308 hw->fc.current_mode = I40E_FC_RX_PAUSE;
1310 hw->fc.current_mode = I40E_FC_NONE;
1316 * i40e_aq_set_mac_config
1317 * @hw: pointer to the hw struct
1318 * @max_frame_size: Maximum Frame Size to be supported by the port
1319 * @crc_en: Tell HW to append a CRC to outgoing frames
1320 * @pacing: Pacing configurations
1321 * @cmd_details: pointer to command details structure or NULL
1323 * Configure MAC settings for frame size, jumbo frame support and the
1324 * addition of a CRC by the hardware.
1326 enum i40e_status_code i40e_aq_set_mac_config(struct i40e_hw *hw,
1328 bool crc_en, u16 pacing,
1329 struct i40e_asq_cmd_details *cmd_details)
1331 struct i40e_aq_desc desc;
1332 struct i40e_aq_set_mac_config *cmd =
1333 (struct i40e_aq_set_mac_config *)&desc.params.raw;
1334 enum i40e_status_code status;
1336 if (max_frame_size == 0)
1337 return I40E_ERR_PARAM;
1339 i40e_fill_default_direct_cmd_desc(&desc,
1340 i40e_aqc_opc_set_mac_config);
1342 cmd->max_frame_size = CPU_TO_LE16(max_frame_size);
1343 cmd->params = ((u8)pacing & 0x0F) << 3;
1345 cmd->params |= I40E_AQ_SET_MAC_CONFIG_CRC_EN;
1347 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1353 * i40e_aq_clear_pxe_mode
1354 * @hw: pointer to the hw struct
1355 * @cmd_details: pointer to command details structure or NULL
1357 * Tell the firmware that the driver is taking over from PXE
1359 enum i40e_status_code i40e_aq_clear_pxe_mode(struct i40e_hw *hw,
1360 struct i40e_asq_cmd_details *cmd_details)
1362 enum i40e_status_code status;
1363 struct i40e_aq_desc desc;
1364 struct i40e_aqc_clear_pxe *cmd =
1365 (struct i40e_aqc_clear_pxe *)&desc.params.raw;
1367 i40e_fill_default_direct_cmd_desc(&desc,
1368 i40e_aqc_opc_clear_pxe_mode);
1372 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1374 wr32(hw, I40E_GLLAN_RCTL_0, 0x1);
1380 * i40e_aq_set_link_restart_an
1381 * @hw: pointer to the hw struct
1382 * @enable_link: if true: enable link, if false: disable link
1383 * @cmd_details: pointer to command details structure or NULL
1385 * Sets up the link and restarts the Auto-Negotiation over the link.
1387 enum i40e_status_code i40e_aq_set_link_restart_an(struct i40e_hw *hw,
1388 bool enable_link, struct i40e_asq_cmd_details *cmd_details)
1390 struct i40e_aq_desc desc;
1391 struct i40e_aqc_set_link_restart_an *cmd =
1392 (struct i40e_aqc_set_link_restart_an *)&desc.params.raw;
1393 enum i40e_status_code status;
1395 i40e_fill_default_direct_cmd_desc(&desc,
1396 i40e_aqc_opc_set_link_restart_an);
1398 cmd->command = I40E_AQ_PHY_RESTART_AN;
1400 cmd->command |= I40E_AQ_PHY_LINK_ENABLE;
1402 cmd->command &= ~I40E_AQ_PHY_LINK_ENABLE;
1404 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1410 * i40e_aq_get_link_info
1411 * @hw: pointer to the hw struct
1412 * @enable_lse: enable/disable LinkStatusEvent reporting
1413 * @link: pointer to link status structure - optional
1414 * @cmd_details: pointer to command details structure or NULL
1416 * Returns the link status of the adapter.
1418 enum i40e_status_code i40e_aq_get_link_info(struct i40e_hw *hw,
1419 bool enable_lse, struct i40e_link_status *link,
1420 struct i40e_asq_cmd_details *cmd_details)
1422 struct i40e_aq_desc desc;
1423 struct i40e_aqc_get_link_status *resp =
1424 (struct i40e_aqc_get_link_status *)&desc.params.raw;
1425 struct i40e_link_status *hw_link_info = &hw->phy.link_info;
1426 enum i40e_status_code status;
1427 bool tx_pause, rx_pause;
1430 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_get_link_status);
1433 command_flags = I40E_AQ_LSE_ENABLE;
1435 command_flags = I40E_AQ_LSE_DISABLE;
1436 resp->command_flags = CPU_TO_LE16(command_flags);
1438 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1440 if (status != I40E_SUCCESS)
1441 goto aq_get_link_info_exit;
1443 /* save off old link status information */
1444 i40e_memcpy(&hw->phy.link_info_old, hw_link_info,
1445 sizeof(struct i40e_link_status), I40E_NONDMA_TO_NONDMA);
1447 /* update link status */
1448 hw_link_info->phy_type = (enum i40e_aq_phy_type)resp->phy_type;
1449 hw->phy.media_type = i40e_get_media_type(hw);
1450 hw_link_info->link_speed = (enum i40e_aq_link_speed)resp->link_speed;
1451 hw_link_info->link_info = resp->link_info;
1452 hw_link_info->an_info = resp->an_info;
1453 hw_link_info->ext_info = resp->ext_info;
1454 hw_link_info->loopback = resp->loopback;
1455 hw_link_info->max_frame_size = LE16_TO_CPU(resp->max_frame_size);
1456 hw_link_info->pacing = resp->config & I40E_AQ_CONFIG_PACING_MASK;
1458 /* update fc info */
1459 tx_pause = !!(resp->an_info & I40E_AQ_LINK_PAUSE_TX);
1460 rx_pause = !!(resp->an_info & I40E_AQ_LINK_PAUSE_RX);
1461 if (tx_pause & rx_pause)
1462 hw->fc.current_mode = I40E_FC_FULL;
1464 hw->fc.current_mode = I40E_FC_TX_PAUSE;
1466 hw->fc.current_mode = I40E_FC_RX_PAUSE;
1468 hw->fc.current_mode = I40E_FC_NONE;
1470 if (resp->config & I40E_AQ_CONFIG_CRC_ENA)
1471 hw_link_info->crc_enable = true;
1473 hw_link_info->crc_enable = false;
1475 if (resp->command_flags & CPU_TO_LE16(I40E_AQ_LSE_ENABLE))
1476 hw_link_info->lse_enable = true;
1478 hw_link_info->lse_enable = false;
1480 /* save link status information */
1482 i40e_memcpy(link, hw_link_info, sizeof(struct i40e_link_status),
1483 I40E_NONDMA_TO_NONDMA);
1485 /* flag cleared so helper functions don't call AQ again */
1486 hw->phy.get_link_info = false;
1488 aq_get_link_info_exit:
1493 * i40e_update_link_info
1494 * @hw: pointer to the hw struct
1495 * @enable_lse: enable/disable LinkStatusEvent reporting
1497 * Returns the link status of the adapter
1499 enum i40e_status_code i40e_update_link_info(struct i40e_hw *hw,
1502 struct i40e_aq_get_phy_abilities_resp abilities;
1503 enum i40e_status_code status;
1505 status = i40e_aq_get_link_info(hw, enable_lse, NULL, NULL);
1509 status = i40e_aq_get_phy_capabilities(hw, false, false,
1514 if (abilities.abilities & I40E_AQ_PHY_AN_ENABLED)
1515 hw->phy.link_info.an_enabled = true;
1517 hw->phy.link_info.an_enabled = false;
1523 * i40e_aq_set_phy_int_mask
1524 * @hw: pointer to the hw struct
1525 * @mask: interrupt mask to be set
1526 * @cmd_details: pointer to command details structure or NULL
1528 * Set link interrupt mask.
1530 enum i40e_status_code i40e_aq_set_phy_int_mask(struct i40e_hw *hw,
1532 struct i40e_asq_cmd_details *cmd_details)
1534 struct i40e_aq_desc desc;
1535 struct i40e_aqc_set_phy_int_mask *cmd =
1536 (struct i40e_aqc_set_phy_int_mask *)&desc.params.raw;
1537 enum i40e_status_code status;
1539 i40e_fill_default_direct_cmd_desc(&desc,
1540 i40e_aqc_opc_set_phy_int_mask);
1542 cmd->event_mask = CPU_TO_LE16(mask);
1544 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1550 * i40e_aq_get_local_advt_reg
1551 * @hw: pointer to the hw struct
1552 * @advt_reg: local AN advertisement register value
1553 * @cmd_details: pointer to command details structure or NULL
1555 * Get the Local AN advertisement register value.
1557 enum i40e_status_code i40e_aq_get_local_advt_reg(struct i40e_hw *hw,
1559 struct i40e_asq_cmd_details *cmd_details)
1561 struct i40e_aq_desc desc;
1562 struct i40e_aqc_an_advt_reg *resp =
1563 (struct i40e_aqc_an_advt_reg *)&desc.params.raw;
1564 enum i40e_status_code status;
1566 i40e_fill_default_direct_cmd_desc(&desc,
1567 i40e_aqc_opc_get_local_advt_reg);
1569 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1571 if (status != I40E_SUCCESS)
1572 goto aq_get_local_advt_reg_exit;
1574 *advt_reg = (u64)(LE16_TO_CPU(resp->local_an_reg1)) << 32;
1575 *advt_reg |= LE32_TO_CPU(resp->local_an_reg0);
1577 aq_get_local_advt_reg_exit:
1582 * i40e_aq_set_local_advt_reg
1583 * @hw: pointer to the hw struct
1584 * @advt_reg: local AN advertisement register value
1585 * @cmd_details: pointer to command details structure or NULL
1587 * Get the Local AN advertisement register value.
1589 enum i40e_status_code i40e_aq_set_local_advt_reg(struct i40e_hw *hw,
1591 struct i40e_asq_cmd_details *cmd_details)
1593 struct i40e_aq_desc desc;
1594 struct i40e_aqc_an_advt_reg *cmd =
1595 (struct i40e_aqc_an_advt_reg *)&desc.params.raw;
1596 enum i40e_status_code status;
1598 i40e_fill_default_direct_cmd_desc(&desc,
1599 i40e_aqc_opc_get_local_advt_reg);
1601 cmd->local_an_reg0 = CPU_TO_LE32(I40E_LO_DWORD(advt_reg));
1602 cmd->local_an_reg1 = CPU_TO_LE16(I40E_HI_DWORD(advt_reg));
1604 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1610 * i40e_aq_get_partner_advt
1611 * @hw: pointer to the hw struct
1612 * @advt_reg: AN partner advertisement register value
1613 * @cmd_details: pointer to command details structure or NULL
1615 * Get the link partner AN advertisement register value.
1617 enum i40e_status_code i40e_aq_get_partner_advt(struct i40e_hw *hw,
1619 struct i40e_asq_cmd_details *cmd_details)
1621 struct i40e_aq_desc desc;
1622 struct i40e_aqc_an_advt_reg *resp =
1623 (struct i40e_aqc_an_advt_reg *)&desc.params.raw;
1624 enum i40e_status_code status;
1626 i40e_fill_default_direct_cmd_desc(&desc,
1627 i40e_aqc_opc_get_partner_advt);
1629 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1631 if (status != I40E_SUCCESS)
1632 goto aq_get_partner_advt_exit;
1634 *advt_reg = (u64)(LE16_TO_CPU(resp->local_an_reg1)) << 32;
1635 *advt_reg |= LE32_TO_CPU(resp->local_an_reg0);
1637 aq_get_partner_advt_exit:
1642 * i40e_aq_set_lb_modes
1643 * @hw: pointer to the hw struct
1644 * @lb_modes: loopback mode to be set
1645 * @cmd_details: pointer to command details structure or NULL
1647 * Sets loopback modes.
1649 enum i40e_status_code i40e_aq_set_lb_modes(struct i40e_hw *hw,
1651 struct i40e_asq_cmd_details *cmd_details)
1653 struct i40e_aq_desc desc;
1654 struct i40e_aqc_set_lb_mode *cmd =
1655 (struct i40e_aqc_set_lb_mode *)&desc.params.raw;
1656 enum i40e_status_code status;
1658 i40e_fill_default_direct_cmd_desc(&desc,
1659 i40e_aqc_opc_set_lb_modes);
1661 cmd->lb_mode = CPU_TO_LE16(lb_modes);
1663 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1669 * i40e_aq_set_phy_debug
1670 * @hw: pointer to the hw struct
1671 * @cmd_flags: debug command flags
1672 * @cmd_details: pointer to command details structure or NULL
1674 * Reset the external PHY.
1676 enum i40e_status_code i40e_aq_set_phy_debug(struct i40e_hw *hw, u8 cmd_flags,
1677 struct i40e_asq_cmd_details *cmd_details)
1679 struct i40e_aq_desc desc;
1680 struct i40e_aqc_set_phy_debug *cmd =
1681 (struct i40e_aqc_set_phy_debug *)&desc.params.raw;
1682 enum i40e_status_code status;
1684 i40e_fill_default_direct_cmd_desc(&desc,
1685 i40e_aqc_opc_set_phy_debug);
1687 cmd->command_flags = cmd_flags;
1689 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1696 * @hw: pointer to the hw struct
1697 * @vsi_ctx: pointer to a vsi context struct
1698 * @cmd_details: pointer to command details structure or NULL
1700 * Add a VSI context to the hardware.
1702 enum i40e_status_code i40e_aq_add_vsi(struct i40e_hw *hw,
1703 struct i40e_vsi_context *vsi_ctx,
1704 struct i40e_asq_cmd_details *cmd_details)
1706 struct i40e_aq_desc desc;
1707 struct i40e_aqc_add_get_update_vsi *cmd =
1708 (struct i40e_aqc_add_get_update_vsi *)&desc.params.raw;
1709 struct i40e_aqc_add_get_update_vsi_completion *resp =
1710 (struct i40e_aqc_add_get_update_vsi_completion *)
1712 enum i40e_status_code status;
1714 i40e_fill_default_direct_cmd_desc(&desc,
1715 i40e_aqc_opc_add_vsi);
1717 cmd->uplink_seid = CPU_TO_LE16(vsi_ctx->uplink_seid);
1718 cmd->connection_type = vsi_ctx->connection_type;
1719 cmd->vf_id = vsi_ctx->vf_num;
1720 cmd->vsi_flags = CPU_TO_LE16(vsi_ctx->flags);
1722 desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
1724 status = i40e_asq_send_command(hw, &desc, &vsi_ctx->info,
1725 sizeof(vsi_ctx->info), cmd_details);
1727 if (status != I40E_SUCCESS)
1728 goto aq_add_vsi_exit;
1730 vsi_ctx->seid = LE16_TO_CPU(resp->seid);
1731 vsi_ctx->vsi_number = LE16_TO_CPU(resp->vsi_number);
1732 vsi_ctx->vsis_allocated = LE16_TO_CPU(resp->vsi_used);
1733 vsi_ctx->vsis_unallocated = LE16_TO_CPU(resp->vsi_free);
1740 * i40e_aq_set_default_vsi
1741 * @hw: pointer to the hw struct
1743 * @cmd_details: pointer to command details structure or NULL
1745 enum i40e_status_code i40e_aq_set_default_vsi(struct i40e_hw *hw,
1747 struct i40e_asq_cmd_details *cmd_details)
1749 struct i40e_aq_desc desc;
1750 struct i40e_aqc_set_vsi_promiscuous_modes *cmd =
1751 (struct i40e_aqc_set_vsi_promiscuous_modes *)
1753 enum i40e_status_code status;
1755 i40e_fill_default_direct_cmd_desc(&desc,
1756 i40e_aqc_opc_set_vsi_promiscuous_modes);
1758 cmd->promiscuous_flags = CPU_TO_LE16(I40E_AQC_SET_VSI_DEFAULT);
1759 cmd->valid_flags = CPU_TO_LE16(I40E_AQC_SET_VSI_DEFAULT);
1760 cmd->seid = CPU_TO_LE16(seid);
1762 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1768 * i40e_aq_set_vsi_unicast_promiscuous
1769 * @hw: pointer to the hw struct
1771 * @set: set unicast promiscuous enable/disable
1772 * @cmd_details: pointer to command details structure or NULL
1774 enum i40e_status_code i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw,
1776 struct i40e_asq_cmd_details *cmd_details)
1778 struct i40e_aq_desc desc;
1779 struct i40e_aqc_set_vsi_promiscuous_modes *cmd =
1780 (struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw;
1781 enum i40e_status_code status;
1784 i40e_fill_default_direct_cmd_desc(&desc,
1785 i40e_aqc_opc_set_vsi_promiscuous_modes);
1788 flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST;
1790 cmd->promiscuous_flags = CPU_TO_LE16(flags);
1792 cmd->valid_flags = CPU_TO_LE16(I40E_AQC_SET_VSI_PROMISC_UNICAST);
1794 cmd->seid = CPU_TO_LE16(seid);
1795 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1801 * i40e_aq_set_vsi_multicast_promiscuous
1802 * @hw: pointer to the hw struct
1804 * @set: set multicast promiscuous enable/disable
1805 * @cmd_details: pointer to command details structure or NULL
1807 enum i40e_status_code i40e_aq_set_vsi_multicast_promiscuous(struct i40e_hw *hw,
1808 u16 seid, bool set, struct i40e_asq_cmd_details *cmd_details)
1810 struct i40e_aq_desc desc;
1811 struct i40e_aqc_set_vsi_promiscuous_modes *cmd =
1812 (struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw;
1813 enum i40e_status_code status;
1816 i40e_fill_default_direct_cmd_desc(&desc,
1817 i40e_aqc_opc_set_vsi_promiscuous_modes);
1820 flags |= I40E_AQC_SET_VSI_PROMISC_MULTICAST;
1822 cmd->promiscuous_flags = CPU_TO_LE16(flags);
1824 cmd->valid_flags = CPU_TO_LE16(I40E_AQC_SET_VSI_PROMISC_MULTICAST);
1826 cmd->seid = CPU_TO_LE16(seid);
1827 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1833 * i40e_aq_set_vsi_broadcast
1834 * @hw: pointer to the hw struct
1836 * @set_filter: true to set filter, false to clear filter
1837 * @cmd_details: pointer to command details structure or NULL
1839 * Set or clear the broadcast promiscuous flag (filter) for a given VSI.
1841 enum i40e_status_code i40e_aq_set_vsi_broadcast(struct i40e_hw *hw,
1842 u16 seid, bool set_filter,
1843 struct i40e_asq_cmd_details *cmd_details)
1845 struct i40e_aq_desc desc;
1846 struct i40e_aqc_set_vsi_promiscuous_modes *cmd =
1847 (struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw;
1848 enum i40e_status_code status;
1850 i40e_fill_default_direct_cmd_desc(&desc,
1851 i40e_aqc_opc_set_vsi_promiscuous_modes);
1854 cmd->promiscuous_flags
1855 |= CPU_TO_LE16(I40E_AQC_SET_VSI_PROMISC_BROADCAST);
1857 cmd->promiscuous_flags
1858 &= CPU_TO_LE16(~I40E_AQC_SET_VSI_PROMISC_BROADCAST);
1860 cmd->valid_flags = CPU_TO_LE16(I40E_AQC_SET_VSI_PROMISC_BROADCAST);
1861 cmd->seid = CPU_TO_LE16(seid);
1862 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1868 * i40e_get_vsi_params - get VSI configuration info
1869 * @hw: pointer to the hw struct
1870 * @vsi_ctx: pointer to a vsi context struct
1871 * @cmd_details: pointer to command details structure or NULL
1873 enum i40e_status_code i40e_aq_get_vsi_params(struct i40e_hw *hw,
1874 struct i40e_vsi_context *vsi_ctx,
1875 struct i40e_asq_cmd_details *cmd_details)
1877 struct i40e_aq_desc desc;
1878 struct i40e_aqc_add_get_update_vsi *cmd =
1879 (struct i40e_aqc_add_get_update_vsi *)&desc.params.raw;
1880 struct i40e_aqc_add_get_update_vsi_completion *resp =
1881 (struct i40e_aqc_add_get_update_vsi_completion *)
1883 enum i40e_status_code status;
1885 UNREFERENCED_1PARAMETER(cmd_details);
1886 i40e_fill_default_direct_cmd_desc(&desc,
1887 i40e_aqc_opc_get_vsi_parameters);
1889 cmd->uplink_seid = CPU_TO_LE16(vsi_ctx->seid);
1891 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_BUF);
1893 status = i40e_asq_send_command(hw, &desc, &vsi_ctx->info,
1894 sizeof(vsi_ctx->info), NULL);
1896 if (status != I40E_SUCCESS)
1897 goto aq_get_vsi_params_exit;
1899 vsi_ctx->seid = LE16_TO_CPU(resp->seid);
1900 vsi_ctx->vsi_number = LE16_TO_CPU(resp->vsi_number);
1901 vsi_ctx->vsis_allocated = LE16_TO_CPU(resp->vsi_used);
1902 vsi_ctx->vsis_unallocated = LE16_TO_CPU(resp->vsi_free);
1904 aq_get_vsi_params_exit:
1909 * i40e_aq_update_vsi_params
1910 * @hw: pointer to the hw struct
1911 * @vsi_ctx: pointer to a vsi context struct
1912 * @cmd_details: pointer to command details structure or NULL
1914 * Update a VSI context.
1916 enum i40e_status_code i40e_aq_update_vsi_params(struct i40e_hw *hw,
1917 struct i40e_vsi_context *vsi_ctx,
1918 struct i40e_asq_cmd_details *cmd_details)
1920 struct i40e_aq_desc desc;
1921 struct i40e_aqc_add_get_update_vsi *cmd =
1922 (struct i40e_aqc_add_get_update_vsi *)&desc.params.raw;
1923 enum i40e_status_code status;
1925 i40e_fill_default_direct_cmd_desc(&desc,
1926 i40e_aqc_opc_update_vsi_parameters);
1927 cmd->uplink_seid = CPU_TO_LE16(vsi_ctx->seid);
1929 desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
1931 status = i40e_asq_send_command(hw, &desc, &vsi_ctx->info,
1932 sizeof(vsi_ctx->info), cmd_details);
1938 * i40e_aq_get_switch_config
1939 * @hw: pointer to the hardware structure
1940 * @buf: pointer to the result buffer
1941 * @buf_size: length of input buffer
1942 * @start_seid: seid to start for the report, 0 == beginning
1943 * @cmd_details: pointer to command details structure or NULL
1945 * Fill the buf with switch configuration returned from AdminQ command
1947 enum i40e_status_code i40e_aq_get_switch_config(struct i40e_hw *hw,
1948 struct i40e_aqc_get_switch_config_resp *buf,
1949 u16 buf_size, u16 *start_seid,
1950 struct i40e_asq_cmd_details *cmd_details)
1952 struct i40e_aq_desc desc;
1953 struct i40e_aqc_switch_seid *scfg =
1954 (struct i40e_aqc_switch_seid *)&desc.params.raw;
1955 enum i40e_status_code status;
1957 i40e_fill_default_direct_cmd_desc(&desc,
1958 i40e_aqc_opc_get_switch_config);
1959 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_BUF);
1960 if (buf_size > I40E_AQ_LARGE_BUF)
1961 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
1962 scfg->seid = CPU_TO_LE16(*start_seid);
1964 status = i40e_asq_send_command(hw, &desc, buf, buf_size, cmd_details);
1965 *start_seid = LE16_TO_CPU(scfg->seid);
1971 * i40e_aq_get_firmware_version
1972 * @hw: pointer to the hw struct
1973 * @fw_major_version: firmware major version
1974 * @fw_minor_version: firmware minor version
1975 * @api_major_version: major queue version
1976 * @api_minor_version: minor queue version
1977 * @cmd_details: pointer to command details structure or NULL
1979 * Get the firmware version from the admin queue commands
1981 enum i40e_status_code i40e_aq_get_firmware_version(struct i40e_hw *hw,
1982 u16 *fw_major_version, u16 *fw_minor_version,
1983 u16 *api_major_version, u16 *api_minor_version,
1984 struct i40e_asq_cmd_details *cmd_details)
1986 struct i40e_aq_desc desc;
1987 struct i40e_aqc_get_version *resp =
1988 (struct i40e_aqc_get_version *)&desc.params.raw;
1989 enum i40e_status_code status;
1991 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_get_version);
1993 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
1995 if (status == I40E_SUCCESS) {
1996 if (fw_major_version != NULL)
1997 *fw_major_version = LE16_TO_CPU(resp->fw_major);
1998 if (fw_minor_version != NULL)
1999 *fw_minor_version = LE16_TO_CPU(resp->fw_minor);
2000 if (api_major_version != NULL)
2001 *api_major_version = LE16_TO_CPU(resp->api_major);
2002 if (api_minor_version != NULL)
2003 *api_minor_version = LE16_TO_CPU(resp->api_minor);
2010 * i40e_aq_send_driver_version
2011 * @hw: pointer to the hw struct
2012 * @dv: driver's major, minor version
2013 * @cmd_details: pointer to command details structure or NULL
2015 * Send the driver version to the firmware
2017 enum i40e_status_code i40e_aq_send_driver_version(struct i40e_hw *hw,
2018 struct i40e_driver_version *dv,
2019 struct i40e_asq_cmd_details *cmd_details)
2021 struct i40e_aq_desc desc;
2022 struct i40e_aqc_driver_version *cmd =
2023 (struct i40e_aqc_driver_version *)&desc.params.raw;
2024 enum i40e_status_code status;
2028 return I40E_ERR_PARAM;
2030 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_driver_version);
2032 desc.flags |= CPU_TO_LE16(I40E_AQ_FLAG_SI);
2033 cmd->driver_major_ver = dv->major_version;
2034 cmd->driver_minor_ver = dv->minor_version;
2035 cmd->driver_build_ver = dv->build_version;
2036 cmd->driver_subbuild_ver = dv->subbuild_version;
2039 while (len < sizeof(dv->driver_string) &&
2040 (dv->driver_string[len] < 0x80) &&
2041 dv->driver_string[len])
2043 status = i40e_asq_send_command(hw, &desc, dv->driver_string,
2050 * i40e_get_link_status - get status of the HW network link
2051 * @hw: pointer to the hw struct
2053 * Returns true if link is up, false if link is down.
2055 * Side effect: LinkStatusEvent reporting becomes enabled
2057 bool i40e_get_link_status(struct i40e_hw *hw)
2059 enum i40e_status_code status = I40E_SUCCESS;
2060 bool link_status = false;
2062 if (hw->phy.get_link_info) {
2063 status = i40e_aq_get_link_info(hw, true, NULL, NULL);
2065 if (status != I40E_SUCCESS)
2066 goto i40e_get_link_status_exit;
2069 link_status = hw->phy.link_info.link_info & I40E_AQ_LINK_UP;
2071 i40e_get_link_status_exit:
2076 * i40e_get_link_speed
2077 * @hw: pointer to the hw struct
2079 * Returns the link speed of the adapter.
2081 enum i40e_aq_link_speed i40e_get_link_speed(struct i40e_hw *hw)
2083 enum i40e_aq_link_speed speed = I40E_LINK_SPEED_UNKNOWN;
2084 enum i40e_status_code status = I40E_SUCCESS;
2086 if (hw->phy.get_link_info) {
2087 status = i40e_aq_get_link_info(hw, true, NULL, NULL);
2089 if (status != I40E_SUCCESS)
2090 goto i40e_link_speed_exit;
2093 speed = hw->phy.link_info.link_speed;
2095 i40e_link_speed_exit:
2100 * i40e_aq_add_veb - Insert a VEB between the VSI and the MAC
2101 * @hw: pointer to the hw struct
2102 * @uplink_seid: the MAC or other gizmo SEID
2103 * @downlink_seid: the VSI SEID
2104 * @enabled_tc: bitmap of TCs to be enabled
2105 * @default_port: true for default port VSI, false for control port
2106 * @enable_l2_filtering: true to add L2 filter table rules to regular forwarding rules for cloud support
2107 * @veb_seid: pointer to where to put the resulting VEB SEID
2108 * @cmd_details: pointer to command details structure or NULL
2110 * This asks the FW to add a VEB between the uplink and downlink
2111 * elements. If the uplink SEID is 0, this will be a floating VEB.
2113 enum i40e_status_code i40e_aq_add_veb(struct i40e_hw *hw, u16 uplink_seid,
2114 u16 downlink_seid, u8 enabled_tc,
2115 bool default_port, bool enable_l2_filtering,
2117 struct i40e_asq_cmd_details *cmd_details)
2119 struct i40e_aq_desc desc;
2120 struct i40e_aqc_add_veb *cmd =
2121 (struct i40e_aqc_add_veb *)&desc.params.raw;
2122 struct i40e_aqc_add_veb_completion *resp =
2123 (struct i40e_aqc_add_veb_completion *)&desc.params.raw;
2124 enum i40e_status_code status;
2127 /* SEIDs need to either both be set or both be 0 for floating VEB */
2128 if (!!uplink_seid != !!downlink_seid)
2129 return I40E_ERR_PARAM;
2131 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_add_veb);
2133 cmd->uplink_seid = CPU_TO_LE16(uplink_seid);
2134 cmd->downlink_seid = CPU_TO_LE16(downlink_seid);
2135 cmd->enable_tcs = enabled_tc;
2137 veb_flags |= I40E_AQC_ADD_VEB_FLOATING;
2139 veb_flags |= I40E_AQC_ADD_VEB_PORT_TYPE_DEFAULT;
2141 veb_flags |= I40E_AQC_ADD_VEB_PORT_TYPE_DATA;
2143 if (enable_l2_filtering)
2144 veb_flags |= I40E_AQC_ADD_VEB_ENABLE_L2_FILTER;
2146 cmd->veb_flags = CPU_TO_LE16(veb_flags);
2148 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2150 if (!status && veb_seid)
2151 *veb_seid = LE16_TO_CPU(resp->veb_seid);
2157 * i40e_aq_get_veb_parameters - Retrieve VEB parameters
2158 * @hw: pointer to the hw struct
2159 * @veb_seid: the SEID of the VEB to query
2160 * @switch_id: the uplink switch id
2161 * @floating: set to true if the VEB is floating
2162 * @statistic_index: index of the stats counter block for this VEB
2163 * @vebs_used: number of VEB's used by function
2164 * @vebs_free: total VEB's not reserved by any function
2165 * @cmd_details: pointer to command details structure or NULL
2167 * This retrieves the parameters for a particular VEB, specified by
2168 * uplink_seid, and returns them to the caller.
2170 enum i40e_status_code i40e_aq_get_veb_parameters(struct i40e_hw *hw,
2171 u16 veb_seid, u16 *switch_id,
2172 bool *floating, u16 *statistic_index,
2173 u16 *vebs_used, u16 *vebs_free,
2174 struct i40e_asq_cmd_details *cmd_details)
2176 struct i40e_aq_desc desc;
2177 struct i40e_aqc_get_veb_parameters_completion *cmd_resp =
2178 (struct i40e_aqc_get_veb_parameters_completion *)
2180 enum i40e_status_code status;
2183 return I40E_ERR_PARAM;
2185 i40e_fill_default_direct_cmd_desc(&desc,
2186 i40e_aqc_opc_get_veb_parameters);
2187 cmd_resp->seid = CPU_TO_LE16(veb_seid);
2189 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2194 *switch_id = LE16_TO_CPU(cmd_resp->switch_id);
2195 if (statistic_index)
2196 *statistic_index = LE16_TO_CPU(cmd_resp->statistic_index);
2198 *vebs_used = LE16_TO_CPU(cmd_resp->vebs_used);
2200 *vebs_free = LE16_TO_CPU(cmd_resp->vebs_free);
2202 u16 flags = LE16_TO_CPU(cmd_resp->veb_flags);
2203 if (flags & I40E_AQC_ADD_VEB_FLOATING)
2214 * i40e_aq_add_macvlan
2215 * @hw: pointer to the hw struct
2216 * @seid: VSI for the mac address
2217 * @mv_list: list of macvlans to be added
2218 * @count: length of the list
2219 * @cmd_details: pointer to command details structure or NULL
2221 * Add MAC/VLAN addresses to the HW filtering
2223 enum i40e_status_code i40e_aq_add_macvlan(struct i40e_hw *hw, u16 seid,
2224 struct i40e_aqc_add_macvlan_element_data *mv_list,
2225 u16 count, struct i40e_asq_cmd_details *cmd_details)
2227 struct i40e_aq_desc desc;
2228 struct i40e_aqc_macvlan *cmd =
2229 (struct i40e_aqc_macvlan *)&desc.params.raw;
2230 enum i40e_status_code status;
2233 if (count == 0 || !mv_list || !hw)
2234 return I40E_ERR_PARAM;
2236 buf_size = count * sizeof(struct i40e_aqc_add_macvlan_element_data);
2238 /* prep the rest of the request */
2239 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_add_macvlan);
2240 cmd->num_addresses = CPU_TO_LE16(count);
2241 cmd->seid[0] = CPU_TO_LE16(I40E_AQC_MACVLAN_CMD_SEID_VALID | seid);
2245 desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
2246 if (buf_size > I40E_AQ_LARGE_BUF)
2247 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
2249 status = i40e_asq_send_command(hw, &desc, mv_list, buf_size,
2256 * i40e_aq_remove_macvlan
2257 * @hw: pointer to the hw struct
2258 * @seid: VSI for the mac address
2259 * @mv_list: list of macvlans to be removed
2260 * @count: length of the list
2261 * @cmd_details: pointer to command details structure or NULL
2263 * Remove MAC/VLAN addresses from the HW filtering
2265 enum i40e_status_code i40e_aq_remove_macvlan(struct i40e_hw *hw, u16 seid,
2266 struct i40e_aqc_remove_macvlan_element_data *mv_list,
2267 u16 count, struct i40e_asq_cmd_details *cmd_details)
2269 struct i40e_aq_desc desc;
2270 struct i40e_aqc_macvlan *cmd =
2271 (struct i40e_aqc_macvlan *)&desc.params.raw;
2272 enum i40e_status_code status;
2275 if (count == 0 || !mv_list || !hw)
2276 return I40E_ERR_PARAM;
2278 buf_size = count * sizeof(struct i40e_aqc_remove_macvlan_element_data);
2280 /* prep the rest of the request */
2281 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_remove_macvlan);
2282 cmd->num_addresses = CPU_TO_LE16(count);
2283 cmd->seid[0] = CPU_TO_LE16(I40E_AQC_MACVLAN_CMD_SEID_VALID | seid);
2287 desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
2288 if (buf_size > I40E_AQ_LARGE_BUF)
2289 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
2291 status = i40e_asq_send_command(hw, &desc, mv_list, buf_size,
2298 * i40e_aq_add_vlan - Add VLAN ids to the HW filtering
2299 * @hw: pointer to the hw struct
2300 * @seid: VSI for the vlan filters
2301 * @v_list: list of vlan filters to be added
2302 * @count: length of the list
2303 * @cmd_details: pointer to command details structure or NULL
2305 enum i40e_status_code i40e_aq_add_vlan(struct i40e_hw *hw, u16 seid,
2306 struct i40e_aqc_add_remove_vlan_element_data *v_list,
2307 u8 count, struct i40e_asq_cmd_details *cmd_details)
2309 struct i40e_aq_desc desc;
2310 struct i40e_aqc_macvlan *cmd =
2311 (struct i40e_aqc_macvlan *)&desc.params.raw;
2312 enum i40e_status_code status;
2315 if (count == 0 || !v_list || !hw)
2316 return I40E_ERR_PARAM;
2318 buf_size = count * sizeof(struct i40e_aqc_add_remove_vlan_element_data);
2320 /* prep the rest of the request */
2321 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_add_vlan);
2322 cmd->num_addresses = CPU_TO_LE16(count);
2323 cmd->seid[0] = CPU_TO_LE16(seid | I40E_AQC_MACVLAN_CMD_SEID_VALID);
2327 desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
2328 if (buf_size > I40E_AQ_LARGE_BUF)
2329 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
2331 status = i40e_asq_send_command(hw, &desc, v_list, buf_size,
2338 * i40e_aq_remove_vlan - Remove VLANs from the HW filtering
2339 * @hw: pointer to the hw struct
2340 * @seid: VSI for the vlan filters
2341 * @v_list: list of macvlans to be removed
2342 * @count: length of the list
2343 * @cmd_details: pointer to command details structure or NULL
2345 enum i40e_status_code i40e_aq_remove_vlan(struct i40e_hw *hw, u16 seid,
2346 struct i40e_aqc_add_remove_vlan_element_data *v_list,
2347 u8 count, struct i40e_asq_cmd_details *cmd_details)
2349 struct i40e_aq_desc desc;
2350 struct i40e_aqc_macvlan *cmd =
2351 (struct i40e_aqc_macvlan *)&desc.params.raw;
2352 enum i40e_status_code status;
2355 if (count == 0 || !v_list || !hw)
2356 return I40E_ERR_PARAM;
2358 buf_size = count * sizeof(struct i40e_aqc_add_remove_vlan_element_data);
2360 /* prep the rest of the request */
2361 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_remove_vlan);
2362 cmd->num_addresses = CPU_TO_LE16(count);
2363 cmd->seid[0] = CPU_TO_LE16(seid | I40E_AQC_MACVLAN_CMD_SEID_VALID);
2367 desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
2368 if (buf_size > I40E_AQ_LARGE_BUF)
2369 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
2371 status = i40e_asq_send_command(hw, &desc, v_list, buf_size,
2378 * i40e_aq_send_msg_to_vf
2379 * @hw: pointer to the hardware structure
2380 * @vfid: vf id to send msg
2381 * @v_opcode: opcodes for VF-PF communication
2382 * @v_retval: return error code
2383 * @msg: pointer to the msg buffer
2384 * @msglen: msg length
2385 * @cmd_details: pointer to command details
2389 enum i40e_status_code i40e_aq_send_msg_to_vf(struct i40e_hw *hw, u16 vfid,
2390 u32 v_opcode, u32 v_retval, u8 *msg, u16 msglen,
2391 struct i40e_asq_cmd_details *cmd_details)
2393 struct i40e_aq_desc desc;
2394 struct i40e_aqc_pf_vf_message *cmd =
2395 (struct i40e_aqc_pf_vf_message *)&desc.params.raw;
2396 enum i40e_status_code status;
2398 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_send_msg_to_vf);
2399 cmd->id = CPU_TO_LE32(vfid);
2400 desc.cookie_high = CPU_TO_LE32(v_opcode);
2401 desc.cookie_low = CPU_TO_LE32(v_retval);
2402 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_SI);
2404 desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF |
2406 if (msglen > I40E_AQ_LARGE_BUF)
2407 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
2408 desc.datalen = CPU_TO_LE16(msglen);
2410 status = i40e_asq_send_command(hw, &desc, msg, msglen, cmd_details);
2416 * i40e_aq_get_hmc_resource_profile
2417 * @hw: pointer to the hw struct
2418 * @profile: type of profile the HMC is to be set as
2419 * @pe_vf_enabled_count: the number of PE enabled VFs the system has
2420 * @cmd_details: pointer to command details structure or NULL
2422 * query the HMC profile of the device.
2424 enum i40e_status_code i40e_aq_get_hmc_resource_profile(struct i40e_hw *hw,
2425 enum i40e_aq_hmc_profile *profile,
2426 u8 *pe_vf_enabled_count,
2427 struct i40e_asq_cmd_details *cmd_details)
2429 struct i40e_aq_desc desc;
2430 struct i40e_aq_get_set_hmc_resource_profile *resp =
2431 (struct i40e_aq_get_set_hmc_resource_profile *)&desc.params.raw;
2432 enum i40e_status_code status;
2434 i40e_fill_default_direct_cmd_desc(&desc,
2435 i40e_aqc_opc_query_hmc_resource_profile);
2436 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2438 *profile = (enum i40e_aq_hmc_profile)(resp->pm_profile &
2439 I40E_AQ_GET_HMC_RESOURCE_PROFILE_PM_MASK);
2440 *pe_vf_enabled_count = resp->pe_vf_enabled &
2441 I40E_AQ_GET_HMC_RESOURCE_PROFILE_COUNT_MASK;
2447 * i40e_aq_set_hmc_resource_profile
2448 * @hw: pointer to the hw struct
2449 * @profile: type of profile the HMC is to be set as
2450 * @pe_vf_enabled_count: the number of PE enabled VFs the system has
2451 * @cmd_details: pointer to command details structure or NULL
2453 * set the HMC profile of the device.
2455 enum i40e_status_code i40e_aq_set_hmc_resource_profile(struct i40e_hw *hw,
2456 enum i40e_aq_hmc_profile profile,
2457 u8 pe_vf_enabled_count,
2458 struct i40e_asq_cmd_details *cmd_details)
2460 struct i40e_aq_desc desc;
2461 struct i40e_aq_get_set_hmc_resource_profile *cmd =
2462 (struct i40e_aq_get_set_hmc_resource_profile *)&desc.params.raw;
2463 enum i40e_status_code status;
2465 i40e_fill_default_direct_cmd_desc(&desc,
2466 i40e_aqc_opc_set_hmc_resource_profile);
2468 cmd->pm_profile = (u8)profile;
2469 cmd->pe_vf_enabled = pe_vf_enabled_count;
2471 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2477 * i40e_aq_request_resource
2478 * @hw: pointer to the hw struct
2479 * @resource: resource id
2480 * @access: access type
2481 * @sdp_number: resource number
2482 * @timeout: the maximum time in ms that the driver may hold the resource
2483 * @cmd_details: pointer to command details structure or NULL
2485 * requests common resource using the admin queue commands
2487 enum i40e_status_code i40e_aq_request_resource(struct i40e_hw *hw,
2488 enum i40e_aq_resources_ids resource,
2489 enum i40e_aq_resource_access_type access,
2490 u8 sdp_number, u64 *timeout,
2491 struct i40e_asq_cmd_details *cmd_details)
2493 struct i40e_aq_desc desc;
2494 struct i40e_aqc_request_resource *cmd_resp =
2495 (struct i40e_aqc_request_resource *)&desc.params.raw;
2496 enum i40e_status_code status;
2498 DEBUGFUNC("i40e_aq_request_resource");
2500 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_request_resource);
2502 cmd_resp->resource_id = CPU_TO_LE16(resource);
2503 cmd_resp->access_type = CPU_TO_LE16(access);
2504 cmd_resp->resource_number = CPU_TO_LE32(sdp_number);
2506 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2507 /* The completion specifies the maximum time in ms that the driver
2508 * may hold the resource in the Timeout field.
2509 * If the resource is held by someone else, the command completes with
2510 * busy return value and the timeout field indicates the maximum time
2511 * the current owner of the resource has to free it.
2513 if (status == I40E_SUCCESS || hw->aq.asq_last_status == I40E_AQ_RC_EBUSY)
2514 *timeout = LE32_TO_CPU(cmd_resp->timeout);
2520 * i40e_aq_release_resource
2521 * @hw: pointer to the hw struct
2522 * @resource: resource id
2523 * @sdp_number: resource number
2524 * @cmd_details: pointer to command details structure or NULL
2526 * release common resource using the admin queue commands
2528 enum i40e_status_code i40e_aq_release_resource(struct i40e_hw *hw,
2529 enum i40e_aq_resources_ids resource,
2531 struct i40e_asq_cmd_details *cmd_details)
2533 struct i40e_aq_desc desc;
2534 struct i40e_aqc_request_resource *cmd =
2535 (struct i40e_aqc_request_resource *)&desc.params.raw;
2536 enum i40e_status_code status;
2538 DEBUGFUNC("i40e_aq_release_resource");
2540 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_release_resource);
2542 cmd->resource_id = CPU_TO_LE16(resource);
2543 cmd->resource_number = CPU_TO_LE32(sdp_number);
2545 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2552 * @hw: pointer to the hw struct
2553 * @module_pointer: module pointer location in words from the NVM beginning
2554 * @offset: byte offset from the module beginning
2555 * @length: length of the section to be read (in bytes from the offset)
2556 * @data: command buffer (size [bytes] = length)
2557 * @last_command: tells if this is the last command in a series
2558 * @cmd_details: pointer to command details structure or NULL
2560 * Read the NVM using the admin queue commands
2562 enum i40e_status_code i40e_aq_read_nvm(struct i40e_hw *hw, u8 module_pointer,
2563 u32 offset, u16 length, void *data,
2565 struct i40e_asq_cmd_details *cmd_details)
2567 struct i40e_aq_desc desc;
2568 struct i40e_aqc_nvm_update *cmd =
2569 (struct i40e_aqc_nvm_update *)&desc.params.raw;
2570 enum i40e_status_code status;
2572 DEBUGFUNC("i40e_aq_read_nvm");
2574 /* In offset the highest byte must be zeroed. */
2575 if (offset & 0xFF000000) {
2576 status = I40E_ERR_PARAM;
2577 goto i40e_aq_read_nvm_exit;
2580 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_nvm_read);
2582 /* If this is the last command in a series, set the proper flag. */
2584 cmd->command_flags |= I40E_AQ_NVM_LAST_CMD;
2585 cmd->module_pointer = module_pointer;
2586 cmd->offset = CPU_TO_LE32(offset);
2587 cmd->length = CPU_TO_LE16(length);
2589 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_BUF);
2590 if (length > I40E_AQ_LARGE_BUF)
2591 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
2593 status = i40e_asq_send_command(hw, &desc, data, length, cmd_details);
2595 i40e_aq_read_nvm_exit:
2601 * @hw: pointer to the hw struct
2602 * @module_pointer: module pointer location in words from the NVM beginning
2603 * @offset: offset in the module (expressed in 4 KB from module's beginning)
2604 * @length: length of the section to be erased (expressed in 4 KB)
2605 * @last_command: tells if this is the last command in a series
2606 * @cmd_details: pointer to command details structure or NULL
2608 * Erase the NVM sector using the admin queue commands
2610 enum i40e_status_code i40e_aq_erase_nvm(struct i40e_hw *hw, u8 module_pointer,
2611 u32 offset, u16 length, bool last_command,
2612 struct i40e_asq_cmd_details *cmd_details)
2614 struct i40e_aq_desc desc;
2615 struct i40e_aqc_nvm_update *cmd =
2616 (struct i40e_aqc_nvm_update *)&desc.params.raw;
2617 enum i40e_status_code status;
2619 DEBUGFUNC("i40e_aq_erase_nvm");
2621 /* In offset the highest byte must be zeroed. */
2622 if (offset & 0xFF000000) {
2623 status = I40E_ERR_PARAM;
2624 goto i40e_aq_erase_nvm_exit;
2627 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_nvm_erase);
2629 /* If this is the last command in a series, set the proper flag. */
2631 cmd->command_flags |= I40E_AQ_NVM_LAST_CMD;
2632 cmd->module_pointer = module_pointer;
2633 cmd->offset = CPU_TO_LE32(offset);
2634 cmd->length = CPU_TO_LE16(length);
2636 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2638 i40e_aq_erase_nvm_exit:
2642 #define I40E_DEV_FUNC_CAP_SWITCH_MODE 0x01
2643 #define I40E_DEV_FUNC_CAP_MGMT_MODE 0x02
2644 #define I40E_DEV_FUNC_CAP_NPAR 0x03
2645 #define I40E_DEV_FUNC_CAP_OS2BMC 0x04
2646 #define I40E_DEV_FUNC_CAP_VALID_FUNC 0x05
2647 #define I40E_DEV_FUNC_CAP_SRIOV_1_1 0x12
2648 #define I40E_DEV_FUNC_CAP_VF 0x13
2649 #define I40E_DEV_FUNC_CAP_VMDQ 0x14
2650 #define I40E_DEV_FUNC_CAP_802_1_QBG 0x15
2651 #define I40E_DEV_FUNC_CAP_802_1_QBH 0x16
2652 #define I40E_DEV_FUNC_CAP_VSI 0x17
2653 #define I40E_DEV_FUNC_CAP_DCB 0x18
2654 #define I40E_DEV_FUNC_CAP_FCOE 0x21
2655 #define I40E_DEV_FUNC_CAP_RSS 0x40
2656 #define I40E_DEV_FUNC_CAP_RX_QUEUES 0x41
2657 #define I40E_DEV_FUNC_CAP_TX_QUEUES 0x42
2658 #define I40E_DEV_FUNC_CAP_MSIX 0x43
2659 #define I40E_DEV_FUNC_CAP_MSIX_VF 0x44
2660 #define I40E_DEV_FUNC_CAP_FLOW_DIRECTOR 0x45
2661 #define I40E_DEV_FUNC_CAP_IEEE_1588 0x46
2662 #define I40E_DEV_FUNC_CAP_MFP_MODE_1 0xF1
2663 #define I40E_DEV_FUNC_CAP_CEM 0xF2
2664 #define I40E_DEV_FUNC_CAP_IWARP 0x51
2665 #define I40E_DEV_FUNC_CAP_LED 0x61
2666 #define I40E_DEV_FUNC_CAP_SDP 0x62
2667 #define I40E_DEV_FUNC_CAP_MDIO 0x63
2670 * i40e_parse_discover_capabilities
2671 * @hw: pointer to the hw struct
2672 * @buff: pointer to a buffer containing device/function capability records
2673 * @cap_count: number of capability records in the list
2674 * @list_type_opc: type of capabilities list to parse
2676 * Parse the device/function capabilities list.
2678 STATIC void i40e_parse_discover_capabilities(struct i40e_hw *hw, void *buff,
2680 enum i40e_admin_queue_opc list_type_opc)
2682 struct i40e_aqc_list_capabilities_element_resp *cap;
2683 u32 number, logical_id, phys_id;
2684 struct i40e_hw_capabilities *p;
2688 cap = (struct i40e_aqc_list_capabilities_element_resp *) buff;
2690 if (list_type_opc == i40e_aqc_opc_list_dev_capabilities)
2691 p = (struct i40e_hw_capabilities *)&hw->dev_caps;
2692 else if (list_type_opc == i40e_aqc_opc_list_func_capabilities)
2693 p = (struct i40e_hw_capabilities *)&hw->func_caps;
2697 for (i = 0; i < cap_count; i++, cap++) {
2698 id = LE16_TO_CPU(cap->id);
2699 number = LE32_TO_CPU(cap->number);
2700 logical_id = LE32_TO_CPU(cap->logical_id);
2701 phys_id = LE32_TO_CPU(cap->phys_id);
2704 case I40E_DEV_FUNC_CAP_SWITCH_MODE:
2705 p->switch_mode = number;
2707 case I40E_DEV_FUNC_CAP_MGMT_MODE:
2708 p->management_mode = number;
2710 case I40E_DEV_FUNC_CAP_NPAR:
2711 p->npar_enable = number;
2713 case I40E_DEV_FUNC_CAP_OS2BMC:
2716 case I40E_DEV_FUNC_CAP_VALID_FUNC:
2717 p->valid_functions = number;
2719 case I40E_DEV_FUNC_CAP_SRIOV_1_1:
2721 p->sr_iov_1_1 = true;
2723 case I40E_DEV_FUNC_CAP_VF:
2724 p->num_vfs = number;
2725 p->vf_base_id = logical_id;
2727 case I40E_DEV_FUNC_CAP_VMDQ:
2731 case I40E_DEV_FUNC_CAP_802_1_QBG:
2733 p->evb_802_1_qbg = true;
2735 case I40E_DEV_FUNC_CAP_802_1_QBH:
2737 p->evb_802_1_qbh = true;
2739 case I40E_DEV_FUNC_CAP_VSI:
2740 p->num_vsis = number;
2742 case I40E_DEV_FUNC_CAP_DCB:
2745 p->enabled_tcmap = logical_id;
2749 case I40E_DEV_FUNC_CAP_FCOE:
2753 case I40E_DEV_FUNC_CAP_RSS:
2755 p->rss_table_size = number;
2756 p->rss_table_entry_width = logical_id;
2758 case I40E_DEV_FUNC_CAP_RX_QUEUES:
2759 p->num_rx_qp = number;
2760 p->base_queue = phys_id;
2762 case I40E_DEV_FUNC_CAP_TX_QUEUES:
2763 p->num_tx_qp = number;
2764 p->base_queue = phys_id;
2766 case I40E_DEV_FUNC_CAP_MSIX:
2767 p->num_msix_vectors = number;
2769 case I40E_DEV_FUNC_CAP_MSIX_VF:
2770 p->num_msix_vectors_vf = number;
2772 case I40E_DEV_FUNC_CAP_MFP_MODE_1:
2774 p->mfp_mode_1 = true;
2776 case I40E_DEV_FUNC_CAP_CEM:
2780 case I40E_DEV_FUNC_CAP_IWARP:
2784 case I40E_DEV_FUNC_CAP_LED:
2785 if (phys_id < I40E_HW_CAP_MAX_GPIO)
2786 p->led[phys_id] = true;
2788 case I40E_DEV_FUNC_CAP_SDP:
2789 if (phys_id < I40E_HW_CAP_MAX_GPIO)
2790 p->sdp[phys_id] = true;
2792 case I40E_DEV_FUNC_CAP_MDIO:
2794 p->mdio_port_num = phys_id;
2795 p->mdio_port_mode = logical_id;
2798 case I40E_DEV_FUNC_CAP_IEEE_1588:
2800 p->ieee_1588 = true;
2802 case I40E_DEV_FUNC_CAP_FLOW_DIRECTOR:
2804 p->fd_filters_guaranteed = number;
2805 p->fd_filters_best_effort = logical_id;
2812 /* Software override ensuring FCoE is disabled if npar or mfp
2813 * mode because it is not supported in these modes.
2815 if (p->npar_enable || p->mfp_mode_1)
2818 /* additional HW specific goodies that might
2819 * someday be HW version specific
2821 p->rx_buf_chain_len = I40E_MAX_CHAINED_RX_BUFFERS;
2825 * i40e_aq_discover_capabilities
2826 * @hw: pointer to the hw struct
2827 * @buff: a virtual buffer to hold the capabilities
2828 * @buff_size: Size of the virtual buffer
2829 * @data_size: Size of the returned data, or buff size needed if AQ err==ENOMEM
2830 * @list_type_opc: capabilities type to discover - pass in the command opcode
2831 * @cmd_details: pointer to command details structure or NULL
2833 * Get the device capabilities descriptions from the firmware
2835 enum i40e_status_code i40e_aq_discover_capabilities(struct i40e_hw *hw,
2836 void *buff, u16 buff_size, u16 *data_size,
2837 enum i40e_admin_queue_opc list_type_opc,
2838 struct i40e_asq_cmd_details *cmd_details)
2840 struct i40e_aqc_list_capabilites *cmd;
2841 struct i40e_aq_desc desc;
2842 enum i40e_status_code status = I40E_SUCCESS;
2844 cmd = (struct i40e_aqc_list_capabilites *)&desc.params.raw;
2846 if (list_type_opc != i40e_aqc_opc_list_func_capabilities &&
2847 list_type_opc != i40e_aqc_opc_list_dev_capabilities) {
2848 status = I40E_ERR_PARAM;
2852 i40e_fill_default_direct_cmd_desc(&desc, list_type_opc);
2854 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_BUF);
2855 if (buff_size > I40E_AQ_LARGE_BUF)
2856 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
2858 status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
2859 *data_size = LE16_TO_CPU(desc.datalen);
2864 i40e_parse_discover_capabilities(hw, buff, LE32_TO_CPU(cmd->count),
2872 * i40e_aq_update_nvm
2873 * @hw: pointer to the hw struct
2874 * @module_pointer: module pointer location in words from the NVM beginning
2875 * @offset: byte offset from the module beginning
2876 * @length: length of the section to be written (in bytes from the offset)
2877 * @data: command buffer (size [bytes] = length)
2878 * @last_command: tells if this is the last command in a series
2879 * @cmd_details: pointer to command details structure or NULL
2881 * Update the NVM using the admin queue commands
2883 enum i40e_status_code i40e_aq_update_nvm(struct i40e_hw *hw, u8 module_pointer,
2884 u32 offset, u16 length, void *data,
2886 struct i40e_asq_cmd_details *cmd_details)
2888 struct i40e_aq_desc desc;
2889 struct i40e_aqc_nvm_update *cmd =
2890 (struct i40e_aqc_nvm_update *)&desc.params.raw;
2891 enum i40e_status_code status;
2893 DEBUGFUNC("i40e_aq_update_nvm");
2895 /* In offset the highest byte must be zeroed. */
2896 if (offset & 0xFF000000) {
2897 status = I40E_ERR_PARAM;
2898 goto i40e_aq_update_nvm_exit;
2901 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_nvm_update);
2903 /* If this is the last command in a series, set the proper flag. */
2905 cmd->command_flags |= I40E_AQ_NVM_LAST_CMD;
2906 cmd->module_pointer = module_pointer;
2907 cmd->offset = CPU_TO_LE32(offset);
2908 cmd->length = CPU_TO_LE16(length);
2910 desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
2911 if (length > I40E_AQ_LARGE_BUF)
2912 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
2914 status = i40e_asq_send_command(hw, &desc, data, length, cmd_details);
2916 i40e_aq_update_nvm_exit:
2921 * i40e_aq_get_lldp_mib
2922 * @hw: pointer to the hw struct
2923 * @bridge_type: type of bridge requested
2924 * @mib_type: Local, Remote or both Local and Remote MIBs
2925 * @buff: pointer to a user supplied buffer to store the MIB block
2926 * @buff_size: size of the buffer (in bytes)
2927 * @local_len : length of the returned Local LLDP MIB
2928 * @remote_len: length of the returned Remote LLDP MIB
2929 * @cmd_details: pointer to command details structure or NULL
2931 * Requests the complete LLDP MIB (entire packet).
2933 enum i40e_status_code i40e_aq_get_lldp_mib(struct i40e_hw *hw, u8 bridge_type,
2934 u8 mib_type, void *buff, u16 buff_size,
2935 u16 *local_len, u16 *remote_len,
2936 struct i40e_asq_cmd_details *cmd_details)
2938 struct i40e_aq_desc desc;
2939 struct i40e_aqc_lldp_get_mib *cmd =
2940 (struct i40e_aqc_lldp_get_mib *)&desc.params.raw;
2941 struct i40e_aqc_lldp_get_mib *resp =
2942 (struct i40e_aqc_lldp_get_mib *)&desc.params.raw;
2943 enum i40e_status_code status;
2945 if (buff_size == 0 || !buff)
2946 return I40E_ERR_PARAM;
2948 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_get_mib);
2949 /* Indirect Command */
2950 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_BUF);
2952 cmd->type = mib_type & I40E_AQ_LLDP_MIB_TYPE_MASK;
2953 cmd->type |= ((bridge_type << I40E_AQ_LLDP_BRIDGE_TYPE_SHIFT) &
2954 I40E_AQ_LLDP_BRIDGE_TYPE_MASK);
2956 desc.datalen = CPU_TO_LE16(buff_size);
2958 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_BUF);
2959 if (buff_size > I40E_AQ_LARGE_BUF)
2960 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
2962 status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
2964 if (local_len != NULL)
2965 *local_len = LE16_TO_CPU(resp->local_len);
2966 if (remote_len != NULL)
2967 *remote_len = LE16_TO_CPU(resp->remote_len);
2974 * i40e_aq_cfg_lldp_mib_change_event
2975 * @hw: pointer to the hw struct
2976 * @enable_update: Enable or Disable event posting
2977 * @cmd_details: pointer to command details structure or NULL
2979 * Enable or Disable posting of an event on ARQ when LLDP MIB
2980 * associated with the interface changes
2982 enum i40e_status_code i40e_aq_cfg_lldp_mib_change_event(struct i40e_hw *hw,
2984 struct i40e_asq_cmd_details *cmd_details)
2986 struct i40e_aq_desc desc;
2987 struct i40e_aqc_lldp_update_mib *cmd =
2988 (struct i40e_aqc_lldp_update_mib *)&desc.params.raw;
2989 enum i40e_status_code status;
2991 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_update_mib);
2994 cmd->command |= I40E_AQ_LLDP_MIB_UPDATE_DISABLE;
2996 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3002 * i40e_aq_add_lldp_tlv
3003 * @hw: pointer to the hw struct
3004 * @bridge_type: type of bridge
3005 * @buff: buffer with TLV to add
3006 * @buff_size: length of the buffer
3007 * @tlv_len: length of the TLV to be added
3008 * @mib_len: length of the LLDP MIB returned in response
3009 * @cmd_details: pointer to command details structure or NULL
3011 * Add the specified TLV to LLDP Local MIB for the given bridge type,
3012 * it is responsibility of the caller to make sure that the TLV is not
3013 * already present in the LLDPDU.
3014 * In return firmware will write the complete LLDP MIB with the newly
3015 * added TLV in the response buffer.
3017 enum i40e_status_code i40e_aq_add_lldp_tlv(struct i40e_hw *hw, u8 bridge_type,
3018 void *buff, u16 buff_size, u16 tlv_len,
3020 struct i40e_asq_cmd_details *cmd_details)
3022 struct i40e_aq_desc desc;
3023 struct i40e_aqc_lldp_add_tlv *cmd =
3024 (struct i40e_aqc_lldp_add_tlv *)&desc.params.raw;
3025 enum i40e_status_code status;
3027 if (buff_size == 0 || !buff || tlv_len == 0)
3028 return I40E_ERR_PARAM;
3030 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_add_tlv);
3032 /* Indirect Command */
3033 desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
3034 if (buff_size > I40E_AQ_LARGE_BUF)
3035 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
3036 desc.datalen = CPU_TO_LE16(buff_size);
3038 cmd->type = ((bridge_type << I40E_AQ_LLDP_BRIDGE_TYPE_SHIFT) &
3039 I40E_AQ_LLDP_BRIDGE_TYPE_MASK);
3040 cmd->len = CPU_TO_LE16(tlv_len);
3042 status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
3044 if (mib_len != NULL)
3045 *mib_len = LE16_TO_CPU(desc.datalen);
3052 * i40e_aq_update_lldp_tlv
3053 * @hw: pointer to the hw struct
3054 * @bridge_type: type of bridge
3055 * @buff: buffer with TLV to update
3056 * @buff_size: size of the buffer holding original and updated TLVs
3057 * @old_len: Length of the Original TLV
3058 * @new_len: Length of the Updated TLV
3059 * @offset: offset of the updated TLV in the buff
3060 * @mib_len: length of the returned LLDP MIB
3061 * @cmd_details: pointer to command details structure or NULL
3063 * Update the specified TLV to the LLDP Local MIB for the given bridge type.
3064 * Firmware will place the complete LLDP MIB in response buffer with the
3067 enum i40e_status_code i40e_aq_update_lldp_tlv(struct i40e_hw *hw,
3068 u8 bridge_type, void *buff, u16 buff_size,
3069 u16 old_len, u16 new_len, u16 offset,
3071 struct i40e_asq_cmd_details *cmd_details)
3073 struct i40e_aq_desc desc;
3074 struct i40e_aqc_lldp_update_tlv *cmd =
3075 (struct i40e_aqc_lldp_update_tlv *)&desc.params.raw;
3076 enum i40e_status_code status;
3078 if (buff_size == 0 || !buff || offset == 0 ||
3079 old_len == 0 || new_len == 0)
3080 return I40E_ERR_PARAM;
3082 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_update_tlv);
3084 /* Indirect Command */
3085 desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
3086 if (buff_size > I40E_AQ_LARGE_BUF)
3087 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
3088 desc.datalen = CPU_TO_LE16(buff_size);
3090 cmd->type = ((bridge_type << I40E_AQ_LLDP_BRIDGE_TYPE_SHIFT) &
3091 I40E_AQ_LLDP_BRIDGE_TYPE_MASK);
3092 cmd->old_len = CPU_TO_LE16(old_len);
3093 cmd->new_offset = CPU_TO_LE16(offset);
3094 cmd->new_len = CPU_TO_LE16(new_len);
3096 status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
3098 if (mib_len != NULL)
3099 *mib_len = LE16_TO_CPU(desc.datalen);
3106 * i40e_aq_delete_lldp_tlv
3107 * @hw: pointer to the hw struct
3108 * @bridge_type: type of bridge
3109 * @buff: pointer to a user supplied buffer that has the TLV
3110 * @buff_size: length of the buffer
3111 * @tlv_len: length of the TLV to be deleted
3112 * @mib_len: length of the returned LLDP MIB
3113 * @cmd_details: pointer to command details structure or NULL
3115 * Delete the specified TLV from LLDP Local MIB for the given bridge type.
3116 * The firmware places the entire LLDP MIB in the response buffer.
3118 enum i40e_status_code i40e_aq_delete_lldp_tlv(struct i40e_hw *hw,
3119 u8 bridge_type, void *buff, u16 buff_size,
3120 u16 tlv_len, u16 *mib_len,
3121 struct i40e_asq_cmd_details *cmd_details)
3123 struct i40e_aq_desc desc;
3124 struct i40e_aqc_lldp_add_tlv *cmd =
3125 (struct i40e_aqc_lldp_add_tlv *)&desc.params.raw;
3126 enum i40e_status_code status;
3128 if (buff_size == 0 || !buff)
3129 return I40E_ERR_PARAM;
3131 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_delete_tlv);
3133 /* Indirect Command */
3134 desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
3135 if (buff_size > I40E_AQ_LARGE_BUF)
3136 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
3137 desc.datalen = CPU_TO_LE16(buff_size);
3138 cmd->len = CPU_TO_LE16(tlv_len);
3139 cmd->type = ((bridge_type << I40E_AQ_LLDP_BRIDGE_TYPE_SHIFT) &
3140 I40E_AQ_LLDP_BRIDGE_TYPE_MASK);
3142 status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
3144 if (mib_len != NULL)
3145 *mib_len = LE16_TO_CPU(desc.datalen);
3153 * @hw: pointer to the hw struct
3154 * @shutdown_agent: True if LLDP Agent needs to be Shutdown
3155 * @cmd_details: pointer to command details structure or NULL
3157 * Stop or Shutdown the embedded LLDP Agent
3159 enum i40e_status_code i40e_aq_stop_lldp(struct i40e_hw *hw, bool shutdown_agent,
3160 struct i40e_asq_cmd_details *cmd_details)
3162 struct i40e_aq_desc desc;
3163 struct i40e_aqc_lldp_stop *cmd =
3164 (struct i40e_aqc_lldp_stop *)&desc.params.raw;
3165 enum i40e_status_code status;
3167 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_stop);
3170 cmd->command |= I40E_AQ_LLDP_AGENT_SHUTDOWN;
3172 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3178 * i40e_aq_start_lldp
3179 * @hw: pointer to the hw struct
3180 * @cmd_details: pointer to command details structure or NULL
3182 * Start the embedded LLDP Agent on all ports.
3184 enum i40e_status_code i40e_aq_start_lldp(struct i40e_hw *hw,
3185 struct i40e_asq_cmd_details *cmd_details)
3187 struct i40e_aq_desc desc;
3188 struct i40e_aqc_lldp_start *cmd =
3189 (struct i40e_aqc_lldp_start *)&desc.params.raw;
3190 enum i40e_status_code status;
3192 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_start);
3194 cmd->command = I40E_AQ_LLDP_AGENT_START;
3196 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3202 * i40e_aq_add_udp_tunnel
3203 * @hw: pointer to the hw struct
3204 * @udp_port: the UDP port to add
3205 * @header_len: length of the tunneling header length in DWords
3206 * @protocol_index: protocol index type
3207 * @filter_index: pointer to filter index
3208 * @cmd_details: pointer to command details structure or NULL
3210 enum i40e_status_code i40e_aq_add_udp_tunnel(struct i40e_hw *hw,
3211 u16 udp_port, u8 protocol_index,
3213 struct i40e_asq_cmd_details *cmd_details)
3215 struct i40e_aq_desc desc;
3216 struct i40e_aqc_add_udp_tunnel *cmd =
3217 (struct i40e_aqc_add_udp_tunnel *)&desc.params.raw;
3218 struct i40e_aqc_del_udp_tunnel_completion *resp =
3219 (struct i40e_aqc_del_udp_tunnel_completion *)&desc.params.raw;
3220 enum i40e_status_code status;
3222 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_add_udp_tunnel);
3224 cmd->udp_port = CPU_TO_LE16(udp_port);
3225 cmd->protocol_type = protocol_index;
3227 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3230 *filter_index = resp->index;
3236 * i40e_aq_del_udp_tunnel
3237 * @hw: pointer to the hw struct
3238 * @index: filter index
3239 * @cmd_details: pointer to command details structure or NULL
3241 enum i40e_status_code i40e_aq_del_udp_tunnel(struct i40e_hw *hw, u8 index,
3242 struct i40e_asq_cmd_details *cmd_details)
3244 struct i40e_aq_desc desc;
3245 struct i40e_aqc_remove_udp_tunnel *cmd =
3246 (struct i40e_aqc_remove_udp_tunnel *)&desc.params.raw;
3247 enum i40e_status_code status;
3249 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_del_udp_tunnel);
3253 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3259 * i40e_aq_get_switch_resource_alloc (0x0204)
3260 * @hw: pointer to the hw struct
3261 * @num_entries: pointer to u8 to store the number of resource entries returned
3262 * @buf: pointer to a user supplied buffer. This buffer must be large enough
3263 * to store the resource information for all resource types. Each
3264 * resource type is a i40e_aqc_switch_resource_alloc_data structure.
3265 * @count: size, in bytes, of the buffer provided
3266 * @cmd_details: pointer to command details structure or NULL
3268 * Query the resources allocated to a function.
3270 enum i40e_status_code i40e_aq_get_switch_resource_alloc(struct i40e_hw *hw,
3272 struct i40e_aqc_switch_resource_alloc_element_resp *buf,
3274 struct i40e_asq_cmd_details *cmd_details)
3276 struct i40e_aq_desc desc;
3277 struct i40e_aqc_get_switch_resource_alloc *cmd_resp =
3278 (struct i40e_aqc_get_switch_resource_alloc *)&desc.params.raw;
3279 enum i40e_status_code status;
3281 * sizeof(struct i40e_aqc_switch_resource_alloc_element_resp);
3283 i40e_fill_default_direct_cmd_desc(&desc,
3284 i40e_aqc_opc_get_switch_resource_alloc);
3286 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_BUF);
3287 if (length > I40E_AQ_LARGE_BUF)
3288 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
3290 status = i40e_asq_send_command(hw, &desc, buf, length, cmd_details);
3293 *num_entries = cmd_resp->num_entries;
3299 * i40e_aq_delete_element - Delete switch element
3300 * @hw: pointer to the hw struct
3301 * @seid: the SEID to delete from the switch
3302 * @cmd_details: pointer to command details structure or NULL
3304 * This deletes a switch element from the switch.
3306 enum i40e_status_code i40e_aq_delete_element(struct i40e_hw *hw, u16 seid,
3307 struct i40e_asq_cmd_details *cmd_details)
3309 struct i40e_aq_desc desc;
3310 struct i40e_aqc_switch_seid *cmd =
3311 (struct i40e_aqc_switch_seid *)&desc.params.raw;
3312 enum i40e_status_code status;
3315 return I40E_ERR_PARAM;
3317 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_delete_element);
3319 cmd->seid = CPU_TO_LE16(seid);
3321 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3327 * i40_aq_add_pvirt - Instantiate a Port Virtualizer on a port
3328 * @hw: pointer to the hw struct
3329 * @flags: component flags
3330 * @mac_seid: uplink seid (MAC SEID)
3331 * @vsi_seid: connected vsi seid
3332 * @ret_seid: seid of create pv component
3334 * This instantiates an i40e port virtualizer with specified flags.
3335 * Depending on specified flags the port virtualizer can act as a
3336 * 802.1Qbr port virtualizer or a 802.1Qbg S-component.
3338 enum i40e_status_code i40e_aq_add_pvirt(struct i40e_hw *hw, u16 flags,
3339 u16 mac_seid, u16 vsi_seid,
3342 struct i40e_aq_desc desc;
3343 struct i40e_aqc_add_update_pv *cmd =
3344 (struct i40e_aqc_add_update_pv *)&desc.params.raw;
3345 struct i40e_aqc_add_update_pv_completion *resp =
3346 (struct i40e_aqc_add_update_pv_completion *)&desc.params.raw;
3347 enum i40e_status_code status;
3350 return I40E_ERR_PARAM;
3352 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_add_pv);
3353 cmd->command_flags = CPU_TO_LE16(flags);
3354 cmd->uplink_seid = CPU_TO_LE16(mac_seid);
3355 cmd->connected_seid = CPU_TO_LE16(vsi_seid);
3357 status = i40e_asq_send_command(hw, &desc, NULL, 0, NULL);
3358 if (!status && ret_seid)
3359 *ret_seid = LE16_TO_CPU(resp->pv_seid);
3365 * i40e_aq_add_tag - Add an S/E-tag
3366 * @hw: pointer to the hw struct
3367 * @direct_to_queue: should s-tag direct flow to a specific queue
3368 * @vsi_seid: VSI SEID to use this tag
3369 * @tag: value of the tag
3370 * @queue_num: queue number, only valid is direct_to_queue is true
3371 * @tags_used: return value, number of tags in use by this PF
3372 * @tags_free: return value, number of unallocated tags
3373 * @cmd_details: pointer to command details structure or NULL
3375 * This associates an S- or E-tag to a VSI in the switch complex. It returns
3376 * the number of tags allocated by the PF, and the number of unallocated
3379 enum i40e_status_code i40e_aq_add_tag(struct i40e_hw *hw, bool direct_to_queue,
3380 u16 vsi_seid, u16 tag, u16 queue_num,
3381 u16 *tags_used, u16 *tags_free,
3382 struct i40e_asq_cmd_details *cmd_details)
3384 struct i40e_aq_desc desc;
3385 struct i40e_aqc_add_tag *cmd =
3386 (struct i40e_aqc_add_tag *)&desc.params.raw;
3387 struct i40e_aqc_add_remove_tag_completion *resp =
3388 (struct i40e_aqc_add_remove_tag_completion *)&desc.params.raw;
3389 enum i40e_status_code status;
3392 return I40E_ERR_PARAM;
3394 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_add_tag);
3396 cmd->seid = CPU_TO_LE16(vsi_seid);
3397 cmd->tag = CPU_TO_LE16(tag);
3398 if (direct_to_queue) {
3399 cmd->flags = CPU_TO_LE16(I40E_AQC_ADD_TAG_FLAG_TO_QUEUE);
3400 cmd->queue_number = CPU_TO_LE16(queue_num);
3403 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3406 if (tags_used != NULL)
3407 *tags_used = LE16_TO_CPU(resp->tags_used);
3408 if (tags_free != NULL)
3409 *tags_free = LE16_TO_CPU(resp->tags_free);
3416 * i40e_aq_remove_tag - Remove an S- or E-tag
3417 * @hw: pointer to the hw struct
3418 * @vsi_seid: VSI SEID this tag is associated with
3419 * @tag: value of the S-tag to delete
3420 * @tags_used: return value, number of tags in use by this PF
3421 * @tags_free: return value, number of unallocated tags
3422 * @cmd_details: pointer to command details structure or NULL
3424 * This deletes an S- or E-tag from a VSI in the switch complex. It returns
3425 * the number of tags allocated by the PF, and the number of unallocated
3428 enum i40e_status_code i40e_aq_remove_tag(struct i40e_hw *hw, u16 vsi_seid,
3429 u16 tag, u16 *tags_used, u16 *tags_free,
3430 struct i40e_asq_cmd_details *cmd_details)
3432 struct i40e_aq_desc desc;
3433 struct i40e_aqc_remove_tag *cmd =
3434 (struct i40e_aqc_remove_tag *)&desc.params.raw;
3435 struct i40e_aqc_add_remove_tag_completion *resp =
3436 (struct i40e_aqc_add_remove_tag_completion *)&desc.params.raw;
3437 enum i40e_status_code status;
3440 return I40E_ERR_PARAM;
3442 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_remove_tag);
3444 cmd->seid = CPU_TO_LE16(vsi_seid);
3445 cmd->tag = CPU_TO_LE16(tag);
3447 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3450 if (tags_used != NULL)
3451 *tags_used = LE16_TO_CPU(resp->tags_used);
3452 if (tags_free != NULL)
3453 *tags_free = LE16_TO_CPU(resp->tags_free);
3460 * i40e_aq_add_mcast_etag - Add a multicast E-tag
3461 * @hw: pointer to the hw struct
3462 * @pv_seid: Port Virtualizer of this SEID to associate E-tag with
3463 * @etag: value of E-tag to add
3464 * @num_tags_in_buf: number of unicast E-tags in indirect buffer
3465 * @buf: address of indirect buffer
3466 * @tags_used: return value, number of E-tags in use by this port
3467 * @tags_free: return value, number of unallocated M-tags
3468 * @cmd_details: pointer to command details structure or NULL
3470 * This associates a multicast E-tag to a port virtualizer. It will return
3471 * the number of tags allocated by the PF, and the number of unallocated
3474 * The indirect buffer pointed to by buf is a list of 2-byte E-tags,
3475 * num_tags_in_buf long.
3477 enum i40e_status_code i40e_aq_add_mcast_etag(struct i40e_hw *hw, u16 pv_seid,
3478 u16 etag, u8 num_tags_in_buf, void *buf,
3479 u16 *tags_used, u16 *tags_free,
3480 struct i40e_asq_cmd_details *cmd_details)
3482 struct i40e_aq_desc desc;
3483 struct i40e_aqc_add_remove_mcast_etag *cmd =
3484 (struct i40e_aqc_add_remove_mcast_etag *)&desc.params.raw;
3485 struct i40e_aqc_add_remove_mcast_etag_completion *resp =
3486 (struct i40e_aqc_add_remove_mcast_etag_completion *)&desc.params.raw;
3487 enum i40e_status_code status;
3488 u16 length = sizeof(u16) * num_tags_in_buf;
3490 if ((pv_seid == 0) || (buf == NULL) || (num_tags_in_buf == 0))
3491 return I40E_ERR_PARAM;
3493 i40e_fill_default_direct_cmd_desc(&desc,
3494 i40e_aqc_opc_add_multicast_etag);
3496 cmd->pv_seid = CPU_TO_LE16(pv_seid);
3497 cmd->etag = CPU_TO_LE16(etag);
3498 cmd->num_unicast_etags = num_tags_in_buf;
3500 desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
3501 if (length > I40E_AQ_LARGE_BUF)
3502 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
3504 status = i40e_asq_send_command(hw, &desc, buf, length, cmd_details);
3507 if (tags_used != NULL)
3508 *tags_used = LE16_TO_CPU(resp->mcast_etags_used);
3509 if (tags_free != NULL)
3510 *tags_free = LE16_TO_CPU(resp->mcast_etags_free);
3517 * i40e_aq_remove_mcast_etag - Remove a multicast E-tag
3518 * @hw: pointer to the hw struct
3519 * @pv_seid: Port Virtualizer SEID this M-tag is associated with
3520 * @etag: value of the E-tag to remove
3521 * @tags_used: return value, number of tags in use by this port
3522 * @tags_free: return value, number of unallocated tags
3523 * @cmd_details: pointer to command details structure or NULL
3525 * This deletes an E-tag from the port virtualizer. It will return
3526 * the number of tags allocated by the port, and the number of unallocated
3529 enum i40e_status_code i40e_aq_remove_mcast_etag(struct i40e_hw *hw, u16 pv_seid,
3530 u16 etag, u16 *tags_used, u16 *tags_free,
3531 struct i40e_asq_cmd_details *cmd_details)
3533 struct i40e_aq_desc desc;
3534 struct i40e_aqc_add_remove_mcast_etag *cmd =
3535 (struct i40e_aqc_add_remove_mcast_etag *)&desc.params.raw;
3536 struct i40e_aqc_add_remove_mcast_etag_completion *resp =
3537 (struct i40e_aqc_add_remove_mcast_etag_completion *)&desc.params.raw;
3538 enum i40e_status_code status;
3542 return I40E_ERR_PARAM;
3544 i40e_fill_default_direct_cmd_desc(&desc,
3545 i40e_aqc_opc_remove_multicast_etag);
3547 cmd->pv_seid = CPU_TO_LE16(pv_seid);
3548 cmd->etag = CPU_TO_LE16(etag);
3550 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3553 if (tags_used != NULL)
3554 *tags_used = LE16_TO_CPU(resp->mcast_etags_used);
3555 if (tags_free != NULL)
3556 *tags_free = LE16_TO_CPU(resp->mcast_etags_free);
3563 * i40e_aq_update_tag - Update an S/E-tag
3564 * @hw: pointer to the hw struct
3565 * @vsi_seid: VSI SEID using this S-tag
3566 * @old_tag: old tag value
3567 * @new_tag: new tag value
3568 * @tags_used: return value, number of tags in use by this PF
3569 * @tags_free: return value, number of unallocated tags
3570 * @cmd_details: pointer to command details structure or NULL
3572 * This updates the value of the tag currently attached to this VSI
3573 * in the switch complex. It will return the number of tags allocated
3574 * by the PF, and the number of unallocated tags available.
3576 enum i40e_status_code i40e_aq_update_tag(struct i40e_hw *hw, u16 vsi_seid,
3577 u16 old_tag, u16 new_tag, u16 *tags_used,
3579 struct i40e_asq_cmd_details *cmd_details)
3581 struct i40e_aq_desc desc;
3582 struct i40e_aqc_update_tag *cmd =
3583 (struct i40e_aqc_update_tag *)&desc.params.raw;
3584 struct i40e_aqc_update_tag_completion *resp =
3585 (struct i40e_aqc_update_tag_completion *)&desc.params.raw;
3586 enum i40e_status_code status;
3589 return I40E_ERR_PARAM;
3591 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_update_tag);
3593 cmd->seid = CPU_TO_LE16(vsi_seid);
3594 cmd->old_tag = CPU_TO_LE16(old_tag);
3595 cmd->new_tag = CPU_TO_LE16(new_tag);
3597 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3600 if (tags_used != NULL)
3601 *tags_used = LE16_TO_CPU(resp->tags_used);
3602 if (tags_free != NULL)
3603 *tags_free = LE16_TO_CPU(resp->tags_free);
3610 * i40e_aq_dcb_ignore_pfc - Ignore PFC for given TCs
3611 * @hw: pointer to the hw struct
3612 * @tcmap: TC map for request/release any ignore PFC condition
3613 * @request: request or release ignore PFC condition
3614 * @tcmap_ret: return TCs for which PFC is currently ignored
3615 * @cmd_details: pointer to command details structure or NULL
3617 * This sends out request/release to ignore PFC condition for a TC.
3618 * It will return the TCs for which PFC is currently ignored.
3620 enum i40e_status_code i40e_aq_dcb_ignore_pfc(struct i40e_hw *hw, u8 tcmap,
3621 bool request, u8 *tcmap_ret,
3622 struct i40e_asq_cmd_details *cmd_details)
3624 struct i40e_aq_desc desc;
3625 struct i40e_aqc_pfc_ignore *cmd_resp =
3626 (struct i40e_aqc_pfc_ignore *)&desc.params.raw;
3627 enum i40e_status_code status;
3629 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_dcb_ignore_pfc);
3632 cmd_resp->command_flags = I40E_AQC_PFC_IGNORE_SET;
3634 cmd_resp->tc_bitmap = tcmap;
3636 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3639 if (tcmap_ret != NULL)
3640 *tcmap_ret = cmd_resp->tc_bitmap;
3647 * i40e_aq_dcb_updated - DCB Updated Command
3648 * @hw: pointer to the hw struct
3649 * @cmd_details: pointer to command details structure or NULL
3651 * When LLDP is handled in PF this command is used by the PF
3652 * to notify EMP that a DCB setting is modified.
3653 * When LLDP is handled in EMP this command is used by the PF
3654 * to notify EMP whenever one of the following parameters get
3656 * - PFCLinkDelayAllowance in PRTDCB_GENC.PFCLDA
3657 * - PCIRTT in PRTDCB_GENC.PCIRTT
3658 * - Maximum Frame Size for non-FCoE TCs set by PRTDCB_TDPUC.MAX_TXFRAME.
3659 * EMP will return when the shared RPB settings have been
3660 * recomputed and modified. The retval field in the descriptor
3661 * will be set to 0 when RPB is modified.
3663 enum i40e_status_code i40e_aq_dcb_updated(struct i40e_hw *hw,
3664 struct i40e_asq_cmd_details *cmd_details)
3666 struct i40e_aq_desc desc;
3667 enum i40e_status_code status;
3669 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_dcb_updated);
3671 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3677 * i40e_aq_add_statistics - Add a statistics block to a VLAN in a switch.
3678 * @hw: pointer to the hw struct
3679 * @seid: defines the SEID of the switch for which the stats are requested
3680 * @vlan_id: the VLAN ID for which the statistics are requested
3681 * @stat_index: index of the statistics counters block assigned to this VLAN
3682 * @cmd_details: pointer to command details structure or NULL
3684 * XL710 supports 128 smonVlanStats counters.This command is used to
3685 * allocate a set of smonVlanStats counters to a specific VLAN in a specific
3688 enum i40e_status_code i40e_aq_add_statistics(struct i40e_hw *hw, u16 seid,
3689 u16 vlan_id, u16 *stat_index,
3690 struct i40e_asq_cmd_details *cmd_details)
3692 struct i40e_aq_desc desc;
3693 struct i40e_aqc_add_remove_statistics *cmd_resp =
3694 (struct i40e_aqc_add_remove_statistics *)&desc.params.raw;
3695 enum i40e_status_code status;
3697 if ((seid == 0) || (stat_index == NULL))
3698 return I40E_ERR_PARAM;
3700 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_add_statistics);
3702 cmd_resp->seid = CPU_TO_LE16(seid);
3703 cmd_resp->vlan = CPU_TO_LE16(vlan_id);
3705 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3708 *stat_index = LE16_TO_CPU(cmd_resp->stat_index);
3714 * i40e_aq_remove_statistics - Remove a statistics block to a VLAN in a switch.
3715 * @hw: pointer to the hw struct
3716 * @seid: defines the SEID of the switch for which the stats are requested
3717 * @vlan_id: the VLAN ID for which the statistics are requested
3718 * @stat_index: index of the statistics counters block assigned to this VLAN
3719 * @cmd_details: pointer to command details structure or NULL
3721 * XL710 supports 128 smonVlanStats counters.This command is used to
3722 * deallocate a set of smonVlanStats counters to a specific VLAN in a specific
3725 enum i40e_status_code i40e_aq_remove_statistics(struct i40e_hw *hw, u16 seid,
3726 u16 vlan_id, u16 stat_index,
3727 struct i40e_asq_cmd_details *cmd_details)
3729 struct i40e_aq_desc desc;
3730 struct i40e_aqc_add_remove_statistics *cmd =
3731 (struct i40e_aqc_add_remove_statistics *)&desc.params.raw;
3732 enum i40e_status_code status;
3735 return I40E_ERR_PARAM;
3737 i40e_fill_default_direct_cmd_desc(&desc,
3738 i40e_aqc_opc_remove_statistics);
3740 cmd->seid = CPU_TO_LE16(seid);
3741 cmd->vlan = CPU_TO_LE16(vlan_id);
3742 cmd->stat_index = CPU_TO_LE16(stat_index);
3744 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3750 * i40e_aq_set_port_parameters - set physical port parameters.
3751 * @hw: pointer to the hw struct
3752 * @bad_frame_vsi: defines the VSI to which bad frames are forwarded
3753 * @save_bad_pac: if set packets with errors are forwarded to the bad frames VSI
3754 * @pad_short_pac: if set transmit packets smaller than 60 bytes are padded
3755 * @double_vlan: if set double VLAN is enabled
3756 * @cmd_details: pointer to command details structure or NULL
3758 enum i40e_status_code i40e_aq_set_port_parameters(struct i40e_hw *hw,
3759 u16 bad_frame_vsi, bool save_bad_pac,
3760 bool pad_short_pac, bool double_vlan,
3761 struct i40e_asq_cmd_details *cmd_details)
3763 struct i40e_aqc_set_port_parameters *cmd;
3764 enum i40e_status_code status;
3765 struct i40e_aq_desc desc;
3766 u16 command_flags = 0;
3768 cmd = (struct i40e_aqc_set_port_parameters *)&desc.params.raw;
3770 i40e_fill_default_direct_cmd_desc(&desc,
3771 i40e_aqc_opc_set_port_parameters);
3773 cmd->bad_frame_vsi = CPU_TO_LE16(bad_frame_vsi);
3775 command_flags |= I40E_AQ_SET_P_PARAMS_SAVE_BAD_PACKETS;
3777 command_flags |= I40E_AQ_SET_P_PARAMS_PAD_SHORT_PACKETS;
3779 command_flags |= I40E_AQ_SET_P_PARAMS_DOUBLE_VLAN_ENA;
3780 cmd->command_flags = CPU_TO_LE16(command_flags);
3782 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3788 * i40e_aq_tx_sched_cmd - generic Tx scheduler AQ command handler
3789 * @hw: pointer to the hw struct
3790 * @seid: seid for the physical port/switching component/vsi
3791 * @buff: Indirect buffer to hold data parameters and response
3792 * @buff_size: Indirect buffer size
3793 * @opcode: Tx scheduler AQ command opcode
3794 * @cmd_details: pointer to command details structure or NULL
3796 * Generic command handler for Tx scheduler AQ commands
3798 static enum i40e_status_code i40e_aq_tx_sched_cmd(struct i40e_hw *hw, u16 seid,
3799 void *buff, u16 buff_size,
3800 enum i40e_admin_queue_opc opcode,
3801 struct i40e_asq_cmd_details *cmd_details)
3803 struct i40e_aq_desc desc;
3804 struct i40e_aqc_tx_sched_ind *cmd =
3805 (struct i40e_aqc_tx_sched_ind *)&desc.params.raw;
3806 enum i40e_status_code status;
3807 bool cmd_param_flag = false;
3810 case i40e_aqc_opc_configure_vsi_ets_sla_bw_limit:
3811 case i40e_aqc_opc_configure_vsi_tc_bw:
3812 case i40e_aqc_opc_enable_switching_comp_ets:
3813 case i40e_aqc_opc_modify_switching_comp_ets:
3814 case i40e_aqc_opc_disable_switching_comp_ets:
3815 case i40e_aqc_opc_configure_switching_comp_ets_bw_limit:
3816 case i40e_aqc_opc_configure_switching_comp_bw_config:
3817 cmd_param_flag = true;
3819 case i40e_aqc_opc_query_vsi_bw_config:
3820 case i40e_aqc_opc_query_vsi_ets_sla_config:
3821 case i40e_aqc_opc_query_switching_comp_ets_config:
3822 case i40e_aqc_opc_query_port_ets_config:
3823 case i40e_aqc_opc_query_switching_comp_bw_config:
3824 cmd_param_flag = false;
3827 return I40E_ERR_PARAM;
3830 i40e_fill_default_direct_cmd_desc(&desc, opcode);
3832 /* Indirect command */
3833 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_BUF);
3835 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_RD);
3836 if (buff_size > I40E_AQ_LARGE_BUF)
3837 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
3839 desc.datalen = CPU_TO_LE16(buff_size);
3841 cmd->vsi_seid = CPU_TO_LE16(seid);
3843 status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
3849 * i40e_aq_config_vsi_bw_limit - Configure VSI BW Limit
3850 * @hw: pointer to the hw struct
3852 * @credit: BW limit credits (0 = disabled)
3853 * @max_credit: Max BW limit credits
3854 * @cmd_details: pointer to command details structure or NULL
3856 enum i40e_status_code i40e_aq_config_vsi_bw_limit(struct i40e_hw *hw,
3857 u16 seid, u16 credit, u8 max_credit,
3858 struct i40e_asq_cmd_details *cmd_details)
3860 struct i40e_aq_desc desc;
3861 struct i40e_aqc_configure_vsi_bw_limit *cmd =
3862 (struct i40e_aqc_configure_vsi_bw_limit *)&desc.params.raw;
3863 enum i40e_status_code status;
3865 i40e_fill_default_direct_cmd_desc(&desc,
3866 i40e_aqc_opc_configure_vsi_bw_limit);
3868 cmd->vsi_seid = CPU_TO_LE16(seid);
3869 cmd->credit = CPU_TO_LE16(credit);
3870 cmd->max_credit = max_credit;
3872 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3878 * i40e_aq_config_switch_comp_bw_limit - Configure Switching component BW Limit
3879 * @hw: pointer to the hw struct
3880 * @seid: switching component seid
3881 * @credit: BW limit credits (0 = disabled)
3882 * @max_bw: Max BW limit credits
3883 * @cmd_details: pointer to command details structure or NULL
3885 enum i40e_status_code i40e_aq_config_switch_comp_bw_limit(struct i40e_hw *hw,
3886 u16 seid, u16 credit, u8 max_bw,
3887 struct i40e_asq_cmd_details *cmd_details)
3889 struct i40e_aq_desc desc;
3890 struct i40e_aqc_configure_switching_comp_bw_limit *cmd =
3891 (struct i40e_aqc_configure_switching_comp_bw_limit *)&desc.params.raw;
3892 enum i40e_status_code status;
3894 i40e_fill_default_direct_cmd_desc(&desc,
3895 i40e_aqc_opc_configure_switching_comp_bw_limit);
3897 cmd->seid = CPU_TO_LE16(seid);
3898 cmd->credit = CPU_TO_LE16(credit);
3899 cmd->max_bw = max_bw;
3901 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3907 * i40e_aq_config_vsi_ets_sla_bw_limit - Config VSI BW Limit per TC
3908 * @hw: pointer to the hw struct
3910 * @bw_data: Buffer holding enabled TCs, per TC BW limit/credits
3911 * @cmd_details: pointer to command details structure or NULL
3913 enum i40e_status_code i40e_aq_config_vsi_ets_sla_bw_limit(struct i40e_hw *hw,
3915 struct i40e_aqc_configure_vsi_ets_sla_bw_data *bw_data,
3916 struct i40e_asq_cmd_details *cmd_details)
3918 return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data),
3919 i40e_aqc_opc_configure_vsi_ets_sla_bw_limit,
3924 * i40e_aq_config_vsi_tc_bw - Config VSI BW Allocation per TC
3925 * @hw: pointer to the hw struct
3927 * @bw_data: Buffer holding enabled TCs, relative TC BW limit/credits
3928 * @cmd_details: pointer to command details structure or NULL
3930 enum i40e_status_code i40e_aq_config_vsi_tc_bw(struct i40e_hw *hw,
3932 struct i40e_aqc_configure_vsi_tc_bw_data *bw_data,
3933 struct i40e_asq_cmd_details *cmd_details)
3935 return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data),
3936 i40e_aqc_opc_configure_vsi_tc_bw,
3941 * i40e_aq_config_switch_comp_ets_bw_limit - Config Switch comp BW Limit per TC
3942 * @hw: pointer to the hw struct
3943 * @seid: seid of the switching component
3944 * @bw_data: Buffer holding enabled TCs, per TC BW limit/credits
3945 * @cmd_details: pointer to command details structure or NULL
3947 enum i40e_status_code i40e_aq_config_switch_comp_ets_bw_limit(
3948 struct i40e_hw *hw, u16 seid,
3949 struct i40e_aqc_configure_switching_comp_ets_bw_limit_data *bw_data,
3950 struct i40e_asq_cmd_details *cmd_details)
3952 return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data),
3953 i40e_aqc_opc_configure_switching_comp_ets_bw_limit,
3958 * i40e_aq_query_vsi_bw_config - Query VSI BW configuration
3959 * @hw: pointer to the hw struct
3960 * @seid: seid of the VSI
3961 * @bw_data: Buffer to hold VSI BW configuration
3962 * @cmd_details: pointer to command details structure or NULL
3964 enum i40e_status_code i40e_aq_query_vsi_bw_config(struct i40e_hw *hw,
3966 struct i40e_aqc_query_vsi_bw_config_resp *bw_data,
3967 struct i40e_asq_cmd_details *cmd_details)
3969 return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data),
3970 i40e_aqc_opc_query_vsi_bw_config,
3975 * i40e_aq_query_vsi_ets_sla_config - Query VSI BW configuration per TC
3976 * @hw: pointer to the hw struct
3977 * @seid: seid of the VSI
3978 * @bw_data: Buffer to hold VSI BW configuration per TC
3979 * @cmd_details: pointer to command details structure or NULL
3981 enum i40e_status_code i40e_aq_query_vsi_ets_sla_config(struct i40e_hw *hw,
3983 struct i40e_aqc_query_vsi_ets_sla_config_resp *bw_data,
3984 struct i40e_asq_cmd_details *cmd_details)
3986 return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data),
3987 i40e_aqc_opc_query_vsi_ets_sla_config,
3992 * i40e_aq_query_switch_comp_ets_config - Query Switch comp BW config per TC
3993 * @hw: pointer to the hw struct
3994 * @seid: seid of the switching component
3995 * @bw_data: Buffer to hold switching component's per TC BW config
3996 * @cmd_details: pointer to command details structure or NULL
3998 enum i40e_status_code i40e_aq_query_switch_comp_ets_config(struct i40e_hw *hw,
4000 struct i40e_aqc_query_switching_comp_ets_config_resp *bw_data,
4001 struct i40e_asq_cmd_details *cmd_details)
4003 return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data),
4004 i40e_aqc_opc_query_switching_comp_ets_config,
4009 * i40e_aq_query_port_ets_config - Query Physical Port ETS configuration
4010 * @hw: pointer to the hw struct
4011 * @seid: seid of the VSI or switching component connected to Physical Port
4012 * @bw_data: Buffer to hold current ETS configuration for the Physical Port
4013 * @cmd_details: pointer to command details structure or NULL
4015 enum i40e_status_code i40e_aq_query_port_ets_config(struct i40e_hw *hw,
4017 struct i40e_aqc_query_port_ets_config_resp *bw_data,
4018 struct i40e_asq_cmd_details *cmd_details)
4020 return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data),
4021 i40e_aqc_opc_query_port_ets_config,
4026 * i40e_aq_query_switch_comp_bw_config - Query Switch comp BW configuration
4027 * @hw: pointer to the hw struct
4028 * @seid: seid of the switching component
4029 * @bw_data: Buffer to hold switching component's BW configuration
4030 * @cmd_details: pointer to command details structure or NULL
4032 enum i40e_status_code i40e_aq_query_switch_comp_bw_config(struct i40e_hw *hw,
4034 struct i40e_aqc_query_switching_comp_bw_config_resp *bw_data,
4035 struct i40e_asq_cmd_details *cmd_details)
4037 return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data),
4038 i40e_aqc_opc_query_switching_comp_bw_config,
4043 * i40e_validate_filter_settings
4044 * @hw: pointer to the hardware structure
4045 * @settings: Filter control settings
4047 * Check and validate the filter control settings passed.
4048 * The function checks for the valid filter/context sizes being
4049 * passed for FCoE and PE.
4051 * Returns I40E_SUCCESS if the values passed are valid and within
4052 * range else returns an error.
4054 STATIC enum i40e_status_code i40e_validate_filter_settings(struct i40e_hw *hw,
4055 struct i40e_filter_control_settings *settings)
4057 u32 fcoe_cntx_size, fcoe_filt_size;
4058 u32 pe_cntx_size, pe_filt_size;
4063 /* Validate FCoE settings passed */
4064 switch (settings->fcoe_filt_num) {
4065 case I40E_HASH_FILTER_SIZE_1K:
4066 case I40E_HASH_FILTER_SIZE_2K:
4067 case I40E_HASH_FILTER_SIZE_4K:
4068 case I40E_HASH_FILTER_SIZE_8K:
4069 case I40E_HASH_FILTER_SIZE_16K:
4070 case I40E_HASH_FILTER_SIZE_32K:
4071 fcoe_filt_size = I40E_HASH_FILTER_BASE_SIZE;
4072 fcoe_filt_size <<= (u32)settings->fcoe_filt_num;
4075 return I40E_ERR_PARAM;
4078 switch (settings->fcoe_cntx_num) {
4079 case I40E_DMA_CNTX_SIZE_512:
4080 case I40E_DMA_CNTX_SIZE_1K:
4081 case I40E_DMA_CNTX_SIZE_2K:
4082 case I40E_DMA_CNTX_SIZE_4K:
4083 fcoe_cntx_size = I40E_DMA_CNTX_BASE_SIZE;
4084 fcoe_cntx_size <<= (u32)settings->fcoe_cntx_num;
4087 return I40E_ERR_PARAM;
4090 /* Validate PE settings passed */
4091 switch (settings->pe_filt_num) {
4092 case I40E_HASH_FILTER_SIZE_1K:
4093 case I40E_HASH_FILTER_SIZE_2K:
4094 case I40E_HASH_FILTER_SIZE_4K:
4095 case I40E_HASH_FILTER_SIZE_8K:
4096 case I40E_HASH_FILTER_SIZE_16K:
4097 case I40E_HASH_FILTER_SIZE_32K:
4098 case I40E_HASH_FILTER_SIZE_64K:
4099 case I40E_HASH_FILTER_SIZE_128K:
4100 case I40E_HASH_FILTER_SIZE_256K:
4101 case I40E_HASH_FILTER_SIZE_512K:
4102 case I40E_HASH_FILTER_SIZE_1M:
4103 pe_filt_size = I40E_HASH_FILTER_BASE_SIZE;
4104 pe_filt_size <<= (u32)settings->pe_filt_num;
4107 return I40E_ERR_PARAM;
4110 switch (settings->pe_cntx_num) {
4111 case I40E_DMA_CNTX_SIZE_512:
4112 case I40E_DMA_CNTX_SIZE_1K:
4113 case I40E_DMA_CNTX_SIZE_2K:
4114 case I40E_DMA_CNTX_SIZE_4K:
4115 case I40E_DMA_CNTX_SIZE_8K:
4116 case I40E_DMA_CNTX_SIZE_16K:
4117 case I40E_DMA_CNTX_SIZE_32K:
4118 case I40E_DMA_CNTX_SIZE_64K:
4119 case I40E_DMA_CNTX_SIZE_128K:
4120 case I40E_DMA_CNTX_SIZE_256K:
4121 pe_cntx_size = I40E_DMA_CNTX_BASE_SIZE;
4122 pe_cntx_size <<= (u32)settings->pe_cntx_num;
4125 return I40E_ERR_PARAM;
4128 /* FCHSIZE + FCDSIZE should not be greater than PMFCOEFMAX */
4129 val = rd32(hw, I40E_GLHMC_FCOEFMAX);
4130 fcoe_fmax = (val & I40E_GLHMC_FCOEFMAX_PMFCOEFMAX_MASK)
4131 >> I40E_GLHMC_FCOEFMAX_PMFCOEFMAX_SHIFT;
4132 if (fcoe_filt_size + fcoe_cntx_size > fcoe_fmax)
4133 return I40E_ERR_INVALID_SIZE;
4135 return I40E_SUCCESS;
4139 * i40e_set_filter_control
4140 * @hw: pointer to the hardware structure
4141 * @settings: Filter control settings
4143 * Set the Queue Filters for PE/FCoE and enable filters required
4144 * for a single PF. It is expected that these settings are programmed
4145 * at the driver initialization time.
4147 enum i40e_status_code i40e_set_filter_control(struct i40e_hw *hw,
4148 struct i40e_filter_control_settings *settings)
4150 enum i40e_status_code ret = I40E_SUCCESS;
4151 u32 hash_lut_size = 0;
4155 return I40E_ERR_PARAM;
4157 /* Validate the input settings */
4158 ret = i40e_validate_filter_settings(hw, settings);
4162 /* Read the PF Queue Filter control register */
4163 val = rd32(hw, I40E_PFQF_CTL_0);
4165 /* Program required PE hash buckets for the PF */
4166 val &= ~I40E_PFQF_CTL_0_PEHSIZE_MASK;
4167 val |= ((u32)settings->pe_filt_num << I40E_PFQF_CTL_0_PEHSIZE_SHIFT) &
4168 I40E_PFQF_CTL_0_PEHSIZE_MASK;
4169 /* Program required PE contexts for the PF */
4170 val &= ~I40E_PFQF_CTL_0_PEDSIZE_MASK;
4171 val |= ((u32)settings->pe_cntx_num << I40E_PFQF_CTL_0_PEDSIZE_SHIFT) &
4172 I40E_PFQF_CTL_0_PEDSIZE_MASK;
4174 /* Program required FCoE hash buckets for the PF */
4175 val &= ~I40E_PFQF_CTL_0_PFFCHSIZE_MASK;
4176 val |= ((u32)settings->fcoe_filt_num <<
4177 I40E_PFQF_CTL_0_PFFCHSIZE_SHIFT) &
4178 I40E_PFQF_CTL_0_PFFCHSIZE_MASK;
4179 /* Program required FCoE DDP contexts for the PF */
4180 val &= ~I40E_PFQF_CTL_0_PFFCDSIZE_MASK;
4181 val |= ((u32)settings->fcoe_cntx_num <<
4182 I40E_PFQF_CTL_0_PFFCDSIZE_SHIFT) &
4183 I40E_PFQF_CTL_0_PFFCDSIZE_MASK;
4185 /* Program Hash LUT size for the PF */
4186 val &= ~I40E_PFQF_CTL_0_HASHLUTSIZE_MASK;
4187 if (settings->hash_lut_size == I40E_HASH_LUT_SIZE_512)
4189 val |= (hash_lut_size << I40E_PFQF_CTL_0_HASHLUTSIZE_SHIFT) &
4190 I40E_PFQF_CTL_0_HASHLUTSIZE_MASK;
4192 /* Enable FDIR, Ethertype and MACVLAN filters for PF and VFs */
4193 if (settings->enable_fdir)
4194 val |= I40E_PFQF_CTL_0_FD_ENA_MASK;
4195 if (settings->enable_ethtype)
4196 val |= I40E_PFQF_CTL_0_ETYPE_ENA_MASK;
4197 if (settings->enable_macvlan)
4198 val |= I40E_PFQF_CTL_0_MACVLAN_ENA_MASK;
4200 wr32(hw, I40E_PFQF_CTL_0, val);
4202 return I40E_SUCCESS;
4206 * i40e_aq_add_rem_control_packet_filter - Add or Remove Control Packet Filter
4207 * @hw: pointer to the hw struct
4208 * @mac_addr: MAC address to use in the filter
4209 * @ethtype: Ethertype to use in the filter
4210 * @flags: Flags that needs to be applied to the filter
4211 * @vsi_seid: seid of the control VSI
4212 * @queue: VSI queue number to send the packet to
4213 * @is_add: Add control packet filter if True else remove
4214 * @stats: Structure to hold information on control filter counts
4215 * @cmd_details: pointer to command details structure or NULL
4217 * This command will Add or Remove control packet filter for a control VSI.
4218 * In return it will update the total number of perfect filter count in
4221 enum i40e_status_code i40e_aq_add_rem_control_packet_filter(struct i40e_hw *hw,
4222 u8 *mac_addr, u16 ethtype, u16 flags,
4223 u16 vsi_seid, u16 queue, bool is_add,
4224 struct i40e_control_filter_stats *stats,
4225 struct i40e_asq_cmd_details *cmd_details)
4227 struct i40e_aq_desc desc;
4228 struct i40e_aqc_add_remove_control_packet_filter *cmd =
4229 (struct i40e_aqc_add_remove_control_packet_filter *)
4231 struct i40e_aqc_add_remove_control_packet_filter_completion *resp =
4232 (struct i40e_aqc_add_remove_control_packet_filter_completion *)
4234 enum i40e_status_code status;
4237 return I40E_ERR_PARAM;
4240 i40e_fill_default_direct_cmd_desc(&desc,
4241 i40e_aqc_opc_add_control_packet_filter);
4242 cmd->queue = CPU_TO_LE16(queue);
4244 i40e_fill_default_direct_cmd_desc(&desc,
4245 i40e_aqc_opc_remove_control_packet_filter);
4249 i40e_memcpy(cmd->mac, mac_addr, I40E_ETH_LENGTH_OF_ADDRESS,
4250 I40E_NONDMA_TO_NONDMA);
4252 cmd->etype = CPU_TO_LE16(ethtype);
4253 cmd->flags = CPU_TO_LE16(flags);
4254 cmd->seid = CPU_TO_LE16(vsi_seid);
4256 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
4258 if (!status && stats) {
4259 stats->mac_etype_used = LE16_TO_CPU(resp->mac_etype_used);
4260 stats->etype_used = LE16_TO_CPU(resp->etype_used);
4261 stats->mac_etype_free = LE16_TO_CPU(resp->mac_etype_free);
4262 stats->etype_free = LE16_TO_CPU(resp->etype_free);
4269 * i40e_aq_add_cloud_filters
4270 * @hw: pointer to the hardware structure
4271 * @seid: VSI seid to add cloud filters from
4272 * @filters: Buffer which contains the filters to be added
4273 * @filter_count: number of filters contained in the buffer
4275 * Set the cloud filters for a given VSI. The contents of the
4276 * i40e_aqc_add_remove_cloud_filters_element_data are filled
4277 * in by the caller of the function.
4280 enum i40e_status_code i40e_aq_add_cloud_filters(struct i40e_hw *hw,
4282 struct i40e_aqc_add_remove_cloud_filters_element_data *filters,
4285 struct i40e_aq_desc desc;
4286 struct i40e_aqc_add_remove_cloud_filters *cmd =
4287 (struct i40e_aqc_add_remove_cloud_filters *)&desc.params.raw;
4289 enum i40e_status_code status;
4291 i40e_fill_default_direct_cmd_desc(&desc,
4292 i40e_aqc_opc_add_cloud_filters);
4294 buff_len = sizeof(struct i40e_aqc_add_remove_cloud_filters_element_data) *
4296 desc.datalen = CPU_TO_LE16(buff_len);
4297 desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
4298 cmd->num_filters = filter_count;
4299 cmd->seid = CPU_TO_LE16(seid);
4301 status = i40e_asq_send_command(hw, &desc, filters, buff_len, NULL);
4307 * i40e_aq_remove_cloud_filters
4308 * @hw: pointer to the hardware structure
4309 * @seid: VSI seid to remove cloud filters from
4310 * @filters: Buffer which contains the filters to be removed
4311 * @filter_count: number of filters contained in the buffer
4313 * Remove the cloud filters for a given VSI. The contents of the
4314 * i40e_aqc_add_remove_cloud_filters_element_data are filled
4315 * in by the caller of the function.
4318 enum i40e_status_code i40e_aq_remove_cloud_filters(struct i40e_hw *hw,
4320 struct i40e_aqc_add_remove_cloud_filters_element_data *filters,
4323 struct i40e_aq_desc desc;
4324 struct i40e_aqc_add_remove_cloud_filters *cmd =
4325 (struct i40e_aqc_add_remove_cloud_filters *)&desc.params.raw;
4326 enum i40e_status_code status;
4329 i40e_fill_default_direct_cmd_desc(&desc,
4330 i40e_aqc_opc_remove_cloud_filters);
4332 buff_len = sizeof(struct i40e_aqc_add_remove_cloud_filters_element_data) *
4334 desc.datalen = CPU_TO_LE16(buff_len);
4335 desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
4336 cmd->num_filters = filter_count;
4337 cmd->seid = CPU_TO_LE16(seid);
4339 status = i40e_asq_send_command(hw, &desc, filters, buff_len, NULL);
4345 * i40e_aq_alternate_write
4346 * @hw: pointer to the hardware structure
4347 * @reg_addr0: address of first dword to be read
4348 * @reg_val0: value to be written under 'reg_addr0'
4349 * @reg_addr1: address of second dword to be read
4350 * @reg_val1: value to be written under 'reg_addr1'
4352 * Write one or two dwords to alternate structure. Fields are indicated
4353 * by 'reg_addr0' and 'reg_addr1' register numbers.
4356 enum i40e_status_code i40e_aq_alternate_write(struct i40e_hw *hw,
4357 u32 reg_addr0, u32 reg_val0,
4358 u32 reg_addr1, u32 reg_val1)
4360 struct i40e_aq_desc desc;
4361 struct i40e_aqc_alternate_write *cmd_resp =
4362 (struct i40e_aqc_alternate_write *)&desc.params.raw;
4363 enum i40e_status_code status;
4365 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_alternate_write);
4366 cmd_resp->address0 = CPU_TO_LE32(reg_addr0);
4367 cmd_resp->address1 = CPU_TO_LE32(reg_addr1);
4368 cmd_resp->data0 = CPU_TO_LE32(reg_val0);
4369 cmd_resp->data1 = CPU_TO_LE32(reg_val1);
4371 status = i40e_asq_send_command(hw, &desc, NULL, 0, NULL);
4377 * i40e_aq_alternate_write_indirect
4378 * @hw: pointer to the hardware structure
4379 * @addr: address of a first register to be modified
4380 * @dw_count: number of alternate structure fields to write
4381 * @buffer: pointer to the command buffer
4383 * Write 'dw_count' dwords from 'buffer' to alternate structure
4384 * starting at 'addr'.
4387 enum i40e_status_code i40e_aq_alternate_write_indirect(struct i40e_hw *hw,
4388 u32 addr, u32 dw_count, void *buffer)
4390 struct i40e_aq_desc desc;
4391 struct i40e_aqc_alternate_ind_write *cmd_resp =
4392 (struct i40e_aqc_alternate_ind_write *)&desc.params.raw;
4393 enum i40e_status_code status;
4396 return I40E_ERR_PARAM;
4398 /* Indirect command */
4399 i40e_fill_default_direct_cmd_desc(&desc,
4400 i40e_aqc_opc_alternate_write_indirect);
4402 desc.flags |= CPU_TO_LE16(I40E_AQ_FLAG_RD);
4403 desc.flags |= CPU_TO_LE16(I40E_AQ_FLAG_BUF);
4404 if (dw_count > (I40E_AQ_LARGE_BUF/4))
4405 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
4407 cmd_resp->address = CPU_TO_LE32(addr);
4408 cmd_resp->length = CPU_TO_LE32(dw_count);
4409 cmd_resp->addr_high = CPU_TO_LE32(I40E_HI_WORD((u64)buffer));
4410 cmd_resp->addr_low = CPU_TO_LE32(I40E_LO_DWORD((u64)buffer));
4412 status = i40e_asq_send_command(hw, &desc, buffer,
4413 I40E_LO_DWORD(4*dw_count), NULL);
4419 * i40e_aq_alternate_read
4420 * @hw: pointer to the hardware structure
4421 * @reg_addr0: address of first dword to be read
4422 * @reg_val0: pointer for data read from 'reg_addr0'
4423 * @reg_addr1: address of second dword to be read
4424 * @reg_val1: pointer for data read from 'reg_addr1'
4426 * Read one or two dwords from alternate structure. Fields are indicated
4427 * by 'reg_addr0' and 'reg_addr1' register numbers. If 'reg_val1' pointer
4428 * is not passed then only register at 'reg_addr0' is read.
4431 enum i40e_status_code i40e_aq_alternate_read(struct i40e_hw *hw,
4432 u32 reg_addr0, u32 *reg_val0,
4433 u32 reg_addr1, u32 *reg_val1)
4435 struct i40e_aq_desc desc;
4436 struct i40e_aqc_alternate_write *cmd_resp =
4437 (struct i40e_aqc_alternate_write *)&desc.params.raw;
4438 enum i40e_status_code status;
4440 if (reg_val0 == NULL)
4441 return I40E_ERR_PARAM;
4443 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_alternate_read);
4444 cmd_resp->address0 = CPU_TO_LE32(reg_addr0);
4445 cmd_resp->address1 = CPU_TO_LE32(reg_addr1);
4447 status = i40e_asq_send_command(hw, &desc, NULL, 0, NULL);
4449 if (status == I40E_SUCCESS) {
4450 *reg_val0 = LE32_TO_CPU(cmd_resp->data0);
4452 if (reg_val1 != NULL)
4453 *reg_val1 = LE32_TO_CPU(cmd_resp->data1);
4460 * i40e_aq_alternate_read_indirect
4461 * @hw: pointer to the hardware structure
4462 * @addr: address of the alternate structure field
4463 * @dw_count: number of alternate structure fields to read
4464 * @buffer: pointer to the command buffer
4466 * Read 'dw_count' dwords from alternate structure starting at 'addr' and
4467 * place them in 'buffer'. The buffer should be allocated by caller.
4470 enum i40e_status_code i40e_aq_alternate_read_indirect(struct i40e_hw *hw,
4471 u32 addr, u32 dw_count, void *buffer)
4473 struct i40e_aq_desc desc;
4474 struct i40e_aqc_alternate_ind_write *cmd_resp =
4475 (struct i40e_aqc_alternate_ind_write *)&desc.params.raw;
4476 enum i40e_status_code status;
4479 return I40E_ERR_PARAM;
4481 /* Indirect command */
4482 i40e_fill_default_direct_cmd_desc(&desc,
4483 i40e_aqc_opc_alternate_read_indirect);
4485 desc.flags |= CPU_TO_LE16(I40E_AQ_FLAG_RD);
4486 desc.flags |= CPU_TO_LE16(I40E_AQ_FLAG_BUF);
4487 if (dw_count > (I40E_AQ_LARGE_BUF/4))
4488 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
4490 cmd_resp->address = CPU_TO_LE32(addr);
4491 cmd_resp->length = CPU_TO_LE32(dw_count);
4492 cmd_resp->addr_high = CPU_TO_LE32(I40E_HI_DWORD((u64)buffer));
4493 cmd_resp->addr_low = CPU_TO_LE32(I40E_LO_DWORD((u64)buffer));
4495 status = i40e_asq_send_command(hw, &desc, buffer,
4496 I40E_LO_DWORD(4*dw_count), NULL);
4502 * i40e_aq_alternate_clear
4503 * @hw: pointer to the HW structure.
4505 * Clear the alternate structures of the port from which the function
4509 enum i40e_status_code i40e_aq_alternate_clear(struct i40e_hw *hw)
4511 struct i40e_aq_desc desc;
4512 enum i40e_status_code status;
4514 i40e_fill_default_direct_cmd_desc(&desc,
4515 i40e_aqc_opc_alternate_clear_port);
4517 status = i40e_asq_send_command(hw, &desc, NULL, 0, NULL);
4523 * i40e_aq_alternate_write_done
4524 * @hw: pointer to the HW structure.
4525 * @bios_mode: indicates whether the command is executed by UEFI or legacy BIOS
4526 * @reset_needed: indicates the SW should trigger GLOBAL reset
4528 * Indicates to the FW that alternate structures have been changed.
4531 enum i40e_status_code i40e_aq_alternate_write_done(struct i40e_hw *hw,
4532 u8 bios_mode, bool *reset_needed)
4534 struct i40e_aq_desc desc;
4535 struct i40e_aqc_alternate_write_done *cmd =
4536 (struct i40e_aqc_alternate_write_done *)&desc.params.raw;
4537 enum i40e_status_code status;
4539 if (reset_needed == NULL)
4540 return I40E_ERR_PARAM;
4542 i40e_fill_default_direct_cmd_desc(&desc,
4543 i40e_aqc_opc_alternate_write_done);
4545 cmd->cmd_flags = CPU_TO_LE16(bios_mode);
4547 status = i40e_asq_send_command(hw, &desc, NULL, 0, NULL);
4549 *reset_needed = ((LE16_TO_CPU(cmd->cmd_flags) &
4550 I40E_AQ_ALTERNATE_RESET_NEEDED) != 0);
4556 * i40e_aq_set_oem_mode
4557 * @hw: pointer to the HW structure.
4558 * @oem_mode: the OEM mode to be used
4560 * Sets the device to a specific operating mode. Currently the only supported
4561 * mode is no_clp, which causes FW to refrain from using Alternate RAM.
4564 enum i40e_status_code i40e_aq_set_oem_mode(struct i40e_hw *hw,
4567 struct i40e_aq_desc desc;
4568 struct i40e_aqc_alternate_write_done *cmd =
4569 (struct i40e_aqc_alternate_write_done *)&desc.params.raw;
4570 enum i40e_status_code status;
4572 i40e_fill_default_direct_cmd_desc(&desc,
4573 i40e_aqc_opc_alternate_set_mode);
4575 cmd->cmd_flags = CPU_TO_LE16(oem_mode);
4577 status = i40e_asq_send_command(hw, &desc, NULL, 0, NULL);
4584 * i40e_aq_suspend_port_tx
4585 * @hw: pointer to the hardware structure
4587 * @cmd_details: pointer to command details structure or NULL
4589 * Suspend port's Tx traffic
4591 enum i40e_status_code i40e_aq_suspend_port_tx(struct i40e_hw *hw, u16 seid,
4592 struct i40e_asq_cmd_details *cmd_details)
4594 struct i40e_aq_desc desc;
4595 enum i40e_status_code status;
4596 struct i40e_aqc_tx_sched_ind *cmd =
4597 (struct i40e_aqc_tx_sched_ind *)&desc.params.raw;
4599 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_suspend_port_tx);
4601 cmd->vsi_seid = CPU_TO_LE16(seid);
4603 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
4607 #endif /* I40E_DCB_SW */
4610 * i40e_aq_resume_port_tx
4611 * @hw: pointer to the hardware structure
4612 * @cmd_details: pointer to command details structure or NULL
4614 * Resume port's Tx traffic
4616 enum i40e_status_code i40e_aq_resume_port_tx(struct i40e_hw *hw,
4617 struct i40e_asq_cmd_details *cmd_details)
4619 struct i40e_aq_desc desc;
4620 enum i40e_status_code status;
4622 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_resume_port_tx);
4624 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
4630 * i40e_set_pci_config_data - store PCI bus info
4631 * @hw: pointer to hardware structure
4632 * @link_status: the link status word from PCI config space
4634 * Stores the PCI bus info (speed, width, type) within the i40e_hw structure
4636 void i40e_set_pci_config_data(struct i40e_hw *hw, u16 link_status)
4638 hw->bus.type = i40e_bus_type_pci_express;
4640 switch (link_status & I40E_PCI_LINK_WIDTH) {
4641 case I40E_PCI_LINK_WIDTH_1:
4642 hw->bus.width = i40e_bus_width_pcie_x1;
4644 case I40E_PCI_LINK_WIDTH_2:
4645 hw->bus.width = i40e_bus_width_pcie_x2;
4647 case I40E_PCI_LINK_WIDTH_4:
4648 hw->bus.width = i40e_bus_width_pcie_x4;
4650 case I40E_PCI_LINK_WIDTH_8:
4651 hw->bus.width = i40e_bus_width_pcie_x8;
4654 hw->bus.width = i40e_bus_width_unknown;
4658 switch (link_status & I40E_PCI_LINK_SPEED) {
4659 case I40E_PCI_LINK_SPEED_2500:
4660 hw->bus.speed = i40e_bus_speed_2500;
4662 case I40E_PCI_LINK_SPEED_5000:
4663 hw->bus.speed = i40e_bus_speed_5000;
4665 case I40E_PCI_LINK_SPEED_8000:
4666 hw->bus.speed = i40e_bus_speed_8000;
4669 hw->bus.speed = i40e_bus_speed_unknown;
4675 * i40e_read_bw_from_alt_ram
4676 * @hw: pointer to the hardware structure
4677 * @max_bw: pointer for max_bw read
4678 * @min_bw: pointer for min_bw read
4679 * @min_valid: pointer for bool that is true if min_bw is a valid value
4680 * @max_valid: pointer for bool that is true if max_bw is a valid value
4682 * Read bw from the alternate ram for the given pf
4684 enum i40e_status_code i40e_read_bw_from_alt_ram(struct i40e_hw *hw,
4685 u32 *max_bw, u32 *min_bw,
4686 bool *min_valid, bool *max_valid)
4688 enum i40e_status_code status;
4689 u32 max_bw_addr, min_bw_addr;
4691 /* Calculate the address of the min/max bw registers */
4692 max_bw_addr = I40E_ALT_STRUCT_FIRST_PF_OFFSET +
4693 I40E_ALT_STRUCT_MAX_BW_OFFSET +
4694 (I40E_ALT_STRUCT_DWORDS_PER_PF*hw->pf_id);
4695 min_bw_addr = I40E_ALT_STRUCT_FIRST_PF_OFFSET +
4696 I40E_ALT_STRUCT_MIN_BW_OFFSET +
4697 (I40E_ALT_STRUCT_DWORDS_PER_PF*hw->pf_id);
4699 /* Read the bandwidths from alt ram */
4700 status = i40e_aq_alternate_read(hw, max_bw_addr, max_bw,
4701 min_bw_addr, min_bw);
4703 if (*min_bw & I40E_ALT_BW_VALID_MASK)
4708 if (*max_bw & I40E_ALT_BW_VALID_MASK)
4717 * i40e_aq_configure_partition_bw
4718 * @hw: pointer to the hardware structure
4719 * @bw_data: Buffer holding valid pfs and bw limits
4720 * @cmd_details: pointer to command details
4722 * Configure partitions guaranteed/max bw
4724 enum i40e_status_code i40e_aq_configure_partition_bw(struct i40e_hw *hw,
4725 struct i40e_aqc_configure_partition_bw_data *bw_data,
4726 struct i40e_asq_cmd_details *cmd_details)
4728 enum i40e_status_code status;
4729 struct i40e_aq_desc desc;
4730 u16 bwd_size = sizeof(struct i40e_aqc_configure_partition_bw_data);
4732 i40e_fill_default_direct_cmd_desc(&desc,
4733 i40e_aqc_opc_configure_partition_bw);
4735 /* Indirect command */
4736 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_BUF);
4737 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_RD);
4739 if (bwd_size > I40E_AQ_LARGE_BUF)
4740 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
4742 desc.datalen = CPU_TO_LE16(bwd_size);
4744 status = i40e_asq_send_command(hw, &desc, bw_data, bwd_size, cmd_details);
4750 * i40e_aq_send_msg_to_pf
4751 * @hw: pointer to the hardware structure
4752 * @v_opcode: opcodes for VF-PF communication
4753 * @v_retval: return error code
4754 * @msg: pointer to the msg buffer
4755 * @msglen: msg length
4756 * @cmd_details: pointer to command details
4758 * Send message to PF driver using admin queue. By default, this message
4759 * is sent asynchronously, i.e. i40e_asq_send_command() does not wait for
4760 * completion before returning.
4762 enum i40e_status_code i40e_aq_send_msg_to_pf(struct i40e_hw *hw,
4763 enum i40e_virtchnl_ops v_opcode,
4764 enum i40e_status_code v_retval,
4765 u8 *msg, u16 msglen,
4766 struct i40e_asq_cmd_details *cmd_details)
4768 struct i40e_aq_desc desc;
4769 enum i40e_status_code status;
4771 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_send_msg_to_pf);
4772 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_SI);
4773 desc.cookie_high = CPU_TO_LE32(v_opcode);
4774 desc.cookie_low = CPU_TO_LE32(v_retval);
4776 desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF
4777 | I40E_AQ_FLAG_RD));
4778 if (msglen > I40E_AQ_LARGE_BUF)
4779 desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
4780 desc.datalen = CPU_TO_LE16(msglen);
4783 struct i40e_asq_cmd_details details;
4784 i40e_memset(&details, 0, sizeof(details), I40E_NONDMA_MEM);
4785 details.async = true;
4786 cmd_details = &details;
4788 status = i40e_asq_send_command(hw, (struct i40e_aq_desc *)&desc, msg,
4789 msglen, cmd_details);
4794 * i40e_vf_parse_hw_config
4795 * @hw: pointer to the hardware structure
4796 * @msg: pointer to the virtual channel VF resource structure
4798 * Given a VF resource message from the PF, populate the hw struct
4799 * with appropriate information.
4801 void i40e_vf_parse_hw_config(struct i40e_hw *hw,
4802 struct i40e_virtchnl_vf_resource *msg)
4804 struct i40e_virtchnl_vsi_resource *vsi_res;
4807 vsi_res = &msg->vsi_res[0];
4809 hw->dev_caps.num_vsis = msg->num_vsis;
4810 hw->dev_caps.num_rx_qp = msg->num_queue_pairs;
4811 hw->dev_caps.num_tx_qp = msg->num_queue_pairs;
4812 hw->dev_caps.num_msix_vectors_vf = msg->max_vectors;
4813 hw->dev_caps.dcb = msg->vf_offload_flags &
4814 I40E_VIRTCHNL_VF_OFFLOAD_L2;
4815 hw->dev_caps.fcoe = (msg->vf_offload_flags &
4816 I40E_VIRTCHNL_VF_OFFLOAD_FCOE) ? 1 : 0;
4817 hw->dev_caps.iwarp = (msg->vf_offload_flags &
4818 I40E_VIRTCHNL_VF_OFFLOAD_IWARP) ? 1 : 0;
4819 for (i = 0; i < msg->num_vsis; i++) {
4820 if (vsi_res->vsi_type == I40E_VSI_SRIOV) {
4821 i40e_memcpy(hw->mac.perm_addr,
4822 vsi_res->default_mac_addr,
4823 I40E_ETH_LENGTH_OF_ADDRESS,
4824 I40E_NONDMA_TO_NONDMA);
4825 i40e_memcpy(hw->mac.addr, vsi_res->default_mac_addr,
4826 I40E_ETH_LENGTH_OF_ADDRESS,
4827 I40E_NONDMA_TO_NONDMA);
4835 * @hw: pointer to the hardware structure
4837 * Send a VF_RESET message to the PF. Does not wait for response from PF
4838 * as none will be forthcoming. Immediately after calling this function,
4839 * the admin queue should be shut down and (optionally) reinitialized.
4841 enum i40e_status_code i40e_vf_reset(struct i40e_hw *hw)
4843 return i40e_aq_send_msg_to_pf(hw, I40E_VIRTCHNL_OP_RESET_VF,
4844 I40E_SUCCESS, NULL, 0, NULL);
4846 #endif /* VF_DRIVER */