Skip to contentSkip to conversation

unify drv_bss_info_changed between mt76x0u and mt76x2u

PATCH Applied Lorenzo Bianconi 2 participants 6 messages Nov 6, 2018 – Nov 13, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover unify drv_bss_info_changed between mt76x0u and mt76x2u

Perform channel calibration after each channel switch and not only after connection establishment.
Enable MCU_CAL_TX_SHAPING phy calibration.
Moreover remove remove beacon offset configuration since the driver supports just client mode

Lorenzo Bianconi (4):
mt76x2u: phy: add TX_SHAPING calibration
mt76x2u: phy: run phy_channel_calibrate after channel switch
mt76x2u: main: use mt76x02_bss_info_changed utility routine
mt76x2u: init: remove mt76x2u_init_beacon_offsets routine

 .../wireless/mediatek/mt76/mt76x2/mt76x2u.h   |  1 -
 .../wireless/mediatek/mt76/mt76x2/usb_init.c  | 10 -------
 .../wireless/mediatek/mt76/mt76x2/usb_main.c  | 28 ++-----------------
 .../wireless/mediatek/mt76/mt76x2/usb_phy.c   | 19 +++++++++++--
 4 files changed, 19 insertions(+), 39 deletions(-)
Signature · 1 line
2.17.2
#1 lore raw

PATCH 1/4 mt76x2u: phy: add TX_SHAPING calibration

Add MCU_CAL_TX_SHAPING calibration in mt76x2u_phy_channel_calibrate routine since now mt76x2 and mt76x2u driver run the same firmware

---
 drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c +1 -0
index 8011c261c658..24e292e895b6 100644
@@ -35,6 +35,7 @@ void mt76x2u_phy_channel_calibrate(struct mt76x02_dev *dev)
 	mt76x02_mcu_calibrate(dev, MCU_CAL_TXIQ, is_5ghz, false);
 	mt76x02_mcu_calibrate(dev, MCU_CAL_RXIQC_FI, is_5ghz, false);
 	mt76x02_mcu_calibrate(dev, MCU_CAL_TEMP_SENSOR, 0, false);
+	mt76x02_mcu_calibrate(dev, MCU_CAL_TX_SHAPING, 0, false);
 
 	mt76x2u_mac_resume(dev);
 }
Signature · 1 line
2.17.2
#2 lore raw

PATCH 2/4 mt76x2u: phy: run phy_channel_calibrate after channel switch

In reply to Lorenzo Bianconi

Perform channel calibration after each channel switch and not only after connection establishment since NetworkManager perform multiple frequency scanning if RSSI in lower a given threshold

---
 .../wireless/mediatek/mt76/mt76x2/mt76x2u.h    |  1 -
 .../wireless/mediatek/mt76/mt76x2/usb_main.c   |  5 -----
 .../wireless/mediatek/mt76/mt76x2/usb_phy.c    | 18 +++++++++++++++---
 3 files changed, 15 insertions(+), 9 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2u.h +0 -1
index 833974de5c80..0b0075411b34 100644
@@ -43,7 +43,6 @@ int mt76x2u_mac_stop(struct mt76x02_dev *dev);
 int mt76x2u_phy_set_channel(struct mt76x02_dev *dev,
 			    struct cfg80211_chan_def *chandef);
 void mt76x2u_phy_calibrate(struct work_struct *work);
-void mt76x2u_phy_channel_calibrate(struct mt76x02_dev *dev);
 
 void mt76x2u_mcu_complete_urb(struct urb *urb);
 int mt76x2u_mcu_init(struct mt76x02_dev *dev);
drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c +0 -5
index c2e0a43082e5..cad99715997e 100644
@@ -91,11 +91,6 @@ mt76x2u_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 
 	mutex_lock(&dev->mt76.mutex);
 
-	if (changed & BSS_CHANGED_ASSOC) {
-		mt76x2u_phy_channel_calibrate(dev);
-		mt76x2_apply_gain_adj(dev);
-	}
-
 	if (changed & BSS_CHANGED_BSSID) {
 		mt76_wr(dev, MT_MAC_BSSID_DW0,
 			get_unaligned_le32(info->bssid));
drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c +15 -3
index 24e292e895b6..a64268e8db42 100644
@@ -18,15 +18,20 @@
 #include "eeprom.h"
 #include "../mt76x02_phy.h"
 
-void mt76x2u_phy_channel_calibrate(struct mt76x02_dev *dev)
+static void
+mt76x2u_phy_channel_calibrate(struct mt76x02_dev *dev, bool mac_stopped)
 {
 	struct ieee80211_channel *chan = dev->mt76.chandef.chan;
 	bool is_5ghz = chan->band == NL80211_BAND_5GHZ;
 
+	if (dev->cal.channel_cal_done)
+		return;
+
 	if (mt76x2_channel_silent(dev))
 		return;
 
-	mt76x2u_mac_stop(dev);
+	if (!mac_stopped)
+		mt76x2u_mac_stop(dev);
 
 	if (is_5ghz)
 		mt76x02_mcu_calibrate(dev, MCU_CAL_LC, 0, false);
@@ -37,7 +42,11 @@ void mt76x2u_phy_channel_calibrate(struct mt76x02_dev *dev)
 	mt76x02_mcu_calibrate(dev, MCU_CAL_TEMP_SENSOR, 0, false);
 	mt76x02_mcu_calibrate(dev, MCU_CAL_TX_SHAPING, 0, false);
 
-	mt76x2u_mac_resume(dev);
+	if (!mac_stopped)
+		mt76x2u_mac_resume(dev);
+	mt76x2_apply_gain_adj(dev);
+
+	dev->cal.channel_cal_done = true;
 }
 
 void mt76x2u_phy_calibrate(struct work_struct *work)
@@ -45,6 +54,7 @@ void mt76x2u_phy_calibrate(struct work_struct *work)
 	struct mt76x02_dev *dev;
 
 	dev = container_of(work, struct mt76x02_dev, cal_work.work);
+	mt76x2u_phy_channel_calibrate(dev, false);
 	mt76x2_phy_tssi_compensate(dev, false);
 	mt76x2_phy_update_channel_gain(dev);
 
@@ -165,7 +175,9 @@ int mt76x2u_phy_set_channel(struct mt76x02_dev *dev,
 	if (scan)
 		return 0;
 
+	mt76x2u_phy_channel_calibrate(dev, true);
 	mt76x02_init_agc_gain(dev);
+
 	if (mt76x2_tssi_enabled(dev)) {
 		/* init default values for temp compensation */
 		mt76_rmw_field(dev, MT_TX_ALC_CFG_1, MT_TX_ALC_CFG_1_TEMP_COMP,
Signature · 1 line
2.17.2
#3 lore raw

PATCH 3/4 mt76x2u: main: use mt76x02_bss_info_changed utility routine

In reply to Lorenzo Bianconi

Initialize bss_info_changed mac80211 callback to mt76x02_bss_info_changed utility routine and remove duplicated code. Use 8 as WCID index for sta interface

---
 .../wireless/mediatek/mt76/mt76x2/usb_main.c  | 23 +++----------------
 1 file changed, 3 insertions(+), 20 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c +3 -20
index cad99715997e..a9ecc92875ae 100644
@@ -50,11 +50,12 @@ static int mt76x2u_add_interface(struct ieee80211_hw *hw,
 				 struct ieee80211_vif *vif)
 {
 	struct mt76x02_dev *dev = hw->priv;
+	unsigned int idx = 8;
 
 	if (!ether_addr_equal(dev->mt76.macaddr, vif->addr))
 		mt76x02_mac_setaddr(dev, vif->addr);
 
-	mt76x02_vif_init(dev, vif, 0);
+	mt76x02_vif_init(dev, vif, idx);
 	return 0;
 }
 
@@ -83,24 +84,6 @@ mt76x2u_set_channel(struct mt76x02_dev *dev,
 	return err;
 }
 
-static void
-mt76x2u_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-			 struct ieee80211_bss_conf *info, u32 changed)
-{
-	struct mt76x02_dev *dev = hw->priv;
-
-	mutex_lock(&dev->mt76.mutex);
-
-	if (changed & BSS_CHANGED_BSSID) {
-		mt76_wr(dev, MT_MAC_BSSID_DW0,
-			get_unaligned_le32(info->bssid));
-		mt76_wr(dev, MT_MAC_BSSID_DW1,
-			get_unaligned_le16(info->bssid + 4));
-	}
-
-	mutex_unlock(&dev->mt76.mutex);
-}
-
 static int
 mt76x2u_config(struct ieee80211_hw *hw, u32 changed)
 {
@@ -150,7 +133,7 @@ const struct ieee80211_ops mt76x2u_ops = {
 	.ampdu_action = mt76x02_ampdu_action,
 	.config = mt76x2u_config,
 	.wake_tx_queue = mt76_wake_tx_queue,
-	.bss_info_changed = mt76x2u_bss_info_changed,
+	.bss_info_changed = mt76x02_bss_info_changed,
 	.configure_filter = mt76x02_configure_filter,
 	.conf_tx = mt76x02_conf_tx,
 	.sw_scan_start = mt76x02_sw_scan,
Signature · 1 line
2.17.2
#4 lore raw

PATCH 4/4 mt76x2u: init: remove mt76x2u_init_beacon_offsets routine

In reply to Lorenzo Bianconi

Remove mt76x2u_init_beacon_offsets routine since the driver supports just STA mode

---
 drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c +0 -10
index 8b280a4ea792..de0fbdb02c4d 100644
@@ -156,14 +156,6 @@ struct mt76x02_dev *mt76x2u_alloc_device(struct device *pdev)
 	return dev;
 }
 
-static void mt76x2u_init_beacon_offsets(struct mt76x02_dev *dev)
-{
-	mt76_wr(dev, MT_BCN_OFFSET(0), 0x18100800);
-	mt76_wr(dev, MT_BCN_OFFSET(1), 0x38302820);
-	mt76_wr(dev, MT_BCN_OFFSET(2), 0x58504840);
-	mt76_wr(dev, MT_BCN_OFFSET(3), 0x78706860);
-}
-
 int mt76x2u_init_hardware(struct mt76x02_dev *dev)
 {
 	int i, k, err;
@@ -200,8 +192,6 @@ int mt76x2u_init_hardware(struct mt76x02_dev *dev)
 	mt76x02_mac_setaddr(dev, dev->mt76.eeprom.data + MT_EE_MAC_ADDR);
 	dev->mt76.rxfilter = mt76_rr(dev, MT_RX_FILTR_CFG);
 
-	mt76x2u_init_beacon_offsets(dev);
-
 	if (!mt76x02_wait_for_txrx_idle(&dev->mt76))
 		return -ETIMEDOUT;
 
Signature · 1 line
2.17.2
maintainer Applied
#5 lore raw
In reply to Lorenzo Bianconi
Quoted 5 lines · Lorenzo Bianconi

Perform channel calibration after each channel switch and not only after connection establishment.
Enable MCU_CAL_TX_SHAPING phy calibration.
Moreover remove remove beacon offset configuration since the driver supports just client mode

Applied, thanks.

- Felix