ice: Add helper to determine if VF link is up

The check for vf->link_up is incorrect because this field is only valid if
vf->link_forced is true. Fix this by adding the helper ice_is_vf_link_up()
to determine if the VF's link is up.

Signed-off-by: Brett Creeley <brett.creeley@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
This commit is contained in:
Brett Creeley 2020-01-22 07:21:26 -08:00 committed by Jeff Kirsher
parent b093841f9a
commit 0b6c6a8bb6
1 changed files with 25 additions and 17 deletions

View File

@ -90,6 +90,26 @@ ice_set_pfe_link(struct ice_vf *vf, struct virtchnl_pf_event *pfe,
}
}
/**
* ice_is_vf_link_up - check if the VF's link is up
* @vf: VF to check if link is up
*/
static bool ice_is_vf_link_up(struct ice_vf *vf)
{
struct ice_pf *pf = vf->pf;
if (ice_check_vf_init(pf, vf))
return false;
if (!vf->num_qs_ena)
return false;
else if (vf->link_forced)
return vf->link_up;
else
return pf->hw.port_info->phy.link_info.link_info &
ICE_AQ_LINK_UP;
}
/**
* ice_vc_notify_vf_link_state - Inform a VF of link status
* @vf: pointer to the VF structure
@ -99,28 +119,16 @@ ice_set_pfe_link(struct ice_vf *vf, struct virtchnl_pf_event *pfe,
static void ice_vc_notify_vf_link_state(struct ice_vf *vf)
{
struct virtchnl_pf_event pfe = { 0 };
struct ice_link_status *ls;
struct ice_pf *pf = vf->pf;
struct ice_hw *hw;
hw = &pf->hw;
ls = &hw->port_info->phy.link_info;
struct ice_hw *hw = &vf->pf->hw;
pfe.event = VIRTCHNL_EVENT_LINK_CHANGE;
pfe.severity = PF_EVENT_SEVERITY_INFO;
/* Always report link is down if the VF queues aren't enabled */
if (!vf->num_qs_ena) {
if (ice_is_vf_link_up(vf))
ice_set_pfe_link(vf, &pfe,
hw->port_info->phy.link_info.link_speed, true);
else
ice_set_pfe_link(vf, &pfe, ICE_AQ_LINK_SPEED_UNKNOWN, false);
} else if (vf->link_forced) {
u16 link_speed = vf->link_up ?
ls->link_speed : ICE_AQ_LINK_SPEED_UNKNOWN;
ice_set_pfe_link(vf, &pfe, link_speed, vf->link_up);
} else {
ice_set_pfe_link(vf, &pfe, ls->link_speed,
ls->link_info & ICE_AQ_LINK_UP);
}
ice_aq_send_msg_to_vf(hw, vf->vf_id, VIRTCHNL_OP_EVENT,
VIRTCHNL_STATUS_SUCCESS, (u8 *)&pfe,