Commit 011849e0 authored by Felix Fietkau's avatar Felix Fietkau
Browse files

mt76: move state from struct mt76_dev to mt76_phy



Allows keeping per-wiphy state separate

Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 5a95ca41
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -403,7 +403,10 @@ EXPORT_SYMBOL_GPL(mt76_free_device);

void mt76_rx(struct mt76_dev *dev, enum mt76_rxq_id q, struct sk_buff *skb)
{
	if (!test_bit(MT76_STATE_RUNNING, &dev->state)) {
	struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
	struct mt76_phy *phy = mt76_dev_phy(dev, status->ext_phy);

	if (!test_bit(MT76_STATE_RUNNING, &phy->state)) {
		dev_kfree_skb(skb);
		return;
	}
@@ -459,9 +462,6 @@ void mt76_update_survey(struct mt76_dev *dev)
{
	ktime_t cur_time;

	if (!test_bit(MT76_STATE_RUNNING, &dev->state))
		return;

	if (dev->drv->update_survey)
		dev->drv->update_survey(dev);

@@ -1063,17 +1063,17 @@ EXPORT_SYMBOL_GPL(mt76_get_rate);
void mt76_sw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
		  const u8 *mac)
{
	struct mt76_dev *dev = hw->priv;
	struct mt76_phy *phy = hw->priv;

	set_bit(MT76_SCANNING, &dev->state);
	set_bit(MT76_SCANNING, &phy->state);
}
EXPORT_SYMBOL_GPL(mt76_sw_scan);

void mt76_sw_scan_complete(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
{
	struct mt76_dev *dev = hw->priv;
	struct mt76_phy *phy = hw->priv;

	clear_bit(MT76_SCANNING, &dev->state);
	clear_bit(MT76_SCANNING, &phy->state);
}
EXPORT_SYMBOL_GPL(mt76_sw_scan_complete);

+11 −4
Original line number Diff line number Diff line
@@ -458,6 +458,8 @@ struct mt76_phy {
	struct ieee80211_hw *hw;
	struct mt76_dev *dev;

	unsigned long state;

	struct cfg80211_chan_def chandef;
	struct ieee80211_channel *main_chan;

@@ -518,7 +520,6 @@ struct mt76_dev {

	u8 macaddr[ETH_ALEN];
	u32 rev;
	unsigned long state;

	u32 aggr_stats[32];

@@ -660,12 +661,18 @@ void mt76_seq_puts_array(struct seq_file *file, const char *str,
int mt76_eeprom_init(struct mt76_dev *dev, int len);
void mt76_eeprom_override(struct mt76_dev *dev);

static inline struct mt76_phy *
mt76_dev_phy(struct mt76_dev *dev, bool phy_ext)
{
	if (phy_ext && dev->phy2)
		return dev->phy2;
	return &dev->phy;
}

static inline struct ieee80211_hw *
mt76_phy_hw(struct mt76_dev *dev, bool phy_ext)
{
	if (phy_ext && dev->phy2)
		return dev->phy2->hw;
	return dev->phy.hw;
	return mt76_dev_phy(dev, phy_ext)->hw;
}

static inline u8 *
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ irqreturn_t mt7603_irq_handler(int irq, void *dev_instance)
	intr = mt76_rr(dev, MT_INT_SOURCE_CSR);
	mt76_wr(dev, MT_INT_SOURCE_CSR, intr);

	if (!test_bit(MT76_STATE_INITIALIZED, &dev->mt76.state))
	if (!test_bit(MT76_STATE_INITIALIZED, &dev->mphy.state))
		return IRQ_NONE;

	intr &= dev->mt76.mmio.irqmask;
+1 −1
Original line number Diff line number Diff line
@@ -284,7 +284,7 @@ mt7603_init_hardware(struct mt7603_dev *dev)
	mt76_wr(dev, MT_WPDMA_GLO_CFG, 0x52000850);
	mt7603_mac_dma_start(dev);
	dev->rxfilter = mt76_rr(dev, MT_WF_RFCR);
	set_bit(MT76_STATE_INITIALIZED, &dev->mt76.state);
	set_bit(MT76_STATE_INITIALIZED, &dev->mphy.state);

	for (i = 0; i < MT7603_WTBL_SIZE; i++) {
		mt76_wr(dev, MT_PSE_RTA, MT_PSE_RTA_BUSY | MT_PSE_RTA_WRITE |
+2 −2
Original line number Diff line number Diff line
@@ -1389,7 +1389,7 @@ static void mt7603_mac_watchdog_reset(struct mt7603_dev *dev)
	int i;

	ieee80211_stop_queues(dev->mt76.hw);
	set_bit(MT76_RESET, &dev->mt76.state);
	set_bit(MT76_RESET, &dev->mphy.state);

	/* lock/unlock all queues to ensure that no tx is pending */
	mt76_txq_schedule_all(&dev->mphy);
@@ -1439,7 +1439,7 @@ static void mt7603_mac_watchdog_reset(struct mt7603_dev *dev)
	mt7603_irq_enable(dev, mask);

skip_dma_reset:
	clear_bit(MT76_RESET, &dev->mt76.state);
	clear_bit(MT76_RESET, &dev->mphy.state);
	mutex_unlock(&dev->mt76.mutex);

	tasklet_enable(&dev->mt76.tx_tasklet);
Loading