Commit fdd2e570 authored by Felix Fietkau's avatar Felix Fietkau

mt76: mt7615: add dual-phy support for mac80211 ops

Allows them to be used by a separately registered wiphy later
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent c9619dfa
...@@ -50,7 +50,7 @@ static void mt7615_mac_init(struct mt7615_dev *dev) ...@@ -50,7 +50,7 @@ static void mt7615_mac_init(struct mt7615_dev *dev)
MT_TMAC_CTCR0_INS_DDLMT_VHT_SMPDU_EN | MT_TMAC_CTCR0_INS_DDLMT_VHT_SMPDU_EN |
MT_TMAC_CTCR0_INS_DDLMT_EN); MT_TMAC_CTCR0_INS_DDLMT_EN);
mt7615_mcu_set_rts_thresh(dev, 0x92b); mt7615_mcu_set_rts_thresh(&dev->phy, 0x92b);
mt7615_mac_set_scs(dev, true); mt7615_mac_set_scs(dev, true);
mt76_rmw(dev, MT_AGG_SCR, MT_AGG_SCR_NLNAV_MID_PTEC_DIS, mt76_rmw(dev, MT_AGG_SCR, MT_AGG_SCR_NLNAV_MID_PTEC_DIS,
...@@ -132,7 +132,7 @@ static int mt7615_init_hardware(struct mt7615_dev *dev) ...@@ -132,7 +132,7 @@ static int mt7615_init_hardware(struct mt7615_dev *dev)
mt7615_mcu_set_eeprom(dev); mt7615_mcu_set_eeprom(dev);
mt7615_mac_init(dev); mt7615_mac_init(dev);
mt7615_phy_init(dev); mt7615_phy_init(dev);
mt7615_mcu_ctrl_pm_state(dev, 0); mt7615_mcu_ctrl_pm_state(dev, 0, 0);
mt7615_mcu_del_wtbl_all(dev); mt7615_mcu_del_wtbl_all(dev);
/* Beacon and mgmt frames should occupy wcid 0 */ /* Beacon and mgmt frames should occupy wcid 0 */
...@@ -246,11 +246,9 @@ mt7615_regd_notifier(struct wiphy *wiphy, ...@@ -246,11 +246,9 @@ mt7615_regd_notifier(struct wiphy *wiphy,
struct regulatory_request *request) struct regulatory_request *request)
{ {
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 = mt7615_hw_dev(hw);
struct cfg80211_chan_def *chandef = &dev->mphy.chandef; struct mt76_phy *mphy = hw->priv;
struct cfg80211_chan_def *chandef = &mphy->chandef;
if (request->dfs_region == dev->mt76.region)
return;
dev->mt76.region = request->dfs_region; dev->mt76.region = request->dfs_region;
...@@ -271,6 +269,9 @@ int mt7615_register_device(struct mt7615_dev *dev) ...@@ -271,6 +269,9 @@ int mt7615_register_device(struct mt7615_dev *dev)
struct wiphy *wiphy = hw->wiphy; struct wiphy *wiphy = hw->wiphy;
int ret; int ret;
dev->phy.dev = dev;
dev->phy.mt76 = &dev->mt76.phy;
dev->mt76.phy.priv = &dev->phy;
INIT_DELAYED_WORK(&dev->mt76.mac_work, mt7615_mac_work); INIT_DELAYED_WORK(&dev->mt76.mac_work, mt7615_mac_work);
INIT_LIST_HEAD(&dev->sta_poll_list); INIT_LIST_HEAD(&dev->sta_poll_list);
spin_lock_init(&dev->sta_poll_lock); spin_lock_init(&dev->sta_poll_lock);
......
...@@ -49,13 +49,20 @@ void mt7615_mac_reset_counters(struct mt7615_dev *dev) ...@@ -49,13 +49,20 @@ void mt7615_mac_reset_counters(struct mt7615_dev *dev)
mt76_rr(dev, MT_TX_AGG_CNT(i)); mt76_rr(dev, MT_TX_AGG_CNT(i));
memset(dev->mt76.aggr_stats, 0, sizeof(dev->mt76.aggr_stats)); memset(dev->mt76.aggr_stats, 0, sizeof(dev->mt76.aggr_stats));
dev->mt76.phy.survey_time = ktime_get_boottime();
/* TODO: add DBDC support */ if (dev->mt76.phy2)
dev->mt76.phy2->survey_time = ktime_get_boottime();
/* reset airtime counters */ /* reset airtime counters */
mt76_rr(dev, MT_MIB_SDR9(0)); mt76_rr(dev, MT_MIB_SDR9(0));
mt76_rr(dev, MT_MIB_SDR9(1));
mt76_rr(dev, MT_MIB_SDR36(0)); mt76_rr(dev, MT_MIB_SDR36(0));
mt76_rr(dev, MT_MIB_SDR36(1));
mt76_rr(dev, MT_MIB_SDR37(0)); mt76_rr(dev, MT_MIB_SDR37(0));
mt76_rr(dev, MT_MIB_SDR37(1));
mt76_set(dev, MT_WF_RMAC_MIB_TIME0, MT_WF_RMAC_MIB_RXTIME_CLR); mt76_set(dev, MT_WF_RMAC_MIB_TIME0, MT_WF_RMAC_MIB_RXTIME_CLR);
mt76_set(dev, MT_WF_RMAC_MIB_AIRTIME0, MT_WF_RMAC_MIB_RXTIME_CLR); mt76_set(dev, MT_WF_RMAC_MIB_AIRTIME0, MT_WF_RMAC_MIB_RXTIME_CLR);
} }
...@@ -291,6 +298,7 @@ void mt7615_tx_complete_skb(struct mt76_dev *mdev, enum mt76_txq_id qid, ...@@ -291,6 +298,7 @@ void mt7615_tx_complete_skb(struct mt76_dev *mdev, enum mt76_txq_id qid,
static u16 static u16
mt7615_mac_tx_rate_val(struct mt7615_dev *dev, mt7615_mac_tx_rate_val(struct mt7615_dev *dev,
struct mt76_phy *mphy,
const struct ieee80211_tx_rate *rate, const struct ieee80211_tx_rate *rate,
bool stbc, u8 *bw) bool stbc, u8 *bw)
{ {
...@@ -319,11 +327,11 @@ mt7615_mac_tx_rate_val(struct mt7615_dev *dev, ...@@ -319,11 +327,11 @@ 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->mphy.chandef.chan->band; int band = mphy->chandef.chan->band;
u16 val; u16 val;
nss = 1; nss = 1;
r = &mt76_hw(dev)->wiphy->bands[band]->bitrates[rate->idx]; r = &mphy->hw->wiphy->bands[band]->bitrates[rate->idx];
if (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) if (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
val = r->hw_value_short; val = r->hw_value_short;
else else
...@@ -355,6 +363,7 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi, ...@@ -355,6 +363,7 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi,
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
bool multicast = is_multicast_ether_addr(hdr->addr1); bool multicast = is_multicast_ether_addr(hdr->addr1);
struct ieee80211_vif *vif = info->control.vif; struct ieee80211_vif *vif = info->control.vif;
struct mt76_phy *mphy = &dev->mphy;
int tx_count = 8; int tx_count = 8;
u8 fc_type, fc_stype, p_fmt, q_idx, omac_idx = 0, wmm_idx = 0; u8 fc_type, fc_stype, p_fmt, q_idx, omac_idx = 0, wmm_idx = 0;
__le16 fc = hdr->frame_control; __le16 fc = hdr->frame_control;
...@@ -374,6 +383,9 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi, ...@@ -374,6 +383,9 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi,
tx_count = msta->rate_count; tx_count = msta->rate_count;
} }
if ((info->hw_queue & MT_TX_HW_QUEUE_EXT_PHY) && dev->mt76.phy2)
mphy = dev->mt76.phy2;
fc_type = (le16_to_cpu(fc) & IEEE80211_FCTL_FTYPE) >> 2; fc_type = (le16_to_cpu(fc) & IEEE80211_FCTL_FTYPE) >> 2;
fc_stype = (le16_to_cpu(fc) & IEEE80211_FCTL_STYPE) >> 4; fc_stype = (le16_to_cpu(fc) & IEEE80211_FCTL_STYPE) >> 4;
...@@ -431,7 +443,8 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi, ...@@ -431,7 +443,8 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi,
!(info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)) { !(info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)) {
bool stbc = info->flags & IEEE80211_TX_CTL_STBC; bool stbc = info->flags & IEEE80211_TX_CTL_STBC;
u8 bw; u8 bw;
u16 rateval = mt7615_mac_tx_rate_val(dev, rate, stbc, &bw); u16 rateval = mt7615_mac_tx_rate_val(dev, mphy, rate, stbc,
&bw);
txwi[2] |= cpu_to_le32(MT_TXD2_FIX_RATE); txwi[2] |= cpu_to_le32(MT_TXD2_FIX_RATE);
...@@ -588,10 +601,12 @@ void mt7615_mac_sta_poll(struct mt7615_dev *dev) ...@@ -588,10 +601,12 @@ void mt7615_mac_sta_poll(struct mt7615_dev *dev)
rcu_read_unlock(); rcu_read_unlock();
} }
void mt7615_mac_set_rates(struct mt7615_dev *dev, struct mt7615_sta *sta, void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta,
struct ieee80211_tx_rate *probe_rate, struct ieee80211_tx_rate *probe_rate,
struct ieee80211_tx_rate *rates) struct ieee80211_tx_rate *rates)
{ {
struct mt7615_dev *dev = phy->dev;
struct mt76_phy *mphy = phy->mt76;
struct ieee80211_tx_rate *ref; struct ieee80211_tx_rate *ref;
int wcid = sta->wcid.idx; int wcid = sta->wcid.idx;
u32 addr = mt7615_mac_wtbl_addr(wcid); u32 addr = mt7615_mac_wtbl_addr(wcid);
...@@ -649,11 +664,12 @@ void mt7615_mac_set_rates(struct mt7615_dev *dev, struct mt7615_sta *sta, ...@@ -649,11 +664,12 @@ void mt7615_mac_set_rates(struct mt7615_dev *dev, struct mt7615_sta *sta,
} }
} }
val[0] = mt7615_mac_tx_rate_val(dev, &rates[0], stbc, &bw); val[0] = mt7615_mac_tx_rate_val(dev, mphy, &rates[0], stbc, &bw);
bw_prev = bw; bw_prev = bw;
if (probe_rate) { if (probe_rate) {
probe_val = mt7615_mac_tx_rate_val(dev, probe_rate, stbc, &bw); probe_val = mt7615_mac_tx_rate_val(dev, mphy, probe_rate,
stbc, &bw);
if (bw) if (bw)
bw_idx = 1; bw_idx = 1;
else else
...@@ -662,19 +678,19 @@ void mt7615_mac_set_rates(struct mt7615_dev *dev, struct mt7615_sta *sta, ...@@ -662,19 +678,19 @@ void mt7615_mac_set_rates(struct mt7615_dev *dev, struct mt7615_sta *sta,
probe_val = val[0]; probe_val = val[0];
} }
val[1] = mt7615_mac_tx_rate_val(dev, &rates[1], stbc, &bw); val[1] = mt7615_mac_tx_rate_val(dev, mphy, &rates[1], stbc, &bw);
if (bw_prev) { if (bw_prev) {
bw_idx = 3; bw_idx = 3;
bw_prev = bw; bw_prev = bw;
} }
val[2] = mt7615_mac_tx_rate_val(dev, &rates[2], stbc, &bw); val[2] = mt7615_mac_tx_rate_val(dev, mphy, &rates[2], stbc, &bw);
if (bw_prev) { if (bw_prev) {
bw_idx = 5; bw_idx = 5;
bw_prev = bw; bw_prev = bw;
} }
val[3] = mt7615_mac_tx_rate_val(dev, &rates[3], stbc, &bw); val[3] = mt7615_mac_tx_rate_val(dev, mphy, &rates[3], stbc, &bw);
if (bw_prev) if (bw_prev)
bw_idx = 7; bw_idx = 7;
...@@ -906,8 +922,13 @@ int mt7615_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, ...@@ -906,8 +922,13 @@ int mt7615_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
pid = mt76_tx_status_skb_add(mdev, wcid, tx_info->skb); pid = mt76_tx_status_skb_add(mdev, wcid, tx_info->skb);
if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) { if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) {
struct mt7615_phy *phy = &dev->phy;
if ((info->hw_queue & MT_TX_HW_QUEUE_EXT_PHY) && mdev->phy2)
phy = mdev->phy2->priv;
spin_lock_bh(&dev->mt76.lock); spin_lock_bh(&dev->mt76.lock);
mt7615_mac_set_rates(dev, msta, &info->control.rates[0], mt7615_mac_set_rates(phy, msta, &info->control.rates[0],
msta->rates); msta->rates);
msta->rate_probe = true; msta->rate_probe = true;
spin_unlock_bh(&dev->mt76.lock); spin_unlock_bh(&dev->mt76.lock);
...@@ -962,6 +983,7 @@ static bool mt7615_fill_txs(struct mt7615_dev *dev, struct mt7615_sta *sta, ...@@ -962,6 +983,7 @@ static bool mt7615_fill_txs(struct mt7615_dev *dev, struct mt7615_sta *sta,
{ {
struct ieee80211_supported_band *sband; struct ieee80211_supported_band *sband;
struct mt7615_rate_set *rs; struct mt7615_rate_set *rs;
struct mt76_phy *mphy;
int first_idx = 0, last_idx; int first_idx = 0, last_idx;
int i, idx, count; int i, idx, count;
bool fixed_rate, ack_timeout; bool fixed_rate, ack_timeout;
...@@ -1019,7 +1041,12 @@ static bool mt7615_fill_txs(struct mt7615_dev *dev, struct mt7615_sta *sta, ...@@ -1019,7 +1041,12 @@ static bool mt7615_fill_txs(struct mt7615_dev *dev, struct mt7615_sta *sta,
spin_lock_bh(&dev->mt76.lock); spin_lock_bh(&dev->mt76.lock);
if (sta->rate_probe) { if (sta->rate_probe) {
mt7615_mac_set_rates(dev, sta, NULL, sta->rates); struct mt7615_phy *phy = &dev->phy;
if (sta->wcid.ext_phy && dev->mt76.phy2)
phy = dev->mt76.phy2->priv;
mt7615_mac_set_rates(phy, sta, NULL, sta->rates);
sta->rate_probe = false; sta->rate_probe = false;
} }
spin_unlock_bh(&dev->mt76.lock); spin_unlock_bh(&dev->mt76.lock);
...@@ -1059,10 +1086,14 @@ static bool mt7615_fill_txs(struct mt7615_dev *dev, struct mt7615_sta *sta, ...@@ -1059,10 +1086,14 @@ 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->mphy.chandef.chan->band == NL80211_BAND_5GHZ) mphy = &dev->mphy;
sband = &dev->mphy.sband_5g.sband; if (sta->wcid.ext_phy && dev->mt76.phy2)
mphy = dev->mt76.phy2;
if (mphy->chandef.chan->band == NL80211_BAND_5GHZ)
sband = &mphy->sband_5g.sband;
else else
sband = &dev->mphy.sband_2g.sband; sband = &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);
...@@ -1128,6 +1159,7 @@ void mt7615_mac_add_txs(struct mt7615_dev *dev, void *data) ...@@ -1128,6 +1159,7 @@ void mt7615_mac_add_txs(struct mt7615_dev *dev, void *data)
struct ieee80211_sta *sta = NULL; struct ieee80211_sta *sta = NULL;
struct mt7615_sta *msta = NULL; struct mt7615_sta *msta = NULL;
struct mt76_wcid *wcid; struct mt76_wcid *wcid;
struct mt76_phy *mphy = &dev->mt76.phy;
__le32 *txs_data = data; __le32 *txs_data = data;
u32 txs; u32 txs;
u8 wcidx; u8 wcidx;
...@@ -1164,8 +1196,11 @@ void mt7615_mac_add_txs(struct mt7615_dev *dev, void *data) ...@@ -1164,8 +1196,11 @@ void mt7615_mac_add_txs(struct mt7615_dev *dev, void *data)
if (wcidx >= MT7615_WTBL_STA || !sta) if (wcidx >= MT7615_WTBL_STA || !sta)
goto out; goto out;
if (wcid->ext_phy && dev->mt76.phy2)
mphy = dev->mt76.phy2;
if (mt7615_fill_txs(dev, msta, &info, txs_data)) if (mt7615_fill_txs(dev, msta, &info, txs_data))
ieee80211_tx_status_noskb(mt76_hw(dev), sta, &info); ieee80211_tx_status_noskb(mphy->hw, sta, &info);
out: out:
rcu_read_unlock(); rcu_read_unlock();
...@@ -1367,27 +1402,36 @@ mt7615_mac_scs_check(struct mt7615_dev *dev) ...@@ -1367,27 +1402,36 @@ mt7615_mac_scs_check(struct mt7615_dev *dev)
mt7615_mac_set_default_sensitivity(dev); mt7615_mac_set_default_sensitivity(dev);
} }
void mt7615_update_channel(struct mt76_dev *mdev) static void
mt7615_phy_update_channel(struct mt76_phy *mphy, int idx)
{ {
struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76); struct mt7615_dev *dev = container_of(mphy->dev, struct mt7615_dev, mt76);
struct mt76_channel_state *state; struct mt76_channel_state *state;
u64 busy_time, tx_time, rx_time, obss_time; u64 busy_time, tx_time, rx_time, obss_time;
u32 obss_reg = idx ? MT_WF_RMAC_MIB_TIME6 : MT_WF_RMAC_MIB_TIME5;
/* TODO: add DBDC support */ busy_time = mt76_get_field(dev, MT_MIB_SDR9(idx),
busy_time = mt76_get_field(dev, MT_MIB_SDR9(0),
MT_MIB_SDR9_BUSY_MASK); MT_MIB_SDR9_BUSY_MASK);
tx_time = mt76_get_field(dev, MT_MIB_SDR36(0), tx_time = mt76_get_field(dev, MT_MIB_SDR36(idx),
MT_MIB_SDR36_TXTIME_MASK); MT_MIB_SDR36_TXTIME_MASK);
rx_time = mt76_get_field(dev, MT_MIB_SDR37(0), rx_time = mt76_get_field(dev, MT_MIB_SDR37(idx),
MT_MIB_SDR37_RXTIME_MASK); MT_MIB_SDR37_RXTIME_MASK);
obss_time = mt76_get_field(dev, MT_WF_RMAC_MIB_TIME5, obss_time = mt76_get_field(dev, obss_reg, MT_MIB_OBSSTIME_MASK);
MT_MIB_OBSSTIME_MASK);
state = mdev->phy.chan_state; state = mphy->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;
state->cc_bss_rx += rx_time; state->cc_bss_rx += rx_time;
}
void mt7615_update_channel(struct mt76_dev *mdev)
{
struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
mt7615_phy_update_channel(&mdev->phy, 0);
if (mdev->phy2)
mt7615_phy_update_channel(mdev->phy2, 1);
/* reset obss airtime */ /* reset obss airtime */
mt76_set(dev, MT_WF_RMAC_MIB_TIME0, MT_WF_RMAC_MIB_RXTIME_CLR); mt76_set(dev, MT_WF_RMAC_MIB_TIME0, MT_WF_RMAC_MIB_RXTIME_CLR);
......
...@@ -616,8 +616,9 @@ int mt7615_mcu_init_mac(struct mt7615_dev *dev) ...@@ -616,8 +616,9 @@ int mt7615_mcu_init_mac(struct mt7615_dev *dev)
&req, sizeof(req), true); &req, sizeof(req), true);
} }
int mt7615_mcu_set_rts_thresh(struct mt7615_dev *dev, u32 val) int mt7615_mcu_set_rts_thresh(struct mt7615_phy *phy, u32 val)
{ {
struct mt7615_dev *dev = phy->dev;
struct { struct {
u8 prot_idx; u8 prot_idx;
u8 band; u8 band;
...@@ -626,7 +627,7 @@ int mt7615_mcu_set_rts_thresh(struct mt7615_dev *dev, u32 val) ...@@ -626,7 +627,7 @@ int mt7615_mcu_set_rts_thresh(struct mt7615_dev *dev, u32 val)
__le32 pkt_thresh; __le32 pkt_thresh;
} __packed req = { } __packed req = {
.prot_idx = 1, .prot_idx = 1,
.band = 0, .band = phy != &dev->phy,
.len_thresh = cpu_to_le32(val), .len_thresh = cpu_to_le32(val),
.pkt_thresh = cpu_to_le32(0x2), .pkt_thresh = cpu_to_le32(0x2),
}; };
...@@ -672,7 +673,7 @@ int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue, ...@@ -672,7 +673,7 @@ int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue,
&req, sizeof(req), true); &req, sizeof(req), true);
} }
int mt7615_mcu_ctrl_pm_state(struct mt7615_dev *dev, int enter) int mt7615_mcu_ctrl_pm_state(struct mt7615_dev *dev, int band, int enter)
{ {
#define ENTER_PM_STATE 1 #define ENTER_PM_STATE 1
#define EXIT_PM_STATE 2 #define EXIT_PM_STATE 2
...@@ -695,7 +696,7 @@ int mt7615_mcu_ctrl_pm_state(struct mt7615_dev *dev, int enter) ...@@ -695,7 +696,7 @@ int mt7615_mcu_ctrl_pm_state(struct mt7615_dev *dev, int enter)
} __packed req = { } __packed req = {
.pm_number = 5, .pm_number = 5,
.pm_state = (enter) ? ENTER_PM_STATE : EXIT_PM_STATE, .pm_state = (enter) ? ENTER_PM_STATE : EXIT_PM_STATE,
.band_idx = 0, .band_idx = band,
}; };
return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_PM_STATE_CTRL, return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_PM_STATE_CTRL,
...@@ -1099,12 +1100,14 @@ int mt7615_mcu_set_sta_rec(struct mt7615_dev *dev, struct ieee80211_vif *vif, ...@@ -1099,12 +1100,14 @@ int mt7615_mcu_set_sta_rec(struct mt7615_dev *dev, struct ieee80211_vif *vif,
&req, sizeof(req), true); &req, sizeof(req), true);
} }
int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif, int mt7615_mcu_set_bcn(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
int en) int en)
{ {
struct mt7615_dev *dev = mt7615_hw_dev(hw);
struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv; struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
struct mt76_wcid *wcid = &dev->mt76.global_wcid; struct mt76_wcid *wcid = &dev->mt76.global_wcid;
struct ieee80211_mutable_offsets offs; struct ieee80211_mutable_offsets offs;
struct ieee80211_tx_info *info;
struct req { struct req {
u8 omac_idx; u8 omac_idx;
u8 enable; u8 enable;
...@@ -1128,7 +1131,7 @@ int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif, ...@@ -1128,7 +1131,7 @@ int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif,
}; };
struct sk_buff *skb; struct sk_buff *skb;
skb = ieee80211_beacon_get_template(mt76_hw(dev), vif, &offs); skb = ieee80211_beacon_get_template(hw, vif, &offs);
if (!skb) if (!skb)
return -EINVAL; return -EINVAL;
...@@ -1138,6 +1141,11 @@ int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif, ...@@ -1138,6 +1141,11 @@ int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif,
return -EINVAL; return -EINVAL;
} }
if (mvif->band_idx) {
info = IEEE80211_SKB_CB(skb);
info->hw_queue |= MT_TX_HW_QUEUE_EXT_PHY;
}
mt7615_mac_write_txwi(dev, (__le32 *)(req.pkt), skb, wcid, NULL, mt7615_mac_write_txwi(dev, (__le32 *)(req.pkt), skb, wcid, NULL,
0, NULL); 0, NULL);
memcpy(req.pkt + MT_TXD_SIZE, skb->data, skb->len); memcpy(req.pkt + MT_TXD_SIZE, skb->data, skb->len);
...@@ -1156,14 +1164,16 @@ int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif, ...@@ -1156,14 +1164,16 @@ int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif,
&req, sizeof(req), true); &req, sizeof(req), true);
} }
int mt7615_mcu_set_tx_power(struct mt7615_dev *dev) int mt7615_mcu_set_tx_power(struct mt7615_phy *phy)
{ {
int i, ret, n_chains = hweight8(dev->mphy.antenna_mask); struct mt7615_dev *dev = phy->dev;
struct cfg80211_chan_def *chandef = &dev->mphy.chandef; struct mt76_phy *mphy = phy->mt76;
int i, ret, n_chains = hweight8(mphy->antenna_mask);
struct cfg80211_chan_def *chandef = &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;
struct ieee80211_hw *hw = mt76_hw(dev); struct ieee80211_hw *hw = mphy->hw;
struct { struct {
u8 center_chan; u8 center_chan;
u8 dbdc_idx; u8 dbdc_idx;
...@@ -1172,6 +1182,7 @@ int mt7615_mcu_set_tx_power(struct mt7615_dev *dev) ...@@ -1172,6 +1182,7 @@ int mt7615_mcu_set_tx_power(struct mt7615_dev *dev)
} __packed req_hdr = { } __packed req_hdr = {
.center_chan = ieee80211_frequency_to_channel(freq), .center_chan = ieee80211_frequency_to_channel(freq),
.band = band, .band = band,
.dbdc_idx = phy != &dev->phy,
}; };
s8 tx_power; s8 tx_power;
...@@ -1200,7 +1211,7 @@ int mt7615_mcu_set_tx_power(struct mt7615_dev *dev) ...@@ -1200,7 +1211,7 @@ int mt7615_mcu_set_tx_power(struct mt7615_dev *dev)
break; break;
} }
tx_power = max_t(s8, tx_power, 0); tx_power = max_t(s8, tx_power, 0);
dev->mphy.txpower_cur = tx_power; mphy->txpower_cur = tx_power;
target_chains = mt7615_ext_pa_enabled(dev, band) ? 1 : n_chains; target_chains = mt7615_ext_pa_enabled(dev, band) ? 1 : n_chains;
for (i = 0; i < target_chains; i++) { for (i = 0; i < target_chains; i++) {
...@@ -1274,9 +1285,10 @@ int mt7615_mcu_rdd_send_pattern(struct mt7615_dev *dev) ...@@ -1274,9 +1285,10 @@ int mt7615_mcu_rdd_send_pattern(struct mt7615_dev *dev)
&req, sizeof(req), false); &req, sizeof(req), false);
} }
int mt7615_mcu_set_channel(struct mt7615_dev *dev) int mt7615_mcu_set_channel(struct mt7615_phy *phy)
{ {
struct cfg80211_chan_def *chandef = &dev->mphy.chandef; struct mt7615_dev *dev = phy->dev;
struct cfg80211_chan_def *chandef = &phy->mt76->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 +1325,9 @@ int mt7615_mcu_set_channel(struct mt7615_dev *dev) ...@@ -1313,7 +1325,9 @@ 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->mphy.chandef.width) { req.band_idx = phy != &dev->phy;
switch (chandef->width) {
case NL80211_CHAN_WIDTH_40: case NL80211_CHAN_WIDTH_40:
req.bw = CMD_CBW_40MHZ; req.bw = CMD_CBW_40MHZ;
break; break;
......
...@@ -79,12 +79,20 @@ struct mt7615_vif { ...@@ -79,12 +79,20 @@ struct mt7615_vif {
struct mt7615_sta sta; struct mt7615_sta sta;
}; };
struct mt7615_phy {
struct mt76_phy *mt76;
struct mt7615_dev *dev;
u32 rxfilter;
};
struct mt7615_dev { struct mt7615_dev {
union { /* must be first */ union { /* must be first */
struct mt76_dev mt76; struct mt76_dev mt76;
struct mt76_phy mphy; struct mt76_phy mphy;
}; };
struct mt7615_phy phy;
u16 chainmask; u16 chainmask;
u32 vif_mask; u32 vif_mask;
u32 omac_mask; u32 omac_mask;
...@@ -164,6 +172,33 @@ enum mt7615_rdd_cmd { ...@@ -164,6 +172,33 @@ enum mt7615_rdd_cmd {
RDD_RESUME_BF, RDD_RESUME_BF,
}; };
static inline struct mt7615_phy *
mt7615_hw_phy(struct ieee80211_hw *hw)
{
struct mt76_phy *phy = hw->priv;
return phy->priv;
}
static inline struct mt7615_dev *
mt7615_hw_dev(struct ieee80211_hw *hw)
{
struct mt76_phy *phy = hw->priv;
return container_of(phy->dev, struct mt7615_dev, mt76);
}
static inline struct mt7615_phy *
mt7615_ext_phy(struct mt7615_dev *dev)
{
struct mt76_phy *phy = dev->mt76.phy2;
if (!phy)
return NULL;
return phy->priv;
}
extern const struct ieee80211_ops mt7615_ops; extern const struct ieee80211_ops mt7615_ops;
extern struct pci_driver mt7615_pci_driver; extern struct pci_driver mt7615_pci_driver;
...@@ -182,7 +217,7 @@ int mt7615_mcu_set_dev_info(struct mt7615_dev *dev, ...@@ -182,7 +217,7 @@ int mt7615_mcu_set_dev_info(struct mt7615_dev *dev,
struct ieee80211_vif *vif, bool enable); struct ieee80211_vif *vif, bool enable);
int mt7615_mcu_set_bss_info(struct mt7615_dev *dev, struct ieee80211_vif *vif, int mt7615_mcu_set_bss_info(struct mt7615_dev *dev, struct ieee80211_vif *vif,
int en); int en);
void mt7615_mac_set_rates(struct mt7615_dev *dev, struct mt7615_sta *sta, void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta,
struct ieee80211_tx_rate *probe_rate, struct ieee80211_tx_rate *probe_rate,
struct ieee80211_tx_rate *rates); struct ieee80211_tx_rate *rates);
int mt7615_mcu_wtbl_bmc(struct mt7615_dev *dev, struct ieee80211_vif *vif, int mt7615_mcu_wtbl_bmc(struct mt7615_dev *dev, struct ieee80211_vif *vif,
...@@ -195,9 +230,9 @@ int mt7615_mcu_set_sta_rec_bmc(struct mt7615_dev *dev, ...@@ -195,9 +230,9 @@ int mt7615_mcu_set_sta_rec_bmc(struct mt7615_dev *dev,
struct ieee80211_vif *vif, bool en); struct ieee80211_vif *vif, bool en);
int mt7615_mcu_set_sta_rec(struct mt7615_dev *dev, struct ieee80211_vif *vif, int mt7615_mcu_set_sta_rec(struct mt7615_dev *dev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta, bool en); struct ieee80211_sta *sta, bool en);
int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif, int mt7615_mcu_set_bcn(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
int en); int en);
int mt7615_mcu_set_channel(struct mt7615_dev *dev); int mt7615_mcu_set_channel(struct mt7615_phy *phy);
int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue, int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue,
const struct ieee80211_tx_queue_params *params); const struct ieee80211_tx_queue_params *params);
int mt7615_mcu_set_tx_ba(struct mt7615_dev *dev, int mt7615_mcu_set_tx_ba(struct mt7615_dev *dev,
...@@ -261,10 +296,10 @@ int mt7615_mac_wtbl_set_key(struct mt7615_dev *dev, struct mt76_wcid *wcid, ...@@ -261,10 +296,10 @@ int mt7615_mac_wtbl_set_key(struct mt7615_dev *dev, struct mt76_wcid *wcid,
int mt7615_mcu_set_eeprom(struct mt7615_dev *dev); int mt7615_mcu_set_eeprom(struct mt7615_dev *dev);
int mt7615_mcu_init_mac(struct mt7615_dev *dev); int mt7615_mcu_init_mac(struct mt7615_dev *dev);
int mt7615_mcu_set_rts_thresh(struct mt7615_dev *dev, u32 val); int mt7615_mcu_set_rts_thresh(struct mt7615_phy *phy, u32 val);
int mt7615_mcu_ctrl_pm_state(struct mt7615_dev *dev, int enter); int mt7615_mcu_ctrl_pm_state(struct mt7615_dev *dev, int band, int enter);
int mt7615_mcu_get_temperature(struct mt7615_dev *dev, int index); int mt7615_mcu_get_temperature(struct mt7615_dev *dev, int index);
int mt7615_mcu_set_tx_power(struct mt7615_dev *dev); int mt7615_mcu_set_tx_power(struct mt7615_phy *phy);
void mt7615_mcu_exit(struct mt7615_dev *dev); void mt7615_mcu_exit(struct mt7615_dev *dev);
int mt7615_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, int mt7615_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
......
...@@ -170,7 +170,7 @@ ...@@ -170,7 +170,7 @@
#define MT_WF_RMAC_BASE 0x21200 #define MT_WF_RMAC_BASE 0x21200
#define MT_WF_RMAC(ofs) (MT_WF_RMAC_BASE + (ofs)) #define MT_WF_RMAC(ofs) (MT_WF_RMAC_BASE + (ofs))
#define MT_WF_RFCR MT_WF_RMAC(0x000) #define MT_WF_RFCR(_band) MT_WF_RMAC((_band) ? 0x100 : 0x000)
#define MT_WF_RFCR_DROP_STBC_MULTI BIT(0) #define MT_WF_RFCR_DROP_STBC_MULTI BIT(0)
#define MT_WF_RFCR_DROP_FCSFAIL BIT(1) #define MT_WF_RFCR_DROP_FCSFAIL BIT(1)
#define MT_WF_RFCR_DROP_VERSION BIT(3) #define MT_WF_RFCR_DROP_VERSION BIT(3)
...@@ -193,7 +193,7 @@ ...@@ -193,7 +193,7 @@
#define MT_WF_RFCR_DROP_NDPA BIT(20) #define MT_WF_RFCR_DROP_NDPA BIT(20)
#define MT_WF_RFCR_DROP_UNWANTED_CTL BIT(21) #define MT_WF_RFCR_DROP_UNWANTED_CTL BIT(21)
#define MT_WF_RFCR1 MT_WF_RMAC(0x004) #define MT_WF_RFCR1(_band) MT_WF_RMAC((_band) ? 0x104 : 0x004)
#define MT_WF_RFCR1_DROP_ACK BIT(4) #define MT_WF_RFCR1_DROP_ACK BIT(4)
#define MT_WF_RFCR1_DROP_BF_POLL BIT(5) #define MT_WF_RFCR1_DROP_BF_POLL BIT(5)
#define MT_WF_RFCR1_DROP_BA BIT(6) #define MT_WF_RFCR1_DROP_BA BIT(6)
...@@ -207,6 +207,7 @@ ...@@ -207,6 +207,7 @@
#define MT_WF_RMAC_MIB_AIRTIME0 MT_WF_RMAC(0x0380) #define MT_WF_RMAC_MIB_AIRTIME0 MT_WF_RMAC(0x0380)
#define MT_WF_RMAC_MIB_TIME5 MT_WF_RMAC(0x03d8) #define MT_WF_RMAC_MIB_TIME5 MT_WF_RMAC(0x03d8)
#define MT_WF_RMAC_MIB_TIME6 MT_WF_RMAC(0x03dc)
#define MT_MIB_OBSSTIME_MASK GENMASK(23, 0) #define MT_MIB_OBSSTIME_MASK GENMASK(23, 0)
#define MT_WF_DMA_BASE 0x21800 #define MT_WF_DMA_BASE 0x21800
......
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