Re: [PATCH v3 2/2] mmc: pwrseq: add support for Marvell SD8787 chip

2017-01-12 Thread Shawn Lin

On 2017/1/13 13:29, Matt Ranostay wrote:

Allow power sequencing for the Marvell SD8787 Wifi/BT chip.
This can be abstracted to other chipsets if needed in the future.

Cc: Tony Lindgren 
Cc: Ulf Hansson 
Signed-off-by: Matt Ranostay 
---
 drivers/mmc/core/Kconfig |  10 
 drivers/mmc/core/Makefile|   1 +
 drivers/mmc/core/pwrseq_sd8787.c | 117 +++
 3 files changed, 128 insertions(+)
 create mode 100644 drivers/mmc/core/pwrseq_sd8787.c

diff --git a/drivers/mmc/core/Kconfig b/drivers/mmc/core/Kconfig
index cdfa8520a4b1..fc1ecdaaa9ca 100644
--- a/drivers/mmc/core/Kconfig
+++ b/drivers/mmc/core/Kconfig
@@ -12,6 +12,16 @@ config PWRSEQ_EMMC
  This driver can also be built as a module. If so, the module
  will be called pwrseq_emmc.

+config PWRSEQ_SD8787
+   tristate "HW reset support for SD8787 BT + Wifi module"
+   depends on OF && (MWIFIEX || BT_MRVL_SDIO)
+   help
+ This selects hardware reset support for the SD8787 BT + Wifi
+ module. By default this option is set to n.
+
+ This driver can also be built as a module. If so, the module
+ will be called pwrseq_sd8787.
+


I don't like this way, as we have a chance to list lots
configure options here. wifi A,B,C,D...Z, all of them need a
new section here if needed?

Instead, could you just extent pwrseq_simple.c and add you
.compatible = "mmc-pwrseq-sd8787", "mmc-pwrseq-simple"?



 config PWRSEQ_SIMPLE
tristate "Simple HW reset support for MMC"
default y
diff --git a/drivers/mmc/core/Makefile b/drivers/mmc/core/Makefile
index b2a257dc644f..0f81464fa824 100644
--- a/drivers/mmc/core/Makefile
+++ b/drivers/mmc/core/Makefile
@@ -10,6 +10,7 @@ mmc_core-y:= core.o bus.o host.o \
   quirks.o slot-gpio.o
 mmc_core-$(CONFIG_OF)  += pwrseq.o
 obj-$(CONFIG_PWRSEQ_SIMPLE)+= pwrseq_simple.o
+obj-$(CONFIG_PWRSEQ_SD8787)+= pwrseq_sd8787.o
 obj-$(CONFIG_PWRSEQ_EMMC)  += pwrseq_emmc.o
 mmc_core-$(CONFIG_DEBUG_FS)+= debugfs.o
 obj-$(CONFIG_MMC_BLOCK)+= mmc_block.o
diff --git a/drivers/mmc/core/pwrseq_sd8787.c b/drivers/mmc/core/pwrseq_sd8787.c
new file mode 100644
index ..f4080fe6439e
--- /dev/null
+++ b/drivers/mmc/core/pwrseq_sd8787.c
@@ -0,0 +1,117 @@
+/*
+ * pwrseq_sd8787.c - power sequence support for Marvell SD8787 BT + Wifi chip
+ *
+ * Copyright (C) 2016 Matt Ranostay 
+ *
+ * Based on the original work pwrseq_simple.c
+ *  Copyright (C) 2014 Linaro Ltd
+ *  Author: Ulf Hansson 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "pwrseq.h"
+
+struct mmc_pwrseq_sd8787 {
+   struct mmc_pwrseq pwrseq;
+   struct gpio_desc *reset_gpio;
+   struct gpio_desc *pwrdn_gpio;
+};
+
+#define to_pwrseq_sd8787(p) container_of(p, struct mmc_pwrseq_sd8787, pwrseq)
+
+static void mmc_pwrseq_sd8787_pre_power_on(struct mmc_host *host)
+{
+   struct mmc_pwrseq_sd8787 *pwrseq = to_pwrseq_sd8787(host->pwrseq);
+
+   gpiod_set_value_cansleep(pwrseq->reset_gpio, 1);
+
+   msleep(300);
+   gpiod_set_value_cansleep(pwrseq->pwrdn_gpio, 1);
+}
+
+static void mmc_pwrseq_sd8787_power_off(struct mmc_host *host)
+{
+   struct mmc_pwrseq_sd8787 *pwrseq = to_pwrseq_sd8787(host->pwrseq);
+
+   gpiod_set_value_cansleep(pwrseq->pwrdn_gpio, 0);
+   gpiod_set_value_cansleep(pwrseq->reset_gpio, 0);
+}
+
+static const struct mmc_pwrseq_ops mmc_pwrseq_sd8787_ops = {
+   .pre_power_on = mmc_pwrseq_sd8787_pre_power_on,
+   .power_off = mmc_pwrseq_sd8787_power_off,
+};
+
+static const struct of_device_id mmc_pwrseq_sd8787_of_match[] = {
+   { .compatible = "mmc-pwrseq-sd8787",},
+   {/* sentinel */},
+};
+MODULE_DEVICE_TABLE(of, mmc_pwrseq_sd8787_of_match);
+
+static int mmc_pwrseq_sd8787_probe(struct platform_device *pdev)
+{
+   struct mmc_pwrseq_sd8787 *pwrseq;
+   struct device *dev = >dev;
+
+   pwrseq = devm_kzalloc(dev, sizeof(*pwrseq), GFP_KERNEL);
+   if (!pwrseq)
+   return -ENOMEM;
+
+   pwrseq->pwrdn_gpio = devm_gpiod_get(dev, "pwrdn", GPIOD_OUT_LOW);
+   if (IS_ERR(pwrseq->pwrdn_gpio))
+   return PTR_ERR(pwrseq->pwrdn_gpio);
+
+   pwrseq->reset_gpio = 

[PATCH v3 0/2] mmc: pwrseq: add support for Marvell SD8787 chip

2017-01-12 Thread Matt Ranostay
Changes from v1:
* split devictree docs from pwrseq changes
* rebase devicetree documents due to filename change
* rebase pwrseq patchset

Changes from v2:
* fix rookie mistake missing the main source file and docs

Matt Ranostay (2):
  devicetree: document new marvell-8xxx and pwrseq-sd8787 options
  mmc: pwrseq: add support for Marvell SD8787 chip

 .../devicetree/bindings/mmc/mmc-pwrseq-sd8787.txt  |  14 +++
 .../bindings/net/wireless/marvell-8xxx.txt |   7 +-
 drivers/mmc/core/Kconfig   |  10 ++
 drivers/mmc/core/Makefile  |   1 +
 drivers/mmc/core/pwrseq_sd8787.c   | 117 +
 5 files changed, 148 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/mmc/mmc-pwrseq-sd8787.txt
 create mode 100644 drivers/mmc/core/pwrseq_sd8787.c

-- 
2.10.2



[PATCH v3 1/2] devicetree: document new marvell-8xxx and pwrseq-sd8787 options

2017-01-12 Thread Matt Ranostay
Cc: devicet...@vger.kernel.org
Signed-off-by: Matt Ranostay 
---
 .../devicetree/bindings/mmc/mmc-pwrseq-sd8787.txt  | 14 ++
 .../devicetree/bindings/net/wireless/marvell-8xxx.txt  |  7 ++-
 2 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/mmc/mmc-pwrseq-sd8787.txt

diff --git a/Documentation/devicetree/bindings/mmc/mmc-pwrseq-sd8787.txt 
b/Documentation/devicetree/bindings/mmc/mmc-pwrseq-sd8787.txt
new file mode 100644
index ..1b658351629b
--- /dev/null
+++ b/Documentation/devicetree/bindings/mmc/mmc-pwrseq-sd8787.txt
@@ -0,0 +1,14 @@
+* Marvell SD8787 power sequence provider
+
+Required properties:
+- compatible: must be "mmc-pwrseq-sd8787".
+- pwndn-gpio: contains a power down GPIO specifier.
+- reset-gpio: contains a reset GPIO specifier.
+
+Example:
+
+   wifi_pwrseq: wifi_pwrseq {
+   compatible = "mmc-pwrseq-sd8787";
+   pwrdn-gpio = <_gpio 0 GPIO_ACTIVE_LOW>;
+   reset-gpio = <_gpio 1 GPIO_ACTIVE_LOW>;
+   }
diff --git a/Documentation/devicetree/bindings/net/wireless/marvell-8xxx.txt 
b/Documentation/devicetree/bindings/net/wireless/marvell-8xxx.txt
index 980b16df74c3..0854451ff91d 100644
--- a/Documentation/devicetree/bindings/net/wireless/marvell-8xxx.txt
+++ b/Documentation/devicetree/bindings/net/wireless/marvell-8xxx.txt
@@ -1,4 +1,4 @@
-Marvell 8897/8997 (sd8897/sd8997/pcie8997) SDIO/PCIE devices
+Marvell 8787/8897/8997 (sd8787/sd8897/sd8997/pcie8997) SDIO/PCIE devices
 --
 
 This node provides properties for controlling the Marvell SDIO/PCIE wireless 
device.
@@ -8,6 +8,7 @@ connects the device to the system.
 Required properties:
 
   - compatible : should be one of the following:
+   * "marvell,sd8787"
* "marvell,sd8897"
* "marvell,sd8997"
* "pci11ab,2b42"
@@ -34,6 +35,9 @@ Optional properties:
 so that the wifi chip can wakeup host platform under certain 
condition.
 during system resume, the irq will be disabled to make sure
 unnecessary interrupt is not received.
+  - vmmc-supply: a phandle of a regulator, supplying VCC to the card
+  - mmc-pwrseq:  phandle to the MMC power sequence node. See "mmc-pwrseq-*"
+for documentation of MMC power sequence bindings.
 
 Example:
 
@@ -46,6 +50,7 @@ so that firmware can wakeup host using this device side pin.
  {
status = "okay";
vmmc-supply = <_en_reg>;
+   mmc-pwrseq = <_pwrseq>;
bus-width = <4>;
cap-power-off-card;
keep-power-in-suspend;
-- 
2.10.2



[PATCH v3 2/2] mmc: pwrseq: add support for Marvell SD8787 chip

2017-01-12 Thread Matt Ranostay
Allow power sequencing for the Marvell SD8787 Wifi/BT chip.
This can be abstracted to other chipsets if needed in the future.

Cc: Tony Lindgren 
Cc: Ulf Hansson 
Signed-off-by: Matt Ranostay 
---
 drivers/mmc/core/Kconfig |  10 
 drivers/mmc/core/Makefile|   1 +
 drivers/mmc/core/pwrseq_sd8787.c | 117 +++
 3 files changed, 128 insertions(+)
 create mode 100644 drivers/mmc/core/pwrseq_sd8787.c

diff --git a/drivers/mmc/core/Kconfig b/drivers/mmc/core/Kconfig
index cdfa8520a4b1..fc1ecdaaa9ca 100644
--- a/drivers/mmc/core/Kconfig
+++ b/drivers/mmc/core/Kconfig
@@ -12,6 +12,16 @@ config PWRSEQ_EMMC
  This driver can also be built as a module. If so, the module
  will be called pwrseq_emmc.
 
+config PWRSEQ_SD8787
+   tristate "HW reset support for SD8787 BT + Wifi module"
+   depends on OF && (MWIFIEX || BT_MRVL_SDIO)
+   help
+ This selects hardware reset support for the SD8787 BT + Wifi
+ module. By default this option is set to n.
+
+ This driver can also be built as a module. If so, the module
+ will be called pwrseq_sd8787.
+
 config PWRSEQ_SIMPLE
tristate "Simple HW reset support for MMC"
default y
diff --git a/drivers/mmc/core/Makefile b/drivers/mmc/core/Makefile
index b2a257dc644f..0f81464fa824 100644
--- a/drivers/mmc/core/Makefile
+++ b/drivers/mmc/core/Makefile
@@ -10,6 +10,7 @@ mmc_core-y:= core.o bus.o host.o \
   quirks.o slot-gpio.o
 mmc_core-$(CONFIG_OF)  += pwrseq.o
 obj-$(CONFIG_PWRSEQ_SIMPLE)+= pwrseq_simple.o
+obj-$(CONFIG_PWRSEQ_SD8787)+= pwrseq_sd8787.o
 obj-$(CONFIG_PWRSEQ_EMMC)  += pwrseq_emmc.o
 mmc_core-$(CONFIG_DEBUG_FS)+= debugfs.o
 obj-$(CONFIG_MMC_BLOCK)+= mmc_block.o
diff --git a/drivers/mmc/core/pwrseq_sd8787.c b/drivers/mmc/core/pwrseq_sd8787.c
new file mode 100644
index ..f4080fe6439e
--- /dev/null
+++ b/drivers/mmc/core/pwrseq_sd8787.c
@@ -0,0 +1,117 @@
+/*
+ * pwrseq_sd8787.c - power sequence support for Marvell SD8787 BT + Wifi chip
+ *
+ * Copyright (C) 2016 Matt Ranostay 
+ *
+ * Based on the original work pwrseq_simple.c
+ *  Copyright (C) 2014 Linaro Ltd
+ *  Author: Ulf Hansson 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "pwrseq.h"
+
+struct mmc_pwrseq_sd8787 {
+   struct mmc_pwrseq pwrseq;
+   struct gpio_desc *reset_gpio;
+   struct gpio_desc *pwrdn_gpio;
+};
+
+#define to_pwrseq_sd8787(p) container_of(p, struct mmc_pwrseq_sd8787, pwrseq)
+
+static void mmc_pwrseq_sd8787_pre_power_on(struct mmc_host *host)
+{
+   struct mmc_pwrseq_sd8787 *pwrseq = to_pwrseq_sd8787(host->pwrseq);
+
+   gpiod_set_value_cansleep(pwrseq->reset_gpio, 1);
+
+   msleep(300);
+   gpiod_set_value_cansleep(pwrseq->pwrdn_gpio, 1);
+}
+
+static void mmc_pwrseq_sd8787_power_off(struct mmc_host *host)
+{
+   struct mmc_pwrseq_sd8787 *pwrseq = to_pwrseq_sd8787(host->pwrseq);
+
+   gpiod_set_value_cansleep(pwrseq->pwrdn_gpio, 0);
+   gpiod_set_value_cansleep(pwrseq->reset_gpio, 0);
+}
+
+static const struct mmc_pwrseq_ops mmc_pwrseq_sd8787_ops = {
+   .pre_power_on = mmc_pwrseq_sd8787_pre_power_on,
+   .power_off = mmc_pwrseq_sd8787_power_off,
+};
+
+static const struct of_device_id mmc_pwrseq_sd8787_of_match[] = {
+   { .compatible = "mmc-pwrseq-sd8787",},
+   {/* sentinel */},
+};
+MODULE_DEVICE_TABLE(of, mmc_pwrseq_sd8787_of_match);
+
+static int mmc_pwrseq_sd8787_probe(struct platform_device *pdev)
+{
+   struct mmc_pwrseq_sd8787 *pwrseq;
+   struct device *dev = >dev;
+
+   pwrseq = devm_kzalloc(dev, sizeof(*pwrseq), GFP_KERNEL);
+   if (!pwrseq)
+   return -ENOMEM;
+
+   pwrseq->pwrdn_gpio = devm_gpiod_get(dev, "pwrdn", GPIOD_OUT_LOW);
+   if (IS_ERR(pwrseq->pwrdn_gpio))
+   return PTR_ERR(pwrseq->pwrdn_gpio);
+
+   pwrseq->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
+   if (IS_ERR(pwrseq->reset_gpio))
+   return PTR_ERR(pwrseq->reset_gpio);
+
+   pwrseq->pwrseq.dev = dev;
+   pwrseq->pwrseq.ops = _pwrseq_sd8787_ops;
+   pwrseq->pwrseq.owner = THIS_MODULE;
+   platform_set_drvdata(pdev, pwrseq);
+
+  

[PATCH v3 0/2] mmc: pwrseq: add support for Marvell SD8787 chip

2017-01-12 Thread Matt Ranostay
Changes from v1:
* split devictree docs from pwrseq changes
* rebase devicetree documents due to filename change
* rebase pwrseq patchset

Changes from v2:
* fix rookie mistake missing the main source file and docs

Matt Ranostay (2):
  devicetree: document new marvell-8xxx and pwrseq-sd8787 options
  mmc: pwrseq: add support for Marvell SD8787 chip

 .../devicetree/bindings/mmc/mmc-pwrseq-sd8787.txt  |  14 +++
 .../bindings/net/wireless/marvell-8xxx.txt |   7 +-
 drivers/mmc/core/Kconfig   |  10 ++
 drivers/mmc/core/Makefile  |   1 +
 drivers/mmc/core/pwrseq_sd8787.c   | 117 +
 5 files changed, 148 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/mmc/mmc-pwrseq-sd8787.txt
 create mode 100644 drivers/mmc/core/pwrseq_sd8787.c

-- 
2.10.2



Re: [PATCH v2 2/2] mmc: pwrseq: add support for Marvell SD8787 chip

2017-01-12 Thread Matt Ranostay
On Thu, Jan 12, 2017 at 9:22 PM, Matt Ranostay  wrote:
> Allow power sequencing for the Marvell SD8787 Wifi/BT chip.
> This can be abstracted to other chipsets if needed in the future.


Er crap seems how the main patch file got dropped out. Resubmitting in
a minute... sorry!

>
> Cc: Tony Lindgren 
> Cc: Ulf Hansson 
> Signed-off-by: Matt Ranostay 
> ---
>  drivers/mmc/core/Kconfig  | 10 ++
>  drivers/mmc/core/Makefile |  1 +
>  2 files changed, 11 insertions(+)
>
> diff --git a/drivers/mmc/core/Kconfig b/drivers/mmc/core/Kconfig
> index cdfa8520a4b1..fc1ecdaaa9ca 100644
> --- a/drivers/mmc/core/Kconfig
> +++ b/drivers/mmc/core/Kconfig
> @@ -12,6 +12,16 @@ config PWRSEQ_EMMC
>   This driver can also be built as a module. If so, the module
>   will be called pwrseq_emmc.
>
> +config PWRSEQ_SD8787
> +   tristate "HW reset support for SD8787 BT + Wifi module"
> +   depends on OF && (MWIFIEX || BT_MRVL_SDIO)
> +   help
> + This selects hardware reset support for the SD8787 BT + Wifi
> + module. By default this option is set to n.
> +
> + This driver can also be built as a module. If so, the module
> + will be called pwrseq_sd8787.
> +
>  config PWRSEQ_SIMPLE
> tristate "Simple HW reset support for MMC"
> default y
> diff --git a/drivers/mmc/core/Makefile b/drivers/mmc/core/Makefile
> index b2a257dc644f..0f81464fa824 100644
> --- a/drivers/mmc/core/Makefile
> +++ b/drivers/mmc/core/Makefile
> @@ -10,6 +10,7 @@ mmc_core-y:= core.o bus.o host.o \
>quirks.o slot-gpio.o
>  mmc_core-$(CONFIG_OF)  += pwrseq.o
>  obj-$(CONFIG_PWRSEQ_SIMPLE)+= pwrseq_simple.o
> +obj-$(CONFIG_PWRSEQ_SD8787)+= pwrseq_sd8787.o
>  obj-$(CONFIG_PWRSEQ_EMMC)  += pwrseq_emmc.o
>  mmc_core-$(CONFIG_DEBUG_FS)+= debugfs.o
>  obj-$(CONFIG_MMC_BLOCK)+= mmc_block.o
> --
> 2.10.2
>


[PATCH v2 0/2] mmc: pwrseq: add support for Marvell SD8787 chip

2017-01-12 Thread Matt Ranostay
Changes from v1:
* split devictree docs from pwrseq changes
* rebase devicetree documents due to filename change
* rebase pwrseq patchset

Matt Ranostay (2):
  devicetree: document vmmc-supply and mmc-pwrseq options
  mmc: pwrseq: add support for Marvell SD8787 chip

 .../devicetree/bindings/net/wireless/marvell-8xxx.txt  |  7 ++-
 drivers/mmc/core/Kconfig   | 10 ++
 drivers/mmc/core/Makefile  |  1 +
 3 files changed, 17 insertions(+), 1 deletion(-)

-- 
2.10.2



[PATCH v2 1/2] devicetree: document vmmc-supply and mmc-pwrseq options

2017-01-12 Thread Matt Ranostay
Cc: devicet...@vger.kernel.org
Signed-off-by: Matt Ranostay 
---
 Documentation/devicetree/bindings/net/wireless/marvell-8xxx.txt | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/net/wireless/marvell-8xxx.txt 
b/Documentation/devicetree/bindings/net/wireless/marvell-8xxx.txt
index 980b16df74c3..0854451ff91d 100644
--- a/Documentation/devicetree/bindings/net/wireless/marvell-8xxx.txt
+++ b/Documentation/devicetree/bindings/net/wireless/marvell-8xxx.txt
@@ -1,4 +1,4 @@
-Marvell 8897/8997 (sd8897/sd8997/pcie8997) SDIO/PCIE devices
+Marvell 8787/8897/8997 (sd8787/sd8897/sd8997/pcie8997) SDIO/PCIE devices
 --
 
 This node provides properties for controlling the Marvell SDIO/PCIE wireless 
device.
@@ -8,6 +8,7 @@ connects the device to the system.
 Required properties:
 
   - compatible : should be one of the following:
+   * "marvell,sd8787"
* "marvell,sd8897"
* "marvell,sd8997"
* "pci11ab,2b42"
@@ -34,6 +35,9 @@ Optional properties:
 so that the wifi chip can wakeup host platform under certain 
condition.
 during system resume, the irq will be disabled to make sure
 unnecessary interrupt is not received.
+  - vmmc-supply: a phandle of a regulator, supplying VCC to the card
+  - mmc-pwrseq:  phandle to the MMC power sequence node. See "mmc-pwrseq-*"
+for documentation of MMC power sequence bindings.
 
 Example:
 
@@ -46,6 +50,7 @@ so that firmware can wakeup host using this device side pin.
  {
status = "okay";
vmmc-supply = <_en_reg>;
+   mmc-pwrseq = <_pwrseq>;
bus-width = <4>;
cap-power-off-card;
keep-power-in-suspend;
-- 
2.10.2



[PATCH v2 2/2] mmc: pwrseq: add support for Marvell SD8787 chip

2017-01-12 Thread Matt Ranostay
Allow power sequencing for the Marvell SD8787 Wifi/BT chip.
This can be abstracted to other chipsets if needed in the future.

Cc: Tony Lindgren 
Cc: Ulf Hansson 
Signed-off-by: Matt Ranostay 
---
 drivers/mmc/core/Kconfig  | 10 ++
 drivers/mmc/core/Makefile |  1 +
 2 files changed, 11 insertions(+)

diff --git a/drivers/mmc/core/Kconfig b/drivers/mmc/core/Kconfig
index cdfa8520a4b1..fc1ecdaaa9ca 100644
--- a/drivers/mmc/core/Kconfig
+++ b/drivers/mmc/core/Kconfig
@@ -12,6 +12,16 @@ config PWRSEQ_EMMC
  This driver can also be built as a module. If so, the module
  will be called pwrseq_emmc.
 
+config PWRSEQ_SD8787
+   tristate "HW reset support for SD8787 BT + Wifi module"
+   depends on OF && (MWIFIEX || BT_MRVL_SDIO)
+   help
+ This selects hardware reset support for the SD8787 BT + Wifi
+ module. By default this option is set to n.
+
+ This driver can also be built as a module. If so, the module
+ will be called pwrseq_sd8787.
+
 config PWRSEQ_SIMPLE
tristate "Simple HW reset support for MMC"
default y
diff --git a/drivers/mmc/core/Makefile b/drivers/mmc/core/Makefile
index b2a257dc644f..0f81464fa824 100644
--- a/drivers/mmc/core/Makefile
+++ b/drivers/mmc/core/Makefile
@@ -10,6 +10,7 @@ mmc_core-y:= core.o bus.o host.o \
   quirks.o slot-gpio.o
 mmc_core-$(CONFIG_OF)  += pwrseq.o
 obj-$(CONFIG_PWRSEQ_SIMPLE)+= pwrseq_simple.o
+obj-$(CONFIG_PWRSEQ_SD8787)+= pwrseq_sd8787.o
 obj-$(CONFIG_PWRSEQ_EMMC)  += pwrseq_emmc.o
 mmc_core-$(CONFIG_DEBUG_FS)+= debugfs.o
 obj-$(CONFIG_MMC_BLOCK)+= mmc_block.o
-- 
2.10.2



[RFC] [PULL REQUEST] rt2x00 patches from OpenWrt.org

2017-01-12 Thread Daniel Golle
Hi!

In preparation to be submitted upstream I started to clean up a huge
pile of patches for rt2x00 we have been carrying along for quite a
while (some for more than half a decade!).
Some of them are fixes, most importantly Serge Vasilugin fixed setting
the HT20/HT40 filter which got us much closer to the expected
performance when using HT40 modes.

And also a lot of new added hardware support:
Gabor Juhos wrote code for Rt3883 WiSoC.
Daniel Golle implemented support for Rt3352 by designs with external PA
as well as for boards using a 20MHz crystal instead of the usual 40MHz.
Serge Vasilugin contributed support for the Rt5350 WiSoC.
Michel Stempin, Felix Fietkau and John Crispin have been helping with
cleaning up things and putting away legal doubts.

Please review and comment, so we can get those patches merged!


Cheers


Daniel


The following changes since commit cc75c577806a53893122829d91cb122b51643a2d:

  mwifiex: get rid of global save_adapter and sdio_work (2017-01-12 16:49:18 
+0200)

are available in the git repository at:

  https://github.com/dangowrt/linux.git rt2x00-from-openwrt

for you to fetch changes up to fb8832d1896475059c964c75ab4baaf94199143c:

  rt2x00: fix WARN_ON_ONCE() caused by inbalanced set/clear of beacon enable 
bit (2017-01-13 04:17:57 +0100)


Claudio Mignanti (1):
  rt2x00: rt2x00pci: set PCI MWI only if supported

Daniel Golle (2):
  rt2x00: support for for RT3352 with external PA
  rt2x00: add support for RT3352 with 20MHz crystal

Felix Fietkau (1):
  rt2x00: fix rf id for RT3352

Gabor Juhos (34):
  rt2x00: rt2800lib: move rt2800_drv_data declaration into rt2800lib.h
  rt2x00: rt2800lib: introduce RT2800_HAS_HIGH_SHARED_MEM flag
  rt2x00: rt2800: serialize shared memory access
  rt2x00: rt2800lib: fix beacon generation on RT3593
  rt2x00: rt2800lib: add hw_beacon_count field to struct rt2800_drv_data
  rt2x00: rt2800lib: init additional beacon offset registers
  rt2x00: rt2800lib: fix max supported beacon count for RT3593
  rt2x00: allow to build rt2800soc module for RT3883
  rt2x00: rt2800lib: enable support for RT3883
  rt2x00: rt2800lib: add rf_vals for RF3853
  rt2x00: rt2800lib: enable VCO calibration for RF3853
  rt2x00: rt2800lib: add channel configuration function for RF3853
  rt2x00: rt2800lib: enable RF3853 support
  rt2x00: rt2800lib: add MAC register initialization for RT3883
  rt2x00: rt2800soc: fix rt2800soc_disable_radio for RT3883
  rt2x00: rt2800lib: add BBP register initialization for RT3883
  rt2x00: rt2800lib: add RFCSR initialization for RT3883
  rt2x00: rt2800lib: use the extended EEPROM map for RT3883
  rt2x00: rt2800lib: force rf type to RF3853 on RT3883
  rt2x00: rt2800lib: add channel configuration code for RT3883
  rt2x00: rt2800lib: fix txpower_to_dev function for RT3883
  rt2x00: rt2800lib: use correct txpower calculation function for RT3883
  rt2x00: rt2800lib: hardcode txmixer gain values to zero for RT3883
  rt2x00: rt2800lib: use correct [RT]XWI size for RT3883
  rt2x00: rt2800lib: use correct beacon base for RT3883
  rt2x00: rt2800lib: use correct beacon count for RT3883
  rt2x00: rt2800lib: fix antenna configuration for RT3883
  rt2x00: rt2800lib: fix LNA gain configuration for RT3883
  rt2x00: rt2800lib: fix VGC setup for RT3883
  rt2x00: rt2800lib: fix EEPROM LNA validation for RT3883
  rt2x00: rt2800lib: fix txpower compensation for RT3883
  rt2x00: rt2800lib: enable RT2800_HAS_HIGH_SHARED_MEM for RT3883
  rt2x00: rt2800lib: use high memory for beacons on RT3883
  rt2x00: rt2800mmio: add a workaround for spurious TX_FIFO_STATUS 
interrupts

Michel Stempin (1):
  rt2x00: add support for RT5350 WiSoC

Serge Vasilugin (1):
  rt2x00 correctly set ht20/ht40 filter

evaxige (1):
  rt2x00: fix WARN_ON_ONCE() caused by inbalanced set/clear of beacon 
enable bit

 drivers/net/wireless/ralink/rt2x00/Kconfig  |2 +-
 drivers/net/wireless/ralink/rt2x00/rt2800.h |   79 +-
 drivers/net/wireless/ralink/rt2x00/rt2800lib.c  | 1006 ++-
 drivers/net/wireless/ralink/rt2x00/rt2800lib.h  |   63 ++
 drivers/net/wireless/ralink/rt2x00/rt2800mmio.c |   98 ++-
 drivers/net/wireless/ralink/rt2x00/rt2800mmio.h |4 +
 drivers/net/wireless/ralink/rt2x00/rt2800pci.c  |   14 +
 drivers/net/wireless/ralink/rt2x00/rt2800soc.c  |   12 +-
 drivers/net/wireless/ralink/rt2x00/rt2800usb.c  |   31 +
 drivers/net/wireless/ralink/rt2x00/rt2x00.h |   10 +
 drivers/net/wireless/ralink/rt2x00/rt2x00dev.c  |7 +-
 drivers/net/wireless/ralink/rt2x00/rt2x00mac.c  |8 +-
 drivers/net/wireless/ralink/rt2x00/rt2x00pci.c  |2 +
 13 files changed, 1254 insertions(+), 82 deletions(-)


linux-next: build warning after merge of the wireless-drivers-next tree

2017-01-12 Thread Stephen Rothwell
Hi all,

After merging the wireless-drivers-next tree, today's linux-next build
(x86_64 allmodconfig) produced this warning:

drivers/net/wireless/marvell/mwifiex/pcie.c: In function 'mwifiex_pcie_remove':
drivers/net/wireless/marvell/mwifiex/pcie.c:303:5: warning: 'fw_status' may be 
used uninitialized in this function [-Wmaybe-uninitialized]
  if (fw_status == FIRMWARE_READY_PCIE && !adapter->mfg_mode) {
 ^

Introduced by commit

  045f0c1b5e26 ("mwifiex: get rid of global user_rmmod flag")

This is not a false positive since "reg" could be NULL just above
(otherwise it would be tested for).

-- 
Cheers,
Stephen Rothwell


[PATCH 4/4] cfg80211: Fix documentation for connect result

2017-01-12 Thread Jouni Malinen
The function documentation for cfg80211_connect_bss() and
cfg80211_connect_result() was still claiming that they are used only for
a success case while these functions can now be used to report both
success and various failure cases. The actual use cases were already
described in the connect() documentation.

Update the function specific comments to note the failure cases and also
describe how the special status == -1 case is used in
cfg80211_connect_bss() to indicate a connection timeout based on the
internal implementation in cfg80211_connect_timeout().

Signed-off-by: Jouni Malinen 
---
 include/net/cfg80211.h | 25 -
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 9b3427c..ed3d595 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5086,9 +5086,14 @@ static inline void cfg80211_testmode_event(struct 
sk_buff *skb, gfp_t gfp)
  * @req_ie_len: association request IEs length
  * @resp_ie: association response IEs (may be %NULL)
  * @resp_ie_len: assoc response IEs length
- * @status: status code, 0 for successful connection, use
+ * @status: status code, %WLAN_STATUS_SUCCESS for successful connection, use
  *  %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
- *  the real status code for failures.
+ * the real status code for failures. If this call is used to report a
+ * failure due to a timeout (e.g., not receiving an Authentication frame
+ * from the AP) instead of an explicit rejection by the AP, -1 is used to
+ * indicate that this is a failure, but without a status code.
+ * @timeout_reason is used to report the reason for the timeout in that
+ * case.
  * @gfp: allocation flags
  * @timeout_reason: reason for connection timeout. This is used when the
  * connection fails due to a timeout instead of an explicit rejection from
@@ -5097,10 +5102,10 @@ static inline void cfg80211_testmode_event(struct 
sk_buff *skb, gfp_t gfp)
  * failure is due to a timeout and not due to explicit rejection by the AP.
  * This value is ignored in other cases (@status >= 0).
  *
- * It should be called by the underlying driver whenever connect() has
- * succeeded. This is similar to cfg80211_connect_result(), but with the
- * option of identifying the exact bss entry for the connection. Only one of
- * these functions should be called.
+ * It should be called by the underlying driver once execution of the 
connection
+ * request from connect() has been completed. This is similar to
+ * cfg80211_connect_result(), but with the option of identifying the exact bss
+ * entry for the connection. Only one of these functions should be called.
  */
 void cfg80211_connect_bss(struct net_device *dev, const u8 *bssid,
  struct cfg80211_bss *bss, const u8 *req_ie,
@@ -5117,13 +5122,15 @@ void cfg80211_connect_bss(struct net_device *dev, const 
u8 *bssid,
  * @req_ie_len: association request IEs length
  * @resp_ie: association response IEs (may be %NULL)
  * @resp_ie_len: assoc response IEs length
- * @status: status code, 0 for successful connection, use
+ * @status: status code, %WLAN_STATUS_SUCCESS for successful connection, use
  * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
  * the real status code for failures.
  * @gfp: allocation flags
  *
- * It should be called by the underlying driver whenever connect() has
- * succeeded.
+ * It should be called by the underlying driver once execution of the 
connection
+ * request from connect() has been completed. This is similar to
+ * cfg80211_connect_bss() which allows the exact bss entry to be specified. 
Only
+ * one of these functions should be called.
  */
 static inline void
 cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
-- 
2.7.4



[PATCH v2 3/4] cfg80211: Specify the reason for connect timeout

2017-01-12 Thread Jouni Malinen
From: Purushottam Kushwaha 

This enhances the connect timeout API to also carry the reason for the
timeout. These reason codes for the connect time out are represented by
enum nl80211_timeout_reason and are passed to user space through a new
attribute NL80211_ATTR_TIMEOUT_REASON (u32).

Signed-off-by: Purushottam Kushwaha 
Signed-off-by: Jouni Malinen 
---
 include/net/cfg80211.h   | 18 ++
 include/uapi/linux/nl80211.h | 21 +
 net/wireless/core.h  |  4 +++-
 net/wireless/mlme.c  |  3 ++-
 net/wireless/nl80211.c   |  8 ++--
 net/wireless/nl80211.h   |  3 ++-
 net/wireless/sme.c   | 39 +++
 net/wireless/util.c  |  2 +-
 8 files changed, 76 insertions(+), 22 deletions(-)

v2:
- update cfg80211_connect_bss() comment to note that timeout_reason
  gets ignored for status >= 0
- rename CFG80211_CONN_AUTH_FAILED to CFG80211_CONN_AUTH_FAILED_TIMEOUT
  to be consistent with association (which needs both
  failure-due-to-reject and failure-due-to-timeout)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 4456491..9b3427c 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5090,6 +5090,12 @@ static inline void cfg80211_testmode_event(struct 
sk_buff *skb, gfp_t gfp)
  *  %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
  *  the real status code for failures.
  * @gfp: allocation flags
+ * @timeout_reason: reason for connection timeout. This is used when the
+ * connection fails due to a timeout instead of an explicit rejection from
+ * the AP. %NL80211_TIMEOUT_UNSPECIFIED is used when the timeout reason is
+ * not known. This value is used only if @status < 0 to indicate that the
+ * failure is due to a timeout and not due to explicit rejection by the AP.
+ * This value is ignored in other cases (@status >= 0).
  *
  * It should be called by the underlying driver whenever connect() has
  * succeeded. This is similar to cfg80211_connect_result(), but with the
@@ -5099,7 +5105,8 @@ static inline void cfg80211_testmode_event(struct sk_buff 
*skb, gfp_t gfp)
 void cfg80211_connect_bss(struct net_device *dev, const u8 *bssid,
  struct cfg80211_bss *bss, const u8 *req_ie,
  size_t req_ie_len, const u8 *resp_ie,
- size_t resp_ie_len, int status, gfp_t gfp);
+ size_t resp_ie_len, int status, gfp_t gfp,
+ enum nl80211_timeout_reason timeout_reason);
 
 /**
  * cfg80211_connect_result - notify cfg80211 of connection result
@@ -5125,7 +5132,8 @@ cfg80211_connect_result(struct net_device *dev, const u8 
*bssid,
u16 status, gfp_t gfp)
 {
cfg80211_connect_bss(dev, bssid, NULL, req_ie, req_ie_len, resp_ie,
-resp_ie_len, status, gfp);
+resp_ie_len, status, gfp,
+NL80211_TIMEOUT_UNSPECIFIED);
 }
 
 /**
@@ -5136,6 +5144,7 @@ cfg80211_connect_result(struct net_device *dev, const u8 
*bssid,
  * @req_ie: association request IEs (maybe be %NULL)
  * @req_ie_len: association request IEs length
  * @gfp: allocation flags
+ * @timeout_reason: reason for connection timeout.
  *
  * It should be called by the underlying driver whenever connect() has failed
  * in a sequence where no explicit authentication/association rejection was
@@ -5145,10 +5154,11 @@ cfg80211_connect_result(struct net_device *dev, const 
u8 *bssid,
  */
 static inline void
 cfg80211_connect_timeout(struct net_device *dev, const u8 *bssid,
-const u8 *req_ie, size_t req_ie_len, gfp_t gfp)
+const u8 *req_ie, size_t req_ie_len, gfp_t gfp,
+enum nl80211_timeout_reason timeout_reason)
 {
cfg80211_connect_bss(dev, bssid, NULL, req_ie, req_ie_len, NULL, 0, -1,
-gfp);
+gfp, timeout_reason);
 }
 
 /**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 6b17feb..c51b40c 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1996,6 +1996,10 @@ enum nl80211_commands {
  * better BSSs. The attribute value is a packed structure
  * value as specified by  nl80211_bss_select_rssi_adjust.
  *
+ * @NL80211_ATTR_TIMEOUT_REASON: The reason for which an operation timed out.
+ * u32 attribute with an  nl80211_timeout_reason value. This is used,
+ * e.g., with %NL80211_CMD_CONNECT event.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2405,6 +2409,8 @@ enum nl80211_attrs {
NL80211_ATTR_SCHED_SCAN_RELATIVE_RSSI,

[PATCH v3 1/4] cfg80211: Add support to randomize TA of Public Action frames

2017-01-12 Thread Jouni Malinen
From: vamsi krishna 

Add support to use a random local address (Address 2 = TA in transmit
and the same address in receive functionality) for Public Action frames
in order to improve privacy of WLAN clients. Applications fill the
random transmit address in the frame buffer in the NL80211_CMD_FRAME
command. This can be used only with the drivers that indicate support
for random local address by setting the new
NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA and/or
NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA_CONNECTED in ext_features.

The driver needs to configure receive behavior to accept frames to the
specified random address during the time the frame exchange is pending
and such frames need to be acknowledged similarly to frames sent to the
local permanent address when this random address functionality is not
used.

Signed-off-by: vamsi krishna 
Signed-off-by: Jouni Malinen 
---
 include/uapi/linux/nl80211.h |  6 ++
 net/wireless/mlme.c  | 21 +++--
 2 files changed, 25 insertions(+), 2 deletions(-)

v3:
- moved to the beginning of the series since there were no pending
  comments on this patch; no other changes

diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 174f4b3..908886c 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -4699,6 +4699,10 @@ enum nl80211_feature_flags {
  * configuration (AP/mesh) with VHT rates.
  * @NL80211_EXT_FEATURE_FILS_STA: This driver supports Fast Initial Link Setup
  * with user space SME (NL80211_CMD_AUTHENTICATE) in station mode.
+ * @NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA: This driver supports randomized TA
+ * in @NL80211_CMD_FRAME while not associated.
+ * @NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA_CONNECTED: This driver supports
+ * randomized TA in @NL80211_CMD_FRAME while associated.
  *
  * @NUM_NL80211_EXT_FEATURES: number of extended features.
  * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
@@ -4714,6 +4718,8 @@ enum nl80211_ext_feature_index {
NL80211_EXT_FEATURE_BEACON_RATE_HT,
NL80211_EXT_FEATURE_BEACON_RATE_VHT,
NL80211_EXT_FEATURE_FILS_STA,
+   NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA,
+   NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA_CONNECTED,
 
/* add new features before the definition below */
NUM_NL80211_EXT_FEATURES,
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
index 1c63a77..b876f40 100644
--- a/net/wireless/mlme.c
+++ b/net/wireless/mlme.c
@@ -662,8 +662,25 @@ int cfg80211_mlme_mgmt_tx(struct 
cfg80211_registered_device *rdev,
return err;
}
 
-   if (!ether_addr_equal(mgmt->sa, wdev_address(wdev)))
-   return -EINVAL;
+   if (!ether_addr_equal(mgmt->sa, wdev_address(wdev))) {
+   /* Allow random TA to be used with Public Action frames if the
+* driver has indicated support for this. Otherwise, only allow
+* the local address to be used.
+*/
+   if (!ieee80211_is_action(mgmt->frame_control) ||
+   mgmt->u.action.category != WLAN_CATEGORY_PUBLIC)
+   return -EINVAL;
+   if (!wdev->current_bss &&
+   !wiphy_ext_feature_isset(
+   >wiphy,
+   NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA))
+   return -EINVAL;
+   if (wdev->current_bss &&
+   !wiphy_ext_feature_isset(
+   >wiphy,
+   NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA_CONNECTED))
+   return -EINVAL;
+   }
 
/* Transmit the Action frame as requested by user space */
return rdev_mgmt_tx(rdev, wdev, params, cookie);
-- 
2.7.4



[PATCH v4 2/4] cfg80211: Add support to sched scan to report better BSSs

2017-01-12 Thread Jouni Malinen
From: vamsi krishna 

Enhance sched scan to support option of finding a better BSS while in
connected state. Firmware scans the medium and reports when it finds a
known BSS which has better RSSI than the current connected BSS. New
attributes to specify the relative RSSI (compared to the current BSS)
are added to the sched scan to implement this.

Signed-off-by: vamsi krishna 
Signed-off-by: Jouni Malinen 
---
 include/net/cfg80211.h   | 36 +---
 include/uapi/linux/nl80211.h | 30 ++
 net/wireless/nl80211.c   | 44 
 3 files changed, 99 insertions(+), 11 deletions(-)

v4:
- rebased on top of the random TA patch
- update comments to cover possibility of negative relative_rssi
- use NL80211_ATTR_SCHED_SCAN_RSSI_ADJUST only if
  NL80211_ATTR_SCHED_SCAN_RELATIVE_RSSI is present
- remove unnecessary nl80211_send_wowlan_nd() argument change
- remove invalid rssi_adjust.band comparison (different enum)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index cb13789..4456491 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1620,6 +1620,17 @@ struct cfg80211_sched_scan_plan {
 };
 
 /**
+ * struct cfg80211_bss_select_adjust - BSS selection with RSSI adjustment.
+ *
+ * @band: band of BSS which should match for RSSI level adjustment.
+ * @delta: value of RSSI level adjustment.
+ */
+struct cfg80211_bss_select_adjust {
+   enum nl80211_band band;
+   s8 delta;
+};
+
+/**
  * struct cfg80211_sched_scan_request - scheduled scan request description
  *
  * @ssids: SSIDs to scan for (passed in the probe_reqs in active scans)
@@ -1654,6 +1665,16 @@ struct cfg80211_sched_scan_plan {
  * cycle.  The driver may ignore this parameter and start
  * immediately (or at any other time), if this feature is not
  * supported.
+ * @relative_rssi_set: Indicates whether @relative_rssi is set or not.
+ * @relative_rssi: Relative RSSI threshold in dB to restrict scan result
+ * reporting in connected state to cases where a matching BSS is determined
+ * to have better or slightly worse RSSI than the current connected BSS.
+ * The relative RSSI threshold values are ignored in disconnected state.
+ * @rssi_adjust: delta dB of RSSI preference to be given to the BSSs that 
belong
+ * to the specified band while deciding whether a better BSS is reported
+ * using @relative_rssi. If delta is a negative number, the BSSs that
+ * belong to the specified band will be penalized by delta dB in relative
+ * comparisions.
  */
 struct cfg80211_sched_scan_request {
struct cfg80211_ssid *ssids;
@@ -1673,6 +1694,10 @@ struct cfg80211_sched_scan_request {
u8 mac_addr[ETH_ALEN] __aligned(2);
u8 mac_addr_mask[ETH_ALEN] __aligned(2);
 
+   bool relative_rssi_set;
+   s8 relative_rssi;
+   struct cfg80211_bss_select_adjust rssi_adjust;
+
/* internal */
struct wiphy *wiphy;
struct net_device *dev;
@@ -1981,17 +2006,6 @@ struct cfg80211_ibss_params {
 };
 
 /**
- * struct cfg80211_bss_select_adjust - BSS selection with RSSI adjustment.
- *
- * @band: band of BSS which should match for RSSI level adjustment.
- * @delta: value of RSSI level adjustment.
- */
-struct cfg80211_bss_select_adjust {
-   enum nl80211_band band;
-   s8 delta;
-};
-
-/**
  * struct cfg80211_bss_selection - connection parameters for BSS selection.
  *
  * @behaviour: requested BSS selection behaviour.
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 908886c..6b17feb 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1982,6 +1982,20 @@ enum nl80211_commands {
  * @NL80211_ATTR_BSSID: The BSSID of the AP. Note that %NL80211_ATTR_MAC is 
also
  * used in various commands/events for specifying the BSSID.
  *
+ * @NL80211_ATTR_SCHED_SCAN_RELATIVE_RSSI: Relative RSSI threshold by which
+ * other BSSs has to be better or slightly worse than the current
+ * connected BSS so that they get reported to user space.
+ * This will give an opportunity to userspace to consider connecting to
+ * other matching BSSs which have better or slightly worse RSSI than
+ * the current connected BSS by using an offloaded operation to avoid
+ * unnecessary wakeups.
+ *
+ * @NL80211_ATTR_SCHED_SCAN_RSSI_ADJUST: When present the RSSI level for BSSs 
in
+ * the specified band is to be adjusted before doing
+ * %NL80211_ATTR_SCHED_SCAN_RELATIVE_RSSI based comparision to figure out
+ * better BSSs. The attribute value is a packed structure
+ * value as specified by  nl80211_bss_select_rssi_adjust.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2388,6 +2402,9 

[PATCH 2/2] mwifiex: pcie: don't delay for sleep cookie when not required

2017-01-12 Thread Brian Norris
Wifi modules like 8997 don't support the "sleep cookie", and so most of
the time, we just time out in the mwifiex_delay_for_sleep_cookie()
function ("max count reached while accessing sleep cookie"). This is a
waste of time, and we should skip it for modules without the sleep
cookie flag.

Additionally, this delay is sometimes counterproductive. For instance,
when PCIe ASPM is enabled, this extra delay can leave the link idle for
long enough to re-enter a low-power state even while we are trying to
wake the module, compounding an additional delay when it comes time to
read the next register (e.g., the interrupt status). On some systems,
this is detrimental to overall system latency.

Signed-off-by: Brian Norris 
---
Tested on Marvell 8997, but would be good to get confirmation from Marvell.

 drivers/net/wireless/marvell/mwifiex/pcie.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c 
b/drivers/net/wireless/marvell/mwifiex/pcie.c
index 435ba879ef29..11e0673617c7 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -1712,11 +1712,13 @@ static int mwifiex_pcie_process_cmd_complete(struct 
mwifiex_adapter *adapter)
"Write register failed\n");
return -1;
}
-   mwifiex_delay_for_sleep_cookie(adapter,
-  MWIFIEX_MAX_DELAY_COUNT);
-   while (reg->sleep_cookie && (count++ < 10) &&
-  mwifiex_pcie_ok_to_access_hw(adapter))
-   usleep_range(50, 60);
+   if (reg->sleep_cookie) {
+   mwifiex_delay_for_sleep_cookie(adapter,
+  
MWIFIEX_MAX_DELAY_COUNT);
+   while ((count++ < 10) &&
+  mwifiex_pcie_ok_to_access_hw(adapter))
+   usleep_range(50, 60);
+   }
mwifiex_pcie_enable_host_int(adapter);
mwifiex_process_sleep_confirm_resp(adapter, skb->data,
   skb->len);
-- 
2.11.0.390.gc69c2f50cf-goog



[PATCH 1/2] mwifiex: pcie: use posted write to wake up firmware

2017-01-12 Thread Brian Norris
Depending on system factors (e.g., the PCIe link PM state), the first
read to wake up the Wifi firmware can take a long time. There is no
reason to use a (blocking, non-posted) read at this point, so let's just
use a write instead. Write vs. read doesn't matter functionality-wise --
it's just a dummy operation.

This has been shown to decrease the time spent blocking in this function
on a Rockchip RK3399 SoC.

Signed-off-by: Brian Norris 
---
 drivers/net/wireless/marvell/mwifiex/pcie.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c 
b/drivers/net/wireless/marvell/mwifiex/pcie.c
index 66226c615be0..435ba879ef29 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -458,7 +458,6 @@ static void mwifiex_delay_for_sleep_cookie(struct 
mwifiex_adapter *adapter,
 /* This function wakes up the card by reading fw_status register. */
 static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter)
 {
-   u32 fw_status;
struct pcie_service_card *card = adapter->card;
const struct mwifiex_pcie_card_reg *reg = card->pcie.reg;
 
@@ -468,10 +467,10 @@ static int mwifiex_pm_wakeup_card(struct mwifiex_adapter 
*adapter)
if (reg->sleep_cookie)
mwifiex_pcie_dev_wakeup_delay(adapter);
 
-   /* Reading fw_status register will wakeup device */
-   if (mwifiex_read_reg(adapter, reg->fw_status, _status)) {
+   /* Accessing fw_status register will wakeup device */
+   if (mwifiex_write_reg(adapter, reg->fw_status, 0)) {
mwifiex_dbg(adapter, ERROR,
-   "Reading fw_status register failed\n");
+   "Writing fw_status register failed\n");
return -1;
}
 
-- 
2.11.0.390.gc69c2f50cf-goog



Re: [PATCH v2 12/13] wil6210: set dma mask to reflect device capability

2017-01-12 Thread merez

On 2017-01-12 15:06, Maya Erez wrote:

From: Hamad Kadmany 

11ad device supports 48 bit addresses, reflect that
by setting the dma mask accordingly.

Signed-off-by: Hamad Kadmany 
Signed-off-by: Maya Erez 
---


Kalle, we found an issue caused by this patch. Please don't apply it.
--
Maya Erez
Qualcomm Israel, Inc. on behalf of Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a 
Linux Foundation Collaborative Project


Re: [PATCH] mac80211: prevent skb/txq mismatch

2017-01-12 Thread Dave Taht
Yay! This sounds like a potential fix for this?

https://bugs.lede-project.org/index.php?do=details_id=368

Are all the ath10k chipsets excluded by commit:

4ca1807815aa6801aaced7fdefa9edacc2521767

Still needed to be excluded?


Re: [PATCH] mac80211: prevent skb/txq mismatch

2017-01-12 Thread Felix Fietkau
On 2017-01-12 15:28, Michal Kazior wrote:
> Station structure is considered as not uploaded
> (to driver) until drv_sta_state() finishes. This
> call is however done after the structure is
> attached to mac80211 internal lists and hashes.
> This means mac80211 can lookup (and use) station
> structure before it is uploaded to a driver.
> 
> If this happens (structure exists, but
> sta->uploaded is false) fast_tx path can still be
> taken. Deep in the fastpath call the sta->uploaded
> is checked against to derive "pubsta" argument for
> ieee80211_get_txq(). If sta->uploaded is false
> (and sta is actually non-NULL) ieee80211_get_txq()
> effectively downgraded to vif->txq.
> 
> At first glance this may look innocent but coerces
> mac80211 into a state that is almost guaranteed
> (codel may drop offending skb) to crash because a
> station-oriented skb gets queued up on
> vif-oriented txq. The ieee80211_tx_dequeue() ends
> up looking at info->control.flags and tries to use
> txq->sta which in the fail case is NULL.
> 
> It's probably pointless to pretend one can
> downgrade skb from sta-txq to vif-txq.
> 
> Only drivers using wake_tx_queue were affected.
> 
> Example crash dump before fix:
> 
>  Unable to handle kernel paging request at virtual address e26c
>  PC is at ieee80211_tx_dequeue+0x204/0x690 [mac80211]
>  [] (ieee80211_tx_dequeue [mac80211]) from
>  [] (ath10k_mac_tx_push_txq+0x54/0x1c0 [ath10k_core])
>  [] (ath10k_mac_tx_push_txq [ath10k_core]) from
>  [] (ath10k_htt_txrx_compl_task+0xd78/0x11d0 [ath10k_core])
>  [] (ath10k_htt_txrx_compl_task [ath10k_core])
>  [] (ath10k_pci_napi_poll+0x54/0xe8 [ath10k_pci])
>  [] (ath10k_pci_napi_poll [ath10k_pci]) from
>  [] (net_rx_action+0xac/0x160)
> 
> Reported-by: Mohammed Shafi Shajakhan 
> Signed-off-by: Michal Kazior 
Acked-by: Felix Fietkau 


[PATCH] Revert "bcma: init serial console directly from ChipCommon code"

2017-01-12 Thread Rafał Miłecki
From: Rafał Miłecki 

This reverts commit 4c81acab3816 ("bcma: init serial console directly
from ChipCommon code") as it broke IRQ assignment. Getting IRQ with
bcma_core_irq helper on SoC requires MIPS core to be set. It happens
*after* ChipCommon initialization so we can't do this so early.

This fixes a regression but it seems noone noticed it for about a year.
It could be it was because serial was still somehow working, just
without IRQs. It doesn't look like a critical patch / fix.

Reported-by: Felix Fietkau 
Signed-off-by: Rafał Miłecki 
---
 drivers/bcma/bcma_private.h  |  3 +++
 drivers/bcma/driver_chipcommon.c | 11 +++
 drivers/bcma/driver_mips.c   |  3 +++
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h
index f642c42..168fa17 100644
--- a/drivers/bcma/bcma_private.h
+++ b/drivers/bcma/bcma_private.h
@@ -45,6 +45,9 @@ int bcma_sprom_get(struct bcma_bus *bus);
 void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc);
 void bcma_core_chipcommon_init(struct bcma_drv_cc *cc);
 void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
+#ifdef CONFIG_BCMA_DRIVER_MIPS
+void bcma_chipco_serial_init(struct bcma_drv_cc *cc);
+#endif /* CONFIG_BCMA_DRIVER_MIPS */
 
 /* driver_chipcommon_b.c */
 int bcma_core_chipcommon_b_init(struct bcma_drv_cc_b *ccb);
diff --git a/drivers/bcma/driver_chipcommon.c b/drivers/bcma/driver_chipcommon.c
index b4f6520..62f5bfa 100644
--- a/drivers/bcma/driver_chipcommon.c
+++ b/drivers/bcma/driver_chipcommon.c
@@ -15,8 +15,6 @@
 #include 
 #include 
 
-static void bcma_chipco_serial_init(struct bcma_drv_cc *cc);
-
 static inline u32 bcma_cc_write32_masked(struct bcma_drv_cc *cc, u16 offset,
 u32 mask, u32 value)
 {
@@ -186,9 +184,6 @@ void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc)
if (cc->capabilities & BCMA_CC_CAP_PMU)
bcma_pmu_early_init(cc);
 
-   if (IS_BUILTIN(CONFIG_BCM47XX) && bus->hosttype == BCMA_HOSTTYPE_SOC)
-   bcma_chipco_serial_init(cc);
-
if (bus->hosttype == BCMA_HOSTTYPE_SOC)
bcma_core_chipcommon_flash_detect(cc);
 
@@ -378,9 +373,9 @@ u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 
mask, u32 value)
return res;
 }
 
-static void bcma_chipco_serial_init(struct bcma_drv_cc *cc)
+#ifdef CONFIG_BCMA_DRIVER_MIPS
+void bcma_chipco_serial_init(struct bcma_drv_cc *cc)
 {
-#if IS_BUILTIN(CONFIG_BCM47XX)
unsigned int irq;
u32 baud_base;
u32 i;
@@ -422,5 +417,5 @@ static void bcma_chipco_serial_init(struct bcma_drv_cc *cc)
ports[i].baud_base = baud_base;
ports[i].reg_shift = 0;
}
-#endif /* CONFIG_BCM47XX */
 }
+#endif /* CONFIG_BCMA_DRIVER_MIPS */
diff --git a/drivers/bcma/driver_mips.c b/drivers/bcma/driver_mips.c
index 96f1713..89af807 100644
--- a/drivers/bcma/driver_mips.c
+++ b/drivers/bcma/driver_mips.c
@@ -278,9 +278,12 @@ static void bcma_core_mips_nvram_init(struct bcma_drv_mips 
*mcore)
 
 void bcma_core_mips_early_init(struct bcma_drv_mips *mcore)
 {
+   struct bcma_bus *bus = mcore->core->bus;
+
if (mcore->early_setup_done)
return;
 
+   bcma_chipco_serial_init(>drv_cc);
bcma_core_mips_nvram_init(mcore);
 
mcore->early_setup_done = true;
-- 
2.10.1



Re: [PATCH] ath10k: prevent sta pointer rcu violation

2017-01-12 Thread Michal Kazior
On 12 January 2017 at 16:46, Johannes Berg  wrote:
> On Thu, 2017-01-12 at 16:14 +0100, Michal Kazior wrote:
>> Station pointers are RCU protected so driver must
>> be extra careful if it tries to store them
>> internally for later use outside of the RCU
>> section it obtained it in.
>>
>> It was possible for station teardown to race with
>> some htt events. The possible outcome could be a
>> use-after-free and a crash.
>>
>> Only peer-flow-control capable firmware was
>> affected (so hardware-wise qca99x0 and qca4019).
>>
>> This could be done in sta_state() itself via
>> explicit synchronize_net() call but there's
>> already a convenient sta_pre_rcu_remove() op that
>> can be hooked up to avoid extra rcu stall.
>
> I don't think this makes sense. You're not using RCU-protected pointers
> to the stations yourself, all accesses to them are locked under the
> >data_lock. As a consequence, you can't have any need for waiting
> for a grace period. Since you also remove the pointer (under lock) when
> the station gets removed, I don't think RCU can be the problem?

Unless you then continue to use that sta pointer after you release
data_lock. Consider this:

>  CPU0 CPU1
> 1   synchronize_net()
> 2drv_sta_state()
> 3  htt_fetch_ind(pid,tid) called
> 4  rcu_read_lock()
> 5  get(data_lock)
> 6  txq=peers[pid]->sta->txq[tid]
> 7  put(data_lock)
> 8get(data_lock)
> 9 peer->sta=0
> 10   put(data_lock)
> 11 kfree(sta)
> 12 ieee80211_tx_dequeue(txq)

Even though there's no code like (9) per se you can think of it as
anything that tries to "remove" the peer--sta association (ath10k_peer
is removed implicitly via wmi peer delete command and waiting for htt
event completion).

Holding data_lock for the entire duration of handling fetch indication
isn't really good for performance so it's better to fix RCU handling.


Michał


Re: [PATCH] ath10k: prevent sta pointer rcu violation

2017-01-12 Thread Johannes Berg
On Thu, 2017-01-12 at 16:14 +0100, Michal Kazior wrote:
> Station pointers are RCU protected so driver must
> be extra careful if it tries to store them
> internally for later use outside of the RCU
> section it obtained it in.
> 
> It was possible for station teardown to race with
> some htt events. The possible outcome could be a
> use-after-free and a crash.
> 
> Only peer-flow-control capable firmware was
> affected (so hardware-wise qca99x0 and qca4019).
> 
> This could be done in sta_state() itself via
> explicit synchronize_net() call but there's
> already a convenient sta_pre_rcu_remove() op that
> can be hooked up to avoid extra rcu stall.

I don't think this makes sense. You're not using RCU-protected pointers
to the stations yourself, all accesses to them are locked under the
>data_lock. As a consequence, you can't have any need for waiting
for a grace period. Since you also remove the pointer (under lock) when
the station gets removed, I don't think RCU can be the problem?

johannes


[PATCH] ath10k: prevent sta pointer rcu violation

2017-01-12 Thread Michal Kazior
Station pointers are RCU protected so driver must
be extra careful if it tries to store them
internally for later use outside of the RCU
section it obtained it in.

It was possible for station teardown to race with
some htt events. The possible outcome could be a
use-after-free and a crash.

Only peer-flow-control capable firmware was
affected (so hardware-wise qca99x0 and qca4019).

This could be done in sta_state() itself via
explicit synchronize_net() call but there's
already a convenient sta_pre_rcu_remove() op that
can be hooked up to avoid extra rcu stall.

The peer->sta pointer itself can't be set to
NULL/ERR_PTR because it is later used in
sta_state() for extra sanity checks.

Signed-off-by: Michal Kazior 
---
 drivers/net/wireless/ath/ath10k/core.h |  1 +
 drivers/net/wireless/ath/ath10k/mac.c  | 18 ++
 2 files changed, 19 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index c7664d6569fa..1ab589296dff 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -314,6 +314,7 @@ struct ath10k_peer {
struct ieee80211_vif *vif;
struct ieee80211_sta *sta;
 
+   bool removed;
int vdev_id;
u8 addr[ETH_ALEN];
DECLARE_BITMAP(peer_ids, ATH10K_MAX_NUM_PEER_IDS);
diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index d1b7edba5e49..aa91f55b35a4 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -3774,6 +3774,9 @@ struct ieee80211_txq *ath10k_mac_txq_lookup(struct ath10k 
*ar,
if (!peer)
return NULL;
 
+   if (peer->removed)
+   return NULL;
+
if (peer->sta)
return peer->sta->txq[tid];
else if (peer->vif)
@@ -7476,6 +7479,20 @@ ath10k_mac_op_switch_vif_chanctx(struct ieee80211_hw *hw,
return 0;
 }
 
+static void ath10k_mac_op_sta_pre_rcu_remove(struct ieee80211_hw *hw,
+struct ieee80211_vif *vif,
+struct ieee80211_sta *sta)
+{
+   struct ath10k *ar;
+   struct ath10k_peer *peer;
+
+   ar = hw->priv;
+
+   list_for_each_entry(peer, >peers, list)
+   if (peer->sta == sta)
+   peer->removed = true;
+}
+
 static const struct ieee80211_ops ath10k_ops = {
.tx = ath10k_mac_op_tx,
.wake_tx_queue  = ath10k_mac_op_wake_tx_queue,
@@ -7516,6 +7533,7 @@ static const struct ieee80211_ops ath10k_ops = {
.assign_vif_chanctx = ath10k_mac_op_assign_vif_chanctx,
.unassign_vif_chanctx   = ath10k_mac_op_unassign_vif_chanctx,
.switch_vif_chanctx = ath10k_mac_op_switch_vif_chanctx,
+   .sta_pre_rcu_remove = ath10k_mac_op_sta_pre_rcu_remove,
 
CFG80211_TESTMODE_CMD(ath10k_tm_cmd)
 
-- 
2.1.4



Re: [next] rtlwifi: rtl8192de: fix missing curly braces

2017-01-12 Thread Kalle Valo
Vincent  wrote:
> Restore some curly braces that have been removed in commit c93ac39da006457f
> ("rtlwifi: Remove some redundant code") while removing redundant messages
> and extraneous braces.
> 
> This fixes the following smatch warning:
> 
>   drivers/net/wireless/realtek/rtlwifi/rtl8192de/fw.c:326 
> rtl92d_download_fw() warn: curly braces intended?
> 
> ...and the following coccinelle warning:
> 
>   drivers/net/wireless/realtek/rtlwifi/rtl8192de/fw.c:325:2-38: code aligned 
> with following code on line 326
> 
> Fixes: c93ac39da006457f ("rtlwifi: Remove some redundant code")
> Signed-off-by: Vincent Stehlé 
> Cc: Larry Finger 
> Cc: Kalle Valo 
> Cc: Joe Perches 
> Cc: Ping-Ke Shih 

Larry also sent a fix:

rtlwifi: rtl8192de: Remove a pointless goto
https://patchwork.kernel.org/patch/9508121/

Patch set to Superseded.

-- 
https://patchwork.kernel.org/patch/9506837/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



Re: [PATCH 3/3] cfg80211: Specify the reason for connect timeout

2017-01-12 Thread Malinen, Jouni
On Thu, Jan 12, 2017 at 03:32:20PM +0100, Johannes Berg wrote:
> 
> > We don't.. This discussion here is about the C API where we cannot
> > remove the argument from the call without adding yet another inline
> > wrapper, but the actual function that generates the netlink message
> > does not add the timeout reason attribute for success or explicit
> > rejection cases.
> 
> Ah. But we can just say here then that it's ignored in those cases, and
> not really worry about it?

Sure, I'll update the comment to say that.

-- 
Jouni MalinenPGP id EFC895FA

Re: mwifiex: don't include mac80211.h

2017-01-12 Thread Kalle Valo
Johannes Berg  wrote:
> From: Johannes Berg 
> 
> This driver doesn't use mac80211, so it shouldn't include mac80211.h,
> include only the necessary cfg80211.h instead.
> 
> Signed-off-by: Johannes Berg 

Depends on:

3db5e3e707eb wireless: move IEEE80211_NUM_ACS to ieee80211.h

Currently in mac80211-next.

Patch set to Awaiting Upstream.

-- 
https://patchwork.kernel.org/patch/9498969/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



Re: [PATCH] mac80211: prevent skb/txq mismatch

2017-01-12 Thread Mohammed Shafi Shajakhan
On Thu, Jan 12, 2017 at 03:51:20PM +0100, Johannes Berg wrote:
> On Thu, 2017-01-12 at 20:15 +0530, Mohammed Shafi Shajakhan wrote:
> > 
> > > Reported-by: Mohammed Shafi Shajakhan 
> > > Signed-off-by: Michal Kazior 
> > 
> > Signed-off-by: Mohammed Shafi Shajakhan 
> 
> That makes no sense, you're not handling the patch in any way. You can
> say Tested-by, or Acked-by if you like, but not S-o-b. See the DCO
> (Documentation/SubmittingPatches)
>
apologies for that, I assumed we can add Signed-off on the fly


Re: [1/2] mwifiex: code rearrangement in pcie.c and sdio.c

2017-01-12 Thread Kalle Valo
Amitkumar Karwar  writes:

>> But these didn't. Can you please rebase these and resubmit in one
>> patchset? Less conflicts that way.
>> 
>
> The problem here is you tried to apply the patches in reverse order. Sorry 
> for the confusion.
> Please apply pending patches in below order.
>
> [v3,1/5] mwifiex: don't wait for main_process in shutdown_drv --- Apply this 
> patch first.
> [v3,2/5] mwifiex: do not free firmware dump memory in shutdown_drv
> [v3,3/5] mwifiex: get rid of drv_info* adapter variables
> [v3,4/5] mwifiex: wait firmware dump complete during card remove process
> [v3,5/5] mwifiex: move pcie_work and related variables inside card
>
> [1/2] mwifiex: code rearrangement in pcie.c and sdio.c
> [2/2] mwifiex: get rid of global user_rmmod flag
>
> mwifiex: use module_*_driver helper macros
>
> [1/5] mwifiex: get rid of mwifiex_do_flr wrapper
> [2/5] mwifiex: cleanup in PCIe flr code path
> [3/5] mwifiex: sdio card reset enhancement
> [4/5] mwifiex: get rid of __mwifiex_sdio_remove helper 
> [5/5] mwifiex: get rid of global save_adapter and sdio_work

Thanks, now I was able to apply these but please do double check the
result in wireless-drivers-next.

I also noticed a new warning:

drivers/net/wireless/marvell/mwifiex/pcie.c: In function 'mwifiex_pcie_remove':
drivers/net/wireless/marvell/mwifiex/pcie.c:303:5: warning: 'fw_status'
may be used uninitialized in this function [-Wmaybe-uninitialized]
  if (fw_status == FIRMWARE_READY_PCIE && !adapter->mfg_mode) {

Actually I'm not sure if this warning was caused by these patches as I
have recently updated my ancient gcc to a newer one (5.4.0), but please
take a look and send a fix if it's a valid warning.

-- 
Kalle Valo


Re: [v3,1/5] mwifiex: don't wait for main_process in shutdown_drv

2017-01-12 Thread Kalle Valo
Amitkumar Karwar  wrote:
> From: Xinming Hu 
> 
> main_process is not expected to be running when shutdown_drv function
> is called. currently we wait for main_process completion in the
> function.
> 
> Actually the caller has already made sure main_process is completed by
> performing below actions.
> (1) disable interrupts in if_ops->disable_int.
> (2) set adapter->surprise_removed = true, main_process wont be queued.
> (3) mwifiex_terminate_workqueue(adapter), wait for workqueue to be
> completed.
> 
> This patch removes redundant wait code and takes care of related
> cleanup.
> 
> Signed-off-by: Xinming Hu 
> Signed-off-by: Amitkumar Karwar 

5 patches applied to wireless-drivers-next.git, thanks.

5bf15e3fb85d mwifiex: don't wait for main_process in shutdown_drv
fb45bd0c6d6b mwifiex: do not free firmware dump memory in shutdown_drv
d27121fca129 mwifiex: get rid of drv_info* adapter variables
41efaf5824e7 mwifiex: wait firmware dump complete during card remove process
3860e5e39532 mwifiex: move pcie_work and related variables inside card

-- 
https://patchwork.kernel.org/patch/9431485/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



Re: [PATCH] mac80211: prevent skb/txq mismatch

2017-01-12 Thread Mohammed Shafi Shajakhan
On Thu, Jan 12, 2017 at 03:28:41PM +0100, Michal Kazior wrote:
> Station structure is considered as not uploaded
> (to driver) until drv_sta_state() finishes. This
> call is however done after the structure is
> attached to mac80211 internal lists and hashes.
> This means mac80211 can lookup (and use) station
> structure before it is uploaded to a driver.
> 
> If this happens (structure exists, but
> sta->uploaded is false) fast_tx path can still be
> taken. Deep in the fastpath call the sta->uploaded
> is checked against to derive "pubsta" argument for
> ieee80211_get_txq(). If sta->uploaded is false
> (and sta is actually non-NULL) ieee80211_get_txq()
> effectively downgraded to vif->txq.
> 
> At first glance this may look innocent but coerces
> mac80211 into a state that is almost guaranteed
> (codel may drop offending skb) to crash because a
> station-oriented skb gets queued up on
> vif-oriented txq. The ieee80211_tx_dequeue() ends
> up looking at info->control.flags and tries to use
> txq->sta which in the fail case is NULL.
> 
> It's probably pointless to pretend one can
> downgrade skb from sta-txq to vif-txq.
> 
> Only drivers using wake_tx_queue were affected.
> 
> Example crash dump before fix:
> 
>  Unable to handle kernel paging request at virtual address e26c
>  PC is at ieee80211_tx_dequeue+0x204/0x690 [mac80211]
>  [] (ieee80211_tx_dequeue [mac80211]) from
>  [] (ath10k_mac_tx_push_txq+0x54/0x1c0 [ath10k_core])
>  [] (ath10k_mac_tx_push_txq [ath10k_core]) from
>  [] (ath10k_htt_txrx_compl_task+0xd78/0x11d0 [ath10k_core])
>  [] (ath10k_htt_txrx_compl_task [ath10k_core])
>  [] (ath10k_pci_napi_poll+0x54/0xe8 [ath10k_pci])
>  [] (ath10k_pci_napi_poll [ath10k_pci]) from
>  [] (net_rx_action+0xac/0x160)
> 
> Reported-by: Mohammed Shafi Shajakhan 
> Signed-off-by: Michal Kazior 
Signed-off-by: Mohammed Shafi Shajakhan 

> ---
>  net/mac80211/tx.c | 17 +++--
>  1 file changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
> index 4dea18be385c..c77fcf83d004 100644
> --- a/net/mac80211/tx.c
> +++ b/net/mac80211/tx.c
> @@ -1244,13 +1244,16 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data 
> *sdata,
>  
>  static struct txq_info *ieee80211_get_txq(struct ieee80211_local *local,
> struct ieee80211_vif *vif,
> -   struct ieee80211_sta *pubsta,
> +   struct sta_info *sta,
> struct sk_buff *skb)
>  {
>   struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
>   struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
>   struct ieee80211_txq *txq = NULL;
>  
> + if (sta && !sta->uploaded)
> + return NULL;
> +
>   if ((info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) ||
>   (info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE))
>   return NULL;
> @@ -1258,10 +1261,10 @@ static struct txq_info *ieee80211_get_txq(struct 
> ieee80211_local *local,
>   if (!ieee80211_is_data(hdr->frame_control))
>   return NULL;
>  
> - if (pubsta) {
> + if (sta) {
>   u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK;
>  
> - txq = pubsta->txq[tid];
> + txq = sta->sta.txq[tid];
>   } else if (vif) {
>   txq = vif->txq;
>   }
> @@ -1504,23 +1507,17 @@ static bool ieee80211_queue_skb(struct 
> ieee80211_local *local,
>   struct fq *fq = >fq;
>   struct ieee80211_vif *vif;
>   struct txq_info *txqi;
> - struct ieee80211_sta *pubsta;
>  
>   if (!local->ops->wake_tx_queue ||
>   sdata->vif.type == NL80211_IFTYPE_MONITOR)
>   return false;
>  
> - if (sta && sta->uploaded)
> - pubsta = >sta;
> - else
> - pubsta = NULL;
> -
>   if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
>   sdata = container_of(sdata->bss,
>struct ieee80211_sub_if_data, u.ap);
>  
>   vif = >vif;
> - txqi = ieee80211_get_txq(local, vif, pubsta, skb);
> + txqi = ieee80211_get_txq(local, vif, sta, skb);
>  
>   if (!txqi)
>   return false;
> -- 
> 2.1.4
> 


Re: [PATCH] mac80211: prevent skb/txq mismatch

2017-01-12 Thread Johannes Berg
On Thu, 2017-01-12 at 20:15 +0530, Mohammed Shafi Shajakhan wrote:
> 
> > Reported-by: Mohammed Shafi Shajakhan 
> > Signed-off-by: Michal Kazior 
> 
> Signed-off-by: Mohammed Shafi Shajakhan 

That makes no sense, you're not handling the patch in any way. You can
say Tested-by, or Acked-by if you like, but not S-o-b. See the DCO
(Documentation/SubmittingPatches)

johannes


Re: mwifiex: use module_*_driver helper macros

2017-01-12 Thread Kalle Valo
Amitkumar Karwar  wrote:
> After user_rmmod global flag removal, *_init_module() and
> *_cleanup_module() have become just a wrapper functions.
> We will get rid of them with the help of module_*_driver() macros.
> 
> For pcie, existing ".init_if" handler has same name as what
> module_pcie_driver() macro will create. Let's rename it to
> avoid conflict.
> 
> Signed-off-by: Amitkumar Karwar 

Patch applied to wireless-drivers-next.git, thanks.

c0e6aa426823 mwifiex: use module_*_driver helper macros

-- 
https://patchwork.kernel.org/patch/9456135/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



Re: [1/5] mwifiex: get rid of mwifiex_do_flr wrapper

2017-01-12 Thread Kalle Valo
Amitkumar Karwar  wrote:
> From: Xinming Hu 
> 
> This patch gets rid of mwifiex_do_flr. We will call
> mwifiex_shutdown_sw() and mwifiex_reinit_sw() directly.
> These two general purpose functions will be useful for
> sdio card reset handler.
> 
> Signed-off-by: Xinming Hu 
> Signed-off-by: Amitkumar Karwar 

5 patches applied to wireless-drivers-next.git, thanks.

8750ab6236b0 mwifiex: get rid of mwifiex_do_flr wrapper
ec750f1082d7 mwifiex: cleanup in PCIe flr code path
c742e623e941 mwifiex: sdio card reset enhancement
a7513a4fa919 mwifiex: get rid of __mwifiex_sdio_remove helper
cc75c577806a mwifiex: get rid of global save_adapter and sdio_work

-- 
https://patchwork.kernel.org/patch/9474231/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



Re: [1/2] mwifiex: code rearrangement in pcie.c and sdio.c

2017-01-12 Thread Kalle Valo
Amitkumar Karwar  wrote:
> From: Xinming Hu 
> 
> Next patch in this series is going to use mwifiex_read_reg() in remove
> handlers. The changes here are prerequisites to avoid forward
> declarations.
> 
> Signed-off-by: Xinming Hu 
> Signed-off-by: Amitkumar Karwar 

2 patches applied to wireless-drivers-next.git, thanks.

90ff71f95575 mwifiex: code rearrangement in pcie.c and sdio.c
045f0c1b5e26 mwifiex: get rid of global user_rmmod flag

-- 
https://patchwork.kernel.org/patch/9454491/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



Re: [PATCH 3/3] cfg80211: Specify the reason for connect timeout

2017-01-12 Thread Johannes Berg

> We don't.. This discussion here is about the C API where we cannot
> remove the argument from the call without adding yet another inline
> wrapper, but the actual function that generates the netlink message
> does not add the timeout reason attribute for success or explicit
> rejection cases.

Ah. But we can just say here then that it's ignored in those cases, and
not really worry about it?

johannes


Re: [PATCH 3/3] cfg80211: Specify the reason for connect timeout

2017-01-12 Thread Malinen, Jouni
On Thu, Jan 12, 2017 at 03:06:19PM +0100, Johannes Berg wrote:
> On Thu, 2017-01-12 at 13:58 +, Malinen, Jouni wrote:
> > 
> > > I think this description is misleading - one could easily
> > > understand
> > > "for other cases" to indicate for the cases that the AP did
> > > explicitly
> > > reject it, but that's obviously not true.
> > 
> > Well, the expectation here really was that the reason for the timeout
> > would be known if there was a timeout and the unspecified value would
> > be used in all other cases, i.e., in cases where the AP did indeed
> > explicitly reject the connection.
> 
> Hmm. It doesn't really make sense to include the attribute in that case
> at all though, does it?

We don't.. This discussion here is about the C API where we cannot
remove the argument from the call without adding yet another inline
wrapper, but the actual function that generates the netlink message does
not add the timeout reason attribute for success or explicit rejection
cases.

> > Sure, I can say that NL80211_TIMEOUT_UNSPECIFIED is used when the
> > reason for the timeout is not known or there was an explicit
> > rejection instead of a timeout.
> 
> See above - why even think about this attribute in the successful case?

See above.. C API. Or do you want yet another wrapper for
cfg80211_connect_bss() to be added while trying to hide
cfg80211_connect_bss() from drivers somehow?

> Fair enough. I still think we should not include the
> ATTR_TIMEOUT_REASON for the successful or explicit rejection case at
> all though. We can really even distinguish that in the low-level
> function, I think?

nl80211_send_connect_result() already does this:

(status < 0 &&
 (nla_put_flag(msg, NL80211_ATTR_TIMED_OUT) ||
  nla_put_u32(msg, NL80211_ATTR_TIMEOUT_REASON, timeout_reason))) ||

That status == -1 special case used to be internal special value within
cfg80211, but it gets exposed to drivers since we use
cfg80211_connect_bss() both internally and from drivers instead of
having separate wrappers for drivers for cases where the bss entry is
explicitly specified.

-- 
Jouni MalinenPGP id EFC895FA

[PATCH] mac80211: prevent skb/txq mismatch

2017-01-12 Thread Michal Kazior
Station structure is considered as not uploaded
(to driver) until drv_sta_state() finishes. This
call is however done after the structure is
attached to mac80211 internal lists and hashes.
This means mac80211 can lookup (and use) station
structure before it is uploaded to a driver.

If this happens (structure exists, but
sta->uploaded is false) fast_tx path can still be
taken. Deep in the fastpath call the sta->uploaded
is checked against to derive "pubsta" argument for
ieee80211_get_txq(). If sta->uploaded is false
(and sta is actually non-NULL) ieee80211_get_txq()
effectively downgraded to vif->txq.

At first glance this may look innocent but coerces
mac80211 into a state that is almost guaranteed
(codel may drop offending skb) to crash because a
station-oriented skb gets queued up on
vif-oriented txq. The ieee80211_tx_dequeue() ends
up looking at info->control.flags and tries to use
txq->sta which in the fail case is NULL.

It's probably pointless to pretend one can
downgrade skb from sta-txq to vif-txq.

Only drivers using wake_tx_queue were affected.

Example crash dump before fix:

 Unable to handle kernel paging request at virtual address e26c
 PC is at ieee80211_tx_dequeue+0x204/0x690 [mac80211]
 [] (ieee80211_tx_dequeue [mac80211]) from
 [] (ath10k_mac_tx_push_txq+0x54/0x1c0 [ath10k_core])
 [] (ath10k_mac_tx_push_txq [ath10k_core]) from
 [] (ath10k_htt_txrx_compl_task+0xd78/0x11d0 [ath10k_core])
 [] (ath10k_htt_txrx_compl_task [ath10k_core])
 [] (ath10k_pci_napi_poll+0x54/0xe8 [ath10k_pci])
 [] (ath10k_pci_napi_poll [ath10k_pci]) from
 [] (net_rx_action+0xac/0x160)

Reported-by: Mohammed Shafi Shajakhan 
Signed-off-by: Michal Kazior 
---
 net/mac80211/tx.c | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 4dea18be385c..c77fcf83d004 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1244,13 +1244,16 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data 
*sdata,
 
 static struct txq_info *ieee80211_get_txq(struct ieee80211_local *local,
  struct ieee80211_vif *vif,
- struct ieee80211_sta *pubsta,
+ struct sta_info *sta,
  struct sk_buff *skb)
 {
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
struct ieee80211_txq *txq = NULL;
 
+   if (sta && !sta->uploaded)
+   return NULL;
+
if ((info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) ||
(info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE))
return NULL;
@@ -1258,10 +1261,10 @@ static struct txq_info *ieee80211_get_txq(struct 
ieee80211_local *local,
if (!ieee80211_is_data(hdr->frame_control))
return NULL;
 
-   if (pubsta) {
+   if (sta) {
u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK;
 
-   txq = pubsta->txq[tid];
+   txq = sta->sta.txq[tid];
} else if (vif) {
txq = vif->txq;
}
@@ -1504,23 +1507,17 @@ static bool ieee80211_queue_skb(struct ieee80211_local 
*local,
struct fq *fq = >fq;
struct ieee80211_vif *vif;
struct txq_info *txqi;
-   struct ieee80211_sta *pubsta;
 
if (!local->ops->wake_tx_queue ||
sdata->vif.type == NL80211_IFTYPE_MONITOR)
return false;
 
-   if (sta && sta->uploaded)
-   pubsta = >sta;
-   else
-   pubsta = NULL;
-
if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
sdata = container_of(sdata->bss,
 struct ieee80211_sub_if_data, u.ap);
 
vif = >vif;
-   txqi = ieee80211_get_txq(local, vif, pubsta, skb);
+   txqi = ieee80211_get_txq(local, vif, sta, skb);
 
if (!txqi)
return false;
-- 
2.1.4



Re: [PATCH 3/3] cfg80211: Specify the reason for connect timeout

2017-01-12 Thread Johannes Berg
On Thu, 2017-01-12 at 13:58 +, Malinen, Jouni wrote:
> 
> > I think this description is misleading - one could easily
> > understand
> > "for other cases" to indicate for the cases that the AP did
> > explicitly
> > reject it, but that's obviously not true.
> 
> Well, the expectation here really was that the reason for the timeout
> would be known if there was a timeout and the unspecified value would
> be used in all other cases, i.e., in cases where the AP did indeed
> explicitly reject the connection.

Hmm. It doesn't really make sense to include the attribute in that case
at all though, does it?

> I guess there might be a driver where the connect request goes into
> firmware implementation and the driver would not know whether the
> operation failed due to authentication frame or association frame
> timeout out.. Implementation itself would still be fine, but I agree
> that it might be a bit confusing the try to interpret the description
> here on what the driver should do.
> 
> > Perhaps that could be reworded, to say it's used when it's not
> > known,
> > or such? I'd not indicate the value (0) either, just specify the
> > name,
> > and put a % in front to get better formatting for it please.
> 
> Sure, I can say that NL80211_TIMEOUT_UNSPECIFIED is used when the
> reason for the timeout is not known or there was an explicit
> rejection instead of a timeout.

See above - why even think about this attribute in the successful case?

> That said, cfg80211_connect_bss() is really currently documented to
> be used only for the success case just like
> cfg80211_connect_result(). In other words, if a driver were to call
> cfg80211_connect_bss(), it should really always specify
> NL80211_TIMEOUT_UNSPECIFIED here based on the current documented us.

> All failure would then need to be reported with
> cfg80211_connect_timeout() for the timeout case or by not following
> the documentation and calling cfg80211_connect_result() or
> cfg80211_connect_bss() for rejection cases. That said, the
> documentation for the connect() callback function does describe the
> failure case behavior correctly. I think I cleaned up that at some
> point, but did not update the function documentation at the same
> time.

Ok.

> So it looks like some additional cleanup would be needed to make the
> documentation actually match what we expect the driver to do for
> rejection cases.. I'd like to leave it out from this specific patch
> and address the cleanup of existing failure case description in a
> separate patch.

Fair enough. I still think we should not include the
ATTR_TIMEOUT_REASON for the successful or explicit rejection case at
all though. We can really even distinguish that in the low-level
function, I think?

johannes


Re: [PATCH 3/3] cfg80211: Specify the reason for connect timeout

2017-01-12 Thread Malinen, Jouni
On Wed, Jan 11, 2017 at 02:26:06PM +0100, Johannes Berg wrote:
> On Wed, 2017-01-11 at 13:13 +, Malinen, Jouni wrote:
> > 
> > > > @@ -172,6 +174,7 @@ static int cfg80211_conn_do_work(struct
> > > > wireless_dev *wdev)
> > > >     case CFG80211_CONN_AUTH_FAILED:
> > > > +   *treason = NL80211_TIMEOUT_AUTH;
> > > 
> > > ... but it seems AUTH failure always is a timeout?
> > 
> > The CFG80211_CONN_AUTH_FAILED case is currently used only in
> > cfg80211_sme_auth_timeout() which is indeed always a timeout.
> 
> Might be worth simply renaming it, since you have the reason there
> unconditionally?

Sure, that sounds fine and documents the existing case more accurately.

-- 
Jouni MalinenPGP id EFC895FA

Re: [PATCH 3/3] cfg80211: Specify the reason for connect timeout

2017-01-12 Thread Malinen, Jouni
On Wed, Jan 11, 2017 at 02:31:31PM +0100, Johannes Berg wrote:
> > + * @timeout_reason: reason for connection timeout. This is used when
> > the
> > + * connection fails due to a timeout instead of an explicit
> > rejection from
> > + * the AP. 0 (NL80211_CONNECT_TIMEOUT_UNSPECIFIED) is used
> > for other cases.
> 
> I think this description is misleading - one could easily understand
> "for other cases" to indicate for the cases that the AP did explicitly
> reject it, but that's obviously not true.

Well, the expectation here really was that the reason for the timeout
would be known if there was a timeout and the unspecified value would be
used in all other cases, i.e., in cases where the AP did indeed
explicitly reject the connection.

I guess there might be a driver where the connect request goes into
firmware implementation and the driver would not know whether the
operation failed due to authentication frame or association frame
timeout out.. Implementation itself would still be fine, but I agree
that it might be a bit confusing the try to interpret the description
here on what the driver should do.

> Perhaps that could be reworded, to say it's used when it's not known,
> or such? I'd not indicate the value (0) either, just specify the name,
> and put a % in front to get better formatting for it please.

Sure, I can say that NL80211_TIMEOUT_UNSPECIFIED is used when the reason
for the timeout is not known or there was an explicit rejection instead
of a timeout.

That said, cfg80211_connect_bss() is really currently documented to be
used only for the success case just like cfg80211_connect_result(). In
other words, if a driver were to call cfg80211_connect_bss(), it should
really always specify NL80211_TIMEOUT_UNSPECIFIED here based on the
current documented use. All failure would then need to be reported with
cfg80211_connect_timeout() for the timeout case or by not following the
documentation and calling cfg80211_connect_result() or
cfg80211_connect_bss() for rejection cases. That said, the documentation
for the connect() callback function does describe the failure case
behavior correctly. I think I cleaned up that at some point, but did not
update the function documentation at the same time.

So it looks like some additional cleanup would be needed to make the
documentation actually match what we expect the driver to do for
rejection cases.. I'd like to leave it out from this specific patch and
address the cleanup of existing failure case description in a separate
patch.

> > +    NL80211_TIMEOUT_UNSPECIFIED);
> 
> NL80211_CONNECT_TIMEOUT_UNSPECIFIED in the comment is wrong then.

Yeah, these got renamed at some point and looks like that one was
missed.

-- 
Jouni MalinenPGP id EFC895FA

RE: [PATCH v3 1/3] cfg80211: Add support to sched scan to report better BSSs

2017-01-12 Thread Vamsi, Krishna

> -Original Message-
> From: Johannes Berg [mailto:johan...@sipsolutions.net]
 
> > > So you see a use-case for doing a scan with @relative_rssi being
> > > zero, right?
> >
> > Yes. Zero value for relative_rssi is also valid.
> 
> Or negative even, I guess?

Yes, this can be negative also.
 
> > I like to leave this as s8 only. This will leave more flexibility to
> > userspace especially in case of more than two bands in future.
> 
> I guess you should reword that - instead of "better" it should say how this 
> value
> is applied, as a delta to the current RSSI, and then reporting the result.
> 
> However, I don't understand your comment about this being related to multiple
> bands, can you clarify? The relative_rssi just determines the filter after the
> adjustment(s) done with rssi_adjust, but how could it be relevant?
> 
> The only use case for relative_rssi being negative would be when you actually
> *want* to see slightly worse networks than the one you're connected to, e.g. 
> to
> determine if you should use them because they have better parameters (e.g.
> HT/VHT or soon HE).

I would like to swallow my words. There is something wrong with my earlier 
thinking.
 
 
> >
> > @relative_rssi is valid only when @relative_rssi_set is set to true
> > and @rssi_adjust is valid only when @relative_rssi is valid. I think
> > that is understandable to drivers and there is no need of explicit
> > check here.
> 
> It wouldn't be problematic to parse the RSSI_ADJUST only when the others are
> present though, so that a driver could apply the rssi_adjust unconditionally
> (since, if it's not parsed, the delta will be 0.)

Sure, will take care of this in the next patch.

Thanks,
Vamsi


[PATCH v2 04/13] wil6210: remove __func__ from debug printouts

2017-01-12 Thread Maya Erez
From: Lazar Alexei 

__func__ is automatically added to printouts by dynamic debug
mechanism and by wil_info/wil_err macros.
Remove __func__ from debug printouts to avoid duplication.

Signed-off-by: Lazar Alexei 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/cfg80211.c   | 79 +++
 drivers/net/wireless/ath/wil6210/debugfs.c|  4 +-
 drivers/net/wireless/ath/wil6210/ethtool.c| 10 +--
 drivers/net/wireless/ath/wil6210/interrupt.c  | 30 -
 drivers/net/wireless/ath/wil6210/main.c   | 50 +++---
 drivers/net/wireless/ath/wil6210/netdev.c | 14 ++--
 drivers/net/wireless/ath/wil6210/p2p.c| 36 +--
 drivers/net/wireless/ath/wil6210/pcie_bus.c   | 14 ++--
 drivers/net/wireless/ath/wil6210/pm.c | 17 ++---
 drivers/net/wireless/ath/wil6210/pmc.c| 79 +++
 drivers/net/wireless/ath/wil6210/rx_reorder.c |  8 +--
 drivers/net/wireless/ath/wil6210/txrx.c   | 36 ++-
 drivers/net/wireless/ath/wil6210/wil_crash_dump.c | 18 +++---
 drivers/net/wireless/ath/wil6210/wmi.c| 50 +++---
 14 files changed, 211 insertions(+), 234 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c 
b/drivers/net/wireless/ath/wil6210/cfg80211.c
index e6001bb..f8499a8 100644
--- a/drivers/net/wireless/ath/wil6210/cfg80211.c
+++ b/drivers/net/wireless/ath/wil6210/cfg80211.c
@@ -205,7 +205,7 @@ static int wil_cfg80211_get_station(struct wiphy *wiphy,
 
int cid = wil_find_cid(wil, mac);
 
-   wil_dbg_misc(wil, "%s(%pM) CID %d\n", __func__, mac, cid);
+   wil_dbg_misc(wil, "get_station: %pM CID %d\n", mac, cid);
if (cid < 0)
return cid;
 
@@ -244,7 +244,7 @@ static int wil_cfg80211_dump_station(struct wiphy *wiphy,
return -ENOENT;
 
ether_addr_copy(mac, wil->sta[cid].addr);
-   wil_dbg_misc(wil, "%s(%pM) CID %d\n", __func__, mac, cid);
+   wil_dbg_misc(wil, "dump_station: %pM CID %d\n", mac, cid);
 
rc = wil_cid_fill_sinfo(wil, cid, sinfo);
 
@@ -261,16 +261,15 @@ static int wil_cfg80211_dump_station(struct wiphy *wiphy,
struct net_device *ndev = wil_to_ndev(wil);
struct wireless_dev *p2p_wdev;
 
-   wil_dbg_misc(wil, "%s()\n", __func__);
+   wil_dbg_misc(wil, "add_iface\n");
 
if (type != NL80211_IFTYPE_P2P_DEVICE) {
-   wil_err(wil, "%s: unsupported iftype %d\n", __func__, type);
+   wil_err(wil, "unsupported iftype %d\n", type);
return ERR_PTR(-EINVAL);
}
 
if (wil->p2p_wdev) {
-   wil_err(wil, "%s: P2P_DEVICE interface already created\n",
-   __func__);
+   wil_err(wil, "P2P_DEVICE interface already created\n");
return ERR_PTR(-EINVAL);
}
 
@@ -293,11 +292,10 @@ static int wil_cfg80211_del_iface(struct wiphy *wiphy,
 {
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
 
-   wil_dbg_misc(wil, "%s()\n", __func__);
+   wil_dbg_misc(wil, "del_iface\n");
 
if (wdev != wil->p2p_wdev) {
-   wil_err(wil, "%s: delete of incorrect interface 0x%p\n",
-   __func__, wdev);
+   wil_err(wil, "delete of incorrect interface 0x%p\n", wdev);
return -EINVAL;
}
 
@@ -315,7 +313,7 @@ static int wil_cfg80211_change_iface(struct wiphy *wiphy,
struct wireless_dev *wdev = wil_to_wdev(wil);
int rc;
 
-   wil_dbg_misc(wil, "%s() type=%d\n", __func__, type);
+   wil_dbg_misc(wil, "change_iface: type=%d\n", type);
 
if (netif_running(wil_to_ndev(wil)) && !wil_is_recovery_blocked(wil)) {
wil_dbg_misc(wil, "interface is up. resetting...\n");
@@ -362,8 +360,7 @@ static int wil_cfg80211_scan(struct wiphy *wiphy,
uint i, n;
int rc;
 
-   wil_dbg_misc(wil, "%s(), wdev=0x%p iftype=%d\n",
-__func__, wdev, wdev->iftype);
+   wil_dbg_misc(wil, "scan: wdev=0x%p iftype=%d\n", wdev, wdev->iftype);
 
/* check we are client side */
switch (wdev->iftype) {
@@ -568,7 +565,7 @@ static int wil_cfg80211_connect(struct wiphy *wiphy,
int rc = 0;
enum ieee80211_bss_type bss_type = IEEE80211_BSS_TYPE_ESS;
 
-   wil_dbg_misc(wil, "%s()\n", __func__);
+   wil_dbg_misc(wil, "connect\n");
wil_print_connect_params(wil, sme);
 
if (test_bit(wil_status_fwconnecting, wil->status) ||
@@ -700,12 +697,11 @@ static int wil_cfg80211_disconnect(struct wiphy *wiphy,
int rc;
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
 
-   wil_dbg_misc(wil, "%s(reason=%d)\n", __func__, reason_code);
+   wil_dbg_misc(wil, "disconnect: reason=%d\n", reason_code);
 
if (!(test_bit(wil_status_fwconnecting, wil->status) ||
  

[PATCH v2 01/13] wil6210: add sysfs file for FTM calibration

2017-01-12 Thread Maya Erez
From: Lior David 

In fine timing measurements, the calculation is affected by
2 parts: timing of packets over the air, which is platform
independent, and platform-specific delays, which are dependent
on things like antenna cable length and type.
Add a sysfs file which allows to get/set these platform specific
delays, separated into the TX and RX components.
There are 2 key scenarios where the file can be used:
1. Calibration - start with some initial values (for example,
the default values at startup), make measurements at a known
distance, then iteratively change the values until the
measurement results match the known distance.
2. Adjust the delays when platform starts up, based on known
values.

Signed-off-by: Lior David 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/Makefile   |   1 +
 drivers/net/wireless/ath/wil6210/pcie_bus.c |   4 +-
 drivers/net/wireless/ath/wil6210/sysfs.c| 126 
 drivers/net/wireless/ath/wil6210/wil6210.h  |   4 +-
 4 files changed, 133 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/wireless/ath/wil6210/sysfs.c

diff --git a/drivers/net/wireless/ath/wil6210/Makefile 
b/drivers/net/wireless/ath/wil6210/Makefile
index 89bf2f9..2521343 100644
--- a/drivers/net/wireless/ath/wil6210/Makefile
+++ b/drivers/net/wireless/ath/wil6210/Makefile
@@ -5,6 +5,7 @@ wil6210-y += netdev.o
 wil6210-y += cfg80211.o
 wil6210-y += pcie_bus.o
 wil6210-y += debugfs.o
+wil6210-y += sysfs.o
 wil6210-y += wmi.o
 wil6210-y += interrupt.o
 wil6210-y += txrx.o
diff --git a/drivers/net/wireless/ath/wil6210/pcie_bus.c 
b/drivers/net/wireless/ath/wil6210/pcie_bus.c
index 44746ca..6b8f4d21 100644
--- a/drivers/net/wireless/ath/wil6210/pcie_bus.c
+++ b/drivers/net/wireless/ath/wil6210/pcie_bus.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2016 Qualcomm Atheros, Inc.
+ * Copyright (c) 2012-2017 Qualcomm Atheros, Inc.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -263,6 +263,7 @@ static int wil_pcie_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
 #endif /* CONFIG_PM */
 
wil6210_debugfs_init(wil);
+   wil6210_sysfs_init(wil);
 
 
return 0;
@@ -297,6 +298,7 @@ static void wil_pcie_remove(struct pci_dev *pdev)
 #endif /* CONFIG_PM_SLEEP */
 #endif /* CONFIG_PM */
 
+   wil6210_sysfs_remove(wil);
wil6210_debugfs_remove(wil);
rtnl_lock();
wil_p2p_wdev_free(wil);
diff --git a/drivers/net/wireless/ath/wil6210/sysfs.c 
b/drivers/net/wireless/ath/wil6210/sysfs.c
new file mode 100644
index 000..768f37c
--- /dev/null
+++ b/drivers/net/wireless/ath/wil6210/sysfs.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2017 Qualcomm Atheros, Inc.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include 
+#include 
+
+#include "wil6210.h"
+#include "wmi.h"
+
+static ssize_t
+wil_ftm_txrx_offset_sysfs_show(struct device *dev,
+  struct device_attribute *attr,
+  char *buf)
+{
+   struct wil6210_priv *wil = dev_get_drvdata(dev);
+   struct {
+   struct wmi_cmd_hdr wmi;
+   struct wmi_tof_get_tx_rx_offset_event evt;
+   } __packed reply;
+   int rc;
+   ssize_t len;
+
+   if (!test_bit(WMI_FW_CAPABILITY_FTM, wil->fw_capabilities))
+   return -EOPNOTSUPP;
+
+   memset(, 0, sizeof(reply));
+   rc = wmi_call(wil, WMI_TOF_GET_TX_RX_OFFSET_CMDID, NULL, 0,
+ WMI_TOF_GET_TX_RX_OFFSET_EVENTID,
+ , sizeof(reply), 100);
+   if (rc < 0)
+   return rc;
+   if (reply.evt.status) {
+   wil_err(wil, "get_tof_tx_rx_offset failed, error %d\n",
+   reply.evt.status);
+   return -EIO;
+   }
+   len = snprintf(buf, PAGE_SIZE, "%d %d\n",
+  le32_to_cpu(reply.evt.tx_offset),
+  le32_to_cpu(reply.evt.rx_offset));
+   return len;
+}
+
+static ssize_t
+wil_ftm_txrx_offset_sysfs_store(struct device *dev,
+   struct device_attribute *attr,
+  

[PATCH v2 00/13] wil6210 patches

2017-01-12 Thread Maya Erez
The following set of patches include various wil6210 fixes
Changes from V1:
- Fix copyright year to 2017
- Add a patch to convert symbolic permissions to octal permissions to fix 
checkpatch
  errors and align to latest kernel preference
- Fix "set dma mask to reflect device capability" commit text


Dedy Lansky (2):
  wil6210: add disable_ap_sme module parameter
  wil6210: support new WMI-only FW capability

Hamad Kadmany (2):
  wil6210: protect against false interrupt during reset sequence
  wil6210: set dma mask to reflect device capability

Lazar Alexei (2):
  wil6210: support loading dedicated image for sparrow-plus devices
  wil6210: remove __func__ from debug printouts

Lior David (6):
  wil6210: add sysfs file for FTM calibration
  wil6210: missing reinit_completion in wmi_call
  wil6210: fix for broadcast workaround in PBSS
  wil6210: align to latest auto generated wmi.h
  wil6210: report association ID (AID) per station in debugfs
  wil6210: option to override A-BFT length in start AP/PCP

Maya Erez (1):
  wil6210: convert symbolic permissions to octal permissions

 drivers/net/wireless/ath/wil6210/Makefile |   1 +
 drivers/net/wireless/ath/wil6210/cfg80211.c   | 172 --
 drivers/net/wireless/ath/wil6210/debugfs.c| 136 -
 drivers/net/wireless/ath/wil6210/ethtool.c|  10 +-
 drivers/net/wireless/ath/wil6210/fw.c |   7 +-
 drivers/net/wireless/ath/wil6210/fw_inc.c |  21 ++-
 drivers/net/wireless/ath/wil6210/interrupt.c  |  30 ++--
 drivers/net/wireless/ath/wil6210/main.c   |  87 +--
 drivers/net/wireless/ath/wil6210/netdev.c |  17 ++-
 drivers/net/wireless/ath/wil6210/p2p.c|  36 ++---
 drivers/net/wireless/ath/wil6210/pcie_bus.c   |  77 +++---
 drivers/net/wireless/ath/wil6210/pm.c |  17 +--
 drivers/net/wireless/ath/wil6210/pmc.c|  79 +-
 drivers/net/wireless/ath/wil6210/rx_reorder.c |   8 +-
 drivers/net/wireless/ath/wil6210/sysfs.c  | 126 
 drivers/net/wireless/ath/wil6210/txrx.c   |  75 +-
 drivers/net/wireless/ath/wil6210/wil6210.h|  33 -
 drivers/net/wireless/ath/wil6210/wil_crash_dump.c |  18 +--
 drivers/net/wireless/ath/wil6210/wmi.c| 131 ++--
 drivers/net/wireless/ath/wil6210/wmi.h|  67 -
 20 files changed, 768 insertions(+), 380 deletions(-)
 create mode 100644 drivers/net/wireless/ath/wil6210/sysfs.c

-- 
1.9.1



[PATCH v2 03/13] wil6210: support loading dedicated image for sparrow-plus devices

2017-01-12 Thread Maya Erez
From: Lazar Alexei 

Driver may be used in platforms where some use sparrow cards while
other use sparrow-plus cards, where different FW image is needed.
Add the capability to load dedicated FW image in case sparrow-plus
card is detected and fallback to default image if such does not exist.

Signed-off-by: Lazar Alexei 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/debugfs.c  |  3 ++-
 drivers/net/wireless/ath/wil6210/fw.c   |  7 +++---
 drivers/net/wireless/ath/wil6210/fw_inc.c   | 21 -
 drivers/net/wireless/ath/wil6210/main.c |  8 +++
 drivers/net/wireless/ath/wil6210/pcie_bus.c | 36 ++---
 drivers/net/wireless/ath/wil6210/wil6210.h  | 18 +++
 6 files changed, 72 insertions(+), 21 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c 
b/drivers/net/wireless/ath/wil6210/debugfs.c
index 5e4058a..e5a8382 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2016 Qualcomm Atheros, Inc.
+ * Copyright (c) 2012-2017 Qualcomm Atheros, Inc.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -1699,6 +1699,7 @@ static void wil6210_debugfs_init_isr(struct wil6210_priv 
*wil,
WIL_FIELD(recovery_count, S_IRUGO,  doff_u32),
WIL_FIELD(ap_isolate,   S_IRUGO,doff_u32),
WIL_FIELD(discovery_mode, S_IRUGO | S_IWUSR,doff_u8),
+   WIL_FIELD(chip_revision, S_IRUGO,   doff_u8),
{},
 };
 
diff --git a/drivers/net/wireless/ath/wil6210/fw.c 
b/drivers/net/wireless/ath/wil6210/fw.c
index 82aae2d..540fc20 100644
--- a/drivers/net/wireless/ath/wil6210/fw.c
+++ b/drivers/net/wireless/ath/wil6210/fw.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2015 Qualcomm Atheros, Inc.
+ * Copyright (c) 2014-2015,2017 Qualcomm Atheros, Inc.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -19,8 +19,9 @@
 #include "wil6210.h"
 #include "fw.h"
 
-MODULE_FIRMWARE(WIL_FW_NAME);
-MODULE_FIRMWARE(WIL_FW2_NAME);
+MODULE_FIRMWARE(WIL_FW_NAME_DEFAULT);
+MODULE_FIRMWARE(WIL_FW_NAME_SPARROW_PLUS);
+MODULE_FIRMWARE(WIL_BOARD_FILE_NAME);
 
 static
 void wil_memset_toio_32(volatile void __iomem *dst, u32 val,
diff --git a/drivers/net/wireless/ath/wil6210/fw_inc.c 
b/drivers/net/wireless/ath/wil6210/fw_inc.c
index 8f40eb3..f4901587 100644
--- a/drivers/net/wireless/ath/wil6210/fw_inc.c
+++ b/drivers/net/wireless/ath/wil6210/fw_inc.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2016 Qualcomm Atheros, Inc.
+ * Copyright (c) 2014-2017 Qualcomm Atheros, Inc.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -537,3 +537,22 @@ int wil_request_firmware(struct wil6210_priv *wil, const 
char *name,
release_firmware(fw);
return rc;
 }
+
+/**
+ * wil_fw_verify_file_exists - checks if firmware file exist
+ *
+ * @wil: driver context
+ * @name: firmware file name
+ *
+ * return value - boolean, true for success, false for failure
+ */
+bool wil_fw_verify_file_exists(struct wil6210_priv *wil, const char *name)
+{
+   const struct firmware *fw;
+   int rc;
+
+   rc = request_firmware(, name, wil_to_dev(wil));
+   if (!rc)
+   release_firmware(fw);
+   return rc != -ENOENT;
+}
diff --git a/drivers/net/wireless/ath/wil6210/main.c 
b/drivers/net/wireless/ath/wil6210/main.c
index 57c19d0..3580c6d 100644
--- a/drivers/net/wireless/ath/wil6210/main.c
+++ b/drivers/net/wireless/ath/wil6210/main.c
@@ -934,16 +934,16 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw)
 
wil_set_oob_mode(wil, oob_mode);
if (load_fw) {
-   wil_info(wil, "Use firmware <%s> + board <%s>\n", WIL_FW_NAME,
-WIL_FW2_NAME);
+   wil_info(wil, "Use firmware <%s> + board <%s>\n",
+wil->wil_fw_name, WIL_BOARD_FILE_NAME);
 
wil_halt_cpu(wil);
memset(wil->fw_version, 0, sizeof(wil->fw_version));
/* Loading f/w from the file */
-   rc = wil_request_firmware(wil, WIL_FW_NAME, true);
+   rc = wil_request_firmware(wil, wil->wil_fw_name, true);
if (rc)
return rc;
-   rc = wil_request_firmware(wil, WIL_FW2_NAME, true);
+   rc = wil_request_firmware(wil, WIL_BOARD_FILE_NAME, true);
if (rc)
return rc;
 
diff --git a/drivers/net/wireless/ath/wil6210/pcie_bus.c 
b/drivers/net/wireless/ath/wil6210/pcie_bus.c
index 6b8f4d21..eab74c4 100644
--- 

[PATCH v2 02/13] wil6210: add disable_ap_sme module parameter

2017-01-12 Thread Maya Erez
From: Dedy Lansky 

By default, AP SME is handled by driver/FW.
In case disable_ap_sme is true, driver doesn't turn-on
WIPHY_FLAG_HAVE_AP_SME and the responsibility for
AP SME is passed to user space.

With AP SME disabled, driver reports assoc request frame
to user space which is then responsible for sending assoc
response frame and for sending NL80211_CMD_NEW_STATION.
Driver also reports disassoc frame to user space
which should then send NL80211_CMD_DEL_STATION.

NL80211_CMD_SET_STATION with NL80211_STA_FLAG_AUTHORIZED
is used by user space to allow/disallow data transmit.

Signed-off-by: Dedy Lansky 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/cfg80211.c | 92 +++--
 drivers/net/wireless/ath/wil6210/main.c | 10 +++-
 drivers/net/wireless/ath/wil6210/wil6210.h  |  9 ++-
 drivers/net/wireless/ath/wil6210/wmi.c  | 68 +
 drivers/net/wireless/ath/wil6210/wmi.h  | 23 +++-
 5 files changed, 178 insertions(+), 24 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c 
b/drivers/net/wireless/ath/wil6210/cfg80211.c
index 54dd116..e6001bb 100644
--- a/drivers/net/wireless/ath/wil6210/cfg80211.c
+++ b/drivers/net/wireless/ath/wil6210/cfg80211.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2016 Qualcomm Atheros, Inc.
+ * Copyright (c) 2012-2017 Qualcomm Atheros, Inc.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -20,6 +20,10 @@
 
 #define WIL_MAX_ROC_DURATION_MS 5000
 
+bool disable_ap_sme;
+module_param(disable_ap_sme, bool, S_IRUGO);
+MODULE_PARM_DESC(disable_ap_sme, " let user space handle AP mode SME");
+
 #define CHAN60G(_channel, _flags) {\
.band   = NL80211_BAND_60GHZ,   \
.center_freq= 56160 + (2160 * (_channel)),  \
@@ -62,9 +66,16 @@
},
[NL80211_IFTYPE_AP] = {
.tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
-   BIT(IEEE80211_STYPE_PROBE_RESP >> 4),
+   BIT(IEEE80211_STYPE_PROBE_RESP >> 4) |
+   BIT(IEEE80211_STYPE_ASSOC_RESP >> 4) |
+   BIT(IEEE80211_STYPE_DISASSOC >> 4),
.rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
-   BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
+   BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
+   BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
+   BIT(IEEE80211_STYPE_DISASSOC >> 4) |
+   BIT(IEEE80211_STYPE_AUTH >> 4) |
+   BIT(IEEE80211_STYPE_DEAUTH >> 4) |
+   BIT(IEEE80211_STYPE_REASSOC_REQ >> 4)
},
[NL80211_IFTYPE_P2P_CLIENT] = {
.tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
@@ -1322,6 +1333,28 @@ static int wil_cfg80211_stop_ap(struct wiphy *wiphy,
return 0;
 }
 
+static int wil_cfg80211_add_station(struct wiphy *wiphy,
+   struct net_device *dev,
+   const u8 *mac,
+   struct station_parameters *params)
+{
+   struct wil6210_priv *wil = wiphy_to_wil(wiphy);
+
+   wil_dbg_misc(wil, "add station %pM aid %d\n", mac, params->aid);
+
+   if (!disable_ap_sme) {
+   wil_err(wil, "not supported with AP SME enabled\n");
+   return -EOPNOTSUPP;
+   }
+
+   if (params->aid > WIL_MAX_DMG_AID) {
+   wil_err(wil, "invalid aid\n");
+   return -EINVAL;
+   }
+
+   return wmi_new_sta(wil, mac, params->aid);
+}
+
 static int wil_cfg80211_del_station(struct wiphy *wiphy,
struct net_device *dev,
struct station_del_parameters *params)
@@ -1338,6 +1371,52 @@ static int wil_cfg80211_del_station(struct wiphy *wiphy,
return 0;
 }
 
+static int wil_cfg80211_change_station(struct wiphy *wiphy,
+  struct net_device *dev,
+  const u8 *mac,
+  struct station_parameters *params)
+{
+   struct wil6210_priv *wil = wiphy_to_wil(wiphy);
+   int authorize;
+   int cid, i;
+   struct vring_tx_data *txdata = NULL;
+
+   wil_dbg_misc(wil, "change station %pM mask 0x%x set 0x%x\n", mac,
+params->sta_flags_mask, params->sta_flags_set);
+
+   if (!disable_ap_sme) {
+   wil_dbg_misc(wil, "not supported with AP SME enabled\n");
+   return -EOPNOTSUPP;
+   }
+
+   if (!(params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)))
+   return 0;
+
+   cid = wil_find_cid(wil, mac);
+   if (cid < 0) {
+   wil_err(wil, "station not found\n");
+   return -ENOLINK;
+   }
+
+   for (i = 0; i < 

[PATCH v2 13/13] wil6210: convert symbolic permissions to octal permissions

2017-01-12 Thread Maya Erez
Symbolic permissions are no longer recommended.
This patch changes the symbolic permissions in wil6210 driver
to octal permissions.

Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/cfg80211.c |   2 +-
 drivers/net/wireless/ath/wil6210/debugfs.c  | 128 ++--
 drivers/net/wireless/ath/wil6210/main.c |  16 ++--
 drivers/net/wireless/ath/wil6210/pcie_bus.c |   2 +-
 drivers/net/wireless/ath/wil6210/txrx.c |   4 +-
 drivers/net/wireless/ath/wil6210/wmi.c  |   6 +-
 6 files changed, 79 insertions(+), 79 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c 
b/drivers/net/wireless/ath/wil6210/cfg80211.c
index 9a92790..e25e78e 100644
--- a/drivers/net/wireless/ath/wil6210/cfg80211.c
+++ b/drivers/net/wireless/ath/wil6210/cfg80211.c
@@ -21,7 +21,7 @@
 #define WIL_MAX_ROC_DURATION_MS 5000
 
 bool disable_ap_sme;
-module_param(disable_ap_sme, bool, S_IRUGO);
+module_param(disable_ap_sme, bool, 0444);
 MODULE_PARM_DESC(disable_ap_sme, " let user space handle AP mode SME");
 
 #define CHAN60G(_channel, _flags) {\
diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c 
b/drivers/net/wireless/ath/wil6210/debugfs.c
index 97e9088..3e8cdf1 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -364,13 +364,13 @@ static void wil6210_debugfs_init_offset(struct 
wil6210_priv *wil,
 }
 
 static const struct dbg_off isr_off[] = {
-   {"ICC", S_IRUGO | S_IWUSR, offsetof(struct RGF_ICR, ICC), doff_io32},
-   {"ICR", S_IRUGO | S_IWUSR, offsetof(struct RGF_ICR, ICR), doff_io32},
-   {"ICM", S_IRUGO | S_IWUSR, offsetof(struct RGF_ICR, ICM), doff_io32},
-   {"ICS",   S_IWUSR, offsetof(struct RGF_ICR, ICS), doff_io32},
-   {"IMV", S_IRUGO | S_IWUSR, offsetof(struct RGF_ICR, IMV), doff_io32},
-   {"IMS",   S_IWUSR, offsetof(struct RGF_ICR, IMS), doff_io32},
-   {"IMC",   S_IWUSR, offsetof(struct RGF_ICR, IMC), doff_io32},
+   {"ICC", 0644, offsetof(struct RGF_ICR, ICC), doff_io32},
+   {"ICR", 0644, offsetof(struct RGF_ICR, ICR), doff_io32},
+   {"ICM", 0644, offsetof(struct RGF_ICR, ICM), doff_io32},
+   {"ICS", 0244, offsetof(struct RGF_ICR, ICS), doff_io32},
+   {"IMV", 0644, offsetof(struct RGF_ICR, IMV), doff_io32},
+   {"IMS", 0244, offsetof(struct RGF_ICR, IMS), doff_io32},
+   {"IMC", 0244, offsetof(struct RGF_ICR, IMC), doff_io32},
{},
 };
 
@@ -390,9 +390,9 @@ static int wil6210_debugfs_create_ISR(struct wil6210_priv 
*wil,
 }
 
 static const struct dbg_off pseudo_isr_off[] = {
-   {"CAUSE",   S_IRUGO, HOSTADDR(RGF_DMA_PSEUDO_CAUSE), doff_io32},
-   {"MASK_SW", S_IRUGO, HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_SW), doff_io32},
-   {"MASK_FW", S_IRUGO, HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_FW), doff_io32},
+   {"CAUSE",   0444, HOSTADDR(RGF_DMA_PSEUDO_CAUSE), doff_io32},
+   {"MASK_SW", 0444, HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_SW), doff_io32},
+   {"MASK_FW", 0444, HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_FW), doff_io32},
{},
 };
 
@@ -411,40 +411,40 @@ static int wil6210_debugfs_create_pseudo_ISR(struct 
wil6210_priv *wil,
 }
 
 static const struct dbg_off lgc_itr_cnt_off[] = {
-   {"TRSH", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_CNT_TRSH), doff_io32},
-   {"DATA", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_CNT_DATA), doff_io32},
-   {"CTL",  S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_CNT_CRL), doff_io32},
+   {"TRSH", 0644, HOSTADDR(RGF_DMA_ITR_CNT_TRSH), doff_io32},
+   {"DATA", 0644, HOSTADDR(RGF_DMA_ITR_CNT_DATA), doff_io32},
+   {"CTL",  0644, HOSTADDR(RGF_DMA_ITR_CNT_CRL), doff_io32},
{},
 };
 
 static const struct dbg_off tx_itr_cnt_off[] = {
-   {"TRSH", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_TX_CNT_TRSH),
+   {"TRSH", 0644, HOSTADDR(RGF_DMA_ITR_TX_CNT_TRSH),
 doff_io32},
-   {"DATA", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_TX_CNT_DATA),
+   {"DATA", 0644, HOSTADDR(RGF_DMA_ITR_TX_CNT_DATA),
 doff_io32},
-   {"CTL",  S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_TX_CNT_CTL),
+   {"CTL",  0644, HOSTADDR(RGF_DMA_ITR_TX_CNT_CTL),
 doff_io32},
-   {"IDL_TRSH", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_TX_IDL_CNT_TRSH),
+   {"IDL_TRSH", 0644, HOSTADDR(RGF_DMA_ITR_TX_IDL_CNT_TRSH),
 doff_io32},
-   {"IDL_DATA", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_TX_IDL_CNT_DATA),
+   {"IDL_DATA", 0644, HOSTADDR(RGF_DMA_ITR_TX_IDL_CNT_DATA),
 doff_io32},
-   {"IDL_CTL",  S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_TX_IDL_CNT_CTL),
+   {"IDL_CTL",  0644, HOSTADDR(RGF_DMA_ITR_TX_IDL_CNT_CTL),
 doff_io32},
{},
 };
 
 static const struct dbg_off rx_itr_cnt_off[] = {
-   {"TRSH", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_RX_CNT_TRSH),
+   {"TRSH", 0644, HOSTADDR(RGF_DMA_ITR_RX_CNT_TRSH),
 doff_io32},
-   {"DATA", S_IRUGO | 

[PATCH v2 05/13] wil6210: support new WMI-only FW capability

2017-01-12 Thread Maya Erez
From: Dedy Lansky 

WMI_ONLY FW is used for testing in production. It cannot be used for
scan/connect, etc.
In case FW reports this capability, driver will not allow interface up.

Signed-off-by: Dedy Lansky 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/netdev.c   |  5 +++--
 drivers/net/wireless/ath/wil6210/pcie_bus.c | 10 +++---
 drivers/net/wireless/ath/wil6210/wmi.h  |  1 +
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/netdev.c 
b/drivers/net/wireless/ath/wil6210/netdev.c
index d5df744..1843d98 100644
--- a/drivers/net/wireless/ath/wil6210/netdev.c
+++ b/drivers/net/wireless/ath/wil6210/netdev.c
@@ -24,8 +24,9 @@ static int wil_open(struct net_device *ndev)
 
wil_dbg_misc(wil, "open\n");
 
-   if (debug_fw) {
-   wil_err(wil, "while in debug_fw mode\n");
+   if (debug_fw ||
+   test_bit(WMI_FW_CAPABILITY_WMI_ONLY, wil->fw_capabilities)) {
+   wil_err(wil, "while in debug_fw or wmi_only mode\n");
return -EINVAL;
}
 
diff --git a/drivers/net/wireless/ath/wil6210/pcie_bus.c 
b/drivers/net/wireless/ath/wil6210/pcie_bus.c
index cd57d3e..e891068 100644
--- a/drivers/net/wireless/ath/wil6210/pcie_bus.c
+++ b/drivers/net/wireless/ath/wil6210/pcie_bus.c
@@ -99,8 +99,10 @@ static int wil_if_pcie_enable(struct wil6210_priv *wil)
 */
int msi_only = pdev->msi_enabled;
bool _use_msi = use_msi;
+   bool wmi_only = test_bit(WMI_FW_CAPABILITY_WMI_ONLY,
+wil->fw_capabilities);
 
-   wil_dbg_misc(wil, "if_pcie_enable\n");
+   wil_dbg_misc(wil, "if_pcie_enable, wmi_only %d\n", wmi_only);
 
pdev->msi_enabled = 0;
 
@@ -123,9 +125,11 @@ static int wil_if_pcie_enable(struct wil6210_priv *wil)
if (rc)
goto stop_master;
 
-   /* need reset here to obtain MAC */
+   /* need reset here to obtain MAC or in case of WMI-only FW, full reset
+* and fw loading takes place
+*/
mutex_lock(>mutex);
-   rc = wil_reset(wil, false);
+   rc = wil_reset(wil, wmi_only);
mutex_unlock(>mutex);
if (rc)
goto release_irq;
diff --git a/drivers/net/wireless/ath/wil6210/wmi.h 
b/drivers/net/wireless/ath/wil6210/wmi.h
index 9c4a0bd..906aa72 100644
--- a/drivers/net/wireless/ath/wil6210/wmi.h
+++ b/drivers/net/wireless/ath/wil6210/wmi.h
@@ -57,6 +57,7 @@ enum wmi_fw_capability {
WMI_FW_CAPABILITY_RF_SECTORS= 2,
WMI_FW_CAPABILITY_MGMT_RETRY_LIMIT  = 3,
WMI_FW_CAPABILITY_DISABLE_AP_SME= 4,
+   WMI_FW_CAPABILITY_WMI_ONLY  = 5,
WMI_FW_CAPABILITY_MAX,
 };
 
-- 
1.9.1



[PATCH v2 11/13] wil6210: option to override A-BFT length in start AP/PCP

2017-01-12 Thread Maya Erez
From: Lior David 

Add an option to specify and override the A-BFT length when
starting an AP/PCP. See IEEE P802.11-2016, 10.38.5.
The abft_len must be set before starting AP/PCP. It is only
needed for diagnostics and certification.

Signed-off-by: Lior David 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/debugfs.c | 1 +
 drivers/net/wireless/ath/wil6210/wil6210.h | 1 +
 drivers/net/wireless/ath/wil6210/wmi.c | 1 +
 3 files changed, 3 insertions(+)

diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c 
b/drivers/net/wireless/ath/wil6210/debugfs.c
index bb8a59a..97e9088 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -1702,6 +1702,7 @@ static void wil6210_debugfs_init_isr(struct wil6210_priv 
*wil,
WIL_FIELD(ap_isolate,   S_IRUGO,doff_u32),
WIL_FIELD(discovery_mode, S_IRUGO | S_IWUSR,doff_u8),
WIL_FIELD(chip_revision, S_IRUGO,   doff_u8),
+   WIL_FIELD(abft_len, S_IRUGO | S_IWUSR,  doff_u8),
{},
 };
 
diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h 
b/drivers/net/wireless/ath/wil6210/wil6210.h
index b3c7583..a73864f 100644
--- a/drivers/net/wireless/ath/wil6210/wil6210.h
+++ b/drivers/net/wireless/ath/wil6210/wil6210.h
@@ -667,6 +667,7 @@ struct wil6210_priv {
struct dentry *debug;
struct wil_blob_wrapper blobs[ARRAY_SIZE(fw_mapping)];
u8 discovery_mode;
+   u8 abft_len;
 
void *platform_handle;
struct wil_platform_ops platform_ops;
diff --git a/drivers/net/wireless/ath/wil6210/wmi.c 
b/drivers/net/wireless/ath/wil6210/wmi.c
index 598096f..27d21a3 100644
--- a/drivers/net/wireless/ath/wil6210/wmi.c
+++ b/drivers/net/wireless/ath/wil6210/wmi.c
@@ -1079,6 +1079,7 @@ int wmi_pcp_start(struct wil6210_priv *wil, int bi, u8 
wmi_nettype,
.hidden_ssid = hidden_ssid,
.is_go = is_go,
.disable_ap_sme = disable_ap_sme,
+   .abft_len = wil->abft_len,
};
struct {
struct wmi_cmd_hdr wmi;
-- 
1.9.1



[PATCH v2 07/13] wil6210: protect against false interrupt during reset sequence

2017-01-12 Thread Maya Erez
From: Hamad Kadmany 

During reset sequence it is seen that device is generating an
interrupt eventhough interrupts are masked at device level.

Add workaround to disable the interrupts from host side during
reset and clear any pending interrupts before re-enabling
the interrupt.

Signed-off-by: Hamad Kadmany 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/ath/wil6210/main.c 
b/drivers/net/wireless/ath/wil6210/main.c
index 9b8fa6a..85a795a 100644
--- a/drivers/net/wireless/ath/wil6210/main.c
+++ b/drivers/net/wireless/ath/wil6210/main.c
@@ -918,7 +918,10 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw)
flush_workqueue(wil->wmi_wq);
 
wil_bl_crash_info(wil, false);
+   wil_disable_irq(wil);
rc = wil_target_reset(wil);
+   wil6210_clear_irq(wil);
+   wil_enable_irq(wil);
wil_rx_fini(wil);
if (rc) {
wil_bl_crash_info(wil, true);
-- 
1.9.1



[PATCH v2 12/13] wil6210: set dma mask to reflect device capability

2017-01-12 Thread Maya Erez
From: Hamad Kadmany 

11ad device supports 48 bit addresses, reflect that
by setting the dma mask accordingly.

Signed-off-by: Hamad Kadmany 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/pcie_bus.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/net/wireless/ath/wil6210/pcie_bus.c 
b/drivers/net/wireless/ath/wil6210/pcie_bus.c
index e891068..3a63e98 100644
--- a/drivers/net/wireless/ath/wil6210/pcie_bus.c
+++ b/drivers/net/wireless/ath/wil6210/pcie_bus.c
@@ -205,6 +205,19 @@ static int wil_pcie_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
return -ENODEV;
}
 
+   /* device supports 48bit addresses */
+   rc = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48));
+   if (rc) {
+   dev_err(dev, "dma_set_mask_and_coherent(48) failed: %d\n", rc);
+   rc = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
+   if (rc) {
+   dev_err(dev,
+   "dma_set_mask_and_coherent(32) failed: %d\n",
+   rc);
+   return rc;
+   }
+   }
+
wil = wil_if_alloc(dev);
if (IS_ERR(wil)) {
rc = (int)PTR_ERR(wil);
-- 
1.9.1



[PATCH v2 10/13] wil6210: report association ID (AID) per station in debugfs

2017-01-12 Thread Maya Erez
From: Lior David 

Add reporting of the association ID (AID) for each station
as part of the stations file in the debugfs.
Valid AID values are 1-254. 0 is reported if the AID
is unknown or not reported by firmware.

Signed-off-by: Lior David 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/debugfs.c | 4 +++-
 drivers/net/wireless/ath/wil6210/wil6210.h | 1 +
 drivers/net/wireless/ath/wil6210/wmi.c | 5 +++--
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c 
b/drivers/net/wireless/ath/wil6210/debugfs.c
index db6527a..bb8a59a 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -1379,6 +1379,7 @@ static int wil_sta_debugfs_show(struct seq_file *s, void 
*data)
for (i = 0; i < ARRAY_SIZE(wil->sta); i++) {
struct wil_sta_info *p = >sta[i];
char *status = "unknown";
+   u8 aid = 0;
 
switch (p->status) {
case wil_sta_unused:
@@ -1389,9 +1390,10 @@ static int wil_sta_debugfs_show(struct seq_file *s, void 
*data)
break;
case wil_sta_connected:
status = "connected";
+   aid = p->aid;
break;
}
-   seq_printf(s, "[%d] %pM %s\n", i, p->addr, status);
+   seq_printf(s, "[%d] %pM %s AID %d\n", i, p->addr, status, aid);
 
if (p->status == wil_sta_connected) {
spin_lock_bh(>tid_rx_lock);
diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h 
b/drivers/net/wireless/ath/wil6210/wil6210.h
index b9febed..b3c7583 100644
--- a/drivers/net/wireless/ath/wil6210/wil6210.h
+++ b/drivers/net/wireless/ath/wil6210/wil6210.h
@@ -523,6 +523,7 @@ struct wil_sta_info {
unsigned long tid_rx_stop_requested[BITS_TO_LONGS(WIL_STA_TID_NUM)];
struct wil_tid_crypto_rx tid_crypto_rx[WIL_STA_TID_NUM];
struct wil_tid_crypto_rx group_crypto_rx;
+   u8 aid; /* 1-254; 0 if unknown/not reported */
 };
 
 enum {
diff --git a/drivers/net/wireless/ath/wil6210/wmi.c 
b/drivers/net/wireless/ath/wil6210/wmi.c
index d30b3fc..598096f 100644
--- a/drivers/net/wireless/ath/wil6210/wmi.c
+++ b/drivers/net/wireless/ath/wil6210/wmi.c
@@ -495,8 +495,8 @@ static void wmi_evt_connect(struct wil6210_priv *wil, int 
id, void *d, int len)
}
 
ch = evt->channel + 1;
-   wil_info(wil, "Connect %pM channel [%d] cid %d\n",
-evt->bssid, ch, evt->cid);
+   wil_info(wil, "Connect %pM channel [%d] cid %d aid %d\n",
+evt->bssid, ch, evt->cid, evt->aid);
wil_hex_dump_wmi("connect AI : ", DUMP_PREFIX_OFFSET, 16, 1,
 evt->assoc_info, len - sizeof(*evt), true);
 
@@ -604,6 +604,7 @@ static void wmi_evt_connect(struct wil6210_priv *wil, int 
id, void *d, int len)
}
 
wil->sta[evt->cid].status = wil_sta_connected;
+   wil->sta[evt->cid].aid = evt->aid;
set_bit(wil_status_fwconnected, wil->status);
wil_update_net_queues_bh(wil, NULL, false);
 
-- 
1.9.1



[PATCH v2 09/13] wil6210: align to latest auto generated wmi.h

2017-01-12 Thread Maya Erez
From: Lior David 

Align to latest version of the auto generated wmi file
describing the interface with FW.

Signed-off-by: Lior David 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/wmi.h | 45 --
 1 file changed, 43 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/wmi.h 
b/drivers/net/wireless/ath/wil6210/wmi.h
index 906aa72..7c9fee5 100644
--- a/drivers/net/wireless/ath/wil6210/wmi.h
+++ b/drivers/net/wireless/ath/wil6210/wmi.h
@@ -187,6 +187,7 @@ enum wmi_command_id {
WMI_RS_CFG_CMDID= 0x921,
WMI_GET_DETAILED_RS_RES_CMDID   = 0x922,
WMI_AOA_MEAS_CMDID  = 0x923,
+   WMI_BRP_SET_ANT_LIMIT_CMDID = 0x924,
WMI_SET_MGMT_RETRY_LIMIT_CMDID  = 0x930,
WMI_GET_MGMT_RETRY_LIMIT_CMDID  = 0x931,
WMI_NEW_STA_CMDID   = 0x935,
@@ -547,7 +548,9 @@ struct wmi_pcp_start_cmd {
u8 pcp_max_assoc_sta;
u8 hidden_ssid;
u8 is_go;
-   u8 reserved0[6];
+   u8 reserved0[5];
+   /* abft_len override if non-0 */
+   u8 abft_len;
u8 disable_ap_sme;
u8 network_type;
u8 channel;
@@ -1084,6 +1087,7 @@ enum wmi_event_id {
WMI_RS_CFG_DONE_EVENTID = 0x1921,
WMI_GET_DETAILED_RS_RES_EVENTID = 0x1922,
WMI_AOA_MEAS_EVENTID= 0x1923,
+   WMI_BRP_SET_ANT_LIMIT_EVENTID   = 0x1924,
WMI_SET_MGMT_RETRY_LIMIT_EVENTID= 0x1930,
WMI_GET_MGMT_RETRY_LIMIT_EVENTID= 0x1931,
WMI_TOF_SESSION_END_EVENTID = 0x1991,
@@ -1304,7 +1308,8 @@ struct wmi_connect_event {
u8 assoc_req_len;
u8 assoc_resp_len;
u8 cid;
-   u8 reserved2[3];
+   u8 aid;
+   u8 reserved2[2];
/* not in use */
u8 assoc_info[0];
 } __packed;
@@ -1777,6 +1782,42 @@ struct wmi_get_detailed_rs_res_event {
u8 reserved[3];
 } __packed;
 
+/* BRP antenna limit mode */
+enum wmi_brp_ant_limit_mode {
+   /* Disable BRP force antenna limit */
+   WMI_BRP_ANT_LIMIT_MODE_DISABLE  = 0x00,
+   /* Define maximal antennas limit. Only effective antennas will be
+* actually used
+*/
+   WMI_BRP_ANT_LIMIT_MODE_EFFECTIVE= 0x01,
+   /* Force a specific number of antennas */
+   WMI_BRP_ANT_LIMIT_MODE_FORCE= 0x02,
+   /* number of BRP antenna limit modes */
+   WMI_BRP_ANT_LIMIT_MODES_NUM = 0x03,
+};
+
+/* WMI_BRP_SET_ANT_LIMIT_CMDID */
+struct wmi_brp_set_ant_limit_cmd {
+   /* connection id */
+   u8 cid;
+   /* enum wmi_brp_ant_limit_mode */
+   u8 limit_mode;
+   /* antenna limit count, 1-27
+* disable_mode - ignored
+* effective_mode - upper limit to number of antennas to be used
+* force_mode - exact number of antennas to be used
+*/
+   u8 ant_limit;
+   u8 reserved;
+} __packed;
+
+/* WMI_BRP_SET_ANT_LIMIT_EVENTID */
+struct wmi_brp_set_ant_limit_event {
+   /* wmi_fw_status */
+   u8 status;
+   u8 reserved[3];
+} __packed;
+
 /* broadcast connection ID */
 #define WMI_LINK_MAINTAIN_CFG_CID_BROADCAST(0x)
 
-- 
1.9.1



[PATCH v2 08/13] wil6210: fix for broadcast workaround in PBSS

2017-01-12 Thread Maya Erez
From: Lior David 

Currently we do not have full support for broadcast from
a station inside a PBSS network.
We have a workaround where instead of broadcast we do a
unicast to every known station in the PBSS.
This workaround was performed only for P2P clients.
This fix will perform the broadcast workaround also for a
regular station inside a PBSS.

Signed-off-by: Lior David 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/cfg80211.c |  1 +
 drivers/net/wireless/ath/wil6210/txrx.c | 35 -
 2 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c 
b/drivers/net/wireless/ath/wil6210/cfg80211.c
index f8499a8..9a92790 100644
--- a/drivers/net/wireless/ath/wil6210/cfg80211.c
+++ b/drivers/net/wireless/ath/wil6210/cfg80211.c
@@ -601,6 +601,7 @@ static int wil_cfg80211_connect(struct wiphy *wiphy,
goto out;
}
wil->privacy = sme->privacy;
+   wil->pbss = sme->pbss;
 
if (wil->privacy) {
/* For secure assoc, remove old keys */
diff --git a/drivers/net/wireless/ath/wil6210/txrx.c 
b/drivers/net/wireless/ath/wil6210/txrx.c
index 6e7dc8d..1311688 100644
--- a/drivers/net/wireless/ath/wil6210/txrx.c
+++ b/drivers/net/wireless/ath/wil6210/txrx.c
@@ -1195,17 +1195,6 @@ static struct vring *wil_find_tx_bcast_2(struct 
wil6210_priv *wil,
return v;
 }
 
-static struct vring *wil_find_tx_bcast(struct wil6210_priv *wil,
-  struct sk_buff *skb)
-{
-   struct wireless_dev *wdev = wil->wdev;
-
-   if (wdev->iftype != NL80211_IFTYPE_AP)
-   return wil_find_tx_bcast_2(wil, skb);
-
-   return wil_find_tx_bcast_1(wil, skb);
-}
-
 static int wil_tx_desc_map(struct vring_tx_desc *d, dma_addr_t pa, u32 len,
   int vring_index)
 {
@@ -1905,12 +1894,26 @@ netdev_tx_t wil_start_xmit(struct sk_buff *skb, struct 
net_device *ndev)
pr_once_fw = false;
 
/* find vring */
-   if (wil->wdev->iftype == NL80211_IFTYPE_STATION) {
-   /* in STA mode (ESS), all to same VRING */
+   if (wil->wdev->iftype == NL80211_IFTYPE_STATION && !wil->pbss) {
+   /* in STA mode (ESS), all to same VRING (to AP) */
vring = wil_find_tx_vring_sta(wil, skb);
-   } else { /* direct communication, find matching VRING */
-   vring = bcast ? wil_find_tx_bcast(wil, skb) :
-   wil_find_tx_ucast(wil, skb);
+   } else if (bcast) {
+   if (wil->pbss)
+   /* in pbss, no bcast VRING - duplicate skb in
+* all stations VRINGs
+*/
+   vring = wil_find_tx_bcast_2(wil, skb);
+   else if (wil->wdev->iftype == NL80211_IFTYPE_AP)
+   /* AP has a dedicated bcast VRING */
+   vring = wil_find_tx_bcast_1(wil, skb);
+   else
+   /* unexpected combination, fallback to duplicating
+* the skb in all stations VRINGs
+*/
+   vring = wil_find_tx_bcast_2(wil, skb);
+   } else {
+   /* unicast, find specific VRING by dest. address */
+   vring = wil_find_tx_ucast(wil, skb);
}
if (unlikely(!vring)) {
wil_dbg_txrx(wil, "No Tx VRING found for %pM\n", eth->h_dest);
-- 
1.9.1



[PATCH v2 06/13] wil6210: missing reinit_completion in wmi_call

2017-01-12 Thread Maya Erez
From: Lior David 

The code in wmi_call uses the wil->wmi_call completion
structure to wait for a reply.
In some scenarios, complete was called twice on the
completion structure. This happened mainly with a disconnect
event which can arrive both unsolicited and as a reply to
a disconnect request. In this case the completion structure
was left marked as "done" and the next wmi_call returned
immediately with a corrupted reply buffer. This caused
unexpected results including crashes.
Fix this by adding the missing call to reinit_completion.

Signed-off-by: Lior David 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/wmi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/ath/wil6210/wmi.c 
b/drivers/net/wireless/ath/wil6210/wmi.c
index 0137ac5..d30b3fc 100644
--- a/drivers/net/wireless/ath/wil6210/wmi.c
+++ b/drivers/net/wireless/ath/wil6210/wmi.c
@@ -957,6 +957,7 @@ int wmi_call(struct wil6210_priv *wil, u16 cmdid, void 
*buf, u16 len,
wil->reply_id = reply_id;
wil->reply_buf = reply;
wil->reply_size = reply_size;
+   reinit_completion(>wmi_call);
spin_unlock(>wmi_ev_lock);
 
rc = __wmi_send(wil, cmdid, buf, len);
-- 
1.9.1



Re: [PATCH 6/9] rt2800: fallback from mcs8 to mcs7

2017-01-12 Thread Felix Fietkau
On 2017-01-06 14:05, Stanislaw Gruszka wrote:
> If we do not fallback to lower rate, we are unable to calculate
> correctly number of retries in TX status code.
> 
> Signed-off-by: Stanislaw Gruszka 
I think falling back from the lowest dual-stream to the highest
single-stream rate is a really bad idea.
Instead you should get rid of the assumption that fallback rates are
ordered by their MCS index.

- Felix


Re: ath9k: fix spelling mistake: "meaurement" -> "measurement"

2017-01-12 Thread Kalle Valo
Colin Ian King  wrote:
> From: Colin Ian King 
> 
> Trivial fix to spelling mistake in ath_err message
> 
> Signed-off-by: Colin Ian King 

Patch applied to ath-next branch of ath.git, thanks.

714ee339ff90 ath9k: fix spelling mistake: "meaurement" -> "measurement"

-- 
https://patchwork.kernel.org/patch/9492191/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



Re: [1/2] ath9k: ar9002_mac: kill off ACCESS_ONCE()

2017-01-12 Thread Kalle Valo
Mark Rutland  wrote:
> For several reasons, it is desirable to use {READ,WRITE}_ONCE() in
> preference to ACCESS_ONCE(), and new code is expected to use one of the
> former. So far, there's been no reason to change most existing uses of
> ACCESS_ONCE(), as these aren't currently harmful.
> 
> However, for some new features (e.g. KTSAN / Kernel Thread Sanitizer),
> it is necessary to instrument reads and writes separately, which is not
> possible with ACCESS_ONCE(). This distinction is critical to correct
> operation.
> 
> It's possible to transform the bulk of kernel code using the Coccinelle
> script below. However, for some files (including the ath9k ar9002 mac
> driver), this mangles the formatting. As a preparatory step, this patch
> converts the driver to use {READ,WRITE}_ONCE() without said mangling.
> 
> 
> virtual patch
> 
> @ depends on patch @
> expression E1, E2;
> @@
> 
> - ACCESS_ONCE(E1) = E2
> + WRITE_ONCE(E1, E2)
> 
> @ depends on patch @
> expression E;
> @@
> 
> - ACCESS_ONCE(E)
> + READ_ONCE(E)
> 
> 
> Signed-off-by: Mark Rutland 
> Cc: ath9k-de...@qca.qualcomm.com
> Cc: Kalle Valo 
> Cc: linux-wireless@vger.kernel.org
> Cc: ath9k-de...@lists.ath9k.org
> Cc: net...@vger.kernel.org

2 patches applied to ath-next branch of ath.git, thanks.

d5a3a76a9cb8 ath9k: ar9002_mac: kill off ACCESS_ONCE()
50f3818196f5 ath9k: ar9003_mac: kill off ACCESS_ONCE()

-- 
https://patchwork.kernel.org/patch/9489799/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



Re: [1/2] ath10k: htc: Removal of unused struct members

2017-01-12 Thread Kalle Valo
Erik Stromdahl  wrote:
> Removed tx_credits_per_max_message and tx_credit_size
> from struct ath10k_htc_ep since they are not used
> anywhere in the code.
> 
> They are just written, never read.
> 
> Signed-off-by: Erik Stromdahl 

2 patches applied to ath-next branch of ath.git, thanks.

7bc7441e4da3 ath10k: htc: removal of unused struct members
d48b62ceeea2 ath10k: htc: simplified credit distribution

-- 
https://patchwork.kernel.org/patch/9469283/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



Re: ath5k: drop bogus warning on drv_set_key with unsupported cipher

2017-01-12 Thread Kalle Valo
Felix Fietkau  wrote:
> Simply return -EOPNOTSUPP instead.
> 
> Cc: sta...@vger.kernel.org
> Signed-off-by: Felix Fietkau 

Patch applied to ath-next branch of ath.git, thanks.

a70e1d6fd6b5 ath5k: drop bogus warning on drv_set_key with unsupported cipher

-- 
https://patchwork.kernel.org/patch/9489183/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



Re: net: wireless: ath: wil6210: constify cfg80211_ops structures

2017-01-12 Thread Kalle Valo
Bhumika Goyal  wrote:
> cfg80211_ops structures are only passed as an argument to the function
> wiphy_new. This argument is of type const, so cfg80211_ops strutures
> having this property can be declared as const.
> Done using Coccinelle
> 
> @r1 disable optional_qualifier @
> identifier i;
> position p;
> @@
> static struct cfg80211_ops i@p = {...};
> 
> @ok1@
> identifier r1.i;
> position p;
> @@
> wiphy_new(@p,...)
> 
> @bad@
> position p!={r1.p,ok1.p};
> identifier r1.i;
> @@
> i@p
> 
> @depends on !bad disable optional_qualifier@
> identifier r1.i;
> @@
> +const
> struct cfg80211_ops i;
> 
> File size before:
>text  data bss dec hex filename
>   18133  6632   0   2476560bd wireless/ath/wil6210/cfg80211.o
> 
> File size after:
>text  data bss dec hex filename
>   18933  5832   0   2476560bd wireless/ath/wil6210/cfg80211.o
> 
> Signed-off-by: Bhumika Goyal 

Patch applied to ath-next branch of ath.git, thanks.

b59eb96181e7 wil6210: constify cfg80211_ops structures

-- 
https://patchwork.kernel.org/patch/9479127/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



Re: [v5,1/5] soc: qcom: smem_state: Fix include for ERR_PTR()

2017-01-12 Thread Kalle Valo
Bjorn Andersson  wrote:
> The correct include file for getting errno constants and ERR_PTR() is
> linux/err.h, rather than linux/errno.h, so fix the include.
> 
> Fixes: e8b123e60084 ("soc: qcom: smem_state: Add stubs for disabled 
> smem_state")
> Acked-by: Andy Gross 
> Signed-off-by: Bjorn Andersson 

5 patches applied to ath-next branch of ath.git, thanks.

6c0b2e833f14 soc: qcom: smem_state: Fix include for ERR_PTR()
f303a9311065 wcn36xx: Transition driver to SMD client
886039036c20 wcn36xx: Implement firmware assisted scan
43efa3c0f241 wcn36xx: Implement print_reg indication
d53628882255 wcn36xx: Don't use the destroyed hal_mutex

-- 
https://patchwork.kernel.org/patch/9429045/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



Re: [PATCH] wext: handle NULL exta data in iwe_stream_add_point better

2017-01-12 Thread Arnd Bergmann
On Thursday, January 12, 2017 10:16:00 AM CET Johannes Berg wrote:
> And I realized only now that this was a different place ...

Right, it was a few hundred randconfigs later after I had confirmed
that the first patch fixed all the configurations that were broken
at first.

> I've just added the check you suggested - spent way too much time
> already on this old crap 

Ok, thanks! Let's hope it doesn't come back once more.

I'm still trying to categorize the newly added warnings in gcc-7,
there a number of very useful warnings that got added, but some of
them are rather noisy and find both a number of real bugs and
false positives. The NULL check had only a few findings that all
seemed worth fixing.

Arnd


Re: [PATCH] wext: handle NULL exta data in iwe_stream_add_point better

2017-01-12 Thread Johannes Berg

> Come to think of it, I'm thinking I should drop this patch and the
> driver should just use iwe_stream_add_event() instead? It'll be
> somewhat tricky to get the length correct though.

No, turns out that's basically impossible with all the compat etc.
stuff here.

johannes


Re: [PATCH] wext: handle NULL exta data in iwe_stream_add_point better

2017-01-12 Thread Johannes Berg
On Wed, 2017-01-11 at 21:39 +0100, Arnd Bergmann wrote:
> On Wednesday, January 11, 2017 4:06:17 PM CET Johannes Berg wrote:
> > 
> > Applied. Also fixed the typo in the subject :)
> 
> Thanks! Unfortunately I now got another warning for the same
> function, and though I would have expected the patch to fix it, that
> did not work:
> 
> In file included from /git/arm-
> soc/drivers/net/wireless/intersil/prism54/islpci_dev.h:27:0,
>  from /git/arm-
> soc/drivers/net/wireless/intersil/prism54/isl_ioctl.h:24,
>  from /git/arm-
> soc/drivers/net/wireless/intersil/prism54/isl_ioctl.c:32:
> /git/arm-soc/drivers/net/wireless/intersil/prism54/isl_ioctl.c: In
> function 'prism54_get_scan':
> /git/arm-soc/include/net/iw_handler.h:560:4: error: argument 2 null
> where non-null expected [-Werror=nonnull]
> memcpy(stream + point_len, extra, iwe->u.data.length);

And I realized only now that this was a different place ...

I've just added the check you suggested - spent way too much time
already on this old crap :)

johannes


Re: wl1251 & mac address & calibration data

2017-01-12 Thread Pavel Machek
Hi!

> >> But overwriting that one file is not possible as it next update of 
> >> linux-firmware package will overwrite it back. It break any normal usage 
> >> of package management.
> >> 
> >> Also it is ridiculously broken by design if some "boot" files needs to 
> >> be overwritten to initialize hardware properly. To not break booting you 
> >> need to overwrite that file before first boot. But without booting 
> >> device you cannot read calibration data. So some hack with autoreboot 
> >> after boot is needed.
> 
> Providing the calibration data via Device Tree is the proper way to
> solve this. Yes yes, I know N900 doesn't support it but that's a
> deficiency in N900, not Linux.

Linux has to work with whatever hardware provides. You may not like
N900 design, but we have to support it, anyway.

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH] wext: handle NULL exta data in iwe_stream_add_point better

2017-01-12 Thread Johannes Berg
On Wed, 2017-01-11 at 21:39 +0100, Arnd Bergmann wrote:
> On Wednesday, January 11, 2017 4:06:17 PM CET Johannes Berg wrote:
> > 
> > Applied. Also fixed the typo in the subject :)
> 
> Thanks! Unfortunately I now got another warning for the same
> function, and though I would have expected the patch to fix it, that
> did not work:

I've come to expect better of you (i.e. testing your own patches) ;-)


Come to think of it, I'm thinking I should drop this patch and the
driver should just use iwe_stream_add_event() instead? It'll be
somewhat tricky to get the length correct though.

Alternatively, perhaps we should just uninline all the crap and then
the compiler can't bother us :)

johannes