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