From patchwork Fri Jan 9 02:52:44 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 17463 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 37267DE7C1 for ; Fri, 9 Jan 2009 13:53:12 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752931AbZAICxI (ORCPT ); Thu, 8 Jan 2009 21:53:08 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752623AbZAICxI (ORCPT ); Thu, 8 Jan 2009 21:53:08 -0500 Received: from rhun.apana.org.au ([64.62.148.172]:56569 "EHLO arnor.apana.org.au" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752617AbZAICxH (ORCPT ); Thu, 8 Jan 2009 21:53:07 -0500 Received: from gondolin.me.apana.org.au ([192.168.0.6]) by arnor.apana.org.au with esmtp (Exim 4.63 #1 (Debian)) id 1LL7UW-0005xp-45; Fri, 09 Jan 2009 13:52:56 +1100 Received: from herbert by gondolin.me.apana.org.au with local (Exim 4.69) (envelope-from ) id 1LL7UK-0002xI-NC; Fri, 09 Jan 2009 13:52:44 +1100 Date: Fri, 9 Jan 2009 13:52:44 +1100 From: Herbert Xu To: Jeff Garzik Cc: Ben Hutchings , Rick Jones , davem@davemloft.net, netdev@vger.kernel.org Subject: Re: [PATCH] Make possible speeds known to ethtool Message-ID: <20090109025244.GA11336@gondor.apana.org.au> References: <200901080203.SAA19103@tardy.cup.hp.com> <1231384446.2677.32.camel@hashbaz.i.decadent.org.uk> <49656F01.3090603@pobox.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <49656F01.3090603@pobox.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, Jan 08, 2009 at 03:12:01AM +0000, Jeff Garzik wrote: > > The next release of ethtool is coming in about 4 weeks, and we can > definitely get something like this in there. Jeff, any chance you can stick this patch in there to add the GRO toggle? ethtool: Add GRO toggle This patch adds the -k toggles to query and set GRO on a device. Signed-off-by: Herbert Xu Thanks, diff --git a/ethtool-copy.h b/ethtool-copy.h index eadba25..3ca4e2c 100644 --- a/ethtool-copy.h +++ b/ethtool-copy.h @@ -336,6 +336,8 @@ struct ethtool_rxnfc { #define ETHTOOL_GRXFH 0x00000029 /* Get RX flow hash configuration */ #define ETHTOOL_SRXFH 0x0000002a /* Set RX flow hash configuration */ +#define ETHTOOL_GGRO 0x0000002b /* Get GRO enable (ethtool_value) */ +#define ETHTOOL_SGRO 0x0000002c /* Set GRO enable (ethtool_value) */ /* compatibility with older code */ #define SPARC_ETH_GSET ETHTOOL_GSET diff --git a/ethtool.c b/ethtool.c index a7c02d0..502fc8f 100644 --- a/ethtool.c +++ b/ethtool.c @@ -160,6 +160,7 @@ static struct option { " [ tso on|off ]\n" " [ ufo on|off ]\n" " [ gso on|off ]\n" + " [ gro on|off ]\n" " [ lro on|off ]\n" }, { "-i", "--driver", MODE_GDRV, "Show driver information" }, @@ -218,6 +219,7 @@ static int off_sg_wanted = -1; static int off_tso_wanted = -1; static int off_ufo_wanted = -1; static int off_gso_wanted = -1; +static int off_gro_wanted = -1; static int off_lro_wanted = -1; static struct ethtool_pauseparam epause; @@ -333,6 +335,7 @@ static struct cmdline_info cmdline_offload[] = { { "tso", CMDL_BOOL, &off_tso_wanted, NULL }, { "ufo", CMDL_BOOL, &off_ufo_wanted, NULL }, { "gso", CMDL_BOOL, &off_gso_wanted, NULL }, + { "gro", CMDL_BOOL, &off_gro_wanted, NULL }, { "lro", CMDL_BOOL, &off_lro_wanted, NULL }, }; @@ -1387,7 +1390,8 @@ static int dump_coalesce(void) return 0; } -static int dump_offload(int rx, int tx, int sg, int tso, int ufo, int gso, int lro) +static int dump_offload(int rx, int tx, int sg, int tso, int ufo, int gso, + int gro, int lro) { fprintf(stdout, "rx-checksumming: %s\n" @@ -1396,6 +1400,7 @@ static int dump_offload(int rx, int tx, int sg, int tso, int ufo, int gso, int l "tcp segmentation offload: %s\n" "udp fragmentation offload: %s\n" "generic segmentation offload: %s\n" + "generic receive offload: %s\n" "large receive offload: %s\n", rx ? "on" : "off", tx ? "on" : "off", @@ -1403,6 +1408,7 @@ static int dump_offload(int rx, int tx, int sg, int tso, int ufo, int gso, int l tso ? "on" : "off", ufo ? "on" : "off", gso ? "on" : "off", + gro ? "on" : "off", lro ? "on" : "off"); return 0; @@ -1714,7 +1720,7 @@ static int do_goffload(int fd, struct ifreq *ifr) { struct ethtool_value eval; int err, allfail = 1, rx = 0, tx = 0, sg = 0; - int tso = 0, ufo = 0, gso = 0, lro = 0; + int tso = 0, ufo = 0, gso = 0, gro = 0, lro = 0; fprintf(stdout, "Offload parameters for %s:\n", devname); @@ -1778,6 +1784,16 @@ static int do_goffload(int fd, struct ifreq *ifr) allfail = 0; } + eval.cmd = ETHTOOL_GGRO; + ifr->ifr_data = (caddr_t)&eval; + err = ioctl(fd, SIOCETHTOOL, ifr); + if (err) + perror("Cannot get device generic receive offload settings"); + else { + gro = eval.data; + allfail = 0; + } + eval.cmd = ETHTOOL_GFLAGS; ifr->ifr_data = (caddr_t)&eval; err = ioctl(fd, SIOCETHTOOL, ifr); @@ -1793,7 +1809,7 @@ static int do_goffload(int fd, struct ifreq *ifr) return 83; } - return dump_offload(rx, tx, sg, tso, ufo, gso, lro); + return dump_offload(rx, tx, sg, tso, ufo, gso, gro, lro); } static int do_soffload(int fd, struct ifreq *ifr) @@ -1870,6 +1886,17 @@ static int do_soffload(int fd, struct ifreq *ifr) return 90; } } + if (off_gro_wanted >= 0) { + changed = 1; + eval.cmd = ETHTOOL_SGRO; + eval.data = (off_gro_wanted == 1); + ifr->ifr_data = (caddr_t)&eval; + err = ioctl(fd, SIOCETHTOOL, ifr); + if (err) { + perror("Cannot set device generic receive offload settings"); + return 93; + } + } if (off_lro_wanted >= 0) { changed = 1; eval.cmd = ETHTOOL_GFLAGS;