Re: iwlwifi 4.18rc1 SYNC TIME_QUOTA_CMD with fw 31

2018-04-18 Thread Luca Coelho
On Wed, 2018-04-18 at 11:31 +0300, Emmanuel Grumbach wrote:
> On Wed, Apr 18, 2018 at 5:47 AM, Scott Register  wrote:
> > 
> > Hello,
> > 
> > After upgrading to 4.18rc1 iwlwifi is printing a FW error. There
> > was a
> > previous thread with a similar
> > issue but they seemed to resolve it with a ucode update. I think
> > I'm
> > running a newer FW and
> > am still having an issue. 4.13 works--I haven't gone any higher so
> > far.
> 
> Please download the firmware from
> https://git.kernel.org/cgit/linux/kernel/git/iwlwifi/linux-firmware.g
> it/plain/iwlwifi-8265-36.ucode
> This should fix your problem.

Yeah, it should work with FW 36.  But if there really is something in
4.18 that breaks support on 31, we should either fix it or make sure we
don't even try to load this old firmware.

I'll take a closer look.

--
Cheers,
Luca.


Re: [PATCH v2 4/4] ath10k: Enable sta idle power save

2018-04-18 Thread govinds

On 2018-04-18 18:46, Kalle Valo wrote:

(fixing top posting)

govi...@codeaurora.org writes:


On 2018-04-18 12:36, Sebastian Gottschall wrote:

from my point of view powersave should be optional and not forced.

consider :
iw dev  set power_save on/off

so there is already a config option made for that purpose,


Thanks Sebastian for your review. Agree this should not be forced with
in driver.

I will check if i can set the idle ps at the end of
ath10k_mac_vif_setup_ps by checking arvif->ps.
I will update the patch accordingly.


So what power save is this exactly? I assumed it's some bus level power
save (turning of clocks etc) but is it actually 802.11 power save?


Yes this is WIFI chip set level power-save(based on idleness) and not 
related to protocol power save.
FW will turn off/scale down the resources(clock/rails) based on 
opportunity(when ever idle mode is detected).
This power save is mostly done in disconnected state. I am not really 
sure when framework/user-space

triggers power-save config(iw dev  set power_save on/off).
Then doing this from user-space will be unnecessarily toggling this 
config or may not be setting at disconnected state.


May be you can suggest better here.

BR,
Govind


Re: [PATCH 1/3] ethtool: Support ETHTOOL_GSTATS2 command.

2018-04-18 Thread Ben Greear

On 04/18/2018 02:26 PM, Johannes Berg wrote:

On Tue, 2018-04-17 at 18:49 -0700, gree...@candelatech.com wrote:


+ * @get_ethtool_stats2: Return extended statistics about the device.
+ * This is only useful if the device maintains statistics not
+ * included in  rtnl_link_stats64.
+ *  Takes a flags argument:  0 means all (same as get_ethtool_stats),
+ *  0x1 (ETHTOOL_GS2_SKIP_FW) means skip firmware stats.
+ *  Other flags are reserved for now.


It'd be pretty hard to know which flags are firmware stats?


Yes, it is, but ethtool stats are difficult to understand in a generic
manner anyway, so someone using them is already likely aware of low-level
details of the driver(s) they are using.

In my case, I have lots of virtual stations (or APs), and I want stats
for them as well as for the 'radio', so I would probe the first vdev with
flags of 'skip-none' to get all stats, including radio (firmware) stats.

And then the rest I would just probe the non-firmware stats.

To be honest, I was slightly amused that anyone expressed interest in
this patch originally, but maybe other people have similar use case
and/or drivers with slow-to-acquire stats.


Anyway, there's no way I'm going to take this patch, so you need to
float it on netdev first (best CC us here) and get it applied there
before we can do anything on the wifi side.


I posted the patches to netdev, ath10k and linux-wireless.  If I had only
posted them individually to different lists I figure I'd be hearing about how
the netdev patch is useless because it has no driver support, etc.

Thanks,
Ben

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



Re: [PATCH 1/3] ethtool: Support ETHTOOL_GSTATS2 command.

2018-04-18 Thread Johannes Berg
On Tue, 2018-04-17 at 18:49 -0700, gree...@candelatech.com wrote:
> 
> + * @get_ethtool_stats2: Return extended statistics about the device.
> + *   This is only useful if the device maintains statistics not
> + *   included in  rtnl_link_stats64.
> + *  Takes a flags argument:  0 means all (same as get_ethtool_stats),
> + *  0x1 (ETHTOOL_GS2_SKIP_FW) means skip firmware stats.
> + *  Other flags are reserved for now.

It'd be pretty hard to know which flags are firmware stats?

Anyway, there's no way I'm going to take this patch, so you need to
float it on netdev first (best CC us here) and get it applied there
before we can do anything on the wifi side.

johannes


Re: [PATCH 1/3] ethtool: Support ETHTOOL_GSTATS2 command.

2018-04-18 Thread Florian Fainelli
On 04/17/2018 06:49 PM, gree...@candelatech.com wrote:
> From: Ben Greear 
> 
> This is similar to ETHTOOL_GSTATS, but it allows you to specify
> flags.  These flags can be used by the driver to decrease the
> amount of stats refreshed.  In particular, this helps with ath10k
> since getting the firmware stats can be slow.

You can configure the statistics refresh rate through the ethtool
coalescing parameter stats_block_coalesce_usecs, not sure if this is
exactly what you had in mind, but if it works, then you might as well
want to use it.

> 
> Signed-off-by: Ben Greear 
> ---
>  include/linux/ethtool.h  | 12 
>  include/uapi/linux/ethtool.h | 10 ++
>  net/core/ethtool.c   | 40 +++-
>  3 files changed, 57 insertions(+), 5 deletions(-)
> 
> diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
> index ebe4181..a4aa11f 100644
> --- a/include/linux/ethtool.h
> +++ b/include/linux/ethtool.h
> @@ -243,6 +243,15 @@ bool ethtool_convert_link_mode_to_legacy_u32(u32 
> *legacy_u32,
>   * @get_ethtool_stats: Return extended statistics about the device.
>   *   This is only useful if the device maintains statistics not
>   *   included in  rtnl_link_stats64.
> + * @get_ethtool_stats2: Return extended statistics about the device.
> + *   This is only useful if the device maintains statistics not
> + *   included in  rtnl_link_stats64.
> + *  Takes a flags argument:  0 means all (same as get_ethtool_stats),
> + *  0x1 (ETHTOOL_GS2_SKIP_FW) means skip firmware stats.
> + *  Other flags are reserved for now.
> + *  Same number of stats will be returned, but some of them might
> + *  not be as accurate/refreshed.  This is to allow not querying
> + *  firmware or other expensive-to-read stats, for instance.
>   * @begin: Function to be called before any other operation.  Returns a
>   *   negative error code or zero.
>   * @complete: Function to be called after any other operation except
> @@ -355,6 +364,9 @@ struct ethtool_ops {
>   int (*set_phys_id)(struct net_device *, enum ethtool_phys_id_state);
>   void(*get_ethtool_stats)(struct net_device *,
>struct ethtool_stats *, u64 *);
> + void(*get_ethtool_stats2)(struct net_device *dev,
> +   struct ethtool_stats *gstats, u64 *data,
> +   u32 flags);
>   int (*begin)(struct net_device *);
>   void(*complete)(struct net_device *);
>   u32 (*get_priv_flags)(struct net_device *);
> diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
> index 4ca65b5..1c74f3e 100644
> --- a/include/uapi/linux/ethtool.h
> +++ b/include/uapi/linux/ethtool.h
> @@ -1396,11 +1396,21 @@ enum ethtool_fec_config_bits {
>  #define ETHTOOL_PHY_STUNABLE 0x004f /* Set PHY tunable configuration */
>  #define ETHTOOL_GFECPARAM0x0050 /* Get FEC settings */
>  #define ETHTOOL_SFECPARAM0x0051 /* Set FEC settings */
> +#define ETHTOOL_GSTATS2  0x0052 /* get NIC-specific 
> statistics
> + * with ability to specify flags.
> + * See ETHTOOL_GS2* below.
> + */
>  
>  /* compatibility with older code */
>  #define SPARC_ETH_GSET   ETHTOOL_GSET
>  #define SPARC_ETH_SSET   ETHTOOL_SSET
>  
> +/* GSTATS2 flags */
> +#define ETHTOOL_GS2_SKIP_NONE (0)/* default is to update all stats */
> +#define ETHTOOL_GS2_SKIP_FW   (1<<0) /* Skip reading stats that probe 
> firmware,
> +   * and thus are slow/expensive.
> +   */
> +
>  /* Link mode bit indices */
>  enum ethtool_link_mode_bit_indices {
>   ETHTOOL_LINK_MODE_10baseT_Half_BIT  = 0,
> diff --git a/net/core/ethtool.c b/net/core/ethtool.c
> index 03416e6..6ec3413 100644
> --- a/net/core/ethtool.c
> +++ b/net/core/ethtool.c
> @@ -1952,16 +1952,14 @@ static int ethtool_phys_id(struct net_device *dev, 
> void __user *useraddr)
>   return rc;
>  }
>  
> -static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
> +static int _ethtool_get_stats(struct net_device *dev, void __user *useraddr,
> +   u32 flags)
>  {
>   struct ethtool_stats stats;
>   const struct ethtool_ops *ops = dev->ethtool_ops;
>   u64 *data;
>   int ret, n_stats;
>  
> - if (!ops->get_ethtool_stats || !ops->get_sset_count)
> - return -EOPNOTSUPP;
> -
>   n_stats = ops->get_sset_count(dev, ETH_SS_STATS);
>   if (n_stats < 0)
>   return n_stats;
> @@ -1976,7 +1974,10 @@ static int ethtool_get_stats(struct net_device *dev, 
> void __user *useraddr)
>   if (n_stats && !data)
>   return -ENOMEM;
>  
> - ops->get_ethtool_stats(dev, 

Re: ath confusing log message "country IE"

2018-04-18 Thread Johannes Berg
On Wed, 2018-04-18 at 16:55 +0200, Toke Høiland-Jørgensen wrote:
> 
> Heh, that is a good point, I think. The patch below should fix it; but I
> worry that the log lines become quite long, then? Maybe better to use
> "country-IE", but that could also be confused. "country inf.elem"
> perhaps?

Heh. Drop "information" entirely, the spec also did :-)

802.11-2016 just says

9.4.2 Elements
[...]
9.4.2.9 Country element

johannes


Re: wil6210: low level sector API

2018-04-18 Thread David Dean Zhang
Hi,

I updated the firmware and tried to call some low level functions,
like WMI_PRIO_TX_SECTORS_NUMBER_CMDID and WMI_SET_RF_SECTOR_ON_CMDID .
The previous errors have gone but it still has errors:

wil6210 :03:00.0 wlp3s0: wmi_event_handle: Unhandled event 0x19a5
wil6210 :03:00.0 wlp3s0: wmi_call: wmi_call(0x09a6->0x19a6)
timeout 2000 msec

So I am wondering whether it is because the chipset does not support
these wmi commands. I just want to know how to use these commands and
how to disable TXSS. I appreciate if anyone could provide some
suggestions. Thanks.

Bests,
David

On Thu, Mar 29, 2018 at 8:29 AM, Dedy Lansky  wrote:
> From: linux-wireless-ow...@vger.kernel.org 
> [mailto:linux-wireless-ow...@vger.kernel.org] On Behalf Of David Dean
> Sent: Monday, March 26, 2018 9:38 PM
>
>> My question is how I can disable TXSS. One way I found in the wmi.h is 
>> setting the number of sectors of TXSS to 0 or 1 > by using 
>> wmi_prio_tx_sectors_num_cmd so that the TXSS will only use 1 sector.
>> However, when I called this cmd, I got this error:
>> wil6210 :03:00.0 wlp3s0: wil6210_irq_misc: Firmware error detected, 
>> assert codes FW 0x1038, UCODE 0x
>> wil6210 :03:00.0 wlp3s0: wil_fw_core_dump: fw core dumped, size 823296 
>> bytes
>> wil6210 :03:00.0 wlp3s0: wil_notify_fw_error: Notify about firmware error
>> So I am wondering whether the firmware does not support these kinds of wmi 
>> commands. Does anyone have any experience on this? Thank you.
>
> Indeed this error indicates that FW doesn't support these WMI commands.
> We are working on releasing new FW version with support for these commands.
>
> Thanks,
>  Dedy.
>


Re: ath confusing log message "country IE"

2018-04-18 Thread Steve deRosier
On Wed, Apr 18, 2018 at 7:55 AM, Toke Høiland-Jørgensen  wrote:
> Bernhard Gabler  writes:
>
>> Dear all,
>>
>> would it be possible to re-write the log message from
>> "regdomain ... dynamically updated by country IE"
>> in a less ambiguous way, e.g. to:
>> "regdomain ... dynamically updated by country-IE"
>> "regdomain ... dynamically updated by country information element"
>> , please?
>>
>> To the occasional reader, the following system log messages seem to
>> convey that
>>   -  "DE" (Germany) was intended to be used, but
>>   -  "IE" (Ireland) was configured as regdomain.
>>
>>  [ 2723.739071] ath: EEPROM regdomain: 0x8114
>>  [ 2723.739072] ath: EEPROM indicates we should expect a country code
>>  [ 2723.739073] ath: doing EEPROM country->regdmn map search
>>  [ 2723.739074] ath: country maps to regdmn code: 0x37
>>  [ 2723.739075] ath: Country alpha2 being used: DE
>>  [ 2723.739076] ath: Regpair used: 0x37
>>  [ 2723.739077] ath: regdomain 0x8114 dynamically updated by country IE
>>
>> Only after intense googling, I now know that IE stands for "information
>> element", not for Ireland. But this is not obvious at. To prevent others
>> from confusion and wasting time on a non-problem, could please someone
>> rewrite the log message?
>
> Heh, that is a good point, I think. The patch below should fix it; but I
> worry that the log lines become quite long, then? Maybe better to use
> "country-IE", but that could also be confused. "country inf.elem"
> perhaps?
>

Instead of just rewording the message, perhaps adjusting it to show
more information would make it more clear:

`regdomain 0x8114 dynamically updated by country I.E. to DE`

Assuming the message two lines higher is related, I know the
information is already there, but this way the line stands on its own,
is more information rich, and is also clear.

- Steve


Re: ath confusing log message "country IE"

2018-04-18 Thread Toke Høiland-Jørgensen
Bernhard Gabler  writes:

> Dear all,
>
> would it be possible to re-write the log message from
>     "regdomain ... dynamically updated by country IE"
> in a less ambiguous way, e.g. to:
>     "regdomain ... dynamically updated by country-IE"
>     "regdomain ... dynamically updated by country information element"
> , please?
>
> To the occasional reader, the following system log messages seem to 
> convey that
>   -  "DE" (Germany) was intended to be used, but
>   -  "IE" (Ireland) was configured as regdomain.
>
>      [ 2723.739071] ath: EEPROM regdomain: 0x8114
>      [ 2723.739072] ath: EEPROM indicates we should expect a country code
>      [ 2723.739073] ath: doing EEPROM country->regdmn map search
>      [ 2723.739074] ath: country maps to regdmn code: 0x37
>      [ 2723.739075] ath: Country alpha2 being used: DE
>      [ 2723.739076] ath: Regpair used: 0x37
>      [ 2723.739077] ath: regdomain 0x8114 dynamically updated by country IE
>
> Only after intense googling, I now know that IE stands for "information 
> element", not for Ireland. But this is not obvious at. To prevent others 
> from confusion and wasting time on a non-problem, could please someone 
> rewrite the log message?

Heh, that is a good point, I think. The patch below should fix it; but I
worry that the log lines become quite long, then? Maybe better to use
"country-IE", but that could also be confused. "country inf.elem"
perhaps?

Ah, the bike-shedding possibilities are endless! :)

-Toke


diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 7b42f0bacfd8..7f432734dbe9 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1464,7 +1464,7 @@ const char *reg_initiator_name(enum nl80211_reg_initiator 
initiator)
case NL80211_REGDOM_SET_BY_DRIVER:
return "driver";
case NL80211_REGDOM_SET_BY_COUNTRY_IE:
-   return "country IE";
+   return "country information element";
default:
WARN_ON(1);
return "bug";


ath confusing log message "country IE"

2018-04-18 Thread Bernhard Gabler

Dear all,

would it be possible to re-write the log message from
   "regdomain ... dynamically updated by country IE"
in a less ambiguous way, e.g. to:
   "regdomain ... dynamically updated by country-IE"
   "regdomain ... dynamically updated by country information element"
, please?

To the occasional reader, the following system log messages seem to 
convey that

 -  "DE" (Germany) was intended to be used, but
 -  "IE" (Ireland) was configured as regdomain.

    [ 2723.739071] ath: EEPROM regdomain: 0x8114
    [ 2723.739072] ath: EEPROM indicates we should expect a country code
    [ 2723.739073] ath: doing EEPROM country->regdmn map search
    [ 2723.739074] ath: country maps to regdmn code: 0x37
    [ 2723.739075] ath: Country alpha2 being used: DE
    [ 2723.739076] ath: Regpair used: 0x37
    [ 2723.739077] ath: regdomain 0x8114 dynamically updated by country IE

Only after intense googling, I now know that IE stands for "information 
element", not for Ireland. But this is not obvious at. To prevent others 
from confusion and wasting time on a non-problem, could please someone 
rewrite the log message?


Regards,
Bernhard

PS: The example log is from a machine with "Qualcomm Atheros QCA6174" 
but I fancy other drivers may show same/similar messages.


Re: [PATCH v2 4/4] ath10k: Enable sta idle power save

2018-04-18 Thread Arend van Spriel

On 4/18/2018 3:16 PM, Kalle Valo wrote:

(fixing top posting)

govi...@codeaurora.org writes:


On 2018-04-18 12:36, Sebastian Gottschall wrote:

from my point of view powersave should be optional and not forced.

consider :
iw dev  set power_save on/off

so there is already a config option made for that purpose,


Thanks Sebastian for your review. Agree this should not be forced with
in driver.

I will check if i can set the idle ps at the end of
ath10k_mac_vif_setup_ps by checking arvif->ps.
I will update the patch accordingly.


So what power save is this exactly? I assumed it's some bus level power
save (turning of clocks etc) but is it actually 802.11 power save?


I also suspected bus level power save and I would say runtime-pm 
framework should be considered for that.


Regards,
Arend




Re: [PATCH v2 4/4] ath10k: Enable sta idle power save

2018-04-18 Thread Kalle Valo
(fixing top posting)

govi...@codeaurora.org writes:

> On 2018-04-18 12:36, Sebastian Gottschall wrote:
>> from my point of view powersave should be optional and not forced.
>>
>> consider :
>> iw dev  set power_save on/off
>>
>> so there is already a config option made for that purpose,
>
> Thanks Sebastian for your review. Agree this should not be forced with
> in driver.
>
> I will check if i can set the idle ps at the end of
> ath10k_mac_vif_setup_ps by checking arvif->ps.
> I will update the patch accordingly.

So what power save is this exactly? I assumed it's some bus level power
save (turning of clocks etc) but is it actually 802.11 power save?

-- 
Kalle Valo


Re: [PATCH v2 4/4] ath10k: Enable sta idle power save

2018-04-18 Thread govinds

On 2018-04-18 12:36, Sebastian Gottschall wrote:

from my point of view powersave should be optional and not forced.

consider :
iw dev  set power_save on/off

so there is already a config option made for that purpose,

Sebastian

Am 17.04.2018 um 14:07 schrieb pill...@codeaurora.org:

From: Govind Singh 

Enable sta power save in fw for the targets that
supports idle power save. The idle ps enable command
will be ignored by the firmware which does not support
this feature.

Signed-off-by: Govind Singh 
Signed-off-by: Rakesh Pillai 
---
  drivers/net/wireless/ath/ath10k/mac.c | 7 +++
  1 file changed, 7 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c

index 7e02ca02b28e..1d9222af1bb2 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -4679,6 +4679,13 @@ static int ath10k_start(struct ieee80211_hw 
*hw)

}
}
  + param = ar->wmi.pdev_param->idle_ps_config;
+   ret = ath10k_wmi_pdev_set_param(ar, param, 1);
+   if (ret && ret != -EOPNOTSUPP) {
+   ath10k_warn(ar, "failed to enable idle_ps_config: %d\n", ret);
+   goto err_core_stop;
+   }
+
  	__ath10k_set_antenna(ar, ar->cfg_tx_chainmask, 
ar->cfg_rx_chainmask);

/*


Thanks Sebastian for your review. Agree this should not be forced with 
in driver.


I will check if i can set the idle ps at the end of 
ath10k_mac_vif_setup_ps by checking arvif->ps.

I will update the patch accordingly.


BR,
Govind


Re: [PATCH] rt2x00: fix spelling mistake in various macros, UKNOWN -> UNKNOWN

2018-04-18 Thread Stanislaw Gruszka
On Wed, Apr 18, 2018 at 12:47:50PM +0100, Colin King wrote:
> From: Colin Ian King 
> 
> Rename several macros that contain mispellings of UNKNOWN
> 
> Signed-off-by: Colin Ian King 
Acked-by: Stanislaw Gruszka 


[PATCH] rt2x00: fix spelling mistake in various macros, UKNOWN -> UNKNOWN

2018-04-18 Thread Colin King
From: Colin Ian King 

Rename several macros that contain mispellings of UNKNOWN

Signed-off-by: Colin Ian King 
---
 drivers/net/wireless/ralink/rt2x00/rt2800.h | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800.h 
b/drivers/net/wireless/ralink/rt2x00/rt2800.h
index 6a8c93fb6a43..8eccfbb5d6f8 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
@@ -1193,10 +1193,10 @@
 #define TX_PWR_CFG_3_MCS13 FIELD32(0x00f0)
 #define TX_PWR_CFG_3_MCS14 FIELD32(0x0f00)
 #define TX_PWR_CFG_3_MCS15 FIELD32(0xf000)
-#define TX_PWR_CFG_3_UKNOWN1   FIELD32(0x000f)
-#define TX_PWR_CFG_3_UKNOWN2   FIELD32(0x00f0)
-#define TX_PWR_CFG_3_UKNOWN3   FIELD32(0x0f00)
-#define TX_PWR_CFG_3_UKNOWN4   FIELD32(0xf000)
+#define TX_PWR_CFG_3_UNKNOWN1  FIELD32(0x000f)
+#define TX_PWR_CFG_3_UNKNOWN2  FIELD32(0x00f0)
+#define TX_PWR_CFG_3_UNKNOWN3  FIELD32(0x0f00)
+#define TX_PWR_CFG_3_UNKNOWN4  FIELD32(0xf000)
 /* bits for 3T devices */
 #define TX_PWR_CFG_3_MCS12_CH0 FIELD32(0x000f)
 #define TX_PWR_CFG_3_MCS12_CH1 FIELD32(0x00f0)
@@ -1216,10 +1216,10 @@
  * TX_PWR_CFG_4:
  */
 #define TX_PWR_CFG_4   0x1324
-#define TX_PWR_CFG_4_UKNOWN5   FIELD32(0x000f)
-#define TX_PWR_CFG_4_UKNOWN6   FIELD32(0x00f0)
-#define TX_PWR_CFG_4_UKNOWN7   FIELD32(0x0f00)
-#define TX_PWR_CFG_4_UKNOWN8   FIELD32(0xf000)
+#define TX_PWR_CFG_4_UNKNOWN5  FIELD32(0x000f)
+#define TX_PWR_CFG_4_UNKNOWN6  FIELD32(0x00f0)
+#define TX_PWR_CFG_4_UNKNOWN7  FIELD32(0x0f00)
+#define TX_PWR_CFG_4_UNKNOWN8  FIELD32(0xf000)
 /* bits for 3T devices */
 #define TX_PWR_CFG_4_STBC4_CH0 FIELD32(0x000f)
 #define TX_PWR_CFG_4_STBC4_CH1 FIELD32(0x00f0)
-- 
2.17.0



[PATCH 05/22] staging: wilc1000: refactor add_key() to avoid duplicated code

2018-04-18 Thread Ajay Singh
Cleanup fixes by removing the duplicated code in actor add_key().

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 64 ---
 1 file changed, 23 insertions(+), 41 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index ac4cd58..329899f 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -922,8 +922,7 @@ static int add_key(struct wiphy *wiphy, struct net_device 
*netdev, u8 key_index,
const u8 *rx_mic = NULL;
const u8 *tx_mic = NULL;
u8 mode = NO_ENCRYPT;
-   u8 gmode = NO_ENCRYPT;
-   u8 pmode = NO_ENCRYPT;
+   u8 op_mode;
enum AUTHTYPE auth_type = ANY;
struct wilc *wl;
struct wilc_vif *vif;
@@ -966,71 +965,54 @@ static int add_key(struct wiphy *wiphy, struct net_device 
*netdev, u8 key_index,
priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
wilc_wfi_cfg_allocate_wpa_entry(priv, key_index);
 
+   if (params->key_len > 16 &&
+   params->cipher == WLAN_CIPHER_SUITE_TKIP) {
+   tx_mic = params->key + 24;
+   rx_mic = params->key + 16;
+   keylen = params->key_len - 16;
+   }
+
if (!pairwise) {
if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
-   gmode = ENCRYPT_ENABLED | WPA | TKIP;
+   mode = ENCRYPT_ENABLED | WPA | TKIP;
else
-   gmode = ENCRYPT_ENABLED | WPA2 | AES;
+   mode = ENCRYPT_ENABLED | WPA2 | AES;
 
-   priv->wilc_groupkey = gmode;
+   priv->wilc_groupkey = mode;
 
-   if (params->key_len > 16 && params->cipher == 
WLAN_CIPHER_SUITE_TKIP) {
-   tx_mic = params->key + 24;
-   rx_mic = params->key + 16;
-   keylen = params->key_len - 16;
-   }

wilc_wfi_cfg_copy_wpa_info(priv->wilc_gtk[key_index],
   params);
-
-   wilc_add_rx_gtk(vif, params->key, keylen,
-   key_index, params->seq_len,
-   params->seq, rx_mic,
-   tx_mic, AP_MODE, gmode);
-
} else {
if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
-   pmode = ENCRYPT_ENABLED | WPA | TKIP;
+   mode = ENCRYPT_ENABLED | WPA | TKIP;
else
-   pmode = priv->wilc_groupkey | AES;
-
-   if (params->key_len > 16 && params->cipher == 
WLAN_CIPHER_SUITE_TKIP) {
-   tx_mic = params->key + 24;
-   rx_mic = params->key + 16;
-   keylen = params->key_len - 16;
-   }
+   mode = priv->wilc_groupkey | AES;
 

wilc_wfi_cfg_copy_wpa_info(priv->wilc_ptk[key_index],
   params);
-
-   wilc_add_ptk(vif, params->key, keylen,
-mac_addr, rx_mic, tx_mic,
-AP_MODE, pmode, key_index);
}
-   break;
-   }
-
-   if (!pairwise) {
-   if (params->key_len > 16 && params->cipher == 
WLAN_CIPHER_SUITE_TKIP) {
+   op_mode = AP_MODE;
+   } else {
+   if (params->key_len > 16 &&
+   params->cipher == WLAN_CIPHER_SUITE_TKIP) {
rx_mic = params->key + 24;
tx_mic = params->key + 16;
keylen = params->key_len - 16;
}
 
+   op_mode = STATION_MODE;
+   }
+
+   if (!pairwise) {
wilc_add_rx_gtk(vif, params->key, keylen,
key_index, params->seq_len,
params->seq, rx_mic,
-   tx_mic, STATION_MODE,
+ 

[PATCH 06/22] staging: wilc1000: handle error condition in add_key() and remove auth_type variable

2018-04-18 Thread Ajay Singh
Added the code to return correct error code in add_key() and also removed
'auth_type' variable. Now passing diretly to function instead of using
the 'auth_type' variable.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 52 ---
 1 file changed, 28 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 329899f..821d4f1 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -923,7 +923,6 @@ static int add_key(struct wiphy *wiphy, struct net_device 
*netdev, u8 key_index,
const u8 *tx_mic = NULL;
u8 mode = NO_ENCRYPT;
u8 op_mode;
-   enum AUTHTYPE auth_type = ANY;
struct wilc *wl;
struct wilc_vif *vif;
 
@@ -937,24 +936,24 @@ static int add_key(struct wiphy *wiphy, struct net_device 
*netdev, u8 key_index,
if (priv->wdev->iftype == NL80211_IFTYPE_AP) {
wilc_wfi_cfg_copy_wep_info(priv, key_index, params);
 
-   auth_type = OPEN_SYSTEM;
-
if (params->cipher == WLAN_CIPHER_SUITE_WEP40)
mode = ENCRYPT_ENABLED | WEP;
else
mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
 
-   wilc_add_wep_key_bss_ap(vif, params->key,
-   params->key_len, key_index,
-   mode, auth_type);
+   ret = wilc_add_wep_key_bss_ap(vif, params->key,
+ params->key_len,
+ key_index, mode,
+ OPEN_SYSTEM);
break;
}
if (memcmp(params->key, priv->wep_key[key_index],
   params->key_len)) {
wilc_wfi_cfg_copy_wep_info(priv, key_index, params);
 
-   wilc_add_wep_key_bss_sta(vif, params->key,
-params->key_len, key_index);
+   ret = wilc_add_wep_key_bss_sta(vif, params->key,
+  params->key_len,
+  key_index);
}
 
break;
@@ -963,7 +962,9 @@ static int add_key(struct wiphy *wiphy, struct net_device 
*netdev, u8 key_index,
case WLAN_CIPHER_SUITE_CCMP:
if (priv->wdev->iftype == NL80211_IFTYPE_AP ||
priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
-   wilc_wfi_cfg_allocate_wpa_entry(priv, key_index);
+   ret = wilc_wfi_cfg_allocate_wpa_entry(priv, key_index);
+   if (ret)
+   return -ENOMEM;
 
if (params->key_len > 16 &&
params->cipher == WLAN_CIPHER_SUITE_TKIP) {
@@ -980,16 +981,20 @@ static int add_key(struct wiphy *wiphy, struct net_device 
*netdev, u8 key_index,
 
priv->wilc_groupkey = mode;
 
-   
wilc_wfi_cfg_copy_wpa_info(priv->wilc_gtk[key_index],
-  params);
+   ret = 
wilc_wfi_cfg_copy_wpa_info(priv->wilc_gtk[key_index],
+params);
+   if (ret)
+   return -ENOMEM;
} else {
if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
mode = ENCRYPT_ENABLED | WPA | TKIP;
else
mode = priv->wilc_groupkey | AES;
 
-   
wilc_wfi_cfg_copy_wpa_info(priv->wilc_ptk[key_index],
-  params);
+   ret = 
wilc_wfi_cfg_copy_wpa_info(priv->wilc_ptk[key_index],
+params);
+   if (ret)
+   return -ENOMEM;
}
op_mode = AP_MODE;
} else {
@@ -1003,17 +1008,16 @@ static int add_key(struct wiphy *wiphy, struct 
net_device *netdev, u8 key_index,
op_mode = STATION_MODE;
}
 
-   if (!pairwise) {
-   wilc_add_rx_gtk(vif, params->key, keylen,
-   key_index, params->seq_len,
-   params->seq, 

[PATCH 22/22] staging: wilc1000: rename pu32InactiveTime to avoid camelCase issue

2018-04-18 Thread Ajay Singh
Avoid camelCase issues found by checkpatch.pl script.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 035c537..7a26f34 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -314,7 +314,7 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 
ptk_key_len,
 const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
 u8 mode, u8 cipher_mode, u8 index);
 s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
-  u32 *pu32InactiveTime);
+  u32 *out_val);
 int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
u8 index, u32 key_rsc_len, const u8 *key_rsc,
const u8 *rx_mic, const u8 *tx_mic, u8 mode,
-- 
2.7.4




[PATCH 20/22] staging: wilc1000: rename goto labels starting with '_' in wilc1000_wlan_init()

2018-04-18 Thread Ajay Singh
Rename goto labels starting with '_' in wilc1000_wlan_init() to follow
linux coding style.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_wlan.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 8f97c62..26edbb6 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -735,42 +735,42 @@ int wilc1000_wlan_init(struct net_device *dev, struct 
wilc_vif *vif)
ret = wilc_wlan_init(dev);
if (ret < 0) {
ret = -EIO;
-   goto _fail_locks_;
+   goto fail_locks;
}
 
if (wl->gpio >= 0 && init_irq(dev)) {
ret = -EIO;
-   goto _fail_locks_;
+   goto fail_locks;
}
 
ret = wlan_initialize_threads(dev);
if (ret < 0) {
ret = -EIO;
-   goto _fail_wilc_wlan_;
+   goto fail_wilc_wlan;
}
 
if (!wl->dev_irq_num &&
wl->hif_func->enable_interrupt &&
wl->hif_func->enable_interrupt(wl)) {
ret = -EIO;
-   goto _fail_irq_init_;
+   goto fail_irq_init;
}
 
if (wilc_wlan_get_firmware(dev)) {
ret = -EIO;
-   goto _fail_irq_enable_;
+   goto fail_irq_enable;
}
 
ret = wilc1000_firmware_download(dev);
if (ret < 0) {
ret = -EIO;
-   goto _fail_irq_enable_;
+   goto fail_irq_enable;
}
 
ret = linux_wlan_start_firmware(dev);
if (ret < 0) {
ret = -EIO;
-   goto _fail_irq_enable_;
+   goto fail_irq_enable;
}
 
if (wilc_wlan_cfg_get(vif, 1, WID_FIRMWARE_VERSION, 1, 0)) {
@@ -788,27 +788,27 @@ int wilc1000_wlan_init(struct net_device *dev, struct 
wilc_vif *vif)
if (ret < 0) {
netdev_err(dev, "Failed to configure firmware\n");
ret = -EIO;
-   goto _fail_fw_start_;
+   goto fail_fw_start;
}
 
wl->initialized = true;
return 0;
 
-_fail_fw_start_:
+fail_fw_start:
wilc_wlan_stop(wl);
 
-_fail_irq_enable_:
+fail_irq_enable:
if (!wl->dev_irq_num &&
wl->hif_func->disable_interrupt)
wl->hif_func->disable_interrupt(wl);
-_fail_irq_init_:
+fail_irq_init:
if (wl->dev_irq_num)
deinit_irq(dev);
 
wlan_deinitialize_threads(dev);
-_fail_wilc_wlan_:
+fail_wilc_wlan:
wilc_wlan_cleanup(dev);
-_fail_locks_:
+fail_locks:
wlan_deinit_locks(dev);
netdev_err(dev, "WLAN initialization FAILED\n");
} else {
-- 
2.7.4




[PATCH 12/22] staging: wilc1000: remove multiple define used for MAX_SSID_LEN

2018-04-18 Thread Ajay Singh
Cleanup patch to have commonly used macro in common header file to avoid
same defination in mulitple file. Removed MAX_SSID_LEN macro from
coreconfigurator.h header as its already defined in wilc_wlan_if.h.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/coreconfigurator.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/wilc1000/coreconfigurator.h 
b/drivers/staging/wilc1000/coreconfigurator.h
index 5436fd3..1666b7a 100644
--- a/drivers/staging/wilc1000/coreconfigurator.h
+++ b/drivers/staging/wilc1000/coreconfigurator.h
@@ -17,7 +17,6 @@
 #define NUM_RSSI5
 
 #define MAC_HDR_LEN 24
-#define MAX_SSID_LEN33
 #define FCS_LEN 4
 #define TIME_STAMP_LEN  8
 #define BEACON_INTERVAL_LEN 2
-- 
2.7.4




[PATCH 18/22] staging: wilc1000: remove the use of goto label in wilc_init()

2018-04-18 Thread Ajay Singh
Added direct return in wilc_init() instead of goto label. Changes
are done to avoid the use of '_' in label name.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 19 ---
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 65caa6d..12414f4 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3331,7 +3331,6 @@ static void get_periodic_rssi(struct timer_list *unused)
 
 int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
 {
-   int result = 0;
struct host_if_drv *hif_drv;
struct wilc_vif *vif;
struct wilc *wilc;
@@ -3345,10 +3344,9 @@ int wilc_init(struct net_device *dev, struct host_if_drv 
**hif_drv_handler)
init_completion(_wait_response);
 
hif_drv  = kzalloc(sizeof(*hif_drv), GFP_KERNEL);
-   if (!hif_drv) {
-   result = -ENOMEM;
-   goto _fail_;
-   }
+   if (!hif_drv)
+   return -ENOMEM;
+
*hif_drv_handler = hif_drv;
for (i = 0; i < wilc->vif_num; i++)
if (dev == wilc->vif[i]->ndev) {
@@ -3359,7 +3357,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv 
**hif_drv_handler)
 
wilc_optaining_ip = false;
 
-   if (clients_count == 0) {
+   if (clients_count == 0) {
init_completion(_thread_comp);
init_completion(_driver_comp);
mutex_init(_deinit_lock);
@@ -3370,12 +3368,12 @@ int wilc_init(struct net_device *dev, struct 
host_if_drv **hif_drv_handler)
init_completion(_drv->comp_get_rssi);
init_completion(_drv->comp_inactive_time);
 
-   if (clients_count == 0) {
+   if (clients_count == 0) {
hif_workqueue = create_singlethread_workqueue("WILC_wq");
if (!hif_workqueue) {
netdev_err(vif->ndev, "Failed to create workqueue\n");
-   result = -ENOMEM;
-   goto _fail_;
+   kfree(hif_drv);
+   return -ENOMEM;
}
 
periodic_rssi_vif = vif;
@@ -3403,8 +3401,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv 
**hif_drv_handler)
 
clients_count++;
 
-_fail_:
-   return result;
+   return 0;
 }
 
 int wilc_deinit(struct wilc_vif *vif)
-- 
2.7.4




[PATCH 19/22] staging: wilc1000: rename goto label '_fail_' linux naming convension

2018-04-18 Thread Ajay Singh
Rename '_fail_' goto label to have name as per linux coding style.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_wlan.c | 92 +--
 drivers/staging/wilc1000/wilc_sdio.c  | 84 
 drivers/staging/wilc1000/wilc_wlan.c  | 16 +++---
 3 files changed, 96 insertions(+), 96 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 2236967..8f97c62 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -338,16 +338,16 @@ int wilc_wlan_get_firmware(struct net_device *dev)
netdev_info(dev, "loading firmware %s\n", firmware);
 
if (!(>ndev->dev))
-   goto _fail_;
+   goto fail;
 
if (request_firmware(_firmware, firmware, wilc->dev) != 0) {
netdev_err(dev, "%s - firmware not available\n", firmware);
ret = -1;
-   goto _fail_;
+   goto fail;
}
wilc->firmware = wilc_firmware;
 
-_fail_:
+fail:
 
return ret;
 }
@@ -416,193 +416,193 @@ static int linux_wlan_init_test_config(struct 
net_device *dev,
*(int *)c_val = 1;
 
if (!wilc_wlan_cfg_set(vif, 1, WID_SET_DRV_HANDLER, c_val, 4, 0, 0))
-   goto _fail_;
+   goto fail;
 
c_val[0] = 0;
if (!wilc_wlan_cfg_set(vif, 0, WID_PC_TEST_MODE, c_val, 1, 0, 0))
-   goto _fail_;
+   goto fail;
 
c_val[0] = INFRASTRUCTURE;
if (!wilc_wlan_cfg_set(vif, 0, WID_BSS_TYPE, c_val, 1, 0, 0))
-   goto _fail_;
+   goto fail;
 
c_val[0] = RATE_AUTO;
if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0))
-   goto _fail_;
+   goto fail;
 
c_val[0] = G_MIXED_11B_2_MODE;
if (!wilc_wlan_cfg_set(vif, 0, WID_11G_OPERATING_MODE, c_val, 1, 0,
   0))
-   goto _fail_;
+   goto fail;
 
c_val[0] = 1;
if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_CHANNEL, c_val, 1, 0, 0))
-   goto _fail_;
+   goto fail;
 
c_val[0] = G_SHORT_PREAMBLE;
if (!wilc_wlan_cfg_set(vif, 0, WID_PREAMBLE, c_val, 1, 0, 0))
-   goto _fail_;
+   goto fail;
 
c_val[0] = AUTO_PROT;
if (!wilc_wlan_cfg_set(vif, 0, WID_11N_PROT_MECH, c_val, 1, 0, 0))
-   goto _fail_;
+   goto fail;
 
c_val[0] = ACTIVE_SCAN;
if (!wilc_wlan_cfg_set(vif, 0, WID_SCAN_TYPE, c_val, 1, 0, 0))
-   goto _fail_;
+   goto fail;
 
c_val[0] = SITE_SURVEY_OFF;
if (!wilc_wlan_cfg_set(vif, 0, WID_SITE_SURVEY, c_val, 1, 0, 0))
-   goto _fail_;
+   goto fail;
 
*((int *)c_val) = 0x;
if (!wilc_wlan_cfg_set(vif, 0, WID_RTS_THRESHOLD, c_val, 2, 0, 0))
-   goto _fail_;
+   goto fail;
 
*((int *)c_val) = 2346;
if (!wilc_wlan_cfg_set(vif, 0, WID_FRAG_THRESHOLD, c_val, 2, 0, 0))
-   goto _fail_;
+   goto fail;
 
c_val[0] = 0;
if (!wilc_wlan_cfg_set(vif, 0, WID_BCAST_SSID, c_val, 1, 0, 0))
-   goto _fail_;
+   goto fail;
 
c_val[0] = 1;
if (!wilc_wlan_cfg_set(vif, 0, WID_QOS_ENABLE, c_val, 1, 0, 0))
-   goto _fail_;
+   goto fail;
 
c_val[0] = NO_POWERSAVE;
if (!wilc_wlan_cfg_set(vif, 0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0))
-   goto _fail_;
+   goto fail;
 
c_val[0] = NO_SECURITY; /* NO_ENCRYPT, 0x79 */
if (!wilc_wlan_cfg_set(vif, 0, WID_11I_MODE, c_val, 1, 0, 0))
-   goto _fail_;
+   goto fail;
 
c_val[0] = OPEN_SYSTEM;
if (!wilc_wlan_cfg_set(vif, 0, WID_AUTH_TYPE, c_val, 1, 0, 0))
-   goto _fail_;
+   goto fail;
 
strcpy(c_val, "123456790abcdef1234567890");
if (!wilc_wlan_cfg_set(vif, 0, WID_WEP_KEY_VALUE, c_val,
   (strlen(c_val) + 1), 0, 0))
-   goto _fail_;
+   goto fail;
 
strcpy(c_val, "12345678");
if (!wilc_wlan_cfg_set(vif, 0, WID_11I_PSK, c_val, (strlen(c_val)), 0,
   0))
-   goto _fail_;
+   goto fail;
 
strcpy(c_val, "password");
if (!wilc_wlan_cfg_set(vif, 0, WID_1X_KEY, c_val, (strlen(c_val) + 1),
   0, 0))
-   goto _fail_;
+   goto fail;
 
c_val[0] = 192;
c_val[1] = 168;
c_val[2] = 1;
c_val[3] = 112;
if (!wilc_wlan_cfg_set(vif, 0, WID_1X_SERV_ADDR, c_val, 4, 0, 0))
-   goto _fail_;
+   goto fail;
 
c_val[0] = 3;
if (!wilc_wlan_cfg_set(vif, 0, 

[PATCH 16/22] staging: wilc1000: remove the use of goto label in wilc_spi_read_int()

2018-04-18 Thread Ajay Singh
In wilc_spi_read_int() remove the use of goto label '_fail_'. Changes
are done to avoid the use of '_' in label name.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_spi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_spi.c 
b/drivers/staging/wilc1000/wilc_spi.c
index 57e4f11..1db2814 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -946,7 +946,7 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 
*int_status)
if (!ret) {
dev_err(>dev,
"Failed read WILC_VMM_TO_HOST_SIZE ...\n");
-   goto _fail_;
+   return ret;
}
tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK;
 
@@ -976,7 +976,6 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 
*int_status)
 
*int_status = tmp;
 
-_fail_:
return ret;
 }
 
-- 
2.7.4




[PATCH 21/22] staging: wilc1000: remove the use of goto label in wilc_spi_clear_int_ext()

2018-04-18 Thread Ajay Singh
Remove goto label '_fail_' used in wilc_spi_clear_int_ext(), to avoid
the label name starting with '_'.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_spi.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_spi.c 
b/drivers/staging/wilc1000/wilc_spi.c
index 1db2814..2cb9f4e 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -1013,7 +1013,7 @@ static int wilc_spi_clear_int_ext(struct wilc *wilc, u32 
val)
dev_err(>dev,
"Failed wilc_spi_write_reg, set reg %x ...\n",
0x10c8 + i * 4);
-   goto _fail_;
+   return ret;
}
for (i = g_spi.nint; i < MAX_NUM_INT; i++) {
if (flags & 1)
@@ -1035,7 +1035,7 @@ static int wilc_spi_clear_int_ext(struct wilc *wilc, u32 
val)
ret = wilc_spi_write_reg(wilc, WILC_VMM_TBL_CTL, tbl_ctl);
if (!ret) {
dev_err(>dev, "fail write reg vmm_tbl_ctl...\n");
-   goto _fail_;
+   return ret;
}
 
if ((val & EN_VMM) == EN_VMM) {
@@ -1045,10 +1045,10 @@ static int wilc_spi_clear_int_ext(struct wilc *wilc, 
u32 val)
ret = wilc_spi_write_reg(wilc, WILC_VMM_CORE_CTL, 1);
if (!ret) {
dev_err(>dev, "fail write reg vmm_core_ctl...\n");
-   goto _fail_;
+   return ret;
}
}
-_fail_:
+
return ret;
 }
 
-- 
2.7.4




[PATCH 03/22] staging: wilc1000: split add_key() to avoid line over 80 chars

2018-04-18 Thread Ajay Singh
Cleanup changes to fix 'line over 80 chars' issue found by checkpatch.pl
script by spliting the function. Also make use of kzalloc() instead of
kmalloc().

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 108 +-
 1 file changed, 64 insertions(+), 44 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 57e7bf6..0c7bf2b 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -860,6 +860,58 @@ static int disconnect(struct wiphy *wiphy, struct 
net_device *dev,
return ret;
 }
 
+static inline void wilc_wfi_cfg_copy_wep_info(struct wilc_priv *priv,
+ u8 key_index,
+ struct key_params *params)
+{
+   priv->wep_key_len[key_index] = params->key_len;
+   memcpy(priv->wep_key[key_index], params->key, params->key_len);
+}
+
+static int wilc_wfi_cfg_allocate_wpa_entry(struct wilc_priv *priv, u8 idx)
+{
+   if (!priv->wilc_gtk[idx]) {
+   priv->wilc_gtk[idx] = kzalloc(sizeof(struct wilc_wfi_key),
+  GFP_KERNEL);
+   if (!priv->wilc_gtk[idx])
+   return -ENOMEM;
+   }
+
+   if (!priv->wilc_ptk[idx]) {
+   priv->wilc_ptk[idx] = kzalloc(sizeof(struct wilc_wfi_key),
+  GFP_KERNEL);
+   if (!priv->wilc_ptk[idx])
+   return -ENOMEM;
+   }
+
+   return 0;
+}
+
+static int wilc_wfi_cfg_copy_wpa_info(struct wilc_wfi_key *key_info,
+ struct key_params *params)
+{
+   kfree(key_info->key);
+
+   key_info->key = kmemdup(params->key, params->key_len, GFP_KERNEL);
+   if (!key_info->key)
+   return -ENOMEM;
+
+   kfree(key_info->seq);
+
+   if (params->seq_len > 0) {
+   key_info->seq = kmemdup(params->seq, params->seq_len,
+   GFP_KERNEL);
+   if (!key_info->seq)
+   return -ENOMEM;
+   }
+
+   key_info->cipher = params->cipher;
+   key_info->key_len = params->key_len;
+   key_info->seq_len = params->seq_len;
+
+   return 0;
+}
+
 static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 
key_index,
   bool pairwise,
   const u8 *mac_addr, struct key_params *params)
@@ -880,12 +932,11 @@ static int add_key(struct wiphy *wiphy, struct net_device 
*netdev, u8 key_index,
vif = netdev_priv(netdev);
wl = vif->wilc;
 
-   switch (params->cipher) {
+   switch (params->cipher) {
case WLAN_CIPHER_SUITE_WEP40:
case WLAN_CIPHER_SUITE_WEP104:
if (priv->wdev->iftype == NL80211_IFTYPE_AP) {
-   priv->wep_key_len[key_index] = params->key_len;
-   memcpy(priv->wep_key[key_index], params->key, 
params->key_len);
+   wilc_wfi_cfg_copy_wep_info(priv, key_index, params);
 
auth_type = OPEN_SYSTEM;
 
@@ -899,9 +950,9 @@ static int add_key(struct wiphy *wiphy, struct net_device 
*netdev, u8 key_index,
mode, auth_type);
break;
}
-   if (memcmp(params->key, priv->wep_key[key_index], 
params->key_len)) {
-   priv->wep_key_len[key_index] = params->key_len;
-   memcpy(priv->wep_key[key_index], params->key, 
params->key_len);
+   if (memcmp(params->key, priv->wep_key[key_index],
+  params->key_len)) {
+   wilc_wfi_cfg_copy_wep_info(priv, key_index, params);
 
wilc_add_wep_key_bss_sta(vif, params->key,
 params->key_len, key_index);
@@ -911,17 +962,9 @@ static int add_key(struct wiphy *wiphy, struct net_device 
*netdev, u8 key_index,
 
case WLAN_CIPHER_SUITE_TKIP:
case WLAN_CIPHER_SUITE_CCMP:
-   if (priv->wdev->iftype == NL80211_IFTYPE_AP || 
priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
-   if (!priv->wilc_gtk[key_index]) {
-   priv->wilc_gtk[key_index] = 
kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
-   priv->wilc_gtk[key_index]->key = NULL;
-   priv->wilc_gtk[key_index]->seq = NULL;
-   }
-   if (!priv->wilc_ptk[key_index]) {
-   priv->wilc_ptk[key_index] = 
kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
-   priv->wilc_ptk[key_index]->key = NULL;
-   

[PATCH 09/22] staging: wilc1000: rename WID_LOGTerminal_Switch to avoid camelCase

2018-04-18 Thread Ajay Singh
Fix 'Avoid camelCase' issue found by checkpatch.pl script.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wlan_if.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h 
b/drivers/staging/wilc1000/wilc_wlan_if.h
index e186509..f129d81 100644
--- a/drivers/staging/wilc1000/wilc_wlan_if.h
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -741,7 +741,7 @@ enum {
 
WID_DEL_BEACON  = 0x00CA,
 
-   WID_LOGTerminal_Switch  = 0x00CD,
+   WID_LOG_TERMINAL_SWITCH = 0x00CD,
WID_TX_POWER= 0x00CE,
/*  EMAC Short WID list */
/*  RTS Threshold */
-- 
2.7.4




[PATCH 10/22] staging: wilc1000: added identifiers name in function definations

2018-04-18 Thread Ajay Singh
Fix identifier names required for functions definition issues reported
by checkpatch.pl script.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wlan.h | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan.h 
b/drivers/staging/wilc1000/wilc_wlan.h
index 4abbfa7..20e4659 100644
--- a/drivers/staging/wilc1000/wilc_wlan.h
+++ b/drivers/staging/wilc1000/wilc_wlan.h
@@ -222,7 +222,7 @@ struct txq_entry_t {
int buffer_size;
void *priv;
int status;
-   void (*tx_complete_func)(void *, int);
+   void (*tx_complete_func)(void *priv, int status);
 };
 
 struct rxq_entry_t {
@@ -238,18 +238,18 @@ struct rxq_entry_t {
  /
 struct wilc;
 struct wilc_hif_func {
-   int (*hif_init)(struct wilc *, bool resume);
-   int (*hif_deinit)(struct wilc *);
-   int (*hif_read_reg)(struct wilc *, u32, u32 *);
-   int (*hif_write_reg)(struct wilc *, u32, u32);
-   int (*hif_block_rx)(struct wilc *, u32, u8 *, u32);
-   int (*hif_block_tx)(struct wilc *, u32, u8 *, u32);
-   int (*hif_read_int)(struct wilc *, u32 *);
-   int (*hif_clear_int_ext)(struct wilc *, u32);
-   int (*hif_read_size)(struct wilc *, u32 *);
-   int (*hif_block_tx_ext)(struct wilc *, u32, u8 *, u32);
-   int (*hif_block_rx_ext)(struct wilc *, u32, u8 *, u32);
-   int (*hif_sync_ext)(struct wilc *, int);
+   int (*hif_init)(struct wilc *wilc, bool resume);
+   int (*hif_deinit)(struct wilc *wilc);
+   int (*hif_read_reg)(struct wilc *wilc, u32 addr, u32 *data);
+   int (*hif_write_reg)(struct wilc *wilc, u32 addr, u32 data);
+   int (*hif_block_rx)(struct wilc *wilc, u32 addr, u8 *buf, u32 size);
+   int (*hif_block_tx)(struct wilc *wilc, u32 addr, u8 *buf, u32 size);
+   int (*hif_read_int)(struct wilc *wilc, u32 *int_status);
+   int (*hif_clear_int_ext)(struct wilc *wilc, u32 val);
+   int (*hif_read_size)(struct wilc *wilc, u32 *size);
+   int (*hif_block_tx_ext)(struct wilc *wilc, u32 addr, u8 *buf, u32 size);
+   int (*hif_block_rx_ext)(struct wilc *wilc, u32 addr, u8 *buf, u32 size);
+   int (*hif_sync_ext)(struct wilc *wilc, int nint);
int (*enable_interrupt)(struct wilc *nic);
void (*disable_interrupt)(struct wilc *nic);
 };
-- 
2.7.4




[PATCH 07/22] staging: wilc1000: use sizeof(variable) for memory allocated to store key info

2018-04-18 Thread Ajay Singh
Changes to fix below checkpatch reported issues.

CHECK: Prefer kmalloc(sizeof(*priv->wilc_gtk[idx])...) over
kmalloc(sizeof(struct wilc_wfi_key)...)

CHECK: Prefer kmalloc(sizeof(*priv->wilc_ptk[idx])...) over
kmalloc(sizeof(struct wilc_wfi_key)...)

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 821d4f1..0d3f85d 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -871,15 +871,15 @@ static inline void wilc_wfi_cfg_copy_wep_info(struct 
wilc_priv *priv,
 static int wilc_wfi_cfg_allocate_wpa_entry(struct wilc_priv *priv, u8 idx)
 {
if (!priv->wilc_gtk[idx]) {
-   priv->wilc_gtk[idx] = kzalloc(sizeof(struct wilc_wfi_key),
-  GFP_KERNEL);
+   priv->wilc_gtk[idx] = kzalloc(sizeof(*priv->wilc_gtk[idx]),
+ GFP_KERNEL);
if (!priv->wilc_gtk[idx])
return -ENOMEM;
}
 
if (!priv->wilc_ptk[idx]) {
-   priv->wilc_ptk[idx] = kzalloc(sizeof(struct wilc_wfi_key),
-  GFP_KERNEL);
+   priv->wilc_ptk[idx] = kzalloc(sizeof(*priv->wilc_ptk[idx]),
+ GFP_KERNEL);
if (!priv->wilc_ptk[idx])
return -ENOMEM;
}
-- 
2.7.4




[PATCH 17/22] staging: wilc1000: remove goto label '_done_' in handle_listen_state_expired()

2018-04-18 Thread Ajay Singh
Remove the use of goto label '_done_' in handle_listen_state_expired().
Changes are done to avoid the use of '_' in label name.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 1117705..65caa6d 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -2332,7 +2332,7 @@ static u32 handle_listen_state_expired(struct wilc_vif 
*vif,
kfree(wid.val);
if (result != 0) {
netdev_err(vif->ndev, "Failed to set remain channel\n");
-   goto _done_;
+   return result;
}
 
if (hif_drv->remain_on_ch.expired) {
@@ -2345,7 +2345,6 @@ static u32 handle_listen_state_expired(struct wilc_vif 
*vif,
result = -EFAULT;
}
 
-_done_:
return result;
 }
 
-- 
2.7.4




[PATCH 11/22] staging: wilc1000: remove unused macros in wilc module

2018-04-18 Thread Ajay Singh
Cleanup patch to remove the macros which are defined by not used.
Below mentioned macros are removed:
SCAN_DONE
SCAN_EVENT_DONE_ABORTED
WILC_WFI_RX_INTR
WILC_WFI_TX_INTR
WILC_WFI_TIMEOUT
WILC_WFI_DWELL_PASSIVE
WILC_WFI_DWELL_ACTIVE
MAX_SURVEY_RESULT_FRAG_SIZE
SURVEY_RESULT_LENGTH
NUM_BASIC_SWITCHES
NUM_FHSS_SWITCHES
NUM_11N_BASIC_SWITCHES
NUM_11N_HUT_SWITCHES
BA_SESSION_DEFAULT_BUFFER_SIZE
BA_SESSION_DEFAULT_TIMEOUT
BLOCK_ACK_REQ_SIZE

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/coreconfigurator.h   | 13 -
 drivers/staging/wilc1000/host_interface.c |  3 ---
 drivers/staging/wilc1000/host_interface.h |  1 -
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  3 ---
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |  4 
 drivers/staging/wilc1000/wilc_wlan_if.h   |  2 --
 6 files changed, 26 deletions(-)

diff --git a/drivers/staging/wilc1000/coreconfigurator.h 
b/drivers/staging/wilc1000/coreconfigurator.h
index 3f5da8c..5436fd3 100644
--- a/drivers/staging/wilc1000/coreconfigurator.h
+++ b/drivers/staging/wilc1000/coreconfigurator.h
@@ -14,19 +14,8 @@
 
 #include "wilc_wlan_if.h"
 
-#define NUM_BASIC_SWITCHES  45
-#define NUM_FHSS_SWITCHES   0
-
 #define NUM_RSSI5
 
-#ifdef MAC_802_11N
-#define NUM_11N_BASIC_SWITCHES  25
-#define NUM_11N_HUT_SWITCHES47
-#else
-#define NUM_11N_BASIC_SWITCHES  0
-#define NUM_11N_HUT_SWITCHES0
-#endif
-
 #define MAC_HDR_LEN 24
 #define MAX_SSID_LEN33
 #define FCS_LEN 4
@@ -41,8 +30,6 @@
 #define GET_CFG  1
 
 #define MAX_STRING_LEN   256
-#define MAX_SURVEY_RESULT_FRAG_SIZE  MAX_STRING_LEN
-#define SURVEY_RESULT_LENGTH 44
 #define MAX_ASSOC_RESP_FRAME_SIZEMAX_STRING_LEN
 
 #define MAC_CONNECTED1
diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 6b5300c..1117705 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -53,9 +53,6 @@
 #define HOST_IF_SCAN_TIMEOUT4000
 #define HOST_IF_CONNECT_TIMEOUT 9500
 
-#define BA_SESSION_DEFAULT_BUFFER_SIZE  16
-#define BA_SESSION_DEFAULT_TIMEOUT  1000
-#define BLOCK_ACK_REQ_SIZE  0x14
 #define FALSE_FRMWR_CHANNEL100
 
 #define TCP_ACK_FILTER_LINK_SPEED_THRESH   54
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 4b60b18..035c537 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -49,7 +49,6 @@
 #define PMKID_LEN  16
 #define WILC_MAX_NUM_PMKIDS16
 #define WILC_ADD_STA_LENGTH40
-#define SCAN_EVENT_DONE_ABORTED
 #define NUM_CONCURRENT_IFC 2
 #define DRV_HANDLER_SIZE   5
 #define DRV_HANDLER_MASK   0x00FF
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index bddfbcb..9cd6be5 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -79,9 +79,6 @@ static const struct wiphy_wowlan_support wowlan_support = {
.flags = WIPHY_WOWLAN_ANY
 };
 
-#define WILC_WFI_DWELL_PASSIVE 100
-#define WILC_WFI_DWELL_ACTIVE  40
-
 #define TCP_ACK_FILTER_LINK_SPEED_THRESH   54
 #define DEFAULT_LINK_SPEED 72
 
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h 
b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index bd0c98a..07167637 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -9,10 +9,6 @@
 #ifndef WILC_WFI_NETDEVICE
 #define WILC_WFI_NETDEVICE
 
-#define WILC_WFI_RX_INTR 0x0001
-#define WILC_WFI_TX_INTR 0x0002
-
-#define WILC_WFI_TIMEOUT 5
 #define WILC_MAX_NUM_PMKIDS  16
 #define PMKID_LEN  16
 #define PMKID_FOUND 1
diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h 
b/drivers/staging/wilc1000/wilc_wlan_if.h
index f129d81..eb8d819 100644
--- a/drivers/staging/wilc1000/wilc_wlan_if.h
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -122,8 +122,6 @@ enum {
 
 #define MAC_CONNECTED  1
 #define MAC_DISCONNECTED   0
-
-#define SCAN_DONE  TRUE
 enum {
PASSIVE_SCAN= 0,
ACTIVE_SCAN = 1,
-- 
2.7.4




[PATCH 04/22] staging: wilc1000: remove inner block {} and resetting of mode variable

2018-04-18 Thread Ajay Singh
Cleanup fixes to remove the uncessary inner block { /* */ } and setting
of 'mode' variable.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 43 +++
 1 file changed, 20 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 0c7bf2b..ac4cd58 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1009,31 +1009,28 @@ static int add_key(struct wiphy *wiphy, struct 
net_device *netdev, u8 key_index,
break;
}
 
-   {
-   mode = 0;
-   if (!pairwise) {
-   if (params->key_len > 16 && params->cipher == 
WLAN_CIPHER_SUITE_TKIP) {
-   rx_mic = params->key + 24;
-   tx_mic = params->key + 16;
-   keylen = params->key_len - 16;
-   }
-
-   wilc_add_rx_gtk(vif, params->key, keylen,
-   key_index, params->seq_len,
-   params->seq, rx_mic,
-   tx_mic, STATION_MODE,
-   mode);
-   } else {
-   if (params->key_len > 16 && params->cipher == 
WLAN_CIPHER_SUITE_TKIP) {
-   rx_mic = params->key + 24;
-   tx_mic = params->key + 16;
-   keylen = params->key_len - 16;
-   }
+   if (!pairwise) {
+   if (params->key_len > 16 && params->cipher == 
WLAN_CIPHER_SUITE_TKIP) {
+   rx_mic = params->key + 24;
+   tx_mic = params->key + 16;
+   keylen = params->key_len - 16;
+   }
 
-   wilc_add_ptk(vif, params->key, keylen,
-mac_addr, rx_mic, tx_mic,
-STATION_MODE, mode, key_index);
+   wilc_add_rx_gtk(vif, params->key, keylen,
+   key_index, params->seq_len,
+   params->seq, rx_mic,
+   tx_mic, STATION_MODE,
+   mode);
+   } else {
+   if (params->key_len > 16 && params->cipher == 
WLAN_CIPHER_SUITE_TKIP) {
+   rx_mic = params->key + 24;
+   tx_mic = params->key + 16;
+   keylen = params->key_len - 16;
}
+
+   wilc_add_ptk(vif, params->key, keylen,
+mac_addr, rx_mic, tx_mic,
+STATION_MODE, mode, key_index);
}
break;
 
-- 
2.7.4




[PATCH 14/22] staging: wilc1000: remove the use of goto label in spi_cmd_complete()

2018-04-18 Thread Ajay Singh
In spi_cmd_complete() remove the use of goto label '_error_'. Changes
were done to avoid the use of '_' in label name.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_spi.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_spi.c 
b/drivers/staging/wilc1000/wilc_spi.c
index 6b392c9..3e3c774 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -527,8 +527,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 
adr, u8 *b, u32 sz,
if (wilc_spi_rx(wilc, [ix], nbytes)) {
dev_err(>dev,
"Failed block read, bus err\n");
-   result = N_FAIL;
-   goto _error_;
+   return N_FAIL;
}
 
/*
@@ -537,8 +536,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 
adr, u8 *b, u32 sz,
if (!g_spi.crc_off && wilc_spi_rx(wilc, crc, 2)) {
dev_err(>dev,
"Failed block crc read, bus err\n");
-   result = N_FAIL;
-   goto _error_;
+   return N_FAIL;
}
 
ix += nbytes;
@@ -604,7 +602,6 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 
adr, u8 *b, u32 sz,
sz -= nbytes;
}
}
-_error_:
return result;
 }
 
-- 
2.7.4




[PATCH 13/22] staging: wilc1000: remove multiple define for mac connect and disconnect

2018-04-18 Thread Ajay Singh
Cleanup patch to have commonly used macro in common header file to avoid
same defination in mulitple file. Removed MAC_CONNECTED &
MAC_DISCONNECTED macro from coreconfigurator.h header.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/coreconfigurator.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/wilc1000/coreconfigurator.h 
b/drivers/staging/wilc1000/coreconfigurator.h
index 1666b7a..6e61f3d 100644
--- a/drivers/staging/wilc1000/coreconfigurator.h
+++ b/drivers/staging/wilc1000/coreconfigurator.h
@@ -31,9 +31,6 @@
 #define MAX_STRING_LEN   256
 #define MAX_ASSOC_RESP_FRAME_SIZEMAX_STRING_LEN
 
-#define MAC_CONNECTED1
-#define MAC_DISCONNECTED 0
-
 #define MAKE_WORD16(lsb, msb) u16)(msb) << 8) & 0xFF00) | (lsb))
 #define MAKE_WORD32(lsw, msw) u32)(msw) << 16) & 0x) | (lsw))
 
-- 
2.7.4




[PATCH 15/22] staging: wilc1000: remove the use of goto label in wilc_spi_read_size()

2018-04-18 Thread Ajay Singh
In wilc_spi_read_size() remove the use of goto label '_fail_'. Changes
are done to avoid the use of '_' in label name.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_spi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_spi.c 
b/drivers/staging/wilc1000/wilc_spi.c
index 3e3c774..57e4f11 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -917,13 +917,12 @@ static int wilc_spi_read_size(struct wilc *wilc, u32 
*size)
if (!ret) {
dev_err(>dev,
"Failed read WILC_VMM_TO_HOST_SIZE ...\n");
-   goto _fail_;
+   return ret;
}
tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK;
*size = tmp;
}
 
-_fail_:
return ret;
 }
 
-- 
2.7.4




[PATCH 08/22] staging: wilc1000: fix line over 80 chars in change_station()

2018-04-18 Thread Ajay Singh
Fix 'line over 80 chars' issue found by checkpatch.pl script.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 0d3f85d..bddfbcb 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1155,10 +1155,10 @@ static int get_station(struct wiphy *wiphy, struct 
net_device *dev,
wilc_get_statistics(vif, );
 
sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
-   
BIT(NL80211_STA_INFO_RX_PACKETS) |
-   
BIT(NL80211_STA_INFO_TX_PACKETS) |
-   BIT(NL80211_STA_INFO_TX_FAILED) 
|
-   
BIT(NL80211_STA_INFO_TX_BITRATE);
+BIT(NL80211_STA_INFO_RX_PACKETS) |
+BIT(NL80211_STA_INFO_TX_PACKETS) |
+BIT(NL80211_STA_INFO_TX_FAILED) |
+BIT(NL80211_STA_INFO_TX_BITRATE);
 
sinfo->signal = stats.rssi;
sinfo->rx_packets = stats.rx_cnt;
-- 
2.7.4




[PATCH 01/22] staging: wilc1000: rename WILC_WFI_wep_key & WILC_WFI_wep_key_len

2018-04-18 Thread Ajay Singh
Cleanup patch to use lower case for variable name as per linux coding
style.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 30 +++
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |  4 +--
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 3139ead..bdc6c85 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -726,15 +726,15 @@ static int connect(struct wiphy *wiphy, struct net_device 
*dev,
return ret;
}
 
-   memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key));
-   memset(priv->WILC_WFI_wep_key_len, 0, 
sizeof(priv->WILC_WFI_wep_key_len));
+   memset(priv->wep_key, 0, sizeof(priv->wep_key));
+   memset(priv->wep_key_len, 0, sizeof(priv->wep_key_len));
 
if (sme->crypto.cipher_group != NO_ENCRYPT) {
if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) {
u8security = ENCRYPT_ENABLED | WEP;
 
-   priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
-   memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, 
sme->key_len);
+   priv->wep_key_len[sme->key_idx] = sme->key_len;
+   memcpy(priv->wep_key[sme->key_idx], sme->key, 
sme->key_len);
 
wilc_set_wep_default_keyid(vif, sme->key_idx);
wilc_add_wep_key_bss_sta(vif, sme->key, sme->key_len,
@@ -742,8 +742,8 @@ static int connect(struct wiphy *wiphy, struct net_device 
*dev,
} else if (sme->crypto.cipher_group == 
WLAN_CIPHER_SUITE_WEP104)   {
u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
 
-   priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
-   memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, 
sme->key_len);
+   priv->wep_key_len[sme->key_idx] = sme->key_len;
+   memcpy(priv->wep_key[sme->key_idx], sme->key, 
sme->key_len);
 
wilc_set_wep_default_keyid(vif, sme->key_idx);
wilc_add_wep_key_bss_sta(vif, sme->key, sme->key_len,
@@ -884,8 +884,8 @@ static int add_key(struct wiphy *wiphy, struct net_device 
*netdev, u8 key_index,
case WLAN_CIPHER_SUITE_WEP40:
case WLAN_CIPHER_SUITE_WEP104:
if (priv->wdev->iftype == NL80211_IFTYPE_AP) {
-   priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
-   memcpy(priv->WILC_WFI_wep_key[key_index], params->key, 
params->key_len);
+   priv->wep_key_len[key_index] = params->key_len;
+   memcpy(priv->wep_key[key_index], params->key, 
params->key_len);
 
auth_type = OPEN_SYSTEM;
 
@@ -899,9 +899,9 @@ static int add_key(struct wiphy *wiphy, struct net_device 
*netdev, u8 key_index,
u8mode, auth_type);
break;
}
-   if (memcmp(params->key, priv->WILC_WFI_wep_key[key_index], 
params->key_len)) {
-   priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
-   memcpy(priv->WILC_WFI_wep_key[key_index], params->key, 
params->key_len);
+   if (memcmp(params->key, priv->wep_key[key_index], 
params->key_len)) {
+   priv->wep_key_len[key_index] = params->key_len;
+   memcpy(priv->wep_key[key_index], params->key, 
params->key_len);
 
wilc_add_wep_key_bss_sta(vif, params->key,
 params->key_len, key_index);
@@ -1060,10 +1060,10 @@ static int del_key(struct wiphy *wiphy, struct 
net_device *netdev,
}
 
if (key_index >= 0 && key_index <= 3) {
-   if (priv->WILC_WFI_wep_key_len[key_index]) {
-   memset(priv->WILC_WFI_wep_key[key_index], 0,
-  priv->WILC_WFI_wep_key_len[key_index]);
-   priv->WILC_WFI_wep_key_len[key_index] = 0;
+   if (priv->wep_key_len[key_index]) {
+   memset(priv->wep_key[key_index], 0,
+  priv->wep_key_len[key_index]);
+   priv->wep_key_len[key_index] = 0;
wilc_remove_wep_key(vif, key_index);
}
} else {
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h 
b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index d62c4f1..bd0c98a 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -124,8 +124,8 @@ struct wilc_priv {
struct host_if_drv *hif_drv;
   

[PATCH 02/22] staging: wilc1000: rename variable using datatype in their name in add_key()

2018-04-18 Thread Ajay Singh
Cleanup changes to use variable name as per linux coding style.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 32 +++
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index bdc6c85..57e7bf6 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -869,9 +869,9 @@ static int add_key(struct wiphy *wiphy, struct net_device 
*netdev, u8 key_index,
struct wilc_priv *priv;
const u8 *rx_mic = NULL;
const u8 *tx_mic = NULL;
-   u8 u8mode = NO_ENCRYPT;
-   u8 u8gmode = NO_ENCRYPT;
-   u8 u8pmode = NO_ENCRYPT;
+   u8 mode = NO_ENCRYPT;
+   u8 gmode = NO_ENCRYPT;
+   u8 pmode = NO_ENCRYPT;
enum AUTHTYPE auth_type = ANY;
struct wilc *wl;
struct wilc_vif *vif;
@@ -890,13 +890,13 @@ static int add_key(struct wiphy *wiphy, struct net_device 
*netdev, u8 key_index,
auth_type = OPEN_SYSTEM;
 
if (params->cipher == WLAN_CIPHER_SUITE_WEP40)
-   u8mode = ENCRYPT_ENABLED | WEP;
+   mode = ENCRYPT_ENABLED | WEP;
else
-   u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
+   mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
 
wilc_add_wep_key_bss_ap(vif, params->key,
params->key_len, key_index,
-   u8mode, auth_type);
+   mode, auth_type);
break;
}
if (memcmp(params->key, priv->wep_key[key_index], 
params->key_len)) {
@@ -925,11 +925,11 @@ static int add_key(struct wiphy *wiphy, struct net_device 
*netdev, u8 key_index,
 
if (!pairwise) {
if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
-   u8gmode = ENCRYPT_ENABLED | WPA | TKIP;
+   gmode = ENCRYPT_ENABLED | WPA | TKIP;
else
-   u8gmode = ENCRYPT_ENABLED | WPA2 | AES;
+   gmode = ENCRYPT_ENABLED | WPA2 | AES;
 
-   priv->wilc_groupkey = u8gmode;
+   priv->wilc_groupkey = gmode;
 
if (params->key_len > 16 && params->cipher == 
WLAN_CIPHER_SUITE_TKIP) {
tx_mic = params->key + 24;
@@ -954,13 +954,13 @@ static int add_key(struct wiphy *wiphy, struct net_device 
*netdev, u8 key_index,
wilc_add_rx_gtk(vif, params->key, keylen,
key_index, params->seq_len,
params->seq, rx_mic,
-   tx_mic, AP_MODE, u8gmode);
+   tx_mic, AP_MODE, gmode);
 
} else {
if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
-   u8pmode = ENCRYPT_ENABLED | WPA | TKIP;
+   pmode = ENCRYPT_ENABLED | WPA | TKIP;
else
-   u8pmode = priv->wilc_groupkey | AES;
+   pmode = priv->wilc_groupkey | AES;
 
if (params->key_len > 16 && params->cipher == 
WLAN_CIPHER_SUITE_TKIP) {
tx_mic = params->key + 24;
@@ -984,13 +984,13 @@ static int add_key(struct wiphy *wiphy, struct net_device 
*netdev, u8 key_index,
 
wilc_add_ptk(vif, params->key, keylen,
 mac_addr, rx_mic, tx_mic,
-AP_MODE, u8pmode, key_index);
+AP_MODE, pmode, key_index);
}
break;
}
 
{
-   u8mode = 0;
+   mode = 0;
if (!pairwise) {
if (params->key_len > 16 && params->cipher == 
WLAN_CIPHER_SUITE_TKIP) {
rx_mic = params->key + 24;
@@ -1002,7 +1002,7 @@ static int add_key(struct wiphy *wiphy, struct net_device 
*netdev, u8 key_index,
key_index, params->seq_len,
params->seq, rx_mic,
 

[PATCH 00/22] staging: wilc1000: cleanup patches to follow linux coding style

2018-04-18 Thread Ajay Singh
This patch series is based on top of
"[PATCH 00/11] staging: wilc1000: fix for checkpatch and handled
malloc memory properly" and its not applied yet.[1]

In this series contains fixes to avoid the checkpatch reported issue.
Also remove the multiple #define for same macros and changes to
follow linux coding style.

[1] https://www.mail-archive.com/linux-wireless@vger.kernel.org/msg43998.html

Ajay Singh (22):
  staging: wilc1000: rename WILC_WFI_wep_key & WILC_WFI_wep_key_len
  staging: wilc1000: rename variable using datatype in their name in
add_key()
  staging: wilc1000: split add_key() to avoid line over 80 chars
  staging: wilc1000: remove inner block {} and resetting of mode
variable
  staging: wilc1000: refactor add_key() to avoid duplicated code
  staging: wilc1000: handle error condition in add_key() and remove
auth_type variable
  staging: wilc1000: use sizeof(variable) for memory allocated to store
key info
  staging: wilc1000: fix line over 80 chars in change_station()
  staging: wilc1000: rename WID_LOGTerminal_Switch to avoid camelCase
  staging: wilc1000: added identifiers name in function definations
  staging: wilc1000: remove unused macros in wilc module
  staging: wilc1000: remove multiple define used for MAX_SSID_LEN
  staging: wilc1000: remove multiple define for mac connect and
disconnect
  staging: wilc1000: remove the use of goto label in spi_cmd_complete()
  staging: wilc1000: remove the use of goto label in
wilc_spi_read_size()
  staging: wilc1000: remove the use of goto label in wilc_spi_read_int()
  staging: wilc1000: remove goto label '_done_' in
handle_listen_state_expired()
  staging: wilc1000: remove the use of goto label in wilc_init()
  staging: wilc1000: rename goto label '_fail_' linux naming convension
  staging: wilc1000: rename goto labels starting with '_' in
wilc1000_wlan_init()
  staging: wilc1000: remove the use of goto label in
wilc_spi_clear_int_ext()
  staging: wilc1000: rename pu32InactiveTime to avoid camelCase issue

 drivers/staging/wilc1000/coreconfigurator.h   |  17 --
 drivers/staging/wilc1000/host_interface.c |  25 +--
 drivers/staging/wilc1000/host_interface.h |   3 +-
 drivers/staging/wilc1000/linux_wlan.c | 118 +-
 drivers/staging/wilc1000/wilc_sdio.c  |  84 
 drivers/staging/wilc1000/wilc_spi.c   |  21 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 250 +++---
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |   8 +-
 drivers/staging/wilc1000/wilc_wlan.c  |  16 +-
 drivers/staging/wilc1000/wilc_wlan.h  |  26 +--
 drivers/staging/wilc1000/wilc_wlan_if.h   |   4 +-
 11 files changed, 268 insertions(+), 304 deletions(-)

-- 
2.7.4




Re: [PATCH] mt76x2: fix is_mt7612 routine

2018-04-18 Thread Felix Fietkau
On 2018-04-18 00:27, Lorenzo Bianconi wrote:
> Fix is_mt7612 routine since asic version is set in mt76_dev revision
> field and not in mt76x2_dev one.
> Moreover remove mt76x2_dev rev field since it is never used in the
> driver
> 
> Fixes: 7bc04215a66b ('mt76: add driver code for MT76x2e')
> Signed-off-by: Lorenzo Bianconi 
Acked-by: Felix Fietkau 


[RESEND][PATCH 1/4] NFC: st21nfca: Fix out of bounds kernel access when handling ATR_REQ

2018-04-18 Thread Amit Pundir
From: Suren Baghdasaryan 

Out of bounds kernel accesses in st21nfca's NFC HCI layer
might happen when handling ATR_REQ events if user-specified
atr_req->length is bigger than the buffer size. In
that case memcpy() inside st21nfca_tm_send_atr_res() will
read extra bytes resulting in OOB read from the kernel heap.

Signed-off-by: Suren Baghdasaryan 
Signed-off-by: Amit Pundir 
---
 drivers/nfc/st21nfca/dep.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nfc/st21nfca/dep.c b/drivers/nfc/st21nfca/dep.c
index fd08be2917e6..3420c5104c94 100644
--- a/drivers/nfc/st21nfca/dep.c
+++ b/drivers/nfc/st21nfca/dep.c
@@ -217,7 +217,8 @@ static int st21nfca_tm_recv_atr_req(struct nfc_hci_dev 
*hdev,
 
atr_req = (struct st21nfca_atr_req *)skb->data;
 
-   if (atr_req->length < sizeof(struct st21nfca_atr_req)) {
+   if (atr_req->length < sizeof(struct st21nfca_atr_req) ||
+   atr_req->length > skb->len) {
r = -EPROTO;
goto exit;
}
-- 
2.7.4



[RESEND][PATCH 3/4] NFC: Fix possible memory corruption when handling SHDLC I-Frame commands

2018-04-18 Thread Amit Pundir
From: Suren Baghdasaryan 

When handling SHDLC I-Frame commands "pipe" field used for indexing
into an array should be checked before usage. If left unchecked it
might access memory outside of the array of size NFC_HCI_MAX_PIPES(127).

Signed-off-by: Suren Baghdasaryan 
Signed-off-by: Amit Pundir 
---
 net/nfc/hci/core.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c
index ac8030c4bcf8..19cb2e473ea6 100644
--- a/net/nfc/hci/core.c
+++ b/net/nfc/hci/core.c
@@ -209,6 +209,11 @@ void nfc_hci_cmd_received(struct nfc_hci_dev *hdev, u8 
pipe, u8 cmd,
}
create_info = (struct hci_create_pipe_resp *)skb->data;
 
+   if (create_info->pipe >= NFC_HCI_MAX_PIPES) {
+   status = NFC_HCI_ANY_E_NOK;
+   goto exit;
+   }
+
/* Save the new created pipe and bind with local gate,
 * the description for skb->data[3] is destination gate id
 * but since we received this cmd from host controller, we
@@ -232,6 +237,11 @@ void nfc_hci_cmd_received(struct nfc_hci_dev *hdev, u8 
pipe, u8 cmd,
}
delete_info = (struct hci_delete_pipe_noti *)skb->data;
 
+   if (delete_info->pipe >= NFC_HCI_MAX_PIPES) {
+   status = NFC_HCI_ANY_E_NOK;
+   goto exit;
+   }
+
hdev->pipes[delete_info->pipe].gate = NFC_HCI_INVALID_GATE;
hdev->pipes[delete_info->pipe].dest_host = NFC_HCI_INVALID_HOST;
break;
-- 
2.7.4



[RESEND][PATCH 4/4] NFC: fdp: Fix possible buffer overflow in WCS4000 NFC driver

2018-04-18 Thread Amit Pundir
From: Suren Baghdasaryan 

Possible buffer overflow when reading next_read_size bytes into
tmp buffer after next_read_size was extracted from a previous packet.

Signed-off-by: Suren Baghdasaryan 
Signed-off-by: Amit Pundir 
---
 drivers/nfc/fdp/i2c.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c
index c4da50e07bbc..08a4f82a2965 100644
--- a/drivers/nfc/fdp/i2c.c
+++ b/drivers/nfc/fdp/i2c.c
@@ -176,6 +176,16 @@ static int fdp_nci_i2c_read(struct fdp_i2c_phy *phy, 
struct sk_buff **skb)
/* Packet that contains a length */
if (tmp[0] == 0 && tmp[1] == 0) {
phy->next_read_size = (tmp[2] << 8) + tmp[3] + 3;
+   /*
+* Ensure next_read_size does not exceed sizeof(tmp)
+* for reading that many bytes during next iteration
+*/
+   if (phy->next_read_size > FDP_NCI_I2C_MAX_PAYLOAD) {
+   dev_dbg(>dev, "%s: corrupted packet\n",
+   __func__);
+   phy->next_read_size = 5;
+   goto flush;
+   }
} else {
phy->next_read_size = FDP_NCI_I2C_MIN_PAYLOAD;
 
-- 
2.7.4



[RESEND][PATCH 2/4] NFC: st21nfca: Fix memory OOB and leak issues in connectivity events handler

2018-04-18 Thread Amit Pundir
From: Suren Baghdasaryan 

Overflow on memcpy is possible in kernel driver for st21nfca's
NFC HCI layer when handling connectivity events if aid_len or
params_len are bigger than the buffer size.
Memory leak is possible when parameter tag is invalid.

Signed-off-by: Suren Baghdasaryan 
Signed-off-by: Amit Pundir 
---
 drivers/nfc/st21nfca/se.c | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/nfc/st21nfca/se.c b/drivers/nfc/st21nfca/se.c
index 4bed9e842db3..acdce231e227 100644
--- a/drivers/nfc/st21nfca/se.c
+++ b/drivers/nfc/st21nfca/se.c
@@ -322,23 +322,33 @@ int st21nfca_connectivity_event_received(struct 
nfc_hci_dev *hdev, u8 host,
 * AID  81  5 to 16
 * PARAMETERS   82  0 to 255
 */
-   if (skb->len < NFC_MIN_AID_LENGTH + 2 &&
+   if (skb->len < NFC_MIN_AID_LENGTH + 2 ||
skb->data[0] != NFC_EVT_TRANSACTION_AID_TAG)
return -EPROTO;
 
+   /*
+* Buffer should have enough space for at least
+* two tag fields + two length fields + aid_len (skb->data[1])
+*/
+   if (skb->len < skb->data[1] + 4)
+   return -EPROTO;
+
transaction = (struct nfc_evt_transaction *)devm_kzalloc(dev,
   skb->len - 2, GFP_KERNEL);
 
transaction->aid_len = skb->data[1];
memcpy(transaction->aid, >data[2],
   transaction->aid_len);
+   transaction->params_len = skb->data[transaction->aid_len + 3];
 
-   /* Check next byte is PARAMETERS tag (82) */
+   /* Check next byte is PARAMETERS tag (82) and the length field 
*/
if (skb->data[transaction->aid_len + 2] !=
-   NFC_EVT_TRANSACTION_PARAMS_TAG)
+   NFC_EVT_TRANSACTION_PARAMS_TAG ||
+   skb->len < transaction->aid_len + transaction->params_len + 
4) {
+   devm_kfree(dev, transaction);
return -EPROTO;
+   }
 
-   transaction->params_len = skb->data[transaction->aid_len + 3];
memcpy(transaction->params, skb->data +
   transaction->aid_len + 4, transaction->params_len);
 
-- 
2.7.4



[RESEND][PATCH 0/4] Few NFC fixes from android-4.14 tree

2018-04-18 Thread Amit Pundir
Hi,

Resending few NFC fixes I picked up from android-4.14 tree[1]
for review and comments. They seem reasonable upstream candidates.
My last attempt was not timed properly and it got lost between
Christmas-New Year break and then Meltdown-Spectre happened.

Also like to point out that I have not feature tested these patches
at all. Only made small cosmetic changes to the original patches
(removed Android-only tag and internal bug ID) and build tested for
arm/arm64 defconfigs, before posting them here for review.

Really appreciate any comments or feedback on how to take it forward.

Regards,
Amit Pundir
[1] https://android.googlesource.com/kernel/common/+log/android-4.14

Suren Baghdasaryan (4):
  NFC: st21nfca: Fix out of bounds kernel access when handling ATR_REQ
  NFC: st21nfca: Fix memory OOB and leak issues in connectivity events
handler
  NFC: Fix possible memory corruption when handling SHDLC I-Frame
commands
  NFC: fdp: Fix possible buffer overflow in WCS4000 NFC driver

 drivers/nfc/fdp/i2c.c  | 10 ++
 drivers/nfc/st21nfca/dep.c |  3 ++-
 drivers/nfc/st21nfca/se.c  | 18 ++
 net/nfc/hci/core.c | 10 ++
 4 files changed, 36 insertions(+), 5 deletions(-)

-- 
2.7.4



Re: [PATCH 2/2] ath10k: support MAC address randomization in scan

2018-04-18 Thread Johannes Berg

> > > Is there a problem with the "supported commands" list?
> 
> My understanding is that in general the "supported commands" list is not 
> well-maintained. Not every nl80211 command is represented in the list so 
> user-space can not know whether it is missing or not supported.
> For this particular START_SCHED_SCAN command it can be used still and 
> indeed probably for a long time. I just wanted to point out that it is 
> not recommended for new user-space functionality.

We used to do it more, but most features are more complex than "command
is supported" or are simpler than "these 5 commands are supported" (just
a single bit to indicate the whole feature is enough), so we mostly use
extended feature flags now.

> > It sometimes feels like wpa_supplicant gets treated as a static entity
> > that can never be changed.  In fact, send a patch to Jouni implementing
> > the best practice, with a fallback to preserve compat for old kernels,
> > and I'm sure he'd entertain it.  Just because the supplicant does
> > something a certain way, doesn't mean it's the *best* way, but it too
> > evolves.

You also need to consider old supplicant on new kernels though? But I
didn't really follow this part of the discussion, so you're probably
taking that into account.

johannes


Re: iwlwifi 4.18rc1 SYNC TIME_QUOTA_CMD with fw 31

2018-04-18 Thread Emmanuel Grumbach
On Wed, Apr 18, 2018 at 5:47 AM, Scott Register  wrote:
>
> Hello,
>
> After upgrading to 4.18rc1 iwlwifi is printing a FW error. There was a
> previous thread with a similar
> issue but they seemed to resolve it with a ucode update. I think I'm
> running a newer FW and
> am still having an issue. 4.13 works--I haven't gone any higher so far.

Please download the firmware from
https://git.kernel.org/cgit/linux/kernel/git/iwlwifi/linux-firmware.git/plain/iwlwifi-8265-36.ucode
This should fix your problem.

>
> iwlwifi :02:00.0: Microcode SW error detected.  Restarting 0x200.
> iwlwifi :02:00.0: Start IWL Error Log Dump:
> iwlwifi :02:00.0: Status: 0x0100, count: 6
> iwlwifi :02:00.0: Loaded firmware version: 31.560484.0
> iwlwifi :02:00.0: 0x0038 | BAD_COMMAND
> iwlwifi :02:00.0: 0x00A002F1 | trm_hw_status0
> iwlwifi :02:00.0: 0x | trm_hw_status1
> iwlwifi :02:00.0: 0x0002495C | branchlink2
> iwlwifi :02:00.0: 0x0003962E | interruptlink1
> iwlwifi :02:00.0: 0x | interruptlink2
> iwlwifi :02:00.0: 0x | data1
> iwlwifi :02:00.0: 0x0032 | data2
> iwlwifi :02:00.0: 0x0032 | data3
> iwlwifi :02:00.0: 0x003B15C2 | beacon time
> iwlwifi :02:00.0: 0x0004EA3C | tsf low
> iwlwifi :02:00.0: 0x | tsf hi
> iwlwifi :02:00.0: 0x | time gp1
> iwlwifi :02:00.0: 0x0004EA3D | time gp2
> iwlwifi :02:00.0: 0x0001 | uCode revision type
> iwlwifi :02:00.0: 0x001F | uCode version major
> iwlwifi :02:00.0: 0x00088D64 | uCode version minor
> iwlwifi :02:00.0: 0x0230 | hw version
> iwlwifi :02:00.0: 0x00489000 | board version
> iwlwifi :02:00.0: 0x | hcmd
> iwlwifi :02:00.0: 0x00122080 | isr0
> iwlwifi :02:00.0: 0x | isr1
> iwlwifi :02:00.0: 0x28201802 | isr2
> iwlwifi :02:00.0: 0x404001C0 | isr3
> iwlwifi :02:00.0: 0x | isr4
> iwlwifi :02:00.0: 0x802F0051 | last cmd Id
> iwlwifi :02:00.0: 0x | wait_event
> iwlwifi :02:00.0: 0x277E | l2p_control
> iwlwifi :02:00.0: 0x0820 | l2p_duration
> iwlwifi :02:00.0: 0x | l2p_mhvalid
> iwlwifi :02:00.0: 0x | l2p_addr_match
> iwlwifi :02:00.0: 0x000D | lmpm_pmg_sel
> iwlwifi :02:00.0: 0x13091828 | timestamp
> iwlwifi :02:00.0: 0x2838 | flow_handler
> iwlwifi :02:00.0: Start IWL Error Log Dump:
> iwlwifi :02:00.0: Status: 0x0100, count: 7
> iwlwifi :02:00.0: 0x0034 | NMI_INTERRUPT_WDG
> iwlwifi :02:00.0: 0x | umac branchlink1
> iwlwifi :02:00.0: 0xC0086950 | umac branchlink2
> iwlwifi :02:00.0: 0xC00842BC | umac interruptlink1
> iwlwifi :02:00.0: 0xC00840CC | umac interruptlink2
> iwlwifi :02:00.0: 0x0400 | umac data1
> iwlwifi :02:00.0: 0xC00840CC | umac data2
> iwlwifi :02:00.0: 0xDEADBEEF | umac data3
> iwlwifi :02:00.0: 0x001F | umac major
> iwlwifi :02:00.0: 0x00088D64 | umac minor
> iwlwifi :02:00.0: 0xC08861DC | frame pointer
> iwlwifi :02:00.0: 0xC08861DC | stack pointer
> iwlwifi :02:00.0: 0x | last host cmd
> iwlwifi :02:00.0: 0x4008 | isr status reg
> ieee80211 phy0: Hardware restart was requested
> ieee80211 phy0: Hardware restart was requested
> iwlwifi :02:00.0: FW Error notification: type 0x cmd_id 0x34
> iwlwifi :02:00.0: FW Error notification: seq 0x0070 service 0x0034
> iwlwifi :02:00.0: FW Error notification: timestamp 0xD559
> iwlwifi :02:00.0: FW error in SYNC CMD TIME_QUOTA_CMD
> CPU: 7 PID: 83 Comm: kworker/7:1 Tainted: GW
> 4.17.0-041700rc1-generic #201804152230
> Hardware name: LENOVO 20KHCTO1WW/20KHCTO1WW, BIOS N23ET37W (1.12 ) 02/27/2018
>
> ethtool & lspci:
> driver: iwlwifi
> version: 4.17.0-041700rc1-generic
> firmware-version: 31.560484.0
> expansion-rom-version:
> bus-info: :02:00.0
> supports-statistics: yes
> supports-test: no
> supports-eeprom-access: no
> supports-register-dump: no
> supports-priv-flags: no
> 02:00.0 Network controller: Intel Corporation Wireless 8265 / 8275 (rev 78)
>
> Any ideas?
>
> Cheers,
> Scott


Re: [PATCH 2/2] ath10k: support MAC address randomization in scan

2018-04-18 Thread Arend van Spriel
+ Johannes (to confirm/correct my understanding regarding "supported 
commands")


On 4/18/2018 4:35 AM, Dan Williams wrote:

On Tue, 2018-04-17 at 15:26 -0700, Brian Norris wrote:

On Tue, Apr 17, 2018 at 2:49 PM, Arend van Spriel
 wrote:

On 4/17/2018 6:07 PM, Brian Norris wrote:

On Tue, Apr 17, 2018 at 10:22:13AM +0200, Arend van Spriel wrote:

I believe checking command support is not really recommended.
Instead, you
better check NL80211_ATTR_SCHED_SCAN_MAX_REQS being non-zero
(since kernel
4.12 that is).



Why not? Command support checking is what wpa_supplicant is
doing.



That's not really a good argument. A couple (or more) years ago
wpa_supplicant was not doing nl80211 but wext and some other using
driver private ioctls, but that did not make it the best approach.


I see what you're saying (though your comparison doesn't seem that
fair either; private ioctls are nothing like a well-defined nl80211
support list), and I'm totally good on looking at the new flag
eventually. But you still haven't answered my question ("why not?").
Is there a problem with the "supported commands" list?


My understanding is that in general the "supported commands" list is not 
well-maintained. Not every nl80211 command is represented in the list so 
user-space can not know whether it is missing or not supported.
For this particular START_SCHED_SCAN command it can be used still and 
indeed probably for a long time. I just wanted to point out that it is 
not recommended for new user-space functionality.



The START_SCHED_SCAN command is indeed still provided to user-
space:


And as I see it, it probably needs to be for essentially forever. Or
at least a significant amount of time after wpa_supplicant stops
relying on it. (Hint: it's still using it today, with no reference to
NL80211_ATTR_SCHED_SCAN_MAX_REQS.) There's a reason the kernel has
ABI
guarantees. I suspect you only get a chance to rewrite the world
(WEXT
-> nl80211) a few times in the life of kernel ABIs.


It sometimes feels like wpa_supplicant gets treated as a static entity
that can never be changed.  In fact, send a patch to Jouni implementing
the best practice, with a fallback to preserve compat for old kernels,
and I'm sure he'd entertain it.  Just because the supplicant does
something a certain way, doesn't mean it's the *best* way, but it too
evolves.


I was actually considering to do that. The netlink messages are easily 
checked for presence of an attribute so deciding on whether to use the 
fallback is trivial.


Regards,
Arend



Re: [PATCH v2 4/4] ath10k: Enable sta idle power save

2018-04-18 Thread Sebastian Gottschall

from my point of view powersave should be optional and not forced.

consider :
iw dev  set power_save on/off

so there is already a config option made for that purpose,

Sebastian

Am 17.04.2018 um 14:07 schrieb pill...@codeaurora.org:

From: Govind Singh 

Enable sta power save in fw for the targets that
supports idle power save. The idle ps enable command
will be ignored by the firmware which does not support
this feature.

Signed-off-by: Govind Singh 
Signed-off-by: Rakesh Pillai 
---
  drivers/net/wireless/ath/ath10k/mac.c | 7 +++
  1 file changed, 7 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 7e02ca02b28e..1d9222af1bb2 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -4679,6 +4679,13 @@ static int ath10k_start(struct ieee80211_hw *hw)
}
}
  
+	param = ar->wmi.pdev_param->idle_ps_config;

+   ret = ath10k_wmi_pdev_set_param(ar, param, 1);
+   if (ret && ret != -EOPNOTSUPP) {
+   ath10k_warn(ar, "failed to enable idle_ps_config: %d\n", ret);
+   goto err_core_stop;
+   }
+
__ath10k_set_antenna(ar, ar->cfg_tx_chainmask, ar->cfg_rx_chainmask);
  
  	/*



--
Mit freundlichen Grüssen / Regards

Sebastian Gottschall / CTO

NewMedia-NET GmbH - DD-WRT
Firmensitz:  Stubenwaldallee 21a, 64625 Bensheim
Registergericht: Amtsgericht Darmstadt, HRB 25473
Geschäftsführer: Peter Steinhäuser, Christian Scheele
http://www.dd-wrt.com
email: s.gottsch...@dd-wrt.com
Tel.: +496251-582650 / Fax: +496251-5826565