netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Ethtool offload patch
@ 2004-12-30  8:54 David Dillow
  2005-01-04 17:44 ` David S. Miller
  0 siblings, 1 reply; 4+ messages in thread
From: David Dillow @ 2004-12-30  8:54 UTC (permalink / raw)
  To: Netdev; +Cc: dave

[-- Attachment #1: Type: text/plain, Size: 136 bytes --]

The attached patch allows the ethtool userspace tool to query and
control IPSEC crypto offload.

-- 
David Dillow <dave@thedillows.org>

[-- Attachment #2: ethtool-offload.patch --]
[-- Type: text/x-patch, Size: 3726 bytes --]

diff -urN ethtool-2/ethtool.c ethtool-2-ipsec/ethtool.c
--- ethtool-2/ethtool.c	2004-07-02 11:28:48.000000000 -0400
+++ ethtool-2-ipsec/ethtool.c	2004-11-21 03:15:46.000000000 -0500
@@ -118,7 +118,8 @@
  *		[ rx on|off ] \
  *		[ tx on|off ] \
  *		[ sg on|off ] \
- *		[ tso on|off ]
+ *		[ tso on|off ] \
+ *		[ ipsec on|off ]
  *	ethtool -r DEVNAME
  *	ethtool -p DEVNAME [ %d ]
  *	ethtool -t DEVNAME [ online|offline ]
@@ -190,7 +191,8 @@
 		"		[ rx on|off ] \\\n"
 		"		[ tx on|off ] \\\n"
 		"		[ sg on|off ] \\\n"
-		"		[ tso on|off ]\n"
+		"		[ tso on|off ] \\\n"
+		"		[ ipsec on|off ]\n"
 		"	ethtool -r DEVNAME\n"
 		"	ethtool -p DEVNAME [ %%d ]\n"
 		"	ethtool -t DEVNAME [online|(offline)]\n"
@@ -236,6 +238,7 @@
 static int off_csum_tx_wanted = -1;
 static int off_sg_wanted = -1;
 static int off_tso_wanted = -1;
+static int off_ipsec_wanted = -1;
 
 static struct ethtool_pauseparam epause;
 static int gpause_changed = 0;
@@ -339,6 +342,7 @@
 	{ "tx", CMDL_BOOL, &off_csum_tx_wanted, NULL },
 	{ "sg", CMDL_BOOL, &off_sg_wanted, NULL },
 	{ "tso", CMDL_BOOL, &off_tso_wanted, NULL },
+	{ "ipsec", CMDL_BOOL, &off_ipsec_wanted, NULL },
 };
 
 static struct cmdline_info cmdline_pause[] = {
@@ -1175,17 +1179,19 @@
 	return 0;
 }
 
-static int dump_offload (int rx, int tx, int sg, int tso)
+static int dump_offload (int rx, int tx, int sg, int tso, int ipsec)
 {
 	fprintf(stdout,
 		"rx-checksumming: %s\n"
 		"tx-checksumming: %s\n"
 		"scatter-gather: %s\n"
-		"tcp segmentation offload: %s\n",
+		"tcp segmentation offload: %s\n"
+		"IPSEC crypto offload: %s\n",
 		rx ? "on" : "off",
 		tx ? "on" : "off",
 		sg ? "on" : "off",
-		tso ? "on" : "off");
+		tso ? "on" : "off",
+		ipsec ? "on" : "off");
 
 	return 0;
 }
@@ -1449,7 +1455,7 @@
 static int do_goffload(int fd, struct ifreq *ifr)
 {
 	struct ethtool_value eval;
-	int err, allfail = 1, rx = 0, tx = 0, sg = 0, tso = 0;
+	int err, allfail = 1, rx = 0, tx = 0, sg = 0, tso = 0, ipsec = 0;
 
 	fprintf(stdout, "Offload parameters for %s:\n", devname);
 
@@ -1493,12 +1499,22 @@
 		allfail = 0;
 	}
 
+	eval.cmd = ETHTOOL_GIPSEC;
+	ifr->ifr_data = (caddr_t)&eval;
+	err = ioctl(fd, SIOCETHTOOL, ifr);
+	if (err)
+		perror("Cannot get device IPSEC offload settings");
+	else {
+		ipsec = eval.data;
+		allfail = 0;
+	}
+
 	if (allfail) {
 		fprintf(stdout, "no offload info available\n");
 		return 83;
 	}
 
-	return dump_offload(rx, tx, sg, tso);
+	return dump_offload(rx, tx, sg, tso, ipsec);
 }
 
 static int do_soffload(int fd, struct ifreq *ifr)
@@ -1553,6 +1569,18 @@
 			return 88;
 		}
 	}
+
+	if (off_ipsec_wanted >= 0) {
+		changed = 1;
+		eval.cmd = ETHTOOL_SIPSEC;
+		eval.data = (off_ipsec_wanted == 1);
+		ifr->ifr_data = (caddr_t)&eval;
+		err = ioctl(fd, SIOCETHTOOL, ifr);
+		if (err) {
+			perror("Cannot set device IPSEEC offload settings");
+			return 89;
+		}
+	}
 	if (!changed) {
 		fprintf(stdout, "no offload settings changed\n");
 	}
diff -urN ethtool-2/ethtool-copy.h ethtool-2-ipsec/ethtool-copy.h
--- ethtool-2/ethtool-copy.h	2003-07-19 11:19:52.000000000 -0400
+++ ethtool-2-ipsec/ethtool-copy.h	2004-11-21 02:46:03.000000000 -0500
@@ -283,6 +283,8 @@
 #define ETHTOOL_GSTATS		0x0000001d /* get NIC-specific statistics */
 #define ETHTOOL_GTSO		0x0000001e /* Get TSO enable (ethtool_value) */
 #define ETHTOOL_STSO		0x0000001f /* Set TSO enable (ethtool_value) */
+#define ETHTOOL_GIPSEC		0x00000020 /* Get IPSEC enable (ethtool_value) */
+#define ETHTOOL_SIPSEC		0x00000021 /* Set IPSEC enable (ethtool_value) */
 
 /* compatibility with older code */
 #define SPARC_ETH_GSET		ETHTOOL_GSET

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Ethtool offload patch
  2004-12-30  8:54 Ethtool offload patch David Dillow
@ 2005-01-04 17:44 ` David S. Miller
  2005-01-04 19:04   ` Dave Dillow
  0 siblings, 1 reply; 4+ messages in thread
From: David S. Miller @ 2005-01-04 17:44 UTC (permalink / raw)
  To: David Dillow; +Cc: netdev, dave

On Thu, 30 Dec 2004 03:54:55 -0500
David Dillow <dave@thedillows.org> wrote:

> The attached patch allows the ethtool userspace tool to query and
> control IPSEC crypto offload.

Aren't you going to need something much more sophisticated
than a boolean on/off value?  How can I tell the driver
"offload 3DES ESP, but not AH at all" or something like
that?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Ethtool offload patch
  2005-01-04 17:44 ` David S. Miller
@ 2005-01-04 19:04   ` Dave Dillow
  2005-01-07  6:44     ` David S. Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Dillow @ 2005-01-04 19:04 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev

On Tue, 2005-01-04 at 12:44, David S. Miller wrote:
> On Thu, 30 Dec 2004 03:54:55 -0500
> David Dillow <dave@thedillows.org> wrote:
> 
> > The attached patch allows the ethtool userspace tool to query and
> > control IPSEC crypto offload.
> 
> Aren't you going to need something much more sophisticated
> than a boolean on/off value?  How can I tell the driver
> "offload 3DES ESP, but not AH at all" or something like
> that?

Sure, but this was quicker. :)

Actually, I thought that would be better suited to the xfrm_user/pf_key
interfaces, perhaps using a flag on the SA that says "do not offload
me", or perhaps the opposite. I'd probably want to add a flag to
indicate which ones were actually offloaded as well so "ip xfrm state"
could give an overview of what is currently offloaded.

I know you just got back from vacation, so when you get a chance, I'd
welcome comments on the patch series -- I did most of it simply, just to
see how it would perform. There is (obviously) still work to do -- I
need to figure out how to determine if an IPv6 address is local, and it
may be nice to have some sort of LRU list to offload the most active SAs
when resources get low on the card.

The current version I'm testing includes the changes suggested on the
board (change afinfo->map_direction() and remove xfrm_bundle_list), as
well as a change to call dev->xfrm_state_add() and
dev->xfrm_bundle_add() from process context, so I can get rid of the
GFP_ATOMIC allocations.

I'll have that out as soon as I can test and rediff everything, but in
the meantime, is the whole idea fatally flawed?
-- 
Dave Dillow <dave@thedillows.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Ethtool offload patch
  2005-01-04 19:04   ` Dave Dillow
@ 2005-01-07  6:44     ` David S. Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David S. Miller @ 2005-01-07  6:44 UTC (permalink / raw)
  To: Dave Dillow; +Cc: netdev

On Tue, 04 Jan 2005 14:04:31 -0500
Dave Dillow <dave@thedillows.org> wrote:

> I know you just got back from vacation, so when you get a chance, I'd
> welcome comments on the patch series -- I did most of it simply, just to
> see how it would perform. There is (obviously) still work to do -- I
> need to figure out how to determine if an IPv6 address is local, and it
> may be nice to have some sort of LRU list to offload the most active SAs
> when resources get low on the card.

I intend to review this next week some time.  Sorry for the delay,
but it's snowing like crazy in the mountains and I simply can't
resist taking advantage of that :-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-01-07  6:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-30  8:54 Ethtool offload patch David Dillow
2005-01-04 17:44 ` David S. Miller
2005-01-04 19:04   ` Dave Dillow
2005-01-07  6:44     ` David S. Miller

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).