Skip to contentSkip to conversation

rtlwifi: fix some bugs and add btcoex functions

PATCH Superseded [email protected] 5 participants 35 messages Jan 11, 2018 – Jan 19, 2018 Realtek wireless driver (rtlwifi family)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

v2 cover rtlwifi: fix some bugs and add btcoex functions

From: Ping-Ke Shih <[email protected]>

Fix some bugs reported by QC, and continue to submit btcoex patches for further use.

v2: add my sob to commit log if missing, and remove trivial comments.

Ping-Ke Shih (8):
rtlwifi: Use mutex to replace spin_lock to protect IPS and LPS
rtlwifi: fix scan channel 1 fail after IPS
rtlwifi: Add sta_statistics of mac80211's op, and set filled=0 by
default
rtlwifi: enable mac80211 fast-tx support
rtlwifi: btcoex: Add power_on_setting routine
rtlwifi: btcoex: Remove global variables from btcoex
rtlwifi: btcoex: Add common function for qeurying BT information
rtlwifi: btcoex: add rfe_type parameter to btcoex

Steven Ting (1):
rtlwifi: Support A-MSDU in A-MPDU capability

Tsang-Shian Lin (1):
rtlwifi: unlink bss when un-association

 drivers/net/wireless/realtek/rtlwifi/base.c        |   9 +-
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c       | 398 +++++++++++++++++----
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.h       |  94 ++++-
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.c   | 234 ++++++++++--
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.h   |   4 +-
 drivers/net/wireless/realtek/rtlwifi/core.c        |  34 ++
 drivers/net/wireless/realtek/rtlwifi/pci.c         |   5 +-
 drivers/net/wireless/realtek/rtlwifi/ps.c          |  30 +-
 drivers/net/wireless/realtek/rtlwifi/usb.c         |   1 -
 drivers/net/wireless/realtek/rtlwifi/wifi.h        |  16 +-
 10 files changed, 688 insertions(+), 137 deletions(-)
Signature · 1 line
2.15.1
author maintainer
#1 lore raw

PATCH v2 1/10 rtlwifi: Use mutex to replace spin_lock to protect IPS and LPS

From: Ping-Ke Shih <[email protected]>

Enter/leavel IPS and LPS are large critical section, and they can't use sleep function because running in atomic-context, which own a spin_lock. In commit ba9f93f82aba ("rtlwifi: Fix enter/exit power_save"), it moves LPS functions to thread-context, so this commit can simply change LPS's spin lock to mutex.
Considering IPS functions, rtl_ips_nic_on() may be called by TX tasklet (softirq-context) that check whether packet is auth frame. Fortunately, current mac80211 will ask driver to leave IPS using op_config with changed flag IEEE80211_CONF_CHANGE_IDLE, before issuing auth frame, so IPS functions can run in thread-context and use mutex to protect critical section, too.
Also, this commit removes some useless spin locks.

---
 drivers/net/wireless/realtek/rtlwifi/base.c |  6 ++----
 drivers/net/wireless/realtek/rtlwifi/ps.c   | 24 ++++++++++--------------
 drivers/net/wireless/realtek/rtlwifi/usb.c  |  1 -
 drivers/net/wireless/realtek/rtlwifi/wifi.h | 10 ++--------
 4 files changed, 14 insertions(+), 27 deletions(-)
drivers/net/wireless/realtek/rtlwifi/base.c +2 -4
index 0ba9c0cc95e1..89ec318598ea 100644
@@ -551,7 +551,8 @@ int rtl_init_core(struct ieee80211_hw *hw)
 
 	/* <4> locks */
 	mutex_init(&rtlpriv->locks.conf_mutex);
-	spin_lock_init(&rtlpriv->locks.ips_lock);
+	mutex_init(&rtlpriv->locks.ips_mutex);
+	mutex_init(&rtlpriv->locks.lps_mutex);
 	spin_lock_init(&rtlpriv->locks.irq_th_lock);
 	spin_lock_init(&rtlpriv->locks.h2c_lock);
 	spin_lock_init(&rtlpriv->locks.rf_ps_lock);
@@ -561,9 +562,7 @@ int rtl_init_core(struct ieee80211_hw *hw)
 	spin_lock_init(&rtlpriv->locks.c2hcmd_lock);
 	spin_lock_init(&rtlpriv->locks.scan_list_lock);
 	spin_lock_init(&rtlpriv->locks.cck_and_rw_pagea_lock);
-	spin_lock_init(&rtlpriv->locks.check_sendpkt_lock);
 	spin_lock_init(&rtlpriv->locks.fw_ps_lock);
-	spin_lock_init(&rtlpriv->locks.lps_lock);
 	spin_lock_init(&rtlpriv->locks.iqk_lock);
 	/* <5> init list */
 	INIT_LIST_HEAD(&rtlpriv->entry_list);
@@ -1229,7 +1228,6 @@ bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb)
 	}
 	if (ieee80211_is_auth(fc)) {
 		RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, "MAC80211_LINKING\n");
-		rtl_ips_nic_on(hw);
 
 		mac->link_state = MAC80211_LINKING;
 		/* Dul mac */
drivers/net/wireless/realtek/rtlwifi/ps.c +10 -14
index 24c87fae5382..6a4008845f49 100644
@@ -289,7 +289,7 @@ void rtl_ips_nic_on(struct ieee80211_hw *hw)
 
 	cancel_delayed_work(&rtlpriv->works.ips_nic_off_wq);
 
-	spin_lock(&rtlpriv->locks.ips_lock);
+	mutex_lock(&rtlpriv->locks.ips_mutex);
 	if (ppsc->inactiveps) {
 		rtstate = ppsc->rfpwr_state;
 
@@ -306,7 +306,7 @@ void rtl_ips_nic_on(struct ieee80211_hw *hw)
 									ppsc->inactive_pwrstate);
 		}
 	}
-	spin_unlock(&rtlpriv->locks.ips_lock);
+	mutex_unlock(&rtlpriv->locks.ips_mutex);
 }
 EXPORT_SYMBOL_GPL(rtl_ips_nic_on);
 
@@ -415,7 +415,6 @@ static void rtl_lps_enter_core(struct ieee80211_hw *hw)
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
-	unsigned long flag;
 
 	if (!ppsc->fwctrl_lps)
 		return;
@@ -436,7 +435,7 @@ static void rtl_lps_enter_core(struct ieee80211_hw *hw)
 	if (mac->link_state != MAC80211_LINKED)
 		return;
 
-	spin_lock_irqsave(&rtlpriv->locks.lps_lock, flag);
+	mutex_lock(&rtlpriv->locks.lps_mutex);
 
 	/* Don't need to check (ppsc->dot11_psmode == EACTIVE), because
 	 * bt_ccoexist may ask to enter lps.
@@ -446,7 +445,7 @@ static void rtl_lps_enter_core(struct ieee80211_hw *hw)
 		 "Enter 802.11 power save mode...\n");
 	rtl_lps_set_psmode(hw, EAUTOPS);
 
-	spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flag);
+	mutex_unlock(&rtlpriv->locks.lps_mutex);
 }
 
 /* Interrupt safe routine to leave the leisure power save mode.*/
@@ -455,9 +454,8 @@ static void rtl_lps_leave_core(struct ieee80211_hw *hw)
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
-	unsigned long flag;
 
-	spin_lock_irqsave(&rtlpriv->locks.lps_lock, flag);
+	mutex_lock(&rtlpriv->locks.lps_mutex);
 
 	if (ppsc->fwctrl_lps) {
 		if (ppsc->dot11_psmode != EACTIVE) {
@@ -478,7 +476,7 @@ static void rtl_lps_leave_core(struct ieee80211_hw *hw)
 			rtl_lps_set_psmode(hw, EACTIVE);
 		}
 	}
-	spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flag);
+	mutex_unlock(&rtlpriv->locks.lps_mutex);
 }
 
 /* For sw LPS*/
@@ -568,7 +566,6 @@ void rtl_swlps_rf_awake(struct ieee80211_hw *hw)
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
-	unsigned long flag;
 
 	if (!rtlpriv->psc.swctrl_lps)
 		return;
@@ -581,9 +578,9 @@ void rtl_swlps_rf_awake(struct ieee80211_hw *hw)
 		RT_CLEAR_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM);
 	}
 
-	spin_lock_irqsave(&rtlpriv->locks.lps_lock, flag);
+	mutex_lock(&rtlpriv->locks.lps_mutex);
 	rtl_ps_set_rf_state(hw, ERFON, RF_CHANGE_BY_PS);
-	spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flag);
+	mutex_unlock(&rtlpriv->locks.lps_mutex);
 }
 
 void rtl_swlps_rfon_wq_callback(void *data)
@@ -600,7 +597,6 @@ void rtl_swlps_rf_sleep(struct ieee80211_hw *hw)
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
-	unsigned long flag;
 	u8 sleep_intv;
 
 	if (!rtlpriv->psc.sw_ps_enabled)
@@ -624,9 +620,9 @@ void rtl_swlps_rf_sleep(struct ieee80211_hw *hw)
 	}
 	spin_unlock(&rtlpriv->locks.rf_ps_lock);
 
-	spin_lock_irqsave(&rtlpriv->locks.lps_lock, flag);
+	mutex_lock(&rtlpriv->locks.lps_mutex);
 	rtl_ps_set_rf_state(hw, ERFSLEEP, RF_CHANGE_BY_PS);
-	spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flag);
+	mutex_unlock(&rtlpriv->locks.lps_mutex);
 
 	if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_ASPM &&
 	    !RT_IN_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM)) {
drivers/net/wireless/realtek/rtlwifi/usb.c +0 -1
index 39b033b3b53a..ce3103bb8ebb 100644
@@ -962,7 +962,6 @@ static void _rtl_usb_tx_preprocess(struct ieee80211_hw *hw,
 	memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
 	if (ieee80211_is_auth(fc)) {
 		RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, "MAC80211_LINKING\n");
-		rtl_ips_nic_on(hw);
 	}
 
 	if (rtlpriv->psc.sw_ps_enabled) {
drivers/net/wireless/realtek/rtlwifi/wifi.h +2 -8
index 0b1c54381a2f..941694060f48 100644
@@ -2325,17 +2325,14 @@ struct rtl_hal_cfg {
 struct rtl_locks {
 	/* mutex */
 	struct mutex conf_mutex;
-	struct mutex ps_mutex;
+	struct mutex ips_mutex;	/* mutex for enter/leave IPS */
+	struct mutex lps_mutex;	/* mutex for enter/leave LPS */
 
 	/*spin lock */
-	spinlock_t ips_lock;
 	spinlock_t irq_th_lock;
-	spinlock_t irq_pci_lock;
-	spinlock_t tx_lock;
 	spinlock_t h2c_lock;
 	spinlock_t rf_ps_lock;
 	spinlock_t rf_lock;
-	spinlock_t lps_lock;
 	spinlock_t waitq_lock;
 	spinlock_t entry_list_lock;
 	spinlock_t usb_lock;
@@ -2348,9 +2345,6 @@ struct rtl_locks {
 	/*Dual mac*/
 	spinlock_t cck_and_rw_pagea_lock;
 
-	/*Easy concurrent*/
-	spinlock_t check_sendpkt_lock;
-
 	spinlock_t iqk_lock;
 };
 
Signature · 1 line
2.15.1
Acked-by on v2 1/10
#2 lore raw

Re: [PATCH v2 01/10] rtlwifi: Use mutex to replace spin_lock to protect IPS and LPS

Quoted 15 lines · On 01/11/2018 01:09 AM, [email protected] wrote:

From: Ping-Ke Shih <[email protected]>

Enter/leavel IPS and LPS are large critical section, and they can't use sleep function because running in atomic-context, which own a spin_lock. In commit ba9f93f82aba ("rtlwifi: Fix enter/exit power_save"), it moves LPS functions to thread-context, so this commit can simply change LPS's spin lock to mutex.
Considering IPS functions, rtl_ips_nic_on() may be called by TX tasklet (softirq-context) that check whether packet is auth frame. Fortunately, current mac80211 will ask driver to leave IPS using op_config with changed flag IEEE80211_CONF_CHANGE_IDLE, before issuing auth frame, so IPS functions can run in thread-context and use mutex to protect critical section, too.
Also, this commit removes some useless spin locks.

Quoted 1 line
Quoted 194 lines
---
  drivers/net/wireless/realtek/rtlwifi/base.c |  6 ++----
  drivers/net/wireless/realtek/rtlwifi/ps.c   | 24 ++++++++++--------------
  drivers/net/wireless/realtek/rtlwifi/usb.c  |  1 -
  drivers/net/wireless/realtek/rtlwifi/wifi.h | 10 ++--------
  4 files changed, 14 insertions(+), 27 deletions(-)
drivers/net/wireless/realtek/rtlwifi/base.c +2 -4
index 0ba9c0cc95e1..89ec318598ea 100644
@@ -551,7 +551,8 @@ int rtl_init_core(struct ieee80211_hw *hw)
 
  	/* <4> locks */
  	mutex_init(&rtlpriv->locks.conf_mutex);
-	spin_lock_init(&rtlpriv->locks.ips_lock);
+	mutex_init(&rtlpriv->locks.ips_mutex);
+	mutex_init(&rtlpriv->locks.lps_mutex);
  	spin_lock_init(&rtlpriv->locks.irq_th_lock);
  	spin_lock_init(&rtlpriv->locks.h2c_lock);
  	spin_lock_init(&rtlpriv->locks.rf_ps_lock);
@@ -561,9 +562,7 @@ int rtl_init_core(struct ieee80211_hw *hw)
  	spin_lock_init(&rtlpriv->locks.c2hcmd_lock);
  	spin_lock_init(&rtlpriv->locks.scan_list_lock);
  	spin_lock_init(&rtlpriv->locks.cck_and_rw_pagea_lock);
-	spin_lock_init(&rtlpriv->locks.check_sendpkt_lock);
  	spin_lock_init(&rtlpriv->locks.fw_ps_lock);
-	spin_lock_init(&rtlpriv->locks.lps_lock);
  	spin_lock_init(&rtlpriv->locks.iqk_lock);
  	/* <5> init list */
  	INIT_LIST_HEAD(&rtlpriv->entry_list);
@@ -1229,7 +1228,6 @@ bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb)
  	}
  	if (ieee80211_is_auth(fc)) {
  		RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, "MAC80211_LINKING\n");
-		rtl_ips_nic_on(hw);
 
  		mac->link_state = MAC80211_LINKING;
  		/* Dul mac */
drivers/net/wireless/realtek/rtlwifi/ps.c +10 -14
index 24c87fae5382..6a4008845f49 100644
@@ -289,7 +289,7 @@ void rtl_ips_nic_on(struct ieee80211_hw *hw)
 
  	cancel_delayed_work(&rtlpriv->works.ips_nic_off_wq);
 
-	spin_lock(&rtlpriv->locks.ips_lock);
+	mutex_lock(&rtlpriv->locks.ips_mutex);
  	if (ppsc->inactiveps) {
  		rtstate = ppsc->rfpwr_state;
 
@@ -306,7 +306,7 @@ void rtl_ips_nic_on(struct ieee80211_hw *hw)
  									ppsc->inactive_pwrstate);
  		}
  	}
-	spin_unlock(&rtlpriv->locks.ips_lock);
+	mutex_unlock(&rtlpriv->locks.ips_mutex);
  }
  EXPORT_SYMBOL_GPL(rtl_ips_nic_on);
 
@@ -415,7 +415,6 @@ static void rtl_lps_enter_core(struct ieee80211_hw *hw)
  	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
  	struct rtl_priv *rtlpriv = rtl_priv(hw);
-	unsigned long flag;
 
  	if (!ppsc->fwctrl_lps)
  		return;
@@ -436,7 +435,7 @@ static void rtl_lps_enter_core(struct ieee80211_hw *hw)
  	if (mac->link_state != MAC80211_LINKED)
  		return;
 
-	spin_lock_irqsave(&rtlpriv->locks.lps_lock, flag);
+	mutex_lock(&rtlpriv->locks.lps_mutex);
 
  	/* Don't need to check (ppsc->dot11_psmode == EACTIVE), because
  	 * bt_ccoexist may ask to enter lps.
@@ -446,7 +445,7 @@ static void rtl_lps_enter_core(struct ieee80211_hw *hw)
  		 "Enter 802.11 power save mode...\n");
  	rtl_lps_set_psmode(hw, EAUTOPS);
 
-	spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flag);
+	mutex_unlock(&rtlpriv->locks.lps_mutex);
  }
 
  /* Interrupt safe routine to leave the leisure power save mode.*/
@@ -455,9 +454,8 @@ static void rtl_lps_leave_core(struct ieee80211_hw *hw)
  	struct rtl_priv *rtlpriv = rtl_priv(hw);
  	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
  	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
-	unsigned long flag;
 
-	spin_lock_irqsave(&rtlpriv->locks.lps_lock, flag);
+	mutex_lock(&rtlpriv->locks.lps_mutex);
 
  	if (ppsc->fwctrl_lps) {
  		if (ppsc->dot11_psmode != EACTIVE) {
@@ -478,7 +476,7 @@ static void rtl_lps_leave_core(struct ieee80211_hw *hw)
  			rtl_lps_set_psmode(hw, EACTIVE);
  		}
  	}
-	spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flag);
+	mutex_unlock(&rtlpriv->locks.lps_mutex);
  }
 
  /* For sw LPS*/
@@ -568,7 +566,6 @@ void rtl_swlps_rf_awake(struct ieee80211_hw *hw)
  	struct rtl_priv *rtlpriv = rtl_priv(hw);
  	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
  	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
-	unsigned long flag;
 
  	if (!rtlpriv->psc.swctrl_lps)
  		return;
@@ -581,9 +578,9 @@ void rtl_swlps_rf_awake(struct ieee80211_hw *hw)
  		RT_CLEAR_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM);
  	}
 
-	spin_lock_irqsave(&rtlpriv->locks.lps_lock, flag);
+	mutex_lock(&rtlpriv->locks.lps_mutex);
  	rtl_ps_set_rf_state(hw, ERFON, RF_CHANGE_BY_PS);
-	spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flag);
+	mutex_unlock(&rtlpriv->locks.lps_mutex);
  }
 
  void rtl_swlps_rfon_wq_callback(void *data)
@@ -600,7 +597,6 @@ void rtl_swlps_rf_sleep(struct ieee80211_hw *hw)
  	struct rtl_priv *rtlpriv = rtl_priv(hw);
  	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
-	unsigned long flag;
  	u8 sleep_intv;
 
  	if (!rtlpriv->psc.sw_ps_enabled)
@@ -624,9 +620,9 @@ void rtl_swlps_rf_sleep(struct ieee80211_hw *hw)
  	}
  	spin_unlock(&rtlpriv->locks.rf_ps_lock);
 
-	spin_lock_irqsave(&rtlpriv->locks.lps_lock, flag);
+	mutex_lock(&rtlpriv->locks.lps_mutex);
  	rtl_ps_set_rf_state(hw, ERFSLEEP, RF_CHANGE_BY_PS);
-	spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flag);
+	mutex_unlock(&rtlpriv->locks.lps_mutex);
 
  	if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_ASPM &&
  	    !RT_IN_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM)) {
drivers/net/wireless/realtek/rtlwifi/usb.c +0 -1
index 39b033b3b53a..ce3103bb8ebb 100644
@@ -962,7 +962,6 @@ static void _rtl_usb_tx_preprocess(struct ieee80211_hw *hw,
  	memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
  	if (ieee80211_is_auth(fc)) {
  		RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, "MAC80211_LINKING\n");
-		rtl_ips_nic_on(hw);
  	}
 
  	if (rtlpriv->psc.sw_ps_enabled) {
drivers/net/wireless/realtek/rtlwifi/wifi.h +2 -8
index 0b1c54381a2f..941694060f48 100644
@@ -2325,17 +2325,14 @@ struct rtl_hal_cfg {
  struct rtl_locks {
  	/* mutex */
  	struct mutex conf_mutex;
-	struct mutex ps_mutex;
+	struct mutex ips_mutex;	/* mutex for enter/leave IPS */
+	struct mutex lps_mutex;	/* mutex for enter/leave LPS */
 
  	/*spin lock */
-	spinlock_t ips_lock;
  	spinlock_t irq_th_lock;
-	spinlock_t irq_pci_lock;
-	spinlock_t tx_lock;
  	spinlock_t h2c_lock;
  	spinlock_t rf_ps_lock;
  	spinlock_t rf_lock;
-	spinlock_t lps_lock;
  	spinlock_t waitq_lock;
  	spinlock_t entry_list_lock;
  	spinlock_t usb_lock;
@@ -2348,9 +2345,6 @@ struct rtl_locks {
  	/*Dual mac*/
  	spinlock_t cck_and_rw_pagea_lock;
 
-	/*Easy concurrent*/
-	spinlock_t check_sendpkt_lock;
-
  	spinlock_t iqk_lock;
  };
 
author maintainer
#3 lore raw

PATCH v2 2/10 rtlwifi: fix scan channel 1 fail after IPS

In reply to [email protected]

From: Ping-Ke Shih <[email protected]>

If there is no connection, driver will enter IPS state. Meanwhile, it fails to scan channel 1 by the command 'iw dev wlan0 scan freq 2412', because hardware channel setting lose after IPS. Thus, restore channel setting from hw->conf.channel set by last rtl_op_config().

---
 drivers/net/wireless/realtek/rtlwifi/ps.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/wireless/realtek/rtlwifi/ps.c +5 -0
index 6a4008845f49..71af24e2e051 100644
@@ -51,6 +51,11 @@ bool rtl_ps_enable_nic(struct ieee80211_hw *hw)
 			&rtlmac->retry_long);
 	RT_CLEAR_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC);
 
+	rtlpriv->cfg->ops->switch_channel(hw);
+	rtlpriv->cfg->ops->set_channel_access(hw);
+	rtlpriv->cfg->ops->set_bw_mode(hw,
+			cfg80211_get_chandef_type(&hw->conf.chandef));
+
 	/*<3> Enable Interrupt */
 	rtlpriv->cfg->ops->enable_interrupt(hw);
 
Signature · 1 line
2.15.1
Acked-by on v2 2/10
#4 lore raw

Re: [PATCH v2 02/10] rtlwifi: fix scan channel 1 fail after IPS

Quoted 7 lines · On 01/11/2018 01:09 AM, [email protected] wrote:

From: Ping-Ke Shih <[email protected]>

If there is no connection, driver will enter IPS state. Meanwhile, it fails to scan channel 1 by the command 'iw dev wlan0 scan freq 2412', because hardware channel setting lose after IPS. Thus, restore channel setting from hw->conf.channel set by last rtl_op_config().

Quoted 5 lines
---
  drivers/net/wireless/realtek/rtlwifi/ps.c | 5 +++++
  1 file changed, 5 insertions(+)
Quoted 18 lines
drivers/net/wireless/realtek/rtlwifi/ps.c +5 -0
index 6a4008845f49..71af24e2e051 100644
@@ -51,6 +51,11 @@ bool rtl_ps_enable_nic(struct ieee80211_hw *hw)
  			&rtlmac->retry_long);
  	RT_CLEAR_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC);
 
+	rtlpriv->cfg->ops->switch_channel(hw);
+	rtlpriv->cfg->ops->set_channel_access(hw);
+	rtlpriv->cfg->ops->set_bw_mode(hw,
+			cfg80211_get_chandef_type(&hw->conf.chandef));
+
  	/*<3> Enable Interrupt */
  	rtlpriv->cfg->ops->enable_interrupt(hw);
 
author maintainer
#5 lore raw

PATCH v2 3/10 rtlwifi: Add sta_statistics of mac80211's op, and set filled=0 by default

In reply to [email protected]

From: Ping-Ke Shih <[email protected]>

When using iwconfig to check wifi status, wext uses 'static struct' of sinfo to get station info so sinfo->filled will be persistent. Since the commit 2b9a7e1bac24 ("mac80211: allow drivers to provide most station statistics") assumes driver initializes sinfo->filled to declare supported fields, without initialization it will report wrong info. This commit simply set 'filled' to be zero simply, and left sinfo to be filled by mac80211.

---
 drivers/net/wireless/realtek/rtlwifi/core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/wireless/realtek/rtlwifi/core.c +10 -0
index a78b828f531a..ec639fa8095e 100644
@@ -992,6 +992,15 @@ static int _rtl_get_hal_qnum(u16 queue)
 	return qnum;
 }
 
+static void rtl_op_sta_statistics(struct ieee80211_hw *hw,
+				  struct ieee80211_vif *vif,
+				  struct ieee80211_sta *sta,
+				  struct station_info *sinfo)
+{
+	/* nothing filled by driver, so mac80211 will update all info */
+	sinfo->filled = 0;
+}
+
 /*
  *for mac80211 VO = 0, VI = 1, BE = 2, BK = 3
  *for rtl819x  BE = 0, BK = 1, VI = 2, VO = 3
@@ -1878,6 +1887,7 @@ const struct ieee80211_ops rtl_ops = {
 	.config = rtl_op_config,
 	.configure_filter = rtl_op_configure_filter,
 	.set_key = rtl_op_set_key,
+	.sta_statistics = rtl_op_sta_statistics,
 	.conf_tx = rtl_op_conf_tx,
 	.bss_info_changed = rtl_op_bss_info_changed,
 	.get_tsf = rtl_op_get_tsf,
Signature · 1 line
2.15.1
Acked-by on v2 3/10
#6 lore raw

Re: [PATCH v2 03/10] rtlwifi: Add sta_statistics of mac80211's op, and set filled=0 by default

Quoted 10 lines · On 01/11/2018 01:09 AM, [email protected] wrote:

From: Ping-Ke Shih <[email protected]>

When using iwconfig to check wifi status, wext uses 'static struct' of sinfo to get station info so sinfo->filled will be persistent. Since the commit 2b9a7e1bac24 ("mac80211: allow drivers to provide most station statistics") assumes driver initializes sinfo->filled to declare supported fields, without initialization it will report wrong info. This commit simply set 'filled' to be zero simply, and left sinfo to be filled by mac80211.

Quoted 4 lines
---
  drivers/net/wireless/realtek/rtlwifi/core.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
Quoted 30 lines
drivers/net/wireless/realtek/rtlwifi/core.c +10 -0
index a78b828f531a..ec639fa8095e 100644
@@ -992,6 +992,15 @@ static int _rtl_get_hal_qnum(u16 queue)
  	return qnum;
  }
 
+static void rtl_op_sta_statistics(struct ieee80211_hw *hw,
+				  struct ieee80211_vif *vif,
+				  struct ieee80211_sta *sta,
+				  struct station_info *sinfo)
+{
+	/* nothing filled by driver, so mac80211 will update all info */
+	sinfo->filled = 0;
+}
+
  /*
   *for mac80211 VO = 0, VI = 1, BE = 2, BK = 3
   *for rtl819x  BE = 0, BK = 1, VI = 2, VO = 3
@@ -1878,6 +1887,7 @@ const struct ieee80211_ops rtl_ops = {
  	.config = rtl_op_config,
  	.configure_filter = rtl_op_configure_filter,
  	.set_key = rtl_op_set_key,
+	.sta_statistics = rtl_op_sta_statistics,
  	.conf_tx = rtl_op_conf_tx,
  	.bss_info_changed = rtl_op_bss_info_changed,
  	.get_tsf = rtl_op_get_tsf,
#7 lore raw

Re: [PATCH v2 03/10] rtlwifi: Add sta_statistics of mac80211's op, and set filled=0 by default

In reply to [email protected]
Quoted 36 lines · <[email protected]> writes:

From: Ping-Ke Shih <[email protected]>

When using iwconfig to check wifi status, wext uses 'static struct' of sinfo to get station info so sinfo->filled will be persistent. Since the commit 2b9a7e1bac24 ("mac80211: allow drivers to provide most station statistics") assumes driver initializes sinfo->filled to declare supported fields, without initialization it will report wrong info. This commit simply set 'filled' to be zero simply, and left sinfo to be filled by mac80211.

---
 drivers/net/wireless/realtek/rtlwifi/core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/wireless/realtek/rtlwifi/core.c +9 -0
index a78b828f531a..ec639fa8095e 100644
@@ -992,6 +992,15 @@ static int _rtl_get_hal_qnum(u16 queue)
 	return qnum;
 }
 
+static void rtl_op_sta_statistics(struct ieee80211_hw *hw,
+				  struct ieee80211_vif *vif,
+				  struct ieee80211_sta *sta,
+				  struct station_info *sinfo)
+{
+	/* nothing filled by driver, so mac80211 will update all info */
+	sinfo->filled = 0;
+}
+
 /*
  *for mac80211 VO = 0, VI = 1, BE = 2, BK = 3
  *for rtl819x  BE = 0, BK = 1, VI = 2, VO = 3

drivers/net/wireless/realtek/rtlwifi/core.c const struct ieee80211_ops rtl_ops = { · line 1890

Quoted 4 lines
drivers/net/wireless/realtek/rtlwifi/core.c +1 -0
@@ -1878,6 +1887,7 @@ const struct ieee80211_ops rtl_ops = {
 	.config = rtl_op_config,
 	.configure_filter = rtl_op_configure_filter,
 	.set_key = rtl_op_set_key,
+	.sta_statistics = rtl_op_sta_statistics,

Adding an empty op like that feels pointless, IMHO (but without checking mac80211 sources) not having the op should be the same as filled = 0. To me this smells like a bug in mac80211.

Johannes, what do you think?

Signature · 1 line
Kalle Valo
#8 lore raw

Re: [PATCH v2 03/10] rtlwifi: Add sta_statistics of mac80211's op, and set filled=0 by default

Quoted 7 lines · Kalle Valo
Quoted 7 lines

When using iwconfig to check wifi status, wext uses 'static struct' of sinfo to get station info so sinfo->filled will be persistent. Since the commit 2b9a7e1bac24 ("mac80211: allow drivers to provide most station statistics") assumes driver initializes sinfo->filled to declare supported fields, without initialization it will report wrong info. This commit simply set 'filled' to be zero simply, and left sinfo to be filled by mac80211.

Huh, this can't be right.

Quoted 5 lines

Adding an empty op like that feels pointless, IMHO (but without checking mac80211 sources) not having the op should be the same as filled = 0. To me this smells like a bug in mac80211.

Johannes, what do you think?

It can't be right. It would've broken each and every driver out there, other than the one or two who implement this.

However, it looks like PK is actually correct - *wext* does appear to be broken! nl80211 does this:

                memset(&sinfo, 0, sizeof(sinfo));
                err = rdev_dump_station(rdev, wdev->netdev, sta_idx,
                                        mac_addr, &sinfo);

and

        memset(&sinfo, 0, sizeof(sinfo));

...

        err = rdev_get_station(rdev, dev, mac_addr, &sinfo);

and has a bug in cfg80211_cqm_rssi_update(). Wext also has bugs, I'll send out a fix.

johannes

author maintainer
#9 lore raw

PATCH v2 4/10 rtlwifi: unlink bss when un-association

In reply to [email protected]

From: Tsang-Shian Lin <[email protected]>

When AP change bandwidth setting from 20M to 40M, STA may use old 20M AP information to association with AP. Driver unlink bss in the .bss_info_changed of ieee80211_ops to make sure that later scan can get correct AP bandwidth capability.

---
 drivers/net/wireless/realtek/rtlwifi/core.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/net/wireless/realtek/rtlwifi/core.c +18 -0
index ec639fa8095e..6c698123ac07 100644
@@ -1171,6 +1171,8 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
 			RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
 				 "BSS_CHANGED_ASSOC\n");
 		} else {
+			struct cfg80211_bss *bss = NULL;
+
 			mstatus = RT_MEDIA_DISCONNECT;
 
 			if (mac->link_state == MAC80211_LINKED)
@@ -1178,6 +1180,22 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
 			if (ppsc->p2p_ps_info.p2p_ps_mode > P2P_PS_NONE)
 				rtl_p2p_ps_cmd(hw, P2P_PS_DISABLE);
 			mac->link_state = MAC80211_NOLINK;
+
+			bss = cfg80211_get_bss(hw->wiphy, NULL,
+					       (u8 *)mac->bssid, NULL, 0,
+					       IEEE80211_BSS_TYPE_ESS,
+					       IEEE80211_PRIVACY_OFF);
+
+			RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
+				 "bssid = %pMF\n", mac->bssid);
+
+			if (bss) {
+				cfg80211_unlink_bss(hw->wiphy, bss);
+				cfg80211_put_bss(hw->wiphy, bss);
+				RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
+					 "cfg80211_unlink !!\n");
+			}
+
 			eth_zero_addr(mac->bssid);
 			mac->vendor = PEER_UNKNOWN;
 			mac->mode = 0;
Signature · 1 line
2.15.1
Acked-by on v2 4/10
#10 lore raw

Re: [PATCH v2 04/10] rtlwifi: unlink bss when un-association

Quoted 7 lines · On 01/11/2018 01:09 AM, [email protected] wrote:

From: Tsang-Shian Lin <[email protected]>

When AP change bandwidth setting from 20M to 40M, STA may use old 20M AP information to association with AP. Driver unlink bss in the .bss_info_changed of ieee80211_ops to make sure that later scan can get correct AP bandwidth capability.

Quoted 5 lines
---
  drivers/net/wireless/realtek/rtlwifi/core.c | 18 ++++++++++++++++++
  1 file changed, 18 insertions(+)
Quoted 38 lines
drivers/net/wireless/realtek/rtlwifi/core.c +18 -0
index ec639fa8095e..6c698123ac07 100644
@@ -1171,6 +1171,8 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
  			RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
  				 "BSS_CHANGED_ASSOC\n");
  		} else {
+			struct cfg80211_bss *bss = NULL;
+
  			mstatus = RT_MEDIA_DISCONNECT;
 
  			if (mac->link_state == MAC80211_LINKED)
@@ -1178,6 +1180,22 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
  			if (ppsc->p2p_ps_info.p2p_ps_mode > P2P_PS_NONE)
  				rtl_p2p_ps_cmd(hw, P2P_PS_DISABLE);
  			mac->link_state = MAC80211_NOLINK;
+
+			bss = cfg80211_get_bss(hw->wiphy, NULL,
+					       (u8 *)mac->bssid, NULL, 0,
+					       IEEE80211_BSS_TYPE_ESS,
+					       IEEE80211_PRIVACY_OFF);
+
+			RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
+				 "bssid = %pMF\n", mac->bssid);
+
+			if (bss) {
+				cfg80211_unlink_bss(hw->wiphy, bss);
+				cfg80211_put_bss(hw->wiphy, bss);
+				RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
+					 "cfg80211_unlink !!\n");
+			}
+
  			eth_zero_addr(mac->bssid);
  			mac->vendor = PEER_UNKNOWN;
  			mac->mode = 0;
author maintainer
#11 lore raw

PATCH v2 5/10 rtlwifi: enable mac80211 fast-tx support

In reply to [email protected]

From: Ping-Ke Shih <[email protected]>

To enable the mac80211 fast-tx feature, the hw/driver needs to support dynamic power saving and fragmentation. Since our driver does not need to fragment packet into smaller pieces, we just hook an empty callback of set_frag_threshold to avoid fragmentation in mac80211.

After this, the mac80211 will not fragment the packets and can transmit them faster by cache the header information.

---
 drivers/net/wireless/realtek/rtlwifi/base.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/core.c | 6 ++++++
 2 files changed, 8 insertions(+)
drivers/net/wireless/realtek/rtlwifi/base.c +2 -0
index 89ec318598ea..e902cd7adbfe 100644
@@ -395,6 +395,8 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
 	ieee80211_hw_set(hw, CONNECTION_MONITOR);
 	ieee80211_hw_set(hw, MFP_CAPABLE);
 	ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS);
+	ieee80211_hw_set(hw, SUPPORTS_TX_FRAG);
+	ieee80211_hw_set(hw, SUPPORT_FAST_XMIT);
 
 	/* swlps or hwlps has been set in diff chip in init_sw_vars */
 	if (rtlpriv->psc.swctrl_lps) {
drivers/net/wireless/realtek/rtlwifi/core.c +6 -0
index 6c698123ac07..d454c38fc9cd 100644
@@ -1001,6 +1001,11 @@ static void rtl_op_sta_statistics(struct ieee80211_hw *hw,
 	sinfo->filled = 0;
 }
 
+static int rtl_op_set_frag_threshold(struct ieee80211_hw *hw, u32 value)
+{
+	return -EOPNOTSUPP;
+}
+
 /*
  *for mac80211 VO = 0, VI = 1, BE = 2, BK = 3
  *for rtl819x  BE = 0, BK = 1, VI = 2, VO = 3
@@ -1906,6 +1911,7 @@ const struct ieee80211_ops rtl_ops = {
 	.configure_filter = rtl_op_configure_filter,
 	.set_key = rtl_op_set_key,
 	.sta_statistics = rtl_op_sta_statistics,
+	.set_frag_threshold = rtl_op_set_frag_threshold,
 	.conf_tx = rtl_op_conf_tx,
 	.bss_info_changed = rtl_op_bss_info_changed,
 	.get_tsf = rtl_op_get_tsf,
Signature · 1 line
2.15.1
Acked-by on v2 5/10
#12 lore raw

Re: [PATCH v2 05/10] rtlwifi: enable mac80211 fast-tx support

Quoted 10 lines · On 01/11/2018 01:09 AM, [email protected] wrote:

From: Ping-Ke Shih <[email protected]>

To enable the mac80211 fast-tx feature, the hw/driver needs to support dynamic power saving and fragmentation. Since our driver does not need to fragment packet into smaller pieces, we just hook an empty callback of set_frag_threshold to avoid fragmentation in mac80211.

After this, the mac80211 will not fragment the packets and can transmit them faster by cache the header information.

Quoted 6 lines
---
  drivers/net/wireless/realtek/rtlwifi/base.c | 2 ++
  drivers/net/wireless/realtek/rtlwifi/core.c | 6 ++++++
  2 files changed, 8 insertions(+)
Quoted 39 lines
drivers/net/wireless/realtek/rtlwifi/base.c +2 -0
index 89ec318598ea..e902cd7adbfe 100644
@@ -395,6 +395,8 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
  	ieee80211_hw_set(hw, CONNECTION_MONITOR);
  	ieee80211_hw_set(hw, MFP_CAPABLE);
  	ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS);
+	ieee80211_hw_set(hw, SUPPORTS_TX_FRAG);
+	ieee80211_hw_set(hw, SUPPORT_FAST_XMIT);
 
  	/* swlps or hwlps has been set in diff chip in init_sw_vars */
  	if (rtlpriv->psc.swctrl_lps) {
drivers/net/wireless/realtek/rtlwifi/core.c +6 -0
index 6c698123ac07..d454c38fc9cd 100644
@@ -1001,6 +1001,11 @@ static void rtl_op_sta_statistics(struct ieee80211_hw *hw,
  	sinfo->filled = 0;
  }
 
+static int rtl_op_set_frag_threshold(struct ieee80211_hw *hw, u32 value)
+{
+	return -EOPNOTSUPP;
+}
+
  /*
   *for mac80211 VO = 0, VI = 1, BE = 2, BK = 3
   *for rtl819x  BE = 0, BK = 1, VI = 2, VO = 3
@@ -1906,6 +1911,7 @@ const struct ieee80211_ops rtl_ops = {
  	.configure_filter = rtl_op_configure_filter,
  	.set_key = rtl_op_set_key,
  	.sta_statistics = rtl_op_sta_statistics,
+	.set_frag_threshold = rtl_op_set_frag_threshold,
  	.conf_tx = rtl_op_conf_tx,
  	.bss_info_changed = rtl_op_bss_info_changed,
  	.get_tsf = rtl_op_get_tsf,
#13 lore raw

Re: [PATCH v2 05/10] rtlwifi: enable mac80211 fast-tx support

In reply to [email protected]
Quoted 12 lines · <[email protected]> writes:

From: Ping-Ke Shih <[email protected]>

To enable the mac80211 fast-tx feature, the hw/driver needs to support dynamic power saving and fragmentation. Since our driver does not need to fragment packet into smaller pieces, we just hook an empty callback of set_frag_threshold to avoid fragmentation in mac80211.

After this, the mac80211 will not fragment the packets and can transmit them faster by cache the header information.

[...]

Quoted 15 lines
drivers/net/wireless/realtek/rtlwifi/core.c +5 -0
@@ -1001,6 +1001,11 @@ static void rtl_op_sta_statistics(struct ieee80211_hw *hw,
 	sinfo->filled = 0;
 }
 
+static int rtl_op_set_frag_threshold(struct ieee80211_hw *hw, u32 value)
+{
+	return -EOPNOTSUPP;
+}
+
 /*
  *for mac80211 VO = 0, VI = 1, BE = 2, BK = 3
  *for rtl819x  BE = 0, BK = 1, VI = 2, VO = 3

drivers/net/wireless/realtek/rtlwifi/core.c const struct ieee80211_ops rtl_ops = { · line 1914

Quoted 4 lines
drivers/net/wireless/realtek/rtlwifi/core.c +1 -0
@@ -1906,6 +1911,7 @@ const struct ieee80211_ops rtl_ops = {
 	.configure_filter = rtl_op_configure_filter,
 	.set_key = rtl_op_set_key,
 	.sta_statistics = rtl_op_sta_statistics,
+	.set_frag_threshold = rtl_op_set_frag_threshold,

This also looks fishy, I guess there's a good reason why mac80211 requires set_frag_threshold()? To me this is just a workaround for a mac80211 test.

Signature · 1 line
Kalle Valo
#14 lore raw

Re: [PATCH v2 05/10] rtlwifi: enable mac80211 fast-tx support

Quoted 32 lines · Kalle Valo
Quoted 12 lines · <[email protected]> writes:

From: Ping-Ke Shih <[email protected]>

To enable the mac80211 fast-tx feature, the hw/driver needs to support dynamic power saving and fragmentation. Since our driver does not need to fragment packet into smaller pieces, we just hook an empty callback of set_frag_threshold to avoid fragmentation in mac80211.

After this, the mac80211 will not fragment the packets and can transmit them faster by cache the header information.

[...]

Quoted 15 lines
drivers/net/wireless/realtek/rtlwifi/core.c +5 -0
@@ -1001,6 +1001,11 @@ static void rtl_op_sta_statistics(struct ieee80211_hw *hw,
  	sinfo->filled = 0;
  }
 
+static int rtl_op_set_frag_threshold(struct ieee80211_hw *hw, u32 value)
+{
+	return -EOPNOTSUPP;
+}
+
  /*
   *for mac80211 VO = 0, VI = 1, BE = 2, BK = 3
   *for rtl819x  BE = 0, BK = 1, VI = 2, VO = 3
@@ -1906,6 +1911,7 @@ const struct ieee80211_ops rtl_ops = {
Quoted 8 lines

drivers/net/wireless/realtek/rtlwifi/core.c const struct ieee80211_ops rtl_ops = { · line 1914

Quoted 4 lines
drivers/net/wireless/realtek/rtlwifi/core.c +1 -0
  	.configure_filter = rtl_op_configure_filter,
  	.set_key = rtl_op_set_key,
  	.sta_statistics = rtl_op_sta_statistics,
+	.set_frag_threshold = rtl_op_set_frag_threshold,

This also looks fishy, I guess there's a good reason why mac80211 requires set_frag_threshold()? To me this is just a workaround for a mac80211 test.

When I saw this flying by I had the same feeling. This is clearly not how it was intended although you could interpret the comments of the .set_frag_threshold() callback and IEEE80211_HW_SUPPORTS_TX_FRAG. However, the fragmentation threshold is a user-configurable stack parameter as per the standard. This patch effectively kill that option for the user although there may be RF conditions in which fragmentation can help. Having the user configure a fragmentation threshold of 2346 also disables fragmentation and allows mac80211 to use cached fastpath.

In short this should be NACK'ed.

Regards,
Arend

#15 lore raw

Re: [PATCH v2 05/10] rtlwifi: enable mac80211 fast-tx support

Quoted 10 lines · Arend van Spriel

When I saw this flying by I had the same feeling. This is clearly not how it was intended although you could interpret the comments of the .set_frag_threshold() callback and IEEE80211_HW_SUPPORTS_TX_FRAG. However, the fragmentation threshold is a user-configurable stack parameter as per the standard. This patch effectively kill that option for the user although there may be RF conditions in which fragmentation can help. Having the user configure a fragmentation threshold of 2346 also disables fragmentation and allows mac80211 to use cached fastpath.

        /* fast-xmit doesn't handle fragmentation at all */
        if (local->hw.wiphy->frag_threshold != (u32)-1 &&
            !ieee80211_hw_check(&local->hw, SUPPORTS_TX_FRAG))
                goto out;

so internally at least it has to be -1, does 2346 really do that? remember, but it might well :-)

johannes

#16 lore raw

Re: [PATCH v2 05/10] rtlwifi: enable mac80211 fast-tx support

Quoted 12 lines · Johannes Berg
Quoted 10 lines · Arend van Spriel

When I saw this flying by I had the same feeling. This is clearly not how it was intended although you could interpret the comments of the .set_frag_threshold() callback and IEEE80211_HW_SUPPORTS_TX_FRAG. However, the fragmentation threshold is a user-configurable stack parameter as per the standard. This patch effectively kill that option for the user although there may be RF conditions in which fragmentation can help. Having the user configure a fragmentation threshold of 2346 also disables fragmentation and allows mac80211 to use cached fastpath.

Quoted 7 lines
         /* fast-xmit doesn't handle fragmentation at all */
         if (local->hw.wiphy->frag_threshold != (u32)-1 &&
             !ieee80211_hw_check(&local->hw, SUPPORTS_TX_FRAG))
                 goto out;

so internally at least it has to be -1, does 2346 really do that? remember, but it might well :-)

I am getting old. In my recollection the fragmentation threshold would be set to maximum MPDU size, which I believed to be 2346. Not sure if that still is true today. To be sure taken a look in the 2016 spec:

"""
dot11FragmentationThreshold OBJECT-TYPE
SYNTAX Unsigned32 (256..65535)
UNITS "octets"
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"This is a control variable.
It is written by an external management entity.
Changes take effect as soon as practical in the implementation. This attribute specifies the maximum size of an individually addressed MPDU beyond which the corresponding MSDU or MMPDU is fragmented, except when an MSDU is transmitted under an HT-immediate or HT-delayed block ack agreement, or when an MSDU is carried in an A-MSDU, or when an MSDU or MMPDU is carried in an A-MPDU that does not contain a VHT single MPDU. Fields added to the MPDU by security encapsulation are not counted against the limit specified by this attribute. An MSDU or MMPDU might be fragmented even if it is smaller."
DEFVAL { 65535 }
::= { dot11OperationEntry 5 }
"""

Anyway, the fact remains that we should leave it up to the user to control the value.

Regards,
Arend

#17 lore raw

Re: [PATCH v2 05/10] rtlwifi: enable mac80211 fast-tx support

Quoted 8 lines · Arend van Spriel

I am getting old. In my recollection the fragmentation threshold would be set to maximum MPDU size, which I believed to be 2346. Not sure if that still is true today. To be sure taken a look in the 2016 spec:

"""
dot11FragmentationThreshold OBJECT-TYPE
SYNTAX Unsigned32 (256..65535)

I think the larger sizes are for 60 GHz.

Quoted 2 lines

Anyway, the fact remains that we should leave it up to the user to control the value.

Indeed.

johannes

author maintainer
#18 lore raw

Re: [PATCH v2 05/10] rtlwifi: enable mac80211 fast-tx support

In reply to Johannes Berg

T24gVHVlLCAyMDE4LTAxLTE2IGF0IDIzOjI0ICswMTAwLCBKb2hhbm5lcyBCZXJnIHdyb3RlOg0K PiBPbiBUdWUsIDIwMTgtMDEtMTYgYXQgMjE6MTIgKzAxMDAsIEFyZW5kIHZhbiBTcHJpZWwgd3Jv dGU6DQo+ID4gDQo+ID4gDQo+ID4gV2hlbiBJIHNhdyB0aGlzIGZseWluZyBieSBJIGhhZCB0aGUg c2FtZSBmZWVsaW5nLiBUaGlzIGlzIGNsZWFybHkNCj4gPiBub3TCoA0KPiA+IGhvdyBpdCB3YXMg aW50ZW5kZWQgYWx0aG91Z2ggeW91IGNvdWxkIGludGVycHJldCB0aGUgY29tbWVudHMgb2YNCj4g PiB0aGXCoA0KPiA+IC5zZXRfZnJhZ190aHJlc2hvbGQoKSBjYWxsYmFjayBhbmQgSUVFRTgwMjEx X0hXX1NVUFBPUlRTX1RYX0ZSQUcuwqANCj4gPiBIb3dldmVyLCB0aGUgZnJhZ21lbnRhdGlvbiB0 aHJlc2hvbGQgaXMgYSB1c2VyLWNvbmZpZ3VyYWJsZSBzdGFja8KgDQo+ID4gcGFyYW1ldGVyIGFz IHBlciB0aGUgc3RhbmRhcmQuIFRoaXMgcGF0Y2ggZWZmZWN0aXZlbHkga2lsbCB0aGF0DQo+ID4g b3B0aW9uwqANCj4gPiBmb3IgdGhlIHVzZXIgYWx0aG91Z2ggdGhlcmUgbWF5IGJlIFJGIGNvbmRp dGlvbnMgaW4gd2hpY2gNCj4gPiBmcmFnbWVudGF0aW9uwqANCj4gPiBjYW4gaGVscC4gSGF2aW5n IHRoZSB1c2VyIGNvbmZpZ3VyZSBhIGZyYWdtZW50YXRpb24gdGhyZXNob2xkIG9mDQo+ID4gMjM0 NsKgDQo+ID4gYWxzbyBkaXNhYmxlcyBmcmFnbWVudGF0aW9uIGFuZCBhbGxvd3MgbWFjODAyMTEg dG8gdXNlIGNhY2hlZA0KPiA+IGZhc3RwYXRoLg0KPiA+IA0KPiDCoMKgwqDCoMKgwqDCoMKgLyog ZmFzdC14bWl0IGRvZXNuJ3QgaGFuZGxlIGZyYWdtZW50YXRpb24gYXQgYWxsICovDQo+IMKgwqDC oMKgwqDCoMKgwqBpZiAobG9jYWwtPmh3LndpcGh5LT5mcmFnX3RocmVzaG9sZCAhPSAodTMyKS0x ICYmDQo+IMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoCFpZWVlODAyMTFfaHdfY2hlY2soJmxvY2Fs LT5odywgU1VQUE9SVFNfVFhfRlJBRykpDQo+IMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDC oMKgZ290byBvdXQ7DQo+IA0KDQpUaGFuayB5b3UgZm9yIHRoaXMgcG9pbnQuIFRoaXMgY29tbWl0 IGhhcyBub3QgdG8gc2V0IFNVUFBPUlRTX1RYX0ZSQUcswqANCmJ1dCBvbmx5IHNldCBTVVBQT1JU X0ZBU1RfWE1JVC4gSSdsbCB0ZXN0IGFuZCBwcmVwYXJlIGZvciBuZXh0wqANCnN1Ym1pc3Npb24u DQoNClBLDQoNCg==

#19 lore raw

Re: [PATCH v2 05/10] rtlwifi: enable mac80211 fast-tx support

Quoted 10 lines · Pkshih
Quoted 6 lines
        /* fast-xmit doesn't handle fragmentation at all */
        if (local->hw.wiphy->frag_threshold != (u32)-1 &&
            !ieee80211_hw_check(&local->hw, SUPPORTS_TX_FRAG))
                goto out;

Thank you for this point. This commit has not to set SUPPORTS_TX_FRAG, but only set SUPPORT_FAST_XMIT. I'll test and prepare for next submission.

But the point is that you *shouldn't* set SUPPORTS_TX_FRAG, and then fast-xmit will only get used for non-fragmented setups, which realistically is all anyone cares about anyway.

johannes

author maintainer
#20 lore raw

Re: [PATCH v2 05/10] rtlwifi: enable mac80211 fast-tx support

T24gVGh1LCAyMDE4LTAxLTE4IGF0IDExOjA5ICswMTAwLCBKb2hhbm5lcyBCZXJnIHdyb3RlOg0K PiBPbiBUaHUsIDIwMTgtMDEtMTggYXQgMDk6MDUgKzAwMDAsIFBrc2hpaCB3cm90ZToNCj4gPiAN Cj4gPiANCj4gPiA+IA0KPiA+ID4gwqDCoMKgwqDCoMKgwqDCoC8qIGZhc3QteG1pdCBkb2Vzbid0 IGhhbmRsZSBmcmFnbWVudGF0aW9uIGF0IGFsbCAqLw0KPiA+ID4gwqDCoMKgwqDCoMKgwqDCoGlm IChsb2NhbC0+aHcud2lwaHktPmZyYWdfdGhyZXNob2xkICE9ICh1MzIpLTEgJiYNCj4gPiA+IMKg wqDCoMKgwqDCoMKgwqDCoMKgwqDCoCFpZWVlODAyMTFfaHdfY2hlY2soJmxvY2FsLT5odywgU1VQ UE9SVFNfVFhfRlJBRykpDQo+ID4gPiDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoGdv dG8gb3V0Ow0KPiA+ID4gDQo+ID4gVGhhbmsgeW91IGZvciB0aGlzIHBvaW50LiBUaGlzIGNvbW1p dCBoYXMgbm90IHRvIHNldCBTVVBQT1JUU19UWF9GUkFHLMKgDQo+ID4gYnV0IG9ubHkgc2V0IFNV UFBPUlRfRkFTVF9YTUlULiBJJ2xsIHRlc3QgYW5kIHByZXBhcmUgZm9yIG5leHTCoA0KPiA+IHN1 Ym1pc3Npb24uDQo+IEJ1dCB0aGUgcG9pbnQgaXMgdGhhdCB5b3UgKnNob3VsZG4ndCogc2V0IFNV UFBPUlRTX1RYX0ZSQUcsIGFuZCB0aGVuDQo+IGZhc3QteG1pdCB3aWxsIG9ubHkgZ2V0IHVzZWQg Zm9yIG5vbi1mcmFnbWVudGVkIHNldHVwcywgd2hpY2gNCj4gcmVhbGlzdGljYWxseSBpcyBhbGwg YW55b25lIGNhcmVzIGFib3V0IGFueXdheS4NCj4gDQoNCk15IGZhdWx0LiBTaW5jZSB0aGUgZ29h bCBvZiB0aGlzIGNvbW1pdCBpcyB0byBlbmFibGUgZmFzdC10eCwgSSBzaG91bGRuJ3QNCnNldMKg U1VQUE9SVFNfVFhfRlJBRyBhbmQgdGhlIG9wIHNldF9mcmFnX3RocmVzaG9sZC4NCg0KUEsNCg==

author maintainer
#21 lore raw

PATCH v2 6/10 rtlwifi: Support A-MSDU in A-MPDU capability

In reply to [email protected]

From: Steven Ting <[email protected]>

Due to the fact that A-MSDU deaggregation is done in software, we set this flag to support the A-MSDU in A-MPDU

---
 drivers/net/wireless/realtek/rtlwifi/base.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/realtek/rtlwifi/base.c +1 -0
index e902cd7adbfe..07b91bc9adf9 100644
@@ -397,6 +397,7 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
 	ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS);
 	ieee80211_hw_set(hw, SUPPORTS_TX_FRAG);
 	ieee80211_hw_set(hw, SUPPORT_FAST_XMIT);
+	ieee80211_hw_set(hw, SUPPORTS_AMSDU_IN_AMPDU);
 
 	/* swlps or hwlps has been set in diff chip in init_sw_vars */
 	if (rtlpriv->psc.swctrl_lps) {
Signature · 1 line
2.15.1
Acked-by on v2 6/10
#22 lore raw

Re: [PATCH v2 06/10] rtlwifi: Support A-MSDU in A-MPDU capability

Quoted 10 lines · On 01/11/2018 01:09 AM, [email protected] wrote:

From: Steven Ting <[email protected]>

Due to the fact that A-MSDU deaggregation is done in software, we set this flag to support the A-MSDU in A-MPDU

---
  drivers/net/wireless/realtek/rtlwifi/base.c | 1 +
  1 file changed, 1 insertion(+)
Quoted 14 lines
drivers/net/wireless/realtek/rtlwifi/base.c +1 -0
index e902cd7adbfe..07b91bc9adf9 100644
@@ -397,6 +397,7 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
  	ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS);
  	ieee80211_hw_set(hw, SUPPORTS_TX_FRAG);
  	ieee80211_hw_set(hw, SUPPORT_FAST_XMIT);
+	ieee80211_hw_set(hw, SUPPORTS_AMSDU_IN_AMPDU);
 
  	/* swlps or hwlps has been set in diff chip in init_sw_vars */
  	if (rtlpriv->psc.swctrl_lps) {
author maintainer
#23 lore raw

PATCH v2 7/10 rtlwifi: btcoex: Add power_on_setting routine

In reply to [email protected]

From: Ping-Ke Shih <[email protected]>

After mac power-on sequence, wifi will start to work so notify btcoex the event to configure registers especially related to antenna. This will not only help to assign antenna but also to yield better user experience.

---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h | 1 +
 drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c      | 6 ++++++
 drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h      | 1 +
 drivers/net/wireless/realtek/rtlwifi/wifi.h                   | 1 +
 4 files changed, 9 insertions(+)
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h +1 -0
index ea12b9d63a73..bc523af7ef88 100644
@@ -608,6 +608,7 @@ extern struct btc_coexist gl_bt_coexist;
 
 bool exhalbtc_initlize_variables(void);
 bool exhalbtc_bind_bt_coex_withadapter(void *adapter);
+void exhalbtc_power_on_setting(struct btc_coexist *btcoexist);
 void exhalbtc_init_hw_config(struct btc_coexist *btcoexist, bool wifi_only);
 void exhalbtc_init_coex_dm(struct btc_coexist *btcoexist);
 void exhalbtc_ips_notify(struct btc_coexist *btcoexist, u8 type);
drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c +6 -0
index 4d9e33078d4f..9e3623b0423c 100644
@@ -32,6 +32,7 @@
 static struct rtl_btc_ops rtl_btc_operation = {
 	.btc_init_variables = rtl_btc_init_variables,
 	.btc_init_hal_vars = rtl_btc_init_hal_vars,
+	.btc_power_on_setting = rtl_btc_power_on_setting,
 	.btc_init_hw_config = rtl_btc_init_hw_config,
 	.btc_ips_notify = rtl_btc_ips_notify,
 	.btc_lps_notify = rtl_btc_lps_notify,
@@ -116,6 +117,11 @@ void rtl_btc_init_hal_vars(struct rtl_priv *rtlpriv)
 	 */
 }
 
+void rtl_btc_power_on_setting(struct rtl_priv *rtlpriv)
+{
+	exhalbtc_power_on_setting(&gl_bt_coexist);
+}
+
 void rtl_btc_init_hw_config(struct rtl_priv *rtlpriv)
 {
 	u8 bt_exist;
drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h +1 -0
index 40f1ce8c8a06..9becfa59407d 100644
@@ -29,6 +29,7 @@
 
 void rtl_btc_init_variables(struct rtl_priv *rtlpriv);
 void rtl_btc_init_hal_vars(struct rtl_priv *rtlpriv);
+void rtl_btc_power_on_setting(struct rtl_priv *rtlpriv);
 void rtl_btc_init_hw_config(struct rtl_priv *rtlpriv);
 void rtl_btc_ips_notify(struct rtl_priv *rtlpriv, u8 type);
 void rtl_btc_lps_notify(struct rtl_priv *rtlpriv, u8 type);
drivers/net/wireless/realtek/rtlwifi/wifi.h +1 -0
index 941694060f48..b27dbe10b163 100644
@@ -2557,6 +2557,7 @@ struct bt_coexist_info {
 struct rtl_btc_ops {
 	void (*btc_init_variables) (struct rtl_priv *rtlpriv);
 	void (*btc_init_hal_vars) (struct rtl_priv *rtlpriv);
+	void (*btc_power_on_setting)(struct rtl_priv *rtlpriv);
 	void (*btc_init_hw_config) (struct rtl_priv *rtlpriv);
 	void (*btc_ips_notify) (struct rtl_priv *rtlpriv, u8 type);
 	void (*btc_lps_notify)(struct rtl_priv *rtlpriv, u8 type);
Signature · 1 line
2.15.1
#24 lore raw

Re: [PATCH v2 07/10] rtlwifi: btcoex: Add power_on_setting routine

Quoted 68 lines · On 01/11/2018 01:09 AM, [email protected] wrote:

From: Ping-Ke Shih <[email protected]>

After mac power-on sequence, wifi will start to work so notify btcoex the event to configure registers especially related to antenna. This will not only help to assign antenna but also to yield better user experience.

---
  drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h | 1 +
  drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c      | 6 ++++++
  drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h      | 1 +
  drivers/net/wireless/realtek/rtlwifi/wifi.h                   | 1 +
  4 files changed, 9 insertions(+)
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h +1 -0
index ea12b9d63a73..bc523af7ef88 100644
@@ -608,6 +608,7 @@ extern struct btc_coexist gl_bt_coexist;
 
  bool exhalbtc_initlize_variables(void);
  bool exhalbtc_bind_bt_coex_withadapter(void *adapter);
+void exhalbtc_power_on_setting(struct btc_coexist *btcoexist);
  void exhalbtc_init_hw_config(struct btc_coexist *btcoexist, bool wifi_only);
  void exhalbtc_init_coex_dm(struct btc_coexist *btcoexist);
  void exhalbtc_ips_notify(struct btc_coexist *btcoexist, u8 type);
drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c +6 -0
index 4d9e33078d4f..9e3623b0423c 100644
@@ -32,6 +32,7 @@
  static struct rtl_btc_ops rtl_btc_operation = {
  	.btc_init_variables = rtl_btc_init_variables,
  	.btc_init_hal_vars = rtl_btc_init_hal_vars,
+	.btc_power_on_setting = rtl_btc_power_on_setting,
  	.btc_init_hw_config = rtl_btc_init_hw_config,
  	.btc_ips_notify = rtl_btc_ips_notify,
  	.btc_lps_notify = rtl_btc_lps_notify,
@@ -116,6 +117,11 @@ void rtl_btc_init_hal_vars(struct rtl_priv *rtlpriv)
  	 */
  }
 
+void rtl_btc_power_on_setting(struct rtl_priv *rtlpriv)
+{
+	exhalbtc_power_on_setting(&gl_bt_coexist);
+}
+
  void rtl_btc_init_hw_config(struct rtl_priv *rtlpriv)
  {
  	u8 bt_exist;
drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h +1 -0
index 40f1ce8c8a06..9becfa59407d 100644
@@ -29,6 +29,7 @@
 
  void rtl_btc_init_variables(struct rtl_priv *rtlpriv);
  void rtl_btc_init_hal_vars(struct rtl_priv *rtlpriv);
+void rtl_btc_power_on_setting(struct rtl_priv *rtlpriv);
  void rtl_btc_init_hw_config(struct rtl_priv *rtlpriv);
  void rtl_btc_ips_notify(struct rtl_priv *rtlpriv, u8 type);
  void rtl_btc_lps_notify(struct rtl_priv *rtlpriv, u8 type);
drivers/net/wireless/realtek/rtlwifi/wifi.h +0 -0
index 941694060f48..b27dbe10b163 100644

drivers/net/wireless/realtek/rtlwifi/wifi.h struct bt_coexist_info { · line 2563

Quoted 7 lines
drivers/net/wireless/realtek/rtlwifi/wifi.h +1 -0
@@ -2557,6 +2557,7 @@ struct bt_coexist_info {
  struct rtl_btc_ops {
  	void (*btc_init_variables) (struct rtl_priv *rtlpriv);
  	void (*btc_init_hal_vars) (struct rtl_priv *rtlpriv);
+	void (*btc_power_on_setting)(struct rtl_priv *rtlpriv);
  	void (*btc_init_hw_config) (struct rtl_priv *rtlpriv);
  	void (*btc_ips_notify) (struct rtl_priv *rtlpriv, u8 type);
  	void (*btc_lps_notify)(struct rtl_priv *rtlpriv, u8 type);

I do not see any place in the code where rtl_btc_power_on_setting() is called, either directly or by callback. Did I miss it?

Larry

author maintainer
#25 lore raw

Re: [PATCH v2 07/10] rtlwifi: btcoex: Add power_on_setting routine

T24gTW9uLCAyMDE4LTAxLTE1IGF0IDEzOjE5IC0wNjAwLCBMYXJyeSBGaW5nZXIgd3JvdGU6DQo+ IE9uIDAxLzExLzIwMTggMDE6MDkgQU0sIHBrc2hpaEByZWFsdGVrLmNvbSB3cm90ZToNCj4gPiAN Cj4gPiBGcm9tOiBQaW5nLUtlIFNoaWggPHBrc2hpaEByZWFsdGVrLmNvbT4NCj4gPiANCj4gPiBB ZnRlciBtYWMgcG93ZXItb24gc2VxdWVuY2UsIHdpZmkgd2lsbCBzdGFydCB0byB3b3JrIHNvIG5v dGlmeQ0KPiA+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IChzdHJ1Y3QgcnRsX3ByaXYgKnJ0bHByaXYsIHU4DQo+ID4gdHlwZSk7 DQo+ID4gwqDCoAl2b2lkICgqYnRjX2xwc19ub3RpZnkpKHN0cnVjdCBydGxfcHJpdiAqcnRscHJp diwgdTgNCj4gPiB0eXBlKTsNCj4gPiANCj4gSSBkbyBub3Qgc2VlIGFueSBwbGFjZSBpbiB0aGUg Y29kZSB3aGVyZSBydGxfYnRjX3Bvd2VyX29uX3NldHRpbmcoKQ0KPiBpcyBjYWxsZWQswqANCj4g ZWl0aGVyIGRpcmVjdGx5IG9yIGJ5IGNhbGxiYWNrLiBEaWQgSSBtaXNzIGl0Pw0KPiANClRoaXMg d2lsbCBiZSBjYWxsZWQgYnkgODgyMmJlIGFuZCA4NzIzZGUgZHVyaW5nIGluaXRpYWxpemluZyBo YXJkd2FyZSwNCmFuZCBvcmlnaW5hbGx5IDg3MjNiZSB3aWxsIGFsc28gbmVlZCBpdCAobGl0dGxl IGFudF9zZWwgcmVsYXRlZCkgYnV0DQp5b3UgaGFkIGZpeGVkIGl0IGJ5IHRoZSBjb21taXRzwqA2 ZDYyMjY5MjgzNjkgYW5kwqBhMzNmY2JhNmVjMDEuIEknbGwNCmNoZWNrIHdoZXRoZXIgODcyM2Jl IGhhcyB0byBjYWxsIHRoaXMgb3Igbm90Lg0KDQpQSw0KDQo=

author maintainer
#26 lore raw

PATCH v2 8/10 rtlwifi: btcoex: Remove global variables from btcoex

In reply to [email protected]

From: Ping-Ke Shih <[email protected]>

Remove global variables, so btcoexist can support multiple instances simultaneously.

---
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c       |  79 ++++-----
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.h       |  21 +--
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.c   | 182 +++++++++++++++++----
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.h   |   3 +-
 drivers/net/wireless/realtek/rtlwifi/pci.c         |   5 +-
 drivers/net/wireless/realtek/rtlwifi/wifi.h        |   5 +-
 6 files changed, 217 insertions(+), 78 deletions(-)
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c +42 -37
index 5f3eda31187a..2be81fec789a 100644
@@ -25,14 +25,6 @@
 
 #include "halbt_precomp.h"
 
-/***********************************************
- *		Global variables
- ***********************************************/
-
-struct btc_coexist gl_bt_coexist;
-
-u32 btc_dbg_type[BTC_MSG_MAX];
-
 /***************************************************
  *		Debug related function
  ***************************************************/
@@ -971,9 +963,12 @@ bool halbtc_under_ips(struct btc_coexist *btcoexist)
 /*****************************************************************
  *         Extern functions called by other module
  *****************************************************************/
-bool exhalbtc_initlize_variables(void)
+bool exhalbtc_initlize_variables(struct rtl_priv *rtlpriv)
 {
-	struct btc_coexist *btcoexist = &gl_bt_coexist;
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return false;
 
 	halbtc_dbg_init();
 
@@ -1009,9 +1004,12 @@ bool exhalbtc_initlize_variables(void)
 
 bool exhalbtc_bind_bt_coex_withadapter(void *adapter)
 {
-	struct btc_coexist *btcoexist = &gl_bt_coexist;
 	struct rtl_priv *rtlpriv = adapter;
-	u8 ant_num = 2, chip_type;
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+	u8 ant_num = 2, chip_type, single_ant_path = 0;
+
+	if (!btcoexist)
+		return false;
 
 	if (btcoexist->binded)
 		return false;
@@ -1042,10 +1040,16 @@ bool exhalbtc_bind_bt_coex_withadapter(void *adapter)
 	btcoexist->bt_info.miracast_plus_bt = false;
 
 	chip_type = rtl_get_hwpg_bt_type(rtlpriv);
-	exhalbtc_set_chip_type(chip_type);
+	exhalbtc_set_chip_type(btcoexist, 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(btcoexist, 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)
@@ -1550,30 +1554,25 @@ void exhalbtc_stack_update_profile_info(void)
 {
 }
 
-void exhalbtc_update_min_bt_rssi(s8 bt_rssi)
+void exhalbtc_update_min_bt_rssi(struct btc_coexist *btcoexist, s8 bt_rssi)
 {
-	struct btc_coexist *btcoexist = &gl_bt_coexist;
-
 	if (!halbtc_is_bt_coexist_available(btcoexist))
 		return;
 
 	btcoexist->stack_info.min_bt_rssi = bt_rssi;
 }
 
-void exhalbtc_set_hci_version(u16 hci_version)
+void exhalbtc_set_hci_version(struct btc_coexist *btcoexist, u16 hci_version)
 {
-	struct btc_coexist *btcoexist = &gl_bt_coexist;
-
 	if (!halbtc_is_bt_coexist_available(btcoexist))
 		return;
 
 	btcoexist->stack_info.hci_version = hci_version;
 }
 
-void exhalbtc_set_bt_patch_version(u16 bt_hci_version, u16 bt_patch_version)
+void exhalbtc_set_bt_patch_version(struct btc_coexist *btcoexist,
+				   u16 bt_hci_version, u16 bt_patch_version)
 {
-	struct btc_coexist *btcoexist = &gl_bt_coexist;
-
 	if (!halbtc_is_bt_coexist_available(btcoexist))
 		return;
 
@@ -1581,7 +1580,7 @@ void exhalbtc_set_bt_patch_version(u16 bt_hci_version, u16 bt_patch_version)
 	btcoexist->bt_info.bt_hci_ver = bt_hci_version;
 }
 
-void exhalbtc_set_chip_type(u8 chip_type)
+void exhalbtc_set_chip_type(struct btc_coexist *btcoexist, u8 chip_type)
 {
 	switch (chip_type) {
 	default:
@@ -1589,48 +1588,54 @@ void exhalbtc_set_chip_type(u8 chip_type)
 	case BT_ISSC_3WIRE:
 	case BT_ACCEL:
 	case BT_RTL8756:
-		gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_UNDEF;
+		btcoexist->board_info.bt_chip_type = BTC_CHIP_UNDEF;
 		break;
 	case BT_CSR_BC4:
-		gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC4;
+		btcoexist->board_info.bt_chip_type = BTC_CHIP_CSR_BC4;
 		break;
 	case BT_CSR_BC8:
-		gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC8;
+		btcoexist->board_info.bt_chip_type = BTC_CHIP_CSR_BC8;
 		break;
 	case BT_RTL8723A:
-		gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8723A;
+		btcoexist->board_info.bt_chip_type = BTC_CHIP_RTL8723A;
 		break;
 	case BT_RTL8821A:
-		gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8821;
+		btcoexist->board_info.bt_chip_type = BTC_CHIP_RTL8821;
 		break;
 	case BT_RTL8723B:
-		gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8723B;
+		btcoexist->board_info.bt_chip_type = BTC_CHIP_RTL8723B;
 		break;
 	}
 }
 
 void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num)
 {
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return;
+
 	if (BT_COEX_ANT_TYPE_PG == type) {
-		gl_bt_coexist.board_info.pg_ant_num = ant_num;
-		gl_bt_coexist.board_info.btdm_ant_num = ant_num;
+		btcoexist->board_info.pg_ant_num = ant_num;
+		btcoexist->board_info.btdm_ant_num = ant_num;
 	} else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
-		gl_bt_coexist.board_info.btdm_ant_num = ant_num;
+		btcoexist->board_info.btdm_ant_num = ant_num;
 	} else if (type == BT_COEX_ANT_TYPE_DETECTED) {
-		gl_bt_coexist.board_info.btdm_ant_num = ant_num;
+		btcoexist->board_info.btdm_ant_num = ant_num;
 		if (rtlpriv->cfg->mod_params->ant_sel == 1)
-			gl_bt_coexist.board_info.btdm_ant_pos =
+			btcoexist->board_info.btdm_ant_pos =
 				BTC_ANTENNA_AT_AUX_PORT;
 		else
-			gl_bt_coexist.board_info.btdm_ant_pos =
+			btcoexist->board_info.btdm_ant_pos =
 				BTC_ANTENNA_AT_MAIN_PORT;
 	}
 }
 
 /* Currently used by 8723b only, S0 or S1 */
-void exhalbtc_set_single_ant_path(u8 single_ant_path)
+void exhalbtc_set_single_ant_path(struct btc_coexist *btcoexist,
+				  u8 single_ant_path)
 {
-	gl_bt_coexist.board_info.single_ant_path = single_ant_path;
+	btcoexist->board_info.single_ant_path = single_ant_path;
 }
 
 void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist,
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h +11 -10
index bc523af7ef88..5a7816ff6877 100644
@@ -103,8 +103,6 @@ enum btc_msg_type {
 	BTC_MSG_MAX
 };
 
-extern u32 btc_dbg_type[];
-
 /* following is for BTC_MSG_INTERFACE */
 #define		INTF_INIT				BIT0
 #define		INTF_NOTIFY				BIT2
@@ -604,9 +602,10 @@ struct btc_coexist {
 
 bool halbtc_is_wifi_uplink(struct rtl_priv *adapter);
 
-extern struct btc_coexist gl_bt_coexist;
+#define rtl_btc_coexist(rtlpriv)				\
+	((struct btc_coexist *)((rtlpriv)->btcoexist.btc_context))
 
-bool exhalbtc_initlize_variables(void);
+bool exhalbtc_initlize_variables(struct rtl_priv *rtlpriv);
 bool exhalbtc_bind_bt_coex_withadapter(void *adapter);
 void exhalbtc_power_on_setting(struct btc_coexist *btcoexist);
 void exhalbtc_init_hw_config(struct btc_coexist *btcoexist, bool wifi_only);
@@ -628,11 +627,12 @@ void exhalbtc_periodical(struct btc_coexist *btcoexist);
 void exhalbtc_dbg_control(struct btc_coexist *btcoexist, u8 code, u8 len,
 			  u8 *data);
 void exhalbtc_stack_update_profile_info(void);
-void exhalbtc_set_hci_version(u16 hci_version);
-void exhalbtc_set_bt_patch_version(u16 bt_hci_version, u16 bt_patch_version);
-void exhalbtc_update_min_bt_rssi(s8 bt_rssi);
-void exhalbtc_set_bt_exist(bool bt_exist);
-void exhalbtc_set_chip_type(u8 chip_type);
+void exhalbtc_set_hci_version(struct btc_coexist *btcoexist, u16 hci_version);
+void exhalbtc_set_bt_patch_version(struct btc_coexist *btcoexist,
+				   u16 bt_hci_version, u16 bt_patch_version);
+void exhalbtc_update_min_bt_rssi(struct btc_coexist *btcoexist, s8 bt_rssi);
+void exhalbtc_set_bt_exist(struct btc_coexist *btcoexist, bool bt_exist);
+void exhalbtc_set_chip_type(struct btc_coexist *btcoexist, u8 chip_type);
 void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num);
 void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist,
 				   struct seq_file *m);
@@ -640,6 +640,7 @@ 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);
+void exhalbtc_set_single_ant_path(struct btc_coexist *btcoexist,
+				  u8 single_ant_path);
 
 #endif
drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c +154 -28

318 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h +2 -1
index 9becfa59407d..8c5098266039 100644
@@ -28,6 +28,7 @@
 #include "halbt_precomp.h"
 
 void rtl_btc_init_variables(struct rtl_priv *rtlpriv);
+void rtl_btc_deinit_variables(struct rtl_priv *rtlpriv);
 void rtl_btc_init_hal_vars(struct rtl_priv *rtlpriv);
 void rtl_btc_power_on_setting(struct rtl_priv *rtlpriv);
 void rtl_btc_init_hw_config(struct rtl_priv *rtlpriv);
@@ -38,7 +39,7 @@ void rtl_btc_connect_notify(struct rtl_priv *rtlpriv, u8 action);
 void rtl_btc_mediastatus_notify(struct rtl_priv *rtlpriv,
 				enum rt_media_status mstatus);
 void rtl_btc_periodical(struct rtl_priv *rtlpriv);
-void rtl_btc_halt_notify(void);
+void rtl_btc_halt_notify(struct rtl_priv *rtlpriv);
 void rtl_btc_btinfo_notify(struct rtl_priv *rtlpriv, u8 *tmpbuf, u8 length);
 void rtl_btc_btmpinfo_notify(struct rtl_priv *rtlpriv, u8 *tmp_buf, u8 length);
 bool rtl_btc_is_limited_dig(struct rtl_priv *rtlpriv);
drivers/net/wireless/realtek/rtlwifi/pci.c +4 -1
index c1833a501be4..aa1d3ae4937f 100644
@@ -1841,7 +1841,10 @@ static void rtl_pci_stop(struct ieee80211_hw *hw)
 	u8 rf_timeout = 0;
 
 	if (rtlpriv->cfg->ops->get_btc_status())
-		rtlpriv->btcoexist.btc_ops->btc_halt_notify();
+		rtlpriv->btcoexist.btc_ops->btc_halt_notify(rtlpriv);
+
+	if (rtlpriv->btcoexist.btc_ops)
+		rtlpriv->btcoexist.btc_ops->btc_deinit_variables(rtlpriv);
 
 	/*should be before disable interrupt&adapter
 	 *and will do it immediately.
drivers/net/wireless/realtek/rtlwifi/wifi.h +4 -1
index b27dbe10b163..531c86df54d4 100644
@@ -2500,6 +2500,8 @@ struct rtl_btc_info {
 struct bt_coexist_info {
 	struct rtl_btc_ops *btc_ops;
 	struct rtl_btc_info btc_info;
+	/* btc context */
+	void *btc_context;
 	/* EEPROM BT info. */
 	u8 eeprom_bt_coexist;
 	u8 eeprom_bt_type;
@@ -2556,6 +2558,7 @@ struct bt_coexist_info {
 
 struct rtl_btc_ops {
 	void (*btc_init_variables) (struct rtl_priv *rtlpriv);
+	void (*btc_deinit_variables)(struct rtl_priv *rtlpriv);
 	void (*btc_init_hal_vars) (struct rtl_priv *rtlpriv);
 	void (*btc_power_on_setting)(struct rtl_priv *rtlpriv);
 	void (*btc_init_hw_config) (struct rtl_priv *rtlpriv);
@@ -2566,7 +2569,7 @@ struct rtl_btc_ops {
 	void (*btc_mediastatus_notify) (struct rtl_priv *rtlpriv,
 					enum rt_media_status mstatus);
 	void (*btc_periodical) (struct rtl_priv *rtlpriv);
-	void (*btc_halt_notify) (void);
+	void (*btc_halt_notify)(struct rtl_priv *rtlpriv);
 	void (*btc_btinfo_notify) (struct rtl_priv *rtlpriv,
 				   u8 *tmp_buf, u8 length);
 	void (*btc_btmpinfo_notify)(struct rtl_priv *rtlpriv,
Signature · 1 line
2.15.1
Acked-by on v2 8/10
#27 lore raw

Re: [PATCH v2 08/10] rtlwifi: btcoex: Remove global variables from btcoex

Quoted 6 lines · On 01/11/2018 01:09 AM, [email protected] wrote:

From: Ping-Ke Shih <[email protected]>

Remove global variables, so btcoexist can support multiple instances simultaneously.

Quoted 8 lines
---
  .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c       |  79 ++++-----
  .../realtek/rtlwifi/btcoexist/halbtcoutsrc.h       |  21 +--
  .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.c   | 182 +++++++++++++++++----
  .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.h   |   3 +-
  drivers/net/wireless/realtek/rtlwifi/pci.c         |   5 +-
  drivers/net/wireless/realtek/rtlwifi/wifi.h        |   5 +-
  6 files changed, 217 insertions(+), 78 deletions(-)

I am very happy to see this change. Although a given box is unlikely to have more than one PCI wireless device, it is certainly possible for one of the PCI drivers and rtl8192cu to both be needed.

Quoted 630 lines
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c +42 -37
index 5f3eda31187a..2be81fec789a 100644
@@ -25,14 +25,6 @@
 
  #include "halbt_precomp.h"
 
-/***********************************************
- *		Global variables
- ***********************************************/
-
-struct btc_coexist gl_bt_coexist;
-
-u32 btc_dbg_type[BTC_MSG_MAX];
-
  /***************************************************
   *		Debug related function
   ***************************************************/
@@ -971,9 +963,12 @@ bool halbtc_under_ips(struct btc_coexist *btcoexist)
  /*****************************************************************
   *         Extern functions called by other module
   *****************************************************************/
-bool exhalbtc_initlize_variables(void)
+bool exhalbtc_initlize_variables(struct rtl_priv *rtlpriv)
  {
-	struct btc_coexist *btcoexist = &gl_bt_coexist;
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return false;
 
  	halbtc_dbg_init();
 
@@ -1009,9 +1004,12 @@ bool exhalbtc_initlize_variables(void)
 
  bool exhalbtc_bind_bt_coex_withadapter(void *adapter)
  {
-	struct btc_coexist *btcoexist = &gl_bt_coexist;
  	struct rtl_priv *rtlpriv = adapter;
-	u8 ant_num = 2, chip_type;
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+	u8 ant_num = 2, chip_type, single_ant_path = 0;
+
+	if (!btcoexist)
+		return false;
 
  	if (btcoexist->binded)
  		return false;
@@ -1042,10 +1040,16 @@ bool exhalbtc_bind_bt_coex_withadapter(void *adapter)
  	btcoexist->bt_info.miracast_plus_bt = false;
 
  	chip_type = rtl_get_hwpg_bt_type(rtlpriv);
-	exhalbtc_set_chip_type(chip_type);
+	exhalbtc_set_chip_type(btcoexist, 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(btcoexist, 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)
@@ -1550,30 +1554,25 @@ void exhalbtc_stack_update_profile_info(void)
  {
  }
 
-void exhalbtc_update_min_bt_rssi(s8 bt_rssi)
+void exhalbtc_update_min_bt_rssi(struct btc_coexist *btcoexist, s8 bt_rssi)
  {
-	struct btc_coexist *btcoexist = &gl_bt_coexist;
-
  	if (!halbtc_is_bt_coexist_available(btcoexist))
  		return;
 
  	btcoexist->stack_info.min_bt_rssi = bt_rssi;
  }
 
-void exhalbtc_set_hci_version(u16 hci_version)
+void exhalbtc_set_hci_version(struct btc_coexist *btcoexist, u16 hci_version)
  {
-	struct btc_coexist *btcoexist = &gl_bt_coexist;
-
  	if (!halbtc_is_bt_coexist_available(btcoexist))
  		return;
 
  	btcoexist->stack_info.hci_version = hci_version;
  }
 
-void exhalbtc_set_bt_patch_version(u16 bt_hci_version, u16 bt_patch_version)
+void exhalbtc_set_bt_patch_version(struct btc_coexist *btcoexist,
+				   u16 bt_hci_version, u16 bt_patch_version)
  {
-	struct btc_coexist *btcoexist = &gl_bt_coexist;
-
  	if (!halbtc_is_bt_coexist_available(btcoexist))
  		return;
 
@@ -1581,7 +1580,7 @@ void exhalbtc_set_bt_patch_version(u16 bt_hci_version, u16 bt_patch_version)
  	btcoexist->bt_info.bt_hci_ver = bt_hci_version;
  }
 
-void exhalbtc_set_chip_type(u8 chip_type)
+void exhalbtc_set_chip_type(struct btc_coexist *btcoexist, u8 chip_type)
  {
  	switch (chip_type) {
  	default:
@@ -1589,48 +1588,54 @@ void exhalbtc_set_chip_type(u8 chip_type)
  	case BT_ISSC_3WIRE:
  	case BT_ACCEL:
  	case BT_RTL8756:
-		gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_UNDEF;
+		btcoexist->board_info.bt_chip_type = BTC_CHIP_UNDEF;
  		break;
  	case BT_CSR_BC4:
-		gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC4;
+		btcoexist->board_info.bt_chip_type = BTC_CHIP_CSR_BC4;
  		break;
  	case BT_CSR_BC8:
-		gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC8;
+		btcoexist->board_info.bt_chip_type = BTC_CHIP_CSR_BC8;
  		break;
  	case BT_RTL8723A:
-		gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8723A;
+		btcoexist->board_info.bt_chip_type = BTC_CHIP_RTL8723A;
  		break;
  	case BT_RTL8821A:
-		gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8821;
+		btcoexist->board_info.bt_chip_type = BTC_CHIP_RTL8821;
  		break;
  	case BT_RTL8723B:
-		gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8723B;
+		btcoexist->board_info.bt_chip_type = BTC_CHIP_RTL8723B;
  		break;
  	}
  }
 
  void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num)
  {
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return;
+
  	if (BT_COEX_ANT_TYPE_PG == type) {
-		gl_bt_coexist.board_info.pg_ant_num = ant_num;
-		gl_bt_coexist.board_info.btdm_ant_num = ant_num;
+		btcoexist->board_info.pg_ant_num = ant_num;
+		btcoexist->board_info.btdm_ant_num = ant_num;
  	} else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
-		gl_bt_coexist.board_info.btdm_ant_num = ant_num;
+		btcoexist->board_info.btdm_ant_num = ant_num;
  	} else if (type == BT_COEX_ANT_TYPE_DETECTED) {
-		gl_bt_coexist.board_info.btdm_ant_num = ant_num;
+		btcoexist->board_info.btdm_ant_num = ant_num;
  		if (rtlpriv->cfg->mod_params->ant_sel == 1)
-			gl_bt_coexist.board_info.btdm_ant_pos =
+			btcoexist->board_info.btdm_ant_pos =
  				BTC_ANTENNA_AT_AUX_PORT;
  		else
-			gl_bt_coexist.board_info.btdm_ant_pos =
+			btcoexist->board_info.btdm_ant_pos =
  				BTC_ANTENNA_AT_MAIN_PORT;
  	}
  }
 
  /* Currently used by 8723b only, S0 or S1 */
-void exhalbtc_set_single_ant_path(u8 single_ant_path)
+void exhalbtc_set_single_ant_path(struct btc_coexist *btcoexist,
+				  u8 single_ant_path)
  {
-	gl_bt_coexist.board_info.single_ant_path = single_ant_path;
+	btcoexist->board_info.single_ant_path = single_ant_path;
  }
 
  void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist,
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h +11 -10
index bc523af7ef88..5a7816ff6877 100644
@@ -103,8 +103,6 @@ enum btc_msg_type {
  	BTC_MSG_MAX
  };
 
-extern u32 btc_dbg_type[];
-
  /* following is for BTC_MSG_INTERFACE */
  #define		INTF_INIT				BIT0
  #define		INTF_NOTIFY				BIT2
@@ -604,9 +602,10 @@ struct btc_coexist {
 
  bool halbtc_is_wifi_uplink(struct rtl_priv *adapter);
 
-extern struct btc_coexist gl_bt_coexist;
+#define rtl_btc_coexist(rtlpriv)				\
+	((struct btc_coexist *)((rtlpriv)->btcoexist.btc_context))
 
-bool exhalbtc_initlize_variables(void);
+bool exhalbtc_initlize_variables(struct rtl_priv *rtlpriv);
  bool exhalbtc_bind_bt_coex_withadapter(void *adapter);
  void exhalbtc_power_on_setting(struct btc_coexist *btcoexist);
  void exhalbtc_init_hw_config(struct btc_coexist *btcoexist, bool wifi_only);
@@ -628,11 +627,12 @@ void exhalbtc_periodical(struct btc_coexist *btcoexist);
  void exhalbtc_dbg_control(struct btc_coexist *btcoexist, u8 code, u8 len,
  			  u8 *data);
  void exhalbtc_stack_update_profile_info(void);
-void exhalbtc_set_hci_version(u16 hci_version);
-void exhalbtc_set_bt_patch_version(u16 bt_hci_version, u16 bt_patch_version);
-void exhalbtc_update_min_bt_rssi(s8 bt_rssi);
-void exhalbtc_set_bt_exist(bool bt_exist);
-void exhalbtc_set_chip_type(u8 chip_type);
+void exhalbtc_set_hci_version(struct btc_coexist *btcoexist, u16 hci_version);
+void exhalbtc_set_bt_patch_version(struct btc_coexist *btcoexist,
+				   u16 bt_hci_version, u16 bt_patch_version);
+void exhalbtc_update_min_bt_rssi(struct btc_coexist *btcoexist, s8 bt_rssi);
+void exhalbtc_set_bt_exist(struct btc_coexist *btcoexist, bool bt_exist);
+void exhalbtc_set_chip_type(struct btc_coexist *btcoexist, u8 chip_type);
  void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num);
  void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist,
  				   struct seq_file *m);
@@ -640,6 +640,7 @@ 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);
+void exhalbtc_set_single_ant_path(struct btc_coexist *btcoexist,
+				  u8 single_ant_path);
 
  #endif
drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c +154 -28
index 9e3623b0423c..ddbef65c3740 100644
@@ -31,6 +31,7 @@
 
  static struct rtl_btc_ops rtl_btc_operation = {
  	.btc_init_variables = rtl_btc_init_variables,
+	.btc_deinit_variables = rtl_btc_deinit_variables,
  	.btc_init_hal_vars = rtl_btc_init_hal_vars,
  	.btc_power_on_setting = rtl_btc_power_on_setting,
  	.btc_init_hw_config = rtl_btc_init_hw_config,
@@ -58,58 +59,116 @@ static struct rtl_btc_ops rtl_btc_operation = {
 
  void rtl_btc_display_bt_coex_info(struct rtl_priv *rtlpriv, struct seq_file *m)
  {
-	exhalbtc_display_bt_coex_info(&gl_bt_coexist, m);
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist) {
+		seq_puts(m, "btc_coexist context is NULL!\n");
+		return;
+	}
+
+	exhalbtc_display_bt_coex_info(btcoexist, m);
  }
 
  void rtl_btc_record_pwr_mode(struct rtl_priv *rtlpriv, u8 *buf, u8 len)
  {
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
  	u8 safe_len;
 
-	safe_len = sizeof(gl_bt_coexist.pwr_mode_val);
+	if (!btcoexist)
+		return;
+
+	safe_len = sizeof(btcoexist->pwr_mode_val);
 
  	if (safe_len > len)
  		safe_len = len;
 
-	memcpy(gl_bt_coexist.pwr_mode_val, buf, safe_len);
+	memcpy(btcoexist->pwr_mode_val, buf, safe_len);
  }
 
  u8 rtl_btc_get_lps_val(struct rtl_priv *rtlpriv)
  {
-	return gl_bt_coexist.bt_info.lps_val;
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return 0;
+
+	return btcoexist->bt_info.lps_val;
  }
 
  u8 rtl_btc_get_rpwm_val(struct rtl_priv *rtlpriv)
  {
-	return gl_bt_coexist.bt_info.rpwm_val;
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return 0;
+
+	return btcoexist->bt_info.rpwm_val;
  }
 
  bool rtl_btc_is_bt_ctrl_lps(struct rtl_priv *rtlpriv)
  {
-	return gl_bt_coexist.bt_info.bt_ctrl_lps;
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return false;
+
+	return btcoexist->bt_info.bt_ctrl_lps;
  }
 
  bool rtl_btc_is_bt_lps_on(struct rtl_priv *rtlpriv)
  {
-	return gl_bt_coexist.bt_info.bt_lps_on;
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return false;
+
+	return btcoexist->bt_info.bt_lps_on;
  }
 
  void rtl_btc_get_ampdu_cfg(struct rtl_priv *rtlpriv, u8 *reject_agg,
  			   u8 *ctrl_agg_size, u8 *agg_size)
  {
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist) {
+		*reject_agg = false;
+		*ctrl_agg_size = false;
+		return;
+	}
+
  	if (reject_agg)
-		*reject_agg = gl_bt_coexist.bt_info.reject_agg_pkt;
+		*reject_agg = btcoexist->bt_info.reject_agg_pkt;
  	if (ctrl_agg_size)
-		*ctrl_agg_size = gl_bt_coexist.bt_info.bt_ctrl_agg_buf_size;
+		*ctrl_agg_size = btcoexist->bt_info.bt_ctrl_agg_buf_size;
  	if (agg_size)
-		*agg_size = gl_bt_coexist.bt_info.agg_buf_size;
+		*agg_size = btcoexist->bt_info.agg_buf_size;
+}
+
+static void rtl_btc_alloc_variable(struct rtl_priv *rtlpriv, bool wifi_only)
+{
+	rtlpriv->btcoexist.btc_context =
+			kzalloc(sizeof(struct btc_coexist), GFP_KERNEL);
+}
+
+static void rtl_btc_free_variable(struct rtl_priv *rtlpriv)
+{
+	kfree(rtlpriv->btcoexist.btc_context);
+	rtlpriv->btcoexist.btc_context = NULL;
  }
 
  void rtl_btc_init_variables(struct rtl_priv *rtlpriv)
  {
-	exhalbtc_initlize_variables();
+	rtl_btc_alloc_variable(rtlpriv, false);
+
+	exhalbtc_initlize_variables(rtlpriv);
  	exhalbtc_bind_bt_coex_withadapter(rtlpriv);
  }
 
+void rtl_btc_deinit_variables(struct rtl_priv *rtlpriv)
+{
+	rtl_btc_free_variable(rtlpriv);
+}
+
  void rtl_btc_init_hal_vars(struct rtl_priv *rtlpriv)
  {
  	/* move ant_num, bt_type and single_ant_path to
@@ -119,71 +178,123 @@ void rtl_btc_init_hal_vars(struct rtl_priv *rtlpriv)
 
  void rtl_btc_power_on_setting(struct rtl_priv *rtlpriv)
  {
-	exhalbtc_power_on_setting(&gl_bt_coexist);
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return;
+
+	exhalbtc_power_on_setting(btcoexist);
  }
 
  void rtl_btc_init_hw_config(struct rtl_priv *rtlpriv)
  {
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
  	u8 bt_exist;
 
  	bt_exist = rtl_get_hwpg_bt_exist(rtlpriv);
  	RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
  		"%s, bt_exist is %d\n", __func__, bt_exist);
 
-	exhalbtc_init_hw_config(&gl_bt_coexist, !bt_exist);
-	exhalbtc_init_coex_dm(&gl_bt_coexist);
+	if (!btcoexist)
+		return;
+
+	exhalbtc_init_hw_config(btcoexist, !bt_exist);
+	exhalbtc_init_coex_dm(btcoexist);
  }
 
  void rtl_btc_ips_notify(struct rtl_priv *rtlpriv, u8 type)
  {
-	exhalbtc_ips_notify(&gl_bt_coexist, type);
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return;
+
+	exhalbtc_ips_notify(btcoexist, type);
  }
 
  void rtl_btc_lps_notify(struct rtl_priv *rtlpriv, u8 type)
  {
-	exhalbtc_lps_notify(&gl_bt_coexist, type);
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return;
+
+	exhalbtc_lps_notify(btcoexist, type);
  }
 
  void rtl_btc_scan_notify(struct rtl_priv *rtlpriv, u8 scantype)
  {
-	exhalbtc_scan_notify(&gl_bt_coexist, scantype);
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return;
+
+	exhalbtc_scan_notify(btcoexist, scantype);
  }
 
  void rtl_btc_connect_notify(struct rtl_priv *rtlpriv, u8 action)
  {
-	exhalbtc_connect_notify(&gl_bt_coexist, action);
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return;
+
+	exhalbtc_connect_notify(btcoexist, action);
  }
 
  void rtl_btc_mediastatus_notify(struct rtl_priv *rtlpriv,
  				enum rt_media_status mstatus)
  {
-	exhalbtc_mediastatus_notify(&gl_bt_coexist, mstatus);
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return;
+
+	exhalbtc_mediastatus_notify(btcoexist, mstatus);
  }
 
  void rtl_btc_periodical(struct rtl_priv *rtlpriv)
  {
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return;
+
  	/*rtl_bt_dm_monitor();*/
-	exhalbtc_periodical(&gl_bt_coexist);
+	exhalbtc_periodical(btcoexist);
  }
 
-void rtl_btc_halt_notify(void)
+void rtl_btc_halt_notify(struct rtl_priv *rtlpriv)
  {
-	struct btc_coexist *btcoexist = &gl_bt_coexist;
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return;
 
  	exhalbtc_halt_notify(btcoexist);
  }
 
  void rtl_btc_btinfo_notify(struct rtl_priv *rtlpriv, u8 *tmp_buf, u8 length)
  {
-	exhalbtc_bt_info_notify(&gl_bt_coexist, tmp_buf, length);
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return;
+
+	exhalbtc_bt_info_notify(btcoexist, tmp_buf, length);
  }
 
  void rtl_btc_btmpinfo_notify(struct rtl_priv *rtlpriv, u8 *tmp_buf, u8 length)
  {
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
  	u8 extid, seq, len;
  	u16 bt_real_fw_ver;
  	u8 bt_fw_ver;
 
+	if (!btcoexist)
+		return;
+
  	if ((length < 4) || (!tmp_buf))
  		return;
 
@@ -200,14 +311,19 @@ void rtl_btc_btmpinfo_notify(struct rtl_priv *rtlpriv, u8 *tmp_buf, u8 length)
  		bt_real_fw_ver = tmp_buf[3] | (tmp_buf[4] << 8);
  		bt_fw_ver = tmp_buf[5];
 
-		gl_bt_coexist.bt_info.bt_real_fw_ver = bt_real_fw_ver;
-		gl_bt_coexist.bt_info.bt_fw_ver = bt_fw_ver;
+		btcoexist->bt_info.bt_real_fw_ver = bt_real_fw_ver;
+		btcoexist->bt_info.bt_fw_ver = bt_fw_ver;
  	}
  }
 
  bool rtl_btc_is_limited_dig(struct rtl_priv *rtlpriv)
  {
-	return gl_bt_coexist.bt_info.limited_dig;
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return false;
+
+	return btcoexist->bt_info.limited_dig;
  }
 
  bool rtl_btc_is_disable_edca_turbo(struct rtl_priv *rtlpriv)
@@ -239,8 +355,13 @@ bool rtl_btc_is_disable_edca_turbo(struct rtl_priv *rtlpriv)
 
  bool rtl_btc_is_bt_disabled(struct rtl_priv *rtlpriv)
  {
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return true;
+
  	/* It seems 'bt_disabled' is never be initialized or set. */
-	if (gl_bt_coexist.bt_info.bt_disabled)
+	if (btcoexist->bt_info.bt_disabled)
  		return true;
  	else
  		return false;
@@ -248,7 +369,12 @@ bool rtl_btc_is_bt_disabled(struct rtl_priv *rtlpriv)
 
  void rtl_btc_special_packet_notify(struct rtl_priv *rtlpriv, u8 pkt_type)
  {
-	return exhalbtc_special_packet_notify(&gl_bt_coexist, pkt_type);
+	struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
+
+	if (!btcoexist)
+		return;
+
+	return exhalbtc_special_packet_notify(btcoexist, pkt_type);
  }
 
  struct rtl_btc_ops *rtl_btc_get_ops_pointer(void)
drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h +2 -1
index 9becfa59407d..8c5098266039 100644
@@ -28,6 +28,7 @@
  #include "halbt_precomp.h"
 
  void rtl_btc_init_variables(struct rtl_priv *rtlpriv);
+void rtl_btc_deinit_variables(struct rtl_priv *rtlpriv);
  void rtl_btc_init_hal_vars(struct rtl_priv *rtlpriv);
  void rtl_btc_power_on_setting(struct rtl_priv *rtlpriv);
  void rtl_btc_init_hw_config(struct rtl_priv *rtlpriv);
@@ -38,7 +39,7 @@ void rtl_btc_connect_notify(struct rtl_priv *rtlpriv, u8 action);
  void rtl_btc_mediastatus_notify(struct rtl_priv *rtlpriv,
  				enum rt_media_status mstatus);
  void rtl_btc_periodical(struct rtl_priv *rtlpriv);
-void rtl_btc_halt_notify(void);
+void rtl_btc_halt_notify(struct rtl_priv *rtlpriv);
  void rtl_btc_btinfo_notify(struct rtl_priv *rtlpriv, u8 *tmpbuf, u8 length);
  void rtl_btc_btmpinfo_notify(struct rtl_priv *rtlpriv, u8 *tmp_buf, u8 length);
  bool rtl_btc_is_limited_dig(struct rtl_priv *rtlpriv);
drivers/net/wireless/realtek/rtlwifi/pci.c +4 -1
index c1833a501be4..aa1d3ae4937f 100644
@@ -1841,7 +1841,10 @@ static void rtl_pci_stop(struct ieee80211_hw *hw)
  	u8 rf_timeout = 0;
 
  	if (rtlpriv->cfg->ops->get_btc_status())
-		rtlpriv->btcoexist.btc_ops->btc_halt_notify();
+		rtlpriv->btcoexist.btc_ops->btc_halt_notify(rtlpriv);
+
+	if (rtlpriv->btcoexist.btc_ops)
+		rtlpriv->btcoexist.btc_ops->btc_deinit_variables(rtlpriv);
 
  	/*should be before disable interrupt&adapter
  	 *and will do it immediately.
drivers/net/wireless/realtek/rtlwifi/wifi.h +4 -1
index b27dbe10b163..531c86df54d4 100644
@@ -2500,6 +2500,8 @@ struct rtl_btc_info {
  struct bt_coexist_info {
  	struct rtl_btc_ops *btc_ops;
  	struct rtl_btc_info btc_info;
+	/* btc context */
+	void *btc_context;
  	/* EEPROM BT info. */
  	u8 eeprom_bt_coexist;
  	u8 eeprom_bt_type;
@@ -2556,6 +2558,7 @@ struct bt_coexist_info {
 
  struct rtl_btc_ops {
  	void (*btc_init_variables) (struct rtl_priv *rtlpriv);
+	void (*btc_deinit_variables)(struct rtl_priv *rtlpriv);
  	void (*btc_init_hal_vars) (struct rtl_priv *rtlpriv);
  	void (*btc_power_on_setting)(struct rtl_priv *rtlpriv);
  	void (*btc_init_hw_config) (struct rtl_priv *rtlpriv);
@@ -2566,7 +2569,7 @@ struct rtl_btc_ops {
  	void (*btc_mediastatus_notify) (struct rtl_priv *rtlpriv,
  					enum rt_media_status mstatus);
  	void (*btc_periodical) (struct rtl_priv *rtlpriv);
-	void (*btc_halt_notify) (void);
+	void (*btc_halt_notify)(struct rtl_priv *rtlpriv);
  	void (*btc_btinfo_notify) (struct rtl_priv *rtlpriv,
  				   u8 *tmp_buf, u8 length);
  	void (*btc_btmpinfo_notify)(struct rtl_priv *rtlpriv,
author maintainer
#28 lore raw

PATCH v2 9/10 rtlwifi: btcoex: Add common function for qeurying BT information

In reply to [email protected]

From: Ping-Ke Shih <[email protected]>

This commit implement the common function to sort old features, and add more new features that are get_supported_feature, get_supported_version, get_ant_det_val, ble_scan_type, ble_scan_para, bt_dev_info, forbidden_slot_val, afh_map and etc.

---
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c       | 309 ++++++++++++++++++---
 .../realtek/rtlwifi/btcoexist/halbtcoutsrc.h       |  70 +++++
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.c   |  48 +++-
 3 files changed, 394 insertions(+), 33 deletions(-)
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c +277 -32
index 2be81fec789a..30d940cf3abf 100644
@@ -207,6 +207,102 @@ u8 rtl_get_hwpg_package_type(struct rtl_priv *rtlpriv)
 	return rtlhal->package_type;
 }
 
+static
+bool halbtc_is_hw_mailbox_exist(struct btc_coexist *btcoexist)
+{
+	if (IS_HARDWARE_TYPE_8812(btcoexist->adapter))
+		return false;
+	else
+		return true;
+}
+
+static
+bool halbtc_send_bt_mp_operation(struct btc_coexist *btcoexist, u8 op_code,
+				 u8 *cmd, u32 len, unsigned long wait_ms)
+{
+	struct rtl_priv *rtlpriv;
+	const u8 oper_ver = 0;
+	u8 req_num;
+
+	if (!halbtc_is_hw_mailbox_exist(btcoexist))
+		return false;
+
+	if (wait_ms)	/* before h2c to avoid race condition */
+		reinit_completion(&btcoexist->bt_mp_comp);
+
+	rtlpriv = btcoexist->adapter;
+
+	/* fill req_num by op_code, and rtl_btc_btmpinfo_notify() use it
+	 * to know message type
+	 */
+	switch (op_code) {
+	case BT_OP_GET_BT_VERSION:
+		req_num = BT_SEQ_GET_BT_VERSION;
+		break;
+	case BT_OP_GET_AFH_MAP_L:
+		req_num = BT_SEQ_GET_AFH_MAP_L;
+		break;
+	case BT_OP_GET_AFH_MAP_M:
+		req_num = BT_SEQ_GET_AFH_MAP_M;
+		break;
+	case BT_OP_GET_AFH_MAP_H:
+		req_num = BT_SEQ_GET_AFH_MAP_H;
+		break;
+	case BT_OP_GET_BT_COEX_SUPPORTED_FEATURE:
+		req_num = BT_SEQ_GET_BT_COEX_SUPPORTED_FEATURE;
+		break;
+	case BT_OP_GET_BT_COEX_SUPPORTED_VERSION:
+		req_num = BT_SEQ_GET_BT_COEX_SUPPORTED_VERSION;
+		break;
+	case BT_OP_GET_BT_ANT_DET_VAL:
+		req_num = BT_SEQ_GET_BT_ANT_DET_VAL;
+		break;
+	case BT_OP_GET_BT_BLE_SCAN_PARA:
+		req_num = BT_SEQ_GET_BT_BLE_SCAN_PARA;
+		break;
+	case BT_OP_GET_BT_BLE_SCAN_TYPE:
+		req_num = BT_SEQ_GET_BT_BLE_SCAN_TYPE;
+		break;
+	case BT_OP_GET_BT_DEVICE_INFO:
+		req_num = BT_SEQ_GET_BT_DEVICE_INFO;
+		break;
+	case BT_OP_GET_BT_FORBIDDEN_SLOT_VAL:
+		req_num = BT_SEQ_GET_BT_FORB_SLOT_VAL;
+		break;
+	case BT_OP_WRITE_REG_ADDR:
+	case BT_OP_WRITE_REG_VALUE:
+	case BT_OP_READ_REG:
+	default:
+		req_num = BT_SEQ_DONT_CARE;
+		break;
+	}
+
+	cmd[0] |= (oper_ver & 0x0f);		/* Set OperVer */
+	cmd[0] |= ((req_num << 4) & 0xf0);	/* Set ReqNum */
+	cmd[1] = op_code;
+	rtlpriv->cfg->ops->fill_h2c_cmd(rtlpriv->mac80211.hw, 0x67, len, cmd);
+
+	/* wait? */
+	if (!wait_ms)
+		return true;
+
+	RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
+		 "btmpinfo wait req_num=%d wait=%ld\n", req_num, wait_ms);
+
+	if (in_interrupt())
+		return false;
+
+	if (wait_for_completion_timeout(&btcoexist->bt_mp_comp,
+					msecs_to_jiffies(wait_ms)) == 0) {
+		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_DMESG,
+			 "btmpinfo wait (req_num=%d) timeout\n", req_num);
+
+		return false;	/* timeout */
+	}
+
+	return true;
+}
+
 static void halbtc_leave_lps(struct btc_coexist *btcoexist)
 {
 	struct rtl_priv *rtlpriv;
@@ -334,24 +430,79 @@ static void halbtc_aggregation_check(struct btc_coexist *btcoexist)
 
 static u32 halbtc_get_bt_patch_version(struct btc_coexist *btcoexist)
 {
-	struct rtl_priv *rtlpriv = btcoexist->adapter;
 	u8 cmd_buffer[4] = {0};
-	u8 oper_ver = 0;
-	u8 req_num = 0x0E;
 
 	if (btcoexist->bt_info.bt_real_fw_ver)
 		goto label_done;
 
-	cmd_buffer[0] |= (oper_ver & 0x0f);	/* Set OperVer */
-	cmd_buffer[0] |= ((req_num << 4) & 0xf0);	/* Set ReqNum */
-	cmd_buffer[1] = 0; /* BT_OP_GET_BT_VERSION = 0 */
-	rtlpriv->cfg->ops->fill_h2c_cmd(rtlpriv->mac80211.hw, 0x67, 4,
-					&cmd_buffer[0]);
+	/* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
+	halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_BT_VERSION,
+				    cmd_buffer, 4, 200);
 
 label_done:
 	return btcoexist->bt_info.bt_real_fw_ver;
 }
 
+static u32 halbtc_get_bt_coex_supported_feature(void *btc_context)
+{
+	struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
+	u8 cmd_buffer[4] = {0};
+
+	if (btcoexist->bt_info.bt_supported_feature)
+		goto label_done;
+
+	/* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
+	halbtc_send_bt_mp_operation(btcoexist,
+				    BT_OP_GET_BT_COEX_SUPPORTED_FEATURE,
+				    cmd_buffer, 4, 200);
+
+label_done:
+	return btcoexist->bt_info.bt_supported_feature;
+}
+
+static u32 halbtc_get_bt_coex_supported_version(void *btc_context)
+{
+	struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
+	u8 cmd_buffer[4] = {0};
+
+	if (btcoexist->bt_info.bt_supported_version)
+		goto label_done;
+
+	/* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
+	halbtc_send_bt_mp_operation(btcoexist,
+				    BT_OP_GET_BT_COEX_SUPPORTED_VERSION,
+				    cmd_buffer, 4, 200);
+
+label_done:
+	return btcoexist->bt_info.bt_supported_version;
+}
+
+static u32 halbtc_get_bt_device_info(void *btc_context)
+{
+	struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
+	u8 cmd_buffer[4] = {0};
+
+	/* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
+	halbtc_send_bt_mp_operation(btcoexist,
+				    BT_OP_GET_BT_DEVICE_INFO,
+				    cmd_buffer, 4, 200);
+
+	return btcoexist->bt_info.bt_device_info;
+}
+
+static u32 halbtc_get_bt_forbidden_slot_val(void *btc_context)
+{
+	struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
+	u8 cmd_buffer[4] = {0};
+
+	/* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
+	halbtc_send_bt_mp_operation(btcoexist,
+				    BT_OP_GET_BT_FORBIDDEN_SLOT_VAL,
+				    cmd_buffer, 4, 200);
+
+	return btcoexist->bt_info.bt_forb_slot_val;
+}
+
 u32 halbtc_get_wifi_link_status(struct btc_coexist *btcoexist)
 {
 	/* return value:
@@ -513,6 +664,18 @@ static bool halbtc_get(void *void_btcoexist, u8 get_type, void *out_buf)
 	case BTC_GET_U4_VENDOR:
 		*u32_tmp = BTC_VENDOR_OTHER;
 		break;
+	case BTC_GET_U4_SUPPORTED_VERSION:
+		*u32_tmp = halbtc_get_bt_coex_supported_version(btcoexist);
+		break;
+	case BTC_GET_U4_SUPPORTED_FEATURE:
+		*u32_tmp = halbtc_get_bt_coex_supported_feature(btcoexist);
+		break;
+	case BTC_GET_U4_BT_DEVICE_INFO:
+		*u32_tmp = halbtc_get_bt_device_info(btcoexist);
+		break;
+	case BTC_GET_U4_BT_FORBIDDEN_SLOT_VAL:
+		*u32_tmp = halbtc_get_bt_forbidden_slot_val(btcoexist);
+		break;
 	case BTC_GET_U1_WIFI_DOT11_CHNL:
 		*u8_tmp = rtlphy->current_channel;
 		break;
@@ -894,32 +1057,20 @@ static void halbtc_fill_h2c_cmd(void *bt_context, u8 element_id,
 void halbtc_set_bt_reg(void *btc_context, u8 reg_type, u32 offset, u32 set_val)
 {
 	struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
-	struct rtl_priv *rtlpriv = btcoexist->adapter;
 	u8 cmd_buffer1[4] = {0};
 	u8 cmd_buffer2[4] = {0};
-	u8 *addr_to_set = (u8 *)&offset;
-	u8 *value_to_set = (u8 *)&set_val;
-	u8 oper_ver = 0;
-	u8 req_num = 0;
 
-	if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
-		cmd_buffer1[0] |= (oper_ver & 0x0f);	/* Set OperVer */
-		cmd_buffer1[0] |= ((req_num << 4) & 0xf0);	/* Set ReqNum */
-		cmd_buffer1[1] = 0x0d;	/* OpCode: BT_LO_OP_WRITE_REG_VALUE */
-		cmd_buffer1[2] = value_to_set[0];	/* Set WriteRegValue */
-		rtlpriv->cfg->ops->fill_h2c_cmd(rtlpriv->mac80211.hw, 0x67, 4,
-						&cmd_buffer1[0]);
-
-		msleep(200);
-		req_num++;
-
-		cmd_buffer2[0] |= (oper_ver & 0x0f);	/* Set OperVer */
-		cmd_buffer2[0] |= ((req_num << 4) & 0xf0);	/* Set ReqNum */
-		cmd_buffer2[1] = 0x0c;	/* OpCode: BT_LO_OP_WRITE_REG_ADDR */
-		cmd_buffer2[3] = addr_to_set[0];	/* Set WriteRegAddr */
-		rtlpriv->cfg->ops->fill_h2c_cmd(rtlpriv->mac80211.hw, 0x67, 4,
-						&cmd_buffer2[0]);
-	}
+	/* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
+	*((__le16 *)&cmd_buffer1[2]) = cpu_to_le16((u16)set_val);
+	if (!halbtc_send_bt_mp_operation(btcoexist, BT_OP_WRITE_REG_VALUE,
+					 cmd_buffer1, 4, 200))
+		return;
+
+	/* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
+	cmd_buffer2[2] = reg_type;
+	*((u8 *)&cmd_buffer2[3]) = (u8)offset;
+	halbtc_send_bt_mp_operation(btcoexist, BT_OP_WRITE_REG_ADDR,
+				    cmd_buffer2, 4, 200);
 }
 
 static void halbtc_display_dbg_msg(void *bt_context, u8 disp_type,
@@ -960,6 +1111,86 @@ bool halbtc_under_ips(struct btc_coexist *btcoexist)
 	return false;
 }
 
+static u8 halbtc_get_ant_det_val_from_bt(void *btc_context)
+{
+	struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
+	u8 cmd_buffer[4] = {0};
+
+	/* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
+	halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_BT_ANT_DET_VAL,
+				    cmd_buffer, 4, 200);
+
+	/* need wait completion to return correct value */
+
+	return btcoexist->bt_info.bt_ant_det_val;
+}
+
+static u8 halbtc_get_ble_scan_type_from_bt(void *btc_context)
+{
+	struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
+	u8 cmd_buffer[4] = {0};
+
+	/* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
+	halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_BT_BLE_SCAN_TYPE,
+				    cmd_buffer, 4, 200);
+
+	/* need wait completion to return correct value */
+
+	return btcoexist->bt_info.bt_ble_scan_type;
+}
+
+static u32 halbtc_get_ble_scan_para_from_bt(void *btc_context, u8 scan_type)
+{
+	struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
+	u8 cmd_buffer[4] = {0};
+
+	/* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
+	halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_BT_BLE_SCAN_PARA,
+				    cmd_buffer, 4, 200);
+
+	/* need wait completion to return correct value */
+
+	return btcoexist->bt_info.bt_ble_scan_para;
+}
+
+static bool halbtc_get_bt_afh_map_from_bt(void *btc_context, u8 map_type,
+					  u8 *afh_map)
+{
+	struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
+	u8 cmd_buffer[2] = {0};
+	bool ret;
+	u32 *afh_map_l = (u32 *)afh_map;
+	u32 *afh_map_m = (u32 *)(afh_map + 4);
+	u16 *afh_map_h = (u16 *)(afh_map + 8);
+
+	/* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
+	ret = halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_AFH_MAP_L,
+					  cmd_buffer, 2, 200);
+	if (!ret)
+		goto exit;
+
+	*afh_map_l = btcoexist->bt_info.afh_map_l;
+
+	/* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
+	ret = halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_AFH_MAP_M,
+					  cmd_buffer, 2, 200);
+	if (!ret)
+		goto exit;
+
+	*afh_map_m = btcoexist->bt_info.afh_map_m;
+
+	/* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
+	ret = halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_AFH_MAP_H,
+					  cmd_buffer, 2, 200);
+	if (!ret)
+		goto exit;
+
+	*afh_map_h = btcoexist->bt_info.afh_map_h;
+
+exit:
+	return ret;
+}
+
 /*****************************************************************
  *         Extern functions called by other module
  *****************************************************************/
@@ -994,11 +1225,25 @@ bool exhalbtc_initlize_variables(struct rtl_priv *rtlpriv)
 	btcoexist->btc_set = halbtc_set;
 	btcoexist->btc_set_bt_reg = halbtc_set_bt_reg;
 
-
 	btcoexist->bt_info.bt_ctrl_buf_size = false;
 	btcoexist->bt_info.agg_buf_size = 5;
 
 	btcoexist->bt_info.increase_scan_dev_num = false;
+
+	btcoexist->btc_get_bt_coex_supported_feature =
+					halbtc_get_bt_coex_supported_feature;
+	btcoexist->btc_get_bt_coex_supported_version =
+					halbtc_get_bt_coex_supported_version;
+	btcoexist->btc_get_ant_det_val_from_bt = halbtc_get_ant_det_val_from_bt;
+	btcoexist->btc_get_ble_scan_type_from_bt =
+					halbtc_get_ble_scan_type_from_bt;
+	btcoexist->btc_get_ble_scan_para_from_bt =
+					halbtc_get_ble_scan_para_from_bt;
+	btcoexist->btc_get_bt_afh_map_from_bt =
+					halbtc_get_bt_afh_map_from_bt;
+
+	init_completion(&btcoexist->bt_mp_comp);
+
 	return true;
 }
 
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h +70 -0

106 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c +47 -1

68 lines not on this page · raw message

Signature · 1 line
2.15.1
Acked-by on v2 9/10
#29 lore raw

Re: [PATCH v2 09/10] rtlwifi: btcoex: Add common function for qeurying BT information

Quoted 19 lines · On 01/11/2018 01:09 AM, [email protected] wrote:

From: Ping-Ke Shih <[email protected]>

This commit implement the common function to sort old features, and add more new features that are get_supported_feature, get_supported_version, get_ant_det_val, ble_scan_type, ble_scan_para, bt_dev_info, forbidden_slot_val, afh_map and etc.

---
  .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c       | 309 ++++++++++++++++++---
  .../realtek/rtlwifi/btcoexist/halbtcoutsrc.h       |  70 +++++
  .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.c   |  48 +++-
  3 files changed, 394 insertions(+), 33 deletions(-)
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c +0 -0
index 2be81fec789a..30d940cf3abf 100644

drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c u8 rtl_get_hwpg_package_type(struct rtl_priv *rtlpriv) · line 216

Quoted 10 lines
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c +7 -0
@@ -207,6 +207,102 @@ u8 rtl_get_hwpg_package_type(struct rtl_priv *rtlpriv)
  	return rtlhal->package_type;
  }
 
+static
+bool halbtc_is_hw_mailbox_exist(struct btc_coexist *btcoexist)
+{
+	if (IS_HARDWARE_TYPE_8812(btcoexist->adapter))
+		return false;
+	else
+		return true;

Once you have returned false for 8812, you do not need the 'else'. Use a simple ' return true;'. As this is the only objection in this patch, I will let it pass. Some user with a suitable tool will change it.

drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c u8 rtl_get_hwpg_package_type(struct rtl_priv *rtlpriv) · line 221

Quoted 5 lines
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c +5 -0
+}
+
+static
+bool halbtc_send_bt_mp_operation(struct btc_coexist *btcoexist, u8 op_code,
+				 u8 *cmd, u32 len, unsigned long wait_ms)

--snip--

Quoted 23 lines
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h +7 -0
index 5a7816ff6877..cbbf5e5a9c9b 100644
@@ -278,6 +278,8 @@ enum btc_get_type {
  	BTC_GET_U4_VENDOR,
  	BTC_GET_U4_SUPPORTED_VERSION,
  	BTC_GET_U4_SUPPORTED_FEATURE,
+	BTC_GET_U4_BT_DEVICE_INFO,
+	BTC_GET_U4_BT_FORBIDDEN_SLOT_VAL,
  	BTC_GET_U4_WIFI_IQK_TOTAL,
  	BTC_GET_U4_WIFI_IQK_OK,
  	BTC_GET_U4_WIFI_IQK_FAIL,
@@ -459,6 +461,19 @@ typedef	bool (*bfp_btc_get)(void *btcoexist, u8 get_type, void *out_buf);
 
  typedef	bool (*bfp_btc_set)(void *btcoexist, u8 set_type, void *in_buf);
 
+typedef u32 (*bfp_btc_get_bt_coex_supported_feature)(void *btcoexist);
+
+typedef u32 (*bfp_btc_get_bt_coex_supported_version)(void *btcoexist);
+
+typedef u8 (*bfp_btc_get_ant_det_val_from_bt)(void *btcoexist);

drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h typedef bool (*bfp_btc_get)(void *btcoexist, u8 get_type, void *out_buf); · line 478

Quoted 10 lines
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h +8 -0
+
+typedef u8 (*bfp_btc_get_ble_scan_type_from_bt)(void *btcoexist);
+
+typedef u32 (*bfp_btc_get_ble_scan_para_from_bt)(void *btcoexist, u8 scan_type);
+
+typedef bool (*bfp_btc_get_bt_afh_map_from_bt)(void *btcoexist, u8 map_type,
+					       u8 *afh_map);
+
  typedef void (*bfp_btc_set_bt_reg)(void *btc_context, u8 reg_type, u32 offset,
  				   u32 value);

I would prefer that you not add additional typedef statements, but I will let it pass.

author maintainer
#30 lore raw

Re: [PATCH v2 09/10] rtlwifi: btcoex: Add common function for qeurying BT information

T24gTW9uLCAyMDE4LTAxLTE1IGF0IDEzOjE1IC0wNjAwLCBMYXJyeSBGaW5nZXIgd3JvdGU6DQo+ IE9uIDAxLzExLzIwMTggMDE6MDkgQU0sIHBrc2hpaEByZWFsdGVrLmNvbSB3cm90ZToNCj4gPiAN Cj4gPiBGcm9tOiBQaW5nLUtlIFNoaWggPHBrc2hpaEByZWFsdGVrLmNvbT4NCj4gPiANCj4gPiBU aGlzIGNvbW1pdCBpbXBsZW1lbnQgdGhlIGNvbW1vbiBmdW5jdGlvbiB0byBzb3J0IG9sZCBmZWF0 dXJlcywgYW5kDQo+ID4gYWRkDQo+ID4gbW9yZSBuZXcgZmVhdHVyZXMgdGhhdCBhcmUgZ2V0X3N1 cHBvcnRlZF9mZWF0dXJlLA0KPiA+IGdldF9zdXBwb3J0ZWRfdmVyc2lvbiwNCj4gPiBnZXRfYW50 X2RldF92YWwsIGJsZV9zY2FuX3R5cGUsIGJsZV9zY2FuX3BhcmEsIGJ0X2Rldl9pbmZvLA0KPiA+ IGZvcmJpZGRlbl9zbG90X3ZhbCwgYWZoX21hcCBhbmQgZXRjLg0KPiA+IA0KPiA+IFNpZ25lZC1v ZmYtYnk6IFBpbmctS2UgU2hpaCA8cGtzaGloQHJlYWx0ZWsuY29tPg0KPiA+IC0tLQ0KPiA+IMKg IC4uLi9yZWFsdGVrL3J0bHdpZmkvYnRjb2V4aXN0L2hhbGJ0Y291dHNyYy5jwqDCoMKgwqDCoMKg wqB8IDMwOQ0KPiA+ICsrKysrKysrKysrKysrKysrKy0tLQ0KPiA+IMKgIC4uLi9yZWFsdGVr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x3 ZmluZ2VyLm5ldD4NCj4gDQo+IC0tLS0tLVBsZWFzZSBjb25zaWRlciB0aGUgZW52aXJvbm1lbnQg YmVmb3JlIHByaW50aW5nIHRoaXMgZS1tYWlsLg==

#31 lore raw

Re: [PATCH v2 09/10] rtlwifi: btcoex: Add common function for qeurying BT information

In reply to Larry Finger
Quoted 9 lines · Larry Finger
Quoted 8 lines · On 01/11/2018 01:09 AM, [email protected] wrote:

From: Ping-Ke Shih <[email protected]>

This commit implement the common function to sort old features, and add more new features that are get_supported_feature, get_supported_version, get_ant_det_val, ble_scan_type, ble_scan_para, bt_dev_info, forbidden_slot_val, afh_map and etc.

[...]

Quoted 14 lines
Quoted 14 lines
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h +9 -0
@@ -459,6 +461,19 @@ typedef	bool (*bfp_btc_get)(void *btcoexist, u8 get_type, void *out_buf);
    typedef	bool (*bfp_btc_set)(void *btcoexist, u8 set_type, void
 *in_buf);
  +typedef u32 (*bfp_btc_get_bt_coex_supported_feature)(void
 *btcoexist);
+
+typedef u32 (*bfp_btc_get_bt_coex_supported_version)(void *btcoexist);
+
+typedef u8 (*bfp_btc_get_ant_det_val_from_bt)(void *btcoexist);
+
+typedef u8 (*bfp_btc_get_ble_scan_type_from_bt)(void *btcoexist);
+
+typedef u32 (*bfp_btc_get_ble_scan_para_from_bt)(void *btcoexist, u8 scan_type);
+
Quoted 8 lines

drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h typedef bool (*bfp_btc_get)(void *btcoexist, u8 get_type, void *out_buf); · line 478

Quoted 5 lines
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h +3 -0
+typedef bool (*bfp_btc_get_bt_afh_map_from_bt)(void *btcoexist, u8 map_type,
+					       u8 *afh_map);
+
  typedef void (*bfp_btc_set_bt_reg)(void *btc_context, u8 reg_type, u32 offset,
  				   u32 value);

I would prefer that you not add additional typedef statements, but I will let it pass.

But I can't really take that :( Typedefs are not really liked in upstream and just makes code harder to read.

Signature · 1 line
Kalle Valo
#32 lore raw

Re: [PATCH v2 09/10] rtlwifi: btcoex: Add common function for qeurying BT information

Quoted 37 lines · Kalle Valo
Quoted 9 lines · Larry Finger
Quoted 8 lines · On 01/11/2018 01:09 AM, [email protected] wrote:

From: Ping-Ke Shih <[email protected]>

This commit implement the common function to sort old features, and add more new features that are get_supported_feature, get_supported_version, get_ant_det_val, ble_scan_type, ble_scan_para, bt_dev_info, forbidden_slot_val, afh_map and etc.

[...]

Quoted 14 lines
Quoted 14 lines
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h +9 -0
@@ -459,6 +461,19 @@ typedef	bool (*bfp_btc_get)(void *btcoexist, u8 get_type, void *out_buf);
     typedef	bool (*bfp_btc_set)(void *btcoexist, u8 set_type, void
 *in_buf);
   +typedef u32 (*bfp_btc_get_bt_coex_supported_feature)(void
 *btcoexist);
+
+typedef u32 (*bfp_btc_get_bt_coex_supported_version)(void *btcoexist);
+
+typedef u8 (*bfp_btc_get_ant_det_val_from_bt)(void *btcoexist);
+
+typedef u8 (*bfp_btc_get_ble_scan_type_from_bt)(void *btcoexist);
+
+typedef u32 (*bfp_btc_get_ble_scan_para_from_bt)(void *btcoexist, u8 scan_type);
+
Quoted 8 lines

drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h typedef bool (*bfp_btc_get)(void *btcoexist, u8 get_type, void *out_buf); · line 478

Quoted 5 lines
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h +3 -0
+typedef bool (*bfp_btc_get_bt_afh_map_from_bt)(void *btcoexist, u8 map_type,
+					       u8 *afh_map);
+
   typedef void (*bfp_btc_set_bt_reg)(void *btc_context, u8 reg_type, u32 offset,
   				   u32 value);

I would prefer that you not add additional typedef statements, but I will let it pass.

Quoted 2 lines

But I can't really take that :( Typedefs are not really liked in upstream and just makes code harder to read.

Kalle,

Overnight, I had prepared a patch to remove the typedefs. I have now respun it to handle only the old ones. As the merge of this new patch needs to be coordinated with PK's patches, I have sent it to him so that he can include it with v3 of his series.

Larry

author maintainer
#33 lore raw

PATCH v2 10/10 rtlwifi: btcoex: add rfe_type parameter to btcoex

In reply to [email protected]

From: Ping-Ke Shih <[email protected]>

btcoex configure antenna by rfe_type that is RF type programmed in efuse.

---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c | 10 ++++++++++
 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h |  2 ++
 2 files changed, 12 insertions(+)
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c +10 -0
index 30d940cf3abf..7b7099cbb1c7 100644
@@ -207,6 +207,14 @@ u8 rtl_get_hwpg_package_type(struct rtl_priv *rtlpriv)
 	return rtlhal->package_type;
 }
 
+static
+u8 rtl_get_hwpg_rfe_type(struct rtl_priv *rtlpriv)
+{
+	struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
+
+	return rtlhal->rfe_type;
+}
+
 static
 bool halbtc_is_hw_mailbox_exist(struct btc_coexist *btcoexist)
 {
@@ -1309,6 +1317,8 @@ bool exhalbtc_bind_bt_coex_withadapter(void *adapter)
 		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
 			 "[BTCoex], Package Type = Non-TFBGA\n");
 
+	btcoexist->board_info.rfe_type = rtl_get_hwpg_rfe_type(rtlpriv);
+
 	return true;
 }
 
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h +2 -0
index cbbf5e5a9c9b..ee7bbbd87eae 100644
@@ -151,6 +151,8 @@ struct btc_board_info {
 	u8 btdm_ant_pos;
 	u8 single_ant_path; /* current used for 8723b only, 1=>s0,  0=>s1 */
 	bool tfbga_package;
+
+	u8 rfe_type;
 };
 
 enum btc_dbg_opcode {
Signature · 1 line
2.15.1
Acked-by on v2 10/10
#34 lore raw

Re: [PATCH v2 10/10] rtlwifi: btcoex: add rfe_type parameter to btcoex

Quoted 43 lines · On 01/11/2018 01:09 AM, [email protected] wrote:

From: Ping-Ke Shih <[email protected]>

btcoex configure antenna by rfe_type that is RF type programmed in efuse.

---
  drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c | 10 ++++++++++
  drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h |  2 ++
  2 files changed, 12 insertions(+)
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c +10 -0
index 30d940cf3abf..7b7099cbb1c7 100644
@@ -207,6 +207,14 @@ u8 rtl_get_hwpg_package_type(struct rtl_priv *rtlpriv)
  	return rtlhal->package_type;
  }
 
+static
+u8 rtl_get_hwpg_rfe_type(struct rtl_priv *rtlpriv)
+{
+	struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
+
+	return rtlhal->rfe_type;
+}
+
  static
  bool halbtc_is_hw_mailbox_exist(struct btc_coexist *btcoexist)
  {
@@ -1309,6 +1317,8 @@ bool exhalbtc_bind_bt_coex_withadapter(void *adapter)
  		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
  			 "[BTCoex], Package Type = Non-TFBGA\n");
 
+	btcoexist->board_info.rfe_type = rtl_get_hwpg_rfe_type(rtlpriv);
+
  	return true;
  }
 
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h +0 -0
index cbbf5e5a9c9b..ee7bbbd87eae 100644

drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h struct btc_board_info { · line 158

Quoted 8 lines
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h +2 -0
@@ -151,6 +151,8 @@ struct btc_board_info {
  	u8 btdm_ant_pos;
  	u8 single_ant_path; /* current used for 8723b only, 1=>s0,  0=>s1 */
  	bool tfbga_package;
+
+	u8 rfe_type;
  };
 
  enum btc_dbg_opcode {

Of course, until HP starts encoding efuse correctly, the special ant_sel code is still needed.

Larry