Re: [PATCH 2/4] carl9170: fix debugfs crashes

2016-09-19 Thread Greg KH
On Mon, Sep 19, 2016 at 10:12:08PM +0200, Christian Lamparter wrote:
> On Sunday, September 18, 2016 6:44:08 PM CEST Greg KH wrote:
> > On Sun, Sep 18, 2016 at 02:49:33PM +0200, Christian Lamparter wrote:
> > > On Sunday, September 18, 2016 12:14:55 PM CEST Greg KH wrote:
> > > > On Sun, Sep 18, 2016 at 10:54:18AM +0300, Kalle Valo wrote:
> > > > > Greg KH  writes:
> > > > > 
> > > > > > On Sat, Sep 17, 2016 at 09:43:02PM +0200, Christian Lamparter wrote:
> > > > > >> Ben Greear reported:
> > > > > >> > I see lots of instability as soon as I load up the carl9710 NIC.
> > > > > >> > My application is going to be poking at it's debugfs files...
> > > > > >> >
> > > > > >> > BUG: KASAN: slab-out-of-bounds in 
> > > > > >> > carl9170_debugfs_read+0xd5/0x2a0
> > > > > >> > [carl9170] at addr 8801bc1208b0
> > > > > >> > Read of size 8 by task btserver/5888
> > > > > >> > ===
> > > > > >> > BUG kmalloc-256 (Tainted: GW  ): kasan: bad access 
> > > > > >> > detected
> > > > > >> > ---
> > > > > >> >
> > > > > >> > INFO: Allocated in seq_open+0x50/0x100 age=2690 cpu=2 pid=772
> > > > > >> >...
> > > > > >> 
> > > > > >> This breakage was caused by the introduction of intermediate
> > > > > >> fops in debugfs by commit 9fd4dcece43a
> > > > > >> ("debugfs: prevent access to possibly dead file_operations at file 
> > > > > >> open")
> > > > > >
> > > > > > Because of this, these should all be backported to 4.7-stable, and
> > > > > > 4.8-stable, right?
> > > Ok, only b43legacy has debugfs enabled by default. For b43 and carl9170 
> > > debugfs support is usually disabled.
> > > 
> > > Greg, would you take these four patches "as is" for -stable
> > > or do you want a "minimal version" which just replaces the
> > > 
> > > dfops = container_of(file->f_op, ...
> > > 
> > > with
> > > 
> > > dfops = container_of(file->f_path.dentry->d_fsdata, ...
> > > 
> > > in the three drivers for -stable?
> > 
> > No, I'll take this as is, we want things to remain as close as possible
> > to Linus's tree.  When we are not, is when things break.
> > 
> > > > > Via which tree should these go, Greg's or mine?
> > > > 
> > > > I'll take it if you ack it, as it's a debugfs issue.
> > > For carl9170: Ben Greear has reported:
> > > "I have verified this fixes my problem in the 4.7 kernel."
> > > 
> > > But this was with a preliminary/minimal version so I didn't
> > > add the tested-by tag.
> > > 
> > > As for b43, I'll see if I have a working b43 in my collection
> > > somewhere to confirm the issue and the fix. Question is, do
> > > you want to wait or not?
> > 
> > I'll queue these up this week, no rush.
> 
> I was able to sucessfully test the b43 patch on my iBook G4's BCM4306.

So is that a "Tested-by:"?  :)


[PATCH 1/1] rsi: fix memory leak in debugfs entry and supported bands

2016-09-19 Thread Prameela Rani Garnepudi
From: Prameela Rani Garnepudi 

Signed-off-by: Prameela Rani Garnepudi 
Signed-off-by: Prameela Rani Garnepudi 
---
 drivers/net/wireless/rsi/rsi_91x_mac80211.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/wireless/rsi/rsi_91x_mac80211.c 
b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
index dbb2389..dc64532 100644
--- a/drivers/net/wireless/rsi/rsi_91x_mac80211.c
+++ b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
@@ -194,6 +194,7 @@ static void rsi_register_rates_channels(struct rsi_hw 
*adapter, int band)
 void rsi_mac80211_detach(struct rsi_hw *adapter)
 {
struct ieee80211_hw *hw = adapter->hw;
+   int i;
 
if (hw) {
ieee80211_stop_queues(hw);
@@ -201,7 +202,16 @@ void rsi_mac80211_detach(struct rsi_hw *adapter)
ieee80211_free_hw(hw);
}
 
+   for (i = 0; i < 2; i++) {
+   struct ieee80211_supported_band *sbands = &adapter->sbands[i];
+
+   kfree(sbands->channels);
+   }
+
+#ifdef CONFIG_RSI_DEBUGFS
rsi_remove_dbgfs(adapter);
+   kfree(adapter->dfsentry);
+#endif
 }
 EXPORT_SYMBOL_GPL(rsi_mac80211_detach);
 
-- 
2.4.11



Re: nl80211 fine timing measurement support

2016-09-19 Thread Luca Coelho
On Mon, 2016-09-19 at 20:42 +0200, Arend Van Spriel wrote:
> 
> On 19-9-2016 19:31, Lior David wrote:
> > 
> > Hi Johannes,
> > 
> > We are working on adding indoor location support to the wil6210
> > 11ad driver. This includes fine timing measurement (FTM) as well as
> > something we call angle of arrival (AOA) which measures azimuth and
> > elevation.
> > Initially we implemented it internally using vendor commands but we
> > would like to upstream it using standard nl80211 API.
> > I noticed a patch you sent some time ago (https://patchwork.kernel.
> > org/patch/7790701/) for adding fine timing measurement support to
> > nl80211, it looks like a good baseline though we do have few issues
> > with it... However I did not see any comments or response on this
> > patch. Can you please update if you plan on eventually submitting
> > this patch?
> 
> You can find several FTM related patches in backport-iwlwifi repo on
> kernel.org. See link to git log of nl80211.h there [1].

We have a full FTM implementation in our internal tree (which is
published in the URL Arend provided) and we are currently working on
cleaning it up for upstream submission.  You should see patches from us
this week.

--
Cheers,
Luca.


Re: Problem with 40Mhz on 2.5GHz with Intel 8260

2016-09-19 Thread Volker Mische
Hi,

On 09/20/2016 07:39 AM, Emmanuel Grumbach wrote:
> On Mon, Sep 19, 2016 at 5:00 PM, Volker Mische  
> wrote:
>> I'm having connectivity issues with an Intel 8260 on a 2.5GHz network
>> when using 40Mhz. I'm getting errors like
>>
>> Queue 2 stuck for 1 ms.
>>
>> I've upgrade my system to the firmware version 21 (21.373438.0) and
>> Kernel 4.8.0-rc6 in hope that it fixes the issue and to be able to debug
>> the problem.
>>
>> I then found the page about platform noise [1]. I don't have any issue
>> for several hours now (normally I was hitting the issue every few
>> minutes) as I've set the cfg80211_disable_40mhz_24ghz parameter.
>>
>> Now I wonder, is it worth debugging the issue with being on 40MHz or is
>> disabling the proper solution and I should bother.
> 
> Well... depends whom you ask and how much time you have :)

I really want to get this sorted out.


> We tried a few times to debug those, but they take a very long time to debug
> since typically we need lots of reproductions and the firmware team
> doesn't always
> the time to look at the data immediately so in the end, the people who
> reported this
> originally went away.
> Note that 40MHz on 2.4GHz is not an optimal configuration in crowded
> environment,
> but if you live in a place where you are pretty much the only one using those
> frequencies, then, it can be beneficial.

It's at home. I normally see only one other wifi (I need to check which
frequency that one is using).


> What you can try is to disable low power states (by using power_scheme
> in iwlmvm) and see if it helps.

I will try that.

> This setting has a bigger impact than cfg80211_disable_40mhz_24ghz
> but it can give a hint as where the problem is coming from.

I'll report back.

Should I open a bug report (or use an existing one) or should we keep
the discussion on the mailing list?


Cheers,
  Volker


>> [1]:
>> https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi#about_platform_noise


Re: Problem with 40Mhz on 2.5GHz with Intel 8260

2016-09-19 Thread Emmanuel Grumbach
Hi,

On Mon, Sep 19, 2016 at 5:00 PM, Volker Mische  wrote:
> Hi,
>
> I'm having connectivity issues with an Intel 8260 on a 2.5GHz network
> when using 40Mhz. I'm getting errors like
>
> Queue 2 stuck for 1 ms.
>
> I've upgrade my system to the firmware version 21 (21.373438.0) and
> Kernel 4.8.0-rc6 in hope that it fixes the issue and to be able to debug
> the problem.
>
> I then found the page about platform noise [1]. I don't have any issue
> for several hours now (normally I was hitting the issue every few
> minutes) as I've set the cfg80211_disable_40mhz_24ghz parameter.
>
> Now I wonder, is it worth debugging the issue with being on 40MHz or is
> disabling the proper solution and I should bother.

Well... depends whom you ask and how much time you have :)
We tried a few times to debug those, but they take a very long time to debug
since typically we need lots of reproductions and the firmware team
doesn't always
the time to look at the data immediately so in the end, the people who
reported this
originally went away.
Note that 40MHz on 2.4GHz is not an optimal configuration in crowded
environment,
but if you live in a place where you are pretty much the only one using those
frequencies, then, it can be beneficial.
What you can try is to disable low power states (by using power_scheme
in iwlmvm)
and see if it helps. This setting has a bigger impact than
cfg80211_disable_40mhz_24ghz
but it can give a hint as where the problem is coming from.

>
> [1]:
> https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi#about_platform_noise
>
> Cheers,
>   Volker


[PATCH] ath10k: fix debug cal data file

2016-09-19 Thread Nikolay Martynov
It got broken by 0b8e3c4ca29fe2c0efd3d41a76e34a657b9f17a4

Signed-off-by: Nikolay Martynov 
---
 drivers/net/wireless/ath/ath10k/debug.c | 27 +--
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/debug.c 
b/drivers/net/wireless/ath/ath10k/debug.c
index 8f0fd41..7e82947 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -109,6 +109,11 @@ struct ath10k_dump_file_data {
u8 data[0];
 } __packed;
 
+struct ath10k_debug_cal_data {
+   u32 len;
+   u8 buf[0];
+};
+
 void ath10k_info(struct ath10k *ar, const char *fmt, ...)
 {
struct va_format vaf = {
@@ -1453,7 +1458,8 @@ static const struct file_operations fops_fw_dbglog = {
 static int ath10k_debug_cal_data_open(struct inode *inode, struct file *file)
 {
struct ath10k *ar = inode->i_private;
-   void *buf;
+   struct ath10k_debug_cal_data *data;
+   u32 len;
u32 hi_addr;
__le32 addr;
int ret;
@@ -1466,12 +1472,15 @@ static int ath10k_debug_cal_data_open(struct inode 
*inode, struct file *file)
goto err;
}
 
-   buf = vmalloc(ar->hw_params.cal_data_len);
-   if (!buf) {
+   len = ar->hw_params.cal_data_len;
+   data = vmalloc(sizeof(struct ath10k_debug_cal_data) + len);
+   if (!data) {
ret = -ENOMEM;
goto err;
}
 
+   data->len = len;
+
hi_addr = host_interest_item_address(HI_ITEM(hi_board_data));
 
ret = ath10k_hif_diag_read(ar, hi_addr, &addr, sizeof(addr));
@@ -1480,21 +1489,20 @@ static int ath10k_debug_cal_data_open(struct inode 
*inode, struct file *file)
goto err_vfree;
}
 
-   ret = ath10k_hif_diag_read(ar, le32_to_cpu(addr), buf,
-  ar->hw_params.cal_data_len);
+   ret = ath10k_hif_diag_read(ar, le32_to_cpu(addr), data->buf, len);
if (ret) {
ath10k_warn(ar, "failed to read calibration data: %d\n", ret);
goto err_vfree;
}
 
-   file->private_data = buf;
+   file->private_data = data;
 
mutex_unlock(&ar->conf_mutex);
 
return 0;
 
 err_vfree:
-   vfree(buf);
+   vfree(data);
 
 err:
mutex_unlock(&ar->conf_mutex);
@@ -1506,11 +1514,10 @@ static ssize_t ath10k_debug_cal_data_read(struct file 
*file,
  char __user *user_buf,
  size_t count, loff_t *ppos)
 {
-   struct ath10k *ar = file->private_data;
-   void *buf = file->private_data;
+   struct ath10k_debug_cal_data *data = file->private_data;
 
return simple_read_from_buffer(user_buf, count, ppos,
-  buf, ar->hw_params.cal_data_len);
+  data->buf, data->len);
 }
 
 static int ath10k_debug_cal_data_release(struct inode *inode,
-- 
2.7.4



Re: [v3 PATCH 1/2] rhashtable: Add rhlist interface

2016-09-19 Thread Herbert Xu
On Mon, Sep 19, 2016 at 11:16:21PM +0200, Thomas Graf wrote:
>
> Nice, I like how this simplifies users! Is this suitable for
> ILA as well?

Does it have duplicate objects and use inelastic_security? If so
then yes it should switch over to rhlist.

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [PATCH] mwifiex: parse device tree node for PCIe

2016-09-19 Thread Rob Herring
On Fri, Sep 09, 2016 at 08:47:34PM +0530, Amitkumar Karwar wrote:
> From: Xinming Hu 
> 
> This patch derives device tree node from pcie bus layer framework.
> Device tree bindings file has been renamed(marvell-sd8xxx.txt ->
> marvell-8xxx.txt) to accomodate PCIe changes.
> 
> Signed-off-by: Xinming Hu 
> Signed-off-by: Amitkumar Karwar 
> ---
>  .../bindings/net/wireless/marvell-8xxx.txt | 64 
> ++
>  .../bindings/net/wireless/marvell-sd8xxx.txt   | 63 -

Resend using -M option so I do have to figure out if you added 1 line or 
changed a bunch.

>  drivers/net/wireless/marvell/mwifiex/pcie.c| 19 +++
>  drivers/net/wireless/marvell/mwifiex/sta_cmd.c |  3 +-
>  4 files changed, 85 insertions(+), 64 deletions(-)
>  create mode 100644 
> Documentation/devicetree/bindings/net/wireless/marvell-8xxx.txt
>  delete mode 100644 
> Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt
> 
> diff --git a/Documentation/devicetree/bindings/net/wireless/marvell-8xxx.txt 
> b/Documentation/devicetree/bindings/net/wireless/marvell-8xxx.txt
> new file mode 100644
> index 000..a8a95aa
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/wireless/marvell-8xxx.txt
> @@ -0,0 +1,64 @@
> +Marvell 8897/8997 (sd8897/sd8997/pcie8997) SDIO/PCIE devices
> +--
> +
> +This node provides properties for controlling the marvell sdio/pcie wireless 
> device.
> +The node is expected to be specified as a child node to the SDIO/PCIE 
> controller that
> +connects the device to the system.
> +
> +Required properties:
> +
> +  - compatible : should be one of the following:
> + * "marvell,sd8897"
> + * "marvell,sd8997"
> + * "marvell,pcie8997"

PCIe uses vendor and product IDs for compatible strings. Please read the 
OF PCI bus bindings doc.

Rob


Re: [v3 PATCH 1/2] rhashtable: Add rhlist interface

2016-09-19 Thread Thomas Graf
On 09/19/16 at 07:00pm, Herbert Xu wrote:
> The insecure_elasticity setting is an ugly wart brought out by
> users who need to insert duplicate objects (that is, distinct
> objects with identical keys) into the same table.
> 
> In fact, those users have a much bigger problem.  Once those
> duplicate objects are inserted, they don't have an interface to
> find them (unless you count the walker interface which walks
> over the entire table).
> 
> Some users have resorted to doing a manual walk over the hash
> table which is of course broken because they don't handle the
> potential existence of multiple hash tables.  The result is that
> they will break sporadically when they encounter a hash table
> resize/rehash.
> 
> This patch provides a way out for those users, at the expense
> of an extra pointer per object.  Essentially each object is now
> a list of objects carrying the same key.  The hash table will
> only see the lists so nothing changes as far as rhashtable is
> concerned.
> 
> To use this new interface, you need to insert a struct rhlist_head
> into your objects instead of struct rhash_head.  While the hash
> table is unchanged, for type-safety you'll need to use struct
> rhltable instead of struct rhashtable.  All the existing interfaces
> have been duplicated for rhlist, including the hash table walker.
> 
> One missing feature is nulls marking because AFAIK the only potential
> user of it does not need duplicate objects.  Should anyone need
> this it shouldn't be too hard to add.
> 
> Signed-off-by: Herbert Xu 

Nice, I like how this simplifies users! Is this suitable for
ILA as well?

Acked-by: Thomas Graf 



Re: [PATCH 2/4] carl9170: fix debugfs crashes

2016-09-19 Thread Christian Lamparter
On Sunday, September 18, 2016 6:44:08 PM CEST Greg KH wrote:
> On Sun, Sep 18, 2016 at 02:49:33PM +0200, Christian Lamparter wrote:
> > On Sunday, September 18, 2016 12:14:55 PM CEST Greg KH wrote:
> > > On Sun, Sep 18, 2016 at 10:54:18AM +0300, Kalle Valo wrote:
> > > > Greg KH  writes:
> > > > 
> > > > > On Sat, Sep 17, 2016 at 09:43:02PM +0200, Christian Lamparter wrote:
> > > > >> Ben Greear reported:
> > > > >> > I see lots of instability as soon as I load up the carl9710 NIC.
> > > > >> > My application is going to be poking at it's debugfs files...
> > > > >> >
> > > > >> > BUG: KASAN: slab-out-of-bounds in carl9170_debugfs_read+0xd5/0x2a0
> > > > >> > [carl9170] at addr 8801bc1208b0
> > > > >> > Read of size 8 by task btserver/5888
> > > > >> > ===
> > > > >> > BUG kmalloc-256 (Tainted: GW  ): kasan: bad access 
> > > > >> > detected
> > > > >> > ---
> > > > >> >
> > > > >> > INFO: Allocated in seq_open+0x50/0x100 age=2690 cpu=2 pid=772
> > > > >> >...
> > > > >> 
> > > > >> This breakage was caused by the introduction of intermediate
> > > > >> fops in debugfs by commit 9fd4dcece43a
> > > > >> ("debugfs: prevent access to possibly dead file_operations at file 
> > > > >> open")
> > > > >
> > > > > Because of this, these should all be backported to 4.7-stable, and
> > > > > 4.8-stable, right?
> > Ok, only b43legacy has debugfs enabled by default. For b43 and carl9170 
> > debugfs support is usually disabled.
> > 
> > Greg, would you take these four patches "as is" for -stable
> > or do you want a "minimal version" which just replaces the
> > 
> > dfops = container_of(file->f_op, ...
> > 
> > with
> > 
> > dfops = container_of(file->f_path.dentry->d_fsdata, ...
> > 
> > in the three drivers for -stable?
> 
> No, I'll take this as is, we want things to remain as close as possible
> to Linus's tree.  When we are not, is when things break.
> 
> > > > Via which tree should these go, Greg's or mine?
> > > 
> > > I'll take it if you ack it, as it's a debugfs issue.
> > For carl9170: Ben Greear has reported:
> > "I have verified this fixes my problem in the 4.7 kernel."
> > 
> > But this was with a preliminary/minimal version so I didn't
> > add the tested-by tag.
> > 
> > As for b43, I'll see if I have a working b43 in my collection
> > somewhere to confirm the issue and the fix. Question is, do
> > you want to wait or not?
> 
> I'll queue these up this week, no rush.

I was able to sucessfully test the b43 patch on my iBook G4's BCM4306.

Thanks,

Christian


RTL8192EU on rtl8xxxu driver breaks every few minutes

2016-09-19 Thread Franc[e]sco
Hi, I happen to own a RTL8192EU WiFi dongle which is marked as untested
by the rtl8xxxu driver.

I'm on a linux from scratch system using kernel 4.7.3 and wpa_supplicant
2.5.

The dongle appears to connect and work fine, but after around 10 minutes
it deauthenticates and enters and endless loop of authentication
timeout. This continues even if I bring the interface down and back up
again. The only way to restore the connection is to physically remove
and re-plug the usb dongle.

I have attached a dmesg log of connecting and entering the auth loop.

[ 6622.717543] usb 2-1.7: new high-speed USB device number 12 using ehci-pci
[ 6622.803640] usb 2-1.7: New USB device found, idVendor=0bda, idProduct=818b
[ 6622.804026] usb 2-1.7: New USB device strings: Mfr=1, Product=2, SerialNumber
=3
[ 6622.804417] usb 2-1.7: Product: 802.11n NIC
[ 6622.804816] usb 2-1.7: Manufacturer: Realtek
[ 6622.805215] usb 2-1.7: SerialNumber: 00e04c01
[ 6622.805905] usb 2-1.7: This Realtek USB WiFi dongle (0x0bda:0x818b) is untest
ed!
[ 6622.806332] usb 2-1.7: Please report results to jes.soren...@gmail.com
[ 6622.970016] usb 2-1.7: Vendor: Realtek
[ 6622.970454] usb 2-1.7: Product: 802.11n NIC
[ 6622.970897] usb 2-1.7: Serial: ���
[ 6622.971339] usb 2-1.7: rtl8192eu_parse_efuse: dumping efuse (0x200 bytes):
[ 6622.971802] usb 2-1.7: 00: 29 81 00 7c 01 40 03 00
[ 6622.972269] usb 2-1.7: 08: 40 74 04 50 14 00 00 00
[ 6622.972735] usb 2-1.7: 10: 21 20 1f 23 23 23 2d 2c
[ 6622.973202] usb 2-1.7: 18: 2b 2d 2d ff ef ef ff ff
[ 6622.973671] usb 2-1.7: 20: ff ff ff ff ff ff ff ff
[ 6622.974135] usb 2-1.7: 28: ff ff ff ff ff ff ff ff
[ 6622.974598] usb 2-1.7: 30: ff ff ff ff ff ff ff ff
[ 6622.975052] usb 2-1.7: 38: ff ff 1f 1d 1c 1e 1e 1e
[ 6622.975504] usb 2-1.7: 40: 2a 29 28 29 29 ff ef ef
[ 6622.975957] usb 2-1.7: 48: ff ff ff ff ff ff ff ff
[ 6622.976412] usb 2-1.7: 50: ff ff ff ff ff ff ff ff
[ 6622.976861] usb 2-1.7: 58: ff ff ff ff ff ff ff ff
[ 6622.977308] usb 2-1.7: 60: ff ff ff ff ff ff ff ff
[ 6622.977759] usb 2-1.7: 68: ff ff ff ff ff ff ff ff
[ 6622.978202] usb 2-1.7: 70: ff ff ff ff ff ff ff ff
[ 6622.978641] usb 2-1.7: 78: ff ff ff ff ff ff ff ff
[ 6622.979073] usb 2-1.7: 80: ff ff ff ff ff ff ff ff
[ 6622.979501] usb 2-1.7: 88: ff ff ff ff ff ff ff ff
[ 6622.979926] usb 2-1.7: 90: ff ff ff ff ff ff ff ff
[ 6622.980343] usb 2-1.7: 98: ff ff ff ff ff ff ff ff
[ 6622.980760] usb 2-1.7: a0: ff ff ff ff ff ff ff ff
[ 6622.981174] usb 2-1.7: a8: ff ff ff ff ff ff ff ff
[ 6622.981588] usb 2-1.7: b0: ff ff ff ff ff ff ff ff
[ 6622.982002] usb 2-1.7: b8: 20 0d ff 00 33 88 ff ff
[ 6622.982421] usb 2-1.7: c0: ff 01 20 13 00 00 00 ff
[ 6622.982848] usb 2-1.7: c8: 00 00 ff ff ff ff ff ff
[ 6622.983275] usb 2-1.7: d0: da 0b 8b 81 e7 47 02 00
[ 6622.983711] usb 2-1.7: d8: 19 88 00 1e 33 09 03 52
[ 6622.984150] usb 2-1.7: e0: 65 61 6c 74 65 6b 0d 03
[ 6622.984594] usb 2-1.7: e8: 38 30 32 2e 31 31 6e 20
[ 6622.985045] usb 2-1.7: f0: 4e 49 43 00 ff ff ff ff
[ 6622.985500] usb 2-1.7: f8: ff ff ff ff ff ff ff ff
[ 6622.985960] usb 2-1.7: 100: ff ff ff ff ff ff ff ff
[ 6622.986423] usb 2-1.7: 108: ff ff ff ff ff ff ff ff
[ 6622.986889] usb 2-1.7: 110: ff ff ff ff ff ff ff 0d
[ 6622.987354] usb 2-1.7: 118: 03 00 05 00 30 00 00 00
[ 6622.987827] usb 2-1.7: 120: 00 93 ff ff ff ff ff ff
[ 6622.988302] usb 2-1.7: 128: ff ff ff ff ff ff ff ff
[ 6622.988779] usb 2-1.7: 130: f6 a8 98 2d 03 92 98 00
[ 6622.989262] usb 2-1.7: 138: fc 8c 00 11 9b 44 02 0a
[ 6622.989750] usb 2-1.7: 140: ff ff ff ff ff ff ff ff
[ 6622.990243] usb 2-1.7: 148: ff ff ff ff ff ff ff ff
[ 6622.990736] usb 2-1.7: 150: ff ff ff ff ff ff ff ff
[ 6622.991214] usb 2-1.7: 158: ff ff ff ff ff ff ff ff
[ 6622.991679] usb 2-1.7: 160: ff ff ff ff ff ff ff ff
[ 6622.992133] usb 2-1.7: 168: ff ff ff ff ff ff ff ff
[ 6622.992580] usb 2-1.7: 170: ff ff ff ff ff ff ff ff
[ 6622.993013] usb 2-1.7: 178: ff ff ff ff ff ff ff ff
[ 6622.993437] usb 2-1.7: 180: ff ff ff ff ff ff ff ff
[ 6622.993847] usb 2-1.7: 188: ff ff ff ff ff ff ff ff
[ 6622.994254] usb 2-1.7: 190: ff ff ff ff ff ff ff ff
[ 6622.994653] usb 2-1.7: 198: ff ff ff ff ff ff ff ff
[ 6622.995035] usb 2-1.7: 1a0: ff ff ff ff ff ff ff ff
[ 6622.995409] usb 2-1.7: 1a8: ff ff ff ff ff ff ff ff
[ 6622.995774] usb 2-1.7: 1b0: ff ff ff ff ff ff ff ff
[ 6622.996129] usb 2-1.7: 1b8: ff ff ff ff ff ff ff ff
[ 6622.996479] usb 2-1.7: 1c0: ff ff ff ff ff ff ff ff
[ 6622.996827] usb 2-1.7: 1c8: ff ff ff ff ff ff ff ff
[ 6622.997161] usb 2-1.7: 1d0: ff ff ff ff ff ff ff ff
[ 6622.997483] usb 2-1.7: 1d8: ff ff ff ff ff ff ff ff
[ 6622.997798] usb 2-1.7: 1e0: ff ff ff ff ff ff ff ff
[ 6622.998109] usb 2-1.7: 1e8: ff ff ff ff ff ff ff ff
[ 6622.998413] usb 2-1.7: 1f0: ff ff ff ff ff ff ff ff
[ 6622.998711] usb 2-1.7: 1f8: ff ff ff ff ff ff ff ff
[ 6622.998996] usb 2-1.7: RTL8192EU rev B (SMIC) 2T2R, TX queues 3, WiFi=1, BT=0
, GPS=0, HI PA=0
[ 6622.999302] usb 2-1.7: RTL8192EU MAC: 00:19:88:00:1e:33
[ 6622.999606] usb 2-1.7: rtl8xxxu: Load

Re: nl80211 fine timing measurement support

2016-09-19 Thread Johannes Berg
> > However I did not see any comments or response on this
> > patch. Can you please update if you plan on eventually submitting
> > this patch?
> 
> You can find several FTM related patches in backport-iwlwifi repo on
> kernel.org. See link to git log of nl80211.h there [1].
> 

You can find things there, but they might not be the most organized
always :)

Anyway, I think after Luca is handling the current round of NaN
submission he'll have the cycles to deal with FTM - I'll let him
comment. For all I care, they can also run in parallel, but that might
be more difficult for him.

johannes


Re: nl80211 fine timing measurement support

2016-09-19 Thread Arend Van Spriel


On 19-9-2016 19:31, Lior David wrote:
> Hi Johannes,
> 
> We are working on adding indoor location support to the wil6210 11ad driver. 
> This includes fine timing measurement (FTM) as well as something we call 
> angle of arrival (AOA) which measures azimuth and elevation.
> Initially we implemented it internally using vendor commands but we would 
> like to upstream it using standard nl80211 API.
> I noticed a patch you sent some time ago 
> (https://patchwork.kernel.org/patch/7790701/) for adding fine timing 
> measurement support to nl80211, it looks like a good baseline though we do 
> have few issues with it... However I did not see any comments or response on 
> this patch. Can you please update if you plan on eventually submitting this 
> patch?

You can find several FTM related patches in backport-iwlwifi repo on
kernel.org. See link to git log of nl80211.h there [1].

Regards,
Arend

[1]
https://git.kernel.org/cgit/linux/kernel/git/iwlwifi/backport-iwlwifi.git/log/include/uapi/linux/nl80211.h


Re: brcmfmac MAC address change delay and 500ms down delay

2016-09-19 Thread Arend Van Spriel
On 19-9-2016 16:48, Dan Williams wrote:
> On Fri, 2016-09-16 at 11:58 +0200, Arend Van Spriel wrote:
>> On 15-9-2016 16:42, Dan Williams wrote:
>>>
>>> Hi,
>>>
>>> While refining NetworkManager's MAC address randomization behavior
>>> we
>>> came across two issues with brcmfmac:
>>>
>>> 1) when changing the MAC address, the driver schedules work for the
>>> new
>>> change and returns success, but doesn't actually change the MAC
>>> until
>>> the work is scheduled.  Because it returns 0 from the
>>> ndo_set_mac_address hook the net core will generate a
>>> NETDEV_CHANGEADDR
>>> event and rtnetlink will send out an RTM_NEWLINK with the old MAC
>>> address.  No event for the new address will be sent.  So it's
>>> pretty
>>> hard to figure out when the address actually changed, and when its
>>> safe
>>> to associate, without polling the device's MAC address.  Ugly.
>> And apparently unnecessary. I recalled we had this as the
>> ndo_set_mac_address callback could be called in atomic context. So we
>> are using a worker because we are grabbing a mutex upon sending the
>> control info to the device. Looking into the core network code it
>> seems
>> the callback is not called in atomic context so it seems we can get
>> rid
>> of the worker here. I made a patch
>>
>>>
>>> 2) when closing the device (eg, set !IFF_UP) the driver
>>> unconditionally
>>> blocks for 500ms in __brcmf_cfg80211_down():
>>>
>>> if (check_vif_up(ifp->vif)) {
>>> brcmf_link_down(ifp->vif, WLAN_REASON_UNSPECIFIED);
>>>
>>> /* Make sure WPA_Supplicant receives all the event
>>>generated due to DISASSOC call to the fw to keep
>>>the state fw and WPA_Supplicant state consistent
>>>  */
>>> brcmf_delay(500);
>>> }
>> This is actually a bogus delay as we are under an RTNL lock here so I
>> think the events will not go out until after the delay has finished.
>> I
>> did submit a patch long ago removing this delay, but the change was
>> not
>> accepted. Let me revisit that.
>>
>>>
>>> Should I dump these into kernel bugzilla, or is there some internal
>>> bug
>>> tracker they could get stuffed into?
>> Kernel bugzilla is fine although I check it rather infrequently.
> 
> Thanks for taking another look at these.  Should I still file in
> bugzilla, or are the patches going through the process already?

For the mac address delay I let this [1] one fly today. A pity
git-send-email does not add the 'Reported-by:' email to the Cc:

The other one is a bit more tricky. The 500ms delay can be removed, but
I need to fix a related scenario. Working on it.

Regards,
Arend

[1] 1474283399-14385-6-git-send-email-arend.vanspr...@broadcom.com


nl80211 fine timing measurement support

2016-09-19 Thread Lior David
Hi Johannes,

We are working on adding indoor location support to the wil6210 11ad driver. 
This includes fine timing measurement (FTM) as well as something we call angle 
of arrival (AOA) which measures azimuth and elevation.
Initially we implemented it internally using vendor commands but we would like 
to upstream it using standard nl80211 API.
I noticed a patch you sent some time ago 
(https://patchwork.kernel.org/patch/7790701/) for adding fine timing 
measurement support to nl80211, it looks like a good baseline though we do have 
few issues with it... However I did not see any comments or response on this 
patch. Can you please update if you plan on eventually submitting this patch?

Thanks,
Lior


Re: [PATCH] rsi: fix memory leak in debugfs entry and supported bands

2016-09-19 Thread Heinrich Schuchardt
On 09/19/2016 12:51 PM, Prameela Rani Garnepudi wrote:
> From: Prameela Rani Garnepudi 
> 
> Signed-off-by: Prameela Rani Garnepudi 
> ---
>  drivers/net/wireless/rsi/rsi_91x_mac80211.c | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/net/wireless/rsi/rsi_91x_mac80211.c 
> b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
> index dbb2389..dc64532 100644
> --- a/drivers/net/wireless/rsi/rsi_91x_mac80211.c
> +++ b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
> @@ -194,6 +194,7 @@ static void rsi_register_rates_channels(struct rsi_hw 
> *adapter, int band)
>  void rsi_mac80211_detach(struct rsi_hw *adapter)
>  {
>   struct ieee80211_hw *hw = adapter->hw;
> + int i;
>  
>   if (hw) {
>   ieee80211_stop_queues(hw);
> @@ -201,7 +202,16 @@ void rsi_mac80211_detach(struct rsi_hw *adapter)
>   ieee80211_free_hw(hw);
>   }
>  
> + for (i = 0; i < 2; i++) {
> + struct ieee80211_supported_band *sbands = &adapter->sbands[i];
> +
> + kfree(sbands->channels);
> + }
> +
> +#ifdef CONFIG_RSI_DEBUGFS
>   rsi_remove_dbgfs(adapter);
> + kfree(adapter->dfsentry);
> +#endif
>  }
>  EXPORT_SYMBOL_GPL(rsi_mac80211_detach);
>  
> 

Please, use
  git format-patch -ns HEAD~1..HEAD
to create the patch message and
  git send-email
to post your patch including your commit message.

Best regards

Heinrich


Re: [PATCH 0/9] brcmfmac: coverity fixes

2016-09-19 Thread Florian Fainelli
On 09/19/2016 04:09 AM, Arend van Spriel wrote:
> This series consist of:
> * fixes for several issues found by Coverity.
> * ignore 802.11d configuration if not supported in firmware.
> * remove worker from netdev callback.

Thanks for doing this, can you also provide the coverity id when
relevant? Something like:

Reported-by: coverity (CID #12345678)

Which can help with automated tools hooking to coverity for managing the
lifecycle of the report.

Thanks!

> 
> This is intended for 4.9 and applies to the master branch of
> the wireless-drivers-next repository.
> 
> Arend van Spriel (4):
>   brcmfmac: rework pointer trickery in brcmf_proto_bcdc_query_dcmd()
>   brcmfmac: fix memory leak in brcmf_flowring_add_tdls_peer()
>   brcmfmac: initialize variable in brcmf_sdiod_regrl()
>   brcmfmac: remove worker from .ndo_set_mac_address() callback
> 
> Hante Meuleman (5):
>   brcmfmac: ignore 11d configuration errors
>   brcmfmac: remove unnecessary null pointer check
>   brcmfmac: fix clearing entry IPv6 address
>   brcmfmac: fix out of bound access on clearing wowl wake indicator
>   brcmfmac: simplify mapping of auth type
> 
>  .../wireless/broadcom/brcm80211/brcmfmac/bcdc.c|  2 +-
>  .../wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c  |  2 +-
>  .../broadcom/brcm80211/brcmfmac/cfg80211.c | 41 +-
>  .../wireless/broadcom/brcm80211/brcmfmac/core.c| 49 
> +-
>  .../wireless/broadcom/brcm80211/brcmfmac/core.h|  2 -
>  .../broadcom/brcm80211/brcmfmac/flowring.c |  8 +++-
>  6 files changed, 47 insertions(+), 57 deletions(-)
> 


-- 
Florian


[PATCH V2] rtl8xxxu: Stop log spam from each successful interrupt

2016-09-19 Thread Larry Finger
As soon as debugging is turned on, the logs are filled with messages
reporting the interrupt status. As this quantity is usually zero, this
output is not needed. In fact, there will be a report if the status is
not zero, thus the debug line in question could probably be deleted.
Rather than taking that action, I have changed it to only be printed
when the newly added RTL8XXXU_DEBUG_INTERRUPT bit is set in the debug
mask.

Signed-off-by: Larry Finger 
---
V2 - Added new debugging flag as requested by Jes.
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h  | 1 +
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index 870c9cd..4508b6d 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -29,6 +29,7 @@
 #define RTL8XXXU_DEBUG_H2C 0x800
 #define RTL8XXXU_DEBUG_ACTION  0x1000
 #define RTL8XXXU_DEBUG_EFUSE   0x2000
+#define RTL8XXXU_DEBUG_INTERRUPT   0x4000
 
 #define RTW_USB_CONTROL_MSG_TIMEOUT500
 #define RTL8XXXU_MAX_REG_POLL  500
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 9f6dbb4..efba8f1 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -5260,7 +5260,8 @@ static void rtl8xxxu_int_complete(struct urb *urb)
struct device *dev = &priv->udev->dev;
int ret;
 
-   dev_dbg(dev, "%s: status %i\n", __func__, urb->status);
+   if (rtl8xxxu_debug & RTL8XXXU_DEBUG_INTERRUPT)
+   dev_dbg(dev, "%s: status %i\n", __func__, urb->status);
if (urb->status == 0) {
usb_anchor_urb(urb, &priv->int_anchor);
ret = usb_submit_urb(urb, GFP_ATOMIC);
-- 
2.6.6



Re: [PATCH] cfg80211: cap 20MHz VHT bitrate at MCS 8

2016-09-19 Thread Ben Greear

On 09/19/2016 02:00 AM, Johannes Berg wrote:



Actually, can you apply the v2 (cfg80211: add bitrate for 20MHz MCS
9) of this? Systems guys confirmed they use MCS 9 @ 20MHz when LDPC
is enabled. Also confirmed bitrate should be ok.


I don't really understand that. How can the bitrate be "OK" when the
spec explicitly says it cannot be used?

johannes



I think it is a moot point as far as this change goes:  Regardless of whether
the NIC should or not, it _does_.  So, mis-reporting it up the stack only hides
the issue and does not even give the user a clue that on-the-air encoding may be
slightly off-spec.

If the on-air encoding is an issue, then we need to hack the firmware to
disable this 'feature', but that is a completely separate issue.

Once this patch goes in, someone might consider properly reporting CCK
rx rates for 5Ghz band too:  ath10k can do this 'feature' as well, at least
in some firmware.  Probably can reproduce by sending off-channel mgt frames on
5Ghz when associated on 2.4, or something similar to this.  I was using ath9k as
sniffer when I found this long ago, so at least ath9k needs the change

Thanks,
Ben

--
Ben Greear 
Candela Technologies Inc  http://www.candelatech.com



Re: brcmfmac MAC address change delay and 500ms down delay

2016-09-19 Thread Dan Williams
On Fri, 2016-09-16 at 11:58 +0200, Arend Van Spriel wrote:
> On 15-9-2016 16:42, Dan Williams wrote:
> > 
> > Hi,
> > 
> > While refining NetworkManager's MAC address randomization behavior
> > we
> > came across two issues with brcmfmac:
> > 
> > 1) when changing the MAC address, the driver schedules work for the
> > new
> > change and returns success, but doesn't actually change the MAC
> > until
> > the work is scheduled.  Because it returns 0 from the
> > ndo_set_mac_address hook the net core will generate a
> > NETDEV_CHANGEADDR
> > event and rtnetlink will send out an RTM_NEWLINK with the old MAC
> > address.  No event for the new address will be sent.  So it's
> > pretty
> > hard to figure out when the address actually changed, and when its
> > safe
> > to associate, without polling the device's MAC address.  Ugly.
> And apparently unnecessary. I recalled we had this as the
> ndo_set_mac_address callback could be called in atomic context. So we
> are using a worker because we are grabbing a mutex upon sending the
> control info to the device. Looking into the core network code it
> seems
> the callback is not called in atomic context so it seems we can get
> rid
> of the worker here. I made a patch
> 
> > 
> > 2) when closing the device (eg, set !IFF_UP) the driver
> > unconditionally
> > blocks for 500ms in __brcmf_cfg80211_down():
> > 
> > if (check_vif_up(ifp->vif)) {
> > brcmf_link_down(ifp->vif, WLAN_REASON_UNSPECIFIED);
> > 
> > /* Make sure WPA_Supplicant receives all the event
> >    generated due to DISASSOC call to the fw to keep
> >    the state fw and WPA_Supplicant state consistent
> >  */
> > brcmf_delay(500);
> > }
> This is actually a bogus delay as we are under an RTNL lock here so I
> think the events will not go out until after the delay has finished.
> I
> did submit a patch long ago removing this delay, but the change was
> not
> accepted. Let me revisit that.
> 
> > 
> > Should I dump these into kernel bugzilla, or is there some internal
> > bug
> > tracker they could get stuffed into?
> Kernel bugzilla is fine although I check it rather infrequently.

Thanks for taking another look at these.  Should I still file in
bugzilla, or are the patches going through the process already?

Dan


Problem with 40Mhz on 2.5GHz with Intel 8260

2016-09-19 Thread Volker Mische
Hi,

I'm having connectivity issues with an Intel 8260 on a 2.5GHz network
when using 40Mhz. I'm getting errors like

Queue 2 stuck for 1 ms.

I've upgrade my system to the firmware version 21 (21.373438.0) and
Kernel 4.8.0-rc6 in hope that it fixes the issue and to be able to debug
the problem.

I then found the page about platform noise [1]. I don't have any issue
for several hours now (normally I was hitting the issue every few
minutes) as I've set the cfg80211_disable_40mhz_24ghz parameter.

Now I wonder, is it worth debugging the issue with being on 40MHz or is
disabling the proper solution and I should bother.

[1]:
https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi#about_platform_noise

Cheers,
  Volker


Re: staging: wilc1000: kernel Oops while opening the device

2016-09-19 Thread Greg Kroah-Hartman
On Mon, Sep 19, 2016 at 02:06:02PM +0200, Nicolas Ferre wrote:
> Hi all,
> 
> While using the wilc1000 driver with latest 4.8-rc7, I
> have difficulties to open the device and actually use it as I have
> this kernel Oops right after the loading of the firmware 
> (wilc1003_firmware.bin).
> 
> If I revert back the driver to its b9811891a9f60ca9c314dcab3244c65930c4cf37 
> state,
> it works okay. I did this because I tend to think that it might be related to 
> the latest
> move on this driver to "completion" or "work queues".
> It seems to be a regression from 4.7.

Ick, not good at all.

Any chance you can run 'git bisect' to see if you can find the offending
patch?

I thought the maintainers were testing this driver over time :(

thanks,

greg k-h


Re: [athk9] beacon.c:642 ath9k_calculate_summary_state dump

2016-09-19 Thread Vidar Haarr
On Sat, Sep 17, 2016 at 3:29 PM, Kalle Valo  wrote:
> Vidar Haarr  writes:
>> sep. 17 11:38:36 edbpc kernel: WARNING: CPU: 0 PID: 1684 at
>> /home/kernel/COD/linux/drivers/net/wireless/ath/ath9k/beacon.c:642
>> ath9k_calculate_summary_state+0x135/0x390 [ath9k]
>
> Looks like exactly the same problem, but the fix (below) is not in
> v4.8-rc6. Should be in -rc7 which Linus hopefully releases on Sunday.
> Please test that and report if the problem continues.

Indeed, I did not check to see if -rc6 included it specifically, I
just checked github.com/torvalds/linux master branch to see if the fix
was there just before I sent the email to linux-wireless.
-rc7 seems to have resolved the issue.

Thank you,
-- 
Vidar


staging: wilc1000: kernel Oops while opening the device

2016-09-19 Thread Nicolas Ferre
Hi all,

While using the wilc1000 driver with latest 4.8-rc7, I
have difficulties to open the device and actually use it as I have
this kernel Oops right after the loading of the firmware 
(wilc1003_firmware.bin).

If I revert back the driver to its b9811891a9f60ca9c314dcab3244c65930c4cf37 
state,
it works okay. I did this because I tend to think that it might be related to 
the latest
move on this driver to "completion" or "work queues".
It seems to be a regression from 4.7.

It's on my ARM platform sama5d2 Xplained.

Here is the log:

---

root@sama5d2-xplained:~# ifup wlan0
Successfully initialized wpa_supplicant
wilc1000_sdio mmc1:0001:1: chipid (001003a0)
wilc1000_sdio mmc1:0001:1: has_thrpt_enh3 = 1...
wilc1000_sdio mmc1:0001:1 wlan0: loading firmware atmel/wilc1003_firmware.bin
Unable to handle kernel NULL pointer dereference at virtual address 0010
pgd = d4608000
[0010] *pgd=34671831, *pte=, *ppte=
Internal error: Oops: 17 [#1] ARM
Modules linked in: wilc1000_sdio(C) wilc1000(C)
CPU: 0 PID: 365 Comm: wpa_supplicant Tainted: G C  4.8.0-rc7 #231
Hardware name: Atmel SAMA5
task: d463dbc0 task.stack: d462e000
PC is at __queue_work+0x98/0x29c
LR is at __queue_work+0x60/0x29c
pc : []lr : []psr: 6093
sp : d462fc68  ip : a093  fp : 0014
r10:   r9 : 0001  r8 : c0a0812c
r7 : c0a2f098  r6 : d444a900  r5 : d4663374  r4 : 
r3 : 0006000a  r2 : d4663374  r1 : 07ff  r0 : 
Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment none
Control: 10c53c7d  Table: 34608059  DAC: 0051
Process wpa_supplicant (pid: 365, stack limit = 0xd462e208)
Stack: (0xd462fc68 to 0xd463)
fc60:   c0a0bbc0 c985 a013 ffe1  d461a460
fc80:  d444a500 8914 c0127298 d4663200 d461a460 0001 bf0076b4
fca0: fe7c bf0082b4  0018 0001   
fcc0:        
fce0:        
fd00:        
fd20:        
fd40:        
fd60:        
fd80:        
fda0:        
fdc0:        
fde0:        
fe00:        d461a460
fe20:     d461a000 d461a800  bf00509c
fe40: 0001  d461a000 bf00dde0 0001 1002  c04fde98
fe60: d461a000 d461a000 0001 d461a000 1003 c04fe128 d461a000 0148
fe80: 1002 0001  c04fe204  d444a50c  0001
fea0:  c0557d5c 0020  bebd28f0 bebd28f0 d444a50c d461a000
fec0: 6e616c77 0030   1003   
fee0: 1002 8914 bebd28f0 d0164000 bebd28f0 d43ceb40 d462e000 bebd28f0
ff00: d0164020 c04e40a0 0005 d43ceb40 8914 c01b16e0 d43ce008 0020
ff20: 0001 0001   d4418d80 d43ce000 0008 d4028ba8
ff40: d43ce000 0008 bebd2950 d462ff80 0008 c01a1a1c  
ff60: d43ce000   d43ceb40 d43ceb40 8914 bebd28f0 0005
ff80: d462e000  000f0c70 c01b1ef0  0005 0001 0036
ffa0: c01076e4 c0107520  0005 0005 8914 bebd28f0 1003
ffc0:  0005 0001 0036 0011959d 001195b9 0005 000f0c70
ffe0: 001019bc bebd28e4 000b4660 b6c761fc 600c0010 0005  
[] (__queue_work) from [] (queue_work_on+0x34/0x40)
[] (queue_work_on) from [] (wilc_enqueue_cmd+0x54/0x64 
[wilc1000])
[] (wilc_enqueue_cmd [wilc1000]) from [] 
(wilc_set_wfi_drv_handler+0x48/0x70 [wilc1000])
[] (wilc_set_wfi_drv_handler [wilc1000]) from [] 
(wilc_mac_open+0x214/0x250 [wilc1000])
[] (wilc_mac_open [wilc1000]) from [] 
(__dev_open+0xb8/0x11c)
[] (__dev_open) from [] (__dev_change_flags+0x94/0x158)
[] (__dev_change_flags) from [] (dev_change_flags+0x18/0x48)
[] (dev_change_flags) from [] (devinet_ioctl+0x6b4/0x788)
[] (devinet_ioctl) from [] (sock_ioctl+0x154/0x2cc)
[] (sock_ioctl) from [] (do_vfs_ioctl+0x9c/0x878)
[] (do_vfs_ioctl) from [] (SyS_ioctl+0x34/0x5c)
[] (SyS_ioctl) from [] (ret_fast_syscall+0x0/0x3c)
Code: e5932004 e1520006 01a04003 0aff (e5943010) 
---[ end trace b612328adaa6bf20 ]---
/etc/network/if-pre-up.d/wpa-supplicant: line 83:   365 Segmentation fault  
start-stop-daemon --start --quiet --name $WPA_SUP_PNAME --startas $WP

Re: [v3 PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Johannes Berg
On Mon, 2016-09-19 at 13:03 +0200, Johannes Berg wrote:
> On Mon, 2016-09-19 at 18:58 +0800, Herbert Xu wrote:
> > 
> > v3 fixes a bug in the remove path that causes the element count
> > to decrease when it shouldn't, leading to a gigantic hash table
> > when it underflows.
> > 
> Ok, with the BUG_ON() thrown in, this works in the test that was
> failing before. I'll run the entire suite again over lunch.
> 

Ok, the entire test suite passed (with the BUG_ON, but hey).

Dave, let me know what you want to do (or have done, as it may be).

Thanks,
johannes


Re: ath10k mesh mode issue

2016-09-19 Thread Michal Kazior
On 16 September 2016 at 12:56, Matteo Grandi  wrote:
> Hello all,
[...]
> [8.589474] ath10k_pci :07:00.0: qca988x hw2.0 (0x4100016c,
> 0x043222ff sub :) fw 10.2.4.70.54 fwapi 5 bdapi 1 htt-ver 2.1
> wmi-op 5 htt-op 2 cal otp max-sta 128 raw 0 hwcrypto 1 features
> no-p2p,raw-mode

The "raw-mode" here only hints the firmware is capable of raw mode
operation which needs to be explicitly enabled.


> [8.589491] ath10k_pci :07:00.0: debug 1 debugfs 1 tracing 0
> dfs 0 testmode 1
> [8.691670] ath: EEPROM regdomain: 0x0
> [8.691680] ath: EEPROM indicates default country code should be used
> [8.691686] ath: doing EEPROM country->regdmn map search
> [8.691695] ath: country maps to regdmn code: 0x3a
> [8.691702] ath: Country alpha2 being used: US
> [8.691706] ath: Regpair used: 0x3a
> [  176.983250] ath10k_pci :07:00.0: must load driver with
> rawmode=1 to add mesh interfaces
[...]
> - I've also tried to load the ath10k modules adding the parameter
> rowmode=1 but I had an error "rawmode unknown parameter"

Only ath10k_core needs to be loaded with rawmode=1.

You can check available module parameters with:
  modinfo ath10k_core
  modinfo ath10k_pci


Michał


Re: ath10k inoperatable after suspend

2016-09-19 Thread Michal Kazior
On 19 September 2016 at 00:52, Steffen Arntz  wrote:
> Hi at all,
>
> I have an QCA988X based card in my laptop and have some "issues" with
> it, that I was not experiencing with my previous ath9k based card.
>
> The main issue is, that after suspend to RAM the card seems to be
> "hung up" and only reloading ath10k_core and ath10k_pci helps to fix
> the problem.

Hmm.. just a guess - maybe PCI config space isn't well preserved over
suspend and reloading modules prompts the PCI subsys to reset it.


Michal


[PATCH 8/9] brcmfmac: fix out of bound access on clearing wowl wake indicator

2016-09-19 Thread Arend van Spriel
From: Hante Meuleman 

Clearing the wowl wakeindicator happens with a rather odd
construction where the string "clear" is used to set the iovar
wowl_wakeind. This was implemented incorrectly as it caused an
out of bound access. Use an intermediate variable of correct
length and copy string in that. Problem was found using coverity.

Reviewed-by: Arend Van Spriel 
Reviewed-by: Franky Lin 
Reviewed-by: Pieter-Paul Giesberts 
Signed-off-by: Hante Meuleman 
Signed-off-by: Arend van Spriel 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index c3b8f59..386ad7e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -3703,6 +3703,7 @@ static void brcmf_configure_wowl(struct 
brcmf_cfg80211_info *cfg,
 struct cfg80211_wowlan *wowl)
 {
u32 wowl_config;
+   struct brcmf_wowl_wakeind_le wowl_wakeind;
u32 i;
 
brcmf_dbg(TRACE, "Suspend, wowl config.\n");
@@ -3744,8 +3745,9 @@ static void brcmf_configure_wowl(struct 
brcmf_cfg80211_info *cfg,
if (!test_bit(BRCMF_VIF_STATUS_CONNECTED, &ifp->vif->sme_state))
wowl_config |= BRCMF_WOWL_UNASSOC;
 
-   brcmf_fil_iovar_data_set(ifp, "wowl_wakeind", "clear",
-sizeof(struct brcmf_wowl_wakeind_le));
+   memcpy(&wowl_wakeind, "clear", 6);
+   brcmf_fil_iovar_data_set(ifp, "wowl_wakeind", &wowl_wakeind,
+sizeof(wowl_wakeind));
brcmf_fil_iovar_int_set(ifp, "wowl", wowl_config);
brcmf_fil_iovar_int_set(ifp, "wowl_activate", 1);
brcmf_bus_wowl_config(cfg->pub->bus_if, true);
-- 
1.9.1



[PATCH 9/9] brcmfmac: simplify mapping of auth type

2016-09-19 Thread Arend van Spriel
From: Hante Meuleman 

The 802.11 standard only has four valid auth type configurations of which
our firmware only supports two, ie. Open System and Shared Key. Simplify
the mapping falling back to automatic for other types specified by
user-space.

Reviewed-by: Arend Van Spriel 
Reviewed-by: Franky Lin 
Reviewed-by: Pieter-Paul Giesberts 
Signed-off-by: Hante Meuleman 
Signed-off-by: Arend van Spriel 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 386ad7e..3b7c0f6 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -1595,15 +1595,9 @@ static s32 brcmf_set_auth_type(struct net_device *ndev,
val = 1;
brcmf_dbg(CONN, "shared key\n");
break;
-   case NL80211_AUTHTYPE_AUTOMATIC:
-   val = 2;
-   brcmf_dbg(CONN, "automatic\n");
-   break;
-   case NL80211_AUTHTYPE_NETWORK_EAP:
-   brcmf_dbg(CONN, "network eap\n");
default:
val = 2;
-   brcmf_err("invalid auth type (%d)\n", sme->auth_type);
+   brcmf_dbg(CONN, "automatic, auth type (%d)\n", sme->auth_type);
break;
}
 
-- 
1.9.1



[PATCH 4/9] brcmfmac: initialize variable in brcmf_sdiod_regrl()

2016-09-19 Thread Arend van Spriel
In case of an error the variable returned is uninitialized. The caller
will probably check the error code before using it, but better assure
it is set to zero.

Reviewed-by: Hante Meuleman 
Reviewed-by: Pieter-Paul Giesberts 
Signed-off-by: Arend van Spriel 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
index 03404cb..72139b5 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
@@ -420,7 +420,7 @@ u8 brcmf_sdiod_regrb(struct brcmf_sdio_dev *sdiodev, u32 
addr, int *ret)
 
 u32 brcmf_sdiod_regrl(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret)
 {
-   u32 data;
+   u32 data = 0;
int retval;
 
brcmf_dbg(SDIO, "addr:0x%08x\n", addr);
-- 
1.9.1



[PATCH 6/9] brcmfmac: remove unnecessary null pointer check

2016-09-19 Thread Arend van Spriel
From: Hante Meuleman 

in the function brcmf_bus_start() in the exception handling a
check is made to dermine whether ifp is null, though this is not
possible. Removing the unnessary check.

Reviewed-by: Arend Van Spriel 
Reviewed-by: Franky Lin 
Reviewed-by: Pieter-Paul Giesberts 
Signed-off-by: Hante Meuleman 
Signed-off-by: Arend van Spriel 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 77c4180..3394184 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -1048,8 +1048,7 @@ fail:
brcmf_fws_del_interface(ifp);
brcmf_fws_deinit(drvr);
}
-   if (ifp)
-   brcmf_net_detach(ifp->ndev, false);
+   brcmf_net_detach(ifp->ndev, false);
if (p2p_ifp)
brcmf_net_detach(p2p_ifp->ndev, false);
drvr->iflist[0] = NULL;
-- 
1.9.1



[PATCH 0/9] brcmfmac: coverity fixes

2016-09-19 Thread Arend van Spriel
This series consist of:
* fixes for several issues found by Coverity.
* ignore 802.11d configuration if not supported in firmware.
* remove worker from netdev callback.

This is intended for 4.9 and applies to the master branch of
the wireless-drivers-next repository.

Arend van Spriel (4):
  brcmfmac: rework pointer trickery in brcmf_proto_bcdc_query_dcmd()
  brcmfmac: fix memory leak in brcmf_flowring_add_tdls_peer()
  brcmfmac: initialize variable in brcmf_sdiod_regrl()
  brcmfmac: remove worker from .ndo_set_mac_address() callback

Hante Meuleman (5):
  brcmfmac: ignore 11d configuration errors
  brcmfmac: remove unnecessary null pointer check
  brcmfmac: fix clearing entry IPv6 address
  brcmfmac: fix out of bound access on clearing wowl wake indicator
  brcmfmac: simplify mapping of auth type

 .../wireless/broadcom/brcm80211/brcmfmac/bcdc.c|  2 +-
 .../wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c  |  2 +-
 .../broadcom/brcm80211/brcmfmac/cfg80211.c | 41 +-
 .../wireless/broadcom/brcm80211/brcmfmac/core.c| 49 +-
 .../wireless/broadcom/brcm80211/brcmfmac/core.h|  2 -
 .../broadcom/brcm80211/brcmfmac/flowring.c |  8 +++-
 6 files changed, 47 insertions(+), 57 deletions(-)

-- 
1.9.1



[PATCH 1/9] brcmfmac: ignore 11d configuration errors

2016-09-19 Thread Arend van Spriel
From: Hante Meuleman 

802.11d is not always supported by firmware anymore. Currently the
AP configuration of 11d will cause an abort if the ioctl set is
failing. This behavior is not correct and the error should be
ignored.

Reviewed-by: Arend Van Spriel 
Reviewed-by: Franky Lin 
Reviewed-by: Pieter-Paul Giesberts 
Signed-off-by: Hante Meuleman 
Signed-off-by: Arend van Spriel 
---
 .../broadcom/brcm80211/brcmfmac/cfg80211.c | 27 --
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 201a980..c3b8f59 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -4502,6 +4502,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct 
net_device *ndev,
u16 chanspec = chandef_to_chanspec(&cfg->d11inf, &settings->chandef);
bool mbss;
int is_11d;
+   bool supports_11d;
 
brcmf_dbg(TRACE, "ctrlchn=%d, center=%d, bw=%d, beacon_interval=%d, 
dtim_period=%d,\n",
  settings->chandef.chan->hw_value,
@@ -4514,11 +4515,16 @@ brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct 
net_device *ndev,
mbss = ifp->vif->mbss;
 
/* store current 11d setting */
-   brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_REGULATORY, &ifp->vif->is_11d);
-   country_ie = brcmf_parse_tlvs((u8 *)settings->beacon.tail,
- settings->beacon.tail_len,
- WLAN_EID_COUNTRY);
-   is_11d = country_ie ? 1 : 0;
+   if (brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_REGULATORY,
+ &ifp->vif->is_11d)) {
+   supports_11d = false;
+   } else {
+   country_ie = brcmf_parse_tlvs((u8 *)settings->beacon.tail,
+ settings->beacon.tail_len,
+ WLAN_EID_COUNTRY);
+   is_11d = country_ie ? 1 : 0;
+   supports_11d = true;
+   }
 
memset(&ssid_le, 0, sizeof(ssid_le));
if (settings->ssid == NULL || settings->ssid_len == 0) {
@@ -4577,7 +4583,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct 
net_device *ndev,
 
/* Parameters shared by all radio interfaces */
if (!mbss) {
-   if (is_11d != ifp->vif->is_11d) {
+   if ((supports_11d) && (is_11d != ifp->vif->is_11d)) {
err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_REGULATORY,
is_11d);
if (err < 0) {
@@ -4619,7 +4625,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct 
net_device *ndev,
brcmf_err("SET INFRA error %d\n", err);
goto exit;
}
-   } else if (WARN_ON(is_11d != ifp->vif->is_11d)) {
+   } else if (WARN_ON(supports_11d && (is_11d != ifp->vif->is_11d))) {
/* Multiple-BSS should use same 11d configuration */
err = -EINVAL;
goto exit;
@@ -4753,11 +4759,8 @@ static int brcmf_cfg80211_stop_ap(struct wiphy *wiphy, 
struct net_device *ndev)
brcmf_err("setting INFRA mode failed %d\n", err);
if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MBSS))
brcmf_fil_iovar_int_set(ifp, "mbss", 0);
-   err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_REGULATORY,
-   ifp->vif->is_11d);
-   if (err < 0)
-   brcmf_err("restoring REGULATORY setting failed %d\n",
- err);
+   brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_REGULATORY,
+ ifp->vif->is_11d);
/* Bring device back up so it can be used again */
err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_UP, 1);
if (err < 0)
-- 
1.9.1



[PATCH 5/9] brcmfmac: remove worker from .ndo_set_mac_address() callback

2016-09-19 Thread Arend van Spriel
As it turns out there is no need to use a worker for the callback
because it is not called from atomic context.

Reported-by: Dan Williams 
Reviewed-by: Hante Meuleman 
Reviewed-by: Pieter-Paul Giesberts 
Reviewed-by: Franky Lin 
Signed-off-by: Arend van Spriel 
---
 .../wireless/broadcom/brcm80211/brcmfmac/core.c| 39 --
 .../wireless/broadcom/brcm80211/brcmfmac/core.h|  2 --
 2 files changed, 13 insertions(+), 28 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 8d16f02..77c4180 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -136,27 +136,6 @@ static void _brcmf_set_multicast_list(struct work_struct 
*work)
  err);
 }
 
-static void
-_brcmf_set_mac_address(struct work_struct *work)
-{
-   struct brcmf_if *ifp;
-   s32 err;
-
-   ifp = container_of(work, struct brcmf_if, setmacaddr_work);
-
-   brcmf_dbg(TRACE, "Enter, bsscfgidx=%d\n", ifp->bsscfgidx);
-
-   err = brcmf_fil_iovar_data_set(ifp, "cur_etheraddr", ifp->mac_addr,
-  ETH_ALEN);
-   if (err < 0) {
-   brcmf_err("Setting cur_etheraddr failed, %d\n", err);
-   } else {
-   brcmf_dbg(TRACE, "MAC address updated to %pM\n",
- ifp->mac_addr);
-   memcpy(ifp->ndev->dev_addr, ifp->mac_addr, ETH_ALEN);
-   }
-}
-
 #if IS_ENABLED(CONFIG_IPV6)
 static void _brcmf_update_ndtable(struct work_struct *work)
 {
@@ -190,10 +169,20 @@ static int brcmf_netdev_set_mac_address(struct net_device 
*ndev, void *addr)
 {
struct brcmf_if *ifp = netdev_priv(ndev);
struct sockaddr *sa = (struct sockaddr *)addr;
+   int err;
 
-   memcpy(&ifp->mac_addr, sa->sa_data, ETH_ALEN);
-   schedule_work(&ifp->setmacaddr_work);
-   return 0;
+   brcmf_dbg(TRACE, "Enter, bsscfgidx=%d\n", ifp->bsscfgidx);
+
+   err = brcmf_fil_iovar_data_set(ifp, "cur_etheraddr", sa->sa_data,
+  ETH_ALEN);
+   if (err < 0) {
+   brcmf_err("Setting cur_etheraddr failed, %d\n", err);
+   } else {
+   brcmf_dbg(TRACE, "updated to %pM\n", sa->sa_data);
+   memcpy(ifp->mac_addr, sa->sa_data, ETH_ALEN);
+   memcpy(ifp->ndev->dev_addr, ifp->mac_addr, ETH_ALEN);
+   }
+   return err;
 }
 
 static void brcmf_netdev_set_multicast_list(struct net_device *ndev)
@@ -525,7 +514,6 @@ int brcmf_net_attach(struct brcmf_if *ifp, bool rtnl_locked)
/* set the mac address */
memcpy(ndev->dev_addr, ifp->mac_addr, ETH_ALEN);
 
-   INIT_WORK(&ifp->setmacaddr_work, _brcmf_set_mac_address);
INIT_WORK(&ifp->multicast_work, _brcmf_set_multicast_list);
INIT_WORK(&ifp->ndoffload_work, _brcmf_update_ndtable);
 
@@ -730,7 +718,6 @@ static void brcmf_del_if(struct brcmf_pub *drvr, s32 
bsscfgidx,
}
 
if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) {
-   cancel_work_sync(&ifp->setmacaddr_work);
cancel_work_sync(&ifp->multicast_work);
cancel_work_sync(&ifp->ndoffload_work);
}
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
index 8fa34ca..8a810bb 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
@@ -176,7 +176,6 @@ enum brcmf_netif_stop_reason {
  * @vif: points to cfg80211 specific interface information.
  * @ndev: associated network device.
  * @stats: interface specific network statistics.
- * @setmacaddr_work: worker object for setting mac address.
  * @multicast_work: worker object for multicast provisioning.
  * @ndoffload_work: worker object for neighbor discovery offload configuration.
  * @fws_desc: interface specific firmware-signalling descriptor.
@@ -193,7 +192,6 @@ struct brcmf_if {
struct brcmf_cfg80211_vif *vif;
struct net_device *ndev;
struct net_device_stats stats;
-   struct work_struct setmacaddr_work;
struct work_struct multicast_work;
struct work_struct ndoffload_work;
struct brcmf_fws_mac_descriptor *fws_desc;
-- 
1.9.1



[PATCH 7/9] brcmfmac: fix clearing entry IPv6 address

2016-09-19 Thread Arend van Spriel
From: Hante Meuleman 

When IPv6 address is to be cleared there is a possible out of
bound access. But also the clearing of the last entry and the
adjustment of total number of stored IPv6 addresses is not
updated. This patch fixes that bug. Bug was found using coverity.

Reviewed-by: Arend Van Spriel 
Reviewed-by: Franky Lin 
Reviewed-by: Pieter-Paul Giesberts 
Signed-off-by: Hante Meuleman 
Signed-off-by: Arend van Spriel 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 3394184..bb71199 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -873,9 +873,12 @@ static int brcmf_inet6addr_changed(struct notifier_block 
*nb,
}
break;
case NETDEV_DOWN:
-   if (i < NDOL_MAX_ENTRIES)
-   for (; i < ifp->ipv6addr_idx; i++)
+   if (i < NDOL_MAX_ENTRIES) {
+   for (; i < ifp->ipv6addr_idx - 1; i++)
table[i] = table[i + 1];
+   memset(&table[i], 0, sizeof(table[i]));
+   ifp->ipv6addr_idx--;
+   }
break;
default:
break;
-- 
1.9.1



[PATCH 2/9] brcmfmac: rework pointer trickery in brcmf_proto_bcdc_query_dcmd()

2016-09-19 Thread Arend van Spriel
The variable info is assigned to point to bcdc->msg[1], which is the
same as pointing to bcdc->buf. As that is what we want to access
make it clear by fixing the assignment. This also avoid out-of-bounds
errors from static analyzers are bcdc->msg[1] is not in the structure
definition.

Reviewed-by: Hante Meuleman 
Reviewed-by: Pieter-Paul Giesberts 
Reviewed-by: Franky Lin 
Signed-off-by: Arend van Spriel 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
index d1bc51f..038a960 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
@@ -194,7 +194,7 @@ retry:
}
 
/* Check info buffer */
-   info = (void *)&msg[1];
+   info = (void *)&bcdc->buf[0];
 
/* Copy info buffer */
if (buf) {
-- 
1.9.1



[PATCH 3/9] brcmfmac: fix memory leak in brcmf_flowring_add_tdls_peer()

2016-09-19 Thread Arend van Spriel
In the error paths in brcmf_flowring_add_tdls_peer() the allocated
resource should be freed.

Reviewed-by: Hante Meuleman 
Reviewed-by: Pieter-Paul Giesberts 
Signed-off-by: Arend van Spriel 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c
index 7e269f9..b16b367 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c
@@ -495,14 +495,18 @@ void brcmf_flowring_add_tdls_peer(struct brcmf_flowring 
*flow, int ifidx,
} else {
search = flow->tdls_entry;
if (memcmp(search->mac, peer, ETH_ALEN) == 0)
-   return;
+   goto free_entry;
while (search->next) {
search = search->next;
if (memcmp(search->mac, peer, ETH_ALEN) == 0)
-   return;
+   goto free_entry;
}
search->next = tdls_entry;
}
 
flow->tdls_active = true;
+   return;
+
+free_entry:
+   kfree(tdls_entry);
 }
-- 
1.9.1



Re: [v3 PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Johannes Berg
On Mon, 2016-09-19 at 18:58 +0800, Herbert Xu wrote:
> v3 fixes a bug in the remove path that causes the element count
> to decrease when it shouldn't, leading to a gigantic hash table
> when it underflows.
> 
Ok, with the BUG_ON() thrown in, this works in the test that was
failing before. I'll run the entire suite again over lunch.

johannes


[v3 PATCH 2/2] mac80211: Use rhltable instead of rhashtable

2016-09-19 Thread Herbert Xu
mac80211 currently uses rhashtable with insecure_elasticity set
to true.  The latter is because of duplicate objects.  What's
more, mac80211 walks the rhashtable chains by hand which is broken
as rhashtable may contain multiple tables due to resizing or
rehashing.

This patch fixes it by converting it to the newly added rhltable
interface which is designed for use with duplicate objects.

With rhltable a lookup returns a list of objects instead of a
single one.  This is then fed into the existing for_each_sta_info
macro.

This patch also deletes the sta_addr_hash function since rhashtable
defaults to jhash.

Signed-off-by: Herbert Xu 
---

 net/mac80211/ieee80211_i.h |2 -
 net/mac80211/rx.c  |7 +-
 net/mac80211/sta_info.c|   52 ++---
 net/mac80211/sta_info.h|   19 ++--
 net/mac80211/status.c  |7 +-
 5 files changed, 33 insertions(+), 54 deletions(-)

diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index f56d342..1a52cd4 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1208,7 +1208,7 @@ struct ieee80211_local {
spinlock_t tim_lock;
unsigned long num_sta;
struct list_head sta_list;
-   struct rhashtable sta_hash;
+   struct rhltable sta_hash;
struct timer_list sta_cleanup;
int sta_generation;
 
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 9dce3b1..5e26dc6 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -3940,7 +3940,7 @@ static void __ieee80211_rx_handle_packet(struct 
ieee80211_hw *hw,
__le16 fc;
struct ieee80211_rx_data rx;
struct ieee80211_sub_if_data *prev;
-   struct rhash_head *tmp;
+   struct rhlist_head *tmp;
int err = 0;
 
fc = ((struct ieee80211_hdr *)skb->data)->frame_control;
@@ -3983,13 +3983,10 @@ static void __ieee80211_rx_handle_packet(struct 
ieee80211_hw *hw,
goto out;
} else if (ieee80211_is_data(fc)) {
struct sta_info *sta, *prev_sta;
-   const struct bucket_table *tbl;
 
prev_sta = NULL;
 
-   tbl = rht_dereference_rcu(local->sta_hash.tbl, 
&local->sta_hash);
-
-   for_each_sta_info(local, tbl, hdr->addr2, sta, tmp) {
+   for_each_sta_info(local, hdr->addr2, sta, tmp) {
if (!prev_sta) {
prev_sta = sta;
continue;
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 19f14c9..198d0bd 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -67,12 +67,10 @@
 
 static const struct rhashtable_params sta_rht_params = {
.nelem_hint = 3, /* start small */
-   .insecure_elasticity = true, /* Disable chain-length checks. */
.automatic_shrinking = true,
.head_offset = offsetof(struct sta_info, hash_node),
.key_offset = offsetof(struct sta_info, addr),
.key_len = ETH_ALEN,
-   .hashfn = sta_addr_hash,
.max_size = CONFIG_MAC80211_STA_HASH_MAX_SIZE,
 };
 
@@ -80,8 +78,8 @@ static const struct rhashtable_params sta_rht_params = {
 static int sta_info_hash_del(struct ieee80211_local *local,
 struct sta_info *sta)
 {
-   return rhashtable_remove_fast(&local->sta_hash, &sta->hash_node,
- sta_rht_params);
+   return rhltable_remove(&local->sta_hash, &sta->hash_node,
+  sta_rht_params);
 }
 
 static void __cleanup_single_sta(struct sta_info *sta)
@@ -157,19 +155,22 @@ static void cleanup_single_sta(struct sta_info *sta)
sta_info_free(local, sta);
 }
 
+struct rhlist_head *sta_info_hash_lookup(struct ieee80211_local *local,
+const u8 *addr)
+{
+   return rhltable_lookup(&local->sta_hash, addr, sta_rht_params);
+}
+
 /* protected by RCU */
 struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata,
  const u8 *addr)
 {
struct ieee80211_local *local = sdata->local;
+   struct rhlist_head *tmp;
struct sta_info *sta;
-   struct rhash_head *tmp;
-   const struct bucket_table *tbl;
 
rcu_read_lock();
-   tbl = rht_dereference_rcu(local->sta_hash.tbl, &local->sta_hash);
-
-   for_each_sta_info(local, tbl, addr, sta, tmp) {
+   for_each_sta_info(local, addr, sta, tmp) {
if (sta->sdata == sdata) {
rcu_read_unlock();
/* this is safe as the caller must already hold
@@ -190,14 +191,11 @@ struct sta_info *sta_info_get_bss(struct 
ieee80211_sub_if_data *sdata,
  const u8 *addr)
 {
struct ieee80211_local *local = sdata->local;
+   struct rhlist_head *tmp;
struct sta_info *sta;
-   struct rhash_head *tmp;
-   const struct bucket_table *tbl;
 
   

[v3 PATCH 1/2] rhashtable: Add rhlist interface

2016-09-19 Thread Herbert Xu
The insecure_elasticity setting is an ugly wart brought out by
users who need to insert duplicate objects (that is, distinct
objects with identical keys) into the same table.

In fact, those users have a much bigger problem.  Once those
duplicate objects are inserted, they don't have an interface to
find them (unless you count the walker interface which walks
over the entire table).

Some users have resorted to doing a manual walk over the hash
table which is of course broken because they don't handle the
potential existence of multiple hash tables.  The result is that
they will break sporadically when they encounter a hash table
resize/rehash.

This patch provides a way out for those users, at the expense
of an extra pointer per object.  Essentially each object is now
a list of objects carrying the same key.  The hash table will
only see the lists so nothing changes as far as rhashtable is
concerned.

To use this new interface, you need to insert a struct rhlist_head
into your objects instead of struct rhash_head.  While the hash
table is unchanged, for type-safety you'll need to use struct
rhltable instead of struct rhashtable.  All the existing interfaces
have been duplicated for rhlist, including the hash table walker.

One missing feature is nulls marking because AFAIK the only potential
user of it does not need duplicate objects.  Should anyone need
this it shouldn't be too hard to add.

Signed-off-by: Herbert Xu 
---

 include/linux/rhashtable.h |  491 ++---
 lib/rhashtable.c   |  258 ++-
 2 files changed, 583 insertions(+), 166 deletions(-)

diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h
index fd82584..5c132d3 100644
--- a/include/linux/rhashtable.h
+++ b/include/linux/rhashtable.h
@@ -1,7 +1,7 @@
 /*
  * Resizable, Scalable, Concurrent Hash Table
  *
- * Copyright (c) 2015 Herbert Xu 
+ * Copyright (c) 2015-2016 Herbert Xu 
  * Copyright (c) 2014-2015 Thomas Graf 
  * Copyright (c) 2008-2014 Patrick McHardy 
  *
@@ -53,6 +53,11 @@ struct rhash_head {
struct rhash_head __rcu *next;
 };
 
+struct rhlist_head {
+   struct rhash_head   rhead;
+   struct rhlist_head __rcu*next;
+};
+
 /**
  * struct bucket_table - Table of hash buckets
  * @size: Number of hash buckets
@@ -137,6 +142,7 @@ struct rhashtable_params {
  * @key_len: Key length for hashfn
  * @elasticity: Maximum chain length before rehash
  * @p: Configuration parameters
+ * @rhlist: True if this is an rhltable
  * @run_work: Deferred worker to expand/shrink asynchronously
  * @mutex: Mutex to protect current/future table swapping
  * @lock: Spin lock to protect walker list
@@ -147,12 +153,21 @@ struct rhashtable {
unsigned intkey_len;
unsigned intelasticity;
struct rhashtable_paramsp;
+   boolrhlist;
struct work_struct  run_work;
struct mutexmutex;
spinlock_t  lock;
 };
 
 /**
+ * struct rhltable - Hash table with duplicate objects in a list
+ * @ht: Underlying rhtable
+ */
+struct rhltable {
+   struct rhashtable ht;
+};
+
+/**
  * struct rhashtable_walker - Hash table walker
  * @list: List entry on list of walkers
  * @tbl: The table that we were walking over
@@ -163,9 +178,10 @@ struct rhashtable_walker {
 };
 
 /**
- * struct rhashtable_iter - Hash table iterator, fits into netlink cb
+ * struct rhashtable_iter - Hash table iterator
  * @ht: Table to iterate through
  * @p: Current pointer
+ * @list: Current hash list pointer
  * @walker: Associated rhashtable walker
  * @slot: Current slot
  * @skip: Number of entries to skip in slot
@@ -173,6 +189,7 @@ struct rhashtable_walker {
 struct rhashtable_iter {
struct rhashtable *ht;
struct rhash_head *p;
+   struct rhlist_head *list;
struct rhashtable_walker walker;
unsigned int slot;
unsigned int skip;
@@ -339,13 +356,11 @@ static inline int lockdep_rht_bucket_is_held(const struct 
bucket_table *tbl,
 
 int rhashtable_init(struct rhashtable *ht,
const struct rhashtable_params *params);
+int rhltable_init(struct rhltable *hlt,
+ const struct rhashtable_params *params);
 
-struct bucket_table *rhashtable_insert_slow(struct rhashtable *ht,
-   const void *key,
-   struct rhash_head *obj,
-   struct bucket_table *old_tbl,
-   void **data);
-int rhashtable_insert_rehash(struct rhashtable *ht, struct bucket_table *tbl);
+void *rhashtable_insert_slow(struct rhashtable *ht, const void *key,
+struct rhash_head *obj);
 
 void rhashtable_walk_enter(struct rhashtable *ht,
   struct rhashtable_iter *i

[v3 PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Herbert Xu
v3 fixes a bug in the remove path that causes the element count
to decrease when it shouldn't, leading to a gigantic hash table
when it underflows.

v2 contains a reworked insertion slowpath to ensure that the
spinlock for the table we're inserting into is taken.

This series contains two patches.  The first adds the rhlist
interface and the second converts mac80211 to use it.  If this
works out I'll then proceed to convert the other insecure_elasticity
users over to this.

I've tested the rhlist code with test_rhashtable but I haven't
tested the mac80211 conversion.  So please give it a go and see
if it still works.

Thanks!
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [v2 PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Johannes Berg
On Mon, 2016-09-19 at 18:48 +0800, Herbert Xu wrote:
> On Mon, Sep 19, 2016 at 12:10:27PM +0200, Johannes Berg wrote:
> > 
> > Btw, for debug I put
> > 
> > BUG_ON(atomic_read(&ht->nelems) < 0);
> > 
> > after the atomic_dec() in __rhashtable_remove_fast_one(). That
> > makes
> > the kernel crash instantly on the buggy code, and I just have to
> > run a
> > single test ("wpas_ctrl_interface_add_many") to get there.
> 
> Aha I see the problem now.  The nelems logic on remove is broken.

I looked at it for a long time, but didn't see it :) But yeah, I've
come to the same conclusion by adding debugging of the chains etc.

> I'll send out a v3.

I'll test it when I have it :)

johannes


[PATCH] rsi: fix memory leak in debugfs entry and supported bands

2016-09-19 Thread Prameela Rani Garnepudi
From: Prameela Rani Garnepudi 

Signed-off-by: Prameela Rani Garnepudi 
---
 drivers/net/wireless/rsi/rsi_91x_mac80211.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/wireless/rsi/rsi_91x_mac80211.c 
b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
index dbb2389..dc64532 100644
--- a/drivers/net/wireless/rsi/rsi_91x_mac80211.c
+++ b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
@@ -194,6 +194,7 @@ static void rsi_register_rates_channels(struct rsi_hw 
*adapter, int band)
 void rsi_mac80211_detach(struct rsi_hw *adapter)
 {
struct ieee80211_hw *hw = adapter->hw;
+   int i;
 
if (hw) {
ieee80211_stop_queues(hw);
@@ -201,7 +202,16 @@ void rsi_mac80211_detach(struct rsi_hw *adapter)
ieee80211_free_hw(hw);
}
 
+   for (i = 0; i < 2; i++) {
+   struct ieee80211_supported_band *sbands = &adapter->sbands[i];
+
+   kfree(sbands->channels);
+   }
+
+#ifdef CONFIG_RSI_DEBUGFS
rsi_remove_dbgfs(adapter);
+   kfree(adapter->dfsentry);
+#endif
 }
 EXPORT_SYMBOL_GPL(rsi_mac80211_detach);
 
-- 
2.4.11



Re: [v2 PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Herbert Xu
On Mon, Sep 19, 2016 at 12:10:27PM +0200, Johannes Berg wrote:
> Btw, for debug I put
> 
> BUG_ON(atomic_read(&ht->nelems) < 0);
> 
> after the atomic_dec() in __rhashtable_remove_fast_one(). That makes
> the kernel crash instantly on the buggy code, and I just have to run a
> single test ("wpas_ctrl_interface_add_many") to get there.

Aha I see the problem now.  The nelems logic on remove is broken.
I'll send out a v3.

Thanks!
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [v2 PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Johannes Berg
Btw, for debug I put

BUG_ON(atomic_read(&ht->nelems) < 0);

after the atomic_dec() in __rhashtable_remove_fast_one(). That makes
the kernel crash instantly on the buggy code, and I just have to run a
single test ("wpas_ctrl_interface_add_many") to get there.

johannes


Re: [v2 PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Johannes Berg
On Mon, 2016-09-19 at 12:02 +0200, Johannes Berg wrote:
> On Mon, 2016-09-19 at 11:54 +0200, Johannes Berg wrote:
> > 
> > > 
> > > 
> > > The stack trace is useless, but my other annotation showed that
> > > the
> > > table's nelems *underflowed* to -1, so now the worker will
> > > continue
> > > to try to grow it forever.
> > > 
> > 
> > And this *was* actually a case of duplication, afaict, since it was
> > multiple virtual interfaces on the same device all connecting to
> > the
> > same AP.
> 
> It seems that __rhashtable_remove_fast_one() should return 0 even in
> the case of err==1 for the "skip all the maintenance due to list
> deletion"?
> 
> --- a/include/linux/rhashtable.h
> +++ b/include/linux/rhashtable.h
> @@ -1009,7 +1009,7 @@ static inline int __rhashtable_remove_fast_one(
> err = 0;
> }
>  
> -   return err;
> +   return err < 0 ? err : 0;
>  }
> 

No, that's obviously bogus and already handled - wrong case anyway.
Sorry.

johannes


Re: [v2 PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Johannes Berg
On Mon, 2016-09-19 at 11:54 +0200, Johannes Berg wrote:
> > 
> > The stack trace is useless, but my other annotation showed that the
> > table's nelems *underflowed* to -1, so now the worker will continue
> > to try to grow it forever.
> > 
> 
> And this *was* actually a case of duplication, afaict, since it was
> multiple virtual interfaces on the same device all connecting to the
> same AP.

It seems that __rhashtable_remove_fast_one() should return 0 even in
the case of err==1 for the "skip all the maintenance due to list
deletion"?

--- a/include/linux/rhashtable.h
+++ b/include/linux/rhashtable.h
@@ -1009,7 +1009,7 @@ static inline int __rhashtable_remove_fast_one(
err = 0;
}
 
-   return err;
+   return err < 0 ? err : 0;
 }

But that in itself doesn't help.

johannes


Re: [v2 PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Johannes Berg

> The stack trace is useless, but my other annotation showed that the
> table's nelems *underflowed* to -1, so now the worker will continue
> to try to grow it forever.
> 

And this *was* actually a case of duplication, afaict, since it was
multiple virtual interfaces on the same device all connecting to the
same AP.

johannes


Re: [v2 PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Johannes Berg
On Mon, 2016-09-19 at 17:34 +0800, Herbert Xu wrote:
> On Mon, Sep 19, 2016 at 11:27:24AM +0200, Johannes Berg wrote:
> > 
> > 
> > I have a feeling there's a bug with ht->nelems, since the crash is
> > always in the grow worker, but I haven't quite put my finger on it
> > yet.
> 
> Can you show me a stack trace?
> 
The stack trace is useless, but my other annotation showed that the
table's nelems *underflowed* to -1, so now the worker will continue to
try to grow it forever.

johannes


Re: [v2 PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Johannes Berg
On Mon, 2016-09-19 at 17:34 +0800, Herbert Xu wrote:
> On Mon, Sep 19, 2016 at 11:27:24AM +0200, Johannes Berg wrote:
> > 
> > 
> > I have a feeling there's a bug with ht->nelems, since the crash is
> > always in the grow worker, but I haven't quite put my finger on it
> > yet.
> 
> Can you show me a stack trace?

Oops, just deleted the old ones to reproduce with some debug printks :)

It's always while trying to grow a table from the worker; it kills
processes, but eventually no process are left and the kernel panics.

I'll send you a trace when I have one again - I'm running a new
reproduction now.

johannes


Re: [v2 PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Herbert Xu
On Mon, Sep 19, 2016 at 11:27:24AM +0200, Johannes Berg wrote:
> 
> I have a feeling there's a bug with ht->nelems, since the crash is
> always in the grow worker, but I haven't quite put my finger on it yet.

Can you show me a stack trace?

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [OpenWrt-Devel] ath10k mesh + ap + encryption?

2016-09-19 Thread Sven Eckelmann
On Montag, 19. September 2016 08:43:56 CEST Simon Wunderlich wrote:
[...]
> > We're testing encrypted AP + Mesh quite successfully right now with
> > this firmware: https://github.com/kvalo/ath10k-firmware/commit/307cb46b
> > 06661ebd3186723b5002de769c7add83, of course that is for a QCA4019 chip.
> > Which chip are you using? I can poke the firmware guys for possibility
> > of getting a 10.4.3.2 firmware build for it.
> 
> Hi Thomas,
> 
> thanks for the hint! We are using an older QCA9882. I assume your firmware
> will not work for this one? If you can poke the firmware guys, that would
> be great.
> :)
> 
> We also want to test the 70.52 firmware version next, maybe there were some
> changes since the .42 we used.

I have just checked it with 10.2.4.70.54:

   | 802.11s encrypted | 802.11s unencrypted
---+---+
AP encrypted   | AP doesn't beacon | works
AP unencrypted | AP doesn't beacon | works

I've also checked 10.2.4.70.12-2 (doesn't seem to support encrypted mesh at 
all) and with rawmode=1 (makes no difference).

Kind regards,
Sven

signature.asc
Description: This is a digitally signed message part.


Re: [PATCH] cfg80211: cap 20MHz VHT bitrate at MCS 8

2016-09-19 Thread Arend Van Spriel


On 19-9-2016 11:00, Johannes Berg wrote:
> 
>> Actually, can you apply the v2 (cfg80211: add bitrate for 20MHz MCS
>> 9) of this? Systems guys confirmed they use MCS 9 @ 20MHz when LDPC
>> is enabled. Also confirmed bitrate should be ok.
> 
> I don't really understand that. How can the bitrate be "OK" when the
> spec explicitly says it cannot be used?

This conversation sounds a lot like these two threads [1] and [2]. Just
not sure if our vendor specific IEs cover this rate as well.

Regards,
Arend

[1]
http://mid.gmane.org/145766-27898-1-git-send-email-gree...@candelatech.com
[2] 1461244669-19871-1-git-send-email-kv...@qca.qualcomm.com


Re: [v2 PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Johannes Berg
On Mon, 2016-09-19 at 11:27 +0200, Johannes Berg wrote:
> > 
> I have a feeling there's a bug with ht->nelems, since the crash is
> always in the grow worker, but I haven't quite put my finger on it
> yet.
> 
Btw, I should not actually get into the duplicate case here.

johannes


Re: [v2 PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Johannes Berg

> What does your test suite actually do? Is it something that I
> can run without special hardware?

Yes, it's pretty simple - it spins up a number of VMs with hwsim and
just runs a lot of tests:

https://w1.fi/cgit/hostap/tree/tests/hwsim

I've attached a kernel .config you can use for it.

I'm running 7 VMs (vm/parallel-vm.py 7), which makes it faster, but you
can probably reproduce the bug better with a single VM.

I have a feeling there's a bug with ht->nelems, since the crash is
always in the grow worker, but I haven't quite put my finger on it yet.

johannes#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 4.8.0-rc4 Kernel Configuration
#
CONFIG_64BIT=y
CONFIG_X86_64=y
CONFIG_X86=y
CONFIG_INSTRUCTION_DECODER=y
CONFIG_OUTPUT_FORMAT="elf64-x86-64"
CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig"
CONFIG_LOCKDEP_SUPPORT=y
CONFIG_STACKTRACE_SUPPORT=y
CONFIG_MMU=y
CONFIG_ARCH_MMAP_RND_BITS_MIN=28
CONFIG_ARCH_MMAP_RND_BITS_MAX=32
CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=8
CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=16
CONFIG_NEED_DMA_MAP_STATE=y
CONFIG_NEED_SG_DMA_LENGTH=y
CONFIG_GENERIC_BUG=y
CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y
CONFIG_GENERIC_HWEIGHT=y
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
CONFIG_ARCH_HAS_CPU_RELAX=y
CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
CONFIG_HAVE_SETUP_PER_CPU_AREA=y
CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK=y
CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y
CONFIG_ARCH_HIBERNATION_POSSIBLE=y
CONFIG_ARCH_SUSPEND_POSSIBLE=y
CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y
CONFIG_ARCH_WANT_GENERAL_HUGETLB=y
CONFIG_ZONE_DMA32=y
CONFIG_AUDIT_ARCH=y
CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
CONFIG_X86_64_SMP=y
CONFIG_ARCH_SUPPORTS_UPROBES=y
CONFIG_FIX_EARLYCON_MEM=y
CONFIG_DEBUG_RODATA=y
CONFIG_PGTABLE_LEVELS=4
CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
CONFIG_CONSTRUCTORS=y
CONFIG_IRQ_WORK=y
CONFIG_BUILDTIME_EXTABLE_SORT=y

#
# General setup
#
CONFIG_INIT_ENV_ARG_LIMIT=32
CONFIG_CROSS_COMPILE=""
# CONFIG_COMPILE_TEST is not set
CONFIG_LOCALVERSION=""
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_HAVE_KERNEL_GZIP=y
CONFIG_HAVE_KERNEL_BZIP2=y
CONFIG_HAVE_KERNEL_LZMA=y
CONFIG_HAVE_KERNEL_XZ=y
CONFIG_HAVE_KERNEL_LZO=y
CONFIG_HAVE_KERNEL_LZ4=y
# CONFIG_KERNEL_GZIP is not set
CONFIG_KERNEL_BZIP2=y
# CONFIG_KERNEL_LZMA is not set
# CONFIG_KERNEL_XZ is not set
# CONFIG_KERNEL_LZO is not set
# CONFIG_KERNEL_LZ4 is not set
CONFIG_DEFAULT_HOSTNAME="(none)"
# CONFIG_SWAP is not set
CONFIG_SYSVIPC=y
CONFIG_SYSVIPC_SYSCTL=y
# CONFIG_POSIX_MQUEUE is not set
# CONFIG_CROSS_MEMORY_ATTACH is not set
# CONFIG_FHANDLE is not set
CONFIG_USELIB=y
# CONFIG_AUDIT is not set
CONFIG_HAVE_ARCH_AUDITSYSCALL=y

#
# IRQ subsystem
#
CONFIG_GENERIC_IRQ_PROBE=y
CONFIG_GENERIC_IRQ_SHOW=y
CONFIG_GENERIC_PENDING_IRQ=y
CONFIG_IRQ_DOMAIN=y
CONFIG_IRQ_DOMAIN_HIERARCHY=y
# CONFIG_IRQ_DOMAIN_DEBUG is not set
CONFIG_IRQ_FORCED_THREADING=y
CONFIG_SPARSE_IRQ=y
CONFIG_CLOCKSOURCE_WATCHDOG=y
CONFIG_ARCH_CLOCKSOURCE_DATA=y
CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE=y
CONFIG_GENERIC_TIME_VSYSCALL=y
CONFIG_GENERIC_CLOCKEVENTS=y
CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST=y
CONFIG_GENERIC_CMOS_UPDATE=y

#
# Timers subsystem
#
CONFIG_TICK_ONESHOT=y
CONFIG_NO_HZ_COMMON=y
# CONFIG_HZ_PERIODIC is not set
CONFIG_NO_HZ_IDLE=y
# CONFIG_NO_HZ_FULL is not set
CONFIG_NO_HZ=y
CONFIG_HIGH_RES_TIMERS=y

#
# CPU/Task time and stats accounting
#
CONFIG_TICK_CPU_ACCOUNTING=y
# CONFIG_VIRT_CPU_ACCOUNTING_GEN is not set
# CONFIG_IRQ_TIME_ACCOUNTING is not set
CONFIG_BSD_PROCESS_ACCT=y
# CONFIG_BSD_PROCESS_ACCT_V3 is not set
CONFIG_TASKSTATS=y
CONFIG_TASK_DELAY_ACCT=y
CONFIG_TASK_XACCT=y
CONFIG_TASK_IO_ACCOUNTING=y

#
# RCU Subsystem
#
CONFIG_PREEMPT_RCU=y
# CONFIG_RCU_EXPERT is not set
CONFIG_SRCU=y
# CONFIG_TASKS_RCU is not set
CONFIG_RCU_STALL_COMMON=y
# CONFIG_TREE_RCU_TRACE is not set
# CONFIG_RCU_EXPEDITE_BOOT is not set
# CONFIG_BUILD_BIN2C is not set
# CONFIG_IKCONFIG is not set
CONFIG_LOG_BUF_SHIFT=21
CONFIG_LOG_CPU_MAX_BUF_SHIFT=17
CONFIG_NMI_LOG_BUF_SHIFT=13
CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y
CONFIG_ARCH_SUPPORTS_NUMA_BALANCING=y
CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH=y
CONFIG_ARCH_SUPPORTS_INT128=y
# CONFIG_CGROUPS is not set
# CONFIG_CHECKPOINT_RESTORE is not set
# CONFIG_NAMESPACES is not set
# CONFIG_SCHED_AUTOGROUP is not set
# CONFIG_SYSFS_DEPRECATED is not set
# CONFIG_RELAY is not set
# CONFIG_BLK_DEV_INITRD is not set
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y
# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
CONFIG_SYSCTL=y
CONFIG_ANON_INODES=y
CONFIG_SYSCTL_EXCEPTION_TRACE=y
CONFIG_HAVE_PCSPKR_PLATFORM=y
CONFIG_BPF=y
CONFIG_EXPERT=y
CONFIG_MULTIUSER=y
CONFIG_SGETMASK_SYSCALL=y
CONFIG_SYSFS_SYSCALL=y
CONFIG_SYSCTL_SYSCALL=y
CONFIG_KALLSYMS=y
CONFIG_KALLSYMS_ALL=y
CONFIG_KALLSYMS_ABSOLUTE_PERCPU=y
CONFIG_KALLSYMS_BASE_RELATIVE=y
CONFIG_PRINTK=y
CONFIG_PRINTK_NMI=y
CONFIG_BUG=y
CONFIG_ELF_CORE=y
CONFIG_PCSPKR_PLATFORM=y
CONFIG_BASE_FULL=y
CONFIG_FUTEX=y
CONFIG_EPO

Re: [PATCH 4/4] ath10k: fix spurious tx/rx during boot

2016-09-19 Thread Michal Kazior
On 17 September 2016 at 00:37, Hsu, Ryan  wrote:
[...]
>> + /* WMI and HTT may use separate HIF pipes and are not guaranteed to be
>> +  * serialized properly implicitly.
>> +  *
>> +  * Moreover (most) WMI commands have no explicit acknowledges. It is
>> +  * possible to infer it implicitly by poking firmware with echo
>> +  * command - getting a reply means all preceding comments have been
>> +  * (mostly) processed.
>> +  *
>> +  * In case of vdev create/delete this is sufficient.
>> +  *
>> +  * Without this it's possible to end up with a race when HTT Rx ring is
>> +  * started before vdev create/delete hack is complete allowing a short
>> +  * window of opportunity to receive (and Tx ACK) a bunch of frames.
>> +  */
>> + ret = ath10k_wmi_barrier(ar);
> QCA6174 UTF firmware seems doesn't support the WMI_ECHO command.
>
> [16460.274822] ath10k_pci :04:00.0: wmi tlv echo value 0x0ba991e9
> ...
> [16463.461970] ath10k_pci :04:00.0: failed to ping firmware: -110
> [16463.461975] ath10k_pci :04:00.0: failed to reset rx filter: -110
>
> Has anyone verified any AP solution to see if UTF mode is still working
> with after this patch?
>
> Anyway, I would like to exclude the workaround from all solution's UTF mode.
>
> Michal any concerns? (or maybe just for QCA61x4 if any...)

I didn't expect UTF wouldn't support echo.. Sorry!

If you skip this workaround for UTF I guess the device will (again) be
able to generate some bogus traffic on boot for UTF case. Not sure how
much of a problem that is (assuming it is at all).


Michal


Re: [v2 PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Herbert Xu
On Mon, Sep 19, 2016 at 11:15:30AM +0200, Johannes Berg wrote:
> On Mon, 2016-09-19 at 16:40 +0800, Herbert Xu wrote:
> 
> > I've tested the rhlist code with test_rhashtable but I haven't
> > tested the mac80211 conversion.  So please give it a go and see
> > if it still works.
> 
> This is still running out of memory on my test suite.
> 
> Somehow I don't see kmemleak kicking in, so I'll have to find the bug
> manually :)

What does your test suite actually do? Is it something that I
can run without special hardware?

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [v2 PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Johannes Berg
On Mon, 2016-09-19 at 16:40 +0800, Herbert Xu wrote:

> I've tested the rhlist code with test_rhashtable but I haven't
> tested the mac80211 conversion.  So please give it a go and see
> if it still works.

This is still running out of memory on my test suite.

Somehow I don't see kmemleak kicking in, so I'll have to find the bug
manually :)

johannes


Re: [PATCH] cfg80211: cap 20MHz VHT bitrate at MCS 8

2016-09-19 Thread Johannes Berg

> Actually, can you apply the v2 (cfg80211: add bitrate for 20MHz MCS
> 9) of this? Systems guys confirmed they use MCS 9 @ 20MHz when LDPC
> is enabled. Also confirmed bitrate should be ok.

I don't really understand that. How can the bitrate be "OK" when the
spec explicitly says it cannot be used?

johannes


Re: [PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Johannes Berg

> > I take that back. I think it's leaking memory - my tests never used
> > to run out of memory, but now they eventually do.
> 
> > I'll try to figure out more.
> 
> Interesting.  The kernel test robot found a bug in the insertion
> slowpath where we end up inserting without taking the inner spinlock
> in case of a nested table.  Not sure whether that's the same issue
> as you're seeing but I'll do a v2 posting.

Increasing the memory for the VMs from 384MB to 512MB didn't avoid the
issue, so there's a definite leak somewhere, although this time fewer
VMs crashed :)

Reverting the patches and running with 384MB then works, so it's not
something else added in the meantime (I ran last a few days ago, but
don't think I merged anything interesting in the meantime).

I'll test your new patches in a minute.

johannes


RE: [PATCH v2 6/9] cfg80211: Provide an API to report NAN function termination

2016-09-19 Thread Otcheretianski, Andrei
> -Original Message-
> From: Arend Van Spriel [mailto:arend.vanspr...@broadcom.com]
> Sent: Sunday, September 18, 2016 23:00
> To: Luca Coelho ; johan...@sipsolutions.net
> Cc: linux-wireless@vger.kernel.org; Beker, Ayala ;
> Otcheretianski, Andrei ; Grumbach,
> Emmanuel ; Coelho, Luciano
> 
> Subject: Re: [PATCH v2 6/9] cfg80211: Provide an API to report NAN function
> termination
> 
> On 18-9-2016 21:56, Arend Van Spriel wrote:
> > On 16-9-2016 10:33, Luca Coelho wrote:
> >> From: Ayala Beker 
> >>
> >> Provide a function that reports NAN DE function termination. The
> >> function may be terminated due to one of the following reasons: user
> >> request, ttl expiration or failure.
> >> If the NAN instance is tied to the owner, the notification will be
> >> sent to the socket that started the NAN interface only
> >
> > So the driver is supposed to use this function from the .rm_nan_func
> > callback (or .del_nan_func). How should the driver use this together
> > with cfg80211_free_nan_func() function.
> 
> Hit Send button too fast. Would it make sense to free the nan func implicitly
> in cfg80211_nan_func_terminated() function or would there be reasons to
> keep it.

Currently when the NAN interface is stopped (ieee80211_do_stop) the termination 
notification can't be sent, since ieee80211_vif_to_wdev will return NULL after 
SDATA_STATE_RUNNING bit is cleared.
I guess it's similar not only for mac80211, and in case of interface removal we 
don't really want to send notifications for each function.

> 
> Regards,
> Arend


pull-request: iwlwifi-next 2016-09-19-2

2016-09-19 Thread Luca Coelho
Hi Kalle,

Please drop my previous pull-request.  There was a compilation error
that I missed to due a missing flag in my .config.  I fixed it now and
this is the new pull request that includes the fix.

Here we go again, now I'm almost catching up with the pending stuff in
our internal tree, just in time for 4.9.  This pull contains a bunch of
fixes to DQA and new HW support code, a few new features and some
cleanups.  More details in the tag description.

Let me know if everything's fine (or not). :)

Luca.


The following changes since commit 80ba4f1d365af206b9e818d17d22fed02fe5def0:

  mwifiex: fix null pointer deference when adapter is null (2016-09-17 18:26:32 
+0300)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-next.git 
tags/iwlwifi-next-for-kalle-2016-09-19-2

for you to fetch changes up to 0979a913f879ea39504200d83fb9f275a555a58d:

  iwlwifi: pcie: use LIST_HEAD() macro (2016-09-19 11:29:35 +0300)


* added support for MU-MIMO sniffer
* added support for RRM by scan
* added support for packet injection
* migrate to devm memory allocation handling
* some fixes, mostly in DQA and new HW support
* other generic cleanups


Arik Nemtsov (1):
  iwlwifi: move BIOS MCC retrieval to common code

Aviya Erenfeld (1):
  iwlwifi: mvm: add support for MU-MIMO air sniffer

Avrahams Stern (1):
  iwlwifi: mvm: Add support for RRM by scan

Emmanuel Grumbach (1):
  iwlwifi: don't export trace points that are used in iwlwifi only

Haim Dreyfuss (1):
  iwlwifi: check for valid ethernet address provided by OEM

Ido Yariv (1):
  iwlwifi: mvm: Add mem debugfs entry

Johannes Berg (6):
  iwlwifi: mvm: compare full command ID
  iwlwifi: mvm: make iwl_mvm_update_sta() an inline
  iwlwifi: mvm: document passing unexpected Block Ack Request frames
  iwlwifi: mvm: move AP-specific code to right function
  iwlwifi: mvm: use LIST_HEAD() macro
  iwlwifi: pcie: use LIST_HEAD() macro

Liad Kaufman (1):
  iwlwifi: mvm: remove variable shadowing

Oren Givon (1):
  iwlwifi: add new 8265 series PCI ID

Roee Zamir (1):
  iwlwifi: mvm: Add debugfs function for clocks diff

Sara Sharon (9):
  iwlwifi: pcie: fix typo in struct name for a000 devices
  iwlwifi: mvm: cleanup skb queue functions use
  iwlwifi: mvm: fix DQA AP mode station assumption
  iwlwifi: mvm: support BAR in reorder buffer
  iwlwifi: mvm: support packet injection
  iwlwifi: pcie: log full command sequence
  iwlwifi: move to wide ID for all commands
  iwlwifi: mvm: disable P2P queue on mac context release
  iwlwifi: mvm: set HCMD_NAME for PHY_DB as well

Sharon Dvir (1):
  iwlwifi: migrate to devm_* API

 drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c|   3 --
 drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h |   5 ++
 drivers/net/wireless/intel/iwlwifi/iwl-notif-wait.c  |   8 +++-
 drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c   | 104 
--
 drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h   |  20 +++-
 drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c  |   2 +-
 drivers/net/wireless/intel/iwlwifi/iwl-trans.c   |  11 ++---
 drivers/net/wireless/intel/iwlwifi/iwl-trans.h   |   5 +-
 drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c |  26 +++
 drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 184 
++
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-scan.h |  20 
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h  |  52 
-
 drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c|  47 ++-
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c|  18 
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h |   7 +++
 drivers/net/wireless/intel/iwlwifi/mvm/nvm.c |  93 
+
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c |  32 +++--
 drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c|  30 
 drivers/net/wireless/intel/iwlwifi/mvm/scan.c|  61 
++---
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c |  13 ++
 drivers/net/wireless/intel/iwlwifi/mvm/sta.h |  11 +++--
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c  |  35 +++---
 drivers/net/wireless/intel/iwlwifi/mvm/utils.c   |  22 +
 drivers/net/wireless/intel/iwlwifi/pcie/drv.c|   1 +
 drivers/net/wireless/intel/iwlwifi/pcie/internal.h   |   2 -
 drivers/net/wireless/intel/iwlwifi/pcie/rx.c |   9 ++--
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c  |  84 
++
 drivers/net/wireless/intel/iwlwifi/pcie/tx.c |   2 +-
 28 files changed, 655 insertions(+),

[v2 PATCH 1/2] rhashtable: Add rhlist interface

2016-09-19 Thread Herbert Xu
The insecure_elasticity setting is an ugly wart brought out by
users who need to insert duplicate objects (that is, distinct
objects with identical keys) into the same table.

In fact, those users have a much bigger problem.  Once those
duplicate objects are inserted, they don't have an interface to
find them (unless you count the walker interface which walks
over the entire table).

Some users have resorted to doing a manual walk over the hash
table which is of course broken because they don't handle the
potential existence of multiple hash tables.  The result is that
they will break sporadically when they encounter a hash table
resize/rehash.

This patch provides a way out for those users, at the expense
of an extra pointer per object.  Essentially each object is now
a list of objects carrying the same key.  The hash table will
only see the lists so nothing changes as far as rhashtable is
concerned.

To use this new interface, you need to insert a struct rhlist_head
into your objects instead of struct rhash_head.  While the hash
table is unchanged, for type-safety you'll need to use struct
rhltable instead of struct rhashtable.  All the existing interfaces
have been duplicated for rhlist, including the hash table walker.

One missing feature is nulls marking because AFAIK the only potential
user of it does not need duplicate objects.  Should anyone need
this it shouldn't be too hard to add.

Signed-off-by: Herbert Xu 
---

 include/linux/rhashtable.h |  490 ++---
 lib/rhashtable.c   |  258 ++-
 2 files changed, 582 insertions(+), 166 deletions(-)

diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h
index fd82584..dc7bea6 100644
--- a/include/linux/rhashtable.h
+++ b/include/linux/rhashtable.h
@@ -1,7 +1,7 @@
 /*
  * Resizable, Scalable, Concurrent Hash Table
  *
- * Copyright (c) 2015 Herbert Xu 
+ * Copyright (c) 2015-2016 Herbert Xu 
  * Copyright (c) 2014-2015 Thomas Graf 
  * Copyright (c) 2008-2014 Patrick McHardy 
  *
@@ -53,6 +53,11 @@ struct rhash_head {
struct rhash_head __rcu *next;
 };
 
+struct rhlist_head {
+   struct rhash_head   rhead;
+   struct rhlist_head __rcu*next;
+};
+
 /**
  * struct bucket_table - Table of hash buckets
  * @size: Number of hash buckets
@@ -137,6 +142,7 @@ struct rhashtable_params {
  * @key_len: Key length for hashfn
  * @elasticity: Maximum chain length before rehash
  * @p: Configuration parameters
+ * @rhlist: True if this is an rhltable
  * @run_work: Deferred worker to expand/shrink asynchronously
  * @mutex: Mutex to protect current/future table swapping
  * @lock: Spin lock to protect walker list
@@ -147,12 +153,21 @@ struct rhashtable {
unsigned intkey_len;
unsigned intelasticity;
struct rhashtable_paramsp;
+   boolrhlist;
struct work_struct  run_work;
struct mutexmutex;
spinlock_t  lock;
 };
 
 /**
+ * struct rhltable - Hash table with duplicate objects in a list
+ * @ht: Underlying rhtable
+ */
+struct rhltable {
+   struct rhashtable ht;
+};
+
+/**
  * struct rhashtable_walker - Hash table walker
  * @list: List entry on list of walkers
  * @tbl: The table that we were walking over
@@ -163,9 +178,10 @@ struct rhashtable_walker {
 };
 
 /**
- * struct rhashtable_iter - Hash table iterator, fits into netlink cb
+ * struct rhashtable_iter - Hash table iterator
  * @ht: Table to iterate through
  * @p: Current pointer
+ * @list: Current hash list pointer
  * @walker: Associated rhashtable walker
  * @slot: Current slot
  * @skip: Number of entries to skip in slot
@@ -173,6 +189,7 @@ struct rhashtable_walker {
 struct rhashtable_iter {
struct rhashtable *ht;
struct rhash_head *p;
+   struct rhlist_head *list;
struct rhashtable_walker walker;
unsigned int slot;
unsigned int skip;
@@ -339,13 +356,11 @@ static inline int lockdep_rht_bucket_is_held(const struct 
bucket_table *tbl,
 
 int rhashtable_init(struct rhashtable *ht,
const struct rhashtable_params *params);
+int rhltable_init(struct rhltable *hlt,
+ const struct rhashtable_params *params);
 
-struct bucket_table *rhashtable_insert_slow(struct rhashtable *ht,
-   const void *key,
-   struct rhash_head *obj,
-   struct bucket_table *old_tbl,
-   void **data);
-int rhashtable_insert_rehash(struct rhashtable *ht, struct bucket_table *tbl);
+void *rhashtable_insert_slow(struct rhashtable *ht, const void *key,
+struct rhash_head *obj);
 
 void rhashtable_walk_enter(struct rhashtable *ht,
   struct rhashtable_iter *i

[v2 PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Herbert Xu
v2 contains a reworked insertion slowpath to ensure that the
spinlock for the table we're inserting into is taken.

This series contains one two patches.  The first adds the rhlist
interface and the second converts mac80211 to use it.  If this works
out I'll then proceed to convert the other insecure_elasticity
users over to this.

I've tested the rhlist code with test_rhashtable but I haven't
tested the mac80211 conversion.  So please give it a go and see
if it still works.

Thanks!
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


[v2 PATCH 2/2] mac80211: Use rhltable instead of rhashtable

2016-09-19 Thread Herbert Xu
mac80211 currently uses rhashtable with insecure_elasticity set
to true.  The latter is because of duplicate objects.  What's
more, mac80211 walks the rhashtable chains by hand which is broken
as rhashtable may contain multiple tables due to resizing or
rehashing.

This patch fixes it by converting it to the newly added rhltable
interface which is designed for use with duplicate objects.

With rhltable a lookup returns a list of objects instead of a
single one.  This is then fed into the existing for_each_sta_info
macro.

This patch also deletes the sta_addr_hash function since rhashtable
defaults to jhash.

Signed-off-by: Herbert Xu 
---

 net/mac80211/ieee80211_i.h |2 -
 net/mac80211/rx.c  |7 +-
 net/mac80211/sta_info.c|   52 ++---
 net/mac80211/sta_info.h|   19 ++--
 net/mac80211/status.c  |7 +-
 5 files changed, 33 insertions(+), 54 deletions(-)

diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index f56d342..1a52cd4 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1208,7 +1208,7 @@ struct ieee80211_local {
spinlock_t tim_lock;
unsigned long num_sta;
struct list_head sta_list;
-   struct rhashtable sta_hash;
+   struct rhltable sta_hash;
struct timer_list sta_cleanup;
int sta_generation;
 
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 9dce3b1..5e26dc6 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -3940,7 +3940,7 @@ static void __ieee80211_rx_handle_packet(struct 
ieee80211_hw *hw,
__le16 fc;
struct ieee80211_rx_data rx;
struct ieee80211_sub_if_data *prev;
-   struct rhash_head *tmp;
+   struct rhlist_head *tmp;
int err = 0;
 
fc = ((struct ieee80211_hdr *)skb->data)->frame_control;
@@ -3983,13 +3983,10 @@ static void __ieee80211_rx_handle_packet(struct 
ieee80211_hw *hw,
goto out;
} else if (ieee80211_is_data(fc)) {
struct sta_info *sta, *prev_sta;
-   const struct bucket_table *tbl;
 
prev_sta = NULL;
 
-   tbl = rht_dereference_rcu(local->sta_hash.tbl, 
&local->sta_hash);
-
-   for_each_sta_info(local, tbl, hdr->addr2, sta, tmp) {
+   for_each_sta_info(local, hdr->addr2, sta, tmp) {
if (!prev_sta) {
prev_sta = sta;
continue;
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 19f14c9..198d0bd 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -67,12 +67,10 @@
 
 static const struct rhashtable_params sta_rht_params = {
.nelem_hint = 3, /* start small */
-   .insecure_elasticity = true, /* Disable chain-length checks. */
.automatic_shrinking = true,
.head_offset = offsetof(struct sta_info, hash_node),
.key_offset = offsetof(struct sta_info, addr),
.key_len = ETH_ALEN,
-   .hashfn = sta_addr_hash,
.max_size = CONFIG_MAC80211_STA_HASH_MAX_SIZE,
 };
 
@@ -80,8 +78,8 @@ static const struct rhashtable_params sta_rht_params = {
 static int sta_info_hash_del(struct ieee80211_local *local,
 struct sta_info *sta)
 {
-   return rhashtable_remove_fast(&local->sta_hash, &sta->hash_node,
- sta_rht_params);
+   return rhltable_remove(&local->sta_hash, &sta->hash_node,
+  sta_rht_params);
 }
 
 static void __cleanup_single_sta(struct sta_info *sta)
@@ -157,19 +155,22 @@ static void cleanup_single_sta(struct sta_info *sta)
sta_info_free(local, sta);
 }
 
+struct rhlist_head *sta_info_hash_lookup(struct ieee80211_local *local,
+const u8 *addr)
+{
+   return rhltable_lookup(&local->sta_hash, addr, sta_rht_params);
+}
+
 /* protected by RCU */
 struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata,
  const u8 *addr)
 {
struct ieee80211_local *local = sdata->local;
+   struct rhlist_head *tmp;
struct sta_info *sta;
-   struct rhash_head *tmp;
-   const struct bucket_table *tbl;
 
rcu_read_lock();
-   tbl = rht_dereference_rcu(local->sta_hash.tbl, &local->sta_hash);
-
-   for_each_sta_info(local, tbl, addr, sta, tmp) {
+   for_each_sta_info(local, addr, sta, tmp) {
if (sta->sdata == sdata) {
rcu_read_unlock();
/* this is safe as the caller must already hold
@@ -190,14 +191,11 @@ struct sta_info *sta_info_get_bss(struct 
ieee80211_sub_if_data *sdata,
  const u8 *addr)
 {
struct ieee80211_local *local = sdata->local;
+   struct rhlist_head *tmp;
struct sta_info *sta;
-   struct rhash_head *tmp;
-   const struct bucket_table *tbl;
 
   

Re: [PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Herbert Xu
On Mon, Sep 19, 2016 at 10:25:18AM +0200, Johannes Berg wrote:
> 
> > Yes, it's passing all the wpa_supplicant tests, so
> > 
> > Acked-by: Johannes Berg 
> > 
> 
> I take that back. I think it's leaking memory - my tests never used to
> run out of memory, but now they eventually do.
> 
> I'll try to figure out more.

Interesting.  The kernel test robot found a bug in the insertion
slowpath where we end up inserting without taking the inner spinlock
in case of a nested table.  Not sure whether that's the same issue
as you're seeing but I'll do a v2 posting.

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [PATCH] NFC: nfcmrvl: constify nfcmrvl_if_ops structures

2016-09-19 Thread Samuel Ortiz
Hi Julia,

On Tue, Aug 09, 2016 at 07:03:50PM +0200, Julia Lawall wrote:
> The nfcmrvl_if_ops structures are never modified, so declare them as const.
> 
> Done with the help of Coccinelle.
> 
> Signed-off-by: Julia Lawall 
> 
> ---
>  drivers/nfc/nfcmrvl/i2c.c |2 +-
>  drivers/nfc/nfcmrvl/main.c|2 +-
>  drivers/nfc/nfcmrvl/nfcmrvl.h |4 ++--
>  drivers/nfc/nfcmrvl/spi.c |2 +-
>  drivers/nfc/nfcmrvl/uart.c|2 +-
>  drivers/nfc/nfcmrvl/usb.c |2 +-
>  6 files changed, 7 insertions(+), 7 deletions(-)
Applied as well, thanks.

Cheers,
Samuel.


Re: TCP data throughput for BCM43362

2016-09-19 Thread Jörg Krause
Hi Arend,

On Wed, 2016-09-14 at 20:13 +0200, Arend Van Spriel wrote:
> On 14-9-2016 15:41, Jörg Krause wrote:
> > 
> > Hi,
> > 
> > On Mon, 2016-08-29 at 23:15 +0200, Jörg Krause wrote:
> > > 
> > > On Mi, 2016-08-24 at 20:35 +0200, Arend Van Spriel wrote:
> > > > 
> > > > 
> > > > On 22-8-2016 15:37, Jörg Krause wrote:
> > > > > 
> > > > > 
> > > > > 
> > > > > Hi all,
> > > > > 
> > > > > I am back from vacation and I'd like to do more
> > > > > investigations
> > > > > about
> > > > > this issue. Please see my comments below...
> > > > > 
> > > > > On Sun, 2016-08-07 at 13:41 +0200, Arend van Spriel wrote:
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > On 06-08-16 16:12, Jörg Krause wrote:
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > Hi all,
> > > > > > 
> > > > > > A bit weird email format making it a bit hard to determine
> > > > > > where
> > > > > > your
> > > > > > last reply starts...
> > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > On Fr, 2016-08-05 at 17:56 -0700, Franky Lin wrote:
> > > > > > > 
> > > > > > > On Fri, Aug 5, 2016 at 2:29 PM, Jörg Krause  > > > > > > @emb
> > > > > > > ed
> > > > > > > ded.
> > > > > > > ro
> > > > > > > cks>
> > > > > > > wrote:
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > Am 5. August 2016 23:01:10 MESZ, schrieb Arend Van Spriel
> > > > > > > <
> > > > > > > arend.vanspr...@broadcom.com>:
> > > > > > > 
> > > > > > > 
> > > > > > > Op 5 aug. 2016 22:46 schreef "Jörg Krause"
> > > > > > > :
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > Hi,
> > > > > > > 
> > > > > > > I'm using a custom ARM board with an BCM43362 wifi chip
> > > > > > > from
> > > > > > > 
> > > > > > > Broadcom.
> > > > > > > 
> > > > > > > 
> > > > > > > The wifi chip is attached via SDIO to the controller with
> > > > > > > a
> > > > > > > clock of
> > > > > > > 48MHz. Linux kernel version is 4.7.
> > > > > > > 
> > > > > > > When measuring the network bandwidth with iperf3 I get a
> > > > > > > bandwith of
> > > > > > > only around 5 Mbps. I found a similar thread at the
> > > > > > > Broadcom
> > > > > > > 
> > > > > > > community
> > > > > > > 
> > > > > > > 
> > > > > > > [1] where the test was done with a M4 CPU + BCM43362 and
> > > > > > > an
> > > > > > > average
> > > > > > > result of 3.3 Mbps.
> > > > > > > 
> > > > > > > Interestingly, a BCM43362 Wi-Fi Dev Kit [2] notes a TCP
> > > > > > > data
> > > > > > > 
> > > > > > > throughput
> > > > > > > 
> > > > > > > 
> > > > > > > greater than 20 Mbps.
> > > > > > > 
> > > > > > > Why is the throughput I measured much lower? Note that I
> > > > > > > measured
> > > > > > > several times with almost no neighbor devices or
> > > > > > > networks.
> > > > > > > 
> > > > > > > This is a test sample measured with iperf3:
> > > > > > > 
> > > > > > > $ iperf3 -c 192.168.2.1 -i 1 -t 10
> > > > > > > Connecting to host 192.168.2.1, port 5201
> > > > > > > [  4] local 192.168.2.155 port 36442 connected to
> > > > > > > 192.168.2.1
> > > > > > > 
> > > > > > > port
> > > > > > > 
> > > > > > > 
> > > > > > > 5201
> > > > > > > [ ID]
> > > > > > > Interval   Transfer Bandwidth   Retr  Cwn
> > > > > > > d
> > > > > > > [  4]   0.00-1.00   sec   615 KBytes  5.04
> > > > > > > Mbits/sec0   56.6
> > > > > > > KBytes
> > > > > > > [  4]   1.00-2.00   sec   622 KBytes  5.10
> > > > > > > Mbits/sec0   84.8
> > > > > > > KBytes
> > > > > > > [  4]   2.00-3.00   sec   625 KBytes  5.12
> > > > > > > Mbits/sec0113
> > > > > > > KBytes
> > > > > > > [  4]   3.00-4.00   sec   571 KBytes  4.68
> > > > > > > Mbits/sec0140
> > > > > > > KBytes
> > > > > > > [  4]   4.00-5.00   sec   594 KBytes  4.87
> > > > > > > Mbits/sec0167
> > > > > > > KBytes
> > > > > > > [  4]   5.00-6.00   sec   628 KBytes  5.14
> > > > > > > Mbits/sec0195
> > > > > > > KBytes
> > > > > > > [  4]   6.00-7.00   sec   619 KBytes  5.07
> > > > > > > Mbits/sec0202
> > > > > > > KBytes
> > > > > > > [  4]   7.00-8.00   sec   608 KBytes  4.98
> > > > > > > Mbits/sec0202
> > > > > > > KBytes
> > > > > > > [  4]   8.00-9.00   sec   602 KBytes  4.93
> > > > > > > Mbits/sec0202
> > > > > > > KBytes
> > > > > > > [  4]   9.00-10.00  sec   537 KBytes  4.40
> > > > > > > Mbits/sec0202
> > > > > > > KBytes
> > > > > > > - - - - - - - - - - - - - - - - - - - - - - - - -
> > > > > > > [ ID]
> > > > > > > Interval   Transfer Bandwidth   Retr
> > > > > > > [  4]   0.00-10.00  sec  5.88 MBytes  4.93
> > > > > > > Mbits/sec0 sender
> > > > > > > [  4]   0.00-10.00  sec  5.68 MBytes  4.76
> > > > > > > Mbits/sec  receiver
> > > > > > > 
> > > > > > > 
> > > > > > > Not overly familiar with iperf3. Do these lines mean you
> > >

Re: [PATCH] NFC: pn533: constify pn533_phy_ops structures

2016-09-19 Thread Samuel Ortiz
Hi Julia,

On Tue, Aug 09, 2016 at 06:11:02PM +0200, Julia Lawall wrote:
> The pn533_phy_ops are never modified, so declare them as const.
> 
> Done with the help of Coccinelle.
> 
> Signed-off-by: Julia Lawall 
> 
> ---
>  drivers/nfc/pn533/i2c.c   |2 +-
>  drivers/nfc/pn533/pn533.c |2 +-
>  drivers/nfc/pn533/pn533.h |4 ++--
>  drivers/nfc/pn533/usb.c   |2 +-
>  4 files changed, 5 insertions(+), 5 deletions(-)
Applied to nfc-next, thanks.

Cheers,
Samuel.


[PATCH v2 19/25] iwlwifi: mvm: Add debugfs function for clocks diff

2016-09-19 Thread Luca Coelho
From: Roee Zamir 

New function, reveals the diff between gp2 and host time.

Signed-off-by: Roee Zamir 
Signed-off-by: Luca Coelho 
---

Sorry, I was missing a compilation flag in my .config and missed a
compilation error detected by kbuild-bot.  Here's the fix.

In v2:
   * added a helper function that was missing

Luca.

.../net/wireless/intel/iwlwifi/mvm/debugfs-vif.c   | 26 ++
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h   |  1 +
 drivers/net/wireless/intel/iwlwifi/mvm/utils.c | 22 ++
 3 files changed, 49 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
index b232717..8ff1921 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
@@ -504,6 +504,28 @@ static inline char *iwl_dbgfs_is_match(char *name, char 
*buf)
return !strncmp(name, buf, len) ? buf + len : NULL;
 }
 
+static ssize_t iwl_dbgfs_os_device_timediff_read(struct file *file,
+char __user *user_buf,
+size_t count, loff_t *ppos)
+{
+   struct ieee80211_vif *vif = file->private_data;
+   struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
+   struct iwl_mvm *mvm = mvmvif->mvm;
+   u32 curr_gp2;
+   u64 curr_os;
+   s64 diff;
+   char buf[64];
+   const size_t bufsz = sizeof(buf);
+   int pos = 0;
+
+   iwl_mvm_get_sync_time(mvm, &curr_gp2, &curr_os);
+   do_div(curr_os, NSEC_PER_USEC);
+   diff = curr_os - curr_gp2;
+   pos += scnprintf(buf + pos, bufsz - pos, "diff=%lld\n", diff);
+
+   return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+}
+
 static ssize_t iwl_dbgfs_tof_enable_write(struct ieee80211_vif *vif,
  char *buf,
  size_t count, loff_t *ppos)
@@ -1530,6 +1552,8 @@ MVM_DEBUGFS_READ_FILE_OPS(tof_range_response);
 MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_responder_params, 32);
 MVM_DEBUGFS_READ_WRITE_FILE_OPS(quota_min, 32);
 MVM_DEBUGFS_WRITE_FILE_OPS(lqm_send_cmd, 64);
+MVM_DEBUGFS_READ_FILE_OPS(os_device_timediff);
+
 
 void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
 {
@@ -1570,6 +1594,8 @@ void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, 
struct ieee80211_vif *vif)
MVM_DEBUGFS_ADD_FILE_VIF(quota_min, mvmvif->dbgfs_dir,
 S_IRUSR | S_IWUSR);
MVM_DEBUGFS_ADD_FILE_VIF(lqm_send_cmd, mvmvif->dbgfs_dir, S_IWUSR);
+   MVM_DEBUGFS_ADD_FILE_VIF(os_device_timediff,
+mvmvif->dbgfs_dir, S_IRUSR);
 
if (vif->type == NL80211_IFTYPE_STATION && !vif->p2p &&
mvmvif == mvm->bf_allowed_vif)
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
index e68a2bd..b7cfdcb 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
@@ -1268,6 +1268,7 @@ u8 iwl_mvm_mac80211_idx_to_hwrate(int rate_idx);
 void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm);
 u8 first_antenna(u8 mask);
 u8 iwl_mvm_next_antenna(struct iwl_mvm *mvm, u8 valid, u8 last_idx);
+void iwl_mvm_get_sync_time(struct iwl_mvm *mvm, u32 *gp2, u64 *boottime);
 
 /* Tx / Host Commands */
 int __must_check iwl_mvm_send_cmd(struct iwl_mvm *mvm,
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
index 7c138fe..9e366e2 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
@@ -1225,6 +1225,28 @@ void iwl_mvm_inactivity_check(struct iwl_mvm *mvm)
rcu_read_unlock();
 }
 
+void iwl_mvm_get_sync_time(struct iwl_mvm *mvm, u32 *gp2, u64 *boottime)
+{
+   bool ps_disabled;
+
+   lockdep_assert_held(&mvm->mutex);
+
+   /* Disable power save when reading GP2 */
+   ps_disabled = mvm->ps_disabled;
+   if (!ps_disabled) {
+   mvm->ps_disabled = true;
+   iwl_mvm_power_update_device(mvm);
+   }
+
+   *gp2 = iwl_read_prph(mvm->trans, DEVICE_SYSTEM_TIME_REG);
+   *boottime = ktime_get_boot_ns();
+
+   if (!ps_disabled) {
+   mvm->ps_disabled = ps_disabled;
+   iwl_mvm_power_update_device(mvm);
+   }
+}
+
 int iwl_mvm_send_lqm_cmd(struct ieee80211_vif *vif,
 enum iwl_lqm_cmd_operatrions operation,
 u32 duration, u32 timeout)
-- 
2.9.3



Re: [PATCH] NFC: Delete owner assignment

2016-09-19 Thread Samuel Ortiz
Hi Markus,

On Mon, Aug 15, 2016 at 09:12:29AM +0200, SF Markus Elfring wrote:
> From: Markus Elfring 
> Date: Mon, 15 Aug 2016 09:00:26 +0200
> 
> The field "owner" is set by core. Thus delete an extra initialisation.
> 
> Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci
> Signed-off-by: Markus Elfring 
> ---
>  drivers/nfc/nfcmrvl/i2c.c | 1 -
>  drivers/nfc/pn533/i2c.c   | 1 -
>  drivers/nfc/s3fwrn5/i2c.c | 1 -
>  3 files changed, 3 deletions(-)
Applied to nfc-next, thanks.

Cheers,
Samuel.


Re: [PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Johannes Berg

> OK, it's finally ready now.
> 
> This series contains one two patches.  The first adds the rhlist
> interface and the second converts mac80211 to use it.  If this works
> out I'll then proceed to convert the other insecure_elasticity
> users over to this.

Thanks a lot Herbert!

> I've tested the rhlist code with test_rhashtable but I haven't
> tested the mac80211 conversion.  So please give it a go and see
> if it still works.

Yes, it's passing all the wpa_supplicant tests, so

Acked-by: Johannes Berg 

I assume you want at least the first patch to be merged through net-
next so you can build on it.

Dave, I don't have anything pending right now since you just pulled, so
I can also wait for you to apply the rhltable and then merge the
mac80211 patch. If you apply the mac80211 patch directly I'll just wait
for both of them to show up and then I'll fast forward to your tree.

Thanks,
johannes


Re: [PATCH 0/2] rhashtable: rhashtable with duplicate objects

2016-09-19 Thread Johannes Berg

> Yes, it's passing all the wpa_supplicant tests, so
> 
> Acked-by: Johannes Berg 
> 

I take that back. I think it's leaking memory - my tests never used to
run out of memory, but now they eventually do.

I'll try to figure out more.

johannes


RE: [PATCH v2 3/9] cfg80211: add add_nan_func / rm_nan_func

2016-09-19 Thread Otcheretianski, Andrei
> -Original Message-
> From: Arend Van Spriel [mailto:arend.vanspr...@broadcom.com]
> Sent: Sunday, September 18, 2016 22:54
> To: Luca Coelho ; johan...@sipsolutions.net
> Cc: linux-wireless@vger.kernel.org; Beker, Ayala ;
> Otcheretianski, Andrei ; Grumbach,
> Emmanuel ; Coelho, Luciano
> 
> Subject: Re: [PATCH v2 3/9] cfg80211: add add_nan_func / rm_nan_func
> 
> On 16-9-2016 10:33, Luca Coelho wrote:
> > From: Ayala Beker 
> >
> > A NAN function can be either publish, subscribe or follow up. Make all
> > the necessary verifications and just pass the request to the driver.
> > Allow the user space application that starts NAN to forbid any other
> > socket to add or remove functions.
> >
> > Signed-off-by: Andrei Otcheretianski 
> > Signed-off-by: Emmanuel Grumbach 
> > Signed-off-by: Ayala Beker 
> > Signed-off-by: Luca Coelho 
> > ---
> 
> [...]
> 
> > diff --git a/include/uapi/linux/nl80211.h
> > b/include/uapi/linux/nl80211.h index 7ab18c8..ab16c8e 100644
> > --- a/include/uapi/linux/nl80211.h
> > +++ b/include/uapi/linux/nl80211.h
> > @@ -847,6 +847,24 @@
> >   * After this command NAN functions can be added.
> >   * @NL80211_CMD_STOP_NAN: Stop the NAN operation, identified by
> >   * its %NL80211_ATTR_WDEV interface.
> > + * @NL80211_CMD_ADD_NAN_FUNCTION: Add a NAN function. The
> function is defined
> > + * with %NL80211_ATTR_NAN_FUNC nested attribute. When called,
> this
> > + * operation returns the strictly positive and unique instance id
> > + * (%NL80211_ATTR_NAN_FUNC_INST_ID) and a cookie
> (%NL80211_ATTR_COOKIE)
> > + * of the function upon success.
> > + * Since instance ID's can be re-used, this cookie is the right
> > + * way to identify the function. This will avoid races when a termination
> > + * event is handled by the user space after it has already added a new
> > + * function that got the same instance id from the kernel as the one
> > + * which just terminated.
> > + * This cookie may be used in NAN events even before the command
> > + * returns, so userspace shouldn't process NAN events until it
> processes
> > + * the response to this command.
> > + * Look at %NL80211_ATTR_SOCKET_OWNER as well.
> > + * @NL80211_CMD_RM_NAN_FUNCTION: Remove a NAN function by
> cookie.
> > + * This command is also used as a notification sent when a NAN function
> is
> > + * terminated. This will contain a %NL80211_ATTR_NAN_FUNC_INST_ID
> > + * and %NL80211_ATTR_COOKIE attributes.
> 
> This patch does not show the notification scenario as it is added in patch 6. 
> So
> those three lines could be added by that patch instead to keep things
> logically together.
> 

Good point. Thanks

> Regards,
> Arend


RE: [PATCH v2 4/9] cfg80211: allow the user space to change current NAN configuration

2016-09-19 Thread Otcheretianski, Andrei
> -Original Message-
> From: Arend Van Spriel [mailto:arend.vanspr...@broadcom.com]
> Sent: Sunday, September 18, 2016 22:43
> To: Luca Coelho ; johan...@sipsolutions.net
> Cc: linux-wireless@vger.kernel.org; Beker, Ayala ;
> Otcheretianski, Andrei ; Grumbach,
> Emmanuel ; Coelho, Luciano
> 
> Subject: Re: [PATCH v2 4/9] cfg80211: allow the user space to change current
> NAN configuration
> 
> On 16-9-2016 10:33, Luca Coelho wrote:
> > From: Ayala Beker 
> >
> > Some NAN configuration paramaters may change during the operation of
> > the NaN device. For example, a user may want to update master
> > preference
> 
> typo: NAN iso NaN.

Thanks

> 
> Regards,
> Arend


RE: [PATCH v2 3/9] cfg80211: add add_nan_func / rm_nan_func

2016-09-19 Thread Otcheretianski, Andrei


> -Original Message-
> From: Arend Van Spriel [mailto:arend.vanspr...@broadcom.com]
> Sent: Sunday, September 18, 2016 22:29
> To: Luca Coelho ; johan...@sipsolutions.net
> Cc: linux-wireless@vger.kernel.org; Beker, Ayala ;
> Otcheretianski, Andrei ; Grumbach,
> Emmanuel ; Coelho, Luciano
> 
> Subject: Re: [PATCH v2 3/9] cfg80211: add add_nan_func / rm_nan_func
> 
> On 16-9-2016 10:33, Luca Coelho wrote:
> > From: Ayala Beker 
> >
> > A NAN function can be either publish, subscribe or follow up. Make all
> > the necessary verifications and just pass the request to the driver.
> > Allow the user space application that starts NAN to forbid any other
> > socket to add or remove functions.
> >
> > Signed-off-by: Andrei Otcheretianski 
> > Signed-off-by: Emmanuel Grumbach 
> > Signed-off-by: Ayala Beker 
> > Signed-off-by: Luca Coelho 
> > ---
> >  include/net/cfg80211.h   |  91 +++
> >  include/uapi/linux/nl80211.h | 153 ++
> >  net/wireless/core.c  |   3 +-
> >  net/wireless/nl80211.c   | 368
> +++
> >  net/wireless/rdev-ops.h  |  21 +++
> >  net/wireless/trace.h |  39 +
> >  net/wireless/util.c  |  22 +++
> >  7 files changed, 696 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index
> > ca64d69..ced5b8a 100644
> > --- a/include/net/cfg80211.h
> > +++ b/include/net/cfg80211.h
> > @@ -2306,6 +2306,73 @@ struct cfg80211_nan_conf {  };
> >
> >  /**
> > + * struct cfg80211_nan_func_filter - a NAN function Rx / Tx filter
> > + *
> > + * @filter: the content of the filter
> > + * @len: the length of the filter
> > + */
> > +struct cfg80211_nan_func_filter {
> > +   const u8 *filter;
> > +   u8 len;
> > +};
> > +
> > +/**
> > + * struct cfg80211_nan_func - a NAN function
> > + *
> > + * @type: &enum nl80211_nan_function_type
> > + * @service_id: the service ID of the function
> > + * @publish_type: &nl80211_nan_publish_type
> > + * @close_range: if true, the range should be limited. Threshold is
> > + * implementation specific.
> > + * @publish_bcast: if true, the solicited publish should be
> > +broadcasted
> > + * @subscribe_active: if true, the subscribe is active
> > + * @followup_id: the instance ID for follow up
> > + * @followup_reqid: the requestor instance ID for follow up
> > + * @followup_dest: MAC address of the recipient of the follow up
> > + * @ttl: time to live counter in DW.
> > + * @serv_spec_info: Service Specific Info
> > + * @serv_spec_info_len: Service Specific Info length
> > + * @srf_include: if true, SRF is inclusive
> > + * @srf_bf: Bloom Filter
> > + * @srf_bf_len: Bloom Filter length
> > + * @srf_bf_idx: Bloom Filter index
> > + * @srf_macs: SRF MAC addresses
> > + * @srf_num_macs: number of MAC addresses in SRF
> > + * @rx_filters: rx filters that are matched with corresponding peer's
> > +tx_filter
> > + * @tx_filters: filters that should be transmitted in the SDF.
> > + * @num_rx_filters: length of &rx_filters.
> > + * @num_tx_filters: length of &tx_filters.
> > + * @instance_id: driver allocated id of the function.
> > + * @cookie: unique NAN function identifier.
> 
> Might be wrong but it seems a subset of the fields is used depending on the
> type of NAN function. Maybe better to separate the function type specific
> field in a sub structure defintion.

Most of the fields are common for all the function types. Of course some 
combinations aren't valid.
And there are few followup specific fields. The spec defines a single "NAN 
function" entity (for publish, subscribe and followup) which is represented in 
an SDA (service descriptor attribute).
This is what this struct tries to reflect.

> 
> > + */
> > +struct cfg80211_nan_func {
> > +   enum nl80211_nan_function_type type;
> > +   u8 service_id[NL80211_NAN_FUNC_SERVICE_ID_LEN];
> > +   u8 publish_type;
> > +   bool close_range;
> > +   bool publish_bcast;
> > +   bool subscribe_active;
> > +   u8 followup_id;
> > +   u8 followup_reqid;
> > +   struct mac_address followup_dest;
> > +   u32 ttl;
> > +   const u8 *serv_spec_info;
> > +   u8 serv_spec_info_len;
> > +   bool srf_include;
> > +   const u8 *srf_bf;
> > +   u8 srf_bf_len;
> > +   u8 srf_bf_idx;
> > +   struct mac_address *srf_macs;
> > +   int srf_num_macs;
> > +   struct cfg80211_nan_func_filter *rx_filters;
> > +   struct cfg80211_nan_func_filter *tx_filters;
> > +   u8 num_tx_filters;
> > +   u8 num_rx_filters;
> > +   u8 instance_id;
> > +   u64 cookie;
> > +};
> > +
> > +/**
> >   * struct cfg80211_ops - backend description for wireless configuration
> >   *
> >   * This struct is registered by fullmac card drivers and/or wireless
> > stacks @@ -2595,6 +2662,14 @@ struct cfg80211_nan_conf {
> >   * peers must be on the base channel when the call completes.
> >   * @start_nan: Start the NAN interface.
> >   * @stop_nan: Stop the NAN interface.
> > + * @add_nan_func: Add a NAN function. Returns negative valu

[PATCH] cfg80211: add checks for beacon rate, extend to mesh

2016-09-19 Thread Johannes Berg
From: Johannes Berg 

The previous commit added support for specifying the beacon rate
for AP mode. Add features checks to this, and extend it to also
support the rate configuration for mesh networks. For IBSS it's
not as simple due to joining etc., so that's not yet supported.

Signed-off-by: Johannes Berg 
---
 include/net/cfg80211.h   |  4 +++-
 include/uapi/linux/nl80211.h | 17 +++-
 net/wireless/nl80211.c   | 46 +---
 3 files changed, 54 insertions(+), 13 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index e0949c8bc2d1..ed37304fa09d 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -712,7 +712,7 @@ struct cfg80211_bitrate_mask {
  * MAC address based access control
  * @pbss: If set, start as a PCP instead of AP. Relevant for DMG
  * networks.
- * @beacon_rate: masks for setting user configured beacon tx rate.
+ * @beacon_rate: bitrate to be used for beacons
  */
 struct cfg80211_ap_settings {
struct cfg80211_chan_def chandef;
@@ -1365,6 +1365,7 @@ struct mesh_config {
  * @beacon_interval: beacon interval to use
  * @mcast_rate: multicat rate for Mesh Node [6Mbps is the default for 802.11a]
  * @basic_rates: basic rates to use when creating the mesh
+ * @beacon_rate: bitrate to be used for beacons
  *
  * These parameters are fixed when the mesh is created.
  */
@@ -1385,6 +1386,7 @@ struct mesh_setup {
u16 beacon_interval;
int mcast_rate[NUM_NL80211_BANDS];
u32 basic_rates;
+   struct cfg80211_bitrate_mask beacon_rate;
 };
 
 /**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 220694151434..ec10d1b2838f 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1343,7 +1343,13 @@ enum nl80211_commands {
  * enum nl80211_band value is used as the index (nla_type() of the nested
  * data. If a band is not included, it will be configured to allow all
  * rates based on negotiated supported rates information. This attribute
- * is used with %NL80211_CMD_SET_TX_BITRATE_MASK.
+ * is used with %NL80211_CMD_SET_TX_BITRATE_MASK and with starting AP,
+ * and joining mesh networks (not IBSS yet). In the later case, it must
+ * specify just a single bitrate, which is to be used for the beacon.
+ * The driver must also specify support for this with the extended
+ * features NL80211_EXT_FEATURE_BEACON_RATE_LEGACY,
+ * NL80211_EXT_FEATURE_BEACON_RATE_HT and
+ * NL80211_EXT_FEATURE_BEACON_RATE_VHT.
  *
  * @NL80211_ATTR_FRAME_MATCH: A binary attribute which typically must contain
  * at least one byte, currently used with @NL80211_CMD_REGISTER_FRAME.
@@ -4551,6 +4557,12 @@ enum nl80211_feature_flags {
  * (if available).
  * @NL80211_EXT_FEATURE_SET_SCAN_DWELL: This driver supports configuration of
  * channel dwell time.
+ * @NL80211_EXT_FEATURE_BEACON_RATE_LEGACY: Driver supports beacon rate
+ * configuration (AP/mesh), supporting a legacy (non HT/VHT) rate.
+ * @NL80211_EXT_FEATURE_BEACON_RATE_HT: Driver supports beacon rate
+ * configuration (AP/mesh) with HT rates.
+ * @NL80211_EXT_FEATURE_BEACON_RATE_VHT: Driver supports beacon rate
+ * configuration (AP/mesh) with VHT rates.
  *
  * @NUM_NL80211_EXT_FEATURES: number of extended features.
  * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
@@ -4562,6 +4574,9 @@ enum nl80211_ext_feature_index {
NL80211_EXT_FEATURE_SCAN_START_TIME,
NL80211_EXT_FEATURE_BSS_PARENT_TSF,
NL80211_EXT_FEATURE_SET_SCAN_DWELL,
+   NL80211_EXT_FEATURE_BEACON_RATE_LEGACY,
+   NL80211_EXT_FEATURE_BEACON_RATE_HT,
+   NL80211_EXT_FEATURE_BEACON_RATE_VHT,
 
/* add new features before the definition below */
NUM_NL80211_EXT_FEATURES,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index a10484da60c0..b8441e60b0f6 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -3569,13 +3569,12 @@ out:
return 0;
 }
 
-static int validate_beacon_tx_rate(struct cfg80211_ap_settings *params)
+static int validate_beacon_tx_rate(struct cfg80211_registered_device *rdev,
+  enum nl80211_band band,
+  struct cfg80211_bitrate_mask *beacon_rate)
 {
-   u32 rate, count_ht, count_vht, i;
-   enum nl80211_band band;
-
-   band = params->chandef.chan->band;
-   rate = params->beacon_rate.control[band].legacy;
+   u32 count_ht, count_vht, i;
+   u32 rate = beacon_rate->control[band].legacy;
 
/* Allow only one rate */
if (hweight32(rate) > 1)
@@ -3583,9 +3582,9 @@ static int validate_beacon_tx_rate(struct 
cfg80211_ap_settings *params)
 
count_ht = 0;
for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++) {
-   if (hweight8(params->beacon_rate.control[band].ht_mcs[i]) > 1) {
+   if (hweight8(beacon_rate->control[band].ht

[PATCH 21/25] iwlwifi: mvm: move AP-specific code to right function

2016-09-19 Thread Luca Coelho
From: Johannes Berg 

There's no need for the common MAC context function to have an
if on AP mode, the values can be overridden in the AP-specific
function later. Clean that up by adding the full command as a
new parameter to the AP-specific function, and doing it there.

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c | 42 +++
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
index d742d27..6b962d6 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
@@ -774,26 +774,6 @@ static void iwl_mvm_mac_ctxt_cmd_common(struct iwl_mvm 
*mvm,
cmd->ac[txf].fifos_mask = BIT(txf);
}
 
-   if (vif->type == NL80211_IFTYPE_AP) {
-   /* in AP mode, the MCAST FIFO takes the EDCA params from VO */
-   cmd->ac[IWL_MVM_TX_FIFO_VO].fifos_mask |=
-   BIT(IWL_MVM_TX_FIFO_MCAST);
-
-   /*
-* in AP mode, pass probe requests and beacons from other APs
-* (needed for ht protection); when there're no any associated
-* station don't ask FW to pass beacons to prevent unnecessary
-* wake-ups.
-*/
-   cmd->filter_flags |= cpu_to_le32(MAC_FILTER_IN_PROBE_REQUEST);
-   if (mvmvif->ap_assoc_sta_count || !mvm->drop_bcn_ap_mode) {
-   cmd->filter_flags |= cpu_to_le32(MAC_FILTER_IN_BEACON);
-   IWL_DEBUG_HC(mvm, "Asking FW to pass beacons\n");
-   } else {
-   IWL_DEBUG_HC(mvm, "No need to receive beacons\n");
-   }
-   }
-
if (vif->bss_conf.qos)
cmd->qos_flags |= cpu_to_le32(MAC_QOS_FLG_UPDATE_EDCA);
 
@@ -1191,6 +1171,7 @@ static void iwl_mvm_mac_ap_iterator(void *_data, u8 *mac,
  */
 static void iwl_mvm_mac_ctxt_cmd_fill_ap(struct iwl_mvm *mvm,
 struct ieee80211_vif *vif,
+struct iwl_mac_ctx_cmd *cmd,
 struct iwl_mac_data_ap *ctxt_ap,
 bool add)
 {
@@ -1201,6 +1182,23 @@ static void iwl_mvm_mac_ctxt_cmd_fill_ap(struct iwl_mvm 
*mvm,
.beacon_device_ts = 0
};
 
+   /* in AP mode, the MCAST FIFO takes the EDCA params from VO */
+   cmd->ac[IWL_MVM_TX_FIFO_VO].fifos_mask |= BIT(IWL_MVM_TX_FIFO_MCAST);
+
+   /*
+* in AP mode, pass probe requests and beacons from other APs
+* (needed for ht protection); when there're no any associated
+* station don't ask FW to pass beacons to prevent unnecessary
+* wake-ups.
+*/
+   cmd->filter_flags |= cpu_to_le32(MAC_FILTER_IN_PROBE_REQUEST);
+   if (mvmvif->ap_assoc_sta_count || !mvm->drop_bcn_ap_mode) {
+   cmd->filter_flags |= cpu_to_le32(MAC_FILTER_IN_BEACON);
+   IWL_DEBUG_HC(mvm, "Asking FW to pass beacons\n");
+   } else {
+   IWL_DEBUG_HC(mvm, "No need to receive beacons\n");
+   }
+
ctxt_ap->bi = cpu_to_le32(vif->bss_conf.beacon_int);
ctxt_ap->bi_reciprocal =
cpu_to_le32(iwl_mvm_reciprocal(vif->bss_conf.beacon_int));
@@ -1258,7 +1256,7 @@ static int iwl_mvm_mac_ctxt_cmd_ap(struct iwl_mvm *mvm,
iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, NULL, action);
 
/* Fill the data specific for ap mode */
-   iwl_mvm_mac_ctxt_cmd_fill_ap(mvm, vif, &cmd.ap,
+   iwl_mvm_mac_ctxt_cmd_fill_ap(mvm, vif, &cmd, &cmd.ap,
 action == FW_CTXT_ACTION_ADD);
 
return iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd);
@@ -1277,7 +1275,7 @@ static int iwl_mvm_mac_ctxt_cmd_go(struct iwl_mvm *mvm,
iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, NULL, action);
 
/* Fill the data specific for GO mode */
-   iwl_mvm_mac_ctxt_cmd_fill_ap(mvm, vif, &cmd.go.ap,
+   iwl_mvm_mac_ctxt_cmd_fill_ap(mvm, vif, &cmd, &cmd.go.ap,
 action == FW_CTXT_ACTION_ADD);
 
cmd.go.ctwin = cpu_to_le32(noa->oppps_ctwindow &
-- 
2.9.3



[PATCH 11/25] iwlwifi: move BIOS MCC retrieval to common code

2016-09-19 Thread Luca Coelho
From: Arik Nemtsov 

This will be used by more than MVM, so move it to iwlwifi

While at it, rename WRD_METHOD to the more appropriate
WRDD_METHOD and add some documentation.

Signed-off-by: Arik Nemtsov 
Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c | 89 +
 drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h | 20 -
 drivers/net/wireless/intel/iwlwifi/mvm/nvm.c   | 93 +-
 3 files changed, 109 insertions(+), 93 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
index adba3b0..3bd6fc1 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
@@ -67,6 +67,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "iwl-drv.h"
 #include "iwl-modparams.h"
 #include "iwl-nvm-parse.h"
@@ -904,3 +905,91 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct 
iwl_cfg *cfg,
return regd;
 }
 IWL_EXPORT_SYMBOL(iwl_parse_nvm_mcc_info);
+
+#ifdef CONFIG_ACPI
+#define WRDD_METHOD"WRDD"
+#define WRDD_WIFI  (0x07)
+#define WRDD_WIGIG (0x10)
+
+static u32 iwl_wrdd_get_mcc(struct device *dev, union acpi_object *wrdd)
+{
+   union acpi_object *mcc_pkg, *domain_type, *mcc_value;
+   u32 i;
+
+   if (wrdd->type != ACPI_TYPE_PACKAGE ||
+   wrdd->package.count < 2 ||
+   wrdd->package.elements[0].type != ACPI_TYPE_INTEGER ||
+   wrdd->package.elements[0].integer.value != 0) {
+   IWL_DEBUG_EEPROM(dev, "Unsupported wrdd structure\n");
+   return 0;
+   }
+
+   for (i = 1 ; i < wrdd->package.count ; ++i) {
+   mcc_pkg = &wrdd->package.elements[i];
+
+   if (mcc_pkg->type != ACPI_TYPE_PACKAGE ||
+   mcc_pkg->package.count < 2 ||
+   mcc_pkg->package.elements[0].type != ACPI_TYPE_INTEGER ||
+   mcc_pkg->package.elements[1].type != ACPI_TYPE_INTEGER) {
+   mcc_pkg = NULL;
+   continue;
+   }
+
+   domain_type = &mcc_pkg->package.elements[0];
+   if (domain_type->integer.value == WRDD_WIFI)
+   break;
+
+   mcc_pkg = NULL;
+   }
+
+   if (mcc_pkg) {
+   mcc_value = &mcc_pkg->package.elements[1];
+   return mcc_value->integer.value;
+   }
+
+   return 0;
+}
+
+int iwl_get_bios_mcc(struct device *dev, char *mcc)
+{
+   acpi_handle root_handle;
+   acpi_handle handle;
+   struct acpi_buffer wrdd = {ACPI_ALLOCATE_BUFFER, NULL};
+   acpi_status status;
+   u32 mcc_val;
+
+   root_handle = ACPI_HANDLE(dev);
+   if (!root_handle) {
+   IWL_DEBUG_EEPROM(dev,
+"Could not retrieve root port ACPI handle\n");
+   return -ENOENT;
+   }
+
+   /* Get the method's handle */
+   status = acpi_get_handle(root_handle, (acpi_string)WRDD_METHOD,
+&handle);
+   if (ACPI_FAILURE(status)) {
+   IWL_DEBUG_EEPROM(dev, "WRD method not found\n");
+   return -ENOENT;
+   }
+
+   /* Call WRDD with no arguments */
+   status = acpi_evaluate_object(handle, NULL, NULL, &wrdd);
+   if (ACPI_FAILURE(status)) {
+   IWL_DEBUG_EEPROM(dev, "WRDC invocation failed (0x%x)\n",
+status);
+   return -ENOENT;
+   }
+
+   mcc_val = iwl_wrdd_get_mcc(dev, wrdd.pointer);
+   kfree(wrdd.pointer);
+   if (!mcc_val)
+   return -ENOENT;
+
+   mcc[0] = (mcc_val >> 8) & 0xff;
+   mcc[1] = mcc_val & 0xff;
+   mcc[2] = '\0';
+   return 0;
+}
+IWL_EXPORT_SYMBOL(iwl_get_bios_mcc);
+#endif
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h
index d704d52..7249e5b 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h
@@ -5,7 +5,8 @@
  *
  * GPL LICENSE SUMMARY
  *
- * Copyright(c) 2008 - 2014 Intel Corporation. All rights reserved.
+ * Copyright(c) 2008 - 2015 Intel Corporation. All rights reserved.
+ * Copyright(c) 2016Intel Deutschland GmbH
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of version 2 of the GNU General Public License as
@@ -93,4 +94,21 @@ struct ieee80211_regdomain *
 iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
   int num_of_ch, __le32 *channels, u16 fw_mcc);
 
+#ifdef CONFIG_ACPI
+/**
+ * iwl_get_bios_mcc - read MCC from BIOS, if available
+ *
+ * @dev: the struct device
+ * @mcc: output buffer (3 bytes) that will get the MCC
+ *
+ * This function tries to read the current MCC from ACPI if av

[PATCH 23/25] iwlwifi: mvm: set HCMD_NAME for PHY_DB as well

2016-09-19 Thread Luca Coelho
From: Sara Sharon 

Currently it is logged as UNKNOWN.
Also, 0x6c seems to be the permanent ID for this command, remove
incorrect comment and uncomment the command from the commands
list.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c | 2 +-
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h | 2 +-
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c| 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c
index 7beba9a..2893826 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c
@@ -110,7 +110,7 @@ enum iwl_phy_db_section_type {
IWL_PHY_DB_MAX
 };
 
-#define PHY_DB_CMD 0x6c /* TEMP API - The actual is 0x8c */
+#define PHY_DB_CMD 0x6c
 
 /*
  * phy db - configure operational ucode
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
index fdd9506..9763369 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
@@ -205,7 +205,7 @@ enum {
/* Phy */
PHY_CONFIGURATION_CMD = 0x6a,
CALIB_RES_NOTIF_PHY_DB = 0x6b,
-   /* PHY_DB_CMD = 0x6c, */
+   PHY_DB_CMD = 0x6c,
 
/* ToF - 802.11mc FTM */
TOF_CMD = 0x10,
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index b2d8722..3eccd89 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -359,6 +359,7 @@ static const struct iwl_hcmd_names iwl_mvm_legacy_names[] = 
{
HCMD_NAME(BT_COEX_CI),
HCMD_NAME(PHY_CONFIGURATION_CMD),
HCMD_NAME(CALIB_RES_NOTIF_PHY_DB),
+   HCMD_NAME(PHY_DB_CMD),
HCMD_NAME(SCAN_OFFLOAD_COMPLETE),
HCMD_NAME(SCAN_OFFLOAD_UPDATE_PROFILES_CMD),
HCMD_NAME(SCAN_OFFLOAD_CONFIG_CMD),
-- 
2.9.3



[PATCH 22/25] iwlwifi: mvm: Add mem debugfs entry

2016-09-19 Thread Luca Coelho
From: Ido Yariv 

In order to access cached/paged memory, there are a couple of firmware
commands (one for UMAC and one for LMAC) that let the host access memory
and registers indirectly. Since this is done by the firmware on behalf
of the host, even if memory is paged out or cached, the host will
retrieve the memory as the firmware sees it (paged out memory will get
paged in).

Export this mechanism via a debugfs entry for both read and write
access.

WARNING: This mechanism has no protections at all. Invalid addresses may
crash or hang the firmware. Writing to arbitrary memory also comes with
no guarantees.

Signed-off-by: Ido Yariv 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 129 +++
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h  |  50 +
 2 files changed, 179 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
index 540b7c9..539d718 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
@@ -1518,6 +1518,132 @@ MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters_macs, 
256);
 MVM_DEBUGFS_READ_WRITE_FILE_OPS(d3_sram, 8);
 #endif
 
+static ssize_t iwl_dbgfs_mem_read(struct file *file, char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+   struct iwl_mvm *mvm = file->private_data;
+   struct iwl_dbg_mem_access_cmd cmd = {};
+   struct iwl_dbg_mem_access_rsp *rsp;
+   struct iwl_host_cmd hcmd = {
+   .flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL,
+   .data = { &cmd, },
+   .len = { sizeof(cmd) },
+   };
+   size_t delta, len;
+   ssize_t ret;
+
+   hcmd.id = iwl_cmd_id(*ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR,
+DEBUG_GROUP, 0);
+   cmd.op = cpu_to_le32(DEBUG_MEM_OP_READ);
+
+   /* Take care of alignment of both the position and the length */
+   delta = *ppos & 0x3;
+   cmd.addr = cpu_to_le32(*ppos - delta);
+   cmd.len = cpu_to_le32(min(ALIGN(count + delta, 4) / 4,
+ (size_t)DEBUG_MEM_MAX_SIZE_DWORDS));
+
+   mutex_lock(&mvm->mutex);
+   ret = iwl_mvm_send_cmd(mvm, &hcmd);
+   mutex_unlock(&mvm->mutex);
+
+   if (ret < 0)
+   return ret;
+
+   rsp = (void *)hcmd.resp_pkt->data;
+   if (le32_to_cpu(rsp->status) != DEBUG_MEM_STATUS_SUCCESS) {
+   ret = -ENXIO;
+   goto out;
+   }
+
+   len = min((size_t)le32_to_cpu(rsp->len) << 2,
+ iwl_rx_packet_payload_len(hcmd.resp_pkt) - sizeof(*rsp));
+   len = min(len - delta, count);
+   if (len < 0) {
+   ret = -EFAULT;
+   goto out;
+   }
+
+   ret = len - copy_to_user(user_buf, (void *)rsp->data + delta, len);
+   *ppos += ret;
+
+out:
+   iwl_free_resp(&hcmd);
+   return ret;
+}
+
+static ssize_t iwl_dbgfs_mem_write(struct file *file,
+  const char __user *user_buf, size_t count,
+  loff_t *ppos)
+{
+   struct iwl_mvm *mvm = file->private_data;
+   struct iwl_dbg_mem_access_cmd *cmd;
+   struct iwl_dbg_mem_access_rsp *rsp;
+   struct iwl_host_cmd hcmd = {};
+   size_t cmd_size;
+   size_t data_size;
+   u32 op, len;
+   ssize_t ret;
+
+   hcmd.id = iwl_cmd_id(*ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR,
+DEBUG_GROUP, 0);
+
+   if (*ppos & 0x3 || count < 4) {
+   op = DEBUG_MEM_OP_WRITE_BYTES;
+   len = min(count, (size_t)(4 - (*ppos & 0x3)));
+   data_size = len;
+   } else {
+   op = DEBUG_MEM_OP_WRITE;
+   len = min(count >> 2, (size_t)DEBUG_MEM_MAX_SIZE_DWORDS);
+   data_size = len << 2;
+   }
+
+   cmd_size = sizeof(*cmd) + ALIGN(data_size, 4);
+   cmd = kzalloc(cmd_size, GFP_KERNEL);
+   if (!cmd)
+   return -ENOMEM;
+
+   cmd->op = cpu_to_le32(op);
+   cmd->len = cpu_to_le32(len);
+   cmd->addr = cpu_to_le32(*ppos);
+   if (copy_from_user((void *)cmd->data, user_buf, data_size)) {
+   kfree(cmd);
+   return -EFAULT;
+   }
+
+   hcmd.flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL,
+   hcmd.data[0] = (void *)cmd;
+   hcmd.len[0] = cmd_size;
+
+   mutex_lock(&mvm->mutex);
+   ret = iwl_mvm_send_cmd(mvm, &hcmd);
+   mutex_unlock(&mvm->mutex);
+
+   kfree(cmd);
+
+   if (ret < 0)
+   return ret;
+
+   rsp = (void *)hcmd.resp_pkt->data;
+   if (rsp->status != DEBUG_MEM_STATUS_SUCCESS) {
+   ret = -ENXIO;
+   goto out;
+   }
+
+   ret = data_size;
+   *ppos += ret;
+
+out:
+   iwl_free_resp(&hcmd);
+   return ret;
+}
+
+static const struct file_operations iwl_dbgfs_mem_ops = {
+   .read = iwl_db

[PATCH 15/25] iwlwifi: mvm: document passing unexpected Block Ack Request frames

2016-09-19 Thread Luca Coelho
From: Johannes Berg 

When we get an unexpected Block Ack Request frame, the BAID from
the hardware will be invalid, and we'll pass it to mac80211 for
further handling (sending a delBA action frame.)

Add a comment explaining that, in case anyone looks in the future.

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
index 0274f14..a57c6ef 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
@@ -591,6 +591,11 @@ static bool iwl_mvm_reorder(struct iwl_mvm *mvm,
baid = (reorder & IWL_RX_MPDU_REORDER_BAID_MASK) >>
IWL_RX_MPDU_REORDER_BAID_SHIFT;
 
+   /*
+* This also covers the case of receiving a Block Ack Request
+* outside a BA session; we'll pass it to mac80211 and that
+* then sends a delBA action frame.
+*/
if (baid == IWL_RX_REORDER_DATA_INVALID_BAID)
return false;
 
-- 
2.9.3



[PATCH 13/25] iwlwifi: mvm: make iwl_mvm_update_sta() an inline

2016-09-19 Thread Luca Coelho
From: Johannes Berg 

There's no point in making this an out-of-line function
since it just calls a single other function with a few
changed parameters.

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c |  7 ---
 drivers/net/wireless/intel/iwlwifi/mvm/sta.h | 11 ---
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
index d3a0378..258a234 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
@@ -1297,13 +1297,6 @@ err:
return ret;
 }
 
-int iwl_mvm_update_sta(struct iwl_mvm *mvm,
-  struct ieee80211_vif *vif,
-  struct ieee80211_sta *sta)
-{
-   return iwl_mvm_sta_send_to_fw(mvm, sta, true, 0);
-}
-
 int iwl_mvm_drain_sta(struct iwl_mvm *mvm, struct iwl_mvm_sta *mvmsta,
  bool drain)
 {
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/sta.h
index 709542b..e068d53 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.h
@@ -473,9 +473,14 @@ int iwl_mvm_sta_send_to_fw(struct iwl_mvm *mvm, struct 
ieee80211_sta *sta,
 int iwl_mvm_add_sta(struct iwl_mvm *mvm,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta);
-int iwl_mvm_update_sta(struct iwl_mvm *mvm,
-  struct ieee80211_vif *vif,
-  struct ieee80211_sta *sta);
+
+static inline int iwl_mvm_update_sta(struct iwl_mvm *mvm,
+struct ieee80211_vif *vif,
+struct ieee80211_sta *sta)
+{
+   return iwl_mvm_sta_send_to_fw(mvm, sta, true, 0);
+}
+
 int iwl_mvm_rm_sta(struct iwl_mvm *mvm,
   struct ieee80211_vif *vif,
   struct ieee80211_sta *sta);
-- 
2.9.3



[PATCH 14/25] iwlwifi: move to wide ID for all commands

2016-09-19 Thread Luca Coelho
From: Sara Sharon 

Due to firmware design considerations, move to wide ID for
all commands.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/iwl-notif-wait.c | 8 ++--
 drivers/net/wireless/intel/iwlwifi/iwl-trans.c  | 3 +++
 drivers/net/wireless/intel/iwlwifi/iwl-trans.h  | 5 +++--
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c| 4 ++--
 drivers/net/wireless/intel/iwlwifi/pcie/internal.h  | 2 --
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 1 -
 drivers/net/wireless/intel/iwlwifi/pcie/tx.c| 2 +-
 7 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-notif-wait.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-notif-wait.c
index 8aa1f2b..88f260d 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-notif-wait.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-notif-wait.c
@@ -99,8 +99,12 @@ void iwl_notification_wait_notify(struct iwl_notif_wait_data 
*notif_wait,
continue;
 
for (i = 0; i < w->n_cmds; i++) {
-   if (w->cmds[i] ==
-   WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd)) {
+   u16 rec_id = WIDE_ID(pkt->hdr.group_id,
+pkt->hdr.cmd);
+
+   if (w->cmds[i] == rec_id ||
+   (!iwl_cmd_groupid(w->cmds[i]) &&
+DEF_ID(w->cmds[i]) == rec_id)) {
found = true;
break;
}
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
index b0bd67c..b42152c 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
@@ -140,6 +140,9 @@ int iwl_trans_send_cmd(struct iwl_trans *trans, struct 
iwl_host_cmd *cmd)
if (!(cmd->flags & CMD_ASYNC))
lock_map_acquire_read(&trans->sync_cmd_lockdep_map);
 
+   if (trans->wide_cmd_header && !iwl_cmd_groupid(cmd->id))
+   cmd->id = DEF_ID(cmd->id);
+
ret = trans->ops->send_cmd(trans, cmd);
 
if (!(cmd->flags & CMD_ASYNC))
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
index 04e998d..0296124 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
@@ -153,6 +153,7 @@ static inline u32 iwl_cmd_id(u8 opcode, u8 groupid, u8 
version)
 
 /* make u16 wide id out of u8 group and opcode */
 #define WIDE_ID(grp, opcode) ((grp << 8) | opcode)
+#define DEF_ID(opcode) ((1 << 8) | (opcode))
 
 /* due to the conversion, this group is special; new groups
  * should be defined in the appropriate fw-api header files
@@ -484,7 +485,6 @@ struct iwl_hcmd_arr {
  * @bc_table_dword: set to true if the BC table expects the byte count to be
  * in DWORD (as opposed to bytes)
  * @scd_set_active: should the transport configure the SCD for HCMD queue
- * @wide_cmd_header: firmware supports wide host command header
  * @sw_csum_tx: transport should compute the TCP checksum
  * @command_groups: array of command groups, each member is an array of the
  * commands in the group; for debugging only
@@ -506,7 +506,6 @@ struct iwl_trans_config {
enum iwl_amsdu_size rx_buf_size;
bool bc_table_dword;
bool scd_set_active;
-   bool wide_cmd_header;
bool sw_csum_tx;
const struct iwl_hcmd_arr *command_groups;
int command_groups_size;
@@ -770,6 +769,7 @@ enum iwl_plat_pm_mode {
  * @hw_id_str: a string with info about HW ID. Set during transport allocation.
  * @pm_support: set to true in start_hw if link pm is supported
  * @ltr_enabled: set to true if the LTR is enabled
+ * @wide_cmd_header: true when ucode supports wide command header format
  * @num_rx_queues: number of RX queues allocated by the transport;
  * the transport must set this before calling iwl_drv_start()
  * @dev_cmd_pool: pool for Tx cmd allocation - for internal use only.
@@ -821,6 +821,7 @@ struct iwl_trans {
 
const struct iwl_hcmd_arr *command_groups;
int command_groups_size;
+   bool wide_cmd_header;
 
u8 num_rx_queues;
 
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index de34c9f..b2d8722 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -652,8 +652,8 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct 
iwl_cfg *cfg,
/* the hardware splits the A-MSDU */
if (mvm->cfg->mq_rx_supported)
trans_cfg.rx_buf_size = IWL_AMSDU_4K;
-   trans_cfg.wide_cmd_header = fw_has_api(&mvm->fw->ucode_capa,
-

[PATCH 18/25] iwlwifi: migrate to devm_* API

2016-09-19 Thread Luca Coelho
From: Sharon Dvir 

Change PCIE and trans resource allocations to managed resources.

Signed-off-by: Sharon Dvir 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/iwl-trans.c  |  8 +--
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 81 ++---
 2 files changed, 34 insertions(+), 55 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
index b42152c..d42cab2 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
@@ -78,7 +78,7 @@ struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
static struct lock_class_key __key;
 #endif
 
-   trans = kzalloc(sizeof(*trans) + priv_size, GFP_KERNEL);
+   trans = devm_kzalloc(dev, sizeof(*trans) + priv_size, GFP_KERNEL);
if (!trans)
return NULL;
 
@@ -103,18 +103,14 @@ struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
  SLAB_HWCACHE_ALIGN,
  NULL);
if (!trans->dev_cmd_pool)
-   goto free;
+   return NULL;
 
return trans;
- free:
-   kfree(trans);
-   return NULL;
 }
 
 void iwl_trans_free(struct iwl_trans *trans)
 {
kmem_cache_destroy(trans->dev_cmd_pool);
-   kfree(trans);
 }
 
 int iwl_trans_send_cmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 68fa843..ae95533 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -1605,24 +1605,22 @@ static int iwl_pcie_init_msix_handler(struct pci_dev 
*pdev,
 
for (i = 0; i < trans_pcie->alloc_vecs; i++) {
int ret;
-
-   ret = request_threaded_irq(trans_pcie->msix_entries[i].vector,
-  iwl_pcie_msix_isr,
-  (i == trans_pcie->def_irq) ?
-  iwl_pcie_irq_msix_handler :
-  iwl_pcie_irq_rx_msix_handler,
-  IRQF_SHARED,
-  DRV_NAME,
-  &trans_pcie->msix_entries[i]);
+   struct msix_entry *msix_entry;
+
+   msix_entry = &trans_pcie->msix_entries[i];
+   ret = devm_request_threaded_irq(&pdev->dev,
+   msix_entry->vector,
+   iwl_pcie_msix_isr,
+   (i == trans_pcie->def_irq) ?
+   iwl_pcie_irq_msix_handler :
+   iwl_pcie_irq_rx_msix_handler,
+   IRQF_SHARED,
+   DRV_NAME,
+   msix_entry);
if (ret) {
-   int j;
-
IWL_ERR(trans_pcie->trans,
"Error allocating IRQ %d\n", i);
-   for (j = 0; j < i; j++)
-   free_irq(trans_pcie->msix_entries[j].vector,
-&trans_pcie->msix_entries[j]);
-   pci_disable_msix(pdev);
+
return ret;
}
}
@@ -1789,23 +1787,12 @@ void iwl_trans_pcie_free(struct iwl_trans *trans)
irq_set_affinity_hint(
trans_pcie->msix_entries[i].vector,
NULL);
-
-   free_irq(trans_pcie->msix_entries[i].vector,
-&trans_pcie->msix_entries[i]);
}
 
-   pci_disable_msix(trans_pcie->pci_dev);
trans_pcie->msix_enabled = false;
} else {
-   free_irq(trans_pcie->pci_dev->irq, trans);
-
iwl_pcie_free_ict(trans);
-
-   pci_disable_msi(trans_pcie->pci_dev);
}
-   iounmap(trans_pcie->hw_base);
-   pci_release_regions(trans_pcie->pci_dev);
-   pci_disable_device(trans_pcie->pci_dev);
 
iwl_pcie_free_fw_monitor(trans);
 
@@ -2912,6 +2899,10 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev 
*pdev,
struct iwl_trans *trans;
int ret, addr_size;
 
+   ret = pcim_enable_device(pdev);
+   if (ret)
+   return ERR_PTR(ret);
+
trans = iwl_trans_alloc(sizeof(struct iwl_trans_pcie),
&pdev->dev, cfg, &trans_ops_pcie, 0);
if (!trans)
@@ -2930,9 +2921,6 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev 
*pdev,
goto out_no_pci;
}
 
-   

[PATCH 17/25] iwlwifi: mvm: disable P2P queue on mac context release

2016-09-19 Thread Luca Coelho
From: Sara Sharon 

AP queue is properly released, but P2P queue isn't.

Fixes: commit 4c965139a3cd ("iwlwifi: mvm: support p2p device frames tx on dqa 
queue #2")
Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
index 69c42ce..d742d27 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
@@ -539,6 +539,11 @@ void iwl_mvm_mac_ctxt_release(struct iwl_mvm *mvm, struct 
ieee80211_vif *vif)
iwl_mvm_disable_txq(mvm, IWL_MVM_OFFCHANNEL_QUEUE,
IWL_MVM_OFFCHANNEL_QUEUE,
IWL_MAX_TID_COUNT, 0);
+   else
+   iwl_mvm_disable_txq(mvm,
+   IWL_MVM_DQA_P2P_DEVICE_QUEUE,
+   vif->hw_queue[0], IWL_MAX_TID_COUNT,
+   0);
 
break;
case NL80211_IFTYPE_AP:
-- 
2.9.3



[PATCH 25/25] iwlwifi: pcie: use LIST_HEAD() macro

2016-09-19 Thread Luca Coelho
From: Johannes Berg 

There's no need to declare a list and then init it manually,
just use the LIST_HEAD() macro.

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
index 78cb6d2..6fe5546 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
@@ -487,15 +487,13 @@ static void iwl_pcie_rx_allocator(struct iwl_trans *trans)
 
while (pending) {
int i;
-   struct list_head local_allocated;
+   LIST_HEAD(local_allocated);
gfp_t gfp_mask = GFP_KERNEL;
 
/* Do not post a warning if there are only a few requests */
if (pending < RX_PENDING_WATERMARK)
gfp_mask |= __GFP_NOWARN;
 
-   INIT_LIST_HEAD(&local_allocated);
-
for (i = 0; i < RX_CLAIM_REQ_ALLOC;) {
struct iwl_rx_mem_buffer *rxb;
struct page *page;
-- 
2.9.3



[PATCH 16/25] iwlwifi: don't export trace points that are used in iwlwifi only

2016-09-19 Thread Luca Coelho
From: Emmanuel Grumbach 

This can save a few bytes

Signed-off-by: Emmanuel Grumbach 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c
index 1d9dd153..50510fb 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c
@@ -33,9 +33,6 @@
 #define CREATE_TRACE_POINTS
 #include "iwl-devtrace.h"
 
-EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_iowrite8);
-EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_ioread32);
-EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_iowrite32);
 EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_ucode_event);
 EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_ucode_error);
 EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_ucode_cont_event);
-- 
2.9.3



[PATCH 19/25] iwlwifi: mvm: Add debugfs function for clocks diff

2016-09-19 Thread Luca Coelho
From: Roee Zamir 

New function, reveals the diff between gp2 and host time.

Signed-off-by: Roee Zamir 
Signed-off-by: Luca Coelho 
---
 .../net/wireless/intel/iwlwifi/mvm/debugfs-vif.c   | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
index b232717..8ff1921 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
@@ -504,6 +504,28 @@ static inline char *iwl_dbgfs_is_match(char *name, char 
*buf)
return !strncmp(name, buf, len) ? buf + len : NULL;
 }
 
+static ssize_t iwl_dbgfs_os_device_timediff_read(struct file *file,
+char __user *user_buf,
+size_t count, loff_t *ppos)
+{
+   struct ieee80211_vif *vif = file->private_data;
+   struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
+   struct iwl_mvm *mvm = mvmvif->mvm;
+   u32 curr_gp2;
+   u64 curr_os;
+   s64 diff;
+   char buf[64];
+   const size_t bufsz = sizeof(buf);
+   int pos = 0;
+
+   iwl_mvm_get_sync_time(mvm, &curr_gp2, &curr_os);
+   do_div(curr_os, NSEC_PER_USEC);
+   diff = curr_os - curr_gp2;
+   pos += scnprintf(buf + pos, bufsz - pos, "diff=%lld\n", diff);
+
+   return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+}
+
 static ssize_t iwl_dbgfs_tof_enable_write(struct ieee80211_vif *vif,
  char *buf,
  size_t count, loff_t *ppos)
@@ -1530,6 +1552,8 @@ MVM_DEBUGFS_READ_FILE_OPS(tof_range_response);
 MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_responder_params, 32);
 MVM_DEBUGFS_READ_WRITE_FILE_OPS(quota_min, 32);
 MVM_DEBUGFS_WRITE_FILE_OPS(lqm_send_cmd, 64);
+MVM_DEBUGFS_READ_FILE_OPS(os_device_timediff);
+
 
 void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
 {
@@ -1570,6 +1594,8 @@ void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, 
struct ieee80211_vif *vif)
MVM_DEBUGFS_ADD_FILE_VIF(quota_min, mvmvif->dbgfs_dir,
 S_IRUSR | S_IWUSR);
MVM_DEBUGFS_ADD_FILE_VIF(lqm_send_cmd, mvmvif->dbgfs_dir, S_IWUSR);
+   MVM_DEBUGFS_ADD_FILE_VIF(os_device_timediff,
+mvmvif->dbgfs_dir, S_IRUSR);
 
if (vif->type == NL80211_IFTYPE_STATION && !vif->p2p &&
mvmvif == mvm->bf_allowed_vif)
-- 
2.9.3



[PATCH 24/25] iwlwifi: mvm: use LIST_HEAD() macro

2016-09-19 Thread Luca Coelho
From: Johannes Berg 

There's no need to declare a list and then init it manually,
just use the LIST_HEAD() macro.

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index 3eccd89..75f3ca0 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -858,9 +858,7 @@ static void iwl_mvm_async_handlers_wk(struct work_struct 
*wk)
struct iwl_mvm *mvm =
container_of(wk, struct iwl_mvm, async_handlers_wk);
struct iwl_async_handler_entry *entry, *tmp;
-   struct list_head local_list;
-
-   INIT_LIST_HEAD(&local_list);
+   LIST_HEAD(local_list);
 
/* Ensure that we are not in stop flow (check iwl_mvm_mac_stop) */
 
-- 
2.9.3



[PATCH 20/25] iwlwifi: add new 8265 series PCI ID

2016-09-19 Thread Luca Coelho
From: Oren Givon 

Add a new PCI ID for the 8265 series.

Signed-off-by: Oren Givon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
index 14c6e94..3d766f2 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
@@ -487,6 +487,7 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
{IWL_PCI_DEVICE(0x24FD, 0x1130, iwl8265_2ac_cfg)},
{IWL_PCI_DEVICE(0x24FD, 0x0130, iwl8265_2ac_cfg)},
{IWL_PCI_DEVICE(0x24FD, 0x1010, iwl8265_2ac_cfg)},
+   {IWL_PCI_DEVICE(0x24FD, 0x10D0, iwl8265_2ac_cfg)},
{IWL_PCI_DEVICE(0x24FD, 0x0050, iwl8265_2ac_cfg)},
{IWL_PCI_DEVICE(0x24FD, 0x0150, iwl8265_2ac_cfg)},
{IWL_PCI_DEVICE(0x24FD, 0x9010, iwl8265_2ac_cfg)},
-- 
2.9.3



[PATCH 12/25] iwlwifi: pcie: log full command sequence

2016-09-19 Thread Luca Coelho
From: Sara Sharon 

Log group as well. Remove 0x prefix to match TX logging.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
index 0b5b331..78cb6d2 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
@@ -1108,13 +1108,14 @@ static void iwl_pcie_rx_handle_rb(struct iwl_trans 
*trans,
FH_RSCSR_RXQ_POS != rxq->id);
 
IWL_DEBUG_RX(trans,
-"cmd at offset %d: %s (0x%.2x, seq 0x%x)\n",
+"cmd at offset %d: %s (%.2x.%2x, seq 0x%x)\n",
 rxcb._offset,
 iwl_get_cmd_string(trans,
iwl_cmd_id(pkt->hdr.cmd,
   pkt->hdr.group_id,
   0)),
-pkt->hdr.cmd, le16_to_cpu(pkt->hdr.sequence));
+pkt->hdr.group_id, pkt->hdr.cmd,
+le16_to_cpu(pkt->hdr.sequence));
 
len = iwl_rx_packet_len(pkt);
len += sizeof(u32); /* account for status word */
-- 
2.9.3



[PATCH 05/25] iwlwifi: mvm: add support for MU-MIMO air sniffer

2016-09-19 Thread Luca Coelho
From: Aviya Erenfeld 

enable MU-MIMO air sniffer if it's supported by the NIC

Signed-off-by: Aviya Erenfeld 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index 9506e65..b7d80b5 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -720,6 +720,10 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
if (ret)
iwl_mvm_leds_exit(mvm);
 
+   if (mvm->cfg->vht_mu_mimo_supported)
+   wiphy_ext_feature_set(hw->wiphy,
+ NL80211_EXT_FEATURE_MU_MIMO_AIR_SNIFFER);
+
return ret;
 }
 
@@ -2229,6 +2233,10 @@ static void iwl_mvm_bss_info_changed(struct ieee80211_hw 
*hw,
case NL80211_IFTYPE_ADHOC:
iwl_mvm_bss_info_changed_ap_ibss(mvm, vif, bss_conf, changes);
break;
+   case NL80211_IFTYPE_MONITOR:
+   if (changes & BSS_CHANGED_MU_GROUPS)
+   iwl_mvm_update_mu_groups(mvm, vif);
+   break;
default:
/* shouldn't happen */
WARN_ON_ONCE(1);
-- 
2.9.3



[PATCH 08/25] iwlwifi: mvm: support BAR in reorder buffer

2016-09-19 Thread Luca Coelho
From: Sara Sharon 

On default queue we will not receive frame release notification,
but the BAR itself.
Upon receiving the BAR driver should look at the NSSN and adjust
window accordingly.

Fixes: b915c10174fb ("iwlwifi: mvm: add reorder buffer per queue")
Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
index b386628..0274f14 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
@@ -600,9 +600,10 @@ static bool iwl_mvm_reorder(struct iwl_mvm *mvm,
 
mvm_sta = iwl_mvm_sta_from_mac80211(sta);
 
-   /* not a data packet */
-   if (!ieee80211_is_data_qos(hdr->frame_control) ||
-   is_multicast_ether_addr(hdr->addr1))
+   /* not a data packet or a bar */
+   if (!ieee80211_is_back_req(hdr->frame_control) &&
+   (!ieee80211_is_data_qos(hdr->frame_control) ||
+is_multicast_ether_addr(hdr->addr1)))
return false;
 
if (unlikely(!ieee80211_is_data_present(hdr->frame_control)))
@@ -626,6 +627,11 @@ static bool iwl_mvm_reorder(struct iwl_mvm *mvm,
 
spin_lock_bh(&buffer->lock);
 
+   if (ieee80211_is_back_req(hdr->frame_control)) {
+   iwl_mvm_release_frames(mvm, sta, napi, buffer, nssn);
+   goto drop;
+   }
+
/*
 * If there was a significant jump in the nssn - adjust.
 * If the SN is smaller than the NSSN it might need to first go into
-- 
2.9.3



[PATCH 07/25] iwlwifi: mvm: fix DQA AP mode station assumption

2016-09-19 Thread Luca Coelho
From: Sara Sharon 

There was recently a Full AP mode feature added where hostap adds
the station at auth stage, and not assoc.
However, when running with legacy hostapd, we get the auth response
before station was added, and tx_skb_non_sta fails to allocate
a queue, resulting in a complete failure of association.
Take care of this situation as well.
Add a warning when no valid queue is returned at all and make mvm
drop the packet instead of passing it on.
Refactor the function a bit while at it.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 35 +++--
 1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
index 1051777..e0c9065 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
@@ -490,16 +490,34 @@ iwl_mvm_set_tx_params(struct iwl_mvm *mvm, struct sk_buff 
*skb,
 static int iwl_mvm_get_ctrl_vif_queue(struct iwl_mvm *mvm,
  struct ieee80211_tx_info *info, __le16 fc)
 {
-   if (iwl_mvm_is_dqa_supported(mvm)) {
-   if (info->control.vif->type == NL80211_IFTYPE_AP &&
-   ieee80211_is_probe_resp(fc))
+   if (!iwl_mvm_is_dqa_supported(mvm))
+   return info->hw_queue;
+
+   switch (info->control.vif->type) {
+   case NL80211_IFTYPE_AP:
+   /*
+* handle legacy hostapd as well, where station may be added
+* only after assoc.
+*/
+   if (ieee80211_is_probe_resp(fc) || ieee80211_is_auth(fc))
return IWL_MVM_DQA_AP_PROBE_RESP_QUEUE;
-   else if (ieee80211_is_mgmt(fc) &&
-info->control.vif->type == NL80211_IFTYPE_P2P_DEVICE)
+   if (info->hw_queue == info->control.vif->cab_queue)
+   return info->hw_queue;
+
+   WARN_ON_ONCE(1);
+   return IWL_MVM_DQA_AP_PROBE_RESP_QUEUE;
+   case NL80211_IFTYPE_P2P_DEVICE:
+   if (ieee80211_is_mgmt(fc))
return IWL_MVM_DQA_P2P_DEVICE_QUEUE;
-   }
+   if (info->hw_queue == info->control.vif->cab_queue)
+   return info->hw_queue;
 
-   return info->hw_queue;
+   WARN_ON_ONCE(1);
+   return IWL_MVM_DQA_P2P_DEVICE_QUEUE;
+   default:
+   WARN_ONCE(1, "Not a ctrl vif, no available queue\n");
+   return -1;
+   }
 }
 
 int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)
@@ -560,6 +578,9 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct 
sk_buff *skb)
sta_id = mvmvif->bcast_sta.sta_id;
queue = iwl_mvm_get_ctrl_vif_queue(mvm, &info,
   hdr->frame_control);
+   if (queue < 0)
+   return -1;
+
} else if (info.control.vif->type == NL80211_IFTYPE_STATION &&
   is_multicast_ether_addr(hdr->addr1)) {
u8 ap_sta_id = ACCESS_ONCE(mvmvif->ap_sta_id);
-- 
2.9.3



[PATCH 10/25] iwlwifi: mvm: support packet injection

2016-09-19 Thread Luca Coelho
From: Sara Sharon 

For automatic testing packet injection can be useful.
Support injection through debugfs.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 55 
 1 file changed, 55 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
index b344898..540b7c9 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
@@ -917,6 +917,59 @@ static ssize_t iwl_dbgfs_indirection_tbl_write(struct 
iwl_mvm *mvm,
return ret ?: count;
 }
 
+static ssize_t iwl_dbgfs_inject_packet_write(struct iwl_mvm *mvm,
+char *buf, size_t count,
+loff_t *ppos)
+{
+   struct iwl_rx_cmd_buffer rxb = {
+   ._rx_page_order = 0,
+   .truesize = 0, /* not used */
+   ._offset = 0,
+   };
+   struct iwl_rx_packet *pkt;
+   struct iwl_rx_mpdu_desc *desc;
+   int bin_len = count / 2;
+   int ret = -EINVAL;
+
+   /* supporting only 9000 descriptor */
+   if (!mvm->trans->cfg->mq_rx_supported)
+   return -ENOTSUPP;
+
+   rxb._page = alloc_pages(GFP_ATOMIC, 0);
+   if (!rxb._page)
+   return -ENOMEM;
+   pkt = rxb_addr(&rxb);
+
+   ret = hex2bin(page_address(rxb._page), buf, bin_len);
+   if (ret)
+   goto out;
+
+   /* avoid invalid memory access */
+   if (bin_len < sizeof(*pkt) + sizeof(*desc))
+   goto out;
+
+   /* check this is RX packet */
+   if (WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd) !=
+   WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD))
+   goto out;
+
+   /* check the length in metadata matches actual received length */
+   desc = (void *)pkt->data;
+   if (le16_to_cpu(desc->mpdu_len) !=
+   (bin_len - sizeof(*desc) - sizeof(*pkt)))
+   goto out;
+
+   local_bh_disable();
+   iwl_mvm_rx_mpdu_mq(mvm, NULL, &rxb, 0);
+   local_bh_enable();
+   ret = 0;
+
+out:
+   iwl_free_rxb(&rxb);
+
+   return ret ?: count;
+}
+
 static ssize_t iwl_dbgfs_fw_dbg_conf_read(struct file *file,
  char __user *user_buf,
  size_t count, loff_t *ppos)
@@ -1454,6 +1507,7 @@ MVM_DEBUGFS_WRITE_FILE_OPS(cont_recording, 8);
 MVM_DEBUGFS_WRITE_FILE_OPS(max_amsdu_len, 8);
 MVM_DEBUGFS_WRITE_FILE_OPS(indirection_tbl,
   (IWL_RSS_INDIRECTION_TABLE_SIZE * 2));
+MVM_DEBUGFS_WRITE_FILE_OPS(inject_packet, 512);
 
 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
 MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters, 256);
@@ -1502,6 +1556,7 @@ int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct 
dentry *dbgfs_dir)
MVM_DEBUGFS_ADD_FILE(send_echo_cmd, mvm->debugfs_dir, S_IWUSR);
MVM_DEBUGFS_ADD_FILE(cont_recording, mvm->debugfs_dir, S_IWUSR);
MVM_DEBUGFS_ADD_FILE(indirection_tbl, mvm->debugfs_dir, S_IWUSR);
+   MVM_DEBUGFS_ADD_FILE(inject_packet, mvm->debugfs_dir, S_IWUSR);
if (!debugfs_create_bool("enable_scan_iteration_notif",
 S_IRUSR | S_IWUSR,
 mvm->debugfs_dir,
-- 
2.9.3



[PATCH 04/25] iwlwifi: mvm: compare full command ID

2016-09-19 Thread Luca Coelho
From: Johannes Berg 

When comparing command IDs, the group should be taken
into account so the same command/notification from a
different group doesn't trigger anything unexpected.
Fix this by comparing to the wide ID.

Fixes: commit 1738d60b31d7 ("iwlwifi: mvm: handle RX MPDUs separately")
Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index 43ea1e5..de34c9f 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -966,10 +966,11 @@ static void iwl_mvm_rx(struct iwl_op_mode *op_mode,
 {
struct iwl_rx_packet *pkt = rxb_addr(rxb);
struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
+   u16 cmd = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd);
 
-   if (likely(pkt->hdr.cmd == REPLY_RX_MPDU_CMD))
+   if (likely(cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD)))
iwl_mvm_rx_rx_mpdu(mvm, napi, rxb);
-   else if (pkt->hdr.cmd == REPLY_RX_PHY_CMD)
+   else if (cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_PHY_CMD))
iwl_mvm_rx_rx_phy_cmd(mvm, rxb);
else
iwl_mvm_rx_common(mvm, rxb, pkt);
@@ -981,13 +982,14 @@ static void iwl_mvm_rx_mq(struct iwl_op_mode *op_mode,
 {
struct iwl_rx_packet *pkt = rxb_addr(rxb);
struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
+   u16 cmd = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd);
 
-   if (likely(pkt->hdr.cmd == REPLY_RX_MPDU_CMD))
+   if (likely(cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD)))
iwl_mvm_rx_mpdu_mq(mvm, napi, rxb, 0);
-   else if (unlikely(pkt->hdr.group_id == DATA_PATH_GROUP &&
- pkt->hdr.cmd == RX_QUEUES_NOTIFICATION))
+   else if (unlikely(cmd == WIDE_ID(DATA_PATH_GROUP,
+RX_QUEUES_NOTIFICATION)))
iwl_mvm_rx_queue_notif(mvm, rxb, 0);
-   else if (pkt->hdr.cmd == FRAME_RELEASE)
+   else if (cmd == WIDE_ID(LEGACY_GROUP, FRAME_RELEASE))
iwl_mvm_rx_frame_release(mvm, napi, rxb, 0);
else
iwl_mvm_rx_common(mvm, rxb, pkt);
@@ -1666,13 +1668,14 @@ static void iwl_mvm_rx_mq_rss(struct iwl_op_mode 
*op_mode,
 {
struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
struct iwl_rx_packet *pkt = rxb_addr(rxb);
+   u16 cmd = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd);
 
-   if (unlikely(pkt->hdr.cmd == FRAME_RELEASE))
+   if (unlikely(cmd == WIDE_ID(LEGACY_GROUP, FRAME_RELEASE)))
iwl_mvm_rx_frame_release(mvm, napi, rxb, queue);
-   else if (unlikely(pkt->hdr.cmd == RX_QUEUES_NOTIFICATION &&
- pkt->hdr.group_id == DATA_PATH_GROUP))
+   else if (unlikely(cmd == WIDE_ID(DATA_PATH_GROUP,
+RX_QUEUES_NOTIFICATION)))
iwl_mvm_rx_queue_notif(mvm, rxb, queue);
-   else if (likely(pkt->hdr.cmd == REPLY_RX_MPDU_CMD))
+   else if (likely(cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD)))
iwl_mvm_rx_mpdu_mq(mvm, napi, rxb, queue);
 }
 
-- 
2.9.3



[PATCH 06/25] iwlwifi: check for valid ethernet address provided by OEM

2016-09-19 Thread Luca Coelho
From: Haim Dreyfuss 

In 9000 family products we added an option to let the OEM fuse the
mac address via registers. If these registers are zeroed we use the OTP
address instead. Make sure that the address provided by the OEM is valid
and, if not, fall back to the OTP address as well.

Fixes: commit 17c867bfe89b ("iwlwifi: add support for getting HW address from 
CSR")
Signed-off-by: Haim Dreyfuss 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
index 43f8f7d..adba3b0 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
@@ -564,11 +564,16 @@ static void iwl_set_hw_address_from_csr(struct iwl_trans 
*trans,
__le32 mac_addr0 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR0_STRAP));
__le32 mac_addr1 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR1_STRAP));
 
-   /* If OEM did not fuse address - get it from OTP */
-   if (!mac_addr0 && !mac_addr1) {
-   mac_addr0 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR0_OTP));
-   mac_addr1 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR1_OTP));
-   }
+   iwl_flip_hw_address(mac_addr0, mac_addr1, data->hw_addr);
+   /*
+* If the OEM fused a valid address, use it instead of the one in the
+* OTP
+*/
+   if (is_valid_ether_addr(data->hw_addr))
+   return;
+
+   mac_addr0 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR0_OTP));
+   mac_addr1 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR1_OTP));
 
iwl_flip_hw_address(mac_addr0, mac_addr1, data->hw_addr);
 }
-- 
2.9.3



[PATCH 09/25] iwlwifi: mvm: Add support for RRM by scan

2016-09-19 Thread Luca Coelho
From: Avrahams Stern 

Implement support for RRM by adding an option to configure the scan
dwell time and reporting scan start time and BSS detection time, and
Advertise support for these features.

Signed-off-by: David Spinadel 
Signed-off-by: Avraham Stern 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h   |  5 ++
 .../net/wireless/intel/iwlwifi/mvm/fw-api-scan.h   | 20 ---
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c  | 10 
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h   |  6 +++
 drivers/net/wireless/intel/iwlwifi/mvm/scan.c  | 61 +++---
 5 files changed, 88 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h
index 1b1e045..94423f0 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h
@@ -256,6 +256,10 @@ typedef unsigned int __bitwise__ iwl_ucode_tlv_api_t;
  * instead of 3.
  * @IWL_UCODE_TLV_API_TX_POWER_CHAIN: TX power API has larger command size
  * (command version 3) that supports per-chain limits
+ * @IWL_UCODE_TLV_API_SCAN_TSF_REPORT: Scan start time reported in scan
+ * iteration complete notification, and the timestamp reported for RX
+ * received during scan, are reported in TSF of the mac specified in the
+ * scan request.
  *
  * @NUM_IWL_UCODE_TLV_API: number of bits used
  */
@@ -267,6 +271,7 @@ enum iwl_ucode_tlv_api {
IWL_UCODE_TLV_API_NEW_VERSION   = (__force 
iwl_ucode_tlv_api_t)20,
IWL_UCODE_TLV_API_EXT_SCAN_PRIORITY = (__force 
iwl_ucode_tlv_api_t)24,
IWL_UCODE_TLV_API_TX_POWER_CHAIN= (__force 
iwl_ucode_tlv_api_t)27,
+   IWL_UCODE_TLV_API_SCAN_TSF_REPORT   = (__force 
iwl_ucode_tlv_api_t)28,
 
NUM_IWL_UCODE_TLV_API
 #ifdef __CHECKER__
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-scan.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-scan.h
index f01dab0..0c294c9f 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-scan.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-scan.h
@@ -7,6 +7,7 @@
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
+ * Copyright(c) 2016 Intel Deutschland GmbH
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of version 2 of the GNU General Public License as
@@ -603,6 +604,8 @@ struct iwl_scan_req_umac_tail {
  * @uid: scan id, &enum iwl_umac_scan_uid_offsets
  * @ooc_priority: out of channel priority - &enum iwl_scan_priority
  * @general_flags: &enum iwl_umac_scan_general_flags
+ * @reserved2: for future use and alignment
+ * @scan_start_mac_id: report the scan start TSF time according to this mac TSF
  * @extended_dwell: dwell time for channels 1, 6 and 11
  * @active_dwell: dwell time for active scan
  * @passive_dwell: dwell time for passive scan
@@ -620,8 +623,10 @@ struct iwl_scan_req_umac {
__le32 flags;
__le32 uid;
__le32 ooc_priority;
-   /* SCAN_GENERAL_PARAMS_API_S_VER_1 */
-   __le32 general_flags;
+   /* SCAN_GENERAL_PARAMS_API_S_VER_4 */
+   __le16 general_flags;
+   u8 reserved2;
+   u8 scan_start_mac_id;
u8 extended_dwell;
u8 active_dwell;
u8 passive_dwell;
@@ -629,7 +634,7 @@ struct iwl_scan_req_umac {
__le32 max_out_time;
__le32 suspend_time;
__le32 scan_priority;
-   /* SCAN_CHANNEL_PARAMS_API_S_VER_1 */
+   /* SCAN_CHANNEL_PARAMS_API_S_VER_4 */
u8 channel_flags;
u8 n_channels;
__le16 reserved;
@@ -718,8 +723,8 @@ struct iwl_scan_offload_profiles_query {
  * @status: one of SCAN_COMP_STATUS_*
  * @bt_status: BT on/off status
  * @last_channel: last channel that was scanned
- * @tsf_low: TSF timer (lower half) in usecs
- * @tsf_high: TSF timer (higher half) in usecs
+ * @start_tsf: TSF timer in usecs of the scan start time for the mac specified
+ * in &struct iwl_scan_req_umac.
  * @results: array of scan results, only "scanned_channels" of them are valid
  */
 struct iwl_umac_scan_iter_complete_notif {
@@ -728,9 +733,8 @@ struct iwl_umac_scan_iter_complete_notif {
u8 status;
u8 bt_status;
u8 last_channel;
-   __le32 tsf_low;
-   __le32 tsf_high;
+   __le64 start_tsf;
struct iwl_scan_results_notif results[];
-} __packed; /* SCAN_ITER_COMPLETE_NTF_UMAC_API_S_VER_1 */
+} __packed; /* SCAN_ITER_COMPLETE_NTF_UMAC_API_S_VER_2 */
 
 #endif
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index b7d80b5..a5ede8c 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -653,6 +653,16 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
IWL_UCODE_TLV_CAPA_WFA

[PATCH 01/25] iwlwifi: mvm: remove variable shadowing

2016-09-19 Thread Luca Coelho
From: Liad Kaufman 

Variable "ac" defined twice. Fix that.

Fixes: commit 93f436e2c7fe ("iwlwifi: mvm: set sta_id in SCD_QUEUE_CONFIG cmd")
Signed-off-by: Liad Kaufman 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
index 216aa54..d3a0378 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
@@ -745,14 +745,14 @@ static int iwl_mvm_sta_alloc_queue(struct iwl_mvm *mvm,
.scd_queue = queue,
.action = SCD_CFG_DISABLE_QUEUE,
};
-   u8 ac;
+   u8 txq_curr_ac;
 
disable_agg_tids = iwl_mvm_remove_sta_queue_marking(mvm, queue);
 
spin_lock_bh(&mvm->queue_info_lock);
-   ac = mvm->queue_info[queue].mac80211_ac;
+   txq_curr_ac = mvm->queue_info[queue].mac80211_ac;
cmd.sta_id = mvm->queue_info[queue].ra_sta_id;
-   cmd.tx_fifo = iwl_mvm_ac_to_tx_fifo[ac];
+   cmd.tx_fifo = iwl_mvm_ac_to_tx_fifo[txq_curr_ac];
cmd.tid = mvm->queue_info[queue].txq_tid;
spin_unlock_bh(&mvm->queue_info_lock);
 
-- 
2.9.3



  1   2   >