Re: Representative Needed.

2018-04-20 Thread PPMC OFFSHORE
Good day,

  I am seeking your concept with great gratitude to present you as a 
representative to carry out business transactions with a reasonable share upon 
your interest and cooperation to work with us in trust. If interested please 
get back.

Regards
Kingsley

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



Re: [PATCH v2] rtlwifi: cleanup 8723be ant_sel definition

2018-04-20 Thread Larry Finger

On 04/20/2018 07:01 AM, Kalle Valo wrote:

 writes:


From: Ping-Ke Shih 

The module parameter ant_sel is used to control antenna number and path.
There is an existing enum ANT_{X2,X1} defined the antenna number, so
add a new enum ANT_{MAIN,AUX} to make it readable. After this work,
incorrect given values depend on ant_sel were exposed, so refill values
according following definition:
   ant_sel   ant_num   ant_path  print_label
  1  ANT_X1ANT_AUX#2
  2  ANT_X2ANT_MAIN   #1
Then, a workaround resulted from the incorrect values in halbtcoutsrc.c was
removed. These is a existing bug in the workaround while ant_sel=2, but the
case is rare use so user is hard to observe this bug.

The experimental results with single antenna connected to specific path
are in following:
   ant_sel  ANT_MAIN(#1)  ANT_AUX(#2)
  0-8-62
  1-62   -10
  2-6-60

Signed-off-by: Ping-Ke Shih 
Cc: Stable  # 4.7+
Reviewed-by: Larry Finger 
---
v2: Add more description about fixed bugs in end of first paragraph.


Sorry, I still don't understand the bug you are fixing. It shouldn't
take more than one minute to understand a commit log.

I prose that you rewrite the commit log, or at least parts of if it.
When you are describing a bug don't talk about enums or source files,
that's an implementation detail, and instead talk how the bug looks like
from users point of view. For example:

   "On HP laptop model 1234 with Realtex 4321 device users are supposed
to use ant_sel module parameter with value 77 to use the correct
antenna. But instead rtlwifi incorrectly chose antenna 88 with lower
transmit power and that caused packet loss. Fix it so that the user
gets better transmit power and..."

(that's of course all made up information as I don't know what the
actual bug is)

And after that you can write rtlwifi internals in the commit log as much
as you want :) But there needs to be a clear generic description of the
bug first and it needs to understandable in one read.

To make this faster I propose that you send the new commit log as a
reply to this mail and I can then comment faster.


Kalle,

As I have some responsibility in creating this mess, let me try to write a new 
commit log. I hope this answers your questions.


Thanks,

Larry



Some HP laptops have only a single wifi antenna. This would not be a problem 
except that they were shipped with an incorrectly encoded EFUSE. It should have 
been possible to open the computer and transfer the antenna connection to the 
other terminal except that such action might void the warranty, and moving the 
antenna broke the Windows driver. The fix was to add a module option that would 
override the EFUSE encoding. That was done with commit c18d8f509571 ("rtlwifi: 
rtl8723be: Add antenna select module parameter"). There was still a problem with 
Bluetooth coexistence, which was addressed with commit baa170229095 ("rtlwifi: 
btcoexist: Implement antenna selection"). There were still problems, thus there 
were commit 0ff78adeef11 ("rtlwifi: rtl8723be: fix ant_sel code") and commit 
6d6226928369 ("rtlwifi: btcoexist: Fix antenna selection code"). Despite all 
these attempts at fixing the problem, the code is not yet right. A proper fix is 
important as there are now instances of laptops having RTL8723DE chips with the 
same problem.


The module parameter ant_sel is used to control antenna number and path.
At present enum ANT_{X2,X1} is used to define the antenna number, but this 
choice is not intuitive, thus change to a new enum ANT_{MAIN,AUX} to make it 
more readable. This change showed examples where incorrect values were used. It 
was also possible to remove a workaround in halbtcoutsrc.c.


The experimental results with single antenna connected to specific path
are now as follows:
  ant_sel  ANT_MAIN(#1)  ANT_AUX(#2)
 0-8-62
 1-62   -10
 2-6-60

Signed-off-by: Ping-Ke Shih 
Fixes: c18d8f509571 ("rtlwifi: rtl8723be: Add antenna select module parameter")
Fixes: baa170229095 ("rtlwifi: btcoexist: Implement antenna selection")
Fixes: 0ff78adeef11 ("rtlwifi: rtl8723be: fix ant_sel code")
Fixes: 6d6226928369 ("rtlwifi: btcoexist: Fix antenna selection code")
Cc: Stable  # 4.7+
Reviewed-by: Larry Finger 





Re: [PATCH 2/2] ath10k: search DT for qcom, ath10k-calibration-variant

2018-04-20 Thread Christian Lamparter
On Donnerstag, 19. April 2018 16:56:36 CEST Kalle Valo wrote:
> [...]
> I have added them now, please check:
> 
> https://github.com/kvalo/ath10k-firmware/commit/a47bcf1e58c4d8914af0951a80fd8861368b700d
Yes, The RT-AC58U is now working much better. 

The updated RT-AC58U board-data is here:


Regards
Christian




Re: [PATCH 8/9] mac80211: Support adding duration for prepare_tx() callback

2018-04-20 Thread Peter Oh

where is the 9th patch gone?


On 04/20/2018 03:49 AM, Luca Coelho wrote:

From: Ilan Peer 

There are specific cases, such as SAE authentication exchange, that
might require long duration to complete. For such cases, add support
for indicating to the driver the required duration of the prepare_tx()
operation, so the driver would still be able to complete the frame
exchange.

Currently, indicate the duration only for SAE authentication exchange,
as SAE authentication can take up to 2000 msec (as defined in IEEE
P802.11-REVmd D1.0 p. 3504).

As the patch modified the prepare_tx() callback API, also modify
the relevant code in iwlwifi.

Signed-off-by: Ilan Peer 
Signed-off-by: Luca Coelho 
---
  drivers/net/wireless/ath/ath9k/main.c |  3 ++-
  .../net/wireless/intel/iwlwifi/mvm/mac80211.c |  6 -
  include/net/mac80211.h|  5 +++-
  net/mac80211/driver-ops.h |  8 +++---
  net/mac80211/mlme.c   | 17 -
  net/mac80211/trace.h  | 25 ---
  6 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/main.c 
b/drivers/net/wireless/ath/ath9k/main.c
index a3be8add56e1..b6663c80e7dd 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -2544,7 +2544,8 @@ static void ath9k_unassign_vif_chanctx(struct 
ieee80211_hw *hw,
  }
  
  static void ath9k_mgd_prepare_tx(struct ieee80211_hw *hw,

-struct ieee80211_vif *vif)
+struct ieee80211_vif *vif,
+u16 duration)
  {
struct ath_softc *sc = hw->priv;
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index 51b30424575b..4e428427d1ba 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -2810,7 +2810,8 @@ static int iwl_mvm_mac_conf_tx(struct ieee80211_hw *hw,
  }
  
  static void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw,

- struct ieee80211_vif *vif)
+  struct ieee80211_vif *vif,
+  u16 req_duration)
  {
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
u32 duration = IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS;
@@ -2823,6 +2824,9 @@ static void iwl_mvm_mac_mgd_prepare_tx(struct 
ieee80211_hw *hw,
if (iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PREPARE_TX))
return;
  
+	if (req_duration > duration)

+   duration = req_duration;
+
mutex_lock(>mutex);
/* Try really hard to protect the session and hear a beacon */
iwl_mvm_protect_session(mvm, vif, duration, min_duration, 500, false);
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 52f36c43f35f..cde1db0f6573 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -3378,6 +3378,8 @@ enum ieee80211_reconfig_type {
   *frame in case that no beacon was heard from the AP/P2P GO.
   *The callback will be called before each transmission and upon return
   *mac80211 will transmit the frame right away.
+ *  If duration is greater than zero, mac80211 hints to the driver the
+ *  duration for which the operation is requested.
   *The callback is optional and can (should!) sleep.
   *
   * @mgd_protect_tdls_discover: Protect a TDLS discovery session. After sending
@@ -3697,7 +3699,8 @@ struct ieee80211_ops {
  u32 sset, u8 *data);
  
  	void	(*mgd_prepare_tx)(struct ieee80211_hw *hw,

- struct ieee80211_vif *vif);
+ struct ieee80211_vif *vif,
+ u16 duration);
  
  	void	(*mgd_protect_tdls_discover)(struct ieee80211_hw *hw,

 struct ieee80211_vif *vif);
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index 4d82fe7d627c..8f6998091d26 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -2,6 +2,7 @@
  /*
  * Portions of this file
  * Copyright(c) 2016 Intel Deutschland GmbH
+* Copyright (C) 2018 Intel Corporation
  */
  
  #ifndef __MAC80211_DRIVER_OPS

@@ -813,7 +814,8 @@ drv_allow_buffered_frames(struct ieee80211_local *local,
  }
  
  static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,

- struct ieee80211_sub_if_data *sdata)
+ struct ieee80211_sub_if_data *sdata,
+ u16 duration)
  {
might_sleep();
  
@@ -821,9 +823,9 @@ static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,


Re: [PATCH 9/9] brcmfmac: use request_firmware_nowait2 to load firmware without warnings

2018-04-20 Thread Andres Rodriguez



On 2018-04-20 06:26 AM, Kalle Valo wrote:

Andres Rodriguez  writes:


This reduces the unnecessary spew when trying to load optional firmware:
"Direct firmware load for ... failed with error -2"

Signed-off-by: Andres Rodriguez 
---
  drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c | 7 ---
  1 file changed, 4 insertions(+), 3 deletions(-)


With wireless patches always CC linux-wireless list, please. Adding it
now.


diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
index 091b52979e03..26db3ebd52dc 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
@@ -503,8 +503,9 @@ static void brcmf_fw_request_code_done(const struct 
firmware *fw, void *ctx)
goto done;
  
  	fwctx->code = fw;

-   ret = request_firmware_nowait(THIS_MODULE, true, fwctx->nvram_name,
- fwctx->dev, GFP_KERNEL, fwctx,
+   ret = request_firmware_nowait(THIS_MODULE, true, false,


A perfect example why enums should be in function calls instead of
booleans, that "true, false" tells nothing to me and it would be time
consuming to check from headers files what it means. If you had proper
enums, for example "FIRMWARE_MODE_FOO, FIRMWARE_STATE_BAR", it would be
immediately obvious for the reader what the parameters are. Of course
the first boolean was already there before, but maybe change the new
boolean to an enum >


Anyone else got any feedback before I re-spin the _nowait() API. I'm on 
board for the boolean->enum change.




+ fwctx->nvram_name, fwctx->dev,
+ GFP_KERNEL, fwctx,
  brcmf_fw_request_nvram_done);
  
  	/* pass NULL to nvram callback for bcm47xx fallback */

@@ -547,7 +548,7 @@ int brcmf_fw_get_firmwares_pcie(struct device *dev, u16 
flags,
fwctx->domain_nr = domain_nr;
fwctx->bus_nr = bus_nr;
  
-	return request_firmware_nowait(THIS_MODULE, true, code, dev,

+   return request_firmware_nowait2(THIS_MODULE, true, false, code, dev,
   GFP_KERNEL, fwctx,
   brcmf_fw_request_code_done);
  }


Also the number two in the function name is not really telling anything.
I think that something like request_firmware_nowait_nowarn() would be
better, even if it's so ugly.



The 2 is meant to signify that this is an new version of the api with 
different parameters. I don't think we need to codify into the name what 
the new parameters mean (mostly because when a 2 version of an api is 
implemented, usage of the original version tends to be discouraged).


If we go for something like _nowait_nowarn(), then we would need to drop 
the warn parameter altogether.


Another alternative, drop both bool warn and bool uevent and expose take 
in enum fw_opt directly.


Any thought on exposing the enum directly Luis for _nowait(). I know you 
mentioned this was for some reason decided against for the rest of the API.


Regards,
Andres


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

2018-04-20 Thread Mark Greer
On Fri, Apr 20, 2018 at 03:39:46PM +0300, Andy Shevchenko wrote:
> On Wed, 2018-04-18 at 15:35 +0530, Amit Pundir wrote:
> 
> > if (skb->data[transaction->aid_len + 2] !=
> > -   NFC_EVT_TRANSACTION_PARAMS_TAG)
> > +   NFC_EVT_TRANSACTION_PARAMS_TAG ||
> > +   skb->len < transaction->aid_len + transaction-
> > >params_len + 4) {
> 
> > +   devm_kfree(dev, transaction);
> 
> Oh, no.
> 
> This is not memory leak per se, this is bad choice of devm_ API where it
> should use plain kmalloc() / kfree().

Also, there is no check to see if the allocation worked at all.

Mark
--


[PATCH v1 1/1] ath10k: convert kmemdup to dma_alloc_coherent

2018-04-20 Thread Jared Bents
Update to convert the use of kmemdup to dma_alloc_coherent as
dma_alloc_coherent will consider DMA region limits such as
those seen with CONFIG_FSL_PCI && CONFIG_ZONE_DMA32 whereas
kmemdup does not take those limitations into account.

Signed-off-by: Jared Bents 
---
 drivers/net/wireless/ath/ath10k/pci.c | 36 ++-
 1 file changed, 10 insertions(+), 26 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c 
b/drivers/net/wireless/ath/ath10k/pci.c
index 3c4c800..8637bfe 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -1372,28 +1372,16 @@ static int ath10k_pci_hif_exchange_bmi_msg(struct 
ath10k *ar,
if (resp && resp_len && *resp_len == 0)
return -EINVAL;
 
-   treq = kmemdup(req, req_len, GFP_KERNEL);
-   if (!treq)
-   return -ENOMEM;
-
-   req_paddr = dma_map_single(ar->dev, treq, req_len, DMA_TO_DEVICE);
-   ret = dma_mapping_error(ar->dev, req_paddr);
-   if (ret) {
+   treq = dma_alloc_coherent(ar->dev, req_len, _paddr, GFP_KERNEL);
+   if (!treq) {
ret = -EIO;
goto err_dma;
}
+   memcpy(treq, req, req_len);
 
if (resp && resp_len) {
-   tresp = kzalloc(*resp_len, GFP_KERNEL);
+   tresp = dma_alloc_coherent(ar->dev, *resp_len, _paddr, 
GFP_KERNEL);
if (!tresp) {
-   ret = -ENOMEM;
-   goto err_req;
-   }
-
-   resp_paddr = dma_map_single(ar->dev, tresp, *resp_len,
-   DMA_FROM_DEVICE);
-   ret = dma_mapping_error(ar->dev, resp_paddr);
-   if (ret) {
ret = EIO;
goto err_req;
}
@@ -1422,23 +1410,19 @@ static int ath10k_pci_hif_exchange_bmi_msg(struct 
ath10k *ar,
}
 
 err_resp:
+   if (ret == 0 && resp_len) {
+   *resp_len = min(*resp_len, xfer.resp_len);
+   memcpy(resp, tresp, xfer.resp_len);
+   }
if (resp) {
u32 unused_buffer;
 
ath10k_ce_revoke_recv_next(ce_rx, NULL, _buffer);
-   dma_unmap_single(ar->dev, resp_paddr,
-*resp_len, DMA_FROM_DEVICE);
+   dma_free_coherent(ar->dev, *resp_len, tresp, resp_paddr);
}
 err_req:
-   dma_unmap_single(ar->dev, req_paddr, req_len, DMA_TO_DEVICE);
-
-   if (ret == 0 && resp_len) {
-   *resp_len = min(*resp_len, xfer.resp_len);
-   memcpy(resp, tresp, xfer.resp_len);
-   }
+   dma_free_coherent(ar->dev, req_len, treq, req_paddr);
 err_dma:
-   kfree(treq);
-   kfree(tresp);
 
return ret;
 }
-- 
1.9.1



[PATCH] ath10k: add dynamic vlan support

2018-04-20 Thread Manikanta Pubbisetty
Mutlicast/broadcast traffic destined for a particular vlan group will
always be encrypted in software. To enable dynamic VLANs, it requires
driver support for sending software encrypted packets.

In ath10k, sending sw encrypted frames is allowed only when we insmod
the driver with cryptmode param set to 1, this configuration disables
hardware crypto and enables RAW mode implicitly. Since, enabling raw
mode has performance impact, this cannot be considered as an ideal
solution for supporting VLANs in the driver.

As an alternative take, in this approach, cryptographic keys for
unicast traffic(per peer PTKs) and keys for non-vlan group traffic
will be configured in hardware, allowing hardware encryption for unicast
and non-vlan group traffic. Only vlan group traffic will be encrypted in
software and pushed to the target with encap mode set to RAW in the TX
descriptors.

Not all firmwares can support this type of key configuration(having few
keys installed in hardware and few only in software); for this purpose a
new WMI service flag "WMI_SERVICE_PER_PACKET_SW_ENCRYPT" is introduced to
advertise this support.

Also, adding the logic required to send sw encrypted frames in raw mode.

Tested this change on QCA9984(firmware version 10.4-3.5.3-00057).

Signed-off-by: Manikanta Pubbisetty 
---
 drivers/net/wireless/ath/ath10k/core.h |  1 +
 drivers/net/wireless/ath/ath10k/mac.c  | 26 --
 drivers/net/wireless/ath/ath10k/wmi.h  | 21 +
 3 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index e4ac8f2..105438d 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -122,6 +122,7 @@ enum ath10k_skb_flags {
ATH10K_SKB_F_DELIVER_CAB = BIT(2),
ATH10K_SKB_F_MGMT = BIT(3),
ATH10K_SKB_F_QOS = BIT(4),
+   ATH10K_SKB_F_RAW_TX = BIT(5),
 };
 
 struct ath10k_skb_cb {
diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index fc3320f..694c0aa 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -3362,6 +3362,7 @@ ath10k_mac_tx_h_get_txmode(struct ath10k *ar,
   struct sk_buff *skb)
 {
const struct ieee80211_hdr *hdr = (void *)skb->data;
+   const struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb);
__le16 fc = hdr->frame_control;
 
if (!vif || vif->type == NL80211_IFTYPE_MONITOR)
@@ -3403,7 +3404,8 @@ ath10k_mac_tx_h_get_txmode(struct ath10k *ar,
if (ieee80211_is_data_present(fc) && sta && sta->tdls)
return ATH10K_HW_TXRX_ETHERNET;
 
-   if (test_bit(ATH10K_FLAG_RAW_MODE, >dev_flags))
+   if (test_bit(ATH10K_FLAG_RAW_MODE, >dev_flags) ||
+   skb_cb->flags & ATH10K_SKB_F_RAW_TX)
return ATH10K_HW_TXRX_RAW;
 
return ATH10K_HW_TXRX_NATIVE_WIFI;
@@ -3513,6 +3515,9 @@ static void ath10k_mac_tx_h_fill_cb(struct ath10k *ar,
 {
struct ieee80211_hdr *hdr = (void *)skb->data;
struct ath10k_skb_cb *cb = ATH10K_SKB_CB(skb);
+   const struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+   bool is_data = ieee80211_is_data(hdr->frame_control) ||
+   ieee80211_is_data_qos(hdr->frame_control);
 
cb->flags = 0;
if (!ath10k_tx_h_use_hwcrypto(vif, skb))
@@ -3524,6 +3529,16 @@ static void ath10k_mac_tx_h_fill_cb(struct ath10k *ar,
if (ieee80211_is_data_qos(hdr->frame_control))
cb->flags |= ATH10K_SKB_F_QOS;
 
+   /* Data frames encrypted in software will be posted to firmware
+* with tx encap mode set to RAW. One such case would be the
+* multicast traffic generated for a VLAN group.
+*/
+   if (is_data && ieee80211_has_protected(hdr->frame_control) &&
+   !info->control.hw_key) {
+   cb->flags |= ATH10K_SKB_F_NO_HWCRYPT;
+   cb->flags |= ATH10K_SKB_F_RAW_TX;
+   }
+
cb->vif = vif;
cb->txq = txq;
 }
@@ -3632,6 +3647,7 @@ static int ath10k_mac_tx(struct ath10k *ar,
 {
struct ieee80211_hw *hw = ar->hw;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+   const struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb);
int ret;
 
/* We should disable CCK RATE due to P2P */
@@ -3649,7 +3665,8 @@ static int ath10k_mac_tx(struct ath10k *ar,
ath10k_tx_h_8023(skb);
break;
case ATH10K_HW_TXRX_RAW:
-   if (!test_bit(ATH10K_FLAG_RAW_MODE, >dev_flags)) {
+   if (!test_bit(ATH10K_FLAG_RAW_MODE, >dev_flags) &&
+   !(skb_cb->flags & ATH10K_SKB_F_RAW_TX)) {
WARN_ON_ONCE(1);
ieee80211_free_txskb(hw, skb);
return -ENOTSUPP;
@@ -8455,6 +8472,11 @@ int ath10k_mac_register(struct ath10k *ar)
  

Re: [PATCHv2] ath10k: fix kernel panic while reading tpc_stats

2018-04-20 Thread Kalle Valo
Tamizh chelvam  writes:

> On 2018-03-26 21:19, Kalle Valo wrote:
>> Tamizh chelvam  writes:
>>
>>> @@ -4455,6 +4461,8 @@ void ath10k_wmi_event_pdev_tpc_config(struct
>>> ath10k *ar, struct sk_buff *skb)
>>>__le32_to_cpu(ev->twice_max_rd_power) / 2,
>>>__le32_to_cpu(ev->num_tx_chain),
>>>__le32_to_cpu(ev->rate_max));
>>> +exit:
>>> +   complete(>debug.tpc_complete);
>>>  }
>>
>> And why do you need this anyway? The commit log doesn't explain that.
>
> Previously this complete call was not there in the error case and
> without this we will get "failed to request tpc config stats: -110"
> along with the error message and this is a timeout warning. I've added
> this since we have received the event and the warning message is
> incorrect. I'll remove this complete call here since it is a harmless
> message and send the next version of a patch.

Yeah, that's a good idea. If you want to add the complete it's better to
do that in it's own patch (and with a proper explanation in the commit
log).

-- 
Kalle Valo


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

2018-04-20 Thread govinds

On 2018-04-20 13:46, Arend van Spriel wrote:

On 4/20/2018 9:21 AM, Sebastian Gottschall wrote:


Yes this is WIFI chip set level power-save(based on idleness) and 
not

related to protocol power save. FW will turn off/scale down the
resources(clock/rails) based on opportunity(when ever idle mode is
detected). This power save is mostly done in disconnected state. I 
am

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

I think that 'set power_save' commands affects struct
ieee80211_bss_conf::ps parameter and I don't think it should be used 
in
this case. We already have ath10k_config_ps() for 802.11 level of 
power

saving.

Arend again proposed runtime-pm with which I'm not very familiar. But
why would we want to disable this? Doesn't it make sense to have this
feature always enabled to save power? wcn3990 is a chip for a mobile
device anyway.
it might be made for mobile devices but who knows how it is used by 
the

market.


I guess having this enabled by default is safe as 
WMI_PDEV_PARAM_UNSUPPORTED

protects for those version which does not support this pdev param.



Reading the explanation above it does not make sense to use
runtime-pm. That would only come into play if the host driver would
actually control the resources being turned off/scaled down.

So this is purely reducing power-consumption of the chip. However, it
would be good to know the consequences in terms of responsiveness to
firmware commands for instance when requesting a scan operation.


Exit latency is around 8-10 ms, so i guess this delta should be ok.


Another thing to consider is to provide user-space with possibility to
change this configuration (maybe through debugfs?).



In case any one wants to measure power no's with/without this config, 
just giving

provision to disable may be useful.


BR,
Govind


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

2018-04-20 Thread Andy Shevchenko
On Wed, 2018-04-18 at 15:35 +0530, Amit Pundir wrote:

> + if (phy->next_read_size >
> FDP_NCI_I2C_MAX_PAYLOAD) {

> + dev_dbg(>dev, "%s: corrupted
> packet\n",
> + __func__);

If Android people would follow the kernel in reasonable time they may
have noticed Dynamic Debug functionality and how it works.

In this case the __func__ is superfluous.

> + phy->next_read_size = 5;
> + goto flush;
> + }
>   } else {
>   phy->next_read_size =
> FDP_NCI_I2C_MIN_PAYLOAD;
>  

-- 
Andy Shevchenko 
Intel Finland Oy


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

2018-04-20 Thread Andy Shevchenko
On Wed, 2018-04-18 at 15:35 +0530, Amit Pundir wrote:

>   if (skb->data[transaction->aid_len + 2] !=
> - NFC_EVT_TRANSACTION_PARAMS_TAG)
> + NFC_EVT_TRANSACTION_PARAMS_TAG ||
> + skb->len < transaction->aid_len + transaction-
> >params_len + 4) {

> + devm_kfree(dev, transaction);

Oh, no.

This is not memory leak per se, this is bad choice of devm_ API where it
should use plain kmalloc() / kfree().

>   return -EPROTO;
> + }

-- 
Andy Shevchenko 
Intel Finland Oy


Re: [PATCH v2] rtlwifi: cleanup 8723be ant_sel definition

2018-04-20 Thread Kalle Valo
 writes:

> From: Ping-Ke Shih 
>
> The module parameter ant_sel is used to control antenna number and path.
> There is an existing enum ANT_{X2,X1} defined the antenna number, so
> add a new enum ANT_{MAIN,AUX} to make it readable. After this work,
> incorrect given values depend on ant_sel were exposed, so refill values
> according following definition:
>   ant_sel   ant_num   ant_path  print_label
>  1  ANT_X1ANT_AUX#2
>  2  ANT_X2ANT_MAIN   #1
> Then, a workaround resulted from the incorrect values in halbtcoutsrc.c was
> removed. These is a existing bug in the workaround while ant_sel=2, but the
> case is rare use so user is hard to observe this bug.
>
> The experimental results with single antenna connected to specific path
> are in following:
>   ant_sel  ANT_MAIN(#1)  ANT_AUX(#2)
>  0-8-62
>  1-62   -10
>  2-6-60
>
> Signed-off-by: Ping-Ke Shih 
> Cc: Stable  # 4.7+
> Reviewed-by: Larry Finger 
> ---
> v2: Add more description about fixed bugs in end of first paragraph.

Sorry, I still don't understand the bug you are fixing. It shouldn't
take more than one minute to understand a commit log.

I prose that you rewrite the commit log, or at least parts of if it.
When you are describing a bug don't talk about enums or source files,
that's an implementation detail, and instead talk how the bug looks like
from users point of view. For example:

  "On HP laptop model 1234 with Realtex 4321 device users are supposed
   to use ant_sel module parameter with value 77 to use the correct
   antenna. But instead rtlwifi incorrectly chose antenna 88 with lower
   transmit power and that caused packet loss. Fix it so that the user
   gets better transmit power and..."

(that's of course all made up information as I don't know what the
actual bug is)

And after that you can write rtlwifi internals in the commit log as much
as you want :) But there needs to be a clear generic description of the
bug first and it needs to understandable in one read.

To make this faster I propose that you send the new commit log as a
reply to this mail and I can then comment faster.

-- 
Kalle Valo


[PATCH 7/9] mac80211: add api to set CSA counter in mac80211

2018-04-20 Thread Luca Coelho
From: Gregory Greenman 

Sometimes the most updated CSA counter values are known only
to the device. Add an API to pass this data to mac80211.

Signed-off-by: Gregory Greenman 
Signed-off-by: Luca Coelho 
---
 include/net/mac80211.h | 13 +
 net/mac80211/tx.c  | 25 +
 2 files changed, 38 insertions(+)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index d2279b2d61aa..52f36c43f35f 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -4449,6 +4449,19 @@ static inline struct sk_buff 
*ieee80211_beacon_get(struct ieee80211_hw *hw,
  */
 u8 ieee80211_csa_update_counter(struct ieee80211_vif *vif);
 
+/**
+ * ieee80211_csa_set_counter - request mac80211 to set csa counter
+ * @vif:  ieee80211_vif pointer from the add_interface callback.
+ * @counter: the new value for the counter
+ *
+ * The csa counter can be changed by the device, this API should be
+ * used by the device driver to update csa counter in mac80211.
+ *
+ * It should never be used together with ieee80211_csa_update_counter(),
+ * as it will cause a race condition around the counter value.
+ */
+void ieee80211_csa_set_counter(struct ieee80211_vif *vif, u8 counter);
+
 /**
  * ieee80211_csa_finish - notify mac80211 about channel switch
  * @vif:  ieee80211_vif pointer from the add_interface callback.
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 05a265cd573d..34499f6300d8 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -4085,6 +4085,31 @@ u8 ieee80211_csa_update_counter(struct ieee80211_vif 
*vif)
 }
 EXPORT_SYMBOL(ieee80211_csa_update_counter);
 
+void ieee80211_csa_set_counter(struct ieee80211_vif *vif, u8 counter)
+{
+   struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
+   struct beacon_data *beacon = NULL;
+
+   rcu_read_lock();
+
+   if (sdata->vif.type == NL80211_IFTYPE_AP)
+   beacon = rcu_dereference(sdata->u.ap.beacon);
+   else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
+   beacon = rcu_dereference(sdata->u.ibss.presp);
+   else if (ieee80211_vif_is_mesh(>vif))
+   beacon = rcu_dereference(sdata->u.mesh.beacon);
+
+   if (!beacon)
+   goto unlock;
+
+   if (counter < beacon->csa_current_counter)
+   beacon->csa_current_counter = counter;
+
+unlock:
+   rcu_read_unlock();
+}
+EXPORT_SYMBOL(ieee80211_csa_set_counter);
+
 bool ieee80211_csa_is_complete(struct ieee80211_vif *vif)
 {
struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
-- 
2.17.0



[PATCH 8/9] mac80211: Support adding duration for prepare_tx() callback

2018-04-20 Thread Luca Coelho
From: Ilan Peer 

There are specific cases, such as SAE authentication exchange, that
might require long duration to complete. For such cases, add support
for indicating to the driver the required duration of the prepare_tx()
operation, so the driver would still be able to complete the frame
exchange.

Currently, indicate the duration only for SAE authentication exchange,
as SAE authentication can take up to 2000 msec (as defined in IEEE
P802.11-REVmd D1.0 p. 3504).

As the patch modified the prepare_tx() callback API, also modify
the relevant code in iwlwifi.

Signed-off-by: Ilan Peer 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/ath/ath9k/main.c |  3 ++-
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c |  6 -
 include/net/mac80211.h|  5 +++-
 net/mac80211/driver-ops.h |  8 +++---
 net/mac80211/mlme.c   | 17 -
 net/mac80211/trace.h  | 25 ---
 6 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/main.c 
b/drivers/net/wireless/ath/ath9k/main.c
index a3be8add56e1..b6663c80e7dd 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -2544,7 +2544,8 @@ static void ath9k_unassign_vif_chanctx(struct 
ieee80211_hw *hw,
 }
 
 static void ath9k_mgd_prepare_tx(struct ieee80211_hw *hw,
-struct ieee80211_vif *vif)
+struct ieee80211_vif *vif,
+u16 duration)
 {
struct ath_softc *sc = hw->priv;
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index 51b30424575b..4e428427d1ba 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -2810,7 +2810,8 @@ static int iwl_mvm_mac_conf_tx(struct ieee80211_hw *hw,
 }
 
 static void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif)
+  struct ieee80211_vif *vif,
+  u16 req_duration)
 {
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
u32 duration = IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS;
@@ -2823,6 +2824,9 @@ static void iwl_mvm_mac_mgd_prepare_tx(struct 
ieee80211_hw *hw,
if (iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PREPARE_TX))
return;
 
+   if (req_duration > duration)
+   duration = req_duration;
+
mutex_lock(>mutex);
/* Try really hard to protect the session and hear a beacon */
iwl_mvm_protect_session(mvm, vif, duration, min_duration, 500, false);
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 52f36c43f35f..cde1db0f6573 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -3378,6 +3378,8 @@ enum ieee80211_reconfig_type {
  * frame in case that no beacon was heard from the AP/P2P GO.
  * The callback will be called before each transmission and upon return
  * mac80211 will transmit the frame right away.
+ *  If duration is greater than zero, mac80211 hints to the driver the
+ *  duration for which the operation is requested.
  * The callback is optional and can (should!) sleep.
  *
  * @mgd_protect_tdls_discover: Protect a TDLS discovery session. After sending
@@ -3697,7 +3699,8 @@ struct ieee80211_ops {
  u32 sset, u8 *data);
 
void(*mgd_prepare_tx)(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif);
+ struct ieee80211_vif *vif,
+ u16 duration);
 
void(*mgd_protect_tdls_discover)(struct ieee80211_hw *hw,
 struct ieee80211_vif *vif);
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index 4d82fe7d627c..8f6998091d26 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -2,6 +2,7 @@
 /*
 * Portions of this file
 * Copyright(c) 2016 Intel Deutschland GmbH
+* Copyright (C) 2018 Intel Corporation
 */
 
 #ifndef __MAC80211_DRIVER_OPS
@@ -813,7 +814,8 @@ drv_allow_buffered_frames(struct ieee80211_local *local,
 }
 
 static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
- struct ieee80211_sub_if_data *sdata)
+ struct ieee80211_sub_if_data *sdata,
+ u16 duration)
 {
might_sleep();
 
@@ -821,9 +823,9 @@ static inline void drv_mgd_prepare_tx(struct 
ieee80211_local *local,
return;
WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
 
-   

[PATCH 6/9] mac80211: remove pointless flags=0 assignment

2018-04-20 Thread Luca Coelho
From: Johannes Berg 

The data structure is initialized to all zeroes, and
we already rely on that in other places, so remove the
pointless assignment to 0.

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

diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 655c3d8b0d80..2d5ffb0a16f6 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -3,6 +3,7 @@
  * Copyright 2006-2007 Jiri Benc 
  * Copyright 2013-2014  Intel Mobile Communications GmbH
  * Copyright (C) 2015 - 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 the GNU General Public License version 2 as
@@ -1992,7 +1993,6 @@ static void sta_stats_decode_rate(struct ieee80211_local 
*local, u16 rate,
int band = STA_STATS_GET(LEGACY_BAND, rate);
int rate_idx = STA_STATS_GET(LEGACY_IDX, rate);
 
-   rinfo->flags = 0;
sband = local->hw.wiphy->bands[band];
brate = sband->bitrates[rate_idx].bitrate;
if (rinfo->bw == RATE_INFO_BW_5)
-- 
2.17.0



[PATCH 9/9] nl80211: Add wmm rule attribute to NL80211_CMD_GET_WIPHY dump command.

2018-04-20 Thread Luca Coelho
From: Haim Dreyfuss 

This will serve userspace entity to maintain its regulatory limitation.
More specifcally APs can use this data to calculate the WMM IE when
building: beacons, probe responses, assoc responses etc...

Signed-off-by: Haim Dreyfuss 
Signed-off-by: Luca Coelho 
---
 include/uapi/linux/nl80211.h | 28 ++
 net/wireless/nl80211.c   | 57 +---
 2 files changed, 81 insertions(+), 4 deletions(-)

diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 15daf5e2638d..04c9b97aa5fc 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -11,6 +11,7 @@
  * Copyright 2008 Jouni Malinen 
  * Copyright 2008 Colin McCabe 
  * Copyright 2015-2017 Intel Deutschland GmbH
+ * Copyright (C) 2018 Intel Corporation
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -3141,6 +3142,29 @@ enum nl80211_band_attr {
 
 #define NL80211_BAND_ATTR_HT_CAPA NL80211_BAND_ATTR_HT_CAPA
 
+/**
+ * enum nl80211_wmm_rule - regulatory wmm rule
+ *
+ * @__NL80211_WMMR_INVALID: attribute number 0 is reserved
+ * @NL80211_WMMR_CW_MIN: Minimum contention window slot.
+ * @NL80211_WMMR_CW_MAX: Maximum contention window slot.
+ * @NL80211_WMMR_AIFSN: Arbitration Inter Frame Space.
+ * @NL80211_WMMR_TXOP: Maximum allowed tx operation time.
+ * @nl80211_WMMR_MAX: highest possible wmm rule.
+ * @__NL80211_WMMR_LAST: Internal use.
+ */
+enum nl80211_wmm_rule {
+   __NL80211_WMMR_INVALID,
+   NL80211_WMMR_CW_MIN,
+   NL80211_WMMR_CW_MAX,
+   NL80211_WMMR_AIFSN,
+   NL80211_WMMR_TXOP,
+
+   /* keep last */
+   __NL80211_WMMR_LAST,
+   NL80211_WMMR_MAX = __NL80211_WMMR_LAST - 1
+};
+
 /**
  * enum nl80211_frequency_attr - frequency attributes
  * @__NL80211_FREQUENCY_ATTR_INVALID: attribute number 0 is reserved
@@ -3190,6 +3214,9 @@ enum nl80211_band_attr {
  * on this channel in current regulatory domain.
  * @NL80211_FREQUENCY_ATTR_NO_10MHZ: 10 MHz operation is not allowed
  * on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_WMM: this channel has wmm limitations.
+ * This is a nested attribute that contains the wmm limitation per AC.
+ * (see  nl80211_wmm_rule)
  * @NL80211_FREQUENCY_ATTR_MAX: highest frequency attribute number
  * currently defined
  * @__NL80211_FREQUENCY_ATTR_AFTER_LAST: internal use
@@ -3218,6 +3245,7 @@ enum nl80211_frequency_attr {
NL80211_FREQUENCY_ATTR_IR_CONCURRENT,
NL80211_FREQUENCY_ATTR_NO_20MHZ,
NL80211_FREQUENCY_ATTR_NO_10MHZ,
+   NL80211_FREQUENCY_ATTR_WMM,
 
/* keep last */
__NL80211_FREQUENCY_ATTR_AFTER_LAST,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index ff28f8feeb09..016d0a1de576 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -4,6 +4,7 @@
  * Copyright 2006-2010 Johannes Berg 
  * Copyright 2013-2014  Intel Mobile Communications GmbH
  * Copyright 2015-2017 Intel Deutschland GmbH
+ * Copyright (C) 2018 Intel Corporation
  */
 
 #include 
@@ -645,7 +646,43 @@ static inline void *nl80211hdr_put(struct sk_buff *skb, 
u32 portid, u32 seq,
return genlmsg_put(skb, portid, seq, _fam, flags, cmd);
 }
 
-static int nl80211_msg_put_channel(struct sk_buff *msg,
+static int nl80211_msg_put_wmm_rules(struct sk_buff *msg,
+const struct ieee80211_reg_rule *rule)
+{
+   int j;
+   struct nlattr *nl_wmm_rules =
+   nla_nest_start(msg, NL80211_FREQUENCY_ATTR_WMM);
+
+   if (!nl_wmm_rules)
+   goto nla_put_failure;
+
+   for (j = 0; j < IEEE80211_NUM_ACS; j++) {
+   struct nlattr *nl_wmm_rule = nla_nest_start(msg, j);
+
+   if (!nl_wmm_rule)
+   goto nla_put_failure;
+
+   if (nla_put_u16(msg, NL80211_WMMR_CW_MIN,
+   rule->wmm_rule->client[j].cw_min) ||
+   nla_put_u16(msg, NL80211_WMMR_CW_MAX,
+   rule->wmm_rule->client[j].cw_max) ||
+   nla_put_u8(msg, NL80211_WMMR_AIFSN,
+  rule->wmm_rule->client[j].aifsn) ||
+   nla_put_u8(msg, NL80211_WMMR_TXOP,
+  rule->wmm_rule->client[j].cot))
+   goto nla_put_failure;
+
+   nla_nest_end(msg, nl_wmm_rule);
+   }
+   nla_nest_end(msg, nl_wmm_rules);
+
+   return 0;
+
+nla_put_failure:
+   return -ENOBUFS;
+}
+
+static int nl80211_msg_put_channel(struct sk_buff *msg, struct wiphy *wiphy,
   struct ieee80211_channel *chan,
   bool large)
 {
@@ -721,6 +758,16 @@ static int 

[PATCH 3/9] mac80211: Adjust SAE authentication timeout

2018-04-20 Thread Luca Coelho
From: Ilan Peer 

The IEEE P802.11-REVmd D1.0 specification updated the SAE authentication
timeout to be 2000 milliseconds (see dot11RSNASAERetransPeriod). Update
the SAE timeout setting accordingly.

While at it, reduce some code duplication in the timeout configuration.

Signed-off-by: Ilan Peer 
Signed-off-by: Luca Coelho 
---
 net/mac80211/mlme.c | 25 ++---
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 69449db7e283..51021d3d2d18 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -36,6 +36,7 @@
 #define IEEE80211_AUTH_TIMEOUT (HZ / 5)
 #define IEEE80211_AUTH_TIMEOUT_LONG(HZ / 2)
 #define IEEE80211_AUTH_TIMEOUT_SHORT   (HZ / 10)
+#define IEEE80211_AUTH_TIMEOUT_SAE (HZ * 2)
 #define IEEE80211_AUTH_MAX_TRIES   3
 #define IEEE80211_AUTH_WAIT_ASSOC  (HZ * 5)
 #define IEEE80211_ASSOC_TIMEOUT(HZ / 5)
@@ -3814,16 +3815,19 @@ static int ieee80211_auth(struct ieee80211_sub_if_data 
*sdata)
tx_flags);
 
if (tx_flags == 0) {
-   auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT;
-   auth_data->timeout_started = true;
-   run_again(sdata, auth_data->timeout);
+   if (auth_data->algorithm == WLAN_AUTH_SAE)
+   auth_data->timeout = jiffies +
+   IEEE80211_AUTH_TIMEOUT_SAE;
+   else
+   auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT;
} else {
auth_data->timeout =
round_jiffies_up(jiffies + IEEE80211_AUTH_TIMEOUT_LONG);
-   auth_data->timeout_started = true;
-   run_again(sdata, auth_data->timeout);
}
 
+   auth_data->timeout_started = true;
+   run_again(sdata, auth_data->timeout);
+
return 0;
 }
 
@@ -3894,8 +3898,15 @@ void ieee80211_sta_work(struct ieee80211_sub_if_data 
*sdata)
ifmgd->status_received = false;
if (ifmgd->auth_data && ieee80211_is_auth(fc)) {
if (status_acked) {
-   ifmgd->auth_data->timeout =
-   jiffies + IEEE80211_AUTH_TIMEOUT_SHORT;
+   if (ifmgd->auth_data->algorithm ==
+   WLAN_AUTH_SAE)
+   ifmgd->auth_data->timeout =
+   jiffies +
+   IEEE80211_AUTH_TIMEOUT_SAE;
+   else
+   ifmgd->auth_data->timeout =
+   jiffies +
+   IEEE80211_AUTH_TIMEOUT_SHORT;
run_again(sdata, ifmgd->auth_data->timeout);
} else {
ifmgd->auth_data->timeout = jiffies - 1;
-- 
2.17.0



[PATCH 2/9] mac80211: use timeout from the AddBA response instead of the request

2018-04-20 Thread Luca Coelho
From: Sara Sharon 

2016 spec, section 10.24.2 specifies that the block ack
timeout in the ADD BA request is advisory.

That means we should check the value in the response and
act upon it (same as buffer size).

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 net/mac80211/agg-tx.c | 4 
 net/mac80211/tx.c | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c
index 595c662a61e8..ac4295296514 100644
--- a/net/mac80211/agg-tx.c
+++ b/net/mac80211/agg-tx.c
@@ -8,6 +8,7 @@
  * Copyright 2007, Michael Wu 
  * Copyright 2007-2010, Intel Corporation
  * Copyright(c) 2015-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 the GNU General Public License version 2 as
@@ -970,6 +971,9 @@ void ieee80211_process_addba_resp(struct ieee80211_local 
*local,
 
sta->ampdu_mlme.addba_req_num[tid] = 0;
 
+   tid_tx->timeout =
+   le16_to_cpu(mgmt->u.action.u.addba_resp.timeout);
+
if (tid_tx->timeout) {
mod_timer(_tx->session_timer,
  TU_TO_EXP_TIME(tid_tx->timeout));
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 535de3161a78..05a265cd573d 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -4,6 +4,7 @@
  * Copyright 2006-2007 Jiri Benc 
  * Copyright 2007  Johannes Berg 
  * Copyright 2013-2014  Intel Mobile Communications GmbH
+ * Copyright (C) 2018 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -1135,7 +1136,7 @@ static bool ieee80211_tx_prep_agg(struct 
ieee80211_tx_data *tx,
}
 
/* reset session timer */
-   if (reset_agg_timer && tid_tx->timeout)
+   if (reset_agg_timer)
tid_tx->last_tx = jiffies;
 
return queued;
-- 
2.17.0



[PATCH 4/9] mac80211: clean up rate info bandwidth setting

2018-04-20 Thread Luca Coelho
From: Johannes Berg 

There's no need to do the same thing three times in
the different switch cases, pull that out to a single
place.

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

diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 11f9cfc016d9..2d82c88efd0b 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -2793,12 +2793,13 @@ u64 ieee80211_calculate_rx_timestamp(struct 
ieee80211_local *local,
 
memset(, 0, sizeof(ri));
 
+   ri.bw = status->bw;
+
/* Fill cfg80211 rate info */
switch (status->encoding) {
case RX_ENC_HT:
ri.mcs = status->rate_idx;
ri.flags |= RATE_INFO_FLAGS_MCS;
-   ri.bw = status->bw;
if (status->enc_flags & RX_ENC_FLAG_SHORT_GI)
ri.flags |= RATE_INFO_FLAGS_SHORT_GI;
break;
@@ -2806,7 +2807,6 @@ u64 ieee80211_calculate_rx_timestamp(struct 
ieee80211_local *local,
ri.flags |= RATE_INFO_FLAGS_VHT_MCS;
ri.mcs = status->rate_idx;
ri.nss = status->nss;
-   ri.bw = status->bw;
if (status->enc_flags & RX_ENC_FLAG_SHORT_GI)
ri.flags |= RATE_INFO_FLAGS_SHORT_GI;
break;
@@ -2818,8 +2818,6 @@ u64 ieee80211_calculate_rx_timestamp(struct 
ieee80211_local *local,
int shift = 0;
int bitrate;
 
-   ri.bw = status->bw;
-
switch (status->bw) {
case RATE_INFO_BW_10:
shift = 1;
-- 
2.17.0



[PATCH 5/9] mac80211: ethtool: memset the whole sinfo struct to 0

2018-04-20 Thread Luca Coelho
From: Johannes Berg 

Rather than just setting the valid flags to 0 set the
whole struct to 0 since other places might rely on it.

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

diff --git a/net/mac80211/ethtool.c b/net/mac80211/ethtool.c
index 9cc986deda61..08408520c3f8 100644
--- a/net/mac80211/ethtool.c
+++ b/net/mac80211/ethtool.c
@@ -4,6 +4,7 @@
  * Copied from cfg.c - originally
  * Copyright 2006-2010 Johannes Berg 
  * Copyright 2014  Intel Corporation (Author: Johannes Berg)
+ * Copyright (C) 2018 Intel Corporation
  *
  * This file is GPLv2 as found in COPYING.
  */
@@ -106,7 +107,7 @@ static void ieee80211_get_stats(struct net_device *dev,
if (!(sta && !WARN_ON(sta->sdata->dev != dev)))
goto do_survey;
 
-   sinfo.filled = 0;
+   memset(, 0, sizeof(sinfo));
sta_set_sinfo(sta, );
 
i = 0;
@@ -133,7 +134,7 @@ static void ieee80211_get_stats(struct net_device *dev,
if (sta->sdata->dev != dev)
continue;
 
-   sinfo.filled = 0;
+   memset(, 0, sizeof(sinfo));
sta_set_sinfo(sta, );
i = 0;
ADD_STA_STATS(sta);
-- 
2.17.0



[PATCH 1/9] mac80211: rename rtap_vendor_space to rtap_space

2018-04-20 Thread Luca Coelho
From: Johannes Berg 

Since all the HE data won't fit into struct ieee80211_rx_status,
we'll (have to) move that into the SKB proper. This means we'll
need to skip over more things in the future, so rename this to
remove the vendor-only notion from it.

Signed-off-by: Johannes Berg 
---
 net/mac80211/rx.c | 40 +++-
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 03102aff0953..0a38cc1cbebc 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -5,6 +5,7 @@
  * Copyright 2007-2010 Johannes Berg 
  * Copyright 2013-2014  Intel Mobile Communications GmbH
  * Copyright(c) 2015 - 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 the GNU General Public License version 2 as
@@ -97,27 +98,27 @@ static u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, 
size_t len,
  */
 static void remove_monitor_info(struct sk_buff *skb,
unsigned int present_fcs_len,
-   unsigned int rtap_vendor_space)
+   unsigned int rtap_space)
 {
if (present_fcs_len)
__pskb_trim(skb, skb->len - present_fcs_len);
-   __pskb_pull(skb, rtap_vendor_space);
+   __pskb_pull(skb, rtap_space);
 }
 
 static inline bool should_drop_frame(struct sk_buff *skb, int present_fcs_len,
-unsigned int rtap_vendor_space)
+unsigned int rtap_space)
 {
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
struct ieee80211_hdr *hdr;
 
-   hdr = (void *)(skb->data + rtap_vendor_space);
+   hdr = (void *)(skb->data + rtap_space);
 
if (status->flag & (RX_FLAG_FAILED_FCS_CRC |
RX_FLAG_FAILED_PLCP_CRC |
RX_FLAG_ONLY_MONITOR))
return true;
 
-   if (unlikely(skb->len < 16 + present_fcs_len + rtap_vendor_space))
+   if (unlikely(skb->len < 16 + present_fcs_len + rtap_space))
return true;
 
if (ieee80211_is_ctl(hdr->frame_control) &&
@@ -199,7 +200,7 @@ ieee80211_rx_radiotap_hdrlen(struct ieee80211_local *local,
 
 static void ieee80211_handle_mu_mimo_mon(struct ieee80211_sub_if_data *sdata,
 struct sk_buff *skb,
-int rtap_vendor_space)
+int rtap_space)
 {
struct {
struct ieee80211_hdr_3addr hdr;
@@ -212,14 +213,14 @@ static void ieee80211_handle_mu_mimo_mon(struct 
ieee80211_sub_if_data *sdata,
 
BUILD_BUG_ON(sizeof(action) != IEEE80211_MIN_ACTION_SIZE + 1);
 
-   if (skb->len < rtap_vendor_space + sizeof(action) +
+   if (skb->len < rtap_space + sizeof(action) +
   VHT_MUMIMO_GROUPS_DATA_LEN)
return;
 
if (!is_valid_ether_addr(sdata->u.mntr.mu_follow_addr))
return;
 
-   skb_copy_bits(skb, rtap_vendor_space, , sizeof(action));
+   skb_copy_bits(skb, rtap_space, , sizeof(action));
 
if (!ieee80211_is_action(action.hdr.frame_control))
return;
@@ -545,7 +546,7 @@ static struct sk_buff *
 ieee80211_make_monitor_skb(struct ieee80211_local *local,
   struct sk_buff **origskb,
   struct ieee80211_rate *rate,
-  int rtap_vendor_space, bool use_origskb)
+  int rtap_space, bool use_origskb)
 {
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(*origskb);
int rt_hdrlen, needed_headroom;
@@ -553,7 +554,7 @@ ieee80211_make_monitor_skb(struct ieee80211_local *local,
 
/* room for the radiotap header based on driver features */
rt_hdrlen = ieee80211_rx_radiotap_hdrlen(local, status, *origskb);
-   needed_headroom = rt_hdrlen - rtap_vendor_space;
+   needed_headroom = rt_hdrlen - rtap_space;
 
if (use_origskb) {
/* only need to expand headroom if necessary */
@@ -607,7 +608,7 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct 
sk_buff *origskb,
struct ieee80211_sub_if_data *sdata;
struct sk_buff *monskb = NULL;
int present_fcs_len = 0;
-   unsigned int rtap_vendor_space = 0;
+   unsigned int rtap_space = 0;
struct ieee80211_sub_if_data *monitor_sdata =
rcu_dereference(local->monitor_sdata);
bool only_monitor = false;
@@ -615,7 +616,7 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct 
sk_buff *origskb,
if (unlikely(status->flag & RX_FLAG_RADIOTAP_VENDOR_DATA)) {
struct ieee80211_vendor_radiotap *rtap = (void *)origskb->data;
 
-   

[PATCH 0/9] cfg80211/mac80211 patches from our internal tree 2018-04-20

2018-04-20 Thread Luca Coelho
From: Luca Coelho 

Hi,

Some patches with mac80211 and cfg80211 changes from our internal
tree.

Please review, though you have already reviewed most if not all of
them ;)

Cheers,
Luca.


Gregory Greenman (1):
  mac80211: add api to set CSA counter in mac80211

Haim Dreyfuss (1):
  nl80211: Add wmm rule attribute to NL80211_CMD_GET_WIPHY dump command.

Ilan Peer (2):
  mac80211: Adjust SAE authentication timeout
  mac80211: Support adding duration for prepare_tx() callback

Johannes Berg (4):
  mac80211: rename rtap_vendor_space to rtap_space
  mac80211: clean up rate info bandwidth setting
  mac80211: ethtool: memset the whole sinfo struct to 0
  mac80211: remove pointless flags=0 assignment

Sara Sharon (1):
  mac80211: use timeout from the AddBA response instead of the request

 drivers/net/wireless/ath/ath9k/main.c |  3 +-
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c |  6 +-
 include/net/mac80211.h| 18 +-
 include/uapi/linux/nl80211.h  | 28 +
 net/mac80211/agg-tx.c |  4 ++
 net/mac80211/driver-ops.h |  8 ++-
 net/mac80211/ethtool.c|  5 +-
 net/mac80211/mlme.c   | 42 +-
 net/mac80211/rx.c | 40 +++--
 net/mac80211/sta_info.c   |  2 +-
 net/mac80211/trace.h  | 25 +++-
 net/mac80211/tx.c | 28 -
 net/mac80211/util.c   |  6 +-
 net/wireless/nl80211.c| 57 +--
 14 files changed, 217 insertions(+), 55 deletions(-)

-- 
2.17.0



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

2018-04-20 Thread Kalle Valo
cjhu...@codeaurora.org writes:

> On 2018-04-16 21:42, Kalle Valo wrote:
>> Carl Huang  wrote:
>>
>>> The ath10k reports the random_mac_addr capability to upper layer
>>> based on the service bit firmware reported. Driver sets the
>>> spoofed flag in scan_ctrl_flag to firmware if upper layer has
>>> enabled this feature in scan request.
>>>
>>> Test with QCA6174 hw3.0 and
>>> firmware-6.bin_WLAN.RM.4.4.1-00102-QCARMSWP-1,
>>> but QCA9377 is also affected.
>>>
>>> Signed-off-by: Carl Huang 
>>> Signed-off-by: Kalle Valo 
>>
>> This added a new checkpatch warning:
>>
>> drivers/net/wireless/ath/ath10k/wmi-ops.h:123: Alignment should match
>> open parenthesis
>>
>> I fixed it in the pending branch.
>
> Kvalo, as the flag issue NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR
> will be fixed from Brian side, I don't need to submit V2 for it.
>
> For this alignment warning and sparse warnings in [1/2], as you fixed
> them in the pending branch, so I needn't do anything, right?

Correct, I'm planning to apply this soon.

-- 
Kalle Valo


Re: [PATCH 9/9] brcmfmac: use request_firmware_nowait2 to load firmware without warnings

2018-04-20 Thread Kalle Valo
Andres Rodriguez  writes:

> This reduces the unnecessary spew when trying to load optional firmware:
> "Direct firmware load for ... failed with error -2"
>
> Signed-off-by: Andres Rodriguez 
> ---
>  drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)

With wireless patches always CC linux-wireless list, please. Adding it
now.

> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c 
> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
> index 091b52979e03..26db3ebd52dc 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
> @@ -503,8 +503,9 @@ static void brcmf_fw_request_code_done(const struct 
> firmware *fw, void *ctx)
>   goto done;
>  
>   fwctx->code = fw;
> - ret = request_firmware_nowait(THIS_MODULE, true, fwctx->nvram_name,
> -   fwctx->dev, GFP_KERNEL, fwctx,
> + ret = request_firmware_nowait(THIS_MODULE, true, false,

A perfect example why enums should be in function calls instead of
booleans, that "true, false" tells nothing to me and it would be time
consuming to check from headers files what it means. If you had proper
enums, for example "FIRMWARE_MODE_FOO, FIRMWARE_STATE_BAR", it would be
immediately obvious for the reader what the parameters are. Of course
the first boolean was already there before, but maybe change the new
boolean to an enum?

> +   fwctx->nvram_name, fwctx->dev,
> +   GFP_KERNEL, fwctx,
> brcmf_fw_request_nvram_done);
>  
>   /* pass NULL to nvram callback for bcm47xx fallback */
> @@ -547,7 +548,7 @@ int brcmf_fw_get_firmwares_pcie(struct device *dev, u16 
> flags,
>   fwctx->domain_nr = domain_nr;
>   fwctx->bus_nr = bus_nr;
>  
> - return request_firmware_nowait(THIS_MODULE, true, code, dev,
> + return request_firmware_nowait2(THIS_MODULE, true, false, code, dev,
>  GFP_KERNEL, fwctx,
>  brcmf_fw_request_code_done);
>  }

Also the number two in the function name is not really telling anything.
I think that something like request_firmware_nowait_nowarn() would be
better, even if it's so ugly.

-- 
Kalle Valo


Re: [PATCH 8/9] ath10k: use request_firmware_nowarn to load firmware

2018-04-20 Thread Kalle Valo
(adding linux-wireless and ath10k lists)

Andres Rodriguez  writes:

> This reduces the unnecessary spew when trying to load optional firmware:
> "Direct firmware load for ... failed with error -2"
>
> Signed-off-by: Andres Rodriguez 
> ---
>  drivers/net/wireless/ath/ath10k/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Acked-by: Kalle Valo 

But I think it would be good to change also request_firmware_direct() in
ath10k/testmode.c to request_firmware_nowarn().

-- 
Kalle Valo


Re: ath10k: remove variables which set but not used

2018-04-20 Thread Kalle Valo
Kenneth Lu  wrote:

> Variable buf_len and num_vdev_stats are bging assigned but never read.
> These are redundant and can be remove.
> 
> Signed-off-by: Kenneth Lu 

Fails to compile:

drivers/net/wireless/ath/ath10k/wmi.c: In function 
'ath10k_wmi_10_4_op_pull_fw_stats':
drivers/net/wireless/ath/ath10k/wmi.c:3067:18: error: 'num_vdev_stats' 
undeclared (first use in this function); did you mean 'num_pdev_stats'?
  for (i = 0; i < num_vdev_stats; i++) {
  ^~
  num_pdev_stats
drivers/net/wireless/ath/ath10k/wmi.c:3067:18: note: each undeclared identifier 
is reported only once for each function it appears in
make[5]: *** [drivers/net/wireless/ath/ath10k/wmi.o] Error 1
make[4]: *** [drivers/net/wireless/ath/ath10k] Error 2
make[3]: *** [drivers/net/wireless/ath] Error 2
make[2]: *** [drivers/net/wireless] Error 2
make[1]: *** [drivers/net] Error 2
make[1]: *** Waiting for unfinished jobs
make: *** [drivers] Error 2

Patch set to Changes Requested.

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

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



Re: [PATCH] reg: Rename confusing 'country IE' in log output

2018-04-20 Thread Toke Høiland-Jørgensen
Johannes Berg  writes:

> On Fri, 2018-04-20 at 00:32 +0200, Bernhard Gabler wrote:
>
>> looking at the patch, I see more occurences of the outdated "IE" in a 
>> constant name and function name:
>> 
>>  case NL80211_REGDOM_SET_BY_COUNTRY_IE:
>> or
>>  reg_process_hint_country_ie()
>
>
> Right. I searched for further strings that would show up to the user,
> but didn't see any, but the code still refers to it in many places.
>
>> Would it make sense to likewise fix these (and possibly more) 
>> occurrences too, to match the spec from 2016?
>> For the sake of readability and consistency of code ...
>
> I dunno. Country IE isn't the only place where "IE" is used, it's even
> used in struct names (struct ieee80211_tim_ie, and many others), so I
> would think that people who actually work on the code will have to be
> aware of the previous wording of "Information Element" (and the
> abbreviation IE) anyway. Changing *everything* here to be just _element
> instead of _ie or then probably the shorter _elem would IMHO be too much
> code churn.

Also, no one is going to think that reg_process_hint_country_ie() has
anything to do with Ireland. So it's just a matter of outdated
terminology...

-Toke


pull-request: iwlwifi-next 2018-04-20

2018-04-20 Thread Luca Coelho
Hi Kalle,

This is the first batch of patches intended for v4.18 (or whatever
Linus turns out to call it ;).  Nothing major here, just the usual
continued development, bugfixes, new FW APIs and some new
features.  More details about the contents in the tag description.

I have sent this out before and kbuildbot reported success.

Please let me know if there are any issues.

Cheers,
Luca.


The following changes since commit 5d1365940a68dd57b031b6e3c07d7d451cd69daf:

  Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net (2018-04-12 
11:09:05 -0700)

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-04-20

for you to fetch changes up to bd8f3fc613919b50038c949f80b3f350a166293e:

  iwlwifi: mvm: support 22000 HW opening agg before traffic (2018-04-20 
10:57:16 +0300)


iwlwifi patches for 4.18

* implement Traffic Condition Monitor;
* use TCM for scan and BT coex;
* use TCM to detect when the AP doesn't support UAPSD properly;
* some more work for the 22000 family of devices;
* introduce AMSDU rate control offload;
* a couple of clean-ups and bugfixes.


Emmanuel Grumbach (3):
  iwlwifi: mvm: BT Coex - make the primary / secondary pick traffic aware
  iwlwifi: pcie: implement the overlow queue for Gen2 devices
  iwlwifi: mvm: set the MFP flag for keys that are used by MFP stations

Gregory Greenman (1):
  iwlwifi: mvm: support offload of AMSDU rate control

Haim Dreyfuss (1):
  iwlwifi: move timestamp functions from debugfs.h to dbg.h

Johannes Berg (2):
  iwlwifi: mvm: detect U-APSD breaking aggregation
  iwlwifi: mvm: clean up scan capability checks

Liad Kaufman (2):
  iwlwifi: support api ver2 of NVM_GET_INFO resp
  iwlwifi: mvm: support 22000 HW opening agg before traffic

Luca Coelho (5):
  iwlwifi: mvm: add traffic condition monitoring (TCM)
  iwlwifi: mvm: use TCM data to decide scan priority
  iwlwifi: mvm: fix OOC priority in scans
  iwlwifi: use flags to denote modifiers for the channel maps
  iwlwifi: remove upper case letters in sku_capa_band_*_enable

Naftali Goldstein (1):
  iwlwifi: mvm: update rs-fw API

Sara Sharon (7):
  iwlwifi: mvm: detect low latency and traffic load per band
  iwlwifi: pcie: allocate shorter TX queues for 22000 devices
  iwlwifi: Revert "iwlwifi: pcie: dynamic Tx command queue size"
  iwlwifi: add TX queue size parameter to TX queue allocation
  iwlwifi: pcie: use the queue size as sent by opmode
  iwlwifi: mvm: use shorter queues for mgmt and auxilary queues
  iwlwifi: mvm: use the new get_tid function

Shaul Triebitz (3):
  iwlwifi: move all NVM parsing code to the common files
  iwlwifi: pcie: gen2: fix race in cmd fifo write ptr
  iwlwifi: get rid of fw/nvm.c

 drivers/net/wireless/intel/iwlwifi/Makefile   |   2 +-
 drivers/net/wireless/intel/iwlwifi/cfg/22000.c|   1 -
 drivers/net/wireless/intel/iwlwifi/dvm/main.c |   8 +-
 drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h  |   5 --
 drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h   |  42 ++
 drivers/net/wireless/intel/iwlwifi/fw/api/rs.h| 156 
+--
 drivers/net/wireless/intel/iwlwifi/fw/api/txq.h   |   2 +
 drivers/net/wireless/intel/iwlwifi/fw/dbg.h   |  36 
 drivers/net/wireless/intel/iwlwifi/fw/debugfs.c   |   1 +
 drivers/net/wireless/intel/iwlwifi/fw/debugfs.h   |  31 ---
 drivers/net/wireless/intel/iwlwifi/fw/nvm.c   | 162 

 drivers/net/wireless/intel/iwlwifi/fw/runtime.h   |   1 -
 drivers/net/wireless/intel/iwlwifi/iwl-config.h   |   5 +-
 drivers/net/wireless/intel/iwlwifi/iwl-eeprom-parse.c |   4 +-
 drivers/net/wireless/intel/iwlwifi/iwl-eeprom-parse.h |   5 +-
 drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c| 354 
+--
 drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h|  56 +
 drivers/net/wireless/intel/iwlwifi/iwl-trans.h|   8 +-
 drivers/net/wireless/intel/iwlwifi/mvm/coex.c |  37 +
 drivers/net/wireless/intel/iwlwifi/mvm/constants.h|   7 ++
 drivers/net/wireless/intel/iwlwifi/mvm/d3.c   |   7 ++
 drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c  |   2 +
 drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c  |  25 ++
 drivers/net/wireless/intel/iwlwifi/mvm/fw.c   |  10 ++-
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c |  33 
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h  | 101 
+++
 drivers/net/wireless/intel/iwlwifi/mvm/nvm.c  | 208 
+++---
 

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

2018-04-20 Thread Arend van Spriel

On 4/20/2018 9:21 AM, Sebastian Gottschall wrote:



Yes this is WIFI chip set level power-save(based on idleness) and not
related to protocol power save. FW will turn off/scale down the
resources(clock/rails) based on opportunity(when ever idle mode is
detected). This power save is mostly done in disconnected state. I am
not really sure when framework/user-space triggers power-save
config(iw dev  set power_save on/off). Then doing this from
user-space will be unnecessarily toggling this config or may not be
setting at disconnected state.

I think that 'set power_save' commands affects struct
ieee80211_bss_conf::ps parameter and I don't think it should be used in
this case. We already have ath10k_config_ps() for 802.11 level of power
saving.

Arend again proposed runtime-pm with which I'm not very familiar. But
why would we want to disable this? Doesn't it make sense to have this
feature always enabled to save power? wcn3990 is a chip for a mobile
device anyway.

it might be made for mobile devices but who knows how it is used by the
market.


Reading the explanation above it does not make sense to use runtime-pm. 
That would only come into play if the host driver would actually control 
the resources being turned off/scaled down.


So this is purely reducing power-consumption of the chip. However, it 
would be good to know the consequences in terms of responsiveness to 
firmware commands for instance when requesting a scan operation. Another 
thing to consider is to provide user-space with possibility to change 
this configuration (maybe through debugfs?).


Regards,
Arend


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

2018-04-20 Thread Sebastian Gottschall



Yes this is WIFI chip set level power-save(based on idleness) and not
related to protocol power save. FW will turn off/scale down the
resources(clock/rails) based on opportunity(when ever idle mode is
detected). This power save is mostly done in disconnected state. I am
not really sure when framework/user-space triggers power-save
config(iw dev  set power_save on/off). Then doing this from
user-space will be unnecessarily toggling this config or may not be
setting at disconnected state.

I think that 'set power_save' commands affects struct
ieee80211_bss_conf::ps parameter and I don't think it should be used in
this case. We already have ath10k_config_ps() for 802.11 level of power
saving.

Arend again proposed runtime-pm with which I'm not very familiar. But
why would we want to disable this? Doesn't it make sense to have this
feature always enabled to save power? wcn3990 is a chip for a mobile
device anyway.
it might be made for mobile devices but who knows how it is used by the 
market.


Sebastian




--
Mit freundlichen Grüssen / Regards

Sebastian Gottschall / CTO

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



ath9k and AR9220 (Mikrotik R52N) initialization error on old small router (Asus WL-500g Premium v1)

2018-04-20 Thread Anichang
Hi,

I'm having issues with a Mikrotik R52N mini-pci board (AR9220) on the old Asus 
WL-500g Premium v1 and Openwrt/LEDE 17.01.4 (compat-wireless-2017-01-31). 

Dmesg reports:

[  942.063606] ssb: PCI: Fixing up device :00:02.0
[  942.073038] ath: phy3: address test failed addr: 0x8000 - wr:0x 
!= rd:0x4555
[  942.081787] ath: phy3: Unable to initialize hardware; initialization status: 
-19
[  942.089390] ath9k :00:02.0: Failed to initialize device

lspci -v

00:02.0 Network controller: Qualcomm Atheros AR922X Wireless Network Adapter 
(rev 01)
Subsystem: Qualcomm Atheros Device 4205
Flags: 66MHz, medium devsel, IRQ 6
Memory at 4000 (32-bit, non-prefetchable) [size=65537]
Memory at  (32-bit, non-prefetchable) [size=2]
Memory at  (32-bit, non-prefetchable) [size=2]
Memory at  (32-bit, non-prefetchable) [size=2]
Memory at  (32-bit, non-prefetchable) [size=2]
Memory at  (32-bit, non-prefetchable) [size=2]
Expansion ROM at  [disabled] [size=2]
Capabilities: [44] Power Management version 2

It looks like an old problem: 
https://forum.openwrt.org/viewtopic.php?pid=97509#p97509 .

I tried to comment out the call to ath9k_hw_chip_test function without results. 
Then I tried to randomly change some addresses I've found up and there but I 
didn't get any clue about the driver so ... here I am.

Any idea?

Thanks

Anichang




Re: [PATCH] reg: Rename confusing 'country IE' in log output

2018-04-20 Thread Johannes Berg
On Fri, 2018-04-20 at 00:32 +0200, Bernhard Gabler wrote:

> looking at the patch, I see more occurences of the outdated "IE" in a 
> constant name and function name:
> 
>  case NL80211_REGDOM_SET_BY_COUNTRY_IE:
> or
>  reg_process_hint_country_ie()


Right. I searched for further strings that would show up to the user,
but didn't see any, but the code still refers to it in many places.

> Would it make sense to likewise fix these (and possibly more) 
> occurrences too, to match the spec from 2016?
> For the sake of readability and consistency of code ...

I dunno. Country IE isn't the only place where "IE" is used, it's even
used in struct names (struct ieee80211_tim_ie, and many others), so I
would think that people who actually work on the code will have to be
aware of the previous wording of "Information Element" (and the
abbreviation IE) anyway. Changing *everything* here to be just _element
instead of _ie or then probably the shorter _elem would IMHO be too much
code churn.

johannes


[RFC 3/6] mac80211: implement station's rssi check using rx data signal

2018-04-20 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
and compare with rssi value given by user. This rssi threshold is
station specific. This event will be useful for the user application
like steering to take decision on the particular station.

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

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index d2279b2..7b3d505 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -803,6 +803,13 @@ enum mac80211_rate_control_flags {
 };
 
 
+/*
+ * 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 03102af..d21f5b1 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1536,6 +1536,66 @@ 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 = >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(>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);
+   }
+   }
+
+   if (sta->rssi_low) {
+   int last_event = sta->last_sta_mon_event_signal;
+   int sig = -ewma_signal_read(>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
 ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
 {
@@ -1591,6 +1651,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(>rx_stats_avg.signal, -status->signal);
+   ieee80211_sta_rx_signal_thold_check(rx);
}
 
if (status->chains) {
@@ -4032,9 +4093,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(>rx_stats_avg.signal,

[RFC 4/6] cfg80211: Add support to config station tx rate threshold

2018-04-20 Thread Tamizh chelvam
This patch adds support for txrate configuration to monitor
station's current txrate strength. This will be useful for
the application like steering, which monitors/requires
station's txrate crossing event. Driver should advertise
NL80211_EXT_FEATURE_STA_MON_TXRATE_CONFIG to enable this
feature. User will set the values in 100kbps using
NL80211_ATTR_STA_MON_LOW_TXRATE_THOLD and
NL80211_ATTR_STA_MON_HIGH_TXRATE_THOLD. And
cfg80211_sta_mon_txrate_notify api introduced to notify
the txrate cross event using NL80211_CMD_NOTIFY_STA_MON.

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

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 2f18794..e934742 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -2984,6 +2984,10 @@ struct cfg80211_external_auth_params {
  * The driver should set %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);
@@ -3293,6 +3297,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);
 };
 
 /*
@@ -5812,6 +5821,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/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 78a019c..120dfb9 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -4263,6 +4263,15 @@ enum nl80211_attr_cqm {
  * @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 station's txrate 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 station's txrate goes greater than this threshold.
+ * @NL80211_ATTR_STA_MON_TXRATE_THRESHOLD_EVENT: TX_RATE threshold cross event
+ * @NL80211_ATTR_STA_MON_TXRATE_LEVEL: Station's tx rate value in 100kbps that
+ * triggered the TX_RATE threshold cross event.
  */
 enum nl80211_attr_sta_mon {
__NL80211_ATTR_STA_MON_INVALID,
@@ -4270,6 +4279,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,
@@ -4302,6 +4315,21 @@ enum nl80211_sta_mon_rssi_threshold_event {
NL80211_STA_MON_RSSI_THRESHOLD_EVENT_HIGH,
 };
 
+/**
+ * enum nl80211_sta_mon_txrate_threshold_event - TX_RATE threshold 

[RFC 0/6] cfg80211/mac80211: enable rssi/txrate threshold config for AP mode

2018-04-20 Thread Tamizh chelvam
This patchsets introduced new NL command and api to support
configuring rssi and txrate for the connected stations.
And implemented new api to notify the threshold cross event.
This will be useful/requires for the user application like steering
to monitor station's activity change.

Tamizh chelvam (6):
  cfg80211: enable setting rssi threshold config for AP mode
  mac80211: enable setting rssi threshold config for AP mode
  mac80211: implement station's rssi check using rx data signal
  cfg80211: Add support to config station tx rate threshold
  mac80211: Add support to configure txrate threshold for station
  mac80211: Implement cqm txrate range check for a station

 include/net/cfg80211.h   |  68 ++-
 include/net/mac80211.h   |  12 ++
 include/uapi/linux/nl80211.h |  95 +
 net/mac80211/cfg.c   | 111 +++
 net/mac80211/rx.c|  65 +-
 net/mac80211/sta_info.h  |  32 +++
 net/mac80211/status.c|  40 +++-
 net/wireless/core.c  |  26 ++-
 net/wireless/core.h  |   6 +-
 net/wireless/nl80211.c   | 462 ++-
 net/wireless/rdev-ops.h  |  48 +
 net/wireless/trace.h | 123 
 12 files changed, 1023 insertions(+), 65 deletions(-)

-- 
1.9.1



[RFC 1/6] cfg80211: enable setting rssi threshold config for AP mode

2018-04-20 Thread Tamizh chelvam
This patch enables setting rssi threshold configuration for
connected stations. This will be useful for the user application
like steering to set and monitor the stations rssi threshold change
value. New NL80211_CMD_STA_MON command introduced to set this
configuration using NL80211_ATTR_STA_MON_RSSI_THOLD and
NL80211_ATTR_STA_MON_RSSI_HYST. And introduce new api
to notify station's rssi goes out of range using
NL80211_CMD_NOTIFY_STA_MON command.

Signed-off-by: Tamizh chelvam 
---
 include/net/cfg80211.h   |  42 -
 include/uapi/linux/nl80211.h |  61 +++
 net/wireless/core.c  |  26 ++-
 net/wireless/core.h  |   6 +-
 net/wireless/nl80211.c   | 388 +--
 net/wireless/rdev-ops.h  |  31 
 net/wireless/trace.h |  74 +
 7 files changed, 565 insertions(+), 63 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 250dac3..2f18794 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -2973,6 +2973,17 @@ 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.)
+ * @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 set %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);
@@ -3274,6 +3285,14 @@ 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);
+   int (*set_sta_mon_rssi_range_config)(struct wiphy *wiphy,
+struct net_device *dev,
+const u8 *addr,
+s32 rssi_low, s32 rssi_high);
 };
 
 /*
@@ -4076,7 +4095,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
@@ -4141,7 +4160,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;
@@ -4212,7 +4231,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)
@@ -5776,6 +5796,22 @@ void cfg80211_cqm_rssi_notify(struct net_device *dev,
  s32 rssi_level, 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_cqm_pktloss_notify - notify userspace about packetloss to peer
  * @dev: network device
  * @peer: peer's MAC address
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 15daf5e..78a019c 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1029,6 +1029,11 @@
  * ht opmode or vht opmode changes using any of _ATTR_SMPS_MODE,
  *  

[RFC 2/6] mac80211: enable setting rssi threshold config for AP mode

2018-04-20 Thread Tamizh chelvam
This patch introduce new api to set rssi single or low/high rssi
threshold value to track the connected stations signal strength.

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

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 85dbaa8..0e2047c 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3705,6 +3705,79 @@ static int ieee80211_set_multicast_to_unicast(struct 
wiphy *wiphy,
return 0;
 }
 
+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(>local->sta_mtx);
+
+   sta = sta_info_get_bss(sdata, peer);
+   if (!sta) {
+   mutex_unlock(>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->rssi_low = 0;
+   sta->rssi_high = 0;
+   sta->last_sta_mon_event_signal = 0;
+unlock:
+   mutex_unlock(>local->sta_mtx);
+   return 0;
+}
+
+static int ieee80211_set_sta_mon_rssi_range_confg(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(>local->sta_mtx);
+
+   sta = sta_info_get_bss(sdata, peer);
+   if (!sta) {
+   mutex_unlock(>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(>local->sta_mtx);
+   return 0;
+}
+
 const struct cfg80211_ops mac80211_config_ops = {
.add_virtual_intf = ieee80211_add_iface,
.del_virtual_intf = ieee80211_del_iface,
@@ -3798,4 +3871,6 @@ static int ieee80211_set_multicast_to_unicast(struct 
wiphy *wiphy,
.del_nan_func = ieee80211_del_nan_func,
.set_multicast_to_unicast = ieee80211_set_multicast_to_unicast,
.tx_control_port = ieee80211_tx_control_port,
+   .set_sta_mon_rssi_config = ieee80211_set_sta_mon_rssi_config,
+   .set_sta_mon_rssi_range_config = ieee80211_set_sta_mon_rssi_range_confg,
 };
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index f64eb86..701eb37 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -481,6 +481,18 @@ 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
+ * @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
  */
 struct sta_info {
/* General information, mostly static */
@@ -581,6 +593,12 @@ struct sta_info {
 
struct cfg80211_chan_def tdls_chandef;
 
+   s32 rssi_thold;
+   u32 rssi_hyst;
+   s32 

[RFC 6/6] mac80211: Implement cqm txrate range check for a station

2018-04-20 Thread Tamizh chelvam
This patch trigger cfg80211_sta_mon_txrate_notify with
the corresponding txrate event when the txrate for a station goes
out of configured range.

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

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 7b3d505..7023f40 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -809,6 +809,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/sta_info.h b/net/mac80211/sta_info.h
index 14431c7..271267d 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -418,6 +418,8 @@ struct ieee80211_sta_rx_stats {
  */
 #define STA_SLOW_THRESHOLD 6000 /* 6 Mbps */
 
+DECLARE_EWMA(sta_txrate, 4, 4)
+
 /**
  * struct sta_info - STA information
  *
@@ -608,6 +610,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 743e89c..6656b04 100644
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -699,6 +699,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, >tx_stats.last_rate, );
+   txrate = cfg80211_calculate_bitrate();
+   ewma_sta_txrate_add(>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(>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)
 {
@@ -748,9 +782,13 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,
 
if (ieee80211_hw_check(>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_txrate_thold_check(sta);
+   }
 
if ((info->flags & IEEE80211_TX_STAT_AMPDU_NO_BACK) &&
(ieee80211_is_data_qos(fc))) {
-- 
1.9.1



[RFC 5/6] mac80211: Add support to configure txrate threshold for station

2018-04-20 Thread Tamizh chelvam
This patch add new api to support to configure low and high txrate
threshold for the connected stations.

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

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 0e2047c..0f06b0b 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3778,6 +3778,41 @@ static int ieee80211_set_sta_mon_rssi_range_confg(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(>local->sta_mtx);
+
+   sta = sta_info_get_bss(sdata, peer);
+   if (!sta) {
+   mutex_unlock(>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;
+   sta->last_txrate_event = 0;
+
+unlock:
+   mutex_unlock(>local->sta_mtx);
+   return 0;
+}
+
 const struct cfg80211_ops mac80211_config_ops = {
.add_virtual_intf = ieee80211_add_iface,
.del_virtual_intf = ieee80211_del_iface,
@@ -3873,4 +3908,5 @@ static int ieee80211_set_sta_mon_rssi_range_confg(struct 
wiphy *wiphy,
.tx_control_port = ieee80211_tx_control_port,
.set_sta_mon_rssi_config = ieee80211_set_sta_mon_rssi_config,
.set_sta_mon_rssi_range_config = ieee80211_set_sta_mon_rssi_range_confg,
+   .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 5d6b763..14431c7 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -496,6 +496,8 @@ struct ieee80211_sta_rx_stats {
  * @count_rx_signal: Number of data frames used in ave_sta_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: Lower txrate threshold for a station to monitor
+ * @txrate_high: Upper txrate threshold for a station to monitor
  */
 struct sta_info {
/* General information, mostly static */
@@ -603,6 +605,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



[PATCH] nl80211: Free connkeys on external authentication failure

2018-04-20 Thread Srinivas Dasari
The failure scenario while processing
NL80211_ATTR_EXTERNAL_AUTH_SUPPORT does not free
the connkeys. This commit addresses the same.

Signed-off-by: Srinivas Dasari 
---
 net/wireless/nl80211.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index ff28f8f..a052693 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -9214,6 +9214,7 @@ static int nl80211_connect(struct sk_buff *skb, struct 
genl_info *info)
 
if (nla_get_flag(info->attrs[NL80211_ATTR_EXTERNAL_AUTH_SUPPORT])) {
if (!info->attrs[NL80211_ATTR_SOCKET_OWNER]) {
+   kzfree(connkeys);
GENL_SET_ERR_MSG(info,
 "external auth requires connection 
ownership");
return -EINVAL;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



Re: Simultaneous 2.4 GHz WiFi and Bluetooth issue on Intel Dual Band Wireless-AC 8260

2018-04-20 Thread Emmanuel Grumbach
Hi,


On Thu, Apr 19, 2018 at 11:46 PM, Nathan Schulte  wrote:
> Hi!
>

[...]

>
> Specifically, when testing with Debian Sid, I am unable to connect to
> 2.4 GHz WiFi and Bluetooth at the same time.  I can successfully use
> both independently, and 5 GHz WiFi and Bluetooth works fine.  It's been
> a number of months, but I believe simultaneous 2.4 GHz and Bluetooth
> worked fine in the past, and has slowly degraded.
>
> Under Windows 10, the hardware appears to work without issue.
> Additionally, I believe I managed to warm-reboot from Windows 10 to
> Linux (with Bluetooth connected), and was able to continue using the
> same 2.4 GHz WiFi and Bluetooth audio sink without issue.

This was reported in the past. Please make sure you have the latest BT
firmware files.
Ubuntu may not be shipping the newest BT firmware files. You can find them here:

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

Specifically, I can see that the BT firmware files were updated not long ago:
https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/commit/?id=9cb49be0eecf1de2c020e9de235a4fb5fd6665d7

Then you'll need a cold reboot.

>
> When blueman-manager isn't hanging (it tends to do that a lot in this
> situation), I am sometimes able to connect to 2.4 GHz WiFi and Bluetooth
> device for a short while before the Bluetooth stack disconnects the
> device.  Usually this requires removing and re-pairing the device.

Regardless of the BT firmware version thing which is a pure Intel
problem, I have heard
about problems in the BT stack itself but I can't help about this.