xref: /linux/drivers/net/ethernet/intel/iavf/iavf_common.c (revision f6154d8babbb8a98f0d3ea325aafae2e33bfd8be)
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2013 - 2018 Intel Corporation. */
3 
4 #include "iavf_type.h"
5 #include "iavf_adminq.h"
6 #include "iavf_prototype.h"
7 #include <linux/avf/virtchnl.h>
8 
9 /**
10  * iavf_aq_str - convert AQ err code to a string
11  * @hw: pointer to the HW structure
12  * @aq_err: the AQ error code to convert
13  **/
14 const char *iavf_aq_str(struct iavf_hw *hw, enum iavf_admin_queue_err aq_err)
15 {
16 	switch (aq_err) {
17 	case IAVF_AQ_RC_OK:
18 		return "OK";
19 	case IAVF_AQ_RC_EPERM:
20 		return "IAVF_AQ_RC_EPERM";
21 	case IAVF_AQ_RC_ENOENT:
22 		return "IAVF_AQ_RC_ENOENT";
23 	case IAVF_AQ_RC_ESRCH:
24 		return "IAVF_AQ_RC_ESRCH";
25 	case IAVF_AQ_RC_EINTR:
26 		return "IAVF_AQ_RC_EINTR";
27 	case IAVF_AQ_RC_EIO:
28 		return "IAVF_AQ_RC_EIO";
29 	case IAVF_AQ_RC_ENXIO:
30 		return "IAVF_AQ_RC_ENXIO";
31 	case IAVF_AQ_RC_E2BIG:
32 		return "IAVF_AQ_RC_E2BIG";
33 	case IAVF_AQ_RC_EAGAIN:
34 		return "IAVF_AQ_RC_EAGAIN";
35 	case IAVF_AQ_RC_ENOMEM:
36 		return "IAVF_AQ_RC_ENOMEM";
37 	case IAVF_AQ_RC_EACCES:
38 		return "IAVF_AQ_RC_EACCES";
39 	case IAVF_AQ_RC_EFAULT:
40 		return "IAVF_AQ_RC_EFAULT";
41 	case IAVF_AQ_RC_EBUSY:
42 		return "IAVF_AQ_RC_EBUSY";
43 	case IAVF_AQ_RC_EEXIST:
44 		return "IAVF_AQ_RC_EEXIST";
45 	case IAVF_AQ_RC_EINVAL:
46 		return "IAVF_AQ_RC_EINVAL";
47 	case IAVF_AQ_RC_ENOTTY:
48 		return "IAVF_AQ_RC_ENOTTY";
49 	case IAVF_AQ_RC_ENOSPC:
50 		return "IAVF_AQ_RC_ENOSPC";
51 	case IAVF_AQ_RC_ENOSYS:
52 		return "IAVF_AQ_RC_ENOSYS";
53 	case IAVF_AQ_RC_ERANGE:
54 		return "IAVF_AQ_RC_ERANGE";
55 	case IAVF_AQ_RC_EFLUSHED:
56 		return "IAVF_AQ_RC_EFLUSHED";
57 	case IAVF_AQ_RC_BAD_ADDR:
58 		return "IAVF_AQ_RC_BAD_ADDR";
59 	case IAVF_AQ_RC_EMODE:
60 		return "IAVF_AQ_RC_EMODE";
61 	case IAVF_AQ_RC_EFBIG:
62 		return "IAVF_AQ_RC_EFBIG";
63 	}
64 
65 	snprintf(hw->err_str, sizeof(hw->err_str), "%d", aq_err);
66 	return hw->err_str;
67 }
68 
69 /**
70  * iavf_stat_str - convert status err code to a string
71  * @hw: pointer to the HW structure
72  * @stat_err: the status error code to convert
73  **/
74 const char *iavf_stat_str(struct iavf_hw *hw, enum iavf_status stat_err)
75 {
76 	switch (stat_err) {
77 	case 0:
78 		return "OK";
79 	case IAVF_ERR_NVM:
80 		return "IAVF_ERR_NVM";
81 	case IAVF_ERR_NVM_CHECKSUM:
82 		return "IAVF_ERR_NVM_CHECKSUM";
83 	case IAVF_ERR_PHY:
84 		return "IAVF_ERR_PHY";
85 	case IAVF_ERR_CONFIG:
86 		return "IAVF_ERR_CONFIG";
87 	case IAVF_ERR_PARAM:
88 		return "IAVF_ERR_PARAM";
89 	case IAVF_ERR_MAC_TYPE:
90 		return "IAVF_ERR_MAC_TYPE";
91 	case IAVF_ERR_UNKNOWN_PHY:
92 		return "IAVF_ERR_UNKNOWN_PHY";
93 	case IAVF_ERR_LINK_SETUP:
94 		return "IAVF_ERR_LINK_SETUP";
95 	case IAVF_ERR_ADAPTER_STOPPED:
96 		return "IAVF_ERR_ADAPTER_STOPPED";
97 	case IAVF_ERR_INVALID_MAC_ADDR:
98 		return "IAVF_ERR_INVALID_MAC_ADDR";
99 	case IAVF_ERR_DEVICE_NOT_SUPPORTED:
100 		return "IAVF_ERR_DEVICE_NOT_SUPPORTED";
101 	case IAVF_ERR_PRIMARY_REQUESTS_PENDING:
102 		return "IAVF_ERR_PRIMARY_REQUESTS_PENDING";
103 	case IAVF_ERR_INVALID_LINK_SETTINGS:
104 		return "IAVF_ERR_INVALID_LINK_SETTINGS";
105 	case IAVF_ERR_AUTONEG_NOT_COMPLETE:
106 		return "IAVF_ERR_AUTONEG_NOT_COMPLETE";
107 	case IAVF_ERR_RESET_FAILED:
108 		return "IAVF_ERR_RESET_FAILED";
109 	case IAVF_ERR_SWFW_SYNC:
110 		return "IAVF_ERR_SWFW_SYNC";
111 	case IAVF_ERR_NO_AVAILABLE_VSI:
112 		return "IAVF_ERR_NO_AVAILABLE_VSI";
113 	case IAVF_ERR_NO_MEMORY:
114 		return "IAVF_ERR_NO_MEMORY";
115 	case IAVF_ERR_BAD_PTR:
116 		return "IAVF_ERR_BAD_PTR";
117 	case IAVF_ERR_RING_FULL:
118 		return "IAVF_ERR_RING_FULL";
119 	case IAVF_ERR_INVALID_PD_ID:
120 		return "IAVF_ERR_INVALID_PD_ID";
121 	case IAVF_ERR_INVALID_QP_ID:
122 		return "IAVF_ERR_INVALID_QP_ID";
123 	case IAVF_ERR_INVALID_CQ_ID:
124 		return "IAVF_ERR_INVALID_CQ_ID";
125 	case IAVF_ERR_INVALID_CEQ_ID:
126 		return "IAVF_ERR_INVALID_CEQ_ID";
127 	case IAVF_ERR_INVALID_AEQ_ID:
128 		return "IAVF_ERR_INVALID_AEQ_ID";
129 	case IAVF_ERR_INVALID_SIZE:
130 		return "IAVF_ERR_INVALID_SIZE";
131 	case IAVF_ERR_INVALID_ARP_INDEX:
132 		return "IAVF_ERR_INVALID_ARP_INDEX";
133 	case IAVF_ERR_INVALID_FPM_FUNC_ID:
134 		return "IAVF_ERR_INVALID_FPM_FUNC_ID";
135 	case IAVF_ERR_QP_INVALID_MSG_SIZE:
136 		return "IAVF_ERR_QP_INVALID_MSG_SIZE";
137 	case IAVF_ERR_QP_TOOMANY_WRS_POSTED:
138 		return "IAVF_ERR_QP_TOOMANY_WRS_POSTED";
139 	case IAVF_ERR_INVALID_FRAG_COUNT:
140 		return "IAVF_ERR_INVALID_FRAG_COUNT";
141 	case IAVF_ERR_QUEUE_EMPTY:
142 		return "IAVF_ERR_QUEUE_EMPTY";
143 	case IAVF_ERR_INVALID_ALIGNMENT:
144 		return "IAVF_ERR_INVALID_ALIGNMENT";
145 	case IAVF_ERR_FLUSHED_QUEUE:
146 		return "IAVF_ERR_FLUSHED_QUEUE";
147 	case IAVF_ERR_INVALID_PUSH_PAGE_INDEX:
148 		return "IAVF_ERR_INVALID_PUSH_PAGE_INDEX";
149 	case IAVF_ERR_INVALID_IMM_DATA_SIZE:
150 		return "IAVF_ERR_INVALID_IMM_DATA_SIZE";
151 	case IAVF_ERR_TIMEOUT:
152 		return "IAVF_ERR_TIMEOUT";
153 	case IAVF_ERR_OPCODE_MISMATCH:
154 		return "IAVF_ERR_OPCODE_MISMATCH";
155 	case IAVF_ERR_CQP_COMPL_ERROR:
156 		return "IAVF_ERR_CQP_COMPL_ERROR";
157 	case IAVF_ERR_INVALID_VF_ID:
158 		return "IAVF_ERR_INVALID_VF_ID";
159 	case IAVF_ERR_INVALID_HMCFN_ID:
160 		return "IAVF_ERR_INVALID_HMCFN_ID";
161 	case IAVF_ERR_BACKING_PAGE_ERROR:
162 		return "IAVF_ERR_BACKING_PAGE_ERROR";
163 	case IAVF_ERR_NO_PBLCHUNKS_AVAILABLE:
164 		return "IAVF_ERR_NO_PBLCHUNKS_AVAILABLE";
165 	case IAVF_ERR_INVALID_PBLE_INDEX:
166 		return "IAVF_ERR_INVALID_PBLE_INDEX";
167 	case IAVF_ERR_INVALID_SD_INDEX:
168 		return "IAVF_ERR_INVALID_SD_INDEX";
169 	case IAVF_ERR_INVALID_PAGE_DESC_INDEX:
170 		return "IAVF_ERR_INVALID_PAGE_DESC_INDEX";
171 	case IAVF_ERR_INVALID_SD_TYPE:
172 		return "IAVF_ERR_INVALID_SD_TYPE";
173 	case IAVF_ERR_MEMCPY_FAILED:
174 		return "IAVF_ERR_MEMCPY_FAILED";
175 	case IAVF_ERR_INVALID_HMC_OBJ_INDEX:
176 		return "IAVF_ERR_INVALID_HMC_OBJ_INDEX";
177 	case IAVF_ERR_INVALID_HMC_OBJ_COUNT:
178 		return "IAVF_ERR_INVALID_HMC_OBJ_COUNT";
179 	case IAVF_ERR_INVALID_SRQ_ARM_LIMIT:
180 		return "IAVF_ERR_INVALID_SRQ_ARM_LIMIT";
181 	case IAVF_ERR_SRQ_ENABLED:
182 		return "IAVF_ERR_SRQ_ENABLED";
183 	case IAVF_ERR_ADMIN_QUEUE_ERROR:
184 		return "IAVF_ERR_ADMIN_QUEUE_ERROR";
185 	case IAVF_ERR_ADMIN_QUEUE_TIMEOUT:
186 		return "IAVF_ERR_ADMIN_QUEUE_TIMEOUT";
187 	case IAVF_ERR_BUF_TOO_SHORT:
188 		return "IAVF_ERR_BUF_TOO_SHORT";
189 	case IAVF_ERR_ADMIN_QUEUE_FULL:
190 		return "IAVF_ERR_ADMIN_QUEUE_FULL";
191 	case IAVF_ERR_ADMIN_QUEUE_NO_WORK:
192 		return "IAVF_ERR_ADMIN_QUEUE_NO_WORK";
193 	case IAVF_ERR_BAD_RDMA_CQE:
194 		return "IAVF_ERR_BAD_RDMA_CQE";
195 	case IAVF_ERR_NVM_BLANK_MODE:
196 		return "IAVF_ERR_NVM_BLANK_MODE";
197 	case IAVF_ERR_NOT_IMPLEMENTED:
198 		return "IAVF_ERR_NOT_IMPLEMENTED";
199 	case IAVF_ERR_PE_DOORBELL_NOT_ENABLED:
200 		return "IAVF_ERR_PE_DOORBELL_NOT_ENABLED";
201 	case IAVF_ERR_DIAG_TEST_FAILED:
202 		return "IAVF_ERR_DIAG_TEST_FAILED";
203 	case IAVF_ERR_NOT_READY:
204 		return "IAVF_ERR_NOT_READY";
205 	case IAVF_NOT_SUPPORTED:
206 		return "IAVF_NOT_SUPPORTED";
207 	case IAVF_ERR_FIRMWARE_API_VERSION:
208 		return "IAVF_ERR_FIRMWARE_API_VERSION";
209 	case IAVF_ERR_ADMIN_QUEUE_CRITICAL_ERROR:
210 		return "IAVF_ERR_ADMIN_QUEUE_CRITICAL_ERROR";
211 	}
212 
213 	snprintf(hw->err_str, sizeof(hw->err_str), "%d", stat_err);
214 	return hw->err_str;
215 }
216 
217 /**
218  * iavf_debug_aq
219  * @hw: debug mask related to admin queue
220  * @mask: debug mask
221  * @desc: pointer to admin queue descriptor
222  * @buffer: pointer to command buffer
223  * @buf_len: max length of buffer
224  *
225  * Dumps debug log about adminq command with descriptor contents.
226  **/
227 void iavf_debug_aq(struct iavf_hw *hw, enum iavf_debug_mask mask, void *desc,
228 		   void *buffer, u16 buf_len)
229 {
230 	struct iavf_aq_desc *aq_desc = (struct iavf_aq_desc *)desc;
231 	u8 *buf = (u8 *)buffer;
232 
233 	if ((!(mask & hw->debug_mask)) || !desc)
234 		return;
235 
236 	iavf_debug(hw, mask,
237 		   "AQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n",
238 		   le16_to_cpu(aq_desc->opcode),
239 		   le16_to_cpu(aq_desc->flags),
240 		   le16_to_cpu(aq_desc->datalen),
241 		   le16_to_cpu(aq_desc->retval));
242 	iavf_debug(hw, mask, "\tcookie (h,l) 0x%08X 0x%08X\n",
243 		   le32_to_cpu(aq_desc->cookie_high),
244 		   le32_to_cpu(aq_desc->cookie_low));
245 	iavf_debug(hw, mask, "\tparam (0,1)  0x%08X 0x%08X\n",
246 		   le32_to_cpu(aq_desc->params.internal.param0),
247 		   le32_to_cpu(aq_desc->params.internal.param1));
248 	iavf_debug(hw, mask, "\taddr (h,l)   0x%08X 0x%08X\n",
249 		   le32_to_cpu(aq_desc->params.external.addr_high),
250 		   le32_to_cpu(aq_desc->params.external.addr_low));
251 
252 	if (buffer && aq_desc->datalen) {
253 		u16 len = le16_to_cpu(aq_desc->datalen);
254 
255 		iavf_debug(hw, mask, "AQ CMD Buffer:\n");
256 		if (buf_len < len)
257 			len = buf_len;
258 		/* write the full 16-byte chunks */
259 		if (hw->debug_mask & mask) {
260 			char prefix[27];
261 
262 			snprintf(prefix, sizeof(prefix),
263 				 "iavf %02x:%02x.%x: \t0x",
264 				 hw->bus.bus_id,
265 				 hw->bus.device,
266 				 hw->bus.func);
267 
268 			print_hex_dump(KERN_INFO, prefix, DUMP_PREFIX_OFFSET,
269 				       16, 1, buf, len, false);
270 		}
271 	}
272 }
273 
274 /**
275  * iavf_check_asq_alive
276  * @hw: pointer to the hw struct
277  *
278  * Returns true if Queue is enabled else false.
279  **/
280 bool iavf_check_asq_alive(struct iavf_hw *hw)
281 {
282 	if (hw->aq.asq.len)
283 		return !!(rd32(hw, hw->aq.asq.len) &
284 			  IAVF_VF_ATQLEN1_ATQENABLE_MASK);
285 	else
286 		return false;
287 }
288 
289 /**
290  * iavf_aq_queue_shutdown
291  * @hw: pointer to the hw struct
292  * @unloading: is the driver unloading itself
293  *
294  * Tell the Firmware that we're shutting down the AdminQ and whether
295  * or not the driver is unloading as well.
296  **/
297 enum iavf_status iavf_aq_queue_shutdown(struct iavf_hw *hw, bool unloading)
298 {
299 	struct iavf_aq_desc desc;
300 	struct iavf_aqc_queue_shutdown *cmd =
301 		(struct iavf_aqc_queue_shutdown *)&desc.params.raw;
302 	enum iavf_status status;
303 
304 	iavf_fill_default_direct_cmd_desc(&desc, iavf_aqc_opc_queue_shutdown);
305 
306 	if (unloading)
307 		cmd->driver_unloading = cpu_to_le32(IAVF_AQ_DRIVER_UNLOADING);
308 	status = iavf_asq_send_command(hw, &desc, NULL, 0, NULL);
309 
310 	return status;
311 }
312 
313 /**
314  * iavf_aq_get_set_rss_lut
315  * @hw: pointer to the hardware structure
316  * @vsi_id: vsi fw index
317  * @pf_lut: for PF table set true, for VSI table set false
318  * @lut: pointer to the lut buffer provided by the caller
319  * @lut_size: size of the lut buffer
320  * @set: set true to set the table, false to get the table
321  *
322  * Internal function to get or set RSS look up table
323  **/
324 static enum iavf_status iavf_aq_get_set_rss_lut(struct iavf_hw *hw,
325 						u16 vsi_id, bool pf_lut,
326 						u8 *lut, u16 lut_size,
327 						bool set)
328 {
329 	enum iavf_status status;
330 	struct iavf_aq_desc desc;
331 	struct iavf_aqc_get_set_rss_lut *cmd_resp =
332 		   (struct iavf_aqc_get_set_rss_lut *)&desc.params.raw;
333 
334 	if (set)
335 		iavf_fill_default_direct_cmd_desc(&desc,
336 						  iavf_aqc_opc_set_rss_lut);
337 	else
338 		iavf_fill_default_direct_cmd_desc(&desc,
339 						  iavf_aqc_opc_get_rss_lut);
340 
341 	/* Indirect command */
342 	desc.flags |= cpu_to_le16((u16)IAVF_AQ_FLAG_BUF);
343 	desc.flags |= cpu_to_le16((u16)IAVF_AQ_FLAG_RD);
344 
345 	cmd_resp->vsi_id =
346 			cpu_to_le16((u16)((vsi_id <<
347 					  IAVF_AQC_SET_RSS_LUT_VSI_ID_SHIFT) &
348 					  IAVF_AQC_SET_RSS_LUT_VSI_ID_MASK));
349 	cmd_resp->vsi_id |= cpu_to_le16((u16)IAVF_AQC_SET_RSS_LUT_VSI_VALID);
350 
351 	if (pf_lut)
352 		cmd_resp->flags |= cpu_to_le16((u16)
353 					((IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_PF <<
354 					IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) &
355 					IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_MASK));
356 	else
357 		cmd_resp->flags |= cpu_to_le16((u16)
358 					((IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_VSI <<
359 					IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) &
360 					IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_MASK));
361 
362 	status = iavf_asq_send_command(hw, &desc, lut, lut_size, NULL);
363 
364 	return status;
365 }
366 
367 /**
368  * iavf_aq_set_rss_lut
369  * @hw: pointer to the hardware structure
370  * @vsi_id: vsi fw index
371  * @pf_lut: for PF table set true, for VSI table set false
372  * @lut: pointer to the lut buffer provided by the caller
373  * @lut_size: size of the lut buffer
374  *
375  * set the RSS lookup table, PF or VSI type
376  **/
377 enum iavf_status iavf_aq_set_rss_lut(struct iavf_hw *hw, u16 vsi_id,
378 				     bool pf_lut, u8 *lut, u16 lut_size)
379 {
380 	return iavf_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size, true);
381 }
382 
383 /**
384  * iavf_aq_get_set_rss_key
385  * @hw: pointer to the hw struct
386  * @vsi_id: vsi fw index
387  * @key: pointer to key info struct
388  * @set: set true to set the key, false to get the key
389  *
390  * get the RSS key per VSI
391  **/
392 static enum
393 iavf_status iavf_aq_get_set_rss_key(struct iavf_hw *hw, u16 vsi_id,
394 				    struct iavf_aqc_get_set_rss_key_data *key,
395 				    bool set)
396 {
397 	enum iavf_status status;
398 	struct iavf_aq_desc desc;
399 	struct iavf_aqc_get_set_rss_key *cmd_resp =
400 			(struct iavf_aqc_get_set_rss_key *)&desc.params.raw;
401 	u16 key_size = sizeof(struct iavf_aqc_get_set_rss_key_data);
402 
403 	if (set)
404 		iavf_fill_default_direct_cmd_desc(&desc,
405 						  iavf_aqc_opc_set_rss_key);
406 	else
407 		iavf_fill_default_direct_cmd_desc(&desc,
408 						  iavf_aqc_opc_get_rss_key);
409 
410 	/* Indirect command */
411 	desc.flags |= cpu_to_le16((u16)IAVF_AQ_FLAG_BUF);
412 	desc.flags |= cpu_to_le16((u16)IAVF_AQ_FLAG_RD);
413 
414 	cmd_resp->vsi_id =
415 			cpu_to_le16((u16)((vsi_id <<
416 					  IAVF_AQC_SET_RSS_KEY_VSI_ID_SHIFT) &
417 					  IAVF_AQC_SET_RSS_KEY_VSI_ID_MASK));
418 	cmd_resp->vsi_id |= cpu_to_le16((u16)IAVF_AQC_SET_RSS_KEY_VSI_VALID);
419 
420 	status = iavf_asq_send_command(hw, &desc, key, key_size, NULL);
421 
422 	return status;
423 }
424 
425 /**
426  * iavf_aq_set_rss_key
427  * @hw: pointer to the hw struct
428  * @vsi_id: vsi fw index
429  * @key: pointer to key info struct
430  *
431  * set the RSS key per VSI
432  **/
433 enum iavf_status iavf_aq_set_rss_key(struct iavf_hw *hw, u16 vsi_id,
434 				     struct iavf_aqc_get_set_rss_key_data *key)
435 {
436 	return iavf_aq_get_set_rss_key(hw, vsi_id, key, true);
437 }
438 
439 /* The iavf_ptype_lookup table is used to convert from the 8-bit ptype in the
440  * hardware to a bit-field that can be used by SW to more easily determine the
441  * packet type.
442  *
443  * Macros are used to shorten the table lines and make this table human
444  * readable.
445  *
446  * We store the PTYPE in the top byte of the bit field - this is just so that
447  * we can check that the table doesn't have a row missing, as the index into
448  * the table should be the PTYPE.
449  *
450  * Typical work flow:
451  *
452  * IF NOT iavf_ptype_lookup[ptype].known
453  * THEN
454  *      Packet is unknown
455  * ELSE IF iavf_ptype_lookup[ptype].outer_ip == IAVF_RX_PTYPE_OUTER_IP
456  *      Use the rest of the fields to look at the tunnels, inner protocols, etc
457  * ELSE
458  *      Use the enum iavf_rx_l2_ptype to decode the packet type
459  * ENDIF
460  */
461 
462 /* macro to make the table lines short, use explicit indexing with [PTYPE] */
463 #define IAVF_PTT(PTYPE, OUTER_IP, OUTER_IP_VER, OUTER_FRAG, T, TE, TEF, I, PL)\
464 	[PTYPE] = { \
465 		1, \
466 		IAVF_RX_PTYPE_OUTER_##OUTER_IP, \
467 		IAVF_RX_PTYPE_OUTER_##OUTER_IP_VER, \
468 		IAVF_RX_PTYPE_##OUTER_FRAG, \
469 		IAVF_RX_PTYPE_TUNNEL_##T, \
470 		IAVF_RX_PTYPE_TUNNEL_END_##TE, \
471 		IAVF_RX_PTYPE_##TEF, \
472 		IAVF_RX_PTYPE_INNER_PROT_##I, \
473 		IAVF_RX_PTYPE_PAYLOAD_LAYER_##PL }
474 
475 #define IAVF_PTT_UNUSED_ENTRY(PTYPE) [PTYPE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }
476 
477 /* shorter macros makes the table fit but are terse */
478 #define IAVF_RX_PTYPE_NOF		IAVF_RX_PTYPE_NOT_FRAG
479 #define IAVF_RX_PTYPE_FRG		IAVF_RX_PTYPE_FRAG
480 #define IAVF_RX_PTYPE_INNER_PROT_TS	IAVF_RX_PTYPE_INNER_PROT_TIMESYNC
481 
482 /* Lookup table mapping the 8-bit HW PTYPE to the bit field for decoding */
483 struct iavf_rx_ptype_decoded iavf_ptype_lookup[BIT(8)] = {
484 	/* L2 Packet types */
485 	IAVF_PTT_UNUSED_ENTRY(0),
486 	IAVF_PTT(1,  L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
487 	IAVF_PTT(2,  L2, NONE, NOF, NONE, NONE, NOF, TS,   PAY2),
488 	IAVF_PTT(3,  L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
489 	IAVF_PTT_UNUSED_ENTRY(4),
490 	IAVF_PTT_UNUSED_ENTRY(5),
491 	IAVF_PTT(6,  L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
492 	IAVF_PTT(7,  L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
493 	IAVF_PTT_UNUSED_ENTRY(8),
494 	IAVF_PTT_UNUSED_ENTRY(9),
495 	IAVF_PTT(10, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
496 	IAVF_PTT(11, L2, NONE, NOF, NONE, NONE, NOF, NONE, NONE),
497 	IAVF_PTT(12, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
498 	IAVF_PTT(13, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
499 	IAVF_PTT(14, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
500 	IAVF_PTT(15, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
501 	IAVF_PTT(16, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
502 	IAVF_PTT(17, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
503 	IAVF_PTT(18, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
504 	IAVF_PTT(19, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
505 	IAVF_PTT(20, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
506 	IAVF_PTT(21, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
507 
508 	/* Non Tunneled IPv4 */
509 	IAVF_PTT(22, IP, IPV4, FRG, NONE, NONE, NOF, NONE, PAY3),
510 	IAVF_PTT(23, IP, IPV4, NOF, NONE, NONE, NOF, NONE, PAY3),
511 	IAVF_PTT(24, IP, IPV4, NOF, NONE, NONE, NOF, UDP,  PAY4),
512 	IAVF_PTT_UNUSED_ENTRY(25),
513 	IAVF_PTT(26, IP, IPV4, NOF, NONE, NONE, NOF, TCP,  PAY4),
514 	IAVF_PTT(27, IP, IPV4, NOF, NONE, NONE, NOF, SCTP, PAY4),
515 	IAVF_PTT(28, IP, IPV4, NOF, NONE, NONE, NOF, ICMP, PAY4),
516 
517 	/* IPv4 --> IPv4 */
518 	IAVF_PTT(29, IP, IPV4, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
519 	IAVF_PTT(30, IP, IPV4, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
520 	IAVF_PTT(31, IP, IPV4, NOF, IP_IP, IPV4, NOF, UDP,  PAY4),
521 	IAVF_PTT_UNUSED_ENTRY(32),
522 	IAVF_PTT(33, IP, IPV4, NOF, IP_IP, IPV4, NOF, TCP,  PAY4),
523 	IAVF_PTT(34, IP, IPV4, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
524 	IAVF_PTT(35, IP, IPV4, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
525 
526 	/* IPv4 --> IPv6 */
527 	IAVF_PTT(36, IP, IPV4, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
528 	IAVF_PTT(37, IP, IPV4, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
529 	IAVF_PTT(38, IP, IPV4, NOF, IP_IP, IPV6, NOF, UDP,  PAY4),
530 	IAVF_PTT_UNUSED_ENTRY(39),
531 	IAVF_PTT(40, IP, IPV4, NOF, IP_IP, IPV6, NOF, TCP,  PAY4),
532 	IAVF_PTT(41, IP, IPV4, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
533 	IAVF_PTT(42, IP, IPV4, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
534 
535 	/* IPv4 --> GRE/NAT */
536 	IAVF_PTT(43, IP, IPV4, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
537 
538 	/* IPv4 --> GRE/NAT --> IPv4 */
539 	IAVF_PTT(44, IP, IPV4, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
540 	IAVF_PTT(45, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
541 	IAVF_PTT(46, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, UDP,  PAY4),
542 	IAVF_PTT_UNUSED_ENTRY(47),
543 	IAVF_PTT(48, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, TCP,  PAY4),
544 	IAVF_PTT(49, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
545 	IAVF_PTT(50, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
546 
547 	/* IPv4 --> GRE/NAT --> IPv6 */
548 	IAVF_PTT(51, IP, IPV4, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
549 	IAVF_PTT(52, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
550 	IAVF_PTT(53, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, UDP,  PAY4),
551 	IAVF_PTT_UNUSED_ENTRY(54),
552 	IAVF_PTT(55, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, TCP,  PAY4),
553 	IAVF_PTT(56, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
554 	IAVF_PTT(57, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
555 
556 	/* IPv4 --> GRE/NAT --> MAC */
557 	IAVF_PTT(58, IP, IPV4, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
558 
559 	/* IPv4 --> GRE/NAT --> MAC --> IPv4 */
560 	IAVF_PTT(59, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
561 	IAVF_PTT(60, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
562 	IAVF_PTT(61, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP,  PAY4),
563 	IAVF_PTT_UNUSED_ENTRY(62),
564 	IAVF_PTT(63, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP,  PAY4),
565 	IAVF_PTT(64, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
566 	IAVF_PTT(65, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
567 
568 	/* IPv4 --> GRE/NAT -> MAC --> IPv6 */
569 	IAVF_PTT(66, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
570 	IAVF_PTT(67, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
571 	IAVF_PTT(68, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP,  PAY4),
572 	IAVF_PTT_UNUSED_ENTRY(69),
573 	IAVF_PTT(70, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP,  PAY4),
574 	IAVF_PTT(71, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
575 	IAVF_PTT(72, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
576 
577 	/* IPv4 --> GRE/NAT --> MAC/VLAN */
578 	IAVF_PTT(73, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
579 
580 	/* IPv4 ---> GRE/NAT -> MAC/VLAN --> IPv4 */
581 	IAVF_PTT(74, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
582 	IAVF_PTT(75, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
583 	IAVF_PTT(76, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP,  PAY4),
584 	IAVF_PTT_UNUSED_ENTRY(77),
585 	IAVF_PTT(78, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP,  PAY4),
586 	IAVF_PTT(79, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
587 	IAVF_PTT(80, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
588 
589 	/* IPv4 -> GRE/NAT -> MAC/VLAN --> IPv6 */
590 	IAVF_PTT(81, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
591 	IAVF_PTT(82, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
592 	IAVF_PTT(83, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP,  PAY4),
593 	IAVF_PTT_UNUSED_ENTRY(84),
594 	IAVF_PTT(85, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP,  PAY4),
595 	IAVF_PTT(86, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
596 	IAVF_PTT(87, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
597 
598 	/* Non Tunneled IPv6 */
599 	IAVF_PTT(88, IP, IPV6, FRG, NONE, NONE, NOF, NONE, PAY3),
600 	IAVF_PTT(89, IP, IPV6, NOF, NONE, NONE, NOF, NONE, PAY3),
601 	IAVF_PTT(90, IP, IPV6, NOF, NONE, NONE, NOF, UDP,  PAY4),
602 	IAVF_PTT_UNUSED_ENTRY(91),
603 	IAVF_PTT(92, IP, IPV6, NOF, NONE, NONE, NOF, TCP,  PAY4),
604 	IAVF_PTT(93, IP, IPV6, NOF, NONE, NONE, NOF, SCTP, PAY4),
605 	IAVF_PTT(94, IP, IPV6, NOF, NONE, NONE, NOF, ICMP, PAY4),
606 
607 	/* IPv6 --> IPv4 */
608 	IAVF_PTT(95,  IP, IPV6, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
609 	IAVF_PTT(96,  IP, IPV6, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
610 	IAVF_PTT(97,  IP, IPV6, NOF, IP_IP, IPV4, NOF, UDP,  PAY4),
611 	IAVF_PTT_UNUSED_ENTRY(98),
612 	IAVF_PTT(99,  IP, IPV6, NOF, IP_IP, IPV4, NOF, TCP,  PAY4),
613 	IAVF_PTT(100, IP, IPV6, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
614 	IAVF_PTT(101, IP, IPV6, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
615 
616 	/* IPv6 --> IPv6 */
617 	IAVF_PTT(102, IP, IPV6, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
618 	IAVF_PTT(103, IP, IPV6, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
619 	IAVF_PTT(104, IP, IPV6, NOF, IP_IP, IPV6, NOF, UDP,  PAY4),
620 	IAVF_PTT_UNUSED_ENTRY(105),
621 	IAVF_PTT(106, IP, IPV6, NOF, IP_IP, IPV6, NOF, TCP,  PAY4),
622 	IAVF_PTT(107, IP, IPV6, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
623 	IAVF_PTT(108, IP, IPV6, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
624 
625 	/* IPv6 --> GRE/NAT */
626 	IAVF_PTT(109, IP, IPV6, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
627 
628 	/* IPv6 --> GRE/NAT -> IPv4 */
629 	IAVF_PTT(110, IP, IPV6, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
630 	IAVF_PTT(111, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
631 	IAVF_PTT(112, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, UDP,  PAY4),
632 	IAVF_PTT_UNUSED_ENTRY(113),
633 	IAVF_PTT(114, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, TCP,  PAY4),
634 	IAVF_PTT(115, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
635 	IAVF_PTT(116, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
636 
637 	/* IPv6 --> GRE/NAT -> IPv6 */
638 	IAVF_PTT(117, IP, IPV6, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
639 	IAVF_PTT(118, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
640 	IAVF_PTT(119, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, UDP,  PAY4),
641 	IAVF_PTT_UNUSED_ENTRY(120),
642 	IAVF_PTT(121, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, TCP,  PAY4),
643 	IAVF_PTT(122, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
644 	IAVF_PTT(123, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
645 
646 	/* IPv6 --> GRE/NAT -> MAC */
647 	IAVF_PTT(124, IP, IPV6, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
648 
649 	/* IPv6 --> GRE/NAT -> MAC -> IPv4 */
650 	IAVF_PTT(125, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
651 	IAVF_PTT(126, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
652 	IAVF_PTT(127, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP,  PAY4),
653 	IAVF_PTT_UNUSED_ENTRY(128),
654 	IAVF_PTT(129, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP,  PAY4),
655 	IAVF_PTT(130, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
656 	IAVF_PTT(131, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
657 
658 	/* IPv6 --> GRE/NAT -> MAC -> IPv6 */
659 	IAVF_PTT(132, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
660 	IAVF_PTT(133, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
661 	IAVF_PTT(134, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP,  PAY4),
662 	IAVF_PTT_UNUSED_ENTRY(135),
663 	IAVF_PTT(136, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP,  PAY4),
664 	IAVF_PTT(137, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
665 	IAVF_PTT(138, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
666 
667 	/* IPv6 --> GRE/NAT -> MAC/VLAN */
668 	IAVF_PTT(139, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
669 
670 	/* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv4 */
671 	IAVF_PTT(140, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
672 	IAVF_PTT(141, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
673 	IAVF_PTT(142, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP,  PAY4),
674 	IAVF_PTT_UNUSED_ENTRY(143),
675 	IAVF_PTT(144, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP,  PAY4),
676 	IAVF_PTT(145, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
677 	IAVF_PTT(146, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
678 
679 	/* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv6 */
680 	IAVF_PTT(147, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
681 	IAVF_PTT(148, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
682 	IAVF_PTT(149, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP,  PAY4),
683 	IAVF_PTT_UNUSED_ENTRY(150),
684 	IAVF_PTT(151, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP,  PAY4),
685 	IAVF_PTT(152, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
686 	IAVF_PTT(153, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
687 
688 	/* unused entries */
689 	[154 ... 255] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }
690 };
691 
692 /**
693  * iavf_aq_send_msg_to_pf
694  * @hw: pointer to the hardware structure
695  * @v_opcode: opcodes for VF-PF communication
696  * @v_retval: return error code
697  * @msg: pointer to the msg buffer
698  * @msglen: msg length
699  * @cmd_details: pointer to command details
700  *
701  * Send message to PF driver using admin queue. By default, this message
702  * is sent asynchronously, i.e. iavf_asq_send_command() does not wait for
703  * completion before returning.
704  **/
705 enum iavf_status iavf_aq_send_msg_to_pf(struct iavf_hw *hw,
706 					enum virtchnl_ops v_opcode,
707 					enum iavf_status v_retval,
708 					u8 *msg, u16 msglen,
709 					struct iavf_asq_cmd_details *cmd_details)
710 {
711 	struct iavf_asq_cmd_details details;
712 	struct iavf_aq_desc desc;
713 	enum iavf_status status;
714 
715 	iavf_fill_default_direct_cmd_desc(&desc, iavf_aqc_opc_send_msg_to_pf);
716 	desc.flags |= cpu_to_le16((u16)IAVF_AQ_FLAG_SI);
717 	desc.cookie_high = cpu_to_le32(v_opcode);
718 	desc.cookie_low = cpu_to_le32(v_retval);
719 	if (msglen) {
720 		desc.flags |= cpu_to_le16((u16)(IAVF_AQ_FLAG_BUF
721 						| IAVF_AQ_FLAG_RD));
722 		if (msglen > IAVF_AQ_LARGE_BUF)
723 			desc.flags |= cpu_to_le16((u16)IAVF_AQ_FLAG_LB);
724 		desc.datalen = cpu_to_le16(msglen);
725 	}
726 	if (!cmd_details) {
727 		memset(&details, 0, sizeof(details));
728 		details.async = true;
729 		cmd_details = &details;
730 	}
731 	status = iavf_asq_send_command(hw, &desc, msg, msglen, cmd_details);
732 	return status;
733 }
734 
735 /**
736  * iavf_vf_parse_hw_config
737  * @hw: pointer to the hardware structure
738  * @msg: pointer to the virtual channel VF resource structure
739  *
740  * Given a VF resource message from the PF, populate the hw struct
741  * with appropriate information.
742  **/
743 void iavf_vf_parse_hw_config(struct iavf_hw *hw,
744 			     struct virtchnl_vf_resource *msg)
745 {
746 	struct virtchnl_vsi_resource *vsi_res;
747 	int i;
748 
749 	vsi_res = &msg->vsi_res[0];
750 
751 	hw->dev_caps.num_vsis = msg->num_vsis;
752 	hw->dev_caps.num_rx_qp = msg->num_queue_pairs;
753 	hw->dev_caps.num_tx_qp = msg->num_queue_pairs;
754 	hw->dev_caps.num_msix_vectors_vf = msg->max_vectors;
755 	hw->dev_caps.dcb = msg->vf_cap_flags &
756 			   VIRTCHNL_VF_OFFLOAD_L2;
757 	hw->dev_caps.fcoe = 0;
758 	for (i = 0; i < msg->num_vsis; i++) {
759 		if (vsi_res->vsi_type == VIRTCHNL_VSI_SRIOV) {
760 			ether_addr_copy(hw->mac.perm_addr,
761 					vsi_res->default_mac_addr);
762 			ether_addr_copy(hw->mac.addr,
763 					vsi_res->default_mac_addr);
764 		}
765 		vsi_res++;
766 	}
767 }
768