blob: ea0f2001cc201fa5f6eeced0f72b585e3aa23132 [file] [log] [blame]
Greg Rosed358aa92013-12-21 06:13:11 +00001/*******************************************************************************
2 *
3 * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver
Jesse Brandeburgb8316072014-04-05 07:46:11 +00004 * Copyright(c) 2013 - 2014 Intel Corporation.
Greg Rosed358aa92013-12-21 06:13:11 +00005 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
Jesse Brandeburgb8316072014-04-05 07:46:11 +000015 * You should have received a copy of the GNU General Public License along
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
Greg Rosed358aa92013-12-21 06:13:11 +000018 * The full GNU General Public License is included in this distribution in
19 * the file called "COPYING".
20 *
21 * Contact Information:
22 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 *
25 ******************************************************************************/
26
27#include "i40e_type.h"
28#include "i40e_adminq.h"
29#include "i40e_prototype.h"
30#include "i40e_virtchnl.h"
31
32/**
33 * i40e_set_mac_type - Sets MAC type
34 * @hw: pointer to the HW structure
35 *
36 * This function sets the mac type of the adapter based on the
37 * vendor ID and device ID stored in the hw structure.
38 **/
39i40e_status i40e_set_mac_type(struct i40e_hw *hw)
40{
41 i40e_status status = 0;
42
43 if (hw->vendor_id == PCI_VENDOR_ID_INTEL) {
44 switch (hw->device_id) {
Shannon Nelsonab600852014-01-17 15:36:39 -080045 case I40E_DEV_ID_SFP_XL710:
46 case I40E_DEV_ID_SFP_X710:
47 case I40E_DEV_ID_QEMU:
48 case I40E_DEV_ID_KX_A:
49 case I40E_DEV_ID_KX_B:
50 case I40E_DEV_ID_KX_C:
51 case I40E_DEV_ID_KX_D:
52 case I40E_DEV_ID_QSFP_A:
53 case I40E_DEV_ID_QSFP_B:
54 case I40E_DEV_ID_QSFP_C:
Greg Rosed358aa92013-12-21 06:13:11 +000055 hw->mac.type = I40E_MAC_XL710;
56 break;
Shannon Nelsonab600852014-01-17 15:36:39 -080057 case I40E_DEV_ID_VF:
58 case I40E_DEV_ID_VF_HV:
Greg Rosed358aa92013-12-21 06:13:11 +000059 hw->mac.type = I40E_MAC_VF;
60 break;
61 default:
62 hw->mac.type = I40E_MAC_GENERIC;
63 break;
64 }
65 } else {
66 status = I40E_ERR_DEVICE_NOT_SUPPORTED;
67 }
68
69 hw_dbg(hw, "i40e_set_mac_type found mac: %d, returns: %d\n",
70 hw->mac.type, status);
71 return status;
72}
73
74/**
75 * i40evf_debug_aq
76 * @hw: debug mask related to admin queue
77 * @mask: debug mask
78 * @desc: pointer to admin queue descriptor
79 * @buffer: pointer to command buffer
80 *
81 * Dumps debug log about adminq command with descriptor contents.
82 **/
83void i40evf_debug_aq(struct i40e_hw *hw, enum i40e_debug_mask mask, void *desc,
84 void *buffer)
85{
86 struct i40e_aq_desc *aq_desc = (struct i40e_aq_desc *)desc;
87 u8 *aq_buffer = (u8 *)buffer;
88 u32 data[4];
89 u32 i = 0;
90
91 if ((!(mask & hw->debug_mask)) || (desc == NULL))
92 return;
93
94 i40e_debug(hw, mask,
95 "AQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n",
96 aq_desc->opcode, aq_desc->flags, aq_desc->datalen,
97 aq_desc->retval);
98 i40e_debug(hw, mask, "\tcookie (h,l) 0x%08X 0x%08X\n",
99 aq_desc->cookie_high, aq_desc->cookie_low);
100 i40e_debug(hw, mask, "\tparam (0,1) 0x%08X 0x%08X\n",
101 aq_desc->params.internal.param0,
102 aq_desc->params.internal.param1);
103 i40e_debug(hw, mask, "\taddr (h,l) 0x%08X 0x%08X\n",
104 aq_desc->params.external.addr_high,
105 aq_desc->params.external.addr_low);
106
107 if ((buffer != NULL) && (aq_desc->datalen != 0)) {
108 memset(data, 0, sizeof(data));
109 i40e_debug(hw, mask, "AQ CMD Buffer:\n");
110 for (i = 0; i < le16_to_cpu(aq_desc->datalen); i++) {
111 data[((i % 16) / 4)] |=
112 ((u32)aq_buffer[i]) << (8 * (i % 4));
113 if ((i % 16) == 15) {
114 i40e_debug(hw, mask,
115 "\t0x%04X %08X %08X %08X %08X\n",
116 i - 15, data[0], data[1], data[2],
117 data[3]);
118 memset(data, 0, sizeof(data));
119 }
120 }
121 if ((i % 16) != 0)
122 i40e_debug(hw, mask, "\t0x%04X %08X %08X %08X %08X\n",
123 i - (i % 16), data[0], data[1], data[2],
124 data[3]);
125 }
126}
127
128/**
129 * i40evf_check_asq_alive
130 * @hw: pointer to the hw struct
131 *
132 * Returns true if Queue is enabled else false.
133 **/
134bool i40evf_check_asq_alive(struct i40e_hw *hw)
135{
Kevin Scott8b833b42014-04-09 05:58:54 +0000136 if (hw->aq.asq.len)
137 return !!(rd32(hw, hw->aq.asq.len) &
138 I40E_PF_ATQLEN_ATQENABLE_MASK);
139 else
140 return false;
Greg Rosed358aa92013-12-21 06:13:11 +0000141}
142
143/**
144 * i40evf_aq_queue_shutdown
145 * @hw: pointer to the hw struct
146 * @unloading: is the driver unloading itself
147 *
148 * Tell the Firmware that we're shutting down the AdminQ and whether
149 * or not the driver is unloading as well.
150 **/
151i40e_status i40evf_aq_queue_shutdown(struct i40e_hw *hw,
152 bool unloading)
153{
154 struct i40e_aq_desc desc;
155 struct i40e_aqc_queue_shutdown *cmd =
156 (struct i40e_aqc_queue_shutdown *)&desc.params.raw;
157 i40e_status status;
158
159 i40evf_fill_default_direct_cmd_desc(&desc,
160 i40e_aqc_opc_queue_shutdown);
161
162 if (unloading)
163 cmd->driver_unloading = cpu_to_le32(I40E_AQ_DRIVER_UNLOADING);
164 status = i40evf_asq_send_command(hw, &desc, NULL, 0, NULL);
165
166 return status;
167}
168
169
Eric W Biederman37a622c2014-03-18 00:26:50 -0700170/* The i40evf_ptype_lookup table is used to convert from the 8-bit ptype in the
Jesse Brandeburg206812b2014-02-12 01:45:33 +0000171 * hardware to a bit-field that can be used by SW to more easily determine the
172 * packet type.
173 *
174 * Macros are used to shorten the table lines and make this table human
175 * readable.
176 *
177 * We store the PTYPE in the top byte of the bit field - this is just so that
178 * we can check that the table doesn't have a row missing, as the index into
179 * the table should be the PTYPE.
180 *
181 * Typical work flow:
182 *
Eric W Biederman37a622c2014-03-18 00:26:50 -0700183 * IF NOT i40evf_ptype_lookup[ptype].known
Jesse Brandeburg206812b2014-02-12 01:45:33 +0000184 * THEN
185 * Packet is unknown
Eric W Biederman37a622c2014-03-18 00:26:50 -0700186 * ELSE IF i40evf_ptype_lookup[ptype].outer_ip == I40E_RX_PTYPE_OUTER_IP
Jesse Brandeburg206812b2014-02-12 01:45:33 +0000187 * Use the rest of the fields to look at the tunnels, inner protocols, etc
188 * ELSE
189 * Use the enum i40e_rx_l2_ptype to decode the packet type
190 * ENDIF
191 */
192
193/* macro to make the table lines short */
194#define I40E_PTT(PTYPE, OUTER_IP, OUTER_IP_VER, OUTER_FRAG, T, TE, TEF, I, PL)\
195 { PTYPE, \
196 1, \
197 I40E_RX_PTYPE_OUTER_##OUTER_IP, \
198 I40E_RX_PTYPE_OUTER_##OUTER_IP_VER, \
199 I40E_RX_PTYPE_##OUTER_FRAG, \
200 I40E_RX_PTYPE_TUNNEL_##T, \
201 I40E_RX_PTYPE_TUNNEL_END_##TE, \
202 I40E_RX_PTYPE_##TEF, \
203 I40E_RX_PTYPE_INNER_PROT_##I, \
204 I40E_RX_PTYPE_PAYLOAD_LAYER_##PL }
205
206#define I40E_PTT_UNUSED_ENTRY(PTYPE) \
207 { PTYPE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
208
209/* shorter macros makes the table fit but are terse */
210#define I40E_RX_PTYPE_NOF I40E_RX_PTYPE_NOT_FRAG
211#define I40E_RX_PTYPE_FRG I40E_RX_PTYPE_FRAG
212#define I40E_RX_PTYPE_INNER_PROT_TS I40E_RX_PTYPE_INNER_PROT_TIMESYNC
213
214/* Lookup table mapping the HW PTYPE to the bit field for decoding */
Eric W Biederman37a622c2014-03-18 00:26:50 -0700215struct i40e_rx_ptype_decoded i40evf_ptype_lookup[] = {
Jesse Brandeburg206812b2014-02-12 01:45:33 +0000216 /* L2 Packet types */
217 I40E_PTT_UNUSED_ENTRY(0),
218 I40E_PTT(1, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
219 I40E_PTT(2, L2, NONE, NOF, NONE, NONE, NOF, TS, PAY2),
220 I40E_PTT(3, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
221 I40E_PTT_UNUSED_ENTRY(4),
222 I40E_PTT_UNUSED_ENTRY(5),
223 I40E_PTT(6, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
224 I40E_PTT(7, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
225 I40E_PTT_UNUSED_ENTRY(8),
226 I40E_PTT_UNUSED_ENTRY(9),
227 I40E_PTT(10, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
228 I40E_PTT(11, L2, NONE, NOF, NONE, NONE, NOF, NONE, NONE),
229 I40E_PTT(12, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
230 I40E_PTT(13, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
231 I40E_PTT(14, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
232 I40E_PTT(15, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
233 I40E_PTT(16, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
234 I40E_PTT(17, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
235 I40E_PTT(18, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
236 I40E_PTT(19, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
237 I40E_PTT(20, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
238 I40E_PTT(21, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
239
240 /* Non Tunneled IPv4 */
241 I40E_PTT(22, IP, IPV4, FRG, NONE, NONE, NOF, NONE, PAY3),
242 I40E_PTT(23, IP, IPV4, NOF, NONE, NONE, NOF, NONE, PAY3),
243 I40E_PTT(24, IP, IPV4, NOF, NONE, NONE, NOF, UDP, PAY4),
244 I40E_PTT_UNUSED_ENTRY(25),
245 I40E_PTT(26, IP, IPV4, NOF, NONE, NONE, NOF, TCP, PAY4),
246 I40E_PTT(27, IP, IPV4, NOF, NONE, NONE, NOF, SCTP, PAY4),
247 I40E_PTT(28, IP, IPV4, NOF, NONE, NONE, NOF, ICMP, PAY4),
248
249 /* IPv4 --> IPv4 */
250 I40E_PTT(29, IP, IPV4, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
251 I40E_PTT(30, IP, IPV4, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
252 I40E_PTT(31, IP, IPV4, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
253 I40E_PTT_UNUSED_ENTRY(32),
254 I40E_PTT(33, IP, IPV4, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
255 I40E_PTT(34, IP, IPV4, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
256 I40E_PTT(35, IP, IPV4, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
257
258 /* IPv4 --> IPv6 */
259 I40E_PTT(36, IP, IPV4, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
260 I40E_PTT(37, IP, IPV4, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
261 I40E_PTT(38, IP, IPV4, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
262 I40E_PTT_UNUSED_ENTRY(39),
263 I40E_PTT(40, IP, IPV4, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
264 I40E_PTT(41, IP, IPV4, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
265 I40E_PTT(42, IP, IPV4, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
266
267 /* IPv4 --> GRE/NAT */
268 I40E_PTT(43, IP, IPV4, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
269
270 /* IPv4 --> GRE/NAT --> IPv4 */
271 I40E_PTT(44, IP, IPV4, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
272 I40E_PTT(45, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
273 I40E_PTT(46, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
274 I40E_PTT_UNUSED_ENTRY(47),
275 I40E_PTT(48, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
276 I40E_PTT(49, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
277 I40E_PTT(50, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
278
279 /* IPv4 --> GRE/NAT --> IPv6 */
280 I40E_PTT(51, IP, IPV4, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
281 I40E_PTT(52, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
282 I40E_PTT(53, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
283 I40E_PTT_UNUSED_ENTRY(54),
284 I40E_PTT(55, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
285 I40E_PTT(56, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
286 I40E_PTT(57, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
287
288 /* IPv4 --> GRE/NAT --> MAC */
289 I40E_PTT(58, IP, IPV4, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
290
291 /* IPv4 --> GRE/NAT --> MAC --> IPv4 */
292 I40E_PTT(59, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
293 I40E_PTT(60, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
294 I40E_PTT(61, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
295 I40E_PTT_UNUSED_ENTRY(62),
296 I40E_PTT(63, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
297 I40E_PTT(64, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
298 I40E_PTT(65, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
299
300 /* IPv4 --> GRE/NAT -> MAC --> IPv6 */
301 I40E_PTT(66, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
302 I40E_PTT(67, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
303 I40E_PTT(68, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
304 I40E_PTT_UNUSED_ENTRY(69),
305 I40E_PTT(70, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
306 I40E_PTT(71, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
307 I40E_PTT(72, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
308
309 /* IPv4 --> GRE/NAT --> MAC/VLAN */
310 I40E_PTT(73, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
311
312 /* IPv4 ---> GRE/NAT -> MAC/VLAN --> IPv4 */
313 I40E_PTT(74, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
314 I40E_PTT(75, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
315 I40E_PTT(76, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
316 I40E_PTT_UNUSED_ENTRY(77),
317 I40E_PTT(78, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
318 I40E_PTT(79, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
319 I40E_PTT(80, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
320
321 /* IPv4 -> GRE/NAT -> MAC/VLAN --> IPv6 */
322 I40E_PTT(81, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
323 I40E_PTT(82, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
324 I40E_PTT(83, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
325 I40E_PTT_UNUSED_ENTRY(84),
326 I40E_PTT(85, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
327 I40E_PTT(86, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
328 I40E_PTT(87, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
329
330 /* Non Tunneled IPv6 */
331 I40E_PTT(88, IP, IPV6, FRG, NONE, NONE, NOF, NONE, PAY3),
332 I40E_PTT(89, IP, IPV6, NOF, NONE, NONE, NOF, NONE, PAY3),
333 I40E_PTT(90, IP, IPV6, NOF, NONE, NONE, NOF, UDP, PAY3),
334 I40E_PTT_UNUSED_ENTRY(91),
335 I40E_PTT(92, IP, IPV6, NOF, NONE, NONE, NOF, TCP, PAY4),
336 I40E_PTT(93, IP, IPV6, NOF, NONE, NONE, NOF, SCTP, PAY4),
337 I40E_PTT(94, IP, IPV6, NOF, NONE, NONE, NOF, ICMP, PAY4),
338
339 /* IPv6 --> IPv4 */
340 I40E_PTT(95, IP, IPV6, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
341 I40E_PTT(96, IP, IPV6, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
342 I40E_PTT(97, IP, IPV6, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
343 I40E_PTT_UNUSED_ENTRY(98),
344 I40E_PTT(99, IP, IPV6, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
345 I40E_PTT(100, IP, IPV6, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
346 I40E_PTT(101, IP, IPV6, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
347
348 /* IPv6 --> IPv6 */
349 I40E_PTT(102, IP, IPV6, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
350 I40E_PTT(103, IP, IPV6, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
351 I40E_PTT(104, IP, IPV6, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
352 I40E_PTT_UNUSED_ENTRY(105),
353 I40E_PTT(106, IP, IPV6, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
354 I40E_PTT(107, IP, IPV6, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
355 I40E_PTT(108, IP, IPV6, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
356
357 /* IPv6 --> GRE/NAT */
358 I40E_PTT(109, IP, IPV6, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
359
360 /* IPv6 --> GRE/NAT -> IPv4 */
361 I40E_PTT(110, IP, IPV6, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
362 I40E_PTT(111, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
363 I40E_PTT(112, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
364 I40E_PTT_UNUSED_ENTRY(113),
365 I40E_PTT(114, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
366 I40E_PTT(115, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
367 I40E_PTT(116, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
368
369 /* IPv6 --> GRE/NAT -> IPv6 */
370 I40E_PTT(117, IP, IPV6, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
371 I40E_PTT(118, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
372 I40E_PTT(119, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
373 I40E_PTT_UNUSED_ENTRY(120),
374 I40E_PTT(121, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
375 I40E_PTT(122, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
376 I40E_PTT(123, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
377
378 /* IPv6 --> GRE/NAT -> MAC */
379 I40E_PTT(124, IP, IPV6, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
380
381 /* IPv6 --> GRE/NAT -> MAC -> IPv4 */
382 I40E_PTT(125, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
383 I40E_PTT(126, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
384 I40E_PTT(127, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
385 I40E_PTT_UNUSED_ENTRY(128),
386 I40E_PTT(129, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
387 I40E_PTT(130, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
388 I40E_PTT(131, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
389
390 /* IPv6 --> GRE/NAT -> MAC -> IPv6 */
391 I40E_PTT(132, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
392 I40E_PTT(133, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
393 I40E_PTT(134, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
394 I40E_PTT_UNUSED_ENTRY(135),
395 I40E_PTT(136, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
396 I40E_PTT(137, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
397 I40E_PTT(138, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
398
399 /* IPv6 --> GRE/NAT -> MAC/VLAN */
400 I40E_PTT(139, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
401
402 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv4 */
403 I40E_PTT(140, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
404 I40E_PTT(141, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
405 I40E_PTT(142, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
406 I40E_PTT_UNUSED_ENTRY(143),
407 I40E_PTT(144, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
408 I40E_PTT(145, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
409 I40E_PTT(146, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
410
411 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv6 */
412 I40E_PTT(147, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
413 I40E_PTT(148, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
414 I40E_PTT(149, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
415 I40E_PTT_UNUSED_ENTRY(150),
416 I40E_PTT(151, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
417 I40E_PTT(152, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
418 I40E_PTT(153, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
419
420 /* unused entries */
421 I40E_PTT_UNUSED_ENTRY(154),
422 I40E_PTT_UNUSED_ENTRY(155),
423 I40E_PTT_UNUSED_ENTRY(156),
424 I40E_PTT_UNUSED_ENTRY(157),
425 I40E_PTT_UNUSED_ENTRY(158),
426 I40E_PTT_UNUSED_ENTRY(159),
427
428 I40E_PTT_UNUSED_ENTRY(160),
429 I40E_PTT_UNUSED_ENTRY(161),
430 I40E_PTT_UNUSED_ENTRY(162),
431 I40E_PTT_UNUSED_ENTRY(163),
432 I40E_PTT_UNUSED_ENTRY(164),
433 I40E_PTT_UNUSED_ENTRY(165),
434 I40E_PTT_UNUSED_ENTRY(166),
435 I40E_PTT_UNUSED_ENTRY(167),
436 I40E_PTT_UNUSED_ENTRY(168),
437 I40E_PTT_UNUSED_ENTRY(169),
438
439 I40E_PTT_UNUSED_ENTRY(170),
440 I40E_PTT_UNUSED_ENTRY(171),
441 I40E_PTT_UNUSED_ENTRY(172),
442 I40E_PTT_UNUSED_ENTRY(173),
443 I40E_PTT_UNUSED_ENTRY(174),
444 I40E_PTT_UNUSED_ENTRY(175),
445 I40E_PTT_UNUSED_ENTRY(176),
446 I40E_PTT_UNUSED_ENTRY(177),
447 I40E_PTT_UNUSED_ENTRY(178),
448 I40E_PTT_UNUSED_ENTRY(179),
449
450 I40E_PTT_UNUSED_ENTRY(180),
451 I40E_PTT_UNUSED_ENTRY(181),
452 I40E_PTT_UNUSED_ENTRY(182),
453 I40E_PTT_UNUSED_ENTRY(183),
454 I40E_PTT_UNUSED_ENTRY(184),
455 I40E_PTT_UNUSED_ENTRY(185),
456 I40E_PTT_UNUSED_ENTRY(186),
457 I40E_PTT_UNUSED_ENTRY(187),
458 I40E_PTT_UNUSED_ENTRY(188),
459 I40E_PTT_UNUSED_ENTRY(189),
460
461 I40E_PTT_UNUSED_ENTRY(190),
462 I40E_PTT_UNUSED_ENTRY(191),
463 I40E_PTT_UNUSED_ENTRY(192),
464 I40E_PTT_UNUSED_ENTRY(193),
465 I40E_PTT_UNUSED_ENTRY(194),
466 I40E_PTT_UNUSED_ENTRY(195),
467 I40E_PTT_UNUSED_ENTRY(196),
468 I40E_PTT_UNUSED_ENTRY(197),
469 I40E_PTT_UNUSED_ENTRY(198),
470 I40E_PTT_UNUSED_ENTRY(199),
471
472 I40E_PTT_UNUSED_ENTRY(200),
473 I40E_PTT_UNUSED_ENTRY(201),
474 I40E_PTT_UNUSED_ENTRY(202),
475 I40E_PTT_UNUSED_ENTRY(203),
476 I40E_PTT_UNUSED_ENTRY(204),
477 I40E_PTT_UNUSED_ENTRY(205),
478 I40E_PTT_UNUSED_ENTRY(206),
479 I40E_PTT_UNUSED_ENTRY(207),
480 I40E_PTT_UNUSED_ENTRY(208),
481 I40E_PTT_UNUSED_ENTRY(209),
482
483 I40E_PTT_UNUSED_ENTRY(210),
484 I40E_PTT_UNUSED_ENTRY(211),
485 I40E_PTT_UNUSED_ENTRY(212),
486 I40E_PTT_UNUSED_ENTRY(213),
487 I40E_PTT_UNUSED_ENTRY(214),
488 I40E_PTT_UNUSED_ENTRY(215),
489 I40E_PTT_UNUSED_ENTRY(216),
490 I40E_PTT_UNUSED_ENTRY(217),
491 I40E_PTT_UNUSED_ENTRY(218),
492 I40E_PTT_UNUSED_ENTRY(219),
493
494 I40E_PTT_UNUSED_ENTRY(220),
495 I40E_PTT_UNUSED_ENTRY(221),
496 I40E_PTT_UNUSED_ENTRY(222),
497 I40E_PTT_UNUSED_ENTRY(223),
498 I40E_PTT_UNUSED_ENTRY(224),
499 I40E_PTT_UNUSED_ENTRY(225),
500 I40E_PTT_UNUSED_ENTRY(226),
501 I40E_PTT_UNUSED_ENTRY(227),
502 I40E_PTT_UNUSED_ENTRY(228),
503 I40E_PTT_UNUSED_ENTRY(229),
504
505 I40E_PTT_UNUSED_ENTRY(230),
506 I40E_PTT_UNUSED_ENTRY(231),
507 I40E_PTT_UNUSED_ENTRY(232),
508 I40E_PTT_UNUSED_ENTRY(233),
509 I40E_PTT_UNUSED_ENTRY(234),
510 I40E_PTT_UNUSED_ENTRY(235),
511 I40E_PTT_UNUSED_ENTRY(236),
512 I40E_PTT_UNUSED_ENTRY(237),
513 I40E_PTT_UNUSED_ENTRY(238),
514 I40E_PTT_UNUSED_ENTRY(239),
515
516 I40E_PTT_UNUSED_ENTRY(240),
517 I40E_PTT_UNUSED_ENTRY(241),
518 I40E_PTT_UNUSED_ENTRY(242),
519 I40E_PTT_UNUSED_ENTRY(243),
520 I40E_PTT_UNUSED_ENTRY(244),
521 I40E_PTT_UNUSED_ENTRY(245),
522 I40E_PTT_UNUSED_ENTRY(246),
523 I40E_PTT_UNUSED_ENTRY(247),
524 I40E_PTT_UNUSED_ENTRY(248),
525 I40E_PTT_UNUSED_ENTRY(249),
526
527 I40E_PTT_UNUSED_ENTRY(250),
528 I40E_PTT_UNUSED_ENTRY(251),
529 I40E_PTT_UNUSED_ENTRY(252),
530 I40E_PTT_UNUSED_ENTRY(253),
531 I40E_PTT_UNUSED_ENTRY(254),
532 I40E_PTT_UNUSED_ENTRY(255)
533};
534
535
Greg Rosed358aa92013-12-21 06:13:11 +0000536/**
537 * i40e_aq_send_msg_to_pf
538 * @hw: pointer to the hardware structure
539 * @v_opcode: opcodes for VF-PF communication
540 * @v_retval: return error code
541 * @msg: pointer to the msg buffer
542 * @msglen: msg length
543 * @cmd_details: pointer to command details
544 *
545 * Send message to PF driver using admin queue. By default, this message
546 * is sent asynchronously, i.e. i40evf_asq_send_command() does not wait for
547 * completion before returning.
548 **/
549i40e_status i40e_aq_send_msg_to_pf(struct i40e_hw *hw,
550 enum i40e_virtchnl_ops v_opcode,
551 i40e_status v_retval,
552 u8 *msg, u16 msglen,
553 struct i40e_asq_cmd_details *cmd_details)
554{
555 struct i40e_aq_desc desc;
556 i40e_status status;
557
558 i40evf_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_send_msg_to_pf);
559 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_SI);
560 desc.cookie_high = cpu_to_le32(v_opcode);
561 desc.cookie_low = cpu_to_le32(v_retval);
562 if (msglen) {
563 desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF
564 | I40E_AQ_FLAG_RD));
565 if (msglen > I40E_AQ_LARGE_BUF)
566 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
567 desc.datalen = cpu_to_le16(msglen);
568 }
569 if (!cmd_details) {
570 struct i40e_asq_cmd_details details;
571 memset(&details, 0, sizeof(details));
572 details.async = true;
573 cmd_details = &details;
574 }
Joe Perchesb58f2f72014-03-25 04:30:32 +0000575 status = i40evf_asq_send_command(hw, &desc, msg, msglen, cmd_details);
Greg Rosed358aa92013-12-21 06:13:11 +0000576 return status;
577}
578
579/**
580 * i40e_vf_parse_hw_config
581 * @hw: pointer to the hardware structure
582 * @msg: pointer to the virtual channel VF resource structure
583 *
584 * Given a VF resource message from the PF, populate the hw struct
585 * with appropriate information.
586 **/
587void i40e_vf_parse_hw_config(struct i40e_hw *hw,
588 struct i40e_virtchnl_vf_resource *msg)
589{
590 struct i40e_virtchnl_vsi_resource *vsi_res;
591 int i;
592
593 vsi_res = &msg->vsi_res[0];
594
595 hw->dev_caps.num_vsis = msg->num_vsis;
596 hw->dev_caps.num_rx_qp = msg->num_queue_pairs;
597 hw->dev_caps.num_tx_qp = msg->num_queue_pairs;
598 hw->dev_caps.num_msix_vectors_vf = msg->max_vectors;
599 hw->dev_caps.dcb = msg->vf_offload_flags &
600 I40E_VIRTCHNL_VF_OFFLOAD_L2;
601 hw->dev_caps.fcoe = (msg->vf_offload_flags &
602 I40E_VIRTCHNL_VF_OFFLOAD_FCOE) ? 1 : 0;
603 for (i = 0; i < msg->num_vsis; i++) {
604 if (vsi_res->vsi_type == I40E_VSI_SRIOV) {
605 memcpy(hw->mac.perm_addr, vsi_res->default_mac_addr,
606 ETH_ALEN);
607 memcpy(hw->mac.addr, vsi_res->default_mac_addr,
608 ETH_ALEN);
609 }
610 vsi_res++;
611 }
612}
613
614/**
615 * i40e_vf_reset
616 * @hw: pointer to the hardware structure
617 *
618 * Send a VF_RESET message to the PF. Does not wait for response from PF
619 * as none will be forthcoming. Immediately after calling this function,
620 * the admin queue should be shut down and (optionally) reinitialized.
621 **/
622i40e_status i40e_vf_reset(struct i40e_hw *hw)
623{
624 return i40e_aq_send_msg_to_pf(hw, I40E_VIRTCHNL_OP_RESET_VF,
625 0, NULL, 0, NULL);
626}