* Re: [RFC] ethernet: avoid pre-assigned OUI values in random_ether_addr
From: Bill Fink @ 2011-05-14 6:28 UTC (permalink / raw)
To: rick.jones2; +Cc: Stephen Hemminger, netdev
In-Reply-To: <1305334848.8149.729.camel@tardy>
On Fri, 13 May 2011, Rick Jones wrote:
> > Well, then by a quick glance at
> > http://standards.ieee.org/develop/regauth/oui/oui.txt it looks like
> > there are more to add... (some overlap with your list, I've not checked
> > the entire thing, how the name conflicts should be resolved I've no
> > idea)
> >
> > raj@tardy:~$ grep ^02- oui.txt
> > 02-07-01 (hex) RACAL-DATACOM
> > 02-1C-7C (hex) PERQ SYSTEMS CORPORATION
> > 02-60-86 (hex) LOGIC REPLACEMENT TECH. LTD.
> > 02-60-8C (hex) 3COM CORPORATION
> > 02-70-01 (hex) RACAL-DATACOM
> > 02-70-B0 (hex) M/A-COM INC. COMPANIES
> > 02-70-B3 (hex) DATA RECALL LTD
> > 02-9D-8E (hex) CARDIAC RECORDERS INC.
> > 02-AA-3C (hex) OLIVETTI TELECOMM SPA (OLTECO)
> > 02-BB-01 (hex) OCTOTHORPE CORP.
> > 02-C0-8C (hex) 3COM CORPORATION
> > 02-CF-1C (hex) COMMUNICATION MACHINERY CORP.
> > 02-E6-D3 (hex) NIXDORF COMPUTER CORPORATION
> >
> > The ieee's list doesn't have any 52's though.
>
> It does have some A's though:
> ~$ grep ^.[26AE]- oui.txt
> [the aforementioned 02's]
> AA-00-00 (hex) DIGITAL EQUIPMENT CORPORATION
> AA-00-01 (hex) DIGITAL EQUIPMENT CORPORATION
> AA-00-02 (hex) DIGITAL EQUIPMENT CORPORATION
> AA-00-03 (hex) DIGITAL EQUIPMENT CORPORATION
> AA-00-04 (hex) DIGITAL EQUIPMENT CORPORATION
>
> which if I've not botched my bits has the locally administered bit set.
The AA addresses are used by DECNET and related protocols.
-Bill
^ permalink raw reply
* Re: tap/bridge: Dropping NETIF_F_GSO/NETIF_F_SG
From: Shan Wei @ 2011-05-14 6:54 UTC (permalink / raw)
To: Michał Mirosław
Cc: Michael S. Tsirkin, netdev, Ben Hutchings, herbert
In-Reply-To: <20110505152644.GA8459@rere.qmqm.pl>
Michał Mirosław wrote, at 05/05/2011 11:26 PM:
> On Wed, May 04, 2011 at 09:18:14PM +0300, Michael S. Tsirkin wrote:
>> BTW, I just noticed that net-next spits out
>> many of the following when I run any VMs:
> [...]
>> tap0: Features changed: 0x40004040 -> 0x401b4849
>
> Before this message, userspace called ioctl(TIOCSETOFFLOAD)
> turning offloads on.
>
>> tap0: Dropping NETIF_F_SG since no checksum feature.
>> tap0: Dropping NETIF_F_GSO since no SG feature.
>> tap0: Features changed: 0x401b4849 -> 0x40004040
>
> And then it probably called ioctl(TIOCSETOFFLOAD) again, disabling them.
[263958.167861] tap1: Dropping NETIF_F_SG since no checksum feature.
[263958.167866] tap1: Dropping NETIF_F_GSO since no SG feature.
[263958.167871] tap1: Features changed: 0x401b4849 -> 0x40004040
See same warning message using tunctl to create a tap device on net-next tree.
But on RHEL6, no warning message.
strace shows no TUNSETOFFLOAD to be used.
Seems that checksum feature is not set when creating tap0 interface.
#strace tunctl -u root -t tap1
open("/dev/net/tun", O_RDWR) = 3
ioctl(3, TUNSETIFF, 0x7fff789ada10) = 0
ioctl(3, TUNSETOWNER, 0) = 0
ioctl(3, TUNSETPERSIST, 0x1) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f66aeed9000
write(1, "Set 'tap1' persistent and owned "..., 41Set 'tap1' persistent and owned by uid 0
) = 41
exit_group(0) = ?
--
Best Regards
-----
Shan Wei
^ permalink raw reply
* [PATCH net-next] net: drivers: kill two unused macro definitions
From: Shan Wei @ 2011-05-14 7:08 UTC (permalink / raw)
To: fubar, andy, David Miller, jpirko, Michał Mirosław
Signed-off-by: Shan Wei <shanwei@cn.fujitsu.com>
---
drivers/net/bonding/bonding.h | 10 ----------
drivers/net/veth.c | 1 -
2 files changed, 0 insertions(+), 11 deletions(-)
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index d08362e..ea1d005 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -39,16 +39,6 @@
netif_carrier_ok(dev))
/*
- * Checks whether bond is ready for transmit.
- *
- * Caller must hold bond->lock
- */
-#define BOND_IS_OK(bond) \
- (((bond)->dev->flags & IFF_UP) && \
- netif_running((bond)->dev) && \
- ((bond)->slave_cnt > 0))
-
-/*
* Checks whether slave is ready for transmit.
*/
#define SLAVE_IS_OK(slave) \
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 3b0151a..8461576 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -22,7 +22,6 @@
#define MIN_MTU 68 /* Min L3 MTU */
#define MAX_MTU 65535 /* Max L3 MTU (arbitrary) */
-#define MTU_PAD (ETH_HLEN + 4) /* Max difference between L2 and L3 size MTU */
struct veth_net_stats {
unsigned long rx_packets;
--
1.7.4.1
^ permalink raw reply related
* Re: [PATCH net-next] net: drivers: kill two unused macro definitions
From: Jiri Pirko @ 2011-05-14 7:53 UTC (permalink / raw)
To: Shan Wei
Cc: fubar, andy, David Miller, Michał Mirosław,
Eric Dumazet, ebiederm, netdev
In-Reply-To: <4DCE2A7F.1040000@cn.fujitsu.com>
Sat, May 14, 2011 at 09:08:47AM CEST, shanwei@cn.fujitsu.com wrote:
>
>
>Signed-off-by: Shan Wei <shanwei@cn.fujitsu.com>
>---
> drivers/net/bonding/bonding.h | 10 ----------
> drivers/net/veth.c | 1 -
> 2 files changed, 0 insertions(+), 11 deletions(-)
>
>diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
>index d08362e..ea1d005 100644
>--- a/drivers/net/bonding/bonding.h
>+++ b/drivers/net/bonding/bonding.h
>@@ -39,16 +39,6 @@
> netif_carrier_ok(dev))
>
> /*
>- * Checks whether bond is ready for transmit.
>- *
>- * Caller must hold bond->lock
>- */
>-#define BOND_IS_OK(bond) \
>- (((bond)->dev->flags & IFF_UP) && \
>- netif_running((bond)->dev) && \
>- ((bond)->slave_cnt > 0))
>-
>-/*
> * Checks whether slave is ready for transmit.
> */
> #define SLAVE_IS_OK(slave) \
>diff --git a/drivers/net/veth.c b/drivers/net/veth.c
>index 3b0151a..8461576 100644
>--- a/drivers/net/veth.c
>+++ b/drivers/net/veth.c
>@@ -22,7 +22,6 @@
>
> #define MIN_MTU 68 /* Min L3 MTU */
> #define MAX_MTU 65535 /* Max L3 MTU (arbitrary) */
>-#define MTU_PAD (ETH_HLEN + 4) /* Max difference between L2 and L3 size MTU */
>
> struct veth_net_stats {
> unsigned long rx_packets;
>--
>1.7.4.1
Reviewed-by: Jiri Pirko <jpirko@redhat.com>
^ permalink raw reply
* [PATCH net-next-2.6] net: ping: small changes
From: Eric Dumazet @ 2011-05-14 8:59 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Vasiliy Kulikov
ping_table is not __read_mostly, since it contains one rwlock,
and is static to ping.c
ping_port_rover & ping_v4_lookup are static
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Vasiliy Kulikov <segoon@openwall.com>
---
net/ipv4/ping.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index a77e2d7..7041d09 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -49,9 +49,9 @@
#include <net/checksum.h>
-struct ping_table ping_table __read_mostly;
+static struct ping_table ping_table;
-u16 ping_port_rover;
+static u16 ping_port_rover;
static inline int ping_hashfn(struct net *net, unsigned num, unsigned mask)
{
@@ -150,8 +150,8 @@ static void ping_v4_unhash(struct sock *sk)
}
}
-struct sock *ping_v4_lookup(struct net *net, u32 saddr, u32 daddr,
- u16 ident, int dif)
+static struct sock *ping_v4_lookup(struct net *net, u32 saddr, u32 daddr,
+ u16 ident, int dif)
{
struct hlist_nulls_head *hslot = ping_hashslot(&ping_table, net, ident);
struct sock *sk = NULL;
^ permalink raw reply related
* Re: question about UFO behavior for bridge device
From: Shan Wei @ 2011-05-14 9:54 UTC (permalink / raw)
To: Herbert Xu, Ben Hutchings; +Cc: netdev
In-Reply-To: <20110513143627.GA29054@gondor.apana.org.au>
Herbert Xu wrote, at 05/13/2011 10:36 PM:
> On Fri, May 13, 2011 at 02:06:52PM +0100, Ben Hutchings wrote:
>>
>>> But, actually, i saw original big skb in eth0's tcpdump file, but not segmented skbs.
>>> The behavior is right or what we want?
>>> Is there anything missed about my analysis?
>>
>> I assume that packet capturing is handled earlier in the transmit path.
>
> Yes it is. It's the same with TSO.
Be cheated by tcpdump. :-(
dev_queue_xmit_nit(skb, dev) which dumps packet to user is called before handling GSO segments.
Thanks very much.
--
Best Regards
-----
Shan Wei
^ permalink raw reply
* Re: [PATCH net-2.6] ethtool: Remove fallback to old ethtool operations for ETHTOOL_SFEATURES
From: Michał Mirosław @ 2011-05-14 9:54 UTC (permalink / raw)
To: Ben Hutchings; +Cc: David Miller, netdev
In-Reply-To: <1305335142.2851.70.camel@bwh-desktop>
On Sat, May 14, 2011 at 02:05:42AM +0100, Ben Hutchings wrote:
> ethtool_set_feature_compat() squashes the feature mask into a boolean,
> which is not correct for ethtool_ops::set_flags.
>
> We could fix this, but the fallback code for ETHTOOL_SFEATURES actually
> makes things more complicated for the ethtool utility and any other
> application using the ethtool API. They will still need to fall back to
> the old offload control commands in order to support older kernel
> versions. The fallback code in the kernel adds a third possibility for
> them to handle. So make ETHTOOL_SFEATURES fail when the driver
> implements the old offload control operations, and let userland do the
> fallback.
>
> Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
This will disable SFEATURES for drivers which implement changing newer
features that have no old ethtool ops (e.g. NETIF_F_LOOPBACK), but are
not converted, yet. This might matter when bisecting.
It's easy to fix this. The code is going away for 2.6.40, though.
Do you want to get rid of ETHTOOL_F_COMPAT bit before 2.6.39?
BTW, what are the complications for userspace?
This change misses ethtool_get_features_compat() setting available bits.
Best Regards,
Michał Mirosław
^ permalink raw reply
* Re: future developments of usbnet
From: Oliver Neukum @ 2011-05-14 10:01 UTC (permalink / raw)
To: Alan Stern; +Cc: David Miller, shemminger, tom.leiming, netdev, linux-usb
In-Reply-To: <Pine.LNX.4.44L0.1105121025360.1917-100000@iolanthe.rowland.org>
Am Donnerstag, 12. Mai 2011, 16:37:28 schrieb Alan Stern:
> Therefore usbnet's poll routine should take the "weight" argument as an
> indication of how many outstanding rx URBs are allowed. Each time the
> poll routine is called, it should check to see if any rx URBs have
> completed since the previous poll. If not then there is no network
> traffic, so usbnet can take itself out of the poll loop. Otherwise,
> the number of outstanding URBs should be adjusted (by unlinking some or
> submitting more -- subject to some fixed maximum limit) to match the
> new "weight".
>
> Does that make sense?
What does happen if we reach the weight 0 ?
Regards
Oliver
^ permalink raw reply
* Re: [PATCH 1/1] IPVS: seq_release_net should be used.
From: Hans Schillstrom @ 2011-05-14 10:05 UTC (permalink / raw)
To: Simon Horman; +Cc: Hans Schillstrom, ja, lvs-devel, netdev, netfilter-devel
In-Reply-To: <20110514005025.GD4862@verge.net.au>
On Saturday, May 14, 2011 02:50:26 Simon Horman wrote:
> On Fri, May 13, 2011 at 08:03:20AM +0200, Hans Schillstrom wrote:
> > Without this patch every access to ip_vs in procfs will increase
> > the netns count i.e. an unbalanced get_net()/put_net().
> > (ipvsadm commands also use procfs.)
> > The result is you can't exit a netns if reading ip_vs_* procfs entries.
>
> Hi Hans,
>
> we should try and get this into 2.6.39, right?
Yes, this is a trivial bug fix
>
> >
> > Signed-off-by: Hans Schillstrom <hans.schillstrom@ericsson.com>
> > ---
> > net/netfilter/ipvs/ip_vs_app.c | 2 +-
> > net/netfilter/ipvs/ip_vs_conn.c | 4 ++--
> > net/netfilter/ipvs/ip_vs_ctl.c | 6 +++---
> > 3 files changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/net/netfilter/ipvs/ip_vs_app.c b/net/netfilter/ipvs/ip_vs_app.c
> > index 51f3af7..059af31 100644
> > --- a/net/netfilter/ipvs/ip_vs_app.c
> > +++ b/net/netfilter/ipvs/ip_vs_app.c
> > @@ -572,7 +572,7 @@ static const struct file_operations ip_vs_app_fops = {
> > .open = ip_vs_app_open,
> > .read = seq_read,
> > .llseek = seq_lseek,
> > - .release = seq_release,
> > + .release = seq_release_net,
> > };
> > #endif
> >
> > diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
> > index d3fd91b..bf28ac2 100644
> > --- a/net/netfilter/ipvs/ip_vs_conn.c
> > +++ b/net/netfilter/ipvs/ip_vs_conn.c
> > @@ -1046,7 +1046,7 @@ static const struct file_operations ip_vs_conn_fops = {
> > .open = ip_vs_conn_open,
> > .read = seq_read,
> > .llseek = seq_lseek,
> > - .release = seq_release,
> > + .release = seq_release_net,
> > };
> >
> > static const char *ip_vs_origin_name(unsigned flags)
> > @@ -1114,7 +1114,7 @@ static const struct file_operations ip_vs_conn_sync_fops = {
> > .open = ip_vs_conn_sync_open,
> > .read = seq_read,
> > .llseek = seq_lseek,
> > - .release = seq_release,
> > + .release = seq_release_net,
> > };
> >
> > #endif
> > diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
> > index 89842f0..699c79a 100644
> > --- a/net/netfilter/ipvs/ip_vs_ctl.c
> > +++ b/net/netfilter/ipvs/ip_vs_ctl.c
> > @@ -2066,7 +2066,7 @@ static const struct file_operations ip_vs_info_fops = {
> > .open = ip_vs_info_open,
> > .read = seq_read,
> > .llseek = seq_lseek,
> > - .release = seq_release_private,
> > + .release = seq_release_net,
> > };
> >
> > static int ip_vs_stats_show(struct seq_file *seq, void *v)
> > @@ -2106,7 +2106,7 @@ static const struct file_operations ip_vs_stats_fops = {
> > .open = ip_vs_stats_seq_open,
> > .read = seq_read,
> > .llseek = seq_lseek,
> > - .release = single_release,
> > + .release = single_release_net,
> > };
> >
> > static int ip_vs_stats_percpu_show(struct seq_file *seq, void *v)
> > @@ -2175,7 +2175,7 @@ static const struct file_operations ip_vs_stats_percpu_fops = {
> > .open = ip_vs_stats_percpu_seq_open,
> > .read = seq_read,
> > .llseek = seq_lseek,
> > - .release = single_release,
> > + .release = single_release_net,
> > };
> > #endif
> >
>
^ permalink raw reply
* [PATCH] net: fix ETHTOOL_SFEATURES compatibility with old ethtool_ops.set_flags
From: Michał Mirosław @ 2011-05-14 10:31 UTC (permalink / raw)
To: netdev; +Cc: Ben Hutchings, David Miller
In-Reply-To: <20110514095457.GA31970@rere.qmqm.pl>
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
Against net-next, but this should also go to net.
net/core/ethtool.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index b8c2bcf..7bb3276 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -233,6 +233,29 @@ static int ethtool_set_feature_compat(struct net_device *dev,
return 1;
}
+static int ethtool_set_flags_compat(struct net_device *dev,
+ int (*legacy_set)(struct net_device *, u32),
+ struct ethtool_set_features_block *features, u32 mask)
+{
+ u32 value;
+
+ if (!legacy_set)
+ return 0;
+
+ if (!(features[0].valid & mask))
+ return 0;
+
+ features[0].valid &= ~mask;
+
+ value = dev->features & ~features[0].valid;
+ value |= features[0].requested;
+
+ if (legacy_set(dev, value & mask) < 0)
+ netdev_info(dev, "Legacy flags change failed\n");
+
+ return 1;
+}
+
static int ethtool_set_features_compat(struct net_device *dev,
struct ethtool_set_features_block *features)
{
@@ -249,7 +272,7 @@ static int ethtool_set_features_compat(struct net_device *dev,
features, NETIF_F_ALL_TSO);
compat |= ethtool_set_feature_compat(dev, dev->ethtool_ops->set_rx_csum,
features, NETIF_F_RXCSUM);
- compat |= ethtool_set_feature_compat(dev, dev->ethtool_ops->set_flags,
+ compat |= ethtool_set_flags_compat(dev, dev->ethtool_ops->set_flags,
features, flags_dup_features);
return compat;
--
1.7.2.5
^ permalink raw reply related
* Re: [PATCH net-2.6] ethtool: Remove fallback to old ethtool operations for ETHTOOL_SFEATURES
From: Michał Mirosław @ 2011-05-14 10:35 UTC (permalink / raw)
To: Ben Hutchings; +Cc: David Miller, netdev
In-Reply-To: <1305335142.2851.70.camel@bwh-desktop>
On Sat, May 14, 2011 at 02:05:42AM +0100, Ben Hutchings wrote:
> ethtool_set_feature_compat() squashes the feature mask into a boolean,
> which is not correct for ethtool_ops::set_flags.
>
> We could fix this, but the fallback code for ETHTOOL_SFEATURES actually
> makes things more complicated for the ethtool utility and any other
> application using the ethtool API. They will still need to fall back to
> the old offload control commands in order to support older kernel
> versions. The fallback code in the kernel adds a third possibility for
> them to handle. So make ETHTOOL_SFEATURES fail when the driver
> implements the old offload control operations, and let userland do the
> fallback.
BTW, the idea behind the compat code is that if ETHTOOL_[GS]FEATURES is
available, then there should be no need to fallback to old ops. For
a userspace tool that targets only kernels >= 2.6.39 there's no need
to care about old ops at all.
Best Regards,
Michał Mirosław
^ permalink raw reply
* [PATCH v2] net: fix ETHTOOL_SFEATURES compatibility with old ethtool_ops.set_flags
From: Michał Mirosław @ 2011-05-14 10:41 UTC (permalink / raw)
To: netdev; +Cc: Ben Hutchings, David Miller
In-Reply-To: <20110514103111.3FD5913A6A@rere.qmqm.pl>
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
v2: fix 'valid' bits clearing before use
net/core/ethtool.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index b8c2bcf..d1c8b64 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -233,6 +233,29 @@ static int ethtool_set_feature_compat(struct net_device *dev,
return 1;
}
+static int ethtool_set_flags_compat(struct net_device *dev,
+ int (*legacy_set)(struct net_device *, u32),
+ struct ethtool_set_features_block *features, u32 mask)
+{
+ u32 value;
+
+ if (!legacy_set)
+ return 0;
+
+ if (!(features[0].valid & mask))
+ return 0;
+
+ value = dev->features & ~features[0].valid;
+ value |= features[0].requested;
+
+ features[0].valid &= ~mask;
+
+ if (legacy_set(dev, value & mask) < 0)
+ netdev_info(dev, "Legacy flags change failed\n");
+
+ return 1;
+}
+
static int ethtool_set_features_compat(struct net_device *dev,
struct ethtool_set_features_block *features)
{
@@ -249,7 +272,7 @@ static int ethtool_set_features_compat(struct net_device *dev,
features, NETIF_F_ALL_TSO);
compat |= ethtool_set_feature_compat(dev, dev->ethtool_ops->set_rx_csum,
features, NETIF_F_RXCSUM);
- compat |= ethtool_set_feature_compat(dev, dev->ethtool_ops->set_flags,
+ compat |= ethtool_set_flags_compat(dev, dev->ethtool_ops->set_flags,
features, flags_dup_features);
return compat;
--
1.7.2.5
^ permalink raw reply related
* Re: future developments of usbnet
From: Michał Mirosław @ 2011-05-14 10:46 UTC (permalink / raw)
To: Oliver Neukum
Cc: Alan Stern, David Miller, shemminger-ZtmgI6mnKB3QT0dZR+AlfA,
tom.leiming-Re5JQEeQqe8AvxtiuMwx3w, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <201105141201.40265.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2011/5/14 Oliver Neukum <oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>:
> Am Donnerstag, 12. Mai 2011, 16:37:28 schrieb Alan Stern:
>> Therefore usbnet's poll routine should take the "weight" argument as an
>> indication of how many outstanding rx URBs are allowed. Each time the
>> poll routine is called, it should check to see if any rx URBs have
>> completed since the previous poll. If not then there is no network
>> traffic, so usbnet can take itself out of the poll loop. Otherwise,
>> the number of outstanding URBs should be adjusted (by unlinking some or
>> submitting more -- subject to some fixed maximum limit) to match the
>> new "weight".
> What does happen if we reach the weight 0 ?
Poll callback won't be called with weight 0. If there are more RX
packets after processing 'weight' of them, then the callback will be
called again later.
Best Regards,
Michał Mirosław
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* PATCH: ENC28J60 works with half-duplex DMA
From: Davide Rizzo @ 2011-05-14 12:54 UTC (permalink / raw)
To: netdev
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Attachment #2: enc28j60.c-2.6.38.patch --]
[-- Type: text/x-patch, Size: 5357 bytes --]
This patch modifies SPI access to take advantage of DMA on machines supporting
only half-duplex SPI DMA (like Samsung S3C2410)
Signed-off-by: Davide Rizzo <elpa.rizzo@gmail.com>
---
diff -urNp linux-2.6.38/drivers/net/enc28j60.c linux-2.6.38.elpa/drivers/net/enc28j60.c
--- linux-2.6.38/drivers/net/enc28j60.c 2011-03-15 02:20:32.000000000 +0100
+++ linux-2.6.38.elpa/drivers/net/enc28j60.c 2011-05-14 09:56:05.701797208 +0200
@@ -36,6 +36,8 @@
#define SPI_OPLEN 1
+#define FCLK_MAX 20000000
+
#define ENC28J60_MSG_DEFAULT \
(NETIF_MSG_PROBE | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN | NETIF_MSG_LINK)
@@ -84,29 +86,33 @@ static struct {
* SPI read buffer
* wait for the SPI transfer and copy received data to destination
*/
-static int
-spi_read_buf(struct enc28j60_net *priv, int len, u8 *data)
+static int spi_read_buf(struct enc28j60_net *priv, int len, u8 *data)
{
- u8 *rx_buf = priv->spi_transfer_buf + 4;
- u8 *tx_buf = priv->spi_transfer_buf;
struct spi_transfer t = {
- .tx_buf = tx_buf,
- .rx_buf = rx_buf,
- .len = SPI_OPLEN + len,
+ .tx_buf = priv->spi_transfer_buf,
+ .rx_buf = NULL,
+ .len = SPI_OPLEN,
+ .cs_change = 0,
+ .speed_hz = FCLK_MAX,
+ };
+ struct spi_transfer r = {
+ .tx_buf = NULL,
+ .rx_buf = data,
+ .len = len,
+ .cs_change = 1,
+ .speed_hz = FCLK_MAX,
};
struct spi_message msg;
int ret;
- tx_buf[0] = ENC28J60_READ_BUF_MEM;
- tx_buf[1] = tx_buf[2] = tx_buf[3] = 0; /* don't care */
+ priv->spi_transfer_buf[0] = ENC28J60_READ_BUF_MEM;
spi_message_init(&msg);
spi_message_add_tail(&t, &msg);
+ spi_message_add_tail(&r, &msg);
ret = spi_sync(priv->spi, &msg);
- if (ret == 0) {
- memcpy(data, &rx_buf[SPI_OPLEN], len);
+ if (ret == 0)
ret = msg.status;
- }
if (ret && netif_msg_drv(priv))
printk(KERN_DEBUG DRV_NAME ": %s() failed: ret = %d\n",
__func__, ret);
@@ -114,20 +120,26 @@ spi_read_buf(struct enc28j60_net *priv,
return ret;
}
-/*
- * SPI write buffer
- */
-static int spi_write_buf(struct enc28j60_net *priv, int len,
- const u8 *data)
+static int spi_send(struct enc28j60_net *priv, u8 cmd, int len, const u8 *data)
{
int ret;
+ struct spi_message msg;
+ struct spi_transfer t = {
+ .tx_buf = priv->spi_transfer_buf,
+ .rx_buf = NULL,
+ .len = len + 1,
+ .cs_change = 1,
+ .speed_hz = FCLK_MAX,
+ };
if (len > SPI_TRANSFER_BUF_LEN - 1 || len <= 0)
ret = -EINVAL;
else {
- priv->spi_transfer_buf[0] = ENC28J60_WRITE_BUF_MEM;
+ spi_message_init(&msg);
+ spi_message_add_tail(&t, &msg);
+ priv->spi_transfer_buf[0] = cmd;
memcpy(&priv->spi_transfer_buf[1], data, len);
- ret = spi_write(priv->spi, priv->spi_transfer_buf, len + 1);
+ ret = spi_sync(priv->spi, &msg);
if (ret && netif_msg_drv(priv))
printk(KERN_DEBUG DRV_NAME ": %s() failed: ret = %d\n",
__func__, ret);
@@ -136,28 +148,56 @@ static int spi_write_buf(struct enc28j60
}
/*
+ * SPI write buffer
+ */
+static int spi_write_buf(struct enc28j60_net *priv, int len,
+ const u8 *data)
+{
+ return spi_send(priv, ENC28J60_WRITE_BUF_MEM, len, data);
+}
+
+/*
* basic SPI read operation
*/
-static u8 spi_read_op(struct enc28j60_net *priv, u8 op,
- u8 addr)
+static u8 spi_read_op(struct enc28j60_net *priv, u8 op, u8 addr)
{
- u8 tx_buf[2];
- u8 rx_buf[4];
+ u8 tx_buf;
+ u8 rx_buf[SPI_OPLEN + 1];
u8 val = 0;
+ struct spi_transfer t = {
+ .tx_buf = &tx_buf,
+ .rx_buf = NULL,
+ .len = SPI_OPLEN,
+ .cs_change = 0,
+ .speed_hz = FCLK_MAX,
+ };
+ struct spi_transfer r = {
+ .tx_buf = NULL,
+ .rx_buf = rx_buf,
+ .len = SPI_OPLEN,
+ .cs_change = 1,
+ .speed_hz = FCLK_MAX,
+ };
+ struct spi_message msg;
int ret;
- int slen = SPI_OPLEN;
/* do dummy read if needed */
if (addr & SPRD_MASK)
- slen++;
+ r.len++;
+
+ tx_buf = op | (addr & ADDR_MASK);
- tx_buf[0] = op | (addr & ADDR_MASK);
- ret = spi_write_then_read(priv->spi, tx_buf, 1, rx_buf, slen);
- if (ret)
+ spi_message_init(&msg);
+ spi_message_add_tail(&t, &msg);
+ spi_message_add_tail(&r, &msg);
+ ret = spi_sync(priv->spi, &msg);
+ if (ret == 0)
+ ret = msg.status;
+ if (ret && netif_msg_drv(priv))
printk(KERN_DEBUG DRV_NAME ": %s() failed: ret = %d\n",
__func__, ret);
else
- val = rx_buf[slen - 1];
+ val = rx_buf[r.len - 1];
return val;
}
@@ -165,18 +205,9 @@ static u8 spi_read_op(struct enc28j60_ne
/*
* basic SPI write operation
*/
-static int spi_write_op(struct enc28j60_net *priv, u8 op,
- u8 addr, u8 val)
+static int spi_write_op(struct enc28j60_net *priv, u8 op, u8 addr, u8 val)
{
- int ret;
-
- priv->spi_transfer_buf[0] = op | (addr & ADDR_MASK);
- priv->spi_transfer_buf[1] = val;
- ret = spi_write(priv->spi, priv->spi_transfer_buf, 2);
- if (ret && netif_msg_drv(priv))
- printk(KERN_DEBUG DRV_NAME ": %s() failed: ret = %d\n",
- __func__, ret);
- return ret;
+ return spi_send(priv, op | (addr & ADDR_MASK), 1, &val);
}
static void enc28j60_soft_reset(struct enc28j60_net *priv)
@@ -1572,6 +1603,12 @@ static int __devinit enc28j60_probe(stru
dev_set_drvdata(&spi->dev, priv); /* spi to priv reference */
SET_NETDEV_DEV(dev, &spi->dev);
+ /* Configure the SPI bus */
+ spi->mode = SPI_MODE_0;
+ spi->bits_per_word = 8;
+ spi->max_speed_hz = FCLK_MAX;
+ spi_setup(spi);
+
if (!enc28j60_chipset_init(dev)) {
if (netif_msg_probe(priv))
dev_info(&spi->dev, DRV_NAME " chip not found\n");
^ permalink raw reply
* [PATCH] net: ipv6: mcast: Removing invalid check
From: Maxin B John @ 2011-05-14 13:43 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel, kaber, yoshfuji, jmorris, pekkas, kuznet, davem
Since the variable 'first' is assigned to 1, the check
"if (truncate && !first)" will always be false.
Thanks to Coverity for spotting this issue.
Signed-off-by: Maxin B. John <maxin.john@gmail.com>
---
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 76b8937..441c1a4 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -1536,8 +1536,6 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc,
if (AVAILABLE(skb) < sizeof(*psrc) +
first*sizeof(struct mld2_grec)) {
- if (truncate && !first)
- break; /* truncate these */
if (pgr)
pgr->grec_nsrcs = htons(scount);
if (skb)
^ permalink raw reply related
* Re: [PATCH] net: ipv6: mcast: Removing invalid check
From: Eric Dumazet @ 2011-05-14 14:33 UTC (permalink / raw)
To: Maxin B John
Cc: netdev, linux-kernel, kaber, yoshfuji, jmorris, pekkas, kuznet,
davem
In-Reply-To: <20110514134307.GA3603@maxin>
Le samedi 14 mai 2011 à 16:43 +0300, Maxin B John a écrit :
> Since the variable 'first' is assigned to 1, the check
> "if (truncate && !first)" will always be false.
>
> Thanks to Coverity for spotting this issue.
>
> Signed-off-by: Maxin B. John <maxin.john@gmail.com>
> ---
> diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
> index 76b8937..441c1a4 100644
> --- a/net/ipv6/mcast.c
> +++ b/net/ipv6/mcast.c
> @@ -1536,8 +1536,6 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc,
>
> if (AVAILABLE(skb) < sizeof(*psrc) +
> first*sizeof(struct mld2_grec)) {
> - if (truncate && !first)
> - break; /* truncate these */
> if (pgr)
> pgr->grec_nsrcs = htons(scount);
> if (skb)
At a first glance, I would say Coverity is wrong, unless you can explain
why it's right ;)
first can be 0 at this point, we are in a loop.
BTW "Removing invalid check" is a really wrong patch title.
Once you can prove your point, you should use "Remove useless check"
Thanks
^ permalink raw reply
* Re: [PATCH net-next-2.6] net: ping: small changes
From: Vasiliy Kulikov @ 2011-05-14 14:34 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David Miller, netdev
In-Reply-To: <1305363559.3120.54.camel@edumazet-laptop>
On Sat, May 14, 2011 at 10:59 +0200, Eric Dumazet wrote:
> ping_table is not __read_mostly, since it contains one rwlock,
> and is static to ping.c
>
> ping_port_rover & ping_v4_lookup are static
>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Acked-by: Vasiliy Kulikov <segoon@openwall.com>
Thanks,
--
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments
^ permalink raw reply
* Re: [PATCH] net: ipv6: mcast: Removing invalid check
From: Maxin B John @ 2011-05-14 14:45 UTC (permalink / raw)
To: Eric Dumazet
Cc: netdev, linux-kernel, kaber, yoshfuji, jmorris, pekkas, kuznet,
davem
In-Reply-To: <1305383610.3120.62.camel@edumazet-laptop>
Hi,
> At a first glance, I would say Coverity is wrong, unless you can explain
> why it's right ;)
>
> first can be 0 at this point, we are in a loop.
You are right.
> BTW "Removing invalid check" is a really wrong patch title.
>
> Once you can prove your point, you should use "Remove useless check"
>
I will keep it in mind. Thanks .
Best Regards,
Maxin B John
^ permalink raw reply
* radvd v1.8 released
From: Reuben Hawkins @ 2011-05-14 14:50 UTC (permalink / raw)
To: radvd-announce-l, radvd Development Discussion, netdev
Hi All,
Radvd v1.8 was just released. The release highlights are...
* IgnoreIfMissing now defaults to on
* Timer code replaced with poll
* radvd now listens for interface state changes on a netlink socket
* DecrementLifetimes
* DeprecatePrefix
* FlushRoute
* BugFix in DNSSL parsing
Radvd v1.8 can be downloaded at http://www.litech.org/radvd. Please
report any bugs or problems to radvd-devel-l@litech.org.
Thanks,
Reuben
^ permalink raw reply
* Re: [PATCH net-2.6] ethtool: Remove fallback to old ethtool operations for ETHTOOL_SFEATURES
From: Ben Hutchings @ 2011-05-14 20:08 UTC (permalink / raw)
To: Michał Mirosław; +Cc: David Miller, netdev
In-Reply-To: <20110514095457.GA31970@rere.qmqm.pl>
[Sending this from my home address as solarflare.com mail is under
maintenance and SPF prevents me using that address entirely.]
On Sat, 2011-05-14 at 11:54 +0200, Michał Mirosław wrote:
> On Sat, May 14, 2011 at 02:05:42AM +0100, Ben Hutchings wrote:
> > ethtool_set_feature_compat() squashes the feature mask into a boolean,
> > which is not correct for ethtool_ops::set_flags.
> >
> > We could fix this, but the fallback code for ETHTOOL_SFEATURES actually
> > makes things more complicated for the ethtool utility and any other
> > application using the ethtool API. They will still need to fall back to
> > the old offload control commands in order to support older kernel
> > versions. The fallback code in the kernel adds a third possibility for
> > them to handle. So make ETHTOOL_SFEATURES fail when the driver
> > implements the old offload control operations, and let userland do the
> > fallback.
> >
> > Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
>
> This will disable SFEATURES for drivers which implement changing newer
> features that have no old ethtool ops (e.g. NETIF_F_LOOPBACK), but are
> not converted, yet. This might matter when bisecting.
>
> It's easy to fix this.
Yes, I realise that.
> The code is going away for 2.6.40, though.
> Do you want to get rid of ETHTOOL_F_COMPAT bit before 2.6.39?
Right, I don't want this to ever be in a stable release.
> BTW, what are the complications for userspace?
With 2.6.38 and earlier, ETHTOOL_SFEATURES will fail; ethtool -K will
fall back to the individual operations can can report which of them
failed and why.
With 2.6.39 and a converted driver, ethtool -K can find out exactly
which features are changeable and report whether any of the individual
changes are not supported at all. If there's something wrong with the
combination of features then ETHTOOL_SFEATURES will return
ETHTOOL_F_WISH and it can report that the combination is not supported.
With 2.6.39 and an unconverted driver, ETHTOOL_SFEATURES can return
ETHTOOL_F_COMPAT which just tells us some change failed, but not why.
We can try to guess what went wrong by reading back the features, but
it's unclear. This is particularly problematic with set_flags (again)
where the ethtool core can't tell which flags are settable in an
unconverted driver.
I would much prefer not to have this third case existing in a single
stable release.
> This change misses ethtool_get_features_compat() setting available bits.
Yes, but that is less of a problem in practice.
Ben.
--
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.
^ permalink raw reply
* Re: [PATCH net-next 2/4] tulip: Convert printks to netdev_<level>
From: Grant Grundler @ 2011-05-14 20:30 UTC (permalink / raw)
To: Joe Perches; +Cc: Tobias Ringstrom, netdev, linux-kernel
In-Reply-To: <1305176371.6124.29.camel@Joe-Laptop>
On Wed, May 11, 2011 at 09:59:31PM -0700, Joe Perches wrote:
> On Wed, 2011-05-11 at 22:09 -0600, Grant Grundler wrote:
> > Some additional clean ups to consider in a future patch:
> > o replace "if (skb == NULL)" with "if (!skb)"
>
> Hey Grant.
>
> I generally don't change those.
> While I prefer (!ptr), others prefer explicit comparisons.
> I do have a script that does the conversion though.
> (de4x5.c is a mess and I didn't change it)
>
> Here's the output with hoisted assigns from if too.
> (and a spelling fix I noticed)
LGTM. :)
Please repost with Signed-off-by, my
"Acked-By: Grant Grundler <grundler@parisc-linux.org>"
and davem can apply.
I can't test these at the moment because I haven't figured out how to
update my parisc machine (parisc was dropped from debian testing).
I'm trying to build a gentoo chroot today though. We'll see.
thanks,
grant
>
> drivers/net/tulip/de2104x.c | 3 ++-
> drivers/net/tulip/dmfe.c | 11 ++++++-----
> drivers/net/tulip/eeprom.c | 6 +++---
> drivers/net/tulip/interrupt.c | 18 +++++++++---------
> drivers/net/tulip/timer.c | 2 +-
> drivers/net/tulip/tulip_core.c | 15 +++++++++------
> drivers/net/tulip/uli526x.c | 15 +++++++--------
> drivers/net/tulip/winbond-840.c | 14 ++++++++------
> drivers/net/tulip/xircom_cb.c | 12 ++++++------
> 9 files changed, 51 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
> index e2f6923..45a4843 100644
> --- a/drivers/net/tulip/de2104x.c
> +++ b/drivers/net/tulip/de2104x.c
> @@ -2170,7 +2170,8 @@ static int de_resume (struct pci_dev *pdev)
> goto out;
> if (!netif_running(dev))
> goto out_attach;
> - if ((retval = pci_enable_device(pdev))) {
> + retval = pci_enable_device(pdev);
> + if (retval) {
> netdev_err(dev, "pci_enable_device failed in resume\n");
> goto out;
> }
> diff --git a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
> index 4685127..588d6b4 100644
> --- a/drivers/net/tulip/dmfe.c
> +++ b/drivers/net/tulip/dmfe.c
> @@ -400,7 +400,7 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,
>
> /* Init network device */
> dev = alloc_etherdev(sizeof(*db));
> - if (dev == NULL)
> + if (!dev)
> return -ENOMEM;
> SET_NETDEV_DEV(dev, &pdev->dev);
>
> @@ -1009,10 +1009,10 @@ static void dmfe_rx_packet(struct DEVICE *dev, struct dmfe_board_info * db)
> db->dm910x_chk_mode = 3;
> } else {
> /* Good packet, send to upper layer */
> - /* Shorst packet used new SKB */
> + /* Short packet used new SKB */
> if ((rxlen < RX_COPY_SIZE) &&
> - ((newskb = dev_alloc_skb(rxlen + 2))
> - != NULL)) {
> + (newskb =
> + dev_alloc_skb(rxlen + 2))) {
>
> skb = newskb;
> /* size less than COPY_SIZE, allocate a rxlen SKB */
> @@ -1561,7 +1561,8 @@ static void allocate_rx_buffer(struct dmfe_board_info *db)
> rxptr = db->rx_insert_ptr;
>
> while(db->rx_avail_cnt < RX_DESC_CNT) {
> - if ( ( skb = dev_alloc_skb(RX_ALLOC_SIZE) ) == NULL )
> + skb = dev_alloc_skb(RX_ALLOC_SIZE);
> + if (!skb)
> break;
> rxptr->rx_skb_ptr = skb; /* FIXME (?) */
> rxptr->rdes2 = cpu_to_le32( pci_map_single(db->pdev, skb->data,
> diff --git a/drivers/net/tulip/eeprom.c b/drivers/net/tulip/eeprom.c
> index fa5eee9..a11eb73 100644
> --- a/drivers/net/tulip/eeprom.c
> +++ b/drivers/net/tulip/eeprom.c
> @@ -123,7 +123,7 @@ static void __devinit tulip_build_fake_mediatable(struct tulip_private *tp)
> tp->mtable = kmalloc(sizeof(struct mediatable) +
> sizeof(struct medialeaf), GFP_KERNEL);
>
> - if (tp->mtable == NULL)
> + if (!tp->mtable)
> return; /* Horrible, impossible failure. */
>
> tp->mtable->defaultmedia = 0x800;
> @@ -192,7 +192,7 @@ void __devinit tulip_parse_eeprom(struct net_device *dev)
> break;
> }
> }
> - if (eeprom_fixups[i].name == NULL) { /* No fixup found. */
> + if (!eeprom_fixups[i].name) { /* No fixup found. */
> pr_info("%s: Old style EEPROM with no media selection information\n",
> dev->name);
> return;
> @@ -230,7 +230,7 @@ subsequent_board:
> mtable = kmalloc(sizeof(struct mediatable) +
> count * sizeof(struct medialeaf),
> GFP_KERNEL);
> - if (mtable == NULL)
> + if (!mtable)
> return; /* Horrible, impossible failure. */
> last_mediatable = tp->mtable = mtable;
> mtable->defaultmedia = media;
> diff --git a/drivers/net/tulip/interrupt.c b/drivers/net/tulip/interrupt.c
> index 5350d75..1a1bff5 100644
> --- a/drivers/net/tulip/interrupt.c
> +++ b/drivers/net/tulip/interrupt.c
> @@ -68,12 +68,12 @@ int tulip_refill_rx(struct net_device *dev)
> /* Refill the Rx ring buffers. */
> for (; tp->cur_rx - tp->dirty_rx > 0; tp->dirty_rx++) {
> entry = tp->dirty_rx % RX_RING_SIZE;
> - if (tp->rx_buffers[entry].skb == NULL) {
> + if (!tp->rx_buffers[entry].skb) {
> struct sk_buff *skb;
> dma_addr_t mapping;
>
> skb = tp->rx_buffers[entry].skb = dev_alloc_skb(PKT_BUF_SZ);
> - if (skb == NULL)
> + if (!skb)
> break;
>
> mapping = pci_map_single(tp->pdev, skb->data, PKT_BUF_SZ,
> @@ -205,7 +205,7 @@ int tulip_poll(struct napi_struct *napi, int budget)
> /* Check if the packet is long enough to accept without copying
> to a minimally-sized skbuff. */
> if (pkt_len < tulip_rx_copybreak &&
> - (skb = dev_alloc_skb(pkt_len + 2)) != NULL) {
> + (skb = dev_alloc_skb(pkt_len + 2))) {
> skb_reserve(skb, 2); /* 16 byte align the IP header */
> pci_dma_sync_single_for_cpu(tp->pdev,
> tp->rx_buffers[entry].mapping,
> @@ -311,7 +311,7 @@ int tulip_poll(struct napi_struct *napi, int budget)
> tulip_refill_rx(dev);
>
> /* If RX ring is not full we are out of memory. */
> - if (tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb == NULL)
> + if (!tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb)
> goto oom;
>
> /* Remove us from polling list and enable RX intr. */
> @@ -334,10 +334,10 @@ int tulip_poll(struct napi_struct *napi, int budget)
>
> not_done:
> if (tp->cur_rx - tp->dirty_rx > RX_RING_SIZE/2 ||
> - tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb == NULL)
> + !tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb)
> tulip_refill_rx(dev);
>
> - if (tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb == NULL)
> + if (!tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb)
> goto oom;
>
> return work_done;
> @@ -431,7 +431,7 @@ static int tulip_rx(struct net_device *dev)
> /* Check if the packet is long enough to accept without copying
> to a minimally-sized skbuff. */
> if (pkt_len < tulip_rx_copybreak &&
> - (skb = dev_alloc_skb(pkt_len + 2)) != NULL) {
> + (skb = dev_alloc_skb(pkt_len + 2))) {
> skb_reserve(skb, 2); /* 16 byte align the IP header */
> pci_dma_sync_single_for_cpu(tp->pdev,
> tp->rx_buffers[entry].mapping,
> @@ -591,7 +591,7 @@ irqreturn_t tulip_interrupt(int irq, void *dev_instance)
> break; /* It still has not been Txed */
>
> /* Check for Rx filter setup frames. */
> - if (tp->tx_buffers[entry].skb == NULL) {
> + if (!tp->tx_buffers[entry].skb) {
> /* test because dummy frames not mapped */
> if (tp->tx_buffers[entry].mapping)
> pci_unmap_single(tp->pdev,
> @@ -775,7 +775,7 @@ irqreturn_t tulip_interrupt(int irq, void *dev_instance)
>
> /* check if the card is in suspend mode */
> entry = tp->dirty_rx % RX_RING_SIZE;
> - if (tp->rx_buffers[entry].skb == NULL) {
> + if (!tp->rx_buffers[entry].skb) {
> if (tulip_debug > 1)
> dev_warn(&dev->dev,
> "in rx suspend mode: (%lu) (tp->cur_rx = %u, ttimer = %d, rx = %d) go/stay in suspend mode\n",
> diff --git a/drivers/net/tulip/timer.c b/drivers/net/tulip/timer.c
> index 2017faf..afc5445 100644
> --- a/drivers/net/tulip/timer.c
> +++ b/drivers/net/tulip/timer.c
> @@ -43,7 +43,7 @@ void tulip_media_task(struct work_struct *work)
> default: {
> struct medialeaf *mleaf;
> unsigned char *p;
> - if (tp->mtable == NULL) { /* No EEPROM info, use generic code. */
> + if (!tp->mtable) { /* No EEPROM info, use generic code. */
> /* Not much that can be done.
> Assume this a generic MII or SYM transceiver. */
> next_tick = 60*HZ;
> diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
> index 82f8764..0ab2465 100644
> --- a/drivers/net/tulip/tulip_core.c
> +++ b/drivers/net/tulip/tulip_core.c
> @@ -384,7 +384,7 @@ static void tulip_up(struct net_device *dev)
>
> /* Allow selecting a default media. */
> i = 0;
> - if (tp->mtable == NULL)
> + if (!tp->mtable)
> goto media_picked;
> if (dev->if_port) {
> int looking_for = tulip_media_cap[dev->if_port] & MediaIsMII ? 11 :
> @@ -642,7 +642,7 @@ static void tulip_init_ring(struct net_device *dev)
> use skb_reserve() to align the IP header! */
> struct sk_buff *skb = dev_alloc_skb(PKT_BUF_SZ);
> tp->rx_buffers[i].skb = skb;
> - if (skb == NULL)
> + if (!skb)
> break;
> mapping = pci_map_single(tp->pdev, skb->data,
> PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
> @@ -728,7 +728,7 @@ static void tulip_clean_tx_ring(struct tulip_private *tp)
> }
>
> /* Check for Tx filter setup frames. */
> - if (tp->tx_buffers[entry].skb == NULL) {
> + if (!tp->tx_buffers[entry].skb) {
> /* test because dummy frames not mapped */
> if (tp->tx_buffers[entry].mapping)
> pci_unmap_single(tp->pdev,
> @@ -821,7 +821,7 @@ static void tulip_free_ring (struct net_device *dev)
> for (i = 0; i < TX_RING_SIZE; i++) {
> struct sk_buff *skb = tp->tx_buffers[i].skb;
>
> - if (skb != NULL) {
> + if (skb) {
> pci_unmap_single(tp->pdev, tp->tx_buffers[i].mapping,
> skb->len, PCI_DMA_TODEVICE);
> dev_kfree_skb (skb);
> @@ -1900,12 +1900,15 @@ static int tulip_resume(struct pci_dev *pdev)
> if (!netif_running(dev))
> return 0;
>
> - if ((retval = pci_enable_device(pdev))) {
> + retval = pci_enable_device(pdev);
> + if (retval) {
> pr_err("pci_enable_device failed in resume\n");
> return retval;
> }
>
> - if ((retval = request_irq(dev->irq, tulip_interrupt, IRQF_SHARED, dev->name, dev))) {
> + retval = request_irq(dev->irq, tulip_interrupt, IRQF_SHARED,
> + dev->name, dev);
> + if (retval) {
> pr_err("request_irq failed in resume\n");
> return retval;
> }
> diff --git a/drivers/net/tulip/uli526x.c b/drivers/net/tulip/uli526x.c
> index 9e63f40..a6f6a9e 100644
> --- a/drivers/net/tulip/uli526x.c
> +++ b/drivers/net/tulip/uli526x.c
> @@ -286,7 +286,7 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
>
> /* Init network device */
> dev = alloc_etherdev(sizeof(*db));
> - if (dev == NULL)
> + if (!dev)
> return -ENOMEM;
> SET_NETDEV_DEV(dev, &pdev->dev);
>
> @@ -324,14 +324,12 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
>
> /* Allocate Tx/Rx descriptor memory */
> db->desc_pool_ptr = pci_alloc_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20, &db->desc_pool_dma_ptr);
> - if(db->desc_pool_ptr == NULL)
> - {
> + if (!db->desc_pool_ptr) {
> err = -ENOMEM;
> goto err_out_nomem;
> }
> db->buf_pool_ptr = pci_alloc_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, &db->buf_pool_dma_ptr);
> - if(db->buf_pool_ptr == NULL)
> - {
> + if (!db->buf_pool_ptr) {
> err = -ENOMEM;
> goto err_out_nomem;
> }
> @@ -404,7 +402,7 @@ err_out_nomem:
> pci_free_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20,
> db->desc_pool_ptr, db->desc_pool_dma_ptr);
>
> - if(db->buf_pool_ptr != NULL)
> + if (db->buf_pool_ptr)
> pci_free_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4,
> db->buf_pool_ptr, db->buf_pool_dma_ptr);
> err_out_disable:
> @@ -844,7 +842,7 @@ static void uli526x_rx_packet(struct net_device *dev, struct uli526x_board_info
> /* Good packet, send to upper layer */
> /* Shorst packet used new SKB */
> if ((rxlen < RX_COPY_SIZE) &&
> - (((new_skb = dev_alloc_skb(rxlen + 2)) != NULL))) {
> + (new_skb = dev_alloc_skb(rxlen + 2))) {
> skb = new_skb;
> /* size less than COPY_SIZE, allocate a rxlen SKB */
> skb_reserve(skb, 2); /* 16byte align */
> @@ -1440,7 +1438,8 @@ static void allocate_rx_buffer(struct uli526x_board_info *db)
> rxptr = db->rx_insert_ptr;
>
> while(db->rx_avail_cnt < RX_DESC_CNT) {
> - if ( ( skb = dev_alloc_skb(RX_ALLOC_SIZE) ) == NULL )
> + skb = dev_alloc_skb(RX_ALLOC_SIZE);
> + if (!skb)
> break;
> rxptr->rx_skb_ptr = skb; /* FIXME (?) */
> rxptr->rdes2 = cpu_to_le32(pci_map_single(db->pdev,
> diff --git a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
> index 862eadf..a957e72 100644
> --- a/drivers/net/tulip/winbond-840.c
> +++ b/drivers/net/tulip/winbond-840.c
> @@ -647,7 +647,8 @@ static int netdev_open(struct net_device *dev)
> if (debug > 1)
> netdev_dbg(dev, "w89c840_open() irq %d\n", dev->irq);
>
> - if((i=alloc_ringdesc(dev)))
> + i = alloc_ringdesc(dev);
> + if (i)
> goto out_err;
>
> spin_lock_irq(&np->lock);
> @@ -817,7 +818,7 @@ static void init_rxtx_rings(struct net_device *dev)
> for (i = 0; i < RX_RING_SIZE; i++) {
> struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz);
> np->rx_skbuff[i] = skb;
> - if (skb == NULL)
> + if (!skb)
> break;
> np->rx_addr[i] = pci_map_single(np->pci_dev,skb->data,
> np->rx_buf_sz,PCI_DMA_FROMDEVICE);
> @@ -1231,7 +1232,7 @@ static int netdev_rx(struct net_device *dev)
> /* Check if the packet is long enough to accept without copying
> to a minimally-sized skbuff. */
> if (pkt_len < rx_copybreak &&
> - (skb = dev_alloc_skb(pkt_len + 2)) != NULL) {
> + (skb = dev_alloc_skb(pkt_len + 2))) {
> skb_reserve(skb, 2); /* 16 byte align the IP header */
> pci_dma_sync_single_for_cpu(np->pci_dev,np->rx_addr[entry],
> np->rx_skbuff[entry]->len,
> @@ -1269,10 +1270,10 @@ static int netdev_rx(struct net_device *dev)
> for (; np->cur_rx - np->dirty_rx > 0; np->dirty_rx++) {
> struct sk_buff *skb;
> entry = np->dirty_rx % RX_RING_SIZE;
> - if (np->rx_skbuff[entry] == NULL) {
> + if (!np->rx_skbuff[entry]) {
> skb = dev_alloc_skb(np->rx_buf_sz);
> np->rx_skbuff[entry] = skb;
> - if (skb == NULL)
> + if (!skb)
> break; /* Better luck next round. */
> np->rx_addr[entry] = pci_map_single(np->pci_dev,
> skb->data,
> @@ -1618,7 +1619,8 @@ static int w840_resume (struct pci_dev *pdev)
> if (netif_device_present(dev))
> goto out; /* device not suspended */
> if (netif_running(dev)) {
> - if ((retval = pci_enable_device(pdev))) {
> + retval = pci_enable_device(pdev);
> + if (retval) {
> dev_err(&dev->dev,
> "pci_enable_device failed in resume\n");
> goto out;
> diff --git a/drivers/net/tulip/xircom_cb.c b/drivers/net/tulip/xircom_cb.c
> index 988b8eb..1cb7208 100644
> --- a/drivers/net/tulip/xircom_cb.c
> +++ b/drivers/net/tulip/xircom_cb.c
> @@ -230,12 +230,12 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
>
> /* Allocate the send/receive buffers */
> private->rx_buffer = pci_alloc_consistent(pdev,8192,&private->rx_dma_handle);
> - if (private->rx_buffer == NULL) {
> + if (!private->rx_buffer) {
> pr_err("%s: no memory for rx buffer\n", __func__);
> goto rx_buf_fail;
> }
> private->tx_buffer = pci_alloc_consistent(pdev,8192,&private->tx_dma_handle);
> - if (private->tx_buffer == NULL) {
> + if (!private->tx_buffer) {
> pr_err("%s: no memory for tx buffer\n", __func__);
> goto tx_buf_fail;
> }
> @@ -546,8 +546,8 @@ static void setup_descriptors(struct xircom_private *card)
> u32 address;
> int i;
>
> - BUG_ON(card->rx_buffer == NULL);
> - BUG_ON(card->tx_buffer == NULL);
> + BUG_ON(!card->rx_buffer);
> + BUG_ON(!card->tx_buffer);
>
> /* Receive descriptors */
> memset(card->rx_buffer, 0, 128); /* clear the descriptors */
> @@ -1086,7 +1086,7 @@ investigate_read_descriptor(struct net_device *dev, struct xircom_private *card,
> }
>
> skb = dev_alloc_skb(pkt_len + 2);
> - if (skb == NULL) {
> + if (!skb) {
> dev->stats.rx_dropped++;
> goto out;
> }
> @@ -1125,7 +1125,7 @@ investigate_write_descriptor(struct net_device *dev,
> }
> #endif
> if (status > 0) { /* bit 31 is 0 when done */
> - if (card->tx_skb[descnr]!=NULL) {
> + if (card->tx_skb[descnr]) {
> dev->stats.tx_bytes += card->tx_skb[descnr]->len;
> dev_kfree_skb_irq(card->tx_skb[descnr]);
> }
>
> > o in general, HW doesn't return signed integer values. Where possible,
> > I prefer to see "unsigned int status;" and "if (status)".
>
> That one is yours to change if you want.
^ permalink raw reply
* (unknown),
From: Micha Nelissen @ 2011-05-14 20:20 UTC (permalink / raw)
To: netdev
/* Define the friendly delay before and after opening net devices */
-#define CONF_PRE_OPEN 500 /* Before opening: 1/2 second */
-#define CONF_POST_OPEN 1 /* After opening: 1 second */
+#define CONF_POST_OPEN 10 /* After opening: 10 msecs */
+#define CONF_CARRIER_TIMEOUT 120000 /* Wait for carrier timeout */
/* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */
#define CONF_OPEN_RETRIES 2 /* (Re)open devices twice */
@@ -187,11 +187,22 @@
static struct ic_device *ic_first_dev __initdata = NULL;/* List of open device */
static struct net_device *ic_dev __initdata = NULL; /* Selected device */
+static int __init ic_is_init_dev(struct net_device *dev)
+{
+ if (dev->flags & IFF_LOOPBACK)
+ return 0;
+ return user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :
+ (!(dev->flags & IFF_LOOPBACK) &&
+ (dev->flags & (IFF_POINTOPOINT|IFF_BROADCAST)) &&
+ strncmp(dev->name, "dummy", 5));
+}
+
static int __init ic_open_devs(void)
{
struct ic_device *d, **last;
struct net_device *dev;
unsigned short oflags;
+ unsigned long start;
last = &ic_first_dev;
rtnl_lock();
@@ -205,12 +216,7 @@
}
for_each_netdev(&init_net, dev) {
- if (dev->flags & IFF_LOOPBACK)
- continue;
- if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :
- (!(dev->flags & IFF_LOOPBACK) &&
- (dev->flags & (IFF_POINTOPOINT|IFF_BROADCAST)) &&
- strncmp(dev->name, "dummy", 5))) {
+ if (ic_is_init_dev(dev)) {
int able = 0;
if (dev->mtu >= 364)
able |= IC_BOOTP;
@@ -244,6 +250,17 @@
dev->name, able, d->xid));
}
}
+
+ /* wait for a carrier on at least one device */
+ start = jiffies;
+ while (jiffies - start < msecs_to_jiffies(CONF_CARRIER_TIMEOUT)) {
+ for_each_netdev(&init_net, dev)
+ if (ic_is_init_dev(dev) && netif_carrier_ok(dev))
+ goto have_carrier;
+
+ msleep(1);
+ }
+have_carrier:
rtnl_unlock();
*last = NULL;
@@ -1325,15 +1342,12 @@
#ifdef IPCONFIG_DYNAMIC
try_try_again:
#endif
- /* Give hardware a chance to settle */
- msleep(CONF_PRE_OPEN);
-
/* Setup all network devices */
if (ic_open_devs() < 0)
return -1;
/* Give drivers a chance to settle */
- ssleep(CONF_POST_OPEN);
+ msleep(CONF_POST_OPEN);
/*
* If the config information is insufficient (e.g., our IP address or
^ permalink raw reply
* [PATCH] ipconfig wait for carrier
From: Micha Nelissen @ 2011-05-14 20:36 UTC (permalink / raw)
To: netdev
Currently the ip auto configuration has a hardcoded delay of 1 second.
When (ethernet) link takes longer to come up (e.g. more than 3 seconds),
nfs root may not be found.
Remove the hardcoded delay, and wait for carrier on at least one network
device.
Index: atom-linux/net/ipv4/ipconfig.c
===================================================================
--- atom-linux/net/ipv4/ipconfig.c (revision 1445)
+++ atom-linux/net/ipv4/ipconfig.c (working copy)
@@ -86,8 +86,8 @@
#endif
/* Define the friendly delay before and after opening net devices */
-#define CONF_PRE_OPEN 500 /* Before opening: 1/2 second */
-#define CONF_POST_OPEN 1 /* After opening: 1 second */
+#define CONF_POST_OPEN 10 /* After opening: 10 msecs */
+#define CONF_CARRIER_TIMEOUT 120000 /* Wait for carrier timeout */
/* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */
#define CONF_OPEN_RETRIES 2 /* (Re)open devices twice */
@@ -187,11 +187,22 @@
static struct ic_device *ic_first_dev __initdata = NULL;/* List of open device */
static struct net_device *ic_dev __initdata = NULL; /* Selected device */
+static int __init ic_is_init_dev(struct net_device *dev)
+{
+ if (dev->flags & IFF_LOOPBACK)
+ return 0;
+ return user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :
+ (!(dev->flags & IFF_LOOPBACK) &&
+ (dev->flags & (IFF_POINTOPOINT|IFF_BROADCAST)) &&
+ strncmp(dev->name, "dummy", 5));
+}
+
static int __init ic_open_devs(void)
{
struct ic_device *d, **last;
struct net_device *dev;
unsigned short oflags;
+ unsigned long start;
last = &ic_first_dev;
rtnl_lock();
@@ -205,12 +216,7 @@
}
for_each_netdev(&init_net, dev) {
- if (dev->flags & IFF_LOOPBACK)
- continue;
- if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :
- (!(dev->flags & IFF_LOOPBACK) &&
- (dev->flags & (IFF_POINTOPOINT|IFF_BROADCAST)) &&
- strncmp(dev->name, "dummy", 5))) {
+ if (ic_is_init_dev(dev)) {
int able = 0;
if (dev->mtu >= 364)
able |= IC_BOOTP;
@@ -244,6 +250,17 @@
dev->name, able, d->xid));
}
}
+
+ /* wait for a carrier on at least one device */
+ start = jiffies;
+ while (jiffies - start < msecs_to_jiffies(CONF_CARRIER_TIMEOUT)) {
+ for_each_netdev(&init_net, dev)
+ if (ic_is_init_dev(dev) && netif_carrier_ok(dev))
+ goto have_carrier;
+
+ msleep(1);
+ }
+have_carrier:
rtnl_unlock();
*last = NULL;
@@ -1325,15 +1342,12 @@
#ifdef IPCONFIG_DYNAMIC
try_try_again:
#endif
- /* Give hardware a chance to settle */
- msleep(CONF_PRE_OPEN);
-
/* Setup all network devices */
if (ic_open_devs() < 0)
return -1;
/* Give drivers a chance to settle */
- ssleep(CONF_POST_OPEN);
+ msleep(CONF_POST_OPEN);
/*
* If the config information is insufficient (e.g., our IP address or
^ permalink raw reply
* strange code in cdc-ncm
From: Oliver Neukum @ 2011-05-14 20:58 UTC (permalink / raw)
To: linux-usb-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
Alexey Orishko
Hi,
I was looking at this code:
static void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf)
{
struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
struct usb_driver *driver;
if (ctx == NULL)
return; /* no setup */
driver = driver_of(intf);
usb_set_intfdata(ctx->data, NULL);
usb_set_intfdata(ctx->control, NULL);
usb_set_intfdata(ctx->intf, NULL);
/* release interfaces, if any */
if (ctx->data_claimed) {
usb_driver_release_interface(driver, ctx->data);
ctx->data_claimed = 0;
}
if (ctx->control_claimed) {
usb_driver_release_interface(driver, ctx->control);
ctx->control_claimed = 0;
}
It seems a bit strange to me. If you may or may not have claimed an interface,
how can you unconditionally zero out intfdata?
Regards
Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH] output ipconfig info message as one printk
From: Micha Nelissen @ 2011-05-14 21:45 UTC (permalink / raw)
To: netdev, davem
the "ip-config complete" message with ip address etc is output using
many printks. When using the netconsole, and multiple agents are booting
(and logging their boot) simultaneously, the syslog of the receiving
host gets very messy, as the individual printks are interleaved.
Combining the many printks into one printk improves syslog readability.
Index: atom-linux/net/ipv4/ipconfig.c
===================================================================
--- atom-linux/net/ipv4/ipconfig.c (revision 1493)
+++ atom-linux/net/ipv4/ipconfig.c (revision 1494)
@@ -1363,6 +1363,9 @@
#ifdef IPCONFIG_DYNAMIC
int retries = CONF_OPEN_RETRIES;
#endif
+#ifndef IPCONFIG_SILENT
+ char mtubuf[16];
+#endif
int err;
#ifdef CONFIG_PROC_FS
@@ -1477,19 +1480,17 @@
/*
* Clue in the operator.
*/
- printk("IP-Config: Complete:");
- printk("\n device=%s", ic_dev->name);
- printk(", addr=%pI4", &ic_myaddr);
- printk(", mask=%pI4", &ic_netmask);
- printk(", gw=%pI4", &ic_gateway);
- printk(",\n host=%s, domain=%s, nis-domain=%s",
- utsname()->nodename, ic_domain, utsname()->domainname);
- printk(",\n bootserver=%pI4", &ic_servaddr);
- printk(", rootserver=%pI4", &root_server_addr);
- printk(", rootpath=%s", root_server_path);
if (ic_dev_mtu)
- printk(", mtu=%d", ic_dev_mtu);
- printk("\n");
+ snprintf(mtubuf, sizeof(mtubuf), "mtu=%d, ", ic_dev_mtu);
+ else
+ mtubuf[0] = '\0';
+ printk( "IP-Config: Complete:\n"
+ " device=%s, addr=%pI4, mask=%pI4, gw=%pI4,\n"
+ " %shost=%s, domain=%s, nis-domain=%s,\n"
+ " bootserver=%pI4, rootserver=%pI4, rootpath=%s\n",
+ ic_dev->name, &ic_myaddr, &ic_netmask, &ic_gateway,
+ mtubuf, utsname()->nodename, ic_domain, utsname()->domainname,
+ &ic_servaddr, &root_server_addr, root_server_path);
#endif /* !SILENT */
return 0;
^ 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