mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-27 17:18:59 +00:00
84 lines
3.0 KiB
Diff
84 lines
3.0 KiB
Diff
|
From 0a5243abf168351ea8409caf329448a3e18ab62f Mon Sep 17 00:00:00 2001
|
||
|
From: Ioana Radulescu <ruxandra.radulescu@nxp.com>
|
||
|
Date: Tue, 24 Sep 2019 13:24:40 +0300
|
||
|
Subject: [PATCH] dpaa2-eth: Re-add get_link_ksettings ethtool op
|
||
|
|
||
|
Which was removed from upstream driver since without a MAC driver
|
||
|
we have no support for changing link parameters there.
|
||
|
|
||
|
Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
|
||
|
---
|
||
|
.../net/ethernet/freescale/dpaa2/dpaa2-ethtool.c | 47 +++++++++++++++++++++-
|
||
|
1 file changed, 46 insertions(+), 1 deletion(-)
|
||
|
|
||
|
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c
|
||
|
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c
|
||
|
@@ -85,7 +85,8 @@ dpaa2_eth_get_link_ksettings(struct net_
|
||
|
{
|
||
|
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
|
||
|
|
||
|
- link_settings->base.autoneg = AUTONEG_DISABLE;
|
||
|
+ if (priv->link_state.options & DPNI_LINK_OPT_AUTONEG)
|
||
|
+ link_settings->base.autoneg = AUTONEG_ENABLE;
|
||
|
if (!(priv->link_state.options & DPNI_LINK_OPT_HALF_DUPLEX))
|
||
|
link_settings->base.duplex = DUPLEX_FULL;
|
||
|
link_settings->base.speed = priv->link_state.rate;
|
||
|
@@ -93,6 +94,49 @@ dpaa2_eth_get_link_ksettings(struct net_
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
+#define DPNI_DYNAMIC_LINK_SET_VER_MAJOR 7
|
||
|
+#define DPNI_DYNAMIC_LINK_SET_VER_MINOR 1
|
||
|
+static int
|
||
|
+dpaa2_eth_set_link_ksettings(struct net_device *net_dev,
|
||
|
+ const struct ethtool_link_ksettings *link_settings)
|
||
|
+{
|
||
|
+ struct dpni_link_cfg cfg = {0};
|
||
|
+ struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
|
||
|
+ int err = 0;
|
||
|
+
|
||
|
+ /* If using an older MC version, the DPNI must be down
|
||
|
+ * in order to be able to change link settings. Taking steps to let
|
||
|
+ * the user know that.
|
||
|
+ */
|
||
|
+ if (dpaa2_eth_cmp_dpni_ver(priv, DPNI_DYNAMIC_LINK_SET_VER_MAJOR,
|
||
|
+ DPNI_DYNAMIC_LINK_SET_VER_MINOR) < 0) {
|
||
|
+ if (netif_running(net_dev)) {
|
||
|
+ netdev_info(net_dev, "Interface must be brought down first.\n");
|
||
|
+ return -EACCES;
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
+ cfg.rate = link_settings->base.speed;
|
||
|
+ cfg.options = priv->link_state.options;
|
||
|
+ if (link_settings->base.autoneg == AUTONEG_ENABLE)
|
||
|
+ cfg.options |= DPNI_LINK_OPT_AUTONEG;
|
||
|
+ else
|
||
|
+ cfg.options &= ~DPNI_LINK_OPT_AUTONEG;
|
||
|
+ if (link_settings->base.duplex == DUPLEX_HALF)
|
||
|
+ cfg.options |= DPNI_LINK_OPT_HALF_DUPLEX;
|
||
|
+ else
|
||
|
+ cfg.options &= ~DPNI_LINK_OPT_HALF_DUPLEX;
|
||
|
+
|
||
|
+ err = dpni_set_link_cfg(priv->mc_io, 0, priv->mc_token, &cfg);
|
||
|
+ if (err)
|
||
|
+ /* ethtool will be loud enough if we return an error; no point
|
||
|
+ * in putting our own error message on the console by default
|
||
|
+ */
|
||
|
+ netdev_dbg(net_dev, "ERROR %d setting link cfg\n", err);
|
||
|
+
|
||
|
+ return err;
|
||
|
+}
|
||
|
+
|
||
|
static void dpaa2_eth_get_pauseparam(struct net_device *net_dev,
|
||
|
struct ethtool_pauseparam *pause)
|
||
|
{
|
||
|
@@ -734,6 +778,7 @@ const struct ethtool_ops dpaa2_ethtool_o
|
||
|
.get_drvinfo = dpaa2_eth_get_drvinfo,
|
||
|
.get_link = ethtool_op_get_link,
|
||
|
.get_link_ksettings = dpaa2_eth_get_link_ksettings,
|
||
|
+ .set_link_ksettings = dpaa2_eth_set_link_ksettings,
|
||
|
.get_pauseparam = dpaa2_eth_get_pauseparam,
|
||
|
.set_pauseparam = dpaa2_eth_set_pauseparam,
|
||
|
.get_sset_count = dpaa2_eth_get_sset_count,
|