]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
i40e: Consolidate checks whether given VSI is main
authorIvan Vecera <ivecera@redhat.com>
Sat, 27 Apr 2024 07:26:06 +0000 (09:26 +0200)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Tue, 30 Apr 2024 16:33:07 +0000 (09:33 -0700)
In the driver code there are 3 types of checks whether given
VSI is main or not:
1. vsi->type ==/!= I40E_VSI_MAIN
2. vsi ==/!= pf->vsi[pf->lan_vsi]
3. vsi->seid ==/!= pf->vsi[pf->lan_vsi]->seid

All of them are equivalent and can be consolidated. Convert cases
2 and 3 to case 1.

Reviewed-by: Michal Schmidt <mschmidt@redhat.com>
Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/i40e/i40e_debugfs.c
drivers/net/ethernet/intel/i40e/i40e_ethtool.c
drivers/net/ethernet/intel/i40e/i40e_main.c

index 09db46de29940a8c1a56c1e7e176ae0ecac0b9de..abf624d770e670f7da6e2454acce50e899fdb2b4 100644 (file)
@@ -129,7 +129,7 @@ static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid)
                dev_info(&pf->pdev->dev,
                         "    state[%d] = %08lx\n",
                         i, vsi->state[i]);
-       if (vsi == pf->vsi[pf->lan_vsi])
+       if (vsi->type == I40E_VSI_MAIN)
                dev_info(&pf->pdev->dev, "    MAC address: %pM Port MAC: %pM\n",
                         pf->hw.mac.addr,
                         pf->hw.mac.port_addr);
index 0905c1fb23373ba14aa4cb5480594cd5b44daf9a..5cd0d1b45f0171f407969991ff8b4685e5e43260 100644 (file)
@@ -1241,7 +1241,7 @@ static int i40e_set_link_ksettings(struct net_device *netdev,
                i40e_partition_setting_complaint(pf);
                return -EOPNOTSUPP;
        }
-       if (vsi != pf->vsi[pf->lan_vsi])
+       if (vsi->type != I40E_VSI_MAIN)
                return -EOPNOTSUPP;
        if (hw->phy.media_type != I40E_MEDIA_TYPE_BASET &&
            hw->phy.media_type != I40E_MEDIA_TYPE_FIBER &&
@@ -1710,7 +1710,7 @@ static int i40e_set_pauseparam(struct net_device *netdev,
                return -EOPNOTSUPP;
        }
 
-       if (vsi != pf->vsi[pf->lan_vsi])
+       if (vsi->type != I40E_VSI_MAIN)
                return -EOPNOTSUPP;
 
        is_an = hw_link_info->an_info & I40E_AQ_AN_COMPLETED;
@@ -2292,7 +2292,7 @@ static int i40e_get_stats_count(struct net_device *netdev)
        struct i40e_pf *pf = vsi->back;
        int stats_len;
 
-       if (vsi == pf->vsi[pf->lan_vsi] && pf->hw.partition_id == 1)
+       if (vsi->type == I40E_VSI_MAIN && pf->hw.partition_id == 1)
                stats_len = I40E_PF_STATS_LEN;
        else
                stats_len = I40E_VSI_STATS_LEN;
@@ -2422,7 +2422,7 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
        }
        rcu_read_unlock();
 
-       if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1)
+       if (vsi->type != I40E_VSI_MAIN || pf->hw.partition_id != 1)
                goto check_data_pointer;
 
        veb_stats = ((pf->lan_veb != I40E_NO_VEB) &&
@@ -2495,7 +2495,7 @@ static void i40e_get_stat_strings(struct net_device *netdev, u8 *data)
                                      "rx", i);
        }
 
-       if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1)
+       if (vsi->type != I40E_VSI_MAIN || pf->hw.partition_id != 1)
                goto check_data_pointer;
 
        i40e_add_stat_strings(&data, i40e_gstrings_veb_stats);
@@ -2792,7 +2792,7 @@ static int i40e_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
                return -EOPNOTSUPP;
        }
 
-       if (vsi != pf->vsi[pf->lan_vsi])
+       if (vsi->type != I40E_VSI_MAIN)
                return -EOPNOTSUPP;
 
        /* NVM bit on means WoL disabled for the port */
index e45a556b19bbeedd35691024af416c3239c39041..85d609ad81dce54d8b49070e04adc33c93d77f0a 100644 (file)
@@ -990,7 +990,7 @@ static void i40e_update_vsi_stats(struct i40e_vsi *vsi)
        ns->tx_dropped = es->tx_discards;
 
        /* pull in a couple PF stats if this is the main vsi */
-       if (vsi == pf->vsi[pf->lan_vsi]) {
+       if (vsi->type == I40E_VSI_MAIN) {
                ns->rx_crc_errors = pf->stats.crc_errors;
                ns->rx_errors = pf->stats.crc_errors + pf->stats.illegal_bytes;
                ns->rx_length_errors = pf->stats.rx_length_errors;
@@ -1235,7 +1235,7 @@ void i40e_update_stats(struct i40e_vsi *vsi)
 {
        struct i40e_pf *pf = vsi->back;
 
-       if (vsi == pf->vsi[pf->lan_vsi])
+       if (vsi->type == I40E_VSI_MAIN)
                i40e_update_pf_stats(pf);
 
        i40e_update_vsi_stats(vsi);
@@ -6812,7 +6812,7 @@ static void i40e_dcb_reconfigure(struct i40e_pf *pf)
                /* - Enable all TCs for the LAN VSI
                 * - For all others keep them at TC0 for now
                 */
-               if (v == pf->lan_vsi)
+               if (vsi->type == I40E_VSI_MAIN)
                        tc_map = i40e_pf_get_tc_map(pf);
                else
                        tc_map = I40E_DEFAULT_TRAFFIC_CLASS;
@@ -9119,7 +9119,7 @@ err_setup_rx:
        i40e_vsi_free_rx_resources(vsi);
 err_setup_tx:
        i40e_vsi_free_tx_resources(vsi);
-       if (vsi == pf->vsi[pf->lan_vsi])
+       if (vsi->type == I40E_VSI_MAIN)
                i40e_do_reset(pf, I40E_PF_RESET_FLAG, true);
 
        return err;
@@ -11994,7 +11994,7 @@ static int i40e_vsi_alloc_q_vectors(struct i40e_vsi *vsi)
        /* if not MSIX, give the one vector only to the LAN VSI */
        if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags))
                num_q_vectors = vsi->num_q_vectors;
-       else if (vsi == pf->vsi[pf->lan_vsi])
+       else if (vsi->type == I40E_VSI_MAIN)
                num_q_vectors = 1;
        else
                return -EINVAL;
@@ -13111,7 +13111,7 @@ static int i40e_ndo_bridge_setlink(struct net_device *dev,
        int rem;
 
        /* Only for PF VSI for now */
-       if (vsi->seid != pf->vsi[pf->lan_vsi]->seid)
+       if (vsi->type != I40E_VSI_MAIN)
                return -EOPNOTSUPP;
 
        /* Find the HW bridge for PF VSI */
@@ -13179,7 +13179,7 @@ static int i40e_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
        struct i40e_veb *veb;
 
        /* Only for PF VSI for now */
-       if (vsi->seid != pf->vsi[pf->lan_vsi]->seid)
+       if (vsi->type != I40E_VSI_MAIN)
                return -EOPNOTSUPP;
 
        /* Find the HW bridge for the PF VSI */
@@ -14131,8 +14131,7 @@ int i40e_vsi_release(struct i40e_vsi *vsi)
                         vsi->seid, vsi->uplink_seid);
                return -ENODEV;
        }
-       if (vsi == pf->vsi[pf->lan_vsi] &&
-           !test_bit(__I40E_DOWN, pf->state)) {
+       if (vsi->type == I40E_VSI_MAIN && !test_bit(__I40E_DOWN, pf->state)) {
                dev_info(&pf->pdev->dev, "Can't remove PF VSI\n");
                return -ENODEV;
        }
@@ -14396,7 +14395,7 @@ struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type,
                        veb = i40e_veb_setup(pf, vsi->uplink_seid, vsi->seid,
                                             vsi->tc_config.enabled_tc);
                if (veb) {
-                       if (vsi->seid != pf->vsi[pf->lan_vsi]->seid) {
+                       if (vsi->type != I40E_VSI_MAIN) {
                                dev_info(&vsi->back->pdev->dev,
                                         "New VSI creation error, uplink seid of LAN VSI expected.\n");
                                return NULL;