Commit a782f8bf authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau
Browse files

mt76: move mac_work in mt76_core module



Move mac_work delayed_work and mac_work_count in mt76_phy since it is
used by all drivers. This is a preliminary patch to create a common mcu
library used by mt7615 and mt7921 drivers

Co-developed-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 7517ea01
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -583,6 +583,9 @@ struct mt76_phy {
#ifdef CONFIG_NL80211_TESTMODE
	struct mt76_testmode_data test;
#endif

	struct delayed_work mac_work;
	u8 mac_work_count;
};

struct mt76_dev {
@@ -623,7 +626,6 @@ struct mt76_dev {

	struct mt76_worker tx_worker;
	struct napi_struct tx_napi;
	struct delayed_work mac_work;

	wait_queue_head_t tx_wait;
	struct sk_buff_head status_list;
+1 −1
Original line number Diff line number Diff line
@@ -532,7 +532,7 @@ int mt7603_register_device(struct mt7603_dev *dev)
	spin_lock_init(&dev->sta_poll_lock);
	spin_lock_init(&dev->ps_lock);

	INIT_DELAYED_WORK(&dev->mt76.mac_work, mt7603_mac_work);
	INIT_DELAYED_WORK(&dev->mphy.mac_work, mt7603_mac_work);
	tasklet_setup(&dev->mt76.pre_tbtt_tasklet, mt7603_pre_tbtt_tasklet);

	dev->slottime = 9;
+7 −7
Original line number Diff line number Diff line
@@ -1788,7 +1788,7 @@ mt7603_false_cca_check(struct mt7603_dev *dev)
void mt7603_mac_work(struct work_struct *work)
{
	struct mt7603_dev *dev = container_of(work, struct mt7603_dev,
					      mt76.mac_work.work);
					      mphy.mac_work.work);
	bool reset = false;
	int i, idx;

@@ -1796,7 +1796,7 @@ void mt7603_mac_work(struct work_struct *work)

	mutex_lock(&dev->mt76.mutex);

	dev->mac_work_count++;
	dev->mphy.mac_work_count++;
	mt76_update_survey(&dev->mt76);
	mt7603_edcca_check(dev);

@@ -1807,7 +1807,7 @@ void mt7603_mac_work(struct work_struct *work)
		dev->mt76.aggr_stats[idx++] += val >> 16;
	}

	if (dev->mac_work_count == 10)
	if (dev->mphy.mac_work_count == 10)
		mt7603_false_cca_check(dev);

	if (mt7603_watchdog_check(dev, &dev->rx_pse_check,
@@ -1838,17 +1838,17 @@ void mt7603_mac_work(struct work_struct *work)
		dev->rx_dma_idx = ~0;
		memset(dev->tx_dma_idx, 0xff, sizeof(dev->tx_dma_idx));
		reset = true;
		dev->mac_work_count = 0;
		dev->mphy.mac_work_count = 0;
	}

	if (dev->mac_work_count >= 10)
		dev->mac_work_count = 0;
	if (dev->mphy.mac_work_count >= 10)
		dev->mphy.mac_work_count = 0;

	mutex_unlock(&dev->mt76.mutex);

	if (reset)
		mt7603_mac_watchdog_reset(dev);

	ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mt76.mac_work,
	ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mphy.mac_work,
				     msecs_to_jiffies(MT7603_WATCHDOG_TIME));
}
+5 −5
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ mt7603_start(struct ieee80211_hw *hw)
	mt7603_mac_start(dev);
	dev->mphy.survey_time = ktime_get_boottime();
	set_bit(MT76_STATE_RUNNING, &dev->mphy.state);
	mt7603_mac_work(&dev->mt76.mac_work.work);
	mt7603_mac_work(&dev->mphy.mac_work.work);

	return 0;
}
@@ -28,7 +28,7 @@ mt7603_stop(struct ieee80211_hw *hw)
	struct mt7603_dev *dev = hw->priv;

	clear_bit(MT76_STATE_RUNNING, &dev->mphy.state);
	cancel_delayed_work_sync(&dev->mt76.mac_work);
	cancel_delayed_work_sync(&dev->mphy.mac_work);
	mt7603_mac_stop(dev);
}

@@ -137,7 +137,7 @@ mt7603_set_channel(struct mt7603_dev *dev, struct cfg80211_chan_def *def)
	u8 bw = MT_BW_20;
	bool failed = false;

	cancel_delayed_work_sync(&dev->mt76.mac_work);
	cancel_delayed_work_sync(&dev->mphy.mac_work);
	tasklet_disable(&dev->mt76.pre_tbtt_tasklet);

	mutex_lock(&dev->mt76.mutex);
@@ -178,7 +178,7 @@ mt7603_set_channel(struct mt7603_dev *dev, struct cfg80211_chan_def *def)

	mt76_txq_schedule_all(&dev->mphy);

	ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mt76.mac_work,
	ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mphy.mac_work,
				     msecs_to_jiffies(MT7603_WATCHDOG_TIME));

	/* reset channel stats */
@@ -200,7 +200,7 @@ mt7603_set_channel(struct mt7603_dev *dev, struct cfg80211_chan_def *def)
	tasklet_enable(&dev->mt76.pre_tbtt_tasklet);

	if (failed)
		mt7603_mac_work(&dev->mt76.mac_work.work);
		mt7603_mac_work(&dev->mphy.mac_work.work);

	return ret;
}
+0 −2
Original line number Diff line number Diff line
@@ -132,8 +132,6 @@ struct mt7603_dev {

	spinlock_t ps_lock;

	u8 mac_work_count;

	u8 mcu_running;

	u8 ed_monitor_enabled;
Loading