All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] unify drv_bss_info_changed between mt76x0u and mt76x2u
@ 2018-11-06 16:59 Lorenzo Bianconi
  2018-11-06 16:59 ` [PATCH 1/4] mt76x2u: phy: add TX_SHAPING calibration Lorenzo Bianconi
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2018-11-06 16:59 UTC (permalink / raw)
  To: nbd; +Cc: sgruszka, linux-wireless

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(-)

-- 
2.17.2


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

* [PATCH 1/4] mt76x2u: phy: add TX_SHAPING calibration
  2018-11-06 16:59 [PATCH 0/4] unify drv_bss_info_changed between mt76x0u and mt76x2u Lorenzo Bianconi
@ 2018-11-06 16:59 ` Lorenzo Bianconi
  2018-11-06 16:59 ` [PATCH 2/4] mt76x2u: phy: run phy_channel_calibrate after channel switch Lorenzo Bianconi
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2018-11-06 16:59 UTC (permalink / raw)
  To: nbd; +Cc: sgruszka, linux-wireless

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

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
 drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c
index 8011c261c658..24e292e895b6 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c
@@ -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);
 }
-- 
2.17.2


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

* [PATCH 2/4] mt76x2u: phy: run phy_channel_calibrate after channel switch
  2018-11-06 16:59 [PATCH 0/4] unify drv_bss_info_changed between mt76x0u and mt76x2u Lorenzo Bianconi
  2018-11-06 16:59 ` [PATCH 1/4] mt76x2u: phy: add TX_SHAPING calibration Lorenzo Bianconi
@ 2018-11-06 16:59 ` Lorenzo Bianconi
  2018-11-06 16:59 ` [PATCH 3/4] mt76x2u: main: use mt76x02_bss_info_changed utility routine Lorenzo Bianconi
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2018-11-06 16:59 UTC (permalink / raw)
  To: nbd; +Cc: sgruszka, linux-wireless

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

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
 .../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(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2u.h b/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2u.h
index 833974de5c80..0b0075411b34 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2u.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2u.h
@@ -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);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
index c2e0a43082e5..cad99715997e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
@@ -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));
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c
index 24e292e895b6..a64268e8db42 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c
@@ -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,
-- 
2.17.2


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

* [PATCH 3/4] mt76x2u: main: use mt76x02_bss_info_changed utility routine
  2018-11-06 16:59 [PATCH 0/4] unify drv_bss_info_changed between mt76x0u and mt76x2u Lorenzo Bianconi
  2018-11-06 16:59 ` [PATCH 1/4] mt76x2u: phy: add TX_SHAPING calibration Lorenzo Bianconi
  2018-11-06 16:59 ` [PATCH 2/4] mt76x2u: phy: run phy_channel_calibrate after channel switch Lorenzo Bianconi
@ 2018-11-06 16:59 ` Lorenzo Bianconi
  2018-11-06 16:59 ` [PATCH 4/4] mt76x2u: init: remove mt76x2u_init_beacon_offsets routine Lorenzo Bianconi
  2018-11-13 19:51 ` [PATCH 0/4] unify drv_bss_info_changed between mt76x0u and mt76x2u Felix Fietkau
  4 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2018-11-06 16:59 UTC (permalink / raw)
  To: nbd; +Cc: sgruszka, linux-wireless

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

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
 .../wireless/mediatek/mt76/mt76x2/usb_main.c  | 23 +++----------------
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
index cad99715997e..a9ecc92875ae 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
@@ -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,
-- 
2.17.2


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

* [PATCH 4/4] mt76x2u: init: remove mt76x2u_init_beacon_offsets routine
  2018-11-06 16:59 [PATCH 0/4] unify drv_bss_info_changed between mt76x0u and mt76x2u Lorenzo Bianconi
                   ` (2 preceding siblings ...)
  2018-11-06 16:59 ` [PATCH 3/4] mt76x2u: main: use mt76x02_bss_info_changed utility routine Lorenzo Bianconi
@ 2018-11-06 16:59 ` Lorenzo Bianconi
  2018-11-13 19:51 ` [PATCH 0/4] unify drv_bss_info_changed between mt76x0u and mt76x2u Felix Fietkau
  4 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2018-11-06 16:59 UTC (permalink / raw)
  To: nbd; +Cc: sgruszka, linux-wireless

Remove mt76x2u_init_beacon_offsets routine since the driver supports
just STA mode

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
 drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c
index 8b280a4ea792..de0fbdb02c4d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c
@@ -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;
 
-- 
2.17.2


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

* Re: [PATCH 0/4] unify drv_bss_info_changed between mt76x0u and mt76x2u
  2018-11-06 16:59 [PATCH 0/4] unify drv_bss_info_changed between mt76x0u and mt76x2u Lorenzo Bianconi
                   ` (3 preceding siblings ...)
  2018-11-06 16:59 ` [PATCH 4/4] mt76x2u: init: remove mt76x2u_init_beacon_offsets routine Lorenzo Bianconi
@ 2018-11-13 19:51 ` Felix Fietkau
  4 siblings, 0 replies; 6+ messages in thread
From: Felix Fietkau @ 2018-11-13 19:51 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: sgruszka, linux-wireless

On 2018-11-06 17:59, Lorenzo Bianconi wrote:
> 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

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

end of thread, other threads:[~2018-11-13 19:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-06 16:59 [PATCH 0/4] unify drv_bss_info_changed between mt76x0u and mt76x2u Lorenzo Bianconi
2018-11-06 16:59 ` [PATCH 1/4] mt76x2u: phy: add TX_SHAPING calibration Lorenzo Bianconi
2018-11-06 16:59 ` [PATCH 2/4] mt76x2u: phy: run phy_channel_calibrate after channel switch Lorenzo Bianconi
2018-11-06 16:59 ` [PATCH 3/4] mt76x2u: main: use mt76x02_bss_info_changed utility routine Lorenzo Bianconi
2018-11-06 16:59 ` [PATCH 4/4] mt76x2u: init: remove mt76x2u_init_beacon_offsets routine Lorenzo Bianconi
2018-11-13 19:51 ` [PATCH 0/4] unify drv_bss_info_changed between mt76x0u and mt76x2u Felix Fietkau

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