Commit d348d517 authored by Anirudh Venkataramanan's avatar Anirudh Venkataramanan Committed by Tony Nguyen

ice: Ignore EMODE return for opcode 0x0605

When link is owned by manageability, the driver is not allowed to fiddle
with link. FW returns ICE_AQ_RC_EMODE if the driver attempts to do so.
This patch adds a new function ice_set_link which abstracts the call to
ice_aq_set_link_restart_an and provides a clean way to turn on/off link.

While making this change, I also spotted that an int variable was being
used to hold both an ice_status return code and the Linux errno return
code. This pattern more often than not results in the driver inadvertently
returning ice_status back to kernel which is a major boo-boo. Clean it up.
Signed-off-by: default avatarAnirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: default avatarTony Brelinski <tonyx.brelinski@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent d6730a87
...@@ -1095,24 +1095,15 @@ static int ice_nway_reset(struct net_device *netdev) ...@@ -1095,24 +1095,15 @@ static int ice_nway_reset(struct net_device *netdev)
{ {
struct ice_netdev_priv *np = netdev_priv(netdev); struct ice_netdev_priv *np = netdev_priv(netdev);
struct ice_vsi *vsi = np->vsi; struct ice_vsi *vsi = np->vsi;
struct ice_port_info *pi; int err;
enum ice_status status;
pi = vsi->port_info;
/* If VSI state is up, then restart autoneg with link up */ /* If VSI state is up, then restart autoneg with link up */
if (!test_bit(__ICE_DOWN, vsi->back->state)) if (!test_bit(__ICE_DOWN, vsi->back->state))
status = ice_aq_set_link_restart_an(pi, true, NULL); err = ice_set_link(vsi, true);
else else
status = ice_aq_set_link_restart_an(pi, false, NULL); err = ice_set_link(vsi, false);
if (status) { return err;
netdev_info(netdev, "link restart failed, err %s aq_err %s\n",
ice_stat_str(status),
ice_aq_str(pi->hw->adminq.sq_last_status));
return -EIO;
}
return 0;
} }
/** /**
......
...@@ -3423,3 +3423,40 @@ int ice_clear_dflt_vsi(struct ice_sw *sw) ...@@ -3423,3 +3423,40 @@ int ice_clear_dflt_vsi(struct ice_sw *sw)
return 0; return 0;
} }
/**
* ice_set_link - turn on/off physical link
* @vsi: VSI to modify physical link on
* @ena: turn on/off physical link
*/
int ice_set_link(struct ice_vsi *vsi, bool ena)
{
struct device *dev = ice_pf_to_dev(vsi->back);
struct ice_port_info *pi = vsi->port_info;
struct ice_hw *hw = pi->hw;
enum ice_status status;
if (vsi->type != ICE_VSI_PF)
return -EINVAL;
status = ice_aq_set_link_restart_an(pi, ena, NULL);
/* if link is owned by manageability, FW will return ICE_AQ_RC_EMODE.
* this is not a fatal error, so print a warning message and return
* a success code. Return an error if FW returns an error code other
* than ICE_AQ_RC_EMODE
*/
if (status == ICE_ERR_AQ_ERROR) {
if (hw->adminq.sq_last_status == ICE_AQ_RC_EMODE)
dev_warn(dev, "can't set link to %s, err %s aq_err %s. not fatal, continuing\n",
(ena ? "ON" : "OFF"), ice_stat_str(status),
ice_aq_str(hw->adminq.sq_last_status));
} else if (status) {
dev_err(dev, "can't set link to %s, err %s aq_err %s\n",
(ena ? "ON" : "OFF"), ice_stat_str(status),
ice_aq_str(hw->adminq.sq_last_status));
return -EIO;
}
return 0;
}
...@@ -45,6 +45,8 @@ int ice_cfg_vlan_pruning(struct ice_vsi *vsi, bool ena, bool vlan_promisc); ...@@ -45,6 +45,8 @@ int ice_cfg_vlan_pruning(struct ice_vsi *vsi, bool ena, bool vlan_promisc);
void ice_cfg_sw_lldp(struct ice_vsi *vsi, bool tx, bool create); void ice_cfg_sw_lldp(struct ice_vsi *vsi, bool tx, bool create);
int ice_set_link(struct ice_vsi *vsi, bool ena);
#ifdef CONFIG_DCB #ifdef CONFIG_DCB
int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc); int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc);
#endif /* CONFIG_DCB */ #endif /* CONFIG_DCB */
......
...@@ -873,10 +873,10 @@ ice_link_event(struct ice_pf *pf, struct ice_port_info *pi, bool link_up, ...@@ -873,10 +873,10 @@ ice_link_event(struct ice_pf *pf, struct ice_port_info *pi, bool link_up,
{ {
struct device *dev = ice_pf_to_dev(pf); struct device *dev = ice_pf_to_dev(pf);
struct ice_phy_info *phy_info; struct ice_phy_info *phy_info;
enum ice_status status;
struct ice_vsi *vsi; struct ice_vsi *vsi;
u16 old_link_speed; u16 old_link_speed;
bool old_link; bool old_link;
int result;
phy_info = &pi->phy; phy_info = &pi->phy;
phy_info->link_info_old = phy_info->link_info; phy_info->link_info_old = phy_info->link_info;
...@@ -887,10 +887,11 @@ ice_link_event(struct ice_pf *pf, struct ice_port_info *pi, bool link_up, ...@@ -887,10 +887,11 @@ ice_link_event(struct ice_pf *pf, struct ice_port_info *pi, bool link_up,
/* update the link info structures and re-enable link events, /* update the link info structures and re-enable link events,
* don't bail on failure due to other book keeping needed * don't bail on failure due to other book keeping needed
*/ */
result = ice_update_link_info(pi); status = ice_update_link_info(pi);
if (result) if (status)
dev_dbg(dev, "Failed to update link status and re-enable link events for port %d\n", dev_dbg(dev, "Failed to update link status on port %d, err %s aq_err %s\n",
pi->lport); pi->lport, ice_stat_str(status),
ice_aq_str(pi->hw->adminq.sq_last_status));
/* Check if the link state is up after updating link info, and treat /* Check if the link state is up after updating link info, and treat
* this event as an UP event since the link is actually UP now. * this event as an UP event since the link is actually UP now.
...@@ -906,18 +907,12 @@ ice_link_event(struct ice_pf *pf, struct ice_port_info *pi, bool link_up, ...@@ -906,18 +907,12 @@ ice_link_event(struct ice_pf *pf, struct ice_port_info *pi, bool link_up,
if (!test_bit(ICE_FLAG_NO_MEDIA, pf->flags) && if (!test_bit(ICE_FLAG_NO_MEDIA, pf->flags) &&
!(pi->phy.link_info.link_info & ICE_AQ_MEDIA_AVAILABLE)) { !(pi->phy.link_info.link_info & ICE_AQ_MEDIA_AVAILABLE)) {
set_bit(ICE_FLAG_NO_MEDIA, pf->flags); set_bit(ICE_FLAG_NO_MEDIA, pf->flags);
ice_set_link(vsi, false);
result = ice_aq_set_link_restart_an(pi, false, NULL);
if (result) {
dev_dbg(dev, "Failed to set link down, VSI %d error %d\n",
vsi->vsi_num, result);
return result;
}
} }
/* if the old link up/down and speed is the same as the new */ /* if the old link up/down and speed is the same as the new */
if (link_up == old_link && link_speed == old_link_speed) if (link_up == old_link && link_speed == old_link_speed)
return result; return 0;
if (ice_is_dcb_active(pf)) { if (ice_is_dcb_active(pf)) {
if (test_bit(ICE_FLAG_DCB_ENA, pf->flags)) if (test_bit(ICE_FLAG_DCB_ENA, pf->flags))
...@@ -931,7 +926,7 @@ ice_link_event(struct ice_pf *pf, struct ice_port_info *pi, bool link_up, ...@@ -931,7 +926,7 @@ ice_link_event(struct ice_pf *pf, struct ice_port_info *pi, bool link_up,
ice_vc_notify_link_state(pf); ice_vc_notify_link_state(pf);
return result; return 0;
} }
/** /**
...@@ -6678,6 +6673,7 @@ int ice_open(struct net_device *netdev) ...@@ -6678,6 +6673,7 @@ int ice_open(struct net_device *netdev)
struct ice_vsi *vsi = np->vsi; struct ice_vsi *vsi = np->vsi;
struct ice_pf *pf = vsi->back; struct ice_pf *pf = vsi->back;
struct ice_port_info *pi; struct ice_port_info *pi;
enum ice_status status;
int err; int err;
if (test_bit(__ICE_NEEDS_RESTART, pf->state)) { if (test_bit(__ICE_NEEDS_RESTART, pf->state)) {
...@@ -6688,11 +6684,11 @@ int ice_open(struct net_device *netdev) ...@@ -6688,11 +6684,11 @@ int ice_open(struct net_device *netdev)
netif_carrier_off(netdev); netif_carrier_off(netdev);
pi = vsi->port_info; pi = vsi->port_info;
err = ice_update_link_info(pi); status = ice_update_link_info(pi);
if (err) { if (status) {
netdev_err(netdev, "Failed to get link info, error %d\n", netdev_err(netdev, "Failed to get link info, error %s\n",
err); ice_stat_str(status));
return err; return -EIO;
} }
/* Set PHY if there is media, otherwise, turn off PHY */ /* Set PHY if there is media, otherwise, turn off PHY */
...@@ -6715,12 +6711,7 @@ int ice_open(struct net_device *netdev) ...@@ -6715,12 +6711,7 @@ int ice_open(struct net_device *netdev)
} }
} else { } else {
set_bit(ICE_FLAG_NO_MEDIA, pf->flags); set_bit(ICE_FLAG_NO_MEDIA, pf->flags);
err = ice_aq_set_link_restart_an(pi, false, NULL); ice_set_link(vsi, false);
if (err) {
netdev_err(netdev, "Failed to set PHY state, VSI %d error %d\n",
vsi->vsi_num, err);
return err;
}
} }
err = ice_vsi_open(vsi); err = ice_vsi_open(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