All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/13] rtlwifi: btcoex: Second set of 21a 1ant changes
@ 2017-04-17  0:06 Larry Finger
  2017-04-17  0:06 ` [PATCH 01/13] rtlwifi: btcoex: 21a 1ant: set tdma and coex table when wifi is idle Larry Finger
                   ` (12 more replies)
  0 siblings, 13 replies; 18+ messages in thread
From: Larry Finger @ 2017-04-17  0:06 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Larry Finger, Yan-Hsuan Chuang, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

This set of patches finishes the changes for btcoexist/halbtc8821a1ant.c.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>

Yan-Hsuan Chuang (13):
  rtlwifi: btcoex: 21a 1ant: set tdma and coex table when wifi is idle
  rtlwifi: btcoex: 21a 1ant: more bt profiling when wifi receives
    special packet
  rtlwifi: btcoex: 21a 1ant: shorten wifi slot when connected scan
  rtlwifi: btcoex: 21a 1ant: react to special packet when wifi is not
    scanning
  rtlwifi: btcoex: 21a 1ant: coex table and tdma settings for softap
    mode
  rtlwifi: btcoex: 21a 1ant: wifi slot time adjustment
  rtlwifi: btcoex: 21a 1ant: normal mode for retry limit when connected
  rtlwifi: btcoex: 21a 1ant: mark packet high priority when scanning
  rtlwifi: btcoex: 21a 1ant: use default value when initiating coex
  rtlwifi: btcoex: 21a 1ant: re-init coex after wifi leaves IPS
  rtlwifi: btcoex: 21a 1ant: treat ARP as special packet
  rtlwifi: btcoex: 21a 1ant: fix some coding style issues
  rtlwifi: btcoex: 21a 1ant: add bt_tx_rx_mask into bt info

 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c    | 257 +++++++++++++++------
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.h    |   2 +
 2 files changed, 186 insertions(+), 73 deletions(-)

-- 
2.12.0

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 01/13] rtlwifi: btcoex: 21a 1ant: set tdma and coex table when wifi is idle
  2017-04-17  0:06 [PATCH 00/13] rtlwifi: btcoex: Second set of 21a 1ant changes Larry Finger
@ 2017-04-17  0:06 ` Larry Finger
  2017-04-21  6:38   ` [01/13] " Kalle Valo
  2017-04-17  0:06 ` [PATCH 02/13] rtlwifi: btcoex: 21a 1ant: more bt profiling when wifi receives special packet Larry Finger
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 18+ messages in thread
From: Larry Finger @ 2017-04-17  0:06 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

When wifi is idle, bt could have more resources to transmit, so set the
tdma and coex table to achieve this.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c    | 34 +++++++++++++++-------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 5e9f3b0f7a25..c98441dbf882 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -1212,8 +1212,8 @@ static void btc8821a1ant_ps_tdma(struct btc_coexist *btcoexist,
 						    0x1a, 0, 0x58);
 			break;
 		case 32:
-			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x61, 0xa,
-						    0x3, 0x10, 0x0);
+			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x35,
+						    0x3, 0x11, 0x11);
 			break;
 		case 33:
 			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0xa3, 0x25,
@@ -1231,6 +1231,10 @@ static void btc8821a1ant_ps_tdma(struct btc_coexist *btcoexist,
 			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0xd3, 0x12,
 						    0x3, 0x14, 0x50);
 			break;
+		case 43:
+			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x30,
+						    0x3, 0x10, 0x11);
+			break;
 		}
 	} else {
 		/* disable PS tdma */
@@ -1619,15 +1623,23 @@ static void btc8821a1ant_act_wifi_con_bt_acl_busy(struct btc_coexist *btcoexist,
 		return;
 	} else if (bt_link_info->a2dp_only) {
 		/* A2DP */
-		if ((bt_rssi_state != BTC_RSSI_STATE_HIGH) &&
-		    (bt_rssi_state != BTC_RSSI_STATE_STAY_HIGH)) {
+		if (wifi_status == BT_8821A_1ANT_WIFI_STATUS_CONNECTED_IDLE) {
+			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32);
+			btc8821a1ant_coex_table_with_type(btcoexist,
+							  NORMAL_EXEC, 1);
+			coex_dm->auto_tdma_adjust = false;
+		} else if ((bt_rssi_state != BTC_RSSI_STATE_HIGH) &&
+			   (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
+			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
+			btc8821a1ant_coex_table_with_type(btcoexist,
+							  NORMAL_EXEC, 1);
+		} else {
 			/* for low BT RSSI */
-			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC,
-					     true, 11);
+			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
+			btc8821a1ant_coex_table_with_type(btcoexist,
+							  NORMAL_EXEC, 1);
 			coex_dm->auto_tdma_adjust = false;
 		}
-
-		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
 	} else if (bt_link_info->hid_exist && bt_link_info->a2dp_exist) {
 		/* HID+A2DP */
 		if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
@@ -1638,7 +1650,7 @@ static void btc8821a1ant_act_wifi_con_bt_acl_busy(struct btc_coexist *btcoexist,
 		} else {
 			/*for low BT RSSI*/
 			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC,
-					     true, 11);
+					     true, 14);
 			coex_dm->auto_tdma_adjust = false;
 		}
 
@@ -1647,13 +1659,13 @@ static void btc8821a1ant_act_wifi_con_bt_acl_busy(struct btc_coexist *btcoexist,
 		(bt_link_info->hid_exist && bt_link_info->pan_exist)) {
 		/* PAN(OPP, FTP), HID+PAN(OPP, FTP) */
 		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 3);
-		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
+		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 6);
 		coex_dm->auto_tdma_adjust = false;
 	} else if (((bt_link_info->a2dp_exist) && (bt_link_info->pan_exist)) ||
 		   (bt_link_info->hid_exist && bt_link_info->a2dp_exist &&
 		    bt_link_info->pan_exist)) {
 		/* A2DP+PAN(OPP, FTP), HID+A2DP+PAN(OPP, FTP) */
-		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 13);
+		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 43);
 		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
 		coex_dm->auto_tdma_adjust = false;
 	} else {
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 02/13] rtlwifi: btcoex: 21a 1ant: more bt profiling when wifi receives special packet
  2017-04-17  0:06 [PATCH 00/13] rtlwifi: btcoex: Second set of 21a 1ant changes Larry Finger
  2017-04-17  0:06 ` [PATCH 01/13] rtlwifi: btcoex: 21a 1ant: set tdma and coex table when wifi is idle Larry Finger
@ 2017-04-17  0:06 ` Larry Finger
  2017-04-17  0:06 ` [PATCH 03/13] rtlwifi: btcoex: 21a 1ant: shorten wifi slot when connected scan Larry Finger
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Larry Finger @ 2017-04-17  0:06 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

Consider bt profiling is sco or hid to set coex table and tdma.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c    | 31 ++++++++++------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index c98441dbf882..1844b9102e30 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -1753,29 +1753,26 @@ void btc8821a1ant_action_wifi_connected_scan(struct btc_coexist *btcoexist)
 static void btc8821a1ant_act_wifi_conn_sp_pkt(struct btc_coexist *btcoexist)
 {
 	struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
-	bool hs_connecting = false;
-
-	btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_CONNECTING, &hs_connecting);
 
 	btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
 				      0x0, 0x0);
 
 	/* tdma and coex table */
-	if (coex_dm->bt_status == BT_8821A_1ANT_BT_STATUS_ACL_BUSY) {
-		if (bt_link_info->a2dp_exist && bt_link_info->pan_exist) {
-			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC,
-					     true, 22);
-			btc8821a1ant_coex_table_with_type(btcoexist,
-							  NORMAL_EXEC, 1);
-		} else {
-			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC,
-					     true, 20);
-			btc8821a1ant_coex_table_with_type(btcoexist,
-							  NORMAL_EXEC, 1);
-		}
-	} else {
-		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
+	if ((bt_link_info->sco_exist) || (bt_link_info->hid_exist) ||
+	    (bt_link_info->a2dp_exist)) {
+		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32);
+		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
+	}
+
+	if ((bt_link_info->hid_exist) && (bt_link_info->a2dp_exist)) {
+		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
 		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
+	} else if (bt_link_info->pan_exist) {
+		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
+		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
+	} else {
+		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
+		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
 	}
 }
 
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 03/13] rtlwifi: btcoex: 21a 1ant: shorten wifi slot when connected scan
  2017-04-17  0:06 [PATCH 00/13] rtlwifi: btcoex: Second set of 21a 1ant changes Larry Finger
  2017-04-17  0:06 ` [PATCH 01/13] rtlwifi: btcoex: 21a 1ant: set tdma and coex table when wifi is idle Larry Finger
  2017-04-17  0:06 ` [PATCH 02/13] rtlwifi: btcoex: 21a 1ant: more bt profiling when wifi receives special packet Larry Finger
@ 2017-04-17  0:06 ` Larry Finger
  2017-04-17  0:06 ` [PATCH 04/13] rtlwifi: btcoex: 21a 1ant: react to special packet when wifi is not scanning Larry Finger
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Larry Finger @ 2017-04-17  0:06 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

If the wifi is scanning when connected, it is better if the slot
is shortened and the priority is increased. Otherwise bt a2dp may have
low quality.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c    | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 1844b9102e30..4b405331d82f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -1730,23 +1730,23 @@ void btc8821a1ant_action_wifi_connected_scan(struct btc_coexist *btcoexist)
 
 	/* tdma and coex table */
 	if (BT_8821A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) {
-		if (bt_link_info->a2dp_exist && bt_link_info->pan_exist) {
-			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
+		if (bt_link_info->a2dp_exist) {
+			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
 			btc8821a1ant_coex_table_with_type(btcoexist,
 							  NORMAL_EXEC, 1);
 		} else {
-		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
-		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
-	}
-	} else if ((BT_8821A_1ANT_BT_STATUS_SCO_BUSY ==
-		    coex_dm->bt_status) ||
-		   (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY ==
-		    coex_dm->bt_status)) {
+			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
+			btc8821a1ant_coex_table_with_type(btcoexist,
+							  NORMAL_EXEC, 4);
+		}
+	} else if ((coex_dm->bt_status == BT_8821A_1ANT_BT_STATUS_SCO_BUSY) ||
+		   (coex_dm->bt_status ==
+		    BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY)) {
 		btc8821a1ant_act_bt_sco_hid_only_busy(btcoexist,
 			BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SCAN);
 	} else {
-		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
-		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
+		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
+		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
 	}
 }
 
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 04/13] rtlwifi: btcoex: 21a 1ant: react to special packet when wifi is not scanning
  2017-04-17  0:06 [PATCH 00/13] rtlwifi: btcoex: Second set of 21a 1ant changes Larry Finger
                   ` (2 preceding siblings ...)
  2017-04-17  0:06 ` [PATCH 03/13] rtlwifi: btcoex: 21a 1ant: shorten wifi slot when connected scan Larry Finger
@ 2017-04-17  0:06 ` Larry Finger
  2017-04-17  0:06 ` [PATCH 05/13] rtlwifi: btcoex: 21a 1ant: coex table and tdma settings for softap mode Larry Finger
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Larry Finger @ 2017-04-17  0:06 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

If wifi is not scanning, there may have some special and important
packets such as DHCP or EAPOL or ARP packets. Set tdma and coex table to
take care of them.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 4b405331d82f..51dfa94a9cc7 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -1799,7 +1799,11 @@ static void btc8821a1ant_action_wifi_connected(struct btc_coexist *btcoexist)
 	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
 	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
 	if (scan || link || roam) {
-		btc8821a1ant_action_wifi_connected_scan(btcoexist);
+		if (scan)
+			btc8821a1ant_action_wifi_connected_scan(btcoexist);
+		else
+			btc8821a1ant_act_wifi_conn_sp_pkt(btcoexist);
+
 		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
 			 "[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n");
 		return;
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 05/13] rtlwifi: btcoex: 21a 1ant: coex table and tdma settings for softap mode
  2017-04-17  0:06 [PATCH 00/13] rtlwifi: btcoex: Second set of 21a 1ant changes Larry Finger
                   ` (3 preceding siblings ...)
  2017-04-17  0:06 ` [PATCH 04/13] rtlwifi: btcoex: 21a 1ant: react to special packet when wifi is not scanning Larry Finger
@ 2017-04-17  0:06 ` Larry Finger
  2017-04-17  0:06 ` [PATCH 06/13] rtlwifi: btcoex: 21a 1ant: wifi slot time adjustment Larry Finger
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Larry Finger @ 2017-04-17  0:06 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

Monitor if the wifi is softap mode, and set the tdma and coex table
accordingly.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c    | 25 +++++++++++++++-------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 51dfa94a9cc7..113e22640bbc 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -1782,6 +1782,7 @@ static void btc8821a1ant_action_wifi_connected(struct btc_coexist *btcoexist)
 	bool wifi_busy = false;
 	bool scan = false, link = false, roam = false;
 	bool under_4way = false;
+	bool ap_enable = false;
 
 	RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
 		 "[BTCoex], CoexForWifiConnect()===>\n");
@@ -1810,17 +1811,26 @@ static void btc8821a1ant_action_wifi_connected(struct btc_coexist *btcoexist)
 	}
 
 	/* power save state*/
+	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
+			   &ap_enable);
+	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
 	if (BT_8821A_1ANT_BT_STATUS_ACL_BUSY ==
-			coex_dm->bt_status && !btcoexist->bt_link_info.hid_only)
-		btc8821a1ant_power_save_state(btcoexist,
-					      BTC_PS_LPS_ON, 0x50, 0x4);
-	else
+	    coex_dm->bt_status && !ap_enable &&
+	    !btcoexist->bt_link_info.hid_only) {
+		if (!wifi_busy && btcoexist->bt_link_info.a2dp_only)
+			/* A2DP */
+			btc8821a1ant_power_save_state(btcoexist,
+						BTC_PS_WIFI_NATIVE, 0x0, 0x0);
+		else
+			btc8821a1ant_power_save_state(btcoexist, BTC_PS_LPS_ON,
+						      0x50, 0x4);
+	} else {
 		btc8821a1ant_power_save_state(btcoexist,
 					      BTC_PS_WIFI_NATIVE,
 					      0x0, 0x0);
+	}
 
 	/* tdma and coex table */
-	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
 	if (!wifi_busy) {
 		if (BT_8821A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) {
 			btc8821a1ant_act_wifi_con_bt_acl_busy(btcoexist,
@@ -1832,8 +1842,7 @@ static void btc8821a1ant_action_wifi_connected(struct btc_coexist *btcoexist)
 			btc8821a1ant_act_bt_sco_hid_only_busy(btcoexist,
 				BT_8821A_1ANT_WIFI_STATUS_CONNECTED_IDLE);
 		} else {
-			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC,
-					     true, 5);
+			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
 			btc8821a1ant_coex_table_with_type(btcoexist,
 							  NORMAL_EXEC, 2);
 		}
@@ -1848,7 +1857,7 @@ static void btc8821a1ant_action_wifi_connected(struct btc_coexist *btcoexist)
 			btc8821a1ant_act_bt_sco_hid_only_busy(btcoexist,
 				BT_8821A_1ANT_WIFI_STATUS_CONNECTED_BUSY);
 		} else {
-			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5);
+			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
 			btc8821a1ant_coex_table_with_type(btcoexist,
 							  NORMAL_EXEC, 2);
 		}
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 06/13] rtlwifi: btcoex: 21a 1ant: wifi slot time adjustment
  2017-04-17  0:06 [PATCH 00/13] rtlwifi: btcoex: Second set of 21a 1ant changes Larry Finger
                   ` (4 preceding siblings ...)
  2017-04-17  0:06 ` [PATCH 05/13] rtlwifi: btcoex: 21a 1ant: coex table and tdma settings for softap mode Larry Finger
@ 2017-04-17  0:06 ` Larry Finger
  2017-04-17  0:06 ` [PATCH 07/13] rtlwifi: btcoex: 21a 1ant: normal mode for retry limit when connected Larry Finger
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Larry Finger @ 2017-04-17  0:06 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

Adjust wifi slot time to tune the performance of coexistence

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c    | 38 ++++++++++++++++------
 1 file changed, 28 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 113e22640bbc..0877ca020e63 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -1107,8 +1107,8 @@ static void btc8821a1ant_ps_tdma(struct btc_coexist *btcoexist,
 						    0x3, 0x11, 0x10);
 			break;
 		case 6:
-			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x13, 0xa,
-						    0x3, 0x0, 0x0);
+			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x20,
+						    0x3, 0x11, 0x13);
 			break;
 		case 7:
 			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x13, 0xc,
@@ -1128,8 +1128,8 @@ static void btc8821a1ant_ps_tdma(struct btc_coexist *btcoexist,
 						    0xa, 0x0, 0x40);
 			break;
 		case 11:
-			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x14,
-						    0x03, 0x10, 0x10);
+			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x15,
+						    0x03, 0x10, 0x50);
 			rssi_adjust_val = 20;
 			break;
 		case 12:
@@ -1137,8 +1137,8 @@ static void btc8821a1ant_ps_tdma(struct btc_coexist *btcoexist,
 						    0x0a, 0x0, 0x50);
 			break;
 		case 13:
-			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x18,
-						    0x18, 0x0, 0x10);
+			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x12,
+						    0x12, 0x0, 0x50);
 			break;
 		case 14:
 			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x1e,
@@ -1163,8 +1163,8 @@ static void btc8821a1ant_ps_tdma(struct btc_coexist *btcoexist,
 						    0x03, 0x11, 0x10);
 			break;
 		case 21:
-			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x15,
-						    0x03, 0x11, 0x10);
+			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x25,
+						    0x03, 0x11, 0x11);
 			break;
 		case 22:
 			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x25,
@@ -1204,8 +1204,8 @@ static void btc8821a1ant_ps_tdma(struct btc_coexist *btcoexist,
 						    0x1a, 0x1, 0x10);
 			break;
 		case 30:
-			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x14,
-						    0x3, 0x10, 0x50);
+			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x30,
+						    0x3, 0x10, 0x10);
 			break;
 		case 31:
 			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0xd3, 0x1a,
@@ -1231,6 +1231,24 @@ static void btc8821a1ant_ps_tdma(struct btc_coexist *btcoexist,
 			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0xd3, 0x12,
 						    0x3, 0x14, 0x50);
 			break;
+		case 40:
+			/* SoftAP only with no sta associated, BT disable, TDMA
+			 * mode for power saving
+			 *
+			 * here softap mode screen off will cost 70-80mA for
+			 * phone
+			 */
+			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x23, 0x18,
+						    0x00, 0x10, 0x24);
+			break;
+		case 41:
+			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x15,
+						    0x3, 0x11, 0x11);
+			break;
+		case 42:
+			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x20,
+						    0x3, 0x11, 0x11);
+			break;
 		case 43:
 			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x30,
 						    0x3, 0x10, 0x11);
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 07/13] rtlwifi: btcoex: 21a 1ant: normal mode for retry limit when connected
  2017-04-17  0:06 [PATCH 00/13] rtlwifi: btcoex: Second set of 21a 1ant changes Larry Finger
                   ` (5 preceding siblings ...)
  2017-04-17  0:06 ` [PATCH 06/13] rtlwifi: btcoex: 21a 1ant: wifi slot time adjustment Larry Finger
@ 2017-04-17  0:06 ` Larry Finger
  2017-04-17  0:06 ` [PATCH 08/13] rtlwifi: btcoex: 21a 1ant: mark packet high priority when scanning Larry Finger
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Larry Finger @ 2017-04-17  0:06 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

When wifi is connected, use normal mode to set retry limit.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 0877ca020e63..5b624e76303d 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -2028,11 +2028,11 @@ static void btc8821a1ant_run_coexist_mechanism(struct btc_coexist *btcoexist)
 			    (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
 				btc8821a1ant_limited_tx(btcoexist,
 							NORMAL_EXEC, 1, 1,
-							1, 1);
+							0, 1);
 			} else {
 				btc8821a1ant_limited_tx(btcoexist,
 							NORMAL_EXEC, 1, 1,
-							1, 1);
+							0, 1);
 			}
 		} else {
 			btc8821a1ant_limited_tx(btcoexist, NORMAL_EXEC,
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 08/13] rtlwifi: btcoex: 21a 1ant: mark packet high priority when scanning
  2017-04-17  0:06 [PATCH 00/13] rtlwifi: btcoex: Second set of 21a 1ant changes Larry Finger
                   ` (6 preceding siblings ...)
  2017-04-17  0:06 ` [PATCH 07/13] rtlwifi: btcoex: 21a 1ant: normal mode for retry limit when connected Larry Finger
@ 2017-04-17  0:06 ` Larry Finger
  2017-04-17  0:06 ` [PATCH 09/13] rtlwifi: btcoex: 21a 1ant: use default value when initiating coex Larry Finger
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Larry Finger @ 2017-04-17  0:06 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

When the wifi notifies the coexistence it is going to scan, set the coex
table to avoid issues when the scan result is empty.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c    | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 5b624e76303d..08bf42e80e83 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -2524,6 +2524,19 @@ void ex_btc8821a1ant_scan_notify(struct btc_coexist *btcoexist, u8 type)
 		return;
 	}
 
+	if (type == BTC_SCAN_START) {
+		coex_sta->wifi_is_high_pri_task = true;
+		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+			 "[BTCoex], SCAN START notify\n");
+
+		/* Force antenna setup for no scan result issue */
+		btc8821a1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 8);
+	} else {
+		coex_sta->wifi_is_high_pri_task = false;
+		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+			 "[BTCoex], SCAN FINISH notify\n");
+	}
+
 	if (coex_sta->bt_disabled)
 		return;
 
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 09/13] rtlwifi: btcoex: 21a 1ant: use default value when initiating coex
  2017-04-17  0:06 [PATCH 00/13] rtlwifi: btcoex: Second set of 21a 1ant changes Larry Finger
                   ` (7 preceding siblings ...)
  2017-04-17  0:06 ` [PATCH 08/13] rtlwifi: btcoex: 21a 1ant: mark packet high priority when scanning Larry Finger
@ 2017-04-17  0:06 ` Larry Finger
  2017-04-17  0:06 ` [PATCH 10/13] rtlwifi: btcoex: 21a 1ant: re-init coex after wifi leaves IPS Larry Finger
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Larry Finger @ 2017-04-17  0:06 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

For newer coex mechanism, it is not necessary to set a critical value to
avoid the power on instability, just use default value for PTA.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 08bf42e80e83..6b1ded6a0576 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -2096,7 +2096,6 @@ static void btc8821a1ant_init_coex_dm(struct btc_coexist *btcoexist)
 	 */
 	btc8821a1ant_sw_mechanism(btcoexist, false);
 
-	btc8821a1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 8);
 	btc8821a1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0);
 }
 
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 10/13] rtlwifi: btcoex: 21a 1ant: re-init coex after wifi leaves IPS
  2017-04-17  0:06 [PATCH 00/13] rtlwifi: btcoex: Second set of 21a 1ant changes Larry Finger
                   ` (8 preceding siblings ...)
  2017-04-17  0:06 ` [PATCH 09/13] rtlwifi: btcoex: 21a 1ant: use default value when initiating coex Larry Finger
@ 2017-04-17  0:06 ` Larry Finger
  2017-04-17  0:06 ` [PATCH 11/13] rtlwifi: btcoex: 21a 1ant: treat ARP as special packet Larry Finger
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 18+ messages in thread
From: Larry Finger @ 2017-04-17  0:06 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

Before entering IPS, set the PTA control to default value and re-init it
after it leaves IPS to avoid running some redundant code in
run_coexist_mechanism.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 6b1ded6a0576..b8d5b73011ba 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -2473,7 +2473,7 @@ void ex_btc8821a1ant_ips_notify(struct btc_coexist *btcoexist, u8 type)
 		btc8821a1ant_set_ant_path(btcoexist,
 					  BTC_ANT_PATH_BT, false, true);
 		/* set PTA control */
-		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
+		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 0);
 		btc8821a1ant_coex_table_with_type(btcoexist,
 						  NORMAL_EXEC, 0);
 	} else if (BTC_IPS_LEAVE == type) {
@@ -2481,7 +2481,9 @@ void ex_btc8821a1ant_ips_notify(struct btc_coexist *btcoexist, u8 type)
 			 "[BTCoex], IPS LEAVE notify\n");
 		coex_sta->under_ips = false;
 
-		btc8821a1ant_run_coexist_mechanism(btcoexist);
+		btc8821a1ant_init_hw_config(btcoexist, false, false);
+		btc8821a1ant_init_coex_dm(btcoexist);
+		btc8821a1ant_query_bt_info(btcoexist);
 	}
 }
 
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 11/13] rtlwifi: btcoex: 21a 1ant: treat ARP as special packet
  2017-04-17  0:06 [PATCH 00/13] rtlwifi: btcoex: Second set of 21a 1ant changes Larry Finger
                   ` (9 preceding siblings ...)
  2017-04-17  0:06 ` [PATCH 10/13] rtlwifi: btcoex: 21a 1ant: re-init coex after wifi leaves IPS Larry Finger
@ 2017-04-17  0:06 ` Larry Finger
  2017-04-17  0:06 ` [PATCH 12/13] rtlwifi: btcoex: 21a 1ant: fix some coding style issues Larry Finger
  2017-04-17  0:07 ` [PATCH 13/13] rtlwifi: btcoex: 21a 1ant: add bt_tx_rx_mask into bt info Larry Finger
  12 siblings, 0 replies; 18+ messages in thread
From: Larry Finger @ 2017-04-17  0:06 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

We need to pay attention to ARP packets to correctly establish
connection, and reset the ARP counter when disconnected.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.c    | 49 ++++++++++++++++++++--
 .../realtek/rtlwifi/btcoexist/halbtc8821a1ant.h    |  1 +
 2 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index b8d5b73011ba..7d91d82e37fe 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -2592,7 +2592,7 @@ void ex_btc8821a1ant_scan_notify(struct btc_coexist *btcoexist, u8 type)
 void ex_btc8821a1ant_connect_notify(struct btc_coexist *btcoexist, u8 type)
 {
 	struct rtl_priv *rtlpriv = btcoexist->adapter;
-	bool	wifi_connected = false, bt_hs_on = false;
+	bool wifi_connected = false, bt_hs_on = false;
 	u32 wifi_link_status = 0;
 	u32 num_of_wifi_link = 0;
 	bool bt_ctrl_agg_buf_size = false;
@@ -2610,6 +2610,18 @@ void ex_btc8821a1ant_connect_notify(struct btc_coexist *btcoexist, u8 type)
 		return;
 	}
 
+	if (type == BTC_ASSOCIATE_START) {
+		coex_sta->wifi_is_high_pri_task = true;
+		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+			 "[BTCoex], CONNECT START notify\n");
+		coex_dm->arp_cnt = 0;
+	} else {
+		coex_sta->wifi_is_high_pri_task = false;
+		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+			 "[BTCoex], CONNECT FINISH notify\n");
+		coex_dm->arp_cnt = 0;
+	}
+
 	btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS,
 			   &wifi_link_status);
 	num_of_wifi_link = wifi_link_status >> 16;
@@ -2675,6 +2687,7 @@ void ex_btc8821a1ant_media_status_notify(struct btc_coexist *btcoexist,
 	} else {
 		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
 			 "[BTCoex], MEDIA disconnect notify\n");
+		coex_dm->arp_cnt = 0;
 	}
 
 	/* only 2.4G we need to inform bt the chnl mask */
@@ -2728,6 +2741,24 @@ void ex_btc8821a1ant_special_packet_notify(struct btc_coexist *btcoexist,
 		return;
 	}
 
+	if (type == BTC_PACKET_DHCP || type == BTC_PACKET_EAPOL ||
+	    type == BTC_PACKET_ARP) {
+		coex_sta->wifi_is_high_pri_task = true;
+
+		if (type == BTC_PACKET_ARP) {
+			RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+				 "[BTCoex], specific Packet ARP notify\n");
+		} else {
+			RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+				 "[BTCoex], specific Packet DHCP or EAPOL notify\n");
+		}
+	} else {
+		coex_sta->wifi_is_high_pri_task = false;
+		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+			 "[BTCoex], specific Packet [Type = %d] notify\n",
+			 type);
+	}
+
 	coex_sta->special_pkt_period_cnt = 0;
 
 	btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS,
@@ -2750,8 +2781,20 @@ void ex_btc8821a1ant_special_packet_notify(struct btc_coexist *btcoexist,
 		return;
 	}
 
-	if (BTC_PACKET_DHCP == type ||
-	    BTC_PACKET_EAPOL == type) {
+	if (type == BTC_PACKET_DHCP || type == BTC_PACKET_EAPOL ||
+	    type == BTC_PACKET_ARP) {
+		if (type == BTC_PACKET_ARP) {
+			coex_dm->arp_cnt++;
+			RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+				 "[BTCoex], ARP Packet Count = %d\n",
+				 coex_dm->arp_cnt);
+			if (coex_dm->arp_cnt >= 10)
+				/* if APR PKT > 10 after connect, do not go to
+				 * btc8821a1ant_act_wifi_conn_sp_pkt
+				 */
+				return;
+		}
+
 		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
 			 "[BTCoex], special Packet(%d) notify\n", type);
 		btc8821a1ant_act_wifi_conn_sp_pkt(btcoexist);
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.h b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.h
index 1bd1ebe3364e..8d6ee81586fd 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.h
@@ -135,6 +135,7 @@ struct coex_dm_8821a_1ant {
 	u8	cur_retry_limit_type;
 	u8	pre_ampdu_time_type;
 	u8	cur_ampdu_time_type;
+	u32	arp_cnt;
 
 	u8	error_condition;
 };
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 12/13] rtlwifi: btcoex: 21a 1ant: fix some coding style issues
  2017-04-17  0:06 [PATCH 00/13] rtlwifi: btcoex: Second set of 21a 1ant changes Larry Finger
                   ` (10 preceding siblings ...)
  2017-04-17  0:06 ` [PATCH 11/13] rtlwifi: btcoex: 21a 1ant: treat ARP as special packet Larry Finger
@ 2017-04-17  0:06 ` Larry Finger
  2017-04-17 16:09   ` Joe Perches
  2017-04-17  0:07 ` [PATCH 13/13] rtlwifi: btcoex: 21a 1ant: add bt_tx_rx_mask into bt info Larry Finger
  12 siblings, 1 reply; 18+ messages in thread
From: Larry Finger @ 2017-04-17  0:06 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

Fix alignment for coding style consistency.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c   | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 7d91d82e37fe..8022779004fb 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -2839,14 +2839,14 @@ void ex_btc8821a1ant_bt_info_notify(struct btc_coexist *btcoexist,
 	}
 
 	if (BT_INFO_SRC_8821A_1ANT_WIFI_FW != rsp_source) {
-		coex_sta->bt_retry_cnt =	/* [3:0]*/
-			coex_sta->bt_info_c2h[rsp_source][2]&0xf;
+		/* [3:0] */
+		coex_sta->bt_retry_cnt =
+			coex_sta->bt_info_c2h[rsp_source][2] & 0xf;
 
 		coex_sta->bt_rssi =
-			coex_sta->bt_info_c2h[rsp_source][3]*2+10;
+			coex_sta->bt_info_c2h[rsp_source][3] * 2 + 10;
 
-		coex_sta->bt_info_ext =
-			coex_sta->bt_info_c2h[rsp_source][4];
+		coex_sta->bt_info_ext = coex_sta->bt_info_c2h[rsp_source][4];
 
 		/* Here we need to resend some wifi info to BT
 		 * because bt is reset and lost the info
@@ -2928,11 +2928,11 @@ void ex_btc8821a1ant_bt_info_notify(struct btc_coexist *btcoexist,
 		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
 			 "[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n");
 	} else if ((bt_info&BT_INFO_8821A_1ANT_B_SCO_ESCO) ||
-		(bt_info&BT_INFO_8821A_1ANT_B_SCO_BUSY)) {
+		(bt_info & BT_INFO_8821A_1ANT_B_SCO_BUSY)) {
 		coex_dm->bt_status = BT_8821A_1ANT_BT_STATUS_SCO_BUSY;
 		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
 			 "[BTCoex], BtInfoNotify(), BT SCO busy!!!\n");
-	} else if (bt_info&BT_INFO_8821A_1ANT_B_ACL_BUSY) {
+	} else if (bt_info & BT_INFO_8821A_1ANT_B_ACL_BUSY) {
 		if (BT_8821A_1ANT_BT_STATUS_ACL_BUSY != coex_dm->bt_status)
 			coex_dm->auto_tdma_adjust = false;
 		coex_dm->bt_status = BT_8821A_1ANT_BT_STATUS_ACL_BUSY;
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 13/13] rtlwifi: btcoex: 21a 1ant: add bt_tx_rx_mask into bt info
  2017-04-17  0:06 [PATCH 00/13] rtlwifi: btcoex: Second set of 21a 1ant changes Larry Finger
                   ` (11 preceding siblings ...)
  2017-04-17  0:06 ` [PATCH 12/13] rtlwifi: btcoex: 21a 1ant: fix some coding style issues Larry Finger
@ 2017-04-17  0:07 ` Larry Finger
  12 siblings, 0 replies; 18+ messages in thread
From: Larry Finger @ 2017-04-17  0:07 UTC (permalink / raw)
  To: kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

Set rf register if the tx rx mask is switched.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
---
 .../wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c   | 14 ++++++++++++++
 .../wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.h   |  1 +
 2 files changed, 15 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
index 8022779004fb..bf9c66d571a0 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c
@@ -2848,6 +2848,20 @@ void ex_btc8821a1ant_bt_info_notify(struct btc_coexist *btcoexist,
 
 		coex_sta->bt_info_ext = coex_sta->bt_info_c2h[rsp_source][4];
 
+		coex_sta->bt_tx_rx_mask =
+			(coex_sta->bt_info_c2h[rsp_source][2] & 0x40);
+		btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TX_RX_MASK,
+				   &coex_sta->bt_tx_rx_mask);
+		if (!coex_sta->bt_tx_rx_mask) {
+			/* BT into is responded by BT FW and BT RF REG 0x3C !=
+			 * 0x15 => Need to switch BT TRx Mask
+			 */
+			RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+				 "[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x15\n");
+			btcoexist->btc_set_bt_reg(btcoexist, BTC_BT_REG_RF,
+						  0x3c, 0x15);
+		}
+
 		/* Here we need to resend some wifi info to BT
 		 * because bt is reset and lost the info
 		 */
diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.h b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.h
index 8d6ee81586fd..06ca55d5e647 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.h
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.h
@@ -156,6 +156,7 @@ struct coex_sta_8821a_1ant {
 	u32	low_priority_tx;
 	u32	low_priority_rx;
 	u8	bt_rssi;
+	bool	bt_tx_rx_mask;
 	u8	pre_bt_rssi_state;
 	u8	pre_wifi_rssi_state[4];
 	bool	c2h_bt_info_req_sent;
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 12/13] rtlwifi: btcoex: 21a 1ant: fix some coding style issues
  2017-04-17  0:06 ` [PATCH 12/13] rtlwifi: btcoex: 21a 1ant: fix some coding style issues Larry Finger
@ 2017-04-17 16:09   ` Joe Perches
  2017-04-17 17:13     ` Larry Finger
  0 siblings, 1 reply; 18+ messages in thread
From: Joe Perches @ 2017-04-17 16:09 UTC (permalink / raw)
  To: Larry Finger, kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Pkshih, Birming Chiu, Shaofu,
	Steven Ting

On Sun, 2017-04-16 at 19:06 -0500, Larry Finger wrote:
> From: Yan-Hsuan Chuang <yhchuang@realtek.com>
> 
> Fix alignment for coding style consistency.

aside:

Are all the btcoexist variants for this code identical?

8192e2ant.c 8723b1ant.c 8723b2ant.c 8821a1ant.c 8821a2ant.c

Maybe some of these functions should be centralized.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 12/13] rtlwifi: btcoex: 21a 1ant: fix some coding style issues
  2017-04-17 16:09   ` Joe Perches
@ 2017-04-17 17:13     ` Larry Finger
  2017-04-17 17:28       ` Joe Perches
  0 siblings, 1 reply; 18+ messages in thread
From: Larry Finger @ 2017-04-17 17:13 UTC (permalink / raw)
  To: Joe Perches, kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Pkshih, Birming Chiu, Shaofu,
	Steven Ting

On 04/17/2017 11:09 AM, Joe Perches wrote:
> On Sun, 2017-04-16 at 19:06 -0500, Larry Finger wrote:
>> From: Yan-Hsuan Chuang <yhchuang@realtek.com>
>>
>> Fix alignment for coding style consistency.
>
> aside:
>
> Are all the btcoexist variants for this code identical?
>
> 8192e2ant.c 8723b1ant.c 8723b2ant.c 8821a1ant.c 8821a2ant.c
>
> Maybe some of these functions should be centralized.

They are not identical, but some of the functions could certainly be centralized.

The problem is that the btcoex software at Realtek is multi platform, and 
written by a group that has not been too eager to implement this kind of 
suggestion. If we were to force the issue, then the maintenance load on the 
separate Linux group at Realtek would be greatly increased. This current set of 
updates has already been delayed for at least two years while they found the 
resources to be able to adhere to the "small change" policy of Linux. For that 
reason alone, I would not be in favor of forcing the issue.

Larry

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 12/13] rtlwifi: btcoex: 21a 1ant: fix some coding style issues
  2017-04-17 17:13     ` Larry Finger
@ 2017-04-17 17:28       ` Joe Perches
  0 siblings, 0 replies; 18+ messages in thread
From: Joe Perches @ 2017-04-17 17:28 UTC (permalink / raw)
  To: Larry Finger, kvalo
  Cc: linux-wireless, Yan-Hsuan Chuang, Pkshih, Birming Chiu, Shaofu,
	Steven Ting

On Mon, 2017-04-17 at 12:13 -0500, Larry Finger wrote:
> On 04/17/2017 11:09 AM, Joe Perches wrote:
> > On Sun, 2017-04-16 at 19:06 -0500, Larry Finger wrote:
> > > From: Yan-Hsuan Chuang <yhchuang@realtek.com>
> > > 
> > > Fix alignment for coding style consistency.
> > 
> > aside:
> > 
> > Are all the btcoexist variants for this code identical?
> > 
> > 8192e2ant.c 8723b1ant.c 8723b2ant.c 8821a1ant.c 8821a2ant.c
> > 
> > Maybe some of these functions should be centralized.
> 
> They are not identical, but some of the functions could certainly be centralized.

I was writing specifically about functions not modules.

> The problem is that the btcoex software at Realtek is multi platform, and 
> written by a group that has not been too eager to implement this kind of 
> suggestion. If we were to force the issue, then the maintenance load on the 
> separate Linux group at Realtek would be greatly increased. This current set of 
> updates has already been delayed for at least two years while they found the 
> resources to be able to adhere to the "small change" policy of Linux. For that 
> reason alone, I would not be in favor of forcing the issue.

No worries, it just looked pretty mindless to copy/paste
relatively large blocks of code and then do trivial
whitespace fixes to them individually and separately.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [01/13] rtlwifi: btcoex: 21a 1ant: set tdma and coex table when wifi is idle
  2017-04-17  0:06 ` [PATCH 01/13] rtlwifi: btcoex: 21a 1ant: set tdma and coex table when wifi is idle Larry Finger
@ 2017-04-21  6:38   ` Kalle Valo
  0 siblings, 0 replies; 18+ messages in thread
From: Kalle Valo @ 2017-04-21  6:38 UTC (permalink / raw)
  To: Larry Finger
  Cc: linux-wireless, Yan-Hsuan Chuang, Larry Finger, Pkshih,
	Birming Chiu, Shaofu, Steven Ting

Larry Finger <Larry.Finger@lwfinger.net> wrote:
> From: Yan-Hsuan Chuang <yhchuang@realtek.com>
> 
> When wifi is idle, bt could have more resources to transmit, so set the
> tdma and coex table to achieve this.
> 
> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
> Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> Cc: Pkshih <pkshih@realtek.com>
> Cc: Birming Chiu <birming@realtek.com>
> Cc: Shaofu <shaofu@realtek.com>
> Cc: Steven Ting <steventing@realtek.com>

Requested by Larry

13 patches set to Changes Requested.

9683295 [01/13] rtlwifi: btcoex: 21a 1ant: set tdma and coex table when wifi is idle
9683307 [02/13] rtlwifi: btcoex: 21a 1ant: more bt profiling when wifi receives special packet
9683297 [03/13] rtlwifi: btcoex: 21a 1ant: shorten wifi slot when connected scan
9683299 [04/13] rtlwifi: btcoex: 21a 1ant: react to special packet when wifi is not scanning
9683301 [05/13] rtlwifi: btcoex: 21a 1ant: coex table and tdma settings for softap mode
9683319 [06/13] rtlwifi: btcoex: 21a 1ant: wifi slot time adjustment
9683303 [07/13] rtlwifi: btcoex: 21a 1ant: normal mode for retry limit when connected
9683305 [08/13] rtlwifi: btcoex: 21a 1ant: mark packet high priority when scanning
9683315 [09/13] rtlwifi: btcoex: 21a 1ant: use default value when initiating coex
9683317 [10/13] rtlwifi: btcoex: 21a 1ant: re-init coex after wifi leaves IPS
9683311 [11/13] rtlwifi: btcoex: 21a 1ant: treat ARP as special packet
9683309 [12/13] rtlwifi: btcoex: 21a 1ant: fix some coding style issues
9683313 [13/13] rtlwifi: btcoex: 21a 1ant: add bt_tx_rx_mask into bt info

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

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2017-04-21  6:38 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-17  0:06 [PATCH 00/13] rtlwifi: btcoex: Second set of 21a 1ant changes Larry Finger
2017-04-17  0:06 ` [PATCH 01/13] rtlwifi: btcoex: 21a 1ant: set tdma and coex table when wifi is idle Larry Finger
2017-04-21  6:38   ` [01/13] " Kalle Valo
2017-04-17  0:06 ` [PATCH 02/13] rtlwifi: btcoex: 21a 1ant: more bt profiling when wifi receives special packet Larry Finger
2017-04-17  0:06 ` [PATCH 03/13] rtlwifi: btcoex: 21a 1ant: shorten wifi slot when connected scan Larry Finger
2017-04-17  0:06 ` [PATCH 04/13] rtlwifi: btcoex: 21a 1ant: react to special packet when wifi is not scanning Larry Finger
2017-04-17  0:06 ` [PATCH 05/13] rtlwifi: btcoex: 21a 1ant: coex table and tdma settings for softap mode Larry Finger
2017-04-17  0:06 ` [PATCH 06/13] rtlwifi: btcoex: 21a 1ant: wifi slot time adjustment Larry Finger
2017-04-17  0:06 ` [PATCH 07/13] rtlwifi: btcoex: 21a 1ant: normal mode for retry limit when connected Larry Finger
2017-04-17  0:06 ` [PATCH 08/13] rtlwifi: btcoex: 21a 1ant: mark packet high priority when scanning Larry Finger
2017-04-17  0:06 ` [PATCH 09/13] rtlwifi: btcoex: 21a 1ant: use default value when initiating coex Larry Finger
2017-04-17  0:06 ` [PATCH 10/13] rtlwifi: btcoex: 21a 1ant: re-init coex after wifi leaves IPS Larry Finger
2017-04-17  0:06 ` [PATCH 11/13] rtlwifi: btcoex: 21a 1ant: treat ARP as special packet Larry Finger
2017-04-17  0:06 ` [PATCH 12/13] rtlwifi: btcoex: 21a 1ant: fix some coding style issues Larry Finger
2017-04-17 16:09   ` Joe Perches
2017-04-17 17:13     ` Larry Finger
2017-04-17 17:28       ` Joe Perches
2017-04-17  0:07 ` [PATCH 13/13] rtlwifi: btcoex: 21a 1ant: add bt_tx_rx_mask into bt info Larry Finger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.