提交 46a0ecf9 编写于 作者: V Vladimir Oltean 提交者: Jakub Kicinski

net: enetc: allow the enetc_reconfigure() callback to fail

enetc_reconfigure() was modified in commit c33bfaf9 ("net: enetc:
set up XDP program under enetc_reconfigure()") to take an optional
callback that runs while the netdev is down, but this callback currently
cannot fail.

Code up the error handling so that the interface is restarted with the
old resources if the callback fails.
Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: NSimon Horman <simon.horman@corigine.com>
Signed-off-by: NJakub Kicinski <kuba@kernel.org>
上级 1c81a9b3
...@@ -2574,8 +2574,11 @@ static int enetc_reconfigure(struct enetc_ndev_priv *priv, bool extended, ...@@ -2574,8 +2574,11 @@ static int enetc_reconfigure(struct enetc_ndev_priv *priv, bool extended,
* without reconfiguration. * without reconfiguration.
*/ */
if (!netif_running(priv->ndev)) { if (!netif_running(priv->ndev)) {
if (cb) if (cb) {
cb(priv, ctx); err = cb(priv, ctx);
if (err)
return err;
}
return 0; return 0;
} }
...@@ -2596,8 +2599,11 @@ static int enetc_reconfigure(struct enetc_ndev_priv *priv, bool extended, ...@@ -2596,8 +2599,11 @@ static int enetc_reconfigure(struct enetc_ndev_priv *priv, bool extended,
enetc_free_rxtx_rings(priv); enetc_free_rxtx_rings(priv);
/* Interface is down, run optional callback now */ /* Interface is down, run optional callback now */
if (cb) if (cb) {
cb(priv, ctx); err = cb(priv, ctx);
if (err)
goto out_restart;
}
enetc_assign_tx_resources(priv, tx_res); enetc_assign_tx_resources(priv, tx_res);
enetc_assign_rx_resources(priv, rx_res); enetc_assign_rx_resources(priv, rx_res);
...@@ -2606,6 +2612,10 @@ static int enetc_reconfigure(struct enetc_ndev_priv *priv, bool extended, ...@@ -2606,6 +2612,10 @@ static int enetc_reconfigure(struct enetc_ndev_priv *priv, bool extended,
return 0; return 0;
out_restart:
enetc_setup_bdrs(priv, extended);
enetc_start(priv->ndev);
enetc_free_rx_resources(rx_res, priv->num_rx_rings);
out_free_tx_res: out_free_tx_res:
enetc_free_tx_resources(tx_res, priv->num_tx_rings); enetc_free_tx_resources(tx_res, priv->num_tx_rings);
out: out:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册