[PATCH net-next] net: ethernet: mediatek: add ethtool EEE callbacks

Qingfang Deng posted 1 patch 10 months, 1 week ago
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
[PATCH net-next] net: ethernet: mediatek: add ethtool EEE callbacks
Posted by Qingfang Deng 10 months, 1 week ago
Allow users to adjust the EEE settings of an attached PHY.

Signed-off-by: Qingfang Deng <dqfext@gmail.com>
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 53485142938c..014de2c2624b 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -4474,6 +4474,20 @@ static int mtk_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam
 	return phylink_ethtool_set_pauseparam(mac->phylink, pause);
 }
 
+static int mtk_get_eee(struct net_device *dev, struct ethtool_keee *edata)
+{
+	struct mtk_mac *mac = netdev_priv(dev);
+
+	return phylink_ethtool_get_eee(mac->phylink, edata);
+}
+
+static int mtk_set_eee(struct net_device *dev, struct ethtool_keee *edata)
+{
+	struct mtk_mac *mac = netdev_priv(dev);
+
+	return phylink_ethtool_set_eee(mac->phylink, edata);
+}
+
 static u16 mtk_select_queue(struct net_device *dev, struct sk_buff *skb,
 			    struct net_device *sb_dev)
 {
@@ -4506,6 +4520,8 @@ static const struct ethtool_ops mtk_ethtool_ops = {
 	.set_pauseparam		= mtk_set_pauseparam,
 	.get_rxnfc		= mtk_get_rxnfc,
 	.set_rxnfc		= mtk_set_rxnfc,
+	.get_eee		= mtk_get_eee,
+	.set_eee		= mtk_set_eee,
 };
 
 static const struct net_device_ops mtk_netdev_ops = {
-- 
2.43.0
Re: [PATCH net-next] net: ethernet: mediatek: add ethtool EEE callbacks
Posted by Russell King (Oracle) 10 months, 1 week ago
On Sat, Feb 08, 2025 at 05:27:32PM +0800, Qingfang Deng wrote:
> Allow users to adjust the EEE settings of an attached PHY.

Why do you need to do this? Does the MAC support EEE?

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH net-next] net: ethernet: mediatek: add ethtool EEE callbacks
Posted by Qingfang Deng 10 months, 1 week ago
On Sat, Feb 8, 2025 at 5:29 PM Russell King (Oracle)
<linux@armlinux.org.uk> wrote:
>
> On Sat, Feb 08, 2025 at 05:27:32PM +0800, Qingfang Deng wrote:
> > Allow users to adjust the EEE settings of an attached PHY.
>
> Why do you need to do this? Does the MAC support EEE?

Yes, the MAC supports EEE.

>
> --
> RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
> FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH net-next] net: ethernet: mediatek: add ethtool EEE callbacks
Posted by Russell King (Oracle) 10 months, 1 week ago
On Sat, Feb 08, 2025 at 05:48:46PM +0800, Qingfang Deng wrote:
> On Sat, Feb 8, 2025 at 5:29 PM Russell King (Oracle)
> <linux@armlinux.org.uk> wrote:
> >
> > On Sat, Feb 08, 2025 at 05:27:32PM +0800, Qingfang Deng wrote:
> > > Allow users to adjust the EEE settings of an attached PHY.
> >
> > Why do you need to do this? Does the MAC support EEE?
> 
> Yes, the MAC supports EEE.

Doesn't it need a bit more code to configure the MAC?

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH net-next] net: ethernet: mediatek: add ethtool EEE callbacks
Posted by Qingfang Deng 10 months, 1 week ago
On Sat, Feb 8, 2025 at 5:55 PM Russell King (Oracle)
<linux@armlinux.org.uk> wrote:
> Doesn't it need a bit more code to configure the MAC?

I think you're right. The MT7622 reference manual does not mention the
EEE configuration register so I assumed it would be automatically
enabled.
I just checked the mtk_eth_soc.h and found two unused defs
"MAC_MSR_EEE1G" and "MAC_MSR_EEE100M". I will use those to enable EEE.

>
> --
> RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
> FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!