* [PATCH 0/9] New cxgb4vf network driver for Chelsio T4 Virtual Function NIC
From: Casey Leedom @ 2010-06-25 22:07 UTC (permalink / raw)
To: netdev
This patch series introduces a new network driver for the Chelsio T4 PCI-E
SR-IOV Virtual Function NIC. The patches are against net-next as of commit
39c9cf07077146b14ab077a0e27c869c6f0e6199.
This driver "depends" on the cxgb4 NIC driver only in-so-far as the cxgb4
driver needs to "provision" chip resources for each of the Virtual Functions
and the cxgb4 driver must enable the PCI-E SR-IOV functionality. After that
the new "cxgb4vf" driver operates completely independently. (It will often
be the case that the cxgb4vf driver will be operating withing a Virtual
Machine via "PCI Pass Through."
This is my first submission to Linux so I apologize in advance for any
mistakes. I looked at many submissions to see how to do this but I
anticipate that I've almost certainly missed something critical. Please
correct me on anything I've done wrong and I will happily fix them. Thanks
in advance for you patience and understanding.
There is one part of this submission where I needed to make a big guess
regarding driver policies and procedures so I'll draw your attention to
that. There are several header files which both the cxgb4 and cxgb4vf
drivers need to operate (T4 hardware register definitions, message
structures, etc.) This patch series leaves those files in place within the
cxgb4 driver directory (with a few tiny modifications to add new
definitions) and the cxgb4vf driver includes them via "../cxgb4/xxx.h" I
found a couple of similar usages but I couldn't determine what the official
policy was.
Again, thank you for your time and consideration.
Casey Leedom
drivers/net/Kconfig | 23 +
drivers/net/Makefile | 1 +
drivers/net/cxgb4/cxgb4_main.c | 106 ++
drivers/net/cxgb4/t4_hw.c | 2 +-
drivers/net/cxgb4/t4_hw.h | 39 +
drivers/net/cxgb4/t4_regs.h | 3 +
drivers/net/cxgb4/t4fw_api.h | 27 +-
drivers/net/cxgb4vf/Makefile | 7 +
drivers/net/cxgb4vf/adapter.h | 540 +++++++
drivers/net/cxgb4vf/cxgb4vf_main.c | 2906 ++++++++++++++++++++++++++++++++++++
drivers/net/cxgb4vf/sge.c | 2460 ++++++++++++++++++++++++++++++
drivers/net/cxgb4vf/t4vf_common.h | 273 ++++
drivers/net/cxgb4vf/t4vf_defs.h | 121 ++
drivers/net/cxgb4vf/t4vf_hw.c | 1333 +++++++++++++++++
14 files changed, 7834 insertions(+), 7 deletions(-)
^ permalink raw reply
* Re: [RFC PATCH v2 4/5] skb: add tracepoints to freeing skb
From: Eric Dumazet @ 2010-06-25 20:05 UTC (permalink / raw)
To: Koki Sanagi; +Cc: linux-kernel, kaneshige.kenji, izumi.taku, netdev
In-Reply-To: <4C2456DA.8030200@jp.fujitsu.com>
Le vendredi 25 juin 2010 à 16:12 +0900, Koki Sanagi a écrit :
> > You might add a trace point to skb_free_datagram_locked() too, since it
> > contains an inlined consume_skb()
> >
>
> I think it is contrary.
I think you are _very_ wrong.
> skb_free_datagram_locked() contains consume_skb(), so tracepoint isn't needed.
> Because skb_free_datagram_locked() can be traced by trace_consume_skb().
>
>
>
Koki, it would be good if you worked on net-next-2.6, so that my comment
applies.
Also, not sending this kind of patches on netdev is not going to help
very much.
Who is supposed to review them on lkml and Ack them ?
Nobody.
Please build your future network related patches against net-next-2.6,
and send them to nedev and David Miller, the official network
maintainer, as stated in MAINTAINERS file.
NETWORKING [GENERAL]
M: "David S. Miller" <davem@davemloft.net>
L: netdev@vger.kernel.org
W: http://www.linuxfoundation.org/en/Net
W: http://patchwork.ozlabs.org/project/netdev/list/
T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.git
T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6.git
S: Maintained
F: net/
F: include/net/
F: include/linux/in.h
F: include/linux/net.h
F: include/linux/netdevice.h
^ permalink raw reply
* [PATCH 2.6.35] bonding: prevent netpoll over bonded interfaces
From: Andy Gospodarek @ 2010-06-25 19:50 UTC (permalink / raw)
To: netdev, amwang, fubar
Support for netpoll over bonded interfaces was added here:
commit f6dc31a85cd46a959bdd987adad14c3b645e03c1
Author: WANG Cong <amwang@redhat.com>
Date: Thu May 6 00:48:51 2010 -0700
bonding: make bonding support netpoll
but it is bad enough that we should probably just disable netpoll over
bonding until some of the locking logic in the bonding driver is changed
or converted completely to RCU. Simple actions like changing the active
slave in active-backup mode will hang the box if a high enough printk
debugging level is enabled.
Keeping the old code around will be good for anyone that wants to work
on it (and for after the RCU conversion), so I propose this small patch
rather than ripping it all out.
Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
---
drivers/net/bonding/bond_main.c | 33 ++++++++++++++++++++++-----------
1 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 5e12462..c3d98dd 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -168,7 +168,7 @@ static int arp_ip_count;
static int bond_mode = BOND_MODE_ROUNDROBIN;
static int xmit_hashtype = BOND_XMIT_POLICY_LAYER2;
static int lacp_fast;
-
+static int disable_netpoll = 1;
const struct bond_parm_tbl bond_lacp_tbl[] = {
{ "slow", AD_LACP_SLOW},
@@ -1742,15 +1742,23 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
bond_set_carrier(bond);
#ifdef CONFIG_NET_POLL_CONTROLLER
- if (slaves_support_netpoll(bond_dev)) {
- bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL;
- if (bond_dev->npinfo)
- slave_dev->npinfo = bond_dev->npinfo;
- } else if (!(bond_dev->priv_flags & IFF_DISABLE_NETPOLL)) {
+ /*
+ * Netpoll and bonding is broken, make sure it is not initialized
+ * until it is fixed.
+ */
+ if (disable_netpoll) {
bond_dev->priv_flags |= IFF_DISABLE_NETPOLL;
- pr_info("New slave device %s does not support netpoll\n",
- slave_dev->name);
- pr_info("Disabling netpoll support for %s\n", bond_dev->name);
+ } else {
+ if (slaves_support_netpoll(bond_dev)) {
+ bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL;
+ if (bond_dev->npinfo)
+ slave_dev->npinfo = bond_dev->npinfo;
+ } else if (!(bond_dev->priv_flags & IFF_DISABLE_NETPOLL)) {
+ bond_dev->priv_flags |= IFF_DISABLE_NETPOLL;
+ pr_info("New slave device %s does not support netpoll\n",
+ slave_dev->name);
+ pr_info("Disabling netpoll support for %s\n", bond_dev->name);
+ }
}
#endif
read_unlock(&bond->lock);
@@ -1950,8 +1958,11 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
#ifdef CONFIG_NET_POLL_CONTROLLER
read_lock_bh(&bond->lock);
- if (slaves_support_netpoll(bond_dev))
- bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL;
+
+ /* Make sure netpoll over stays disabled until fixed. */
+ if (!disable_netpoll)
+ if (slaves_support_netpoll(bond_dev))
+ bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL;
read_unlock_bh(&bond->lock);
if (slave_dev->netdev_ops->ndo_netpoll_cleanup)
slave_dev->netdev_ops->ndo_netpoll_cleanup(slave_dev);
^ permalink raw reply related
* Re: nonlocal_bind & IPv6
From: Michal Humpula @ 2010-06-25 19:10 UTC (permalink / raw)
To: Rémi Denis-Courmont; +Cc: netdev
In-Reply-To: <30fe1fa984e52f4cca318e54f9d97a21@chewa.net>
Ok, more detail example.
Let on each node be an apache (just for an example), and you configure VirtualHost for
specific IP. So when node A fails, keepalived move IP to the node B and everything is
still running. No need for restart of apache or anything else. There is a probably a
better solution, but I can't find anything more simple than the posted patch:)
On Friday 25 of June 2010 20:59:58 Rémi Denis-Courmont wrote:
> On Fri, 25 Jun 2010 20:43:45 +0200, Michal Humpula
>
> <michal.humpula@hudrydum.cz> wrote:
> > I was just wondering, what's wrong with this?
>
> It's not in unified format :D
>
> > *** linux-2.6.34/net/ipv6/af_inet6.c 2010-05-16 23:17:36.000000000
> > +0200
> > --- linux-2.6.34-hack/net/ipv6/af_inet6.c 2010-06-25
> > 19:50:19.000000000 +0200
> > ***************
> > *** 345,354 ****
> > --- 345,356 ----
> >
> > if (!(addr_type & IPV6_ADDR_MULTICAST)) {
> >
> > if (!ipv6_chk_addr(net, &addr->sin6_addr,
> >
> > dev, 0)) {
> >
> > + if (!sysctl_ip_nonlocal_bind) {
> >
> > err = -EADDRNOTAVAIL;
> > goto out_unlock;
> >
> > }
> >
> > }
> >
> > + }
> >
> > rcu_read_unlock();
> >
> > }
> >
> > }
> >
> > Motivation: just want to balance one IPv6 address between two nodes with
> > the help of keepalived the same way I do it with IPv4 without the need
> > of restarting the daemons binding on that IP.
>
> nonlocal_bind seems a bit 80's to me. Why don't you bind the daemon to
> [::]? If it needs to know its own address, it can always use getsockname()
> for connected sockets and IPV6_PKTINFO ancillary data for datagram sockets.
^ permalink raw reply
* Re: nonlocal_bind & IPv6
From: Rémi Denis-Courmont @ 2010-06-25 18:59 UTC (permalink / raw)
To: Michal Humpula; +Cc: netdev
In-Reply-To: <201006252043.45581.michal.humpula@hudrydum.cz>
On Fri, 25 Jun 2010 20:43:45 +0200, Michal Humpula
<michal.humpula@hudrydum.cz> wrote:
> I was just wondering, what's wrong with this?
It's not in unified format :D
> *** linux-2.6.34/net/ipv6/af_inet6.c 2010-05-16 23:17:36.000000000
> +0200
> --- linux-2.6.34-hack/net/ipv6/af_inet6.c 2010-06-25
> 19:50:19.000000000 +0200
> ***************
> *** 345,354 ****
> --- 345,356 ----
> if (!(addr_type & IPV6_ADDR_MULTICAST)) {
> if (!ipv6_chk_addr(net, &addr->sin6_addr,
> dev, 0)) {
> + if (!sysctl_ip_nonlocal_bind) {
> err = -EADDRNOTAVAIL;
> goto out_unlock;
> }
> }
> + }
> rcu_read_unlock();
> }
> }
>
> Motivation: just want to balance one IPv6 address between two nodes with
> the help of keepalived the same way I do it with IPv4 without the need
> of restarting the daemons binding on that IP.
nonlocal_bind seems a bit 80's to me. Why don't you bind the daemon to
[::]? If it needs to know its own address, it can always use getsockname()
for connected sockets and IPV6_PKTINFO ancillary data for datagram sockets.
--
Rémi Denis-Courmont
http://www.remlab.net
http://fi.linkedin.com/in/remidenis
^ permalink raw reply
* nonlocal_bind & IPv6
From: Michal Humpula @ 2010-06-25 18:43 UTC (permalink / raw)
To: netdev
Hi,
I was just wondering, what's wrong with this?
*** linux-2.6.34/net/ipv6/af_inet6.c 2010-05-16 23:17:36.000000000 +0200
--- linux-2.6.34-hack/net/ipv6/af_inet6.c 2010-06-25 19:50:19.000000000 +0200
***************
*** 345,354 ****
--- 345,356 ----
if (!(addr_type & IPV6_ADDR_MULTICAST)) {
if (!ipv6_chk_addr(net, &addr->sin6_addr,
dev, 0)) {
+ if (!sysctl_ip_nonlocal_bind) {
err = -EADDRNOTAVAIL;
goto out_unlock;
}
}
+ }
rcu_read_unlock();
}
}
Motivation: just want to balance one IPv6 address between two nodes with the help of
keepalived the same way I do it with IPv4 without the need of restarting the daemons
binding on that IP.
Regards
Michal Humpula
^ permalink raw reply
* LPC track "User visible challenges in Networking" - topics wanted
From: Matt Domsch @ 2010-06-25 18:27 UTC (permalink / raw)
To: netdev
Greetings. I've been asked to organize a track for the Linux Plumbers
Conference [1], November 3-5, 2010 in Cambridge, MA. As I'm still
pursuing my "Deterministic Network Device Naming" problem, that's one
topic for the track. Dan Williams of NetworkManager fame has agreed
to submit a topic.
I'm actively soliciting more ideas for presentation and conversation
to fill a ~2.5 hour mini-conference.
If you have a challenge that you think would benefit from discussion
at the Plumbers Conference, please add your idea to the wiki [2], and
drop me a note.
Thanks,
Matt
[1] http://www.linuxplumbersconf.org/2010/
[2] http://wiki.linuxplumbersconf.org/2010:topics
--
Matt Domsch
Technology Strategist
Dell | Office of the CTO
^ permalink raw reply
* Re: linux-next: manual merge of the net tree with the net-current tree
From: David Miller @ 2010-06-25 18:22 UTC (permalink / raw)
To: sfr; +Cc: netdev, linux-next, linux-kernel, herbert, xiaosuo, eric.dumazet
In-Reply-To: <20100623125116.1370bdd4.sfr@canb.auug.org.au>
From: Stephen Rothwell <sfr@canb.auug.org.au>
Date: Wed, 23 Jun 2010 12:51:16 +1000
> Hi all,
>
> Today's linux-next merge of the net tree got a conflict in
> net/ipv4/ip_output.c between commit
> 26cde9f7e2747b6d254b704594eed87ab959afa5 ("udp: Fix bogus UFO packet
> generation") from the net-current tree and commit
> d8d1f30b95a635dbd610dcc5eb641aca8f4768cf ("net-next: remove useless union
> keyword") from the net tree.
>
> Just context changes. I fixed it up (see below) and can carry the fix as
> necessary.
I recently merged net-2.6 into net-next-2.6, let me know if the problem
persists.
^ permalink raw reply
* Re: dhclient, checksum and tap
From: David Miller @ 2010-06-25 18:21 UTC (permalink / raw)
To: mst; +Cc: herbert.xu, netdev
In-Reply-To: <20100625151008.GA17911@redhat.com>
From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Fri, 25 Jun 2010 18:10:08 +0300
> I've been looking at the issue of checksum on
> dhcp packets: to recap, 8dc4194474159660d7f37c495e3fc3f10d0db8cc
> added a way for af_packet sockets to get the packet status.
> Unfortunately not all dhcp clients caught up with
> this development, so they are still broken
> when both server and client run on the same host,
> e.g. with bridge+tap.
>
> And of course virtualization adds another way to run
> old dhcp clients, so userspace virtio net in qemu has
> a hack to detect DHCP and fill in the checksum.
> I guess we could add this in vhost, as well.
>
> However, one wonders whether the tap driver is a better place
> for this work-around, that would help all users.
> Any objections against putting such code in tap?
We added the af_packet status as the migration path to deal with
this issue in the cleanest manner possible. Putting a new hack
into the TAP driver works contrary to that goal.
^ permalink raw reply
* Re: [PATCH] smsc95xx: Add module parameter to override MAC address
From: David Miller @ 2010-06-25 18:17 UTC (permalink / raw)
To: s-jan; +Cc: Steve.Glendinning, horms, linux-omap, netdev, Ian.Saturley
In-Reply-To: <4C24BB34.3010601@ti.com>
From: Sebastien Jan <s-jan@ti.com>
Date: Fri, 25 Jun 2010 16:20:36 +0200
> Hi Steve,
>
> Thanks for your answer.
>
> On 06/25/2010 10:43 AM, Steve.Glendinning@smsc.com wrote:
> [...]
>> I can see you have a different use case, but I don't think this specific
>> driver is the place for this logic. I'd rather see it added to either
>> the usbnet framework or (preferably) the netdev framework so *all*
>> ethernet drivers can do this the same way. otherwise we could end up
>> with slight variations of this code in every single driver!
>
> I perfectly understand your concerns. Unfortunately, I will probably not be
> able to implement these changes into the netdev framework. However, I'd be
> happy to make some tests if someone proposes such changes.
I don't think such logic belongs anywhere other than an initrd.
We have mechanisms by which to handle this already, and contrary to
what many people claim it is not at all so hard to create a custom
initrd.
^ permalink raw reply
* Re: SO_REUSEPORT
From: Tom Herbert @ 2010-06-25 17:39 UTC (permalink / raw)
To: Brian Bloniarz; +Cc: Alexander Clouter, linux-kernel, netdev
In-Reply-To: <4C2231B5.10401@athenacr.com>
>> Of course this depends on what you are doing, but my opinion is that the
>> functionality has been unneeded so far by people in the kernel, so *I*
>> must be doing something wrong ;)
>
> Tom Herbert gave a pretty great description of why you
> might want this functionality in his original patch submission:
>
> http://kerneltrap.org/mailarchive/linux-netdev/2010/4/19/6274993
>
> If you follow that thread though, there wasn't consensus about
> the best architecture & API for it, and nothing has made it
> yet.
>
I am planning to get back to this as the patch still needs some work
and isn't quite robust or optimized yet. Some restructuring is needed
in the socket hash lists. The UDP implementation in the patch will
work okay, and the TCP works as long as the number of listeners isn't
changing.
^ permalink raw reply
* Re: [PATCH ethtool 4/5] ethtool: Implement named message type flags
From: Jeff Garzik @ 2010-06-25 17:11 UTC (permalink / raw)
To: Ben Hutchings; +Cc: netdev, linux-net-drivers
In-Reply-To: <1277477385.2094.9.camel@achroite.uk.solarflarecom.com>
On 06/25/2010 10:49 AM, Ben Hutchings wrote:
> +static struct cmdline_info cmdline_msglvl[] = {
> + { "drv", CMDL_FLAG,&msglvl_wanted, NULL,
> + NETIF_MSG_DRV,&msglvl_unwanted },
> + { "probe", CMDL_FLAG,&msglvl_wanted, NULL,
> + NETIF_MSG_PROBE,&msglvl_unwanted },
> + { "link", CMDL_FLAG,&msglvl_wanted, NULL,
> + NETIF_MSG_LINK,&msglvl_unwanted },
> + { "timer", CMDL_FLAG,&msglvl_wanted, NULL,
> + NETIF_MSG_TIMER,&msglvl_unwanted },
> + { "ifdown", CMDL_FLAG,&msglvl_wanted, NULL,
> + NETIF_MSG_IFDOWN,&msglvl_unwanted },
> + { "ifup", CMDL_FLAG,&msglvl_wanted, NULL,
> + NETIF_MSG_IFUP,&msglvl_unwanted },
> + { "rx_err", CMDL_FLAG,&msglvl_wanted, NULL,
> + NETIF_MSG_RX_ERR,&msglvl_unwanted },
> + { "tx_err", CMDL_FLAG,&msglvl_wanted, NULL,
> + NETIF_MSG_TX_ERR,&msglvl_unwanted },
> + { "tx_queued", CMDL_FLAG,&msglvl_wanted, NULL,
> + NETIF_MSG_TX_QUEUED,&msglvl_unwanted },
> + { "intr", CMDL_FLAG,&msglvl_wanted, NULL,
> + NETIF_MSG_INTR,&msglvl_unwanted },
> + { "tx_done", CMDL_FLAG,&msglvl_wanted, NULL,
> + NETIF_MSG_TX_DONE,&msglvl_unwanted },
> + { "rx_status", CMDL_FLAG,&msglvl_wanted, NULL,
> + NETIF_MSG_RX_STATUS,&msglvl_unwanted },
> + { "pktdata", CMDL_FLAG,&msglvl_wanted, NULL,
> + NETIF_MSG_PKTDATA,&msglvl_unwanted },
> + { "hw", CMDL_FLAG,&msglvl_wanted, NULL,
> + NETIF_MSG_HW,&msglvl_unwanted },
> + { "wol", CMDL_FLAG,&msglvl_wanted, NULL,
> + NETIF_MSG_WOL,&msglvl_unwanted },
A nice improvement over one-variable-per-bit, I think.
applied patches 1-5, thanks!
Jeff
P.S. If you could use my open source email address (jgarzik@pobox.com
or jeff@garzik.org), that would be greatly appreciated. @redhat.com is
only used for sign-offs, as it's less portable than !@redhat.com addresses.
^ permalink raw reply
* [PATCH net-next-2.6 4/4] sfc: Log clearer error messages for hardware monitor
From: Ben Hutchings @ 2010-06-25 17:06 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers, Jesper Dangaard Brouer
In-Reply-To: <1277485434.2094.13.camel@achroite.uk.solarflarecom.com>
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
drivers/net/sfc/falcon_boards.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/net/sfc/falcon_boards.c b/drivers/net/sfc/falcon_boards.c
index 92b35e3..3d950c2 100644
--- a/drivers/net/sfc/falcon_boards.c
+++ b/drivers/net/sfc/falcon_boards.c
@@ -108,10 +108,15 @@ static int efx_check_lm87(struct efx_nic *efx, unsigned mask)
if (alarms1 || alarms2) {
netif_err(efx, hw, efx->net_dev,
"LM87 detected a hardware failure (status %02x:%02x)"
- "%s%s\n",
+ "%s%s%s\n",
alarms1, alarms2,
- (alarms1 & LM87_ALARM_TEMP_INT) ? " INTERNAL" : "",
- (alarms1 & LM87_ALARM_TEMP_EXT1) ? " EXTERNAL" : "");
+ (alarms1 & LM87_ALARM_TEMP_INT) ?
+ "; board is overheating" : "",
+ (alarms1 & LM87_ALARM_TEMP_EXT1) ?
+ "; controller is overheating" : "",
+ (alarms1 & ~(LM87_ALARM_TEMP_INT | LM87_ALARM_TEMP_EXT1)
+ || alarms2) ?
+ "; electrical fault" : "");
return -ERANGE;
}
--
1.6.2.5
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related
* [PATCH net-next-2.6 3/4] sfc: Use Toeplitz IPv4 hash for RSS and hash insertion
From: Ben Hutchings @ 2010-06-25 17:05 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers
In-Reply-To: <1277485434.2094.13.camel@achroite.uk.solarflarecom.com>
Insertion of the Falcon hash is unreliable.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
drivers/net/sfc/falcon.c | 14 ++++++++++++--
drivers/net/sfc/siena.c | 11 ++++++++++-
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index 5a40145..4f9d33f 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -1581,8 +1581,14 @@ static void falcon_init_rx_cfg(struct efx_nic *efx)
EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_XOFF_MAC_TH, data_xoff_thr);
EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_XON_TX_TH, ctrl_xon_thr);
EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_XOFF_TX_TH, ctrl_xoff_thr);
- EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_HASH_INSRT_HDR, 1);
EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_INGR_EN, 1);
+
+ /* Enable hash insertion. This is broken for the
+ * 'Falcon' hash so also select Toeplitz TCP/IPv4 and
+ * IPv4 hashes. */
+ EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_HASH_INSRT_HDR, 1);
+ EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_HASH_ALG, 1);
+ EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_IP_HASH, 1);
}
/* Always enable XOFF signal from RX FIFO. We enable
* or disable transmission of pause frames at the MAC. */
@@ -1656,8 +1662,12 @@ static int falcon_init_nic(struct efx_nic *efx)
falcon_init_rx_cfg(efx);
- /* Set destination of both TX and RX Flush events */
if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0) {
+ /* Set hash key for IPv4 */
+ memcpy(&temp, efx->rx_hash_key, sizeof(temp));
+ efx_writeo(efx, &temp, FR_BZ_RX_RSS_TKEY);
+
+ /* Set destination of both TX and RX Flush events */
EFX_POPULATE_OWORD_1(temp, FRF_BZ_FLS_EVQ_ID, 0);
efx_writeo(efx, &temp, FR_BZ_DP_CTRL);
}
diff --git a/drivers/net/sfc/siena.c b/drivers/net/sfc/siena.c
index 7fd258c..3fab030 100644
--- a/drivers/net/sfc/siena.c
+++ b/drivers/net/sfc/siena.c
@@ -327,10 +327,19 @@ static int siena_init_nic(struct efx_nic *efx)
efx_reado(efx, &temp, FR_AZ_RX_CFG);
EFX_SET_OWORD_FIELD(temp, FRF_BZ_RX_DESC_PUSH_EN, 0);
- EFX_SET_OWORD_FIELD(temp, FRF_BZ_RX_HASH_INSRT_HDR, 1);
EFX_SET_OWORD_FIELD(temp, FRF_BZ_RX_INGR_EN, 1);
+ /* Enable hash insertion. This is broken for the 'Falcon' hash
+ * if IPv6 hashing is also enabled, so also select Toeplitz
+ * TCP/IPv4 and IPv4 hashes. */
+ EFX_SET_OWORD_FIELD(temp, FRF_BZ_RX_HASH_INSRT_HDR, 1);
+ EFX_SET_OWORD_FIELD(temp, FRF_BZ_RX_HASH_ALG, 1);
+ EFX_SET_OWORD_FIELD(temp, FRF_BZ_RX_IP_HASH, 1);
efx_writeo(efx, &temp, FR_AZ_RX_CFG);
+ /* Set hash key for IPv4 */
+ memcpy(&temp, efx->rx_hash_key, sizeof(temp));
+ efx_writeo(efx, &temp, FR_BZ_RX_RSS_TKEY);
+
/* Enable IPv6 RSS */
BUILD_BUG_ON(sizeof(efx->rx_hash_key) <
2 * sizeof(temp) + FRF_CZ_RX_RSS_IPV6_TKEY_HI_WIDTH / 8 ||
--
1.6.2.5
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related
* [PATCH net-next-2.6 2/4] sfc: Move siena_nic_data::ipv6_rss_key to efx_nic::rx_hash_key
From: Ben Hutchings @ 2010-06-25 17:05 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers
In-Reply-To: <1277485434.2094.13.camel@achroite.uk.solarflarecom.com>
We will use this hash key for Toeplitz IPv4 hashing too.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
drivers/net/sfc/efx.c | 3 +++
drivers/net/sfc/net_driver.h | 1 +
drivers/net/sfc/nic.h | 1 -
drivers/net/sfc/siena.c | 12 ++++--------
4 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index d68f061..2a90bf9 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -1134,6 +1134,9 @@ static int efx_probe_nic(struct efx_nic *efx)
* in MSI-X interrupts. */
efx_probe_interrupts(efx);
+ if (efx->n_channels > 1)
+ get_random_bytes(&efx->rx_hash_key, sizeof(efx->rx_hash_key));
+
efx_set_channels(efx);
efx->net_dev->real_num_tx_queues = efx->n_tx_channels;
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h
index 8b17c92..ba272a4 100644
--- a/drivers/net/sfc/net_driver.h
+++ b/drivers/net/sfc/net_driver.h
@@ -733,6 +733,7 @@ struct efx_nic {
unsigned n_tx_channels;
unsigned int rx_buffer_len;
unsigned int rx_buffer_order;
+ u8 rx_hash_key[40];
unsigned int_error_count;
unsigned long int_error_expire;
diff --git a/drivers/net/sfc/nic.h b/drivers/net/sfc/nic.h
index 534461f..a39822d 100644
--- a/drivers/net/sfc/nic.h
+++ b/drivers/net/sfc/nic.h
@@ -142,7 +142,6 @@ struct siena_nic_data {
u32 fw_build;
struct efx_mcdi_iface mcdi;
int wol_filter_id;
- u8 ipv6_rss_key[40];
};
extern void siena_print_fwver(struct efx_nic *efx, char *buf, size_t len);
diff --git a/drivers/net/sfc/siena.c b/drivers/net/sfc/siena.c
index f1741b4..7fd258c 100644
--- a/drivers/net/sfc/siena.c
+++ b/drivers/net/sfc/siena.c
@@ -285,9 +285,6 @@ static int siena_probe_nic(struct efx_nic *efx)
goto fail5;
}
- get_random_bytes(&nic_data->ipv6_rss_key,
- sizeof(nic_data->ipv6_rss_key));
-
return 0;
fail5:
@@ -307,7 +304,6 @@ fail1:
*/
static int siena_init_nic(struct efx_nic *efx)
{
- struct siena_nic_data *nic_data = efx->nic_data;
efx_oword_t temp;
int rc;
@@ -336,16 +332,16 @@ static int siena_init_nic(struct efx_nic *efx)
efx_writeo(efx, &temp, FR_AZ_RX_CFG);
/* Enable IPv6 RSS */
- BUILD_BUG_ON(sizeof(nic_data->ipv6_rss_key) !=
+ BUILD_BUG_ON(sizeof(efx->rx_hash_key) <
2 * sizeof(temp) + FRF_CZ_RX_RSS_IPV6_TKEY_HI_WIDTH / 8 ||
FRF_CZ_RX_RSS_IPV6_TKEY_HI_LBN != 0);
- memcpy(&temp, nic_data->ipv6_rss_key, sizeof(temp));
+ memcpy(&temp, efx->rx_hash_key, sizeof(temp));
efx_writeo(efx, &temp, FR_CZ_RX_RSS_IPV6_REG1);
- memcpy(&temp, nic_data->ipv6_rss_key + sizeof(temp), sizeof(temp));
+ memcpy(&temp, efx->rx_hash_key + sizeof(temp), sizeof(temp));
efx_writeo(efx, &temp, FR_CZ_RX_RSS_IPV6_REG2);
EFX_POPULATE_OWORD_2(temp, FRF_CZ_RX_RSS_IPV6_THASH_ENABLE, 1,
FRF_CZ_RX_RSS_IPV6_IP_THASH_ENABLE, 1);
- memcpy(&temp, nic_data->ipv6_rss_key + 2 * sizeof(temp),
+ memcpy(&temp, efx->rx_hash_key + 2 * sizeof(temp),
FRF_CZ_RX_RSS_IPV6_TKEY_HI_WIDTH / 8);
efx_writeo(efx, &temp, FR_CZ_RX_RSS_IPV6_REG3);
--
1.6.2.5
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related
* [PATCH net-next-2.6 1/4] sfc: Fix reading of inserted hash
From: Ben Hutchings @ 2010-06-25 17:05 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers
In-Reply-To: <1277485434.2094.13.camel@achroite.uk.solarflarecom.com>
The hash appears immediately before the packet data, not at the
beginning of the buffer. This means we can easily use negative offsets
from the start of packet data, so adjust the data and length at the
top of __efx_rx_packet() instead of wherever we consume the hash.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
drivers/net/sfc/rx.c | 11 ++++++-----
drivers/net/sfc/selftest.c | 3 ---
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/net/sfc/rx.c b/drivers/net/sfc/rx.c
index 0fb9835..799c461 100644
--- a/drivers/net/sfc/rx.c
+++ b/drivers/net/sfc/rx.c
@@ -104,9 +104,9 @@ static inline unsigned int efx_rx_buf_size(struct efx_nic *efx)
static inline u32 efx_rx_buf_hash(struct efx_rx_buffer *buf)
{
#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) || NET_IP_ALIGN % 4 == 0
- return __le32_to_cpup((const __le32 *)buf->data);
+ return __le32_to_cpup((const __le32 *)(buf->data - 4));
#else
- const u8 *data = (const u8 *)buf->data;
+ const u8 *data = (const u8 *)(buf->data - 4);
return ((u32)data[0] |
(u32)data[1] << 8 |
(u32)data[2] << 16 |
@@ -469,8 +469,6 @@ static void efx_rx_packet_lro(struct efx_channel *channel,
if (efx->net_dev->features & NETIF_F_RXHASH)
skb->rxhash = efx_rx_buf_hash(rx_buf);
- rx_buf->data += efx->type->rx_buffer_hash_size;
- rx_buf->len -= efx->type->rx_buffer_hash_size;
skb_shinfo(skb)->frags[0].page = page;
skb_shinfo(skb)->frags[0].page_offset =
@@ -577,6 +575,9 @@ void __efx_rx_packet(struct efx_channel *channel,
struct efx_nic *efx = channel->efx;
struct sk_buff *skb;
+ rx_buf->data += efx->type->rx_buffer_hash_size;
+ rx_buf->len -= efx->type->rx_buffer_hash_size;
+
/* If we're in loopback test, then pass the packet directly to the
* loopback layer, and free the rx_buf here
*/
@@ -589,11 +590,11 @@ void __efx_rx_packet(struct efx_channel *channel,
if (rx_buf->skb) {
prefetch(skb_shinfo(rx_buf->skb));
+ skb_reserve(rx_buf->skb, efx->type->rx_buffer_hash_size);
skb_put(rx_buf->skb, rx_buf->len);
if (efx->net_dev->features & NETIF_F_RXHASH)
rx_buf->skb->rxhash = efx_rx_buf_hash(rx_buf);
- skb_pull(rx_buf->skb, efx->type->rx_buffer_hash_size);
/* Move past the ethernet header. rx_buf->data still points
* at the ethernet header */
diff --git a/drivers/net/sfc/selftest.c b/drivers/net/sfc/selftest.c
index 0399be2..85f015f 100644
--- a/drivers/net/sfc/selftest.c
+++ b/drivers/net/sfc/selftest.c
@@ -258,9 +258,6 @@ void efx_loopback_rx_packet(struct efx_nic *efx,
payload = &state->payload;
- buf_ptr += efx->type->rx_buffer_hash_size;
- pkt_len -= efx->type->rx_buffer_hash_size;
-
received = (struct efx_loopback_payload *) buf_ptr;
received->ip.saddr = payload->ip.saddr;
if (state->offload_csum)
--
1.6.2.5
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related
* [PATCH net-next-2.6 0/4] More sfc changes for 2.6.36
From: Ben Hutchings @ 2010-06-25 17:03 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers
Dave,
You appear to have applied all my previous patches to net-next-2.6, so
here are the fix-ups for hash insertion. Also, an improvement in
hardware monitoring which has been in the the out-of-tree sfc driver for
a while but which I failed to carry over.
Ben.
Ben Hutchings (4):
sfc: Fix reading of inserted hash
sfc: Move siena_nic_data::ipv6_rss_key to efx_nic::rx_hash_key
sfc: Use Toeplitz IPv4 hash for RSS and hash insertion
sfc: Log clearer error messages for hardware monitor
drivers/net/sfc/efx.c | 3 +++
drivers/net/sfc/falcon.c | 14 ++++++++++++--
drivers/net/sfc/falcon_boards.c | 11 ++++++++---
drivers/net/sfc/net_driver.h | 1 +
drivers/net/sfc/nic.h | 1 -
drivers/net/sfc/rx.c | 11 ++++++-----
drivers/net/sfc/selftest.c | 3 ---
drivers/net/sfc/siena.c | 23 ++++++++++++++---------
8 files changed, 44 insertions(+), 23 deletions(-)
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* dhclient, checksum and tap
From: Michael S. Tsirkin @ 2010-06-25 15:10 UTC (permalink / raw)
To: Herbert Xu; +Cc: netdev
Hi!
I've been looking at the issue of checksum on
dhcp packets: to recap, 8dc4194474159660d7f37c495e3fc3f10d0db8cc
added a way for af_packet sockets to get the packet status.
Unfortunately not all dhcp clients caught up with
this development, so they are still broken
when both server and client run on the same host,
e.g. with bridge+tap.
And of course virtualization adds another way to run
old dhcp clients, so userspace virtio net in qemu has
a hack to detect DHCP and fill in the checksum.
I guess we could add this in vhost, as well.
However, one wonders whether the tap driver is a better place
for this work-around, that would help all users.
Any objections against putting such code in tap?
--
MST
^ permalink raw reply
* [PATCH ethtool 5/5] ethtool: Use named flag support to update extended offload flags
From: Ben Hutchings @ 2010-06-25 14:50 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, linux-net-drivers
In-Reply-To: <1277477027.2094.2.camel@achroite.uk.solarflarecom.com>
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
ethtool.c | 70 ++++++++++--------------------------------------------------
1 files changed, 12 insertions(+), 58 deletions(-)
diff --git a/ethtool.c b/ethtool.c
index a70cd03..4073745 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -277,10 +277,9 @@ 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_lro_wanted = -1;
+static u32 off_flags_wanted = 0;
+static u32 off_flags_unwanted = 0;
static int off_gro_wanted = -1;
-static int off_ntuple_wanted = -1;
-static int off_rxhash_wanted = -1;
static struct ethtool_pauseparam epause;
static int gpause_changed = 0;
@@ -419,10 +418,13 @@ 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 },
- { "lro", CMDL_BOOL, &off_lro_wanted, NULL },
+ { "lro", CMDL_FLAG, &off_flags_wanted, NULL,
+ ETH_FLAG_LRO, &off_flags_unwanted },
{ "gro", CMDL_BOOL, &off_gro_wanted, NULL },
- { "ntuple", CMDL_BOOL, &off_ntuple_wanted, NULL },
- { "rxhash", CMDL_BOOL, &off_rxhash_wanted, NULL },
+ { "ntuple", CMDL_FLAG, &off_flags_wanted, NULL,
+ ETH_FLAG_NTUPLE, &off_flags_unwanted },
+ { "rxhash", CMDL_FLAG, &off_flags_wanted, NULL,
+ ETH_FLAG_RXHASH, &off_flags_unwanted },
};
static struct cmdline_info cmdline_pause[] = {
@@ -2191,7 +2193,7 @@ static int do_soffload(int fd, struct ifreq *ifr)
return 90;
}
}
- if (off_lro_wanted >= 0) {
+ if (off_flags_wanted || off_flags_unwanted) {
changed = 1;
eval.cmd = ETHTOOL_GFLAGS;
eval.data = 0;
@@ -2203,14 +2205,12 @@ static int do_soffload(int fd, struct ifreq *ifr)
}
eval.cmd = ETHTOOL_SFLAGS;
- if (off_lro_wanted == 1)
- eval.data |= ETH_FLAG_LRO;
- else
- eval.data &= ~ETH_FLAG_LRO;
+ eval.data = ((eval.data & ~off_flags_unwanted) |
+ off_flags_wanted);
err = ioctl(fd, SIOCETHTOOL, ifr);
if (err) {
- perror("Cannot set large receive offload settings");
+ perror("Cannot set device flag settings");
return 92;
}
}
@@ -2225,52 +2225,6 @@ static int do_soffload(int fd, struct ifreq *ifr)
return 93;
}
}
- if (off_ntuple_wanted >= 0) {
- changed = 1;
- eval.cmd = ETHTOOL_GFLAGS;
- eval.data = 0;
- ifr->ifr_data = (caddr_t)&eval;
- err = ioctl(fd, SIOCETHTOOL, ifr);
- if (err) {
- perror("Cannot get device flag settings");
- return 91;
- }
-
- eval.cmd = ETHTOOL_SFLAGS;
- if (off_ntuple_wanted == 1)
- eval.data |= ETH_FLAG_NTUPLE;
- else
- eval.data &= ~ETH_FLAG_NTUPLE;
-
- err = ioctl(fd, SIOCETHTOOL, ifr);
- if (err) {
- perror("Cannot set n-tuple filter settings");
- return 93;
- }
- }
- if (off_rxhash_wanted >= 0) {
- changed = 1;
- eval.cmd = ETHTOOL_GFLAGS;
- eval.data = 0;
- ifr->ifr_data = (caddr_t)&eval;
- err = ioctl(fd, SIOCETHTOOL, ifr);
- if (err) {
- perror("Cannot get device flag settings");
- return 91;
- }
-
- eval.cmd = ETHTOOL_SFLAGS;
- if (off_rxhash_wanted)
- eval.data |= ETH_FLAG_RXHASH;
- else
- eval.data &= ~ETH_FLAG_RXHASH;
-
- err = ioctl(fd, SIOCETHTOOL, ifr);
- if (err) {
- perror("Cannot set receive hash settings");
- return 93;
- }
- }
if (!changed) {
fprintf(stdout, "no offload settings changed\n");
--
1.6.2.5
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related
* [PATCH ethtool 4/5] ethtool: Implement named message type flags
From: Ben Hutchings @ 2010-06-25 14:49 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, linux-net-drivers
In-Reply-To: <1277477027.2094.2.camel@achroite.uk.solarflarecom.com>
Allow message type flags to be turned on and off by name.
Print the names of the currently set flags below the numeric value.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
ethtool.8 | 66 +++++++++++++++++++++++++++++++++++++--
ethtool.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------
2 files changed, 156 insertions(+), 14 deletions(-)
diff --git a/ethtool.8 b/ethtool.8
index a7b43d5..5983d0e 100644
--- a/ethtool.8
+++ b/ethtool.8
@@ -200,7 +200,10 @@ ethtool \- Display or change ethernet card settings
.RB [ wol \ \*(WO]
.RB [ sopass \ \*(MA]
.RB [ msglvl
-.IR N ]
+.IR N \ |
+.BI msglvl \ type
+.A1 on off
+.RB ...]
.B ethtool \-n
.I ethX
@@ -482,9 +485,66 @@ Disable (wake on nothing). This option clears all previous options.
.B sopass \*(MA\c
Sets the SecureOn(tm) password. The argument to this option must be 6
bytes in ethernet MAC hex format (\*(MA).
-.TP
+.PP
.BI msglvl \ N
-Sets the driver message level. Meanings differ per driver.
+.br
+.BI msglvl \ type
+.A1 on off
+.RB ...
+.RS
+Sets the driver message type flags by name or number. \fItype\fR
+names the type of message to enable or disable; \fIN\fR specifies the
+new flags numerically. The defined type names and numbers are:
+.PD 0
+.TP 12
+.B drv
+0x0001 General driver status
+.TP 12
+.B probe
+0x0002 Hardware probing
+.TP 12
+.B link
+0x0004 Link state
+.TP 12
+.B timer
+0x0008 Periodic status check
+.TP 12
+.B ifdown
+0x0010 Interface being brought down
+.TP 12
+.B ifup
+0x0020 Interface being brought up
+.TP 12
+.B rx_err
+0x0040 Receive error
+.TP 12
+.B tx_err
+0x0080 Transmit error
+.TP 12
+.B tx_queued
+0x0100 Transmit queueing
+.TP 12
+.B intr
+0x0200 Interrupt handling
+.TP 12
+.B tx_done
+0x0400 Transmit completion
+.TP 12
+.B rx_status
+0x0800 Receive completion
+.TP 12
+.B pktdata
+0x1000 Packet contents
+.TP 12
+.B hw
+0x2000 Hardware status
+.TP 12
+.B wol
+0x4000 Wake-on-LAN status
+.PP
+The precise meanings of these type flags differ between drivers.
+.PD
+.RE
.TP
.B \-n \-\-show-nfc
Retrieves the receive network flow classification configurations.
diff --git a/ethtool.c b/ethtool.c
index 4adab4b..a70cd03 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -20,7 +20,6 @@
* * better man page (steal from mii-tool?)
* * fall back on SIOCMII* ioctl()s and possibly SIOCDEVPRIVATE*
* * abstract ioctls to allow for fallback modes of data gathering
- * * symbolic names for msglvl bitmask
*/
#ifdef HAVE_CONFIG_H
@@ -39,6 +38,7 @@
#include <net/if.h>
#include <sys/utsname.h>
#include <limits.h>
+#include <ctype.h>
#include <linux/sockios.h>
#include "ethtool-util.h"
@@ -51,6 +51,26 @@
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
+#ifndef HAVE_NETIF_MSG
+enum {
+ NETIF_MSG_DRV = 0x0001,
+ NETIF_MSG_PROBE = 0x0002,
+ NETIF_MSG_LINK = 0x0004,
+ NETIF_MSG_TIMER = 0x0008,
+ NETIF_MSG_IFDOWN = 0x0010,
+ NETIF_MSG_IFUP = 0x0020,
+ NETIF_MSG_RX_ERR = 0x0040,
+ NETIF_MSG_TX_ERR = 0x0080,
+ NETIF_MSG_TX_QUEUED = 0x0100,
+ NETIF_MSG_INTR = 0x0200,
+ NETIF_MSG_TX_DONE = 0x0400,
+ NETIF_MSG_RX_STATUS = 0x0800,
+ NETIF_MSG_PKTDATA = 0x1000,
+ NETIF_MSG_HW = 0x2000,
+ NETIF_MSG_WOL = 0x4000,
+};
+#endif
+
static int parse_wolopts(char *optstr, u32 *data);
static char *unparse_wolopts(int wolopts);
static int parse_sopass(char *src, unsigned char *dest);
@@ -126,7 +146,7 @@ static 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 ] \n" },
+ " [ msglvl %d | msglvl type on|off ... ]\n" },
{ "-a", "--show-pause", MODE_GPAUSE, "Show pause options" },
{ "-A", "--pause", MODE_SPAUSE, "Set pause options",
" [ autoneg on|off ]\n"
@@ -313,7 +333,6 @@ static int wol_change = 0;
static u8 sopass_wanted[SOPASS_MAX];
static int sopass_change = 0;
static int gwol_changed = 0; /* did anything in GWOL change? */
-static int msglvl_wanted = -1;
static int phys_id_time = 0;
static int gregs_changed = 0;
static int gregs_dump_raw = 0;
@@ -337,6 +356,11 @@ static struct ethtool_rx_ntuple_flow_spec ntuple_fs;
static char *flash_file = NULL;
static int flash = -1;
static int flash_region = -1;
+
+static int msglvl_changed;
+static u32 msglvl_wanted = 0;
+static u32 msglvl_unwanted =0;
+
static enum {
ONLINE=0,
OFFLINE,
@@ -455,6 +479,39 @@ static struct cmdline_info cmdline_ntuple[] = {
{ "action", CMDL_S32, &ntuple_fs.action, NULL },
};
+static struct cmdline_info cmdline_msglvl[] = {
+ { "drv", CMDL_FLAG, &msglvl_wanted, NULL,
+ NETIF_MSG_DRV, &msglvl_unwanted },
+ { "probe", CMDL_FLAG, &msglvl_wanted, NULL,
+ NETIF_MSG_PROBE, &msglvl_unwanted },
+ { "link", CMDL_FLAG, &msglvl_wanted, NULL,
+ NETIF_MSG_LINK, &msglvl_unwanted },
+ { "timer", CMDL_FLAG, &msglvl_wanted, NULL,
+ NETIF_MSG_TIMER, &msglvl_unwanted },
+ { "ifdown", CMDL_FLAG, &msglvl_wanted, NULL,
+ NETIF_MSG_IFDOWN, &msglvl_unwanted },
+ { "ifup", CMDL_FLAG, &msglvl_wanted, NULL,
+ NETIF_MSG_IFUP, &msglvl_unwanted },
+ { "rx_err", CMDL_FLAG, &msglvl_wanted, NULL,
+ NETIF_MSG_RX_ERR, &msglvl_unwanted },
+ { "tx_err", CMDL_FLAG, &msglvl_wanted, NULL,
+ NETIF_MSG_TX_ERR, &msglvl_unwanted },
+ { "tx_queued", CMDL_FLAG, &msglvl_wanted, NULL,
+ NETIF_MSG_TX_QUEUED, &msglvl_unwanted },
+ { "intr", CMDL_FLAG, &msglvl_wanted, NULL,
+ NETIF_MSG_INTR, &msglvl_unwanted },
+ { "tx_done", CMDL_FLAG, &msglvl_wanted, NULL,
+ NETIF_MSG_TX_DONE, &msglvl_unwanted },
+ { "rx_status", CMDL_FLAG, &msglvl_wanted, NULL,
+ NETIF_MSG_RX_STATUS, &msglvl_unwanted },
+ { "pktdata", CMDL_FLAG, &msglvl_wanted, NULL,
+ NETIF_MSG_PKTDATA, &msglvl_unwanted },
+ { "hw", CMDL_FLAG, &msglvl_wanted, NULL,
+ NETIF_MSG_HW, &msglvl_unwanted },
+ { "wol", CMDL_FLAG, &msglvl_wanted, NULL,
+ NETIF_MSG_WOL, &msglvl_unwanted },
+};
+
static long long
get_int_range(char *str, int base, long long min, long long max)
{
@@ -920,7 +977,20 @@ static void parse_cmdline(int argc, char **argp)
i++;
if (i >= argc)
show_usage(1);
- msglvl_wanted = get_int(argp[i], 0);
+ if (isdigit((unsigned char)argp[i][0])) {
+ msglvl_changed = 1;
+ msglvl_unwanted = ~0;
+ msglvl_wanted =
+ get_uint_range(argp[i], 0,
+ 0xffffffff);
+ } else {
+ parse_generic_cmdline(
+ argc, argp, i,
+ &msglvl_changed,
+ cmdline_msglvl,
+ ARRAY_SIZE(cmdline_msglvl));
+ i = argc;
+ }
break;
}
show_usage(1);
@@ -2247,8 +2317,12 @@ static int do_gset(int fd, struct ifreq *ifr)
ifr->ifr_data = (caddr_t)&edata;
err = send_ioctl(fd, ifr);
if (err == 0) {
- fprintf(stdout, " Current message level: 0x%08x (%d)\n",
+ fprintf(stdout, " Current message level: 0x%08x (%d)\n"
+ " ",
edata.data, edata.data);
+ print_flags(cmdline_msglvl, ARRAY_SIZE(cmdline_msglvl),
+ edata.data);
+ fprintf(stdout, "\n");
allfail = 0;
} else if (errno != EOPNOTSUPP) {
perror("Cannot get message level");
@@ -2371,15 +2445,23 @@ static int do_sset(int fd, struct ifreq *ifr)
}
}
- if (msglvl_wanted != -1) {
+ if (msglvl_changed) {
struct ethtool_value edata;
- edata.cmd = ETHTOOL_SMSGLVL;
- edata.data = msglvl_wanted;
- ifr->ifr_data = (caddr_t)&edata;;
+ edata.cmd = ETHTOOL_GMSGLVL;
+ ifr->ifr_data = (caddr_t)&edata;
err = send_ioctl(fd, ifr);
- if (err < 0)
- perror("Cannot set new msglvl");
+ if (err < 0) {
+ perror("Cannot get msglvl");
+ } else {
+ edata.cmd = ETHTOOL_SMSGLVL;
+ edata.data = ((edata.data & ~msglvl_unwanted) |
+ msglvl_wanted);
+ ifr->ifr_data = (caddr_t)&edata;
+ err = send_ioctl(fd, ifr);
+ if (err < 0)
+ perror("Cannot set new msglvl");
+ }
}
return 0;
--
1.6.2.5
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related
* [PATCH ethtool 3/5] ethtool: Add support for named flags
From: Ben Hutchings @ 2010-06-25 14:49 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, linux-net-drivers
In-Reply-To: <1277477027.2094.2.camel@achroite.uk.solarflarecom.com>
Define an argument type CMDL_FLAG, which can be used to set and
clear flags. For each setting that can be modified in this way,
the flags to be set and cleared are accumulated in two variables.
Add support for CMDL_FLAGS parse_generic_cmdline().
Add utility function print_flags().
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
print_flags() is unused here, but will be used in the next patch.
Ben.
ethtool.c | 40 +++++++++++++++++++++++++++++++++++++++-
1 files changed, 39 insertions(+), 1 deletions(-)
diff --git a/ethtool.c b/ethtool.c
index d4bf5a8..4adab4b 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -352,14 +352,21 @@ typedef enum {
CMDL_BE16,
CMDL_BE32,
CMDL_STR,
+ CMDL_FLAG,
} cmdline_type_t;
struct cmdline_info {
const char *name;
cmdline_type_t type;
- /* Points to int (BOOL), s32, u16, u32, u64 or char * (STR) */
+ /* Points to int (BOOL), s32, u16, u32 (U32/FLAG), u64 or
+ * char * (STR). For FLAG, the value accumulates all flags
+ * to be set. */
void *wanted_val;
void *ioctl_val;
+ /* For FLAG, the flag value to be set/cleared */
+ u32 flag_val;
+ /* For FLAG, accumulates all flags to be cleared */
+ u32 *unwanted_val;
};
static struct cmdline_info cmdline_gregs[] = {
@@ -550,6 +557,17 @@ static void parse_generic_cmdline(int argc, char **argp,
0xffffffff));
break;
}
+ case CMDL_FLAG: {
+ u32 *p;
+ if (!strcmp(argp[i], "on"))
+ p = info[idx].wanted_val;
+ else if (!strcmp(argp[i], "off"))
+ p = info[idx].unwanted_val;
+ else
+ show_usage(1);
+ *p |= info[idx].flag_val;
+ break;
+ }
case CMDL_STR: {
char **s = info[idx].wanted_val;
*s = strdup(argp[i]);
@@ -566,6 +584,26 @@ static void parse_generic_cmdline(int argc, char **argp,
}
}
+static void
+print_flags(const struct cmdline_info *info, unsigned int n_info, u32 value)
+{
+ const char *sep = "";
+
+ while (n_info) {
+ if (info->type == CMDL_FLAG && value & info->flag_val) {
+ printf("%s%s", sep, info->name);
+ sep = " ";
+ value &= ~info->flag_val;
+ }
+ ++info;
+ --n_info;
+ }
+
+ /* Print any unrecognised flags in hex */
+ if (value)
+ printf("%s%#x", sep, value);
+}
+
static int rxflow_str_to_type(const char *str)
{
int flow_type = 0;
--
1.6.2.5
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related
* [PATCH ethtool 2/5] ethtool: Mark show_usage() as noreturn
From: Ben Hutchings @ 2010-06-25 14:48 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, linux-net-drivers
In-Reply-To: <1277477027.2094.2.camel@achroite.uk.solarflarecom.com>
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
This prevents the next patch from provoking an incorrect warning about
an uninitialised variable.
Ben.
ethtool.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/ethtool.c b/ethtool.c
index 8969390..d4bf5a8 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -220,6 +220,8 @@ static struct option {
};
+static void show_usage(int badarg) __attribute__((noreturn));
+
static void show_usage(int badarg)
{
int i;
--
1.6.2.5
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related
* [PATCH ethtool 1/5] ethtool: Parse integers into variables of different sizes and byte orders
From: Ben Hutchings @ 2010-06-25 14:46 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, linux-net-drivers, Peter Waskiewicz
In-Reply-To: <1277477027.2094.2.camel@achroite.uk.solarflarecom.com>
The arguments for RX n-tuple traffic direction are filled into
structure fields of varying size, some of which are in big-endian
rather than native byte order. Currently parse_generic_cmdline()
only supports 32-bit integers in native byte order, so this does
not work correctly.
Replace CMDL_INT and CMDL_UINT with the more explicit CMDL_S32 and
CMDL_U32. Add CMDL_U16 and CMDL_U64 for narrower and wider integers,
and CMDL_BE16 and CMDL_BE32 for big-endian unsigned integers. Use
them for RX n-tuple argument parsing.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
I've removed the 'historical' comment from the kernel-style named types
because I see no sign of a transition away from them.
Ben.
ethtool-util.h | 29 ++++++-
ethtool.c | 226 +++++++++++++++++++++++++++++++++-----------------------
2 files changed, 160 insertions(+), 95 deletions(-)
diff --git a/ethtool-util.h b/ethtool-util.h
index e9a998a..01b1d03 100644
--- a/ethtool-util.h
+++ b/ethtool-util.h
@@ -4,14 +4,35 @@
#define ETHTOOL_UTIL_H__
#include <sys/types.h>
+#include <endian.h>
#include "ethtool-copy.h"
-/* historical: we used to use kernel-like types; remove these once cleaned */
typedef unsigned long long u64;
-typedef __uint32_t u32; /* ditto */
-typedef __uint16_t u16; /* ditto */
-typedef __uint8_t u8; /* ditto */
+typedef __uint32_t u32;
+typedef __uint16_t u16;
+typedef __uint8_t u8;
+typedef __int32_t s32;
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+static inline u16 cpu_to_be16(u16 value)
+{
+ return value;
+}
+static inline u32 cpu_to_be32(u32 value)
+{
+ return value;
+}
+#else
+static inline u16 cpu_to_be16(u16 value)
+{
+ return (value >> 8) | (value << 8);
+}
+static inline u32 cpu_to_be32(u32 value)
+{
+ return cpu_to_be16(value >> 16) | (cpu_to_be16(value) << 16);
+}
+#endif
/* National Semiconductor DP83815, DP83816 */
int natsemi_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
diff --git a/ethtool.c b/ethtool.c
index 5d61439..8969390 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -268,35 +268,35 @@ static int pause_tx_wanted = -1;
static struct ethtool_ringparam ering;
static int gring_changed = 0;
-static int ring_rx_wanted = -1;
-static int ring_rx_mini_wanted = -1;
-static int ring_rx_jumbo_wanted = -1;
-static int ring_tx_wanted = -1;
+static s32 ring_rx_wanted = -1;
+static s32 ring_rx_mini_wanted = -1;
+static s32 ring_rx_jumbo_wanted = -1;
+static s32 ring_tx_wanted = -1;
static struct ethtool_coalesce ecoal;
static int gcoalesce_changed = 0;
-static int coal_stats_wanted = -1;
+static s32 coal_stats_wanted = -1;
static int coal_adaptive_rx_wanted = -1;
static int coal_adaptive_tx_wanted = -1;
-static int coal_sample_rate_wanted = -1;
-static int coal_pkt_rate_low_wanted = -1;
-static int coal_pkt_rate_high_wanted = -1;
-static int coal_rx_usec_wanted = -1;
-static int coal_rx_frames_wanted = -1;
-static int coal_rx_usec_irq_wanted = -1;
-static int coal_rx_frames_irq_wanted = -1;
-static int coal_tx_usec_wanted = -1;
-static int coal_tx_frames_wanted = -1;
-static int coal_tx_usec_irq_wanted = -1;
-static int coal_tx_frames_irq_wanted = -1;
-static int coal_rx_usec_low_wanted = -1;
-static int coal_rx_frames_low_wanted = -1;
-static int coal_tx_usec_low_wanted = -1;
-static int coal_tx_frames_low_wanted = -1;
-static int coal_rx_usec_high_wanted = -1;
-static int coal_rx_frames_high_wanted = -1;
-static int coal_tx_usec_high_wanted = -1;
-static int coal_tx_frames_high_wanted = -1;
+static s32 coal_sample_rate_wanted = -1;
+static s32 coal_pkt_rate_low_wanted = -1;
+static s32 coal_pkt_rate_high_wanted = -1;
+static s32 coal_rx_usec_wanted = -1;
+static s32 coal_rx_frames_wanted = -1;
+static s32 coal_rx_usec_irq_wanted = -1;
+static s32 coal_rx_frames_irq_wanted = -1;
+static s32 coal_tx_usec_wanted = -1;
+static s32 coal_tx_frames_wanted = -1;
+static s32 coal_tx_usec_irq_wanted = -1;
+static s32 coal_tx_frames_irq_wanted = -1;
+static s32 coal_rx_usec_low_wanted = -1;
+static s32 coal_rx_frames_low_wanted = -1;
+static s32 coal_tx_usec_low_wanted = -1;
+static s32 coal_tx_frames_low_wanted = -1;
+static s32 coal_rx_usec_high_wanted = -1;
+static s32 coal_rx_frames_high_wanted = -1;
+static s32 coal_tx_usec_high_wanted = -1;
+static s32 coal_tx_frames_high_wanted = -1;
static int speed_wanted = -1;
static int duplex_wanted = -1;
@@ -319,13 +319,13 @@ static int gregs_dump_hex = 0;
static char *gregs_dump_file = NULL;
static int geeprom_changed = 0;
static int geeprom_dump_raw = 0;
-static int geeprom_offset = 0;
-static int geeprom_length = -1;
+static s32 geeprom_offset = 0;
+static s32 geeprom_length = -1;
static int seeprom_changed = 0;
-static int seeprom_magic = 0;
-static int seeprom_length = -1;
-static int seeprom_offset = 0;
-static int seeprom_value = EOF;
+static s32 seeprom_magic = 0;
+static s32 seeprom_length = -1;
+static s32 seeprom_offset = 0;
+static s32 seeprom_value = EOF;
static int rx_fhash_get = 0;
static int rx_fhash_set = 0;
static u32 rx_fhash_val = 0;
@@ -343,14 +343,19 @@ static enum {
typedef enum {
CMDL_NONE,
CMDL_BOOL,
- CMDL_INT,
- CMDL_UINT,
+ CMDL_S32,
+ CMDL_U16,
+ CMDL_U32,
+ CMDL_U64,
+ CMDL_BE16,
+ CMDL_BE32,
CMDL_STR,
} cmdline_type_t;
struct cmdline_info {
const char *name;
cmdline_type_t type;
+ /* Points to int (BOOL), s32, u16, u32, u64 or char * (STR) */
void *wanted_val;
void *ioctl_val;
};
@@ -362,16 +367,16 @@ static struct cmdline_info cmdline_gregs[] = {
};
static struct cmdline_info cmdline_geeprom[] = {
- { "offset", CMDL_INT, &geeprom_offset, NULL },
- { "length", CMDL_INT, &geeprom_length, NULL },
+ { "offset", CMDL_S32, &geeprom_offset, NULL },
+ { "length", CMDL_S32, &geeprom_length, NULL },
{ "raw", CMDL_BOOL, &geeprom_dump_raw, NULL },
};
static struct cmdline_info cmdline_seeprom[] = {
- { "magic", CMDL_INT, &seeprom_magic, NULL },
- { "offset", CMDL_INT, &seeprom_offset, NULL },
- { "length", CMDL_INT, &seeprom_length, NULL },
- { "value", CMDL_INT, &seeprom_value, NULL },
+ { "magic", CMDL_S32, &seeprom_magic, NULL },
+ { "offset", CMDL_S32, &seeprom_offset, NULL },
+ { "length", CMDL_S32, &seeprom_length, NULL },
+ { "value", CMDL_S32, &seeprom_value, NULL },
};
static struct cmdline_info cmdline_offload[] = {
@@ -394,87 +399,94 @@ static struct cmdline_info cmdline_pause[] = {
};
static struct cmdline_info cmdline_ring[] = {
- { "rx", CMDL_INT, &ring_rx_wanted, &ering.rx_pending },
- { "rx-mini", CMDL_INT, &ring_rx_mini_wanted, &ering.rx_mini_pending },
- { "rx-jumbo", CMDL_INT, &ring_rx_jumbo_wanted, &ering.rx_jumbo_pending },
- { "tx", CMDL_INT, &ring_tx_wanted, &ering.tx_pending },
+ { "rx", CMDL_S32, &ring_rx_wanted, &ering.rx_pending },
+ { "rx-mini", CMDL_S32, &ring_rx_mini_wanted, &ering.rx_mini_pending },
+ { "rx-jumbo", CMDL_S32, &ring_rx_jumbo_wanted, &ering.rx_jumbo_pending },
+ { "tx", CMDL_S32, &ring_tx_wanted, &ering.tx_pending },
};
static struct cmdline_info cmdline_coalesce[] = {
{ "adaptive-rx", CMDL_BOOL, &coal_adaptive_rx_wanted, &ecoal.use_adaptive_rx_coalesce },
{ "adaptive-tx", CMDL_BOOL, &coal_adaptive_tx_wanted, &ecoal.use_adaptive_tx_coalesce },
- { "sample-interval", CMDL_INT, &coal_sample_rate_wanted, &ecoal.rate_sample_interval },
- { "stats-block-usecs", CMDL_INT, &coal_stats_wanted, &ecoal.stats_block_coalesce_usecs },
- { "pkt-rate-low", CMDL_INT, &coal_pkt_rate_low_wanted, &ecoal.pkt_rate_low },
- { "pkt-rate-high", CMDL_INT, &coal_pkt_rate_high_wanted, &ecoal.pkt_rate_high },
- { "rx-usecs", CMDL_INT, &coal_rx_usec_wanted, &ecoal.rx_coalesce_usecs },
- { "rx-frames", CMDL_INT, &coal_rx_frames_wanted, &ecoal.rx_max_coalesced_frames },
- { "rx-usecs-irq", CMDL_INT, &coal_rx_usec_irq_wanted, &ecoal.rx_coalesce_usecs_irq },
- { "rx-frames-irq", CMDL_INT, &coal_rx_frames_irq_wanted, &ecoal.rx_max_coalesced_frames_irq },
- { "tx-usecs", CMDL_INT, &coal_tx_usec_wanted, &ecoal.tx_coalesce_usecs },
- { "tx-frames", CMDL_INT, &coal_tx_frames_wanted, &ecoal.tx_max_coalesced_frames },
- { "tx-usecs-irq", CMDL_INT, &coal_tx_usec_irq_wanted, &ecoal.tx_coalesce_usecs_irq },
- { "tx-frames-irq", CMDL_INT, &coal_tx_frames_irq_wanted, &ecoal.tx_max_coalesced_frames_irq },
- { "rx-usecs-low", CMDL_INT, &coal_rx_usec_low_wanted, &ecoal.rx_coalesce_usecs_low },
- { "rx-frames-low", CMDL_INT, &coal_rx_frames_low_wanted, &ecoal.rx_max_coalesced_frames_low },
- { "tx-usecs-low", CMDL_INT, &coal_tx_usec_low_wanted, &ecoal.tx_coalesce_usecs_low },
- { "tx-frames-low", CMDL_INT, &coal_tx_frames_low_wanted, &ecoal.tx_max_coalesced_frames_low },
- { "rx-usecs-high", CMDL_INT, &coal_rx_usec_high_wanted, &ecoal.rx_coalesce_usecs_high },
- { "rx-frames-high", CMDL_INT, &coal_rx_frames_high_wanted, &ecoal.rx_max_coalesced_frames_high },
- { "tx-usecs-high", CMDL_INT, &coal_tx_usec_high_wanted, &ecoal.tx_coalesce_usecs_high },
- { "tx-frames-high", CMDL_INT, &coal_tx_frames_high_wanted, &ecoal.tx_max_coalesced_frames_high },
+ { "sample-interval", CMDL_S32, &coal_sample_rate_wanted, &ecoal.rate_sample_interval },
+ { "stats-block-usecs", CMDL_S32, &coal_stats_wanted, &ecoal.stats_block_coalesce_usecs },
+ { "pkt-rate-low", CMDL_S32, &coal_pkt_rate_low_wanted, &ecoal.pkt_rate_low },
+ { "pkt-rate-high", CMDL_S32, &coal_pkt_rate_high_wanted, &ecoal.pkt_rate_high },
+ { "rx-usecs", CMDL_S32, &coal_rx_usec_wanted, &ecoal.rx_coalesce_usecs },
+ { "rx-frames", CMDL_S32, &coal_rx_frames_wanted, &ecoal.rx_max_coalesced_frames },
+ { "rx-usecs-irq", CMDL_S32, &coal_rx_usec_irq_wanted, &ecoal.rx_coalesce_usecs_irq },
+ { "rx-frames-irq", CMDL_S32, &coal_rx_frames_irq_wanted, &ecoal.rx_max_coalesced_frames_irq },
+ { "tx-usecs", CMDL_S32, &coal_tx_usec_wanted, &ecoal.tx_coalesce_usecs },
+ { "tx-frames", CMDL_S32, &coal_tx_frames_wanted, &ecoal.tx_max_coalesced_frames },
+ { "tx-usecs-irq", CMDL_S32, &coal_tx_usec_irq_wanted, &ecoal.tx_coalesce_usecs_irq },
+ { "tx-frames-irq", CMDL_S32, &coal_tx_frames_irq_wanted, &ecoal.tx_max_coalesced_frames_irq },
+ { "rx-usecs-low", CMDL_S32, &coal_rx_usec_low_wanted, &ecoal.rx_coalesce_usecs_low },
+ { "rx-frames-low", CMDL_S32, &coal_rx_frames_low_wanted, &ecoal.rx_max_coalesced_frames_low },
+ { "tx-usecs-low", CMDL_S32, &coal_tx_usec_low_wanted, &ecoal.tx_coalesce_usecs_low },
+ { "tx-frames-low", CMDL_S32, &coal_tx_frames_low_wanted, &ecoal.tx_max_coalesced_frames_low },
+ { "rx-usecs-high", CMDL_S32, &coal_rx_usec_high_wanted, &ecoal.rx_coalesce_usecs_high },
+ { "rx-frames-high", CMDL_S32, &coal_rx_frames_high_wanted, &ecoal.rx_max_coalesced_frames_high },
+ { "tx-usecs-high", CMDL_S32, &coal_tx_usec_high_wanted, &ecoal.tx_coalesce_usecs_high },
+ { "tx-frames-high", CMDL_S32, &coal_tx_frames_high_wanted, &ecoal.tx_max_coalesced_frames_high },
};
static struct cmdline_info cmdline_ntuple[] = {
- { "src-ip", CMDL_INT, &ntuple_fs.h_u.tcp_ip4_spec.ip4src, NULL },
- { "src-ip-mask", CMDL_UINT, &ntuple_fs.m_u.tcp_ip4_spec.ip4src, NULL },
- { "dst-ip", CMDL_INT, &ntuple_fs.h_u.tcp_ip4_spec.ip4dst, NULL },
- { "dst-ip-mask", CMDL_UINT, &ntuple_fs.m_u.tcp_ip4_spec.ip4dst, NULL },
- { "src-port", CMDL_INT, &ntuple_fs.h_u.tcp_ip4_spec.psrc, NULL },
- { "src-port-mask", CMDL_UINT, &ntuple_fs.m_u.tcp_ip4_spec.psrc, NULL },
- { "dst-port", CMDL_INT, &ntuple_fs.h_u.tcp_ip4_spec.pdst, NULL },
- { "dst-port-mask", CMDL_UINT, &ntuple_fs.m_u.tcp_ip4_spec.pdst, NULL },
- { "vlan", CMDL_INT, &ntuple_fs.vlan_tag, NULL },
- { "vlan-mask", CMDL_UINT, &ntuple_fs.vlan_tag_mask, NULL },
- { "user-def", CMDL_INT, &ntuple_fs.data, NULL },
- { "user-def-mask", CMDL_UINT, &ntuple_fs.data_mask, NULL },
- { "action", CMDL_INT, &ntuple_fs.action, NULL },
+ { "src-ip", CMDL_BE32, &ntuple_fs.h_u.tcp_ip4_spec.ip4src, NULL },
+ { "src-ip-mask", CMDL_BE32, &ntuple_fs.m_u.tcp_ip4_spec.ip4src, NULL },
+ { "dst-ip", CMDL_BE32, &ntuple_fs.h_u.tcp_ip4_spec.ip4dst, NULL },
+ { "dst-ip-mask", CMDL_BE32, &ntuple_fs.m_u.tcp_ip4_spec.ip4dst, NULL },
+ { "src-port", CMDL_BE16, &ntuple_fs.h_u.tcp_ip4_spec.psrc, NULL },
+ { "src-port-mask", CMDL_BE16, &ntuple_fs.m_u.tcp_ip4_spec.psrc, NULL },
+ { "dst-port", CMDL_BE16, &ntuple_fs.h_u.tcp_ip4_spec.pdst, NULL },
+ { "dst-port-mask", CMDL_BE16, &ntuple_fs.m_u.tcp_ip4_spec.pdst, NULL },
+ { "vlan", CMDL_U16, &ntuple_fs.vlan_tag, NULL },
+ { "vlan-mask", CMDL_U16, &ntuple_fs.vlan_tag_mask, NULL },
+ { "user-def", CMDL_U64, &ntuple_fs.data, NULL },
+ { "user-def-mask", CMDL_U64, &ntuple_fs.data_mask, NULL },
+ { "action", CMDL_S32, &ntuple_fs.action, NULL },
};
-static int get_int(char *str, int base)
+static long long
+get_int_range(char *str, int base, long long min, long long max)
{
- long v;
+ long long v;
char *endp;
if (!str)
show_usage(1);
errno = 0;
- v = strtol(str, &endp, base);
- if ( errno || *endp || v > INT_MAX)
+ v = strtoll(str, &endp, base);
+ if (errno || *endp || v < min || v > max)
show_usage(1);
- return (int)v;
+ return v;
}
-static int get_uint(char *str, int base)
+static unsigned long long
+get_uint_range(char *str, int base, unsigned long long max)
{
- unsigned long v;
+ unsigned long long v;
char *endp;
if (!str)
show_usage(1);
errno = 0;
- v = strtoul(str, &endp, base);
- if ( errno || *endp || v > UINT_MAX)
+ v = strtoull(str, &endp, base);
+ if ( errno || *endp || v > max)
show_usage(1);
return v;
}
+static int get_int(char *str, int base)
+{
+ return get_int_range(str, base, INT_MIN, INT_MAX);
+}
+
static void parse_generic_cmdline(int argc, char **argp,
int first_arg, int *changed,
struct cmdline_info *info,
unsigned int n_info)
{
- int i, idx, *p;
+ int i, idx;
int found;
for (i = first_arg; i < argc; i++) {
@@ -486,9 +498,9 @@ static void parse_generic_cmdline(int argc, char **argp,
i += 1;
if (i >= argc)
show_usage(1);
- p = info[idx].wanted_val;
switch (info[idx].type) {
- case CMDL_BOOL:
+ case CMDL_BOOL: {
+ int *p = info[idx].wanted_val;
if (!strcmp(argp[i], "on"))
*p = 1;
else if (!strcmp(argp[i], "off"))
@@ -496,12 +508,44 @@ static void parse_generic_cmdline(int argc, char **argp,
else
show_usage(1);
break;
- case CMDL_INT: {
- *p = get_int(argp[i],0);
+ }
+ case CMDL_S32: {
+ s32 *p = info[idx].wanted_val;
+ *p = get_int_range(argp[i], 0,
+ -0x80000000LL,
+ 0x7fffffff);
+ break;
+ }
+ case CMDL_U16: {
+ u16 *p = info[idx].wanted_val;
+ *p = get_uint_range(argp[i], 0, 0xffff);
+ break;
+ }
+ case CMDL_U32: {
+ u32 *p = info[idx].wanted_val;
+ *p = get_uint_range(argp[i], 0,
+ 0xffffffff);
+ break;
+ }
+ case CMDL_U64: {
+ u64 *p = info[idx].wanted_val;
+ *p = get_uint_range(
+ argp[i], 0,
+ 0xffffffffffffffffLL);
+ break;
+ }
+ case CMDL_BE16: {
+ u16 *p = info[idx].wanted_val;
+ *p = cpu_to_be16(
+ get_uint_range(argp[i], 0,
+ 0xffff));
break;
}
- case CMDL_UINT: {
- *p = get_uint(argp[i],0);
+ case CMDL_BE32: {
+ u32 *p = info[idx].wanted_val;
+ *p = cpu_to_be32(
+ get_uint_range(argp[i], 0,
+ 0xffffffff));
break;
}
case CMDL_STR: {
--
1.6.2.5
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related
* [PATCH ethtool 0/5] Fix and enhance command-line parsing
From: Ben Hutchings @ 2010-06-25 14:43 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, linux-net-drivers
This patch series fixes the initialisation of RX n-tuple specs, adds
general support for named flags, and then uses that for message types
and extended offload flags.
Ben.
Ben Hutchings (5):
ethtool: Parse integers into variables of different sizes and byte
orders
ethtool: Mark show_usage() as noreturn
ethtool: Add support for named flags
ethtool: Implement named message type flags
ethtool: Use named flag support to update extended offload flags
ethtool-util.h | 29 ++++-
ethtool.8 | 66 ++++++++-
ethtool.c | 440 +++++++++++++++++++++++++++++++++++--------------------
3 files changed, 368 insertions(+), 167 deletions(-)
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* Re: [PATCH] smsc95xx: Add module parameter to override MAC address
From: Sebastien Jan @ 2010-06-25 14:20 UTC (permalink / raw)
To: Steve.Glendinning@smsc.com
Cc: Simon Horman, linux-omap@vger.kernel.org, netdev@vger.kernel.org,
davem@davemloft.net, Ian.Saturley@smsc.com
In-Reply-To: <OF60E8D688.255F8F16-ON8025774D.002E17AA-8025774D.002FEC33@smsc.com>
Hi Steve,
Thanks for your answer.
On 06/25/2010 10:43 AM, Steve.Glendinning@smsc.com wrote:
[...]
> I can see you have a different use case, but I don't think this specific
> driver is the place for this logic. I'd rather see it added to either
> the usbnet framework or (preferably) the netdev framework so *all*
> ethernet drivers can do this the same way. otherwise we could end up
> with slight variations of this code in every single driver!
I perfectly understand your concerns. Unfortunately, I will probably not be
able to implement these changes into the netdev framework. However, I'd be
happy to make some tests if someone proposes such changes.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox