* Re: +157.8% netperf throughput by "ipv4: raise IP_MAX_MTU to theoretical limit"
From: Fengguang Wu @ 2013-09-26 1:35 UTC (permalink / raw)
To: Eric Dumazet
Cc: Alexey Kuznetsov, Willem de Bruijn, lkp, netdev@vger.kernel.org,
LKML
In-Reply-To: <20130926012144.GA9931@localhost>
On Thu, Sep 26, 2013 at 09:21:44AM +0800, Fengguang Wu wrote:
> Hi Eric,
>
> We are glad to find that your below commit brings large increase in
> lo netperf throughput:
>
> 35596b2796713c6a9dc0 734d2725db879f3f6fcd
> ------------------------ ------------------------
> 761.80 +534.6% 4834.60 lkp-ib03/micro/netperf/120s-200%-UDP_STREAM
> 168.10 +1317.4% 2382.70 lkp-nex04/micro/netperf/120s-200%-UDP_STREAM
> 169.60 +979.4% 1830.70 lkp-nex05/micro/netperf/120s-200%-UDP_STREAM
> 2154.20 +135.7% 5077.50 lkp-sb03/micro/netperf/120s-200%-UDP_STREAM
> 3559.00 -3.5% 3435.20 lkp-t410/micro/netperf/120s-200%-TCP_STREAM
> 6812.70 +157.8% 17560.70 TOTAL netperf.Throughput_Mbps
>
> The side effects are some increased/decreased lock contentions:
This direct view may be more clear. Before patch:
class name con-bounces contentions waittime-min waittime-max waittime-total acq-bounces acquis
itions holdtime-min holdtime-max holdtime-total
-------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------
&(&nf->lru_lock)->rlock: 19017744 19034681 0.15 5884.35 5772892473.69 20428335 20
475976 0.10 1109.59 77448429.38
-----------------------
&(&nf->lru_lock)->rlock 4905538 [<ffffffff819227b9>] ip_defrag+0xa4f/0xbd3
&(&nf->lru_lock)->rlock 5695105 [<ffffffff8195bd6f>] inet_frag_find+0x2c7/0x30d
&(&nf->lru_lock)->rlock 5629414 [<ffffffff8195be74>] inet_frag_kill+0xbf/0x117
&(&nf->lru_lock)->rlock 2804624 [<ffffffff8195bf29>] inet_frag_evictor+0x5d/0x103
-----------------------
&(&nf->lru_lock)->rlock 6172104 [<ffffffff8195bd6f>] inet_frag_find+0x2c7/0x30d
&(&nf->lru_lock)->rlock 5348696 [<ffffffff8195be74>] inet_frag_kill+0xbf/0x117
&(&nf->lru_lock)->rlock 4421308 [<ffffffff819227b9>] ip_defrag+0xa4f/0xbd3
&(&nf->lru_lock)->rlock 3092573 [<ffffffff8195bf29>] inet_frag_evictor+0x5d/0x103
...............................................................................................................................................................................................
&(&q->lock)->rlock: 2322575 2323896 0.22 5802.58 934469091.38 3041941 13000848 0.10 5902.91 2811690638.18
------------------
&(&q->lock)->rlock 2163449 [<ffffffff8195bf7e>] inet_frag_evictor+0xb2/0x103
&(&q->lock)->rlock 160447 [<ffffffff81921e91>] ip_defrag+0x127/0xbd3
------------------
&(&q->lock)->rlock 2165896 [<ffffffff81921e91>] ip_defrag+0x127/0xbd3
&(&q->lock)->rlock 158000 [<ffffffff8195bf7e>] inet_frag_evictor+0xb2/0x103
...............................................................................................................................................................................................
&(&zone->lock)->rlock: 1845042 1851805 0.18 4917.52 19475590.18 9003807 10134386 0.13 3747.70 8347088.06
---------------------
&(&zone->lock)->rlock 866751 [<ffffffff8116fbbc>] __free_pages_ok.part.47+0x94/0x2a1
&(&zone->lock)->rlock 984597 [<ffffffff8116f856>] get_page_from_freelist+0x4a3/0x6e8
&(&zone->lock)->rlock 112 [<ffffffff8116fe3b>] free_pcppages_bulk+0x35/0x31a
&(&zone->lock)->rlock 116 [<ffffffff8116f72c>] get_page_from_freelist+0x379/0x6e8
---------------------
&(&zone->lock)->rlock 918190 [<ffffffff8116fbbc>] __free_pages_ok.part.47+0x94/0x2a1
&(&zone->lock)->rlock 722 [<ffffffff8116f72c>] get_page_from_freelist+0x379/0x6e8
&(&zone->lock)->rlock 861 [<ffffffff8116fe3b>] free_pcppages_bulk+0x35/0x31a
&(&zone->lock)->rlock 922607 [<ffffffff8116f856>] get_page_from_freelist+0x4a3/0x6e8
After patch, top contented locks become:
&(&zone->lock)->rlock: 58469530 58470181 0.16 4838.84 238618042.87 107374530 107408478 0.13 3610.05 73617127.93
---------------------
&(&zone->lock)->rlock 29783268 [<ffffffff8116f856>] get_page_from_freelist+0x4a3/0x6e8
&(&zone->lock)->rlock 837 [<ffffffff8116f72c>] get_page_from_freelist+0x379/0x6e8
&(&zone->lock)->rlock 1105 [<ffffffff8116fe3b>] free_pcppages_bulk+0x35/0x31a
&(&zone->lock)->rlock 28684627 [<ffffffff8116fbbc>] __free_pages_ok.part.47+0x94/0x2a1
---------------------
&(&zone->lock)->rlock 11356 [<ffffffff8116fe3b>] free_pcppages_bulk+0x35/0x31a
&(&zone->lock)->rlock 6741 [<ffffffff8116f72c>] get_page_from_freelist+0x379/0x6e8
&(&zone->lock)->rlock 28880589 [<ffffffff8116f856>] get_page_from_freelist+0x4a3/0x6e8
&(&zone->lock)->rlock 29558251 [<ffffffff8116fbbc>] __free_pages_ok.part.47+0x94/0x2a1
...............................................................................................................................................................................................
slock-AF_INET: 507780 508036 0.20 1167.78 2564695.48 11115246 106594271 0.12 1196.01 989718694.82
-------------
slock-AF_INET 434691 [<ffffffff818ed738>] lock_sock_fast+0x2f/0x84
slock-AF_INET 73294 [<ffffffff819482dc>] udp_queue_rcv_skb+0x1ba/0x3aa
slock-AF_INET 51 [<ffffffff818ed6b5>] lock_sock_nested+0x34/0x88
-------------
slock-AF_INET 434615 [<ffffffff819482dc>] udp_queue_rcv_skb+0x1ba/0x3aa
slock-AF_INET 73370 [<ffffffff818ed738>] lock_sock_fast+0x2f/0x84
slock-AF_INET 51 [<ffffffff8193fae1>] tcp_v4_rcv+0x390/0x978
..............................................................................................................................................................................................
&rq->lock: 286309 286456 0.21 294.85 1768779.90 5887506 244517912 0.09 1080.71 315600465.71
---------
&rq->lock 92057 [<ffffffff81a0aa65>] __schedule+0x103/0x852
&rq->lock 18386 [<ffffffff810ecc02>] try_to_wake_up+0x95/0x26c
&rq->lock 730 [<ffffffff810f13fb>] update_blocked_averages+0x30/0x47f
&rq->lock 304 [<ffffffff81a0af43>] __schedule+0x5e1/0x852
---------
&rq->lock 107807 [<ffffffff810ecd7b>] try_to_wake_up+0x20e/0x26c
&rq->lock 144391 [<ffffffff81a0aa65>] __schedule+0x103/0x852
&rq->lock 924 [<ffffffff810ecc02>] try_to_wake_up+0x95/0x26c
&rq->lock 29 [<ffffffff810e9090>] task_rq_lock+0x4b/0x85
Thanks,
Fengguang
^ permalink raw reply
* Re: BUG: MARK in OUTPUT + ip_tunnel causes kernel panic
From: Konstantin Kuzov @ 2013-09-26 2:06 UTC (permalink / raw)
To: Steffen Klassert; +Cc: netdev
In-Reply-To: <20130925085947.GY7660@secunet.com>
On Wed, 25 Sep 2013 10:59:47 +0200
Steffen Klassert wrote:
> > > When trying to tunnel traffic originating from the same machine as the
> > > tunnel endpoint, I am experiencing kernel panics for some types of
> > > traffic (ICMP and UDP). TCP seems not to be affected by this, at least
> > > I have not been able to trigger the panic.
> > >
> > > I have one tunnel (without an IP address) and use policy routing to
> > > steer some traffic through the tunnels.
> > [...]
> > > An interesting thing is that I have seen different kernel panics being
> > > triggered. The other one I have seen has RIP pointing to
> > > e1000_xmit_frame() and the message "protocol 0800 is buggy". However,
> > > the one I have posted is by far the most common.
> > I'm experiencing the same issue on two different machines. It happens on any
> > kernel starting from 3.10 when ip_tunnel/ip_tunnel_core were introduced.
> >
> Can you please try the patch below?
> I've posted the same patch already to netdev in the morning.
>
> Subject: [PATCH net 1/2] ip_tunnel: Fix a memory corruption in ip_tunnel_xmit
Thank you very much. All works fine with that patch applied.
^ permalink raw reply
* Re: [PATCH] moxa: drop free_irq of devm_request_irq allocated irq
From: Wei Yongjun @ 2013-09-26 2:12 UTC (permalink / raw)
To: jg1.han
Cc: jonas.jensen, davem, grant.likely, rob.herring, yongjun_wei,
netdev, sachin.kamat
In-Reply-To: <000001ceba51$f8b45c10$ea1d1430$%han@samsung.com>
On 09/26/2013 08:47 AM, Jingoo Han wrote:
> On Wednesday, September 25, 2013 4:33 PM, Wei Yongjun wrote:
>> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>>
>> irq allocated with devm_request_irq should not be freed using
>> free_irq, because doing so causes a dangling pointer, and a
>> subsequent double free.
>>
>> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>> ---
>> drivers/net/ethernet/moxa/moxart_ether.c | 1 -
>> 1 file changed, 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c
>> index 83c2091..9a7fcb5 100644
>> --- a/drivers/net/ethernet/moxa/moxart_ether.c
>> +++ b/drivers/net/ethernet/moxa/moxart_ether.c
>> @@ -531,7 +531,6 @@ static int moxart_remove(struct platform_device *pdev)
>> struct net_device *ndev = platform_get_drvdata(pdev);
>>
>> unregister_netdev(ndev);
>> - free_irq(ndev->irq, ndev);
>> moxart_mac_free_memory(ndev);
>> free_netdev(ndev);
> CC'ed Sachin Kamat,
>
> In this case, the free_irq() will be called, after calling
> free_netdev(). 'ndev' is freed by free_netdev(). Then, 'ndev->irq'
> is used by free_irq(). Is it right?
>
> In my humble opinion, it seems to make the problem.
>
devm_request_irq() has recorded the irq and dev_id, so free_irq() by devm_*
will not touch 'ndev' which has been freed by free_netdev().
So, if we not need to call free_irq() before free_netdev(), there will be
no problem.
^ permalink raw reply
* Re: [PATCH v5 net-next 11/27] bonding: rework bond_3ad_xmit_xor() to use bond_for_each_slave() only
From: Ding Tianhong @ 2013-09-26 2:31 UTC (permalink / raw)
To: Veaceslav Falico; +Cc: netdev, jiri, Jay Vosburgh, Andy Gospodarek
In-Reply-To: <1380093632-1842-12-git-send-email-vfalico@redhat.com>
On 2013/9/25 15:20, Veaceslav Falico wrote:
> Currently, there are two loops - first we find the first slave in an
> aggregator after the xmit_hash_policy() returned number, and after that we
> loop from that slave, over bonding head, and till that slave to find any
> suitable slave to send the packet through.
>
> Replace it by just one bond_for_each_slave() loop, which first loops
> through the requested number of slaves, saving the first suitable one, and
> after that we've hit the requested number of slaves to skip - search for
> any up slave to send the packet through. If we don't find such kind of
> slave - then just send the packet through the first suitable slave found.
>
> Logic remains unchainged, and we skip two loops. Also, refactor it a bit
> for readability.
>
> CC: Jay Vosburgh <fubar@us.ibm.com>
> CC: Andy Gospodarek <andy@greyhouse.net>
> Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
> ---
>
> Notes:
> v4 -> v5
> No change.
>
> v3 -> v4:
> No change.
>
> v2 -> v3:
> No change.
>
> v1 -> v2:
> No changes.
>
> RFC -> v1:
> New patch.
>
> drivers/net/bonding/bond_3ad.c | 46 ++++++++++++++++++++----------------------
> 1 file changed, 22 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
> index 3847aee..c861ee7 100644
> --- a/drivers/net/bonding/bond_3ad.c
> +++ b/drivers/net/bonding/bond_3ad.c
> @@ -2417,15 +2417,15 @@ int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info)
>
> int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
> {
> - struct slave *slave, *start_at;
> struct bonding *bond = netdev_priv(dev);
> + struct slave *slave, *first_ok_slave;
> + struct aggregator *agg;
> + struct ad_info ad_info;
> struct list_head *iter;
> - int slave_agg_no;
> int slaves_in_agg;
> - int agg_id;
> - int i;
> - struct ad_info ad_info;
> + int slave_agg_no;
> int res = 1;
> + int agg_id;
>
> read_lock(&bond->lock);
> if (__bond_3ad_get_active_agg_info(bond, &ad_info)) {
> @@ -2438,20 +2438,28 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
> agg_id = ad_info.aggregator_id;
>
> if (slaves_in_agg == 0) {
> - /*the aggregator is empty*/
> pr_debug("%s: Error: active aggregator is empty\n", dev->name);
> goto out;
> }
>
> slave_agg_no = bond->xmit_hash_policy(skb, slaves_in_agg);
> + first_ok_slave = NULL;
>
> bond_for_each_slave(bond, slave, iter) {
> - struct aggregator *agg = SLAVE_AD_INFO(slave).port.aggregator;
> + agg = SLAVE_AD_INFO(slave).port.aggregator;
> + if (!agg || agg->aggregator_identifier != agg_id)
> + continue;
>
> - if (agg && (agg->aggregator_identifier == agg_id)) {
> + if (slave_agg_no >= 0) {
> + if (!first_ok_slave && SLAVE_IS_OK(slave))
> + first_ok_slave = slave;
> slave_agg_no--;
> - if (slave_agg_no < 0)
> - break;
> + continue;
> + }
> +
> + if (SLAVE_IS_OK(slave)) {
> + res = bond_dev_queue_xmit(bond, skb, slave->dev);
> + goto out;
> }
I think you miss something, you will send skb always by the first suitable port,
it could not support load balance.
pls consult my function.
if (agg && (agg->aggregator_identifier == agg_id)) {
- slave_agg_no--;
- if (slave_agg_no < 0)
- break;
+ if (--slave_agg_no < 0) {
+ if (SLAVE_IS_OK(slave)) {
+ res = bond_dev_queue_xmit(bond,
+ skb, slave->dev);
+ goto out;
+ }
+ }
}
}
> }
>
> @@ -2461,20 +2469,10 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
> goto out;
> }
>
> - start_at = slave;
> -
> - bond_for_each_slave_from(bond, slave, i, start_at) {
> - int slave_agg_id = 0;
> - struct aggregator *agg = SLAVE_AD_INFO(slave).port.aggregator;
> -
> - if (agg)
> - slave_agg_id = agg->aggregator_identifier;
> -
> - if (SLAVE_IS_OK(slave) && agg && (slave_agg_id == agg_id)) {
> - res = bond_dev_queue_xmit(bond, skb, slave->dev);
> - break;
> - }
> - }
> + /* we couldn't find any suitable slave after the agg_no, so use the
> + * first suitable found, if found. */
> + if (first_ok_slave)
> + res = bond_dev_queue_xmit(bond, skb, first_ok_slave->dev);
>
> out:
> read_unlock(&bond->lock);
>
^ permalink raw reply
* Re: [PATCH net-next v5 1/6] bonding: simplify and use RCU protection for 3ad xmit path
From: Ding Tianhong @ 2013-09-26 2:33 UTC (permalink / raw)
To: Veaceslav Falico
Cc: Jay Vosburgh, Andy Gospodarek, David S. Miller,
Nikolay Aleksandrov, Netdev
In-Reply-To: <20130925105000.GC23575@redhat.com>
On 2013/9/25 18:50, Veaceslav Falico wrote:
> On Wed, Sep 25, 2013 at 05:52:15PM +0800, Ding Tianhong wrote:
>> The commit 278b20837511776dc9d5f6ee1c7fabd5479838bb
>> (bonding: initial RCU conversion) has convert the roundrobin, active-backup,
>> broadcast and xor xmit path to rcu protection, the performance will be better
>> for these mode, so this time, convert xmit path for 3ad mode.
>>
>> Suggested-by: Nikolay Aleksandrov <nikolay@redhat.com>
>> Suggested-by: Veaceslav Falico <vfalico@redhat.com>
>> Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
>> Signed-off-by: Wang Yufen <wangyufen@huawei.com>
>> Cc: Nikolay Aleksandrov <nikolay@redhat.com>
>> Cc: Veaceslav Falico <vfalico@redhat.com>
>> ---
>> drivers/net/bonding/bond_3ad.c | 32 ++++++++++++++------------------
>> drivers/net/bonding/bonding.h | 30 +++++++++++++++++++++++++++++-
>> 2 files changed, 43 insertions(+), 19 deletions(-)
>>
>> diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
>> index 0d8f427..13f1deb 100644
>> --- a/drivers/net/bonding/bond_3ad.c
>> +++ b/drivers/net/bonding/bond_3ad.c
>> @@ -143,7 +143,7 @@ static inline struct bonding *__get_bond_by_port(struct port *port)
>> */
>> static inline struct port *__get_first_port(struct bonding *bond)
>> {
>> - struct slave *first_slave = bond_first_slave(bond);
>> + struct slave *first_slave = bond_first_slave_rcu(bond);
>>
>> return first_slave ? &(SLAVE_AD_INFO(first_slave).port) : NULL;
>> }
>> @@ -163,7 +163,7 @@ static inline struct port *__get_next_port(struct port *port)
>> // If there's no bond for this port, or this is the last slave
>> if (bond == NULL)
>> return NULL;
>> - slave_next = bond_next_slave(bond, slave);
>> + slave_next = bond_next_slave_rcu(bond, slave);
>> if (!slave_next || bond_is_first_slave(bond, slave_next))
>> return NULL;
>>
>> @@ -2417,16 +2417,14 @@ int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info)
>>
>> int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
>> {
>> - struct slave *slave, *start_at;
>> struct bonding *bond = netdev_priv(dev);
>> + struct slave *slave;
>> int slave_agg_no;
>> int slaves_in_agg;
>> int agg_id;
>> - int i;
>> struct ad_info ad_info;
>> int res = 1;
>>
>> - read_lock(&bond->lock);
>> if (__bond_3ad_get_active_agg_info(bond, &ad_info)) {
>> pr_debug("%s: Error: __bond_3ad_get_active_agg_info failed\n",
>> dev->name);
>> @@ -2444,13 +2442,17 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
>>
>> slave_agg_no = bond->xmit_hash_policy(skb, slaves_in_agg);
>>
>> - bond_for_each_slave(bond, slave) {
>> + bond_for_each_slave_rcu(bond, slave) {
>> struct aggregator *agg = SLAVE_AD_INFO(slave).port.aggregator;
>>
>> if (agg && (agg->aggregator_identifier == agg_id)) {
>> - slave_agg_no--;
>> - if (slave_agg_no < 0)
>> - break;
>> + if (--slave_agg_no < 0) {
>> + if (SLAVE_IS_OK(slave)) {
>> + res = bond_dev_queue_xmit(bond,
>> + skb, slave->dev);
>> + goto out;
>> + }
>> + }
>> }
>> }
>>
>> @@ -2460,23 +2462,17 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
>> goto out;
>> }
>>
>> - start_at = slave;
>> -
>> - bond_for_each_slave_from(bond, slave, i, start_at) {
>> - int slave_agg_id = 0;
>> + bond_for_each_slave_rcu(bond, slave) {
>> struct aggregator *agg = SLAVE_AD_INFO(slave).port.aggregator;
>>
>> - if (agg)
>> - slave_agg_id = agg->aggregator_identifier;
>> -
>> - if (SLAVE_IS_OK(slave) && agg && (slave_agg_id == agg_id)) {
>> + if (SLAVE_IS_OK(slave) && agg &&
>> + agg->aggregator_identifier == agg_id) {
>> res = bond_dev_queue_xmit(bond, skb, slave->dev);
>> break;
>> }
>> }
>>
>> out:
>> - read_unlock(&bond->lock);
>> if (res) {
>> /* no suitable interface, frame not sent */
>> kfree_skb(skb);
>> diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
>> index 03cf3fd..eb36f57 100644
>> --- a/drivers/net/bonding/bonding.h
>> +++ b/drivers/net/bonding/bonding.h
>> @@ -74,13 +74,31 @@
>> /* slave list primitives */
>> #define bond_to_slave(ptr) list_entry(ptr, struct slave, list)
>>
>> +/* slave list primitives, Caller must hold rcu_read_lock */
>> +#define bond_to_slave_rcu(ptr) list_entry_rcu(ptr, struct slave, list)
>> +
>> +/* bond_is_empty return NULL if slave list is empty*/
>> +#define bond_is_empty(bond) \
>> + (list_empty(&(bond)->slave_list))
>> +
>> +/* bond_is_empty_rcu return NULL if slave list is empty*/
>> +#define bond_is_empty_rcu(bond) \
>> + (!list_first_or_null_rcu(&(bond)->slave_list, struct slave, list))
>
> Useless/dangerous function. It's not used in this patch and there can be no
> constructs like:
>
> 1 if (!bond_is_empty_rcu(bond)) {
> 2 slave = bond_first_slave_rcu(bond);
> 3 do_something(slave);
>
agree, forgot to remove it.
> because between 1) and 2) the slave can go away, and we'll end up with
> slave == NULL.
>
>> +
>> /* IMPORTANT: bond_first/last_slave can return NULL in case of an empty list */
>> #define bond_first_slave(bond) \
>> list_first_entry_or_null(&(bond)->slave_list, struct slave, list)
>> #define bond_last_slave(bond) \
>> - (list_empty(&(bond)->slave_list) ? NULL : \
>> + (bond_is_empty(bond) ? NULL : \
>> bond_to_slave((bond)->slave_list.prev))
>>
>> +/**
>> + * IMPORTANT: bond_first/last_slave_rcu can return NULL in case of an empty list
>> + * Caller must hold rcu_read_lock
>> + */
>> +#define bond_first_slave_rcu(bond) \
>> + list_first_or_null_rcu(&(bond)->slave_list, struct slave, list);
>
> bond_first_slave_or_null_rcu() ?
>
both is suitable.
>> +
>> #define bond_is_first_slave(bond, pos) ((pos)->list.prev == &(bond)->slave_list)
>> #define bond_is_last_slave(bond, pos) ((pos)->list.next == &(bond)->slave_list)
>>
>> @@ -93,6 +111,16 @@
>> (bond_is_first_slave(bond, pos) ? bond_last_slave(bond) : \
>> bond_to_slave((pos)->list.prev))
>>
>> +/* Since bond_first/last_slave_rcu can return NULL, these can return NULL too */
>> +#define bond_next_slave_rcu(bond, pos) \
>> + ({struct list_head *__slave_list = &(bond)->slave_list; \
>> + struct list_head __rcu *__next = list_next_rcu(__slave_list); \
>> + struct list_head __rcu *__pos_next = list_next_rcu(&(pos)->list); \
>> + likely(__pos_next != __slave_list) ? \
>> + container_of(__pos_next, struct slave, list) : \
>> + container_of(__next, struct slave, list); \
>> + })
>
> And if bond has no slaves, whilst pos being the slave that has just
> detached? Then bond->slave_list->next == pos->list->next ==
> &bond->slave_list, and we'll return the container_of(bond->slave_list),
> which is garbage, but not NULL.
>
>> +
>> /**
>> * bond_for_each_slave_from - iterate the slaves list from a starting point
>> * @bond: the bond holding this list.
>> --
>> 1.8.0
>>
>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
> .
>
^ permalink raw reply
* Re: [PATCH] moxa: drop free_irq of devm_request_irq allocated irq
From: Jingoo Han @ 2013-09-26 2:36 UTC (permalink / raw)
To: 'Wei Yongjun'
Cc: 'Jonas Jensen', 'David S. Miller',
'Grant Likely', rob.herring, yongjun_wei, netdev,
'Sachin Kamat', 'Jingoo Han'
In-Reply-To: <CAPgLHd9VXaPx18ujDKbUik6XjOsnARcK-C-orCOynyJaWFREjw@mail.gmail.com>
On Thursday, September 26, 2013 11:13 AM, Wei Yongjun wrote:
> On 09/26/2013 08:47 AM, Jingoo Han wrote:
> > On Wednesday, September 25, 2013 4:33 PM, Wei Yongjun wrote:
> >> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> >>
> >> irq allocated with devm_request_irq should not be freed using
> >> free_irq, because doing so causes a dangling pointer, and a
> >> subsequent double free.
> >>
> >> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> >> ---
> >> drivers/net/ethernet/moxa/moxart_ether.c | 1 -
> >> 1 file changed, 1 deletion(-)
> >>
> >> diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c
> >> index 83c2091..9a7fcb5 100644
> >> --- a/drivers/net/ethernet/moxa/moxart_ether.c
> >> +++ b/drivers/net/ethernet/moxa/moxart_ether.c
> >> @@ -531,7 +531,6 @@ static int moxart_remove(struct platform_device *pdev)
> >> struct net_device *ndev = platform_get_drvdata(pdev);
> >>
> >> unregister_netdev(ndev);
> >> - free_irq(ndev->irq, ndev);
> >> moxart_mac_free_memory(ndev);
> >> free_netdev(ndev);
> > CC'ed Sachin Kamat,
> >
> > In this case, the free_irq() will be called, after calling
> > free_netdev(). 'ndev' is freed by free_netdev(). Then, 'ndev->irq'
> > is used by free_irq(). Is it right?
> >
> > In my humble opinion, it seems to make the problem.
> >
>
> devm_request_irq() has recorded the irq and dev_id, so free_irq() by devm_*
> will not touch 'ndev' which has been freed by free_netdev().
> So, if we not need to call free_irq() before free_netdev(), there will be
> no problem.
However, 'dev_id' is a pointer, not a value.
It seems to make the problem that references the invalid pointer.
Best regards,
Jingoo Han
^ permalink raw reply
* Re: Kernel Panic Sending Frames Using dev_queue_xmit()
From: Merlin Davis @ 2013-09-26 2:47 UTC (permalink / raw)
To: Francois Romieu; +Cc: Ben Hutchings, netdev
In-Reply-To: <20130925220351.GA4653@electric-eye.fr.zoreil.com>
On Wed, Sep 25, 2013 at 3:03 PM, Francois Romieu <romieu@fr.zoreil.com> wrote:
> Macro expansion bug.
Yes! Excellent. If I change the code to:
err = dev_queue_xmit(skb);
err = net_xmit_eval(err);
then the panic seems to disappear (I've run for at least 30 minutes
now without a crash anyway). Would the best fix for this in the
kernel code be to:
A.) document the net_xmit_eval() macro with a warning,
B.) add local scope the the macro with ({ ... }) to remove the double
evaluation, or
C.) do nothing in the kernel code and stop being such a dumbass when calling it?
Thank you,
Merlin
^ permalink raw reply
* Re: [PATCH RFC] net: introduce support for lazy initialization of secret keys
From: Hannes Frederic Sowa @ 2013-09-26 2:50 UTC (permalink / raw)
To: Eric Dumazet; +Cc: netdev, fw, edumazet, davem, ycheng
In-Reply-To: <1380148946.3165.166.camel@edumazet-glaptop>
On Wed, Sep 25, 2013 at 03:42:26PM -0700, Eric Dumazet wrote:
> BTW, build_ehash_secret() is called like that :
>
> if (unlikely(!inet_ehash_secret))
> if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM)
> build_ehash_secret();
>
> So it would be better to make sure inet_ehash_secret is not 0 by
> accident.
This is the most idiomatic version which does not have this problem. It
does add a very few instructions on every hashing call and splits
inet6_ehash_secret and inet_ehash_secret. I just did this in a hurry
and did not test it well, so this is only a preview if this way would
be acceptable.
I would finish a final version by tomorrow based on the feedback. Thanks! ;)
[PATCH RFC] net: introduce support for lazy initialization of secret keys
net_get_random_once is a new macro which handles the initialization
of secret keys. It is possible to call it in the fast path. Only the
initialization depends on the spinlock and is rather slow. Otherwise
it should get used just before the key is used to delay the entropy
extration as late as possible to get better randomness. It returns true
if the key got initialized.
This patch splits the secret key for syncookies between ipv4 and ipv6
and initializes them with net_get_random_once.
Changed key initialization of tcp_fastopen cookies to net_get_random_once.
Also initialize the secret keys for tcp connection hashing via
net_get_random_once and split inet_ehash_secret and inet6_ehash_secret.
Thus inet_hash_secret need not be exported any more.
Cc: Florian Westphal <fw@strlen.de>
Cc: Eric Dumazet <edumazet@google.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
include/linux/net.h | 14 ++++++++++++++
include/net/inet6_hashtables.h | 9 +++++++--
include/net/inet_sock.h | 4 ++--
include/net/ipv6.h | 7 ++++++-
include/net/tcp.h | 3 +--
net/core/secure_seq.c | 14 ++------------
net/core/utils.c | 21 +++++++++++++++++++++
net/ipv4/af_inet.c | 25 -------------------------
net/ipv4/syncookies.c | 16 ++++++----------
net/ipv4/sysctl_net_ipv4.c | 5 +++++
net/ipv4/tcp_fastopen.c | 21 ++++++++++-----------
net/ipv6/af_inet6.c | 5 -----
net/ipv6/inet6_hashtables.c | 3 +++
net/ipv6/syncookies.c | 10 ++++++++--
14 files changed, 85 insertions(+), 72 deletions(-)
diff --git a/include/linux/net.h b/include/linux/net.h
index 4f27575..d14fad5 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -243,6 +243,20 @@ do { \
#define net_random() prandom_u32()
#define net_srandom(seed) prandom_seed((__force u32)(seed))
+bool __net_get_random_once(void *buf, int nbytes, bool *done);
+
+/* BE CAREFUL: this function is not interrupt safe */
+#define net_get_random_once(buf, nbytes) \
+ ({ \
+ static bool ___done = false; \
+ bool ___ret = false; \
+ if (unlikely(!___done)) \
+ ___ret = __net_get_random_once(buf, \
+ nbytes, \
+ &___done); \
+ ___ret; \
+ })
+
extern int kernel_sendmsg(struct socket *sock, struct msghdr *msg,
struct kvec *vec, size_t num, size_t len);
extern int kernel_recvmsg(struct socket *sock, struct msghdr *msg,
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h
index f52fa88..8b66189 100644
--- a/include/net/inet6_hashtables.h
+++ b/include/net/inet6_hashtables.h
@@ -28,16 +28,21 @@
struct inet_hashinfo;
+extern u32 inet6_ehash_secret;
+
static inline unsigned int inet6_ehashfn(struct net *net,
const struct in6_addr *laddr, const u16 lport,
const struct in6_addr *faddr, const __be16 fport)
{
- u32 ports = (((u32)lport) << 16) | (__force u32)fport;
+ u32 ports;
+
+ net_get_random_once(&inet6_ehash_secret, sizeof(inet6_ehash_secret));
+ ports = (((u32)lport) << 16) | (__force u32)fport;
return jhash_3words((__force u32)laddr->s6_addr32[3],
ipv6_addr_jhash(faddr),
ports,
- inet_ehash_secret + net_hash_mix(net));
+ inet6_ehash_secret + net_hash_mix(net));
}
static inline int inet6_sk_ehashfn(const struct sock *sk)
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index 636d203..d5a5353 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -202,13 +202,13 @@ static inline void inet_sk_copy_descendant(struct sock *sk_to,
int inet_sk_rebuild_header(struct sock *sk);
extern u32 inet_ehash_secret;
-extern u32 ipv6_hash_secret;
-void build_ehash_secret(void);
static inline unsigned int inet_ehashfn(struct net *net,
const __be32 laddr, const __u16 lport,
const __be32 faddr, const __be16 fport)
{
+ net_get_random_once(&inet_ehash_secret, sizeof(inet_ehash_secret));
+
return jhash_3words((__force __u32) laddr,
(__force __u32) faddr,
((__u32) lport) << 16 | (__force __u32)fport,
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index fe1c7f6..c683020 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -538,11 +538,16 @@ static inline u32 ipv6_addr_hash(const struct in6_addr *a)
#endif
}
+extern u32 ipv6_hash_secret;
+
/* more secured version of ipv6_addr_hash() */
static inline u32 ipv6_addr_jhash(const struct in6_addr *a)
{
- u32 v = (__force u32)a->s6_addr32[0] ^ (__force u32)a->s6_addr32[1];
+ u32 v;
+
+ net_get_random_once(&ipv6_hash_secret, sizeof(ipv6_hash_secret));
+ v = (__force u32)a->s6_addr32[0] ^ (__force u32)a->s6_addr32[1];
return jhash_3words(v,
(__force u32)a->s6_addr32[2],
(__force u32)a->s6_addr32[3],
diff --git a/include/net/tcp.h b/include/net/tcp.h
index de870ee..2a26100 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -475,7 +475,6 @@ int tcp_send_rcvq(struct sock *sk, struct msghdr *msg, size_t size);
void inet_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb);
/* From syncookies.c */
-extern __u32 syncookie_secret[2][16-4+SHA_DIGEST_WORDS];
int __cookie_v4_check(const struct iphdr *iph, const struct tcphdr *th,
u32 cookie);
struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
@@ -1323,7 +1322,7 @@ extern struct tcp_fastopen_context __rcu *tcp_fastopen_ctx;
int tcp_fastopen_reset_cipher(void *key, unsigned int len);
void tcp_fastopen_cookie_gen(__be32 src, __be32 dst,
struct tcp_fastopen_cookie *foc);
-
+void tcp_fastopen_init_key_once(bool publish);
#define TCP_FASTOPEN_KEY_LENGTH 16
/* Fastopen key context */
diff --git a/net/core/secure_seq.c b/net/core/secure_seq.c
index 3f1ec15..b02fd16 100644
--- a/net/core/secure_seq.c
+++ b/net/core/secure_seq.c
@@ -7,6 +7,7 @@
#include <linux/hrtimer.h>
#include <linux/ktime.h>
#include <linux/string.h>
+#include <linux/net.h>
#include <net/secure_seq.h>
@@ -16,18 +17,7 @@ static u32 net_secret[NET_SECRET_SIZE] ____cacheline_aligned;
static void net_secret_init(void)
{
- u32 tmp;
- int i;
-
- if (likely(net_secret[0]))
- return;
-
- for (i = NET_SECRET_SIZE; i > 0;) {
- do {
- get_random_bytes(&tmp, sizeof(tmp));
- } while (!tmp);
- cmpxchg(&net_secret[--i], 0, tmp);
- }
+ net_get_random_once(net_secret, sizeof(net_secret));
}
#ifdef CONFIG_INET
diff --git a/net/core/utils.c b/net/core/utils.c
index aa88e23..b420547 100644
--- a/net/core/utils.c
+++ b/net/core/utils.c
@@ -338,3 +338,24 @@ void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb,
csum_unfold(*sum)));
}
EXPORT_SYMBOL(inet_proto_csum_replace16);
+
+bool __net_get_random_once(void *buf, int nbytes, bool *done)
+{
+ static DEFINE_SPINLOCK(lock);
+
+ spin_lock_bh(&lock);
+ if (*done) {
+ spin_unlock_bh(&lock);
+ return false;
+ }
+
+ get_random_bytes(buf, nbytes);
+ /* Make sure random data is published before toggeling done.
+ * There is no corresponding rmb.
+ */
+ smp_wmb();
+ *done = true;
+ spin_unlock_bh(&lock);
+ return true;
+}
+EXPORT_SYMBOL(__net_get_random_once);
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index cfeb85c..49a5c48 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -246,27 +246,6 @@ out:
EXPORT_SYMBOL(inet_listen);
u32 inet_ehash_secret __read_mostly;
-EXPORT_SYMBOL(inet_ehash_secret);
-
-u32 ipv6_hash_secret __read_mostly;
-EXPORT_SYMBOL(ipv6_hash_secret);
-
-/*
- * inet_ehash_secret must be set exactly once, and to a non nul value
- * ipv6_hash_secret must be set exactly once.
- */
-void build_ehash_secret(void)
-{
- u32 rnd;
-
- do {
- get_random_bytes(&rnd, sizeof(rnd));
- } while (rnd == 0);
-
- if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0)
- get_random_bytes(&ipv6_hash_secret, sizeof(ipv6_hash_secret));
-}
-EXPORT_SYMBOL(build_ehash_secret);
/*
* Create an inet socket.
@@ -284,10 +263,6 @@ static int inet_create(struct net *net, struct socket *sock, int protocol,
int try_loading_module = 0;
int err;
- if (unlikely(!inet_ehash_secret))
- if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM)
- build_ehash_secret();
-
sock->state = SS_UNCONNECTED;
/* Look for the requested type/protocol pair. */
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index 15e0241..af79b84 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -25,15 +25,7 @@
extern int sysctl_tcp_syncookies;
-__u32 syncookie_secret[2][16-4+SHA_DIGEST_WORDS];
-EXPORT_SYMBOL(syncookie_secret);
-
-static __init int init_syncookies(void)
-{
- get_random_bytes(syncookie_secret, sizeof(syncookie_secret));
- return 0;
-}
-__initcall(init_syncookies);
+static u32 syncookie_secret[2][16-4+SHA_DIGEST_WORDS];
#define COOKIEBITS 24 /* Upper bits store count */
#define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1)
@@ -44,7 +36,11 @@ static DEFINE_PER_CPU(__u32 [16 + 5 + SHA_WORKSPACE_WORDS],
static u32 cookie_hash(__be32 saddr, __be32 daddr, __be16 sport, __be16 dport,
u32 count, int c)
{
- __u32 *tmp = __get_cpu_var(ipv4_cookie_scratch);
+ __u32 *tmp;
+
+ net_get_random_once(syncookie_secret, sizeof(syncookie_secret));
+
+ tmp = __get_cpu_var(ipv4_cookie_scratch);
memcpy(tmp + 4, syncookie_secret[c], sizeof(syncookie_secret[c]));
tmp[0] = (__force u32)saddr;
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 540279f..d2b5140 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -267,6 +267,11 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
ret = -EINVAL;
goto bad_key;
}
+ /* Generate a dummy secret but don't publish it. This
+ * is needed so we don't regenerate a new key on the
+ * first invocation of tcp_fastopen_cookie_gen
+ */
+ tcp_fastopen_init_key_once(false);
tcp_fastopen_reset_cipher(user_key, TCP_FASTOPEN_KEY_LENGTH);
}
diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
index ab7bd35..316bfdc 100644
--- a/net/ipv4/tcp_fastopen.c
+++ b/net/ipv4/tcp_fastopen.c
@@ -14,6 +14,14 @@ struct tcp_fastopen_context __rcu *tcp_fastopen_ctx;
static DEFINE_SPINLOCK(tcp_fastopen_ctx_lock);
+void tcp_fastopen_init_key_once(bool publish)
+{
+ static u8 key[TCP_FASTOPEN_KEY_LENGTH];
+
+ if (net_get_random_once(key, sizeof(key)) && publish)
+ tcp_fastopen_reset_cipher(key, sizeof(key));
+}
+
static void tcp_fastopen_ctx_free(struct rcu_head *head)
{
struct tcp_fastopen_context *ctx =
@@ -70,6 +78,8 @@ void tcp_fastopen_cookie_gen(__be32 src, __be32 dst,
__be32 path[4] = { src, dst, 0, 0 };
struct tcp_fastopen_context *ctx;
+ tcp_fastopen_init_key_once(true);
+
rcu_read_lock();
ctx = rcu_dereference(tcp_fastopen_ctx);
if (ctx) {
@@ -78,14 +88,3 @@ void tcp_fastopen_cookie_gen(__be32 src, __be32 dst,
}
rcu_read_unlock();
}
-
-static int __init tcp_fastopen_init(void)
-{
- __u8 key[TCP_FASTOPEN_KEY_LENGTH];
-
- get_random_bytes(key, sizeof(key));
- tcp_fastopen_reset_cipher(key, sizeof(key));
- return 0;
-}
-
-late_initcall(tcp_fastopen_init);
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 4966b12..5bd9b25 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -110,11 +110,6 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol,
int try_loading_module = 0;
int err;
- if (sock->type != SOCK_RAW &&
- sock->type != SOCK_DGRAM &&
- !inet_ehash_secret)
- build_ehash_secret();
-
/* Look for the requested type/protocol pair. */
lookup_protocol:
err = -ESOCKTNOSUPPORT;
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index 32b4a16..4015720 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -23,6 +23,9 @@
#include <net/secure_seq.h>
#include <net/ip.h>
+u32 inet6_ehash_secret __read_mostly;
+u32 ipv6_hash_secret __read_mostly;
+
int __inet6_hash(struct sock *sk, struct inet_timewait_sock *tw)
{
struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo;
diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c
index d703218..a454cef 100644
--- a/net/ipv6/syncookies.c
+++ b/net/ipv6/syncookies.c
@@ -21,6 +21,8 @@
#include <net/ipv6.h>
#include <net/tcp.h>
+static u32 syncookie6_secret[2][16-4+SHA_DIGEST_WORDS];
+
#define COOKIEBITS 24 /* Upper bits store count */
#define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1)
@@ -61,14 +63,18 @@ static DEFINE_PER_CPU(__u32 [16 + 5 + SHA_WORKSPACE_WORDS],
static u32 cookie_hash(const struct in6_addr *saddr, const struct in6_addr *daddr,
__be16 sport, __be16 dport, u32 count, int c)
{
- __u32 *tmp = __get_cpu_var(ipv6_cookie_scratch);
+ __u32 *tmp;
+
+ net_get_random_once(syncookie6_secret, sizeof(syncookie6_secret));
+
+ tmp = __get_cpu_var(ipv6_cookie_scratch);
/*
* we have 320 bits of information to hash, copy in the remaining
* 192 bits required for sha_transform, from the syncookie_secret
* and overwrite the digest with the secret
*/
- memcpy(tmp + 10, syncookie_secret[c], 44);
+ memcpy(tmp + 10, syncookie6_secret[c], 44);
memcpy(tmp, saddr, 16);
memcpy(tmp + 4, daddr, 16);
tmp[8] = ((__force u32)sport << 16) + (__force u32)dport;
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH net-next v5 2/6] bonding: remove the no effect lock for bond_3ad_lacpdu_recv()
From: Ding Tianhong @ 2013-09-26 2:51 UTC (permalink / raw)
To: Veaceslav Falico
Cc: Jay Vosburgh, Andy Gospodarek, David S. Miller,
Nikolay Aleksandrov, Netdev
In-Reply-To: <20130925103300.GB23575@redhat.com>
On 2013/9/25 18:33, Veaceslav Falico wrote:
> On Wed, Sep 25, 2013 at 05:52:19PM +0800, Ding Tianhong wrote:
>> There is no pointer needed read lock protection, remove the unnecessary lock
>> and improve performance for the 3ad recv path.
>
> I don't really understand it. Here's the code path:
>
> rx_handler (holding rcu_read_lock()) -> bond_handle_frame() ->
> bond->recv_probe -> bond_3ad_lacpdu_recv(). So we're holding only the
> rcu_read_lock() there. What stops us from racing with
> bond_3ad_unbind_slave(), for example?
>
> As in:
>
> CPU0 CPU1
> -------- -----------
> ... bond_3ad_unbind_slave()
> bond_3ad_rx_indication() ...
> if (!port->slave) { ... //slave is ok
> port->slave = NULL;
> ad_marker_info_received() ...
> ad_marker_send() ...
> slave = port->slave; ...
> skb->dev = slave->dev; ...
> ^^^ NULL pointer dereference.
>
>
> I'm not saying that this approach is wrong, maybe I'm missing something,
> but when removing locks it's usually a good thing to do - to comment it in
> depth in the commit message why it's not already needed.
>
no, it will not happend, pls review the cold:
netdev_rx_handler_unregister(slave_dev);
write_lock_bh(&bond->lock);
/* Inform AD package of unbinding of slave. */
if (bond->params.mode == BOND_MODE_8023AD) {
/* must be called before the slave is
* detached from the list
*/
bond_3ad_unbind_slave(slave);
}
netdev_rx_handler_unregiste() will remvoe the rx_handle before the bond_3ad_unbind_slave(),
it was safe to run bond_3ad_rx_indication().
Best regards
Ding Tianhong
>>
>> Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
>> Cc: Nikolay Aleksandrov <nikolay@redhat.com>
>> ---
>> drivers/net/bonding/bond_3ad.c | 2 --
>> 1 file changed, 2 deletions(-)
>>
>> diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
>> index 7a3860f..c134f43 100644
>> --- a/drivers/net/bonding/bond_3ad.c
>> +++ b/drivers/net/bonding/bond_3ad.c
>> @@ -2494,9 +2494,7 @@ int bond_3ad_lacpdu_recv(const struct sk_buff *skb, struct bonding *bond,
>> if (!lacpdu)
>> return ret;
>>
>> - read_lock(&bond->lock);
>> ret = bond_3ad_rx_indication(lacpdu, slave, skb->len);
>> - read_unlock(&bond->lock);
>> return ret;
>> }
>>
>> --
>> 1.8.2.1
>>
>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
> .
>
^ permalink raw reply
* Re: [PATCH RFC] net: introduce support for lazy initialization of secret keys
From: Hannes Frederic Sowa @ 2013-09-26 3:03 UTC (permalink / raw)
To: Eric Dumazet, netdev, fw, edumazet, davem, ycheng
In-Reply-To: <20130926025024.GC30920@order.stressinduktion.org>
On Thu, Sep 26, 2013 at 04:50:24AM +0200, Hannes Frederic Sowa wrote:
> static inline unsigned int inet6_ehashfn(struct net *net,
> const struct in6_addr *laddr, const u16 lport,
> const struct in6_addr *faddr, const __be16 fport)
> {
> - u32 ports = (((u32)lport) << 16) | (__force u32)fport;
> + u32 ports;
> +
> + net_get_random_once(&inet6_ehash_secret, sizeof(inet6_ehash_secret));
I was too quick with sending, this is broken. I cannot call this in a
static inline. Sorry for the noise.
^ permalink raw reply
* Re: [PATCH] moxa: drop free_irq of devm_request_irq allocated irq
From: Wei Yongjun @ 2013-09-26 3:23 UTC (permalink / raw)
To: jg1.han
Cc: jonas.jensen, davem, grant.likely, rob.herring, yongjun_wei,
netdev, sachin.kamat
On 09/26/2013 10:36 AM, Jingoo Han wrote:
> On Thursday, September 26, 2013 11:13 AM, Wei Yongjun wrote:
>> On 09/26/2013 08:47 AM, Jingoo Han wrote:
>>> On Wednesday, September 25, 2013 4:33 PM, Wei Yongjun wrote:
>>>> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>>>>
>>>> irq allocated with devm_request_irq should not be freed using
>>>> free_irq, because doing so causes a dangling pointer, and a
>>>> subsequent double free.
>>>>
>>>> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>>>> ---
>>>> drivers/net/ethernet/moxa/moxart_ether.c | 1 -
>>>> 1 file changed, 1 deletion(-)
>>>>
>>>> diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c
>>>> index 83c2091..9a7fcb5 100644
>>>> --- a/drivers/net/ethernet/moxa/moxart_ether.c
>>>> +++ b/drivers/net/ethernet/moxa/moxart_ether.c
>>>> @@ -531,7 +531,6 @@ static int moxart_remove(struct platform_device *pdev)
>>>> struct net_device *ndev = platform_get_drvdata(pdev);
>>>>
>>>> unregister_netdev(ndev);
>>>> - free_irq(ndev->irq, ndev);
>>>> moxart_mac_free_memory(ndev);
>>>> free_netdev(ndev);
>>> CC'ed Sachin Kamat,
>>>
>>> In this case, the free_irq() will be called, after calling
>>> free_netdev(). 'ndev' is freed by free_netdev(). Then, 'ndev->irq'
>>> is used by free_irq(). Is it right?
>>>
>>> In my humble opinion, it seems to make the problem.
>>>
>> devm_request_irq() has recorded the irq and dev_id, so free_irq() by devm_*
>> will not touch 'ndev' which has been freed by free_netdev().
>> So, if we not need to call free_irq() before free_netdev(), there will be
>> no problem.
> However, 'dev_id' is a pointer, not a value.
> It seems to make the problem that references the invalid pointer.
free_irq using dev_id as a raw data, so you mean the irq handle?
----
free_irq(...)
{
...
if (action->dev_id == dev_id)
...
}
---
Regards,
Yongjun Wei
^ permalink raw reply
* Re: [PATCH net-next v5 2/6] bonding: remove the no effect lock for bond_3ad_lacpdu_recv()
From: Jay Vosburgh @ 2013-09-26 4:23 UTC (permalink / raw)
To: Ding Tianhong
Cc: Veaceslav Falico, Andy Gospodarek, David S. Miller,
Nikolay Aleksandrov, Netdev
In-Reply-To: <5243A127.80404@huawei.com>
Ding Tianhong <dingtianhong@huawei.com> wrote:
>On 2013/9/25 18:33, Veaceslav Falico wrote:
>> On Wed, Sep 25, 2013 at 05:52:19PM +0800, Ding Tianhong wrote:
>>> There is no pointer needed read lock protection, remove the unnecessary lock
>>> and improve performance for the 3ad recv path.
How much does removing the lock around the LACPDU receive
processing improve performance? This is not high rate traffic; the
"fast" rate is one LACPDU per second (per port); the default rate is one
every 30 seconds.
>> I don't really understand it. Here's the code path:
>>
>> rx_handler (holding rcu_read_lock()) -> bond_handle_frame() ->
>> bond->recv_probe -> bond_3ad_lacpdu_recv(). So we're holding only the
>> rcu_read_lock() there. What stops us from racing with
>> bond_3ad_unbind_slave(), for example?
>>
>> As in:
>>
>> CPU0 CPU1
>> -------- -----------
>> ... bond_3ad_unbind_slave()
>> bond_3ad_rx_indication() ...
>> if (!port->slave) { ... //slave is ok
>> port->slave = NULL;
>> ad_marker_info_received() ...
>> ad_marker_send() ...
>> slave = port->slave; ...
>> skb->dev = slave->dev; ...
>> ^^^ NULL pointer dereference.
>>
>>
>> I'm not saying that this approach is wrong, maybe I'm missing something,
>> but when removing locks it's usually a good thing to do - to comment it in
>> depth in the commit message why it's not already needed.
>>
>
>no, it will not happend, pls review the cold:
> netdev_rx_handler_unregister(slave_dev);
> write_lock_bh(&bond->lock);
>
> /* Inform AD package of unbinding of slave. */
> if (bond->params.mode == BOND_MODE_8023AD) {
> /* must be called before the slave is
> * detached from the list
> */
> bond_3ad_unbind_slave(slave);
> }
>netdev_rx_handler_unregiste() will remvoe the rx_handle before the bond_3ad_unbind_slave(),
>it was safe to run bond_3ad_rx_indication().
I'm not sure this is safe if bond_3ad_rx_indication is started
prior to the unbind, e.g.,
CPU 0 CPU 1
---- -----
bond_3ad_rx_indication
[ pass port->slave test ]
[ ... ] rx_handler_unregister
[ state machine lock could be
contended, forcing us to wait ]
__get_state_machine_lock
write_lock(&bond->lock)
bond_3ad_unbind_slave()
[ ... ]
port->slave = NULL;
[ got the lock ]
ad_rx_machine(lacpdu, port)
[ detect loopback ]
pr_err(... port->slave->bond->dev->name)
or that ad_marker case that Veaceslav describes.
-J
>Best regards
>Ding Tianhong
>
>
>>>
>>> Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
>>> Cc: Nikolay Aleksandrov <nikolay@redhat.com>
>>> ---
>>> drivers/net/bonding/bond_3ad.c | 2 --
>>> 1 file changed, 2 deletions(-)
>>>
>>> diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
>>> index 7a3860f..c134f43 100644
>>> --- a/drivers/net/bonding/bond_3ad.c
>>> +++ b/drivers/net/bonding/bond_3ad.c
>>> @@ -2494,9 +2494,7 @@ int bond_3ad_lacpdu_recv(const struct sk_buff *skb, struct bonding *bond,
>>> if (!lacpdu)
>>> return ret;
>>>
>>> - read_lock(&bond->lock);
>>> ret = bond_3ad_rx_indication(lacpdu, slave, skb->len);
>>> - read_unlock(&bond->lock);
>>> return ret;
>>> }
>>>
>>> --
>>> 1.8.2.1
---
-Jay Vosburgh, IBM Linux Technology Center, fubar@us.ibm.com
^ permalink raw reply
* Re: [PATCH V3 4/6] vhost_net: determine whether or not to use zerocopy at one time
From: Jason Wang @ 2013-09-26 4:30 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: netdev, linux-kernel, kvm, virtualization
In-Reply-To: <20130923071620.GB31886@redhat.com>
On 09/23/2013 03:16 PM, Michael S. Tsirkin wrote:
> On Thu, Sep 05, 2013 at 10:54:44AM +0800, Jason Wang wrote:
>> > On 09/04/2013 07:59 PM, Michael S. Tsirkin wrote:
>>> > > On Mon, Sep 02, 2013 at 04:40:59PM +0800, Jason Wang wrote:
>>>> > >> Currently, even if the packet length is smaller than VHOST_GOODCOPY_LEN, if
>>>> > >> upend_idx != done_idx we still set zcopy_used to true and rollback this choice
>>>> > >> later. This could be avoided by determining zerocopy once by checking all
>>>> > >> conditions at one time before.
>>>> > >>
>>>> > >> Signed-off-by: Jason Wang <jasowang@redhat.com>
>>>> > >> ---
>>>> > >> drivers/vhost/net.c | 47 ++++++++++++++++++++---------------------------
>>>> > >> 1 files changed, 20 insertions(+), 27 deletions(-)
>>>> > >>
>>>> > >> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
>>>> > >> index 8a6dd0d..3f89dea 100644
>>>> > >> --- a/drivers/vhost/net.c
>>>> > >> +++ b/drivers/vhost/net.c
>>>> > >> @@ -404,43 +404,36 @@ static void handle_tx(struct vhost_net *net)
>>>> > >> iov_length(nvq->hdr, s), hdr_size);
>>>> > >> break;
>>>> > >> }
>>>> > >> - zcopy_used = zcopy && (len >= VHOST_GOODCOPY_LEN ||
>>>> > >> - nvq->upend_idx != nvq->done_idx);
>>>> > >> +
>>>> > >> + zcopy_used = zcopy && len >= VHOST_GOODCOPY_LEN
>>>> > >> + && (nvq->upend_idx + 1) % UIO_MAXIOV !=
>>>> > >> + nvq->done_idx
>>> > > Thinking about this, this looks strange.
>>> > > The original idea was that once we start doing zcopy, we keep
>>> > > using the heads ring even for short packets until no zcopy is outstanding.
>> >
>> > What's the reason for keep using the heads ring?
> To keep completions in order.
Ok, I will do some test to see the impact.
>>> > >
>>> > > What's the logic behind (nvq->upend_idx + 1) % UIO_MAXIOV != nvq->done_idx
>>> > > here?
>> >
>> > Because we initialize both upend_idx and done_idx to zero, so upend_idx
>> > != done_idx could not be used to check whether or not the heads ring
>> > were full.
> But what does ring full have to do with zerocopy use?
>
It was used to forbid the zerocopy when heads ring are full, but since
we have the limitation now, it could be removed.
^ permalink raw reply
* Re: [PATCH] ipvs: improved SH fallback strategy
From: Julian Anastasov @ 2013-09-26 5:30 UTC (permalink / raw)
To: Alexander Frolkin
Cc: Simon Horman, Sergei Shtylyov, lvs-devel, Wensong Zhang, netdev,
linux-kernel
In-Reply-To: <20130925092638.GD19768@eldamar.org.uk>
Hello,
On Wed, 25 Sep 2013, Alexander Frolkin wrote:
> Improve the SH fallback realserver selection strategy.
>
> With sh and sh-fallback, if a realserver is down, this attempts to
> distribute the traffic that would have gone to that server evenly
> among the remaining servers.
>
> Signed-off-by: Alexander Frolkin <avf@eldamar.org.uk>
>
> --
> diff --git a/net/netfilter/ipvs/ip_vs_sh.c b/net/netfilter/ipvs/ip_vs_sh.c
> index 3588fae..3d5ab7c 100644
> --- a/net/netfilter/ipvs/ip_vs_sh.c
> +++ b/net/netfilter/ipvs/ip_vs_sh.c
> @@ -115,27 +115,47 @@ ip_vs_sh_get(struct ip_vs_service *svc, struct ip_vs_sh_state *s,
> }
>
>
> -/* As ip_vs_sh_get, but with fallback if selected server is unavailable */
> +/* As ip_vs_sh_get, but with fallback if selected server is unavailable
> + *
> + * The fallback strategy loops around the table starting from a "random"
> + * point (in fact, it is chosen to be the original hash value to make the
> + * algorithm deterministic) to find a new server.
> + */
> static inline struct ip_vs_dest *
> ip_vs_sh_get_fallback(struct ip_vs_service *svc, struct ip_vs_sh_state *s,
> const union nf_inet_addr *addr, __be16 port)
> {
> - unsigned int offset;
> - unsigned int hash;
> + unsigned int offset, roffset;
> + unsigned int hash, ihash;
> struct ip_vs_dest *dest;
>
> - for (offset = 0; offset < IP_VS_SH_TAB_SIZE; offset++) {
> - hash = ip_vs_sh_hashkey(svc->af, addr, port, offset);
> - dest = rcu_dereference(s->buckets[hash].dest);
> - if (!dest)
> - break;
> - if (is_unavailable(dest))
> - IP_VS_DBG_BUF(6, "SH: selected unavailable server "
> - "%s:%d (offset %d)",
> + /* first try the dest it's supposed to go to */
> + ihash = ip_vs_sh_hashkey(svc->af, addr, port, 0);
> + dest = rcu_dereference(s->buckets[ihash].dest);
> + if (!dest)
> + return NULL;
Can we reduce the indentation here, eg:
if (!is_unavailable(dest))
return dest;
IP_VS_DBG_BUF(6, "SH: selected unavailable server "
...
for ()...
...
return NULL;
> + if (is_unavailable(dest)) {
> + IP_VS_DBG_BUF(6, "SH: selected unavailable server "
> + "%s:%d, reselecting",
> + IP_VS_DBG_ADDR(svc->af, &dest->addr),
> + ntohs(dest->port));
> + /* if the original dest is unavailable, loop around the table
> + * starting from ihash to find a new dest
> + */
> + for (offset = 0; offset < IP_VS_SH_TAB_SIZE; offset++) {
> + roffset = (offset + ihash) % IP_VS_SH_TAB_SIZE;
> + hash = ip_vs_sh_hashkey(svc->af, addr, port, roffset);
> + dest = rcu_dereference(s->buckets[hash].dest);
Every result of rcu_dereference should be checked
for NULL (no dests anymore):
if (!dest)
break;
Then make sure there is correct indentation
for IP_VS_DBG_BUF parameters.
> + if (is_unavailable(dest))
> + IP_VS_DBG_BUF(6, "SH: selected unavailable "
> + "server %s:%d (offset %d), reselecting",
> IP_VS_DBG_ADDR(svc->af, &dest->addr),
> - ntohs(dest->port), offset);
> - else
> - return dest;
> + ntohs(dest->port), roffset);
> + else
> + return dest;
> + }
> + } else {
> + return dest;
> }
>
> return NULL;
Regards
--
Julian Anastasov <ja@ssi.bg>
^ permalink raw reply
* Re: [PATCH v5 net-next 11/27] bonding: rework bond_3ad_xmit_xor() to use bond_for_each_slave() only
From: Veaceslav Falico @ 2013-09-26 5:43 UTC (permalink / raw)
To: Ding Tianhong; +Cc: netdev, jiri, Jay Vosburgh, Andy Gospodarek
In-Reply-To: <52439C87.6050809@huawei.com>
On Thu, Sep 26, 2013 at 10:31:35AM +0800, Ding Tianhong wrote:
First of all - thanks a lot for the review! Answered below.
>On 2013/9/25 15:20, Veaceslav Falico wrote:
>> Currently, there are two loops - first we find the first slave in an
>> aggregator after the xmit_hash_policy() returned number, and after that we
>> loop from that slave, over bonding head, and till that slave to find any
>> suitable slave to send the packet through.
>>
>> Replace it by just one bond_for_each_slave() loop, which first loops
>> through the requested number of slaves, saving the first suitable one, and
>> after that we've hit the requested number of slaves to skip - search for
>> any up slave to send the packet through. If we don't find such kind of
>> slave - then just send the packet through the first suitable slave found.
>>
>> Logic remains unchainged, and we skip two loops. Also, refactor it a bit
>> for readability.
>>
>> CC: Jay Vosburgh <fubar@us.ibm.com>
>> CC: Andy Gospodarek <andy@greyhouse.net>
>> Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
>> ---
>>
>> Notes:
>> v4 -> v5
>> No change.
>>
>> v3 -> v4:
>> No change.
>>
>> v2 -> v3:
>> No change.
>>
>> v1 -> v2:
>> No changes.
>>
>> RFC -> v1:
>> New patch.
>>
>> drivers/net/bonding/bond_3ad.c | 46 ++++++++++++++++++++----------------------
>> 1 file changed, 22 insertions(+), 24 deletions(-)
>>
>> diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
>> index 3847aee..c861ee7 100644
>> --- a/drivers/net/bonding/bond_3ad.c
>> +++ b/drivers/net/bonding/bond_3ad.c
>> @@ -2417,15 +2417,15 @@ int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info)
>>
>> int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
>> {
>> - struct slave *slave, *start_at;
>> struct bonding *bond = netdev_priv(dev);
>> + struct slave *slave, *first_ok_slave;
>> + struct aggregator *agg;
>> + struct ad_info ad_info;
>> struct list_head *iter;
>> - int slave_agg_no;
>> int slaves_in_agg;
>> - int agg_id;
>> - int i;
>> - struct ad_info ad_info;
>> + int slave_agg_no;
>> int res = 1;
>> + int agg_id;
>>
>> read_lock(&bond->lock);
>> if (__bond_3ad_get_active_agg_info(bond, &ad_info)) {
>> @@ -2438,20 +2438,28 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
>> agg_id = ad_info.aggregator_id;
>>
>> if (slaves_in_agg == 0) {
>> - /*the aggregator is empty*/
>> pr_debug("%s: Error: active aggregator is empty\n", dev->name);
>> goto out;
>> }
>>
>> slave_agg_no = bond->xmit_hash_policy(skb, slaves_in_agg);
>> + first_ok_slave = NULL;
>>
>> bond_for_each_slave(bond, slave, iter) {
>> - struct aggregator *agg = SLAVE_AD_INFO(slave).port.aggregator;
>> + agg = SLAVE_AD_INFO(slave).port.aggregator;
>> + if (!agg || agg->aggregator_identifier != agg_id)
>> + continue;
>>
>> - if (agg && (agg->aggregator_identifier == agg_id)) {
>> + if (slave_agg_no >= 0) {
>> + if (!first_ok_slave && SLAVE_IS_OK(slave))
>> + first_ok_slave = slave;
>> slave_agg_no--;
>> - if (slave_agg_no < 0)
>> - break;
>> + continue;
>> + }
[1] ^^^^^^^^^^^^^^^^^^^^^^^^^
>> +
>> + if (SLAVE_IS_OK(slave)) {
>> + res = bond_dev_queue_xmit(bond, skb, slave->dev);
>> + goto out;
>> }
[2] ^^^^^^^^^^^^^^^^^^^^^^^^^
>
>I think you miss something, you will send skb always by the first suitable port,
>it could not support load balance.
Well, yes, it will send always by the first suitable port AFTER
slave_agg_no, returned by the xmit_hash_policy(), which is the whole point
in the hash function and in the load balance.
It will first loop through the slaves, decrementing slave_agg_no to a
negative value, while saving the first good to send slave, as shown in [1].
Notice the "continue;":
if (slave_agg_no >= 0) {
if (!first_ok_slave && SLAVE_IS_OK(slave))
first_ok_slave = slave;
slave_agg_no--;
continue;
}
Once we hit the negative value - which means we've skipped enough slaves,
as requested by the hash function - we can start looking for the first
slave that is good to send AFTER those all skipped slaves, as shown in [2].
Down the patch we also use that 'first_ok_slave' - in case we didn't find
any suitable one after we've skipped first slave_agg_no and till the last
slave, so it implements the same 'circular' logic as was in
bond_for_each_slave_from().
>pls consult my function.
> if (agg && (agg->aggregator_identifier == agg_id)) {
>- slave_agg_no--;
>- if (slave_agg_no < 0)
>- break;
>+ if (--slave_agg_no < 0) {
>+ if (SLAVE_IS_OK(slave)) {
>+ res = bond_dev_queue_xmit(bond,
>+ skb, slave->dev);
>+ goto out;
>+ }
>+ }
I'll review your function in your patch.
> }
> }
>
>> }
>>
>> @@ -2461,20 +2469,10 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
>> goto out;
>> }
>>
>> - start_at = slave;
>> -
>> - bond_for_each_slave_from(bond, slave, i, start_at) {
>> - int slave_agg_id = 0;
>> - struct aggregator *agg = SLAVE_AD_INFO(slave).port.aggregator;
>> -
>> - if (agg)
>> - slave_agg_id = agg->aggregator_identifier;
>> -
>> - if (SLAVE_IS_OK(slave) && agg && (slave_agg_id == agg_id)) {
>> - res = bond_dev_queue_xmit(bond, skb, slave->dev);
>> - break;
>> - }
>> - }
>> + /* we couldn't find any suitable slave after the agg_no, so use the
>> + * first suitable found, if found. */
>> + if (first_ok_slave)
>> + res = bond_dev_queue_xmit(bond, skb, first_ok_slave->dev);
>>
>> out:
>> read_unlock(&bond->lock);
>>
>
>
^ permalink raw reply
* Established sockets remain open after iface down or address lost
From: Chris Verges @ 2013-09-26 6:04 UTC (permalink / raw)
To: davem, kuznet, jmorris, yoshfuji, kaber, netdev
Hello all,
I've encountered a behavior that appears to be known, but am seeking
some clarity on its rationale. The scenario is as follows:
(0) A TCP server socket listens on :: (v4/v6).
(1) Connect a USB/Ethernet adapter to a Linux system.
(2) Adapter is brought up as 'eth0' with an IP address.
(3) A remote TCP client connects to the server socket.
(4) 'netstat -anp' shows the socket as ESTABLISHED
(5) The TCP server starts a blocking read waiting for data.
(6) Physically disconnect the USB/Ethernet adapter from the USB bus.
(7) Linux removes the 'eth0' interface and associated IP address.
At this point, the socket _still_ shows as ESTABLISHED under netstat.
This is the paradox. Why is the blocking read not interrupted with a
socket error to indicate that the socket is no longer viable?
Thank you in advance,
Chris
P.S. I apologize in advance if I missed this answer in the netdev
archives.
^ permalink raw reply
* Re: [PATCH net-next v5 1/6] bonding: simplify and use RCU protection for 3ad xmit path
From: Veaceslav Falico @ 2013-09-26 6:07 UTC (permalink / raw)
To: Ding Tianhong
Cc: Jay Vosburgh, Andy Gospodarek, David S. Miller,
Nikolay Aleksandrov, Netdev
In-Reply-To: <5242B24F.5000309@huawei.com>
On Wed, Sep 25, 2013 at 05:52:15PM +0800, Ding Tianhong wrote:
>The commit 278b20837511776dc9d5f6ee1c7fabd5479838bb
>(bonding: initial RCU conversion) has convert the roundrobin, active-backup,
>broadcast and xor xmit path to rcu protection, the performance will be better
>for these mode, so this time, convert xmit path for 3ad mode.
>
>Suggested-by: Nikolay Aleksandrov <nikolay@redhat.com>
>Suggested-by: Veaceslav Falico <vfalico@redhat.com>
>Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
>Signed-off-by: Wang Yufen <wangyufen@huawei.com>
>Cc: Nikolay Aleksandrov <nikolay@redhat.com>
>Cc: Veaceslav Falico <vfalico@redhat.com>
>---
> drivers/net/bonding/bond_3ad.c | 32 ++++++++++++++------------------
> drivers/net/bonding/bonding.h | 30 +++++++++++++++++++++++++++++-
> 2 files changed, 43 insertions(+), 19 deletions(-)
>
>diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
>index 0d8f427..13f1deb 100644
>--- a/drivers/net/bonding/bond_3ad.c
>+++ b/drivers/net/bonding/bond_3ad.c
>@@ -143,7 +143,7 @@ static inline struct bonding *__get_bond_by_port(struct port *port)
> */
> static inline struct port *__get_first_port(struct bonding *bond)
> {
>- struct slave *first_slave = bond_first_slave(bond);
>+ struct slave *first_slave = bond_first_slave_rcu(bond);
>
> return first_slave ? &(SLAVE_AD_INFO(first_slave).port) : NULL;
> }
>@@ -163,7 +163,7 @@ static inline struct port *__get_next_port(struct port *port)
> // If there's no bond for this port, or this is the last slave
> if (bond == NULL)
> return NULL;
>- slave_next = bond_next_slave(bond, slave);
>+ slave_next = bond_next_slave_rcu(bond, slave);
> if (!slave_next || bond_is_first_slave(bond, slave_next))
> return NULL;
>
>@@ -2417,16 +2417,14 @@ int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info)
>
> int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
> {
>- struct slave *slave, *start_at;
> struct bonding *bond = netdev_priv(dev);
>+ struct slave *slave;
> int slave_agg_no;
> int slaves_in_agg;
> int agg_id;
>- int i;
> struct ad_info ad_info;
> int res = 1;
>
>- read_lock(&bond->lock);
> if (__bond_3ad_get_active_agg_info(bond, &ad_info)) {
> pr_debug("%s: Error: __bond_3ad_get_active_agg_info failed\n",
> dev->name);
>@@ -2444,13 +2442,17 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
>
> slave_agg_no = bond->xmit_hash_policy(skb, slaves_in_agg);
>
>- bond_for_each_slave(bond, slave) {
>+ bond_for_each_slave_rcu(bond, slave) {
> struct aggregator *agg = SLAVE_AD_INFO(slave).port.aggregator;
>
> if (agg && (agg->aggregator_identifier == agg_id)) {
>- slave_agg_no--;
>- if (slave_agg_no < 0)
>- break;
>+ if (--slave_agg_no < 0) {
>+ if (SLAVE_IS_OK(slave)) {
>+ res = bond_dev_queue_xmit(bond,
>+ skb, slave->dev);
>+ goto out;
>+ }
>+ }
> }
> }
So here you are checking for any suitable slave from slave number
slave_agg_no+1 and till the last slave. Ok.
Some nitpicks, though not critical - slave_agg_no will always get
decremented, even if it's negative. It's ok though harder to
read/understand. The triple cascaded ifs can be omited, from (used the same
code):
if (agg && (agg->aggregator_identifier == agg_id)) {
if (--slave_agg_no < 0) {
if (SLAVE_IS_OK(slave)) {
do_something();
goto out;
}
}
}
to (again, used the same code):
if (!agg || agg->aggregator_identifier != agg_id)
continue;
if (--slave_agg_no >= 0)
continue;
if (SLAVE_IS_OK(slave)) {
do_something();
goto out;
}
Which is a lot easier to read/understand. Though, again, there are small
nitpicks and I'm ok with your approach.
>
>@@ -2460,23 +2462,17 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
> goto out;
> }
>
>- start_at = slave;
>-
>- bond_for_each_slave_from(bond, slave, i, start_at) {
>- int slave_agg_id = 0;
>+ bond_for_each_slave_rcu(bond, slave) {
> struct aggregator *agg = SLAVE_AD_INFO(slave).port.aggregator;
>
>- if (agg)
>- slave_agg_id = agg->aggregator_identifier;
>-
>- if (SLAVE_IS_OK(slave) && agg && (slave_agg_id == agg_id)) {
>+ if (SLAVE_IS_OK(slave) && agg &&
>+ agg->aggregator_identifier == agg_id) {
> res = bond_dev_queue_xmit(bond, skb, slave->dev);
> break;
> }
> }
Ok, so if the first approach fails - you loop through *all* the slaves
again, checking the slaves already checked by the first loop - i.e. the
slaves from slave number slave_agg_no and till the last slave.
It's suboptimal, but still should work. You can optimize this by storing a
'first ok slave' in the first loop, and if the first loop fails to find any
slave *after* slave_agg_no, you can use that first_ok_slave (if found) to
send. This way you'll drop the second loop entirely. It's the way that I've
done in my patch - pls consult my function :) :
http://patchwork.ozlabs.org/patch/277701/
bond_for_each_slave(bond, slave, iter) {
agg = SLAVE_AD_INFO(slave).port.aggregator;
if (!agg || agg->aggregator_identifier != agg_id)
continue;
if (slave_agg_no >= 0) {
if (!first_ok_slave && SLAVE_IS_OK(slave))
first_ok_slave = slave;
slave_agg_no--;
continue;
}
if (SLAVE_IS_OK(slave)) {
res = bond_dev_queue_xmit(bond, skb, slave->dev);
goto out;
}
}
...
if (first_ok_slave)
res = bond_dev_queue_xmit(bond, skb, first_ok_slave->dev);
>
> out:
>- read_unlock(&bond->lock);
> if (res) {
> /* no suitable interface, frame not sent */
> kfree_skb(skb);
>diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
>index 03cf3fd..eb36f57 100644
>--- a/drivers/net/bonding/bonding.h
>+++ b/drivers/net/bonding/bonding.h
>@@ -74,13 +74,31 @@
> /* slave list primitives */
> #define bond_to_slave(ptr) list_entry(ptr, struct slave, list)
>
>+/* slave list primitives, Caller must hold rcu_read_lock */
>+#define bond_to_slave_rcu(ptr) list_entry_rcu(ptr, struct slave, list)
>+
>+/* bond_is_empty return NULL if slave list is empty*/
>+#define bond_is_empty(bond) \
>+ (list_empty(&(bond)->slave_list))
>+
>+/* bond_is_empty_rcu return NULL if slave list is empty*/
>+#define bond_is_empty_rcu(bond) \
>+ (!list_first_or_null_rcu(&(bond)->slave_list, struct slave, list))
>+
> /* IMPORTANT: bond_first/last_slave can return NULL in case of an empty list */
> #define bond_first_slave(bond) \
> list_first_entry_or_null(&(bond)->slave_list, struct slave, list)
> #define bond_last_slave(bond) \
>- (list_empty(&(bond)->slave_list) ? NULL : \
>+ (bond_is_empty(bond) ? NULL : \
> bond_to_slave((bond)->slave_list.prev))
>
>+/**
>+ * IMPORTANT: bond_first/last_slave_rcu can return NULL in case of an empty list
>+ * Caller must hold rcu_read_lock
>+ */
>+#define bond_first_slave_rcu(bond) \
>+ list_first_or_null_rcu(&(bond)->slave_list, struct slave, list);
>+
> #define bond_is_first_slave(bond, pos) ((pos)->list.prev == &(bond)->slave_list)
> #define bond_is_last_slave(bond, pos) ((pos)->list.next == &(bond)->slave_list)
>
>@@ -93,6 +111,16 @@
> (bond_is_first_slave(bond, pos) ? bond_last_slave(bond) : \
> bond_to_slave((pos)->list.prev))
>
>+/* Since bond_first/last_slave_rcu can return NULL, these can return NULL too */
>+#define bond_next_slave_rcu(bond, pos) \
>+ ({struct list_head *__slave_list = &(bond)->slave_list; \
>+ struct list_head __rcu *__next = list_next_rcu(__slave_list); \
>+ struct list_head __rcu *__pos_next = list_next_rcu(&(pos)->list); \
>+ likely(__pos_next != __slave_list) ? \
>+ container_of(__pos_next, struct slave, list) : \
>+ container_of(__next, struct slave, list); \
>+ })
>+
> /**
> * bond_for_each_slave_from - iterate the slaves list from a starting point
> * @bond: the bond holding this list.
>--
>1.8.0
>
>
>
^ permalink raw reply
* Re: [PATCH net-next v5 2/6] bonding: remove the no effect lock for bond_3ad_lacpdu_recv()
From: Ding Tianhong @ 2013-09-26 6:19 UTC (permalink / raw)
To: Jay Vosburgh
Cc: Veaceslav Falico, Andy Gospodarek, David S. Miller,
Nikolay Aleksandrov, Netdev
In-Reply-To: <11033.1380169422@death.nxdomain>
On 2013/9/26 12:23, Jay Vosburgh wrote:
> Ding Tianhong <dingtianhong@huawei.com> wrote:
>
>> On 2013/9/25 18:33, Veaceslav Falico wrote:
>>> On Wed, Sep 25, 2013 at 05:52:19PM +0800, Ding Tianhong wrote:
>>>> There is no pointer needed read lock protection, remove the unnecessary lock
>>>> and improve performance for the 3ad recv path.
>
> How much does removing the lock around the LACPDU receive
> processing improve performance? This is not high rate traffic; the
> "fast" rate is one LACPDU per second (per port); the default rate is one
> every 30 seconds.
>
agree.
>>> I don't really understand it. Here's the code path:
>>>
>>> rx_handler (holding rcu_read_lock()) -> bond_handle_frame() ->
>>> bond->recv_probe -> bond_3ad_lacpdu_recv(). So we're holding only the
>>> rcu_read_lock() there. What stops us from racing with
>>> bond_3ad_unbind_slave(), for example?
>>>
>>> As in:
>>>
>>> CPU0 CPU1
>>> -------- -----------
>>> ... bond_3ad_unbind_slave()
>>> bond_3ad_rx_indication() ...
>>> if (!port->slave) { ... //slave is ok
>>> port->slave = NULL;
>>> ad_marker_info_received() ...
>>> ad_marker_send() ...
>>> slave = port->slave; ...
>>> skb->dev = slave->dev; ...
>>> ^^^ NULL pointer dereference.
>>>
>>>
>>> I'm not saying that this approach is wrong, maybe I'm missing something,
>>> but when removing locks it's usually a good thing to do - to comment it in
>>> depth in the commit message why it's not already needed.
>>>
>>
>> no, it will not happend, pls review the cold:
>> netdev_rx_handler_unregister(slave_dev);
>> write_lock_bh(&bond->lock);
>>
>> /* Inform AD package of unbinding of slave. */
>> if (bond->params.mode == BOND_MODE_8023AD) {
>> /* must be called before the slave is
>> * detached from the list
>> */
>> bond_3ad_unbind_slave(slave);
>> }
>> netdev_rx_handler_unregiste() will remvoe the rx_handle before the bond_3ad_unbind_slave(),
>> it was safe to run bond_3ad_rx_indication().
>
> I'm not sure this is safe if bond_3ad_rx_indication is started
> prior to the unbind, e.g.,
>
> CPU 0 CPU 1
> ---- -----
> bond_3ad_rx_indication
> [ pass port->slave test ]
> [ ... ] rx_handler_unregister
>
> [ state machine lock could be
> contended, forcing us to wait ]
> __get_state_machine_lock
>
> write_lock(&bond->lock)
> bond_3ad_unbind_slave()
> [ ... ]
> port->slave = NULL;
>
> [ got the lock ]
> ad_rx_machine(lacpdu, port)
> [ detect loopback ]
> pr_err(... port->slave->bond->dev->name)
>
> or that ad_marker case that Veaceslav describes.
>
> -J
>
yes, I miss one thing here, there is no rcu_read_lock() here, so when enter
bond_3ad_unbind_slave(), bond_3ad_rx_indication() was running.
we should miss the patch, thanks.
>> Best regards
>> Ding Tianhong
>>
>>
>>>>
>>>> Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
>>>> Cc: Nikolay Aleksandrov <nikolay@redhat.com>
>>>> ---
>>>> drivers/net/bonding/bond_3ad.c | 2 --
>>>> 1 file changed, 2 deletions(-)
>>>>
>>>> diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
>>>> index 7a3860f..c134f43 100644
>>>> --- a/drivers/net/bonding/bond_3ad.c
>>>> +++ b/drivers/net/bonding/bond_3ad.c
>>>> @@ -2494,9 +2494,7 @@ int bond_3ad_lacpdu_recv(const struct sk_buff *skb, struct bonding *bond,
>>>> if (!lacpdu)
>>>> return ret;
>>>>
>>>> - read_lock(&bond->lock);
>>>> ret = bond_3ad_rx_indication(lacpdu, slave, skb->len);
>>>> - read_unlock(&bond->lock);
>>>> return ret;
>>>> }
>>>>
>>>> --
>>>> 1.8.2.1
>
> ---
> -Jay Vosburgh, IBM Linux Technology Center, fubar@us.ibm.com
>
>
> .
>
^ permalink raw reply
* Re: [PATCH v5 net-next 11/27] bonding: rework bond_3ad_xmit_xor() to use bond_for_each_slave() only
From: Ding Tianhong @ 2013-09-26 6:39 UTC (permalink / raw)
To: Veaceslav Falico; +Cc: netdev, jiri, Jay Vosburgh, Andy Gospodarek
In-Reply-To: <20130926054317.GA2547@redhat.com>
On 2013/9/26 13:43, Veaceslav Falico wrote:
> On Thu, Sep 26, 2013 at 10:31:35AM +0800, Ding Tianhong wrote:
>
> First of all - thanks a lot for the review! Answered below.
>
>> On 2013/9/25 15:20, Veaceslav Falico wrote:
>>> Currently, there are two loops - first we find the first slave in an
>>> aggregator after the xmit_hash_policy() returned number, and after that we
>>> loop from that slave, over bonding head, and till that slave to find any
>>> suitable slave to send the packet through.
>>>
>>> Replace it by just one bond_for_each_slave() loop, which first loops
>>> through the requested number of slaves, saving the first suitable one, and
>>> after that we've hit the requested number of slaves to skip - search for
>>> any up slave to send the packet through. If we don't find such kind of
>>> slave - then just send the packet through the first suitable slave found.
>>>
>>> Logic remains unchainged, and we skip two loops. Also, refactor it a bit
>>> for readability.
>>>
>>> CC: Jay Vosburgh <fubar@us.ibm.com>
>>> CC: Andy Gospodarek <andy@greyhouse.net>
>>> Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
>>> ---
>>>
>>> Notes:
>>> v4 -> v5
>>> No change.
>>>
>>> v3 -> v4:
>>> No change.
>>>
>>> v2 -> v3:
>>> No change.
>>>
>>> v1 -> v2:
>>> No changes.
>>>
>>> RFC -> v1:
>>> New patch.
>>>
>>> drivers/net/bonding/bond_3ad.c | 46 ++++++++++++++++++++----------------------
>>> 1 file changed, 22 insertions(+), 24 deletions(-)
>>>
>>> diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
>>> index 3847aee..c861ee7 100644
>>> --- a/drivers/net/bonding/bond_3ad.c
>>> +++ b/drivers/net/bonding/bond_3ad.c
>>> @@ -2417,15 +2417,15 @@ int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info)
>>>
>>> int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
>>> {
>>> - struct slave *slave, *start_at;
>>> struct bonding *bond = netdev_priv(dev);
>>> + struct slave *slave, *first_ok_slave;
>>> + struct aggregator *agg;
>>> + struct ad_info ad_info;
>>> struct list_head *iter;
>>> - int slave_agg_no;
>>> int slaves_in_agg;
>>> - int agg_id;
>>> - int i;
>>> - struct ad_info ad_info;
>>> + int slave_agg_no;
>>> int res = 1;
>>> + int agg_id;
>>>
>>> read_lock(&bond->lock);
>>> if (__bond_3ad_get_active_agg_info(bond, &ad_info)) {
>>> @@ -2438,20 +2438,28 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
>>> agg_id = ad_info.aggregator_id;
>>>
>>> if (slaves_in_agg == 0) {
>>> - /*the aggregator is empty*/
>>> pr_debug("%s: Error: active aggregator is empty\n", dev->name);
>>> goto out;
>>> }
>>>
>>> slave_agg_no = bond->xmit_hash_policy(skb, slaves_in_agg);
>>> + first_ok_slave = NULL;
>>>
>>> bond_for_each_slave(bond, slave, iter) {
>>> - struct aggregator *agg = SLAVE_AD_INFO(slave).port.aggregator;
>>> + agg = SLAVE_AD_INFO(slave).port.aggregator;
>>> + if (!agg || agg->aggregator_identifier != agg_id)
>>> + continue;
>>>
>>> - if (agg && (agg->aggregator_identifier == agg_id)) {
>>> + if (slave_agg_no >= 0) {
>>> + if (!first_ok_slave && SLAVE_IS_OK(slave))
>>> + first_ok_slave = slave;
>>> slave_agg_no--;
>>> - if (slave_agg_no < 0)
>>> - break;
>>> + continue;
>>> + }
>
> [1] ^^^^^^^^^^^^^^^^^^^^^^^^^
>
>>> +
>>> + if (SLAVE_IS_OK(slave)) {
>>> + res = bond_dev_queue_xmit(bond, skb, slave->dev);
>>> + goto out;
>>> }
>
> [2] ^^^^^^^^^^^^^^^^^^^^^^^^^
>
>>
>> I think you miss something, you will send skb always by the first suitable port,
>> it could not support load balance.
>
> Well, yes, it will send always by the first suitable port AFTER
> slave_agg_no, returned by the xmit_hash_policy(), which is the whole point
> in the hash function and in the load balance.
>
> It will first loop through the slaves, decrementing slave_agg_no to a
> negative value, while saving the first good to send slave, as shown in [1].
> Notice the "continue;":
>
> if (slave_agg_no >= 0) {
> if (!first_ok_slave && SLAVE_IS_OK(slave))
> first_ok_slave = slave;
> slave_agg_no--;
> continue;
> }
>
yes, I got your opinion, tnanks.
> Once we hit the negative value - which means we've skipped enough slaves,
> as requested by the hash function - we can start looking for the first
> slave that is good to send AFTER those all skipped slaves, as shown in [2].
>
> Down the patch we also use that 'first_ok_slave' - in case we didn't find
> any suitable one after we've skipped first slave_agg_no and till the last
> slave, so it implements the same 'circular' logic as was in
> bond_for_each_slave_from().
>
>> pls consult my function.
>> if (agg && (agg->aggregator_identifier == agg_id)) {
>> - slave_agg_no--;
>> - if (slave_agg_no < 0)
>> - break;
>> + if (--slave_agg_no < 0) {
>> + if (SLAVE_IS_OK(slave)) {
>> + res = bond_dev_queue_xmit(bond,
>> + skb, slave->dev);
>> + goto out;
>> + }
>> + }
>
> I'll review your function in your patch.
>
>> }
>> }
>>
>>> }
>>>
>>> @@ -2461,20 +2469,10 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
>>> goto out;
>>> }
>>>
>>> - start_at = slave;
>>> -
>>> - bond_for_each_slave_from(bond, slave, i, start_at) {
>>> - int slave_agg_id = 0;
>>> - struct aggregator *agg = SLAVE_AD_INFO(slave).port.aggregator;
>>> -
>>> - if (agg)
>>> - slave_agg_id = agg->aggregator_identifier;
>>> -
>>> - if (SLAVE_IS_OK(slave) && agg && (slave_agg_id == agg_id)) {
>>> - res = bond_dev_queue_xmit(bond, skb, slave->dev);
>>> - break;
>>> - }
>>> - }
>>> + /* we couldn't find any suitable slave after the agg_no, so use the
>>> + * first suitable found, if found. */
>>> + if (first_ok_slave)
>>> + res = bond_dev_queue_xmit(bond, skb, first_ok_slave->dev);
>>>
>>> out:
>>> read_unlock(&bond->lock);
>>>
>>
>>
>
> .
>
^ permalink raw reply
* Re: [PATCH] ARM: shmobile: Lager: add Micrel KSZ8041 PHY fixup
From: Magnus Damm @ 2013-09-26 6:50 UTC (permalink / raw)
To: Sergei Shtylyov
Cc: Simon Horman [Horms], SH-Linux, Russell King - ARM Linux,
linux-arm-kernel@lists.infradead.org, Laurent Pinchart, netdev
In-Reply-To: <201309140429.23474.sergei.shtylyov@cogentembedded.com>
On Fri, Sep 13, 2013 at 5:29 PM, Sergei Shtylyov
<sergei.shtylyov@cogentembedded.com> wrote:
> Currently on the Lager board NFS timeouts/delays are seen when booting. That
> turned out to happen because the SoC's ETH_LINK signal turns on and off after
> each packet. It is connected to Micrel KSZ8041 PHY's LED0 signal. Ether LEDs
> on the Lager board are named LINK and ACTIVE which corresponds to non-default
> 01 setting of the PHY control register 1 bits 14-15. The 'sh_eth' driver resets
> the PHY when opening the network device, so we have to set the mentioned bits
> back to 01 from the default 00 value which causes bouncing of ETH_LINK. That
> can be achieved using the PHY platform fixup mechanism if we also modify the
> driver to use it..
>
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Hi Sergei,
Thanks for your efforts on this. Nice to see that Ethernet for Lager
board support is improving.
Can you please share with us with link speeds you tested? I suspect
that this patch is only needed for some case, like for instance 100
MBit Full Duplex. Fixing the PHY settings makes sense even though only
a single mode needs it, but knowing which link speeds that are known
to work would help a lot.
Cheers,
/ magnus
^ permalink raw reply
* Re: [PATCH 04/11] ath: Remove extern from function prototypes
From: Kalle Valo @ 2013-09-26 7:30 UTC (permalink / raw)
To: Joe Perches
Cc: netdev, linux-wireless, Jouni Malinen, Luis R. Rodriguez, ath10k,
John W. Linville, ath9k-devel, David S. Miller, linux-kernel
In-Reply-To: <a3dabaf02d36dbb4051188b706a3e66e6465c56b.1380137609.git.joe@perches.com>
Joe Perches <joe@perches.com> writes:
> There are a mix of function prototypes with and without extern
> in the kernel sources. Standardize on not using extern for
> function prototypes.
>
> Function prototypes don't need to be written with extern.
> extern is assumed by the compiler. Its use is as unnecessary as
> using auto to declare automatic/local variables in a block.
>
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> drivers/net/wireless/ath/ath10k/debug.h | 8 ++++----
> drivers/net/wireless/ath/ath6kl/common.h | 3 +--
> drivers/net/wireless/ath/ath6kl/debug.h | 9 ++++-----
> drivers/net/wireless/ath/ath9k/ath9k.h | 2 +-
> 4 files changed, 10 insertions(+), 12 deletions(-)
For the ath10k and ath6kl changes:
Acked-by: Kalle Valo <kvalo@qca.qualcomm.com>
--
Kalle Valo
^ permalink raw reply
* Re: [PATCH 05/11] brcm80211: Remove extern from function prototypes
From: Arend van Spriel @ 2013-09-26 7:32 UTC (permalink / raw)
To: Joe Perches, netdev
Cc: David S. Miller, Brett Rudley, Franky (Zhenhui) Lin,
Hante Meuleman, John W. Linville, linux-wireless,
brcm80211-dev-list, linux-kernel
In-Reply-To: <9bd91f3c00bd8dd54339499a9253b31c6bac7c7b.1380137609.git.joe@perches.com>
On 09/25/2013 09:37 PM, Joe Perches wrote:
> There are a mix of function prototypes with and without extern
> in the kernel sources. Standardize on not using extern for
> function prototypes.
>
> Function prototypes don't need to be written with extern.
> extern is assumed by the compiler. Its use is as unnecessary as
> using auto to declare automatic/local variables in a block.
Acked-by: Arend van Spriel <arend@broadcom.com>
> Signed-off-by: Joe Perches <joe@perches.com>
As a side note, I submitted a patch to the wireless tree yesterday
adding a function prototype and I decided to ignore the checkpatch
warning and follow the convention in the header file (for now). So that
patch is going to collide with this one.
Regards,
Arend
> ---
> drivers/net/wireless/brcm80211/brcmfmac/dhd.h | 30 +-
> drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h | 27 +-
> .../net/wireless/brcm80211/brcmfmac/dhd_proto.h | 12 +-
> .../net/wireless/brcm80211/brcmfmac/sdio_chip.h | 23 +-
> .../net/wireless/brcm80211/brcmfmac/sdio_host.h | 92 +++--
> drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 18 +-
> drivers/net/wireless/brcm80211/brcmsmac/ampdu.h | 22 +-
> drivers/net/wireless/brcm80211/brcmsmac/antsel.h | 14 +-
> drivers/net/wireless/brcm80211/brcmsmac/channel.h | 20 +-
> .../net/wireless/brcm80211/brcmsmac/mac80211_if.h | 38 +--
> drivers/net/wireless/brcm80211/brcmsmac/main.h | 110 +++---
> .../net/wireless/brcm80211/brcmsmac/phy/phy_hal.h | 219 ++++++------
> .../net/wireless/brcm80211/brcmsmac/phy/phy_int.h | 371 ++++++++++-----------
> drivers/net/wireless/brcm80211/brcmsmac/phy_shim.h | 91 +++--
> drivers/net/wireless/brcm80211/brcmsmac/pmu.h | 4 +-
> drivers/net/wireless/brcm80211/brcmsmac/pub.h | 145 ++++----
> drivers/net/wireless/brcm80211/brcmsmac/rate.h | 48 ++-
> drivers/net/wireless/brcm80211/brcmsmac/stf.h | 31 +-
> .../net/wireless/brcm80211/brcmsmac/ucode_loader.h | 16 +-
> drivers/net/wireless/brcm80211/include/brcmu_d11.h | 2 +-
> .../net/wireless/brcm80211/include/brcmu_utils.h | 44 ++-
> 21 files changed, 644 insertions(+), 733 deletions(-)
>
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h
> index 2eb9e64..34af9d1 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h
> @@ -632,29 +632,29 @@ struct brcmf_skb_reorder_data {
> u8 *reorder;
> };
>
> -extern int brcmf_netdev_wait_pend8021x(struct net_device *ndev);
> +int brcmf_netdev_wait_pend8021x(struct net_device *ndev);
>
> /* Return pointer to interface name */
> -extern char *brcmf_ifname(struct brcmf_pub *drvr, int idx);
> +char *brcmf_ifname(struct brcmf_pub *drvr, int idx);
>
> /* Query dongle */
> -extern int brcmf_proto_cdc_query_dcmd(struct brcmf_pub *drvr, int ifidx,
> - uint cmd, void *buf, uint len);
> -extern int brcmf_proto_cdc_set_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd,
> - void *buf, uint len);
> +int brcmf_proto_cdc_query_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd,
> + void *buf, uint len);
> +int brcmf_proto_cdc_set_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd,
> + void *buf, uint len);
>
> /* Remove any protocol-specific data header. */
> -extern int brcmf_proto_hdrpull(struct brcmf_pub *drvr, bool do_fws, u8 *ifidx,
> - struct sk_buff *rxp);
> +int brcmf_proto_hdrpull(struct brcmf_pub *drvr, bool do_fws, u8 *ifidx,
> + struct sk_buff *rxp);
>
> -extern int brcmf_net_attach(struct brcmf_if *ifp, bool rtnl_locked);
> -extern struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bssidx,
> - s32 ifidx, char *name, u8 *mac_addr);
> -extern void brcmf_del_if(struct brcmf_pub *drvr, s32 bssidx);
> +int brcmf_net_attach(struct brcmf_if *ifp, bool rtnl_locked);
> +struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bssidx, s32 ifidx,
> + char *name, u8 *mac_addr);
> +void brcmf_del_if(struct brcmf_pub *drvr, s32 bssidx);
> void brcmf_txflowblock_if(struct brcmf_if *ifp,
> enum brcmf_netif_stop_reason reason, bool state);
> -extern u32 brcmf_get_chip_info(struct brcmf_if *ifp);
> -extern void brcmf_txfinalize(struct brcmf_pub *drvr, struct sk_buff *txp,
> - bool success);
> +u32 brcmf_get_chip_info(struct brcmf_if *ifp);
> +void brcmf_txfinalize(struct brcmf_pub *drvr, struct sk_buff *txp,
> + bool success);
>
> #endif /* _BRCMF_H_ */
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h
> index f7c1985..5bc0276 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h
> @@ -132,34 +132,33 @@ struct pktq *brcmf_bus_gettxq(struct brcmf_bus *bus)
> * interface functions from common layer
> */
>
> -extern bool brcmf_c_prec_enq(struct device *dev, struct pktq *q,
> - struct sk_buff *pkt, int prec);
> +bool brcmf_c_prec_enq(struct device *dev, struct pktq *q, struct sk_buff *pkt,
> + int prec);
>
> /* Receive frame for delivery to OS. Callee disposes of rxp. */
> -extern void brcmf_rx_frames(struct device *dev, struct sk_buff_head *rxlist);
> +void brcmf_rx_frames(struct device *dev, struct sk_buff_head *rxlist);
>
> /* Indication from bus module regarding presence/insertion of dongle. */
> -extern int brcmf_attach(uint bus_hdrlen, struct device *dev);
> +int brcmf_attach(uint bus_hdrlen, struct device *dev);
> /* Indication from bus module regarding removal/absence of dongle */
> -extern void brcmf_detach(struct device *dev);
> +void brcmf_detach(struct device *dev);
> /* Indication from bus module that dongle should be reset */
> -extern void brcmf_dev_reset(struct device *dev);
> +void brcmf_dev_reset(struct device *dev);
> /* Indication from bus module to change flow-control state */
> -extern void brcmf_txflowblock(struct device *dev, bool state);
> +void brcmf_txflowblock(struct device *dev, bool state);
>
> /* Notify the bus has transferred the tx packet to firmware */
> -extern void brcmf_txcomplete(struct device *dev, struct sk_buff *txp,
> - bool success);
> +void brcmf_txcomplete(struct device *dev, struct sk_buff *txp, bool success);
>
> -extern int brcmf_bus_start(struct device *dev);
> +int brcmf_bus_start(struct device *dev);
>
> #ifdef CONFIG_BRCMFMAC_SDIO
> -extern void brcmf_sdio_exit(void);
> -extern void brcmf_sdio_init(void);
> +void brcmf_sdio_exit(void);
> +void brcmf_sdio_init(void);
> #endif
> #ifdef CONFIG_BRCMFMAC_USB
> -extern void brcmf_usb_exit(void);
> -extern void brcmf_usb_init(void);
> +void brcmf_usb_exit(void);
> +void brcmf_usb_init(void);
> #endif
>
> #endif /* _BRCMF_BUS_H_ */
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_proto.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_proto.h
> index ef91798..53c6e71 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_proto.h
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_proto.h
> @@ -22,21 +22,21 @@
> */
>
> /* Linkage, sets prot link and updates hdrlen in pub */
> -extern int brcmf_proto_attach(struct brcmf_pub *drvr);
> +int brcmf_proto_attach(struct brcmf_pub *drvr);
>
> /* Unlink, frees allocated protocol memory (including brcmf_proto) */
> -extern void brcmf_proto_detach(struct brcmf_pub *drvr);
> +void brcmf_proto_detach(struct brcmf_pub *drvr);
>
> /* Stop protocol: sync w/dongle state. */
> -extern void brcmf_proto_stop(struct brcmf_pub *drvr);
> +void brcmf_proto_stop(struct brcmf_pub *drvr);
>
> /* Add any protocol-specific data header.
> * Caller must reserve prot_hdrlen prepend space.
> */
> -extern void brcmf_proto_hdrpush(struct brcmf_pub *, int ifidx, u8 offset,
> - struct sk_buff *txp);
> +void brcmf_proto_hdrpush(struct brcmf_pub *, int ifidx, u8 offset,
> + struct sk_buff *txp);
>
> /* Sets dongle media info (drv_version, mac address). */
> -extern int brcmf_c_preinit_dcmds(struct brcmf_if *ifp);
> +int brcmf_c_preinit_dcmds(struct brcmf_if *ifp);
>
> #endif /* _BRCMF_PROTO_H_ */
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h
> index 83c041f..f0780ee 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h
> @@ -215,17 +215,16 @@ struct sdpcmd_regs {
> u16 PAD[0x80];
> };
>
> -extern int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev,
> - struct chip_info **ci_ptr, u32 regs);
> -extern void brcmf_sdio_chip_detach(struct chip_info **ci_ptr);
> -extern void brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev,
> - struct chip_info *ci,
> - u32 drivestrength);
> -extern u8 brcmf_sdio_chip_getinfidx(struct chip_info *ci, u16 coreid);
> -extern void brcmf_sdio_chip_enter_download(struct brcmf_sdio_dev *sdiodev,
> - struct chip_info *ci);
> -extern bool brcmf_sdio_chip_exit_download(struct brcmf_sdio_dev *sdiodev,
> - struct chip_info *ci, char *nvram_dat,
> - uint nvram_sz);
> +int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev,
> + struct chip_info **ci_ptr, u32 regs);
> +void brcmf_sdio_chip_detach(struct chip_info **ci_ptr);
> +void brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev,
> + struct chip_info *ci, u32 drivestrength);
> +u8 brcmf_sdio_chip_getinfidx(struct chip_info *ci, u16 coreid);
> +void brcmf_sdio_chip_enter_download(struct brcmf_sdio_dev *sdiodev,
> + struct chip_info *ci);
> +bool brcmf_sdio_chip_exit_download(struct brcmf_sdio_dev *sdiodev,
> + struct chip_info *ci, char *nvram_dat,
> + uint nvram_sz);
>
> #endif /* _BRCMFMAC_SDIO_CHIP_H_ */
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h
> index 2b5407f..c9b06b4 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h
> @@ -181,18 +181,18 @@ struct brcmf_sdio_dev {
> };
>
> /* Register/deregister interrupt handler. */
> -extern int brcmf_sdio_intr_register(struct brcmf_sdio_dev *sdiodev);
> -extern int brcmf_sdio_intr_unregister(struct brcmf_sdio_dev *sdiodev);
> +int brcmf_sdio_intr_register(struct brcmf_sdio_dev *sdiodev);
> +int brcmf_sdio_intr_unregister(struct brcmf_sdio_dev *sdiodev);
>
> /* sdio device register access interface */
> -extern u8 brcmf_sdio_regrb(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret);
> -extern u32 brcmf_sdio_regrl(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret);
> -extern void brcmf_sdio_regwb(struct brcmf_sdio_dev *sdiodev, u32 addr,
> - u8 data, int *ret);
> -extern void brcmf_sdio_regwl(struct brcmf_sdio_dev *sdiodev, u32 addr,
> - u32 data, int *ret);
> -extern int brcmf_sdio_regrw_helper(struct brcmf_sdio_dev *sdiodev, u32 addr,
> - void *data, bool write);
> +u8 brcmf_sdio_regrb(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret);
> +u32 brcmf_sdio_regrl(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret);
> +void brcmf_sdio_regwb(struct brcmf_sdio_dev *sdiodev, u32 addr, u8 data,
> + int *ret);
> +void brcmf_sdio_regwl(struct brcmf_sdio_dev *sdiodev, u32 addr, u32 data,
> + int *ret);
> +int brcmf_sdio_regrw_helper(struct brcmf_sdio_dev *sdiodev, u32 addr,
> + void *data, bool write);
>
> /* Buffer transfer to/from device (client) core via cmd53.
> * fn: function number
> @@ -206,22 +206,17 @@ extern int brcmf_sdio_regrw_helper(struct brcmf_sdio_dev *sdiodev, u32 addr,
> * Returns 0 or error code.
> * NOTE: Async operation is not currently supported.
> */
> -extern int
> -brcmf_sdcard_send_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
> - uint flags, struct sk_buff_head *pktq);
> -extern int
> -brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
> - uint flags, u8 *buf, uint nbytes);
> -
> -extern int
> -brcmf_sdcard_recv_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
> - uint flags, struct sk_buff *pkt);
> -extern int
> -brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
> - uint flags, u8 *buf, uint nbytes);
> -extern int
> -brcmf_sdcard_recv_chain(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
> - uint flags, struct sk_buff_head *pktq);
> +int brcmf_sdcard_send_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
> + uint flags, struct sk_buff_head *pktq);
> +int brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
> + uint flags, u8 *buf, uint nbytes);
> +
> +int brcmf_sdcard_recv_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
> + uint flags, struct sk_buff *pkt);
> +int brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
> + uint flags, u8 *buf, uint nbytes);
> +int brcmf_sdcard_recv_chain(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
> + uint flags, struct sk_buff_head *pktq);
>
> /* Flags bits */
>
> @@ -237,46 +232,43 @@ brcmf_sdcard_recv_chain(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
> * nbytes: number of bytes to transfer to/from buf
> * Returns 0 or error code.
> */
> -extern int brcmf_sdcard_rwdata(struct brcmf_sdio_dev *sdiodev, uint rw,
> - u32 addr, u8 *buf, uint nbytes);
> -extern int brcmf_sdio_ramrw(struct brcmf_sdio_dev *sdiodev, bool write,
> - u32 address, u8 *data, uint size);
> +int brcmf_sdcard_rwdata(struct brcmf_sdio_dev *sdiodev, uint rw, u32 addr,
> + u8 *buf, uint nbytes);
> +int brcmf_sdio_ramrw(struct brcmf_sdio_dev *sdiodev, bool write, u32 address,
> + u8 *data, uint size);
>
> /* Issue an abort to the specified function */
> -extern int brcmf_sdcard_abort(struct brcmf_sdio_dev *sdiodev, uint fn);
> +int brcmf_sdcard_abort(struct brcmf_sdio_dev *sdiodev, uint fn);
>
> /* platform specific/high level functions */
> -extern int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev);
> -extern int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev);
> +int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev);
> +int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev);
>
> /* attach, return handler on success, NULL if failed.
> * The handler shall be provided by all subsequent calls. No local cache
> * cfghdl points to the starting address of pci device mapped memory
> */
> -extern int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev);
> -extern void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev);
> +int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev);
> +void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev);
>
> /* read or write one byte using cmd52 */
> -extern int brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw,
> - uint fnc, uint addr, u8 *byte);
> +int brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint fnc,
> + uint addr, u8 *byte);
>
> /* read or write 2/4 bytes using cmd53 */
> -extern int
> -brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev,
> - uint rw, uint fnc, uint addr,
> - u32 *word, uint nbyte);
> +int brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint rw, uint fnc,
> + uint addr, u32 *word, uint nbyte);
>
> /* Watchdog timer interface for pm ops */
> -extern void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev,
> - bool enable);
> +void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev, bool enable);
>
> -extern void *brcmf_sdbrcm_probe(u32 regsva, struct brcmf_sdio_dev *sdiodev);
> -extern void brcmf_sdbrcm_disconnect(void *ptr);
> -extern void brcmf_sdbrcm_isr(void *arg);
> +void *brcmf_sdbrcm_probe(u32 regsva, struct brcmf_sdio_dev *sdiodev);
> +void brcmf_sdbrcm_disconnect(void *ptr);
> +void brcmf_sdbrcm_isr(void *arg);
>
> -extern void brcmf_sdbrcm_wd_timer(struct brcmf_sdio *bus, uint wdtick);
> +void brcmf_sdbrcm_wd_timer(struct brcmf_sdio *bus, uint wdtick);
>
> -extern void brcmf_pm_resume_wait(struct brcmf_sdio_dev *sdiodev,
> - wait_queue_head_t *wq);
> -extern bool brcmf_pm_resume_error(struct brcmf_sdio_dev *sdiodev);
> +void brcmf_pm_resume_wait(struct brcmf_sdio_dev *sdiodev,
> + wait_queue_head_t *wq);
> +bool brcmf_pm_resume_error(struct brcmf_sdio_dev *sdiodev);
> #endif /* _BRCM_SDH_H_ */
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
> index a8a267b..2d08c15 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
> @@ -172,19 +172,19 @@ struct si_info {
>
>
> /* AMBA Interconnect exported externs */
> -extern u32 ai_core_cflags(struct bcma_device *core, u32 mask, u32 val);
> +u32 ai_core_cflags(struct bcma_device *core, u32 mask, u32 val);
>
> /* === exported functions === */
> -extern struct si_pub *ai_attach(struct bcma_bus *pbus);
> -extern void ai_detach(struct si_pub *sih);
> -extern uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val);
> -extern void ai_clkctl_init(struct si_pub *sih);
> -extern u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih);
> -extern bool ai_clkctl_cc(struct si_pub *sih, enum bcma_clkmode mode);
> -extern bool ai_deviceremoved(struct si_pub *sih);
> +struct si_pub *ai_attach(struct bcma_bus *pbus);
> +void ai_detach(struct si_pub *sih);
> +uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val);
> +void ai_clkctl_init(struct si_pub *sih);
> +u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih);
> +bool ai_clkctl_cc(struct si_pub *sih, enum bcma_clkmode mode);
> +bool ai_deviceremoved(struct si_pub *sih);
>
> /* Enable Ex-PA for 4313 */
> -extern void ai_epa_4313war(struct si_pub *sih);
> +void ai_epa_4313war(struct si_pub *sih);
>
> static inline u32 ai_get_cccaps(struct si_pub *sih)
> {
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.h b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.h
> index 73d01e5..03bdcf2 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.h
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.h
> @@ -37,17 +37,17 @@ struct brcms_ampdu_session {
> u16 dma_len;
> };
>
> -extern void brcms_c_ampdu_reset_session(struct brcms_ampdu_session *session,
> - struct brcms_c_info *wlc);
> -extern int brcms_c_ampdu_add_frame(struct brcms_ampdu_session *session,
> - struct sk_buff *p);
> -extern void brcms_c_ampdu_finalize(struct brcms_ampdu_session *session);
> +void brcms_c_ampdu_reset_session(struct brcms_ampdu_session *session,
> + struct brcms_c_info *wlc);
> +int brcms_c_ampdu_add_frame(struct brcms_ampdu_session *session,
> + struct sk_buff *p);
> +void brcms_c_ampdu_finalize(struct brcms_ampdu_session *session);
>
> -extern struct ampdu_info *brcms_c_ampdu_attach(struct brcms_c_info *wlc);
> -extern void brcms_c_ampdu_detach(struct ampdu_info *ampdu);
> -extern void brcms_c_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb,
> - struct sk_buff *p, struct tx_status *txs);
> -extern void brcms_c_ampdu_macaddr_upd(struct brcms_c_info *wlc);
> -extern void brcms_c_ampdu_shm_upd(struct ampdu_info *ampdu);
> +struct ampdu_info *brcms_c_ampdu_attach(struct brcms_c_info *wlc);
> +void brcms_c_ampdu_detach(struct ampdu_info *ampdu);
> +void brcms_c_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb,
> + struct sk_buff *p, struct tx_status *txs);
> +void brcms_c_ampdu_macaddr_upd(struct brcms_c_info *wlc);
> +void brcms_c_ampdu_shm_upd(struct ampdu_info *ampdu);
>
> #endif /* _BRCM_AMPDU_H_ */
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/antsel.h b/drivers/net/wireless/brcm80211/brcmsmac/antsel.h
> index 97ea388..a3d487a 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/antsel.h
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/antsel.h
> @@ -17,13 +17,11 @@
> #ifndef _BRCM_ANTSEL_H_
> #define _BRCM_ANTSEL_H_
>
> -extern struct antsel_info *brcms_c_antsel_attach(struct brcms_c_info *wlc);
> -extern void brcms_c_antsel_detach(struct antsel_info *asi);
> -extern void brcms_c_antsel_init(struct antsel_info *asi);
> -extern void brcms_c_antsel_antcfg_get(struct antsel_info *asi, bool usedef,
> - bool sel,
> - u8 id, u8 fbid, u8 *antcfg,
> - u8 *fbantcfg);
> -extern u8 brcms_c_antsel_antsel2id(struct antsel_info *asi, u16 antsel);
> +struct antsel_info *brcms_c_antsel_attach(struct brcms_c_info *wlc);
> +void brcms_c_antsel_detach(struct antsel_info *asi);
> +void brcms_c_antsel_init(struct antsel_info *asi);
> +void brcms_c_antsel_antcfg_get(struct antsel_info *asi, bool usedef, bool sel,
> + u8 id, u8 fbid, u8 *antcfg, u8 *fbantcfg);
> +u8 brcms_c_antsel_antsel2id(struct antsel_info *asi, u16 antsel);
>
> #endif /* _BRCM_ANTSEL_H_ */
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/channel.h b/drivers/net/wireless/brcm80211/brcmsmac/channel.h
> index 006483a..39dd3a5 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/channel.h
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/channel.h
> @@ -32,20 +32,16 @@
>
> #define BRCMS_DFS_EU (BRCMS_DFS_TPC | BRCMS_RADAR_TYPE_EU) /* Flag for DFS EU */
>
> -extern struct brcms_cm_info *
> -brcms_c_channel_mgr_attach(struct brcms_c_info *wlc);
> +struct brcms_cm_info *brcms_c_channel_mgr_attach(struct brcms_c_info *wlc);
>
> -extern void brcms_c_channel_mgr_detach(struct brcms_cm_info *wlc_cm);
> +void brcms_c_channel_mgr_detach(struct brcms_cm_info *wlc_cm);
>
> -extern bool brcms_c_valid_chanspec_db(struct brcms_cm_info *wlc_cm,
> - u16 chspec);
> +bool brcms_c_valid_chanspec_db(struct brcms_cm_info *wlc_cm, u16 chspec);
>
> -extern void brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm,
> - u16 chanspec,
> - struct txpwr_limits *txpwr);
> -extern void brcms_c_channel_set_chanspec(struct brcms_cm_info *wlc_cm,
> - u16 chanspec,
> - u8 local_constraint_qdbm);
> -extern void brcms_c_regd_init(struct brcms_c_info *wlc);
> +void brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec,
> + struct txpwr_limits *txpwr);
> +void brcms_c_channel_set_chanspec(struct brcms_cm_info *wlc_cm, u16 chanspec,
> + u8 local_constraint_qdbm);
> +void brcms_c_regd_init(struct brcms_c_info *wlc);
>
> #endif /* _WLC_CHANNEL_H */
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h
> index 4090032..198053d 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h
> @@ -88,26 +88,26 @@ struct brcms_info {
> };
>
> /* misc callbacks */
> -extern void brcms_init(struct brcms_info *wl);
> -extern uint brcms_reset(struct brcms_info *wl);
> -extern void brcms_intrson(struct brcms_info *wl);
> -extern u32 brcms_intrsoff(struct brcms_info *wl);
> -extern void brcms_intrsrestore(struct brcms_info *wl, u32 macintmask);
> -extern int brcms_up(struct brcms_info *wl);
> -extern void brcms_down(struct brcms_info *wl);
> -extern void brcms_txflowcontrol(struct brcms_info *wl, struct brcms_if *wlif,
> - bool state, int prio);
> -extern bool brcms_rfkill_set_hw_state(struct brcms_info *wl);
> +void brcms_init(struct brcms_info *wl);
> +uint brcms_reset(struct brcms_info *wl);
> +void brcms_intrson(struct brcms_info *wl);
> +u32 brcms_intrsoff(struct brcms_info *wl);
> +void brcms_intrsrestore(struct brcms_info *wl, u32 macintmask);
> +int brcms_up(struct brcms_info *wl);
> +void brcms_down(struct brcms_info *wl);
> +void brcms_txflowcontrol(struct brcms_info *wl, struct brcms_if *wlif,
> + bool state, int prio);
> +bool brcms_rfkill_set_hw_state(struct brcms_info *wl);
>
> /* timer functions */
> -extern struct brcms_timer *brcms_init_timer(struct brcms_info *wl,
> - void (*fn) (void *arg), void *arg,
> - const char *name);
> -extern void brcms_free_timer(struct brcms_timer *timer);
> -extern void brcms_add_timer(struct brcms_timer *timer, uint ms, int periodic);
> -extern bool brcms_del_timer(struct brcms_timer *timer);
> -extern void brcms_dpc(unsigned long data);
> -extern void brcms_timer(struct brcms_timer *t);
> -extern void brcms_fatal_error(struct brcms_info *wl);
> +struct brcms_timer *brcms_init_timer(struct brcms_info *wl,
> + void (*fn) (void *arg), void *arg,
> + const char *name);
> +void brcms_free_timer(struct brcms_timer *timer);
> +void brcms_add_timer(struct brcms_timer *timer, uint ms, int periodic);
> +bool brcms_del_timer(struct brcms_timer *timer);
> +void brcms_dpc(unsigned long data);
> +void brcms_timer(struct brcms_timer *t);
> +void brcms_fatal_error(struct brcms_info *wl);
>
> #endif /* _BRCM_MAC80211_IF_H_ */
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.h b/drivers/net/wireless/brcm80211/brcmsmac/main.h
> index b5d7a38..c4d135c 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
> @@ -616,66 +616,54 @@ struct brcms_bss_cfg {
> struct brcms_bss_info *current_bss;
> };
>
> -extern int brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo,
> - struct sk_buff *p);
> -extern int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo,
> - uint *blocks);
> -
> -extern int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config);
> -extern void brcms_c_mac_promisc(struct brcms_c_info *wlc, uint filter_flags);
> -extern u16 brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec,
> - uint mac_len);
> -extern u32 brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc,
> - u32 rspec,
> - bool use_rspec, u16 mimo_ctlchbw);
> -extern u16 brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only,
> - u32 rts_rate,
> - u32 frame_rate,
> - u8 rts_preamble_type,
> - u8 frame_preamble_type, uint frame_len,
> - bool ba);
> -extern void brcms_c_inval_dma_pkts(struct brcms_hardware *hw,
> - struct ieee80211_sta *sta,
> - void (*dma_callback_fn));
> -extern void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend);
> -extern int brcms_c_set_nmode(struct brcms_c_info *wlc);
> -extern void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc,
> - u32 bcn_rate);
> -extern void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw,
> - u8 antsel_type);
> -extern void brcms_b_set_chanspec(struct brcms_hardware *wlc_hw,
> - u16 chanspec,
> - bool mute, struct txpwr_limits *txpwr);
> -extern void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset,
> - u16 v);
> -extern u16 brcms_b_read_shm(struct brcms_hardware *wlc_hw, uint offset);
> -extern void brcms_b_mhf(struct brcms_hardware *wlc_hw, u8 idx, u16 mask,
> - u16 val, int bands);
> -extern void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags);
> -extern void brcms_b_mctrl(struct brcms_hardware *wlc_hw, u32 mask, u32 val);
> -extern void brcms_b_phy_reset(struct brcms_hardware *wlc_hw);
> -extern void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw);
> -extern void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw);
> -extern void brcms_c_ucode_wake_override_set(struct brcms_hardware *wlc_hw,
> - u32 override_bit);
> -extern void brcms_c_ucode_wake_override_clear(struct brcms_hardware *wlc_hw,
> - u32 override_bit);
> -extern void brcms_b_write_template_ram(struct brcms_hardware *wlc_hw,
> - int offset, int len, void *buf);
> -extern u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate);
> -extern void brcms_b_copyto_objmem(struct brcms_hardware *wlc_hw,
> - uint offset, const void *buf, int len,
> - u32 sel);
> -extern void brcms_b_copyfrom_objmem(struct brcms_hardware *wlc_hw, uint offset,
> - void *buf, int len, u32 sel);
> -extern void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode);
> -extern u16 brcms_b_get_txant(struct brcms_hardware *wlc_hw);
> -extern void brcms_b_phyclk_fgc(struct brcms_hardware *wlc_hw, bool clk);
> -extern void brcms_b_macphyclk_set(struct brcms_hardware *wlc_hw, bool clk);
> -extern void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on);
> -extern void brcms_b_txant_set(struct brcms_hardware *wlc_hw, u16 phytxant);
> -extern void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw,
> - u8 stf_mode);
> -extern void brcms_c_init_scb(struct scb *scb);
> +int brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p);
> +int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo,
> + uint *blocks);
> +
> +int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config);
> +void brcms_c_mac_promisc(struct brcms_c_info *wlc, uint filter_flags);
> +u16 brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec, uint mac_len);
> +u32 brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec,
> + bool use_rspec, u16 mimo_ctlchbw);
> +u16 brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only,
> + u32 rts_rate, u32 frame_rate,
> + u8 rts_preamble_type, u8 frame_preamble_type,
> + uint frame_len, bool ba);
> +void brcms_c_inval_dma_pkts(struct brcms_hardware *hw,
> + struct ieee80211_sta *sta, void (*dma_callback_fn));
> +void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend);
> +int brcms_c_set_nmode(struct brcms_c_info *wlc);
> +void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc, u32 bcn_rate);
> +void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw, u8 antsel_type);
> +void brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec,
> + bool mute, struct txpwr_limits *txpwr);
> +void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset, u16 v);
> +u16 brcms_b_read_shm(struct brcms_hardware *wlc_hw, uint offset);
> +void brcms_b_mhf(struct brcms_hardware *wlc_hw, u8 idx, u16 mask, u16 val,
> + int bands);
> +void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags);
> +void brcms_b_mctrl(struct brcms_hardware *wlc_hw, u32 mask, u32 val);
> +void brcms_b_phy_reset(struct brcms_hardware *wlc_hw);
> +void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw);
> +void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw);
> +void brcms_c_ucode_wake_override_set(struct brcms_hardware *wlc_hw,
> + u32 override_bit);
> +void brcms_c_ucode_wake_override_clear(struct brcms_hardware *wlc_hw,
> + u32 override_bit);
> +void brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, int offset,
> + int len, void *buf);
> +u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate);
> +void brcms_b_copyto_objmem(struct brcms_hardware *wlc_hw, uint offset,
> + const void *buf, int len, u32 sel);
> +void brcms_b_copyfrom_objmem(struct brcms_hardware *wlc_hw, uint offset,
> + void *buf, int len, u32 sel);
> +void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode);
> +u16 brcms_b_get_txant(struct brcms_hardware *wlc_hw);
> +void brcms_b_phyclk_fgc(struct brcms_hardware *wlc_hw, bool clk);
> +void brcms_b_macphyclk_set(struct brcms_hardware *wlc_hw, bool clk);
> +void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on);
> +void brcms_b_txant_set(struct brcms_hardware *wlc_hw, u16 phytxant);
> +void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw, u8 stf_mode);
> +void brcms_c_init_scb(struct scb *scb);
>
> #endif /* _BRCM_MAIN_H_ */
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_hal.h b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_hal.h
> index e34a71e..4d3734f 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_hal.h
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_hal.h
> @@ -179,121 +179,106 @@ struct shared_phy_params {
> };
>
>
> -extern struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp);
> -extern struct brcms_phy_pub *wlc_phy_attach(struct shared_phy *sh,
> - struct bcma_device *d11core,
> - int bandtype, struct wiphy *wiphy);
> -extern void wlc_phy_detach(struct brcms_phy_pub *ppi);
> -
> -extern bool wlc_phy_get_phyversion(struct brcms_phy_pub *pih, u16 *phytype,
> - u16 *phyrev, u16 *radioid,
> - u16 *radiover);
> -extern bool wlc_phy_get_encore(struct brcms_phy_pub *pih);
> -extern u32 wlc_phy_get_coreflags(struct brcms_phy_pub *pih);
> -
> -extern void wlc_phy_hw_clk_state_upd(struct brcms_phy_pub *ppi, bool newstate);
> -extern void wlc_phy_hw_state_upd(struct brcms_phy_pub *ppi, bool newstate);
> -extern void wlc_phy_init(struct brcms_phy_pub *ppi, u16 chanspec);
> -extern void wlc_phy_watchdog(struct brcms_phy_pub *ppi);
> -extern int wlc_phy_down(struct brcms_phy_pub *ppi);
> -extern u32 wlc_phy_clk_bwbits(struct brcms_phy_pub *pih);
> -extern void wlc_phy_cal_init(struct brcms_phy_pub *ppi);
> -extern void wlc_phy_antsel_init(struct brcms_phy_pub *ppi, bool lut_init);
> -
> -extern void wlc_phy_chanspec_set(struct brcms_phy_pub *ppi,
> - u16 chanspec);
> -extern u16 wlc_phy_chanspec_get(struct brcms_phy_pub *ppi);
> -extern void wlc_phy_chanspec_radio_set(struct brcms_phy_pub *ppi,
> - u16 newch);
> -extern u16 wlc_phy_bw_state_get(struct brcms_phy_pub *ppi);
> -extern void wlc_phy_bw_state_set(struct brcms_phy_pub *ppi, u16 bw);
> -
> -extern int wlc_phy_rssi_compute(struct brcms_phy_pub *pih,
> - struct d11rxhdr *rxh);
> -extern void wlc_phy_por_inform(struct brcms_phy_pub *ppi);
> -extern void wlc_phy_noise_sample_intr(struct brcms_phy_pub *ppi);
> -extern bool wlc_phy_bist_check_phy(struct brcms_phy_pub *ppi);
> -
> -extern void wlc_phy_set_deaf(struct brcms_phy_pub *ppi, bool user_flag);
> -
> -extern void wlc_phy_switch_radio(struct brcms_phy_pub *ppi, bool on);
> -extern void wlc_phy_anacore(struct brcms_phy_pub *ppi, bool on);
> -
> -
> -extern void wlc_phy_BSSinit(struct brcms_phy_pub *ppi, bool bonlyap, int rssi);
> -
> -extern void wlc_phy_chanspec_ch14_widefilter_set(struct brcms_phy_pub *ppi,
> - bool wide_filter);
> -extern void wlc_phy_chanspec_band_validch(struct brcms_phy_pub *ppi, uint band,
> - struct brcms_chanvec *channels);
> -extern u16 wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi,
> - uint band);
> -
> -extern void wlc_phy_txpower_sromlimit(struct brcms_phy_pub *ppi, uint chan,
> - u8 *_min_, u8 *_max_, int rate);
> -extern void wlc_phy_txpower_sromlimit_max_get(struct brcms_phy_pub *ppi,
> - uint chan, u8 *_max_, u8 *_min_);
> -extern void wlc_phy_txpower_boardlimit_band(struct brcms_phy_pub *ppi,
> - uint band, s32 *, s32 *, u32 *);
> -extern void wlc_phy_txpower_limit_set(struct brcms_phy_pub *ppi,
> - struct txpwr_limits *,
> - u16 chanspec);
> -extern int wlc_phy_txpower_get(struct brcms_phy_pub *ppi, uint *qdbm,
> - bool *override);
> -extern int wlc_phy_txpower_set(struct brcms_phy_pub *ppi, uint qdbm,
> - bool override);
> -extern void wlc_phy_txpower_target_set(struct brcms_phy_pub *ppi,
> - struct txpwr_limits *);
> -extern bool wlc_phy_txpower_hw_ctrl_get(struct brcms_phy_pub *ppi);
> -extern void wlc_phy_txpower_hw_ctrl_set(struct brcms_phy_pub *ppi,
> - bool hwpwrctrl);
> -extern u8 wlc_phy_txpower_get_target_min(struct brcms_phy_pub *ppi);
> -extern u8 wlc_phy_txpower_get_target_max(struct brcms_phy_pub *ppi);
> -extern bool wlc_phy_txpower_ipa_ison(struct brcms_phy_pub *pih);
> -
> -extern void wlc_phy_stf_chain_init(struct brcms_phy_pub *pih, u8 txchain,
> - u8 rxchain);
> -extern void wlc_phy_stf_chain_set(struct brcms_phy_pub *pih, u8 txchain,
> - u8 rxchain);
> -extern void wlc_phy_stf_chain_get(struct brcms_phy_pub *pih, u8 *txchain,
> - u8 *rxchain);
> -extern u8 wlc_phy_stf_chain_active_get(struct brcms_phy_pub *pih);
> -extern s8 wlc_phy_stf_ssmode_get(struct brcms_phy_pub *pih,
> - u16 chanspec);
> -extern void wlc_phy_ldpc_override_set(struct brcms_phy_pub *ppi, bool val);
> -
> -extern void wlc_phy_cal_perical(struct brcms_phy_pub *ppi, u8 reason);
> -extern void wlc_phy_noise_sample_request_external(struct brcms_phy_pub *ppi);
> -extern void wlc_phy_edcrs_lock(struct brcms_phy_pub *pih, bool lock);
> -extern void wlc_phy_cal_papd_recal(struct brcms_phy_pub *ppi);
> -
> -extern void wlc_phy_ant_rxdiv_set(struct brcms_phy_pub *ppi, u8 val);
> -extern void wlc_phy_clear_tssi(struct brcms_phy_pub *ppi);
> -extern void wlc_phy_hold_upd(struct brcms_phy_pub *ppi, u32 id, bool val);
> -extern void wlc_phy_mute_upd(struct brcms_phy_pub *ppi, bool val, u32 flags);
> -
> -extern void wlc_phy_antsel_type_set(struct brcms_phy_pub *ppi, u8 antsel_type);
> -
> -extern void wlc_phy_txpower_get_current(struct brcms_phy_pub *ppi,
> - struct tx_power *power, uint channel);
> -
> -extern void wlc_phy_initcal_enable(struct brcms_phy_pub *pih, bool initcal);
> -extern bool wlc_phy_test_ison(struct brcms_phy_pub *ppi);
> -extern void wlc_phy_txpwr_percent_set(struct brcms_phy_pub *ppi,
> - u8 txpwr_percent);
> -extern void wlc_phy_ofdm_rateset_war(struct brcms_phy_pub *pih, bool war);
> -extern void wlc_phy_bf_preempt_enable(struct brcms_phy_pub *pih,
> - bool bf_preempt);
> -extern void wlc_phy_machwcap_set(struct brcms_phy_pub *ppi, u32 machwcap);
> -
> -extern void wlc_phy_runbist_config(struct brcms_phy_pub *ppi, bool start_end);
> -
> -extern void wlc_phy_freqtrack_start(struct brcms_phy_pub *ppi);
> -extern void wlc_phy_freqtrack_end(struct brcms_phy_pub *ppi);
> -
> -extern const u8 *wlc_phy_get_ofdm_rate_lookup(void);
> -
> -extern s8 wlc_phy_get_tx_power_offset_by_mcs(struct brcms_phy_pub *ppi,
> - u8 mcs_offset);
> -extern s8 wlc_phy_get_tx_power_offset(struct brcms_phy_pub *ppi, u8 tbl_offset);
> +struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp);
> +struct brcms_phy_pub *wlc_phy_attach(struct shared_phy *sh,
> + struct bcma_device *d11core, int bandtype,
> + struct wiphy *wiphy);
> +void wlc_phy_detach(struct brcms_phy_pub *ppi);
> +
> +bool wlc_phy_get_phyversion(struct brcms_phy_pub *pih, u16 *phytype,
> + u16 *phyrev, u16 *radioid, u16 *radiover);
> +bool wlc_phy_get_encore(struct brcms_phy_pub *pih);
> +u32 wlc_phy_get_coreflags(struct brcms_phy_pub *pih);
> +
> +void wlc_phy_hw_clk_state_upd(struct brcms_phy_pub *ppi, bool newstate);
> +void wlc_phy_hw_state_upd(struct brcms_phy_pub *ppi, bool newstate);
> +void wlc_phy_init(struct brcms_phy_pub *ppi, u16 chanspec);
> +void wlc_phy_watchdog(struct brcms_phy_pub *ppi);
> +int wlc_phy_down(struct brcms_phy_pub *ppi);
> +u32 wlc_phy_clk_bwbits(struct brcms_phy_pub *pih);
> +void wlc_phy_cal_init(struct brcms_phy_pub *ppi);
> +void wlc_phy_antsel_init(struct brcms_phy_pub *ppi, bool lut_init);
> +
> +void wlc_phy_chanspec_set(struct brcms_phy_pub *ppi, u16 chanspec);
> +u16 wlc_phy_chanspec_get(struct brcms_phy_pub *ppi);
> +void wlc_phy_chanspec_radio_set(struct brcms_phy_pub *ppi, u16 newch);
> +u16 wlc_phy_bw_state_get(struct brcms_phy_pub *ppi);
> +void wlc_phy_bw_state_set(struct brcms_phy_pub *ppi, u16 bw);
> +
> +int wlc_phy_rssi_compute(struct brcms_phy_pub *pih, struct d11rxhdr *rxh);
> +void wlc_phy_por_inform(struct brcms_phy_pub *ppi);
> +void wlc_phy_noise_sample_intr(struct brcms_phy_pub *ppi);
> +bool wlc_phy_bist_check_phy(struct brcms_phy_pub *ppi);
> +
> +void wlc_phy_set_deaf(struct brcms_phy_pub *ppi, bool user_flag);
> +
> +void wlc_phy_switch_radio(struct brcms_phy_pub *ppi, bool on);
> +void wlc_phy_anacore(struct brcms_phy_pub *ppi, bool on);
> +
> +
> +void wlc_phy_BSSinit(struct brcms_phy_pub *ppi, bool bonlyap, int rssi);
> +
> +void wlc_phy_chanspec_ch14_widefilter_set(struct brcms_phy_pub *ppi,
> + bool wide_filter);
> +void wlc_phy_chanspec_band_validch(struct brcms_phy_pub *ppi, uint band,
> + struct brcms_chanvec *channels);
> +u16 wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi, uint band);
> +
> +void wlc_phy_txpower_sromlimit(struct brcms_phy_pub *ppi, uint chan, u8 *_min_,
> + u8 *_max_, int rate);
> +void wlc_phy_txpower_sromlimit_max_get(struct brcms_phy_pub *ppi, uint chan,
> + u8 *_max_, u8 *_min_);
> +void wlc_phy_txpower_boardlimit_band(struct brcms_phy_pub *ppi, uint band,
> + s32 *, s32 *, u32 *);
> +void wlc_phy_txpower_limit_set(struct brcms_phy_pub *ppi, struct txpwr_limits *,
> + u16 chanspec);
> +int wlc_phy_txpower_get(struct brcms_phy_pub *ppi, uint *qdbm, bool *override);
> +int wlc_phy_txpower_set(struct brcms_phy_pub *ppi, uint qdbm, bool override);
> +void wlc_phy_txpower_target_set(struct brcms_phy_pub *ppi,
> + struct txpwr_limits *);
> +bool wlc_phy_txpower_hw_ctrl_get(struct brcms_phy_pub *ppi);
> +void wlc_phy_txpower_hw_ctrl_set(struct brcms_phy_pub *ppi, bool hwpwrctrl);
> +u8 wlc_phy_txpower_get_target_min(struct brcms_phy_pub *ppi);
> +u8 wlc_phy_txpower_get_target_max(struct brcms_phy_pub *ppi);
> +bool wlc_phy_txpower_ipa_ison(struct brcms_phy_pub *pih);
> +
> +void wlc_phy_stf_chain_init(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain);
> +void wlc_phy_stf_chain_set(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain);
> +void wlc_phy_stf_chain_get(struct brcms_phy_pub *pih, u8 *txchain, u8 *rxchain);
> +u8 wlc_phy_stf_chain_active_get(struct brcms_phy_pub *pih);
> +s8 wlc_phy_stf_ssmode_get(struct brcms_phy_pub *pih, u16 chanspec);
> +void wlc_phy_ldpc_override_set(struct brcms_phy_pub *ppi, bool val);
> +
> +void wlc_phy_cal_perical(struct brcms_phy_pub *ppi, u8 reason);
> +void wlc_phy_noise_sample_request_external(struct brcms_phy_pub *ppi);
> +void wlc_phy_edcrs_lock(struct brcms_phy_pub *pih, bool lock);
> +void wlc_phy_cal_papd_recal(struct brcms_phy_pub *ppi);
> +
> +void wlc_phy_ant_rxdiv_set(struct brcms_phy_pub *ppi, u8 val);
> +void wlc_phy_clear_tssi(struct brcms_phy_pub *ppi);
> +void wlc_phy_hold_upd(struct brcms_phy_pub *ppi, u32 id, bool val);
> +void wlc_phy_mute_upd(struct brcms_phy_pub *ppi, bool val, u32 flags);
> +
> +void wlc_phy_antsel_type_set(struct brcms_phy_pub *ppi, u8 antsel_type);
> +
> +void wlc_phy_txpower_get_current(struct brcms_phy_pub *ppi,
> + struct tx_power *power, uint channel);
> +
> +void wlc_phy_initcal_enable(struct brcms_phy_pub *pih, bool initcal);
> +bool wlc_phy_test_ison(struct brcms_phy_pub *ppi);
> +void wlc_phy_txpwr_percent_set(struct brcms_phy_pub *ppi, u8 txpwr_percent);
> +void wlc_phy_ofdm_rateset_war(struct brcms_phy_pub *pih, bool war);
> +void wlc_phy_bf_preempt_enable(struct brcms_phy_pub *pih, bool bf_preempt);
> +void wlc_phy_machwcap_set(struct brcms_phy_pub *ppi, u32 machwcap);
> +
> +void wlc_phy_runbist_config(struct brcms_phy_pub *ppi, bool start_end);
> +
> +void wlc_phy_freqtrack_start(struct brcms_phy_pub *ppi);
> +void wlc_phy_freqtrack_end(struct brcms_phy_pub *ppi);
> +
> +const u8 *wlc_phy_get_ofdm_rate_lookup(void);
> +
> +s8 wlc_phy_get_tx_power_offset_by_mcs(struct brcms_phy_pub *ppi,
> + u8 mcs_offset);
> +s8 wlc_phy_get_tx_power_offset(struct brcms_phy_pub *ppi, u8 tbl_offset);
> #endif /* _BRCM_PHY_HAL_H_ */
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h
> index 1dc767c..4960f7d 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h
> @@ -910,113 +910,103 @@ struct lcnphy_radio_regs {
> u8 do_init_g;
> };
>
> -extern u16 read_phy_reg(struct brcms_phy *pi, u16 addr);
> -extern void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
> -extern void and_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
> -extern void or_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
> -extern void mod_phy_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val);
> -
> -extern u16 read_radio_reg(struct brcms_phy *pi, u16 addr);
> -extern void or_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);
> -extern void and_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);
> -extern void mod_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask,
> - u16 val);
> -extern void xor_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask);
> -
> -extern void write_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);
> -
> -extern void wlc_phyreg_enter(struct brcms_phy_pub *pih);
> -extern void wlc_phyreg_exit(struct brcms_phy_pub *pih);
> -extern void wlc_radioreg_enter(struct brcms_phy_pub *pih);
> -extern void wlc_radioreg_exit(struct brcms_phy_pub *pih);
> -
> -extern void wlc_phy_read_table(struct brcms_phy *pi,
> - const struct phytbl_info *ptbl_info,
> - u16 tblAddr, u16 tblDataHi,
> - u16 tblDatalo);
> -extern void wlc_phy_write_table(struct brcms_phy *pi,
> - const struct phytbl_info *ptbl_info,
> - u16 tblAddr, u16 tblDataHi, u16 tblDatalo);
> -extern void wlc_phy_table_addr(struct brcms_phy *pi, uint tbl_id,
> - uint tbl_offset, u16 tblAddr, u16 tblDataHi,
> - u16 tblDataLo);
> -extern void wlc_phy_table_data_write(struct brcms_phy *pi, uint width, u32 val);
> -
> -extern void write_phy_channel_reg(struct brcms_phy *pi, uint val);
> -extern void wlc_phy_txpower_update_shm(struct brcms_phy *pi);
> -
> -extern u8 wlc_phy_nbits(s32 value);
> -extern void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_dB, u8 core);
> -
> -extern uint wlc_phy_init_radio_regs_allbands(struct brcms_phy *pi,
> - struct radio_20xx_regs *radioregs);
> -extern uint wlc_phy_init_radio_regs(struct brcms_phy *pi,
> - const struct radio_regs *radioregs,
> - u16 core_offset);
> -
> -extern void wlc_phy_txpower_ipa_upd(struct brcms_phy *pi);
> -
> -extern void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on);
> -extern void wlc_phy_papd_decode_epsilon(u32 epsilon, s32 *eps_real,
> - s32 *eps_imag);
> -
> -extern void wlc_phy_cal_perical_mphase_reset(struct brcms_phy *pi);
> -extern void wlc_phy_cal_perical_mphase_restart(struct brcms_phy *pi);
> -
> -extern bool wlc_phy_attach_nphy(struct brcms_phy *pi);
> -extern bool wlc_phy_attach_lcnphy(struct brcms_phy *pi);
> -
> -extern void wlc_phy_detach_lcnphy(struct brcms_phy *pi);
> -
> -extern void wlc_phy_init_nphy(struct brcms_phy *pi);
> -extern void wlc_phy_init_lcnphy(struct brcms_phy *pi);
> -
> -extern void wlc_phy_cal_init_nphy(struct brcms_phy *pi);
> -extern void wlc_phy_cal_init_lcnphy(struct brcms_phy *pi);
> -
> -extern void wlc_phy_chanspec_set_nphy(struct brcms_phy *pi,
> - u16 chanspec);
> -extern void wlc_phy_chanspec_set_lcnphy(struct brcms_phy *pi,
> - u16 chanspec);
> -extern void wlc_phy_chanspec_set_fixup_lcnphy(struct brcms_phy *pi,
> - u16 chanspec);
> -extern int wlc_phy_channel2freq(uint channel);
> -extern int wlc_phy_chanspec_freq2bandrange_lpssn(uint);
> -extern int wlc_phy_chanspec_bandrange_get(struct brcms_phy *, u16 chanspec);
> -
> -extern void wlc_lcnphy_set_tx_pwr_ctrl(struct brcms_phy *pi, u16 mode);
> -extern s8 wlc_lcnphy_get_current_tx_pwr_idx(struct brcms_phy *pi);
> -
> -extern void wlc_phy_txpower_recalc_target_nphy(struct brcms_phy *pi);
> -extern void wlc_lcnphy_txpower_recalc_target(struct brcms_phy *pi);
> -extern void wlc_phy_txpower_recalc_target_lcnphy(struct brcms_phy *pi);
> -
> -extern void wlc_lcnphy_set_tx_pwr_by_index(struct brcms_phy *pi, int index);
> -extern void wlc_lcnphy_tx_pu(struct brcms_phy *pi, bool bEnable);
> -extern void wlc_lcnphy_stop_tx_tone(struct brcms_phy *pi);
> -extern void wlc_lcnphy_start_tx_tone(struct brcms_phy *pi, s32 f_kHz,
> - u16 max_val, bool iqcalmode);
> -
> -extern void wlc_phy_txpower_sromlimit_get_nphy(struct brcms_phy *pi, uint chan,
> - u8 *max_pwr, u8 rate_id);
> -extern void wlc_phy_ofdm_to_mcs_powers_nphy(u8 *power, u8 rate_mcs_start,
> - u8 rate_mcs_end,
> - u8 rate_ofdm_start);
> -extern void wlc_phy_mcs_to_ofdm_powers_nphy(u8 *power,
> - u8 rate_ofdm_start,
> - u8 rate_ofdm_end,
> - u8 rate_mcs_start);
> -
> -extern u16 wlc_lcnphy_tempsense(struct brcms_phy *pi, bool mode);
> -extern s16 wlc_lcnphy_tempsense_new(struct brcms_phy *pi, bool mode);
> -extern s8 wlc_lcnphy_tempsense_degree(struct brcms_phy *pi, bool mode);
> -extern s8 wlc_lcnphy_vbatsense(struct brcms_phy *pi, bool mode);
> -extern void wlc_phy_carrier_suppress_lcnphy(struct brcms_phy *pi);
> -extern void wlc_lcnphy_crsuprs(struct brcms_phy *pi, int channel);
> -extern void wlc_lcnphy_epa_switch(struct brcms_phy *pi, bool mode);
> -extern void wlc_2064_vco_cal(struct brcms_phy *pi);
> -
> -extern void wlc_phy_txpower_recalc_target(struct brcms_phy *pi);
> +u16 read_phy_reg(struct brcms_phy *pi, u16 addr);
> +void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
> +void and_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
> +void or_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
> +void mod_phy_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val);
> +
> +u16 read_radio_reg(struct brcms_phy *pi, u16 addr);
> +void or_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);
> +void and_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);
> +void mod_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val);
> +void xor_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask);
> +
> +void write_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);
> +
> +void wlc_phyreg_enter(struct brcms_phy_pub *pih);
> +void wlc_phyreg_exit(struct brcms_phy_pub *pih);
> +void wlc_radioreg_enter(struct brcms_phy_pub *pih);
> +void wlc_radioreg_exit(struct brcms_phy_pub *pih);
> +
> +void wlc_phy_read_table(struct brcms_phy *pi,
> + const struct phytbl_info *ptbl_info,
> + u16 tblAddr, u16 tblDataHi, u16 tblDatalo);
> +void wlc_phy_write_table(struct brcms_phy *pi,
> + const struct phytbl_info *ptbl_info,
> + u16 tblAddr, u16 tblDataHi, u16 tblDatalo);
> +void wlc_phy_table_addr(struct brcms_phy *pi, uint tbl_id, uint tbl_offset,
> + u16 tblAddr, u16 tblDataHi, u16 tblDataLo);
> +void wlc_phy_table_data_write(struct brcms_phy *pi, uint width, u32 val);
> +
> +void write_phy_channel_reg(struct brcms_phy *pi, uint val);
> +void wlc_phy_txpower_update_shm(struct brcms_phy *pi);
> +
> +u8 wlc_phy_nbits(s32 value);
> +void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_dB, u8 core);
> +
> +uint wlc_phy_init_radio_regs_allbands(struct brcms_phy *pi,
> + struct radio_20xx_regs *radioregs);
> +uint wlc_phy_init_radio_regs(struct brcms_phy *pi,
> + const struct radio_regs *radioregs,
> + u16 core_offset);
> +
> +void wlc_phy_txpower_ipa_upd(struct brcms_phy *pi);
> +
> +void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on);
> +void wlc_phy_papd_decode_epsilon(u32 epsilon, s32 *eps_real, s32 *eps_imag);
> +
> +void wlc_phy_cal_perical_mphase_reset(struct brcms_phy *pi);
> +void wlc_phy_cal_perical_mphase_restart(struct brcms_phy *pi);
> +
> +bool wlc_phy_attach_nphy(struct brcms_phy *pi);
> +bool wlc_phy_attach_lcnphy(struct brcms_phy *pi);
> +
> +void wlc_phy_detach_lcnphy(struct brcms_phy *pi);
> +
> +void wlc_phy_init_nphy(struct brcms_phy *pi);
> +void wlc_phy_init_lcnphy(struct brcms_phy *pi);
> +
> +void wlc_phy_cal_init_nphy(struct brcms_phy *pi);
> +void wlc_phy_cal_init_lcnphy(struct brcms_phy *pi);
> +
> +void wlc_phy_chanspec_set_nphy(struct brcms_phy *pi, u16 chanspec);
> +void wlc_phy_chanspec_set_lcnphy(struct brcms_phy *pi, u16 chanspec);
> +void wlc_phy_chanspec_set_fixup_lcnphy(struct brcms_phy *pi, u16 chanspec);
> +int wlc_phy_channel2freq(uint channel);
> +int wlc_phy_chanspec_freq2bandrange_lpssn(uint);
> +int wlc_phy_chanspec_bandrange_get(struct brcms_phy *, u16 chanspec);
> +
> +void wlc_lcnphy_set_tx_pwr_ctrl(struct brcms_phy *pi, u16 mode);
> +s8 wlc_lcnphy_get_current_tx_pwr_idx(struct brcms_phy *pi);
> +
> +void wlc_phy_txpower_recalc_target_nphy(struct brcms_phy *pi);
> +void wlc_lcnphy_txpower_recalc_target(struct brcms_phy *pi);
> +void wlc_phy_txpower_recalc_target_lcnphy(struct brcms_phy *pi);
> +
> +void wlc_lcnphy_set_tx_pwr_by_index(struct brcms_phy *pi, int index);
> +void wlc_lcnphy_tx_pu(struct brcms_phy *pi, bool bEnable);
> +void wlc_lcnphy_stop_tx_tone(struct brcms_phy *pi);
> +void wlc_lcnphy_start_tx_tone(struct brcms_phy *pi, s32 f_kHz, u16 max_val,
> + bool iqcalmode);
> +
> +void wlc_phy_txpower_sromlimit_get_nphy(struct brcms_phy *pi, uint chan,
> + u8 *max_pwr, u8 rate_id);
> +void wlc_phy_ofdm_to_mcs_powers_nphy(u8 *power, u8 rate_mcs_start,
> + u8 rate_mcs_end, u8 rate_ofdm_start);
> +void wlc_phy_mcs_to_ofdm_powers_nphy(u8 *power, u8 rate_ofdm_start,
> + u8 rate_ofdm_end, u8 rate_mcs_start);
> +
> +u16 wlc_lcnphy_tempsense(struct brcms_phy *pi, bool mode);
> +s16 wlc_lcnphy_tempsense_new(struct brcms_phy *pi, bool mode);
> +s8 wlc_lcnphy_tempsense_degree(struct brcms_phy *pi, bool mode);
> +s8 wlc_lcnphy_vbatsense(struct brcms_phy *pi, bool mode);
> +void wlc_phy_carrier_suppress_lcnphy(struct brcms_phy *pi);
> +void wlc_lcnphy_crsuprs(struct brcms_phy *pi, int channel);
> +void wlc_lcnphy_epa_switch(struct brcms_phy *pi, bool mode);
> +void wlc_2064_vco_cal(struct brcms_phy *pi);
> +
> +void wlc_phy_txpower_recalc_target(struct brcms_phy *pi);
>
> #define LCNPHY_TBL_ID_PAPDCOMPDELTATBL 0x18
> #define LCNPHY_TX_POWER_TABLE_SIZE 128
> @@ -1030,26 +1020,24 @@ extern void wlc_phy_txpower_recalc_target(struct brcms_phy *pi);
>
> #define LCNPHY_TX_PWR_CTRL_TEMPBASED 0xE001
>
> -extern void wlc_lcnphy_write_table(struct brcms_phy *pi,
> - const struct phytbl_info *pti);
> -extern void wlc_lcnphy_read_table(struct brcms_phy *pi,
> - struct phytbl_info *pti);
> -extern void wlc_lcnphy_set_tx_iqcc(struct brcms_phy *pi, u16 a, u16 b);
> -extern void wlc_lcnphy_set_tx_locc(struct brcms_phy *pi, u16 didq);
> -extern void wlc_lcnphy_get_tx_iqcc(struct brcms_phy *pi, u16 *a, u16 *b);
> -extern u16 wlc_lcnphy_get_tx_locc(struct brcms_phy *pi);
> -extern void wlc_lcnphy_get_radio_loft(struct brcms_phy *pi, u8 *ei0,
> - u8 *eq0, u8 *fi0, u8 *fq0);
> -extern void wlc_lcnphy_calib_modes(struct brcms_phy *pi, uint mode);
> -extern void wlc_lcnphy_deaf_mode(struct brcms_phy *pi, bool mode);
> -extern bool wlc_phy_tpc_isenabled_lcnphy(struct brcms_phy *pi);
> -extern void wlc_lcnphy_tx_pwr_update_npt(struct brcms_phy *pi);
> -extern s32 wlc_lcnphy_tssi2dbm(s32 tssi, s32 a1, s32 b0, s32 b1);
> -extern void wlc_lcnphy_get_tssi(struct brcms_phy *pi, s8 *ofdm_pwr,
> - s8 *cck_pwr);
> -extern void wlc_lcnphy_tx_power_adjustment(struct brcms_phy_pub *ppi);
> -
> -extern s32 wlc_lcnphy_rx_signal_power(struct brcms_phy *pi, s32 gain_index);
> +void wlc_lcnphy_write_table(struct brcms_phy *pi,
> + const struct phytbl_info *pti);
> +void wlc_lcnphy_read_table(struct brcms_phy *pi, struct phytbl_info *pti);
> +void wlc_lcnphy_set_tx_iqcc(struct brcms_phy *pi, u16 a, u16 b);
> +void wlc_lcnphy_set_tx_locc(struct brcms_phy *pi, u16 didq);
> +void wlc_lcnphy_get_tx_iqcc(struct brcms_phy *pi, u16 *a, u16 *b);
> +u16 wlc_lcnphy_get_tx_locc(struct brcms_phy *pi);
> +void wlc_lcnphy_get_radio_loft(struct brcms_phy *pi, u8 *ei0, u8 *eq0, u8 *fi0,
> + u8 *fq0);
> +void wlc_lcnphy_calib_modes(struct brcms_phy *pi, uint mode);
> +void wlc_lcnphy_deaf_mode(struct brcms_phy *pi, bool mode);
> +bool wlc_phy_tpc_isenabled_lcnphy(struct brcms_phy *pi);
> +void wlc_lcnphy_tx_pwr_update_npt(struct brcms_phy *pi);
> +s32 wlc_lcnphy_tssi2dbm(s32 tssi, s32 a1, s32 b0, s32 b1);
> +void wlc_lcnphy_get_tssi(struct brcms_phy *pi, s8 *ofdm_pwr, s8 *cck_pwr);
> +void wlc_lcnphy_tx_power_adjustment(struct brcms_phy_pub *ppi);
> +
> +s32 wlc_lcnphy_rx_signal_power(struct brcms_phy *pi, s32 gain_index);
>
> #define NPHY_MAX_HPVGA1_INDEX 10
> #define NPHY_DEF_HPVGA1_INDEXLIMIT 7
> @@ -1060,9 +1048,8 @@ struct phy_iq_est {
> u32 q_pwr;
> };
>
> -extern void wlc_phy_stay_in_carriersearch_nphy(struct brcms_phy *pi,
> - bool enable);
> -extern void wlc_nphy_deaf_mode(struct brcms_phy *pi, bool mode);
> +void wlc_phy_stay_in_carriersearch_nphy(struct brcms_phy *pi, bool enable);
> +void wlc_nphy_deaf_mode(struct brcms_phy *pi, bool mode);
>
> #define wlc_phy_write_table_nphy(pi, pti) \
> wlc_phy_write_table(pi, pti, 0x72, 0x74, 0x73)
> @@ -1076,10 +1063,10 @@ extern void wlc_nphy_deaf_mode(struct brcms_phy *pi, bool mode);
> #define wlc_nphy_table_data_write(pi, w, v) \
> wlc_phy_table_data_write((pi), (w), (v))
>
> -extern void wlc_phy_table_read_nphy(struct brcms_phy *pi, u32, u32 l, u32 o,
> - u32 w, void *d);
> -extern void wlc_phy_table_write_nphy(struct brcms_phy *pi, u32, u32, u32,
> - u32, const void *);
> +void wlc_phy_table_read_nphy(struct brcms_phy *pi, u32, u32 l, u32 o, u32 w,
> + void *d);
> +void wlc_phy_table_write_nphy(struct brcms_phy *pi, u32, u32, u32, u32,
> + const void *);
>
> #define PHY_IPA(pi) \
> ((pi->ipa2g_on && CHSPEC_IS2G(pi->radio_chanspec)) || \
> @@ -1089,73 +1076,67 @@ extern void wlc_phy_table_write_nphy(struct brcms_phy *pi, u32, u32, u32,
> if (NREV_LT((pi)->pubpi.phy_rev, 3)) \
> (void)bcma_read32(pi->d11core, D11REGOFFS(maccontrol))
>
> -extern void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype);
> -extern void wlc_phy_aci_reset_nphy(struct brcms_phy *pi);
> -extern void wlc_phy_pa_override_nphy(struct brcms_phy *pi, bool en);
> -
> -extern u8 wlc_phy_get_chan_freq_range_nphy(struct brcms_phy *pi, uint chan);
> -extern void wlc_phy_switch_radio_nphy(struct brcms_phy *pi, bool on);
> -
> -extern void wlc_phy_stf_chain_upd_nphy(struct brcms_phy *pi);
> -
> -extern void wlc_phy_force_rfseq_nphy(struct brcms_phy *pi, u8 cmd);
> -extern s16 wlc_phy_tempsense_nphy(struct brcms_phy *pi);
> -
> -extern u16 wlc_phy_classifier_nphy(struct brcms_phy *pi, u16 mask, u16 val);
> -
> -extern void wlc_phy_rx_iq_est_nphy(struct brcms_phy *pi, struct phy_iq_est *est,
> - u16 num_samps, u8 wait_time,
> - u8 wait_for_crs);
> -
> -extern void wlc_phy_rx_iq_coeffs_nphy(struct brcms_phy *pi, u8 write,
> - struct nphy_iq_comp *comp);
> -extern void wlc_phy_aci_and_noise_reduction_nphy(struct brcms_phy *pi);
> -
> -extern void wlc_phy_rxcore_setstate_nphy(struct brcms_phy_pub *pih,
> - u8 rxcore_bitmask);
> -extern u8 wlc_phy_rxcore_getstate_nphy(struct brcms_phy_pub *pih);
> -
> -extern void wlc_phy_txpwrctrl_enable_nphy(struct brcms_phy *pi, u8 ctrl_type);
> -extern void wlc_phy_txpwr_fixpower_nphy(struct brcms_phy *pi);
> -extern void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi);
> -extern void wlc_phy_txpwr_papd_cal_nphy(struct brcms_phy *pi);
> -extern u16 wlc_phy_txpwr_idx_get_nphy(struct brcms_phy *pi);
> -
> -extern struct nphy_txgains wlc_phy_get_tx_gain_nphy(struct brcms_phy *pi);
> -extern int wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi,
> - struct nphy_txgains target_gain,
> - bool full, bool m);
> -extern int wlc_phy_cal_rxiq_nphy(struct brcms_phy *pi,
> - struct nphy_txgains target_gain,
> - u8 type, bool d);
> -extern void wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask,
> - s8 txpwrindex, bool res);
> -extern void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core, u8 rssi_type);
> -extern int wlc_phy_poll_rssi_nphy(struct brcms_phy *pi, u8 rssi_type,
> - s32 *rssi_buf, u8 nsamps);
> -extern void wlc_phy_rssi_cal_nphy(struct brcms_phy *pi);
> -extern int wlc_phy_aci_scan_nphy(struct brcms_phy *pi);
> -extern void wlc_phy_cal_txgainctrl_nphy(struct brcms_phy *pi,
> - s32 dBm_targetpower, bool debug);
> -extern int wlc_phy_tx_tone_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val,
> - u8 mode, u8, bool);
> -extern void wlc_phy_stopplayback_nphy(struct brcms_phy *pi);
> -extern void wlc_phy_est_tonepwr_nphy(struct brcms_phy *pi, s32 *qdBm_pwrbuf,
> - u8 num_samps);
> -extern void wlc_phy_radio205x_vcocal_nphy(struct brcms_phy *pi);
> -
> -extern int wlc_phy_rssi_compute_nphy(struct brcms_phy *pi,
> - struct d11rxhdr *rxh);
> +void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype);
> +void wlc_phy_aci_reset_nphy(struct brcms_phy *pi);
> +void wlc_phy_pa_override_nphy(struct brcms_phy *pi, bool en);
> +
> +u8 wlc_phy_get_chan_freq_range_nphy(struct brcms_phy *pi, uint chan);
> +void wlc_phy_switch_radio_nphy(struct brcms_phy *pi, bool on);
> +
> +void wlc_phy_stf_chain_upd_nphy(struct brcms_phy *pi);
> +
> +void wlc_phy_force_rfseq_nphy(struct brcms_phy *pi, u8 cmd);
> +s16 wlc_phy_tempsense_nphy(struct brcms_phy *pi);
> +
> +u16 wlc_phy_classifier_nphy(struct brcms_phy *pi, u16 mask, u16 val);
> +
> +void wlc_phy_rx_iq_est_nphy(struct brcms_phy *pi, struct phy_iq_est *est,
> + u16 num_samps, u8 wait_time, u8 wait_for_crs);
> +
> +void wlc_phy_rx_iq_coeffs_nphy(struct brcms_phy *pi, u8 write,
> + struct nphy_iq_comp *comp);
> +void wlc_phy_aci_and_noise_reduction_nphy(struct brcms_phy *pi);
> +
> +void wlc_phy_rxcore_setstate_nphy(struct brcms_phy_pub *pih, u8 rxcore_bitmask);
> +u8 wlc_phy_rxcore_getstate_nphy(struct brcms_phy_pub *pih);
> +
> +void wlc_phy_txpwrctrl_enable_nphy(struct brcms_phy *pi, u8 ctrl_type);
> +void wlc_phy_txpwr_fixpower_nphy(struct brcms_phy *pi);
> +void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi);
> +void wlc_phy_txpwr_papd_cal_nphy(struct brcms_phy *pi);
> +u16 wlc_phy_txpwr_idx_get_nphy(struct brcms_phy *pi);
> +
> +struct nphy_txgains wlc_phy_get_tx_gain_nphy(struct brcms_phy *pi);
> +int wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi,
> + struct nphy_txgains target_gain, bool full, bool m);
> +int wlc_phy_cal_rxiq_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain,
> + u8 type, bool d);
> +void wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask,
> + s8 txpwrindex, bool res);
> +void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core, u8 rssi_type);
> +int wlc_phy_poll_rssi_nphy(struct brcms_phy *pi, u8 rssi_type,
> + s32 *rssi_buf, u8 nsamps);
> +void wlc_phy_rssi_cal_nphy(struct brcms_phy *pi);
> +int wlc_phy_aci_scan_nphy(struct brcms_phy *pi);
> +void wlc_phy_cal_txgainctrl_nphy(struct brcms_phy *pi, s32 dBm_targetpower,
> + bool debug);
> +int wlc_phy_tx_tone_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, u8 mode,
> + u8, bool);
> +void wlc_phy_stopplayback_nphy(struct brcms_phy *pi);
> +void wlc_phy_est_tonepwr_nphy(struct brcms_phy *pi, s32 *qdBm_pwrbuf,
> + u8 num_samps);
> +void wlc_phy_radio205x_vcocal_nphy(struct brcms_phy *pi);
> +
> +int wlc_phy_rssi_compute_nphy(struct brcms_phy *pi, struct d11rxhdr *rxh);
>
> #define NPHY_TESTPATTERN_BPHY_EVM 0
> #define NPHY_TESTPATTERN_BPHY_RFCS 1
>
> -extern void wlc_phy_nphy_tkip_rifs_war(struct brcms_phy *pi, u8 rifs);
> +void wlc_phy_nphy_tkip_rifs_war(struct brcms_phy *pi, u8 rifs);
>
> void wlc_phy_get_pwrdet_offsets(struct brcms_phy *pi, s8 *cckoffset,
> s8 *ofdmoffset);
> -extern s8 wlc_phy_upd_rssi_offset(struct brcms_phy *pi, s8 rssi,
> - u16 chanspec);
> +s8 wlc_phy_upd_rssi_offset(struct brcms_phy *pi, s8 rssi, u16 chanspec);
>
> -extern bool wlc_phy_n_txpower_ipa_ison(struct brcms_phy *pih);
> +bool wlc_phy_n_txpower_ipa_ison(struct brcms_phy *pih);
> #endif /* _BRCM_PHY_INT_H_ */
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy_shim.h b/drivers/net/wireless/brcm80211/brcmsmac/phy_shim.h
> index 2c5b66b..dd87747 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/phy_shim.h
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy_shim.h
> @@ -124,56 +124,49 @@
>
> struct brcms_phy;
>
> -extern struct phy_shim_info *wlc_phy_shim_attach(struct brcms_hardware *wlc_hw,
> - struct brcms_info *wl,
> - struct brcms_c_info *wlc);
> -extern void wlc_phy_shim_detach(struct phy_shim_info *physhim);
> +struct phy_shim_info *wlc_phy_shim_attach(struct brcms_hardware *wlc_hw,
> + struct brcms_info *wl,
> + struct brcms_c_info *wlc);
> +void wlc_phy_shim_detach(struct phy_shim_info *physhim);
>
> /* PHY to WL utility functions */
> -extern struct wlapi_timer *wlapi_init_timer(struct phy_shim_info *physhim,
> - void (*fn) (struct brcms_phy *pi),
> - void *arg, const char *name);
> -extern void wlapi_free_timer(struct wlapi_timer *t);
> -extern void wlapi_add_timer(struct wlapi_timer *t, uint ms, int periodic);
> -extern bool wlapi_del_timer(struct wlapi_timer *t);
> -extern void wlapi_intrson(struct phy_shim_info *physhim);
> -extern u32 wlapi_intrsoff(struct phy_shim_info *physhim);
> -extern void wlapi_intrsrestore(struct phy_shim_info *physhim,
> - u32 macintmask);
> -
> -extern void wlapi_bmac_write_shm(struct phy_shim_info *physhim, uint offset,
> - u16 v);
> -extern u16 wlapi_bmac_read_shm(struct phy_shim_info *physhim, uint offset);
> -extern void wlapi_bmac_mhf(struct phy_shim_info *physhim, u8 idx,
> - u16 mask, u16 val, int bands);
> -extern void wlapi_bmac_corereset(struct phy_shim_info *physhim, u32 flags);
> -extern void wlapi_suspend_mac_and_wait(struct phy_shim_info *physhim);
> -extern void wlapi_switch_macfreq(struct phy_shim_info *physhim, u8 spurmode);
> -extern void wlapi_enable_mac(struct phy_shim_info *physhim);
> -extern void wlapi_bmac_mctrl(struct phy_shim_info *physhim, u32 mask,
> - u32 val);
> -extern void wlapi_bmac_phy_reset(struct phy_shim_info *physhim);
> -extern void wlapi_bmac_bw_set(struct phy_shim_info *physhim, u16 bw);
> -extern void wlapi_bmac_phyclk_fgc(struct phy_shim_info *physhim, bool clk);
> -extern void wlapi_bmac_macphyclk_set(struct phy_shim_info *physhim, bool clk);
> -extern void wlapi_bmac_core_phypll_ctl(struct phy_shim_info *physhim, bool on);
> -extern void wlapi_bmac_core_phypll_reset(struct phy_shim_info *physhim);
> -extern void wlapi_bmac_ucode_wake_override_phyreg_set(struct phy_shim_info *
> - physhim);
> -extern void wlapi_bmac_ucode_wake_override_phyreg_clear(struct phy_shim_info *
> - physhim);
> -extern void wlapi_bmac_write_template_ram(struct phy_shim_info *physhim, int o,
> - int len, void *buf);
> -extern u16 wlapi_bmac_rate_shm_offset(struct phy_shim_info *physhim,
> - u8 rate);
> -extern void wlapi_ucode_sample_init(struct phy_shim_info *physhim);
> -extern void wlapi_copyfrom_objmem(struct phy_shim_info *physhim, uint,
> - void *buf, int, u32 sel);
> -extern void wlapi_copyto_objmem(struct phy_shim_info *physhim, uint,
> - const void *buf, int, u32);
> -
> -extern void wlapi_high_update_phy_mode(struct phy_shim_info *physhim,
> - u32 phy_mode);
> -extern u16 wlapi_bmac_get_txant(struct phy_shim_info *physhim);
> +struct wlapi_timer *wlapi_init_timer(struct phy_shim_info *physhim,
> + void (*fn)(struct brcms_phy *pi),
> + void *arg, const char *name);
> +void wlapi_free_timer(struct wlapi_timer *t);
> +void wlapi_add_timer(struct wlapi_timer *t, uint ms, int periodic);
> +bool wlapi_del_timer(struct wlapi_timer *t);
> +void wlapi_intrson(struct phy_shim_info *physhim);
> +u32 wlapi_intrsoff(struct phy_shim_info *physhim);
> +void wlapi_intrsrestore(struct phy_shim_info *physhim, u32 macintmask);
> +
> +void wlapi_bmac_write_shm(struct phy_shim_info *physhim, uint offset, u16 v);
> +u16 wlapi_bmac_read_shm(struct phy_shim_info *physhim, uint offset);
> +void wlapi_bmac_mhf(struct phy_shim_info *physhim, u8 idx, u16 mask, u16 val,
> + int bands);
> +void wlapi_bmac_corereset(struct phy_shim_info *physhim, u32 flags);
> +void wlapi_suspend_mac_and_wait(struct phy_shim_info *physhim);
> +void wlapi_switch_macfreq(struct phy_shim_info *physhim, u8 spurmode);
> +void wlapi_enable_mac(struct phy_shim_info *physhim);
> +void wlapi_bmac_mctrl(struct phy_shim_info *physhim, u32 mask, u32 val);
> +void wlapi_bmac_phy_reset(struct phy_shim_info *physhim);
> +void wlapi_bmac_bw_set(struct phy_shim_info *physhim, u16 bw);
> +void wlapi_bmac_phyclk_fgc(struct phy_shim_info *physhim, bool clk);
> +void wlapi_bmac_macphyclk_set(struct phy_shim_info *physhim, bool clk);
> +void wlapi_bmac_core_phypll_ctl(struct phy_shim_info *physhim, bool on);
> +void wlapi_bmac_core_phypll_reset(struct phy_shim_info *physhim);
> +void wlapi_bmac_ucode_wake_override_phyreg_set(struct phy_shim_info *physhim);
> +void wlapi_bmac_ucode_wake_override_phyreg_clear(struct phy_shim_info *physhim);
> +void wlapi_bmac_write_template_ram(struct phy_shim_info *physhim, int o,
> + int len, void *buf);
> +u16 wlapi_bmac_rate_shm_offset(struct phy_shim_info *physhim, u8 rate);
> +void wlapi_ucode_sample_init(struct phy_shim_info *physhim);
> +void wlapi_copyfrom_objmem(struct phy_shim_info *physhim, uint, void *buf,
> + int, u32 sel);
> +void wlapi_copyto_objmem(struct phy_shim_info *physhim, uint, const void *buf,
> + int, u32);
> +
> +void wlapi_high_update_phy_mode(struct phy_shim_info *physhim, u32 phy_mode);
> +u16 wlapi_bmac_get_txant(struct phy_shim_info *physhim);
>
> #endif /* _BRCM_PHY_SHIM_H_ */
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pmu.h b/drivers/net/wireless/brcm80211/brcmsmac/pmu.h
> index 20e2012..a014bbc 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/pmu.h
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/pmu.h
> @@ -20,7 +20,7 @@
>
> #include "types.h"
>
> -extern u16 si_pmu_fast_pwrup_delay(struct si_pub *sih);
> -extern u32 si_pmu_measure_alpclk(struct si_pub *sih);
> +u16 si_pmu_fast_pwrup_delay(struct si_pub *sih);
> +u32 si_pmu_measure_alpclk(struct si_pub *sih);
>
> #endif /* _BRCM_PMU_H_ */
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pub.h b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
> index d36ea5e..4da38cb 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
> @@ -266,83 +266,76 @@ struct brcms_antselcfg {
> };
>
> /* common functions for every port */
> -extern struct brcms_c_info *
> -brcms_c_attach(struct brcms_info *wl, struct bcma_device *core, uint unit,
> - bool piomode, uint *perr);
> -extern uint brcms_c_detach(struct brcms_c_info *wlc);
> -extern int brcms_c_up(struct brcms_c_info *wlc);
> -extern uint brcms_c_down(struct brcms_c_info *wlc);
> -
> -extern bool brcms_c_chipmatch(struct bcma_device *core);
> -extern void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx);
> -extern void brcms_c_reset(struct brcms_c_info *wlc);
> -
> -extern void brcms_c_intrson(struct brcms_c_info *wlc);
> -extern u32 brcms_c_intrsoff(struct brcms_c_info *wlc);
> -extern void brcms_c_intrsrestore(struct brcms_c_info *wlc, u32 macintmask);
> -extern bool brcms_c_intrsupd(struct brcms_c_info *wlc);
> -extern bool brcms_c_isr(struct brcms_c_info *wlc);
> -extern bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded);
> -extern bool brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc,
> - struct sk_buff *sdu,
> - struct ieee80211_hw *hw);
> -extern bool brcms_c_aggregatable(struct brcms_c_info *wlc, u8 tid);
> -extern void brcms_c_protection_upd(struct brcms_c_info *wlc, uint idx,
> - int val);
> -extern int brcms_c_get_header_len(void);
> -extern void brcms_c_set_addrmatch(struct brcms_c_info *wlc,
> - int match_reg_offset,
> - const u8 *addr);
> -extern void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci,
> - const struct ieee80211_tx_queue_params *arg,
> - bool suspend);
> -extern struct brcms_pub *brcms_c_pub(struct brcms_c_info *wlc);
> -extern void brcms_c_ampdu_flush(struct brcms_c_info *wlc,
> - struct ieee80211_sta *sta, u16 tid);
> -extern void brcms_c_ampdu_tx_operational(struct brcms_c_info *wlc, u8 tid,
> - u8 ba_wsize, uint max_rx_ampdu_bytes);
> -extern int brcms_c_module_register(struct brcms_pub *pub,
> - const char *name, struct brcms_info *hdl,
> - int (*down_fn)(void *handle));
> -extern int brcms_c_module_unregister(struct brcms_pub *pub, const char *name,
> - struct brcms_info *hdl);
> -extern void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc);
> -extern void brcms_c_enable_mac(struct brcms_c_info *wlc);
> -extern void brcms_c_associate_upd(struct brcms_c_info *wlc, bool state);
> -extern void brcms_c_scan_start(struct brcms_c_info *wlc);
> -extern void brcms_c_scan_stop(struct brcms_c_info *wlc);
> -extern int brcms_c_get_curband(struct brcms_c_info *wlc);
> -extern int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel);
> -extern int brcms_c_set_rate_limit(struct brcms_c_info *wlc, u16 srl, u16 lrl);
> -extern void brcms_c_get_current_rateset(struct brcms_c_info *wlc,
> +struct brcms_c_info *brcms_c_attach(struct brcms_info *wl,
> + struct bcma_device *core, uint unit,
> + bool piomode, uint *perr);
> +uint brcms_c_detach(struct brcms_c_info *wlc);
> +int brcms_c_up(struct brcms_c_info *wlc);
> +uint brcms_c_down(struct brcms_c_info *wlc);
> +
> +bool brcms_c_chipmatch(struct bcma_device *core);
> +void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx);
> +void brcms_c_reset(struct brcms_c_info *wlc);
> +
> +void brcms_c_intrson(struct brcms_c_info *wlc);
> +u32 brcms_c_intrsoff(struct brcms_c_info *wlc);
> +void brcms_c_intrsrestore(struct brcms_c_info *wlc, u32 macintmask);
> +bool brcms_c_intrsupd(struct brcms_c_info *wlc);
> +bool brcms_c_isr(struct brcms_c_info *wlc);
> +bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded);
> +bool brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu,
> + struct ieee80211_hw *hw);
> +bool brcms_c_aggregatable(struct brcms_c_info *wlc, u8 tid);
> +void brcms_c_protection_upd(struct brcms_c_info *wlc, uint idx, int val);
> +int brcms_c_get_header_len(void);
> +void brcms_c_set_addrmatch(struct brcms_c_info *wlc, int match_reg_offset,
> + const u8 *addr);
> +void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci,
> + const struct ieee80211_tx_queue_params *arg,
> + bool suspend);
> +struct brcms_pub *brcms_c_pub(struct brcms_c_info *wlc);
> +void brcms_c_ampdu_flush(struct brcms_c_info *wlc, struct ieee80211_sta *sta,
> + u16 tid);
> +void brcms_c_ampdu_tx_operational(struct brcms_c_info *wlc, u8 tid,
> + u8 ba_wsize, uint max_rx_ampdu_bytes);
> +int brcms_c_module_register(struct brcms_pub *pub, const char *name,
> + struct brcms_info *hdl,
> + int (*down_fn)(void *handle));
> +int brcms_c_module_unregister(struct brcms_pub *pub, const char *name,
> + struct brcms_info *hdl);
> +void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc);
> +void brcms_c_enable_mac(struct brcms_c_info *wlc);
> +void brcms_c_associate_upd(struct brcms_c_info *wlc, bool state);
> +void brcms_c_scan_start(struct brcms_c_info *wlc);
> +void brcms_c_scan_stop(struct brcms_c_info *wlc);
> +int brcms_c_get_curband(struct brcms_c_info *wlc);
> +int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel);
> +int brcms_c_set_rate_limit(struct brcms_c_info *wlc, u16 srl, u16 lrl);
> +void brcms_c_get_current_rateset(struct brcms_c_info *wlc,
> struct brcm_rateset *currs);
> -extern int brcms_c_set_rateset(struct brcms_c_info *wlc,
> - struct brcm_rateset *rs);
> -extern int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period);
> -extern u16 brcms_c_get_phy_type(struct brcms_c_info *wlc, int phyidx);
> -extern void brcms_c_set_shortslot_override(struct brcms_c_info *wlc,
> +int brcms_c_set_rateset(struct brcms_c_info *wlc, struct brcm_rateset *rs);
> +int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period);
> +u16 brcms_c_get_phy_type(struct brcms_c_info *wlc, int phyidx);
> +void brcms_c_set_shortslot_override(struct brcms_c_info *wlc,
> s8 sslot_override);
> -extern void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc,
> - u8 interval);
> -extern u64 brcms_c_tsf_get(struct brcms_c_info *wlc);
> -extern void brcms_c_tsf_set(struct brcms_c_info *wlc, u64 tsf);
> -extern int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr);
> -extern int brcms_c_get_tx_power(struct brcms_c_info *wlc);
> -extern bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc);
> -extern void brcms_c_mute(struct brcms_c_info *wlc, bool on);
> -extern bool brcms_c_tx_flush_completed(struct brcms_c_info *wlc);
> -extern void brcms_c_start_station(struct brcms_c_info *wlc, u8 *addr);
> -extern void brcms_c_start_ap(struct brcms_c_info *wlc, u8 *addr,
> - const u8 *bssid, u8 *ssid, size_t ssid_len);
> -extern void brcms_c_start_adhoc(struct brcms_c_info *wlc, u8 *addr);
> -extern void brcms_c_update_beacon(struct brcms_c_info *wlc);
> -extern void brcms_c_set_new_beacon(struct brcms_c_info *wlc,
> - struct sk_buff *beacon, u16 tim_offset,
> - u16 dtim_period);
> -extern void brcms_c_set_new_probe_resp(struct brcms_c_info *wlc,
> - struct sk_buff *probe_resp);
> -extern void brcms_c_enable_probe_resp(struct brcms_c_info *wlc, bool enable);
> -extern void brcms_c_set_ssid(struct brcms_c_info *wlc, u8 *ssid,
> - size_t ssid_len);
> +void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc, u8 interval);
> +u64 brcms_c_tsf_get(struct brcms_c_info *wlc);
> +void brcms_c_tsf_set(struct brcms_c_info *wlc, u64 tsf);
> +int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr);
> +int brcms_c_get_tx_power(struct brcms_c_info *wlc);
> +bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc);
> +void brcms_c_mute(struct brcms_c_info *wlc, bool on);
> +bool brcms_c_tx_flush_completed(struct brcms_c_info *wlc);
> +void brcms_c_start_station(struct brcms_c_info *wlc, u8 *addr);
> +void brcms_c_start_ap(struct brcms_c_info *wlc, u8 *addr, const u8 *bssid,
> + u8 *ssid, size_t ssid_len);
> +void brcms_c_start_adhoc(struct brcms_c_info *wlc, u8 *addr);
> +void brcms_c_update_beacon(struct brcms_c_info *wlc);
> +void brcms_c_set_new_beacon(struct brcms_c_info *wlc, struct sk_buff *beacon,
> + u16 tim_offset, u16 dtim_period);
> +void brcms_c_set_new_probe_resp(struct brcms_c_info *wlc,
> + struct sk_buff *probe_resp);
> +void brcms_c_enable_probe_resp(struct brcms_c_info *wlc, bool enable);
> +void brcms_c_set_ssid(struct brcms_c_info *wlc, u8 *ssid, size_t ssid_len);
>
> #endif /* _BRCM_PUB_H_ */
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/rate.h b/drivers/net/wireless/brcm80211/brcmsmac/rate.h
> index 980d578..5bb88b7 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/rate.h
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/rate.h
> @@ -216,34 +216,30 @@ static inline u8 cck_phy2mac_rate(u8 signal)
>
> /* sanitize, and sort a rateset with the basic bit(s) preserved, validate
> * rateset */
> -extern bool
> -brcms_c_rate_hwrs_filter_sort_validate(struct brcms_c_rateset *rs,
> - const struct brcms_c_rateset *hw_rs,
> - bool check_brate, u8 txstreams);
> +bool brcms_c_rate_hwrs_filter_sort_validate(struct brcms_c_rateset *rs,
> + const struct brcms_c_rateset *hw_rs,
> + bool check_brate, u8 txstreams);
> /* copy rateset src to dst as-is (no masking or sorting) */
> -extern void brcms_c_rateset_copy(const struct brcms_c_rateset *src,
> - struct brcms_c_rateset *dst);
> +void brcms_c_rateset_copy(const struct brcms_c_rateset *src,
> + struct brcms_c_rateset *dst);
>
> /* would be nice to have these documented ... */
> -extern u32 brcms_c_compute_rspec(struct d11rxhdr *rxh, u8 *plcp);
> -
> -extern void brcms_c_rateset_filter(struct brcms_c_rateset *src,
> - struct brcms_c_rateset *dst, bool basic_only, u8 rates, uint xmask,
> - bool mcsallow);
> -
> -extern void
> -brcms_c_rateset_default(struct brcms_c_rateset *rs_tgt,
> - const struct brcms_c_rateset *rs_hw, uint phy_type,
> - int bandtype, bool cck_only, uint rate_mask,
> - bool mcsallow, u8 bw, u8 txstreams);
> -
> -extern s16 brcms_c_rate_legacy_phyctl(uint rate);
> -
> -extern void brcms_c_rateset_mcs_upd(struct brcms_c_rateset *rs, u8 txstreams);
> -extern void brcms_c_rateset_mcs_clear(struct brcms_c_rateset *rateset);
> -extern void brcms_c_rateset_mcs_build(struct brcms_c_rateset *rateset,
> - u8 txstreams);
> -extern void brcms_c_rateset_bw_mcs_filter(struct brcms_c_rateset *rateset,
> - u8 bw);
> +u32 brcms_c_compute_rspec(struct d11rxhdr *rxh, u8 *plcp);
> +
> +void brcms_c_rateset_filter(struct brcms_c_rateset *src,
> + struct brcms_c_rateset *dst, bool basic_only,
> + u8 rates, uint xmask, bool mcsallow);
> +
> +void brcms_c_rateset_default(struct brcms_c_rateset *rs_tgt,
> + const struct brcms_c_rateset *rs_hw, uint phy_type,
> + int bandtype, bool cck_only, uint rate_mask,
> + bool mcsallow, u8 bw, u8 txstreams);
> +
> +s16 brcms_c_rate_legacy_phyctl(uint rate);
> +
> +void brcms_c_rateset_mcs_upd(struct brcms_c_rateset *rs, u8 txstreams);
> +void brcms_c_rateset_mcs_clear(struct brcms_c_rateset *rateset);
> +void brcms_c_rateset_mcs_build(struct brcms_c_rateset *rateset, u8 txstreams);
> +void brcms_c_rateset_bw_mcs_filter(struct brcms_c_rateset *rateset, u8 bw);
>
> #endif /* _BRCM_RATE_H_ */
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/stf.h b/drivers/net/wireless/brcm80211/brcmsmac/stf.h
> index 19f6580..ba94930 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/stf.h
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/stf.h
> @@ -19,24 +19,19 @@
>
> #include "types.h"
>
> -extern int brcms_c_stf_attach(struct brcms_c_info *wlc);
> -extern void brcms_c_stf_detach(struct brcms_c_info *wlc);
> +int brcms_c_stf_attach(struct brcms_c_info *wlc);
> +void brcms_c_stf_detach(struct brcms_c_info *wlc);
>
> -extern void brcms_c_tempsense_upd(struct brcms_c_info *wlc);
> -extern void brcms_c_stf_ss_algo_channel_get(struct brcms_c_info *wlc,
> - u16 *ss_algo_channel,
> - u16 chanspec);
> -extern int brcms_c_stf_ss_update(struct brcms_c_info *wlc,
> - struct brcms_band *band);
> -extern void brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc);
> -extern int brcms_c_stf_txchain_set(struct brcms_c_info *wlc, s32 int_val,
> - bool force);
> -extern bool brcms_c_stf_stbc_rx_set(struct brcms_c_info *wlc, s32 int_val);
> -extern void brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc);
> -extern void brcms_c_stf_phy_chain_calc(struct brcms_c_info *wlc);
> -extern u16 brcms_c_stf_phytxchain_sel(struct brcms_c_info *wlc,
> - u32 rspec);
> -extern u16 brcms_c_stf_d11hdrs_phyctl_txant(struct brcms_c_info *wlc,
> - u32 rspec);
> +void brcms_c_tempsense_upd(struct brcms_c_info *wlc);
> +void brcms_c_stf_ss_algo_channel_get(struct brcms_c_info *wlc,
> + u16 *ss_algo_channel, u16 chanspec);
> +int brcms_c_stf_ss_update(struct brcms_c_info *wlc, struct brcms_band *band);
> +void brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc);
> +int brcms_c_stf_txchain_set(struct brcms_c_info *wlc, s32 int_val, bool force);
> +bool brcms_c_stf_stbc_rx_set(struct brcms_c_info *wlc, s32 int_val);
> +void brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc);
> +void brcms_c_stf_phy_chain_calc(struct brcms_c_info *wlc);
> +u16 brcms_c_stf_phytxchain_sel(struct brcms_c_info *wlc, u32 rspec);
> +u16 brcms_c_stf_d11hdrs_phyctl_txant(struct brcms_c_info *wlc, u32 rspec);
>
> #endif /* _BRCM_STF_H_ */
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/ucode_loader.h b/drivers/net/wireless/brcm80211/brcmsmac/ucode_loader.h
> index 18750a8..c87dd89 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/ucode_loader.h
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/ucode_loader.h
> @@ -43,16 +43,14 @@ struct brcms_ucode {
> u32 *bcm43xx_bomminor;
> };
>
> -extern int
> -brcms_ucode_data_init(struct brcms_info *wl, struct brcms_ucode *ucode);
> +int brcms_ucode_data_init(struct brcms_info *wl, struct brcms_ucode *ucode);
>
> -extern void brcms_ucode_data_free(struct brcms_ucode *ucode);
> +void brcms_ucode_data_free(struct brcms_ucode *ucode);
>
> -extern int brcms_ucode_init_buf(struct brcms_info *wl, void **pbuf,
> - unsigned int idx);
> -extern int brcms_ucode_init_uint(struct brcms_info *wl, size_t *n_bytes,
> - unsigned int idx);
> -extern void brcms_ucode_free_buf(void *);
> -extern int brcms_check_firmwares(struct brcms_info *wl);
> +int brcms_ucode_init_buf(struct brcms_info *wl, void **pbuf, unsigned int idx);
> +int brcms_ucode_init_uint(struct brcms_info *wl, size_t *n_bytes,
> + unsigned int idx);
> +void brcms_ucode_free_buf(void *);
> +int brcms_check_firmwares(struct brcms_info *wl);
>
> #endif /* _BRCM_UCODE_H_ */
> diff --git a/drivers/net/wireless/brcm80211/include/brcmu_d11.h b/drivers/net/wireless/brcm80211/include/brcmu_d11.h
> index 92623f0..8660a2c 100644
> --- a/drivers/net/wireless/brcm80211/include/brcmu_d11.h
> +++ b/drivers/net/wireless/brcm80211/include/brcmu_d11.h
> @@ -140,6 +140,6 @@ struct brcmu_d11inf {
> void (*decchspec)(struct brcmu_chan *ch);
> };
>
> -extern void brcmu_d11_attach(struct brcmu_d11inf *d11inf);
> +void brcmu_d11_attach(struct brcmu_d11inf *d11inf);
>
> #endif /* _BRCMU_CHANNELS_H_ */
> diff --git a/drivers/net/wireless/brcm80211/include/brcmu_utils.h b/drivers/net/wireless/brcm80211/include/brcmu_utils.h
> index 898cacb..8ba445b 100644
> --- a/drivers/net/wireless/brcm80211/include/brcmu_utils.h
> +++ b/drivers/net/wireless/brcm80211/include/brcmu_utils.h
> @@ -114,31 +114,29 @@ static inline struct sk_buff *pktq_ppeek_tail(struct pktq *pq, int prec)
> return skb_peek_tail(&pq->q[prec].skblist);
> }
>
> -extern struct sk_buff *brcmu_pktq_penq(struct pktq *pq, int prec,
> - struct sk_buff *p);
> -extern struct sk_buff *brcmu_pktq_penq_head(struct pktq *pq, int prec,
> - struct sk_buff *p);
> -extern struct sk_buff *brcmu_pktq_pdeq(struct pktq *pq, int prec);
> -extern struct sk_buff *brcmu_pktq_pdeq_tail(struct pktq *pq, int prec);
> -extern struct sk_buff *brcmu_pktq_pdeq_match(struct pktq *pq, int prec,
> - bool (*match_fn)(struct sk_buff *p,
> - void *arg),
> - void *arg);
> +struct sk_buff *brcmu_pktq_penq(struct pktq *pq, int prec, struct sk_buff *p);
> +struct sk_buff *brcmu_pktq_penq_head(struct pktq *pq, int prec,
> + struct sk_buff *p);
> +struct sk_buff *brcmu_pktq_pdeq(struct pktq *pq, int prec);
> +struct sk_buff *brcmu_pktq_pdeq_tail(struct pktq *pq, int prec);
> +struct sk_buff *brcmu_pktq_pdeq_match(struct pktq *pq, int prec,
> + bool (*match_fn)(struct sk_buff *p,
> + void *arg),
> + void *arg);
>
> /* packet primitives */
> -extern struct sk_buff *brcmu_pkt_buf_get_skb(uint len);
> -extern void brcmu_pkt_buf_free_skb(struct sk_buff *skb);
> +struct sk_buff *brcmu_pkt_buf_get_skb(uint len);
> +void brcmu_pkt_buf_free_skb(struct sk_buff *skb);
>
> /* Empty the queue at particular precedence level */
> /* callback function fn(pkt, arg) returns true if pkt belongs to if */
> -extern void brcmu_pktq_pflush(struct pktq *pq, int prec,
> - bool dir, bool (*fn)(struct sk_buff *, void *), void *arg);
> +void brcmu_pktq_pflush(struct pktq *pq, int prec, bool dir,
> + bool (*fn)(struct sk_buff *, void *), void *arg);
>
> /* operations on a set of precedences in packet queue */
>
> -extern int brcmu_pktq_mlen(struct pktq *pq, uint prec_bmp);
> -extern struct sk_buff *brcmu_pktq_mdeq(struct pktq *pq, uint prec_bmp,
> - int *prec_out);
> +int brcmu_pktq_mlen(struct pktq *pq, uint prec_bmp);
> +struct sk_buff *brcmu_pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out);
>
> /* operations on packet queue as a whole */
>
> @@ -167,11 +165,11 @@ static inline bool pktq_empty(struct pktq *pq)
> return pq->len == 0;
> }
>
> -extern void brcmu_pktq_init(struct pktq *pq, int num_prec, int max_len);
> +void brcmu_pktq_init(struct pktq *pq, int num_prec, int max_len);
> /* prec_out may be NULL if caller is not interested in return value */
> -extern struct sk_buff *brcmu_pktq_peek_tail(struct pktq *pq, int *prec_out);
> -extern void brcmu_pktq_flush(struct pktq *pq, bool dir,
> - bool (*fn)(struct sk_buff *, void *), void *arg);
> +struct sk_buff *brcmu_pktq_peek_tail(struct pktq *pq, int *prec_out);
> +void brcmu_pktq_flush(struct pktq *pq, bool dir,
> + bool (*fn)(struct sk_buff *, void *), void *arg);
>
> /* externs */
> /* ip address */
> @@ -204,13 +202,13 @@ static inline u16 brcmu_maskget16(u16 var, u16 mask, u8 shift)
> /* externs */
> /* format/print */
> #ifdef DEBUG
> -extern void brcmu_prpkt(const char *msg, struct sk_buff *p0);
> +void brcmu_prpkt(const char *msg, struct sk_buff *p0);
> #else
> #define brcmu_prpkt(a, b)
> #endif /* DEBUG */
>
> #ifdef DEBUG
> -extern __printf(3, 4)
> +__printf(3, 4)
> void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...);
> #else
> __printf(3, 4)
>
^ permalink raw reply
* Re: [PATCH 28/51] DMA-API: sound: fix dma mask handling in a lot of drivers
From: Takashi Iwai @ 2013-09-26 7:51 UTC (permalink / raw)
To: Russell King
Cc: alsa-devel, linux-doc, linux-mmc, linux-fbdev, linux-nvme,
Jaroslav Kysela, Peter Ujfalusi, linux-ide, Kukjin Kim, devel,
linux-samsung-soc, linux-scsi, e1000-devel, b43-dev, linux-media,
devicetree, Haojian Zhuang, Timur Tabi, Mark Brown, dri-devel,
Ben Dooks, linux-tegra, linux-omap, linux-arm-kernel,
Solarflare linux maintainers, Eric Miao, Sangbeom Kim
In-Reply-To: <E1VMm9m-0007ij-ER@rmk-PC.arm.linux.org.uk>
Hi,
sorry for the lat response, as I've been traveling in the last weeks.
At Thu, 19 Sep 2013 22:53:02 +0100,
Russell King wrote:
>
> This code sequence is unsafe in modules:
>
> static u64 mask = DMA_BIT_MASK(something);
> ...
> if (!dev->dma_mask)
> dev->dma_mask = &mask;
>
> as if a module is reloaded, the mask will be pointing at the original
> module's mask address, and this can lead to oopses. Moreover, they
> all follow this with:
>
> if (!dev->coherent_dma_mask)
> dev->coherent_dma_mask = mask;
>
> where 'mask' is the same value as the statically defined mask, and this
> bypasses the architecture's check on whether the DMA mask is possible.
>
> Fix these issues by using the new dma_coerce_coherent_and_mask()
> function.
>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Applied with Mark's ack now.
BTW, sound/soc/fsl/imx-pcm-fiq.c wasn't covered by this patch, so I
fixed it, too.
Thanks!
Takashi
> ---
> sound/arm/pxa2xx-pcm.c | 9 +++------
> sound/soc/atmel/atmel-pcm.c | 11 ++++-------
> sound/soc/blackfin/bf5xx-ac97-pcm.c | 11 ++++-------
> sound/soc/blackfin/bf5xx-i2s-pcm.c | 10 ++++------
> sound/soc/davinci/davinci-pcm.c | 9 +++------
> sound/soc/fsl/fsl_dma.c | 9 +++------
> sound/soc/fsl/mpc5200_dma.c | 10 ++++------
> sound/soc/jz4740/jz4740-pcm.c | 12 ++++--------
> sound/soc/kirkwood/kirkwood-dma.c | 9 +++------
> sound/soc/nuc900/nuc900-pcm.c | 9 ++++-----
> sound/soc/omap/omap-pcm.c | 11 ++++-------
> sound/soc/pxa/pxa2xx-pcm.c | 11 ++++-------
> sound/soc/s6000/s6000-pcm.c | 9 +++------
> sound/soc/samsung/dma.c | 11 ++++-------
> sound/soc/samsung/idma.c | 11 ++++-------
> 15 files changed, 55 insertions(+), 97 deletions(-)
>
> diff --git a/sound/arm/pxa2xx-pcm.c b/sound/arm/pxa2xx-pcm.c
> index 69a2455..fb3b76f 100644
> --- a/sound/arm/pxa2xx-pcm.c
> +++ b/sound/arm/pxa2xx-pcm.c
> @@ -83,8 +83,6 @@ static struct snd_pcm_ops pxa2xx_pcm_ops = {
> .mmap = pxa2xx_pcm_mmap,
> };
>
> -static u64 pxa2xx_pcm_dmamask = 0xffffffff;
> -
> int pxa2xx_pcm_new(struct snd_card *card, struct pxa2xx_pcm_client *client,
> struct snd_pcm **rpcm)
> {
> @@ -100,10 +98,9 @@ int pxa2xx_pcm_new(struct snd_card *card, struct pxa2xx_pcm_client *client,
> pcm->private_data = client;
> pcm->private_free = pxa2xx_pcm_free_dma_buffers;
>
> - if (!card->dev->dma_mask)
> - card->dev->dma_mask = &pxa2xx_pcm_dmamask;
> - if (!card->dev->coherent_dma_mask)
> - card->dev->coherent_dma_mask = 0xffffffff;
> + ret = dma_coerce_mask_and_coherent_mask(card->dev, DMA_BIT_MASK(32));
> + if (ret)
> + goto out;
>
> if (play) {
> int stream = SNDRV_PCM_STREAM_PLAYBACK;
> diff --git a/sound/soc/atmel/atmel-pcm.c b/sound/soc/atmel/atmel-pcm.c
> index 3109db7..fbb87e3 100644
> --- a/sound/soc/atmel/atmel-pcm.c
> +++ b/sound/soc/atmel/atmel-pcm.c
> @@ -68,18 +68,15 @@ int atmel_pcm_mmap(struct snd_pcm_substream *substream,
> }
> EXPORT_SYMBOL_GPL(atmel_pcm_mmap);
>
> -static u64 atmel_pcm_dmamask = DMA_BIT_MASK(32);
> -
> int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd)
> {
> struct snd_card *card = rtd->card->snd_card;
> struct snd_pcm *pcm = rtd->pcm;
> - int ret = 0;
> + int ret;
>
> - if (!card->dev->dma_mask)
> - card->dev->dma_mask = &atmel_pcm_dmamask;
> - if (!card->dev->coherent_dma_mask)
> - card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> + ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> + if (ret)
> + return ret;
>
> if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
> pr_debug("atmel-pcm: allocating PCM playback DMA buffer\n");
> diff --git a/sound/soc/blackfin/bf5xx-ac97-pcm.c b/sound/soc/blackfin/bf5xx-ac97-pcm.c
> index 53f8408..1d4c676 100644
> --- a/sound/soc/blackfin/bf5xx-ac97-pcm.c
> +++ b/sound/soc/blackfin/bf5xx-ac97-pcm.c
> @@ -415,19 +415,16 @@ static void bf5xx_pcm_free_dma_buffers(struct snd_pcm *pcm)
> }
> }
>
> -static u64 bf5xx_pcm_dmamask = DMA_BIT_MASK(32);
> -
> static int bf5xx_pcm_ac97_new(struct snd_soc_pcm_runtime *rtd)
> {
> struct snd_card *card = rtd->card->snd_card;
> struct snd_pcm *pcm = rtd->pcm;
> - int ret = 0;
> + int ret;
>
> pr_debug("%s enter\n", __func__);
> - if (!card->dev->dma_mask)
> - card->dev->dma_mask = &bf5xx_pcm_dmamask;
> - if (!card->dev->coherent_dma_mask)
> - card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> + ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> + if (ret)
> + return ret;
>
> if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
> ret = bf5xx_pcm_preallocate_dma_buffer(pcm,
> diff --git a/sound/soc/blackfin/bf5xx-i2s-pcm.c b/sound/soc/blackfin/bf5xx-i2s-pcm.c
> index 9cb4a80..2a5b434 100644
> --- a/sound/soc/blackfin/bf5xx-i2s-pcm.c
> +++ b/sound/soc/blackfin/bf5xx-i2s-pcm.c
> @@ -323,18 +323,16 @@ static struct snd_pcm_ops bf5xx_pcm_i2s_ops = {
> .silence = bf5xx_pcm_silence,
> };
>
> -static u64 bf5xx_pcm_dmamask = DMA_BIT_MASK(32);
> -
> static int bf5xx_pcm_i2s_new(struct snd_soc_pcm_runtime *rtd)
> {
> struct snd_card *card = rtd->card->snd_card;
> size_t size = bf5xx_pcm_hardware.buffer_bytes_max;
> + int ret;
>
> pr_debug("%s enter\n", __func__);
> - if (!card->dev->dma_mask)
> - card->dev->dma_mask = &bf5xx_pcm_dmamask;
> - if (!card->dev->coherent_dma_mask)
> - card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> + ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> + if (ret)
> + return ret;
>
> return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
> SNDRV_DMA_TYPE_DEV, card->dev, size, size);
> diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c
> index 8460edc..84a63c6 100644
> --- a/sound/soc/davinci/davinci-pcm.c
> +++ b/sound/soc/davinci/davinci-pcm.c
> @@ -844,18 +844,15 @@ static void davinci_pcm_free(struct snd_pcm *pcm)
> }
> }
>
> -static u64 davinci_pcm_dmamask = DMA_BIT_MASK(32);
> -
> static int davinci_pcm_new(struct snd_soc_pcm_runtime *rtd)
> {
> struct snd_card *card = rtd->card->snd_card;
> struct snd_pcm *pcm = rtd->pcm;
> int ret;
>
> - if (!card->dev->dma_mask)
> - card->dev->dma_mask = &davinci_pcm_dmamask;
> - if (!card->dev->coherent_dma_mask)
> - card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> + ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> + if (ret)
> + return ret;
>
> if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
> ret = davinci_pcm_preallocate_dma_buffer(pcm,
> diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c
> index 9cc5c1f..f73c7ef 100644
> --- a/sound/soc/fsl/fsl_dma.c
> +++ b/sound/soc/fsl/fsl_dma.c
> @@ -298,14 +298,11 @@ static int fsl_dma_new(struct snd_soc_pcm_runtime *rtd)
> {
> struct snd_card *card = rtd->card->snd_card;
> struct snd_pcm *pcm = rtd->pcm;
> - static u64 fsl_dma_dmamask = DMA_BIT_MASK(36);
> int ret;
>
> - if (!card->dev->dma_mask)
> - card->dev->dma_mask = &fsl_dma_dmamask;
> -
> - if (!card->dev->coherent_dma_mask)
> - card->dev->coherent_dma_mask = fsl_dma_dmamask;
> + ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(36));
> + if (ret)
> + return ret;
>
> /* Some codecs have separate DAIs for playback and capture, so we
> * should allocate a DMA buffer only for the streams that are valid.
> diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c
> index 2a847ca..8fcf224 100644
> --- a/sound/soc/fsl/mpc5200_dma.c
> +++ b/sound/soc/fsl/mpc5200_dma.c
> @@ -299,7 +299,6 @@ static struct snd_pcm_ops psc_dma_ops = {
> .hw_params = psc_dma_hw_params,
> };
>
> -static u64 psc_dma_dmamask = DMA_BIT_MASK(32);
> static int psc_dma_new(struct snd_soc_pcm_runtime *rtd)
> {
> struct snd_card *card = rtd->card->snd_card;
> @@ -307,15 +306,14 @@ static int psc_dma_new(struct snd_soc_pcm_runtime *rtd)
> struct snd_pcm *pcm = rtd->pcm;
> struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(rtd->cpu_dai);
> size_t size = psc_dma_hardware.buffer_bytes_max;
> - int rc = 0;
> + int rc;
>
> dev_dbg(rtd->platform->dev, "psc_dma_new(card=%p, dai=%p, pcm=%p)\n",
> card, dai, pcm);
>
> - if (!card->dev->dma_mask)
> - card->dev->dma_mask = &psc_dma_dmamask;
> - if (!card->dev->coherent_dma_mask)
> - card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> + rc = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> + if (rc)
> + return rc;
>
> if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
> rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->card->dev,
> diff --git a/sound/soc/jz4740/jz4740-pcm.c b/sound/soc/jz4740/jz4740-pcm.c
> index 7100592..1d7ef28 100644
> --- a/sound/soc/jz4740/jz4740-pcm.c
> +++ b/sound/soc/jz4740/jz4740-pcm.c
> @@ -297,19 +297,15 @@ static void jz4740_pcm_free(struct snd_pcm *pcm)
> }
> }
>
> -static u64 jz4740_pcm_dmamask = DMA_BIT_MASK(32);
> -
> static int jz4740_pcm_new(struct snd_soc_pcm_runtime *rtd)
> {
> struct snd_card *card = rtd->card->snd_card;
> struct snd_pcm *pcm = rtd->pcm;
> - int ret = 0;
> -
> - if (!card->dev->dma_mask)
> - card->dev->dma_mask = &jz4740_pcm_dmamask;
> + int ret;
>
> - if (!card->dev->coherent_dma_mask)
> - card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> + ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> + if (ret)
> + return ret;
>
> if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
> ret = jz4740_pcm_preallocate_dma_buffer(pcm,
> diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c
> index b238434..3814bb0 100644
> --- a/sound/soc/kirkwood/kirkwood-dma.c
> +++ b/sound/soc/kirkwood/kirkwood-dma.c
> @@ -59,8 +59,6 @@ static struct snd_pcm_hardware kirkwood_dma_snd_hw = {
> .fifo_size = 0,
> };
>
> -static u64 kirkwood_dma_dmamask = DMA_BIT_MASK(32);
> -
> static irqreturn_t kirkwood_dma_irq(int irq, void *dev_id)
> {
> struct kirkwood_dma_data *priv = dev_id;
> @@ -292,10 +290,9 @@ static int kirkwood_dma_new(struct snd_soc_pcm_runtime *rtd)
> struct snd_pcm *pcm = rtd->pcm;
> int ret;
>
> - if (!card->dev->dma_mask)
> - card->dev->dma_mask = &kirkwood_dma_dmamask;
> - if (!card->dev->coherent_dma_mask)
> - card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> + ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> + if (ret)
> + return ret;
>
> if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
> ret = kirkwood_dma_preallocate_dma_buffer(pcm,
> diff --git a/sound/soc/nuc900/nuc900-pcm.c b/sound/soc/nuc900/nuc900-pcm.c
> index c894ff0..f588ee4 100644
> --- a/sound/soc/nuc900/nuc900-pcm.c
> +++ b/sound/soc/nuc900/nuc900-pcm.c
> @@ -314,16 +314,15 @@ static void nuc900_dma_free_dma_buffers(struct snd_pcm *pcm)
> snd_pcm_lib_preallocate_free_for_all(pcm);
> }
>
> -static u64 nuc900_pcm_dmamask = DMA_BIT_MASK(32);
> static int nuc900_dma_new(struct snd_soc_pcm_runtime *rtd)
> {
> struct snd_card *card = rtd->card->snd_card;
> struct snd_pcm *pcm = rtd->pcm;
> + int ret;
>
> - if (!card->dev->dma_mask)
> - card->dev->dma_mask = &nuc900_pcm_dmamask;
> - if (!card->dev->coherent_dma_mask)
> - card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> + ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> + if (ret)
> + return ret;
>
> snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
> card->dev, 4 * 1024, (4 * 1024) - 1);
> diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
> index a11405d..b8fa986 100644
> --- a/sound/soc/omap/omap-pcm.c
> +++ b/sound/soc/omap/omap-pcm.c
> @@ -156,8 +156,6 @@ static struct snd_pcm_ops omap_pcm_ops = {
> .mmap = omap_pcm_mmap,
> };
>
> -static u64 omap_pcm_dmamask = DMA_BIT_MASK(64);
> -
> static int omap_pcm_preallocate_dma_buffer(struct snd_pcm *pcm,
> int stream)
> {
> @@ -202,12 +200,11 @@ static int omap_pcm_new(struct snd_soc_pcm_runtime *rtd)
> {
> struct snd_card *card = rtd->card->snd_card;
> struct snd_pcm *pcm = rtd->pcm;
> - int ret = 0;
> + int ret;
>
> - if (!card->dev->dma_mask)
> - card->dev->dma_mask = &omap_pcm_dmamask;
> - if (!card->dev->coherent_dma_mask)
> - card->dev->coherent_dma_mask = DMA_BIT_MASK(64);
> + ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(64));
> + if (ret)
> + return ret;
>
> if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
> ret = omap_pcm_preallocate_dma_buffer(pcm,
> diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c
> index 806da27..d58b09f 100644
> --- a/sound/soc/pxa/pxa2xx-pcm.c
> +++ b/sound/soc/pxa/pxa2xx-pcm.c
> @@ -87,18 +87,15 @@ static struct snd_pcm_ops pxa2xx_pcm_ops = {
> .mmap = pxa2xx_pcm_mmap,
> };
>
> -static u64 pxa2xx_pcm_dmamask = DMA_BIT_MASK(32);
> -
> static int pxa2xx_soc_pcm_new(struct snd_soc_pcm_runtime *rtd)
> {
> struct snd_card *card = rtd->card->snd_card;
> struct snd_pcm *pcm = rtd->pcm;
> - int ret = 0;
> + int ret;
>
> - if (!card->dev->dma_mask)
> - card->dev->dma_mask = &pxa2xx_pcm_dmamask;
> - if (!card->dev->coherent_dma_mask)
> - card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> + ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> + if (ret)
> + return ret;
>
> if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
> ret = pxa2xx_pcm_preallocate_dma_buffer(pcm,
> diff --git a/sound/soc/s6000/s6000-pcm.c b/sound/soc/s6000/s6000-pcm.c
> index d0740a7..283620a 100644
> --- a/sound/soc/s6000/s6000-pcm.c
> +++ b/sound/soc/s6000/s6000-pcm.c
> @@ -444,8 +444,6 @@ static void s6000_pcm_free(struct snd_pcm *pcm)
> snd_pcm_lib_preallocate_free_for_all(pcm);
> }
>
> -static u64 s6000_pcm_dmamask = DMA_BIT_MASK(32);
> -
> static int s6000_pcm_new(struct snd_soc_pcm_runtime *runtime)
> {
> struct snd_card *card = runtime->card->snd_card;
> @@ -456,10 +454,9 @@ static int s6000_pcm_new(struct snd_soc_pcm_runtime *runtime)
> params = snd_soc_dai_get_dma_data(runtime->cpu_dai,
> pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream);
>
> - if (!card->dev->dma_mask)
> - card->dev->dma_mask = &s6000_pcm_dmamask;
> - if (!card->dev->coherent_dma_mask)
> - card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> + res = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> + if (res)
> + return res;
>
> if (params->dma_in) {
> s6dmac_disable_chan(DMA_MASK_DMAC(params->dma_in),
> diff --git a/sound/soc/samsung/dma.c b/sound/soc/samsung/dma.c
> index 9338d11..fe2748b 100644
> --- a/sound/soc/samsung/dma.c
> +++ b/sound/soc/samsung/dma.c
> @@ -406,20 +406,17 @@ static void dma_free_dma_buffers(struct snd_pcm *pcm)
> }
> }
>
> -static u64 dma_mask = DMA_BIT_MASK(32);
> -
> static int dma_new(struct snd_soc_pcm_runtime *rtd)
> {
> struct snd_card *card = rtd->card->snd_card;
> struct snd_pcm *pcm = rtd->pcm;
> - int ret = 0;
> + int ret;
>
> pr_debug("Entered %s\n", __func__);
>
> - if (!card->dev->dma_mask)
> - card->dev->dma_mask = &dma_mask;
> - if (!card->dev->coherent_dma_mask)
> - card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> + ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> + if (ret)
> + return ret;
>
> if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
> ret = preallocate_dma_buffer(pcm,
> diff --git a/sound/soc/samsung/idma.c b/sound/soc/samsung/idma.c
> index ce1e1e1..e4f318f 100644
> --- a/sound/soc/samsung/idma.c
> +++ b/sound/soc/samsung/idma.c
> @@ -383,18 +383,15 @@ static int preallocate_idma_buffer(struct snd_pcm *pcm, int stream)
> return 0;
> }
>
> -static u64 idma_mask = DMA_BIT_MASK(32);
> -
> static int idma_new(struct snd_soc_pcm_runtime *rtd)
> {
> struct snd_card *card = rtd->card->snd_card;
> struct snd_pcm *pcm = rtd->pcm;
> - int ret = 0;
> + int ret;
>
> - if (!card->dev->dma_mask)
> - card->dev->dma_mask = &idma_mask;
> - if (!card->dev->coherent_dma_mask)
> - card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> + ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> + if (ret)
> + return ret;
>
> if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
> ret = preallocate_idma_buffer(pcm,
> --
> 1.7.4.4
>
^ permalink raw reply
* Re: [PATCH 28/51] DMA-API: sound: fix dma mask handling in a lot of drivers
From: Russell King - ARM Linux @ 2013-09-26 7:54 UTC (permalink / raw)
To: Takashi Iwai
Cc: alsa-devel, linux-doc, linux-mmc, linux-fbdev, linux-nvme,
Jaroslav Kysela, Peter Ujfalusi, linux-ide, Kukjin Kim, devel,
linux-samsung-soc, linux-scsi, e1000-devel, b43-dev, linux-media,
devicetree, Haojian Zhuang, Timur Tabi, Mark Brown, dri-devel,
Ben Dooks, linux-tegra, linux-omap, linux-arm-kernel,
Solarflare linux maintainers, Eric Miao, Sangbeom Kim
In-Reply-To: <s5h1u4cf2bo.wl%tiwai@suse.de>
On Thu, Sep 26, 2013 at 09:51:23AM +0200, Takashi Iwai wrote:
> Hi,
>
> sorry for the lat response, as I've been traveling in the last weeks.
>
> At Thu, 19 Sep 2013 22:53:02 +0100,
> Russell King wrote:
> >
> > This code sequence is unsafe in modules:
> >
> > static u64 mask = DMA_BIT_MASK(something);
> > ...
> > if (!dev->dma_mask)
> > dev->dma_mask = &mask;
> >
> > as if a module is reloaded, the mask will be pointing at the original
> > module's mask address, and this can lead to oopses. Moreover, they
> > all follow this with:
> >
> > if (!dev->coherent_dma_mask)
> > dev->coherent_dma_mask = mask;
> >
> > where 'mask' is the same value as the statically defined mask, and this
> > bypasses the architecture's check on whether the DMA mask is possible.
> >
> > Fix these issues by using the new dma_coerce_coherent_and_mask()
> > function.
> >
> > Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
>
> Applied with Mark's ack now.
Which is a very stupid thing to do because you won't have
dma_coerce_coherent_and_mask() in your tree, so all these drivers
will fail to build for you.
^ permalink raw reply
* Re: [PATCH net 2/2] ip_tunnel: Add fallback tunnels to the hash lists
From: Steffen Klassert @ 2013-09-26 8:13 UTC (permalink / raw)
To: Pravin Shelar; +Cc: David Miller, netdev
In-Reply-To: <CALnjE+rrm3Vzov4sUjBfEKHwzRb6MfTRhkA_B96yuNGpgFgiCg@mail.gmail.com>
On Wed, Sep 25, 2013 at 09:03:11AM -0700, Pravin Shelar wrote:
> On Tue, Sep 24, 2013 at 10:55 PM, Steffen Klassert
> <steffen.klassert@secunet.com> wrote:
> > Currently we can not update the tunnel parameters of
> > the fallback tunnels because we don't find them in the
> > hash lists. Fix this by adding them on initialization.
> >
> > Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
> > ---
> > net/ipv4/ip_tunnel.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
> > index b8ce640..f2348f2 100644
> > --- a/net/ipv4/ip_tunnel.c
> > +++ b/net/ipv4/ip_tunnel.c
> > @@ -853,8 +853,10 @@ int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id,
> > /* FB netdevice is special: we have one, and only one per netns.
> > * Allowing to move it to another netns is clearly unsafe.
> > */
> > - if (!IS_ERR(itn->fb_tunnel_dev))
> > + if (!IS_ERR(itn->fb_tunnel_dev)) {
> > itn->fb_tunnel_dev->features |= NETIF_F_NETNS_LOCAL;
> > + ip_tunnel_add(itn, netdev_priv(itn->fb_tunnel_dev));
> > + }
> > rtnl_unlock();
> >
> fallback tunnel s not required to be in hash table, Its is returned if
> none of hashed tunnels are matched, ref ip_tunnel_lookup().
> Can you post command to reproduce this issue?
>
Something like
ip tunnel change tunl0 mode ipip remote 0.0.0.0 local 0.0.0.0 ttl 0 tos 1
worked until v3.9 and stopped working with v3.10.
^ 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