[PATCH 00/10] iwlwifi: updates intended for v4.18 2018-05-30

2018-05-30 Thread Luca Coelho
From: Luca Coelho 

Hi,

Here's the last batch of patches intended for 4.18.  Focused on
bugfixes, especially (but not exclusively) regressions introduced in
4.18.  The patches include these changes:

* Some bugzilla fixes;
* Some kernel warning fixes;
* Fix for an (ETSI) WMM limits bug;
* Fix for a Bluetooth coexistence problem on 9000 devices;
* Fix for an interoperability bug related to block-ack sessions; 

As usual, I'm pushing this to a pending branch, for kbuild bot, and
will send a pull-request later.

Please review.

Cheers,
Luca.


Aviya Erenfeld (1):
  iwlmvm: tdls: Check TDLS channel switch support

Colin Ian King (1):
  iwlwifi: mvm: remove division by size of sizeof(struct
ieee80211_wmm_rule)

Emmanuel Grumbach (2):
  iwlwifi: mvm: fix TSO with highly fragmented SKBs
  iwlwifi: mvm: honor the max_amsdu_subframes limit

Erel Geron (1):
  iwlwifi: fix non_shared_ant for 9000 devices

Golan Ben Ami (1):
  iwlwifi: add csr configuration for 6300 devices

Gregory Greenman (1):
  iwlwifi: mvm: open BA session only when sta is authorized

Johannes Berg (1):
  iwlwifi: mvm: fix race in queue notification wait

Sara Sharon (1):
  iwlwifi: mvm: drop UNKNOWN security type frames

Shaul Triebitz (1):
  iwlwifi: pcie: fix race in Rx buffer allocator

 drivers/net/wireless/intel/iwlwifi/cfg/6000.c |  1 +
 drivers/net/wireless/intel/iwlwifi/cfg/9000.c |  2 +-
 .../net/wireless/intel/iwlwifi/fw/api/rx.h|  1 +
 .../wireless/intel/iwlwifi/iwl-nvm-parse.c|  3 +-
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c |  8 ++--
 drivers/net/wireless/intel/iwlwifi/mvm/rs.c   | 38 +--
 drivers/net/wireless/intel/iwlwifi/mvm/rs.h   |  7 +---
 drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 36 --
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c  |  2 +-
 drivers/net/wireless/intel/iwlwifi/mvm/sta.h  | 10 ++---
 drivers/net/wireless/intel/iwlwifi/mvm/tdls.c | 16 +---
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c   | 16 +---
 drivers/net/wireless/intel/iwlwifi/pcie/drv.c |  3 ++
 drivers/net/wireless/intel/iwlwifi/pcie/rx.c  |  2 +
 14 files changed, 83 insertions(+), 62 deletions(-)

-- 
2.17.0



[PATCH 01/10] iwlwifi: add csr configuration for 6300 devices

2018-05-30 Thread Luca Coelho
From: Golan Ben Ami 

Recently we have switched the csr addresses and values configuration
from a single configuration to all devices to a per-device configuration.
Doing that, the configuration for 6300 devices wasn't set.
This missing definition introduced a kernel panic once trying to access
the csr's.

Add the missing 6300 csr configuration.

While at it, add a checker that the csr values were indeed
configured, and bail out more gracefully if not.

Fixes: a8cbb46f831d ("iwlwifi: allow different csr flags for different device 
families")
Signed-off-by: Golan Ben Ami 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/cfg/6000.c | 1 +
 drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/cfg/6000.c 
b/drivers/net/wireless/intel/iwlwifi/cfg/6000.c
index 51cec0bb75fc..dbcec7ce7863 100644
--- a/drivers/net/wireless/intel/iwlwifi/cfg/6000.c
+++ b/drivers/net/wireless/intel/iwlwifi/cfg/6000.c
@@ -373,6 +373,7 @@ const struct iwl_cfg iwl6000_3agn_cfg = {
.eeprom_params = &iwl6000_eeprom_params,
.ht_params = &iwl6000_ht_params,
.led_mode = IWL_LED_BLINK,
+   .csr = &iwl_csr_v1,
 };
 
 MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX));
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
index 959de2f8bb28..38234bda9017 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
@@ -836,6 +836,9 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
struct iwl_trans *iwl_trans;
int ret;
 
+   if (WARN_ONCE(!cfg->csr, "CSR addresses aren't configured\n"))
+   return -EINVAL;
+
iwl_trans = iwl_trans_pcie_alloc(pdev, ent, cfg);
if (IS_ERR(iwl_trans))
return PTR_ERR(iwl_trans);
-- 
2.17.0



[PATCH 08/10] iwlwifi: mvm: honor the max_amsdu_subframes limit

2018-05-30 Thread Luca Coelho
From: Emmanuel Grumbach 

A peer can limit the number of subframes it can handle in a
single A-MSDU.  Honor this limit.

Note that the smallest limit is 8, and we are very unlikely to reach
that limit. So this isn't really a big deal.

Fixes: a6d5e32f247c ("iwlwifi: mvm: send large SKBs to the transport")
Signed-off-by: Emmanuel Grumbach 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
index 0b7f98d00298..cf2591f2ac23 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
@@ -844,6 +844,10 @@ static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct 
sk_buff *skb,
 */
num_subframes = (max_amsdu_len + pad) / (subf_len + pad);
 
+   if (sta->max_amsdu_subframes &&
+   num_subframes > sta->max_amsdu_subframes)
+   num_subframes = sta->max_amsdu_subframes;
+
tcp_payload_len = skb_tail_pointer(skb) - skb_transport_header(skb) -
tcp_hdrlen(skb) + skb->data_len;
 
-- 
2.17.0



[PATCH 02/10] iwlwifi: mvm: drop UNKNOWN security type frames

2018-05-30 Thread Luca Coelho
From: Sara Sharon 

In some cases we may get from FW errored frames with
UNKNOWN security type.

This may happen in unsecured aggregation flow, where
the first packet had a CRC error in the WEP bit, which
was followed by a failure to decrypt and was dropped.

The next frames in the aggregation "inherit" the bad metadata
of the first packet.

Make sure to drop such frames since RADA and other offloads
will not operate correctly which may have unexpected results.

In case of AP it also causes to TX AMSDU frames to the peers,
resulting with assert 0x104B.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 .../net/wireless/intel/iwlwifi/fw/api/rx.h|  1 +
 drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 20 +++
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h 
b/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h
index e7565f37ece9..7e570c4a9df0 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h
@@ -295,6 +295,7 @@ enum iwl_rx_mpdu_status {
IWL_RX_MPDU_STATUS_MIC_OK   = BIT(6),
IWL_RX_MPDU_RES_STATUS_TTAK_OK  = BIT(7),
IWL_RX_MPDU_STATUS_SEC_MASK = 0x7 << 8,
+   IWL_RX_MPDU_STATUS_SEC_UNKNOWN  = IWL_RX_MPDU_STATUS_SEC_MASK,
IWL_RX_MPDU_STATUS_SEC_NONE = 0x0 << 8,
IWL_RX_MPDU_STATUS_SEC_WEP  = 0x1 << 8,
IWL_RX_MPDU_STATUS_SEC_CCM  = 0x2 << 8,
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
index bb63e75a9b7f..2b1f0dc73c25 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
@@ -227,12 +227,24 @@ static void iwl_mvm_get_signal_strength(struct iwl_mvm 
*mvm,
 }
 
 static int iwl_mvm_rx_crypto(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr,
-struct ieee80211_rx_status *stats,
-struct iwl_rx_mpdu_desc *desc, u32 pkt_flags,
-int queue, u8 *crypt_len)
+struct ieee80211_rx_status *stats, u16 phy_info,
+struct iwl_rx_mpdu_desc *desc,
+u32 pkt_flags, int queue, u8 *crypt_len)
 {
u16 status = le16_to_cpu(desc->status);
 
+   /*
+* Drop UNKNOWN frames in aggregation, unless in monitor mode
+* (where we don't have the keys).
+* We limit this to aggregation because in TKIP this is a valid
+* scenario, since we may not have the (correct) TTAK (phase 1
+* key) in the firmware.
+*/
+   if (phy_info & IWL_RX_MPDU_PHY_AMPDU &&
+   (status & IWL_RX_MPDU_STATUS_SEC_MASK) ==
+   IWL_RX_MPDU_STATUS_SEC_UNKNOWN && !mvm->monitor_on)
+   return -1;
+
if (!ieee80211_has_protected(hdr->frame_control) ||
(status & IWL_RX_MPDU_STATUS_SEC_MASK) ==
IWL_RX_MPDU_STATUS_SEC_NONE)
@@ -870,7 +882,7 @@ void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct 
napi_struct *napi,
 
rx_status = IEEE80211_SKB_RXCB(skb);
 
-   if (iwl_mvm_rx_crypto(mvm, hdr, rx_status, desc,
+   if (iwl_mvm_rx_crypto(mvm, hdr, rx_status, phy_info, desc,
  le32_to_cpu(pkt->len_n_flags), queue,
  &crypt_len)) {
kfree_skb(skb);
-- 
2.17.0



[PATCH 05/10] iwlwifi: pcie: fix race in Rx buffer allocator

2018-05-30 Thread Luca Coelho
From: Shaul Triebitz 

Make sure the rx_allocator worker is canceled before running the
rx_init routine.  rx_init frees and re-allocates all rxb's pages.  The
rx_allocator worker also allocates pages for the used rxb's.  Running
rx_init and rx_allocator simultaniously causes a kernel panic.  Fix
that by canceling the work in rx_init.

Signed-off-by: Shaul Triebitz 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
index f772d70a65e4..d15f5ba2dc77 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
@@ -902,6 +902,8 @@ static int _iwl_pcie_rx_init(struct iwl_trans *trans)
}
def_rxq = trans_pcie->rxq;
 
+   cancel_work_sync(&rba->rx_alloc);
+
spin_lock(&rba->lock);
atomic_set(&rba->req_pending, 0);
atomic_set(&rba->req_ready, 0);
-- 
2.17.0



[PATCH 09/10] iwlwifi: mvm: fix race in queue notification wait

2018-05-30 Thread Luca Coelho
From: Johannes Berg 

Initially in this code, the race didn't matter since it didn't
do anything. Latest with the commit I marked this as fixing it
started to matter as something got done here that needed other
data that got freed as soon as the queue notification wait was
returning.

In the scenario we saw, apparently the IWL_MVM_RXQ_NOTIF_DEL_BA
event was sent to all queues, but processing the last event we
returned from iwl_mvm_sync_rx_queues_internal() and then from
iwl_mvm_free_reorder() and continued some processing before
wl_mvm_del_ba() was even invoked on the other CPU. Thus, when
the latter finally ran, it found that mvm->baid_map[baid] was
no longer valid.

Correct the race by moving the counter decrement and wake_up()
to be done only after all the per-event processing completed.
Note that in the commit I marked as being fixed the wake_up()
didn't exist yet (and the code was otherwise problematic) but
this particular problem already existed in a way.

Fixes: b915c10174fb ("iwlwifi: mvm: add reorder buffer per queue")
Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
index 2b1f0dc73c25..129c4c09648d 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
@@ -590,14 +590,10 @@ void iwl_mvm_rx_queue_notif(struct iwl_mvm *mvm, struct 
iwl_rx_cmd_buffer *rxb,
notif = (void *)pkt->data;
internal_notif = (void *)notif->payload;
 
-   if (internal_notif->sync) {
-   if (mvm->queue_sync_cookie != internal_notif->cookie) {
-   WARN_ONCE(1,
- "Received expired RX queue sync message\n");
-   return;
-   }
-   if (!atomic_dec_return(&mvm->queue_sync_counter))
-   wake_up(&mvm->rx_sync_waitq);
+   if (internal_notif->sync &&
+   mvm->queue_sync_cookie != internal_notif->cookie) {
+   WARN_ONCE(1, "Received expired RX queue sync message\n");
+   return;
}
 
switch (internal_notif->type) {
@@ -609,6 +605,10 @@ void iwl_mvm_rx_queue_notif(struct iwl_mvm *mvm, struct 
iwl_rx_cmd_buffer *rxb,
default:
WARN_ONCE(1, "Invalid identifier %d", internal_notif->type);
}
+
+   if (internal_notif->sync &&
+   !atomic_dec_return(&mvm->queue_sync_counter))
+   wake_up(&mvm->rx_sync_waitq);
 }
 
 /*
-- 
2.17.0



[PATCH 07/10] iwlwifi: mvm: open BA session only when sta is authorized

2018-05-30 Thread Luca Coelho
From: Gregory Greenman 

Currently, a BA session is opened when the tx traffic exceeds
10 frames per second. As a result of inter-op problems with some
APs, add a condition to open BA session only when station is
already authorized.

Fixes: 482e48440a0e ("iwlwifi: mvm: change open and close criteria of a BA 
session")
Signed-off-by: Gregory Greenman 
Signed-off-by: Luca Coelho 
---
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c |  8 ++--
 drivers/net/wireless/intel/iwlwifi/mvm/rs.c   | 38 +--
 drivers/net/wireless/intel/iwlwifi/mvm/rs.h   |  7 +---
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c  |  2 +-
 drivers/net/wireless/intel/iwlwifi/mvm/sta.h  | 10 ++---
 5 files changed, 29 insertions(+), 36 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index 5f0701c992a4..f3cab26f81b5 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -2685,7 +2685,7 @@ static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw,
 
mutex_lock(&mvm->mutex);
/* track whether or not the station is associated */
-   mvm_sta->associated = new_state >= IEEE80211_STA_ASSOC;
+   mvm_sta->sta_state = new_state;
 
if (old_state == IEEE80211_STA_NOTEXIST &&
new_state == IEEE80211_STA_NONE) {
@@ -2737,8 +2737,7 @@ static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw,
iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL);
}
 
-   iwl_mvm_rs_rate_init(mvm, sta, mvmvif->phy_ctxt->channel->band,
-true);
+   iwl_mvm_rs_rate_init(mvm, sta, mvmvif->phy_ctxt->channel->band);
ret = iwl_mvm_update_sta(mvm, vif, sta);
} else if (old_state == IEEE80211_STA_ASSOC &&
   new_state == IEEE80211_STA_AUTHORIZED) {
@@ -2754,8 +2753,7 @@ static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw,
/* enable beacon filtering */
WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif, 0));
 
-   iwl_mvm_rs_rate_init(mvm, sta, mvmvif->phy_ctxt->channel->band,
-false);
+   iwl_mvm_rs_rate_init(mvm, sta, mvmvif->phy_ctxt->channel->band);
 
ret = 0;
} else if (old_state == IEEE80211_STA_AUTHORIZED &&
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
index af7bc3b7b0c3..642da10b0b7f 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
@@ -3,6 +3,7 @@
  * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
+ * Copyright(c) 2018 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -13,10 +14,6 @@
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  * more details.
  *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
  * The full GNU General Public License is included in this distribution in the
  * file called LICENSE.
  *
@@ -651,9 +648,10 @@ static void rs_tl_turn_on_agg(struct iwl_mvm *mvm, struct 
iwl_mvm_sta *mvmsta,
}
 
tid_data = &mvmsta->tid_data[tid];
-   if ((tid_data->state == IWL_AGG_OFF) &&
+   if (mvmsta->sta_state >= IEEE80211_STA_AUTHORIZED &&
+   tid_data->state == IWL_AGG_OFF &&
(lq_sta->tx_agg_tid_en & BIT(tid)) &&
-   (tid_data->tx_count_last >= IWL_MVM_RS_AGG_START_THRESHOLD)) {
+   tid_data->tx_count_last >= IWL_MVM_RS_AGG_START_THRESHOLD) {
IWL_DEBUG_RATE(mvm, "try to aggregate tid %d\n", tid);
if (rs_tl_turn_on_agg_for_tid(mvm, lq_sta, tid, sta) == 0)
tid_data->state = IWL_AGG_QUEUED;
@@ -1257,7 +1255,7 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct 
ieee80211_sta *sta,
   (unsigned long)(lq_sta->last_tx +
   (IWL_MVM_RS_IDLE_TIMEOUT * HZ {
IWL_DEBUG_RATE(mvm, "Tx idle for too long. reinit rs\n");
-   iwl_mvm_rs_rate_init(mvm, sta, info->band, false);
+   iwl_mvm_rs_rate_init(mvm, sta, info->band);
return;
}
lq_sta->last_tx = jiffies;
@@ -2690,9 +2688,9 @@ static void rs_get_initial_rate(struct iwl_mvm *mvm,
struct ieee80211_sta *sta,
struct iwl_lq_sta *lq_sta,
enum nl80211_band band,
-   struct

[PATCH 06/10] iwlwifi: mvm: remove division by size of sizeof(struct ieee80211_wmm_rule)

2018-05-30 Thread Luca Coelho
From: Colin Ian King 

The subtraction of two struct ieee80211_wmm_rule pointers leaves a result
that is automatically scaled down by the size of the size of pointed-to
type, hence the division by sizeof(struct ieee80211_wmm_rule) is
bogus and should be removed.

Detected by CoverityScan, CID#146 ("Extra sizeof expression")

Fixes: 77e30e10ee28 ("iwlwifi: mvm: query regdb for wmm rule if needed")
Signed-off-by: Colin Ian King 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
index 0f9d56420c42..b815ba38dbdb 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
@@ -1025,8 +1025,7 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct 
iwl_cfg *cfg,
continue;
 
copy_rd->reg_rules[i].wmm_rule = d_wmm +
-   (regd->reg_rules[i].wmm_rule - s_wmm) /
-   sizeof(struct ieee80211_wmm_rule);
+   (regd->reg_rules[i].wmm_rule - s_wmm);
}
 
 out:
-- 
2.17.0



RE: [EXT] Re: [PATCH] mwifiex: handle race during mwifiex_usb_disconnect

2018-05-30 Thread Ganapathi Bhat
Hi Brian,

> > @@ -644,6 +644,9 @@ static void mwifiex_usb_disconnect(struct
> usb_interface *intf)
> >  MWIFIEX_FUNC_SHUTDOWN);
> > }
> >
> > +   if (adapter->workqueue)
> > +   flush_workqueue(adapter->workqueue);
>
> This seems like a bad fix. I'm fairly sure there's another race in here
> somewhere, and at a minimum, this is fragile code.
Ok. Did you mean there can be some RX work pending at this point, which can
cause a similar race for rx URBs?
>
> Instead, can't you just move the mwifiex_usb_free() into a .cleanup_if()
> or .unregister_dev() callback? That's what your other drivers (PCIe and
> SDIO) use to clean up old buffers and stop bus activity; those are
> called after the appropriate synchronization points; and I'm pretty sure
> I've already audited those to be more or less safe.
Ok. Yes, this is a better fix for this issue. I will revert the earlier fix and 
upstream this version.
>
> Brian
>
> > +
> > mwifiex_usb_free(card);
> >
> > mwifiex_dbg(adapter, FATAL,
> > --
> > 1.9.1
> >
Thanks,
Ganapathi


[PATCH 03/10] iwlmvm: tdls: Check TDLS channel switch support

2018-05-30 Thread Luca Coelho
From: Aviya Erenfeld 

Some versions of the FW don't support channel switch in TDLS.
Add a condition that checks it.

Fixes: 307e47235a10 ("iwlwifi: mvm: configure TDLS peers to FW")
Signed-off-by: Aviya Erenfeld 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/tdls.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tdls.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/tdls.c
index 3d97436bbdf5..67f360c0d17e 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tdls.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tdls.c
@@ -7,6 +7,7 @@
  *
  * Copyright(c) 2014 Intel Mobile Communications GmbH
  * Copyright(c) 2017 Intel Deutschland GmbH
+ * Copyright(C) 2018 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of version 2 of the GNU General Public License as
@@ -18,9 +19,7 @@
  * General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
- * USA
+ * along with this program.
  *
  * The full GNU General Public License is included in this distribution
  * in the file called COPYING.
@@ -33,6 +32,7 @@
  *
  * Copyright(c) 2014 Intel Mobile Communications GmbH
  * Copyright(c) 2017 Intel Deutschland GmbH
+ * Copyright(C) 2018 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -188,8 +188,14 @@ void iwl_mvm_recalc_tdls_state(struct iwl_mvm *mvm, struct 
ieee80211_vif *vif,
if (tdls_sta_cnt == 1 && sta_added)
iwl_mvm_power_update_mac(mvm);
 
-   /* configure the FW with TDLS peer info */
-   iwl_mvm_tdls_config(mvm, vif);
+   /* Configure the FW with TDLS peer info only if TDLS channel switch
+* capability is set.
+* TDLS config data is used currently only in TDLS channel switch code.
+* Supposed to serve also TDLS buffer station which is not implemneted
+* yet in FW*/
+   if (fw_has_capa(&mvm->fw->ucode_capa,
+   IWL_UCODE_TLV_CAPA_TDLS_CHANNEL_SWITCH))
+   iwl_mvm_tdls_config(mvm, vif);
 
/* when the last peer leaves, send a power update last */
if (tdls_sta_cnt == 0 && !sta_added)
-- 
2.17.0



[PATCH 04/10] iwlwifi: mvm: fix TSO with highly fragmented SKBs

2018-05-30 Thread Luca Coelho
From: Emmanuel Grumbach 

Our hardware has a limited amount of buffer descriptors
for each Tx packet. Because of that, there is a short
piece of code that makes sure that that we don't push too
many subframes in an A-MSDU because of subframes needs 2
buffer descriptors. This code also takes into account the
number of fragment of the skb since we also need a buffer
descriptor for each fragment in the skb.

This piece of code though didn't check that the resulting
number of subframes wasn't 0.

A user reported that using NFS client, he could get skbs
that are so fragmented that the code mentioned above
returned 0 for the number of subframes making
skb_gso_segment fail and subconsequently iwlwifi would WARN.

Fix this by make sure that num_subframes is at least 1.

This fixes:
https://bugzilla.kernel.org/show_bug.cgi?id=199209

Fixes: a6d5e32f247c ("iwlwifi: mvm: send large SKBs to the transport")
Signed-off-by: Emmanuel Grumbach 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
index df4c60496f72..0b7f98d00298 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
@@ -843,8 +843,6 @@ static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct 
sk_buff *skb,
 * N * subf_len + (N - 1) * pad.
 */
num_subframes = (max_amsdu_len + pad) / (subf_len + pad);
-   if (num_subframes > 1)
-   *ieee80211_get_qos_ctl(hdr) |= IEEE80211_QOS_CTL_A_MSDU_PRESENT;
 
tcp_payload_len = skb_tail_pointer(skb) - skb_transport_header(skb) -
tcp_hdrlen(skb) + skb->data_len;
@@ -855,10 +853,12 @@ static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct 
sk_buff *skb,
 *  1 more for each fragment
 *  1 more for the potential data in the header
 */
-   num_subframes =
-   min_t(unsigned int, num_subframes,
- (mvm->trans->max_skb_frags - 1 -
-  skb_shinfo(skb)->nr_frags) / 2);
+   if ((num_subframes * 2 + skb_shinfo(skb)->nr_frags + 1) >
+   mvm->trans->max_skb_frags)
+   num_subframes = 1;
+
+   if (num_subframes > 1)
+   *ieee80211_get_qos_ctl(hdr) |= IEEE80211_QOS_CTL_A_MSDU_PRESENT;
 
/* This skb fits in one single A-MSDU */
if (num_subframes * mss >= tcp_payload_len) {
-- 
2.17.0



[PATCH 10/10] iwlwifi: fix non_shared_ant for 9000 devices

2018-05-30 Thread Luca Coelho
From: Erel Geron 

The non-shared antenna was wrong for 9000 device series.  Fix it to
ANT_B for correct antenna preference by coex in MVM driver.

Fixes: 89374fe60bfb ("iwlwifi: Add new PCI IDs for 9260 and 5165 series")
Signed-off-by: Erel Geron 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/cfg/9000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/cfg/9000.c 
b/drivers/net/wireless/intel/iwlwifi/cfg/9000.c
index 9706624911f8..e20c30b29c03 100644
--- a/drivers/net/wireless/intel/iwlwifi/cfg/9000.c
+++ b/drivers/net/wireless/intel/iwlwifi/cfg/9000.c
@@ -137,7 +137,7 @@ static const struct iwl_tt_params iwl9000_tt_params = {
.base_params = &iwl9000_base_params,\
.led_mode = IWL_LED_RF_STATE,   \
.nvm_hw_section_num = NVM_HW_SECTION_NUM_FAMILY_9000,   \
-   .non_shared_ant = ANT_A,\
+   .non_shared_ant = ANT_B,\
.dccm_offset = IWL9000_DCCM_OFFSET, \
.dccm_len = IWL9000_DCCM_LEN,   \
.dccm2_offset = IWL9000_DCCM2_OFFSET,   \
-- 
2.17.0



Re: [PATCH V3 0/5] Update brcm firmware files

2018-05-30 Thread Chi-Hsien Lin




On 05/27/2018 10:37, Hans de Goede wrote:

Hi,

On 18-05-18 09:04, Hans de Goede wrote:

Hi,

On 15-05-18 10:43, Arend van Spriel wrote:

On 5/14/2018 2:05 PM, Josh Boyer wrote:

n Mon, May 14, 2018 at 6:11 AM Arend van Spriel <
arend.vanspr...@broadcom.com> wrote:


On 3/16/2018 3:08 PM, Chi-Hsien Lin wrote:

Update brcm firmware files and WHENCE accordingly.



Hi firmware-maintainers,


It seems this series somehow got lost. Can these still be applied. 
They
can be found in the linux-wireless patchwork database. I provided 
links

below.


All 5 of these move the respective firmware files under the Cypress
license.  It has been pointed out that the Cypress license has some
questionable language in it and that people have been in touch to 
try and

get this resolved.  I'm personally waiting on applying them until the
licence issue is sorted out.


Thanks, Josh

I could not find any such response. Has it been taken off-list? Seems 
like 2 months is quite some time, but maybe there are lawyers 
involved ;-)


Yes the discussion about this has been happening off-list. IANAL but
the gist of it is (AFAIK) that:

https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/LICENCE.cypress 



has a clause which allows Cypress to retro-actively revoke the LICENSE:

"either party may terminate this Agreement at any time with or without 
cause."

...
"Upon termination, you must destroy all copies of Software in your 
possession or

control."

So upon revokation we would have to remove the files from linux-firmware
(rewrite git history?) and since distros get their redistribution rights
from this license too they would also need to remove it from their 
packages

including all mirrors and archives of older versions. Which simply is not
feasible and no other license in linux-firmware has such a clause.


Chi-Hsien or other people from Cypress, any progress on getting the license
updated to remove the troublesome termination without cause clause?

Hi all,

I have received the updated license from the Legal department today. 
Have just submitted a V4 with the updated license.


Regards,
Chi-hsien Lin



Non of the other vendors with firmware in Linux firmware deem it necessary
to have such a patch.

Given that the proposed firmware updates which this is blocking are
*SECURITY* fixes it would be good to get this resolved ASAP.

Regards,

Hans


Re: [PATCH V3 0/5] Update brcm firmware files

2018-05-30 Thread Hans de Goede

Hi,

On 30-05-18 09:28, Chi-Hsien Lin wrote:



On 05/27/2018 10:37, Hans de Goede wrote:

Hi,

On 18-05-18 09:04, Hans de Goede wrote:

Hi,

On 15-05-18 10:43, Arend van Spriel wrote:

On 5/14/2018 2:05 PM, Josh Boyer wrote:

n Mon, May 14, 2018 at 6:11 AM Arend van Spriel <
arend.vanspr...@broadcom.com> wrote:


On 3/16/2018 3:08 PM, Chi-Hsien Lin wrote:

Update brcm firmware files and WHENCE accordingly.



Hi firmware-maintainers,



It seems this series somehow got lost. Can these still be applied. They
can be found in the linux-wireless patchwork database. I provided links
below.


All 5 of these move the respective firmware files under the Cypress
license.  It has been pointed out that the Cypress license has some
questionable language in it and that people have been in touch to try and
get this resolved.  I'm personally waiting on applying them until the
licence issue is sorted out.


Thanks, Josh

I could not find any such response. Has it been taken off-list? Seems like 2 
months is quite some time, but maybe there are lawyers involved ;-)


Yes the discussion about this has been happening off-list. IANAL but
the gist of it is (AFAIK) that:

https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/LICENCE.cypress

has a clause which allows Cypress to retro-actively revoke the LICENSE:

"either party may terminate this Agreement at any time with or without cause."
...
"Upon termination, you must destroy all copies of Software in your possession or
control."

So upon revokation we would have to remove the files from linux-firmware
(rewrite git history?) and since distros get their redistribution rights
from this license too they would also need to remove it from their packages
including all mirrors and archives of older versions. Which simply is not
feasible and no other license in linux-firmware has such a clause.


Chi-Hsien or other people from Cypress, any progress on getting the license
updated to remove the troublesome termination without cause clause?

Hi all,

I have received the updated license from the Legal department today. Have just 
submitted a V4 with the updated license.


Great, thank you (note I've not checked the new license yet).

Regards,

Hans



[RFT v2, 6/6] wlcore: Use generic runtime pm calls for wowlan elp configuration

2018-05-30 Thread Eyal Reizer
With runtime PM enabled, we can now use calls to pm_runtime_force_suspend
and pm_runtime_force_resume for enabling elp during suspend when wowlan
is enabled and waking the chip from elp on resume.

Remove the custom API that was used to ensure that the command
that is used to allow ELP during suspend is completed before the system
suspend.

Signed-off-by: Eyal Reizer 
Signed-off-by: Tony Lindgren 
---
Changes since v1:
use pm_runtime_force_() instaed of pm_generic_runtime_() calls

 drivers/net/wireless/ti/wlcore/main.c | 51 +--
 1 file changed, 13 insertions(+), 38 deletions(-)

diff --git a/drivers/net/wireless/ti/wlcore/main.c 
b/drivers/net/wireless/ti/wlcore/main.c
index 890397a..36d7055 100644
--- a/drivers/net/wireless/ti/wlcore/main.c
+++ b/drivers/net/wireless/ti/wlcore/main.c
@@ -1000,24 +1000,6 @@ static int wlcore_fw_wakeup(struct wl1271 *wl)
return wlcore_raw_write32(wl, HW_ACCESS_ELP_CTRL_REG, ELPCTRL_WAKE_UP);
 }
 
-static int wlcore_fw_sleep(struct wl1271 *wl)
-{
-   int ret;
-
-   mutex_lock(&wl->mutex);
-   ret = wlcore_raw_write32(wl, HW_ACCESS_ELP_CTRL_REG, ELPCTRL_SLEEP);
-   if (ret < 0) {
-   wl12xx_queue_recovery_work(wl);
-   goto out;
-   }
-   set_bit(WL1271_FLAG_IN_ELP, &wl->flags);
-out:
-   mutex_unlock(&wl->mutex);
-   mdelay(WL1271_SUSPEND_SLEEP);
-
-   return 0;
-}
-
 static int wl1271_setup(struct wl1271 *wl)
 {
wl->raw_fw_status = kzalloc(wl->fw_status_len, GFP_KERNEL);
@@ -1741,6 +1723,7 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw,
 {
struct wl1271 *wl = hw->priv;
struct wl12xx_vif *wlvif;
+   unsigned long flags;
int ret;
 
wl1271_debug(DEBUG_MAC80211, "mac80211 suspend wow=%d", !!wow);
@@ -1799,19 +1782,6 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw,
/* flush any remaining work */
wl1271_debug(DEBUG_MAC80211, "flushing remaining works");
 
-   /*
-* disable and re-enable interrupts in order to flush
-* the threaded_irq
-*/
-   wlcore_disable_interrupts(wl);
-
-   /*
-* set suspended flag to avoid triggering a new threaded_irq
-* work. no need for spinlock as interrupts are disabled.
-*/
-   set_bit(WL1271_FLAG_SUSPENDED, &wl->flags);
-
-   wlcore_enable_interrupts(wl);
flush_work(&wl->tx_work);
 
/*
@@ -1821,15 +1791,14 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw,
cancel_delayed_work(&wl->tx_watchdog_work);
 
/*
-* Use an immediate call for allowing the firmware to go into power
-* save during suspend.
-* Using a workque for this last write was only hapenning on resume
-* leaving the firmware with power save disabled during suspend,
-* while consuming full power during wowlan suspend.
+* set suspended flag to avoid triggering a new threaded_irq
+* work.
 */
-   wlcore_fw_sleep(wl);
+   spin_lock_irqsave(&wl->wl_lock, flags);
+   set_bit(WL1271_FLAG_SUSPENDED, &wl->flags);
+   spin_unlock_irqrestore(&wl->wl_lock, flags);
 
-   return 0;
+   return pm_runtime_force_suspend(wl->dev);
 }
 
 static int wl1271_op_resume(struct ieee80211_hw *hw)
@@ -1844,6 +1813,12 @@ static int wl1271_op_resume(struct ieee80211_hw *hw)
 wl->wow_enabled);
WARN_ON(!wl->wow_enabled);
 
+   ret = pm_runtime_force_resume(wl->dev);
+   if (ret < 0) {
+   wl1271_error("ELP wakeup failure!");
+   goto out_sleep;
+   }
+
/*
 * re-enable irq_work enqueuing, and call irq_work directly if
 * there is a pending work.
-- 
2.7.4



Re: [PATCH 2/3] brcmfmac: handle monitor mode marked msgbuf packets

2018-05-30 Thread Arend van Spriel

On 5/27/2018 7:34 AM, Julian Calaby wrote:

Hi Arend,
On Fri, May 25, 2018 at 12:38 PM Arend van Spriel <
arend.vanspr...@broadcom.com> wrote:


On 5/22/2018 3:18 PM, Rafał Miłecki wrote:

From: Rafał Miłecki 

New Broadcom firmwares mark monitor mode packets using a newly defined
bit in the flags field. Use it to filter them out and pass to the
monitor interface. These defines were found in bcmmsgbuf.h from SDK.

As not every firmware generates radiotap header this commit introduces
BRCMF_FEAT_MON_FMT_RADIOTAP that has to be set per firmware version. If
not present brcmf_netif_mon_rx() assumed packet being a raw 802.11 frame
and prepends it with an empty radiotap header.

It's limited to the msgbuf protocol. Adding support for SDIO/USB devices
will require some extra research.



So I went looking on my shelf and found the patch I made for SDIO a
while back. It relies on firmware change and I did not introduce a
firmware flag for it. I will send the patch as RFT so you can have a
look at it.



I checked our internal driver and it turns out the raw vs. radiotap is a
compilation option. So depending on customer they would get either
firmware doing the radiotap header generation or the host driver,
without any run-time way to determine it. Not nice for brcmfmac.


I pretty sure I know what the answer to this is going to be, however I
still have to ask:

Is it possible to open up _any_ part of the firmware? (Even if it's just
the host-interface end and the hardware end is a big ugly blob) It'd make
dealing with stuff like this so much easier if we can just toggle a flag
and recompile. (I'm also sure that we'd be more than happy to pass some
flag through telling us/you that it's unofficial firmware and has probably
broken the hardware, etc.)


Hah. Yeah, with next to nil uncertainty I know the answer to this as 
well. If you know how long it took before we committed to supporting the 
upstream drivers. Despite my better judgement I will pass your idea, but 
it is not something that is going to fall in the timeframe that Rafał 
had in mind.


Regards,
Arend


Re: [PATCH 2/3] brcmfmac: handle monitor mode marked msgbuf packets

2018-05-30 Thread Arend van Spriel

On 5/22/2018 3:18 PM, Rafał Miłecki wrote:

From: Rafał Miłecki 

New Broadcom firmwares mark monitor mode packets using a newly defined
bit in the flags field. Use it to filter them out and pass to the
monitor interface. These defines were found in bcmmsgbuf.h from SDK.

As not every firmware generates radiotap header this commit introduces
BRCMF_FEAT_MON_FMT_RADIOTAP that has to be set per firmware version. If
not present brcmf_netif_mon_rx() assumed packet being a raw 802.11 frame
and prepends it with an empty radiotap header.

It's limited to the msgbuf protocol. Adding support for SDIO/USB devices
will require some extra research.

Signed-off-by: Rafał Miłecki 
---
  .../wireless/broadcom/brcm80211/brcmfmac/core.c| 24 ++
  .../wireless/broadcom/brcm80211/brcmfmac/core.h|  2 ++
  .../wireless/broadcom/brcm80211/brcmfmac/feature.h |  6 +-
  .../wireless/broadcom/brcm80211/brcmfmac/msgbuf.c  | 17 +++
  4 files changed, 48 insertions(+), 1 deletion(-)



[snip]


diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
index d1193825e559..6e417d104b7f 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
@@ -33,6 +33,8 @@
   * MFP: 802.11w Management Frame Protection.
   * GSCAN: enhanced scan offload feature.
   * FWSUP: Firmware supplicant.
+ * MON_802_11_FLAG: monitor packets flagged as 802.11
+ * MON_FMT_RADIOTAP: monitor packets include radiotap header


Hi Rafał,

I am preparing the 4366c0 release. Can you tell me which firmwares that 
you have provide 802.11 packets and/or radiotap+802.11? Doing 'strings 
fwfile | tail -1' should give me the necessary info.


Regards,
Arend


   */
  #define BRCMF_FEAT_LIST \
BRCMF_FEAT_DEF(MBSS) \
@@ -48,7 +50,9 @@
BRCMF_FEAT_DEF(WOWL_ARP_ND) \
BRCMF_FEAT_DEF(MFP) \
BRCMF_FEAT_DEF(GSCAN) \
-   BRCMF_FEAT_DEF(FWSUP)
+   BRCMF_FEAT_DEF(FWSUP) \
+   BRCMF_FEAT_DEF(MON_802_11_FLAG) \
+   BRCMF_FEAT_DEF(MON_FMT_RADIOTAP)




Re: [PATCH 2/3] brcmfmac: handle monitor mode marked msgbuf packets

2018-05-30 Thread Julian Calaby
Hi Arend,

On Wed, May 30, 2018 at 8:05 PM Arend van Spriel <
arend.vanspr...@broadcom.com> wrote:

> On 5/27/2018 7:34 AM, Julian Calaby wrote:
> > Hi Arend,
> > On Fri, May 25, 2018 at 12:38 PM Arend van Spriel <
> > arend.vanspr...@broadcom.com> wrote:
> >
> >> On 5/22/2018 3:18 PM, Rafał Miłecki wrote:
> >>> From: Rafał Miłecki 
> >>>
> >>> New Broadcom firmwares mark monitor mode packets using a newly defined
> >>> bit in the flags field. Use it to filter them out and pass to the
> >>> monitor interface. These defines were found in bcmmsgbuf.h from SDK.
> >>>
> >>> As not every firmware generates radiotap header this commit introduces
> >>> BRCMF_FEAT_MON_FMT_RADIOTAP that has to be set per firmware version.
If
> >>> not present brcmf_netif_mon_rx() assumed packet being a raw 802.11
frame
> >>> and prepends it with an empty radiotap header.
> >>>
> >>> It's limited to the msgbuf protocol. Adding support for SDIO/USB
devices
> >>> will require some extra research.
> >
> >> So I went looking on my shelf and found the patch I made for SDIO a
> >> while back. It relies on firmware change and I did not introduce a
> >> firmware flag for it. I will send the patch as RFT so you can have a
> >> look at it.
> >
> >> I checked our internal driver and it turns out the raw vs. radiotap is
a
> >> compilation option. So depending on customer they would get either
> >> firmware doing the radiotap header generation or the host driver,
> >> without any run-time way to determine it. Not nice for brcmfmac.
> >
> > I pretty sure I know what the answer to this is going to be, however I
> > still have to ask:
> >
> > Is it possible to open up _any_ part of the firmware? (Even if it's just
> > the host-interface end and the hardware end is a big ugly blob) It'd
make
> > dealing with stuff like this so much easier if we can just toggle a flag
> > and recompile. (I'm also sure that we'd be more than happy to pass some
> > flag through telling us/you that it's unofficial firmware and has
probably
> > broken the hardware, etc.)

> Hah. Yeah, with next to nil uncertainty I know the answer to this as
> well. If you know how long it took before we committed to supporting the
> upstream drivers. Despite my better judgement I will pass your idea, but
> it is not something that is going to fall in the timeframe that Rafał
> had in mind.

Fair enough, I can't ask for more than that.

Good Luck!

-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/


Re: Research + questions on brcmfmac and support for monitor mode

2018-05-30 Thread Rafał Miłecki

I'm providing extra version info of tested firmware images as requested
by Arend in another e-mail thread.

On 15.05.2018 14:29, Rafał Miłecki wrote:

1) brcmfmac43602-pcie.ap.bin from linux-firmware.git
Firmware version = wl0: Sep 18 2015 03:30:01 version 7.35.177.56 (r587209) FWID 
01-6cb8e269

Monitor frames without raiotap

flags: 0x0001

Extra caps: mbss4 ndoe proptxstatus


43602a1-roml/pcie-ag-splitrx-fdap-mbss-mfp-wl11k-wl11u-txbf-pktctx-amsdutx-ampduretry-chkd2hdma-proptxstatus-11nprop
 Version: 7.35.177.56 CRC: 548eccd4 Date: Fri 2015-09-18 03:31:06 PDT Ucode 
Ver: 986.122 FWID: 01-6cb8e269



2) brcmfmac4366b-pcie.bin from linux-firmware.git
Firmware version = wl0: Jan  8 2016 12:54:07 version 10.10.69.3309 (r610991) 
FWID 01-c47a91a4

Monitor frames without raiotap

flags: 0x0001

Extra caps: ccx mbss8 multi-user-beamformer proptxstatus
single-user-beamformee single-user-beamformer toe txpwrcache


4366b1-roml/pcie-ag-splitrx-fdap-mbss-mfp-wnm-osen-wl11k-wl11u-txbf-pktctx-amsdutx-ampduretry-chkd2hdma-proptxstatus-11nprop-obss-dbwsw-ringer-dmaindex16-bgdfs
 Version: 10.10.69.237 CRC: 4bc48c7b Date: Fri 2016-01-08 12:55:25 PST Ucode 
Ver: 1073.531 FWID: 01-c47a91a4



3) 4366b1 development branch (from Arend)
Firmware version = wl0: Oct  6 2016 10:17:32 version 10.10 (TOB) (r663589) FWID 
01-6c5a1687

Monitor frames without raiotap

flags: 0x0001

Extra caps: bgdfs ccx mbss8 multi-user-beamformer proptxstatus
single-user-beamformee single-user-beamformer toe txpwrcache


4366b1-roml/pcie-ag-splitrx-fdap-mbss-mfp-wnm-osen-wl11k-wl11u-txbf-pktctx-amsdutx-ampduretry-chkd2hdma-proptxstatus-11nprop-obss-dbwsw-ringer-dmaindex16-bgdfs
 Version: 10.10 (TOB) (r663589) CRC: 50d4be62 Date: Thu 2016-10-06 10:46:42 BST 
Ucode Ver: 1128.155 FWID: 01-6c5a1687


4) brcmfmac4366c-pcie.bin.k3
Firmware version = wl0: Aug 19 2016 15:22:35 version 10.10.69.74 (r629731 
WLTEST) FWID 01-5c0166fa

Monitor frames without raiotap

flags: 0x0001

Extra caps: bgdfs ccx cptlv-4 mbss8 multi-user-beamformee
multi-user-beamformer single-user-beamformee single-user-beamformer toe
txpwrcache


4366c0-roml/pcie-ag-splitrx-fdap-mbss-mfgtest-seqcmds-phydbg-phydump-txbf-pktctx-amsdutx-ampduretry-chkd2hdma-11nprop-dbgam-dbgams-ringer-dmaindex16-bgdfs-hostpmac
 Version: 10.10.69.74 CRC: a6268b76 Date: Mon 2016-09-12 16:39:23 CST FWID 
01-5c0166fa



5) brcmfmac4366c-pcie.bin.ea9500
Firmware version = wl0: Aug 23 2016 17:19:51 version 10.10.69.69 (r625687) FWID 
01-8438621f

Monitor frames without raiotap

flags: 0x0001

Extra caps: bgdfs ccx mbss8 multi-user-beamformee multi-user-beamformer
proptxstatus single-user-beamformee single-user-beamformer toe
txpwrcache


4366c0-roml/pcie-ag-splitrx-fdap-mbss-mfp-wnm-osen-wl11k-wl11u-txbf-pktctx-amsdutx-ampduretry-chkd2hdma-proptxstatus-11nprop-obss-dbwsw-ringer-dmaindex16-bgdfs-hostpmac
 Version: 10.10.69.69 CRC: 34d30c8c Date: Tue 2016-08-23 17:31:24 PDT FWID 
01-8438621f



6) brcmfmac4366c-pcie.bin.ac88u
Firmware version = wl0: Sep 12 2016 13:26:44 version 10.10.69.6908 (r658761) 
FWID 01-fed440e1

Monitor frames without raiotap

flags: 0x0001

Extra caps: bgdfs ccx cptlv-4 mbss8 multi-user-beamformee
multi-user-beamformer proptxstatus single-user-beamformee
single-user-beamformer toe txpwrcache


4366c0-roml/pcie-ag-splitrx-fdap-mbss-mfp-wnm-osen-wl11k-wl11u-txbf-pktctx-amsdutx-ampduretry-chkd2hdma-proptxstatus-11nprop-obss-dbwsw-ringer-dmaindex16-bgdfs-hostpmac-txpwr
 Version: 10.10.69.252 CRC: 9fa88ab1 Date: Mon 2016-09-12 13:28:49 CST Ucode 
Ver: 1073.579 FWID: 01-fed440e1



7) brcmfmac4366c-pcie.bin.asus-dhd24
Firmware version = wl0: Nov  7 2017 12:23:08 version 10.10.69.69017 (r730013) 
FWID 01-e258597c

Monitor frames include radiotap header

flags: 0x0002

Extra caps: bgdfs ccx cptlv-4 mbss8 multi-user-beamformee
multi-user-beamformer proptxstatus single-user-beamformee
single-user-beamformer toe txpwrcache


4366c0-roml/pcie-ag-splitrx-fdap-mbss-mfp-wnm-osen-wl11k-wl11u-txbf-pktctx-amsdutx-ampduretry-chkd2hdma-proptxstatus-11nprop-obss-dbwsw-ringer-dmaindex16-bgdfs-hostpmac-txpwr-stamon
 Version: 10.10.69.69017 (r730013) CRC: cf0b5621 Date: Tue 2017-11-07 12:34:00 
CST Ucode Ver: 1073.579 FWID: 01-e258597c



8) 4366c0 fw from FW_EA9500v2_EA9500S_2.1.1.183171_prod.img
Firmware version = wl0: Aug  2 2017 18:45:13 version 10.10.122.20 (r683106) 
FWID 01-91326ac8

Monitor frames include radiotap header

flags: 0x0002

Extra caps: 160 bgdfs ccx dyn160 mbss8 multi-user-beamformee
multi-user-beamformer proptxstatus single-user-beamformee
single-user-beamformer toe txpwrcache


4366c0-roml/pcie-ag-splitrx-fdap-mbss-mfp-wnm-osen-wl11k-wl11u-txbf-pktctx-amsdutx-ampduretry-chkd2hdma-proptxstatus-11nprop-obss-dbwsw-ringer-dmaindex16-bgdfs-stamon-hostpmac-murx-splitassoc-hostmemucode-dyn160-dhdhdr
 Version: 10.10.122.20 CRC: c3ff28b5 Date: Wed 2017-08-02 18:58:48 PDT FWID 
01-91326ac8



9) 4366c0 fw from GT-AC5300_3.0.0.4_382_15984-gf481f58_cferom_ubi_0824.w
Firmware version = wl0: Aug 17

pull-request: iwlwifi-next 2018-05-30

2018-05-30 Thread Luca Coelho
Hi Kalle,

This is the final batch of patches intended for v4.18.  As discussed,
it is focused on bugfixes.  More details about the contents in the tag
description.

I have sent this out before and kbuildbot this morning, but I didn't
get any replies from it yet.

Please let me know if there are any issues.

Cheers,
Luca.


The following changes since commit 06895b1627fe36f0bea49d4c9fd0e27f0f7498b1:

  rtlwifi: remove duplicate code (2018-05-29 10:28:24 +0300)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-next.git 
tags/iwlwifi-next-for-kalle-2018-05-30

for you to fetch changes up to 506247825c5e877741f33a2c657d351e5c7943ba:

  iwlwifi: fix non_shared_ant for 9000 devices (2018-05-30 10:05:12 +0300)


Final batch of iwlwifi patches for 4.18

* Some bugzilla fixes;
* Some kernel warning fixes;
* Fix for an (ETSI) WMM limits bug;
* Fix for a Bluetooth coexistence problem on 9000 devices;
* Fix for an interoperability bug related to block-ack sessions;


Aviya Erenfeld (1):
  iwlmvm: tdls: Check TDLS channel switch support

Colin Ian King (1):
  iwlwifi: mvm: remove division by size of sizeof(struct ieee80211_wmm_rule)

Emmanuel Grumbach (2):
  iwlwifi: mvm: fix TSO with highly fragmented SKBs
  iwlwifi: mvm: honor the max_amsdu_subframes limit

Erel Geron (1):
  iwlwifi: fix non_shared_ant for 9000 devices

Golan Ben Ami (1):
  iwlwifi: add csr configuration for 6300 devices

Gregory Greenman (1):
  iwlwifi: mvm: open BA session only when sta is authorized

Johannes Berg (1):
  iwlwifi: mvm: fix race in queue notification wait

Sara Sharon (1):
  iwlwifi: mvm: drop UNKNOWN security type frames

Shaul Triebitz (1):
  iwlwifi: pcie: fix race in Rx buffer allocator

 drivers/net/wireless/intel/iwlwifi/cfg/6000.c  |  1 +
 drivers/net/wireless/intel/iwlwifi/cfg/9000.c  |  2 +-
 drivers/net/wireless/intel/iwlwifi/fw/api/rx.h |  1 +
 drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c |  3 +--
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c  |  8 +++-
 drivers/net/wireless/intel/iwlwifi/mvm/rs.c| 38 
+++---
 drivers/net/wireless/intel/iwlwifi/mvm/rs.h|  7 ++-
 drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c  | 36 

 drivers/net/wireless/intel/iwlwifi/mvm/sta.c   |  2 +-
 drivers/net/wireless/intel/iwlwifi/mvm/sta.h   | 10 --
 drivers/net/wireless/intel/iwlwifi/mvm/tdls.c  | 16 +++-
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c| 16 ++--
 drivers/net/wireless/intel/iwlwifi/pcie/drv.c  |  3 +++
 drivers/net/wireless/intel/iwlwifi/pcie/rx.c   |  2 ++
 14 files changed, 83 insertions(+), 62 deletions(-)

signature.asc
Description: This is a digitally signed message part


Re: Atheros AR9462 - 5Ghz not working

2018-05-30 Thread mgreger


 Sedat Dilek  wrote: 
> On Tue, May 22, 2018 at 7:21 PM,   wrote:
> > I've run out of ideas and am hoping someone here can help.
> >
> > All I want to do is connect a client to my 5Ghz network.
> >
> > My client:
> >   OS is Debian stable "Stretch" with sysvinit instead of systemd
> >   Atheros AR9462 (World roaming 0x64 regdomain in EEPROM)
> >   "iw reg set US"
> >   "iw list" shows both 2.4Ghz and 5Ghz bands available.
> >   "iw wlp3s0 survey dump" shows received traffic on 5Ghz bands.
> >
> > There are oodles of 5Ghz AP's within range, but scans (including passive 
> > scans) reveal only 2.4Ghz networks. My only guess was that it won't 
> > transmit due to regulatory requirements, but I cannot make it work.
> >
> > What I've tried:
> >   Running with and without CRDA
> >   Running latest mainline kernel
> >   Hacking around on the ath9k driver and nl80211 to remove all regulatory 
> > enforcement.
> >
> > Nothing works and I'm pulling my hair out. Any help would be greatly 
> > appreciated.
> 
> Hi,
> 
> I try to give some initial help.
> 
> The linux-wireless driver is supported by ath9k driver see [1] and [2].
> 
> Unfortunately, you have not sent any log-files at least your dmesg-log.
> No output of the above userspace commands or userspace-tools versions.
> No information to VendorID/ProductID (PCI, USB, whatever).
> It's not clear to me if this is a kernelspace (ath9k-driver) or
> userspace (CRDA/regulatory) problem.
> How should someone help you effectively?
> 
> The linux-wireless wiki has somne informations on how to debug
> Atheros/Qualcomm ath9k-driver, see [3].
> 
> As a debianist I say try Linux v4.16 Debian packages from
> stretch-backports (and maybe a higher version of wireless-regdb).
> 
> Try to ask questions the smart way [4] :-).
> 
> Hope this helps.
> 
> Regards,
> - Sedat -
> 
> [1] https://wireless.wiki.kernel.org/en/users/drivers/ath9k
> [2] https://wireless.wiki.kernel.org/en/users/drivers/ath9k/devices
> [3] https://wireless.wiki.kernel.org/en/users/drivers/ath9k/debug
> [4] http://www.catb.org/esr/faqs/smart-questions.html


I have also built the latest wireless-regdb and crda, but it made no difference.


[RFCv3 0/7] cfg80211/mac80211: Add support to configure and monitor rssi threshold

2018-05-30 Thread Tamizh chelvam
This patchsets introduced new NL command and api to support
configuring rssi for the connected stations and api to notify
userspace application upon crossing the configured threshold.
This will be useful for the application which requires
station's current capability change information.

Tamizh chelvam (7):
  wireless: Change single cqm_config to rssi config list
  cfg80211: Add new NL command to configure peer specific rssi threshold
  mac80211: Add api to support configuring station specific rssi
threshold
  cfg80211: Add support to notify station's rssi level crossing
  mac80211: Implement functionality to monitor station's rssi cross
event
  cfg80211: Accept multiple RSSI threholds for STA_MON command
  mac80211: Add api to configure low and high RSSI threshold

v3:
  * splitted single and multiple RSSI threshold changes as different patches

v2:
  * fixed kbuild warnings
  * updated commit log

 include/net/cfg80211.h   |  42 -
 include/net/mac80211.h   |   6 +
 include/uapi/linux/nl80211.h |  60 +++
 net/mac80211/cfg.c   |  75 +
 net/mac80211/rx.c|  65 +++-
 net/mac80211/sta_info.h  |  22 +++
 net/wireless/core.c  |  29 +++-
 net/wireless/core.h  |   6 +-
 net/wireless/nl80211.c   | 377 +--
 net/wireless/rdev-ops.h  |  31 
 net/wireless/trace.h |  73 +
 11 files changed, 723 insertions(+), 63 deletions(-)

-- 
1.9.1



[RFCv3 1/7] wireless: Change single cqm_config to rssi config list

2018-05-30 Thread Tamizh chelvam
This patch changes single cqm_config into mac address based
rssi config list. This way the same structure can be
utilized by AP mode as well.

Signed-off-by: Tamizh chelvam 
---
 include/net/cfg80211.h |  7 +++--
 net/wireless/core.c| 29 
 net/wireless/core.h|  6 ++--
 net/wireless/nl80211.c | 74 +-
 4 files changed, 81 insertions(+), 35 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 5fbfe61..656031e 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4139,7 +4139,7 @@ static inline struct wiphy *wiphy_new(const struct 
cfg80211_ops *ops,
 struct cfg80211_conn;
 struct cfg80211_internal_bss;
 struct cfg80211_cached_keys;
-struct cfg80211_cqm_config;
+struct cfg80211_rssi_config;
 
 /**
  * struct wireless_dev - wireless device state
@@ -4204,7 +4204,7 @@ static inline struct wiphy *wiphy_new(const struct 
cfg80211_ops *ops,
  * @event_lock: (private) lock for event list
  * @owner_nlportid: (private) owner socket port ID
  * @nl_owner_dead: (private) owner socket went away
- * @cqm_config: (private) nl80211 RSSI monitor state
+ * @rssi_config: (private) nl80211 RSSI monitor state
  */
 struct wireless_dev {
struct wiphy *wiphy;
@@ -4275,7 +4275,8 @@ struct wireless_dev {
} wext;
 #endif
 
-   struct cfg80211_cqm_config *cqm_config;
+   struct cfg80211_rssi_config *rssi_config;
+   struct list_head rssi_config_list;
 };
 
 static inline u8 *wdev_address(struct wireless_dev *wdev)
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 5fe35aa..62e496e 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -994,10 +994,28 @@ void wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool 
blocked)
 }
 EXPORT_SYMBOL(wiphy_rfkill_set_hw_state);
 
-void cfg80211_cqm_config_free(struct wireless_dev *wdev)
+void cfg80211_rssi_config_free(struct wireless_dev *wdev, const u8 *peer)
 {
-   kfree(wdev->cqm_config);
-   wdev->cqm_config = NULL;
+   struct cfg80211_rssi_config *rssi_config, *tmp;
+
+   if (list_empty(&wdev->rssi_config_list))
+   goto free;
+
+   list_for_each_entry_safe(rssi_config, tmp, &wdev->rssi_config_list,
+list) {
+   if (peer && memcmp(rssi_config->addr, peer, ETH_ALEN))
+   continue;
+
+   list_del(&rssi_config->list);
+   kfree(rssi_config);
+   if (list_empty(&wdev->rssi_config_list) || peer)
+   goto out;
+   }
+
+free:
+   kfree(wdev->rssi_config);
+out:
+   wdev->rssi_config = NULL;
 }
 
 void cfg80211_unregister_wdev(struct wireless_dev *wdev)
@@ -1027,7 +1045,7 @@ void cfg80211_unregister_wdev(struct wireless_dev *wdev)
break;
}
 
-   cfg80211_cqm_config_free(wdev);
+   cfg80211_rssi_config_free(wdev, NULL);
 }
 EXPORT_SYMBOL(cfg80211_unregister_wdev);
 
@@ -1163,6 +1181,7 @@ static int cfg80211_netdev_notifier_call(struct 
notifier_block *nb,
spin_lock_init(&wdev->event_lock);
INIT_LIST_HEAD(&wdev->mgmt_registrations);
spin_lock_init(&wdev->mgmt_registrations_lock);
+   INIT_LIST_HEAD(&wdev->rssi_config_list);
 
/*
 * We get here also when the interface changes network 
namespaces,
@@ -1292,7 +1311,7 @@ static int cfg80211_netdev_notifier_call(struct 
notifier_block *nb,
kzfree(wdev->wext.keys);
 #endif
flush_work(&wdev->disconnect_wk);
-   cfg80211_cqm_config_free(wdev);
+   cfg80211_rssi_config_free(wdev, NULL);
}
/*
 * synchronise (so that we won't find this netdev
diff --git a/net/wireless/core.h b/net/wireless/core.h
index 63eb1b5..170a31b 100644
--- a/net/wireless/core.h
+++ b/net/wireless/core.h
@@ -260,10 +260,12 @@ struct cfg80211_beacon_registration {
u32 nlportid;
 };
 
-struct cfg80211_cqm_config {
+struct cfg80211_rssi_config {
+   struct list_head list;
u32 rssi_hyst;
s32 last_rssi_event_value;
int n_rssi_thresholds;
+   u8 addr[ETH_ALEN];
s32 rssi_thresholds[0];
 };
 
@@ -514,6 +516,6 @@ void cfg80211_stop_nan(struct cfg80211_registered_device 
*rdev,
 #define CFG80211_DEV_WARN_ON(cond) ({bool __r = (cond); __r; })
 #endif
 
-void cfg80211_cqm_config_free(struct wireless_dev *wdev);
+void cfg80211_rssi_config_free(struct wireless_dev *wdev, const u8 *peer);
 
 #endif /* __NET_WIRELESS_CORE_H */
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 07514ca..2fb2e97 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -3200,6 +3200,7 @@ static int nl80211_new_interface(struct sk_buff *skb, 
struct genl_info *info)
spin_lock_init(&wdev->event_lock);
INIT_LIST_HEAD(&wdev->mgmt_registrations)

[RFCv3 4/7] cfg80211: Add support to notify station's rssi level crossing

2018-05-30 Thread Tamizh chelvam
Add cfg80211_sta_mon_rssi_notify api to update user space upon
crossing the configured rssi threshold of a station.
NL80211_CMD_NOTIFY_STA_MON introduced to send this event to
userspace along with NL80211_ATTR_STA_MON_RSSI_THRESHOLD_EVENT,
NL80211_ATTR_MAC and NL80211_ATTR_STA_MON_RSSI_LEVEL info.
Userspace application can make a decision depends on this
notification.

Signed-off-by: Tamizh chelvam 
---
 include/net/cfg80211.h   | 16 
 include/uapi/linux/nl80211.h |  1 +
 net/wireless/nl80211.c   | 98 
 net/wireless/trace.h | 22 ++
 4 files changed, 137 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 8e4c7db..494d47f 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5915,6 +5915,22 @@ void cfg80211_cqm_txe_notify(struct net_device *dev, 
const u8 *peer,
 void cfg80211_cqm_beacon_loss_notify(struct net_device *dev, gfp_t gfp);
 
 /**
+ * cfg80211_sta_mon_rssi_notify - Station's rssi out of range event
+ * @dev: network device
+ * @peer: Station's mac address
+ * @rssi_event: the triggered RSSI event
+ * @rssi_level: new RSSI level value or 0 if not available
+ * @gfp: context flags
+ *
+ * This function is called when a configured rssi threshold reached event
+ * occurs for a station.
+ */
+void
+cfg80211_sta_mon_rssi_notify(struct net_device *dev, const u8 *peer,
+   enum nl80211_sta_mon_rssi_threshold_event rssi_event,
+   s32 rssi_level, gfp_t gfp);
+
+/**
  * cfg80211_radar_event - radar detection event
  * @wiphy: the wiphy
  * @chandef: chandef for the current channel
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index f13ad07..9d47ee6 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1249,6 +1249,7 @@ enum nl80211_commands {
NL80211_CMD_CONTROL_PORT_FRAME,
 
NL80211_CMD_SET_STA_MON,
+   NL80211_CMD_NOTIFY_STA_MON,
 
/* add new commands above here */
 
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 587a5cb1..021e55a 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -15364,6 +15364,104 @@ void cfg80211_pmksa_candidate_notify(struct 
net_device *dev, int index,
 }
 EXPORT_SYMBOL(cfg80211_pmksa_candidate_notify);
 
+static struct sk_buff *cfg80211_prepare_sta_mon(struct net_device *dev,
+   const char *mac, gfp_t gfp)
+{
+   struct wireless_dev *wdev = dev->ieee80211_ptr;
+   struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
+   struct sk_buff *msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
+   void **cb;
+
+   if (!msg)
+   return NULL;
+
+   cb = (void **)msg->cb;
+
+   cb[0] = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NOTIFY_STA_MON);
+   if (!cb[0]) {
+   nlmsg_free(msg);
+   return NULL;
+   }
+
+   if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
+   nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex))
+   goto nla_put_failure;
+
+   if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac))
+   goto nla_put_failure;
+
+   cb[1] = nla_nest_start(msg, NL80211_ATTR_STA_MON);
+   if (!cb[1])
+   goto nla_put_failure;
+
+   cb[2] = rdev;
+
+   return msg;
+nla_put_failure:
+   nlmsg_free(msg);
+   return NULL;
+}
+
+static void cfg80211_send_sta_mon(struct sk_buff *msg, gfp_t gfp)
+{
+   void **cb = (void **)msg->cb;
+   struct cfg80211_registered_device *rdev = cb[2];
+
+   nla_nest_end(msg, cb[1]);
+   genlmsg_end(msg, cb[0]);
+
+   memset(msg->cb, 0, sizeof(msg->cb));
+
+   genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
+   NL80211_MCGRP_MLME, gfp);
+}
+
+void cfg80211_sta_mon_rssi_notify(struct net_device *dev, const u8 *peer,
+   enum nl80211_sta_mon_rssi_threshold_event rssi_event,
+   s32 rssi_level, gfp_t gfp)
+{
+   struct sk_buff *msg;
+   struct wireless_dev *wdev = dev->ieee80211_ptr;
+   struct cfg80211_rssi_config *rssi_config;
+
+   if (WARN_ON(!peer))
+   return;
+
+   if (WARN_ON(rssi_event != NL80211_STA_MON_RSSI_THRESHOLD_EVENT_LOW &&
+   rssi_event != NL80211_STA_MON_RSSI_THRESHOLD_EVENT_HIGH))
+   return;
+
+   trace_cfg80211_sta_mon_rssi_notify(dev, peer, rssi_event, rssi_level);
+
+   list_for_each_entry(rssi_config, &wdev->rssi_config_list, list) {
+   if (!memcmp(rssi_config->addr, peer, ETH_ALEN)) {
+   wdev->rssi_config = rssi_config;
+   wdev->rssi_config->last_rssi_event_value = rssi_level;
+   break;
+   }
+   }
+
+   msg = cfg80211_prepare_sta_mon(dev, peer, gfp);
+   if (!msg)
+   return;
+
+   if (nla_put_u32(msg, NL

[RFCv3 6/7] cfg80211: Accept multiple RSSI threholds for STA_MON command

2018-05-30 Thread Tamizh chelvam
Change the NL80211_CMD_STA_MON RSSI threshold attribut to
accept any number of thresholds as a sorted array. If
user send the configuration with single RSSI threshold then
the old mechanism is enabled. Same netlink event will be
generated in both cases. This patch introduced
set_sta_mon_rssi_range_config to configure high and low
value.
Driver supporting this feature should advertise
NL80211_EXT_FEATURE_STA_MON_RSSI_LIST.

Signed-off-by: Tamizh chelvam 
---
 include/net/cfg80211.h   |  10 +++
 include/uapi/linux/nl80211.h |   4 +
 net/wireless/nl80211.c   | 176 ++-
 net/wireless/rdev-ops.h  |  15 
 net/wireless/trace.h |  26 +++
 5 files changed, 180 insertions(+), 51 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 494d47f..ffd1204 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -3029,6 +3029,12 @@ struct cfg80211_external_auth_params {
  * the current level of a station is above/below the configured threshold;
  * this may need some care when the configuration is changed
  * (without first being disabled.)
+ * @set_sta_mon_rssi_range_config: Configure two RSSI thresholds in the
+ * station's rssi monitor.  An event is to be sent only when the
+ * signal level of a station is found to be outside the two values.
+ * The driver should advertise %NL80211_EXT_FEATURE_STA_MON_RSSI_LIST if
+ * this method is implemented. If it is provided then there's no point
+ * providing @set_sta_mon_rssi_config
  */
 struct cfg80211_ops {
int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -3338,6 +3344,10 @@ struct cfg80211_ops {
   struct net_device *dev,
   const u8 *addr,
   s32 rssi_thold, u32 rssi_hyst);
+   int (*set_sta_mon_rssi_range_config)(struct wiphy *wiphy,
+struct net_device *dev,
+const u8 *addr,
+s32 rssi_low, s32 rssi_high);
 };
 
 /*
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 9d47ee6..8e2a84b 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -5188,6 +5188,9 @@ enum nl80211_feature_flags {
  * @NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG: With this driver can set
  * rssi threshold using %NL80211_ATTR_STA_MON_RSSI_THOLD attribute
  * for a connected station.
+ * @NL80211_EXT_FEATURE_STA_MON_RSSI_LIST: With this driver the
+ * %NL80211_ATTR_STA_MON_RSSI_THOLD attribute accepts a list of zero or
+ * more RSSI threshold values to monitor rather than exactly one threshold.
  *
  * @NUM_NL80211_EXT_FEATURES: number of extended features.
  * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
@@ -5223,6 +5226,7 @@ enum nl80211_ext_feature_index {
NL80211_EXT_FEATURE_DATA_ACK_SIGNAL_SUPPORT,
NL80211_EXT_FEATURE_TXQS,
NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG,
+   NL80211_EXT_FEATURE_STA_MON_RSSI_LIST,
 
/* add new features before the definition below */
NUM_NL80211_EXT_FEATURES,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 021e55a..c0fccb4 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -10134,61 +10134,101 @@ static int nl80211_set_cqm_txe(struct genl_info 
*info,
 
 static const struct nla_policy
 nl80211_attr_sta_mon_policy[NL80211_ATTR_STA_MON_MAX + 1] = {
-   [NL80211_ATTR_STA_MON_RSSI_THOLD] = { .type = NLA_U32 },
+   [NL80211_ATTR_STA_MON_RSSI_THOLD] = { .type = NLA_BINARY },
[NL80211_ATTR_STA_MON_RSSI_HYST] = { .type = NLA_U32 },
[NL80211_ATTR_STA_MON_RSSI_THRESHOLD_EVENT] = { .type = NLA_U32 },
[NL80211_ATTR_STA_MON_RSSI_LEVEL] = { .type = NLA_S32 },
 };
 
-static int cfg80211_cqm_rssi_update(struct cfg80211_registered_device *rdev,
-   struct net_device *dev)
+static int cfg80211_set_rssi_range(struct cfg80211_registered_device *rdev,
+  struct net_device *dev, const u8 *mac_addr,
+  bool get_last_rssi)
 {
struct wireless_dev *wdev = dev->ieee80211_ptr;
-   s32 last, low, high;
+   s32 low, high, last;
u32 hyst;
-   int i, n;
-   int err;
-
-   /* RSSI reporting disabled? */
-   if (!wdev->rssi_config)
-   return rdev_set_cqm_rssi_range_config(rdev, dev, 0, 0);
+   int i, n, err;
 
-   /*
-* Obtain current RSSI value if possible, if not and no RSSI threshold
-* event has been received yet, we should receive an event after a
-* connection is established and enough beacons received to calculate
-* the average.
-*/
-   if (!wdev->rssi_config->last_rssi_event_value && w

[RFCv3 2/7] cfg80211: Add new NL command to configure peer specific rssi threshold

2018-05-30 Thread Tamizh chelvam
This patch add support to configure peer specific rssi configuration
to monitor station's signal strength variation.
New NL80211_CMD_SET_STA_MON introduced to configure rssi threshold
and hysteresis info using NL80211_ATTR_STA_MON_RSSI_THOLD and
NL80211_ATTR_STA_MON_RSSI_HYST along with NL80211_ATTR_MAC.
Driver supporting this configuration should advertise
NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG.
Monitoring station's signal strength variation will be useful
for the application like steering.

Signed-off-by: Tamizh chelvam 
---
 include/net/cfg80211.h   |  9 ++
 include/uapi/linux/nl80211.h | 55 +++
 net/wireless/nl80211.c   | 77 
 net/wireless/rdev-ops.h  | 16 +
 net/wireless/trace.h | 25 ++
 5 files changed, 182 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 656031e..8e4c7db 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -3024,6 +3024,11 @@ struct cfg80211_external_auth_params {
  *
  * @tx_control_port: TX a control port frame (EAPoL).  The noencrypt parameter
  * tells the driver that the frame should not be encrypted.
+ * @set_sta_mon_rssi_config: Configure  RSSI threshold for a station.
+ * After configuration, the driver should (soon) send an event indicating
+ * the current level of a station is above/below the configured threshold;
+ * this may need some care when the configuration is changed
+ * (without first being disabled.)
  */
 struct cfg80211_ops {
int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -3329,6 +3334,10 @@ struct cfg80211_ops {
   const u8 *buf, size_t len,
   const u8 *dest, const __be16 proto,
   const bool noencrypt);
+   int (*set_sta_mon_rssi_config)(struct wiphy *wiphy,
+  struct net_device *dev,
+  const u8 *addr,
+  s32 rssi_thold, u32 rssi_hyst);
 };
 
 /*
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 28b3654..f13ad07 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1033,6 +1033,9 @@
  * &NL80211_ATTR_CHANNEL_WIDTH,&NL80211_ATTR_NSS attributes with its
  * address(specified in &NL80211_ATTR_MAC).
  *
+ * @NL80211_CMD_SET_STA_MON: This command is used to configure station's
+ * connection monitoring notification trigger levels.
+ *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
  */
@@ -1245,6 +1248,8 @@ enum nl80211_commands {
 
NL80211_CMD_CONTROL_PORT_FRAME,
 
+   NL80211_CMD_SET_STA_MON,
+
/* add new commands above here */
 
/* used to define NL80211_CMD_MAX below */
@@ -2238,6 +2243,9 @@ enum nl80211_commands {
  * @NL80211_ATTR_TXQ_QUANTUM: TXQ scheduler quantum (bytes). Number of bytes
  *  a flow is assigned on each round of the DRR scheduler.
  *
+ * @NL80211_ATTR_STA_MON: Station's connection monitor configuration in a
+ * nested attribute with %NL80211_ATTR_STA_MON_* sub-attributes.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2677,6 +2685,8 @@ enum nl80211_attrs {
NL80211_ATTR_TXQ_MEMORY_LIMIT,
NL80211_ATTR_TXQ_QUANTUM,
 
+   NL80211_ATTR_STA_MON,
+
/* add attributes here, update the policy in nl80211.c */
 
__NL80211_ATTR_AFTER_LAST,
@@ -4276,6 +4286,46 @@ enum nl80211_ps_state {
 };
 
 /**
+ * enum nl80211_attr_sta_mon - Attributes to monitor station's connection
+ * @NL80211_ATTR_STA_MON_RSSI_THOLD: RSSI threshold in dBm. This value 
specifies
+ * the threshold for the RSSI level at which an event will be sent. Zero
+ * to disable.  Alternatively, if %NL80211_EXT_FEATURE_STA_MON_RSSI_LIST is
+ * set, multiple values can be supplied as a low-to-high sorted array of\
+ * threshold values in dBm.  Events will be sent when the RSSI value
+ * crosses any of the thresholds. This threshold values are station
+ * specific.
+ * @NL80211_ATTR_STA_MON_RSSI_HYST: RSSI hysteresis in dBm. This value 
specifies
+ * the minimum amount the RSSI level must change after an event before a
+ * new event may be issued (to reduce effects of RSSI oscillation).
+ * @NL80211_ATTR_STA_MON_RSSI_THRESHOLD_EVENT: RSSI threshold event
+ * @NL80211_ATTR_STA_MON_RSSI_LEVEL: the RSSI value in dBm that triggered the
+ * RSSI threshold event.
+ */
+enum nl80211_attr_sta_mon {
+   __NL80211_ATTR_STA_MON_INVALID,
+   NL80211_ATTR_STA_MON_RSSI_THOLD,
+   NL80211_ATTR_STA_MON_RSSI_HYST,
+   NL80211_ATTR_STA_MON_RSSI_THRESHOLD_EVENT,
+   NL80211_ATTR_STA_MON_RSSI_LEVEL,
+
+

[RFCv3 3/7] mac80211: Add api to support configuring station specific rssi threshold

2018-05-30 Thread Tamizh chelvam
This patch add set_sta_mon_rssi_config api to configure rssi and
hysteresis threshold value for a connected station. This configuration
will be applied only for the connected station.

Signed-off-by: Tamizh chelvam 
---
 net/mac80211/cfg.c  | 35 +++
 net/mac80211/sta_info.h | 12 
 2 files changed, 47 insertions(+)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index bdf6fa7..80ced50 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3803,6 +3803,40 @@ static int ieee80211_get_txq_stats(struct wiphy *wiphy,
return ret;
 }
 
+static int ieee80211_set_sta_mon_rssi_config(struct wiphy *wiphy,
+struct net_device *dev,
+const u8 *peer, s32 rssi_thold,
+u32 rssi_hyst)
+{
+   struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+   struct sta_info *sta;
+
+   if (sdata->vif.type == NL80211_IFTYPE_AP &&
+   (!sdata->vif.bss_conf.enable_beacon ||
+!wiphy_ext_feature_isset(sdata->local->hw.wiphy,
+NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG)))
+   return -EOPNOTSUPP;
+
+   mutex_lock(&sdata->local->sta_mtx);
+
+   sta = sta_info_get_bss(sdata, peer);
+   if (!sta) {
+   mutex_unlock(&sdata->local->sta_mtx);
+   return -ENOENT;
+   }
+
+   if (sta->rssi_thold == rssi_thold &&
+   sta->rssi_hyst == rssi_hyst)
+   goto unlock;
+
+   sta->rssi_thold = rssi_thold;
+   sta->rssi_hyst = rssi_hyst;
+   sta->last_sta_mon_event_signal = 0;
+unlock:
+   mutex_unlock(&sdata->local->sta_mtx);
+   return 0;
+}
+
 const struct cfg80211_ops mac80211_config_ops = {
.add_virtual_intf = ieee80211_add_iface,
.del_virtual_intf = ieee80211_del_iface,
@@ -3897,4 +3931,5 @@ static int ieee80211_get_txq_stats(struct wiphy *wiphy,
.set_multicast_to_unicast = ieee80211_set_multicast_to_unicast,
.tx_control_port = ieee80211_tx_control_port,
.get_txq_stats = ieee80211_get_txq_stats,
+   .set_sta_mon_rssi_config = ieee80211_set_sta_mon_rssi_config,
 };
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 81b35f6..8c459a7 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -482,6 +482,14 @@ struct ieee80211_sta_rx_stats {
  * @pcpu_rx_stats: per-CPU RX statistics, assigned only if the driver needs
  * this (by advertising the USES_RSS hw flag)
  * @status_stats: TX status statistics
+ * @rssi_thold: RSSI threshold to monitor station's signal strength, a zero
+ * value implies disabled. As with the cfg80211 callback, a change here
+ * should cause an event to be sent indicating where the current value
+ * is in relation to the newly configured threshold
+ * @rssi_hyst: Station's RSSI hysteresis
+ * @last_sta_mon_event_signal: Last signal strength average for a station
+ * that triggered a sta_mon event. 0 indicates that no event has been
+ * generated for the current association
  */
 struct sta_info {
/* General information, mostly static */
@@ -583,6 +591,10 @@ struct sta_info {
 
struct cfg80211_chan_def tdls_chandef;
 
+   s32 rssi_thold;
+   u32 rssi_hyst;
+   int last_sta_mon_event_signal;
+
/* keep last! */
struct ieee80211_sta sta;
 };
-- 
1.9.1



[RFCv3 7/7] mac80211: Add api to configure low and high RSSI threshold

2018-05-30 Thread Tamizh chelvam
Add set_sta_mon_rssi_range_config api to support
configuring low and high RSSI threshold values
for a connected station. And trigger an event if a
station's signal strength goes out of configured
range.

Signed-off-by: Tamizh chelvam 
---
 net/mac80211/cfg.c  | 40 
 net/mac80211/rx.c   | 23 +++
 net/mac80211/sta_info.h |  6 ++
 3 files changed, 69 insertions(+)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 80ced50..5cdd8a3 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3831,12 +3831,51 @@ static int ieee80211_set_sta_mon_rssi_config(struct 
wiphy *wiphy,
 
sta->rssi_thold = rssi_thold;
sta->rssi_hyst = rssi_hyst;
+   sta->rssi_low = 0;
+   sta->rssi_high = 0;
sta->last_sta_mon_event_signal = 0;
 unlock:
mutex_unlock(&sdata->local->sta_mtx);
return 0;
 }
 
+static int ieee80211_set_sta_mon_rssi_range_cfg(struct wiphy *wiphy,
+   struct net_device *dev,
+   const u8 *peer,
+   s32 rssi_low, s32 rssi_high)
+{
+   struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+   struct sta_info *sta;
+
+   if (sdata->vif.type == NL80211_IFTYPE_AP &&
+   (!sdata->vif.bss_conf.enable_beacon ||
+   !wiphy_ext_feature_isset(sdata->local->hw.wiphy,
+NL80211_EXT_FEATURE_STA_MON_RSSI_LIST)))
+   return -EOPNOTSUPP;
+
+   mutex_lock(&sdata->local->sta_mtx);
+
+   sta = sta_info_get_bss(sdata, peer);
+   if (!sta) {
+   mutex_unlock(&sdata->local->sta_mtx);
+   return -ENOENT;
+   }
+
+   if (sta->rssi_low == rssi_low &&
+   sta->rssi_high == rssi_high)
+   goto unlock;
+
+   sta->rssi_thold = 0;
+   sta->rssi_hyst = 0;
+   sta->rssi_low = rssi_low;
+   sta->rssi_high = rssi_high;
+   sta->last_sta_mon_event_signal = 0;
+
+unlock:
+   mutex_unlock(&sdata->local->sta_mtx);
+   return 0;
+}
+
 const struct cfg80211_ops mac80211_config_ops = {
.add_virtual_intf = ieee80211_add_iface,
.del_virtual_intf = ieee80211_del_iface,
@@ -3932,4 +3971,5 @@ static int ieee80211_set_sta_mon_rssi_config(struct wiphy 
*wiphy,
.tx_control_port = ieee80211_tx_control_port,
.get_txq_stats = ieee80211_get_txq_stats,
.set_sta_mon_rssi_config = ieee80211_set_sta_mon_rssi_config,
+   .set_sta_mon_rssi_range_config = ieee80211_set_sta_mon_rssi_range_cfg,
 };
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 06a6111..fddb5c6 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1569,6 +1569,29 @@ static void ieee80211_sta_rx_signal_thold_check(struct 
ieee80211_rx_data *rx)
sig, GFP_ATOMIC);
}
}
+
+   if (sta->rssi_low) {
+   int last_event = sta->last_sta_mon_event_signal;
+   int sig = -ewma_signal_read(&sta->rx_stats_avg.signal);
+   int low = sta->rssi_low;
+   int high = sta->rssi_high;
+
+   if (sig < low &&
+   (last_event == 0 || last_event >= low)) {
+   sta->last_sta_mon_event_signal = sig;
+   cfg80211_sta_mon_rssi_notify(
+   rx->sdata->dev, sta->addr,
+   NL80211_STA_MON_RSSI_THRESHOLD_EVENT_LOW,
+   sig, GFP_ATOMIC);
+   } else if (sig > high &&
+  (last_event == 0 || last_event <= high)) {
+   sta->last_sta_mon_event_signal = sig;
+   cfg80211_sta_mon_rssi_notify(
+   rx->sdata->dev, sta->addr,
+   NL80211_STA_MON_RSSI_THRESHOLD_EVENT_HIGH,
+   sig, GFP_ATOMIC);
+   }
+   }
 }
 
 static ieee80211_rx_result debug_noinline
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index e130f6d..05d68f8 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -487,6 +487,10 @@ struct ieee80211_sta_rx_stats {
  * should cause an event to be sent indicating where the current value
  * is in relation to the newly configured threshold
  * @rssi_hyst: Station's RSSI hysteresis
+ * @rssi_low: RSSI lower threshold to monitor station's signal strength, a zero
+ * value implies disabled.  This is an alternative mechanism to the single
+ * threshold event and can't be enabled simultaneously with it
+ * @rssi_high: RSSI upper threshold for station
  * @last_sta_mon_event_signal: Last signal strength average for a station
  * that triggered a sta_mon event. 0 indicates that no event has been
  * generated for the current association
@@ -596,6 +600,8 @@ struct sta_info {
 

[RFCv3 5/7] mac80211: Implement functionality to monitor station's rssi cross event

2018-05-30 Thread Tamizh chelvam
Triggers cfg80211_sta_mon_rssi_notify with the corresponding event when
station signal goes out of configured threshold. It uses rx data signal
to check against rssi threshold configured by the user.
This event will be useful for the application like steering to take
decision on any station depends on its current capability.

Signed-off-by: Tamizh chelvam 
---
 include/net/mac80211.h  |  6 ++
 net/mac80211/rx.c   | 42 +-
 net/mac80211/sta_info.h |  4 
 3 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 851a5e1..96fb9a8 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -802,6 +802,12 @@ enum mac80211_rate_control_flags {
IEEE80211_TX_RC_160_MHZ_WIDTH   = BIT(10),
 };
 
+/*
+ * How many frames need to have been used in average station's
+ * signal strength before checking against the threshold
+ */
+#define IEEE80211_STA_SIGNAL_AVE_MIN_COUNT 4
+
 
 /* there are 40 bytes if you don't need the rateset to be kept */
 #define IEEE80211_TX_INFO_DRIVER_DATA_SIZE 40
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 0a38cc1..06a6111 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1534,6 +1534,43 @@ void ieee80211_sta_uapsd_trigger(struct ieee80211_sta 
*pubsta, u8 tid)
return RX_CONTINUE;
 }
 
+static void ieee80211_sta_rx_signal_thold_check(struct ieee80211_rx_data *rx)
+{
+   struct sta_info *sta = rx->sta;
+   struct ieee80211_bss_conf *bss_conf = &rx->sdata->vif.bss_conf;
+
+   if (!wiphy_ext_feature_isset(rx->local->hw.wiphy,
+   NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG))
+   return;
+
+   sta->count_rx_signal++;
+   if (sta->count_rx_signal < IEEE80211_STA_SIGNAL_AVE_MIN_COUNT)
+   return;
+
+   if (sta->rssi_thold && bss_conf->enable_beacon) {
+   int last_event = sta->last_sta_mon_event_signal;
+   int thold = sta->rssi_thold;
+   int hyst = sta->rssi_hyst;
+   int sig = -ewma_signal_read(&sta->rx_stats_avg.signal);
+
+   if (sig < thold &&
+   (last_event == 0 || sig < last_event - hyst)) {
+   sta->last_sta_mon_event_signal = sig;
+   cfg80211_sta_mon_rssi_notify(
+   rx->sdata->dev, sta->addr,
+   NL80211_STA_MON_RSSI_THRESHOLD_EVENT_LOW,
+   sig, GFP_ATOMIC);
+   } else if (sig > thold &&
+  (last_event == 0 || sig > last_event + hyst)) {
+   sta->last_sta_mon_event_signal = sig;
+   cfg80211_sta_mon_rssi_notify(
+   rx->sdata->dev, sta->addr,
+   NL80211_STA_MON_RSSI_THRESHOLD_EVENT_HIGH,
+   sig, GFP_ATOMIC);
+   }
+   }
+}
+
 static ieee80211_rx_result debug_noinline
 ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
 {
@@ -1589,6 +1626,7 @@ void ieee80211_sta_uapsd_trigger(struct ieee80211_sta 
*pubsta, u8 tid)
if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) {
sta->rx_stats.last_signal = status->signal;
ewma_signal_add(&sta->rx_stats_avg.signal, -status->signal);
+   ieee80211_sta_rx_signal_thold_check(rx);
}
 
if (status->chains) {
@@ -4030,9 +4068,11 @@ static bool ieee80211_invoke_fast_rx(struct 
ieee80211_rx_data *rx,
/* statistics part of ieee80211_rx_h_sta_process() */
if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) {
stats->last_signal = status->signal;
-   if (!fast_rx->uses_rss)
+   if (!fast_rx->uses_rss) {
ewma_signal_add(&sta->rx_stats_avg.signal,
-status->signal);
+   ieee80211_sta_rx_signal_thold_check(rx);
+   }
}
 
if (status->chains) {
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 8c459a7..e130f6d 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -490,6 +490,9 @@ struct ieee80211_sta_rx_stats {
  * @last_sta_mon_event_signal: Last signal strength average for a station
  * that triggered a sta_mon event. 0 indicates that no event has been
  * generated for the current association
+ * @count_rx_signal: Number of data frames used in averaging station signal.
+ * This can be used to avoid generating less reliable station rssi cross
+ * events that would be based only on couple of received frames
  */
 struct sta_info {
/* General information, mostly static */
@@ -594,6 +597,7 @@ struct sta_info {
s32 rssi_thold;
u32 rssi_hyst;
int last_sta_mon_event_signal;
+   unsigned int count_rx_signal;
 
/* keep last! */
struct ieee80211

[RFCv3 0/4] cfg80211/mac80211: Add support to configure and monitor txrate threshold

2018-05-30 Thread Tamizh chelvam
This patchsets introduced new NL command and api to support
configuring txrate threshold for the connected stations and api to
notify userspace application upon crossing the configured txrate threshold.
This will be useful for the application which requires
station's current capability change information.

Tamizh chelvam (4):
  cfg80211: Add support to configure station specific txrate threshold
  mac80211: Add api to configure low and high txrate threshold
  cfg80211: Add support to notify station's txrate crossing event
  mac80211: Implement functionality to monitor txrate cross event for a
station

Note:
  * This patch rebased on top of below patchset
[RFCv3 0/7] cfg80211/mac80211: Add support to configure and monitor rssi 
threshold

v3:
  * splitted txrate patchsets as a different patchsets.

v2:
  * fixed kbuild warnings
  * updated commit log

 include/net/cfg80211.h   | 26 +++
 include/net/mac80211.h   |  5 +++
 include/uapi/linux/nl80211.h | 34 
 net/mac80211/cfg.c   | 36 +
 net/mac80211/sta_info.h  | 17 ++
 net/mac80211/status.c| 40 ++-
 net/wireless/nl80211.c   | 76 
 net/wireless/rdev-ops.h  | 17 ++
 net/wireless/trace.h | 50 +
 9 files changed, 300 insertions(+), 1 deletion(-)

-- 
1.9.1



[RFCv3 4/4] mac80211: Implement functionality to monitor txrate cross event for a station

2018-05-30 Thread Tamizh chelvam
Trigger cfg80211_sta_mon_txrate_notify with the corresponding txrate
event when the txrate for a station goes out of configured range.
This event will be useful for the application like steering to take
decision on any station depends on its current capability.

Signed-off-by: Tamizh chelvam 
---
 include/net/mac80211.h  |  5 +
 net/mac80211/cfg.c  |  1 +
 net/mac80211/sta_info.h | 10 ++
 net/mac80211/status.c   | 40 +++-
 4 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 96fb9a8..02714ea 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -808,6 +808,11 @@ enum mac80211_rate_control_flags {
  */
 #define IEEE80211_STA_SIGNAL_AVE_MIN_COUNT 4
 
+/* Number of txrate count need to have been used in average station's
+ * txrate before checking against the threshold
+ */
+#define IEEE80211_STA_TXRATE_AVE_MIN_COUNT 4
+
 
 /* there are 40 bytes if you don't need the rateset to be kept */
 #define IEEE80211_TX_INFO_DRIVER_DATA_SIZE 40
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 649f5c7..36ec5fb 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3904,6 +3904,7 @@ static int ieee80211_set_sta_mon_txrate_config(struct 
wiphy *wiphy,
 
sta->txrate_low = low_txrate_thold;
sta->txrate_high = high_txrate_thold;
+   sta->last_txrate_event = 0;
 
 unlock:
mutex_unlock(&sdata->local->sta_mtx);
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index a71f50c..f978e5a 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -419,6 +419,8 @@ struct ieee80211_sta_rx_stats {
  */
 #define STA_SLOW_THRESHOLD 6000 /* 6 Mbps */
 
+DECLARE_EWMA(sta_txrate, 4, 4)
+
 /**
  * struct sta_info - STA information
  *
@@ -501,6 +503,11 @@ struct ieee80211_sta_rx_stats {
  * in 100Kbps
  * @txrate_high: TXRATE upper threshold for a station to monitor, this will be
  * in 100Kbps
+ * @count_sta_txrate: Number of transmitted data frames used in ave_sta_txrate
+ * @last_txrate_event: Last txrate event that triggered sta_mon event for a
+ * station
+ * @ave_sta_txrate: Average txrate to check against the txrate_low and
+ * txrate_high. Values expressed in 100kbps
  */
 struct sta_info {
/* General information, mostly static */
@@ -611,6 +618,9 @@ struct sta_info {
 
u32 txrate_low;
u32 txrate_high;
+   unsigned int count_sta_txrate;
+   enum nl80211_sta_mon_txrate_threshold_event last_txrate_event;
+   struct ewma_sta_txrate ave_sta_txrate;
 
/* keep last! */
struct ieee80211_sta sta;
diff --git a/net/mac80211/status.c b/net/mac80211/status.c
index 9a6d720..112b18d 100644
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -701,6 +701,40 @@ void ieee80211_tx_monitor(struct ieee80211_local *local, 
struct sk_buff *skb,
dev_kfree_skb(skb);
 }
 
+static void ieee80211_sta_mon_txrate_thold_check(struct sta_info *sta)
+{
+   struct rate_info rinfo;
+   enum nl80211_sta_mon_txrate_threshold_event sta_txrate_event;
+   int txrate;
+
+   if (!sta->txrate_high)
+   return;
+
+   sta_set_rate_info_tx(sta, &sta->tx_stats.last_rate, &rinfo);
+   txrate = cfg80211_calculate_bitrate(&rinfo);
+   ewma_sta_txrate_add(&sta->ave_sta_txrate, txrate);
+   sta->count_sta_txrate++;
+
+   if (sta->count_sta_txrate < IEEE80211_STA_TXRATE_AVE_MIN_COUNT)
+   return;
+
+   txrate = ewma_sta_txrate_read(&sta->ave_sta_txrate);
+
+   if (txrate < sta->txrate_low)
+   sta_txrate_event = NL80211_STA_MON_TXRATE_THRESHOLD_EVENT_LOW;
+   else if (txrate > sta->txrate_high)
+   sta_txrate_event = NL80211_STA_MON_TXRATE_THRESHOLD_EVENT_HIGH;
+   else
+   sta_txrate_event = NL80211_STA_MON_TXRATE_THRESHOLD_IN_RANGE;
+
+   if (sta_txrate_event != sta->last_txrate_event) {
+   cfg80211_sta_mon_txrate_notify(sta->sdata->dev, sta->addr,
+  sta_txrate_event, txrate,
+  GFP_ATOMIC);
+   sta->last_txrate_event = sta_txrate_event;
+   }
+}
+
 static void __ieee80211_tx_status(struct ieee80211_hw *hw,
  struct ieee80211_tx_status *status)
 {
@@ -750,9 +784,13 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,
 
if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL) &&
(ieee80211_is_data(hdr->frame_control)) &&
-   (rates_idx != -1))
+   (rates_idx != -1)) {
sta->tx_stats.last_rate =
info->status.rates[rates_idx];
+   if (wiphy_ext_feature_isset(hw->wiphy,
+   NL80211_EXT_FEATURE_STA_MON_TXRATE_CONFIG))
+   ieee80211_sta_mon_txrat

[RFCv3 1/4] cfg80211: Add support to configure station specific txrate threshold

2018-05-30 Thread Tamizh chelvam
Add support to configure station specific txrate threshold
to monitor variation in the txrate for a station. Configuration
is passed using NL80211_ATTR_STA_MON_LOW_TXRATE_THOLD and
NL80211_ATTR_STA_MON_HIGH_TXRATE_THOLD in NL80211_CMD_SET_STA_MON
command and the configuration will be represented in 100kbps.
This will be useful for the application like steering which requires
station's current capability.

Driver supporting this configuration feature should advertise
NL80211_EXT_FEATURE_STA_MON_TXRATE_CONFIG.

Signed-off-by: Tamizh chelvam 
---
 include/net/cfg80211.h   |  9 +
 include/uapi/linux/nl80211.h | 34 ++
 net/wireless/nl80211.c   | 40 
 net/wireless/rdev-ops.h  | 17 +
 net/wireless/trace.h | 25 +
 5 files changed, 125 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index ffd1204..ab8a43f 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -3035,6 +3035,10 @@ struct cfg80211_external_auth_params {
  * The driver should advertise %NL80211_EXT_FEATURE_STA_MON_RSSI_LIST if
  * this method is implemented. If it is provided then there's no point
  * providing @set_sta_mon_rssi_config
+ * @set_sta_mon_txrate_config: Configure low and high TXRATE threshold in 
100kbs
+ * for a connected station. The driver should(soon) send an event
+ * indicating the current attempted frame txrate level is above/below the
+ * configured threshold
  */
 struct cfg80211_ops {
int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -3348,6 +3352,11 @@ struct cfg80211_ops {
 struct net_device *dev,
 const u8 *addr,
 s32 rssi_low, s32 rssi_high);
+   int (*set_sta_mon_txrate_config)(struct wiphy *wiphy,
+struct net_device *dev,
+const u8 *addr,
+u32 low_txrate_thold,
+u32 high_txrate_thold);
 };
 
 /*
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 8e2a84b..c7ce475 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -4301,6 +4301,15 @@ enum nl80211_ps_state {
  * @NL80211_ATTR_STA_MON_RSSI_THRESHOLD_EVENT: RSSI threshold event
  * @NL80211_ATTR_STA_MON_RSSI_LEVEL: the RSSI value in dBm that triggered the
  * RSSI threshold event.
+ * @NL80211_ATTR_STA_MON_LOW_TXRATE_THOLD: TX_RATE threshold in 100kbps. This
+ * u32 attribute specifies the low txrate threshold. Event will be sent
+ * if the txrate for a station goes lesser than this threshold.
+ * @NL80211_ATTR_STA_MON_HIGH_TXRATE_THOLD: TX_RATE threshold in 100kbps. This
+ * u32 attribute specifies the upper txrate threshold. Event will be sent
+ * if the txrate for a station goes greater than this threshold.
+ * @NL80211_ATTR_STA_MON_TXRATE_THRESHOLD_EVENT: TX_RATE threshold cross event
+ * @NL80211_ATTR_STA_MON_TXRATE_LEVEL: TXRATE for a station in 100kbps that
+ * triggered the TX_RATE threshold cross event.
  */
 enum nl80211_attr_sta_mon {
__NL80211_ATTR_STA_MON_INVALID,
@@ -4308,6 +4317,10 @@ enum nl80211_attr_sta_mon {
NL80211_ATTR_STA_MON_RSSI_HYST,
NL80211_ATTR_STA_MON_RSSI_THRESHOLD_EVENT,
NL80211_ATTR_STA_MON_RSSI_LEVEL,
+   NL80211_ATTR_STA_MON_LOW_TXRATE_THOLD,
+   NL80211_ATTR_STA_MON_HIGH_TXRATE_THOLD,
+   NL80211_ATTR_STA_MON_TXRATE_THRESHOLD_EVENT,
+   NL80211_ATTR_STA_MON_TXRATE_LEVEL,
 
/* keep last */
__NL80211_ATTR_STA_MON_AFTER_LAST,
@@ -4327,6 +4340,21 @@ enum nl80211_sta_mon_rssi_threshold_event {
 };
 
 /**
+ * enum nl80211_sta_mon_txrate_threshold_event - TX_RATE threshold event
+ * @NL80211_STA_MON_TXRATE_THRESHOLD_IN_RANGE: The TX_RATE level is in between
+ * low and high threshold
+ * @NL80211_STA_MON_TXRATE_THRESHOLD_EVENT_LOW: The TX_RATE level is lower than
+ * the configured threshold
+ * @NL80211_STA_MON_TXRATE_THRESHOLD_EVENT_HIGH: The TX_RATE is higher than the
+ * configured threshold
+ */
+enum nl80211_sta_mon_txrate_threshold_event {
+   NL80211_STA_MON_TXRATE_THRESHOLD_IN_RANGE,
+   NL80211_STA_MON_TXRATE_THRESHOLD_EVENT_LOW,
+   NL80211_STA_MON_TXRATE_THRESHOLD_EVENT_HIGH,
+};
+
+/**
  * enum nl80211_attr_cqm - connection quality monitor attributes
  * @__NL80211_ATTR_CQM_INVALID: invalid
  * @NL80211_ATTR_CQM_RSSI_THOLD: RSSI threshold in dBm. This value specifies
@@ -5191,6 +5219,11 @@ enum nl80211_feature_flags {
  * @NL80211_EXT_FEATURE_STA_MON_RSSI_LIST: With this driver the
  * %NL80211_ATTR_STA_MON_RSSI_THOLD attribute accepts a list of zero or
  * more RSSI threshold values to monitor rather than exact

[RFCv3 2/4] mac80211: Add api to configure low and high txrate threshold

2018-05-30 Thread Tamizh chelvam
Add set_sta_mon_txrate_config api to configure low and high
txrate threshold for a connected station. The configuration
will be represented in 100kbps.

Signed-off-by: Tamizh chelvam 
---
 net/mac80211/cfg.c  | 35 +++
 net/mac80211/sta_info.h |  7 +++
 2 files changed, 42 insertions(+)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 5cdd8a3..649f5c7 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3876,6 +3876,40 @@ static int ieee80211_set_sta_mon_rssi_range_cfg(struct 
wiphy *wiphy,
return 0;
 }
 
+static int ieee80211_set_sta_mon_txrate_config(struct wiphy *wiphy,
+  struct net_device *dev,
+  const u8 *peer,
+  u32 low_txrate_thold,
+  u32 high_txrate_thold)
+{
+   struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+   struct sta_info *sta;
+
+   if (sdata->vif.type == NL80211_IFTYPE_AP &&
+   !wiphy_ext_feature_isset(sdata->local->hw.wiphy,
+   NL80211_EXT_FEATURE_STA_MON_TXRATE_CONFIG))
+   return -EOPNOTSUPP;
+
+   mutex_lock(&sdata->local->sta_mtx);
+
+   sta = sta_info_get_bss(sdata, peer);
+   if (!sta) {
+   mutex_unlock(&sdata->local->sta_mtx);
+   return -ENOENT;
+   }
+
+   if (sta->txrate_low == low_txrate_thold &&
+   sta->txrate_high == high_txrate_thold)
+   goto unlock;
+
+   sta->txrate_low = low_txrate_thold;
+   sta->txrate_high = high_txrate_thold;
+
+unlock:
+   mutex_unlock(&sdata->local->sta_mtx);
+   return 0;
+}
+
 const struct cfg80211_ops mac80211_config_ops = {
.add_virtual_intf = ieee80211_add_iface,
.del_virtual_intf = ieee80211_del_iface,
@@ -3972,4 +4006,5 @@ static int ieee80211_set_sta_mon_rssi_range_cfg(struct 
wiphy *wiphy,
.get_txq_stats = ieee80211_get_txq_stats,
.set_sta_mon_rssi_config = ieee80211_set_sta_mon_rssi_config,
.set_sta_mon_rssi_range_config = ieee80211_set_sta_mon_rssi_range_cfg,
+   .set_sta_mon_txrate_config = ieee80211_set_sta_mon_txrate_config,
 };
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 05d68f8..a71f50c 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -497,6 +497,10 @@ struct ieee80211_sta_rx_stats {
  * @count_rx_signal: Number of data frames used in averaging station signal.
  * This can be used to avoid generating less reliable station rssi cross
  * events that would be based only on couple of received frames
+ * @txrate_low: TXRATE lower threshold for a station to monitor, this will be
+ * in 100Kbps
+ * @txrate_high: TXRATE upper threshold for a station to monitor, this will be
+ * in 100Kbps
  */
 struct sta_info {
/* General information, mostly static */
@@ -605,6 +609,9 @@ struct sta_info {
int last_sta_mon_event_signal;
unsigned int count_rx_signal;
 
+   u32 txrate_low;
+   u32 txrate_high;
+
/* keep last! */
struct ieee80211_sta sta;
 };
-- 
1.9.1



[RFCv3 3/4] cfg80211: Add support to notify station's txrate crossing event

2018-05-30 Thread Tamizh chelvam
Add cfg80211_sta_mon_txrate_notify to update userspace upon
crossing the configured txrate threshold for a station.
This uses NL80211_CMD_NOTIFY_STA_MON along with
NL80211_ATTR_STA_MON_TXRATE_THRESHOLD_EVENT, NL80211_ATTR_MAC
and NL80211_ATTR_STA_MON_TXRATE_LEVEL. Userspace application can
make a decision on the station depends on this notification.

Signed-off-by: Tamizh chelvam 
---
 include/net/cfg80211.h | 17 +
 net/wireless/nl80211.c | 36 
 net/wireless/trace.h   | 25 +
 3 files changed, 78 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index ab8a43f..b02ed31 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5898,6 +5898,23 @@ void cfg80211_cqm_rssi_notify(struct net_device *dev,
  s32 rssi_level, gfp_t gfp);
 
 /**
+ * cfg80211_sta_mon_txrate_notify - txrate event for connected stations
+ * @dev: network device
+ * @peer: peer's MAC address
+ * @txrate_event: the triggered TX RATE event
+ * @txrate_level: new TX RATE level value or 0 if not available
+ * @gfp: context flags
+ *
+ * This function is called when a average of attempted frame txrate crossed
+ * above configured high txrate or below configured low txrate event
+ * occurs for a station.
+ */
+void
+cfg80211_sta_mon_txrate_notify(struct net_device *dev, const u8 *peer,
+   enum nl80211_sta_mon_txrate_threshold_event txrate_event,
+   u32 txrate_level, gfp_t gfp);
+
+/**
  * cfg80211_cqm_pktloss_notify - notify userspace about packetloss to peer
  * @dev: network device
  * @peer: peer's MAC address
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 31680d6..6701961 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -15576,6 +15576,42 @@ void cfg80211_sta_mon_rssi_notify(struct net_device 
*dev, const u8 *peer,
 }
 EXPORT_SYMBOL(cfg80211_sta_mon_rssi_notify);
 
+void
+cfg80211_sta_mon_txrate_notify(struct net_device *dev, const u8 *peer,
+   enum nl80211_sta_mon_txrate_threshold_event txrate_event,
+   u32 txrate_level, gfp_t gfp)
+{
+   struct sk_buff *msg;
+
+   trace_cfg80211_sta_mon_txrate_notify(dev, peer, txrate_event,
+txrate_level);
+
+   if (WARN_ON(txrate_event !=
+   NL80211_STA_MON_TXRATE_THRESHOLD_EVENT_LOW &&
+   txrate_event !=
+   NL80211_STA_MON_TXRATE_THRESHOLD_EVENT_HIGH))
+   return;
+
+   msg = cfg80211_prepare_sta_mon(dev, peer, gfp);
+   if (!msg)
+   return;
+
+   if (nla_put_u32(msg, NL80211_ATTR_STA_MON_TXRATE_THRESHOLD_EVENT,
+   txrate_event))
+   goto nla_put_failure;
+
+   if (txrate_level && nla_put_u32(msg, NL80211_ATTR_STA_MON_TXRATE_LEVEL,
+   txrate_level))
+   goto nla_put_failure;
+
+   cfg80211_send_sta_mon(msg, gfp);
+
+   return;
+nla_put_failure:
+   nlmsg_free(msg);
+}
+EXPORT_SYMBOL(cfg80211_sta_mon_txrate_notify);
+
 static void nl80211_ch_switch_notify(struct cfg80211_registered_device *rdev,
 struct net_device *netdev,
 struct cfg80211_chan_def *chandef,
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index ca985c2..95f4a31 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -3355,6 +3355,31 @@
  WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer),
  __entry->low_txrate_thold, __entry->high_txrate_thold)
 );
+
+TRACE_EVENT(cfg80211_sta_mon_txrate_notify,
+   TP_PROTO(struct net_device *netdev, const u8 *peer,
+enum nl80211_sta_mon_txrate_threshold_event txrate_event,
+u32 txrate_level),
+   TP_ARGS(netdev, peer, txrate_event, txrate_level),
+   TP_STRUCT__entry(
+   NETDEV_ENTRY
+   MAC_ENTRY(peer)
+   __field(enum nl80211_sta_mon_txrate_threshold_event,
+   txrate_event)
+   __field(u32, txrate_level)
+   ),
+   TP_fast_assign(
+   NETDEV_ASSIGN;
+   MAC_ASSIGN(peer, peer);
+   __entry->txrate_event = txrate_event;
+   __entry->txrate_level = txrate_level;
+   ),
+   TP_printk(NETDEV_PR_FMT ", peer: " MAC_PR_FMT
+ ", tx_rate event: %d, txrate : %u",
+ NETDEV_PR_ARG, MAC_PR_ARG(peer),
+ __entry->txrate_event, __entry->txrate_level)
+);
+
 #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */
 
 #undef TRACE_INCLUDE_PATH
-- 
1.9.1



Re: pull-request: iwlwifi-next 2018-05-30

2018-05-30 Thread Kalle Valo
Luca Coelho  writes:

> Hi Kalle,
>
> This is the final batch of patches intended for v4.18.  As discussed,
> it is focused on bugfixes.  More details about the contents in the tag
> description.
>
> I have sent this out before and kbuildbot this morning, but I didn't
> get any replies from it yet.
>
> Please let me know if there are any issues.
>
> Cheers,
> Luca.
>
>
> The following changes since commit 06895b1627fe36f0bea49d4c9fd0e27f0f7498b1:
>
>   rtlwifi: remove duplicate code (2018-05-29 10:28:24 +0300)
>
> are available in the Git repository at:
>
>   git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-next.git 
> tags/iwlwifi-next-for-kalle-2018-05-30
>
> for you to fetch changes up to 506247825c5e877741f33a2c657d351e5c7943ba:
>
>   iwlwifi: fix non_shared_ant for 9000 devices (2018-05-30 10:05:12 +0300)
>
> 
> Final batch of iwlwifi patches for 4.18
>
> * Some bugzilla fixes;
> * Some kernel warning fixes;
> * Fix for an (ETSI) WMM limits bug;
> * Fix for a Bluetooth coexistence problem on 9000 devices;
> * Fix for an interoperability bug related to block-ack sessions;
>
> 

Pulled, thanks.

-- 
Kalle Valo


Re: [1/9] qtnfmac: remove unused function declarations

2018-05-30 Thread Kalle Valo
Sergey Matyukevich  wrote:

> From: Andrey Shevchenko 
> 
> Functions qtnf_cmd_resp_parse and qtnf_cmd_resp_check have
> been removed. Remove their declarations as well.
> 
> Signed-off-by: Andrey Shevchenko 

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

6d89265d7841 qtnfmac: remove unused function declarations
d62b622ca409 qtnfmac: simplify notation
36e8c538b374 qtnfmac: decode error codes from firmware replies
9a3beeb5b73a qtnfmac: cleanup wdev structure between its uses
9e33e7fb4772 qtnfmac: improve control path timeout handling
b60769e2dff0 qtnfmac: fix firmware command error path
f5d2ff43b9ed qtnfmac: fix bg_scan_period parameter processing
40d68dbb986d qtnfmac: cancel scan on disconnect
480daa9cb62c qtnfmac: fix invalid STA state on EAPOL failure

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

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



[PATCH V2 3/3] brcmfmac: add initial support for monitor mode interface

2018-05-30 Thread Rafał Miłecki
From: Rafał Miłecki 

Right now it's limited to firmwares that mark monitor interface packets
with a special flag. It's required to distinguish them from other
interface packets as firmware doesn't use any unique ifidx for monitor
interface.

In the future one may also add support for older firmwares without
support for proper packet flags. That will require limiting interface
combos to allow monitor mode *only* and adjusting condition in the
brcmf_msgbuf_process_rx_complete().

Signed-off-by: Rafał Miłecki 
---
 .../broadcom/brcm80211/brcmfmac/cfg80211.c | 107 +++--
 .../wireless/broadcom/brcm80211/brcmfmac/core.c|  65 -
 .../wireless/broadcom/brcm80211/brcmfmac/core.h|   2 +
 .../wireless/broadcom/brcm80211/brcmfmac/fwil.h|   2 +
 4 files changed, 168 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index f5b405c98047..bbb4f913eece 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -608,6 +609,82 @@ static bool brcmf_is_ibssmode(struct brcmf_cfg80211_vif 
*vif)
return vif->wdev.iftype == NL80211_IFTYPE_ADHOC;
 }
 
+/**
+ * brcmf_mon_add_vif() - create monitor mode virtual interface
+ *
+ * @wiphy: wiphy device of new interface.
+ * @name: name of the new interface.
+ */
+static struct wireless_dev *brcmf_mon_add_vif(struct wiphy *wiphy,
+ const char *name)
+{
+   struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+   struct brcmf_cfg80211_vif *vif;
+   struct net_device *ndev;
+   struct brcmf_if *ifp;
+   int err;
+
+   if (cfg->pub->mon_if) {
+   err = -EEXIST;
+   goto err_out;
+   }
+
+   vif = brcmf_alloc_vif(cfg, NL80211_IFTYPE_MONITOR);
+   if (IS_ERR(vif)) {
+   err = PTR_ERR(vif);
+   goto err_out;
+   }
+
+   ndev = alloc_netdev(sizeof(*ifp), name, NET_NAME_UNKNOWN, ether_setup);
+   if (!ndev) {
+   err = -ENOMEM;
+   goto err_free_vif;
+   }
+   ndev->type = ARPHRD_IEEE80211_RADIOTAP;
+   ndev->ieee80211_ptr = &vif->wdev;
+   ndev->needs_free_netdev = true;
+   ndev->priv_destructor = brcmf_cfg80211_free_netdev;
+   SET_NETDEV_DEV(ndev, wiphy_dev(cfg->wiphy));
+
+   ifp = netdev_priv(ndev);
+   ifp->vif = vif;
+   ifp->ndev = ndev;
+   ifp->drvr = cfg->pub;
+
+   vif->ifp = ifp;
+   vif->wdev.netdev = ndev;
+
+   err = brcmf_net_mon_attach(ifp);
+   if (err) {
+   brcmf_err("Failed to attach %s device\n", ndev->name);
+   free_netdev(ndev);
+   goto err_free_vif;
+   }
+
+   cfg->pub->mon_if = ifp;
+
+   return &vif->wdev;
+
+err_free_vif:
+   brcmf_free_vif(vif);
+err_out:
+   return ERR_PTR(err);
+}
+
+static int brcmf_mon_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev)
+{
+   struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+   struct net_device *ndev = wdev->netdev;
+
+   ndev->netdev_ops->ndo_stop(ndev);
+
+   brcmf_net_detach(ndev, true);
+
+   cfg->pub->mon_if = NULL;
+
+   return 0;
+}
+
 static struct wireless_dev *brcmf_cfg80211_add_iface(struct wiphy *wiphy,
 const char *name,
 unsigned char 
name_assign_type,
@@ -628,9 +705,10 @@ static struct wireless_dev 
*brcmf_cfg80211_add_iface(struct wiphy *wiphy,
case NL80211_IFTYPE_STATION:
case NL80211_IFTYPE_AP_VLAN:
case NL80211_IFTYPE_WDS:
-   case NL80211_IFTYPE_MONITOR:
case NL80211_IFTYPE_MESH_POINT:
return ERR_PTR(-EOPNOTSUPP);
+   case NL80211_IFTYPE_MONITOR:
+   return brcmf_mon_add_vif(wiphy, name);
case NL80211_IFTYPE_AP:
wdev = brcmf_ap_add_vif(wiphy, name, params);
break;
@@ -810,9 +888,10 @@ int brcmf_cfg80211_del_iface(struct wiphy *wiphy, struct 
wireless_dev *wdev)
case NL80211_IFTYPE_STATION:
case NL80211_IFTYPE_AP_VLAN:
case NL80211_IFTYPE_WDS:
-   case NL80211_IFTYPE_MONITOR:
case NL80211_IFTYPE_MESH_POINT:
return -EOPNOTSUPP;
+   case NL80211_IFTYPE_MONITOR:
+   return brcmf_mon_del_vif(wiphy, wdev);
case NL80211_IFTYPE_AP:
return brcmf_cfg80211_del_ap_iface(wiphy, wdev);
case NL80211_IFTYPE_P2P_CLIENT:
@@ -6339,9 +6418,10 @@ static int brcmf_setup_ifmodes(struct wiphy *wiphy, 
struct brcmf_if *ifp)
struct ieee80211_iface_limit *c0_limits = NULL;
struct ieee80211_iface_limit *p2p_limits = NULL;
struct ieee80211_iface_limit *mbss_lim

[PATCH V2 2/3] brcmfmac: handle monitor mode marked msgbuf packets

2018-05-30 Thread Rafał Miłecki
From: Rafał Miłecki 

New Broadcom firmwares mark monitor mode packets using a newly defined
bit in the flags field. Use it to filter them out and pass to the
monitor interface. These defines were found in bcmmsgbuf.h from SDK.

As not every firmware generates radiotap header this commit introduces
BRCMF_FEAT_MON_FMT_RADIOTAP that has to be set per firmware version. If
not present brcmf_netif_mon_rx() assumed packet being a raw 802.11 frame
and prepends it with an empty radiotap header.

It's limited to the msgbuf protocol. Adding support for SDIO/USB devices
will require some extra research.

Signed-off-by: Rafał Miłecki 
---
V2: Use cpu_to_le16 when setting it_len
---
 .../wireless/broadcom/brcm80211/brcmfmac/core.c| 24 ++
 .../wireless/broadcom/brcm80211/brcmfmac/core.h|  2 ++
 .../wireless/broadcom/brcm80211/brcmfmac/feature.h |  6 +-
 .../wireless/broadcom/brcm80211/brcmfmac/msgbuf.c  | 17 +++
 4 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 72954fd6df3b..c9e1f6fcc57b 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -404,6 +405,29 @@ void brcmf_netif_rx(struct brcmf_if *ifp, struct sk_buff 
*skb)
netif_rx_ni(skb);
 }
 
+void brcmf_netif_mon_rx(struct brcmf_if *ifp, struct sk_buff *skb)
+{
+   if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MON_FMT_RADIOTAP)) {
+   /* Do nothing */
+   } else {
+   struct ieee80211_radiotap_header *radiotap;
+
+   radiotap = skb_push(skb, sizeof(*radiotap));
+   memset(radiotap, 0, sizeof(*radiotap));
+   radiotap->it_len = cpu_to_le16(sizeof(*radiotap));
+
+   /* TODO: what are these extra 4 bytes? */
+   skb->len -= 4;
+   }
+
+   skb->dev = ifp->ndev;
+   skb_reset_mac_header(skb);
+   skb->pkt_type = PACKET_OTHERHOST;
+   skb->protocol = htons(ETH_P_802_2);
+
+   brcmf_netif_rx(ifp, skb);
+}
+
 static int brcmf_rx_hdrpull(struct brcmf_pub *drvr, struct sk_buff *skb,
struct brcmf_if **ifp)
 {
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
index 401f50458686..dcf6e27cc16f 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
@@ -121,6 +121,7 @@ struct brcmf_pub {
 
struct brcmf_if *iflist[BRCMF_MAX_IFS];
s32 if2bss[BRCMF_MAX_IFS];
+   struct brcmf_if *mon_if;
 
struct mutex proto_block;
unsigned char proto_buf[BRCMF_DCMD_MAXLEN];
@@ -216,6 +217,7 @@ void brcmf_txflowblock_if(struct brcmf_if *ifp,
  enum brcmf_netif_stop_reason reason, bool state);
 void brcmf_txfinalize(struct brcmf_if *ifp, struct sk_buff *txp, bool success);
 void brcmf_netif_rx(struct brcmf_if *ifp, struct sk_buff *skb);
+void brcmf_netif_mon_rx(struct brcmf_if *ifp, struct sk_buff *skb);
 void brcmf_net_setcarrier(struct brcmf_if *ifp, bool on);
 int __init brcmf_core_init(void);
 void __exit brcmf_core_exit(void);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
index d1193825e559..6e417d104b7f 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
@@ -33,6 +33,8 @@
  * MFP: 802.11w Management Frame Protection.
  * GSCAN: enhanced scan offload feature.
  * FWSUP: Firmware supplicant.
+ * MON_802_11_FLAG: monitor packets flagged as 802.11
+ * MON_FMT_RADIOTAP: monitor packets include radiotap header
  */
 #define BRCMF_FEAT_LIST \
BRCMF_FEAT_DEF(MBSS) \
@@ -48,7 +50,9 @@
BRCMF_FEAT_DEF(WOWL_ARP_ND) \
BRCMF_FEAT_DEF(MFP) \
BRCMF_FEAT_DEF(GSCAN) \
-   BRCMF_FEAT_DEF(FWSUP)
+   BRCMF_FEAT_DEF(FWSUP) \
+   BRCMF_FEAT_DEF(MON_802_11_FLAG) \
+   BRCMF_FEAT_DEF(MON_FMT_RADIOTAP)
 
 /*
  * Quirks:
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
index 49d37ad96958..47a9318cccb8 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
@@ -69,6 +69,8 @@
 #define BRCMF_MSGBUF_MAX_EVENTBUF_POST 8
 
 #define BRCMF_MSGBUF_PKT_FLAGS_FRAME_802_3 0x01
+#define BRCMF_MSGBUF_PKT_FLAGS_FRAME_802_110x02
+#define BRCMF_MSGBUF_PKT_FLAGS_FRAME_MASK  0x07
 #define BRCMF_MSGBUF_PKT_FLAGS_PRIO_SHIFT  5
 
 #define BRCMF_MSGBUF_TX_FLUSH_CNT1 32
@@ -1128,6 +1130,7 @@ brcmf_msgbuf_process_rx_complete(stru

[PATCH V2 1/3] brcmfmac: allow specifying features per firmware version

2018-05-30 Thread Rafał Miłecki
From: Rafał Miłecki 

Some features supported by firmware aren't advertised and there is no
way for a driver to query them. This includes e.g. monitor mode details.
Some firmwares support tagging monitor frames, some build radiotap
header but there is no way to detect it. Such features often depend on
used firmware compilation options.

This commit adds table that will allow specifying features like:
{ "01-abcdef01", BIT(BRCMF_FEAT_FOO) }

Signed-off-by: Rafał Miłecki 
---
V2: Rename struct field to "feat_flags"
Rename function to the brcmf_feat_firmware_overrides()
Print enabled features
Rename variable to "drv"
Update commit message body (mention compilation time options)
---
 .../wireless/broadcom/brcm80211/brcmfmac/feature.c | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
index 800a423c7bc2..2712bfcb2864 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
@@ -91,6 +91,38 @@ static int brcmf_feat_debugfs_read(struct seq_file *seq, 
void *data)
 }
 #endif /* DEBUG */
 
+struct brcmf_feat_fwfeat {
+   const char * const fwid;
+   u32 feat_flags;
+};
+
+static const struct brcmf_feat_fwfeat brcmf_feat_fwfeat_map[] = {
+};
+
+static void brcmf_feat_firmware_overrides(struct brcmf_pub *drv)
+{
+   const struct brcmf_feat_fwfeat *e;
+   u32 feat_flags = 0;
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(brcmf_feat_fwfeat_map); i++) {
+   e = &brcmf_feat_fwfeat_map[i];
+   if (!strcmp(e->fwid, drv->fwver)) {
+   feat_flags = e->feat_flags;
+   break;
+   }
+   }
+
+   if (!feat_flags)
+   return;
+
+   for (i = 0; i < BRCMF_FEAT_LAST; i++)
+   if (feat_flags & BIT(i))
+   brcmf_dbg(INFO, "enabling firmware feature: %s\n",
+ brcmf_feat_names[i]);
+   drv->feat_flags |= feat_flags;
+}
+
 /**
  * brcmf_feat_iovar_int_get() - determine feature through iovar query.
  *
@@ -251,6 +283,8 @@ void brcmf_feat_attach(struct brcmf_pub *drvr)
}
brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_FWSUP, "sup_wpa");
 
+   brcmf_feat_firmware_overrides(drvr);
+
/* set chip related quirks */
switch (drvr->bus_if->chip) {
case BRCM_CC_43236_CHIP_ID:
-- 
2.13.6



Re: [PATCH V2 2/3] brcmfmac: handle monitor mode marked msgbuf packets

2018-05-30 Thread Arend van Spriel

On 5/30/2018 10:13 PM, Rafał Miłecki wrote:

From: Rafał Miłecki 

New Broadcom firmwares mark monitor mode packets using a newly defined
bit in the flags field. Use it to filter them out and pass to the
monitor interface. These defines were found in bcmmsgbuf.h from SDK.

As not every firmware generates radiotap header this commit introduces
BRCMF_FEAT_MON_FMT_RADIOTAP that has to be set per firmware version. If
not present brcmf_netif_mon_rx() assumed packet being a raw 802.11 frame
and prepends it with an empty radiotap header.

It's limited to the msgbuf protocol. Adding support for SDIO/USB devices
will require some extra research.


No just extra research but actual firmware change.


Signed-off-by: Rafał Miłecki 
---
V2: Use cpu_to_le16 when setting it_len
---
  .../wireless/broadcom/brcm80211/brcmfmac/core.c| 24 ++
  .../wireless/broadcom/brcm80211/brcmfmac/core.h|  2 ++
  .../wireless/broadcom/brcm80211/brcmfmac/feature.h |  6 +-
  .../wireless/broadcom/brcm80211/brcmfmac/msgbuf.c  | 17 +++
  4 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 72954fd6df3b..c9e1f6fcc57b 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -21,6 +21,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -404,6 +405,29 @@ void brcmf_netif_rx(struct brcmf_if *ifp, struct sk_buff 
*skb)
netif_rx_ni(skb);
  }

+void brcmf_netif_mon_rx(struct brcmf_if *ifp, struct sk_buff *skb)
+{
+   if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MON_FMT_RADIOTAP)) {
+   /* Do nothing */
+   } else {
+   struct ieee80211_radiotap_header *radiotap;
+
+   radiotap = skb_push(skb, sizeof(*radiotap));
+   memset(radiotap, 0, sizeof(*radiotap));
+   radiotap->it_len = cpu_to_le16(sizeof(*radiotap));
+
+   /* TODO: what are these extra 4 bytes? */
+   skb->len -= 4;


This could be dongle memory location holding receive status needed to 
build radiotap header on the host. Will look into this.



+   }


[snip]


diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
index d1193825e559..6e417d104b7f 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
@@ -33,6 +33,8 @@
   * MFP: 802.11w Management Frame Protection.
   * GSCAN: enhanced scan offload feature.
   * FWSUP: Firmware supplicant.
+ * MON_802_11_FLAG: monitor packets flagged as 802.11
+ * MON_FMT_RADIOTAP: monitor packets include radiotap header
   */
  #define BRCMF_FEAT_LIST \
BRCMF_FEAT_DEF(MBSS) \
@@ -48,7 +50,9 @@
BRCMF_FEAT_DEF(WOWL_ARP_ND) \
BRCMF_FEAT_DEF(MFP) \
BRCMF_FEAT_DEF(GSCAN) \
-   BRCMF_FEAT_DEF(FWSUP)
+   BRCMF_FEAT_DEF(FWSUP) \
+   BRCMF_FEAT_DEF(MON_802_11_FLAG) \


On branch I created for 4366c0 release firmware includes 'monitor' in 
the 'cap' iovar.



+   BRCMF_FEAT_DEF(MON_FMT_RADIOTAP)


I intend to add this to the 'cap' iovar as well for 4366c0 release if I 
get green light for it. Either 'rtap' or just 'radiotap'.


As it turns out the 'cap' iovar returns worst case (or best if you are a 
sucker for features) a string of 566 characters, but brcmfmac uses 512 
bytes right now. Better increase that to 768 or so.


Regards,
Arend


Re: [RFT 6/6] wlcore: Use generic runtime pm calls for wowlan elp configuration

2018-05-30 Thread Tony Lindgren
* Reizer, Eyal  [180530 06:37]:
> > > >
> > > > With runtime PM enabled, we can now use generic calls to
> > > > pm_generic_runtime_suspend and pm_generic_runtime_resume for
> > enabling elp
> > > > during suspend when wowlan is enabled and waking the chip from elp
> > > > on resume.
> > >
> > > Sry, but not sure you can :(
> > >
> > > These functions are not used by drivers directly because system suspend
> > > are not synchronized with PM runtime, so if you call
> > pm_generic_runtime_suspend()
> > > and, at the same time, there is pm_runtime_get_() in progress --> race ...
> > >
> > > The pm_runtime_force_() APIs have to be used, or
> > > PM runtime drivers functions can be called directly, but only if it 
> > > possible to
> > be
> > > sure no other PM runtime calls active which is usually true at
> > suspend_noirq stage.
> > 
> > Oh right, those are subsystem calls. Seems like
> > pm_runtime_force_suspend/resume() should work here,
> > Eyal?
> > 
> 
> Oh, nice, wasn't aware of the pm_runtime_force_() calls.
> For some reason they are not documented in:
> https://www.kernel.org/doc/Documentation/power/runtime_pm.txt
> Perhaps they should be?

Sure why not submit a patch for that.

> Anyway I have tried them instead of pm_generic_runtime_() and they seem
> To work fine on my platform.
> Will test some more and submit a v2.

OK I'll your pick v2 into my series.

Regards,

Tony


Re: [PATCH 13/14] rtlwifi: access skb->data to get C2H data by macro

2018-05-30 Thread Pkshih
On Tue, 2018-05-29 at 08:18 +0300, Kalle Valo wrote:
>  writes:
> 
> > From: Ping-Ke Shih 
> >
> > The format of C2H data is ID(1 byte) + Length(1 byte) + value, and it is
> > more readable to use macros to access C2H data.
> >
> > Signed-off-by: Ping-Ke Shih 
> 
> [...]
> 
> > --- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
> > +++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
> > @@ -177,6 +177,11 @@ enum rtl_c2h_evt_v2 {
> >     C2H_V2_CCX_RPT = 0x0F,
> >  };
> >  
> > +#define GET_C2H_CMD_ID(c2h)({u8 *__c2h = c2h; __c2h[0]; })
> > +#define GET_C2H_SEQ(c2h)   ({u8 *__c2h = c2h; __c2h[1]; })
> > +#define C2H_DATA_OFFSET2
> > +#define GET_C2H_DATA_PTR(c2h)  ({u8 *__c2h = c2h; 
> > &__c2h[C2H_DATA_OFFSET]; })
> 
> These macros are not really pretty, a proper static inline function
> would be a much better choise. But I'm planning to apply this patch
> anyway, I don't think it's a blocker but a good idea to cleanup later.
> 
> And rtlwifi really should get away with this foo[0] and foo[1] style of
> buffers and switch to proper structs (foo->bar and foo->koo).

Thanks for your review and suggestion.

Because C2H data is little endian order, the struct will look like
struct foo {
#ifdef __LITTLE_ENDIAN
u8 bar:4;
u8 koo:4;
#else
u8 koo:4;
u8 bar:4;
#endif
}

Is this a linux convention?

Regards
PK



Re: [PATCH v4 0/9] rtlwifi: btcoex: Add 8822b btcoex support

2018-05-30 Thread Pkshih
On Fri, 2018-04-13 at 14:16 +0800, pks...@realtek.com wrote:
> From: Ping-Ke Shih 
> 
> v4: swap the order of patch 4/9 and 5/9, because kbuild test robot reports
> undefined reference. No source code change.
> v3: forget to CC wireless mailing list, so resend again. No any change.
> v2: fix misspelling and boolean expression in patch 1/9
> 
> Patches 1-2 are revised by patches 12 of previous patchset. 8822b coex
> files are split into two patches, and I remove some comments and apply
> 'static const' to version related variables.
> Patches 3-4 aren't changed. (identical to patches 13-15 of previous patchset)
> Patches 6-7 remove comments and apply 'static const' to existing files.
> Patches 8-9 remove global variables, and use local variables instead.
> 
> Ping-Ke Shih (9):
>   rtlwifi: btcoex: Add 8822b1ant coex files
>   rtlwifi: btcoex: Add 8822b2ant coex files
>   rtlwifi: btcoex: Add 8822b header files to precomp.h
>   rtlwifi: btcoex: Add 8822b to Makefile
>   rtlwifi: btcoex: Add 8822b routine to btc interfaces
>   rtlwifi: btcoex: remove comments that are not meaningful
>   rtlwifi: btcoex: Add modifier const to version related variables
>   rtlwifi: btcoex: Add struct members to replace global varaibles
>   rtlwifi: btcoex: Remove global variables of chip specific context
> 

Hi Kalle,

I would like to send v5 to change the order of this patchset like:
  rtlwifi: btcoex: remove comments that are not meaningful
  rtlwifi: btcoex: Add modifier const to version related variables
  rtlwifi: btcoex: Add struct members to replace global varaibles
  rtlwifi: btcoex: Remove global variables of chip specific context

  rtlwifi: btcoex: Add 8822b1ant coex files
  rtlwifi: btcoex: Add 8822b2ant coex files
  rtlwifi: btcoex: Add 8822b header files to precomp.h
  rtlwifi: btcoex: Add 8822b to Makefile
  rtlwifi: btcoex: Add 8822b routine to btc interfaces

Then, you can review patches 1/9 - 4/9 that refine btcoex, and
the remaining 8822b's btcoex can review later.
Does it work for you?

Thanks
PK


Re: [PATCH 1/2] cfg80211: last ack singal support in station dump

2018-05-30 Thread Balaji Pothunoori

On 2018-05-27 15:18, kbuild test robot wrote:

Hi Balaji,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mac80211-next/master]
[cannot apply to v4.17-rc6]
[if your patch is applied to the wrong git tree, please drop us a note
to help improve the system]

url:
https://github.com/0day-ci/linux/commits/Balaji-Pothunoori/cfg80211-mac80211-last-ack-singal-support-in-station-dump/20180527-162750
base:
https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git
master
config: x86_64-randconfig-x000-201821 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64

Note: the
linux-review/Balaji-Pothunoori/cfg80211-mac80211-last-ack-singal-support-in-station-dump/20180527-162750
HEAD 7d4f99704af356d198be9638b571119647e26397 builds fine.
  It only hurts bisectibility.

All errors (new ones prefixed by >>):

   In file included from include/linux/kernel.h:11:0,
from include/linux/list.h:9,
from include/linux/module.h:9,
from net//mac80211/sta_info.c:13:
   net//mac80211/sta_info.c: In function 'sta_set_sinfo':
net//mac80211/sta_info.c:2314:32: error: 
'NL80211_STA_INFO_DATA_ACK_SIGNAL_AVG' undeclared (first use in this 
function); did you mean 'NL80211_STA_INFO_ACK_SIGNAL_AVG'?


Yes, It is "NL80211_STA_INFO_ACK_SIGNAL_AVG" and i could see this patch 
is building on top of https://patchwork.kernel.org/patch/10343163/ which 
is incorrect.
This patch has to build with its subsequent patch 
https://patchwork.kernel.org/patch/10426699/



 !(sinfo->filled & 
BIT_ULL(NL80211_STA_INFO_DATA_ACK_SIGNAL_AVG))) {

   ^
   include/linux/bitops.h:8:32: note: in definition of macro 'BIT_ULL'
#define BIT_ULL(nr)  (1ULL << (nr))
   ^~
   net//mac80211/sta_info.c:2314:32: note: each undeclared identifier
is reported only once for each function it appears in
 !(sinfo->filled & 
BIT_ULL(NL80211_STA_INFO_DATA_ACK_SIGNAL_AVG))) {

   ^
   include/linux/bitops.h:8:32: note: in definition of macro 'BIT_ULL'
#define BIT_ULL(nr)  (1ULL << (nr))
   ^~

vim +2314 net//mac80211/sta_info.c

c9c5962b5 Johannes Berg2016-03-31  2081
0fdf1493b Johannes Berg2018-05-18  2082  void
sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
0fdf1493b Johannes Berg2018-05-18  2083  		   bool 
tidstats)

b7ffbd7ef Johannes Berg2014-06-04  2084  {
b7ffbd7ef Johannes Berg2014-06-04  2085 struct
ieee80211_sub_if_data *sdata = sta->sdata;
b7ffbd7ef Johannes Berg2014-06-04  2086 struct
ieee80211_local *local = sdata->local;
b7ffbd7ef Johannes Berg2014-06-04  2087 u32 thr = 0;
c9c5962b5 Johannes Berg2016-03-31  2088 int i, ac, cpu;
c9c5962b5 Johannes Berg2016-03-31  2089 struct
ieee80211_sta_rx_stats *last_rxstats;
c9c5962b5 Johannes Berg2016-03-31  2090
c9c5962b5 Johannes Berg2016-03-31  2091 last_rxstats =
sta_get_last_rx_stats(sta);
b7ffbd7ef Johannes Berg2014-06-04  2092
b7ffbd7ef Johannes Berg2014-06-04  2093
sinfo->generation = sdata->local->sta_generation;
b7ffbd7ef Johannes Berg2014-06-04  2094
225b81898 Johannes Berg2015-01-21  2095 /* do before
driver, so beacon filtering drivers have a
225b81898 Johannes Berg2015-01-21  2096  * chance to
e.g. just add the number of filtered beacons
225b81898 Johannes Berg2015-01-21  2097  * (or just
modify the value entirely, of course)
225b81898 Johannes Berg2015-01-21  2098  */
225b81898 Johannes Berg2015-01-21  2099 if
(sdata->vif.type == NL80211_IFTYPE_STATION)
225b81898 Johannes Berg2015-01-21  2100
sinfo->rx_beacon = sdata->u.mgd.count_beacon_signal;
225b81898 Johannes Berg2015-01-21  2101
2b9a7e1ba Johannes Berg2014-11-17  2102
drv_sta_statistics(local, sdata, &sta->sta, sinfo);
2b9a7e1ba Johannes Berg2014-11-17  2103
319090bf6 Johannes Berg2014-11-17  2104 sinfo->filled |=
BIT(NL80211_STA_INFO_INACTIVE_TIME) |
319090bf6 Johannes Berg2014-11-17  2105 
BIT(NL80211_STA_INFO_STA_FLAGS) |
319090bf6 Johannes Berg2014-11-17  2106 
BIT(NL80211_STA_INFO_BSS_PARAM) |
319090bf6 Johannes Berg2014-11-17  2107 
BIT(NL80211_STA_INFO_CONNECTED_TIME) |
976bd9efd Johannes Berg2015-10-16  2108 
BIT(NL80211_STA_INFO_RX_DROP_MISC);
976bd9efd Johannes Berg2015-10-16  2109
976bd9efd Johannes Berg2015-10-16  2110 if
(sdata->vif.type == NL80211_IFTYPE_STATION) {
97

Re: iwlwifi: regression due to: allow different csr flags for different device families

2018-05-30 Thread Luca Coelho
On Sun, 2018-05-27 at 14:08 +0200, Alexander Wetzel wrote:
> > From: Golan Ben Ami 
> > 
> > Different device families may have different flag values
> > for passing a message to the fw (i.e. SW_RESET).
> > In order to keep the code readable, and avoid conditioning
> > upon the family, store a value for each flag, which indicates
> > the bit that needs to be enabled.
> > 
> > Signed-off-by: Golan Ben Ami 
> > Signed-off-by: Luca Coelho 
> 
> This patch generates a Null pointer exception for my Ultimate-N 6300
> card when loading the driver, making the card unusable.
> (Bisecting linked it to commit
> a8cbb46f831d2c101feccdd0e0daf3627b8c1dca.)
> 
> Sine the commit could not be simply reverted I applied this commit to
> my
> distribution kernel - basically 4.16.12 - and can confirm it is
> indeed
> causing the issue.

It seems that I forgot to reply to this, even though we looked into it
and provided a fix[1].  This fix will hopefully be included in 4.17
final.

Thanks a lot for reporting and bisecting!

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

--
Cheers,
Luca.