Skip to content

Commit 0db66d2

Browse files
Michal Swiatkowskianguy11
authored andcommitted
ice: cleanup in VSI config/deconfig code
Do few small cleanups: 1) Rename the function to reflect that it doesn't configure all things related to VSI. ice_vsi_cfg_lan() better fits to what function is doing. ice_vsi_cfg() can be use to name function that will configure whole VSI. 2) Remove unused ethtype field from VSI. There is no need to set ethtype here, because it is never used. 3) Remove unnecessary check for ICE_VSI_CHNL. There is check for ICE_VSI_CHNL in ice_vsi_get_qs, so there is no need to check it before calling the function. 4) Simplify ice_vsi_alloc() call. There is no need to check the type of VSI before calling ice_vsi_alloc(). For ICE_VSI_CHNL vf is always NULL (ice_vsi_setup() is called with vf=NULL). For ICE_VSI_VF or ICE_VSI_CTRL ch is always NULL and for other VSI types ch and vf are always NULL. 5) Remove unnecessary call to ice_vsi_dis_irq(). ice_vsi_dis_irq() will be called in ice_vsi_close() flow (ice_vsi_close() -> ice_vsi_down() -> ice_vsi_dis_irq()). Remove unnecessary call. 6) Don't remove specific filters in release. All hw filters are removed in ice_fltr_remove_alli(), which is always called in VSI release flow. There is no need to remove only ethertype filters before calling ice_fltr_remove_all(). 7) Rename ice_vsi_clear() to ice_vsi_free(). As ice_vsi_clear() only free memory allocated in ice_vsi_alloc() rename it to ice_vsi_free() which better shows what function is doing. 8) Free coalesce param in rebuild. There is potential memory leak if configuration of VSI lan fails. Free coalesce to avoid it. Signed-off-by: Michal Swiatkowski <[email protected]> Tested-by: Gurucharan G <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]>
1 parent 2be2928 commit 0db66d2

File tree

5 files changed

+26
-44
lines changed

5 files changed

+26
-44
lines changed

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ struct ice_vsi {
353353

354354
struct ice_vf *vf; /* VF associated with this VSI */
355355

356-
u16 ethtype; /* Ethernet protocol for pause frame */
357356
u16 num_gfltr;
358357
u16 num_bfltr;
359358

@@ -889,7 +888,7 @@ ice_fetch_u64_stats_per_ring(struct u64_stats_sync *syncp,
889888
int ice_up(struct ice_vsi *vsi);
890889
int ice_down(struct ice_vsi *vsi);
891890
int ice_down_up(struct ice_vsi *vsi);
892-
int ice_vsi_cfg(struct ice_vsi *vsi);
891+
int ice_vsi_cfg_lan(struct ice_vsi *vsi);
893892
struct ice_vsi *ice_lb_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi);
894893
int ice_vsi_determine_xdp_res(struct ice_vsi *vsi);
895894
int ice_prepare_xdp_rings(struct ice_vsi *vsi, struct bpf_prog *prog);

drivers/net/ethernet/intel/ice/ice_ethtool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ static int ice_lbtest_prepare_rings(struct ice_vsi *vsi)
656656
if (status)
657657
goto err_setup_rx_ring;
658658

659-
status = ice_vsi_cfg(vsi);
659+
status = ice_vsi_cfg_lan(vsi);
660660
if (status)
661661
goto err_setup_rx_ring;
662662

drivers/net/ethernet/intel/ice/ice_lib.c

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -348,15 +348,15 @@ static void ice_vsi_free_arrays(struct ice_vsi *vsi)
348348
}
349349

350350
/**
351-
* ice_vsi_clear - clean up and deallocate the provided VSI
351+
* ice_vsi_free - clean up and deallocate the provided VSI
352352
* @vsi: pointer to VSI being cleared
353353
*
354354
* This deallocates the VSI's queue resources, removes it from the PF's
355355
* VSI array if necessary, and deallocates the VSI
356356
*
357357
* Returns 0 on success, negative on failure
358358
*/
359-
int ice_vsi_clear(struct ice_vsi *vsi)
359+
int ice_vsi_free(struct ice_vsi *vsi)
360360
{
361361
struct ice_pf *pf = NULL;
362362
struct device *dev;
@@ -2668,12 +2668,7 @@ ice_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi,
26682668
struct ice_vsi *vsi;
26692669
int ret, i;
26702670

2671-
if (vsi_type == ICE_VSI_CHNL)
2672-
vsi = ice_vsi_alloc(pf, vsi_type, ch, NULL);
2673-
else if (vsi_type == ICE_VSI_VF || vsi_type == ICE_VSI_CTRL)
2674-
vsi = ice_vsi_alloc(pf, vsi_type, NULL, vf);
2675-
else
2676-
vsi = ice_vsi_alloc(pf, vsi_type, NULL, NULL);
2671+
vsi = ice_vsi_alloc(pf, vsi_type, ch, vf);
26772672

26782673
if (!vsi) {
26792674
dev_err(dev, "could not allocate VSI\n");
@@ -2682,17 +2677,13 @@ ice_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi,
26822677

26832678
vsi->port_info = pi;
26842679
vsi->vsw = pf->first_sw;
2685-
if (vsi->type == ICE_VSI_PF)
2686-
vsi->ethtype = ETH_P_PAUSE;
26872680

26882681
ice_alloc_fd_res(vsi);
26892682

2690-
if (vsi_type != ICE_VSI_CHNL) {
2691-
if (ice_vsi_get_qs(vsi)) {
2692-
dev_err(dev, "Failed to allocate queues. vsi->idx = %d\n",
2693-
vsi->idx);
2694-
goto unroll_vsi_alloc;
2695-
}
2683+
if (ice_vsi_get_qs(vsi)) {
2684+
dev_err(dev, "Failed to allocate queues. vsi->idx = %d\n",
2685+
vsi->idx);
2686+
goto unroll_vsi_alloc;
26962687
}
26972688

26982689
/* set RSS capabilities */
@@ -2857,7 +2848,7 @@ ice_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi,
28572848
unroll_vsi_alloc:
28582849
if (vsi_type == ICE_VSI_VF)
28592850
ice_enable_lag(pf->lag);
2860-
ice_vsi_clear(vsi);
2851+
ice_vsi_free(vsi);
28612852

28622853
return NULL;
28632854
}
@@ -3181,9 +3172,6 @@ int ice_vsi_release(struct ice_vsi *vsi)
31813172
if (test_bit(ICE_FLAG_RSS_ENA, pf->flags))
31823173
ice_rss_clean(vsi);
31833174

3184-
/* Disable VSI and free resources */
3185-
if (vsi->type != ICE_VSI_LB)
3186-
ice_vsi_dis_irq(vsi);
31873175
ice_vsi_close(vsi);
31883176

31893177
/* SR-IOV determines needed MSIX resources all at once instead of per
@@ -3199,18 +3187,12 @@ int ice_vsi_release(struct ice_vsi *vsi)
31993187
pf->num_avail_sw_msix += vsi->num_q_vectors;
32003188
}
32013189

3202-
if (!ice_is_safe_mode(pf)) {
3203-
if (vsi->type == ICE_VSI_PF) {
3204-
ice_fltr_remove_eth(vsi, ETH_P_PAUSE, ICE_FLTR_TX,
3205-
ICE_DROP_PACKET);
3206-
ice_cfg_sw_lldp(vsi, true, false);
3207-
/* The Rx rule will only exist to remove if the LLDP FW
3208-
* engine is currently stopped
3209-
*/
3210-
if (!test_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags))
3211-
ice_cfg_sw_lldp(vsi, false, false);
3212-
}
3213-
}
3190+
/* The Rx rule will only exist to remove if the LLDP FW
3191+
* engine is currently stopped
3192+
*/
3193+
if (!ice_is_safe_mode(pf) && vsi->type == ICE_VSI_PF &&
3194+
!test_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags))
3195+
ice_cfg_sw_lldp(vsi, false, false);
32143196

32153197
if (ice_is_vsi_dflt_vsi(vsi))
32163198
ice_clear_dflt_vsi(vsi);
@@ -3247,7 +3229,7 @@ int ice_vsi_release(struct ice_vsi *vsi)
32473229
* for ex: during rmmod.
32483230
*/
32493231
if (!ice_is_reset_in_progress(pf->state))
3250-
ice_vsi_clear(vsi);
3232+
ice_vsi_free(vsi);
32513233

32523234
return 0;
32533235
}
@@ -3601,6 +3583,7 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, bool init_vsi)
36013583
ret = -EIO;
36023584
goto err_vectors;
36033585
} else {
3586+
kfree(coalesce);
36043587
return ice_schedule_reset(pf, ICE_RESET_PFR);
36053588
}
36063589
}
@@ -3623,7 +3606,7 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, bool init_vsi)
36233606
vsi->netdev = NULL;
36243607
}
36253608
err_vsi:
3626-
ice_vsi_clear(vsi);
3609+
ice_vsi_free(vsi);
36273610
set_bit(ICE_RESET_FAILED, pf->state);
36283611
kfree(coalesce);
36293612
return ret;

drivers/net/ethernet/intel/ice/ice_lib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void ice_cfg_sw_lldp(struct ice_vsi *vsi, bool tx, bool create);
4242
int ice_set_link(struct ice_vsi *vsi, bool ena);
4343

4444
void ice_vsi_delete(struct ice_vsi *vsi);
45-
int ice_vsi_clear(struct ice_vsi *vsi);
45+
int ice_vsi_free(struct ice_vsi *vsi);
4646

4747
int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc);
4848

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6128,12 +6128,12 @@ static int ice_vsi_vlan_setup(struct ice_vsi *vsi)
61286128
}
61296129

61306130
/**
6131-
* ice_vsi_cfg - Setup the VSI
6131+
* ice_vsi_cfg_lan - Setup the VSI lan related config
61326132
* @vsi: the VSI being configured
61336133
*
61346134
* Return 0 on success and negative value on error
61356135
*/
6136-
int ice_vsi_cfg(struct ice_vsi *vsi)
6136+
int ice_vsi_cfg_lan(struct ice_vsi *vsi)
61376137
{
61386138
int err;
61396139

@@ -6349,7 +6349,7 @@ int ice_up(struct ice_vsi *vsi)
63496349
{
63506350
int err;
63516351

6352-
err = ice_vsi_cfg(vsi);
6352+
err = ice_vsi_cfg_lan(vsi);
63536353
if (!err)
63546354
err = ice_up_complete(vsi);
63556355

@@ -6917,7 +6917,7 @@ int ice_vsi_open_ctrl(struct ice_vsi *vsi)
69176917
if (err)
69186918
goto err_setup_rx;
69196919

6920-
err = ice_vsi_cfg(vsi);
6920+
err = ice_vsi_cfg_lan(vsi);
69216921
if (err)
69226922
goto err_setup_rx;
69236923

@@ -6971,7 +6971,7 @@ int ice_vsi_open(struct ice_vsi *vsi)
69716971
if (err)
69726972
goto err_setup_rx;
69736973

6974-
err = ice_vsi_cfg(vsi);
6974+
err = ice_vsi_cfg_lan(vsi);
69756975
if (err)
69766976
goto err_setup_rx;
69776977

@@ -8405,7 +8405,7 @@ static void ice_remove_q_channels(struct ice_vsi *vsi, bool rem_fltr)
84058405
ice_vsi_delete(ch->ch_vsi);
84068406

84078407
/* Delete VSI from PF and HW VSI arrays */
8408-
ice_vsi_clear(ch->ch_vsi);
8408+
ice_vsi_free(ch->ch_vsi);
84098409

84108410
/* free the channel */
84118411
kfree(ch);

0 commit comments

Comments
 (0)