Re: [Outreachy kernel] [PATCH] staging: wilc1000: renames struct tstrRSSI and its members u8Index, u8Full

2017-02-21 Thread Julia Lawall


On Tue, 21 Feb 2017, Tahia Khan wrote:

> Fixes multiple camel case checks on struct tstrRSSI from checkpatch.pl:
>
> Avoid CamelCase: 
> Avoid CamelCase: 
> Avoid CamelCase: 
>
> Signed-off-by: Tahia Khan 
> ---
>  drivers/staging/wilc1000/coreconfigurator.h   |  8 
>  drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 10 +-
>  2 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/staging/wilc1000/coreconfigurator.h 
> b/drivers/staging/wilc1000/coreconfigurator.h
> index cff1698..c9cf23b 100644
> --- a/drivers/staging/wilc1000/coreconfigurator.h
> +++ b/drivers/staging/wilc1000/coreconfigurator.h
> @@ -70,9 +70,9 @@ enum connect_status {
>   CONNECT_STS_FORCE_16_BIT = 0x
>  };
>
> -struct tstrRSSI {
> - u8 u8Full;
> - u8 u8Index;
> +struct tstr_RSSI {
> + u8 u8_full;
> + u8 u8_index;

The kernel doesn't use variable names that incorporate types.  These could
just be full and index.

julia

>   s8 as8RSSI[NUM_RSSI];
>  };
>
> @@ -93,7 +93,7 @@ struct network_info {
>   u8 *ies;
>   u16 ies_len;
>   void *join_params;
> - struct tstrRSSI str_rssi;
> + struct tstr_RSSI str_rssi;
>   u64 tsf_hi;
>  };
>
> diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
> b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
> index f7ce47c..30285b9 100644
> --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
> +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
> @@ -205,8 +205,8 @@ static u32 get_rssi_avg(struct network_info *network_info)
>  {
>   u8 i;
>   int rssi_v = 0;
> - u8 num_rssi = (network_info->str_rssi.u8Full) ?
> -NUM_RSSI : (network_info->str_rssi.u8Index);
> + u8 num_rssi = (network_info->str_rssi.u8_full) ?
> +NUM_RSSI : (network_info->str_rssi.u8_index);
>
>   for (i = 0; i < num_rssi; i++)
>   rssi_v += network_info->str_rssi.as8RSSI[i];
> @@ -346,13 +346,13 @@ static void add_network_to_shadow(struct network_info 
> *pstrNetworkInfo,
>   } else {
>   ap_index = ap_found;
>   }
> - rssi_index = last_scanned_shadow[ap_index].str_rssi.u8Index;
> + rssi_index = last_scanned_shadow[ap_index].str_rssi.u8_index;
>   last_scanned_shadow[ap_index].str_rssi.as8RSSI[rssi_index++] = 
> pstrNetworkInfo->rssi;
>   if (rssi_index == NUM_RSSI) {
>   rssi_index = 0;
> - last_scanned_shadow[ap_index].str_rssi.u8Full = 1;
> + last_scanned_shadow[ap_index].str_rssi.u8_full = 1;
>   }
> - last_scanned_shadow[ap_index].str_rssi.u8Index = rssi_index;
> + last_scanned_shadow[ap_index].str_rssi.u8_index = rssi_index;
>   last_scanned_shadow[ap_index].rssi = pstrNetworkInfo->rssi;
>   last_scanned_shadow[ap_index].cap_info = pstrNetworkInfo->cap_info;
>   last_scanned_shadow[ap_index].ssid_len = pstrNetworkInfo->ssid_len;
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/20170222045543.GA27847%40coolbox.
> For more options, visit https://groups.google.com/d/optout.
>


[PATCH] staging: wilc1000: renames struct tstrRSSI and its members u8Index, u8Full

2017-02-21 Thread Tahia Khan
Fixes multiple camel case checks on struct tstrRSSI from checkpatch.pl:

Avoid CamelCase: 
Avoid CamelCase: 
Avoid CamelCase: 

Signed-off-by: Tahia Khan 
---
 drivers/staging/wilc1000/coreconfigurator.h   |  8 
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 10 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/wilc1000/coreconfigurator.h 
b/drivers/staging/wilc1000/coreconfigurator.h
index cff1698..c9cf23b 100644
--- a/drivers/staging/wilc1000/coreconfigurator.h
+++ b/drivers/staging/wilc1000/coreconfigurator.h
@@ -70,9 +70,9 @@ enum connect_status {
CONNECT_STS_FORCE_16_BIT = 0x
 };
 
-struct tstrRSSI {
-   u8 u8Full;
-   u8 u8Index;
+struct tstr_RSSI {
+   u8 u8_full;
+   u8 u8_index;
s8 as8RSSI[NUM_RSSI];
 };
 
@@ -93,7 +93,7 @@ struct network_info {
u8 *ies;
u16 ies_len;
void *join_params;
-   struct tstrRSSI str_rssi;
+   struct tstr_RSSI str_rssi;
u64 tsf_hi;
 };
 
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index f7ce47c..30285b9 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -205,8 +205,8 @@ static u32 get_rssi_avg(struct network_info *network_info)
 {
u8 i;
int rssi_v = 0;
-   u8 num_rssi = (network_info->str_rssi.u8Full) ?
-  NUM_RSSI : (network_info->str_rssi.u8Index);
+   u8 num_rssi = (network_info->str_rssi.u8_full) ?
+  NUM_RSSI : (network_info->str_rssi.u8_index);
 
for (i = 0; i < num_rssi; i++)
rssi_v += network_info->str_rssi.as8RSSI[i];
@@ -346,13 +346,13 @@ static void add_network_to_shadow(struct network_info 
*pstrNetworkInfo,
} else {
ap_index = ap_found;
}
-   rssi_index = last_scanned_shadow[ap_index].str_rssi.u8Index;
+   rssi_index = last_scanned_shadow[ap_index].str_rssi.u8_index;
last_scanned_shadow[ap_index].str_rssi.as8RSSI[rssi_index++] = 
pstrNetworkInfo->rssi;
if (rssi_index == NUM_RSSI) {
rssi_index = 0;
-   last_scanned_shadow[ap_index].str_rssi.u8Full = 1;
+   last_scanned_shadow[ap_index].str_rssi.u8_full = 1;
}
-   last_scanned_shadow[ap_index].str_rssi.u8Index = rssi_index;
+   last_scanned_shadow[ap_index].str_rssi.u8_index = rssi_index;
last_scanned_shadow[ap_index].rssi = pstrNetworkInfo->rssi;
last_scanned_shadow[ap_index].cap_info = pstrNetworkInfo->cap_info;
last_scanned_shadow[ap_index].ssid_len = pstrNetworkInfo->ssid_len;
-- 
2.7.4



[PATCH v2 0/2] iwlwifi: corner case fix and request module changes

2017-02-21 Thread Luis R. Rodriguez
This v2 addresses the preference to keep things simple on iwlwifi when
requesting modules and not implementing a verifier for loaing the opmode
module. We now know what a verifier looks like for both sync and async
approaches. The already established long standing practice of just doing
best effort to load suffices and keeps the driver cleaner.

There no change to the first patch. The second patch just embraces
request_module_nowait() instead of implementing a verifier for a sync
call. The remaining patches from the last series will be sent separately.

Luis R. Rodriguez (2):
  iwlwifi: fix drv cleanup on opmode registration failure
  iwlwifi: simplify requesting ops module

 drivers/net/wireless/intel/iwlwifi/iwl-drv.c | 28 ++--
 1 file changed, 10 insertions(+), 18 deletions(-)

-- 
2.11.0



[PATCH v2 0/2] iwlwifi: share opmode start code

2017-02-21 Thread Luis R. Rodriguez
This v2 split off the opmode handling sharing code into its
own series, it however depends on the request_module_nowait()
change.

The sharing of the opmode handling makes it easier to share fixes
when dealing with opmode handling on devices. It should also hopefully
make the code easier to grok. Lastly, since we are moving things to
a workqueue naturally the module_init() for iwlmvm is not offloaded,
and so this should reduce the boot time by a bit.

As per the average of systemd-analyze on 5 boots using next-20170221
as base:

next-20170221:
Startup finished in   2.6142s (kernel) +   5.1916s (initrd) +  10.8968s 
(userspace) =  18.7036s

After these patches:
Startup finished in   2.5468s (kernel) +   4.9536s (initrd) +   10.798s 
(userspace) =  18.2994s

Luis R. Rodriguez (2):
  iwlwifi: share opmode start work code
  iwlwifi: convert final opmode work into a workqueue

 drivers/net/wireless/intel/iwlwifi/iwl-drv.c | 93 +++-
 1 file changed, 64 insertions(+), 29 deletions(-)

-- 
2.11.0



[PATCH v2 1/2] iwlwifi: share opmode start work code

2017-02-21 Thread Luis R. Rodriguez
The firmware async callback and the opmode registration share
some functionality -- to start the drv's opmode. Move this work
into a helper which is shared. This should help us share fixes
should these diverging code paths change.

Signed-off-by: Luis R. Rodriguez 
---
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c | 90 +++-
 1 file changed, 61 insertions(+), 29 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
index e96095c1824a..ea88b5cec869 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
@@ -102,6 +102,7 @@ static struct dentry *iwl_dbgfs_root;
  * @op_mode: the running op_mode
  * @trans: transport layer
  * @dev: for debug prints only
+ * @start_requested: start op has been requested and is pending on this device
  * @fw_index: firmware revision to try loading
  * @firmware_name: composite filename of ucode file to load
  * @request_firmware_complete: the firmware has been obtained from user space
@@ -113,6 +114,7 @@ struct iwl_drv {
struct iwl_op_mode *op_mode;
struct iwl_trans *trans;
struct device *dev;
+   bool start_requested;
 
int fw_index;   /* firmware we're trying to load */
char firmware_name[64]; /* name of firmware file to load */
@@ -1231,6 +1233,48 @@ static void _iwl_op_mode_stop(struct iwl_drv *drv)
}
 }
 
+static void iwlwifi_opmode_start_drv(struct iwlwifi_opmode_table *op,
+struct iwl_drv *drv)
+{
+   if (!drv->start_requested)
+   return;
+
+   drv->op_mode = _iwl_op_mode_start(drv, op);
+   drv->start_requested = false;
+
+   /*
+* Complete the firmware request last so that
+* a driver unbind (stop) doesn't run while we
+* are doing the start() above.
+*/
+   complete(&drv->request_firmware_complete);
+
+   if (!drv->op_mode)
+   device_release_driver(drv->trans->dev);
+}
+
+static void iwlwifi_opmode_start(struct iwlwifi_opmode_table *op)
+{
+   struct iwl_drv *drv;
+
+   list_for_each_entry(drv, &op->drv, list)
+   iwlwifi_opmode_start_drv(op, drv);
+}
+
+static void iwlwifi_opmode_dowork(void)
+{
+   unsigned int i;
+   struct iwlwifi_opmode_table *op;
+
+   mutex_lock(&iwlwifi_opmode_table_mtx);
+   for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) {
+   op = &iwlwifi_opmode_table[i];
+   if (op->ops)
+   iwlwifi_opmode_start(op);
+   }
+   mutex_unlock(&iwlwifi_opmode_table_mtx);
+}
+
 /**
  * iwl_req_fw_callback - callback when firmware was loaded
  *
@@ -1443,30 +1487,17 @@ static void iwl_req_fw_callback(const struct firmware 
*ucode_raw, void *context)
IWL_INFO(drv, "loaded firmware version %s op_mode %s\n",
 drv->fw.fw_version, op->name);
 
+   drv->start_requested = true;
/* add this device to the list of devices using this op_mode */
list_add_tail(&drv->list, &op->drv);
 
-   if (op->ops) {
-   drv->op_mode = _iwl_op_mode_start(drv, op);
-
-   if (!drv->op_mode) {
-   mutex_unlock(&iwlwifi_opmode_table_mtx);
-   goto out_unbind;
-   }
-   }
mutex_unlock(&iwlwifi_opmode_table_mtx);
 
-   /*
-* Complete the firmware request last so that
-* a driver unbind (stop) doesn't run while we
-* are doing the start() above.
-*/
-   complete(&drv->request_firmware_complete);
-
err = request_module_nowait("%s", op->name);
if (err)
goto out_unbind;
 
+   iwlwifi_opmode_dowork();
goto free;
 
  try_again:
@@ -1588,8 +1619,8 @@ IWL_EXPORT_SYMBOL(iwlwifi_mod_params);
 int iwl_opmode_register(const char *name, const struct iwl_op_mode_ops *ops)
 {
int i;
-   struct iwl_drv *drv;
struct iwlwifi_opmode_table *op;
+   int ret = -EIO;
 
mutex_lock(&iwlwifi_opmode_table_mtx);
for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) {
@@ -1597,20 +1628,15 @@ int iwl_opmode_register(const char *name, const struct 
iwl_op_mode_ops *ops)
if (strcmp(op->name, name))
continue;
op->ops = ops;
-   /* TODO: need to handle exceptional case */
-   list_for_each_entry(drv, &op->drv, list) {
-   drv->op_mode = _iwl_op_mode_start(drv, op);
-   if (!drv->op_mode) {
-   complete(&drv->request_firmware_complete);
-   device_release_driver(drv->trans->dev);
-   }
-   }
-
-   mutex_unlock(&iwlwifi_opmode_table_mtx);
-   return 0;
+   ret = 0;
+   break;
}
mute

[PATCH v2 2/2] iwlwifi: convert final opmode work into a workqueue

2017-02-21 Thread Luis R. Rodriguez
This lets us offload and share all the final opmode related work
necessary for either an opmode driver or new device. This has the most
impact for opmode drivers as this now offloads opmode start for each
device onto the workqueue.

Signed-off-by: Luis R. Rodriguez 
---
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
index ea88b5cec869..1db372e9c039 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
@@ -143,6 +143,8 @@ static struct iwlwifi_opmode_table {
[DVM_OP_MODE] = { .name = "iwldvm", .ops = NULL },
[MVM_OP_MODE] = { .name = "iwlmvm", .ops = NULL },
 };
+static void iwlwifi_opmode_dowork(struct work_struct *work);
+static DECLARE_WORK(iwlwifi_opmode_work, iwlwifi_opmode_dowork);
 
 #define IWL_DEFAULT_SCAN_CHANNELS 40
 
@@ -1261,7 +1263,7 @@ static void iwlwifi_opmode_start(struct 
iwlwifi_opmode_table *op)
iwlwifi_opmode_start_drv(op, drv);
 }
 
-static void iwlwifi_opmode_dowork(void)
+static void iwlwifi_opmode_dowork(struct work_struct *unused_work)
 {
unsigned int i;
struct iwlwifi_opmode_table *op;
@@ -1497,7 +1499,7 @@ static void iwl_req_fw_callback(const struct firmware 
*ucode_raw, void *context)
if (err)
goto out_unbind;
 
-   iwlwifi_opmode_dowork();
+   schedule_work(&iwlwifi_opmode_work);
goto free;
 
  try_again:
@@ -1581,6 +1583,7 @@ struct iwl_drv *iwl_drv_start(struct iwl_trans *trans)
 void iwl_drv_stop(struct iwl_drv *drv)
 {
wait_for_completion(&drv->request_firmware_complete);
+   cancel_work_sync(&iwlwifi_opmode_work);
 
_iwl_op_mode_stop(drv);
 
@@ -1634,7 +1637,7 @@ int iwl_opmode_register(const char *name, const struct 
iwl_op_mode_ops *ops)
mutex_unlock(&iwlwifi_opmode_table_mtx);
 
if (!ret)
-   iwlwifi_opmode_dowork();
+   schedule_work(&iwlwifi_opmode_work);
 
return ret;
 }
-- 
2.11.0



[PATCH v2 2/2] iwlwifi: simplify requesting ops module

2017-02-21 Thread Luis R. Rodriguez
The return value of request_module() being 0 does not mean that the
driver which was requested has loaded. To properly check that the driver
was loaded each driver can use internal mechanisms to vet the driver is
now present. The helper try_then_request_module() was added to help with
this, allowing drivers to specify their own validation as the first
argument for synchronous requests.

On iwlwifi the use case is a bit more complicated given that the value
we need to check for is protected with a mutex later used on the
module_init() of the module we are asking for. If we were to lock and
request_module() we'd deadlock. iwlwifi could use its own wrapper for
requesting its ops module synchronously so it can handle its special
locking requirements on its own but the given code has been in the
kernel for a long time and the preference is to keep its simplicity.

We can do two more things to simplify this even further:

a) just use the async request, request_module_nowait(), to acknowledge
   we are using best effort -- we are not verifying the module is loaded

b) we can unconditionally call request_module_nowait() whether or not
   we were built-in or not, if built-in this will return immediately
   without failure.

Signed-off-by: Luis R. Rodriguez 
---
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c | 21 -
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
index e198d6f5fcea..e96095c1824a 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
@@ -1250,7 +1250,6 @@ static void iwl_req_fw_callback(const struct firmware 
*ucode_raw, void *context)
size_t trigger_tlv_sz[FW_DBG_TRIGGER_MAX];
u32 api_ver;
int i;
-   bool load_module = false;
bool usniffer_images = false;
 
fw->ucode_capa.max_probe_length = IWL_DEFAULT_MAX_PROBE_LENGTH;
@@ -1454,8 +1453,6 @@ static void iwl_req_fw_callback(const struct firmware 
*ucode_raw, void *context)
mutex_unlock(&iwlwifi_opmode_table_mtx);
goto out_unbind;
}
-   } else {
-   load_module = true;
}
mutex_unlock(&iwlwifi_opmode_table_mtx);
 
@@ -1466,20 +1463,10 @@ static void iwl_req_fw_callback(const struct firmware 
*ucode_raw, void *context)
 */
complete(&drv->request_firmware_complete);
 
-   /*
-* Load the module last so we don't block anything
-* else from proceeding if the module fails to load
-* or hangs loading.
-*/
-   if (load_module) {
-   err = request_module("%s", op->name);
-#ifdef CONFIG_IWLWIFI_OPMODE_MODULAR
-   if (err)
-   IWL_ERR(drv,
-   "failed to load module %s (error %d), is 
dynamic loading enabled?\n",
-   op->name, err);
-#endif
-   }
+   err = request_module_nowait("%s", op->name);
+   if (err)
+   goto out_unbind;
+
goto free;
 
  try_again:
-- 
2.11.0



[PATCH v2 1/2] iwlwifi: fix drv cleanup on opmode registration failure

2017-02-21 Thread Luis R. Rodriguez
The firmware async callback handles the device's opmode start
call, but optionally also allows opmode registration to take
care of its opmode start. If the firmware callback handles it
its error path in case of opmode start failure has a few pieces
of code missing from the opmode registration. The opmode
registration hanlder has no cleanup at all. Sync both error
paths.

This should in theory fix a detangled drv from the drv list should
either of the opmode modules loaded and handled registration for the
drv.

The path of having the opmode registration deal with the drv
opmode start is actually the more common path. The other path,
from the async callback is rathe rare (1/8 or so times for me) --
it happens when the the opmode driver's init routine completed
prior to the driver's async callback opmode start call.

Signed-off-by: Luis R. Rodriguez 
---
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
index be466a074c1d..e198d6f5fcea 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
@@ -1611,8 +1611,13 @@ int iwl_opmode_register(const char *name, const struct 
iwl_op_mode_ops *ops)
continue;
op->ops = ops;
/* TODO: need to handle exceptional case */
-   list_for_each_entry(drv, &op->drv, list)
+   list_for_each_entry(drv, &op->drv, list) {
drv->op_mode = _iwl_op_mode_start(drv, op);
+   if (!drv->op_mode) {
+   complete(&drv->request_firmware_complete);
+   device_release_driver(drv->trans->dev);
+   }
+   }
 
mutex_unlock(&iwlwifi_opmode_table_mtx);
return 0;
-- 
2.11.0



Re: [RFC 2/5] iwlwifi: fix request_module() use

2017-02-21 Thread Luis R. Rodriguez
On Tue, Feb 21, 2017 at 09:17:15PM +0100, Luis R. Rodriguez wrote:
> On Tue, Feb 21, 2017 at 07:15:41PM +0100, Luis R. Rodriguez wrote:
> > On Tue, Feb 21, 2017 at 07:16:16AM +, Grumbach, Emmanuel wrote:
> > > > 
> > > > a) just remove the print and use instead request_module_nowait() (this 
> > > > is
> > > > more in alignment of what your code actually does today; or
> > > > 
> > > > b) fix the request_module() use so that the error print matches the
> > > > expected and proper recommended use of request_module() (what this patch
> > > > does)
> > > > 
> > > > I prefer a) actually but I had to show what b) looked like first :)
> > >
> > > Me too. Let's do the simple thing. After all, it's been working for 5 
> > > years
> > > now (maybe more?) and I don't see a huge need to verify that the opmode
> > > module has been loaded.  It is very unlikely to fail anyway, and in the 
> > > case
> > > it did fail, it's not that we can do much from iwlwifi point of view. 
> > 
> > I tend to agree with you on this, retries would be the only sensible thing 
> > to
> > do, but why do that -- the error should be logged right and addressed by any
> > upper layers. Its one reason to consider in the future adding verifiers
> > as built-in optional part of module loading.
> 
> It would seem we still need to offload the opmode start as it is the one that
> really should be issuing the completion, otherwise we would end up sending a
> completion while the opmode module is being loaded asynchronously. The changes
> are for that are still very likely desirable as it should help with speeding
> boot up.
> 
> So the sharing of the opcode start will go first.
> 
> Will send v2.

Actually the completion was always being sent prior to request_module(), so this
would not change anything really. The sharing of the opcode then is optional,
and I can send separately in another series.

  Luis


[PATCH] mac80211: Jitter HWMP MPATH reply frames to reduce collision, on dense networks.

2017-02-21 Thread Alexis Green
From: Jesse Jones 

When more than one station hears a broadcast request, it is possible that
multiple devices will reply at the same time, potentially causing
collision. This patch helps reduce this issue.

Signed-off-by: Alexis Green 
Signed-off-by: Benjamin Morgan 
---
 net/mac80211/ieee80211_i.h |  11 
 net/mac80211/iface.c   |  58 +
 net/mac80211/mesh.c|   2 +
 net/mac80211/mesh_hwmp.c   | 124 +++--
 4 files changed, 168 insertions(+), 27 deletions(-)

diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 159a1a7..f422897 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -330,6 +330,11 @@ struct mesh_preq_queue {
u8 flags;
 };
 
+struct mesh_tx_queue {
+   struct list_head list;
+   struct sk_buff *skb;
+};
+
 struct ieee80211_roc_work {
struct list_head list;
 
@@ -670,6 +675,11 @@ struct ieee80211_if_mesh {
spinlock_t mesh_preq_queue_lock;
struct mesh_preq_queue preq_queue;
int preq_queue_len;
+   /* Spinlock for MPATH frame tx queue */
+   spinlock_t mesh_tx_queue_lock;
+   struct mesh_tx_queue tx_queue;
+   int tx_queue_len;
+
struct mesh_stats mshstats;
struct mesh_config mshcfg;
atomic_t estab_plinks;
@@ -919,6 +929,7 @@ struct ieee80211_sub_if_data {
 
struct work_struct work;
struct sk_buff_head skb_queue;
+   struct delayed_work tx_work;
 
u8 needed_rx_chains;
enum ieee80211_smps_mode smps_mode;
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 40813dd..51d5cfa 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -778,6 +778,59 @@ static int ieee80211_open(struct net_device *dev)
return ieee80211_do_open(&sdata->wdev, true);
 }
 
+static void flush_tx_skbs(struct ieee80211_sub_if_data *sdata)
+{
+   struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
+   struct mesh_tx_queue *tx_node;
+
+   spin_lock_bh(&ifmsh->mesh_tx_queue_lock);
+
+   /* Note that this check is important because of the two-stage
+* way that ieee80211_if_mesh is initialized.
+*/
+   if (ifmsh->tx_queue_len > 0) {
+   mhwmp_dbg(sdata, "flushing %d skbs", ifmsh->tx_queue_len);
+
+   while (!list_empty(&ifmsh->tx_queue.list)) {
+   tx_node = list_last_entry(&ifmsh->tx_queue.list,
+ struct mesh_tx_queue, list);
+   kfree_skb(tx_node->skb);
+   list_del(&tx_node->list);
+   kfree(tx_node);
+   }
+   ifmsh->tx_queue_len = 0;
+   }
+
+   spin_unlock_bh(&ifmsh->mesh_tx_queue_lock);
+}
+
+static void mesh_jittered_tx(struct work_struct *wk)
+{
+   struct ieee80211_sub_if_data *sdata =
+   container_of(
+wk, struct ieee80211_sub_if_data,
+tx_work.work);
+
+   struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
+   struct mesh_tx_queue *tx_node;
+
+   spin_lock_bh(&ifmsh->mesh_tx_queue_lock);
+
+   list_for_each_entry(tx_node, &ifmsh->tx_queue.list, list) {
+   ieee80211_tx_skb(sdata, tx_node->skb);
+   }
+
+   while (!list_empty(&ifmsh->tx_queue.list)) {
+   tx_node = list_last_entry(&ifmsh->tx_queue.list,
+ struct mesh_tx_queue, list);
+   list_del(&tx_node->list);
+   kfree(tx_node);
+   }
+   ifmsh->tx_queue_len = 0;
+
+   spin_unlock_bh(&ifmsh->mesh_tx_queue_lock);
+}
+
 static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
  bool going_down)
 {
@@ -881,6 +934,9 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data 
*sdata,
 
cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
 
+   flush_tx_skbs(sdata);
+   cancel_delayed_work_sync(&sdata->tx_work);
+
if (sdata->wdev.cac_started) {
chandef = sdata->vif.bss_conf.chandef;
WARN_ON(local->suspended);
@@ -1846,6 +1902,8 @@ int ieee80211_if_add(struct ieee80211_local *local, const 
char *name,
  ieee80211_dfs_cac_timer_work);
INIT_DELAYED_WORK(&sdata->dec_tailroom_needed_wk,
  ieee80211_delayed_tailroom_dec);
+   INIT_DELAYED_WORK(&sdata->tx_work,
+ mesh_jittered_tx);
 
for (i = 0; i < NUM_NL80211_BANDS; i++) {
struct ieee80211_supported_band *sband;
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index c28b0af..f0d3cd9 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -1381,6 +1381,8 @@ void ieee80211_mesh_init_sdata(struct 
ieee80211_sub_if_data *sdata)
ieee80211_mesh_path_root_timer,
(unsigned long) sdata);
INIT_LIST_HEAD(&ifms

Usage of WoWLAN with iwlwifi driver (Device phy0 failed to suspend async: error -16)

2017-02-21 Thread Oliver Freyermuth
Dear wireless experts, 

I have been trying to get basic WoWLAN to work with the following configuration:
- Intel Corporation Wireless 7260 (rev 73) with in-tree iwlwifi driver
- Kernel 4.10.0 (on Gentoo Linux)
- Very recent firmware version for the card and revision:
iwlwifi :0a:00.0: loaded firmware version 17.459231.0 op_mode iwlmvm
iwlwifi :0a:00.0: Detected Intel(R) Dual Band Wireless AC 7260, REV=0x144

I try to do:
$ iw phy phy0 wowlan enable magic-packet
$ iw phy phy0 wowlan show
WoWLAN is enabled:
 * wake up on magic packet

However, when trying to suspend to RAM ( echo mem > /sys/power/state ), I get:
[46656.403767] dpm_run_callback(): wiphy_suspend+0x0/0x97 [cfg80211] returns -16
[46656.403769] PM: Device phy0 failed to suspend async: error -16
[46656.967002] PM: Some devices failed to suspend, or early wake event detected

It also happens with more complex configurations (e.g. TCP connection WoWLAN 
mode). 

Only after:
$ iw phy phy0 wowlan disable
I can suspend normally again. 

I found an earlier report here:
https://bugzilla.kernel.org/show_bug.cgi?id=109591#c25
from somebody using kernel 4.6. 

Is this a known issue? Is WoWLAN supposed to work with this hardware (I guess 
it's quite wide-spread)? 

If possible, please ping me directly in replies, I am not subscribed to the 
list (but will try to check gmane regularly). 

Cheers and thanks for any support, 
Oliver


Regression with Intel 3160 AP: client not reconnecting

2017-02-21 Thread Jarek Kamiński
Hello,

I have an accesspoint running on Intel 3160 (ZBOX RI-323). It was
running just fine on 3.16 from Debian, but I recently tried upgrading it
to 4.9 and noticed strange issues with wireless clients.

With the recent versions of iwlwifi, when a client disconnects, it is
not noticed by the accesspoint. The following log comes from
backport-iwlwifi master (7ae529a404a30fdb78d7dcc1a7e5883a014c6552) on
3.16 (similar results on 4.9 as well):
#v+
lut 21 22:12:04 Wintermute hostapd[2419]: wlan0: STA xx:xx:xx:xx:xx:xx RADIUS: 
VLAN ID 2
lut 21 22:12:04 Wintermute hostapd[2419]: wlan0: STA xx:xx:xx:xx:xx:xx IEEE 
802.11: authenticated
lut 21 22:12:04 Wintermute hostapd[2419]: wlan0: STA xx:xx:xx:xx:xx:xx IEEE 
802.11: associated (aid 3)
lut 21 22:12:04 Wintermute hostapd[2419]: wlan0: STA xx:xx:xx:xx:xx:xx RADIUS: 
starting accounting session 58ACAD18-0002
lut 21 22:12:04 Wintermute hostapd[2419]: wlan0: STA xx:xx:xx:xx:xx:xx WPA: 
pairwise key handshake completed (RSN)
[disconnect: nothing happens]
[try to reconnect: nothing happens, client doesn't connect]
#v-
Only running iw wlan0.2 station del xx:xx:xx:xx:xx:xx helps and allows
the client to connect.

To compare, on iwlwifi from Debian 3.16.39-1-amd64 everything works fine:
#v+
lut 21 22:03:46 Wintermute hostapd[12719]: wlan0: STA xx:xx:xx:xx:xx:xx RADIUS: 
VLAN ID 2
lut 21 22:03:46 Wintermute hostapd[12719]: wlan0: STA xx:xx:xx:xx:xx:xx IEEE 
802.11: authenticated
lut 21 22:03:46 Wintermute hostapd[12719]: wlan0: STA xx:xx:xx:xx:xx:xx IEEE 
802.11: associated (aid 2)
lut 21 22:03:49 Wintermute hostapd[12719]: wlan0: STA xx:xx:xx:xx:xx:xx RADIUS: 
starting accounting session 58A9650D-0084
lut 21 22:03:49 Wintermute hostapd[12719]: wlan0: STA xx:xx:xx:xx:xx:xx WPA: 
pairwise key handshake completed (RSN)

lut 21 22:04:16 Wintermute hostapd[12719]: wlan0: STA xx:xx:xx:xx:xx:xx IEEE 
802.11: disassociated
lut 21 22:04:16 Wintermute hostapd[12719]: wlan0: STA xx:xx:xx:xx:xx:xx IEEE 
802.11: disassociated
lut 21 22:04:17 Wintermute hostapd[12719]: wlan0: STA xx:xx:xx:xx:xx:xx IEEE 
802.11: deauthenticated due to inactivity (timer DEAUTH/REMOVE)

lut 21 22:04:24 Wintermute hostapd[12719]: wlan0: STA xx:xx:xx:xx:xx:xx RADIUS: 
VLAN ID 2
lut 21 22:04:24 Wintermute hostapd[12719]: wlan0: STA xx:xx:xx:xx:xx:xx IEEE 
802.11: authenticated
lut 21 22:04:24 Wintermute hostapd[12719]: wlan0: STA xx:xx:xx:xx:xx:xx IEEE 
802.11: associated (aid 2)
lut 21 22:04:26 Wintermute hostapd[12719]: wlan0: STA xx:xx:xx:xx:xx:xx RADIUS: 
starting accounting session 58A9650D-0085
lut 21 22:04:26 Wintermute hostapd[12719]: wlan0: STA xx:xx:xx:xx:xx:xx WPA: 
pairwise key handshake completed (RSN)
#v-

I bisected it using the backport-iwlwifi tree on 4.5 down to
4061dda503118ef5c70e0afe77798c94a48a79b9 (iwlwifi: mvm: pass station to
mac80211 RX where known, [1]). I was using the following test procedure:
1) Build, load, start hostapd.
2) Connect with an Android mobile phone (which I had at hand).
3) Disable Wi-Fi on Android.
4) Reenable Wi-Fi. Connected -> git bisect good, didn't connect -> git
   bisect bad.
I was using 4.5 because that was the lowest version against which all
intermediate commits were compiling without errors.

To verify, I patched the backports-iwlwifi master with the following
patch (on 3.16) and the Android phone started reconnecting.
#v+
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
index b02ad68..70edf42 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
@@ -144,7 +144,7 @@ static void iwl_mvm_pass_packet_to_mac80211(struct iwl_mvm 
*mvm,
fraglen, rxb->truesize);
}
 
-   ieee80211_rx_napi(mvm->hw, sta, skb, napi);
+   ieee80211_rx_napi(mvm->hw, NULL, skb, napi);
 }
 
 /*
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
index 66d237c..93c2542 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
@@ -209,7 +209,7 @@ static void iwl_mvm_pass_packet_to_mac80211(struct iwl_mvm 
*mvm,
if (iwl_mvm_check_pn(mvm, skb, queue, sta))
kfree_skb(skb);
else
-   ieee80211_rx_napi(mvm->hw, sta, skb, napi);
+   ieee80211_rx_napi(mvm->hw, NULL, skb, napi);
 }
 
 static void iwl_mvm_get_signal_strength(struct iwl_mvm *mvm,
#v-
I assume that's not a correct fix, but maybe it can help to pinpoint the
root cause.

I'm running hostapd in a fairly normal configuration. One notable thing
is dynamic_vlan=1 with accept_mac_file and individual PSKs set in
wpa_psk_file.

What might be the cause? Is there anything I can do to help debug or fix
this?

Thanks in advance!

[1] 
http://git.kernel.org/cgit/linux/kernel/git/iwlwifi/backport-iwlwifi.git/commit/?id=4061dda503118ef5c70e0afe77798c94a48a79b9


-- 
pozdr(); // Jarek


Re: ath10k regression on XPS13

2017-02-21 Thread David Miller
From: Linus Torvalds 
Date: Tue, 21 Feb 2017 10:52:33 -0800

> On Tue, Feb 21, 2017 at 10:18 AM, David Miller  wrote:
>>
>> Kalle I really wanted to send my net-next pull request to Linus later
>> today.  But I guess I have to wait for this ath10k first.
> 
> Feel free to send it to me - it sounds like the regression is
>  (a) easy to work around
> and
>  (b) has a fix coming up.
> 
> And it won't even be something that I personally notice, since I have
> the prev-gen XPS13 that has intel wireless.

I have the revert in my tree, it's all good.

I'll let my tree sit quietly for a few hours then send a pull
request out later tonight.


Re: ath10k regression on XPS13

2017-02-21 Thread David Miller
From: Kalle Valo 
Date: Tue, 21 Feb 2017 21:49:09 +0200

> David Miller  writes:
> 
>> From: Kalle Valo 
>> Date: Tue, 21 Feb 2017 20:38:48 +0200
>>
>>> David Miller  writes:
>>> 
 From: Kalle Valo 
 Date: Tue, 21 Feb 2017 11:32:49 +0200

> We are working on a fix so that ath10k continues to work with older
> board-2.bin, but that might take a day or two still.

 Kalle I really wanted to send my net-next pull request to Linus later
 today.  But I guess I have to wait for this ath10k first.

 Please get this to me as soon as possible, thanks.
>>> 
>>> We have a fix now but it's not really tested that well so I'm reluctant
>>> to submit it yet. As I don't want to make you wait I think I'll submit
>>> you a patch reverting f2593cb1b291 in an hour or two. And later in the
>>> week I send you a properly fixed (and tested) version of f2593cb1b291.
>>> 
>>> Does that sound ok to you?
>>
>> Sure.
> 
> Here's the revert:
> 
> https://patchwork.ozlabs.org/patch/730735/
> 
> I didn't send a pull request because that felt overkill to do just for
> one patch.

Yep, that's fine.


Re: [PATCH] Revert "ath10k: Search SMBIOS for OEM board file extension"

2017-02-21 Thread David Miller
From: Kalle Valo 
Date: Tue, 21 Feb 2017 21:47:06 +0200

> This reverts commit f2593cb1b29185d38db706cbcbe22ed538720ae1.
> 
> Paul reported that this patch with older board-2.bin ath10k initialisation
> fails on Dell XPS 13:
> 
> ath10k_pci :3a:00.0: failed to fetch board data for bus=pci,vendor=168c,
> device=003e,subsystem-vendor=1a56,subsystem-device=1535,variant=RV_0520 from
> ath10k/QCA6174/hw3.0/board-2.bin
> 
> The reason is that the older board-2.bin does not have the variant version of
> the image name and ath10k does not fallback to the older naming scheme.
> 
> Reported-by: Paul Menzel 
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=185621#c9
> Fixes: f2593cb1b291 ("ath10k: Search SMBIOS for OEM board file extension")
> Signed-off-by: Kalle Valo 
> ---
> 
> Dave, please take this directly if you can.

Applied, thanks Kalle.


Re: [RFC 2/5] iwlwifi: fix request_module() use

2017-02-21 Thread Luis R. Rodriguez
On Tue, Feb 21, 2017 at 07:15:41PM +0100, Luis R. Rodriguez wrote:
> On Tue, Feb 21, 2017 at 07:16:16AM +, Grumbach, Emmanuel wrote:
> > > 
> > > a) just remove the print and use instead request_module_nowait() (this is
> > > more in alignment of what your code actually does today; or
> > > 
> > > b) fix the request_module() use so that the error print matches the
> > > expected and proper recommended use of request_module() (what this patch
> > > does)
> > > 
> > > I prefer a) actually but I had to show what b) looked like first :)
> >
> > Me too. Let's do the simple thing. After all, it's been working for 5 years
> > now (maybe more?) and I don't see a huge need to verify that the opmode
> > module has been loaded.  It is very unlikely to fail anyway, and in the case
> > it did fail, it's not that we can do much from iwlwifi point of view. 
> 
> I tend to agree with you on this, retries would be the only sensible thing to
> do, but why do that -- the error should be logged right and addressed by any
> upper layers. Its one reason to consider in the future adding verifiers
> as built-in optional part of module loading.

It would seem we still need to offload the opmode start as it is the one that
really should be issuing the completion, otherwise we would end up sending a
completion while the opmode module is being loaded asynchronously. The changes
are for that are still very likely desirable as it should help with speeding
boot up.

So the sharing of the opcode start will go first.

Will send v2.

  Luis


Re: [PATCH] cfg80211: support 4-way handshake offloading for WPA/WPA2-PSK

2017-02-21 Thread Arend Van Spriel
On 21-2-2017 13:37, Johannes Berg wrote:
> 
>> What I am also missing is how to deal with NL80211_CMD_CONNECTED
>> event signalling. Should that be given after (un)successful
>> completion of the 4-way handshake or should we have a separate event
>> for that? 
> 
> That's a good point. I don't think a new event really works well, but
> perhaps we should extend the NL80211_TIMEOUT_* values with this? It's
> not strictly a timeout, I guess, but it's not a direct rejection of the
> association either.
> 
> Any thoughts?

I discussed about the event mechanism with Jithu which is who asked me
to look at their patches for this feature. His suggestion was to have a
"port authorized" event after successful handshake as it will help in
key mgmt offload cases. He gave the following example: Suppose you are
doing a fresh 8021x followed by 4way handshake offload. Right now there
is no event to indicate to the upper layer that the 4way handshake have
been completed successfully. So the only thing to do in wpa_supplicant
is to consider it completed and if not be hit with deauth.

Regards,
Arend


Re: ath10k regression on XPS13

2017-02-21 Thread Kalle Valo
David Miller  writes:

> From: Kalle Valo 
> Date: Tue, 21 Feb 2017 20:38:48 +0200
>
>> David Miller  writes:
>> 
>>> From: Kalle Valo 
>>> Date: Tue, 21 Feb 2017 11:32:49 +0200
>>>
 We are working on a fix so that ath10k continues to work with older
 board-2.bin, but that might take a day or two still.
>>>
>>> Kalle I really wanted to send my net-next pull request to Linus later
>>> today.  But I guess I have to wait for this ath10k first.
>>>
>>> Please get this to me as soon as possible, thanks.
>> 
>> We have a fix now but it's not really tested that well so I'm reluctant
>> to submit it yet. As I don't want to make you wait I think I'll submit
>> you a patch reverting f2593cb1b291 in an hour or two. And later in the
>> week I send you a properly fixed (and tested) version of f2593cb1b291.
>> 
>> Does that sound ok to you?
>
> Sure.

Here's the revert:

https://patchwork.ozlabs.org/patch/730735/

I didn't send a pull request because that felt overkill to do just for
one patch.

-- 
Kalle Valo


[PATCH] Revert "ath10k: Search SMBIOS for OEM board file extension"

2017-02-21 Thread Kalle Valo
This reverts commit f2593cb1b29185d38db706cbcbe22ed538720ae1.

Paul reported that this patch with older board-2.bin ath10k initialisation
fails on Dell XPS 13:

ath10k_pci :3a:00.0: failed to fetch board data for bus=pci,vendor=168c,
device=003e,subsystem-vendor=1a56,subsystem-device=1535,variant=RV_0520 from
ath10k/QCA6174/hw3.0/board-2.bin

The reason is that the older board-2.bin does not have the variant version of
the image name and ath10k does not fallback to the older naming scheme.

Reported-by: Paul Menzel 
Link: https://bugzilla.kernel.org/show_bug.cgi?id=185621#c9
Fixes: f2593cb1b291 ("ath10k: Search SMBIOS for OEM board file extension")
Signed-off-by: Kalle Valo 
---

Dave, please take this directly if you can.

 drivers/net/wireless/ath/ath10k/core.c | 84 ++
 drivers/net/wireless/ath/ath10k/core.h | 19 
 2 files changed, 3 insertions(+), 100 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 59729aa8cd82..dd902b43f8f7 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -18,8 +18,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 
 #include "core.h"
@@ -713,72 +711,6 @@ static int ath10k_core_get_board_id_from_otp(struct ath10k 
*ar)
return 0;
 }
 
-static void ath10k_core_check_bdfext(const struct dmi_header *hdr, void *data)
-{
-   struct ath10k *ar = data;
-   const char *bdf_ext;
-   const char *magic = ATH10K_SMBIOS_BDF_EXT_MAGIC;
-   u8 bdf_enabled;
-   int i;
-
-   if (hdr->type != ATH10K_SMBIOS_BDF_EXT_TYPE)
-   return;
-
-   if (hdr->length != ATH10K_SMBIOS_BDF_EXT_LENGTH) {
-   ath10k_dbg(ar, ATH10K_DBG_BOOT,
-  "wrong smbios bdf ext type length (%d).\n",
-  hdr->length);
-   return;
-   }
-
-   bdf_enabled = *((u8 *)hdr + ATH10K_SMBIOS_BDF_EXT_OFFSET);
-   if (!bdf_enabled) {
-   ath10k_dbg(ar, ATH10K_DBG_BOOT, "bdf variant name not 
found.\n");
-   return;
-   }
-
-   /* Only one string exists (per spec) */
-   bdf_ext = (char *)hdr + hdr->length;
-
-   if (memcmp(bdf_ext, magic, strlen(magic)) != 0) {
-   ath10k_dbg(ar, ATH10K_DBG_BOOT,
-  "bdf variant magic does not match.\n");
-   return;
-   }
-
-   for (i = 0; i < strlen(bdf_ext); i++) {
-   if (!isascii(bdf_ext[i]) || !isprint(bdf_ext[i])) {
-   ath10k_dbg(ar, ATH10K_DBG_BOOT,
-  "bdf variant name contains non ascii 
chars.\n");
-   return;
-   }
-   }
-
-   /* Copy extension name without magic suffix */
-   if (strscpy(ar->id.bdf_ext, bdf_ext + strlen(magic),
-   sizeof(ar->id.bdf_ext)) < 0) {
-   ath10k_dbg(ar, ATH10K_DBG_BOOT,
-  "bdf variant string is longer than the buffer can 
accommodate (variant: %s)\n",
-   bdf_ext);
-   return;
-   }
-
-   ath10k_dbg(ar, ATH10K_DBG_BOOT,
-  "found and validated bdf variant smbios_type 0x%x bdf %s\n",
-  ATH10K_SMBIOS_BDF_EXT_TYPE, bdf_ext);
-}
-
-static int ath10k_core_check_smbios(struct ath10k *ar)
-{
-   ar->id.bdf_ext[0] = '\0';
-   dmi_walk(ath10k_core_check_bdfext, ar);
-
-   if (ar->id.bdf_ext[0] == '\0')
-   return -ENODATA;
-
-   return 0;
-}
-
 static int ath10k_download_and_run_otp(struct ath10k *ar)
 {
u32 result, address = ar->hw_params.patch_load_addr;
@@ -1125,9 +1057,6 @@ static int ath10k_core_fetch_board_data_api_n(struct 
ath10k *ar,
 static int ath10k_core_create_board_name(struct ath10k *ar, char *name,
 size_t name_len)
 {
-   /* strlen(',variant=') + strlen(ar->id.bdf_ext) */
-   char variant[9 + ATH10K_SMBIOS_BDF_EXT_STR_LENGTH] = { 0 };
-
if (ar->id.bmi_ids_valid) {
scnprintf(name, name_len,
  "bus=%s,bmi-chip-id=%d,bmi-board-id=%d",
@@ -1137,15 +1066,12 @@ static int ath10k_core_create_board_name(struct ath10k 
*ar, char *name,
goto out;
}
 
-   if (ar->id.bdf_ext[0] != '\0')
-   scnprintf(variant, sizeof(variant), ",variant=%s",
- ar->id.bdf_ext);
-
scnprintf(name, name_len,
- 
"bus=%s,vendor=%04x,device=%04x,subsystem-vendor=%04x,subsystem-device=%04x%s",
+ 
"bus=%s,vendor=%04x,device=%04x,subsystem-vendor=%04x,subsystem-device=%04x",
  ath10k_bus_str(ar->hif.bus),
  ar->id.vendor, ar->id.device,
- ar->id.subsystem_vendor, ar->id.subsystem_device, variant);
+ ar->id.subsystem_vendor, ar->id.subsystem_device);
+
 out:
ath10k_db

Problem with RTL8191SU driver

2017-02-21 Thread Marius Melzer
Hi,

I have a usb wifi stick with a RTL8191SU chipset and the driver doesn't
work for me (at least I think that's the problem). I'm using the
following driver: [1] which refers on its page to this email address for
reports.

I listed all relevant information in a post [2] in the archlinux forum,
espescially interesting is probably the dmesg output [3] and the
systemctl status NetworkManager output [4]. Also with NetworkManager
stopped it doesn't work (which was one of the proposed solutions): [5]

Is this a driver problem? If yes, how can I solve this? Espescially the
"does not support SSID scanning" is a bit weird for a usb wifi stick
which should at least support this, right?

Thanks in advance,
Marius

PS: Please keep me in CC or send me a quick message if I need to
subscribe to the mailinglist to follow the thread.

[1] https://github.com/chunkeey/rtl8192su
[2] https://bbs.archlinux.org/viewtopic.php?id=223264
[3] https://bbs.archlinux.org/viewtopic.php?pid=1691938#p1691938
[4] https://bbs.archlinux.org/viewtopic.php?pid=1692639#p1692639
[5] https://bbs.archlinux.org/viewtopic.php?pid=1692790#p1692790


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

2017-02-21 Thread Luis R. Rodriguez
On Tue, Feb 21, 2017 at 10:47:53AM +0100, Rafał Miłecki wrote:
> 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.
> 
> Resolve this problem by adding a one flexible function and making old
> request_firmware_nowait a simple inline using new solution. This
> implementation:
> 1) Modifies only single bits on existing code
> 2) Doesn't require adjusting / rewriting current drivers
> 3) Adds new function for drivers that need more control over loading a
>firmware. Thanks to using flags more features can be added later.
> 
> Signed-off-by: Rafał Miłecki 
> ---
> This patch is based on top of
> [PATCH V2 RESEND] firmware: simplify defining and handling FW_OPT_FALLBACK
> applied on top of Linux 4.10-rc8.
> 
> Ming/Luis/Greg: assuming this gets a positive review, could someone of you 
> pick
> this patchset? Second patch modifies brcmfmac, I'll try to get a proper Ack 
> for
> that one.
> Unless you want this to go through wireless tree, then let me know please.

As noted in the v1 and v2 series:

This is not as flexible as we need. I'll fold this functionality in to the
driver data series as it provides more flexibility and enables more testing to
be done in userspace.

  Luis


Re: ath10k regression on XPS13

2017-02-21 Thread David Miller
From: Kalle Valo 
Date: Tue, 21 Feb 2017 20:38:48 +0200

> David Miller  writes:
> 
>> From: Kalle Valo 
>> Date: Tue, 21 Feb 2017 11:32:49 +0200
>>
>>> We are working on a fix so that ath10k continues to work with older
>>> board-2.bin, but that might take a day or two still.
>>
>> Kalle I really wanted to send my net-next pull request to Linus later
>> today.  But I guess I have to wait for this ath10k first.
>>
>> Please get this to me as soon as possible, thanks.
> 
> We have a fix now but it's not really tested that well so I'm reluctant
> to submit it yet. As I don't want to make you wait I think I'll submit
> you a patch reverting f2593cb1b291 in an hour or two. And later in the
> week I send you a properly fixed (and tested) version of f2593cb1b291.
> 
> Does that sound ok to you?

Sure.


Re: ath10k regression on XPS13

2017-02-21 Thread Linus Torvalds
On Tue, Feb 21, 2017 at 10:18 AM, David Miller  wrote:
>
> Kalle I really wanted to send my net-next pull request to Linus later
> today.  But I guess I have to wait for this ath10k first.

Feel free to send it to me - it sounds like the regression is
 (a) easy to work around
and
 (b) has a fix coming up.

And it won't even be something that I personally notice, since I have
the prev-gen XPS13 that has intel wireless.

  Linus


Re: TL-WN823N

2017-02-21 Thread Jes Sorensen

On 02/16/2017 10:20 AM, madmaxxx wrote:

Hi,

I have a problem with rtl8xxxu driver, which seems to not work with a
dongle tp-link TL-WN823N model. I just filled out a 4.9.10 kernel and the
device is not fully recognized .. I can only scan network and not link.

Thank you


There is nothing in this output that looks unusual, you need to provide 
more data.


Jes



lsusb:
Bus 002 Device 002: ID 2357:0109

dmesg:
[gio feb 16 16:08:33 2017] usb 2-1: Vendor: Realtek
[gio feb 16 16:08:33 2017] usb 2-1: Product: \x03802.11n NI
[gio feb 16 16:08:33 2017] usb 2-1: Serial:
[gio feb 16 16:08:33 2017] usb 2-1: rtl8192eu_parse_efuse: dumping efuse
(0x200 bytes):
[gio feb 16 16:08:33 2017] usb 2-1: 00: 29 81 00 7c 01 40 03 00
[gio feb 16 16:08:33 2017] usb 2-1: 08: 40 74 04 50 14 00 00 00
[gio feb 16 16:08:33 2017] usb 2-1: 10: 28 28 28 29 29 29 2a 2a
[gio feb 16 16:08:33 2017] usb 2-1: 18: 2b 2b 2b f2 ef ef ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 20: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 28: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 30: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 38: ff ff 28 28 28 28 28 28
[gio feb 16 16:08:33 2017] usb 2-1: 40: 2a 2a 29 2a 2a f2 ef ef
[gio feb 16 16:08:33 2017] usb 2-1: 48: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 50: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 58: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 60: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 68: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 70: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 78: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 80: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 88: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 90: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 98: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: a0: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: a8: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: b0: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: b8: a1 22 21 00 00 00 ff ff
[gio feb 16 16:08:33 2017] usb 2-1: c0: ff 01 00 10 00 00 00 ff
[gio feb 16 16:08:33 2017] usb 2-1: c8: 00 00 ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: d0: 57 23 09 01 e7 47 02 98
[gio feb 16 16:08:33 2017] usb 2-1: d8: de d0 1e a4 d7 0a 03 52
[gio feb 16 16:08:33 2017] usb 2-1: e0: 65 61 6c 74 65 6b 20 0e
[gio feb 16 16:08:33 2017] usb 2-1: e8: 03 38 30 32 2e 31 31 6e
[gio feb 16 16:08:33 2017] usb 2-1: f0: 20 4e 49 43 20 00 00 ff
[gio feb 16 16:08:33 2017] usb 2-1: f8: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 100: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 108: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 110: ff ff ff ff ff ff ff 0d
[gio feb 16 16:08:33 2017] usb 2-1: 118: 03 00 05 00 30 00 00 00
[gio feb 16 16:08:33 2017] usb 2-1: 120: 00 93 ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 128: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 130: f6 a8 98 2d 03 92 98 00
[gio feb 16 16:08:33 2017] usb 2-1: 138: fc 8c 00 11 9b 44 02 0a
[gio feb 16 16:08:33 2017] usb 2-1: 140: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 148: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 150: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 158: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 160: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 168: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 170: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 178: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 180: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 188: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 190: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 198: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 1a0: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 1a8: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 1b0: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 1b8: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 1c0: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 1c8: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 1d0: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 1d8: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 1e0: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 1e8: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 1f0: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: 1f8: ff ff ff ff ff ff ff ff
[gio feb 16 16:08:33 2017] usb 2-1: RTL8192EU rev B (SMIC) 2T2R, TX
queues 3, WiFi=1, BT=0, GPS=0, HI PA=0
[gio feb 16 16:08:33 2017] usb 2-1: RTL8192EU MAC: 98:de:d0:1e:a4:d7
[gio feb 16 16:08:33 2017] usb 2-1

Re: ath10k regression on XPS13

2017-02-21 Thread Kalle Valo
David Miller  writes:

> From: Kalle Valo 
> Date: Tue, 21 Feb 2017 11:32:49 +0200
>
>> We are working on a fix so that ath10k continues to work with older
>> board-2.bin, but that might take a day or two still.
>
> Kalle I really wanted to send my net-next pull request to Linus later
> today.  But I guess I have to wait for this ath10k first.
>
> Please get this to me as soon as possible, thanks.

We have a fix now but it's not really tested that well so I'm reluctant
to submit it yet. As I don't want to make you wait I think I'll submit
you a patch reverting f2593cb1b291 in an hour or two. And later in the
week I send you a properly fixed (and tested) version of f2593cb1b291.

Does that sound ok to you?

-- 
Kalle Valo


Re: [RFC 2/5] iwlwifi: fix request_module() use

2017-02-21 Thread Luis R. Rodriguez
On Tue, Feb 21, 2017 at 07:16:16AM +, Grumbach, Emmanuel wrote:
> > 
> > a) just remove the print and use instead request_module_nowait() (this is
> > more in alignment of what your code actually does today; or
> > 
> > b) fix the request_module() use so that the error print matches the
> > expected and proper recommended use of request_module() (what this patch
> > does)
> > 
> > I prefer a) actually but I had to show what b) looked like first :)
>
> Me too. Let's do the simple thing. After all, it's been working for 5 years
> now (maybe more?) and I don't see a huge need to verify that the opmode
> module has been loaded.  It is very unlikely to fail anyway, and in the case
> it did fail, it's not that we can do much from iwlwifi point of view. 

I tend to agree with you on this, retries would be the only sensible thing to
do, but why do that -- the error should be logged right and addressed by any
upper layers. Its one reason to consider in the future adding verifiers
as built-in optional part of module loading.

> iwlwifi will stay loaded and sit idle since no opmode will be there to start
> using the hardware. We will keep having the device claimed, and will keep the
> interrupt registered and all that. No WiFi for you, but no harm caused
> either.

Fine by me. Will send follow up simple patches.

  Luis


Re: ath10k regression on XPS13

2017-02-21 Thread David Miller
From: Kalle Valo 
Date: Tue, 21 Feb 2017 11:32:49 +0200

> We are working on a fix so that ath10k continues to work with older
> board-2.bin, but that might take a day or two still.

Kalle I really wanted to send my net-next pull request to Linus later
today.  But I guess I have to wait for this ath10k first.

Please get this to me as soon as possible, thanks.


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

2017-02-21 Thread Luis R. Rodriguez
On Thu, Feb 16, 2017 at 08:26:35AM +0100, Rafał Miłecki wrote:
> 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.
> 
> Resolve this problem by adding a one flexible function and making old
> request_firmware_nowait a simple inline using new solution. This
> implementation:
> 1) Modifies only single bits on existing code
> 2) Doesn't require adjusting / rewriting current drivers
> 3) Adds new function for drivers that need more control over loading a
>firmware. Thanks to using flags more features can be added later.
> 
> Signed-off-by: Rafał Miłecki 
> ---
> This patch is based on top of
> [PATCH V2 RESEND] firmware: simplify defining and handling FW_OPT_FALLBACK
> applied on top of Linux 4.10-rc8.
> 
> Ming/Luis/Greg: assuming this gets a positive review, could someone of you 
> pick
> this patchset? Second patch modifies brcmfmac, I'll try to get a proper Ack 
> for
> that one.
> Unless you want this to go through wireless tree, then let me know please.

As I noted in the v1 post, just exposing all the flags under the hood is not
enough to ensure sanity here. Additionally just flags won't cut it to make this
as flexible as we need. I've addressed this in the driver data series, so I'll
take this feature request and fold it in there.

  Luis


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

2017-02-21 Thread Luis R. Rodriguez
On Wed, Feb 15, 2017 at 11:29:47PM +0100, Rafał Miłecki wrote:
> 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.
> 
> Resolve this problem by adding a one flexible function 

You've just taken under-the-hood flags and exposed them without considering and
enabling easy testing of any possible conflicts here.  Take for instance the
FW_OPT_NOCACHE feature -- not using caching functionality has implications for
driver developers -- they *must* resolve their own suspend/resume mishaps.
Another example, when we get firmware signing having just flags won't cut it
for optional parameters, we want a struct with the ability to specify custom
signing requirements. Exposing just flags will not cut it for us long term and
we'd have to then either add new export symbol or modify this one.

This is not as flexible nor as well documented as I want for future
functionality. Nor is there any series of battery of tests of all possible
options to ensure we do not regress. I've addressed this in the driver data
series.

> and making old
> request_firmware_nowait a simple inline using new solution. 

This I had not addressed in the driver data series but I will fold similar
strategy onto it.

> This
> implementation:
> 1) Modifies only single bits on existing code
> 2) Doesn't require adjusting / rewriting current drivers
> 3) Adds new function for drivers that need more control over loading a
>firmware. Thanks to using flags more features can be added later.

As I noted in the driver data series -- we're passed using the firmware API for
non-firmware specific stuff, and as recent history shows regressions are are
easy, specially with the fallback mechanism. A new API which just gives us
2 calls: sync/async calls and shares a common set of optional parameters is
what we need, we need proper testing to ensure we also don't regress should
new features be introduced.

What I'll do is I'll integrate the feature you are asking for here and fold
this into the driver data series as what we need now is actual users of new
functionality, not just a test driver.

  Luis


ANNOUNCE: Netdev 2.1 CFP extended

2017-02-21 Thread Jamal Hadi Salim



The tech committee has graciously extended the CFP to February 27th.
Hurry o thee procastinators and submit early to avoid the hazards of
last minute traffic. Refer to:
https://netdevconf.org/2.1/submit-proposal.html

Some reminders, again:
-Registration is open. Register early so we can plan better.
https://onlineregistrations.ca/netdev21/

- hotel (If you can get the hotel cheaper online than conference
rates please send us email, dont book ):
https://www.netdevconf.org/2.1/hotel.html

cheers,
jamal


Re: [OpenWrt-Devel] ATH10K VLAN firmware issue

2017-02-21 Thread Bruno Antunes
On 21 February 2017 at 13:42, Tom Psyborg  wrote:
> have you tried this one
> https://forum.lede-project.org/t/new-qca988x-firmware-with-mesh-support/1587

>From my testing it does not work.

>
> On 21 February 2017 at 14:19, Valo, Kalle  wrote:
>>
>> voncken  writes:
>>
>> > Do you know if the firmware team planned to fix the VLAN issue on ath10k
>> > firmware?
>>
>> I reported it forward only this week.
>>
>> --
>> Kalle Valo
>> ___
>> openwrt-devel mailing list
>> openwrt-de...@lists.openwrt.org
>> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>
>
>
> ___
> openwrt-devel mailing list
> openwrt-de...@lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>


Re: [PATCH] Make EN2 pin optional in the TRF7970A driver

2017-02-21 Thread Rob Herring
On Sun, Feb 19, 2017 at 11:19 PM, Heiko Schocher  wrote:
> Hello all,
>
> Am 13.02.2017 um 22:31 schrieb Rob Herring:
>>
>> On Mon, Feb 13, 2017 at 12:38 AM, Heiko Schocher  wrote:
>>>
>>> Hello Rob,
>>>
>>>
>>> Am 10.02.2017 um 16:51 schrieb Rob Herring:


 On Tue, Feb 07, 2017 at 06:22:04AM +0100, Heiko Schocher wrote:
>
>
> From: Guan Ben 
>
> Make the EN2 pin optional. This is useful for boards,
> which have this pin fix wired, for example to ground.
>
> Signed-off-by: Guan Ben 
> Signed-off-by: Mark Jonas 
> Signed-off-by: Heiko Schocher 
>
> ---
>
>.../devicetree/bindings/net/nfc/trf7970a.txt   |  4 ++--
>drivers/nfc/trf7970a.c | 26
> --
>2 files changed, 16 insertions(+), 14 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/net/nfc/trf7970a.txt
> b/Documentation/devicetree/bindings/net/nfc/trf7970a.txt
> index 32b35a0..5889a3d 100644
> --- a/Documentation/devicetree/bindings/net/nfc/trf7970a.txt
> +++ b/Documentation/devicetree/bindings/net/nfc/trf7970a.txt
> @@ -5,8 +5,8 @@ Required properties:
>- spi-max-frequency: Maximum SPI frequency (<= 200).
>- interrupt-parent: phandle of parent interrupt handler.
>- interrupts: A single interrupt specifier.
> -- ti,enable-gpios: Two GPIO entries used for 'EN' and 'EN2' pins on
> the
> -  TRF7970A.
> +- ti,enable-gpios: One or two GPIO entries used for 'EN' and 'EN2'
> pins
> on the
> +  TRF7970A. EN2 is optional.



 Could EN ever be optional/fixed? If so, perhaps deprecate this property
 and do 2 properties, one for each pin.
>>>
>>>
>>>
>>> The hardware I have has the EN2 pin fix connected to ground. Looking
>>> into http://www.ti.com/lit/ds/slos743k/slos743k.pdf page 19 table 6-3
>>> and 6-4 the EN2 pin is a don;t core if EN = 1. If EN = 0 EN2 pin
>>> selects between Power Down and Sleep Mode ... I see no reason why
>>> this is not possible/allowed ...
>>>
>>> Hmm.. I do not like the idea of deprecating the "ti,enable-gpios"
>>> property into 2 seperate properties ... but if this would be a reason
>>> for not accepting this patch, I can do this ... How should I name
>>> the 2 new properties?
>>
>>
>> I guess if this ever happens, then we just add "ti,enable2-gpios" and
>> ti,enable-gpios continues to point to EN. We don't need to deprecate
>> anything (or maybe just deprecate having both GPIOs on single
>> property).
>>
>> In that case,
>>
>> Acked-by: Rob Herring 
>
>
> gentle ping.
>
> Are there any more comments to this patch? Is it acceptable as it
> is?

I acked it, so yes, it is fine.

Rob


RE: [OpenWrt-Devel] ATH10K VLAN firmware issue

2017-02-21 Thread voncken
Kalle, 

Do you know if the firmware team planned to fix the VLAN issue on ath10k
firmware?

Thanks for your help.

Cedric.
> -Message d'origine-
> De : linux-wireless-ow...@vger.kernel.org [mailto:linux-wireless-
> ow...@vger.kernel.org] De la part de Valo, Kalle
> Envoyé : mardi 15 novembre 2016 14:44
> À : Bruno Antunes
> Cc : OpenWrt Development List; linux-wireless; voncken;
> ath...@lists.infradead.org
> Objet : Re: [OpenWrt-Devel] ATH10K VLAN firmware issue
> 
> Bruno Antunes  writes:
> 
> > On 7 November 2016 at 18:06, Valo, Kalle 
> wrote:
> >> Bruno Antunes  writes:
> >>
> >>> On 4 November 2016 at 21:17, Valo, Kalle 
> wrote:
> >>>
>  Can someone file a bug to bugzilla about this so that all the info
>  is properly stored? The more comprehensive the report is the
> better.
> 
>  https://bugzilla.kernel.org/
> >>>
> >>> I will file a bug report.
> >>
> >> Thanks, it's good to store all in one place so that it's easier to
> >> find the relevant info.
> >
> > Just file the bug with the ID 187241 - VLAN support in ATH10k Feel
> > free to ask for adicional info. I did not mention any names in the
> bug
> > report fell free to take credit if wanted.
> 
> Thanks. I'll report it to the firmware team, let's see what happens. If
> there's more information which might help to fix this feel free to
> update that to the bug report.
> 
> https://bugzilla.kernel.org/show_bug.cgi?id=187241
> 
> --
> Kalle Valo



[RFC v4 15/21] ath10k: per target configurablity of various items

2017-02-21 Thread Erik Stromdahl
Added ability to set bus type and configure the max number of
peers in the ath10k_hw_params struct.

With this functionality it is possible to have a different
hw configuration depending on bus type for the same radio
chipset.

E.g. SDIO and USB devices using the same chipset as PCIe
devices will potentially use different board files and perhaps
other configuration parameters.

One such parameter is the max number of peers.
Instead of using a default value (suitable for PCIe devices)
derived from the WMI op version, a per target value can be
used instead.

This is needed by the QCA9377 USB device in order to prevent
the target fw to crash after HTT RX ring cfg is issued.

Apparently, the QCA9377 HL device does not seem to handle the
same amount of peers as the LL devices.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/core.c| 33 +++
 drivers/net/wireless/ath/ath10k/core.h|  7 ---
 drivers/net/wireless/ath/ath10k/hw.h  | 22 +
 drivers/net/wireless/ath/ath10k/wmi-tlv.c |  4 ++--
 4 files changed, 49 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 9d60f4b..6b667c7 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -1592,9 +1592,19 @@ static int ath10k_init_hw_params(struct ath10k *ar)
for (i = 0; i < ARRAY_SIZE(ath10k_hw_params_list); i++) {
hw_params = &ath10k_hw_params_list[i];
 
-   if (hw_params->id == ar->target_version &&
-   hw_params->dev_id == ar->dev_id)
-   break;
+   if (ar->is_high_latency) {
+   /* High latency devices will use different fw depending
+* on if it is a USB or SDIO device.
+*/
+   if (hw_params->bus == ar->hif.bus &&
+   hw_params->id == ar->target_version &&
+   hw_params->dev_id == ar->dev_id)
+   break;
+   } else {
+   if (hw_params->id == ar->target_version &&
+   hw_params->dev_id == ar->dev_id)
+   break;
+   }
}
 
if (i == ARRAY_SIZE(ath10k_hw_params_list)) {
@@ -1685,6 +1695,7 @@ static void ath10k_core_set_coverage_class_work(struct 
work_struct *work)
 static int ath10k_core_init_firmware_features(struct ath10k *ar)
 {
struct ath10k_fw_file *fw_file = &ar->normal_mode_fw.fw_file;
+   int max_num_peers;
 
if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, fw_file->fw_features) &&
!test_bit(ATH10K_FW_FEATURE_WMI_10X, fw_file->fw_features)) {
@@ -1764,7 +1775,7 @@ static int ath10k_core_init_firmware_features(struct 
ath10k *ar)
 
switch (fw_file->wmi_op_version) {
case ATH10K_FW_WMI_OP_VERSION_MAIN:
-   ar->max_num_peers = TARGET_NUM_PEERS;
+   max_num_peers = TARGET_NUM_PEERS;
ar->max_num_stations = TARGET_NUM_STATIONS;
ar->max_num_vdevs = TARGET_NUM_VDEVS;
ar->htt.max_num_pending_tx = TARGET_NUM_MSDU_DESC;
@@ -1776,10 +1787,10 @@ static int ath10k_core_init_firmware_features(struct 
ath10k *ar)
case ATH10K_FW_WMI_OP_VERSION_10_2:
case ATH10K_FW_WMI_OP_VERSION_10_2_4:
if (ath10k_peer_stats_enabled(ar)) {
-   ar->max_num_peers = TARGET_10X_TX_STATS_NUM_PEERS;
+   max_num_peers = TARGET_10X_TX_STATS_NUM_PEERS;
ar->max_num_stations = TARGET_10X_TX_STATS_NUM_STATIONS;
} else {
-   ar->max_num_peers = TARGET_10X_NUM_PEERS;
+   max_num_peers = TARGET_10X_NUM_PEERS;
ar->max_num_stations = TARGET_10X_NUM_STATIONS;
}
ar->max_num_vdevs = TARGET_10X_NUM_VDEVS;
@@ -1788,7 +1799,7 @@ static int ath10k_core_init_firmware_features(struct 
ath10k *ar)
ar->max_spatial_stream = WMI_MAX_SPATIAL_STREAM;
break;
case ATH10K_FW_WMI_OP_VERSION_TLV:
-   ar->max_num_peers = TARGET_TLV_NUM_PEERS;
+   max_num_peers = TARGET_TLV_NUM_PEERS;
ar->max_num_stations = TARGET_TLV_NUM_STATIONS;
ar->max_num_vdevs = TARGET_TLV_NUM_VDEVS;
ar->max_num_tdls_vdevs = TARGET_TLV_NUM_TDLS_VDEVS;
@@ -1799,7 +1810,7 @@ static int ath10k_core_init_firmware_features(struct 
ath10k *ar)
ar->max_spatial_stream = WMI_MAX_SPATIAL_STREAM;
break;
case ATH10K_FW_WMI_OP_VERSION_10_4:
-   ar->max_num_peers = TARGET_10_4_NUM_PEERS;
+   max_num_peers = TARGET_10_4_NUM_PEERS;
ar->max_num_stations = TARGET_10_4_NUM_STATIONS;
ar->num_active_peers = TA

[RFC v4 11/21] ath10k: usb support

2017-02-21 Thread Erik Stromdahl
usb HIF implementation

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/Kconfig  |6 +
 drivers/net/wireless/ath/ath10k/Makefile |3 +
 drivers/net/wireless/ath/ath10k/usb.c| 1125 ++
 drivers/net/wireless/ath/ath10k/usb.h|  128 
 4 files changed, 1262 insertions(+)
 create mode 100644 drivers/net/wireless/ath/ath10k/usb.c
 create mode 100644 drivers/net/wireless/ath/ath10k/usb.h

diff --git a/drivers/net/wireless/ath/ath10k/Kconfig 
b/drivers/net/wireless/ath/ath10k/Kconfig
index f2f6321..9a2f8cd 100644
--- a/drivers/net/wireless/ath/ath10k/Kconfig
+++ b/drivers/net/wireless/ath/ath10k/Kconfig
@@ -28,6 +28,12 @@ config ATH10K_SDIO
---help---
  This module adds support for SDIO/MMC bus
 
+config ATH10K_USB
+   tristate "Atheros ath10k USB support (EXPERIMENTAL)"
+   depends on ATH10K && USB
+   ---help---
+ This module adds support for USB bus
+
 config ATH10K_DEBUG
bool "Atheros ath10k debugging"
depends on ATH10K
diff --git a/drivers/net/wireless/ath/ath10k/Makefile 
b/drivers/net/wireless/ath/ath10k/Makefile
index b0b19a7..899b9b7 100644
--- a/drivers/net/wireless/ath/ath10k/Makefile
+++ b/drivers/net/wireless/ath/ath10k/Makefile
@@ -30,5 +30,8 @@ ath10k_pci-$(CONFIG_ATH10K_AHB) += ahb.o
 obj-$(CONFIG_ATH10K_SDIO) += ath10k_sdio.o
 ath10k_sdio-y += sdio.o
 
+obj-$(CONFIG_ATH10K_USB) += ath10k_usb.o
+ath10k_usb-y += usb.o
+
 # for tracing framework to find trace.h
 CFLAGS_trace.o := -I$(src)
diff --git a/drivers/net/wireless/ath/ath10k/usb.c 
b/drivers/net/wireless/ath/ath10k/usb.c
new file mode 100644
index 000..525706c
--- /dev/null
+++ b/drivers/net/wireless/ath/ath10k/usb.c
@@ -0,0 +1,1125 @@
+/*
+ * Copyright (c) 2007-2011 Atheros Communications Inc.
+ * Copyright (c) 2011-2012 Qualcomm Atheros, Inc.
+ * Copyright (c) 2016-2017 Erik Stromdahl 
+ *
+ * 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 "debug.h"
+#include "core.h"
+#include "bmi.h"
+#include "hif.h"
+#include "htc.h"
+#include "usb.h"
+
+static void ath10k_usb_post_recv_transfers(struct ath10k *ar,
+  struct ath10k_usb_pipe *recv_pipe);
+
+/* inlined helper functions */
+
+static inline enum ath10k_htc_ep_id
+eid_from_htc_hdr(struct ath10k_htc_hdr *htc_hdr)
+{
+   return (enum ath10k_htc_ep_id)htc_hdr->eid;
+}
+
+static inline bool is_trailer_only_msg(struct ath10k_htc_hdr *htc_hdr)
+{
+   bool trailer_only = false;
+   u16 len = __le16_to_cpu(htc_hdr->len);
+
+   if (len == htc_hdr->trailer_len)
+   trailer_only = true;
+
+   return trailer_only;
+}
+
+/* pipe/urb operations */
+static struct ath10k_urb_context *
+ath10k_usb_alloc_urb_from_pipe(struct ath10k_usb_pipe *pipe)
+{
+   struct ath10k_urb_context *urb_context = NULL;
+   unsigned long flags;
+
+   spin_lock_irqsave(&pipe->ar_usb->cs_lock, flags);
+   if (!list_empty(&pipe->urb_list_head)) {
+   urb_context =
+   list_first_entry(&pipe->urb_list_head,
+struct ath10k_urb_context, link);
+   list_del(&urb_context->link);
+   pipe->urb_cnt--;
+   }
+   spin_unlock_irqrestore(&pipe->ar_usb->cs_lock, flags);
+
+   return urb_context;
+}
+
+static void ath10k_usb_free_urb_to_pipe(struct ath10k_usb_pipe *pipe,
+   struct ath10k_urb_context *urb_context)
+{
+   unsigned long flags;
+
+   spin_lock_irqsave(&pipe->ar_usb->cs_lock, flags);
+   pipe->urb_cnt++;
+
+   list_add(&urb_context->link, &pipe->urb_list_head);
+   spin_unlock_irqrestore(&pipe->ar_usb->cs_lock, flags);
+}
+
+static void ath10k_usb_cleanup_recv_urb(struct ath10k_urb_context *urb_context)
+{
+   dev_kfree_skb(urb_context->skb);
+   urb_context->skb = NULL;
+
+   ath10k_usb_free_urb_to_pipe(urb_context->pipe, urb_context);
+}
+
+static void ath10k_usb_free_pipe_resources(struct ath10k *ar,
+  struct ath10k_usb_pipe *pipe)
+{
+   if (!pipe->ar_usb) {
+   /* nothing allocated for this pipe */
+   return;
+   }
+
+   ath10k_dbg(ar, ATH10K_DBG_USB,
+ 

[RFC v4 08/21] ath10k: sdio get target info

2017-02-21 Thread Erik Stromdahl
Special BMI get target info function for SDIO.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/bmi.c  | 70 ++
 drivers/net/wireless/ath/ath10k/bmi.h  |  2 +
 drivers/net/wireless/ath/ath10k/core.c |  5 ++-
 3 files changed, 76 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/bmi.c 
b/drivers/net/wireless/ath/ath10k/bmi.c
index abeee20..54aaa1c0 100644
--- a/drivers/net/wireless/ath/ath10k/bmi.c
+++ b/drivers/net/wireless/ath/ath10k/bmi.c
@@ -97,6 +97,76 @@ int ath10k_bmi_get_target_info(struct ath10k *ar,
return 0;
 }
 
+#define TARGET_VERSION_SENTINAL 0xu
+
+int ath10k_bmi_get_target_info_sdio(struct ath10k *ar,
+   struct bmi_target_info *target_info)
+{
+   struct bmi_cmd cmd;
+   union bmi_resp resp;
+   u32 cmdlen = sizeof(cmd.id) + sizeof(cmd.get_target_info);
+   u32 resplen, tmp, ver_len;
+   int ret;
+
+   ath10k_dbg(ar, ATH10K_DBG_BMI, "bmi get target info SDIO\n");
+
+   if (ar->bmi.done_sent) {
+   ath10k_warn(ar, "BMI Get Target Info Command disallowed\n");
+   return -EBUSY;
+   }
+
+   cmd.id = __cpu_to_le32(BMI_GET_TARGET_INFO);
+
+   /* Step 1: Read 4 bytes of the target info and check if it is
+* the special sentinal version word or the first word in the
+* version response.
+*/
+   resplen = sizeof(u32);
+   ret = ath10k_hif_exchange_bmi_msg(ar, &cmd, cmdlen, &tmp, &resplen);
+   if (ret) {
+   ath10k_warn(ar, "unable to read from device\n");
+   return ret;
+   }
+
+   /* Some SDIO boards have a special sentinal byte before the real
+* version response.
+*/
+   if (tmp == TARGET_VERSION_SENTINAL) {
+   /* Step 1b: Read the version length */
+   resplen = sizeof(u32);
+   ret = ath10k_hif_exchange_bmi_msg(ar, NULL, 0, &tmp,
+ &resplen);
+   if (ret) {
+   ath10k_warn(ar, "unable to read from device\n");
+   return ret;
+   }
+   }
+
+   ver_len = __le32_to_cpu(tmp);
+
+   /* Step 2: Check the target info length */
+   if (ver_len != sizeof(resp.get_target_info)) {
+   ath10k_warn(ar, "Unexpected target info len: %u. Expected: 
%zu\n",
+   ver_len, sizeof(resp.get_target_info));
+   return -EINVAL;
+   }
+
+   /* Step 3: Read the rest of the version response */
+   resplen = sizeof(resp.get_target_info) - sizeof(u32);
+   ret = ath10k_hif_exchange_bmi_msg(ar, NULL, 0,
+ &resp.get_target_info.version,
+ &resplen);
+   if (ret) {
+   ath10k_warn(ar, "unable to read from device\n");
+   return ret;
+   }
+
+   target_info->version = __le32_to_cpu(resp.get_target_info.version);
+   target_info->type= __le32_to_cpu(resp.get_target_info.type);
+
+   return 0;
+}
+
 int ath10k_bmi_read_memory(struct ath10k *ar,
   u32 address, void *buffer, u32 length)
 {
diff --git a/drivers/net/wireless/ath/ath10k/bmi.h 
b/drivers/net/wireless/ath/ath10k/bmi.h
index a65f262..2043d00 100644
--- a/drivers/net/wireless/ath/ath10k/bmi.h
+++ b/drivers/net/wireless/ath/ath10k/bmi.h
@@ -197,6 +197,8 @@ void ath10k_bmi_start(struct ath10k *ar);
 int ath10k_bmi_done(struct ath10k *ar);
 int ath10k_bmi_get_target_info(struct ath10k *ar,
   struct bmi_target_info *target_info);
+int ath10k_bmi_get_target_info_sdio(struct ath10k *ar,
+   struct bmi_target_info *target_info);
 int ath10k_bmi_read_memory(struct ath10k *ar, u32 address,
   void *buffer, u32 length);
 int ath10k_bmi_write_memory(struct ath10k *ar, u32 address,
diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index eae502e..a0b331d 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -2186,7 +2186,10 @@ static int ath10k_core_probe_fw(struct ath10k *ar)
}
 
memset(&target_info, 0, sizeof(target_info));
-   ret = ath10k_bmi_get_target_info(ar, &target_info);
+   if (ar->hif.bus == ATH10K_BUS_SDIO)
+   ret = ath10k_bmi_get_target_info_sdio(ar, &target_info);
+   else
+   ret = ath10k_bmi_get_target_info(ar, &target_info);
if (ret) {
ath10k_err(ar, "could not get target info (%d)\n", ret);
goto err_power_down;
-- 
2.7.4



[RFC v4 17/21] ath10k: htt: High latency TX support

2017-02-21 Thread Erik Stromdahl
Add HTT TX function for HL interfaces.
Intended for SDIO and USB.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/htt.h|  9 ++--
 drivers/net/wireless/ath/ath10k/htt_tx.c | 72 +++-
 drivers/net/wireless/ath/ath10k/mac.c|  5 ++-
 3 files changed, 80 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/htt.h 
b/drivers/net/wireless/ath/ath10k/htt.h
index bdee2e7..85ad46c 100644
--- a/drivers/net/wireless/ath/ath10k/htt.h
+++ b/drivers/net/wireless/ath/ath10k/htt.h
@@ -1822,9 +1822,12 @@ int ath10k_htt_tx_mgmt_inc_pending(struct ath10k_htt 
*htt, bool is_mgmt,
 int ath10k_htt_tx_alloc_msdu_id(struct ath10k_htt *htt, struct sk_buff *skb);
 void ath10k_htt_tx_free_msdu_id(struct ath10k_htt *htt, u16 msdu_id);
 int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu);
-int ath10k_htt_tx(struct ath10k_htt *htt,
- enum ath10k_hw_txrx_mode txmode,
- struct sk_buff *msdu);
+int ath10k_htt_tx_ll(struct ath10k_htt *htt,
+enum ath10k_hw_txrx_mode txmode,
+struct sk_buff *msdu);
+int ath10k_htt_tx_hl(struct ath10k_htt *htt,
+enum ath10k_hw_txrx_mode txmode,
+struct sk_buff *msdu);
 void ath10k_htt_rx_pktlog_completion_handler(struct ath10k *ar,
 struct sk_buff *skb);
 int ath10k_htt_txrx_compl_task(struct ath10k *ar, int budget);
diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c 
b/drivers/net/wireless/ath/ath10k/htt_tx.c
index ca899e1..a714aa8 100644
--- a/drivers/net/wireless/ath/ath10k/htt_tx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
@@ -945,8 +945,76 @@ int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct 
sk_buff *msdu)
return res;
 }
 
-int ath10k_htt_tx(struct ath10k_htt *htt, enum ath10k_hw_txrx_mode txmode,
- struct sk_buff *msdu)
+#define HTT_TX_HL_NEEDED_HEADROOM \
+   (unsigned int)(sizeof(struct htt_cmd_hdr) + \
+   sizeof(struct htt_data_tx_desc) + \
+   sizeof(struct ath10k_htc_hdr))
+
+int ath10k_htt_tx_hl(struct ath10k_htt *htt, enum ath10k_hw_txrx_mode txmode,
+struct sk_buff *msdu)
+{
+   struct ath10k *ar = htt->ar;
+   int res, data_len;
+   struct htt_cmd_hdr *cmd_hdr;
+   struct htt_data_tx_desc *tx_desc;
+   struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(msdu);
+   u8 flags0;
+   u16 flags1 = 0;
+
+   data_len = msdu->len;
+   flags0 = SM(txmode, HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE);
+
+   if (skb_cb->flags & ATH10K_SKB_F_NO_HWCRYPT)
+   flags0 |= HTT_DATA_TX_DESC_FLAGS0_NO_ENCRYPT;
+
+   if (msdu->ip_summed == CHECKSUM_PARTIAL &&
+   !test_bit(ATH10K_FLAG_RAW_MODE, &ar->dev_flags)) {
+   flags1 |= HTT_DATA_TX_DESC_FLAGS1_CKSUM_L3_OFFLOAD;
+   flags1 |= HTT_DATA_TX_DESC_FLAGS1_CKSUM_L4_OFFLOAD;
+   }
+
+   /* Prepend the HTT header and TX desc struct to the data message
+* and realloc the skb if it does not have enough headroom.
+*/
+   if (skb_headroom(msdu) < HTT_TX_HL_NEEDED_HEADROOM) {
+   struct sk_buff *tmp_skb = msdu;
+
+   ath10k_dbg(htt->ar, ATH10K_DBG_HTT,
+  "Not enough headroom in skb. Current headroom: %u, 
needed: %u. Reallocating...\n",
+  skb_headroom(msdu), HTT_TX_HL_NEEDED_HEADROOM);
+   msdu = skb_realloc_headroom(msdu, HTT_TX_HL_NEEDED_HEADROOM);
+   kfree_skb(tmp_skb);
+   if (!msdu) {
+   ath10k_warn(htt->ar, "htt hl tx: Unable to realloc 
skb!\n");
+   res = -ENOMEM;
+   goto out;
+   }
+   }
+
+   skb_push(msdu, sizeof(*cmd_hdr));
+   skb_push(msdu, sizeof(*tx_desc));
+   cmd_hdr = (struct htt_cmd_hdr *)msdu->data;
+   tx_desc = (struct htt_data_tx_desc *)(msdu->data + sizeof(*cmd_hdr));
+
+   cmd_hdr->msg_type = HTT_H2T_MSG_TYPE_TX_FRM;
+   tx_desc->flags0 = flags0;
+   tx_desc->flags1 = __cpu_to_le16(flags1);
+   tx_desc->len = __cpu_to_le16(data_len);
+   tx_desc->id = 0;
+   tx_desc->frags_paddr = 0; /* always zero */
+   /* Initialize peer_id to INVALID_PEER because this is NOT
+* Reinjection path
+*/
+   tx_desc->peerid = __cpu_to_le32(HTT_INVALID_PEERID);
+
+   res = ath10k_htc_send(&htt->ar->htc, htt->eid, msdu);
+
+out:
+   return res;
+}
+
+int ath10k_htt_tx_ll(struct ath10k_htt *htt, enum ath10k_hw_txrx_mode txmode,
+struct sk_buff *msdu)
 {
struct ath10k *ar = htt->ar;
struct device *dev = ar->dev;
diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 3029f25..6d2da19 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -3531,7 +3531,10 @@ static int ath10k_mac_tx_subm

[RFC v4 18/21] ath10k: htt: High latency RX support

2017-02-21 Thread Erik Stromdahl
Special HTT RX handling for high latency interfaces.

Since no DMA physical addresses are used in the RX ring
config message (this is not supported by the high latency
devices), no RX ring is allocated.
All RX skb's are allocated by the driver and passed directly
to mac80211 in the HTT RX indication handler.

A nice side effect of this is that no huge buffer will be
allocated with dma_alloc_coherent. On embedded systems with
limited memory resources, the allocation of the RX ring is
prone to fail.

Some tweaks made to "make it work":

Removal of protected bit in 802.11 header frame control field.
The chipset seems to do hw decryption but the frame_control
protected bit is still set.

This is necessary for mac80211 not to drop the frame.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/core.c| 38 -
 drivers/net/wireless/ath/ath10k/htt.h | 47 +++
 drivers/net/wireless/ath/ath10k/htt_rx.c  | 95 ++-
 drivers/net/wireless/ath/ath10k/rx_desc.h | 15 +
 4 files changed, 177 insertions(+), 18 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 0a177bf..2e2d3d3 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -1997,10 +1997,12 @@ int ath10k_core_start(struct ath10k *ar, enum 
ath10k_firmware_mode mode,
goto err_wmi_detach;
}
 
-   status = ath10k_htt_rx_alloc(&ar->htt);
-   if (status) {
-   ath10k_err(ar, "failed to alloc htt rx: %d\n", status);
-   goto err_htt_tx_detach;
+   if (!ar->is_high_latency) {
+   status = ath10k_htt_rx_alloc(&ar->htt);
+   if (status) {
+   ath10k_err(ar, "failed to alloc htt rx: %d\n", status);
+   goto err_htt_tx_detach;
+   }
}
 
status = ath10k_hif_start(ar);
@@ -2109,16 +2111,20 @@ int ath10k_core_start(struct ath10k *ar, enum 
ath10k_firmware_mode mode,
}
}
 
-   /* If firmware indicates Full Rx Reorder support it must be used in a
-* slightly different manner. Let HTT code know.
-*/
-   ar->htt.rx_ring.in_ord_rx = !!(test_bit(WMI_SERVICE_RX_FULL_REORDER,
-   ar->wmi.svc_map));
+   if (!ar->is_high_latency) {
+   /* If firmware indicates Full Rx Reorder support it must be
+* used in a slightly different manner. Let HTT code know.
+*/
+   ar->htt.rx_ring.in_ord_rx =
+   !!(test_bit(WMI_SERVICE_RX_FULL_REORDER,
+   ar->wmi.svc_map));
 
-   status = ath10k_htt_rx_ring_refill(ar);
-   if (status) {
-   ath10k_err(ar, "failed to refill htt rx ring: %d\n", status);
-   goto err_hif_stop;
+   status = ath10k_htt_rx_ring_refill(ar);
+   if (status) {
+   ath10k_err(ar, "failed to refill htt rx ring: %d\n",
+  status);
+   goto err_hif_stop;
+   }
}
 
if (ar->max_num_vdevs >= 64)
@@ -2147,7 +2153,8 @@ int ath10k_core_start(struct ath10k *ar, enum 
ath10k_firmware_mode mode,
 err_hif_stop:
ath10k_hif_stop(ar);
 err_htt_rx_detach:
-   ath10k_htt_rx_free(&ar->htt);
+   if (!ar->is_high_latency)
+   ath10k_htt_rx_free(&ar->htt);
 err_htt_tx_detach:
ath10k_htt_tx_free(&ar->htt);
 err_wmi_detach:
@@ -2192,7 +2199,8 @@ void ath10k_core_stop(struct ath10k *ar)
 
ath10k_hif_stop(ar);
ath10k_htt_tx_stop(&ar->htt);
-   ath10k_htt_rx_free(&ar->htt);
+   if (!ar->is_high_latency)
+   ath10k_htt_rx_free(&ar->htt);
ath10k_wmi_detach(ar);
ar->is_started = false;
 }
diff --git a/drivers/net/wireless/ath/ath10k/htt.h 
b/drivers/net/wireless/ath/ath10k/htt.h
index 85ad46c..554636d 100644
--- a/drivers/net/wireless/ath/ath10k/htt.h
+++ b/drivers/net/wireless/ath/ath10k/htt.h
@@ -645,6 +645,15 @@ struct htt_rx_indication {
struct htt_rx_indication_mpdu_range mpdu_ranges[0];
 } __packed;
 
+/* High latency version of the RX indication */
+struct htt_rx_indication_hl {
+   struct htt_rx_indication_hdr hdr;
+   struct htt_rx_indication_ppdu ppdu;
+   struct htt_rx_indication_prefix prefix;
+   struct fw_rx_desc_hl fw_desc;
+   struct htt_rx_indication_mpdu_range mpdu_ranges[0];
+} __packed;
+
 static inline struct htt_rx_indication_mpdu_range *
htt_rx_ind_get_mpdu_ranges(struct htt_rx_indication *rx_ind)
 {
@@ -657,6 +666,18 @@ static inline struct htt_rx_indication_mpdu_range *
return ptr;
 }
 
+static inline struct htt_rx_indication_mpdu_range *
+   htt_rx_ind_get_mpdu_ranges_hl(struct htt_rx_indication_hl *rx_ind)
+{
+   void *ptr = rx_ind;
+
+   ptr += sizeof(rx_in

[RFC v4 20/21] ath10k: add QCA9377 sdio hw_param item

2017-02-21 Thread Erik Stromdahl
Hardware parameters for QCA9377 sdio devices.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/core.c | 25 +
 drivers/net/wireless/ath/ath10k/hw.h   |  1 +
 2 files changed, 26 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 96b278b..a884e34 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -311,6 +311,31 @@ static const struct ath10k_hw_params 
ath10k_hw_params_list[] = {
.start_once = true,
},
{
+   .id = QCA9377_HW_1_1_DEV_VERSION,
+   .dev_id = QCA9377_1_0_DEVICE_ID,
+   .name = "qca9377 hw1.1 sdio",
+   .patch_load_addr = QCA9377_HW_1_0_PATCH_LOAD_ADDR,
+   .uart_pin = 19,
+   .otp_exe_param = 0,
+   .channel_counters_freq_hz = 88000,
+   .max_probe_resp_desc_thres = 0,
+   .cal_data_len = 8124,
+   .fw = {
+   .dir = QCA9377_HW_1_0_FW_DIR,
+   .board = QCA9377_HW_1_0_BOARD_DATA_FILE_SDIO,
+   .board_size = QCA9377_BOARD_DATA_SZ,
+   .board_ext_size = QCA9377_BOARD_EXT_DATA_SZ,
+   },
+   .hw_ops = &qca6174_ops,
+   .hw_clk = qca6174_clk,
+   .target_cpu_freq = 17600,
+   .decap_align_bytes = 4,
+   .max_num_peers = TARGET_QCA9377_HL_NUM_PEERS,
+   .is_high_latency = true,
+   .bus = ATH10K_BUS_SDIO,
+   .start_once = true,
+   },
+   {
.id = QCA4019_HW_1_0_DEV_VERSION,
.dev_id = 0,
.name = "qca4019 hw1.0",
diff --git a/drivers/net/wireless/ath/ath10k/hw.h 
b/drivers/net/wireless/ath/ath10k/hw.h
index 5408ebc..d76b206 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -128,6 +128,7 @@ enum qca9377_chip_id_rev {
 #define QCA9377_HW_1_0_FW_DIR  ATH10K_FW_DIR "/QCA9377/hw1.0"
 #define QCA9377_HW_1_0_BOARD_DATA_FILE "board.bin"
 #define QCA9377_HW_1_0_BOARD_DATA_FILE_USB "board-usb.bin"
+#define QCA9377_HW_1_0_BOARD_DATA_FILE_SDIO "board-sdio.bin"
 #define QCA9377_HW_1_0_PATCH_LOAD_ADDR 0x1234
 
 /* QCA4019 1.0 definitions */
-- 
2.7.4



[RFC v4 07/21] ath10k: add sdio extra initializations

2017-02-21 Thread Erik Stromdahl
Extra initializations needed by all sdio boards.
Derived from qcacld.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/core.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 83ab651..eae502e 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -377,6 +377,27 @@ static void ath10k_send_suspend_complete(struct ath10k *ar)
complete(&ar->target_suspend);
 }
 
+static void ath10k_sdio_extra_initialization(struct ath10k *ar)
+{
+   u32 param = 0;
+
+   /* Turn on fwlog.
+*/
+   ath10k_bmi_read32(ar, hi_option_flag, ¶m);
+   param &= ~(HI_OPTION_DISABLE_DBGLOG);
+   ath10k_bmi_write32(ar, hi_option_flag, param);
+
+   ath10k_bmi_write32(ar, hi_mbox_io_block_sz, 256);
+   ath10k_bmi_write32(ar, hi_mbox_isr_yield_limit, 99);
+   ath10k_bmi_read32(ar, hi_acs_flags, ¶m);
+
+   param |= (HI_ACS_FLAGS_SDIO_SWAP_MAILBOX_SET |
+ HI_ACS_FLAGS_SDIO_REDUCE_TX_COMPL_SET |
+ HI_ACS_FLAGS_ALT_DATA_CREDIT_SIZE);
+
+   ath10k_bmi_write32(ar, hi_acs_flags, param);
+}
+
 static int ath10k_init_configure_target(struct ath10k *ar)
 {
u32 param_host;
@@ -1916,6 +1937,9 @@ int ath10k_core_start(struct ath10k *ar, enum 
ath10k_firmware_mode mode,
if (status)
goto err;
 
+   if (ar->hif.bus == ATH10K_BUS_SDIO)
+   ath10k_sdio_extra_initialization(ar);
+
ar->htc.htc_ops.target_send_suspend_complete =
ath10k_send_suspend_complete;
 
-- 
2.7.4



[RFC v4 10/21] ath10k: various usb related definitions

2017-02-21 Thread Erik Stromdahl
Definitions for USB based chipsets

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/core.h  | 3 +++
 drivers/net/wireless/ath/ath10k/debug.h | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index 5965d18..2768b07 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -92,6 +92,7 @@ enum ath10k_bus {
ATH10K_BUS_PCI,
ATH10K_BUS_AHB,
ATH10K_BUS_SDIO,
+   ATH10K_BUS_USB,
 };
 
 static inline const char *ath10k_bus_str(enum ath10k_bus bus)
@@ -103,6 +104,8 @@ static inline const char *ath10k_bus_str(enum ath10k_bus 
bus)
return "ahb";
case ATH10K_BUS_SDIO:
return "sdio";
+   case ATH10K_BUS_USB:
+   return "usb";
}
 
return "unknown";
diff --git a/drivers/net/wireless/ath/ath10k/debug.h 
b/drivers/net/wireless/ath/ath10k/debug.h
index 257d109..548ad54 100644
--- a/drivers/net/wireless/ath/ath10k/debug.h
+++ b/drivers/net/wireless/ath/ath10k/debug.h
@@ -40,6 +40,8 @@ enum ath10k_debug_mask {
ATH10K_DBG_AHB  = 0x8000,
ATH10K_DBG_SDIO = 0x0001,
ATH10K_DBG_SDIO_DUMP= 0x0002,
+   ATH10K_DBG_USB  = 0x0004,
+   ATH10K_DBG_USB_BULK = 0x0008,
ATH10K_DBG_ANY  = 0x,
 };
 
-- 
2.7.4



[RFC v4 21/21] ath10k: dma fixes for high latency devices

2017-02-21 Thread Erik Stromdahl
Several DMA related functions (such as the dma_map_xxx functions)
are not used with high latency devices and don't need to be invoked
in this case.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/htc.c| 13 -
 drivers/net/wireless/ath/ath10k/htt_rx.c |  3 ++-
 drivers/net/wireless/ath/ath10k/htt_tx.c |  3 +++
 drivers/net/wireless/ath/ath10k/txrx.c   |  5 +++--
 4 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/htc.c 
b/drivers/net/wireless/ath/ath10k/htc.c
index 3eaa9a8..b5fddd7 100644
--- a/drivers/net/wireless/ath/ath10k/htc.c
+++ b/drivers/net/wireless/ath/ath10k/htc.c
@@ -134,11 +134,14 @@ int ath10k_htc_send(struct ath10k_htc *htc,
ath10k_htc_prepare_tx_skb(ep, skb);
 
skb_cb->eid = eid;
-   skb_cb->paddr = dma_map_single(dev, skb->data, skb->len, DMA_TO_DEVICE);
-   ret = dma_mapping_error(dev, skb_cb->paddr);
-   if (ret) {
-   ret = -EIO;
-   goto err_credits;
+   if (!ar->is_high_latency) {
+   skb_cb->paddr = dma_map_single(dev, skb->data, skb->len,
+  DMA_TO_DEVICE);
+   ret = dma_mapping_error(dev, skb_cb->paddr);
+   if (ret) {
+   ret = -EIO;
+   goto err_credits;
+   }
}
 
sg_item.transfer_id = ep->eid;
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c 
b/drivers/net/wireless/ath/ath10k/htt_rx.c
index c90570f..96e73b4 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -2485,7 +2485,8 @@ bool ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct 
sk_buff *skb)
break;
}
case HTT_T2H_MSG_TYPE_TX_COMPL_IND:
-   ath10k_htt_rx_tx_compl_ind(htt->ar, skb);
+   if (!ar->is_high_latency)
+   ath10k_htt_rx_tx_compl_ind(htt->ar, skb);
break;
case HTT_T2H_MSG_TYPE_SEC_IND: {
struct ath10k *ar = htt->ar;
diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c 
b/drivers/net/wireless/ath/ath10k/htt_tx.c
index a714aa8..190d002 100644
--- a/drivers/net/wireless/ath/ath10k/htt_tx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
@@ -409,6 +409,9 @@ int ath10k_htt_tx_start(struct ath10k_htt *htt)
if (htt->tx_mem_allocated)
return 0;
 
+   if (ar->is_high_latency)
+   return 0;
+
ret = ath10k_htt_tx_alloc_buf(htt);
if (ret)
goto free_idr_pending_tx;
diff --git a/drivers/net/wireless/ath/ath10k/txrx.c 
b/drivers/net/wireless/ath/ath10k/txrx.c
index 9852c5d..5e27f6da 100644
--- a/drivers/net/wireless/ath/ath10k/txrx.c
+++ b/drivers/net/wireless/ath/ath10k/txrx.c
@@ -89,11 +89,12 @@ int ath10k_txrx_tx_unref(struct ath10k_htt *htt,
 
ath10k_htt_tx_free_msdu_id(htt, tx_done->msdu_id);
ath10k_htt_tx_dec_pending(htt);
-   if (htt->num_pending_tx == 0)
+   if (!ar->is_high_latency && (htt->num_pending_tx == 0))
wake_up(&htt->empty_tx_wq);
spin_unlock_bh(&htt->tx_lock);
 
-   dma_unmap_single(dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
+   if (!ar->is_high_latency)
+   dma_unmap_single(dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
 
ath10k_report_offchan_tx(htt->ar, msdu);
 
-- 
2.7.4



[RFC v4 12/21] ath10k: high_latency detection

2017-02-21 Thread Erik Stromdahl
The setup of high latency chips (USB and SDIO) is
sometimes different than for chips using low latency
interfaces.

The bus type is used to determine if the interface is
a high latency interface.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/core.c | 1 +
 drivers/net/wireless/ath/ath10k/core.h | 7 +++
 2 files changed, 8 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index a0b331d..39c407e 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -2400,6 +2400,7 @@ struct ath10k *ath10k_core_create(size_t priv_size, 
struct device *dev,
ar->hw_rev = hw_rev;
ar->hif.ops = hif_ops;
ar->hif.bus = bus;
+   ar->is_high_latency = ath10k_is_high_latency(bus);
 
switch (hw_rev) {
case ATH10K_HW_QCA988X:
diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index 2768b07..0c970fe 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -785,6 +785,8 @@ struct ath10k {
 
bool p2p;
 
+   bool is_high_latency;
+
struct {
enum ath10k_bus bus;
const struct ath10k_hif_ops *ops;
@@ -1003,6 +1005,11 @@ static inline bool ath10k_peer_stats_enabled(struct 
ath10k *ar)
return false;
 }
 
+static inline bool ath10k_is_high_latency(enum ath10k_bus bus)
+{
+   return ((bus == ATH10K_BUS_SDIO) || (bus == ATH10K_BUS_USB));
+}
+
 struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
  enum ath10k_bus bus,
  enum ath10k_hw_rev hw_rev,
-- 
2.7.4



[RFC v4 13/21] ath10k: different fw file names for usb and sdio

2017-02-21 Thread Erik Stromdahl
Since both SDIO and USB based chipsets will use different
firmware from the PCIe and AHB chipsets, the fw file name
must be different depending on bus type.

The new firmware names are:

For PCIe and AHB:
firmware-.bin (same as before)

For SDIO:
firmware-sdio-.bin

For USB:
firmware-usb-.bin

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/core.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 39c407e..9d60f4b 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -1387,7 +1387,13 @@ int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, 
const char *name,
 static void ath10k_core_get_fw_name(struct ath10k *ar, char *fw_name,
size_t fw_name_len, int fw_api)
 {
-   scnprintf(fw_name, fw_name_len, "%s-%d.bin", ATH10K_FW_FILE_BASE, 
fw_api);
+   if ((ar->hif.bus != ATH10K_BUS_PCI) && (ar->hif.bus != ATH10K_BUS_AHB))
+   scnprintf(fw_name, fw_name_len, "%s-%s-%d.bin",
+ ATH10K_FW_FILE_BASE, ath10k_bus_str(ar->hif.bus),
+ fw_api);
+   else
+   scnprintf(fw_name, fw_name_len, "%s-%d.bin",
+ ATH10K_FW_FILE_BASE, fw_api);
 }
 
 static int ath10k_core_fetch_firmware_files(struct ath10k *ar)
-- 
2.7.4



[RFC v4 19/21] ath10k: add QCA9377 usb hw_param item

2017-02-21 Thread Erik Stromdahl
Hardware parameters for QCA9377 usb devices.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/core.c | 23 +++
 drivers/net/wireless/ath/ath10k/hw.h   |  1 +
 2 files changed, 24 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 2e2d3d3..96b278b 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -288,6 +288,29 @@ static const struct ath10k_hw_params 
ath10k_hw_params_list[] = {
.decap_align_bytes = 4,
},
{
+   .id = QCA9377_HW_1_1_DEV_VERSION,
+   .dev_id = QCA9377_1_0_DEVICE_ID,
+   .name = "qca9377 hw1.1 usb",
+   .patch_load_addr = QCA9377_HW_1_0_PATCH_LOAD_ADDR,
+   .uart_pin = 6,
+   .otp_exe_param = 0,
+   .channel_counters_freq_hz = 88000,
+   .max_probe_resp_desc_thres = 0,
+   .cal_data_len = 8124,
+   .fw = {
+   .dir = QCA9377_HW_1_0_FW_DIR,
+   .board = QCA9377_HW_1_0_BOARD_DATA_FILE_USB,
+   .board_size = QCA9377_BOARD_DATA_SZ,
+   .board_ext_size = QCA9377_BOARD_EXT_DATA_SZ,
+   },
+   .hw_ops = &qca988x_ops,
+   .decap_align_bytes = 4,
+   .max_num_peers = TARGET_QCA9377_HL_NUM_PEERS,
+   .is_high_latency = true,
+   .bus = ATH10K_BUS_USB,
+   .start_once = true,
+   },
+   {
.id = QCA4019_HW_1_0_DEV_VERSION,
.dev_id = 0,
.name = "qca4019 hw1.0",
diff --git a/drivers/net/wireless/ath/ath10k/hw.h 
b/drivers/net/wireless/ath/ath10k/hw.h
index cf88aba..5408ebc 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -127,6 +127,7 @@ enum qca9377_chip_id_rev {
 /* QCA9377 1.0 definitions */
 #define QCA9377_HW_1_0_FW_DIR  ATH10K_FW_DIR "/QCA9377/hw1.0"
 #define QCA9377_HW_1_0_BOARD_DATA_FILE "board.bin"
+#define QCA9377_HW_1_0_BOARD_DATA_FILE_USB "board-usb.bin"
 #define QCA9377_HW_1_0_PATCH_LOAD_ADDR 0x1234
 
 /* QCA4019 1.0 definitions */
-- 
2.7.4



[RFC v4 06/21] ath10k: sdio support

2017-02-21 Thread Erik Stromdahl
sdio/mailbox HIF implementation.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/Kconfig  |6 +
 drivers/net/wireless/ath/ath10k/Makefile |3 +
 drivers/net/wireless/ath/ath10k/sdio.c   | 2138 ++
 drivers/net/wireless/ath/ath10k/sdio.h   |  263 
 4 files changed, 2410 insertions(+)
 create mode 100644 drivers/net/wireless/ath/ath10k/sdio.c
 create mode 100644 drivers/net/wireless/ath/ath10k/sdio.h

diff --git a/drivers/net/wireless/ath/ath10k/Kconfig 
b/drivers/net/wireless/ath/ath10k/Kconfig
index b4241cf..f2f6321 100644
--- a/drivers/net/wireless/ath/ath10k/Kconfig
+++ b/drivers/net/wireless/ath/ath10k/Kconfig
@@ -22,6 +22,12 @@ config ATH10K_AHB
---help---
  This module adds support for AHB bus
 
+config ATH10K_SDIO
+   tristate "Atheros ath10k SDIO support (EXPERIMENTAL)"
+   depends on ATH10K && MMC
+   ---help---
+ This module adds support for SDIO/MMC bus
+
 config ATH10K_DEBUG
bool "Atheros ath10k debugging"
depends on ATH10K
diff --git a/drivers/net/wireless/ath/ath10k/Makefile 
b/drivers/net/wireless/ath/ath10k/Makefile
index 930fadd..b0b19a7 100644
--- a/drivers/net/wireless/ath/ath10k/Makefile
+++ b/drivers/net/wireless/ath/ath10k/Makefile
@@ -27,5 +27,8 @@ ath10k_pci-y += pci.o \
 
 ath10k_pci-$(CONFIG_ATH10K_AHB) += ahb.o
 
+obj-$(CONFIG_ATH10K_SDIO) += ath10k_sdio.o
+ath10k_sdio-y += sdio.o
+
 # for tracing framework to find trace.h
 CFLAGS_trace.o := -I$(src)
diff --git a/drivers/net/wireless/ath/ath10k/sdio.c 
b/drivers/net/wireless/ath/ath10k/sdio.c
new file mode 100644
index 000..06379da
--- /dev/null
+++ b/drivers/net/wireless/ath/ath10k/sdio.c
@@ -0,0 +1,2138 @@
+/*
+ * Copyright (c) 2004-2011 Atheros Communications Inc.
+ * Copyright (c) 2011-2012 Qualcomm Atheros, Inc.
+ * Copyright (c) 2016-2017 Erik Stromdahl 
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "core.h"
+#include "bmi.h"
+#include "debug.h"
+#include "hif.h"
+#include "htc.h"
+#include "targaddrs.h"
+#include "trace.h"
+#include "sdio.h"
+
+/* inlined helper functions */
+
+static inline int ath10k_sdio_calc_txrx_padded_len(struct ath10k_sdio *ar_sdio,
+  size_t len)
+{
+   return __ALIGN_MASK((len), ar_sdio->mbox_info.block_mask);
+}
+
+static inline enum ath10k_htc_ep_id pipe_id_to_eid(u8 pipe_id)
+{
+   return (enum ath10k_htc_ep_id)pipe_id;
+}
+
+static inline void ath10k_sdio_mbox_free_rx_pkt(struct ath10k_sdio_rx_data 
*pkt)
+{
+   dev_kfree_skb(pkt->skb);
+   pkt->skb = NULL;
+   pkt->alloc_len = 0;
+   pkt->act_len = 0;
+   pkt->trailer_only = false;
+}
+
+static inline int ath10k_sdio_mbox_alloc_rx_pkt(struct ath10k_sdio_rx_data 
*pkt,
+   size_t act_len, size_t full_len,
+   bool part_of_bundle,
+   bool last_in_bundle)
+{
+   pkt->skb = dev_alloc_skb(full_len);
+   if (!pkt->skb)
+   return -ENOMEM;
+
+   pkt->act_len = act_len;
+   pkt->alloc_len = full_len;
+   pkt->part_of_bundle = part_of_bundle;
+   pkt->last_in_bundle = last_in_bundle;
+   pkt->trailer_only = false;
+
+   return 0;
+}
+
+static inline bool is_trailer_only_msg(struct ath10k_sdio_rx_data *pkt)
+{
+   bool trailer_only = false;
+   struct ath10k_htc_hdr *htc_hdr =
+   (struct ath10k_htc_hdr *)pkt->skb->data;
+   u16 len = __le16_to_cpu(htc_hdr->len);
+
+   if (len == htc_hdr->trailer_len)
+   trailer_only = true;
+
+   return trailer_only;
+}
+
+/* sdio/mmc functions */
+
+static inline void ath10k_sdio_set_cmd52_arg(u32 *arg, u8 write, u8 raw,
+unsigned int address,
+unsigned char val)
+{
+   *arg = FIELD_PREP(BIT(31), write) |
+  FIELD_PREP(BIT(27), raw) |
+  FIELD_PREP(BIT(26), 1) |
+  FIELD_PREP(GENMASK(25, 9), address) |
+  FIELD_PREP(BIT(8), 1) |
+  FIELD_PREP(GENMASK(7, 0), val);
+}

[RFC v4 14/21] ath10k: htt: RX ring config HL support

2017-02-21 Thread Erik Stromdahl
Special HTT RX ring config message used by high latency
devices.

The main difference between HL and LL is that HL devices
do not use shared memory between device and host and thus,
no host paddr's are added to the RX config message.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/htt.c|  5 +++-
 drivers/net/wireless/ath/ath10k/htt.h|  1 +
 drivers/net/wireless/ath/ath10k/htt_tx.c | 51 
 3 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/htt.c 
b/drivers/net/wireless/ath/ath10k/htt.c
index cd160b1..29ed4af 100644
--- a/drivers/net/wireless/ath/ath10k/htt.c
+++ b/drivers/net/wireless/ath/ath10k/htt.c
@@ -258,7 +258,10 @@ int ath10k_htt_setup(struct ath10k_htt *htt)
if (status)
return status;
 
-   status = ath10k_htt_send_rx_ring_cfg_ll(htt);
+   if (ar->is_high_latency)
+   status = ath10k_htt_send_rx_ring_cfg_hl(htt);
+   else
+   status = ath10k_htt_send_rx_ring_cfg_ll(htt);
if (status) {
ath10k_warn(ar, "failed to setup rx ring: %d\n",
status);
diff --git a/drivers/net/wireless/ath/ath10k/htt.h 
b/drivers/net/wireless/ath/ath10k/htt.h
index 90c2f72..bdee2e7 100644
--- a/drivers/net/wireless/ath/ath10k/htt.h
+++ b/drivers/net/wireless/ath/ath10k/htt.h
@@ -1797,6 +1797,7 @@ int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt);
 int ath10k_htt_h2t_stats_req(struct ath10k_htt *htt, u8 mask, u64 cookie);
 int ath10k_htt_send_frag_desc_bank_cfg(struct ath10k_htt *htt);
 int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt);
+int ath10k_htt_send_rx_ring_cfg_hl(struct ath10k_htt *htt);
 int ath10k_htt_h2t_aggr_cfg_msg(struct ath10k_htt *htt,
u8 max_subfrms_ampdu,
u8 max_subfrms_amsdu);
diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c 
b/drivers/net/wireless/ath/ath10k/htt_tx.c
index 86b427f..ca899e1 100644
--- a/drivers/net/wireless/ath/ath10k/htt_tx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
@@ -692,6 +692,57 @@ int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt)
return 0;
 }
 
+int ath10k_htt_send_rx_ring_cfg_hl(struct ath10k_htt *htt)
+{
+   struct ath10k *ar = htt->ar;
+   struct sk_buff *skb;
+   struct htt_cmd *cmd;
+   struct htt_rx_ring_setup_ring *ring;
+   const int num_rx_ring = 1;
+   u16 flags;
+   int len;
+   int ret;
+
+   /*
+* the HW expects the buffer to be an integral number of 4-byte
+* "words"
+*/
+   BUILD_BUG_ON(!IS_ALIGNED(HTT_RX_BUF_SIZE, 4));
+   BUILD_BUG_ON((HTT_RX_BUF_SIZE & HTT_MAX_CACHE_LINE_SIZE_MASK) != 0);
+
+   len = sizeof(cmd->hdr) + sizeof(cmd->rx_setup.hdr)
+   + (sizeof(*ring) * num_rx_ring);
+   skb = ath10k_htc_alloc_skb(ar, len);
+   if (!skb)
+   return -ENOMEM;
+
+   skb_put(skb, len);
+
+   cmd = (struct htt_cmd *)skb->data;
+   ring = &cmd->rx_setup.rings[0];
+
+   cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_RX_RING_CFG;
+   cmd->rx_setup.hdr.num_rings = 1;
+
+   flags = 0;
+   flags |= HTT_RX_RING_FLAGS_MSDU_PAYLOAD;
+   flags |= HTT_RX_RING_FLAGS_UNICAST_RX;
+   flags |= HTT_RX_RING_FLAGS_MULTICAST_RX;
+
+   memset(ring, 0, sizeof(*ring));
+   ring->rx_ring_len = __cpu_to_le16(HTT_RX_RING_SIZE_MIN);
+   ring->rx_ring_bufsize = __cpu_to_le16(HTT_RX_BUF_SIZE);
+   ring->flags = __cpu_to_le16(flags);
+
+   ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb);
+   if (ret) {
+   dev_kfree_skb_any(skb);
+   return ret;
+   }
+
+   return 0;
+}
+
 int ath10k_htt_h2t_aggr_cfg_msg(struct ath10k_htt *htt,
u8 max_subfrms_ampdu,
u8 max_subfrms_amsdu)
-- 
2.7.4



[RFC v4 05/21] ath10k: various sdio related definitions

2017-02-21 Thread Erik Stromdahl
Debug masks for SDIO HIF layer.
Address definitions for SDIO/mbox based chipsets.
Augmented struct host_interest with more members.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/core.h  |  3 ++
 drivers/net/wireless/ath/ath10k/debug.h |  2 ++
 drivers/net/wireless/ath/ath10k/hw.h| 53 +
 drivers/net/wireless/ath/ath10k/targaddrs.h | 24 +
 4 files changed, 82 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index 88d14be..5965d18 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -91,6 +91,7 @@ struct ath10k;
 enum ath10k_bus {
ATH10K_BUS_PCI,
ATH10K_BUS_AHB,
+   ATH10K_BUS_SDIO,
 };
 
 static inline const char *ath10k_bus_str(enum ath10k_bus bus)
@@ -100,6 +101,8 @@ static inline const char *ath10k_bus_str(enum ath10k_bus 
bus)
return "pci";
case ATH10K_BUS_AHB:
return "ahb";
+   case ATH10K_BUS_SDIO:
+   return "sdio";
}
 
return "unknown";
diff --git a/drivers/net/wireless/ath/ath10k/debug.h 
b/drivers/net/wireless/ath/ath10k/debug.h
index 2368f47..257d109 100644
--- a/drivers/net/wireless/ath/ath10k/debug.h
+++ b/drivers/net/wireless/ath/ath10k/debug.h
@@ -38,6 +38,8 @@ enum ath10k_debug_mask {
ATH10K_DBG_WMI_PRINT= 0x2000,
ATH10K_DBG_PCI_PS   = 0x4000,
ATH10K_DBG_AHB  = 0x8000,
+   ATH10K_DBG_SDIO = 0x0001,
+   ATH10K_DBG_SDIO_DUMP= 0x0002,
ATH10K_DBG_ANY  = 0x,
 };
 
diff --git a/drivers/net/wireless/ath/ath10k/hw.h 
b/drivers/net/wireless/ath/ath10k/hw.h
index d370b57..4055144 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -856,6 +856,59 @@ ath10k_rx_desc_get_l3_pad_bytes(struct ath10k_hw_params 
*hw,
 #define QCA9887_EEPROM_ADDR_LO_MASK0x00ff
 #define QCA9887_EEPROM_ADDR_LO_LSB 16
 
+#define MBOX_RESET_CONTROL_ADDRESS 0x
+#define MBOX_HOST_INT_STATUS_ADDRESS   0x0800
+#define MBOX_HOST_INT_STATUS_ERROR_LSB 7
+#define MBOX_HOST_INT_STATUS_ERROR_MASK0x0080
+#define MBOX_HOST_INT_STATUS_CPU_LSB   6
+#define MBOX_HOST_INT_STATUS_CPU_MASK  0x0040
+#define MBOX_HOST_INT_STATUS_COUNTER_LSB   4
+#define MBOX_HOST_INT_STATUS_COUNTER_MASK  0x0010
+#define MBOX_CPU_INT_STATUS_ADDRESS0x0801
+#define MBOX_ERROR_INT_STATUS_ADDRESS  0x0802
+#define MBOX_ERROR_INT_STATUS_WAKEUP_LSB   2
+#define MBOX_ERROR_INT_STATUS_WAKEUP_MASK  0x0004
+#define MBOX_ERROR_INT_STATUS_RX_UNDERFLOW_LSB 1
+#define MBOX_ERROR_INT_STATUS_RX_UNDERFLOW_MASK0x0002
+#define MBOX_ERROR_INT_STATUS_TX_OVERFLOW_LSB  0
+#define MBOX_ERROR_INT_STATUS_TX_OVERFLOW_MASK 0x0001
+#define MBOX_COUNTER_INT_STATUS_ADDRESS0x0803
+#define MBOX_COUNTER_INT_STATUS_COUNTER_LSB0
+#define MBOX_COUNTER_INT_STATUS_COUNTER_MASK   0x00ff
+#define MBOX_RX_LOOKAHEAD_VALID_ADDRESS0x0805
+#define MBOX_INT_STATUS_ENABLE_ADDRESS 0x0828
+#define MBOX_INT_STATUS_ENABLE_ERROR_LSB   7
+#define MBOX_INT_STATUS_ENABLE_ERROR_MASK  0x0080
+#define MBOX_INT_STATUS_ENABLE_CPU_LSB 6
+#define MBOX_INT_STATUS_ENABLE_CPU_MASK0x0040
+#define MBOX_INT_STATUS_ENABLE_INT_LSB 5
+#define MBOX_INT_STATUS_ENABLE_INT_MASK0x0020
+#define MBOX_INT_STATUS_ENABLE_COUNTER_LSB 4
+#define MBOX_INT_STATUS_ENABLE_COUNTER_MASK0x0010
+#define MBOX_INT_STATUS_ENABLE_MBOX_DATA_LSB   0
+#define MBOX_INT_STATUS_ENABLE_MBOX_DATA_MASK  0x000f
+#define MBOX_CPU_INT_STATUS_ENABLE_ADDRESS 0x0819
+#define MBOX_CPU_INT_STATUS_ENABLE_BIT_LSB 0
+#define MBOX_CPU_INT_STATUS_ENABLE_BIT_MASK0x00ff
+#define MBOX_ERROR_STATUS_ENABLE_ADDRESS   0x081a
+#define MBOX_ERROR_STATUS_ENABLE_RX_UNDERFLOW_LSB  1
+#define MBOX_ERROR_STATUS_ENABLE_RX_UNDERFLOW_MASK 0x0002
+#define MBOX_ERROR_STATUS_ENABLE_TX_OVERFLOW_LSB   0
+#define MBOX_ERROR_STATUS_ENABLE_TX_OVERFLOW_MASK  0x0001
+#define MBOX_COUNTER_INT_STATUS_ENABLE_ADDRESS 0x081b
+#define MBOX_COUNTER_INT_STATUS_ENABLE_BIT_LSB 0
+#define MBOX_COUNTER_INT_STATUS_ENABLE_BIT_MASK0x00ff
+#define MBOX_COUNT_ADDRESS 0x0820
+#define MBOX_COUNT_DEC_ADDRESS 0x0840
+#define MBOX_WINDOW_DATA_ADDRESS   0x0874
+#define MBOX_WINDOW_WRITE_ADDR_ADDRESS 0x0878
+#define MBOX_WINDOW_READ_ADDR_ADDRESS  0x087c
+#define MBOX_CPU_DBG_SEL_ADDRESS   0x0883
+#define MBOX_CPU_DBG_ADDRESS   0x0884
+#define MBOX_RTC_BASE_ADDRESS  0x
+#define MBOX_GPIO_BASE_ADDRESS 

[RFC v4 16/21] ath10k: add start_once support

2017-02-21 Thread Erik Stromdahl
Add possibility to configure the driver to only start target once.
This can reduce startup time of SDIO devices significantly since
loading the firmware can take a substantial amount of time.

The patch is also necessary for high latency devices in general
since it does not seem to be possible to rerun the BMI phase
(fw upload) without power-cycling the device.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/core.c | 19 +++
 drivers/net/wireless/ath/ath10k/core.h |  2 ++
 drivers/net/wireless/ath/ath10k/hw.h   |  6 ++
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 6b667c7..0a177bf 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -1919,6 +1919,9 @@ int ath10k_core_start(struct ath10k *ar, enum 
ath10k_firmware_mode mode,
int status;
u32 val;
 
+   if (ar->is_started && ar->hw_params.start_once)
+   return 0;
+
lockdep_assert_held(&ar->conf_mutex);
 
clear_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags);
@@ -2138,6 +2141,7 @@ int ath10k_core_start(struct ath10k *ar, enum 
ath10k_firmware_mode mode,
if (status)
goto err_hif_stop;
 
+   ar->is_started = true;
return 0;
 
 err_hif_stop:
@@ -2190,6 +2194,7 @@ void ath10k_core_stop(struct ath10k *ar)
ath10k_htt_tx_stop(&ar->htt);
ath10k_htt_rx_free(&ar->htt);
ath10k_wmi_detach(ar);
+   ar->is_started = false;
 }
 EXPORT_SYMBOL(ath10k_core_stop);
 
@@ -2291,12 +2296,18 @@ static int ath10k_core_probe_fw(struct ath10k *ar)
goto err_unlock;
}
 
-   ath10k_debug_print_boot_info(ar);
-   ath10k_core_stop(ar);
+   /* Leave target running if hw_params.start_once is set */
+   if (ar->hw_params.start_once) {
+   mutex_unlock(&ar->conf_mutex);
+   } else {
+   ath10k_debug_print_boot_info(ar);
+   ath10k_core_stop(ar);
 
-   mutex_unlock(&ar->conf_mutex);
+   mutex_unlock(&ar->conf_mutex);
+
+   ath10k_hif_power_down(ar);
+   }
 
-   ath10k_hif_power_down(ar);
return 0;
 
 err_unlock:
diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index e3cdaba..6be6e66 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -780,6 +780,8 @@ struct ath10k {
 
bool is_high_latency;
 
+   bool is_started;
+
struct {
enum ath10k_bus bus;
const struct ath10k_hif_ops *ops;
diff --git a/drivers/net/wireless/ath/ath10k/hw.h 
b/drivers/net/wireless/ath/ath10k/hw.h
index bc4fd43..cf88aba 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -466,6 +466,12 @@ struct ath10k_hw_params {
bool is_high_latency;
 
enum ath10k_bus bus;
+
+   /* Specifies whether or not the device should be started once.
+* If set, the device will be started once by the early fw probe
+* and it will not be terminated afterwards.
+*/
+   bool start_once;
 };
 
 struct htt_rx_desc;
-- 
2.7.4



[RFC v4 09/21] ath10k: htc: ready_ext msg support

2017-02-21 Thread Erik Stromdahl
Added support for extended ready message.
The extended ready message contains the maximum bundle
count supported by SDIO chipsets.

It is transmitted by SDIO chipset only and replaces the
"standard" ready message in this case.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/htc.c | 28 ++--
 drivers/net/wireless/ath/ath10k/htc.h |  5 +
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/htc.c 
b/drivers/net/wireless/ath/ath10k/htc.c
index eb036b3..3eaa9a8 100644
--- a/drivers/net/wireless/ath/ath10k/htc.c
+++ b/drivers/net/wireless/ath/ath10k/htc.c
@@ -581,8 +581,6 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc)
unsigned long time_left;
struct ath10k_htc_msg *msg;
u16 message_id;
-   u16 credit_count;
-   u16 credit_size;
 
time_left = wait_for_completion_timeout(&htc->ctl_resp,
ATH10K_HTC_WAIT_TIMEOUT_HZ);
@@ -619,16 +617,14 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc)
 
msg = (struct ath10k_htc_msg *)htc->control_resp_buffer;
message_id   = __le16_to_cpu(msg->hdr.message_id);
-   credit_count = __le16_to_cpu(msg->ready.credit_count);
-   credit_size  = __le16_to_cpu(msg->ready.credit_size);
 
if (message_id != ATH10K_HTC_MSG_READY_ID) {
ath10k_err(ar, "Invalid HTC ready msg: 0x%x\n", message_id);
return -ECOMM;
}
 
-   htc->total_transmit_credits = credit_count;
-   htc->target_credit_size = credit_size;
+   htc->total_transmit_credits = __le16_to_cpu(msg->ready.credit_count);
+   htc->target_credit_size = __le16_to_cpu(msg->ready.credit_size);
 
ath10k_dbg(ar, ATH10K_DBG_HTC,
   "Target ready! transmit resources: %d size:%d\n",
@@ -641,6 +637,19 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc)
return -ECOMM;
}
 
+   /* The only way to determine if the ready message is an extended
+* message is from the size.
+*/
+   if (htc->control_resp_len >=
+   sizeof(msg->hdr) + sizeof(msg->ready_ext)) {
+   htc->max_msgs_per_htc_bundle =
+   min_t(u8, msg->ready_ext.max_msgs_per_htc_bundle,
+ HTC_HOST_MAX_MSG_PER_BUNDLE);
+   ath10k_dbg(ar, ATH10K_DBG_HTC,
+  "Extended ready message. RX bundle size: %d\n",
+  htc->max_msgs_per_htc_bundle);
+   }
+
return 0;
 }
 
@@ -836,6 +845,13 @@ int ath10k_htc_start(struct ath10k_htc *htc)
msg->hdr.message_id =
__cpu_to_le16(ATH10K_HTC_MSG_SETUP_COMPLETE_EX_ID);
 
+   if (ar->hif.bus == ATH10K_BUS_SDIO) {
+   /* Extra setup params used by SDIO */
+   msg->setup_complete_ext.flags =
+   
__cpu_to_le32(ATH10K_HTC_SETUP_COMPLETE_FLAGS_RX_BNDL_EN);
+   msg->setup_complete_ext.max_msgs_per_bundled_recv =
+   htc->max_msgs_per_htc_bundle;
+   }
ath10k_dbg(ar, ATH10K_DBG_HTC, "HTC is using TX credit flow control\n");
 
status = ath10k_htc_send(htc, ATH10K_HTC_EP_0, skb);
diff --git a/drivers/net/wireless/ath/ath10k/htc.h 
b/drivers/net/wireless/ath/ath10k/htc.h
index 9a1db90..566e437 100644
--- a/drivers/net/wireless/ath/ath10k/htc.h
+++ b/drivers/net/wireless/ath/ath10k/htc.h
@@ -112,6 +112,10 @@ enum ath10k_htc_conn_svc_status {
ATH10K_HTC_CONN_SVC_STATUS_NO_MORE_EP   = 4
 };
 
+enum ath10k_htc_setup_complete_flags {
+   ATH10K_HTC_SETUP_COMPLETE_FLAGS_RX_BNDL_EN = 1
+};
+
 struct ath10k_ath10k_htc_msg_hdr {
__le16 message_id; /* @enum htc_message_id */
 } __packed;
@@ -360,6 +364,7 @@ struct ath10k_htc {
 
int total_transmit_credits;
int target_credit_size;
+   u8 max_msgs_per_htc_bundle;
 };
 
 int ath10k_htc_init(struct ath10k *ar);
-- 
2.7.4



[RFC v4 03/21] ath10k: htc: move htc ctrl ep connect to htc_init

2017-02-21 Thread Erik Stromdahl
This patch moves the HTC ctrl service connect from
htc_wait_target to htc_init.

This is done in order to make sure the htc ctrl service
is setup properly before hif_start is called.

The reason for this is that we want the HTC ctrl service
callback to be initialized before the target sends the
HTC ready message.

The ready message will always be transmitted on endpoint 0
(which is always assigned to the HTC control service) so it
makes more sense if HTC control has been connected before the
ready message is received.

Since the service to pipe mapping is done as a part of
the service connect, the get_default_pipe call is redundant
and was removed.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/htc.c | 39 +++
 1 file changed, 17 insertions(+), 22 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/htc.c 
b/drivers/net/wireless/ath/ath10k/htc.c
index e72f385..f39eef6 100644
--- a/drivers/net/wireless/ath/ath10k/htc.c
+++ b/drivers/net/wireless/ath/ath10k/htc.c
@@ -584,8 +584,6 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc)
struct ath10k *ar = htc->ar;
int i, status = 0;
unsigned long time_left;
-   struct ath10k_htc_svc_conn_req conn_req;
-   struct ath10k_htc_svc_conn_resp conn_resp;
struct ath10k_htc_msg *msg;
u16 message_id;
u16 credit_count;
@@ -648,22 +646,6 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc)
return -ECOMM;
}
 
-   /* setup our pseudo HTC control endpoint connection */
-   memset(&conn_req, 0, sizeof(conn_req));
-   memset(&conn_resp, 0, sizeof(conn_resp));
-   conn_req.ep_ops.ep_tx_complete = ath10k_htc_control_tx_complete;
-   conn_req.ep_ops.ep_rx_complete = ath10k_htc_control_rx_complete;
-   conn_req.max_send_queue_depth = ATH10K_NUM_CONTROL_TX_BUFFERS;
-   conn_req.service_id = ATH10K_HTC_SVC_ID_RSVD_CTRL;
-
-   /* connect fake service */
-   status = ath10k_htc_connect_service(htc, &conn_req, &conn_resp);
-   if (status) {
-   ath10k_err(ar, "could not connect to htc service (%d)\n",
-  status);
-   return status;
-   }
-
return 0;
 }
 
@@ -873,8 +855,10 @@ int ath10k_htc_start(struct ath10k_htc *htc)
 /* registered target arrival callback from the HIF layer */
 int ath10k_htc_init(struct ath10k *ar)
 {
-   struct ath10k_htc_ep *ep = NULL;
+   int status;
struct ath10k_htc *htc = &ar->htc;
+   struct ath10k_htc_svc_conn_req conn_req;
+   struct ath10k_htc_svc_conn_resp conn_resp;
 
spin_lock_init(&htc->tx_lock);
 
@@ -882,10 +866,21 @@ int ath10k_htc_init(struct ath10k *ar)
 
htc->ar = ar;
 
-   /* Get HIF default pipe for HTC message exchange */
-   ep = &htc->endpoint[ATH10K_HTC_EP_0];
+   /* setup our pseudo HTC control endpoint connection */
+   memset(&conn_req, 0, sizeof(conn_req));
+   memset(&conn_resp, 0, sizeof(conn_resp));
+   conn_req.ep_ops.ep_tx_complete = ath10k_htc_control_tx_complete;
+   conn_req.ep_ops.ep_rx_complete = ath10k_htc_control_rx_complete;
+   conn_req.max_send_queue_depth = ATH10K_NUM_CONTROL_TX_BUFFERS;
+   conn_req.service_id = ATH10K_HTC_SVC_ID_RSVD_CTRL;
 
-   ath10k_hif_get_default_pipe(ar, &ep->ul_pipe_id, &ep->dl_pipe_id);
+   /* connect fake service */
+   status = ath10k_htc_connect_service(htc, &conn_req, &conn_resp);
+   if (status) {
+   ath10k_err(ar, "could not connect to htc service (%d)\n",
+  status);
+   return status;
+   }
 
init_completion(&htc->ctl_resp);
 
-- 
2.7.4



[RFC v4 04/21] ath10k: htc: refactorization

2017-02-21 Thread Erik Stromdahl
Code refactorization:

Moved the code for ep 0 in ath10k_htc_rx_completion_handler
to ath10k_htc_control_rx_complete.

This eases the implementation of SDIO/mbox significantly since
the ep_rx_complete cb is invoked directly from the SDIO/mbox
hif layer.

Since the ath10k_htc_control_rx_complete already is present
(only containing a warning message) there is no reason for not
using it (instead of having a special case for ep 0 in
ath10k_htc_rx_completion_handler).

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/htc.c | 73 ---
 1 file changed, 34 insertions(+), 39 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/htc.c 
b/drivers/net/wireless/ath/ath10k/htc.c
index f39eef6..eb036b3 100644
--- a/drivers/net/wireless/ath/ath10k/htc.c
+++ b/drivers/net/wireless/ath/ath10k/htc.c
@@ -459,42 +459,6 @@ void ath10k_htc_rx_completion_handler(struct ath10k *ar, 
struct sk_buff *skb)
/* zero length packet with trailer data, just drop these */
goto out;
 
-   if (eid == ATH10K_HTC_EP_0) {
-   struct ath10k_htc_msg *msg = (struct ath10k_htc_msg *)skb->data;
-
-   switch (__le16_to_cpu(msg->hdr.message_id)) {
-   case ATH10K_HTC_MSG_READY_ID:
-   case ATH10K_HTC_MSG_CONNECT_SERVICE_RESP_ID:
-   /* handle HTC control message */
-   if (completion_done(&htc->ctl_resp)) {
-   /*
-* this is a fatal error, target should not be
-* sending unsolicited messages on the ep 0
-*/
-   ath10k_warn(ar, "HTC rx ctrl still 
processing\n");
-   complete(&htc->ctl_resp);
-   goto out;
-   }
-
-   htc->control_resp_len =
-   min_t(int, skb->len,
- ATH10K_HTC_MAX_CTRL_MSG_LEN);
-
-   memcpy(htc->control_resp_buffer, skb->data,
-  htc->control_resp_len);
-
-   complete(&htc->ctl_resp);
-   break;
-   case ATH10K_HTC_MSG_SEND_SUSPEND_COMPLETE:
-   htc->htc_ops.target_send_suspend_complete(ar);
-   break;
-   default:
-   ath10k_warn(ar, "ignoring unsolicited htc ep0 event\n");
-   break;
-   }
-   goto out;
-   }
-
ath10k_dbg(ar, ATH10K_DBG_HTC, "htc rx completion ep %d skb %pK\n",
   eid, skb);
ep->ep_ops.ep_rx_complete(ar, skb);
@@ -509,9 +473,40 @@ EXPORT_SYMBOL(ath10k_htc_rx_completion_handler);
 static void ath10k_htc_control_rx_complete(struct ath10k *ar,
   struct sk_buff *skb)
 {
-   /* This is unexpected. FW is not supposed to send regular rx on this
-* endpoint. */
-   ath10k_warn(ar, "unexpected htc rx\n");
+   struct ath10k_htc *htc = &ar->htc;
+   struct ath10k_htc_msg *msg = (struct ath10k_htc_msg *)skb->data;
+
+   switch (__le16_to_cpu(msg->hdr.message_id)) {
+   case ATH10K_HTC_MSG_READY_ID:
+   case ATH10K_HTC_MSG_CONNECT_SERVICE_RESP_ID:
+   /* handle HTC control message */
+   if (completion_done(&htc->ctl_resp)) {
+   /* this is a fatal error, target should not be
+* sending unsolicited messages on the ep 0
+*/
+   ath10k_warn(ar, "HTC rx ctrl still processing\n");
+   complete(&htc->ctl_resp);
+   goto out;
+   }
+
+   htc->control_resp_len =
+   min_t(int, skb->len,
+ ATH10K_HTC_MAX_CTRL_MSG_LEN);
+
+   memcpy(htc->control_resp_buffer, skb->data,
+  htc->control_resp_len);
+
+   complete(&htc->ctl_resp);
+   break;
+   case ATH10K_HTC_MSG_SEND_SUSPEND_COMPLETE:
+   htc->htc_ops.target_send_suspend_complete(ar);
+   break;
+   default:
+   ath10k_warn(ar, "ignoring unsolicited htc ep0 event\n");
+   break;
+   }
+
+out:
kfree_skb(skb);
 }
 
-- 
2.7.4



[RFC v4 02/21] ath10k: htc: rx trailer lookahead support

2017-02-21 Thread Erik Stromdahl
The RX trailer parsing is now capable of parsing lookahead reports.
A lookahead contains the first 4 bytes of the next HTC message
(that will be read in the next SDIO read operation).
Lookaheads are used by the SDIO/mbox HIF layer to determine if
the next message is part of a bundle, which endpoint it belongs
to and how long it is.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/htc.c | 93 ++-
 drivers/net/wireless/ath/ath10k/htc.h | 30 +--
 2 files changed, 118 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/htc.c 
b/drivers/net/wireless/ath/ath10k/htc.c
index 35e67c4..e72f385 100644
--- a/drivers/net/wireless/ath/ath10k/htc.c
+++ b/drivers/net/wireless/ath/ath10k/htc.c
@@ -228,10 +228,76 @@ ath10k_htc_process_credit_report(struct ath10k_htc *htc,
spin_unlock_bh(&htc->tx_lock);
 }
 
+static int
+ath10k_htc_process_lookahead(struct ath10k_htc *htc,
+const struct ath10k_htc_lookahead_report *report,
+int len,
+enum ath10k_htc_ep_id eid,
+void *next_lookaheads,
+int *next_lookaheads_len)
+{
+   struct ath10k *ar = htc->ar;
+
+   /* Invalid lookahead flags are actually transmitted by
+* the target in the HTC control message.
+* Since this will happen at every boot we silently ignore
+* the lookahead in this case
+*/
+   if (report->pre_valid != ((~report->post_valid) & 0xFF))
+   return 0;
+
+   if (next_lookaheads && next_lookaheads_len) {
+   ath10k_dbg(ar, ATH10K_DBG_HTC,
+  "htc rx lookahead found pre_valid 0x%x post_valid 
0x%x\n",
+  report->pre_valid, report->post_valid);
+
+   /* look ahead bytes are valid, copy them over */
+   memcpy((u8 *)next_lookaheads, report->lookahead, 4);
+
+   *next_lookaheads_len = 1;
+   }
+
+   return 0;
+}
+
+static int
+ath10k_htc_process_lookahead_bundle(struct ath10k_htc *htc,
+   const struct 
ath10k_htc_lookahead_report_bundle *report,
+   int len,
+   enum ath10k_htc_ep_id eid,
+   void *next_lookaheads,
+   int *next_lookaheads_len)
+{
+   struct ath10k *ar = htc->ar;
+   int bundle_cnt = len / sizeof(*report);
+
+   if (!bundle_cnt || (bundle_cnt > HTC_HOST_MAX_MSG_PER_BUNDLE)) {
+   ath10k_warn(ar, "Invalid lookahead bundle count: %d\n",
+   bundle_cnt);
+   return -EINVAL;
+   }
+
+   if (next_lookaheads && next_lookaheads_len) {
+   int i;
+
+   for (i = 0; i < bundle_cnt; i++) {
+   memcpy(((u8 *)next_lookaheads) + 4 * i,
+  report->lookahead, 4);
+   report++;
+   }
+
+   *next_lookaheads_len = bundle_cnt;
+   }
+
+   return 0;
+}
+
 int ath10k_htc_process_trailer(struct ath10k_htc *htc,
   u8 *buffer,
   int length,
-  enum ath10k_htc_ep_id src_eid)
+  enum ath10k_htc_ep_id src_eid,
+  void *next_lookaheads,
+  int *next_lookaheads_len)
 {
struct ath10k *ar = htc->ar;
int status = 0;
@@ -272,6 +338,28 @@ int ath10k_htc_process_trailer(struct ath10k_htc *htc,
 record->hdr.len,
 src_eid);
break;
+   case ATH10K_HTC_RECORD_LOOKAHEAD:
+   len = sizeof(struct ath10k_htc_lookahead_report);
+   if (record->hdr.len < len) {
+   ath10k_warn(ar, "Lookahead report too long\n");
+   status = -EINVAL;
+   break;
+   }
+   status = ath10k_htc_process_lookahead(htc,
+ 
record->lookahead_report,
+ record->hdr.len,
+ src_eid,
+ next_lookaheads,
+ 
next_lookaheads_len);
+   break;
+   case ATH10K_HTC_RECORD_LOOKAHEAD_BUNDLE:
+   status = ath10k_htc_process_lookahead_bundle(htc,
+
record->lookahead_bundle,
+

[RFC v4 01/21] ath10k: htc: made static function public

2017-02-21 Thread Erik Stromdahl
Changed ath10k_htc_notify_tx_completion and
ath10k_htc_process_trailer from static to non static.

These functions are needed by SDIO/mbox.

Signed-off-by: Erik Stromdahl 
---
 drivers/net/wireless/ath/ath10k/htc.c | 14 --
 drivers/net/wireless/ath/ath10k/htc.h |  6 ++
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/htc.c 
b/drivers/net/wireless/ath/ath10k/htc.c
index 9f6a915..35e67c4 100644
--- a/drivers/net/wireless/ath/ath10k/htc.c
+++ b/drivers/net/wireless/ath/ath10k/htc.c
@@ -57,8 +57,8 @@ static inline void ath10k_htc_restore_tx_skb(struct 
ath10k_htc *htc,
skb_pull(skb, sizeof(struct ath10k_htc_hdr));
 }
 
-static void ath10k_htc_notify_tx_completion(struct ath10k_htc_ep *ep,
-   struct sk_buff *skb)
+void ath10k_htc_notify_tx_completion(struct ath10k_htc_ep *ep,
+struct sk_buff *skb)
 {
struct ath10k *ar = ep->htc->ar;
 
@@ -75,6 +75,7 @@ static void ath10k_htc_notify_tx_completion(struct 
ath10k_htc_ep *ep,
 
ep->ep_ops.ep_tx_complete(ep->htc->ar, skb);
 }
+EXPORT_SYMBOL(ath10k_htc_notify_tx_completion);
 
 static void ath10k_htc_prepare_tx_skb(struct ath10k_htc_ep *ep,
  struct sk_buff *skb)
@@ -227,10 +228,10 @@ ath10k_htc_process_credit_report(struct ath10k_htc *htc,
spin_unlock_bh(&htc->tx_lock);
 }
 
-static int ath10k_htc_process_trailer(struct ath10k_htc *htc,
- u8 *buffer,
- int length,
- enum ath10k_htc_ep_id src_eid)
+int ath10k_htc_process_trailer(struct ath10k_htc *htc,
+  u8 *buffer,
+  int length,
+  enum ath10k_htc_ep_id src_eid)
 {
struct ath10k *ar = htc->ar;
int status = 0;
@@ -291,6 +292,7 @@ static int ath10k_htc_process_trailer(struct ath10k_htc 
*htc,
 
return status;
 }
+EXPORT_SYMBOL(ath10k_htc_process_trailer);
 
 void ath10k_htc_rx_completion_handler(struct ath10k *ar, struct sk_buff *skb)
 {
diff --git a/drivers/net/wireless/ath/ath10k/htc.h 
b/drivers/net/wireless/ath/ath10k/htc.h
index 6ababa3..f728ce7 100644
--- a/drivers/net/wireless/ath/ath10k/htc.h
+++ b/drivers/net/wireless/ath/ath10k/htc.h
@@ -351,5 +351,11 @@ int ath10k_htc_send(struct ath10k_htc *htc, enum 
ath10k_htc_ep_id eid,
 struct sk_buff *ath10k_htc_alloc_skb(struct ath10k *ar, int size);
 void ath10k_htc_tx_completion_handler(struct ath10k *ar, struct sk_buff *skb);
 void ath10k_htc_rx_completion_handler(struct ath10k *ar, struct sk_buff *skb);
+void ath10k_htc_notify_tx_completion(struct ath10k_htc_ep *ep,
+struct sk_buff *skb);
+int ath10k_htc_process_trailer(struct ath10k_htc *htc,
+  u8 *buffer,
+  int length,
+  enum ath10k_htc_ep_id src_eid);
 
 #endif
-- 
2.7.4



[RFC v4 00/21] ath10k sdio and usb support

2017-02-21 Thread Erik Stromdahl
This is the 4th version of the sdio and usb RFC patch series.
I have combined the sdio and usb patches into one series since they are
inseparable (both series must be applied in order to have a working system).

The main difference since last version (v3) is that QCA9377 sdio support
was added. I have also fixed a few minor issues in the sdio HIF layer.

*Current status*

The sdio and usb HIF layers seem to work fine. I am able to download fw,
connect WMI and HTT services and so on.

I have been running it for a while now and so far I have not encountered
any major issues.

The biggest issue right now is that the board setup of high latency devices
is very different in qcacld than for ath10k. I have a working qcacld
system on a 4.1 kernel that I am using a as a reference. I am basically
diffing the bus traffic between qcacld and ath10k to see what the
differences are and then try to incorporate the missing stuff in ath10k.
Some WMI messages used by qcacld are not present in ath10k, and a few
others are different.

An example is the WMI init message:

>From qcacld:
[539.662779]WMI msg id:  1,  WMI_INIT_CMDID
WmiTlvInitCmd:
  TlvHeader:
length: 0x1c
tag: 0x4a (WMI_TLV_TAG_STRUCT_INIT_CMD)
  WmiTlvAbiVersion:
abi_ver0: 0x100
abi_ver1: 0xa8<- DIFFERENT
abi_ver_ns0: 0x5f414351
abi_ver_ns1: 0x4c4d
abi_ver_ns2: 0x0
abi_ver_ns3: 0x0
  num_host_mem_chunks: 0x0
WmiTlvResourceConfig:
  TlvHeader:
length: 0xac  <- DIFFERENT
tag: 0x4b (WMI_TLV_TAG_STRUCT_RESOURCE_CONFIG)
...

>From ath10k:
[51.312300] WMI msg id:  1,  WMI_INIT_CMDID
WmiTlvInitCmd:
  TlvHeader:
length: 0x1c
tag: 0x4a (WMI_TLV_TAG_STRUCT_INIT_CMD)
  WmiTlvAbiVersion:
abi_ver0: 0x100
abi_ver1: 0x35<- DIFFERENT
abi_ver_ns0: 0x5f414351
abi_ver_ns1: 0x4c4d
abi_ver_ns2: 0x0
abi_ver_ns3: 0x0
  num_host_mem_chunks: 0x0
WmiTlvResourceConfig:
  TlvHeader:
length: 0x9c  <- DIFFERENT
tag: 0x4b (WMI_TLV_TAG_STRUCT_RESOURCE_CONFIG)
...

Notice the difference in abi_ver1 and the WmiTlvResourceConfig length.
Apparently qcacld uses a newer version of the wmi tlv protocol.
I get the feeling that the high latency devices are intended to be used
with a newer WMI protocol version than ath10k supports.

The usb firmware seems to be more capable of handling the older wmi format
than the sdio firmware (I am able to connect to my AP and lease an IP
address with the usb device but not with the sdio device using exactly the
same setup)

I think these issues will have to be addressed in a future patch series.

The usb stuff is more or less in the same state as previously, nothing
has happened there except for a few checkpatch fixes.

Erik Stromdahl (21):
  ath10k: htc: made static function public
  ath10k: htc: rx trailer lookahead support
  ath10k: htc: move htc ctrl ep connect to htc_init
  ath10k: htc: refactorization
  ath10k: various sdio related definitions
  ath10k: sdio support
  ath10k: add sdio extra initializations
  ath10k: sdio get target info
  ath10k: htc: ready_ext msg support
  ath10k: various usb related definitions
  ath10k: usb support
  ath10k: high_latency detection
  ath10k: different fw file names for usb and sdio
  ath10k: htt: RX ring config HL support
  ath10k: per target configurablity of various items
  ath10k: add start_once support
  ath10k: htt: High latency TX support
  ath10k: htt: High latency RX support
  ath10k: add QCA9377 usb hw_param item
  ath10k: add QCA9377 sdio hw_param item
  ath10k: dma fixes for high latency devices

 drivers/net/wireless/ath/ath10k/Kconfig |   12 +
 drivers/net/wireless/ath/ath10k/Makefile|6 +
 drivers/net/wireless/ath/ath10k/bmi.c   |   70 +
 drivers/net/wireless/ath/ath10k/bmi.h   |2 +
 drivers/net/wireless/ath/ath10k/core.c  |  176 ++-
 drivers/net/wireless/ath/ath10k/core.h  |   18 +-
 drivers/net/wireless/ath/ath10k/debug.h |4 +
 drivers/net/wireless/ath/ath10k/htc.c   |  254 +++-
 drivers/net/wireless/ath/ath10k/htc.h   |   39 +-
 drivers/net/wireless/ath/ath10k/htt.c   |5 +-
 drivers/net/wireless/ath/ath10k/htt.h   |   57 +-
 drivers/net/wireless/ath/ath10k/htt_rx.c|   98 +-
 drivers/net/wireless/ath/ath10k/htt_tx.c|  126 +-
 drivers/net/wireless/ath/ath10k/hw.h|   83 ++
 drivers/net/wireless/ath/ath10k/mac.c   |5 +-
 drivers/net/wireless/ath/ath10k/rx_desc.h   |   15 +
 drivers/net/wireless/ath/ath10k/sdio.c  | 2138 +++
 drivers/net/wireless/ath/ath10k/sdio.h  |  263 
 drivers/net/wireless/ath/ath10k/targaddrs.h |   24 +
 drivers/net/wireless/ath/ath10k/txrx.c  |5 +-
 drivers/net/wireless/ath/ath10k/usb.c   | 1125 ++
 drivers/net/wireless/ath/ath10k/usb.h   |  128 ++
 drivers/net/wireless/ath/ath10k/wmi-tlv.c   |

Re: [RFC v2 1/2] cfg80211: support 4-way handshake offloading for WPA/WPA2-PSK

2017-02-21 Thread Jouni Malinen
On Tue, Feb 21, 2017 at 01:37:57PM +0100, Johannes Berg wrote:
> Add a new NL80211_ATTR_PMK attribute that might be passed as part
> of NL80211_CMD_CONNECT command, and contain the PSK (which is the
> PMK, hence the name.)

> diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
> +#define WLAN_PMK_LEN 32

> diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
>  struct cfg80211_crypto_settings {
> + const u8 *psk;

> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
> + [NL80211_ATTR_PMK] = { .len = WLAN_PMK_LEN },

While the existing WPA2-PSK cases all use 32 octet PMK, there are also
48 octet PMKs in use with EAP (Suite B 192-bit level and FILS with
SHA384). Patch 2/2 seemed to look at the PMK length as well.. Should the
same be done already with 1/2 so that the PSK case is separately
validating exact match with 32 octets in length for PMK = PSK while the
other cases allow longer PMK as well?

I never remember how the attr policy .len works, so that may already be
the implicit behavior here, but it would be clearer to be more explicit
about the possible lengths of the WLAN_ATTR_PMK and not assume that
WLAN_PMK_LEN definition is the only possible option.

-- 
Jouni MalinenPGP id EFC895FA


Re: [RFC v2 1/2] cfg80211: support 4-way handshake offloading for WPA/WPA2-PSK

2017-02-21 Thread Johannes Berg

> The .len verifies that it's at least that long. We're thus ignoring
> additional bytes in the PSK case if they're present, which I suppose
> we should fix by checking the exact length in the code separately.
> 
IOW, I'll add this:

--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -8044,6 +8044,8 @@ static int nl80211_crypto_settings(struct 
cfg80211_registered_device *rdev,
if (!wiphy_ext_feature_isset(&rdev->wiphy,
 
NL80211_EXT_FEATURE_4WAY_HANDSHAKE_STA_PSK))
return -EINVAL;
+   if (nla_len(info->attrs[NL80211_ATTR_PMK]) != WLAN_PMK_LEN)
+   return -EINVAL;
settings->psk = nla_data(info->attrs[NL80211_ATTR_PMK]);
}
 

johannes


Re: [RFC v2 1/2] cfg80211: support 4-way handshake offloading for WPA/WPA2-PSK

2017-02-21 Thread Johannes Berg

> While the existing WPA2-PSK cases all use 32 octet PMK, there are
> also
> 48 octet PMKs in use with EAP (Suite B 192-bit level and FILS with
> SHA384). Patch 2/2 seemed to look at the PMK length as well.. Should
> the same be done already with 1/2 so that the PSK case is separately
> validating exact match with 32 octets in length for PMK = PSK while
> the other cases allow longer PMK as well?
> 
> I never remember how the attr policy .len works, so that may already
> be the implicit behavior here, but it would be clearer to be more
> explicit about the possible lengths of the WLAN_ATTR_PMK and not
> assume that WLAN_PMK_LEN definition is the only possible option.

The .len verifies that it's at least that long. We're thus ignoring
additional bytes in the PSK case if they're present, which I suppose we
should fix by checking the exact length in the code separately.

johannes


[PATCH 07/10] wil6210: protect list of pending wmi events during flush

2017-02-21 Thread Maya Erez
From: Hamad Kadmany 

When flush is done, pending events list is manipulated
without taking the proper spinlock, which could lead to
memory corruption if list is manipulated by wmi worker
or by interrupt routine.

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

diff --git a/drivers/net/wireless/ath/wil6210/wmi.c 
b/drivers/net/wireless/ath/wil6210/wmi.c
index a2a895b..02ccdae 100644
--- a/drivers/net/wireless/ath/wil6210/wmi.c
+++ b/drivers/net/wireless/ath/wil6210/wmi.c
@@ -1738,14 +1738,19 @@ int wmi_new_sta(struct wil6210_priv *wil, const u8 
*mac, u8 aid)
 
 void wmi_event_flush(struct wil6210_priv *wil)
 {
+   ulong flags;
struct pending_wmi_event *evt, *t;
 
wil_dbg_wmi(wil, "event_flush\n");
 
+   spin_lock_irqsave(&wil->wmi_ev_lock, flags);
+
list_for_each_entry_safe(evt, t, &wil->pending_wmi_ev, list) {
list_del(&evt->list);
kfree(evt);
}
+
+   spin_unlock_irqrestore(&wil->wmi_ev_lock, flags);
 }
 
 static bool wmi_evt_call_handler(struct wil6210_priv *wil, int id,
-- 
1.9.1



[PATCH 06/10] wil6210: store bss object and use cfg80211_connect_bss()

2017-02-21 Thread Maya Erez
From: Dedy Lansky 

In a fast disconnect/connect sequence, cfg80211_connect_result() can
fail to find the bss object which the driver is connecting to. Detailed
sequence of events:
* Driver is connected in STA mode
* Disconnect request arrives from user space. Driver disconnects and
  calls cfg80211_disconnected() which adds new event to the
  cfg80211_wq worker thread
* Connect request arrives from user space. cfg80211_connect() stores
  ssid/ssid_len and calls rdev_connect()
* __cfg80211_disconnected() runs in worker thread and zero
  wdev->ssid_len
* Connect succeeds. Driver calls cfg80211_connect_result() which fails
  to find the bss because wdev->ssid_len is zero

To overcome this, upon connect request, store the bss object in the
driver and upon connect completion pass it to kernel using
cfg80211_connect_bss().

Signed-off-by: Dedy Lansky 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/cfg80211.c |  1 +
 drivers/net/wireless/ath/wil6210/main.c |  1 +
 drivers/net/wireless/ath/wil6210/wil6210.h  |  1 +
 drivers/net/wireless/ath/wil6210/wmi.c  | 14 +-
 4 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c 
b/drivers/net/wireless/ath/wil6210/cfg80211.c
index 581a4e2..39ee565 100644
--- a/drivers/net/wireless/ath/wil6210/cfg80211.c
+++ b/drivers/net/wireless/ath/wil6210/cfg80211.c
@@ -681,6 +681,7 @@ static int wil_cfg80211_connect(struct wiphy *wiphy,
if (rc == 0) {
netif_carrier_on(ndev);
wil6210_bus_request(wil, WIL_MAX_BUS_REQUEST_KBPS);
+   wil->bss = bss;
/* Connect can take lots of time */
mod_timer(&wil->connect_timer,
  jiffies + msecs_to_jiffies(2000));
diff --git a/drivers/net/wireless/ath/wil6210/main.c 
b/drivers/net/wireless/ath/wil6210/main.c
index e94..5d45fac 100644
--- a/drivers/net/wireless/ath/wil6210/main.c
+++ b/drivers/net/wireless/ath/wil6210/main.c
@@ -284,6 +284,7 @@ static void _wil6210_disconnect(struct wil6210_priv *wil, 
const u8 *bssid,
cfg80211_connect_result(ndev, bssid, NULL, 0, NULL, 0,
WLAN_STATUS_UNSPECIFIED_FAILURE,
GFP_KERNEL);
+   wil->bss = NULL;
}
clear_bit(wil_status_fwconnecting, wil->status);
break;
diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h 
b/drivers/net/wireless/ath/wil6210/wil6210.h
index 89e7eb7..09e2fce 100644
--- a/drivers/net/wireless/ath/wil6210/wil6210.h
+++ b/drivers/net/wireless/ath/wil6210/wil6210.h
@@ -613,6 +613,7 @@ struct wil6210_priv {
u16 channel; /* relevant in AP mode */
int sinfo_gen;
u32 ap_isolate; /* no intra-BSS communication */
+   struct cfg80211_bss *bss; /* connected bss, relevant in STA mode */
/* interrupt moderation */
u32 tx_max_burst_duration;
u32 tx_interframe_timeout;
diff --git a/drivers/net/wireless/ath/wil6210/wmi.c 
b/drivers/net/wireless/ath/wil6210/wmi.c
index a7a4ac1..a2a895b 100644
--- a/drivers/net/wireless/ath/wil6210/wmi.c
+++ b/drivers/net/wireless/ath/wil6210/wmi.c
@@ -573,12 +573,16 @@ static void wmi_evt_connect(struct wil6210_priv *wil, int 
id, void *d, int len)
GFP_KERNEL);
goto out;
} else {
-   cfg80211_connect_result(ndev, evt->bssid,
-   assoc_req_ie, assoc_req_ielen,
-   assoc_resp_ie, assoc_resp_ielen,
-   WLAN_STATUS_SUCCESS,
-   GFP_KERNEL);
+   struct wiphy *wiphy = wil_to_wiphy(wil);
+
+   cfg80211_ref_bss(wiphy, wil->bss);
+   cfg80211_connect_bss(ndev, evt->bssid, wil->bss,
+assoc_req_ie, assoc_req_ielen,
+assoc_resp_ie, assoc_resp_ielen,
+WLAN_STATUS_SUCCESS, GFP_KERNEL,
+NL80211_TIMEOUT_UNSPECIFIED);
}
+   wil->bss = NULL;
} else if ((wdev->iftype == NL80211_IFTYPE_AP) ||
   (wdev->iftype == NL80211_IFTYPE_P2P_GO)) {
if (rc) {
-- 
1.9.1



[PATCH 08/10] wil6210: use WMI_DISCONNECT_CMDID upon connect timeout

2017-02-21 Thread Maya Erez
From: Dedy Lansky 

Upon connect timeout driver invokes _wil6210_disconnect() which iterates
over sta array and disconnects each connected sta. In practice, because
the connection is still ongoing and because cid is not yet allocated,
disconnect is not actually happening. This leaves FW in connecting
state while driver is in disconnected state.
To fix this, upon connect timeout, explicitly send WMI_DISCONNECT_CMDID
to FW to make sure it gets disconnected.

Signed-off-by: Dedy Lansky 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/main.c | 30 +++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/main.c 
b/drivers/net/wireless/ath/wil6210/main.c
index 5d45fac..79aeb2b8 100644
--- a/drivers/net/wireless/ath/wil6210/main.c
+++ b/drivers/net/wireless/ath/wil6210/main.c
@@ -306,10 +306,34 @@ static void wil_disconnect_worker(struct work_struct 
*work)
 {
struct wil6210_priv *wil = container_of(work,
struct wil6210_priv, disconnect_worker);
+   struct net_device *ndev = wil_to_ndev(wil);
+   int rc;
+   struct {
+   struct wmi_cmd_hdr wmi;
+   struct wmi_disconnect_event evt;
+   } __packed reply;
 
-   mutex_lock(&wil->mutex);
-   _wil6210_disconnect(wil, NULL, WLAN_REASON_UNSPECIFIED, false);
-   mutex_unlock(&wil->mutex);
+   if (test_bit(wil_status_fwconnected, wil->status))
+   /* connect succeeded after all */
+   return;
+
+   if (!test_bit(wil_status_fwconnecting, wil->status))
+   /* already disconnected */
+   return;
+
+   rc = wmi_call(wil, WMI_DISCONNECT_CMDID, NULL, 0,
+ WMI_DISCONNECT_EVENTID, &reply, sizeof(reply),
+ WIL6210_DISCONNECT_TO_MS);
+   if (rc) {
+   wil_err(wil, "disconnect error %d\n", rc);
+   return;
+   }
+
+   wil_update_net_queues_bh(wil, NULL, true);
+   netif_carrier_off(ndev);
+   cfg80211_connect_result(ndev, NULL, NULL, 0, NULL, 0,
+   WLAN_STATUS_UNSPECIFIED_FAILURE, GFP_KERNEL);
+   clear_bit(wil_status_fwconnecting, wil->status);
 }
 
 static void wil_connect_timer_fn(ulong x)
-- 
1.9.1



[PATCH 09/10] wil6210: correctly report locally generated disconnect in STA mode

2017-02-21 Thread Maya Erez
From: Dedy Lansky 

Driver always invoke cfg80211_disconnected() with locally_generated as
false.
Fix this by reporting true whenever the disconnect is triggered from
upper layers (cfg80211) or from within the driver itself (reset,
deinit).

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

diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c 
b/drivers/net/wireless/ath/wil6210/cfg80211.c
index 39ee565..1981ec2 100644
--- a/drivers/net/wireless/ath/wil6210/cfg80211.c
+++ b/drivers/net/wireless/ath/wil6210/cfg80211.c
@@ -710,6 +710,7 @@ static int wil_cfg80211_disconnect(struct wiphy *wiphy,
return 0;
}
 
+   wil->locally_generated_disc = true;
rc = wmi_call(wil, WMI_DISCONNECT_CMDID, NULL, 0,
  WMI_DISCONNECT_EVENTID, NULL, 0,
  WIL6210_DISCONNECT_TO_MS);
diff --git a/drivers/net/wireless/ath/wil6210/main.c 
b/drivers/net/wireless/ath/wil6210/main.c
index 79aeb2b8..3206aea 100644
--- a/drivers/net/wireless/ath/wil6210/main.c
+++ b/drivers/net/wireless/ath/wil6210/main.c
@@ -279,7 +279,10 @@ static void _wil6210_disconnect(struct wil6210_priv *wil, 
const u8 *bssid,
if (test_bit(wil_status_fwconnected, wil->status)) {
clear_bit(wil_status_fwconnected, wil->status);
cfg80211_disconnected(ndev, reason_code,
- NULL, 0, false, GFP_KERNEL);
+ NULL, 0,
+ wil->locally_generated_disc,
+ GFP_KERNEL);
+   wil->locally_generated_disc = false;
} else if (test_bit(wil_status_fwconnecting, wil->status)) {
cfg80211_connect_result(ndev, bssid, NULL, 0, NULL, 0,
WLAN_STATUS_UNSPECIFIED_FAILURE,
diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h 
b/drivers/net/wireless/ath/wil6210/wil6210.h
index 09e2fce..cb825cc 100644
--- a/drivers/net/wireless/ath/wil6210/wil6210.h
+++ b/drivers/net/wireless/ath/wil6210/wil6210.h
@@ -614,6 +614,7 @@ struct wil6210_priv {
int sinfo_gen;
u32 ap_isolate; /* no intra-BSS communication */
struct cfg80211_bss *bss; /* connected bss, relevant in STA mode */
+   int locally_generated_disc; /* relevant in STA mode */
/* interrupt moderation */
u32 tx_max_burst_duration;
u32 tx_interframe_timeout;
diff --git a/drivers/net/wireless/ath/wil6210/wmi.c 
b/drivers/net/wireless/ath/wil6210/wmi.c
index 02ccdae..9255c47 100644
--- a/drivers/net/wireless/ath/wil6210/wmi.c
+++ b/drivers/net/wireless/ath/wil6210/wmi.c
@@ -1497,6 +1497,7 @@ int wmi_disconnect_sta(struct wil6210_priv *wil, const u8 
*mac,
 
wil_dbg_wmi(wil, "disconnect_sta: (%pM, reason %d)\n", mac, reason);
 
+   wil->locally_generated_disc = true;
if (del_sta) {
ether_addr_copy(del_sta_cmd.dst_mac, mac);
rc = wmi_call(wil, WMI_DEL_STA_CMDID, &del_sta_cmd,
-- 
1.9.1



[PATCH 10/10] wil6210: add oob_mode for AP certification

2017-02-21 Thread Maya Erez
From: Lior David 

Add a new value to the oob_mode module parameter for
supporting AP certification.
All enabled values of oob_mode (>0) are intended only
for debugging and diagnostics.

Signed-off-by: Lior David 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/main.c| 24 ++--
 drivers/net/wireless/ath/wil6210/wil6210.h |  1 +
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/main.c 
b/drivers/net/wireless/ath/wil6210/main.c
index 3206aea..c33cc4a 100644
--- a/drivers/net/wireless/ath/wil6210/main.c
+++ b/drivers/net/wireless/ath/wil6210/main.c
@@ -30,8 +30,8 @@
 module_param(debug_fw, bool, 0444);
 MODULE_PARM_DESC(debug_fw, " do not perform card reset. For FW debug");
 
-static bool oob_mode;
-module_param(oob_mode, bool, 0444);
+static u8 oob_mode;
+module_param(oob_mode, byte, 0444);
 MODULE_PARM_DESC(oob_mode,
 " enable out of the box (OOB) mode in FW, for diagnostics and 
certification");
 
@@ -642,13 +642,25 @@ static inline void wil_release_cpu(struct wil6210_priv 
*wil)
wil_w(wil, RGF_USER_USER_CPU_0, 1);
 }
 
-static void wil_set_oob_mode(struct wil6210_priv *wil, bool enable)
+static void wil_set_oob_mode(struct wil6210_priv *wil, u8 mode)
 {
-   wil_info(wil, "enable=%d\n", enable);
-   if (enable)
+   wil_info(wil, "oob_mode to %d\n", mode);
+   switch (mode) {
+   case 0:
+   wil_c(wil, RGF_USER_USAGE_6, BIT_USER_OOB_MODE |
+ BIT_USER_OOB_R2_MODE);
+   break;
+   case 1:
+   wil_c(wil, RGF_USER_USAGE_6, BIT_USER_OOB_R2_MODE);
wil_s(wil, RGF_USER_USAGE_6, BIT_USER_OOB_MODE);
-   else
+   break;
+   case 2:
wil_c(wil, RGF_USER_USAGE_6, BIT_USER_OOB_MODE);
+   wil_s(wil, RGF_USER_USAGE_6, BIT_USER_OOB_R2_MODE);
+   break;
+   default:
+   wil_err(wil, "invalid oob_mode: %d\n", mode);
+   }
 }
 
 static int wil_target_reset(struct wil6210_priv *wil)
diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h 
b/drivers/net/wireless/ath/wil6210/wil6210.h
index cb825cc..fee1891 100644
--- a/drivers/net/wireless/ath/wil6210/wil6210.h
+++ b/drivers/net/wireless/ath/wil6210/wil6210.h
@@ -140,6 +140,7 @@ struct RGF_ICR {
 #define RGF_USER_USAGE_1   (0x880004)
 #define RGF_USER_USAGE_6   (0x880018)
#define BIT_USER_OOB_MODE   BIT(31)
+   #define BIT_USER_OOB_R2_MODEBIT(30)
 #define RGF_USER_HW_MACHINE_STATE  (0x8801dc)
#define HW_MACHINE_BOOT_DONE(0x3fd)
 #define RGF_USER_USER_CPU_0(0x8801e0)
-- 
1.9.1



[PATCH 03/10] wil6210: bus_request platform operation refinement

2017-02-21 Thread Maya Erez
From: Lior David 

The driver uses the bus_request platform operation to
request resources from the platform for a specific bandwidth.
Currently the driver requests resources for the maximum
theoretical bandwidth, when interface is brought up.
Refine this process a bit: now the driver will request a
small amount of resources when interface is up, and will only
issue the maximum request when connected.
This mechanism will be improved further in the future to make
more refined requests based on actual bandwidth.

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

diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c 
b/drivers/net/wireless/ath/wil6210/cfg80211.c
index 14aa6d3..2dc594d 100644
--- a/drivers/net/wireless/ath/wil6210/cfg80211.c
+++ b/drivers/net/wireless/ath/wil6210/cfg80211.c
@@ -680,6 +680,7 @@ static int wil_cfg80211_connect(struct wiphy *wiphy,
rc = wmi_send(wil, WMI_CONNECT_CMDID, &conn, sizeof(conn));
if (rc == 0) {
netif_carrier_on(ndev);
+   wil6210_bus_request(wil, WIL_MAX_BUS_REQUEST_KBPS);
/* Connect can take lots of time */
mod_timer(&wil->connect_timer,
  jiffies + msecs_to_jiffies(2000));
@@ -1199,6 +1200,7 @@ static int _wil_cfg80211_start_ap(struct wiphy *wiphy,
wil->pbss = pbss;
 
netif_carrier_on(ndev);
+   wil6210_bus_request(wil, WIL_MAX_BUS_REQUEST_KBPS);
 
rc = wmi_pcp_start(wil, bi, wmi_nettype, chan, hidden_ssid, is_go);
if (rc)
@@ -1214,6 +1216,7 @@ static int _wil_cfg80211_start_ap(struct wiphy *wiphy,
wmi_pcp_stop(wil);
 err_pcp_start:
netif_carrier_off(ndev);
+   wil6210_bus_request(wil, WIL_DEFAULT_BUS_REQUEST_KBPS);
 out:
mutex_unlock(&wil->mutex);
return rc;
@@ -1320,6 +1323,7 @@ static int wil_cfg80211_stop_ap(struct wiphy *wiphy,
wil_dbg_misc(wil, "stop_ap\n");
 
netif_carrier_off(ndev);
+   wil6210_bus_request(wil, WIL_DEFAULT_BUS_REQUEST_KBPS);
wil_set_recovery_state(wil, fw_recovery_idle);
 
mutex_lock(&wil->mutex);
diff --git a/drivers/net/wireless/ath/wil6210/main.c 
b/drivers/net/wireless/ath/wil6210/main.c
index efb1f59..21b7fac 100644
--- a/drivers/net/wireless/ath/wil6210/main.c
+++ b/drivers/net/wireless/ath/wil6210/main.c
@@ -274,6 +274,7 @@ static void _wil6210_disconnect(struct wil6210_priv *wil, 
const u8 *bssid,
wil_bcast_fini(wil);
wil_update_net_queues_bh(wil, NULL, true);
netif_carrier_off(ndev);
+   wil6210_bus_request(wil, WIL_DEFAULT_BUS_REQUEST_KBPS);
 
if (test_bit(wil_status_fwconnected, wil->status)) {
clear_bit(wil_status_fwconnected, wil->status);
@@ -555,6 +556,12 @@ int wil_priv_init(struct wil6210_priv *wil)
return -EAGAIN;
 }
 
+void wil6210_bus_request(struct wil6210_priv *wil, u32 kbps)
+{
+   if (wil->platform_ops.bus_request)
+   wil->platform_ops.bus_request(wil->platform_handle, kbps);
+}
+
 /**
  * wil6210_disconnect - disconnect one connection
  * @wil: driver context
@@ -1066,9 +1073,7 @@ int __wil_up(struct wil6210_priv *wil)
napi_enable(&wil->napi_tx);
set_bit(wil_status_napi_en, wil->status);
 
-   if (wil->platform_ops.bus_request)
-   wil->platform_ops.bus_request(wil->platform_handle,
- WIL_MAX_BUS_REQUEST_KBPS);
+   wil6210_bus_request(wil, WIL_DEFAULT_BUS_REQUEST_KBPS);
 
return 0;
 }
@@ -1092,8 +1097,7 @@ int __wil_down(struct wil6210_priv *wil)
 
set_bit(wil_status_resetting, wil->status);
 
-   if (wil->platform_ops.bus_request)
-   wil->platform_ops.bus_request(wil->platform_handle, 0);
+   wil6210_bus_request(wil, 0);
 
wil_disable_irq(wil);
if (test_and_clear_bit(wil_status_napi_en, wil->status)) {
diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h 
b/drivers/net/wireless/ath/wil6210/wil6210.h
index ea1e5b34..12de74a 100644
--- a/drivers/net/wireless/ath/wil6210/wil6210.h
+++ b/drivers/net/wireless/ath/wil6210/wil6210.h
@@ -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
@@ -40,6 +40,7 @@
 #define WIL_FW_NAME_SPARROW_PLUS "wil6210_sparrow_plus.fw" /* code Sparrow D0 
*/
 #define WIL_BOARD_FILE_NAME "wil6210.brd" /* board & radio parameters */
 
+#define WIL_DEFAULT_BUS_REQUEST_KBPS 128000 /* ~1Gbps */
 #define WIL_MAX_BUS_REQUEST_KBPS 80 /* 

[PATCH 04/10] wil6210: use print_hex_dump_debug instead of print_hex_dump_bytes

2017-02-21 Thread Maya Erez
From: Dedy Lansky 

Some dynamic debug printouts in driver are using print_hex_dump_bytes.
However, with dynamic debug disabled, print_hex_dump_bytes outputs to
log unconditionally.
Use print_hex_dump_debug instead to prevent log pollution when dynamic
debug disabled.

Signed-off-by: Dedy Lansky 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/cfg80211.c | 41 +++--
 drivers/net/wireless/ath/wil6210/wil6210.h  | 12 +
 2 files changed, 33 insertions(+), 20 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c 
b/drivers/net/wireless/ath/wil6210/cfg80211.c
index 2dc594d..581a4e2 100644
--- a/drivers/net/wireless/ath/wil6210/cfg80211.c
+++ b/drivers/net/wireless/ath/wil6210/cfg80211.c
@@ -416,9 +416,9 @@ static int wil_cfg80211_scan(struct wiphy *wiphy,
 
for (i = 0; i < request->n_ssids; i++) {
wil_dbg_misc(wil, "SSID[%d]", i);
-   print_hex_dump_bytes("SSID ", DUMP_PREFIX_OFFSET,
-request->ssids[i].ssid,
-request->ssids[i].ssid_len);
+   wil_hex_dump_misc("SSID ", DUMP_PREFIX_OFFSET, 16, 1,
+ request->ssids[i].ssid,
+ request->ssids[i].ssid_len, true);
}
 
if (request->n_ssids)
@@ -455,8 +455,8 @@ static int wil_cfg80211_scan(struct wiphy *wiphy,
}
 
if (request->ie_len)
-   print_hex_dump_bytes("Scan IE ", DUMP_PREFIX_OFFSET,
-request->ie, request->ie_len);
+   wil_hex_dump_misc("Scan IE ", DUMP_PREFIX_OFFSET, 16, 1,
+ request->ie, request->ie_len, true);
else
wil_dbg_misc(wil, "Scan has no IE's\n");
 
@@ -762,7 +762,8 @@ int wil_cfg80211_mgmt_tx(struct wiphy *wiphy, struct 
wireless_dev *wdev,
 */
 
wil_dbg_misc(wil, "mgmt_tx\n");
-   print_hex_dump_bytes("mgmt tx frame ", DUMP_PREFIX_OFFSET, buf, len);
+   wil_hex_dump_misc("mgmt tx frame ", DUMP_PREFIX_OFFSET, 16, 1, buf,
+ len, true);
 
cmd = kmalloc(sizeof(*cmd) + len, GFP_KERNEL);
if (!cmd) {
@@ -1095,18 +1096,18 @@ static int _wil_cfg80211_merge_extra_ies(const u8 
*ies1, u16 ies1_len,
 
 static void wil_print_bcon_data(struct cfg80211_beacon_data *b)
 {
-   print_hex_dump_bytes("head ", DUMP_PREFIX_OFFSET,
-b->head, b->head_len);
-   print_hex_dump_bytes("tail ", DUMP_PREFIX_OFFSET,
-b->tail, b->tail_len);
-   print_hex_dump_bytes("BCON IE  ", DUMP_PREFIX_OFFSET,
-b->beacon_ies, b->beacon_ies_len);
-   print_hex_dump_bytes("PROBE", DUMP_PREFIX_OFFSET,
-b->probe_resp, b->probe_resp_len);
-   print_hex_dump_bytes("PROBE IE ", DUMP_PREFIX_OFFSET,
-b->proberesp_ies, b->proberesp_ies_len);
-   print_hex_dump_bytes("ASSOC IE ", DUMP_PREFIX_OFFSET,
-b->assocresp_ies, b->assocresp_ies_len);
+   wil_hex_dump_misc("head ", DUMP_PREFIX_OFFSET, 16, 1,
+ b->head, b->head_len, true);
+   wil_hex_dump_misc("tail ", DUMP_PREFIX_OFFSET, 16, 1,
+ b->tail, b->tail_len, true);
+   wil_hex_dump_misc("BCON IE  ", DUMP_PREFIX_OFFSET, 16, 1,
+ b->beacon_ies, b->beacon_ies_len, true);
+   wil_hex_dump_misc("PROBE", DUMP_PREFIX_OFFSET, 16, 1,
+ b->probe_resp, b->probe_resp_len, true);
+   wil_hex_dump_misc("PROBE IE ", DUMP_PREFIX_OFFSET, 16, 1,
+ b->proberesp_ies, b->proberesp_ies_len, true);
+   wil_hex_dump_misc("ASSOC IE ", DUMP_PREFIX_OFFSET, 16, 1,
+ b->assocresp_ies, b->assocresp_ies_len, true);
 }
 
 /* internal functions for device reset and starting AP */
@@ -1302,8 +1303,8 @@ static int wil_cfg80211_start_ap(struct wiphy *wiphy,
wil_dbg_misc(wil, "BI %d DTIM %d\n", info->beacon_interval,
 info->dtim_period);
wil_dbg_misc(wil, "PBSS %d\n", info->pbss);
-   print_hex_dump_bytes("SSID ", DUMP_PREFIX_OFFSET,
-info->ssid, info->ssid_len);
+   wil_hex_dump_misc("SSID ", DUMP_PREFIX_OFFSET, 16, 1,
+ info->ssid, info->ssid_len, true);
wil_print_bcon_data(bcon);
wil_print_crypto(wil, crypto);
 
diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h 
b/drivers/net/wireless/ath/wil6210/wil6210.h
index 12de74a..89e7eb7 100644
--- a/drivers/net/wireless/ath/wil6210/wil6210.h
+++ b/drivers/net/wireless/ath/wil6210/wil6210.h
@@ -766,6 +766,12 @@ static inline void wil_c(struct wil6210_priv *wil, u32 
reg, u32 val)
 print_hex_dump_debug("DBG[ WMI]" prefix_str,\
prefix_type, row

[PATCH 05/10] wil6210: missing reinit_completion in HALP voting

2017-02-21 Thread Maya Erez
After setting HALP ICR bit, we keep it set until HALP unvote.
Masking HALP ICR should protect the driver from hitting the HALP ICR
over and over again. However, in case there is another MISC ICR
we will read the HALP ICR and issue a completion. This can lead to
a case where HALP voting is completed immediately, as the completion
is already set.
Reinit the HALP completion before the actual vote will clear previous
completions and protect from such cases.

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

diff --git a/drivers/net/wireless/ath/wil6210/main.c 
b/drivers/net/wireless/ath/wil6210/main.c
index 21b7fac..e94 100644
--- a/drivers/net/wireless/ath/wil6210/main.c
+++ b/drivers/net/wireless/ath/wil6210/main.c
@@ -1158,6 +1158,7 @@ void wil_halp_vote(struct wil6210_priv *wil)
wil->halp.ref_cnt);
 
if (++wil->halp.ref_cnt == 1) {
+   reinit_completion(&wil->halp.comp);
wil6210_set_halp(wil);
rc = wait_for_completion_timeout(&wil->halp.comp, to_jiffies);
if (!rc) {
-- 
1.9.1



[PATCH 00/10] wil6210 patches

2017-02-21 Thread Maya Erez
various wil6210 patches

Dedy Lansky (4):
  wil6210: use print_hex_dump_debug instead of print_hex_dump_bytes
  wil6210: store bss object and use cfg80211_connect_bss()
  wil6210: use WMI_DISCONNECT_CMDID upon connect timeout
  wil6210: correctly report locally generated disconnect in STA mode

Hamad Kadmany (2):
  wil6210: set dma mask to reflect device capability
  wil6210: protect list of pending wmi events during flush

Lior David (3):
  wil6210: do not start regular scan on stopped p2p device
  wil6210: bus_request platform operation refinement
  wil6210: add oob_mode for AP certification

Maya Erez (1):
  wil6210: missing reinit_completion in HALP voting

 drivers/net/wireless/ath/wil6210/cfg80211.c | 68 ++
 drivers/net/wireless/ath/wil6210/main.c | 75 +++--
 drivers/net/wireless/ath/wil6210/pcie_bus.c | 16 ++
 drivers/net/wireless/ath/wil6210/pmc.c  | 17 ++-
 drivers/net/wireless/ath/wil6210/txrx.c | 19 +++-
 drivers/net/wireless/ath/wil6210/wil6210.h  | 21 +++-
 drivers/net/wireless/ath/wil6210/wmi.c  | 21 ++--
 7 files changed, 183 insertions(+), 54 deletions(-)

-- 
1.9.1



[PATCH 01/10] wil6210: set dma mask to reflect device capability

2017-02-21 Thread Maya Erez
From: Hamad Kadmany 

device supports 48bit 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 | 16 
 drivers/net/wireless/ath/wil6210/pmc.c  | 17 -
 drivers/net/wireless/ath/wil6210/txrx.c | 19 ++-
 drivers/net/wireless/ath/wil6210/wil6210.h  |  1 +
 4 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/pcie_bus.c 
b/drivers/net/wireless/ath/wil6210/pcie_bus.c
index 874c787..b38515f 100644
--- a/drivers/net/wireless/ath/wil6210/pcie_bus.c
+++ b/drivers/net/wireless/ath/wil6210/pcie_bus.c
@@ -211,6 +211,7 @@ static int wil_pcie_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
dev_err(dev, "wil_if_alloc failed: %d\n", rc);
return rc;
}
+
wil->pdev = pdev;
pci_set_drvdata(pdev, wil);
/* rollback to if_free */
@@ -224,6 +225,21 @@ static int wil_pcie_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
}
/* rollback to err_plat */
 
+   /* 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);
+   goto err_plat;
+   }
+   } else {
+   wil->use_extended_dma_addr = 1;
+   }
+
rc = pci_enable_device(pdev);
if (rc) {
wil_err(wil,
diff --git a/drivers/net/wireless/ath/wil6210/pmc.c 
b/drivers/net/wireless/ath/wil6210/pmc.c
index 3ff4f4c..b067fdf 100644
--- a/drivers/net/wireless/ath/wil6210/pmc.c
+++ b/drivers/net/wireless/ath/wil6210/pmc.c
@@ -107,13 +107,28 @@ void wil_pmc_alloc(struct wil6210_priv *wil,
 
/* Allocate pring buffer and descriptors.
 * vring->va should be aligned on its size rounded up to power of 2
-* This is granted by the dma_alloc_coherent
+* This is granted by the dma_alloc_coherent.
+*
+* HW has limitation that all vrings addresses must share the same
+* upper 16 msb bits part of 48 bits address. To workaround that,
+* if we are using 48 bit addresses switch to 32 bit allocation
+* before allocating vring memory.
+*
+* There's no check for the return value of dma_set_mask_and_coherent,
+* since we assume if we were able to set the mask during
+* initialization in this system it will not fail if we set it again
 */
+   if (wil->use_extended_dma_addr)
+   dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
+
pmc->pring_va = dma_alloc_coherent(dev,
sizeof(struct vring_tx_desc) * num_descriptors,
&pmc->pring_pa,
GFP_KERNEL);
 
+   if (wil->use_extended_dma_addr)
+   dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48));
+
wil_dbg_misc(wil,
 "pmc_alloc: allocated pring %p => %pad. %zd x %d = total 
%zd bytes\n",
 pmc->pring_va, &pmc->pring_pa,
diff --git a/drivers/net/wireless/ath/wil6210/txrx.c 
b/drivers/net/wireless/ath/wil6210/txrx.c
index 072182e..67f50ae 100644
--- a/drivers/net/wireless/ath/wil6210/txrx.c
+++ b/drivers/net/wireless/ath/wil6210/txrx.c
@@ -123,15 +123,32 @@ static int wil_vring_alloc(struct wil6210_priv *wil, 
struct vring *vring)
vring->va = NULL;
return -ENOMEM;
}
+
/* vring->va should be aligned on its size rounded up to power of 2
-* This is granted by the dma_alloc_coherent
+* This is granted by the dma_alloc_coherent.
+*
+* HW has limitation that all vrings addresses must share the same
+* upper 16 msb bits part of 48 bits address. To workaround that,
+* if we are using 48 bit addresses switch to 32 bit allocation
+* before allocating vring memory.
+*
+* There's no check for the return value of dma_set_mask_and_coherent,
+* since we assume if we were able to set the mask during
+* initialization in this system it will not fail if we set it again
 */
+   if (wil->use_extended_dma_addr)
+   dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
+
vring->va = dma_alloc_coherent(dev, sz, &vring->pa, GFP_KERNEL);
if (!vring->va) {
kfree(vring->ctx);
vring->ctx = NULL;
return -ENOMEM;
}
+
+   if (wil->use_extended_dma_addr)
+   dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48));
+
/* initially

[PATCH 02/10] wil6210: do not start regular scan on stopped p2p device

2017-02-21 Thread Maya Erez
From: Lior David 

The driver should not allow starting any type of scan on a stopped
P2P device. Current implementation only checked social scan.

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

diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c 
b/drivers/net/wireless/ath/wil6210/cfg80211.c
index 83155b5..14aa6d3 100644
--- a/drivers/net/wireless/ath/wil6210/cfg80211.c
+++ b/drivers/net/wireless/ath/wil6210/cfg80211.c
@@ -390,22 +390,23 @@ static int wil_cfg80211_scan(struct wiphy *wiphy,
}
mutex_unlock(&wil->p2p_wdev_mutex);
 
-   /* social scan on P2P_DEVICE is handled as p2p search */
-   if (wdev->iftype == NL80211_IFTYPE_P2P_DEVICE &&
-   wil_p2p_is_social_scan(request)) {
+   if (wdev->iftype == NL80211_IFTYPE_P2P_DEVICE) {
if (!wil->p2p.p2p_dev_started) {
wil_err(wil, "P2P search requested on stopped P2P 
device\n");
rc = -EIO;
goto out;
}
-   wil->scan_request = request;
-   wil->radio_wdev = wdev;
-   rc = wil_p2p_search(wil, request);
-   if (rc) {
-   wil->radio_wdev = wil_to_wdev(wil);
-   wil->scan_request = NULL;
+   /* social scan on P2P_DEVICE is handled as p2p search */
+   if (wil_p2p_is_social_scan(request)) {
+   wil->scan_request = request;
+   wil->radio_wdev = wdev;
+   rc = wil_p2p_search(wil, request);
+   if (rc) {
+   wil->radio_wdev = wil_to_wdev(wil);
+   wil->scan_request = NULL;
+   }
+   goto out;
}
-   goto out;
}
 
(void)wil_p2p_stop_discovery(wil);
-- 
1.9.1



Re: [OpenWrt-Devel] ATH10K VLAN firmware issue

2017-02-21 Thread Valo, Kalle
voncken  writes:

> Do you know if the firmware team planned to fix the VLAN issue on ath10k
> firmware?

I reported it forward only this week.

-- 
Kalle Valo

[RFC v2 1/2] cfg80211: support 4-way handshake offloading for WPA/WPA2-PSK

2017-02-21 Thread Johannes Berg
From: Eliad Peller 

Let drivers advertise support for station-mode 4-way handshake
offloading with a new NL80211_EXT_FEATURE_4WAY_HANDSHAKE_OFFLOAD_STA
flag.

Add a new NL80211_ATTR_PMK attribute that might be passed as part
of NL80211_CMD_CONNECT command, and contain the PSK (which is the
PMK, hence the name.)

The driver/device is assumed to handle the 4-way handshake by
itself in this case (including key derivations, etc.), instead
of relying on the supplicant.

This patch is somewhat based on this one (by Vladimir Kondratiev):
https://patchwork.kernel.org/patch/1309561/.

Signed-off-by: Vladimir Kondratiev 
Signed-off-by: Eliad Peller 
Signed-off-by: Luca Coelho 
Signed-off-by: Johannes Berg 
---
 include/linux/ieee80211.h| 1 +
 include/net/cfg80211.h   | 2 ++
 include/uapi/linux/nl80211.h | 9 +
 net/wireless/nl80211.c   | 8 
 4 files changed, 20 insertions(+)

diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index 6ea381c98aae..2049e983a994 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -2357,6 +2357,7 @@ enum ieee80211_sa_query_action {
 #define WLAN_MAX_KEY_LEN   32
 
 #define WLAN_PMKID_LEN 16
+#define WLAN_PMK_LEN   32
 
 #define WLAN_OUI_WFA   0x506f9a
 #define WLAN_OUI_TYPE_WFA_P2P  9
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 86c12f85fb53..4ca968927d60 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -643,6 +643,7 @@ struct survey_info {
  * @wep_keys: static WEP keys, if not NULL points to an array of
  * CFG80211_MAX_WEP_KEYS WEP keys
  * @wep_tx_key: key index (0..3) of the default TX static WEP key
+ * @psk: PSK (for devices supporting 4-way-handshake offload)
  */
 struct cfg80211_crypto_settings {
u32 wpa_versions;
@@ -656,6 +657,7 @@ struct cfg80211_crypto_settings {
bool control_port_no_encrypt;
struct key_params *wep_keys;
int wep_tx_key;
+   const u8 *psk;
 };
 
 /**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 9a499b15cfbc..bb5e1904a107 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -2012,6 +2012,9 @@ enum nl80211_commands {
  * u32 attribute with an &enum nl80211_timeout_reason value. This is used,
  * e.g., with %NL80211_CMD_CONNECT event.
  *
+ * @NL80211_ATTR_PMK: PSK for offloaded 4-Way Handshake. Relevant only
+ * with %NL80211_CMD_CONNECT (for WPA/WPA2-PSK networks).
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2423,6 +2426,8 @@ enum nl80211_attrs {
 
NL80211_ATTR_TIMEOUT_REASON,
 
+   NL80211_ATTR_PMK,
+
/* add attributes here, update the policy in nl80211.c */
 
__NL80211_ATTR_AFTER_LAST,
@@ -4759,6 +4764,9 @@ enum nl80211_feature_flags {
  * @NL80211_EXT_FEATURE_CQM_RSSI_LIST: With this driver the
  * %NL80211_ATTR_CQM_RSSI_THOLD attribute accepts a list of zero or more
  * RSSI threshold values to monitor rather than exactly one threshold.
+ * @NL80211_EXT_FEATURE_4WAY_HANDSHAKE_STA_PSK: Device supports doing 4-way
+ * handshake with PSK in station mode (PSK is passed as part of the connect
+ * and associate commands).
  *
  * @NUM_NL80211_EXT_FEATURES: number of extended features.
  * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
@@ -4778,6 +4786,7 @@ enum nl80211_ext_feature_index {
NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA_CONNECTED,
NL80211_EXT_FEATURE_SCHED_SCAN_RELATIVE_RSSI,
NL80211_EXT_FEATURE_CQM_RSSI_LIST,
+   NL80211_EXT_FEATURE_4WAY_HANDSHAKE_STA_PSK,
 
/* add new features before the definition below */
NUM_NL80211_EXT_FEATURES,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index d516527fcb8e..494b50b3eb71 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -410,6 +410,7 @@ static const struct nla_policy 
nl80211_policy[NUM_NL80211_ATTR] = {
.len = sizeof(struct nl80211_bss_select_rssi_adjust)
},
[NL80211_ATTR_TIMEOUT_REASON] = { .type = NLA_U32 },
+   [NL80211_ATTR_PMK] = { .len = WLAN_PMK_LEN },
 };
 
 /* policy for the key attributes */
@@ -8039,6 +8040,13 @@ static int nl80211_crypto_settings(struct 
cfg80211_registered_device *rdev,
memcpy(settings->akm_suites, data, len);
}
 
+   if (info->attrs[NL80211_ATTR_PMK]) {
+   if (!wiphy_ext_feature_isset(&rdev->wiphy,
+
NL80211_EXT_FEATURE_4WAY_HANDSHAKE_STA_PSK))
+   return -EINVAL;
+   settings->psk = nla_data(info->attrs[NL80211_ATTR_PMK]);
+   }
+
return 0;
 }
 
-- 
2.9.3



[RFC v2 2/2] cfg80211: support 4-way handshake offloading for 802.1X

2017-02-21 Thread Johannes Berg
From: Avraham Stern 

Add API for setting the PMK to the driver. For FT support, allow
setting also the PMK-R0 Name.

This can be used by drivers that support 4-Way handshake offload
while IEEE802.1X authentication is managed by upper layers.

Signed-off-by: Avraham Stern 
Signed-off-by: Johannes Berg 
---
 include/linux/ieee80211.h|  3 ++
 include/net/cfg80211.h   | 27 
 include/uapi/linux/nl80211.h | 24 ++-
 net/wireless/core.c  |  5 +++
 net/wireless/nl80211.c   | 99 
 net/wireless/rdev-ops.h  | 25 +++
 net/wireless/trace.h | 60 +++
 7 files changed, 241 insertions(+), 2 deletions(-)

diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index 2049e983a994..fb1f533e75b3 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -2356,8 +2356,11 @@ enum ieee80211_sa_query_action {
 
 #define WLAN_MAX_KEY_LEN   32
 
+#define WLAN_PMK_NAME_LEN  16
 #define WLAN_PMKID_LEN 16
+#define WLAN_PMK_LEN_EAP_LEAP  16
 #define WLAN_PMK_LEN   32
+#define WLAN_PMK_LEN_SUITE_B_192   48
 
 #define WLAN_OUI_WFA   0x506f9a
 #define WLAN_OUI_TYPE_WFA_P2P  9
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 4ca968927d60..a68c6db6ac55 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -2507,6 +2507,23 @@ struct cfg80211_nan_func {
 };
 
 /**
+ * struct cfg80211_pmk_conf - PMK configuration
+ *
+ * @aa: authenticator address
+ * @pmk_len: PMK length in bytes.
+ * @pmk: the PMK material
+ * @pmk_r0_name: PMK-R0 Name. NULL if not applicable (i.e., the PMK
+ * is not PMK-R0). When pmk_r0_name is not NULL, the pmk field
+ * holds PMK-R0.
+ */
+struct cfg80211_pmk_conf {
+   const u8 *aa;
+   u8 pmk_len;
+   const u8 *pmk;
+   const u8 *pmk_r0_name;
+};
+
+/**
  * struct cfg80211_ops - backend description for wireless configuration
  *
  * This struct is registered by fullmac card drivers and/or wireless stacks
@@ -2823,6 +2840,11 @@ struct cfg80211_nan_func {
  * All other parameters must be ignored.
  *
  * @set_multicast_to_unicast: configure multicast to unicast conversion for BSS
+ *
+ * @set_pmk: configure the PMK to be used for offloaded 4-Way handshake.
+ * (invoked with the wireless_dev mutex held)
+ * @del_pmk: delete the previously configured PMK for the given authenticator.
+ * (invoked with the wireless_dev mutex held)
  */
 struct cfg80211_ops {
int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -3111,6 +3133,11 @@ struct cfg80211_ops {
int (*set_multicast_to_unicast)(struct wiphy *wiphy,
struct net_device *dev,
const bool enabled);
+
+   int (*set_pmk)(struct wiphy *wiphy, struct net_device *dev,
+  const struct cfg80211_pmk_conf *conf);
+   int (*del_pmk)(struct wiphy *wiphy, struct net_device *dev,
+  const u8 *aa);
 };
 
 /*
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index bb5e1904a107..89295fc2336b 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -901,6 +901,14 @@
  * does not result in a change for the current association. Currently,
  * only the %NL80211_ATTR_IE data is used and updated with this command.
  *
+ * @NL80211_CMD_SET_PMK: For offloaded 4-Way handshake, set the PMK or PMK-R0
+ * for the given authenticator address (specified with &NL80211_ATTR_MAC).
+ * When &NL80211_ATTR_PMKR0_NAME is set, &NL80211_ATTR_PMK specifies the
+ * PMK-R0, otherwise it specifies the PMK.
+ * @NL80211_CMD_DEL_PMK: For offloaded 4-Way handshake, delete the previously
+ * configured PMK for the authenticator address identified by
+ * &NL80211_ATTR_MAC.
+ *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
  */
@@ -1100,6 +1108,9 @@ enum nl80211_commands {
 
NL80211_CMD_UPDATE_CONNECT_PARAMS,
 
+   NL80211_CMD_SET_PMK,
+   NL80211_CMD_DEL_PMK,
+
/* add new commands above here */
 
/* used to define NL80211_CMD_MAX below */
@@ -2012,8 +2023,12 @@ enum nl80211_commands {
  * u32 attribute with an &enum nl80211_timeout_reason value. This is used,
  * e.g., with %NL80211_CMD_CONNECT event.
  *
- * @NL80211_ATTR_PMK: PSK for offloaded 4-Way Handshake. Relevant only
- * with %NL80211_CMD_CONNECT (for WPA/WPA2-PSK networks).
+ * @NL80211_ATTR_PMK: PMK for offloaded 4-Way Handshake. Relevant with
+ * %NL80211_CMD_CONNECT (for WPA/WPA2-PSK networks) when PSK is used, or
+ * with %NL80211_CMD_SET_PMK when 802.1X authentication is used.
+ * When &NL80211_ATTR_PMKR0_NAME is specified, this attribute specifies
+ * the PMK-R0.
+ * @NL80211_ATTR_PM

Re: [PATCH] cfg80211: support 4-way handshake offloading for WPA/WPA2-PSK

2017-02-21 Thread Johannes Berg

> What I am also missing is how to deal with NL80211_CMD_CONNECTED
> event signalling. Should that be given after (un)successful
> completion of the 4-way handshake or should we have a separate event
> for that? 

That's a good point. I don't think a new event really works well, but
perhaps we should extend the NL80211_TIMEOUT_* values with this? It's
not strictly a timeout, I guess, but it's not a direct rejection of the
association either.

Any thoughts?

johannes


Re: [PATCH] cfg80211: support 4-way handshake offloading for WPA/WPA2-PSK

2017-02-21 Thread Arend Van Spriel


On 21-2-2017 12:46, Johannes Berg wrote:
> 
 Would this work for you? We should have wpa_supplicant support
 too, but need to ask Andrei to look at that.
>>
>> Forgot to reply to this. Yes, this will work. Can come up with
>> wpa_supp changes.
> 
> No, we have them. Just need to see where they are :)

I see. Will keep an eye on hostapd list ;-)

Gr. AvS


Re: [PATCH] cfg80211: support 4-way handshake offloading for WPA/WPA2-PSK

2017-02-21 Thread Johannes Berg

> > > Would this work for you? We should have wpa_supplicant support
> > > too, but need to ask Andrei to look at that.
> 
> Forgot to reply to this. Yes, this will work. Can come up with
> wpa_supp changes.

No, we have them. Just need to see where they are :)

johannes


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

2017-02-21 Thread Kalle Valo
Arend Van Spriel  writes:

> On 21-2-2017 10:47, Rafał Miłecki wrote:
>> From: Rafał Miłecki 
>> 
>> Failing to load NVRAM file isn't critical if we manage to get platform
>> one 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. This is
>> very common case for Broadcom home routers.
>> 
>> So instead of printing warning immediately with the firmware subsystem
>> let's first try our fallback code. 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.
>
> I think FW_OPT_NO_WARN does not cover all warnings in firmware_class
> although I did not check. Anyway...
>
> Acked-by: Arend van Spriel 

Acked-by: Kalle Valo 

Feel free to this via some another tree.

-- 
Kalle Valo


Re: [PATCH] cfg80211: support 4-way handshake offloading for WPA/WPA2-PSK

2017-02-21 Thread Arend Van Spriel


On 21-2-2017 12:34, Arend Van Spriel wrote:
> On 21-2-2017 11:40, Johannes Berg wrote:
>> On Tue, 2017-02-21 at 11:32 +0100, Arend Van Spriel wrote:
>>> On 21-2-2017 11:09, Johannes Berg wrote:
 From: Eliad Peller 

 Let drivers advertise support for station-mode 4-way handshake
 offloading with a new
 NL80211_EXT_FEATURE_4WAY_HANDSHAKE_OFFLOAD_STA
 flag.
>>>
>>> I find use of the term OFFLOAD a bit redundant as it is implied by
>>> its presence anyway.
>>
>> Fair enough, we can remove that.
>>
 Add a new NL80211_ATTR_PMK attribute that might be passed as part
 of NL80211_CMD_CONNECT command, and contain the PSK (which is the
 PMK, hence the name.)
> 
> It is also added to NL80211_CMD_ASSOCIATE. Maybe worth mentioning.
> 
 The driver/device is assumed to handle the 4-way handshake by
 itself in this case (including key derivations, etc.), instead
 of relying on the supplicant.
> 
> What I am also missing is how to deal with NL80211_CMD_CONNECTED event
> signalling. Should that be given after (un)successful completion of the
> 4-way handshake or should we have a separate event for that?
> 
> Regards,
> Arend
> 
 This patch is somewhat based on this one (by Vladimir Kondratiev):
 https://patchwork.kernel.org/patch/1309561/.
>>>
>>> It also looks quite like this one we posted a while ago [1]. Our bad
>>> that we did not follow-up :-p
>>
>> Indeed, I was looking for the better link (had gmane recorded in the
>> internal commit log) and found a few that all looked the same ... :)
>>
>> Would this work for you? We should have wpa_supplicant support too, but
>> need to ask Andrei to look at that.

Forgot to reply to this. Yes, this will work. Can come up with wpa_supp
changes.

Regards,
Arend


Re: [PATCH] cfg80211: support 4-way handshake offloading for WPA/WPA2-PSK

2017-02-21 Thread Arend Van Spriel
On 21-2-2017 11:40, Johannes Berg wrote:
> On Tue, 2017-02-21 at 11:32 +0100, Arend Van Spriel wrote:
>> On 21-2-2017 11:09, Johannes Berg wrote:
>>> From: Eliad Peller 
>>>
>>> Let drivers advertise support for station-mode 4-way handshake
>>> offloading with a new
>>> NL80211_EXT_FEATURE_4WAY_HANDSHAKE_OFFLOAD_STA
>>> flag.
>>
>> I find use of the term OFFLOAD a bit redundant as it is implied by
>> its presence anyway.
> 
> Fair enough, we can remove that.
> 
>>> Add a new NL80211_ATTR_PMK attribute that might be passed as part
>>> of NL80211_CMD_CONNECT command, and contain the PSK (which is the
>>> PMK, hence the name.)

It is also added to NL80211_CMD_ASSOCIATE. Maybe worth mentioning.

>>> The driver/device is assumed to handle the 4-way handshake by
>>> itself in this case (including key derivations, etc.), instead
>>> of relying on the supplicant.

What I am also missing is how to deal with NL80211_CMD_CONNECTED event
signalling. Should that be given after (un)successful completion of the
4-way handshake or should we have a separate event for that?

Regards,
Arend

>>> This patch is somewhat based on this one (by Vladimir Kondratiev):
>>> https://patchwork.kernel.org/patch/1309561/.
>>
>> It also looks quite like this one we posted a while ago [1]. Our bad
>> that we did not follow-up :-p
> 
> Indeed, I was looking for the better link (had gmane recorded in the
> internal commit log) and found a few that all looked the same ... :)
> 
> Would this work for you? We should have wpa_supplicant support too, but
> need to ask Andrei to look at that.
> 
> johannes
> 


Re: [PATCH] cfg80211: support 4-way handshake offloading for WPA/WPA2-PSK

2017-02-21 Thread Johannes Berg
On Tue, 2017-02-21 at 11:32 +0100, Arend Van Spriel wrote:
> On 21-2-2017 11:09, Johannes Berg wrote:
> > From: Eliad Peller 
> > 
> > Let drivers advertise support for station-mode 4-way handshake
> > offloading with a new
> > NL80211_EXT_FEATURE_4WAY_HANDSHAKE_OFFLOAD_STA
> > flag.
> 
> I find use of the term OFFLOAD a bit redundant as it is implied by
> its presence anyway.

Fair enough, we can remove that.

> > Add a new NL80211_ATTR_PMK attribute that might be passed as part
> > of NL80211_CMD_CONNECT command, and contain the PSK (which is the
> > PMK, hence the name.)
> > 
> > The driver/device is assumed to handle the 4-way handshake by
> > itself in this case (including key derivations, etc.), instead
> > of relying on the supplicant.
> > 
> > This patch is somewhat based on this one (by Vladimir Kondratiev):
> > https://patchwork.kernel.org/patch/1309561/.
> 
> It also looks quite like this one we posted a while ago [1]. Our bad
> that we did not follow-up :-p

Indeed, I was looking for the better link (had gmane recorded in the
internal commit log) and found a few that all looked the same ... :)

Would this work for you? We should have wpa_supplicant support too, but
need to ask Andrei to look at that.

johannes


Re: [PATCH] cfg80211: support 4-way handshake offloading for WPA/WPA2-PSK

2017-02-21 Thread Arend Van Spriel
On 21-2-2017 11:09, Johannes Berg wrote:
> From: Eliad Peller 
> 
> Let drivers advertise support for station-mode 4-way handshake
> offloading with a new NL80211_EXT_FEATURE_4WAY_HANDSHAKE_OFFLOAD_STA
> flag.

I find use of the term OFFLOAD a bit redundant as it is implied by its
presence anyway.

> Add a new NL80211_ATTR_PMK attribute that might be passed as part
> of NL80211_CMD_CONNECT command, and contain the PSK (which is the
> PMK, hence the name.)
> 
> The driver/device is assumed to handle the 4-way handshake by
> itself in this case (including key derivations, etc.), instead
> of relying on the supplicant.
> 
> This patch is somewhat based on this one (by Vladimir Kondratiev):
> https://patchwork.kernel.org/patch/1309561/.

It also looks quite like this one we posted a while ago [1]. Our bad
that we did not follow-up :-p

Thanks,
Arend

[1] https://www.spinics.net/lists/linux-wireless/msg129387.html

> Signed-off-by: Vladimir Kondratiev 
> Signed-off-by: Eliad Peller 
> Signed-off-by: Luca Coelho 
> Signed-off-by: Johannes Berg 
> ---
>  include/linux/ieee80211.h| 1 +
>  include/net/cfg80211.h   | 2 ++
>  include/uapi/linux/nl80211.h | 9 +
>  net/wireless/nl80211.c   | 8 
>  4 files changed, 20 insertions(+)
> 
> diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
> index 6ea381c98aae..2049e983a994 100644
> --- a/include/linux/ieee80211.h
> +++ b/include/linux/ieee80211.h
> @@ -2357,6 +2357,7 @@ enum ieee80211_sa_query_action {
>  #define WLAN_MAX_KEY_LEN 32
>  
>  #define WLAN_PMKID_LEN   16
> +#define WLAN_PMK_LEN 32
>  
>  #define WLAN_OUI_WFA 0x506f9a
>  #define WLAN_OUI_TYPE_WFA_P2P9
> diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
> index 86c12f85fb53..4ca968927d60 100644
> --- a/include/net/cfg80211.h
> +++ b/include/net/cfg80211.h
> @@ -643,6 +643,7 @@ struct survey_info {
>   * @wep_keys: static WEP keys, if not NULL points to an array of
>   *   CFG80211_MAX_WEP_KEYS WEP keys
>   * @wep_tx_key: key index (0..3) of the default TX static WEP key
> + * @psk: PSK (for devices supporting 4-way-handshake offload)
>   */
>  struct cfg80211_crypto_settings {
>   u32 wpa_versions;
> @@ -656,6 +657,7 @@ struct cfg80211_crypto_settings {
>   bool control_port_no_encrypt;
>   struct key_params *wep_keys;
>   int wep_tx_key;
> + const u8 *psk;
>  };
>  
>  /**
> diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
> index 9a499b15cfbc..ba102c937750 100644
> --- a/include/uapi/linux/nl80211.h
> +++ b/include/uapi/linux/nl80211.h
> @@ -2012,6 +2012,9 @@ enum nl80211_commands {
>   *   u32 attribute with an &enum nl80211_timeout_reason value. This is used,
>   *   e.g., with %NL80211_CMD_CONNECT event.
>   *
> + * @NL80211_ATTR_PMK: PSK for offloaded 4-Way Handshake. Relevant only
> + *   with %NL80211_CMD_CONNECT (for WPA/WPA2-PSK networks).
> + *
>   * @NUM_NL80211_ATTR: total number of nl80211_attrs available
>   * @NL80211_ATTR_MAX: highest attribute number currently defined
>   * @__NL80211_ATTR_AFTER_LAST: internal use
> @@ -2423,6 +2426,8 @@ enum nl80211_attrs {
>  
>   NL80211_ATTR_TIMEOUT_REASON,
>  
> + NL80211_ATTR_PMK,
> +
>   /* add attributes here, update the policy in nl80211.c */
>  
>   __NL80211_ATTR_AFTER_LAST,
> @@ -4759,6 +4764,9 @@ enum nl80211_feature_flags {
>   * @NL80211_EXT_FEATURE_CQM_RSSI_LIST: With this driver the
>   *   %NL80211_ATTR_CQM_RSSI_THOLD attribute accepts a list of zero or more
>   *   RSSI threshold values to monitor rather than exactly one threshold.
> + * @NL80211_EXT_FEATURE_4WAY_HANDSHAKE_OFFLOAD_STA: Device supports
> + *   doing 4-way handshake in station mode (PSK is passed as part
> + *   of the connect command).
>   *
>   * @NUM_NL80211_EXT_FEATURES: number of extended features.
>   * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
> @@ -4778,6 +4786,7 @@ enum nl80211_ext_feature_index {
>   NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA_CONNECTED,
>   NL80211_EXT_FEATURE_SCHED_SCAN_RELATIVE_RSSI,
>   NL80211_EXT_FEATURE_CQM_RSSI_LIST,
> + NL80211_EXT_FEATURE_4WAY_HANDSHAKE_OFFLOAD_STA,
>  
>   /* add new features before the definition below */
>   NUM_NL80211_EXT_FEATURES,
> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
> index d516527fcb8e..34b551edbc4f 100644
> --- a/net/wireless/nl80211.c
> +++ b/net/wireless/nl80211.c
> @@ -410,6 +410,7 @@ static const struct nla_policy 
> nl80211_policy[NUM_NL80211_ATTR] = {
>   .len = sizeof(struct nl80211_bss_select_rssi_adjust)
>   },
>   [NL80211_ATTR_TIMEOUT_REASON] = { .type = NLA_U32 },
> + [NL80211_ATTR_PMK] = { .len = WLAN_PMK_LEN },
>  };
>  
>  /* policy for the key attributes */
> @@ -8039,6 +8040,13 @@ static int nl80211_crypto_settings(struct 
> cfg80211_registered_device *rdev,
>   memcpy(settings->akm_suites, data, len);
>   }

[RFC] mac80211_hwsim: report survey data for scanned channels

2017-02-21 Thread Johannes Berg
From: Johannes Berg 

Currently, hwsim is reporting survey data (only a fake noise floor)
for the current channel. This breaks when the multi-channel support
is enabled since then there's no current channel.

Make the dummy implementation closer to a real one and only report
data while scanning, for all the scanned channels. At other times,
no survey data might be available (in real hardware) due to power-
save for example.

Signed-off-by: Johannes Berg 
---
Had this lying around - is it useful for anyone?
---
 drivers/net/wireless/mac80211_hwsim.c | 73 ---
 1 file changed, 60 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c 
b/drivers/net/wireless/mac80211_hwsim.c
index 0150747c79ac..5a636b09320b 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -525,6 +525,11 @@ struct mac80211_hwsim_data {
struct ieee80211_vif *hw_scan_vif;
int scan_chan_idx;
u8 scan_addr[ETH_ALEN];
+   struct {
+   struct ieee80211_channel *channel;
+   unsigned long next_start, start, end;
+   } survey_data[ARRAY_SIZE(hwsim_channels_2ghz) +
+ ARRAY_SIZE(hwsim_channels_5ghz)];
 
struct ieee80211_channel *channel;
u64 beacon_int  /* beacon interval in us */;
@@ -1576,6 +1581,7 @@ static int mac80211_hwsim_config(struct ieee80211_hw *hw, 
u32 changed)
[IEEE80211_SMPS_STATIC] = "static",
[IEEE80211_SMPS_DYNAMIC] = "dynamic",
};
+   int idx;
 
if (conf->chandef.chan)
wiphy_debug(hw->wiphy,
@@ -1598,9 +1604,33 @@ static int mac80211_hwsim_config(struct ieee80211_hw 
*hw, u32 changed)
 
data->idle = !!(conf->flags & IEEE80211_CONF_IDLE);
 
-   data->channel = conf->chandef.chan;
+   WARN_ON(conf->chandef.chan && data->use_chanctx);
+
+   mutex_lock(&data->mutex);
+   if (data->scanning && conf->chandef.chan) {
+   for (idx = 0; idx < ARRAY_SIZE(data->survey_data); idx++) {
+   if (data->survey_data[idx].channel == data->channel) {
+   data->survey_data[idx].start =
+   data->survey_data[idx].next_start;
+   data->survey_data[idx].end = jiffies;
+   break;
+   }
+   }
 
-   WARN_ON(data->channel && data->use_chanctx);
+   data->channel = conf->chandef.chan;
+
+   for (idx = 0; idx < ARRAY_SIZE(data->survey_data); idx++) {
+   if (data->survey_data[idx].channel &&
+   data->survey_data[idx].channel != data->channel)
+   continue;
+   data->survey_data[idx].channel = data->channel;
+   data->survey_data[idx].next_start = jiffies;
+   break;
+   }
+   } else {
+   data->channel = conf->chandef.chan;
+   }
+   mutex_unlock(&data->mutex);
 
data->power_level = conf->power_level;
if (!data->started || !data->beacon_int)
@@ -1787,28 +1817,39 @@ static int mac80211_hwsim_conf_tx(
return 0;
 }
 
-static int mac80211_hwsim_get_survey(
-   struct ieee80211_hw *hw, int idx,
-   struct survey_info *survey)
+static int mac80211_hwsim_get_survey(struct ieee80211_hw *hw, int idx,
+struct survey_info *survey)
 {
-   struct ieee80211_conf *conf = &hw->conf;
+   struct mac80211_hwsim_data *hwsim = hw->priv;
 
wiphy_debug(hw->wiphy, "%s (idx=%d)\n", __func__, idx);
 
-   if (idx != 0)
+   if (idx < 0 || idx >= ARRAY_SIZE(hwsim->survey_data))
return -ENOENT;
 
-   /* Current channel */
-   survey->channel = conf->chandef.chan;
+   mutex_lock(&hwsim->mutex);
+   survey->channel = hwsim->survey_data[idx].channel;
+   if (!survey->channel) {
+   mutex_unlock(&hwsim->mutex);
+   return -ENOENT;
+   }
 
/*
-* Magically conjured noise level --- this is only ok for simulated 
hardware.
+* Magically conjured dummy values --- this is only ok for simulated 
hardware.
 *
-* A real driver which cannot determine the real channel noise MUST NOT
-* report any noise, especially not a magically conjured one :-)
+* A real driver which cannot determine real values noise MUST NOT
+* report any, especially not a magically conjured ones :-)
 */
-   survey->filled = SURVEY_INFO_NOISE_DBM;
+   survey->filled = SURVEY_INFO_NOISE_DBM |
+SURVEY_INFO_CHANNEL_TIME |
+SURVEY_INFO_CHANNEL_TIME_BUSY;
survey->noise = -92;
+   survey->channel_time =
+   jiffies_to_msecs(hwsim->survey_data[idx].end -
+ 

[PATCH v2] ath10k: Remove return statement from a void function

2017-02-21 Thread Marcin Rokicki
The empty 'return;' statement in a void function should be
used to return from somewhere else than the end.

Signed-off-by: Marcin Rokicki 
---

Changes for v2
 -remove only return statement instead of empty err label
  which can be used in the future

---
 drivers/net/wireless/ath/ath10k/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 59729aa..a22d3c9 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -2311,7 +2311,7 @@ static void ath10k_core_register_work(struct work_struct 
*work)
/* TODO: It's probably a good idea to release device from the driver
 * but calling device_release_driver() here will cause a deadlock.
 */
-   return;
+   ;
 }
 
 int ath10k_core_register(struct ath10k *ar, u32 chip_id)
-- 
2.7.4



[RFC] nl80211/cfg80211: Add API for setting the PMK to the driver

2017-02-21 Thread Johannes Berg
From: Avraham Stern 

Add API for setting the PMK to the driver. For FT support, allow
setting also the PMK-R0 Name.

This can be used by drivers that support 4-Way handshake offload
while IEEE802.1X authentication is managed by upper layers.

Signed-off-by: Avraham Stern 
Signed-off-by: Johannes Berg 
---
We reused the PSK feature bit here since the 4-way-HS is the same,
but perhaps we should split it if some firmware/driver can't or
doesn't want to implement both?
---
 include/linux/ieee80211.h|  3 ++
 include/net/cfg80211.h   | 27 
 include/uapi/linux/nl80211.h | 23 --
 net/wireless/nl80211.c   | 99 
 net/wireless/rdev-ops.h  | 25 +++
 net/wireless/trace.h | 60 +++
 6 files changed, 234 insertions(+), 3 deletions(-)

diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index 2049e983a994..fb1f533e75b3 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -2356,8 +2356,11 @@ enum ieee80211_sa_query_action {
 
 #define WLAN_MAX_KEY_LEN   32
 
+#define WLAN_PMK_NAME_LEN  16
 #define WLAN_PMKID_LEN 16
+#define WLAN_PMK_LEN_EAP_LEAP  16
 #define WLAN_PMK_LEN   32
+#define WLAN_PMK_LEN_SUITE_B_192   48
 
 #define WLAN_OUI_WFA   0x506f9a
 #define WLAN_OUI_TYPE_WFA_P2P  9
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 4ca968927d60..a68c6db6ac55 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -2507,6 +2507,23 @@ struct cfg80211_nan_func {
 };
 
 /**
+ * struct cfg80211_pmk_conf - PMK configuration
+ *
+ * @aa: authenticator address
+ * @pmk_len: PMK length in bytes.
+ * @pmk: the PMK material
+ * @pmk_r0_name: PMK-R0 Name. NULL if not applicable (i.e., the PMK
+ * is not PMK-R0). When pmk_r0_name is not NULL, the pmk field
+ * holds PMK-R0.
+ */
+struct cfg80211_pmk_conf {
+   const u8 *aa;
+   u8 pmk_len;
+   const u8 *pmk;
+   const u8 *pmk_r0_name;
+};
+
+/**
  * struct cfg80211_ops - backend description for wireless configuration
  *
  * This struct is registered by fullmac card drivers and/or wireless stacks
@@ -2823,6 +2840,11 @@ struct cfg80211_nan_func {
  * All other parameters must be ignored.
  *
  * @set_multicast_to_unicast: configure multicast to unicast conversion for BSS
+ *
+ * @set_pmk: configure the PMK to be used for offloaded 4-Way handshake.
+ * (invoked with the wireless_dev mutex held)
+ * @del_pmk: delete the previously configured PMK for the given authenticator.
+ * (invoked with the wireless_dev mutex held)
  */
 struct cfg80211_ops {
int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -3111,6 +3133,11 @@ struct cfg80211_ops {
int (*set_multicast_to_unicast)(struct wiphy *wiphy,
struct net_device *dev,
const bool enabled);
+
+   int (*set_pmk)(struct wiphy *wiphy, struct net_device *dev,
+  const struct cfg80211_pmk_conf *conf);
+   int (*del_pmk)(struct wiphy *wiphy, struct net_device *dev,
+  const u8 *aa);
 };
 
 /*
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index ba102c937750..6ca7fb4a3d71 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -901,6 +901,14 @@
  * does not result in a change for the current association. Currently,
  * only the %NL80211_ATTR_IE data is used and updated with this command.
  *
+ * @NL80211_CMD_SET_PMK: For offloaded 4-Way handshake, set the PMK or PMK-R0
+ * for the given authenticator address (specified with &NL80211_ATTR_MAC).
+ * When &NL80211_ATTR_PMKR0_NAME is set, &NL80211_ATTR_PMK specifies the
+ * PMK-R0, otherwise it specifies the PMK.
+ * @NL80211_CMD_DEL_PMK: For offloaded 4-Way handshake, delete the previously
+ * configured PMK for the authenticator address identified by
+ * &NL80211_ATTR_MAC.
+ *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
  */
@@ -1100,6 +1108,9 @@ enum nl80211_commands {
 
NL80211_CMD_UPDATE_CONNECT_PARAMS,
 
+   NL80211_CMD_SET_PMK,
+   NL80211_CMD_DEL_PMK,
+
/* add new commands above here */
 
/* used to define NL80211_CMD_MAX below */
@@ -2012,8 +2023,12 @@ enum nl80211_commands {
  * u32 attribute with an &enum nl80211_timeout_reason value. This is used,
  * e.g., with %NL80211_CMD_CONNECT event.
  *
- * @NL80211_ATTR_PMK: PSK for offloaded 4-Way Handshake. Relevant only
- * with %NL80211_CMD_CONNECT (for WPA/WPA2-PSK networks).
+ * @NL80211_ATTR_PMK: PMK for offloaded 4-Way Handshake. Relevant with
+ * %NL80211_CMD_CONNECT (for WPA/WPA2-PSK networks) when PSK is used, or
+ * with %NL80211_CMD_SET_PMK when 802.1X authentication

[PATCH] cfg80211: support 4-way handshake offloading for WPA/WPA2-PSK

2017-02-21 Thread Johannes Berg
From: Eliad Peller 

Let drivers advertise support for station-mode 4-way handshake
offloading with a new NL80211_EXT_FEATURE_4WAY_HANDSHAKE_OFFLOAD_STA
flag.

Add a new NL80211_ATTR_PMK attribute that might be passed as part
of NL80211_CMD_CONNECT command, and contain the PSK (which is the
PMK, hence the name.)

The driver/device is assumed to handle the 4-way handshake by
itself in this case (including key derivations, etc.), instead
of relying on the supplicant.

This patch is somewhat based on this one (by Vladimir Kondratiev):
https://patchwork.kernel.org/patch/1309561/.

Signed-off-by: Vladimir Kondratiev 
Signed-off-by: Eliad Peller 
Signed-off-by: Luca Coelho 
Signed-off-by: Johannes Berg 
---
 include/linux/ieee80211.h| 1 +
 include/net/cfg80211.h   | 2 ++
 include/uapi/linux/nl80211.h | 9 +
 net/wireless/nl80211.c   | 8 
 4 files changed, 20 insertions(+)

diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index 6ea381c98aae..2049e983a994 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -2357,6 +2357,7 @@ enum ieee80211_sa_query_action {
 #define WLAN_MAX_KEY_LEN   32
 
 #define WLAN_PMKID_LEN 16
+#define WLAN_PMK_LEN   32
 
 #define WLAN_OUI_WFA   0x506f9a
 #define WLAN_OUI_TYPE_WFA_P2P  9
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 86c12f85fb53..4ca968927d60 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -643,6 +643,7 @@ struct survey_info {
  * @wep_keys: static WEP keys, if not NULL points to an array of
  * CFG80211_MAX_WEP_KEYS WEP keys
  * @wep_tx_key: key index (0..3) of the default TX static WEP key
+ * @psk: PSK (for devices supporting 4-way-handshake offload)
  */
 struct cfg80211_crypto_settings {
u32 wpa_versions;
@@ -656,6 +657,7 @@ struct cfg80211_crypto_settings {
bool control_port_no_encrypt;
struct key_params *wep_keys;
int wep_tx_key;
+   const u8 *psk;
 };
 
 /**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 9a499b15cfbc..ba102c937750 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -2012,6 +2012,9 @@ enum nl80211_commands {
  * u32 attribute with an &enum nl80211_timeout_reason value. This is used,
  * e.g., with %NL80211_CMD_CONNECT event.
  *
+ * @NL80211_ATTR_PMK: PSK for offloaded 4-Way Handshake. Relevant only
+ * with %NL80211_CMD_CONNECT (for WPA/WPA2-PSK networks).
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2423,6 +2426,8 @@ enum nl80211_attrs {
 
NL80211_ATTR_TIMEOUT_REASON,
 
+   NL80211_ATTR_PMK,
+
/* add attributes here, update the policy in nl80211.c */
 
__NL80211_ATTR_AFTER_LAST,
@@ -4759,6 +4764,9 @@ enum nl80211_feature_flags {
  * @NL80211_EXT_FEATURE_CQM_RSSI_LIST: With this driver the
  * %NL80211_ATTR_CQM_RSSI_THOLD attribute accepts a list of zero or more
  * RSSI threshold values to monitor rather than exactly one threshold.
+ * @NL80211_EXT_FEATURE_4WAY_HANDSHAKE_OFFLOAD_STA: Device supports
+ * doing 4-way handshake in station mode (PSK is passed as part
+ * of the connect command).
  *
  * @NUM_NL80211_EXT_FEATURES: number of extended features.
  * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
@@ -4778,6 +4786,7 @@ enum nl80211_ext_feature_index {
NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA_CONNECTED,
NL80211_EXT_FEATURE_SCHED_SCAN_RELATIVE_RSSI,
NL80211_EXT_FEATURE_CQM_RSSI_LIST,
+   NL80211_EXT_FEATURE_4WAY_HANDSHAKE_OFFLOAD_STA,
 
/* add new features before the definition below */
NUM_NL80211_EXT_FEATURES,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index d516527fcb8e..34b551edbc4f 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -410,6 +410,7 @@ static const struct nla_policy 
nl80211_policy[NUM_NL80211_ATTR] = {
.len = sizeof(struct nl80211_bss_select_rssi_adjust)
},
[NL80211_ATTR_TIMEOUT_REASON] = { .type = NLA_U32 },
+   [NL80211_ATTR_PMK] = { .len = WLAN_PMK_LEN },
 };
 
 /* policy for the key attributes */
@@ -8039,6 +8040,13 @@ static int nl80211_crypto_settings(struct 
cfg80211_registered_device *rdev,
memcpy(settings->akm_suites, data, len);
}
 
+   if (info->attrs[NL80211_ATTR_PMK]) {
+   if (!wiphy_ext_feature_isset(&rdev->wiphy,
+
NL80211_EXT_FEATURE_4WAY_HANDSHAKE_OFFLOAD_STA))
+   return -EINVAL;
+   settings->psk = nla_data(info->attrs[NL80211_ATTR_PMK]);
+   }
+
return 0;
 }
 
-- 
2.9.3



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

2017-02-21 Thread Arend Van Spriel
On 21-2-2017 10:47, Rafał Miłecki wrote:
> From: Rafał Miłecki 
> 
> Failing to load NVRAM file isn't critical if we manage to get platform
> one 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. This is
> very common case for Broadcom home routers.
> 
> So instead of printing warning immediately with the firmware subsystem
> let's first try our fallback code. 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.

I think FW_OPT_NO_WARN does not cover all warnings in firmware_class
although I did not check. Anyway...

Acked-by: Arend van Spriel 
> 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
> 
> Kalle, Arend: this patch is strictly related to the bigger 1/2. Could you ack
> this change as I expect this patchset to be picked by Ming, Luis or Greg?
> ---
>  .../net/wireless/broadcom/brcm80211/brcmfmac/firmware.c | 17 
> -
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c 
> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
> index c7c1e9906500..6dbcceff2529 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(&data_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;
>   }
>  
> @@ -504,9 +510,10 @@ static void brcmf_fw_request_code_done(const struct 
> firmware *fw, void *ctx)
>   return;
>   }
>   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(THIS_MODULE,
> +  FW_OPT_UEVENT | FW_OPT_NO_WARN,
> +  fwctx->nvram_name, fwctx->dev, GFP_KERNEL,
> +  fwctx, brcmf_fw_request_nvram_done);


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

2017-02-21 Thread Rafał Miłecki
From: Rafał Miłecki 

Failing to load NVRAM file isn't critical if we manage to get platform
one 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. This is
very common case for Broadcom home routers.

So instead of printing warning immediately with the firmware subsystem
let's first try our fallback code. 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.

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

Kalle, Arend: this patch is strictly related to the bigger 1/2. Could you ack
this change as I expect this patchset to be picked by Ming, Luis or Greg?
---
 .../net/wireless/broadcom/brcm80211/brcmfmac/firmware.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
index c7c1e9906500..6dbcceff2529 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(&data_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;
}
 
@@ -504,9 +510,10 @@ static void brcmf_fw_request_code_done(const struct 
firmware *fw, void *ctx)
return;
}
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(THIS_MODULE,
+FW_OPT_UEVENT | FW_OPT_NO_WARN,
+fwctx->nvram_name, fwctx->dev, GFP_KERNEL,
+fwctx, brcmf_fw_request_nvram_done);
 
if (!ret)
return;
-- 
2.11.0



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

2017-02-21 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.

Resolve this problem by adding a one flexible function and making old
request_firmware_nowait a simple inline using new solution. This
implementation:
1) Modifies only single bits on existing code
2) Doesn't require adjusting / rewriting current drivers
3) Adds new function for drivers that need more control over loading a
   firmware. Thanks to using flags more features can be added later.

Signed-off-by: Rafał Miłecki 
---
This patch is based on top of
[PATCH V2 RESEND] firmware: simplify defining and handling FW_OPT_FALLBACK
applied on top of Linux 4.10-rc8.

Ming/Luis/Greg: assuming this gets a positive review, could someone of you pick
this patchset? Second patch modifies brcmfmac, I'll try to get a proper Ack for
that one.
Unless you want this to go through wireless tree, then let me know please.
---
 drivers/base/firmware_class.c | 25 ++---
 include/linux/firmware.h  | 34 +-
 2 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index d05be1732c8b..7b3f0a018dc3 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -182,18 +182,6 @@ static int __fw_state_check(struct fw_state *fw_st, enum 
fw_status status)
 
 #endif /* CONFIG_FW_LOADER_USER_HELPER */
 
-/* firmware behavior options */
-#define FW_OPT_UEVENT  (1U << 0)
-#define FW_OPT_NOWAIT  (1U << 1)
-#ifdef CONFIG_FW_LOADER_USER_HELPER
-#define FW_OPT_USERHELPER  (1U << 2)
-#else
-#define FW_OPT_USERHELPER  0
-#endif
-#define FW_OPT_NO_WARN (1U << 3)
-#define FW_OPT_NOCACHE (1U << 4)
-#define FW_OPT_FALLBACK(1U << 5)
-
 struct firmware_cache {
/* firmware_buf instance will be added into the below list */
spinlock_t lock;
@@ -1356,7 +1344,7 @@ static void request_firmware_work_func(struct work_struct 
*work)
_request_firmware(&fw, 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_async() */
 
module_put(fw_work->module);
kfree_const(fw_work->name);
@@ -1364,7 +1352,7 @@ static void request_firmware_work_func(struct work_struct 
*work)
 }
 
 /**
- * request_firmware_nowait - asynchronous version of request_firmware
+ * request_firmware_async - 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.
@@ -1387,8 +1375,8 @@ 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,
+request_firmware_async(
+   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))
 {
@@ -1407,8 +1395,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);
@@ -1421,7 +1408,7 @@ request_firmware_nowait(
schedule_work(&fw_work->work);
return 0;
 }
-EXPORT_SYMBOL(request_firmware_nowait);
+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..1f2bf14aa441 100644
--- a/include/linux/firmware.h
+++ b/include/linux/firmware.h
@@ -8,6 +8,18 @@
 #define FW_ACTION_NOHOTPLUG 0
 #define FW_ACTION_HOTPLUG 1
 
+/* firmware behavior options */
+#define FW_OPT_UEVENT  (1U << 0)
+#define FW_OPT_NOWAIT  (1U << 1)
+#ifdef CONFIG_FW_LOADER_USER_HELPER
+#define FW_OPT_USERHELPER  (1U << 2)
+#else
+#define FW_OPT_USERHELPER  0
+#endif
+#define FW_OPT_NO_WARN (1U << 3)
+#define FW_OPT_NOCACHE (1U << 4)
+#define FW_OPT_FALLBACK(1U << 5)
+
 struct firmware {
size_t size;
const u8 *data;
@@ -41,8 +53,8 @@ struct builtin_fw {
 #if defined(CONFIG_FW_LOADER) || (defined(CONFIG_FW_LOADER_MODULE) && 
defined(MODULE))
 int request_firmware(const struct firmware **fw, const char *name,
 struct device *device);
-i

Re: [PATCH] ath10k: Remove return statement from a void function

2017-02-21 Thread Arend Van Spriel


On 21-2-2017 10:04, Marcin Rokicki wrote:
> The empty 'return;' statement in a void function should be
> used to return from somewhere else then the end.
> 
> Signed-off-by: Marcin Rokicki 
> ---
>  drivers/net/wireless/ath/ath10k/core.c | 11 +--
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath10k/core.c 
> b/drivers/net/wireless/ath/ath10k/core.c
> index 59729aa..d65850e 100644
> --- a/drivers/net/wireless/ath/ath10k/core.c
> +++ b/drivers/net/wireless/ath/ath10k/core.c
> @@ -2268,7 +2268,7 @@ static void ath10k_core_register_work(struct 
> work_struct *work)
>   status = ath10k_core_probe_fw(ar);
>   if (status) {
>   ath10k_err(ar, "could not probe fw (%d)\n", status);
> - goto err;
> + return;

The subject seems misleading as you add a return here. Also removing the
goto will break the desired behavior as expressed in the TODO below.

>   }
>  
>   status = ath10k_mac_register(ar);
> @@ -2307,11 +2307,10 @@ static void ath10k_core_register_work(struct 
> work_struct *work)
>   ath10k_mac_unregister(ar);
>  err_release_fw:
>   ath10k_core_free_firmware_files(ar);
> -err:
> - /* TODO: It's probably a good idea to release device from the driver
> -  * but calling device_release_driver() here will cause a deadlock.
> -  */
> - return;

So to me removing this return statement and no more is sufficient for
this patch. Just leave the label and TODO comment in place or fix it
properly by scheduling a "release driver" work here or whatever is
needed to prevent the deadlock.

Regards,
Arend

> +
> +/* TODO: It's probably a good idea to release device from the driver
> + * but calling device_release_driver() here will cause a deadlock.
> + */
>  }
>  
>  int ath10k_core_register(struct ath10k *ar, u32 chip_id)
> 


Re: wpa psk offloading

2017-02-21 Thread Johannes Berg
On Tue, 2017-02-21 at 10:20 +0100, Arend Van Spriel wrote:
> Hi Johannes,
> 
> Internally I am asked to look at "pmk plumbing" patches allowing
> firmware to deal with 4-way handshake. Now I noticed this topic being
> discussed during last wireless workshop in Santa Fe [1].
> 
> I do not recall any follow-up after that. At least no concrete
> patches, right? Also in wpa_supplicant there is already a solution
> using QCA vendor command. Should we aim to adopt just that or are
> there issues/requirements not covered by that.

I don't think we should adopt a QCA vendor command as the official
solution :)

We do have a patch internally, I'll send it out - we just haven't
managed to release the driver for it yet.

johannes


ath10k regression on XPS13

2017-02-21 Thread Kalle Valo
(Changing subject, adding Dave and relevant lists)

Linus Torvalds  writes:

> On Mon, Feb 20, 2017 at 7:20 AM, Jiri Kosina  wrote:
>>
>>   git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid.git for-linus
>>
>> to receive HID subsystem updates for 4.11:
>
> The touchpad on my XPS13 no longer works. It might not be this pull
> request, and I'll bisect the exact cause, but this pull seems the most
> likely culprit.
>
> Just an early heads-up,

While talking about XPS13 also a heads-up from me as we have a nasty
regression in ath10k on XPS13 with QCA6174 (though not sure if you have
QCA6174, recent models seem to have that) which completely breaks driver
initialisation an error:

"ath10k_pci :3a:00.0: failed to fetch board data for
bus=pci,vendor=168c,device=003e,subsystem-vendor=1a56,subsystem-device=1535,variant=RV_0520
from ath10k/QCA6174/hw3.0/board-2.bin"

https://bugzilla.kernel.org/show_bug.cgi?id=185621#c9

This is caused by this commit which I believe Dave will be sending to
you soon:

f2593cb1b291 ath10k: Search SMBIOS for OEM board file extension

As a workaround I recommend updating ath10k/QCA6174/hw3.0/board-2.bin
from this link _before_ updating the kernel:

https://github.com/kvalo/ath10k-firmware/blob/8d15818b0f9c7b09f743538ac2d3e1409779f52a/QCA6174/hw3.0/board-2.bin

We are working on a fix so that ath10k continues to work with older
board-2.bin, but that might take a day or two still.

-- 
Kalle Valo


wpa psk offloading

2017-02-21 Thread Arend Van Spriel
Hi Johannes,

Internally I am asked to look at "pmk plumbing" patches allowing
firmware to deal with 4-way handshake. Now I noticed this topic being
discussed during last wireless workshop in Santa Fe [1].

I do not recall any follow-up after that. At least no concrete patches,
right? Also in wpa_supplicant there is already a solution using QCA
vendor command. Should we aim to adopt just that or are there
issues/requirements not covered by that.

Regards,
Arend

[1]
https://docs.google.com/document/u/1/d/e/2PACX-1vQXbVQ-3zQt3Bcr3OWfwzbw_C49tTvf0ed8Hmf7b20E6tXc3a40tWZmPku49iGDE-OhgxNmO_lkkHEn/pub#h.kj1rq2w7lxdv


[PATCH] ath10k: Remove return statement from a void function

2017-02-21 Thread Marcin Rokicki
The empty 'return;' statement in a void function should be
used to return from somewhere else then the end.

Signed-off-by: Marcin Rokicki 
---
 drivers/net/wireless/ath/ath10k/core.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 59729aa..d65850e 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -2268,7 +2268,7 @@ static void ath10k_core_register_work(struct work_struct 
*work)
status = ath10k_core_probe_fw(ar);
if (status) {
ath10k_err(ar, "could not probe fw (%d)\n", status);
-   goto err;
+   return;
}
 
status = ath10k_mac_register(ar);
@@ -2307,11 +2307,10 @@ static void ath10k_core_register_work(struct 
work_struct *work)
ath10k_mac_unregister(ar);
 err_release_fw:
ath10k_core_free_firmware_files(ar);
-err:
-   /* TODO: It's probably a good idea to release device from the driver
-* but calling device_release_driver() here will cause a deadlock.
-*/
-   return;
+
+/* TODO: It's probably a good idea to release device from the driver
+ * but calling device_release_driver() here will cause a deadlock.
+ */
 }
 
 int ath10k_core_register(struct ath10k *ar, u32 chip_id)
-- 
2.7.4



Re: [PATCH v6 1/3] cfg80211: Accept multiple RSSI thresholds for CQM

2017-02-21 Thread Kalle Valo
Andrew Zaborowski  writes:

> Hi,
>
> On 15 February 2017 at 09:58, Kalle Valo  wrote:
>> Johannes Berg  writes:
>>> On Fri, 2017-02-10 at 10:02 +0100, Andrew Zaborowski wrote:
 Change the SET CQM command's RSSI threshold attribute to accept any
 number of thresholds as a sorted array.  The API should be backwards
 compatible so that if one s32 threshold value is passed, the old
 mechanism is enabled.  The netlink event generated is the same in
 both cases.
>>>
>>> I've applied this now, thanks for your patience :)
>>>
>>> I got a bit confused - and then fixed it up - patchwork has giving your
>>> name as "Andrzej Zaborowski" which apparently you didn't really want
>>> (any more). I've fixed it for these patches to be as the patches you
>>> sent, but no guarantees I've done this before or will remember to do
>>> that in the future - if you can somehow change your name in patchwork
>>> (patchwork.kernel.org) that would be good.
>
> Thanks, changed it for consistency now.
>
>>
>> IIRC if you haven't registered to patchwork.kernel.org it's possible to
>> change the name easily. But after registration the user needs to contact
>> helpdesk to change the name.
>
> Indeed I was able to set name on registration today but can see no way
> to modify it.  The project's mailing list has a thread about a patch
> that's about to be backported to the patchwork.kernel.org version
> though,
> https://github.com/getpatchwork/patchwork/commit/d365402fb98dfb2c4aea4b58346096f85bdfa0c3

Great, that's exactly the right way to fix this. Thanks for letting us
now.

-- 
Kalle Valo


Re: Monitor mode 'cook' flag meaning

2017-02-21 Thread Johannes Berg
(please quote properly)

On Mon, 2017-02-20 at 18:46 -0700, Thomas d'Otreppe wrote:
> Do you have any example of devices where control or otherbss would be
> useful? Would both be for FullMAC devices?

No, I don't really know.

johannes