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