Skip to content

Commit 6c8e355

Browse files
iveceraanguy11
authored andcommitted
i40e: Consolidate checks whether given VSI is main
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>
1 parent 43f4466 commit 6c8e355

3 files changed

Lines changed: 16 additions & 17 deletions

File tree

drivers/net/ethernet/intel/i40e/i40e_debugfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid)
129129
dev_info(&pf->pdev->dev,
130130
" state[%d] = %08lx\n",
131131
i, vsi->state[i]);
132-
if (vsi == pf->vsi[pf->lan_vsi])
132+
if (vsi->type == I40E_VSI_MAIN)
133133
dev_info(&pf->pdev->dev, " MAC address: %pM Port MAC: %pM\n",
134134
pf->hw.mac.addr,
135135
pf->hw.mac.port_addr);

drivers/net/ethernet/intel/i40e/i40e_ethtool.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ static int i40e_set_link_ksettings(struct net_device *netdev,
12411241
i40e_partition_setting_complaint(pf);
12421242
return -EOPNOTSUPP;
12431243
}
1244-
if (vsi != pf->vsi[pf->lan_vsi])
1244+
if (vsi->type != I40E_VSI_MAIN)
12451245
return -EOPNOTSUPP;
12461246
if (hw->phy.media_type != I40E_MEDIA_TYPE_BASET &&
12471247
hw->phy.media_type != I40E_MEDIA_TYPE_FIBER &&
@@ -1710,7 +1710,7 @@ static int i40e_set_pauseparam(struct net_device *netdev,
17101710
return -EOPNOTSUPP;
17111711
}
17121712

1713-
if (vsi != pf->vsi[pf->lan_vsi])
1713+
if (vsi->type != I40E_VSI_MAIN)
17141714
return -EOPNOTSUPP;
17151715

17161716
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)
22922292
struct i40e_pf *pf = vsi->back;
22932293
int stats_len;
22942294

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)
22962296
stats_len = I40E_PF_STATS_LEN;
22972297
else
22982298
stats_len = I40E_VSI_STATS_LEN;
@@ -2422,7 +2422,7 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
24222422
}
24232423
rcu_read_unlock();
24242424

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)
24262426
goto check_data_pointer;
24272427

24282428
veb_stats = ((pf->lan_veb != I40E_NO_VEB) &&
@@ -2495,7 +2495,7 @@ static void i40e_get_stat_strings(struct net_device *netdev, u8 *data)
24952495
"rx", i);
24962496
}
24972497

2498-
if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1)
2498+
if (vsi->type != I40E_VSI_MAIN || pf->hw.partition_id != 1)
24992499
goto check_data_pointer;
25002500

25012501
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)
27922792
return -EOPNOTSUPP;
27932793
}
27942794

2795-
if (vsi != pf->vsi[pf->lan_vsi])
2795+
if (vsi->type != I40E_VSI_MAIN)
27962796
return -EOPNOTSUPP;
27972797

27982798
/* NVM bit on means WoL disabled for the port */

drivers/net/ethernet/intel/i40e/i40e_main.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ static void i40e_update_vsi_stats(struct i40e_vsi *vsi)
990990
ns->tx_dropped = es->tx_discards;
991991

992992
/* 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) {
994994
ns->rx_crc_errors = pf->stats.crc_errors;
995995
ns->rx_errors = pf->stats.crc_errors + pf->stats.illegal_bytes;
996996
ns->rx_length_errors = pf->stats.rx_length_errors;
@@ -1235,7 +1235,7 @@ void i40e_update_stats(struct i40e_vsi *vsi)
12351235
{
12361236
struct i40e_pf *pf = vsi->back;
12371237

1238-
if (vsi == pf->vsi[pf->lan_vsi])
1238+
if (vsi->type == I40E_VSI_MAIN)
12391239
i40e_update_pf_stats(pf);
12401240

12411241
i40e_update_vsi_stats(vsi);
@@ -6812,7 +6812,7 @@ static void i40e_dcb_reconfigure(struct i40e_pf *pf)
68126812
/* - Enable all TCs for the LAN VSI
68136813
* - For all others keep them at TC0 for now
68146814
*/
6815-
if (v == pf->lan_vsi)
6815+
if (vsi->type == I40E_VSI_MAIN)
68166816
tc_map = i40e_pf_get_tc_map(pf);
68176817
else
68186818
tc_map = I40E_DEFAULT_TRAFFIC_CLASS;
@@ -9119,7 +9119,7 @@ int i40e_vsi_open(struct i40e_vsi *vsi)
91199119
i40e_vsi_free_rx_resources(vsi);
91209120
err_setup_tx:
91219121
i40e_vsi_free_tx_resources(vsi);
9122-
if (vsi == pf->vsi[pf->lan_vsi])
9122+
if (vsi->type == I40E_VSI_MAIN)
91239123
i40e_do_reset(pf, I40E_PF_RESET_FLAG, true);
91249124

91259125
return err;
@@ -11994,7 +11994,7 @@ static int i40e_vsi_alloc_q_vectors(struct i40e_vsi *vsi)
1199411994
/* if not MSIX, give the one vector only to the LAN VSI */
1199511995
if (test_bit(I40E_FLAG_MSIX_ENA, pf->flags))
1199611996
num_q_vectors = vsi->num_q_vectors;
11997-
else if (vsi == pf->vsi[pf->lan_vsi])
11997+
else if (vsi->type == I40E_VSI_MAIN)
1199811998
num_q_vectors = 1;
1199911999
else
1200012000
return -EINVAL;
@@ -13111,7 +13111,7 @@ static int i40e_ndo_bridge_setlink(struct net_device *dev,
1311113111
int rem;
1311213112

1311313113
/* Only for PF VSI for now */
13114-
if (vsi->seid != pf->vsi[pf->lan_vsi]->seid)
13114+
if (vsi->type != I40E_VSI_MAIN)
1311513115
return -EOPNOTSUPP;
1311613116

1311713117
/* 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,
1317913179
struct i40e_veb *veb;
1318013180

1318113181
/* Only for PF VSI for now */
13182-
if (vsi->seid != pf->vsi[pf->lan_vsi]->seid)
13182+
if (vsi->type != I40E_VSI_MAIN)
1318313183
return -EOPNOTSUPP;
1318413184

1318513185
/* Find the HW bridge for the PF VSI */
@@ -14131,8 +14131,7 @@ int i40e_vsi_release(struct i40e_vsi *vsi)
1413114131
vsi->seid, vsi->uplink_seid);
1413214132
return -ENODEV;
1413314133
}
14134-
if (vsi == pf->vsi[pf->lan_vsi] &&
14135-
!test_bit(__I40E_DOWN, pf->state)) {
14134+
if (vsi->type == I40E_VSI_MAIN && !test_bit(__I40E_DOWN, pf->state)) {
1413614135
dev_info(&pf->pdev->dev, "Can't remove PF VSI\n");
1413714136
return -ENODEV;
1413814137
}
@@ -14396,7 +14395,7 @@ struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type,
1439614395
veb = i40e_veb_setup(pf, vsi->uplink_seid, vsi->seid,
1439714396
vsi->tc_config.enabled_tc);
1439814397
if (veb) {
14399-
if (vsi->seid != pf->vsi[pf->lan_vsi]->seid) {
14398+
if (vsi->type != I40E_VSI_MAIN) {
1440014399
dev_info(&vsi->back->pdev->dev,
1440114400
"New VSI creation error, uplink seid of LAN VSI expected.\n");
1440214401
return NULL;

0 commit comments

Comments
 (0)