netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: netdev@vger.kernel.org
Cc: linux-net-drivers@solarflare.com,
	"Michał Mirosław" <mirq-linux@rere.qmqm.pl>,
	netdev@vger.kernel.org, "David Miller" <davem@davemloft.net>
Subject: [RFC PATCH ethtool 2/3] ethtool: Report any consequential offload feature changes
Date: Mon, 16 May 2011 16:57:45 +0100	[thread overview]
Message-ID: <1305561465.2885.16.camel@bwh-desktop> (raw)
In-Reply-To: <BANLkTi=Q_RrGgw0H=OeNeJ4JkkCgyYckFA@mail.gmail.com>

When an offload feature is enabled or disabled, this can change the
state of other features that depend on it.  Report any such changes.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
 ethtool.c |   47 +++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/ethtool.c b/ethtool.c
index 419f349..5eeca64 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -1807,13 +1807,15 @@ static const struct {
 	{ "receive-hashing",		  0,		   NETIF_F_RXHASH },
 };
 
-static int dump_offload(u32 active)
+static int dump_offload(u32 active, u32 mask)
 {
 	u32 value;
 	int i;
 
 	for (i = 0; i < ARRAY_SIZE(off_feature_def); i++) {
 		value = off_feature_def[i].value;
+		if (!(mask & value))
+			continue;
 		printf("%s: %s\n",
 		       off_feature_def[i].long_name,
 		       (active & value) ? "on" : "off");
@@ -2147,14 +2149,14 @@ static const u32 flags_dup_features =
 	(ETH_FLAG_LRO | ETH_FLAG_RXVLAN | ETH_FLAG_TXVLAN | ETH_FLAG_NTUPLE |
 	 ETH_FLAG_RXHASH);
 
-static int do_goffload(int fd, struct ifreq *ifr)
+static int get_offload(int fd, struct ifreq *ifr, u32 *features)
 {
 	struct ethtool_value eval;
 	int err, allfail = 1;
-	u32 features = 0, value;
+	u32 value;
 	int i;
 
-	fprintf(stdout, "Offload parameters for %s:\n", devname);
+	*features = 0; 
 
 	for (i = 0; i < ARRAY_SIZE(off_feature_def); i++) {
 		value = off_feature_def[i].value;
@@ -2169,7 +2171,7 @@ static int do_goffload(int fd, struct ifreq *ifr)
 				off_feature_def[i].long_name);
 		} else {
 			if (eval.data)
-				features |= value;
+				*features |= value;
 			allfail = 0;
 		}
 	}
@@ -2180,24 +2182,39 @@ static int do_goffload(int fd, struct ifreq *ifr)
 	if (err) {
 		perror("Cannot get device flags");
 	} else {
-		features |= eval.data & flags_dup_features;
+		*features |= eval.data & flags_dup_features;
 		allfail = 0;
 	}
 
-	if (allfail) {
+	return allfail;
+}
+
+static int do_goffload(int fd, struct ifreq *ifr)
+{
+	u32 features;
+
+	fprintf(stdout, "Offload parameters for %s:\n", devname);
+
+	if (get_offload(fd, ifr, &features)) {
 		fprintf(stdout, "no offload info available\n");
 		return 83;
 	}
 
-	return dump_offload(features);
+	return dump_offload(features, ~(u32)0);
 }
 
 static int do_soffload(int fd, struct ifreq *ifr)
 {
+	u32 old_features, new_features, diff;
 	struct ethtool_value eval;
 	int err;
 	int i;
 
+	if (get_offload(fd, ifr, &old_features)) {
+		fprintf(stderr, "no offload info available\n");
+		return 1;
+	}
+
 	for (i = 0; i < ARRAY_SIZE(off_feature_def); i++) {
 		if (!off_feature_def[i].cmd)
 			continue;
@@ -2239,6 +2256,20 @@ static int do_soffload(int fd, struct ifreq *ifr)
 
 	if (off_features_mask == 0) {
 		fprintf(stdout, "no offload settings changed\n");
+		return 0;
+	}
+
+	/* Were any additional changes made automatically? */
+	if (get_offload(fd, ifr, &new_features)) {
+		fprintf(stderr, "no offload info available\n");
+		return 1;
+	}
+	diff = ((old_features & ~off_features_mask) |
+		(off_features_wanted & off_features_mask)) ^
+		new_features;
+	if (diff) {
+		printf("Additional changes:\n");
+		dump_offload(new_features, diff);
 	}
 
 	return 0;
-- 
1.7.4



-- 
Ben Hutchings, Senior Software 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.


  parent reply	other threads:[~2011-05-16 15:57 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-14  1:05 [PATCH net-2.6] ethtool: Remove fallback to old ethtool operations for ETHTOOL_SFEATURES Ben Hutchings
2011-05-14  9:54 ` Michał Mirosław
2011-05-14 20:08   ` Ben Hutchings
2011-05-14 10:31 ` [PATCH] net: fix ETHTOOL_SFEATURES compatibility with old ethtool_ops.set_flags Michał Mirosław
2011-05-14 10:35 ` [PATCH net-2.6] ethtool: Remove fallback to old ethtool operations for ETHTOOL_SFEATURES Michał Mirosław
2011-05-16  2:45   ` Ben Hutchings
2011-05-16 12:13     ` Michał Mirosław
2011-05-16 13:28     ` [PATCH] ethtool: ETHTOOL_SFEATURES: remove NETIF_F_COMPAT return Michał Mirosław
2011-05-16 13:37       ` Ben Hutchings
2011-05-16 14:23         ` Michał Mirosław
2011-05-16 14:53           ` Ben Hutchings
2011-05-16 15:01             ` Michał Mirosław
2011-05-16 15:57               ` [RFC PATCH ethtool 1/3] ethtool: Regularise offload feature settings Ben Hutchings
2011-05-16 15:57               ` Ben Hutchings [this message]
2011-05-16 15:58               ` [RFC PATCH ethtool 3/3] ethtool: Use ETHTOOL_{G,S}FEATURES where available Ben Hutchings
2011-05-16 20:51             ` [PATCH] ethtool: ETHTOOL_SFEATURES: remove NETIF_F_COMPAT return Michał Mirosław
2011-05-16 21:08               ` Ben Hutchings
2011-05-16 21:50                 ` Michał Mirosław
2011-05-16 22:09                   ` Ben Hutchings
2011-05-17  8:45                     ` Michał Mirosław
2011-05-17 20:33                     ` [RFC PATCH ethtool] ethtool: merge ETHTOOL_[GS]FEATURES support to -k/-K modes Michał Mirosław
2011-05-18 19:02                     ` [PATCH] ethtool: ETHTOOL_SFEATURES: remove NETIF_F_COMPAT return Ben Hutchings
2011-05-19  9:18                       ` Michał Mirosław
2011-05-19 13:25                         ` [RFC PATCH v3 ethtool] ethtool: implement [GS]FEATURES calls Michał Mirosław
2011-05-16 20:54             ` [RFC PATCH ethtool] ethtool: implement G/SFEATURES calls Michał Mirosław
2011-05-16 18:09           ` [PATCH] ethtool: ETHTOOL_SFEATURES: remove NETIF_F_COMPAT return David Miller
2011-05-19 10:03             ` Michał Mirosław
2011-05-24  9:14               ` Michał Mirosław
2011-05-24 19:39                 ` David Miller
2011-05-24 21:59                   ` Michał Mirosław
2011-05-27 14:13                     ` Ben Hutchings
2011-05-27 15:28                       ` Michał Mirosław
2011-05-27 15:45                         ` Ben Hutchings
2011-05-27 16:34                           ` Michał Mirosław
2011-05-27 23:25                             ` Ben Hutchings
2011-05-28  7:35                               ` Michał Mirosław
     [not found]                                 ` <20110528073525.GA19033-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org>
2011-05-28 10:07                                   ` [Xen-devel] " Ian Campbell
     [not found]                                     ` <1306577228.23577.17.camel-ztPmHsLffjjnO4AKDKe2m+kiAK3p4hvP@public.gmane.org>
2011-05-28 17:31                                       ` Jesse Gross
     [not found]                                         ` <BANLkTime8PHYe+BFELt92gg7SZ91xKvAwA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-05-29  9:38                                           ` Michał Mirosław
     [not found]                                             ` <20110529093849.GA5245-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org>
2011-05-31 18:43                                               ` Jesse Gross
2011-05-26 10:42                   ` [RESEND PATCH net] net: fix ETHTOOL_SFEATURES compatibility with old ethtool_ops.set_flags Michał Mirosław
2011-05-26 18:14                     ` David Miller
2011-05-14 10:41 ` [PATCH v2] " Michał Mirosław

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=1305561465.2885.16.camel@bwh-desktop \
    --to=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=linux-net-drivers@solarflare.com \
    --cc=mirq-linux@rere.qmqm.pl \
    --cc=netdev@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).