Skip to contentSkip to conversation

unify debugfs code between mt76x0 and mt76x2

PATCH Applied Lorenzo Bianconi 2 participants 8 messages Oct 15, 2018 – Oct 16, 2018

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

cover unify debugfs code between mt76x0 and mt76x2

Unify debugfs implementation between mt76x0 and mt76x2 drivers. Add get_survey support to mt76x0e driver
Add mac work support to mt76x2u driver

Lorenzo Bianconi (6):
mt76x0: pci: add get_survey support
mt76: move mt76x02_mac_work routine in mt76x02-lib module
mt76: move mt76x02_debugfs in mt76x02-lib module
mt76x0: use shared debugfs implementation
mt76x0: use mt76x02_mac_work as stats handler
mt76x2u: introduce mac workqueue support

 drivers/net/wireless/mediatek/mt76/Makefile   |  2 +-
 .../wireless/mediatek/mt76/mt76x0/Makefile    |  4 +-
 .../wireless/mediatek/mt76/mt76x0/debugfs.c   | 87 -------------------
 .../net/wireless/mediatek/mt76/mt76x0/init.c  |  5 +-
 .../net/wireless/mediatek/mt76/mt76x0/mac.c   | 66 --------------
 .../net/wireless/mediatek/mt76/mt76x0/main.c  |  5 ++
 .../wireless/mediatek/mt76/mt76x0/mt76x0.h    |  5 --
 .../net/wireless/mediatek/mt76/mt76x0/pci.c   |  2 +
 drivers/net/wireless/mediatek/mt76/mt76x02.h  | 12 +--
 .../{mt76x2/debugfs.c => mt76x02_debugfs.c}   | 22 ++---
 .../net/wireless/mediatek/mt76/mt76x02_mac.c  | 56 ++++++++++++
 .../net/wireless/mediatek/mt76/mt76x02_mac.h  |  2 +
 .../wireless/mediatek/mt76/mt76x2/Makefile    |  2 +-
 .../net/wireless/mediatek/mt76/mt76x2/init.c  |  2 +
 .../net/wireless/mediatek/mt76/mt76x2/mac.h   |  2 -
 .../wireless/mediatek/mt76/mt76x2/mt76x2.h    |  5 --
 .../wireless/mediatek/mt76/mt76x2/pci_init.c  |  5 +-
 .../wireless/mediatek/mt76/mt76x2/pci_mac.c   | 35 --------
 .../wireless/mediatek/mt76/mt76x2/usb_init.c  |  3 +-
 .../wireless/mediatek/mt76/mt76x2/usb_main.c  |  2 +
 20 files changed, 93 insertions(+), 231 deletions(-)
 delete mode 100644 drivers/net/wireless/mediatek/mt76/mt76x0/debugfs.c
 rename drivers/net/wireless/mediatek/mt76/{mt76x2/debugfs.c => mt76x02_debugfs.c} (86%)
Signature · 1 line
2.19.0
#1 lore raw

PATCH 1/6 mt76x0: pci: add get_survey support

Move mt76x02_update_channel routine in mt76x02-lib module in order to be reused by mt76x0 driver adding get_survey support

---
 .../net/wireless/mediatek/mt76/mt76x0/mac.c   |  2 ++
 .../net/wireless/mediatek/mt76/mt76x0/main.c  |  5 +++++
 .../net/wireless/mediatek/mt76/mt76x0/pci.c   |  2 ++
 .../net/wireless/mediatek/mt76/mt76x02_mac.c  | 18 ++++++++++++++++++
 .../net/wireless/mediatek/mt76/mt76x02_mac.h  |  1 +
 .../wireless/mediatek/mt76/mt76x2/mt76x2.h    |  2 --
 .../wireless/mediatek/mt76/mt76x2/pci_init.c  |  2 +-
 .../wireless/mediatek/mt76/mt76x2/pci_mac.c   | 19 +------------------
 8 files changed, 30 insertions(+), 21 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x0/mac.c +2 -0
index 7a422c590211..9cabe8ebf5da 100644
@@ -137,6 +137,8 @@ void mt76x0_mac_work(struct work_struct *work)
 	u32 sum, n;
 	int i, j, k;
 
+	mt76x02_update_channel(&dev->mt76);
+
 	/* Note: using MCU_RANDOM_READ is actually slower then reading all the
 	 *	 registers by hand.  MCU takes ca. 20ms to complete read of 24
 	 *	 registers while reading them one by one will takes roughly
drivers/net/wireless/mediatek/mt76/mt76x0/main.c +5 -0
index 9273d2d2764a..e9fbbabbe7e0 100644
@@ -25,6 +25,11 @@ mt76x0_set_channel(struct mt76x02_dev *dev, struct cfg80211_chan_def *chandef)
 
 	mt76_set_channel(&dev->mt76);
 	ret = mt76x0_phy_set_channel(dev, chandef);
+
+	/* channel cycle counters read-and-clear */
+	mt76_rr(dev, MT_CH_IDLE);
+	mt76_rr(dev, MT_CH_BUSY);
+
 	mt76_txq_schedule_all(&dev->mt76);
 
 	return ret;
drivers/net/wireless/mediatek/mt76/mt76x0/pci.c +2 -0
index 522c86059bcb..3277e6b07a46 100644
@@ -85,6 +85,7 @@ static const struct ieee80211_ops mt76x0e_ops = {
 	.ampdu_action = mt76x02_ampdu_action,
 	.sta_rate_tbl_update = mt76x02_sta_rate_tbl_update,
 	.wake_tx_queue = mt76_wake_tx_queue,
+	.get_survey = mt76_get_survey,
 };
 
 static int mt76x0e_register_device(struct mt76x02_dev *dev)
@@ -135,6 +136,7 @@ mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
 	static const struct mt76_driver_ops drv_ops = {
 		.txwi_size = sizeof(struct mt76x02_txwi),
+		.update_survey = mt76x02_update_channel,
 		.tx_prepare_skb = mt76x02_tx_prepare_skb,
 		.tx_complete_skb = mt76x02_tx_complete_skb,
 		.rx_skb = mt76x02_queue_rx_skb,
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +18 -0
index 10578e4cb269..e6d6ddaa5a07 100644
@@ -735,3 +735,21 @@ void mt76x02_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue *q,
 		dev_kfree_skb_any(e->skb);
 }
 EXPORT_SYMBOL_GPL(mt76x02_tx_complete_skb);
+
+void mt76x02_update_channel(struct mt76_dev *mdev)
+{
+	struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
+	struct mt76_channel_state *state;
+	u32 active, busy;
+
+	state = mt76_channel_state(&dev->mt76, dev->mt76.chandef.chan);
+
+	busy = mt76_rr(dev, MT_CH_BUSY);
+	active = busy + mt76_rr(dev, MT_CH_IDLE);
+
+	spin_lock_bh(&dev->mt76.cc_lock);
+	state->cc_busy += busy;
+	state->cc_active += active;
+	spin_unlock_bh(&dev->mt76.cc_lock);
+}
+EXPORT_SYMBOL_GPL(mt76x02_update_channel);
drivers/net/wireless/mediatek/mt76/mt76x02_mac.h +1 -0
index d99c18743969..6bce18bcbf36 100644
@@ -226,4 +226,5 @@ void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi *txwi,
 void mt76x02_mac_poll_tx_status(struct mt76x02_dev *dev, bool irq);
 void mt76x02_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue *q,
 			     struct mt76_queue_entry *e, bool flush);
+void mt76x02_update_channel(struct mt76_dev *mdev);
 #endif
drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h +0 -2
index be0ae24d310a..72c365040be1 100644
@@ -85,8 +85,6 @@ void mt76x2_pre_tbtt_tasklet(unsigned long arg);
 
 void mt76x2_sta_ps(struct mt76_dev *dev, struct ieee80211_sta *sta, bool ps);
 
-void mt76x2_update_channel(struct mt76_dev *mdev);
-
 void mt76x2_reset_wlan(struct mt76x02_dev *dev, bool enable);
 void mt76x2_init_txpower(struct mt76x02_dev *dev,
 			 struct ieee80211_supported_band *sband);
drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c +1 -1
index 3824290b219d..279edc612119 100644
@@ -354,7 +354,7 @@ struct mt76x02_dev *mt76x2_alloc_device(struct device *pdev)
 {
 	static const struct mt76_driver_ops drv_ops = {
 		.txwi_size = sizeof(struct mt76x02_txwi),
-		.update_survey = mt76x2_update_channel,
+		.update_survey = mt76x02_update_channel,
 		.tx_prepare_skb = mt76x02_tx_prepare_skb,
 		.tx_complete_skb = mt76x02_tx_complete_skb,
 		.rx_skb = mt76x02_queue_rx_skb,
drivers/net/wireless/mediatek/mt76/mt76x2/pci_mac.c +1 -18
index 4b331ed14bb2..15620d4d425e 100644
@@ -137,30 +137,13 @@ void mt76x2_mac_set_beacon_enable(struct mt76x02_dev *dev,
 		mt76x02_irq_disable(dev, MT_INT_PRE_TBTT | MT_INT_TBTT);
 }
 
-void mt76x2_update_channel(struct mt76_dev *mdev)
-{
-	struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
-	struct mt76_channel_state *state;
-	u32 active, busy;
-
-	state = mt76_channel_state(&dev->mt76, dev->mt76.chandef.chan);
-
-	busy = mt76_rr(dev, MT_CH_BUSY);
-	active = busy + mt76_rr(dev, MT_CH_IDLE);
-
-	spin_lock_bh(&dev->mt76.cc_lock);
-	state->cc_busy += busy;
-	state->cc_active += active;
-	spin_unlock_bh(&dev->mt76.cc_lock);
-}
-
 void mt76x2_mac_work(struct work_struct *work)
 {
 	struct mt76x02_dev *dev = container_of(work, struct mt76x02_dev,
 					       mac_work.work);
 	int i, idx;
 
-	mt76x2_update_channel(&dev->mt76);
+	mt76x02_update_channel(&dev->mt76);
 	for (i = 0, idx = 0; i < 16; i++) {
 		u32 val = mt76_rr(dev, MT_TX_AGG_CNT(i));
 
Signature · 1 line
2.19.0
#2 lore raw

PATCH 2/6 mt76: move mt76x02_mac_work routine in mt76x02-lib module

In reply to Lorenzo Bianconi

Move mt76x02_mac_work routine in mt76x02_mac.c in order to be reused by mt76x0 driver to read device statistics

---
 .../wireless/mediatek/mt76/mt76x0/mt76x0.h    |  2 --
 drivers/net/wireless/mediatek/mt76/mt76x02.h  |  2 ++
 .../net/wireless/mediatek/mt76/mt76x02_mac.c  | 19 +++++++++++++++++++
 .../net/wireless/mediatek/mt76/mt76x02_mac.h  |  1 +
 .../net/wireless/mediatek/mt76/mt76x2/mac.h   |  2 --
 .../wireless/mediatek/mt76/mt76x2/mt76x2.h    |  2 --
 .../wireless/mediatek/mt76/mt76x2/pci_init.c  |  2 +-
 .../wireless/mediatek/mt76/mt76x2/pci_mac.c   | 18 ------------------
 8 files changed, 23 insertions(+), 25 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h +0 -2
index f27335ccb582..17fc7206c55d 100644
@@ -28,8 +28,6 @@
 #include "../mt76x02.h"
 #include "eeprom.h"
 
-#define MT_CALIBRATE_INTERVAL		(4 * HZ)
-
 #define MT_USB_AGGR_SIZE_LIMIT		21 /* * 1024B */
 #define MT_USB_AGGR_TIMEOUT		0x80 /* * 33ns */
 
drivers/net/wireless/mediatek/mt76/mt76x02.h +2 -0
index 47c42c607964..189c697973bd 100644
@@ -26,6 +26,8 @@
 #include "mt76x02_dfs.h"
 #include "mt76x02_dma.h"
 
+#define MT_CALIBRATE_INTERVAL	HZ
+
 struct mt76x02_mac_stats {
 	u64 rx_stat[6];
 	u64 tx_stat[6];
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +19 -0
index e6d6ddaa5a07..c7666f4c432f 100644
@@ -753,3 +753,22 @@ void mt76x02_update_channel(struct mt76_dev *mdev)
 	spin_unlock_bh(&dev->mt76.cc_lock);
 }
 EXPORT_SYMBOL_GPL(mt76x02_update_channel);
+
+void mt76x02_mac_work(struct work_struct *work)
+{
+	struct mt76x02_dev *dev = container_of(work, struct mt76x02_dev,
+					       mac_work.work);
+	int i, idx;
+
+	mt76x02_update_channel(&dev->mt76);
+	for (i = 0, idx = 0; i < 16; i++) {
+		u32 val = mt76_rr(dev, MT_TX_AGG_CNT(i));
+
+		dev->aggr_stats[idx++] += val & 0xffff;
+		dev->aggr_stats[idx++] += val >> 16;
+	}
+
+	ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mac_work,
+				     MT_CALIBRATE_INTERVAL);
+}
+EXPORT_SYMBOL_GPL(mt76x02_mac_work);
drivers/net/wireless/mediatek/mt76/mt76x02_mac.h +1 -0
index 6bce18bcbf36..c1936e2277d1 100644
@@ -227,4 +227,5 @@ void mt76x02_mac_poll_tx_status(struct mt76x02_dev *dev, bool irq);
 void mt76x02_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue *q,
 			     struct mt76_queue_entry *e, bool flush);
 void mt76x02_update_channel(struct mt76_dev *mdev);
+void mt76x02_mac_work(struct work_struct *work);
 #endif
drivers/net/wireless/mediatek/mt76/mt76x2/mac.h +0 -2
index a31bd49ae6cb..2dc2b9d5dc8f 100644
@@ -32,6 +32,4 @@ int mt76x2_mac_set_beacon(struct mt76x02_dev *dev, u8 vif_idx,
 			  struct sk_buff *skb);
 void mt76x2_mac_set_beacon_enable(struct mt76x02_dev *dev, u8 vif_idx, bool val);
 
-void mt76x2_mac_work(struct work_struct *work);
-
 #endif
drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h +0 -2
index 72c365040be1..eca142ac656d 100644
@@ -31,8 +31,6 @@
 #define MT7662_ROM_PATCH	"mt7662_rom_patch.bin"
 #define MT7662_EEPROM_SIZE	512
 
-#define MT_CALIBRATE_INTERVAL	HZ
-
 #include "../mt76x02.h"
 #include "mac.h"
 #include "dfs.h"
drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c +1 -1
index 279edc612119..0dea7d7b17a3 100644
@@ -467,7 +467,7 @@ int mt76x2_register_device(struct mt76x02_dev *dev)
 	int i, ret;
 
 	INIT_DELAYED_WORK(&dev->cal_work, mt76x2_phy_calibrate);
-	INIT_DELAYED_WORK(&dev->mac_work, mt76x2_mac_work);
+	INIT_DELAYED_WORK(&dev->mac_work, mt76x02_mac_work);
 
 	mt76x2_init_device(dev);
 
drivers/net/wireless/mediatek/mt76/mt76x2/pci_mac.c +0 -18
index 15620d4d425e..97128ea6bd7a 100644
@@ -137,24 +137,6 @@ void mt76x2_mac_set_beacon_enable(struct mt76x02_dev *dev,
 		mt76x02_irq_disable(dev, MT_INT_PRE_TBTT | MT_INT_TBTT);
 }
 
-void mt76x2_mac_work(struct work_struct *work)
-{
-	struct mt76x02_dev *dev = container_of(work, struct mt76x02_dev,
-					       mac_work.work);
-	int i, idx;
-
-	mt76x02_update_channel(&dev->mt76);
-	for (i = 0, idx = 0; i < 16; i++) {
-		u32 val = mt76_rr(dev, MT_TX_AGG_CNT(i));
-
-		dev->aggr_stats[idx++] += val & 0xffff;
-		dev->aggr_stats[idx++] += val >> 16;
-	}
-
-	ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mac_work,
-				     MT_CALIBRATE_INTERVAL);
-}
-
 void mt76x2_mac_set_tx_protection(struct mt76x02_dev *dev, u32 val)
 {
 	u32 data = 0;
Signature · 1 line
2.19.0
#3 lore raw

PATCH 3/6 mt76: move mt76x02_debugfs in mt76x02-lib module

In reply to Lorenzo Bianconi

Move mt76x02_debugfs in mt76x02-lib module in order to be reused by mt76x0 driver and remove duplicated code

---
 drivers/net/wireless/mediatek/mt76/Makefile   |  2 +-
 drivers/net/wireless/mediatek/mt76/mt76x02.h  |  2 ++
 .../{mt76x2/debugfs.c => mt76x02_debugfs.c}   | 22 +++++++++----------
 .../wireless/mediatek/mt76/mt76x2/Makefile    |  2 +-
 .../wireless/mediatek/mt76/mt76x2/mt76x2.h    |  1 -
 .../wireless/mediatek/mt76/mt76x2/pci_init.c  |  2 +-
 .../wireless/mediatek/mt76/mt76x2/usb_init.c  |  2 +-
 7 files changed, 17 insertions(+), 16 deletions(-)
 rename drivers/net/wireless/mediatek/mt76/{mt76x2/debugfs.c => mt76x02_debugfs.c} (86%)
drivers/net/wireless/mediatek/mt76/Makefile +1 -1
index 9b8d7488c545..a737a518802f 100644
@@ -14,7 +14,7 @@ CFLAGS_mt76x02_trace.o := -I$(src)
 
 mt76x02-lib-y := mt76x02_util.o mt76x02_mac.o mt76x02_mcu.o \
 		 mt76x02_eeprom.o mt76x02_phy.o mt76x02_mmio.o \
-		 mt76x02_txrx.o mt76x02_trace.o
+		 mt76x02_txrx.o mt76x02_trace.o mt76x02_debugfs.o
 
 mt76x02-usb-y := mt76x02_usb_mcu.o mt76x02_usb_core.o
 
drivers/net/wireless/mediatek/mt76/mt76x02.h +2 -0
index 189c697973bd..58721307d917 100644
@@ -162,6 +162,8 @@ void mt76x02_set_beacon_offsets(struct mt76x02_dev *dev);
 void mt76x02_set_irq_mask(struct mt76x02_dev *dev, u32 clear, u32 set);
 void mt76x02_mac_start(struct mt76x02_dev *dev);
 
+void mt76x02_init_debugfs(struct mt76x02_dev *dev);
+
 static inline bool is_mt76x2(struct mt76x02_dev *dev)
 {
 	return mt76_chip(&dev->mt76) == 0x7612 ||
drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c renamed from drivers/net/wireless/mediatek/mt76/mt76x2/debugfs.c +11 -11
similarity index 86%
rename from drivers/net/wireless/mediatek/mt76/mt76x2/debugfs.c
rename to drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c
index e8f8ccc0a5ed..a9d52ba1e270 100644
@@ -15,10 +15,10 @@
  */
 
 #include <linux/debugfs.h>
-#include "mt76x2.h"
+#include "mt76x02.h"
 
 static int
-mt76x2_ampdu_stat_read(struct seq_file *file, void *data)
+mt76x02_ampdu_stat_read(struct seq_file *file, void *data)
 {
 	struct mt76x02_dev *dev = file->private;
 	int i, j;
@@ -42,9 +42,9 @@ mt76x2_ampdu_stat_read(struct seq_file *file, void *data)
 }
 
 static int
-mt76x2_ampdu_stat_open(struct inode *inode, struct file *f)
+mt76x02_ampdu_stat_open(struct inode *inode, struct file *f)
 {
-	return single_open(f, mt76x2_ampdu_stat_read, inode->i_private);
+	return single_open(f, mt76x02_ampdu_stat_read, inode->i_private);
 }
 
 static int read_txpower(struct seq_file *file, void *data)
@@ -59,14 +59,14 @@ static int read_txpower(struct seq_file *file, void *data)
 }
 
 static const struct file_operations fops_ampdu_stat = {
-	.open = mt76x2_ampdu_stat_open,
+	.open = mt76x02_ampdu_stat_open,
 	.read = seq_read,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
 
 static int
-mt76x2_dfs_stat_read(struct seq_file *file, void *data)
+mt76x02_dfs_stat_read(struct seq_file *file, void *data)
 {
 	struct mt76x02_dev *dev = file->private;
 	struct mt76x02_dfs_pattern_detector *dfs_pd = &dev->dfs_pd;
@@ -92,13 +92,13 @@ mt76x2_dfs_stat_read(struct seq_file *file, void *data)
 }
 
 static int
-mt76x2_dfs_stat_open(struct inode *inode, struct file *f)
+mt76x02_dfs_stat_open(struct inode *inode, struct file *f)
 {
-	return single_open(f, mt76x2_dfs_stat_read, inode->i_private);
+	return single_open(f, mt76x02_dfs_stat_read, inode->i_private);
 }
 
 static const struct file_operations fops_dfs_stat = {
-	.open = mt76x2_dfs_stat_open,
+	.open = mt76x02_dfs_stat_open,
 	.read = seq_read,
 	.llseek = seq_lseek,
 	.release = single_release,
@@ -116,7 +116,7 @@ static int read_agc(struct seq_file *file, void *data)
 	return 0;
 }
 
-void mt76x2_init_debugfs(struct mt76x02_dev *dev)
+void mt76x02_init_debugfs(struct mt76x02_dev *dev)
 {
 	struct dentry *dir;
 
@@ -134,4 +134,4 @@ void mt76x2_init_debugfs(struct mt76x02_dev *dev)
 
 	debugfs_create_devm_seqfile(dev->mt76.dev, "agc", dir, read_agc);
 }
-EXPORT_SYMBOL_GPL(mt76x2_init_debugfs);
+EXPORT_SYMBOL_GPL(mt76x02_init_debugfs);
drivers/net/wireless/mediatek/mt76/mt76x2/Makefile +1 -1
index b71bb1049170..696f071f47f8 100644
@@ -3,7 +3,7 @@ obj-$(CONFIG_MT76x2E) += mt76x2e.o
 obj-$(CONFIG_MT76x2U) += mt76x2u.o
 
 mt76x2-common-y := \
-	eeprom.o mac.o init.o phy.o debugfs.o mcu.o
+	eeprom.o mac.o init.o phy.o mcu.o
 
 mt76x2e-y := \
 	pci.o pci_main.o pci_init.o pci_tx.o \
drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h +0 -1
index eca142ac656d..7408db788409 100644
@@ -52,7 +52,6 @@ extern const struct ieee80211_ops mt76x2_ops;
 
 struct mt76x02_dev *mt76x2_alloc_device(struct device *pdev);
 int mt76x2_register_device(struct mt76x02_dev *dev);
-void mt76x2_init_debugfs(struct mt76x02_dev *dev);
 void mt76x2_init_device(struct mt76x02_dev *dev);
 
 void mt76x2_phy_power_on(struct mt76x02_dev *dev);
drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c +1 -1
index 0dea7d7b17a3..5b167aaaf7f7 100644
@@ -515,7 +515,7 @@ int mt76x2_register_device(struct mt76x02_dev *dev)
 	if (ret)
 		goto fail;
 
-	mt76x2_init_debugfs(dev);
+	mt76x02_init_debugfs(dev);
 	mt76x2_init_txpower(dev, &dev->mt76.sband_2g.sband);
 	mt76x2_init_txpower(dev, &dev->mt76.sband_5g.sband);
 
drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c +1 -1
index 13cce2937573..dfc80ecfde92 100644
@@ -282,7 +282,7 @@ int mt76x2u_register_device(struct mt76x02_dev *dev)
 
 	set_bit(MT76_STATE_INITIALIZED, &dev->mt76.state);
 
-	mt76x2_init_debugfs(dev);
+	mt76x02_init_debugfs(dev);
 	mt76x2_init_txpower(dev, &dev->mt76.sband_2g.sband);
 	mt76x2_init_txpower(dev, &dev->mt76.sband_5g.sband);
 
Signature · 1 line
2.19.0
#4 lore raw

PATCH 4/6 mt76x0: use shared debugfs implementation

In reply to Lorenzo Bianconi

Use mt76x02 debugfs implementation and remove duplicated code

---
 .../wireless/mediatek/mt76/mt76x0/Makefile    |  4 +-
 .../wireless/mediatek/mt76/mt76x0/debugfs.c   | 87 -------------------
 .../net/wireless/mediatek/mt76/mt76x0/init.c  |  2 +-
 .../wireless/mediatek/mt76/mt76x0/mt76x0.h    |  2 -
 4 files changed, 3 insertions(+), 92 deletions(-)
 delete mode 100644 drivers/net/wireless/mediatek/mt76/mt76x0/debugfs.c
drivers/net/wireless/mediatek/mt76/mt76x0/Makefile +2 -2
index 20672978dceb..e49cbf6be945 100644
@@ -3,8 +3,8 @@ obj-$(CONFIG_MT76x0E) += mt76x0e.o
 obj-$(CONFIG_MT76x0_COMMON) += mt76x0-common.o
 
 mt76x0-common-y := \
-	init.o main.o trace.o eeprom.o phy.o \
-	mac.o debugfs.o
+	init.o main.o trace.o eeprom.o phy.o mac.o
+
 mt76x0u-y := usb.o usb_mcu.o
 mt76x0e-y := pci.o pci_mcu.o
 
drivers/net/wireless/mediatek/mt76/mt76x0/debugfs.c deleted +0 -87

87 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt76x0/init.c +1 -1
index d7d4dfbbd04d..f90ef4d803d5 100644
@@ -389,7 +389,7 @@ int mt76x0_register_device(struct mt76x02_dev *dev)
 	if (mdev->cap.has_5ghz)
 		mt76x0_vht_cap_mask(&dev->mt76.sband_5g.sband);
 
-	mt76x0_init_debugfs(dev);
+	mt76x02_init_debugfs(dev);
 
 	return 0;
 }
drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h +0 -2
index 17fc7206c55d..b9743b575099 100644
@@ -37,8 +37,6 @@ static inline bool is_mt7610e(struct mt76x02_dev *dev)
 	return false;
 }
 
-void mt76x0_init_debugfs(struct mt76x02_dev *dev);
-
 /* Init */
 struct mt76x02_dev *
 mt76x0_alloc_device(struct device *pdev,
Signature · 1 line
2.19.0
#5 lore raw

PATCH 5/6 mt76x0: use mt76x02_mac_work as stats handler

In reply to Lorenzo Bianconi

Use mt76x02_mac_work utility routine as stats workqueue handler and remove duplicated code. Moreover run mac stuck check in mt76x02_mac_work for client interfaces.
Remove no longer used avg_ampdu_len and mt76x02_mac_stats data structure in mt76x02_dev

---
 .../net/wireless/mediatek/mt76/mt76x0/init.c  |  3 +-
 .../net/wireless/mediatek/mt76/mt76x0/mac.c   | 68 -------------------
 .../wireless/mediatek/mt76/mt76x0/mt76x0.h    |  1 -
 drivers/net/wireless/mediatek/mt76/mt76x02.h  | 10 ---
 .../net/wireless/mediatek/mt76/mt76x02_mac.c  | 19 ++++++
 5 files changed, 20 insertions(+), 81 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x0/init.c +1 -2
index f90ef4d803d5..f5c7db9ca02a 100644
@@ -339,7 +339,6 @@ mt76x0_alloc_device(struct device *pdev,
 
 	dev = container_of(mdev, struct mt76x02_dev, mt76);
 	mutex_init(&dev->phy_mutex);
-	atomic_set(&dev->avg_ampdu_len, 1);
 
 	return dev;
 }
@@ -378,7 +377,7 @@ int mt76x0_register_device(struct mt76x02_dev *dev)
 
 	wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
 
-	INIT_DELAYED_WORK(&dev->mac_work, mt76x0_mac_work);
+	INIT_DELAYED_WORK(&dev->mac_work, mt76x02_mac_work);
 
 	ret = mt76_register_device(mdev, true, mt76x02_rates,
 				   ARRAY_SIZE(mt76x02_rates));
drivers/net/wireless/mediatek/mt76/mt76x0/mac.c +0 -68

74 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h +0 -1
index b9743b575099..85de821483cd 100644
@@ -69,7 +69,6 @@ void mt76x0_phy_set_txpower(struct mt76x02_dev *dev);
 void mt76x0_phy_calibrate(struct mt76x02_dev *dev, bool power_on);
 
 /* MAC */
-void mt76x0_mac_work(struct work_struct *work);
 void mt76x0_mac_set_protection(struct mt76x02_dev *dev, bool legacy_prot,
 				int ht_mode);
 void mt76x0_mac_set_short_preamble(struct mt76x02_dev *dev, bool short_preamb);
drivers/net/wireless/mediatek/mt76/mt76x02.h +0 -10
index 58721307d917..bdbe4bbf7a59 100644
@@ -28,14 +28,6 @@
 
 #define MT_CALIBRATE_INTERVAL	HZ
 
-struct mt76x02_mac_stats {
-	u64 rx_stat[6];
-	u64 tx_stat[6];
-	u64 aggr_stat[2];
-	u64 aggr_n[32];
-	u64 zero_len_del[2];
-};
-
 #define MT_MAX_CHAINS		2
 struct mt76x02_rx_freq_cal {
 	s8 high_gain[MT_MAX_CHAINS];
@@ -85,8 +77,6 @@ struct mt76x02_dev {
 	struct delayed_work cal_work;
 	struct delayed_work mac_work;
 
-	struct mt76x02_mac_stats stats;
-	atomic_t avg_ampdu_len;
 	u32 aggr_stats[32];
 
 	struct sk_buff *beacons[8];
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +19 -0
index c7666f4c432f..3896da690b83 100644
@@ -754,6 +754,21 @@ void mt76x02_update_channel(struct mt76_dev *mdev)
 }
 EXPORT_SYMBOL_GPL(mt76x02_update_channel);
 
+static void mt76x02_check_mac_err(struct mt76x02_dev *dev)
+{
+	u32 val = mt76_rr(dev, 0x10f4);
+
+	if (!(val & BIT(29)) || !(val & (BIT(7) | BIT(5))))
+		return;
+
+	dev_err(dev->mt76.dev, "mac specific condition occurred\n");
+
+	mt76_set(dev, MT_MAC_SYS_CTRL, MT_MAC_SYS_CTRL_RESET_CSR);
+	udelay(10);
+	mt76_clear(dev, MT_MAC_SYS_CTRL,
+		   MT_MAC_SYS_CTRL_ENABLE_TX | MT_MAC_SYS_CTRL_ENABLE_RX);
+}
+
 void mt76x02_mac_work(struct work_struct *work)
 {
 	struct mt76x02_dev *dev = container_of(work, struct mt76x02_dev,
@@ -768,6 +783,10 @@ void mt76x02_mac_work(struct work_struct *work)
 		dev->aggr_stats[idx++] += val >> 16;
 	}
 
+	/* XXX: check beacon stuck for ap mode */
+	if (!dev->beacon_mask)
+		mt76x02_check_mac_err(dev);
+
 	ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mac_work,
 				     MT_CALIBRATE_INTERVAL);
 }
Signature · 1 line
2.19.0
#6 lore raw

PATCH 6/6 mt76x2u: introduce mac workqueue support

In reply to Lorenzo Bianconi

Add mac workqueue support to mt76x2u driver in order to compute device statistics and add mac stuck routine

---
 drivers/net/wireless/mediatek/mt76/mt76x2/init.c     | 2 ++
 drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c | 1 -
 drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c | 1 +
 drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c | 2 ++
 4 files changed, 5 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt76x2/init.c +2 -0
index 3c73fdeaf30f..04790f84d7d4 100644
@@ -162,6 +162,8 @@ void mt76x2_init_device(struct mt76x02_dev *dev)
 {
 	struct ieee80211_hw *hw = mt76_hw(dev);
 
+	INIT_DELAYED_WORK(&dev->mac_work, mt76x02_mac_work);
+
 	hw->queues = 4;
 	hw->max_rates = 1;
 	hw->max_report_rates = 7;
drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c +0 -1
index 5b167aaaf7f7..b15c97e1dfb3 100644
@@ -467,7 +467,6 @@ int mt76x2_register_device(struct mt76x02_dev *dev)
 	int i, ret;
 
 	INIT_DELAYED_WORK(&dev->cal_work, mt76x2_phy_calibrate);
-	INIT_DELAYED_WORK(&dev->mac_work, mt76x02_mac_work);
 
 	mt76x2_init_device(dev);
 
drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c +1 -0
index dfc80ecfde92..b2388f506505 100644
@@ -297,6 +297,7 @@ void mt76x2u_stop_hw(struct mt76x02_dev *dev)
 {
 	mt76u_stop_stat_wk(&dev->mt76);
 	cancel_delayed_work_sync(&dev->cal_work);
+	cancel_delayed_work_sync(&dev->mac_work);
 	mt76x2u_mac_stop(dev);
 }
 
drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c +2 -0
index 1971a1b00038..25c43175e6e5 100644
@@ -27,6 +27,8 @@ static int mt76x2u_start(struct ieee80211_hw *hw)
 	if (ret)
 		goto out;
 
+	ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mac_work,
+				     MT_CALIBRATE_INTERVAL);
 	set_bit(MT76_STATE_RUNNING, &dev->mt76.state);
 
 out:
Signature · 1 line
2.19.0
maintainer Applied
#7 lore raw
In reply to Lorenzo Bianconi
Quoted 3 lines · Lorenzo Bianconi

Unify debugfs implementation between mt76x0 and mt76x2 drivers. Add get_survey support to mt76x0e driver
Add mac work support to mt76x2u driver

Applied, thanks.

- Felix