Commit 4b816446 authored by Alexander Duyck's avatar Alexander Duyck Committed by Jeff Kirsher

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: default avatarAlexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: default avatarBimmy Pujari <bimmy.pujari@intel.com>
Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 7d3f04af
...@@ -723,6 +723,25 @@ int i40e_get_rss(struct i40e_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size); ...@@ -723,6 +723,25 @@ int i40e_get_rss(struct i40e_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size);
void i40e_fill_rss_lut(struct i40e_pf *pf, u8 *lut, void i40e_fill_rss_lut(struct i40e_pf *pf, u8 *lut,
u16 rss_table_size, u16 rss_size); u16 rss_table_size, u16 rss_size);
struct i40e_vsi *i40e_find_vsi_from_id(struct i40e_pf *pf, u16 id); struct i40e_vsi *i40e_find_vsi_from_id(struct i40e_pf *pf, u16 id);
/**
* i40e_find_vsi_by_type - Find and return Flow Director VSI
* @pf: PF to search for VSI
* @type: Value indicating type of VSI we are looking for
**/
static inline struct i40e_vsi *
i40e_find_vsi_by_type(struct i40e_pf *pf, u16 type)
{
int i;
for (i = 0; i < pf->num_alloc_vsi; i++) {
struct i40e_vsi *vsi = pf->vsi[i];
if (vsi && vsi->type == type)
return vsi;
}
return NULL;
}
void i40e_update_stats(struct i40e_vsi *vsi); void i40e_update_stats(struct i40e_vsi *vsi);
void i40e_update_eth_stats(struct i40e_vsi *vsi); void i40e_update_eth_stats(struct i40e_vsi *vsi);
struct rtnl_link_stats64 *i40e_get_vsi_stats_struct(struct i40e_vsi *vsi); struct rtnl_link_stats64 *i40e_get_vsi_stats_struct(struct i40e_vsi *vsi);
......
...@@ -1768,17 +1768,7 @@ static inline bool i40e_active_vfs(struct i40e_pf *pf) ...@@ -1768,17 +1768,7 @@ static inline bool i40e_active_vfs(struct i40e_pf *pf)
static inline bool i40e_active_vmdqs(struct i40e_pf *pf) static inline bool i40e_active_vmdqs(struct i40e_pf *pf)
{ {
struct i40e_vsi **vsi = pf->vsi; return !!i40e_find_vsi_by_type(pf, I40E_VSI_VMDQ2);
int i;
for (i = 0; i < pf->num_alloc_vsi; i++) {
if (!vsi[i])
continue;
if (vsi[i]->type == I40E_VSI_VMDQ2)
return true;
}
return false;
} }
static void i40e_diag_test(struct net_device *netdev, static void i40e_diag_test(struct net_device *netdev,
......
...@@ -6718,7 +6718,6 @@ static int i40e_vsi_clear(struct i40e_vsi *vsi); ...@@ -6718,7 +6718,6 @@ static int i40e_vsi_clear(struct i40e_vsi *vsi);
static void i40e_fdir_sb_setup(struct i40e_pf *pf) static void i40e_fdir_sb_setup(struct i40e_pf *pf)
{ {
struct i40e_vsi *vsi; struct i40e_vsi *vsi;
int i;
/* quick workaround for an NVM issue that leaves a critical register /* quick workaround for an NVM issue that leaves a critical register
* uninitialized * uninitialized
...@@ -6729,6 +6728,7 @@ static void i40e_fdir_sb_setup(struct i40e_pf *pf) ...@@ -6729,6 +6728,7 @@ static void i40e_fdir_sb_setup(struct i40e_pf *pf)
0xeacb7d61, 0xaa4f05b6, 0x9c5c89ed, 0xfc425ddb, 0xeacb7d61, 0xaa4f05b6, 0x9c5c89ed, 0xfc425ddb,
0xa4654832, 0xfc7461d4, 0x8f827619, 0xf5c63c21, 0xa4654832, 0xfc7461d4, 0x8f827619, 0xf5c63c21,
0x95b3a76d}; 0x95b3a76d};
int i;
for (i = 0; i <= I40E_GLQF_HKEY_MAX_INDEX; i++) for (i = 0; i <= I40E_GLQF_HKEY_MAX_INDEX; i++)
wr32(&pf->hw, I40E_GLQF_HKEY(i), hkey[i]); wr32(&pf->hw, I40E_GLQF_HKEY(i), hkey[i]);
...@@ -6738,13 +6738,7 @@ static void i40e_fdir_sb_setup(struct i40e_pf *pf) ...@@ -6738,13 +6738,7 @@ static void i40e_fdir_sb_setup(struct i40e_pf *pf)
return; return;
/* find existing VSI and see if it needs configuring */ /* find existing VSI and see if it needs configuring */
vsi = NULL; vsi = i40e_find_vsi_by_type(pf, I40E_VSI_FDIR);
for (i = 0; i < pf->num_alloc_vsi; i++) {
if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) {
vsi = pf->vsi[i];
break;
}
}
/* create a new VSI if none exists */ /* create a new VSI if none exists */
if (!vsi) { if (!vsi) {
...@@ -6766,15 +6760,12 @@ static void i40e_fdir_sb_setup(struct i40e_pf *pf) ...@@ -6766,15 +6760,12 @@ static void i40e_fdir_sb_setup(struct i40e_pf *pf)
**/ **/
static void i40e_fdir_teardown(struct i40e_pf *pf) static void i40e_fdir_teardown(struct i40e_pf *pf)
{ {
int i; struct i40e_vsi *vsi;
i40e_fdir_filter_exit(pf); i40e_fdir_filter_exit(pf);
for (i = 0; i < pf->num_alloc_vsi; i++) { vsi = i40e_find_vsi_by_type(pf, I40E_VSI_FDIR);
if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) { if (vsi)
i40e_vsi_release(pf->vsi[i]); i40e_vsi_release(vsi);
break;
}
}
} }
/** /**
......
...@@ -125,10 +125,7 @@ static int i40e_program_fdir_filter(struct i40e_fdir_filter *fdir_data, ...@@ -125,10 +125,7 @@ static int i40e_program_fdir_filter(struct i40e_fdir_filter *fdir_data,
u16 i; u16 i;
/* find existing FDIR VSI */ /* find existing FDIR VSI */
vsi = NULL; vsi = i40e_find_vsi_by_type(pf, I40E_VSI_FDIR);
for (i = 0; i < pf->num_alloc_vsi; i++)
if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR)
vsi = pf->vsi[i];
if (!vsi) if (!vsi)
return -ENOENT; return -ENOENT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment