Skip to contentSkip to conversation

Ethtool: Add EEE support

PATCH Superseded Yuval Mintz 2 participants 4 messages Jun 6, 2012 – Jun 8, 2012

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Ethtool: Add EEE support

This patch adds 2 new ethtool commands which can be used to manipulate network interfaces' support in EEE.

Output of 'get' has the following form:

EEE Settings for p2p1:
EEE status: enabled - active
Tx LPI: 1000 (us)
Supported EEE link modes: 10000baseT/Full Advertised EEE link modes: 10000baseT/Full Link partner advertised EEE link modes: 10000baseT/Full

Thanks goes to Giuseppe Cavallaro for his original patch.

---
 ethtool-copy.h |   31 +++++++++++++
 ethtool.8.in   |   32 +++++++++++++
 ethtool.c      |  137 +++++++++++++++++++++++++++++++++++++++++++++++--------
 test-cmdline.c |   11 +++++
 4 files changed, 191 insertions(+), 20 deletions(-)
ethtool-copy.h +31 -0
index 9e26a76..070f702 100644
@@ -134,6 +134,35 @@ struct ethtool_eeprom {
 };
 
 /**
+ * struct ethtool_eee - Energy Efficient Ethernet information
+ * @cmd: ETHTOOL_{G,S}EEE
+ * @supported: Mask of %SUPPORTED_* flags for the speed/duplex combinations
+ *	for which there is EEE support.
+ * @advertised: Mask of %ADVERTISED_* flags for the speed/duplex combinations
+ *	advertised as eee capable.
+ * @lp_advertised: Mask of %ADVERTISED_* flags for the speed/duplex
+ *	combinations advertised by the link partner as eee capable.
+ * @eee_active: Result of the eee auto negotiation.
+ * @eee_enabled: EEE configured mode (enabled/disabled).
+ * @tx_lpi_enabled: Whether the interface should assert its tx lpi, given
+ *	that eee was negotiated.
+ * @tx_lpi_timer: Time in microseconds the interface delays prior to asserting
+ *	its tx lpi (after reaching 'idle' state). Effective only when eee
+ *	was negotiated and tx_lpi_enabled was set.
+ */
+struct ethtool_eee {
+	__u32	cmd;
+	__u32	supported;
+	__u32	advertised;
+	__u32	lp_advertised;
+	__u32	eee_active;
+	__u32	eee_enabled;
+	__u32	tx_lpi_enabled;
+	__u32	tx_lpi_timer;
+	__u32	reserved[2];
+};
+
+/**
  * struct ethtool_modinfo - plugin module eeprom information
  * @cmd: %ETHTOOL_GMODULEINFO
  * @type: Standard the module information conforms to %ETH_MODULE_SFF_xxxx
@@ -848,6 +877,8 @@ enum ethtool_sfeatures_retval_bits {
 #define ETHTOOL_GET_TS_INFO	0x00000041 /* Get time stamping and PHC info */
 #define ETHTOOL_GMODULEINFO	0x00000042 /* Get plug-in module information */
 #define ETHTOOL_GMODULEEEPROM	0x00000043 /* Get plug-in module eeprom */
+#define ETHTOOL_GEEE		0x00000044 /* Get EEE settings */
+#define ETHTOOL_SEEE		0x00000045 /* Set EEE settings */
 
 /* compatibility with older code */
 #define SPARC_ETH_GSET		ETHTOOL_GSET
ethtool.8.in +32 -0
index 523b737..b906d8e 100644
@@ -335,6 +335,16 @@ ethtool \- query or control network driver and hardware settings
 .I devname flag
 .A1 on off
 .RB ...
+.HP
+.B ethtool \-\-get\-eee
+.I devname
+.HP
+.B ethtool \-\-set\-eee
+.I devname
+.B2 eee on off
+.B2 tx-lpi on off
+.BN tx-timer
+.BN advertise
 .
 .\" Adjust lines (i.e. full justification) and hyphenate.
 .ad
@@ -817,6 +827,28 @@ Sets the device's private flags as specified.
 .I flag
 .A1 on off
 Sets the state of the named private flag.
+.TP
+.B \-\-get\-eee
+Queries the specified network device for its support in Efficient Energy
+Ethernet (according to the IEEE 802.3az specifications)
+.TP
+.B \-\-set\-eee
+Sets the device EEE behaviour.
+.TP
+.A2 eee on off
+Enables/Disables the device support in EEE.
+.TP
+.A2 tx-lpi on off
+Determines whether the device should assert its tx lpi.
+.TP
+.BI advertise \ N
+Sets the speeds for which the device would advertise EEE capabliities.
+Values are as for
+.B \-\-change advertise
+.TP
+.BI tx-timer \ N
+Sets the amount of time the device should stay in idle mode prior to asserting
+its tx lpi (in microseconds). This has meaning only when tx lpi is on.
 .SH BUGS
 Not supported (in part or whole) on all network drivers.
 .SH AUTHOR
ethtool.c +117 -20

190 lines not on this page · raw message

test-cmdline.c +11 -0
index c30b0e6..d072886 100644
@@ -223,6 +223,17 @@ static struct test_case {
 	{ 0, "-m devname hex off" },
 	{ 1, "-m devname hex on raw on" },
 	{ 0, "-m devname offset 4 length 6" },
+	{ 1, "--get-eee" },
+	{ 0, "--get-eee devname" },
+	{ 0, "--get-eee devname foo" },
+	{ 1, "--set-eee" },
+	{ 1, "--set-eee devname" },
+	{ 0, "--set-eee devname eee on" },
+	{ 0, "--set-eee devname eee off" },
+	{ 0, "--set-eee devname tx-lpi on" },
+	{ 0, "--set-eee devname tx-lpi off" },
+	{ 1, "--set-eee devname tx-timer foo" },
+	{ 1, "--set-eee devname advertise foo" },
 	/* can't test --set-priv-flags yet */
 	{ 0, "-h" },
 	{ 0, "--help" },
Signature · 1 line
1.7.9.rc2
#1 lore raw
Quoted 6 lines · Yuval Mintz

This patch adds 2 new ethtool commands which can be used to manipulate network interfaces' support in EEE.

Output of 'get' has the following form:

Quoted 8 lines

EEE Settings for p2p1:
EEE status: enabled - active
Tx LPI: 1000 (us)
Supported EEE link modes: 10000baseT/Full Advertised EEE link modes: 10000baseT/Full Link partner advertised EEE link modes: 10000baseT/Full

Thanks goes to Giuseppe Cavallaro for his original patch.

[...]

You're supposed to actually run the self-tests (make check):

make[1]: Entering directory `/home/bwh/src/ethtool'
E: ethtool --get-eee devname foo returns 1
FAIL: test-cmdline

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.
#2 lore raw
In reply to Yuval Mintz
Quoted 3 lines · Yuval Mintz

This patch adds 2 new ethtool commands which can be used to manipulate network interfaces' support in EEE.

[...]

ethtool.c static const struct option { · line 3522

Quoted 10 lines
ethtool.c +6 -0
@@ -3423,6 +3514,12 @@ static const struct option {
 	  "		[ hex on|off ]\n"
 	  "		[ offset N ]\n"
 	  "		[ length N ]\n" },
+	{ "--get-eee", 1, do_geee, "Get EEE settings"},
+	{ "--set-eee", 1, do_seee, "Set EEE settings",
+	  "		[ eee on|off ]\n"
+	  "		[ advertise %x ]\n"
+	  "		[ tx-lpi on|off ]\n"
+	  "		[ tx-timer %d ]\n"},

[...]

Another thing: the long options are generally --foo to set/change foo settings and --show-foo to get/show foo settings. Please rename these options to match.

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.
#3 lore raw
Quoted 17 lines · Ben Hutchings
Quoted 3 lines · Yuval Mintz

This patch adds 2 new ethtool commands which can be used to manipulate network interfaces' support in EEE.

[...]

Quoted 10 lines
ethtool.c +6 -0
@@ -3423,6 +3514,12 @@ static const struct option {
 	  "		[ hex on|off ]\n"
 	  "		[ offset N ]\n"
 	  "		[ length N ]\n" },
+	{ "--get-eee", 1, do_geee, "Get EEE settings"},
+	{ "--set-eee", 1, do_seee, "Set EEE settings",
+	  "		[ eee on|off ]\n"
+	  "		[ advertise %x ]\n"
+	  "		[ tx-lpi on|off ]\n"
+	  "		[ tx-timer %d ]\n"},

[...]

Quoted 3 lines

Another thing: the long options are generally --foo to set/change foo settings and --show-foo to get/show foo settings. Please rename these options to match.

Hmm, we already have a lot of --set-foo options, so never mind that. But do change --get-eee to --show-eee.

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.