Re: Problem seen with wireless mesh

2017-07-31 Thread George H
Hi Michel,

I didn't have SAE authentication enabled, it was open mode. The latest
logs give some clues. The mesh appears to have gone down and this is
possibly the reason for the ping failure. After a while, the mesh
discovery starts again and restores the mesh. On product B, I see the
dropped_frames_no_route statistic incrementing during the period of
ping failure. I'm investigating why the mesh became inactive.

Thanks for your response.


Re: [PATCH 19/24] iwlwifi: mvm: fix TCP CSUM offload with WEP and A000 series

2017-07-31 Thread Coelho, Luciano
On Fri, 2017-07-28 at 17:23 +0300, Luca Coelho wrote:
> From: Emmanuel Grumbach 
> 
> When we enabled TCP checksum offload, we need to tell the
> firmware where the IP header starts. If we have an IV, then
> we need to adapt that value since the IV is placed before
> the SNAP header. This is true only for cases where the
> driver adds the IV, not the WEP case in which the IV is
> added by the firmware itself.
> 
> On A000 devices series, the IV is always added by the
> device.
> 
> Fix this.
> 
> Fixes: 5e6a98dc4863 ("iwlwifi: mvm: enable TCP/UDP checksum support for 9000 
> family")
> Signed-off-by: Emmanuel Grumbach 
> Signed-off-by: Luca Coelho 
> ---

Emmanuel asked me to send this for the rc-series, since it fixes our
newly supported 9000 family.

--
Luca.

Re: [PATCH 00/24] iwlwifi: updates intended for v4.13 2017-07-28

2017-07-31 Thread Coelho, Luciano
As Emmanuel pointed out, the subject is obviously wrong.  These are
intended for v4.14 as my text correctly says below.

Sorry if this caused confusion.

--
Luca.

On Fri, 2017-07-28 at 17:23 +0300, Luca Coelho wrote:
> From: Luca Coelho 
> 
> Hi,
> 
> Here's my first set of patches for v4.14.  These are the changes:
> 
> * Reorganization of the code into separate directories continues;
> * A couple of new minor features;
> * Fixes and cleanups here and there.
> 
> As usual, I'm pushing this to a pending branch, for kbuild bot, and
> will send a pull-request later.
> 
> Please review.
> 
> Cheers,
> Luca.
> 
> 
> Emmanuel Grumbach (4):
>   iwlwifi: mvm: fix the FIFO numbers in A000 devices
>   iwlwifi: pcie: fix A-MSDU on gen2 devices
>   iwlwifi: mvm: fix TCP CSUM offload with WEP and A000 series
>   iwlwifi: mvm: don't retake the pointer to skb's CB
> 
> Johannes Berg (13):
>   iwlwifi: refactor out paging code
>   iwlwifi: refactor shared mem parsing
>   iwlwifi: track current firmware image in common code
>   iwlwifi: refactor firmware debug code
>   iwlwifi: reorganize firmware API
>   iwlwifi: fw api: fix various kernel-doc warnings
>   iwlwifi: mvm: add and use iwl_mvm_has_unified_ucode()
>   iwlwifi: mvm: check family instead of new TX API for workarounds
>   iwlwifi: mvm: byte-swap constant instead of variable
>   iwlwifi: pcie: rename iwl_trans_check_hw_rf_kill() to pcie
>   iwlwifi: mvm: require AP_LINK_PS for TVQM
>   iwlwifi: mvm: simplify bufferable MMPDU check
>   iwlwifi: mvm: remove non-DQA mode
> 
> Liad Kaufman (1):
>   iwlwifi: mvm: support fw reading empty OTP
> 
> Luca Coelho (2):
>   iwlwifi: mvm: refactor beacon template command code
>   iwlwifi: mvm: rename p2p-specific sta functions to include p2p in the
> names
> 
> Mordechai Goodstein (1):
>   iwlwifi: implement fseq version mismatch warning
> 
> Seraphime Kirkovski (1):
>   iwlwifi: dvm: remove unused defines
> 
> Sharon Dvir (1):
>   iwlwifi: mvm: fix uninitialized var while waiting for queues to empty
> 
> Zamir, Roee (1):
>   iwlwifi: mvm: add compile-time option to disable EBS
> 
>  drivers/net/wireless/intel/iwlwifi/Makefile|2 +
>  drivers/net/wireless/intel/iwlwifi/dvm/commands.h  |   16 -
>  drivers/net/wireless/intel/iwlwifi/fw/api/alive.h  |  206 ++
>  .../net/wireless/intel/iwlwifi/fw/api/binding.h|  144 +
>  .../intel/iwlwifi/fw/{api.h => api/cmdhdr.h}   |   78 +-
>  .../iwlwifi/{mvm/fw-api-coex.h => fw/api/coex.h}   |   11 +-
>  .../net/wireless/intel/iwlwifi/fw/api/commands.h   |  664 +
>  drivers/net/wireless/intel/iwlwifi/fw/api/config.h |  192 ++
>  .../net/wireless/intel/iwlwifi/fw/api/context.h|   94 +
>  .../intel/iwlwifi/{mvm/fw-api-d3.h => fw/api/d3.h} |   11 +-
>  .../net/wireless/intel/iwlwifi/fw/api/datapath.h   |  127 +
>  drivers/net/wireless/intel/iwlwifi/fw/api/debug.h  |  345 +++
>  drivers/net/wireless/intel/iwlwifi/fw/api/filter.h |  183 ++
>  .../net/wireless/intel/iwlwifi/fw/api/mac-cfg.h|  152 ++
>  .../iwlwifi/{mvm/fw-api-mac.h => fw/api/mac.h} |   33 +-
>  .../net/wireless/intel/iwlwifi/fw/api/nvm-reg.h|  386 +++
>  .../net/wireless/intel/iwlwifi/fw/api/offload.h|  101 +
>  drivers/net/wireless/intel/iwlwifi/fw/api/paging.h |  108 +
>  .../net/wireless/intel/iwlwifi/fw/api/phy-ctxt.h   |  164 ++
>  drivers/net/wireless/intel/iwlwifi/fw/api/phy.h|  258 ++
>  .../iwlwifi/{mvm/fw-api-power.h => fw/api/power.h} |   13 +-
>  .../intel/iwlwifi/{mvm/fw-api-rs.h => fw/api/rs.h} |   13 +-
>  .../intel/iwlwifi/{mvm/fw-api-rx.h => fw/api/rx.h} |   31 +-
>  .../iwlwifi/{mvm/fw-api-scan.h => fw/api/scan.h}   |   11 +-
>  drivers/net/wireless/intel/iwlwifi/fw/api/sf.h |  138 +
>  .../iwlwifi/{mvm/fw-api-sta.h => fw/api/sta.h} |   15 +-
>  .../iwlwifi/{mvm/fw-api-stats.h => fw/api/stats.h} |   13 +-
>  drivers/net/wireless/intel/iwlwifi/fw/api/tdls.h   |  208 ++
>  .../net/wireless/intel/iwlwifi/fw/api/time-event.h |  386 +++
>  .../iwlwifi/{mvm/fw-api-tof.h => fw/api/tof.h} |9 +-
>  .../intel/iwlwifi/{mvm/fw-api-tx.h => fw/api/tx.h} |   42 +-
>  drivers/net/wireless/intel/iwlwifi/fw/api/txq.h|  163 ++
>  drivers/net/wireless/intel/iwlwifi/fw/common_rx.c  |   88 +
>  .../intel/iwlwifi/{mvm/fw-dbg.c => fw/dbg.c}   |  438 +--
>  .../intel/iwlwifi/{mvm/fw-dbg.h => fw/dbg.h}   |  125 +-
>  drivers/net/wireless/intel/iwlwifi/fw/init.c   |   75 +
>  drivers/net/wireless/intel/iwlwifi/fw/paging.c |  414 +++
>  drivers/net/wireless/intel/iwlwifi/fw/runtime.h|  156 ++
>  drivers/net/wireless/intel/iwlwifi/fw/smem.c   |  152 ++
>  drivers/net/wireless/intel/iwlwifi/iwl-trans.h |3 +-
>  drivers/net/wireless/intel/iwlwifi/mvm/Makefile|2 +-
>  drivers/net/wireless/intel/iwlwifi/mvm/coex.c  |2 +-
>  drivers/net/wireless/intel/iwlwifi/mvm/constants.h |2 +-
>  .../net/wireless/intel/iwlwifi/mvm/debugfs-vif.c   |2 +-
>  drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c   | 

Re: Re: [PATCH 2/2] mwifiex: pcie: compatible with wifi-only image while extract wifi-part fw

2017-07-31 Thread Xinming Hu
Hi Brian,

Thanks for the review, fix below comment format in V2.

Regards,
Simon

From: Brian Norris 
Sent: Tuesday, August 1, 2017 0:58
To: Xinming Hu
Cc: Linux Wireless; Kalle Valo; Dmitry Torokhov; raja...@google.com; Zhiyuan 
Yang; Tim Song; Cathy Luo; Ganapathi Bhat; Xinming Hu
Subject: [EXT] Re: [PATCH 2/2] mwifiex: pcie: compatible with wifi-only image 
while extract wifi-part fw

External Email

--
Hi,

Two nitpicks below:

On Mon, Jul 31, 2017 at 01:07:27PM +, Xinming Hu wrote:
> From: Xinming Hu 
>
> Sometimes, we might using wifi-only firmware with a combo firmware name,
> in this case, do not need to filter bluetooth part from header.
>
> Signed-off-by: Xinming Hu 
> Signed-off-by: Cathy Luo 
> ---
>  drivers/net/wireless/marvell/mwifiex/pcie.c | 26 +++---
>  1 file changed, 19 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c 
> b/drivers/net/wireless/marvell/mwifiex/pcie.c
> index 3da1eeb..dc4e054 100644
> --- a/drivers/net/wireless/marvell/mwifiex/pcie.c
> +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
> @@ -1985,7 +1985,8 @@ static int mwifiex_pcie_event_complete(struct 
> mwifiex_adapter *adapter,
>   * (3) wifi image.
>   *
>   * This function bypass the header and bluetooth part, return
> - * the offset of tail wifi-only part.
> + * the offset of tail wifi-only part. if the image is already wifi-only,

Sentences start with capital letters (i.e., "If the image ...").

> + * that is start with CMD1, return 0.
>   */
>
>  static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter,
> @@ -1993,7 +1994,7 @@ static int mwifiex_extract_wifi_fw(struct 
> mwifiex_adapter *adapter,
>   const struct mwifiex_fw_data *fwdata;
>   u32 offset = 0, data_len, dnld_cmd;
>   int ret = 0;
> - bool cmd7_before = false;
> + bool cmd7_before = false, first_cmd = false;
>
>   while (1) {
>   /* Check for integer and buffer overflow */
> @@ -2014,20 +2015,29 @@ static int mwifiex_extract_wifi_fw(struct 
> mwifiex_adapter *adapter,
>
>   switch (dnld_cmd) {
>   case MWIFIEX_FW_DNLD_CMD_1:
> - if (!cmd7_before) {
> - mwifiex_dbg(adapter, ERROR,
> - "no cmd7 before cmd1!\n");
> + if (offset + data_len < data_len) {
> + mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
>   ret = -1;
>   goto done;
>   }
> - if (offset + data_len < data_len) {
> - mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
> +
> + /* Image start with cmd1, already wifi-only firmware*/

You need a space before closing the comment. i.e.:

/* Image starts with cmd1; already wifi-only firmware */

Otherwise, I think both of these look fine:

Reviewed-by: Brian Norris 

> + if (!first_cmd) {
> + mwifiex_dbg(adapter, MSG,
> + "input wifi-only firmware\n");
> + return 0;
> + }
> +
> + if (!cmd7_before) {
> + mwifiex_dbg(adapter, ERROR,
> + "no cmd7 before cmd1!\n");
>   ret = -1;
>   goto done;
>   }
>   offset += data_len;
>   break;
>   case MWIFIEX_FW_DNLD_CMD_5:
> + first_cmd = true;
>   /* Check for integer overflow */
>   if (offset + data_len < data_len) {
>   mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
> @@ -2037,6 +2047,7 @@ static int mwifiex_extract_wifi_fw(struct 
> mwifiex_adapter *adapter,
>   offset += data_len;
>   break;
>   case MWIFIEX_FW_DNLD_CMD_6:
> + first_cmd = true;
>   /* Check for integer overflow */
>   if (offset + data_len < data_len) {
>   mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
> @@ -2053,6 +2064,7 @@ static int mwifiex_extract_wifi_fw(struct 
> mwifiex_adapter *adapter,
>   }
>   goto done;
>   case MWIFIEX_FW_DNLD_CMD_7:
> + first_cmd = true;
>   cmd7_before = true;
>   break;
>   default:
> --
> 1.9.1
>


[v2 PATCH 2/2] mwifiex: pcie: compatible with wifi-only image while extract wifi-part fw

2017-07-31 Thread Xinming Hu
From: Xinming Hu 

Sometimes, we might using wifi-only firmware with a combo firmware name,
in this case, do not need to filter bluetooth part from header.

Signed-off-by: Xinming Hu 
Signed-off-by: Cathy Luo 
Reviewed-by: Brian Norris 
---
v2: fix comment format/grammar (Brain)
---
 drivers/net/wireless/marvell/mwifiex/pcie.c | 26 +++---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c 
b/drivers/net/wireless/marvell/mwifiex/pcie.c
index 3da1eeb..dc4e054 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -1985,7 +1985,8 @@ static int mwifiex_pcie_event_complete(struct 
mwifiex_adapter *adapter,
  * (3) wifi image.
  *
  * This function bypass the header and bluetooth part, return
- * the offset of tail wifi-only part.
+ * the offset of tail wifi-only part. If the image is already wifi-only,
+ * that is start with CMD1, return 0.
  */
 
 static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter,
@@ -1993,7 +1994,7 @@ static int mwifiex_extract_wifi_fw(struct mwifiex_adapter 
*adapter,
const struct mwifiex_fw_data *fwdata;
u32 offset = 0, data_len, dnld_cmd;
int ret = 0;
-   bool cmd7_before = false;
+   bool cmd7_before = false, first_cmd = false;
 
while (1) {
/* Check for integer and buffer overflow */
@@ -2014,20 +2015,29 @@ static int mwifiex_extract_wifi_fw(struct 
mwifiex_adapter *adapter,
 
switch (dnld_cmd) {
case MWIFIEX_FW_DNLD_CMD_1:
-   if (!cmd7_before) {
-   mwifiex_dbg(adapter, ERROR,
-   "no cmd7 before cmd1!\n");
+   if (offset + data_len < data_len) {
+   mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
ret = -1;
goto done;
}
-   if (offset + data_len < data_len) {
-   mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
+
+   /* Image start with cmd1, already wifi-only firmware */
+   if (!first_cmd) {
+   mwifiex_dbg(adapter, MSG,
+   "input wifi-only firmware\n");
+   return 0;
+   }
+
+   if (!cmd7_before) {
+   mwifiex_dbg(adapter, ERROR,
+   "no cmd7 before cmd1!\n");
ret = -1;
goto done;
}
offset += data_len;
break;
case MWIFIEX_FW_DNLD_CMD_5:
+   first_cmd = true;
/* Check for integer overflow */
if (offset + data_len < data_len) {
mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
@@ -2037,6 +2047,7 @@ static int mwifiex_extract_wifi_fw(struct mwifiex_adapter 
*adapter,
offset += data_len;
break;
case MWIFIEX_FW_DNLD_CMD_6:
+   first_cmd = true;
/* Check for integer overflow */
if (offset + data_len < data_len) {
mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
@@ -2053,6 +2064,7 @@ static int mwifiex_extract_wifi_fw(struct mwifiex_adapter 
*adapter,
}
goto done;
case MWIFIEX_FW_DNLD_CMD_7:
+   first_cmd = true;
cmd7_before = true;
break;
default:
-- 
1.9.1



Re: [PATCH V5 1/2] firmware: add more flexible request_firmware_async function

2017-07-31 Thread kbuild test robot
Hi Rafał,

[auto build test WARNING on driver-core/driver-core-testing]
[also build test WARNING on v4.13-rc3 next-20170731]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Rafa-Mi-ecki/firmware-add-more-flexible-request_firmware_async-function/20170801-033319
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   WARNING: convert(1) not found, for SVG to PDF conversion install ImageMagick 
(https://www.imagemagick.org)
   include/linux/init.h:1: warning: no structured comments found
   include/linux/mod_devicetable.h:687: warning: Excess 
struct/union/enum/typedef member 'ver_major' description in 'fsl_mc_device_id'
   include/linux/mod_devicetable.h:687: warning: Excess 
struct/union/enum/typedef member 'ver_minor' description in 'fsl_mc_device_id'
   kernel/sched/core.c:2080: warning: No description found for parameter 'rf'
   kernel/sched/core.c:2080: warning: Excess function parameter 'cookie' 
description in 'try_to_wake_up_local'
   include/linux/wait.h:555: warning: No description found for parameter 'wq'
   include/linux/wait.h:555: warning: Excess function parameter 'wq_head' 
description in 'wait_event_interruptible_hrtimeout'
   include/linux/wait.h:759: warning: No description found for parameter 
'wq_head'
   include/linux/wait.h:759: warning: Excess function parameter 'wq' 
description in 'wait_event_killable'
   include/linux/kthread.h:26: warning: Excess function parameter '...' 
description in 'kthread_create'
   kernel/sys.c:1: warning: no structured comments found
   include/linux/device.h:968: warning: No description found for parameter 
'dma_ops'
   drivers/dma-buf/seqno-fence.c:1: warning: no structured comments found
>> drivers/base/firmware_class.c:1: warning: no structured comments found
   include/linux/iio/iio.h:603: warning: No description found for parameter 
'trig_readonly'
   include/linux/iio/trigger.h:151: warning: No description found for parameter 
'indio_dev'
   include/linux/iio/trigger.h:151: warning: No description found for parameter 
'trig'
   include/linux/device.h:969: warning: No description found for parameter 
'dma_ops'
   drivers/ata/libata-eh.c:1449: warning: No description found for parameter 
'link'
   drivers/ata/libata-eh.c:1449: warning: Excess function parameter 'ap' 
description in 'ata_eh_done'
   drivers/ata/libata-eh.c:1590: warning: No description found for parameter 
'qc'
   drivers/ata/libata-eh.c:1590: warning: Excess function parameter 'dev' 
description in 'ata_eh_request_sense'
   drivers/mtd/nand/nand_base.c:2751: warning: Excess function parameter 
'cached' description in 'nand_write_page'
   drivers/mtd/nand/nand_base.c:2751: warning: Excess function parameter 
'cached' description in 'nand_write_page'
   arch/s390/include/asm/cmb.h:1: warning: no structured comments found
   drivers/scsi/scsi_lib.c:1116: warning: No description found for parameter 
'rq'
   drivers/scsi/constants.c:1: warning: no structured comments found
   include/linux/usb/gadget.h:230: warning: No description found for parameter 
'claimed'
   include/linux/usb/gadget.h:230: warning: No description found for parameter 
'enabled'
   include/linux/usb/gadget.h:412: warning: No description found for parameter 
'quirk_altset_not_supp'
   include/linux/usb/gadget.h:412: warning: No description found for parameter 
'quirk_stall_not_supp'
   include/linux/usb/gadget.h:412: warning: No description found for parameter 
'quirk_zlp_not_supp'
   fs/inode.c:1666: warning: No description found for parameter 'rcu'
   include/linux/jbd2.h:443: warning: No description found for parameter 
'i_transaction'
   include/linux/jbd2.h:443: warning: No description found for parameter 
'i_next_transaction'
   include/linux/jbd2.h:443: warning: No description found for parameter 
'i_list'
   include/linux/jbd2.h:443: warning: No description found for parameter 
'i_vfs_inode'
   include/linux/jbd2.h:443: warning: No description found for parameter 
'i_flags'
   include/linux/jbd2.h:497: warning: No description found for parameter 
'h_rsv_handle'
   include/linux/jbd2.h:497: warning: No description found for parameter 
'h_reserved'
   include/linux/jbd2.h:497: warning: No description found for parameter 
'h_type'
   include/linux/jbd2.h:497: warning: No description found for parameter 
'h_line_no'
   include/linux/jbd2.h:497: warning: No description found for parameter 
'h_start_jiffies'
   include/linux/jbd2.h:497: warning: No description found for parameter 
'h_requested_credits'
   include/linux/jbd2.h:497: warning: No description found for parameter 
'saved_alloc_context'
   include/linux/jbd2.h:1050: warning: No description found for parameter 
'j_chkpt_bhs'
   include/linux/jbd2.h:1050: warning: No description found for parameter 
'j_devname'
   include/linux/jbd2.h:1050: warning: No description found for parameter 
'j_average_commit_time'
   include/linux

Re: AP mode with Broadcom 4330

2017-07-31 Thread Arend van Spriel
On 31-07-17 14:59, Russell King - ARM Linux wrote:
> On Fri, Jul 28, 2017 at 09:50:21PM +0200, Arend van Spriel wrote:
>> I was going to agree with you, but having second thoughts. There are
>> actually two use-cases that need to be handled properly. The regular AP
>> case and the MBSS case. In case of MBSS the initial AP interface will
>> have mbss set to false and subsequent AP interfaces will have mbss set
>> to true, but in firmware this has to be configured inverted. That is
>> what the code above is doing. However, this indeed breaks the regular AP
>> case for firmwares that abuse that setting for testing purposes (no idea
>> why that is in a released firmware).
> 
> Maybe detect the BCRM_TEST_SSID string in the firmware file (as it's
> broken up amongst other data, it's not trivial) and disable mbss for
> such firmware?  Alternatively, maybe blacklist mbss for some firmware
> versions?

Well. It seem 43362 chip also had this and we disabled mbss for that
chipset. So we may do that for 4330 as well.

> Do the firmware versions that include this "abuse" actually have
> functional mbss?

Digging through our internal bug database I found a remark that
BRCM_TEST_SSID showing up means mbss is not functional.

> There's also the obvious question: which firmware is recommended for
> the 4330?

We tend to rely on what is released to AOSP as our team does not have
the bandwidth to go through the release process. I checked and it is
still the same so matches what is in linux-firmware.

Regards,
Arend


Re: [PATCH v1 3/6] staging: unisys: Switch to use new generic UUID API

2017-07-31 Thread Andy Shevchenko
On Sun, 2017-07-30 at 10:37 -0700, Greg Kroah-Hartman wrote:
> On Sun, Jul 30, 2017 at 08:26:48PM +0300, Andy Shevchenko wrote:
> > On Sun, Jul 30, 2017 at 6:32 PM, Greg Kroah-Hartman
> >  wrote:

> > > Doesn't apply to the staging tree at all :(
> > 
> > No surprises, it was cooked against uuid tree in the first place.
> > If you agree to take it through staging tree I will prepare a
> > rebased version.
> > Does it sound good?
> 
> You can take it through the uuid tree if it's easier for you, but then
> someone will have to deal with the merge issues...
> 
> If it's easier, I can take it to prevent the merge problems.

Yep! There are so many conflicts that would be better just to push
through your tree.

I have just sent a v2 of this patch separately.

-- 
Andy Shevchenko 
Intel Finland Oy


Re: [PATCH 2/2] mwifiex: pcie: compatible with wifi-only image while extract wifi-part fw

2017-07-31 Thread Brian Norris
Hi,

Two nitpicks below:

On Mon, Jul 31, 2017 at 01:07:27PM +, Xinming Hu wrote:
> From: Xinming Hu 
> 
> Sometimes, we might using wifi-only firmware with a combo firmware name,
> in this case, do not need to filter bluetooth part from header.
> 
> Signed-off-by: Xinming Hu 
> Signed-off-by: Cathy Luo 
> ---
>  drivers/net/wireless/marvell/mwifiex/pcie.c | 26 +++---
>  1 file changed, 19 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c 
> b/drivers/net/wireless/marvell/mwifiex/pcie.c
> index 3da1eeb..dc4e054 100644
> --- a/drivers/net/wireless/marvell/mwifiex/pcie.c
> +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
> @@ -1985,7 +1985,8 @@ static int mwifiex_pcie_event_complete(struct 
> mwifiex_adapter *adapter,
>   * (3) wifi image.
>   *
>   * This function bypass the header and bluetooth part, return
> - * the offset of tail wifi-only part.
> + * the offset of tail wifi-only part. if the image is already wifi-only,

Sentences start with capital letters (i.e., "If the image ...").

> + * that is start with CMD1, return 0.
>   */
>  
>  static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter,
> @@ -1993,7 +1994,7 @@ static int mwifiex_extract_wifi_fw(struct 
> mwifiex_adapter *adapter,
>   const struct mwifiex_fw_data *fwdata;
>   u32 offset = 0, data_len, dnld_cmd;
>   int ret = 0;
> - bool cmd7_before = false;
> + bool cmd7_before = false, first_cmd = false;
>  
>   while (1) {
>   /* Check for integer and buffer overflow */
> @@ -2014,20 +2015,29 @@ static int mwifiex_extract_wifi_fw(struct 
> mwifiex_adapter *adapter,
>  
>   switch (dnld_cmd) {
>   case MWIFIEX_FW_DNLD_CMD_1:
> - if (!cmd7_before) {
> - mwifiex_dbg(adapter, ERROR,
> - "no cmd7 before cmd1!\n");
> + if (offset + data_len < data_len) {
> + mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
>   ret = -1;
>   goto done;
>   }
> - if (offset + data_len < data_len) {
> - mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
> +
> + /* Image start with cmd1, already wifi-only firmware*/

You need a space before closing the comment. i.e.:

/* Image starts with cmd1; already wifi-only firmware */

Otherwise, I think both of these look fine:

Reviewed-by: Brian Norris 

> + if (!first_cmd) {
> + mwifiex_dbg(adapter, MSG,
> + "input wifi-only firmware\n");
> + return 0;
> + }
> +
> + if (!cmd7_before) {
> + mwifiex_dbg(adapter, ERROR,
> + "no cmd7 before cmd1!\n");
>   ret = -1;
>   goto done;
>   }
>   offset += data_len;
>   break;
>   case MWIFIEX_FW_DNLD_CMD_5:
> + first_cmd = true;
>   /* Check for integer overflow */
>   if (offset + data_len < data_len) {
>   mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
> @@ -2037,6 +2047,7 @@ static int mwifiex_extract_wifi_fw(struct 
> mwifiex_adapter *adapter,
>   offset += data_len;
>   break;
>   case MWIFIEX_FW_DNLD_CMD_6:
> + first_cmd = true;
>   /* Check for integer overflow */
>   if (offset + data_len < data_len) {
>   mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
> @@ -2053,6 +2064,7 @@ static int mwifiex_extract_wifi_fw(struct 
> mwifiex_adapter *adapter,
>   }
>   goto done;
>   case MWIFIEX_FW_DNLD_CMD_7:
> + first_cmd = true;
>   cmd7_before = true;
>   break;
>   default:
> -- 
> 1.9.1
> 


Re: QCA9994 ath10k chipset

2017-07-31 Thread Ben Greear

Very likely 9984 firmware works for 9994, usually the '9' just means
it is expensive and high-temp and/or high-power capable.

I don't know of any 9994 NIC manufacturersYou might could get some
from zcomax or compex, but might take a special order.

Thanks,
Ben

On 07/31/2017 05:47 AM, Matteo Grandi wrote:

Dear all,

I have to find a miniPCIe Wi-Fi adapters that uses the QCA9994 chipset.
As far as I discovered looking to the Internet, seems that only the
Acelink EW-7956MAC uses the QCA9994 chipset, but I didn't find a
dealer where to purchase it. Contacting Acelink is useless because
their email " cont...@acelink.com.tw" seems to be inexistent: I
receive a mail delivery status notification.


Moreover, having a look on Kalle Valo git repo, I didn't find any
QCA9994 but only QCA9984 firmwares. And it's quite easier to find
devices that use the QCA9984 chipset.


Does anyone use/have used such QCA9994 chipset?
Any hint to find a QCA9994 device and its related ath10k firmware will
be really appreciated.

Thank you in advance

Matteo



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


[PATCH 04/10] wil6210: check no_fw_recovery in resume failure recovery

2017-07-31 Thread Maya Erez
Reset 11ad device on resume failure only if no_fw_recovery
is not set.

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

diff --git a/drivers/net/wireless/ath/wil6210/pm.c 
b/drivers/net/wireless/ath/wil6210/pm.c
index ce1f384..4548829 100644
--- a/drivers/net/wireless/ath/wil6210/pm.c
+++ b/drivers/net/wireless/ath/wil6210/pm.c
@@ -85,7 +85,9 @@ static int wil_resume_keep_radio_on(struct wil6210_priv *wil)
/* Send WMI resume request to the device */
rc = wmi_resume(wil);
if (rc) {
-   wil_err(wil, "device failed to resume (%d), resetting\n", rc);
+   wil_err(wil, "device failed to resume (%d)\n", rc);
+   if (no_fw_recovery)
+   goto out;
rc = wil_down(wil);
if (rc) {
wil_err(wil, "wil_down failed (%d)\n", rc);
-- 
1.9.1



[PATCH 10/10] wil6210: make debugfs compilation optional

2017-07-31 Thread Maya Erez
From: Gidon Studinski 

Since debugfs is a kernel configuration option, enable the driver to
compile without debugfs.

Signed-off-by: Gidon Studinski 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/debugfs.c | 14 ++
 drivers/net/wireless/ath/wil6210/main.c|  1 +
 drivers/net/wireless/ath/wil6210/txrx.c|  6 +++---
 drivers/net/wireless/ath/wil6210/wil6210.h |  2 +-
 4 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c 
b/drivers/net/wireless/ath/wil6210/debugfs.c
index 97d79a9..0ef8e0c 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -14,6 +14,10 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include "wil6210.h"
+
+#ifdef CONFIG_DEBUG_FS
+
 #include 
 #include 
 #include 
@@ -21,7 +25,6 @@
 #include 
 #include 
 
-#include "wil6210.h"
 #include "wmi.h"
 #include "txrx.h"
 #include "pmc.h"
@@ -30,7 +33,6 @@
 static u32 mem_addr;
 static u32 dbg_txdesc_index;
 static u32 dbg_vring_index; /* 24+ for Rx, 0..23 for Tx */
-u32 vring_idle_trsh = 16; /* HW fetches up to 16 descriptors at once */
 
 enum dbg_off_type {
doff_u32 = 0,
@@ -1815,6 +1817,7 @@ static void wil6210_debugfs_init_isr(struct wil6210_priv 
*wil,
WIL_FIELD(chip_revision, 0444,  doff_u8),
WIL_FIELD(abft_len, 0644,   doff_u8),
WIL_FIELD(wakeup_trigger, 0644, doff_u8),
+   WIL_FIELD(vring_idle_trsh, 0644,doff_u32),
{},
 };
 
@@ -1830,8 +1833,6 @@ static void wil6210_debugfs_init_isr(struct wil6210_priv 
*wil,
{"desc_index",  0644, (ulong)_txdesc_index, doff_u32},
{"vring_index", 0644, (ulong)_vring_index, doff_u32},
{"mem_addr",0644, (ulong)_addr, doff_u32},
-   {"vring_idle_trsh", 0644, (ulong)_idle_trsh,
-doff_u32},
{"led_polarity", 0644, (ulong)_polarity, doff_u8},
{},
 };
@@ -1892,3 +1893,8 @@ void wil6210_debugfs_remove(struct wil6210_priv *wil)
 */
wil_pmc_free(wil, false);
 }
+
+#else /* !CONFIG_DEBUG_FS */
+int wil6210_debugfs_init(struct wil6210_priv *wil) { return 0; }
+void wil6210_debugfs_remove(struct wil6210_priv *wil) {}
+#endif
diff --git a/drivers/net/wireless/ath/wil6210/main.c 
b/drivers/net/wireless/ath/wil6210/main.c
index b89d017..e2ea490 100644
--- a/drivers/net/wireless/ath/wil6210/main.c
+++ b/drivers/net/wireless/ath/wil6210/main.c
@@ -581,6 +581,7 @@ int wil_priv_init(struct wil6210_priv *wil)
  WMI_WAKEUP_TRIGGER_BCAST;
memset(>suspend_stats, 0, sizeof(wil->suspend_stats));
wil->suspend_stats.min_suspend_time = ULONG_MAX;
+   wil->vring_idle_trsh = 16;
 
return 0;
 
diff --git a/drivers/net/wireless/ath/wil6210/txrx.c 
b/drivers/net/wireless/ath/wil6210/txrx.c
index ec57bcc..389c718 100644
--- a/drivers/net/wireless/ath/wil6210/txrx.c
+++ b/drivers/net/wireless/ath/wil6210/txrx.c
@@ -1666,7 +1666,7 @@ static int __wil_tx_vring_tso(struct wil6210_priv *wil, 
struct vring *vring,
 
/* performance monitoring */
used = wil_vring_used_tx(vring);
-   if (wil_val_in_range(vring_idle_trsh,
+   if (wil_val_in_range(wil->vring_idle_trsh,
 used, used + descs_used)) {
txdata->idle += get_cycles() - txdata->last_idle;
wil_dbg_txrx(wil,  "Ring[%2d] not idle %d -> %d\n",
@@ -1813,7 +1813,7 @@ static int __wil_tx_vring(struct wil6210_priv *wil, 
struct vring *vring,
 
/* performance monitoring */
used = wil_vring_used_tx(vring);
-   if (wil_val_in_range(vring_idle_trsh,
+   if (wil_val_in_range(wil->vring_idle_trsh,
 used, used + nr_frags + 1)) {
txdata->idle += get_cycles() - txdata->last_idle;
wil_dbg_txrx(wil,  "Ring[%2d] not idle %d -> %d\n",
@@ -2175,7 +2175,7 @@ int wil_tx_complete(struct wil6210_priv *wil, int ringid)
 
/* performance monitoring */
used_new = wil_vring_used_tx(vring);
-   if (wil_val_in_range(vring_idle_trsh,
+   if (wil_val_in_range(wil->vring_idle_trsh,
 used_new, used_before_complete)) {
wil_dbg_txrx(wil, "Ring[%2d] idle %d -> %d\n",
 ringid, used_before_complete, used_new);
diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h 
b/drivers/net/wireless/ath/wil6210/wil6210.h
index 9ad7b11..bdfcd72 100644
--- a/drivers/net/wireless/ath/wil6210/wil6210.h
+++ b/drivers/net/wireless/ath/wil6210/wil6210.h
@@ -30,7 +30,6 @@
 extern unsigned int mtu_max;
 extern unsigned short rx_ring_overflow_thrsh;
 extern int agg_wsize;
-extern u32 vring_idle_trsh;
 extern bool rx_align_2;
 extern bool rx_large_buf;
 extern bool debug_fw;
@@ -703,6 +702,7 @@ struct wil6210_priv {
u8 

[PATCH 09/10] wil6210: store FW RF calibration result

2017-07-31 Thread Maya Erez
From: Dedy Lansky 

Store initial FW RF calibration result in driver. Set this calibration
result back to FW after each FW reset in order to avoid future calibration
procedures.

Signed-off-by: Dedy Lansky 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/main.c| 6 ++
 drivers/net/wireless/ath/wil6210/wil6210.h | 6 ++
 drivers/net/wireless/ath/wil6210/wmi.c | 5 +
 drivers/net/wireless/ath/wil6210/wmi.h | 2 ++
 4 files changed, 19 insertions(+)

diff --git a/drivers/net/wireless/ath/wil6210/main.c 
b/drivers/net/wireless/ath/wil6210/main.c
index b1e2814..b89d017 100644
--- a/drivers/net/wireless/ath/wil6210/main.c
+++ b/drivers/net/wireless/ath/wil6210/main.c
@@ -1034,6 +1034,12 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw)
wil_s(wil, RGF_CAF_ICR + offsetof(struct RGF_ICR, ICR), 0);
wil_w(wil, RGF_CAF_ICR + offsetof(struct RGF_ICR, IMV), ~0);
 
+   if (wil->fw_calib_result > 0) {
+   __le32 val = cpu_to_le32(wil->fw_calib_result |
+(CALIB_RESULT_SIGNATURE << 8));
+   wil_w(wil, RGF_USER_FW_CALIB_RESULT, (u32 __force)val);
+   }
+
wil_release_cpu(wil);
}
 
diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h 
b/drivers/net/wireless/ath/wil6210/wil6210.h
index f1488299..9ad7b11 100644
--- a/drivers/net/wireless/ath/wil6210/wil6210.h
+++ b/drivers/net/wireless/ath/wil6210/wil6210.h
@@ -171,6 +171,10 @@ struct RGF_ICR {
 #define RGF_USER_USER_SCRATCH_PAD  (0x8802bc)
 #define RGF_USER_BL(0x880A3C) /* Boot Loader */
 #define RGF_USER_FW_REV_ID (0x880a8c) /* chip revision */
+#define RGF_USER_FW_CALIB_RESULT   (0x880a90) /* b0-7:result
+   * b8-15:signature
+   */
+   #define CALIB_RESULT_SIGNATURE  (0x11)
 #define RGF_USER_CLKS_CTL_0(0x880abc)
#define BIT_USER_CLKS_CAR_AHB_SW_SELBIT(1) /* ref clk/PLL */
#define BIT_USER_CLKS_RST_PWGD  BIT(11) /* reset on "power good" */
@@ -735,6 +739,8 @@ struct wil6210_priv {
 
enum wmi_ps_profile_type ps_profile;
 
+   int fw_calib_result;
+
 #ifdef CONFIG_PM
 #ifdef CONFIG_PM_SLEEP
struct notifier_block pm_notify;
diff --git a/drivers/net/wireless/ath/wil6210/wmi.c 
b/drivers/net/wireless/ath/wil6210/wmi.c
index a9487f2..ffdd2fa 100644
--- a/drivers/net/wireless/ath/wil6210/wmi.c
+++ b/drivers/net/wireless/ath/wil6210/wmi.c
@@ -344,6 +344,11 @@ static void wmi_evt_ready(struct wil6210_priv *wil, int 
id, void *d, int len)
strlcpy(wdev->wiphy->fw_version, wil->fw_version,
sizeof(wdev->wiphy->fw_version));
 
+   if (len > offsetof(struct wmi_ready_event, rfc_read_calib_result)) {
+   wil_dbg_wmi(wil, "rfc calibration result %d\n",
+   evt->rfc_read_calib_result);
+   wil->fw_calib_result = evt->rfc_read_calib_result;
+   }
wil_set_recovery_state(wil, fw_recovery_idle);
set_bit(wil_status_fwready, wil->status);
/* let the reset sequence continue */
diff --git a/drivers/net/wireless/ath/wil6210/wmi.h 
b/drivers/net/wireless/ath/wil6210/wmi.h
index 4e31c2f..1b426d7 100644
--- a/drivers/net/wireless/ath/wil6210/wmi.h
+++ b/drivers/net/wireless/ath/wil6210/wmi.h
@@ -1300,6 +1300,8 @@ struct wmi_ready_event {
/* enum wmi_phy_capability */
u8 phy_capability;
u8 numof_additional_mids;
+   u8 rfc_read_calib_result;
+   u8 reserved[3];
 } __packed;
 
 /* WMI_NOTIFY_REQ_DONE_EVENTID */
-- 
1.9.1



[PATCH 01/10] wil6210: protect against invalid length of tx management frame

2017-07-31 Thread Maya Erez
From: Hamad Kadmany 

Validate buffer length has the minimum needed size
when sending management frame to protect against
possible buffer overrun.

Signed-off-by: Hamad Kadmany 
Signed-off-by: Lior David 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/cfg80211.c | 3 +++
 drivers/net/wireless/ath/wil6210/debugfs.c  | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c 
b/drivers/net/wireless/ath/wil6210/cfg80211.c
index 0b5383a..77af749 100644
--- a/drivers/net/wireless/ath/wil6210/cfg80211.c
+++ b/drivers/net/wireless/ath/wil6210/cfg80211.c
@@ -884,6 +884,9 @@ int wil_cfg80211_mgmt_tx(struct wiphy *wiphy, struct 
wireless_dev *wdev,
wil_hex_dump_misc("mgmt tx frame ", DUMP_PREFIX_OFFSET, 16, 1, buf,
  len, true);
 
+   if (len < sizeof(struct ieee80211_hdr_3addr))
+   return -EINVAL;
+
cmd = kmalloc(sizeof(*cmd) + len, GFP_KERNEL);
if (!cmd) {
rc = -ENOMEM;
diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c 
b/drivers/net/wireless/ath/wil6210/debugfs.c
index f82506d..a2b5d59 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -801,6 +801,9 @@ static ssize_t wil_write_file_txmgmt(struct file *file, 
const char __user *buf,
int rc;
void *frame;
 
+   if (!len)
+   return -EINVAL;
+
frame = memdup_user(buf, len);
if (IS_ERR(frame))
return PTR_ERR(frame);
-- 
1.9.1



[PATCH 08/10] wil6210: fix interface-up check

2017-07-31 Thread Maya Erez
From: Hamad Kadmany 

While wil_open is executed, any call to netif_running
would return a success. In case there are failures
within wil_open, should not treat the device as if it
is already opened in relevant functions (like FW recovery
and runtime suspend check).

Fix that by checking the device up flag instead.

Signed-off-by: Hamad Kadmany 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/main.c | 3 ++-
 drivers/net/wireless/ath/wil6210/pm.c   | 4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/main.c 
b/drivers/net/wireless/ath/wil6210/main.c
index 8968c2c..b1e2814 100644
--- a/drivers/net/wireless/ath/wil6210/main.c
+++ b/drivers/net/wireless/ath/wil6210/main.c
@@ -394,10 +394,11 @@ static void wil_fw_error_worker(struct work_struct *work)
struct wil6210_priv *wil = container_of(work, struct wil6210_priv,
fw_error_worker);
struct wireless_dev *wdev = wil->wdev;
+   struct net_device *ndev = wil_to_ndev(wil);
 
wil_dbg_misc(wil, "fw error worker\n");
 
-   if (!netif_running(wil_to_ndev(wil))) {
+   if (!(ndev->flags & IFF_UP)) {
wil_info(wil, "No recovery - interface is down\n");
return;
}
diff --git a/drivers/net/wireless/ath/wil6210/pm.c 
b/drivers/net/wireless/ath/wil6210/pm.c
index 4a18f8e..4f61dc1 100644
--- a/drivers/net/wireless/ath/wil6210/pm.c
+++ b/drivers/net/wireless/ath/wil6210/pm.c
@@ -24,6 +24,7 @@ int wil_can_suspend(struct wil6210_priv *wil, bool is_runtime)
 {
int rc = 0;
struct wireless_dev *wdev = wil->wdev;
+   struct net_device *ndev = wil_to_ndev(wil);
bool wmi_only = test_bit(WMI_FW_CAPABILITY_WMI_ONLY,
 wil->fw_capabilities);
 
@@ -35,7 +36,8 @@ int wil_can_suspend(struct wil6210_priv *wil, bool is_runtime)
rc = -EPERM;
goto out;
}
-   if (!netif_running(wil_to_ndev(wil))) {
+
+   if (!(ndev->flags & IFF_UP)) {
/* can always sleep when down */
wil_dbg_pm(wil, "Interface is down\n");
goto out;
-- 
1.9.1



[PATCH 02/10] wil6210: allow configuring scan timers

2017-07-31 Thread Maya Erez
From: Hamad Kadmany 

Allow setting scan timeout and scan dwell time
through module parameters.

Signed-off-by: Hamad Kadmany 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/cfg80211.c | 17 ++---
 drivers/net/wireless/ath/wil6210/wil6210.h  |  2 +-
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c 
b/drivers/net/wireless/ath/wil6210/cfg80211.c
index 77af749..d079533 100644
--- a/drivers/net/wireless/ath/wil6210/cfg80211.c
+++ b/drivers/net/wireless/ath/wil6210/cfg80211.c
@@ -26,6 +26,14 @@
 module_param(disable_ap_sme, bool, 0444);
 MODULE_PARM_DESC(disable_ap_sme, " let user space handle AP mode SME");
 
+static uint scan_dwell_time  = WMI_SCAN_DWELL_TIME_MS;
+module_param(scan_dwell_time, uint, 0644);
+MODULE_PARM_DESC(scan_dwell_time, " Scan dwell time (msec)");
+
+static uint scan_timeout = WIL6210_SCAN_TO_SEC;
+module_param(scan_timeout, uint, 0644);
+MODULE_PARM_DESC(scan_timeout, " Scan timeout (seconds)");
+
 #define CHAN60G(_channel, _flags) {\
.band   = NL80211_BAND_60GHZ,   \
.center_freq= 56160 + (2160 * (_channel)),  \
@@ -528,8 +536,9 @@ static int wil_cfg80211_scan(struct wiphy *wiphy,
 
(void)wil_p2p_stop_discovery(wil);
 
-   wil_dbg_misc(wil, "Start scan_request 0x%p\n", request);
-   wil_dbg_misc(wil, "SSID count: %d", request->n_ssids);
+   wil_dbg_misc(wil,
+"Start scan_request 0x%p, dwell_time %dms, timeout %dsec, 
SSID count %d\n",
+request, scan_dwell_time, scan_timeout, request->n_ssids);
 
for (i = 0; i < request->n_ssids; i++) {
wil_dbg_misc(wil, "SSID[%d]", i);
@@ -550,10 +559,12 @@ static int wil_cfg80211_scan(struct wiphy *wiphy,
}
 
wil->scan_request = request;
-   mod_timer(>scan_timer, jiffies + WIL6210_SCAN_TO);
+   mod_timer(>scan_timer,
+ jiffies + msecs_to_jiffies(1000U * scan_timeout));
 
memset(, 0, sizeof(cmd));
cmd.cmd.scan_type = WMI_ACTIVE_SCAN;
+   cmd.cmd.dwell_time = cpu_to_le32(scan_dwell_time);
cmd.cmd.num_channels = 0;
n = min(request->n_channels, 4U);
for (i = 0; i < n; i++) {
diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h 
b/drivers/net/wireless/ath/wil6210/wil6210.h
index d085ccf..ac32284 100644
--- a/drivers/net/wireless/ath/wil6210/wil6210.h
+++ b/drivers/net/wireless/ath/wil6210/wil6210.h
@@ -112,7 +112,7 @@ static inline u32 wil_mtu2macbuf(u32 mtu)
 #define WIL6210_ITR_RX_MAX_BURST_DURATION_DEFAULT (500) /* usec */
 #define WIL6210_FW_RECOVERY_RETRIES(5) /* try to recover this many times */
 #define WIL6210_FW_RECOVERY_TO msecs_to_jiffies(5000)
-#define WIL6210_SCAN_TOmsecs_to_jiffies(1)
+#define WIL6210_SCAN_TO_SEC10
 #define WIL6210_DISCONNECT_TO_MS (2000)
 #define WIL6210_RX_HIGH_TRSH_INIT  (0)
 #define WIL6210_RX_HIGH_TRSH_DEFAULT \
-- 
1.9.1



[PATCH 05/10] wil6210: run-time PM when interface down

2017-07-31 Thread Maya Erez
From: Lazar Alexei 

Allow run-time suspend when interface is down, keep card alive when
interface is up.
If driver is in wmi only or debug_fw mode run-time PM won't suspend.

Signed-off-by: Lazar Alexei 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/debugfs.c  | 85 ++---
 drivers/net/wireless/ath/wil6210/ethtool.c  | 15 +
 drivers/net/wireless/ath/wil6210/netdev.c   | 18 +-
 drivers/net/wireless/ath/wil6210/pcie_bus.c | 35 
 drivers/net/wireless/ath/wil6210/pm.c   | 62 +
 drivers/net/wireless/ath/wil6210/wil6210.h  | 16 ++
 6 files changed, 222 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c 
b/drivers/net/wireless/ath/wil6210/debugfs.c
index 21b6611..8a0e64c 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -244,12 +244,19 @@ static void wil_print_ring(struct seq_file *s, const char 
*prefix,
 static int wil_mbox_debugfs_show(struct seq_file *s, void *data)
 {
struct wil6210_priv *wil = s->private;
+   int ret;
+
+   ret = wil_pm_runtime_get(wil);
+   if (ret < 0)
+   return ret;
 
wil_print_ring(s, "tx", wil->csr + HOST_MBOX +
   offsetof(struct wil6210_mbox_ctl, tx));
wil_print_ring(s, "rx", wil->csr + HOST_MBOX +
   offsetof(struct wil6210_mbox_ctl, rx));
 
+   wil_pm_runtime_put(wil);
+
return 0;
 }
 
@@ -267,15 +274,37 @@ static int wil_mbox_seq_open(struct inode *inode, struct 
file *file)
 
 static int wil_debugfs_iomem_x32_set(void *data, u64 val)
 {
-   writel(val, (void __iomem *)data);
+   struct wil_debugfs_iomem_data *d = (struct
+   wil_debugfs_iomem_data *)data;
+   struct wil6210_priv *wil = d->wil;
+   int ret;
+
+   ret = wil_pm_runtime_get(wil);
+   if (ret < 0)
+   return ret;
+
+   writel(val, (void __iomem *)d->offset);
wmb(); /* make sure write propagated to HW */
 
+   wil_pm_runtime_put(wil);
+
return 0;
 }
 
 static int wil_debugfs_iomem_x32_get(void *data, u64 *val)
 {
-   *val = readl((void __iomem *)data);
+   struct wil_debugfs_iomem_data *d = (struct
+   wil_debugfs_iomem_data *)data;
+   struct wil6210_priv *wil = d->wil;
+   int ret;
+
+   ret = wil_pm_runtime_get(wil);
+   if (ret < 0)
+   return ret;
+
+   *val = readl((void __iomem *)d->offset);
+
+   wil_pm_runtime_put(wil);
 
return 0;
 }
@@ -286,10 +315,21 @@ static int wil_debugfs_iomem_x32_get(void *data, u64 *val)
 static struct dentry *wil_debugfs_create_iomem_x32(const char *name,
   umode_t mode,
   struct dentry *parent,
-  void *value)
+  void *value,
+  struct wil6210_priv *wil)
 {
-   return debugfs_create_file(name, mode, parent, value,
-  _iomem_x32);
+   struct dentry *file;
+   struct wil_debugfs_iomem_data *data = >dbg_data.data_arr[
+ wil->dbg_data.iomem_data_count];
+
+   data->wil = wil;
+   data->offset = value;
+
+   file = debugfs_create_file(name, mode, parent, data, _iomem_x32);
+   if (!IS_ERR_OR_NULL(file))
+   wil->dbg_data.iomem_data_count++;
+
+   return file;
 }
 
 static int wil_debugfs_ulong_set(void *data, u64 val)
@@ -348,7 +388,8 @@ static void wil6210_debugfs_init_offset(struct wil6210_priv 
*wil,
case doff_io32:
f = wil_debugfs_create_iomem_x32(tbl[i].name,
 tbl[i].mode, dbg,
-base + tbl[i].off);
+base + tbl[i].off,
+wil);
break;
case doff_u8:
f = debugfs_create_u8(tbl[i].name, tbl[i].mode, dbg,
@@ -504,10 +545,12 @@ static ssize_t wil_read_file_ioblob(struct file *file, 
char __user *user_buf,
 {
enum { max_count = 4096 };
struct wil_blob_wrapper *wil_blob = file->private_data;
+   struct wil6210_priv *wil = wil_blob->wil;
loff_t pos = *ppos;
size_t available = wil_blob->blob.size;
void *buf;
size_t ret;
+   int rc;
 
if (test_bit(wil_status_suspending, wil_blob->wil->status) ||
test_bit(wil_status_suspended, wil_blob->wil->status))
@@ -528,10 +571,19 @@ static ssize_t 

[PATCH 06/10] wil6210: add statistics for suspend time

2017-07-31 Thread Maya Erez
Add statistics for total, min and max suspend time, that
calculates the time the 11ad device was in suspend.
Those statistics will help to estimate the power impact
of d3hot feature.

Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/debugfs.c | 17 +++--
 drivers/net/wireless/ath/wil6210/main.c|  2 ++
 drivers/net/wireless/ath/wil6210/pm.c  | 20 ++--
 drivers/net/wireless/ath/wil6210/wil6210.h |  5 +
 4 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c 
b/drivers/net/wireless/ath/wil6210/debugfs.c
index 8a0e64c..97d79a9 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -1669,6 +1669,8 @@ static ssize_t wil_write_suspend_stats(struct file *file,
struct wil6210_priv *wil = file->private_data;
 
memset(>suspend_stats, 0, sizeof(wil->suspend_stats));
+   wil->suspend_stats.min_suspend_time = ULONG_MAX;
+   wil->suspend_stats.collection_start = ktime_get();
 
return len;
 }
@@ -1680,18 +1682,27 @@ static ssize_t wil_read_suspend_stats(struct file *file,
struct wil6210_priv *wil = file->private_data;
static char text[400];
int n;
+   unsigned long long stats_collection_time =
+   ktime_to_us(ktime_sub(ktime_get(),
+ wil->suspend_stats.collection_start));
 
n = snprintf(text, sizeof(text),
 "Suspend statistics:\n"
 "successful suspends:%ld failed suspends:%ld\n"
 "successful resumes:%ld failed resumes:%ld\n"
-"rejected by host:%ld rejected by device:%ld\n",
+"rejected by host:%ld rejected by device:%ld\n"
+"total suspend time:%lld min suspend time:%lld\n"
+"max suspend time:%lld stats collection time: %lld\n",
 wil->suspend_stats.successful_suspends,
 wil->suspend_stats.failed_suspends,
 wil->suspend_stats.successful_resumes,
 wil->suspend_stats.failed_resumes,
 wil->suspend_stats.rejected_by_host,
-wil->suspend_stats.rejected_by_device);
+wil->suspend_stats.rejected_by_device,
+wil->suspend_stats.total_suspend_time,
+wil->suspend_stats.min_suspend_time,
+wil->suspend_stats.max_suspend_time,
+stats_collection_time);
 
n = min_t(int, n, sizeof(text));
 
@@ -1864,6 +1875,8 @@ int wil6210_debugfs_init(struct wil6210_priv *wil)
 
wil6210_debugfs_create_ITR_CNT(wil, dbg);
 
+   wil->suspend_stats.collection_start = ktime_get();
+
return 0;
 }
 
diff --git a/drivers/net/wireless/ath/wil6210/main.c 
b/drivers/net/wireless/ath/wil6210/main.c
index daf944a..8968c2c 100644
--- a/drivers/net/wireless/ath/wil6210/main.c
+++ b/drivers/net/wireless/ath/wil6210/main.c
@@ -578,6 +578,8 @@ int wil_priv_init(struct wil6210_priv *wil)
 
wil->wakeup_trigger = WMI_WAKEUP_TRIGGER_UCAST |
  WMI_WAKEUP_TRIGGER_BCAST;
+   memset(>suspend_stats, 0, sizeof(wil->suspend_stats));
+   wil->suspend_stats.min_suspend_time = ULONG_MAX;
 
return 0;
 
diff --git a/drivers/net/wireless/ath/wil6210/pm.c 
b/drivers/net/wireless/ath/wil6210/pm.c
index 976c9aa..4a18f8e 100644
--- a/drivers/net/wireless/ath/wil6210/pm.c
+++ b/drivers/net/wireless/ath/wil6210/pm.c
@@ -321,6 +321,9 @@ int wil_suspend(struct wil6210_priv *wil, bool is_runtime)
wil_dbg_pm(wil, "suspend: %s => %d\n",
   is_runtime ? "runtime" : "system", rc);
 
+   if (!rc)
+   wil->suspend_stats.suspend_start_time = ktime_get();
+
return rc;
 }
 
@@ -330,6 +333,7 @@ int wil_resume(struct wil6210_priv *wil, bool is_runtime)
struct net_device *ndev = wil_to_ndev(wil);
bool keep_radio_on = ndev->flags & IFF_UP &&
 wil->keep_radio_on_during_sleep;
+   unsigned long long suspend_time_usec = 0;
 
wil_dbg_pm(wil, "resume: %s\n", is_runtime ? "runtime" : "system");
 
@@ -347,9 +351,21 @@ int wil_resume(struct wil6210_priv *wil, bool is_runtime)
else
rc = wil_resume_radio_off(wil);
 
+   if (rc)
+   goto out;
+
+   suspend_time_usec =
+   ktime_to_us(ktime_sub(ktime_get(),
+ wil->suspend_stats.suspend_start_time));
+   wil->suspend_stats.total_suspend_time += suspend_time_usec;
+   if (suspend_time_usec < wil->suspend_stats.min_suspend_time)
+   wil->suspend_stats.min_suspend_time = suspend_time_usec;
+   if (suspend_time_usec > wil->suspend_stats.max_suspend_time)
+   wil->suspend_stats.max_suspend_time = suspend_time_usec;
+
 out:
- 

[PATCH 00/10] wil6210 patches

2017-07-31 Thread Maya Erez
The following patches incude:
- wil6210 bug fixes
- Addition of runtime PM support

Dedy Lansky (2):
  wil6210: support FW RSSI reporting
  wil6210: store FW RF calibration result

Gidon Studinski (1):
  wil6210: make debugfs compilation optional

Hamad Kadmany (3):
  wil6210: protect against invalid length of tx management frame
  wil6210: allow configuring scan timers
  wil6210: fix interface-up check

Lazar Alexei (1):
  wil6210: run-time PM when interface down

Maya Erez (3):
  wil6210: check no_fw_recovery in resume failure recovery
  wil6210: add statistics for suspend time
  wil6210: notify wiphy on wowlan support

 drivers/net/wireless/ath/wil6210/cfg80211.c |  42 --
 drivers/net/wireless/ath/wil6210/debugfs.c  | 121 +---
 drivers/net/wireless/ath/wil6210/ethtool.c  |  15 
 drivers/net/wireless/ath/wil6210/main.c |  12 ++-
 drivers/net/wireless/ath/wil6210/netdev.c   |  18 -
 drivers/net/wireless/ath/wil6210/pcie_bus.c |  38 +
 drivers/net/wireless/ath/wil6210/pm.c   |  90 -
 drivers/net/wireless/ath/wil6210/txrx.c |   6 +-
 drivers/net/wireless/ath/wil6210/wil6210.h  |  31 ++-
 drivers/net/wireless/ath/wil6210/wmi.c  |  14 +++-
 drivers/net/wireless/ath/wil6210/wmi.h  |   8 +-
 11 files changed, 358 insertions(+), 37 deletions(-)

-- 
1.9.1



[PATCH 07/10] wil6210: notify wiphy on wowlan support

2017-07-31 Thread Maya Erez
Set wowlan to indicate that 11ad device can wake-up
on any trigger and disconnect.

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

diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c 
b/drivers/net/wireless/ath/wil6210/cfg80211.c
index c860c0c..61e872c 100644
--- a/drivers/net/wireless/ath/wil6210/cfg80211.c
+++ b/drivers/net/wireless/ath/wil6210/cfg80211.c
@@ -34,6 +34,12 @@
 module_param(scan_timeout, uint, 0644);
 MODULE_PARM_DESC(scan_timeout, " Scan timeout (seconds)");
 
+#ifdef CONFIG_PM
+static struct wiphy_wowlan_support wil_wowlan_support = {
+   .flags = WIPHY_WOWLAN_ANY | WIPHY_WOWLAN_DISCONNECT,
+};
+#endif
+
 #define CHAN60G(_channel, _flags) {\
.band   = NL80211_BAND_60GHZ,   \
.center_freq= 56160 + (2160 * (_channel)),  \
@@ -1819,6 +1825,10 @@ static void wil_wiphy_init(struct wiphy *wiphy)
 
wiphy->n_vendor_commands = ARRAY_SIZE(wil_nl80211_vendor_commands);
wiphy->vendor_commands = wil_nl80211_vendor_commands;
+
+#ifdef CONFIG_PM
+   wiphy->wowlan = _wowlan_support;
+#endif
 }
 
 struct wireless_dev *wil_cfg80211_init(struct device *dev)
-- 
1.9.1



[PATCH 03/10] wil6210: support FW RSSI reporting

2017-07-31 Thread Maya Erez
From: Dedy Lansky 

New FW supports reporting RSSI signal in dBm.
Report RSSI to kernel in case FW has this capability.

Signed-off-by: Dedy Lansky 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/cfg80211.c | 12 
 drivers/net/wireless/ath/wil6210/debugfs.c  |  2 ++
 drivers/net/wireless/ath/wil6210/pcie_bus.c |  3 +++
 drivers/net/wireless/ath/wil6210/wmi.c  |  9 ++---
 drivers/net/wireless/ath/wil6210/wmi.h  |  6 --
 5 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c 
b/drivers/net/wireless/ath/wil6210/cfg80211.c
index d079533..c860c0c 100644
--- a/drivers/net/wireless/ath/wil6210/cfg80211.c
+++ b/drivers/net/wireless/ath/wil6210/cfg80211.c
@@ -281,12 +281,12 @@ int wil_cid_fill_sinfo(struct wil6210_priv *wil, int cid,
 
wil_dbg_wmi(wil, "Link status for CID %d: {\n"
"  MCS %d TSF 0x%016llx\n"
-   "  BF status 0x%08x SNR 0x%08x SQI %d%%\n"
+   "  BF status 0x%08x RSSI %d SQI %d%%\n"
"  Tx Tpt %d goodput %d Rx goodput %d\n"
"  Sectors(rx:tx) my %d:%d peer %d:%d\n""}\n",
cid, le16_to_cpu(reply.evt.bf_mcs),
le64_to_cpu(reply.evt.tsf), reply.evt.status,
-   le32_to_cpu(reply.evt.snr_val),
+   reply.evt.rssi,
reply.evt.sqi,
le32_to_cpu(reply.evt.tx_tpt),
le32_to_cpu(reply.evt.tx_goodput),
@@ -319,7 +319,11 @@ int wil_cid_fill_sinfo(struct wil6210_priv *wil, int cid,
 
if (test_bit(wil_status_fwconnected, wil->status)) {
sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
-   sinfo->signal = reply.evt.sqi;
+   if (test_bit(WMI_FW_CAPABILITY_RSSI_REPORTING,
+wil->fw_capabilities))
+   sinfo->signal = reply.evt.rssi;
+   else
+   sinfo->signal = reply.evt.sqi;
}
 
return rc;
@@ -1805,7 +1809,7 @@ static void wil_wiphy_init(struct wiphy *wiphy)
 
wiphy->bands[NL80211_BAND_60GHZ] = _band_60ghz;
 
-   /* TODO: figure this out */
+   /* may change after reading FW capabilities */
wiphy->signal_type = CFG80211_SIGNAL_TYPE_UNSPEC;
 
wiphy->cipher_suites = wil_cipher_suites;
diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c 
b/drivers/net/wireless/ath/wil6210/debugfs.c
index a2b5d59..21b6611 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -1016,6 +1016,7 @@ static int wil_bf_debugfs_show(struct seq_file *s, void 
*data)
   "  TSF = 0x%016llx\n"
   "  TxMCS = %2d TxTpt = %4d\n"
   "  SQI = %4d\n"
+  "  RSSI = %4d\n"
   "  Status = 0x%08x %s\n"
   "  Sectors(rx:tx) my %2d:%2d peer %2d:%2d\n"
   "  Goodput(rx:tx) %4d:%4d\n"
@@ -1025,6 +1026,7 @@ static int wil_bf_debugfs_show(struct seq_file *s, void 
*data)
   le16_to_cpu(reply.evt.bf_mcs),
   le32_to_cpu(reply.evt.tx_tpt),
   reply.evt.sqi,
+  reply.evt.rssi,
   status, wil_bfstatus_str(status),
   le16_to_cpu(reply.evt.my_rx_sector),
   le16_to_cpu(reply.evt.my_tx_sector),
diff --git a/drivers/net/wireless/ath/wil6210/pcie_bus.c 
b/drivers/net/wireless/ath/wil6210/pcie_bus.c
index d571feb..6a3ab4b 100644
--- a/drivers/net/wireless/ath/wil6210/pcie_bus.c
+++ b/drivers/net/wireless/ath/wil6210/pcie_bus.c
@@ -84,6 +84,9 @@ void wil_set_capabilities(struct wil6210_priv *wil)
 
/* extract FW capabilities from file without loading the FW */
wil_request_firmware(wil, wil->wil_fw_name, false);
+
+   if (test_bit(WMI_FW_CAPABILITY_RSSI_REPORTING, wil->fw_capabilities))
+   wil_to_wiphy(wil)->signal_type = CFG80211_SIGNAL_TYPE_MBM;
 }
 
 void wil_disable_irq(struct wil6210_priv *wil)
diff --git a/drivers/net/wireless/ath/wil6210/wmi.c 
b/drivers/net/wireless/ath/wil6210/wmi.c
index 65ef673..a9487f2 100644
--- a/drivers/net/wireless/ath/wil6210/wmi.c
+++ b/drivers/net/wireless/ath/wil6210/wmi.c
@@ -381,12 +381,15 @@ static void wmi_evt_rx_mgmt(struct wil6210_priv *wil, int 
id, void *d, int len)
ch_no = data->info.channel + 1;
freq = ieee80211_channel_to_frequency(ch_no, NL80211_BAND_60GHZ);
channel = ieee80211_get_channel(wiphy, freq);
-   signal = data->info.sqi;
+   if (test_bit(WMI_FW_CAPABILITY_RSSI_REPORTING, wil->fw_capabilities))
+   signal = 100 * data->info.rssi;
+   else
+   signal = data->info.sqi;

[PATCH v2] rtlwifi: Fix fallback firmware loading

2017-07-31 Thread Sven Joachim
Commit f70e4df2b384 ("rtlwifi: Add code to read new versions of
firmware") added code to load an old firmware file if the new one is
not available.  Unfortunately that code is never reached because
request_firmware_nowait() does not wait for the firmware to show up
and returns 0 even if the file is not there.

Use the existing fallback mechanism introduced by commit 62009b7f1279
("rtlwifi: rtl8192cu: Add new firmware") instead.

Fixes: f70e4df2b384 ("rtlwifi: Add code to read new versions of firmware")
Cc: sta...@vger.kernel.org
Signed-off-by: Sven Joachim 
---
 drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c | 17 +
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c | 17 +
 2 files changed, 10 insertions(+), 24 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
index 56c05c4e1499..f47d839f388d 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
@@ -187,18 +187,10 @@ int rtl8723be_init_sw_vars(struct ieee80211_hw *hw)
  rtlpriv->io.dev, GFP_KERNEL, hw,
  rtl_fw_cb);
if (err) {
-   /* Failed to get firmware. Check if old version available */
-   fw_name = "rtlwifi/rtl8723befw.bin";
-   pr_info("Using firmware %s\n", fw_name);
-   err = request_firmware_nowait(THIS_MODULE, 1, fw_name,
- rtlpriv->io.dev, GFP_KERNEL, hw,
- rtl_fw_cb);
-   if (err) {
-   pr_err("Failed to request firmware!\n");
-   vfree(rtlpriv->rtlhal.pfirmware);
-   rtlpriv->rtlhal.pfirmware = NULL;
-   return 1;
-   }
+   pr_err("Failed to request firmware!\n");
+   vfree(rtlpriv->rtlhal.pfirmware);
+   rtlpriv->rtlhal.pfirmware = NULL;
+   return 1;
}
return 0;
 }
@@ -289,6 +281,7 @@ static const struct rtl_hal_cfg rtl8723be_hal_cfg = {
.bar_id = 2,
.write_readback = true,
.name = "rtl8723be_pci",
+   .alt_fw_name = "rtlwifi/rtl8723befw.bin",
.ops = _hal_ops,
.mod_params = _mod_params,
.maps[SYS_ISO_CTRL] = REG_SYS_ISO_CTRL,
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c
index ec2d577ba85b..5925edf7877f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c
@@ -216,18 +216,10 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw)
  rtlpriv->io.dev, GFP_KERNEL, hw,
  rtl_fw_cb);
if (err) {
-   /* Failed to get firmware. Check if old version available */
-   fw_name = "rtlwifi/rtl8821aefw.bin";
-   pr_info("Using firmware %s\n", fw_name);
-   err = request_firmware_nowait(THIS_MODULE, 1, fw_name,
- rtlpriv->io.dev, GFP_KERNEL, hw,
- rtl_fw_cb);
-   if (err) {
-   pr_err("Failed to request normal firmware!\n");
-   vfree(rtlpriv->rtlhal.wowlan_firmware);
-   vfree(rtlpriv->rtlhal.pfirmware);
-   return 1;
-   }
+   pr_err("Failed to request normal firmware!\n");
+   vfree(rtlpriv->rtlhal.wowlan_firmware);
+   vfree(rtlpriv->rtlhal.pfirmware);
+   return 1;
}
/*load wowlan firmware*/
pr_info("Using firmware %s\n", wowlan_fw_name);
@@ -331,6 +323,7 @@ static const struct rtl_hal_cfg rtl8821ae_hal_cfg = {
.bar_id = 2,
.write_readback = true,
.name = "rtl8821ae_pci",
+   .alt_fw_name = "rtlwifi/rtl8821aefw.bin",
.ops = _hal_ops,
.mod_params = _mod_params,
.maps[SYS_ISO_CTRL] = REG_SYS_ISO_CTRL,
-- 
2.13.3



[PATCH V5 1/2] firmware: add more flexible request_firmware_async function

2017-07-31 Thread Rafał Miłecki
From: Rafał Miłecki 

So far we got only one function for loading firmware asynchronously:
request_firmware_nowait. It didn't allow much customization of firmware
loading process - there is only one bool uevent argument. Moreover this
bool also controls user helper in an unclear way.

Some drivers need more flexible helper providing more options. This
includes control over uevent or warning for the missing firmware. Of
course this list may grow up in the future.

To handle this easily this patch adds a generic request_firmware_async
function. It takes struct with options as an argument which will allow
extending it in the future without massive changes.

This is a really cheap change (no new independent API) which works
nicely with the existing code. The old request_firmware_nowait is kept
as a simple helper calling new helper.

Signed-off-by: Rafał Miłecki 
---
V3: Don't expose all FW_OPT_* flags.
As Luis noted we want a struct so add struct firmware_opts for real
flexibility.
Thank you Luis for your review!
V5: Rebase, update commit message, resend after drvdata discussion
---
 drivers/base/firmware_class.c | 43 ++-
 include/linux/firmware.h  | 15 ++-
 2 files changed, 48 insertions(+), 10 deletions(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index b9f907eedbf7..cde85b05e4cb 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -1375,7 +1375,7 @@ static void request_firmware_work_func(struct work_struct 
*work)
_request_firmware(, fw_work->name, fw_work->device, NULL, 0,
  fw_work->opt_flags);
fw_work->cont(fw, fw_work->context);
-   put_device(fw_work->device); /* taken in request_firmware_nowait() */
+   put_device(fw_work->device); /* taken in __request_firmware_nowait() */
 
module_put(fw_work->module);
kfree_const(fw_work->name);
@@ -1383,10 +1383,9 @@ static void request_firmware_work_func(struct 
work_struct *work)
 }
 
 /**
- * request_firmware_nowait - asynchronous version of request_firmware
+ * __request_firmware_nowait - asynchronous version of request_firmware
  * @module: module requesting the firmware
- * @uevent: sends uevent to copy the firmware image if this flag
- * is non-zero else the firmware copy must be done manually.
+ * @opt_flags: flags that control firmware loading process, see FW_OPT_*
  * @name: name of firmware file
  * @device: device for which firmware is being loaded
  * @gfp: allocation flags
@@ -1405,9 +1404,9 @@ static void request_firmware_work_func(struct work_struct 
*work)
  *
  * - can't sleep at all if @gfp is GFP_ATOMIC.
  **/
-int
-request_firmware_nowait(
-   struct module *module, bool uevent,
+static int
+__request_firmware_nowait(
+   struct module *module, unsigned int opt_flags,
const char *name, struct device *device, gfp_t gfp, void *context,
void (*cont)(const struct firmware *fw, void *context))
 {
@@ -1426,8 +1425,7 @@ request_firmware_nowait(
fw_work->device = device;
fw_work->context = context;
fw_work->cont = cont;
-   fw_work->opt_flags = FW_OPT_NOWAIT | FW_OPT_FALLBACK |
-   (uevent ? FW_OPT_UEVENT : FW_OPT_USERHELPER);
+   fw_work->opt_flags = FW_OPT_NOWAIT | opt_flags;
 
if (!try_module_get(module)) {
kfree_const(fw_work->name);
@@ -1440,8 +1438,35 @@ request_firmware_nowait(
schedule_work(_work->work);
return 0;
 }
+
+int request_firmware_nowait(struct module *module, bool uevent,
+   const char *name, struct device *device, gfp_t gfp,
+   void *context,
+   void (*cont)(const struct firmware *fw, void 
*context))
+{
+   unsigned int opt_flags = FW_OPT_FALLBACK |
+   (uevent ? FW_OPT_UEVENT : FW_OPT_USERHELPER);
+
+   return __request_firmware_nowait(module, opt_flags, name, device, gfp,
+context, cont);
+}
 EXPORT_SYMBOL(request_firmware_nowait);
 
+int __request_firmware_async(struct module *module, const char *name,
+struct firmware_opts *fw_opts, struct device *dev,
+void *context,
+void (*cont)(const struct firmware *fw, void 
*context))
+{
+   unsigned int opt_flags = FW_OPT_UEVENT;
+
+   if (fw_opts->optional)
+   opt_flags |= FW_OPT_NO_WARN;
+
+   return __request_firmware_nowait(module, opt_flags, name, dev,
+GFP_KERNEL, context, cont);
+}
+EXPORT_SYMBOL(__request_firmware_async);
+
 #ifdef CONFIG_PM_SLEEP
 static ASYNC_DOMAIN_EXCLUSIVE(fw_cache_domain);
 
diff --git a/include/linux/firmware.h b/include/linux/firmware.h
index b1f9f0ccb8ac..a32b6e67462d 100644
--- a/include/linux/firmware.h
+++ 

[PATCH V5 2/2] brcmfmac: don't warn user about NVRAM if fallback to the platform one succeeds

2017-07-31 Thread Rafał Miłecki
From: Rafał Miłecki 

Failing to load NVRAM *file* isn't critical if we manage to get platform
NVRAM in the fallback path. It means warnings like:
[   10.801506] brcmfmac :01:00.0: Direct firmware load for 
brcm/brcmfmac43602-pcie.txt failed with error -2
are unnecessary & disturbing for people with *platform* NVRAM as they
are not expected to have NVRAM file. This is a very common case for
Broadcom home routers.

Instead of printing warning immediately within the firmware subsystem
let's try our fallback code first. If that fails as well, then it's a
right moment to print an error.

This should reduce amount of false reports from users seeing this
warning while having wireless working perfectly fine with the platform
NVRAM.

Signed-off-by: Rafał Miłecki 
---
V2: Update commit message as it wasn't clear enough (thanks Andy) & add extra
messages to the firmware.c.
V3: Set FW_OPT_UEVENT to don't change behavior
V4: Switch to the new request_firmware_async syntax
V5: Rebase, update commit message, resend after drvdata discussion
---
 .../wireless/broadcom/brcm80211/brcmfmac/firmware.c| 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
index d231042f19d6..524442b3870f 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
@@ -462,8 +462,14 @@ static void brcmf_fw_request_nvram_done(const struct 
firmware *fw, void *ctx)
raw_nvram = false;
} else {
data = bcm47xx_nvram_get_contents(_len);
-   if (!data && !(fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL))
-   goto fail;
+   if (!data) {
+   brcmf_dbg(TRACE, "Failed to get platform NVRAM\n");
+   if (!(fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL)) {
+   brcmf_err("Loading NVRAM from %s and using 
platform one both failed\n",
+ fwctx->nvram_name);
+   goto fail;
+   }
+   }
raw_nvram = true;
}
 
@@ -491,6 +497,9 @@ static void brcmf_fw_request_nvram_done(const struct 
firmware *fw, void *ctx)
 static void brcmf_fw_request_code_done(const struct firmware *fw, void *ctx)
 {
struct brcmf_fw *fwctx = ctx;
+   struct firmware_opts fw_opts = {
+   .optional = true,
+   };
int ret = 0;
 
brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(fwctx->dev));
@@ -503,9 +512,8 @@ static void brcmf_fw_request_code_done(const struct 
firmware *fw, void *ctx)
goto done;
 
fwctx->code = fw;
-   ret = request_firmware_nowait(THIS_MODULE, true, fwctx->nvram_name,
- fwctx->dev, GFP_KERNEL, fwctx,
- brcmf_fw_request_nvram_done);
+   ret = request_firmware_async(fwctx->nvram_name, _opts, fwctx->dev,
+fwctx, brcmf_fw_request_nvram_done);
 
/* pass NULL to nvram callback for bcm47xx fallback */
if (ret)
-- 
2.11.0



Re: [PATCH v4] rtlwifi: Replace hardcode value with macro

2017-07-31 Thread Larry Finger

On 07/31/2017 06:14 AM, Souptick Joarder wrote:

In _rtl_init_mac80211(), hardcoded value for hw->max_listen_interval
and hw->max_rate_tries are replaced by macro.


That is NOT what your patch does. It only removes a comment! Granted, that 
comment is useless and should come out, but your commit message must be a little 
more accurate.


NACK.

Larry



Signed-off-by: Souptick Joarder 
---
  drivers/net/wireless/realtek/rtlwifi/base.c | 1 -
  1 file changed, 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index f45d093..52f2d0b 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -422,7 +422,6 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
hw->extra_tx_headroom = RTL_TX_HEADER_SIZE;

/* TODO: Correct this value for our hw */
-   /* defined these hard code values */
hw->max_listen_interval = MAX_LISTEN_INTERVAL;
hw->max_rate_tries = MAX_RATE_TRIES;
/* hw->max_rates = 1; */
--
1.9.1






[PATCH 2/2] mwifiex: pcie: compatible with wifi-only image while extract wifi-part fw

2017-07-31 Thread Xinming Hu
From: Xinming Hu 

Sometimes, we might using wifi-only firmware with a combo firmware name,
in this case, do not need to filter bluetooth part from header.

Signed-off-by: Xinming Hu 
Signed-off-by: Cathy Luo 
---
 drivers/net/wireless/marvell/mwifiex/pcie.c | 26 +++---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c 
b/drivers/net/wireless/marvell/mwifiex/pcie.c
index 3da1eeb..dc4e054 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -1985,7 +1985,8 @@ static int mwifiex_pcie_event_complete(struct 
mwifiex_adapter *adapter,
  * (3) wifi image.
  *
  * This function bypass the header and bluetooth part, return
- * the offset of tail wifi-only part.
+ * the offset of tail wifi-only part. if the image is already wifi-only,
+ * that is start with CMD1, return 0.
  */
 
 static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter,
@@ -1993,7 +1994,7 @@ static int mwifiex_extract_wifi_fw(struct mwifiex_adapter 
*adapter,
const struct mwifiex_fw_data *fwdata;
u32 offset = 0, data_len, dnld_cmd;
int ret = 0;
-   bool cmd7_before = false;
+   bool cmd7_before = false, first_cmd = false;
 
while (1) {
/* Check for integer and buffer overflow */
@@ -2014,20 +2015,29 @@ static int mwifiex_extract_wifi_fw(struct 
mwifiex_adapter *adapter,
 
switch (dnld_cmd) {
case MWIFIEX_FW_DNLD_CMD_1:
-   if (!cmd7_before) {
-   mwifiex_dbg(adapter, ERROR,
-   "no cmd7 before cmd1!\n");
+   if (offset + data_len < data_len) {
+   mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
ret = -1;
goto done;
}
-   if (offset + data_len < data_len) {
-   mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
+
+   /* Image start with cmd1, already wifi-only firmware*/
+   if (!first_cmd) {
+   mwifiex_dbg(adapter, MSG,
+   "input wifi-only firmware\n");
+   return 0;
+   }
+
+   if (!cmd7_before) {
+   mwifiex_dbg(adapter, ERROR,
+   "no cmd7 before cmd1!\n");
ret = -1;
goto done;
}
offset += data_len;
break;
case MWIFIEX_FW_DNLD_CMD_5:
+   first_cmd = true;
/* Check for integer overflow */
if (offset + data_len < data_len) {
mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
@@ -2037,6 +2047,7 @@ static int mwifiex_extract_wifi_fw(struct mwifiex_adapter 
*adapter,
offset += data_len;
break;
case MWIFIEX_FW_DNLD_CMD_6:
+   first_cmd = true;
/* Check for integer overflow */
if (offset + data_len < data_len) {
mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
@@ -2053,6 +2064,7 @@ static int mwifiex_extract_wifi_fw(struct mwifiex_adapter 
*adapter,
}
goto done;
case MWIFIEX_FW_DNLD_CMD_7:
+   first_cmd = true;
cmd7_before = true;
break;
default:
-- 
1.9.1



[PATCH 1/2] mwifiex: make addba request command clean

2017-07-31 Thread Xinming Hu
From: Xinming Hu 

uninitilized variable, such as .add_req_result might be magic stack
value. Initialize the structure to make it clean.

Signed-off-by: Xinming Hu 
Signed-off-by: Cathy Luo 
---
 drivers/net/wireless/marvell/mwifiex/11n.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/11n.c 
b/drivers/net/wireless/marvell/mwifiex/11n.c
index 16c77c2..7252069 100644
--- a/drivers/net/wireless/marvell/mwifiex/11n.c
+++ b/drivers/net/wireless/marvell/mwifiex/11n.c
@@ -572,6 +572,8 @@ int mwifiex_send_addba(struct mwifiex_private *priv, int 
tid, u8 *peer_mac)
 
mwifiex_dbg(priv->adapter, CMD, "cmd: %s: tid %d\n", __func__, tid);
 
+   memset(_ba_req, 0, sizeof(add_ba_req));
+
if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) &&
ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) &&
priv->adapter->is_hw_11ac_capable &&
-- 
1.9.1



Re: AP mode with Broadcom 4330

2017-07-31 Thread Russell King - ARM Linux
On Fri, Jul 28, 2017 at 09:50:21PM +0200, Arend van Spriel wrote:
> I was going to agree with you, but having second thoughts. There are
> actually two use-cases that need to be handled properly. The regular AP
> case and the MBSS case. In case of MBSS the initial AP interface will
> have mbss set to false and subsequent AP interfaces will have mbss set
> to true, but in firmware this has to be configured inverted. That is
> what the code above is doing. However, this indeed breaks the regular AP
> case for firmwares that abuse that setting for testing purposes (no idea
> why that is in a released firmware).

Maybe detect the BCRM_TEST_SSID string in the firmware file (as it's
broken up amongst other data, it's not trivial) and disable mbss for
such firmware?  Alternatively, maybe blacklist mbss for some firmware
versions?

Do the firmware versions that include this "abuse" actually have
functional mbss?

There's also the obvious question: which firmware is recommended for
the 4330?

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.


QCA9994 ath10k chipset

2017-07-31 Thread Matteo Grandi
Dear all,

I have to find a miniPCIe Wi-Fi adapters that uses the QCA9994 chipset.
As far as I discovered looking to the Internet, seems that only the
Acelink EW-7956MAC uses the QCA9994 chipset, but I didn't find a
dealer where to purchase it. Contacting Acelink is useless because
their email " cont...@acelink.com.tw" seems to be inexistent: I
receive a mail delivery status notification.


Moreover, having a look on Kalle Valo git repo, I didn't find any
QCA9994 but only QCA9984 firmwares. And it's quite easier to find
devices that use the QCA9984 chipset.


Does anyone use/have used such QCA9994 chipset?
Any hint to find a QCA9994 device and its related ath10k firmware will
be really appreciated.

Thank you in advance

Matteo


[PATCH v4] rtlwifi: Replace hardcode value with macro

2017-07-31 Thread Souptick Joarder
In _rtl_init_mac80211(), hardcoded value for hw->max_listen_interval
and hw->max_rate_tries are replaced by macro.

Signed-off-by: Souptick Joarder 
---
 drivers/net/wireless/realtek/rtlwifi/base.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index f45d093..52f2d0b 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -422,7 +422,6 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
hw->extra_tx_headroom = RTL_TX_HEADER_SIZE;

/* TODO: Correct this value for our hw */
-   /* defined these hard code values */
hw->max_listen_interval = MAX_LISTEN_INTERVAL;
hw->max_rate_tries = MAX_RATE_TRIES;
/* hw->max_rates = 1; */
--
1.9.1



Re: [PATCH] mwifiex: correct IE parse during association

2017-07-31 Thread Xinming Hu
Hi Kalle,

Thanks for the review, I have refactor code to avoid ugly indent in v2.

Regards,
Simon

From: Kalle Valo 
Sent: Friday, July 28, 2017 22:39
To: Xinming Hu
Cc: Linux Wireless; Brian Norris; Dmitry Torokhov; raja...@google.com; Zhiyuan 
Yang; Tim Song; Cathy Luo; Xinming Hu
Subject: Re: [PATCH] mwifiex: correct IE parse during association

Xinming Hu  writes:

> From: Xinming Hu 
>
> It is observed that some IEs get missed during association.
> This patch correct the old IE parse code. sme->ie will be
> store as wpa ie, wps ie, wapi ie and gen ie accordingly.
>
> Signed-off-by: Xinming Hu 
> Signed-off-by: Cathy Luo 

[...]

> + } else {
> + if (pvendor_ie->element_id ==
> + WLAN_EID_VENDOR_SPECIFIC) {
> + /* Test to see if it is a WPA IE,
> +  * if not, then it is a gen IE
> +  */
> + if (!memcmp(pvendor_ie->oui, wpa_oui,
> + sizeof(wpa_oui))) {
> + /* IE is a WPA/WPA2 IE so call
> +  * set_wpa function
> +  */
> + mwifiex_set_wpa_ie(priv,
> +(u8 *)pvendor_ie,
> +cur_ie_len);

The indentation is getting ugly here. A helper function or similar would
really make this more readable.


[...]

> +NEXT_IE:

Goto labels in lower case, please.

--
Kalle Valo


[v2 PATCH] mwifiex: correct IE parse during association

2017-07-31 Thread Xinming Hu
From: Xinming Hu 

It is observed that some IEs get missed during association.
This patch correct the old IE parse code. sme->ie will be
store as wpa ie, wps ie, wapi ie and gen ie accordingly.

Signed-off-by: Xinming Hu 
Signed-off-by: Cathy Luo 
---
v2: refactor code to avoid ugly intent (Kalle)
---
 drivers/net/wireless/marvell/mwifiex/sta_ioctl.c | 115 +++
 1 file changed, 55 insertions(+), 60 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/sta_ioctl.c 
b/drivers/net/wireless/marvell/mwifiex/sta_ioctl.c
index 43ecd62..a6077ab 100644
--- a/drivers/net/wireless/marvell/mwifiex/sta_ioctl.c
+++ b/drivers/net/wireless/marvell/mwifiex/sta_ioctl.c
@@ -811,8 +811,8 @@ int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 
*ps_mode)
  * is checked to determine WPA version. If buffer length is zero, the existing
  * WPA IE is reset.
  */
-static int mwifiex_set_wpa_ie_helper(struct mwifiex_private *priv,
-u8 *ie_data_ptr, u16 ie_len)
+static int mwifiex_set_wpa_ie(struct mwifiex_private *priv,
+ u8 *ie_data_ptr, u16 ie_len)
 {
if (ie_len) {
if (ie_len > sizeof(priv->wpa_ie)) {
@@ -1351,101 +1351,96 @@ static int mwifiex_reg_mem_ioctl_reg_rw(struct 
mwifiex_private *priv,
 mwifiex_set_gen_ie_helper(struct mwifiex_private *priv, u8 *ie_data_ptr,
  u16 ie_len)
 {
-   int ret = 0;
struct ieee_types_vendor_header *pvendor_ie;
const u8 wpa_oui[] = { 0x00, 0x50, 0xf2, 0x01 };
const u8 wps_oui[] = { 0x00, 0x50, 0xf2, 0x04 };
-   u16 unparsed_len = ie_len;
-   int find_wpa_ie = 0;
+   u16 unparsed_len = ie_len, cur_ie_len;
 
/* If the passed length is zero, reset the buffer */
if (!ie_len) {
priv->gen_ie_buf_len = 0;
priv->wps.session_enable = false;
-
return 0;
-   } else if (!ie_data_ptr) {
+   } else if (!ie_data_ptr ||
+  ie_len <= sizeof(struct ieee_types_header)) {
return -1;
}
pvendor_ie = (struct ieee_types_vendor_header *) ie_data_ptr;
 
while (pvendor_ie) {
+   cur_ie_len = pvendor_ie->len + sizeof(struct ieee_types_header);
+
+   if (pvendor_ie->element_id == WLAN_EID_RSN) {
+   /* IE is a WPA/WPA2 IE so call set_wpa function */
+   mwifiex_set_wpa_ie(priv, (u8 *)pvendor_ie, cur_ie_len);
+   priv->wps.session_enable = false;
+   goto next_ie;
+   }
+
+   if (pvendor_ie->element_id == WLAN_EID_BSS_AC_ACCESS_DELAY) {
+   /* IE is a WAPI IE so call set_wapi function */
+   mwifiex_set_wapi_ie(priv, (u8 *)pvendor_ie,
+   cur_ie_len);
+   goto next_ie;
+   }
+
if (pvendor_ie->element_id == WLAN_EID_VENDOR_SPECIFIC) {
-   /* Test to see if it is a WPA IE, if not, then it is a
-* gen IE
+   /* Test to see if it is a WPA IE, if not, then
+* it is a gen IE
 */
if (!memcmp(pvendor_ie->oui, wpa_oui,
sizeof(wpa_oui))) {
-   find_wpa_ie = 1;
-   break;
+   /* IE is a WPA/WPA2 IE so call set_wpa function
+*/
+   mwifiex_set_wpa_ie(priv, (u8 *)pvendor_ie,
+  cur_ie_len);
+   priv->wps.session_enable = false;
+   goto next_ie;
}
 
-   /* Test to see if it is a WPS IE, if so, enable
-* wps session flag
-*/
if (!memcmp(pvendor_ie->oui, wps_oui,
sizeof(wps_oui))) {
+   /* Test to see if it is a WPS IE,
+* if so, enable wps session flag
+*/
priv->wps.session_enable = true;
mwifiex_dbg(priv->adapter, MSG,
-   "info: WPS Session Enabled.\n");
-   ret = mwifiex_set_wps_ie(priv,
-(u8 *)pvendor_ie,
-unparsed_len);
+   "WPS Session Enabled.\n");
+   mwifiex_set_wps_ie(priv, (u8 *)pvendor_ie,
+  cur_ie_len);
+   

[v4] wlcore: add missing nvs file name info for wilink8

2017-07-31 Thread Reizer, Eyal
The following commits:
c815fde wlcore: spi: Populate config firmware data
d776fc8 wlcore: sdio: Populate config firmware data

Populated the nvs entry for wilink6 and wilink7 only while it is
still needed for wilink8 as well.
This broke user space backward compatibility when upgrading from older
kernels, as the alternate mac address would not be read from the nvs that
is present in the file system (lib/firmware/ti-connectivity/wl1271-nvs.bin)
causing mac address change of the wlan interface.

This patch fix this and update the structure field with the same default
nvs file name that has been used before.

In addition, some distros hold a default wl1271-nvs.bin in the file
system with a bogus mac address (deadbeef...) that for a wl18xx device
also overrides the mac address that is stored inside the device.
Warn users about this bogus mac address and use a random mac instead

Cc: stable 
Signed-off-by: Eyal Reizer 
---
v2->v3: add a check for default deadbeef... mac address and warn about it
v3->v4: use a random TI mac address instead of the bogus one

---
 drivers/net/wireless/ti/wlcore/main.c | 16 
 drivers/net/wireless/ti/wlcore/sdio.c |  1 +
 drivers/net/wireless/ti/wlcore/spi.c  |  1 +
 3 files changed, 18 insertions(+)

diff --git a/drivers/net/wireless/ti/wlcore/main.c 
b/drivers/net/wireless/ti/wlcore/main.c
index 60aaa85..7ce4221 100644
--- a/drivers/net/wireless/ti/wlcore/main.c
+++ b/drivers/net/wireless/ti/wlcore/main.c
@@ -5961,6 +5961,22 @@ static void wl12xx_derive_mac_addresses(struct wl1271 
*wl, u32 oui, u32 nic)
if (nic + WLCORE_NUM_MAC_ADDRESSES - wl->num_mac_addr > 0xff)
wl1271_warning("NIC part of the MAC address wraps around!");
 
+   if (oui == 0xdeadbe && nic == 0xef) {
+   wl1271_warning("Detected unconfigured mac address in nvs.\n"
+   "Using a random TI mac address instead.\n"
+   "in case of using a wl12xx device, your "
+   "device performance may not be optimized.\n"
+   "Please use the calibrator tool to configure "
+   "your device.\n"
+   "When using a wl18xx device the nvs file can "
+   "be removed as a default mac address is "
+   "stored internally.\n");
+
+   /* Use TI oui and a random nic */
+   oui = 0x080028;
+   nic = get_random_int();
+   }
+
for (i = 0; i < wl->num_mac_addr; i++) {
wl->addresses[i].addr[0] = (u8)(oui >> 16);
wl->addresses[i].addr[1] = (u8)(oui >> 8);
diff --git a/drivers/net/wireless/ti/wlcore/sdio.c 
b/drivers/net/wireless/ti/wlcore/sdio.c
index 2fb3871..f8a1fea 100644
--- a/drivers/net/wireless/ti/wlcore/sdio.c
+++ b/drivers/net/wireless/ti/wlcore/sdio.c
@@ -230,6 +230,7 @@ static const struct wilink_family_data wl128x_data = {
 static const struct wilink_family_data wl18xx_data = {
.name = "wl18xx",
.cfg_name = "ti-connectivity/wl18xx-conf.bin",
+   .nvs_name = "ti-connectivity/wl1271-nvs.bin",
 };
 
 static const struct of_device_id wlcore_sdio_of_match_table[] = {
diff --git a/drivers/net/wireless/ti/wlcore/spi.c 
b/drivers/net/wireless/ti/wlcore/spi.c
index fdabb92..62ce54a 100644
--- a/drivers/net/wireless/ti/wlcore/spi.c
+++ b/drivers/net/wireless/ti/wlcore/spi.c
@@ -92,6 +92,7 @@ static const struct wilink_family_data wl128x_data = {
 static const struct wilink_family_data wl18xx_data = {
.name = "wl18xx",
.cfg_name = "ti-connectivity/wl18xx-conf.bin",
+   .nvs_name = "ti-connectivity/wl1271-nvs.bin",
 };
 
 struct wl12xx_spi_glue {
-- 
2.7.4