Commit 96747a51 authored by Felix Fietkau's avatar Felix Fietkau

mt76: move channel state to struct mt76_phy

Add support for an extra wiphy in mt76_set_channel and mt76_get_survey
This is preparation for supporting multiple wiphys per device to support the
concurrent dual-band feature of MT7615D
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 426e8e41
...@@ -156,9 +156,9 @@ static void mt76_init_stream_cap(struct mt76_dev *dev, ...@@ -156,9 +156,9 @@ static void mt76_init_stream_cap(struct mt76_dev *dev,
void mt76_set_stream_caps(struct mt76_dev *dev, bool vht) void mt76_set_stream_caps(struct mt76_dev *dev, bool vht)
{ {
if (dev->cap.has_2ghz) if (dev->cap.has_2ghz)
mt76_init_stream_cap(dev, &dev->sband_2g.sband, false); mt76_init_stream_cap(dev, &dev->phy.sband_2g.sband, false);
if (dev->cap.has_5ghz) if (dev->cap.has_5ghz)
mt76_init_stream_cap(dev, &dev->sband_5g.sband, vht); mt76_init_stream_cap(dev, &dev->phy.sband_5g.sband, vht);
} }
EXPORT_SYMBOL_GPL(mt76_set_stream_caps); EXPORT_SYMBOL_GPL(mt76_set_stream_caps);
...@@ -187,8 +187,8 @@ mt76_init_sband(struct mt76_dev *dev, struct mt76_sband *msband, ...@@ -187,8 +187,8 @@ mt76_init_sband(struct mt76_dev *dev, struct mt76_sband *msband,
sband->n_channels = n_chan; sband->n_channels = n_chan;
sband->bitrates = rates; sband->bitrates = rates;
sband->n_bitrates = n_rates; sband->n_bitrates = n_rates;
dev->chandef.chan = &sband->channels[0]; dev->phy.chandef.chan = &sband->channels[0];
dev->chan_state = &msband->chan[0]; dev->phy.chan_state = &msband->chan[0];
ht_cap = &sband->ht_cap; ht_cap = &sband->ht_cap;
ht_cap->ht_supported = true; ht_cap->ht_supported = true;
...@@ -223,9 +223,9 @@ static int ...@@ -223,9 +223,9 @@ static int
mt76_init_sband_2g(struct mt76_dev *dev, struct ieee80211_rate *rates, mt76_init_sband_2g(struct mt76_dev *dev, struct ieee80211_rate *rates,
int n_rates) int n_rates)
{ {
dev->hw->wiphy->bands[NL80211_BAND_2GHZ] = &dev->sband_2g.sband; dev->hw->wiphy->bands[NL80211_BAND_2GHZ] = &dev->phy.sband_2g.sband;
return mt76_init_sband(dev, &dev->sband_2g, return mt76_init_sband(dev, &dev->phy.sband_2g,
mt76_channels_2ghz, mt76_channels_2ghz,
ARRAY_SIZE(mt76_channels_2ghz), ARRAY_SIZE(mt76_channels_2ghz),
rates, n_rates, false); rates, n_rates, false);
...@@ -235,9 +235,9 @@ static int ...@@ -235,9 +235,9 @@ static int
mt76_init_sband_5g(struct mt76_dev *dev, struct ieee80211_rate *rates, mt76_init_sband_5g(struct mt76_dev *dev, struct ieee80211_rate *rates,
int n_rates, bool vht) int n_rates, bool vht)
{ {
dev->hw->wiphy->bands[NL80211_BAND_5GHZ] = &dev->sband_5g.sband; dev->hw->wiphy->bands[NL80211_BAND_5GHZ] = &dev->phy.sband_5g.sband;
return mt76_init_sband(dev, &dev->sband_5g, return mt76_init_sband(dev, &dev->phy.sband_5g,
mt76_channels_5ghz, mt76_channels_5ghz,
ARRAY_SIZE(mt76_channels_5ghz), ARRAY_SIZE(mt76_channels_5ghz),
rates, n_rates, vht); rates, n_rates, vht);
...@@ -428,23 +428,32 @@ bool mt76_has_tx_pending(struct mt76_dev *dev) ...@@ -428,23 +428,32 @@ bool mt76_has_tx_pending(struct mt76_dev *dev)
EXPORT_SYMBOL_GPL(mt76_has_tx_pending); EXPORT_SYMBOL_GPL(mt76_has_tx_pending);
static struct mt76_channel_state * static struct mt76_channel_state *
mt76_channel_state(struct mt76_dev *dev, struct ieee80211_channel *c) mt76_channel_state(struct mt76_phy *phy, struct ieee80211_channel *c)
{ {
struct mt76_sband *msband; struct mt76_sband *msband;
int idx; int idx;
if (c->band == NL80211_BAND_2GHZ) if (c->band == NL80211_BAND_2GHZ)
msband = &dev->sband_2g; msband = &phy->sband_2g;
else else
msband = &dev->sband_5g; msband = &phy->sband_5g;
idx = c - &msband->sband.channels[0]; idx = c - &msband->sband.channels[0];
return &msband->chan[idx]; return &msband->chan[idx];
} }
static void
mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time)
{
struct mt76_channel_state *state = phy->chan_state;
state->cc_active += ktime_to_us(ktime_sub(time,
phy->survey_time));
phy->survey_time = time;
}
void mt76_update_survey(struct mt76_dev *dev) void mt76_update_survey(struct mt76_dev *dev)
{ {
struct mt76_channel_state *state = dev->chan_state;
ktime_t cur_time; ktime_t cur_time;
if (!test_bit(MT76_STATE_RUNNING, &dev->state)) if (!test_bit(MT76_STATE_RUNNING, &dev->state))
...@@ -454,11 +463,13 @@ void mt76_update_survey(struct mt76_dev *dev) ...@@ -454,11 +463,13 @@ void mt76_update_survey(struct mt76_dev *dev)
dev->drv->update_survey(dev); dev->drv->update_survey(dev);
cur_time = ktime_get_boottime(); cur_time = ktime_get_boottime();
state->cc_active += ktime_to_us(ktime_sub(cur_time, mt76_update_survey_active_time(&dev->phy, cur_time);
dev->survey_time)); if (dev->phy2)
dev->survey_time = cur_time; mt76_update_survey_active_time(dev->phy2, cur_time);
if (dev->drv->drv_flags & MT_DRV_SW_RX_AIRTIME) { if (dev->drv->drv_flags & MT_DRV_SW_RX_AIRTIME) {
struct mt76_channel_state *state = dev->phy.chan_state;
spin_lock_bh(&dev->cc_lock); spin_lock_bh(&dev->cc_lock);
state->cc_bss_rx += dev->cur_cc_bss_rx; state->cc_bss_rx += dev->cur_cc_bss_rx;
dev->cur_cc_bss_rx = 0; dev->cur_cc_bss_rx = 0;
...@@ -467,9 +478,10 @@ void mt76_update_survey(struct mt76_dev *dev) ...@@ -467,9 +478,10 @@ void mt76_update_survey(struct mt76_dev *dev)
} }
EXPORT_SYMBOL_GPL(mt76_update_survey); EXPORT_SYMBOL_GPL(mt76_update_survey);
void mt76_set_channel(struct mt76_dev *dev) void mt76_set_channel(struct mt76_phy *phy)
{ {
struct ieee80211_hw *hw = dev->hw; struct mt76_dev *dev = phy->dev;
struct ieee80211_hw *hw = phy->hw;
struct cfg80211_chan_def *chandef = &hw->conf.chandef; struct cfg80211_chan_def *chandef = &hw->conf.chandef;
bool offchannel = hw->conf.flags & IEEE80211_CONF_OFFCHANNEL; bool offchannel = hw->conf.flags & IEEE80211_CONF_OFFCHANNEL;
int timeout = HZ / 5; int timeout = HZ / 5;
...@@ -477,21 +489,22 @@ void mt76_set_channel(struct mt76_dev *dev) ...@@ -477,21 +489,22 @@ void mt76_set_channel(struct mt76_dev *dev)
wait_event_timeout(dev->tx_wait, !mt76_has_tx_pending(dev), timeout); wait_event_timeout(dev->tx_wait, !mt76_has_tx_pending(dev), timeout);
mt76_update_survey(dev); mt76_update_survey(dev);
dev->chandef = *chandef; phy->chandef = *chandef;
dev->chan_state = mt76_channel_state(dev, chandef->chan); phy->chan_state = mt76_channel_state(phy, chandef->chan);
if (!offchannel) if (!offchannel)
dev->main_chan = chandef->chan; phy->main_chan = chandef->chan;
if (chandef->chan != dev->main_chan) if (chandef->chan != phy->main_chan)
memset(dev->chan_state, 0, sizeof(*dev->chan_state)); memset(phy->chan_state, 0, sizeof(*phy->chan_state));
} }
EXPORT_SYMBOL_GPL(mt76_set_channel); EXPORT_SYMBOL_GPL(mt76_set_channel);
int mt76_get_survey(struct ieee80211_hw *hw, int idx, int mt76_get_survey(struct ieee80211_hw *hw, int idx,
struct survey_info *survey) struct survey_info *survey)
{ {
struct mt76_dev *dev = hw->priv; struct mt76_phy *phy = hw->priv;
struct mt76_dev *dev = phy->dev;
struct mt76_sband *sband; struct mt76_sband *sband;
struct ieee80211_channel *chan; struct ieee80211_channel *chan;
struct mt76_channel_state *state; struct mt76_channel_state *state;
...@@ -501,10 +514,10 @@ int mt76_get_survey(struct ieee80211_hw *hw, int idx, ...@@ -501,10 +514,10 @@ int mt76_get_survey(struct ieee80211_hw *hw, int idx,
if (idx == 0 && dev->drv->update_survey) if (idx == 0 && dev->drv->update_survey)
mt76_update_survey(dev); mt76_update_survey(dev);
sband = &dev->sband_2g; sband = &phy->sband_2g;
if (idx >= sband->sband.n_channels) { if (idx >= sband->sband.n_channels) {
idx -= sband->sband.n_channels; idx -= sband->sband.n_channels;
sband = &dev->sband_5g; sband = &phy->sband_5g;
} }
if (idx >= sband->sband.n_channels) { if (idx >= sband->sband.n_channels) {
...@@ -513,13 +526,13 @@ int mt76_get_survey(struct ieee80211_hw *hw, int idx, ...@@ -513,13 +526,13 @@ int mt76_get_survey(struct ieee80211_hw *hw, int idx,
} }
chan = &sband->sband.channels[idx]; chan = &sband->sband.channels[idx];
state = mt76_channel_state(dev, chan); state = mt76_channel_state(phy, chan);
memset(survey, 0, sizeof(*survey)); memset(survey, 0, sizeof(*survey));
survey->channel = chan; survey->channel = chan;
survey->filled = SURVEY_INFO_TIME | SURVEY_INFO_TIME_BUSY; survey->filled = SURVEY_INFO_TIME | SURVEY_INFO_TIME_BUSY;
survey->filled |= dev->drv->survey_flags; survey->filled |= dev->drv->survey_flags;
if (chan == dev->main_chan) { if (chan == phy->main_chan) {
survey->filled |= SURVEY_INFO_IN_USE; survey->filled |= SURVEY_INFO_IN_USE;
if (dev->drv->drv_flags & MT_DRV_SW_RX_AIRTIME) if (dev->drv->drv_flags & MT_DRV_SW_RX_AIRTIME)
...@@ -1027,11 +1040,11 @@ int mt76_get_rate(struct mt76_dev *dev, ...@@ -1027,11 +1040,11 @@ int mt76_get_rate(struct mt76_dev *dev,
int i, offset = 0, len = sband->n_bitrates; int i, offset = 0, len = sband->n_bitrates;
if (cck) { if (cck) {
if (sband == &dev->sband_5g.sband) if (sband == &dev->phy.sband_5g.sband)
return 0; return 0;
idx &= ~BIT(2); /* short preamble */ idx &= ~BIT(2); /* short preamble */
} else if (sband == &dev->sband_2g.sband) { } else if (sband == &dev->phy.sband_2g.sband) {
offset = 4; offset = 4;
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#define MT_SKB_HEAD_LEN 128 #define MT_SKB_HEAD_LEN 128
struct mt76_dev; struct mt76_dev;
struct mt76_phy;
struct mt76_wcid; struct mt76_wcid;
struct mt76_reg_pair { struct mt76_reg_pair {
...@@ -456,6 +457,15 @@ struct mt76_rx_status { ...@@ -456,6 +457,15 @@ struct mt76_rx_status {
struct mt76_phy { struct mt76_phy {
struct ieee80211_hw *hw; struct ieee80211_hw *hw;
struct mt76_dev *dev; struct mt76_dev *dev;
struct cfg80211_chan_def chandef;
struct ieee80211_channel *main_chan;
struct mt76_channel_state *chan_state;
ktime_t survey_time;
struct mt76_sband sband_2g;
struct mt76_sband sband_5g;
}; };
struct mt76_dev { struct mt76_dev {
...@@ -464,10 +474,7 @@ struct mt76_dev { ...@@ -464,10 +474,7 @@ struct mt76_dev {
struct mt76_phy *phy2; struct mt76_phy *phy2;
struct ieee80211_hw *hw; struct ieee80211_hw *hw;
struct cfg80211_chan_def chandef;
struct ieee80211_channel *main_chan;
struct mt76_channel_state *chan_state;
spinlock_t lock; spinlock_t lock;
spinlock_t cc_lock; spinlock_t cc_lock;
...@@ -522,8 +529,6 @@ struct mt76_dev { ...@@ -522,8 +529,6 @@ struct mt76_dev {
int beacon_int; int beacon_int;
u8 beacon_mask; u8 beacon_mask;
struct mt76_sband sband_2g;
struct mt76_sband sband_5g;
struct debugfs_blob_wrapper eeprom; struct debugfs_blob_wrapper eeprom;
struct debugfs_blob_wrapper otp; struct debugfs_blob_wrapper otp;
struct mt76_hw_cap cap; struct mt76_hw_cap cap;
...@@ -543,8 +548,6 @@ struct mt76_dev { ...@@ -543,8 +548,6 @@ struct mt76_dev {
u8 csa_complete; u8 csa_complete;
ktime_t survey_time;
u32 rxfilter; u32 rxfilter;
union { union {
...@@ -750,7 +753,7 @@ void mt76_release_buffered_frames(struct ieee80211_hw *hw, ...@@ -750,7 +753,7 @@ void mt76_release_buffered_frames(struct ieee80211_hw *hw,
enum ieee80211_frame_release_type reason, enum ieee80211_frame_release_type reason,
bool more_data); bool more_data);
bool mt76_has_tx_pending(struct mt76_dev *dev); bool mt76_has_tx_pending(struct mt76_dev *dev);
void mt76_set_channel(struct mt76_dev *dev); void mt76_set_channel(struct mt76_phy *phy);
void mt76_update_survey(struct mt76_dev *dev); void mt76_update_survey(struct mt76_dev *dev);
int mt76_get_survey(struct ieee80211_hw *hw, int idx, int mt76_get_survey(struct ieee80211_hw *hw, int idx,
struct survey_info *survey); struct survey_info *survey);
......
...@@ -573,7 +573,7 @@ int mt7603_register_device(struct mt7603_dev *dev) ...@@ -573,7 +573,7 @@ int mt7603_register_device(struct mt7603_dev *dev)
return ret; return ret;
mt7603_init_debugfs(dev); mt7603_init_debugfs(dev);
mt7603_init_txpower(dev, &dev->mt76.sband_2g.sband); mt7603_init_txpower(dev, &dev->mphy.sband_2g.sband);
return 0; return 0;
} }
......
...@@ -53,7 +53,7 @@ void mt7603_mac_set_timing(struct mt7603_dev *dev) ...@@ -53,7 +53,7 @@ void mt7603_mac_set_timing(struct mt7603_dev *dev)
int sifs; int sifs;
u32 val; u32 val;
if (dev->mt76.chandef.chan->band == NL80211_BAND_5GHZ) if (dev->mphy.chandef.chan->band == NL80211_BAND_5GHZ)
sifs = 16; sifs = 16;
else else
sifs = 10; sifs = 10;
...@@ -456,7 +456,7 @@ void mt7603_mac_sta_poll(struct mt7603_dev *dev) ...@@ -456,7 +456,7 @@ void mt7603_mac_sta_poll(struct mt7603_dev *dev)
return; return;
spin_lock_bh(&dev->mt76.cc_lock); spin_lock_bh(&dev->mt76.cc_lock);
dev->mt76.chan_state->cc_tx += total_airtime; dev->mphy.chan_state->cc_tx += total_airtime;
spin_unlock_bh(&dev->mt76.cc_lock); spin_unlock_bh(&dev->mt76.cc_lock);
} }
...@@ -502,7 +502,7 @@ mt7603_mac_fill_rx(struct mt7603_dev *dev, struct sk_buff *skb) ...@@ -502,7 +502,7 @@ mt7603_mac_fill_rx(struct mt7603_dev *dev, struct sk_buff *skb)
memset(status, 0, sizeof(*status)); memset(status, 0, sizeof(*status));
i = FIELD_GET(MT_RXD1_NORMAL_CH_FREQ, rxd1); i = FIELD_GET(MT_RXD1_NORMAL_CH_FREQ, rxd1);
sband = (i & 1) ? &dev->mt76.sband_5g.sband : &dev->mt76.sband_2g.sband; sband = (i & 1) ? &dev->mphy.sband_5g.sband : &dev->mphy.sband_2g.sband;
i >>= 1; i >>= 1;
idx = FIELD_GET(MT_RXD2_NORMAL_WLAN_IDX, rxd2); idx = FIELD_GET(MT_RXD2_NORMAL_WLAN_IDX, rxd2);
...@@ -668,7 +668,7 @@ mt7603_mac_tx_rate_val(struct mt7603_dev *dev, ...@@ -668,7 +668,7 @@ mt7603_mac_tx_rate_val(struct mt7603_dev *dev,
*bw = 1; *bw = 1;
} else { } else {
const struct ieee80211_rate *r; const struct ieee80211_rate *r;
int band = dev->mt76.chandef.chan->band; int band = dev->mphy.chandef.chan->band;
u16 val; u16 val;
nss = 1; nss = 1;
...@@ -1156,10 +1156,10 @@ mt7603_fill_txs(struct mt7603_dev *dev, struct mt7603_sta *sta, ...@@ -1156,10 +1156,10 @@ mt7603_fill_txs(struct mt7603_dev *dev, struct mt7603_sta *sta,
cck = true; cck = true;
/* fall through */ /* fall through */
case MT_PHY_TYPE_OFDM: case MT_PHY_TYPE_OFDM:
if (dev->mt76.chandef.chan->band == NL80211_BAND_5GHZ) if (dev->mphy.chandef.chan->band == NL80211_BAND_5GHZ)
sband = &dev->mt76.sband_5g.sband; sband = &dev->mphy.sband_5g.sband;
else else
sband = &dev->mt76.sband_2g.sband; sband = &dev->mphy.sband_2g.sband;
final_rate &= GENMASK(5, 0); final_rate &= GENMASK(5, 0);
final_rate = mt76_get_rate(&dev->mt76, sband, final_rate, final_rate = mt76_get_rate(&dev->mt76, sband, final_rate,
cck); cck);
...@@ -1574,7 +1574,7 @@ void mt7603_update_channel(struct mt76_dev *mdev) ...@@ -1574,7 +1574,7 @@ void mt7603_update_channel(struct mt76_dev *mdev)
struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76); struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76);
struct mt76_channel_state *state; struct mt76_channel_state *state;
state = mdev->chan_state; state = mdev->phy.chan_state;
state->cc_busy += mt76_rr(dev, MT_MIB_STAT_CCA); state->cc_busy += mt76_rr(dev, MT_MIB_STAT_CCA);
} }
......
...@@ -15,7 +15,7 @@ mt7603_start(struct ieee80211_hw *hw) ...@@ -15,7 +15,7 @@ mt7603_start(struct ieee80211_hw *hw)
mt7603_mac_reset_counters(dev); mt7603_mac_reset_counters(dev);
mt7603_mac_start(dev); mt7603_mac_start(dev);
dev->mt76.survey_time = ktime_get_boottime(); dev->mphy.survey_time = ktime_get_boottime();
set_bit(MT76_STATE_RUNNING, &dev->mt76.state); set_bit(MT76_STATE_RUNNING, &dev->mt76.state);
mt7603_mac_work(&dev->mt76.mac_work.work); mt7603_mac_work(&dev->mt76.mac_work.work);
...@@ -146,13 +146,13 @@ mt7603_set_channel(struct mt7603_dev *dev, struct cfg80211_chan_def *def) ...@@ -146,13 +146,13 @@ mt7603_set_channel(struct mt7603_dev *dev, struct cfg80211_chan_def *def)
set_bit(MT76_RESET, &dev->mt76.state); set_bit(MT76_RESET, &dev->mt76.state);
mt7603_beacon_set_timer(dev, -1, 0); mt7603_beacon_set_timer(dev, -1, 0);
mt76_set_channel(&dev->mt76); mt76_set_channel(&dev->mphy);
mt7603_mac_stop(dev); mt7603_mac_stop(dev);
if (def->width == NL80211_CHAN_WIDTH_40) if (def->width == NL80211_CHAN_WIDTH_40)
bw = MT_BW_40; bw = MT_BW_40;
dev->mt76.chandef = *def; dev->mphy.chandef = *def;
mt76_rmw_field(dev, MT_AGG_BWCR, MT_AGG_BWCR_BW, bw); mt76_rmw_field(dev, MT_AGG_BWCR, MT_AGG_BWCR_BW, bw);
ret = mt7603_mcu_set_channel(dev); ret = mt7603_mcu_set_channel(dev);
if (ret) { if (ret) {
...@@ -190,7 +190,7 @@ mt7603_set_channel(struct mt7603_dev *dev, struct cfg80211_chan_def *def) ...@@ -190,7 +190,7 @@ mt7603_set_channel(struct mt7603_dev *dev, struct cfg80211_chan_def *def)
mt76_rr(dev, MT_MIB_STAT_PSCCA); mt76_rr(dev, MT_MIB_STAT_PSCCA);
mt7603_cca_stats_reset(dev); mt7603_cca_stats_reset(dev);
dev->mt76.survey_time = ktime_get_boottime(); dev->mphy.survey_time = ktime_get_boottime();
mt7603_init_edcca(dev); mt7603_init_edcca(dev);
......
...@@ -397,7 +397,7 @@ static int mt7603_mcu_set_tx_power(struct mt7603_dev *dev) ...@@ -397,7 +397,7 @@ static int mt7603_mcu_set_tx_power(struct mt7603_dev *dev)
u8 temp_comp_power[17]; u8 temp_comp_power[17];
u8 reserved; u8 reserved;
} req = { } req = {
.center_channel = dev->mt76.chandef.chan->hw_value, .center_channel = dev->mphy.chandef.chan->hw_value,
#define EEP_VAL(n) ((u8 *)dev->mt76.eeprom.data)[n] #define EEP_VAL(n) ((u8 *)dev->mt76.eeprom.data)[n]
.tssi = EEP_VAL(MT_EE_NIC_CONF_1 + 1), .tssi = EEP_VAL(MT_EE_NIC_CONF_1 + 1),
.temp_comp = EEP_VAL(MT_EE_NIC_CONF_1), .temp_comp = EEP_VAL(MT_EE_NIC_CONF_1),
...@@ -430,7 +430,7 @@ static int mt7603_mcu_set_tx_power(struct mt7603_dev *dev) ...@@ -430,7 +430,7 @@ static int mt7603_mcu_set_tx_power(struct mt7603_dev *dev)
int mt7603_mcu_set_channel(struct mt7603_dev *dev) int mt7603_mcu_set_channel(struct mt7603_dev *dev)
{ {
struct cfg80211_chan_def *chandef = &dev->mt76.chandef; struct cfg80211_chan_def *chandef = &dev->mphy.chandef;
struct ieee80211_hw *hw = mt76_hw(dev); struct ieee80211_hw *hw = mt76_hw(dev);
int n_chains = hweight8(dev->mt76.antenna_mask); int n_chains = hweight8(dev->mt76.antenna_mask);
struct { struct {
...@@ -452,7 +452,7 @@ int mt7603_mcu_set_channel(struct mt7603_dev *dev) ...@@ -452,7 +452,7 @@ int mt7603_mcu_set_channel(struct mt7603_dev *dev)
s8 tx_power; s8 tx_power;
int i, ret; int i, ret;
if (dev->mt76.chandef.width == NL80211_CHAN_WIDTH_40) { if (dev->mphy.chandef.width == NL80211_CHAN_WIDTH_40) {
req.bw = MT_BW_40; req.bw = MT_BW_40;
if (chandef->center_freq1 > chandef->chan->center_freq) if (chandef->center_freq1 > chandef->chan->center_freq)
req.center_chan += 2; req.center_chan += 2;
......
...@@ -247,7 +247,7 @@ mt7615_regd_notifier(struct wiphy *wiphy, ...@@ -247,7 +247,7 @@ mt7615_regd_notifier(struct wiphy *wiphy,
{ {
struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
struct mt7615_dev *dev = hw->priv; struct mt7615_dev *dev = hw->priv;
struct cfg80211_chan_def *chandef = &dev->mt76.chandef; struct cfg80211_chan_def *chandef = &dev->mphy.chandef;
if (request->dfs_region == dev->mt76.region) if (request->dfs_region == dev->mt76.region)
return; return;
...@@ -296,9 +296,9 @@ int mt7615_register_device(struct mt7615_dev *dev) ...@@ -296,9 +296,9 @@ int mt7615_register_device(struct mt7615_dev *dev)
ieee80211_hw_set(hw, TX_STATUS_NO_AMPDU_LEN); ieee80211_hw_set(hw, TX_STATUS_NO_AMPDU_LEN);
dev->mt76.sband_2g.sband.ht_cap.cap |= IEEE80211_HT_CAP_LDPC_CODING; dev->mphy.sband_2g.sband.ht_cap.cap |= IEEE80211_HT_CAP_LDPC_CODING;
dev->mt76.sband_5g.sband.ht_cap.cap |= IEEE80211_HT_CAP_LDPC_CODING; dev->mphy.sband_5g.sband.ht_cap.cap |= IEEE80211_HT_CAP_LDPC_CODING;
dev->mt76.sband_5g.sband.vht_cap.cap |= dev->mphy.sband_5g.sband.vht_cap.cap |=
IEEE80211_VHT_CAP_SHORT_GI_160 | IEEE80211_VHT_CAP_SHORT_GI_160 |
IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 | IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 |
IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK |
...@@ -310,8 +310,8 @@ int mt7615_register_device(struct mt7615_dev *dev) ...@@ -310,8 +310,8 @@ int mt7615_register_device(struct mt7615_dev *dev)
if (ret) if (ret)
return ret; return ret;
mt7615_init_txpower(dev, &dev->mt76.sband_2g.sband); mt7615_init_txpower(dev, &dev->mphy.sband_2g.sband);
mt7615_init_txpower(dev, &dev->mt76.sband_5g.sband); mt7615_init_txpower(dev, &dev->mphy.sband_5g.sband);
hw->max_tx_fragments = MT_TXP_MAX_BUF_NUM; hw->max_tx_fragments = MT_TXP_MAX_BUF_NUM;
......
...@@ -92,12 +92,12 @@ int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb) ...@@ -92,12 +92,12 @@ int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb)
} }
/* TODO: properly support DBDC */ /* TODO: properly support DBDC */
status->freq = dev->mt76.chandef.chan->center_freq; status->freq = dev->mphy.chandef.chan->center_freq;
status->band = dev->mt76.chandef.chan->band; status->band = dev->mphy.chandef.chan->band;
if (status->band == NL80211_BAND_5GHZ) if (status->band == NL80211_BAND_5GHZ)
sband = &dev->mt76.sband_5g.sband; sband = &dev->mphy.sband_5g.sband;
else else
sband = &dev->mt76.sband_2g.sband; sband = &dev->mphy.sband_2g.sband;
if (rxd2 & MT_RXD2_NORMAL_FCS_ERR) if (rxd2 & MT_RXD2_NORMAL_FCS_ERR)
status->flag |= RX_FLAG_FAILED_FCS_CRC; status->flag |= RX_FLAG_FAILED_FCS_CRC;
...@@ -319,7 +319,7 @@ mt7615_mac_tx_rate_val(struct mt7615_dev *dev, ...@@ -319,7 +319,7 @@ mt7615_mac_tx_rate_val(struct mt7615_dev *dev,
*bw = 1; *bw = 1;
} else { } else {
const struct ieee80211_rate *r; const struct ieee80211_rate *r;
int band = dev->mt76.chandef.chan->band; int band = dev->mphy.chandef.chan->band;
u16 val; u16 val;
nss = 1; nss = 1;
...@@ -1059,10 +1059,10 @@ static bool mt7615_fill_txs(struct mt7615_dev *dev, struct mt7615_sta *sta, ...@@ -1059,10 +1059,10 @@ static bool mt7615_fill_txs(struct mt7615_dev *dev, struct mt7615_sta *sta,
cck = true; cck = true;
/* fall through */ /* fall through */
case MT_PHY_TYPE_OFDM: case MT_PHY_TYPE_OFDM:
if (dev->mt76.chandef.chan->band == NL80211_BAND_5GHZ) if (dev->mphy.chandef.chan->band == NL80211_BAND_5GHZ)
sband = &dev->mt76.sband_5g.sband; sband = &dev->mphy.sband_5g.sband;
else else
sband = &dev->mt76.sband_2g.sband; sband = &dev->mphy.sband_2g.sband;
final_rate &= MT_TX_RATE_IDX; final_rate &= MT_TX_RATE_IDX;
final_rate = mt76_get_rate(&dev->mt76, sband, final_rate, final_rate = mt76_get_rate(&dev->mt76, sband, final_rate,
cck); cck);
...@@ -1383,7 +1383,7 @@ void mt7615_update_channel(struct mt76_dev *mdev) ...@@ -1383,7 +1383,7 @@ void mt7615_update_channel(struct mt76_dev *mdev)
obss_time = mt76_get_field(dev, MT_WF_RMAC_MIB_TIME5, obss_time = mt76_get_field(dev, MT_WF_RMAC_MIB_TIME5,
MT_MIB_OBSSTIME_MASK); MT_MIB_OBSSTIME_MASK);
state = mdev->chan_state; state = mdev->phy.chan_state;
state->cc_busy += busy_time; state->cc_busy += busy_time;
state->cc_tx += tx_time; state->cc_tx += tx_time;
state->cc_rx += rx_time + obss_time; state->cc_rx += rx_time + obss_time;
...@@ -1423,7 +1423,7 @@ void mt7615_mac_work(struct work_struct *work) ...@@ -1423,7 +1423,7 @@ void mt7615_mac_work(struct work_struct *work)
int mt7615_dfs_stop_radar_detector(struct mt7615_dev *dev) int mt7615_dfs_stop_radar_detector(struct mt7615_dev *dev)
{ {
struct cfg80211_chan_def *chandef = &dev->mt76.chandef; struct cfg80211_chan_def *chandef = &dev->mphy.chandef;
int err; int err;
err = mt7615_mcu_rdd_cmd(dev, RDD_STOP, MT_HW_RDD0, err = mt7615_mcu_rdd_cmd(dev, RDD_STOP, MT_HW_RDD0,
...@@ -1452,7 +1452,7 @@ static int mt7615_dfs_start_rdd(struct mt7615_dev *dev, int chain) ...@@ -1452,7 +1452,7 @@ static int mt7615_dfs_start_rdd(struct mt7615_dev *dev, int chain)
int mt7615_dfs_start_radar_detector(struct mt7615_dev *dev) int mt7615_dfs_start_radar_detector(struct mt7615_dev *dev)
{ {
struct cfg80211_chan_def *chandef = &dev->mt76.chandef; struct cfg80211_chan_def *chandef = &dev->mphy.chandef;
int err; int err;
/* start CAC */ /* start CAC */
...@@ -1479,7 +1479,7 @@ int mt7615_dfs_start_radar_detector(struct mt7615_dev *dev) ...@@ -1479,7 +1479,7 @@ int mt7615_dfs_start_radar_detector(struct mt7615_dev *dev)
int mt7615_dfs_init_radar_detector(struct mt7615_dev *dev) int mt7615_dfs_init_radar_detector(struct mt7615_dev *dev)
{ {
struct cfg80211_chan_def *chandef = &dev->mt76.chandef; struct cfg80211_chan_def *chandef = &dev->mphy.chandef;
int err; int err;
if (dev->mt76.region == NL80211_DFS_UNSET) if (dev->mt76.region == NL80211_DFS_UNSET)
......
...@@ -18,7 +18,7 @@ static int mt7615_start(struct ieee80211_hw *hw) ...@@ -18,7 +18,7 @@ static int mt7615_start(struct ieee80211_hw *hw)
mt7615_mac_reset_counters(dev); mt7615_mac_reset_counters(dev);
dev->mt76.survey_time = ktime_get_boottime(); dev->mphy.survey_time = ktime_get_boottime();
set_bit(MT76_STATE_RUNNING, &dev->mt76.state); set_bit(MT76_STATE_RUNNING, &dev->mt76.state);
ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mt76.mac_work, ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mt76.mac_work,
MT7615_WATCHDOG_TIME); MT7615_WATCHDOG_TIME);
...@@ -155,7 +155,7 @@ static int mt7615_set_channel(struct mt7615_dev *dev) ...@@ -155,7 +155,7 @@ static int mt7615_set_channel(struct mt7615_dev *dev)
mt7615_dfs_check_channel(dev); mt7615_dfs_check_channel(dev);
mt76_set_channel(&dev->mt76); mt76_set_channel(&dev->mphy);
ret = mt7615_mcu_set_channel(dev); ret = mt7615_mcu_set_channel(dev);
if (ret) if (ret)
...@@ -163,7 +163,7 @@ static int mt7615_set_channel(struct mt7615_dev *dev) ...@@ -163,7 +163,7 @@ static int mt7615_set_channel(struct mt7615_dev *dev)
ret = mt7615_dfs_init_radar_detector(dev); ret = mt7615_dfs_init_radar_detector(dev);
mt7615_mac_cca_stats_reset(dev); mt7615_mac_cca_stats_reset(dev);
dev->mt76.survey_time = ktime_get_boottime(); dev->mphy.survey_time = ktime_get_boottime();
mt7615_mac_reset_counters(dev); mt7615_mac_reset_counters(dev);
......
...@@ -1159,7 +1159,7 @@ int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif, ...@@ -1159,7 +1159,7 @@ int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif,
int mt7615_mcu_set_tx_power(struct mt7615_dev *dev) int mt7615_mcu_set_tx_power(struct mt7615_dev *dev)
{ {
int i, ret, n_chains = hweight8(dev->mt76.antenna_mask); int i, ret, n_chains = hweight8(dev->mt76.antenna_mask);
struct cfg80211_chan_def *chandef = &dev->mt76.chandef; struct cfg80211_chan_def *chandef = &dev->mphy.chandef;
int freq = chandef->center_freq1, len, target_chains; int freq = chandef->center_freq1, len, target_chains;
u8 *req, *data, *eep = (u8 *)dev->mt76.eeprom.data; u8 *req, *data, *eep = (u8 *)dev->mt76.eeprom.data;
enum nl80211_band band = chandef->chan->band; enum nl80211_band band = chandef->chan->band;
...@@ -1276,7 +1276,7 @@ int mt7615_mcu_rdd_send_pattern(struct mt7615_dev *dev) ...@@ -1276,7 +1276,7 @@ int mt7615_mcu_rdd_send_pattern(struct mt7615_dev *dev)
int mt7615_mcu_set_channel(struct mt7615_dev *dev) int mt7615_mcu_set_channel(struct mt7615_dev *dev)
{ {
struct cfg80211_chan_def *chandef = &dev->mt76.chandef; struct cfg80211_chan_def *chandef = &dev->mphy.chandef;
int freq1 = chandef->center_freq1, freq2 = chandef->center_freq2; int freq1 = chandef->center_freq1, freq2 = chandef->center_freq2;
struct { struct {
u8 control_chan; u8 control_chan;
...@@ -1313,7 +1313,7 @@ int mt7615_mcu_set_channel(struct mt7615_dev *dev) ...@@ -1313,7 +1313,7 @@ int mt7615_mcu_set_channel(struct mt7615_dev *dev)
else else
req.switch_reason = CH_SWITCH_NORMAL; req.switch_reason = CH_SWITCH_NORMAL;
switch (dev->mt76.chandef.width) { switch (dev->mphy.chandef.width) {
case NL80211_CHAN_WIDTH_40: case NL80211_CHAN_WIDTH_40:
req.bw = CMD_CBW_40MHZ; req.bw = CMD_CBW_40MHZ;
break; break;
......
...@@ -221,8 +221,8 @@ static inline bool is_mt7622(struct mt76_dev *dev) ...@@ -221,8 +221,8 @@ static inline bool is_mt7622(struct mt76_dev *dev)
static inline void mt7615_dfs_check_channel(struct mt7615_dev *dev) static inline void mt7615_dfs_check_channel(struct mt7615_dev *dev)
{ {
enum nl80211_chan_width width = dev->mt76.chandef.width; enum nl80211_chan_width width = dev->mphy.chandef.width;
u32 freq = dev->mt76.chandef.chan->center_freq; u32 freq = dev->mphy.chandef.chan->center_freq;
struct ieee80211_hw *hw = mt76_hw(dev); struct ieee80211_hw *hw = mt76_hw(dev);
if (hw->conf.chandef.chan->center_freq != freq || if (hw->conf.chandef.chan->center_freq != freq ||
......
...@@ -109,7 +109,7 @@ static void mt76x0_set_freq_offset(struct mt76x02_dev *dev) ...@@ -109,7 +109,7 @@ static void mt76x0_set_freq_offset(struct mt76x02_dev *dev)
void mt76x0_read_rx_gain(struct mt76x02_dev *dev) void mt76x0_read_rx_gain(struct mt76x02_dev *dev)
{ {
struct ieee80211_channel *chan = dev->mt76.chandef.chan; struct ieee80211_channel *chan = dev->mphy.chandef.chan;
struct mt76x02_rx_freq_cal *caldata = &dev->cal.rx; struct mt76x02_rx_freq_cal *caldata = &dev->cal.rx;
s8 val, lna_5g[3], lna_2g; s8 val, lna_5g[3], lna_2g;
u16 rssi_offset; u16 rssi_offset;
...@@ -129,7 +129,7 @@ void mt76x0_read_rx_gain(struct mt76x02_dev *dev) ...@@ -129,7 +129,7 @@ void mt76x0_read_rx_gain(struct mt76x02_dev *dev)
static s8 mt76x0_get_delta(struct mt76x02_dev *dev) static s8 mt76x0_get_delta(struct mt76x02_dev *dev)
{ {
struct cfg80211_chan_def *chandef = &dev->mt76.chandef; struct cfg80211_chan_def *chandef = &dev->mphy.chandef;
u8 val; u8 val;
if (chandef->width == NL80211_CHAN_WIDTH_80) { if (chandef->width == NL80211_CHAN_WIDTH_80) {
......
...@@ -264,12 +264,12 @@ int mt76x0_register_device(struct mt76x02_dev *dev) ...@@ -264,12 +264,12 @@ int mt76x0_register_device(struct mt76x02_dev *dev)
if (dev->mt76.cap.has_5ghz) { if (dev->mt76.cap.has_5ghz) {
/* overwrite unsupported features */ /* overwrite unsupported features */
mt76x0_vht_cap_mask(&dev->mt76.sband_5g.sband); mt76x0_vht_cap_mask(&dev->mphy.sband_5g.sband);
mt76x0_init_txpower(dev, &dev->mt76.sband_5g.sband); mt76x0_init_txpower(dev, &dev->mphy.sband_5g.sband);
} }
if (dev->mt76.cap.has_2ghz) if (dev->mt76.cap.has_2ghz)
mt76x0_init_txpower(dev, &dev->mt76.sband_2g.sband); mt76x0_init_txpower(dev, &dev->mphy.sband_2g.sband);
mt76x02_init_debugfs(dev); mt76x02_init_debugfs(dev);
......
...@@ -16,7 +16,7 @@ mt76x0_set_channel(struct mt76x02_dev *dev, struct cfg80211_chan_def *chandef) ...@@ -16,7 +16,7 @@ mt76x0_set_channel(struct mt76x02_dev *dev, struct cfg80211_chan_def *chandef)
if (mt76_is_mmio(&dev->mt76)) if (mt76_is_mmio(&dev->mt76))
tasklet_disable(&dev->dfs_pd.dfs_tasklet); tasklet_disable(&dev->dfs_pd.dfs_tasklet);
mt76_set_channel(&dev->mt76); mt76_set_channel(&dev->mphy);
mt76x0_phy_set_channel(dev, chandef); mt76x0_phy_set_channel(dev, chandef);
mt76x02_mac_cc_reset(dev); mt76x02_mac_cc_reset(dev);
......
...@@ -502,7 +502,7 @@ mt76x0_phy_bbp_set_bw(struct mt76x02_dev *dev, enum nl80211_chan_width width) ...@@ -502,7 +502,7 @@ mt76x0_phy_bbp_set_bw(struct mt76x02_dev *dev, enum nl80211_chan_width width)
static void mt76x0_phy_tssi_dc_calibrate(struct mt76x02_dev *dev) static void mt76x0_phy_tssi_dc_calibrate(struct mt76x02_dev *dev)
{ {
struct ieee80211_channel *chan = dev->mt76.chandef.chan; struct ieee80211_channel *chan = dev->mphy.chandef.chan;
u32 val; u32 val;
if (chan->band == NL80211_BAND_5GHZ) if (chan->band == NL80211_BAND_5GHZ)
...@@ -543,7 +543,7 @@ static int ...@@ -543,7 +543,7 @@ static int
mt76x0_phy_tssi_adc_calibrate(struct mt76x02_dev *dev, s16 *ltssi, mt76x0_phy_tssi_adc_calibrate(struct mt76x02_dev *dev, s16 *ltssi,
u8 *info) u8 *info)
{ {
struct ieee80211_channel *chan = dev->mt76.chandef.chan; struct ieee80211_channel *chan = dev->mphy.chandef.chan;
u32 val; u32 val;
val = (chan->band == NL80211_BAND_5GHZ) ? 0x80055 : 0x80050; val = (chan->band == NL80211_BAND_5GHZ) ? 0x80055 : 0x80050;
...@@ -696,7 +696,7 @@ mt76x0_phy_get_delta_power(struct mt76x02_dev *dev, u8 tx_mode, ...@@ -696,7 +696,7 @@ mt76x0_phy_get_delta_power(struct mt76x02_dev *dev, u8 tx_mode,
s8 target_power, s8 target_pa_power, s8 target_power, s8 target_pa_power,
s16 ltssi) s16 ltssi)
{ {
struct ieee80211_channel *chan = dev->mt76.chandef.chan; struct ieee80211_channel *chan = dev->mphy.chandef.chan;
int tssi_target = target_power << 12, tssi_slope; int tssi_target = target_power << 12, tssi_slope;
int tssi_offset, tssi_db, ret; int tssi_offset, tssi_db, ret;
u32 data; u32 data;
...@@ -844,8 +844,8 @@ void mt76x0_phy_set_txpower(struct mt76x02_dev *dev) ...@@ -844,8 +844,8 @@ void mt76x0_phy_set_txpower(struct mt76x02_dev *dev)
struct mt76_rate_power *t = &dev->mt76.rate_power; struct mt76_rate_power *t = &dev->mt76.rate_power;
s8 info; s8 info;
mt76x0_get_tx_power_per_rate(dev, dev->mt76.chandef.chan, t); mt76x0_get_tx_power_per_rate(dev, dev->mphy.chandef.chan, t);
mt76x0_get_power_info(dev, dev->mt76.chandef.chan, &info); mt76x0_get_power_info(dev, dev->mphy.chandef.chan, &info);
mt76x02_add_rate_power_offset(t, info); mt76x02_add_rate_power_offset(t, info);
mt76x02_limit_rate_power(t, dev->mt76.txpower_conf); mt76x02_limit_rate_power(t, dev->mt76.txpower_conf);
...@@ -858,7 +858,7 @@ void mt76x0_phy_set_txpower(struct mt76x02_dev *dev) ...@@ -858,7 +858,7 @@ void mt76x0_phy_set_txpower(struct mt76x02_dev *dev)
void mt76x0_phy_calibrate(struct mt76x02_dev *dev, bool power_on) void mt76x0_phy_calibrate(struct mt76x02_dev *dev, bool power_on)
{ {
struct ieee80211_channel *chan = dev->mt76.chandef.chan; struct ieee80211_channel *chan = dev->mphy.chandef.chan;
int is_5ghz = (chan->band == NL80211_BAND_5GHZ) ? 1 : 0; int is_5ghz = (chan->band == NL80211_BAND_5GHZ) ? 1 : 0;
u32 val, tx_alc, reg_val; u32 val, tx_alc, reg_val;
...@@ -1037,7 +1037,7 @@ static void mt76x0_phy_temp_sensor(struct mt76x02_dev *dev) ...@@ -1037,7 +1037,7 @@ static void mt76x0_phy_temp_sensor(struct mt76x02_dev *dev)
if (abs(val - dev->cal.temp_vco) > 20) { if (abs(val - dev->cal.temp_vco) > 20) {
mt76x02_mcu_calibrate(dev, MCU_CAL_VCO, mt76x02_mcu_calibrate(dev, MCU_CAL_VCO,
dev->mt76.chandef.chan->hw_value); dev->mphy.chandef.chan->hw_value);
dev->cal.temp_vco = val; dev->cal.temp_vco = val;
} }
if (abs(val - dev->cal.temp) > 30) { if (abs(val - dev->cal.temp) > 30) {
...@@ -1057,7 +1057,7 @@ static void mt76x0_phy_set_gain_val(struct mt76x02_dev *dev) ...@@ -1057,7 +1057,7 @@ static void mt76x0_phy_set_gain_val(struct mt76x02_dev *dev)
mt76_rmw_field(dev, MT_BBP(AGC, 8), MT_BBP_AGC_GAIN, gain); mt76_rmw_field(dev, MT_BBP(AGC, 8), MT_BBP_AGC_GAIN, gain);
if ((dev->mt76.chandef.chan->flags & IEEE80211_CHAN_RADAR) && if ((dev->mphy.chandef.chan->flags & IEEE80211_CHAN_RADAR) &&
!is_mt7630(dev)) !is_mt7630(dev))
mt76x02_phy_dfs_adjust_agc(dev); mt76x02_phy_dfs_adjust_agc(dev);
} }
......
...@@ -307,8 +307,8 @@ static bool mt76x02_dfs_check_hw_pulse(struct mt76x02_dev *dev, ...@@ -307,8 +307,8 @@ static bool mt76x02_dfs_check_hw_pulse(struct mt76x02_dev *dev,
pulse->period <= 100100); pulse->period <= 100100);
break; break;
case NL80211_DFS_JP: case NL80211_DFS_JP:
if (dev->mt76.chandef.chan->center_freq >= 5250 && if (dev->mphy.chandef.chan->center_freq >= 5250 &&
dev->mt76.chandef.chan->center_freq <= 5350) { dev->mphy.chandef.chan->center_freq <= 5350) {
/* JPW53 */ /* JPW53 */
if (pulse->w1 <= 130) if (pulse->w1 <= 130)
ret = (pulse->period >= 28360 && ret = (pulse->period >= 28360 &&
...@@ -702,7 +702,7 @@ static void mt76x02_dfs_set_bbp_params(struct mt76x02_dev *dev) ...@@ -702,7 +702,7 @@ static void mt76x02_dfs_set_bbp_params(struct mt76x02_dev *dev)
u8 i, shift; u8 i, shift;
u32 data; u32 data;
switch (dev->mt76.chandef.width) { switch (dev->mphy.chandef.width) {
case NL80211_CHAN_WIDTH_40: case NL80211_CHAN_WIDTH_40:
shift = MT_DFS_NUM_ENGINES; shift = MT_DFS_NUM_ENGINES;
break; break;
...@@ -722,8 +722,8 @@ static void mt76x02_dfs_set_bbp_params(struct mt76x02_dev *dev) ...@@ -722,8 +722,8 @@ static void mt76x02_dfs_set_bbp_params(struct mt76x02_dev *dev)
radar_specs = &etsi_radar_specs[shift]; radar_specs = &etsi_radar_specs[shift];
break; break;
case NL80211_DFS_JP: case NL80211_DFS_JP:
if (dev->mt76.chandef.chan->center_freq >= 5250 && if (dev->mphy.chandef.chan->center_freq >= 5250 &&
dev->mt76.chandef.chan->center_freq <= 5350) dev->mphy.chandef.chan->center_freq <= 5350)
radar_specs = &jp_w53_radar_specs[shift]; radar_specs = &jp_w53_radar_specs[shift];
else else
radar_specs = &jp_w56_radar_specs[shift]; radar_specs = &jp_w56_radar_specs[shift];
...@@ -822,7 +822,7 @@ EXPORT_SYMBOL_GPL(mt76x02_phy_dfs_adjust_agc); ...@@ -822,7 +822,7 @@ EXPORT_SYMBOL_GPL(mt76x02_phy_dfs_adjust_agc);
void mt76x02_dfs_init_params(struct mt76x02_dev *dev) void mt76x02_dfs_init_params(struct mt76x02_dev *dev)
{ {
struct cfg80211_chan_def *chandef = &dev->mt76.chandef; struct cfg80211_chan_def *chandef = &dev->mphy.chandef;
if ((chandef->chan->flags & IEEE80211_CHAN_RADAR) && if ((chandef->chan->flags & IEEE80211_CHAN_RADAR) &&
dev->mt76.region != NL80211_DFS_UNSET) { dev->mt76.region != NL80211_DFS_UNSET) {
......
...@@ -200,7 +200,7 @@ mt76x02_mac_tx_rate_val(struct mt76x02_dev *dev, ...@@ -200,7 +200,7 @@ mt76x02_mac_tx_rate_val(struct mt76x02_dev *dev,
bw = 1; bw = 1;
} else { } else {
const struct ieee80211_rate *r; const struct ieee80211_rate *r;
int band = dev->mt76.chandef.chan->band; int band = dev->mphy.chandef.chan->band;
u16 val; u16 val;
r = &dev->mt76.hw->wiphy->bands[band]->bitrates[rate->idx]; r = &dev->mt76.hw->wiphy->bands[band]->bitrates[rate->idx];
...@@ -487,17 +487,17 @@ mt76x02_mac_fill_tx_status(struct mt76x02_dev *dev, struct mt76x02_sta *msta, ...@@ -487,17 +487,17 @@ mt76x02_mac_fill_tx_status(struct mt76x02_dev *dev, struct mt76x02_sta *msta,
first_rate |= st->pktid & MT_PKTID_RATE; first_rate |= st->pktid & MT_PKTID_RATE;
mt76x02_mac_process_tx_rate(&rate[0], first_rate, mt76x02_mac_process_tx_rate(&rate[0], first_rate,
dev->mt76.chandef.chan->band); dev->mphy.chandef.chan->band);
} else if (rate[0].idx < 0) { } else if (rate[0].idx < 0) {
if (!msta) if (!msta)
return; return;
mt76x02_mac_process_tx_rate(&rate[0], msta->wcid.tx_info, mt76x02_mac_process_tx_rate(&rate[0], msta->wcid.tx_info,
dev->mt76.chandef.chan->band); dev->mphy.chandef.chan->band);
} }
mt76x02_mac_process_tx_rate(&last_rate, st->rate, mt76x02_mac_process_tx_rate(&last_rate, st->rate,
dev->mt76.chandef.chan->band); dev->mphy.chandef.chan->band);
for (i = 0; i < ARRAY_SIZE(info->status.rates); i++) { for (i = 0; i < ARRAY_SIZE(info->status.rates); i++) {
retry--; retry--;
...@@ -853,8 +853,8 @@ int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb, ...@@ -853,8 +853,8 @@ int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb,
signal = max_t(s8, signal, status->chain_signal[1]); signal = max_t(s8, signal, status->chain_signal[1]);
} }
status->signal = signal; status->signal = signal;
status->freq = dev->mt76.chandef.chan->center_freq; status->freq = dev->mphy.chandef.chan->center_freq;
status->band = dev->mt76.chandef.chan->band; status->band = dev->mphy.chandef.chan->band;
status->tid = FIELD_GET(MT_RXWI_TID, tid_sn); status->tid = FIELD_GET(MT_RXWI_TID, tid_sn);
status->seqno = FIELD_GET(MT_RXWI_SN, tid_sn); status->seqno = FIELD_GET(MT_RXWI_SN, tid_sn);
...@@ -1018,7 +1018,7 @@ void mt76x02_update_channel(struct mt76_dev *mdev) ...@@ -1018,7 +1018,7 @@ void mt76x02_update_channel(struct mt76_dev *mdev)
struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76); struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
struct mt76_channel_state *state; struct mt76_channel_state *state;
state = mdev->chan_state; state = mdev->phy.chan_state;
state->cc_busy += mt76_rr(dev, MT_CH_BUSY); state->cc_busy += mt76_rr(dev, MT_CH_BUSY);
spin_lock_bh(&dev->mt76.cc_lock); spin_lock_bh(&dev->mt76.cc_lock);
...@@ -1074,7 +1074,7 @@ void mt76x02_edcca_init(struct mt76x02_dev *dev) ...@@ -1074,7 +1074,7 @@ void mt76x02_edcca_init(struct mt76x02_dev *dev)
dev->ed_silent = 0; dev->ed_silent = 0;
if (dev->ed_monitor) { if (dev->ed_monitor) {
struct ieee80211_channel *chan = dev->mt76.chandef.chan; struct ieee80211_channel *chan = dev->mphy.chandef.chan;
u8 ed_th = chan->band == NL80211_BAND_5GHZ ? 0x0e : 0x20; u8 ed_th = chan->band == NL80211_BAND_5GHZ ? 0x0e : 0x20;
mt76_clear(dev, MT_TX_LINK_CFG, MT_TX_CFACK_EN); mt76_clear(dev, MT_TX_LINK_CFG, MT_TX_CFACK_EN);
...@@ -1184,7 +1184,7 @@ void mt76x02_mac_work(struct work_struct *work) ...@@ -1184,7 +1184,7 @@ void mt76x02_mac_work(struct work_struct *work)
void mt76x02_mac_cc_reset(struct mt76x02_dev *dev) void mt76x02_mac_cc_reset(struct mt76x02_dev *dev)
{ {
dev->mt76.survey_time = ktime_get_boottime(); dev->mphy.survey_time = ktime_get_boottime();
mt76_wr(dev, MT_CH_TIME_CFG, mt76_wr(dev, MT_CH_TIME_CFG,
MT_CH_TIME_CFG_TIMER_EN | MT_CH_TIME_CFG_TIMER_EN |
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
static inline int static inline int
mt76x02_get_rssi_gain_thresh(struct mt76x02_dev *dev) mt76x02_get_rssi_gain_thresh(struct mt76x02_dev *dev)
{ {
switch (dev->mt76.chandef.width) { switch (dev->mphy.chandef.width) {
case NL80211_CHAN_WIDTH_80: case NL80211_CHAN_WIDTH_80:
return -62; return -62;
case NL80211_CHAN_WIDTH_40: case NL80211_CHAN_WIDTH_40:
...@@ -24,7 +24,7 @@ mt76x02_get_rssi_gain_thresh(struct mt76x02_dev *dev) ...@@ -24,7 +24,7 @@ mt76x02_get_rssi_gain_thresh(struct mt76x02_dev *dev)
static inline int static inline int
mt76x02_get_low_rssi_gain_thresh(struct mt76x02_dev *dev) mt76x02_get_low_rssi_gain_thresh(struct mt76x02_dev *dev)
{ {
switch (dev->mt76.chandef.width) { switch (dev->mphy.chandef.width) {
case NL80211_CHAN_WIDTH_80: case NL80211_CHAN_WIDTH_80:
return -76; return -76;
case NL80211_CHAN_WIDTH_40: case NL80211_CHAN_WIDTH_40:
......
...@@ -74,7 +74,7 @@ s8 mt76x02_tx_get_max_txpwr_adj(struct mt76x02_dev *dev, ...@@ -74,7 +74,7 @@ s8 mt76x02_tx_get_max_txpwr_adj(struct mt76x02_dev *dev,
} else if (rate->flags & IEEE80211_TX_RC_MCS) { } else if (rate->flags & IEEE80211_TX_RC_MCS) {
max_txpwr = dev->mt76.rate_power.ht[rate->idx & 0xf]; max_txpwr = dev->mt76.rate_power.ht[rate->idx & 0xf];
} else { } else {
enum nl80211_band band = dev->mt76.chandef.chan->band; enum nl80211_band band = dev->mphy.chandef.chan->band;
if (band == NL80211_BAND_2GHZ) { if (band == NL80211_BAND_2GHZ) {
const struct ieee80211_rate *r; const struct ieee80211_rate *r;
......
...@@ -188,9 +188,9 @@ void mt76x02_init_device(struct mt76x02_dev *dev) ...@@ -188,9 +188,9 @@ void mt76x02_init_device(struct mt76x02_dev *dev)
dev->slottime = 9; dev->slottime = 9;
if (is_mt76x2(dev)) { if (is_mt76x2(dev)) {
dev->mt76.sband_2g.sband.ht_cap.cap |= dev->mphy.sband_2g.sband.ht_cap.cap |=
IEEE80211_HT_CAP_LDPC_CODING; IEEE80211_HT_CAP_LDPC_CODING;
dev->mt76.sband_5g.sband.ht_cap.cap |= dev->mphy.sband_5g.sband.ht_cap.cap |=
IEEE80211_HT_CAP_LDPC_CODING; IEEE80211_HT_CAP_LDPC_CODING;
dev->mt76.chainmask = 0x202; dev->mt76.chainmask = 0x202;
dev->mt76.antenna_mask = 3; dev->mt76.antenna_mask = 3;
......
...@@ -248,7 +248,7 @@ mt76x2_get_5g_rx_gain(struct mt76x02_dev *dev, u8 channel) ...@@ -248,7 +248,7 @@ mt76x2_get_5g_rx_gain(struct mt76x02_dev *dev, u8 channel)
void mt76x2_read_rx_gain(struct mt76x02_dev *dev) void mt76x2_read_rx_gain(struct mt76x02_dev *dev)
{ {
struct ieee80211_channel *chan = dev->mt76.chandef.chan; struct ieee80211_channel *chan = dev->mphy.chandef.chan;
int channel = chan->hw_value; int channel = chan->hw_value;
s8 lna_5g[3], lna_2g; s8 lna_5g[3], lna_2g;
u8 lna; u8 lna;
...@@ -455,7 +455,7 @@ EXPORT_SYMBOL_GPL(mt76x2_get_power_info); ...@@ -455,7 +455,7 @@ EXPORT_SYMBOL_GPL(mt76x2_get_power_info);
int mt76x2_get_temp_comp(struct mt76x02_dev *dev, struct mt76x2_temp_comp *t) int mt76x2_get_temp_comp(struct mt76x02_dev *dev, struct mt76x2_temp_comp *t)
{ {
enum nl80211_band band = dev->mt76.chandef.chan->band; enum nl80211_band band = dev->mphy.chandef.chan->band;
u16 val, slope; u16 val, slope;
u8 bounds; u8 bounds;
......
...@@ -53,7 +53,7 @@ mt76x2_has_ext_lna(struct mt76x02_dev *dev) ...@@ -53,7 +53,7 @@ mt76x2_has_ext_lna(struct mt76x02_dev *dev)
{ {
u32 val = mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_1); u32 val = mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_1);
if (dev->mt76.chandef.chan->band == NL80211_BAND_2GHZ) if (dev->mphy.chandef.chan->band == NL80211_BAND_2GHZ)
return val & MT_EE_NIC_CONF_1_LNA_EXT_2G; return val & MT_EE_NIC_CONF_1_LNA_EXT_2G;
else else
return val & MT_EE_NIC_CONF_1_LNA_EXT_5G; return val & MT_EE_NIC_CONF_1_LNA_EXT_5G;
......
...@@ -30,7 +30,7 @@ static inline bool is_mt7612(struct mt76x02_dev *dev) ...@@ -30,7 +30,7 @@ static inline bool is_mt7612(struct mt76x02_dev *dev)
static inline bool mt76x2_channel_silent(struct mt76x02_dev *dev) static inline bool mt76x2_channel_silent(struct mt76x02_dev *dev)
{ {
struct ieee80211_channel *chan = dev->mt76.chandef.chan; struct ieee80211_channel *chan = dev->mphy.chandef.chan;
return ((chan->flags & IEEE80211_CHAN_RADAR) && return ((chan->flags & IEEE80211_CHAN_RADAR) &&
chan->dfs_state != NL80211_DFS_AVAILABLE); chan->dfs_state != NL80211_DFS_AVAILABLE);
......
...@@ -289,8 +289,8 @@ int mt76x2_register_device(struct mt76x02_dev *dev) ...@@ -289,8 +289,8 @@ int mt76x2_register_device(struct mt76x02_dev *dev)
goto fail; goto fail;
mt76x02_init_debugfs(dev); mt76x02_init_debugfs(dev);
mt76x2_init_txpower(dev, &dev->mt76.sband_2g.sband); mt76x2_init_txpower(dev, &dev->mphy.sband_2g.sband);
mt76x2_init_txpower(dev, &dev->mt76.sband_5g.sband); mt76x2_init_txpower(dev, &dev->mphy.sband_5g.sband);
return 0; return 0;
......
...@@ -47,7 +47,7 @@ mt76x2_set_channel(struct mt76x02_dev *dev, struct cfg80211_chan_def *chandef) ...@@ -47,7 +47,7 @@ mt76x2_set_channel(struct mt76x02_dev *dev, struct cfg80211_chan_def *chandef)
mutex_lock(&dev->mt76.mutex); mutex_lock(&dev->mt76.mutex);
set_bit(MT76_RESET, &dev->mt76.state); set_bit(MT76_RESET, &dev->mt76.state);
mt76_set_channel(&dev->mt76); mt76_set_channel(&dev->mphy);
mt76x2_mac_stop(dev, true); mt76x2_mac_stop(dev, true);
ret = mt76x2_phy_set_channel(dev, chandef); ret = mt76x2_phy_set_channel(dev, chandef);
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
static bool static bool
mt76x2_phy_tssi_init_cal(struct mt76x02_dev *dev) mt76x2_phy_tssi_init_cal(struct mt76x02_dev *dev)
{ {
struct ieee80211_channel *chan = dev->mt76.chandef.chan; struct ieee80211_channel *chan = dev->mphy.chandef.chan;
u32 flag = 0; u32 flag = 0;
if (!mt76x2_tssi_enabled(dev)) if (!mt76x2_tssi_enabled(dev))
...@@ -35,7 +35,7 @@ mt76x2_phy_tssi_init_cal(struct mt76x02_dev *dev) ...@@ -35,7 +35,7 @@ mt76x2_phy_tssi_init_cal(struct mt76x02_dev *dev)
static void static void
mt76x2_phy_channel_calibrate(struct mt76x02_dev *dev, bool mac_stopped) mt76x2_phy_channel_calibrate(struct mt76x02_dev *dev, bool mac_stopped)
{ {
struct ieee80211_channel *chan = dev->mt76.chandef.chan; struct ieee80211_channel *chan = dev->mphy.chandef.chan;
bool is_5ghz = chan->band == NL80211_BAND_5GHZ; bool is_5ghz = chan->band == NL80211_BAND_5GHZ;
if (dev->cal.channel_cal_done) if (dev->cal.channel_cal_done)
......
...@@ -136,8 +136,8 @@ mt76x2_get_min_rate_power(struct mt76_rate_power *r) ...@@ -136,8 +136,8 @@ mt76x2_get_min_rate_power(struct mt76_rate_power *r)
void mt76x2_phy_set_txpower(struct mt76x02_dev *dev) void mt76x2_phy_set_txpower(struct mt76x02_dev *dev)
{ {
enum nl80211_chan_width width = dev->mt76.chandef.width; enum nl80211_chan_width width = dev->mphy.chandef.width;
struct ieee80211_channel *chan = dev->mt76.chandef.chan; struct ieee80211_channel *chan = dev->mphy.chandef.chan;
struct mt76x2_tx_power_info txp; struct mt76x2_tx_power_info txp;
int txp_0, txp_1, delta = 0; int txp_0, txp_1, delta = 0;
struct mt76_rate_power t = {}; struct mt76_rate_power t = {};
...@@ -202,7 +202,7 @@ EXPORT_SYMBOL_GPL(mt76x2_configure_tx_delay); ...@@ -202,7 +202,7 @@ EXPORT_SYMBOL_GPL(mt76x2_configure_tx_delay);
void mt76x2_phy_tssi_compensate(struct mt76x02_dev *dev) void mt76x2_phy_tssi_compensate(struct mt76x02_dev *dev)
{ {
struct ieee80211_channel *chan = dev->mt76.chandef.chan; struct ieee80211_channel *chan = dev->mphy.chandef.chan;
struct mt76x2_tx_power_info txp; struct mt76x2_tx_power_info txp;
struct mt76x2_tssi_comp t = {}; struct mt76x2_tssi_comp t = {};
...@@ -252,12 +252,12 @@ mt76x2_phy_set_gain_val(struct mt76x02_dev *dev) ...@@ -252,12 +252,12 @@ mt76x2_phy_set_gain_val(struct mt76x02_dev *dev)
val = 0x1836 << 16; val = 0x1836 << 16;
if (!mt76x2_has_ext_lna(dev) && if (!mt76x2_has_ext_lna(dev) &&
dev->mt76.chandef.width >= NL80211_CHAN_WIDTH_40) dev->mphy.chandef.width >= NL80211_CHAN_WIDTH_40)
val = 0x1e42 << 16; val = 0x1e42 << 16;
if (mt76x2_has_ext_lna(dev) && if (mt76x2_has_ext_lna(dev) &&
dev->mt76.chandef.chan->band == NL80211_BAND_2GHZ && dev->mphy.chandef.chan->band == NL80211_BAND_2GHZ &&
dev->mt76.chandef.width < NL80211_CHAN_WIDTH_40) dev->mphy.chandef.width < NL80211_CHAN_WIDTH_40)
val = 0x0f36 << 16; val = 0x0f36 << 16;
val |= 0xf8; val |= 0xf8;
...@@ -267,7 +267,7 @@ mt76x2_phy_set_gain_val(struct mt76x02_dev *dev) ...@@ -267,7 +267,7 @@ mt76x2_phy_set_gain_val(struct mt76x02_dev *dev)
mt76_wr(dev, MT_BBP(AGC, 9), mt76_wr(dev, MT_BBP(AGC, 9),
val | FIELD_PREP(MT_BBP_AGC_GAIN, gain_val[1])); val | FIELD_PREP(MT_BBP_AGC_GAIN, gain_val[1]));
if (dev->mt76.chandef.chan->flags & IEEE80211_CHAN_RADAR) if (dev->mphy.chandef.chan->flags & IEEE80211_CHAN_RADAR)
mt76x02_phy_dfs_adjust_agc(dev); mt76x02_phy_dfs_adjust_agc(dev);
} }
...@@ -297,7 +297,7 @@ void mt76x2_phy_update_channel_gain(struct mt76x02_dev *dev) ...@@ -297,7 +297,7 @@ void mt76x2_phy_update_channel_gain(struct mt76x02_dev *dev)
return; return;
} }
if (dev->mt76.chandef.width == NL80211_CHAN_WIDTH_80) { if (dev->mphy.chandef.width == NL80211_CHAN_WIDTH_80) {
mt76_wr(dev, MT_BBP(RXO, 14), 0x00560211); mt76_wr(dev, MT_BBP(RXO, 14), 0x00560211);
val = mt76_rr(dev, MT_BBP(AGC, 26)) & ~0xf; val = mt76_rr(dev, MT_BBP(AGC, 26)) & ~0xf;
if (low_gain == 2) if (low_gain == 2)
...@@ -315,11 +315,11 @@ void mt76x2_phy_update_channel_gain(struct mt76x02_dev *dev) ...@@ -315,11 +315,11 @@ void mt76x2_phy_update_channel_gain(struct mt76x02_dev *dev)
low_gain_delta = 14; low_gain_delta = 14;
agc_37 = 0x2121262c; agc_37 = 0x2121262c;
if (dev->mt76.chandef.chan->band == NL80211_BAND_2GHZ) if (dev->mphy.chandef.chan->band == NL80211_BAND_2GHZ)
agc_35 = 0x11111516; agc_35 = 0x11111516;
else if (low_gain == 2) else if (low_gain == 2)
agc_35 = agc_37 = 0x08080808; agc_35 = agc_37 = 0x08080808;
else if (dev->mt76.chandef.width == NL80211_CHAN_WIDTH_80) else if (dev->mphy.chandef.width == NL80211_CHAN_WIDTH_80)
agc_35 = 0x10101014; agc_35 = 0x10101014;
else else
agc_35 = 0x11111116; agc_35 = 0x11111116;
......
...@@ -221,8 +221,8 @@ int mt76x2u_register_device(struct mt76x02_dev *dev) ...@@ -221,8 +221,8 @@ int mt76x2u_register_device(struct mt76x02_dev *dev)
set_bit(MT76_STATE_INITIALIZED, &dev->mt76.state); set_bit(MT76_STATE_INITIALIZED, &dev->mt76.state);
mt76x02_init_debugfs(dev); mt76x02_init_debugfs(dev);
mt76x2_init_txpower(dev, &dev->mt76.sband_2g.sband); mt76x2_init_txpower(dev, &dev->mphy.sband_2g.sband);
mt76x2_init_txpower(dev, &dev->mt76.sband_5g.sband); mt76x2_init_txpower(dev, &dev->mphy.sband_5g.sband);
return 0; return 0;
......
...@@ -43,7 +43,7 @@ mt76x2u_set_channel(struct mt76x02_dev *dev, ...@@ -43,7 +43,7 @@ mt76x2u_set_channel(struct mt76x02_dev *dev,
mutex_lock(&dev->mt76.mutex); mutex_lock(&dev->mt76.mutex);
set_bit(MT76_RESET, &dev->mt76.state); set_bit(MT76_RESET, &dev->mt76.state);
mt76_set_channel(&dev->mt76); mt76_set_channel(&dev->mphy);
mt76x2_mac_stop(dev, false); mt76x2_mac_stop(dev, false);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
static void static void
mt76x2u_phy_channel_calibrate(struct mt76x02_dev *dev, bool mac_stopped) mt76x2u_phy_channel_calibrate(struct mt76x02_dev *dev, bool mac_stopped)
{ {
struct ieee80211_channel *chan = dev->mt76.chandef.chan; struct ieee80211_channel *chan = dev->mphy.chandef.chan;
bool is_5ghz = chan->band == NL80211_BAND_5GHZ; bool is_5ghz = chan->band == NL80211_BAND_5GHZ;
if (dev->cal.channel_cal_done) if (dev->cal.channel_cal_done)
...@@ -185,7 +185,7 @@ int mt76x2u_phy_set_channel(struct mt76x02_dev *dev, ...@@ -185,7 +185,7 @@ int mt76x2u_phy_set_channel(struct mt76x02_dev *dev,
struct ieee80211_channel *chan; struct ieee80211_channel *chan;
u32 flag = 0; u32 flag = 0;
chan = dev->mt76.chandef.chan; chan = dev->mphy.chandef.chan;
if (chan->band == NL80211_BAND_5GHZ) if (chan->band == NL80211_BAND_5GHZ)
flag |= BIT(0); flag |= BIT(0);
if (mt76x02_ext_pa_enabled(dev, chan->band)) if (mt76x02_ext_pa_enabled(dev, chan->band))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment