Commit c391818a authored by Ioana Ciornei's avatar Ioana Ciornei Committed by Greg Kroah-Hartman

staging: fsl-dpaa2/ethsw: do not force user to bring interface down

Link settings can be changed only when the interface is down. Disable
and re-enable the interface, if necessary, behind the scenes so that we do
not force users to an if down/up sequence.
Reported-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
Link: https://lore.kernel.org/r/1565700187-16048-11-git-send-email-ioana.ciornei@nxp.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 18f1296f
...@@ -88,16 +88,21 @@ ethsw_set_link_ksettings(struct net_device *netdev, ...@@ -88,16 +88,21 @@ ethsw_set_link_ksettings(struct net_device *netdev,
const struct ethtool_link_ksettings *link_ksettings) const struct ethtool_link_ksettings *link_ksettings)
{ {
struct ethsw_port_priv *port_priv = netdev_priv(netdev); struct ethsw_port_priv *port_priv = netdev_priv(netdev);
struct ethsw_core *ethsw = port_priv->ethsw_data;
struct dpsw_link_cfg cfg = {0}; struct dpsw_link_cfg cfg = {0};
int err = 0; bool if_running;
int err = 0, ret;
/* Due to a temporary MC limitation, the DPSW port must be down
* in order to be able to change link settings. Taking steps to let /* Interface needs to be down to change link settings */
* the user know that. if_running = netif_running(netdev);
*/ if (if_running) {
if (netif_running(netdev)) { err = dpsw_if_disable(ethsw->mc_io, 0,
netdev_info(netdev, "Sorry, interface must be brought down first.\n"); ethsw->dpsw_handle,
return -EACCES; port_priv->idx);
if (err) {
netdev_err(netdev, "dpsw_if_disable err %d\n", err);
return err;
}
} }
cfg.rate = link_ksettings->base.speed; cfg.rate = link_ksettings->base.speed;
...@@ -115,6 +120,15 @@ ethsw_set_link_ksettings(struct net_device *netdev, ...@@ -115,6 +120,15 @@ ethsw_set_link_ksettings(struct net_device *netdev,
port_priv->idx, port_priv->idx,
&cfg); &cfg);
if (if_running) {
ret = dpsw_if_enable(ethsw->mc_io, 0,
ethsw->dpsw_handle,
port_priv->idx);
if (ret) {
netdev_err(netdev, "dpsw_if_enable err %d\n", ret);
return ret;
}
}
return err; return err;
} }
......
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