All of lore.kernel.org
 help / color / mirror / Atom feed
From: Giuseppe CAVALLARO <peppe.cavallaro@st.com>
To: netdev@vger.kernel.org
Cc: bhutchings@solarflare.com, rayagond@vayavyalabs.com,
	davem@davemloft.net, Giuseppe Cavallaro <peppe.cavallaro@st.com>
Subject: [PATCH] ethtool: add the EEE option
Date: Fri,  6 Apr 2012 11:29:19 +0200	[thread overview]
Message-ID: <1333704559-11251-6-git-send-email-peppe.cavallaro@st.com> (raw)
In-Reply-To: <1333704559-11251-1-git-send-email-peppe.cavallaro@st.com>

This patch adds a new option to enable/disable the
Energy Efficient Ethernet support: below some example:

bash-3.00# ethtool -s eth0 eee on
stmmac: Energy-Efficient Ethernet initialized

bash-3.00# ./ethtool eth0
Settings for eth0:
	Supported ports: [ TP MII ]
	Supported link modes:   10baseT/Half 10baseT/Full
	                        100baseT/Half 100baseT/Full
[snip]
	Wake-on: d
	Current message level: 0x0000003f (63)
			       drv probe link timer ifdown ifup
	Link detected: yes
	Energy-Efficient Ethernet: Enabled

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 ethtool-copy.h |    3 +++
 ethtool.c      |   45 ++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 47 insertions(+), 1 deletions(-)

diff --git a/ethtool-copy.h b/ethtool-copy.h
index d904c1a..e17ae37 100644
--- a/ethtool-copy.h
+++ b/ethtool-copy.h
@@ -40,6 +40,7 @@ struct ethtool_cmd {
 	__u8	eth_tp_mdix;
 	__u8	reserved2;
 	__u32	lp_advertising;	/* Features the link partner advertises */
+	__u32	eee;		/* Energy-Efficient Etehrnet */
 	__u32	reserved[2];
 };
 
@@ -786,6 +787,8 @@ enum ethtool_sfeatures_retval_bits {
 #define ETHTOOL_SET_DUMP	0x0000003e /* Set dump settings */
 #define ETHTOOL_GET_DUMP_FLAG	0x0000003f /* Get dump settings */
 #define ETHTOOL_GET_DUMP_DATA	0x00000040 /* Get dump data */
+#define ETHTOOL_GEEE		0x00000041 /* Get EEE */
+#define ETHTOOL_SEEE		0x00000042 /* Set EEE */
 
 /* compatibility with older code */
 #define SPARC_ETH_GSET		ETHTOOL_GSET
diff --git a/ethtool.c b/ethtool.c
index d0cc7d4..9e63973 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -1840,6 +1840,18 @@ static int do_gset(struct cmd_context *ctx)
 	} else if (errno != EOPNOTSUPP) {
 		perror("Cannot get link status");
 	}
+	edata.cmd = ETHTOOL_GEEE;
+	err = send_ioctl(ctx, &edata);
+	if (err == 0) {
+		fprintf(stdout, "	Energy-Efficient Ethernet: %s\n",
+			edata.data ? "enabled" : "disabled");
+		allfail = 0;
+	} else if (errno != EOPNOTSUPP) {
+		perror("Cannot get EEE feature");
+	} else if (errno == EOPNOTSUPP) {
+		fprintf(stdout, "	Energy-Efficient Ethernet:"
+				" not supported\n");
+	}
 
 	if (allfail) {
 		fprintf(stdout, "No data available\n");
@@ -1857,6 +1869,8 @@ static int do_sset(struct cmd_context *ctx)
 	int phyad_wanted = -1;
 	int xcvr_wanted = -1;
 	int advertising_wanted = -1;
+	int eee_wanted = -1;
+	int eee_changed = 0;
 	int gset_changed = 0; /* did anything in GSET change? */
 	u32 wol_wanted = 0;
 	int wol_change = 0;
@@ -1983,6 +1997,17 @@ static int do_sset(struct cmd_context *ctx)
 					ARRAY_SIZE(cmdline_msglvl));
 				break;
 			}
+		} else if (!strcmp(argp[i], "eee")) {
+			eee_changed = 1;
+			i++;
+			if (i >= argc)
+				exit_bad_args();
+			if (!strcmp(argp[i], "on"))
+				eee_wanted = 1;
+			else if (!strcmp(argp[i], "off"))
+				eee_wanted = 0;
+			else
+				exit_bad_args();
 		} else {
 			exit_bad_args();
 		}
@@ -2129,6 +2154,23 @@ static int do_sset(struct cmd_context *ctx)
 		}
 	}
 
+	if (eee_changed) {
+		struct ethtool_value edata;
+
+		edata.cmd = ETHTOOL_GEEE;
+		err = send_ioctl(ctx, &edata);
+		if (err < 0)
+			perror("Cannot get current EEE settings");
+		else {
+			edata.cmd = ETHTOOL_SEEE;
+			edata.data = eee_wanted;
+			err = send_ioctl(ctx, &edata);
+			if (err < 0)
+				fprintf(stderr, "Cannot turn %s the EEE",
+					(eee_wanted ? "on" : "off"));
+		}
+	}
+
 	if (msglvl_changed) {
 		struct ethtool_value edata;
 
@@ -3129,7 +3171,8 @@ static const struct option {
 	  "		[ xcvr internal|external ]\n"
 	  "		[ wol p|u|m|b|a|g|s|d... ]\n"
 	  "		[ sopass %x:%x:%x:%x:%x:%x ]\n"
-	  "		[ msglvl %d | msglvl type on|off ... ]\n" },
+	  "		[ msglvl %d | msglvl type on|off ]\n"
+	  "		[ eee on|off ... ]\n" },
 	{ "-a|--show-pause", 1, do_gpause, "Show pause options" },
 	{ "-A|--pause", 1, do_spause, "Set pause options",
 	  "		[ autoneg on|off ]\n"
-- 
1.7.4.4

  parent reply	other threads:[~2012-04-06  9:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-06  9:29 [net-next 0/4 (V3)] stmmac & EEE support Giuseppe CAVALLARO
2012-04-06  9:29 ` [net-next 1/4 (V3)] net: ethtool: add the " Giuseppe CAVALLARO
2012-04-12 22:26   ` Ben Hutchings
2012-04-16  5:41     ` Giuseppe CAVALLARO
2012-04-19 12:58       ` Giuseppe CAVALLARO
2012-04-19 13:48         ` Yuval Mintz
2012-04-19 15:14           ` Ben Hutchings
2012-04-19 15:30         ` Ben Hutchings
2012-04-26  7:48           ` Giuseppe CAVALLARO
2012-04-26 17:17             ` Ben Hutchings
2012-04-27 14:11               ` Giuseppe CAVALLARO
2012-04-29  9:20                 ` Yuval Mintz
2012-04-29 21:56                   ` Ben Hutchings
2012-05-07  5:25                     ` Giuseppe CAVALLARO
2012-04-06  9:29 ` [net-next 2/4 (V3)] phy: add the EEE support and the way to access to the MMD regs Giuseppe CAVALLARO
2012-04-06  9:29 ` [net-next 3/4 (V3)] stmmac: add the Energy Efficient Ethernet support Giuseppe CAVALLARO
2012-04-12 20:32   ` David Miller
2012-04-13  6:35     ` Giuseppe CAVALLARO
2012-04-06  9:29 ` [net-next 4/4 (V3)] stmmac: update the driver Documentation and add EEE Giuseppe CAVALLARO
2012-04-06  9:29 ` Giuseppe CAVALLARO [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-02-28 12:44 [PATCH 0/4 (net.git)] stmmac EEE support Giuseppe CAVALLARO
2012-02-28 12:46 ` [PATCH] ethtool: add the EEE option Giuseppe CAVALLARO

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1333704559-11251-6-git-send-email-peppe.cavallaro@st.com \
    --to=peppe.cavallaro@st.com \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=rayagond@vayavyalabs.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.