* Re: [PATCH net v2] xfrm: Fix crash observed during device unregistration and decryption
From: Steffen Klassert @ 2016-03-23 12:50 UTC (permalink / raw)
To: Subash Abhinov Kasiviswanathan, David Miller
Cc: netdev, 'Herbert Xu', jeromes
In-Reply-To: <001c01d1849b$1c7c98e0$5575caa0$@codeaurora.org>
On Tue, Mar 22, 2016 at 06:29:48PM -0600, Subash Abhinov Kasiviswanathan wrote:
> A crash is observed when a decrypted packet is processed in receive
> path. get_rps_cpus() tries to dereference the skb->dev fields but it
> appears that the device is freed from the poison pattern.
>
> [<ffffffc000af58ec>] get_rps_cpu+0x94/0x2f0
> [<ffffffc000af5f94>] netif_rx_internal+0x140/0x1cc
> [<ffffffc000af6094>] netif_rx+0x74/0x94
> [<ffffffc000bc0b6c>] xfrm_input+0x754/0x7d0
> [<ffffffc000bc0bf8>] xfrm_input_resume+0x10/0x1c
> [<ffffffc000ba6eb8>] esp_input_done+0x20/0x30
> [<ffffffc0000b64c8>] process_one_work+0x244/0x3fc
> [<ffffffc0000b7324>] worker_thread+0x2f8/0x418
> [<ffffffc0000bb40c>] kthread+0xe0/0xec
>
> -013|get_rps_cpu(
> | dev = 0xFFFFFFC08B688000,
> | skb = 0xFFFFFFC0C76AAC00 -> (
> | dev = 0xFFFFFFC08B688000 -> (
> | name =
> "......................................................
> | name_hlist = (next = 0xAAAAAAAAAAAAAAAA, pprev =
> 0xAAAAAAAAAAA
>
> Following are the sequence of events observed -
>
> - Encrypted packet in receive path from netdevice is queued
> - Encrypted packet queued for decryption (asynchronous)
> - Netdevice brought down and freed
> - Packet is decrypted and returned through callback in esp_input_done
> - Packet is queued again for process in network stack using netif_rx
>
> Since the device appears to have been freed, the dereference of
> skb->dev in get_rps_cpus() leads to an unhandled page fault
> exception.
>
> Fix this by holding on to device reference when queueing packets
> asynchronously and releasing the reference on call back return.
>
> v2: Make the change generic to xfrm as mentioned by Steffen and
> update the title to xfrm
>
> Suggested-by: Herbert Xu <herbert@gondor.apana.org.au>
> Signed-off-by: Jerome Stanislaus <jeromes@codeaurora.org>
> Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
Looks good.
David, in case you want to take it directly into the net tree:
Acked-by: Steffen Klassert <steffen.klassert@secunet.com>
^ permalink raw reply
* Re: [patch iproute2 v2 1/2] include: add linked list implementation from kernel
From: Jiri Pirko @ 2016-03-23 13:08 UTC (permalink / raw)
To: David Laight
Cc: netdev@vger.kernel.org, stephen@networkplumber.org,
davem@davemloft.net, idosch@mellanox.com, eladr@mellanox.com,
yotamg@mellanox.com, ogerlitz@mellanox.com, yishaih@mellanox.com,
dledford@redhat.com, sean.hefty@intel.com,
hal.rosenstock@gmail.com, eugenia@mellanox.com,
roopa@cumulusnetworks.com, nikolay@cumulusnetworks.com,
hadarh@mellanox.com, jhs@mojatatu.com, john.fastabend@gmail.com,
"jeffrey.t.kirsher@intel.com" <jeffrey.t.kir
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D41124DBA@AcuExch.aculab.com>
Wed, Mar 23, 2016 at 01:22:22PM CET, David.Laight@ACULAB.COM wrote:
>From: Jiri Pirko
>> Sent: 22 March 2016 09:02
>> Rename hlist.h to list.h while adding it to be aligned with kernel
>...
>> include/hlist.h | 56 ----------------------------
>> include/list.h | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>I'm not sure where this gets installed, but #include <list.h>
>is likely to give grief and find the wrong file.
It does not get installed anywhere.
>
>Even hlist.h seems a bit terse.
>
> David
>
^ permalink raw reply
* Re: [PATCH] at803x: fix reset handling
From: Sergei Shtylyov @ 2016-03-23 13:23 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: netdev, f.fainelli, Daniel Mack
In-Reply-To: <20160323064504.GI6191@pengutronix.de>
On 03/23/2016 09:45 AM, Uwe Kleine-König wrote:
> On Wed, Mar 23, 2016 at 12:44:40AM +0300, Sergei Shtylyov wrote:
>> The driver of course "knows" that the chip's reset signal is active low,
>> so it drives the GPIO to 0 to reset the PHY and to 1 otherwise; however
>> all this will only work iff the GPIO is specified as active-high in the
>> device tree! I think both the driver and the device trees (if there are
>> any -- I was unable to find them) need to be fixed in this case...
>>
>> Fixes: 13a56b449325 ("net: phy: at803x: Add support for hardware reset")
>> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
>>
>> ---
>> The patch is against DaveM's 'net.git' repo.
>
> Don't you need to work against net-next for non-urgent stuff? Or do you
> consider this urgent?
The net-next.git is not for fixes, net.git is. And net-next is closed
right now because of the merge window.
>> drivers/net/phy/at803x.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> Index: net/drivers/net/phy/at803x.c
>> ===================================================================
>> --- net.orig/drivers/net/phy/at803x.c
>> +++ net/drivers/net/phy/at803x.c
>> @@ -277,7 +277,7 @@ static int at803x_probe(struct phy_devic
>> if (!priv)
>> return -ENOMEM;
>>
>> - gpiod_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
>> + gpiod_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
>> if (IS_ERR(gpiod_reset))
>> return PTR_ERR(gpiod_reset);
>>
>> @@ -362,10 +362,10 @@ static void at803x_link_change_notify(st
>>
>> at803x_context_save(phydev, &context);
>>
>> - gpiod_set_value(priv->gpiod_reset, 0);
>> - msleep(1);
>> gpiod_set_value(priv->gpiod_reset, 1);
>> msleep(1);
>> + gpiod_set_value(priv->gpiod_reset, 0);
>> + msleep(1);
>
> The new variant is better than the old one. The change however breaks
> existing device trees which is not so nice. Given there are no mainline
> users this is probably ok though. So:
>
> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Thank you!
MBR, Sergei
^ permalink raw reply
* Re: [PATCH net v2] xfrm: Fix crash observed during device unregistration and decryption
From: Eric Dumazet @ 2016-03-23 13:25 UTC (permalink / raw)
To: Subash Abhinov Kasiviswanathan
Cc: 'Steffen Klassert', netdev, 'Herbert Xu', jeromes
In-Reply-To: <001c01d1849b$1c7c98e0$5575caa0$@codeaurora.org>
On Tue, 2016-03-22 at 18:29 -0600, Subash Abhinov Kasiviswanathan wrote:
> A crash is observed when a decrypted packet is processed in receive
> path. get_rps_cpus() tries to dereference the skb->dev fields but it
> appears that the device is freed from the poison pattern.
>
> [<ffffffc000af58ec>] get_rps_cpu+0x94/0x2f0
> [<ffffffc000af5f94>] netif_rx_internal+0x140/0x1cc
> [<ffffffc000af6094>] netif_rx+0x74/0x94
> [<ffffffc000bc0b6c>] xfrm_input+0x754/0x7d0
> [<ffffffc000bc0bf8>] xfrm_input_resume+0x10/0x1c
> [<ffffffc000ba6eb8>] esp_input_done+0x20/0x30
> [<ffffffc0000b64c8>] process_one_work+0x244/0x3fc
> [<ffffffc0000b7324>] worker_thread+0x2f8/0x418
> [<ffffffc0000bb40c>] kthread+0xe0/0xec
>
> -013|get_rps_cpu(
> | dev = 0xFFFFFFC08B688000,
> | skb = 0xFFFFFFC0C76AAC00 -> (
> | dev = 0xFFFFFFC08B688000 -> (
> | name =
> "......................................................
> | name_hlist = (next = 0xAAAAAAAAAAAAAAAA, pprev =
> 0xAAAAAAAAAAA
>
> Following are the sequence of events observed -
>
> - Encrypted packet in receive path from netdevice is queued
> - Encrypted packet queued for decryption (asynchronous)
> - Netdevice brought down and freed
> - Packet is decrypted and returned through callback in esp_input_done
> - Packet is queued again for process in network stack using netif_rx
>
> Since the device appears to have been freed, the dereference of
> skb->dev in get_rps_cpus() leads to an unhandled page fault
> exception.
>
> Fix this by holding on to device reference when queueing packets
> asynchronously and releasing the reference on call back return.
>
> v2: Make the change generic to xfrm as mentioned by Steffen and
> update the title to xfrm
>
> Suggested-by: Herbert Xu <herbert@gondor.apana.org.au>
> Signed-off-by: Jerome Stanislaus <jeromes@codeaurora.org>
> Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
> ---
> net/xfrm/xfrm_input.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
> index ad7f5b3..1c4ad47 100644
> --- a/net/xfrm/xfrm_input.c
> +++ b/net/xfrm/xfrm_input.c
> @@ -292,12 +292,15 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32
> spi, int encap_type)
> XFRM_SKB_CB(skb)->seq.input.hi = seq_hi;
>
> skb_dst_force(skb);
> + dev_hold(skb->dev);
>
> nexthdr = x->type->input(x, skb);
>
> if (nexthdr == -EINPROGRESS)
> return 0;
> resume:
> + dev_put(skb->dev);
> +
> spin_lock(&x->lock);
> if (nexthdr <= 0) {
> if (nexthdr == -EBADMSG) {
> --
>
Wont this prevent device from being dismantled ?
Where is this xfrm queue purged at device dismantle ?
dev_put() is probably missing, if you add a dev_hold() for every packet
in it.
^ permalink raw reply
* Re: [Y2038] [PATCH v2] prism54: isl_38xx: Replace 'struct timeval'
From: Arnd Bergmann @ 2016-03-23 13:28 UTC (permalink / raw)
To: y2038; +Cc: Tina Ruchandani, Kalle Valo, netdev, linux-wireless, linux-kernel
In-Reply-To: <20160322221615.GA55727@localhost>
On Tuesday 22 March 2016 15:16:15 Tina Ruchandani wrote:
> 'struct timeval' uses a 32-bit seconds field which will overflow in
> year 2038 and beyond. This patch is part of a larger effort to remove
> all instances of 'struct timeval' from the kernel and replace them
> with 64-bit timekeeping variables.
> The correctness of the code isn't affected by this patch - the seconds
> value being printed would earlier be wrong due to overflow in timeval,
> and now it gets truncated to 32-bit due to the 'long' cast used on
> tv.sec field to prevent compiler warnings. Truly fixing this would
> require changing the debug print to print more than 8 digits and
> use a different specifier from %li.
> The patch was build-tested / debugged by removing the
> "if VERBOSE > SHOW_ERROR_MESSAGES" guards.
>
> Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> --
> Changes in v2:
> - Changed printf specifier as suggested by Arnd Bergmann to
> avoid truncation.
>
The patch looks great now, but it no longer matches the description,
as you actually fix the correctness.
Arnd
^ permalink raw reply
* Re: [PATCH net v2] xfrm: Fix crash observed during device unregistration and decryption
From: Herbert Xu @ 2016-03-23 13:29 UTC (permalink / raw)
To: Eric Dumazet
Cc: Subash Abhinov Kasiviswanathan, 'Steffen Klassert',
netdev, jeromes
In-Reply-To: <1458739547.10868.37.camel@edumazet-glaptop3.roam.corp.google.com>
On Wed, Mar 23, 2016 at 06:25:47AM -0700, Eric Dumazet wrote:
>
> Wont this prevent device from being dismantled ?
This is only held while the crypto processing is ongoing.
> Where is this xfrm queue purged at device dismantle ?
There is no way to cancel an ongoing crypto processing so you'll
just have to wait it out.
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* Re: [PATCH] at803x: fix reset handling
From: Sergei Shtylyov @ 2016-03-23 13:30 UTC (permalink / raw)
To: Daniel Mack, Uwe Kleine-König; +Cc: netdev, f.fainelli, Daniel Mack
In-Reply-To: <56F2847B.5090904@zonque.org>
Hello.
On 03/23/2016 02:56 PM, Daniel Mack wrote:
>> I added the author of 13a56b449325 to Cc.
> Thanks for doing that!
I forgot to do it, sorry.
>> On Wed, Mar 23, 2016 at 12:44:40AM +0300, Sergei Shtylyov wrote:
>>> The driver of course "knows" that the chip's reset signal is active low,
>>> so it drives the GPIO to 0 to reset the PHY and to 1 otherwise; however
>>> all this will only work iff the GPIO is specified as active-high in the
>>> device tree! I think both the driver and the device trees (if there are
>>> any -- I was unable to find them) need to be fixed in this case...
>
> Well, the driver asserts the line by setting it to 1, while in fact the
Contariwise, it sets GPIO to 0 to assert the reset signal.
> chip itself considers 'low' as 'asserted'.
My Micrel chips do that as well...
> Hence I opted for flipping the logic in DT rather than in the driver core.
So did you use GPIO_ACTIVE_LOW or _HIGH in the device tree? AFAIU, only
the latter ould work with this patch, but it'll be in error.
> IIRC, there was even
> some sort of level-shifting inversion going on in our design, but I
> don't recall the details.
>
> That said, I don't care much. If the general assumption is to make the
> driver calls match the actual output on the peripheral,
They seem to do now, but that doesn't fly well with the modern gpiolob
where you can declare the active-low/high for each GPIO, so that gpiolib would
automatically invert the value for the active-low pins.
> then fine, let's
> turn it around, but that's a matter of interpretation IMO.
>>> Fixes: 13a56b449325 ("net: phy: at803x: Add support for hardware reset")
>>> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
>>>
>>> ---
>>> The patch is against DaveM's 'net.git' repo.
>>
>> Don't you need to work against net-next for non-urgent stuff? Or do you
>> consider this urgent?
>
> It's certainly not :)
>
>> The new variant is better than the old one. The change however breaks
>> existing device trees which is not so nice. Given there are no mainline
>> users this is probably ok though. So:
>
> Hmm, one idea for DT was to allow for external board support via DTB
> files, right? Then again, bindings breaks happen all the time anyway.
Contrariwise, the drivers are supposed to be able to work with older .dtb
files... but if we have out-of-tree .dtb's to consider only, our hands are
untied then.
> As far as I'm concerned, I'm fine with the change. If it lands, I'll
> simply give my colleagues a short heads-up so they can flip the bit on
> their side too.
Thank you. :-)
> Thanks,
> Daniel
MBR, Sergei
^ permalink raw reply
* [PATCH] net: Fix typos and whitespace.
From: Bjorn Helgaas @ 2016-03-23 13:45 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, linux-kernel
Fix typos. Capitalize CPU, NAPI, RCU consistently. Align structure
indentation. No functional change intended; only comment and whitespace
changes.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
include/linux/netdevice.h | 215 ++++++++++++++++++++++-----------------------
1 file changed, 106 insertions(+), 109 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 009c85a..45e980e 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -81,8 +81,8 @@ void netdev_set_default_ethtool_ops(struct net_device *dev,
* function. Real network devices commonly used with qdiscs should only return
* the driver transmit return codes though - when qdiscs are used, the actual
* transmission happens asynchronously, so the value is not propagated to
- * higher layers. Virtual network devices transmit synchronously, in this case
- * the driver transmit return codes are consumed by dev_queue_xmit(), all
+ * higher layers. Virtual network devices transmit synchronously; in this case
+ * the driver transmit return codes are consumed by dev_queue_xmit(), and all
* others are propagated to higher layers.
*/
@@ -129,7 +129,7 @@ static inline bool dev_xmit_complete(int rc)
}
/*
- * Compute the worst case header length according to the protocols
+ * Compute the worst-case header length according to the protocols
* used.
*/
@@ -246,7 +246,7 @@ struct hh_cache {
unsigned long hh_data[HH_DATA_ALIGN(LL_MAX_HEADER) / sizeof(long)];
};
-/* Reserve HH_DATA_MOD byte aligned hard_header_len, but at least that much.
+/* Reserve HH_DATA_MOD byte-aligned hard_header_len, but at least that much.
* Alternative is:
* dev->hard_header_len ? (dev->hard_header_len +
* (HH_DATA_MOD - 1)) & ~(HH_DATA_MOD - 1) : 0
@@ -272,7 +272,7 @@ struct header_ops {
};
/* These flag bits are private to the generic network queueing
- * layer, they may not be explicitly referenced by any other
+ * layer; they may not be explicitly referenced by any other
* code.
*/
@@ -286,7 +286,7 @@ enum netdev_state_t {
/*
- * This structure holds at boot time configured netdevice settings. They
+ * This structure holds boot-time configured netdevice settings. They
* are then used in the device probing.
*/
struct netdev_boot_setup {
@@ -304,7 +304,7 @@ struct napi_struct {
/* The poll_list must only be managed by the entity which
* changes the state of the NAPI_STATE_SCHED bit. This means
* whoever atomically sets that bit can add this napi_struct
- * to the per-cpu poll_list, and whoever clears that bit
+ * to the per-CPU poll_list, and whoever clears that bit
* can remove from the list right before clearing the bit.
*/
struct list_head poll_list;
@@ -350,7 +350,7 @@ typedef enum gro_result gro_result_t;
* @RX_HANDLER_ANOTHER: Do another round in receive path. This is indicated in
* case skb->dev was changed by rx_handler.
* @RX_HANDLER_EXACT: Force exact delivery, no wildcard.
- * @RX_HANDLER_PASS: Do nothing, passe the skb as if no rx_handler was called.
+ * @RX_HANDLER_PASS: Do nothing, pass the skb as if no rx_handler was called.
*
* rx_handlers are functions called from inside __netif_receive_skb(), to do
* special processing of the skb, prior to delivery to protocol handlers.
@@ -365,19 +365,19 @@ typedef enum gro_result gro_result_t;
* Upon return, rx_handler is expected to tell __netif_receive_skb() what to
* do with the skb.
*
- * If the rx_handler consumed to skb in some way, it should return
+ * If the rx_handler consumed the skb in some way, it should return
* RX_HANDLER_CONSUMED. This is appropriate when the rx_handler arranged for
- * the skb to be delivered in some other ways.
+ * the skb to be delivered in some other way.
*
* If the rx_handler changed skb->dev, to divert the skb to another
* net_device, it should return RX_HANDLER_ANOTHER. The rx_handler for the
* new device will be called if it exists.
*
- * If the rx_handler consider the skb should be ignored, it should return
+ * If the rx_handler decides the skb should be ignored, it should return
* RX_HANDLER_EXACT. The skb will only be delivered to protocol handlers that
* are registered on exact device (ptype->dev == skb->dev).
*
- * If the rx_handler didn't changed skb->dev, but want the skb to be normally
+ * If the rx_handler didn't change skb->dev, but wants the skb to be normally
* delivered, it should return RX_HANDLER_PASS.
*
* A device without a registered rx_handler will behave as if rx_handler
@@ -402,11 +402,11 @@ static inline bool napi_disable_pending(struct napi_struct *n)
}
/**
- * napi_schedule_prep - check if napi can be scheduled
- * @n: napi context
+ * napi_schedule_prep - check if NAPI can be scheduled
+ * @n: NAPI context
*
* Test if NAPI routine is already running, and if not mark
- * it as running. This is used as a condition variable
+ * it as running. This is used as a condition variable to
* insure only one NAPI poll instance runs. We also make
* sure there is no pending NAPI disable.
*/
@@ -418,7 +418,7 @@ static inline bool napi_schedule_prep(struct napi_struct *n)
/**
* napi_schedule - schedule NAPI poll
- * @n: napi context
+ * @n: NAPI context
*
* Schedule NAPI poll routine to be called if it is not already
* running.
@@ -431,7 +431,7 @@ static inline void napi_schedule(struct napi_struct *n)
/**
* napi_schedule_irqoff - schedule NAPI poll
- * @n: napi context
+ * @n: NAPI context
*
* Variant of napi_schedule(), assuming hard irqs are masked.
*/
@@ -455,7 +455,7 @@ void __napi_complete(struct napi_struct *n);
void napi_complete_done(struct napi_struct *n, int work_done);
/**
* napi_complete - NAPI processing complete
- * @n: napi context
+ * @n: NAPI context
*
* Mark NAPI processing as complete.
* Consider using napi_complete_done() instead.
@@ -467,32 +467,32 @@ static inline void napi_complete(struct napi_struct *n)
/**
* napi_hash_add - add a NAPI to global hashtable
- * @napi: napi context
+ * @napi: NAPI context
*
- * generate a new napi_id and store a @napi under it in napi_hash
- * Used for busy polling (CONFIG_NET_RX_BUSY_POLL)
+ * Generate a new napi_id and store a @napi under it in napi_hash.
+ * Used for busy polling (CONFIG_NET_RX_BUSY_POLL).
* Note: This is normally automatically done from netif_napi_add(),
- * so might disappear in a future linux version.
+ * so might disappear in a future Linux version.
*/
void napi_hash_add(struct napi_struct *napi);
/**
* napi_hash_del - remove a NAPI from global table
- * @napi: napi context
+ * @napi: NAPI context
*
- * Warning: caller must observe rcu grace period
+ * Warning: caller must observe RCU grace period
* before freeing memory containing @napi, if
* this function returns true.
* Note: core networking stack automatically calls it
- * from netif_napi_del()
+ * from netif_napi_del().
* Drivers might want to call this helper to combine all
- * the needed rcu grace periods into a single one.
+ * the needed RCU grace periods into a single one.
*/
bool napi_hash_del(struct napi_struct *napi);
/**
* napi_disable - prevent NAPI from scheduling
- * @n: napi context
+ * @n: NAPI context
*
* Stop NAPI from being scheduled on this context.
* Waits till any outstanding processing completes.
@@ -501,7 +501,7 @@ void napi_disable(struct napi_struct *n);
/**
* napi_enable - enable NAPI scheduling
- * @n: napi context
+ * @n: NAPI context
*
* Resume NAPI from being scheduled on this context.
* Must be paired with napi_disable.
@@ -516,7 +516,7 @@ static inline void napi_enable(struct napi_struct *n)
/**
* napi_synchronize - wait until NAPI is not running
- * @n: napi context
+ * @n: NAPI context
*
* Wait until NAPI is done being scheduled on this context.
* Waits till any outstanding processing completes but
@@ -559,7 +559,7 @@ enum netdev_queue_state_t {
struct netdev_queue {
/*
- * read mostly part
+ * read-mostly part
*/
struct net_device *dev;
struct Qdisc __rcu *qdisc;
@@ -571,7 +571,7 @@ struct netdev_queue {
int numa_node;
#endif
/*
- * write mostly part
+ * write-mostly part
*/
spinlock_t _xmit_lock ____cacheline_aligned_in_smp;
int xmit_lock_owner;
@@ -648,11 +648,11 @@ struct rps_dev_flow_table {
/*
* The rps_sock_flow_table contains mappings of flows to the last CPU
* on which they were processed by the application (set in recvmsg).
- * Each entry is a 32bit value. Upper part is the high order bits
- * of flow hash, lower part is cpu number.
+ * Each entry is a 32bit value. Upper part is the high-order bits
+ * of flow hash, lower part is CPU number.
* rps_cpu_mask is used to partition the space, depending on number of
- * possible cpus : rps_cpu_mask = roundup_pow_of_two(nr_cpu_ids) - 1
- * For example, if 64 cpus are possible, rps_cpu_mask = 0x3f,
+ * possible CPUs : rps_cpu_mask = roundup_pow_of_two(nr_cpu_ids) - 1
+ * For example, if 64 CPUs are possible, rps_cpu_mask = 0x3f,
* meaning we use 32-6=26 bits for the hash.
*/
struct rps_sock_flow_table {
@@ -674,7 +674,7 @@ static inline void rps_record_sock_flow(struct rps_sock_flow_table *table,
unsigned int index = hash & table->mask;
u32 val = hash & ~rps_cpu_mask;
- /* We only give a hint, preemption can change cpu under us */
+ /* We only give a hint, preemption can change CPU under us */
val |= raw_smp_processor_id();
if (table->ents[index] != val)
@@ -807,21 +807,21 @@ struct tc_to_netdev {
* optional and can be filled with a null pointer.
*
* int (*ndo_init)(struct net_device *dev);
- * This function is called once when network device is registered.
- * The network device can use this to any late stage initializaton
- * or semantic validattion. It can fail with an error code which will
- * be propogated back to register_netdev
+ * This function is called once when a network device is registered.
+ * The network device can use this for any late stage initialization
+ * or semantic validation. It can fail with an error code which will
+ * be propagated back to register_netdev.
*
* void (*ndo_uninit)(struct net_device *dev);
* This function is called when device is unregistered or when registration
* fails. It is not called if init fails.
*
* int (*ndo_open)(struct net_device *dev);
- * This function is called when network device transistions to the up
+ * This function is called when a network device transitions to the up
* state.
*
* int (*ndo_stop)(struct net_device *dev);
- * This function is called when network device transistions to the down
+ * This function is called when a network device transitions to the down
* state.
*
* netdev_tx_t (*ndo_start_xmit)(struct sk_buff *skb,
@@ -832,7 +832,7 @@ struct tc_to_netdev {
* corner cases, but the stack really does a non-trivial amount
* of useless work if you return NETDEV_TX_BUSY.
* (can also return NETDEV_TX_LOCKED iff NETIF_F_LLTX)
- * Required can not be NULL.
+ * Required; cannot be NULL.
*
* netdev_features_t (*ndo_fix_features)(struct net_device *dev,
* netdev_features_t features);
@@ -842,34 +842,34 @@ struct tc_to_netdev {
*
* u16 (*ndo_select_queue)(struct net_device *dev, struct sk_buff *skb,
* void *accel_priv, select_queue_fallback_t fallback);
- * Called to decide which queue to when device supports multiple
+ * Called to decide which queue to use when device supports multiple
* transmit queues.
*
* void (*ndo_change_rx_flags)(struct net_device *dev, int flags);
* This function is called to allow device receiver to make
- * changes to configuration when multicast or promiscious is enabled.
+ * changes to configuration when multicast or promiscuous is enabled.
*
* void (*ndo_set_rx_mode)(struct net_device *dev);
* This function is called device changes address list filtering.
* If driver handles unicast address filtering, it should set
- * IFF_UNICAST_FLT to its priv_flags.
+ * IFF_UNICAST_FLT in its priv_flags.
*
* int (*ndo_set_mac_address)(struct net_device *dev, void *addr);
* This function is called when the Media Access Control address
* needs to be changed. If this interface is not defined, the
- * mac address can not be changed.
+ * MAC address can not be changed.
*
* int (*ndo_validate_addr)(struct net_device *dev);
* Test if Media Access Control address is valid for the device.
*
* int (*ndo_do_ioctl)(struct net_device *dev, struct ifreq *ifr, int cmd);
- * Called when a user request an ioctl which can't be handled by
- * the generic interface code. If not defined ioctl's return
+ * Called when a user requests an ioctl which can't be handled by
+ * the generic interface code. If not defined ioctls return
* not supported error code.
*
* int (*ndo_set_config)(struct net_device *dev, struct ifmap *map);
* Used to set network devices bus interface parameters. This interface
- * is retained for legacy reason, new devices should use the bus
+ * is retained for legacy reasons; new devices should use the bus
* interface (PCI) for low level management.
*
* int (*ndo_change_mtu)(struct net_device *dev, int new_mtu);
@@ -878,7 +878,7 @@ struct tc_to_netdev {
* will return an error.
*
* void (*ndo_tx_timeout)(struct net_device *dev);
- * Callback uses when the transmitter has not made any progress
+ * Callback used when the transmitter has not made any progress
* for dev->watchdog ticks.
*
* struct rtnl_link_stats64* (*ndo_get_stats64)(struct net_device *dev,
@@ -896,11 +896,11 @@ struct tc_to_netdev {
* neither operation.
*
* int (*ndo_vlan_rx_add_vid)(struct net_device *dev, __be16 proto, u16 vid);
- * If device support VLAN filtering this function is called when a
+ * If device supports VLAN filtering this function is called when a
* VLAN id is registered.
*
* int (*ndo_vlan_rx_kill_vid)(struct net_device *dev, __be16 proto, u16 vid);
- * If device support VLAN filtering this function is called when a
+ * If device supports VLAN filtering this function is called when a
* VLAN id is unregistered.
*
* void (*ndo_poll_controller)(struct net_device *dev);
@@ -920,7 +920,7 @@ struct tc_to_netdev {
*
* Enable or disable the VF ability to query its RSS Redirection Table and
* Hash Key. This is needed since on some devices VF share this information
- * with PF and querying it may adduce a theoretical security risk.
+ * with PF and querying it may introduce a theoretical security risk.
* int (*ndo_set_vf_rss_query_en)(struct net_device *dev, int vf, bool setting);
* int (*ndo_get_vf_port)(struct net_device *dev, int vf, struct sk_buff *skb);
* int (*ndo_setup_tc)(struct net_device *dev, u8 tc)
@@ -1030,20 +1030,20 @@ struct tc_to_netdev {
*
* void (*ndo_add_vxlan_port)(struct net_device *dev,
* sa_family_t sa_family, __be16 port);
- * Called by vxlan to notiy a driver about the UDP port and socket
- * address family that vxlan is listnening to. It is called only when
+ * Called by vxlan to notify a driver about the UDP port and socket
+ * address family that vxlan is listening to. It is called only when
* a new port starts listening. The operation is protected by the
* vxlan_net->sock_lock.
*
* void (*ndo_add_geneve_port)(struct net_device *dev,
- * sa_family_t sa_family, __be16 port);
+ * sa_family_t sa_family, __be16 port);
* Called by geneve to notify a driver about the UDP port and socket
* address family that geneve is listnening to. It is called only when
* a new port starts listening. The operation is protected by the
* geneve_net->sock_lock.
*
* void (*ndo_del_geneve_port)(struct net_device *dev,
- * sa_family_t sa_family, __be16 port);
+ * sa_family_t sa_family, __be16 port);
* Called by geneve to notify the driver about a UDP port and socket
* address family that geneve is not listening to anymore. The operation
* is protected by the geneve_net->sock_lock.
@@ -1072,9 +1072,9 @@ struct tc_to_netdev {
* Callback to use for xmit over the accelerated station. This
* is used in place of ndo_start_xmit on accelerated net
* devices.
- * netdev_features_t (*ndo_features_check) (struct sk_buff *skb,
- * struct net_device *dev
- * netdev_features_t features);
+ * netdev_features_t (*ndo_features_check)(struct sk_buff *skb,
+ * struct net_device *dev
+ * netdev_features_t features);
* Called by core transmit path to determine if device is capable of
* performing offload operations on a given packet. This is to give
* the device an opportunity to implement any restrictions that cannot
@@ -1088,7 +1088,7 @@ struct tc_to_netdev {
* int (*ndo_get_iflink)(const struct net_device *dev);
* Called to get the iflink value of this device.
* void (*ndo_change_proto_down)(struct net_device *dev,
- * bool proto_down);
+ * bool proto_down);
* This function is used to pass protocol port error state information
* to the switch driver. The switch driver can react to the proto_down
* by doing a phys down on the associated switch port.
@@ -1100,7 +1100,7 @@ struct tc_to_netdev {
* This function is used to specify the headroom that the skb must
* consider when allocation skb during packet reception. Setting
* appropriate rx headroom value allows avoiding skb head copy on
- * forward. Setting a negative value reset the rx headroom to the
+ * forward. Setting a negative value resets the rx headroom to the
* default value.
*
*/
@@ -1299,7 +1299,7 @@ struct net_device_ops {
*
* These are the &struct net_device, they are only set internally
* by drivers and used in the kernel. These flags are invisible to
- * userspace, this means that the order of these flags can change
+ * userspace; this means that the order of these flags can change
* during any kernel release.
*
* You should have a pretty good reason to be extending these flags.
@@ -1413,10 +1413,10 @@ enum netdev_priv_flags {
*
* @state: Generic network queuing layer state, see netdev_state_t
* @dev_list: The global list of network devices
- * @napi_list: List entry, that is used for polling napi devices
- * @unreg_list: List entry, that is used, when we are unregistering the
- * device, see the function unregister_netdev
- * @close_list: List entry, that is used, when we are closing the device
+ * @napi_list: List entry used for polling NAPI devices
+ * @unreg_list: List entry used when we are unregistering the
+ * device; see the function unregister_netdev()
+ * @close_list: List entry used when we are closing the device
*
* @adj_list: Directly linked devices, like slaves for bonding
* @all_adj_list: All linked devices, *including* neighbours
@@ -1434,7 +1434,7 @@ enum netdev_priv_flags {
* @mpls_features: Mask of features inheritable by MPLS
*
* @ifindex: interface index
- * @group: The group, that the device belongs to
+ * @group: The group the device belongs to
*
* @stats: Statistics struct, which was left as a legacy, use
* rtnl_link_stats64 instead
@@ -1488,7 +1488,7 @@ enum netdev_priv_flags {
* @dev_port: Used to differentiate devices that share
* the same function
* @addr_list_lock: XXX: need comments on this one
- * @uc_promisc: Counter, that indicates, that promiscuous mode
+ * @uc_promisc: Counter that indicates promiscuous mode
* has been enabled due to the need to listen to
* additional unicast addresses in a device that
* does not implement ndo_set_rx_mode()
@@ -1496,9 +1496,9 @@ enum netdev_priv_flags {
* @mc: multicast mac addresses
* @dev_addrs: list of device hw addresses
* @queues_kset: Group of all Kobjects in the Tx and RX queues
- * @promiscuity: Number of times, the NIC is told to work in
- * Promiscuous mode, if it becomes 0 the NIC will
- * exit from working in Promiscuous mode
+ * @promiscuity: Number of times the NIC is told to work in
+ * promiscuous mode; if it becomes 0 the NIC will
+ * exit promiscuous mode
* @allmulti: Counter, enables or disables allmulticast mode
*
* @vlan_info: VLAN info
@@ -1544,7 +1544,7 @@ enum netdev_priv_flags {
*
* @trans_start: Time (in jiffies) of last Tx
* @watchdog_timeo: Represents the timeout that is used by
- * the watchdog ( see dev_watchdog() )
+ * the watchdog (see dev_watchdog())
* @watchdog_timer: List of timers
*
* @pcpu_refcnt: Number of references to this device
@@ -1661,8 +1661,8 @@ struct net_device {
atomic_long_t rx_nohandler;
#ifdef CONFIG_WIRELESS_EXT
- const struct iw_handler_def * wireless_handlers;
- struct iw_public_data * wireless_data;
+ const struct iw_handler_def *wireless_handlers;
+ struct iw_public_data *wireless_data;
#endif
const struct net_device_ops *netdev_ops;
const struct ethtool_ops *ethtool_ops;
@@ -1715,7 +1715,7 @@ struct net_device {
unsigned int allmulti;
- /* Protocol specific pointers */
+ /* Protocol-specific pointers */
#if IS_ENABLED(CONFIG_VLAN_8021Q)
struct vlan_info __rcu *vlan_info;
@@ -1745,13 +1745,11 @@ struct net_device {
/* Interface address info used in eth_type_trans() */
unsigned char *dev_addr;
-
#ifdef CONFIG_SYSFS
struct netdev_rx_queue *_rx;
unsigned int num_rx_queues;
unsigned int real_num_rx_queues;
-
#endif
unsigned long gro_flush_timeout;
@@ -1843,7 +1841,7 @@ struct net_device {
struct garp_port __rcu *garp_port;
struct mrp_port __rcu *mrp_port;
- struct device dev;
+ struct device dev;
const struct attribute_group *sysfs_groups[4];
const struct attribute_group *sysfs_rx_queue_group;
@@ -1858,9 +1856,9 @@ struct net_device {
#ifdef CONFIG_DCB
const struct dcbnl_rtnl_ops *dcbnl_ops;
#endif
- u8 num_tc;
- struct netdev_tc_txq tc_to_txq[TC_MAX_QUEUE];
- u8 prio_tc_map[TC_BITMASK + 1];
+ u8 num_tc;
+ struct netdev_tc_txq tc_to_txq[TC_MAX_QUEUE];
+ u8 prio_tc_map[TC_BITMASK + 1];
#if IS_ENABLED(CONFIG_FCOE)
unsigned int fcoe_ddp_xid;
@@ -1868,9 +1866,9 @@ struct net_device {
#if IS_ENABLED(CONFIG_CGROUP_NET_PRIO)
struct netprio_map __rcu *priomap;
#endif
- struct phy_device *phydev;
- struct lock_class_key *qdisc_tx_busylock;
- bool proto_down;
+ struct phy_device *phydev;
+ struct lock_class_key *qdisc_tx_busylock;
+ bool proto_down;
};
#define to_net_dev(d) container_of(d, struct net_device, dev)
@@ -2018,7 +2016,7 @@ static inline void *netdev_priv(const struct net_device *dev)
/* Set the sysfs device type for the network logical device to allow
* fine-grained identification of different network device types. For
- * example Ethernet, Wirelss LAN, Bluetooth, WiMAX etc.
+ * example Ethernet, Wireless LAN, Bluetooth, WiMAX etc.
*/
#define SET_NETDEV_DEVTYPE(net, devtype) ((net)->dev.type = (devtype))
@@ -2028,22 +2026,22 @@ static inline void *netdev_priv(const struct net_device *dev)
#define NAPI_POLL_WEIGHT 64
/**
- * netif_napi_add - initialize a napi context
+ * netif_napi_add - initialize a NAPI context
* @dev: network device
- * @napi: napi context
+ * @napi: NAPI context
* @poll: polling function
* @weight: default weight
*
- * netif_napi_add() must be used to initialize a napi context prior to calling
- * *any* of the other napi related functions.
+ * netif_napi_add() must be used to initialize a NAPI context prior to calling
+ * *any* of the other NAPI-related functions.
*/
void netif_napi_add(struct net_device *dev, struct napi_struct *napi,
int (*poll)(struct napi_struct *, int), int weight);
/**
- * netif_tx_napi_add - initialize a napi context
+ * netif_tx_napi_add - initialize a NAPI context
* @dev: network device
- * @napi: napi context
+ * @napi: NAPI context
* @poll: polling function
* @weight: default weight
*
@@ -2061,22 +2059,22 @@ static inline void netif_tx_napi_add(struct net_device *dev,
}
/**
- * netif_napi_del - remove a napi context
- * @napi: napi context
+ * netif_napi_del - remove a NAPI context
+ * @napi: NAPI context
*
- * netif_napi_del() removes a napi context from the network device napi list
+ * netif_napi_del() removes a NAPI context from the network device NAPI list
*/
void netif_napi_del(struct napi_struct *napi);
struct napi_gro_cb {
/* Virtual address of skb_shinfo(skb)->frags[0].page + offset. */
- void *frag0;
+ void *frag0;
/* Length of frag0. */
unsigned int frag0_len;
/* This indicates where we are processing relative to skb->data. */
- int data_offset;
+ int data_offset;
/* This is non-zero if the packet cannot be merged with the new skb. */
u16 flush;
@@ -2172,7 +2170,7 @@ struct udp_offload {
struct udp_offload_callbacks callbacks;
};
-/* often modified stats are per cpu, other are shared (netdev->stats) */
+/* often modified stats are per-CPU, other are shared (netdev->stats) */
struct pcpu_sw_netstats {
u64 rx_packets;
u64 rx_bytes;
@@ -2269,7 +2267,7 @@ struct netdev_notifier_changeupper_info {
struct netdev_notifier_info info; /* must be first */
struct net_device *upper_dev; /* new upper dev */
bool master; /* is upper dev master */
- bool linking; /* is the nofication for link or unlink */
+ bool linking; /* is the notification for link or unlink */
void *upper_info; /* upper dev info */
};
@@ -2734,7 +2732,7 @@ extern int netdev_flow_limit_table_len;
#endif /* CONFIG_NET_FLOW_LIMIT */
/*
- * Incoming packets are placed on per-cpu queues
+ * Incoming packets are placed on per-CPU queues
*/
struct softnet_data {
struct list_head poll_list;
@@ -2904,7 +2902,7 @@ netif_xmit_frozen_or_drv_stopped(const struct netdev_queue *dev_queue)
* @dev_queue: pointer to transmit queue
*
* BQL enabled drivers might use this helper in their ndo_start_xmit(),
- * to give appropriate hint to the cpu.
+ * to give appropriate hint to the CPU.
*/
static inline void netdev_txq_bql_enqueue_prefetchw(struct netdev_queue *dev_queue)
{
@@ -2918,7 +2916,7 @@ static inline void netdev_txq_bql_enqueue_prefetchw(struct netdev_queue *dev_que
* @dev_queue: pointer to transmit queue
*
* BQL enabled drivers might use this helper in their TX completion path,
- * to give appropriate hint to the cpu.
+ * to give appropriate hint to the CPU.
*/
static inline void netdev_txq_bql_complete_prefetchw(struct netdev_queue *dev_queue)
{
@@ -3057,7 +3055,7 @@ static inline bool netif_running(const struct net_device *dev)
}
/*
- * Routines to manage the subqueues on a device. We only need start
+ * Routines to manage the subqueues on a device. We only need start,
* stop, and a check if it's stopped. All other device management is
* done at the overall netdevice level.
* Also test the device if we're multiqueue.
@@ -3341,7 +3339,6 @@ void netif_carrier_off(struct net_device *dev);
* in a "pending" state, waiting for some external event. For "on-
* demand" interfaces, this new state identifies the situation where the
* interface is waiting for events to place it in the up state.
- *
*/
static inline void netif_dormant_on(struct net_device *dev)
{
@@ -3676,7 +3673,7 @@ void dev_uc_init(struct net_device *dev);
*
* Add newly added addresses to the interface, and release
* addresses that have been deleted.
- **/
+ */
static inline int __dev_uc_sync(struct net_device *dev,
int (*sync)(struct net_device *,
const unsigned char *),
@@ -3692,7 +3689,7 @@ static inline int __dev_uc_sync(struct net_device *dev,
* @unsync: function to call if address should be removed
*
* Remove all addresses that were added to the device by dev_uc_sync().
- **/
+ */
static inline void __dev_uc_unsync(struct net_device *dev,
int (*unsync)(struct net_device *,
const unsigned char *))
@@ -3720,7 +3717,7 @@ void dev_mc_init(struct net_device *dev);
*
* Add newly added addresses to the interface, and release
* addresses that have been deleted.
- **/
+ */
static inline int __dev_mc_sync(struct net_device *dev,
int (*sync)(struct net_device *,
const unsigned char *),
@@ -3736,7 +3733,7 @@ static inline int __dev_mc_sync(struct net_device *dev,
* @unsync: function to call if address should be removed
*
* Remove all addresses that were added to the device by dev_mc_sync().
- **/
+ */
static inline void __dev_mc_unsync(struct net_device *dev,
int (*unsync)(struct net_device *,
const unsigned char *))
^ permalink raw reply related
* Re: [PATCH] net: Fix typos and whitespace.
From: Bjorn Helgaas @ 2016-03-23 13:55 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: David S. Miller, netdev, linux-kernel, Vlad Zolotarov
In-Reply-To: <20160323134530.18742.35082.stgit@bhelgaas-glaptop2.roam.corp.google.com>
[+cc Vlad]
On Wed, Mar 23, 2016 at 08:45:30AM -0500, Bjorn Helgaas wrote:
> Fix typos. Capitalize CPU, NAPI, RCU consistently. Align structure
> indentation. No functional change intended; only comment and whitespace
> changes.
>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
> include/linux/netdevice.h | 215 ++++++++++++++++++++++-----------------------
> @@ -920,7 +920,7 @@ struct tc_to_netdev {
> *
> * Enable or disable the VF ability to query its RSS Redirection Table and
> * Hash Key. This is needed since on some devices VF share this information
> - * with PF and querying it may adduce a theoretical security risk.
> + * with PF and querying it may introduce a theoretical security risk.
> * int (*ndo_set_vf_rss_query_en)(struct net_device *dev, int vf, bool setting)
Most of these are obvious typo fixes, but I want to point out this one
in particular because "adduce" is a real word. It's possible that's
what Vlad intended in 01a3d796813d ("if_link: Add an additional
parameter to ifla_vf_info for RSS querying"), though it doesn't quite
seem to fit. Vlad, if you did intend "adduce", my apologies in
advance.
Bjorn
^ permalink raw reply
* [PATCH 1/2] net: ethernet: dlink: dl2k: fix code style
From: Maxim Zhukov @ 2016-03-23 14:36 UTC (permalink / raw)
To: davem; +Cc: linux, netdev, linux-kernel, Maxim Zhukov
This commit fixed spacing errors and warnings.
Signed-off-by: Maxim Zhukov <mussitantesmortem@gmail.com>
---
drivers/net/ethernet/dlink/dl2k.c | 491 +++++++++++++++++++-------------------
1 file changed, 245 insertions(+), 246 deletions(-)
diff --git a/drivers/net/ethernet/dlink/dl2k.c b/drivers/net/ethernet/dlink/dl2k.c
index f92b6d9..d128306 100644
--- a/drivers/net/ethernet/dlink/dl2k.c
+++ b/drivers/net/ethernet/dlink/dl2k.c
@@ -30,16 +30,16 @@ static int mtu[MAX_UNITS];
static int vlan[MAX_UNITS];
static int jumbo[MAX_UNITS];
static char *media[MAX_UNITS];
-static int tx_flow=-1;
-static int rx_flow=-1;
+static int tx_flow = -1;
+static int rx_flow = -1;
static int copy_thresh;
-static int rx_coalesce=10; /* Rx frame count each interrupt */
-static int rx_timeout=200; /* Rx DMA wait time in 640ns increments */
-static int tx_coalesce=16; /* HW xmit count each TxDMAComplete */
+static int rx_coalesce = 10; /* Rx frame count each interrupt */
+static int rx_timeout = 200; /* Rx DMA wait time in 640ns increments */
+static int tx_coalesce = 16; /* HW xmit count each TxDMAComplete */
-MODULE_AUTHOR ("Edward Peng");
-MODULE_DESCRIPTION ("D-Link DL2000-based Gigabit Ethernet Adapter");
+MODULE_AUTHOR("Edward Peng");
+MODULE_DESCRIPTION("D-Link DL2000-based Gigabit Ethernet Adapter");
MODULE_LICENSE("GPL");
module_param_array(mtu, int, NULL, 0);
module_param_array(media, charp, NULL, 0);
@@ -54,7 +54,7 @@ module_param(tx_coalesce, int, 0); /* HW xmit count each TxDMAComplete */
/* Enable the default interrupts */
-#define DEFAULT_INTR (RxDMAComplete | HostError | IntRequested | TxDMAComplete| \
+#define DEFAULT_INTR (RxDMAComplete | HostError | IntRequested | TxDMAComplete | \
UpdateStats | LinkEvent)
static void dl2k_enable_int(struct netdev_private *np)
@@ -67,32 +67,32 @@ static void dl2k_enable_int(struct netdev_private *np)
static const int max_intrloop = 50;
static const int multicast_filter_limit = 0x40;
-static int rio_open (struct net_device *dev);
-static void rio_timer (unsigned long data);
-static void rio_tx_timeout (struct net_device *dev);
-static netdev_tx_t start_xmit (struct sk_buff *skb, struct net_device *dev);
-static irqreturn_t rio_interrupt (int irq, void *dev_instance);
-static void rio_free_tx (struct net_device *dev, int irq);
-static void tx_error (struct net_device *dev, int tx_status);
-static int receive_packet (struct net_device *dev);
-static void rio_error (struct net_device *dev, int int_status);
-static int change_mtu (struct net_device *dev, int new_mtu);
-static void set_multicast (struct net_device *dev);
-static struct net_device_stats *get_stats (struct net_device *dev);
-static int clear_stats (struct net_device *dev);
-static int rio_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
-static int rio_close (struct net_device *dev);
-static int find_miiphy (struct net_device *dev);
-static int parse_eeprom (struct net_device *dev);
-static int read_eeprom (struct netdev_private *, int eep_addr);
-static int mii_wait_link (struct net_device *dev, int wait);
-static int mii_set_media (struct net_device *dev);
-static int mii_get_media (struct net_device *dev);
-static int mii_set_media_pcs (struct net_device *dev);
-static int mii_get_media_pcs (struct net_device *dev);
-static int mii_read (struct net_device *dev, int phy_addr, int reg_num);
-static int mii_write (struct net_device *dev, int phy_addr, int reg_num,
- u16 data);
+static int rio_open(struct net_device *dev);
+static void rio_timer(unsigned long data);
+static void rio_tx_timeout(struct net_device *dev);
+static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev);
+static irqreturn_t rio_interrupt(int irq, void *dev_instance);
+static void rio_free_tx(struct net_device *dev, int irq);
+static void tx_error(struct net_device *dev, int tx_status);
+static int receive_packet(struct net_device *dev);
+static void rio_error(struct net_device *dev, int int_status);
+static int change_mtu(struct net_device *dev, int new_mtu);
+static void set_multicast(struct net_device *dev);
+static struct net_device_stats *get_stats(struct net_device *dev);
+static int clear_stats(struct net_device *dev);
+static int rio_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
+static int rio_close(struct net_device *dev);
+static int find_miiphy(struct net_device *dev);
+static int parse_eeprom(struct net_device *dev);
+static int read_eeprom(struct netdev_private *, int eep_addr);
+static int mii_wait_link(struct net_device *dev, int wait);
+static int mii_set_media(struct net_device *dev);
+static int mii_get_media(struct net_device *dev);
+static int mii_set_media_pcs(struct net_device *dev);
+static int mii_get_media_pcs(struct net_device *dev);
+static int mii_read(struct net_device *dev, int phy_addr, int reg_num);
+static int mii_write(struct net_device *dev, int phy_addr, int reg_num,
+ u16 data);
static const struct ethtool_ops ethtool_ops;
@@ -102,7 +102,7 @@ static const struct net_device_ops netdev_ops = {
.ndo_stop = rio_close,
.ndo_get_stats = get_stats,
.ndo_validate_addr = eth_validate_addr,
- .ndo_set_mac_address = eth_mac_addr,
+ .ndo_set_mac_address = eth_mac_addr,
.ndo_set_rx_mode = set_multicast,
.ndo_do_ioctl = rio_ioctl,
.ndo_tx_timeout = rio_tx_timeout,
@@ -110,7 +110,7 @@ static const struct net_device_ops netdev_ops = {
};
static int
-rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
+rio_probe1(struct pci_dev *pdev, const struct pci_device_id *ent)
{
struct net_device *dev;
struct netdev_private *np;
@@ -123,22 +123,22 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
dma_addr_t ring_dma;
if (!version_printed++)
- printk ("%s", version);
+ printk("%s", version);
- err = pci_enable_device (pdev);
+ err = pci_enable_device(pdev);
if (err)
return err;
irq = pdev->irq;
- err = pci_request_regions (pdev, "dl2k");
+ err = pci_request_regions(pdev, "dl2k");
if (err)
goto err_out_disable;
- pci_set_master (pdev);
+ pci_set_master(pdev);
err = -ENOMEM;
- dev = alloc_etherdev (sizeof (*np));
+ dev = alloc_etherdev(sizeof(*np));
if (!dev)
goto err_out_res;
SET_NETDEV_DEV(dev, &pdev->dev);
@@ -160,8 +160,8 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
np->ioaddr = ioaddr;
np->chip_id = chip_idx;
np->pdev = pdev;
- spin_lock_init (&np->tx_lock);
- spin_lock_init (&np->rx_lock);
+ spin_lock_init(&np->tx_lock);
+ spin_lock_init(&np->rx_lock);
/* Parse manual configuration */
np->an_enable = 1;
@@ -169,32 +169,32 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
if (card_idx < MAX_UNITS) {
if (media[card_idx] != NULL) {
np->an_enable = 0;
- if (strcmp (media[card_idx], "auto") == 0 ||
- strcmp (media[card_idx], "autosense") == 0 ||
- strcmp (media[card_idx], "0") == 0 ) {
+ if (strcmp(media[card_idx], "auto") == 0 ||
+ strcmp(media[card_idx], "autosense") == 0 ||
+ strcmp(media[card_idx], "0") == 0) {
np->an_enable = 2;
- } else if (strcmp (media[card_idx], "100mbps_fd") == 0 ||
- strcmp (media[card_idx], "4") == 0) {
+ } else if (strcmp(media[card_idx], "100mbps_fd") == 0 ||
+ strcmp(media[card_idx], "4") == 0) {
np->speed = 100;
np->full_duplex = 1;
- } else if (strcmp (media[card_idx], "100mbps_hd") == 0 ||
- strcmp (media[card_idx], "3") == 0) {
+ } else if (strcmp(media[card_idx], "100mbps_hd") == 0 ||
+ strcmp(media[card_idx], "3") == 0) {
np->speed = 100;
np->full_duplex = 0;
- } else if (strcmp (media[card_idx], "10mbps_fd") == 0 ||
- strcmp (media[card_idx], "2") == 0) {
+ } else if (strcmp(media[card_idx], "10mbps_fd") == 0 ||
+ strcmp(media[card_idx], "2") == 0) {
np->speed = 10;
np->full_duplex = 1;
- } else if (strcmp (media[card_idx], "10mbps_hd") == 0 ||
- strcmp (media[card_idx], "1") == 0) {
+ } else if (strcmp(media[card_idx], "10mbps_hd") == 0 ||
+ strcmp(media[card_idx], "1") == 0) {
np->speed = 10;
np->full_duplex = 0;
- } else if (strcmp (media[card_idx], "1000mbps_fd") == 0 ||
- strcmp (media[card_idx], "6") == 0) {
- np->speed=1000;
- np->full_duplex=1;
- } else if (strcmp (media[card_idx], "1000mbps_hd") == 0 ||
- strcmp (media[card_idx], "5") == 0) {
+ } else if (strcmp(media[card_idx], "1000mbps_fd") == 0 ||
+ strcmp(media[card_idx], "6") == 0) {
+ np->speed = 1000;
+ np->full_duplex = 1;
+ } else if (strcmp(media[card_idx], "1000mbps_hd") == 0 ||
+ strcmp(media[card_idx], "5") == 0) {
np->speed = 1000;
np->full_duplex = 0;
} else {
@@ -221,7 +221,7 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
if (tx_coalesce < 1)
tx_coalesce = 1;
- else if (tx_coalesce > TX_RING_SIZE-1)
+ else if (tx_coalesce > TX_RING_SIZE - 1)
tx_coalesce = TX_RING_SIZE - 1;
}
dev->netdev_ops = &netdev_ops;
@@ -230,25 +230,25 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
#if 0
dev->features = NETIF_F_IP_CSUM;
#endif
- pci_set_drvdata (pdev, dev);
+ pci_set_drvdata(pdev, dev);
- ring_space = pci_alloc_consistent (pdev, TX_TOTAL_SIZE, &ring_dma);
+ ring_space = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma);
if (!ring_space)
goto err_out_iounmap;
np->tx_ring = ring_space;
np->tx_ring_dma = ring_dma;
- ring_space = pci_alloc_consistent (pdev, RX_TOTAL_SIZE, &ring_dma);
+ ring_space = pci_alloc_consistent(pdev, RX_TOTAL_SIZE, &ring_dma);
if (!ring_space)
goto err_out_unmap_tx;
np->rx_ring = ring_space;
np->rx_ring_dma = ring_dma;
/* Parse eeprom data */
- parse_eeprom (dev);
+ parse_eeprom(dev);
/* Find PHY address */
- err = find_miiphy (dev);
+ err = find_miiphy(dev);
if (err)
goto err_out_unmap_rx;
@@ -258,7 +258,7 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
/* Set media and reset PHY */
if (np->phy_media) {
/* default Auto-Negotiation for fiber deivices */
- if (np->an_enable == 2) {
+ if (np->an_enable == 2) {
np->an_enable = 1;
}
} else {
@@ -268,13 +268,13 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
np->an_enable = 1;
}
- err = register_netdev (dev);
+ err = register_netdev(dev);
if (err)
goto err_out_unmap_rx;
card_idx++;
- printk (KERN_INFO "%s: %s, %pM, IRQ %d\n",
+ printk(KERN_INFO "%s: %s, %pM, IRQ %d\n",
dev->name, np->name, dev->dev_addr, irq);
if (tx_coalesce > 1)
printk(KERN_INFO "tx_coalesce:\t%d packets\n",
@@ -283,31 +283,31 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
printk(KERN_INFO
"rx_coalesce:\t%d packets\n"
"rx_timeout: \t%d ns\n",
- np->rx_coalesce, np->rx_timeout*640);
+ np->rx_coalesce, np->rx_timeout * 640);
if (np->vlan)
printk(KERN_INFO "vlan(id):\t%d\n", np->vlan);
return 0;
err_out_unmap_rx:
- pci_free_consistent (pdev, RX_TOTAL_SIZE, np->rx_ring, np->rx_ring_dma);
+ pci_free_consistent(pdev, RX_TOTAL_SIZE, np->rx_ring, np->rx_ring_dma);
err_out_unmap_tx:
- pci_free_consistent (pdev, TX_TOTAL_SIZE, np->tx_ring, np->tx_ring_dma);
+ pci_free_consistent(pdev, TX_TOTAL_SIZE, np->tx_ring, np->tx_ring_dma);
err_out_iounmap:
#ifdef MEM_MAPPING
pci_iounmap(pdev, np->ioaddr);
#endif
pci_iounmap(pdev, np->eeprom_addr);
err_out_dev:
- free_netdev (dev);
+ free_netdev(dev);
err_out_res:
- pci_release_regions (pdev);
+ pci_release_regions(pdev);
err_out_disable:
- pci_disable_device (pdev);
+ pci_disable_device(pdev);
return err;
}
static int
-find_miiphy (struct net_device *dev)
+find_miiphy(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
int i, phy_found = 0;
@@ -315,21 +315,21 @@ find_miiphy (struct net_device *dev)
np->phy_addr = 1;
for (i = 31; i >= 0; i--) {
- int mii_status = mii_read (dev, i, 1);
+ int mii_status = mii_read(dev, i, 1);
if (mii_status != 0xffff && mii_status != 0x0000) {
np->phy_addr = i;
phy_found++;
}
}
if (!phy_found) {
- printk (KERN_ERR "%s: No MII PHY found!\n", dev->name);
+ printk(KERN_ERR "%s: No MII PHY found!\n", dev->name);
return -ENODEV;
}
return 0;
}
static int
-parse_eeprom (struct net_device *dev)
+parse_eeprom(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
@@ -337,18 +337,18 @@ parse_eeprom (struct net_device *dev)
u8 sromdata[256];
u8 *psib;
u32 crc;
- PSROM_t psrom = (PSROM_t) sromdata;
+ PSROM_t psrom = (PSROM_t)sromdata;
int cid, next;
for (i = 0; i < 128; i++)
- ((__le16 *) sromdata)[i] = cpu_to_le16(read_eeprom(np, i));
+ ((__le16 *)sromdata)[i] = cpu_to_le16(read_eeprom(np, i));
if (np->pdev->vendor == PCI_VENDOR_ID_DLINK) { /* D-Link Only */
/* Check CRC */
- crc = ~ether_crc_le (256 - 4, sromdata);
+ crc = ~ether_crc_le(256 - 4, sromdata);
if (psrom->crc != cpu_to_le32(crc)) {
- printk (KERN_ERR "%s: EEPROM data CRC error.\n",
+ printk(KERN_ERR "%s: EEPROM data CRC error.\n",
dev->name);
return -1;
}
@@ -369,12 +369,12 @@ parse_eeprom (struct net_device *dev)
/* Parse Software Information Block */
i = 0x30;
- psib = (u8 *) sromdata;
+ psib = (u8 *)sromdata;
do {
cid = psib[i++];
next = psib[i++];
if ((cid == 0 && next == 0) || (cid == 0xff && next == 0xff)) {
- printk (KERN_ERR "Cell data error\n");
+ printk(KERN_ERR "Cell data error\n");
return -1;
}
switch (cid) {
@@ -391,7 +391,7 @@ parse_eeprom (struct net_device *dev)
break;
case 9: /* Adapter description */
j = (next - i > 255) ? 255 : next - i;
- memcpy (np->name, &(psib[i]), j);
+ memcpy(np->name, &(psib[i]), j);
break;
case 4:
case 5:
@@ -560,7 +560,7 @@ static void rio_hw_init(struct net_device *dev)
/* Jumbo frame */
if (np->jumbo != 0)
- dw16(MaxFrameSize, MAX_JUMBO+14);
+ dw16(MaxFrameSize, MAX_JUMBO + 14);
/* Set RFDListPtr */
dw32(RFDListPtr0, np->rx_ring_dma);
@@ -574,7 +574,7 @@ static void rio_hw_init(struct net_device *dev)
dw16(StationAddr0 + 2 * i,
cpu_to_le16(((u16 *)dev->dev_addr)[i]));
- set_multicast (dev);
+ set_multicast(dev);
if (np->coalesce) {
dw32(RxDMAIntCtrl, np->rx_coalesce | np->rx_timeout << 16);
}
@@ -585,7 +585,7 @@ static void rio_hw_init(struct net_device *dev)
dw8(RxDMAUrgentThresh, 0x30);
dw32(RmonStatMask, 0x0007ffff);
/* clear statistics */
- clear_stats (dev);
+ clear_stats(dev);
/* VLAN supported */
if (np->vlan) {
@@ -646,19 +646,19 @@ static int rio_open(struct net_device *dev)
np->timer.expires = jiffies + 1 * HZ;
add_timer(&np->timer);
- netif_start_queue (dev);
+ netif_start_queue(dev);
dl2k_enable_int(np);
return 0;
}
static void
-rio_timer (unsigned long data)
+rio_timer(unsigned long data)
{
struct net_device *dev = (struct net_device *)data;
struct netdev_private *np = netdev_priv(dev);
unsigned int entry;
- int next_tick = 1*HZ;
+ int next_tick = 1 * HZ;
unsigned long flags;
spin_lock_irqsave(&np->rx_lock, flags);
@@ -675,14 +675,14 @@ rio_timer (unsigned long data)
np->rx_buf_sz);
if (skb == NULL) {
np->rx_ring[entry].fraginfo = 0;
- printk (KERN_INFO
+ printk(KERN_INFO
"%s: Still unable to re-allocate Rx skbuff.#%d\n",
dev->name, entry);
break;
}
np->rx_skbuff[entry] = skb;
np->rx_ring[entry].fraginfo =
- cpu_to_le64 (pci_map_single
+ cpu_to_le64(pci_map_single
(np->pdev, skb->data, np->rx_buf_sz,
PCI_DMA_FROMDEVICE));
}
@@ -691,18 +691,18 @@ rio_timer (unsigned long data)
np->rx_ring[entry].status = 0;
} /* end for */
} /* end if */
- spin_unlock_irqrestore (&np->rx_lock, flags);
+ spin_unlock_irqrestore(&np->rx_lock, flags);
np->timer.expires = jiffies + next_tick;
add_timer(&np->timer);
}
static void
-rio_tx_timeout (struct net_device *dev)
+rio_tx_timeout(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
- printk (KERN_INFO "%s: Tx timed out (%4.4x), is buffer full?\n",
+ printk(KERN_INFO "%s: Tx timed out (%4.4x), is buffer full?\n",
dev->name, dr32(TxStatus));
rio_free_tx(dev, 0);
dev->if_port = 0;
@@ -710,7 +710,7 @@ rio_tx_timeout (struct net_device *dev)
}
static netdev_tx_t
-start_xmit (struct sk_buff *skb, struct net_device *dev)
+start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
@@ -729,7 +729,7 @@ start_xmit (struct sk_buff *skb, struct net_device *dev)
#if 0
if (skb->ip_summed == CHECKSUM_PARTIAL) {
txdesc->status |=
- cpu_to_le64 (TCPChecksumEnable | UDPChecksumEnable |
+ cpu_to_le64(TCPChecksumEnable | UDPChecksumEnable |
IPChecksumEnable);
}
#endif
@@ -738,7 +738,7 @@ start_xmit (struct sk_buff *skb, struct net_device *dev)
((u64)np->vlan << 32) |
((u64)skb->priority << 45);
}
- txdesc->fraginfo = cpu_to_le64 (pci_map_single (np->pdev, skb->data,
+ txdesc->fraginfo = cpu_to_le64(pci_map_single(np->pdev, skb->data,
skb->len,
PCI_DMA_TODEVICE));
txdesc->fraginfo |= cpu_to_le64((u64)skb->len << 48);
@@ -746,12 +746,12 @@ start_xmit (struct sk_buff *skb, struct net_device *dev)
/* DL2K bug: DMA fails to get next descriptor ptr in 10Mbps mode
* Work around: Always use 1 descriptor in 10Mbps mode */
if (entry % np->tx_coalesce == 0 || np->speed == 10)
- txdesc->status = cpu_to_le64 (entry | tfc_vlan_tag |
+ txdesc->status = cpu_to_le64(entry | tfc_vlan_tag |
WordAlignDisable |
TxDMAIndicate |
(1 << FragCountShift));
else
- txdesc->status = cpu_to_le64 (entry | tfc_vlan_tag |
+ txdesc->status = cpu_to_le64(entry | tfc_vlan_tag |
WordAlignDisable |
(1 << FragCountShift));
@@ -764,13 +764,13 @@ start_xmit (struct sk_buff *skb, struct net_device *dev)
< TX_QUEUE_LEN - 1 && np->speed != 10) {
/* do nothing */
} else if (!netif_queue_stopped(dev)) {
- netif_stop_queue (dev);
+ netif_stop_queue(dev);
}
/* The first TFDListPtr */
if (!dr32(TFDListPtr0)) {
dw32(TFDListPtr0, np->tx_ring_dma +
- entry * sizeof (struct netdev_desc));
+ entry * sizeof(struct netdev_desc));
dw32(TFDListPtr1, 0);
}
@@ -778,7 +778,7 @@ start_xmit (struct sk_buff *skb, struct net_device *dev)
}
static irqreturn_t
-rio_interrupt (int irq, void *dev_instance)
+rio_interrupt(int irq, void *dev_instance)
{
struct net_device *dev = dev_instance;
struct netdev_private *np = netdev_priv(dev);
@@ -796,21 +796,21 @@ rio_interrupt (int irq, void *dev_instance)
handled = 1;
/* Processing received packets */
if (int_status & RxDMAComplete)
- receive_packet (dev);
+ receive_packet(dev);
/* TxDMAComplete interrupt */
- if ((int_status & (TxDMAComplete|IntRequested))) {
+ if ((int_status & (TxDMAComplete | IntRequested))) {
int tx_status;
tx_status = dr32(TxStatus);
if (tx_status & 0x01)
- tx_error (dev, tx_status);
+ tx_error(dev, tx_status);
/* Free used tx skbuffs */
- rio_free_tx (dev, 1);
+ rio_free_tx(dev, 1);
}
/* Handle uncommon events */
if (int_status &
(HostError | LinkEvent | UpdateStats))
- rio_error (dev, int_status);
+ rio_error(dev, int_status);
}
if (np->cur_tx != np->old_tx)
dw32(CountDown, 100);
@@ -818,7 +818,7 @@ rio_interrupt (int irq, void *dev_instance)
}
static void
-rio_free_tx (struct net_device *dev, int irq)
+rio_free_tx(struct net_device *dev, int irq)
{
struct netdev_private *np = netdev_priv(dev);
int entry = np->old_tx % TX_RING_SIZE;
@@ -837,13 +837,13 @@ rio_free_tx (struct net_device *dev, int irq)
if (!(np->tx_ring[entry].status & cpu_to_le64(TFDDone)))
break;
skb = np->tx_skbuff[entry];
- pci_unmap_single (np->pdev,
+ pci_unmap_single(np->pdev,
desc_to_dma(&np->tx_ring[entry]),
skb->len, PCI_DMA_TODEVICE);
if (irq)
- dev_kfree_skb_irq (skb);
+ dev_kfree_skb_irq(skb);
else
- dev_kfree_skb (skb);
+ dev_kfree_skb(skb);
np->tx_skbuff[entry] = NULL;
entry = (entry + 1) % TX_RING_SIZE;
@@ -861,12 +861,12 @@ rio_free_tx (struct net_device *dev, int irq)
if (netif_queue_stopped(dev) &&
((np->cur_tx - np->old_tx + TX_RING_SIZE) % TX_RING_SIZE
< TX_QUEUE_LEN - 1 || np->speed == 10)) {
- netif_wake_queue (dev);
+ netif_wake_queue(dev);
}
}
static void
-tx_error (struct net_device *dev, int tx_status)
+tx_error(struct net_device *dev, int tx_status)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
@@ -874,7 +874,7 @@ tx_error (struct net_device *dev, int tx_status)
int i;
frame_id = (tx_status & 0xffff0000);
- printk (KERN_ERR "%s: Transmit error, TxStatus %4.4x, FrameId %d.\n",
+ printk(KERN_ERR "%s: Transmit error, TxStatus %4.4x, FrameId %d.\n",
dev->name, tx_status, frame_id);
np->stats.tx_errors++;
/* Ttransmit Underrun */
@@ -888,13 +888,13 @@ tx_error (struct net_device *dev, int tx_status)
for (i = 50; i > 0; i--) {
if (!(dr16(ASICCtrl + 2) & ResetBusy))
break;
- mdelay (1);
+ mdelay(1);
}
rio_set_led_mode(dev);
- rio_free_tx (dev, 1);
+ rio_free_tx(dev, 1);
/* Reset TFDListPtr */
dw32(TFDListPtr0, np->tx_ring_dma +
- np->old_tx * sizeof (struct netdev_desc));
+ np->old_tx * sizeof(struct netdev_desc));
dw32(TFDListPtr1, 0);
/* Let TxStartThresh stay default value */
@@ -908,7 +908,7 @@ tx_error (struct net_device *dev, int tx_status)
for (i = 50; i > 0; i--) {
if (!(dr16(ASICCtrl + 2) & ResetBusy))
break;
- mdelay (1);
+ mdelay(1);
}
rio_set_led_mode(dev);
/* Let TxStartThresh stay default value */
@@ -926,7 +926,7 @@ tx_error (struct net_device *dev, int tx_status)
}
static int
-receive_packet (struct net_device *dev)
+receive_packet(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
int entry = np->cur_rx % RX_RING_SIZE;
@@ -958,33 +958,33 @@ receive_packet (struct net_device *dev)
if (frame_status & RxAlignmentError && np->speed != 1000)
np->stats.rx_frame_errors++;
if (frame_status & RxFIFOOverrun)
- np->stats.rx_fifo_errors++;
+ np->stats.rx_fifo_errors++;
} else {
struct sk_buff *skb;
/* Small skbuffs for short packets */
if (pkt_len > copy_thresh) {
- pci_unmap_single (np->pdev,
+ pci_unmap_single(np->pdev,
desc_to_dma(desc),
np->rx_buf_sz,
PCI_DMA_FROMDEVICE);
- skb_put (skb = np->rx_skbuff[entry], pkt_len);
+ skb_put(skb = np->rx_skbuff[entry], pkt_len);
np->rx_skbuff[entry] = NULL;
} else if ((skb = netdev_alloc_skb_ip_align(dev, pkt_len))) {
pci_dma_sync_single_for_cpu(np->pdev,
desc_to_dma(desc),
np->rx_buf_sz,
PCI_DMA_FROMDEVICE);
- skb_copy_to_linear_data (skb,
+ skb_copy_to_linear_data(skb,
np->rx_skbuff[entry]->data,
pkt_len);
- skb_put (skb, pkt_len);
+ skb_put(skb, pkt_len);
pci_dma_sync_single_for_device(np->pdev,
desc_to_dma(desc),
np->rx_buf_sz,
PCI_DMA_FROMDEVICE);
}
- skb->protocol = eth_type_trans (skb, dev);
+ skb->protocol = eth_type_trans(skb, dev);
#if 0
/* Checksum done by hw, but csum value unavailable. */
if (np->pdev->pci_rev_id >= 0x0c &&
@@ -992,7 +992,7 @@ receive_packet (struct net_device *dev)
skb->ip_summed = CHECKSUM_UNNECESSARY;
}
#endif
- netif_rx (skb);
+ netif_rx(skb);
}
entry = (entry + 1) % RX_RING_SIZE;
}
@@ -1007,7 +1007,7 @@ receive_packet (struct net_device *dev)
skb = netdev_alloc_skb_ip_align(dev, np->rx_buf_sz);
if (skb == NULL) {
np->rx_ring[entry].fraginfo = 0;
- printk (KERN_INFO
+ printk(KERN_INFO
"%s: receive_packet: "
"Unable to re-allocate Rx skbuff.#%d\n",
dev->name, entry);
@@ -1015,7 +1015,7 @@ receive_packet (struct net_device *dev)
}
np->rx_skbuff[entry] = skb;
np->rx_ring[entry].fraginfo =
- cpu_to_le64 (pci_map_single
+ cpu_to_le64(pci_map_single
(np->pdev, skb->data, np->rx_buf_sz,
PCI_DMA_FROMDEVICE));
}
@@ -1030,7 +1030,7 @@ receive_packet (struct net_device *dev)
}
static void
-rio_error (struct net_device *dev, int int_status)
+rio_error(struct net_device *dev, int int_status)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
@@ -1038,12 +1038,12 @@ rio_error (struct net_device *dev, int int_status)
/* Link change event */
if (int_status & LinkEvent) {
- if (mii_wait_link (dev, 10) == 0) {
- printk (KERN_INFO "%s: Link up\n", dev->name);
+ if (mii_wait_link(dev, 10) == 0) {
+ printk(KERN_INFO "%s: Link up\n", dev->name);
if (np->phy_media)
- mii_get_media_pcs (dev);
+ mii_get_media_pcs(dev);
else
- mii_get_media (dev);
+ mii_get_media(dev);
if (np->speed == 1000)
np->tx_coalesce = tx_coalesce;
else
@@ -1059,7 +1059,7 @@ rio_error (struct net_device *dev, int int_status)
np->link_status = 1;
netif_carrier_on(dev);
} else {
- printk (KERN_INFO "%s: Link off\n", dev->name);
+ printk(KERN_INFO "%s: Link off\n", dev->name);
np->link_status = 0;
netif_carrier_off(dev);
}
@@ -1067,22 +1067,22 @@ rio_error (struct net_device *dev, int int_status)
/* UpdateStats statistics registers */
if (int_status & UpdateStats) {
- get_stats (dev);
+ get_stats(dev);
}
/* PCI Error, a catastronphic error related to the bus interface
occurs, set GlobalReset and HostReset to reset. */
if (int_status & HostError) {
- printk (KERN_ERR "%s: HostError! IntStatus %4.4x.\n",
+ printk(KERN_ERR "%s: HostError! IntStatus %4.4x.\n",
dev->name, int_status);
dw16(ASICCtrl + 2, GlobalReset | HostReset);
- mdelay (500);
+ mdelay(500);
rio_set_led_mode(dev);
}
}
static struct net_device_stats *
-get_stats (struct net_device *dev)
+get_stats(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
@@ -1144,7 +1144,7 @@ get_stats (struct net_device *dev)
}
static int
-clear_stats (struct net_device *dev)
+clear_stats(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
@@ -1200,7 +1200,7 @@ clear_stats (struct net_device *dev)
static int
-change_mtu (struct net_device *dev, int new_mtu)
+change_mtu(struct net_device *dev, int new_mtu)
{
struct netdev_private *np = netdev_priv(dev);
int max = (np->jumbo) ? MAX_JUMBO : 1536;
@@ -1215,7 +1215,7 @@ change_mtu (struct net_device *dev, int new_mtu)
}
static void
-set_multicast (struct net_device *dev)
+set_multicast(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
@@ -1276,7 +1276,7 @@ static int rio_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
if (np->phy_media) {
/* fiber device */
cmd->supported = SUPPORTED_Autoneg | SUPPORTED_FIBRE;
- cmd->advertising= ADVERTISED_Autoneg | ADVERTISED_FIBRE;
+ cmd->advertising = ADVERTISED_Autoneg | ADVERTISED_FIBRE;
cmd->port = PORT_FIBRE;
cmd->transceiver = XCVR_INTERNAL;
} else {
@@ -1287,19 +1287,19 @@ static int rio_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
SUPPORTED_Autoneg | SUPPORTED_MII;
cmd->advertising = ADVERTISED_10baseT_Half |
ADVERTISED_10baseT_Full | ADVERTISED_100baseT_Half |
- ADVERTISED_100baseT_Full | ADVERTISED_1000baseT_Full|
+ ADVERTISED_100baseT_Full | ADVERTISED_1000baseT_Full |
ADVERTISED_Autoneg | ADVERTISED_MII;
cmd->port = PORT_MII;
cmd->transceiver = XCVR_INTERNAL;
}
- if ( np->link_status ) {
+ if (np->link_status) {
ethtool_cmd_speed_set(cmd, np->speed);
cmd->duplex = np->full_duplex ? DUPLEX_FULL : DUPLEX_HALF;
} else {
ethtool_cmd_speed_set(cmd, SPEED_UNKNOWN);
cmd->duplex = DUPLEX_UNKNOWN;
}
- if ( np->an_enable)
+ if (np->an_enable)
cmd->autoneg = AUTONEG_ENABLE;
else
cmd->autoneg = AUTONEG_DISABLE;
@@ -1359,7 +1359,7 @@ static const struct ethtool_ops ethtool_ops = {
};
static int
-rio_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
+rio_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
int phy_addr;
struct netdev_private *np = netdev_priv(dev);
@@ -1371,12 +1371,12 @@ rio_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
miidata->phy_id = phy_addr;
break;
case SIOCGMIIREG:
- miidata->val_out = mii_read (dev, phy_addr, miidata->reg_num);
+ miidata->val_out = mii_read(dev, phy_addr, miidata->reg_num);
break;
case SIOCSMIIREG:
if (!capable(CAP_NET_ADMIN))
return -EPERM;
- mii_write (dev, phy_addr, miidata->reg_num, miidata->val_in);
+ mii_write(dev, phy_addr, miidata->reg_num, miidata->val_in);
break;
default:
return -EOPNOTSUPP;
@@ -1408,20 +1408,20 @@ enum phy_ctrl_bits {
#define mii_delay() dr8(PhyCtrl)
static void
-mii_sendbit (struct net_device *dev, u32 data)
+mii_sendbit(struct net_device *dev, u32 data)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
data = ((data) ? MII_DATA1 : 0) | (dr8(PhyCtrl) & 0xf8) | MII_WRITE;
dw8(PhyCtrl, data);
- mii_delay ();
+ mii_delay();
dw8(PhyCtrl, data | MII_CLK);
- mii_delay ();
+ mii_delay();
}
static int
-mii_getbit (struct net_device *dev)
+mii_getbit(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
@@ -1429,67 +1429,67 @@ mii_getbit (struct net_device *dev)
data = (dr8(PhyCtrl) & 0xf8) | MII_READ;
dw8(PhyCtrl, data);
- mii_delay ();
+ mii_delay();
dw8(PhyCtrl, data | MII_CLK);
- mii_delay ();
+ mii_delay();
return (dr8(PhyCtrl) >> 1) & 1;
}
static void
-mii_send_bits (struct net_device *dev, u32 data, int len)
+mii_send_bits(struct net_device *dev, u32 data, int len)
{
int i;
for (i = len - 1; i >= 0; i--) {
- mii_sendbit (dev, data & (1 << i));
+ mii_sendbit(dev, data & (1 << i));
}
}
static int
-mii_read (struct net_device *dev, int phy_addr, int reg_num)
+mii_read(struct net_device *dev, int phy_addr, int reg_num)
{
u32 cmd;
int i;
u32 retval = 0;
/* Preamble */
- mii_send_bits (dev, 0xffffffff, 32);
+ mii_send_bits(dev, 0xffffffff, 32);
/* ST(2), OP(2), ADDR(5), REG#(5), TA(2), Data(16) total 32 bits */
/* ST,OP = 0110'b for read operation */
cmd = (0x06 << 10 | phy_addr << 5 | reg_num);
- mii_send_bits (dev, cmd, 14);
+ mii_send_bits(dev, cmd, 14);
/* Turnaround */
- if (mii_getbit (dev))
+ if (mii_getbit(dev))
goto err_out;
/* Read data */
for (i = 0; i < 16; i++) {
- retval |= mii_getbit (dev);
+ retval |= mii_getbit(dev);
retval <<= 1;
}
/* End cycle */
- mii_getbit (dev);
+ mii_getbit(dev);
return (retval >> 1) & 0xffff;
err_out:
return 0;
}
static int
-mii_write (struct net_device *dev, int phy_addr, int reg_num, u16 data)
+mii_write(struct net_device *dev, int phy_addr, int reg_num, u16 data)
{
u32 cmd;
/* Preamble */
- mii_send_bits (dev, 0xffffffff, 32);
+ mii_send_bits(dev, 0xffffffff, 32);
/* ST(2), OP(2), ADDR(5), REG#(5), TA(2), Data(16) total 32 bits */
/* ST,OP,AAAAA,RRRRR,TA = 0101xxxxxxxxxx10'b = 0x5002 for write */
cmd = (0x5002 << 16) | (phy_addr << 23) | (reg_num << 18) | data;
- mii_send_bits (dev, cmd, 32);
+ mii_send_bits(dev, cmd, 32);
/* End cycle */
- mii_getbit (dev);
+ mii_getbit(dev);
return 0;
}
static int
-mii_wait_link (struct net_device *dev, int wait)
+mii_wait_link(struct net_device *dev, int wait)
{
__u16 bmsr;
int phy_addr;
@@ -1499,15 +1499,15 @@ mii_wait_link (struct net_device *dev, int wait)
phy_addr = np->phy_addr;
do {
- bmsr = mii_read (dev, phy_addr, MII_BMSR);
+ bmsr = mii_read(dev, phy_addr, MII_BMSR);
if (bmsr & BMSR_LSTATUS)
return 0;
- mdelay (1);
+ mdelay(1);
} while (--wait > 0);
return -1;
}
static int
-mii_get_media (struct net_device *dev)
+mii_get_media(struct net_device *dev)
{
__u16 negotiate;
__u16 bmsr;
@@ -1519,40 +1519,40 @@ mii_get_media (struct net_device *dev)
np = netdev_priv(dev);
phy_addr = np->phy_addr;
- bmsr = mii_read (dev, phy_addr, MII_BMSR);
+ bmsr = mii_read(dev, phy_addr, MII_BMSR);
if (np->an_enable) {
if (!(bmsr & BMSR_ANEGCOMPLETE)) {
/* Auto-Negotiation not completed */
return -1;
}
- negotiate = mii_read (dev, phy_addr, MII_ADVERTISE) &
- mii_read (dev, phy_addr, MII_LPA);
- mscr = mii_read (dev, phy_addr, MII_CTRL1000);
- mssr = mii_read (dev, phy_addr, MII_STAT1000);
+ negotiate = mii_read(dev, phy_addr, MII_ADVERTISE) &
+ mii_read(dev, phy_addr, MII_LPA);
+ mscr = mii_read(dev, phy_addr, MII_CTRL1000);
+ mssr = mii_read(dev, phy_addr, MII_STAT1000);
if (mscr & ADVERTISE_1000FULL && mssr & LPA_1000FULL) {
np->speed = 1000;
np->full_duplex = 1;
- printk (KERN_INFO "Auto 1000 Mbps, Full duplex\n");
+ printk(KERN_INFO "Auto 1000 Mbps, Full duplex\n");
} else if (mscr & ADVERTISE_1000HALF && mssr & LPA_1000HALF) {
np->speed = 1000;
np->full_duplex = 0;
- printk (KERN_INFO "Auto 1000 Mbps, Half duplex\n");
+ printk(KERN_INFO "Auto 1000 Mbps, Half duplex\n");
} else if (negotiate & ADVERTISE_100FULL) {
np->speed = 100;
np->full_duplex = 1;
- printk (KERN_INFO "Auto 100 Mbps, Full duplex\n");
+ printk(KERN_INFO "Auto 100 Mbps, Full duplex\n");
} else if (negotiate & ADVERTISE_100HALF) {
np->speed = 100;
np->full_duplex = 0;
- printk (KERN_INFO "Auto 100 Mbps, Half duplex\n");
+ printk(KERN_INFO "Auto 100 Mbps, Half duplex\n");
} else if (negotiate & ADVERTISE_10FULL) {
np->speed = 10;
np->full_duplex = 1;
- printk (KERN_INFO "Auto 10 Mbps, Full duplex\n");
+ printk(KERN_INFO "Auto 10 Mbps, Full duplex\n");
} else if (negotiate & ADVERTISE_10HALF) {
np->speed = 10;
np->full_duplex = 0;
- printk (KERN_INFO "Auto 10 Mbps, Half duplex\n");
+ printk(KERN_INFO "Auto 10 Mbps, Half duplex\n");
}
if (negotiate & ADVERTISE_PAUSE_CAP) {
np->tx_flow &= 1;
@@ -1563,21 +1563,21 @@ mii_get_media (struct net_device *dev)
}
/* else tx_flow, rx_flow = user select */
} else {
- __u16 bmcr = mii_read (dev, phy_addr, MII_BMCR);
+ __u16 bmcr = mii_read(dev, phy_addr, MII_BMCR);
switch (bmcr & (BMCR_SPEED100 | BMCR_SPEED1000)) {
case BMCR_SPEED1000:
- printk (KERN_INFO "Operating at 1000 Mbps, ");
+ printk(KERN_INFO "Operating at 1000 Mbps, ");
break;
case BMCR_SPEED100:
- printk (KERN_INFO "Operating at 100 Mbps, ");
+ printk(KERN_INFO "Operating at 100 Mbps, ");
break;
case 0:
- printk (KERN_INFO "Operating at 10 Mbps, ");
+ printk(KERN_INFO "Operating at 10 Mbps, ");
}
if (bmcr & BMCR_FULLDPLX) {
- printk (KERN_CONT "Full duplex\n");
+ printk(KERN_CONT "Full duplex\n");
} else {
- printk (KERN_CONT "Half duplex\n");
+ printk(KERN_CONT "Half duplex\n");
}
}
if (np->tx_flow)
@@ -1593,7 +1593,7 @@ mii_get_media (struct net_device *dev)
}
static int
-mii_set_media (struct net_device *dev)
+mii_set_media(struct net_device *dev)
{
__u16 pscr;
__u16 bmcr;
@@ -1607,8 +1607,8 @@ mii_set_media (struct net_device *dev)
/* Does user set speed? */
if (np->an_enable) {
/* Advertise capabilities */
- bmsr = mii_read (dev, phy_addr, MII_BMSR);
- anar = mii_read (dev, phy_addr, MII_ADVERTISE) &
+ bmsr = mii_read(dev, phy_addr, MII_BMSR);
+ anar = mii_read(dev, phy_addr, MII_ADVERTISE) &
~(ADVERTISE_100FULL | ADVERTISE_10FULL |
ADVERTISE_100HALF | ADVERTISE_10HALF |
ADVERTISE_100BASE4);
@@ -1623,66 +1623,66 @@ mii_set_media (struct net_device *dev)
if (bmsr & BMSR_10HALF)
anar |= ADVERTISE_10HALF;
anar |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;
- mii_write (dev, phy_addr, MII_ADVERTISE, anar);
+ mii_write(dev, phy_addr, MII_ADVERTISE, anar);
/* Enable Auto crossover */
- pscr = mii_read (dev, phy_addr, MII_PHY_SCR);
+ pscr = mii_read(dev, phy_addr, MII_PHY_SCR);
pscr |= 3 << 5; /* 11'b */
- mii_write (dev, phy_addr, MII_PHY_SCR, pscr);
+ mii_write(dev, phy_addr, MII_PHY_SCR, pscr);
/* Soft reset PHY */
- mii_write (dev, phy_addr, MII_BMCR, BMCR_RESET);
+ mii_write(dev, phy_addr, MII_BMCR, BMCR_RESET);
bmcr = BMCR_ANENABLE | BMCR_ANRESTART | BMCR_RESET;
- mii_write (dev, phy_addr, MII_BMCR, bmcr);
+ mii_write(dev, phy_addr, MII_BMCR, bmcr);
mdelay(1);
} else {
/* Force speed setting */
/* 1) Disable Auto crossover */
- pscr = mii_read (dev, phy_addr, MII_PHY_SCR);
+ pscr = mii_read(dev, phy_addr, MII_PHY_SCR);
pscr &= ~(3 << 5);
- mii_write (dev, phy_addr, MII_PHY_SCR, pscr);
+ mii_write(dev, phy_addr, MII_PHY_SCR, pscr);
/* 2) PHY Reset */
- bmcr = mii_read (dev, phy_addr, MII_BMCR);
+ bmcr = mii_read(dev, phy_addr, MII_BMCR);
bmcr |= BMCR_RESET;
- mii_write (dev, phy_addr, MII_BMCR, bmcr);
+ mii_write(dev, phy_addr, MII_BMCR, bmcr);
/* 3) Power Down */
bmcr = 0x1940; /* must be 0x1940 */
- mii_write (dev, phy_addr, MII_BMCR, bmcr);
- mdelay (100); /* wait a certain time */
+ mii_write(dev, phy_addr, MII_BMCR, bmcr);
+ mdelay(100); /* wait a certain time */
/* 4) Advertise nothing */
- mii_write (dev, phy_addr, MII_ADVERTISE, 0);
+ mii_write(dev, phy_addr, MII_ADVERTISE, 0);
/* 5) Set media and Power Up */
bmcr = BMCR_PDOWN;
if (np->speed == 100) {
bmcr |= BMCR_SPEED100;
- printk (KERN_INFO "Manual 100 Mbps, ");
+ printk(KERN_INFO "Manual 100 Mbps, ");
} else if (np->speed == 10) {
- printk (KERN_INFO "Manual 10 Mbps, ");
+ printk(KERN_INFO "Manual 10 Mbps, ");
}
if (np->full_duplex) {
bmcr |= BMCR_FULLDPLX;
- printk (KERN_CONT "Full duplex\n");
+ printk(KERN_CONT "Full duplex\n");
} else {
- printk (KERN_CONT "Half duplex\n");
+ printk(KERN_CONT "Half duplex\n");
}
#if 0
/* Set 1000BaseT Master/Slave setting */
- mscr = mii_read (dev, phy_addr, MII_CTRL1000);
+ mscr = mii_read(dev, phy_addr, MII_CTRL1000);
mscr |= MII_MSCR_CFG_ENABLE;
mscr &= ~MII_MSCR_CFG_VALUE = 0;
#endif
- mii_write (dev, phy_addr, MII_BMCR, bmcr);
+ mii_write(dev, phy_addr, MII_BMCR, bmcr);
mdelay(10);
}
return 0;
}
static int
-mii_get_media_pcs (struct net_device *dev)
+mii_get_media_pcs(struct net_device *dev)
{
__u16 negotiate;
__u16 bmsr;
@@ -1692,20 +1692,20 @@ mii_get_media_pcs (struct net_device *dev)
np = netdev_priv(dev);
phy_addr = np->phy_addr;
- bmsr = mii_read (dev, phy_addr, PCS_BMSR);
+ bmsr = mii_read(dev, phy_addr, PCS_BMSR);
if (np->an_enable) {
if (!(bmsr & BMSR_ANEGCOMPLETE)) {
/* Auto-Negotiation not completed */
return -1;
}
- negotiate = mii_read (dev, phy_addr, PCS_ANAR) &
- mii_read (dev, phy_addr, PCS_ANLPAR);
+ negotiate = mii_read(dev, phy_addr, PCS_ANAR) &
+ mii_read(dev, phy_addr, PCS_ANLPAR);
np->speed = 1000;
if (negotiate & PCS_ANAR_FULL_DUPLEX) {
- printk (KERN_INFO "Auto 1000 Mbps, Full duplex\n");
+ printk(KERN_INFO "Auto 1000 Mbps, Full duplex\n");
np->full_duplex = 1;
} else {
- printk (KERN_INFO "Auto 1000 Mbps, half duplex\n");
+ printk(KERN_INFO "Auto 1000 Mbps, half duplex\n");
np->full_duplex = 0;
}
if (negotiate & PCS_ANAR_PAUSE) {
@@ -1717,12 +1717,12 @@ mii_get_media_pcs (struct net_device *dev)
}
/* else tx_flow, rx_flow = user select */
} else {
- __u16 bmcr = mii_read (dev, phy_addr, PCS_BMCR);
- printk (KERN_INFO "Operating at 1000 Mbps, ");
+ __u16 bmcr = mii_read(dev, phy_addr, PCS_BMCR);
+ printk(KERN_INFO "Operating at 1000 Mbps, ");
if (bmcr & BMCR_FULLDPLX) {
- printk (KERN_CONT "Full duplex\n");
+ printk(KERN_CONT "Full duplex\n");
} else {
- printk (KERN_CONT "Half duplex\n");
+ printk(KERN_CONT "Half duplex\n");
}
}
if (np->tx_flow)
@@ -1738,7 +1738,7 @@ mii_get_media_pcs (struct net_device *dev)
}
static int
-mii_set_media_pcs (struct net_device *dev)
+mii_set_media_pcs(struct net_device *dev)
{
__u16 bmcr;
__u16 esr;
@@ -1751,8 +1751,8 @@ mii_set_media_pcs (struct net_device *dev)
/* Auto-Negotiation? */
if (np->an_enable) {
/* Advertise capabilities */
- esr = mii_read (dev, phy_addr, PCS_ESR);
- anar = mii_read (dev, phy_addr, MII_ADVERTISE) &
+ esr = mii_read(dev, phy_addr, PCS_ESR);
+ anar = mii_read(dev, phy_addr, MII_ADVERTISE) &
~PCS_ANAR_HALF_DUPLEX &
~PCS_ANAR_FULL_DUPLEX;
if (esr & (MII_ESR_1000BT_HD | MII_ESR_1000BX_HD))
@@ -1760,48 +1760,48 @@ mii_set_media_pcs (struct net_device *dev)
if (esr & (MII_ESR_1000BT_FD | MII_ESR_1000BX_FD))
anar |= PCS_ANAR_FULL_DUPLEX;
anar |= PCS_ANAR_PAUSE | PCS_ANAR_ASYMMETRIC;
- mii_write (dev, phy_addr, MII_ADVERTISE, anar);
+ mii_write(dev, phy_addr, MII_ADVERTISE, anar);
/* Soft reset PHY */
- mii_write (dev, phy_addr, MII_BMCR, BMCR_RESET);
+ mii_write(dev, phy_addr, MII_BMCR, BMCR_RESET);
bmcr = BMCR_ANENABLE | BMCR_ANRESTART | BMCR_RESET;
- mii_write (dev, phy_addr, MII_BMCR, bmcr);
+ mii_write(dev, phy_addr, MII_BMCR, bmcr);
mdelay(1);
} else {
/* Force speed setting */
/* PHY Reset */
bmcr = BMCR_RESET;
- mii_write (dev, phy_addr, MII_BMCR, bmcr);
+ mii_write(dev, phy_addr, MII_BMCR, bmcr);
mdelay(10);
if (np->full_duplex) {
bmcr = BMCR_FULLDPLX;
- printk (KERN_INFO "Manual full duplex\n");
+ printk(KERN_INFO "Manual full duplex\n");
} else {
bmcr = 0;
- printk (KERN_INFO "Manual half duplex\n");
+ printk(KERN_INFO "Manual half duplex\n");
}
- mii_write (dev, phy_addr, MII_BMCR, bmcr);
+ mii_write(dev, phy_addr, MII_BMCR, bmcr);
mdelay(10);
/* Advertise nothing */
- mii_write (dev, phy_addr, MII_ADVERTISE, 0);
+ mii_write(dev, phy_addr, MII_ADVERTISE, 0);
}
return 0;
}
static int
-rio_close (struct net_device *dev)
+rio_close(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
struct pci_dev *pdev = np->pdev;
- netif_stop_queue (dev);
+ netif_stop_queue(dev);
rio_hw_stop(dev);
free_irq(pdev->irq, dev);
- del_timer_sync (&np->timer);
+ del_timer_sync(&np->timer);
free_list(dev);
@@ -1809,25 +1809,25 @@ rio_close (struct net_device *dev)
}
static void
-rio_remove1 (struct pci_dev *pdev)
+rio_remove1(struct pci_dev *pdev)
{
- struct net_device *dev = pci_get_drvdata (pdev);
+ struct net_device *dev = pci_get_drvdata(pdev);
if (dev) {
struct netdev_private *np = netdev_priv(dev);
- unregister_netdev (dev);
- pci_free_consistent (pdev, RX_TOTAL_SIZE, np->rx_ring,
- np->rx_ring_dma);
- pci_free_consistent (pdev, TX_TOTAL_SIZE, np->tx_ring,
- np->tx_ring_dma);
+ unregister_netdev(dev);
+ pci_free_consistent(pdev, RX_TOTAL_SIZE, np->rx_ring,
+ np->rx_ring_dma);
+ pci_free_consistent(pdev, TX_TOTAL_SIZE, np->tx_ring,
+ np->tx_ring_dma);
#ifdef MEM_MAPPING
pci_iounmap(pdev, np->ioaddr);
#endif
pci_iounmap(pdev, np->eeprom_addr);
- free_netdev (dev);
- pci_release_regions (pdev);
- pci_disable_device (pdev);
+ free_netdev(dev);
+ pci_release_regions(pdev);
+ pci_disable_device(pdev);
}
}
@@ -1892,4 +1892,3 @@ gcc -D__KERNEL__ -DMODULE -I/usr/src/linux/include -Wall -Wstrict-prototypes -O2
Read Documentation/networking/dl2k.txt for details.
*/
-
--
2.7.1.1.g3617aa0
^ permalink raw reply related
* [PATCH 2/2] drivers: net: ethernet: dlink: dl2k: fix indent
From: Maxim Zhukov @ 2016-03-23 14:36 UTC (permalink / raw)
To: davem; +Cc: linux, netdev, linux-kernel, Maxim Zhukov
In-Reply-To: <1458743800-30606-1-git-send-email-mussitantesmortem@gmail.com>
This commit fixed indent in file. Labels must be start of the line
Signed-off-by: Maxim Zhukov <mussitantesmortem@gmail.com>
---
drivers/net/ethernet/dlink/dl2k.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/dlink/dl2k.c b/drivers/net/ethernet/dlink/dl2k.c
index d128306..e635b1e 100644
--- a/drivers/net/ethernet/dlink/dl2k.c
+++ b/drivers/net/ethernet/dlink/dl2k.c
@@ -98,7 +98,7 @@ static const struct ethtool_ops ethtool_ops;
static const struct net_device_ops netdev_ops = {
.ndo_open = rio_open,
- .ndo_start_xmit = start_xmit,
+ .ndo_start_xmit = start_xmit,
.ndo_stop = rio_close,
.ndo_get_stats = get_stats,
.ndo_validate_addr = eth_validate_addr,
@@ -174,7 +174,7 @@ rio_probe1(struct pci_dev *pdev, const struct pci_device_id *ent)
strcmp(media[card_idx], "0") == 0) {
np->an_enable = 2;
} else if (strcmp(media[card_idx], "100mbps_fd") == 0 ||
- strcmp(media[card_idx], "4") == 0) {
+ strcmp(media[card_idx], "4") == 0) {
np->speed = 100;
np->full_duplex = 1;
} else if (strcmp(media[card_idx], "100mbps_hd") == 0 ||
@@ -190,11 +190,11 @@ rio_probe1(struct pci_dev *pdev, const struct pci_device_id *ent)
np->speed = 10;
np->full_duplex = 0;
} else if (strcmp(media[card_idx], "1000mbps_fd") == 0 ||
- strcmp(media[card_idx], "6") == 0) {
+ strcmp(media[card_idx], "6") == 0) {
np->speed = 1000;
np->full_duplex = 1;
} else if (strcmp(media[card_idx], "1000mbps_hd") == 0 ||
- strcmp(media[card_idx], "5") == 0) {
+ strcmp(media[card_idx], "5") == 0) {
np->speed = 1000;
np->full_duplex = 0;
} else {
@@ -210,7 +210,7 @@ rio_probe1(struct pci_dev *pdev, const struct pci_device_id *ent)
dev->mtu = mtu[card_idx];
}
np->vlan = (vlan[card_idx] > 0 && vlan[card_idx] < 4096) ?
- vlan[card_idx] : 0;
+ vlan[card_idx] : 0;
if (rx_coalesce > 0 && rx_timeout > 0) {
np->rx_coalesce = rx_coalesce;
np->rx_timeout = rx_timeout;
@@ -278,12 +278,12 @@ rio_probe1(struct pci_dev *pdev, const struct pci_device_id *ent)
dev->name, np->name, dev->dev_addr, irq);
if (tx_coalesce > 1)
printk(KERN_INFO "tx_coalesce:\t%d packets\n",
- tx_coalesce);
+ tx_coalesce);
if (np->coalesce)
printk(KERN_INFO
"rx_coalesce:\t%d packets\n"
"rx_timeout: \t%d ns\n",
- np->rx_coalesce, np->rx_timeout * 640);
+ np->rx_coalesce, np->rx_timeout * 640);
if (np->vlan)
printk(KERN_INFO "vlan(id):\t%d\n", np->vlan);
return 0;
@@ -1470,7 +1470,7 @@ mii_read(struct net_device *dev, int phy_addr, int reg_num)
mii_getbit(dev);
return (retval >> 1) & 0xffff;
- err_out:
+err_out:
return 0;
}
static int
--
2.7.1.1.g3617aa0
^ permalink raw reply related
* Re: [PATCH 1/2] net: ethernet: dlink: dl2k: fix code style
From: Joe Perches @ 2016-03-23 14:50 UTC (permalink / raw)
To: Maxim Zhukov, davem; +Cc: linux, netdev, linux-kernel
In-Reply-To: <1458743800-30606-1-git-send-email-mussitantesmortem@gmail.com>
On Wed, 2016-03-23 at 17:36 +0300, Maxim Zhukov wrote:
> This commit fixed spacing errors and warnings.
This commit log should show that you've tested this
by stating something like:
"git diff -w shows no difference"
and
"objdiff shows no changes"
If objdiff shows changes, you need to be show
why it's OK.
^ permalink raw reply
* [PATCH net] ppp: take reference on channels netns
From: Guillaume Nault @ 2016-03-23 15:38 UTC (permalink / raw)
To: netdev; +Cc: Cyrill Gorcunov, Baozeng Ding, Paul Mackerras, David Miller
Let channels hold a reference on their network namespace.
Some channel types, like ppp_async and ppp_synctty, can have their
userspace controller running in a different namespace. Therefore they
can't rely on them to preclude their netns from being removed from
under them.
==================================================================
BUG: KASAN: use-after-free in ppp_unregister_channel+0x372/0x3a0 at
addr ffff880064e217e0
Read of size 8 by task syz-executor/11581
=============================================================================
BUG net_namespace (Not tainted): kasan: bad access detected
-----------------------------------------------------------------------------
Disabling lock debugging due to kernel taint
INFO: Allocated in copy_net_ns+0x6b/0x1a0 age=92569 cpu=3 pid=6906
[< none >] ___slab_alloc+0x4c7/0x500 kernel/mm/slub.c:2440
[< none >] __slab_alloc+0x4c/0x90 kernel/mm/slub.c:2469
[< inline >] slab_alloc_node kernel/mm/slub.c:2532
[< inline >] slab_alloc kernel/mm/slub.c:2574
[< none >] kmem_cache_alloc+0x23a/0x2b0 kernel/mm/slub.c:2579
[< inline >] kmem_cache_zalloc kernel/include/linux/slab.h:597
[< inline >] net_alloc kernel/net/core/net_namespace.c:325
[< none >] copy_net_ns+0x6b/0x1a0 kernel/net/core/net_namespace.c:360
[< none >] create_new_namespaces+0x2f6/0x610 kernel/kernel/nsproxy.c:95
[< none >] copy_namespaces+0x297/0x320 kernel/kernel/nsproxy.c:150
[< none >] copy_process.part.35+0x1bf4/0x5760 kernel/kernel/fork.c:1451
[< inline >] copy_process kernel/kernel/fork.c:1274
[< none >] _do_fork+0x1bc/0xcb0 kernel/kernel/fork.c:1723
[< inline >] SYSC_clone kernel/kernel/fork.c:1832
[< none >] SyS_clone+0x37/0x50 kernel/kernel/fork.c:1826
[< none >] entry_SYSCALL_64_fastpath+0x16/0x7a kernel/arch/x86/entry/entry_64.S:185
INFO: Freed in net_drop_ns+0x67/0x80 age=575 cpu=2 pid=2631
[< none >] __slab_free+0x1fc/0x320 kernel/mm/slub.c:2650
[< inline >] slab_free kernel/mm/slub.c:2805
[< none >] kmem_cache_free+0x2a0/0x330 kernel/mm/slub.c:2814
[< inline >] net_free kernel/net/core/net_namespace.c:341
[< none >] net_drop_ns+0x67/0x80 kernel/net/core/net_namespace.c:348
[< none >] cleanup_net+0x4e5/0x600 kernel/net/core/net_namespace.c:448
[< none >] process_one_work+0x794/0x1440 kernel/kernel/workqueue.c:2036
[< none >] worker_thread+0xdb/0xfc0 kernel/kernel/workqueue.c:2170
[< none >] kthread+0x23f/0x2d0 kernel/drivers/block/aoe/aoecmd.c:1303
[< none >] ret_from_fork+0x3f/0x70 kernel/arch/x86/entry/entry_64.S:468
INFO: Slab 0xffffea0001938800 objects=3 used=0 fp=0xffff880064e20000
flags=0x5fffc0000004080
INFO: Object 0xffff880064e20000 @offset=0 fp=0xffff880064e24200
CPU: 1 PID: 11581 Comm: syz-executor Tainted: G B 4.4.0+
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
rel-1.8.2-0-g33fbe13 by qemu-project.org 04/01/2014
00000000ffffffff ffff8800662c7790 ffffffff8292049d ffff88003e36a300
ffff880064e20000 ffff880064e20000 ffff8800662c77c0 ffffffff816f2054
ffff88003e36a300 ffffea0001938800 ffff880064e20000 0000000000000000
Call Trace:
[< inline >] __dump_stack kernel/lib/dump_stack.c:15
[<ffffffff8292049d>] dump_stack+0x6f/0xa2 kernel/lib/dump_stack.c:50
[<ffffffff816f2054>] print_trailer+0xf4/0x150 kernel/mm/slub.c:654
[<ffffffff816f875f>] object_err+0x2f/0x40 kernel/mm/slub.c:661
[< inline >] print_address_description kernel/mm/kasan/report.c:138
[<ffffffff816fb0c5>] kasan_report_error+0x215/0x530 kernel/mm/kasan/report.c:236
[< inline >] kasan_report kernel/mm/kasan/report.c:259
[<ffffffff816fb4de>] __asan_report_load8_noabort+0x3e/0x40 kernel/mm/kasan/report.c:280
[< inline >] ? ppp_pernet kernel/include/linux/compiler.h:218
[<ffffffff83ad71b2>] ? ppp_unregister_channel+0x372/0x3a0 kernel/drivers/net/ppp/ppp_generic.c:2392
[< inline >] ppp_pernet kernel/include/linux/compiler.h:218
[<ffffffff83ad71b2>] ppp_unregister_channel+0x372/0x3a0 kernel/drivers/net/ppp/ppp_generic.c:2392
[< inline >] ? ppp_pernet kernel/drivers/net/ppp/ppp_generic.c:293
[<ffffffff83ad6f26>] ? ppp_unregister_channel+0xe6/0x3a0 kernel/drivers/net/ppp/ppp_generic.c:2392
[<ffffffff83ae18f3>] ppp_asynctty_close+0xa3/0x130 kernel/drivers/net/ppp/ppp_async.c:241
[<ffffffff83ae1850>] ? async_lcp_peek+0x5b0/0x5b0 kernel/drivers/net/ppp/ppp_async.c:1000
[<ffffffff82c33239>] tty_ldisc_close.isra.1+0x99/0xe0 kernel/drivers/tty/tty_ldisc.c:478
[<ffffffff82c332c0>] tty_ldisc_kill+0x40/0x170 kernel/drivers/tty/tty_ldisc.c:744
[<ffffffff82c34943>] tty_ldisc_release+0x1b3/0x260 kernel/drivers/tty/tty_ldisc.c:772
[<ffffffff82c1ef21>] tty_release+0xac1/0x13e0 kernel/drivers/tty/tty_io.c:1901
[<ffffffff82c1e460>] ? release_tty+0x320/0x320 kernel/drivers/tty/tty_io.c:1688
[<ffffffff8174de36>] __fput+0x236/0x780 kernel/fs/file_table.c:208
[<ffffffff8174e405>] ____fput+0x15/0x20 kernel/fs/file_table.c:244
[<ffffffff813595ab>] task_work_run+0x16b/0x200 kernel/kernel/task_work.c:115
[< inline >] exit_task_work kernel/include/linux/task_work.h:21
[<ffffffff81307105>] do_exit+0x8b5/0x2c60 kernel/kernel/exit.c:750
[<ffffffff813fdd20>] ? debug_check_no_locks_freed+0x290/0x290 kernel/kernel/locking/lockdep.c:4123
[<ffffffff81306850>] ? mm_update_next_owner+0x6f0/0x6f0 kernel/kernel/exit.c:357
[<ffffffff813215e6>] ? __dequeue_signal+0x136/0x470 kernel/kernel/signal.c:550
[<ffffffff8132067b>] ? recalc_sigpending_tsk+0x13b/0x180 kernel/kernel/signal.c:145
[<ffffffff81309628>] do_group_exit+0x108/0x330 kernel/kernel/exit.c:880
[<ffffffff8132b9d4>] get_signal+0x5e4/0x14f0 kernel/kernel/signal.c:2307
[< inline >] ? kretprobe_table_lock kernel/kernel/kprobes.c:1113
[<ffffffff8151d355>] ? kprobe_flush_task+0xb5/0x450 kernel/kernel/kprobes.c:1158
[<ffffffff8115f7d3>] do_signal+0x83/0x1c90 kernel/arch/x86/kernel/signal.c:712
[<ffffffff8151d2a0>] ? recycle_rp_inst+0x310/0x310 kernel/include/linux/list.h:655
[<ffffffff8115f750>] ? setup_sigcontext+0x780/0x780 kernel/arch/x86/kernel/signal.c:165
[<ffffffff81380864>] ? finish_task_switch+0x424/0x5f0 kernel/kernel/sched/core.c:2692
[< inline >] ? finish_lock_switch kernel/kernel/sched/sched.h:1099
[<ffffffff81380560>] ? finish_task_switch+0x120/0x5f0 kernel/kernel/sched/core.c:2678
[< inline >] ? context_switch kernel/kernel/sched/core.c:2807
[<ffffffff85d794e9>] ? __schedule+0x919/0x1bd0 kernel/kernel/sched/core.c:3283
[<ffffffff81003901>] exit_to_usermode_loop+0xf1/0x1a0 kernel/arch/x86/entry/common.c:247
[< inline >] prepare_exit_to_usermode kernel/arch/x86/entry/common.c:282
[<ffffffff810062ef>] syscall_return_slowpath+0x19f/0x210 kernel/arch/x86/entry/common.c:344
[<ffffffff85d88022>] int_ret_from_sys_call+0x25/0x9f kernel/arch/x86/entry/entry_64.S:281
Memory state around the buggy address:
ffff880064e21680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff880064e21700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff880064e21780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff880064e21800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff880064e21880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Fixes: 273ec51dd7ce ("net: ppp_generic - introduce net-namespace functionality v2")
Reported-by: Baozeng Ding <sploving1@gmail.com>
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
---
drivers/net/ppp/ppp_generic.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 4fd8610..f572b31 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -2307,7 +2307,7 @@ int ppp_register_net_channel(struct net *net, struct ppp_channel *chan)
pch->ppp = NULL;
pch->chan = chan;
- pch->chan_net = net;
+ pch->chan_net = get_net(net);
chan->ppp = pch;
init_ppp_file(&pch->file, CHANNEL);
pch->file.hdrlen = chan->hdrlen;
@@ -2404,6 +2404,8 @@ ppp_unregister_channel(struct ppp_channel *chan)
spin_lock_bh(&pn->all_channels_lock);
list_del(&pch->list);
spin_unlock_bh(&pn->all_channels_lock);
+ put_net(pch->chan_net);
+ pch->chan_net = NULL;
pch->file.dead = 1;
wake_up_interruptible(&pch->file.rwait);
--
2.8.0.rc3
^ permalink raw reply related
* Re: b43: Fix memory leaks in b43_bus_dev_ssb_init andb43_bus_dev_bcma_init
From: Kalle Valo @ 2016-03-23 15:51 UTC (permalink / raw)
To: Sudip Mukherjee
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-wireless-u79uwXL29TY76Z2rM5mHXA,
b43-dev-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
netdev-u79uwXL29TY76Z2rM5mHXA, Jia-Ju Bai, Michael Büsch
In-Reply-To: <1457716477-6287-1-git-send-email-sudipm.mukherjee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 832 bytes --]
> From: Jia-Ju Bai <baijiaju1990-9Onoh4P/yGk@public.gmane.org>
>
> The memory allocated by kzalloc in b43_bus_dev_ssb_init and
> b43_bus_dev_bcma_init is not freed.
> This patch fixes the bug by adding kfree in b43_ssb_remove,
> b43_bcma_remove and error handling code of b43_bcma_probe.
>
> Thanks Michael for his suggestion.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990-9Onoh4P/yGk@public.gmane.org>
> Acked-by: Michael Büsch <m@bues.ch>
> Signed-off-by: Sudip Mukherjee <sudip.mukherjee-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>
Thanks, applied to wireless-drivers.git.
Kalle Valo
--
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
* Re: b43: Fix memory leaks in b43_bus_dev_ssb_init andb43_bus_dev_bcma_init
From: Kalle Valo @ 2016-03-23 15:51 UTC (permalink / raw)
To: Sudip Mukherjee
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-wireless-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Jia-Ju Bai,
b43-dev-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Michael Büsch
In-Reply-To: <1457716477-6287-1-git-send-email-sudipm.mukherjee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 590 bytes --]
> From: Jia-Ju Bai <baijiaju1990-9Onoh4P/yGk@public.gmane.org>
>
> The memory allocated by kzalloc in b43_bus_dev_ssb_init and
> b43_bus_dev_bcma_init is not freed.
> This patch fixes the bug by adding kfree in b43_ssb_remove,
> b43_bcma_remove and error handling code of b43_bcma_probe.
>
> Thanks Michael for his suggestion.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990-9Onoh4P/yGk@public.gmane.org>
> Acked-by: Michael Büsch <m@bues.ch>
> Signed-off-by: Sudip Mukherjee <sudip.mukherjee-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>
Thanks, applied to wireless-drivers.git.
Kalle Valo
[-- Attachment #2: Type: text/plain, Size: 179 bytes --]
_______________________________________________
b43-dev mailing list
b43-dev-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
http://lists.infradead.org/mailman/listinfo/b43-dev
^ permalink raw reply
* Re: rtlwifi: fix gcc-6 indentation warning
From: Kalle Valo @ 2016-03-23 15:53 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Larry Finger, Chaoming Li, Arnd Bergmann, linux-wireless, netdev,
linux-kernel
In-Reply-To: <1458209066-3979295-1-git-send-email-arnd@arndb.de>
> The rtl8821ae_dm_txpower_tracking_callback_thermalmeter function
> contains a call to RT_TRACE() that is indented in a misleading
> way, as pointed out by a gcc-6 warning:
>
> drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c: In function 'rtl8821ae_dm_txpower_tracking_callback_thermalmeter':
> drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c:2491:4: error: statement is indented as if it were guarded by...
> RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
> ^~~~~~~~
> drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c:2488:3: note: ...this 'for' clause, but it is not
> for (p = RF90_PATH_A; p < MAX_PATH_NUM_8821A; p++)
> ^~~
>
> It is clear from the context that the call was not meant to be
> part of the loop and only the indentation is wrong, so this
> removes the extra tabs.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Thanks, applied to wireless-drivers.git.
Kalle Valo
^ permalink raw reply
* [PATCH 1/2] net: ethernet: dlink: dl2k: fix code style
From: Maxim Zhukov @ 2016-03-23 15:57 UTC (permalink / raw)
To: davem; +Cc: linux, netdev, linux-kernel, Maxim Zhukov
This commit fixed spacing errors and warnings.
this output command git diff origin/master -w drivers/net/ethernet/dlink
diff --git a/drivers/net/ethernet/dlink/dl2k.c
b/drivers/net/ethernet/dlink/dl2k.c
index f92b6d9..e635b1e 100644
--- a/drivers/net/ethernet/dlink/dl2k.c
+++ b/drivers/net/ethernet/dlink/dl2k.c
@@ -1892,4 +1892,3 @@ gcc -D__KERNEL__ -DMODULE -I/usr/src/linux/include
-Wall -Wstrict-prototypes -O2
Read Documentation/networking/dl2k.txt for details.
Signed-off-by: Maxim Zhukov <mussitantesmortem@gmail.com>
---
drivers/net/ethernet/dlink/dl2k.c | 491 +++++++++++++++++++-------------------
1 file changed, 245 insertions(+), 246 deletions(-)
diff --git a/drivers/net/ethernet/dlink/dl2k.c b/drivers/net/ethernet/dlink/dl2k.c
index f92b6d9..d128306 100644
--- a/drivers/net/ethernet/dlink/dl2k.c
+++ b/drivers/net/ethernet/dlink/dl2k.c
@@ -30,16 +30,16 @@ static int mtu[MAX_UNITS];
static int vlan[MAX_UNITS];
static int jumbo[MAX_UNITS];
static char *media[MAX_UNITS];
-static int tx_flow=-1;
-static int rx_flow=-1;
+static int tx_flow = -1;
+static int rx_flow = -1;
static int copy_thresh;
-static int rx_coalesce=10; /* Rx frame count each interrupt */
-static int rx_timeout=200; /* Rx DMA wait time in 640ns increments */
-static int tx_coalesce=16; /* HW xmit count each TxDMAComplete */
+static int rx_coalesce = 10; /* Rx frame count each interrupt */
+static int rx_timeout = 200; /* Rx DMA wait time in 640ns increments */
+static int tx_coalesce = 16; /* HW xmit count each TxDMAComplete */
-MODULE_AUTHOR ("Edward Peng");
-MODULE_DESCRIPTION ("D-Link DL2000-based Gigabit Ethernet Adapter");
+MODULE_AUTHOR("Edward Peng");
+MODULE_DESCRIPTION("D-Link DL2000-based Gigabit Ethernet Adapter");
MODULE_LICENSE("GPL");
module_param_array(mtu, int, NULL, 0);
module_param_array(media, charp, NULL, 0);
@@ -54,7 +54,7 @@ module_param(tx_coalesce, int, 0); /* HW xmit count each TxDMAComplete */
/* Enable the default interrupts */
-#define DEFAULT_INTR (RxDMAComplete | HostError | IntRequested | TxDMAComplete| \
+#define DEFAULT_INTR (RxDMAComplete | HostError | IntRequested | TxDMAComplete | \
UpdateStats | LinkEvent)
static void dl2k_enable_int(struct netdev_private *np)
@@ -67,32 +67,32 @@ static void dl2k_enable_int(struct netdev_private *np)
static const int max_intrloop = 50;
static const int multicast_filter_limit = 0x40;
-static int rio_open (struct net_device *dev);
-static void rio_timer (unsigned long data);
-static void rio_tx_timeout (struct net_device *dev);
-static netdev_tx_t start_xmit (struct sk_buff *skb, struct net_device *dev);
-static irqreturn_t rio_interrupt (int irq, void *dev_instance);
-static void rio_free_tx (struct net_device *dev, int irq);
-static void tx_error (struct net_device *dev, int tx_status);
-static int receive_packet (struct net_device *dev);
-static void rio_error (struct net_device *dev, int int_status);
-static int change_mtu (struct net_device *dev, int new_mtu);
-static void set_multicast (struct net_device *dev);
-static struct net_device_stats *get_stats (struct net_device *dev);
-static int clear_stats (struct net_device *dev);
-static int rio_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
-static int rio_close (struct net_device *dev);
-static int find_miiphy (struct net_device *dev);
-static int parse_eeprom (struct net_device *dev);
-static int read_eeprom (struct netdev_private *, int eep_addr);
-static int mii_wait_link (struct net_device *dev, int wait);
-static int mii_set_media (struct net_device *dev);
-static int mii_get_media (struct net_device *dev);
-static int mii_set_media_pcs (struct net_device *dev);
-static int mii_get_media_pcs (struct net_device *dev);
-static int mii_read (struct net_device *dev, int phy_addr, int reg_num);
-static int mii_write (struct net_device *dev, int phy_addr, int reg_num,
- u16 data);
+static int rio_open(struct net_device *dev);
+static void rio_timer(unsigned long data);
+static void rio_tx_timeout(struct net_device *dev);
+static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev);
+static irqreturn_t rio_interrupt(int irq, void *dev_instance);
+static void rio_free_tx(struct net_device *dev, int irq);
+static void tx_error(struct net_device *dev, int tx_status);
+static int receive_packet(struct net_device *dev);
+static void rio_error(struct net_device *dev, int int_status);
+static int change_mtu(struct net_device *dev, int new_mtu);
+static void set_multicast(struct net_device *dev);
+static struct net_device_stats *get_stats(struct net_device *dev);
+static int clear_stats(struct net_device *dev);
+static int rio_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
+static int rio_close(struct net_device *dev);
+static int find_miiphy(struct net_device *dev);
+static int parse_eeprom(struct net_device *dev);
+static int read_eeprom(struct netdev_private *, int eep_addr);
+static int mii_wait_link(struct net_device *dev, int wait);
+static int mii_set_media(struct net_device *dev);
+static int mii_get_media(struct net_device *dev);
+static int mii_set_media_pcs(struct net_device *dev);
+static int mii_get_media_pcs(struct net_device *dev);
+static int mii_read(struct net_device *dev, int phy_addr, int reg_num);
+static int mii_write(struct net_device *dev, int phy_addr, int reg_num,
+ u16 data);
static const struct ethtool_ops ethtool_ops;
@@ -102,7 +102,7 @@ static const struct net_device_ops netdev_ops = {
.ndo_stop = rio_close,
.ndo_get_stats = get_stats,
.ndo_validate_addr = eth_validate_addr,
- .ndo_set_mac_address = eth_mac_addr,
+ .ndo_set_mac_address = eth_mac_addr,
.ndo_set_rx_mode = set_multicast,
.ndo_do_ioctl = rio_ioctl,
.ndo_tx_timeout = rio_tx_timeout,
@@ -110,7 +110,7 @@ static const struct net_device_ops netdev_ops = {
};
static int
-rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
+rio_probe1(struct pci_dev *pdev, const struct pci_device_id *ent)
{
struct net_device *dev;
struct netdev_private *np;
@@ -123,22 +123,22 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
dma_addr_t ring_dma;
if (!version_printed++)
- printk ("%s", version);
+ printk("%s", version);
- err = pci_enable_device (pdev);
+ err = pci_enable_device(pdev);
if (err)
return err;
irq = pdev->irq;
- err = pci_request_regions (pdev, "dl2k");
+ err = pci_request_regions(pdev, "dl2k");
if (err)
goto err_out_disable;
- pci_set_master (pdev);
+ pci_set_master(pdev);
err = -ENOMEM;
- dev = alloc_etherdev (sizeof (*np));
+ dev = alloc_etherdev(sizeof(*np));
if (!dev)
goto err_out_res;
SET_NETDEV_DEV(dev, &pdev->dev);
@@ -160,8 +160,8 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
np->ioaddr = ioaddr;
np->chip_id = chip_idx;
np->pdev = pdev;
- spin_lock_init (&np->tx_lock);
- spin_lock_init (&np->rx_lock);
+ spin_lock_init(&np->tx_lock);
+ spin_lock_init(&np->rx_lock);
/* Parse manual configuration */
np->an_enable = 1;
@@ -169,32 +169,32 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
if (card_idx < MAX_UNITS) {
if (media[card_idx] != NULL) {
np->an_enable = 0;
- if (strcmp (media[card_idx], "auto") == 0 ||
- strcmp (media[card_idx], "autosense") == 0 ||
- strcmp (media[card_idx], "0") == 0 ) {
+ if (strcmp(media[card_idx], "auto") == 0 ||
+ strcmp(media[card_idx], "autosense") == 0 ||
+ strcmp(media[card_idx], "0") == 0) {
np->an_enable = 2;
- } else if (strcmp (media[card_idx], "100mbps_fd") == 0 ||
- strcmp (media[card_idx], "4") == 0) {
+ } else if (strcmp(media[card_idx], "100mbps_fd") == 0 ||
+ strcmp(media[card_idx], "4") == 0) {
np->speed = 100;
np->full_duplex = 1;
- } else if (strcmp (media[card_idx], "100mbps_hd") == 0 ||
- strcmp (media[card_idx], "3") == 0) {
+ } else if (strcmp(media[card_idx], "100mbps_hd") == 0 ||
+ strcmp(media[card_idx], "3") == 0) {
np->speed = 100;
np->full_duplex = 0;
- } else if (strcmp (media[card_idx], "10mbps_fd") == 0 ||
- strcmp (media[card_idx], "2") == 0) {
+ } else if (strcmp(media[card_idx], "10mbps_fd") == 0 ||
+ strcmp(media[card_idx], "2") == 0) {
np->speed = 10;
np->full_duplex = 1;
- } else if (strcmp (media[card_idx], "10mbps_hd") == 0 ||
- strcmp (media[card_idx], "1") == 0) {
+ } else if (strcmp(media[card_idx], "10mbps_hd") == 0 ||
+ strcmp(media[card_idx], "1") == 0) {
np->speed = 10;
np->full_duplex = 0;
- } else if (strcmp (media[card_idx], "1000mbps_fd") == 0 ||
- strcmp (media[card_idx], "6") == 0) {
- np->speed=1000;
- np->full_duplex=1;
- } else if (strcmp (media[card_idx], "1000mbps_hd") == 0 ||
- strcmp (media[card_idx], "5") == 0) {
+ } else if (strcmp(media[card_idx], "1000mbps_fd") == 0 ||
+ strcmp(media[card_idx], "6") == 0) {
+ np->speed = 1000;
+ np->full_duplex = 1;
+ } else if (strcmp(media[card_idx], "1000mbps_hd") == 0 ||
+ strcmp(media[card_idx], "5") == 0) {
np->speed = 1000;
np->full_duplex = 0;
} else {
@@ -221,7 +221,7 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
if (tx_coalesce < 1)
tx_coalesce = 1;
- else if (tx_coalesce > TX_RING_SIZE-1)
+ else if (tx_coalesce > TX_RING_SIZE - 1)
tx_coalesce = TX_RING_SIZE - 1;
}
dev->netdev_ops = &netdev_ops;
@@ -230,25 +230,25 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
#if 0
dev->features = NETIF_F_IP_CSUM;
#endif
- pci_set_drvdata (pdev, dev);
+ pci_set_drvdata(pdev, dev);
- ring_space = pci_alloc_consistent (pdev, TX_TOTAL_SIZE, &ring_dma);
+ ring_space = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma);
if (!ring_space)
goto err_out_iounmap;
np->tx_ring = ring_space;
np->tx_ring_dma = ring_dma;
- ring_space = pci_alloc_consistent (pdev, RX_TOTAL_SIZE, &ring_dma);
+ ring_space = pci_alloc_consistent(pdev, RX_TOTAL_SIZE, &ring_dma);
if (!ring_space)
goto err_out_unmap_tx;
np->rx_ring = ring_space;
np->rx_ring_dma = ring_dma;
/* Parse eeprom data */
- parse_eeprom (dev);
+ parse_eeprom(dev);
/* Find PHY address */
- err = find_miiphy (dev);
+ err = find_miiphy(dev);
if (err)
goto err_out_unmap_rx;
@@ -258,7 +258,7 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
/* Set media and reset PHY */
if (np->phy_media) {
/* default Auto-Negotiation for fiber deivices */
- if (np->an_enable == 2) {
+ if (np->an_enable == 2) {
np->an_enable = 1;
}
} else {
@@ -268,13 +268,13 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
np->an_enable = 1;
}
- err = register_netdev (dev);
+ err = register_netdev(dev);
if (err)
goto err_out_unmap_rx;
card_idx++;
- printk (KERN_INFO "%s: %s, %pM, IRQ %d\n",
+ printk(KERN_INFO "%s: %s, %pM, IRQ %d\n",
dev->name, np->name, dev->dev_addr, irq);
if (tx_coalesce > 1)
printk(KERN_INFO "tx_coalesce:\t%d packets\n",
@@ -283,31 +283,31 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
printk(KERN_INFO
"rx_coalesce:\t%d packets\n"
"rx_timeout: \t%d ns\n",
- np->rx_coalesce, np->rx_timeout*640);
+ np->rx_coalesce, np->rx_timeout * 640);
if (np->vlan)
printk(KERN_INFO "vlan(id):\t%d\n", np->vlan);
return 0;
err_out_unmap_rx:
- pci_free_consistent (pdev, RX_TOTAL_SIZE, np->rx_ring, np->rx_ring_dma);
+ pci_free_consistent(pdev, RX_TOTAL_SIZE, np->rx_ring, np->rx_ring_dma);
err_out_unmap_tx:
- pci_free_consistent (pdev, TX_TOTAL_SIZE, np->tx_ring, np->tx_ring_dma);
+ pci_free_consistent(pdev, TX_TOTAL_SIZE, np->tx_ring, np->tx_ring_dma);
err_out_iounmap:
#ifdef MEM_MAPPING
pci_iounmap(pdev, np->ioaddr);
#endif
pci_iounmap(pdev, np->eeprom_addr);
err_out_dev:
- free_netdev (dev);
+ free_netdev(dev);
err_out_res:
- pci_release_regions (pdev);
+ pci_release_regions(pdev);
err_out_disable:
- pci_disable_device (pdev);
+ pci_disable_device(pdev);
return err;
}
static int
-find_miiphy (struct net_device *dev)
+find_miiphy(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
int i, phy_found = 0;
@@ -315,21 +315,21 @@ find_miiphy (struct net_device *dev)
np->phy_addr = 1;
for (i = 31; i >= 0; i--) {
- int mii_status = mii_read (dev, i, 1);
+ int mii_status = mii_read(dev, i, 1);
if (mii_status != 0xffff && mii_status != 0x0000) {
np->phy_addr = i;
phy_found++;
}
}
if (!phy_found) {
- printk (KERN_ERR "%s: No MII PHY found!\n", dev->name);
+ printk(KERN_ERR "%s: No MII PHY found!\n", dev->name);
return -ENODEV;
}
return 0;
}
static int
-parse_eeprom (struct net_device *dev)
+parse_eeprom(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
@@ -337,18 +337,18 @@ parse_eeprom (struct net_device *dev)
u8 sromdata[256];
u8 *psib;
u32 crc;
- PSROM_t psrom = (PSROM_t) sromdata;
+ PSROM_t psrom = (PSROM_t)sromdata;
int cid, next;
for (i = 0; i < 128; i++)
- ((__le16 *) sromdata)[i] = cpu_to_le16(read_eeprom(np, i));
+ ((__le16 *)sromdata)[i] = cpu_to_le16(read_eeprom(np, i));
if (np->pdev->vendor == PCI_VENDOR_ID_DLINK) { /* D-Link Only */
/* Check CRC */
- crc = ~ether_crc_le (256 - 4, sromdata);
+ crc = ~ether_crc_le(256 - 4, sromdata);
if (psrom->crc != cpu_to_le32(crc)) {
- printk (KERN_ERR "%s: EEPROM data CRC error.\n",
+ printk(KERN_ERR "%s: EEPROM data CRC error.\n",
dev->name);
return -1;
}
@@ -369,12 +369,12 @@ parse_eeprom (struct net_device *dev)
/* Parse Software Information Block */
i = 0x30;
- psib = (u8 *) sromdata;
+ psib = (u8 *)sromdata;
do {
cid = psib[i++];
next = psib[i++];
if ((cid == 0 && next == 0) || (cid == 0xff && next == 0xff)) {
- printk (KERN_ERR "Cell data error\n");
+ printk(KERN_ERR "Cell data error\n");
return -1;
}
switch (cid) {
@@ -391,7 +391,7 @@ parse_eeprom (struct net_device *dev)
break;
case 9: /* Adapter description */
j = (next - i > 255) ? 255 : next - i;
- memcpy (np->name, &(psib[i]), j);
+ memcpy(np->name, &(psib[i]), j);
break;
case 4:
case 5:
@@ -560,7 +560,7 @@ static void rio_hw_init(struct net_device *dev)
/* Jumbo frame */
if (np->jumbo != 0)
- dw16(MaxFrameSize, MAX_JUMBO+14);
+ dw16(MaxFrameSize, MAX_JUMBO + 14);
/* Set RFDListPtr */
dw32(RFDListPtr0, np->rx_ring_dma);
@@ -574,7 +574,7 @@ static void rio_hw_init(struct net_device *dev)
dw16(StationAddr0 + 2 * i,
cpu_to_le16(((u16 *)dev->dev_addr)[i]));
- set_multicast (dev);
+ set_multicast(dev);
if (np->coalesce) {
dw32(RxDMAIntCtrl, np->rx_coalesce | np->rx_timeout << 16);
}
@@ -585,7 +585,7 @@ static void rio_hw_init(struct net_device *dev)
dw8(RxDMAUrgentThresh, 0x30);
dw32(RmonStatMask, 0x0007ffff);
/* clear statistics */
- clear_stats (dev);
+ clear_stats(dev);
/* VLAN supported */
if (np->vlan) {
@@ -646,19 +646,19 @@ static int rio_open(struct net_device *dev)
np->timer.expires = jiffies + 1 * HZ;
add_timer(&np->timer);
- netif_start_queue (dev);
+ netif_start_queue(dev);
dl2k_enable_int(np);
return 0;
}
static void
-rio_timer (unsigned long data)
+rio_timer(unsigned long data)
{
struct net_device *dev = (struct net_device *)data;
struct netdev_private *np = netdev_priv(dev);
unsigned int entry;
- int next_tick = 1*HZ;
+ int next_tick = 1 * HZ;
unsigned long flags;
spin_lock_irqsave(&np->rx_lock, flags);
@@ -675,14 +675,14 @@ rio_timer (unsigned long data)
np->rx_buf_sz);
if (skb == NULL) {
np->rx_ring[entry].fraginfo = 0;
- printk (KERN_INFO
+ printk(KERN_INFO
"%s: Still unable to re-allocate Rx skbuff.#%d\n",
dev->name, entry);
break;
}
np->rx_skbuff[entry] = skb;
np->rx_ring[entry].fraginfo =
- cpu_to_le64 (pci_map_single
+ cpu_to_le64(pci_map_single
(np->pdev, skb->data, np->rx_buf_sz,
PCI_DMA_FROMDEVICE));
}
@@ -691,18 +691,18 @@ rio_timer (unsigned long data)
np->rx_ring[entry].status = 0;
} /* end for */
} /* end if */
- spin_unlock_irqrestore (&np->rx_lock, flags);
+ spin_unlock_irqrestore(&np->rx_lock, flags);
np->timer.expires = jiffies + next_tick;
add_timer(&np->timer);
}
static void
-rio_tx_timeout (struct net_device *dev)
+rio_tx_timeout(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
- printk (KERN_INFO "%s: Tx timed out (%4.4x), is buffer full?\n",
+ printk(KERN_INFO "%s: Tx timed out (%4.4x), is buffer full?\n",
dev->name, dr32(TxStatus));
rio_free_tx(dev, 0);
dev->if_port = 0;
@@ -710,7 +710,7 @@ rio_tx_timeout (struct net_device *dev)
}
static netdev_tx_t
-start_xmit (struct sk_buff *skb, struct net_device *dev)
+start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
@@ -729,7 +729,7 @@ start_xmit (struct sk_buff *skb, struct net_device *dev)
#if 0
if (skb->ip_summed == CHECKSUM_PARTIAL) {
txdesc->status |=
- cpu_to_le64 (TCPChecksumEnable | UDPChecksumEnable |
+ cpu_to_le64(TCPChecksumEnable | UDPChecksumEnable |
IPChecksumEnable);
}
#endif
@@ -738,7 +738,7 @@ start_xmit (struct sk_buff *skb, struct net_device *dev)
((u64)np->vlan << 32) |
((u64)skb->priority << 45);
}
- txdesc->fraginfo = cpu_to_le64 (pci_map_single (np->pdev, skb->data,
+ txdesc->fraginfo = cpu_to_le64(pci_map_single(np->pdev, skb->data,
skb->len,
PCI_DMA_TODEVICE));
txdesc->fraginfo |= cpu_to_le64((u64)skb->len << 48);
@@ -746,12 +746,12 @@ start_xmit (struct sk_buff *skb, struct net_device *dev)
/* DL2K bug: DMA fails to get next descriptor ptr in 10Mbps mode
* Work around: Always use 1 descriptor in 10Mbps mode */
if (entry % np->tx_coalesce == 0 || np->speed == 10)
- txdesc->status = cpu_to_le64 (entry | tfc_vlan_tag |
+ txdesc->status = cpu_to_le64(entry | tfc_vlan_tag |
WordAlignDisable |
TxDMAIndicate |
(1 << FragCountShift));
else
- txdesc->status = cpu_to_le64 (entry | tfc_vlan_tag |
+ txdesc->status = cpu_to_le64(entry | tfc_vlan_tag |
WordAlignDisable |
(1 << FragCountShift));
@@ -764,13 +764,13 @@ start_xmit (struct sk_buff *skb, struct net_device *dev)
< TX_QUEUE_LEN - 1 && np->speed != 10) {
/* do nothing */
} else if (!netif_queue_stopped(dev)) {
- netif_stop_queue (dev);
+ netif_stop_queue(dev);
}
/* The first TFDListPtr */
if (!dr32(TFDListPtr0)) {
dw32(TFDListPtr0, np->tx_ring_dma +
- entry * sizeof (struct netdev_desc));
+ entry * sizeof(struct netdev_desc));
dw32(TFDListPtr1, 0);
}
@@ -778,7 +778,7 @@ start_xmit (struct sk_buff *skb, struct net_device *dev)
}
static irqreturn_t
-rio_interrupt (int irq, void *dev_instance)
+rio_interrupt(int irq, void *dev_instance)
{
struct net_device *dev = dev_instance;
struct netdev_private *np = netdev_priv(dev);
@@ -796,21 +796,21 @@ rio_interrupt (int irq, void *dev_instance)
handled = 1;
/* Processing received packets */
if (int_status & RxDMAComplete)
- receive_packet (dev);
+ receive_packet(dev);
/* TxDMAComplete interrupt */
- if ((int_status & (TxDMAComplete|IntRequested))) {
+ if ((int_status & (TxDMAComplete | IntRequested))) {
int tx_status;
tx_status = dr32(TxStatus);
if (tx_status & 0x01)
- tx_error (dev, tx_status);
+ tx_error(dev, tx_status);
/* Free used tx skbuffs */
- rio_free_tx (dev, 1);
+ rio_free_tx(dev, 1);
}
/* Handle uncommon events */
if (int_status &
(HostError | LinkEvent | UpdateStats))
- rio_error (dev, int_status);
+ rio_error(dev, int_status);
}
if (np->cur_tx != np->old_tx)
dw32(CountDown, 100);
@@ -818,7 +818,7 @@ rio_interrupt (int irq, void *dev_instance)
}
static void
-rio_free_tx (struct net_device *dev, int irq)
+rio_free_tx(struct net_device *dev, int irq)
{
struct netdev_private *np = netdev_priv(dev);
int entry = np->old_tx % TX_RING_SIZE;
@@ -837,13 +837,13 @@ rio_free_tx (struct net_device *dev, int irq)
if (!(np->tx_ring[entry].status & cpu_to_le64(TFDDone)))
break;
skb = np->tx_skbuff[entry];
- pci_unmap_single (np->pdev,
+ pci_unmap_single(np->pdev,
desc_to_dma(&np->tx_ring[entry]),
skb->len, PCI_DMA_TODEVICE);
if (irq)
- dev_kfree_skb_irq (skb);
+ dev_kfree_skb_irq(skb);
else
- dev_kfree_skb (skb);
+ dev_kfree_skb(skb);
np->tx_skbuff[entry] = NULL;
entry = (entry + 1) % TX_RING_SIZE;
@@ -861,12 +861,12 @@ rio_free_tx (struct net_device *dev, int irq)
if (netif_queue_stopped(dev) &&
((np->cur_tx - np->old_tx + TX_RING_SIZE) % TX_RING_SIZE
< TX_QUEUE_LEN - 1 || np->speed == 10)) {
- netif_wake_queue (dev);
+ netif_wake_queue(dev);
}
}
static void
-tx_error (struct net_device *dev, int tx_status)
+tx_error(struct net_device *dev, int tx_status)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
@@ -874,7 +874,7 @@ tx_error (struct net_device *dev, int tx_status)
int i;
frame_id = (tx_status & 0xffff0000);
- printk (KERN_ERR "%s: Transmit error, TxStatus %4.4x, FrameId %d.\n",
+ printk(KERN_ERR "%s: Transmit error, TxStatus %4.4x, FrameId %d.\n",
dev->name, tx_status, frame_id);
np->stats.tx_errors++;
/* Ttransmit Underrun */
@@ -888,13 +888,13 @@ tx_error (struct net_device *dev, int tx_status)
for (i = 50; i > 0; i--) {
if (!(dr16(ASICCtrl + 2) & ResetBusy))
break;
- mdelay (1);
+ mdelay(1);
}
rio_set_led_mode(dev);
- rio_free_tx (dev, 1);
+ rio_free_tx(dev, 1);
/* Reset TFDListPtr */
dw32(TFDListPtr0, np->tx_ring_dma +
- np->old_tx * sizeof (struct netdev_desc));
+ np->old_tx * sizeof(struct netdev_desc));
dw32(TFDListPtr1, 0);
/* Let TxStartThresh stay default value */
@@ -908,7 +908,7 @@ tx_error (struct net_device *dev, int tx_status)
for (i = 50; i > 0; i--) {
if (!(dr16(ASICCtrl + 2) & ResetBusy))
break;
- mdelay (1);
+ mdelay(1);
}
rio_set_led_mode(dev);
/* Let TxStartThresh stay default value */
@@ -926,7 +926,7 @@ tx_error (struct net_device *dev, int tx_status)
}
static int
-receive_packet (struct net_device *dev)
+receive_packet(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
int entry = np->cur_rx % RX_RING_SIZE;
@@ -958,33 +958,33 @@ receive_packet (struct net_device *dev)
if (frame_status & RxAlignmentError && np->speed != 1000)
np->stats.rx_frame_errors++;
if (frame_status & RxFIFOOverrun)
- np->stats.rx_fifo_errors++;
+ np->stats.rx_fifo_errors++;
} else {
struct sk_buff *skb;
/* Small skbuffs for short packets */
if (pkt_len > copy_thresh) {
- pci_unmap_single (np->pdev,
+ pci_unmap_single(np->pdev,
desc_to_dma(desc),
np->rx_buf_sz,
PCI_DMA_FROMDEVICE);
- skb_put (skb = np->rx_skbuff[entry], pkt_len);
+ skb_put(skb = np->rx_skbuff[entry], pkt_len);
np->rx_skbuff[entry] = NULL;
} else if ((skb = netdev_alloc_skb_ip_align(dev, pkt_len))) {
pci_dma_sync_single_for_cpu(np->pdev,
desc_to_dma(desc),
np->rx_buf_sz,
PCI_DMA_FROMDEVICE);
- skb_copy_to_linear_data (skb,
+ skb_copy_to_linear_data(skb,
np->rx_skbuff[entry]->data,
pkt_len);
- skb_put (skb, pkt_len);
+ skb_put(skb, pkt_len);
pci_dma_sync_single_for_device(np->pdev,
desc_to_dma(desc),
np->rx_buf_sz,
PCI_DMA_FROMDEVICE);
}
- skb->protocol = eth_type_trans (skb, dev);
+ skb->protocol = eth_type_trans(skb, dev);
#if 0
/* Checksum done by hw, but csum value unavailable. */
if (np->pdev->pci_rev_id >= 0x0c &&
@@ -992,7 +992,7 @@ receive_packet (struct net_device *dev)
skb->ip_summed = CHECKSUM_UNNECESSARY;
}
#endif
- netif_rx (skb);
+ netif_rx(skb);
}
entry = (entry + 1) % RX_RING_SIZE;
}
@@ -1007,7 +1007,7 @@ receive_packet (struct net_device *dev)
skb = netdev_alloc_skb_ip_align(dev, np->rx_buf_sz);
if (skb == NULL) {
np->rx_ring[entry].fraginfo = 0;
- printk (KERN_INFO
+ printk(KERN_INFO
"%s: receive_packet: "
"Unable to re-allocate Rx skbuff.#%d\n",
dev->name, entry);
@@ -1015,7 +1015,7 @@ receive_packet (struct net_device *dev)
}
np->rx_skbuff[entry] = skb;
np->rx_ring[entry].fraginfo =
- cpu_to_le64 (pci_map_single
+ cpu_to_le64(pci_map_single
(np->pdev, skb->data, np->rx_buf_sz,
PCI_DMA_FROMDEVICE));
}
@@ -1030,7 +1030,7 @@ receive_packet (struct net_device *dev)
}
static void
-rio_error (struct net_device *dev, int int_status)
+rio_error(struct net_device *dev, int int_status)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
@@ -1038,12 +1038,12 @@ rio_error (struct net_device *dev, int int_status)
/* Link change event */
if (int_status & LinkEvent) {
- if (mii_wait_link (dev, 10) == 0) {
- printk (KERN_INFO "%s: Link up\n", dev->name);
+ if (mii_wait_link(dev, 10) == 0) {
+ printk(KERN_INFO "%s: Link up\n", dev->name);
if (np->phy_media)
- mii_get_media_pcs (dev);
+ mii_get_media_pcs(dev);
else
- mii_get_media (dev);
+ mii_get_media(dev);
if (np->speed == 1000)
np->tx_coalesce = tx_coalesce;
else
@@ -1059,7 +1059,7 @@ rio_error (struct net_device *dev, int int_status)
np->link_status = 1;
netif_carrier_on(dev);
} else {
- printk (KERN_INFO "%s: Link off\n", dev->name);
+ printk(KERN_INFO "%s: Link off\n", dev->name);
np->link_status = 0;
netif_carrier_off(dev);
}
@@ -1067,22 +1067,22 @@ rio_error (struct net_device *dev, int int_status)
/* UpdateStats statistics registers */
if (int_status & UpdateStats) {
- get_stats (dev);
+ get_stats(dev);
}
/* PCI Error, a catastronphic error related to the bus interface
occurs, set GlobalReset and HostReset to reset. */
if (int_status & HostError) {
- printk (KERN_ERR "%s: HostError! IntStatus %4.4x.\n",
+ printk(KERN_ERR "%s: HostError! IntStatus %4.4x.\n",
dev->name, int_status);
dw16(ASICCtrl + 2, GlobalReset | HostReset);
- mdelay (500);
+ mdelay(500);
rio_set_led_mode(dev);
}
}
static struct net_device_stats *
-get_stats (struct net_device *dev)
+get_stats(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
@@ -1144,7 +1144,7 @@ get_stats (struct net_device *dev)
}
static int
-clear_stats (struct net_device *dev)
+clear_stats(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
@@ -1200,7 +1200,7 @@ clear_stats (struct net_device *dev)
static int
-change_mtu (struct net_device *dev, int new_mtu)
+change_mtu(struct net_device *dev, int new_mtu)
{
struct netdev_private *np = netdev_priv(dev);
int max = (np->jumbo) ? MAX_JUMBO : 1536;
@@ -1215,7 +1215,7 @@ change_mtu (struct net_device *dev, int new_mtu)
}
static void
-set_multicast (struct net_device *dev)
+set_multicast(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
@@ -1276,7 +1276,7 @@ static int rio_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
if (np->phy_media) {
/* fiber device */
cmd->supported = SUPPORTED_Autoneg | SUPPORTED_FIBRE;
- cmd->advertising= ADVERTISED_Autoneg | ADVERTISED_FIBRE;
+ cmd->advertising = ADVERTISED_Autoneg | ADVERTISED_FIBRE;
cmd->port = PORT_FIBRE;
cmd->transceiver = XCVR_INTERNAL;
} else {
@@ -1287,19 +1287,19 @@ static int rio_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
SUPPORTED_Autoneg | SUPPORTED_MII;
cmd->advertising = ADVERTISED_10baseT_Half |
ADVERTISED_10baseT_Full | ADVERTISED_100baseT_Half |
- ADVERTISED_100baseT_Full | ADVERTISED_1000baseT_Full|
+ ADVERTISED_100baseT_Full | ADVERTISED_1000baseT_Full |
ADVERTISED_Autoneg | ADVERTISED_MII;
cmd->port = PORT_MII;
cmd->transceiver = XCVR_INTERNAL;
}
- if ( np->link_status ) {
+ if (np->link_status) {
ethtool_cmd_speed_set(cmd, np->speed);
cmd->duplex = np->full_duplex ? DUPLEX_FULL : DUPLEX_HALF;
} else {
ethtool_cmd_speed_set(cmd, SPEED_UNKNOWN);
cmd->duplex = DUPLEX_UNKNOWN;
}
- if ( np->an_enable)
+ if (np->an_enable)
cmd->autoneg = AUTONEG_ENABLE;
else
cmd->autoneg = AUTONEG_DISABLE;
@@ -1359,7 +1359,7 @@ static const struct ethtool_ops ethtool_ops = {
};
static int
-rio_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
+rio_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
int phy_addr;
struct netdev_private *np = netdev_priv(dev);
@@ -1371,12 +1371,12 @@ rio_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
miidata->phy_id = phy_addr;
break;
case SIOCGMIIREG:
- miidata->val_out = mii_read (dev, phy_addr, miidata->reg_num);
+ miidata->val_out = mii_read(dev, phy_addr, miidata->reg_num);
break;
case SIOCSMIIREG:
if (!capable(CAP_NET_ADMIN))
return -EPERM;
- mii_write (dev, phy_addr, miidata->reg_num, miidata->val_in);
+ mii_write(dev, phy_addr, miidata->reg_num, miidata->val_in);
break;
default:
return -EOPNOTSUPP;
@@ -1408,20 +1408,20 @@ enum phy_ctrl_bits {
#define mii_delay() dr8(PhyCtrl)
static void
-mii_sendbit (struct net_device *dev, u32 data)
+mii_sendbit(struct net_device *dev, u32 data)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
data = ((data) ? MII_DATA1 : 0) | (dr8(PhyCtrl) & 0xf8) | MII_WRITE;
dw8(PhyCtrl, data);
- mii_delay ();
+ mii_delay();
dw8(PhyCtrl, data | MII_CLK);
- mii_delay ();
+ mii_delay();
}
static int
-mii_getbit (struct net_device *dev)
+mii_getbit(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->ioaddr;
@@ -1429,67 +1429,67 @@ mii_getbit (struct net_device *dev)
data = (dr8(PhyCtrl) & 0xf8) | MII_READ;
dw8(PhyCtrl, data);
- mii_delay ();
+ mii_delay();
dw8(PhyCtrl, data | MII_CLK);
- mii_delay ();
+ mii_delay();
return (dr8(PhyCtrl) >> 1) & 1;
}
static void
-mii_send_bits (struct net_device *dev, u32 data, int len)
+mii_send_bits(struct net_device *dev, u32 data, int len)
{
int i;
for (i = len - 1; i >= 0; i--) {
- mii_sendbit (dev, data & (1 << i));
+ mii_sendbit(dev, data & (1 << i));
}
}
static int
-mii_read (struct net_device *dev, int phy_addr, int reg_num)
+mii_read(struct net_device *dev, int phy_addr, int reg_num)
{
u32 cmd;
int i;
u32 retval = 0;
/* Preamble */
- mii_send_bits (dev, 0xffffffff, 32);
+ mii_send_bits(dev, 0xffffffff, 32);
/* ST(2), OP(2), ADDR(5), REG#(5), TA(2), Data(16) total 32 bits */
/* ST,OP = 0110'b for read operation */
cmd = (0x06 << 10 | phy_addr << 5 | reg_num);
- mii_send_bits (dev, cmd, 14);
+ mii_send_bits(dev, cmd, 14);
/* Turnaround */
- if (mii_getbit (dev))
+ if (mii_getbit(dev))
goto err_out;
/* Read data */
for (i = 0; i < 16; i++) {
- retval |= mii_getbit (dev);
+ retval |= mii_getbit(dev);
retval <<= 1;
}
/* End cycle */
- mii_getbit (dev);
+ mii_getbit(dev);
return (retval >> 1) & 0xffff;
err_out:
return 0;
}
static int
-mii_write (struct net_device *dev, int phy_addr, int reg_num, u16 data)
+mii_write(struct net_device *dev, int phy_addr, int reg_num, u16 data)
{
u32 cmd;
/* Preamble */
- mii_send_bits (dev, 0xffffffff, 32);
+ mii_send_bits(dev, 0xffffffff, 32);
/* ST(2), OP(2), ADDR(5), REG#(5), TA(2), Data(16) total 32 bits */
/* ST,OP,AAAAA,RRRRR,TA = 0101xxxxxxxxxx10'b = 0x5002 for write */
cmd = (0x5002 << 16) | (phy_addr << 23) | (reg_num << 18) | data;
- mii_send_bits (dev, cmd, 32);
+ mii_send_bits(dev, cmd, 32);
/* End cycle */
- mii_getbit (dev);
+ mii_getbit(dev);
return 0;
}
static int
-mii_wait_link (struct net_device *dev, int wait)
+mii_wait_link(struct net_device *dev, int wait)
{
__u16 bmsr;
int phy_addr;
@@ -1499,15 +1499,15 @@ mii_wait_link (struct net_device *dev, int wait)
phy_addr = np->phy_addr;
do {
- bmsr = mii_read (dev, phy_addr, MII_BMSR);
+ bmsr = mii_read(dev, phy_addr, MII_BMSR);
if (bmsr & BMSR_LSTATUS)
return 0;
- mdelay (1);
+ mdelay(1);
} while (--wait > 0);
return -1;
}
static int
-mii_get_media (struct net_device *dev)
+mii_get_media(struct net_device *dev)
{
__u16 negotiate;
__u16 bmsr;
@@ -1519,40 +1519,40 @@ mii_get_media (struct net_device *dev)
np = netdev_priv(dev);
phy_addr = np->phy_addr;
- bmsr = mii_read (dev, phy_addr, MII_BMSR);
+ bmsr = mii_read(dev, phy_addr, MII_BMSR);
if (np->an_enable) {
if (!(bmsr & BMSR_ANEGCOMPLETE)) {
/* Auto-Negotiation not completed */
return -1;
}
- negotiate = mii_read (dev, phy_addr, MII_ADVERTISE) &
- mii_read (dev, phy_addr, MII_LPA);
- mscr = mii_read (dev, phy_addr, MII_CTRL1000);
- mssr = mii_read (dev, phy_addr, MII_STAT1000);
+ negotiate = mii_read(dev, phy_addr, MII_ADVERTISE) &
+ mii_read(dev, phy_addr, MII_LPA);
+ mscr = mii_read(dev, phy_addr, MII_CTRL1000);
+ mssr = mii_read(dev, phy_addr, MII_STAT1000);
if (mscr & ADVERTISE_1000FULL && mssr & LPA_1000FULL) {
np->speed = 1000;
np->full_duplex = 1;
- printk (KERN_INFO "Auto 1000 Mbps, Full duplex\n");
+ printk(KERN_INFO "Auto 1000 Mbps, Full duplex\n");
} else if (mscr & ADVERTISE_1000HALF && mssr & LPA_1000HALF) {
np->speed = 1000;
np->full_duplex = 0;
- printk (KERN_INFO "Auto 1000 Mbps, Half duplex\n");
+ printk(KERN_INFO "Auto 1000 Mbps, Half duplex\n");
} else if (negotiate & ADVERTISE_100FULL) {
np->speed = 100;
np->full_duplex = 1;
- printk (KERN_INFO "Auto 100 Mbps, Full duplex\n");
+ printk(KERN_INFO "Auto 100 Mbps, Full duplex\n");
} else if (negotiate & ADVERTISE_100HALF) {
np->speed = 100;
np->full_duplex = 0;
- printk (KERN_INFO "Auto 100 Mbps, Half duplex\n");
+ printk(KERN_INFO "Auto 100 Mbps, Half duplex\n");
} else if (negotiate & ADVERTISE_10FULL) {
np->speed = 10;
np->full_duplex = 1;
- printk (KERN_INFO "Auto 10 Mbps, Full duplex\n");
+ printk(KERN_INFO "Auto 10 Mbps, Full duplex\n");
} else if (negotiate & ADVERTISE_10HALF) {
np->speed = 10;
np->full_duplex = 0;
- printk (KERN_INFO "Auto 10 Mbps, Half duplex\n");
+ printk(KERN_INFO "Auto 10 Mbps, Half duplex\n");
}
if (negotiate & ADVERTISE_PAUSE_CAP) {
np->tx_flow &= 1;
@@ -1563,21 +1563,21 @@ mii_get_media (struct net_device *dev)
}
/* else tx_flow, rx_flow = user select */
} else {
- __u16 bmcr = mii_read (dev, phy_addr, MII_BMCR);
+ __u16 bmcr = mii_read(dev, phy_addr, MII_BMCR);
switch (bmcr & (BMCR_SPEED100 | BMCR_SPEED1000)) {
case BMCR_SPEED1000:
- printk (KERN_INFO "Operating at 1000 Mbps, ");
+ printk(KERN_INFO "Operating at 1000 Mbps, ");
break;
case BMCR_SPEED100:
- printk (KERN_INFO "Operating at 100 Mbps, ");
+ printk(KERN_INFO "Operating at 100 Mbps, ");
break;
case 0:
- printk (KERN_INFO "Operating at 10 Mbps, ");
+ printk(KERN_INFO "Operating at 10 Mbps, ");
}
if (bmcr & BMCR_FULLDPLX) {
- printk (KERN_CONT "Full duplex\n");
+ printk(KERN_CONT "Full duplex\n");
} else {
- printk (KERN_CONT "Half duplex\n");
+ printk(KERN_CONT "Half duplex\n");
}
}
if (np->tx_flow)
@@ -1593,7 +1593,7 @@ mii_get_media (struct net_device *dev)
}
static int
-mii_set_media (struct net_device *dev)
+mii_set_media(struct net_device *dev)
{
__u16 pscr;
__u16 bmcr;
@@ -1607,8 +1607,8 @@ mii_set_media (struct net_device *dev)
/* Does user set speed? */
if (np->an_enable) {
/* Advertise capabilities */
- bmsr = mii_read (dev, phy_addr, MII_BMSR);
- anar = mii_read (dev, phy_addr, MII_ADVERTISE) &
+ bmsr = mii_read(dev, phy_addr, MII_BMSR);
+ anar = mii_read(dev, phy_addr, MII_ADVERTISE) &
~(ADVERTISE_100FULL | ADVERTISE_10FULL |
ADVERTISE_100HALF | ADVERTISE_10HALF |
ADVERTISE_100BASE4);
@@ -1623,66 +1623,66 @@ mii_set_media (struct net_device *dev)
if (bmsr & BMSR_10HALF)
anar |= ADVERTISE_10HALF;
anar |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;
- mii_write (dev, phy_addr, MII_ADVERTISE, anar);
+ mii_write(dev, phy_addr, MII_ADVERTISE, anar);
/* Enable Auto crossover */
- pscr = mii_read (dev, phy_addr, MII_PHY_SCR);
+ pscr = mii_read(dev, phy_addr, MII_PHY_SCR);
pscr |= 3 << 5; /* 11'b */
- mii_write (dev, phy_addr, MII_PHY_SCR, pscr);
+ mii_write(dev, phy_addr, MII_PHY_SCR, pscr);
/* Soft reset PHY */
- mii_write (dev, phy_addr, MII_BMCR, BMCR_RESET);
+ mii_write(dev, phy_addr, MII_BMCR, BMCR_RESET);
bmcr = BMCR_ANENABLE | BMCR_ANRESTART | BMCR_RESET;
- mii_write (dev, phy_addr, MII_BMCR, bmcr);
+ mii_write(dev, phy_addr, MII_BMCR, bmcr);
mdelay(1);
} else {
/* Force speed setting */
/* 1) Disable Auto crossover */
- pscr = mii_read (dev, phy_addr, MII_PHY_SCR);
+ pscr = mii_read(dev, phy_addr, MII_PHY_SCR);
pscr &= ~(3 << 5);
- mii_write (dev, phy_addr, MII_PHY_SCR, pscr);
+ mii_write(dev, phy_addr, MII_PHY_SCR, pscr);
/* 2) PHY Reset */
- bmcr = mii_read (dev, phy_addr, MII_BMCR);
+ bmcr = mii_read(dev, phy_addr, MII_BMCR);
bmcr |= BMCR_RESET;
- mii_write (dev, phy_addr, MII_BMCR, bmcr);
+ mii_write(dev, phy_addr, MII_BMCR, bmcr);
/* 3) Power Down */
bmcr = 0x1940; /* must be 0x1940 */
- mii_write (dev, phy_addr, MII_BMCR, bmcr);
- mdelay (100); /* wait a certain time */
+ mii_write(dev, phy_addr, MII_BMCR, bmcr);
+ mdelay(100); /* wait a certain time */
/* 4) Advertise nothing */
- mii_write (dev, phy_addr, MII_ADVERTISE, 0);
+ mii_write(dev, phy_addr, MII_ADVERTISE, 0);
/* 5) Set media and Power Up */
bmcr = BMCR_PDOWN;
if (np->speed == 100) {
bmcr |= BMCR_SPEED100;
- printk (KERN_INFO "Manual 100 Mbps, ");
+ printk(KERN_INFO "Manual 100 Mbps, ");
} else if (np->speed == 10) {
- printk (KERN_INFO "Manual 10 Mbps, ");
+ printk(KERN_INFO "Manual 10 Mbps, ");
}
if (np->full_duplex) {
bmcr |= BMCR_FULLDPLX;
- printk (KERN_CONT "Full duplex\n");
+ printk(KERN_CONT "Full duplex\n");
} else {
- printk (KERN_CONT "Half duplex\n");
+ printk(KERN_CONT "Half duplex\n");
}
#if 0
/* Set 1000BaseT Master/Slave setting */
- mscr = mii_read (dev, phy_addr, MII_CTRL1000);
+ mscr = mii_read(dev, phy_addr, MII_CTRL1000);
mscr |= MII_MSCR_CFG_ENABLE;
mscr &= ~MII_MSCR_CFG_VALUE = 0;
#endif
- mii_write (dev, phy_addr, MII_BMCR, bmcr);
+ mii_write(dev, phy_addr, MII_BMCR, bmcr);
mdelay(10);
}
return 0;
}
static int
-mii_get_media_pcs (struct net_device *dev)
+mii_get_media_pcs(struct net_device *dev)
{
__u16 negotiate;
__u16 bmsr;
@@ -1692,20 +1692,20 @@ mii_get_media_pcs (struct net_device *dev)
np = netdev_priv(dev);
phy_addr = np->phy_addr;
- bmsr = mii_read (dev, phy_addr, PCS_BMSR);
+ bmsr = mii_read(dev, phy_addr, PCS_BMSR);
if (np->an_enable) {
if (!(bmsr & BMSR_ANEGCOMPLETE)) {
/* Auto-Negotiation not completed */
return -1;
}
- negotiate = mii_read (dev, phy_addr, PCS_ANAR) &
- mii_read (dev, phy_addr, PCS_ANLPAR);
+ negotiate = mii_read(dev, phy_addr, PCS_ANAR) &
+ mii_read(dev, phy_addr, PCS_ANLPAR);
np->speed = 1000;
if (negotiate & PCS_ANAR_FULL_DUPLEX) {
- printk (KERN_INFO "Auto 1000 Mbps, Full duplex\n");
+ printk(KERN_INFO "Auto 1000 Mbps, Full duplex\n");
np->full_duplex = 1;
} else {
- printk (KERN_INFO "Auto 1000 Mbps, half duplex\n");
+ printk(KERN_INFO "Auto 1000 Mbps, half duplex\n");
np->full_duplex = 0;
}
if (negotiate & PCS_ANAR_PAUSE) {
@@ -1717,12 +1717,12 @@ mii_get_media_pcs (struct net_device *dev)
}
/* else tx_flow, rx_flow = user select */
} else {
- __u16 bmcr = mii_read (dev, phy_addr, PCS_BMCR);
- printk (KERN_INFO "Operating at 1000 Mbps, ");
+ __u16 bmcr = mii_read(dev, phy_addr, PCS_BMCR);
+ printk(KERN_INFO "Operating at 1000 Mbps, ");
if (bmcr & BMCR_FULLDPLX) {
- printk (KERN_CONT "Full duplex\n");
+ printk(KERN_CONT "Full duplex\n");
} else {
- printk (KERN_CONT "Half duplex\n");
+ printk(KERN_CONT "Half duplex\n");
}
}
if (np->tx_flow)
@@ -1738,7 +1738,7 @@ mii_get_media_pcs (struct net_device *dev)
}
static int
-mii_set_media_pcs (struct net_device *dev)
+mii_set_media_pcs(struct net_device *dev)
{
__u16 bmcr;
__u16 esr;
@@ -1751,8 +1751,8 @@ mii_set_media_pcs (struct net_device *dev)
/* Auto-Negotiation? */
if (np->an_enable) {
/* Advertise capabilities */
- esr = mii_read (dev, phy_addr, PCS_ESR);
- anar = mii_read (dev, phy_addr, MII_ADVERTISE) &
+ esr = mii_read(dev, phy_addr, PCS_ESR);
+ anar = mii_read(dev, phy_addr, MII_ADVERTISE) &
~PCS_ANAR_HALF_DUPLEX &
~PCS_ANAR_FULL_DUPLEX;
if (esr & (MII_ESR_1000BT_HD | MII_ESR_1000BX_HD))
@@ -1760,48 +1760,48 @@ mii_set_media_pcs (struct net_device *dev)
if (esr & (MII_ESR_1000BT_FD | MII_ESR_1000BX_FD))
anar |= PCS_ANAR_FULL_DUPLEX;
anar |= PCS_ANAR_PAUSE | PCS_ANAR_ASYMMETRIC;
- mii_write (dev, phy_addr, MII_ADVERTISE, anar);
+ mii_write(dev, phy_addr, MII_ADVERTISE, anar);
/* Soft reset PHY */
- mii_write (dev, phy_addr, MII_BMCR, BMCR_RESET);
+ mii_write(dev, phy_addr, MII_BMCR, BMCR_RESET);
bmcr = BMCR_ANENABLE | BMCR_ANRESTART | BMCR_RESET;
- mii_write (dev, phy_addr, MII_BMCR, bmcr);
+ mii_write(dev, phy_addr, MII_BMCR, bmcr);
mdelay(1);
} else {
/* Force speed setting */
/* PHY Reset */
bmcr = BMCR_RESET;
- mii_write (dev, phy_addr, MII_BMCR, bmcr);
+ mii_write(dev, phy_addr, MII_BMCR, bmcr);
mdelay(10);
if (np->full_duplex) {
bmcr = BMCR_FULLDPLX;
- printk (KERN_INFO "Manual full duplex\n");
+ printk(KERN_INFO "Manual full duplex\n");
} else {
bmcr = 0;
- printk (KERN_INFO "Manual half duplex\n");
+ printk(KERN_INFO "Manual half duplex\n");
}
- mii_write (dev, phy_addr, MII_BMCR, bmcr);
+ mii_write(dev, phy_addr, MII_BMCR, bmcr);
mdelay(10);
/* Advertise nothing */
- mii_write (dev, phy_addr, MII_ADVERTISE, 0);
+ mii_write(dev, phy_addr, MII_ADVERTISE, 0);
}
return 0;
}
static int
-rio_close (struct net_device *dev)
+rio_close(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
struct pci_dev *pdev = np->pdev;
- netif_stop_queue (dev);
+ netif_stop_queue(dev);
rio_hw_stop(dev);
free_irq(pdev->irq, dev);
- del_timer_sync (&np->timer);
+ del_timer_sync(&np->timer);
free_list(dev);
@@ -1809,25 +1809,25 @@ rio_close (struct net_device *dev)
}
static void
-rio_remove1 (struct pci_dev *pdev)
+rio_remove1(struct pci_dev *pdev)
{
- struct net_device *dev = pci_get_drvdata (pdev);
+ struct net_device *dev = pci_get_drvdata(pdev);
if (dev) {
struct netdev_private *np = netdev_priv(dev);
- unregister_netdev (dev);
- pci_free_consistent (pdev, RX_TOTAL_SIZE, np->rx_ring,
- np->rx_ring_dma);
- pci_free_consistent (pdev, TX_TOTAL_SIZE, np->tx_ring,
- np->tx_ring_dma);
+ unregister_netdev(dev);
+ pci_free_consistent(pdev, RX_TOTAL_SIZE, np->rx_ring,
+ np->rx_ring_dma);
+ pci_free_consistent(pdev, TX_TOTAL_SIZE, np->tx_ring,
+ np->tx_ring_dma);
#ifdef MEM_MAPPING
pci_iounmap(pdev, np->ioaddr);
#endif
pci_iounmap(pdev, np->eeprom_addr);
- free_netdev (dev);
- pci_release_regions (pdev);
- pci_disable_device (pdev);
+ free_netdev(dev);
+ pci_release_regions(pdev);
+ pci_disable_device(pdev);
}
}
@@ -1892,4 +1892,3 @@ gcc -D__KERNEL__ -DMODULE -I/usr/src/linux/include -Wall -Wstrict-prototypes -O2
Read Documentation/networking/dl2k.txt for details.
*/
-
--
2.7.1.1.g3617aa0
^ permalink raw reply related
* [PATCH 2/2] drivers: net: ethernet: dlink: dl2k: fix indent
From: Maxim Zhukov @ 2016-03-23 15:57 UTC (permalink / raw)
To: davem; +Cc: linux, netdev, linux-kernel, Maxim Zhukov
In-Reply-To: <1458748660-10571-1-git-send-email-mussitantesmortem@gmail.com>
This commit fixed indent in file. Labels must be start of the line
Signed-off-by: Maxim Zhukov <mussitantesmortem@gmail.com>
---
drivers/net/ethernet/dlink/dl2k.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/dlink/dl2k.c b/drivers/net/ethernet/dlink/dl2k.c
index d128306..e635b1e 100644
--- a/drivers/net/ethernet/dlink/dl2k.c
+++ b/drivers/net/ethernet/dlink/dl2k.c
@@ -98,7 +98,7 @@ static const struct ethtool_ops ethtool_ops;
static const struct net_device_ops netdev_ops = {
.ndo_open = rio_open,
- .ndo_start_xmit = start_xmit,
+ .ndo_start_xmit = start_xmit,
.ndo_stop = rio_close,
.ndo_get_stats = get_stats,
.ndo_validate_addr = eth_validate_addr,
@@ -174,7 +174,7 @@ rio_probe1(struct pci_dev *pdev, const struct pci_device_id *ent)
strcmp(media[card_idx], "0") == 0) {
np->an_enable = 2;
} else if (strcmp(media[card_idx], "100mbps_fd") == 0 ||
- strcmp(media[card_idx], "4") == 0) {
+ strcmp(media[card_idx], "4") == 0) {
np->speed = 100;
np->full_duplex = 1;
} else if (strcmp(media[card_idx], "100mbps_hd") == 0 ||
@@ -190,11 +190,11 @@ rio_probe1(struct pci_dev *pdev, const struct pci_device_id *ent)
np->speed = 10;
np->full_duplex = 0;
} else if (strcmp(media[card_idx], "1000mbps_fd") == 0 ||
- strcmp(media[card_idx], "6") == 0) {
+ strcmp(media[card_idx], "6") == 0) {
np->speed = 1000;
np->full_duplex = 1;
} else if (strcmp(media[card_idx], "1000mbps_hd") == 0 ||
- strcmp(media[card_idx], "5") == 0) {
+ strcmp(media[card_idx], "5") == 0) {
np->speed = 1000;
np->full_duplex = 0;
} else {
@@ -210,7 +210,7 @@ rio_probe1(struct pci_dev *pdev, const struct pci_device_id *ent)
dev->mtu = mtu[card_idx];
}
np->vlan = (vlan[card_idx] > 0 && vlan[card_idx] < 4096) ?
- vlan[card_idx] : 0;
+ vlan[card_idx] : 0;
if (rx_coalesce > 0 && rx_timeout > 0) {
np->rx_coalesce = rx_coalesce;
np->rx_timeout = rx_timeout;
@@ -278,12 +278,12 @@ rio_probe1(struct pci_dev *pdev, const struct pci_device_id *ent)
dev->name, np->name, dev->dev_addr, irq);
if (tx_coalesce > 1)
printk(KERN_INFO "tx_coalesce:\t%d packets\n",
- tx_coalesce);
+ tx_coalesce);
if (np->coalesce)
printk(KERN_INFO
"rx_coalesce:\t%d packets\n"
"rx_timeout: \t%d ns\n",
- np->rx_coalesce, np->rx_timeout * 640);
+ np->rx_coalesce, np->rx_timeout * 640);
if (np->vlan)
printk(KERN_INFO "vlan(id):\t%d\n", np->vlan);
return 0;
@@ -1470,7 +1470,7 @@ mii_read(struct net_device *dev, int phy_addr, int reg_num)
mii_getbit(dev);
return (retval >> 1) & 0xffff;
- err_out:
+err_out:
return 0;
}
static int
--
2.7.1.1.g3617aa0
^ permalink raw reply related
* Re: [PATCH net] ppp: take reference on channels netns
From: Cyrill Gorcunov @ 2016-03-23 16:02 UTC (permalink / raw)
To: Guillaume Nault; +Cc: netdev, Baozeng Ding, Paul Mackerras, David Miller
In-Reply-To: <4dbdfa8e264d5a635865c6e843c122daf9be4f8d.1458747209.git.g.nault@alphalink.fr>
On Wed, Mar 23, 2016 at 04:38:55PM +0100, Guillaume Nault wrote:
> Let channels hold a reference on their network namespace.
> Some channel types, like ppp_async and ppp_synctty, can have their
> userspace controller running in a different namespace. Therefore they
> can't rely on them to preclude their netns from being removed from
> under them.
>
...
>
> Fixes: 273ec51dd7ce ("net: ppp_generic - introduce net-namespace functionality v2")
> Reported-by: Baozeng Ding <sploving1@gmail.com>
> Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Good catch! Thanks!
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
^ permalink raw reply
* Re: [RFC PATCH 7/9] GSO: Support partial segmentation offload
From: Edward Cree @ 2016-03-23 16:27 UTC (permalink / raw)
To: Alexander Duyck; +Cc: Alexander Duyck, Netdev, David Miller, Tom Herbert
In-Reply-To: <CAKgT0UcAuOrBTcmj1ue8mK=j4dCqr-0bydHhRb+ghS1cZaUqrw@mail.gmail.com>
On 22/03/16 21:38, Alexander Duyck wrote:
> On Tue, Mar 22, 2016 at 12:40 PM, Edward Cree <ecree@solarflare.com> wrote:
>> But won't the tunnel dev have the feature flag for GSO_PARTIAL depending
>> on what the underlying dev advertises? (Or, at least, could we make it
>> bethatway?)
> This stuff doesn't work. That is why tunnels now advertise all
> available features that can be offloaded via software. Basically if
> we can advertise a feature we do, and then we sort things out in
> software if we cannot actually do it in hardware.
Fair enough; then go withthe other approach:
>> Alternatively, have per-protocol GSO callbacks to do the fixup in the
>> opposite direction to what you have now - in the long term we hope that
>> hardware supporting GSO partial will become the common case, so that
>> should be the fast path without bouncing backwards through GSO callbacks.
>> Then, if you find out at GSO time that the hardware wants to do old-style
>> TSO, you call those callbacks so as to give it a superframe with the long
>> lengths filled in everywhere.
> I thought about doing that but decided it was much simpler to simply
> update all headers. For now I want to keep this as simple as possible
> while we get the first few drivers on board. If we later want to
> optimize and add complexity we can go that route, but for now this
> change is more than fast enough as it allows me to push an i40e at
> 20Gb/s while sending frames with outer checksums enabled.
My belief is that my way is (in the long run) simpler: ultimately it gets
rid of per-protocol GSO callbacks entirely. Every header gets written
correctly* when the packet initially traverses the stack, and then at
transmit time you either hand that off to TSO, or do the equivalent thing
in software: segment at the TCP layer while treating everything above it
as an opaque pseudo-L2 header.
*That is, correctly for a single segment, rather than correctly for the
superframe.
>> Yes; it's a clever idea. Only trouble is that we really want theinner IP
>> header rather than the inner TCP header, so that we can (if we want to)
>> increment the inner IP IDs. Of course, if we Officially Don't Care about
>> inner IP IDs that's not a problem.
> The inner IP IDs are the ones that are guaranteed to be the ones we
> can leave fixed since TCP will require that the DF bit be set.
I was worrying about the SLHC stuff, I thought the inner ones were precisely
the ones where that was a problem. If we really don't care about it, then
we do just need the inner TCP header, and we can stick with using your
csum_start == gso_start trick :)
> The
> current VXLAN implementation does not set DF for the outer headers.
> So really we don't have too many options right now if we are wanting
> to support tunnels.
I was predicating all this on the assumption that tunnels would be changed
to set DF in their outer frames; I thought I saw a patch recently to do
that, but maybe I was mistaken. In any case I think that's the right thing
to do, and it's a necessary prerequisite for truly tunnel-agnostic TSO.
>> Iwonder if we could just always fill in inner_network_headereven if we're
>> not doing encapsulation. Or does it end up pointing to a 'middle' header
>> in the case of nested encap?
> Right now neseted encap is not supported because tunnels don't
> advertise hw_encap_features.
You mean not supported by offloads, right? We can still _create_ a nested
tunnel device, it just won't use hardware offloads. And in the long run,
if we can make tunnel-agnostic TSO as I'm proposing, we should be able to
support it for nested tunnels too (the giant L2 header just gets more giant).
>> Why not use the single-segment length in the pseudo-header, then the
>> outer L4 checksum is already the right thing? (And if yourhardware
>> can't be told to leave the outer L4 checksum alone, then it's not worth
>> the trouble of trying to support GSO partial for it, since it clearly
>> wants to do old-style "NIC knows best" TSO.)
> The problem then becomes that I needs special case code. One for
> standard TSO and one for this special case. If I leave it as is I can
> use the same code to cancel out the length in the TCP pseudo-header
> checksum for either case.
I don't think that's true. Look at it this way: there are two choices.
1) The normal path builds things for standard TSO, and we have code to
fix it up for this new-style TSO.
2) The normal path builds things for new-style TSO, and we have code to
fix it up for standard TSO.
Now the fix-up code should be of equal complexity in either case, because
the two cases are inverses of each other. So we should choose whichever
approach makes the normal path simpler. I think having TCP 'lie' to all
the outer layers about the length of the packet is simpler, because then
they don't even have to know that GSO is happening. They just append a
header appropriate for an MSS-sized packet, blissfully unaware that the
payload data carries on for longer than that.
Moreover, the fixup in (2) can sometimes be avoided...
I don't know how your hardware does encapsulated TSO, but what ours does
(in the old "I'm-a-smart-NIC-I-know-best" world) is that it computes both
checksums itself from scratch. So it doesn't care what it was given as
the pre-seeded value, because it's reconstructing the pseudo-header and
zeroing the checksum field to begin with.
I would have expected this to be the common behaviour for "smart" NICs
doing encap TSO, in which case (2) is a clear winner. And, of course,
once "less is more" hardware becomes common, we will want (2) anyway.
> The general idea to my approach is to treat the the UDP or GRE header
> to the inner IP header as an IP header extension type value. That
> will allow us to trick most hardware into being able to accept it.
I think an L2 header extension is a better semantic match for what's
happening (the tunnel is an L2 device and we're sending L3 packets over
it). But why does it matter? Are you giving the hardware the L2 and
L3 headers in separate DMA descriptors or something? The way I see it,
all hardware needs to be told is "where to start TSO from", and how it
thinks of the stuff before that doesn't matter, because it's not
supposed to touch it anyway.
>> Again, the idea is that we optimise for GSO partial by making it a plain
>> header copy everywhere, and put all the 'fix things up' on the _other_
>> path.
> That is what I went for. The only part that isn't a plain header copy
> is the TCP pseudo-header checksum.
Right, but that means someone, somewhere, has to fix up the outer UDP
checksum to account for that (because the TCP phdr sum leaks out of LCO).
I realise that's a per-superframe job, rather than a per-segment job, but
it still means that code at GSO time (when we decide whether to do GSO or
GSO-partial) has to know enough about the tunnel headers to find the outer
checksum and fix it up.
And it's a question of who pays that cost, the old TSO or the new one; see
above for why I think the old TSO should pay it.
> The only issue I see is the expectation that the outer headers go
> untouched is problematic. The outer headers are where things like
> fragmentation will occur in transit.
Like I say, I'm assuming we'll start setting DF on outer frames.
Besides, it doesn't matter what happens "in transit" - as long as the
outer headers aren't touched by the transmitting NIC, the network can
do what it likes to them afterwards, without it breaking our TSO code.
> In addition I suspect a number
> of devices other than the Intel NICs probably use the network header
> to determine where to insert L2 tags such as VLAN.
Ah, VLAN is interesting, because there's two things you might want:
VLAN inside the tunnel, or outside of it. Presumably if you're having
the NIC insert the VLAN, you want it outside (e.g. you're doing SR-IOV
and you're putting the VF on a VLAN).
But then it doesn't make sense to work backwards from the network
header, because that'll get confused by traffic that's already VLAN
tagged - because again, you want to insert the new VLAN as the outer
VLAN. You need to find the Ethertype, as well; it just seems like
working backwards from L3 is crazy. Particularly when working forwards
from L2 is so easy - you know your L2 header begins at the start of the
packet, you (hopefully) know it's Ethernet, so you know where the VLAN
tags and Ethertype go. (Are you /sure/ Intel works backwards from the
L3 header? I'm pretty confident we don't.)
Then of course this works fine with the 'giant L2 header', because the
NIC just inserts the VLAN as normal in the outer Ethernet header and
shunts the remaining headers along to make room for it. In fact, in
our NICs I think that's done by an entirely separate bit of hardware
that doesn't even have to know that TSO was considering much more of
the packet to be "L2 header".
_However_, if we don't need to update the IP IDs, then we can just take
the offset of the inner L4 header, and it doesn't make any difference
whether you choose to think of the stuff before that as L2 + giant L3
or as giant L2 + normal L3, because it's not part of the OS->NIC
interface (which is just "L4 starts here"). If your NIC needs to be
told where the outer L3 starts as well, then, I guess that's just a
wart you need in your drivers. You have skb->network_header, so that
shouldn't be difficult - that will always point to the outer one.
> Like I have said with the current solution I could probably update
> igb, igbvf, fm10k, ixgbe, ixgbevf, i40e, and i40evf to support this.
> That covers pretty much the entire Intel series of drivers in terms of
> enterprise. The question is what do I need to enable to support other
> drivers. It doesn't seem like there would be too much but the bit I
> would need to know is what the expectations are when computing outer
> IPv4 checksums.
Like I say, the plan we had for Solarflare NICs before "less is more"
happened was that the device would reconstruct the outer pseudo-header
(same as it does with the inner) and ignore any pre-seeded value in the
checksum field. I'd expected other vendors to have gone down the same
route, but if Intel didn't then maybe others didn't either. It'd be
nice if some of them would chime in and let us know what they want...
-Ed
^ permalink raw reply
* [PATCH] net: mlxsw: avoid unused variable warnings
From: Arnd Bergmann @ 2016-03-23 16:37 UTC (permalink / raw)
To: Jiri Pirko, Ido Schimmel
Cc: Arnd Bergmann, David S. Miller, Elad Raz, netdev, linux-kernel
dev_dbg_ratelimited() is a macro that ignores its arguments when DEBUG is
not set, which can lead to unused variable warnings:
ethernet/mellanox/mlxsw/pci.c: In function 'mlxsw_pci_cqe_sdq_handle':
ethernet/mellanox/mlxsw/pci.c:646:18: warning: unused variable 'pdev' [-Wunused-variable]
ethernet/mellanox/mlxsw/pci.c: In function 'mlxsw_pci_cqe_rdq_handle':
ethernet/mellanox/mlxsw/pci.c:671:18: warning: unused variable 'pdev' [-Wunused-variable]
This changes the mlxsw driver to remove the local variables we get
warnings for and instead pass the device directly into the API.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/ethernet/mellanox/mlxsw/pci.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c
index 7f4173c8eda3..fdcce03b028d 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/pci.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c
@@ -643,7 +643,6 @@ static void mlxsw_pci_cqe_sdq_handle(struct mlxsw_pci *mlxsw_pci,
u16 consumer_counter_limit,
char *cqe)
{
- struct pci_dev *pdev = mlxsw_pci->pdev;
struct mlxsw_pci_queue_elem_info *elem_info;
char *wqe;
struct sk_buff *skb;
@@ -659,7 +658,7 @@ static void mlxsw_pci_cqe_sdq_handle(struct mlxsw_pci *mlxsw_pci,
elem_info->u.sdq.skb = NULL;
if (q->consumer_counter++ != consumer_counter_limit)
- dev_dbg_ratelimited(&pdev->dev, "Consumer counter does not match limit in SDQ\n");
+ dev_dbg_ratelimited(&mlxsw_pci->pdev->dev, "Consumer counter does not match limit in SDQ\n");
spin_unlock(&q->lock);
}
@@ -668,7 +667,6 @@ static void mlxsw_pci_cqe_rdq_handle(struct mlxsw_pci *mlxsw_pci,
u16 consumer_counter_limit,
char *cqe)
{
- struct pci_dev *pdev = mlxsw_pci->pdev;
struct mlxsw_pci_queue_elem_info *elem_info;
char *wqe;
struct sk_buff *skb;
@@ -684,7 +682,7 @@ static void mlxsw_pci_cqe_rdq_handle(struct mlxsw_pci *mlxsw_pci,
mlxsw_pci_wqe_frag_unmap(mlxsw_pci, wqe, 0, DMA_FROM_DEVICE);
if (q->consumer_counter++ != consumer_counter_limit)
- dev_dbg_ratelimited(&pdev->dev, "Consumer counter does not match limit in RDQ\n");
+ dev_dbg_ratelimited(&mlxsw_pci->pdev->dev, "Consumer counter does not match limit in RDQ\n");
if (mlxsw_pci_cqe_lag_get(cqe)) {
rx_info.is_lag = true;
@@ -706,7 +704,7 @@ static void mlxsw_pci_cqe_rdq_handle(struct mlxsw_pci *mlxsw_pci,
memset(wqe, 0, q->elem_size);
err = mlxsw_pci_rdq_skb_alloc(mlxsw_pci, elem_info);
if (err)
- dev_dbg_ratelimited(&pdev->dev, "Failed to alloc skb for RDQ\n");
+ dev_dbg_ratelimited(&mlxsw_pci->pdev->dev, "Failed to alloc skb for RDQ\n");
/* Everything is set up, ring doorbell to pass elem to HW */
q->producer_counter++;
mlxsw_pci_queue_doorbell_producer_ring(mlxsw_pci, q);
--
2.7.0
^ permalink raw reply related
* Re: net/sctp: stack-out-of-bounds in sctp_getsockopt
From: Baozeng @ 2016-03-23 16:42 UTC (permalink / raw)
To: Eric Dumazet
Cc: pablo, kaber, kadlec, coreteam, netfilter-devel,
Vladislav Yasevich, nhorman, davem, linux-sctp, netdev,
linux-kernel
In-Reply-To: <1458660478.10868.21.camel@edumazet-glaptop3.roam.corp.google.com>
2016-03-22 23:27 GMT+08:00 Eric Dumazet <eric.dumazet@gmail.com>:
>
> On Tue, 2016-03-22 at 08:21 -0700, Eric Dumazet wrote:
> > On Tue, 2016-03-22 at 23:08 +0800, Baozeng Ding wrote:
> > > Hi all,
> > >
> > > The following program triggers an out-of-bounds bug in
> > > sctp_getsockopt. The kernel version is 4.5 (on Mar 16
> > > commit 09fd671ccb2475436bd5f597f751ca4a7d177aea).
> > >
> > > ==================================================================
> > > BUG: KASAN: stack-out-of-bounds in string+0x1ef/0x200 at addr
> > > ffff88003ae679e0
> > > Read of size 1 by task syz-executor/19753
> > > page:ffffea0000eb99c0 count:0 mapcount:0 mapping: (null)
> > > index:0x0
> > > flags: 0x1fffc0000000000()
> > > page dumped because: kasan: bad access detected
> > > CPU: 3 PID: 19753 Comm: syz-executor Not tainted 4.5.0+ #8
> > > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
> > > rel-1.8.2-0-g33fbe13 by qemu-project.org 04/01/2014
> > > 0000000000000003 ffff88003ae67578 ffffffff82945051 ffff88003ae67608
> > > ffff88003ae679e0 0000000000000096 dffffc0000000000 ffff88003ae675f8
> > > ffffffff81709f88 000000000000030d 0000000000000000 0000000000000286
> > > Call Trace:
> > > [< inline >] __dump_stack lib/dump_stack.c:15
> > > [<ffffffff82945051>] dump_stack+0xb3/0x112 lib/dump_stack.c:51
> > > [< inline >] print_address_description mm/kasan/report.c:150
> > > [<ffffffff81709f88>] kasan_report_error+0x4f8/0x530 mm/kasan/report.c:236
> > > [<ffffffff8140785b>] ? __lock_acquire+0x15fb/0x5dd0 kernel/locking/lockdep.c:3226
> > > [< inline >] kasan_report mm/kasan/report.c:259
> > > [<ffffffff81709ffe>] __asan_report_load1_noabort+0x3e/0x40 mm/kasan/report.c:277
> > > [<ffffffff8296613f>] ? string+0x1ef/0x200 lib/vsprintf.c:591
> > > [<ffffffff8296613f>] string+0x1ef/0x200 lib/vsprintf.c:591
> > > [<ffffffff8296f103>] vsnprintf+0xb83/0x1900 lib/vsprintf.c:2049
> > > [<ffffffff8296e580>] ? pointer+0xab0/0xab0 lib/vsprintf.c:1584
> > > [<ffffffff813456f2>] __request_module+0x132/0x6b0 kernel/kmod.c:146
> > > [<ffffffff814056b0>] ? mark_held_locks+0xd0/0x130 kernel/locking/lockdep.c:2552
> > > [<ffffffff813455c0>] ? call_usermodehelper_setup+0x2b0/0x2b0 kernel/kmod.c:530
> > > [<ffffffff85da47b0>] ? mutex_lock_interruptible_nested+0x980/0x980
> > > [<ffffffff8168fed4>] ? __might_fault+0xe4/0x1d0 mm/memory.c:3833
> > > [<ffffffff8538f74c>] find_inlist_lock.constprop.17+0x10c/0x210 net/bridge/netfilter/ebtables.c:347
> > > [< inline >] find_table_lock net/bridge/netfilter/ebtables.c:356
> > > [<ffffffff853904ab>] do_ebt_get_ctl+0x13b/0x540 net/bridge/netfilter/ebtables.c:1524
> > > [<ffffffff85390370>] ? copy_everything_to_user+0x600/0x600 net/bridge/netfilter/ebtables.c:1455
> > > [< inline >] ? __mutex_unlock_common_slowpath kernel/locking/mutex.c:751
> > > [<ffffffff85da6799>] ? __mutex_unlock_slowpath+0x239/0x3f0 kernel/locking/mutex.c:762
> > > [<ffffffff85da6959>] ? mutex_unlock+0x9/0x10 kernel/locking/mutex.c:437
> > > [<ffffffff84dea126>] ? nf_sockopt_find+0x1a6/0x220 net/netfilter/nf_sockopt.c:87
> > > [< inline >] nf_sockopt net/netfilter/nf_sockopt.c:103
> > > [<ffffffff84dea20d>] nf_getsockopt+0x6d/0xc0 net/netfilter/nf_sockopt.c:121
> > > [<ffffffff84fadf05>] ip_getsockopt+0x135/0x190 net/ipv4/ip_sockglue.c:1523
> > > [<ffffffff84faddd0>] ? do_ip_getsockopt+0x1520/0x1520 net/ipv4/ip_sockglue.c:1353
> > > [< inline >] ? wake_up_process kernel/sched/core.c:2024
> > > [<ffffffff8138bcc2>] ? wake_up_q+0x82/0xe0 kernel/sched/core.c:416
> > > [< inline >] ? atomic_dec_and_test /arch/x86/include/asm/atomic.h:117
> > > [< inline >] ? mmdrop include/linux/sched.h:2611
> > > [<ffffffff814a3310>] ? drop_futex_key_refs.isra.13+0x70/0xe0 kernel/futex.c:444
> > > [<ffffffff8583a4dd>] sctp_getsockopt+0x18d/0x3f40 net/sctp/socket.c:5964
> > > [<ffffffff8140785b>] ? __lock_acquire+0x15fb/0x5dd0 kernel/locking/lockdep.c:3226
> > > [<ffffffff8583a350>] ? sctp_do_peeloff+0x2b0/0x2b0 net/sctp/socket.c:4434
> > > [<ffffffff81406260>] ? debug_check_no_locks_freed+0x290/0x290 kernel/locking/lockdep.c:4104
> > > [< inline >] ? rcu_read_unlock include/linux/rcupdate.h:922
> > > [<ffffffff817b398c>] ? __fget+0x20c/0x3b0 fs/file.c:712
> > > [< inline >] ? rcu_lock_release include/linux/rcupdate.h:491
> > > [< inline >] ? rcu_read_unlock include/linux/rcupdate.h:926
> > > [<ffffffff817b39b5>] ? __fget+0x235/0x3b0 fs/file.c:712
> > > [<ffffffff817b37c7>] ? __fget+0x47/0x3b0 fs/file.c:696
> > > [<ffffffff817b3c11>] ? __fget_light+0xa1/0x1f0 fs/file.c:759
> > > [<ffffffff84c3a695>] sock_common_getsockopt+0x95/0xd0 net/core/sock.c:2579
> > > [< inline >] SYSC_getsockopt net/socket.c:1783
> > > [<ffffffff84c37e12>] SyS_getsockopt+0x142/0x230 net/socket.c:1765
> > > [<ffffffff84c37cd0>] ? SyS_setsockopt+0x240/0x240 net/socket.c:1752
> > > [<ffffffff85dab922>] ? entry_SYSCALL_64_fastpath+0x5/0xc1 arch/x86/entry/entry_64.S:191
> > > [<ffffffff81003017>] ? trace_hardirqs_on_thunk+0x17/0x19 arch/x86/entry/thunk_64.S:39
> > > [<ffffffff85dab940>] entry_SYSCALL_64_fastpath+0x23/0xc1 arch/x86/entry/entry_64.S:207
> > > Memory state around the buggy address:
> > > ffff88003ae67880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> > > ffff88003ae67900: 00 f1 f1 f1 f1 04 f4 f4 f4 f2 f2 f2 f2 00 00 00
> > > >ffff88003ae67980: 00 00 00 00 00 00 00 00 00 00 00 00 f4 f3 f3 f3
> > > ^
> > > ffff88003ae67a00: f3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> > > ffff88003ae67a80: f1 f1 f1 f1 04 f4 f4 f4 f3 f3 f3 f3 00 00 00 00
> > > ==================================================================
> > >
> > > #include <unistd.h>
> > > #include <sys/syscall.h>
> > > #include <netinet/in.h>
> > > #include <string.h>
> > > #include <stdint.h>
> > > #include <sys/mman.h>
> > > #include <sys/socket.h>
> > >
> > > int main()
> > > {
> > > int sock = 0;
> > > int sock_dup = 0;
> > > mmap((void *)0x20000000ul, 0x5000ul, PROT_READ|PROT_WRITE,
> > > MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0);
> > > sock = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);
> > > sock_dup = dup(sock);
> > > memcpy((void*)0x20000bf3,"\xac\x71\x93\x68\x02\xb3\xd1\x86\x52\xf1\xf0\x18\x09\x56\xc6\x98\x6f\x8e\x74\xb7\x17\xd4\x3a\x64\x51\x68\x13\x2d\x25\xba\x6d\x3f\x74\x68\x84\x89\x04\xd1\xa6\xe2\x7d\xaf\xfa\xd9\xce\x52\xbe\x6f\xb6\xe3\xff\x92\x35\xa1\x88\x4a\x68\x27\xaa\x25\xf8\xc1\xd5\x3b\xe5\x69\x11\x4f\x75\x4c\xe9\xff\x8b\x86\x53\x20\xb7\x10\xa2\x62\xcc\xc3\x06\x85\xde\x3e\x1c\x5a\x62\x3a\x2d\x0d\x0b\x0c\xb2\xac\x75\x42\x4d\x82\x3f\x7b\xf7\x28\xea\x2d\xff\x42\xa8\xdf\xb3\x49\x1a\xfd\xae\x2c\xd4\x35\x8e\x96\xb3\xe1\x0a\x92\x56\xb7\xde\xe8\x9e\xc3\x9e\x88\x79\xc4\x71\x46\x27\xf4\x9e\x85\xf4\x8f\x1f\x9a\xe5\x7e\x02\x09\x34\x80\x1e\x87\xa8\x9a\xce\xac\xfb\x43\x07\xdf\x15\xe8\x71\x9a\xa3\x80\x18\x1b\x15\xbd\x57\xb6\xc1\x73\x6e\xb1\x28\x3a\x01\xd5\x8e\x15\x85\xbd\x52\xdf\xfa\x64\xaa\x13
\x0e\x2f\x64\x05\x11\xce\x79\x8b\xa8\x02\x29\x7f\x72\x0f\x37\x89\xb4\x54\x0b\x09\x02\x75\xc2\x8e\xd7\xcd\x7e\xfb\x4f\x72\xf1\x47\xea\xa2\x2a\xc3\xc4\xe9\x70\xfe\xa5\x80\x88\x21\x33\xcf\x13\x66\x98\x23\x10\x5c\xa4\xbd\xee\xc0\xb4\xdd\xfb\xff\xf2\x38\xab\xca\x36\x62\x35\x84\xe4\x73\x5c\xc7\x3e\x72\x2e\x17\x43\x6f\x85\x45\x4f\x82\x62\x0d\x77\xae\xcb\xe1\x8f\xe8\xf0\x84\x3e\x62\x8b\x70\x2b\x55\xb5\xa7\x13\xcf\xa1\x78\x77\x82\xe2\xb7\x1c\x65\x7f\xb5\x79\x73\x01\x07\xd1\x9f\x45\x6a\xbb\x3d\xbf\xc8\x71\x5b\x9f\x30\xc7\xb9\xb8\x53\x9f\xe1\xba\xb6\x78\x9e\x05\x75\xa3\x55\xb1\x26\x96\xa9\xb2\x82\xce\x81\x5c\x8a\x18\xb3\x4b\x0c\x18\x8c\xf2\x7c\x09\xde\xcb\xcf\x78\x22\x58\xf6\x15\xf6\xf7\x48\xda\x08\x75\xd4\xc1\x20\xc3\x18\x2e\x89\xe8\x5b\x48\xd9\xbc\x1f\xbb\xed\x31\xaf\x12\x4d\xcd\x46\x60\xa0\xef\x
0e\x2e\x21\x1d\x2b\x68\x75\xb9\x42\x5e\xd7\xae\x35\x46\xe9\x06\x63\x1d\x3c\xd6\x9c\x14\x3b\x09\x29\x49\x70\xb9\xe1\xe0\x09\x45\x41\x62\x0c\xff\x5a\x77\xbe\x31\xa6\x03\x94\x92\xde\x41\x99\xfa\x68\x99\x74\xbb\x0a\x3d\xac\x9c\x7e\x00\x6b\xcd\xc1\x83\xa7\xc5\x63\xdd\x10\xea\x59\x27\xdc\x02\x98\xd6\x43\x20\x24\x4e\xc0\xdc\xa2\x98\xdf\x3e\xaf\x61\x35\xa0\x95\x3f\x9a\xaa\x7d\xe9\xe9\x0d\xe5\x97\x66\x1a\x9f\xbf\x56\xc8\x37\x84\x18\x2b\xd2\xcd\xd6\xb3\x19\xd8\x4a\x30\x6e\xcb\x99\x1c\xe9\x0f\xdb\xca\x30\xe1\xe2\x90\xba\xb9\x61\x00\xbf\xeb\xad\x6a\xc8\x52\xea\x1a\x92\x05\x0c\x3b\x78\x82\x01\xac\xfd\x88\x6c\xca\xe2\xfb\xe7\x0f\xcc\x75\x9c\x98\x12\x26\xcf\xa6\x80\x02\x35\xdf\x6e\xe1\x11\x1d\xa7\x30\x17\x38\x41\xd9\x81\x55\x1a\x1e\xd1\xfe\x60\xbf\xef\x09\x25\xc0\xdb\x9f\xc4\xc6\x54\x1a\x85\x36\x85\x05
\xb3\x9f\x2c\xc5\xcd\x12\x51\xef\xbe\x10\x79\xbf\x11\x00\x47\x0d\x9c\x14\x43\x1a\x46\xea\xd1\x34\x2e\x10\x6b\xa4\x3c\x25\x21\xe3\xb9\x15\x78\x6c\x40\x87\x90\xf7\x93\x5a\x66\x5f\x0a\x76\xff\xc2\xe2\x14\x35\x88\x47\xa1\x33\x5b\x8f\x3d\xc5\x89\xb7\xf9\x8a\x40\xf0\x1e\xc9\x30\xcd\xd8\x96\x41\x78\x58\x97\x49\xc8\x50\x61\x36\x8f\x7e\x44\x41\xc0\x84\xbb\x35\xf0\x63\xa9\xc2\x2a\xbd\xcc\x4b\xab\x8b\x16\x33\xc0\x66\xbf\x47\x62\x9b\xc4\x47\x2d\x68\x83\xca\xe3\x52\x79\xd7\xe0\x61\x80\x15\xf1\x90\x83\xa2\xbb\x4c\xe5\x8b\x50\xc8\x1b\x68\x7b\xee\x57\xdc\x54\xfa\x90\xf1\xf5\xec\x7d\x93\xe0\x80\x74\x06\xbe\xac\xc8\x85\x4d\xe8\xbf\xd3\xdd\x34\x55\xc4\xbf\x2f\x24\x19\xad\x86\x1e\x69\x2b\x6c\x3f\x00\xe8\x4b\xbb\x99\xcf\x17\x99\x00\x9d\x6c\x70\x57\xcc\x35\xee\x07\x87\x25\x8c\x0c\x8b\x9b\x38\x15\xcc\x05\x6f\x
f8\x16\x78\x0b\x41\xfa\x23\x96\xc0\x79\xf8\xb7\xf0\x2b\x60\x7e\x98\xe3\x7b\xab\x80\x1f\x0d\xbf\xf6\x7e\x37\x06\xf1\x11\x42\x38\x2a\x70\xdf\xa4\xca\xf5\xf3\xf4\x7d\xca\x10\x0c\xd5\xe2\x90\xa0\x15\xde\xc2\x61\xa2\x88\xea\x32\x37\x97\x83\xd0\x4c\xad\xe2\xae\x9b\x53\xa2\xc2\x54\x0c\xbd\xe1\x50\x3b\x15\xd4\xb1\xa9\x41\x6e\x18\x2e\x30\x3f\x91\x03\x81\x86\x8c\x5c\x1f\x76\x51\x92\xf5\xb5\xb2\xc3\x16\x01\xef\xe3\x9e\xb1\x92\x0e\x0e\xcb\x20\x7f\x10\x29\x08\x6e\x15\x3d\x1e\x7c\x70\xf5\xb5\x3c\x56\x15\x3c\x59\xe6\xe7\x9e\x16\xcd\xfc\x8e\xfa\x12\x99\xbb\x07\xaa\xd7\x1c\xd0\xae\x93\x4c\xba\x16\x5d\x0c\xed\x1d\x02\x87\xcd\x38\x31\xc6\x10\x42\xe1\x46\x4e\xa3\xae\xb6\xda\xb6\xb0\x49\x55\x89\x57\xe6\xac\xe3\xbf\xb5\x5c\x59\x93\x0d\x21\x35\xdd\x57\x8c\x04\x15\x91\x05\x69\x4a\xdb\x5e\xcb\x4d\xa3\x5d\xa8\x7e
\x95\x9e\x9d\x95\x61\xc9\x1c\xdd\x66\x0a\x76\x18\xbb\x59\x6a\xa5\xc0\xf2\xb8\x2f\xa9\x4c\xa8\xb3\x2b\xa3\x8a\xbf\x5c\xe8\x18\x3d\x7f\x0e\x2f\xe9\x06\xf9\xb6\xcc\x60\xcc\x38\x6c\x9a\x78\xa7\x7c\x61",
> > > 1037);
> > > getsockopt(sock_dup, IPPROTO_IP, 0x81, (void *)0x20000bf3ul,
> > > (socklen_t *)0x20003000ul);
> > > return 0;
> > > }
> > >
> > > Best Regards,
> > >
> > > Baozeng Ding
> >
> > More likely a netfilter bug in net/bridge/netfilter/ebtables.c
> >
>
> Untested patch would be :
>
> diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
> index 67b2e27999aa..fceb7354d169 100644
> --- a/net/bridge/netfilter/ebtables.c
> +++ b/net/bridge/netfilter/ebtables.c
> @@ -346,7 +346,7 @@ find_inlist_lock(struct list_head *head, const char *name, const char *prefix,
> {
> return try_then_request_module(
> find_inlist_lock_noload(head, name, error, mutex),
> - "%s%s", prefix, name);
> + "%.*s%s", EBT_TABLE_MAXNAMELEN, prefix, name);
> }
>
> static inline struct ebt_table *
>
>
Thanks for your quick patch. I tested it but it still reproduce the
bug. We should limit the length of the name,
not the prefix. The following patch fixs it.
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 67b2e27..4837425 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -346,7 +346,7 @@ find_inlist_lock(struct list_head *head, const
char *name, const char *prefix,
{
return try_then_request_module(
find_inlist_lock_noload(head, name, error, mutex),
- "%s%s", prefix, name);
+ "%s%.*s", prefix, EBT_TABLE_MAXNAMELEN, name);
}
--
Best Regards,
Baozeng Ding
^ permalink raw reply related
* [PATCH net-next, 1/2] hv_netvsc: Fix accessing freed memory in netvsc_change_mtu()
From: Haiyang Zhang @ 2016-03-23 16:43 UTC (permalink / raw)
To: davem, netdev; +Cc: olaf, haiyangz, driverdev-devel, linux-kernel
struct netvsc_device is freed in rndis_filter_device_remove(). So we save
the nvdev->num_chn into a temp variable for later usage.
(Please also include this patch into stable branch.)
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
---
drivers/net/hyperv/netvsc_drv.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 0860849..b8121eb 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -858,6 +858,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
struct netvsc_device *nvdev = hv_get_drvdata(hdev);
struct netvsc_device_info device_info;
int limit = ETH_DATA_LEN;
+ u32 num_chn;
int ret = 0;
if (nvdev == NULL || nvdev->destroy)
@@ -873,6 +874,8 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
if (ret)
goto out;
+ num_chn = nvdev->num_chn;
+
nvdev->start_remove = true;
rndis_filter_device_remove(hdev);
@@ -883,7 +886,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
memset(&device_info, 0, sizeof(device_info));
device_info.ring_size = ring_size;
- device_info.num_chn = nvdev->num_chn;
+ device_info.num_chn = num_chn;
device_info.max_num_vrss_chns = max_num_vrss_chns;
rndis_filter_device_add(hdev, &device_info);
--
1.7.4.1
^ permalink raw reply related
* [PATCH net-next, 2/2] hv_netvsc: Fix the array sizes to be max supported channels
From: Haiyang Zhang @ 2016-03-23 16:43 UTC (permalink / raw)
To: davem, netdev; +Cc: olaf, haiyangz, driverdev-devel, linux-kernel
In-Reply-To: <1458751390-26971-1-git-send-email-haiyangz@microsoft.com>
The VRSS_CHANNEL_MAX is the max number of channels supported by Hyper-V
hosts. We use it for the related array sizes instead of using NR_CPUS,
which may be set to several thousands.
This patch reduces possible memory allocation failures.
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
---
drivers/net/hyperv/hyperv_net.h | 7 ++++---
drivers/net/hyperv/rndis_filter.c | 4 ++--
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index b4c6878..8b3bd8e 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -619,6 +619,7 @@ struct nvsp_message {
#define NETVSC_PACKET_SIZE 4096
#define VRSS_SEND_TAB_SIZE 16
+#define VRSS_CHANNEL_MAX 64
#define RNDIS_MAX_PKT_DEFAULT 8
#define RNDIS_PKT_ALIGN_DEFAULT 8
@@ -700,13 +701,13 @@ struct netvsc_device {
struct net_device *ndev;
- struct vmbus_channel *chn_table[NR_CPUS];
+ struct vmbus_channel *chn_table[VRSS_CHANNEL_MAX];
u32 send_table[VRSS_SEND_TAB_SIZE];
u32 max_chn;
u32 num_chn;
spinlock_t sc_lock; /* Protects num_sc_offered variable */
u32 num_sc_offered;
- atomic_t queue_sends[NR_CPUS];
+ atomic_t queue_sends[VRSS_CHANNEL_MAX];
/* Holds rndis device info */
void *extension;
@@ -718,7 +719,7 @@ struct netvsc_device {
/* The sub channel callback buffer */
unsigned char *sub_cb_buf;
- struct multi_send_data msd[NR_CPUS];
+ struct multi_send_data msd[VRSS_CHANNEL_MAX];
u32 max_pkt; /* max number of pkt in one send, e.g. 8 */
u32 pkt_align; /* alignment bytes, e.g. 8 */
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index 47d07c5..d5a54da 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -1113,9 +1113,9 @@ int rndis_filter_device_add(struct hv_device *dev,
if (ret || rsscap.num_recv_que < 2)
goto out;
- num_rss_qs = min(device_info->max_num_vrss_chns, rsscap.num_recv_que);
+ net_device->max_chn = min_t(u32, VRSS_CHANNEL_MAX, rsscap.num_recv_que);
- net_device->max_chn = rsscap.num_recv_que;
+ num_rss_qs = min(device_info->max_num_vrss_chns, net_device->max_chn);
/*
* We will limit the VRSS channels to the number CPUs in the NUMA node
--
1.7.4.1
^ permalink raw reply related
* Re: [PATCH] net: mlxsw: avoid unused variable warnings
From: Andrew Lunn @ 2016-03-23 16:51 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Jiri Pirko, Ido Schimmel, David S. Miller, Elad Raz, netdev,
linux-kernel
In-Reply-To: <1458751080-2044921-1-git-send-email-arnd@arndb.de>
On Wed, Mar 23, 2016 at 05:37:38PM +0100, Arnd Bergmann wrote:
> dev_dbg_ratelimited() is a macro that ignores its arguments when DEBUG is
> not set, which can lead to unused variable warnings:
>
> ethernet/mellanox/mlxsw/pci.c: In function 'mlxsw_pci_cqe_sdq_handle':
> ethernet/mellanox/mlxsw/pci.c:646:18: warning: unused variable 'pdev' [-Wunused-variable]
> ethernet/mellanox/mlxsw/pci.c: In function 'mlxsw_pci_cqe_rdq_handle':
> ethernet/mellanox/mlxsw/pci.c:671:18: warning: unused variable 'pdev' [-Wunused-variable]
>
> This changes the mlxsw driver to remove the local variables we get
> warnings for and instead pass the device directly into the API.
Hi Arnd
Would it not be better to fix the macro?
I think the issue is that dev_dbg_ratelimited calls no_printk(),
without making use of dev. So how about:
#define dev_dbg_ratelimited(dev, fmt, ...) \
({ \
if (0) \
dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \
})
This follows the pattern for other macros for when DEBUG is not defined.
Andrew
^ 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