Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue

Tony Nguyen says:

====================
i40e: cleanups & refactors

Ivan Vecera says:

This series do following:
Patch 1 - Removes write-only flags field from i40e_veb structure and
from i40e_veb_setup() parameters
Patch 2 - Refactors parameter of i40e_notify_client_of_l2_param_changes()
and i40e_notify_client_of_netdev_close()
Patch 3 - Refactors parameter of i40e_detect_recover_hung()
Patch 4 - Adds helper i40e_pf_get_main_vsi() to get main VSI and uses it
in existing code
Patch 5 - Consolidates checks whether given VSI is the main one
Patch 6 - Adds helper i40e_pf_get_main_veb() to get main VEB and uses it
in existing code
Patch 7 - Adds helper i40e_vsi_reconfig_tc() to reconfigure TC for
particular and uses it to replace existing open-coded pieces

* '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue:
i40e: Add and use helper to reconfigure TC for given VSI
i40e: Add helper to access main VEB
i40e: Consolidate checks whether given VSI is main
i40e: Add helper to access main VSI
i40e: Refactor argument of i40e_detect_recover_hung()
i40e: Refactor argument of several client notification functions
i40e: Remove flags field from i40e_veb
====================

Link: https://lore.kernel.org/r/20240430180639.1938515-1-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+211 -152
+25 -4
drivers/net/ethernet/intel/i40e/i40e.h
··· 788 788 u16 stats_idx; /* index of VEB parent */ 789 789 u8 enabled_tc; 790 790 u16 bridge_mode; /* Bridge Mode (VEB/VEPA) */ 791 - u16 flags; 792 791 u16 bw_limit; 793 792 u8 bw_max_quanta; 794 793 bool is_abs_credits; ··· 1212 1213 void i40e_vsi_stop_rings_no_wait(struct i40e_vsi *vsi); 1213 1214 int i40e_vsi_wait_queues_disabled(struct i40e_vsi *vsi); 1214 1215 int i40e_reconfig_rss_queues(struct i40e_pf *pf, int queue_count); 1215 - struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 flags, u16 uplink_seid, 1216 + struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 uplink_seid, 1216 1217 u16 downlink_seid, u8 enabled_tc); 1217 1218 void i40e_veb_release(struct i40e_veb *veb); 1218 1219 ··· 1236 1237 int i40e_lan_add_device(struct i40e_pf *pf); 1237 1238 int i40e_lan_del_device(struct i40e_pf *pf); 1238 1239 void i40e_client_subtask(struct i40e_pf *pf); 1239 - void i40e_notify_client_of_l2_param_changes(struct i40e_vsi *vsi); 1240 - void i40e_notify_client_of_netdev_close(struct i40e_vsi *vsi, bool reset); 1240 + void i40e_notify_client_of_l2_param_changes(struct i40e_pf *pf); 1241 + void i40e_notify_client_of_netdev_close(struct i40e_pf *pf, bool reset); 1241 1242 void i40e_notify_client_of_vf_enable(struct i40e_pf *pf, u32 num_vfs); 1242 1243 void i40e_notify_client_of_vf_reset(struct i40e_pf *pf, u32 vf_id); 1243 1244 void i40e_client_update_msix_info(struct i40e_pf *pf); ··· 1373 1374 } 1374 1375 1375 1376 /** 1377 + * i40e_pf_get_main_vsi - get pointer to main VSI 1378 + * @pf: pointer to a PF 1379 + * 1380 + * Return: pointer to main VSI or NULL if it does not exist 1381 + **/ 1382 + static inline struct i40e_vsi *i40e_pf_get_main_vsi(struct i40e_pf *pf) 1383 + { 1384 + return (pf->lan_vsi != I40E_NO_VSI) ? pf->vsi[pf->lan_vsi] : NULL; 1385 + } 1386 + 1387 + /** 1376 1388 * i40e_pf_get_veb_by_seid - find VEB by SEID 1377 1389 * @pf: pointer to a PF 1378 1390 * @seid: SEID of the VSI ··· 1399 1389 return veb; 1400 1390 1401 1391 return NULL; 1392 + } 1393 + 1394 + /** 1395 + * i40e_pf_get_main_veb - get pointer to main VEB 1396 + * @pf: pointer to a PF 1397 + * 1398 + * Return: pointer to main VEB or NULL if it does not exist 1399 + **/ 1400 + static inline struct i40e_veb *i40e_pf_get_main_veb(struct i40e_pf *pf) 1401 + { 1402 + return (pf->lan_veb != I40E_NO_VEB) ? pf->veb[pf->lan_veb] : NULL; 1402 1403 } 1403 1404 1404 1405 #endif /* _I40E_H_ */
+14 -14
drivers/net/ethernet/intel/i40e/i40e_client.c
··· 101 101 102 102 /** 103 103 * i40e_notify_client_of_l2_param_changes - call the client notify callback 104 - * @vsi: the VSI with l2 param changes 104 + * @pf: PF device pointer 105 105 * 106 - * If there is a client to this VSI, call the client 106 + * If there is a client, call its callback 107 107 **/ 108 - void i40e_notify_client_of_l2_param_changes(struct i40e_vsi *vsi) 108 + void i40e_notify_client_of_l2_param_changes(struct i40e_pf *pf) 109 109 { 110 - struct i40e_pf *pf = vsi->back; 110 + struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); 111 111 struct i40e_client_instance *cdev = pf->cinst; 112 112 struct i40e_params params; 113 113 114 114 if (!cdev || !cdev->client) 115 115 return; 116 116 if (!cdev->client->ops || !cdev->client->ops->l2_param_change) { 117 - dev_dbg(&vsi->back->pdev->dev, 117 + dev_dbg(&pf->pdev->dev, 118 118 "Cannot locate client instance l2_param_change routine\n"); 119 119 return; 120 120 } 121 121 if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) { 122 - dev_dbg(&vsi->back->pdev->dev, "Client is not open, abort l2 param change\n"); 122 + dev_dbg(&pf->pdev->dev, 123 + "Client is not open, abort l2 param change\n"); 123 124 return; 124 125 } 125 126 memset(&params, 0, sizeof(params)); ··· 158 157 159 158 /** 160 159 * i40e_notify_client_of_netdev_close - call the client close callback 161 - * @vsi: the VSI with netdev closed 160 + * @pf: PF device pointer 162 161 * @reset: true when close called due to a reset pending 163 162 * 164 163 * If there is a client to this netdev, call the client with close 165 164 **/ 166 - void i40e_notify_client_of_netdev_close(struct i40e_vsi *vsi, bool reset) 165 + void i40e_notify_client_of_netdev_close(struct i40e_pf *pf, bool reset) 167 166 { 168 - struct i40e_pf *pf = vsi->back; 169 167 struct i40e_client_instance *cdev = pf->cinst; 170 168 171 169 if (!cdev || !cdev->client) 172 170 return; 173 171 if (!cdev->client->ops || !cdev->client->ops->close) { 174 - dev_dbg(&vsi->back->pdev->dev, 172 + dev_dbg(&pf->pdev->dev, 175 173 "Cannot locate client instance close routine\n"); 176 174 return; 177 175 } ··· 333 333 **/ 334 334 static void i40e_client_add_instance(struct i40e_pf *pf) 335 335 { 336 + struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); 336 337 struct i40e_client_instance *cdev = NULL; 337 338 struct netdev_hw_addr *mac = NULL; 338 - struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; 339 339 340 340 cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); 341 341 if (!cdev) ··· 399 399 **/ 400 400 void i40e_client_subtask(struct i40e_pf *pf) 401 401 { 402 - struct i40e_client *client; 402 + struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); 403 403 struct i40e_client_instance *cdev; 404 - struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; 404 + struct i40e_client *client; 405 405 int ret = 0; 406 406 407 407 if (!test_and_clear_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state)) ··· 665 665 bool is_vf, u32 vf_id, 666 666 u32 flag, u32 valid_flag) 667 667 { 668 + struct i40e_vsi *vsi = i40e_pf_get_main_vsi(ldev->pf); 668 669 struct i40e_pf *pf = ldev->pf; 669 - struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; 670 670 struct i40e_vsi_context ctxt; 671 671 bool update = true; 672 672 int err;
+2 -1
drivers/net/ethernet/intel/i40e/i40e_ddp.c
··· 407 407 **/ 408 408 static int i40e_ddp_restore(struct i40e_pf *pf) 409 409 { 410 + struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); 411 + struct net_device *netdev = vsi->netdev; 410 412 struct i40e_ddp_old_profile_list *entry; 411 - struct net_device *netdev = pf->vsi[pf->lan_vsi]->netdev; 412 413 int status = 0; 413 414 414 415 if (!list_empty(&pf->ddp_old_prof)) {
+20 -16
drivers/net/ethernet/intel/i40e/i40e_debugfs.c
··· 53 53 size_t count, loff_t *ppos) 54 54 { 55 55 struct i40e_pf *pf = filp->private_data; 56 + struct i40e_vsi *main_vsi; 56 57 int bytes_not_copied; 57 58 int buf_size = 256; 58 59 char *buf; ··· 69 68 if (!buf) 70 69 return -ENOSPC; 71 70 72 - len = snprintf(buf, buf_size, "%s: %s\n", 73 - pf->vsi[pf->lan_vsi]->netdev->name, 71 + main_vsi = i40e_pf_get_main_vsi(pf); 72 + len = snprintf(buf, buf_size, "%s: %s\n", main_vsi->netdev->name, 74 73 i40e_dbg_command_buf); 75 74 76 75 bytes_not_copied = copy_to_user(buffer, buf, len); ··· 129 128 dev_info(&pf->pdev->dev, 130 129 " state[%d] = %08lx\n", 131 130 i, vsi->state[i]); 132 - if (vsi == pf->vsi[pf->lan_vsi]) 131 + if (vsi->type == I40E_VSI_MAIN) 133 132 dev_info(&pf->pdev->dev, " MAC address: %pM Port MAC: %pM\n", 134 133 pf->hw.mac.addr, 135 134 pf->hw.mac.port_addr); ··· 787 786 cnt = sscanf(&cmd_buf[7], "%i", &vsi_seid); 788 787 if (cnt == 0) { 789 788 /* default to PF VSI */ 790 - vsi_seid = pf->vsi[pf->lan_vsi]->seid; 789 + vsi = i40e_pf_get_main_vsi(pf); 790 + vsi_seid = vsi->seid; 791 791 } else if (vsi_seid < 0) { 792 792 dev_info(&pf->pdev->dev, "add VSI %d: bad vsi seid\n", 793 793 vsi_seid); ··· 869 867 goto command_write_done; 870 868 } 871 869 872 - veb = i40e_veb_setup(pf, 0, uplink_seid, vsi_seid, enabled_tc); 870 + veb = i40e_veb_setup(pf, uplink_seid, vsi_seid, enabled_tc); 873 871 if (veb) 874 872 dev_info(&pf->pdev->dev, "added relay %d\n", veb->seid); 875 873 else ··· 1032 1030 goto command_write_done; 1033 1031 } 1034 1032 1035 - vsi = pf->vsi[pf->lan_vsi]; 1033 + vsi = i40e_pf_get_main_vsi(pf); 1036 1034 switch_id = 1037 1035 le16_to_cpu(vsi->info.switch_id) & 1038 1036 I40E_AQ_VSI_SW_ID_MASK; ··· 1382 1380 dev_info(&pf->pdev->dev, "FD current total filter count for this interface: %d\n", 1383 1381 i40e_get_current_fd_count(pf)); 1384 1382 } else if (strncmp(cmd_buf, "lldp", 4) == 0) { 1383 + /* Get main VSI */ 1384 + struct i40e_vsi *main_vsi = i40e_pf_get_main_vsi(pf); 1385 + 1385 1386 if (strncmp(&cmd_buf[5], "stop", 4) == 0) { 1386 1387 int ret; 1387 1388 ··· 1396 1391 goto command_write_done; 1397 1392 } 1398 1393 ret = i40e_aq_add_rem_control_packet_filter(&pf->hw, 1399 - pf->hw.mac.addr, 1400 - ETH_P_LLDP, 0, 1401 - pf->vsi[pf->lan_vsi]->seid, 1402 - 0, true, NULL, NULL); 1394 + pf->hw.mac.addr, ETH_P_LLDP, 0, 1395 + main_vsi->seid, 0, true, NULL, 1396 + NULL); 1403 1397 if (ret) { 1404 1398 dev_info(&pf->pdev->dev, 1405 1399 "%s: Add Control Packet Filter AQ command failed =0x%x\n", ··· 1413 1409 int ret; 1414 1410 1415 1411 ret = i40e_aq_add_rem_control_packet_filter(&pf->hw, 1416 - pf->hw.mac.addr, 1417 - ETH_P_LLDP, 0, 1418 - pf->vsi[pf->lan_vsi]->seid, 1419 - 0, false, NULL, NULL); 1412 + pf->hw.mac.addr, ETH_P_LLDP, 0, 1413 + main_vsi->seid, 0, false, NULL, 1414 + NULL); 1420 1415 if (ret) { 1421 1416 dev_info(&pf->pdev->dev, 1422 1417 "%s: Remove Control Packet Filter AQ command failed =0x%x\n", ··· 1642 1639 size_t count, loff_t *ppos) 1643 1640 { 1644 1641 struct i40e_pf *pf = filp->private_data; 1642 + struct i40e_vsi *main_vsi; 1645 1643 int bytes_not_copied; 1646 1644 int buf_size = 256; 1647 1645 char *buf; ··· 1658 1654 if (!buf) 1659 1655 return -ENOSPC; 1660 1656 1661 - len = snprintf(buf, buf_size, "%s: %s\n", 1662 - pf->vsi[pf->lan_vsi]->netdev->name, 1657 + main_vsi = i40e_pf_get_main_vsi(pf); 1658 + len = snprintf(buf, buf_size, "%s: %s\n", main_vsi->netdev->name, 1663 1659 i40e_dbg_netdev_ops_buf); 1664 1660 1665 1661 bytes_not_copied = copy_to_user(buffer, buf, len);
+13 -16
drivers/net/ethernet/intel/i40e/i40e_ethtool.c
··· 1241 1241 i40e_partition_setting_complaint(pf); 1242 1242 return -EOPNOTSUPP; 1243 1243 } 1244 - if (vsi != pf->vsi[pf->lan_vsi]) 1244 + if (vsi->type != I40E_VSI_MAIN) 1245 1245 return -EOPNOTSUPP; 1246 1246 if (hw->phy.media_type != I40E_MEDIA_TYPE_BASET && 1247 1247 hw->phy.media_type != I40E_MEDIA_TYPE_FIBER && ··· 1710 1710 return -EOPNOTSUPP; 1711 1711 } 1712 1712 1713 - if (vsi != pf->vsi[pf->lan_vsi]) 1713 + if (vsi->type != I40E_VSI_MAIN) 1714 1714 return -EOPNOTSUPP; 1715 1715 1716 1716 is_an = hw_link_info->an_info & I40E_AQ_AN_COMPLETED; ··· 2029 2029 { 2030 2030 struct i40e_netdev_priv *np = netdev_priv(netdev); 2031 2031 struct i40e_pf *pf = np->vsi->back; 2032 - struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; 2032 + struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); 2033 2033 2034 2034 ring->rx_max_pending = i40e_get_max_num_descriptors(pf); 2035 2035 ring->tx_max_pending = i40e_get_max_num_descriptors(pf); ··· 2292 2292 struct i40e_pf *pf = vsi->back; 2293 2293 int stats_len; 2294 2294 2295 - if (vsi == pf->vsi[pf->lan_vsi] && pf->hw.partition_id == 1) 2295 + if (vsi->type == I40E_VSI_MAIN && pf->hw.partition_id == 1) 2296 2296 stats_len = I40E_PF_STATS_LEN; 2297 2297 else 2298 2298 stats_len = I40E_VSI_STATS_LEN; ··· 2422 2422 } 2423 2423 rcu_read_unlock(); 2424 2424 2425 - if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1) 2425 + if (vsi->type != I40E_VSI_MAIN || pf->hw.partition_id != 1) 2426 2426 goto check_data_pointer; 2427 2427 2428 - veb_stats = ((pf->lan_veb != I40E_NO_VEB) && 2429 - (pf->lan_veb < I40E_MAX_VEB) && 2430 - test_bit(I40E_FLAG_VEB_STATS_ENA, pf->flags)); 2428 + veb = i40e_pf_get_main_veb(pf); 2429 + veb_stats = veb && test_bit(I40E_FLAG_VEB_STATS_ENA, pf->flags); 2431 2430 2432 - if (veb_stats) { 2433 - veb = pf->veb[pf->lan_veb]; 2431 + if (veb_stats) 2434 2432 i40e_update_veb_stats(veb); 2435 - } 2436 2433 2437 2434 /* If veb stats aren't enabled, pass NULL instead of the veb so that 2438 2435 * we initialize stats to zero and update the data pointer ··· 2492 2495 "rx", i); 2493 2496 } 2494 2497 2495 - if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1) 2498 + if (vsi->type != I40E_VSI_MAIN || pf->hw.partition_id != 1) 2496 2499 goto check_data_pointer; 2497 2500 2498 2501 i40e_add_stat_strings(&data, i40e_gstrings_veb_stats); ··· 2789 2792 return -EOPNOTSUPP; 2790 2793 } 2791 2794 2792 - if (vsi != pf->vsi[pf->lan_vsi]) 2795 + if (vsi->type != I40E_VSI_MAIN) 2793 2796 return -EOPNOTSUPP; 2794 2797 2795 2798 /* NVM bit on means WoL disabled for the port */ ··· 3367 3370 struct i40e_rx_flow_userdef userdef = {0}; 3368 3371 struct i40e_fdir_filter *rule = NULL; 3369 3372 struct hlist_node *node2; 3373 + struct i40e_vsi *vsi; 3370 3374 u64 input_set; 3371 3375 u16 index; 3372 3376 ··· 3491 3493 fsp->flow_type |= FLOW_EXT; 3492 3494 } 3493 3495 3494 - if (rule->dest_vsi != pf->vsi[pf->lan_vsi]->id) { 3495 - struct i40e_vsi *vsi; 3496 - 3496 + vsi = i40e_pf_get_main_vsi(pf); 3497 + if (rule->dest_vsi != vsi->id) { 3497 3498 vsi = i40e_find_vsi_from_id(pf, rule->dest_vsi); 3498 3499 if (vsi && vsi->type == I40E_VSI_SRIOV) { 3499 3500 /* VFs are zero-indexed by the driver, but ethtool
+115 -85
drivers/net/ethernet/intel/i40e/i40e_main.c
··· 990 990 ns->tx_dropped = es->tx_discards; 991 991 992 992 /* pull in a couple PF stats if this is the main vsi */ 993 - if (vsi == pf->vsi[pf->lan_vsi]) { 993 + if (vsi->type == I40E_VSI_MAIN) { 994 994 ns->rx_crc_errors = pf->stats.crc_errors; 995 995 ns->rx_errors = pf->stats.crc_errors + pf->stats.illegal_bytes; 996 996 ns->rx_length_errors = pf->stats.rx_length_errors; ··· 1235 1235 { 1236 1236 struct i40e_pf *pf = vsi->back; 1237 1237 1238 - if (vsi == pf->vsi[pf->lan_vsi]) 1238 + if (vsi->type == I40E_VSI_MAIN) 1239 1239 i40e_update_pf_stats(pf); 1240 1240 1241 1241 i40e_update_vsi_stats(vsi); ··· 2476 2476 **/ 2477 2477 static int i40e_set_promiscuous(struct i40e_pf *pf, bool promisc) 2478 2478 { 2479 - struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; 2479 + struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); 2480 2480 struct i40e_hw *hw = &pf->hw; 2481 2481 int aq_ret; 2482 2482 2483 2483 if (vsi->type == I40E_VSI_MAIN && 2484 - pf->lan_veb != I40E_NO_VEB && 2484 + i40e_pf_get_main_veb(pf) && 2485 2485 !test_bit(I40E_FLAG_MFP_ENA, pf->flags)) { 2486 2486 /* set defport ON for Main VSI instead of true promisc 2487 2487 * this way we will get all unicast/multicast and VLAN ··· 4323 4323 4324 4324 /* only q0 is used in MSI/Legacy mode, and none are used in MSIX */ 4325 4325 if (icr0 & I40E_PFINT_ICR0_QUEUE_0_MASK) { 4326 - struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; 4326 + struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); 4327 4327 struct i40e_q_vector *q_vector = vsi->q_vectors[0]; 4328 4328 4329 4329 /* We do not have a way to disarm Queue causes while leaving ··· 5473 5473 **/ 5474 5474 static u8 i40e_mqprio_get_enabled_tc(struct i40e_pf *pf) 5475 5475 { 5476 - struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; 5476 + struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); 5477 5477 u8 num_tc = vsi->mqprio_qopt.qopt.num_tc; 5478 5478 u8 enabled_tc = 1, i; 5479 5479 ··· 5490 5490 **/ 5491 5491 static u8 i40e_pf_get_num_tc(struct i40e_pf *pf) 5492 5492 { 5493 - struct i40e_hw *hw = &pf->hw; 5494 5493 u8 i, enabled_tc = 1; 5495 5494 u8 num_tc = 0; 5496 - struct i40e_dcbx_config *dcbcfg = &hw->local_dcbx_config; 5497 5495 5498 - if (i40e_is_tc_mqprio_enabled(pf)) 5499 - return pf->vsi[pf->lan_vsi]->mqprio_qopt.qopt.num_tc; 5496 + if (i40e_is_tc_mqprio_enabled(pf)) { 5497 + struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); 5498 + 5499 + return vsi->mqprio_qopt.qopt.num_tc; 5500 + } 5500 5501 5501 5502 /* If neither MQPRIO nor DCB is enabled, then always use single TC */ 5502 5503 if (!test_bit(I40E_FLAG_DCB_ENA, pf->flags)) ··· 5505 5504 5506 5505 /* SFP mode will be enabled for all TCs on port */ 5507 5506 if (!test_bit(I40E_FLAG_MFP_ENA, pf->flags)) 5508 - return i40e_dcb_get_num_tc(dcbcfg); 5507 + return i40e_dcb_get_num_tc(&pf->hw.local_dcbx_config); 5509 5508 5510 5509 /* MFP mode return count of enabled TCs for this PF */ 5511 5510 if (pf->hw.func_caps.iscsi) ··· 5915 5914 i40e_vsi_config_netdev_tc(vsi, enabled_tc); 5916 5915 out: 5917 5916 return ret; 5917 + } 5918 + 5919 + /** 5920 + * i40e_vsi_reconfig_tc - Reconfigure VSI Tx Scheduler for stored TC map 5921 + * @vsi: VSI to be reconfigured 5922 + * 5923 + * This reconfigures a particular VSI for TCs that are mapped to the 5924 + * TC bitmap stored previously for the VSI. 5925 + * 5926 + * Context: It is expected that the VSI queues have been quisced before 5927 + * calling this function. 5928 + * 5929 + * Return: 0 on success, negative value on failure 5930 + **/ 5931 + static int i40e_vsi_reconfig_tc(struct i40e_vsi *vsi) 5932 + { 5933 + u8 enabled_tc; 5934 + 5935 + enabled_tc = vsi->tc_config.enabled_tc; 5936 + vsi->tc_config.enabled_tc = 0; 5937 + 5938 + return i40e_vsi_config_tc(vsi, enabled_tc); 5918 5939 } 5919 5940 5920 5941 /** ··· 6501 6478 static bool i40e_setup_channel(struct i40e_pf *pf, struct i40e_vsi *vsi, 6502 6479 struct i40e_channel *ch) 6503 6480 { 6481 + struct i40e_vsi *main_vsi; 6504 6482 u8 vsi_type; 6505 6483 u16 seid; 6506 6484 int ret; ··· 6515 6491 } 6516 6492 6517 6493 /* underlying switching element */ 6518 - seid = pf->vsi[pf->lan_vsi]->uplink_seid; 6494 + main_vsi = i40e_pf_get_main_vsi(pf); 6495 + seid = main_vsi->uplink_seid; 6519 6496 6520 6497 /* create channel (VSI), configure TX rings */ 6521 6498 ret = i40e_setup_hw_channel(pf, vsi, ch, seid, vsi_type); ··· 6834 6809 /* - Enable all TCs for the LAN VSI 6835 6810 * - For all others keep them at TC0 for now 6836 6811 */ 6837 - if (v == pf->lan_vsi) 6812 + if (vsi->type == I40E_VSI_MAIN) 6838 6813 tc_map = i40e_pf_get_tc_map(pf); 6839 6814 else 6840 6815 tc_map = I40E_DEFAULT_TRAFFIC_CLASS; ··· 7073 7048 7074 7049 /* Configure Rx Packet Buffers in HW */ 7075 7050 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { 7076 - mfs_tc[i] = pf->vsi[pf->lan_vsi]->netdev->mtu; 7051 + struct i40e_vsi *main_vsi = i40e_pf_get_main_vsi(pf); 7052 + 7053 + mfs_tc[i] = main_vsi->netdev->mtu; 7077 7054 mfs_tc[i] += I40E_PACKET_HDR_PAD; 7078 7055 } 7079 7056 ··· 9141 9114 i40e_vsi_free_rx_resources(vsi); 9142 9115 err_setup_tx: 9143 9116 i40e_vsi_free_tx_resources(vsi); 9144 - if (vsi == pf->vsi[pf->lan_vsi]) 9117 + if (vsi->type == I40E_VSI_MAIN) 9145 9118 i40e_do_reset(pf, I40E_PF_RESET_FLAG, true); 9146 9119 9147 9120 return err; ··· 9832 9805 dev_warn(&pf->pdev->dev, "FD table did not flush, needs more time\n"); 9833 9806 } else { 9834 9807 /* replay sideband filters */ 9835 - i40e_fdir_filter_restore(pf->vsi[pf->lan_vsi]); 9808 + i40e_fdir_filter_restore(i40e_pf_get_main_vsi(pf)); 9836 9809 if (!disable_atr && !pf->fd_tcp4_filter_cnt) 9837 9810 clear_bit(__I40E_FD_ATR_AUTO_DISABLED, pf->state); 9838 9811 clear_bit(__I40E_FD_FLUSH_REQUESTED, pf->state); ··· 9930 9903 **/ 9931 9904 static void i40e_link_event(struct i40e_pf *pf) 9932 9905 { 9933 - struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; 9906 + struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); 9907 + struct i40e_veb *veb = i40e_pf_get_main_veb(pf); 9934 9908 u8 new_link_speed, old_link_speed; 9935 9909 bool new_link, old_link; 9936 9910 int status; ··· 9971 9943 /* Notify the base of the switch tree connected to 9972 9944 * the link. Floating VEBs are not notified. 9973 9945 */ 9974 - if (pf->lan_veb < I40E_MAX_VEB && pf->veb[pf->lan_veb]) 9975 - i40e_veb_link_event(pf->veb[pf->lan_veb], new_link); 9946 + if (veb) 9947 + i40e_veb_link_event(veb, new_link); 9976 9948 else 9977 9949 i40e_vsi_link_event(vsi, new_link); 9978 9950 ··· 10302 10274 **/ 10303 10275 static void i40e_enable_pf_switch_lb(struct i40e_pf *pf) 10304 10276 { 10305 - struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; 10277 + struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); 10306 10278 struct i40e_vsi_context ctxt; 10307 10279 int ret; 10308 10280 ··· 10338 10310 **/ 10339 10311 static void i40e_disable_pf_switch_lb(struct i40e_pf *pf) 10340 10312 { 10341 - struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; 10313 + struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); 10342 10314 struct i40e_vsi_context ctxt; 10343 10315 int ret; 10344 10316 ··· 10414 10386 10415 10387 if (veb->uplink_seid == pf->mac_seid) { 10416 10388 /* Check that the LAN VSI has VEB owning flag set */ 10417 - ctl_vsi = pf->vsi[pf->lan_vsi]; 10389 + ctl_vsi = i40e_pf_get_main_vsi(pf); 10418 10390 10419 10391 if (WARN_ON(ctl_vsi->veb_idx != veb->idx || 10420 10392 !(ctl_vsi->flags & I40E_VSI_FLAG_VEB_OWNER))) { ··· 10557 10529 **/ 10558 10530 static void i40e_fdir_sb_setup(struct i40e_pf *pf) 10559 10531 { 10560 - struct i40e_vsi *vsi; 10532 + struct i40e_vsi *main_vsi, *vsi; 10561 10533 10562 10534 /* quick workaround for an NVM issue that leaves a critical register 10563 10535 * uninitialized ··· 10582 10554 10583 10555 /* create a new VSI if none exists */ 10584 10556 if (!vsi) { 10585 - vsi = i40e_vsi_setup(pf, I40E_VSI_FDIR, 10586 - pf->vsi[pf->lan_vsi]->seid, 0); 10557 + main_vsi = i40e_pf_get_main_vsi(pf); 10558 + vsi = i40e_vsi_setup(pf, I40E_VSI_FDIR, main_vsi->seid, 0); 10587 10559 if (!vsi) { 10588 10560 dev_info(&pf->pdev->dev, "Couldn't create FDir VSI\n"); 10589 10561 clear_bit(I40E_FLAG_FD_SB_ENA, pf->flags); ··· 10862 10834 static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired) 10863 10835 { 10864 10836 const bool is_recovery_mode_reported = i40e_check_recovery_mode(pf); 10865 - struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; 10837 + struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); 10866 10838 struct i40e_hw *hw = &pf->hw; 10867 10839 struct i40e_veb *veb; 10868 10840 int ret; ··· 10871 10843 10872 10844 if (test_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf->state) && 10873 10845 is_recovery_mode_reported) 10874 - i40e_set_ethtool_ops(pf->vsi[pf->lan_vsi]->netdev); 10846 + i40e_set_ethtool_ops(vsi->netdev); 10875 10847 10876 10848 if (test_bit(__I40E_DOWN, pf->state) && 10877 10849 !test_bit(__I40E_RECOVERY_MODE, pf->state)) ··· 11295 11267 return; 11296 11268 11297 11269 if (!test_bit(__I40E_RECOVERY_MODE, pf->state)) { 11298 - i40e_detect_recover_hung(pf->vsi[pf->lan_vsi]); 11270 + i40e_detect_recover_hung(pf); 11299 11271 i40e_sync_filters_subtask(pf); 11300 11272 i40e_reset_subtask(pf); 11301 11273 i40e_handle_mdd_event(pf); ··· 11304 11276 i40e_fdir_reinit_subtask(pf); 11305 11277 if (test_and_clear_bit(__I40E_CLIENT_RESET, pf->state)) { 11306 11278 /* Client subtask will reopen next time through. */ 11307 - i40e_notify_client_of_netdev_close(pf->vsi[pf->lan_vsi], 11308 - true); 11279 + i40e_notify_client_of_netdev_close(pf, true); 11309 11280 } else { 11310 11281 i40e_client_subtask(pf); 11311 11282 if (test_and_clear_bit(__I40E_CLIENT_L2_CHANGE, 11312 11283 pf->state)) 11313 - i40e_notify_client_of_l2_param_changes( 11314 - pf->vsi[pf->lan_vsi]); 11284 + i40e_notify_client_of_l2_param_changes(pf); 11315 11285 } 11316 11286 i40e_sync_filters_subtask(pf); 11317 11287 } else { ··· 12017 11991 /* if not MSIX, give the one vector only to the LAN VSI */ 12018 11992 if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags)) 12019 11993 num_q_vectors = vsi->num_q_vectors; 12020 - else if (vsi == pf->vsi[pf->lan_vsi]) 11994 + else if (vsi->type == I40E_VSI_MAIN) 12021 11995 num_q_vectors = 1; 12022 11996 else 12023 11997 return -EINVAL; ··· 12423 12397 **/ 12424 12398 static int i40e_pf_config_rss(struct i40e_pf *pf) 12425 12399 { 12426 - struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; 12400 + struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); 12427 12401 u8 seed[I40E_HKEY_ARRAY_SIZE]; 12428 12402 u8 *lut; 12429 12403 struct i40e_hw *hw = &pf->hw; ··· 12495 12469 **/ 12496 12470 int i40e_reconfig_rss_queues(struct i40e_pf *pf, int queue_count) 12497 12471 { 12498 - struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; 12472 + struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); 12499 12473 int new_rss_size; 12500 12474 12501 12475 if (!test_bit(I40E_FLAG_RSS_ENA, pf->flags)) ··· 13134 13108 int rem; 13135 13109 13136 13110 /* Only for PF VSI for now */ 13137 - if (vsi->seid != pf->vsi[pf->lan_vsi]->seid) 13111 + if (vsi->type != I40E_VSI_MAIN) 13138 13112 return -EOPNOTSUPP; 13139 13113 13140 13114 /* Find the HW bridge for PF VSI */ ··· 13153 13127 13154 13128 /* Insert a new HW bridge */ 13155 13129 if (!veb) { 13156 - veb = i40e_veb_setup(pf, 0, vsi->uplink_seid, vsi->seid, 13130 + veb = i40e_veb_setup(pf, vsi->uplink_seid, vsi->seid, 13157 13131 vsi->tc_config.enabled_tc); 13158 13132 if (veb) { 13159 13133 veb->bridge_mode = mode; ··· 13202 13176 struct i40e_veb *veb; 13203 13177 13204 13178 /* Only for PF VSI for now */ 13205 - if (vsi->seid != pf->vsi[pf->lan_vsi]->seid) 13179 + if (vsi->type != I40E_VSI_MAIN) 13206 13180 return -EOPNOTSUPP; 13207 13181 13208 13182 /* Find the HW bridge for the PF VSI */ ··· 13784 13758 * the end, which is 4 bytes long, so force truncation of the 13785 13759 * original name by IFNAMSIZ - 4 13786 13760 */ 13787 - snprintf(netdev->name, IFNAMSIZ, "%.*sv%%d", 13788 - IFNAMSIZ - 4, 13789 - pf->vsi[pf->lan_vsi]->netdev->name); 13761 + struct i40e_vsi *main_vsi = i40e_pf_get_main_vsi(pf); 13762 + 13763 + snprintf(netdev->name, IFNAMSIZ, "%.*sv%%d", IFNAMSIZ - 4, 13764 + main_vsi->netdev->name); 13790 13765 eth_random_addr(mac_addr); 13791 13766 13792 13767 spin_lock_bh(&vsi->mac_filter_hash_lock); ··· 14154 14127 vsi->seid, vsi->uplink_seid); 14155 14128 return -ENODEV; 14156 14129 } 14157 - if (vsi == pf->vsi[pf->lan_vsi] && 14158 - !test_bit(__I40E_DOWN, pf->state)) { 14130 + if (vsi->type == I40E_VSI_MAIN && !test_bit(__I40E_DOWN, pf->state)) { 14159 14131 dev_info(&pf->pdev->dev, "Can't remove PF VSI\n"); 14160 14132 return -ENODEV; 14161 14133 } ··· 14298 14272 **/ 14299 14273 static struct i40e_vsi *i40e_vsi_reinit_setup(struct i40e_vsi *vsi) 14300 14274 { 14275 + struct i40e_vsi *main_vsi; 14301 14276 u16 alloc_queue_pairs; 14302 14277 struct i40e_pf *pf; 14303 - u8 enabled_tc; 14304 14278 int ret; 14305 14279 14306 14280 if (!vsi) ··· 14332 14306 /* Update the FW view of the VSI. Force a reset of TC and queue 14333 14307 * layout configurations. 14334 14308 */ 14335 - enabled_tc = pf->vsi[pf->lan_vsi]->tc_config.enabled_tc; 14336 - pf->vsi[pf->lan_vsi]->tc_config.enabled_tc = 0; 14337 - pf->vsi[pf->lan_vsi]->seid = pf->main_vsi_seid; 14338 - i40e_vsi_config_tc(pf->vsi[pf->lan_vsi], enabled_tc); 14309 + main_vsi = i40e_pf_get_main_vsi(pf); 14310 + main_vsi->seid = pf->main_vsi_seid; 14311 + i40e_vsi_reconfig_tc(main_vsi); 14312 + 14339 14313 if (vsi->type == I40E_VSI_MAIN) 14340 14314 i40e_rm_default_mac_filter(vsi, pf->hw.mac.perm_addr); 14341 14315 ··· 14409 14383 } 14410 14384 14411 14385 if (vsi->uplink_seid == pf->mac_seid) 14412 - veb = i40e_veb_setup(pf, 0, pf->mac_seid, vsi->seid, 14386 + veb = i40e_veb_setup(pf, pf->mac_seid, vsi->seid, 14413 14387 vsi->tc_config.enabled_tc); 14414 14388 else if ((vsi->flags & I40E_VSI_FLAG_VEB_OWNER) == 0) 14415 - veb = i40e_veb_setup(pf, 0, vsi->uplink_seid, vsi->seid, 14389 + veb = i40e_veb_setup(pf, vsi->uplink_seid, vsi->seid, 14416 14390 vsi->tc_config.enabled_tc); 14417 14391 if (veb) { 14418 - if (vsi->seid != pf->vsi[pf->lan_vsi]->seid) { 14392 + if (vsi->type != I40E_VSI_MAIN) { 14419 14393 dev_info(&vsi->back->pdev->dev, 14420 14394 "New VSI creation error, uplink seid of LAN VSI expected.\n"); 14421 14395 return NULL; ··· 14806 14780 /** 14807 14781 * i40e_veb_setup - Set up a VEB 14808 14782 * @pf: board private structure 14809 - * @flags: VEB setup flags 14810 14783 * @uplink_seid: the switch element to link to 14811 14784 * @vsi_seid: the initial VSI seid 14812 14785 * @enabled_tc: Enabled TC bit-map ··· 14818 14793 * Returns pointer to the successfully allocated VEB sw struct on 14819 14794 * success, otherwise returns NULL on failure. 14820 14795 **/ 14821 - struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 flags, 14822 - u16 uplink_seid, u16 vsi_seid, 14823 - u8 enabled_tc) 14796 + struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 uplink_seid, 14797 + u16 vsi_seid, u8 enabled_tc) 14824 14798 { 14825 14799 struct i40e_vsi *vsi = NULL; 14826 14800 struct i40e_veb *veb; ··· 14850 14826 if (veb_idx < 0) 14851 14827 goto err_alloc; 14852 14828 veb = pf->veb[veb_idx]; 14853 - veb->flags = flags; 14854 14829 veb->uplink_seid = uplink_seid; 14855 14830 veb->enabled_tc = (enabled_tc ? enabled_tc : 0x1); 14856 14831 ··· 14901 14878 /* Main VEB? */ 14902 14879 if (uplink_seid != pf->mac_seid) 14903 14880 break; 14904 - if (pf->lan_veb >= I40E_MAX_VEB) { 14881 + veb = i40e_pf_get_main_veb(pf); 14882 + if (!veb) { 14905 14883 int v; 14906 14884 14907 14885 /* find existing or else empty VEB */ ··· 14916 14892 pf->lan_veb = v; 14917 14893 } 14918 14894 } 14919 - if (pf->lan_veb >= I40E_MAX_VEB) 14895 + 14896 + /* Try to get again main VEB as pf->lan_veb may have changed */ 14897 + veb = i40e_pf_get_main_veb(pf); 14898 + if (!veb) 14920 14899 break; 14921 14900 14922 - pf->veb[pf->lan_veb]->seid = seid; 14923 - pf->veb[pf->lan_veb]->uplink_seid = pf->mac_seid; 14924 - pf->veb[pf->lan_veb]->pf = pf; 14901 + veb->seid = seid; 14902 + veb->uplink_seid = pf->mac_seid; 14903 + veb->pf = pf; 14925 14904 break; 14926 14905 case I40E_SWITCH_ELEMENT_TYPE_VSI: 14927 14906 if (num_reported != 1) ··· 15022 14995 **/ 15023 14996 static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit, bool lock_acquired) 15024 14997 { 14998 + struct i40e_vsi *main_vsi; 15025 14999 u16 flags = 0; 15026 15000 int ret; 15027 15001 ··· 15067 15039 } 15068 15040 15069 15041 /* first time setup */ 15070 - if (pf->lan_vsi == I40E_NO_VSI || reinit) { 15071 - struct i40e_vsi *vsi = NULL; 15042 + main_vsi = i40e_pf_get_main_vsi(pf); 15043 + if (!main_vsi || reinit) { 15044 + struct i40e_veb *veb; 15072 15045 u16 uplink_seid; 15073 15046 15074 15047 /* Set up the PF VSI associated with the PF's main VSI 15075 15048 * that is already in the HW switch 15076 15049 */ 15077 - if (pf->lan_veb < I40E_MAX_VEB && pf->veb[pf->lan_veb]) 15078 - uplink_seid = pf->veb[pf->lan_veb]->seid; 15050 + veb = i40e_pf_get_main_veb(pf); 15051 + if (veb) 15052 + uplink_seid = veb->seid; 15079 15053 else 15080 15054 uplink_seid = pf->mac_seid; 15081 - if (pf->lan_vsi == I40E_NO_VSI) 15082 - vsi = i40e_vsi_setup(pf, I40E_VSI_MAIN, uplink_seid, 0); 15055 + if (!main_vsi) 15056 + main_vsi = i40e_vsi_setup(pf, I40E_VSI_MAIN, 15057 + uplink_seid, 0); 15083 15058 else if (reinit) 15084 - vsi = i40e_vsi_reinit_setup(pf->vsi[pf->lan_vsi]); 15085 - if (!vsi) { 15059 + main_vsi = i40e_vsi_reinit_setup(main_vsi); 15060 + if (!main_vsi) { 15086 15061 dev_info(&pf->pdev->dev, "setup of MAIN VSI failed\n"); 15087 15062 i40e_cloud_filter_exit(pf); 15088 15063 i40e_fdir_teardown(pf); ··· 15093 15062 } 15094 15063 } else { 15095 15064 /* force a reset of TC and queue layout configurations */ 15096 - u8 enabled_tc = pf->vsi[pf->lan_vsi]->tc_config.enabled_tc; 15097 - 15098 - pf->vsi[pf->lan_vsi]->tc_config.enabled_tc = 0; 15099 - pf->vsi[pf->lan_vsi]->seid = pf->main_vsi_seid; 15100 - i40e_vsi_config_tc(pf->vsi[pf->lan_vsi], enabled_tc); 15065 + main_vsi->seid = pf->main_vsi_seid; 15066 + i40e_vsi_reconfig_tc(main_vsi); 15101 15067 } 15102 - i40e_vlan_stripping_disable(pf->vsi[pf->lan_vsi]); 15068 + i40e_vlan_stripping_disable(main_vsi); 15103 15069 15104 15070 i40e_fdir_sb_setup(pf); 15105 15071 ··· 15123 15095 rtnl_lock(); 15124 15096 15125 15097 /* repopulate tunnel port filters */ 15126 - udp_tunnel_nic_reset_ntf(pf->vsi[pf->lan_vsi]->netdev); 15098 + udp_tunnel_nic_reset_ntf(main_vsi->netdev); 15127 15099 15128 15100 if (!lock_acquired) 15129 15101 rtnl_unlock(); ··· 15267 15239 #define REMAIN(__x) (INFO_STRING_LEN - (__x)) 15268 15240 static void i40e_print_features(struct i40e_pf *pf) 15269 15241 { 15242 + struct i40e_vsi *main_vsi = i40e_pf_get_main_vsi(pf); 15270 15243 struct i40e_hw *hw = &pf->hw; 15271 15244 char *buf; 15272 15245 int i; ··· 15281 15252 i += scnprintf(&buf[i], REMAIN(i), " VFs: %d", pf->num_req_vfs); 15282 15253 #endif 15283 15254 i += scnprintf(&buf[i], REMAIN(i), " VSIs: %d QP: %d", 15284 - pf->hw.func_caps.num_vsis, 15285 - pf->vsi[pf->lan_vsi]->num_queue_pairs); 15255 + pf->hw.func_caps.num_vsis, main_vsi->num_queue_pairs); 15286 15256 if (test_bit(I40E_FLAG_RSS_ENA, pf->flags)) 15287 15257 i += scnprintf(&buf[i], REMAIN(i), " RSS"); 15288 15258 if (test_bit(I40E_FLAG_FD_ATR_ENA, pf->flags)) ··· 15945 15917 dev_info(&pdev->dev, "setup_pf_switch failed: %d\n", err); 15946 15918 goto err_vsis; 15947 15919 } 15948 - INIT_LIST_HEAD(&pf->vsi[pf->lan_vsi]->ch_list); 15920 + 15921 + vsi = i40e_pf_get_main_vsi(pf); 15922 + INIT_LIST_HEAD(&vsi->ch_list); 15949 15923 15950 15924 /* if FDIR VSI was set up, start it now */ 15951 15925 vsi = i40e_find_vsi_by_type(pf, I40E_VSI_FDIR); ··· 16250 16220 /* Client close must be called explicitly here because the timer 16251 16221 * has been stopped. 16252 16222 */ 16253 - i40e_notify_client_of_netdev_close(pf->vsi[pf->lan_vsi], false); 16223 + i40e_notify_client_of_netdev_close(pf, false); 16254 16224 16255 16225 i40e_fdir_teardown(pf); 16256 16226 ··· 16449 16419 **/ 16450 16420 static void i40e_enable_mc_magic_wake(struct i40e_pf *pf) 16451 16421 { 16422 + struct i40e_vsi *main_vsi = i40e_pf_get_main_vsi(pf); 16452 16423 struct i40e_hw *hw = &pf->hw; 16453 16424 u8 mac_addr[6]; 16454 16425 u16 flags = 0; 16455 16426 int ret; 16456 16427 16457 16428 /* Get current MAC address in case it's an LAA */ 16458 - if (pf->vsi[pf->lan_vsi] && pf->vsi[pf->lan_vsi]->netdev) { 16459 - ether_addr_copy(mac_addr, 16460 - pf->vsi[pf->lan_vsi]->netdev->dev_addr); 16429 + if (main_vsi && main_vsi->netdev) { 16430 + ether_addr_copy(mac_addr, main_vsi->netdev->dev_addr); 16461 16431 } else { 16462 16432 dev_err(&pf->pdev->dev, 16463 16433 "Failed to retrieve MAC address; using default\n"); ··· 16509 16479 /* Client close must be called explicitly here because the timer 16510 16480 * has been stopped. 16511 16481 */ 16512 - i40e_notify_client_of_netdev_close(pf->vsi[pf->lan_vsi], false); 16482 + i40e_notify_client_of_netdev_close(pf, false); 16513 16483 16514 16484 if (test_bit(I40E_HW_CAP_WOL_MC_MAGIC_PKT_WAKE, pf->hw.caps) && 16515 16485 pf->wol_en) ··· 16563 16533 /* Client close must be called explicitly here because the timer 16564 16534 * has been stopped. 16565 16535 */ 16566 - i40e_notify_client_of_netdev_close(pf->vsi[pf->lan_vsi], false); 16536 + i40e_notify_client_of_netdev_close(pf, false); 16567 16537 16568 16538 if (test_bit(I40E_HW_CAP_WOL_MC_MAGIC_PKT_WAKE, pf->hw.caps) && 16569 16539 pf->wol_en)
+4 -2
drivers/net/ethernet/intel/i40e/i40e_ptp.c
··· 1472 1472 **/ 1473 1473 void i40e_ptp_init(struct i40e_pf *pf) 1474 1474 { 1475 - struct net_device *netdev = pf->vsi[pf->lan_vsi]->netdev; 1475 + struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); 1476 + struct net_device *netdev = vsi->netdev; 1476 1477 struct i40e_hw *hw = &pf->hw; 1477 1478 u32 pf_id; 1478 1479 long err; ··· 1537 1536 **/ 1538 1537 void i40e_ptp_stop(struct i40e_pf *pf) 1539 1538 { 1539 + struct i40e_vsi *main_vsi = i40e_pf_get_main_vsi(pf); 1540 1540 struct i40e_hw *hw = &pf->hw; 1541 1541 u32 regval; 1542 1542 ··· 1557 1555 ptp_clock_unregister(pf->ptp_clock); 1558 1556 pf->ptp_clock = NULL; 1559 1557 dev_info(&pf->pdev->dev, "%s: removed PHC on %s\n", __func__, 1560 - pf->vsi[pf->lan_vsi]->netdev->name); 1558 + main_vsi->netdev->name); 1561 1559 } 1562 1560 1563 1561 if (i40e_is_ptp_pin_dev(&pf->hw)) {
+9 -7
drivers/net/ethernet/intel/i40e/i40e_txrx.c
··· 24 24 { 25 25 struct i40e_filter_program_desc *fdir_desc; 26 26 struct i40e_pf *pf = tx_ring->vsi->back; 27 - u32 flex_ptype, dtype_cmd; 27 + u32 flex_ptype, dtype_cmd, vsi_id; 28 28 u16 i; 29 29 30 30 /* grab the next descriptor */ ··· 42 42 flex_ptype |= FIELD_PREP(I40E_TXD_FLTR_QW0_PCTYPE_MASK, fdata->pctype); 43 43 44 44 /* Use LAN VSI Id if not programmed by user */ 45 - flex_ptype |= FIELD_PREP(I40E_TXD_FLTR_QW0_DEST_VSI_MASK, 46 - fdata->dest_vsi ? : pf->vsi[pf->lan_vsi]->id); 45 + vsi_id = fdata->dest_vsi ? : i40e_pf_get_main_vsi(pf)->id; 46 + flex_ptype |= FIELD_PREP(I40E_TXD_FLTR_QW0_DEST_VSI_MASK, vsi_id); 47 47 48 48 dtype_cmd = I40E_TX_DESC_DTYPE_FILTER_PROG; 49 49 ··· 861 861 862 862 /** 863 863 * i40e_detect_recover_hung - Function to detect and recover hung_queues 864 - * @vsi: pointer to vsi struct with tx queues 864 + * @pf: pointer to PF struct 865 865 * 866 - * VSI has netdev and netdev has TX queues. This function is to check each of 867 - * those TX queues if they are hung, trigger recovery by issuing SW interrupt. 866 + * LAN VSI has netdev and netdev has TX queues. This function is to check 867 + * each of those TX queues if they are hung, trigger recovery by issuing 868 + * SW interrupt. 868 869 **/ 869 - void i40e_detect_recover_hung(struct i40e_vsi *vsi) 870 + void i40e_detect_recover_hung(struct i40e_pf *pf) 870 871 { 872 + struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); 871 873 struct i40e_ring *tx_ring = NULL; 872 874 struct net_device *netdev; 873 875 unsigned int i;
+1 -1
drivers/net/ethernet/intel/i40e/i40e_txrx.h
··· 470 470 int i40e_napi_poll(struct napi_struct *napi, int budget); 471 471 void i40e_force_wb(struct i40e_vsi *vsi, struct i40e_q_vector *q_vector); 472 472 u32 i40e_get_tx_pending(struct i40e_ring *ring, bool in_sw); 473 - void i40e_detect_recover_hung(struct i40e_vsi *vsi); 473 + void i40e_detect_recover_hung(struct i40e_pf *pf); 474 474 int __i40e_maybe_stop_tx(struct i40e_ring *tx_ring, int size); 475 475 bool __i40e_chk_linearize(struct sk_buff *skb); 476 476 int i40e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
+8 -6
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
··· 795 795 static int i40e_alloc_vsi_res(struct i40e_vf *vf, u8 idx) 796 796 { 797 797 struct i40e_mac_filter *f = NULL; 798 + struct i40e_vsi *main_vsi, *vsi; 798 799 struct i40e_pf *pf = vf->pf; 799 - struct i40e_vsi *vsi; 800 800 u64 max_tx_rate = 0; 801 801 int ret = 0; 802 802 803 - vsi = i40e_vsi_setup(pf, I40E_VSI_SRIOV, pf->vsi[pf->lan_vsi]->seid, 804 - vf->vf_id); 803 + main_vsi = i40e_pf_get_main_vsi(pf); 804 + vsi = i40e_vsi_setup(pf, I40E_VSI_SRIOV, main_vsi->seid, vf->vf_id); 805 805 806 806 if (!vsi) { 807 807 dev_err(&pf->pdev->dev, ··· 3322 3322 static int i40e_vc_rdma_msg(struct i40e_vf *vf, u8 *msg, u16 msglen) 3323 3323 { 3324 3324 struct i40e_pf *pf = vf->pf; 3325 - int abs_vf_id = vf->vf_id + pf->hw.func_caps.vf_base_id; 3325 + struct i40e_vsi *main_vsi; 3326 3326 int aq_ret = 0; 3327 + int abs_vf_id; 3327 3328 3328 3329 if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) || 3329 3330 !test_bit(I40E_VF_STATE_RDMAENA, &vf->vf_states)) { ··· 3332 3331 goto error_param; 3333 3332 } 3334 3333 3335 - i40e_notify_client_of_vf_msg(pf->vsi[pf->lan_vsi], abs_vf_id, 3336 - msg, msglen); 3334 + main_vsi = i40e_pf_get_main_vsi(pf); 3335 + abs_vf_id = vf->vf_id + pf->hw.func_caps.vf_base_id; 3336 + i40e_notify_client_of_vf_msg(main_vsi, abs_vf_id, msg, msglen); 3337 3337 3338 3338 error_param: 3339 3339 /* send the response to the VF */