RE: [PATCH v7] Add new mac80211 driver mwlwifi.

2015-11-26 Thread David Lin
> On November 20, 2015 7:22 PM, Johannes Berg wrote:
> 
> On Thu, 2015-11-12 at 03:51 +, David Lin wrote:
> >
> > +static int print_mac_addr(char *p, u8 *mac_addr) {
> > +   int i;
> > +   char *str = p;
> > +
> > +   str += sprintf(str, "mac address: %02x", mac_addr[0]);
> > +   for (i = 1; i < ETH_ALEN; i++)
> > +   str += sprintf(str, ":%02x", mac_addr[i]);
> > +   str += sprintf(str, "\n");
> > +
> > +   return (str - p);
> > +}
> 
> You can use %pM here (and perhaps get rid of the function then)
> 

I will modify it.

> > +void mwl_debugfs_remove(struct ieee80211_hw *hw) {
> > +   struct mwl_priv *priv = hw->priv;
> > +
> > +   debugfs_remove(priv->debugfs_phy);
> 
> doesn't that have to be _recursive()?
> 
> > +#define MWL_DRV_NAME KBUILD_MODNAME
> > +#define MWL_DRV_VERSION "10.3.0.14"
> 
> versions like that are generally fairly useless since you don't update them 
> for
> every commit ...
> 

We still need version information for formal release.

> > +struct mwl_tx_desc {
> > +   u8 data_rate;
> > +   u8 tx_priority;
> > +   __le16 qos_ctrl;
> [...]
> 
> I still wouldn't mix device/firmware API with driver-use structures in the 
> same
> file, it gets confusing. It's your driver though, so if you really want to 
> confuse
> yourselves ... assuming you're going to maintain it :)
>

These fields are firmware API. Yes, we will maintain it.

> > +struct mwl_sta {
> > +   struct list_head list;
> > +   bool is_mesh_node;
> > +   bool is_ampdu_allowed;
> > +   struct mwl_tx_info tx_stats[MWL_MAX_TID];
> > +   bool is_amsdu_allowed;
> > +   spinlock_t amsdu_lock;  /* for amsdu
> > aggregation   */
> > +   struct mwl_amsdu_ctrl amsdu_ctrl;
> > +   u16 iv16;
> > +   u32 iv32;
> > +};
> 
> I still don't see how this iv stuff in the *station* can possibly be right. I 
> think I
> also pointed out earlier that you can just let
> mac80211 assign the PN/IV.
> 

I will try to modify the code to remove them.

> > +static int mwl_fwcmd_wait_complete(struct mwl_priv *priv, unsigned
> > short cmd)
> > +{
> >
> [...]
> > +   mdelay(3);
> > +
> > +   return 0;
> > +}
> > +
> > +static int mwl_fwcmd_exec_cmd(struct mwl_priv *priv, unsigned short
> > cmd)
> > +{
> [...]
> > +   if (mwl_fwcmd_wait_complete(priv, 0x8000 | cmd)) {
> [...]
> > +}
> > +
> > +static int mwl_fwcmd_802_11_radio_control(struct mwl_priv *priv,
> > +     bool enable, bool force)
> > +{
> [...]
> > +   spin_lock_bh(&priv->fwcmd_lock);
> [...]
> > +   if (mwl_fwcmd_exec_cmd(priv,
> > HOSTCMD_CMD_802_11_RADIO_CONTROL)) {
> > +   spin_unlock_bh(&priv->fwcmd_lock);
> 
> This seems like a terrible idea. Spinning for 3 milliseconds (and more) while
> blocking local soft-irqs is really bad for general latency on the system. I 
> don't
> like it at all.
> 
> And there doesn't really seem to be much reason for it either as far as I can
> tell - almost all places can (as I pointed out before) live with this being a
> mutex, you just need special handling in very few places that really do want 
> to
> send a command while not being able to sleep.
> 

I will try to use mutex in next patch soon.

> > +++ b/drivers/net/wireless/marvell/mwlwifi/hostcmd.h
> 
> This looks like you do have a file for commands - maybe move that TX thing
> above here?
> 

It is better to keep current file structure (easier for our internal 
maintenance syncing other files)

> > +const struct ieee80211_ops mwl_mac80211_ops = {
> > +   .tx = mwl_mac80211_tx,
> > +   .start  = mwl_mac80211_start,
> > +   .stop   = mwl_mac80211_stop,
> > +   .add_interface  = mwl_mac80211_add_interface,
> > +   .remove_interface   = mwl_mac80211_remove_interface,
> > +   .config = mwl_mac80211_config,
> > +   .bss_info_changed   = mwl_mac80211_bss_info_changed,
> > +   .configure_filter   = mwl_mac80211_configure_filter,
> > +   .set_key= mwl_mac80211_set_key,
> > +   .set_rts_threshold  = mwl_mac80211_set_rts_threshold,
> > +   .sta_add= mwl_mac80211_sta_add,
> > +   .sta_remove = mwl_mac80211_sta_remove,
> > +   .conf_tx= mwl_mac80211_conf_tx,
> > +   .get_stats  = mwl_mac80211_get_stats,
> > +   .get_survey = mwl_mac80211_get_survey,
> > +   .ampdu_action   = mwl_mac80211_ampdu_action, };
> 
> Apart from .tx and .configure_filter, all of these can sleep I think.
> 
> > +   rc = mwl_init_firmware(priv, fw_name);
> >
> Since you do this in .probe, you should consider loading the firmware
> asynchronously.
> 

I hope I can postpone this modification later.

> > +#ifdef CONFIG_SUPPORT_MFG
> 
> This Kconfig variable doesn't exist.
> 

The compile variable is used privately by Marvell and our customers in 
production line.

> > +static inline bool mwl_rx_process_mesh_amsdu(struct mwl_priv *priv,
> > +    struct sk_buff *skb,
> 
> 
> 
> 
> Please instead teach mac80211 to do it rig

RE: [PATCH v7] Add new mac80211 driver mwlwifi.

2015-11-26 Thread David Lin
> On November 13, 2015 3:48 AM, Jes Sorensen wrote:
> 
> David Lin  writes:
> > This patch provides the mwlwifi driver for Marvell 8863, 8864 and 8897
> > chipsets.
> > This driver was developed as part of the openwrt.org project to
> > support Linksys WRT1900AC and is maintained on
> https://github.com/kaloz/mwlwifi.
> >
> > The mwlwifi driver differs from existing mwifiex driver:
> > o mwlwifi is a "softmac driver" using the kernel? mac802.11 subsystem
> > to provide full AP/Wireless Bridge functionality (routers).
> > o mwifiex is a "fullmac driver" which provides a comprehensive set of
> > client functions (laptops/embedded devices) o only mwlwifi supports
> > Marvell AP chip 886X series
> >
> > NOTE: Users with Marvell 88W8897 chipsets currently should enable
> > (CONFIG=Y or M) either CONFIG_MWIFIEX or CONFIG_MWLWIFI, NOT
> BOTH.
> 
> I didn't get very far reading through this - but there was a few bits that 
> stood
> out like a sore thumb.
> 
> > mwlwifi driver leveraged code from existing MWL8K driver in the
> > following areas:
> > - 802.11n setting for mac80211
> > - Functions needed to hook up to mac80211
> > - Interactions with mac80211 to establish BA streams
> > - Partial firmware APIs, some data fields
> > - Method to pass Rx packets to mac80211 except 11ac rates
> >
> > In addition, mwlwifi driver supports:
> > - future scalability and future development (refactored source code)
> > - Marvell 802.11ac chipsets, including combo BT devices
> > - 802.11ac related settings and functions
> > - concurrent AP+STA functionalities with single firmware per chip
> > - firmware APIs for the supported chipset
> > - communicating new mac80211 settings to firmware
> > - Different TX/RX datapath where applicable
> > - A-MSDU and A-MPDU
> > - mac80211-based MESH (work in progress)
> > - Refined the code to establish BA streams
> >
> > NOTE: MWLWIFI will be organized under new vendor specific
> > folder/marvell, as per request of the gate keeper and community.
> >
> > Signed-off-by: David Lin 
> > ---
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS index 27b27c0..7c32f0a 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -6629,6 +6629,12 @@ L:   linux-wireless@vger.kernel.org
> >  S: Odd Fixes
> >  F: drivers/net/wireless/mwl8k.c
> >
> > +MARVELL MWLWIFI WIRELESS DRIVER
> > +M: David Lin 
> > +L: linux-wireless@vger.kernel.org
> > +S: Maintained
> > +F: drivers/net/wireless/marvell/mwlwifi
> > +
> >  MARVELL SOC MMC/SD/SDIO CONTROLLER DRIVER
> >  M: Nicolas Pitre 
> >  S: Odd Fixes
> > diff --git a/drivers/net/wireless/Kconfig
> > b/drivers/net/wireless/Kconfig index f9f9422..d599b35 100644
> > --- a/drivers/net/wireless/Kconfig
> > +++ b/drivers/net/wireless/Kconfig
> > @@ -285,5 +285,6 @@ source "drivers/net/wireless/zd1211rw/Kconfig"
> >  source "drivers/net/wireless/mwifiex/Kconfig"
> >  source "drivers/net/wireless/cw1200/Kconfig"
> >  source "drivers/net/wireless/rsi/Kconfig"
> > +source "drivers/net/wireless/marvell/Kconfig"
> >
> >  endif # WLAN
> > diff --git a/drivers/net/wireless/Makefile
> > b/drivers/net/wireless/Makefile index 740fdd3..71504a7 100644
> > --- a/drivers/net/wireless/Makefile
> > +++ b/drivers/net/wireless/Makefile
> > @@ -60,3 +60,5 @@ obj-$(CONFIG_BRCMSMAC)+= brcm80211/
> >
> >  obj-$(CONFIG_CW1200)   += cw1200/
> >  obj-$(CONFIG_RSI_91X)  += rsi/
> > +
> > +obj-$(CONFIG_WL_MARVELL)   += marvell/
> > diff --git a/drivers/net/wireless/marvell/Kconfig
> > b/drivers/net/wireless/marvell/Kconfig
> > new file mode 100644
> > index 000..d73e642
> > --- /dev/null
> > +++ b/drivers/net/wireless/marvell/Kconfig
> > @@ -0,0 +1,8 @@
> > +menuconfig WL_MARVELL
> > +   bool "Marvell Wireless LAN support"
> > +   ---help---
> > + Enable community drivers for Marvell Wi-Fi devices.
> > +
> > +if WL_MARVELL
> > +source "drivers/net/wireless/marvell/mwlwifi/Kconfig"
> > +endif # WL_MARVELL
> > diff --git a/drivers/net/wireless/marvell/Makefile
> > b/drivers/net/wireless/marvell/Makefile
> > new file mode 100644
> > index 000..70d1b3f
> > --- /dev/null
> > +++ b/drivers/net/wireless/marvell/Makefile
> > @@ -0,0 +1 @@
> > +obj-$(CONFIG_MWLWIFI)  += mwlwifi/
> > diff --git a/drivers/net/wireless/marvell/mwlwifi/Kconfig
> > b/drivers/net/wireless/marvell/mwlwifi/Kconfig
> > new file mode 100644
> > index 000..a9bcb9c
> > --- /dev/null
> > +++ b/drivers/net/wireless/marvell/mwlwifi/Kconfig
> > @@ -0,0 +1,23 @@
> > +config MWLWIFI
> > + tristate "Marvell Avastar 88W8864/88W8897 PCIe driver (mac80211
> > compatible)"
> > +   depends on PCI && MAC80211
> > +   select FW_LOADER
> > +   ---help---
> > +   Select to build the driver supporting the:
> > +
> > +   Marvell Wireless Wi-Fi 88W8864 modules
> > +   Marvell Wireless Wi-Fi 88W8897 modules
> > +
> > +   This driver uses the kernel's mac80211 subsystem.
> > +
> > + If you want to compile the driver as a module (= code which can be
> > +inserted in and removed from the running ker

[PATCH 1/2]iw: DEREF_AFTER_NULL: fix

2015-11-26 Thread Rahul Jain
From: Amit Khatri 

Signed-off-by: Amit Khatri 
Signed-off-by: Rahul Jain 
---
 wowlan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/wowlan.c b/wowlan.c
index 25f260b..ac2c13d 100644
--- a/wowlan.c
+++ b/wowlan.c
@@ -194,7 +194,8 @@ static int wowlan_parse_tcp_file(struct nl_msg *msg, const 
char *fn)
err = -ENOBUFS;
  close:
fclose(f);
-   nla_nest_end(msg, tcp);
+   if(tcp)
+   nla_nest_end(msg, tcp);
return err;
 }
 
-- 
1.9.1

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


[PATCH 2/2]iw: UNSPECIFIED_CHAR_IN_COND : Fix

2015-11-26 Thread Rahul Jain
From: Amit Khatri 

Signed-off-by: Amit Khatri 
Signed-off-by: Rahul Jain 
---
 util.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/util.c b/util.c
index 8fd14bd..7edc830 100644
--- a/util.c
+++ b/util.c
@@ -330,11 +330,13 @@ void print_ssid_escaped(const uint8_t len, const uint8_t 
*data)
 
 static int hex2num(char digit)
 {
+   unsigned char temp;
+   temp = digit;
if (!isxdigit(digit))
return -1;
if (isdigit(digit))
return digit - '0';
-   return tolower(digit) - 'a' + 10;
+   return tolower(temp) - 'a' + 10;
 }
 
 static int hex2byte(char *hex)
-- 
1.9.1

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


Re: [PATCH 2/2]iw: UNSPECIFIED_CHAR_IN_COND : Fix

2015-11-26 Thread Johannes Berg
Err, the other patch I can kinda understand - but this one? What kind
of static checker is giving that warning, and what does it really mean?
please describe in the commit log... actually I'm not sure why I should
apply this at all even, if there's a problem just make the function
prototype "unsigned char"?

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


Re: [PATCH v7] Add new mac80211 driver mwlwifi.

2015-11-26 Thread Johannes Berg
On Thu, 2015-11-26 at 08:27 +, David Lin wrote:

> > Since you do this in .probe, you should consider loading the
> > firmware asynchronously.
> > 
> 
> I hope I can postpone this modification later.

I don't feel strongly about this one - otoh it's not really
complicated.

> > > +#ifdef CONFIG_SUPPORT_MFG
> > 
> > This Kconfig variable doesn't exist.
> > 
> 
> The compile variable is used privately by Marvell and our customers
> in production line.

Yeah, still. Make it a proper Kconfig variable, defaulting to off and
hidden under something, or remove it. It's extremely misleading to have
something called CONFIG_* when it's not a Kconfig variable.

> Mac80211 does not support mesh AMSDU now, we implement this function
> in mwlwifi driver for the time being. Except for mesh AMSDU, we still
> leverage mac80211 to handle data AMSDU.

You're allowed to modify mac80211.

> > What's going on here? Why are you modifying the action frames on
> > the fly??!
> > 
> 
> Due to mwlwifi supports Tx/Rx AMSDU, these frames are modified to
> inform client that we support AMSDU.
> 

Ditto - you're allowed to modify mac80211. We actually have a patch
like this already:
https://git.kernel.org/cgit/linux/kernel/git/jberg/mac80211-
next.git/commit/?id=99e7ca44bb910f0cbfda5d9008e8517df0ebc939

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


[PATCH 2/8] mac80211: properly free TX skbs when monitor TX fails

2015-11-26 Thread Johannes Berg
From: Johannes Berg 

We need to free all skbs here, not just the one we peeked
from the list.

Signed-off-by: Johannes Berg 
---
 net/mac80211/tx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index bdc224d5053a..3311ce0f3d6c 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1431,7 +1431,7 @@ static bool __ieee80211_tx(struct ieee80211_local *local,
info->hw_queue =
vif->hw_queue[skb_get_queue_mapping(skb)];
} else if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) {
-   dev_kfree_skb(skb);
+   ieee80211_purge_tx_queue(&local->hw, skbs);
return true;
} else
vif = NULL;
-- 
2.6.2

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


[PATCH 3/8] mac80211: catch queue stop underflow

2015-11-26 Thread Johannes Berg
From: Johannes Berg 

If some code stops the queues more times than having started
(for when refcounting is used), warn on and reset the counter
to 0 to avoid blocking forever.

Signed-off-by: Johannes Berg 
---
 net/mac80211/util.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 74058020b7d6..08af2b307945 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -288,10 +288,13 @@ static void __ieee80211_wake_queue(struct ieee80211_hw 
*hw, int queue,
if (!test_bit(reason, &local->queue_stop_reasons[queue]))
return;
 
-   if (!refcounted)
+   if (!refcounted) {
local->q_stop_reasons[queue][reason] = 0;
-   else
+   } else {
local->q_stop_reasons[queue][reason]--;
+   if (WARN_ON(local->q_stop_reasons[queue][reason] < 0))
+   local->q_stop_reasons[queue][reason] = 0;
+   }
 
if (local->q_stop_reasons[queue][reason] == 0)
__clear_bit(reason, &local->queue_stop_reasons[queue]);
-- 
2.6.2

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


[PATCH 5/8] mac80211: move off-channel/mgmt-tx code to offchannel.oc

2015-11-26 Thread Johannes Berg
From: Johannes Berg 

This is quite a bit of code that logically depends here since
it has to deal with all the remain-on-channel logic.

Signed-off-by: Johannes Berg 
---
 net/mac80211/cfg.c | 500 ++---
 net/mac80211/ieee80211_i.h |  19 +-
 net/mac80211/offchannel.c  | 470 +-
 3 files changed, 498 insertions(+), 491 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 25199e2d9b50..ae1b92a58e23 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2509,294 +2509,6 @@ static int ieee80211_set_bitrate_mask(struct wiphy 
*wiphy,
return 0;
 }
 
-static bool ieee80211_coalesce_started_roc(struct ieee80211_local *local,
-  struct ieee80211_roc_work *new_roc,
-  struct ieee80211_roc_work *cur_roc)
-{
-   unsigned long now = jiffies;
-   unsigned long remaining = cur_roc->hw_start_time +
- msecs_to_jiffies(cur_roc->duration) -
- now;
-
-   if (WARN_ON(!cur_roc->started || !cur_roc->hw_begun))
-   return false;
-
-   /* if it doesn't fit entirely, schedule a new one */
-   if (new_roc->duration > jiffies_to_msecs(remaining))
-   return false;
-
-   ieee80211_handle_roc_started(new_roc);
-
-   /* add to dependents so we send the expired event properly */
-   list_add_tail(&new_roc->list, &cur_roc->dependents);
-   return true;
-}
-
-static u64 ieee80211_mgmt_tx_cookie(struct ieee80211_local *local)
-{
-   lockdep_assert_held(&local->mtx);
-
-   local->roc_cookie_counter++;
-
-   /* wow, you wrapped 64 bits ... more likely a bug */
-   if (WARN_ON(local->roc_cookie_counter == 0))
-   local->roc_cookie_counter++;
-
-   return local->roc_cookie_counter;
-}
-
-static int ieee80211_start_roc_work(struct ieee80211_local *local,
-   struct ieee80211_sub_if_data *sdata,
-   struct ieee80211_channel *channel,
-   unsigned int duration, u64 *cookie,
-   struct sk_buff *txskb,
-   enum ieee80211_roc_type type)
-{
-   struct ieee80211_roc_work *roc, *tmp;
-   bool queued = false;
-   int ret;
-
-   lockdep_assert_held(&local->mtx);
-
-   if (local->use_chanctx && !local->ops->remain_on_channel)
-   return -EOPNOTSUPP;
-
-   roc = kzalloc(sizeof(*roc), GFP_KERNEL);
-   if (!roc)
-   return -ENOMEM;
-
-   /*
-* If the duration is zero, then the driver
-* wouldn't actually do anything. Set it to
-* 10 for now.
-*
-* TODO: cancel the off-channel operation
-*   when we get the SKB's TX status and
-*   the wait time was zero before.
-*/
-   if (!duration)
-   duration = 10;
-
-   roc->chan = channel;
-   roc->duration = duration;
-   roc->req_duration = duration;
-   roc->frame = txskb;
-   roc->type = type;
-   roc->sdata = sdata;
-   INIT_DELAYED_WORK(&roc->work, ieee80211_sw_roc_work);
-   INIT_LIST_HEAD(&roc->dependents);
-
-   /*
-* cookie is either the roc cookie (for normal roc)
-* or the SKB (for mgmt TX)
-*/
-   if (!txskb) {
-   roc->cookie = ieee80211_mgmt_tx_cookie(local);
-   *cookie = roc->cookie;
-   } else {
-   roc->mgmt_tx_cookie = *cookie;
-   }
-
-   /* if there's one pending or we're scanning, queue this one */
-   if (!list_empty(&local->roc_list) ||
-   local->scanning || ieee80211_is_radar_required(local))
-   goto out_check_combine;
-
-   /* if not HW assist, just queue & schedule work */
-   if (!local->ops->remain_on_channel) {
-   ieee80211_queue_delayed_work(&local->hw, &roc->work, 0);
-   goto out_queue;
-   }
-
-   /* otherwise actually kick it off here (for error handling) */
-
-   ret = drv_remain_on_channel(local, sdata, channel, duration, type);
-   if (ret) {
-   kfree(roc);
-   return ret;
-   }
-
-   roc->started = true;
-   goto out_queue;
-
- out_check_combine:
-   list_for_each_entry(tmp, &local->roc_list, list) {
-   if (tmp->chan != channel || tmp->sdata != sdata)
-   continue;
-
-   /*
-* Extend this ROC if possible:
-*
-* If it hasn't started yet, just increase the duration
-* and add the new one to the list of dependents.
-* If the type of the new ROC has higher priority, modify the
-* type of the previous one to match that of the new one.
-*/
-   if (!

[PATCH 4/8] mac80211: fix mgmt-tx abort cookie and leak

2015-11-26 Thread Johannes Berg
From: Johannes Berg 

If a mgmt-tx operation is aborted before it runs, the wrong
cookie is reported back to userspace, and the ack_skb gets
leaked since the frame is freed directly instead of freeing
it using ieee80211_free_txskb(). Fix that.

Fixes: 3b79af973cf4 ("mac80211: stop using pointers as userspace cookies")
Signed-off-by: Johannes Berg 
---
 net/mac80211/offchannel.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
index 04401037140e..0fe9f746cd7e 100644
--- a/net/mac80211/offchannel.c
+++ b/net/mac80211/offchannel.c
@@ -308,11 +308,10 @@ void ieee80211_roc_notify_destroy(struct 
ieee80211_roc_work *roc, bool free)
 
/* was never transmitted */
if (roc->frame) {
-   cfg80211_mgmt_tx_status(&roc->sdata->wdev,
-   (unsigned long)roc->frame,
+   cfg80211_mgmt_tx_status(&roc->sdata->wdev, roc->mgmt_tx_cookie,
roc->frame->data, roc->frame->len,
false, GFP_KERNEL);
-   kfree_skb(roc->frame);
+   ieee80211_free_txskb(&roc->sdata->local->hw, roc->frame);
}
 
if (!roc->mgmt_tx_cookie)
-- 
2.6.2

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


[PATCH 7/8] mac80211_hwsim: delay hardware remain-on-channel start

2015-11-26 Thread Johannes Berg
From: Johannes Berg 

Typically drivers that implement hardware remain-on-channel will
have to wait for scheduling constraints, so make hwsim also wait
a little bit (only 20ms) before actually starting the operation.

Signed-off-by: Johannes Berg 
---
 drivers/net/wireless/mac80211_hwsim.c | 30 +-
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c 
b/drivers/net/wireless/mac80211_hwsim.c
index ee46f4647fbc..227c9c85d3ce 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -495,6 +495,9 @@ struct mac80211_hwsim_data {
const struct ieee80211_regdomain *regd;
 
struct ieee80211_channel *tmp_chan;
+   struct ieee80211_channel *roc_chan;
+   u32 roc_duration;
+   struct delayed_work roc_start;
struct delayed_work roc_done;
struct delayed_work hw_scan;
struct cfg80211_scan_request *hw_scan_request;
@@ -1987,6 +1990,23 @@ static void mac80211_hwsim_sw_scan_complete(struct 
ieee80211_hw *hw,
mutex_unlock(&hwsim->mutex);
 }
 
+static void hw_roc_start(struct work_struct *work)
+{
+   struct mac80211_hwsim_data *hwsim =
+   container_of(work, struct mac80211_hwsim_data, roc_start.work);
+
+   mutex_lock(&hwsim->mutex);
+
+   wiphy_debug(hwsim->hw->wiphy, "hwsim ROC begins\n");
+   hwsim->tmp_chan = hwsim->roc_chan;
+   ieee80211_ready_on_channel(hwsim->hw);
+
+   ieee80211_queue_delayed_work(hwsim->hw, &hwsim->roc_done,
+msecs_to_jiffies(hwsim->roc_duration));
+
+   mutex_unlock(&hwsim->mutex);
+}
+
 static void hw_roc_done(struct work_struct *work)
 {
struct mac80211_hwsim_data *hwsim =
@@ -2014,16 +2034,14 @@ static int mac80211_hwsim_roc(struct ieee80211_hw *hw,
return -EBUSY;
}
 
-   hwsim->tmp_chan = chan;
+   hwsim->roc_chan = chan;
+   hwsim->roc_duration = duration;
mutex_unlock(&hwsim->mutex);
 
wiphy_debug(hw->wiphy, "hwsim ROC (%d MHz, %d ms)\n",
chan->center_freq, duration);
+   ieee80211_queue_delayed_work(hw, &hwsim->roc_start, HZ/50);
 
-   ieee80211_ready_on_channel(hw);
-
-   ieee80211_queue_delayed_work(hw, &hwsim->roc_done,
-msecs_to_jiffies(duration));
return 0;
 }
 
@@ -2031,6 +2049,7 @@ static int mac80211_hwsim_croc(struct ieee80211_hw *hw)
 {
struct mac80211_hwsim_data *hwsim = hw->priv;
 
+   cancel_delayed_work_sync(&hwsim->roc_start);
cancel_delayed_work_sync(&hwsim->roc_done);
 
mutex_lock(&hwsim->mutex);
@@ -2375,6 +2394,7 @@ static int mac80211_hwsim_new_radio(struct genl_info 
*info,
hw->wiphy->n_iface_combinations = ARRAY_SIZE(hwsim_if_comb);
}
 
+   INIT_DELAYED_WORK(&data->roc_start, hw_roc_start);
INIT_DELAYED_WORK(&data->roc_done, hw_roc_done);
INIT_DELAYED_WORK(&data->hw_scan, hw_scan_work);
 
-- 
2.6.2

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


[PATCH 8/8] mac80211: rewrite remain-on-channel logic

2015-11-26 Thread Johannes Berg
From: Johannes Berg 

Jouni found a bug in the remain-on-channel logic: when a short item
is queued, a long item is combined with it extending the original
one, and then the long item is deleted, the timeout doesn't go back
to the short one, and the short item ends up taking a long time. In
this case, this showed as blocking scan when running two test cases
back to back - the scan from the second was delayed even though all
the remain-on-channel items should long have been gone.

Fixing this with the current data structures turns out to be a bit
complicated, we just remove the long item from the dependents list
right now and don't recalculate the timeouts.

There's a somewhat similar bug where we delete the short item and
all the dependents go with it; to fix this we'd have to move them
from the dependents to the real list.

Instead of trying to do that, rewrite the code to not have all this
complexity in the data structures: use a single list and allow more
than one entry in it being marked as started. This makes the code a
bit more complex, the worker needs to understand that it might need
to just remove one of the started items, while keeping the device
off-channel, but that's not more complicated than the nested data
structures.

This then fixes both issues described, and makes it easier to also
limit the overall off-channel time when combining.

TODO: as before, with hardware remain-on-channel, deleting an item
after combining results in cancelling them all - we can keep track
of the time elapsed and only cancel after that to fix this.

Signed-off-by: Johannes Berg 
---
 net/mac80211/ieee80211_i.h |   7 +-
 net/mac80211/main.c|   1 +
 net/mac80211/offchannel.c  | 599 +++--
 3 files changed, 316 insertions(+), 291 deletions(-)

diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 0c50031fadac..c30b6842ed9f 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -325,19 +325,15 @@ struct mesh_preq_queue {
 
 struct ieee80211_roc_work {
struct list_head list;
-   struct list_head dependents;
-
-   struct delayed_work work;
 
struct ieee80211_sub_if_data *sdata;
 
struct ieee80211_channel *chan;
 
bool started, abort, hw_begun, notified;
-   bool to_be_freed;
bool on_channel;
 
-   unsigned long hw_start_time;
+   unsigned long start_time;
 
u32 duration, req_duration;
struct sk_buff *frame;
@@ -1335,6 +1331,7 @@ struct ieee80211_local {
/*
 * Remain-on-channel support
 */
+   struct delayed_work roc_work;
struct list_head roc_list;
struct work_struct hw_roc_start, hw_roc_done;
unsigned long hw_roc_start_time;
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 858f6b1cb149..6bcf0faa4a89 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -1149,6 +1149,7 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw)
 
rtnl_unlock();
 
+   cancel_delayed_work_sync(&local->roc_work);
cancel_work_sync(&local->restart_work);
cancel_work_sync(&local->reconfig_filter);
cancel_work_sync(&local->tdls_chsw_work);
diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
index d616ce34fea7..ce8e1a6c7281 100644
--- a/net/mac80211/offchannel.c
+++ b/net/mac80211/offchannel.c
@@ -187,11 +187,76 @@ void ieee80211_offchannel_return(struct ieee80211_local 
*local)
false);
 }
 
-static void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc)
+static void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc)
 {
-   if (roc->notified)
+   /* was never transmitted */
+   if (roc->frame) {
+   cfg80211_mgmt_tx_status(&roc->sdata->wdev, roc->mgmt_tx_cookie,
+   roc->frame->data, roc->frame->len,
+   false, GFP_KERNEL);
+   ieee80211_free_txskb(&roc->sdata->local->hw, roc->frame);
+   }
+
+   if (!roc->mgmt_tx_cookie)
+   cfg80211_remain_on_channel_expired(&roc->sdata->wdev,
+  roc->cookie, roc->chan,
+  GFP_KERNEL);
+
+   list_del(&roc->list);
+   kfree(roc);
+}
+
+static unsigned long ieee80211_end_finished_rocs(struct ieee80211_local *local,
+unsigned long now)
+{
+   struct ieee80211_roc_work *roc, *tmp;
+   long remaining_dur_min = LONG_MAX;
+
+   lockdep_assert_held(&local->mtx);
+
+   list_for_each_entry_safe(roc, tmp, &local->roc_list, list) {
+   long remaining;
+
+   if (!roc->started)
+   break;
+
+   remaining = roc->start_time +
+   msecs_to_jiffies(roc->duration) -
+   now;
+
+   if (

[PATCH 1/8] mac80211: properly free skb when r-o-c for TX fails

2015-11-26 Thread Johannes Berg
From: Johannes Berg 

When freeing the TX skb for an off-channel TX, use the correct
API to also free the ACK skb that might have been allocated.

Signed-off-by: Johannes Berg 
---
 net/mac80211/cfg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index c2bd1b6a6922..25199e2d9b50 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3475,7 +3475,7 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct 
wireless_dev *wdev,
   params->wait, cookie, skb,
   IEEE80211_ROC_TYPE_MGMT_TX);
if (ret)
-   kfree_skb(skb);
+   ieee80211_free_txskb(&local->hw, skb);
  out_unlock:
mutex_unlock(&local->mtx);
return ret;
-- 
2.6.2

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


[PATCH 6/8] mac80211: simplify ack_skb handling

2015-11-26 Thread Johannes Berg
From: Johannes Berg 

Since the cookie is assigned inside ieee80211_make_ack_skb()
now, we no longer need to return the ack_skb as the cookie
and can simplify the function's return and the callers. Also
rename it to ieee80211_attach_ack_skb() to more accurately
reflect its purpose.

Signed-off-by: Johannes Berg 
---
 net/mac80211/cfg.c | 18 --
 net/mac80211/ieee80211_i.h |  5 ++---
 net/mac80211/offchannel.c  | 11 +++
 3 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index ae1b92a58e23..2274a163874f 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2992,9 +2992,8 @@ u64 ieee80211_mgmt_tx_cookie(struct ieee80211_local 
*local)
return local->roc_cookie_counter;
 }
 
-struct sk_buff *ieee80211_make_ack_skb(struct ieee80211_local *local,
-  struct sk_buff *skb, u64 *cookie,
-  gfp_t gfp)
+int ieee80211_attach_ack_skb(struct ieee80211_local *local, struct sk_buff 
*skb,
+u64 *cookie, gfp_t gfp)
 {
unsigned long spin_flags;
struct sk_buff *ack_skb;
@@ -3002,7 +3001,7 @@ struct sk_buff *ieee80211_make_ack_skb(struct 
ieee80211_local *local,
 
ack_skb = skb_copy(skb, gfp);
if (!ack_skb)
-   return ERR_PTR(-ENOMEM);
+   return -ENOMEM;
 
spin_lock_irqsave(&local->ack_status_lock, spin_flags);
id = idr_alloc(&local->ack_status_frames, ack_skb,
@@ -3011,7 +3010,7 @@ struct sk_buff *ieee80211_make_ack_skb(struct 
ieee80211_local *local,
 
if (id < 0) {
kfree_skb(ack_skb);
-   return ERR_PTR(-ENOMEM);
+   return -ENOMEM;
}
 
IEEE80211_SKB_CB(skb)->ack_frame_id = id;
@@ -3019,7 +3018,7 @@ struct sk_buff *ieee80211_make_ack_skb(struct 
ieee80211_local *local,
*cookie = ieee80211_mgmt_tx_cookie(local);
IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie;
 
-   return ack_skb;
+   return 0;
 }
 
 static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
@@ -3097,7 +3096,7 @@ static int ieee80211_probe_client(struct wiphy *wiphy, 
struct net_device *dev,
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
struct ieee80211_local *local = sdata->local;
struct ieee80211_qos_hdr *nullfunc;
-   struct sk_buff *skb, *ack_skb;
+   struct sk_buff *skb;
int size = sizeof(*nullfunc);
__le16 fc;
bool qos;
@@ -3165,10 +3164,9 @@ static int ieee80211_probe_client(struct wiphy *wiphy, 
struct net_device *dev,
if (qos)
nullfunc->qos_ctrl = cpu_to_le16(7);
 
-   ack_skb = ieee80211_make_ack_skb(local, skb, cookie, GFP_ATOMIC);
-   if (IS_ERR(ack_skb)) {
+   ret = ieee80211_attach_ack_skb(local, skb, cookie, GFP_ATOMIC);
+   if (ret) {
kfree_skb(skb);
-   ret = PTR_ERR(ack_skb);
goto unlock;
}
 
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index b03d5410a2e9..0c50031fadac 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1484,9 +1484,8 @@ void ieee80211_configure_filter(struct ieee80211_local 
*local);
 u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata);
 
 u64 ieee80211_mgmt_tx_cookie(struct ieee80211_local *local);
-struct sk_buff *ieee80211_make_ack_skb(struct ieee80211_local *local,
-  struct sk_buff *skb, u64 *cookie,
-  gfp_t gfp);
+int ieee80211_attach_ack_skb(struct ieee80211_local *local, struct sk_buff 
*skb,
+u64 *cookie, gfp_t gfp);
 
 /* STA code */
 void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata);
diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
index bf21301dfa4b..d616ce34fea7 100644
--- a/net/mac80211/offchannel.c
+++ b/net/mac80211/offchannel.c
@@ -733,7 +733,7 @@ int ieee80211_mgmt_tx(struct wiphy *wiphy, struct 
wireless_dev *wdev,
 {
struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
struct ieee80211_local *local = sdata->local;
-   struct sk_buff *skb, *ack_skb;
+   struct sk_buff *skb;
struct sta_info *sta;
const struct ieee80211_mgmt *mgmt = (void *)params->buf;
bool need_offchan = false;
@@ -876,16 +876,11 @@ int ieee80211_mgmt_tx(struct wiphy *wiphy, struct 
wireless_dev *wdev,
/* make a copy to preserve the frame contents
 * in case of encryption.
 */
-   ack_skb = ieee80211_make_ack_skb(local, skb, cookie,
-GFP_KERNEL);
-   if (IS_ERR(ack_skb)) {
-   ret = PTR_ERR(ack_skb);
+   ret = ieee80211_attach_ack_skb(local, skb, cookie, GFP_KERNEL);
+   if (ret) {
  

[patch] rt2x00: type bug in _rt2500usb_register_read()

2015-11-26 Thread Dan Carpenter
This code causes a static checker bug.

drivers/net/wireless/ralink/rt2x00/rt2500usb.c:232 _rt2500usb_register_read()
warn: passing casted pointer 'value' to 'rt2500usb_register_read()' 32 vs 16.

If the low 16 bits were initialized to zero then this code would only be
a problem on big endian systems.  But in this case this is case the low
16 bits are never initialized.  This is called from a function which is
created using a macro:

RT2X00DEBUGFS_OPS(csr, "0x%.8x\n", u32);

We end up copying uninitialized data to the user which is bogus and an
information leak.

Signed-off-by: Dan Carpenter 
---
Not tested.  Perhaps we should just remove this code since it has never
worked.

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2500usb.c 
b/drivers/net/wireless/ralink/rt2x00/rt2500usb.c
index b50d873..d26018f 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2500usb.c
@@ -229,7 +229,10 @@ static void _rt2500usb_register_read(struct rt2x00_dev 
*rt2x00dev,
 const unsigned int offset,
 u32 *value)
 {
-   rt2500usb_register_read(rt2x00dev, offset, (u16 *)value);
+   u16 tmp;
+
+   rt2500usb_register_read(rt2x00dev, offset, &tmp);
+   *value = tmp;
 }
 
 static void _rt2500usb_register_write(struct rt2x00_dev *rt2x00dev,
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [1/9] brcmfmac: Add support for the BCM4359 11ac RSDB PCIE device.

2015-11-26 Thread Kalle Valo

> From: Hante Meuleman 
> 
> Reviewed-by: Arend Van Spriel 
> Reviewed-by: Pieter-Paul Giesberts 
> Signed-off-by: Hante Meuleman 
> Signed-off-by: Arend van Spriel 

Thanks, 9 patches applied to wireless-drivers-next.git:

2aff030355b5 brcmfmac: Add support for the BCM4359 11ac RSDB PCIE device.
c9c0043894cf brcmfmac: Simplify and fix usage of brcmf_ifname.
31fa86cb342b brcmfmac: Remove unnecessary check from start_xmit.
da402c56bc91 brcmfmac: Remove unncessary variable irq_requested.
dc1a272ec440 brcmfmac: Disable runtime pm for USB.
8abffd8173a1 brcmfmac: Add RSDB support.
37a869ec8593 brcmfmac: Use consistent naming for bsscfgidx.
c2a43a6ba5e5 brcmfmac: Use new methods for pcie Power Management.
aeb64225aa8e brcmfmac: Add wowl wake indication report.

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


(bug report) b43: precendence error

2015-11-26 Thread Dan Carpenter
[ All the old wireless Smatch warnings are showing up as new ones
  because of the path reshuffle in linux-next.  I'm going through and
  reporting the extra suspicious ones.  -dan ]

Hello Rafał Miłecki,

The patch 6f98e62a9f1b: "b43: update cordic code to match current
specs" from Jan 25, 2010, leads to the following static checker
warning:

drivers/net/wireless/broadcom/b43/phy_lp.c:1803 lpphy_start_tx_tone()
warn: mask and shift to zero

drivers/net/wireless/broadcom/b43/phy_lp.c
  1800  for (i = 0; i < samples; i++) {
  1801  sample = b43_cordic(angle);
  1802  angle += rotation;
  1803  buf[i] = CORDIC_CONVERT((sample.i * max) & 0xFF) << 8;
  1804  buf[i] |= CORDIC_CONVERT((sample.q * max) & 0xFF);

Maybe the intention was:

buf[i] = (CORDIC_CONVERT(sample.i * max) & 0xFF) << 8;
buf[i] |= CORDIC_CONVERT((sample.q * max) & 0xFF;

  1805  }
  1806  

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


(bug report) b43: impossible conditions in debugfs

2015-11-26 Thread Dan Carpenter
Hello Michael Buesch,

The patch 6bbc321a96d4: "b43: Add debugfs files for random SHM
access" from Jun 19, 2008, leads to the following static checker
warning:

drivers/net/wireless/broadcom/b43/debugfs.c:217 shm32write__write_file()
warn: impossible condition '(mask > 4294967295) => (0-u32max > u32max)'

drivers/net/wireless/broadcom/b43/debugfs.c
   198  static int shm32write__write_file(struct b43_wldev *dev,
   199const char *buf, size_t count)
   200  {
   201  unsigned int routing, addr, mask, set;
   202  u32 val;
   203  int res;
   204  
   205  res = sscanf(buf, "0x%X 0x%X 0x%X 0x%X",
   206   &routing, &addr, &mask, &set);
   207  if (res != 4)
   208  return -EINVAL;
   209  if (routing > B43_MAX_SHM_ROUTING)
   210  return -EADDRNOTAVAIL;
   211  if (addr > B43_MAX_SHM_ADDR)
   212  return -EADDRNOTAVAIL;
   213  if (routing == B43_SHM_SHARED) {
   214  if ((addr % 2) != 0)
   215  return -EADDRNOTAVAIL;
   216  }
   217  if ((mask > 0x) || (set > 0x))

Both of these conditions are impossible.

   218  return -E2BIG;
   219  
   220  if (mask == 0)
   221  val = 0;
   222  else
   223  val = b43_shm_read32(dev, routing, addr);
   224  val &= mask;
   225  val |= set;
   226  b43_shm_write32(dev, routing, addr, val);
   227  
   228  return 0;
   229  }

See also:
drivers/net/wireless/broadcom/b43/debugfs.c:346 mmio32write__write_file() warn: 
impossible condition '(mask > 4294967295) => (0-u32max > u32max)'
drivers/net/wireless/broadcom/b43/debugfs.c:346 mmio32write__write_file() warn: 
impossible condition '(set > 4294967295) => (0-u32max > u32max)'


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


(bug report) iwlwifi: inconsitent NULL checking

2015-11-26 Thread Dan Carpenter
[ All old wireless warnings are showing up as new because the files
  moved around in linux-next.  - dan ]

Hello Johannes Berg,

The patch 8ca151b568b6: "iwlwifi: add the MVM driver" from Jan 24,
2013, leads to the following static checker warning:

drivers/net/wireless/intel/iwlwifi/mvm/rs.c:2802 rs_get_rate()
error: we previously assumed 'lq_sta' could be null (see line 2793)

drivers/net/wireless/intel/iwlwifi/mvm/rs.c
  2790  /* TODO: handle rate_idx_mask and rate_idx_mcs_mask */
  2791  
  2792  /* Treat uninitialized rate scaling data same as non-existing. 
*/
  2793  if (lq_sta && !lq_sta->pers.drv) {
^^
Check.

  2794  IWL_DEBUG_RATE(mvm, "Rate scaling not initialized 
yet.\n");
  2795  mvm_sta = NULL;
  2796  }
  2797  
  2798  /* Send management frames and NO_ACK data using lowest rate. */
  2799  if (rate_control_send_low(sta, mvm_sta, txrc))
  2800  return;
  2801  
  2802  iwl_mvm_hwrate_to_tx_rate(lq_sta->last_rate_n_flags,
  ^
Uchecked dereference.

  2803info->band, &info->control.rates[0]);
  2804  info->control.rates[0].count = 1;
  2805  

See also:
drivers/net/wireless/intel/iwlwifi/dvm/rs.c:2742 rs_get_rate() error: we 
previously assumed 'lq_sta' could be null (see line 2733)


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


Re: brcm80211: Delete an unnecessary check before the function call"release_firmware"

2015-11-26 Thread Kalle Valo

> From: Markus Elfring 
> Date: Fri, 6 Nov 2015 08:48:23 +0100
> 
> The release_firmware() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring 
> Acked-by: Arend van Spriel 

Thanks, applied to wireless-drivers-next.git.

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


Re: ath9k_htc: check for underflow in ath9k_htc_rx_msg()

2015-11-26 Thread Kalle Valo

> We check for overflow here, but we don't check for underflow so it
> causes a static checker warning.
> 
> Fixes: fb9987d0f748 ('ath9k_htc: Support for AR9271 chipset.')
> Signed-off-by: Dan Carpenter 

Thanks, applied to wireless-drivers-next.git.

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


[patch] libertas: cleanup a variable name

2015-11-26 Thread Dan Carpenter
"&card->priv->driver_lock" and "&priv->driver_lock" are the same and
it's nicer to use the shorter one consistently.

Signed-off-by: Dan Carpenter 

diff --git a/drivers/net/wireless/marvell/libertas/if_sdio.c 
b/drivers/net/wireless/marvell/libertas/if_sdio.c
index 33ceda2..68fd3a9 100644
--- a/drivers/net/wireless/marvell/libertas/if_sdio.c
+++ b/drivers/net/wireless/marvell/libertas/if_sdio.c
@@ -228,7 +228,7 @@ static int if_sdio_handle_cmd(struct if_sdio_card *card,
memcpy(priv->resp_buf[i], buffer, size);
lbs_notify_command_response(priv, i);
 
-   spin_unlock_irqrestore(&card->priv->driver_lock, flags);
+   spin_unlock_irqrestore(&priv->driver_lock, flags);
 
ret = 0;
 
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ath10k: Fix check for !THERMAL case

2015-11-26 Thread Mark Brown
When defining stubs for !THERMAL cases we currently check if CONFIG_THERMAL
is defined but this fails when the thermal code is built as a module in
which case CONFIG_THERMAL_MODULE is defined instead causing us to define
the stubs as well as building the actual ath10k thermal code which in turn
causes the build to fail on arm64 allmodconfig. Fix this by changing the
check in the header to use IS_ENABLED().

Signed-off-by: Mark Brown 
---
 drivers/net/wireless/ath/ath10k/thermal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/thermal.h 
b/drivers/net/wireless/ath/ath10k/thermal.h
index b610ea5caae8..793eec160e65 100644
--- a/drivers/net/wireless/ath/ath10k/thermal.h
+++ b/drivers/net/wireless/ath/ath10k/thermal.h
@@ -36,7 +36,7 @@ struct ath10k_thermal {
int temperature;
 };
 
-#ifdef CONFIG_THERMAL
+#if IS_ENABLED(CONFIG_THERMAL)
 int ath10k_thermal_register(struct ath10k *ar);
 void ath10k_thermal_unregister(struct ath10k *ar);
 void ath10k_thermal_event_temperature(struct ath10k *ar, int temperature);
-- 
2.6.2

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


Re: (bug report) iwlwifi: inconsitent NULL checking

2015-11-26 Thread Johannes Berg
On Thu, 2015-11-26 at 15:03 +0300, Dan Carpenter wrote:
> 
>   2793  if (lq_sta && !lq_sta->pers.drv) {
> ^^
> Check.
> 
>   2794  IWL_DEBUG_RATE(mvm, "Rate scaling not
> initialized yet.\n");
>   2795  mvm_sta = NULL;
>   2796  }
>   2797  
>   2798  /* Send management frames and NO_ACK data using
> lowest rate. */
>   2799  if (rate_control_send_low(sta, mvm_sta, txrc))
>   2800  return;
>   2801  
>   2802  iwl_mvm_hwrate_to_tx_rate(lq_sta->last_rate_n_flags,
>   ^
> Uchecked dereference.
> 

Yeah, this is a bit tricky. If you look into rate_control_send_low(),
I'm sure it'll return true when mvm_sta argument is NULL. Not sure how,
if at all, we could make that more explicit here.

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


Re: next-20151126 build: 3 failures 15 warnings (next-20151126)

2015-11-26 Thread Mark Brown
On Thu, Nov 26, 2015 at 09:06:25AM +, Build bot for Mark Brown wrote:

Today's -next fails to build an arm64 allmodconfig due to:

>   arm64-allmodconfig
> ../drivers/net/wireless/ath/ath10k/thermal.c:119:6: error: redefinition of 
> 'ath10k_thermal_event_temperature'
> ../drivers/net/wireless/ath/ath10k/thermal.c:136:6: error: redefinition of 
> 'ath10k_thermal_set_throttling'
> ../drivers/net/wireless/ath/ath10k/thermal.c:162:5: error: redefinition of 
> 'ath10k_thermal_register'
> ../drivers/net/wireless/ath/ath10k/thermal.c:216:6: error: redefinition of 
> 'ath10k_thermal_unregister'

This is happening because there are stub functions provided in the
driver's thermal.h for !THERMAL cases but these are guarded by an #ifdef
not an #if and so fails to do the right thing if the thermal code is
built as a module.  It looks like this was somehow triggered as part of
the reorganisation of the WiFi directory structure.


signature.asc
Description: PGP signature


Re: [patch] rt2x00: type bug in _rt2500usb_register_read()

2015-11-26 Thread walter harms


Am 26.11.2015 12:55, schrieb Dan Carpenter:
> This code causes a static checker bug.
> 
> drivers/net/wireless/ralink/rt2x00/rt2500usb.c:232 _rt2500usb_register_read()
> warn: passing casted pointer 'value' to 'rt2500usb_register_read()' 32 vs 16.
> 
> If the low 16 bits were initialized to zero then this code would only be
> a problem on big endian systems.  But in this case this is case the low
> 16 bits are never initialized.  This is called from a function which is
> created using a macro:
> 
> RT2X00DEBUGFS_OPS(csr, "0x%.8x\n", u32);
> 
> We end up copying uninitialized data to the user which is bogus and an
> information leak.
> 
> Signed-off-by: Dan Carpenter 
> ---
> Not tested.  Perhaps we should just remove this code since it has never
> worked.
> 
> diff --git a/drivers/net/wireless/ralink/rt2x00/rt2500usb.c 
> b/drivers/net/wireless/ralink/rt2x00/rt2500usb.c
> index b50d873..d26018f 100644
> --- a/drivers/net/wireless/ralink/rt2x00/rt2500usb.c
> +++ b/drivers/net/wireless/ralink/rt2x00/rt2500usb.c
> @@ -229,7 +229,10 @@ static void _rt2500usb_register_read(struct rt2x00_dev 
> *rt2x00dev,
>const unsigned int offset,
>u32 *value)
>  {
> - rt2500usb_register_read(rt2x00dev, offset, (u16 *)value);
> + u16 tmp;
> +
> + rt2500usb_register_read(rt2x00dev, offset, &tmp);
> + *value = tmp;
>  }
>  

perhaps, cleaning *value would be sufficient ? Avoiding the need for a tmp var.

*value = 0
rt2500usb_register_read(rt2x00dev, offset, (u16 *)value);


re,
 wh

>  static void _rt2500usb_register_write(struct rt2x00_dev *rt2x00dev,
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: (bug report) b43: impossible conditions in debugfs

2015-11-26 Thread Michael Büsch
On Thu, 26 Nov 2015 14:59:24 +0300
Dan Carpenter  wrote:

> Hello Michael Buesch,
> 
> The patch 6bbc321a96d4: "b43: Add debugfs files for random SHM
> access" from Jun 19, 2008, leads to the following static checker
> warning:
> 
>   drivers/net/wireless/broadcom/b43/debugfs.c:217 shm32write__write_file()
>   warn: impossible condition '(mask > 4294967295) => (0-u32max > u32max)'
> 
> drivers/net/wireless/broadcom/b43/debugfs.c
>198  static int shm32write__write_file(struct b43_wldev *dev,
>199const char *buf, size_t count)
>200  {
>201  unsigned int routing, addr, mask, set;
>202  u32 val;
>203  int res;
>204  
>205  res = sscanf(buf, "0x%X 0x%X 0x%X 0x%X",
>206   &routing, &addr, &mask, &set);
>207  if (res != 4)
>208  return -EINVAL;
>209  if (routing > B43_MAX_SHM_ROUTING)
>210  return -EADDRNOTAVAIL;
>211  if (addr > B43_MAX_SHM_ADDR)
>212  return -EADDRNOTAVAIL;
>213  if (routing == B43_SHM_SHARED) {
>214  if ((addr % 2) != 0)
>215  return -EADDRNOTAVAIL;
>216  }
>217  if ((mask > 0x) || (set > 0x))
> 
> Both of these conditions are impossible.
> 
>218  return -E2BIG;
>219  
>220  if (mask == 0)
>221  val = 0;
>222  else
>223  val = b43_shm_read32(dev, routing, addr);
>224  val &= mask;
>225  val |= set;
>226  b43_shm_write32(dev, routing, addr, val);
>227  
>228  return 0;
>229  }
> 
> See also:
> drivers/net/wireless/broadcom/b43/debugfs.c:346 mmio32write__write_file() 
> warn: impossible condition '(mask > 4294967295) => (0-u32max > u32max)'
> drivers/net/wireless/broadcom/b43/debugfs.c:346 mmio32write__write_file() 
> warn: impossible condition '(set > 4294967295) => (0-u32max > u32max)'



Sure. These are intentional.
The compiler will optimize this out.

-- 
Michael


pgpVxbGfqgyhy.pgp
Description: OpenPGP digital signature


Re: [patch] rt2x00: type bug in _rt2500usb_register_read()

2015-11-26 Thread Dan Carpenter
On Thu, Nov 26, 2015 at 01:21:48PM +0100, walter harms wrote:
> > If the low 16 bits were initialized to zero then this code would only be
> > a problem on big endian systems.

> perhaps, cleaning *value would be sufficient ? Avoiding the need for a tmp 
> var.
> 
> *value = 0
> rt2500usb_register_read(rt2x00dev, offset, (u16 *)value);
> 

Because if you initialize value then you still have a bug on big endian
systems.

regards,
dan carpenter

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


Re: (bug report) iwlwifi: inconsitent NULL checking

2015-11-26 Thread Dan Carpenter
On Thu, Nov 26, 2015 at 01:16:51PM +0100, Johannes Berg wrote:
> On Thu, 2015-11-26 at 15:03 +0300, Dan Carpenter wrote:
> > 
> >   2793  if (lq_sta && !lq_sta->pers.drv) {
> > ^^
> > Check.
> > 
> >   2794  IWL_DEBUG_RATE(mvm, "Rate scaling not
> > initialized yet.\n");
> >   2795  mvm_sta = NULL;
> >   2796  }
> >   2797  
> >   2798  /* Send management frames and NO_ACK data using
> > lowest rate. */
> >   2799  if (rate_control_send_low(sta, mvm_sta, txrc))
> >   2800  return;
> >   2801  
> >   2802  iwl_mvm_hwrate_to_tx_rate(lq_sta->last_rate_n_flags,
> >   ^
> > Uchecked dereference.
> > 
> 
> Yeah, this is a bit tricky. If you look into rate_control_send_low(),
> I'm sure it'll return true when mvm_sta argument is NULL. Not sure how,
> if at all, we could make that more explicit here.

Ah.  Thanks for looking at this.  Eventually Smatch will be smart enough
to figure this implication out but not yet.  No need to change the code
because the static checker isn't capable enough...

regards,
dan carpenter

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


Re: next-20151126 build: 3 failures 15 warnings (next-20151126)

2015-11-26 Thread Kalle Valo
Mark Brown  writes:

> On Thu, Nov 26, 2015 at 09:06:25AM +, Build bot for Mark Brown wrote:
>
> Today's -next fails to build an arm64 allmodconfig due to:
>
>>  arm64-allmodconfig
>> ../drivers/net/wireless/ath/ath10k/thermal.c:119:6: error: redefinition of 
>> 'ath10k_thermal_event_temperature'
>> ../drivers/net/wireless/ath/ath10k/thermal.c:136:6: error: redefinition of 
>> 'ath10k_thermal_set_throttling'
>> ../drivers/net/wireless/ath/ath10k/thermal.c:162:5: error: redefinition of 
>> 'ath10k_thermal_register'
>> ../drivers/net/wireless/ath/ath10k/thermal.c:216:6: error: redefinition of 
>> 'ath10k_thermal_unregister'
>
> This is happening because there are stub functions provided in the
> driver's thermal.h for !THERMAL cases but these are guarded by an #ifdef
> not an #if and so fails to do the right thing if the thermal code is
> built as a module.

Thanks, I'll apply the fix soon. Just wait for comments from others
first.

> It looks like this was somehow triggered as part of the reorganisation
> of the WiFi directory structure.

This is surprising and also worrying, any ideas why? It would be good to
understand the root cause in case there's a bug in wireless drivers
directory reorganisation.

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


Re: (bug report) b43: precendence error

2015-11-26 Thread Michael Büsch
On Thu, 26 Nov 2015 14:58:43 +0300
Dan Carpenter  wrote:

> [ All the old wireless Smatch warnings are showing up as new ones
>   because of the path reshuffle in linux-next.  I'm going through and
>   reporting the extra suspicious ones.  -dan ]
> 
> Hello Rafał Miłecki,
> 
> The patch 6f98e62a9f1b: "b43: update cordic code to match current
> specs" from Jan 25, 2010, leads to the following static checker
> warning:
> 
>   drivers/net/wireless/broadcom/b43/phy_lp.c:1803 lpphy_start_tx_tone()
>   warn: mask and shift to zero
> 
> drivers/net/wireless/broadcom/b43/phy_lp.c
>   1800  for (i = 0; i < samples; i++) {
>   1801  sample = b43_cordic(angle);
>   1802  angle += rotation;
>   1803  buf[i] = CORDIC_CONVERT((sample.i * max) & 0xFF) << 8;
>   1804  buf[i] |= CORDIC_CONVERT((sample.q * max) & 0xFF);
> 
> Maybe the intention was:
> 
>   buf[i] = (CORDIC_CONVERT(sample.i * max) & 0xFF) << 8;
>   buf[i] |= CORDIC_CONVERT((sample.q * max) & 0xFF;
> 
>   1805  }
>   1806  


This looks like a bug indeed.
Rafał, do you have hw to check this?

buf[i] = (CORDIC_CONVERT(sample.i * max) & 0xFF) << 8;
buf[i] |= CORDIC_CONVERT(sample.q * max) & 0xFF;

-- 
Michael


pgpF77HLoans5.pgp
Description: OpenPGP digital signature


Re: (bug report) iwlwifi: inconsitent NULL checking

2015-11-26 Thread Johannes Berg
On Thu, 2015-11-26 at 15:37 +0300, Dan Carpenter wrote:
> 
> Ah.  Thanks for looking at this.  Eventually Smatch will be smart
> enoughto figure this implication out but not yet.  No need to change 
> the code because the static checker isn't capable enough...
> 

Actually I just had an idea - we should put those two *checks* into an
inline anyway since they're actually really unlikely and we might not
want to take the function call every time...

So I thought that smatch would then be able to see through it, since
it's now an inline, but it doesn't seem like it can?

https://p.sipsolutions.net/a162ca550f675800.txt

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


Re: brcmfmac: constify brcmf_bus_ops structures

2015-11-26 Thread Kalle Valo

> The brcmf_bus_ops structures are never modified, so declare them as const.
> 
> Done with the help of Coccinelle.
> 
> Signed-off-by: Julia Lawall 
> Acked-by: Arend van Spriel 

Thanks, applied to wireless-drivers-next.git.

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


Re: (bug report) b43: impossible conditions in debugfs

2015-11-26 Thread Dan Carpenter
On Thu, Nov 26, 2015 at 01:32:41PM +0100, Michael Büsch wrote:
> > See also:
> > drivers/net/wireless/broadcom/b43/debugfs.c:346 mmio32write__write_file() 
> > warn: impossible condition '(mask > 4294967295) => (0-u32max > u32max)'
> > drivers/net/wireless/broadcom/b43/debugfs.c:346 mmio32write__write_file() 
> > warn: impossible condition '(set > 4294967295) => (0-u32max > u32max)'
> 
> 
> 
> Sure. These are intentional.
> The compiler will optimize this out.

Hm...  We try to ignore when people do intentional comparisons with zero
like this:

if (unsigned_var < 0 || unsigned_var >= 10)
return -EINVAL;

Because they are obviously harmless and they don't hurt readability.
Also Linus doesn't like removing these.

But what's the point of this?  I have seen these before when I was
checking ide_set_disk_chs() for underflows.  I also reported another one
recently that was exactly the same as this and the guy changed it from
if (x > UINT_MAX) to if (!(x < UINT_MAX))...  I don't get it.

regards,
dan carpenter


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


Re: rtlwifi: Delete unnecessary checks before the function call"kfree_skb"

2015-11-26 Thread Kalle Valo

> From: Markus Elfring 
> Date: Mon, 16 Nov 2015 13:12:25 +0100
> 
> The kfree_skb() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the calls is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring 

Thanks, applied to wireless-drivers-next.git.

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


Re: [1/1] rtlwifi: btcoexist: re-use %*ph specifier to hexdump

2015-11-26 Thread Kalle Valo

> Instead of printing each byte from the given buffer the code is converted to
> use %*ph specifier.
> 
> Signed-off-by: Andy Shevchenko 

Thanks, applied to wireless-drivers-next.git.

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


Re: [v2] libertas: check for NULL before use

2015-11-26 Thread Kalle Valo

> If kzalloc fails it will return NULL. Lets check for NULL first before
> using the pointer.
> 
> Signed-off-by: Sudip Mukherjee 

Thanks, applied to wireless-drivers-next.git.

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


Re: next-20151126 build: 3 failures 15 warnings (next-20151126)

2015-11-26 Thread Mark Brown
On Thu, Nov 26, 2015 at 02:39:40PM +0200, Kalle Valo wrote:
> Mark Brown  writes:

> > It looks like this was somehow triggered as part of the reorganisation
> > of the WiFi directory structure.

> This is surprising and also worrying, any ideas why? It would be good to
> understand the root cause in case there's a bug in wireless drivers
> directory reorganisation.

No, I didn't make much effort to check though since the use of ifdef was
clearly a bug waiting to happen anyway, I was more surprised it worked
at all than anything.


signature.asc
Description: PGP signature


Re: [PATCH 1/1] wireless: airo: re-use mac_pton()

2015-11-26 Thread Kalle Valo
Andy Shevchenko  writes:

> mac_pton() converts 6-byte MAC / BSSID to binary format. Change an open coded
> variant by the generic one.
>
> Signed-off-by: Andy Shevchenko 

This breaks compilation:

  CC [M]  drivers/net/wireless/cisco/airo.o
drivers/net/wireless/cisco/airo.c: In function ‘proc_APList_on_close’:
drivers/net/wireless/cisco/airo.c:5141:49: error: request for member ‘ap’ in 
something not a structure or union

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


Re: (bug report) b43: impossible conditions in debugfs

2015-11-26 Thread Michael Büsch
On Thu, 26 Nov 2015 16:00:34 +0300
Dan Carpenter  wrote:

> On Thu, Nov 26, 2015 at 01:32:41PM +0100, Michael Büsch wrote:
> > > See also:
> > > drivers/net/wireless/broadcom/b43/debugfs.c:346 mmio32write__write_file() 
> > > warn: impossible condition '(mask > 4294967295) => (0-u32max > u32max)'
> > > drivers/net/wireless/broadcom/b43/debugfs.c:346 mmio32write__write_file() 
> > > warn: impossible condition '(set > 4294967295) => (0-u32max > u32max)'  
> > 
> > 
> > 
> > Sure. These are intentional.
> > The compiler will optimize this out.  
> 
> Hm...  We try to ignore when people do intentional comparisons with zero
> like this:
> 
>   if (unsigned_var < 0 || unsigned_var >= 10)
>   return -EINVAL;
> 
> Because they are obviously harmless and they don't hurt readability.
> Also Linus doesn't like removing these.


It just checks whether the value will fit into a 32 bit unsigned int
variable. It doesn't make assumptions on what sizeof(unsigned int) is,
although it would be safe to assume 4 here and omit the check.

-- 
Michael


pgpoqLXE7TGyO.pgp
Description: OpenPGP digital signature


Re: [patch] rt2x00: type bug in _rt2500usb_register_read()

2015-11-26 Thread Stanislaw Gruszka
On Thu, Nov 26, 2015 at 02:55:23PM +0300, Dan Carpenter wrote:
> This code causes a static checker bug.
> 
> drivers/net/wireless/ralink/rt2x00/rt2500usb.c:232 _rt2500usb_register_read()
> warn: passing casted pointer 'value' to 'rt2500usb_register_read()' 32 vs 16.
> 
> If the low 16 bits were initialized to zero then this code would only be
> a problem on big endian systems.  But in this case this is case the low
> 16 bits are never initialized.  This is called from a function which is
> created using a macro:
> 
> RT2X00DEBUGFS_OPS(csr, "0x%.8x\n", u32);
> 
> We end up copying uninitialized data to the user which is bogus and an
> information leak.
> 
> Signed-off-by: Dan Carpenter 
Acked-by: Stanislaw Gruszka 

> ---
> Not tested.  Perhaps we should just remove this code since it has never
> worked.

It is used for debugfs interface and I would like to keep it.

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


[PATCH 1/3] cfg80211: use NL80211_ATTR_STA_AID in nl82011_set_station

2015-11-26 Thread Johannes Berg
From: Ayala Beker 

Fix nl80211_set_station() to use the value of NL80211_ATTR_STA_AID
attribute instead of NL80211_ATTR_PEER_AID attribute.

Signed-off-by: Ayala Beker 
Signed-off-by: Johannes Berg 
---
 net/wireless/nl80211.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index c71e274c810a..5536b69df2ee 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -4256,8 +4256,8 @@ static int nl80211_set_station(struct sk_buff *skb, 
struct genl_info *info)
 * station. Include these parameters here and will check them in
 * cfg80211_check_station_change().
 */
-   if (info->attrs[NL80211_ATTR_PEER_AID])
-   params.aid = nla_get_u16(info->attrs[NL80211_ATTR_PEER_AID]);
+   if (info->attrs[NL80211_ATTR_STA_AID])
+   params.aid = nla_get_u16(info->attrs[NL80211_ATTR_STA_AID]);
 
if (info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL])
params.listen_interval =
-- 
2.6.2

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


[PATCH 2/3] cfg80211: handle add_station auth/assoc flag quirks

2015-11-26 Thread Johannes Berg
From: Johannes Berg 

When a new station is added to AP/GO interfaces the default behaviour
is for it to be added authenticated and associated, due to backwards
compatibility. To prevent that, the driver must be able to do that
(setting the NL80211_FEATURE_FULL_AP_CLIENT_STATE feature flag) and
userspace must set the flag mask to auth|assoc and clear the set.

Handle this quirk in the API entirely in nl80211, and always push the
full flags to the drivers. NL80211_FEATURE_FULL_AP_CLIENT_STATE is
still required for userspace to be allowed to set the mask including
those bits, but after checking that add both flags to the mask and
set in case userspace didn't set them otherwise.

This obsoletes the mac80211 code handling this difference, no other
driver is currently using these flags.

Signed-off-by: Johannes Berg 
---
 net/mac80211/cfg.c | 10 --
 net/wireless/nl80211.c | 23 +++
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index c2bd1b6a6922..9ce0b2f60c72 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1216,16 +1216,6 @@ static int ieee80211_add_station(struct wiphy *wiphy, 
struct net_device *dev,
if (!sta)
return -ENOMEM;
 
-   /*
-* defaults -- if userspace wants something else we'll
-* change it accordingly in sta_apply_parameters()
-*/
-   if (!(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) &&
-   !(params->sta_flags_set & (BIT(NL80211_STA_FLAG_AUTHENTICATED) |
-   BIT(NL80211_STA_FLAG_ASSOCIATED {
-   sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
-   sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
-   }
if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))
sta->sta.tdls = true;
 
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 5536b69df2ee..5750d84aa466 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -4359,6 +4359,8 @@ static int nl80211_new_station(struct sk_buff *skb, 
struct genl_info *info)
struct net_device *dev = info->user_ptr[1];
struct station_parameters params;
u8 *mac_addr = NULL;
+   u32 auth_assoc = BIT(NL80211_STA_FLAG_AUTHENTICATED) |
+BIT(NL80211_STA_FLAG_ASSOCIATED);
 
memset(¶ms, 0, sizeof(params));
 
@@ -4470,10 +4472,23 @@ static int nl80211_new_station(struct sk_buff *skb, 
struct genl_info *info)
/* allow authenticated/associated only if driver handles it */
if (!(rdev->wiphy.features &
NL80211_FEATURE_FULL_AP_CLIENT_STATE) &&
-   params.sta_flags_mask &
-   (BIT(NL80211_STA_FLAG_AUTHENTICATED) |
-BIT(NL80211_STA_FLAG_ASSOCIATED)))
-   return -EINVAL;
+   params.sta_flags_mask & auth_assoc)
+   return -EINVAL;
+
+   /* Older userspace, or userspace wanting to be compatible with
+* !NL80211_FEATURE_FULL_AP_CLIENT_STATE, will not set the auth
+* and assoc flags in the mask, but assumes the station will be
+* added as associated anyway since this was the required driver
+* behaviour before NL80211_FEATURE_FULL_AP_CLIENT_STATE was
+* introduced.
+* In order to not bother drivers with this quirk in the API
+* set the flags in both the mask and set for new stations in
+* this case.
+*/
+   if (!(params.sta_flags_mask & auth_assoc)) {
+   params.sta_flags_mask |= auth_assoc;
+   params.sta_flags_set |= auth_assoc;
+   }
 
/* must be last in here for error handling */
params.vlan = get_vlan(info, rdev);
-- 
2.6.2

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


[PATCH 3/3] Revert "mac80211: don't advertise NL80211_FEATURE_FULL_AP_CLIENT_STATE"

2015-11-26 Thread Johannes Berg
From: Johannes Berg 

This reverts commit 45bb780a2147b9995f3d288c44ecb87ca8a330e2,
the previous two patches fixed the functionality.

Signed-off-by: Johannes Berg 
---
 net/mac80211/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 175ffcf7fb06..858f6b1cb149 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -541,7 +541,8 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t 
priv_data_len,
   NL80211_FEATURE_HT_IBSS |
   NL80211_FEATURE_VIF_TXPOWER |
   NL80211_FEATURE_MAC_ON_CREATE |
-  NL80211_FEATURE_USERSPACE_MPM;
+  NL80211_FEATURE_USERSPACE_MPM |
+  NL80211_FEATURE_FULL_AP_CLIENT_STATE;
 
if (!ops->hw_scan)
wiphy->features |= NL80211_FEATURE_LOW_PRIORITY_SCAN |
-- 
2.6.2

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


pull-request: mac80211 2015-11-26

2015-11-26 Thread Johannes Berg
Hi Dave,

Sorry for being so late. These have been pending for a while (and in
fact in linux-next too, I asked to be added there recently :) ).

Let me know if there's any problem.

Thanks,
johannes


The following changes since commit 17c790a60dad11c0193127e83ac8e183b4fed1a2:

  Merge branch 'mv88e6060-fixes' (2015-11-15 20:16:26 -0500)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211.git 
tags/mac80211-for-davem-2015-11-26

for you to fetch changes up to 5ff3ca2888940533dcd50212cf0be7049fee979c:

  mac80211: don't teardown sdata on sdata stop (2015-11-20 11:40:50 +0100)


A small set of fixes for 4.4:
 * remove NL80211_FEATURE_FULL_AP_CLIENT_STATE again, it
   was broken and needs more work, we'll enable it for 4.5
 * fix call_rcu() induced use-after-reset/free in mesh
   (that was suddenly causing issues in certain tests)
 * always request block-ack window size 64 as we found
   some APs will otherwise crash (really ...)
 * fix P2P-Device teardown sequence to avoid restarting
   with uninitialized data


Eliad Peller (1):
  mac80211: don't teardown sdata on sdata stop

Emmanuel Grumbach (1):
  mac80211: ensure we don't update tx power on a non-running sdata

Gregory Greenman (1):
  mac80211: always set the buf_size in AddBA req to 64

Johannes Berg (2):
  mac80211: don't advertise NL80211_FEATURE_FULL_AP_CLIENT_STATE
  mac80211: mesh: fix call_rcu() usage

 include/net/mac80211.h  | 6 --
 net/mac80211/agg-tx.c   | 3 ++-
 net/mac80211/iface.c| 5 +++--
 net/mac80211/main.c | 3 +--
 net/mac80211/mesh_pathtbl.c | 8 
 5 files changed, 14 insertions(+), 11 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


pull-request: mac80211 2015-11-26

2015-11-26 Thread Johannes Berg
[resending with correct netdev address, not sure how that ended up in
my autocompletion address book ... sorry about that!]

Hi Dave,

Sorry for being so late. These have been pending for a while (and in
fact in linux-next too, I asked to be added there recently :) ).

Let me know if there's any problem.

Thanks,
johannes


The following changes since commit
17c790a60dad11c0193127e83ac8e183b4fed1a2:

  Merge branch 'mv88e6060-fixes' (2015-11-15 20:16:26 -0500)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211.git
tags/mac80211-for-davem-2015-11-26

for you to fetch changes up to
5ff3ca2888940533dcd50212cf0be7049fee979c:

  mac80211: don't teardown sdata on sdata stop (2015-11-20 11:40:50
+0100)


A small set of fixes for 4.4:
 * remove NL80211_FEATURE_FULL_AP_CLIENT_STATE again, it
   was broken and needs more work, we'll enable it for 4.5
 * fix call_rcu() induced use-after-reset/free in mesh
   (that was suddenly causing issues in certain tests)
 * always request block-ack window size 64 as we found
   some APs will otherwise crash (really ...)
 * fix P2P-Device teardown sequence to avoid restarting
   with uninitialized data


Eliad Peller (1):
  mac80211: don't teardown sdata on sdata stop

Emmanuel Grumbach (1):
  mac80211: ensure we don't update tx power on a non-running sdata

Gregory Greenman (1):
  mac80211: always set the buf_size in AddBA req to 64

Johannes Berg (2):
  mac80211: don't advertise NL80211_FEATURE_FULL_AP_CLIENT_STATE
  mac80211: mesh: fix call_rcu() usage

 include/net/mac80211.h  | 6 --
 net/mac80211/agg-tx.c   | 3 ++-
 net/mac80211/iface.c| 5 +++--
 net/mac80211/main.c | 3 +--
 net/mac80211/mesh_pathtbl.c | 8 
 5 files changed, 14 insertions(+), 11 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] iwlwifi: mvm: add hwmon device for the temperature sensor

2015-11-26 Thread Johannes Berg
Hi Bjørn,

> I got bored and made an attempt on this. Still just for fun.  I don't
> have a real usecase.  What do you think?  Completely useless?

It's not so bad :)

However, it's (soon going to be) redundant, we're planning to implement
a thermal_zone_device in this code, and if you then set the Kconfig
option THERMAL_HWMON you'll get a hwmon to go along with it. So I'd
rather not take this patch since we'd otherwise end up with two ways to
do the same thing in the driver.

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


Re: [PATCH 1/2] cfg80211: Add missing tracing to cfg80211

2015-11-26 Thread Johannes Berg
Both applied, thanks.

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


Re: [PATCH] cfg80211: ocb: Fix null pointer deref if join_ocb is unimplemented

2015-11-26 Thread Johannes Berg
Applied, but only to mac80211-next as it's not really relevant - all
drivers actually advertising OCB mode (should) have the pointer, and
the iftype is checked here.

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


Re: [PATCH v2] nl80211: clarify NL80211_ATTR_SCHED_SCAN_DELAY usage with net-detect

2015-11-26 Thread Johannes Berg
On Mon, 2015-11-09 at 12:17 +0200, Luca Coelho wrote:
> From: Luca Coelho 
> 
> In this attribute's documentation, it was not clear whether the delay
> started counting when WoWLAN net-detect was enabled or when the
> system
> was suspended.  The correct answer is that it starts when the system
> suspends (which is when, in practice, the scan is
> scheduled).  Clarify
> that in the nl80211.h documentation.
> 
Applied.

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


Re: [PATCH 0/8] various mac80211 patches

2015-11-26 Thread Johannes Berg
On Fri, 2015-11-20 at 11:02 +, Grumbach, Emmanuel wrote:
> 
> On 11/20/2015 12:42 PM, Johannes Berg wrote:
> > I'm ignoring patches 1-3 since I already have them pending.
> > 
> > I've applied 6-8 to mac80211 now.
> > 
> > I'll leave 4 and 5 pending for now and apply them to mac80211-next,
> > unless you speak up now and tell me you really want those driver
> > fixes
> > they prepare for. Doesn't really seem relevant though.
> 
> mac80211-next is good enough for 4 and 5.

Ok, applied there.

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


Re: [PATCH v2 2/8] cfg80211: Remove unused cfg80211_can_use_iftype_chan()

2015-11-26 Thread Johannes Berg
On Mon, 2015-11-23 at 19:27 +0100, Michal Sojka wrote:
> Last caller of this function was removed in 3.17 in commit
> 97dc94f1d933c9df2c0b327066ea130c0e92083f.
> 
Heh.

I've applied the first two patches for now - will review the others in
more detail later.

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


Re: [PATCH] mac80211_hwsim: check ATTR_FREQ for wmediumd (netlink) packets

2015-11-26 Thread Johannes Berg
On Mon, 2015-11-02 at 10:25 -0500, arwe...@cert.org wrote:
> From: Adam Welle 
> 
> If a packet is received from netlink with the frequency value set it
> is
> checked against the current radio's frequency and discarded if
> different.
> 
Reviewing this more closely, it seems that the frequency should also be
checked against data->tmp_channel if that's non-zero, to support the
"hw" off-channel/scan case.

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


Re: [PATCH] iwlwifi: mvm: add hwmon device for the temperature sensor

2015-11-26 Thread Bjørn Mork
Johannes Berg  writes:

> Hi Bjørn,
>
>> I got bored and made an attempt on this. Still just for fun.  I don't
>> have a real usecase.  What do you think?  Completely useless?
>
> It's not so bad :)
>
> However, it's (soon going to be) redundant, we're planning to implement
> a thermal_zone_device in this code, and if you then set the Kconfig
> option THERMAL_HWMON you'll get a hwmon to go along with it. So I'd
> rather not take this patch since we'd otherwise end up with two ways to
> do the same thing in the driver.

Ah, right.  I wondered a bit about that, but concluded that you probably
didn't want it since you had all your own temp limit handling.

Sounds like a good plan to me


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


Re: next-20151126 build: 3 failures 15 warnings (next-20151126)

2015-11-26 Thread Kalle Valo
Mark Brown  writes:

> On Thu, Nov 26, 2015 at 02:39:40PM +0200, Kalle Valo wrote:
>> Mark Brown  writes:
>
>> > It looks like this was somehow triggered as part of the reorganisation
>> > of the WiFi directory structure.
>
>> This is surprising and also worrying, any ideas why? It would be good to
>> understand the root cause in case there's a bug in wireless drivers
>> directory reorganisation.
>
> No, I didn't make much effort to check though since the use of ifdef was
> clearly a bug waiting to happen anyway, I was more surprised it worked
> at all than anything.

Michal Marek explains[1] that this is due to commit cf4f21938e13
("kbuild: Allow to specify composite modules with modname-m") and has
nothing to do with the wireless drivers reorganisation. I'll drop this
patch as Michal will apply his fix to the kbuild tree.

[1] https://patchwork.kernel.org/patch/7707801/

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


Re: [PATCH] ath10: Fix build with CONFIG_THERMAL=m

2015-11-26 Thread Kalle Valo
+ linux-wireless

Michal Marek  writes:

> After commit cf4f21938e13 ("kbuild: Allow to specify composite modules
> with modname-m"), thermal.c gets included in the driver and the build
> fails with
>
> drivers/net/wireless/ath/ath10k/thermal.c:119:6: error: redefinition of 
> ‘ath10k_thermal_event_temperature’
> drivers/net/wireless/ath/ath10k/thermal.h:54:20: note: previous definition of 
> ‘ath10k_thermal_event_temperature’ was here
> drivers/net/wireless/ath/ath10k/thermal.c:136:6: error: redefinition of 
> ‘ath10k_thermal_set_throttling’
> drivers/net/wireless/ath/ath10k/thermal.h:59:20: note: previous definition of 
> ‘ath10k_thermal_set_throttling’ was here
> drivers/net/wireless/ath/ath10k/thermal.c:162:5: error: redefinition of 
> ‘ath10k_thermal_register’
> drivers/net/wireless/ath/ath10k/thermal.h:45:19: note: previous definition of 
> ‘ath10k_thermal_register’ was here
> drivers/net/wireless/ath/ath10k/thermal.c:216:6: error: redefinition of 
> ‘ath10k_thermal_unregister’
> drivers/net/wireless/ath/ath10k/thermal.h:50:20: note: previous definition of 
> ‘ath10k_thermal_unregister’ was here
>
> Change the #ifdef to reflect the new kbuild behavior.
>
> Reported-by: kbuild test robot 
> Signed-off-by: Michal Marek 

Please fix the subject prefix to "ath10k: ", otherwise looks good. Feel
free to apply this to the kbuild tree.

Acked-by: Kalle Valo 

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


Re: next-20151126 build: 3 failures 15 warnings (next-20151126)

2015-11-26 Thread Mark Brown
On Thu, Nov 26, 2015 at 06:58:32PM +0200, Kalle Valo wrote:
> Mark Brown  writes:

> > No, I didn't make much effort to check though since the use of ifdef was
> > clearly a bug waiting to happen anyway, I was more surprised it worked
> > at all than anything.

> Michal Marek explains[1] that this is due to commit cf4f21938e13
> ("kbuild: Allow to specify composite modules with modname-m") and has
> nothing to do with the wireless drivers reorganisation. I'll drop this
> patch as Michal will apply his fix to the kbuild tree.

It still ought to be fixed regardless of why it showed up - the
intention of the code is that we build the real thermal code regardless
of if that's modular or not but that's not what the code actually does.


signature.asc
Description: PGP signature


Re: [PATCH] iwlwifi: mvm: add hwmon device for the temperature sensor

2015-11-26 Thread Johannes Berg

> Ah, right.  I wondered a bit about that, but concluded that you
> probably
> didn't want it since you had all your own temp limit handling.
> 

:)

We do, but we're going to have to be able to handle requests from the
platform to ask the device to do its part to reduce heating.

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


Re: [PATCH v3] mac80211: do not actively scan DFS channels

2015-11-26 Thread Johannes Berg
On Sat, 2015-11-21 at 18:13 +0800, Antonio Quartulli wrote:
> DFS channels should not be actively scanned as we can't be sure
> if we are allowed or not.
> 
> If the current channel is in the DFS band, active scan might be
> performed after CSA, but we have no guarantee about other channels,
> therefore it is safer to prevent active scanning at all.
> 
Applied to mac80211.git, also added cc stable. I modified the code a
bit to be shorter :)

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


Re: [PATCH] mac80211: add new IEEE80211_VIF_GET_NOA_UPDATE flag

2015-11-26 Thread Johannes Berg
On Tue, 2015-10-27 at 08:38 +0100, Janusz Dziedzic wrote:
> Add new VIF flag, that will allow get NOA update
> notification when driver will request this, even
> this is not pure P2P vif (eg. STA vif).

Applied.

I'll note that people here seem to want to do a similar thing, so
thanks :)

Also, perhaps we should have a common way to advertise this kind of
capability in the association request of this station, so that the
(mobile?) APs implementing it can know? I think we'd discussed using an
Intel-specific vendor IE for this, but making the specification thereof
public so others could do it as well, but I'm sure we're open for other
suggestions. Any interest?

We're also going to be working on nl80211 extensions to actually let
the driver know if the client is P2P (or NoA capable) or not.

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


Re: [PATCH v2 1/2] cfg80211: Add support for aborting an ongoing scan

2015-11-26 Thread Johannes Berg
On Fri, 2015-10-30 at 19:14 +0530, Sunil Dutt wrote:
> From: Vidyullatha Kanchanapally 
> 
> Implement new functionality for aborting an ongoing scan.
> 
> Add NL80211_CMD_ABORT_SCAN to the nl80211 interface. After
> aborting the scan, driver shall provide the scan status by
> calling cfg80211_scan_done().
> 
Applied, I made some changes to allow this to be used on wdev, not just
netdev and cleaned up/shuffled the code a bit.

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


Re: [PATCH] mac80211: Parse legacy and HT rate in injected frames

2015-11-26 Thread Johannes Berg
On Tue, 2015-10-13 at 16:36 +0200, Sven Eckelmann wrote:
> 
> The removal of this feature heavily reduced the usefulness of frame
> injection when wanting to simulate specific transmission behavior.
> Having
> rate parsing together with MCS rates and retry support allows a fine
> grained selection of the tx behavior of injected frames for these
> kind of
> tests.

Assuming you have hardware to do it, but that requirement seems fair.

> We have required the support for rate parsing (legacy + HT) for some
> tests.
> It is already known that this may not be the best place to set this
> flag
> (IEEE80211_TX_CTRL_RATE_INJECT) but the main flags field is already
> full.

It seems you could perhaps put that into struct
ieee80211_tx_data::flags? Or is it required somewhere outside the
mac80211 processing?

Otherwise I think the place is fine? What issue do you have with it?

> There is also the problem that powersave could overwrite the rate
> control
> fields - so either we disable powersave queueing or find a different
> solution.

I have no idea what you mean? The flag - as you have it now - should be
preserved, no? Perhaps if you moved the flag into tx_data then it
wouldn't be, and that's a good argument for not moving it?

> But maybe this feature is also not wanted anymore in the mac80211
> driver.

Well, I'm open to adding the code if you need it. Could consider VHT as
well, I guess.

Adding the check to the fast-xmit path seems neither right nor
necessary though, since that shouldn't get invoked for injection to
start with?

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


Re: [PATCH] Fix memory leak if nla_put fails

2015-11-26 Thread Johannes Berg
On Tue, 2015-11-24 at 17:15 +0530, Rahul Jain wrote:
> From: Amit Khatri 
> 
> Signed-off-by: Amit Khatri 
> Signed-off-by: Rahul Jain  
> 
> avoid memory leak because of nla_put_failure
> 
Please fix coding style, and put the message before signed-off-by :)

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


Re: [PATCH 1/2]iw: DEREF_AFTER_NULL: fix

2015-11-26 Thread Johannes Berg
Applied, but please use better coding style and a useful commit message
next time.

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


Re: [PATCH v2 3/8] cfg80211: reg: Refactor calculation of bandwidth flags

2015-11-26 Thread Johannes Berg
On Mon, 2015-11-23 at 19:27 +0100, Michal Sojka wrote:
> The same piece of code appears at two places. Make a function from
> it.
> 
Also applied.

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


Re: [PATCH v2 4/8] cfg80211: reg: Properly handle rules for 5 and 10 MHz channels

2015-11-26 Thread Johannes Berg
On Mon, 2015-11-23 at 19:27 +0100, Michal Sojka wrote:
> Regulatory rules are applied to channels as if the channel is at
> least
> 20 MHz wide. This is a problem when dealing with 5 and 10 MHz
> channels
> because side channels of a regulatory rule get disabled even when
> they
> fall into rule's frequency range.
> 
> This problem was already fixed in commit
> 4edd56981c8fbb349b1529a2feaf772636eb1c83, but only for custom
> regulatory
> domains provided by drivers. Here we fix it also for all other (e.g.
> user-supplied) regulatory domains.
> 
> Before that, similar commit was
> reverted (e33e2241e272eddc38339692500bd1c7d8753a77) due to it
> allowing
> running AP on channel 12 in the US regulatory domain. I have checked
> that this is not possible with this change:
> 
>   # iw reg set US
>   # iw dev wlan0 interface add wlan0_ap  type __ap
>   # iw dev wlan0_ap set channel 12
>   command failed: Invalid argument (-22)
> 
Applied, with some fixups to the commit message :)

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


Re: [PATCH v2 7/8] cfg80211: Add Kconfig option for ITS-G5 band (5.9 GHz)

2015-11-26 Thread Johannes Berg
On Mon, 2015-11-23 at 19:27 +0100, Michal Sojka wrote:
> This option is meant for use by drivers and other subsystems to
> enable
> support for the Intelligent Transportation System (ITS-G5) band. The
> option depends on CFG80211_CERTIFICATION_ONUS as the use of this band
> is
> restricted. EU allows using it only for certain applications, USA
> require certification.

Hm. Why do we need this now? I see that you're checking it in ath9k, to
enable the "ITSG5" channels, but why wouldn't you always do that, now
that you have the extra checks with the user regdb being required and
all?

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


Re: next-20151126 build: 3 failures 15 warnings (next-20151126)

2015-11-26 Thread Kalle Valo
Mark Brown  writes:

> On Thu, Nov 26, 2015 at 06:58:32PM +0200, Kalle Valo wrote:
>> Mark Brown  writes:
>
>> > No, I didn't make much effort to check though since the use of ifdef was
>> > clearly a bug waiting to happen anyway, I was more surprised it worked
>> > at all than anything.
>
>> Michal Marek explains[1] that this is due to commit cf4f21938e13
>> ("kbuild: Allow to specify composite modules with modname-m") and has
>> nothing to do with the wireless drivers reorganisation. I'll drop this
>> patch as Michal will apply his fix to the kbuild tree.
>
> It still ought to be fixed regardless of why it showed up - the
> intention of the code is that we build the real thermal code regardless
> of if that's modular or not but that's not what the code actually does.

Like I said above Michal will apply a fix to his tree. Read the full
discussion from patchwork:

https://patchwork.kernel.org/patch/7707801/

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


[PATCH] mac80211: Allow a STA to join an IBSS with 80+80 MHz channel

2015-11-26 Thread Jouni Malinen
While it was possible to create an IBSS with 80+80 MHz channel, joining
such an IBSS resulted in falling back to 20 MHz channel with VHT
disabled due to a missing switch case for 80+80.

Signed-off-by: Jouni Malinen 
---
 net/mac80211/ibss.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 337bb5d..f7fc0e0 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -428,6 +428,7 @@ static void ieee80211_sta_join_ibss(struct 
ieee80211_sub_if_data *sdata,
chandef.width = sdata->u.ibss.chandef.width;
break;
case NL80211_CHAN_WIDTH_80:
+   case NL80211_CHAN_WIDTH_80P80:
case NL80211_CHAN_WIDTH_160:
chandef = sdata->u.ibss.chandef;
chandef.chan = cbss->channel;
-- 
1.9.1

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


[PATCH] mac80211_hwsim: Advertise support for VHT IBSS

2015-11-26 Thread Jouni Malinen
VHT can be used with IBSS without needing any additional changes in
mac80211_hwsim, so start claiming support for this to increase test
coverage.

Signed-off-by: Jouni Malinen 
---
 drivers/net/wireless/mac80211_hwsim.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/mac80211_hwsim.c 
b/drivers/net/wireless/mac80211_hwsim.c
index 551dfff..1c598a5 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -2449,6 +2449,7 @@ static int mac80211_hwsim_new_radio(struct genl_info 
*info,
   NL80211_FEATURE_STATIC_SMPS |
   NL80211_FEATURE_DYNAMIC_SMPS |
   NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR;
+   wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_VHT_IBSS);
 
/* ask mac80211 to reserve space for magic */
hw->vif_data_size = sizeof(struct hwsim_vif_priv);
-- 
1.9.1


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


[PATCH] mac80211_hwsim: Update timestamp in Probe Response frames

2015-11-26 Thread Jouni Malinen
Previously, this was done only for Beacon frames, but similar timestamp
update is needed for Probe Response frames to make these more accurately
match the real IEEE 802.11 behavior. Previously, all zeros timestamp was
sent in Probe Response frames.

Signed-off-by: Jouni Malinen 
---
 drivers/net/wireless/mac80211_hwsim.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/wireless/mac80211_hwsim.c 
b/drivers/net/wireless/mac80211_hwsim.c
index e922a4d..551dfff 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -1250,6 +1250,7 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
 {
struct mac80211_hwsim_data *data = hw->priv;
struct ieee80211_tx_info *txi = IEEE80211_SKB_CB(skb);
+   struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
struct ieee80211_chanctx_conf *chanctx_conf;
struct ieee80211_channel *channel;
bool ack;
@@ -1295,6 +1296,22 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
   ARRAY_SIZE(txi->control.rates));
 
txi->rate_driver_data[0] = channel;
+
+   if (skb->len >= 24 + 8 &&
+   ieee80211_is_probe_resp(hdr->frame_control)) {
+   /* fake header transmission time */
+   struct ieee80211_mgmt *mgmt;
+   struct ieee80211_rate *txrate;
+   u64 ts;
+
+   mgmt = (struct ieee80211_mgmt *)skb->data;
+   txrate = ieee80211_get_tx_rate(hw, txi);
+   ts = mac80211_hwsim_get_tsf_raw();
+   mgmt->u.probe_resp.timestamp =
+   cpu_to_le64(ts + data->tsf_offset +
+   24 * 8 * 10 / txrate->bitrate);
+   }
+
mac80211_hwsim_monitor_rx(hw, skb, channel);
 
/* wmediumd mode check */
-- 
1.9.1

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


Re: (bug report) iwlwifi: inconsitent NULL checking

2015-11-26 Thread Dan Carpenter
There are two issues in Smatch that would need to be fixed:

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
index d1ad103..d3bc193 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
@@ -2767,6 +2767,7 @@ static void rs_initialize_lq(struct iwl_mvm *mvm,
iwl_mvm_send_lq_cmd(mvm, &lq_sta->lq, init);
 }
 
+#include "/home/dcarpenter/progs/smatch/devel/check_debug.h"
 static void rs_get_rate(void *mvm_r, struct ieee80211_sta *sta, void *mvm_sta,
struct ieee80211_tx_rate_control *txrc)
 {
@@ -2795,9 +2796,13 @@ static void rs_get_rate(void *mvm_r, struct 
ieee80211_sta *sta, void *mvm_sta,
mvm_sta = NULL;
}
 
+   if (mvm_sta)
+   __smatch_implied(lq_sta);
+
/* Send management frames and NO_ACK data using lowest rate. */
if (rate_control_send_low(sta, mvm_sta, txrc))
return;
+   __smatch_implied(mvm_sta);
 
iwl_mvm_hwrate_to_tx_rate(lq_sta->last_rate_n_flags,
  info->band, &info->control.rates[0]);


If apply that patch (with changes for your system) and run
kchecker drivers/net/wireless/intel/iwlwifi/mvm/rs.c then it prints:

drivers/net/wireless/intel/iwlwifi/mvm/rs.c:2800 rs_get_rate() implied: lq_sta 
= '0,4096-211'
drivers/net/wireless/intel/iwlwifi/mvm/rs.c:2805 rs_get_rate() implied: mvm_sta 
= 's64min-(-1),1-s64max'

The first problem is that it doesn't see that if mvm_sta is non-NULL
then that implies lq_sta is non-NULL.  But even if that worked, after we
do the function call, it sees that the function that mvm_sta is non-NULL
but it wouldn't see that that means lq_sta is non-NULL.  It's not so
terribly far from working but it's not there yet.

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


Re: (bug report) iwlwifi: inconsitent NULL checking

2015-11-26 Thread Johannes Berg
On Thu, 2015-11-26 at 22:44 +0300, Dan Carpenter wrote:
> 
> The first problem is that it doesn't see that if mvm_sta is non-NULL
> then that implies lq_sta is non-NULL.  But even if that worked, after
> we do the function call, it sees that the function that mvm_sta is
> non-NULL but it wouldn't see that that means lq_sta is non-
> NULL.  It's not so terribly far from working but it's not there yet.
> 

Ah, yes, I completely forgot that it's two (related) variables :)

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


Re: next-20151126 build: 3 failures 15 warnings (next-20151126)

2015-11-26 Thread Mark Brown
On Thu, Nov 26, 2015 at 08:34:20PM +0200, Kalle Valo wrote:
> Mark Brown  writes:

> > It still ought to be fixed regardless of why it showed up - the
> > intention of the code is that we build the real thermal code regardless
> > of if that's modular or not but that's not what the code actually does.

> Like I said above Michal will apply a fix to his tree. Read the full
> discussion from patchwork:

> https://patchwork.kernel.org/patch/7707801/

Oh, right - a fix for this specific issue rather than a fix for whatever
change he made.


signature.asc
Description: PGP signature


Re: [PATCH v2 7/8] cfg80211: Add Kconfig option for ITS-G5 band (5.9 GHz)

2015-11-26 Thread Michal Sojka
On Thu, Nov 26 2015, Johannes Berg wrote:
> On Mon, 2015-11-23 at 19:27 +0100, Michal Sojka wrote:
>> This option is meant for use by drivers and other subsystems to
>> enable
>> support for the Intelligent Transportation System (ITS-G5) band. The
>> option depends on CFG80211_CERTIFICATION_ONUS as the use of this band
>> is
>> restricted. EU allows using it only for certain applications, USA
>> require certification.
>
> Hm. Why do we need this now? I see that you're checking it in ath9k, to
> enable the "ITSG5" channels, but why wouldn't you always do that, now
> that you have the extra checks with the user regdb being required and
> all?

Because in [1] Jouni said that

   "kernel config option + custom regdb would certainly be much closer
   to what I'd like to see from the regulatory enforcement view point"

I also like the fact that the help text mentions the relevant regulatory
documents. I guess the users would appreciate that.

-Michal

[1] http://www.mail-archive.com/ath9k-devel@lists.ath9k.org/msg13795.html
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH v7] Add new mac80211 driver mwlwifi.

2015-11-26 Thread David Lin
> On November 26, 2015 5:40 PM, Johannes Berg wrote:
> 
> On Thu, 2015-11-26 at 08:27 +, David Lin wrote:
> 
> > > Since you do this in .probe, you should consider loading the
> > > firmware asynchronously.
> > >
> >
> > I hope I can postpone this modification later.
> 
> I don't feel strongly about this one - otoh it's not really complicated.
> 

Thanks.

> > > > +#ifdef CONFIG_SUPPORT_MFG
> > >
> > > This Kconfig variable doesn't exist.
> > >
> >
> > The compile variable is used privately by Marvell and our customers in
> > production line.
> 
> Yeah, still. Make it a proper Kconfig variable, defaulting to off and hidden
> under something, or remove it. It's extremely misleading to have something
> called CONFIG_* when it's not a Kconfig variable.
> 

I will change this compile variable from "CONFIG_SUPPORT_MFG" to "SUPPORT_MFG".

> > Mac80211 does not support mesh AMSDU now, we implement this function
> > in mwlwifi driver for the time being. Except for mesh AMSDU, we still
> > leverage mac80211 to handle data AMSDU.
> 
> You're allowed to modify mac80211.
> 
> > > What's going on here? Why are you modifying the action frames on the
> > > fly??!
> > >
> >
> > Due to mwlwifi supports Tx/Rx AMSDU, these frames are modified to
> > inform client that we support AMSDU.
> >
> 
> Ditto - you're allowed to modify mac80211. We actually have a patch like this
> already:
> https://git.kernel.org/cgit/linux/kernel/git/jberg/mac80211-
> next.git/commit/?id=99e7ca44bb910f0cbfda5d9008e8517df0ebc939
> 

Once if this patch is ready, I will modify mwlwifi to use it. Thanks.

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


[PATCH 0/3] clean up interface information structure

2015-11-26 Thread Glen Lee
This patch series combines perInterface_wlan_t and struct wilc_vif. vif of
struct wilc can be the pointer of net device private data with
perInterface_wlan_t. As a conseqeunce, there will be one interface information
structure wilc_vif.

Glen Lee (3):
  staging: wilc1000: move perInterface_wlan_t to wilc_vif
  staging: wilc1000: change vif to pointer to refence real private data
  staging: wilc1000: remove duplicate netdev

 drivers/staging/wilc1000/host_interface.c |   6 +-
 drivers/staging/wilc1000/linux_wlan.c | 307 +++---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 220 
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |  22 +-
 drivers/staging/wilc1000/wilc_wlan.c  |  60 ++---
 5 files changed, 305 insertions(+), 310 deletions(-)

-- 
1.9.1

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


[PATCH 2/3] staging: wilc1000: change vif to pointer to refence real private data

2015-11-26 Thread Glen Lee
vif of struct has it's own memory which is not necessary because we have
allocated vif from netdev_priv.
Change vif to pointer type and assign vif which is netdev private data.
Change it's operator on related codes as well.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c | 65 ++--
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 72 +++
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |  2 +-
 3 files changed, 70 insertions(+), 69 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 263d9d8..810d7ce 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -289,9 +289,9 @@ static struct net_device *get_if_handler(struct wilc *wilc, 
u8 *mac_header)
bssid1 = mac_header + 4;
 
for (i = 0; i < wilc->vif_num; i++)
-   if (!memcmp(bssid1, wilc->vif[i].bssid, ETH_ALEN) ||
-   !memcmp(bssid, wilc->vif[i].bssid, ETH_ALEN))
-   return wilc->vif[i].ndev;
+   if (!memcmp(bssid1, wilc->vif[i]->bssid, ETH_ALEN) ||
+   !memcmp(bssid, wilc->vif[i]->bssid, ETH_ALEN))
+   return wilc->vif[i]->ndev;
 
PRINT_INFO(INIT_DBG, "Invalide handle\n");
for (i = 0; i < 25; i++)
@@ -299,9 +299,9 @@ static struct net_device *get_if_handler(struct wilc *wilc, 
u8 *mac_header)
bssid = mac_header + 18;
bssid1 = mac_header + 12;
for (i = 0; i < wilc->vif_num; i++)
-   if (!memcmp(bssid1, wilc->vif[i].bssid, ETH_ALEN) ||
-   !memcmp(bssid, wilc->vif[i].bssid, ETH_ALEN))
-   return wilc->vif[i].ndev;
+   if (!memcmp(bssid1, wilc->vif[i]->bssid, ETH_ALEN) ||
+   !memcmp(bssid, wilc->vif[i]->bssid, ETH_ALEN))
+   return wilc->vif[i]->ndev;
 
PRINT_INFO(INIT_DBG, "\n");
return NULL;
@@ -318,8 +318,8 @@ int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 
*bssid)
wilc = vif->wilc;
 
for (i = 0; i < wilc->vif_num; i++)
-   if (wilc->vif[i].ndev == wilc_netdev) {
-   memcpy(wilc->vif[i].bssid, bssid, 6);
+   if (wilc->vif[i]->ndev == wilc_netdev) {
+   memcpy(wilc->vif[i]->bssid, bssid, 6);
ret = 0;
break;
}
@@ -334,7 +334,7 @@ int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc)
u8 ret_val = 0;
 
for (i = 0; i < wilc->vif_num; i++)
-   if (memcmp(wilc->vif[i].bssid, null_bssid, 6))
+   if (memcmp(wilc->vif[i]->bssid, null_bssid, 6))
ret_val++;
 
return ret_val;
@@ -384,10 +384,10 @@ static int linux_wlan_txq_task(void *vp)
if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD) {
PRINT_D(TX_DBG, "Waking up queue\n");
 
-   if (netif_queue_stopped(wl->vif[0].ndev))
-   netif_wake_queue(wl->vif[0].ndev);
-   if (netif_queue_stopped(wl->vif[1].ndev))
-   netif_wake_queue(wl->vif[1].ndev);
+   if (netif_queue_stopped(wl->vif[0]->ndev))
+   netif_wake_queue(wl->vif[0]->ndev);
+   if (netif_queue_stopped(wl->vif[1]->ndev))
+   netif_wake_queue(wl->vif[1]->ndev);
}
 
if (ret == WILC_TX_ERR_NO_BUF) {
@@ -1034,14 +1034,14 @@ int wilc_mac_open(struct net_device *ndev)
PRINT_D(INIT_DBG, "Mac address: %pM\n", mac_add);
 
for (i = 0; i < wl->vif_num; i++) {
-   if (ndev == wl->vif[i].ndev) {
-   memcpy(wl->vif[i].src_addr, mac_add, ETH_ALEN);
-   wl->vif[i].hif_drv = priv->hWILCWFIDrv;
+   if (ndev == wl->vif[i]->ndev) {
+   memcpy(wl->vif[i]->src_addr, mac_add, ETH_ALEN);
+   wl->vif[i]->hif_drv = priv->hWILCWFIDrv;
break;
}
}
 
-   memcpy(ndev->dev_addr, wl->vif[i].src_addr, ETH_ALEN);
+   memcpy(ndev->dev_addr, wl->vif[i]->src_addr, ETH_ALEN);
 
if (!is_valid_ether_addr(ndev->dev_addr)) {
PRINT_ER("Error: Wrong MAC address\n");
@@ -1182,14 +1182,14 @@ int wilc_mac_xmit(struct sk_buff *skb, struct 
net_device *ndev)
PRINT_D(TX_DBG, "Adding tx packet to TX Queue\n");
vif->netstats.tx_packets++;
vif->netstats.tx_bytes += tx_data->size;
-   tx_data->pBssid = wilc->vif[vif->u8IfIdx].bssid;
+   tx_data->pBssid = wilc->vif[vif->u8IfIdx]->bssid;
queue_count = wilc_wlan_txq_add_net_pkt(ndev, (void *)tx_data,
 

[PATCH 1/3] staging: wilc1000: move perInterface_wlan_t to wilc_vif

2015-11-26 Thread Glen Lee
perInterface_wlan_t and wilc_vif are all about interface control informations.
We will combine those two structures and maintain as one network interface
control information.
Move all the members of perInterface_wlan_t to wilc_vif and remove the
structure. Rename perInterace_wlan_t to wilc_vif and rename variable name nic
to vif which is proper name for it.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/host_interface.c |   6 +-
 drivers/staging/wilc1000/linux_wlan.c | 251 +++---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 148 ++---
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |  21 +-
 drivers/staging/wilc1000/wilc_wlan.c  |  60 +++---
 5 files changed, 241 insertions(+), 245 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 3b986cb..f7e560e 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3772,11 +3772,11 @@ s32 wilc_init(struct net_device *dev, struct 
host_if_drv **hif_drv_handler)
s32 result = 0;
struct host_if_drv *hif_drv;
int err;
-   perInterface_wlan_t *nic;
+   struct wilc_vif *vif;
struct wilc *wilc;
 
-   nic = netdev_priv(dev);
-   wilc = nic->wilc;
+   vif = netdev_priv(dev);
+   wilc = vif->wilc;
 
PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", 
clients_count + 1);
 
diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 92ca072..263d9d8 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -64,7 +64,7 @@ static int dev_state_ev_handler(struct notifier_block *this, 
unsigned long event
struct host_if_drv *hif_drv;
struct net_device *dev;
u8 *ip_addr_buf;
-   perInterface_wlan_t *nic;
+   struct wilc_vif *vif;
u8 null_ip[4] = {0};
char wlan_dev_name[5] = "wlan0";
 
@@ -90,8 +90,8 @@ static int dev_state_ev_handler(struct notifier_block *this, 
unsigned long event
return NOTIFY_DONE;
}
hif_drv = (struct host_if_drv *)priv->hWILCWFIDrv;
-   nic = netdev_priv(dev);
-   if (!nic || !hif_drv) {
+   vif = netdev_priv(dev);
+   if (!vif || !hif_drv) {
PRINT_D(GENERIC_DBG, "No Wireless Priv\n");
return NOTIFY_DONE;
}
@@ -104,7 +104,7 @@ static int dev_state_ev_handler(struct notifier_block 
*this, unsigned long event
 
PRINT_INFO(GENERIC_DBG, "\n == IP Address Obtained 
===\n\n");
 
-   if (nic->iftype == STATION_MODE || nic->iftype == CLIENT_MODE) {
+   if (vif->iftype == STATION_MODE || vif->iftype == CLIENT_MODE) {
hif_drv->IFC_UP = 1;
wilc_optaining_ip = false;
del_timer(&wilc_during_ip_timer);
@@ -120,7 +120,7 @@ static int dev_state_ev_handler(struct notifier_block 
*this, unsigned long event
PRINT_D(GENERIC_DBG, "IP add=%d:%d:%d:%d\n",
ip_addr_buf[0], ip_addr_buf[1],
ip_addr_buf[2], ip_addr_buf[3]);
-   wilc_setup_ipaddress(hif_drv, ip_addr_buf, nic->u8IfIdx);
+   wilc_setup_ipaddress(hif_drv, ip_addr_buf, vif->u8IfIdx);
 
break;
 
@@ -128,7 +128,7 @@ static int dev_state_ev_handler(struct notifier_block 
*this, unsigned long event
PRINT_D(GENERIC_DBG, "dev_state_ev_handler event=NETDEV_DOWN 
%p\n", dev);
 
PRINT_INFO(GENERIC_DBG, "\n == IP Address Released 
===\n\n");
-   if (nic->iftype == STATION_MODE || nic->iftype == CLIENT_MODE) {
+   if (vif->iftype == STATION_MODE || vif->iftype == CLIENT_MODE) {
hif_drv->IFC_UP = 0;
wilc_optaining_ip = false;
}
@@ -145,7 +145,7 @@ static int dev_state_ev_handler(struct notifier_block 
*this, unsigned long event
ip_addr_buf[0], ip_addr_buf[1],
ip_addr_buf[2], ip_addr_buf[3]);
 
-   wilc_setup_ipaddress(hif_drv, ip_addr_buf, nic->u8IfIdx);
+   wilc_setup_ipaddress(hif_drv, ip_addr_buf, vif->u8IfIdx);
 
break;
 
@@ -161,12 +161,12 @@ static int dev_state_ev_handler(struct notifier_block 
*this, unsigned long event
 
 static irqreturn_t isr_uh_routine(int irq, void *user_data)
 {
-   perInterface_wlan_t *nic;
+   struct wilc_vif *vif;
struct wilc *wilc;
struct net_device *dev = (struct net_device *)user_data;
 
-   nic = netdev_priv(dev);
-   wilc = nic->wilc;
+   vif = netdev_priv(dev);
+   wilc = vif->wilc;
PRINT_D(INT_DBG, "Interrupt received UH\n");
 
if (wilc->close) {
@@ -178,11 +178,11 @@ static irqreturn_t isr_uh_routine(i

[PATCH 3/3] staging: wilc1000: remove duplicate netdev

2015-11-26 Thread Glen Lee
There are two net_device pointer which is the same because two structures
are merged into wilc_vif in previous patch. Remove wilc_netdev and change
with ndev.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c | 35 +++
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  4 +--
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |  1 -
 3 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 810d7ce..bb3ff49 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -440,8 +440,8 @@ int wilc_wlan_get_firmware(struct net_device *dev)
goto _fail_;
}
 
-   if (!(&vif->wilc_netdev->dev)) {
-   PRINT_ER("&vif->wilc_netdev->dev  is NULL\n");
+   if (!(&vif->ndev->dev)) {
+   PRINT_ER("&vif->ndev->dev  is NULL\n");
goto _fail_;
}
 
@@ -1010,7 +1010,7 @@ int wilc_mac_open(struct net_device *ndev)
 
vif = netdev_priv(ndev);
wilc = vif->wilc;
-   priv = wiphy_priv(vif->wilc_netdev->ieee80211_ptr->wiphy);
+   priv = wiphy_priv(vif->ndev->ieee80211_ptr->wiphy);
PRINT_D(INIT_DBG, "MAC OPEN[%p]\n", ndev);
 
ret = wilc_init_host_int(ndev);
@@ -1050,12 +1050,12 @@ int wilc_mac_open(struct net_device *ndev)
return -EINVAL;
}
 
-   wilc_mgmt_frame_register(vif->wilc_netdev->ieee80211_ptr->wiphy,
-vif->wilc_netdev->ieee80211_ptr,
+   wilc_mgmt_frame_register(vif->ndev->ieee80211_ptr->wiphy,
+vif->ndev->ieee80211_ptr,
 vif->g_struct_frame_reg[0].frame_type,
 vif->g_struct_frame_reg[0].reg);
-   wilc_mgmt_frame_register(vif->wilc_netdev->ieee80211_ptr->wiphy,
-vif->wilc_netdev->ieee80211_ptr,
+   wilc_mgmt_frame_register(vif->ndev->ieee80211_ptr->wiphy,
+vif->ndev->ieee80211_ptr,
 vif->g_struct_frame_reg[1].frame_type,
 vif->g_struct_frame_reg[1].reg);
netif_wake_queue(ndev);
@@ -1204,13 +1204,13 @@ int wilc_mac_close(struct net_device *ndev)
 
vif = netdev_priv(ndev);
 
-   if (!vif || !vif->wilc_netdev || !vif->wilc_netdev->ieee80211_ptr ||
-   !vif->wilc_netdev->ieee80211_ptr->wiphy) {
+   if (!vif || !vif->ndev || !vif->ndev->ieee80211_ptr ||
+   !vif->ndev->ieee80211_ptr->wiphy) {
PRINT_ER("vif = NULL\n");
return 0;
}
 
-   priv = wiphy_priv(vif->wilc_netdev->ieee80211_ptr->wiphy);
+   priv = wiphy_priv(vif->ndev->ieee80211_ptr->wiphy);
wl = vif->wilc;
 
if (!priv) {
@@ -1239,10 +1239,10 @@ int wilc_mac_close(struct net_device *ndev)
return 0;
}
 
-   if (vif->wilc_netdev) {
-   netif_stop_queue(vif->wilc_netdev);
+   if (vif->ndev) {
+   netif_stop_queue(vif->ndev);
 
-   wilc_deinit_host_int(vif->wilc_netdev);
+   wilc_deinit_host_int(vif->ndev);
}
 
if (wl->open_ifcs == 0) {
@@ -1288,7 +1288,7 @@ static int mac_ioctl(struct net_device *ndev, struct 
ifreq *req, int cmd)
return PTR_ERR(buff);
 
if (strncasecmp(buff, "RSSI", length) == 0) {
-   priv = 
wiphy_priv(vif->wilc_netdev->ieee80211_ptr->wiphy);
+   priv = 
wiphy_priv(vif->ndev->ieee80211_ptr->wiphy);
ret = wilc_get_rssi(priv->hWILCWFIDrv, &rssi);
if (ret)
PRINT_ER("Failed to send get rssi 
param's message queue ");
@@ -1457,7 +1457,6 @@ int wilc_netdev_init(struct wilc **wilc, struct device 
*dev, int io_type,
strcpy(ndev->name, "p2p%d");
 
vif->u8IfIdx = wl->vif_num;
-   vif->wilc_netdev = ndev;
vif->wilc = *wilc;
wl->vif[i] = vif;
wl->vif[wl->vif_num]->ndev = ndev;
@@ -1476,9 +1475,9 @@ int wilc_netdev_init(struct wilc **wilc, struct device 
*dev, int io_type,
return -1;
}
 
-   vif->wilc_netdev->ieee80211_ptr = wdev;
-   vif->wilc_netdev->ml_priv = vif;
-   wdev->netdev = vif->wilc_netdev;
+   vif->ndev->ieee80211_ptr = wdev;
+   vif->ndev->ml_priv = vif;
+   wdev->netdev = vif->ndev;
vif->netstats.rx_packets = 0;
vif->netstats.tx_packets = 0;
vif->netstats.rx_bytes = 0;
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgope