[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221109024329.15805-1-noor.azura.ahmad.tarmizi@linux.intel.com>
Date: Wed, 9 Nov 2022 10:43:29 +0800
From: Noor Azura Ahmad Tarmizi
<noor.azura.ahmad.tarmizi@...ux.intel.com>
To: "David S . Miller" <davem@...emloft.net>,
Giuseppe Cavallaro <peppe.cavallaro@...com>,
Alexandre Torgue <alexandre.torgue@...s.st.com>,
Jose Abreu <joabreu@...opsys.com>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
Muhammad Husaini Zulkifli <muhammad.husaini.zulkifli@...el.com>
Cc: netdev@...r.kernel.org, linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
Voon Weifeng <weifeng.voon@...el.com>,
Tan Tee Min <tee.min.tan@...el.com>,
Looi Hong Aun <hong.aun.looi@...el.com>,
Noor Azura Ahmad Tarmizi <noor.azura.ahmad.tarmizi@...el.com>
Subject: [PATCH net 1/1] net: stmmac: add check for supported link mode before mode change
From: Noor Azura Ahmad Tarmizi <noor.azura.ahmad.tarmizi@...el.com>
Currently, change for unsupported speed and duplex are sent to the phy,
rendering the link to unknown speed (link state down). Plus, advertising
settings are also passed down directly to the phy. Additional test is
now added to compare new speed and duplex settings and advertising
against current supported settings by attached phy.
Non-supported new settings(speed/duplex and advertising) will be rejected.
Signed-off-by: Noor Azura Ahmad Tarmizi <noor.azura.ahmad.tarmizi@...el.com>
---
.../net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
index f453b0d09366..d40cf7908eaa 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
@@ -390,6 +390,21 @@ stmmac_ethtool_set_link_ksettings(struct net_device *dev,
const struct ethtool_link_ksettings *cmd)
{
struct stmmac_priv *priv = netdev_priv(dev);
+ struct ethtool_link_ksettings link_ks = {};
+
+ /* Get the current link settings */
+ stmmac_ethtool_get_link_ksettings(dev, &link_ks);
+
+ /* Check if the speed and duplex are supported by phy */
+ if (!phy_lookup_setting(cmd->base.speed, cmd->base.duplex,
+ link_ks.link_modes.supported, true))
+ return -EINVAL;
+
+ /* Check if the advertising request is supported */
+ if (!bitmap_subset(cmd->link_modes.advertising,
+ link_ks.link_modes.supported,
+ __ETHTOOL_LINK_MODE_MASK_NBITS))
+ return -EINVAL;
if (priv->hw->pcs & STMMAC_PCS_RGMII ||
priv->hw->pcs & STMMAC_PCS_SGMII) {
--
2.17.1
Powered by blists - more mailing lists