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


Groups > linux.kernel > #1558953 > unrolled thread

[PATCH] net: marvell: skge: use new api ethtool_{get|set}_link_ksettings

Started byPhilippe Reynes <tremyfr@gmail.com>
First post2017-01-14 13:10 +0100
Last post2017-01-16 18:40 +0100
Articles 5 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] net: marvell: skge: use new api ethtool_{get|set}_link_ksettings Philippe Reynes <tremyfr@gmail.com> - 2017-01-14 13:10 +0100
    Re: [PATCH] net: marvell: skge: use new api  ethtool_{get|set}_link_ksettings David Miller <davem@davemloft.net> - 2017-01-16 18:40 +0100
      Re: [PATCH] net: marvell: skge: use new api  ethtool_{get|set}_link_ksettings Stephen Hemminger <stephen@networkplumber.org> - 2017-01-16 19:00 +0100
        Re: [PATCH] net: marvell: skge: use new api ethtool_{get|set}_link_ksettings Philippe Reynes <tremyfr@gmail.com> - 2017-01-16 22:30 +0100
    Re: [PATCH] net: marvell: skge: use new api  ethtool_{get|set}_link_ksettings Stephen Hemminger <stephen@networkplumber.org> - 2017-01-16 18:40 +0100

#1558953 — [PATCH] net: marvell: skge: use new api ethtool_{get|set}_link_ksettings

FromPhilippe Reynes <tremyfr@gmail.com>
Date2017-01-14 13:10 +0100
Subject[PATCH] net: marvell: skge: use new api ethtool_{get|set}_link_ksettings
Message-ID<sZvjH-5Nh-17@gated-at.bofh.it>
The ethtool api {get|set}_settings is deprecated.
We move this driver to new api {get|set}_link_ksettings.

The callback set_link_ksettings no longer update the value
of advertising, as the struct ethtool_link_ksettings is
defined as const.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
---
 drivers/net/ethernet/marvell/skge.c |   63 ++++++++++++++++++++--------------
 1 files changed, 37 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c
index 9146a51..81106b7 100644
--- a/drivers/net/ethernet/marvell/skge.c
+++ b/drivers/net/ethernet/marvell/skge.c
@@ -300,65 +300,76 @@ static u32 skge_supported_modes(const struct skge_hw *hw)
 	return supported;
 }
 
-static int skge_get_settings(struct net_device *dev,
-			     struct ethtool_cmd *ecmd)
+static int skge_get_link_ksettings(struct net_device *dev,
+				   struct ethtool_link_ksettings *cmd)
 {
 	struct skge_port *skge = netdev_priv(dev);
 	struct skge_hw *hw = skge->hw;
+	u32 supported, advertising;
 
-	ecmd->transceiver = XCVR_INTERNAL;
-	ecmd->supported = skge_supported_modes(hw);
+	supported = skge_supported_modes(hw);
 
 	if (hw->copper) {
-		ecmd->port = PORT_TP;
-		ecmd->phy_address = hw->phy_addr;
+		cmd->base.port = PORT_TP;
+		cmd->base.phy_address = hw->phy_addr;
 	} else
-		ecmd->port = PORT_FIBRE;
+		cmd->base.port = PORT_FIBRE;
+
+	advertising = skge->advertising;
+	cmd->base.autoneg = skge->autoneg;
+	cmd->base.speed = skge->speed;
+	cmd->base.duplex = skge->duplex;
+
+	ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
+						supported);
+	ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
+						advertising);
 
-	ecmd->advertising = skge->advertising;
-	ecmd->autoneg = skge->autoneg;
-	ethtool_cmd_speed_set(ecmd, skge->speed);
-	ecmd->duplex = skge->duplex;
 	return 0;
 }
 
-static int skge_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+static int skge_set_link_ksettings(struct net_device *dev,
+				   const struct ethtool_link_ksettings *cmd)
 {
 	struct skge_port *skge = netdev_priv(dev);
 	const struct skge_hw *hw = skge->hw;
 	u32 supported = skge_supported_modes(hw);
 	int err = 0;
+	u32 advertising;
+
+	ethtool_convert_link_mode_to_legacy_u32(&advertising,
+						cmd->link_modes.advertising);
 
-	if (ecmd->autoneg == AUTONEG_ENABLE) {
-		ecmd->advertising = supported;
+	if (cmd->base.autoneg == AUTONEG_ENABLE) {
+		advertising = supported;
 		skge->duplex = -1;
 		skge->speed = -1;
 	} else {
 		u32 setting;
-		u32 speed = ethtool_cmd_speed(ecmd);
+		u32 speed = cmd->base.speed;
 
 		switch (speed) {
 		case SPEED_1000:
-			if (ecmd->duplex == DUPLEX_FULL)
+			if (cmd->base.duplex == DUPLEX_FULL)
 				setting = SUPPORTED_1000baseT_Full;
-			else if (ecmd->duplex == DUPLEX_HALF)
+			else if (cmd->base.duplex == DUPLEX_HALF)
 				setting = SUPPORTED_1000baseT_Half;
 			else
 				return -EINVAL;
 			break;
 		case SPEED_100:
-			if (ecmd->duplex == DUPLEX_FULL)
+			if (cmd->base.duplex == DUPLEX_FULL)
 				setting = SUPPORTED_100baseT_Full;
-			else if (ecmd->duplex == DUPLEX_HALF)
+			else if (cmd->base.duplex == DUPLEX_HALF)
 				setting = SUPPORTED_100baseT_Half;
 			else
 				return -EINVAL;
 			break;
 
 		case SPEED_10:
-			if (ecmd->duplex == DUPLEX_FULL)
+			if (cmd->base.duplex == DUPLEX_FULL)
 				setting = SUPPORTED_10baseT_Full;
-			else if (ecmd->duplex == DUPLEX_HALF)
+			else if (cmd->base.duplex == DUPLEX_HALF)
 				setting = SUPPORTED_10baseT_Half;
 			else
 				return -EINVAL;
@@ -371,11 +382,11 @@ static int skge_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 			return -EINVAL;
 
 		skge->speed = speed;
-		skge->duplex = ecmd->duplex;
+		skge->duplex = cmd->base.duplex;
 	}
 
-	skge->autoneg = ecmd->autoneg;
-	skge->advertising = ecmd->advertising;
+	skge->autoneg = cmd->base.autoneg;
+	skge->advertising = advertising;
 
 	if (netif_running(dev)) {
 		skge_down(dev);
@@ -875,8 +886,6 @@ static int skge_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom
 }
 
 static const struct ethtool_ops skge_ethtool_ops = {
-	.get_settings	= skge_get_settings,
-	.set_settings	= skge_set_settings,
 	.get_drvinfo	= skge_get_drvinfo,
 	.get_regs_len	= skge_get_regs_len,
 	.get_regs	= skge_get_regs,
@@ -899,6 +908,8 @@ static int skge_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom
 	.set_phys_id	= skge_set_phys_id,
 	.get_sset_count = skge_get_sset_count,
 	.get_ethtool_stats = skge_get_ethtool_stats,
+	.get_link_ksettings = skge_get_link_ksettings,
+	.set_link_ksettings = skge_set_link_ksettings,
 };
 
 /*
-- 
1.7.4.4

[toc] | [next] | [standalone]


#1559940 — Re: [PATCH] net: marvell: skge: use new api ethtool_{get|set}_link_ksettings

FromDavid Miller <davem@davemloft.net>
Date2017-01-16 18:40 +0100
SubjectRe: [PATCH] net: marvell: skge: use new api ethtool_{get|set}_link_ksettings
Message-ID<t0jqa-3zg-35@gated-at.bofh.it>
In reply to#1558953
From: Stephen Hemminger <stephen@networkplumber.org>
Date: Mon, 16 Jan 2017 09:29:51 -0800

> On Sat, 14 Jan 2017 13:08:28 +0100
> Philippe Reynes <tremyfr@gmail.com> wrote:
> 
>> The ethtool api {get|set}_settings is deprecated.
>> We move this driver to new api {get|set}_link_ksettings.
>> 
>> The callback set_link_ksettings no longer update the value
>> of advertising, as the struct ethtool_link_ksettings is
>> defined as const.
>> 
>> Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
> 
> Did you test this on real hardware?

Philippe probably doesn't have physical access to most of the
drivers he is converting.

But, he is the only person working on converting all of the drivers,
and therefore when the change looks straightforward I am going to
reward his work and effort by applying his changes and hope there
isn't any fallout.

Those who really care can test his patches and give a Tested-by:

Thanks.

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


#1559950 — Re: [PATCH] net: marvell: skge: use new api ethtool_{get|set}_link_ksettings

FromStephen Hemminger <stephen@networkplumber.org>
Date2017-01-16 19:00 +0100
SubjectRe: [PATCH] net: marvell: skge: use new api ethtool_{get|set}_link_ksettings
Message-ID<t0jJv-3Hq-15@gated-at.bofh.it>
In reply to#1559940
On Mon, 16 Jan 2017 12:36:17 -0500 (EST)
David Miller <davem@davemloft.net> wrote:

> From: Stephen Hemminger <stephen@networkplumber.org>
> Date: Mon, 16 Jan 2017 09:29:51 -0800
> 
> > On Sat, 14 Jan 2017 13:08:28 +0100
> > Philippe Reynes <tremyfr@gmail.com> wrote:
> >   
> >> The ethtool api {get|set}_settings is deprecated.
> >> We move this driver to new api {get|set}_link_ksettings.
> >> 
> >> The callback set_link_ksettings no longer update the value
> >> of advertising, as the struct ethtool_link_ksettings is
> >> defined as const.
> >> 
> >> Signed-off-by: Philippe Reynes <tremyfr@gmail.com>  
> > 
> > Did you test this on real hardware?  
> 
> Philippe probably doesn't have physical access to most of the
> drivers he is converting.
> 
> But, he is the only person working on converting all of the drivers,
> and therefore when the change looks straightforward I am going to
> reward his work and effort by applying his changes and hope there
> isn't any fallout.
> 
> Those who really care can test his patches and give a Tested-by:
> 
> Thanks.

Yes, it looks mechanical and should be applied. There are lots of pieces of
old hardware that no developer is running, and if we required full test suite runs
on all drivers, then no refactoring would ever be possible.

My preference is to always add commit note that the patch was compile
tested only so that if someone has a problem with real hardware then they know
what to suspect.

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


#1560071

FromPhilippe Reynes <tremyfr@gmail.com>
Date2017-01-16 22:30 +0100
Message-ID<t0n0J-6iP-9@gated-at.bofh.it>
In reply to#1559950
Hi Stephen,

On 1/16/17, Stephen Hemminger <stephen@networkplumber.org> wrote:
> On Mon, 16 Jan 2017 12:36:17 -0500 (EST)
> David Miller <davem@davemloft.net> wrote:
>
>> From: Stephen Hemminger <stephen@networkplumber.org>
>> Date: Mon, 16 Jan 2017 09:29:51 -0800
>>
>> > On Sat, 14 Jan 2017 13:08:28 +0100
>> > Philippe Reynes <tremyfr@gmail.com> wrote:
>> >
>> >> The ethtool api {get|set}_settings is deprecated.
>> >> We move this driver to new api {get|set}_link_ksettings.
>> >>
>> >> The callback set_link_ksettings no longer update the value
>> >> of advertising, as the struct ethtool_link_ksettings is
>> >> defined as const.
>> >>
>> >> Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
>> >
>> > Did you test this on real hardware?
>>
>> Philippe probably doesn't have physical access to most of the
>> drivers he is converting.
>>
>> But, he is the only person working on converting all of the drivers,
>> and therefore when the change looks straightforward I am going to
>> reward his work and effort by applying his changes and hope there
>> isn't any fallout.
>>
>> Those who really care can test his patches and give a Tested-by:
>>
>> Thanks.
>
> Yes, it looks mechanical and should be applied. There are lots of pieces of
> old hardware that no developer is running, and if we required full test
> suite runs
> on all drivers, then no refactoring would ever be possible.
>
> My preference is to always add commit note that the patch was compile
> tested only so that if someone has a problem with real hardware then they
> know
> what to suspect.

David is right, I don't have the hardware to test all drivers.
I haven't added a little note on all commit, because I was
thinking it would be a lot of noise. But if you prefer (and
David agrees), I'll add a note on all the following patches.

Btw, thanks David for applying my patches.

Philippe

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


#1559943 — Re: [PATCH] net: marvell: skge: use new api ethtool_{get|set}_link_ksettings

FromStephen Hemminger <stephen@networkplumber.org>
Date2017-01-16 18:40 +0100
SubjectRe: [PATCH] net: marvell: skge: use new api ethtool_{get|set}_link_ksettings
Message-ID<t0jqa-3zg-31@gated-at.bofh.it>
In reply to#1558953
On Sat, 14 Jan 2017 13:08:28 +0100
Philippe Reynes <tremyfr@gmail.com> wrote:

> The ethtool api {get|set}_settings is deprecated.
> We move this driver to new api {get|set}_link_ksettings.
> 
> The callback set_link_ksettings no longer update the value
> of advertising, as the struct ethtool_link_ksettings is
> defined as const.
> 
> Signed-off-by: Philippe Reynes <tremyfr@gmail.com>

Did you test this on real hardware?

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web