Skip to content

Commit 4b81644

Browse files
Alexander DuyckJeff Kirsher
authored andcommitted
i40e: Add common function for finding VSI by type
This patch adds a common method for finding a VSI by type. The main motivation for doing this is that the Flow Director path actually had two ways of handling this, one stopped on first match and one did not. This patch makes it so that all callers of this function will get the same approach for finding a VSI. Change-ID: Ibf25de8acd8466582520694424aa87da66965fbd Signed-off-by: Alexander Duyck <[email protected]> Signed-off-by: Bimmy Pujari <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 7d3f04a commit 4b81644

File tree

4 files changed

+27
-30
lines changed

4 files changed

+27
-30
lines changed

drivers/net/ethernet/intel/i40e/i40e.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,25 @@ int i40e_get_rss(struct i40e_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size);
723723
void i40e_fill_rss_lut(struct i40e_pf *pf, u8 *lut,
724724
u16 rss_table_size, u16 rss_size);
725725
struct i40e_vsi *i40e_find_vsi_from_id(struct i40e_pf *pf, u16 id);
726+
/**
727+
* i40e_find_vsi_by_type - Find and return Flow Director VSI
728+
* @pf: PF to search for VSI
729+
* @type: Value indicating type of VSI we are looking for
730+
**/
731+
static inline struct i40e_vsi *
732+
i40e_find_vsi_by_type(struct i40e_pf *pf, u16 type)
733+
{
734+
int i;
735+
736+
for (i = 0; i < pf->num_alloc_vsi; i++) {
737+
struct i40e_vsi *vsi = pf->vsi[i];
738+
739+
if (vsi && vsi->type == type)
740+
return vsi;
741+
}
742+
743+
return NULL;
744+
}
726745
void i40e_update_stats(struct i40e_vsi *vsi);
727746
void i40e_update_eth_stats(struct i40e_vsi *vsi);
728747
struct rtnl_link_stats64 *i40e_get_vsi_stats_struct(struct i40e_vsi *vsi);

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,17 +1768,7 @@ static inline bool i40e_active_vfs(struct i40e_pf *pf)
17681768

17691769
static inline bool i40e_active_vmdqs(struct i40e_pf *pf)
17701770
{
1771-
struct i40e_vsi **vsi = pf->vsi;
1772-
int i;
1773-
1774-
for (i = 0; i < pf->num_alloc_vsi; i++) {
1775-
if (!vsi[i])
1776-
continue;
1777-
if (vsi[i]->type == I40E_VSI_VMDQ2)
1778-
return true;
1779-
}
1780-
1781-
return false;
1771+
return !!i40e_find_vsi_by_type(pf, I40E_VSI_VMDQ2);
17821772
}
17831773

17841774
static void i40e_diag_test(struct net_device *netdev,

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

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6718,7 +6718,6 @@ static int i40e_vsi_clear(struct i40e_vsi *vsi);
67186718
static void i40e_fdir_sb_setup(struct i40e_pf *pf)
67196719
{
67206720
struct i40e_vsi *vsi;
6721-
int i;
67226721

67236722
/* quick workaround for an NVM issue that leaves a critical register
67246723
* uninitialized
@@ -6729,6 +6728,7 @@ static void i40e_fdir_sb_setup(struct i40e_pf *pf)
67296728
0xeacb7d61, 0xaa4f05b6, 0x9c5c89ed, 0xfc425ddb,
67306729
0xa4654832, 0xfc7461d4, 0x8f827619, 0xf5c63c21,
67316730
0x95b3a76d};
6731+
int i;
67326732

67336733
for (i = 0; i <= I40E_GLQF_HKEY_MAX_INDEX; i++)
67346734
wr32(&pf->hw, I40E_GLQF_HKEY(i), hkey[i]);
@@ -6738,13 +6738,7 @@ static void i40e_fdir_sb_setup(struct i40e_pf *pf)
67386738
return;
67396739

67406740
/* find existing VSI and see if it needs configuring */
6741-
vsi = NULL;
6742-
for (i = 0; i < pf->num_alloc_vsi; i++) {
6743-
if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) {
6744-
vsi = pf->vsi[i];
6745-
break;
6746-
}
6747-
}
6741+
vsi = i40e_find_vsi_by_type(pf, I40E_VSI_FDIR);
67486742

67496743
/* create a new VSI if none exists */
67506744
if (!vsi) {
@@ -6766,15 +6760,12 @@ static void i40e_fdir_sb_setup(struct i40e_pf *pf)
67666760
**/
67676761
static void i40e_fdir_teardown(struct i40e_pf *pf)
67686762
{
6769-
int i;
6763+
struct i40e_vsi *vsi;
67706764

67716765
i40e_fdir_filter_exit(pf);
6772-
for (i = 0; i < pf->num_alloc_vsi; i++) {
6773-
if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) {
6774-
i40e_vsi_release(pf->vsi[i]);
6775-
break;
6776-
}
6777-
}
6766+
vsi = i40e_find_vsi_by_type(pf, I40E_VSI_FDIR);
6767+
if (vsi)
6768+
i40e_vsi_release(vsi);
67786769
}
67796770

67806771
/**

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,7 @@ static int i40e_program_fdir_filter(struct i40e_fdir_filter *fdir_data,
125125
u16 i;
126126

127127
/* find existing FDIR VSI */
128-
vsi = NULL;
129-
for (i = 0; i < pf->num_alloc_vsi; i++)
130-
if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR)
131-
vsi = pf->vsi[i];
128+
vsi = i40e_find_vsi_by_type(pf, I40E_VSI_FDIR);
132129
if (!vsi)
133130
return -ENOENT;
134131

0 commit comments

Comments
 (0)