blob: b98b642b897a0384c7212a56a5520edd4aadd610 [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:
Shannon Nelsonab600852014-01-17 15:36:39 -080046 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:
Shannon Nelsonab600852014-01-17 15:36:39 -080050 case I40E_DEV_ID_QSFP_A:
51 case I40E_DEV_ID_QSFP_B:
52 case I40E_DEV_ID_QSFP_C:
Paul M Stillwell Jr1ac1e762014-10-17 03:14:44 +000053 case I40E_DEV_ID_10G_BASE_T:
Shannon Nelsonbc5166b92015-08-26 15:14:10 -040054 case I40E_DEV_ID_10G_BASE_T4:
Jesse Brandeburgae24b402015-03-27 00:12:09 -070055 case I40E_DEV_ID_20G_KR2:
Shannon Nelson48a3b512015-07-23 16:54:39 -040056 case I40E_DEV_ID_20G_KR2_A:
Greg Rosed358aa92013-12-21 06:13:11 +000057 hw->mac.type = I40E_MAC_XL710;
58 break;
Anjali Singhai Jain87e6c1d2015-06-05 12:20:25 -040059 case I40E_DEV_ID_SFP_X722:
60 case I40E_DEV_ID_1G_BASE_T_X722:
61 case I40E_DEV_ID_10G_BASE_T_X722:
62 hw->mac.type = I40E_MAC_X722;
63 break;
64 case I40E_DEV_ID_X722_VF:
65 case I40E_DEV_ID_X722_VF_HV:
66 hw->mac.type = I40E_MAC_X722_VF;
67 break;
Shannon Nelsonab600852014-01-17 15:36:39 -080068 case I40E_DEV_ID_VF:
69 case I40E_DEV_ID_VF_HV:
Greg Rosed358aa92013-12-21 06:13:11 +000070 hw->mac.type = I40E_MAC_VF;
71 break;
72 default:
73 hw->mac.type = I40E_MAC_GENERIC;
74 break;
75 }
76 } else {
77 status = I40E_ERR_DEVICE_NOT_SUPPORTED;
78 }
79
80 hw_dbg(hw, "i40e_set_mac_type found mac: %d, returns: %d\n",
81 hw->mac.type, status);
82 return status;
83}
84
85/**
Shannon Nelsonf1c7e722015-06-04 16:24:01 -040086 * i40evf_aq_str - convert AQ err code to a string
87 * @hw: pointer to the HW structure
88 * @aq_err: the AQ error code to convert
89 **/
90char *i40evf_aq_str(struct i40e_hw *hw, enum i40e_admin_queue_err aq_err)
91{
92 switch (aq_err) {
93 case I40E_AQ_RC_OK:
94 return "OK";
95 case I40E_AQ_RC_EPERM:
96 return "I40E_AQ_RC_EPERM";
97 case I40E_AQ_RC_ENOENT:
98 return "I40E_AQ_RC_ENOENT";
99 case I40E_AQ_RC_ESRCH:
100 return "I40E_AQ_RC_ESRCH";
101 case I40E_AQ_RC_EINTR:
102 return "I40E_AQ_RC_EINTR";
103 case I40E_AQ_RC_EIO:
104 return "I40E_AQ_RC_EIO";
105 case I40E_AQ_RC_ENXIO:
106 return "I40E_AQ_RC_ENXIO";
107 case I40E_AQ_RC_E2BIG:
108 return "I40E_AQ_RC_E2BIG";
109 case I40E_AQ_RC_EAGAIN:
110 return "I40E_AQ_RC_EAGAIN";
111 case I40E_AQ_RC_ENOMEM:
112 return "I40E_AQ_RC_ENOMEM";
113 case I40E_AQ_RC_EACCES:
114 return "I40E_AQ_RC_EACCES";
115 case I40E_AQ_RC_EFAULT:
116 return "I40E_AQ_RC_EFAULT";
117 case I40E_AQ_RC_EBUSY:
118 return "I40E_AQ_RC_EBUSY";
119 case I40E_AQ_RC_EEXIST:
120 return "I40E_AQ_RC_EEXIST";
121 case I40E_AQ_RC_EINVAL:
122 return "I40E_AQ_RC_EINVAL";
123 case I40E_AQ_RC_ENOTTY:
124 return "I40E_AQ_RC_ENOTTY";
125 case I40E_AQ_RC_ENOSPC:
126 return "I40E_AQ_RC_ENOSPC";
127 case I40E_AQ_RC_ENOSYS:
128 return "I40E_AQ_RC_ENOSYS";
129 case I40E_AQ_RC_ERANGE:
130 return "I40E_AQ_RC_ERANGE";
131 case I40E_AQ_RC_EFLUSHED:
132 return "I40E_AQ_RC_EFLUSHED";
133 case I40E_AQ_RC_BAD_ADDR:
134 return "I40E_AQ_RC_BAD_ADDR";
135 case I40E_AQ_RC_EMODE:
136 return "I40E_AQ_RC_EMODE";
137 case I40E_AQ_RC_EFBIG:
138 return "I40E_AQ_RC_EFBIG";
139 }
140
141 snprintf(hw->err_str, sizeof(hw->err_str), "%d", aq_err);
142 return hw->err_str;
143}
144
145/**
146 * i40evf_stat_str - convert status err code to a string
147 * @hw: pointer to the HW structure
148 * @stat_err: the status error code to convert
149 **/
150char *i40evf_stat_str(struct i40e_hw *hw, i40e_status stat_err)
151{
152 switch (stat_err) {
153 case 0:
154 return "OK";
155 case I40E_ERR_NVM:
156 return "I40E_ERR_NVM";
157 case I40E_ERR_NVM_CHECKSUM:
158 return "I40E_ERR_NVM_CHECKSUM";
159 case I40E_ERR_PHY:
160 return "I40E_ERR_PHY";
161 case I40E_ERR_CONFIG:
162 return "I40E_ERR_CONFIG";
163 case I40E_ERR_PARAM:
164 return "I40E_ERR_PARAM";
165 case I40E_ERR_MAC_TYPE:
166 return "I40E_ERR_MAC_TYPE";
167 case I40E_ERR_UNKNOWN_PHY:
168 return "I40E_ERR_UNKNOWN_PHY";
169 case I40E_ERR_LINK_SETUP:
170 return "I40E_ERR_LINK_SETUP";
171 case I40E_ERR_ADAPTER_STOPPED:
172 return "I40E_ERR_ADAPTER_STOPPED";
173 case I40E_ERR_INVALID_MAC_ADDR:
174 return "I40E_ERR_INVALID_MAC_ADDR";
175 case I40E_ERR_DEVICE_NOT_SUPPORTED:
176 return "I40E_ERR_DEVICE_NOT_SUPPORTED";
177 case I40E_ERR_MASTER_REQUESTS_PENDING:
178 return "I40E_ERR_MASTER_REQUESTS_PENDING";
179 case I40E_ERR_INVALID_LINK_SETTINGS:
180 return "I40E_ERR_INVALID_LINK_SETTINGS";
181 case I40E_ERR_AUTONEG_NOT_COMPLETE:
182 return "I40E_ERR_AUTONEG_NOT_COMPLETE";
183 case I40E_ERR_RESET_FAILED:
184 return "I40E_ERR_RESET_FAILED";
185 case I40E_ERR_SWFW_SYNC:
186 return "I40E_ERR_SWFW_SYNC";
187 case I40E_ERR_NO_AVAILABLE_VSI:
188 return "I40E_ERR_NO_AVAILABLE_VSI";
189 case I40E_ERR_NO_MEMORY:
190 return "I40E_ERR_NO_MEMORY";
191 case I40E_ERR_BAD_PTR:
192 return "I40E_ERR_BAD_PTR";
193 case I40E_ERR_RING_FULL:
194 return "I40E_ERR_RING_FULL";
195 case I40E_ERR_INVALID_PD_ID:
196 return "I40E_ERR_INVALID_PD_ID";
197 case I40E_ERR_INVALID_QP_ID:
198 return "I40E_ERR_INVALID_QP_ID";
199 case I40E_ERR_INVALID_CQ_ID:
200 return "I40E_ERR_INVALID_CQ_ID";
201 case I40E_ERR_INVALID_CEQ_ID:
202 return "I40E_ERR_INVALID_CEQ_ID";
203 case I40E_ERR_INVALID_AEQ_ID:
204 return "I40E_ERR_INVALID_AEQ_ID";
205 case I40E_ERR_INVALID_SIZE:
206 return "I40E_ERR_INVALID_SIZE";
207 case I40E_ERR_INVALID_ARP_INDEX:
208 return "I40E_ERR_INVALID_ARP_INDEX";
209 case I40E_ERR_INVALID_FPM_FUNC_ID:
210 return "I40E_ERR_INVALID_FPM_FUNC_ID";
211 case I40E_ERR_QP_INVALID_MSG_SIZE:
212 return "I40E_ERR_QP_INVALID_MSG_SIZE";
213 case I40E_ERR_QP_TOOMANY_WRS_POSTED:
214 return "I40E_ERR_QP_TOOMANY_WRS_POSTED";
215 case I40E_ERR_INVALID_FRAG_COUNT:
216 return "I40E_ERR_INVALID_FRAG_COUNT";
217 case I40E_ERR_QUEUE_EMPTY:
218 return "I40E_ERR_QUEUE_EMPTY";
219 case I40E_ERR_INVALID_ALIGNMENT:
220 return "I40E_ERR_INVALID_ALIGNMENT";
221 case I40E_ERR_FLUSHED_QUEUE:
222 return "I40E_ERR_FLUSHED_QUEUE";
223 case I40E_ERR_INVALID_PUSH_PAGE_INDEX:
224 return "I40E_ERR_INVALID_PUSH_PAGE_INDEX";
225 case I40E_ERR_INVALID_IMM_DATA_SIZE:
226 return "I40E_ERR_INVALID_IMM_DATA_SIZE";
227 case I40E_ERR_TIMEOUT:
228 return "I40E_ERR_TIMEOUT";
229 case I40E_ERR_OPCODE_MISMATCH:
230 return "I40E_ERR_OPCODE_MISMATCH";
231 case I40E_ERR_CQP_COMPL_ERROR:
232 return "I40E_ERR_CQP_COMPL_ERROR";
233 case I40E_ERR_INVALID_VF_ID:
234 return "I40E_ERR_INVALID_VF_ID";
235 case I40E_ERR_INVALID_HMCFN_ID:
236 return "I40E_ERR_INVALID_HMCFN_ID";
237 case I40E_ERR_BACKING_PAGE_ERROR:
238 return "I40E_ERR_BACKING_PAGE_ERROR";
239 case I40E_ERR_NO_PBLCHUNKS_AVAILABLE:
240 return "I40E_ERR_NO_PBLCHUNKS_AVAILABLE";
241 case I40E_ERR_INVALID_PBLE_INDEX:
242 return "I40E_ERR_INVALID_PBLE_INDEX";
243 case I40E_ERR_INVALID_SD_INDEX:
244 return "I40E_ERR_INVALID_SD_INDEX";
245 case I40E_ERR_INVALID_PAGE_DESC_INDEX:
246 return "I40E_ERR_INVALID_PAGE_DESC_INDEX";
247 case I40E_ERR_INVALID_SD_TYPE:
248 return "I40E_ERR_INVALID_SD_TYPE";
249 case I40E_ERR_MEMCPY_FAILED:
250 return "I40E_ERR_MEMCPY_FAILED";
251 case I40E_ERR_INVALID_HMC_OBJ_INDEX:
252 return "I40E_ERR_INVALID_HMC_OBJ_INDEX";
253 case I40E_ERR_INVALID_HMC_OBJ_COUNT:
254 return "I40E_ERR_INVALID_HMC_OBJ_COUNT";
255 case I40E_ERR_INVALID_SRQ_ARM_LIMIT:
256 return "I40E_ERR_INVALID_SRQ_ARM_LIMIT";
257 case I40E_ERR_SRQ_ENABLED:
258 return "I40E_ERR_SRQ_ENABLED";
259 case I40E_ERR_ADMIN_QUEUE_ERROR:
260 return "I40E_ERR_ADMIN_QUEUE_ERROR";
261 case I40E_ERR_ADMIN_QUEUE_TIMEOUT:
262 return "I40E_ERR_ADMIN_QUEUE_TIMEOUT";
263 case I40E_ERR_BUF_TOO_SHORT:
264 return "I40E_ERR_BUF_TOO_SHORT";
265 case I40E_ERR_ADMIN_QUEUE_FULL:
266 return "I40E_ERR_ADMIN_QUEUE_FULL";
267 case I40E_ERR_ADMIN_QUEUE_NO_WORK:
268 return "I40E_ERR_ADMIN_QUEUE_NO_WORK";
269 case I40E_ERR_BAD_IWARP_CQE:
270 return "I40E_ERR_BAD_IWARP_CQE";
271 case I40E_ERR_NVM_BLANK_MODE:
272 return "I40E_ERR_NVM_BLANK_MODE";
273 case I40E_ERR_NOT_IMPLEMENTED:
274 return "I40E_ERR_NOT_IMPLEMENTED";
275 case I40E_ERR_PE_DOORBELL_NOT_ENABLED:
276 return "I40E_ERR_PE_DOORBELL_NOT_ENABLED";
277 case I40E_ERR_DIAG_TEST_FAILED:
278 return "I40E_ERR_DIAG_TEST_FAILED";
279 case I40E_ERR_NOT_READY:
280 return "I40E_ERR_NOT_READY";
281 case I40E_NOT_SUPPORTED:
282 return "I40E_NOT_SUPPORTED";
283 case I40E_ERR_FIRMWARE_API_VERSION:
284 return "I40E_ERR_FIRMWARE_API_VERSION";
285 }
286
287 snprintf(hw->err_str, sizeof(hw->err_str), "%d", stat_err);
288 return hw->err_str;
289}
290
291/**
Greg Rosed358aa92013-12-21 06:13:11 +0000292 * i40evf_debug_aq
293 * @hw: debug mask related to admin queue
294 * @mask: debug mask
295 * @desc: pointer to admin queue descriptor
296 * @buffer: pointer to command buffer
Shannon Nelsonf905dd62014-07-10 07:58:20 +0000297 * @buf_len: max length of buffer
Greg Rosed358aa92013-12-21 06:13:11 +0000298 *
299 * Dumps debug log about adminq command with descriptor contents.
300 **/
301void i40evf_debug_aq(struct i40e_hw *hw, enum i40e_debug_mask mask, void *desc,
Shannon Nelsonf905dd62014-07-10 07:58:20 +0000302 void *buffer, u16 buf_len)
Greg Rosed358aa92013-12-21 06:13:11 +0000303{
304 struct i40e_aq_desc *aq_desc = (struct i40e_aq_desc *)desc;
Shannon Nelsonf905dd62014-07-10 07:58:20 +0000305 u16 len = le16_to_cpu(aq_desc->datalen);
Shannon Nelson37a29732015-02-27 09:15:19 +0000306 u8 *buf = (u8 *)buffer;
307 u16 i = 0;
Greg Rosed358aa92013-12-21 06:13:11 +0000308
309 if ((!(mask & hw->debug_mask)) || (desc == NULL))
310 return;
311
312 i40e_debug(hw, mask,
313 "AQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n",
Paul M Stillwell Jrf1abd7d2015-02-06 08:52:07 +0000314 le16_to_cpu(aq_desc->opcode),
315 le16_to_cpu(aq_desc->flags),
316 le16_to_cpu(aq_desc->datalen),
317 le16_to_cpu(aq_desc->retval));
Greg Rosed358aa92013-12-21 06:13:11 +0000318 i40e_debug(hw, mask, "\tcookie (h,l) 0x%08X 0x%08X\n",
Paul M Stillwell Jrf1abd7d2015-02-06 08:52:07 +0000319 le32_to_cpu(aq_desc->cookie_high),
320 le32_to_cpu(aq_desc->cookie_low));
Greg Rosed358aa92013-12-21 06:13:11 +0000321 i40e_debug(hw, mask, "\tparam (0,1) 0x%08X 0x%08X\n",
Paul M Stillwell Jrf1abd7d2015-02-06 08:52:07 +0000322 le32_to_cpu(aq_desc->params.internal.param0),
323 le32_to_cpu(aq_desc->params.internal.param1));
Greg Rosed358aa92013-12-21 06:13:11 +0000324 i40e_debug(hw, mask, "\taddr (h,l) 0x%08X 0x%08X\n",
Paul M Stillwell Jrf1abd7d2015-02-06 08:52:07 +0000325 le32_to_cpu(aq_desc->params.external.addr_high),
326 le32_to_cpu(aq_desc->params.external.addr_low));
Greg Rosed358aa92013-12-21 06:13:11 +0000327
328 if ((buffer != NULL) && (aq_desc->datalen != 0)) {
Greg Rosed358aa92013-12-21 06:13:11 +0000329 i40e_debug(hw, mask, "AQ CMD Buffer:\n");
Shannon Nelsonf905dd62014-07-10 07:58:20 +0000330 if (buf_len < len)
331 len = buf_len;
Shannon Nelson37a29732015-02-27 09:15:19 +0000332 /* write the full 16-byte chunks */
333 for (i = 0; i < (len - 16); i += 16)
334 i40e_debug(hw, mask,
335 "\t0x%04X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n",
336 i, buf[i], buf[i + 1], buf[i + 2],
337 buf[i + 3], buf[i + 4], buf[i + 5],
338 buf[i + 6], buf[i + 7], buf[i + 8],
339 buf[i + 9], buf[i + 10], buf[i + 11],
340 buf[i + 12], buf[i + 13], buf[i + 14],
341 buf[i + 15]);
342 /* write whatever's left over without overrunning the buffer */
343 if (i < len) {
344 char d_buf[80];
345 int j = 0;
346
347 memset(d_buf, 0, sizeof(d_buf));
348 j += sprintf(d_buf, "\t0x%04X ", i);
349 while (i < len)
350 j += sprintf(&d_buf[j], " %02X", buf[i++]);
351 i40e_debug(hw, mask, "%s\n", d_buf);
Greg Rosed358aa92013-12-21 06:13:11 +0000352 }
Greg Rosed358aa92013-12-21 06:13:11 +0000353 }
354}
355
356/**
357 * i40evf_check_asq_alive
358 * @hw: pointer to the hw struct
359 *
360 * Returns true if Queue is enabled else false.
361 **/
362bool i40evf_check_asq_alive(struct i40e_hw *hw)
363{
Kevin Scott8b833b42014-04-09 05:58:54 +0000364 if (hw->aq.asq.len)
365 return !!(rd32(hw, hw->aq.asq.len) &
Anjali Singhai Jaine02a7f82015-07-10 19:36:06 -0400366 I40E_VF_ATQLEN1_ATQENABLE_MASK);
Kevin Scott8b833b42014-04-09 05:58:54 +0000367 else
368 return false;
Greg Rosed358aa92013-12-21 06:13:11 +0000369}
370
371/**
372 * i40evf_aq_queue_shutdown
373 * @hw: pointer to the hw struct
374 * @unloading: is the driver unloading itself
375 *
376 * Tell the Firmware that we're shutting down the AdminQ and whether
377 * or not the driver is unloading as well.
378 **/
379i40e_status i40evf_aq_queue_shutdown(struct i40e_hw *hw,
380 bool unloading)
381{
382 struct i40e_aq_desc desc;
383 struct i40e_aqc_queue_shutdown *cmd =
384 (struct i40e_aqc_queue_shutdown *)&desc.params.raw;
385 i40e_status status;
386
387 i40evf_fill_default_direct_cmd_desc(&desc,
388 i40e_aqc_opc_queue_shutdown);
389
390 if (unloading)
391 cmd->driver_unloading = cpu_to_le32(I40E_AQ_DRIVER_UNLOADING);
392 status = i40evf_asq_send_command(hw, &desc, NULL, 0, NULL);
393
394 return status;
395}
396
Anjali Singhai Jaine50c8d62015-06-05 12:20:27 -0400397/**
398 * i40e_aq_get_set_rss_lut
399 * @hw: pointer to the hardware structure
400 * @vsi_id: vsi fw index
401 * @pf_lut: for PF table set true, for VSI table set false
402 * @lut: pointer to the lut buffer provided by the caller
403 * @lut_size: size of the lut buffer
404 * @set: set true to set the table, false to get the table
405 *
406 * Internal function to get or set RSS look up table
407 **/
408static i40e_status i40e_aq_get_set_rss_lut(struct i40e_hw *hw,
409 u16 vsi_id, bool pf_lut,
410 u8 *lut, u16 lut_size,
411 bool set)
412{
413 i40e_status status;
414 struct i40e_aq_desc desc;
415 struct i40e_aqc_get_set_rss_lut *cmd_resp =
416 (struct i40e_aqc_get_set_rss_lut *)&desc.params.raw;
417
418 if (set)
419 i40evf_fill_default_direct_cmd_desc(&desc,
420 i40e_aqc_opc_set_rss_lut);
421 else
422 i40evf_fill_default_direct_cmd_desc(&desc,
423 i40e_aqc_opc_get_rss_lut);
424
425 /* Indirect command */
426 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
427 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_RD);
428
429 cmd_resp->vsi_id =
430 cpu_to_le16((u16)((vsi_id <<
431 I40E_AQC_SET_RSS_LUT_VSI_ID_SHIFT) &
432 I40E_AQC_SET_RSS_LUT_VSI_ID_MASK));
433 cmd_resp->vsi_id |= cpu_to_le16((u16)I40E_AQC_SET_RSS_LUT_VSI_VALID);
434
435 if (pf_lut)
436 cmd_resp->flags |= cpu_to_le16((u16)
437 ((I40E_AQC_SET_RSS_LUT_TABLE_TYPE_PF <<
438 I40E_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) &
439 I40E_AQC_SET_RSS_LUT_TABLE_TYPE_MASK));
440 else
441 cmd_resp->flags |= cpu_to_le16((u16)
442 ((I40E_AQC_SET_RSS_LUT_TABLE_TYPE_VSI <<
443 I40E_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) &
444 I40E_AQC_SET_RSS_LUT_TABLE_TYPE_MASK));
445
446 cmd_resp->addr_high = cpu_to_le32(high_16_bits((u64)lut));
447 cmd_resp->addr_low = cpu_to_le32(lower_32_bits((u64)lut));
448
449 status = i40evf_asq_send_command(hw, &desc, lut, lut_size, NULL);
450
451 return status;
452}
453
454/**
455 * i40evf_aq_get_rss_lut
456 * @hw: pointer to the hardware structure
457 * @vsi_id: vsi fw index
458 * @pf_lut: for PF table set true, for VSI table set false
459 * @lut: pointer to the lut buffer provided by the caller
460 * @lut_size: size of the lut buffer
461 *
462 * get the RSS lookup table, PF or VSI type
463 **/
464i40e_status i40evf_aq_get_rss_lut(struct i40e_hw *hw, u16 vsi_id,
465 bool pf_lut, u8 *lut, u16 lut_size)
466{
467 return i40e_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size,
468 false);
469}
470
471/**
472 * i40evf_aq_set_rss_lut
473 * @hw: pointer to the hardware structure
474 * @vsi_id: vsi fw index
475 * @pf_lut: for PF table set true, for VSI table set false
476 * @lut: pointer to the lut buffer provided by the caller
477 * @lut_size: size of the lut buffer
478 *
479 * set the RSS lookup table, PF or VSI type
480 **/
481i40e_status i40evf_aq_set_rss_lut(struct i40e_hw *hw, u16 vsi_id,
482 bool pf_lut, u8 *lut, u16 lut_size)
483{
484 return i40e_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size, true);
485}
486
487/**
488 * i40e_aq_get_set_rss_key
489 * @hw: pointer to the hw struct
490 * @vsi_id: vsi fw index
491 * @key: pointer to key info struct
492 * @set: set true to set the key, false to get the key
493 *
494 * get the RSS key per VSI
495 **/
496static i40e_status i40e_aq_get_set_rss_key(struct i40e_hw *hw,
497 u16 vsi_id,
498 struct i40e_aqc_get_set_rss_key_data *key,
499 bool set)
500{
501 i40e_status status;
502 struct i40e_aq_desc desc;
503 struct i40e_aqc_get_set_rss_key *cmd_resp =
504 (struct i40e_aqc_get_set_rss_key *)&desc.params.raw;
505 u16 key_size = sizeof(struct i40e_aqc_get_set_rss_key_data);
506
507 if (set)
508 i40evf_fill_default_direct_cmd_desc(&desc,
509 i40e_aqc_opc_set_rss_key);
510 else
511 i40evf_fill_default_direct_cmd_desc(&desc,
512 i40e_aqc_opc_get_rss_key);
513
514 /* Indirect command */
515 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
516 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_RD);
517
518 cmd_resp->vsi_id =
519 cpu_to_le16((u16)((vsi_id <<
520 I40E_AQC_SET_RSS_KEY_VSI_ID_SHIFT) &
521 I40E_AQC_SET_RSS_KEY_VSI_ID_MASK));
522 cmd_resp->vsi_id |= cpu_to_le16((u16)I40E_AQC_SET_RSS_KEY_VSI_VALID);
523 cmd_resp->addr_high = cpu_to_le32(high_16_bits((u64)key));
524 cmd_resp->addr_low = cpu_to_le32(lower_32_bits((u64)key));
525
526 status = i40evf_asq_send_command(hw, &desc, key, key_size, NULL);
527
528 return status;
529}
530
531/**
532 * i40evf_aq_get_rss_key
533 * @hw: pointer to the hw struct
534 * @vsi_id: vsi fw index
535 * @key: pointer to key info struct
536 *
537 **/
538i40e_status i40evf_aq_get_rss_key(struct i40e_hw *hw,
539 u16 vsi_id,
540 struct i40e_aqc_get_set_rss_key_data *key)
541{
542 return i40e_aq_get_set_rss_key(hw, vsi_id, key, false);
543}
544
545/**
546 * i40evf_aq_set_rss_key
547 * @hw: pointer to the hw struct
548 * @vsi_id: vsi fw index
549 * @key: pointer to key info struct
550 *
551 * set the RSS key per VSI
552 **/
553i40e_status i40evf_aq_set_rss_key(struct i40e_hw *hw,
554 u16 vsi_id,
555 struct i40e_aqc_get_set_rss_key_data *key)
556{
557 return i40e_aq_get_set_rss_key(hw, vsi_id, key, true);
558}
559
Greg Rosed358aa92013-12-21 06:13:11 +0000560
Eric W Biederman37a622c2014-03-18 00:26:50 -0700561/* The i40evf_ptype_lookup table is used to convert from the 8-bit ptype in the
Jesse Brandeburg206812b2014-02-12 01:45:33 +0000562 * hardware to a bit-field that can be used by SW to more easily determine the
563 * packet type.
564 *
565 * Macros are used to shorten the table lines and make this table human
566 * readable.
567 *
568 * We store the PTYPE in the top byte of the bit field - this is just so that
569 * we can check that the table doesn't have a row missing, as the index into
570 * the table should be the PTYPE.
571 *
572 * Typical work flow:
573 *
Eric W Biederman37a622c2014-03-18 00:26:50 -0700574 * IF NOT i40evf_ptype_lookup[ptype].known
Jesse Brandeburg206812b2014-02-12 01:45:33 +0000575 * THEN
576 * Packet is unknown
Eric W Biederman37a622c2014-03-18 00:26:50 -0700577 * ELSE IF i40evf_ptype_lookup[ptype].outer_ip == I40E_RX_PTYPE_OUTER_IP
Jesse Brandeburg206812b2014-02-12 01:45:33 +0000578 * Use the rest of the fields to look at the tunnels, inner protocols, etc
579 * ELSE
580 * Use the enum i40e_rx_l2_ptype to decode the packet type
581 * ENDIF
582 */
583
584/* macro to make the table lines short */
585#define I40E_PTT(PTYPE, OUTER_IP, OUTER_IP_VER, OUTER_FRAG, T, TE, TEF, I, PL)\
586 { PTYPE, \
587 1, \
588 I40E_RX_PTYPE_OUTER_##OUTER_IP, \
589 I40E_RX_PTYPE_OUTER_##OUTER_IP_VER, \
590 I40E_RX_PTYPE_##OUTER_FRAG, \
591 I40E_RX_PTYPE_TUNNEL_##T, \
592 I40E_RX_PTYPE_TUNNEL_END_##TE, \
593 I40E_RX_PTYPE_##TEF, \
594 I40E_RX_PTYPE_INNER_PROT_##I, \
595 I40E_RX_PTYPE_PAYLOAD_LAYER_##PL }
596
597#define I40E_PTT_UNUSED_ENTRY(PTYPE) \
598 { PTYPE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
599
600/* shorter macros makes the table fit but are terse */
601#define I40E_RX_PTYPE_NOF I40E_RX_PTYPE_NOT_FRAG
602#define I40E_RX_PTYPE_FRG I40E_RX_PTYPE_FRAG
603#define I40E_RX_PTYPE_INNER_PROT_TS I40E_RX_PTYPE_INNER_PROT_TIMESYNC
604
605/* Lookup table mapping the HW PTYPE to the bit field for decoding */
Eric W Biederman37a622c2014-03-18 00:26:50 -0700606struct i40e_rx_ptype_decoded i40evf_ptype_lookup[] = {
Jesse Brandeburg206812b2014-02-12 01:45:33 +0000607 /* L2 Packet types */
608 I40E_PTT_UNUSED_ENTRY(0),
609 I40E_PTT(1, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
610 I40E_PTT(2, L2, NONE, NOF, NONE, NONE, NOF, TS, PAY2),
611 I40E_PTT(3, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
612 I40E_PTT_UNUSED_ENTRY(4),
613 I40E_PTT_UNUSED_ENTRY(5),
614 I40E_PTT(6, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
615 I40E_PTT(7, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
616 I40E_PTT_UNUSED_ENTRY(8),
617 I40E_PTT_UNUSED_ENTRY(9),
618 I40E_PTT(10, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
619 I40E_PTT(11, L2, NONE, NOF, NONE, NONE, NOF, NONE, NONE),
620 I40E_PTT(12, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
621 I40E_PTT(13, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
622 I40E_PTT(14, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
623 I40E_PTT(15, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
624 I40E_PTT(16, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
625 I40E_PTT(17, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
626 I40E_PTT(18, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
627 I40E_PTT(19, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
628 I40E_PTT(20, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
629 I40E_PTT(21, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
630
631 /* Non Tunneled IPv4 */
632 I40E_PTT(22, IP, IPV4, FRG, NONE, NONE, NOF, NONE, PAY3),
633 I40E_PTT(23, IP, IPV4, NOF, NONE, NONE, NOF, NONE, PAY3),
634 I40E_PTT(24, IP, IPV4, NOF, NONE, NONE, NOF, UDP, PAY4),
635 I40E_PTT_UNUSED_ENTRY(25),
636 I40E_PTT(26, IP, IPV4, NOF, NONE, NONE, NOF, TCP, PAY4),
637 I40E_PTT(27, IP, IPV4, NOF, NONE, NONE, NOF, SCTP, PAY4),
638 I40E_PTT(28, IP, IPV4, NOF, NONE, NONE, NOF, ICMP, PAY4),
639
640 /* IPv4 --> IPv4 */
641 I40E_PTT(29, IP, IPV4, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
642 I40E_PTT(30, IP, IPV4, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
643 I40E_PTT(31, IP, IPV4, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
644 I40E_PTT_UNUSED_ENTRY(32),
645 I40E_PTT(33, IP, IPV4, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
646 I40E_PTT(34, IP, IPV4, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
647 I40E_PTT(35, IP, IPV4, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
648
649 /* IPv4 --> IPv6 */
650 I40E_PTT(36, IP, IPV4, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
651 I40E_PTT(37, IP, IPV4, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
652 I40E_PTT(38, IP, IPV4, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
653 I40E_PTT_UNUSED_ENTRY(39),
654 I40E_PTT(40, IP, IPV4, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
655 I40E_PTT(41, IP, IPV4, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
656 I40E_PTT(42, IP, IPV4, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
657
658 /* IPv4 --> GRE/NAT */
659 I40E_PTT(43, IP, IPV4, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
660
661 /* IPv4 --> GRE/NAT --> IPv4 */
662 I40E_PTT(44, IP, IPV4, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
663 I40E_PTT(45, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
664 I40E_PTT(46, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
665 I40E_PTT_UNUSED_ENTRY(47),
666 I40E_PTT(48, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
667 I40E_PTT(49, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
668 I40E_PTT(50, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
669
670 /* IPv4 --> GRE/NAT --> IPv6 */
671 I40E_PTT(51, IP, IPV4, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
672 I40E_PTT(52, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
673 I40E_PTT(53, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
674 I40E_PTT_UNUSED_ENTRY(54),
675 I40E_PTT(55, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
676 I40E_PTT(56, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
677 I40E_PTT(57, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
678
679 /* IPv4 --> GRE/NAT --> MAC */
680 I40E_PTT(58, IP, IPV4, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
681
682 /* IPv4 --> GRE/NAT --> MAC --> IPv4 */
683 I40E_PTT(59, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
684 I40E_PTT(60, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
685 I40E_PTT(61, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
686 I40E_PTT_UNUSED_ENTRY(62),
687 I40E_PTT(63, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
688 I40E_PTT(64, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
689 I40E_PTT(65, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
690
691 /* IPv4 --> GRE/NAT -> MAC --> IPv6 */
692 I40E_PTT(66, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
693 I40E_PTT(67, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
694 I40E_PTT(68, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
695 I40E_PTT_UNUSED_ENTRY(69),
696 I40E_PTT(70, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
697 I40E_PTT(71, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
698 I40E_PTT(72, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
699
700 /* IPv4 --> GRE/NAT --> MAC/VLAN */
701 I40E_PTT(73, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
702
703 /* IPv4 ---> GRE/NAT -> MAC/VLAN --> IPv4 */
704 I40E_PTT(74, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
705 I40E_PTT(75, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
706 I40E_PTT(76, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
707 I40E_PTT_UNUSED_ENTRY(77),
708 I40E_PTT(78, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
709 I40E_PTT(79, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
710 I40E_PTT(80, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
711
712 /* IPv4 -> GRE/NAT -> MAC/VLAN --> IPv6 */
713 I40E_PTT(81, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
714 I40E_PTT(82, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
715 I40E_PTT(83, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
716 I40E_PTT_UNUSED_ENTRY(84),
717 I40E_PTT(85, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
718 I40E_PTT(86, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
719 I40E_PTT(87, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
720
721 /* Non Tunneled IPv6 */
722 I40E_PTT(88, IP, IPV6, FRG, NONE, NONE, NOF, NONE, PAY3),
723 I40E_PTT(89, IP, IPV6, NOF, NONE, NONE, NOF, NONE, PAY3),
724 I40E_PTT(90, IP, IPV6, NOF, NONE, NONE, NOF, UDP, PAY3),
725 I40E_PTT_UNUSED_ENTRY(91),
726 I40E_PTT(92, IP, IPV6, NOF, NONE, NONE, NOF, TCP, PAY4),
727 I40E_PTT(93, IP, IPV6, NOF, NONE, NONE, NOF, SCTP, PAY4),
728 I40E_PTT(94, IP, IPV6, NOF, NONE, NONE, NOF, ICMP, PAY4),
729
730 /* IPv6 --> IPv4 */
731 I40E_PTT(95, IP, IPV6, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
732 I40E_PTT(96, IP, IPV6, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
733 I40E_PTT(97, IP, IPV6, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
734 I40E_PTT_UNUSED_ENTRY(98),
735 I40E_PTT(99, IP, IPV6, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
736 I40E_PTT(100, IP, IPV6, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
737 I40E_PTT(101, IP, IPV6, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
738
739 /* IPv6 --> IPv6 */
740 I40E_PTT(102, IP, IPV6, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
741 I40E_PTT(103, IP, IPV6, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
742 I40E_PTT(104, IP, IPV6, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
743 I40E_PTT_UNUSED_ENTRY(105),
744 I40E_PTT(106, IP, IPV6, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
745 I40E_PTT(107, IP, IPV6, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
746 I40E_PTT(108, IP, IPV6, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
747
748 /* IPv6 --> GRE/NAT */
749 I40E_PTT(109, IP, IPV6, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
750
751 /* IPv6 --> GRE/NAT -> IPv4 */
752 I40E_PTT(110, IP, IPV6, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
753 I40E_PTT(111, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
754 I40E_PTT(112, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
755 I40E_PTT_UNUSED_ENTRY(113),
756 I40E_PTT(114, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
757 I40E_PTT(115, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
758 I40E_PTT(116, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
759
760 /* IPv6 --> GRE/NAT -> IPv6 */
761 I40E_PTT(117, IP, IPV6, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
762 I40E_PTT(118, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
763 I40E_PTT(119, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
764 I40E_PTT_UNUSED_ENTRY(120),
765 I40E_PTT(121, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
766 I40E_PTT(122, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
767 I40E_PTT(123, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
768
769 /* IPv6 --> GRE/NAT -> MAC */
770 I40E_PTT(124, IP, IPV6, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
771
772 /* IPv6 --> GRE/NAT -> MAC -> IPv4 */
773 I40E_PTT(125, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
774 I40E_PTT(126, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
775 I40E_PTT(127, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
776 I40E_PTT_UNUSED_ENTRY(128),
777 I40E_PTT(129, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
778 I40E_PTT(130, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
779 I40E_PTT(131, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
780
781 /* IPv6 --> GRE/NAT -> MAC -> IPv6 */
782 I40E_PTT(132, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
783 I40E_PTT(133, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
784 I40E_PTT(134, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
785 I40E_PTT_UNUSED_ENTRY(135),
786 I40E_PTT(136, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
787 I40E_PTT(137, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
788 I40E_PTT(138, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
789
790 /* IPv6 --> GRE/NAT -> MAC/VLAN */
791 I40E_PTT(139, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
792
793 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv4 */
794 I40E_PTT(140, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
795 I40E_PTT(141, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
796 I40E_PTT(142, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
797 I40E_PTT_UNUSED_ENTRY(143),
798 I40E_PTT(144, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
799 I40E_PTT(145, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
800 I40E_PTT(146, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
801
802 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv6 */
803 I40E_PTT(147, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
804 I40E_PTT(148, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
805 I40E_PTT(149, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
806 I40E_PTT_UNUSED_ENTRY(150),
807 I40E_PTT(151, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
808 I40E_PTT(152, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
809 I40E_PTT(153, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
810
811 /* unused entries */
812 I40E_PTT_UNUSED_ENTRY(154),
813 I40E_PTT_UNUSED_ENTRY(155),
814 I40E_PTT_UNUSED_ENTRY(156),
815 I40E_PTT_UNUSED_ENTRY(157),
816 I40E_PTT_UNUSED_ENTRY(158),
817 I40E_PTT_UNUSED_ENTRY(159),
818
819 I40E_PTT_UNUSED_ENTRY(160),
820 I40E_PTT_UNUSED_ENTRY(161),
821 I40E_PTT_UNUSED_ENTRY(162),
822 I40E_PTT_UNUSED_ENTRY(163),
823 I40E_PTT_UNUSED_ENTRY(164),
824 I40E_PTT_UNUSED_ENTRY(165),
825 I40E_PTT_UNUSED_ENTRY(166),
826 I40E_PTT_UNUSED_ENTRY(167),
827 I40E_PTT_UNUSED_ENTRY(168),
828 I40E_PTT_UNUSED_ENTRY(169),
829
830 I40E_PTT_UNUSED_ENTRY(170),
831 I40E_PTT_UNUSED_ENTRY(171),
832 I40E_PTT_UNUSED_ENTRY(172),
833 I40E_PTT_UNUSED_ENTRY(173),
834 I40E_PTT_UNUSED_ENTRY(174),
835 I40E_PTT_UNUSED_ENTRY(175),
836 I40E_PTT_UNUSED_ENTRY(176),
837 I40E_PTT_UNUSED_ENTRY(177),
838 I40E_PTT_UNUSED_ENTRY(178),
839 I40E_PTT_UNUSED_ENTRY(179),
840
841 I40E_PTT_UNUSED_ENTRY(180),
842 I40E_PTT_UNUSED_ENTRY(181),
843 I40E_PTT_UNUSED_ENTRY(182),
844 I40E_PTT_UNUSED_ENTRY(183),
845 I40E_PTT_UNUSED_ENTRY(184),
846 I40E_PTT_UNUSED_ENTRY(185),
847 I40E_PTT_UNUSED_ENTRY(186),
848 I40E_PTT_UNUSED_ENTRY(187),
849 I40E_PTT_UNUSED_ENTRY(188),
850 I40E_PTT_UNUSED_ENTRY(189),
851
852 I40E_PTT_UNUSED_ENTRY(190),
853 I40E_PTT_UNUSED_ENTRY(191),
854 I40E_PTT_UNUSED_ENTRY(192),
855 I40E_PTT_UNUSED_ENTRY(193),
856 I40E_PTT_UNUSED_ENTRY(194),
857 I40E_PTT_UNUSED_ENTRY(195),
858 I40E_PTT_UNUSED_ENTRY(196),
859 I40E_PTT_UNUSED_ENTRY(197),
860 I40E_PTT_UNUSED_ENTRY(198),
861 I40E_PTT_UNUSED_ENTRY(199),
862
863 I40E_PTT_UNUSED_ENTRY(200),
864 I40E_PTT_UNUSED_ENTRY(201),
865 I40E_PTT_UNUSED_ENTRY(202),
866 I40E_PTT_UNUSED_ENTRY(203),
867 I40E_PTT_UNUSED_ENTRY(204),
868 I40E_PTT_UNUSED_ENTRY(205),
869 I40E_PTT_UNUSED_ENTRY(206),
870 I40E_PTT_UNUSED_ENTRY(207),
871 I40E_PTT_UNUSED_ENTRY(208),
872 I40E_PTT_UNUSED_ENTRY(209),
873
874 I40E_PTT_UNUSED_ENTRY(210),
875 I40E_PTT_UNUSED_ENTRY(211),
876 I40E_PTT_UNUSED_ENTRY(212),
877 I40E_PTT_UNUSED_ENTRY(213),
878 I40E_PTT_UNUSED_ENTRY(214),
879 I40E_PTT_UNUSED_ENTRY(215),
880 I40E_PTT_UNUSED_ENTRY(216),
881 I40E_PTT_UNUSED_ENTRY(217),
882 I40E_PTT_UNUSED_ENTRY(218),
883 I40E_PTT_UNUSED_ENTRY(219),
884
885 I40E_PTT_UNUSED_ENTRY(220),
886 I40E_PTT_UNUSED_ENTRY(221),
887 I40E_PTT_UNUSED_ENTRY(222),
888 I40E_PTT_UNUSED_ENTRY(223),
889 I40E_PTT_UNUSED_ENTRY(224),
890 I40E_PTT_UNUSED_ENTRY(225),
891 I40E_PTT_UNUSED_ENTRY(226),
892 I40E_PTT_UNUSED_ENTRY(227),
893 I40E_PTT_UNUSED_ENTRY(228),
894 I40E_PTT_UNUSED_ENTRY(229),
895
896 I40E_PTT_UNUSED_ENTRY(230),
897 I40E_PTT_UNUSED_ENTRY(231),
898 I40E_PTT_UNUSED_ENTRY(232),
899 I40E_PTT_UNUSED_ENTRY(233),
900 I40E_PTT_UNUSED_ENTRY(234),
901 I40E_PTT_UNUSED_ENTRY(235),
902 I40E_PTT_UNUSED_ENTRY(236),
903 I40E_PTT_UNUSED_ENTRY(237),
904 I40E_PTT_UNUSED_ENTRY(238),
905 I40E_PTT_UNUSED_ENTRY(239),
906
907 I40E_PTT_UNUSED_ENTRY(240),
908 I40E_PTT_UNUSED_ENTRY(241),
909 I40E_PTT_UNUSED_ENTRY(242),
910 I40E_PTT_UNUSED_ENTRY(243),
911 I40E_PTT_UNUSED_ENTRY(244),
912 I40E_PTT_UNUSED_ENTRY(245),
913 I40E_PTT_UNUSED_ENTRY(246),
914 I40E_PTT_UNUSED_ENTRY(247),
915 I40E_PTT_UNUSED_ENTRY(248),
916 I40E_PTT_UNUSED_ENTRY(249),
917
918 I40E_PTT_UNUSED_ENTRY(250),
919 I40E_PTT_UNUSED_ENTRY(251),
920 I40E_PTT_UNUSED_ENTRY(252),
921 I40E_PTT_UNUSED_ENTRY(253),
922 I40E_PTT_UNUSED_ENTRY(254),
923 I40E_PTT_UNUSED_ENTRY(255)
924};
925
Greg Rosed358aa92013-12-21 06:13:11 +0000926/**
927 * i40e_aq_send_msg_to_pf
928 * @hw: pointer to the hardware structure
929 * @v_opcode: opcodes for VF-PF communication
930 * @v_retval: return error code
931 * @msg: pointer to the msg buffer
932 * @msglen: msg length
933 * @cmd_details: pointer to command details
934 *
935 * Send message to PF driver using admin queue. By default, this message
936 * is sent asynchronously, i.e. i40evf_asq_send_command() does not wait for
937 * completion before returning.
938 **/
939i40e_status i40e_aq_send_msg_to_pf(struct i40e_hw *hw,
940 enum i40e_virtchnl_ops v_opcode,
941 i40e_status v_retval,
942 u8 *msg, u16 msglen,
943 struct i40e_asq_cmd_details *cmd_details)
944{
945 struct i40e_aq_desc desc;
Mitch Williams4334edf2014-06-04 08:45:16 +0000946 struct i40e_asq_cmd_details details;
Greg Rosed358aa92013-12-21 06:13:11 +0000947 i40e_status status;
948
949 i40evf_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_send_msg_to_pf);
950 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_SI);
951 desc.cookie_high = cpu_to_le32(v_opcode);
952 desc.cookie_low = cpu_to_le32(v_retval);
953 if (msglen) {
954 desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF
955 | I40E_AQ_FLAG_RD));
956 if (msglen > I40E_AQ_LARGE_BUF)
957 desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
958 desc.datalen = cpu_to_le16(msglen);
959 }
960 if (!cmd_details) {
Greg Rosed358aa92013-12-21 06:13:11 +0000961 memset(&details, 0, sizeof(details));
962 details.async = true;
963 cmd_details = &details;
964 }
Joe Perchesb58f2f72014-03-25 04:30:32 +0000965 status = i40evf_asq_send_command(hw, &desc, msg, msglen, cmd_details);
Greg Rosed358aa92013-12-21 06:13:11 +0000966 return status;
967}
968
969/**
970 * i40e_vf_parse_hw_config
971 * @hw: pointer to the hardware structure
972 * @msg: pointer to the virtual channel VF resource structure
973 *
974 * Given a VF resource message from the PF, populate the hw struct
975 * with appropriate information.
976 **/
977void i40e_vf_parse_hw_config(struct i40e_hw *hw,
978 struct i40e_virtchnl_vf_resource *msg)
979{
980 struct i40e_virtchnl_vsi_resource *vsi_res;
981 int i;
982
983 vsi_res = &msg->vsi_res[0];
984
985 hw->dev_caps.num_vsis = msg->num_vsis;
986 hw->dev_caps.num_rx_qp = msg->num_queue_pairs;
987 hw->dev_caps.num_tx_qp = msg->num_queue_pairs;
988 hw->dev_caps.num_msix_vectors_vf = msg->max_vectors;
989 hw->dev_caps.dcb = msg->vf_offload_flags &
990 I40E_VIRTCHNL_VF_OFFLOAD_L2;
991 hw->dev_caps.fcoe = (msg->vf_offload_flags &
992 I40E_VIRTCHNL_VF_OFFLOAD_FCOE) ? 1 : 0;
993 for (i = 0; i < msg->num_vsis; i++) {
994 if (vsi_res->vsi_type == I40E_VSI_SRIOV) {
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400995 ether_addr_copy(hw->mac.perm_addr,
996 vsi_res->default_mac_addr);
997 ether_addr_copy(hw->mac.addr,
998 vsi_res->default_mac_addr);
Greg Rosed358aa92013-12-21 06:13:11 +0000999 }
1000 vsi_res++;
1001 }
1002}
1003
1004/**
1005 * i40e_vf_reset
1006 * @hw: pointer to the hardware structure
1007 *
1008 * Send a VF_RESET message to the PF. Does not wait for response from PF
1009 * as none will be forthcoming. Immediately after calling this function,
1010 * the admin queue should be shut down and (optionally) reinitialized.
1011 **/
1012i40e_status i40e_vf_reset(struct i40e_hw *hw)
1013{
1014 return i40e_aq_send_msg_to_pf(hw, I40E_VIRTCHNL_OP_RESET_VF,
1015 0, NULL, 0, NULL);
1016}