Re: [PATCH 06/16] wcn36xx: Fetch private sta data from sta entry instead of from vif

2016-03-29 Thread Kalle Valo
Bjorn Andersson  writes:

>> All error/warnings (new ones prefixed by >>):
>> 
>>drivers/net/wireless/ath/wcn36xx/main.c: In function 'wcn36xx_set_key':
>> >> drivers/net/wireless/ath/wcn36xx/main.c:389:9: error: implicit 
>> >> declaration of function 'wcn36xx_sta_to_priv' 
>> >> [-Werror=implicit-function-declaration]
>>  struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
>> ^
>> >> drivers/net/wireless/ath/wcn36xx/main.c:389:33: warning: initialization 
>> >> makes pointer from integer without a cast
>>  struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
>> ^
>>cc1: some warnings being treated as errors
>
> This should have been reordered with patch 7, that introduces this
> helper function. Do you want me to resend, or can you apply the patches
> out of order?

It's better that you resend the whole patchset as v2.

-- 
Kalle Valo
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC] ath10k: implement dql for htt tx

2016-03-29 Thread Dave Taht
As a side note of wifi ideas complementary to codel, please see:

http://blog.cerowrt.org/post/selective_unprotect/

On Tue, Mar 29, 2016 at 12:49 AM, Michal Kazior  wrote:
> On 26 March 2016 at 17:44, Dave Taht  wrote:
>> Dear Michal:
> [...]
>> I am running behind on this patch set, but a couple quick comments.
> [...]
>>>  - no rrul tests, sorry Dave! :)
>>
>> rrul would be a good baseline to have, but no need to waste your time
>> on running it every time as yet. It stresses out both sides of the
>> link so whenever you get two devices with these driver changes on them
>> it would be "interesting". It's the meanest, nastiest test we have...
>> if you can get past the rrul, you've truly won.
>>
>> Consistently using tcp_fair_up with 1,2,4 flows and 1-4 stations as
>> you are now is good enough.
>>
>> doing a more voip-like test with slamming d-itg into your test would be 
>> good...
>>
>>>
>>> Observations / conclusions:
>>>  - DQL builds up throughput slowly on "veryfast"; in some tests it
>>> doesn't get to reach peak (roughly 210mbps average) because the test
>>> is too short
>>
>> It looks like having access to the rate control info here for the
>> initial and ongoing estimates will react faster and better than dql
>> can. I loved the potential here in getting full rate for web traffic
>> in the usual 2second burst you get it in (see above blog entries)
>
> On one hand - yes, rate control should in theory be "faster".
>
> On the other hand DQL will react also to host system interrupt service
> time. On slow CPUs (typically found on routers and such) you might end
> up grinding the CPU so much you need deeper tx queues to keep the hw
> busy (and therefore keep performance maxed). DQL should automatically
> adjust to that while "txop limit" might not.

Mmmm current multi-core generation arm routers should be fast enough.

Otherwise, point taken (possibly). Even intel i3 boxes need offloads to get to
line rate.


>>
>> It is always good to test codel and fq_codel separately, particularly
>> on a new codel implementation. There are so many ways to get codel
>> wrong or add an optimization that doesn't work (speaking as someone
>> that has got it wrong often)
>>
>> If you are getting a fq result of 12 ms, that means you are getting
>> data into the device with a ~12ms standing queue there. On a good day
>> you'd see perhaps 17-22ms for "codel target 5ms" in that case, on the
>> rtt_fair_up series of tests.
>
> This will obviously depend on the number of stations you have data
> queued to. Estimating codel target time requires smarter tx
> scheduling. My earlier (RFC) patch tried doing that.

and I loved it. ;)

>
>> if you are getting a pure codel result of 160ms, that means the
>> implementation is broken. But I think (after having read your
>> description twice), the baseline result today of 160ms of queuing was
>> with a fq_codel *qdisc* doing the work on top of huge buffers,
>
> Yes. The 160ms is with fq_codel qdisc with ath10k doing DQL at 6mbps.
> Without DQL ath10k would clog up all tx slots (1424 of them) with
> frames. At 6mbps you typically want/need a handful (5-10) of frames to
> be queued.
>
>> the
>> results a few days ago were with a fq_codel 802.11 layer, and the
>> results today you are comparing, are pure fq (no codel) in the 802.11e
>> stack, with fixed (and dql) buffering?
>
> Yes. codel target in fq_codel-in-mac80211 is hardcoded at 20ms now
> because there's no scheduling and hence no data to derive the target
> dynamically.

Well, for these simple 2 station tests, you could halve it, easily.

With ecn on on both sides, I tend to look at the groupings of the ecn
marks in wireshark.

>
>
>> if so. Yea! Science!
>>
>> ...
>>
>> One of the flaws of the flent tests is that conceptually they were
>> developed before the fq stuff won so big, and looking hard at the
>> per-queue latency for the fat flows requires either looking hard at
>> the packet captures or sampling the actual queue length. There is that
>> sampling capability in various flent tests, but at the moment it only
>> samples what tc provides (Drops, marks, and length) and it does not
>> look like there is a snapshot queue length exported from that ath10k
>> driver?
>
> Exporting tx queue length snapshot should be fairly easy. 2 debugfs
> entries for ar->htt.max_num_pending_tx and ar->htt.num_pending_tx.

K. Still running *way* behind you on getting stuff up and running. The
ath10ks I ordered were backordered, should arrive shortly.

>
>
>>
>> ...
>>
>> As for a standing queue of 12ms at all in wifi... and making the fq
>> portion work better, it would be quite nice to get that down a bit
>> more. One thought (for testing purposes) would be to fix a txop at
>> 1024,2048,3xxxus for some test runs. I really don't have a a feel for
>> framing overhead on the latest standards. (I loathe the idea of
>> holding the media for more than 2-3ms when you have other stuff coming
>> in 

[RESEND] nfc: Drop owner assignment from i2c_driver

2016-03-29 Thread Krzysztof Kozlowski
i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski 

---

The coccinelle script which generated the patch was sent here:
http://www.spinics.net/lists/kernel/msg2029903.html
---
 drivers/nfc/nxp-nci/i2c.c  | 1 -
 drivers/nfc/pn544/i2c.c| 1 -
 drivers/nfc/st-nci/i2c.c   | 1 -
 drivers/nfc/st21nfca/i2c.c | 1 -
 4 files changed, 4 deletions(-)

diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c
index 11520f472f98..36099e557730 100644
--- a/drivers/nfc/nxp-nci/i2c.c
+++ b/drivers/nfc/nxp-nci/i2c.c
@@ -418,7 +418,6 @@ MODULE_DEVICE_TABLE(acpi, acpi_id);
 static struct i2c_driver nxp_nci_i2c_driver = {
.driver = {
   .name = NXP_NCI_I2C_DRIVER_NAME,
-  .owner  = THIS_MODULE,
   .acpi_match_table = ACPI_PTR(acpi_id),
   .of_match_table = of_match_ptr(of_nxp_nci_i2c_match),
  },
diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c
index 45d0e667d7ae..f837c39a8017 100644
--- a/drivers/nfc/pn544/i2c.c
+++ b/drivers/nfc/pn544/i2c.c
@@ -1106,7 +1106,6 @@ MODULE_DEVICE_TABLE(of, of_pn544_i2c_match);
 static struct i2c_driver pn544_hci_i2c_driver = {
.driver = {
   .name = PN544_HCI_I2C_DRIVER_NAME,
-  .owner  = THIS_MODULE,
   .of_match_table = of_match_ptr(of_pn544_i2c_match),
   .acpi_match_table = ACPI_PTR(pn544_hci_i2c_acpi_match),
  },
diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index 8a56b5c6e4c4..925dbeef74db 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -416,7 +416,6 @@ MODULE_DEVICE_TABLE(of, of_st_nci_i2c_match);
 
 static struct i2c_driver st_nci_i2c_driver = {
.driver = {
-   .owner = THIS_MODULE,
.name = ST_NCI_I2C_DRIVER_NAME,
.of_match_table = of_match_ptr(of_st_nci_i2c_match),
.acpi_match_table = ACPI_PTR(st_nci_i2c_acpi_match),
diff --git a/drivers/nfc/st21nfca/i2c.c b/drivers/nfc/st21nfca/i2c.c
index 1f44a151d206..640b4de05793 100644
--- a/drivers/nfc/st21nfca/i2c.c
+++ b/drivers/nfc/st21nfca/i2c.c
@@ -721,7 +721,6 @@ MODULE_DEVICE_TABLE(of, of_st21nfca_i2c_match);
 
 static struct i2c_driver st21nfca_hci_i2c_driver = {
.driver = {
-   .owner = THIS_MODULE,
.name = ST21NFCA_HCI_I2C_DRIVER_NAME,
.of_match_table = of_match_ptr(of_st21nfca_i2c_match),
.acpi_match_table = ACPI_PTR(st21nfca_hci_i2c_acpi_match),
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH 15/16] wcn36xx: don't pad beacons for mesh

2016-03-29 Thread Bjorn Andersson
On Tue 29 Mar 14:41 PDT 2016, Bjorn Andersson wrote:

> From: Jason Mobarak 
> 
> Patch "wcn36xx: Pad TIM PVM if needed" has caused a regression in mesh
> beaconing.  The field tim_off is always 0 for mesh mode, and thus
> pvm_len (referring to the TIM length field) and pad are both incorrectly
> calculated.  Thus, msg_body.beacon_length is incorrectly calculated for
> mesh mode. Fix this.
> 
> Fixes: 8ad99a4e3ee5 ("wcn36xx: Pad TIM PVM if needed")
> Signed-off-by: Jason Mobarak 
> Signed-off-by: Chun-Yeow Yeoh 
> Signed-off-by: Bjorn Andersson 
> ---
> 
> Resend this single patch with included Fixes tag.
> 

Sorry for the spam, I read the git log incorrectly. The patch referred
to is part of this series, so the sha1 is bogus.

Regards,
Bjorn

>  drivers/net/wireless/ath/wcn36xx/smd.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c 
> b/drivers/net/wireless/ath/wcn36xx/smd.c
> index a57d158298a1..b1bdc229e560 100644
> --- a/drivers/net/wireless/ath/wcn36xx/smd.c
> +++ b/drivers/net/wireless/ath/wcn36xx/smd.c
> @@ -1410,6 +1410,11 @@ int wcn36xx_smd_send_beacon(struct wcn36xx *wcn, 
> struct ieee80211_vif *vif,
>  
>   pvm_len = skb_beacon->data[tim_off + 1] - 3;
>   pad = TIM_MIN_PVM_SIZE - pvm_len;
> +
> + /* Padding is irrelevant to mesh mode since tim_off is always 0. */
> + if (vif->type == NL80211_IFTYPE_MESH_POINT)
> + pad = 0;
> +
>   msg_body.beacon_length = skb_beacon->len + pad;
>   /* TODO need to find out why + 6 is needed */
>   msg_body.beacon_length6 = msg_body.beacon_length + 6;
> -- 
> 2.5.0
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH 15/16] wcn36xx: don't pad beacons for mesh

2016-03-29 Thread Bjorn Andersson
From: Jason Mobarak 

Patch "wcn36xx: Pad TIM PVM if needed" has caused a regression in mesh
beaconing.  The field tim_off is always 0 for mesh mode, and thus
pvm_len (referring to the TIM length field) and pad are both incorrectly
calculated.  Thus, msg_body.beacon_length is incorrectly calculated for
mesh mode. Fix this.

Fixes: 8ad99a4e3ee5 ("wcn36xx: Pad TIM PVM if needed")
Signed-off-by: Jason Mobarak 
Signed-off-by: Chun-Yeow Yeoh 
Signed-off-by: Bjorn Andersson 
---

Resend this single patch with included Fixes tag.

 drivers/net/wireless/ath/wcn36xx/smd.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c 
b/drivers/net/wireless/ath/wcn36xx/smd.c
index a57d158298a1..b1bdc229e560 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -1410,6 +1410,11 @@ int wcn36xx_smd_send_beacon(struct wcn36xx *wcn, struct 
ieee80211_vif *vif,
 
pvm_len = skb_beacon->data[tim_off + 1] - 3;
pad = TIM_MIN_PVM_SIZE - pvm_len;
+
+   /* Padding is irrelevant to mesh mode since tim_off is always 0. */
+   if (vif->type == NL80211_IFTYPE_MESH_POINT)
+   pad = 0;
+
msg_body.beacon_length = skb_beacon->len + pad;
/* TODO need to find out why + 6 is needed */
msg_body.beacon_length6 = msg_body.beacon_length + 6;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 06/16] wcn36xx: Fetch private sta data from sta entry instead of from vif

2016-03-29 Thread Bjorn Andersson
On Tue 29 Mar 10:01 PDT 2016, kbuild test robot wrote:

> Hi Pontus,
> 
> [auto build test ERROR on wireless-drivers/master]
> [also build test ERROR on v4.6-rc1 next-20160329]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improving the system]
> 
> url:
> https://github.com/0day-ci/linux/commits/Bjorn-Andersson/Misc-wcn36xx-fixes/20160329-141847
> base:   
> https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers.git 
> master
> config: sparc64-allyesconfig (attached as .config)
> reproduce:
> wget 
> https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
>  -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> make.cross ARCH=sparc64 
> 
> Note: the linux-review/Bjorn-Andersson/Misc-wcn36xx-fixes/20160329-141847 
> HEAD 8303daac889854237207e7caefaea94fee0b87f2 builds fine.
>   It only hurts bisectibility.
> 
> All error/warnings (new ones prefixed by >>):
> 
>drivers/net/wireless/ath/wcn36xx/main.c: In function 'wcn36xx_set_key':
> >> drivers/net/wireless/ath/wcn36xx/main.c:389:9: error: implicit declaration 
> >> of function 'wcn36xx_sta_to_priv' [-Werror=implicit-function-declaration]
>  struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
> ^
> >> drivers/net/wireless/ath/wcn36xx/main.c:389:33: warning: initialization 
> >> makes pointer from integer without a cast
>  struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
> ^
>cc1: some warnings being treated as errors

This should have been reordered with patch 7, that introduces this
helper function. Do you want me to resend, or can you apply the patches
out of order?

Regards,
Bjorn

> 
> vim +/wcn36xx_sta_to_priv +389 drivers/net/wireless/ath/wcn36xx/main.c
> 
>383   struct ieee80211_vif *vif,
>384   struct ieee80211_sta *sta,
>385   struct ieee80211_key_conf *key_conf)
>386{
>387struct wcn36xx *wcn = hw->priv;
>388struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
>  > 389struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
>390int ret = 0;
>391u8 key[WLAN_MAX_KEY_LEN];
>392
> 
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation


> ___
> wcn36xx mailing list
> wcn3...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/wcn36xx

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Bonjour mDNS broacast can be lost during BT-WLAN coexistence schemes?

2016-03-29 Thread Adrian Chadd
On 28 March 2016 at 21:22, sandeep suresh  wrote:
> Hello Adrian,
>   Thanks for your response. Currently with 2-wire coexistence, BT has
> higher priority when compared to WiFi. You had shared the following
> different bitfields that can be configured with different weights:
>
> WLAN:-
> wait_beacon | qcu_priority | rx_clear | wlan level
>
> BT:-
> bt_priority | bt freq | bt_tx_rx | bt_level
>
> I have the following queries, please help:
> 1.  wait_beacon:- WLAN client is waiting for a beacon from AP, this bit will
> be set. If the weights during this state is kept the highest, then even if
> BT wants to use the medium (BT_ACTIVE = 1), WLAN will always attempt to
> catch the beacon. Am I correct in my understanding?

Right. The idea is that the STA wants to hear a beacon, so if it's
important to do this ,you want to have WLAN stomp BT.

> 2. What happens if BT wants to transmit during this time when wait_beacon =
> TRUE; will the BT transmission be suppressed?

If you set the weight appropriately then yeah, WLAN stomps BT.

> 3. Regarding "bt_tx_rx". As I understand, bt_tx_rx = 1 when BT is
> transmitting and bt_tx_rx = 0 when BT is receiving; am I correct? How can BT
> module communicate if it will be transmitting or receiving to WLAN module?
> Because BT_PRIORITY will only indicate High or Low priority.

I thought bt_tx_rx is "bt is active", not "bt is tx'ing." I'd have to
check the PHY docs.

> 4. Currently the WLAN_ACTIVE line indicates only Tx activity from WLAN. Is
> there any way to indicate only Rx activities (E.g. Beacon reception etc) ?

On two/three-wire coex, no, I don't think so. The whole point is that
you just need to know "is the BT wanting to do stuff", "is the wlan
wanting to do stuff" and "who wins".
The wlan chip is the arbiter of who wins, it has the weights
programmed in to figure out what to do when.

> 5.  Regarding your comment on dynamically changing weights. AR9287 and the
> BT chipsets are separate and connected to a Host controller running linux.

> As for different states of BT, if there is a need for different weights, I
> do not think at runtime the weights can be changed (by sending a command
> from BT to Host and then weight change from Host to WLAN)as we might not be
> able to meet the short timings. WHat is your opinion on this?

No, the BT doesn't get to send the host commands like that. The driver
layer (ath9k) could be extended to include smarts about traffic
patterns and which BT profiles are active, so you can tune the weights
based on it.

The ath9k driver can also do things to "tune" how much of the channel
it uses - eg, by using the quiet time timers to control TX duty cycle
so BT has more of a chance to work.

The later chips (MCI?) implement a control protocol between the wlan
side and the bt side. I haven't yet ported that functionality to
freebsd so I don't have any operational experience with that!


-adrian
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] PCI: Add Broadcom 4331 reset quirk to prevent IRQ storm

2016-03-29 Thread Lukas Wunner
Broadcom 4331 wireless cards built into Apple Macs unleash an IRQ storm
on boot until they are reset, causing spurious interrupts if the IRQ is
shared. Apparently the EFI bootloader enables the device and does not
disable it before passing control to the OS. The bootloader contains a
driver for the wireless card which allows it to phone home to Cupertino.
This is used for Internet Recovery (download and install OS X images)
and probably also for Back to My Mac (remote access, RFC 6281) and to
discover stolen hardware.

The issue is most pronounced on 2011 and 2012 MacBook Pros where the IRQ
is shared with 3 other devices (Light Ridge Thunderbolt controller, SDXC
reader, HDA card on discrete GPU). As soon as an interrupt handler is
installed for one of these devices, the ensuing storm of spurious IRQs
causes the kernel to disable the IRQ and switch to polling. This lasts
until the b43 driver loads and resets the device.

Loading the b43 driver first is not always an option, in particular with
the Light Ridge Thunderbolt controller: The PCI hotplug IRQ handler gets
installed early on because it is built in, unlike b43 which is usually
a module.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=79301
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=895951
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1009819
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1149632
Tested-by: Lukas Wunner  [MacBookPro9,1]
Signed-off-by: Lukas Wunner 
---
 drivers/bcma/bcma_private.h |  2 --
 drivers/pci/quirks.c| 27 +++
 include/linux/bcma/bcma.h   |  1 +
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h
index eda0909..f642c42 100644
--- a/drivers/bcma/bcma_private.h
+++ b/drivers/bcma/bcma_private.h
@@ -8,8 +8,6 @@
 #include 
 #include 
 
-#define BCMA_CORE_SIZE 0x1000
-
 #define bcma_err(bus, fmt, ...) \
pr_err("bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
 #define bcma_warn(bus, fmt, ...) \
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 8e67802..d4fb5ee 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -25,6 +25,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include/* isa_dma_bridge_buggy */
 #include "pci.h"
 
@@ -3282,6 +3284,31 @@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, 
0x156d,
   quirk_apple_wait_for_thunderbolt);
 #endif
 
+/*
+ * Broadcom 4331 wireless cards built into Apple Macs unleash an IRQ storm
+ * on boot until they are reset, causing spurious interrupts if the IRQ is
+ * shared. Apparently the EFI bootloader enables the device to phone home
+ * to Cupertino and does not disable it before passing control to the OS.
+ */
+static void quirk_apple_b43_reset(struct pci_dev *dev)
+{
+   void __iomem *mmio;
+
+   if (!dmi_match(DMI_BOARD_VENDOR, "Apple Inc.") || !dev->bus->self ||
+   pci_pcie_type(dev->bus->self) != PCI_EXP_TYPE_ROOT_PORT)
+   return;
+
+   mmio = pci_iomap(dev, 0, 0);
+   if (!mmio) {
+   pr_err("b43 quirk: Cannot iomap device, IRQ storm ahead\n");
+   return;
+   }
+   iowrite32(BCMA_RESET_CTL_RESET,
+ mmio + (1 * BCMA_CORE_SIZE) + BCMA_RESET_CTL);
+   pci_iounmap(dev, mmio);
+}
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM, 0x4331, quirk_apple_b43_reset);
+
 static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
  struct pci_fixup *end)
 {
diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h
index 0367c63..5c37b58 100644
--- a/include/linux/bcma/bcma.h
+++ b/include/linux/bcma/bcma.h
@@ -158,6 +158,7 @@ struct bcma_host_ops {
 #define BCMA_CORE_DEFAULT  0xFFF
 
 #define BCMA_MAX_NR_CORES  16
+#define BCMA_CORE_SIZE 0x1000
 
 /* Chip IDs of PCIe devices */
 #define BCMA_CHIP_ID_BCM4313   0x4313
-- 
2.8.0.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] PCI: Add Broadcom 4331 reset quirk to prevent IRQ storm

2016-03-29 Thread Lukas Wunner
Dear bcma maintainers,

I'm moving BCMA_CORE_SIZE from drivers/bcma/bcma_private.h to
include/linux/bcma/bcma.h in the patch included below to be
able to use it in drivers/pci/quirks.c.

If you are okay with this change and have no other objections then
please kindly ack the patch for merging via the pci tree.

If you object against this change then I could alternatively redefine
BCMA_CORE_SIZE in drivers/pci/quirks.c. Other pci quirks are redefining
constants there as well. However it's obviously nicer to have a single
definition in one place.

Thanks,

Lukas

On Tue, Mar 29, 2016 at 07:41:30PM +0200, Lukas Wunner wrote:
> Broadcom 4331 wireless cards built into Apple Macs unleash an IRQ storm
> on boot until they are reset, causing spurious interrupts if the IRQ is
> shared. Apparently the EFI bootloader enables the device and does not
> disable it before passing control to the OS. The bootloader contains a
> driver for the wireless card which allows it to phone home to Cupertino.
> This is used for Internet Recovery (download and install OS X images)
> and probably also for Back to My Mac (remote access, RFC 6281) and to
> discover stolen hardware.
> 
> The issue is most pronounced on 2011 and 2012 MacBook Pros where the IRQ
> is shared with 3 other devices (Light Ridge Thunderbolt controller, SDXC
> reader, HDA card on discrete GPU). As soon as an interrupt handler is
> installed for one of these devices, the ensuing storm of spurious IRQs
> causes the kernel to disable the IRQ and switch to polling. This lasts
> until the b43 driver loads and resets the device.
> 
> Loading the b43 driver first is not always an option, in particular with
> the Light Ridge Thunderbolt controller: The PCI hotplug IRQ handler gets
> installed early on because it is built in, unlike b43 which is usually
> a module.
> 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=79301
> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=895951
> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1009819
> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1149632
> Tested-by: Lukas Wunner  [MacBookPro9,1]
> Signed-off-by: Lukas Wunner 
> ---
>  drivers/bcma/bcma_private.h |  2 --
>  drivers/pci/quirks.c| 27 +++
>  include/linux/bcma/bcma.h   |  1 +
>  3 files changed, 28 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h
> index eda0909..f642c42 100644
> --- a/drivers/bcma/bcma_private.h
> +++ b/drivers/bcma/bcma_private.h
> @@ -8,8 +8,6 @@
>  #include 
>  #include 
>  
> -#define BCMA_CORE_SIZE   0x1000
> -
>  #define bcma_err(bus, fmt, ...) \
>   pr_err("bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
>  #define bcma_warn(bus, fmt, ...) \
> diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> index 8e67802..d4fb5ee 100644
> --- a/drivers/pci/quirks.c
> +++ b/drivers/pci/quirks.c
> @@ -25,6 +25,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include  /* isa_dma_bridge_buggy */
>  #include "pci.h"
>  
> @@ -3282,6 +3284,31 @@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, 
> 0x156d,
>  quirk_apple_wait_for_thunderbolt);
>  #endif
>  
> +/*
> + * Broadcom 4331 wireless cards built into Apple Macs unleash an IRQ storm
> + * on boot until they are reset, causing spurious interrupts if the IRQ is
> + * shared. Apparently the EFI bootloader enables the device to phone home
> + * to Cupertino and does not disable it before passing control to the OS.
> + */
> +static void quirk_apple_b43_reset(struct pci_dev *dev)
> +{
> + void __iomem *mmio;
> +
> + if (!dmi_match(DMI_BOARD_VENDOR, "Apple Inc.") || !dev->bus->self ||
> + pci_pcie_type(dev->bus->self) != PCI_EXP_TYPE_ROOT_PORT)
> + return;
> +
> + mmio = pci_iomap(dev, 0, 0);
> + if (!mmio) {
> + pr_err("b43 quirk: Cannot iomap device, IRQ storm ahead\n");
> + return;
> + }
> + iowrite32(BCMA_RESET_CTL_RESET,
> +   mmio + (1 * BCMA_CORE_SIZE) + BCMA_RESET_CTL);
> + pci_iounmap(dev, mmio);
> +}
> +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM, 0x4331, 
> quirk_apple_b43_reset);
> +
>  static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
> struct pci_fixup *end)
>  {
> diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h
> index 0367c63..5c37b58 100644
> --- a/include/linux/bcma/bcma.h
> +++ b/include/linux/bcma/bcma.h
> @@ -158,6 +158,7 @@ struct bcma_host_ops {
>  #define BCMA_CORE_DEFAULT0xFFF
>  
>  #define BCMA_MAX_NR_CORES16
> +#define BCMA_CORE_SIZE   0x1000
>  
>  /* Chip IDs of PCIe devices */
>  #define BCMA_CHIP_ID_BCM4313 0x4313
> -- 
> 2.8.0.rc3
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo 

Re: [PATCH 06/16] wcn36xx: Fetch private sta data from sta entry instead of from vif

2016-03-29 Thread kbuild test robot
Hi Pontus,

[auto build test ERROR on wireless-drivers/master]
[also build test ERROR on v4.6-rc1 next-20160329]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improving the system]

url:
https://github.com/0day-ci/linux/commits/Bjorn-Andersson/Misc-wcn36xx-fixes/20160329-141847
base:   
https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers.git 
master
config: sparc64-allyesconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sparc64 

Note: the linux-review/Bjorn-Andersson/Misc-wcn36xx-fixes/20160329-141847 HEAD 
8303daac889854237207e7caefaea94fee0b87f2 builds fine.
  It only hurts bisectibility.

All error/warnings (new ones prefixed by >>):

   drivers/net/wireless/ath/wcn36xx/main.c: In function 'wcn36xx_set_key':
>> drivers/net/wireless/ath/wcn36xx/main.c:389:9: error: implicit declaration 
>> of function 'wcn36xx_sta_to_priv' [-Werror=implicit-function-declaration]
 struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
^
>> drivers/net/wireless/ath/wcn36xx/main.c:389:33: warning: initialization 
>> makes pointer from integer without a cast
 struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
^
   cc1: some warnings being treated as errors

vim +/wcn36xx_sta_to_priv +389 drivers/net/wireless/ath/wcn36xx/main.c

   383 struct ieee80211_vif *vif,
   384 struct ieee80211_sta *sta,
   385 struct ieee80211_key_conf *key_conf)
   386  {
   387  struct wcn36xx *wcn = hw->priv;
   388  struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
 > 389  struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
   390  int ret = 0;
   391  u8 key[WLAN_MAX_KEY_LEN];
   392  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH] rtl8xxxu: fix uninitialized return value in ret

2016-03-29 Thread Jes Sorensen
Colin King  writes:
> From: Colin Ian King 
>
> several functions are not initializing a return status in ret
> resulting in garbage to be returned instead of 0 for success.
> Currently, the calls to these functions are not checking the
> return, however, it seems prudent to return the correct status
> in case they are to be checked at a later date.
>
> Signed-off-by: Colin Ian King 
> ---
>  drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Thanks for the patch! I'm surprised the compiler didn't warn about this.

I'll add it to my queue for rtl8xxxu.

Cheers,
Jes

>
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c 
> b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c
> index abdff45..9262aad 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c
> @@ -5231,7 +5231,7 @@ static void rtl8xxxu_set_ampdu_min_space(struct 
> rtl8xxxu_priv *priv, u8 density)
>  static int rtl8xxxu_active_to_emu(struct rtl8xxxu_priv *priv)
>  {
>   u8 val8;
> - int count, ret;
> + int count, ret = 0;
>  
>   /* Start of rtl8723AU_card_enable_flow */
>   /* Act to Cardemu sequence*/
> @@ -5281,7 +5281,7 @@ static int rtl8723bu_active_to_emu(struct rtl8xxxu_priv 
> *priv)
>   u8 val8;
>   u16 val16;
>   u32 val32;
> - int count, ret;
> + int count, ret = 0;
>  
>   /* Turn off RF */
>   rtl8xxxu_write8(priv, REG_RF_CTRL, 0);
> @@ -5338,7 +5338,7 @@ static int rtl8xxxu_active_to_lps(struct rtl8xxxu_priv 
> *priv)
>  {
>   u8 val8;
>   u8 val32;
> - int count, ret;
> + int count, ret = 0;
>  
>   rtl8xxxu_write8(priv, REG_TXPAUSE, 0xff);
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] rtl8xxxu: fix uninitialized return value in ret

2016-03-29 Thread Colin King
From: Colin Ian King 

several functions are not initializing a return status in ret
resulting in garbage to be returned instead of 0 for success.
Currently, the calls to these functions are not checking the
return, however, it seems prudent to return the correct status
in case they are to be checked at a later date.

Signed-off-by: Colin Ian King 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c
index abdff45..9262aad 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c
@@ -5231,7 +5231,7 @@ static void rtl8xxxu_set_ampdu_min_space(struct 
rtl8xxxu_priv *priv, u8 density)
 static int rtl8xxxu_active_to_emu(struct rtl8xxxu_priv *priv)
 {
u8 val8;
-   int count, ret;
+   int count, ret = 0;
 
/* Start of rtl8723AU_card_enable_flow */
/* Act to Cardemu sequence*/
@@ -5281,7 +5281,7 @@ static int rtl8723bu_active_to_emu(struct rtl8xxxu_priv 
*priv)
u8 val8;
u16 val16;
u32 val32;
-   int count, ret;
+   int count, ret = 0;
 
/* Turn off RF */
rtl8xxxu_write8(priv, REG_RF_CTRL, 0);
@@ -5338,7 +5338,7 @@ static int rtl8xxxu_active_to_lps(struct rtl8xxxu_priv 
*priv)
 {
u8 val8;
u8 val32;
-   int count, ret;
+   int count, ret = 0;
 
rtl8xxxu_write8(priv, REG_TXPAUSE, 0xff);
 
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Question on rhashtable in worst-case scenario.

2016-03-29 Thread Ben Greear

Looks like rhashtable has too much policy in it to properly deal with
cases where there are too many hash collisions, so I am going to work on
reverting it's use in mac80211.

Thanks,
Ben

On 03/28/2016 01:29 PM, Ben Greear wrote:

Hello!

I have a use case for mac80211 where I create multiple stations to
the same remote peer MAC address.

I'm seeing cases where the rhashtable logic is returning -16 (EBUSY)
on insert (see sta_info_hash_add).
This is with the 4.4.6+ (plus local patches) kernel, and it has the patch 
mentioned
here:

https://lkml.org/lkml/2015/12/3/307

If I understand the code properly, my use case is going to be worst-case 
scenario,
where all of my items in the hash have the same key (peer mac addr).

I have my own secondary hash to handle most of my hot-path lookups, but I still 
need
the main hash to at least function in a linear-search manner.

Any idea what I can do to get rid of the EBUSY return code problem, or how
to debug it further?

Thanks,
Ben




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

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC] ath10k: implement dql for htt tx

2016-03-29 Thread Ben Greear

On 03/29/2016 12:49 AM, Michal Kazior wrote:


if you are getting a pure codel result of 160ms, that means the
implementation is broken. But I think (after having read your
description twice), the baseline result today of 160ms of queuing was
with a fq_codel *qdisc* doing the work on top of huge buffers,


Yes. The 160ms is with fq_codel qdisc with ath10k doing DQL at 6mbps.
Without DQL ath10k would clog up all tx slots (1424 of them) with
frames. At 6mbps you typically want/need a handful (5-10) of frames to
be queued.


Have you actually verified you can use all tx slots?  The way the
firmware uses it's tx buffers I think you may not be able to actually
do that...and in practice, you will get a lot fewer usable tx-buffers
than configured

THanks,
Ben


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

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Staging: rtl8723au: Remove unused functions

2016-03-29 Thread Jes Sorensen
Bhumika Goyal  writes:
> The functions rtw_get_oper_bw23a and rtw_get_oper_ch23aoffset are never
> used anywhere in the kernel. So, remove their definition and prototype.
> Grepped to find occurences.
>
> Signed-off-by: Bhumika Goyal 
> ---
>  drivers/staging/rtl8723au/core/rtw_wlan_util.c   | 10 --
>  drivers/staging/rtl8723au/include/rtw_mlme_ext.h |  2 --
>  2 files changed, 12 deletions(-)

Acked-by: Jes Sorensen 
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Staging: rtl8723au: Remove function rtw_enqueue_{recvbuf23a/recvbuf23a_to_head}

2016-03-29 Thread Jes Sorensen
Bhumika Goyal  writes:
> The functions rtw_enqueue_recvbuf23a and rtw_enqueue_recvbuf23a_to_head
> are never used anywhere in the kernel. So, remove their definition and
> prototype.
> Grepped to find occurences.
>
> Signed-off-by: Bhumika Goyal 
> ---
>  drivers/staging/rtl8723au/core/rtw_recv.c| 25 -
>  drivers/staging/rtl8723au/include/rtw_recv.h |  2 --
>  2 files changed, 27 deletions(-)

Looks reasonable to me.

Acked-by: Jes Sorensen 

Jes

> diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c 
> b/drivers/staging/rtl8723au/core/rtw_recv.c
> index 989ed07..150dabc 100644
> --- a/drivers/staging/rtl8723au/core/rtw_recv.c
> +++ b/drivers/staging/rtl8723au/core/rtw_recv.c
> @@ -211,31 +211,6 @@ u32 rtw_free_uc_swdec_pending_queue23a(struct 
> rtw_adapter *adapter)
>   return cnt;
>  }
>  
> -int rtw_enqueue_recvbuf23a_to_head(struct recv_buf *precvbuf, struct 
> rtw_queue *queue)
> -{
> - spin_lock_bh(>lock);
> -
> - list_del_init(>list);
> - list_add(>list, get_list_head(queue));
> -
> - spin_unlock_bh(>lock);
> -
> - return _SUCCESS;
> -}
> -
> -int rtw_enqueue_recvbuf23a(struct recv_buf *precvbuf, struct rtw_queue 
> *queue)
> -{
> - unsigned long irqL;
> -
> - spin_lock_irqsave(>lock, irqL);
> -
> - list_del_init(>list);
> -
> - list_add_tail(>list, get_list_head(queue));
> - spin_unlock_irqrestore(>lock, irqL);
> - return _SUCCESS;
> -}
> -
>  struct recv_buf *rtw_dequeue_recvbuf23a (struct rtw_queue *queue)
>  {
>   unsigned long irqL;
> diff --git a/drivers/staging/rtl8723au/include/rtw_recv.h 
> b/drivers/staging/rtl8723au/include/rtw_recv.h
> index dc784be..85a5edb 100644
> --- a/drivers/staging/rtl8723au/include/rtw_recv.h
> +++ b/drivers/staging/rtl8723au/include/rtw_recv.h
> @@ -279,8 +279,6 @@ int rtw_enqueue_recvframe23a(struct recv_frame 
> *precvframe, struct rtw_queue *qu
>  
>  u32 rtw_free_uc_swdec_pending_queue23a(struct rtw_adapter *adapter);
>  
> -int rtw_enqueue_recvbuf23a_to_head(struct recv_buf *precvbuf, struct 
> rtw_queue *queue);
> -int rtw_enqueue_recvbuf23a(struct recv_buf *precvbuf, struct rtw_queue 
> *queue);
>  struct recv_buf *rtw_dequeue_recvbuf23a(struct rtw_queue *queue);
>  
>  void rtw_reordering_ctrl_timeout_handler23a(unsigned long pcontext);
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mmc: add API for data write using scatter gather DMA

2016-03-29 Thread Amitkumar Karwar
From: Bing Zhao 

This patch adds new API for SDIO scatter gather.

Existing mmc_io_rw_extended() API expects caller to pass single contiguous
buffer. It will be split if it exceeds segment size, SG table is prepared
and used it for reading/writing the data.

Our intention for defining new API here is to facilitate caller to provide
ready SG table(scattered buffer list). It will be useful for the drivers
which intend to handle SDIO SG internally.

Signed-off-by: Bing Zhao 
Signed-off-by: Xinming Hu 
Signed-off-by: Amitkumar Karwar 
---
 drivers/mmc/core/sdio_ops.c   | 64 +++
 include/linux/mmc/sdio_func.h |  5 
 2 files changed, 69 insertions(+)

diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c
index 62508b4..6875980 100644
--- a/drivers/mmc/core/sdio_ops.c
+++ b/drivers/mmc/core/sdio_ops.c
@@ -204,6 +204,70 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, 
unsigned fn,
return 0;
 }
 
+int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn,
+ unsigned addr, int incr_addr,
+ struct sg_table *sgt, unsigned blksz)
+{
+   struct mmc_request mrq = {NULL};
+   struct mmc_command cmd = {0};
+   struct mmc_data data = {0};
+   struct scatterlist *sg_ptr;
+   unsigned blocks = 0;
+   int i;
+
+   WARN_ON(!card || !card->host);
+   WARN_ON(fn > 7);
+   WARN_ON(blksz == 0);
+   for_each_sg(sgt->sgl, sg_ptr, sgt->nents, i) {
+   WARN_ON(sg_ptr->length > card->host->max_seg_size);
+   blocks += DIV_ROUND_UP(sg_ptr->length, blksz);
+   }
+
+   /* sanity check */
+   if (addr & ~0x1)
+   return -EINVAL;
+
+   mrq.cmd = 
+   mrq.data = 
+
+   cmd.opcode = SD_IO_RW_EXTENDED;
+   cmd.arg = write ? 0x8000 : 0x;
+   cmd.arg |= fn << 28;
+   cmd.arg |= incr_addr ? 0x0400 : 0x;
+   cmd.arg |= addr << 9;
+   cmd.arg |= 0x0800 | blocks;
+   cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_ADTC;
+
+   data.blksz = blksz;
+   data.blocks = blocks;
+   data.flags = write ? MMC_DATA_WRITE : MMC_DATA_READ;
+
+   data.sg = sgt->sgl;
+   data.sg_len = sgt->nents;
+
+   mmc_set_data_timeout(, card);
+   mmc_wait_for_req(card->host, );
+
+   if (cmd.error)
+   return cmd.error;
+   if (data.error)
+   return data.error;
+
+   if (mmc_host_is_spi(card->host)) {
+   /* host driver already reported errors */
+   } else {
+   if (cmd.resp[0] & R5_ERROR)
+   return -EIO;
+   if (cmd.resp[0] & R5_FUNCTION_NUMBER)
+   return -EINVAL;
+   if (cmd.resp[0] & R5_OUT_OF_RANGE)
+   return -ERANGE;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(mmc_io_rw_extended_sg);
+
 int sdio_reset(struct mmc_host *host)
 {
int ret;
diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h
index aab032a..2107e91 100644
--- a/include/linux/mmc/sdio_func.h
+++ b/include/linux/mmc/sdio_func.h
@@ -14,6 +14,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -151,6 +152,10 @@ extern int sdio_memcpy_toio(struct sdio_func *func, 
unsigned int addr,
 extern int sdio_writesb(struct sdio_func *func, unsigned int addr,
void *src, int count);
 
+int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn,
+ unsigned addr, int incr_addr,
+ struct sg_table *sgt, unsigned blksz);
+
 extern unsigned char sdio_f0_readb(struct sdio_func *func,
unsigned int addr, int *err_ret);
 extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b,
-- 
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mwifiex: add __GFP_REPEAT to skb allocation call

2016-03-29 Thread Eric Dumazet
On Tue, 2016-03-29 at 17:27 +0800, Wei-Ning Huang wrote:
> Adding some chromium devs to the thread.
> 
> In, http://lxr.free-electrons.com/source/mm/page_alloc.c#L3152
> 
> The default mm retry allocation when 'order <=
> PAGE_ALLOC_COSTLY_ORDER' of gfp_mask contains __GFP_REPEAT.
> PAGE_ALLOC_COSTLY_ORDER is defined to be 3. On systems with page size
> = 4K, this means memory compaction and retry is only done when the
> size of allocation is <= 32K
> In mwifiex, the allocation size is 64K.



>  When we have system with
> memory fragmentation and allocation failed, there will be no retry.
> This is why we need to add __GFP_REPEAT here to allow the system to
> perform memory compaction and retry allocation.
> 
> Maybe Amit@marvell can comment on if this is a good fix on this issue.
> I'm also aware that marvell is the progress of implementing
> scatter/gatter for mwifiex, which can also fix the issue.

Before SG is implemented, you really need to copy incoming frames into
smallest chunks (to get lowest skb->truesize) and leave the 64KB
allocated stuff forever in the driver.

__GFP_REPEAT wont really solve the issue.

It seems the problem comes from the fact that the drivers calls
dev_kfree_skb_any() after calling mwifiex_deaggr_sdio_pkt(), instead of
recycling this very precious 64KB skb once memory gets fragmented.

Another problem is that mwifiex_deaggr_sdio_pkt() uses
mwifiex_alloc_dma_align_buf() with GFP_KERNEL | GFP_DMA

Really GFP_DMA makes no sense here, since the skb is going to be
processed by the stack, which has no such requirement.

Please use normal skb allocations there.

diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c 
b/drivers/net/wireless/marvell/mwifiex/sdio.c
index b2c839a..8404db5 100644
--- a/drivers/net/wireless/marvell/mwifiex/sdio.c
+++ b/drivers/net/wireless/marvell/mwifiex/sdio.c
@@ -1123,8 +1123,8 @@ static void mwifiex_deaggr_sdio_pkt(struct 
mwifiex_adapter *adapter,
__func__, pkt_len, blk_size);
break;
}
-   skb_deaggr = mwifiex_alloc_dma_align_buf(pkt_len,
-GFP_KERNEL | GFP_DMA);
+   skb_deaggr = __netdev_alloc_skb_ip_align(NULL, pkt_len,
+GFP_KERNEL);
if (!skb_deaggr)
break;
skb_put(skb_deaggr, pkt_len);




--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 15/16] wcn36xx: don't pad beacons for mesh

2016-03-29 Thread Sergei Shtylyov

Hello.

On 3/29/2016 9:06 AM, Bjorn Andersson wrote:


From: Jason Mobarak 

Patch "wcn36xx: Pad TIM PVM if needed" has caused a regression in mesh


   scripts/checkpatch.pl now enforces the specific commit citing format, i.e. 
<12-digit SHA1> ("").



beaconing.  The field tim_off is always 0 for mesh mode, and thus
pvm_len (referring to the TIM length field) and pad are both incorrectly
calculated.  Thus, msg_body.beacon_length is incorrectly calculated for
mesh mode. Fix this.

Signed-off-by: Jason Mobarak 
Signed-off-by: Chun-Yeow Yeoh 
Signed-off-by: Bjorn Andersson 


   You might want to add the Fixes: tag.

[...]

MBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Wireless Encryption

2016-03-29 Thread Aswin Paranji
Arend,

Thanks for the response. What I'm trying to accomplish is to encrypt
the 802.11 data packet that is sent to mac80211 as data frames and
mac80211 sends it to the wifi driver.
I took a look at this blog
"https://www.linux.com/community/blogs/133-general-linux/816721-linux-wireless-networking-a-short-walk;
and thought it would be possible to just encrypt the data part.

I also checked using wireshark where the 80211 data is encrypted using
the wpa key and ssid. I'm looking for a way to encrypt data with out
touching any wifi drivers.

I'am trying to use openwrt to come up with new encryption and see if i
can use it in rapberry pi as a test bed.


Appreciate if you can help.

Regards,
Aswin

On Tue, Mar 29, 2016 at 5:16 PM, Arend Van Spriel
 wrote:
> On 29-3-2016 13:09, Aswin Paranji wrote:
>> Hi,
>> I'm trying to encrypt the 802.11 data with my own encryption instead
>> of WEP or WPA. Can anybody guide me on how to do that and where I need
>> to change. I'm trying to do this with Raspberry PI 3 device.
>
> Umm. You mean you want to do it with the integrated wifi chipset on
> RPi3. You can basically forget about that. Encryption is done on the
> wifi device. The kernel passes 802.3 packets down to the device so there
> is nothing to encrypt at that level and the device/firmware does not
> have a way for you to plugin a different encryption.
>
> Regards,
> Arend
>
>> Appreciate if you can guide me.
>>
>> Regards,
>> Aswin
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
>> the body of a message to majord...@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Wireless Encryption

2016-03-29 Thread Arend Van Spriel
On 29-3-2016 13:09, Aswin Paranji wrote:
> Hi,
> I'm trying to encrypt the 802.11 data with my own encryption instead
> of WEP or WPA. Can anybody guide me on how to do that and where I need
> to change. I'm trying to do this with Raspberry PI 3 device.

Umm. You mean you want to do it with the integrated wifi chipset on
RPi3. You can basically forget about that. Encryption is done on the
wifi device. The kernel passes 802.3 packets down to the device so there
is nothing to encrypt at that level and the device/firmware does not
have a way for you to plugin a different encryption.

Regards,
Arend

> Appreciate if you can guide me.
> 
> Regards,
> Aswin
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Wireless Encryption

2016-03-29 Thread Aswin Paranji
Hi,
I'm trying to encrypt the 802.11 data with my own encryption instead
of WEP or WPA. Can anybody guide me on how to do that and where I need
to change. I'm trying to do this with Raspberry PI 3 device.

Appreciate if you can guide me.

Regards,
Aswin
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mwifiex: advertise low priority scan feature

2016-03-29 Thread Wei-Ning Huang
I've resent the patch here: https://patchwork.kernel.org/patch/8637861/
Thanks!

Wei-Ning

On Tue, Mar 22, 2016 at 12:12 PM, Wei-Ning Huang  wrote:
> Hi Kalle,
>
> Thanks for the review. I accidentally removed the s-o-b line from
> akarwar in this version.
> The original patch can be found at:
> https://chromium-review.googlesource.com/#/c/246052/
> I've resent a new one.
>
> Wei-Ning
>
> On Mon, Mar 21, 2016 at 6:28 PM, Kalle Valo  wrote:
>> Wei-Ning Huang  writes:
>>
>>> From: Amitkumar Karwar 
>>>
>>> Low priority scan handling code which delays or aborts scan
>>> operation based on Tx traffic is removed recently. The reason
>>> is firmware already takes care of it in our new feature scan
>>> channel gap. Hence we should advertise low priority scan
>>> support to cfg80211.
>>>
>>> This patch fixes a problem in which OBSS scan request from
>>> wpa_supplicant was being rejected by cfg80211.
>>>
>>> Signed-off-by: Wei-Ning Huang 
>>
>> The From line states that this is written by Amitkumar but there's no
>> Signed-off-By line from him. I can't take this without that, please
>> resend.
>>
>> (Wei-Ning's s-o-b line is correct, I just need also Amitkumar's line.)
>>
>> --
>> Kalle Valo
>
>
>
> --
> Wei-Ning Huang, 黃偉寧 | Software Engineer, Google Inc., Taiwan |
> wnhu...@google.com | Cell: +886 910-380678



-- 
Wei-Ning Huang, 黃偉寧 | Software Engineer, Google Inc., Taiwan |
wnhu...@google.com | Cell: +886 910-380678
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] cfg80211: Add option to specify previous BSSID for Connect command

2016-03-29 Thread Jouni Malinen
This extends NL80211_CMD_CONNECT to allow the NL80211_ATTR_PREV_BSSID
attribute to be used similarly to way this was already allowed with
NL80211_CMD_ASSOCIATE. This allows user space to request reassociation
(instead of association) when already connected to an AP. This provides
an option to reassociate within an ESS without having to disconnect and
associate with the AP.

Signed-off-by: Jouni Malinen 
---
 include/net/cfg80211.h | 2 ++
 net/wireless/nl80211.c | 4 
 net/wireless/trace.h   | 6 --
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 0bbfbf3..5fbb14d 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1923,6 +1923,7 @@ struct cfg80211_bss_selection {
  * @pbss: if set, connect to a PCP instead of AP. Valid for DMG
  * networks.
  * @bss_select: criteria to be used for BSS selection.
+ * @prev_bssid: previous BSSID, if not %NULL use reassociate frame
  */
 struct cfg80211_connect_params {
struct ieee80211_channel *channel;
@@ -1947,6 +1948,7 @@ struct cfg80211_connect_params {
struct ieee80211_vht_cap vht_capa_mask;
bool pbss;
struct cfg80211_bss_selection bss_select;
+   const u8 *prev_bssid;
 };
 
 /**
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index d6c6449..a98665a 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -8024,6 +8024,10 @@ static int nl80211_connect(struct sk_buff *skb, struct 
genl_info *info)
connect.mfp = NL80211_MFP_NO;
}
 
+   if (info->attrs[NL80211_ATTR_PREV_BSSID])
+   connect.prev_bssid =
+   nla_data(info->attrs[NL80211_ATTR_PREV_BSSID]);
+
if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) {
connect.channel = nl80211_get_valid_chan(
wiphy, info->attrs[NL80211_ATTR_WIPHY_FREQ]);
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index 09b242b..8da1fae 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -1259,6 +1259,7 @@ TRACE_EVENT(rdev_connect,
__field(bool, privacy)
__field(u32, wpa_versions)
__field(u32, flags)
+   MAC_ENTRY(prev_bssid)
),
TP_fast_assign(
WIPHY_ASSIGN;
@@ -1270,13 +1271,14 @@ TRACE_EVENT(rdev_connect,
__entry->privacy = sme->privacy;
__entry->wpa_versions = sme->crypto.wpa_versions;
__entry->flags = sme->flags;
+   MAC_ASSIGN(prev_bssid, sme->prev_bssid);
),
TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", bssid: " MAC_PR_FMT
  ", ssid: %s, auth type: %d, privacy: %s, wpa versions: %u, "
- "flags: %u",
+ "flags: %u, previous bssid: " MAC_PR_FMT,
  WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(bssid), __entry->ssid,
  __entry->auth_type, BOOL_TO_STR(__entry->privacy),
- __entry->wpa_versions, __entry->flags)
+ __entry->wpa_versions, __entry->flags, MAC_PR_ARG(prev_bssid))
 );
 
 TRACE_EVENT(rdev_set_cqm_rssi_config,
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] cfg80211: Allow reassociation to be requested with internal SME

2016-03-29 Thread Jouni Malinen
If the user space issues a NL80211_CMD_CONNECT with
NL80211_ATTR_PREV_BSSID when there is already a connection, allow this
to proceed as a reassociation instead of rejecting the new connect
command with EALREADY.

Signed-off-by: Jouni Malinen 
---
 net/wireless/nl80211.c |  3 ++-
 net/wireless/sme.c | 11 +--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index a98665a..773b20f 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -8117,7 +8117,8 @@ static int nl80211_connect(struct sk_buff *skb, struct 
genl_info *info)
}
 
wdev_lock(dev->ieee80211_ptr);
-   err = cfg80211_connect(rdev, dev, , connkeys, NULL);
+   err = cfg80211_connect(rdev, dev, , connkeys,
+  connect.prev_bssid);
wdev_unlock(dev->ieee80211_ptr);
if (err)
kzfree(connkeys);
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index 65882d2..ce32492 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -492,8 +492,15 @@ static int cfg80211_sme_connect(struct wireless_dev *wdev,
if (!rdev->ops->auth || !rdev->ops->assoc)
return -EOPNOTSUPP;
 
-   if (wdev->current_bss)
-   return -EALREADY;
+   if (wdev->current_bss) {
+   if (!prev_bssid)
+   return -EALREADY;
+   cfg80211_unhold_bss(wdev->current_bss);
+   cfg80211_put_bss(wdev->wiphy, >current_bss->pub);
+   wdev->current_bss = NULL;
+
+   cfg80211_sme_free(wdev);
+   }
 
if (WARN_ON(wdev->conn))
return -EINPROGRESS;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH] mwifiex: add __GFP_REPEAT to skb allocation call

2016-03-29 Thread Amitkumar Karwar
> From: Wei-Ning Huang [mailto:wnhu...@google.com]
> Sent: Tuesday, March 29, 2016 2:57 PM
> To: Kalle Valo
> Cc: Linux Wireless; LKML; Amitkumar Karwar; Nishant Sarmukadam; Sameer
> Nanda; net...@vger.kernel.org; Sonny Rao; Douglas Anderson
> Subject: Re: [PATCH] mwifiex: add __GFP_REPEAT to skb allocation call
> 
> Adding some chromium devs to the thread.
> 
> In, http://lxr.free-electrons.com/source/mm/page_alloc.c#L3152
> 
> The default mm retry allocation when 'order <= PAGE_ALLOC_COSTLY_ORDER'
> of gfp_mask contains __GFP_REPEAT.
> PAGE_ALLOC_COSTLY_ORDER is defined to be 3. On systems with page size =
> 4K, this means memory compaction and retry is only done when the size of
> allocation is <= 32K In mwifiex, the allocation size is 64K. When we
> have system with memory fragmentation and allocation failed, there will
> be no retry.
> This is why we need to add __GFP_REPEAT here to allow the system to
> perform memory compaction and retry allocation.
> 
> Maybe Amit@marvell can comment on if this is a good fix on this issue.
> I'm also aware that marvell is the progress of implementing
> scatter/gatter for mwifiex, which can also fix the issue.
> 
> Wei-Ning
> 

This fix would be useful. We have a feature called single port aggregation in 
which sometimes data received from SDIO interface can be >32k (but less than 
64k). This feature improves throughput performance. We are preparing patches 
for scatter/gather feature. but scatter/gather won't be supported by some 
platforms. Hence this fix would still be needed.

Regards,
Amitkumar


[PATCHv3 RESEND 06/11] cfg80211: Provide an API to report NAN function termination

2016-03-29 Thread Emmanuel Grumbach
From: Andrei Otcheretianski 

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.

Signed-off-by: Andrei Otcheretianski 
Signed-off-by: Emmanuel Grumbach 
---
 include/net/cfg80211.h   | 16 +++
 include/uapi/linux/nl80211.h | 18 +
 net/wireless/nl80211.c   | 46 
 3 files changed, 80 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 8c200a0..3a94b21 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5528,6 +5528,22 @@ struct cfg80211_nan_match_params {
 void cfg80211_nan_match(struct wireless_dev *wdev,
struct cfg80211_nan_match_params *match, gfp_t gfp);
 
+/**
+ * cfg80211_nan_func_terminated - notify about NAN function termination.
+ *
+ * @wdev: the wireless device reporting the match
+ * @inst_id: the local instance id
+ * @reason: termination reason (one of the NL80211_NAN_FUNC_TERM_REASON_*)
+ * @cookie: user defined cookie
+ * @gfp: allocation flags
+ *
+ * This function reports that the a NAN function is terminated.
+ */
+void cfg80211_nan_func_terminated(struct wireless_dev *wdev,
+ u8 inst_id,
+ enum nl80211_nan_func_term_reason reason,
+ u64 cookie, gfp_t gfp);
+
 /* ethtool helper */
 void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo 
*info);
 
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 40dbbb9..f4a2e46 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1862,6 +1862,8 @@ enum nl80211_commands {
  * Its type is u8 and it cannot be 0.
  * @NL80211_ATTR_NAN_MATCH: used to report a match. This is a nested attribute.
  * See  nl80211_nan_match_attributes.
+ * @NL80211_ATTR_NAN_FUNC_TERM_REASON: NAN function termination reason.
+ * See  nl80211_nan_func_term_reason.
  *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
@@ -2246,6 +2248,7 @@ enum nl80211_attrs {
NL80211_ATTR_NAN_FUNC,
NL80211_ATTR_NAN_FUNC_INST_ID,
NL80211_ATTR_NAN_MATCH,
+   NL80211_ATTR_NAN_FUNC_TERM_REASON,
 
/* add attributes here, update the policy in nl80211.c */
 
@@ -4838,6 +4841,21 @@ enum nl80211_nan_publish_type {
NL80211_NAN_UNSOLICITED_PUBLISH = 1 << 1,
 };
 
+/**
+ * enum nl80211_nan_func_term_reason - NAN functions termination reason
+ *
+ * Defines termination reasons of a NAN function
+ *
+ * @NL80211_NAN_FUNC_TERM_REASON_USER_REQUEST: requested by user
+ * @NL80211_NAN_FUNC_TERM_REASON_TTL_EXPIRED: timeout
+ * @NL80211_NAN_FUNC_TERM_REASON_ERROR: errored
+ */
+enum nl80211_nan_func_term_reason {
+   NL80211_NAN_FUNC_TERM_REASON_USER_REQUEST,
+   NL80211_NAN_FUNC_TERM_REASON_TTL_EXPIRED,
+   NL80211_NAN_FUNC_TERM_REASON_ERROR,
+};
+
 #define NL80211_NAN_FUNC_SERVICE_ID_LEN 6
 #define NL80211_NAN_FUNC_SERVICE_SPEC_INFO_MAX_LEN 0xff
 #define NL80211_NAN_FUNC_SRF_MAX_LEN 0xff
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 32334df..4872349 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -10591,6 +10591,52 @@ nla_put_failure:
 }
 EXPORT_SYMBOL(cfg80211_nan_match);
 
+void cfg80211_nan_func_terminated(struct wireless_dev *wdev,
+ u8 inst_id,
+ enum nl80211_nan_func_term_reason reason,
+ u64 cookie, gfp_t gfp)
+{
+   struct wiphy *wiphy = wdev->wiphy;
+   struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
+   struct sk_buff *msg;
+   void *hdr;
+
+   if (WARN_ON(!inst_id))
+   return;
+
+   msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
+   if (!msg)
+   return;
+
+   hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_RM_NAN_FUNCTION);
+   if (!hdr) {
+   nlmsg_free(msg);
+   return;
+   }
+
+   if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
+   (wdev->netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX,
+wdev->netdev->ifindex)) ||
+   nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)))
+   goto nla_put_failure;
+
+   if (nla_put_u8(msg, NL80211_ATTR_NAN_FUNC_INST_ID, inst_id) ||
+   nla_put_u8(msg, NL80211_ATTR_NAN_FUNC_TERM_REASON, reason) ||
+   nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie))
+   goto nla_put_failure;
+
+   genlmsg_end(msg, hdr);
+
+   genlmsg_multicast_netns(_fam, wiphy_net(>wiphy), msg, 0,
+   NL80211_MCGRP_NAN, gfp);
+   return;
+

[PATCHv3 RESEND 09/11] mac80211: Implement add_nan_func and rm_nan_func

2016-03-29 Thread Emmanuel Grumbach
From: Andrei Otcheretianski 

Implement add/rm_nan_func functions and handle nan function
termination notifications. Handle instance_id allocation for
nan functions and implement the reconfig flow.

Signed-off-by: Andrei Otcheretianski 
Signed-off-by: Emmanuel Grumbach 
---
 include/net/mac80211.h |  31 ++
 net/mac80211/cfg.c | 147 +
 net/mac80211/driver-ops.h  |  32 ++
 net/mac80211/ieee80211_i.h |  15 +
 net/mac80211/iface.c   |  21 ++-
 net/mac80211/main.c|   3 +
 net/mac80211/trace.h   |  53 
 net/mac80211/util.c|  55 -
 8 files changed, 354 insertions(+), 3 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 011f979..a3cc08f 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -2116,6 +2116,8 @@ enum ieee80211_hw_flags {
  *
  * @txq_ac_max_pending: maximum number of frames per AC pending in all txq
  * entries for a vif.
+ * @max_nan_de_entries: maximum number of NAN DE functions supported by the
+ * device.
  */
 struct ieee80211_hw {
struct ieee80211_conf conf;
@@ -2146,6 +2148,7 @@ struct ieee80211_hw {
u8 n_cipher_schemes;
const struct ieee80211_cipher_scheme *cipher_schemes;
int txq_ac_max_pending;
+   u8 max_nan_de_entries;
 };
 
 static inline bool _ieee80211_hw_check(struct ieee80211_hw *hw,
@@ -3364,6 +3367,12 @@ enum ieee80211_reconfig_type {
  * @nan_change_conf: change nan configuration. The data in cfg80211_nan_conf
  * contains full new configuration and changes specify which parameters
  * are changed with respect to the last nan config.
+ * @add_nan_func: Add a nan function. Returns 0 on success. The data in
+ * cfg80211_nan_func must not be referenced outside the scope of
+ * this call.
+ * @rm_nan_func: Remove a nan function. The driver must call
+ * ieee80211_nan_func_terminated() with
+ * NL80211_NAN_FUNC_TERM_REASON_USER_REQUEST reason code upon removal.
  */
 struct ieee80211_ops {
void (*tx)(struct ieee80211_hw *hw,
@@ -3611,6 +3620,12 @@ struct ieee80211_ops {
int (*nan_change_conf)(struct ieee80211_hw *hw,
   struct ieee80211_vif *vif,
   struct cfg80211_nan_conf *conf, u8 changes);
+   int (*add_nan_func)(struct ieee80211_hw *hw,
+   struct ieee80211_vif *vif,
+   const struct cfg80211_nan_func *nan_func);
+   void (*rm_nan_func)(struct ieee80211_hw *hw,
+   struct ieee80211_vif *vif,
+   u8 instance_id);
 };
 
 /**
@@ -5655,4 +5670,20 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw 
*hw,
 void ieee80211_txq_get_depth(struct ieee80211_txq *txq,
 unsigned long *frame_cnt,
 unsigned long *byte_cnt);
+
+/*
+ * ieee80211_nan_func_terminated - notify about NAN function termination.
+ *
+ * This function is used to notify mac80211 about nan function termination.
+ *
+ * @vif:  ieee80211_vif pointer from the add_interface callback.
+ * @inst_id: the local instance id
+ * @reason: termination reason (one of the NL80211_NAN_FUNC_TERM_REASON_*)
+ * @gfp: allocation flags
+ */
+void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,
+  u8 inst_id,
+  enum nl80211_nan_func_term_reason reason,
+  gfp_t gfp);
+
 #endif /* MAC80211_H */
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 9215232..67b0d8a 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3,6 +3,7 @@
  *
  * Copyright 2006-2010 Johannes Berg 
  * Copyright 2013-2015  Intel Mobile Communications GmbH
+ * Copyright (C) 2015-2016 Intel Deutschland GmbH
  *
  * This file is GPLv2 as found in COPYING.
  */
@@ -152,6 +153,12 @@ static int ieee80211_start_nan(struct wiphy *wiphy,
 
memcpy(>u.nan.nan_conf, conf, sizeof(sdata->u.nan.nan_conf));
 
+   /* Only set max_nan_de_entries as available to honor the device's
+* limitations
+*/
+   bitmap_set(sdata->u.nan.func_ids, 1,
+  sdata->local->hw.max_nan_de_entries);
+
return ret;
 }
 
@@ -194,6 +201,107 @@ static int ieee80211_nan_change_conf(struct wiphy *wiphy,
return ret;
 }
 
+static int ieee80211_add_nan_func(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ struct cfg80211_nan_func *nan_func)
+{
+   struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
+   struct ieee80211_nan_func *func;
+   int ret;
+   int inst_id;
+
+   if (sdata->vif.type != NL80211_IFTYPE_NAN)
+   return -EOPNOTSUPP;
+

[PATCHv3 RESEND 08/11] mac80211: implement nan_change_conf

2016-03-29 Thread Emmanuel Grumbach
From: Andrei Otcheretianski 

Implement nan_change_conf callback which allows to change current
nan configuration (master preference and dual band operation).
Store the current nan configuration in sdata, so it can be used
both to provide the driver the updated configuration with changes
and also it will be used in hw reconfig flows in next patches.

Signed-off-by: Andrei Otcheretianski 
Signed-off-by: Emmanuel Grumbach 
---
 include/net/mac80211.h |  6 ++
 net/mac80211/cfg.c | 33 +
 net/mac80211/driver-ops.h  | 21 +
 net/mac80211/ieee80211_i.h | 10 ++
 net/mac80211/trace.h   | 31 +++
 5 files changed, 101 insertions(+)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 12860de..011f979 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -3361,6 +3361,9 @@ enum ieee80211_reconfig_type {
  *
  * @start_nan: join an existing nan cluster, or create a new one.
  * @stop_nan: leave the nan cluster.
+ * @nan_change_conf: change nan configuration. The data in cfg80211_nan_conf
+ * contains full new configuration and changes specify which parameters
+ * are changed with respect to the last nan config.
  */
 struct ieee80211_ops {
void (*tx)(struct ieee80211_hw *hw,
@@ -3605,6 +3608,9 @@ struct ieee80211_ops {
 struct cfg80211_nan_conf *conf);
int (*stop_nan)(struct ieee80211_hw *hw,
struct ieee80211_vif *vif);
+   int (*nan_change_conf)(struct ieee80211_hw *hw,
+  struct ieee80211_vif *vif,
+  struct cfg80211_nan_conf *conf, u8 changes);
 };
 
 /**
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index a9d66b4..9215232 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -150,6 +150,8 @@ static int ieee80211_start_nan(struct wiphy *wiphy,
if (ret)
ieee80211_sdata_stop(sdata);
 
+   memcpy(>u.nan.nan_conf, conf, sizeof(sdata->u.nan.nan_conf));
+
return ret;
 }
 
@@ -162,6 +164,36 @@ static void ieee80211_stop_nan(struct wiphy *wiphy,
ieee80211_sdata_stop(sdata);
 }
 
+static int ieee80211_nan_change_conf(struct wiphy *wiphy,
+struct wireless_dev *wdev,
+struct cfg80211_nan_conf *conf,
+u32 changes)
+{
+   struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
+   struct cfg80211_nan_conf new_conf;
+   int ret = 0;
+
+   if (sdata->vif.type != NL80211_IFTYPE_NAN)
+   return -EOPNOTSUPP;
+
+   if (!ieee80211_sdata_running(sdata))
+   return -ENETDOWN;
+
+   memcpy(_conf, >u.nan.nan_conf, sizeof(new_conf));
+   if (changes & CFG80211_NAN_CONF_CHANGED_PREF)
+   new_conf.master_pref = conf->master_pref;
+
+   if (changes & CFG80211_NAN_CONF_CHANGED_DUAL)
+   new_conf.dual = conf->dual;
+
+   ret = drv_nan_change_conf(sdata->local, sdata, _conf, changes);
+   if (!ret)
+   memcpy(>u.nan.nan_conf, _conf,
+  sizeof(sdata->u.nan.nan_conf));
+
+   return ret;
+}
+
 static int ieee80211_set_noack_map(struct wiphy *wiphy,
  struct net_device *dev,
  u16 noack_map)
@@ -3473,4 +3505,5 @@ const struct cfg80211_ops mac80211_config_ops = {
.del_tx_ts = ieee80211_del_tx_ts,
.start_nan = ieee80211_start_nan,
.stop_nan = ieee80211_stop_nan,
+   .nan_change_conf = ieee80211_nan_change_conf,
 };
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index 3352ce2..3c84fbd 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -1206,4 +1206,25 @@ static inline void drv_stop_nan(struct ieee80211_local 
*local,
trace_drv_return_void(local);
 }
 
+static inline int drv_nan_change_conf(struct ieee80211_local *local,
+  struct ieee80211_sub_if_data *sdata,
+  struct cfg80211_nan_conf *conf,
+  u32 changes)
+{
+   int ret;
+
+   might_sleep();
+   check_sdata_in_driver(sdata);
+
+   if (!local->ops->nan_change_conf)
+   return -EOPNOTSUPP;
+
+   trace_drv_nan_change_conf(local, sdata, conf, changes);
+   ret = local->ops->nan_change_conf(>hw, >vif, conf,
+ changes);
+   trace_drv_return_int(local, ret);
+
+   return ret;
+}
+
 #endif /* __MAC80211_DRIVER_OPS */
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index c6830fb..f985ed2 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -813,6 +813,15 @@ struct txq_info {

[PATCHv3 RESEND 10/11] mac80211: Add API to report nan function match

2016-03-29 Thread Emmanuel Grumbach
From: Andrei Otcheretianski 

Provide an API to report nan function match. Mac80211 will lookup the
corresponding cookie and report the match to cfg80211.

Signed-off-by: Andrei Otcheretianski 
Signed-off-by: Emmanuel Grumbach 
---
 include/net/mac80211.h | 14 ++
 net/mac80211/cfg.c | 28 
 2 files changed, 42 insertions(+)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index a3cc08f..5ca5b02 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -5686,4 +5686,18 @@ void ieee80211_nan_func_terminated(struct ieee80211_vif 
*vif,
   enum nl80211_nan_func_term_reason reason,
   gfp_t gfp);
 
+/**
+ * ieee80211_nan_func_match - notify about NAN function match event.
+ *
+ * This function is used to notify mac80211 about nan function match. The
+ * cookie inside the match struct will be assigned by mac80211.
+ *
+ * @vif:  ieee80211_vif pointer from the add_interface callback.
+ * @match: match event information
+ * @gfp: allocation flags
+ */
+void ieee80211_nan_func_match(struct ieee80211_vif *vif,
+ struct cfg80211_nan_match_params *match,
+ gfp_t gfp);
+
 #endif /* MAC80211_H */
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 67b0d8a..e0e5301 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3563,6 +3563,34 @@ void ieee80211_nan_func_terminated(struct ieee80211_vif 
*vif,
 }
 EXPORT_SYMBOL(ieee80211_nan_func_terminated);
 
+void ieee80211_nan_func_match(struct ieee80211_vif *vif,
+ struct cfg80211_nan_match_params *match,
+ gfp_t gfp)
+{
+   struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
+   struct ieee80211_nan_func *func;
+   struct wireless_dev *wdev;
+
+   if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
+   return;
+
+   spin_lock_bh(>u.nan.func_lock);
+
+   func = ieee80211_find_nan_func(sdata, match->inst_id);
+   if (WARN_ON(!func)) {
+   spin_unlock_bh(>u.nan.func_lock);
+   return;
+   }
+   match->cookie = func->func.cookie;
+
+   spin_unlock_bh(>u.nan.func_lock);
+
+   wdev = ieee80211_vif_to_wdev(vif);
+   if (!WARN_ON_ONCE(!wdev))
+   cfg80211_nan_match(wdev, match, gfp);
+}
+EXPORT_SYMBOL(ieee80211_nan_func_match);
+
 const struct cfg80211_ops mac80211_config_ops = {
.add_virtual_intf = ieee80211_add_iface,
.del_virtual_intf = ieee80211_del_iface,
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 RESEND 07/11] cfg80211: add utility functions to clone and free nan_func

2016-03-29 Thread Emmanuel Grumbach
From: Andrei Otcheretianski 

Add cfg80211_free_nan_func and cfg80211_clone_nan_func. These helper
functions will be used by mac80211 in the next patch.

Signed-off-by: Andrei Otcheretianski 
Signed-off-by: Emmanuel Grumbach 
---
 include/net/cfg80211.h |  21 ++
 net/wireless/util.c| 112 +
 2 files changed, 133 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 3a94b21..5e972f4 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5544,6 +5544,27 @@ void cfg80211_nan_func_terminated(struct wireless_dev 
*wdev,
  enum nl80211_nan_func_term_reason reason,
  u64 cookie, gfp_t gfp);
 
+/**
+ * cfg80211_free_nan_func_members - free nan function members
+ * @f: NAN function that should be freed
+ *
+ * Frees all the allocated members of the given function, however
+ * it doesn't frees the pointed memory. This function can be only called if @f
+ * was cloned using cfg80211_clone_nan_func_members()
+ */
+void cfg80211_free_nan_func_members(struct cfg80211_nan_func *f);
+
+/**
+ * cfg80211_clone_nan_func_members - clone nan function
+ * @f1: destination
+ * @f2: source
+ *
+ * Clones @f2 to @f1. The function doesn't allocate @f1. Returns 0 on success.
+ * To free @f1's members cfg80211_free_nan_func_members() should be used.
+ */
+int cfg80211_clone_nan_func_members(struct cfg80211_nan_func *f1,
+   const struct cfg80211_nan_func *f2);
+
 /* ethtool helper */
 void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo 
*info);
 
diff --git a/net/wireless/util.c b/net/wireless/util.c
index bdf0c40..09f07c7 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -1757,6 +1757,118 @@ int cfg80211_get_station(struct net_device *dev, const 
u8 *mac_addr,
 }
 EXPORT_SYMBOL(cfg80211_get_station);
 
+void cfg80211_free_nan_func_members(struct cfg80211_nan_func *f)
+{
+   int i;
+
+   kfree(f->serv_spec_info);
+   kfree(f->srf_bf);
+   kfree(f->srf_macs);
+   for (i = 0; i < f->num_rx_filters; i++)
+   kfree(f->rx_filters[i].filter);
+
+   for (i = 0; i < f->num_tx_filters; i++)
+   kfree(f->tx_filters[i].filter);
+
+   kfree(f->rx_filters);
+   kfree(f->tx_filters);
+}
+EXPORT_SYMBOL(cfg80211_free_nan_func_members);
+
+static int
+ieee80211_clone_match_filters(struct cfg80211_nan_func_filter *filt1,
+ const struct cfg80211_nan_func_filter *filt2,
+ int num_filters)
+{
+   int i;
+
+   for (i = 0; i < num_filters; i++) {
+   filt1[i].filter = kmemdup(filt2[i].filter, filt2[i].len,
+ GFP_KERNEL);
+   filt1[i].len = filt2[i].len;
+
+   if (!filt1[i].filter)
+   return -ENOMEM;
+   }
+
+   return 0;
+}
+
+int cfg80211_clone_nan_func_members(struct cfg80211_nan_func *f1,
+   const struct cfg80211_nan_func *f2)
+{
+   memcpy(f1, f2, sizeof(*f1));
+
+   /* set all pointers to NULL so we can free them in case of failure */
+   f1->serv_spec_info = NULL;
+   f1->srf_bf = NULL;
+   f1->srf_macs = NULL;
+   f1->rx_filters = NULL;
+   f1->tx_filters = NULL;
+   f1->num_rx_filters = 0;
+   f1->num_tx_filters = 0;
+
+   if (f2->serv_spec_info_len) {
+   f1->serv_spec_info = kmemdup(f2->serv_spec_info,
+f2->serv_spec_info_len,
+GFP_KERNEL);
+   if (!f1->serv_spec_info)
+   goto err;
+   }
+
+   if (f2->srf_bf_len) {
+   f1->srf_bf = kmemdup(f2->srf_bf, f2->srf_bf_len, GFP_KERNEL);
+   if (!f1->srf_bf)
+   goto err;
+   }
+
+   if (f2->srf_num_macs) {
+   f1->srf_macs = kmemdup(f2->srf_macs,
+  f2->srf_num_macs *
+  sizeof(*f2->srf_macs),
+  GFP_KERNEL);
+   if (!f1->srf_macs)
+   goto err;
+   }
+
+   if (f2->num_rx_filters) {
+   f1->rx_filters = kcalloc(f2->num_rx_filters,
+sizeof(*f1->rx_filters),
+GFP_KERNEL);
+   if (!f1->rx_filters)
+   goto err;
+
+   if (!ieee80211_clone_match_filters(f1->rx_filters,
+  f2->rx_filters,
+  f2->num_rx_filters))
+   goto err;
+
+   f1->num_rx_filters = f2->num_rx_filters;
+   }
+
+   

[PATCHv3 RESEND 05/11] cfg80211: provide a function to report a match for NAN

2016-03-29 Thread Emmanuel Grumbach
Provide a function the driver can call to report a match.
This will send the event to the user space.

Signed-off-by: Andrei Otcheretianski 
Signed-off-by: Emmanuel Grumbach 
---
 include/net/cfg80211.h   | 37 ++
 include/uapi/linux/nl80211.h | 38 +++
 net/wireless/nl80211.c   | 62 
 3 files changed, 137 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index becfdff..8c200a0 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5491,6 +5491,43 @@ wiphy_ext_feature_isset(struct wiphy *wiphy,
return (ft_byte & BIT(ftidx % 8)) != 0;
 }
 
+/**
+ * struct cfg80211_nan_match_params - NAN match parameters
+ * @type: the type of the function that triggered a match. If it is
+ *  %NL80211_NAN_FUNC_SUBSCRIBE it means that we replied to a subscriber.
+ *  If it is %NL80211_NAN_FUNC_PUBLISH, it means that we got a discovery
+ *  result.
+ *  If it is %NL80211_NAN_FUNC_FOLLOW_UP, we received a follow up.
+ * @inst_id: the local instance id
+ * @peer_inst_id: the instance id of the peer's function
+ * @addr: the MAC address of the peer
+ * @info_len: the length of the 
+ * @info: the Service Specific Info from the peer (if any)
+ * @cookie: user defined cookie of the corresponding function
+ */
+struct cfg80211_nan_match_params {
+   enum nl80211_nan_function_type type;
+   u8 inst_id;
+   u8 peer_inst_id;
+   const u8 *addr;
+   u8 info_len;
+   const u8 *info;
+   u64 cookie;
+};
+
+/**
+ * cfg80211_nan_match - report a match for a NAN function.
+ * @wdev: the wireless device reporting the match
+ * @match: match notification parameters
+ * @gfp: allocation flags
+ *
+ * This function reports that the a NAN function had a match. This
+ * can be a subscribe that had a match or a solicited publish that
+ * was sent. It can also be a follow up that was received.
+ */
+void cfg80211_nan_match(struct wireless_dev *wdev,
+   struct cfg80211_nan_match_params *match, gfp_t gfp);
+
 /* ethtool helper */
 void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo 
*info);
 
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index b3f9b1a..40dbbb9 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -48,6 +48,7 @@
 #define NL80211_MULTICAST_GROUP_REG"regulatory"
 #define NL80211_MULTICAST_GROUP_MLME   "mlme"
 #define NL80211_MULTICAST_GROUP_VENDOR "vendor"
+#define NL80211_MULTICAST_GROUP_NAN"nan"
 #define NL80211_MULTICAST_GROUP_TESTMODE   "testmode"
 
 /**
@@ -856,6 +857,9 @@
  * must be operational (%NL80211_CMD_START_NAN was executed).
  * It must contain at least one of the following attributes:
  * %NL80211_ATTR_NAN_MASTER_PREF, %NL80211_ATTR_NAN_DUAL.
+ * @NL80211_CMD_NAN_FUNC_MATCH: Notification sent when a match is reported.
+ * This will contain a %NL80211_ATTR_NAN_MATCH nested attribute and
+ * %NL80211_ATTR_COOKIE.
  *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
@@ -1050,6 +1054,7 @@ enum nl80211_commands {
NL80211_CMD_ADD_NAN_FUNCTION,
NL80211_CMD_RM_NAN_FUNCTION,
NL80211_CMD_CHANGE_NAN_CONFIG,
+   NL80211_CMD_NAN_MATCH,
 
/* add new commands above here */
 
@@ -1855,6 +1860,8 @@ enum nl80211_commands {
  * attribute.
  * @NL80211_ATTR_NAN_FUNC_INST_ID: the instance id of a %NL80211_ATTR_NAN_FUNC.
  * Its type is u8 and it cannot be 0.
+ * @NL80211_ATTR_NAN_MATCH: used to report a match. This is a nested attribute.
+ * See  nl80211_nan_match_attributes.
  *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
@@ -2238,6 +2245,7 @@ enum nl80211_attrs {
NL80211_ATTR_NAN_DUAL,
NL80211_ATTR_NAN_FUNC,
NL80211_ATTR_NAN_FUNC_INST_ID,
+   NL80211_ATTR_NAN_MATCH,
 
/* add attributes here, update the policy in nl80211.c */
 
@@ -4923,4 +4931,34 @@ enum nl80211_nan_srf_attributes {
NL80211_NAN_SRF_ATTR_MAX = NUM_NL80211_NAN_SRF_ATTR - 1,
 };
 
+/**
+ * enum nl80211_nan_match_attributes - NAN match attributes
+ * @__NL80211_NAN_MATCH_INVALID: invalid
+ * @NL80211_NAN_MATCH_FUNC_TYPE:  nl80211_nan_function_type (u8). This is
+ * the type of the function which had a match.
+ * @NL80211_NAN_MATCH_INSTANCE_ID: The instance ID of the local function that
+ * had a match. This is a u8.
+ * @NL80211_NAN_MATCH_PEER_INSTANCE_ID: The instance ID of the peer's function
+ * that caused the match. This is a u8.
+ * @NL80211_NAN_MATCH_MAC: The MAC address of the peer. This attribute is
+ * binary.
+ * @NL80211_NAN_MATCH_SERVICE_INFO: array of bytes describing the peer's
+ * service specific info. This is a binary 

[PATCHv3 RESEND 03/11] cfg80211: add add_nan_func / rm_nan_func

2016-03-29 Thread Emmanuel Grumbach
A NAN function can be either publish, subscribe or follow
up. Make all the necessary verifications and just pass the
request to the driver.

Signed-off-by: Andrei Otcheretianski 
Signed-off-by: Emmanuel Grumbach 
---
 include/net/cfg80211.h   |  79 +++
 include/uapi/linux/nl80211.h | 153 -
 net/wireless/core.c  |   3 +-
 net/wireless/nl80211.c   | 313 +++
 net/wireless/rdev-ops.h  |  21 +++
 net/wireless/trace.h |  40 ++
 6 files changed, 607 insertions(+), 2 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 69253f5..2dc63ec 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -2272,6 +2272,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:  nl80211_nan_function_type
+ * @service_id: the service ID of the function
+ * @publish_type: _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 _filters.
+ * @num_tx_filters: length of _filters.
+ * @instance_id: driver allocated id of the function.
+ * @cookie: user defined cookie (will be returned with notifications)
+ */
+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
@@ -2546,6 +2613,11 @@ 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 value on failure.
+ * The data in cfg80211_nan_func must not be referenced outside the
+ * scope of this call. The function assigns a unique instance_id in the
+ * provided @nan_func.
+ * @rm_nan_func: Remove a nan function.
  */
 struct cfg80211_ops {
int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -2814,6 +2886,10 @@ struct cfg80211_ops {
int (*start_nan)(struct wiphy *wiphy, struct wireless_dev *wdev,
 struct cfg80211_nan_conf *conf);
void(*stop_nan)(struct wiphy *wiphy, struct wireless_dev *wdev);
+   int (*add_nan_func)(struct wiphy *wiphy, struct wireless_dev *wdev,
+   struct cfg80211_nan_func *nan_func);
+   void(*rm_nan_func)(struct wiphy *wiphy, struct wireless_dev *wdev,
+  u64 cookie);
 };
 
 /*
@@ -3236,6 +3312,7 @@ struct wiphy_vendor_command {
  * @bss_select_support: bitmask indicating the BSS selection criteria supported
  * by the driver in the .connect() callback. The bit position maps to the
  * attribute indices defined in  nl80211_bss_select_attr.
+ * @cookie_counter: unique generic cookie counter, used to identify objects.
  */
 struct wiphy {
/* assign these fields before you register the wiphy */
@@ -3360,6 +3437,8 @@ struct wiphy {
 
u32 bss_select_support;
 
+   u64 

[PATCHv3 RESEND 02/11] mac80211: add boilerplate code for start / stop NAN

2016-03-29 Thread Emmanuel Grumbach
This codes doens't do much besides allowing to start and
stop the vif.

Signed-off-by: Andrei Otcheretianski 
Signed-off-by: Emmanuel Grumbach 
---
 include/net/mac80211.h|  9 +
 net/mac80211/cfg.c| 35 +
 net/mac80211/chan.c   |  3 +++
 net/mac80211/driver-ops.h | 29 ++-
 net/mac80211/iface.c  |  8 ++--
 net/mac80211/main.c   |  5 +
 net/mac80211/offchannel.c |  3 ++-
 net/mac80211/trace.h  | 50 +++
 net/mac80211/util.c   |  3 ++-
 9 files changed, 140 insertions(+), 5 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index a5c..12860de 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -3358,6 +3358,9 @@ enum ieee80211_reconfig_type {
  * synchronization which is needed in case driver has in its RSS queues
  * pending frames that were received prior to the control path action
  * currently taken (e.g. disassociation) but are not processed yet.
+ *
+ * @start_nan: join an existing nan cluster, or create a new one.
+ * @stop_nan: leave the nan cluster.
  */
 struct ieee80211_ops {
void (*tx)(struct ieee80211_hw *hw,
@@ -3596,6 +3599,12 @@ struct ieee80211_ops {
void (*wake_tx_queue)(struct ieee80211_hw *hw,
  struct ieee80211_txq *txq);
void (*sync_rx_queues)(struct ieee80211_hw *hw);
+
+   int (*start_nan)(struct ieee80211_hw *hw,
+struct ieee80211_vif *vif,
+struct cfg80211_nan_conf *conf);
+   int (*stop_nan)(struct ieee80211_hw *hw,
+   struct ieee80211_vif *vif);
 };
 
 /**
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 80a5958..a9d66b4 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -129,6 +129,39 @@ static void ieee80211_stop_p2p_device(struct wiphy *wiphy,
ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev));
 }
 
+static int ieee80211_start_nan(struct wiphy *wiphy,
+  struct wireless_dev *wdev,
+  struct cfg80211_nan_conf *conf)
+{
+   struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
+   int ret;
+
+   mutex_lock(>local->chanctx_mtx);
+   ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
+   mutex_unlock(>local->chanctx_mtx);
+   if (ret < 0)
+   return ret;
+
+   ret = ieee80211_do_open(wdev, true);
+   if (ret)
+   return ret;
+
+   ret = drv_start_nan(sdata->local, sdata, conf);
+   if (ret)
+   ieee80211_sdata_stop(sdata);
+
+   return ret;
+}
+
+static void ieee80211_stop_nan(struct wiphy *wiphy,
+  struct wireless_dev *wdev)
+{
+   struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
+
+   drv_stop_nan(sdata->local, sdata);
+   ieee80211_sdata_stop(sdata);
+}
+
 static int ieee80211_set_noack_map(struct wiphy *wiphy,
  struct net_device *dev,
  u16 noack_map)
@@ -3438,4 +3471,6 @@ const struct cfg80211_ops mac80211_config_ops = {
.set_ap_chanwidth = ieee80211_set_ap_chanwidth,
.add_tx_ts = ieee80211_add_tx_ts,
.del_tx_ts = ieee80211_del_tx_ts,
+   .start_nan = ieee80211_start_nan,
+   .stop_nan = ieee80211_stop_nan,
 };
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index acb50f8..e4d147e 100644
--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -647,6 +647,9 @@ static int ieee80211_assign_vif_chanctx(struct 
ieee80211_sub_if_data *sdata,
struct ieee80211_chanctx *curr_ctx = NULL;
int ret = 0;
 
+   if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_NAN))
+   return -ENOTSUPP;
+
conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
 lockdep_is_held(>chanctx_mtx));
 
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index 184473c..3352ce2 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -162,7 +162,8 @@ static inline void drv_bss_info_changed(struct 
ieee80211_local *local,
return;
 
if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
-sdata->vif.type == NL80211_IFTYPE_MONITOR))
+sdata->vif.type == NL80211_IFTYPE_MONITOR ||
+sdata->vif.type == NL80211_IFTYPE_NAN))
return;
 
if (!check_sdata_in_driver(sdata))
@@ -1179,4 +1180,30 @@ static inline void drv_wake_tx_queue(struct 
ieee80211_local *local,
local->ops->wake_tx_queue(>hw, >txq);
 }
 
+static inline int drv_start_nan(struct ieee80211_local *local,
+   struct ieee80211_sub_if_data *sdata,
+

[PATCHv3 RESEND 04/11] cfg80211: allow the user space to change current NAN configuration

2016-03-29 Thread Emmanuel Grumbach
Some NAN configuration paramaters may change during the operation of
the NaN device. For example, a user may want to update master preference
value when the device gets plugged/unplugged to the power.
Add API that allows to do so.

Signed-off-by: Andrei Otcheretianski 
Signed-off-by: Emmanuel Grumbach 
---
 include/net/cfg80211.h   | 17 +
 include/uapi/linux/nl80211.h | 11 +--
 net/wireless/nl80211.c   | 45 
 net/wireless/rdev-ops.h  | 17 +
 net/wireless/trace.h | 24 +++
 5 files changed, 112 insertions(+), 2 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 2dc63ec..becfdff 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -2339,6 +2339,17 @@ struct cfg80211_nan_func {
 };
 
 /**
+ * enum cfg80211_nan_conf_changes - indicates changed fields in nan 
configuration
+ *
+ * @CFG80211_NAN_CONF_CHANGED_PREF: master preference
+ * @CFG80211_NAN_CONF_CHANGED_DUAL: dual band operation
+ */
+enum cfg80211_nan_conf_changes {
+   CFG80211_NAN_CONF_CHANGED_PREF = BIT(0),
+   CFG80211_NAN_CONF_CHANGED_DUAL = BIT(1),
+};
+
+/**
  * struct cfg80211_ops - backend description for wireless configuration
  *
  * This struct is registered by fullmac card drivers and/or wireless stacks
@@ -2618,6 +2629,8 @@ struct cfg80211_nan_func {
  * scope of this call. The function assigns a unique instance_id in the
  * provided @nan_func.
  * @rm_nan_func: Remove a nan function.
+ * @nan_change_conf: changes NAN configuration. The changed parameters must
+ * be specified in @changes. All other parameters must be ignored.
  */
 struct cfg80211_ops {
int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -2890,6 +2903,10 @@ struct cfg80211_ops {
struct cfg80211_nan_func *nan_func);
void(*rm_nan_func)(struct wiphy *wiphy, struct wireless_dev *wdev,
   u64 cookie);
+   int (*nan_change_conf)(struct wiphy *wiphy,
+  struct wireless_dev *wdev,
+  struct cfg80211_nan_conf *conf,
+  u32 changes);
 };
 
 /*
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index daf116a..b3f9b1a 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -852,6 +852,10 @@
  * 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.
+ * @NL80211_CMD_CHANGE_NAN_CONFIG: Change current NAN configuration. NAN
+ * must be operational (%NL80211_CMD_START_NAN was executed).
+ * It must contain at least one of the following attributes:
+ * %NL80211_ATTR_NAN_MASTER_PREF, %NL80211_ATTR_NAN_DUAL.
  *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
@@ -1045,6 +1049,7 @@ enum nl80211_commands {
NL80211_CMD_STOP_NAN,
NL80211_CMD_ADD_NAN_FUNCTION,
NL80211_CMD_RM_NAN_FUNCTION,
+   NL80211_CMD_CHANGE_NAN_CONFIG,
 
/* add new commands above here */
 
@@ -1837,12 +1842,14 @@ enum nl80211_commands {
  * BSS selection to be done by driver and/or firmware.
  *
  * @NL80211_ATTR_NAN_MASTER_PREF: the master preference to be used by
- * _CMD_START_NAN. Its type is u8 and it can't be 0.
+ * _CMD_START_NAN and optionally with
+ * _CMD_CHANGE_NAN_CONFIG. Its type is u8 and it can't be 0.
  * Also, values 1 and 255 are reserved for certification purposes and
  * should not be used during a normal device operation.
  * @NL80211_ATTR_NAN_DUAL: NAN dual band operation config (see
  *  nl80211_nan_dual_band_conf). This attribute is used with
- * _CMD_START_NAN.
+ * _CMD_START_NAN and optionally with
+ * _CMD_CHANGE_NAN_CONFIG.
  * @NL80211_ATTR_NAN_FUNC: a function that can be added to NAN. See
  *  nl80211_nan_func_attributes for description of this nested
  * attribute.
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index ef59218..ceb32d3 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -10492,6 +10492,43 @@ static int nl80211_nan_rm_func(struct sk_buff *skb,
return 0;
 }
 
+static int nl80211_nan_change_config(struct sk_buff *skb,
+struct genl_info *info)
+{
+   struct cfg80211_registered_device *rdev = info->user_ptr[0];
+   struct wireless_dev *wdev = info->user_ptr[1];
+   struct cfg80211_nan_conf conf = {};
+   u32 changed = 0;
+
+   if (wdev->iftype != NL80211_IFTYPE_NAN)
+   return -EOPNOTSUPP;
+
+   if (!wdev->nan_started)
+   return -ENOTCONN;
+
+   if (info->attrs[NL80211_ATTR_NAN_MASTER_PREF]) 

[PATCHv3 RESEND 11/11] cfg80211: allow to tie the NAN instance to the owner

2016-03-29 Thread Emmanuel Grumbach
Allow the user space application that starts NAN to
forbid any other socket to add or remove functions.
Notifications will be sent to the socket that started
the NAN interface only.

By default, keep the current behavior: events are sent
in multicast and any application can add / remove
functions.

Signed-off-by: Emmanuel Grumbach 
---
 include/uapi/linux/nl80211.h |  7 +++
 net/wireless/nl80211.c   | 26 ++
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index f4a2e46..c9867ae 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -849,6 +849,7 @@
  * 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
@@ -1760,6 +1761,12 @@ enum nl80211_commands {
  * regulatory indoor configuration would be owned by the netlink socket
  * that configured the indoor setting, and the indoor operation would be
  * cleared when the socket is closed.
+ * If set during NAN interface creation, the interface will be destroyed
+ * if the socket is closed just like any other interface. Moreover, only
+ * the netlink socket that created the interface will be allowed to add
+ * and remove functions. NAN notifications will be sent in unicast to that
+ * socket. Without this attribute, any socket can add functions and the
+ * notifications will be sent to the %NL80211_MCGRP_NAN multicast group.
  *
  * @NL80211_ATTR_TDLS_INITIATOR: flag attribute indicating the current end is
  * the TDLS link initiator.
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 4872349..b42c45f 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -10304,6 +10304,10 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
 
func.cookie = wdev->wiphy->cookie_counter++;
 
+   if (wdev->owner_nlportid &&
+   wdev->owner_nlportid != info->snd_portid)
+   return -ENOTCONN;
+
err = nla_parse(tb, NL80211_NAN_FUNC_ATTR_MAX,
nla_data(info->attrs[NL80211_ATTR_NAN_FUNC]),
nla_len(info->attrs[NL80211_ATTR_NAN_FUNC]),
@@ -10487,6 +10491,10 @@ static int nl80211_nan_rm_func(struct sk_buff *skb,
if (!info->attrs[NL80211_ATTR_COOKIE])
return -EINVAL;
 
+   if (wdev->owner_nlportid &&
+   wdev->owner_nlportid != info->snd_portid)
+   return -ENOTCONN;
+
cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]);
 
rdev_rm_nan_func(rdev, wdev, cookie);
@@ -10581,8 +10589,13 @@ void cfg80211_nan_match(struct wireless_dev *wdev,
nla_nest_end(msg, match_attr);
genlmsg_end(msg, hdr);
 
-   genlmsg_multicast_netns(_fam, wiphy_net(>wiphy), msg, 0,
-   NL80211_MCGRP_NAN, gfp);
+   if (!wdev->owner_nlportid)
+   genlmsg_multicast_netns(_fam, wiphy_net(>wiphy),
+   msg, 0, NL80211_MCGRP_NAN, gfp);
+   else
+   genlmsg_unicast(wiphy_net(>wiphy), msg,
+   wdev->owner_nlportid);
+
return;
 
 nla_put_failure:
@@ -10627,8 +10640,13 @@ void cfg80211_nan_func_terminated(struct wireless_dev 
*wdev,
 
genlmsg_end(msg, hdr);
 
-   genlmsg_multicast_netns(_fam, wiphy_net(>wiphy), msg, 0,
-   NL80211_MCGRP_NAN, gfp);
+   if (!wdev->owner_nlportid)
+   genlmsg_multicast_netns(_fam, wiphy_net(>wiphy),
+   msg, 0, NL80211_MCGRP_NAN, gfp);
+   else
+   genlmsg_unicast(wiphy_net(>wiphy), msg,
+   wdev->owner_nlportid);
+
return;
 
 nla_put_failure:
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mwifiex: add __GFP_REPEAT to skb allocation call

2016-03-29 Thread Wei-Ning Huang
Adding some chromium devs to the thread.

In, http://lxr.free-electrons.com/source/mm/page_alloc.c#L3152

The default mm retry allocation when 'order <=
PAGE_ALLOC_COSTLY_ORDER' of gfp_mask contains __GFP_REPEAT.
PAGE_ALLOC_COSTLY_ORDER is defined to be 3. On systems with page size
= 4K, this means memory compaction and retry is only done when the
size of allocation is <= 32K
In mwifiex, the allocation size is 64K. When we have system with
memory fragmentation and allocation failed, there will be no retry.
This is why we need to add __GFP_REPEAT here to allow the system to
perform memory compaction and retry allocation.

Maybe Amit@marvell can comment on if this is a good fix on this issue.
I'm also aware that marvell is the progress of implementing
scatter/gatter for mwifiex, which can also fix the issue.

Wei-Ning

On Tue, Mar 29, 2016 at 4:37 PM, Kalle Valo  wrote:
> Wei-Ning Huang  writes:
>
>> "single skb allocation failure" happens when system is under heavy
>> memory pressure.  Add __GFP_REPEAT to skb allocation call so kernel
>> attempts to reclaim pages and retry the allocation.
>>
>> Signed-off-by: Wei-Ning Huang 
>
> Is this really a proper way to fix the issue? This is the first time I'm
> hearing about the flag and there isn't even a single user in
> drivers/net. I would like to get confirmation from others that
> __GFP_REPEAT is really ok to use in a wireless driver before I can take
> this.
>
> --
> Kalle Valo



-- 
Wei-Ning Huang, 黃偉寧 | Software Engineer, Google Inc., Taiwan |
wnhu...@google.com | Cell: +886 910-380678
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 1/2] ath10k: Add support for ath10k_sta_statistics support

2016-03-29 Thread kbuild test robot
Hi Mohammed,

[auto build test ERROR on ath6kl/ath-next]
[also build test ERROR on v4.6-rc1 next-20160329]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improving the system]

url:
https://github.com/0day-ci/linux/commits/Mohammed-Shafi-Shajakhan/ath10k-Add-support-for-ath10k_sta_statistics-support/20160329-165849
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git ath-next
config: sparc64-allyesconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sparc64 

All errors (new ones prefixed by >>):

   drivers/net/wireless/ath/ath10k/debugfs_sta.c: In function 
'ath10k_sta_statistics':
>> drivers/net/wireless/ath/ath10k/debugfs_sta.c:45:2: error: implicit 
>> declaration of function 'ath10k_peer_stats_enabled' 
>> [-Werror=implicit-function-declaration]
 if (!ath10k_peer_stats_enabled(ar))
 ^
>> drivers/net/wireless/ath/ath10k/debugfs_sta.c:48:7: error: 'struct 
>> station_info' has no member named 'rx_duration'
 sinfo->rx_duration = arsta->rx_duration;
  ^
>> drivers/net/wireless/ath/ath10k/debugfs_sta.c:49:27: error: 
>> 'NL80211_STA_INFO_RX_DURATION' undeclared (first use in this function)
 sinfo->filled |= 1ULL << NL80211_STA_INFO_RX_DURATION;
  ^
   drivers/net/wireless/ath/ath10k/debugfs_sta.c:49:27: note: each undeclared 
identifier is reported only once for each function it appears in
   cc1: some warnings being treated as errors

vim +/ath10k_peer_stats_enabled +45 
drivers/net/wireless/ath/ath10k/debugfs_sta.c

39 struct ieee80211_sta *sta,
40 struct station_info *sinfo)
41  {
42  struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
43  struct ath10k *ar = arsta->arvif->ar;
44  
  > 45  if (!ath10k_peer_stats_enabled(ar))
46  return;
47  
  > 48  sinfo->rx_duration = arsta->rx_duration;
  > 49  sinfo->filled |= 1ULL << NL80211_STA_INFO_RX_DURATION;
50  }
51  
52  static ssize_t ath10k_dbg_sta_read_aggr_mode(struct file *file,

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[PATCH v3 2/2] ath10k: Remove debugfs support for Per STA total rx duration

2016-03-29 Thread Mohammed Shafi Shajakhan
From: Mohammed Shafi Shajakhan 

cfg80211/nl80211 interface changes for per STA total rx-duration and
very basic 'ath10k_sta_statistics'  mac80211 callback is implemented
to extend support for per station statistics from the driver.

Also provision in 'iw dev wlan#N station dump' to parse rx-duration
is supported. So its safer to remove the debugfs entry for per STA
rx-duration

Signed-off-by: Mohammed Shafi Shajakhan 
---
 drivers/net/wireless/ath/ath10k/debugfs_sta.c |   24 
 1 file changed, 24 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/debugfs_sta.c 
b/drivers/net/wireless/ath/ath10k/debugfs_sta.c
index c5396bf..d1186b6 100644
--- a/drivers/net/wireless/ath/ath10k/debugfs_sta.c
+++ b/drivers/net/wireless/ath/ath10k/debugfs_sta.c
@@ -263,28 +263,6 @@ static const struct file_operations fops_delba = {
.llseek = default_llseek,
 };
 
-static ssize_t ath10k_dbg_sta_read_rx_duration(struct file *file,
-  char __user *user_buf,
-  size_t count, loff_t *ppos)
-{
-   struct ieee80211_sta *sta = file->private_data;
-   struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
-   char buf[100];
-   int len = 0;
-
-   len = scnprintf(buf, sizeof(buf),
-   "%llu usecs\n", arsta->rx_duration);
-
-   return simple_read_from_buffer(user_buf, count, ppos, buf, len);
-}
-
-static const struct file_operations fops_rx_duration = {
-   .read = ath10k_dbg_sta_read_rx_duration,
-   .open = simple_open,
-   .owner = THIS_MODULE,
-   .llseek = default_llseek,
-};
-
 void ath10k_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct ieee80211_sta *sta, struct dentry *dir)
 {
@@ -293,6 +271,4 @@ void ath10k_sta_add_debugfs(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif,
debugfs_create_file("addba", S_IWUSR, dir, sta, _addba);
debugfs_create_file("addba_resp", S_IWUSR, dir, sta, _addba_resp);
debugfs_create_file("delba", S_IWUSR, dir, sta, _delba);
-   debugfs_create_file("rx_duration", S_IRUGO, dir, sta,
-   _rx_duration);
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/2] ath10k: Add support for ath10k_sta_statistics support

2016-03-29 Thread Mohammed Shafi Shajakhan
From: Mohammed Shafi Shajakhan 

Enable support for 'drv_sta_statistics' callback.
Export rx_duration support if available to cfg80211/nl80211

This can also act as a placeholder for any new per STA stats support

Signed-off-by: Mohammed Shafi Shajakhan 
---
[v3] removed conditions for ath10k state checks based on Michal's suggestion

Dependencies:

1. cfg80211/nl80211: Add support for NL80211_STA_INFO_RX_DURATION (under review)
2. iw: Add support for NL80211_STA_INFO_RX_DURATION netlink
 attribute (under review)
3. ath10k: Enable debugfs provision to enable Peer Stats feature (merged in 
pending branch)

 drivers/net/wireless/ath/ath10k/debug.h   |4 
 drivers/net/wireless/ath/ath10k/debugfs_sta.c |   14 ++
 drivers/net/wireless/ath/ath10k/mac.c |1 +
 3 files changed, 19 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/debug.h 
b/drivers/net/wireless/ath/ath10k/debug.h
index 6206edd..01c500f 100644
--- a/drivers/net/wireless/ath/ath10k/debug.h
+++ b/drivers/net/wireless/ath/ath10k/debug.h
@@ -155,6 +155,10 @@ ath10k_debug_get_new_fw_crash_data(struct ath10k *ar)
 void ath10k_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct ieee80211_sta *sta, struct dentry *dir);
 void ath10k_sta_update_rx_duration(struct ath10k *ar, struct list_head *peer);
+void ath10k_sta_statistics(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+  struct ieee80211_sta *sta,
+  struct station_info *sinfo);
+
 #else
 static inline void ath10k_sta_update_rx_duration(struct ath10k *ar,
 struct list_head *peer)
diff --git a/drivers/net/wireless/ath/ath10k/debugfs_sta.c 
b/drivers/net/wireless/ath/ath10k/debugfs_sta.c
index 67ef75b..c5396bf 100644
--- a/drivers/net/wireless/ath/ath10k/debugfs_sta.c
+++ b/drivers/net/wireless/ath/ath10k/debugfs_sta.c
@@ -35,6 +35,20 @@ void ath10k_sta_update_rx_duration(struct ath10k *ar, struct 
list_head *head)
rcu_read_unlock();
 }
 
+void ath10k_sta_statistics(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+  struct ieee80211_sta *sta,
+  struct station_info *sinfo)
+{
+   struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
+   struct ath10k *ar = arsta->arvif->ar;
+
+   if (!ath10k_peer_stats_enabled(ar))
+   return;
+
+   sinfo->rx_duration = arsta->rx_duration;
+   sinfo->filled |= 1ULL << NL80211_STA_INFO_RX_DURATION;
+}
+
 static ssize_t ath10k_dbg_sta_read_aggr_mode(struct file *file,
 char __user *user_buf,
 size_t count, loff_t *ppos)
diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 20d72e2..02edeff 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -7271,6 +7271,7 @@ static const struct ieee80211_ops ath10k_ops = {
 #endif
 #ifdef CONFIG_MAC80211_DEBUGFS
.sta_add_debugfs= ath10k_sta_add_debugfs,
+   .sta_statistics = ath10k_sta_statistics,
 #endif
 };
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [V11,2/2] brcmfmac: add support for nl80211 BSS_SELECT feature

2016-03-29 Thread Arend Van Spriel
+ linux-wireless, Johannes

On 26-3-2016 11:28, Kalle Valo wrote:
> Arend van Spriel  writes:
> 
>> This brcmfmac patch [1] is set to "Awaiting Upstream" as it relies on
>> nl80211 patch. However, that patch was already in linux-next before the
>> merge window so are you waiting for 4.6-rc1 or did you miss this one?
>> Just want to understand the use of this state.
>>
>> Regards,
>> Arend
>>
>> [1] https://patchwork.kernel.org/patch/8484901/
> 
> Commit 0a87cadbb54e is not in net-next yet, I guess Johannes didn't send
> a pull request yet. Once it's in net-next it needs come down to
> wireless-drivers-next before I can apply it. So I'm waiting for that.

Ah. I figured the patch made it to the 4.6 deadline, but apparently not.

> But please do remind about this, I seldomly check the "Awaiting
> Upstream" queue so sometimes it might take way too long before I apply
> the patch.

So this is another way of saying the author should keep an eye on his
patches when it ends up in this state or in general ;-) Noted.

Thanks,
Arend
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mwifiex: add __GFP_REPEAT to skb allocation call

2016-03-29 Thread Kalle Valo
Wei-Ning Huang  writes:

> "single skb allocation failure" happens when system is under heavy
> memory pressure.  Add __GFP_REPEAT to skb allocation call so kernel
> attempts to reclaim pages and retry the allocation.
>
> Signed-off-by: Wei-Ning Huang 

Is this really a proper way to fix the issue? This is the first time I'm
hearing about the flag and there isn't even a single user in
drivers/net. I would like to get confirmation from others that
__GFP_REPEAT is really ok to use in a wireless driver before I can take
this.

-- 
Kalle Valo
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mac80211: allow same PN for AMSDU sub-frames

2016-03-29 Thread Johannes Berg
On Wed, 2016-03-09 at 11:29 +0200, Emmanuel Grumbach wrote:
> From: Sara Sharon 
> 
> Some hardware (iwlwifi an example) de-aggregate AMSDUs and
> copy the IV as is to the generated MPDUs, so the same PN
> appears in multiple packets without being a replay attack.
> Do not increment the PN until all the sub-frames are received
> to accommodate to that.
> 
I'll drop this for now since you found an issue with it :)

johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC] ath10k: implement dql for htt tx

2016-03-29 Thread Michal Kazior
On 26 March 2016 at 17:44, Dave Taht  wrote:
> Dear Michal:
[...]
> I am running behind on this patch set, but a couple quick comments.
[...]
>>  - no rrul tests, sorry Dave! :)
>
> rrul would be a good baseline to have, but no need to waste your time
> on running it every time as yet. It stresses out both sides of the
> link so whenever you get two devices with these driver changes on them
> it would be "interesting". It's the meanest, nastiest test we have...
> if you can get past the rrul, you've truly won.
>
> Consistently using tcp_fair_up with 1,2,4 flows and 1-4 stations as
> you are now is good enough.
>
> doing a more voip-like test with slamming d-itg into your test would be 
> good...
>
>>
>> Observations / conclusions:
>>  - DQL builds up throughput slowly on "veryfast"; in some tests it
>> doesn't get to reach peak (roughly 210mbps average) because the test
>> is too short
>
> It looks like having access to the rate control info here for the
> initial and ongoing estimates will react faster and better than dql
> can. I loved the potential here in getting full rate for web traffic
> in the usual 2second burst you get it in (see above blog entries)

On one hand - yes, rate control should in theory be "faster".

On the other hand DQL will react also to host system interrupt service
time. On slow CPUs (typically found on routers and such) you might end
up grinding the CPU so much you need deeper tx queues to keep the hw
busy (and therefore keep performance maxed). DQL should automatically
adjust to that while "txop limit" might not.


>>  - DQL shows better latency results in almost all cases compared to
>> the txop based scheduling from my mac80211 RFC (but i haven't
>> thoroughly looked at *all* the data; I might've missed a case where it
>> performs worse)
>
> Well, if you are not saturating the link, latency will be better.
> Showing how much less latency is possible, is good too, but

If you wait long enough DQL does scale the tx queue size for max
performance (you can see TCP throughput scale towards test end). It
does take a few seconds to reach the peak. Perhaps this could be
tweaked.


>>  - latency improvement seen on sw/ath10k_dql @ rate6m,fast compared to
>> sw/base (1800ms -> 160ms) can be explained by the fact that txq AC
>> limit is 256 and since all TCP streams run on BE (and fq_codel as the
>> qdisc) the induced txq latency is 256 * (1500 / (6*1024*1024/8.)) / 4
>> = ~122ms which is pretty close to the test data (the formula ignores
>> MAC overhead, so the latency in practice is larger). Once you consider
>> the overhead and in-flight packets on driver-firmware tx queue 160ms
>> doesn't seem strange. Moreover when you compare the same case with
>> sw/fq+ath10k_dql you can clearly see the advantage of having fq_codel
>> in mac80211 software queuing - the latency drops by (another) order of
>> magnitude because now incomming ICMPs are treated as new, bursty flows
>> and get fed to the device quickly.
>
>
> It is always good to test codel and fq_codel separately, particularly
> on a new codel implementation. There are so many ways to get codel
> wrong or add an optimization that doesn't work (speaking as someone
> that has got it wrong often)
>
> If you are getting a fq result of 12 ms, that means you are getting
> data into the device with a ~12ms standing queue there. On a good day
> you'd see perhaps 17-22ms for "codel target 5ms" in that case, on the
> rtt_fair_up series of tests.

This will obviously depend on the number of stations you have data
queued to. Estimating codel target time requires smarter tx
scheduling. My earlier (RFC) patch tried doing that.


> if you are getting a pure codel result of 160ms, that means the
> implementation is broken. But I think (after having read your
> description twice), the baseline result today of 160ms of queuing was
> with a fq_codel *qdisc* doing the work on top of huge buffers,

Yes. The 160ms is with fq_codel qdisc with ath10k doing DQL at 6mbps.
Without DQL ath10k would clog up all tx slots (1424 of them) with
frames. At 6mbps you typically want/need a handful (5-10) of frames to
be queued.

> the
> results a few days ago were with a fq_codel 802.11 layer, and the
> results today you are comparing, are pure fq (no codel) in the 802.11e
> stack, with fixed (and dql) buffering?

Yes. codel target in fq_codel-in-mac80211 is hardcoded at 20ms now
because there's no scheduling and hence no data to derive the target
dynamically.


> if so. Yea! Science!
>
> ...
>
> One of the flaws of the flent tests is that conceptually they were
> developed before the fq stuff won so big, and looking hard at the
> per-queue latency for the fat flows requires either looking hard at
> the packet captures or sampling the actual queue length. There is that
> sampling capability in various flent tests, but at the moment it only
> samples what tc provides (Drops, marks, and length) and it does not
> look like there is a snapshot queue 

Re: [PATCH 1/9] ath10k: speedup htt rx descriptor processing for tx completion

2016-03-29 Thread Valo, Kalle
"Manoharan, Rajkumar"  writes:

>>> @@ -1712,7 +1710,20 @@ static void ath10k_htt_rx_frm_tx_compl(struct ath10k 
>>> *ar,
>>>   for (i = 0; i < resp->data_tx_completion.num_msdus; i++) {
>>>   msdu_id = resp->data_tx_completion.msdus[i];
>>>   tx_done.msdu_id = __le16_to_cpu(msdu_id);
>>> - ath10k_txrx_tx_unref(htt, _done);
>>> +
>>> + /* kfifo_put: In practice firmware shouldn't fire off per-CE
>>> +  * interrupt and main interrupt (MSI/-X range case) for the 
>>> same
>>> +  * HTC service so it should be safe to use kfifo_put w/o lock.
>>> +  *
>>> +  * From kfifo_put() documentation:
>>> +  *  Note that with only one concurrent reader and one 
>>> concurrent
>>> +  *  writer, you don't need extra locking to use these macro.
>>> +  */
>>> + if (!kfifo_put(>txdone_fifo, tx_done)) {
>>> + ath10k_warn(ar, "txdone fifo overrun, msdu_id %d 
>>> status %d\n",
>>> + tx_done.msdu_id, tx_done.status);
>>> + ath10k_txrx_tx_unref(htt, _done);
>>> + }
>>
>> I see two new warnings on the kfifo_put() call:
>>
>> drivers/net/wireless/ath/ath10k/htt_rx.c:1722:22: warning: cast to non-scalar
>> drivers/net/wireless/ath/ath10k/htt_rx.c:1722:22: warning: cast from 
>> non-scalar
>> 
>> But I suspect they are false warnings due to my old compiler:
>> 
>> gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
>> 
>> Opinions?
>> 
> Hmm... I am not sure why older compiler is not complaining this. Unfortunately
> both x86 and cross compiler are not throwing any warnings though :(
>
> gcc version 5.3.0 (GCC)
> Target: x86_64-unknown-linux-gnu
>
> gcc version 4.8.3 (OpenWrt/Linaro GCC 4.8-2014.04 r47724)
> Target: arm-openwrt-linux-uclibcgnueabi

Maybe we can just ignore the warning and hope that all recent compilers
are smart enough.

-- 
Kalle Valo--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: WMM vs QoS

2016-03-29 Thread Steven Pease
As a test, I attempted to hardcode mac80211 to hardcode a priority of
6 or 7. I tried several places, but the most correct seemed to be
cfg80211_classify8021d. Despite this I noticed no change in behavior.
I also looked for a place in the ath9k driver, but it looked like it
pretty much just handed the data frames off from mac80211 to the
device firmware.

Any pointers on where I should be looking to affect the QoS attached
to 802.11 frames?

Thanks.

- Steven

On Wed, Mar 23, 2016 at 2:57 AM, Steven Pease  wrote:
> Hi,
> I've been tracking down some obscure wireless issues and noticed that
> there doesn't seem to be a clean mapping between RFC4594 DSCP classes
> and WMM queues.
>
> Specifically, it appears that the highest priority defined for VOIP
> traffic (EF), and which seems to be commonly used for voice, maps as
> AC_VI (next-highest) rather than AC_VO (highest). Whereas I would've
> naively expected AF41 to map as AC_VI and EF to map as AC_VO.
>
> I might be misunderstanding something. However, if this is truly the
> case, I'm wondering if there would be any adverse effects to modifying
> mac80211 to cause EF packets to get translated into the AC_VO queue?
> It seems like this way I might be able to have my cake and eat it too
> rather than choosing between correct QoS on only one of L2 or L3.
>
> Thanks.
>
> --
> - Steven



-- 
- Steven
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/16] wcn36xx: Add helper macros to cast vif to private vif and vice versa

2016-03-29 Thread Bjorn Andersson
From: Pontus Fuchs 

Makes the code a little easier to read.

Signed-off-by: Pontus Fuchs 
Signed-off-by: Bjorn Andersson 
---
 drivers/net/wireless/ath/wcn36xx/debug.c   | 12 +++-
 drivers/net/wireless/ath/wcn36xx/main.c| 16 +++-
 drivers/net/wireless/ath/wcn36xx/pmc.c |  4 ++--
 drivers/net/wireless/ath/wcn36xx/smd.c | 24 ++--
 drivers/net/wireless/ath/wcn36xx/txrx.c|  8 ++--
 drivers/net/wireless/ath/wcn36xx/wcn36xx.h | 12 
 6 files changed, 36 insertions(+), 40 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/debug.c 
b/drivers/net/wireless/ath/wcn36xx/debug.c
index ef44a2da644d..2a6bb62e785c 100644
--- a/drivers/net/wireless/ath/wcn36xx/debug.c
+++ b/drivers/net/wireless/ath/wcn36xx/debug.c
@@ -33,9 +33,7 @@ static ssize_t read_file_bool_bmps(struct file *file, char 
__user *user_buf,
char buf[3];
 
list_for_each_entry(vif_priv, >vif_list, list) {
-   vif = container_of((void *)vif_priv,
-  struct ieee80211_vif,
-  drv_priv);
+   vif = wcn36xx_priv_to_vif(vif_priv);
if (NL80211_IFTYPE_STATION == vif->type) {
if (vif_priv->pw_state == WCN36XX_BMPS)
buf[0] = '1';
@@ -70,9 +68,7 @@ static ssize_t write_file_bool_bmps(struct file *file,
case 'Y':
case '1':
list_for_each_entry(vif_priv, >vif_list, list) {
-   vif = container_of((void *)vif_priv,
-  struct ieee80211_vif,
-  drv_priv);
+   vif = wcn36xx_priv_to_vif(vif_priv);
if (NL80211_IFTYPE_STATION == vif->type) {
wcn36xx_enable_keep_alive_null_packet(wcn, vif);
wcn36xx_pmc_enter_bmps_state(wcn, vif);
@@ -83,9 +79,7 @@ static ssize_t write_file_bool_bmps(struct file *file,
case 'N':
case '0':
list_for_each_entry(vif_priv, >vif_list, list) {
-   vif = container_of((void *)vif_priv,
-  struct ieee80211_vif,
-  drv_priv);
+   vif = wcn36xx_priv_to_vif(vif_priv);
if (NL80211_IFTYPE_STATION == vif->type)
wcn36xx_pmc_exit_bmps_state(wcn, vif);
}
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c 
b/drivers/net/wireless/ath/wcn36xx/main.c
index a27279c2c695..62cb9ffd854c 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -346,9 +346,7 @@ static int wcn36xx_config(struct ieee80211_hw *hw, u32 
changed)
wcn36xx_dbg(WCN36XX_DBG_MAC, "wcn36xx_config channel 
switch=%d\n",
ch);
list_for_each_entry(tmp, >vif_list, list) {
-   vif = container_of((void *)tmp,
-  struct ieee80211_vif,
-  drv_priv);
+   vif = wcn36xx_priv_to_vif(tmp);
wcn36xx_smd_switch_channel(wcn, vif, ch);
}
}
@@ -387,7 +385,7 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum 
set_key_cmd cmd,
   struct ieee80211_key_conf *key_conf)
 {
struct wcn36xx *wcn = hw->priv;
-   struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
+   struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
struct wcn36xx_sta *sta_priv = vif_priv->sta;
int ret = 0;
u8 key[WLAN_MAX_KEY_LEN];
@@ -590,7 +588,7 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw 
*hw,
struct sk_buff *skb = NULL;
u16 tim_off, tim_len;
enum wcn36xx_hal_link_state link_state;
-   struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
+   struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
 
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac bss info changed vif %p changed 
0x%08x\n",
vif, changed);
@@ -757,7 +755,7 @@ static void wcn36xx_remove_interface(struct ieee80211_hw 
*hw,
 struct ieee80211_vif *vif)
 {
struct wcn36xx *wcn = hw->priv;
-   struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
+   struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac remove interface vif %p\n", vif);
 
list_del(_priv->list);
@@ -768,7 +766,7 @@ static int wcn36xx_add_interface(struct ieee80211_hw *hw,
 struct ieee80211_vif *vif)
 {
struct wcn36xx *wcn = hw->priv;
-   struct 

[PATCH 04/16] wcn36xx: Use consistent name for private vif

2016-03-29 Thread Bjorn Andersson
From: Pontus Fuchs 

Some code used priv_vif and some used vif_priv. Convert all to vif_priv
for consistency.

Signed-off-by: Pontus Fuchs 
Signed-off-by: Bjorn Andersson 
---
 drivers/net/wireless/ath/wcn36xx/smd.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c 
b/drivers/net/wireless/ath/wcn36xx/smd.c
index a08153eef4ae..6baf54db6241 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -191,7 +191,7 @@ static void wcn36xx_smd_set_sta_params(struct wcn36xx *wcn,
struct ieee80211_sta *sta,
struct wcn36xx_hal_config_sta_params *sta_params)
 {
-   struct wcn36xx_vif *priv_vif = wcn36xx_vif_to_priv(vif);
+   struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
struct wcn36xx_sta *priv_sta = NULL;
if (vif->type == NL80211_IFTYPE_ADHOC ||
vif->type == NL80211_IFTYPE_AP ||
@@ -215,7 +215,7 @@ static void wcn36xx_smd_set_sta_params(struct wcn36xx *wcn,
else
memcpy(_params->bssid, vif->addr, ETH_ALEN);
 
-   sta_params->encrypt_type = priv_vif->encrypt_type;
+   sta_params->encrypt_type = vif_priv->encrypt_type;
sta_params->short_preamble_supported = true;
 
sta_params->rifs_mode = 0;
@@ -224,7 +224,7 @@ static void wcn36xx_smd_set_sta_params(struct wcn36xx *wcn,
sta_params->uapsd = 0;
sta_params->mimo_ps = WCN36XX_HAL_HT_MIMO_PS_STATIC;
sta_params->max_ampdu_duration = 0;
-   sta_params->bssid_index = priv_vif->bss_index;
+   sta_params->bssid_index = vif_priv->bss_index;
sta_params->p2p = 0;
 
if (sta) {
@@ -726,7 +726,7 @@ static int wcn36xx_smd_add_sta_self_rsp(struct wcn36xx *wcn,
size_t len)
 {
struct wcn36xx_hal_add_sta_self_rsp_msg *rsp;
-   struct wcn36xx_vif *priv_vif = wcn36xx_vif_to_priv(vif);
+   struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
 
if (len < sizeof(*rsp))
return -EINVAL;
@@ -743,8 +743,8 @@ static int wcn36xx_smd_add_sta_self_rsp(struct wcn36xx *wcn,
"hal add sta self status %d self_sta_index %d dpu_index 
%d\n",
rsp->status, rsp->self_sta_index, rsp->dpu_index);
 
-   priv_vif->self_sta_index = rsp->self_sta_index;
-   priv_vif->self_dpu_desc_index = rsp->dpu_index;
+   vif_priv->self_sta_index = rsp->self_sta_index;
+   vif_priv->self_dpu_desc_index = rsp->dpu_index;
 
return 0;
 }
@@ -1175,7 +1175,7 @@ static int wcn36xx_smd_config_bss_rsp(struct wcn36xx *wcn,
 {
struct wcn36xx_hal_config_bss_rsp_msg *rsp;
struct wcn36xx_hal_config_bss_rsp_params *params;
-   struct wcn36xx_vif *priv_vif = wcn36xx_vif_to_priv(vif);
+   struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
 
if (len < sizeof(*rsp))
return -EINVAL;
@@ -1198,14 +1198,14 @@ static int wcn36xx_smd_config_bss_rsp(struct wcn36xx 
*wcn,
params->bss_bcast_sta_idx, params->mac,
params->tx_mgmt_power, params->ucast_dpu_signature);
 
-   priv_vif->bss_index = params->bss_index;
+   vif_priv->bss_index = params->bss_index;
 
-   if (priv_vif->sta) {
-   priv_vif->sta->bss_sta_index =  params->bss_sta_index;
-   priv_vif->sta->bss_dpu_desc_index = params->dpu_desc_index;
+   if (vif_priv->sta) {
+   vif_priv->sta->bss_sta_index =  params->bss_sta_index;
+   vif_priv->sta->bss_dpu_desc_index = params->dpu_desc_index;
}
 
-   priv_vif->self_ucast_dpu_sign = params->ucast_dpu_signature;
+   vif_priv->self_ucast_dpu_sign = params->ucast_dpu_signature;
 
return 0;
 }
@@ -1343,13 +1343,13 @@ out:
 int wcn36xx_smd_delete_bss(struct wcn36xx *wcn, struct ieee80211_vif *vif)
 {
struct wcn36xx_hal_delete_bss_req_msg msg_body;
-   struct wcn36xx_vif *priv_vif = wcn36xx_vif_to_priv(vif);
+   struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
int ret = 0;
 
mutex_lock(>hal_mutex);
INIT_HAL_MSG(msg_body, WCN36XX_HAL_DELETE_BSS_REQ);
 
-   msg_body.bss_index = priv_vif->bss_index;
+   msg_body.bss_index = vif_priv->bss_index;
 
PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/16] wcn36xx: Use define for invalid index and fix typo

2016-03-29 Thread Bjorn Andersson
From: Pontus Fuchs 

Signed-off-by: Pontus Fuchs 
Signed-off-by: Bjorn Andersson 
---
 drivers/net/wireless/ath/wcn36xx/hal.h  | 2 +-
 drivers/net/wireless/ath/wcn36xx/main.c | 4 ++--
 drivers/net/wireless/ath/wcn36xx/smd.c  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h 
b/drivers/net/wireless/ath/wcn36xx/hal.h
index 6f99b6134e4e..67e778f9d29d 100644
--- a/drivers/net/wireless/ath/wcn36xx/hal.h
+++ b/drivers/net/wireless/ath/wcn36xx/hal.h
@@ -48,7 +48,7 @@
 
 #define WCN36XX_HAL_IPV4_ADDR_LEN   4
 
-#define WALN_HAL_STA_INVALID_IDX 0xFF
+#define WCN36XX_HAL_STA_INVALID_IDX 0xFF
 #define WCN36XX_HAL_BSS_INVALID_IDX 0xFF
 
 /* Default Beacon template size. */
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c 
b/drivers/net/wireless/ath/wcn36xx/main.c
index 62cb9ffd854c..4781b5e8deb3 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -618,7 +618,7 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw 
*hw,
 
if (!is_zero_ether_addr(bss_conf->bssid)) {
vif_priv->is_joining = true;
-   vif_priv->bss_index = 0xff;
+   vif_priv->bss_index = WCN36XX_HAL_BSS_INVALID_IDX;
wcn36xx_smd_join(wcn, bss_conf->bssid,
 vif->addr, WCN36XX_HW_CHANNEL(wcn));
wcn36xx_smd_config_bss(wcn, vif, NULL,
@@ -711,7 +711,7 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw 
*hw,
 
if (bss_conf->enable_beacon) {
vif_priv->dtim_period = bss_conf->dtim_period;
-   vif_priv->bss_index = 0xff;
+   vif_priv->bss_index = WCN36XX_HAL_BSS_INVALID_IDX;
wcn36xx_smd_config_bss(wcn, vif, NULL,
   vif->addr, false);
skb = ieee80211_beacon_get_tim(hw, vif, _off,
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c 
b/drivers/net/wireless/ath/wcn36xx/smd.c
index 6baf54db6241..ca325323c802 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -197,7 +197,7 @@ static void wcn36xx_smd_set_sta_params(struct wcn36xx *wcn,
vif->type == NL80211_IFTYPE_AP ||
vif->type == NL80211_IFTYPE_MESH_POINT) {
sta_params->type = 1;
-   sta_params->sta_index = 0xFF;
+   sta_params->sta_index = WCN36XX_HAL_STA_INVALID_IDX;
} else {
sta_params->type = 0;
sta_params->sta_index = 1;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/16] wcn36xx: Clean up wcn36xx_smd_send_beacon

2016-03-29 Thread Bjorn Andersson
From: Pontus Fuchs 

Needed for coming improvements. No functional changes.

Signed-off-by: Pontus Fuchs 
Signed-off-by: Bjorn Andersson 
---
 drivers/net/wireless/ath/wcn36xx/hal.h |  7 +--
 drivers/net/wireless/ath/wcn36xx/smd.c | 12 +---
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h 
b/drivers/net/wireless/ath/wcn36xx/hal.h
index b947de0fb2e5..4fd77ccc2287 100644
--- a/drivers/net/wireless/ath/wcn36xx/hal.h
+++ b/drivers/net/wireless/ath/wcn36xx/hal.h
@@ -51,8 +51,8 @@
 #define WALN_HAL_STA_INVALID_IDX 0xFF
 #define WCN36XX_HAL_BSS_INVALID_IDX 0xFF
 
-/* Default Beacon template size */
-#define BEACON_TEMPLATE_SIZE 0x180
+/* Default Beacon template size. */
+#define BEACON_TEMPLATE_SIZE 0x17C
 
 /* Param Change Bitmap sent to HAL */
 #define PARAM_BCN_INTERVAL_CHANGED  (1 << 0)
@@ -2884,6 +2884,9 @@ struct update_beacon_rsp_msg {
 struct wcn36xx_hal_send_beacon_req_msg {
struct wcn36xx_hal_msg_header header;
 
+   /* length of the template + 6. Only qcom knows why */
+   u32 beacon_length6;
+
/* length of the template. */
u32 beacon_length;
 
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c 
b/drivers/net/wireless/ath/wcn36xx/smd.c
index 74f56a81ad9a..ff3ed2461a69 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -1380,19 +1380,17 @@ int wcn36xx_smd_send_beacon(struct wcn36xx *wcn, struct 
ieee80211_vif *vif,
mutex_lock(>hal_mutex);
INIT_HAL_MSG(msg_body, WCN36XX_HAL_SEND_BEACON_REQ);
 
-   /* TODO need to find out why this is needed? */
-   msg_body.beacon_length = skb_beacon->len + 6;
+   msg_body.beacon_length = skb_beacon->len;
+   /* TODO need to find out why + 6 is needed */
+   msg_body.beacon_length6 = msg_body.beacon_length + 6;
 
-   if (BEACON_TEMPLATE_SIZE > msg_body.beacon_length) {
-   memcpy(_body.beacon, _beacon->len, sizeof(u32));
-   memcpy(&(msg_body.beacon[4]), skb_beacon->data,
-  skb_beacon->len);
-   } else {
+   if (msg_body.beacon_length > BEACON_TEMPLATE_SIZE) {
wcn36xx_err("Beacon is to big: beacon size=%d\n",
  msg_body.beacon_length);
ret = -ENOMEM;
goto out;
}
+   memcpy(msg_body.beacon, skb_beacon->data, skb_beacon->len);
memcpy(msg_body.bssid, vif->addr, ETH_ALEN);
 
/* TODO need to find out why this is needed? */
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/16] Misc wcn36xx fixes

2016-03-29 Thread Bjorn Andersson
As I was debugging some issues with the wcn36xx driver I found a series of
patches that exists in Eugene's github tree but not in mainline.

Noteworthy is the long requested feature of having working ARP support.

Please apply these rebased and relocated patches.

Jason Mobarak (1):
  wcn36xx: don't pad beacons for mesh

Pontus Fuchs (15):
  wcn36xx: Clean up wcn36xx_smd_send_beacon
  wcn36xx: Pad TIM PVM if needed
  wcn36xx: Add helper macros to cast vif to private vif and vice versa
  wcn36xx: Use consistent name for private vif
  wcn36xx: Use define for invalid index and fix typo
  wcn36xx: Fetch private sta data from sta entry instead of from vif
  wcn36xx: Add helper macros to cast sta to priv
  wcn36xx: Remove sta pointer in private vif struct
  wcn36xx: Parse trigger_ba response properly
  wcn36xx: Copy all members in config_sta v1 conversion
  wcn36xx: Use allocated self sta index instead of hard coded
  wcn36xx: Clear encrypt_type when deleting bss key
  wcn36xx: Track association state
  wcn36xx: Implement multicast filtering
  wcn36xx: Use correct command struct for EXIT_BMPS_REQ

 drivers/net/wireless/ath/wcn36xx/debug.c   |  12 +-
 drivers/net/wireless/ath/wcn36xx/hal.h |  18 ++-
 drivers/net/wireless/ath/wcn36xx/main.c|  91 +
 drivers/net/wireless/ath/wcn36xx/pmc.c |   4 +-
 drivers/net/wireless/ath/wcn36xx/smd.c | 205 +
 drivers/net/wireless/ath/wcn36xx/smd.h |   3 +
 drivers/net/wireless/ath/wcn36xx/txrx.c|   8 +-
 drivers/net/wireless/ath/wcn36xx/wcn36xx.h |  20 ++-
 8 files changed, 257 insertions(+), 104 deletions(-)

-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/16] wcn36xx: Use allocated self sta index instead of hard coded

2016-03-29 Thread Bjorn Andersson
From: Pontus Fuchs 

Signed-off-by: Pontus Fuchs 
Signed-off-by: Bjorn Andersson 
---
 drivers/net/wireless/ath/wcn36xx/smd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c 
b/drivers/net/wireless/ath/wcn36xx/smd.c
index ce764cce1a3e..8b304b305e69 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -200,7 +200,7 @@ static void wcn36xx_smd_set_sta_params(struct wcn36xx *wcn,
sta_params->sta_index = WCN36XX_HAL_STA_INVALID_IDX;
} else {
sta_params->type = 0;
-   sta_params->sta_index = 1;
+   sta_params->sta_index = vif_priv->self_sta_index;
}
 
sta_params->listen_interval = WCN36XX_LISTEN_INTERVAL(wcn);
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/16] wcn36xx: Remove sta pointer in private vif struct

2016-03-29 Thread Bjorn Andersson
From: Pontus Fuchs 

This does not work with multiple sta's in a vif.

Signed-off-by: Pontus Fuchs 
Signed-off-by: Bjorn Andersson 
---
 drivers/net/wireless/ath/wcn36xx/main.c|  3 ---
 drivers/net/wireless/ath/wcn36xx/smd.c | 28 +++-
 drivers/net/wireless/ath/wcn36xx/wcn36xx.h |  1 -
 3 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/main.c 
b/drivers/net/wireless/ath/wcn36xx/main.c
index a23738deb5b3..7c06ca9fdd2c 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -796,7 +796,6 @@ static int wcn36xx_sta_add(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif,
vif, sta->addr);
 
spin_lock_init(_priv->ampdu_lock);
-   vif_priv->sta = sta_priv;
sta_priv->vif = vif_priv;
/*
 * For STA mode HW will be configured on BSS_CHANGED_ASSOC because
@@ -815,14 +814,12 @@ static int wcn36xx_sta_remove(struct ieee80211_hw *hw,
  struct ieee80211_sta *sta)
 {
struct wcn36xx *wcn = hw->priv;
-   struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
 
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac sta remove vif %p sta %pM index %d\n",
vif, sta->addr, sta_priv->sta_index);
 
wcn36xx_smd_delete_sta(wcn, sta_priv->sta_index);
-   vif_priv->sta = NULL;
sta_priv->vif = NULL;
return 0;
 }
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c 
b/drivers/net/wireless/ath/wcn36xx/smd.c
index b75e7211049d..887781dff110 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -1170,6 +1170,7 @@ static int wcn36xx_smd_config_bss_v1(struct wcn36xx *wcn,
 
 static int wcn36xx_smd_config_bss_rsp(struct wcn36xx *wcn,
  struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta,
  void *buf,
  size_t len)
 {
@@ -1200,9 +1201,10 @@ static int wcn36xx_smd_config_bss_rsp(struct wcn36xx 
*wcn,
 
vif_priv->bss_index = params->bss_index;
 
-   if (vif_priv->sta) {
-   vif_priv->sta->bss_sta_index =  params->bss_sta_index;
-   vif_priv->sta->bss_dpu_desc_index = params->dpu_desc_index;
+   if (sta) {
+   struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
+   sta_priv->bss_sta_index = params->bss_sta_index;
+   sta_priv->bss_dpu_desc_index = params->dpu_desc_index;
}
 
vif_priv->self_ucast_dpu_sign = params->ucast_dpu_signature;
@@ -1329,6 +1331,7 @@ int wcn36xx_smd_config_bss(struct wcn36xx *wcn, struct 
ieee80211_vif *vif,
}
ret = wcn36xx_smd_config_bss_rsp(wcn,
 vif,
+sta,
 wcn->hal_buf,
 wcn->hal_rsp_len);
if (ret) {
@@ -2053,25 +2056,24 @@ static int wcn36xx_smd_delete_sta_context_ind(struct 
wcn36xx *wcn,
 {
struct wcn36xx_hal_delete_sta_context_ind_msg *rsp = buf;
struct wcn36xx_vif *tmp;
-   struct ieee80211_sta *sta = NULL;
+   struct ieee80211_sta *sta;
 
if (len != sizeof(*rsp)) {
wcn36xx_warn("Corrupted delete sta indication\n");
return -EIO;
}
 
+   wcn36xx_dbg(WCN36XX_DBG_HAL, "delete station indication %pM index %d\n",
+   rsp->addr2, rsp->sta_id);
+
list_for_each_entry(tmp, >vif_list, list) {
-   if (sta && (tmp->sta->sta_index == rsp->sta_id)) {
-   sta = container_of((void *)tmp->sta,
-struct ieee80211_sta,
-drv_priv);
-   wcn36xx_dbg(WCN36XX_DBG_HAL,
-   "delete station indication %pM index %d\n",
-   rsp->addr2,
-   rsp->sta_id);
+   rcu_read_lock();
+   sta = ieee80211_find_sta(wcn36xx_priv_to_vif(tmp), rsp->addr2);
+   if (sta)
ieee80211_report_low_ack(sta, 0);
+   rcu_read_unlock();
+   if (sta)
return 0;
-   }
}
 
wcn36xx_warn("STA with addr %pM and index %d not found\n",
diff --git a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h 
b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
index c368a34c8de7..54000db0af1a 100644
--- a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
+++ b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
@@ -125,7 +125,6 @@ struct wcn36xx_platform_ctrl_ops {
  */
 struct wcn36xx_vif {

[PATCH 09/16] wcn36xx: Parse trigger_ba response properly

2016-03-29 Thread Bjorn Andersson
From: Pontus Fuchs 

This message does not follow the canonical format and needs it's own
parser.

Signed-off-by: Pontus Fuchs 
Signed-off-by: Bjorn Andersson 
---
 drivers/net/wireless/ath/wcn36xx/smd.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c 
b/drivers/net/wireless/ath/wcn36xx/smd.c
index 887781dff110..2b416ee9f105 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -1963,6 +1963,17 @@ out:
return ret;
 }
 
+static int wcn36xx_smd_trigger_ba_rsp(void *buf, int len)
+{
+   struct wcn36xx_hal_trigger_ba_rsp_msg *rsp;
+
+   if (len < sizeof(*rsp))
+   return -EINVAL;
+
+   rsp = (struct wcn36xx_hal_trigger_ba_rsp_msg *) buf;
+   return rsp->status;
+}
+
 int wcn36xx_smd_trigger_ba(struct wcn36xx *wcn, u8 sta_index)
 {
struct wcn36xx_hal_trigger_ba_req_msg msg_body;
@@ -1987,8 +1998,7 @@ int wcn36xx_smd_trigger_ba(struct wcn36xx *wcn, u8 
sta_index)
wcn36xx_err("Sending hal_trigger_ba failed\n");
goto out;
}
-   ret = wcn36xx_smd_rsp_status_check_v2(wcn, wcn->hal_buf,
-   wcn->hal_rsp_len);
+   ret = wcn36xx_smd_trigger_ba_rsp(wcn->hal_buf, wcn->hal_rsp_len);
if (ret) {
wcn36xx_err("hal_trigger_ba response failed err=%d\n", ret);
goto out;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/16] wcn36xx: Clear encrypt_type when deleting bss key

2016-03-29 Thread Bjorn Andersson
From: Pontus Fuchs 

This fixes a problem connecting to an open network after being
connected to an encrypted network.

Signed-off-by: Pontus Fuchs 
Signed-off-by: Bjorn Andersson 
---
 drivers/net/wireless/ath/wcn36xx/main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/ath/wcn36xx/main.c 
b/drivers/net/wireless/ath/wcn36xx/main.c
index 7c06ca9fdd2c..f9c77de94583 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -471,6 +471,7 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum 
set_key_cmd cmd,
break;
case DISABLE_KEY:
if (!(IEEE80211_KEY_FLAG_PAIRWISE & key_conf->flags)) {
+   vif_priv->encrypt_type = WCN36XX_HAL_ED_NONE;
wcn36xx_smd_remove_bsskey(wcn,
vif_priv->encrypt_type,
key_conf->keyidx);
@@ -626,6 +627,7 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw 
*hw,
} else {
vif_priv->is_joining = false;
wcn36xx_smd_delete_bss(wcn, vif);
+   vif_priv->encrypt_type = WCN36XX_HAL_ED_NONE;
}
}
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/16] wcn36xx: Copy all members in config_sta v1 conversion

2016-03-29 Thread Bjorn Andersson
From: Pontus Fuchs 

When converting to version 1 of the config_sta struct not all
members where copied. This fixes the problem of multicast frames
not being delivered on an encrypted network.

Signed-off-by: Pontus Fuchs 
Signed-off-by: Bjorn Andersson 
---
 drivers/net/wireless/ath/wcn36xx/smd.c | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c 
b/drivers/net/wireless/ath/wcn36xx/smd.c
index 2b416ee9f105..ce764cce1a3e 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -949,17 +949,32 @@ static void wcn36xx_smd_convert_sta_to_v1(struct wcn36xx 
*wcn,
memcpy(>mac, orig->mac, ETH_ALEN);
v1->aid = orig->aid;
v1->type = orig->type;
+   v1->short_preamble_supported = orig->short_preamble_supported;
v1->listen_interval = orig->listen_interval;
+   v1->wmm_enabled = orig->wmm_enabled;
v1->ht_capable = orig->ht_capable;
-
+   v1->tx_channel_width_set = orig->tx_channel_width_set;
+   v1->rifs_mode = orig->rifs_mode;
+   v1->lsig_txop_protection = orig->lsig_txop_protection;
v1->max_ampdu_size = orig->max_ampdu_size;
v1->max_ampdu_density = orig->max_ampdu_density;
v1->sgi_40mhz = orig->sgi_40mhz;
v1->sgi_20Mhz = orig->sgi_20Mhz;
-
+   v1->rmf = orig->rmf;
+   v1->encrypt_type = orig->encrypt_type;
+   v1->action = orig->action;
+   v1->uapsd = orig->uapsd;
+   v1->max_sp_len = orig->max_sp_len;
+   v1->green_field_capable = orig->green_field_capable;
+   v1->mimo_ps = orig->mimo_ps;
+   v1->delayed_ba_support = orig->delayed_ba_support;
+   v1->max_ampdu_duration = orig->max_ampdu_duration;
+   v1->dsss_cck_mode_40mhz = orig->dsss_cck_mode_40mhz;
memcpy(>supported_rates, >supported_rates,
   sizeof(orig->supported_rates));
v1->sta_index = orig->sta_index;
+   v1->bssid_index = orig->bssid_index;
+   v1->p2p = orig->p2p;
 }
 
 static int wcn36xx_smd_config_sta_rsp(struct wcn36xx *wcn,
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/16] wcn36xx: Implement multicast filtering

2016-03-29 Thread Bjorn Andersson
From: Pontus Fuchs 

Pass the multicast list to FW.

This patch also adds a way to build the smd command in place. This is
needed because the MC list command is too big for the stack.

Signed-off-by: Pontus Fuchs 
[bjorn: dropped FIF_PROMISC_IN_BSS usage]
Signed-off-by: Bjorn Andersson 

Signed-off-by: Bjorn Andersson 
---
 drivers/net/wireless/ath/wcn36xx/hal.h  |  6 ++--
 drivers/net/wireless/ath/wcn36xx/main.c | 50 ++--
 drivers/net/wireless/ath/wcn36xx/smd.c  | 51 +
 drivers/net/wireless/ath/wcn36xx/smd.h  |  3 ++
 4 files changed, 104 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h 
b/drivers/net/wireless/ath/wcn36xx/hal.h
index 67e778f9d29d..6a4816352973 100644
--- a/drivers/net/wireless/ath/wcn36xx/hal.h
+++ b/drivers/net/wireless/ath/wcn36xx/hal.h
@@ -4267,9 +4267,9 @@ struct wcn36xx_hal_rcv_flt_mc_addr_list_type {
u8 data_offset;
 
u32 mc_addr_count;
-   u8 mc_addr[ETH_ALEN][WCN36XX_HAL_MAX_NUM_MULTICAST_ADDRESS];
+   u8 mc_addr[WCN36XX_HAL_MAX_NUM_MULTICAST_ADDRESS][ETH_ALEN];
u8 bss_index;
-};
+} __packed;
 
 struct wcn36xx_hal_set_pkt_filter_rsp_msg {
struct wcn36xx_hal_msg_header header;
@@ -4323,7 +4323,7 @@ struct wcn36xx_hal_rcv_flt_pkt_clear_rsp_msg {
 struct wcn36xx_hal_rcv_flt_pkt_set_mc_list_req_msg {
struct wcn36xx_hal_msg_header header;
struct wcn36xx_hal_rcv_flt_mc_addr_list_type mc_addr_list;
-};
+} __packed;
 
 struct wcn36xx_hal_rcv_flt_pkt_set_mc_list_rsp_msg {
struct wcn36xx_hal_msg_header header;
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c 
b/drivers/net/wireless/ath/wcn36xx/main.c
index 253cece1b660..c0ba7b0775b3 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -287,6 +287,7 @@ static int wcn36xx_start(struct ieee80211_hw *hw)
}
 
wcn36xx_detect_chip_version(wcn);
+   wcn36xx_smd_update_cfg(wcn, WCN36XX_HAL_CFG_ENABLE_MC_ADDR_LIST, 1);
 
/* DMA channel initialization */
ret = wcn36xx_dxe_init(wcn);
@@ -354,15 +355,57 @@ static int wcn36xx_config(struct ieee80211_hw *hw, u32 
changed)
return 0;
 }
 
-#define WCN36XX_SUPPORTED_FILTERS (0)
-
 static void wcn36xx_configure_filter(struct ieee80211_hw *hw,
 unsigned int changed,
 unsigned int *total, u64 multicast)
 {
+   struct wcn36xx_hal_rcv_flt_mc_addr_list_type *fp;
+   struct wcn36xx *wcn = hw->priv;
+   struct wcn36xx_vif *tmp;
+   struct ieee80211_vif *vif = NULL;
+
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac configure filter\n");
 
-   *total &= WCN36XX_SUPPORTED_FILTERS;
+   *total &= FIF_ALLMULTI;
+
+   fp = (void *)(unsigned long)multicast;
+   list_for_each_entry(tmp, >vif_list, list) {
+   vif = wcn36xx_priv_to_vif(tmp);
+
+   /* FW handles MC filtering only when connected as STA */
+   if (*total & FIF_ALLMULTI)
+   wcn36xx_smd_set_mc_list(wcn, vif, NULL);
+   else if (NL80211_IFTYPE_STATION == vif->type && tmp->sta_assoc)
+   wcn36xx_smd_set_mc_list(wcn, vif, fp);
+   }
+   kfree(fp);
+}
+
+static u64 wcn36xx_prepare_multicast(struct ieee80211_hw *hw,
+struct netdev_hw_addr_list *mc_list)
+{
+   struct wcn36xx_hal_rcv_flt_mc_addr_list_type *fp;
+   struct netdev_hw_addr *ha;
+
+   wcn36xx_dbg(WCN36XX_DBG_MAC, "mac prepare multicast list\n");
+   fp = kzalloc(sizeof(*fp), GFP_ATOMIC);
+   if (!fp) {
+   wcn36xx_err("Out of memory setting filters.\n");
+   return 0;
+   }
+
+   fp->mc_addr_count = 0;
+   /* update multicast filtering parameters */
+   if (netdev_hw_addr_list_count(mc_list) <=
+   WCN36XX_HAL_MAX_NUM_MULTICAST_ADDRESS) {
+   netdev_hw_addr_list_for_each(ha, mc_list) {
+   memcpy(fp->mc_addr[fp->mc_addr_count],
+   ha->addr, ETH_ALEN);
+   fp->mc_addr_count++;
+   }
+   }
+
+   return (u64)(unsigned long)fp;
 }
 
 static void wcn36xx_tx(struct ieee80211_hw *hw,
@@ -920,6 +963,7 @@ static const struct ieee80211_ops wcn36xx_ops = {
.resume = wcn36xx_resume,
 #endif
.config = wcn36xx_config,
+   .prepare_multicast  = wcn36xx_prepare_multicast,
.configure_filter   = wcn36xx_configure_filter,
.tx = wcn36xx_tx,
.set_key= wcn36xx_set_key,
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c 
b/drivers/net/wireless/ath/wcn36xx/smd.c
index 8b304b305e69..a57d158298a1 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ 

[PATCH 06/16] wcn36xx: Fetch private sta data from sta entry instead of from vif

2016-03-29 Thread Bjorn Andersson
From: Pontus Fuchs 

For consistency with other code.

Signed-off-by: Pontus Fuchs 
Signed-off-by: Bjorn Andersson 
---
 drivers/net/wireless/ath/wcn36xx/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/main.c 
b/drivers/net/wireless/ath/wcn36xx/main.c
index 4781b5e8deb3..62178a03f50d 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -386,7 +386,7 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum 
set_key_cmd cmd,
 {
struct wcn36xx *wcn = hw->priv;
struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
-   struct wcn36xx_sta *sta_priv = vif_priv->sta;
+   struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
int ret = 0;
u8 key[WLAN_MAX_KEY_LEN];
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/16] wcn36xx: Use correct command struct for EXIT_BMPS_REQ

2016-03-29 Thread Bjorn Andersson
From: Pontus Fuchs 

EXIT_BMPS_REQ was using the command struct for ENTER_BMPS_REQ. I
spotted this when looking at command dumps.

Signed-off-by: Pontus Fuchs 
Signed-off-by: Bjorn Andersson 
---
 drivers/net/wireless/ath/wcn36xx/smd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c 
b/drivers/net/wireless/ath/wcn36xx/smd.c
index b1bdc229e560..c15501c06eb2 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -1690,7 +1690,7 @@ out:
 
 int wcn36xx_smd_exit_bmps(struct wcn36xx *wcn, struct ieee80211_vif *vif)
 {
-   struct wcn36xx_hal_enter_bmps_req_msg msg_body;
+   struct wcn36xx_hal_exit_bmps_req_msg msg_body;
struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
int ret = 0;
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/16] wcn36xx: don't pad beacons for mesh

2016-03-29 Thread Bjorn Andersson
From: Jason Mobarak 

Patch "wcn36xx: Pad TIM PVM if needed" has caused a regression in mesh
beaconing.  The field tim_off is always 0 for mesh mode, and thus
pvm_len (referring to the TIM length field) and pad are both incorrectly
calculated.  Thus, msg_body.beacon_length is incorrectly calculated for
mesh mode. Fix this.

Signed-off-by: Jason Mobarak 
Signed-off-by: Chun-Yeow Yeoh 
Signed-off-by: Bjorn Andersson 
---
 drivers/net/wireless/ath/wcn36xx/smd.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c 
b/drivers/net/wireless/ath/wcn36xx/smd.c
index a57d158298a1..b1bdc229e560 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -1410,6 +1410,11 @@ int wcn36xx_smd_send_beacon(struct wcn36xx *wcn, struct 
ieee80211_vif *vif,
 
pvm_len = skb_beacon->data[tim_off + 1] - 3;
pad = TIM_MIN_PVM_SIZE - pvm_len;
+
+   /* Padding is irrelevant to mesh mode since tim_off is always 0. */
+   if (vif->type == NL80211_IFTYPE_MESH_POINT)
+   pad = 0;
+
msg_body.beacon_length = skb_beacon->len + pad;
/* TODO need to find out why + 6 is needed */
msg_body.beacon_length6 = msg_body.beacon_length + 6;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/16] wcn36xx: Track association state

2016-03-29 Thread Bjorn Andersson
From: Pontus Fuchs 

Knowing the association state is needed for mc filtering.

Signed-off-by: Pontus Fuchs 
Signed-off-by: Bjorn Andersson 
---
 drivers/net/wireless/ath/wcn36xx/main.c| 2 ++
 drivers/net/wireless/ath/wcn36xx/wcn36xx.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/net/wireless/ath/wcn36xx/main.c 
b/drivers/net/wireless/ath/wcn36xx/main.c
index f9c77de94583..253cece1b660 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -655,6 +655,7 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw 
*hw,
 vif->addr,
 bss_conf->aid);
 
+   vif_priv->sta_assoc = true;
rcu_read_lock();
sta = ieee80211_find_sta(vif, bss_conf->bssid);
if (!sta) {
@@ -686,6 +687,7 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw 
*hw,
bss_conf->bssid,
vif->addr,
bss_conf->aid);
+   vif_priv->sta_assoc = false;
wcn36xx_smd_set_link_st(wcn,
bss_conf->bssid,
vif->addr,
diff --git a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h 
b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
index 54000db0af1a..7433d67a5929 100644
--- a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
+++ b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
@@ -128,6 +128,7 @@ struct wcn36xx_vif {
u8 dtim_period;
enum ani_ed_type encrypt_type;
bool is_joining;
+   bool sta_assoc;
struct wcn36xx_hal_mac_ssid ssid;
 
/* Power management */
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/16] wcn36xx: Pad TIM PVM if needed

2016-03-29 Thread Bjorn Andersson
From: Pontus Fuchs 

The wcn36xx FW expects a fixed size TIM PVM in the beacon template. If
supplied with a shorter than expected PVM it will overwrite the IE
following the TIM.

Signed-off-by: Pontus Fuchs 
Signed-off-by: Bjorn Andersson 
---
 drivers/net/wireless/ath/wcn36xx/hal.h |  3 +++
 drivers/net/wireless/ath/wcn36xx/smd.c | 22 --
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h 
b/drivers/net/wireless/ath/wcn36xx/hal.h
index 4fd77ccc2287..6f99b6134e4e 100644
--- a/drivers/net/wireless/ath/wcn36xx/hal.h
+++ b/drivers/net/wireless/ath/wcn36xx/hal.h
@@ -54,6 +54,9 @@
 /* Default Beacon template size. */
 #define BEACON_TEMPLATE_SIZE 0x17C
 
+/* Minimum PVM size that the FW expects. See comment in smd.c for details. */
+#define TIM_MIN_PVM_SIZE 6
+
 /* Param Change Bitmap sent to HAL */
 #define PARAM_BCN_INTERVAL_CHANGED  (1 << 0)
 #define PARAM_SHORT_PREAMBLE_CHANGED (1 << 1)
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c 
b/drivers/net/wireless/ath/wcn36xx/smd.c
index ff3ed2461a69..0aa3ae62494e 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -1375,12 +1375,14 @@ int wcn36xx_smd_send_beacon(struct wcn36xx *wcn, struct 
ieee80211_vif *vif,
u16 p2p_off)
 {
struct wcn36xx_hal_send_beacon_req_msg msg_body;
-   int ret = 0;
+   int ret = 0, pad, pvm_len;
 
mutex_lock(>hal_mutex);
INIT_HAL_MSG(msg_body, WCN36XX_HAL_SEND_BEACON_REQ);
 
-   msg_body.beacon_length = skb_beacon->len;
+   pvm_len = skb_beacon->data[tim_off + 1] - 3;
+   pad = TIM_MIN_PVM_SIZE - pvm_len;
+   msg_body.beacon_length = skb_beacon->len + pad;
/* TODO need to find out why + 6 is needed */
msg_body.beacon_length6 = msg_body.beacon_length + 6;
 
@@ -1393,6 +1395,22 @@ int wcn36xx_smd_send_beacon(struct wcn36xx *wcn, struct 
ieee80211_vif *vif,
memcpy(msg_body.beacon, skb_beacon->data, skb_beacon->len);
memcpy(msg_body.bssid, vif->addr, ETH_ALEN);
 
+   if (pad > 0) {
+   /*
+* The wcn36xx FW has a fixed size for the PVM in the TIM. If
+* given the beacon template from mac80211 with a PVM shorter
+* than the FW expectes it will overwrite the data after the
+* TIM.
+*/
+   wcn36xx_dbg(WCN36XX_DBG_HAL, "Pad TIM PVM. %d bytes at %d\n",
+   pad, pvm_len);
+   memmove(_body.beacon[tim_off + 5 + pvm_len + pad],
+   _body.beacon[tim_off + 5 + pvm_len],
+   skb_beacon->len - (tim_off + 5 + pvm_len));
+   memset(_body.beacon[tim_off + 5 + pvm_len], 0, pad);
+   msg_body.beacon[tim_off + 1] += pad;
+   }
+
/* TODO need to find out why this is needed? */
if (vif->type == NL80211_IFTYPE_MESH_POINT)
/* mesh beacon don't need this, so push further down */
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/16] wcn36xx: Add helper macros to cast sta to priv

2016-03-29 Thread Bjorn Andersson
From: Pontus Fuchs 

While poking at this I also change two related things. I rename one
variable to make the names consistent. I also move one assignment of
priv_sta to the declaration to save a few lines.

Signed-off-by: Pontus Fuchs 
Signed-off-by: Bjorn Andersson 
---
 drivers/net/wireless/ath/wcn36xx/main.c| 14 ++
 drivers/net/wireless/ath/wcn36xx/smd.c | 12 ++--
 drivers/net/wireless/ath/wcn36xx/wcn36xx.h |  6 ++
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/main.c 
b/drivers/net/wireless/ath/wcn36xx/main.c
index 62178a03f50d..a23738deb5b3 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -373,7 +373,7 @@ static void wcn36xx_tx(struct ieee80211_hw *hw,
struct wcn36xx_sta *sta_priv = NULL;
 
if (control->sta)
-   sta_priv = (struct wcn36xx_sta *)control->sta->drv_priv;
+   sta_priv = wcn36xx_sta_to_priv(control->sta);
 
if (wcn36xx_start_tx(wcn, sta_priv, skb))
ieee80211_free_txskb(wcn->hw, skb);
@@ -518,7 +518,7 @@ static void wcn36xx_update_allowed_rates(struct 
ieee80211_sta *sta,
 {
int i, size;
u16 *rates_table;
-   struct wcn36xx_sta *sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
+   struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
u32 rates = sta->supp_rates[band];
 
memset(_priv->supported_rates, 0,
@@ -661,7 +661,7 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw 
*hw,
rcu_read_unlock();
goto out;
}
-   sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
+   sta_priv = wcn36xx_sta_to_priv(sta);
 
wcn36xx_update_allowed_rates(sta, WCN36XX_BAND(wcn));
 
@@ -791,7 +791,7 @@ static int wcn36xx_sta_add(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif,
 {
struct wcn36xx *wcn = hw->priv;
struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
-   struct wcn36xx_sta *sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
+   struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac sta add vif %p sta %pM\n",
vif, sta->addr);
 
@@ -816,7 +816,7 @@ static int wcn36xx_sta_remove(struct ieee80211_hw *hw,
 {
struct wcn36xx *wcn = hw->priv;
struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
-   struct wcn36xx_sta *sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
+   struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
 
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac sta remove vif %p sta %pM index %d\n",
vif, sta->addr, sta_priv->sta_index);
@@ -858,7 +858,7 @@ static int wcn36xx_ampdu_action(struct ieee80211_hw *hw,
struct ieee80211_ampdu_params *params)
 {
struct wcn36xx *wcn = hw->priv;
-   struct wcn36xx_sta *sta_priv = NULL;
+   struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(params->sta);
struct ieee80211_sta *sta = params->sta;
enum ieee80211_ampdu_mlme_action action = params->action;
u16 tid = params->tid;
@@ -867,8 +867,6 @@ static int wcn36xx_ampdu_action(struct ieee80211_hw *hw,
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac ampdu action action %d tid %d\n",
action, tid);
 
-   sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
-
switch (action) {
case IEEE80211_AMPDU_RX_START:
sta_priv->tid = tid;
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c 
b/drivers/net/wireless/ath/wcn36xx/smd.c
index ca325323c802..b75e7211049d 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -192,7 +192,7 @@ static void wcn36xx_smd_set_sta_params(struct wcn36xx *wcn,
struct wcn36xx_hal_config_sta_params *sta_params)
 {
struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
-   struct wcn36xx_sta *priv_sta = NULL;
+   struct wcn36xx_sta *sta_priv = NULL;
if (vif->type == NL80211_IFTYPE_ADHOC ||
vif->type == NL80211_IFTYPE_AP ||
vif->type == NL80211_IFTYPE_MESH_POINT) {
@@ -228,17 +228,17 @@ static void wcn36xx_smd_set_sta_params(struct wcn36xx 
*wcn,
sta_params->p2p = 0;
 
if (sta) {
-   priv_sta = (struct wcn36xx_sta *)sta->drv_priv;
+   sta_priv = wcn36xx_sta_to_priv(sta);
if (NL80211_IFTYPE_STATION == vif->type)
memcpy(_params->bssid, sta->addr, ETH_ALEN);
else
memcpy(_params->mac, sta->addr, ETH_ALEN);
sta_params->wmm_enabled = sta->wme;
sta_params->max_sp_len = sta->max_sp;
-   sta_params->aid = priv_sta->aid;
+