Skip to contentSkip to conversation

ethtool: don't overwrite useful bits in advertising bitfield

PATCH Superseded Johan Gunnarsson 2 participants 7 messages Aug 14, 2012 – Aug 24, 2012

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ethtool: don't overwrite useful bits in advertising bitfield

There are bits in this bitfield that we want to leave untouched (PAUSE and ASYM_PAUSE bits) when changing other bits (speed and duplex bits.) Previously, these were always overwritten to zero when running commands like "ethtool -s eth0 speed 10 duplex full autoneg off".

---
 ethtool.c |   45 +++++++++++++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 14 deletions(-)
ethtool.c +31 -14
index e573357..efa12c7 100644
@@ -46,6 +46,18 @@
 #define MAX_ADDR_LEN	32
 #endif
 
+#define ALL_ADVERTISED_MODES \
+	(ADVERTISED_10baseT_Half | \
+	 ADVERTISED_10baseT_Full | \
+	 ADVERTISED_100baseT_Half | \
+	 ADVERTISED_100baseT_Full | \
+	 ADVERTISED_1000baseT_Half | \
+	 ADVERTISED_1000baseT_Full | \
+	 ADVERTISED_2500baseX_Full | \
+	 ADVERTISED_10000baseT_Full | \
+	 ADVERTISED_20000baseMLD2_Full | \
+	 ADVERTISED_20000baseKR2_Full)
+
 #ifndef HAVE_NETIF_MSG
 enum {
 	NETIF_MSG_DRV		= 0x0001,
@@ -2202,6 +2214,7 @@ static int do_sset(struct cmd_context *ctx)
 	int autoneg_wanted = -1;
 	int phyad_wanted = -1;
 	int xcvr_wanted = -1;
+	int full_advertising_wanted = -1;
 	int advertising_wanted = -1;
 	int gset_changed = 0; /* did anything in GSET change? */
 	u32 wol_wanted = 0;
@@ -2277,7 +2290,7 @@ static int do_sset(struct cmd_context *ctx)
 			i += 1;
 			if (i >= argc)
 				exit_bad_args();
-			advertising_wanted = get_int(argp[i], 16);
+			full_advertising_wanted = get_int(argp[i], 16);
 		} else if (!strcmp(argp[i], "phyad")) {
 			gset_changed = 1;
 			i += 1;
@@ -2334,7 +2347,10 @@ static int do_sset(struct cmd_context *ctx)
 		}
 	}
 
-	if (advertising_wanted < 0) {
+	if (full_advertising_wanted < 0) {
+		/* User didn't supply a full advertisement bitfield:
+		 * construct one from the specified speed and duplex.
+		 */
 		if (speed_wanted == SPEED_10 && duplex_wanted == DUPLEX_HALF)
 			advertising_wanted = ADVERTISED_10baseT_Half;
 		else if (speed_wanted == SPEED_10 &&
@@ -2405,19 +2421,20 @@ static int do_sset(struct cmd_context *ctx)
 			}
 			if (autoneg_wanted == AUTONEG_ENABLE &&
 			    advertising_wanted == 0) {
-				ecmd.advertising = ecmd.supported &
-					(ADVERTISED_10baseT_Half |
-					 ADVERTISED_10baseT_Full |
-					 ADVERTISED_100baseT_Half |
-					 ADVERTISED_100baseT_Full |
-					 ADVERTISED_1000baseT_Half |
-					 ADVERTISED_1000baseT_Full |
-					 ADVERTISED_2500baseX_Full |
-					 ADVERTISED_10000baseT_Full |
-					 ADVERTISED_20000baseMLD2_Full |
-					 ADVERTISED_20000baseKR2_Full);
+				/* Auto negotation enabled, but with
+				 * unspecified speed and duplex: enable all
+				 * supported speeds and duplexes.
+				 */
+				ecmd.advertising = (ecmd.advertising &
+					~ALL_ADVERTISED_MODES) |
+					(ALL_ADVERTISED_MODES & ecmd.supported);
 			} else if (advertising_wanted > 0) {
-				ecmd.advertising = advertising_wanted;
+				/* Enable all requested modes */
+				ecmd.advertising = (ecmd.advertising &
+					~ALL_ADVERTISED_MODES) |
+					(advertising_wanted & ecmd.supported);
+			} else if (full_advertising_wanted > 0) {
+				ecmd.advertising = full_advertising_wanted;
 			}
 
 			/* Try to perform the update. */
Signature · 1 line
1.7.10
#1 lore raw
Quoted 4 lines · Johan Gunnarsson

There are bits in this bitfield that we want to leave untouched (PAUSE and ASYM_PAUSE bits) when changing other bits (speed and duplex bits.) Previously, these were always overwritten to zero when running commands like "ethtool -s eth0 speed 10 duplex full autoneg off".

This is right in principle, but the implementation isn't quite right.

Quoted 14 lines
---
 ethtool.c |   45 +++++++++++++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 14 deletions(-)
ethtool.c +1 -0
index e573357..efa12c7 100644
@@ -46,6 +46,18 @@
 #define MAX_ADDR_LEN	32
 #endif
 
+#define ALL_ADVERTISED_MODES \

ethtool.c line 59

Quoted 10 lines
ethtool.c +10 -0
+	(ADVERTISED_10baseT_Half | \
+	 ADVERTISED_10baseT_Full | \
+	 ADVERTISED_100baseT_Half | \
+	 ADVERTISED_100baseT_Full | \
+	 ADVERTISED_1000baseT_Half | \
+	 ADVERTISED_1000baseT_Full | \
+	 ADVERTISED_2500baseX_Full | \
+	 ADVERTISED_10000baseT_Full | \
+	 ADVERTISED_20000baseMLD2_Full | \
+	 ADVERTISED_20000baseKR2_Full)

This is missing the new 40G modes (not a regression, I realise).

[...]

Quoted 12 lines
ethtool.c +0 -8
@@ -2405,19 +2421,20 @@ static int do_sset(struct cmd_context *ctx)
 			}
 			if (autoneg_wanted == AUTONEG_ENABLE &&
 			    advertising_wanted == 0) {
-				ecmd.advertising = ecmd.supported &
-					(ADVERTISED_10baseT_Half |
-					 ADVERTISED_10baseT_Full |
-					 ADVERTISED_100baseT_Half |
-					 ADVERTISED_100baseT_Full |
-					 ADVERTISED_1000baseT_Half |
-					 ADVERTISED_1000baseT_Full |
-					 ADVERTISED_2500baseX_Full |

ethtool.c static int do_sset(struct cmd_context *ctx) · line 2430

Quoted 10 lines
ethtool.c +7 -3
-					 ADVERTISED_10000baseT_Full |
-					 ADVERTISED_20000baseMLD2_Full |
-					 ADVERTISED_20000baseKR2_Full);
+				/* Auto negotation enabled, but with
+				 * unspecified speed and duplex: enable all
+				 * supported speeds and duplexes.
+				 */
+				ecmd.advertising = (ecmd.advertising &
+					~ALL_ADVERTISED_MODES) |
+					(ALL_ADVERTISED_MODES & ecmd.supported);

Perhaps we should also warn if there's a 'supported' flag we don't recognise, because we don't know whether it's a link mode and we might be failing to enable/disable it as requested.

ethtool.c static int do_sset(struct cmd_context *ctx) · line 2435

Quoted 6 lines
ethtool.c +4 -1
 			} else if (advertising_wanted > 0) {
-				ecmd.advertising = advertising_wanted;
+				/* Enable all requested modes */
+				ecmd.advertising = (ecmd.advertising &
+					~ALL_ADVERTISED_MODES) |
+					(advertising_wanted & ecmd.supported);

I don't think the '& ecmd.supported' here is right. If an autoneg device supports some new link mode L that is not in ALL_ADVERTISED_MODES, but not link mode M which the user requested, then this can silently fail because the resulting advertising mask will include L but not M.

We should either use advertising_wanted unmasked and let the driver validate it, or report an error if it's not present in the supported mask. I think we should be consistent with the following case, i.e. let the driver validate it.

Ben.

Quoted 5 lines
ethtool.c +2 -0
+			} else if (full_advertising_wanted > 0) {
+				ecmd.advertising = full_advertising_wanted;
 			}
 
 			/* Try to perform the update. */
Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#2 lore raw
Quoted 35 lines

-----Original Message-----
From: [email protected] [mailto:netdev- [email protected]] On Behalf Of Ben Hutchings
Sent: den 20 augusti 2012 17:23
To: Johan Gunnarsson
Cc: [email protected]; Mikael Starvik
Subject: Re: [PATCH] ethtool: don't overwrite useful bits in advertising bitfield

Quoted 1 line · Johan Gunnarsson

There are bits in this bitfield that we want to leave untouched

(PAUSE

Quoted 1 line

and ASYM_PAUSE bits) when changing other bits (speed and duplex

bits.)

Quoted 1 line

Previously, these were always overwritten to zero when running

commands

Quoted 1 line

like "ethtool -s eth0 speed 10 duplex full autoneg off".

This is right in principle, but the implementation isn't quite right.

Quoted 13 lines
---
 ethtool.c |   45 +++++++++++++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 14 deletions(-)
ethtool.c +0 -0
index e573357..efa12c7 100644
@@ -46,6 +46,18 @@
 #define MAX_ADDR_LEN	32
 #endif
 
Quoted 13 lines

ethtool.c line 59

Quoted 11 lines
ethtool.c +11 -0
+#define ALL_ADVERTISED_MODES \
+	(ADVERTISED_10baseT_Half | \
+	 ADVERTISED_10baseT_Full | \
+	 ADVERTISED_100baseT_Half | \
+	 ADVERTISED_100baseT_Full | \
+	 ADVERTISED_1000baseT_Half | \
+	 ADVERTISED_1000baseT_Full | \
+	 ADVERTISED_2500baseX_Full | \
+	 ADVERTISED_10000baseT_Full | \
+	 ADVERTISED_20000baseMLD2_Full | \
+	 ADVERTISED_20000baseKR2_Full)

This is missing the new 40G modes (not a regression, I realise).

I'll add the 40G modes. There is also a bunch of 10G modes missing. Shall I add these too?

Quoted 20 lines

[...]

Quoted 18 lines
ethtool.c +3 -11
@@ -2405,19 +2421,20 @@ static int do_sset(struct cmd_context *ctx)
 			}
 			if (autoneg_wanted == AUTONEG_ENABLE &&
 			    advertising_wanted == 0) {
-				ecmd.advertising = ecmd.supported &
-					(ADVERTISED_10baseT_Half |
-					 ADVERTISED_10baseT_Full |
-					 ADVERTISED_100baseT_Half |
-					 ADVERTISED_100baseT_Full |
-					 ADVERTISED_1000baseT_Half |
-					 ADVERTISED_1000baseT_Full |
-					 ADVERTISED_2500baseX_Full |
-					 ADVERTISED_10000baseT_Full |
-					 ADVERTISED_20000baseMLD2_Full |
-					 ADVERTISED_20000baseKR2_Full);
+				/* Auto negotation enabled, but with
+				 * unspecified speed and duplex: enable all
+				 * supported speeds and duplexes.
Quoted 8 lines

ethtool.c static int do_sset(struct cmd_context *ctx) · line 2430

Quoted 4 lines
ethtool.c +4 -0
+				 */
+				ecmd.advertising = (ecmd.advertising &
+					~ALL_ADVERTISED_MODES) |
+					(ALL_ADVERTISED_MODES & ecmd.supported);

Perhaps we should also warn if there's a 'supported' flag we don't recognise, because we don't know whether it's a link mode and we might be failing to enable/disable it as requested.

You mean if ecmd.supported has bits enabled that ALL_ADVERTISED_MODES hasn't? I don't think that's a good idea, because that happens very often (for example PAUSE bits in my case.)

Quoted 15 lines

ethtool.c static int do_sset(struct cmd_context *ctx) · line 2435

Quoted 7 lines
ethtool.c +4 -1
 			} else if (advertising_wanted > 0) {
-				ecmd.advertising = advertising_wanted;
+				/* Enable all requested modes */
+				ecmd.advertising = (ecmd.advertising &
+					~ALL_ADVERTISED_MODES) |
+					(advertising_wanted & ecmd.supported);

I don't think the '& ecmd.supported' here is right. If an autoneg device supports some new link mode L that is not in ALL_ADVERTISED_MODES, but not link mode M which the user requested, then
this can silently fail because the resulting advertising mask will include L but not M.

Quoted 5 lines

We should either use advertising_wanted unmasked and let the driver validate it, or report an error if it's not present in the supported mask. I think we should be consistent with the following case, i.e. let
the driver validate it.

How about remove "& ecmd.supported", but also warn if trying to add an unsupported mode? Similar to the previous case.

Quoted 18 lines

Ben.

ethtool.c static int do_sset(struct cmd_context *ctx) · line 2440

Quoted 5 lines
ethtool.c +2 -0
+			} else if (full_advertising_wanted > 0) {
+				ecmd.advertising = full_advertising_wanted;
 			}
 
 			/* Try to perform the update. */

--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 48 lines · Johan Gunnarsson
Quoted 34 lines

-----Original Message-----
From: [email protected] [mailto:netdev- [email protected]] On Behalf Of Ben Hutchings
Sent: den 20 augusti 2012 17:23
To: Johan Gunnarsson
Cc: [email protected]; Mikael Starvik
Subject: Re: [PATCH] ethtool: don't overwrite useful bits in advertising bitfield

Quoted 1 line · Johan Gunnarsson

There are bits in this bitfield that we want to leave untouched

(PAUSE

Quoted 1 line

and ASYM_PAUSE bits) when changing other bits (speed and duplex

bits.)

Quoted 1 line

Previously, these were always overwritten to zero when running

commands

Quoted 1 line

like "ethtool -s eth0 speed 10 duplex full autoneg off".

This is right in principle, but the implementation isn't quite right.

Quoted 13 lines
---
 ethtool.c |   45 +++++++++++++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 14 deletions(-)
ethtool.c +0 -0
index e573357..efa12c7 100644
@@ -46,6 +46,18 @@
 #define MAX_ADDR_LEN	32
 #endif
 
Quoted 13 lines

ethtool.c line 59

Quoted 11 lines
ethtool.c +11 -0
+#define ALL_ADVERTISED_MODES \
+	(ADVERTISED_10baseT_Half | \
+	 ADVERTISED_10baseT_Full | \
+	 ADVERTISED_100baseT_Half | \
+	 ADVERTISED_100baseT_Full | \
+	 ADVERTISED_1000baseT_Half | \
+	 ADVERTISED_1000baseT_Full | \
+	 ADVERTISED_2500baseX_Full | \
+	 ADVERTISED_10000baseT_Full | \
+	 ADVERTISED_20000baseMLD2_Full | \
+	 ADVERTISED_20000baseKR2_Full)

This is missing the new 40G modes (not a regression, I realise).

Quoted 1 line

I'll add the 40G modes. There is also a bunch of 10G modes missing. Shall I add these too?

Yes please.

Quoted 29 lines
Quoted 20 lines

[...]

Quoted 18 lines
ethtool.c +3 -11
@@ -2405,19 +2421,20 @@ static int do_sset(struct cmd_context *ctx)
 			}
 			if (autoneg_wanted == AUTONEG_ENABLE &&
 			    advertising_wanted == 0) {
-				ecmd.advertising = ecmd.supported &
-					(ADVERTISED_10baseT_Half |
-					 ADVERTISED_10baseT_Full |
-					 ADVERTISED_100baseT_Half |
-					 ADVERTISED_100baseT_Full |
-					 ADVERTISED_1000baseT_Half |
-					 ADVERTISED_1000baseT_Full |
-					 ADVERTISED_2500baseX_Full |
-					 ADVERTISED_10000baseT_Full |
-					 ADVERTISED_20000baseMLD2_Full |
-					 ADVERTISED_20000baseKR2_Full);
+				/* Auto negotation enabled, but with
+				 * unspecified speed and duplex: enable all
+				 * supported speeds and duplexes.
Quoted 8 lines

ethtool.c static int do_sset(struct cmd_context *ctx) · line 2430

Quoted 4 lines
ethtool.c +4 -0
+				 */
+				ecmd.advertising = (ecmd.advertising &
+					~ALL_ADVERTISED_MODES) |
+					(ALL_ADVERTISED_MODES & ecmd.supported);

Perhaps we should also warn if there's a 'supported' flag we don't recognise, because we don't know whether it's a link mode and we might be failing to enable/disable it as requested.

Quoted 3 lines

You mean if ecmd.supported has bits enabled that ALL_ADVERTISED_MODES hasn't? I don't think that's a good idea, because that happens very often (for example PAUSE bits in my case.)

No, I mean if it has bits enabled that are not defined at all (currently any of bits 27-31).

Quoted 15 lines
Quoted 15 lines

ethtool.c static int do_sset(struct cmd_context *ctx) · line 2435

Quoted 7 lines
ethtool.c +4 -1
 			} else if (advertising_wanted > 0) {
-				ecmd.advertising = advertising_wanted;
+				/* Enable all requested modes */
+				ecmd.advertising = (ecmd.advertising &
+					~ALL_ADVERTISED_MODES) |
+					(advertising_wanted & ecmd.supported);

I don't think the '& ecmd.supported' here is right. If an autoneg device supports some new link mode L that is not in ALL_ADVERTISED_MODES, but not link mode M which the user requested, then
this can silently fail because the resulting advertising mask will include L but not M.

Quoted 8 lines
Quoted 5 lines

We should either use advertising_wanted unmasked and let the driver validate it, or report an error if it's not present in the supported mask. I think we should be consistent with the following case, i.e. let
the driver validate it.

How about remove "& ecmd.supported", but also warn if trying to add an unsupported mode? Similar to the previous case.

[...]

I don't think this is similar and I don't think we need to do both.

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#4 lore raw
Quoted 60 lines

-----Original Message-----
From: Ben Hutchings [mailto:[email protected]]
Sent: den 21 augusti 2012 17:12
To: Johan Gunnarsson
Cc: [email protected]; Mikael Starvik
Subject: RE: [PATCH] ethtool: don't overwrite useful bits in advertising bitfield

Quoted 12 lines · Johan Gunnarsson
Quoted 12 lines

-----Original Message-----
From: [email protected] [mailto:netdev- [email protected]] On Behalf Of Ben Hutchings
Sent: den 20 augusti 2012 17:23
To: Johan Gunnarsson
Cc: [email protected]; Mikael Starvik
Subject: Re: [PATCH] ethtool: don't overwrite useful bits in advertising bitfield

Quoted 1 line · Johan Gunnarsson

There are bits in this bitfield that we want to leave untouched

Quoted 8 lines
Quoted 8 lines

(PAUSE

Quoted 1 line

and ASYM_PAUSE bits) when changing other bits (speed and duplex

bits.)

Quoted 1 line

Previously, these were always overwritten to zero when running

commands

Quoted 1 line

like "ethtool -s eth0 speed 10 duplex full autoneg off".

This is right in principle, but the implementation isn't quite

right.

Quoted 28 lines
Quoted 27 lines
Quoted 15 lines
---
 ethtool.c |   45 +++++++++++++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 14 deletions(-)
ethtool.c +1 -0
index e573357..efa12c7 100644
@@ -46,6 +46,18 @@
 #define MAX_ADDR_LEN	32
 #endif
 
+#define ALL_ADVERTISED_MODES \

ethtool.c line 59

Quoted 10 lines
ethtool.c +10 -0
+	(ADVERTISED_10baseT_Half | \
+	 ADVERTISED_10baseT_Full | \
+	 ADVERTISED_100baseT_Half | \
+	 ADVERTISED_100baseT_Full | \
+	 ADVERTISED_1000baseT_Half | \
+	 ADVERTISED_1000baseT_Full | \
+	 ADVERTISED_2500baseX_Full | \
+	 ADVERTISED_10000baseT_Full | \
+	 ADVERTISED_20000baseMLD2_Full | \
+	 ADVERTISED_20000baseKR2_Full)

This is missing the new 40G modes (not a regression, I realise).

Quoted 4 lines
Quoted 1 line

I'll add the 40G modes. There is also a bunch of 10G modes missing.

Shall I add these too?

Yes please.

Alright.

Quoted 34 lines
Quoted 4 lines
Quoted 4 lines

[...]

ethtool.c static int do_sset(struct cmd_context

Quoted 1 line
ethtool.c +0 -0
@@ -2405,19 +2421,20 @@ static int do_sset(struct cmd_context

*ctx)

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
ethtool.c +0 -5
 			}
 			if (autoneg_wanted == AUTONEG_ENABLE &&
 			    advertising_wanted == 0) {
-				ecmd.advertising = ecmd.supported &
-					(ADVERTISED_10baseT_Half |
-					 ADVERTISED_10baseT_Full |
-					 ADVERTISED_100baseT_Half |
-					 ADVERTISED_100baseT_Full |
Quoted 8 lines
Quoted 8 lines

ethtool.c static int do_sset(struct cmd_context *ctx)

Quoted 8 lines
ethtool.c +2 -6
-					 ADVERTISED_1000baseT_Half |
-					 ADVERTISED_1000baseT_Full |
-					 ADVERTISED_2500baseX_Full |
-					 ADVERTISED_10000baseT_Full |
-					 ADVERTISED_20000baseMLD2_Full |
-					 ADVERTISED_20000baseKR2_Full);
+				/* Auto negotation enabled, but with
+				 * unspecified speed and duplex: enable

all

Quoted 5 lines
Quoted 5 lines

ethtool.c static int do_sset(struct cmd_context *ctx)

Quoted 5 lines
ethtool.c +5 -0
+				 * supported speeds and duplexes.
+				 */
+				ecmd.advertising = (ecmd.advertising &
+					~ALL_ADVERTISED_MODES) |
+					(ALL_ADVERTISED_MODES &

ecmd.supported);

Quoted 3 lines
Quoted 3 lines

Perhaps we should also warn if there's a 'supported' flag we don't recognise, because we don't know whether it's a link mode and we

might

Quoted 2 lines
Quoted 1 line

be failing to enable/disable it as requested.

Quoted 7 lines
Quoted 3 lines

You mean if ecmd.supported has bits enabled that ALL_ADVERTISED_MODES hasn't? I don't think that's a good idea, because that happens very often (for example PAUSE bits in my case.)

No, I mean if it has bits enabled that are not defined at all (currently
any of bits 27-31).

Not totally sure I follow. Care to show me?

Quoted 25 lines
Quoted 8 lines
Quoted 8 lines

ethtool.c static int do_sset(struct cmd_context *ctx)

Quoted 8 lines
ethtool.c +4 -1
 			} else if (advertising_wanted > 0) {
-				ecmd.advertising = advertising_wanted;
+				/* Enable all requested modes */
+				ecmd.advertising = (ecmd.advertising &
+					~ALL_ADVERTISED_MODES) |
+					(advertising_wanted &

ecmd.supported);

Quoted 10 lines
Quoted 10 lines

I don't think the '& ecmd.supported' here is right. If an autoneg device supports some new link mode L that is not in ALL_ADVERTISED_MODES, but not link mode M which the user requested, then
this can silently fail because the resulting advertising mask will include L but not M.

We should either use advertising_wanted unmasked and let the driver validate it, or report an error if it's not present in the

supported

Quoted 1 line
Quoted 1 line

mask. I think we should be consistent with the following case,

i.e.

Quoted 3 lines
Quoted 2 lines

let
the driver validate it.

Quoted 6 lines
Quoted 1 line

How about remove "& ecmd.supported", but also warn if trying to add

an

Quoted 1 line

unsupported mode? Similar to the previous case.

[...]

I don't think this is similar and I don't think we need to do both.

So let's go for the removed "& ecmd.supported" then.

Quoted 7 lines

Ben.

--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.

#5 lore raw

On Tue, 2012-08-21 at 18:45 +0200, Johan Gunnarsson wrote:
[...]

Quoted 35 lines
Quoted 35 lines
Quoted 1 line
Quoted 1 line

Review static int do_sset(struct cmd_context

Quoted 1 line
(quoted diff) +0 -0
@@ -2405,19 +2421,20 @@ static int do_sset(struct cmd_context

*ctx)

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
ethtool.c +0 -5
 			}
 			if (autoneg_wanted == AUTONEG_ENABLE &&
 			    advertising_wanted == 0) {
-				ecmd.advertising = ecmd.supported &
-					(ADVERTISED_10baseT_Half |
-					 ADVERTISED_10baseT_Full |
-					 ADVERTISED_100baseT_Half |
-					 ADVERTISED_100baseT_Full |
Quoted 8 lines
Quoted 8 lines

ethtool.c static int do_sset(struct cmd_context *ctx)

Quoted 8 lines
ethtool.c +2 -6
-					 ADVERTISED_1000baseT_Half |
-					 ADVERTISED_1000baseT_Full |
-					 ADVERTISED_2500baseX_Full |
-					 ADVERTISED_10000baseT_Full |
-					 ADVERTISED_20000baseMLD2_Full |
-					 ADVERTISED_20000baseKR2_Full);
+				/* Auto negotation enabled, but with
+				 * unspecified speed and duplex: enable

all

Quoted 5 lines
Quoted 5 lines

ethtool.c static int do_sset(struct cmd_context *ctx)

Quoted 5 lines
ethtool.c +5 -0
+				 * supported speeds and duplexes.
+				 */
+				ecmd.advertising = (ecmd.advertising &
+					~ALL_ADVERTISED_MODES) |
+					(ALL_ADVERTISED_MODES &

ecmd.supported);

Quoted 3 lines
Quoted 3 lines

Perhaps we should also warn if there's a 'supported' flag we don't recognise, because we don't know whether it's a link mode and we

might

Quoted 5 lines
Quoted 1 line

be failing to enable/disable it as requested.

You mean if ecmd.supported has bits enabled that ALL_ADVERTISED_MODES hasn't? I don't think that's a good idea, because that happens very often (for example PAUSE bits in my case.)

Quoted 5 lines
Quoted 3 lines

No, I mean if it has bits enabled that are not defined at all (currently
any of bits 27-31).

Not totally sure I follow. Care to show me?

[...]

<linux/ethtool.h> or ethtool-copy.h currently defines the meanings of bits 0-26 in the supported field. You define ALL_ADVERTISED_MODES to include all of those that are link modes. But some time in the future, the remaining bits will be assigned to new capabilities.

If today's ethtool is used with a newer driver that sets bit 27 in its supported field, ethtool can't tell whether that represents a new link mode that should be included in ALL_ADVERTISED_MODES, or some other kind of capability. So it may not be able to set the driver's advertising mask correctly.

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#6 lore raw
Quoted 17 lines

-----Original Message-----
From: Ben Hutchings [mailto:[email protected]]
Sent: den 21 augusti 2012 19:03
To: Johan Gunnarsson
Cc: [email protected]; Mikael Starvik
Subject: RE: [PATCH] ethtool: don't overwrite useful bits in advertising bitfield

[...]

<linux/ethtool.h> or ethtool-copy.h currently defines the meanings of bits 0-26 in the supported field. You define ALL_ADVERTISED_MODES to include all of those that are link modes. But some time in the future, the remaining bits will be assigned to new capabilities.

Quoted 6 lines

If today's ethtool is used with a newer driver that sets bit 27 in its supported field, ethtool can't tell whether that represents a new link mode that should be included in ALL_ADVERTISED_MODES, or some other kind
of capability. So it may not be able to set the driver's advertising mask correctly.

I see. Thanks. I'll submit new version of the patch.

Quoted 7 lines

Ben.

--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.