net: txgbe: Correct the currect link settings
authorJiawen Wu <jiawenwu@trustnetic.com>
Wed, 21 May 2025 06:43:59 +0000 (14:43 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Mon, 26 May 2025 15:25:42 +0000 (17:25 +0200)
For AML 25G/10G devices, some of the information returned from
phylink_ethtool_ksettings_get() is not correct, since there is a
fixed-link mode. So add additional corrections.

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/C94BF867617C544D+20250521064402.22348-7-jiawenwu@trustnetic.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
drivers/net/ethernet/wangxun/txgbe/txgbe_ethtool.c
drivers/net/ethernet/wangxun/txgbe/txgbe_ethtool.h

index 86c0159e8a2de9cd0a0a3933ab2db01347e5e486..c12a4cb951f68c314f39cafe7f9686ba4b70df00 100644 (file)
@@ -231,9 +231,6 @@ int wx_get_link_ksettings(struct net_device *netdev,
 {
        struct wx *wx = netdev_priv(netdev);
 
-       if (wx->mac.type == wx_mac_aml40)
-               return -EOPNOTSUPP;
-
        return phylink_ethtool_ksettings_get(wx->phylink, cmd);
 }
 EXPORT_SYMBOL(wx_get_link_ksettings);
index 78999d484f18e37b72450285ae2fa843877703f9..fa770961df5f818a6038bdbdf5b4fc20bbb9b52d 100644 (file)
 #include "txgbe_fdir.h"
 #include "txgbe_ethtool.h"
 
+int txgbe_get_link_ksettings(struct net_device *netdev,
+                            struct ethtool_link_ksettings *cmd)
+{
+       struct wx *wx = netdev_priv(netdev);
+       struct txgbe *txgbe = wx->priv;
+       int err;
+
+       if (wx->mac.type == wx_mac_aml40)
+               return -EOPNOTSUPP;
+
+       err = wx_get_link_ksettings(netdev, cmd);
+       if (err)
+               return err;
+
+       if (wx->mac.type == wx_mac_sp)
+               return 0;
+
+       cmd->base.port = txgbe->link_port;
+       cmd->base.autoneg = AUTONEG_DISABLE;
+       linkmode_copy(cmd->link_modes.supported, txgbe->sfp_support);
+       linkmode_copy(cmd->link_modes.advertising, txgbe->advertising);
+
+       return 0;
+}
+
 static int txgbe_set_ringparam(struct net_device *netdev,
                               struct ethtool_ringparam *ring,
                               struct kernel_ethtool_ringparam *kernel_ring,
@@ -510,7 +535,7 @@ static const struct ethtool_ops txgbe_ethtool_ops = {
        .get_drvinfo            = wx_get_drvinfo,
        .nway_reset             = wx_nway_reset,
        .get_link               = ethtool_op_get_link,
-       .get_link_ksettings     = wx_get_link_ksettings,
+       .get_link_ksettings     = txgbe_get_link_ksettings,
        .set_link_ksettings     = wx_set_link_ksettings,
        .get_sset_count         = wx_get_sset_count,
        .get_strings            = wx_get_strings,
index ace1b3571012407dd96678adb9ab1e11b568c00d..66dbc8ec1bb6555bfb150787851ffd7dc70e43ee 100644 (file)
@@ -4,6 +4,8 @@
 #ifndef _TXGBE_ETHTOOL_H_
 #define _TXGBE_ETHTOOL_H_
 
+int txgbe_get_link_ksettings(struct net_device *netdev,
+                            struct ethtool_link_ksettings *cmd);
 void txgbe_set_ethtool_ops(struct net_device *netdev);
 
 #endif /* _TXGBE_ETHTOOL_H_ */