* Re: [RFC v3 00/10] snet: Security for NETwork syscalls
From: Samir Bellabes @ 2011-05-03 17:15 UTC (permalink / raw)
To: Casey Schaufler
Cc: linux-security-module, linux-kernel, netdev, netfilter-devel,
jamal, Patrick McHardy, Evgeniy Polyakov, Grzegorz Nosek
In-Reply-To: <4DC0330C.60208@schaufler-ca.com>
Casey Schaufler <casey@schaufler-ca.com> writes:
> On 5/3/2011 7:24 AM, Samir Bellabes wrote:
>> Hello lsm and netdev people,
>> This set of patches is the version 3 of snet, which I would like to submit as a
>> RFC.
>>
>> snet is a linux security module. It provides a mecanism defering syscall
>> security hooks and decision (verdict) to userspace.
>
> As you have submitted this as a Request For Comments I will make one.
>
> I first saw this approach in 1987, on Unix, from a company called
> SecureWare (long completely assimilated into HP). The potential for
> deadlock, where the system prevents the decision making application
> from accessing the information it needs to grant itself access is
> great. The performance impact of making security checks in user
> space is appalling. The exposure for attack, especially regarding
> denial of service, is enormous. I do not recommend this approach.
>
> There are cases where user space access control assistance could
> be appropriate, in particular controls based on the data involved.
> Even those controls must be very carefully crafted to avoid
> impacting the correct function of the system in the unhappily
> likely event of the access control enforcing applications being
> unavailable or incapable of keeping up with demand.
>
As everything may be exposed to denial of service attack..
I have some thoughts. snet is not a tool for securing the kernel code,
there is only one way to do so, it's to fix bug and to add code feature
to protect memory (cf grsecurity). snet is a tool to manage the
behaviour of users and applications, regarding network connections.
the risk of deadlock is uneffective, as every sleeps occurs in process
context, so application can sleep without trouble.
there are 2 ways to go out of sleep :
- receiving the verdict
- timeouting
so deadlock are more "latency".
You win a admin tool, you loose some latency. I'm ok with that, as this
feature as its own public.
and of course, I'm not pretending to add a new idea. I'm sure some
mecanism like this already exist before 1987. I'm just the man who put
the code in order to be discuss on the lists, which was never been done
so far.
there are some request from public distro:
http://brainstorm.ubuntu.com/idea/23333/
^ permalink raw reply
* RE: [PATCH] ipheth.c: Enable IP header alignment
From: David Hill @ 2011-05-03 17:18 UTC (permalink / raw)
To: L. Alberto Giménez, Ben Hutchings
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
dgiagio-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
dborca-/E1597aS9LQAvxtiuMwx3w@public.gmane.org,
davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
pmcenery-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
open list:USB SUBSYSTEM, open list:NETWORKING DRIVERS
In-Reply-To: <20110503165751.GA6566-vFZw08TITM7wxNmfbb4FQRs6BjWItJ1b@public.gmane.org>
Maybe I can help on this part.
Git ?
I'm using ubuntu natty ... The part I'm not sure of is , do I patch ubuntu's kernel or I start from scratch?
-----Original Message-----
From: L. Alberto Giménez [mailto:agimenez-lqZFv/KUvpAxAGwisGp4zA@public.gmane.org]
Sent: 3 mai 2011 12:58
To: Ben Hutchings
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; dgiagio-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dborca-/E1597aS9LQAvxtiuMwx3w@public.gmane.org; davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org; pmcenery-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; David Hill; open list:USB SUBSYSTEM; open list:NETWORKING DRIVERS
Subject: Re: [PATCH] ipheth.c: Enable IP header alignment
On Mon, May 02, 2011 at 10:04:34PM +0100, Ben Hutchings wrote:
> So this was using NET_IP_ALIGN as an offset into the URB. Which was
> totally bogus, as its value has long been architecture-dependent. The
> code is also claiming to put len bytes but only copying len - delta.
>
> The correct code would be something like:
>
> if (urb->actual_length <= IPHETH_IP_ALIGN) {
> dev->net->stats.rx_length_errors++;
> return;
> }
> len = urb->actual_length - IPHETH_IP_ALIGN;
> buf = urb->transfer_buffer + IPHETH_IP_ALIGN;
>
> dev_alloc_skb(len);
> ...
> memcpy(skb_put(skb, len), buf, len);
Thanks for the response Ben.
I can try to change the code, but I don't own the device anymore. Changing the
code without being able to test it would be walking blindfolded :-/
If upstrem (everyone involved is in CC) can't do it, I can submit the changes
advised by Ben, but I can't warantee anything beyond successful compilation. I
don't think that it would be acceptable here.
Regards,
--
L. Alberto Giménez
JabberID agimenez-eu7EghD4TOHJ13y34KW5H97lo5+wdyHW@public.gmane.org
GnuPG key ID 0x3BAABDE1
--
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
* Re: [PATCH] ipheth.c: Enable IP header alignment
From: Paul McEnery @ 2011-05-03 17:33 UTC (permalink / raw)
To: David Hill
Cc: L. Alberto Giménez, Ben Hutchings,
linux-kernel@vger.kernel.org, dgiagio@gmail.com, dborca@yahoo.com,
davem@davemloft.net, open list:USB SUBSYSTEM,
open list:NETWORKING DRIVERS
In-Reply-To: <710D4D6CE160654C87478D18385BB9971BE3FDCA46@MDC-MAIL-CMS01.ubisoft.org>
On 3 May 2011 18:18, David Hill <david.hill@ubisoft.com> wrote:
>
> Maybe I can help on this part.
>
> Git ?
>
> I'm using ubuntu natty ... The part I'm not sure of is , do I patch ubuntu's kernel or I start from scratch?
>
If we can get the patch committed to the Github ipheth repo, I'll
package it in my Ubuntu PPA. You can then simply install ipheth-dkms
which allow it to replace the in-tree module for testing...
I unfortunately cannot test either, since I no longer have an iPhone.
Paul.
^ permalink raw reply
* Re: [PATCH V3 3/8] Add userspace buffers support in skb
From: Shirley Ma @ 2011-05-03 17:36 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: David Miller, Eric Dumazet, Avi Kivity, Arnd Bergmann, netdev,
kvm, linux-kernel
In-Reply-To: <20110502105348.GA21706@redhat.com>
On Mon, 2011-05-02 at 13:53 +0300, Michael S. Tsirkin wrote:
> On Wed, Apr 20, 2011 at 12:47:57PM -0700, Shirley Ma wrote:
> > This patch adds userspace buffers support in skb. A new struct
> > skb_ubuf_info is needed to maintain the userspace buffers argument
> > and index, a callback is used to notify userspace to release the
> > buffers once lower device has done DMA (Last reference to that skb
> > has gone).
> >
> > Signed-off-by: Shirley Ma <xma@us.ibm.com>
> > ---
> >
> > include/linux/skbuff.h | 14 ++++++++++++++
> > net/core/skbuff.c | 15 ++++++++++++++-
> > 2 files changed, 28 insertions(+), 1 deletions(-)
> >
> > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> > index d0ae90a..47a187b 100644
> > --- a/include/linux/skbuff.h
> > +++ b/include/linux/skbuff.h
> > @@ -189,6 +189,16 @@ enum {
> > SKBTX_DRV_NEEDS_SK_REF = 1 << 3,
> > };
> >
> > +/* The callback notifies userspace to release buffers when skb DMA
> is done in
> > + * lower device, the desc is used to track userspace buffer index.
> > + */
> > +struct skb_ubuf_info {
> > + /* support buffers allocation from userspace */
> > + void (*callback)(struct sk_buff *);
> > + void *arg;
> > + size_t desc;
> > +};
> > +
> > /* This data is invariant across clones and lives at
> > * the end of the header data, ie. at skb->end.
> > */
> > @@ -211,6 +221,10 @@ struct skb_shared_info {
> > /* Intermediate layers must ensure that destructor_arg
> > * remains valid until skb destructor */
> > void * destructor_arg;
> > +
> > + /* DMA mapping from/to userspace buffers */
> > + struct skb_ubuf_info ubuf;
> > +
> > /* must be last field, see pskb_expand_head() */
> > skb_frag_t frags[MAX_SKB_FRAGS];
> > };
> > diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> > index 7ebeed0..822c07d 100644
> > --- a/net/core/skbuff.c
> > +++ b/net/core/skbuff.c
> > @@ -210,6 +210,8 @@ struct sk_buff *__alloc_skb(unsigned int size,
> gfp_t gfp_mask,
> > shinfo = skb_shinfo(skb);
> > memset(shinfo, 0, offsetof(struct skb_shared_info, dataref));
> > atomic_set(&shinfo->dataref, 1);
> > + shinfo->ubuf.callback = NULL;
> > + shinfo->ubuf.arg = NULL;
> > kmemcheck_annotate_variable(shinfo->destructor_arg);
> >
> > if (fclone) {
> > @@ -327,7 +329,15 @@ static void skb_release_data(struct sk_buff
> *skb)
> > for (i = 0; i < skb_shinfo(skb)->nr_frags; i
> ++)
> > put_page(skb_shinfo(skb)->frags[i].page);
> > }
> > -
> > + /*
> > + * if skb buf is from userspace, we need to notify the
> caller
> > + * the lower device DMA has done;
> > + */
> > + if (skb_shinfo(skb)->ubuf.callback) {
> > + skb_shinfo(skb)->ubuf.callback(skb);
> > + skb_shinfo(skb)->ubuf.callback = NULL;
> > + skb_shinfo(skb)->ubuf.arg = NULL;
> > + }
> > if (skb_has_frag_list(skb))
> > skb_drop_fraglist(skb);
> >
>
> We probably don't need to touch arg if callback is NULL?
Yes.
> > @@ -480,6 +490,9 @@ bool skb_recycle_check(struct sk_buff *skb, int
> skb_size)
> > if (irqs_disabled())
> > return false;
> >
> > + if (shinfo->ubuf.callback)
> > + return false;
> > +
> > if (skb_is_nonlinear(skb) || skb->fclone !=
> SKB_FCLONE_UNAVAILABLE)
> > return false;
>
> This is not the only API unsupported for these skbs, is it?
> Probably need to check and fail there as well.
Yes, I am going through all these skbs to make sure covering all.
Thanks
Shirley
^ permalink raw reply
* RE: [PATCH] ipheth.c: Enable IP header alignment
From: David Hill @ 2011-05-03 17:41 UTC (permalink / raw)
To: Paul McEnery
Cc: L. Alberto Giménez, Ben Hutchings,
linux-kernel@vger.kernel.org, dgiagio@gmail.com, dborca@yahoo.com,
davem@davemloft.net, open list:USB SUBSYSTEM,
open list:NETWORKING DRIVERS
In-Reply-To: <BANLkTi=W5HTLDa-UEvk4TefP3FyOvphxew@mail.gmail.com>
That's not a problem, I can test it :)
-----Original Message-----
From: Paul McEnery [mailto:pmcenery@gmail.com]
Sent: 3 mai 2011 13:34
To: David Hill
Cc: L. Alberto Giménez; Ben Hutchings; linux-kernel@vger.kernel.org; dgiagio@gmail.com; dborca@yahoo.com; davem@davemloft.net; open list:USB SUBSYSTEM; open list:NETWORKING DRIVERS
Subject: Re: [PATCH] ipheth.c: Enable IP header alignment
On 3 May 2011 18:18, David Hill <david.hill@ubisoft.com> wrote:
>
> Maybe I can help on this part.
>
> Git ?
>
> I'm using ubuntu natty ... The part I'm not sure of is , do I patch ubuntu's kernel or I start from scratch?
>
If we can get the patch committed to the Github ipheth repo, I'll
package it in my Ubuntu PPA. You can then simply install ipheth-dkms
which allow it to replace the in-tree module for testing...
I unfortunately cannot test either, since I no longer have an iPhone.
Paul.
^ permalink raw reply
* Re: [PATCH V3 2/8] Add a new zerocopy device flag
From: Shirley Ma @ 2011-05-03 17:42 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: David Miller, Eric Dumazet, Avi Kivity, Arnd Bergmann, netdev,
kvm, linux-kernel
In-Reply-To: <20110502195302.GA25619@redhat.com>
On Mon, 2011-05-02 at 22:53 +0300, Michael S. Tsirkin wrote:
> On Mon, May 02, 2011 at 11:47:08AM -0700, Shirley Ma wrote:
> > On Mon, 2011-05-02 at 13:42 +0300, Michael S. Tsirkin wrote:
> > > This comment should specify what exactly is the promise the
> > > device makes by setting this flag. Specifically, the
> > > condition is that no skb fragments are used
> > > after the uinfo callback has been called.
> > >
> > > The way it's implemented, it probably means the device
> > > should not use any of skb_clone, expand head etc.
> >
> > Agree. Or maybe force a copy when device uses skb_clone, expand
> > head ...?
> >
> > Thanks
> > Shirley
>
> Copy from userspace upfront without locking is probably cheaper?
Better to prevent this kind of skbs to be used in skb_clone, expand head
for now.
Thanks
Shirley
^ permalink raw reply
* [PATCH net-next-2.6] ipheth: Properly distinguish length and alignment in URBs and skbs
From: Ben Hutchings @ 2011-05-03 17:49 UTC (permalink / raw)
To: David Hill
Cc: L. Alberto Giménez, linux-kernel@vger.kernel.org,
dgiagio@gmail.com, dborca@yahoo.com, davem@davemloft.net,
pmcenery@gmail.com, open list:USB SUBSYSTEM,
open list:NETWORKING DRIVERS
In-Reply-To: <710D4D6CE160654C87478D18385BB9971BE3FDCA46@MDC-MAIL-CMS01.ubisoft.org>
The USB protocol this driver implements appears to require 2 bytes of
padding in front of each received packet. This used to be equal to
the value of NET_IP_ALIGN on x86, so the driver abused that constant
and mostly worked, but this is no longer the case. The driver also
mixed up the URB and packet lengths, resulting in 2 bytes of junk at
the end of the skb.
Introduce a private constant for the 2 bytes of padding; fix this
confusion and check for the under-length case.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
Compile-tested only, as I'm not cool enough for an iPhone either.
This is applicable to net-next-2.6 or v2.6.38.
Ben.
drivers/net/usb/ipheth.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c
index 7d42f9a..81126ff 100644
--- a/drivers/net/usb/ipheth.c
+++ b/drivers/net/usb/ipheth.c
@@ -65,6 +65,7 @@
#define IPHETH_USBINTF_PROTO 1
#define IPHETH_BUF_SIZE 1516
+#define IPHETH_IP_ALIGN 2 /* padding at front of URB */
#define IPHETH_TX_TIMEOUT (5 * HZ)
#define IPHETH_INTFNUM 2
@@ -202,18 +203,21 @@ static void ipheth_rcvbulk_callback(struct urb *urb)
return;
}
- len = urb->actual_length;
- buf = urb->transfer_buffer;
+ if (urb->actual_length <= IPHETH_IP_ALIGN) {
+ dev->net->stats.rx_length_errors++;
+ return;
+ }
+ len = urb->actual_length - IPHETH_IP_ALIGN;
+ buf = urb->transfer_buffer + IPHETH_IP_ALIGN;
- skb = dev_alloc_skb(NET_IP_ALIGN + len);
+ skb = dev_alloc_skb(len);
if (!skb) {
err("%s: dev_alloc_skb: -ENOMEM", __func__);
dev->net->stats.rx_dropped++;
return;
}
- skb_reserve(skb, NET_IP_ALIGN);
- memcpy(skb_put(skb, len), buf + NET_IP_ALIGN, len - NET_IP_ALIGN);
+ memcpy(skb_put(skb, len), buf, len);
skb->dev = dev->net;
skb->protocol = eth_type_trans(skb, dev->net);
--
1.7.4
--
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related
* [PATCH 0/2] usbnet: style cleaning and logging
From: Joe Perches @ 2011-05-03 18:17 UTC (permalink / raw)
To: Oliver Neukum, netdev, linux-usb; +Cc: linux-kernel
Just a spring cleaning for the new maintainer to deal with...
Joe Perches (2):
usbnet: Style cleanups
usbnet: Convert dbg to dev_dbg and neatening.
drivers/net/usb/usbnet.c | 638 +++++++++++++++++++++++-----------------------
1 files changed, 325 insertions(+), 313 deletions(-)
--
1.7.5.rc3.dirty
^ permalink raw reply
* [PATCH 1/2] usbnet: Style cleanups
From: Joe Perches @ 2011-05-03 18:17 UTC (permalink / raw)
To: Oliver Neukum, David Brownell, Greg Kroah-Hartman
Cc: netdev, linux-usb, linux-kernel
In-Reply-To: <cover.1304445019.git.joe@perches.com>
Just general neatening.
Remove spaces before function open parentheses.
Add spaces around sizeof uses.
Convert c99 comments to /* */
Hoist assigns from if where appropriate.
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/net/usb/usbnet.c | 625 +++++++++++++++++++++++----------------------
1 files changed, 319 insertions(+), 306 deletions(-)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 7bc9852..28aecbb 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -30,8 +30,8 @@
* issues can usefully be addressed by this framework.
*/
-// #define DEBUG // error path messages, extra info
-// #define VERBOSE // more; success messages
+/* #define DEBUG // error path messages, extra info */
+/* #define VERBOSE // more; success messages */
#include <linux/module.h>
#include <linux/init.h>
@@ -64,32 +64,31 @@
* is required, under load. Jumbograms change the equation.
*/
#define RX_MAX_QUEUE_MEMORY (60 * 1518)
-#define RX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? \
- (RX_MAX_QUEUE_MEMORY/(dev)->rx_urb_size) : 4)
-#define TX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? \
- (RX_MAX_QUEUE_MEMORY/(dev)->hard_mtu) : 4)
+#define RX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? \
+ (RX_MAX_QUEUE_MEMORY/(dev)->rx_urb_size) : 4)
+#define TX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? \
+ (RX_MAX_QUEUE_MEMORY/(dev)->hard_mtu) : 4)
-// reawaken network queue this soon after stopping; else watchdog barks
+/* reawaken network queue this soon after stopping; else watchdog barks */
#define TX_TIMEOUT_JIFFIES (5*HZ)
-// throttle rx/tx briefly after some faults, so khubd might disconnect()
-// us (it polls at HZ/4 usually) before we report too many false errors.
+/* throttle rx/tx briefly after some faults, so khubd might disconnect()
+ * us (it polls at HZ/4 usually) before we report too many false errors.
+ */
#define THROTTLE_JIFFIES (HZ/8)
-// between wakeups
-#define UNLINK_TIMEOUT_MS 3
+#define UNLINK_TIMEOUT_MS 3 /* between wakeups */
/*-------------------------------------------------------------------------*/
-// randomly generated ethernet address
-static u8 node_id [ETH_ALEN];
+static u8 node_id[ETH_ALEN]; /* randomly generated ethernet address */
-static const char driver_name [] = "usbnet";
+static const char driver_name[] = "usbnet";
/* use ethtool to change the level for any given device */
static int msg_level = -1;
-module_param (msg_level, int, 0);
-MODULE_PARM_DESC (msg_level, "Override default message level");
+module_param(msg_level, int, 0);
+MODULE_PARM_DESC(msg_level, "Override default message level");
/*-------------------------------------------------------------------------*/
@@ -145,15 +144,15 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
if (alt->desc.bAlternateSetting != 0 ||
!(dev->driver_info->flags & FLAG_NO_SETINT)) {
- tmp = usb_set_interface (dev->udev, alt->desc.bInterfaceNumber,
- alt->desc.bAlternateSetting);
+ tmp = usb_set_interface(dev->udev, alt->desc.bInterfaceNumber,
+ alt->desc.bAlternateSetting);
if (tmp < 0)
return tmp;
}
- dev->in = usb_rcvbulkpipe (dev->udev,
+ dev->in = usb_rcvbulkpipe(dev->udev,
in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
- dev->out = usb_sndbulkpipe (dev->udev,
+ dev->out = usb_sndbulkpipe(dev->udev,
out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
dev->status = status;
return 0;
@@ -162,27 +161,27 @@ EXPORT_SYMBOL_GPL(usbnet_get_endpoints);
int usbnet_get_ethernet_addr(struct usbnet *dev, int iMACAddress)
{
- int tmp, i;
- unsigned char buf [13];
+ int tmp, i;
+ unsigned char buf[13];
- tmp = usb_string(dev->udev, iMACAddress, buf, sizeof buf);
+ tmp = usb_string(dev->udev, iMACAddress, buf, sizeof(buf));
if (tmp != 12) {
- dev_dbg(&dev->udev->dev,
- "bad MAC string %d fetch, %d\n", iMACAddress, tmp);
+ dev_dbg(&dev->udev->dev, "bad MAC string %d fetch, %d\n",
+ iMACAddress, tmp);
if (tmp >= 0)
tmp = -EINVAL;
return tmp;
}
for (i = tmp = 0; i < 6; i++, tmp += 2)
- dev->net->dev_addr [i] =
+ dev->net->dev_addr[i] =
(hex_to_bin(buf[tmp]) << 4) + hex_to_bin(buf[tmp + 1]);
return 0;
}
EXPORT_SYMBOL_GPL(usbnet_get_ethernet_addr);
-static void intr_complete (struct urb *urb);
+static void intr_complete(struct urb *urb);
-static int init_status (struct usbnet *dev, struct usb_interface *intf)
+static int init_status(struct usbnet *dev, struct usb_interface *intf)
{
char *buf = NULL;
unsigned pipe = 0;
@@ -192,24 +191,24 @@ static int init_status (struct usbnet *dev, struct usb_interface *intf)
if (!dev->driver_info->status)
return 0;
- pipe = usb_rcvintpipe (dev->udev,
- dev->status->desc.bEndpointAddress
- & USB_ENDPOINT_NUMBER_MASK);
- maxp = usb_maxpacket (dev->udev, pipe, 0);
+ pipe = usb_rcvintpipe(dev->udev,
+ dev->status->desc.bEndpointAddress
+ & USB_ENDPOINT_NUMBER_MASK);
+ maxp = usb_maxpacket(dev->udev, pipe, 0);
/* avoid 1 msec chatter: min 8 msec poll rate */
- period = max ((int) dev->status->desc.bInterval,
- (dev->udev->speed == USB_SPEED_HIGH) ? 7 : 3);
+ period = max((int)dev->status->desc.bInterval,
+ (dev->udev->speed == USB_SPEED_HIGH) ? 7 : 3);
- buf = kmalloc (maxp, GFP_KERNEL);
+ buf = kmalloc(maxp, GFP_KERNEL);
if (buf) {
- dev->interrupt = usb_alloc_urb (0, GFP_KERNEL);
+ dev->interrupt = usb_alloc_urb(0, GFP_KERNEL);
if (!dev->interrupt) {
- kfree (buf);
+ kfree(buf);
return -ENOMEM;
} else {
usb_fill_int_urb(dev->interrupt, dev->udev, pipe,
- buf, maxp, intr_complete, dev, period);
+ buf, maxp, intr_complete, dev, period);
dev_dbg(&intf->dev,
"status ep%din, %d bytes period %d\n",
usb_pipeendpoint(pipe), maxp, period);
@@ -222,7 +221,7 @@ static int init_status (struct usbnet *dev, struct usb_interface *intf)
* Some link protocols batch packets, so their rx_fixup paths
* can return clones as well as just modify the original skb.
*/
-void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb)
+void usbnet_skb_return(struct usbnet *dev, struct sk_buff *skb)
{
int status;
@@ -231,28 +230,27 @@ void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb)
return;
}
- skb->protocol = eth_type_trans (skb, dev->net);
+ skb->protocol = eth_type_trans(skb, dev->net);
dev->net->stats.rx_packets++;
dev->net->stats.rx_bytes += skb->len;
netif_dbg(dev, rx_status, dev->net, "< rx, len %zu, type 0x%x\n",
- skb->len + sizeof (struct ethhdr), skb->protocol);
- memset (skb->cb, 0, sizeof (struct skb_data));
- status = netif_rx (skb);
+ skb->len + sizeof(struct ethhdr), skb->protocol);
+ memset(skb->cb, 0, sizeof(struct skb_data));
+ status = netif_rx(skb);
if (status != NET_RX_SUCCESS)
netif_dbg(dev, rx_err, dev->net,
"netif_rx status %d\n", status);
}
EXPORT_SYMBOL_GPL(usbnet_skb_return);
-\f
/*-------------------------------------------------------------------------
*
* Network Device Driver (peer link to "Host Device", from USB host)
*
*-------------------------------------------------------------------------*/
-int usbnet_change_mtu (struct net_device *net, int new_mtu)
+int usbnet_change_mtu(struct net_device *net, int new_mtu)
{
struct usbnet *dev = netdev_priv(net);
int ll_mtu = new_mtu + net->hard_header_len;
@@ -261,7 +259,7 @@ int usbnet_change_mtu (struct net_device *net, int new_mtu)
if (new_mtu <= 0)
return -EINVAL;
- // no second zero-length packet read wanted after mtu-sized packets
+ /* no second zero-length packet read wanted after mtu-sized packets */
if ((ll_mtu % dev->maxpacket) == 0)
return -EDOM;
net->mtu = new_mtu;
@@ -283,7 +281,8 @@ EXPORT_SYMBOL_GPL(usbnet_change_mtu);
* completion callbacks. 2.5 should have fixed those bugs...
*/
-static void defer_bh(struct usbnet *dev, struct sk_buff *skb, struct sk_buff_head *list)
+static void
+defer_bh(struct usbnet *dev, struct sk_buff *skb, struct sk_buff_head *list)
{
unsigned long flags;
@@ -302,10 +301,10 @@ static void defer_bh(struct usbnet *dev, struct sk_buff *skb, struct sk_buff_hea
* NOTE: annoying asymmetry: if it's active, schedule_work() fails,
* but tasklet_schedule() doesn't. hope the failure is rare.
*/
-void usbnet_defer_kevent (struct usbnet *dev, int work)
+void usbnet_defer_kevent(struct usbnet *dev, int work)
{
- set_bit (work, &dev->flags);
- if (!schedule_work (&dev->kevent))
+ set_bit(work, &dev->flags);
+ if (!schedule_work(&dev->kevent))
netdev_err(dev->net, "kevent %d may have been dropped\n", work);
else
netdev_dbg(dev->net, "kevent %d scheduled\n", work);
@@ -314,9 +313,9 @@ EXPORT_SYMBOL_GPL(usbnet_defer_kevent);
/*-------------------------------------------------------------------------*/
-static void rx_complete (struct urb *urb);
+static void rx_complete(struct urb *urb);
-static int rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
+static int rx_submit(struct usbnet *dev, struct urb *urb, gfp_t flags)
{
struct sk_buff *skb;
struct skb_data *entry;
@@ -324,39 +323,40 @@ static int rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
unsigned long lockflags;
size_t size = dev->rx_urb_size;
- if ((skb = alloc_skb (size + NET_IP_ALIGN, flags)) == NULL) {
+ skb = alloc_skb(size + NET_IP_ALIGN, flags);
+ if (!skb) {
netif_dbg(dev, rx_err, dev->net, "no rx skb\n");
- usbnet_defer_kevent (dev, EVENT_RX_MEMORY);
- usb_free_urb (urb);
+ usbnet_defer_kevent(dev, EVENT_RX_MEMORY);
+ usb_free_urb(urb);
return -ENOMEM;
}
- skb_reserve (skb, NET_IP_ALIGN);
+ skb_reserve(skb, NET_IP_ALIGN);
- entry = (struct skb_data *) skb->cb;
+ entry = (struct skb_data *)skb->cb;
entry->urb = urb;
entry->dev = dev;
entry->state = rx_start;
entry->length = 0;
- usb_fill_bulk_urb (urb, dev->udev, dev->in,
- skb->data, size, rx_complete, skb);
+ usb_fill_bulk_urb(urb, dev->udev, dev->in,
+ skb->data, size, rx_complete, skb);
- spin_lock_irqsave (&dev->rxq.lock, lockflags);
+ spin_lock_irqsave(&dev->rxq.lock, lockflags);
- if (netif_running (dev->net) &&
- netif_device_present (dev->net) &&
- !test_bit (EVENT_RX_HALT, &dev->flags) &&
- !test_bit (EVENT_DEV_ASLEEP, &dev->flags)) {
- switch (retval = usb_submit_urb (urb, GFP_ATOMIC)) {
+ if (netif_running(dev->net) &&
+ netif_device_present(dev->net) &&
+ !test_bit(EVENT_RX_HALT, &dev->flags) &&
+ !test_bit(EVENT_DEV_ASLEEP, &dev->flags)) {
+ switch (retval = usb_submit_urb(urb, GFP_ATOMIC)) {
case -EPIPE:
- usbnet_defer_kevent (dev, EVENT_RX_HALT);
+ usbnet_defer_kevent(dev, EVENT_RX_HALT);
break;
case -ENOMEM:
- usbnet_defer_kevent (dev, EVENT_RX_MEMORY);
+ usbnet_defer_kevent(dev, EVENT_RX_MEMORY);
break;
case -ENODEV:
netif_dbg(dev, ifdown, dev->net, "device gone\n");
- netif_device_detach (dev->net);
+ netif_device_detach(dev->net);
break;
case -EHOSTUNREACH:
retval = -ENOLINK;
@@ -364,19 +364,19 @@ static int rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
default:
netif_dbg(dev, rx_err, dev->net,
"rx submit, %d\n", retval);
- tasklet_schedule (&dev->bh);
+ tasklet_schedule(&dev->bh);
break;
case 0:
- __skb_queue_tail (&dev->rxq, skb);
+ __skb_queue_tail(&dev->rxq, skb);
}
} else {
netif_dbg(dev, ifdown, dev->net, "rx: stopped\n");
retval = -ENOLINK;
}
- spin_unlock_irqrestore (&dev->rxq.lock, lockflags);
+ spin_unlock_irqrestore(&dev->rxq.lock, lockflags);
if (retval) {
- dev_kfree_skb_any (skb);
- usb_free_urb (urb);
+ dev_kfree_skb_any(skb);
+ usb_free_urb(urb);
}
return retval;
}
@@ -384,16 +384,16 @@ static int rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
/*-------------------------------------------------------------------------*/
-static inline void rx_process (struct usbnet *dev, struct sk_buff *skb)
+static inline void rx_process(struct usbnet *dev, struct sk_buff *skb)
{
if (dev->driver_info->rx_fixup &&
- !dev->driver_info->rx_fixup (dev, skb)) {
+ !dev->driver_info->rx_fixup(dev, skb)) {
/* With RX_ASSEMBLE, rx_fixup() must update counters */
if (!(dev->driver_info->flags & FLAG_RX_ASSEMBLE))
dev->net->stats.rx_errors++;
goto done;
}
- // else network stack removes extra byte if we forced a short packet
+ /* else network stack removes extra byte if we forced a short packet */
if (skb->len) {
/* all data was already cloned from skb inside the driver */
@@ -412,19 +412,19 @@ done:
/*-------------------------------------------------------------------------*/
-static void rx_complete (struct urb *urb)
+static void rx_complete(struct urb *urb)
{
- struct sk_buff *skb = (struct sk_buff *) urb->context;
- struct skb_data *entry = (struct skb_data *) skb->cb;
+ struct sk_buff *skb = (struct sk_buff *)urb->context;
+ struct skb_data *entry = (struct skb_data *)skb->cb;
struct usbnet *dev = entry->dev;
int urb_status = urb->status;
- skb_put (skb, urb->actual_length);
+ skb_put(skb, urb->actual_length);
entry->state = rx_done;
entry->urb = NULL;
switch (urb_status) {
- /* success */
+ /* success */
case 0:
if (skb->len < dev->net->hard_header_len) {
entry->state = rx_cleanup;
@@ -435,33 +435,34 @@ static void rx_complete (struct urb *urb)
}
break;
- /* stalls need manual reset. this is rare ... except that
- * when going through USB 2.0 TTs, unplug appears this way.
- * we avoid the highspeed version of the ETIMEDOUT/EILSEQ
- * storm, recovering as needed.
- */
+ /* stalls need manual reset. this is rare ... except that
+ * when going through USB 2.0 TTs, unplug appears this way.
+ * we avoid the highspeed version of the ETIMEDOUT/EILSEQ
+ * storm, recovering as needed.
+ */
case -EPIPE:
dev->net->stats.rx_errors++;
- usbnet_defer_kevent (dev, EVENT_RX_HALT);
- // FALLTHROUGH
+ usbnet_defer_kevent(dev, EVENT_RX_HALT);
+ /* FALLTHROUGH */
- /* software-driven interface shutdown */
+ /* software-driven interface shutdown */
case -ECONNRESET: /* async unlink */
case -ESHUTDOWN: /* hardware gone */
netif_dbg(dev, ifdown, dev->net,
"rx shutdown, code %d\n", urb_status);
goto block;
- /* we get controller i/o faults during khubd disconnect() delays.
- * throttle down resubmits, to avoid log floods; just temporarily,
- * so we still recover when the fault isn't a khubd delay.
- */
+ /* we get controller i/o faults during khubd disconnect()
+ * delays. Throttle down resubmits, to avoid log floods;
+ * just temporarily, so we still recover when the fault
+ * isn't a khubd delay.
+ */
case -EPROTO:
case -ETIME:
case -EILSEQ:
dev->net->stats.rx_errors++;
- if (!timer_pending (&dev->delay)) {
- mod_timer (&dev->delay, jiffies + THROTTLE_JIFFIES);
+ if (!timer_pending(&dev->delay)) {
+ mod_timer(&dev->delay, jiffies + THROTTLE_JIFFIES);
netif_dbg(dev, link, dev->net,
"rx throttle %d\n", urb_status);
}
@@ -471,10 +472,10 @@ block:
urb = NULL;
break;
- /* data overrun ... flush fifo? */
+ /* data overrun ... flush fifo? */
case -EOVERFLOW:
dev->net->stats.rx_over_errors++;
- // FALLTHROUGH
+ /* FALLTHROUGH */
default:
entry->state = rx_cleanup;
@@ -486,47 +487,47 @@ block:
defer_bh(dev, skb, &dev->rxq);
if (urb) {
- if (netif_running (dev->net) &&
- !test_bit (EVENT_RX_HALT, &dev->flags)) {
- rx_submit (dev, urb, GFP_ATOMIC);
+ if (netif_running(dev->net) &&
+ !test_bit(EVENT_RX_HALT, &dev->flags)) {
+ rx_submit(dev, urb, GFP_ATOMIC);
return;
}
- usb_free_urb (urb);
+ usb_free_urb(urb);
}
netif_dbg(dev, rx_err, dev->net, "no read resubmitted\n");
}
-static void intr_complete (struct urb *urb)
+static void intr_complete(struct urb *urb)
{
struct usbnet *dev = urb->context;
int status = urb->status;
switch (status) {
- /* success */
+ /* success */
case 0:
dev->driver_info->status(dev, urb);
break;
- /* software-driven interface shutdown */
+ /* software-driven interface shutdown */
case -ENOENT: /* urb killed */
case -ESHUTDOWN: /* hardware gone */
netif_dbg(dev, ifdown, dev->net,
"intr shutdown, code %d\n", status);
return;
- /* NOTE: not throttling like RX/TX, since this endpoint
- * already polls infrequently
- */
+ /* NOTE: not throttling like RX/TX, since this endpoint
+ * already polls infrequently
+ */
default:
netdev_dbg(dev->net, "intr status %d\n", status);
break;
}
- if (!netif_running (dev->net))
+ if (!netif_running(dev->net))
return;
memset(urb->transfer_buffer, 0, urb->transfer_buffer_length);
- status = usb_submit_urb (urb, GFP_ATOMIC);
+ status = usb_submit_urb(urb, GFP_ATOMIC);
if (status != 0)
netif_err(dev, timer, dev->net,
"intr resubmit --> %d\n", status);
@@ -568,15 +569,15 @@ EXPORT_SYMBOL_GPL(usbnet_purge_paused_rxq);
/*-------------------------------------------------------------------------*/
-// unlink pending rx/tx; completion handlers do all other cleanup
+/* unlink pending rx/tx; completion handlers do all other cleanup */
-static int unlink_urbs (struct usbnet *dev, struct sk_buff_head *q)
+static int unlink_urbs(struct usbnet *dev, struct sk_buff_head *q)
{
unsigned long flags;
struct sk_buff *skb, *skbnext;
int count = 0;
- spin_lock_irqsave (&q->lock, flags);
+ spin_lock_irqsave(&q->lock, flags);
skb_queue_walk_safe(q, skb, skbnext) {
struct skb_data *entry;
struct urb *urb;
@@ -585,25 +586,27 @@ static int unlink_urbs (struct usbnet *dev, struct sk_buff_head *q)
entry = (struct skb_data *) skb->cb;
urb = entry->urb;
- // during some PM-driven resume scenarios,
- // these (async) unlinks complete immediately
- retval = usb_unlink_urb (urb);
+ /* during some PM-driven resume scenarios,
+ * these (async) unlinks complete immediately
+ */
+ retval = usb_unlink_urb(urb);
if (retval != -EINPROGRESS && retval != 0)
netdev_dbg(dev->net, "unlink urb err, %d\n", retval);
else
count++;
}
- spin_unlock_irqrestore (&q->lock, flags);
+ spin_unlock_irqrestore(&q->lock, flags);
return count;
}
-// Flush all pending rx urbs
-// minidrivers may need to do this when the MTU changes
+/* Flush all pending rx urbs
+ * minidrivers may need to do this when the MTU changes
+ */
void usbnet_unlink_rx_urbs(struct usbnet *dev)
{
if (netif_running(dev->net)) {
- (void) unlink_urbs (dev, &dev->rxq);
+ (void)unlink_urbs(dev, &dev->rxq);
tasklet_schedule(&dev->bh);
}
}
@@ -611,7 +614,7 @@ EXPORT_SYMBOL_GPL(usbnet_unlink_rx_urbs);
/*-------------------------------------------------------------------------*/
-// precondition: never called in_interrupt
+/* precondition: never called in_interrupt */
static void usbnet_terminate_urbs(struct usbnet *dev)
{
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(unlink_wakeup);
@@ -622,30 +625,29 @@ static void usbnet_terminate_urbs(struct usbnet *dev)
add_wait_queue(&unlink_wakeup, &wait);
set_current_state(TASK_UNINTERRUPTIBLE);
dev->wait = &unlink_wakeup;
- temp = unlink_urbs(dev, &dev->txq) +
- unlink_urbs(dev, &dev->rxq);
+ temp = unlink_urbs(dev, &dev->txq) + unlink_urbs(dev, &dev->rxq);
/* maybe wait for deletions to finish. */
- while (!skb_queue_empty(&dev->rxq)
- && !skb_queue_empty(&dev->txq)
- && !skb_queue_empty(&dev->done)) {
- schedule_timeout(msecs_to_jiffies(UNLINK_TIMEOUT_MS));
- set_current_state(TASK_UNINTERRUPTIBLE);
- netif_dbg(dev, ifdown, dev->net,
- "waited for %d urb completions\n", temp);
+ while (!skb_queue_empty(&dev->rxq) &&
+ !skb_queue_empty(&dev->txq) &&
+ !skb_queue_empty(&dev->done)) {
+ schedule_timeout(msecs_to_jiffies(UNLINK_TIMEOUT_MS));
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ netif_dbg(dev, ifdown, dev->net,
+ "waited for %d urb completions\n", temp);
}
set_current_state(TASK_RUNNING);
dev->wait = NULL;
remove_wait_queue(&unlink_wakeup, &wait);
}
-int usbnet_stop (struct net_device *net)
+int usbnet_stop(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
struct driver_info *info = dev->driver_info;
int retval;
- netif_stop_queue (net);
+ netif_stop_queue(net);
netif_info(dev, ifdown, dev->net,
"stop stats: rx/tx %lu/%lu, errs %lu/%lu\n",
@@ -676,8 +678,8 @@ int usbnet_stop (struct net_device *net)
* else workers could deadlock; so make workers a NOP.
*/
dev->flags = 0;
- del_timer_sync (&dev->delay);
- tasklet_kill (&dev->bh);
+ del_timer_sync(&dev->delay);
+ tasklet_kill(&dev->bh);
if (info->manage_power)
info->manage_power(dev, 0);
else
@@ -689,17 +691,18 @@ EXPORT_SYMBOL_GPL(usbnet_stop);
/*-------------------------------------------------------------------------*/
-// posts reads, and enables write queuing
-
-// precondition: never called in_interrupt
+/* posts reads, and enables write queuing
+ * precondition: never called in_interrupt
+ */
-int usbnet_open (struct net_device *net)
+int usbnet_open(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
int retval;
struct driver_info *info = dev->driver_info;
- if ((retval = usb_autopm_get_interface(dev->intf)) < 0) {
+ retval = usb_autopm_get_interface(dev->intf);
+ if (retval < 0) {
netif_info(dev, ifup, dev->net,
"resumption fail (%d) usbnet usb-%s-%s, %s\n",
retval,
@@ -709,8 +712,8 @@ int usbnet_open (struct net_device *net)
goto done_nopm;
}
- // put into "known safe" state
- if (info->reset && (retval = info->reset (dev)) < 0) {
+ /* put into "known safe" state */
+ if (info->reset && (retval = info->reset(dev)) < 0) {
netif_info(dev, ifup, dev->net,
"open reset fail (%d) usbnet usb-%s-%s, %s\n",
retval,
@@ -720,15 +723,15 @@ int usbnet_open (struct net_device *net)
goto done;
}
- // insist peer be connected
- if (info->check_connect && (retval = info->check_connect (dev)) < 0) {
+ /* insist peer be connected */
+ if (info->check_connect && (retval = info->check_connect(dev)) < 0) {
netif_dbg(dev, ifup, dev->net, "can't open; %d\n", retval);
goto done;
}
/* start any status interrupt transfer */
if (dev->interrupt) {
- retval = usb_submit_urb (dev->interrupt, GFP_KERNEL);
+ retval = usb_submit_urb(dev->interrupt, GFP_KERNEL);
if (retval < 0) {
netif_err(dev, ifup, dev->net,
"intr submit %d\n", retval);
@@ -736,7 +739,7 @@ int usbnet_open (struct net_device *net)
}
}
- netif_start_queue (net);
+ netif_start_queue(net);
netif_info(dev, ifup, dev->net,
"open: enable queueing (rx %d, tx %d) mtu %d %s framing\n",
(int)RX_QLEN(dev), (int)TX_QLEN(dev),
@@ -748,8 +751,8 @@ int usbnet_open (struct net_device *net)
(dev->driver_info->flags & FLAG_FRAMING_AX) ? "ASIX" :
"simple");
- // delay posting reads until we're fully open
- tasklet_schedule (&dev->bh);
+ /* delay posting reads until we're fully open */
+ tasklet_schedule(&dev->bh);
if (info->manage_power) {
retval = info->manage_power(dev, 1);
if (retval < 0)
@@ -771,7 +774,7 @@ EXPORT_SYMBOL_GPL(usbnet_open);
* they'll probably want to use this base set.
*/
-int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd)
+int usbnet_get_settings(struct net_device *net, struct ethtool_cmd *cmd)
{
struct usbnet *dev = netdev_priv(net);
@@ -782,7 +785,7 @@ int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd)
}
EXPORT_SYMBOL_GPL(usbnet_get_settings);
-int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd)
+int usbnet_set_settings(struct net_device *net, struct ethtool_cmd *cmd)
{
struct usbnet *dev = netdev_priv(net);
int retval;
@@ -801,13 +804,13 @@ int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd)
}
EXPORT_SYMBOL_GPL(usbnet_set_settings);
-u32 usbnet_get_link (struct net_device *net)
+u32 usbnet_get_link(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
/* If a check_connect is defined, return its result */
if (dev->driver_info->check_connect)
- return dev->driver_info->check_connect (dev) == 0;
+ return dev->driver_info->check_connect(dev) == 0;
/* if the device has mii operations, use those */
if (dev->mii.mdio_read)
@@ -829,19 +832,19 @@ int usbnet_nway_reset(struct net_device *net)
}
EXPORT_SYMBOL_GPL(usbnet_nway_reset);
-void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info)
+void usbnet_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info)
{
struct usbnet *dev = netdev_priv(net);
- strncpy (info->driver, dev->driver_name, sizeof info->driver);
- strncpy (info->version, DRIVER_VERSION, sizeof info->version);
- strncpy (info->fw_version, dev->driver_info->description,
- sizeof info->fw_version);
- usb_make_path (dev->udev, info->bus_info, sizeof info->bus_info);
+ strncpy(info->driver, dev->driver_name, sizeof(info->driver));
+ strncpy(info->version, DRIVER_VERSION, sizeof(info->version));
+ strncpy(info->fw_version, dev->driver_info->description,
+ sizeof(info->fw_version));
+ usb_make_path(dev->udev, info->bus_info, sizeof(info->bus_info));
}
EXPORT_SYMBOL_GPL(usbnet_get_drvinfo);
-u32 usbnet_get_msglevel (struct net_device *net)
+u32 usbnet_get_msglevel(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
@@ -849,7 +852,7 @@ u32 usbnet_get_msglevel (struct net_device *net)
}
EXPORT_SYMBOL_GPL(usbnet_get_msglevel);
-void usbnet_set_msglevel (struct net_device *net, u32 level)
+void usbnet_set_msglevel(struct net_device *net, u32 level)
{
struct usbnet *dev = netdev_priv(net);
@@ -876,90 +879,92 @@ static const struct ethtool_ops usbnet_ethtool_ops = {
* especially now that control transfers can be queued.
*/
static void
-kevent (struct work_struct *work)
+kevent(struct work_struct *work)
{
- struct usbnet *dev =
- container_of(work, struct usbnet, kevent);
- int status;
+ struct usbnet *dev = container_of(work, struct usbnet, kevent);
+ int status;
/* usb_clear_halt() needs a thread context */
- if (test_bit (EVENT_TX_HALT, &dev->flags)) {
- unlink_urbs (dev, &dev->txq);
+ if (test_bit(EVENT_TX_HALT, &dev->flags)) {
+ unlink_urbs(dev, &dev->txq);
status = usb_autopm_get_interface(dev->intf);
if (status < 0)
goto fail_pipe;
- status = usb_clear_halt (dev->udev, dev->out);
+ status = usb_clear_halt(dev->udev, dev->out);
usb_autopm_put_interface(dev->intf);
if (status < 0 &&
status != -EPIPE &&
status != -ESHUTDOWN) {
- if (netif_msg_tx_err (dev))
+ if (netif_msg_tx_err(dev))
fail_pipe:
- netdev_err(dev->net, "can't clear tx halt, status %d\n",
+ netdev_err(dev->net,
+ "can't clear tx halt, status %d\n",
status);
} else {
- clear_bit (EVENT_TX_HALT, &dev->flags);
+ clear_bit(EVENT_TX_HALT, &dev->flags);
if (status != -ESHUTDOWN)
- netif_wake_queue (dev->net);
+ netif_wake_queue(dev->net);
}
}
- if (test_bit (EVENT_RX_HALT, &dev->flags)) {
- unlink_urbs (dev, &dev->rxq);
+ if (test_bit(EVENT_RX_HALT, &dev->flags)) {
+ unlink_urbs(dev, &dev->rxq);
status = usb_autopm_get_interface(dev->intf);
if (status < 0)
goto fail_halt;
- status = usb_clear_halt (dev->udev, dev->in);
+ status = usb_clear_halt(dev->udev, dev->in);
usb_autopm_put_interface(dev->intf);
if (status < 0 &&
status != -EPIPE &&
status != -ESHUTDOWN) {
- if (netif_msg_rx_err (dev))
+ if (netif_msg_rx_err(dev))
fail_halt:
- netdev_err(dev->net, "can't clear rx halt, status %d\n",
+ netdev_err(dev->net,
+ "can't clear rx halt, status %d\n",
status);
} else {
- clear_bit (EVENT_RX_HALT, &dev->flags);
- tasklet_schedule (&dev->bh);
+ clear_bit(EVENT_RX_HALT, &dev->flags);
+ tasklet_schedule(&dev->bh);
}
}
/* tasklet could resubmit itself forever if memory is tight */
- if (test_bit (EVENT_RX_MEMORY, &dev->flags)) {
+ if (test_bit(EVENT_RX_MEMORY, &dev->flags)) {
struct urb *urb = NULL;
int resched = 1;
- if (netif_running (dev->net))
- urb = usb_alloc_urb (0, GFP_KERNEL);
+ if (netif_running(dev->net))
+ urb = usb_alloc_urb(0, GFP_KERNEL);
else
- clear_bit (EVENT_RX_MEMORY, &dev->flags);
+ clear_bit(EVENT_RX_MEMORY, &dev->flags);
if (urb != NULL) {
- clear_bit (EVENT_RX_MEMORY, &dev->flags);
+ clear_bit(EVENT_RX_MEMORY, &dev->flags);
status = usb_autopm_get_interface(dev->intf);
if (status < 0) {
usb_free_urb(urb);
goto fail_lowmem;
}
- if (rx_submit (dev, urb, GFP_KERNEL) == -ENOLINK)
+ if (rx_submit(dev, urb, GFP_KERNEL) == -ENOLINK)
resched = 0;
usb_autopm_put_interface(dev->intf);
fail_lowmem:
if (resched)
- tasklet_schedule (&dev->bh);
+ tasklet_schedule(&dev->bh);
}
}
- if (test_bit (EVENT_LINK_RESET, &dev->flags)) {
+ if (test_bit(EVENT_LINK_RESET, &dev->flags)) {
struct driver_info *info = dev->driver_info;
int retval = 0;
- clear_bit (EVENT_LINK_RESET, &dev->flags);
+ clear_bit(EVENT_LINK_RESET, &dev->flags);
status = usb_autopm_get_interface(dev->intf);
if (status < 0)
goto skip_reset;
- if(info->link_reset && (retval = info->link_reset(dev)) < 0) {
+ if (info->link_reset && (retval = info->link_reset(dev)) < 0) {
usb_autopm_put_interface(dev->intf);
skip_reset:
- netdev_info(dev->net, "link reset failed (%d) usbnet usb-%s-%s, %s\n",
+ netdev_info(dev->net,
+ "link reset failed (%d) usbnet usb-%s-%s, %s\n",
retval,
dev->udev->bus->bus_name,
dev->udev->devpath,
@@ -970,15 +975,16 @@ skip_reset:
}
if (dev->flags)
- netdev_dbg(dev->net, "kevent done, flags = 0x%lx\n", dev->flags);
+ netdev_dbg(dev->net, "kevent done, flags = 0x%lx\n",
+ dev->flags);
}
/*-------------------------------------------------------------------------*/
-static void tx_complete (struct urb *urb)
+static void tx_complete(struct urb *urb)
{
- struct sk_buff *skb = (struct sk_buff *) urb->context;
- struct skb_data *entry = (struct skb_data *) skb->cb;
+ struct sk_buff *skb = (struct sk_buff *)urb->context;
+ struct skb_data *entry = (struct skb_data *)skb->cb;
struct usbnet *dev = entry->dev;
if (urb->status == 0) {
@@ -990,27 +996,29 @@ static void tx_complete (struct urb *urb)
switch (urb->status) {
case -EPIPE:
- usbnet_defer_kevent (dev, EVENT_TX_HALT);
+ usbnet_defer_kevent(dev, EVENT_TX_HALT);
break;
- /* software-driven interface shutdown */
- case -ECONNRESET: // async unlink
- case -ESHUTDOWN: // hardware gone
+ /* software-driven interface shutdown */
+ case -ECONNRESET: /* async unlink */
+ case -ESHUTDOWN: /* hardware gone */
break;
- // like rx, tx gets controller i/o faults during khubd delays
- // and so it uses the same throttling mechanism.
+ /* like rx, tx gets controller i/o faults during
+ * khubd delays and so it uses the same throttling
+ * mechanism.
+ */
case -EPROTO:
case -ETIME:
case -EILSEQ:
usb_mark_last_busy(dev->udev);
- if (!timer_pending (&dev->delay)) {
- mod_timer (&dev->delay,
- jiffies + THROTTLE_JIFFIES);
+ if (!timer_pending(&dev->delay)) {
+ mod_timer(&dev->delay,
+ jiffies + THROTTLE_JIFFIES);
netif_dbg(dev, link, dev->net,
"tx throttle %d\n", urb->status);
}
- netif_stop_queue (dev->net);
+ netif_stop_queue(dev->net);
break;
default:
netif_dbg(dev, tx_err, dev->net,
@@ -1027,21 +1035,21 @@ static void tx_complete (struct urb *urb)
/*-------------------------------------------------------------------------*/
-void usbnet_tx_timeout (struct net_device *net)
+void usbnet_tx_timeout(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
- unlink_urbs (dev, &dev->txq);
- tasklet_schedule (&dev->bh);
+ unlink_urbs(dev, &dev->txq);
+ tasklet_schedule(&dev->bh);
- // FIXME: device recovery -- reset?
+ /* FIXME: device recovery -- reset? */
}
EXPORT_SYMBOL_GPL(usbnet_tx_timeout);
/*-------------------------------------------------------------------------*/
-netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
- struct net_device *net)
+netdev_tx_t usbnet_start_xmit(struct sk_buff *skb,
+ struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
int length;
@@ -1051,10 +1059,11 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
unsigned long flags;
int retval;
- // some devices want funky USB-level framing, for
- // win32 driver (usually) and/or hardware quirks
+ /* some devices want funky USB-level framing, for
+ * win32 driver (usually) and/or hardware quirks
+ */
if (info->tx_fixup) {
- skb = info->tx_fixup (dev, skb, GFP_ATOMIC);
+ skb = info->tx_fixup(dev, skb, GFP_ATOMIC);
if (!skb) {
if (netif_msg_tx_err(dev)) {
netif_dbg(dev, tx_err, dev->net, "can't tx_fixup skb\n");
@@ -1067,19 +1076,20 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
}
length = skb->len;
- if (!(urb = usb_alloc_urb (0, GFP_ATOMIC))) {
+ urb = usb_alloc_urb(0, GFP_ATOMIC);
+ if (!urb) {
netif_dbg(dev, tx_err, dev->net, "no urb\n");
goto drop;
}
- entry = (struct skb_data *) skb->cb;
+ entry = (struct skb_data *)skb->cb;
entry->urb = urb;
entry->dev = dev;
entry->state = tx_start;
entry->length = length;
- usb_fill_bulk_urb (urb, dev->udev, dev->out,
- skb->data, skb->len, tx_complete, skb);
+ usb_fill_bulk_urb(urb, dev->udev, dev->out,
+ skb->data, skb->len, tx_complete, skb);
/* don't assume the hardware handles USB_ZERO_PACKET
* NOTE: strictly conforming cdc-ether devices should expect
@@ -1121,10 +1131,10 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
}
#endif
- switch ((retval = usb_submit_urb (urb, GFP_ATOMIC))) {
+ switch ((retval = usb_submit_urb(urb, GFP_ATOMIC))) {
case -EPIPE:
- netif_stop_queue (net);
- usbnet_defer_kevent (dev, EVENT_TX_HALT);
+ netif_stop_queue(net);
+ usbnet_defer_kevent(dev, EVENT_TX_HALT);
usb_autopm_put_interface_async(dev->intf);
break;
default:
@@ -1134,11 +1144,11 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
break;
case 0:
net->trans_start = jiffies;
- __skb_queue_tail (&dev->txq, skb);
- if (dev->txq.qlen >= TX_QLEN (dev))
- netif_stop_queue (net);
+ __skb_queue_tail(&dev->txq, skb);
+ if (dev->txq.qlen >= TX_QLEN(dev))
+ netif_stop_queue(net);
}
- spin_unlock_irqrestore (&dev->txq.lock, flags);
+ spin_unlock_irqrestore(&dev->txq.lock, flags);
if (retval) {
netif_dbg(dev, tx_err, dev->net, "drop, code %d\n", retval);
@@ -1146,8 +1156,8 @@ drop:
dev->net->stats.tx_dropped++;
not_drop:
if (skb)
- dev_kfree_skb_any (skb);
- usb_free_urb (urb);
+ dev_kfree_skb_any(skb);
+ usb_free_urb(urb);
} else
netif_dbg(dev, tx_queued, dev->net,
"> tx, len %d, type 0x%x\n", length, skb->protocol);
@@ -1160,54 +1170,54 @@ EXPORT_SYMBOL_GPL(usbnet_start_xmit);
/*-------------------------------------------------------------------------*/
-// tasklet (work deferred from completions, in_irq) or timer
+/* tasklet (work deferred from completions, in_irq) or timer */
-static void usbnet_bh (unsigned long param)
+static void usbnet_bh(unsigned long param)
{
- struct usbnet *dev = (struct usbnet *) param;
+ struct usbnet *dev = (struct usbnet *)param;
struct sk_buff *skb;
struct skb_data *entry;
- while ((skb = skb_dequeue (&dev->done))) {
- entry = (struct skb_data *) skb->cb;
+ while ((skb = skb_dequeue(&dev->done))) {
+ entry = (struct skb_data *)skb->cb;
switch (entry->state) {
case rx_done:
entry->state = rx_cleanup;
- rx_process (dev, skb);
+ rx_process(dev, skb);
continue;
case tx_done:
case rx_cleanup:
- usb_free_urb (entry->urb);
- dev_kfree_skb (skb);
+ usb_free_urb(entry->urb);
+ dev_kfree_skb(skb);
continue;
default:
- netdev_dbg(dev->net, "bogus skb state %d\n", entry->state);
+ netdev_dbg(dev->net, "bogus skb state %d\n",
+ entry->state);
}
}
- // waiting for all pending urbs to complete?
+ /* waiting for all pending urbs to complete? */
if (dev->wait) {
- if ((dev->txq.qlen + dev->rxq.qlen + dev->done.qlen) == 0) {
- wake_up (dev->wait);
- }
-
- // or are we maybe short a few urbs?
- } else if (netif_running (dev->net) &&
- netif_device_present (dev->net) &&
- !timer_pending (&dev->delay) &&
- !test_bit (EVENT_RX_HALT, &dev->flags)) {
+ if ((dev->txq.qlen + dev->rxq.qlen + dev->done.qlen) == 0)
+ wake_up(dev->wait);
+
+ /* or are we maybe short a few urbs? */
+ } else if (netif_running(dev->net) &&
+ netif_device_present(dev->net) &&
+ !timer_pending(&dev->delay) &&
+ !test_bit(EVENT_RX_HALT, &dev->flags)) {
int temp = dev->rxq.qlen;
- int qlen = RX_QLEN (dev);
+ int qlen = RX_QLEN(dev);
if (temp < qlen) {
struct urb *urb;
int i;
- // don't refill the queue all at once
+ /* don't refill the queue all at once */
for (i = 0; i < 10 && dev->rxq.qlen < qlen; i++) {
- urb = usb_alloc_urb (0, GFP_ATOMIC);
+ urb = usb_alloc_urb(0, GFP_ATOMIC);
if (urb != NULL) {
- if (rx_submit (dev, urb, GFP_ATOMIC) ==
+ if (rx_submit(dev, urb, GFP_ATOMIC) ==
-ENOLINK)
return;
}
@@ -1217,10 +1227,10 @@ static void usbnet_bh (unsigned long param)
"rxqlen %d --> %d\n",
temp, dev->rxq.qlen);
if (dev->rxq.qlen < qlen)
- tasklet_schedule (&dev->bh);
+ tasklet_schedule(&dev->bh);
}
- if (dev->txq.qlen < TX_QLEN (dev))
- netif_wake_queue (dev->net);
+ if (dev->txq.qlen < TX_QLEN(dev))
+ netif_wake_queue(dev->net);
}
}
@@ -1231,9 +1241,9 @@ static void usbnet_bh (unsigned long param)
*
*-------------------------------------------------------------------------*/
-// precondition: never called in_interrupt
+/* precondition: never called in_interrupt */
-void usbnet_disconnect (struct usb_interface *intf)
+void usbnet_disconnect(struct usb_interface *intf)
{
struct usbnet *dev;
struct usb_device *xdev;
@@ -1244,7 +1254,7 @@ void usbnet_disconnect (struct usb_interface *intf)
if (!dev)
return;
- xdev = interface_to_usbdev (intf);
+ xdev = interface_to_usbdev(intf);
netif_info(dev, probe, dev->net, "unregister '%s' usb-%s-%s, %s\n",
intf->dev.driver->name,
@@ -1252,15 +1262,15 @@ void usbnet_disconnect (struct usb_interface *intf)
dev->driver_info->description);
net = dev->net;
- unregister_netdev (net);
+ unregister_netdev(net);
cancel_work_sync(&dev->kevent);
if (dev->driver_info->unbind)
- dev->driver_info->unbind (dev, intf);
+ dev->driver_info->unbind(dev, intf);
free_netdev(net);
- usb_put_dev (xdev);
+ usb_put_dev(xdev);
}
EXPORT_SYMBOL_GPL(usbnet_disconnect);
@@ -1270,13 +1280,13 @@ static const struct net_device_ops usbnet_netdev_ops = {
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_change_mtu = usbnet_change_mtu,
- .ndo_set_mac_address = eth_mac_addr,
+ .ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
};
/*-------------------------------------------------------------------------*/
-// precondition: never called in_interrupt
+/* precondition: never called in_interrupt */
static struct device_type wlan_type = {
.name = "wlan",
@@ -1287,7 +1297,7 @@ static struct device_type wwan_type = {
};
int
-usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
+usbnet_probe(struct usb_interface *udev, const struct usb_device_id *prod)
{
struct usbnet *dev;
struct net_device *net;
@@ -1296,7 +1306,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
struct usb_device *xdev;
int status;
const char *name;
- struct usb_driver *driver = to_usb_driver(udev->dev.driver);
+ struct usb_driver *driver = to_usb_driver(udev->dev.driver);
/* usbnet already took usb runtime pm, so have to enable the feature
* for usb interface, otherwise usb_autopm_get_interface may return
@@ -1308,22 +1318,22 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
}
name = udev->dev.driver->name;
- info = (struct driver_info *) prod->driver_info;
+ info = (struct driver_info *)prod->driver_info;
if (!info) {
- dev_dbg (&udev->dev, "blacklisted by %s\n", name);
+ dev_dbg(&udev->dev, "blacklisted by %s\n", name);
return -ENODEV;
}
- xdev = interface_to_usbdev (udev);
+ xdev = interface_to_usbdev(udev);
interface = udev->cur_altsetting;
- usb_get_dev (xdev);
+ usb_get_dev(xdev);
status = -ENOMEM;
- // set up our own records
+ /* set up our own records */
net = alloc_etherdev(sizeof(*dev));
if (!net) {
- dbg ("can't kmalloc dev");
+ dbg("can't kmalloc dev");
goto out;
}
@@ -1335,33 +1345,34 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
dev->intf = udev;
dev->driver_info = info;
dev->driver_name = name;
- dev->msg_enable = netif_msg_init (msg_level, NETIF_MSG_DRV
- | NETIF_MSG_PROBE | NETIF_MSG_LINK);
- skb_queue_head_init (&dev->rxq);
- skb_queue_head_init (&dev->txq);
- skb_queue_head_init (&dev->done);
+ dev->msg_enable = netif_msg_init(msg_level, NETIF_MSG_DRV
+ | NETIF_MSG_PROBE | NETIF_MSG_LINK);
+ skb_queue_head_init(&dev->rxq);
+ skb_queue_head_init(&dev->txq);
+ skb_queue_head_init(&dev->done);
skb_queue_head_init(&dev->rxq_pause);
dev->bh.func = usbnet_bh;
- dev->bh.data = (unsigned long) dev;
- INIT_WORK (&dev->kevent, kevent);
+ dev->bh.data = (unsigned long)dev;
+ INIT_WORK(&dev->kevent, kevent);
init_usb_anchor(&dev->deferred);
dev->delay.function = usbnet_bh;
- dev->delay.data = (unsigned long) dev;
- init_timer (&dev->delay);
- mutex_init (&dev->phy_mutex);
+ dev->delay.data = (unsigned long)dev;
+ init_timer(&dev->delay);
+ mutex_init(&dev->phy_mutex);
dev->net = net;
- strcpy (net->name, "usb%d");
- memcpy (net->dev_addr, node_id, sizeof node_id);
+ strcpy(net->name, "usb%d");
+ memcpy(net->dev_addr, node_id, sizeof(node_id));
/* rx and tx sides can use different message sizes;
* bind() should set rx_urb_size in that case.
*/
dev->hard_mtu = net->mtu + net->hard_header_len;
#if 0
-// dma_supported() is deeply broken on almost all architectures
- // possible with some EHCI controllers
- if (dma_supported (&udev->dev, DMA_BIT_MASK(64)))
+ /* dma_supported() is deeply broken on almost all architectures
+ * possible with some EHCI controllers
+ */
+ if (dma_supported(&udev->dev, DMA_BIT_MASK(64)))
net->features |= NETIF_F_HIGHDMA;
#endif
@@ -1369,20 +1380,22 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
net->watchdog_timeo = TX_TIMEOUT_JIFFIES;
net->ethtool_ops = &usbnet_ethtool_ops;
- // allow device-specific bind/init procedures
- // NOTE net->name still not usable ...
+ /* allow device-specific bind/init procedures
+ * NOTE net->name still not usable ...
+ */
if (info->bind) {
- status = info->bind (dev, udev);
+ status = info->bind(dev, udev);
if (status < 0)
goto out1;
- // heuristic: "usb%d" for links we know are two-host,
- // else "eth%d" when there's reasonable doubt. userspace
- // can rename the link if it knows better.
+ /* heuristic: "usb%d" for links we know are two-host,
+ * else "eth%d" when there's reasonable doubt. userspace
+ * can rename the link if it knows better.
+ */
if ((dev->driver_info->flags & FLAG_ETHER) != 0 &&
((dev->driver_info->flags & FLAG_POINTTOPOINT) == 0 ||
- (net->dev_addr [0] & 0x02) == 0))
- strcpy (net->name, "eth%d");
+ (net->dev_addr[0] & 0x02) == 0))
+ strcpy(net->name, "eth%d");
/* WLAN devices should always be named "wlan%d" */
if ((dev->driver_info->flags & FLAG_WLAN) != 0)
strcpy(net->name, "wlan%d");
@@ -1394,33 +1407,33 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
if (net->mtu > (dev->hard_mtu - net->hard_header_len))
net->mtu = dev->hard_mtu - net->hard_header_len;
} else if (!info->in || !info->out)
- status = usbnet_get_endpoints (dev, udev);
+ status = usbnet_get_endpoints(dev, udev);
else {
- dev->in = usb_rcvbulkpipe (xdev, info->in);
- dev->out = usb_sndbulkpipe (xdev, info->out);
+ dev->in = usb_rcvbulkpipe(xdev, info->in);
+ dev->out = usb_sndbulkpipe(xdev, info->out);
if (!(info->flags & FLAG_NO_SETINT))
- status = usb_set_interface (xdev,
- interface->desc.bInterfaceNumber,
- interface->desc.bAlternateSetting);
+ status = usb_set_interface(xdev,
+ interface->desc.bInterfaceNumber,
+ interface->desc.bAlternateSetting);
else
status = 0;
}
if (status >= 0 && dev->status)
- status = init_status (dev, udev);
+ status = init_status(dev, udev);
if (status < 0)
goto out3;
if (!dev->rx_urb_size)
dev->rx_urb_size = dev->hard_mtu;
- dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1);
+ dev->maxpacket = usb_maxpacket(dev->udev, dev->out, 1);
if ((dev->driver_info->flags & FLAG_WLAN) != 0)
SET_NETDEV_DEVTYPE(net, &wlan_type);
if ((dev->driver_info->flags & FLAG_WWAN) != 0)
SET_NETDEV_DEVTYPE(net, &wwan_type);
- status = register_netdev (net);
+ status = register_netdev(net);
if (status)
goto out3;
netif_info(dev, probe, dev->net,
@@ -1430,10 +1443,10 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
dev->driver_info->description,
net->dev_addr);
- // ok, it's ready to go.
- usb_set_intfdata (udev, dev);
+ /* ok, it's ready to go. */
+ usb_set_intfdata(udev, dev);
- netif_device_attach (net);
+ netif_device_attach(net);
if (dev->driver_info->flags & FLAG_LINK_INTR)
netif_carrier_off(net);
@@ -1442,7 +1455,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
out3:
if (info->unbind)
- info->unbind (dev, udev);
+ info->unbind(dev, udev);
out1:
free_netdev(net);
out:
@@ -1458,7 +1471,7 @@ EXPORT_SYMBOL_GPL(usbnet_probe);
* resume only when the last interface is resumed
*/
-int usbnet_suspend (struct usb_interface *intf, pm_message_t message)
+int usbnet_suspend(struct usb_interface *intf, pm_message_t message)
{
struct usbnet *dev = usb_get_intfdata(intf);
@@ -1476,7 +1489,7 @@ int usbnet_suspend (struct usb_interface *intf, pm_message_t message)
* accelerate emptying of the rx and queues, to avoid
* having everything error out.
*/
- netif_device_detach (dev->net);
+ netif_device_detach(dev->net);
usbnet_terminate_urbs(dev);
usb_kill_urb(dev->interrupt);
@@ -1484,13 +1497,13 @@ int usbnet_suspend (struct usb_interface *intf, pm_message_t message)
* reattach so runtime management can use and
* wake the device
*/
- netif_device_attach (dev->net);
+ netif_device_attach(dev->net);
}
return 0;
}
EXPORT_SYMBOL_GPL(usbnet_suspend);
-int usbnet_resume (struct usb_interface *intf)
+int usbnet_resume(struct usb_interface *intf)
{
struct usbnet *dev = usb_get_intfdata(intf);
struct sk_buff *skb;
@@ -1518,7 +1531,7 @@ int usbnet_resume (struct usb_interface *intf)
spin_unlock_irq(&dev->txq.lock);
if (!(dev->txq.qlen >= TX_QLEN(dev)))
netif_start_queue(dev->net);
- tasklet_schedule (&dev->bh);
+ tasklet_schedule(&dev->bh);
}
return 0;
}
--
1.7.5.rc3.dirty
^ permalink raw reply related
* [PATCH 2/2] usbnet: Convert dbg to dev_dbg and neatening
From: Joe Perches @ 2011-05-03 18:17 UTC (permalink / raw)
To: Oliver Neukum, David Brownell, Greg Kroah-Hartman
Cc: netdev, linux-usb, linux-kernel
In-Reply-To: <cover.1304445019.git.joe@perches.com>
Use the more standard logging form.
Add a bit more tidying style.
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/net/usb/usbnet.c | 23 +++++++++++------------
1 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 28aecbb..b803085 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -192,8 +192,8 @@ static int init_status(struct usbnet *dev, struct usb_interface *intf)
return 0;
pipe = usb_rcvintpipe(dev->udev,
- dev->status->desc.bEndpointAddress
- & USB_ENDPOINT_NUMBER_MASK);
+ (dev->status->desc.bEndpointAddress
+ & USB_ENDPOINT_NUMBER_MASK));
maxp = usb_maxpacket(dev->udev, pipe, 0);
/* avoid 1 msec chatter: min 8 msec poll rate */
@@ -1066,7 +1066,8 @@ netdev_tx_t usbnet_start_xmit(struct sk_buff *skb,
skb = info->tx_fixup(dev, skb, GFP_ATOMIC);
if (!skb) {
if (netif_msg_tx_err(dev)) {
- netif_dbg(dev, tx_err, dev->net, "can't tx_fixup skb\n");
+ netif_dbg(dev, tx_err, dev->net,
+ "can't tx_fixup skb\n");
goto drop;
} else {
/* cdc_ncm collected packet; waits for more */
@@ -1333,7 +1334,7 @@ usbnet_probe(struct usb_interface *udev, const struct usb_device_id *prod)
/* set up our own records */
net = alloc_etherdev(sizeof(*dev));
if (!net) {
- dbg("can't kmalloc dev");
+ dev_dbg(&udev->dev, "can't alloc_etherdev\n");
goto out;
}
@@ -1345,8 +1346,9 @@ usbnet_probe(struct usb_interface *udev, const struct usb_device_id *prod)
dev->intf = udev;
dev->driver_info = info;
dev->driver_name = name;
- dev->msg_enable = netif_msg_init(msg_level, NETIF_MSG_DRV
- | NETIF_MSG_PROBE | NETIF_MSG_LINK);
+ dev->msg_enable = netif_msg_init(msg_level, (NETIF_MSG_DRV |
+ NETIF_MSG_PROBE |
+ NETIF_MSG_LINK));
skb_queue_head_init(&dev->rxq);
skb_queue_head_init(&dev->txq);
skb_queue_head_init(&dev->done);
@@ -1466,8 +1468,7 @@ EXPORT_SYMBOL_GPL(usbnet_probe);
/*-------------------------------------------------------------------------*/
-/*
- * suspend the whole driver as soon as the first interface is suspended
+/* suspend the whole driver as soon as the first interface is suspended
* resume only when the last interface is resumed
*/
@@ -1485,16 +1486,14 @@ int usbnet_suspend(struct usb_interface *intf, pm_message_t message)
set_bit(EVENT_DEV_ASLEEP, &dev->flags);
spin_unlock_irq(&dev->txq.lock);
}
- /*
- * accelerate emptying of the rx and queues, to avoid
+ /* accelerate emptying of the rx and queues, to avoid
* having everything error out.
*/
netif_device_detach(dev->net);
usbnet_terminate_urbs(dev);
usb_kill_urb(dev->interrupt);
- /*
- * reattach so runtime management can use and
+ /* reattach so runtime management can use and
* wake the device
*/
netif_device_attach(dev->net);
--
1.7.5.rc3.dirty
^ permalink raw reply related
* Re: [PATCH 1/2] usbnet: Style cleanups
From: Oliver Neukum @ 2011-05-03 18:49 UTC (permalink / raw)
To: Joe Perches
Cc: David Brownell, Greg Kroah-Hartman, netdev, linux-usb,
linux-kernel
In-Reply-To: <3592918df9ee156047042aae16531e96db0b7144.1304445019.git.joe@perches.com>
Am Dienstag, 3. Mai 2011, 20:17:57 schrieb Joe Perches:
> drivers/net/usb/usbnet.c | 625 +++++++++++++++++++++++----------------------
> 1 files changed, 319 insertions(+), 306 deletions(-)
>
> diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
> index 7bc9852..28aecbb 100644
> --- a/drivers/net/usb/usbnet.c
> +++ b/drivers/net/usb/usbnet.c
> @@ -30,8 +30,8 @@
> * issues can usefully be addressed by this framework.
> */
>
> -// #define DEBUG // error path messages, extra info
> -// #define VERBOSE // more; success messages
> +/* #define DEBUG // error path messages, extra info */
> +/* #define VERBOSE // more; success messages */
Hi,
1. please don't touch things like that. They are not comments in a semantic sense
2. If you are touching comments, please redo the multiline comments according to
the coding style.
3. please delay these modifications until the patches against the oom problem have
been applied
Regards
Oliver
--
- - -
SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg)
Maxfeldstraße 5
90409 Nürnberg
Germany
- - -
^ permalink raw reply
* Re: [PATCH 2/2] usbnet: Convert dbg to dev_dbg and neatening
From: Oliver Neukum @ 2011-05-03 18:51 UTC (permalink / raw)
To: Joe Perches
Cc: David Brownell, Greg Kroah-Hartman, netdev, linux-usb,
linux-kernel
In-Reply-To: <f86364fbdc335fadad003081d010843579e95765.1304445019.git.joe@perches.com>
Am Dienstag, 3. Mai 2011, 20:17:58 schrieb Joe Perches:
> Use the more standard logging form.
> Add a bit more tidying style.
>
> Signed-off-by: Joe Perches <joe@perches.com>
Please do not mix changes like that. Either only coding style or only
other cleanups.
Regards
Oliver
--
- - -
SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg)
Maxfeldstraße 5
90409 Nürnberg
Germany
- - -
^ permalink raw reply
* Re: [PATCH 1/2] usbnet: Style cleanups
From: Joe Perches @ 2011-05-03 19:05 UTC (permalink / raw)
To: Oliver Neukum; +Cc: Greg Kroah-Hartman, netdev, linux-usb, linux-kernel
In-Reply-To: <201105032049.41433.oneukum@suse.de>
On Tue, 2011-05-03 at 20:49 +0200, Oliver Neukum wrote:
> Am Dienstag, 3. Mai 2011, 20:17:57 schrieb Joe Perches:
> > drivers/net/usb/usbnet.c | 625 +++++++++++++++++++++++----------------------
> > 1 files changed, 319 insertions(+), 306 deletions(-)
> >
> > diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
> > index 7bc9852..28aecbb 100644
> > --- a/drivers/net/usb/usbnet.c
> > +++ b/drivers/net/usb/usbnet.c
> > @@ -30,8 +30,8 @@
> > * issues can usefully be addressed by this framework.
> > */
> >
> > -// #define DEBUG // error path messages, extra info
> > -// #define VERBOSE // more; success messages
> > +/* #define DEBUG // error path messages, extra info */
> > +/* #define VERBOSE // more; success messages */
>
> Hi,
Hi Oliver.
> 1. please don't touch things like that. They are not comments in a semantic sense
We disagree. Look for other uses of commented out DEBUG.
For instance, in drivers it's:
$ grep -rP --include=*.[ch] --exclude=drivers/staging "/\*\s*\#\s*define\s+DEBUG\b" drivers | wc -l
32
$ grep -rP --include=*.[ch] --exclude=drivers/staging "//\s*\#\s*define\s+DEBUG\b" drivers | wc -l
17
Treewide, there are 20 uses of //#define DEBUG
> if you are touching comments, please redo the multiline comments according to
> the coding style.
Read the patches, they are converted to appropriate form.
> 3. please delay these modifications until the patches against the oom problem have
> been applied
I think they're correct and don't feel a need to regenerate them
nor do I think micropatches for trivial stuff like this is necessary.
You want to be the maintainer for this stuff, it's your choice to
apply them, modify them to suit your taste or ignore them.
cheers, Joe
^ permalink raw reply
* [PATCH] net: ehea: fix wrongly-reported supported modes
From: Kleber Sacilotto de Souza @ 2011-05-03 19:42 UTC (permalink / raw)
To: netdev
Currently EHEA reports to ethtool as supporting 10000baseT_Full and
FIBRE independent of the hardware configuration. However, these
capabilities should be reported only if the physical port and
the medium support them, which is the case where the physical port
is connected at 10Gb.
Signed-off-by: Kleber Sacilotto de Souza <klebers@linux.vnet.ibm.com>
---
drivers/net/ehea/ehea_ethtool.c | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ehea/ehea_ethtool.c b/drivers/net/ehea/ehea_ethtool.c
index 3e2e734..04716c2 100644
--- a/drivers/net/ehea/ehea_ethtool.c
+++ b/drivers/net/ehea/ehea_ethtool.c
@@ -55,15 +55,22 @@ static int ehea_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
cmd->duplex = -1;
}
- cmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_1000baseT_Full
- | SUPPORTED_100baseT_Full | SUPPORTED_100baseT_Half
- | SUPPORTED_10baseT_Full | SUPPORTED_10baseT_Half
- | SUPPORTED_Autoneg | SUPPORTED_FIBRE);
+ cmd->supported = (SUPPORTED_1000baseT_Full | SUPPORTED_100baseT_Full
+ | SUPPORTED_100baseT_Half | SUPPORTED_10baseT_Full
+ | SUPPORTED_10baseT_Half | SUPPORTED_Autoneg);
- cmd->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_Autoneg
- | ADVERTISED_FIBRE);
+ cmd->advertising = ADVERTISED_Autoneg;
+
+ if (cmd->speed == SPEED_10000) {
+ cmd->supported |= (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
+ cmd->advertising |= (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE);
+ cmd->port = PORT_FIBRE;
+ } else {
+ cmd->supported |= SUPPORTED_TP;
+ cmd->advertising |= (ADVERTISED_1000baseT_Full | ADVERTISED_TP);
+ cmd->port = PORT_TP;
+ }
- cmd->port = PORT_FIBRE;
cmd->autoneg = port->autoneg == 1 ? AUTONEG_ENABLE : AUTONEG_DISABLE;
return 0;
--
1.7.1
^ permalink raw reply related
* Re: [PATCH V3 2/8] Add a new zerocopy device flag
From: Shirley Ma @ 2011-05-03 20:11 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: David Miller, Eric Dumazet, Avi Kivity, Arnd Bergmann, netdev,
kvm, linux-kernel
In-Reply-To: <1304444570.20660.32.camel@localhost.localdomain>
On Tue, 2011-05-03 at 10:42 -0700, Shirley Ma wrote:
> Better to prevent this kind of skbs to be used in skb_clone, expand
> head
> for now.
I looked at the code, skb_clone shouldn't have any problem since ubuf
callback is only called after the lower device DMA has done. I can
modify the zerocopy len to 256 bytes so expand head should be OK as
well. So we only need to prevent recycle skb. I also checked the device
drivers, only a few device do RX buffers recycle. So there shouldn't be
any problem.
I will add more comments here to make sure when ZEROCOPY flag is set,
the ubuf callback should only be called when last reference to this skb
is gone.
Thanks
Shirley
^ permalink raw reply
* Re: [PATCH] net: ehea: fix wrongly-reported supported modes
From: Ben Hutchings @ 2011-05-03 20:16 UTC (permalink / raw)
To: Kleber Sacilotto de Souza; +Cc: netdev
In-Reply-To: <1304451745.6899.15.camel@dream>
On Tue, 2011-05-03 at 16:42 -0300, Kleber Sacilotto de Souza wrote:
> Currently EHEA reports to ethtool as supporting 10000baseT_Full and
> FIBRE independent of the hardware configuration. However, these
> capabilities should be reported only if the physical port and
> the medium support them, which is the case where the physical port
> is connected at 10Gb.
>
> Signed-off-by: Kleber Sacilotto de Souza <klebers@linux.vnet.ibm.com>
> ---
> drivers/net/ehea/ehea_ethtool.c | 21 ++++++++++++++-------
> 1 files changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ehea/ehea_ethtool.c b/drivers/net/ehea/ehea_ethtool.c
> index 3e2e734..04716c2 100644
> --- a/drivers/net/ehea/ehea_ethtool.c
> +++ b/drivers/net/ehea/ehea_ethtool.c
> @@ -55,15 +55,22 @@ static int ehea_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
> cmd->duplex = -1;
> }
>
> - cmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_1000baseT_Full
> - | SUPPORTED_100baseT_Full | SUPPORTED_100baseT_Half
> - | SUPPORTED_10baseT_Full | SUPPORTED_10baseT_Half
> - | SUPPORTED_Autoneg | SUPPORTED_FIBRE);
> + cmd->supported = (SUPPORTED_1000baseT_Full | SUPPORTED_100baseT_Full
> + | SUPPORTED_100baseT_Half | SUPPORTED_10baseT_Full
> + | SUPPORTED_10baseT_Half | SUPPORTED_Autoneg);
>
> - cmd->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_Autoneg
> - | ADVERTISED_FIBRE);
> + cmd->advertising = ADVERTISED_Autoneg;
> +
> + if (cmd->speed == SPEED_10000) {
> + cmd->supported |= (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
> + cmd->advertising |= (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE);
> + cmd->port = PORT_FIBRE;
> + } else {
> + cmd->supported |= SUPPORTED_TP;
> + cmd->advertising |= (ADVERTISED_1000baseT_Full | ADVERTISED_TP);
> + cmd->port = PORT_TP;
> + }
This doesn't make any sense. If the current speed is 10G, then the
driver also claims to support speeds of 10M, 100M, 1G and 10G. But then
if the speed actually is <10G, the driver claims to support TP. What's
going on here?
(Also, claiming to support BASE-T modes on non-TP media is bogus, though
I understand why people are doing it.)
Ben.
> - cmd->port = PORT_FIBRE;
> cmd->autoneg = port->autoneg == 1 ? AUTONEG_ENABLE : AUTONEG_DISABLE;
>
> return 0;
--
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
* [PATCH] pktgen: use %pI6c for printing IPv6 addresses
From: Alexey Dobriyan @ 2011-05-03 21:23 UTC (permalink / raw)
To: davem; +Cc: netdev
I don't know why %pI6 doesn't compress, but the format specifier is
kernel-standard, so use it.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
net/core/pktgen.c | 109 ++++++------------------------------------------------
1 file changed, 13 insertions(+), 96 deletions(-)
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -449,7 +449,6 @@ static void pktgen_stop(struct pktgen_thread *t);
static void pktgen_clear_counters(struct pktgen_dev *pkt_dev);
static unsigned int scan_ip6(const char *s, char ip[16]);
-static unsigned int fmt_ip6(char *s, const char ip[16]);
/* Module parameters, defaults. */
static int pg_count_d __read_mostly = 1000;
@@ -556,21 +555,13 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
pkt_dev->skb_priority);
if (pkt_dev->flags & F_IPV6) {
- char b1[128], b2[128], b3[128];
- fmt_ip6(b1, pkt_dev->in6_saddr.s6_addr);
- fmt_ip6(b2, pkt_dev->min_in6_saddr.s6_addr);
- fmt_ip6(b3, pkt_dev->max_in6_saddr.s6_addr);
seq_printf(seq,
- " saddr: %s min_saddr: %s max_saddr: %s\n", b1,
- b2, b3);
-
- fmt_ip6(b1, pkt_dev->in6_daddr.s6_addr);
- fmt_ip6(b2, pkt_dev->min_in6_daddr.s6_addr);
- fmt_ip6(b3, pkt_dev->max_in6_daddr.s6_addr);
- seq_printf(seq,
- " daddr: %s min_daddr: %s max_daddr: %s\n", b1,
- b2, b3);
-
+ " saddr: %pI6c min_saddr: %pI6c max_saddr: %pI6c\n"
+ " daddr: %pI6c min_daddr: %pI6c max_daddr: %pI6c\n",
+ &pkt_dev->in6_saddr,
+ &pkt_dev->min_in6_saddr, &pkt_dev->max_in6_saddr,
+ &pkt_dev->in6_daddr,
+ &pkt_dev->min_in6_daddr, &pkt_dev->max_in6_daddr);
} else {
seq_printf(seq,
" dst_min: %s dst_max: %s\n",
@@ -706,10 +697,9 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
pkt_dev->cur_src_mac_offset);
if (pkt_dev->flags & F_IPV6) {
- char b1[128], b2[128];
- fmt_ip6(b1, pkt_dev->cur_in6_daddr.s6_addr);
- fmt_ip6(b2, pkt_dev->cur_in6_saddr.s6_addr);
- seq_printf(seq, " cur_saddr: %s cur_daddr: %s\n", b2, b1);
+ seq_printf(seq, " cur_saddr: %pI6c cur_daddr: %pI6c\n",
+ &pkt_dev->cur_in6_saddr,
+ &pkt_dev->cur_in6_daddr);
} else
seq_printf(seq, " cur_saddr: 0x%x cur_daddr: 0x%x\n",
pkt_dev->cur_saddr, pkt_dev->cur_daddr);
@@ -1309,7 +1299,7 @@ static ssize_t pktgen_if_write(struct file *file,
buf[len] = 0;
scan_ip6(buf, pkt_dev->in6_daddr.s6_addr);
- fmt_ip6(buf, pkt_dev->in6_daddr.s6_addr);
+ snprintf(buf, sizeof(buf), "%pI6c", &pkt_dev->in6_daddr);
ipv6_addr_copy(&pkt_dev->cur_in6_daddr, &pkt_dev->in6_daddr);
@@ -1332,7 +1322,7 @@ static ssize_t pktgen_if_write(struct file *file,
buf[len] = 0;
scan_ip6(buf, pkt_dev->min_in6_daddr.s6_addr);
- fmt_ip6(buf, pkt_dev->min_in6_daddr.s6_addr);
+ snprintf(buf, sizeof(buf), "%pI6c", &pkt_dev->min_in6_daddr);
ipv6_addr_copy(&pkt_dev->cur_in6_daddr,
&pkt_dev->min_in6_daddr);
@@ -1355,7 +1345,7 @@ static ssize_t pktgen_if_write(struct file *file,
buf[len] = 0;
scan_ip6(buf, pkt_dev->max_in6_daddr.s6_addr);
- fmt_ip6(buf, pkt_dev->max_in6_daddr.s6_addr);
+ snprintf(buf, sizeof(buf), "%pI6c", &pkt_dev->max_in6_daddr);
if (debug)
printk(KERN_DEBUG "pktgen: dst6_max set to: %s\n", buf);
@@ -1376,7 +1366,7 @@ static ssize_t pktgen_if_write(struct file *file,
buf[len] = 0;
scan_ip6(buf, pkt_dev->in6_saddr.s6_addr);
- fmt_ip6(buf, pkt_dev->in6_saddr.s6_addr);
+ snprintf(buf, sizeof(buf), "%pI6c", &pkt_dev->in6_saddr);
ipv6_addr_copy(&pkt_dev->cur_in6_saddr, &pkt_dev->in6_saddr);
@@ -2898,79 +2888,6 @@ static unsigned int scan_ip6(const char *s, char ip[16])
return len;
}
-static char tohex(char hexdigit)
-{
- return hexdigit > 9 ? hexdigit + 'a' - 10 : hexdigit + '0';
-}
-
-static int fmt_xlong(char *s, unsigned int i)
-{
- char *bak = s;
- *s = tohex((i >> 12) & 0xf);
- if (s != bak || *s != '0')
- ++s;
- *s = tohex((i >> 8) & 0xf);
- if (s != bak || *s != '0')
- ++s;
- *s = tohex((i >> 4) & 0xf);
- if (s != bak || *s != '0')
- ++s;
- *s = tohex(i & 0xf);
- return s - bak + 1;
-}
-
-static unsigned int fmt_ip6(char *s, const char ip[16])
-{
- unsigned int len;
- unsigned int i;
- unsigned int temp;
- unsigned int compressing;
- int j;
-
- len = 0;
- compressing = 0;
- for (j = 0; j < 16; j += 2) {
-
-#ifdef V4MAPPEDPREFIX
- if (j == 12 && !memcmp(ip, V4mappedprefix, 12)) {
- inet_ntoa_r(*(struct in_addr *)(ip + 12), s);
- temp = strlen(s);
- return len + temp;
- }
-#endif
- temp = ((unsigned long)(unsigned char)ip[j] << 8) +
- (unsigned long)(unsigned char)ip[j + 1];
- if (temp == 0) {
- if (!compressing) {
- compressing = 1;
- if (j == 0) {
- *s++ = ':';
- ++len;
- }
- }
- } else {
- if (compressing) {
- compressing = 0;
- *s++ = ':';
- ++len;
- }
- i = fmt_xlong(s, temp);
- len += i;
- s += i;
- if (j < 14) {
- *s++ = ':';
- ++len;
- }
- }
- }
- if (compressing) {
- *s++ = ':';
- ++len;
- }
- *s = 0;
- return len;
-}
-
static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
struct pktgen_dev *pkt_dev)
{
^ permalink raw reply
* Re: [PATCH] net: ehea: fix wrongly-reported supported modes
From: Ben Hutchings @ 2011-05-03 21:34 UTC (permalink / raw)
To: Kleber Sacilotto de Souza; +Cc: netdev
In-Reply-To: <1304453775.2873.17.camel@bwh-desktop>
On Tue, 2011-05-03 at 21:16 +0100, Ben Hutchings wrote:
> On Tue, 2011-05-03 at 16:42 -0300, Kleber Sacilotto de Souza wrote:
> > Currently EHEA reports to ethtool as supporting 10000baseT_Full and
> > FIBRE independent of the hardware configuration. However, these
> > capabilities should be reported only if the physical port and
> > the medium support them, which is the case where the physical port
> > is connected at 10Gb.
> >
> > Signed-off-by: Kleber Sacilotto de Souza <klebers@linux.vnet.ibm.com>
> > ---
> > drivers/net/ehea/ehea_ethtool.c | 21 ++++++++++++++-------
> > 1 files changed, 14 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/net/ehea/ehea_ethtool.c b/drivers/net/ehea/ehea_ethtool.c
> > index 3e2e734..04716c2 100644
> > --- a/drivers/net/ehea/ehea_ethtool.c
> > +++ b/drivers/net/ehea/ehea_ethtool.c
> > @@ -55,15 +55,22 @@ static int ehea_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
> > cmd->duplex = -1;
> > }
> >
> > - cmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_1000baseT_Full
> > - | SUPPORTED_100baseT_Full | SUPPORTED_100baseT_Half
> > - | SUPPORTED_10baseT_Full | SUPPORTED_10baseT_Half
> > - | SUPPORTED_Autoneg | SUPPORTED_FIBRE);
> > + cmd->supported = (SUPPORTED_1000baseT_Full | SUPPORTED_100baseT_Full
> > + | SUPPORTED_100baseT_Half | SUPPORTED_10baseT_Full
> > + | SUPPORTED_10baseT_Half | SUPPORTED_Autoneg);
> >
> > - cmd->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_Autoneg
> > - | ADVERTISED_FIBRE);
> > + cmd->advertising = ADVERTISED_Autoneg;
> > +
> > + if (cmd->speed == SPEED_10000) {
> > + cmd->supported |= (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
> > + cmd->advertising |= (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE);
> > + cmd->port = PORT_FIBRE;
> > + } else {
> > + cmd->supported |= SUPPORTED_TP;
> > + cmd->advertising |= (ADVERTISED_1000baseT_Full | ADVERTISED_TP);
> > + cmd->port = PORT_TP;
> > + }
>
> This doesn't make any sense. If the current speed is 10G, then the
> driver also claims to support speeds of 10M, 100M, 1G and 10G. But then
^
on fibre
> if the speed actually is <10G, the driver claims to support TP. What's
> going on here?
>
> (Also, claiming to support BASE-T modes on non-TP media is bogus, though
> I understand why people are doing it.)
>
> Ben.
>
> > - cmd->port = PORT_FIBRE;
> > cmd->autoneg = port->autoneg == 1 ? AUTONEG_ENABLE : AUTONEG_DISABLE;
> >
> > return 0;
>
--
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: [RFC v3 02/10] Revert "lsm: Remove the socket_post_accept() hook"
From: Paul Moore @ 2011-05-03 22:02 UTC (permalink / raw)
To: Samir Bellabes
Cc: linux-security-module, linux-kernel, netdev, netfilter-devel,
jamal, Patrick McHardy, Evgeniy Polyakov, Grzegorz Nosek
In-Reply-To: <1304432663-1575-3-git-send-email-sam@synack.fr>
On Tuesday, May 03, 2011 10:24:15 AM Samir Bellabes wrote:
> snet needs to reintroduce this hook, as it was designed to be: a hook for
> updating security informations on objects.
Looking at this and 5/10 again, it seems that you should be able to do what
you need with the sock_graft() hook. Am I missing something?
My apologies if we've already discussed this approach previously ...
> Originally, This was a direct revert of commit
> 8651d5c0b1f874c5b8307ae2b858bc40f9f02482.
>
> But from the comment of Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> :
> > Please move security_socket_post_accept() to before fd_install().
> > Otherwise, other threads which share fd tables can use
> > security-informations-not-yet-updated accept()ed sockets.
>
> Signed-off-by: Samir Bellabes <sam@synack.fr>
> Acked-by: Serge Hallyn <serue@us.ibm.com>
>
> snet needs to reintroduce this hook, as it was designed to be: a hook for
> updating security informations on objects.
>
> Signed-off-by: Samir Bellabes <sam@synack.fr>
> ---
> include/linux/security.h | 13 +++++++++++++
> net/socket.c | 2 ++
> security/capability.c | 5 +++++
> security/security.c | 5 +++++
> 4 files changed, 25 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/security.h b/include/linux/security.h
> index da0d59e..02effe5 100644
> --- a/include/linux/security.h
> +++ b/include/linux/security.h
> @@ -875,6 +875,11 @@ static inline void security_free_mnt_opts(struct
> security_mnt_opts *opts) * @sock contains the listening socket structure.
> * @newsock contains the newly created server socket for connection.
> * Return 0 if permission is granted.
> + * @socket_post_accept:
> + * This hook allows a security module to copy security
> + * information into the newly created socket's inode.
> + * @sock contains the listening socket structure.
> + * @newsock contains the newly created server socket for connection.
> * @socket_sendmsg:
> * Check permission before transmitting a message to another socket.
> * @sock contains the socket structure.
> @@ -1587,6 +1592,8 @@ struct security_operations {
> struct sockaddr *address, int addrlen);
> int (*socket_listen) (struct socket *sock, int backlog);
> int (*socket_accept) (struct socket *sock, struct socket *newsock);
> + void (*socket_post_accept) (struct socket *sock,
> + struct socket *newsock);
> int (*socket_sendmsg) (struct socket *sock,
> struct msghdr *msg, int size);
> int (*socket_recvmsg) (struct socket *sock,
> @@ -2555,6 +2562,7 @@ int security_socket_bind(struct socket *sock, struct
> sockaddr *address, int addr int security_socket_connect(struct socket
> *sock, struct sockaddr *address, int addrlen); int
> security_socket_listen(struct socket *sock, int backlog);
> int security_socket_accept(struct socket *sock, struct socket *newsock);
> +void security_socket_post_accept(struct socket *sock, struct socket
> *newsock); int security_socket_sendmsg(struct socket *sock, struct msghdr
> *msg, int size); int security_socket_recvmsg(struct socket *sock, struct
> msghdr *msg, int size, int flags);
> @@ -2640,6 +2648,11 @@ static inline int security_socket_accept(struct
> socket *sock, return 0;
> }
>
> +static inline void security_socket_post_accept(struct socket *sock,
> + struct socket *newsock)
> +{
> +}
> +
> static inline int security_socket_sendmsg(struct socket *sock,
> struct msghdr *msg, int size)
> {
> diff --git a/net/socket.c b/net/socket.c
> index d588e9e..7807904 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -1535,6 +1535,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr
> __user *, upeer_sockaddr, goto out_fd;
> }
>
> + security_socket_post_accept(sock, newsock);
> +
> /* File flags are not inherited via accept() unlike another OSes. */
>
> fd_install(newfd, newfile);
> diff --git a/security/capability.c b/security/capability.c
> index 1f8bbe2..da68c60 100644
> --- a/security/capability.c
> +++ b/security/capability.c
> @@ -593,6 +593,10 @@ static int cap_socket_accept(struct socket *sock,
> struct socket *newsock) return 0;
> }
>
> +static void cap_socket_post_accept(struct socket *sock, struct socket
> *newsock) +{
> +}
> +
> static int cap_socket_sendmsg(struct socket *sock, struct msghdr *msg, int
> size) {
> return 0;
> @@ -1022,6 +1026,7 @@ void __init security_fixup_ops(struct
> security_operations *ops) set_to_cap_if_null(ops, socket_connect);
> set_to_cap_if_null(ops, socket_listen);
> set_to_cap_if_null(ops, socket_accept);
> + set_to_cap_if_null(ops, socket_post_accept);
> set_to_cap_if_null(ops, socket_sendmsg);
> set_to_cap_if_null(ops, socket_recvmsg);
> set_to_cap_if_null(ops, socket_getsockname);
> diff --git a/security/security.c b/security/security.c
> index 84187d8..eda2b75 100644
> --- a/security/security.c
> +++ b/security/security.c
> @@ -1038,6 +1038,11 @@ int security_socket_accept(struct socket *sock,
> struct socket *newsock) return security_ops->socket_accept(sock, newsock);
> }
>
> +void security_socket_post_accept(struct socket *sock, struct socket
> *newsock) +{
> + security_ops->socket_post_accept(sock, newsock);
> +}
> +
> int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int
> size) {
> return security_ops->socket_sendmsg(sock, msg, size);
--
paul moore
linux @ hp
^ permalink raw reply
* Re: [PATCH] pktgen: use %pI6c for printing IPv6 addresses
From: Joe Perches @ 2011-05-03 22:11 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: davem, netdev
In-Reply-To: <20110503212340.GA25293@p183>
On Wed, 2011-05-04 at 00:23 +0300, Alexey Dobriyan wrote:
> I don't know why %pI6 doesn't compress, but the format specifier is
> kernel-standard, so use it.
Because seq_printf output using %pI6 has a known
output style and shouldn't be changed to avoid
breaking user applications.
^ permalink raw reply
* Re: [GIT PULL nf-2.6] IPVS (Take II)
From: Simon Horman @ 2011-05-03 22:12 UTC (permalink / raw)
To: lvs-devel, netdev, netfilter-devel, netfilter
Cc: Wensong Zhang, Julian Anastasov, Patrick McHardy,
Hans Schillstrom, Hans Schillstrom, Eric W. Biederman
In-Reply-To: <1304406316-15636-1-git-send-email-horms@verge.net.au>
On Tue, May 03, 2011 at 04:05:14PM +0900, Simon Horman wrote:
> Hi Patrick,
>
> please consider pulling
> git://git.kernel.org/pub/scm/linux/kernel/git/horms/ipvs-2.6.git for-patrick
> to get the following fix from Hans. They resolve some problems related
> to his netns for IPVS work which was incorporated into 2.6.39-rc1.
Sorry for all the messing about.
A fresh version of these patches has been provided by Hans,
and I'm looking into weather they should replace this pull request.
So please ignore this for now (again!).
>
> The pull request is based on nf-2.6/master.
>
> There are other less-pressing changes from Hans which
> I plan to get you to pull into nf-next-2.6 once these
> changes make it there (presumably via net-2.6 and then net-next-2.6).
>
> Hans Schillstrom (2):
> IPVS: Change of socket usage to enable name space exit.
> IPVS: init and cleanup restructuring.
>
> include/net/ip_vs.h | 17 +++++
> net/netfilter/ipvs/ip_vs_app.c | 15 +----
> net/netfilter/ipvs/ip_vs_conn.c | 12 +---
> net/netfilter/ipvs/ip_vs_core.c | 102 ++++++++++++++++++++++++++++---
> net/netfilter/ipvs/ip_vs_ctl.c | 123 ++++++++++++++++++++++++++++++++------
> net/netfilter/ipvs/ip_vs_est.c | 14 +----
> net/netfilter/ipvs/ip_vs_proto.c | 11 +---
> net/netfilter/ipvs/ip_vs_sync.c | 65 +++++++++++---------
> 8 files changed, 260 insertions(+), 99 deletions(-)
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply
* Re: [PATCH] net: fix rtnl even race in register_netdevice()
From: Kalle Valo @ 2011-05-03 22:13 UTC (permalink / raw)
To: David Miller
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-wireless-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20110429.135339.200375209.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org> writes:
> From: Kalle Valo <kvalo-BkwN83ws05HQT0dZR+AlfA@public.gmane.org>
> Date: Fri, 29 Apr 2011 20:26:34 +0300
>
>> From: Kalle Valo <kalle.valo-DlyHzToyqoxBDgjK7y7TUQ@public.gmane.org>
>>
>> There's a race in register_netdevice so that the rtnl event is sent before
>> the device is actually ready. This was visible with flimflam, chrome os
>> connection manager:
>>
>> 00:21:35 roska flimflamd[2598]: src/udev.c:add_net_device()
>> 00:21:35 roska flimflamd[2598]: connman_inet_ifname: SIOCGIFNAME(index
>> 4): No such device
>> 00:21:45 roska flimflamd[2598]: src/rtnl.c:rtnl_message() buf
>> 0xbfefda3c len 1004
>> 00:21:45 roska flimflamd[2598]: src/rtnl.c:rtnl_message()
>> NEWLINK len 1004 type 16 flags 0x0000 seq 0
[...]
>> The fix is to call netdev_register_kobject() after the device is added
>> to the list.
>>
>> Signed-off-by: Kalle Valo <kalle.valo-DlyHzToyqoxBDgjK7y7TUQ@public.gmane.org>
>
> This is not correct.
>
> If you move the kobject registry around, you have to change the
> error handling cleanup to match.
>
> This change will leave the netdevice on all sorts of lists, it will
> also leak a reference to the device.
>
> I also think this points a fundamental problem with this change, in
> that you can't register the kobject after the device is added to
> the various lists in list_netdevice().
>
> Once it's in those lists, any thread of control can find the device
> and those threads of control may try to get at the data backed by
> the kobject and therefore they really expect it to be there by
> then.
>
> What you can do instead is try to delay the NETREG_REGISTERED
> setting, and block the problematic notifications by testing
> reg_state or similar.
I'm having difficulties to find a proper fix for the race. The uevent
is emitted from device_add() and I don't see how to block the event in
a clean way.
I tried to delay calling device_add() (patch below), but it didn't
work because register_queue_kobjects() expects that the parent device
is already added. I still need to investigate if I can delay creating
(or registering) queue kobjects.
This is a tricky problem and it's very easy to break something. I
would appreciate any help here. Maybe there's a better way to do this?
BTW, I can now easily reproduce the race on my laptop with e1000e and
a small test application. More info here:
https://bugzilla.kernel.org/show_bug.cgi?id=15606#c8
diff --git a/net/core/dev.c b/net/core/dev.c
index c2ac599..8882eaf 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5158,6 +5158,7 @@ static void rollback_registered_many(struct list_head *head)
/* Remove entries from kobject tree */
netdev_unregister_kobject(dev);
+ netdev_del_kobject(dev);
}
/* Process any work delayed until the end of the batch */
@@ -5432,7 +5433,6 @@ int register_netdevice(struct net_device *dev)
ret = netdev_register_kobject(dev);
if (ret)
goto err_uninit;
- dev->reg_state = NETREG_REGISTERED;
netdev_update_features(dev);
@@ -5447,6 +5447,12 @@ int register_netdevice(struct net_device *dev)
dev_hold(dev);
list_netdevice(dev);
+ ret = netdev_add_kobject(dev);
+ if (ret)
+ goto err_unregister;
+
+ dev->reg_state = NETREG_REGISTERED;
+
/* Notify protocols, that a new device appeared. */
ret = call_netdevice_notifiers(NETDEV_REGISTER, dev);
ret = notifier_to_errno(ret);
@@ -5465,6 +5471,9 @@ int register_netdevice(struct net_device *dev)
out:
return ret;
+err_unregister:
+ netdev_unregister_kobject(dev);
+
err_uninit:
if (dev->netdev_ops->ndo_uninit)
dev->netdev_ops->ndo_uninit(dev);
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 5ceb257..db35137 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1303,8 +1303,6 @@ void netdev_unregister_kobject(struct net_device * net)
kobject_get(&dev->kobj);
remove_queue_kobjects(net);
-
- device_del(dev);
}
/* Create sysfs entries for network device. */
@@ -1312,7 +1310,6 @@ int netdev_register_kobject(struct net_device *net)
{
struct device *dev = &(net->dev);
const struct attribute_group **groups = net->sysfs_groups;
- int error = 0;
device_initialize(dev);
dev->class = &net_class;
@@ -1337,17 +1334,21 @@ int netdev_register_kobject(struct net_device *net)
#endif
#endif /* CONFIG_SYSFS */
- error = device_add(dev);
- if (error)
- return error;
+ return register_queue_kobjects(net);
+}
- error = register_queue_kobjects(net);
- if (error) {
- device_del(dev);
- return error;
- }
+void netdev_del_kobject(struct net_device *net)
+{
+ struct device *dev = &(net->dev);
- return error;
+ device_del(dev);
+}
+
+int netdev_add_kobject(struct net_device *net)
+{
+ struct device *dev = &(net->dev);
+
+ return device_add(dev);
}
int netdev_class_create_file(struct class_attribute *class_attr)
diff --git a/net/core/net-sysfs.h b/net/core/net-sysfs.h
index bd7751e..ead06a1 100644
--- a/net/core/net-sysfs.h
+++ b/net/core/net-sysfs.h
@@ -4,6 +4,8 @@
int netdev_kobject_init(void);
int netdev_register_kobject(struct net_device *);
void netdev_unregister_kobject(struct net_device *);
+int netdev_add_kobject(struct net_device *net);
+void netdev_del_kobject(struct net_device *net);
int net_rx_queue_update_kobjects(struct net_device *, int old_num, int new_num);
int netdev_queue_update_kobjects(struct net_device *net,
int old_num, int new_num);
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" 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 related
* Re: [PATCH] ipheth.c: Enable IP header alignment
From: Paul McEnery @ 2011-05-03 22:45 UTC (permalink / raw)
To: David Hill
Cc: L. Alberto Giménez, Ben Hutchings,
linux-kernel@vger.kernel.org, dgiagio@gmail.com, dborca@yahoo.com,
davem@davemloft.net, open list:USB SUBSYSTEM,
open list:NETWORKING DRIVERS
In-Reply-To: <710D4D6CE160654C87478D18385BB9971BE3FDCA5C@MDC-MAIL-CMS01.ubisoft.org>
On 3 May 2011 18:41, David Hill <david.hill@ubisoft.com> wrote:
> That's not a problem, I can test it :)
>
I have applied Ben Hutching's patch [1] to the Github repository [2].
Updated Debian/Ubuntu packages are now available for testing [3].
Please test and report back. I'm sure Ben would also like to know if
this fix work :)
[1] - https://lkml.org/lkml/2011/5/3/283
[2] - https://github.com/dgiagio/ipheth/commit/46d6db65e0054cfae6f7355200b83f04e2fb9042
[3] - https://launchpad.net/~pmcenery/+archive/ppa
^ permalink raw reply
* Re: [net-next 1/5] bnx2x: link report improvements
From: David Miller @ 2011-05-03 23:05 UTC (permalink / raw)
To: dmitry; +Cc: netdev, vladz, eilong
In-Reply-To: <1304429925.19456.11.camel@lb-tlvb-dmitry>
From: "Dmitry Kravkov" <dmitry@broadcom.com>
Date: Tue, 3 May 2011 16:38:45 +0300
> From: Vladislav Zolotarov <vladz@broadcom.com>
>
> To avoid link notification duplications
>
> Signed-off-by: Dmitry Kravkov <dmitry@broadcom.com>
> Signed-off-by: Vladislav Zolotarov <vladz@broadcom.com>
> Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
You go through all of the effort to use atomic bit operations
on the link state statue flags, then do a memcpy() to propagate
new state into the software state structure which is not atomic.
Either it needs to be atomic or it does not.
If it doesn't use __set_bit() and friends and document exactly
what synchronizes and protects access to this object.
^ permalink raw reply
* Re: [net-next 4/5] bnx2x: improve memory handling, low memory recovery flows
From: David Miller @ 2011-05-03 23:07 UTC (permalink / raw)
To: dmitry; +Cc: netdev, eilong
In-Reply-To: <1304429337.19456.5.camel@lb-tlvb-dmitry>
From: "Dmitry Kravkov" <dmitry@broadcom.com>
Date: Tue, 3 May 2011 16:28:57 +0300
>
> +/**
> + * zeros the contents of the bp->fp[index].
> + * Makes sure the contents of the bp->fp[index]. napi is kept
> + * intact.
> + *
> + * @param bp
> + * @param index
> + */
I should have caught this in the past but I've only noticed it right
now.
Do not use your own, custom, format for documenting functions and
their arguments.
Use the standard DocBook comment format we use in the entire kernel.
The last thing we need is every single driver using their own custom
format.
Fix up the existing cases, or remove them completely.
Thanks.
^ 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