Commit 5509fc9e authored by Ivan Vecera's avatar Ivan Vecera Committed by Tony Nguyen

i40e: Add helper to access main VEB

Add a helper to access main VEB:

i40e_pf_get_main_veb(pf) replaces 'pf->veb[pf->lan_veb]'
Reviewed-by: default avatarMichal Schmidt <mschmidt@redhat.com>
Reviewed-by: default avatarAleksandr Loktionov <aleksandr.loktionov@intel.com>
Tested-by: default avatarPucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com>
Signed-off-by: default avatarIvan Vecera <ivecera@redhat.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 6c8e355e
...@@ -1401,4 +1401,15 @@ i40e_pf_get_veb_by_seid(struct i40e_pf *pf, u16 seid) ...@@ -1401,4 +1401,15 @@ i40e_pf_get_veb_by_seid(struct i40e_pf *pf, u16 seid)
return NULL; return NULL;
} }
/**
* i40e_pf_get_main_veb - get pointer to main VEB
* @pf: pointer to a PF
*
* Return: pointer to main VEB or NULL if it does not exist
**/
static inline struct i40e_veb *i40e_pf_get_main_veb(struct i40e_pf *pf)
{
return (pf->lan_veb != I40E_NO_VEB) ? pf->veb[pf->lan_veb] : NULL;
}
#endif /* _I40E_H_ */ #endif /* _I40E_H_ */
...@@ -2425,14 +2425,11 @@ static void i40e_get_ethtool_stats(struct net_device *netdev, ...@@ -2425,14 +2425,11 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
if (vsi->type != I40E_VSI_MAIN || pf->hw.partition_id != 1) if (vsi->type != I40E_VSI_MAIN || pf->hw.partition_id != 1)
goto check_data_pointer; goto check_data_pointer;
veb_stats = ((pf->lan_veb != I40E_NO_VEB) && veb = i40e_pf_get_main_veb(pf);
(pf->lan_veb < I40E_MAX_VEB) && veb_stats = veb && test_bit(I40E_FLAG_VEB_STATS_ENA, pf->flags);
test_bit(I40E_FLAG_VEB_STATS_ENA, pf->flags));
if (veb_stats) { if (veb_stats)
veb = pf->veb[pf->lan_veb];
i40e_update_veb_stats(veb); i40e_update_veb_stats(veb);
}
/* If veb stats aren't enabled, pass NULL instead of the veb so that /* If veb stats aren't enabled, pass NULL instead of the veb so that
* we initialize stats to zero and update the data pointer * we initialize stats to zero and update the data pointer
......
...@@ -2481,7 +2481,7 @@ static int i40e_set_promiscuous(struct i40e_pf *pf, bool promisc) ...@@ -2481,7 +2481,7 @@ static int i40e_set_promiscuous(struct i40e_pf *pf, bool promisc)
int aq_ret; int aq_ret;
if (vsi->type == I40E_VSI_MAIN && if (vsi->type == I40E_VSI_MAIN &&
pf->lan_veb != I40E_NO_VEB && i40e_pf_get_main_veb(pf) &&
!test_bit(I40E_FLAG_MFP_ENA, pf->flags)) { !test_bit(I40E_FLAG_MFP_ENA, pf->flags)) {
/* set defport ON for Main VSI instead of true promisc /* set defport ON for Main VSI instead of true promisc
* this way we will get all unicast/multicast and VLAN * this way we will get all unicast/multicast and VLAN
...@@ -9909,6 +9909,7 @@ static void i40e_veb_link_event(struct i40e_veb *veb, bool link_up) ...@@ -9909,6 +9909,7 @@ static void i40e_veb_link_event(struct i40e_veb *veb, bool link_up)
static void i40e_link_event(struct i40e_pf *pf) static void i40e_link_event(struct i40e_pf *pf)
{ {
struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf); struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf);
struct i40e_veb *veb = i40e_pf_get_main_veb(pf);
u8 new_link_speed, old_link_speed; u8 new_link_speed, old_link_speed;
bool new_link, old_link; bool new_link, old_link;
int status; int status;
...@@ -9948,8 +9949,8 @@ static void i40e_link_event(struct i40e_pf *pf) ...@@ -9948,8 +9949,8 @@ static void i40e_link_event(struct i40e_pf *pf)
/* Notify the base of the switch tree connected to /* Notify the base of the switch tree connected to
* the link. Floating VEBs are not notified. * the link. Floating VEBs are not notified.
*/ */
if (pf->lan_veb < I40E_MAX_VEB && pf->veb[pf->lan_veb]) if (veb)
i40e_veb_link_event(pf->veb[pf->lan_veb], new_link); i40e_veb_link_event(veb, new_link);
else else
i40e_vsi_link_event(vsi, new_link); i40e_vsi_link_event(vsi, new_link);
...@@ -14881,7 +14882,8 @@ static void i40e_setup_pf_switch_element(struct i40e_pf *pf, ...@@ -14881,7 +14882,8 @@ static void i40e_setup_pf_switch_element(struct i40e_pf *pf,
/* Main VEB? */ /* Main VEB? */
if (uplink_seid != pf->mac_seid) if (uplink_seid != pf->mac_seid)
break; break;
if (pf->lan_veb >= I40E_MAX_VEB) { veb = i40e_pf_get_main_veb(pf);
if (!veb) {
int v; int v;
/* find existing or else empty VEB */ /* find existing or else empty VEB */
...@@ -14895,12 +14897,15 @@ static void i40e_setup_pf_switch_element(struct i40e_pf *pf, ...@@ -14895,12 +14897,15 @@ static void i40e_setup_pf_switch_element(struct i40e_pf *pf,
pf->lan_veb = v; pf->lan_veb = v;
} }
} }
if (pf->lan_veb >= I40E_MAX_VEB)
/* Try to get again main VEB as pf->lan_veb may have changed */
veb = i40e_pf_get_main_veb(pf);
if (!veb)
break; break;
pf->veb[pf->lan_veb]->seid = seid; veb->seid = seid;
pf->veb[pf->lan_veb]->uplink_seid = pf->mac_seid; veb->uplink_seid = pf->mac_seid;
pf->veb[pf->lan_veb]->pf = pf; veb->pf = pf;
break; break;
case I40E_SWITCH_ELEMENT_TYPE_VSI: case I40E_SWITCH_ELEMENT_TYPE_VSI:
if (num_reported != 1) if (num_reported != 1)
...@@ -15045,13 +15050,15 @@ static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit, bool lock_acqui ...@@ -15045,13 +15050,15 @@ static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit, bool lock_acqui
/* first time setup */ /* first time setup */
main_vsi = i40e_pf_get_main_vsi(pf); main_vsi = i40e_pf_get_main_vsi(pf);
if (!main_vsi || reinit) { if (!main_vsi || reinit) {
struct i40e_veb *veb;
u16 uplink_seid; u16 uplink_seid;
/* Set up the PF VSI associated with the PF's main VSI /* Set up the PF VSI associated with the PF's main VSI
* that is already in the HW switch * that is already in the HW switch
*/ */
if (pf->lan_veb < I40E_MAX_VEB && pf->veb[pf->lan_veb]) veb = i40e_pf_get_main_veb(pf);
uplink_seid = pf->veb[pf->lan_veb]->seid; if (veb)
uplink_seid = veb->seid;
else else
uplink_seid = pf->mac_seid; uplink_seid = pf->mac_seid;
if (!main_vsi) if (!main_vsi)
......
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