Update regulatory rules for Kazakhstan (KZ) on 5GHz

2017-06-25 Thread Vasiliy Safronov
Please add support 5ghz for Kazakhstan.
In Kazakhstan there are no restrictions up to 100mW
country KZ: DFS-ETSI
 (2402 - 2482 @ 40), (20)
 (5170 - 5250 @ 80), (20), AUTO-BW
 (5250 - 5330 @ 80), (20), DFS, AUTO-BW
 (5650 - 5730 @ 80), (30), DFS
 (5735 - 5835 @ 80), (30)

http://adilet.zan.kz/rus/docs/P01379_
S 5.282 etc


Re: [[linux-nfc][PATCH v1] 2/6] NFC: nfcst: Add ST NFC Transceiver core framework

2017-06-25 Thread Samuel Ortiz
Hi Shikha,

On Tue, May 02, 2017 at 02:03:39AM -0400, Shikha Singh wrote:
> +static int nfcst_in_send_cmd(struct nfc_digital_dev *ddev,
> +  struct sk_buff *skb,
> +  u16 timeout,
> +  nfc_digital_cmd_complete_t cb,
> +  void *arg)
> +{
> + struct nfcst_context *context = nfc_digital_get_drvdata(ddev);
> + int rc;
> + int len_data_to_tag = 0;
> +
> + if (!context->nfcst_power)
> + return -EIO;
> +
> + /*
> +  * down the semaphore to indicate that last nfcst_in_send_cmd()
> +  * call is pending, If interrupted, WARN and return !
> +  */
> + rc = down_killable(>exchange_lock);
> + if (rc) {
> + WARN(1, "Semaphore wait is interrupted in nfcst_in_send_cmd\n");
> + return rc;
> + }
> +
> + if (context->trig_config) {
> + context->trig_config = false;
> + rc = nfcst_handle_config_fdt(context, false);
> + if (rc) {
> + dev_err(>nfcdev->dev, "config fdt failed from 
> nfcst_in_send_cmd %d\n",
> + rc);
> + return rc;
> + }
> + }
> +
> + switch (context->current_rf_tech) {
> + case NFC_DIGITAL_RF_TECH_106A:
> + len_data_to_tag = skb->len + 1;
> + *skb_put(skb, 1) = context->sendrcv_trflag;
You can't dereference a void pointer. Please fix that as it will most
likely break the build.

Cheers,
Samuel.


[PATCH][-next] ath10k: fix a bunch of spelling mistakes in messages

2017-06-25 Thread Colin King
From: Colin Ian King 

Fix the following spelling mistakes in messages:
  syncronise -> synchronize
  unusally -> unusually
  addrress -> address
  inverval -> interval

Signed-off-by: Colin Ian King 
---
 drivers/net/wireless/ath/ath10k/mac.c | 2 +-
 drivers/net/wireless/ath/ath10k/pci.c | 2 +-
 drivers/net/wireless/ath/ath10k/sdio.c| 4 ++--
 drivers/net/wireless/ath/ath10k/wmi-tlv.c | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 4a71815490ae..55c808f03a84 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -1392,7 +1392,7 @@ static int ath10k_vdev_stop(struct ath10k_vif *arvif)
 
ret = ath10k_vdev_setup_sync(ar);
if (ret) {
-   ath10k_warn(ar, "failed to syncronise setup for vdev %i: %d\n",
+   ath10k_warn(ar, "failed to synchronize setup for vdev %i: %d\n",
arvif->vdev_id, ret);
return ret;
}
diff --git a/drivers/net/wireless/ath/ath10k/pci.c 
b/drivers/net/wireless/ath/ath10k/pci.c
index 4f3f513dac4f..7ebfc409018d 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -469,7 +469,7 @@ static int ath10k_pci_wake_wait(struct ath10k *ar)
while (tot_delay < PCIE_WAKE_TIMEOUT) {
if (ath10k_pci_is_awake(ar)) {
if (tot_delay > PCIE_WAKE_LATE_US)
-   ath10k_warn(ar, "device wakeup took %d ms which 
is unusally long, otherwise it works normally.\n",
+   ath10k_warn(ar, "device wakeup took %d ms which 
is unusually long, otherwise it works normally.\n",
tot_delay / 1000);
return 0;
}
diff --git a/drivers/net/wireless/ath/ath10k/sdio.c 
b/drivers/net/wireless/ath/ath10k/sdio.c
index 9e78fbae8413..859ed870bd97 100644
--- a/drivers/net/wireless/ath/ath10k/sdio.c
+++ b/drivers/net/wireless/ath/ath10k/sdio.c
@@ -1553,7 +1553,7 @@ static int ath10k_sdio_hif_diag_read(struct ath10k *ar, 
u32 address, void *buf,
/* read the data */
ret = ath10k_sdio_read(ar, MBOX_WINDOW_DATA_ADDRESS, buf, buf_len);
if (ret) {
-   ath10k_warn(ar, "failed to read from mbox window data addrress: 
%d\n",
+   ath10k_warn(ar, "failed to read from mbox window data address: 
%d\n",
ret);
return ret;
}
@@ -1592,7 +1592,7 @@ static int ath10k_sdio_hif_diag_write_mem(struct ath10k 
*ar, u32 address,
ret = ath10k_sdio_write(ar, MBOX_WINDOW_DATA_ADDRESS, data, nbytes);
if (ret) {
ath10k_warn(ar,
-   "failed to write 0x%p to mbox window data addrress: 
%d\n",
+   "failed to write 0x%p to mbox window data address: 
%d\n",
data, ret);
return ret;
}
diff --git a/drivers/net/wireless/ath/ath10k/wmi-tlv.c 
b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
index f9188027a6f6..7616c1c4bbd3 100644
--- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c
+++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
@@ -2022,7 +2022,7 @@ ath10k_wmi_tlv_op_gen_sta_keepalive(struct ath10k *ar,
arp->dest_ip4_addr = arg->dest_ip4_addr;
ether_addr_copy(arp->dest_mac_addr.addr, arg->dest_mac_addr);
 
-   ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv sta keepalive vdev %d enabled 
%d method %d inverval %d\n",
+   ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv sta keepalive vdev %d enabled 
%d method %d interval %d\n",
   arg->vdev_id, arg->enabled, arg->method, arg->interval);
return skb;
 }
-- 
2.11.0



Re: pull-request: wireless-drivers-next 2017-06-25

2017-06-25 Thread David Miller
From: Kalle Valo 
Date: Sun, 25 Jun 2017 20:48:36 +0300

> yet another pull request to net-next for 4.13, more info in the signed
> tag below. While doing a test merge on net-next I noticed git doing
> quite a lot of auto-merging, maybe because of mac80211 API changes, but
> luckily no conflicts. But please do let me know if you have any
> problems.

Pulled, thanks Kalle.

> Patchwork shows me that I have over 100 patches still pending for review
> so quite a lot still coming towards you some time next week.

Have fun with that :)


pull-request: wireless-drivers-next 2017-06-25

2017-06-25 Thread Kalle Valo
Hi Dave,

yet another pull request to net-next for 4.13, more info in the signed
tag below. While doing a test merge on net-next I noticed git doing
quite a lot of auto-merging, maybe because of mac80211 API changes, but
luckily no conflicts. But please do let me know if you have any
problems.

Patchwork shows me that I have over 100 patches still pending for review
so quite a lot still coming towards you some time next week.

Kalle

The following changes since commit 63a2f310d040a4e42f92d60762c8965cd6f2a5ed:

  Merge tag 'wireless-drivers-next-for-davem-2017-06-12' of 
git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next 
(2017-06-12 10:14:29 -0400)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git 
tags/wireless-drivers-next-for-davem-2017-06-25

for you to fetch changes up to 52f8c9380f2eb051581628782a4917f2c3f9751f:

  Merge ath-next from 
git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git (2017-06-22 
16:29:52 +0300)


wireless-drivers-next patches for 4.13

New features and bug fixes to quite a few different drivers, but
nothing really special standing out.

What makes me happy that we have now more vendors actively
contributing to upstream drivers. In this pull request we have patches
from Broadcom, Intel, Qualcomm, Realtek and Redpine Signals, and I
still have patches from Marvell and Quantenna pending in patchwork. Now
that's something comparing to how things looked 11 years ago in Jeff
Garzik's "State of the Union: Wireless" email:

https://lkml.org/lkml/2006/1/5/671

Major changes:

wil6210

* add low level RF sector interface via nl80211 vendor commands

* add module parameter ftm_mode to load separate firmware for factory
  testing

* support devices with different PCIe bar size

* add support for PCIe D3hot in system suspend

* remove ioctl interface which should not be in a wireless driver

ath10k

* go back to using dma_alloc_coherent() for firmware scratch memory

* add per chain RSSI reporting

brcmfmac

* add support multi-scheduled scan

* add scheduled scan support for specified BSSIDs

* add support for brcm43430 revision 0

wlcore

* add wil1285 compatible

rsi

* add RS9113 USB support

iwlwifi

* FW API documentation improvements (for tools and htmldoc)

* continuing work for the new A000 family

* bump the maximum supported FW API to 31

* improve the differentiation between 8000, 9000 and A000 families


Adrian Chadd (1):
  ath10k: go back to using dma_alloc_coherent() for firmware scratch memory

Amitkumar Karwar (1):
  rsi: use enum for FSM states

Anilkumar Kolli (1):
  ath10k: add BMI parameters to fix calibration from DT/pre-cal

Arend Van Spriel (3):
  brcmfmac: add support multi-scheduled scan
  brcmfmac: add mutex to protect pno requests
  brcmfmac: add scheduled scan support for specified BSSIDs

Ben Greear (5):
  ath10k: increase BMI timeout
  ath10k: log when longer bmi cmds happen
  ath10k: initialize nbytes to 0
  ath10k: use complete VHT chan width for 160MHz workaround
  ath10k: configure rxnss_override for QCA9984

Beni Lev (1):
  iwlwifi: mvm: add TLV for NAN API differentiation

Binoy Jayan (1):
  mwifiex: Replace semaphore async_sem with mutex

Caesar Wang (1):
  mwifiex: fixes the unexpected be printed log by default

Colin Ian King (3):
  mwifiex: make function mwifiex_ret_pkt_aggr_ctrl static
  qtnfmac: check band before allocating cmd_skb to avoid resource leak
  ath6kl: fix spelling mistake: "Indicat" -> "Indicate"

Dedy Lansky (1):
  wil6210: prevent platform callbacks after uninit

Gustavo A. R. Silva (2):
  ath10k: remove unnecessary code
  wlcore: spi: remove unnecessary variable

Haim Dreyfuss (1):
  iwlwifi: Add fw_name_pre_rf_next_step to support different rf steps

Hamad Kadmany (2):
  wil6210: add option to load FTM FW
  wil6210: Improve AP stop handling

Hans de Goede (1):
  brcmfmac: Use separate firmware for revision 0 of the brcm43430 chip

Johannes Berg (28):
  iwlwifi: mvm: fix endianness in lq_cmd declaration
  iwlwifi: mvm: document which group enums are used with which group ID
  iwlwifi: mvm: use proper sta_addr in firmware API
  iwlwifi: mvm: fix MCC endianness bug
  iwlwifi: mvm: use u8 for reserved fields
  iwlwifi: mvm: disentangle paging command structs
  iwlwifi: mvm: add documentation to some WoWLAN commands
  iwlwifi: mvm: fix some kernel-doc
  iwlwifi: mvm: add documentation links to various fields
  iwlwifi: mvm: disentangle binding command versions
  iwlwifi: mvm: create/name various enums
  iwlwifi: mvm: document structures used by commands
  iwlwifi: mvm: remove unused TX_CMD_NEXT_FRAME_*
  iwlwifi: kernel-doc: make proper links
  iwlwifi: mvm: 

[PATCH v2 05/10] rtlwifi: Update 8723be new phy parameters and its parser.

2017-06-25 Thread Larry Finger
From: Ping-Ke Shih 

There are new PHY table values for the RTL8723BE. The changes require
new parsing code.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
Cc: Yan-Hsuan Chuang 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 
---
v2 - no changes
---
 .../net/wireless/realtek/rtlwifi/rtl8723be/phy.c   | 365 +
 .../net/wireless/realtek/rtlwifi/rtl8723be/table.c | 192 ++-
 .../net/wireless/realtek/rtlwifi/rtl8723be/table.h |  10 +-
 3 files changed, 281 insertions(+), 286 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c
index 9752175cc466..9606641519e7 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c
@@ -152,33 +152,86 @@ bool rtl8723be_phy_rf_config(struct ieee80211_hw *hw)
return rtl8723be_phy_rf6052_config(hw);
 }
 
-static bool _rtl8723be_check_condition(struct ieee80211_hw *hw,
-  const u32  condition)
+static bool _rtl8723be_check_positive(struct ieee80211_hw *hw,
+ const u32 condition1,
+ const u32 condition2)
 {
-   struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
-   struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
-   u32 _board = rtlefuse->board_type; /*need efuse define*/
-   u32 _interface = rtlhal->interface;
-   u32 _platform = 0x08;/*SupportPlatform */
-   u32 cond = condition;
+   struct rtl_priv *rtlpriv = rtl_priv(hw);
+   struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
+   u32 cut_ver = ((rtlhal->version & CHIP_VER_RTL_MASK)
+   >> CHIP_VER_RTL_SHIFT);
+   u32 intf = (rtlhal->interface == INTF_USB ? BIT(1) : BIT(0));
+
+   u8  board_type = ((rtlhal->board_type & BIT(4)) >> 4) << 0 | /* _GLNA */
+((rtlhal->board_type & BIT(3)) >> 3) << 1 | /* _GPA  */
+((rtlhal->board_type & BIT(7)) >> 7) << 2 | /* _ALNA */
+((rtlhal->board_type & BIT(6)) >> 6) << 3 | /* _APA  */
+((rtlhal->board_type & BIT(2)) >> 2) << 4;  /* _BT   */
+
+   u32 cond1 = condition1, cond2 = condition2;
+   u32 driver1 = cut_ver << 24 |   /* CUT ver */
+ 0 << 20 | /* interface 2/2 */
+ 0x04 << 16 |  /* platform */
+ rtlhal->package_type << 12 |
+ intf << 8 |   /* interface 1/2 */
+ board_type;
+
+   u32 driver2 = rtlhal->type_glna <<  0 |
+ rtlhal->type_gpa  <<  8 |
+ rtlhal->type_alna << 16 |
+ rtlhal->type_apa  << 24;
 
-   if (condition == 0xCDCDCDCD)
-   return true;
+   RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
+"===> [8812A] CheckPositive (cond1, cond2) = (0x%X 0x%X)\n",
+cond1, cond2);
+   RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
+"===> [8812A] CheckPositive (driver1, driver2) = (0x%X 
0x%X)\n",
+driver1, driver2);
 
-   cond = condition & 0xFF;
-   if ((_board & cond) == 0 && cond != 0x1F)
-   return false;
+   RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
+"  (Platform, Interface) = (0x%X, 0x%X)\n", 0x04, intf);
+   RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
+"  (Board, Package) = (0x%X, 0x%X)\n",
+rtlhal->board_type, rtlhal->package_type);
 
-   cond = condition & 0xFF00;
-   cond = cond >> 8;
-   if ((_interface & cond) == 0 && cond != 0x07)
-   return false;
+   /*== Value Defined Check ===*/
+   /*QFN Type [15:12] and Cut Version [27:24] need to do value check*/
 
-   cond = condition & 0xFF;
-   cond = cond >> 16;
-   if ((_platform & cond) == 0 && cond != 0x0F)
+   if (((cond1 & 0xF000) != 0) && ((cond1 & 0xF000) !=
+   (driver1 & 0xF000)))
return false;
-   return true;
+   if (((cond1 & 0x0F00) != 0) && ((cond1 & 0x0F00) !=
+   (driver1 & 0x0F00)))
+   return false;
+
+   /*=== Bit Defined Check */
+   /* We don't care [31:28] */
+
+   cond1   &= 0x00FF0FFF;
+   driver1 &= 0x00FF0FFF;
+
+   if ((cond1 & driver1) == cond1) {
+   u32 mask = 0;
+
+   if ((cond1 & 0x0F) == 0) /* BoardType is DONTCARE*/
+   return true;
+
+   if ((cond1 & BIT(0)) != 0) /*GLNA*/
+   mask |= 0x00FF;
+   if ((cond1 & BIT(1)) != 0) 

[PATCH v2 09/10] rtlwifi: use debugfs to debug.

2017-06-25 Thread Larry Finger
From: Ping-Ke Shih 

Use debugfs to dump register and btcoex status.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
Cc: Yan-Hsuan Chuang 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 
---
v2 - no changes
---
 drivers/net/wireless/realtek/rtlwifi/base.c|   6 +
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c   |   3 +-
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.h   |   3 +-
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.c   |   6 +
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.h   |   1 +
 drivers/net/wireless/realtek/rtlwifi/debug.c   | 439 +
 drivers/net/wireless/realtek/rtlwifi/debug.h   |  12 +
 drivers/net/wireless/realtek/rtlwifi/pci.c |   6 +
 drivers/net/wireless/realtek/rtlwifi/wifi.h|   9 +
 9 files changed, 483 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index 464f14450f75..40c6fbc05c14 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -2453,6 +2453,9 @@ static int __init rtl_core_module_init(void)
if (rtl_rate_control_register())
pr_err("rtl: Unable to register rtl_rc, use default RC !!\n");
 
+   /* add debugfs */
+   rtl_debugfs_add_topdir();
+
/* init some global vars */
INIT_LIST_HEAD(_global_var.glb_priv_list);
spin_lock_init(_global_var.glb_list_lock);
@@ -2464,6 +2467,9 @@ static void __exit rtl_core_module_exit(void)
 {
/*RC*/
rtl_rate_control_unregister();
+
+   /* remove debugfs */
+   rtl_debugfs_remove_topdir();
 }
 
 module_init(rtl_core_module_init);
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index c1eacd8352a2..e4f0d4710fb4 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -1504,7 +1504,8 @@ void exhalbtc_set_single_ant_path(u8 single_ant_path)
gl_bt_coexist.board_info.single_ant_path = single_ant_path;
 }
 
-void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist)
+void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist,
+  struct seq_file *m)
 {
if (!halbtc_is_bt_coexist_available(btcoexist))
return;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
index f9b87c12db09..53aeb669cc63 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
@@ -626,7 +626,8 @@ void exhalbtc_update_min_bt_rssi(s8 bt_rssi);
 void exhalbtc_set_bt_exist(bool bt_exist);
 void exhalbtc_set_chip_type(u8 chip_type);
 void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num);
-void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist);
+void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist,
+  struct seq_file *m);
 void exhalbtc_signal_compensation(struct btc_coexist *btcoexist,
  u8 *rssi_wifi, u8 *rssi_bt);
 void exhalbtc_lps_leave(struct btc_coexist *btcoexist);
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
index 7d296a401b6f..4d9e33078d4f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
@@ -52,8 +52,14 @@ static struct rtl_btc_ops rtl_btc_operation = {
.btc_is_bt_ctrl_lps = rtl_btc_is_bt_ctrl_lps,
.btc_is_bt_lps_on = rtl_btc_is_bt_lps_on,
.btc_get_ampdu_cfg = rtl_btc_get_ampdu_cfg,
+   .btc_display_bt_coex_info = rtl_btc_display_bt_coex_info,
 };
 
+void rtl_btc_display_bt_coex_info(struct rtl_priv *rtlpriv, struct seq_file *m)
+{
+   exhalbtc_display_bt_coex_info(_bt_coexist, m);
+}
+
 void rtl_btc_record_pwr_mode(struct rtl_priv *rtlpriv, u8 *buf, u8 len)
 {
u8 safe_len;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
index ac1253c46f44..40f1ce8c8a06 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
@@ -44,6 +44,7 @@ bool rtl_btc_is_limited_dig(struct rtl_priv *rtlpriv);
 bool rtl_btc_is_disable_edca_turbo(struct rtl_priv *rtlpriv);
 bool rtl_btc_is_bt_disabled(struct rtl_priv *rtlpriv);
 void rtl_btc_special_packet_notify(struct rtl_priv *rtlpriv, u8 pkt_type);
+void rtl_btc_display_bt_coex_info(struct rtl_priv *rtlpriv, struct seq_file 
*m);
 

[PATCH v2 07/10] rtlwifi: Uses addr1 instead DA to determine broadcast and multicast addr.

2017-06-25 Thread Larry Finger
From: Ping-Ke Shih 

We should check addr1 to indicate a packet as broadcast or multicast
in tx desc. An obvious example, a STA transmit an *unicast* ARP packet
where addr1 and DA are the addresses of AP and broadcast respectively.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
Cc: Yan-Hsuan Chuang 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 
---
v2 - no changes
---
 drivers/net/wireless/realtek/rtlwifi/base.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index 7aa3c39c9c5c..464f14450f75 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -1166,9 +1166,9 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw,
}
}
 
-   if (is_multicast_ether_addr(ieee80211_get_DA(hdr)))
+   if (is_multicast_ether_addr(hdr->addr1))
tcb_desc->multicast = 1;
-   else if (is_broadcast_ether_addr(ieee80211_get_DA(hdr)))
+   else if (is_broadcast_ether_addr(hdr->addr1))
tcb_desc->broadcast = 1;
 
_rtl_txrate_selectmode(hw, sta, tcb_desc);
-- 
2.12.3



[PATCH v2 01/10] rtlwifi: Fill in_4way field by driver

2017-06-25 Thread Larry Finger
From: Ping-Ke Shih 

Because it isn't always correct to use EAPOL to check 4-way,
we add a timer to handle exception.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
Cc: Yan-Hsuan Chuang 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 
---
v2 - no changes
---
 drivers/net/wireless/realtek/rtlwifi/base.c | 11 +++
 drivers/net/wireless/realtek/rtlwifi/core.c |  2 ++
 drivers/net/wireless/realtek/rtlwifi/wifi.h |  3 +++
 3 files changed, 16 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index bd9ae07647e1..7aa3c39c9c5c 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -1408,6 +1408,11 @@ u8 rtl_is_special_data(struct ieee80211_hw *hw, struct 
sk_buff *skb, u8 is_tx,
 
return true;
} else if (ETH_P_PAE == ether_type) {
+   /* EAPOL is seens as in-4way */
+   rtlpriv->btcoexist.btc_info.in_4way = true;
+   rtlpriv->btcoexist.btc_info.in_4way_ts = jiffies;
+   rtlpriv->btcoexist.btc_info.in_4way_ts = jiffies;
+
RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
 "802.1X %s EAPOL pkt!!\n", (is_tx) ? "Tx" : "Rx");
 
@@ -1959,6 +1964,12 @@ void rtl_watchdog_wq_callback(void *data)
if (rtlpriv->cfg->ops->get_btc_status())
rtlpriv->btcoexist.btc_ops->btc_periodical(rtlpriv);
 
+   if (rtlpriv->btcoexist.btc_info.in_4way) {
+   if (time_after(jiffies, rtlpriv->btcoexist.btc_info.in_4way_ts +
+  msecs_to_jiffies(IN_4WAY_TIMEOUT_TIME)))
+   rtlpriv->btcoexist.btc_info.in_4way = false;
+   }
+
rtlpriv->link_info.bcn_rx_inperiod = 0;
 
/* <6> scan list */
diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c 
b/drivers/net/wireless/realtek/rtlwifi/core.c
index b0ad061048c5..c53cbf3d52bd 100644
--- a/drivers/net/wireless/realtek/rtlwifi/core.c
+++ b/drivers/net/wireless/realtek/rtlwifi/core.c
@@ -1505,6 +1505,8 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum 
set_key_cmd cmd,
u8 mac_addr[ETH_ALEN];
u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
 
+   rtlpriv->btcoexist.btc_info.in_4way = false;
+
if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) {
RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
 "not open hw encryption\n");
diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h 
b/drivers/net/wireless/realtek/rtlwifi/wifi.h
index fb1ebb01133f..7ec0d502a0d9 100644
--- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
+++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
@@ -2477,6 +2477,8 @@ struct rtl_global_var {
spinlock_t glb_list_lock;
 };
 
+#define IN_4WAY_TIMEOUT_TIME   (30 * MSEC_PER_SEC) /* 30 seconds */
+
 struct rtl_btc_info {
u8 bt_type;
u8 btcoexist;
@@ -2485,6 +2487,7 @@ struct rtl_btc_info {
 
u8 ap_num;
bool in_4way;
+   unsigned long in_4way_ts;
 };
 
 struct bt_coexist_info {
-- 
2.12.3



[PATCH v2 06/10] rtlwifi: Rename rtl_desc92_rate to rtl_desc_rate

2017-06-25 Thread Larry Finger
From: Ping-Ke Shih 

This is a common enumeration, so we use a common name.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
Cc: Yan-Hsuan Chuang 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 
---
v2 - no changes
---
 drivers/net/wireless/realtek/rtlwifi/wifi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h 
b/drivers/net/wireless/realtek/rtlwifi/wifi.h
index 77c3b186900e..4c6d01eb065d 100644
--- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
+++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
@@ -592,7 +592,7 @@ enum rtl_hal_state {
_HAL_STATE_START = 1,
 };
 
-enum rtl_desc92_rate {
+enum rtl_desc_rate {
DESC_RATE1M = 0x00,
DESC_RATE2M = 0x01,
DESC_RATE5_5M = 0x02,
-- 
2.12.3



[PATCH v2 08/10] rtlwifi: move IS_HARDWARE_TYPE_xxx checker to wifi.h

2017-06-25 Thread Larry Finger
From: Ping-Ke Shih 

Use rtlpriv instead of rtlhal as argument, so driver and btcoex use
the same definitions.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
Cc: Yan-Hsuan Chuang 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 
---
v2 - no changes
---
 .../realtek/rtlwifi/btcoexist/halbt_precomp.h  | 16 -
 .../net/wireless/realtek/rtlwifi/rtl8192cu/mac.c   |  3 +-
 drivers/net/wireless/realtek/rtlwifi/wifi.h| 42 ++
 3 files changed, 19 insertions(+), 42 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbt_precomp.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbt_precomp.h
index 2ac989a4b2bb..02dff4c3f664 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbt_precomp.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbt_precomp.h
@@ -43,22 +43,6 @@
 #define RT_SDIO_INTERFACE  3
 #define DEV_BUS_TYPE   RT_PCI_INTERFACE
 
-/* IC type */
-#define RTL_HW_TYPE(adapter)   (rtl_hal((struct rtl_priv *)adapter)->hw_type)
-
-#define IS_NEW_GENERATION_IC(adapter)  \
-   (RTL_HW_TYPE(adapter) >= HARDWARE_TYPE_RTL8192EE)
-#define IS_HARDWARE_TYPE_8812(adapter) \
-   (RTL_HW_TYPE(adapter) == HARDWARE_TYPE_RTL8812AE)
-#define IS_HARDWARE_TYPE_8821(adapter) \
-   (RTL_HW_TYPE(adapter) == HARDWARE_TYPE_RTL8821AE)
-#define IS_HARDWARE_TYPE_8723A(adapter)\
-   (RTL_HW_TYPE(adapter) == HARDWARE_TYPE_RTL8723AE)
-#define IS_HARDWARE_TYPE_8723B(adapter)\
-   (RTL_HW_TYPE(adapter) == HARDWARE_TYPE_RTL8723BE)
-#define IS_HARDWARE_TYPE_8192E(adapter)\
-   (RTL_HW_TYPE(adapter) == HARDWARE_TYPE_RTL8192EE)
-
 #include "halbtc8192e2ant.h"
 #include "halbtc8723b1ant.h"
 #include "halbtc8723b2ant.h"
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/mac.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/mac.c
index 1b124eade846..5657b1e34ad0 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/mac.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/mac.c
@@ -352,11 +352,10 @@ u32 rtl92c_get_txdma_status(struct ieee80211_hw *hw)
 void rtl92c_enable_interrupt(struct ieee80211_hw *hw)
 {
struct rtl_priv *rtlpriv = rtl_priv(hw);
-   struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
 
-   if (IS_HARDWARE_TYPE_8192CE(rtlhal)) {
+   if (IS_HARDWARE_TYPE_8192CE(rtlpriv)) {
rtl_write_dword(rtlpriv, REG_HIMR, rtlpci->irq_mask[0] &
0x);
rtl_write_dword(rtlpriv, REG_HIMRE, rtlpci->irq_mask[1] &
diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h 
b/drivers/net/wireless/realtek/rtlwifi/wifi.h
index 4c6d01eb065d..f77acd329e0e 100644
--- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
+++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
@@ -314,35 +314,29 @@ enum hardware_type {
HARDWARE_TYPE_RTL8192EE,
HARDWARE_TYPE_RTL8821AE,
HARDWARE_TYPE_RTL8812AE,
+   HARDWARE_TYPE_RTL8822BE,
 
/* keep it last */
HARDWARE_TYPE_NUM
 };
 
-#define IS_HARDWARE_TYPE_8192SU(rtlhal)\
-   (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SU)
-#define IS_HARDWARE_TYPE_8192SE(rtlhal)\
-   (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SE)
-#define IS_HARDWARE_TYPE_8192CE(rtlhal)\
-   (rtlhal->hw_type == HARDWARE_TYPE_RTL8192CE)
-#define IS_HARDWARE_TYPE_8192CU(rtlhal)\
-   (rtlhal->hw_type == HARDWARE_TYPE_RTL8192CU)
-#define IS_HARDWARE_TYPE_8192DE(rtlhal)\
-   (rtlhal->hw_type == HARDWARE_TYPE_RTL8192DE)
-#define IS_HARDWARE_TYPE_8192DU(rtlhal)\
-   (rtlhal->hw_type == HARDWARE_TYPE_RTL8192DU)
-#define IS_HARDWARE_TYPE_8723E(rtlhal) \
-   (rtlhal->hw_type == HARDWARE_TYPE_RTL8723E)
-#define IS_HARDWARE_TYPE_8723U(rtlhal) \
-   (rtlhal->hw_type == HARDWARE_TYPE_RTL8723U)
-#defineIS_HARDWARE_TYPE_8192S(rtlhal)  \
-(IS_HARDWARE_TYPE_8192SE(rtlhal) || IS_HARDWARE_TYPE_8192SU(rtlhal))
-#defineIS_HARDWARE_TYPE_8192C(rtlhal)  \
-(IS_HARDWARE_TYPE_8192CE(rtlhal) || IS_HARDWARE_TYPE_8192CU(rtlhal))
-#defineIS_HARDWARE_TYPE_8192D(rtlhal)  \
-(IS_HARDWARE_TYPE_8192DE(rtlhal) || IS_HARDWARE_TYPE_8192DU(rtlhal))
-#defineIS_HARDWARE_TYPE_8723(rtlhal)   \
-(IS_HARDWARE_TYPE_8723E(rtlhal) || IS_HARDWARE_TYPE_8723U(rtlhal))
+#define RTL_HW_TYPE(rtlpriv)   (rtl_hal((struct rtl_priv *)rtlpriv)->hw_type)

[PATCH v2 03/10] rtlwifi: Add board type for 8723be and 8192ee

2017-06-25 Thread Larry Finger
From: Ping-Ke Shih 

With correct board_type, the phy praser can choose correct parameters.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
Cc: Yan-Hsuan Chuang 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 
---
v2 - no changes
---
 drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c | 5 +
 drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c | 7 +++
 2 files changed, 12 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c
index d84ac7adfd82..ef9394be7016 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c
@@ -2133,7 +2133,12 @@ static void _rtl92ee_read_adapter_info(struct 
ieee80211_hw *hw)
if ((*(u8 *)[EEPROM_RF_BOARD_OPTION_92E]) == 0xFF)
rtlefuse->board_type = 0;
 
+   if (rtlpriv->btcoexist.btc_info.btcoexist == 1)
+   rtlefuse->board_type |= BIT(2); /* ODM_BOARD_BT */
+
rtlhal->board_type = rtlefuse->board_type;
+   RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
+"board_type = 0x%x\n", rtlefuse->board_type);
/*parse xtal*/
rtlefuse->crystalcap = hwinfo[EEPROM_XTAL_92E];
if (hwinfo[EEPROM_XTAL_92E] == 0xFF)
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
index 2a7ad5ffe997..0b9366e7acbd 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
@@ -2114,6 +2114,13 @@ static void _rtl8723be_read_adapter_info(struct 
ieee80211_hw *hw,
 rtlefuse->autoload_failflag,
 hwinfo);
 
+   if (rtlpriv->btcoexist.btc_info.btcoexist == 1)
+   rtlefuse->board_type |= BIT(2); /* ODM_BOARD_BT */
+
+   rtlhal->board_type = rtlefuse->board_type;
+   RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
+"board_type = 0x%x\n", rtlefuse->board_type);
+
rtlhal->package_type = _rtl8723be_read_package_type(hw);
 
/* set channel plan from efuse */
-- 
2.12.3



[PATCH v2 10/10] rtlwifi: btcoex: Use seq_file to dump btcoex status

2017-06-25 Thread Larry Finger
From: Ping-Ke Shih 

If we use seq_file to dump status, then we can use 'cat' to access
debugfs.  Other related changes are
1. implement btc_disp_dbg_msg() to access btcoex's common status.
2. remove obsolete field bt_exist

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
Cc: Yan-Hsuan Chuang 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 
---
v2 - remove \r formatting characters as suggested by Joe Perches
---
 .../realtek/rtlwifi/btcoexist/halbtc8192e2ant.c| 202 +++
 .../realtek/rtlwifi/btcoexist/halbtc8192e2ant.h|   3 +-
 .../realtek/rtlwifi/btcoexist/halbtc8723b1ant.c| 269 ++-
 .../realtek/rtlwifi/btcoexist/halbtc8723b1ant.h|   3 +-
 .../realtek/rtlwifi/btcoexist/halbtc8723b2ant.c| 206 +++
 .../realtek/rtlwifi/btcoexist/halbtc8723b2ant.h|   3 +-
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c| 285 +
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.h|   3 +-
 .../realtek/rtlwifi/btcoexist/halbtc8821a2ant.c| 177 ++---
 .../realtek/rtlwifi/btcoexist/halbtc8821a2ant.h|   3 +-
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c   | 130 +-
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.h   |  11 +-
 12 files changed, 663 insertions(+), 632 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8192e2ant.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8192e2ant.c
index 44c25724529e..c0a5faa59c57 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8192e2ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8192e2ant.c
@@ -2704,11 +2704,11 @@ void ex_btc8192e2ant_init_coex_dm(struct btc_coexist 
*btcoexist)
btc8192e2ant_init_coex_dm(btcoexist);
 }
 
-void ex_btc8192e2ant_display_coex_info(struct btc_coexist *btcoexist)
+void ex_btc8192e2ant_display_coex_info(struct btc_coexist *btcoexist,
+  struct seq_file *m)
 {
struct btc_board_info *board_info = >board_info;
struct btc_stack_info *stack_info = >stack_info;
-   struct rtl_priv *rtlpriv = btcoexist->adapter;
u8 u8tmp[4], i, bt_info_ext, ps_tdma_case = 0;
u16 u16tmp[4];
u32 u32tmp[4];
@@ -2719,75 +2719,64 @@ void ex_btc8192e2ant_display_coex_info(struct 
btc_coexist *btcoexist)
u8 wifi_dot11_chnl, wifi_hs_chnl;
u32 fw_ver = 0, bt_patch_ver = 0;
 
-   RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
-"\r\n [BT Coexist info]");
+   seq_puts(m, "\n [BT Coexist info]");
 
if (btcoexist->manual_control) {
-   RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
-"\r\n ===[Under Manual Control]===");
-   RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
-"\r\n ==");
-   }
-
-   if (!board_info->bt_exist) {
-   RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "\r\n BT not exists 
!!!");
-   return;
+   seq_puts(m, "\n ===[Under Manual Control]===");
+   seq_puts(m, "\n ==");
}
 
-   RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
-"\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:",
+   seq_printf(m, "\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:",
   board_info->pg_ant_num, board_info->btdm_ant_num);
 
-   RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "\r\n %-35s = %s / %d",
-"BT stack/ hci ext ver",
+   seq_printf(m, "\n %-35s = %s / %d", "BT stack/ hci ext ver",
   ((stack_info->profile_notified) ? "Yes" : "No"),
   stack_info->hci_version);
 
btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, _patch_ver);
btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, _ver);
-   RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
-"\r\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)",
-"CoexVer/ FwVer/ PatchVer",
-glcoex_ver_date_8192e_2ant, glcoex_ver_8192e_2ant,
-fw_ver, bt_patch_ver, bt_patch_ver);
+   seq_printf(m, "\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)",
+  "CoexVer/ FwVer/ PatchVer",
+  glcoex_ver_date_8192e_2ant, glcoex_ver_8192e_2ant,
+  fw_ver, bt_patch_ver, bt_patch_ver);
 
btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, _hs_on);
btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_DOT11_CHNL,
   _dot11_chnl);
btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_HS_CHNL, _hs_chnl);
-   RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "\r\n %-35s = %d / %d(%d)",
-"Dot11 channel / HsMode(HsChnl)",
-  

[PATCH v2 02/10] rtlwifi: Add BT_MP_INFO to c2h handler.

2017-06-25 Thread Larry Finger
From: Ping-Ke Shih 

We use H2C to ask BT's status, and C2H will return the status.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
Cc: Yan-Hsuan Chuang 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 
---
v2 - no changes
---
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c   | 17 -
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.c   | 28 ++
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.h   |  1 +
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.c|  9 +--
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.c|  9 +--
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.c| 13 +++---
 drivers/net/wireless/realtek/rtlwifi/wifi.h|  2 ++
 7 files changed, 71 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index e6024b013ca5..c1eacd8352a2 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -327,7 +327,22 @@ static void halbtc_aggregation_check(struct btc_coexist 
*btcoexist)
 
 static u32 halbtc_get_bt_patch_version(struct btc_coexist *btcoexist)
 {
-   return 0;
+   struct rtl_priv *rtlpriv = btcoexist->adapter;
+   u8 cmd_buffer[4] = {0};
+   u8 oper_ver = 0;
+   u8 req_num = 0x0E;
+
+   if (btcoexist->bt_info.bt_real_fw_ver)
+   goto label_done;
+
+   cmd_buffer[0] |= (oper_ver & 0x0f); /* Set OperVer */
+   cmd_buffer[0] |= ((req_num << 4) & 0xf0);   /* Set ReqNum */
+   cmd_buffer[1] = 0; /* BT_OP_GET_BT_VERSION = 0 */
+   rtlpriv->cfg->ops->fill_h2c_cmd(rtlpriv->mac80211.hw, 0x67, 4,
+   _buffer[0]);
+
+label_done:
+   return btcoexist->bt_info.bt_real_fw_ver;
 }
 
 u32 halbtc_get_wifi_link_status(struct btc_coexist *btcoexist)
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
index 4366c9817e1e..7d296a401b6f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c
@@ -41,6 +41,7 @@ static struct rtl_btc_ops rtl_btc_operation = {
.btc_periodical = rtl_btc_periodical,
.btc_halt_notify = rtl_btc_halt_notify,
.btc_btinfo_notify = rtl_btc_btinfo_notify,
+   .btc_btmpinfo_notify = rtl_btc_btmpinfo_notify,
.btc_is_limited_dig = rtl_btc_is_limited_dig,
.btc_is_disable_edca_turbo = rtl_btc_is_disable_edca_turbo,
.btc_is_bt_disabled = rtl_btc_is_bt_disabled,
@@ -165,6 +166,33 @@ void rtl_btc_btinfo_notify(struct rtl_priv *rtlpriv, u8 
*tmp_buf, u8 length)
exhalbtc_bt_info_notify(_bt_coexist, tmp_buf, length);
 }
 
+void rtl_btc_btmpinfo_notify(struct rtl_priv *rtlpriv, u8 *tmp_buf, u8 length)
+{
+   u8 extid, seq, len;
+   u16 bt_real_fw_ver;
+   u8 bt_fw_ver;
+
+   if ((length < 4) || (!tmp_buf))
+   return;
+
+   extid = tmp_buf[0];
+   /* not response from BT FW then exit*/
+   if (extid != 1) /* C2H_TRIG_BY_BT_FW = 1 */
+   return;
+
+   len = tmp_buf[1] >> 4;
+   seq = tmp_buf[2] >> 4;
+
+   /* BT Firmware version response */
+   if (seq == 0x0E) {
+   bt_real_fw_ver = tmp_buf[3] | (tmp_buf[4] << 8);
+   bt_fw_ver = tmp_buf[5];
+
+   gl_bt_coexist.bt_info.bt_real_fw_ver = bt_real_fw_ver;
+   gl_bt_coexist.bt_info.bt_fw_ver = bt_fw_ver;
+   }
+}
+
 bool rtl_btc_is_limited_dig(struct rtl_priv *rtlpriv)
 {
return gl_bt_coexist.bt_info.limited_dig;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
index 6fe521cbe7f0..ac1253c46f44 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h
@@ -39,6 +39,7 @@ void rtl_btc_mediastatus_notify(struct rtl_priv *rtlpriv,
 void rtl_btc_periodical(struct rtl_priv *rtlpriv);
 void rtl_btc_halt_notify(void);
 void rtl_btc_btinfo_notify(struct rtl_priv *rtlpriv, u8 *tmpbuf, u8 length);
+void rtl_btc_btmpinfo_notify(struct rtl_priv *rtlpriv, u8 *tmp_buf, u8 length);
 bool rtl_btc_is_limited_dig(struct rtl_priv *rtlpriv);
 bool rtl_btc_is_disable_edca_turbo(struct rtl_priv *rtlpriv);
 bool rtl_btc_is_bt_disabled(struct rtl_priv *rtlpriv);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
index f4ee7906eb20..31a391e9b830 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
@@ -888,6 +888,7 @@ void 

[PATCH v2 04/10] rtlwifi: add amplifier type for 8812ae

2017-06-25 Thread Larry Finger
From: Ping-Ke Shih 

With correct amplifier_type, the phy praser can choose correct parameters.

Signed-off-by: Ping-Ke Shih 
Signed-off-by: Larry Finger 
Cc: Yan-Hsuan Chuang 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 
---
v2 - no changes
---
 .../net/wireless/realtek/rtlwifi/rtl8821ae/hw.c| 41 +-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
index 2bc6bace069c..8f4abb3d7669 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
@@ -2966,6 +2966,44 @@ static void _rtl8812ae_read_pa_type(struct ieee80211_hw 
*hw, u8 *hwinfo,
}
 }
 
+static void _rtl8812ae_read_amplifier_type(struct ieee80211_hw *hw, u8 *hwinfo,
+  bool autoload_fail)
+{
+   struct rtl_priv *rtlpriv = rtl_priv(hw);
+   struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
+
+   u8 ext_type_pa_2g_a  = (hwinfo[0xBD] & BIT(2))  >> 2; /* 0xBD[2] */
+   u8 ext_type_pa_2g_b  = (hwinfo[0xBD] & BIT(6))  >> 6; /* 0xBD[6] */
+   u8 ext_type_pa_5g_a  = (hwinfo[0xBF] & BIT(2))  >> 2; /* 0xBF[2] */
+   u8 ext_type_pa_5g_b  = (hwinfo[0xBF] & BIT(6))  >> 6; /* 0xBF[6] */
+   /* 0xBD[1:0] */
+   u8 ext_type_lna_2g_a = (hwinfo[0xBD] & (BIT(1) | BIT(0))) >> 0;
+   /* 0xBD[5:4] */
+   u8 ext_type_lna_2g_b = (hwinfo[0xBD] & (BIT(5) | BIT(4))) >> 4;
+   /* 0xBF[1:0] */
+   u8 ext_type_lna_5g_a = (hwinfo[0xBF] & (BIT(1) | BIT(0))) >> 0;
+   /* 0xBF[5:4] */
+   u8 ext_type_lna_5g_b = (hwinfo[0xBF] & (BIT(5) | BIT(4))) >> 4;
+
+   _rtl8812ae_read_pa_type(hw, hwinfo, autoload_fail);
+
+   /* [2.4G] Path A and B are both extPA */
+   if ((rtlhal->pa_type_2g & (BIT(5) | BIT(4))) == (BIT(5) | BIT(4)))
+   rtlhal->type_gpa  = ext_type_pa_2g_b  << 2 | ext_type_pa_2g_a;
+
+   /* [5G] Path A and B are both extPA */
+   if ((rtlhal->pa_type_5g & (BIT(1) | BIT(0))) == (BIT(1) | BIT(0)))
+   rtlhal->type_apa  = ext_type_pa_5g_b  << 2 | ext_type_pa_5g_a;
+
+   /* [2.4G] Path A and B are both extLNA */
+   if ((rtlhal->lna_type_2g & (BIT(7) | BIT(3))) == (BIT(7) | BIT(3)))
+   rtlhal->type_glna = ext_type_lna_2g_b << 2 | ext_type_lna_2g_a;
+
+   /* [5G] Path A and B are both extLNA */
+   if ((rtlhal->lna_type_5g & (BIT(7) | BIT(3))) == (BIT(7) | BIT(3)))
+   rtlhal->type_alna = ext_type_lna_5g_b << 2 | ext_type_lna_5g_a;
+}
+
 static void _rtl8821ae_read_pa_type(struct ieee80211_hw *hw, u8 *hwinfo,
bool autoload_fail)
 {
@@ -3114,7 +3152,8 @@ static void _rtl8821ae_read_adapter_info(struct 
ieee80211_hw *hw, bool b_pseudo_
   hwinfo);
 
if (rtlhal->hw_type == HARDWARE_TYPE_RTL8812AE) {
-   _rtl8812ae_read_pa_type(hw, hwinfo, 
rtlefuse->autoload_failflag);
+   _rtl8812ae_read_amplifier_type(hw, hwinfo,
+  rtlefuse->autoload_failflag);
_rtl8812ae_read_bt_coexist_info_from_hwpg(hw,
rtlefuse->autoload_failflag, hwinfo);
} else {
-- 
2.12.3



[PATCH v2 00/10] Set 3 of changes related to updates of btcoexist

2017-06-25 Thread Larry Finger
To get maximum benefit of the recent changes in btcoexist, changes need
to be made in the drivers for the NIC. This is set 3 of those changes.

v2 - remove \r characters as suggested by Joe Perches

Ping-Ke Shih (10):
  rtlwifi: Fill in_4way field by driver
  rtlwifi: Add BT_MP_INFO to c2h handler.
  rtlwifi: Add board type for 8723be and 8192ee
  rtlwifi: add amplifier type for 8812ae
  rtlwifi: Update 8723be new phy parameters and its parser.
  rtlwifi: Rename rtl_desc92_rate to rtl_desc_rate
  rtlwifi: Uses addr1 instead DA to determine broadcast and multicast
addr.
  rtlwifi: move IS_HARDWARE_TYPE_xxx checker to wifi.h
  rtlwifi: use debugfs to debug.
  rtlwifi: btcoex: Use seq_file to dump btcoex status

 drivers/net/wireless/realtek/rtlwifi/base.c|  21 +-
 .../realtek/rtlwifi/btcoexist/halbt_precomp.h  |  16 -
 .../realtek/rtlwifi/btcoexist/halbtc8192e2ant.c| 202 +-
 .../realtek/rtlwifi/btcoexist/halbtc8192e2ant.h|   3 +-
 .../realtek/rtlwifi/btcoexist/halbtc8723b1ant.c| 269 ++---
 .../realtek/rtlwifi/btcoexist/halbtc8723b1ant.h|   3 +-
 .../realtek/rtlwifi/btcoexist/halbtc8723b2ant.c| 206 +-
 .../realtek/rtlwifi/btcoexist/halbtc8723b2ant.h|   3 +-
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c| 285 ++---
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.h|   3 +-
 .../realtek/rtlwifi/btcoexist/halbtc8821a2ant.c| 177 -
 .../realtek/rtlwifi/btcoexist/halbtc8821a2ant.h|   3 +-
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c   | 150 ++-
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.h   |  14 +-
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.c   |  34 ++
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.h   |   2 +
 drivers/net/wireless/realtek/rtlwifi/core.c|   2 +
 drivers/net/wireless/realtek/rtlwifi/debug.c   | 439 +
 drivers/net/wireless/realtek/rtlwifi/debug.h   |  12 +
 drivers/net/wireless/realtek/rtlwifi/pci.c |   6 +
 .../net/wireless/realtek/rtlwifi/rtl8192cu/mac.c   |   3 +-
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.c|   9 +-
 .../net/wireless/realtek/rtlwifi/rtl8192ee/hw.c|   5 +
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.c|   9 +-
 .../net/wireless/realtek/rtlwifi/rtl8723be/hw.c|   7 +
 .../net/wireless/realtek/rtlwifi/rtl8723be/phy.c   | 365 -
 .../net/wireless/realtek/rtlwifi/rtl8723be/table.c | 192 +
 .../net/wireless/realtek/rtlwifi/rtl8723be/table.h |  10 +-
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.c|  13 +-
 .../net/wireless/realtek/rtlwifi/rtl8821ae/hw.c|  41 +-
 drivers/net/wireless/realtek/rtlwifi/wifi.h|  58 +--
 31 files changed, 1588 insertions(+), 974 deletions(-)

-- 
2.12.3



[PATCH] drivers: staging: wilc1000/host_interface.c Fix sparse warning: right shift by bigger than source value

2017-06-25 Thread Guillermo O. Freschi
Shifting by equal to or bigger than the width of a type results in
undefined behavior. By using a wide enough temporary variable the issue
can be avoided.

Signed-off-by: Guillermo O. Freschi 
---
 drivers/staging/wilc1000/host_interface.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index f7c22d7b28d1..ed614698c22c 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -2416,10 +2416,12 @@ static void Handle_SetMulticastFilter(struct wilc_vif 
*vif,
goto ERRORHANDLER;
 
pu8CurrByte = wid.val;
-   *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
-   *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 8) & 0xFF);
-   *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 16) & 0xFF);
-   *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 24) & 0xFF);
+
+   u32 enabled = strHostIfSetMulti->enabled;
+   *pu8CurrByte++ = (enabled & 0xFF);
+   *pu8CurrByte++ = ((enabled >> 8) & 0xFF);
+   *pu8CurrByte++ = ((enabled >> 16) & 0xFF);
+   *pu8CurrByte++ = ((enabled >> 24) & 0xFF);
 
*pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
*pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
-- 
2.11.0



rfkill(8) move and improvements

2017-06-25 Thread Sami Kerola
Hello maintainers and other,

The otherday I ran powertop and it did rfkill to save battery, which was 
particularly annoying because I had not installed rfkill(8) package.  
Fixing the immediate issue was relatively easy, but the ordeal made me 
wonder if this tool could be moved to a package that is installed by 
default to all systems, such as util-linux.

To put money where my mouth is I have done the time consuming bits of the 
move.  Notice that full history of the rfkill project is saved in the git 
branch below, with attribution to original authors and no change to 
copyleft statement.

https://github.com/kerolasa/lelux-utiliteetit/tree/rfkill

But it would not be sufficient to do just the minimal, so I took liberty 
to make few additional changes. These include libsmartcols output, 
bash-completion file, add syslog message when state changes happen, and 
converting unix timestamps in event output to human readable format. 
Perhaps the easiest is to simply to see what I have done something like:

git clone https://github.com/kerolasa/lelux-utiliteetit.git rfkill-proposal
cd rfkill-proposal
./autogen.sh && ./configure && make -j4
git checkout rfkill
./rfkill
./rfkill --help
./rfkill event
man ./sys-utils/rfkill.8
. bash-completion/rfkill
PATH="$PWD:$PATH"
rfkill 
git show origin/rfkill-master..origin/rfkill

What do you think, would the move and proposed updates be ok?

-- 
Sami Kerola
http://www.iki.fi/kerolasa/


[PATCH 19/26] iwlwifi: mvm: support new flush API

2017-06-25 Thread Luca Coelho
From: Mordechai Goodstein 

This new API allows flushing queues based on station ID and TID in A000
devices.  One reason for using this is that tfd_queue_mask is only good
for 32 queues, which is not enough for A000 devices.

Signed-off-by: Sara Sharon 
Signed-off-by: Mordechai Goodstein 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c   | 19 ++--
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h | 14 +-
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h   |  2 +
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c   | 12 +++--
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c   | 51 --
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c| 44 ++-
 6 files changed, 100 insertions(+), 42 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
index 744dc069ff23..c2a1aeef74ec 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
@@ -119,19 +119,30 @@ static ssize_t iwl_dbgfs_tx_flush_write(struct iwl_mvm 
*mvm, char *buf,
size_t count, loff_t *ppos)
 {
int ret;
-   u32 scd_q_msk;
+   u32 flush_arg;
 
if (!iwl_mvm_firmware_running(mvm) ||
mvm->cur_ucode != IWL_UCODE_REGULAR)
return -EIO;
 
-   if (sscanf(buf, "%x", _q_msk) != 1)
+   if (kstrtou32(buf, 0, _arg))
return -EINVAL;
 
-   IWL_ERR(mvm, "FLUSHING queues: scd_q_msk = 0x%x\n", scd_q_msk);
+   if (iwl_mvm_has_new_tx_api(mvm)) {
+   IWL_DEBUG_TX_QUEUES(mvm,
+   "FLUSHING all tids queues on sta_id = %d\n",
+   flush_arg);
+   mutex_lock(>mutex);
+   ret = iwl_mvm_flush_sta_tids(mvm, flush_arg, 0xFF, 0) ? : count;
+   mutex_unlock(>mutex);
+   return ret;
+   }
+
+   IWL_DEBUG_TX_QUEUES(mvm, "FLUSHING queues mask to flush = 0x%x\n",
+   flush_arg);
 
mutex_lock(>mutex);
-   ret =  iwl_mvm_flush_tx_path(mvm, scd_q_msk, 0) ? : count;
+   ret =  iwl_mvm_flush_tx_path(mvm, flush_arg, 0) ? : count;
mutex_unlock(>mutex);
 
return ret;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h
index 0562ce406249..a37c584b0b48 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h
@@ -846,12 +846,24 @@ enum iwl_dump_control {
  * @flush_ctl: control flags
  * @reserved: reserved
  */
-struct iwl_tx_path_flush_cmd {
+struct iwl_tx_path_flush_cmd_v1 {
__le32 queues_ctl;
__le16 flush_ctl;
__le16 reserved;
 } __packed; /* TX_PATH_FLUSH_CMD_API_S_VER_1 */
 
+/**
+ * struct iwl_tx_path_flush_cmd -- queue/FIFO flush command
+ * @sta_id: station ID to flush
+ * @tid_mask: TID mask to flush
+ * @reserved: reserved
+ */
+struct iwl_tx_path_flush_cmd {
+   __le32 sta_id;
+   __le16 tid_mask;
+   __le16 reserved;
+} __packed; /* TX_PATH_FLUSH_CMD_API_S_VER_2 */
+
 /* Available options for the SCD_QUEUE_CFG HCMD */
 enum iwl_scd_cfg_actions {
SCD_CFG_DISABLE_QUEUE   = 0x0,
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
index 7171928872de..3b1f15873034 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
@@ -1385,6 +1385,8 @@ static inline const char *iwl_mvm_get_tx_fail_reason(u32 
status) { return ""; }
 #endif
 int iwl_mvm_flush_tx_path(struct iwl_mvm *mvm, u32 tfd_msk, u32 flags);
 int iwl_mvm_flush_sta(struct iwl_mvm *mvm, void *sta, bool internal, u32 
flags);
+int iwl_mvm_flush_sta_tids(struct iwl_mvm *mvm, u32 sta_id,
+  u16 tids, u32 flags);
 
 void iwl_mvm_async_handlers_purge(struct iwl_mvm *mvm);
 
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index fc2c607013fb..2e4bfe9f07ec 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -1477,9 +1477,15 @@ int iwl_mvm_enter_d0i3(struct iwl_op_mode *op_mode)
synchronize_net();
 
/* Flush the hw queues, in case something got queued during entry */
-   ret = iwl_mvm_flush_tx_path(mvm, iwl_mvm_flushable_queues(mvm), flags);
-   if (ret)
-   return ret;
+   /* TODO new tx api */
+   if (iwl_mvm_has_new_tx_api(mvm)) {
+   WARN_ONCE(1, "d0i3: Need to implement flush TX queue\n");
+   } else {
+   ret = iwl_mvm_flush_tx_path(mvm, iwl_mvm_flushable_queues(mvm),
+   flags);
+  

[PATCH 17/26] iwlwifi: mvm: set assoc_beacon_arrive_time

2017-06-25 Thread Luca Coelho
From: Avraham Stern 

When updating the mac context after association,
assoc_beacon_arrive_time is not being set, which causes the FW to
set a wrong TSF to the MAC.

Fix this by setting the assoc_beacon_arrive_time when updating the
mac context after association.

Signed-off-by: Avraham Stern 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
index 50a71da2e96e..f06751598fb8 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
@@ -846,6 +846,8 @@ static int iwl_mvm_mac_ctxt_cmd_sta(struct iwl_mvm *mvm,
cpu_to_le64(vif->bss_conf.sync_tsf + dtim_offs);
ctxt_sta->dtim_time =
cpu_to_le32(vif->bss_conf.sync_device_ts + dtim_offs);
+   ctxt_sta->assoc_beacon_arrive_time =
+   cpu_to_le32(vif->bss_conf.sync_device_ts);
 
IWL_DEBUG_INFO(mvm, "DTIM TBTT is 0x%llx/0x%x, offset %d\n",
   le64_to_cpu(ctxt_sta->dtim_tsf),
-- 
2.11.0



[PATCH 06/26] iwlwifi: mvm: disentangle union in TX status struct

2017-06-25 Thread Luca Coelho
From: Johannes Berg 

This improves documentation, since kernel-doc can't deal with the
union well.

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h | 73 ++
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h|  3 +-
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h   |  9 ++-
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c|  3 +-
 4 files changed, 69 insertions(+), 19 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h
index a5a8616dad6f..0562ce406249 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h
@@ -513,7 +513,7 @@ struct agg_tx_status {
 #define IWL_MVM_TX_RES_GET_RA(_ra_tid) ((_ra_tid) >> 4)
 
 /**
- * struct iwl_mvm_tx_resp - notifies that fw is TXing a packet
+ * struct iwl_mvm_tx_resp_v3 - notifies that fw is TXing a packet
  * ( REPLY_TX = 0x1c )
  * @frame_count: 1 no aggregation, >1 aggregation
  * @bt_kill_count: num of times blocked by bluetooth (unused for agg)
@@ -540,7 +540,63 @@ struct agg_tx_status {
  * @tx_queue: TX queue for this response
  * @status: for non-agg:  frame status TX_STATUS_*
  * for agg: status of 1st frame, AGG_TX_STATE_*; other frame status fields
- * follow this one, up to frame_count.
+ * follow this one, up to frame_count. Length in @frame_count.
+ *
+ * After the array of statuses comes the SSN of the SCD. Look at
+ * %iwl_mvm_get_scd_ssn for more details.
+ */
+struct iwl_mvm_tx_resp_v3 {
+   u8 frame_count;
+   u8 bt_kill_count;
+   u8 failure_rts;
+   u8 failure_frame;
+   __le32 initial_rate;
+   __le16 wireless_media_time;
+
+   u8 pa_status;
+   u8 pa_integ_res_a[3];
+   u8 pa_integ_res_b[3];
+   u8 pa_integ_res_c[3];
+   __le16 measurement_req_id;
+   u8 reduced_tpc;
+   u8 reserved;
+
+   __le32 tfd_info;
+   __le16 seq_ctl;
+   __le16 byte_cnt;
+   u8 tlc_info;
+   u8 ra_tid;
+   __le16 frame_ctrl;
+   struct agg_tx_status status[];
+} __packed; /* TX_RSP_API_S_VER_3 */
+
+/**
+ * struct iwl_mvm_tx_resp - notifies that fw is TXing a packet
+ * ( REPLY_TX = 0x1c )
+ * @frame_count: 1 no aggregation, >1 aggregation
+ * @bt_kill_count: num of times blocked by bluetooth (unused for agg)
+ * @failure_rts: num of failures due to unsuccessful RTS
+ * @failure_frame: num failures due to no ACK (unused for agg)
+ * @initial_rate: for non-agg: rate of the successful Tx. For agg: rate of the
+ * Tx of all the batch. RATE_MCS_*
+ * @wireless_media_time: for non-agg: RTS + CTS + frame tx attempts time + ACK.
+ * for agg: RTS + CTS + aggregation tx time + block-ack time.
+ * in usec.
+ * @pa_status: tx power info
+ * @pa_integ_res_a: tx power info
+ * @pa_integ_res_b: tx power info
+ * @pa_integ_res_c: tx power info
+ * @measurement_req_id: tx power info
+ * @reduced_tpc: transmit power reduction used
+ * @reserved: reserved
+ * @tfd_info: TFD information set by the FH
+ * @seq_ctl: sequence control from the Tx cmd
+ * @byte_cnt: byte count from the Tx cmd
+ * @tlc_info: TLC rate info
+ * @ra_tid: bits [3:0] = ra, bits [7:4] = tid
+ * @frame_ctrl: frame control
+ * @tx_queue: TX queue for this response
+ * @status: for non-agg:  frame status TX_STATUS_*
  * For version 6 TX response isn't received for aggregation at all.
  *
  * After the array of statuses comes the SSN of the SCD. Look at
@@ -568,16 +624,9 @@ struct iwl_mvm_tx_resp {
u8 tlc_info;
u8 ra_tid;
__le16 frame_ctrl;
-   union {
-   struct {
-   struct agg_tx_status status;
-   } v3;/* TX_RSP_API_S_VER_3 */
-   struct {
-   __le16 tx_queue;
-   __le16 reserved2;
-   struct agg_tx_status status;
-   } v6;
-   };
+   __le16 tx_queue;
+   __le16 reserved2;
+   struct agg_tx_status status;
 } __packed; /* TX_RSP_API_S_VER_6 */
 
 /**
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
index 7a52fb6b4924..dc613b604914 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
@@ -217,7 +217,8 @@ enum iwl_legacy_cmds {
 
/**
 * @TX_CMD: uses  iwl_tx_cmd or  iwl_tx_cmd_gen2,
-*  response in  iwl_mvm_tx_resp
+*  response in  iwl_mvm_tx_resp or
+*   iwl_mvm_tx_resp_v3
 */
TX_CMD = 0x1c,
 
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
index 0b5e92c1483e..e616472afd45 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
@@ -1296,14 

[PATCH 12/26] iwlwifi: pcie: don't disable bh when handling FW errors

2017-06-25 Thread Luca Coelho
From: Luca Coelho 

When we started using threaded irqs, all the opmode calls were changed
to be called with local_bh disabled.  The reason for this was it was
that mac80211 needs that.  When we are handling FW errors, mac80211 is
not involved, so we don't need it.

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

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
index 6eef2e789426..fa5f39f72d22 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
@@ -1413,11 +1413,9 @@ static void iwl_pcie_irq_handle_error(struct iwl_trans 
*trans)
return;
}
 
-   local_bh_disable();
/* The STATUS_FW_ERROR bit is set in this function. This must happen
 * before we wake up the command caller, to ensure a proper cleanup. */
iwl_trans_fw_error(trans);
-   local_bh_enable();
 
for (i = 0; i < trans->cfg->base_params->num_of_queues; i++) {
if (!trans_pcie->txq[i])
-- 
2.11.0



[PATCH 14/26] iwlwifi: mvm: don't mark TIDs that are not idle wrt BA as inactive

2017-06-25 Thread Luca Coelho
From: Emmanuel Grumbach 

A TID may not have traffic but still have a BA agreement
active (or being setup / torn down) since a BA agreement
can be triggered by a debugfs hook.
Just avoid to consider such a TID as inactive to make the
logic safer.

Signed-off-by: Emmanuel Grumbach 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/utils.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
index e7cc8e05615a..8ba8b71dd1a4 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
@@ -1215,6 +1215,10 @@ static void iwl_mvm_remove_inactive_tids(struct iwl_mvm 
*mvm,
/* If some TFDs are still queued - don't mark TID as inactive */
if (iwl_mvm_tid_queued(mvm, >tid_data[tid]))
tid_bitmap &= ~BIT(tid);
+
+   /* Don't mark as inactive any TID that has an active BA */
+   if (mvmsta->tid_data[tid].state != IWL_AGG_OFF)
+   tid_bitmap &= ~BIT(tid);
}
 
/* If all TIDs in the queue are inactive - mark queue as inactive. */
-- 
2.11.0



[PATCH 11/26] iwlwifi: mvm: fix the recovery flow while connecting

2017-06-25 Thread Luca Coelho
From: Emmanuel Grumbach 

In BSS mode in the disconnection flow, mac80211 removes
the AP station before the vif is set to unassociated.
Our firmware wants it the other way around: first set
the vif as unassociated, and then remove the AP station.

In order to bridge between those two different behaviors,
iwlmvm doesn't remove the station from the firmware when
mac80211 removes it, but only after the vif is set to
unassociated. The implementation is in
iwl_mvm_bss_info_changed_station:

if (assoc state was modified && mvmvif->ap_sta_id is VALID
&& assoc state is now UNASSC)
remove_the_station_from_the_firmware()

During the recovery flow, mac80211 re-adds the AP station
and then reconfigures the vif. Since the vif is not
associated, and then, we enter the if above (which was
intended to be taken in the disconnection flow only) and
remove the station we just added. This defeats the
recovery flow.

Fix this by not removing the AP station in this flow if
we are in recovery flow.

Cc: sta...@vger.kernel.org
Signed-off-by: Emmanuel Grumbach 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 32 ++-
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index d608ce8305c7..d04a88c6c593 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -1988,14 +1988,32 @@ static void iwl_mvm_bss_info_changed_station(struct 
iwl_mvm *mvm,
WARN_ONCE(iwl_mvm_sf_update(mvm, vif, false),
  "Failed to update SF upon disassociation\n");
 
-   /* remove AP station now that the MAC is unassoc */
-   ret = iwl_mvm_rm_sta_id(mvm, vif, mvmvif->ap_sta_id);
-   if (ret)
-   IWL_ERR(mvm, "failed to remove AP station\n");
+   /*
+* If we get an assert during the connection (after the
+* station has been added, but before the vif is set
+* to associated), mac80211 will re-add the station and
+* then configure the vif. Since the vif is not
+* associated, we would remove the station here and
+* this would fail the recovery.
+*/
+   if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART,
+ >status)) {
+   /*
+* Remove AP station now that
+* the MAC is unassoc
+*/
+   ret = iwl_mvm_rm_sta_id(mvm, vif,
+   mvmvif->ap_sta_id);
+   if (ret)
+   IWL_ERR(mvm,
+   "failed to remove AP 
station\n");
+
+   if (mvm->d0i3_ap_sta_id == mvmvif->ap_sta_id)
+   mvm->d0i3_ap_sta_id =
+   IWL_MVM_INVALID_STA;
+   mvmvif->ap_sta_id = IWL_MVM_INVALID_STA;
+   }
 
-   if (mvm->d0i3_ap_sta_id == mvmvif->ap_sta_id)
-   mvm->d0i3_ap_sta_id = IWL_MVM_INVALID_STA;
-   mvmvif->ap_sta_id = IWL_MVM_INVALID_STA;
/* remove quota for this interface */
ret = iwl_mvm_update_quotas(mvm, false, NULL);
if (ret)
-- 
2.11.0



[PATCH 21/26] iwlwifi: mvm: print base HW address during init

2017-06-25 Thread Luca Coelho
From: Luca Coelho 

It's sometimes hard to find out which HW address the iwlwifi device is
using, for instance when reading crouded sniffer logs.  To make it
easier, print out an info level message with the HW address as soon as
we know it.

Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c | 2 ++
 drivers/net/wireless/intel/iwlwifi/mvm/nvm.c   | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
index 070f3dfb94ce..5c08f4d40f6a 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
@@ -640,6 +640,8 @@ static int iwl_set_hw_address(struct iwl_trans *trans,
return -EINVAL;
}
 
+   IWL_INFO(trans, "base HW address: %pM\n", data->hw_addr);
+
return 0;
 }
 
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
index efdcffbaac6f..dac7e542a190 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
@@ -599,6 +599,8 @@ int iwl_mvm_nvm_get_from_fw(struct iwl_mvm *mvm)
goto err_free;
}
 
+   IWL_INFO(trans, "base HW address: %pM\n", mvm->nvm_data->hw_addr);
+
/* Initialize general data */
mvm->nvm_data->nvm_version = le16_to_cpu(rsp->general.nvm_version);
 
-- 
2.11.0



[PATCH 26/26] iwlwifi: mvm: support TX on MONITOR iface

2017-06-25 Thread Luca Coelho
From: Liad Kaufman 

When trying to TX through a monitor interface, the
conditions in iwl_mvm_tx_skb_non_sta() don't match
and the frame tries to go out from an usued TXQ.

Add a check for monitor iface, and use the AUX queue
in such a case.

In non-DQA mode the frame is sent through the
static-allocated queues anyway, so the problem is
in DQA mode only.

Signed-off-by: Liad Kaufman 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
index 157a75394763..c89bb453c496 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
@@ -651,6 +651,9 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct 
sk_buff *skb)
   info.control.vif->type == NL80211_IFTYPE_STATION &&
   queue != mvm->aux_queue) {
queue = IWL_MVM_DQA_BSS_CLIENT_QUEUE;
+   } else if (iwl_mvm_is_dqa_supported(mvm) &&
+  info.control.vif->type == NL80211_IFTYPE_MONITOR) {
+   queue = mvm->aux_queue;
}
}
 
-- 
2.11.0



[PATCH 20/26] iwlwifi: mvm: document assoc_beacon_arrive_time

2017-06-25 Thread Luca Coelho
From: Luca Coelho 

Document the assoc_beacon_arrive_time element in the iwl_mac_data_sta
struct.

Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-mac.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-mac.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-mac.h
index aa5aaf7c940d..1d970bf0d735 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-mac.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-mac.h
@@ -199,6 +199,7 @@ struct iwl_mac_data_ibss {
  * @dtim_reciprocal: 2^32 / dtim_interval , applicable only when associated
  * @listen_interval: in beacon intervals, applicable only when associated
  * @assoc_id: unique ID assigned by the AP during association
+ * @assoc_beacon_arrive_time: TSF of first beacon after association
  */
 struct iwl_mac_data_sta {
__le32 is_assoc;
-- 
2.11.0



[PATCH 15/26] iwlwifi: add a W/A for a scheduler hardware bug

2017-06-25 Thread Luca Coelho
From: Emmanuel Grumbach 

In case we need to move the scheduler write pointer by
steps of 0x40, 0x80 or 0xc0, the scheduler gets stuck.
This leads to hardware error interrupts with status:
0x5A5A5A5A or alike.

In order to work around this, detect in the transport
layer that we are going to hit this case and tell iwlmvm
to increment the sequence number of the packets. This
allows to keep the requirement that the WiFi sequence
number is in sync with the index in the scheduler Tx queue
and it also allows to avoid the problematic sequence.
This means that from time to time, we will start a queue
from ssn + 1, but that shouldn't be a problem since we
don't switch to new queues for AMPDU now that we have
DQA which allows to keep the same queue while toggling
the AMPDU state.

This bug has been fixed on 9000 devices and up.

Signed-off-by: Emmanuel Grumbach 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/iwl-trans.h | 13 +++---
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h   |  2 +-
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c   | 17 ++--
 drivers/net/wireless/intel/iwlwifi/mvm/utils.c | 50 --
 drivers/net/wireless/intel/iwlwifi/pcie/internal.h |  2 +-
 drivers/net/wireless/intel/iwlwifi/pcie/tx.c   | 22 +-
 6 files changed, 72 insertions(+), 34 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
index 2e975c0be045..57db6250a329 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
@@ -482,7 +482,9 @@ struct iwl_trans_txq_scd_cfg {
  * iwl_trans_ac_txq_enable wrapper. fw_alive must have been called before
  * this one. The op_mode must not configure the HCMD queue. The scheduler
  * configuration may be %NULL, in which case the hardware will not be
- * configured. May sleep.
+ * configured. If true is returned, the operation mode needs to increment
+ * the sequence number of the packets routed to this queue because of a
+ * hardware scheduler bug. May sleep.
  * @txq_disable: de-configure a Tx queue to send AMPDUs
  * Must be atomic
  * @txq_set_shared_mode: change Tx queue shared/unshared marking
@@ -544,7 +546,7 @@ struct iwl_trans_ops {
void (*reclaim)(struct iwl_trans *trans, int queue, int ssn,
struct sk_buff_head *skbs);
 
-   void (*txq_enable)(struct iwl_trans *trans, int queue, u16 ssn,
+   bool (*txq_enable)(struct iwl_trans *trans, int queue, u16 ssn,
   const struct iwl_trans_txq_scd_cfg *cfg,
   unsigned int queue_wdg_timeout);
void (*txq_disable)(struct iwl_trans *trans, int queue,
@@ -952,7 +954,7 @@ static inline void iwl_trans_txq_disable(struct iwl_trans 
*trans, int queue,
trans->ops->txq_disable(trans, queue, configure_scd);
 }
 
-static inline void
+static inline bool
 iwl_trans_txq_enable_cfg(struct iwl_trans *trans, int queue, u16 ssn,
 const struct iwl_trans_txq_scd_cfg *cfg,
 unsigned int queue_wdg_timeout)
@@ -961,10 +963,11 @@ iwl_trans_txq_enable_cfg(struct iwl_trans *trans, int 
queue, u16 ssn,
 
if (WARN_ON_ONCE(trans->state != IWL_TRANS_FW_ALIVE)) {
IWL_ERR(trans, "%s bad state = %d\n", __func__, trans->state);
-   return;
+   return false;
}
 
-   trans->ops->txq_enable(trans, queue, ssn, cfg, queue_wdg_timeout);
+   return trans->ops->txq_enable(trans, queue, ssn,
+ cfg, queue_wdg_timeout);
 }
 
 static inline void
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
index e616472afd45..7171928872de 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
@@ -1744,7 +1744,7 @@ static inline bool iwl_mvm_vif_low_latency(struct 
iwl_mvm_vif *mvmvif)
 }
 
 /* hw scheduler queue config */
-void iwl_mvm_enable_txq(struct iwl_mvm *mvm, int queue, int mac80211_queue,
+bool iwl_mvm_enable_txq(struct iwl_mvm *mvm, int queue, int mac80211_queue,
u16 ssn, const struct iwl_trans_txq_scd_cfg *cfg,
unsigned int wdg_timeout);
 int iwl_mvm_tvqm_enable_txq(struct iwl_mvm *mvm, int mac80211_queue,
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
index 0249300c4600..aa41ee8ed916 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
@@ -758,7 +758,7 @@ static int iwl_mvm_sta_alloc_queue(struct iwl_mvm *mvm,
bool using_inactive_queue = false, same_sta = false;
unsigned long disable_agg_tids = 0;
enum iwl_mvm_agg_state queue_state;
-   bool 

[PATCH 22/26] iwlwifi: pcie: reduce unwanted noise in the logs

2017-06-25 Thread Luca Coelho
From: Luca Coelho 

The driver prints "L1 Enabled - LTR Enabled" all the time as dev_info,
which is just useless noise in most cases.  Convert this to
IWL_DEBUG_POWER() so we don't pollute the log unnecessarily but still
can get this info on demand.

Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 106e822308c7..233b6734c237 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -224,9 +224,9 @@ void iwl_pcie_apm_config(struct iwl_trans *trans)
 
pcie_capability_read_word(trans_pcie->pci_dev, PCI_EXP_DEVCTL2, );
trans->ltr_enabled = cap & PCI_EXP_DEVCTL2_LTR_EN;
-   dev_info(trans->dev, "L1 %sabled - LTR %sabled\n",
-(lctl & PCI_EXP_LNKCTL_ASPM_L1) ? "En" : "Dis",
-trans->ltr_enabled ? "En" : "Dis");
+   IWL_DEBUG_POWER(trans, "L1 %sabled - LTR %sabled\n",
+   (lctl & PCI_EXP_LNKCTL_ASPM_L1) ? "En" : "Dis",
+   trans->ltr_enabled ? "En" : "Dis");
 }
 
 /*
-- 
2.11.0



[PATCH 10/26] iwlwifi: mvm: fix nvm_data leak

2017-06-25 Thread Luca Coelho
From: Luca Coelho 

We allocate nvm_data in iwl_mvm_nvm_get_from_fw().  If something goes
wrong after the allocation (i.e. if no valid MAC address is valid), we
should free nvm_data before returning an error.

Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/nvm.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
index ad8bd90deed2..efdcffbaac6f 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
@@ -596,7 +596,7 @@ int iwl_mvm_nvm_get_from_fw(struct iwl_mvm *mvm)
if (!is_valid_ether_addr(mvm->nvm_data->hw_addr)) {
IWL_ERR(trans, "no valid mac address was found\n");
ret = -EINVAL;
-   goto out;
+   goto err_free;
}
 
/* Initialize general data */
@@ -628,7 +628,11 @@ int iwl_mvm_nvm_get_from_fw(struct iwl_mvm *mvm)
mvm->nvm_data->valid_rx_ant & mvm->fw->valid_rx_ant,
rsp->regulatory.lar_enabled && lar_fw_supported);
 
-   ret = 0;
+   iwl_free_resp();
+   return 0;
+
+err_free:
+   kfree(mvm->nvm_data);
 out:
iwl_free_resp();
return ret;
-- 
2.11.0



[PATCH 24/26] iwlwifi: mvm: fix typo in CTDP_CMD_OPERATION_REPORT description

2017-06-25 Thread Luca Coelho
From: Chaya Rachel Ivgi 

Signed-off-by: Chaya Rachel Ivgi 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
index 224d10b1b076..b84e8ddbbbc9 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
@@ -2130,7 +2130,7 @@ struct ct_kill_notif {
 * enum ctdp_cmd_operation - CTDP command operations
 * @CTDP_CMD_OPERATION_START: update the current budget
 * @CTDP_CMD_OPERATION_STOP: stop ctdp
-* @CTDP_CMD_OPERATION_REPORT: get the avgerage budget
+* @CTDP_CMD_OPERATION_REPORT: get the average budget
 */
 enum iwl_mvm_ctdp_cmd_operation {
CTDP_CMD_OPERATION_START= 0x1,
-- 
2.11.0



[PATCH 16/26] iwlwifi: pcie: make iwl_pcie_apm_stop_master() return void

2017-06-25 Thread Luca Coelho
From: Johannes Berg 

Nothing ever checks the return value of iwl_pcie_apm_stop_master(),
so there's no point in it having one - make it return void.

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/pcie/internal.h | 2 +-
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c| 6 ++
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h 
b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
index 4295b8409720..1f4bc933f0f2 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
@@ -779,7 +779,7 @@ void iwl_trans_pcie_handle_stop_rfkill(struct iwl_trans 
*trans,
   bool was_in_rfkill);
 void iwl_pcie_txq_free_tfd(struct iwl_trans *trans, struct iwl_txq *txq);
 int iwl_queue_space(const struct iwl_txq *q);
-int iwl_pcie_apm_stop_master(struct iwl_trans *trans);
+void iwl_pcie_apm_stop_master(struct iwl_trans *trans);
 void iwl_pcie_conf_msix_hw(struct iwl_trans_pcie *trans_pcie);
 int iwl_pcie_txq_init(struct iwl_trans *trans, struct iwl_txq *txq,
  int slots_num, bool cmd_queue);
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 67343b10b0da..106e822308c7 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -448,9 +448,9 @@ static void iwl_pcie_apm_lp_xtal_enable(struct iwl_trans 
*trans)
 ~SHR_APMG_XTAL_CFG_XTAL_ON_REQ);
 }
 
-int iwl_pcie_apm_stop_master(struct iwl_trans *trans)
+void iwl_pcie_apm_stop_master(struct iwl_trans *trans)
 {
-   int ret = 0;
+   int ret;
 
/* stop device's busmaster DMA activity */
iwl_set_bit(trans, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
@@ -462,8 +462,6 @@ int iwl_pcie_apm_stop_master(struct iwl_trans *trans)
IWL_WARN(trans, "Master Disable Timed Out, 100 usec\n");
 
IWL_DEBUG_INFO(trans, "stop master\n");
-
-   return ret;
 }
 
 static void iwl_pcie_apm_stop(struct iwl_trans *trans, bool op_mode_leave)
-- 
2.11.0



[PATCH 02/26] iwlwifi: fix TX tracing for non-linear SKBs

2017-06-25 Thread Luca Coelho
From: Johannes Berg 

When sending non-linear SKBs that should be included in the regular
TX tracing completely (and not be pushed into the tx_data tracing),
the (tracing) code didn't correctly take the fact that they were
non-linear into account and added only the skb head portion.

This probably never really triggered, since those frames we want
traced fully are most likely linear anyway, but the code gets easier
to understand and we lose an argument to the tracing function, so
overall fixing this is better.

Fixes: 206eea783385 ("iwlwifi: pcie: support frag SKBs")
Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 .../net/wireless/intel/iwlwifi/iwl-devtrace-iwlwifi.h | 19 ---
 drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c |  5 ++---
 drivers/net/wireless/intel/iwlwifi/pcie/tx.c  |  5 ++---
 3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-devtrace-iwlwifi.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-devtrace-iwlwifi.h
index f02e2c89abbb..7f16dcce0995 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-devtrace-iwlwifi.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-devtrace-iwlwifi.h
@@ -2,7 +2,7 @@
  *
  * Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2015 Intel Mobile Communications GmbH
- * Copyright(c) 2016Intel Deutschland GmbH
+ * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -91,8 +91,8 @@ TRACE_EVENT(iwlwifi_dev_tx,
TP_PROTO(const struct device *dev, struct sk_buff *skb,
 void *tfd, size_t tfdlen,
 void *buf0, size_t buf0_len,
-void *buf1, size_t buf1_len),
-   TP_ARGS(dev, skb, tfd, tfdlen, buf0, buf0_len, buf1, buf1_len),
+int hdr_len),
+   TP_ARGS(dev, skb, tfd, tfdlen, buf0, buf0_len, hdr_len),
TP_STRUCT__entry(
DEV_ENTRY
 
@@ -105,15 +105,20 @@ TRACE_EVENT(iwlwifi_dev_tx,
 * for the possible padding).
 */
__dynamic_array(u8, buf0, buf0_len)
-   __dynamic_array(u8, buf1, iwl_trace_data(skb) ? 0 : buf1_len)
+   __dynamic_array(u8, buf1, hdr_len > 0 && iwl_trace_data(skb) ?
+   0 : skb->len - hdr_len)
),
TP_fast_assign(
DEV_ASSIGN;
-   __entry->framelen = buf0_len + buf1_len;
+   __entry->framelen = buf0_len;
+   if (hdr_len > 0)
+   __entry->framelen += skb->len - hdr_len;
memcpy(__get_dynamic_array(tfd), tfd, tfdlen);
memcpy(__get_dynamic_array(buf0), buf0, buf0_len);
-   if (!iwl_trace_data(skb))
-   memcpy(__get_dynamic_array(buf1), buf1, buf1_len);
+   if (hdr_len > 0 && !iwl_trace_data(skb))
+   skb_copy_bits(skb, hdr_len,
+ __get_dynamic_array(buf1),
+ skb->len - hdr_len);
),
TP_printk("[%s] TX %.2x (%zu bytes)",
  __get_str(dev), ((u8 *)__get_dynamic_array(buf0))[0],
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
index a0b237b58b3d..a3795ba0d7b9 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
@@ -249,7 +249,7 @@ static int iwl_pcie_gen2_build_amsdu(struct iwl_trans 
*trans,
IEEE80211_CCMP_HDR_LEN : 0;
 
trace_iwlwifi_dev_tx(trans->dev, skb, tfd, sizeof(*tfd),
-_cmd->hdr, start_len, NULL, 0);
+_cmd->hdr, start_len, 0);
 
ip_hdrlen = skb_transport_header(skb) - skb_network_header(skb);
snap_ip_tcp_hdrlen = 8 + ip_hdrlen + tcp_hdrlen(skb);
@@ -467,8 +467,7 @@ struct iwl_tfh_tfd *iwl_pcie_gen2_build_tfd(struct 
iwl_trans *trans,
}
 
trace_iwlwifi_dev_tx(trans->dev, skb, tfd, sizeof(*tfd), _cmd->hdr,
-IWL_FIRST_TB_SIZE + tb1_len,
-skb->data + hdr_len, tb2_len);
+IWL_FIRST_TB_SIZE + tb1_len, hdr_len);
trace_iwlwifi_dev_tx_data(trans->dev, skb, hdr_len);
 
return tfd;
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
index 98cccaeeecdd..be38dd3a6d93 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
@@ -1978,7 +1978,7 @@ static int iwl_fill_data_tbs(struct iwl_trans *trans, 
struct sk_buff *skb,
 iwl_pcie_get_tfd(trans_pcie, txq, 

[PATCH 25/26] iwlwifi: pcie: work around suspend/resume issue

2017-06-25 Thread Luca Coelho
From: Johannes Berg 

In some platforms, having the device enabled with certain radio
frontends causes the platform to not be able to resume properly
from suspend, regardless of the wakeup cause. This was traced to
a hardware issue with the integrated 9000-series A-step variant.
Set the right hardware bit to disable the problematic state.

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/iwl-csr.h|  4 
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 11 +++
 2 files changed, 15 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-csr.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
index 36fb20168598..e239b1d92cf9 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
@@ -153,6 +153,10 @@
 /* GIO Chicken Bits (PCI Express bus link power management) */
 #define CSR_GIO_CHICKEN_BITS(CSR_BASE+0x100)
 
+/* host chicken bits */
+#define CSR_HOST_CHICKEN   (CSR_BASE + 0x204)
+#define CSR_HOST_CHICKEN_PM_IDLE_SRC_DIS_SB_PMEBIT(19)
+
 /* Analog phase-lock-loop configuration  */
 #define CSR_ANA_PLL_CFG (CSR_BASE+0x20c)
 
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 233b6734c237..5778ba2278d1 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -3134,6 +3134,17 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev 
*pdev,
}
}
 
+   /*
+* 9000-series integrated A-step has a problem with suspend/resume
+* and sometimes even causes the whole platform to get stuck. This
+* workaround makes the hardware not go into the problematic state.
+*/
+   if (trans->cfg->integrated &&
+   trans->cfg->device_family == IWL_DEVICE_FAMILY_9000 &&
+   CSR_HW_REV_STEP(trans->hw_rev) == SILICON_A_STEP)
+   iwl_set_bit(trans, CSR_HOST_CHICKEN,
+   CSR_HOST_CHICKEN_PM_IDLE_SRC_DIS_SB_PME);
+
trans->hw_rf_id = iwl_read32(trans, CSR_HW_RF_ID);
 
iwl_pcie_set_interrupt_capa(pdev, trans);
-- 
2.11.0



[PATCH 23/26] iwlwifi: pcie: delete the Tx queue timer earlier upon firmware crash

2017-06-25 Thread Luca Coelho
From: Emmanuel Grumbach 

When the firmware crashes, the transmit queues can't make
any progress. This is why we stop the counter that monitor
the transmit queues' activity.
The call that notifies the error to the op_mode may take
a bit of time, so stop the timer of the transmit queues
earlier.

Signed-off-by: Emmanuel Grumbach 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
index fa5f39f72d22..a5c0f69423d2 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
@@ -1413,16 +1413,16 @@ static void iwl_pcie_irq_handle_error(struct iwl_trans 
*trans)
return;
}
 
-   /* The STATUS_FW_ERROR bit is set in this function. This must happen
-* before we wake up the command caller, to ensure a proper cleanup. */
-   iwl_trans_fw_error(trans);
-
for (i = 0; i < trans->cfg->base_params->num_of_queues; i++) {
if (!trans_pcie->txq[i])
continue;
del_timer(_pcie->txq[i]->stuck_timer);
}
 
+   /* The STATUS_FW_ERROR bit is set in this function. This must happen
+* before we wake up the command caller, to ensure a proper cleanup. */
+   iwl_trans_fw_error(trans);
+
clear_bit(STATUS_SYNC_HCMD_ACTIVE, >status);
wake_up(_pcie->wait_command_queue);
 }
-- 
2.11.0



[PATCH 13/26] iwlwifi: mvm: reset the HW before dumping if HW error is detected

2017-06-25 Thread Luca Coelho
From: Luca Coelho 

If the hardware is stuck, we can't read any of the memory we need to
dump it, so we end up printing only 0xa5a5a5a5, which is useless.

To solve this, poke the hardware by triggering a reset and re-enabling
the clocks if we detect a HW error.

Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/utils.c | 32 ++
 1 file changed, 32 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
index dc8104d846f9..e7cc8e05615a 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
@@ -69,6 +69,7 @@
 #include "iwl-debug.h"
 #include "iwl-io.h"
 #include "iwl-prph.h"
+#include "iwl-csr.h"
 #include "fw-dbg.h"
 #include "mvm.h"
 #include "fw-api-rs.h"
@@ -497,6 +498,7 @@ static void iwl_mvm_dump_lmac_error_log(struct iwl_mvm 
*mvm, u32 base)
 {
struct iwl_trans *trans = mvm->trans;
struct iwl_error_event_table table;
+   u32 val;
 
if (mvm->cur_ucode == IWL_UCODE_INIT) {
if (!base)
@@ -515,6 +517,36 @@ static void iwl_mvm_dump_lmac_error_log(struct iwl_mvm 
*mvm, u32 base)
return;
}
 
+   /* check if there is a HW error */
+   val = iwl_trans_read_mem32(trans, base);
+   if (((val & ~0xf) == 0xa5a5a5a0) || ((val & ~0xf) == 0x5a5a5a50)) {
+   int err;
+
+   IWL_ERR(trans, "HW error, resetting before reading\n");
+
+   /* reset the device */
+   iwl_set_bit(trans, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
+   usleep_range(1000, 2000);
+
+   /* set INIT_DONE flag */
+   iwl_set_bit(trans, CSR_GP_CNTRL,
+   CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
+
+   /* and wait for clock stabilization */
+   if (trans->cfg->device_family == IWL_DEVICE_FAMILY_8000)
+   udelay(2);
+
+   err = iwl_poll_bit(trans, CSR_GP_CNTRL,
+  CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
+  CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
+  25000);
+   if (err < 0) {
+   IWL_DEBUG_INFO(trans,
+  "Failed to reset the card for the 
dump\n");
+   return;
+   }
+   }
+
iwl_trans_read_mem_bytes(trans, base, , sizeof(table));
 
if (ERROR_START_OFFSET <= table.valid * ERROR_ELEM_SIZE) {
-- 
2.11.0



[PATCH 09/26] iwlwifi: remove useless iwl_free_nvm_data() function

2017-06-25 Thread Luca Coelho
From: Luca Coelho 

This function just calls kfree(), so it only obscures the code without
bringing any benefits.  Remove it.

Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/dvm/main.c | 4 ++--
 drivers/net/wireless/intel/iwlwifi/iwl-eeprom-parse.h | 9 -
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c  | 2 +-
 3 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/main.c 
b/drivers/net/wireless/intel/iwlwifi/dvm/main.c
index b49848683587..4c8f9f1a5532 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/main.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/main.c
@@ -1513,7 +1513,7 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct 
iwl_trans *trans,
 out_free_eeprom_blob:
kfree(priv->eeprom_blob);
 out_free_eeprom:
-   iwl_free_nvm_data(priv->nvm_data);
+   kfree(priv->nvm_data);
 out_free_hw:
ieee80211_free_hw(priv->hw);
 out:
@@ -1532,7 +1532,7 @@ static void iwl_op_mode_dvm_stop(struct iwl_op_mode 
*op_mode)
iwl_tt_exit(priv);
 
kfree(priv->eeprom_blob);
-   iwl_free_nvm_data(priv->nvm_data);
+   kfree(priv->nvm_data);
 
/*netif_stop_queue(dev); */
flush_workqueue(priv->workqueue);
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-eeprom-parse.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-eeprom-parse.h
index e04a91d70a15..b33888991b94 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-eeprom-parse.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-eeprom-parse.h
@@ -121,15 +121,6 @@ struct iwl_nvm_data *
 iwl_parse_eeprom_data(struct device *dev, const struct iwl_cfg *cfg,
  const u8 *eeprom, size_t eeprom_size);
 
-/**
- * iwl_free_nvm_data - free NVM data
- * @data: the data to free
- */
-static inline void iwl_free_nvm_data(struct iwl_nvm_data *data)
-{
-   kfree(data);
-}
-
 int iwl_nvm_check_version(struct iwl_nvm_data *data,
  struct iwl_trans *trans);
 
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index 4e66cc662120..fc2c607013fb 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -849,7 +849,7 @@ static void iwl_op_mode_mvm_stop(struct iwl_op_mode 
*op_mode)
iwl_phy_db_free(mvm->phy_db);
mvm->phy_db = NULL;
 
-   iwl_free_nvm_data(mvm->nvm_data);
+   kfree(mvm->nvm_data);
for (i = 0; i < NVM_MAX_NUM_SECTIONS; i++)
kfree(mvm->nvm_sections[i].data);
 
-- 
2.11.0



[PATCH 03/26] iwlwifi: pcie: fix command completion name debug

2017-06-25 Thread Luca Coelho
From: Johannes Berg 

When the command name is printed on command completion, the wrong
group is used, leading to the wrong name being printed. Fix this
by using the group ID without inappropriately mangling it through
iwl_cmd_groupid() - it's already a u8. Also, while at it, use it
from the same place as the command ID, everything else is just
confusing.

Fixes: ab02165ccec4 ("iwlwifi: add wide firmware command infrastructure for TX")
Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/pcie/tx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
index be38dd3a6d93..6b19ccc0ae41 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
@@ -1706,7 +1706,7 @@ void iwl_pcie_hcmd_complete(struct iwl_trans *trans,
 {
struct iwl_rx_packet *pkt = rxb_addr(rxb);
u16 sequence = le16_to_cpu(pkt->hdr.sequence);
-   u8 group_id = iwl_cmd_groupid(pkt->hdr.group_id);
+   u8 group_id;
u32 cmd_id;
int txq_id = SEQ_TO_QUEUE(sequence);
int index = SEQ_TO_INDEX(sequence);
@@ -1732,6 +1732,7 @@ void iwl_pcie_hcmd_complete(struct iwl_trans *trans,
cmd_index = get_cmd_index(txq, index);
cmd = txq->entries[cmd_index].cmd;
meta = >entries[cmd_index].meta;
+   group_id = cmd->hdr.group_id;
cmd_id = iwl_cmd_id(cmd->hdr.cmd, group_id, 0);
 
iwl_pcie_tfd_unmap(trans, meta, txq, index);
-- 
2.11.0



[PATCH 08/26] iwlwifi: document transmit buffer bits better

2017-06-25 Thread Luca Coelho
From: Johannes Berg 

Properly document the transmit buffer bits using an enum and
kernel-doc documentation.

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/iwl-fh.h | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-fh.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-fh.h
index 77be149276b6..66e5db41e559 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-fh.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-fh.h
@@ -6,7 +6,7 @@
  * GPL LICENSE SUMMARY
  *
  * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
- * Copyright(c) 2015 - 2016 Intel Deutschland GmbH
+ * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of version 2 of the GNU General Public License as
@@ -32,7 +32,7 @@
  * BSD LICENSE
  *
  * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
- * Copyright(c) 2015 - 2016 Intel Deutschland GmbH
+ * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -655,6 +655,17 @@ static inline u8 iwl_get_dma_hi_addr(dma_addr_t addr)
 {
return (sizeof(addr) > sizeof(u32) ? upper_32_bits(addr) : 0) & 0xF;
 }
+
+/**
+ * enum iwl_tfd_tb_hi_n_len - TB hi_n_len bits
+ * @TB_HI_N_LEN_ADDR_HI_MSK: high 4 bits (to make it 36) of DMA address
+ * @TB_HI_N_LEN_LEN_MSK: length of the TB
+ */
+enum iwl_tfd_tb_hi_n_len {
+   TB_HI_N_LEN_ADDR_HI_MSK = 0xf,
+   TB_HI_N_LEN_LEN_MSK = 0xfff0,
+};
+
 /**
  * struct iwl_tfd_tb transmit buffer descriptor within transmit frame 
descriptor
  *
@@ -662,8 +673,7 @@ static inline u8 iwl_get_dma_hi_addr(dma_addr_t addr)
  *
  * @lo: low [31:0] portion of the dma address of TX buffer
  * every even is unaligned on 16 bit boundary
- * @hi_n_len 0-3 [35:32] portion of dma
- *  4-15 length of the tx buffer
+ * @hi_n_len:  iwl_tfd_tb_hi_n_len
  */
 struct iwl_tfd_tb {
__le32 lo;
-- 
2.11.0



[PATCH 00/26] iwlwifi: updates intended for v4.13 2017-06-25

2017-06-25 Thread Luca Coelho
From: Luca Coelho 

Hi,

More patches intended for 4.13.  These are the changes:

* Support for a new version of the TX flush FW API;
* Some fixes in monitor interfaces;
* A few fixes in the recovery flows;
* Documentation fixes and FW API struct cleanups;
* Remove some noise from the kernel logs;
* Clean-ups and small fixes here and there.

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

Please review.

Cheers,
Luca.

Avraham Stern (1):
  iwlwifi: mvm: set assoc_beacon_arrive_time

Chaya Rachel Ivgi (1):
  iwlwifi: mvm: fix typo in CTDP_CMD_OPERATION_REPORT description

Emmanuel Grumbach (5):
  iwlwifi: mvm: fix the recovery flow while connecting
  iwlwifi: mvm: don't mark TIDs that are not idle wrt BA as inactive
  iwlwifi: add a W/A for a scheduler hardware bug
  iwlwifi: mvm: reset the fw_dump_desc pointer after ASSERT
  iwlwifi: pcie: delete the Tx queue timer earlier upon firmware crash

Johannes Berg (9):
  iwlwifi: simplify data tracepoint
  iwlwifi: fix TX tracing for non-linear SKBs
  iwlwifi: pcie: fix command completion name debug
  iwlwifi: mvm: docs: fix enum link, provide TX response link
  iwlwifi: mvm: disentangle union in TX status struct
  iwlwifi: mvm: add documentation for enum iwl_debug_cmds
  iwlwifi: document transmit buffer bits better
  iwlwifi: pcie: make iwl_pcie_apm_stop_master() return void
  iwlwifi: pcie: work around suspend/resume issue

Liad Kaufman (2):
  iwlwifi: mvm: fix fw monitor 7000 HW recollecting
  iwlwifi: mvm: support TX on MONITOR iface

Luca Coelho (7):
  iwlwifi: remove useless iwl_free_nvm_data() function
  iwlwifi: mvm: fix nvm_data leak
  iwlwifi: pcie: don't disable bh when handling FW errors
  iwlwifi: mvm: reset the HW before dumping if HW error is detected
  iwlwifi: mvm: document assoc_beacon_arrive_time
  iwlwifi: mvm: print base HW address during init
  iwlwifi: pcie: reduce unwanted noise in the logs

Mordechai Goodstein (1):
  iwlwifi: mvm: support new flush API

 drivers/net/wireless/intel/iwlwifi/dvm/main.c  |  4 +-
 drivers/net/wireless/intel/iwlwifi/iwl-csr.h   |  4 +
 .../net/wireless/intel/iwlwifi/iwl-devtrace-data.h | 11 +--
 .../wireless/intel/iwlwifi/iwl-devtrace-iwlwifi.h  | 19 +++--
 .../net/wireless/intel/iwlwifi/iwl-eeprom-parse.h  |  9 ---
 drivers/net/wireless/intel/iwlwifi/iwl-fh.h| 18 -
 drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c |  2 +
 drivers/net/wireless/intel/iwlwifi/iwl-trans.h | 13 ++--
 drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c   | 19 -
 .../net/wireless/intel/iwlwifi/mvm/fw-api-mac.h|  1 +
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h | 89 ++
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h| 23 +-
 drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c|  6 +-
 drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c  |  2 +
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c  | 32 ++--
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h   | 13 ++--
 drivers/net/wireless/intel/iwlwifi/mvm/nvm.c   | 10 ++-
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c   | 20 +++--
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c   | 68 ++---
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c| 50 +---
 drivers/net/wireless/intel/iwlwifi/mvm/utils.c | 86 +++--
 drivers/net/wireless/intel/iwlwifi/pcie/internal.h |  4 +-
 drivers/net/wireless/intel/iwlwifi/pcie/rx.c   | 10 +--
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c| 23 --
 drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c  |  8 +-
 drivers/net/wireless/intel/iwlwifi/pcie/tx.c   | 33 ++--
 26 files changed, 413 insertions(+), 164 deletions(-)

-- 
2.11.0



[PATCH 04/26] iwlwifi: mvm: docs: fix enum link, provide TX response link

2017-06-25 Thread Luca Coelho
From: Johannes Berg 

Fix the enum link by adding the missing & and provide the link
to the TX response documentation.

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h | 2 +-
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h| 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h
index c30e0e95b0b0..a5a8616dad6f 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h
@@ -488,7 +488,7 @@ enum iwl_tx_agg_status {
 
 /**
  * struct agg_tx_status - per packet TX aggregation status
- * @status: enum iwl_tx_agg_status
+ * @status: See  iwl_tx_agg_status
  * @sequence: Sequence # for this frame's Tx cmd (not SSN!)
  */
 struct agg_tx_status {
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
index cc6af9bd4e10..7a52fb6b4924 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
@@ -216,7 +216,8 @@ enum iwl_legacy_cmds {
FW_GET_ITEM_CMD = 0x1a,
 
/**
-* @TX_CMD: uses  iwl_tx_cmd or  iwl_tx_cmd_gen2
+* @TX_CMD: uses  iwl_tx_cmd or  iwl_tx_cmd_gen2,
+*  response in  iwl_mvm_tx_resp
 */
TX_CMD = 0x1c,
 
-- 
2.11.0



[PATCH 01/26] iwlwifi: simplify data tracepoint

2017-06-25 Thread Luca Coelho
From: Johannes Berg 

There's no need to calculate the data_len outside of the tracepoint,
since it's always skb->len - hdr_len, which are both available inside.
Simplify the callers and move the calculation in.

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/iwl-devtrace-data.h | 11 ++-
 drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c  |  3 +--
 drivers/net/wireless/intel/iwlwifi/pcie/tx.c   |  3 +--
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-devtrace-data.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-devtrace-data.h
index d80312b46f16..a80e4202cd03 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-devtrace-data.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-devtrace-data.h
@@ -35,19 +35,20 @@
 
 TRACE_EVENT(iwlwifi_dev_tx_data,
TP_PROTO(const struct device *dev,
-struct sk_buff *skb,
-u8 hdr_len, size_t data_len),
-   TP_ARGS(dev, skb, hdr_len, data_len),
+struct sk_buff *skb, u8 hdr_len),
+   TP_ARGS(dev, skb, hdr_len),
TP_STRUCT__entry(
DEV_ENTRY
 
-   __dynamic_array(u8, data, iwl_trace_data(skb) ? data_len : 0)
+   __dynamic_array(u8, data,
+   iwl_trace_data(skb) ? skb->len - hdr_len : 0)
),
TP_fast_assign(
DEV_ASSIGN;
if (iwl_trace_data(skb))
skb_copy_bits(skb, hdr_len,
- __get_dynamic_array(data), data_len);
+ __get_dynamic_array(data),
+ skb->len - hdr_len);
),
TP_printk("[%s] TX frame data", __get_str(dev))
 );
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
index 464a435a4440..a0b237b58b3d 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
@@ -469,8 +469,7 @@ struct iwl_tfh_tfd *iwl_pcie_gen2_build_tfd(struct 
iwl_trans *trans,
trace_iwlwifi_dev_tx(trans->dev, skb, tfd, sizeof(*tfd), _cmd->hdr,
 IWL_FIRST_TB_SIZE + tb1_len,
 skb->data + hdr_len, tb2_len);
-   trace_iwlwifi_dev_tx_data(trans->dev, skb, hdr_len,
- skb->len - hdr_len);
+   trace_iwlwifi_dev_tx_data(trans->dev, skb, hdr_len);
 
return tfd;
 
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
index 0a6e36a8a0bf..98cccaeeecdd 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
@@ -1979,8 +1979,7 @@ static int iwl_fill_data_tbs(struct iwl_trans *trans, 
struct sk_buff *skb,
 trans_pcie->tfd_size,
 _cmd->hdr, IWL_FIRST_TB_SIZE + tb1_len,
 skb->data + hdr_len, tb2_len);
-   trace_iwlwifi_dev_tx_data(trans->dev, skb,
- hdr_len, skb->len - hdr_len);
+   trace_iwlwifi_dev_tx_data(trans->dev, skb, hdr_len);
return 0;
 }
 
-- 
2.11.0



Re: mac80211: out of date seq number cause network stall

2017-06-25 Thread 孙建希
hi,

In function `ieee80211_sta_manage_reorder_buf`:

1104 /* frame with out of date sequence number */
1105 if (ieee80211_sn_less(mpdu_seq_num, head_seq_num)) {
1106 dev_kfree_skb(skb);
1107 goto out;
1108 }
1109

head_seq_num will out of oder, in ath9k wds mode.  But i can not find
why will out of order.

[ 1549.043719]  mac80211 mpdu_seq_num: 325  head_seq_num:326
[ 1549.053979]  mac80211 mpdu_seq_num: 325  head_seq_num:1263
[ 1549.072450]  mac80211 mpdu_seq_num: 326  head_seq_num:1263

head_seq_num out of order. Then almost 1000 packet will drop. I have
read function `ieee80211_sta_manage_reorder_buf` and add some debug
info. I suppose this bug is not caused by this function.

I grep all mac80211 code, and there's no code change  head_seq_num.

Please help.

On Sun, Jun 25, 2017 at 1:49 AM, 孙建希  wrote:
> Hi,
>
> I found `head seq number` bigger than all seq num:
>
> [ 3887.972639] ma80211 with out of date seq number: 1296 1297 1889
> [ 3887.977134] ma80211 with out of date seq number: 1296 1298 1889
> [ 3887.983082] ma80211 with out of date seq number: 1296 1299 1889
> [ 3887.988929] ma80211 with out of date seq number: 1296 1300 1889
> [ 3887.994861] ma80211 with out of date seq number: 1296 1301 1889
> [ 3888.000764] ma80211 with out of date seq number: 1296 1302 1889
> [ 3888.006638] ma80211 with out of date seq number: 1296 1303 1889
> [ 3888.012576] ma80211 with out of date seq number: 1296 1304 1889
>
> On Sun, Jun 25, 2017 at 1:21 AM, 孙建希  wrote:
>> Hi,
>>
>> I first find this bug in wds ath9k mode.
>>
>> When use iperf3, so many out of date seq number, in mac80211 function
>> ieee80211_sta_manage_reorder_buf:
>>
>> [ 1248.968407] mac80211 with out of date seq number: 2551 2547 2552
>> [ 1248.972972] mac80211 with out of date seq number: 2551 2548 2552
>> [ 1248.978800] mac80211 with out of date seq number: 2551 2549 2552
>> [ 1248.984760] mac80211 with out of date seq number: 2551 2550 2552
>> [ 1248.990636] mac80211 with out of date seq number: 2551 2551 2552
>>
>>
>> `previous seq number` `current seq number` `head seq num`.
>>
>>
>> when `head seq number` - `current seq num` > 200 . Iperf3 will block.