Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1592467 > unrolled thread

[PATCH v2] net: smsc: smc91x: use new api ethtool_{get|set}_link_ksettings

Started byPhilippe Reynes <tremyfr@gmail.com>
First post2017-03-04 12:50 +0100
Last post2017-03-09 07:10 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2] net: smsc: smc91x: use new api ethtool_{get|set}_link_ksettings Philippe Reynes <tremyfr@gmail.com> - 2017-03-04 12:50 +0100
    Re: [PATCH v2] net: smsc: smc91x: use new api ethtool_{get|set}_link_ksettings Robert Jarzmik <robert.jarzmik@free.fr> - 2017-03-05 15:30 +0100
    Re: [PATCH v2] net: smsc: smc91x: use new api  ethtool_{get|set}_link_ksettings David Miller <davem@davemloft.net> - 2017-03-09 07:10 +0100

#1592467 — [PATCH v2] net: smsc: smc91x: use new api ethtool_{get|set}_link_ksettings

FromPhilippe Reynes <tremyfr@gmail.com>
Date2017-03-04 12:50 +0100
Subject[PATCH v2] net: smsc: smc91x: use new api ethtool_{get|set}_link_ksettings
Message-ID<thgmd-6M-3@gated-at.bofh.it>
The ethtool api {get|set}_settings is deprecated.
We move this driver to new api {get|set}_link_ksettings.

As I don't have the hardware, I'd be very pleased if
someone may test this patch.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
---
Changelog:
v2:
- also update comment (feeback from Russel King)

 drivers/net/ethernet/smsc/smc91x.c |   47 +++++++++++++++++++----------------
 1 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
index 65077c7..91e9bd7 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -1535,32 +1535,33 @@ static int smc_close(struct net_device *dev)
  * Ethtool support
  */
 static int
-smc_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd)
+smc_ethtool_get_link_ksettings(struct net_device *dev,
+			       struct ethtool_link_ksettings *cmd)
 {
 	struct smc_local *lp = netdev_priv(dev);
 	int ret;
 
-	cmd->maxtxpkt = 1;
-	cmd->maxrxpkt = 1;
-
 	if (lp->phy_type != 0) {
 		spin_lock_irq(&lp->lock);
-		ret = mii_ethtool_gset(&lp->mii, cmd);
+		ret = mii_ethtool_get_link_ksettings(&lp->mii, cmd);
 		spin_unlock_irq(&lp->lock);
 	} else {
-		cmd->supported = SUPPORTED_10baseT_Half |
+		u32 supported = SUPPORTED_10baseT_Half |
 				 SUPPORTED_10baseT_Full |
 				 SUPPORTED_TP | SUPPORTED_AUI;
 
 		if (lp->ctl_rspeed == 10)
-			ethtool_cmd_speed_set(cmd, SPEED_10);
+			cmd->base.speed = SPEED_10;
 		else if (lp->ctl_rspeed == 100)
-			ethtool_cmd_speed_set(cmd, SPEED_100);
+			cmd->base.speed = SPEED_100;
+
+		cmd->base.autoneg = AUTONEG_DISABLE;
+		cmd->base.port = 0;
+		cmd->base.duplex = lp->tcr_cur_mode & TCR_SWFDUP ?
+			DUPLEX_FULL : DUPLEX_HALF;
 
-		cmd->autoneg = AUTONEG_DISABLE;
-		cmd->transceiver = XCVR_INTERNAL;
-		cmd->port = 0;
-		cmd->duplex = lp->tcr_cur_mode & TCR_SWFDUP ? DUPLEX_FULL : DUPLEX_HALF;
+		ethtool_convert_legacy_u32_to_link_mode(
+			cmd->link_modes.supported, supported);
 
 		ret = 0;
 	}
@@ -1569,24 +1570,26 @@ static int smc_close(struct net_device *dev)
 }
 
 static int
-smc_ethtool_setsettings(struct net_device *dev, struct ethtool_cmd *cmd)
+smc_ethtool_set_link_ksettings(struct net_device *dev,
+			       const struct ethtool_link_ksettings *cmd)
 {
 	struct smc_local *lp = netdev_priv(dev);
 	int ret;
 
 	if (lp->phy_type != 0) {
 		spin_lock_irq(&lp->lock);
-		ret = mii_ethtool_sset(&lp->mii, cmd);
+		ret = mii_ethtool_set_link_ksettings(&lp->mii, cmd);
 		spin_unlock_irq(&lp->lock);
 	} else {
-		if (cmd->autoneg != AUTONEG_DISABLE ||
-		    cmd->speed != SPEED_10 ||
-		    (cmd->duplex != DUPLEX_HALF && cmd->duplex != DUPLEX_FULL) ||
-		    (cmd->port != PORT_TP && cmd->port != PORT_AUI))
+		if (cmd->base.autoneg != AUTONEG_DISABLE ||
+		    cmd->base.speed != SPEED_10 ||
+		    (cmd->base.duplex != DUPLEX_HALF &&
+		     cmd->base.duplex != DUPLEX_FULL) ||
+		    (cmd->base.port != PORT_TP && cmd->base.port != PORT_AUI))
 			return -EINVAL;
 
-//		lp->port = cmd->port;
-		lp->ctl_rfduplx = cmd->duplex == DUPLEX_FULL;
+//		lp->port = cmd->base.port;
+		lp->ctl_rfduplx = cmd->base.duplex == DUPLEX_FULL;
 
 //		if (netif_running(dev))
 //			smc_set_port(dev);
@@ -1744,8 +1747,6 @@ static int smc_ethtool_seteeprom(struct net_device *dev,
 
 
 static const struct ethtool_ops smc_ethtool_ops = {
-	.get_settings	= smc_ethtool_getsettings,
-	.set_settings	= smc_ethtool_setsettings,
 	.get_drvinfo	= smc_ethtool_getdrvinfo,
 
 	.get_msglevel	= smc_ethtool_getmsglevel,
@@ -1755,6 +1756,8 @@ static int smc_ethtool_seteeprom(struct net_device *dev,
 	.get_eeprom_len = smc_ethtool_geteeprom_len,
 	.get_eeprom	= smc_ethtool_geteeprom,
 	.set_eeprom	= smc_ethtool_seteeprom,
+	.get_link_ksettings	= smc_ethtool_get_link_ksettings,
+	.set_link_ksettings	= smc_ethtool_set_link_ksettings,
 };
 
 static const struct net_device_ops smc_netdev_ops = {
-- 
1.7.4.4

[toc] | [next] | [standalone]


#1592770

FromRobert Jarzmik <robert.jarzmik@free.fr>
Date2017-03-05 15:30 +0100
Message-ID<thFkB-1yo-7@gated-at.bofh.it>
In reply to#1592467
Philippe Reynes <tremyfr@gmail.com> writes:

> The ethtool api {get|set}_settings is deprecated.
> We move this driver to new api {get|set}_link_ksettings.
>
> As I don't have the hardware, I'd be very pleased if
> someone may test this patch.
>
> Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
> ---
> Changelog:
> v2:
> - also update comment (feeback from Russel King)

Ok, I tested it, with :
    ethtool -s eth0 duplex half autoneg off speed 10
    ethtool eth0
       => see the changes
    ping -f x.x.x.x
    ethtool -s eth0 duplex full autoneg on
    ethtool eth0
       => see the changes
    ping -f x.x.x.x

This both with your patch and without, it works in both cases, and the former as
a smaller throughput, which makes me believe the patch is fine.

Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>

Cheers.

--
Robert

[toc] | [prev] | [next] | [standalone]


#1595690 — Re: [PATCH v2] net: smsc: smc91x: use new api ethtool_{get|set}_link_ksettings

FromDavid Miller <davem@davemloft.net>
Date2017-03-09 07:10 +0100
SubjectRe: [PATCH v2] net: smsc: smc91x: use new api ethtool_{get|set}_link_ksettings
Message-ID<tiZqV-YG-9@gated-at.bofh.it>
In reply to#1592467
From: Philippe Reynes <tremyfr@gmail.com>
Date: Sat,  4 Mar 2017 12:42:39 +0100

> The ethtool api {get|set}_settings is deprecated.
> We move this driver to new api {get|set}_link_ksettings.
> 
> As I don't have the hardware, I'd be very pleased if
> someone may test this patch.
> 
> Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
> ---
> Changelog:
> v2:
> - also update comment (feeback from Russel King)

Applied.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web