mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
mt76: store current channel survey_state in struct mt76_dev
Move mt76_channel_state() from mt76.h to mac80211.c Preparation for updating channel state from more places in the drivers/core Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
+19
-5
@@ -180,6 +180,7 @@ mt76_init_sband(struct mt76_dev *dev, struct mt76_sband *msband,
|
||||
sband->bitrates = rates;
|
||||
sband->n_bitrates = n_rates;
|
||||
dev->chandef.chan = &sband->channels[0];
|
||||
dev->chan_state = &msband->chan[0];
|
||||
|
||||
ht_cap = &sband->ht_cap;
|
||||
ht_cap->ht_supported = true;
|
||||
@@ -398,11 +399,25 @@ bool mt76_has_tx_pending(struct mt76_dev *dev)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mt76_has_tx_pending);
|
||||
|
||||
static struct mt76_channel_state *
|
||||
mt76_channel_state(struct mt76_dev *dev, struct ieee80211_channel *c)
|
||||
{
|
||||
struct mt76_sband *msband;
|
||||
int idx;
|
||||
|
||||
if (c->band == NL80211_BAND_2GHZ)
|
||||
msband = &dev->sband_2g;
|
||||
else
|
||||
msband = &dev->sband_5g;
|
||||
|
||||
idx = c - &msband->sband.channels[0];
|
||||
return &msband->chan[idx];
|
||||
}
|
||||
|
||||
void mt76_set_channel(struct mt76_dev *dev)
|
||||
{
|
||||
struct ieee80211_hw *hw = dev->hw;
|
||||
struct cfg80211_chan_def *chandef = &hw->conf.chandef;
|
||||
struct mt76_channel_state *state;
|
||||
bool offchannel = hw->conf.flags & IEEE80211_CONF_OFFCHANNEL;
|
||||
int timeout = HZ / 5;
|
||||
|
||||
@@ -412,14 +427,13 @@ void mt76_set_channel(struct mt76_dev *dev)
|
||||
dev->drv->update_survey(dev);
|
||||
|
||||
dev->chandef = *chandef;
|
||||
dev->chan_state = mt76_channel_state(dev, chandef->chan);
|
||||
|
||||
if (!offchannel)
|
||||
dev->main_chan = chandef->chan;
|
||||
|
||||
if (chandef->chan != dev->main_chan) {
|
||||
state = mt76_channel_state(dev, chandef->chan);
|
||||
memset(state, 0, sizeof(*state));
|
||||
}
|
||||
if (chandef->chan != dev->main_chan)
|
||||
memset(dev->chan_state, 0, sizeof(*dev->chan_state));
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mt76_set_channel);
|
||||
|
||||
|
||||
@@ -423,6 +423,7 @@ struct mt76_dev {
|
||||
struct cfg80211_chan_def chandef;
|
||||
struct ieee80211_channel *main_chan;
|
||||
|
||||
struct mt76_channel_state *chan_state;
|
||||
spinlock_t lock;
|
||||
spinlock_t cc_lock;
|
||||
|
||||
@@ -603,21 +604,6 @@ static inline u16 mt76_rev(struct mt76_dev *dev)
|
||||
#define mt76_queue_tx_cleanup(dev, ...) (dev)->mt76.queue_ops->tx_cleanup(&((dev)->mt76), __VA_ARGS__)
|
||||
#define mt76_queue_kick(dev, ...) (dev)->mt76.queue_ops->kick(&((dev)->mt76), __VA_ARGS__)
|
||||
|
||||
static inline struct mt76_channel_state *
|
||||
mt76_channel_state(struct mt76_dev *dev, struct ieee80211_channel *c)
|
||||
{
|
||||
struct mt76_sband *msband;
|
||||
int idx;
|
||||
|
||||
if (c->band == NL80211_BAND_2GHZ)
|
||||
msband = &dev->sband_2g;
|
||||
else
|
||||
msband = &dev->sband_5g;
|
||||
|
||||
idx = c - &msband->sband.channels[0];
|
||||
return &msband->chan[idx];
|
||||
}
|
||||
|
||||
struct mt76_dev *mt76_alloc_device(struct device *pdev, unsigned int size,
|
||||
const struct ieee80211_ops *ops,
|
||||
const struct mt76_driver_ops *drv_ops);
|
||||
|
||||
+1
-1
@@ -1491,7 +1491,7 @@ void mt7603_update_channel(struct mt76_dev *mdev)
|
||||
if (!test_bit(MT76_STATE_RUNNING, &dev->mt76.state))
|
||||
return;
|
||||
|
||||
state = mt76_channel_state(&dev->mt76, dev->mt76.chandef.chan);
|
||||
state = mdev->chan_state;
|
||||
busy = mt76_rr(dev, MT_MIB_STAT_PSCCA);
|
||||
|
||||
spin_lock_bh(&dev->mt76.cc_lock);
|
||||
|
||||
+1
-1
@@ -1269,7 +1269,7 @@ void mt7615_update_channel(struct mt76_dev *mdev)
|
||||
if (!test_bit(MT76_STATE_RUNNING, &mdev->state))
|
||||
return;
|
||||
|
||||
state = mt76_channel_state(mdev, mdev->chandef.chan);
|
||||
state = mdev->chan_state;
|
||||
/* TODO: add DBDC support */
|
||||
busy = mt76_get_field(dev, MT_MIB_SDR16(0), MT_MIB_BUSY_MASK);
|
||||
|
||||
|
||||
+1
-1
@@ -986,7 +986,7 @@ void mt76x02_update_channel(struct mt76_dev *mdev)
|
||||
struct mt76_channel_state *state;
|
||||
u32 active, busy;
|
||||
|
||||
state = mt76_channel_state(&dev->mt76, dev->mt76.chandef.chan);
|
||||
state = mdev->chan_state;
|
||||
|
||||
busy = mt76_rr(dev, MT_CH_BUSY);
|
||||
active = busy + mt76_rr(dev, MT_CH_IDLE);
|
||||
|
||||
Reference in New Issue
Block a user