[PATCH v2] brcmfmac: Fix glom_skb leak in brcmf_sdiod_recv_chain

2017-06-02 Thread Peter S. Housel
An earlier change to this function (3bdae810721b) fixed a leak in the
case of an unsuccessful call to brcmf_sdiod_buffrw(). However, the
glom_skb buffer, used for emulating a scattering read, is never used
or referenced after its contents are copied into the destination
buffers, and therefore always needs to be freed by the end of the
function.

Fixes: 3bdae810721b ("brcmfmac: Fix glob_skb leak in brcmf_sdiod_recv_chain")
Fixes: a413e39a38573 ("brcmfmac: fix brcmf_sdcard_recv_chain() for host without 
sg support")
Signed-off-by: Peter S. Housel 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
index 9b970dc..30fb54e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
@@ -727,15 +727,13 @@ int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev *sdiodev,
return -ENOMEM;
err = brcmf_sdiod_buffrw(sdiodev, SDIO_FUNC_2, false, addr,
 glom_skb);
-   if (err) {
-   brcmu_pkt_buf_free_skb(glom_skb);
-   goto done;
-   }
-
-   skb_queue_walk(pktq, skb) {
-   memcpy(skb->data, glom_skb->data, skb->len);
-   skb_pull(glom_skb, skb->len);
+   if (!err) {
+   skb_queue_walk(pktq, skb) {
+   memcpy(skb->data, glom_skb->data, skb->len);
+   skb_pull(glom_skb, skb->len);
+   }
}
+   brcmu_pkt_buf_free_skb(glom_skb);
} else
err = brcmf_sdiod_sglist_rw(sdiodev, SDIO_FUNC_2, false, addr,
pktq);
-- 
2.7.4



ath9k - Division by zero in kernel (as well as firmware panic)

2017-06-02 Thread Nathan Royce
ODroid XU4

$ uname -a
Linux computer 4.12.0-rc3-dirty #1 SMP Wed May 31 15:02:05 CDT 2017
armv7l GNU/Linux

$ lsusb
...
Bus 001 Device 002: ID 2109:2813 VIA Labs, Inc.
Bus 001 Device 010: ID 0cf3:7015 Qualcomm Atheros Communications
TP-Link TL-WN821N v3 / TL-WN822N v2 802.11n [Atheros AR7010+AR9287]
...

*
Jun 02 16:20:11 computer hostapd[14954]: vwlan0: interface state
COUNTRY_UPDATE->HT_SCAN
Jun 02 16:20:17 computer hostapd[14954]: 20/40 MHz operation not
permitted on channel pri=7 sec=3 based on overlapping BSSes
Jun 02 16:20:18 computer kernel: Division by zero in kernel.
Jun 02 16:20:18 computer kernel: CPU: 1 PID: 14507 Comm: kworker/u16:2
Tainted: GW   4.12.0-rc3-dirty #1
Jun 02 16:20:18 computer kernel: Hardware name: SAMSUNG EXYNOS
(Flattened Device Tree)
Jun 02 16:20:18 computer kernel: Workqueue: phy5 ieee80211_scan_work [mac80211]
Jun 02 16:20:18 computer kernel: [] (unwind_backtrace) from
[] (show_stack+0x10/0x14)
Jun 02 16:20:18 computer kernel: [] (show_stack) from
[] (dump_stack+0x88/0x9c)
Jun 02 16:20:18 computer kernel: [] (dump_stack) from
[] (Ldiv0_64+0x8/0x18)
Jun 02 16:20:18 computer kernel: [] (Ldiv0_64) from
[] (ath9k_get_next_tbtt+0x58/0x5c [ath9k_common])
Jun 02 16:20:18 computer kernel: [] (ath9k_get_next_tbtt
[ath9k_common]) from [] (ath9k_cmn_beacon_config
Jun 02 16:20:18 computer kernel: []
(ath9k_cmn_beacon_config_ap [ath9k_common]) from []
(ath9k_htc_beacon
Jun 02 16:20:18 computer kernel: []
(ath9k_htc_beacon_config_ap [ath9k_htc]) from []
(ath9k_htc_vif_recon
Jun 02 16:20:18 computer kernel: [] (ath9k_htc_vif_reconfig
[ath9k_htc]) from [] (ath9k_htc_sw_scan_compl
Jun 02 16:20:18 computer kernel: []
(ath9k_htc_sw_scan_complete [ath9k_htc]) from []
(__ieee80211_scan_co
Jun 02 16:20:18 computer kernel: []
(__ieee80211_scan_completed [mac80211]) from []
(ieee80211_scan_work+
Jun 02 16:20:18 computer kernel: [] (ieee80211_scan_work
[mac80211]) from [] (process_one_work+0x1d8/0x40
Jun 02 16:20:18 computer kernel: [] (process_one_work) from
[] (worker_thread+0x4c/0x564)
Jun 02 16:20:18 computer kernel: [] (worker_thread) from
[] (kthread+0x14c/0x154)
Jun 02 16:20:18 computer kernel: [] (kthread) from
[] (ret_from_fork+0x14/0x3c)
Jun 02 16:20:18 computer hostapd[14954]: Using interface wlan0 with
hwaddr  and ssid ""
Jun 02 16:20:18 computer kernel: IPv6: ADDRCONF(NETDEV_CHANGE):
vwlan0: link becomes ready
*
This is a new one on me.

The "normal" problem (search shows to be a very old issue) I
consistently (daily or multiple times/day) encounter is:
*
Jun 02 14:55:30 computer kernel: usb 1-1.1: ath: firmware panic!
exccause: 0x000d; pc: 0x0090ae81; badvaddr: 0x10ff4038.
Jun 02 14:55:30 computer kernel: usb 1-1.1: USB disconnect, device number 9
Jun 02 14:55:30 computer systemd-networkd[11959]: vwlan0: Lost carrier
Jun 02 14:55:30 computer kernel: br0: port 2(vwlan0) entered disabled state
Jun 02 14:55:30 computer kernel: wlan0: deauthenticating from
 by local choice (Reason: 3=DEAUTH_LEAVING)
Jun 02 14:55:30 computer kernel: ath: phy4: Failed to wakeup in 500us
Jun 02 14:55:30 computer kernel: ath: phy4: Failed to wakeup in 500us
Jun 02 14:55:30 computer kernel: ath: phy4: Failed to wakeup in 500us
Jun 02 14:55:30 computer kernel: ath: phy4: Failed to wakeup in 500us
Jun 02 14:55:30 computer systemd-networkd[11959]: wlan0: Lost carrier
Jun 02 14:55:30 computer systemd[1]: Stopping A simple WPA encrypted
wireless connection using a static IP...
-- Subject: Unit netctl@wlan0.service has begun shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit netctl@wlan0.service has begun shutting down.
Jun 02 14:55:30 computer kernel: device vwlan0 left promiscuous mode
Jun 02 14:55:30 computer kernel: br0: port 2(vwlan0) entered disabled state
Jun 02 14:55:30 computer audit: ANOM_PROMISCUOUS dev=vwlan0 prom=0
old_prom=256 auid=4294967295 uid=0 gid=0 ses=4294967295
Jun 02 14:55:30 computer hostapd[13218]: vwlan0: AP-STA-DISCONNECTED 
Jun 02 14:55:30 computer hostapd[13218]: Failed to set beacon parameters
Jun 02 14:55:30 computer hostapd[13218]: vwlan0: INTERFACE-DISABLED
Jun 02 14:55:30 computer kernel: usb 1-1.1: ath9k_htc: USB layer deinitialized
Jun 02 14:55:30 computer systemd[1]: Starting Load/Save RF Kill Switch Status...
-- Subject: Unit systemd-rfkill.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-rfkill.service has begun starting up.
Jun 02 14:55:30 computer systemd[1]: Started Load/Save RF Kill Switch Status.
-- Subject: Unit systemd-rfkill.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-rfkill.service has finished starting up.
--
-- The start-up result is done.
Jun 02 14:55:30 computer network[13261]: Stopping network profile 'wlan0'...
Jun 02 14:55:30 computer kernel: usb 1-1.1: new high-speed USB 

[PATCH 2/9] rtlwifi: btcoex: rename ex_halbtc*ant to ex_btc*ant

2017-06-02 Thread Larry Finger
From: Yan-Hsuan Chuang 

These external functions are for BT-coexistence, so remove the "hal"
prefix for consistancy.

Signed-off-by: Yan-Hsuan Chuang 
Signed-off-by: Larry Finger 
Cc: Ping-Ke Shih 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 
---
 .../realtek/rtlwifi/btcoexist/halbtc8192e2ant.h| 32 ++---
 .../realtek/rtlwifi/btcoexist/halbtc8723b1ant.c| 52 +++---
 .../realtek/rtlwifi/btcoexist/halbtc8723b1ant.h| 41 -
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.h| 38 
 .../realtek/rtlwifi/btcoexist/halbtc8821a2ant.h| 24 +-
 5 files changed, 95 insertions(+), 92 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8192e2ant.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8192e2ant.h
index a57d6947eaf7..65502acee52c 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8192e2ant.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8192e2ant.h
@@ -164,20 +164,20 @@ struct coex_sta_8192e_2ant {
 /
  *The following is interface which will notify coex module.
  /
-void ex_halbtc8192e2ant_init_hwconfig(struct btc_coexist *btcoexist);
-void ex_halbtc8192e2ant_init_coex_dm(struct btc_coexist *btcoexist);
-void ex_halbtc8192e2ant_ips_notify(struct btc_coexist *btcoexist, u8 type);
-void ex_halbtc8192e2ant_lps_notify(struct btc_coexist *btcoexist, u8 type);
-void ex_halbtc8192e2ant_scan_notify(struct btc_coexist *btcoexist, u8 type);
-void ex_halbtc8192e2ant_connect_notify(struct btc_coexist *btcoexist, u8 type);
-void ex_halbtc8192e2ant_media_status_notify(struct btc_coexist *btcoexist,
+void ex_btc8192e2ant_init_hwconfig(struct btc_coexist *btcoexist);
+void ex_btc8192e2ant_init_coex_dm(struct btc_coexist *btcoexist);
+void ex_btc8192e2ant_ips_notify(struct btc_coexist *btcoexist, u8 type);
+void ex_btc8192e2ant_lps_notify(struct btc_coexist *btcoexist, u8 type);
+void ex_btc8192e2ant_scan_notify(struct btc_coexist *btcoexist, u8 type);
+void ex_btc8192e2ant_connect_notify(struct btc_coexist *btcoexist, u8 type);
+void ex_btc8192e2ant_media_status_notify(struct btc_coexist *btcoexist,
+u8 type);
+void ex_btc8192e2ant_special_packet_notify(struct btc_coexist *btcoexist,
+  u8 type);
+void ex_btc8192e2ant_bt_info_notify(struct btc_coexist *btcoexist,
+   u8 *tmpbuf, u8 length);
+void ex_btc8192e2ant_stack_operation_notify(struct btc_coexist *btcoexist,
u8 type);
-void ex_halbtc8192e2ant_special_packet_notify(struct btc_coexist *btcoexist,
- u8 type);
-void ex_halbtc8192e2ant_bt_info_notify(struct btc_coexist *btcoexist,
-  u8 *tmpbuf, u8 length);
-void ex_halbtc8192e2ant_stack_operation_notify(struct btc_coexist *btcoexist,
-  u8 type);
-void ex_halbtc8192e2ant_halt_notify(struct btc_coexist *btcoexist);
-void ex_halbtc8192e2ant_periodical(struct btc_coexist *btcoexist);
-void ex_halbtc8192e2ant_display_coex_info(struct btc_coexist *btcoexist);
+void ex_btc8192e2ant_halt_notify(struct btc_coexist *btcoexist);
+void ex_btc8192e2ant_periodical(struct btc_coexist *btcoexist);
+void ex_btc8192e2ant_display_coex_info(struct btc_coexist *btcoexist);
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b1ant.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b1ant.c
index a0f3a18add25..03998d2e9eb8 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b1ant.c
@@ -2390,9 +2390,9 @@ static void halbtc8723b1ant_init_hw_config(struct 
btc_coexist *btcoexist,
 }
 
 /**
- * extern function start with ex_halbtc8723b1ant_
+ * extern function start with ex_btc8723b1ant_
  **/
-void ex_halbtc8723b1ant_power_on_setting(struct btc_coexist *btcoexist)
+void ex_btc8723b1ant_power_on_setting(struct btc_coexist *btcoexist)
 {
struct rtl_priv *rtlpriv = btcoexist->adapter;
struct btc_board_info *board_info = >board_info;
@@ -2462,14 +2462,14 @@ void ex_halbtc8723b1ant_power_on_setting(struct 
btc_coexist *btcoexist)
 }
 
 
-void ex_halbtc8723b1ant_init_hwconfig(struct btc_coexist *btcoexist,
- bool wifi_only)
+void ex_btc8723b1ant_init_hwconfig(struct btc_coexist *btcoexist,
+  bool wifi_only)
 {

[PATCH 9/9] rtlwifi: btcoex: let btcoex get wifi rssi and link status

2017-06-02 Thread Larry Finger
From: Yan-Hsuan Chuang 

Instead of rssi status, the btcoex also needs to get the link status of
the wifi. In addition, some of the rssi status can be merged into link
status.

Signed-off-by: Yan-Hsuan Chuang 
Signed-off-by: Larry Finger 
Cc: Ping-Ke Shih 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 
---
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c   | 358 +++--
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.h   |  32 +-
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.c   |   6 +-
 3 files changed, 292 insertions(+), 104 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index 53a43dfdecba..f00d6e6ab69b 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -36,6 +36,20 @@ u32 btc_dbg_type[BTC_MSG_MAX];
 /***
  * Debug related function
  ***/
+
+const char *const gl_btc_wifi_bw_string[] = {
+   "11bg",
+   "HT20",
+   "HT40",
+   "HT80",
+   "HT160"
+};
+
+const char *const gl_btc_wifi_freq_string[] = {
+   "2.4G",
+   "5G"
+};
+
 static bool halbtc_is_bt_coexist_available(struct btc_coexist *btcoexist)
 {
if (!btcoexist->binded || NULL == btcoexist->adapter)
@@ -54,28 +68,39 @@ static bool halbtc_is_wifi_busy(struct rtl_priv *rtlpriv)
 
 static void halbtc_dbg_init(void)
 {
-   u8 i;
-
-   for (i = 0; i < BTC_MSG_MAX; i++)
-   btc_dbg_type[i] = 0;
-
-   btc_dbg_type[BTC_MSG_INTERFACE] =
-/* INTF_INIT   | */
-/* INTF_NOTIFY | */
-   0;
+}
 
-   btc_dbg_type[BTC_MSG_ALGORITHM] =
-/* ALGO_BT_RSSI_STATE  | */
-/* ALGO_WIFI_RSSI_STATE| */
-/* ALGO_BT_MONITOR | */
-/* ALGO_TRACE  | */
-/* ALGO_TRACE_FW   | */
-/* ALGO_TRACE_FW_DETAIL| */
-/* ALGO_TRACE_FW_EXEC  | */
-/* ALGO_TRACE_SW   | */
-/* ALGO_TRACE_SW_DETAIL| */
-/* ALGO_TRACE_SW_EXEC  | */
-   0;
+/***
+ * helper function
+ ***/
+static bool is_any_client_connect_to_ap(struct btc_coexist *btcoexist)
+{
+   struct rtl_priv *rtlpriv = btcoexist->adapter;
+   struct rtl_mac *mac = rtl_mac(rtlpriv);
+   struct rtl_sta_info *drv_priv;
+   u8 cnt = 0;
+
+   if (mac->opmode == NL80211_IFTYPE_ADHOC ||
+   mac->opmode == NL80211_IFTYPE_MESH_POINT ||
+   mac->opmode == NL80211_IFTYPE_AP) {
+   if (in_interrupt() > 0) {
+   list_for_each_entry(drv_priv, >entry_list,
+   list) {
+   cnt++;
+   }
+   } else {
+   spin_lock_bh(>locks.entry_list_lock);
+   list_for_each_entry(drv_priv, >entry_list,
+   list) {
+   cnt++;
+   }
+   spin_unlock_bh(>locks.entry_list_lock);
+   }
+   }
+   if (cnt > 0)
+   return true;
+   else
+   return false;
 }
 
 static bool halbtc_is_bt40(struct rtl_priv *adapter)
@@ -188,12 +213,14 @@ static void halbtc_leave_lps(struct btc_coexist 
*btcoexist)
   _enable);
 
if (ap_enable) {
-   pr_info("halbtc_leave_lps()<--dont leave lps under AP mode\n");
+   RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_DMESG,
+"%s()<--dont leave lps under AP mode\n", __func__);
return;
}
 
btcoexist->bt_info.bt_ctrl_lps = true;
btcoexist->bt_info.bt_lps_on = false;
+   rtl_lps_leave(rtlpriv->mac80211.hw);
 }
 
 static void halbtc_enter_lps(struct btc_coexist *btcoexist)
@@ -209,12 +236,14 @@ static void halbtc_enter_lps(struct btc_coexist 
*btcoexist)
   _enable);
 
if (ap_enable) {
-   pr_info("halbtc_enter_lps()<--dont enter lps under AP mode\n");
+   RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_DMESG,
+"%s()<--dont enter lps 

[PATCH 6/9] rtlwifi: btcoex: hook external functions for newer chips

2017-06-02 Thread Larry Finger
From: Yan-Hsuan Chuang 

Hook the external functions for newer ICs such as 8821a and 8192e.

Rename ex_halbtc8192e2ant_halt_notify to ex_btc8192e2ant_halt_notify.

Signed-off-by: Yan-Hsuan Chuang 
Signed-off-by: Larry Finger 
Cc: Ping-Ke Shih 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 
---
 .../realtek/rtlwifi/btcoexist/halbtc8192e2ant.c|   2 +-
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c   | 340 +
 2 files changed, 280 insertions(+), 62 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8192e2ant.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8192e2ant.c
index 9015512ed647..44c25724529e 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8192e2ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8192e2ant.c
@@ -3194,7 +3194,7 @@ void ex_btc8192e2ant_bt_info_notify(struct btc_coexist 
*btcoexist,
btc8192e2ant_run_coexist_mechanism(btcoexist);
 }
 
-void ex_halbtc8192e2ant_halt_notify(struct btc_coexist *btcoexist)
+void ex_btc8192e2ant_halt_notify(struct btc_coexist *btcoexist)
 {
struct rtl_priv *rtlpriv = btcoexist->adapter;
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index 8b015e64af49..9832405c5e26 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -225,11 +225,11 @@ static void halbtc_normal_lps(struct btc_coexist 
*btcoexist)
}
 }
 
-static void halbtc_leave_low_power(void)
+static void halbtc_leave_low_power(struct btc_coexist *btcoexist)
 {
 }
 
-static void halbtc_nomal_low_power(void)
+static void halbtc_normal_low_power(struct btc_coexist *btcoexist)
 {
 }
 
@@ -640,6 +640,24 @@ static void halbtc_display_dbg_msg(void *bt_context, u8 
disp_type)
}
 }
 
+bool halbtc_under_ips(struct btc_coexist *btcoexist)
+{
+   struct rtl_priv *rtlpriv = btcoexist->adapter;
+   struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv);
+   enum rf_pwrstate rtstate;
+
+   if (ppsc->inactiveps) {
+   rtstate = ppsc->rfpwr_state;
+
+   if (rtstate != ERFON &&
+   ppsc->rfoff_reason == RF_CHANGE_BY_IPS) {
+   return true;
+   }
+   }
+
+   return false;
+}
+
 /*
  * Extern functions called by other module
  */
@@ -720,38 +738,58 @@ void exhalbtc_pre_load_firmware(struct btc_coexist 
*btcoexist)
 
 void exhalbtc_init_hw_config(struct btc_coexist *btcoexist)
 {
-   struct rtl_priv *rtlpriv = btcoexist->adapter;
-   struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
+   bool wifi_only = true;
 
if (!halbtc_is_bt_coexist_available(btcoexist))
return;
 
btcoexist->statistics.cnt_init_hw_config++;
 
-   if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE)
-   ex_btc8723b2ant_init_hwconfig(btcoexist);
+   if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
+   if (btcoexist->board_info.btdm_ant_num == 2)
+   ex_btc8821a2ant_init_hwconfig(btcoexist);
+   else if (btcoexist->board_info.btdm_ant_num == 1)
+   ex_btc8821a1ant_init_hwconfig(btcoexist, wifi_only);
+   } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
+   if (btcoexist->board_info.btdm_ant_num == 2)
+   ex_btc8723b2ant_init_hwconfig(btcoexist);
+   else if (btcoexist->board_info.btdm_ant_num == 1)
+   ex_btc8723b1ant_init_hwconfig(btcoexist, wifi_only);
+   } else if (IS_HARDWARE_TYPE_8723A(btcoexist->adapter)) {
+   /* 8723A has no this function */
+   } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
+   if (btcoexist->board_info.btdm_ant_num == 2)
+   ex_btc8192e2ant_init_hwconfig(btcoexist);
+   }
 }
 
 void exhalbtc_init_coex_dm(struct btc_coexist *btcoexist)
 {
-   struct rtl_priv *rtlpriv = btcoexist->adapter;
-   struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
-
if (!halbtc_is_bt_coexist_available(btcoexist))
return;
 
btcoexist->statistics.cnt_init_coex_dm++;
 
-   if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE)
-   ex_btc8723b2ant_init_coex_dm(btcoexist);
+   if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
+   if (btcoexist->board_info.btdm_ant_num == 2)
+   ex_btc8821a2ant_init_coex_dm(btcoexist);
+   else if (btcoexist->board_info.btdm_ant_num == 1)
+   ex_btc8821a1ant_init_coex_dm(btcoexist);
+   

[PATCH 1/9] rtlwifi: btcoex: add macros to check chip type

2017-06-02 Thread Larry Finger
From: Yan-Hsuan Chuang 

For some external functions that have hardware dependency, we need to
know the type of the hardware before invoking them.

Signed-off-by: Yan-Hsuan Chuang 
Signed-off-by: Larry Finger 
Cc: Ping-Ke Shih 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 
---
 .../realtek/rtlwifi/btcoexist/halbt_precomp.h  | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbt_precomp.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbt_precomp.h
index 39b9a3309cfd..2ac989a4b2bb 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbt_precomp.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbt_precomp.h
@@ -37,6 +37,28 @@
 
 #include "halbtcoutsrc.h"
 
+/* Interface type */
+#define RT_PCI_INTERFACE   1
+#define RT_USB_INTERFACE   2
+#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"
-- 
2.13.0



[PATCH 7/9] rtlwifi: btcoex: bind BT coex information with wifi driver

2017-06-02 Thread Larry Finger
From: Yan-Hsuan Chuang 

When initializing, gather BT information in struct btcoexist and
provide them to wifi driver.

Signed-off-by: Yan-Hsuan Chuang 
Signed-off-by: Larry Finger 
Cc: Ping-Ke Shih 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 
---
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c   | 56 ++
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.h   |  8 
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.c   | 29 ---
 3 files changed, 72 insertions(+), 21 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index 9832405c5e26..5ad9c180bc28 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -708,6 +708,56 @@ bool exhalbtc_initlize_variables(struct rtl_priv *adapter)
return true;
 }
 
+bool exhalbtc_bind_bt_coex_withadapter(void *adapter)
+{
+   struct btc_coexist *btcoexist = _bt_coexist;
+   struct rtl_priv *rtlpriv = adapter;
+   u8 ant_num = 2, chip_type, single_ant_path = 0;
+
+   if (btcoexist->binded)
+   return false;
+
+   btcoexist->binded = true;
+   btcoexist->statistics.cnt_bind++;
+
+   btcoexist->adapter = adapter;
+
+   btcoexist->stack_info.profile_notified = false;
+
+   btcoexist->bt_info.bt_ctrl_agg_buf_size = false;
+   btcoexist->bt_info.agg_buf_size = 5;
+
+   btcoexist->bt_info.increase_scan_dev_num = false;
+   btcoexist->bt_info.miracast_plus_bt = false;
+
+   chip_type = rtl_get_hwpg_bt_type(rtlpriv);
+   exhalbtc_set_chip_type(chip_type);
+   ant_num = rtl_get_hwpg_ant_num(rtlpriv);
+   exhalbtc_set_ant_num(rtlpriv, BT_COEX_ANT_TYPE_PG, ant_num);
+
+   /* set default antenna position to main  port */
+   btcoexist->board_info.btdm_ant_pos = BTC_ANTENNA_AT_MAIN_PORT;
+
+   single_ant_path = rtl_get_hwpg_single_ant_path(rtlpriv);
+   exhalbtc_set_single_ant_path(single_ant_path);
+
+   if (rtl_get_hwpg_package_type(rtlpriv) == 0)
+   btcoexist->board_info.tfbga_package = false;
+   else if (rtl_get_hwpg_package_type(rtlpriv) == 1)
+   btcoexist->board_info.tfbga_package = false;
+   else
+   btcoexist->board_info.tfbga_package = true;
+
+   if (btcoexist->board_info.tfbga_package)
+   RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+"[BTCoex], Package Type = TFBGA\n");
+   else
+   RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+"[BTCoex], Package Type = Non-TFBGA\n");
+
+   return true;
+}
+
 void exhalbtc_power_on_setting(struct btc_coexist *btcoexist)
 {
if (!halbtc_is_bt_coexist_available(btcoexist))
@@ -1296,6 +1346,12 @@ void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 
type, u8 ant_num)
}
 }
 
+/* Currently used by 8723b only, S0 or S1 */
+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)
 {
struct rtl_priv *rtlpriv = btcoexist->adapter;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
index 9b0a6e9c5b20..3d34cf83d7fc 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
@@ -153,6 +153,7 @@ struct btc_board_info {
u8 btdm_ant_pos;
u8 single_ant_path; /* current used for 8723b only, 1=>s0,  0=>s1 */
bool bt_exist;
+   bool tfbga_package;
 };
 
 enum btc_dbg_opcode {
@@ -433,12 +434,18 @@ struct btc_bt_info {
bool bt_disabled;
u8 rssi_adjust_for_agc_table_on;
u8 rssi_adjust_for_1ant_coex_type;
+   bool pre_bt_ctrl_agg_buf_size;
bool bt_busy;
+   u8 pre_agg_buf_size;
u8 agg_buf_size;
bool limited_dig;
+   bool pre_reject_agg_pkt;
bool reject_agg_pkt;
bool bt_ctrl_buf_size;
bool increase_scan_dev_num;
+   bool miracast_plus_bt;
+   bool bt_ctrl_agg_buf_size;
+   bool bt_tx_rx_mask;
u16 bt_hci_ver;
u16 bt_real_fw_ver;
u8 bt_fw_ver;
@@ -593,5 +600,6 @@ void exhalbtc_signal_compensation(struct btc_coexist 
*btcoexist,
  u8 *rssi_wifi, u8 *rssi_bt);
 void exhalbtc_lps_leave(struct btc_coexist *btcoexist);
 void exhalbtc_low_wifi_traffic_notify(struct btc_coexist *btcoexist);
+void exhalbtc_set_single_ant_path(u8 single_ant_path);
 
 #endif
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c 

[PATCH 4/9] rtlwifi: btcoex: hook external PnP notify by chip for wifi driver

2017-06-02 Thread Larry Finger
From: Yan-Hsuan Chuang 

Hook the chip-specific PnP notify functions for the wifi driver to
notify btcoexistence.

Signed-off-by: Yan-Hsuan Chuang 
Signed-off-by: Larry Finger 
Cc: Ping-Ke Shih 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 
---
 .../realtek/rtlwifi/btcoexist/halbtc8723b2ant.h|  1 +
 .../wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c  | 18 ++
 2 files changed, 19 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h
index a98b9548c3c7..ae3e450c5966 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h
@@ -196,6 +196,7 @@ void ex_btc8723b2ant_bt_info_notify(struct btc_coexist 
*btcoexist,
 void ex_btc8723b2ant_halt_notify(struct btc_coexist *btcoexist);
 void ex_btc8723b2ant_periodical(struct btc_coexist *btcoexist);
 void ex_btc8723b2ant_display_coex_info(struct btc_coexist *btcoexist);
+void ex_btc8723b2ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state);
 void ex_btc8723b2ant_pre_load_firmware(struct btc_coexist *btcoexist);
 
 #endif
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index 0cd4926c1ed7..5e6e14fd8c85 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -916,6 +916,24 @@ void exhalbtc_pnp_notify(struct btc_coexist *btcoexist, u8 
pnp_state)
 {
if (!halbtc_is_bt_coexist_available(btcoexist))
return;
+
+   /* currently only 1ant we have to do the notification,
+* once pnp is notified to sleep state, we have to leave LPS that
+* we can sleep normally.
+*/
+
+   if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
+   if (btcoexist->board_info.btdm_ant_num == 1)
+   ex_btc8723b1ant_pnp_notify(btcoexist, pnp_state);
+   else if (btcoexist->board_info.btdm_ant_num == 2)
+   ex_btc8723b2ant_pnp_notify(btcoexist, pnp_state);
+   } else if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
+   if (btcoexist->board_info.btdm_ant_num == 1)
+   ex_btc8821a1ant_pnp_notify(btcoexist, pnp_state);
+   else if (btcoexist->board_info.btdm_ant_num == 2)
+   ex_btc8821a2ant_pnp_notify(btcoexist, pnp_state);
+   } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
+   }
 }
 
 void exhalbtc_periodical(struct btc_coexist *btcoexist)
-- 
2.13.0



[PATCH 5/9] rtlwifi: btcoex: add settings before the hardware is ready

2017-06-02 Thread Larry Finger
From: Yan-Hsuan Chuang 

When the hardware is turned on and in the initialization stage, the PTA
circuit is unstable. Hence we need to force some hardware settings to
make sure the PTA circuit work correctly, otherwise it may affect the
user's experience.

Signed-off-by: Yan-Hsuan Chuang 
Signed-off-by: Larry Finger 
Cc: Ping-Ke Shih 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 
---
 .../wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h  |  1 +
 .../net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c | 15 +++
 .../net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h |  1 +
 3 files changed, 17 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h
index ae3e450c5966..bc1e3042e271 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h
@@ -198,5 +198,6 @@ void ex_btc8723b2ant_periodical(struct btc_coexist 
*btcoexist);
 void ex_btc8723b2ant_display_coex_info(struct btc_coexist *btcoexist);
 void ex_btc8723b2ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state);
 void ex_btc8723b2ant_pre_load_firmware(struct btc_coexist *btcoexist);
+void ex_btc8723b2ant_power_on_setting(struct btc_coexist *btcoexist);
 
 #endif
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index 5e6e14fd8c85..8b015e64af49 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -690,6 +690,21 @@ bool exhalbtc_initlize_variables(struct rtl_priv *adapter)
return true;
 }
 
+void exhalbtc_power_on_setting(struct btc_coexist *btcoexist)
+{
+   if (!halbtc_is_bt_coexist_available(btcoexist))
+   return;
+
+   btcoexist->statistics.cnt_power_on++;
+
+   if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
+   if (btcoexist->board_info.btdm_ant_num == 2)
+   ex_btc8723b2ant_power_on_setting(btcoexist);
+   else if (btcoexist->board_info.btdm_ant_num == 1)
+   ex_btc8723b1ant_power_on_setting(btcoexist);
+   }
+}
+
 void exhalbtc_pre_load_firmware(struct btc_coexist *btcoexist)
 {
if (!halbtc_is_bt_coexist_available(btcoexist))
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
index eca0e5a78ada..9b0a6e9c5b20 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
@@ -487,6 +487,7 @@ struct btc_statistics {
u32 cnt_stack_operation_notify;
u32 cnt_dbg_ctrl;
u32 cnt_pre_load_firmware;
+   u32 cnt_power_on;
 };
 
 struct btc_bt_link_info {
-- 
2.13.0



[PATCH 3/9] rtlwifi: btcoex: settings before firmware is downloaded

2017-06-02 Thread Larry Finger
From: Yan-Hsuan Chuang 

The btcoex is sometimes unstable because there are some unexpected
behaviors before the firmware has been downloaded successfully.

Therefore we force the antenna path settings to avoid this, then let the
firmware control the btcoexistence when the firmware is ready.

Signed-off-by: Yan-Hsuan Chuang 
Signed-off-by: Larry Finger 
Cc: Ping-Ke Shih 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 
---
 .../wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h|  1 +
 .../wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.h|  2 ++
 .../net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c   | 13 +
 .../net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h   |  1 +
 4 files changed, 17 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h
index 50726beaeead..a98b9548c3c7 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h
@@ -196,5 +196,6 @@ void ex_btc8723b2ant_bt_info_notify(struct btc_coexist 
*btcoexist,
 void ex_btc8723b2ant_halt_notify(struct btc_coexist *btcoexist);
 void ex_btc8723b2ant_periodical(struct btc_coexist *btcoexist);
 void ex_btc8723b2ant_display_coex_info(struct btc_coexist *btcoexist);
+void ex_btc8723b2ant_pre_load_firmware(struct btc_coexist *btcoexist);
 
 #endif
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.h
index 1d6e3e9abd91..a839d5574422 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.h
@@ -228,3 +228,5 @@ void
 ex_btc8821a2ant_display_coex_info(
struct btc_coexist *btcoexist
);
+void ex_btc8821a2ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state);
+void ex_btc8821a2ant_pre_load_firmware(struct btc_coexist *btcoexist);
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index f13000612913..0cd4926c1ed7 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -690,6 +690,19 @@ bool exhalbtc_initlize_variables(struct rtl_priv *adapter)
return true;
 }
 
+void exhalbtc_pre_load_firmware(struct btc_coexist *btcoexist)
+{
+   if (!halbtc_is_bt_coexist_available(btcoexist))
+   return;
+
+   btcoexist->statistics.cnt_pre_load_firmware++;
+
+   if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
+   if (btcoexist->board_info.btdm_ant_num == 2)
+   ex_btc8723b2ant_pre_load_firmware(btcoexist);
+   }
+}
+
 void exhalbtc_init_hw_config(struct btc_coexist *btcoexist)
 {
struct rtl_priv *rtlpriv = btcoexist->adapter;
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
index c5c360e011a9..eca0e5a78ada 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h
@@ -486,6 +486,7 @@ struct btc_statistics {
u32 cnt_coex_dm_switch;
u32 cnt_stack_operation_notify;
u32 cnt_dbg_ctrl;
+   u32 cnt_pre_load_firmware;
 };
 
 struct btc_bt_link_info {
-- 
2.13.0



[PATCH 0/9] rtlwifi: btcoex: Further updates

2017-06-02 Thread Larry Finger
This set of 9 patches contain the material that was originally sent as
1 of 7. Each of these now accomplish a single task.

Larry

Signed-off-by: Yan-Hsuan Chuang 
Signed-off-by: Larry Finger 
Cc: Ping-Ke Shih 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 

Yan-Hsuan Chuang (9):
  rtlwifi: btcoex: add macros to check chip type
  rtlwifi: btcoex: rename ex_halbtcYZant to ex_btcYZant
  rtlwifi: btcoex: settings before firmware is downloaded
  rtlwifi: btcoex: hook external PnP notify by chip for wifi driver
  rtlwifi: btcoex: add settings before the hardware is ready
  rtlwifi: btcoex: hook external functions for newer chips
  rtlwifi: btcoex: bind BT coex information with wifi driver
  rtlwifi: btcoex: remove unused display functions
  rtlwifi: btcoex: let btcoex get wifi rssi and link status

 .../realtek/rtlwifi/btcoexist/halbt_precomp.h  |  22 +
 .../realtek/rtlwifi/btcoexist/halbtc8192e2ant.c|   2 +-
 .../realtek/rtlwifi/btcoexist/halbtc8192e2ant.h|  32 +-
 .../realtek/rtlwifi/btcoexist/halbtc8723b1ant.c|  52 +-
 .../realtek/rtlwifi/btcoexist/halbtc8723b1ant.h|  41 +-
 .../realtek/rtlwifi/btcoexist/halbtc8723b2ant.h|   3 +
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.h|  38 +-
 .../realtek/rtlwifi/btcoexist/halbtc8821a2ant.h|  26 +-
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c   | 838 -
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.h   |  42 +-
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.c   |  35 +-
 11 files changed, 814 insertions(+), 317 deletions(-)

-- 
2.13.0



[PATCH 8/9] rtlwifi: btcoex: remove unused display functions

2017-06-02 Thread Larry Finger
From: Yan-Hsuan Chuang 

These display functions are useless and will not be called in the
future.

Signed-off-by: Yan-Hsuan Chuang 
Signed-off-by: Larry Finger 
Cc: Ping-Ke Shih 
Cc: Birming Chiu 
Cc: Shaofu 
Cc: Steven Ting 
---
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c   | 38 --
 1 file changed, 38 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index 5ad9c180bc28..53a43dfdecba 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -485,22 +485,6 @@ static bool halbtc_set(void *void_btcoexist, u8 set_type, 
void *in_buf)
return true;
 }
 
-static void halbtc_display_coex_statistics(struct btc_coexist *btcoexist)
-{
-}
-
-static void halbtc_display_bt_link_info(struct btc_coexist *btcoexist)
-{
-}
-
-static void halbtc_display_bt_fw_info(struct btc_coexist *btcoexist)
-{
-}
-
-static void halbtc_display_fw_pwr_mode_cmd(struct btc_coexist *btcoexist)
-{
-}
-
 /
  * IO related function
  /
@@ -619,27 +603,6 @@ static void halbtc_fill_h2c_cmd(void *bt_context, u8 
element_id,
cmd_len, cmd_buf);
 }
 
-static void halbtc_display_dbg_msg(void *bt_context, u8 disp_type)
-{
-   struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
-   switch (disp_type) {
-   case BTC_DBG_DISP_COEX_STATISTICS:
-   halbtc_display_coex_statistics(btcoexist);
-   break;
-   case BTC_DBG_DISP_BT_LINK_INFO:
-   halbtc_display_bt_link_info(btcoexist);
-   break;
-   case BTC_DBG_DISP_BT_FW_VER:
-   halbtc_display_bt_fw_info(btcoexist);
-   break;
-   case BTC_DBG_DISP_FW_PWR_MODE_CMD:
-   halbtc_display_fw_pwr_mode_cmd(btcoexist);
-   break;
-   default:
-   break;
-   }
-}
-
 bool halbtc_under_ips(struct btc_coexist *btcoexist)
 {
struct rtl_priv *rtlpriv = btcoexist->adapter;
@@ -696,7 +659,6 @@ bool exhalbtc_initlize_variables(struct rtl_priv *adapter)
btcoexist->btc_get_rf_reg = halbtc_get_rfreg;
 
btcoexist->btc_fill_h2c = halbtc_fill_h2c_cmd;
-   btcoexist->btc_disp_dbg_msg = halbtc_display_dbg_msg;
 
btcoexist->btc_get = halbtc_get;
btcoexist->btc_set = halbtc_set;
-- 
2.13.0



Re: [PATCH] brcmfmac: Fix glob_skb leak in brcmf_sdiod_recv_chain

2017-06-02 Thread Franky Lin
On Fri, Jun 2, 2017 at 10:22 AM, Peter S. Housel  wrote:
> An earlier change to this function (3bdae810721b) fixed a leak in the
> case of an unsuccessful call to brcmf_sdiod_buffrw(). However, the
> glob_skb buffer, used for emulating a scattering read, is never used
> or referenced after its contents are copied into the destination
> buffers, and therefore always needs to be freed by the end of the
> function.
>
> Signed-off-by: Peter S. Housel 
> ---
>  drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c 
> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
> index 9b970dc..4c5064f 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
> @@ -727,15 +727,16 @@ int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev 
> *sdiodev,
> return -ENOMEM;
> err = brcmf_sdiod_buffrw(sdiodev, SDIO_FUNC_2, false, addr,
>  glom_skb);
> -   if (err) {
> -   brcmu_pkt_buf_free_skb(glom_skb);
> -   goto done;
> -   }
> +   if (err)
> +   goto free_glom_skb;
>
> skb_queue_walk(pktq, skb) {
> memcpy(skb->data, glom_skb->data, skb->len);
> skb_pull(glom_skb, skb->len);
> }
> +
> +free_glom_skb:
> +   brcmu_pkt_buf_free_skb(glom_skb);

What about
if (!err) {
skb_queue_walk(pktq, skb) {
memcpy(skb->data, glom_skb->data, skb->len);
skb_pull(glom_skb, skb->len);
}
}
brcmu_pkt_buf_free_skb(glom_skb);

Then no goto is needed.

Thanks,
Franky

> } else
> err = brcmf_sdiod_sglist_rw(sdiodev, SDIO_FUNC_2, false, addr,
> pktq);
> --
> 2.7.4
>


Re: [PATCH] brcmfmac: Fix glob_skb leak in brcmf_sdiod_recv_chain

2017-06-02 Thread Florian Fainelli
On 06/02/2017 10:22 AM, Peter S. Housel wrote:
> An earlier change to this function (3bdae810721b) fixed a leak in the
> case of an unsuccessful call to brcmf_sdiod_buffrw(). However, the
> glob_skb buffer, used for emulating a scattering read, is never used
> or referenced after its contents are copied into the destination
> buffers, and therefore always needs to be freed by the end of the
> function.

That looks correct, could you add the relevant Fixes tag for this?

Fixes: 3bdae810721b ("brcmfmac: Fix glob_skb leak in
brcmf_sdiod_recv_chain")
Fixes: a413e39a38573 ("brcmfmac: fix brcmf_sdcard_recv_chain() for host
without sg support")

BTW, you made the same typo that I did, it's actually glom_skb ;)

> 
> Signed-off-by: Peter S. Housel 
> ---
>  drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c 
> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
> index 9b970dc..4c5064f 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
> @@ -727,15 +727,16 @@ int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev 
> *sdiodev,
>   return -ENOMEM;
>   err = brcmf_sdiod_buffrw(sdiodev, SDIO_FUNC_2, false, addr,
>glom_skb);
> - if (err) {
> - brcmu_pkt_buf_free_skb(glom_skb);
> - goto done;
> - }
> + if (err)
> + goto free_glom_skb;
>  
>   skb_queue_walk(pktq, skb) {
>   memcpy(skb->data, glom_skb->data, skb->len);
>   skb_pull(glom_skb, skb->len);
>   }
> +
> +free_glom_skb:
> + brcmu_pkt_buf_free_skb(glom_skb);
>   } else
>   err = brcmf_sdiod_sglist_rw(sdiodev, SDIO_FUNC_2, false, addr,
>   pktq);
> 


-- 
Florian


[PATCH] brcmfmac: Fix glob_skb leak in brcmf_sdiod_recv_chain

2017-06-02 Thread Peter S. Housel
An earlier change to this function (3bdae810721b) fixed a leak in the
case of an unsuccessful call to brcmf_sdiod_buffrw(). However, the
glob_skb buffer, used for emulating a scattering read, is never used
or referenced after its contents are copied into the destination
buffers, and therefore always needs to be freed by the end of the
function.

Signed-off-by: Peter S. Housel 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
index 9b970dc..4c5064f 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
@@ -727,15 +727,16 @@ int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev *sdiodev,
return -ENOMEM;
err = brcmf_sdiod_buffrw(sdiodev, SDIO_FUNC_2, false, addr,
 glom_skb);
-   if (err) {
-   brcmu_pkt_buf_free_skb(glom_skb);
-   goto done;
-   }
+   if (err)
+   goto free_glom_skb;
 
skb_queue_walk(pktq, skb) {
memcpy(skb->data, glom_skb->data, skb->len);
skb_pull(glom_skb, skb->len);
}
+
+free_glom_skb:
+   brcmu_pkt_buf_free_skb(glom_skb);
} else
err = brcmf_sdiod_sglist_rw(sdiodev, SDIO_FUNC_2, false, addr,
pktq);
-- 
2.7.4



Re: [PATCH][wireless-next] qtnfmac: check band before allocating cmd_skb to avoid resource leak

2017-06-02 Thread Igor Mitsyanko

On 06/02/2017 08:40 AM, Colin King wrote:

External Email


From: Colin Ian King 

The current code allocates cmd_skb and then will leak this if band->band
is an illegal value. It is simpler to sanity check the band first before
allocating cmd_skb so that we don't have to free cmd_skb if an invalid
band occurs.

Detected by CoverityScan, CID#1437561 ("Resource Leak")

Signed-off-by: Colin Ian King 
---
  drivers/net/wireless/quantenna/qtnfmac/commands.c | 12 ++--
  1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c 
b/drivers/net/wireless/quantenna/qtnfmac/commands.c
index f0a0cfa7d8a1..cce62f39edaf 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/commands.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c
@@ -1300,12 +1300,6 @@ int qtnf_cmd_get_mac_chan_info(struct qtnf_wmac *mac,
 int ret = 0;
 u8 qband;

-   cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, 0,
-   QLINK_CMD_CHANS_INFO_GET,
-   sizeof(*cmd));
-   if (!cmd_skb)
-   return -ENOMEM;
-
 switch (band->band) {
 case NL80211_BAND_2GHZ:
 qband = QLINK_BAND_2GHZ;
@@ -1320,6 +1314,12 @@ int qtnf_cmd_get_mac_chan_info(struct qtnf_wmac *mac,
 return -EINVAL;
 }

+   cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, 0,
+   QLINK_CMD_CHANS_INFO_GET,
+   sizeof(*cmd));
+   if (!cmd_skb)
+   return -ENOMEM;
+
 cmd = (struct qlink_cmd_chans_info_get *)cmd_skb->data;
 cmd->band = qband;
 ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, _skb, _code,
--
2.11.0


Reviewed-by: Igor Mitsyanko 


[PATCH][wireless-next] qtnfmac: check band before allocating cmd_skb to avoid resource leak

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

The current code allocates cmd_skb and then will leak this if band->band
is an illegal value. It is simpler to sanity check the band first before
allocating cmd_skb so that we don't have to free cmd_skb if an invalid
band occurs.

Detected by CoverityScan, CID#1437561 ("Resource Leak")

Signed-off-by: Colin Ian King 
---
 drivers/net/wireless/quantenna/qtnfmac/commands.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c 
b/drivers/net/wireless/quantenna/qtnfmac/commands.c
index f0a0cfa7d8a1..cce62f39edaf 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/commands.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c
@@ -1300,12 +1300,6 @@ int qtnf_cmd_get_mac_chan_info(struct qtnf_wmac *mac,
int ret = 0;
u8 qband;
 
-   cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, 0,
-   QLINK_CMD_CHANS_INFO_GET,
-   sizeof(*cmd));
-   if (!cmd_skb)
-   return -ENOMEM;
-
switch (band->band) {
case NL80211_BAND_2GHZ:
qband = QLINK_BAND_2GHZ;
@@ -1320,6 +1314,12 @@ int qtnf_cmd_get_mac_chan_info(struct qtnf_wmac *mac,
return -EINVAL;
}
 
+   cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, 0,
+   QLINK_CMD_CHANS_INFO_GET,
+   sizeof(*cmd));
+   if (!cmd_skb)
+   return -ENOMEM;
+
cmd = (struct qlink_cmd_chans_info_get *)cmd_skb->data;
cmd->band = qband;
ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, _skb, _code,
-- 
2.11.0



Re: pull-request: mac80211 2017-06-02

2017-06-02 Thread David Miller
From: Johannes Berg 
Date: Fri,  2 Jun 2017 15:47:44 +0200

> Here I just have two fixes for issues that folks reported to me recently.
> 
> Please pull and let me know if there's any problem.

Looks good, pulled, thanks!


[PATCH 3/6] rsi: Register interrupt handler before firmware load

2017-06-02 Thread Amitkumar Karwar
From: Prameela Rani Garnepudi 

Before firmware load, sometimes false interrupts are received.
System hang is observed if interrupt handler is not registered
to receive these interrupts. Hence interrupt handler registration
is moved before firmware load. We will drop these false interrupts
as these are not from the device.

Signed-off-by: Prameela Rani Garnepudi 
Signed-off-by: Amitkumar Karwar 
---
 drivers/net/wireless/rsi/rsi_91x_hal.c  |  1 +
 drivers/net/wireless/rsi/rsi_91x_sdio.c | 21 +++--
 drivers/net/wireless/rsi/rsi_main.h |  1 +
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_hal.c 
b/drivers/net/wireless/rsi/rsi_91x_hal.c
index 3d24e8e..94e074d 100644
--- a/drivers/net/wireless/rsi/rsi_91x_hal.c
+++ b/drivers/net/wireless/rsi/rsi_91x_hal.c
@@ -733,6 +733,7 @@ int rsi_hal_device_init(struct rsi_hw *adapter)
default:
return -EINVAL;
}
+   common->fsm_state = FSM_CARD_NOT_READY;
 
return 0;
 }
diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio.c 
b/drivers/net/wireless/rsi/rsi_91x_sdio.c
index 2ef844a..e5ea99b 100644
--- a/drivers/net/wireless/rsi/rsi_91x_sdio.c
+++ b/drivers/net/wireless/rsi/rsi_91x_sdio.c
@@ -139,6 +139,8 @@ static void rsi_handle_interrupt(struct sdio_func *function)
 {
struct rsi_hw *adapter = sdio_get_drvdata(function);
 
+   if (adapter->priv->fsm_state == FSM_FW_NOT_LOADED)
+   return;
sdio_release_host(function);
rsi_interrupt_handler(adapter);
sdio_claim_host(function);
@@ -908,10 +910,19 @@ static int rsi_probe(struct sdio_func *pfunction,
__func__);
goto fail;
}
+   sdio_claim_host(pfunction);
+   if (sdio_claim_irq(pfunction, rsi_handle_interrupt)) {
+   rsi_dbg(ERR_ZONE, "%s: Failed to request IRQ\n", __func__);
+   sdio_release_host(pfunction);
+   goto fail;
+   }
+   sdio_release_host(pfunction);
+   rsi_dbg(INIT_ZONE, "%s: Registered Interrupt handler\n", __func__);
 
if (rsi_hal_device_init(adapter)) {
rsi_dbg(ERR_ZONE, "%s: Failed in device init\n", __func__);
sdio_claim_host(pfunction);
+   sdio_release_irq(pfunction);
sdio_disable_func(pfunction);
sdio_release_host(pfunction);
goto fail;
@@ -923,16 +934,6 @@ static int rsi_probe(struct sdio_func *pfunction,
return -EIO;
}
 
-   sdio_claim_host(pfunction);
-   if (sdio_claim_irq(pfunction, rsi_handle_interrupt)) {
-   rsi_dbg(ERR_ZONE, "%s: Failed to request IRQ\n", __func__);
-   sdio_release_host(pfunction);
-   goto fail;
-   }
-
-   sdio_release_host(pfunction);
-   rsi_dbg(INIT_ZONE, "%s: Registered Interrupt handler\n", __func__);
-
return 0;
 fail:
rsi_91x_deinit(adapter);
diff --git a/drivers/net/wireless/rsi/rsi_main.h 
b/drivers/net/wireless/rsi/rsi_main.h
index 833c66f5..74ae0ac 100644
--- a/drivers/net/wireless/rsi/rsi_main.h
+++ b/drivers/net/wireless/rsi/rsi_main.h
@@ -32,6 +32,7 @@
 #define ISR_ZONEBIT(8)  /* For Interrupt Msgs 
*/
 
 enum RSI_FSM_STATES {
+   FSM_FW_NOT_LOADED,
FSM_CARD_NOT_READY,
FSM_BOOT_PARAMS_SENT,
FSM_EEPROM_READ_MAC_ADDR,
-- 
2.7.4



[PATCH 5/6] rsi: configure new boot parameters to device

2017-06-02 Thread Amitkumar Karwar
From: Prameela Rani Garnepudi 

Boot parameters are changed in new firmware. Also three
new sdio sleep parameters are added for ultra low power
save.

Signed-off-by: Prameela Rani Garnepudi 
Signed-off-by: Amitkumar Karwar 
---
 drivers/net/wireless/rsi/rsi_91x_mgmt.c| 20 +---
 drivers/net/wireless/rsi/rsi_boot_params.h | 15 +--
 2 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_mgmt.c 
b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
index fac87c0..b2950aa 100644
--- a/drivers/net/wireless/rsi/rsi_91x_mgmt.c
+++ b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
@@ -45,10 +45,10 @@ static struct bootup_params boot_params_20 = {
}
},
.switch_clk_g = {
-   .switch_clk_info = cpu_to_le16(BIT(3)),
-   .bbp_lmac_clk_reg_val = cpu_to_le16(0x121),
-   .umac_clock_reg_config = 0x0,
-   .qspi_uart_clock_reg_config = 0x0
+   .switch_clk_info = cpu_to_le16(0xb),
+   .bbp_lmac_clk_reg_val = cpu_to_le16(0x111),
+   .umac_clock_reg_config = cpu_to_le16(0x48),
+   .qspi_uart_clock_reg_config = cpu_to_le16(0x1211)
}
},
{
@@ -106,7 +106,10 @@ static struct bootup_params boot_params_20 = {
.wdt_prog_value = 0x0,
.wdt_soc_rst_delay = 0x0,
.dcdc_operation_mode = 0x0,
-   .soc_reset_wait_cnt = 0x0
+   .soc_reset_wait_cnt = 0x0,
+   .waiting_time_at_fresh_sleep = 0x0,
+   .max_threshold_to_avoid_sleep = 0x0,
+   .beacon_resedue_alg_en = 0,
 };
 
 static struct bootup_params boot_params_40 = {
@@ -139,7 +142,7 @@ static struct bootup_params boot_params_40 = {
.switch_clk_info = cpu_to_le16(0x09),
.bbp_lmac_clk_reg_val = cpu_to_le16(0x1121),
.umac_clock_reg_config = cpu_to_le16(0x48),
-   .qspi_uart_clock_reg_config = 0x0
+   .qspi_uart_clock_reg_config = cpu_to_le16(0x1211)
}
},
{
@@ -197,7 +200,10 @@ static struct bootup_params boot_params_40 = {
.wdt_prog_value = 0x0,
.wdt_soc_rst_delay = 0x0,
.dcdc_operation_mode = 0x0,
-   .soc_reset_wait_cnt = 0x0
+   .soc_reset_wait_cnt = 0x0,
+   .waiting_time_at_fresh_sleep = 0x0,
+   .max_threshold_to_avoid_sleep = 0x0,
+   .beacon_resedue_alg_en = 0,
 };
 
 static u16 mcs[] = {13, 26, 39, 52, 78, 104, 117, 130};
diff --git a/drivers/net/wireless/rsi/rsi_boot_params.h 
b/drivers/net/wireless/rsi/rsi_boot_params.h
index 5e2721f..238ee96 100644
--- a/drivers/net/wireless/rsi/rsi_boot_params.h
+++ b/drivers/net/wireless/rsi/rsi_boot_params.h
@@ -24,19 +24,19 @@
 #define WIFI_AFEPLL_CONFIGS  BIT(7)
 #define WIFI_SWITCH_CLK_CONFIGS  BIT(8)
 
-#define TA_PLL_M_VAL_20  8
-#define TA_PLL_N_VAL_20  1
+#define TA_PLL_M_VAL_20  9
+#define TA_PLL_N_VAL_20  0
 #define TA_PLL_P_VAL_20  4
 
 #define PLL960_M_VAL_20  0x14
 #define PLL960_N_VAL_20  0
 #define PLL960_P_VAL_20  5
 
-#define UMAC_CLK_40MHZ   40
+#define UMAC_CLK_40MHZ   80
 
-#define TA_PLL_M_VAL_40  46
-#define TA_PLL_N_VAL_40  3
-#define TA_PLL_P_VAL_40  3
+#define TA_PLL_M_VAL_40  9
+#define TA_PLL_N_VAL_40  0
+#define TA_PLL_P_VAL_40  4
 
 #define PLL960_M_VAL_40  0x14
 #define PLL960_N_VAL_40  0
@@ -122,5 +122,8 @@ struct bootup_params {
/* dcdc modes configs */
__le32 dcdc_operation_mode;
__le32 soc_reset_wait_cnt;
+   __le32 waiting_time_at_fresh_sleep;
+   __le32 max_threshold_to_avoid_sleep;
+   u8 beacon_resedue_alg_en;
 } __packed;
 #endif
-- 
2.7.4



[PATCH 4/6] rsi: receive path enhancement for RS9113

2017-06-02 Thread Amitkumar Karwar
From: Prameela Rani Garnepudi 

RS9113 chipset supports Coex feature. Initial frame exchanges during
device initialization happens on coex queue. This patch adds the
handling for coex queue.

Signed-off-by: Prameela Rani Garnepudi 
Signed-off-by: Amitkumar Karwar 
---
 drivers/net/wireless/rsi/rsi_91x_main.c | 9 -
 drivers/net/wireless/rsi/rsi_main.h | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_main.c 
b/drivers/net/wireless/rsi/rsi_91x_main.c
index 8810862..f1cde0c 100644
--- a/drivers/net/wireless/rsi/rsi_91x_main.c
+++ b/drivers/net/wireless/rsi/rsi_91x_main.c
@@ -123,9 +123,16 @@ int rsi_read_pkt(struct rsi_common *common, s32 
rcv_pkt_len)
 
queueno = rsi_get_queueno(frame_desc, offset);
length = rsi_get_length(frame_desc, offset);
-   extended_desc = rsi_get_extended_desc(frame_desc, offset);
+
+   /* Extended descriptor is valid for WLAN queues only */
+   if (queueno == RSI_WIFI_DATA_Q || queueno == RSI_WIFI_MGMT_Q)
+   extended_desc = rsi_get_extended_desc(frame_desc,
+ offset);
 
switch (queueno) {
+   case RSI_COEX_Q:
+   rsi_mgmt_pkt_recv(common, (frame_desc + offset));
+   break;
case RSI_WIFI_DATA_Q:
skb = rsi_prepare_skb(common,
  (frame_desc + offset),
diff --git a/drivers/net/wireless/rsi/rsi_main.h 
b/drivers/net/wireless/rsi/rsi_main.h
index 74ae0ac..f12e5d9 100644
--- a/drivers/net/wireless/rsi/rsi_main.h
+++ b/drivers/net/wireless/rsi/rsi_main.h
@@ -63,6 +63,7 @@ extern __printf(2, 3) void rsi_dbg(u32 zone, const char *fmt, 
...);
 #define MAX_CONTINUOUS_VI_PKTS  4
 
 /* Queue information */
+#define RSI_COEX_Q 0x0
 #define RSI_WIFI_MGMT_Q 0x4
 #define RSI_WIFI_DATA_Q 0x5
 #define IEEE80211_MGMT_FRAME0x00
-- 
2.7.4



[PATCH 6/6] rsi: add tx frame for common device configuration

2017-06-02 Thread Amitkumar Karwar
From: Prameela Rani Garnepudi 

After successful loading of firmware, a CARD READY indication is
received by host. Common device configuration parameters are sent
to the device after this. It includes information like device
operating mode (Wi-Fi alone or BT coex), power save related
parameters, GPIO information etc. As device supports BT coex,
this frame is send in COEX queue initially. Based on the operating
mode, CARD READY indication is received from each protocol module
in firmware i.e. WLAN, BT.

Signed-off-by: Prameela Rani Garnepudi 
Signed-off-by: Amitkumar Karwar 
---
 drivers/net/wireless/rsi/rsi_91x_hal.c  |   3 +-
 drivers/net/wireless/rsi/rsi_91x_mgmt.c | 132 +---
 drivers/net/wireless/rsi/rsi_hal.h  |   3 +
 drivers/net/wireless/rsi/rsi_main.h |  11 ++-
 drivers/net/wireless/rsi/rsi_mgmt.h |  97 +++
 5 files changed, 232 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_hal.c 
b/drivers/net/wireless/rsi/rsi_91x_hal.c
index 94e074d..c230359 100644
--- a/drivers/net/wireless/rsi/rsi_91x_hal.c
+++ b/drivers/net/wireless/rsi/rsi_91x_hal.c
@@ -718,7 +718,8 @@ int rsi_hal_device_init(struct rsi_hw *adapter)
 {
struct rsi_common *common = adapter->priv;
 
-   common->coex_mode = 1;
+   common->coex_mode = RSI_DEV_COEX_MODE_WIFI_ALONE;
+   common->oper_mode = RSI_DEV_OPMODE_WIFI_ALONE;
adapter->device_model = RSI_DEV_9113;
 
switch (adapter->device_model) {
diff --git a/drivers/net/wireless/rsi/rsi_91x_mgmt.c 
b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
index b2950aa..237e59a 100644
--- a/drivers/net/wireless/rsi/rsi_91x_mgmt.c
+++ b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
@@ -206,6 +206,39 @@ static struct bootup_params boot_params_40 = {
.beacon_resedue_alg_en = 0,
 };
 
+#define UNUSED_GPIO1
+#define USED_GPIO  0
+static struct rsi_ulp_gpio_vals unused_ulp_gpio_bitmap = {
+   .motion_sensor_gpio_ulp_wakeup = UNUSED_GPIO,
+   .sleep_ind_from_device = UNUSED_GPIO,
+   .ulp_gpio_2 = UNUSED_GPIO,
+   .push_button_ulp_wakeup = UNUSED_GPIO,
+};
+
+static struct rsi_soc_gpio_vals unused_soc_gpio_bitmap = {
+   .pspi_csn_0 = USED_GPIO,//GPIO_0
+   .pspi_csn_1 = USED_GPIO,//GPIO_1
+   .host_wakeup_intr   = USED_GPIO,//GPIO_2
+   .pspi_data_0= USED_GPIO,//GPIO_3
+   .pspi_data_1= USED_GPIO,//GPIO_4
+   .pspi_data_2= USED_GPIO,//GPIO_5
+   .pspi_data_3= USED_GPIO,//GPIO_6
+   .i2c_scl= USED_GPIO,//GPIO_7
+   .i2c_sda= USED_GPIO,//GPIO_8
+   .uart1_rx   = UNUSED_GPIO,  //GPIO_9
+   .uart1_tx   = UNUSED_GPIO,  //GPIO_10
+   .uart1_rts_i2s_clk  = UNUSED_GPIO,  //GPIO_11
+   .uart1_cts_i2s_ws   = UNUSED_GPIO,  //GPIO_12
+   .dbg_uart_rx_i2s_din= UNUSED_GPIO,  //GPIO_13
+   .dbg_uart_tx_i2s_dout   = UNUSED_GPIO,  //GPIO_14
+   .lp_wakeup_boot_bypass  = UNUSED_GPIO,  //GPIO_15
+   .led_0  = USED_GPIO,//GPIO_16
+   .btcoex_wlan_active_ext_pa_ant_sel_A = UNUSED_GPIO, //GPIO_17
+   .btcoex_bt_priority_ext_pa_ant_sel_B = UNUSED_GPIO, //GPIO_18
+   .btcoex_bt_active_ext_pa_on_off = UNUSED_GPIO, //GPIO_19
+   .rf_reset   = USED_GPIO, //GPIO_20
+   .sleep_ind_from_device  = UNUSED_GPIO,
+};
 static u16 mcs[] = {13, 26, 39, 52, 78, 104, 117, 130};
 
 /**
@@ -224,6 +257,12 @@ static void rsi_set_default_parameters(struct rsi_common 
*common)
common->fsm_state = FSM_CARD_NOT_READY;
common->iface_down = true;
common->endpoint = EP_2GHZ_20MHZ;
+   common->driver_mode = 1; /* End to end mode */
+   common->lp_ps_handshake_mode = 0; /* Default no handShake mode*/
+   common->ulp_ps_handshake_mode = 2; /* Default PKT handShake mode*/
+   common->rf_power_val = 0; /* Default 1.9V */
+   common->wlan_rf_power_mode = 0;
+   common->obm_ant_sel_val = 2;
 }
 
 /**
@@ -762,6 +801,52 @@ int rsi_hal_load_key(struct rsi_common *common,
 }
 
 /*
+ * This function sends the common device configuration parameters to device.
+ * This frame includes the useful information to make device works on
+ * specific operating mode.
+ */
+static int rsi_send_common_dev_params(struct rsi_common *common)
+{
+   struct sk_buff *skb;
+   u32 frame_len;
+   struct rsi_config_vals *dev_cfgs;
+
+   frame_len = sizeof(struct rsi_config_vals);
+
+   rsi_dbg(MGMT_TX_ZONE, "Sending common device config params\n");
+   skb = dev_alloc_skb(frame_len);
+   if (!skb) {
+   rsi_dbg(ERR_ZONE, "%s: Unable to allocate skb\n", __func__);
+   return -ENOMEM;
+   }
+
+   memset(skb->data, 0, frame_len);
+
+   dev_cfgs = (struct 

[PATCH 2/6] rsi: use enum for FSM states

2017-06-02 Thread Amitkumar Karwar
Currently macros are used for FSM states. We will replace
it with enum so that new state can be added easily without
worrying about macro value.

Signed-off-by: Amitkumar Karwar 
---
 drivers/net/wireless/rsi/rsi_main.h | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_main.h 
b/drivers/net/wireless/rsi/rsi_main.h
index ea4fc22..833c66f5 100644
--- a/drivers/net/wireless/rsi/rsi_main.h
+++ b/drivers/net/wireless/rsi/rsi_main.h
@@ -31,13 +31,15 @@
 #define FSM_ZONEBIT(7)  /* For State Machine Msgs 
*/
 #define ISR_ZONEBIT(8)  /* For Interrupt Msgs 
*/
 
-#define FSM_CARD_NOT_READY  0
-#define FSM_BOOT_PARAMS_SENT1
-#define FSM_EEPROM_READ_MAC_ADDR2
-#define FSM_RESET_MAC_SENT  3
-#define FSM_RADIO_CAPS_SENT 4
-#define FSM_BB_RF_PROG_SENT 5
-#define FSM_MAC_INIT_DONE   6
+enum RSI_FSM_STATES {
+   FSM_CARD_NOT_READY,
+   FSM_BOOT_PARAMS_SENT,
+   FSM_EEPROM_READ_MAC_ADDR,
+   FSM_RESET_MAC_SENT,
+   FSM_RADIO_CAPS_SENT,
+   FSM_BB_RF_PROG_SENT,
+   FSM_MAC_INIT_DONE
+};
 
 extern u32 rsi_zone_enabled;
 extern __printf(2, 3) void rsi_dbg(u32 zone, const char *fmt, ...);
-- 
2.7.4



[PATCH 1/6] rsi: add usb RS9113 chipset support

2017-06-02 Thread Amitkumar Karwar
From: Prameela Rani Garnepudi 

usb device id and vendor id for RS9113 chipset are included.
So it can be used through usb interface.

Signed-off-by: Prameela Rani Garnepudi 
Signed-off-by: Amitkumar Karwar 
---
 drivers/net/wireless/rsi/rsi_91x_usb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/rsi/rsi_91x_usb.c 
b/drivers/net/wireless/rsi/rsi_91x_usb.c
index f5de693..bcd7f45 100644
--- a/drivers/net/wireless/rsi/rsi_91x_usb.c
+++ b/drivers/net/wireless/rsi/rsi_91x_usb.c
@@ -666,6 +666,7 @@ static const struct usb_device_id rsi_dev_table[] = {
{ USB_DEVICE(0x041B, 0x0301) },
{ USB_DEVICE(0x041B, 0x0201) },
{ USB_DEVICE(0x041B, 0x9330) },
+   { USB_DEVICE(0x1618, 0x9113) },
{ /* Blank */},
 };
 
-- 
2.7.4



[PATCH 0/6] rsi driver bringup changes

2017-06-02 Thread Amitkumar Karwar
This patch series includes the changes for adding USB chipset,
frames exchanged with firmware during initialization
and false interrupt problem fix for SDIO.

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

Prameela Rani Garnepudi (5):
  rsi: add usb RS9113 chipset support
  rsi: Register interrupt handler before firmware load
  rsi: receive path enhancement for RS9113
  rsi: configure new boot parameters to device
  rsi: add tx frame for common device configuration

 drivers/net/wireless/rsi/rsi_91x_hal.c |   4 +-
 drivers/net/wireless/rsi/rsi_91x_main.c|   9 +-
 drivers/net/wireless/rsi/rsi_91x_mgmt.c| 152 +
 drivers/net/wireless/rsi/rsi_91x_sdio.c|  21 ++--
 drivers/net/wireless/rsi/rsi_91x_usb.c |   1 +
 drivers/net/wireless/rsi/rsi_boot_params.h |  15 +--
 drivers/net/wireless/rsi/rsi_hal.h |   3 +
 drivers/net/wireless/rsi/rsi_main.h|  29 --
 drivers/net/wireless/rsi/rsi_mgmt.h|  97 ++
 9 files changed, 286 insertions(+), 45 deletions(-)

-- 
2.7.4



Re: [PATCH V2 0/9] nl80211: add support for PTK/GTK handshake offload

2017-06-02 Thread Johannes Berg
On Fri, 2017-06-02 at 13:19 +0200, Arend van Spriel wrote:

> I was thinking about adding a DOC section in nl80211.h:

Sure!

> /**
>   * DOC: WPA/WPA2 temporal key exchange offload
>   *
>   * By setting @NL80211_EXT_FEATURE_4WAY_HANDSHAKE_STA_PSK flag
> drivers
>   * can indicate offload support of EAPOL handshakes for WPA/WPA2

can indicate they support offloading EAPOL ...?

>   * preshared key authentication. In %NL80211_CMD_CONNECT the
> preshared
>   * key should be specified using %NL80211_ATTR_PMK. Drivers
> supporting
>   * this offload may reject the %NL80211_CMD_CONNECT when no
> preshared
>   * key material is provided. For example when that driver does not
>   * support setting the temporal keys through %NL80211_CMD_NEW_KEY.

[...] is provided, for example when [...]

I think? Starting with "For example" seems odd to me.

>   *
>   * Similarly @NL80211_EXT_FEATURE_4WAY_HANDSHAKE_STA_1X flag can be
>   * set by drivers indicating offload support of the PTK/GTK EAPOL
>   * handshakes during 802.1X authentication. In order to use the
> offload
>   * the %NL80211_CMD_CONNECT should have
> %NL80211_ATTR_WANT_1X_4WAY_HS
>   * attribute flag. Drivers supporting this offload may reject the
>   * %NL80211_CMD_CONNECT when the attribute flag is not present.
>   */
> 
> Could add description for FT, ie. PMK-R0 handling as well. Do you
> think this change warrants a separate section or not. Any comments on
> the text itself are welcome.

I think that's good to have.

johannes


pull-request: mac80211 2017-06-02

2017-06-02 Thread Johannes Berg
Hi Dave,

Here I just have two fixes for issues that folks reported to me recently.

Please pull and let me know if there's any problem.

Thanks,
johannes



The following changes since commit 029c58178b9aa0a293a86ee0da3355611ac99d07:

  Merge tag 'mac80211-for-davem-2017-05-23' of 
git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211 (2017-05-24 
15:31:39 -0400)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211.git 
tags/mac80211-for-davem-2017-06-02

for you to fetch changes up to e165bc02a02c70e40d5c811c705ba269aeca0497:

  mac80211: fix dropped counter in multiqueue RX (2017-06-01 21:26:03 +0200)


Just two fixes:
 * fix the per-CPU drop counters to not be added to the
   rx_packets counter, but really the drop counter
 * fix TX aggregation start/stop callback races by setting
   bits instead of allocating and queueing an skb


Johannes Berg (2):
  mac80211: fix TX aggregation start/stop callback race
  mac80211: fix dropped counter in multiqueue RX

 net/mac80211/agg-tx.c  | 128 ++---
 net/mac80211/ht.c  |  16 --
 net/mac80211/ieee80211_i.h |  14 ++---
 net/mac80211/iface.c   |  11 +---
 net/mac80211/sta_info.c|   2 +-
 net/mac80211/sta_info.h|   2 +
 6 files changed, 72 insertions(+), 101 deletions(-)


[PATCH 24/25] iwlwifi: mvm: fix many kernel-doc warnings

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

Fix many kernel-doc warnings. In one case, this required adding
a new enum value to be able to document things properly.

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 .../net/wireless/intel/iwlwifi/mvm/fw-api-power.h  | 35 ++
 .../net/wireless/intel/iwlwifi/mvm/fw-api-tof.h| 16 ++
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h | 15 --
 3 files changed, 46 insertions(+), 20 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-power.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-power.h
index 0d88721b7b52..9d87fddd29b6 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-power.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-power.h
@@ -82,6 +82,8 @@
  * @LTR_CFG_FLAG_SW_SET_SHORT: fixed static short LTR register
  * @LTR_CFG_FLAG_SW_SET_LONG: fixed static short LONG register
  * @LTR_CFG_FLAG_DENIE_C10_ON_PD: allow going into C10 on PD
+ * @LTR_CFG_FLAG_UPDATE_VALUES: update config values and short
+ * idle timeout
  */
 enum iwl_ltr_config_flags {
LTR_CFG_FLAG_FEATURE_ENABLE = BIT(0),
@@ -91,11 +93,14 @@ enum iwl_ltr_config_flags {
LTR_CFG_FLAG_SW_SET_SHORT = BIT(4),
LTR_CFG_FLAG_SW_SET_LONG = BIT(5),
LTR_CFG_FLAG_DENIE_C10_ON_PD = BIT(6),
+   LTR_CFG_FLAG_UPDATE_VALUES = BIT(7),
 };
 
 /**
  * struct iwl_ltr_config_cmd_v1 - configures the LTR
  * @flags: See  iwl_ltr_config_flags
+ * @static_long: static LTR Long register value.
+ * @static_short: static LTR Short register value.
  */
 struct iwl_ltr_config_cmd_v1 {
__le32 flags;
@@ -108,10 +113,13 @@ struct iwl_ltr_config_cmd_v1 {
 /**
  * struct iwl_ltr_config_cmd - configures the LTR
  * @flags: See  iwl_ltr_config_flags
- * @static_long:
- * @static_short:
- * @ltr_cfg_values:
- * @ltr_short_idle_timeout:
+ * @static_long: static LTR Long register value.
+ * @static_short: static LTR Short register value.
+ * @ltr_cfg_values: LTR parameters table values (in usec) in folowing order:
+ * TX, RX, Short Idle, Long Idle. Used only if %LTR_CFG_FLAG_UPDATE_VALUES
+ * is set.
+ * @ltr_short_idle_timeout: LTR Short Idle timeout (in usec). Used only if
+ * %LTR_CFG_FLAG_UPDATE_VALUES is set.
  */
 struct iwl_ltr_config_cmd {
__le32 flags;
@@ -140,7 +148,7 @@ struct iwl_ltr_config_cmd {
  * PBW Snoozing enabled
  * @POWER_FLAGS_ADVANCE_PM_ENA_MSK: Advanced PM (uAPSD) enable mask
  * @POWER_FLAGS_LPRX_ENA_MSK: Low Power RX enable.
- * @POWER_FLAGS_AP_UAPSD_MISBEHAVING_ENA_MSK: AP/GO's uAPSD misbehaving
+ * @POWER_FLAGS_UAPSD_MISBEHAVING_ENA_MSK: AP/GO's uAPSD misbehaving
  * detection enablement
 */
 enum iwl_power_flags {
@@ -166,6 +174,7 @@ enum iwl_power_flags {
  * Minimum allowed:- 3 * DTIM. Keep alive period must be
  * set regardless of power scheme or current power state.
  * FW use this value also when PM is disabled.
+ * @debug_flags:   debug flags
  * @rx_data_timeout:Minimum time (usec) from last Rx packet for AM to
  * PSM transition - legacy PM
  * @tx_data_timeout:Minimum time (usec) from last Tx packet for AM to
@@ -191,7 +200,8 @@ struct iwl_powertable_cmd {
 
 /**
  * enum iwl_device_power_flags - masks for device power command flags
- * @DEVIC_POWER_FLAGS_POWER_SAVE_ENA_MSK: '1' Allow to save power by turning 
off
+ * @DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK:
+ * '1' Allow to save power by turning off
  * receiver and transmitter. '0' - does not allow.
 */
 enum iwl_device_power_flags {
@@ -203,6 +213,7 @@ enum iwl_device_power_flags {
  * DEVICE_POWER_CMD = 0x77 (command, has simple generic response)
  *
  * @flags: Power table command flags from  iwl_device_power_flags
+ * @reserved: reserved (padding)
  */
 struct iwl_device_power_cmd {
/* PM_POWER_TABLE_CMD_API_S_VER_6 */
@@ -223,7 +234,6 @@ struct iwl_device_power_cmd {
  * PSM transition - legacy PM
  * @tx_data_timeout:Minimum time (usec) from last Tx packet for AM to
  * PSM transition - legacy PM
- * @sleep_interval:not in use
  * @skip_dtim_periods: Number of DTIM periods to skip if Skip over DTIM flag
  * is set. For example, if it is required to skip over
  * one DTIM, this value need to be set to 2 (DTIM periods).
@@ -233,7 +243,6 @@ struct iwl_device_power_cmd {
  * PSM transition - uAPSD
  * @lprx_rssi_threshold: Signal strength up to which LP RX can be enabled.
  * Default: 80dbm
- * @num_skip_dtim: Number of DTIMs to skip if Skip over DTIM flag is set
  * @snooze_interval:   Maximum time between attempts to retrieve buffered data
  * from the AP [msec]
  * @snooze_window: A window of time in which PBW snoozing insures that all
@@ 

[PATCH 13/25] iwlwifi: mvm: add documentation links to various fields

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

Link various fields to the documentation of the enums that
define their values.

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 .../net/wireless/intel/iwlwifi/mvm/fw-api-coex.h   | 10 +++
 .../net/wireless/intel/iwlwifi/mvm/fw-api-mac.h| 10 +++
 .../net/wireless/intel/iwlwifi/mvm/fw-api-power.h  |  4 +--
 .../net/wireless/intel/iwlwifi/mvm/fw-api-sta.h| 14 +-
 .../net/wireless/intel/iwlwifi/mvm/fw-api-stats.h  |  4 +++
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h |  4 +--
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h| 31 +-
 7 files changed, 45 insertions(+), 32 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-coex.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-coex.h
index 204c1b13988b..c432fdb98630 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-coex.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-coex.h
@@ -99,8 +99,8 @@ enum iwl_bt_coex_enabled_modules {
 
 /**
  * struct iwl_bt_coex_cmd - bt coex configuration command
- * @mode: enum %iwl_bt_coex_mode
- * @enabled_modules: enum %iwl_bt_coex_enabled_modules
+ * @mode:  iwl_bt_coex_mode
+ * @enabled_modules:  iwl_bt_coex_enabled_modules
  *
  * The structure is used for the BT_COEX command.
  */
@@ -234,9 +234,9 @@ enum iwl_bt_ci_compliance {
  * @mbox_msg: message from BT to WiFi
  * @msg_idx: the index of the message
  * @bt_ci_compliance: enum %iwl_bt_ci_compliance
- * @primary_ch_lut: LUT used for primary channel enum %iwl_bt_coex_lut_type
- * @secondary_ch_lut: LUT used for secondary channel enume 
%iwl_bt_coex_lut_type
- * @bt_activity_grading: the activity of BT enum %iwl_bt_activity_grading
+ * @primary_ch_lut: LUT used for primary channel  iwl_bt_coex_lut_type
+ * @secondary_ch_lut: LUT used for secondary channel  iwl_bt_coex_lut_type
+ * @bt_activity_grading: the activity of BT  iwl_bt_activity_grading
  * @ttc_rrc_status: is TTC or RRC enabled - one bit per PHY
  */
 struct iwl_bt_coex_profile_notif {
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 970b030ed28d..aa5aaf7c940d 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-mac.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-mac.h
@@ -329,17 +329,17 @@ struct iwl_ac_qos {
  * ( MAC_CONTEXT_CMD = 0x28 )
  * @id_and_color: ID and color of the MAC
  * @action: action to perform, one of FW_CTXT_ACTION_*
- * @mac_type: one of FW_MAC_TYPE_*
- * @tsd_id: TSF HW timer, one of TSF_ID_*
+ * @mac_type: one of  iwl_mac_types
+ * @tsd_id: TSF HW timer, one of  iwl_tsf_id
  * @node_addr: MAC address
  * @bssid_addr: BSSID
  * @cck_rates: basic rates available for CCK
  * @ofdm_rates: basic rates available for OFDM
- * @protection_flags: combination of MAC_PROT_FLG_FLAG_*
+ * @protection_flags: combination of  iwl_mac_protection_flags
  * @cck_short_preamble: 0x20 for enabling short preamble, 0 otherwise
  * @short_slot: 0x10 for enabling short slots, 0 otherwise
- * @filter_flags: combination of MAC_FILTER_*
- * @qos_flags: from MAC_QOS_FLG_*
+ * @filter_flags: combination of  iwl_mac_filter_flags
+ * @qos_flags: from  iwl_mac_qos_flags
  * @ac: one iwl_mac_qos configuration for each AC
  * @mac_specific: one of struct iwl_mac_data_*, according to mac_type
  */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-power.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-power.h
index 3d56ba4c0c71..f329e87cd97c 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-power.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-power.h
@@ -202,7 +202,7 @@ enum iwl_device_power_flags {
  * struct iwl_device_power_cmd - device wide power command.
  * DEVICE_POWER_CMD = 0x77 (command, has simple generic response)
  *
- * @flags: Power table command flags from DEVICE_POWER_FLAGS_*
+ * @flags: Power table command flags from  iwl_device_power_flags
  */
 struct iwl_device_power_cmd {
/* PM_POWER_TABLE_CMD_API_S_VER_6 */
@@ -213,7 +213,7 @@ struct iwl_device_power_cmd {
 /**
  * struct iwl_mac_power_cmd - New power command containing uAPSD support
  * MAC_PM_POWER_TABLE = 0xA9 (command, has simple generic response)
- * @id_and_color:  MAC contex identifier
+ * @id_and_color:  MAC contex identifier,  iwl_mvm_id_and_color
  * @flags: Power table command flags from POWER_FLAGS_*
  * @keep_alive_seconds:Keep alive period in seconds. Default - 25 sec.
  * Minimum allowed:- 3 * DTIM. Keep alive period must be
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-sta.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-sta.h
index 894b8f6c8adc..0f6264fdfed1 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-sta.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-sta.h
@@ -253,11 +253,12 @@ struct iwl_mvm_keyinfo {
 /**
  * struct 

[PATCH 25/25] iwlwifi: add wait for tx queue empty

2017-06-02 Thread Luca Coelho
From: Sara Sharon 

Now that we have 512 queues, add a wait for single TX
queue to gen2.
This replaces gen1 wait_tx_queues_empty, which was limited
to 32 queues.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/iwl-trans.c|  2 +
 drivers/net/wireless/intel/iwlwifi/iwl-trans.h| 20 ++-
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c |  4 +-
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c  | 41 -
 drivers/net/wireless/intel/iwlwifi/mvm/sta.h  |  2 +
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c   | 72 ++-
 6 files changed, 107 insertions(+), 34 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
index 0bde26bab15d..c0871f8f2c68 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
@@ -102,6 +102,8 @@ struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
if (!trans->dev_cmd_pool)
return NULL;
 
+   WARN_ON(!ops->wait_txq_empty && !ops->wait_tx_queues_empty);
+
return trans;
 }
 
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
index 0ebfdbb22992..d3a78a11821a 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
@@ -619,7 +619,8 @@ struct iwl_tx_queue_cfg_rsp {
  * @txq_disable: de-configure a Tx queue to send AMPDUs
  * Must be atomic
  * @txq_set_shared_mode: change Tx queue shared/unshared marking
- * @wait_tx_queue_empty: wait until tx queues are empty. May sleep.
+ * @wait_tx_queues_empty: wait until tx queues are empty. May sleep.
+ * @wait_txq_empty: wait until specific tx queue is empty. May sleep.
  * @freeze_txq_timer: prevents the timer of the queue from firing until the
  * queue is set to awake. Must be atomic.
  * @block_txq_ptrs: stop updating the write pointers of the Tx queues. Note
@@ -692,6 +693,7 @@ struct iwl_trans_ops {
bool shared);
 
int (*wait_tx_queues_empty)(struct iwl_trans *trans, u32 txq_bm);
+   int (*wait_txq_empty)(struct iwl_trans *trans, int queue);
void (*freeze_txq_timer)(struct iwl_trans *trans, unsigned long txqs,
 bool freeze);
void (*block_txq_ptrs)(struct iwl_trans *trans, bool block);
@@ -1198,6 +1200,9 @@ static inline void iwl_trans_block_txq_ptrs(struct 
iwl_trans *trans,
 static inline int iwl_trans_wait_tx_queues_empty(struct iwl_trans *trans,
 u32 txqs)
 {
+   if (WARN_ON_ONCE(!trans->ops->wait_tx_queues_empty))
+   return -ENOTSUPP;
+
if (WARN_ON_ONCE(trans->state != IWL_TRANS_FW_ALIVE)) {
IWL_ERR(trans, "%s bad state = %d\n", __func__, trans->state);
return -EIO;
@@ -1206,6 +1211,19 @@ static inline int iwl_trans_wait_tx_queues_empty(struct 
iwl_trans *trans,
return trans->ops->wait_tx_queues_empty(trans, txqs);
 }
 
+static inline int iwl_trans_wait_txq_empty(struct iwl_trans *trans, int queue)
+{
+   if (WARN_ON_ONCE(!trans->ops->wait_txq_empty))
+   return -ENOTSUPP;
+
+   if (WARN_ON_ONCE(trans->state != IWL_TRANS_FW_ALIVE)) {
+   IWL_ERR(trans, "%s bad state = %d\n", __func__, trans->state);
+   return -EIO;
+   }
+
+   return trans->ops->wait_txq_empty(trans, queue);
+}
+
 static inline void iwl_trans_write8(struct iwl_trans *trans, u32 ofs, u8 val)
 {
trans->ops->write8(trans, ofs, val);
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index f4437d5b2e73..50510e96a82d 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -3995,6 +3995,8 @@ static void iwl_mvm_mac_flush(struct ieee80211_hw *hw,
IWL_ERR(mvm, "flush request fail\n");
} else {
msk |= mvmsta->tfd_queue_msk;
+   if (iwl_mvm_has_new_tx_api(mvm))
+   iwl_mvm_wait_sta_queues_empty(mvm, mvmsta);
}
}
 
@@ -4003,7 +4005,7 @@ static void iwl_mvm_mac_flush(struct ieee80211_hw *hw,
/* this can take a while, and we may need/want other operations
 * to succeed while doing this, so do it without the mutex held
 */
-   if (!drop)
+   if (!drop && !iwl_mvm_has_new_tx_api(mvm))
iwl_trans_wait_tx_queues_empty(mvm->trans, msk);
 }
 
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
index 9f74d4ff6b73..3dad87b79cf0 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
+++ 

[PATCH 16/25] iwlwifi: mvm: create/name various enums

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

Some values should be in enums so documentation can refer to
them, some values should be named for the same reason.

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 .../net/wireless/intel/iwlwifi/mvm/fw-api-sta.h| 10 +++-
 .../net/wireless/intel/iwlwifi/mvm/fw-api-stats.h  | 25 +++--
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h| 61 +-
 3 files changed, 77 insertions(+), 19 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-sta.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-sta.h
index 0f6264fdfed1..c14ebd7ff77d 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-sta.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-sta.h
@@ -197,7 +197,15 @@ enum iwl_sta_modify_flag {
STA_MODIFY_QUEUES   = BIT(7),
 };
 
-#define STA_MODE_MODIFY1
+/**
+ * enum iwl_sta_mode - station command mode
+ * @STA_MODE_ADD: add new station
+ * @STA_MODE_MODIFY: modify the station
+ */
+enum iwl_sta_mode {
+   STA_MODE_ADD= 0,
+   STA_MODE_MODIFY = 1,
+};
 
 /**
  * enum iwl_sta_sleep_flag - type of sleep of the station
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-stats.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-stats.h
index c8561b16add4..4286222f54f7 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-stats.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-stats.h
@@ -7,7 +7,7 @@
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
- * Copyright(c) 2016 Intel 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
@@ -323,12 +323,29 @@ struct iwl_notif_statistics_cdb {
struct mvm_statistics_load_cdb load_stats;
 } __packed; /* STATISTICS_NTFY_API_S_VER_12 */
 
-#define IWL_STATISTICS_FLG_CLEAR   0x1
-#define IWL_STATISTICS_FLG_DISABLE_NOTIF   0x2
+/**
+ * enum iwl_statistics_notif_flags - flags used in statistics notification
+ * @IWL_STATISTICS_REPLY_FLG_CLEAR: statistics were cleared after this report
+ */
+enum iwl_statistics_notif_flags {
+   IWL_STATISTICS_REPLY_FLG_CLEAR  = 0x1,
+};
+
+/**
+ * enum iwl_statistics_cmd_flags - flags used in statistics command
+ * @IWL_STATISTICS_FLG_CLEAR: request to clear statistics after the report
+ * that's sent after this command
+ * @IWL_STATISTICS_FLG_DISABLE_NOTIF: disable unilateral statistics
+ * notifications
+ */
+enum iwl_statistics_cmd_flags {
+   IWL_STATISTICS_FLG_CLEAR= 0x1,
+   IWL_STATISTICS_FLG_DISABLE_NOTIF= 0x2,
+};
 
 /**
  * struct iwl_statistics_cmd - statistics config command
- * @flags: flags from  iwl_statistics_flags
+ * @flags: flags from  iwl_statistics_cmd_flags
  */
 struct iwl_statistics_cmd {
__le32 flags;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
index 4c5f38e50caa..6e0e65eb2b4d 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
@@ -472,15 +472,39 @@ struct iwl_phy_cfg_cmd {
 #define PHY_CFG_RX_CHAIN_C BIT(14)
 
 
-/* Target of the NVM_ACCESS_CMD */
-enum {
+/**
+ * enum iwl_nvm_access_op - NVM access opcode
+ * @IWL_NVM_READ: read NVM
+ * @IWL_NVM_WRITE: write NVM
+ */
+enum iwl_nvm_access_op {
+   IWL_NVM_READ= 0,
+   IWL_NVM_WRITE   = 1,
+};
+
+/**
+ * enum iwl_nvm_access_target - target of the NVM_ACCESS_CMD
+ * @NVM_ACCESS_TARGET_CACHE: access the cache
+ * @NVM_ACCESS_TARGET_OTP: access the OTP
+ * @NVM_ACCESS_TARGET_EEPROM: access the EEPROM
+ */
+enum iwl_nvm_access_target {
NVM_ACCESS_TARGET_CACHE = 0,
NVM_ACCESS_TARGET_OTP = 1,
NVM_ACCESS_TARGET_EEPROM = 2,
 };
 
-/* Section types for NVM_ACCESS_CMD */
-enum {
+/**
+ * enum iwl_nvm_section_type - section types for NVM_ACCESS_CMD
+ * @NVM_SECTION_TYPE_SW: software section
+ * @NVM_SECTION_TYPE_REGULATORY: regulatory section
+ * @NVM_SECTION_TYPE_CALIBRATION: calibration section
+ * @NVM_SECTION_TYPE_PRODUCTION: production section
+ * @NVM_SECTION_TYPE_MAC_OVERRIDE: MAC override section
+ * @NVM_SECTION_TYPE_PHY_SKU: PHY SKU section
+ * @NVM_MAX_NUM_SECTIONS: number of sections
+ */
+enum iwl_nvm_section_type {
NVM_SECTION_TYPE_SW = 1,
NVM_SECTION_TYPE_REGULATORY = 3,
NVM_SECTION_TYPE_CALIBRATION = 4,
@@ -718,12 +742,21 @@ struct iwl_error_resp {
 #define MAX_MACS_IN_BINDING(3)
 #define MAX_BINDINGS   (4)
 
-/* Used to extract ID and color from the context dword */
-#define FW_CTXT_ID_POS   (0)
-#define FW_CTXT_ID_MSK   (0xff << FW_CTXT_ID_POS)
-#define FW_CTXT_COLOR_POS (8)
-#define FW_CTXT_COLOR_MSK (0xff << 

[PATCH 23/25] iwlwifi: mvm: remove unused REPLY_MAX

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

This value is unused, and there's no reason we'd ever use it.
Just remove it.

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
index 332f204761cc..ef8b47faa265 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
@@ -470,8 +470,6 @@ enum iwl_legacy_cmds {
SCAN_OFFLOAD_PROFILES_QUERY_CMD = 0x56,
SCAN_OFFLOAD_HOTSPOTS_CONFIG_CMD = 0x58,
SCAN_OFFLOAD_HOTSPOTS_QUERY_CMD = 0x59,
-
-   REPLY_MAX = 0xff,
 };
 
 /* Please keep this enum *SORTED* by hex value.
-- 
2.11.0



[PATCH 18/25] iwlwifi: mvm: remove wrt support of page dumps in gen2

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

In gen2, page dumping should be done in transport
layer, since the addresses needed for the paging
mechanism reside there.

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

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c
index 7b86a4f1b574..d8b592aa362c 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c
@@ -691,7 +691,8 @@ void iwl_mvm_fw_error_dump(struct iwl_mvm *mvm)
}
 
/* Make room for fw's virtual image pages, if it exists */
-   if (mvm->fw->img[mvm->cur_ucode].paging_mem_size &&
+   if (!mvm->trans->cfg->gen2 &&
+   mvm->fw->img[mvm->cur_ucode].paging_mem_size &&
mvm->fw_paging_db[0].fw_paging_block)
file_len += mvm->num_of_paging_blk *
(sizeof(*dump_data) +
@@ -850,7 +851,8 @@ void iwl_mvm_fw_error_dump(struct iwl_mvm *mvm)
}
 
/* Dump fw's virtual image */
-   if (mvm->fw->img[mvm->cur_ucode].paging_mem_size &&
+   if (!mvm->trans->cfg->gen2 &&
+   mvm->fw->img[mvm->cur_ucode].paging_mem_size &&
mvm->fw_paging_db[0].fw_paging_block) {
for (i = 1; i < mvm->num_of_paging_blk + 1; i++) {
struct iwl_fw_error_dump_paging *paging;
-- 
2.11.0



[PATCH 10/25] iwlwifi: mvm: add documentation to some WoWLAN commands

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

Add some documentation for the WoWLAN commands, also linking the
correct enums used.

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-d3.h | 29 +-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-d3.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-d3.h
index 5f22cc7ac26a..edde49202786 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-d3.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-d3.h
@@ -7,7 +7,7 @@
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
- * Copyright(c) 2015 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
@@ -34,6 +34,7 @@
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
+ * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -254,6 +255,17 @@ enum iwl_wowlan_flags {
ENABLE_STORE_BEACON = BIT(4),
 };
 
+/**
+ * struct iwl_wowlan_config_cmd - WoWLAN configuration
+ * @wakeup_filter: filter from  iwl_wowlan_wakeup_filters
+ * @non_qos_seq: non-QoS sequence counter to use next
+ * @qos_seq: QoS sequence counters to use next
+ * @wowlan_ba_teardown_tids: bitmap of BA sessions to tear down
+ * @is_11n_connection: indicates HT connection
+ * @offloading_tid: TID reserved for firmware use
+ * @flags: extra flags, see  iwl_wowlan_flags
+ * @reserved: reserved
+ */
 struct iwl_wowlan_config_cmd {
__le32 wakeup_filter;
__le16 non_qos_seq;
@@ -370,6 +382,21 @@ struct iwl_wowlan_gtk_status {
struct iwl_wowlan_rsc_tsc_params_cmd rsc;
 } __packed; /* WOWLAN_GTK_MATERIAL_VER_1 */
 
+/**
+ * struct iwl_wowlan_status - WoWLAN status
+ * @gtk: GTK data
+ * @replay_ctr: GTK rekey replay counter
+ * @pattern_number: number of the matched pattern
+ * @non_qos_seq_ctr: non-QoS sequence counter to use next
+ * @qos_seq_ctr: QoS sequence counters to use next
+ * @wakeup_reasons: wakeup reasons, see  iwl_wowlan_wakeup_reason
+ * @num_of_gtk_rekeys: number of GTK rekeys
+ * @transmitted_ndps: number of transmitted neighbor discovery packets
+ * @received_beacons: number of received beacons
+ * @wake_packet_length: wakeup packet length
+ * @wake_packet_bufsize: wakeup packet buffer size
+ * @wake_packet: wakeup packet
+ */
 struct iwl_wowlan_status {
struct iwl_wowlan_gtk_status gtk;
__le64 replay_ctr;
-- 
2.11.0



[PATCH 12/25] iwlwifi: mvm: fix some kernel-doc

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

This mostly fixes missing tags/struct names, but also some other
things. Lots of issues remain though.

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h   |  4 +-
 .../net/wireless/intel/iwlwifi/mvm/fw-api-power.h  |  2 +-
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-rx.h |  7 +--
 .../net/wireless/intel/iwlwifi/mvm/fw-api-scan.h   | 32 +--
 .../net/wireless/intel/iwlwifi/mvm/fw-api-sta.h| 22 
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h | 17 +++---
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h| 62 +++---
 7 files changed, 78 insertions(+), 68 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h
index 44419e82da1b..89bc008e152f 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h
@@ -395,8 +395,8 @@ enum iwl_ucode_tlv_capa {
 #define IWL_UCODE_API(ver) (((ver) & 0xFF00) >> 8)
 #define IWL_UCODE_SERIAL(ver)  ((ver) & 0x00FF)
 
-/*
- * Calibration control struct.
+/**
+ * struct iwl_tlv_calib_ctrl - Calibration control struct.
  * Sent as part of the phy configuration command.
  * @flow_trigger: bitmap for which calibrations to perform according to
  * flow triggers.
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-power.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-power.h
index 750510aff70b..3d56ba4c0c71 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-power.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-power.h
@@ -411,7 +411,7 @@ struct iwl_geo_tx_power_profiles_cmd {
  *  Threshold. Typical energy threshold is -72dBm.
  * @bf_temp_threshold: This threshold determines the type of temperature
  * filtering (Slow or Fast) that is selected (Units are in Celsuis):
- *  If the current temperature is above this threshold - Fast filter
+ * If the current temperature is above this threshold - Fast filter
  * will be used, If the current temperature is below this threshold -
  * Slow filter will be used.
  * @bf_temp_fast_filter: Send Beacon to driver if delta in temperature values
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-rx.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-rx.h
index b530fa47d68a..67dffd725690 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-rx.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-rx.h
@@ -147,7 +147,8 @@ enum iwl_csum_rx_assist_info {
 
 /**
  * struct iwl_rx_mpdu_res_start - phy info
- * @assist: see CSUM_RX_ASSIST_ above
+ * @byte_count: byte count of the frame
+ * @assist: see  iwl_csum_rx_assist_info
  */
 struct iwl_rx_mpdu_res_start {
__le16 byte_count;
@@ -447,7 +448,7 @@ struct iwl_rxq_sync_notification {
 } __packed; /* MULTI_QUEUE_DRV_SYNC_HDR_CMD_API_S_VER_1 */
 
 /**
- * Internal message identifier
+ * enum iwl_mvm_rxq_notif_type - Internal message identifier
  *
  * @IWL_MVM_RXQ_EMPTY: empty sync notification
  * @IWL_MVM_RXQ_NOTIF_DEL_BA: notify RSS queues of delBA
@@ -491,7 +492,7 @@ enum iwl_mvm_pm_event {
 /**
  * struct iwl_mvm_pm_state_notification - station PM state notification
  * @sta_id: station ID of the station changing state
- * @type: the new powersave state, see IWL_MVM_PM_EVENT_ above
+ * @type: the new powersave state, see  iwl_mvm_pm_event
  */
 struct iwl_mvm_pm_state_notification {
u8 sta_id;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-scan.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-scan.h
index 3178eb96e395..dded91d7eb96 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-scan.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-scan.h
@@ -7,7 +7,7 @@
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
- * Copyright(c) 2016 Intel 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
@@ -34,6 +34,7 @@
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
+ * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -111,7 +112,7 @@ enum scan_framework_client {
 };
 
 /**
- * iwl_scan_offload_blacklist - SCAN_OFFLOAD_BLACKLIST_S
+ * struct iwl_scan_offload_blacklist - SCAN_OFFLOAD_BLACKLIST_S
  * @ssid:  MAC address to filter out
  * @reported_rssi: AP rssi reported to the host
  * @client_bitmap: clients ignore this entry  - enum scan_framework_client
@@ -135,7 +136,7 @@ enum iwl_scan_offload_band_selection {
 };
 
 

[PATCH 20/25] iwlwifi: Add fw_name_pre_rf_next_step to support different rf steps

2017-06-02 Thread Luca Coelho
From: Haim Dreyfuss 

Integrated chip may have different HW and RF steps.
Currently, the driver supports only different HW steps.
Add logic to support different RF steps enables combining different
HW and RF steps.

Signed-off-by: Haim Dreyfuss 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/iwl-9000.c   | 6 ++
 drivers/net/wireless/intel/iwlwifi/iwl-config.h | 3 +++
 drivers/net/wireless/intel/iwlwifi/iwl-csr.h| 5 +
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c| 4 
 4 files changed, 18 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-9000.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-9000.c
index 110ceefccc15..a2ee6aad3ce3 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-9000.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-9000.c
@@ -73,10 +73,13 @@
 #define IWL9000_SMEM_LEN   0x68000
 
 #define  IWL9000_FW_PRE "iwlwifi-9000-pu-a0-jf-a0-"
+#define  IWL9000RFB_FW_PRE "iwlwifi-9000-pu-a0-jf-b0-"
 #define  IWL9260A_FW_PRE "iwlwifi-9260-th-a0-jf-a0-"
 #define  IWL9260B_FW_PRE "iwlwifi-9260-th-b0-jf-b0-"
 #define IWL9000_MODULE_FIRMWARE(api) \
IWL9000_FW_PRE "-" __stringify(api) ".ucode"
+#define IWL9000RFB_MODULE_FIRMWARE(api) \
+   IWL9000RFB_FW_PRE "-" __stringify(api) ".ucode"
 #define IWL9260A_MODULE_FIRMWARE(api) \
IWL9260A_FW_PRE "-" __stringify(api) ".ucode"
 #define IWL9260B_MODULE_FIRMWARE(api) \
@@ -182,6 +185,7 @@ const struct iwl_cfg iwl9270_2ac_cfg = {
 const struct iwl_cfg iwl9460_2ac_cfg = {
.name = "Intel(R) Dual Band Wireless AC 9460",
.fw_name_pre = IWL9000_FW_PRE,
+   .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE,
IWL_DEVICE_9000,
.ht_params = _ht_params,
.nvm_ver = IWL9000_NVM_VERSION,
@@ -193,6 +197,7 @@ const struct iwl_cfg iwl9460_2ac_cfg = {
 const struct iwl_cfg iwl9560_2ac_cfg = {
.name = "Intel(R) Dual Band Wireless AC 9560",
.fw_name_pre = IWL9000_FW_PRE,
+   .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE,
IWL_DEVICE_9000,
.ht_params = _ht_params,
.nvm_ver = IWL9000_NVM_VERSION,
@@ -202,5 +207,6 @@ const struct iwl_cfg iwl9560_2ac_cfg = {
 };
 
 MODULE_FIRMWARE(IWL9000_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX));
+MODULE_FIRMWARE(IWL9000RFB_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX));
 MODULE_FIRMWARE(IWL9260A_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX));
 MODULE_FIRMWARE(IWL9260B_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX));
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-config.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-config.h
index a12197e3ce78..8b3ebd1d4a3d 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-config.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-config.h
@@ -275,6 +275,8 @@ struct iwl_pwr_tx_backoff {
  * filename is constructed as fw_name_pre.ucode.
  * @fw_name_pre_next_step: same as @fw_name_pre, only for next step
  * (if supported)
+ * @fw_name_pre_rf_next_step: same as @fw_name_pre_next_step, only for rf next
+ * step. Supported only in integrated solutions.
  * @ucode_api_max: Highest version of uCode API supported by driver.
  * @ucode_api_min: Lowest version of uCode API supported by driver.
  * @max_inst_size: The maximal length of the fw inst section
@@ -325,6 +327,7 @@ struct iwl_cfg {
const char *name;
const char *fw_name_pre;
const char *fw_name_pre_next_step;
+   const char *fw_name_pre_rf_next_step;
/* params not likely to change within a device family */
const struct iwl_base_params *base_params;
/* params likely to change within a device family */
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-csr.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
index c9481b23b1a7..36fb20168598 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
@@ -316,6 +316,11 @@
 #define CSR_HW_REV_DASH(_val)  (((_val) & 0x003) >> 0)
 #define CSR_HW_REV_STEP(_val)  (((_val) & 0x00C) >> 2)
 
+/* HW RFID */
+#define CSR_HW_RFID_FLAVOR(_val)   (((_val) & 0x00F) >> 0)
+#define CSR_HW_RFID_DASH(_val) (((_val) & 0x0F0) >> 4)
+#define CSR_HW_RFID_STEP(_val) (((_val) & 0xF00) >> 8)
+#define CSR_HW_RFID_TYPE(_val) (((_val) & 0x0FFF000) >> 12)
 
 /**
  *  hw_rev values
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
index 5cfacb0bca84..806933377c58 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
@@ -218,6 +218,10 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool 
first)
if (drv->trans->cfg->device_family == IWL_DEVICE_FAMILY_8000 &&
CSR_HW_REV_STEP(drv->trans->hw_rev) == SILICON_B_STEP)
fw_pre_name = cfg->fw_name_pre_next_step;
+   else if (drv->trans->cfg->integrated &&
+

[PATCH 21/25] iwlwifi: mvm: remove unused TX_CMD_NEXT_FRAME_*

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

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h | 25 +-
 1 file changed, 1 insertion(+), 24 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 052b7f0db889..30008237323a 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h
@@ -177,29 +177,6 @@ enum iwl_tx_cmd_sec_ctrl {
TX_CMD_SEC_KEY_FROM_TABLE   = 0x10,
 };
 
-/* TODO: how does these values are OK with only 16 bit variable??? */
-/*
- * TX command next frame info
- *
- * bits 0:2 - security control (TX_CMD_SEC_*)
- * bit 3 - immediate ACK required
- * bit 4 - rate is taken from STA table
- * bit 5 - frame belongs to BA stream
- * bit 6 - immediate BA response expected
- * bit 7 - unused
- * bits 8:15 - Station ID
- * bits 16:31 - rate
- */
-#define TX_CMD_NEXT_FRAME_ACK_MSK  (0x8)
-#define TX_CMD_NEXT_FRAME_STA_RATE_MSK (0x10)
-#define TX_CMD_NEXT_FRAME_BA_MSK   (0x20)
-#define TX_CMD_NEXT_FRAME_IMM_BA_RSP_MSK   (0x40)
-#define TX_CMD_NEXT_FRAME_FLAGS_MSK(0xf8)
-#define TX_CMD_NEXT_FRAME_STA_ID_MSK   (0xff00)
-#define TX_CMD_NEXT_FRAME_STA_ID_POS   (8)
-#define TX_CMD_NEXT_FRAME_RATE_MSK (0x)
-#define TX_CMD_NEXT_FRAME_RATE_POS (16)
-
 /*
  * TX command Frame life time in us - to be written in pm_frame_timeout
  */
@@ -265,7 +242,7 @@ enum iwl_tx_offload_assist_flags_pos {
  * @initial_rate_index: index into the the rate table for initial TX attempt.
  * Applied if TX_CMD_FLG_STA_RATE_MSK is set, normally 0 for data frames.
  * @key: security key
- * @next_frame_flags: TX_CMD_SEC_* and TX_CMD_NEXT_FRAME_*
+ * @reserved3: reserved
  * @life_time: frame life time (usecs??)
  * @dram_lsb_ptr: Physical address of scratch area in the command (try_cnt +
  * btkill_cnd + reserved), first 32 bits. "0" disables usage.
-- 
2.11.0



[PATCH 15/25] iwlwifi: mvm: disentangle binding command versions

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

The comments/size of the different binding commands get lost
in documentation, so introduce two different command structs
that can be used there.

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

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
index a4567d5206e2..4c5f38e50caa 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
@@ -997,6 +997,26 @@ struct iwl_time_event_notif {
 /* Bindings and Time Quota */
 
 /**
+ * struct iwl_binding_cmd_v1 - configuring bindings
+ * ( BINDING_CONTEXT_CMD = 0x2b )
+ * @id_and_color: ID and color of the relevant Binding,
+ *  iwl_mvm_id_and_color
+ * @action: action to perform, one of FW_CTXT_ACTION_*
+ * @macs: array of MAC id and colors which belong to the binding,
+ *  iwl_mvm_id_and_color
+ * @phy: PHY id and color which belongs to the binding,
+ *  iwl_mvm_id_and_color
+ */
+struct iwl_binding_cmd_v1 {
+   /* COMMON_INDEX_HDR_API_S_VER_1 */
+   __le32 id_and_color;
+   __le32 action;
+   /* BINDING_DATA_API_S_VER_1 */
+   __le32 macs[MAX_MACS_IN_BINDING];
+   __le32 phy;
+} __packed; /* BINDING_CMD_API_S_VER_1 */
+
+/**
  * struct iwl_binding_cmd - configuring bindings
  * ( BINDING_CONTEXT_CMD = 0x2b )
  * @id_and_color: ID and color of the relevant Binding,
@@ -1015,11 +1035,10 @@ struct iwl_binding_cmd {
/* BINDING_DATA_API_S_VER_1 */
__le32 macs[MAX_MACS_IN_BINDING];
__le32 phy;
-   /* BINDING_CMD_API_S_VER_1 */
__le32 lmac_id;
 } __packed; /* BINDING_CMD_API_S_VER_2 */
 
-#define IWL_BINDING_CMD_SIZE_V1offsetof(struct iwl_binding_cmd, 
lmac_id)
+#define IWL_BINDING_CMD_SIZE_V1sizeof(struct iwl_binding_cmd_v1)
 #define IWL_LMAC_24G_INDEX 0
 #define IWL_LMAC_5G_INDEX  1
 
-- 
2.11.0



[PATCH 11/25] iwlwifi: mvm: wait for the flushed queue only

2017-06-02 Thread Luca Coelho
From: Sara Sharon 

The function flushed only agg queue and no more traffic
is queued on it.
However, it waits for all queues to empty, which is not
necessary and may take more time.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
index bf105c6572ba..9f74d4ff6b73 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
@@ -2850,8 +2850,7 @@ int iwl_mvm_sta_tx_agg_flush(struct iwl_mvm *mvm, struct 
ieee80211_vif *vif,
iwl_mvm_drain_sta(mvm, mvmsta, true);
if (iwl_mvm_flush_tx_path(mvm, BIT(txq_id), 0))
IWL_ERR(mvm, "Couldn't flush the AGG queue\n");
-   iwl_trans_wait_tx_queues_empty(mvm->trans,
-  mvmsta->tfd_queue_msk);
+   iwl_trans_wait_tx_queues_empty(mvm->trans, BIT(txq_id));
iwl_mvm_drain_sta(mvm, mvmsta, false);
 
iwl_mvm_sta_tx_agg(mvm, sta, tid, txq_id, false);
-- 
2.11.0



[PATCH 14/25] iwlwifi: update device ID for a000 family

2017-06-02 Thread Luca Coelho
From: Sara Sharon 

Three configurations will share device ID 2720, and will
be differentiated by RF ID.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/iwl-csr.h  |  3 ++-
 drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 12 +++-
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-csr.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
index fa120fb55373..c9481b23b1a7 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
@@ -348,7 +348,8 @@ enum {
 
 /* RF_ID value */
 #define CSR_HW_RF_ID_TYPE_JF   (0x00105000)
-#define CSR_HW_RF_ID_TYPE_HR   (0x00109000)
+#define CSR_HW_RF_ID_TYPE_HR   (0x0010A000)
+#define CSR_HW_RF_ID_TYPE_HRCDB(0x00109000)
 
 /* EEPROM REG */
 #define CSR_EEPROM_REG_READ_VALID_MSK  (0x0001)
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
index e51760e752d4..2d92d3708619 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
@@ -538,7 +538,7 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
 
 /* a000 Series */
{IWL_PCI_DEVICE(0x2720, 0x0A10, iwla000_2ac_cfg_hr_cdb)},
-   {IWL_PCI_DEVICE(0x2722, 0x0A10, iwla000_2ac_cfg_hr)},
+   {IWL_PCI_DEVICE(0x34F0, 0x0310, iwla000_2ac_cfg_jf)},
 #endif /* CONFIG_IWLMVM */
 
{0}
@@ -672,10 +672,12 @@ static int iwl_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
iwl_trans->cfg = cfg_7265d;
}
 
-   if (iwl_trans->cfg->rf_id &&
-   (cfg == _2ac_cfg_hr || cfg == _2ac_cfg_hr_cdb) &&
-iwl_trans->hw_rf_id == CSR_HW_RF_ID_TYPE_JF) {
-   cfg = _2ac_cfg_jf;
+   if (iwl_trans->cfg->rf_id && cfg == _2ac_cfg_hr_cdb) {
+   if (iwl_trans->hw_rf_id == CSR_HW_RF_ID_TYPE_JF)
+   cfg = _2ac_cfg_jf;
+   else if (iwl_trans->hw_rf_id == CSR_HW_RF_ID_TYPE_HR)
+   cfg = _2ac_cfg_hr;
+
iwl_trans->cfg = cfg;
}
 #endif
-- 
2.11.0



[PATCH 19/25] iwlwifi: pcie: support page dumping in wrt in gen2

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

In gen2, page dumping needs to be done in the trans
layer, as it is the one with access to the paging
pointers.

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

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 70acf850a9f1..85f44d8f1c41 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -2754,6 +2754,13 @@ static struct iwl_trans_dump_data
  (PAGE_SIZE << trans_pcie->rx_page_order));
}
 
+   /* Paged memory for gen2 HW */
+   if (trans->cfg->gen2)
+   for (i = 0; i < trans_pcie->init_dram.paging_cnt; i++)
+   len += sizeof(*data) +
+  sizeof(struct iwl_fw_error_dump_paging) +
+  trans_pcie->init_dram.paging[i].size;
+
dump_data = vzalloc(len);
if (!dump_data)
return NULL;
@@ -2793,6 +2800,28 @@ static struct iwl_trans_dump_data
if (dump_rbs)
len += iwl_trans_pcie_dump_rbs(trans, , num_rbs);
 
+   /* Paged memory for gen2 HW */
+   if (trans->cfg->gen2) {
+   for (i = 0; i < trans_pcie->init_dram.paging_cnt; i++) {
+   struct iwl_fw_error_dump_paging *paging;
+   dma_addr_t addr =
+   trans_pcie->init_dram.paging[i].physical;
+   u32 page_len = trans_pcie->init_dram.paging[i].size;
+
+   data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_PAGING);
+   data->len = cpu_to_le32(sizeof(*paging) + page_len);
+   paging = (void *)data->data;
+   paging->index = cpu_to_le32(i);
+   dma_sync_single_for_cpu(trans->dev, addr, page_len,
+   DMA_BIDIRECTIONAL);
+   memcpy(paging->data,
+  trans_pcie->init_dram.paging[i].block, page_len);
+   data = iwl_fw_error_next_data(data);
+
+   len += sizeof(*data) + sizeof(*paging) + page_len;
+   }
+   }
+
len += iwl_trans_pcie_dump_monitor(trans, , monitor_len);
 
dump_data->len = len;
-- 
2.11.0



[PATCH 22/25] iwlwifi: kernel-doc: make proper links

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

Using %enum instead of  (and in one case, %struct) results in
the wrong parsing. Fix that so that if documentation is generated,
the result is clickable links.

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/iwl-fw-error-dump.h |  8 
 drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h   | 10 +-
 drivers/net/wireless/intel/iwlwifi/iwl-modparams.h |  2 +-
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-power.h  |  4 ++--
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-fw-error-dump.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-fw-error-dump.h
index 420c31dab263..cfebde68a391 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-fw-error-dump.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-fw-error-dump.h
@@ -116,7 +116,7 @@ enum iwl_fw_error_dump_type {
 
 /**
  * struct iwl_fw_error_dump_data - data for one type
- * @type: %enum iwl_fw_error_dump_type
+ * @type:  iwl_fw_error_dump_type
  * @len: the length starting from %data
  * @data: the data itself
  */
@@ -130,7 +130,7 @@ struct iwl_fw_error_dump_data {
  * struct iwl_fw_error_dump_file - the layout of the header of the file
  * @barker: must be %IWL_FW_ERROR_DUMP_BARKER
  * @file_len: the length of all the file starting from %barker
- * @data: array of %struct iwl_fw_error_dump_data
+ * @data: array of  iwl_fw_error_dump_data
  */
 struct iwl_fw_error_dump_file {
__le32 barker;
@@ -225,7 +225,7 @@ enum iwl_fw_error_dump_mem_type {
 
 /**
  * struct iwl_fw_error_dump_mem - chunk of memory
- * @type: %enum iwl_fw_error_dump_mem_type
+ * @type:  iwl_fw_error_dump_mem_type
  * @offset: the offset from which the memory was read
  * @data: the content of the memory
  */
@@ -324,7 +324,7 @@ enum iwl_fw_dbg_trigger {
 
 /**
  * struct iwl_fw_error_dump_trigger_desc - describes the trigger condition
- * @type: %enum iwl_fw_dbg_trigger
+ * @type:  iwl_fw_dbg_trigger
  * @data: raw data about what happened
  */
 struct iwl_fw_error_dump_trigger_desc {
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h
index 89bc008e152f..c178c8f32466 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h
@@ -468,7 +468,7 @@ enum iwl_fw_dbg_reg_operator {
 /**
  * struct iwl_fw_dbg_reg_op - an operation on a register
  *
- * @op: %enum iwl_fw_dbg_reg_operator
+ * @op:  iwl_fw_dbg_reg_operator
  * @addr: offset of the register
  * @val: value
  */
@@ -526,7 +526,7 @@ struct iwl_fw_dbg_mem_seg_tlv {
  * struct iwl_fw_dbg_dest_tlv - configures the destination of the debug data
  *
  * @version: version of the TLV - currently 0
- * @monitor_mode: %enum iwl_fw_dbg_monitor_mode
+ * @monitor_mode:  iwl_fw_dbg_monitor_mode
  * @size_power: buffer size will be 2^(size_power + 11)
  * @base_reg: addr of the base addr register (PRPH)
  * @end_reg:  addr of the end addr register (PRPH)
@@ -595,15 +595,15 @@ enum iwl_fw_dbg_trigger_vif_type {
 
 /**
  * struct iwl_fw_dbg_trigger_tlv - a TLV that describes the trigger
- * @id: %enum iwl_fw_dbg_trigger
- * @vif_type: %enum iwl_fw_dbg_trigger_vif_type
+ * @id:  iwl_fw_dbg_trigger
+ * @vif_type:  iwl_fw_dbg_trigger_vif_type
  * @stop_conf_ids: bitmap of configurations this trigger relates to.
  * if the mode is %IWL_FW_DBG_TRIGGER_STOP, then if the bit corresponding
  * to the currently running configuration is set, the data should be
  * collected.
  * @stop_delay: how many milliseconds to wait before collecting the data
  * after the STOP trigger fires.
- * @mode: %enum iwl_fw_dbg_trigger_mode - can be stop / start of both
+ * @mode:  iwl_fw_dbg_trigger_mode - can be stop / start of both
  * @start_conf_id: if mode is %IWL_FW_DBG_TRIGGER_START, this defines what
  * configuration should be applied when the triggers kicks in.
  * @occurrences: number of occurrences. 0 means the trigger will never fire.
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-modparams.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-modparams.h
index 4d32b10fe50c..0bd85e58cc2c 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-modparams.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-modparams.h
@@ -114,7 +114,7 @@ enum iwl_uapsd_disable {
  * @debug_level: levels are IWL_DL_*
  * @ant_coupling: antenna coupling in dB, default = 0
  * @nvm_file: specifies a external NVM file
- * @uapsd_disable: disable U-APSD, see %enum iwl_uapsd_disable, default =
+ * @uapsd_disable: disable U-APSD, see  iwl_uapsd_disable, default =
  * IWL_DISABLE_UAPSD_BSS | IWL_DISABLE_UAPSD_P2P_CLIENT
  * @d0i3_disable: disable d0i3, default = 1,
  * @d0i3_entry_delay: time to wait after no refs are taken before
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-power.h 

[PATCH 17/25] iwlwifi: mvm: document structures used by commands

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

Add documentation to a lot of command IDs that links to the
appropriate structure(s) used with those IDs. In one case,
actually add and use a new struct for that purpose.

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

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/coex.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/coex.c
index 49b4418e6c35..fe7f1e424f55 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/coex.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/coex.c
@@ -914,7 +914,8 @@ void iwl_mvm_rx_ant_coupling_notif(struct iwl_mvm *mvm,
   struct iwl_rx_cmd_buffer *rxb)
 {
struct iwl_rx_packet *pkt = rxb_addr(rxb);
-   u32 ant_isolation = le32_to_cpup((void *)pkt->data);
+   struct iwl_mvm_antenna_coupling_notif *notif = (void *)pkt->data;
+   u32 ant_isolation = le32_to_cpu(notif->isolation);
struct iwl_bt_coex_corun_lut_update_cmd cmd = {};
u8 __maybe_unused lower_bound, upper_bound;
u8 lut;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
index 6e0e65eb2b4d..332f204761cc 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
@@ -130,31 +130,86 @@ enum iwl_mvm_tx_fifo {
 };
 
 
-/* commands */
+/**
+ * enum iwl_legacy_cmds - legacy group command IDs
+ */
 enum iwl_legacy_cmds {
+   /**
+* @MVM_ALIVE:
+* Alive data from the firmware, as described in
+*  mvm_alive_resp_v3 or  mvm_alive_resp.
+*/
MVM_ALIVE = 0x1,
+
+   /**
+* @REPLY_ERROR: Cause an error in the firmware, for testing purposes.
+*/
REPLY_ERROR = 0x2,
+
+   /**
+* @ECHO_CMD: Send data to the device to have it returned immediately.
+*/
ECHO_CMD = 0x3,
 
+   /**
+* @INIT_COMPLETE_NOTIF: Notification that initialization is complete.
+*/
INIT_COMPLETE_NOTIF = 0x4,
 
-   /* PHY context commands */
+   /**
+* @PHY_CONTEXT_CMD:
+* Add/modify/remove a PHY context, using  iwl_phy_context_cmd.
+*/
PHY_CONTEXT_CMD = 0x8,
+
+   /**
+* @DBG_CFG: Debug configuration command.
+*/
DBG_CFG = 0x9,
+
+   /**
+* @ANTENNA_COUPLING_NOTIFICATION:
+* Antenna coupling data,  iwl_mvm_antenna_coupling_notif
+*/
ANTENNA_COUPLING_NOTIFICATION = 0xa,
 
-   /* UMAC scan commands */
+   /**
+* @SCAN_ITERATION_COMPLETE_UMAC:
+* Firmware indicates a scan iteration completed, using
+*  iwl_umac_scan_iter_complete_notif.
+*/
SCAN_ITERATION_COMPLETE_UMAC = 0xb5,
+
+   /**
+* @SCAN_CFG_CMD:
+* uses  iwl_scan_config_v1 or  iwl_scan_config
+*/
SCAN_CFG_CMD = 0xc,
SCAN_REQ_UMAC = 0xd,
SCAN_ABORT_UMAC = 0xe,
+
+   /**
+* @SCAN_COMPLETE_UMAC: uses  iwl_umac_scan_complete
+*/
SCAN_COMPLETE_UMAC = 0xf,
 
BA_WINDOW_STATUS_NOTIFICATION_ID = 0x13,
 
-   /* station table */
+   /**
+* @ADD_STA_KEY:
+*  iwl_mvm_add_sta_key_cmd_v1 or
+*  iwl_mvm_add_sta_key_cmd.
+*/
ADD_STA_KEY = 0x17,
+
+   /**
+* @ADD_STA:
+*  iwl_mvm_add_sta_cmd or  iwl_mvm_add_sta_cmd_v7.
+*/
ADD_STA = 0x18,
+   /**
+* @REMOVE_STA:  iwl_mvm_rm_sta_cmd
+*/
REMOVE_STA = 0x19,
 
/* paging get item */
@@ -162,10 +217,23 @@ enum iwl_legacy_cmds {
 
/* TX */
TX_CMD = 0x1c,
+
+   /**
+* @TXPATH_FLUSH:  iwl_tx_path_flush_cmd
+*/
TXPATH_FLUSH = 0x1e,
+
+   /**
+* @MGMT_MCAST_KEY:
+*  iwl_mvm_mgmt_mcast_key_cmd or
+*  iwl_mvm_mgmt_mcast_key_cmd_v1
+*/
MGMT_MCAST_KEY = 0x1f,
 
/* scheduler config */
+   /**
+* @SCD_QUEUE_CFG:  iwl_scd_txq_cfg_cmd
+*/
SCD_QUEUE_CFG = 0x1d,
 
/* global key */
@@ -179,17 +247,40 @@ enum iwl_legacy_cmds {
TDLS_CHANNEL_SWITCH_NOTIFICATION = 0xaa,
TDLS_CONFIG_CMD = 0xa7,
 
-   /* MAC and Binding commands */
+   /**
+* @MAC_CONTEXT_CMD:  iwl_mac_ctx_cmd
+*/
MAC_CONTEXT_CMD = 0x28,
+
+   /**
+* @TIME_EVENT_CMD:
+*  iwl_time_event_cmd, response in  iwl_time_event_resp
+*/
TIME_EVENT_CMD = 0x29, /* both CMD and response */
+   /**
+* @TIME_EVENT_NOTIFICATION:  iwl_time_event_notif
+*/
TIME_EVENT_NOTIFICATION = 0x2a,
+   /**
+* @BINDING_CONTEXT_CMD:
+*  iwl_binding_cmd or  

[PATCH 04/25] iwlwifi: mvm: fix endianness in lq_cmd declaration

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

This member doesn't seem to be used, so this doesn't really
fix anything, but it's better to have the right type there.

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

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-rs.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-rs.h
index 1b7d265ffb0a..019a9a92a1ed 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-rs.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-rs.h
@@ -387,7 +387,7 @@ enum {
 struct iwl_lq_cmd {
u8 sta_id;
u8 reduced_tpc;
-   u16 control;
+   __le16 control;
/* LINK_QUAL_GENERAL_PARAMS_API_S_VER_1 */
u8 flags;
u8 mimo_delim;
-- 
2.11.0



[PATCH 08/25] iwlwifi: mvm: use u8 for reserved fields

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

There's no saying what kind of type a reserved field will
get in the future, so use u8 arrays to reserve space.

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

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-stats.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-stats.h
index 6371c342b96d..809ec1ba5025 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-stats.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-stats.h
@@ -72,7 +72,7 @@ struct mvm_statistics_dbg {
__le32 burst_check;
__le32 burst_count;
__le32 wait_for_silence_timeout_cnt;
-   __le32 reserved[3];
+   u8 reserved[12];
 } __packed; /* STATISTICS_DEBUG_API_S_VER_2 */
 
 struct mvm_statistics_div {
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
index 8e4919a27cc7..69f3065ba600 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
@@ -1612,7 +1612,7 @@ struct iwl_mcc_update_cmd {
u8 source_id;
u8 reserved;
__le32 key;
-   __le32 reserved2[5];
+   u8 reserved2[20];
 } __packed; /* LAR_UPDATE_MCC_CMD_API_S_VER_2 */
 
 /**
@@ -2196,7 +2196,7 @@ struct iwl_link_qual_msrmnt_notif {
__le32 tx_frame_dropped;
__le32 mac_id;
__le32 status;
-   __le32 reserved[3];
+   u8 reserved[12];
 } __packed; /* LQM_MEASUREMENT_COMPLETE_NTF_API_S_VER1 */
 
 /**
-- 
2.11.0



[PATCH 06/25] iwlwifi: mvm: use proper sta_addr in firmware API

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

There's no point to declare an address as a __le32/__le16
and then only take a pointer to it anyway, change that to
just a sta_addr[ETH_ALEN].

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h | 6 ++
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c| 2 +-
 2 files changed, 3 insertions(+), 5 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 81b98915b1a4..c03fbb81efd1 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h
@@ -594,8 +594,7 @@ struct iwl_mvm_tx_resp {
 /**
  * struct iwl_mvm_ba_notif - notifies about reception of BA
  * ( BA_NOTIF = 0xc5 )
- * @sta_addr_lo32: lower 32 bits of the MAC address
- * @sta_addr_hi16: upper 16 bits of the MAC address
+ * @sta_addr: MAC address
  * @sta_id: Index of recipient (BA-sending) station in fw's station table
  * @tid: tid of the session
  * @seq_ctl:
@@ -609,8 +608,7 @@ struct iwl_mvm_tx_resp {
  * for Tx-ing then this value will be set to 0 by FW.
  */
 struct iwl_mvm_ba_notif {
-   __le32 sta_addr_lo32;
-   __le16 sta_addr_hi16;
+   u8 sta_addr[ETH_ALEN];
__le16 reserved;
 
u8 sta_id;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
index aa76c8baecce..64ca8b92f8d2 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
@@ -1850,7 +1850,7 @@ void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct 
iwl_rx_cmd_buffer *rxb)
 
IWL_DEBUG_TX_REPLY(mvm,
   "BA_NOTIFICATION Received from %pM, sta_id = %d\n",
-  (u8 *)_notif->sta_addr_lo32, ba_notif->sta_id);
+  ba_notif->sta_addr, ba_notif->sta_id);
 
IWL_DEBUG_TX_REPLY(mvm,
   "TID = %d, SeqCtl = %d, bitmap = 0x%llx, scd_flow = 
%d, scd_ssn = %d sent:%d, acked:%d\n",
-- 
2.11.0



[PATCH 09/25] iwlwifi: mvm: disentangle paging command structs

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

Instead of using a union and hard-coding the size difference,
declare both command structs properly, use a union on the
stack to build them and the right sizeof() for the size.

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

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
index 69f3065ba600..a1cce18460bb 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
@@ -508,7 +508,26 @@ struct iwl_nvm_access_cmd {
 
 #define NUM_OF_FW_PAGING_BLOCKS33 /* 32 for data and 1 block for CSS */
 
-/*
+/**
+ * struct iwl_fw_paging_cmd_v1 - paging layout
+ *
+ * (FW_PAGING_BLOCK_CMD = 0x4f)
+ *
+ * Send to FW the paging layout in the driver.
+ *
+ * @flags: various flags for the command
+ * @block_size: the block size in powers of 2
+ * @block_num: number of blocks specified in the command.
+ * @device_phy_addr: virtual addresses from device side
+ */
+struct iwl_fw_paging_cmd_v1 {
+   __le32 flags;
+   __le32 block_size;
+   __le32 block_num;
+   __le32 device_phy_addr[NUM_OF_FW_PAGING_BLOCKS];
+} __packed; /* FW_PAGING_BLOCK_CMD_API_S_VER_1 */
+
+/**
  * struct iwl_fw_paging_cmd - paging layout
  *
  * (FW_PAGING_BLOCK_CMD = 0x4f)
@@ -519,16 +538,12 @@ struct iwl_nvm_access_cmd {
  * @block_size: the block size in powers of 2
  * @block_num: number of blocks specified in the command.
  * @device_phy_addr: virtual addresses from device side
- * 32 bit address for API version 1, 64 bit address for API version 2.
-*/
+ */
 struct iwl_fw_paging_cmd {
__le32 flags;
__le32 block_size;
__le32 block_num;
-   union {
-   __le32 addr32[NUM_OF_FW_PAGING_BLOCKS];
-   __le64 addr64[NUM_OF_FW_PAGING_BLOCKS];
-   } device_phy_addr;
+   __le64 device_phy_addr[NUM_OF_FW_PAGING_BLOCKS];
 } __packed; /* FW_PAGING_BLOCK_CMD_API_S_VER_2 */
 
 /*
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
index a8804bc979fe..8bdeb7c891e9 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
@@ -384,20 +384,23 @@ static int iwl_save_fw_paging(struct iwl_mvm *mvm,
 /* send paging cmd to FW in case CPU2 has paging image */
 static int iwl_send_paging_cmd(struct iwl_mvm *mvm, const struct fw_img *fw)
 {
-   struct iwl_fw_paging_cmd paging_cmd = {
-   .flags =
+   union {
+   struct iwl_fw_paging_cmd v2;
+   struct iwl_fw_paging_cmd_v1 v1;
+   } paging_cmd = {
+   .v2.flags =
cpu_to_le32(PAGING_CMD_IS_SECURED |
PAGING_CMD_IS_ENABLED |
(mvm->num_of_pages_in_last_blk <<
PAGING_CMD_NUM_OF_PAGES_IN_LAST_GRP_POS)),
-   .block_size = cpu_to_le32(BLOCK_2_EXP_SIZE),
-   .block_num = cpu_to_le32(mvm->num_of_paging_blk),
+   .v2.block_size = cpu_to_le32(BLOCK_2_EXP_SIZE),
+   .v2.block_num = cpu_to_le32(mvm->num_of_paging_blk),
};
-   int blk_idx, size = sizeof(paging_cmd);
+   int blk_idx, size = sizeof(paging_cmd.v2);
 
/* A bit hard coded - but this is the old API and will be deprecated */
if (!iwl_mvm_has_new_tx_api(mvm))
-   size -= NUM_OF_FW_PAGING_BLOCKS * 4;
+   size = sizeof(paging_cmd.v1);
 
/* loop for for all paging blocks + CSS block */
for (blk_idx = 0; blk_idx < mvm->num_of_paging_blk + 1; blk_idx++) {
@@ -408,11 +411,11 @@ static int iwl_send_paging_cmd(struct iwl_mvm *mvm, const 
struct fw_img *fw)
if (iwl_mvm_has_new_tx_api(mvm)) {
__le64 phy_addr = cpu_to_le64(addr);
 
-   paging_cmd.device_phy_addr.addr64[blk_idx] = phy_addr;
+   paging_cmd.v2.device_phy_addr[blk_idx] = phy_addr;
} else {
__le32 phy_addr = cpu_to_le32(addr);
 
-   paging_cmd.device_phy_addr.addr32[blk_idx] = phy_addr;
+   paging_cmd.v1.device_phy_addr[blk_idx] = phy_addr;
}
}
 
-- 
2.11.0



[PATCH 07/25] iwlwifi: mvm: fix MCC endianness bug

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

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

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
index c69aff91404b..8e4919a27cc7 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
@@ -1681,7 +1681,7 @@ struct iwl_mcc_update_resp {
  * @reserved1: reserved for alignment
  */
 struct iwl_mcc_chub_notif {
-   u16 mcc;
+   __le16 mcc;
u8 source_id;
u8 reserved1;
 } __packed; /* LAR_MCC_NOTIFY_S */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
index 67a6c9c9af27..e7b16ecccb86 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
@@ -913,8 +913,8 @@ void iwl_mvm_rx_chub_update_mcc(struct iwl_mvm *mvm,
if (WARN_ON_ONCE(!iwl_mvm_is_lar_supported(mvm)))
return;
 
-   mcc[0] = notif->mcc >> 8;
-   mcc[1] = notif->mcc & 0xff;
+   mcc[0] = le16_to_cpu(notif->mcc) >> 8;
+   mcc[1] = le16_to_cpu(notif->mcc) & 0xff;
mcc[2] = '\0';
src = notif->source_id;
 
-- 
2.11.0



[PATCH 01/25] iwlwifi: mvm: flush per station for DQA mode

2017-06-02 Thread Luca Coelho
From: Sara Sharon 

Avoid using the global flush and move to flush per
station whenever possible in DQA mode.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c  | 26 --
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h   |  2 ++
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c   |  6 -
 .../net/wireless/intel/iwlwifi/mvm/time-event.c|  5 -
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c| 17 ++
 5 files changed, 42 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index a67aa1f5a51c..f4437d5b2e73 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -1451,7 +1451,7 @@ static void iwl_mvm_prepare_mac_removal(struct iwl_mvm 
*mvm,
 {
u32 tfd_msk = iwl_mvm_mac_get_queues_mask(vif);
 
-   if (tfd_msk) {
+   if (tfd_msk && !iwl_mvm_is_dqa_supported(mvm)) {
/*
 * mac80211 first removes all the stations of the vif and
 * then removes the vif. When it removes a station it also
@@ -1460,6 +1460,8 @@ static void iwl_mvm_prepare_mac_removal(struct iwl_mvm 
*mvm,
 * of these AMPDU sessions are properly closed.
 * We still need to take care of the shared queues of the vif.
 * Flush them here.
+* For DQA mode there is no need - broacast and multicast queue
+* are flushed separately.
 */
mutex_lock(>mutex);
iwl_mvm_flush_tx_path(mvm, tfd_msk, 0);
@@ -3988,21 +3990,21 @@ static void iwl_mvm_mac_flush(struct ieee80211_hw *hw,
/* make sure only TDLS peers or the AP are flushed */
WARN_ON(i != mvmvif->ap_sta_id && !sta->tdls);
 
-   msk |= mvmsta->tfd_queue_msk;
+   if (drop) {
+   if (iwl_mvm_flush_sta(mvm, mvmsta, false, 0))
+   IWL_ERR(mvm, "flush request fail\n");
+   } else {
+   msk |= mvmsta->tfd_queue_msk;
+   }
}
 
-   if (drop) {
-   if (iwl_mvm_flush_tx_path(mvm, msk, 0))
-   IWL_ERR(mvm, "flush request fail\n");
-   mutex_unlock(>mutex);
-   } else {
-   mutex_unlock(>mutex);
+   mutex_unlock(>mutex);
 
-   /* this can take a while, and we may need/want other operations
-* to succeed while doing this, so do it without the mutex held
-*/
+   /* this can take a while, and we may need/want other operations
+* to succeed while doing this, so do it without the mutex held
+*/
+   if (!drop)
iwl_trans_wait_tx_queues_empty(mvm->trans, msk);
-   }
 }
 
 static int iwl_mvm_mac_get_survey(struct ieee80211_hw *hw, int idx,
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
index 4e74a6b90e70..53fbdb9136ab 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
@@ -1355,6 +1355,8 @@ const char *iwl_mvm_get_tx_fail_reason(u32 status);
 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 int_sta, u32 flags);
+
 void iwl_mvm_async_handlers_purge(struct iwl_mvm *mvm);
 
 static inline void iwl_mvm_set_tx_cmd_ccmp(struct ieee80211_tx_info *info,
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
index f5c786ddc526..bf105c6572ba 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
@@ -1611,7 +1611,7 @@ int iwl_mvm_rm_sta(struct iwl_mvm *mvm,
if (ret)
return ret;
/* flush its queues here since we are freeing mvm_sta */
-   ret = iwl_mvm_flush_tx_path(mvm, mvm_sta->tfd_queue_msk, 0);
+   ret = iwl_mvm_flush_sta(mvm, mvm_sta, false, 0);
if (ret)
return ret;
ret = iwl_trans_wait_tx_queues_empty(mvm->trans,
@@ -1978,6 +1978,8 @@ static void iwl_mvm_free_bcast_sta_queues(struct iwl_mvm 
*mvm,
 
lockdep_assert_held(>mutex);
 
+   iwl_mvm_flush_sta(mvm, >bcast_sta, true, 0);
+
if (vif->type == NL80211_IFTYPE_AP ||
vif->type == NL80211_IFTYPE_ADHOC)
iwl_mvm_disable_txq(mvm, vif->cab_queue, vif->cab_queue,
@@ -2176,6 +2178,8 @@ int iwl_mvm_rm_mcast_sta(struct iwl_mvm *mvm, struct 
ieee80211_vif *vif)
if (!iwl_mvm_is_dqa_supported(mvm))

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

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

Hi,

Here's my first set of patches for v4.13.  These are the changes:

* A bunch of FW API documentation updates;
* Continued work for the new A000 family;
* Some small fixes and cleanups here and there.

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

Please review.

Cheers,
Luca.


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

Johannes Berg (16):
  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: remove unused REPLY_MAX
  iwlwifi: mvm: fix many kernel-doc warnings

Liad Kaufman (2):
  iwlwifi: mvm: remove wrt support of page dumps in gen2
  iwlwifi: pcie: support page dumping in wrt in gen2

Sara Sharon (6):
  iwlwifi: mvm: flush per station for DQA mode
  iwlwifi: mvm: support getting nvm data from firmware
  iwlwifi: mvm: support old method of NVM parsing
  iwlwifi: mvm: wait for the flushed queue only
  iwlwifi: update device ID for a000 family
  iwlwifi: add wait for tx queue empty

 drivers/net/wireless/intel/iwlwifi/iwl-9000.c  |   6 +
 drivers/net/wireless/intel/iwlwifi/iwl-config.h|   3 +
 drivers/net/wireless/intel/iwlwifi/iwl-csr.h   |   8 +-
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c   |   4 +
 .../net/wireless/intel/iwlwifi/iwl-fw-error-dump.h |   8 +-
 drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h   |  14 +-
 drivers/net/wireless/intel/iwlwifi/iwl-modparams.h |   2 +-
 drivers/net/wireless/intel/iwlwifi/iwl-trans.c |   2 +
 drivers/net/wireless/intel/iwlwifi/iwl-trans.h |  20 +-
 drivers/net/wireless/intel/iwlwifi/mvm/coex.c  |   3 +-
 drivers/net/wireless/intel/iwlwifi/mvm/constants.h |   1 +
 .../net/wireless/intel/iwlwifi/mvm/fw-api-coex.h   |  10 +-
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-d3.h |  29 +-
 .../net/wireless/intel/iwlwifi/mvm/fw-api-mac.h|  10 +-
 .../net/wireless/intel/iwlwifi/mvm/fw-api-power.h  |  45 +-
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-rs.h |   2 +-
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-rx.h |   7 +-
 .../net/wireless/intel/iwlwifi/mvm/fw-api-scan.h   |  32 +-
 .../net/wireless/intel/iwlwifi/mvm/fw-api-sta.h|  46 +-
 .../net/wireless/intel/iwlwifi/mvm/fw-api-stats.h  |  29 +-
 .../net/wireless/intel/iwlwifi/mvm/fw-api-tof.h|  16 +-
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h |  67 ++-
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h| 536 +
 drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c|   6 +-
 drivers/net/wireless/intel/iwlwifi/mvm/fw.c|  54 ++-
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c  |  28 +-
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h   |   4 +
 drivers/net/wireless/intel/iwlwifi/mvm/nvm.c   |  94 +++-
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c   |   1 +
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c   |  48 +-
 drivers/net/wireless/intel/iwlwifi/mvm/sta.h   |   2 +
 .../net/wireless/intel/iwlwifi/mvm/time-event.c|   5 +-
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c|  19 +-
 drivers/net/wireless/intel/iwlwifi/pcie/drv.c  |  12 +-
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c| 101 ++--
 drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c  |   9 +-
 36 files changed, 989 insertions(+), 294 deletions(-)

-- 
2.11.0



[PATCH 02/25] iwlwifi: mvm: support getting nvm data from firmware

2017-06-02 Thread Luca Coelho
From: Sara Sharon 

This API replaces the complex NVM parsing of the iwlwifi module.
Instead, we get all needed data from firmware.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h   | 77 +++
 drivers/net/wireless/intel/iwlwifi/mvm/fw.c   | 37 +-
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h  |  2 +
 drivers/net/wireless/intel/iwlwifi/mvm/nvm.c  | 90 ++-
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c  |  1 +
 drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c |  9 ++-
 6 files changed, 194 insertions(+), 22 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
index f545c5f9e4e3..0996127897c1 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
@@ -345,6 +345,7 @@ enum iwl_prot_offload_subcmd_ids {
 
 enum iwl_regulatory_and_nvm_subcmd_ids {
NVM_ACCESS_COMPLETE = 0x0,
+   NVM_GET_INFO = 0x2,
 };
 
 enum iwl_debug_cmds {
@@ -2259,4 +2260,80 @@ struct iwl_init_extended_cfg_cmd {
__le32 init_flags;
 } __packed; /* INIT_EXTENDED_CFG_CMD_API_S_VER_1 */
 
+/*
+ * struct iwl_nvm_get_info - request to get NVM data
+ */
+struct iwl_nvm_get_info {
+   __le32 reserved;
+} __packed; /* GRP_REGULATORY_NVM_GET_INFO_CMD_S_VER_1 */
+
+/**
+ * struct iwl_nvm_get_info_general - general NVM data
+ * @flags: 1 - empty, 0 - valid
+ * @nvm_version: nvm version
+ * @board_type: board type
+ */
+struct iwl_nvm_get_info_general {
+   __le32 flags;
+   __le16 nvm_version;
+   u8 board_type;
+   u8 reserved;
+} __packed; /* GRP_REGULATORY_NVM_GET_INFO_GENERAL_S_VER_1 */
+
+/**
+ * struct iwl_nvm_get_info_sku - mac information
+ * @enable_24g: band 2.4G enabled
+ * @enable_5g: band 5G enabled
+ * @enable_11n: 11n enabled
+ * @enable_11ac: 11ac enabled
+ * @mimo_disable: MIMO enabled
+ * @ext_crypto: Extended crypto enabled
+ */
+struct iwl_nvm_get_info_sku {
+   __le32 enable_24g;
+   __le32 enable_5g;
+   __le32 enable_11n;
+   __le32 enable_11ac;
+   __le32 mimo_disable;
+   __le32 ext_crypto;
+} __packed; /* GRP_REGULATORY_NVM_GET_INFO_MAC_SKU_SECTION_S_VER_1 */
+
+/**
+ * struct iwl_nvm_get_info_phy - phy information
+ * @tx_chains: BIT 0 chain A, BIT 1 chain B
+ * @rx_chains: BIT 0 chain A, BIT 1 chain B
+ */
+struct iwl_nvm_get_info_phy {
+   __le32 tx_chains;
+   __le32 rx_chains;
+} __packed; /* GRP_REGULATORY_NVM_GET_INFO_PHY_SKU_SECTION_S_VER_1 */
+
+#define IWL_NUM_CHANNELS (51)
+
+/**
+ * struct iwl_nvm_get_info_regulatory - regulatory information
+ * @lar_enabled: is LAR enabled
+ * @channel_profile: regulatory data of this channel
+ * @regulatory: regulatory data, see  iwl_nvm_channel_flags for data
+ */
+struct iwl_nvm_get_info_regulatory {
+   __le32 lar_enabled;
+   __le16 channel_profile[IWL_NUM_CHANNELS];
+   __le16 reserved;
+} __packed; /* GRP_REGULATORY_NVM_GET_INFO_REGULATORY_S_VER_1 */
+
+/**
+ * struct iwl_nvm_get_info_rsp - response to get NVM data
+ * @general: general NVM data
+ * @mac_sku: data relating to MAC sku
+ * @phy_sku: data relating to PHY sku
+ * @regulatory: regulatory data
+ */
+struct iwl_nvm_get_info_rsp {
+   struct iwl_nvm_get_info_general general;
+   struct iwl_nvm_get_info_sku mac_sku;
+   struct iwl_nvm_get_info_phy phy_sku;
+   struct iwl_nvm_get_info_regulatory regulatory;
+} __packed; /* GRP_REGULATORY_NVM_GET_INFO_CMD_RSP_S_VER_1 */
+
 #endif /* __fw_api_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
index e6c9528eeeda..3d68595243fc 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
@@ -738,23 +738,11 @@ static int iwl_run_unified_mvm_ucode(struct iwl_mvm *mvm, 
bool read_nvm)
goto error;
}
 
-   /* Read the NVM only at driver load time, no need to do this twice */
-   if (read_nvm) {
-   /* Read nvm */
-   ret = iwl_nvm_init(mvm, true);
-   if (ret) {
-   IWL_ERR(mvm, "Failed to read NVM: %d\n", ret);
-   goto error;
-   }
-   }
-
-   /* In case we read the NVM from external file, load it to the NIC */
-   if (mvm->nvm_file_name)
+   /* Load NVM to NIC if needed */
+   if (mvm->nvm_file_name) {
+   iwl_mvm_read_external_nvm(mvm);
iwl_mvm_load_nvm_to_nic(mvm);
-
-   ret = iwl_nvm_check_version(mvm->nvm_data, mvm->trans);
-   if (WARN_ON(ret))
-   goto error;
+   }
 
ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(REGULATORY_AND_NVM_GROUP,
NVM_ACCESS_COMPLETE), 0,
@@ -766,8 +754,21 @@ static int 

[PATCH 03/25] iwlwifi: mvm: support old method of NVM parsing

2017-06-02 Thread Luca Coelho
From: Sara Sharon 

Add configuration for allowing driver's nvm parsing and
bypassing the new host command, for debugging.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/constants.h |  1 +
 drivers/net/wireless/intel/iwlwifi/mvm/fw.c| 10 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/constants.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/constants.h
index 4eeb6b78d952..6fda8627b726 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/constants.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/constants.h
@@ -110,6 +110,7 @@
 #define IWL_MVM_TOF_IS_RESPONDER   0
 #define IWL_MVM_SW_TX_CSUM_OFFLOAD 0
 #define IWL_MVM_HW_CSUM_DISABLE0
+#define IWL_MVM_PARSE_NVM  0
 #define IWL_MVM_COLLECT_FW_ERR_DUMP1
 #define IWL_MVM_RS_NUM_TRY_BEFORE_ANT_TOGGLE1
 #define IWL_MVM_RS_HT_VHT_RETRIES_PER_RATE  2
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
index 3d68595243fc..a8804bc979fe 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
@@ -744,6 +744,14 @@ static int iwl_run_unified_mvm_ucode(struct iwl_mvm *mvm, 
bool read_nvm)
iwl_mvm_load_nvm_to_nic(mvm);
}
 
+   if (IWL_MVM_PARSE_NVM && read_nvm) {
+   ret = iwl_nvm_init(mvm, true);
+   if (ret) {
+   IWL_ERR(mvm, "Failed to read NVM: %d\n", ret);
+   goto error;
+   }
+   }
+
ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(REGULATORY_AND_NVM_GROUP,
NVM_ACCESS_COMPLETE), 0,
   sizeof(nvm_complete), _complete);
@@ -760,7 +768,7 @@ static int iwl_run_unified_mvm_ucode(struct iwl_mvm *mvm, 
bool read_nvm)
return ret;
 
/* Read the NVM only at driver load time, no need to do this twice */
-   if (read_nvm) {
+   if (!IWL_MVM_PARSE_NVM && read_nvm) {
ret = iwl_mvm_nvm_get_from_fw(mvm);
if (ret) {
IWL_ERR(mvm, "Failed to read NVM: %d\n", ret);
-- 
2.11.0



[PATCH 05/25] iwlwifi: mvm: document which group enums are used with which group ID

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

Make it explicit which command definition enum is supposed to be
used with which command group, rather than relying on being able
to figure it out by name.

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

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
index 0996127897c1..c69aff91404b 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
@@ -131,7 +131,7 @@ enum iwl_mvm_tx_fifo {
 
 
 /* commands */
-enum {
+enum iwl_legacy_cmds {
MVM_ALIVE = 0x1,
REPLY_ERROR = 0x2,
ECHO_CMD = 0x3,
@@ -354,8 +354,29 @@ enum iwl_debug_cmds {
MFU_ASSERT_DUMP_NTF = 0xFE,
 };
 
-/* command groups */
-enum {
+/**
+ * enum iwl_mvm_command_groups - command groups for the firmware
+ * @LEGACY_GROUP: legacy group, uses command IDs from  iwl_legacy_cmds
+ * @LONG_GROUP: legacy group with long header, also uses command IDs
+ * from  iwl_legacy_cmds
+ * @SYSTEM_GROUP: system group, uses command IDs from
+ *  iwl_system_subcmd_ids
+ * @MAC_CONF_GROUP: MAC configuration group, uses command IDs from
+ *  iwl_mac_conf_subcmd_ids
+ * @PHY_OPS_GROUP: PHY operations group, uses command IDs from
+ *  iwl_phy_ops_subcmd_ids
+ * @DATA_PATH_GROUP: data path group, uses command IDs from
+ *  iwl_data_path_subcmd_ids
+ * @SCAN_GROUP: scan group, uses command IDs from  iwl_scan_subcmd_ids
+ * @NAN_GROUP: NAN group, uses command IDs from  iwl_nan_subcmd_ids
+ * @TOF_GROUP: TOF group, uses command IDs from  iwl_tof_subcmd_ids
+ * @PROT_OFFLOAD_GROUP: protocol offload group, uses command IDs from
+ *  iwl_prot_offload_subcmd_ids
+ * @REGULATORY_AND_NVM_GROUP: regulatory/NVM group, uses command IDs from
+ *  iwl_regulatory_and_nvm_subcmd_ids
+ * @DEBUG_GROUP: Debug group, uses command IDs from  iwl_debug_cmds
+ */
+enum iwl_mvm_command_groups {
LEGACY_GROUP = 0x0,
LONG_GROUP = 0x1,
SYSTEM_GROUP = 0x2,
-- 
2.11.0



Re: [PATCH V2 0/9] nl80211: add support for PTK/GTK handshake offload

2017-06-02 Thread Arend van Spriel

On 5/29/2017 11:31 AM, Johannes Berg wrote:

Hi Arend,


Note that this (checking NEW_KEY) only works when you don't have
any split between AP/client cases. Not sure what's the case for
you.


Late response so hopefully you recall, but what do you mean by "any
split between AP/client cases"?


I meant the capability split - let's say you support 4-way-HS only for
client, but not for AP. Then you have to support the NEW_KEY command
for the AP case, even if you might not support non-offloaded 4-way-HS
for the client case.

So if something supports the following:

  * client: offloaded 4-way-HS only
  * AP: not offloaded 4-way-HS only

Then you have to support NEW_KEY (AP case) and then using NEW_KEY to
detect whether or not a wpa_s configuration option to not use offloaded
4-way-HS can be used will not work correctly.

I don't really see that this is a sensible configuration, but I could
imagine it existing if somebody "bolted on" AP functionality for a
client-side chipset or something like that.

Again, I think I'm happy to leave this up to you - this kind of
configuration option should really only be used for debugging anyway,
so just getting errors later is probably fine.


Hi Johannes,

I was thinking about adding a DOC section in nl80211.h:

/**
 * DOC: WPA/WPA2 temporal key exchange offload
 *
 * By setting @NL80211_EXT_FEATURE_4WAY_HANDSHAKE_STA_PSK flag drivers
 * can indicate offload support of EAPOL handshakes for WPA/WPA2
 * preshared key authentication. In %NL80211_CMD_CONNECT the preshared
 * key should be specified using %NL80211_ATTR_PMK. Drivers supporting
 * this offload may reject the %NL80211_CMD_CONNECT when no preshared
 * key material is provided. For example when that driver does not
 * support setting the temporal keys through %NL80211_CMD_NEW_KEY.
 *
 * Similarly @NL80211_EXT_FEATURE_4WAY_HANDSHAKE_STA_1X flag can be
 * set by drivers indicating offload support of the PTK/GTK EAPOL
 * handshakes during 802.1X authentication. In order to use the offload
 * the %NL80211_CMD_CONNECT should have %NL80211_ATTR_WANT_1X_4WAY_HS
 * attribute flag. Drivers supporting this offload may reject the
 * %NL80211_CMD_CONNECT when the attribute flag is not present.
 */

Could add description for FT, ie. PMK-R0 handling as well. Do you think 
this change warrants a separate section or not. Any comments on the text 
itself are welcome.


Regards,
Arend



[PATCH 10/10] iwlwifi: fix host command memory leaks

2017-06-02 Thread Luca Coelho
From: Shahar S Matityahu 

Sending host command with CMD_WANT_SKB flag demands the release of the
response buffer with iwl_free_resp function.
The patch adds the memory release in all the relevant places

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

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
index 9fb46a6f47cf..9c9bfbbabdf1 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
@@ -906,7 +906,7 @@ int iwl_trans_pcie_dyn_txq_alloc(struct iwl_trans *trans,
 
if (WARN_ON(iwl_rx_packet_payload_len(hcmd.resp_pkt) != sizeof(*rsp))) {
ret = -EINVAL;
-   goto error;
+   goto error_free_resp;
}
 
rsp = (void *)hcmd.resp_pkt->data;
@@ -915,13 +915,13 @@ int iwl_trans_pcie_dyn_txq_alloc(struct iwl_trans *trans,
if (qid > ARRAY_SIZE(trans_pcie->txq)) {
WARN_ONCE(1, "queue index %d unsupported", qid);
ret = -EIO;
-   goto error;
+   goto error_free_resp;
}
 
if (test_and_set_bit(qid, trans_pcie->queue_used)) {
WARN_ONCE(1, "queue %d already used", qid);
ret = -EIO;
-   goto error;
+   goto error_free_resp;
}
 
txq->id = qid;
@@ -934,8 +934,11 @@ int iwl_trans_pcie_dyn_txq_alloc(struct iwl_trans *trans,
   (txq->write_ptr) | (qid << 16));
IWL_DEBUG_TX_QUEUES(trans, "Activate queue %d\n", qid);
 
+   iwl_free_resp();
return qid;
 
+error_free_resp:
+   iwl_free_resp();
 error:
iwl_pcie_gen2_txq_free_memory(trans, txq);
return ret;
-- 
2.11.0



Re: After upgrading to 4.11.1, wifi driver refuses to load after being unloaded once.

2017-06-02 Thread Luca Coelho
On Thu, 2017-05-25 at 19:48 -0700, Marc MERLIN wrote:
> Howdy,
> 
> First I tried i...@linux.intel.com which is now dead
> Then linuxw...@intel.com, but no reply.
> So I'm trying here next.

Sorry, Marc.  Somehow your emails really slipped through the cracks and
I hadn't seen them before.

> 3 different ways it's failing now:
> 1) CPU: 3 PID: 9349 at drivers/net/wireless/intel/iwlwifi/pcie/trans.c:1913 
> iwl_trans_pcie_grab_nic_access+0xcc/0xe1 [iwlwifi]
> Timeout waiting for hardware access (CSR_GP_CNTRL 0x)
> 
> 2) 
> iwlwifi :04:00.0: loaded firmware version 19.277230.0 op_mode iwlmvm

I kernel v4.9, we stopped supporting firmware versions smaller than 22
for the 8260.  But unfortunately I made a mistake in the patch[1] when I
removed support for those firmwares and I used 17, which is the lowest
version for 7260 devices.

I have just sent out a patch[2] with a fix for that.

You can probably solve your problem by getting the latest firmware we
have released, which is version 27.  You can get it from the linux-
firmware.git repository[3].  Please try that and let us know how it
goes.


[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4b87e5af638b6056bd6c20b0954d09a5a58633be
[2] https://patchwork.kernel.org/patch/9762047/
[3] 
https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/iwlwifi-8000C-27.ucode

--
Cheers,
Luca.


[PATCH 06/10] iwlwifi: pcie: only use d0i3 in suspend/resume if system_pm is set to d0i3

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

We only need to handle d0i3 entry and exit during suspend resume if
system_pm is set to IWL_PLAT_PM_MODE_D0I3, otherwise d0i3 entry
failures will cause suspend to fail.

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

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

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 70acf850a9f1..93cbc7a69bcd 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -2803,7 +2803,8 @@ static struct iwl_trans_dump_data
 #ifdef CONFIG_PM_SLEEP
 static int iwl_trans_pcie_suspend(struct iwl_trans *trans)
 {
-   if (trans->runtime_pm_mode == IWL_PLAT_PM_MODE_D0I3)
+   if (trans->runtime_pm_mode == IWL_PLAT_PM_MODE_D0I3 &&
+   (trans->system_pm_mode == IWL_PLAT_PM_MODE_D0I3))
return iwl_pci_fw_enter_d0i3(trans);
 
return 0;
@@ -2811,7 +2812,8 @@ static int iwl_trans_pcie_suspend(struct iwl_trans *trans)
 
 static void iwl_trans_pcie_resume(struct iwl_trans *trans)
 {
-   if (trans->runtime_pm_mode == IWL_PLAT_PM_MODE_D0I3)
+   if (trans->runtime_pm_mode == IWL_PLAT_PM_MODE_D0I3 &&
+   (trans->system_pm_mode == IWL_PLAT_PM_MODE_D0I3))
iwl_pci_fw_exit_d0i3(trans);
 }
 #endif /* CONFIG_PM_SLEEP */
-- 
2.11.0



[PATCH 08/10] iwlwifi: mvm: clear new beacon command template struct

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

Clear the struct so that all reserved fields are zero when we
send the struct down to the device.

Signed-off-by: Johannes Berg 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
index 0f1831b41915..fd2fc46e2fe5 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
@@ -1040,7 +1040,7 @@ static int iwl_mvm_mac_ctxt_send_beacon(struct iwl_mvm 
*mvm,
struct iwl_mac_beacon_cmd_v6 beacon_cmd_v6;
struct iwl_mac_beacon_cmd_v7 beacon_cmd;
} u = {};
-   struct iwl_mac_beacon_cmd beacon_cmd;
+   struct iwl_mac_beacon_cmd beacon_cmd = {};
struct ieee80211_tx_info *info;
u32 beacon_skb_len;
u32 rate, tx_flags;
-- 
2.11.0



[PATCH 03/10] iwlwifi: mvm: support ibss in dqa mode

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

Allow working IBSS also when working in DQA mode.
This is done by setting it to treat the queues the
same as a BSS AP treats the queues.

Fixes: 7948b87308a4 ("iwlwifi: mvm: enable dynamic queue allocation mode")
Signed-off-by: Liad Kaufman 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
index f5c786ddc526..9184ce09b89a 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
@@ -2120,7 +2120,8 @@ int iwl_mvm_add_mcast_sta(struct iwl_mvm *mvm, struct 
ieee80211_vif *vif)
if (!iwl_mvm_is_dqa_supported(mvm))
return 0;
 
-   if (WARN_ON(vif->type != NL80211_IFTYPE_AP))
+   if (WARN_ON(vif->type != NL80211_IFTYPE_AP &&
+   vif->type != NL80211_IFTYPE_ADHOC))
return -ENOTSUPP;
 
/*
@@ -2155,6 +2156,16 @@ int iwl_mvm_add_mcast_sta(struct iwl_mvm *mvm, struct 
ieee80211_vif *vif)
mvmvif->cab_queue = queue;
} else if (!fw_has_api(>fw->ucode_capa,
   IWL_UCODE_TLV_API_STA_TYPE)) {
+   /*
+* In IBSS, ieee80211_check_queues() sets the cab_queue to be
+* invalid, so make sure we use the queue we want.
+* Note that this is done here as we want to avoid making DQA
+* changes in mac80211 layer.
+*/
+   if (vif->type == NL80211_IFTYPE_ADHOC) {
+   vif->cab_queue = IWL_MVM_DQA_GCAST_QUEUE;
+   mvmvif->cab_queue = vif->cab_queue;
+   }
iwl_mvm_enable_txq(mvm, vif->cab_queue, vif->cab_queue, 0,
   , timeout);
}
-- 
2.11.0



[PATCH 02/10] iwlwifi: mvm: Fix command queue number on d0i3 flow

2017-06-02 Thread Luca Coelho
From: Haim Dreyfuss 

During d0i3 flow we flush all the queue except from the command queue.
Currently, in this flow the command queue is hard coded to 9.
In DQA the command queue number has changed from 9 to 0.
Fix that.

Fixes: 097129c9e625 ("iwlwifi: mvm: move cmd queue to be #0 in dqa mode")
Signed-off-by: Haim Dreyfuss 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
index 4e74a6b90e70..ed20c0c5abc8 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
@@ -1730,8 +1730,11 @@ int iwl_mvm_find_free_queue(struct iwl_mvm *mvm, u8 
sta_id, u8 minq, u8 maxq);
  */
 static inline u32 iwl_mvm_flushable_queues(struct iwl_mvm *mvm)
 {
+   u32 cmd_queue = iwl_mvm_is_dqa_supported(mvm) ? IWL_MVM_DQA_CMD_QUEUE :
+   IWL_MVM_CMD_QUEUE;
+
return ((BIT(mvm->cfg->base_params->num_of_queues) - 1) &
-   ~BIT(IWL_MVM_CMD_QUEUE));
+   ~BIT(cmd_queue));
 }
 
 static inline
-- 
2.11.0



[PATCH 05/10] iwlwifi: mvm: fix firmware debug restart recording

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

When we want to stop the recording of the firmware debug
and restart it later without reloading the firmware we
don't need to resend the configuration that comes with
host commands.
Sending those commands confused the hardware and led to
an NMI 0x66.

Change the flow as following:
* read the relevant registers (DBGC_IN_SAMPLE, DBGC_OUT_CTRL)
* clear those registers
* wait for the hardware to complete its write to the buffer
* get the data
* restore the value of those registers (to restart the
  recording)

For early start (where the configuration is already
compiled in the firmware), we don't need to set those
registers after the firmware has been loaded, but only
when we want to restart the recording without having
restarted the firmware.

Signed-off-by: Emmanuel Grumbach 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/iwl-prph.h   |  1 +
 drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c | 12 +-
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h|  1 +
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c| 32 ++---
 4 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-prph.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-prph.h
index 306bc967742e..77efbb78e867 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-prph.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-prph.h
@@ -370,6 +370,7 @@
 #define MON_DMARB_RD_DATA_ADDR (0xa03c5c)
 
 #define DBGC_IN_SAMPLE (0xa03c00)
+#define DBGC_OUT_CTRL  (0xa03c0c)
 
 /* enable the ID buf for read */
 #define WFPM_PS_CTL_CLR0xA0300C
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c
index 7b86a4f1b574..c8712e6eea74 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c
@@ -1002,14 +1002,6 @@ int iwl_mvm_fw_dbg_collect_trig(struct iwl_mvm *mvm,
return 0;
 }
 
-static inline void iwl_mvm_restart_early_start(struct iwl_mvm *mvm)
-{
-   if (mvm->cfg->device_family == IWL_DEVICE_FAMILY_7000)
-   iwl_clear_bits_prph(mvm->trans, MON_BUFF_SAMPLE_CTL, 0x100);
-   else
-   iwl_write_prph(mvm->trans, DBGC_IN_SAMPLE, 1);
-}
-
 int iwl_mvm_start_fw_dbg_conf(struct iwl_mvm *mvm, u8 conf_id)
 {
u8 *ptr;
@@ -1023,10 +1015,8 @@ int iwl_mvm_start_fw_dbg_conf(struct iwl_mvm *mvm, u8 
conf_id)
/* EARLY START - firmware's configuration is hard coded */
if ((!mvm->fw->dbg_conf_tlv[conf_id] ||
 !mvm->fw->dbg_conf_tlv[conf_id]->num_of_hcmds) &&
-   conf_id == FW_DBG_START_FROM_ALIVE) {
-   iwl_mvm_restart_early_start(mvm);
+   conf_id == FW_DBG_START_FROM_ALIVE)
return 0;
-   }
 
if (!mvm->fw->dbg_conf_tlv[conf_id])
return -EINVAL;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
index ed20c0c5abc8..52f8d7a6a7dc 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
@@ -1756,6 +1756,7 @@ static inline void iwl_mvm_stop_device(struct iwl_mvm 
*mvm)
if (!iwl_mvm_has_new_tx_api(mvm))
iwl_free_fw_paging(mvm);
mvm->ucode_loaded = false;
+   mvm->fw_dbg_conf = FW_DBG_INVALID;
iwl_trans_stop_device(mvm->trans);
 }
 
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index 96ed8133..3da5ec40aaea 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -1149,21 +1149,37 @@ static void iwl_mvm_fw_error_dump_wk(struct work_struct 
*work)
 
mutex_lock(>mutex);
 
-   /* stop recording */
if (mvm->cfg->device_family == IWL_DEVICE_FAMILY_7000) {
+   /* stop recording */
iwl_set_bits_prph(mvm->trans, MON_BUFF_SAMPLE_CTL, 0x100);
+
+   iwl_mvm_fw_error_dump(mvm);
+
+   /* start recording again if the firmware is not crashed */
+   if (!test_bit(STATUS_FW_ERROR, >trans->status) &&
+   mvm->fw->dbg_dest_tlv)
+   iwl_clear_bits_prph(mvm->trans,
+   MON_BUFF_SAMPLE_CTL, 0x100);
} else {
+   u32 in_sample = iwl_read_prph(mvm->trans, DBGC_IN_SAMPLE);
+   u32 out_ctrl = iwl_read_prph(mvm->trans, DBGC_OUT_CTRL);
+
+   /* stop recording */
iwl_write_prph(mvm->trans, DBGC_IN_SAMPLE, 0);
-   /* wait before we collect the data till the DBGC stop */
udelay(100);
-   }
+   iwl_write_prph(mvm->trans, DBGC_OUT_CTRL, 0);
+   /* wait before we collect the data till the 

[PATCH 07/10] iwlwifi: mvm: don't fail when removing a key from an inexisting sta

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

The iwl_mvm_remove_sta_key() function handles removing a key when the
sta doesn't exist anymore.  Mistakenly, this was changed to return an
error while fixing another bug.

If the mvm_sta doesn't exist, we continue normally, but just don't try
to remove the igtk key.

Fixes: cd4d23c1ea9b ("iwlwifi: mvm: Fix removal of IGTK")
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
index 9184ce09b89a..614d67810d05 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
@@ -3332,18 +3332,15 @@ int iwl_mvm_remove_sta_key(struct iwl_mvm *mvm,
 
/* Get the station from the mvm local station table */
mvm_sta = iwl_mvm_get_key_sta(mvm, vif, sta);
-   if (!mvm_sta) {
-   IWL_ERR(mvm, "Failed to find station\n");
-   return -EINVAL;
-   }
-   sta_id = mvm_sta->sta_id;
+   if (mvm_sta)
+   sta_id = mvm_sta->sta_id;
 
IWL_DEBUG_WEP(mvm, "mvm remove dynamic key: idx=%d sta=%d\n",
  keyconf->keyidx, sta_id);
 
-   if (keyconf->cipher == WLAN_CIPHER_SUITE_AES_CMAC ||
-   keyconf->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 ||
-   keyconf->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256)
+   if (mvm_sta && (keyconf->cipher == WLAN_CIPHER_SUITE_AES_CMAC ||
+   keyconf->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 ||
+   keyconf->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256))
return iwl_mvm_send_sta_igtk(mvm, keyconf, sta_id, true);
 
if (!__test_and_clear_bit(keyconf->hw_key_idx, mvm->fw_key_table)) {
-- 
2.11.0



[PATCH 01/10] iwlwifi: mvm: rs: start using LQ command color

2017-06-02 Thread Luca Coelho
From: Gregory Greenman 

Up until now, the driver was comparing the rate reported by the FW and
the rate of the latest LQ command to avoid processing data belonging
to the old LQ command. Recently, FW changed the meaning of the initial
rate field in tx response and it holds the actual rate (which is not
necessarily the initial rate of LQ's rate table). Use instead LQ cmd
color to be able to filter out tx responses/BA notifications which
where sent during earlier LQ commands' time frame.

Signed-off-by: Gregory Greenman 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-rs.h |  5 +++
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h |  3 ++
 drivers/net/wireless/intel/iwlwifi/mvm/rs.c| 46 ++
 drivers/net/wireless/intel/iwlwifi/mvm/rs.h| 15 +++
 drivers/net/wireless/intel/iwlwifi/mvm/sta.h   |  2 +
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c| 12 +-
 6 files changed, 47 insertions(+), 36 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-rs.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-rs.h
index 1b7d265ffb0a..a10c6aae9ab9 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-rs.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-rs.h
@@ -307,6 +307,11 @@ enum {
 /* Bit 1-3: LQ command color. Used to match responses to LQ commands */
 #define LQ_FLAG_COLOR_POS   1
 #define LQ_FLAG_COLOR_MSK   (7 << LQ_FLAG_COLOR_POS)
+#define LQ_FLAG_COLOR_GET(_f)  (((_f) & LQ_FLAG_COLOR_MSK) >>\
+LQ_FLAG_COLOR_POS)
+#define LQ_FLAGS_COLOR_INC(_c) _c) + 1) << LQ_FLAG_COLOR_POS) &\
+LQ_FLAG_COLOR_MSK)
+#define LQ_FLAG_COLOR_SET(_f, _c)  ((_c) | ((_f) & ~LQ_FLAG_COLOR_MSK))
 
 /* Bit 4-5: Tx RTS BW Signalling
  * (0) No RTS BW signalling
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 81b98915b1a4..1360ebfdc51b 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h
@@ -519,8 +519,11 @@ struct agg_tx_status {
  * bit-7 invalid rate indication
  */
 #define TX_RES_INIT_RATE_INDEX_MSK 0x0f
+#define TX_RES_RATE_TABLE_COLOR_POS 4
 #define TX_RES_RATE_TABLE_COLOR_MSK 0x70
 #define TX_RES_INV_RATE_INDEX_MSK 0x80
+#define TX_RES_RATE_TABLE_COL_GET(_f) (((_f) & TX_RES_RATE_TABLE_COLOR_MSK) >>\
+  TX_RES_RATE_TABLE_COLOR_POS)
 
 #define IWL_MVM_TX_RES_GET_TID(_ra_tid) ((_ra_tid) & 0x0f)
 #define IWL_MVM_TX_RES_GET_RA(_ra_tid) ((_ra_tid) >> 4)
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
index 7788eefcd2bd..aa785cf3cf68 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
@@ -2,7 +2,7 @@
  *
  * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
- * Copyright(c) 2016 Intel 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
@@ -1083,34 +1083,6 @@ static void rs_get_lower_rate_down_column(struct 
iwl_lq_sta *lq_sta,
rs_get_lower_rate_in_column(lq_sta, rate);
 }
 
-/* Check if both rates are identical
- * allow_ant_mismatch enables matching a SISO rate on ANT_A or ANT_B
- * with a rate indicating STBC/BFER and ANT_AB.
- */
-static inline bool rs_rate_equal(struct rs_rate *a,
-struct rs_rate *b,
-bool allow_ant_mismatch)
-
-{
-   bool ant_match = (a->ant == b->ant) && (a->stbc == b->stbc) &&
-   (a->bfer == b->bfer);
-
-   if (allow_ant_mismatch) {
-   if (a->stbc || a->bfer) {
-   WARN_ONCE(a->ant != ANT_AB, "stbc %d bfer %d ant %d",
- a->stbc, a->bfer, a->ant);
-   ant_match |= (b->ant == ANT_A || b->ant == ANT_B);
-   } else if (b->stbc || b->bfer) {
-   WARN_ONCE(b->ant != ANT_AB, "stbc %d bfer %d ant %d",
- b->stbc, b->bfer, b->ant);
-   ant_match |= (a->ant == ANT_A || a->ant == ANT_B);
-   }
-   }
-
-   return (a->type == b->type) && (a->bw == b->bw) && (a->sgi == b->sgi) &&
-   (a->ldpc == b->ldpc) && (a->index == b->index) && ant_match;
-}
-
 /* Check if both rates share the same column */
 static inline bool rs_rate_column_match(struct rs_rate *a,
struct rs_rate *b)
@@ -1182,12 +1154,12 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct 

[PATCH 00/10] iwlwifi: some fixes intended for 4.12

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

Hi,

Here some patches that I intend to send in a pull-request for 4.12.
Some of the issues solved are:

* Some memory leaks;
* IBSS support;
* Some bugzilla bugs;
* Some runtime PM fixes;
* Rate-scaling issues;
* Some locking problems;

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

Please review.

Cheers,
Luca.


Emmanuel Grumbach (1):
  iwlwifi: mvm: fix firmware debug restart recording

Gregory Greenman (1):
  iwlwifi: mvm: rs: start using LQ command color

Haim Dreyfuss (1):
  iwlwifi: mvm: Fix command queue number on d0i3 flow

Johannes Berg (2):
  iwlwifi: tt: move ucode_loaded check under mutex
  iwlwifi: mvm: clear new beacon command template struct

Liad Kaufman (1):
  iwlwifi: mvm: support ibss in dqa mode

Luca Coelho (3):
  iwlwifi: pcie: only use d0i3 in suspend/resume if system_pm is set to
d0i3
  iwlwifi: mvm: don't fail when removing a key from an inexisting sta
  iwlwifi: fix min API version for 7265D, 3168, 8000 and 8265

Shahar S Matityahu (1):
  iwlwifi: fix host command memory leaks

 drivers/net/wireless/intel/iwlwifi/iwl-7000.c  |  4 +-
 drivers/net/wireless/intel/iwlwifi/iwl-8000.c  |  4 +-
 drivers/net/wireless/intel/iwlwifi/iwl-prph.h  |  1 +
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-rs.h |  5 +++
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-tx.h |  3 ++
 drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c| 12 +-
 drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c  |  2 +-
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h   |  6 ++-
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c   | 32 +++
 drivers/net/wireless/intel/iwlwifi/mvm/rs.c| 46 ++
 drivers/net/wireless/intel/iwlwifi/mvm/rs.h| 15 +++
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c   | 26 +++-
 drivers/net/wireless/intel/iwlwifi/mvm/sta.h   |  2 +
 drivers/net/wireless/intel/iwlwifi/mvm/tt.c|  8 ++--
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c| 12 +-
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c|  6 ++-
 drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c  |  9 +++--
 17 files changed, 115 insertions(+), 78 deletions(-)

-- 
2.11.0



[PATCH][-next] mwifiex: make function mwifiex_ret_pkt_aggr_ctrl static

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

function mwifiex_ret_pkt_aggr_ctrl can be made static as it does not
need to be in global scope.

Cleans up sparse warning: "symbol 'mwifiex_ret_pkt_aggr_ctrl' was not
declared. Should it be static?"

Signed-off-by: Colin Ian King 
---
 drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c 
b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
index 3348fb3a7514..2945775e83c5 100644
--- a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
+++ b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
@@ -1154,8 +1154,8 @@ static int mwifiex_ret_chan_region_cfg(struct 
mwifiex_private *priv,
return 0;
 }
 
-int mwifiex_ret_pkt_aggr_ctrl(struct mwifiex_private *priv,
- struct host_cmd_ds_command *resp)
+static int mwifiex_ret_pkt_aggr_ctrl(struct mwifiex_private *priv,
+struct host_cmd_ds_command *resp)
 {
struct host_cmd_ds_pkt_aggr_ctrl *pkt_aggr_ctrl =
>params.pkt_aggr_ctrl;
-- 
2.11.0