ethtool : Add option -L | --set-common to set common flags.
Subsystems (2)
PATCH 1/1 ethtool : Add option -L | --set-common to set common flags.
This patch adds -L | --set-common option to add / remove common flags which includes loopback flag. The -l | --show-common displays the current values for these common flags.
--- ethtool-copy.h | 1 + ethtool.8 | 16 ++++++++++ ethtool.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 105 insertions(+), 2 deletions(-)
ethtool-copy.h +1 -0
@@ -309,6 +309,7 @@ struct ethtool_perm_addr {* flag differs from the read-only value. */ enum ethtool_flags { +ETH_FLAG_LOOPBACK = (1 <<2 ),/* Loopback enable / disable */ ETH_FLAG_TXVLAN = (1 <<7 ),/* TX VLAN offload enabled */ ETH_FLAG_RXVLAN = (1 <<8 ),/* RX VLAN offload enabled */ ETH_FLAG_LRO = (1 <<15 ),/* LRO is enabled */
ethtool.8 +16 -0
@@ -174,6 +174,13 @@ ethtool \- Display or change ethernet card settings .B2 txvlan on off .B2 rxhash on off +.B ethtool \-l|\-\-show\-common +.I ethX + +.B ethtool \-L|\-\-set\-common +.I ethX +.B2 loopback on off + .B ethtool \-p|\-\-identify .I ethX .RI [ N ]
@@ -406,6 +413,15 @@ Specifies whether TX VLAN acceleration should be enabled .A2 rxhash on off Specifies whether receive hashing offload should be enabled .TP +.B \-l \-\-show\-common +Queries the specified ethernet device for common flag settings. +.TP +.B \-L \-\-set\-common +Changes the common parameters of the specified ethernet device. +.TP +.A2 loopback on off +Specifies whether loopback should be enabled. +.TP .B \-p \-\-identify Initiates adapter-specific action intended to enable an operator to easily identify the adapter by sight. Typically this involves
ethtool.c +88 -2
156 lines not on this page · raw message
Signature · 1 line
1.7.3.1
Quoted 44 lines · Mahesh Bandewar
This patch adds -L | --set-common option to add / remove common flags which includes loopback flag. The -l | --show-common displays the current values for these common flags.
Signed-off-by Mahesh Bandewar <[email protected]>--- ethtool-copy.h | 1 + ethtool.8 | 16 ++++++++++ ethtool.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 105 insertions(+), 2 deletions(-)ethtool-copy.h +1
-0@@ -309,6 +309,7 @@ struct ethtool_perm_addr {* flag differs from the read-only value. */ enum ethtool_flags { +ETH_FLAG_LOOPBACK = (1 <<2 ),/* Loopback enable / disable */ ETH_FLAG_TXVLAN = (1 <<7 ),/* TX VLAN offload enabled */ ETH_FLAG_RXVLAN = (1 <<8 ),/* RX VLAN offload enabled */ ETH_FLAG_LRO = (1 <<15 ),/* LRO is enabled */ ethtool.8 +7
-0@@ -174,6 +174,13 @@ ethtool \- Display or change ethernet card settings .B2 txvlan on off .B2 rxhash on off +.B ethtool \-l|\-\-show\-common +.I ethX + +.B ethtool \-L|\-\-set\-common +.I ethX +.B2 loopback on off + .B ethtool \-p|\-\-identify .I ethX .RI [ N ]@@ -406,6 +413,15 @@ Specifies whether TX VLAN acceleration should be enabled .A2 rxhash on off Specifies whether receive hashing offload should be enabled
ethtool.8 Specifies whether TX VLAN acceleration should be enabled · line 424
Quoted 10 lines
ethtool.8 +9
-0.TP +.B \-l \-\-show\-common +Queries the specified ethernet device for common flag settings. +.TP +.B \-L \-\-set\-common +Changes the common parameters of the specified ethernet device. +.TP +.A2 loopback on off +Specifies whether loopback should be enabled. +.TP
I've just gone through the manual page and changed 'ethernet device' to 'network device' for all generic operations; please follow that. The source for the manual page was also renamed to ethtool.8.in as it now goes through autoconf substitution.
Quoted 7 lines
ethtool.8 +0
-0.B \-p \-\-identify Initiates adapter-specific action intended to enable an operator to easily identify the adapter by sight. Typically this involvesethtool.c +0
-0
[...]
Quoted 14 lines
ethtool.c +7
-0@@ -1905,6 +1932,13 @@ static int dump_offload(int rx, int tx, int sg, int tso, int ufo, int gso,return 0 ; } +static int dump_common_flags (int loopback) +{ +fprintf (stdout,"loopback: %s\n" , loopback ?"on" :"off" ); + +return 0 ; +} +static int dump_rxfhash (int fhash,u64 val) {switch (fhash) {
[...]
Quoted 10 lines
ethtool.c +6
-0@@ -2219,6 +2257,53 @@ static int do_scoalesce(int fd, struct ifreq *ifr)return 0 ; } +static int do_gcommon (int fd,struct ifreq *ifr) +{ +struct ethtool_value eval; +int loopback =0 ; + +fprintf (stdout,"Common flags for %s:\n" , devname);
ethtool.c static int do_scoalesce(int fd, struct ifreq *ifr) · line 2275
Quoted 10 lines
ethtool.c +10
-0+ + eval.cmd =ETHTOOL_GFLAGS ; + ifr->ifr_data = (caddr_t)&eval; +if (ioctl (fd,SIOCETHTOOL , ifr)) { +perror ("Cannot get device flags" ); + }else { + loopback = (eval.data Ð_FLAG_LOOPBACK ) !=0 ; + } + +return dump_common_flags (loopback);
Breaking up a bitmask into a list of flag parameters is fairly pointless. I realise do_goffload() and dump_offload() do that but I am just waiting for Michał Mirosław's changes to offload flags to be settled before I fix them.
Quoted 9 lines
ethtool.c +9
-0+} + +static int do_scommon (int fd,struct ifreq *ifr) +{ +struct ethtool_value eval; + +if (common_flags_mask) { + eval.cmd =ETHTOOL_GFLAGS ; + eval.data =0 ;
ethtool.c static int do_scoalesce(int fd, struct ifreq *ifr) · line 2294
Quoted 10 lines
ethtool.c +10
-0+ ifr->ifr_data = (caddr_t)&eval; +if (ioctl (fd,SIOCETHTOOL , ifr)) { +perror ("Cannot get device common flags" ); +return 1 ; + } + + eval.cmd =ETHTOOL_SFLAGS ; + eval.data = + ((eval.data & ~(common_flags_mask | off_flags_mask)) | + (common_flags_wanted | off_flags_wanted));
Why should this use off_flags_mask and off_flags_wanted? They should both be 0 if this function is called.
Quoted 15 lines
ethtool.c +11
-0+if (ioctl (fd,SIOCETHTOOL , ifr)) { +perror ("Cannot set device common flags" ); +return 1 ; + } + }else { +fprintf (stdout,"No common settings changed\n" ); + } + +return 0 ; +} +static int do_goffload (int fd,struct ifreq *ifr) {struct ethtool_value eval;
ethtool.c static int do_soffload(int fd, struct ifreq *ifr) · line 2497
Quoted 8 lines
ethtool.c +3
-2@@ -2407,8 +2492,9 @@ static int do_soffload(int fd, struct ifreq *ifr) } eval.cmd =ETHTOOL_SFLAGS ; - eval.data = ((eval.data & ~off_flags_mask) | - off_flags_wanted); + eval.data = + ((eval.data & ~(off_flags_mask | common_flags_mask)) | + (off_flags_wanted | common_flags_wanted));
Similarly, why should this use common_flags_mask and common_flags_wanted?
Ben.
Quoted 3 lines
ethtool.c +0
-0err =ioctl (fd,SIOCETHTOOL , ifr);if (err) {
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Quoted 52 lines · Ben Hutchings
Quoted 51 lines · Mahesh Bandewar
This patch adds -L | --set-common option to add / remove common flags which includes loopback flag. The -l | --show-common displays the current values for these common flags.
Signed-off-by Mahesh Bandewar <[email protected]>---
ethtool-copy.h | 1 +
ethtool.8 | 16 ++++++++++
ethtool.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-3 files changed, 105 insertions(+), 2 deletions(-)ethtool-copy.h +1
-0@@ -309,6 +309,7 @@ struct ethtool_perm_addr {* flag differs from the read-only value. */ enum ethtool_flags { + ETH_FLAG_LOOPBACK = (1 << 2), /* Loopback enable / disable */
ETH_FLAG_TXVLAN= (1 << 7), /* TX VLAN offload enabled */ETH_FLAG_RXVLAN= (1 << 8), /* RX VLAN offload enabled */ETH_FLAG_LRO= (1 << 15), /* LRO is enabled */ethtool.8 +0
-0@@ -174,6 +174,13 @@ ethtool \- Display or change ethernet card settings.B2 txvlan on off
.B2 rxhash on off+.B ethtool \-l|\-\-show\-common
+.I ethXethtool.8 +5
-0+ +.B ethtool \-L|\-\-set\-common +.I ethX +.B2 loopback on off +.B ethtool \-p|\-\-identify
.I ethX
.RI [ N ]ethtool.8 +0
-0@@ -406,6 +413,15 @@ Specifies whether TX VLAN acceleration should be enabled.A2 rxhash on off
Specifies whether receive hashing offload should be enabled .TP
+.B \-l \-\-show\-commonethtool.8 +5
-0+Queries the specified ethernet device for common flag settings. +.TP +.B \-L \-\-set\-common +Changes the common parameters of the specified ethernet device. +.TP
Quoted 9 lines
Quoted 3 lines
+.A2 loopback on off
+Specifies whether loopback should be enabled.
+.TPI've just gone through the manual page and changed 'ethernet device' to 'network device' for all generic operations; please follow that. The source for the manual page was also renamed to ethtool.8.in as it now goes through autoconf substitution.
OK. I'll make those changes.
Quoted 63 lines
Quoted 7 lines
.B \-p \-\-identify
Initiates adapter-specific action intended to enable an operator to easily identify the adapter by sight. Typically this involvesethtool.c +0
-0[...]
Quoted 14 lines
ethtool.c +7
-0@@ -1905,6 +1932,13 @@ static int dump_offload(int rx, int tx, int sg, int tso, int ufo, int gso, return 0; } +static int dump_common_flags (int loopback) +{ + fprintf(stdout, "loopback: %s\n", loopback ? "on" : "off"); + + return 0; +} + static int dump_rxfhash(int fhash, u64 val) { switch (fhash) {[...]
Quoted 10 lines
ethtool.c +6
-0@@ -2219,6 +2257,53 @@ static int do_scoalesce(int fd, struct ifreq *ifr) return 0; } +static int do_gcommon (int fd,struct ifreq *ifr) +{ + struct ethtool_value eval; + int loopback = 0; + + fprintf(stdout, "Common flags for %s:\n", devname);ethtool.c static int do_scoalesce(int fd, struct ifreq *ifr) · line 2275
Quoted 10 lines
ethtool.c +10
-0+ + eval.cmd = ETHTOOL_GFLAGS; + ifr->ifr_data = (caddr_t)&eval; + if (ioctl(fd, SIOCETHTOOL, ifr)) { + perror("Cannot get device flags"); + } else { + loopback = (eval.data & ETH_FLAG_LOOPBACK) != 0; + } + + return dump_common_flags(loopback);Breaking up a bitmask into a list of flag parameters is fairly pointless. I realise
do_goffload()anddump_offload()do that but I am just waiting for Michał Mirosław's changes to offload flags to be settled before I fix them.Quoted 14 lines
ethtool.c +14
-0+} + +static int do_scommon (int fd,struct ifreq *ifr) +{ + struct ethtool_value eval; + + if (common_flags_mask) { + eval.cmd = ETHTOOL_GFLAGS; + eval.data = 0; + ifr->ifr_data = (caddr_t)&eval; + if (ioctl(fd, SIOCETHTOOL, ifr)) { + perror("Cannot get device common flags"); + return 1; + }
Quoted 9 lines
ethtool.c static int do_scoalesce(int fd, struct ifreq *ifr) · line 2294
Quoted 5 lines
ethtool.c +5
-0+ + eval.cmd = ETHTOOL_SFLAGS; + eval.data = + ((eval.data & ~(common_flags_mask | off_flags_mask)) | + (common_flags_wanted | off_flags_wanted));Why should this use
off_flags_maskandoff_flags_wanted? They should both be 0 if this function is called.
That is right! Actually the get (ETHTOOL_GFLAGS) operation confused me. I thought the values are fetched and *preserved* while setting the new value. But when looked at it carefully, that is not the case. Actually why that ioctl() with ETHTOOL_GFLAGS required?
Quoted 17 lines
Quoted 17 lines
ethtool.c +11
-0+ if (ioctl(fd, SIOCETHTOOL, ifr)) { + perror("Cannot set device common flags"); + return 1; + } + } else { + fprintf(stdout, "No common settings changed\n"); + } + + return 0; +} + static int do_goffload(int fd, struct ifreq *ifr) { struct ethtool_value eval;@@ -2407,8 +2492,9 @@ static int do_soffload(int fd, struct ifreq *ifr) }
Quoted 9 lines
ethtool.c static int do_soffload(int fd, struct ifreq *ifr) · line 2497
Quoted 6 lines
ethtool.c +3
-2eval.cmd = ETHTOOL_SFLAGS; - eval.data = ((eval.data & ~off_flags_mask) | - off_flags_wanted); + eval.data = + ((eval.data & ~(off_flags_mask | common_flags_mask)) | + (off_flags_wanted | common_flags_wanted));Similarly, why should this use
common_flags_maskandcommon_flags_wanted?
For the same (wrong) reason mentioned above. I'll correct it and post the new patch.
Thanks,
--mahesh..
Quoted 13 lines
Ben.
ethtool.c static int do_soffload(int fd, struct ifreq *ifr) · line 2500
Quoted 3 lines
ethtool.c +0
-0err = ioctl(fd, SIOCETHTOOL, ifr); if (err) {--
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Quoted 3 lines · Mahesh Bandewar
Quoted 1 line · Ben Hutchings
On Thu, 2011-01-13 at 16:11 -0800, Mahesh Bandewar wrote:
[...]
Quoted 21 lines
Quoted 12 lines
Quoted 12 lines
ethtool.c +12
-0+static int do_scommon (int fd,struct ifreq *ifr) +{ +struct ethtool_value eval; + +if (common_flags_mask) { + eval.cmd =ETHTOOL_GFLAGS ; + eval.data =0 ; + ifr->ifr_data = (caddr_t)&eval; +if (ioctl (fd,SIOCETHTOOL , ifr)) { +perror ("Cannot get device common flags" ); +return 1 ; + }Quoted 9 lines
ethtool.c static int do_scoalesce(int fd, struct ifreq *ifr) · line 2294
Quoted 5 lines
ethtool.c +5
-0+ + eval.cmd =ETHTOOL_SFLAGS ; + eval.data = + ((eval.data & ~(common_flags_mask | off_flags_mask)) | + (common_flags_wanted | off_flags_wanted));Why should this use
off_flags_maskandoff_flags_wanted? They should both be 0 if this function is called.
Quoted 4 lines
That is right! Actually the get (
ETHTOOL_GFLAGS) operation confused me. I thought the values are fetched and *preserved* while setting the new value. But when looked at it carefully, that is not the case. Actually why thatioctl()withETHTOOL_GFLAGSrequired?
[...]
This is a read-modify-write operation. We have to:
1. Parse the options to find out which flags are to be changed (common_flags_mask) and the wanted values (common_flags_wanted).
2. Read the current flags (ETHTOOL_GFLAGS reads them into eval.data).
3. Modify the flags (eval.data = ...).
4. Write the new flags (ETHTOOL_SFLAGS).
Ben.
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH v2 1/1 ethtool : Add option -L | --set-common to set common flags.
In reply to Mahesh BandewarThis patch adds -L | --set-common option to add / remove common flags which includes loopback flag. The -l | --show-common displays the current values for these common flags.
--- ethtool-copy.h | 1 + ethtool.8.in | 16 ++++++++++ ethtool.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 0 deletions(-)
ethtool-copy.h +1 -0
@@ -309,6 +309,7 @@ struct ethtool_perm_addr {* flag differs from the read-only value. */ enum ethtool_flags { +ETH_FLAG_LOOPBACK = (1 <<2 ),/* Loopback enable / disable */ ETH_FLAG_TXVLAN = (1 <<7 ),/* TX VLAN offload enabled */ ETH_FLAG_RXVLAN = (1 <<8 ),/* RX VLAN offload enabled */ ETH_FLAG_LRO = (1 <<15 ),/* LRO is enabled */
ethtool.8.in +16 -0
@@ -211,6 +211,13 @@ ethtool \- query or control network driver and hardware settings .B2 txvlan on off .B2 rxhash on off +.B ethtool \-l|\-\-show\-common +.I ethX + +.B ethtool \-L|\-\-set\-common +.I ethX +.B2 loopback on off + .B ethtool \-p|\-\-identify .I ethX .RI [ N ]
@@ -444,6 +451,15 @@ Specifies whether TX VLAN acceleration should be enabled .A2 rxhash on off Specifies whether receive hashing offload should be enabled .TP +.B \-l \-\-show\-common +Queries the specified network device for common flag settings. +.TP +.B \-L \-\-set\-common +Changes the common parameters of the specified network device. +.TP +.A2 loopback on off +Specifies whether loopback should be enabled. +.TP .B \-p \-\-identify Initiates adapter-specific action intended to enable an operator to easily identify the adapter by sight. Typically this involves
ethtool.c +84 -0
144 lines not on this page · raw message
Signature · 1 line
1.7.3.1
Quoted 3 lines · Mahesh Bandewar
This patch adds -L | --set-common option to add / remove common flags which includes loopback flag. The -l | --show-common displays the current values for these common flags.
[...]
I haven't forgotten this, but I won't apply it until the corresponding kernel change is applied.
Ben.
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
That makes sense! The corresponding kernel patch -
http://patchwork.ozlabs.org/patch/77815/
is in RFC state. So what does that state mean?
Thanks,
--mahesh..
Quoted 17 lines · Ben Hutchings
Quoted 3 lines · Mahesh Bandewar
This patch adds -L | --set-common option to add / remove common flags which includes loopback flag. The -l | --show-common displays the current values for these common flags.
[...]
I haven't forgotten this, but I won't apply it until the corresponding kernel change is applied.
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.