1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* Copyright (c) 2021, Intel Corporation 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * 3. Neither the name of the Intel Corporation nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 /*$FreeBSD$*/ 32 33 #include "iavf_type.h" 34 #include "iavf_adminq.h" 35 #include "iavf_prototype.h" 36 #include "virtchnl.h" 37 38 /** 39 * iavf_set_mac_type - Sets MAC type 40 * @hw: pointer to the HW structure 41 * 42 * This function sets the mac type of the adapter based on the 43 * vendor ID and device ID stored in the hw structure. 44 **/ 45 enum iavf_status iavf_set_mac_type(struct iavf_hw *hw) 46 { 47 enum iavf_status status = IAVF_SUCCESS; 48 49 DEBUGFUNC("iavf_set_mac_type\n"); 50 51 if (hw->vendor_id == IAVF_INTEL_VENDOR_ID) { 52 switch (hw->device_id) { 53 case IAVF_DEV_ID_X722_VF: 54 hw->mac.type = IAVF_MAC_X722_VF; 55 break; 56 case IAVF_DEV_ID_VF: 57 case IAVF_DEV_ID_VF_HV: 58 case IAVF_DEV_ID_ADAPTIVE_VF: 59 hw->mac.type = IAVF_MAC_VF; 60 break; 61 default: 62 hw->mac.type = IAVF_MAC_GENERIC; 63 break; 64 } 65 } else { 66 status = IAVF_ERR_DEVICE_NOT_SUPPORTED; 67 } 68 69 DEBUGOUT2("iavf_set_mac_type found mac: %d, returns: %d\n", 70 hw->mac.type, status); 71 return status; 72 } 73 74 /** 75 * iavf_aq_str - convert AQ err code to a string 76 * @hw: pointer to the HW structure 77 * @aq_err: the AQ error code to convert 78 **/ 79 const char *iavf_aq_str(struct iavf_hw *hw, enum iavf_admin_queue_err aq_err) 80 { 81 switch (aq_err) { 82 case IAVF_AQ_RC_OK: 83 return "OK"; 84 case IAVF_AQ_RC_EPERM: 85 return "IAVF_AQ_RC_EPERM"; 86 case IAVF_AQ_RC_ENOENT: 87 return "IAVF_AQ_RC_ENOENT"; 88 case IAVF_AQ_RC_ESRCH: 89 return "IAVF_AQ_RC_ESRCH"; 90 case IAVF_AQ_RC_EINTR: 91 return "IAVF_AQ_RC_EINTR"; 92 case IAVF_AQ_RC_EIO: 93 return "IAVF_AQ_RC_EIO"; 94 case IAVF_AQ_RC_ENXIO: 95 return "IAVF_AQ_RC_ENXIO"; 96 case IAVF_AQ_RC_E2BIG: 97 return "IAVF_AQ_RC_E2BIG"; 98 case IAVF_AQ_RC_EAGAIN: 99 return "IAVF_AQ_RC_EAGAIN"; 100 case IAVF_AQ_RC_ENOMEM: 101 return "IAVF_AQ_RC_ENOMEM"; 102 case IAVF_AQ_RC_EACCES: 103 return "IAVF_AQ_RC_EACCES"; 104 case IAVF_AQ_RC_EFAULT: 105 return "IAVF_AQ_RC_EFAULT"; 106 case IAVF_AQ_RC_EBUSY: 107 return "IAVF_AQ_RC_EBUSY"; 108 case IAVF_AQ_RC_EEXIST: 109 return "IAVF_AQ_RC_EEXIST"; 110 case IAVF_AQ_RC_EINVAL: 111 return "IAVF_AQ_RC_EINVAL"; 112 case IAVF_AQ_RC_ENOTTY: 113 return "IAVF_AQ_RC_ENOTTY"; 114 case IAVF_AQ_RC_ENOSPC: 115 return "IAVF_AQ_RC_ENOSPC"; 116 case IAVF_AQ_RC_ENOSYS: 117 return "IAVF_AQ_RC_ENOSYS"; 118 case IAVF_AQ_RC_ERANGE: 119 return "IAVF_AQ_RC_ERANGE"; 120 case IAVF_AQ_RC_EFLUSHED: 121 return "IAVF_AQ_RC_EFLUSHED"; 122 case IAVF_AQ_RC_BAD_ADDR: 123 return "IAVF_AQ_RC_BAD_ADDR"; 124 case IAVF_AQ_RC_EMODE: 125 return "IAVF_AQ_RC_EMODE"; 126 case IAVF_AQ_RC_EFBIG: 127 return "IAVF_AQ_RC_EFBIG"; 128 } 129 130 snprintf(hw->err_str, sizeof(hw->err_str), "%d", aq_err); 131 return hw->err_str; 132 } 133 134 /** 135 * iavf_stat_str - convert status err code to a string 136 * @hw: pointer to the HW structure 137 * @stat_err: the status error code to convert 138 **/ 139 const char *iavf_stat_str(struct iavf_hw *hw, enum iavf_status stat_err) 140 { 141 switch (stat_err) { 142 case IAVF_SUCCESS: 143 return "OK"; 144 case IAVF_ERR_NVM: 145 return "IAVF_ERR_NVM"; 146 case IAVF_ERR_NVM_CHECKSUM: 147 return "IAVF_ERR_NVM_CHECKSUM"; 148 case IAVF_ERR_PHY: 149 return "IAVF_ERR_PHY"; 150 case IAVF_ERR_CONFIG: 151 return "IAVF_ERR_CONFIG"; 152 case IAVF_ERR_PARAM: 153 return "IAVF_ERR_PARAM"; 154 case IAVF_ERR_MAC_TYPE: 155 return "IAVF_ERR_MAC_TYPE"; 156 case IAVF_ERR_UNKNOWN_PHY: 157 return "IAVF_ERR_UNKNOWN_PHY"; 158 case IAVF_ERR_LINK_SETUP: 159 return "IAVF_ERR_LINK_SETUP"; 160 case IAVF_ERR_ADAPTER_STOPPED: 161 return "IAVF_ERR_ADAPTER_STOPPED"; 162 case IAVF_ERR_INVALID_MAC_ADDR: 163 return "IAVF_ERR_INVALID_MAC_ADDR"; 164 case IAVF_ERR_DEVICE_NOT_SUPPORTED: 165 return "IAVF_ERR_DEVICE_NOT_SUPPORTED"; 166 case IAVF_ERR_MASTER_REQUESTS_PENDING: 167 return "IAVF_ERR_MASTER_REQUESTS_PENDING"; 168 case IAVF_ERR_INVALID_LINK_SETTINGS: 169 return "IAVF_ERR_INVALID_LINK_SETTINGS"; 170 case IAVF_ERR_AUTONEG_NOT_COMPLETE: 171 return "IAVF_ERR_AUTONEG_NOT_COMPLETE"; 172 case IAVF_ERR_RESET_FAILED: 173 return "IAVF_ERR_RESET_FAILED"; 174 case IAVF_ERR_SWFW_SYNC: 175 return "IAVF_ERR_SWFW_SYNC"; 176 case IAVF_ERR_NO_AVAILABLE_VSI: 177 return "IAVF_ERR_NO_AVAILABLE_VSI"; 178 case IAVF_ERR_NO_MEMORY: 179 return "IAVF_ERR_NO_MEMORY"; 180 case IAVF_ERR_BAD_PTR: 181 return "IAVF_ERR_BAD_PTR"; 182 case IAVF_ERR_RING_FULL: 183 return "IAVF_ERR_RING_FULL"; 184 case IAVF_ERR_INVALID_PD_ID: 185 return "IAVF_ERR_INVALID_PD_ID"; 186 case IAVF_ERR_INVALID_QP_ID: 187 return "IAVF_ERR_INVALID_QP_ID"; 188 case IAVF_ERR_INVALID_CQ_ID: 189 return "IAVF_ERR_INVALID_CQ_ID"; 190 case IAVF_ERR_INVALID_CEQ_ID: 191 return "IAVF_ERR_INVALID_CEQ_ID"; 192 case IAVF_ERR_INVALID_AEQ_ID: 193 return "IAVF_ERR_INVALID_AEQ_ID"; 194 case IAVF_ERR_INVALID_SIZE: 195 return "IAVF_ERR_INVALID_SIZE"; 196 case IAVF_ERR_INVALID_ARP_INDEX: 197 return "IAVF_ERR_INVALID_ARP_INDEX"; 198 case IAVF_ERR_INVALID_FPM_FUNC_ID: 199 return "IAVF_ERR_INVALID_FPM_FUNC_ID"; 200 case IAVF_ERR_QP_INVALID_MSG_SIZE: 201 return "IAVF_ERR_QP_INVALID_MSG_SIZE"; 202 case IAVF_ERR_QP_TOOMANY_WRS_POSTED: 203 return "IAVF_ERR_QP_TOOMANY_WRS_POSTED"; 204 case IAVF_ERR_INVALID_FRAG_COUNT: 205 return "IAVF_ERR_INVALID_FRAG_COUNT"; 206 case IAVF_ERR_QUEUE_EMPTY: 207 return "IAVF_ERR_QUEUE_EMPTY"; 208 case IAVF_ERR_INVALID_ALIGNMENT: 209 return "IAVF_ERR_INVALID_ALIGNMENT"; 210 case IAVF_ERR_FLUSHED_QUEUE: 211 return "IAVF_ERR_FLUSHED_QUEUE"; 212 case IAVF_ERR_INVALID_PUSH_PAGE_INDEX: 213 return "IAVF_ERR_INVALID_PUSH_PAGE_INDEX"; 214 case IAVF_ERR_INVALID_IMM_DATA_SIZE: 215 return "IAVF_ERR_INVALID_IMM_DATA_SIZE"; 216 case IAVF_ERR_TIMEOUT: 217 return "IAVF_ERR_TIMEOUT"; 218 case IAVF_ERR_OPCODE_MISMATCH: 219 return "IAVF_ERR_OPCODE_MISMATCH"; 220 case IAVF_ERR_CQP_COMPL_ERROR: 221 return "IAVF_ERR_CQP_COMPL_ERROR"; 222 case IAVF_ERR_INVALID_VF_ID: 223 return "IAVF_ERR_INVALID_VF_ID"; 224 case IAVF_ERR_INVALID_HMCFN_ID: 225 return "IAVF_ERR_INVALID_HMCFN_ID"; 226 case IAVF_ERR_BACKING_PAGE_ERROR: 227 return "IAVF_ERR_BACKING_PAGE_ERROR"; 228 case IAVF_ERR_NO_PBLCHUNKS_AVAILABLE: 229 return "IAVF_ERR_NO_PBLCHUNKS_AVAILABLE"; 230 case IAVF_ERR_INVALID_PBLE_INDEX: 231 return "IAVF_ERR_INVALID_PBLE_INDEX"; 232 case IAVF_ERR_INVALID_SD_INDEX: 233 return "IAVF_ERR_INVALID_SD_INDEX"; 234 case IAVF_ERR_INVALID_PAGE_DESC_INDEX: 235 return "IAVF_ERR_INVALID_PAGE_DESC_INDEX"; 236 case IAVF_ERR_INVALID_SD_TYPE: 237 return "IAVF_ERR_INVALID_SD_TYPE"; 238 case IAVF_ERR_MEMCPY_FAILED: 239 return "IAVF_ERR_MEMCPY_FAILED"; 240 case IAVF_ERR_INVALID_HMC_OBJ_INDEX: 241 return "IAVF_ERR_INVALID_HMC_OBJ_INDEX"; 242 case IAVF_ERR_INVALID_HMC_OBJ_COUNT: 243 return "IAVF_ERR_INVALID_HMC_OBJ_COUNT"; 244 case IAVF_ERR_INVALID_SRQ_ARM_LIMIT: 245 return "IAVF_ERR_INVALID_SRQ_ARM_LIMIT"; 246 case IAVF_ERR_SRQ_ENABLED: 247 return "IAVF_ERR_SRQ_ENABLED"; 248 case IAVF_ERR_ADMIN_QUEUE_ERROR: 249 return "IAVF_ERR_ADMIN_QUEUE_ERROR"; 250 case IAVF_ERR_ADMIN_QUEUE_TIMEOUT: 251 return "IAVF_ERR_ADMIN_QUEUE_TIMEOUT"; 252 case IAVF_ERR_BUF_TOO_SHORT: 253 return "IAVF_ERR_BUF_TOO_SHORT"; 254 case IAVF_ERR_ADMIN_QUEUE_FULL: 255 return "IAVF_ERR_ADMIN_QUEUE_FULL"; 256 case IAVF_ERR_ADMIN_QUEUE_NO_WORK: 257 return "IAVF_ERR_ADMIN_QUEUE_NO_WORK"; 258 case IAVF_ERR_BAD_IWARP_CQE: 259 return "IAVF_ERR_BAD_IWARP_CQE"; 260 case IAVF_ERR_NVM_BLANK_MODE: 261 return "IAVF_ERR_NVM_BLANK_MODE"; 262 case IAVF_ERR_NOT_IMPLEMENTED: 263 return "IAVF_ERR_NOT_IMPLEMENTED"; 264 case IAVF_ERR_PE_DOORBELL_NOT_ENABLED: 265 return "IAVF_ERR_PE_DOORBELL_NOT_ENABLED"; 266 case IAVF_ERR_DIAG_TEST_FAILED: 267 return "IAVF_ERR_DIAG_TEST_FAILED"; 268 case IAVF_ERR_NOT_READY: 269 return "IAVF_ERR_NOT_READY"; 270 case IAVF_NOT_SUPPORTED: 271 return "IAVF_NOT_SUPPORTED"; 272 case IAVF_ERR_FIRMWARE_API_VERSION: 273 return "IAVF_ERR_FIRMWARE_API_VERSION"; 274 case IAVF_ERR_ADMIN_QUEUE_CRITICAL_ERROR: 275 return "IAVF_ERR_ADMIN_QUEUE_CRITICAL_ERROR"; 276 } 277 278 snprintf(hw->err_str, sizeof(hw->err_str), "%d", stat_err); 279 return hw->err_str; 280 } 281 282 /** 283 * iavf_debug_aq 284 * @hw: debug mask related to admin queue 285 * @mask: debug mask 286 * @desc: pointer to admin queue descriptor 287 * @buffer: pointer to command buffer 288 * @buf_len: max length of buffer 289 * 290 * Dumps debug log about adminq command with descriptor contents. 291 **/ 292 void iavf_debug_aq(struct iavf_hw *hw, enum iavf_debug_mask mask, void *desc, 293 void *buffer, u16 buf_len) 294 { 295 struct iavf_aq_desc *aq_desc = (struct iavf_aq_desc *)desc; 296 u8 *buf = (u8 *)buffer; 297 u16 len; 298 u16 i = 0; 299 300 if ((!(mask & hw->debug_mask)) || (desc == NULL)) 301 return; 302 303 len = LE16_TO_CPU(aq_desc->datalen); 304 305 iavf_debug(hw, mask, 306 "AQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n", 307 LE16_TO_CPU(aq_desc->opcode), 308 LE16_TO_CPU(aq_desc->flags), 309 LE16_TO_CPU(aq_desc->datalen), 310 LE16_TO_CPU(aq_desc->retval)); 311 iavf_debug(hw, mask, "\tcookie (h,l) 0x%08X 0x%08X\n", 312 LE32_TO_CPU(aq_desc->cookie_high), 313 LE32_TO_CPU(aq_desc->cookie_low)); 314 iavf_debug(hw, mask, "\tparam (0,1) 0x%08X 0x%08X\n", 315 LE32_TO_CPU(aq_desc->params.internal.param0), 316 LE32_TO_CPU(aq_desc->params.internal.param1)); 317 iavf_debug(hw, mask, "\taddr (h,l) 0x%08X 0x%08X\n", 318 LE32_TO_CPU(aq_desc->params.external.addr_high), 319 LE32_TO_CPU(aq_desc->params.external.addr_low)); 320 321 if ((buffer != NULL) && (aq_desc->datalen != 0)) { 322 iavf_debug(hw, mask, "AQ CMD Buffer:\n"); 323 if (buf_len < len) 324 len = buf_len; 325 /* write the full 16-byte chunks */ 326 for (i = 0; i < (len - 16); i += 16) 327 iavf_debug(hw, mask, 328 "\t0x%04X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", 329 i, buf[i], buf[i+1], buf[i+2], buf[i+3], 330 buf[i+4], buf[i+5], buf[i+6], buf[i+7], 331 buf[i+8], buf[i+9], buf[i+10], buf[i+11], 332 buf[i+12], buf[i+13], buf[i+14], buf[i+15]); 333 /* the most we could have left is 16 bytes, pad with zeros */ 334 if (i < len) { 335 char d_buf[16]; 336 int j, i_sav; 337 338 i_sav = i; 339 memset(d_buf, 0, sizeof(d_buf)); 340 for (j = 0; i < len; j++, i++) 341 d_buf[j] = buf[i]; 342 iavf_debug(hw, mask, 343 "\t0x%04X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", 344 i_sav, d_buf[0], d_buf[1], d_buf[2], d_buf[3], 345 d_buf[4], d_buf[5], d_buf[6], d_buf[7], 346 d_buf[8], d_buf[9], d_buf[10], d_buf[11], 347 d_buf[12], d_buf[13], d_buf[14], d_buf[15]); 348 } 349 } 350 } 351 352 /** 353 * iavf_check_asq_alive 354 * @hw: pointer to the hw struct 355 * 356 * Returns true if Queue is enabled else false. 357 **/ 358 bool iavf_check_asq_alive(struct iavf_hw *hw) 359 { 360 if (hw->aq.asq.len) 361 return !!(rd32(hw, hw->aq.asq.len) & 362 IAVF_VF_ATQLEN1_ATQENABLE_MASK); 363 else 364 return false; 365 } 366 367 /** 368 * iavf_aq_queue_shutdown 369 * @hw: pointer to the hw struct 370 * @unloading: is the driver unloading itself 371 * 372 * Tell the Firmware that we're shutting down the AdminQ and whether 373 * or not the driver is unloading as well. 374 **/ 375 enum iavf_status iavf_aq_queue_shutdown(struct iavf_hw *hw, 376 bool unloading) 377 { 378 struct iavf_aq_desc desc; 379 struct iavf_aqc_queue_shutdown *cmd = 380 (struct iavf_aqc_queue_shutdown *)&desc.params.raw; 381 enum iavf_status status; 382 383 iavf_fill_default_direct_cmd_desc(&desc, 384 iavf_aqc_opc_queue_shutdown); 385 386 if (unloading) 387 cmd->driver_unloading = CPU_TO_LE32(IAVF_AQ_DRIVER_UNLOADING); 388 status = iavf_asq_send_command(hw, &desc, NULL, 0, NULL); 389 390 return status; 391 } 392 393 /** 394 * iavf_aq_get_set_rss_lut 395 * @hw: pointer to the hardware structure 396 * @vsi_id: vsi fw index 397 * @pf_lut: for PF table set true, for VSI table set false 398 * @lut: pointer to the lut buffer provided by the caller 399 * @lut_size: size of the lut buffer 400 * @set: set true to set the table, false to get the table 401 * 402 * Internal function to get or set RSS look up table 403 **/ 404 STATIC enum iavf_status iavf_aq_get_set_rss_lut(struct iavf_hw *hw, 405 u16 vsi_id, bool pf_lut, 406 u8 *lut, u16 lut_size, 407 bool set) 408 { 409 enum iavf_status status; 410 struct iavf_aq_desc desc; 411 struct iavf_aqc_get_set_rss_lut *cmd_resp = 412 (struct iavf_aqc_get_set_rss_lut *)&desc.params.raw; 413 414 if (set) 415 iavf_fill_default_direct_cmd_desc(&desc, 416 iavf_aqc_opc_set_rss_lut); 417 else 418 iavf_fill_default_direct_cmd_desc(&desc, 419 iavf_aqc_opc_get_rss_lut); 420 421 /* Indirect command */ 422 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_BUF); 423 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_RD); 424 425 cmd_resp->vsi_id = 426 CPU_TO_LE16((u16)((vsi_id << 427 IAVF_AQC_SET_RSS_LUT_VSI_ID_SHIFT) & 428 IAVF_AQC_SET_RSS_LUT_VSI_ID_MASK)); 429 cmd_resp->vsi_id |= CPU_TO_LE16((u16)IAVF_AQC_SET_RSS_LUT_VSI_VALID); 430 431 if (pf_lut) 432 cmd_resp->flags |= CPU_TO_LE16((u16) 433 ((IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_PF << 434 IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) & 435 IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_MASK)); 436 else 437 cmd_resp->flags |= CPU_TO_LE16((u16) 438 ((IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_VSI << 439 IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) & 440 IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_MASK)); 441 442 status = iavf_asq_send_command(hw, &desc, lut, lut_size, NULL); 443 444 return status; 445 } 446 447 /** 448 * iavf_aq_get_rss_lut 449 * @hw: pointer to the hardware structure 450 * @vsi_id: vsi fw index 451 * @pf_lut: for PF table set true, for VSI table set false 452 * @lut: pointer to the lut buffer provided by the caller 453 * @lut_size: size of the lut buffer 454 * 455 * get the RSS lookup table, PF or VSI type 456 **/ 457 enum iavf_status iavf_aq_get_rss_lut(struct iavf_hw *hw, u16 vsi_id, 458 bool pf_lut, u8 *lut, u16 lut_size) 459 { 460 return iavf_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size, 461 false); 462 } 463 464 /** 465 * iavf_aq_set_rss_lut 466 * @hw: pointer to the hardware structure 467 * @vsi_id: vsi fw index 468 * @pf_lut: for PF table set true, for VSI table set false 469 * @lut: pointer to the lut buffer provided by the caller 470 * @lut_size: size of the lut buffer 471 * 472 * set the RSS lookup table, PF or VSI type 473 **/ 474 enum iavf_status iavf_aq_set_rss_lut(struct iavf_hw *hw, u16 vsi_id, 475 bool pf_lut, u8 *lut, u16 lut_size) 476 { 477 return iavf_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size, true); 478 } 479 480 /** 481 * iavf_aq_get_set_rss_key 482 * @hw: pointer to the hw struct 483 * @vsi_id: vsi fw index 484 * @key: pointer to key info struct 485 * @set: set true to set the key, false to get the key 486 * 487 * get the RSS key per VSI 488 **/ 489 STATIC enum iavf_status iavf_aq_get_set_rss_key(struct iavf_hw *hw, 490 u16 vsi_id, 491 struct iavf_aqc_get_set_rss_key_data *key, 492 bool set) 493 { 494 enum iavf_status status; 495 struct iavf_aq_desc desc; 496 struct iavf_aqc_get_set_rss_key *cmd_resp = 497 (struct iavf_aqc_get_set_rss_key *)&desc.params.raw; 498 u16 key_size = sizeof(struct iavf_aqc_get_set_rss_key_data); 499 500 if (set) 501 iavf_fill_default_direct_cmd_desc(&desc, 502 iavf_aqc_opc_set_rss_key); 503 else 504 iavf_fill_default_direct_cmd_desc(&desc, 505 iavf_aqc_opc_get_rss_key); 506 507 /* Indirect command */ 508 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_BUF); 509 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_RD); 510 511 cmd_resp->vsi_id = 512 CPU_TO_LE16((u16)((vsi_id << 513 IAVF_AQC_SET_RSS_KEY_VSI_ID_SHIFT) & 514 IAVF_AQC_SET_RSS_KEY_VSI_ID_MASK)); 515 cmd_resp->vsi_id |= CPU_TO_LE16((u16)IAVF_AQC_SET_RSS_KEY_VSI_VALID); 516 517 status = iavf_asq_send_command(hw, &desc, key, key_size, NULL); 518 519 return status; 520 } 521 522 /** 523 * iavf_aq_get_rss_key 524 * @hw: pointer to the hw struct 525 * @vsi_id: vsi fw index 526 * @key: pointer to key info struct 527 * 528 **/ 529 enum iavf_status iavf_aq_get_rss_key(struct iavf_hw *hw, 530 u16 vsi_id, 531 struct iavf_aqc_get_set_rss_key_data *key) 532 { 533 return iavf_aq_get_set_rss_key(hw, vsi_id, key, false); 534 } 535 536 /** 537 * iavf_aq_set_rss_key 538 * @hw: pointer to the hw struct 539 * @vsi_id: vsi fw index 540 * @key: pointer to key info struct 541 * 542 * set the RSS key per VSI 543 **/ 544 enum iavf_status iavf_aq_set_rss_key(struct iavf_hw *hw, 545 u16 vsi_id, 546 struct iavf_aqc_get_set_rss_key_data *key) 547 { 548 return iavf_aq_get_set_rss_key(hw, vsi_id, key, true); 549 } 550 551 /* The iavf_ptype_lookup table is used to convert from the 8-bit ptype in the 552 * hardware to a bit-field that can be used by SW to more easily determine the 553 * packet type. 554 * 555 * Macros are used to shorten the table lines and make this table human 556 * readable. 557 * 558 * We store the PTYPE in the top byte of the bit field - this is just so that 559 * we can check that the table doesn't have a row missing, as the index into 560 * the table should be the PTYPE. 561 * 562 * Typical work flow: 563 * 564 * IF NOT iavf_ptype_lookup[ptype].known 565 * THEN 566 * Packet is unknown 567 * ELSE IF iavf_ptype_lookup[ptype].outer_ip == IAVF_RX_PTYPE_OUTER_IP 568 * Use the rest of the fields to look at the tunnels, inner protocols, etc 569 * ELSE 570 * Use the enum iavf_rx_l2_ptype to decode the packet type 571 * ENDIF 572 */ 573 574 /* macro to make the table lines short */ 575 #define IAVF_PTT(PTYPE, OUTER_IP, OUTER_IP_VER, OUTER_FRAG, T, TE, TEF, I, PL)\ 576 { PTYPE, \ 577 1, \ 578 IAVF_RX_PTYPE_OUTER_##OUTER_IP, \ 579 IAVF_RX_PTYPE_OUTER_##OUTER_IP_VER, \ 580 IAVF_RX_PTYPE_##OUTER_FRAG, \ 581 IAVF_RX_PTYPE_TUNNEL_##T, \ 582 IAVF_RX_PTYPE_TUNNEL_END_##TE, \ 583 IAVF_RX_PTYPE_##TEF, \ 584 IAVF_RX_PTYPE_INNER_PROT_##I, \ 585 IAVF_RX_PTYPE_PAYLOAD_LAYER_##PL } 586 587 #define IAVF_PTT_UNUSED_ENTRY(PTYPE) \ 588 { PTYPE, 0, 0, 0, 0, 0, 0, 0, 0, 0 } 589 590 /* shorter macros makes the table fit but are terse */ 591 #define IAVF_RX_PTYPE_NOF IAVF_RX_PTYPE_NOT_FRAG 592 #define IAVF_RX_PTYPE_FRG IAVF_RX_PTYPE_FRAG 593 #define IAVF_RX_PTYPE_INNER_PROT_TS IAVF_RX_PTYPE_INNER_PROT_TIMESYNC 594 595 /* Lookup table mapping the HW PTYPE to the bit field for decoding */ 596 struct iavf_rx_ptype_decoded iavf_ptype_lookup[] = { 597 /* L2 Packet types */ 598 IAVF_PTT_UNUSED_ENTRY(0), 599 IAVF_PTT(1, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2), 600 IAVF_PTT(2, L2, NONE, NOF, NONE, NONE, NOF, TS, PAY2), 601 IAVF_PTT(3, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2), 602 IAVF_PTT_UNUSED_ENTRY(4), 603 IAVF_PTT_UNUSED_ENTRY(5), 604 IAVF_PTT(6, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2), 605 IAVF_PTT(7, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2), 606 IAVF_PTT_UNUSED_ENTRY(8), 607 IAVF_PTT_UNUSED_ENTRY(9), 608 IAVF_PTT(10, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2), 609 IAVF_PTT(11, L2, NONE, NOF, NONE, NONE, NOF, NONE, NONE), 610 IAVF_PTT(12, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), 611 IAVF_PTT(13, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), 612 IAVF_PTT(14, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), 613 IAVF_PTT(15, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), 614 IAVF_PTT(16, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), 615 IAVF_PTT(17, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), 616 IAVF_PTT(18, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), 617 IAVF_PTT(19, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), 618 IAVF_PTT(20, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), 619 IAVF_PTT(21, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3), 620 621 /* Non Tunneled IPv4 */ 622 IAVF_PTT(22, IP, IPV4, FRG, NONE, NONE, NOF, NONE, PAY3), 623 IAVF_PTT(23, IP, IPV4, NOF, NONE, NONE, NOF, NONE, PAY3), 624 IAVF_PTT(24, IP, IPV4, NOF, NONE, NONE, NOF, UDP, PAY4), 625 IAVF_PTT_UNUSED_ENTRY(25), 626 IAVF_PTT(26, IP, IPV4, NOF, NONE, NONE, NOF, TCP, PAY4), 627 IAVF_PTT(27, IP, IPV4, NOF, NONE, NONE, NOF, SCTP, PAY4), 628 IAVF_PTT(28, IP, IPV4, NOF, NONE, NONE, NOF, ICMP, PAY4), 629 630 /* IPv4 --> IPv4 */ 631 IAVF_PTT(29, IP, IPV4, NOF, IP_IP, IPV4, FRG, NONE, PAY3), 632 IAVF_PTT(30, IP, IPV4, NOF, IP_IP, IPV4, NOF, NONE, PAY3), 633 IAVF_PTT(31, IP, IPV4, NOF, IP_IP, IPV4, NOF, UDP, PAY4), 634 IAVF_PTT_UNUSED_ENTRY(32), 635 IAVF_PTT(33, IP, IPV4, NOF, IP_IP, IPV4, NOF, TCP, PAY4), 636 IAVF_PTT(34, IP, IPV4, NOF, IP_IP, IPV4, NOF, SCTP, PAY4), 637 IAVF_PTT(35, IP, IPV4, NOF, IP_IP, IPV4, NOF, ICMP, PAY4), 638 639 /* IPv4 --> IPv6 */ 640 IAVF_PTT(36, IP, IPV4, NOF, IP_IP, IPV6, FRG, NONE, PAY3), 641 IAVF_PTT(37, IP, IPV4, NOF, IP_IP, IPV6, NOF, NONE, PAY3), 642 IAVF_PTT(38, IP, IPV4, NOF, IP_IP, IPV6, NOF, UDP, PAY4), 643 IAVF_PTT_UNUSED_ENTRY(39), 644 IAVF_PTT(40, IP, IPV4, NOF, IP_IP, IPV6, NOF, TCP, PAY4), 645 IAVF_PTT(41, IP, IPV4, NOF, IP_IP, IPV6, NOF, SCTP, PAY4), 646 IAVF_PTT(42, IP, IPV4, NOF, IP_IP, IPV6, NOF, ICMP, PAY4), 647 648 /* IPv4 --> GRE/NAT */ 649 IAVF_PTT(43, IP, IPV4, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3), 650 651 /* IPv4 --> GRE/NAT --> IPv4 */ 652 IAVF_PTT(44, IP, IPV4, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3), 653 IAVF_PTT(45, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3), 654 IAVF_PTT(46, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4), 655 IAVF_PTT_UNUSED_ENTRY(47), 656 IAVF_PTT(48, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4), 657 IAVF_PTT(49, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4), 658 IAVF_PTT(50, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4), 659 660 /* IPv4 --> GRE/NAT --> IPv6 */ 661 IAVF_PTT(51, IP, IPV4, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3), 662 IAVF_PTT(52, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3), 663 IAVF_PTT(53, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4), 664 IAVF_PTT_UNUSED_ENTRY(54), 665 IAVF_PTT(55, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4), 666 IAVF_PTT(56, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4), 667 IAVF_PTT(57, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4), 668 669 /* IPv4 --> GRE/NAT --> MAC */ 670 IAVF_PTT(58, IP, IPV4, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3), 671 672 /* IPv4 --> GRE/NAT --> MAC --> IPv4 */ 673 IAVF_PTT(59, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3), 674 IAVF_PTT(60, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3), 675 IAVF_PTT(61, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4), 676 IAVF_PTT_UNUSED_ENTRY(62), 677 IAVF_PTT(63, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4), 678 IAVF_PTT(64, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4), 679 IAVF_PTT(65, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4), 680 681 /* IPv4 --> GRE/NAT -> MAC --> IPv6 */ 682 IAVF_PTT(66, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3), 683 IAVF_PTT(67, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3), 684 IAVF_PTT(68, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4), 685 IAVF_PTT_UNUSED_ENTRY(69), 686 IAVF_PTT(70, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4), 687 IAVF_PTT(71, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4), 688 IAVF_PTT(72, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4), 689 690 /* IPv4 --> GRE/NAT --> MAC/VLAN */ 691 IAVF_PTT(73, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3), 692 693 /* IPv4 ---> GRE/NAT -> MAC/VLAN --> IPv4 */ 694 IAVF_PTT(74, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3), 695 IAVF_PTT(75, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3), 696 IAVF_PTT(76, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4), 697 IAVF_PTT_UNUSED_ENTRY(77), 698 IAVF_PTT(78, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4), 699 IAVF_PTT(79, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4), 700 IAVF_PTT(80, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4), 701 702 /* IPv4 -> GRE/NAT -> MAC/VLAN --> IPv6 */ 703 IAVF_PTT(81, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3), 704 IAVF_PTT(82, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3), 705 IAVF_PTT(83, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4), 706 IAVF_PTT_UNUSED_ENTRY(84), 707 IAVF_PTT(85, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4), 708 IAVF_PTT(86, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4), 709 IAVF_PTT(87, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4), 710 711 /* Non Tunneled IPv6 */ 712 IAVF_PTT(88, IP, IPV6, FRG, NONE, NONE, NOF, NONE, PAY3), 713 IAVF_PTT(89, IP, IPV6, NOF, NONE, NONE, NOF, NONE, PAY3), 714 IAVF_PTT(90, IP, IPV6, NOF, NONE, NONE, NOF, UDP, PAY4), 715 IAVF_PTT_UNUSED_ENTRY(91), 716 IAVF_PTT(92, IP, IPV6, NOF, NONE, NONE, NOF, TCP, PAY4), 717 IAVF_PTT(93, IP, IPV6, NOF, NONE, NONE, NOF, SCTP, PAY4), 718 IAVF_PTT(94, IP, IPV6, NOF, NONE, NONE, NOF, ICMP, PAY4), 719 720 /* IPv6 --> IPv4 */ 721 IAVF_PTT(95, IP, IPV6, NOF, IP_IP, IPV4, FRG, NONE, PAY3), 722 IAVF_PTT(96, IP, IPV6, NOF, IP_IP, IPV4, NOF, NONE, PAY3), 723 IAVF_PTT(97, IP, IPV6, NOF, IP_IP, IPV4, NOF, UDP, PAY4), 724 IAVF_PTT_UNUSED_ENTRY(98), 725 IAVF_PTT(99, IP, IPV6, NOF, IP_IP, IPV4, NOF, TCP, PAY4), 726 IAVF_PTT(100, IP, IPV6, NOF, IP_IP, IPV4, NOF, SCTP, PAY4), 727 IAVF_PTT(101, IP, IPV6, NOF, IP_IP, IPV4, NOF, ICMP, PAY4), 728 729 /* IPv6 --> IPv6 */ 730 IAVF_PTT(102, IP, IPV6, NOF, IP_IP, IPV6, FRG, NONE, PAY3), 731 IAVF_PTT(103, IP, IPV6, NOF, IP_IP, IPV6, NOF, NONE, PAY3), 732 IAVF_PTT(104, IP, IPV6, NOF, IP_IP, IPV6, NOF, UDP, PAY4), 733 IAVF_PTT_UNUSED_ENTRY(105), 734 IAVF_PTT(106, IP, IPV6, NOF, IP_IP, IPV6, NOF, TCP, PAY4), 735 IAVF_PTT(107, IP, IPV6, NOF, IP_IP, IPV6, NOF, SCTP, PAY4), 736 IAVF_PTT(108, IP, IPV6, NOF, IP_IP, IPV6, NOF, ICMP, PAY4), 737 738 /* IPv6 --> GRE/NAT */ 739 IAVF_PTT(109, IP, IPV6, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3), 740 741 /* IPv6 --> GRE/NAT -> IPv4 */ 742 IAVF_PTT(110, IP, IPV6, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3), 743 IAVF_PTT(111, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3), 744 IAVF_PTT(112, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4), 745 IAVF_PTT_UNUSED_ENTRY(113), 746 IAVF_PTT(114, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4), 747 IAVF_PTT(115, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4), 748 IAVF_PTT(116, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4), 749 750 /* IPv6 --> GRE/NAT -> IPv6 */ 751 IAVF_PTT(117, IP, IPV6, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3), 752 IAVF_PTT(118, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3), 753 IAVF_PTT(119, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4), 754 IAVF_PTT_UNUSED_ENTRY(120), 755 IAVF_PTT(121, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4), 756 IAVF_PTT(122, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4), 757 IAVF_PTT(123, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4), 758 759 /* IPv6 --> GRE/NAT -> MAC */ 760 IAVF_PTT(124, IP, IPV6, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3), 761 762 /* IPv6 --> GRE/NAT -> MAC -> IPv4 */ 763 IAVF_PTT(125, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3), 764 IAVF_PTT(126, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3), 765 IAVF_PTT(127, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4), 766 IAVF_PTT_UNUSED_ENTRY(128), 767 IAVF_PTT(129, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4), 768 IAVF_PTT(130, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4), 769 IAVF_PTT(131, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4), 770 771 /* IPv6 --> GRE/NAT -> MAC -> IPv6 */ 772 IAVF_PTT(132, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3), 773 IAVF_PTT(133, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3), 774 IAVF_PTT(134, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4), 775 IAVF_PTT_UNUSED_ENTRY(135), 776 IAVF_PTT(136, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4), 777 IAVF_PTT(137, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4), 778 IAVF_PTT(138, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4), 779 780 /* IPv6 --> GRE/NAT -> MAC/VLAN */ 781 IAVF_PTT(139, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3), 782 783 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv4 */ 784 IAVF_PTT(140, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3), 785 IAVF_PTT(141, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3), 786 IAVF_PTT(142, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4), 787 IAVF_PTT_UNUSED_ENTRY(143), 788 IAVF_PTT(144, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4), 789 IAVF_PTT(145, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4), 790 IAVF_PTT(146, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4), 791 792 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv6 */ 793 IAVF_PTT(147, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3), 794 IAVF_PTT(148, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3), 795 IAVF_PTT(149, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4), 796 IAVF_PTT_UNUSED_ENTRY(150), 797 IAVF_PTT(151, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4), 798 IAVF_PTT(152, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4), 799 IAVF_PTT(153, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4), 800 801 /* unused entries */ 802 IAVF_PTT_UNUSED_ENTRY(154), 803 IAVF_PTT_UNUSED_ENTRY(155), 804 IAVF_PTT_UNUSED_ENTRY(156), 805 IAVF_PTT_UNUSED_ENTRY(157), 806 IAVF_PTT_UNUSED_ENTRY(158), 807 IAVF_PTT_UNUSED_ENTRY(159), 808 809 IAVF_PTT_UNUSED_ENTRY(160), 810 IAVF_PTT_UNUSED_ENTRY(161), 811 IAVF_PTT_UNUSED_ENTRY(162), 812 IAVF_PTT_UNUSED_ENTRY(163), 813 IAVF_PTT_UNUSED_ENTRY(164), 814 IAVF_PTT_UNUSED_ENTRY(165), 815 IAVF_PTT_UNUSED_ENTRY(166), 816 IAVF_PTT_UNUSED_ENTRY(167), 817 IAVF_PTT_UNUSED_ENTRY(168), 818 IAVF_PTT_UNUSED_ENTRY(169), 819 820 IAVF_PTT_UNUSED_ENTRY(170), 821 IAVF_PTT_UNUSED_ENTRY(171), 822 IAVF_PTT_UNUSED_ENTRY(172), 823 IAVF_PTT_UNUSED_ENTRY(173), 824 IAVF_PTT_UNUSED_ENTRY(174), 825 IAVF_PTT_UNUSED_ENTRY(175), 826 IAVF_PTT_UNUSED_ENTRY(176), 827 IAVF_PTT_UNUSED_ENTRY(177), 828 IAVF_PTT_UNUSED_ENTRY(178), 829 IAVF_PTT_UNUSED_ENTRY(179), 830 831 IAVF_PTT_UNUSED_ENTRY(180), 832 IAVF_PTT_UNUSED_ENTRY(181), 833 IAVF_PTT_UNUSED_ENTRY(182), 834 IAVF_PTT_UNUSED_ENTRY(183), 835 IAVF_PTT_UNUSED_ENTRY(184), 836 IAVF_PTT_UNUSED_ENTRY(185), 837 IAVF_PTT_UNUSED_ENTRY(186), 838 IAVF_PTT_UNUSED_ENTRY(187), 839 IAVF_PTT_UNUSED_ENTRY(188), 840 IAVF_PTT_UNUSED_ENTRY(189), 841 842 IAVF_PTT_UNUSED_ENTRY(190), 843 IAVF_PTT_UNUSED_ENTRY(191), 844 IAVF_PTT_UNUSED_ENTRY(192), 845 IAVF_PTT_UNUSED_ENTRY(193), 846 IAVF_PTT_UNUSED_ENTRY(194), 847 IAVF_PTT_UNUSED_ENTRY(195), 848 IAVF_PTT_UNUSED_ENTRY(196), 849 IAVF_PTT_UNUSED_ENTRY(197), 850 IAVF_PTT_UNUSED_ENTRY(198), 851 IAVF_PTT_UNUSED_ENTRY(199), 852 853 IAVF_PTT_UNUSED_ENTRY(200), 854 IAVF_PTT_UNUSED_ENTRY(201), 855 IAVF_PTT_UNUSED_ENTRY(202), 856 IAVF_PTT_UNUSED_ENTRY(203), 857 IAVF_PTT_UNUSED_ENTRY(204), 858 IAVF_PTT_UNUSED_ENTRY(205), 859 IAVF_PTT_UNUSED_ENTRY(206), 860 IAVF_PTT_UNUSED_ENTRY(207), 861 IAVF_PTT_UNUSED_ENTRY(208), 862 IAVF_PTT_UNUSED_ENTRY(209), 863 864 IAVF_PTT_UNUSED_ENTRY(210), 865 IAVF_PTT_UNUSED_ENTRY(211), 866 IAVF_PTT_UNUSED_ENTRY(212), 867 IAVF_PTT_UNUSED_ENTRY(213), 868 IAVF_PTT_UNUSED_ENTRY(214), 869 IAVF_PTT_UNUSED_ENTRY(215), 870 IAVF_PTT_UNUSED_ENTRY(216), 871 IAVF_PTT_UNUSED_ENTRY(217), 872 IAVF_PTT_UNUSED_ENTRY(218), 873 IAVF_PTT_UNUSED_ENTRY(219), 874 875 IAVF_PTT_UNUSED_ENTRY(220), 876 IAVF_PTT_UNUSED_ENTRY(221), 877 IAVF_PTT_UNUSED_ENTRY(222), 878 IAVF_PTT_UNUSED_ENTRY(223), 879 IAVF_PTT_UNUSED_ENTRY(224), 880 IAVF_PTT_UNUSED_ENTRY(225), 881 IAVF_PTT_UNUSED_ENTRY(226), 882 IAVF_PTT_UNUSED_ENTRY(227), 883 IAVF_PTT_UNUSED_ENTRY(228), 884 IAVF_PTT_UNUSED_ENTRY(229), 885 886 IAVF_PTT_UNUSED_ENTRY(230), 887 IAVF_PTT_UNUSED_ENTRY(231), 888 IAVF_PTT_UNUSED_ENTRY(232), 889 IAVF_PTT_UNUSED_ENTRY(233), 890 IAVF_PTT_UNUSED_ENTRY(234), 891 IAVF_PTT_UNUSED_ENTRY(235), 892 IAVF_PTT_UNUSED_ENTRY(236), 893 IAVF_PTT_UNUSED_ENTRY(237), 894 IAVF_PTT_UNUSED_ENTRY(238), 895 IAVF_PTT_UNUSED_ENTRY(239), 896 897 IAVF_PTT_UNUSED_ENTRY(240), 898 IAVF_PTT_UNUSED_ENTRY(241), 899 IAVF_PTT_UNUSED_ENTRY(242), 900 IAVF_PTT_UNUSED_ENTRY(243), 901 IAVF_PTT_UNUSED_ENTRY(244), 902 IAVF_PTT_UNUSED_ENTRY(245), 903 IAVF_PTT_UNUSED_ENTRY(246), 904 IAVF_PTT_UNUSED_ENTRY(247), 905 IAVF_PTT_UNUSED_ENTRY(248), 906 IAVF_PTT_UNUSED_ENTRY(249), 907 908 IAVF_PTT_UNUSED_ENTRY(250), 909 IAVF_PTT_UNUSED_ENTRY(251), 910 IAVF_PTT_UNUSED_ENTRY(252), 911 IAVF_PTT_UNUSED_ENTRY(253), 912 IAVF_PTT_UNUSED_ENTRY(254), 913 IAVF_PTT_UNUSED_ENTRY(255) 914 }; 915 916 /** 917 * iavf_validate_mac_addr - Validate unicast MAC address 918 * @mac_addr: pointer to MAC address 919 * 920 * Tests a MAC address to ensure it is a valid Individual Address 921 **/ 922 enum iavf_status iavf_validate_mac_addr(u8 *mac_addr) 923 { 924 enum iavf_status status = IAVF_SUCCESS; 925 926 DEBUGFUNC("iavf_validate_mac_addr"); 927 928 /* Broadcast addresses ARE multicast addresses 929 * Make sure it is not a multicast address 930 * Reject the zero address 931 */ 932 if (IAVF_IS_MULTICAST(mac_addr) || 933 (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 && 934 mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0)) 935 status = IAVF_ERR_INVALID_MAC_ADDR; 936 937 return status; 938 } 939 940 /** 941 * iavf_aq_send_msg_to_pf 942 * @hw: pointer to the hardware structure 943 * @v_opcode: opcodes for VF-PF communication 944 * @v_retval: return error code 945 * @msg: pointer to the msg buffer 946 * @msglen: msg length 947 * @cmd_details: pointer to command details 948 * 949 * Send message to PF driver using admin queue. By default, this message 950 * is sent asynchronously, i.e. iavf_asq_send_command() does not wait for 951 * completion before returning. 952 **/ 953 enum iavf_status iavf_aq_send_msg_to_pf(struct iavf_hw *hw, 954 enum virtchnl_ops v_opcode, 955 enum iavf_status v_retval, 956 u8 *msg, u16 msglen, 957 struct iavf_asq_cmd_details *cmd_details) 958 { 959 struct iavf_aq_desc desc; 960 struct iavf_asq_cmd_details details; 961 enum iavf_status status; 962 963 iavf_fill_default_direct_cmd_desc(&desc, iavf_aqc_opc_send_msg_to_pf); 964 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_SI); 965 desc.cookie_high = CPU_TO_LE32(v_opcode); 966 desc.cookie_low = CPU_TO_LE32(v_retval); 967 if (msglen) { 968 desc.flags |= CPU_TO_LE16((u16)(IAVF_AQ_FLAG_BUF 969 | IAVF_AQ_FLAG_RD)); 970 if (msglen > IAVF_AQ_LARGE_BUF) 971 desc.flags |= CPU_TO_LE16((u16)IAVF_AQ_FLAG_LB); 972 desc.datalen = CPU_TO_LE16(msglen); 973 } 974 if (!cmd_details) { 975 iavf_memset(&details, 0, sizeof(details), IAVF_NONDMA_MEM); 976 details.async = true; 977 cmd_details = &details; 978 } 979 status = iavf_asq_send_command(hw, (struct iavf_aq_desc *)&desc, msg, 980 msglen, cmd_details); 981 return status; 982 } 983 984 /** 985 * iavf_vf_parse_hw_config 986 * @hw: pointer to the hardware structure 987 * @msg: pointer to the virtual channel VF resource structure 988 * 989 * Given a VF resource message from the PF, populate the hw struct 990 * with appropriate information. 991 **/ 992 void iavf_vf_parse_hw_config(struct iavf_hw *hw, 993 struct virtchnl_vf_resource *msg) 994 { 995 struct virtchnl_vsi_resource *vsi_res; 996 int i; 997 998 vsi_res = &msg->vsi_res[0]; 999 1000 hw->dev_caps.num_vsis = msg->num_vsis; 1001 hw->dev_caps.num_rx_qp = msg->num_queue_pairs; 1002 hw->dev_caps.num_tx_qp = msg->num_queue_pairs; 1003 hw->dev_caps.num_msix_vectors_vf = msg->max_vectors; 1004 hw->dev_caps.dcb = msg->vf_cap_flags & 1005 VIRTCHNL_VF_OFFLOAD_L2; 1006 for (i = 0; i < msg->num_vsis; i++) { 1007 if (vsi_res->vsi_type == VIRTCHNL_VSI_SRIOV) { 1008 iavf_memcpy(hw->mac.perm_addr, 1009 vsi_res->default_mac_addr, 1010 ETH_ALEN, 1011 IAVF_NONDMA_TO_NONDMA); 1012 iavf_memcpy(hw->mac.addr, vsi_res->default_mac_addr, 1013 ETH_ALEN, 1014 IAVF_NONDMA_TO_NONDMA); 1015 } 1016 vsi_res++; 1017 } 1018 } 1019 1020 /** 1021 * iavf_vf_reset 1022 * @hw: pointer to the hardware structure 1023 * 1024 * Send a VF_RESET message to the PF. Does not wait for response from PF 1025 * as none will be forthcoming. Immediately after calling this function, 1026 * the admin queue should be shut down and (optionally) reinitialized. 1027 **/ 1028 enum iavf_status iavf_vf_reset(struct iavf_hw *hw) 1029 { 1030 return iavf_aq_send_msg_to_pf(hw, VIRTCHNL_OP_RESET_VF, 1031 IAVF_SUCCESS, NULL, 0, NULL); 1032 } 1033 1034 /** 1035 * iavf_aq_clear_all_wol_filters 1036 * @hw: pointer to the hw struct 1037 * @cmd_details: pointer to command details structure or NULL 1038 * 1039 * Get information for the reason of a Wake Up event 1040 **/ 1041 enum iavf_status iavf_aq_clear_all_wol_filters(struct iavf_hw *hw, 1042 struct iavf_asq_cmd_details *cmd_details) 1043 { 1044 struct iavf_aq_desc desc; 1045 enum iavf_status status; 1046 1047 iavf_fill_default_direct_cmd_desc(&desc, 1048 iavf_aqc_opc_clear_all_wol_filters); 1049 1050 status = iavf_asq_send_command(hw, &desc, NULL, 0, cmd_details); 1051 1052 return status; 1053 } 1054