2024-06-13 03:02:53

by Sean Wang

[permalink] [raw]
Subject: [PATCH 00/47] Prerequisite Refactoring for Enabling MLO on MT7925

From: Sean Wang <[email protected]>

I'm submitting some patches that are essential preliminary steps for getting
Multi-Link Operation (MLO) up and running smoothly on the MT7925 driver.

Before we can activate MLO, we need to do some necessary refactoring work.
This involves adjusting how the driver handles certain commands and data to
support per-link STA and per-BSS operations. It's like laying down a strong
foundation so that MLO can seamlessly integrate with our existing setup.

It's important to note that these patches focus solely on refactoring work.
We're not changing any of the current functions or logic; we're just making
sure everything is structured properly to support MLO when it's enabled.

I've tested these patches to make sure they're reliable and won't mess up
anything that's already working.

Deren Wu (5):
wifi: mt76: mt792x: add struct mt792x_bss_conf
wifi: mt76: mt792x: add struct mt792x_link_sta
wifi: mt76: mt792x: add struct mt792x_chanctx
wifi: mt76: mt7925: support for split bss_info_changed method
wifi: mt76: mt7925: extend mt7925_mcu_set_tx with for per-link BSS

Sean Wang (42):
wifi: mt76: mt792x: extend mt76_connac_mcu_uni_add_dev for per-link
BSS
wifi: mt76: mt7925: extend mt7925_mcu_add_bss_info for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_set_timing for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_bss_ifs_tlv for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_bss_color_tlv for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_bss_he_tlv for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_bss_qos_tlv for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_bss_mld_tlv for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_bss_bmc_tlv for per-link BSS
wifi: mt76: mt7925: remove unused parameters in mt7925_mcu_bss_bmc_tlv
wifi: mt76: mt7925: extend mt7925_mcu_bss_sec_tlv for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_bss_basic_tlv for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_set_bss_pm for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_[abort, set]_roc for per-link
BSS
wifi: mt76: mt7925: extend mt7925_mcu_uni_bss_bcnft for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_uni_bss_ps for per-link BSS
wifi: mt76: mt7925: add mt7925_mcu_bss_rlm_tlv to constitue the RLM
TLV
wifi: mt76: mt7925: mt7925_mcu_set_chctx rely on
mt7925_mcu_bss_rlm_tlv
wifi: mt76: mt7925: extend mt7925_mcu_sta_update for per-link STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_state_v2_tlv for per-link
STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_rate_ctrl_tlv with per-link
STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_eht_tlv for per-link STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_he_6g_tlv for per-link STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_he_tlv for per-link STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_amsdu_tlv for per-link STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_vht_tlv for per-link STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_ht_tlv for per-link STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_phy_tlv for per-link STA
wifi: mt76: mt7925: extend mt7925_get_phy_mode_ext for per-link STA
wifi: mt76: mt7925: extend mt7925_get_phy_mode for per-link STA
wifi: mt76: mt792x: extend mt76_connac_get_phy_mode_v2 for per-link
STA
wifi: mt76: mt762x: extend mt76_connac_mcu_sta_basic_tlv for per-link
STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_hdr_trans_tlv for per-link
STA
wifi: mt76: mt7925: extend mt7925_mcu_add_bss_info for per-link STA
wifi: mt76: mt7925: extend mt7925_mcu_bss_mld_tlv for per-link STA
wifi: mt76: mt7925: extend mt7925_mcu_bss_basic_tlv for per-link STA
wifi: mt76: mt7925: add mt7925_mac_link_sta_add to create per-link STA
wifi: mt76: mt7925: add mt7925_mac_link_sta_assoc to associate
per-link STA
wifi: mt76: mt7925: add mt7925_mac_link_sta_remove to remove per-link
STA
wifi: mt76: mt7925: add mt7925_mac_link_bss_add to create per-link BSS
wifi: mt76: mt7925: add mt7925_mac_link_bss_remove to remove per-link
BSS
wifi: mt76: mt7925: simpify mt7925_mcu_sta_cmd logic by removing
fw_offload

.../net/wireless/mediatek/mt76/mt7615/mcu.c | 8 +-
.../wireless/mediatek/mt76/mt76_connac_mcu.c | 56 +-
.../wireless/mediatek/mt76/mt76_connac_mcu.h | 19 +-
.../net/wireless/mediatek/mt76/mt7915/mcu.c | 4 +-
.../net/wireless/mediatek/mt76/mt7921/mac.c | 66 +--
.../net/wireless/mediatek/mt76/mt7921/main.c | 143 +++--
.../net/wireless/mediatek/mt76/mt7921/mcu.c | 46 +-
.../wireless/mediatek/mt76/mt7921/pci_mac.c | 4 +-
.../net/wireless/mediatek/mt76/mt7925/mac.c | 69 +--
.../net/wireless/mediatek/mt76/mt7925/main.c | 452 +++++++++-------
.../net/wireless/mediatek/mt76/mt7925/mcu.c | 500 ++++++++++--------
.../net/wireless/mediatek/mt76/mt7925/mcu.h | 25 +-
.../wireless/mediatek/mt76/mt7925/mt7925.h | 15 +-
.../wireless/mediatek/mt76/mt7925/pci_mac.c | 4 +-
drivers/net/wireless/mediatek/mt76/mt792x.h | 78 ++-
.../net/wireless/mediatek/mt76/mt792x_core.c | 70 ++-
.../net/wireless/mediatek/mt76/mt792x_mac.c | 8 +-
.../net/wireless/mediatek/mt76/mt7996/mcu.c | 2 +-
18 files changed, 896 insertions(+), 673 deletions(-)

--
2.34.1



2024-06-13 03:02:57

by Sean Wang

[permalink] [raw]
Subject: [PATCH 01/47] wifi: mt76: mt792x: add struct mt792x_bss_conf

From: Deren Wu <[email protected]>

We are introducing a new structure, mt792x_bss_conf, to manage per-link
configurations in preparation for future STA support of Multi-Link
Operation (MLO).

The patch does not include any logic changes, only structural changes.

We have moved relevant parameters from the mt7921x_vif structure such
as to mt76 of mt76_vif structure, rssi and Tx queue parameters to
mt7921x_bss_conf structure. We can access those members to configure the
BSS for this interface, whether it is our own BSS or the one we are
associated with.

However, we have not yet created the per-link BSS configuration indexed by
link ID for Multi-Link Device (MLD) support. This step needs to be
extended before adding MLD support for AP mode.

Co-developed-by: Sean Wang <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7921/main.c | 42 +++++++-------
.../net/wireless/mediatek/mt76/mt7921/mcu.c | 42 +++++++-------
.../net/wireless/mediatek/mt76/mt7925/main.c | 56 +++++++++----------
.../net/wireless/mediatek/mt76/mt7925/mcu.c | 56 +++++++++----------
drivers/net/wireless/mediatek/mt76/mt792x.h | 12 ++--
.../net/wireless/mediatek/mt76/mt792x_core.c | 18 +++---
.../net/wireless/mediatek/mt76/mt792x_mac.c | 2 +-
7 files changed, 115 insertions(+), 113 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index 3e3ad3518d85..2752e1735575 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -295,30 +295,30 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)

mt792x_mutex_acquire(dev);

- mvif->mt76.idx = __ffs64(~dev->mt76.vif_mask);
- if (mvif->mt76.idx >= MT792x_MAX_INTERFACES) {
+ mvif->bss_conf.mt76.idx = __ffs64(~dev->mt76.vif_mask);
+ if (mvif->bss_conf.mt76.idx >= MT792x_MAX_INTERFACES) {
ret = -ENOSPC;
goto out;
}

- mvif->mt76.omac_idx = mvif->mt76.idx;
+ mvif->bss_conf.mt76.omac_idx = mvif->bss_conf.mt76.idx;
mvif->phy = phy;
- mvif->mt76.band_idx = 0;
- mvif->mt76.wmm_idx = mvif->mt76.idx % MT76_CONNAC_MAX_WMM_SETS;
+ mvif->bss_conf.mt76.band_idx = 0;
+ mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx % MT76_CONNAC_MAX_WMM_SETS;

ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.wcid,
true);
if (ret)
goto out;

- dev->mt76.vif_mask |= BIT_ULL(mvif->mt76.idx);
- phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx);
+ dev->mt76.vif_mask |= BIT_ULL(mvif->bss_conf.mt76.idx);
+ phy->omac_mask |= BIT_ULL(mvif->bss_conf.mt76.omac_idx);

- idx = MT792x_WTBL_RESERVED - mvif->mt76.idx;
+ idx = MT792x_WTBL_RESERVED - mvif->bss_conf.mt76.idx;

INIT_LIST_HEAD(&mvif->sta.wcid.poll_list);
mvif->sta.wcid.idx = idx;
- mvif->sta.wcid.phy_idx = mvif->mt76.band_idx;
+ mvif->sta.wcid.phy_idx = mvif->bss_conf.mt76.band_idx;
mvif->sta.wcid.hw_key_idx = -1;
mvif->sta.wcid.tx_info |= MT_WCID_TX_INFO_SET;
mt76_wcid_init(&mvif->sta.wcid);
@@ -326,7 +326,7 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
mt7921_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

- ewma_rssi_init(&mvif->rssi);
+ ewma_rssi_init(&mvif->bss_conf.rssi);

rcu_assign_pointer(dev->mt76.wcid[idx], &mvif->sta.wcid);
if (vif->txq) {
@@ -718,7 +718,7 @@ static void mt7921_bss_info_changed(struct ieee80211_hw *hw,
if (changed & BSS_CHANGED_ARP_FILTER) {
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;

- mt76_connac_mcu_update_arp_filter(&dev->mt76, &mvif->mt76,
+ mt76_connac_mcu_update_arp_filter(&dev->mt76, &mvif->bss_conf.mt76,
info);
}

@@ -803,7 +803,7 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
msta->vif = mvif;
msta->wcid.sta = 1;
msta->wcid.idx = idx;
- msta->wcid.phy_idx = mvif->mt76.band_idx;
+ msta->wcid.phy_idx = mvif->bss_conf.mt76.band_idx;
msta->wcid.tx_info |= MT_WCID_TX_INFO_SET;
msta->last_txs = jiffies;

@@ -841,7 +841,7 @@ void mt7921_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,

if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
mt76_connac_mcu_uni_add_bss(&dev->mphy, vif, &mvif->sta.wcid,
- true, mvif->mt76.ctx);
+ true, mvif->bss_conf.mt76.ctx);

ewma_avg_signal_init(&msta->avg_ack_signal);

@@ -872,11 +872,11 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;

mvif->wep_sta = NULL;
- ewma_rssi_init(&mvif->rssi);
+ ewma_rssi_init(&mvif->bss_conf.rssi);
if (!sta->tdls)
mt76_connac_mcu_uni_add_bss(&dev->mphy, vif,
&mvif->sta.wcid, false,
- mvif->mt76.ctx);
+ mvif->bss_conf.mt76.ctx);
}

spin_lock_bh(&dev->mt76.sta_poll_lock);
@@ -1196,7 +1196,7 @@ static void mt7921_ipv6_addr_change(struct ieee80211_hw *hw,
struct mt76_connac_arpns_tlv arpns;
} req_hdr = {
.hdr = {
- .bss_idx = mvif->mt76.idx,
+ .bss_idx = mvif->bss_conf.mt76.idx,
},
.arpns = {
.tag = cpu_to_le16(UNI_OFFLOAD_OFFLOAD_ND),
@@ -1295,7 +1295,7 @@ mt7921_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
mt792x_mutex_acquire(dev);

err = mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.wcid,
- true, mvif->mt76.ctx);
+ true, mvif->bss_conf.mt76.ctx);
if (err)
goto out;

@@ -1327,7 +1327,7 @@ mt7921_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
goto out;

mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.wcid, false,
- mvif->mt76.ctx);
+ mvif->bss_conf.mt76.ctx);

out:
mt792x_mutex_release(dev);
@@ -1352,13 +1352,13 @@ static void mt7921_ctx_iter(void *priv, u8 *mac,
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct ieee80211_chanctx_conf *ctx = priv;

- if (ctx != mvif->mt76.ctx)
+ if (ctx != mvif->bss_conf.mt76.ctx)
return;

if (vif->type == NL80211_IFTYPE_MONITOR)
mt7921_mcu_config_sniffer(mvif, ctx);
else
- mt76_connac_mcu_uni_set_chctx(mvif->phy->mt76, &mvif->mt76, ctx);
+ mt76_connac_mcu_uni_set_chctx(mvif->phy->mt76, &mvif->bss_conf.mt76, ctx);
}

static void
@@ -1385,7 +1385,7 @@ static void mt7921_mgd_prepare_tx(struct ieee80211_hw *hw,
jiffies_to_msecs(HZ);

mt792x_mutex_acquire(dev);
- mt7921_set_roc(mvif->phy, mvif, mvif->mt76.ctx->def.chan, duration,
+ mt7921_set_roc(mvif->phy, mvif, mvif->bss_conf.mt76.ctx->def.chan, duration,
MT7921_ROC_REQ_JOIN);
mt792x_mutex_release(dev);
}
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
index bdd8b5f19b24..0453af012016 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
@@ -105,7 +105,7 @@ mt7921_mcu_set_ipv6_ns_filter(struct mt76_dev *dev,
struct mt76_connac_arpns_tlv arpns;
} req = {
.hdr = {
- .bss_idx = mvif->mt76.idx,
+ .bss_idx = mvif->bss_conf.mt76.idx,
},
.arpns = {
.tag = cpu_to_le16(UNI_OFFLOAD_OFFLOAD_ND),
@@ -260,7 +260,7 @@ mt7921_mcu_rssi_monitor_iter(void *priv, u8 *mac,
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct mt76_connac_rssi_notify_event *event = priv;
enum nl80211_cqm_rssi_threshold_event nl_event;
- s32 rssi = le32_to_cpu(event->rssi[mvif->mt76.idx]);
+ s32 rssi = le32_to_cpu(event->rssi[mvif->bss_conf.mt76.idx]);

if (!rssi)
return;
@@ -388,7 +388,7 @@ int mt7921_mcu_uni_tx_ba(struct mt792x_dev *dev,
if (enable && !params->amsdu)
msta->wcid.amsdu = false;

- return mt76_connac_mcu_sta_ba(&dev->mt76, &msta->vif->mt76, params,
+ return mt76_connac_mcu_sta_ba(&dev->mt76, &msta->vif->bss_conf.mt76, params,
MCU_UNI_CMD(STA_REC_UPDATE),
enable, true);
}
@@ -399,7 +399,7 @@ int mt7921_mcu_uni_rx_ba(struct mt792x_dev *dev,
{
struct mt792x_sta *msta = (struct mt792x_sta *)params->sta->drv_priv;

- return mt76_connac_mcu_sta_ba(&dev->mt76, &msta->vif->mt76, params,
+ return mt76_connac_mcu_sta_ba(&dev->mt76, &msta->vif->bss_conf.mt76, params,
MCU_UNI_CMD(STA_REC_UPDATE),
enable, false);
}
@@ -678,9 +678,9 @@ int mt7921_mcu_set_tx(struct mt792x_dev *dev, struct ieee80211_vif *vif)
u8 wmm_idx;
u8 pad;
} __packed req = {
- .bss_idx = mvif->mt76.idx,
+ .bss_idx = mvif->bss_conf.mt76.idx,
.qos = vif->bss_conf.qos,
- .wmm_idx = mvif->mt76.wmm_idx,
+ .wmm_idx = mvif->bss_conf.mt76.wmm_idx,
};
struct mu_edca {
u8 cw_min;
@@ -701,15 +701,15 @@ int mt7921_mcu_set_tx(struct mt792x_dev *dev, struct ieee80211_vif *vif)
struct mu_edca edca[IEEE80211_NUM_ACS];
u8 pad3[32];
} __packed req_mu = {
- .bss_idx = mvif->mt76.idx,
+ .bss_idx = mvif->bss_conf.mt76.idx,
.qos = vif->bss_conf.qos,
- .wmm_idx = mvif->mt76.wmm_idx,
+ .wmm_idx = mvif->bss_conf.mt76.wmm_idx,
};
static const int to_aci[] = { 1, 0, 2, 3 };
int ac, ret;

for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
- struct ieee80211_tx_queue_params *q = &mvif->queue_params[ac];
+ struct ieee80211_tx_queue_params *q = &mvif->bss_conf.queue_params[ac];
struct edca *e = &req.edca[to_aci[ac]];

e->aifs = cpu_to_le16(q->aifs);
@@ -738,10 +738,10 @@ int mt7921_mcu_set_tx(struct mt792x_dev *dev, struct ieee80211_vif *vif)
struct ieee80211_he_mu_edca_param_ac_rec *q;
struct mu_edca *e;

- if (!mvif->queue_params[ac].mu_edca)
+ if (!mvif->bss_conf.queue_params[ac].mu_edca)
break;

- q = &mvif->queue_params[ac].mu_edca_param_rec;
+ q = &mvif->bss_conf.queue_params[ac].mu_edca_param_rec;
e = &(req_mu.edca[to_aci[ac]]);

e->cw_min = q->ecw_min_max & 0xf;
@@ -790,7 +790,7 @@ int mt7921_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_vif *vif,
.tokenid = token_id,
.reqtype = type,
.maxinterval = cpu_to_le32(duration),
- .bss_idx = vif->mt76.idx,
+ .bss_idx = vif->bss_conf.mt76.idx,
.control_channel = chan->hw_value,
.bw = CMD_CBW_20MHZ,
.bw_from_ap = CMD_CBW_20MHZ,
@@ -842,7 +842,7 @@ int mt7921_mcu_abort_roc(struct mt792x_phy *phy, struct mt792x_vif *vif,
.tag = cpu_to_le16(UNI_ROC_ABORT),
.len = cpu_to_le16(sizeof(struct roc_abort_tlv)),
.tokenid = token_id,
- .bss_idx = vif->mt76.idx,
+ .bss_idx = vif->bss_conf.mt76.idx,
.dbdcband = 0xff, /* auto*/
},
};
@@ -947,7 +947,7 @@ int mt7921_mcu_uni_bss_ps(struct mt792x_dev *dev, struct ieee80211_vif *vif)
} __packed ps;
} __packed ps_req = {
.hdr = {
- .bss_idx = mvif->mt76.idx,
+ .bss_idx = mvif->bss_conf.mt76.idx,
},
.ps = {
.tag = cpu_to_le16(UNI_BSS_INFO_PS),
@@ -982,7 +982,7 @@ mt7921_mcu_uni_bss_bcnft(struct mt792x_dev *dev, struct ieee80211_vif *vif,
} __packed bcnft;
} __packed bcnft_req = {
.hdr = {
- .bss_idx = mvif->mt76.idx,
+ .bss_idx = mvif->bss_conf.mt76.idx,
},
.bcnft = {
.tag = cpu_to_le16(UNI_BSS_INFO_BCNFT),
@@ -1015,7 +1015,7 @@ mt7921_mcu_set_bss_pm(struct mt792x_dev *dev, struct ieee80211_vif *vif,
u8 bmc_triggered_ac;
u8 pad;
} req = {
- .bss_idx = mvif->mt76.idx,
+ .bss_idx = mvif->bss_conf.mt76.idx,
.aid = cpu_to_le16(vif->cfg.aid),
.dtim_period = vif->bss_conf.dtim_period,
.bcn_interval = cpu_to_le16(vif->bss_conf.beacon_int),
@@ -1024,7 +1024,7 @@ mt7921_mcu_set_bss_pm(struct mt792x_dev *dev, struct ieee80211_vif *vif,
u8 bss_idx;
u8 pad[3];
} req_hdr = {
- .bss_idx = mvif->mt76.idx,
+ .bss_idx = mvif->bss_conf.mt76.idx,
};
int err;

@@ -1042,7 +1042,7 @@ int mt7921_mcu_sta_update(struct mt792x_dev *dev, struct ieee80211_sta *sta,
enum mt76_sta_info_state state)
{
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
- int rssi = -ewma_rssi_read(&mvif->rssi);
+ int rssi = -ewma_rssi_read(&mvif->bss_conf.rssi);
struct mt76_sta_cmd_info info = {
.sta = sta,
.vif = vif,
@@ -1190,7 +1190,7 @@ int mt7921_mcu_config_sniffer(struct mt792x_vif *vif,
} __packed tlv;
} __packed req = {
.hdr = {
- .band_idx = vif->mt76.band_idx,
+ .band_idx = vif->bss_conf.mt76.band_idx,
},
.tlv = {
.tag = cpu_to_le16(1),
@@ -1251,7 +1251,7 @@ mt7921_mcu_uni_add_beacon_offload(struct mt792x_dev *dev,
} __packed beacon_tlv;
} req = {
.hdr = {
- .bss_idx = mvif->mt76.idx,
+ .bss_idx = mvif->bss_conf.mt76.idx,
},
.beacon_tlv = {
.tag = cpu_to_le16(UNI_BSS_INFO_BCN_CONTENT),
@@ -1460,7 +1460,7 @@ int mt7921_mcu_set_rssimonitor(struct mt792x_dev *dev, struct ieee80211_vif *vif
.enable = vif->cfg.assoc,
.cqm_rssi_high = vif->bss_conf.cqm_rssi_thold + vif->bss_conf.cqm_rssi_hyst,
.cqm_rssi_low = vif->bss_conf.cqm_rssi_thold - vif->bss_conf.cqm_rssi_hyst,
- .bss_idx = mvif->mt76.idx,
+ .bss_idx = mvif->bss_conf.mt76.idx,
};

return mt76_mcu_send_msg(&dev->mt76, MCU_CE_CMD(RSSI_MONITOR),
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 6179798a8845..dfc606cc9bdd 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -328,35 +328,35 @@ mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)

mt792x_mutex_acquire(dev);

- mvif->mt76.idx = __ffs64(~dev->mt76.vif_mask);
- if (mvif->mt76.idx >= MT792x_MAX_INTERFACES) {
+ mvif->bss_conf.mt76.idx = __ffs64(~dev->mt76.vif_mask);
+ if (mvif->bss_conf.mt76.idx >= MT792x_MAX_INTERFACES) {
ret = -ENOSPC;
goto out;
}

- mvif->mt76.omac_idx = mvif->mt76.idx;
+ mvif->bss_conf.mt76.omac_idx = mvif->bss_conf.mt76.idx;
mvif->phy = phy;
- mvif->mt76.band_idx = 0;
- mvif->mt76.wmm_idx = mvif->mt76.idx % MT76_CONNAC_MAX_WMM_SETS;
+ mvif->bss_conf.mt76.band_idx = 0;
+ mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx % MT76_CONNAC_MAX_WMM_SETS;

if (phy->mt76->chandef.chan->band != NL80211_BAND_2GHZ)
- mvif->mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL + 4;
+ mvif->bss_conf.mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL + 4;
else
- mvif->mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL;
+ mvif->bss_conf.mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL;

ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.wcid,
true);
if (ret)
goto out;

- dev->mt76.vif_mask |= BIT_ULL(mvif->mt76.idx);
- phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx);
+ dev->mt76.vif_mask |= BIT_ULL(mvif->bss_conf.mt76.idx);
+ phy->omac_mask |= BIT_ULL(mvif->bss_conf.mt76.omac_idx);

- idx = MT792x_WTBL_RESERVED - mvif->mt76.idx;
+ idx = MT792x_WTBL_RESERVED - mvif->bss_conf.mt76.idx;

INIT_LIST_HEAD(&mvif->sta.wcid.poll_list);
mvif->sta.wcid.idx = idx;
- mvif->sta.wcid.phy_idx = mvif->mt76.band_idx;
+ mvif->sta.wcid.phy_idx = mvif->bss_conf.mt76.band_idx;
mvif->sta.wcid.hw_key_idx = -1;
mvif->sta.wcid.tx_info |= MT_WCID_TX_INFO_SET;
mvif->sta.vif = mvif;
@@ -365,7 +365,7 @@ mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
mt7925_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

- ewma_rssi_init(&mvif->rssi);
+ ewma_rssi_init(&mvif->bss_conf.rssi);

rcu_assign_pointer(dev->mt76.wcid[idx], &mvif->sta.wcid);
if (vif->txq) {
@@ -524,11 +524,11 @@ static int mt7925_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,

mt792x_mutex_acquire(dev);

- if (cmd == SET_KEY && !mvif->mt76.cipher) {
+ if (cmd == SET_KEY && !mvif->bss_conf.mt76.cipher) {
struct mt792x_phy *phy = mt792x_hw_phy(hw);

- mvif->mt76.cipher = mt7925_mcu_get_cipher(key->cipher);
- mt7925_mcu_add_bss_info(phy, mvif->mt76.ctx, vif, sta, true);
+ mvif->bss_conf.mt76.cipher = mt7925_mcu_get_cipher(key->cipher);
+ mt7925_mcu_add_bss_info(phy, mvif->bss_conf.mt76.ctx, vif, sta, true);
}

if (cmd == SET_KEY)
@@ -748,7 +748,7 @@ static void mt7925_bss_info_changed(struct ieee80211_hw *hw,
if (changed & BSS_CHANGED_ARP_FILTER) {
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;

- mt7925_mcu_update_arp_filter(&dev->mt76, &mvif->mt76, info);
+ mt7925_mcu_update_arp_filter(&dev->mt76, &mvif->bss_conf.mt76, info);
}

mt792x_mutex_release(dev);
@@ -770,7 +770,7 @@ int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
msta->vif = mvif;
msta->wcid.sta = 1;
msta->wcid.idx = idx;
- msta->wcid.phy_idx = mvif->mt76.band_idx;
+ msta->wcid.phy_idx = mvif->bss_conf.mt76.band_idx;
msta->wcid.tx_info |= MT_WCID_TX_INFO_SET;
msta->last_txs = jiffies;

@@ -786,7 +786,7 @@ int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,

/* should update bss info before STA add */
if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
- mt7925_mcu_add_bss_info(&dev->phy, mvif->mt76.ctx, vif, sta,
+ mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx, vif, sta,
false);

ret = mt7925_mcu_sta_update(dev, sta, vif, true,
@@ -810,7 +810,7 @@ void mt7925_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
mt792x_mutex_acquire(dev);

if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
- mt7925_mcu_add_bss_info(&dev->phy, mvif->mt76.ctx, vif, sta,
+ mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx, vif, sta,
true);

ewma_avg_signal_init(&msta->avg_ack_signal);
@@ -842,9 +842,9 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;

mvif->wep_sta = NULL;
- ewma_rssi_init(&mvif->rssi);
+ ewma_rssi_init(&mvif->bss_conf.rssi);
if (!sta->tdls)
- mt7925_mcu_add_bss_info(&dev->phy, mvif->mt76.ctx, vif, sta,
+ mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx, vif, sta,
false);
}

@@ -1190,7 +1190,7 @@ static void mt7925_ipv6_addr_change(struct ieee80211_hw *hw,
struct in6_addr ns_addrs[IEEE80211_BSS_ARP_ADDR_LIST_LEN];
} req_hdr = {
.hdr = {
- .bss_idx = mvif->mt76.idx,
+ .bss_idx = mvif->bss_conf.mt76.idx,
},
.arpns = {
.tag = cpu_to_le16(UNI_OFFLOAD_OFFLOAD_ND),
@@ -1288,7 +1288,7 @@ mt7925_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
};

/* firmware uses access class index */
- mvif->queue_params[mq_to_aci[queue]] = *params;
+ mvif->bss_conf.queue_params[mq_to_aci[queue]] = *params;

return 0;
}
@@ -1303,7 +1303,7 @@ mt7925_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,

mt792x_mutex_acquire(dev);

- err = mt7925_mcu_add_bss_info(&dev->phy, mvif->mt76.ctx, vif, NULL,
+ err = mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx, vif, NULL,
true);
if (err)
goto out;
@@ -1334,7 +1334,7 @@ mt7925_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
if (err)
goto out;

- mt7925_mcu_add_bss_info(&dev->phy, mvif->mt76.ctx, vif, NULL,
+ mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx, vif, NULL,
false);

out:
@@ -1360,14 +1360,14 @@ static void mt7925_ctx_iter(void *priv, u8 *mac,
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct ieee80211_chanctx_conf *ctx = priv;

- if (ctx != mvif->mt76.ctx)
+ if (ctx != mvif->bss_conf.mt76.ctx)
return;

if (vif->type == NL80211_IFTYPE_MONITOR) {
mt7925_mcu_set_sniffer(mvif->phy->dev, vif, true);
mt7925_mcu_config_sniffer(mvif, ctx);
} else {
- mt7925_mcu_set_chctx(mvif->phy->mt76, &mvif->mt76, ctx);
+ mt7925_mcu_set_chctx(mvif->phy->mt76, &mvif->bss_conf.mt76, ctx);
}
}

@@ -1395,7 +1395,7 @@ static void mt7925_mgd_prepare_tx(struct ieee80211_hw *hw,
jiffies_to_msecs(HZ);

mt792x_mutex_acquire(dev);
- mt7925_set_roc(mvif->phy, mvif, mvif->mt76.ctx->def.chan, duration,
+ mt7925_set_roc(mvif->phy, mvif, mvif->bss_conf.mt76.ctx->def.chan, duration,
MT7925_ROC_REQ_JOIN);
mt792x_mutex_release(dev);
}
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 652a9accc43c..c259aedb96e0 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -546,7 +546,7 @@ int mt7925_mcu_uni_tx_ba(struct mt792x_dev *dev,
if (enable && !params->amsdu)
msta->wcid.amsdu = false;

- return mt7925_mcu_sta_ba(&dev->mt76, &mvif->mt76, params,
+ return mt7925_mcu_sta_ba(&dev->mt76, &mvif->bss_conf.mt76, params,
enable, true);
}

@@ -557,7 +557,7 @@ int mt7925_mcu_uni_rx_ba(struct mt792x_dev *dev,
struct mt792x_sta *msta = (struct mt792x_sta *)params->sta->drv_priv;
struct mt792x_vif *mvif = msta->vif;

- return mt7925_mcu_sta_ba(&dev->mt76, &mvif->mt76, params,
+ return mt7925_mcu_sta_ba(&dev->mt76, &mvif->bss_conf.mt76, params,
enable, false);
}

@@ -889,7 +889,7 @@ int mt7925_mcu_wtbl_update_hdr_trans(struct mt792x_dev *dev,

msta = sta ? (struct mt792x_sta *)sta->drv_priv : &mvif->sta;

- skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
+ skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->bss_conf.mt76,
&msta->wcid,
MT7925_STA_UPDATE_MAX_SIZE);
if (IS_ERR(skb))
@@ -915,7 +915,7 @@ int mt7925_mcu_set_tx(struct mt792x_dev *dev, struct ieee80211_vif *vif)
u8 bss_idx;
u8 __rsv[3];
} __packed hdr = {
- .bss_idx = mvif->mt76.idx,
+ .bss_idx = mvif->bss_conf.mt76.idx,
};
struct sk_buff *skb;
int len = sizeof(hdr) + IEEE80211_NUM_ACS * sizeof(struct edca);
@@ -928,7 +928,7 @@ int mt7925_mcu_set_tx(struct mt792x_dev *dev, struct ieee80211_vif *vif)
skb_put_data(skb, &hdr, sizeof(hdr));

for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
- struct ieee80211_tx_queue_params *q = &mvif->queue_params[ac];
+ struct ieee80211_tx_queue_params *q = &mvif->bss_conf.queue_params[ac];
struct edca *e;
struct tlv *tlv;

@@ -976,7 +976,7 @@ mt7925_mcu_sta_key_tlv(struct mt76_wcid *wcid,

tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_KEY_V3, sizeof(*sec));
sec = (struct sta_rec_sec_uni *)tlv;
- sec->bss_idx = mvif->mt76.idx;
+ sec->bss_idx = mvif->bss_conf.mt76.idx;
sec->is_authenticator = 0;
sec->mgmt_prot = 0;
sec->wlan_idx = (u8)wcid->idx;
@@ -1085,7 +1085,7 @@ int mt7925_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_vif *vif,
.tokenid = token_id,
.reqtype = type,
.maxinterval = cpu_to_le32(duration),
- .bss_idx = vif->mt76.idx,
+ .bss_idx = vif->bss_conf.mt76.idx,
.control_channel = chan->hw_value,
.bw = CMD_CBW_20MHZ,
.bw_from_ap = CMD_CBW_20MHZ,
@@ -1137,7 +1137,7 @@ int mt7925_mcu_abort_roc(struct mt792x_phy *phy, struct mt792x_vif *vif,
.tag = cpu_to_le16(UNI_ROC_ABORT),
.len = cpu_to_le16(sizeof(struct roc_abort_tlv)),
.tokenid = token_id,
- .bss_idx = vif->mt76.idx,
+ .bss_idx = vif->bss_conf.mt76.idx,
.dbdcband = 0xff, /* auto*/
},
};
@@ -1263,7 +1263,7 @@ int mt7925_mcu_uni_bss_ps(struct mt792x_dev *dev, struct ieee80211_vif *vif)
} __packed ps;
} __packed ps_req = {
.hdr = {
- .bss_idx = mvif->mt76.idx,
+ .bss_idx = mvif->bss_conf.mt76.idx,
},
.ps = {
.tag = cpu_to_le16(UNI_BSS_INFO_PS),
@@ -1300,7 +1300,7 @@ mt7925_mcu_uni_bss_bcnft(struct mt792x_dev *dev, struct ieee80211_vif *vif,
} __packed bcnft;
} __packed bcnft_req = {
.hdr = {
- .bss_idx = mvif->mt76.idx,
+ .bss_idx = mvif->bss_conf.mt76.idx,
},
.bcnft = {
.tag = cpu_to_le16(UNI_BSS_INFO_BCNFT),
@@ -1338,7 +1338,7 @@ mt7925_mcu_set_bss_pm(struct mt792x_dev *dev, struct ieee80211_vif *vif,
} __packed enable;
} req = {
.hdr = {
- .bss_idx = mvif->mt76.idx,
+ .bss_idx = mvif->bss_conf.mt76.idx,
},
.enable = {
.tag = cpu_to_le16(UNI_BSS_INFO_BCNFT),
@@ -1358,7 +1358,7 @@ mt7925_mcu_set_bss_pm(struct mt792x_dev *dev, struct ieee80211_vif *vif,
} __packed disable;
} req1 = {
.hdr = {
- .bss_idx = mvif->mt76.idx,
+ .bss_idx = mvif->bss_conf.mt76.idx,
},
.disable = {
.tag = cpu_to_le16(UNI_BSS_INFO_PM_DISABLE),
@@ -1502,7 +1502,7 @@ mt7925_mcu_sta_phy_tlv(struct sk_buff *skb,
struct ieee80211_vif *vif, struct ieee80211_sta *sta)
{
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
- struct cfg80211_chan_def *chandef = &mvif->mt76.ctx->def;
+ struct cfg80211_chan_def *chandef = &mvif->bss_conf.mt76.ctx->def;
struct sta_rec_phy *phy;
struct tlv *tlv;
u8 af = 0, mm = 0;
@@ -1569,7 +1569,7 @@ mt7925_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb,
struct ieee80211_vif *vif, struct ieee80211_sta *sta)
{
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
- struct cfg80211_chan_def *chandef = &mvif->mt76.ctx->def;
+ struct cfg80211_chan_def *chandef = &mvif->bss_conf.mt76.ctx->def;
enum nl80211_band band = chandef->chan->band;
struct sta_rec_ra_info *ra_info;
struct tlv *tlv;
@@ -1655,7 +1655,7 @@ int mt7925_mcu_sta_update(struct mt792x_dev *dev, struct ieee80211_sta *sta,
enum mt76_sta_info_state state)
{
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
- int rssi = -ewma_rssi_read(&mvif->rssi);
+ int rssi = -ewma_rssi_read(&mvif->bss_conf.rssi);
struct mt76_sta_cmd_info info = {
.sta = sta,
.vif = vif,
@@ -1746,7 +1746,7 @@ int mt7925_mcu_set_sniffer(struct mt792x_dev *dev, struct ieee80211_vif *vif,
} __packed enable;
} __packed req = {
.hdr = {
- .band_idx = mvif->mt76.band_idx,
+ .band_idx = mvif->bss_conf.mt76.band_idx,
},
.enable = {
.tag = cpu_to_le16(UNI_SNIFFER_ENABLE),
@@ -1805,7 +1805,7 @@ int mt7925_mcu_config_sniffer(struct mt792x_vif *vif,
} __packed tlv;
} __packed req = {
.hdr = {
- .band_idx = vif->mt76.band_idx,
+ .band_idx = vif->bss_conf.mt76.band_idx,
},
.tlv = {
.tag = cpu_to_le16(UNI_SNIFFER_CONFIG),
@@ -1866,7 +1866,7 @@ mt7925_mcu_uni_add_beacon_offload(struct mt792x_dev *dev,
} __packed beacon_tlv;
} req = {
.hdr = {
- .bss_idx = mvif->mt76.idx,
+ .bss_idx = mvif->bss_conf.mt76.idx,
},
.beacon_tlv = {
.tag = cpu_to_le16(UNI_BSS_INFO_BCN_CONTENT),
@@ -2080,8 +2080,8 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb,
tlv = mt76_connac_mcu_add_tlv(skb, UNI_BSS_INFO_BASIC, sizeof(*basic_req));
basic_req = (struct mt76_connac_bss_basic_tlv *)tlv;

- idx = mvif->mt76.omac_idx > EXT_BSSID_START ? HW_BSSID_0 :
- mvif->mt76.omac_idx;
+ idx = mvif->bss_conf.mt76.omac_idx > EXT_BSSID_START ? HW_BSSID_0 :
+ mvif->bss_conf.mt76.omac_idx;
basic_req->hw_bss_idx = idx;

basic_req->phymode_ext = mt7925_get_phy_mode_ext(phy, vif, band, sta);
@@ -2097,9 +2097,9 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb,
basic_req->dtim_period = vif->bss_conf.dtim_period;
basic_req->bmc_tx_wlan_idx = cpu_to_le16(wlan_idx);
basic_req->sta_idx = cpu_to_le16(msta->wcid.idx);
- basic_req->omac_idx = mvif->mt76.omac_idx;
- basic_req->band_idx = mvif->mt76.band_idx;
- basic_req->wmm_idx = mvif->mt76.wmm_idx;
+ basic_req->omac_idx = mvif->bss_conf.mt76.omac_idx;
+ basic_req->band_idx = mvif->bss_conf.mt76.band_idx;
+ basic_req->wmm_idx = mvif->bss_conf.mt76.wmm_idx;
basic_req->conn_state = !enable;

switch (vif->type) {
@@ -2217,8 +2217,8 @@ mt7925_mcu_bss_mld_tlv(struct sk_buff *skb,
mld = (struct bss_mld_tlv *)tlv;

mld->link_id = sta ? (is_mld ? vif->bss_conf.link_id : 0) : 0xff;
- mld->group_mld_id = is_mld ? mvif->mt76.idx : 0xff;
- mld->own_mld_id = mvif->mt76.idx + 32;
+ mld->group_mld_id = is_mld ? mvif->bss_conf.mt76.idx : 0xff;
+ mld->own_mld_id = mvif->bss_conf.mt76.idx + 32;
mld->remap_idx = 0xff;

if (sta)
@@ -2301,7 +2301,7 @@ int mt7925_mcu_set_timing(struct mt792x_phy *phy,
struct mt792x_dev *dev = phy->dev;
struct sk_buff *skb;

- skb = __mt7925_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76,
+ skb = __mt7925_mcu_alloc_bss_req(&dev->mt76, &mvif->bss_conf.mt76,
MT7925_BSS_UPDATE_MAX_SIZE);
if (IS_ERR(skb))
return PTR_ERR(skb);
@@ -2323,7 +2323,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
struct sk_buff *skb;
int err;

- skb = __mt7925_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76,
+ skb = __mt7925_mcu_alloc_bss_req(&dev->mt76, &mvif->bss_conf.mt76,
MT7925_BSS_UPDATE_MAX_SIZE);
if (IS_ERR(skb))
return PTR_ERR(skb);
@@ -2348,7 +2348,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
if (err < 0)
return err;

- return mt7925_mcu_set_chctx(phy->mt76, &mvif->mt76, ctx);
+ return mt7925_mcu_set_chctx(phy->mt76, &mvif->bss_conf.mt76, ctx);
}

int mt7925_mcu_set_dbdc(struct mt76_phy *phy)
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h
index 4c14e2c5da5b..e377f8ea9782 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x.h
+++ b/drivers/net/wireless/mediatek/mt76/mt792x.h
@@ -96,17 +96,19 @@ struct mt792x_sta {

DECLARE_EWMA(rssi, 10, 8);

-struct mt792x_vif {
+struct mt792x_bss_conf {
struct mt76_vif mt76; /* must be first */
+ struct ewma_rssi rssi;
+ struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS];
+};
+
+struct mt792x_vif {
+ struct mt792x_bss_conf bss_conf; /* must be first */

struct mt792x_sta sta;
struct mt792x_sta *wep_sta;

struct mt792x_phy *phy;
-
- struct ewma_rssi rssi;
-
- struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS];
};

struct mt792x_phy {
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
index a405af8d9052..4b4afc1add6e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c
+++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
@@ -128,8 +128,8 @@ void mt792x_remove_interface(struct ieee80211_hw *hw,

rcu_assign_pointer(dev->mt76.wcid[idx], NULL);

- dev->mt76.vif_mask &= ~BIT_ULL(mvif->mt76.idx);
- phy->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx);
+ dev->mt76.vif_mask &= ~BIT_ULL(mvif->bss_conf.mt76.idx);
+ phy->omac_mask &= ~BIT_ULL(mvif->bss_conf.mt76.omac_idx);
mt792x_mutex_release(dev);

spin_lock_bh(&dev->mt76.sta_poll_lock);
@@ -149,7 +149,7 @@ int mt792x_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,

/* no need to update right away, we'll get BSS_CHANGED_QOS */
queue = mt76_connac_lmac_mapping(queue);
- mvif->queue_params[queue] = *params;
+ mvif->bss_conf.queue_params[queue] = *params;

return 0;
}
@@ -178,7 +178,7 @@ u64 mt792x_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
{
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct mt792x_dev *dev = mt792x_hw_dev(hw);
- u8 omac_idx = mvif->mt76.omac_idx;
+ u8 omac_idx = mvif->bss_conf.mt76.omac_idx;
union {
u64 t64;
u32 t32[2];
@@ -204,7 +204,7 @@ void mt792x_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
{
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct mt792x_dev *dev = mt792x_hw_dev(hw);
- u8 omac_idx = mvif->mt76.omac_idx;
+ u8 omac_idx = mvif->bss_conf.mt76.omac_idx;
union {
u64 t64;
u32 t32[2];
@@ -265,7 +265,7 @@ int mt792x_assign_vif_chanctx(struct ieee80211_hw *hw,
struct mt792x_dev *dev = mt792x_hw_dev(hw);

mutex_lock(&dev->mt76.mutex);
- mvif->mt76.ctx = ctx;
+ mvif->bss_conf.mt76.ctx = ctx;
mutex_unlock(&dev->mt76.mutex);

return 0;
@@ -281,7 +281,7 @@ void mt792x_unassign_vif_chanctx(struct ieee80211_hw *hw,
struct mt792x_dev *dev = mt792x_hw_dev(hw);

mutex_lock(&dev->mt76.mutex);
- mvif->mt76.ctx = NULL;
+ mvif->bss_conf.mt76.ctx = NULL;
mutex_unlock(&dev->mt76.mutex);
}
EXPORT_SYMBOL_GPL(mt792x_unassign_vif_chanctx);
@@ -405,7 +405,7 @@ mt792x_ethtool_worker(void *wi_data, struct ieee80211_sta *sta)
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
struct mt76_ethtool_worker_info *wi = wi_data;

- if (msta->vif->mt76.idx != wi->idx)
+ if (msta->vif->bss_conf.mt76.idx != wi->idx)
return;

mt76_ethtool_worker(wi, &msta->wcid.stats, true);
@@ -421,7 +421,7 @@ void mt792x_get_et_stats(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct mt76_mib_stats *mib = &phy->mib;
struct mt76_ethtool_worker_info wi = {
.data = data,
- .idx = mvif->mt76.idx,
+ .idx = mvif->bss_conf.mt76.idx,
};
int i, ei = 0;

diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_mac.c b/drivers/net/wireless/mediatek/mt76/mt792x_mac.c
index eb29434abee1..45dd94ff386d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x_mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt792x_mac.c
@@ -173,7 +173,7 @@ mt792x_mac_rssi_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
if (!ether_addr_equal(vif->addr, hdr->addr1))
return;

- ewma_rssi_add(&mvif->rssi, -status->signal);
+ ewma_rssi_add(&mvif->bss_conf.rssi, -status->signal);
}

void mt792x_mac_assoc_rssi(struct mt792x_dev *dev, struct sk_buff *skb)
--
2.34.1


2024-06-13 03:03:05

by Sean Wang

[permalink] [raw]
Subject: [PATCH 03/47] wifi: mt76: mt792x: add struct mt792x_chanctx

From: Deren Wu <[email protected]>

We are introducing a new structure, mt792x_chanctx, to quickly identify
the linked BSS it is working on. This eliminates the need to search in
mt7921_ctx_iter() or mt7925_ctx_iter() when the channel context changes.

Co-developed-by: Sean Wang <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7921/main.c | 31 ++++++++-----------
.../net/wireless/mediatek/mt76/mt7925/main.c | 31 ++++++++-----------
drivers/net/wireless/mediatek/mt76/mt792x.h | 4 +++
.../net/wireless/mediatek/mt76/mt792x_core.c | 5 +++
4 files changed, 35 insertions(+), 36 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index 3141807ec54b..89d47cce9e8b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -1346,32 +1346,27 @@ mt7921_remove_chanctx(struct ieee80211_hw *hw,
{
}

-static void mt7921_ctx_iter(void *priv, u8 *mac,
- struct ieee80211_vif *vif)
-{
- struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
- struct ieee80211_chanctx_conf *ctx = priv;
-
- if (ctx != mvif->bss_conf.mt76.ctx)
- return;
-
- if (vif->type == NL80211_IFTYPE_MONITOR)
- mt7921_mcu_config_sniffer(mvif, ctx);
- else
- mt76_connac_mcu_uni_set_chctx(mvif->phy->mt76, &mvif->bss_conf.mt76, ctx);
-}
-
static void
mt7921_change_chanctx(struct ieee80211_hw *hw,
struct ieee80211_chanctx_conf *ctx,
u32 changed)
{
+ struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv;
struct mt792x_phy *phy = mt792x_hw_phy(hw);
+ struct ieee80211_vif *vif;
+ struct mt792x_vif *mvif;
+
+ if (!mctx->bss_conf)
+ return;
+
+ mvif = container_of(mctx->bss_conf, struct mt792x_vif, bss_conf);
+ vif = container_of((void *)mvif, struct ieee80211_vif, drv_priv);

mt792x_mutex_acquire(phy->dev);
- ieee80211_iterate_active_interfaces(phy->mt76->hw,
- IEEE80211_IFACE_ITER_ACTIVE,
- mt7921_ctx_iter, ctx);
+ if (vif->type == NL80211_IFTYPE_MONITOR)
+ mt7921_mcu_config_sniffer(mvif, ctx);
+ else
+ mt76_connac_mcu_uni_set_chctx(mvif->phy->mt76, &mvif->bss_conf.mt76, ctx);
mt792x_mutex_release(phy->dev);
}

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 504c2ecc3845..91edbe076c22 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -1354,34 +1354,29 @@ mt7925_remove_chanctx(struct ieee80211_hw *hw,
{
}

-static void mt7925_ctx_iter(void *priv, u8 *mac,
- struct ieee80211_vif *vif)
+static void
+mt7925_change_chanctx(struct ieee80211_hw *hw,
+ struct ieee80211_chanctx_conf *ctx,
+ u32 changed)
{
- struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
- struct ieee80211_chanctx_conf *ctx = priv;
+ struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv;
+ struct mt792x_phy *phy = mt792x_hw_phy(hw);
+ struct ieee80211_vif *vif;
+ struct mt792x_vif *mvif;

- if (ctx != mvif->bss_conf.mt76.ctx)
+ if (!mctx->bss_conf)
return;

+ mvif = container_of(mctx->bss_conf, struct mt792x_vif, bss_conf);
+ vif = container_of((void *)mvif, struct ieee80211_vif, drv_priv);
+
+ mt792x_mutex_acquire(phy->dev);
if (vif->type == NL80211_IFTYPE_MONITOR) {
mt7925_mcu_set_sniffer(mvif->phy->dev, vif, true);
mt7925_mcu_config_sniffer(mvif, ctx);
} else {
mt7925_mcu_set_chctx(mvif->phy->mt76, &mvif->bss_conf.mt76, ctx);
}
-}
-
-static void
-mt7925_change_chanctx(struct ieee80211_hw *hw,
- struct ieee80211_chanctx_conf *ctx,
- u32 changed)
-{
- struct mt792x_phy *phy = mt792x_hw_phy(hw);
-
- mt792x_mutex_acquire(phy->dev);
- ieee80211_iterate_active_interfaces(phy->mt76->hw,
- IEEE80211_IFACE_ITER_ACTIVE,
- mt7925_ctx_iter, ctx);
mt792x_mutex_release(phy->dev);
}

diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h
index cb0bb06bef80..b5eb574e8548 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x.h
+++ b/drivers/net/wireless/mediatek/mt76/mt792x.h
@@ -100,6 +100,10 @@ struct mt792x_sta {

DECLARE_EWMA(rssi, 10, 8);

+struct mt792x_chanctx {
+ struct mt792x_bss_conf *bss_conf;
+};
+
struct mt792x_bss_conf {
struct mt76_vif mt76; /* must be first */
struct ewma_rssi rssi;
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
index ae21a2829c9c..a189ae38f2d0 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c
+++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
@@ -261,11 +261,13 @@ int mt792x_assign_vif_chanctx(struct ieee80211_hw *hw,
struct ieee80211_bss_conf *link_conf,
struct ieee80211_chanctx_conf *ctx)
{
+ struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv;
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct mt792x_dev *dev = mt792x_hw_dev(hw);

mutex_lock(&dev->mt76.mutex);
mvif->bss_conf.mt76.ctx = ctx;
+ mctx->bss_conf = &mvif->bss_conf;
mutex_unlock(&dev->mt76.mutex);

return 0;
@@ -277,10 +279,12 @@ void mt792x_unassign_vif_chanctx(struct ieee80211_hw *hw,
struct ieee80211_bss_conf *link_conf,
struct ieee80211_chanctx_conf *ctx)
{
+ struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv;
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct mt792x_dev *dev = mt792x_hw_dev(hw);

mutex_lock(&dev->mt76.mutex);
+ mctx->bss_conf = NULL;
mvif->bss_conf.mt76.ctx = NULL;
mutex_unlock(&dev->mt76.mutex);
}
@@ -556,6 +560,7 @@ int mt792x_init_wiphy(struct ieee80211_hw *hw)

hw->sta_data_size = sizeof(struct mt792x_sta);
hw->vif_data_size = sizeof(struct mt792x_vif);
+ hw->chanctx_data_size = sizeof(struct mt792x_chanctx);

if (dev->fw_features & MT792x_FW_CAP_CNM) {
wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
--
2.34.1


2024-06-13 03:03:09

by Sean Wang

[permalink] [raw]
Subject: [PATCH 04/47] wifi: mt76: mt7925: support for split bss_info_changed method

From: Deren Wu <[email protected]>

The .bss_info_changed method is being split into .vif_cfg_changed and
.link_info_changed to support MLD devices, but it will still support
non-MLD devices.

Co-developed-by: Sean Wang <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7925/main.c | 132 ++++++++++--------
.../net/wireless/mediatek/mt76/mt7925/mcu.c | 7 +-
.../net/wireless/mediatek/mt76/mt7925/mcu.h | 3 +-
3 files changed, 76 insertions(+), 66 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 91edbe076c22..397776ddf01a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -695,65 +695,6 @@ mt7925_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
return mvif->basic_rates_idx;
}

-static void mt7925_bss_info_changed(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_bss_conf *info,
- u64 changed)
-{
- struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
- struct mt792x_phy *phy = mt792x_hw_phy(hw);
- struct mt792x_dev *dev = mt792x_hw_dev(hw);
-
- mt792x_mutex_acquire(dev);
-
- if (changed & BSS_CHANGED_ERP_SLOT) {
- int slottime = info->use_short_slot ? 9 : 20;
-
- if (slottime != phy->slottime) {
- phy->slottime = slottime;
- mt7925_mcu_set_timing(phy, vif);
- }
- }
-
- if (changed & BSS_CHANGED_MCAST_RATE)
- mvif->mcast_rates_idx =
- mt7925_get_rates_table(hw, vif, false, true);
-
- if (changed & BSS_CHANGED_BASIC_RATES)
- mvif->basic_rates_idx =
- mt7925_get_rates_table(hw, vif, false, false);
-
- if (changed & (BSS_CHANGED_BEACON |
- BSS_CHANGED_BEACON_ENABLED)) {
- mvif->beacon_rates_idx =
- mt7925_get_rates_table(hw, vif, true, false);
-
- mt7925_mcu_uni_add_beacon_offload(dev, hw, vif,
- info->enable_beacon);
- }
-
- /* ensure that enable txcmd_mode after bss_info */
- if (changed & (BSS_CHANGED_QOS | BSS_CHANGED_BEACON_ENABLED))
- mt7925_mcu_set_tx(dev, vif);
-
- if (changed & BSS_CHANGED_PS)
- mt7925_mcu_uni_bss_ps(dev, vif);
-
- if (changed & BSS_CHANGED_ASSOC) {
- mt7925_mcu_sta_update(dev, NULL, vif, true,
- MT76_STA_INFO_STATE_ASSOC);
- mt7925_mcu_set_beacon_filter(dev, vif, vif->cfg.assoc);
- }
-
- if (changed & BSS_CHANGED_ARP_FILTER) {
- struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
-
- mt7925_mcu_update_arp_filter(&dev->mt76, &mvif->bss_conf.mt76, info);
- }
-
- mt792x_mutex_release(dev);
-}
-
int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta)
{
@@ -1404,6 +1345,76 @@ static void mt7925_mgd_complete_tx(struct ieee80211_hw *hw,
mt7925_abort_roc(mvif->phy, mvif);
}

+static void mt7925_vif_cfg_changed(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ u64 changed)
+{
+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
+
+ mt792x_mutex_acquire(dev);
+
+ if (changed & BSS_CHANGED_ASSOC) {
+ mt7925_mcu_sta_update(dev, NULL, vif, true,
+ MT76_STA_INFO_STATE_ASSOC);
+ mt7925_mcu_set_beacon_filter(dev, vif, vif->cfg.assoc);
+ }
+
+ if (changed & BSS_CHANGED_ARP_FILTER) {
+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+
+ mt7925_mcu_update_arp_filter(&dev->mt76, &mvif->bss_conf.mt76);
+ }
+
+ if (changed & BSS_CHANGED_PS)
+ mt7925_mcu_uni_bss_ps(dev, vif);
+
+ mt792x_mutex_release(dev);
+}
+
+static void mt7925_link_info_changed(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct ieee80211_bss_conf *info,
+ u64 changed)
+{
+ struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
+ struct mt792x_phy *phy = mt792x_hw_phy(hw);
+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
+
+ mt792x_mutex_acquire(dev);
+
+ if (changed & BSS_CHANGED_ERP_SLOT) {
+ int slottime = info->use_short_slot ? 9 : 20;
+
+ if (slottime != phy->slottime) {
+ phy->slottime = slottime;
+ mt7925_mcu_set_timing(phy, vif);
+ }
+ }
+
+ if (changed & BSS_CHANGED_MCAST_RATE)
+ mvif->mcast_rates_idx =
+ mt7925_get_rates_table(hw, vif, false, true);
+
+ if (changed & BSS_CHANGED_BASIC_RATES)
+ mvif->basic_rates_idx =
+ mt7925_get_rates_table(hw, vif, false, false);
+
+ if (changed & (BSS_CHANGED_BEACON |
+ BSS_CHANGED_BEACON_ENABLED)) {
+ mvif->beacon_rates_idx =
+ mt7925_get_rates_table(hw, vif, true, false);
+
+ mt7925_mcu_uni_add_beacon_offload(dev, hw, vif,
+ info->enable_beacon);
+ }
+
+ /* ensure that enable txcmd_mode after bss_info */
+ if (changed & (BSS_CHANGED_QOS | BSS_CHANGED_BEACON_ENABLED))
+ mt7925_mcu_set_tx(dev, vif);
+
+ mt792x_mutex_release(dev);
+}
+
const struct ieee80211_ops mt7925_ops = {
.tx = mt792x_tx,
.start = mt7925_start,
@@ -1413,7 +1424,6 @@ const struct ieee80211_ops mt7925_ops = {
.config = mt7925_config,
.conf_tx = mt7925_conf_tx,
.configure_filter = mt7925_configure_filter,
- .bss_info_changed = mt7925_bss_info_changed,
.start_ap = mt7925_start_ap,
.stop_ap = mt7925_stop_ap,
.sta_state = mt76_sta_state,
@@ -1461,6 +1471,8 @@ const struct ieee80211_ops mt7925_ops = {
.unassign_vif_chanctx = mt792x_unassign_vif_chanctx,
.mgd_prepare_tx = mt7925_mgd_prepare_tx,
.mgd_complete_tx = mt7925_mgd_complete_tx,
+ .vif_cfg_changed = mt7925_vif_cfg_changed,
+ .link_info_changed = mt7925_link_info_changed,
};
EXPORT_SYMBOL_GPL(mt7925_ops);

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 67c05f785190..5e72f7278e8b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -121,11 +121,10 @@ int mt7925_mcu_regval(struct mt792x_dev *dev, u32 regidx, u32 *val, bool set)
EXPORT_SYMBOL_GPL(mt7925_mcu_regval);

int mt7925_mcu_update_arp_filter(struct mt76_dev *dev,
- struct mt76_vif *vif,
- struct ieee80211_bss_conf *info)
+ struct mt76_vif *vif)
{
- struct ieee80211_vif *mvif = container_of(info, struct ieee80211_vif,
- bss_conf);
+ struct ieee80211_vif *mvif = container_of((void *)vif, struct ieee80211_vif,
+ drv_priv);
struct sk_buff *skb;
int i, len = min_t(int, mvif->cfg.arp_addr_cnt,
IEEE80211_BSS_ARP_ADDR_LIST_LEN);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h
index b8315a89f4a9..b499b1d0531a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h
@@ -590,6 +590,5 @@ int mt7925_mcu_set_chctx(struct mt76_phy *phy, struct mt76_vif *mvif,
struct ieee80211_chanctx_conf *ctx);
int mt7925_mcu_set_rate_txpower(struct mt76_phy *phy);
int mt7925_mcu_update_arp_filter(struct mt76_dev *dev,
- struct mt76_vif *vif,
- struct ieee80211_bss_conf *info);
+ struct mt76_vif *vif);
#endif
--
2.34.1


2024-06-13 03:03:13

by Sean Wang

[permalink] [raw]
Subject: [PATCH 05/47] wifi: mt76: mt792x: extend mt76_connac_mcu_uni_add_dev for per-link BSS

From: Sean Wang <[email protected]>

Extend mt76_connac_mcu_uni_add_dev with per-link BSS configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

We also extend link_idx field in mt76_connac_bss_basic_tlv for the firmware
to able to identify the link index in the MLO mode that is not harmful
for the current non-MLO mode.

Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 4 ++--
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 12 +++++++-----
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h | 4 ++--
drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 3 ++-
drivers/net/wireless/mediatek/mt76/mt7921/main.c | 4 ++--
drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 3 ++-
drivers/net/wireless/mediatek/mt76/mt7925/main.c | 4 ++--
drivers/net/wireless/mediatek/mt76/mt792x_core.c | 2 +-
8 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
index c807bd8d928d..792ae41f7c69 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
@@ -1109,8 +1109,8 @@ mt7615_mcu_uni_add_dev(struct mt7615_phy *phy, struct ieee80211_vif *vif,
{
struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;

- return mt76_connac_mcu_uni_add_dev(phy->mt76, vif, &mvif->sta.wcid,
- enable);
+ return mt76_connac_mcu_uni_add_dev(phy->mt76, &vif->bss_conf,
+ &mvif->sta.wcid, enable);
}

static int
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
index fb8bd50eb7de..87f918461051 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
@@ -1125,11 +1125,11 @@ void mt76_connac_mcu_wtbl_ba_tlv(struct mt76_dev *dev, struct sk_buff *skb,
EXPORT_SYMBOL_GPL(mt76_connac_mcu_wtbl_ba_tlv);

int mt76_connac_mcu_uni_add_dev(struct mt76_phy *phy,
- struct ieee80211_vif *vif,
+ struct ieee80211_bss_conf *bss_conf,
struct mt76_wcid *wcid,
bool enable)
{
- struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
+ struct mt76_vif *mvif = (struct mt76_vif *)bss_conf->vif->drv_priv;
struct mt76_dev *dev = phy->dev;
struct {
struct {
@@ -1141,7 +1141,7 @@ int mt76_connac_mcu_uni_add_dev(struct mt76_phy *phy,
__le16 tag;
__le16 len;
u8 active;
- u8 pad;
+ u8 link_idx; /* not link_id */
u8 omac_addr[ETH_ALEN];
} __packed tlv;
} dev_req = {
@@ -1153,6 +1153,7 @@ int mt76_connac_mcu_uni_add_dev(struct mt76_phy *phy,
.tag = cpu_to_le16(DEV_INFO_ACTIVE),
.len = cpu_to_le16(sizeof(struct req_tlv)),
.active = enable,
+ .link_idx = mvif->idx,
},
};
struct {
@@ -1175,12 +1176,13 @@ int mt76_connac_mcu_uni_add_dev(struct mt76_phy *phy,
.bmc_tx_wlan_idx = cpu_to_le16(wcid->idx),
.sta_idx = cpu_to_le16(wcid->idx),
.conn_state = 1,
+ .link_idx = mvif->idx,
},
};
int err, idx, cmd, len;
void *data;

- switch (vif->type) {
+ switch (bss_conf->vif->type) {
case NL80211_IFTYPE_MESH_POINT:
case NL80211_IFTYPE_MONITOR:
case NL80211_IFTYPE_AP:
@@ -1200,7 +1202,7 @@ int mt76_connac_mcu_uni_add_dev(struct mt76_phy *phy,
idx = mvif->omac_idx > EXT_BSSID_START ? HW_BSSID_0 : mvif->omac_idx;
basic_req.basic.hw_bss_idx = idx;

- memcpy(dev_req.tlv.omac_addr, vif->addr, ETH_ALEN);
+ memcpy(dev_req.tlv.omac_addr, bss_conf->vif->addr, ETH_ALEN);

cmd = enable ? MCU_UNI_CMD(DEV_INFO_UPDATE) : MCU_UNI_CMD(BSS_INFO_UPDATE);
data = enable ? (void *)&dev_req : (void *)&basic_req;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
index 4d83ec2a0f9a..e6e8824c828e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
@@ -1436,7 +1436,7 @@ struct mt76_connac_bss_basic_tlv {
__le16 sta_idx;
__le16 nonht_basic_phy;
u8 phymode_ext; /* bit(0) AX_6G */
- u8 pad[1];
+ u8 link_idx;
} __packed;

struct mt76_connac_bss_qos_tlv {
@@ -1910,7 +1910,7 @@ void mt76_connac_mcu_sta_ba_tlv(struct sk_buff *skb,
struct ieee80211_ampdu_params *params,
bool enable, bool tx);
int mt76_connac_mcu_uni_add_dev(struct mt76_phy *phy,
- struct ieee80211_vif *vif,
+ struct ieee80211_bss_conf *bss_conf,
struct mt76_wcid *wcid,
bool enable);
int mt76_connac_mcu_sta_ba(struct mt76_dev *dev, struct mt76_vif *mvif,
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
index 5ea01c39e2e1..101cac747f9f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
@@ -646,7 +646,8 @@ mt7921_vif_connect_iter(void *priv, u8 *mac,
if (vif->type == NL80211_IFTYPE_STATION)
ieee80211_disconnect(vif, true);

- mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.deflink.wcid, true);
+ mt76_connac_mcu_uni_add_dev(&dev->mphy, &vif->bss_conf,
+ &mvif->sta.deflink.wcid, true);
mt7921_mcu_set_tx(dev, vif);

if (vif->type == NL80211_IFTYPE_AP) {
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index 89d47cce9e8b..c7e71043c257 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -306,8 +306,8 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
mvif->bss_conf.mt76.band_idx = 0;
mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx % MT76_CONNAC_MAX_WMM_SETS;

- ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.deflink.wcid,
- true);
+ ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, &vif->bss_conf,
+ &mvif->sta.deflink.wcid, true);
if (ret)
goto out;

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
index 88e7b2ff4593..48425fc4e7fe 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
@@ -1243,7 +1243,8 @@ mt7925_vif_connect_iter(void *priv, u8 *mac,
if (vif->type == NL80211_IFTYPE_STATION)
ieee80211_disconnect(vif, true);

- mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.deflink.wcid, true);
+ mt76_connac_mcu_uni_add_dev(&dev->mphy, &vif->bss_conf,
+ &mvif->sta.deflink.wcid, true);
mt7925_mcu_set_tx(dev, vif);

if (vif->type == NL80211_IFTYPE_AP) {
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 397776ddf01a..b0c8b090d2ce 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -344,8 +344,8 @@ mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
else
mvif->bss_conf.mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL;

- ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.deflink.wcid,
- true);
+ ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, &vif->bss_conf,
+ &mvif->sta.deflink.wcid, true);
if (ret)
goto out;

diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
index a189ae38f2d0..222204916b73 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c
+++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
@@ -124,7 +124,7 @@ void mt792x_remove_interface(struct ieee80211_hw *hw,

mt792x_mutex_acquire(dev);
mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->deflink.wcid);
- mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.deflink.wcid, false);
+ mt76_connac_mcu_uni_add_dev(&dev->mphy, &vif->bss_conf, &mvif->sta.deflink.wcid, false);

rcu_assign_pointer(dev->mt76.wcid[idx], NULL);

--
2.34.1


2024-06-13 03:03:17

by Sean Wang

[permalink] [raw]
Subject: [PATCH 06/47] wifi: mt76: mt7925: extend mt7925_mcu_set_tx with for per-link BSS

From: Deren Wu <[email protected]>

Extend mt7925_mcu_set_tx with per-link BSS configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Sean Wang <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7925/mac.c | 2 +-
.../net/wireless/mediatek/mt76/mt7925/main.c | 2 +-
.../net/wireless/mediatek/mt76/mt7925/mcu.c | 9 ++++---
.../wireless/mediatek/mt76/mt7925/mt7925.h | 2 +-
drivers/net/wireless/mediatek/mt76/mt792x.h | 25 +++++++++++++++++++
5 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
index 48425fc4e7fe..2be2ab914411 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
@@ -1245,7 +1245,7 @@ mt7925_vif_connect_iter(void *priv, u8 *mac,

mt76_connac_mcu_uni_add_dev(&dev->mphy, &vif->bss_conf,
&mvif->sta.deflink.wcid, true);
- mt7925_mcu_set_tx(dev, vif);
+ mt7925_mcu_set_tx(dev, &vif->bss_conf);

if (vif->type == NL80211_IFTYPE_AP) {
mt76_connac_mcu_uni_add_bss(dev->phy.mt76, vif, &mvif->sta.deflink.wcid,
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index b0c8b090d2ce..d11919688bae 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -1410,7 +1410,7 @@ static void mt7925_link_info_changed(struct ieee80211_hw *hw,

/* ensure that enable txcmd_mode after bss_info */
if (changed & (BSS_CHANGED_QOS | BSS_CHANGED_BEACON_ENABLED))
- mt7925_mcu_set_tx(dev, vif);
+ mt7925_mcu_set_tx(dev, info);

mt792x_mutex_release(dev);
}
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 5e72f7278e8b..1c262a024dc8 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -900,7 +900,8 @@ int mt7925_mcu_wtbl_update_hdr_trans(struct mt792x_dev *dev,
MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true);
}

-int mt7925_mcu_set_tx(struct mt792x_dev *dev, struct ieee80211_vif *vif)
+int mt7925_mcu_set_tx(struct mt792x_dev *dev,
+ struct ieee80211_bss_conf *bss_conf)
{
#define MCU_EDCA_AC_PARAM 0
#define WMM_AIFS_SET BIT(0)
@@ -909,12 +910,12 @@ int mt7925_mcu_set_tx(struct mt792x_dev *dev, struct ieee80211_vif *vif)
#define WMM_TXOP_SET BIT(3)
#define WMM_PARAM_SET (WMM_AIFS_SET | WMM_CW_MIN_SET | \
WMM_CW_MAX_SET | WMM_TXOP_SET)
- struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+ struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(bss_conf);
struct {
u8 bss_idx;
u8 __rsv[3];
} __packed hdr = {
- .bss_idx = mvif->bss_conf.mt76.idx,
+ .bss_idx = mconf->mt76.idx,
};
struct sk_buff *skb;
int len = sizeof(hdr) + IEEE80211_NUM_ACS * sizeof(struct edca);
@@ -927,7 +928,7 @@ int mt7925_mcu_set_tx(struct mt792x_dev *dev, struct ieee80211_vif *vif)
skb_put_data(skb, &hdr, sizeof(hdr));

for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
- struct ieee80211_tx_queue_params *q = &mvif->bss_conf.queue_params[ac];
+ struct ieee80211_tx_queue_params *q = &mconf->queue_params[ac];
struct edca *e;
struct tlv *tlv;

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
index 8a4a71f6bcb6..f689f7a359ea 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
@@ -198,7 +198,7 @@ int mt7925_mcu_sta_update(struct mt792x_dev *dev, struct ieee80211_sta *sta,
struct ieee80211_vif *vif, bool enable,
enum mt76_sta_info_state state);
int mt7925_mcu_set_chan_info(struct mt792x_phy *phy, u16 tag);
-int mt7925_mcu_set_tx(struct mt792x_dev *dev, struct ieee80211_vif *vif);
+int mt7925_mcu_set_tx(struct mt792x_dev *dev, struct ieee80211_bss_conf *bss_conf);
int mt7925_mcu_set_eeprom(struct mt792x_dev *dev);
int mt7925_mcu_get_rx_rate(struct mt792x_phy *phy, struct ieee80211_vif *vif,
struct ieee80211_sta *sta, struct rate_info *rate);
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h
index b5eb574e8548..4a7526322c30 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x.h
+++ b/drivers/net/wireless/mediatek/mt76/mt792x.h
@@ -112,6 +112,7 @@ struct mt792x_bss_conf {

struct mt792x_vif {
struct mt792x_bss_conf bss_conf; /* must be first */
+ struct mt792x_bss_conf __rcu *link_conf[IEEE80211_MLD_MAX_NUM_LINKS];

struct mt792x_sta sta;
struct mt792x_sta *wep_sta;
@@ -219,6 +220,30 @@ struct mt792x_dev {
u32 backup_l2;
};

+static inline struct mt792x_bss_conf *
+mt792x_vif_to_link(struct mt792x_vif *mvif, u8 link_id)
+{
+ struct ieee80211_vif *vif;
+
+ vif = container_of((void *)mvif, struct ieee80211_vif, drv_priv);
+
+ if (!ieee80211_vif_is_mld(vif) ||
+ link_id >= IEEE80211_LINK_UNSPECIFIED)
+ return &mvif->bss_conf;
+
+ return rcu_dereference_protected(mvif->link_conf[link_id],
+ lockdep_is_held(&mvif->phy->dev->mt76.mutex));
+}
+
+static inline struct mt792x_bss_conf *
+mt792x_link_conf_to_mconf(struct ieee80211_bss_conf *link_conf)
+{
+ struct ieee80211_vif *vif = link_conf->vif;
+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+
+ return mt792x_vif_to_link(mvif, link_conf->link_id);
+}
+
static inline struct mt792x_dev *
mt792x_hw_dev(struct ieee80211_hw *hw)
{
--
2.34.1


2024-06-13 03:03:26

by Sean Wang

[permalink] [raw]
Subject: [PATCH 08/47] wifi: mt76: mt7925: extend mt7925_mcu_set_timing for per-link BSS

From: Sean Wang <[email protected]>

Extend mt7925_mcu_set_timing with per-link BSS configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/main.c | 2 +-
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 6 +++---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 7b9deb586b34..6a1afff92399 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -1400,7 +1400,7 @@ static void mt7925_link_info_changed(struct ieee80211_hw *hw,

if (slottime != phy->slottime) {
phy->slottime = slottime;
- mt7925_mcu_set_timing(phy, vif);
+ mt7925_mcu_set_timing(phy, info);
}
}

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index fb261ee525be..b82cc1bd09b6 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -2296,9 +2296,9 @@ mt7925_mcu_bss_ifs_tlv(struct sk_buff *skb, struct ieee80211_vif *vif)
}

int mt7925_mcu_set_timing(struct mt792x_phy *phy,
- struct ieee80211_vif *vif)
+ struct ieee80211_bss_conf *link_conf)
{
- struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+ struct mt792x_vif *mvif = (struct mt792x_vif *)link_conf->vif->drv_priv;
struct mt792x_dev *dev = phy->dev;
struct sk_buff *skb;

@@ -2307,7 +2307,7 @@ int mt7925_mcu_set_timing(struct mt792x_phy *phy,
if (IS_ERR(skb))
return PTR_ERR(skb);

- mt7925_mcu_bss_ifs_tlv(skb, vif);
+ mt7925_mcu_bss_ifs_tlv(skb, link_conf->vif);

return mt76_mcu_skb_send_msg(&dev->mt76, skb,
MCU_UNI_CMD(BSS_INFO_UPDATE), true);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h
index c692996e057c..d3584743c266 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h
@@ -582,7 +582,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
struct ieee80211_sta *sta,
int enable);
int mt7925_mcu_set_timing(struct mt792x_phy *phy,
- struct ieee80211_vif *vif);
+ struct ieee80211_bss_conf *link_conf);
int mt7925_mcu_set_deep_sleep(struct mt792x_dev *dev, bool enable);
int mt7925_mcu_set_channel_domain(struct mt76_phy *phy);
int mt7925_mcu_set_radio_en(struct mt792x_phy *phy, bool enable);
--
2.34.1


2024-06-13 03:03:33

by Sean Wang

[permalink] [raw]
Subject: [PATCH 09/47] wifi: mt76: mt7925: extend mt7925_mcu_bss_ifs_tlv for per-link BSS

From: Sean Wang <[email protected]>

Extend mt7925_mcu_bss_ifs_tlv with per-link BSS configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index b82cc1bd09b6..7cde18e273d8 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -2282,9 +2282,10 @@ mt7925_mcu_bss_color_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
}

static void
-mt7925_mcu_bss_ifs_tlv(struct sk_buff *skb, struct ieee80211_vif *vif)
+mt7925_mcu_bss_ifs_tlv(struct sk_buff *skb,
+ struct ieee80211_bss_conf *link_conf)
{
- struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+ struct mt792x_vif *mvif = (struct mt792x_vif *)link_conf->vif->drv_priv;
struct mt792x_phy *phy = mvif->phy;
struct bss_ifs_time_tlv *ifs_time;
struct tlv *tlv;
@@ -2307,7 +2308,7 @@ int mt7925_mcu_set_timing(struct mt792x_phy *phy,
if (IS_ERR(skb))
return PTR_ERR(skb);

- mt7925_mcu_bss_ifs_tlv(skb, link_conf->vif);
+ mt7925_mcu_bss_ifs_tlv(skb, link_conf);

return mt76_mcu_skb_send_msg(&dev->mt76, skb,
MCU_UNI_CMD(BSS_INFO_UPDATE), true);
@@ -2337,7 +2338,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
mt7925_mcu_bss_bmc_tlv(skb, phy, ctx, link_conf->vif, sta);
mt7925_mcu_bss_qos_tlv(skb, link_conf->vif);
mt7925_mcu_bss_mld_tlv(skb, link_conf->vif, sta);
- mt7925_mcu_bss_ifs_tlv(skb, link_conf->vif);
+ mt7925_mcu_bss_ifs_tlv(skb, link_conf);

if (link_conf->he_support) {
mt7925_mcu_bss_he_tlv(skb, link_conf->vif, phy);
--
2.34.1


2024-06-13 03:03:33

by Sean Wang

[permalink] [raw]
Subject: [PATCH 10/47] wifi: mt76: mt7925: extend mt7925_mcu_bss_color_tlv for per-link BSS

From: Sean Wang <[email protected]>

Extend mt7925_mcu_bss_color_tlv with per-link BSS configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 7cde18e273d8..10e38637eb83 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -2266,7 +2266,7 @@ mt7925_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
}

static void
-mt7925_mcu_bss_color_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
+mt7925_mcu_bss_color_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *link_conf,
bool enable)
{
struct bss_info_uni_bss_color *color;
@@ -2276,9 +2276,9 @@ mt7925_mcu_bss_color_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
color = (struct bss_info_uni_bss_color *)tlv;

color->enable = enable ?
- vif->bss_conf.he_bss_color.enabled : 0;
+ link_conf->he_bss_color.enabled : 0;
color->bss_color = enable ?
- vif->bss_conf.he_bss_color.color : 0;
+ link_conf->he_bss_color.color : 0;
}

static void
@@ -2342,7 +2342,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,

if (link_conf->he_support) {
mt7925_mcu_bss_he_tlv(skb, link_conf->vif, phy);
- mt7925_mcu_bss_color_tlv(skb, link_conf->vif, enable);
+ mt7925_mcu_bss_color_tlv(skb, link_conf, enable);
}

err = mt76_mcu_skb_send_msg(&dev->mt76, skb,
--
2.34.1


2024-06-13 03:03:34

by Sean Wang

[permalink] [raw]
Subject: [PATCH 02/47] wifi: mt76: mt792x: add struct mt792x_link_sta

From: Deren Wu <[email protected]>

We are introducing a new structure, mt792x_link_sta, to manage per-link
configurations in preparation for future station (STA) support of
Multi-Link Operation (MLO).

This patch only includes structural changes and does not involve any
logic changes.

We have moved relevant parameters, such as the wcid from the mt76_wcid
structure, from the mt7921x_sta structure to the mt792x_link_sta structure.

For current drivers that do not support MLO, there is only one link STA,
and link information is accessed via the deflink member.

However, we have not yet created the per-link BSS configuration indexed
by link ID for Multi-Link Device (MLD) support in mt7921x_sta.
This step needs to be completed before adding MLD support for STA mode.

Co-developed-by: Sean Wang <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7921/mac.c | 65 ++++++++--------
.../net/wireless/mediatek/mt76/mt7921/main.c | 76 +++++++++----------
.../net/wireless/mediatek/mt76/mt7921/mcu.c | 4 +-
.../wireless/mediatek/mt76/mt7921/pci_mac.c | 4 +-
.../net/wireless/mediatek/mt76/mt7925/mac.c | 66 ++++++++--------
.../net/wireless/mediatek/mt76/mt7925/main.c | 66 ++++++++--------
.../net/wireless/mediatek/mt76/mt7925/mcu.c | 17 +++--
.../wireless/mediatek/mt76/mt7925/pci_mac.c | 4 +-
drivers/net/wireless/mediatek/mt76/mt792x.h | 10 ++-
.../net/wireless/mediatek/mt76/mt792x_core.c | 28 +++----
.../net/wireless/mediatek/mt76/mt792x_mac.c | 6 +-
11 files changed, 180 insertions(+), 166 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
index 867e14f6b93a..5ea01c39e2e1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
@@ -39,6 +39,7 @@ static void mt7921_mac_sta_poll(struct mt792x_dev *dev)
};
struct ieee80211_sta *sta;
struct mt792x_sta *msta;
+ struct mt792x_link_sta *mlink;
u32 tx_time[IEEE80211_NUM_ACS], rx_time[IEEE80211_NUM_ACS];
LIST_HEAD(sta_poll_list);
struct rate_info *rate;
@@ -60,23 +61,25 @@ static void mt7921_mac_sta_poll(struct mt792x_dev *dev)
spin_unlock_bh(&dev->mt76.sta_poll_lock);
break;
}
- msta = list_first_entry(&sta_poll_list,
- struct mt792x_sta, wcid.poll_list);
- list_del_init(&msta->wcid.poll_list);
+ mlink = list_first_entry(&sta_poll_list,
+ struct mt792x_link_sta,
+ wcid.poll_list);
+ msta = container_of(mlink, struct mt792x_sta, deflink);
+ list_del_init(&mlink->wcid.poll_list);
spin_unlock_bh(&dev->mt76.sta_poll_lock);

- idx = msta->wcid.idx;
+ idx = mlink->wcid.idx;
addr = mt7921_mac_wtbl_lmac_addr(idx, MT_WTBL_AC0_CTT_OFFSET);

for (i = 0; i < IEEE80211_NUM_ACS; i++) {
- u32 tx_last = msta->airtime_ac[i];
- u32 rx_last = msta->airtime_ac[i + 4];
+ u32 tx_last = mlink->airtime_ac[i];
+ u32 rx_last = mlink->airtime_ac[i + 4];

- msta->airtime_ac[i] = mt76_rr(dev, addr);
- msta->airtime_ac[i + 4] = mt76_rr(dev, addr + 4);
+ mlink->airtime_ac[i] = mt76_rr(dev, addr);
+ mlink->airtime_ac[i + 4] = mt76_rr(dev, addr + 4);

- tx_time[i] = msta->airtime_ac[i] - tx_last;
- rx_time[i] = msta->airtime_ac[i + 4] - rx_last;
+ tx_time[i] = mlink->airtime_ac[i] - tx_last;
+ rx_time[i] = mlink->airtime_ac[i + 4] - rx_last;

if ((tx_last | rx_last) & BIT(30))
clear = true;
@@ -87,10 +90,10 @@ static void mt7921_mac_sta_poll(struct mt792x_dev *dev)
if (clear) {
mt7921_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
- memset(msta->airtime_ac, 0, sizeof(msta->airtime_ac));
+ memset(mlink->airtime_ac, 0, sizeof(mlink->airtime_ac));
}

- if (!msta->wcid.sta)
+ if (!mlink->wcid.sta)
continue;

sta = container_of((void *)msta, struct ieee80211_sta,
@@ -113,7 +116,7 @@ static void mt7921_mac_sta_poll(struct mt792x_dev *dev)
* we need to make sure that flags match so polling GI
* from per-sta counters directly.
*/
- rate = &msta->wcid.rate;
+ rate = &mlink->wcid.rate;
addr = mt7921_mac_wtbl_lmac_addr(idx,
MT_WTBL_TXRX_CAP_RATE_OFFSET);
val = mt76_rr(dev, addr);
@@ -154,10 +157,10 @@ static void mt7921_mac_sta_poll(struct mt792x_dev *dev)
rssi[2] = to_rssi(GENMASK(23, 16), val);
rssi[3] = to_rssi(GENMASK(31, 14), val);

- msta->ack_signal =
+ mlink->ack_signal =
mt76_rx_signal(msta->vif->phy->mt76->antenna_mask, rssi);

- ewma_avg_signal_add(&msta->avg_ack_signal, -msta->ack_signal);
+ ewma_avg_signal_add(&mlink->avg_ack_signal, -mlink->ack_signal);
}
}

@@ -180,6 +183,7 @@ mt7921_mac_fill_rx(struct mt792x_dev *dev, struct sk_buff *skb)
u32 rxd3 = le32_to_cpu(rxd[3]);
u32 rxd4 = le32_to_cpu(rxd[4]);
struct mt792x_sta *msta = NULL;
+ struct mt792x_link_sta *mlink;
u16 seq_ctrl = 0;
__le16 fc = 0;
u8 mode = 0;
@@ -210,10 +214,11 @@ mt7921_mac_fill_rx(struct mt792x_dev *dev, struct sk_buff *skb)
status->wcid = mt792x_rx_get_wcid(dev, idx, unicast);

if (status->wcid) {
- msta = container_of(status->wcid, struct mt792x_sta, wcid);
+ mlink = container_of(status->wcid, struct mt792x_link_sta, wcid);
+ msta = container_of(mlink, struct mt792x_sta, deflink);
spin_lock_bh(&dev->mt76.sta_poll_lock);
- if (list_empty(&msta->wcid.poll_list))
- list_add_tail(&msta->wcid.poll_list,
+ if (list_empty(&mlink->wcid.poll_list))
+ list_add_tail(&mlink->wcid.poll_list,
&dev->mt76.sta_poll_list);
spin_unlock_bh(&dev->mt76.sta_poll_lock);
}
@@ -444,7 +449,7 @@ mt7921_mac_fill_rx(struct mt792x_dev *dev, struct sk_buff *skb)

void mt7921_mac_add_txs(struct mt792x_dev *dev, void *data)
{
- struct mt792x_sta *msta = NULL;
+ struct mt792x_link_sta *mlink;
struct mt76_wcid *wcid;
__le32 *txs_data = data;
u16 wcidx;
@@ -468,15 +473,15 @@ void mt7921_mac_add_txs(struct mt792x_dev *dev, void *data)
if (!wcid)
goto out;

- msta = container_of(wcid, struct mt792x_sta, wcid);
+ mlink = container_of(wcid, struct mt792x_link_sta, wcid);

mt76_connac2_mac_add_txs_skb(&dev->mt76, wcid, pid, txs_data);
if (!wcid->sta)
goto out;

spin_lock_bh(&dev->mt76.sta_poll_lock);
- if (list_empty(&msta->wcid.poll_list))
- list_add_tail(&msta->wcid.poll_list, &dev->mt76.sta_poll_list);
+ if (list_empty(&mlink->wcid.poll_list))
+ list_add_tail(&mlink->wcid.poll_list, &dev->mt76.sta_poll_list);
spin_unlock_bh(&dev->mt76.sta_poll_lock);

out:
@@ -513,7 +518,7 @@ static void mt7921_mac_tx_free(struct mt792x_dev *dev, void *data, int len)
* 1'b0: msdu_id with the same 'wcid pair' as above.
*/
if (info & MT_TX_FREE_PAIR) {
- struct mt792x_sta *msta;
+ struct mt792x_link_sta *mlink;
u16 idx;

count++;
@@ -523,10 +528,10 @@ static void mt7921_mac_tx_free(struct mt792x_dev *dev, void *data, int len)
if (!sta)
continue;

- msta = container_of(wcid, struct mt792x_sta, wcid);
+ mlink = container_of(wcid, struct mt792x_link_sta, wcid);
spin_lock_bh(&mdev->sta_poll_lock);
- if (list_empty(&msta->wcid.poll_list))
- list_add_tail(&msta->wcid.poll_list,
+ if (list_empty(&mlink->wcid.poll_list))
+ list_add_tail(&mlink->wcid.poll_list,
&mdev->sta_poll_list);
spin_unlock_bh(&mdev->sta_poll_lock);
continue;
@@ -641,11 +646,11 @@ mt7921_vif_connect_iter(void *priv, u8 *mac,
if (vif->type == NL80211_IFTYPE_STATION)
ieee80211_disconnect(vif, true);

- mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.wcid, true);
+ mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.deflink.wcid, true);
mt7921_mcu_set_tx(dev, vif);

if (vif->type == NL80211_IFTYPE_AP) {
- mt76_connac_mcu_uni_add_bss(dev->phy.mt76, vif, &mvif->sta.wcid,
+ mt76_connac_mcu_uni_add_bss(dev->phy.mt76, vif, &mvif->sta.deflink.wcid,
true, NULL);
mt7921_mcu_sta_update(dev, NULL, vif, true,
MT76_STA_INFO_STATE_NONE);
@@ -784,9 +789,9 @@ int mt7921_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
if (sta) {
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;

- if (time_after(jiffies, msta->last_txs + HZ / 4)) {
+ if (time_after(jiffies, msta->deflink.last_txs + HZ / 4)) {
info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
- msta->last_txs = jiffies;
+ msta->deflink.last_txs = jiffies;
}
}

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index 2752e1735575..3141807ec54b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -306,7 +306,7 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
mvif->bss_conf.mt76.band_idx = 0;
mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx % MT76_CONNAC_MAX_WMM_SETS;

- ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.wcid,
+ ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.deflink.wcid,
true);
if (ret)
goto out;
@@ -316,19 +316,19 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)

idx = MT792x_WTBL_RESERVED - mvif->bss_conf.mt76.idx;

- INIT_LIST_HEAD(&mvif->sta.wcid.poll_list);
- mvif->sta.wcid.idx = idx;
- mvif->sta.wcid.phy_idx = mvif->bss_conf.mt76.band_idx;
- mvif->sta.wcid.hw_key_idx = -1;
- mvif->sta.wcid.tx_info |= MT_WCID_TX_INFO_SET;
- mt76_wcid_init(&mvif->sta.wcid);
+ INIT_LIST_HEAD(&mvif->sta.deflink.wcid.poll_list);
+ mvif->sta.deflink.wcid.idx = idx;
+ mvif->sta.deflink.wcid.phy_idx = mvif->bss_conf.mt76.band_idx;
+ mvif->sta.deflink.wcid.hw_key_idx = -1;
+ mvif->sta.deflink.wcid.tx_info |= MT_WCID_TX_INFO_SET;
+ mt76_wcid_init(&mvif->sta.deflink.wcid);

mt7921_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

ewma_rssi_init(&mvif->bss_conf.rssi);

- rcu_assign_pointer(dev->mt76.wcid[idx], &mvif->sta.wcid);
+ rcu_assign_pointer(dev->mt76.wcid[idx], &mvif->sta.deflink.wcid);
if (vif->txq) {
mtxq = (struct mt76_txq *)vif->txq->drv_priv;
mtxq->wcid = idx;
@@ -494,7 +494,7 @@ static int mt7921_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct mt792x_sta *msta = sta ? (struct mt792x_sta *)sta->drv_priv :
&mvif->sta;
- struct mt76_wcid *wcid = &msta->wcid;
+ struct mt76_wcid *wcid = &msta->deflink.wcid;
u8 *wcid_keyidx = &wcid->hw_key_idx;
int idx = key->keyidx, err = 0;

@@ -541,18 +541,18 @@ static int mt7921_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
}

mt76_wcid_key_setup(&dev->mt76, wcid, key);
- err = mt76_connac_mcu_add_key(&dev->mt76, vif, &msta->bip,
+ err = mt76_connac_mcu_add_key(&dev->mt76, vif, &msta->deflink.bip,
key, MCU_UNI_CMD(STA_REC_UPDATE),
- &msta->wcid, cmd);
+ &msta->deflink.wcid, cmd);
if (err)
goto out;

if (key->cipher == WLAN_CIPHER_SUITE_WEP104 ||
key->cipher == WLAN_CIPHER_SUITE_WEP40)
err = mt76_connac_mcu_add_key(&dev->mt76, vif,
- &mvif->wep_sta->bip,
+ &mvif->wep_sta->deflink.bip,
key, MCU_UNI_CMD(STA_REC_UPDATE),
- &mvif->wep_sta->wcid, cmd);
+ &mvif->wep_sta->deflink.wcid, cmd);
out:
mt792x_mutex_release(dev);

@@ -799,13 +799,13 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
if (idx < 0)
return -ENOSPC;

- INIT_LIST_HEAD(&msta->wcid.poll_list);
+ INIT_LIST_HEAD(&msta->deflink.wcid.poll_list);
msta->vif = mvif;
- msta->wcid.sta = 1;
- msta->wcid.idx = idx;
- msta->wcid.phy_idx = mvif->bss_conf.mt76.band_idx;
- msta->wcid.tx_info |= MT_WCID_TX_INFO_SET;
- msta->last_txs = jiffies;
+ msta->deflink.wcid.sta = 1;
+ msta->deflink.wcid.idx = idx;
+ msta->deflink.wcid.phy_idx = mvif->bss_conf.mt76.band_idx;
+ msta->deflink.wcid.tx_info |= MT_WCID_TX_INFO_SET;
+ msta->deflink.last_txs = jiffies;

ret = mt76_connac_pm_wake(&dev->mphy, &dev->pm);
if (ret)
@@ -840,14 +840,14 @@ void mt7921_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
mt792x_mutex_acquire(dev);

if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
- mt76_connac_mcu_uni_add_bss(&dev->mphy, vif, &mvif->sta.wcid,
+ mt76_connac_mcu_uni_add_bss(&dev->mphy, vif, &mvif->sta.deflink.wcid,
true, mvif->bss_conf.mt76.ctx);

- ewma_avg_signal_init(&msta->avg_ack_signal);
+ ewma_avg_signal_init(&msta->deflink.avg_ack_signal);

- mt7921_mac_wtbl_update(dev, msta->wcid.idx,
+ mt7921_mac_wtbl_update(dev, msta->deflink.wcid.idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
- memset(msta->airtime_ac, 0, sizeof(msta->airtime_ac));
+ memset(msta->deflink.airtime_ac, 0, sizeof(msta->deflink.airtime_ac));

mt7921_mcu_sta_update(dev, sta, vif, true, MT76_STA_INFO_STATE_ASSOC);

@@ -861,11 +861,11 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;

- mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->wcid);
+ mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->deflink.wcid);
mt76_connac_pm_wake(&dev->mphy, &dev->pm);

mt7921_mcu_sta_update(dev, sta, vif, false, MT76_STA_INFO_STATE_NONE);
- mt7921_mac_wtbl_update(dev, msta->wcid.idx,
+ mt7921_mac_wtbl_update(dev, msta->deflink.wcid.idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

if (vif->type == NL80211_IFTYPE_STATION) {
@@ -875,13 +875,13 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
ewma_rssi_init(&mvif->bss_conf.rssi);
if (!sta->tdls)
mt76_connac_mcu_uni_add_bss(&dev->mphy, vif,
- &mvif->sta.wcid, false,
+ &mvif->sta.deflink.wcid, false,
mvif->bss_conf.mt76.ctx);
}

spin_lock_bh(&dev->mt76.sta_poll_lock);
- if (!list_empty(&msta->wcid.poll_list))
- list_del_init(&msta->wcid.poll_list);
+ if (!list_empty(&msta->deflink.wcid.poll_list))
+ list_del_init(&msta->deflink.wcid.poll_list);
spin_unlock_bh(&dev->mt76.sta_poll_lock);

mt7921_regd_set_6ghz_power_type(vif, false);
@@ -923,12 +923,12 @@ mt7921_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
mt792x_mutex_acquire(dev);
switch (action) {
case IEEE80211_AMPDU_RX_START:
- mt76_rx_aggr_start(&dev->mt76, &msta->wcid, tid, ssn,
+ mt76_rx_aggr_start(&dev->mt76, &msta->deflink.wcid, tid, ssn,
params->buf_size);
mt7921_mcu_uni_rx_ba(dev, params, true);
break;
case IEEE80211_AMPDU_RX_STOP:
- mt76_rx_aggr_stop(&dev->mt76, &msta->wcid, tid);
+ mt76_rx_aggr_stop(&dev->mt76, &msta->deflink.wcid, tid);
mt7921_mcu_uni_rx_ba(dev, params, false);
break;
case IEEE80211_AMPDU_TX_OPERATIONAL:
@@ -939,16 +939,16 @@ mt7921_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
case IEEE80211_AMPDU_TX_STOP_FLUSH:
case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
mtxq->aggr = false;
- clear_bit(tid, &msta->wcid.ampdu_state);
+ clear_bit(tid, &msta->deflink.wcid.ampdu_state);
mt7921_mcu_uni_tx_ba(dev, params, false);
break;
case IEEE80211_AMPDU_TX_START:
- set_bit(tid, &msta->wcid.ampdu_state);
+ set_bit(tid, &msta->deflink.wcid.ampdu_state);
ret = IEEE80211_AMPDU_TX_START_IMMEDIATE;
break;
case IEEE80211_AMPDU_TX_STOP_CONT:
mtxq->aggr = false;
- clear_bit(tid, &msta->wcid.ampdu_state);
+ clear_bit(tid, &msta->deflink.wcid.ampdu_state);
mt7921_mcu_uni_tx_ba(dev, params, false);
ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
break;
@@ -1166,11 +1166,11 @@ static void mt7921_sta_set_decap_offload(struct ieee80211_hw *hw,
mt792x_mutex_acquire(dev);

if (enabled)
- set_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags);
+ set_bit(MT_WCID_FLAG_HDR_TRANS, &msta->deflink.wcid.flags);
else
- clear_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags);
+ clear_bit(MT_WCID_FLAG_HDR_TRANS, &msta->deflink.wcid.flags);

- mt76_connac_mcu_sta_update_hdr_trans(&dev->mt76, vif, &msta->wcid,
+ mt76_connac_mcu_sta_update_hdr_trans(&dev->mt76, vif, &msta->deflink.wcid,
MCU_UNI_CMD(STA_REC_UPDATE));

mt792x_mutex_release(dev);
@@ -1294,7 +1294,7 @@ mt7921_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,

mt792x_mutex_acquire(dev);

- err = mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.wcid,
+ err = mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.deflink.wcid,
true, mvif->bss_conf.mt76.ctx);
if (err)
goto out;
@@ -1326,7 +1326,7 @@ mt7921_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
if (err)
goto out;

- mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.wcid, false,
+ mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.deflink.wcid, false,
mvif->bss_conf.mt76.ctx);

out:
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
index 0453af012016..394fcd799345 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
@@ -386,7 +386,7 @@ int mt7921_mcu_uni_tx_ba(struct mt792x_dev *dev,
struct mt792x_sta *msta = (struct mt792x_sta *)params->sta->drv_priv;

if (enable && !params->amsdu)
- msta->wcid.amsdu = false;
+ msta->deflink.wcid.amsdu = false;

return mt76_connac_mcu_sta_ba(&dev->mt76, &msta->vif->bss_conf.mt76, params,
MCU_UNI_CMD(STA_REC_UPDATE),
@@ -1055,7 +1055,7 @@ int mt7921_mcu_sta_update(struct mt792x_dev *dev, struct ieee80211_sta *sta,
struct mt792x_sta *msta;

msta = sta ? (struct mt792x_sta *)sta->drv_priv : NULL;
- info.wcid = msta ? &msta->wcid : &mvif->sta.wcid;
+ info.wcid = msta ? &msta->deflink.wcid : &mvif->sta.deflink.wcid;
info.newly = msta ? state != MT76_STA_INFO_STATE_ASSOC : true;

return mt76_connac_mcu_sta_cmd(&dev->mphy, &info);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c
index c866144ff061..a0c19e861ce1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c
@@ -34,9 +34,9 @@ int mt7921e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
if (sta) {
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;

- if (time_after(jiffies, msta->last_txs + HZ / 4)) {
+ if (time_after(jiffies, msta->deflink.last_txs + HZ / 4)) {
info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
- msta->last_txs = jiffies;
+ msta->deflink.last_txs = jiffies;
}
}

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
index c2460ef4993d..88e7b2ff4593 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
@@ -28,6 +28,7 @@ static void mt7925_mac_sta_poll(struct mt792x_dev *dev)
};
struct ieee80211_sta *sta;
struct mt792x_sta *msta;
+ struct mt792x_link_sta *mlink;
u32 tx_time[IEEE80211_NUM_ACS], rx_time[IEEE80211_NUM_ACS];
LIST_HEAD(sta_poll_list);
struct rate_info *rate;
@@ -46,24 +47,25 @@ static void mt7925_mac_sta_poll(struct mt792x_dev *dev)

if (list_empty(&sta_poll_list))
break;
- msta = list_first_entry(&sta_poll_list,
- struct mt792x_sta, wcid.poll_list);
+ mlink = list_first_entry(&sta_poll_list,
+ struct mt792x_link_sta, wcid.poll_list);
+ msta = container_of(mlink, struct mt792x_sta, deflink);
spin_lock_bh(&dev->mt76.sta_poll_lock);
- list_del_init(&msta->wcid.poll_list);
+ list_del_init(&mlink->wcid.poll_list);
spin_unlock_bh(&dev->mt76.sta_poll_lock);

- idx = msta->wcid.idx;
+ idx = mlink->wcid.idx;
addr = mt7925_mac_wtbl_lmac_addr(dev, idx, MT_WTBL_AC0_CTT_OFFSET);

for (i = 0; i < IEEE80211_NUM_ACS; i++) {
- u32 tx_last = msta->airtime_ac[i];
- u32 rx_last = msta->airtime_ac[i + 4];
+ u32 tx_last = mlink->airtime_ac[i];
+ u32 rx_last = mlink->airtime_ac[i + 4];

- msta->airtime_ac[i] = mt76_rr(dev, addr);
- msta->airtime_ac[i + 4] = mt76_rr(dev, addr + 4);
+ mlink->airtime_ac[i] = mt76_rr(dev, addr);
+ mlink->airtime_ac[i + 4] = mt76_rr(dev, addr + 4);

- tx_time[i] = msta->airtime_ac[i] - tx_last;
- rx_time[i] = msta->airtime_ac[i + 4] - rx_last;
+ tx_time[i] = mlink->airtime_ac[i] - tx_last;
+ rx_time[i] = mlink->airtime_ac[i + 4] - rx_last;

if ((tx_last | rx_last) & BIT(30))
clear = true;
@@ -74,10 +76,10 @@ static void mt7925_mac_sta_poll(struct mt792x_dev *dev)
if (clear) {
mt7925_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
- memset(msta->airtime_ac, 0, sizeof(msta->airtime_ac));
+ memset(mlink->airtime_ac, 0, sizeof(mlink->airtime_ac));
}

- if (!msta->wcid.sta)
+ if (!mlink->wcid.sta)
continue;

sta = container_of((void *)msta, struct ieee80211_sta,
@@ -100,7 +102,7 @@ static void mt7925_mac_sta_poll(struct mt792x_dev *dev)
* we need to make sure that flags match so polling GI
* from per-sta counters directly.
*/
- rate = &msta->wcid.rate;
+ rate = &mlink->wcid.rate;

switch (rate->bw) {
case RATE_INFO_BW_160:
@@ -144,10 +146,10 @@ static void mt7925_mac_sta_poll(struct mt792x_dev *dev)
rssi[2] = to_rssi(GENMASK(23, 16), val);
rssi[3] = to_rssi(GENMASK(31, 14), val);

- msta->ack_signal =
+ mlink->ack_signal =
mt76_rx_signal(msta->vif->phy->mt76->antenna_mask, rssi);

- ewma_avg_signal_add(&msta->avg_ack_signal, -msta->ack_signal);
+ ewma_avg_signal_add(&mlink->avg_ack_signal, -mlink->ack_signal);
}
}

@@ -365,7 +367,7 @@ mt7925_mac_fill_rx(struct mt792x_dev *dev, struct sk_buff *skb)
u32 rxd2 = le32_to_cpu(rxd[2]);
u32 rxd3 = le32_to_cpu(rxd[3]);
u32 rxd4 = le32_to_cpu(rxd[4]);
- struct mt792x_sta *msta = NULL;
+ struct mt792x_link_sta *mlink;
u8 mode = 0; /* , band_idx; */
u16 seq_ctrl = 0;
__le16 fc = 0;
@@ -393,10 +395,10 @@ mt7925_mac_fill_rx(struct mt792x_dev *dev, struct sk_buff *skb)
status->wcid = mt792x_rx_get_wcid(dev, idx, unicast);

if (status->wcid) {
- msta = container_of(status->wcid, struct mt792x_sta, wcid);
+ mlink = container_of(status->wcid, struct mt792x_link_sta, wcid);
spin_lock_bh(&dev->mt76.sta_poll_lock);
- if (list_empty(&msta->wcid.poll_list))
- list_add_tail(&msta->wcid.poll_list,
+ if (list_empty(&mlink->wcid.poll_list))
+ list_add_tail(&mlink->wcid.poll_list,
&dev->mt76.sta_poll_list);
spin_unlock_bh(&dev->mt76.sta_poll_lock);
}
@@ -851,7 +853,7 @@ static void mt7925_tx_check_aggr(struct ieee80211_sta *sta, __le32 *txwi)
return;

msta = (struct mt792x_sta *)sta->drv_priv;
- if (!test_and_set_bit(tid, &msta->wcid.ampdu_state))
+ if (!test_and_set_bit(tid, &msta->deflink.wcid.ampdu_state))
ieee80211_start_tx_ba_session(sta, tid, 0);
}

@@ -991,7 +993,7 @@ mt7925_mac_add_txs_skb(struct mt792x_dev *dev, struct mt76_wcid *wcid,

void mt7925_mac_add_txs(struct mt792x_dev *dev, void *data)
{
- struct mt792x_sta *msta = NULL;
+ struct mt792x_link_sta *mlink = NULL;
struct mt76_wcid *wcid;
__le32 *txs_data = data;
u16 wcidx;
@@ -1015,15 +1017,15 @@ void mt7925_mac_add_txs(struct mt792x_dev *dev, void *data)
if (!wcid)
goto out;

- msta = container_of(wcid, struct mt792x_sta, wcid);
+ mlink = container_of(wcid, struct mt792x_link_sta, wcid);

mt7925_mac_add_txs_skb(dev, wcid, pid, txs_data);
if (!wcid->sta)
goto out;

spin_lock_bh(&dev->mt76.sta_poll_lock);
- if (list_empty(&msta->wcid.poll_list))
- list_add_tail(&msta->wcid.poll_list, &dev->mt76.sta_poll_list);
+ if (list_empty(&mlink->wcid.poll_list))
+ list_add_tail(&mlink->wcid.poll_list, &dev->mt76.sta_poll_list);
spin_unlock_bh(&dev->mt76.sta_poll_lock);

out:
@@ -1094,7 +1096,7 @@ mt7925_mac_tx_free(struct mt792x_dev *dev, void *data, int len)
*/
info = le32_to_cpu(*cur_info);
if (info & MT_TXFREE_INFO_PAIR) {
- struct mt792x_sta *msta;
+ struct mt792x_link_sta *mlink;
u16 idx;

idx = FIELD_GET(MT_TXFREE_INFO_WLAN_ID, info);
@@ -1103,10 +1105,10 @@ mt7925_mac_tx_free(struct mt792x_dev *dev, void *data, int len)
if (!sta)
continue;

- msta = container_of(wcid, struct mt792x_sta, wcid);
+ mlink = container_of(wcid, struct mt792x_link_sta, wcid);
spin_lock_bh(&mdev->sta_poll_lock);
- if (list_empty(&msta->wcid.poll_list))
- list_add_tail(&msta->wcid.poll_list,
+ if (list_empty(&mlink->wcid.poll_list))
+ list_add_tail(&mlink->wcid.poll_list,
&mdev->sta_poll_list);
spin_unlock_bh(&mdev->sta_poll_lock);
continue;
@@ -1241,11 +1243,11 @@ mt7925_vif_connect_iter(void *priv, u8 *mac,
if (vif->type == NL80211_IFTYPE_STATION)
ieee80211_disconnect(vif, true);

- mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.wcid, true);
+ mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.deflink.wcid, true);
mt7925_mcu_set_tx(dev, vif);

if (vif->type == NL80211_IFTYPE_AP) {
- mt76_connac_mcu_uni_add_bss(dev->phy.mt76, vif, &mvif->sta.wcid,
+ mt76_connac_mcu_uni_add_bss(dev->phy.mt76, vif, &mvif->sta.deflink.wcid,
true, NULL);
mt7925_mcu_sta_update(dev, NULL, vif, true,
MT76_STA_INFO_STATE_NONE);
@@ -1380,9 +1382,9 @@ int mt7925_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
if (sta) {
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;

- if (time_after(jiffies, msta->last_txs + HZ / 4)) {
+ if (time_after(jiffies, msta->deflink.last_txs + HZ / 4)) {
info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
- msta->last_txs = jiffies;
+ msta->deflink.last_txs = jiffies;
}
}

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index dfc606cc9bdd..504c2ecc3845 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -344,7 +344,7 @@ mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
else
mvif->bss_conf.mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL;

- ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.wcid,
+ ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.deflink.wcid,
true);
if (ret)
goto out;
@@ -354,20 +354,20 @@ mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)

idx = MT792x_WTBL_RESERVED - mvif->bss_conf.mt76.idx;

- INIT_LIST_HEAD(&mvif->sta.wcid.poll_list);
- mvif->sta.wcid.idx = idx;
- mvif->sta.wcid.phy_idx = mvif->bss_conf.mt76.band_idx;
- mvif->sta.wcid.hw_key_idx = -1;
- mvif->sta.wcid.tx_info |= MT_WCID_TX_INFO_SET;
+ INIT_LIST_HEAD(&mvif->sta.deflink.wcid.poll_list);
+ mvif->sta.deflink.wcid.idx = idx;
+ mvif->sta.deflink.wcid.phy_idx = mvif->bss_conf.mt76.band_idx;
+ mvif->sta.deflink.wcid.hw_key_idx = -1;
+ mvif->sta.deflink.wcid.tx_info |= MT_WCID_TX_INFO_SET;
mvif->sta.vif = mvif;
- mt76_wcid_init(&mvif->sta.wcid);
+ mt76_wcid_init(&mvif->sta.deflink.wcid);

mt7925_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

ewma_rssi_init(&mvif->bss_conf.rssi);

- rcu_assign_pointer(dev->mt76.wcid[idx], &mvif->sta.wcid);
+ rcu_assign_pointer(dev->mt76.wcid[idx], &mvif->sta.deflink.wcid);
if (vif->txq) {
mtxq = (struct mt76_txq *)vif->txq->drv_priv;
mtxq->wcid = idx;
@@ -486,7 +486,7 @@ static int mt7925_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct mt792x_sta *msta = sta ? (struct mt792x_sta *)sta->drv_priv :
&mvif->sta;
- struct mt76_wcid *wcid = &msta->wcid;
+ struct mt76_wcid *wcid = &msta->deflink.wcid;
u8 *wcid_keyidx = &wcid->hw_key_idx;
int idx = key->keyidx, err = 0;

@@ -541,18 +541,18 @@ static int mt7925_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
mt76_wcid_key_setup(&dev->mt76, wcid,
cmd == SET_KEY ? key : NULL);

- err = mt7925_mcu_add_key(&dev->mt76, vif, &msta->bip,
+ err = mt7925_mcu_add_key(&dev->mt76, vif, &msta->deflink.bip,
key, MCU_UNI_CMD(STA_REC_UPDATE),
- &msta->wcid, cmd);
+ &msta->deflink.wcid, cmd);

if (err)
goto out;

if (key->cipher == WLAN_CIPHER_SUITE_WEP104 ||
key->cipher == WLAN_CIPHER_SUITE_WEP40)
- err = mt7925_mcu_add_key(&dev->mt76, vif, &mvif->wep_sta->bip,
+ err = mt7925_mcu_add_key(&dev->mt76, vif, &mvif->wep_sta->deflink.bip,
key, MCU_WMWA_UNI_CMD(STA_REC_UPDATE),
- &mvif->wep_sta->wcid, cmd);
+ &mvif->wep_sta->deflink.wcid, cmd);

out:
mt792x_mutex_release(dev);
@@ -766,13 +766,13 @@ int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
if (idx < 0)
return -ENOSPC;

- INIT_LIST_HEAD(&msta->wcid.poll_list);
+ INIT_LIST_HEAD(&msta->deflink.wcid.poll_list);
msta->vif = mvif;
- msta->wcid.sta = 1;
- msta->wcid.idx = idx;
- msta->wcid.phy_idx = mvif->bss_conf.mt76.band_idx;
- msta->wcid.tx_info |= MT_WCID_TX_INFO_SET;
- msta->last_txs = jiffies;
+ msta->deflink.wcid.sta = 1;
+ msta->deflink.wcid.idx = idx;
+ msta->deflink.wcid.phy_idx = mvif->bss_conf.mt76.band_idx;
+ msta->deflink.wcid.tx_info |= MT_WCID_TX_INFO_SET;
+ msta->deflink.last_txs = jiffies;

ret = mt76_connac_pm_wake(&dev->mphy, &dev->pm);
if (ret)
@@ -813,11 +813,11 @@ void mt7925_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx, vif, sta,
true);

- ewma_avg_signal_init(&msta->avg_ack_signal);
+ ewma_avg_signal_init(&msta->deflink.avg_ack_signal);

- mt7925_mac_wtbl_update(dev, msta->wcid.idx,
+ mt7925_mac_wtbl_update(dev, msta->deflink.wcid.idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
- memset(msta->airtime_ac, 0, sizeof(msta->airtime_ac));
+ memset(msta->deflink.airtime_ac, 0, sizeof(msta->deflink.airtime_ac));

mt7925_mcu_sta_update(dev, sta, vif, true, MT76_STA_INFO_STATE_ASSOC);

@@ -831,11 +831,11 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;

- mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->wcid);
+ mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->deflink.wcid);
mt76_connac_pm_wake(&dev->mphy, &dev->pm);

mt7925_mcu_sta_update(dev, sta, vif, false, MT76_STA_INFO_STATE_NONE);
- mt7925_mac_wtbl_update(dev, msta->wcid.idx,
+ mt7925_mac_wtbl_update(dev, msta->deflink.wcid.idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

if (vif->type == NL80211_IFTYPE_STATION) {
@@ -849,8 +849,8 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
}

spin_lock_bh(&mdev->sta_poll_lock);
- if (!list_empty(&msta->wcid.poll_list))
- list_del_init(&msta->wcid.poll_list);
+ if (!list_empty(&msta->deflink.wcid.poll_list))
+ list_del_init(&msta->deflink.wcid.poll_list);
spin_unlock_bh(&mdev->sta_poll_lock);

mt76_connac_power_save_sched(&dev->mphy, &dev->pm);
@@ -890,12 +890,12 @@ mt7925_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
mt792x_mutex_acquire(dev);
switch (action) {
case IEEE80211_AMPDU_RX_START:
- mt76_rx_aggr_start(&dev->mt76, &msta->wcid, tid, ssn,
+ mt76_rx_aggr_start(&dev->mt76, &msta->deflink.wcid, tid, ssn,
params->buf_size);
mt7925_mcu_uni_rx_ba(dev, params, true);
break;
case IEEE80211_AMPDU_RX_STOP:
- mt76_rx_aggr_stop(&dev->mt76, &msta->wcid, tid);
+ mt76_rx_aggr_stop(&dev->mt76, &msta->deflink.wcid, tid);
mt7925_mcu_uni_rx_ba(dev, params, false);
break;
case IEEE80211_AMPDU_TX_OPERATIONAL:
@@ -906,16 +906,16 @@ mt7925_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
case IEEE80211_AMPDU_TX_STOP_FLUSH:
case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
mtxq->aggr = false;
- clear_bit(tid, &msta->wcid.ampdu_state);
+ clear_bit(tid, &msta->deflink.wcid.ampdu_state);
mt7925_mcu_uni_tx_ba(dev, params, false);
break;
case IEEE80211_AMPDU_TX_START:
- set_bit(tid, &msta->wcid.ampdu_state);
+ set_bit(tid, &msta->deflink.wcid.ampdu_state);
ret = IEEE80211_AMPDU_TX_START_IMMEDIATE;
break;
case IEEE80211_AMPDU_TX_STOP_CONT:
mtxq->aggr = false;
- clear_bit(tid, &msta->wcid.ampdu_state);
+ clear_bit(tid, &msta->deflink.wcid.ampdu_state);
mt7925_mcu_uni_tx_ba(dev, params, false);
ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
break;
@@ -1161,9 +1161,9 @@ static void mt7925_sta_set_decap_offload(struct ieee80211_hw *hw,
mt792x_mutex_acquire(dev);

if (enabled)
- set_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags);
+ set_bit(MT_WCID_FLAG_HDR_TRANS, &msta->deflink.wcid.flags);
else
- clear_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags);
+ clear_bit(MT_WCID_FLAG_HDR_TRANS, &msta->deflink.wcid.flags);

mt7925_mcu_wtbl_update_hdr_trans(dev, vif, sta);

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index c259aedb96e0..67c05f785190 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -544,7 +544,7 @@ int mt7925_mcu_uni_tx_ba(struct mt792x_dev *dev,
struct mt792x_vif *mvif = msta->vif;

if (enable && !params->amsdu)
- msta->wcid.amsdu = false;
+ msta->deflink.wcid.amsdu = false;

return mt7925_mcu_sta_ba(&dev->mt76, &mvif->bss_conf.mt76, params,
enable, true);
@@ -867,7 +867,7 @@ mt7925_mcu_sta_hdr_trans_tlv(struct sk_buff *skb,
if (sta)
wcid = (struct mt76_wcid *)sta->drv_priv;
else
- wcid = &mvif->sta.wcid;
+ wcid = &mvif->sta.deflink.wcid;

if (!wcid)
return;
@@ -890,7 +890,7 @@ int mt7925_mcu_wtbl_update_hdr_trans(struct mt792x_dev *dev,
msta = sta ? (struct mt792x_sta *)sta->drv_priv : &mvif->sta;

skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->bss_conf.mt76,
- &msta->wcid,
+ &msta->deflink.wcid,
MT7925_STA_UPDATE_MAX_SIZE);
if (IS_ERR(skb))
return PTR_ERR(skb);
@@ -962,7 +962,8 @@ mt7925_mcu_sta_key_tlv(struct mt76_wcid *wcid,
struct ieee80211_key_conf *key,
enum set_key_cmd cmd)
{
- struct mt792x_sta *msta = container_of(wcid, struct mt792x_sta, wcid);
+ struct mt792x_link_sta *mlink = container_of(wcid, struct mt792x_link_sta, wcid);
+ struct mt792x_sta *msta = container_of(mlink, struct mt792x_sta, deflink);
struct sta_rec_sec_uni *sec;
struct mt792x_vif *mvif = msta->vif;
struct ieee80211_sta *sta;
@@ -1480,7 +1481,7 @@ mt7925_mcu_sta_amsdu_tlv(struct sk_buff *skb,
amsdu = (struct sta_rec_amsdu *)tlv;
amsdu->max_amsdu_num = 8;
amsdu->amsdu_en = true;
- msta->wcid.amsdu = true;
+ msta->deflink.wcid.amsdu = true;

switch (sta->deflink.agg.max_amsdu_len) {
case IEEE80211_MAX_MPDU_LEN_VHT_11454:
@@ -1668,7 +1669,7 @@ int mt7925_mcu_sta_update(struct mt792x_dev *dev, struct ieee80211_sta *sta,
struct mt792x_sta *msta;

msta = sta ? (struct mt792x_sta *)sta->drv_priv : NULL;
- info.wcid = msta ? &msta->wcid : &mvif->sta.wcid;
+ info.wcid = msta ? &msta->deflink.wcid : &mvif->sta.deflink.wcid;
info.newly = msta ? state != MT76_STA_INFO_STATE_ASSOC : true;

return mt7925_mcu_sta_cmd(&dev->mphy, &info);
@@ -2096,7 +2097,7 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb,
basic_req->bcn_interval = cpu_to_le16(vif->bss_conf.beacon_int);
basic_req->dtim_period = vif->bss_conf.dtim_period;
basic_req->bmc_tx_wlan_idx = cpu_to_le16(wlan_idx);
- basic_req->sta_idx = cpu_to_le16(msta->wcid.idx);
+ basic_req->sta_idx = cpu_to_le16(msta->deflink.wcid.idx);
basic_req->omac_idx = mvif->bss_conf.mt76.omac_idx;
basic_req->band_idx = mvif->bss_conf.mt76.band_idx;
basic_req->wmm_idx = mvif->bss_conf.mt76.wmm_idx;
@@ -2330,7 +2331,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,

/* bss_basic must be first */
mt7925_mcu_bss_basic_tlv(skb, vif, sta, ctx, phy->mt76,
- mvif->sta.wcid.idx, enable);
+ mvif->sta.deflink.wcid.idx, enable);
mt7925_mcu_bss_sec_tlv(skb, vif);

mt7925_mcu_bss_bmc_tlv(skb, phy, ctx, vif, sta);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c
index 9fca887977d2..ef631a68005d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c
@@ -34,9 +34,9 @@ int mt7925e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
if (sta) {
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;

- if (time_after(jiffies, msta->last_txs + HZ / 4)) {
+ if (time_after(jiffies, msta->deflink.last_txs + HZ / 4)) {
info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
- msta->last_txs = jiffies;
+ msta->deflink.last_txs = jiffies;
}
}

diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h
index e377f8ea9782..cb0bb06bef80 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x.h
+++ b/drivers/net/wireless/mediatek/mt76/mt792x.h
@@ -79,11 +79,9 @@ enum mt792x_reg_power_type {

DECLARE_EWMA(avg_signal, 10, 8)

-struct mt792x_sta {
+struct mt792x_link_sta {
struct mt76_wcid wcid; /* must be first */

- struct mt792x_vif *vif;
-
u32 airtime_ac[8];

int ack_signal;
@@ -94,6 +92,12 @@ struct mt792x_sta {
struct mt76_connac_sta_key_conf bip;
};

+struct mt792x_sta {
+ struct mt792x_link_sta deflink; /* must be first */
+
+ struct mt792x_vif *vif;
+};
+
DECLARE_EWMA(rssi, 10, 8);

struct mt792x_bss_conf {
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
index 4b4afc1add6e..ae21a2829c9c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c
+++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
@@ -65,14 +65,14 @@ void mt792x_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
struct mt792x_sta *sta;

sta = (struct mt792x_sta *)control->sta->drv_priv;
- wcid = &sta->wcid;
+ wcid = &sta->deflink.wcid;
}

if (vif && !control->sta) {
struct mt792x_vif *mvif;

mvif = (struct mt792x_vif *)vif->drv_priv;
- wcid = &mvif->sta.wcid;
+ wcid = &mvif->sta.deflink.wcid;
}

if (mt76_connac_pm_ref(mphy, &dev->pm)) {
@@ -120,11 +120,11 @@ void mt792x_remove_interface(struct ieee80211_hw *hw,
struct mt792x_sta *msta = &mvif->sta;
struct mt792x_dev *dev = mt792x_hw_dev(hw);
struct mt792x_phy *phy = mt792x_hw_phy(hw);
- int idx = msta->wcid.idx;
+ int idx = msta->deflink.wcid.idx;

mt792x_mutex_acquire(dev);
- mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->wcid);
- mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.wcid, false);
+ mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->deflink.wcid);
+ mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.deflink.wcid, false);

rcu_assign_pointer(dev->mt76.wcid[idx], NULL);

@@ -133,11 +133,11 @@ void mt792x_remove_interface(struct ieee80211_hw *hw,
mt792x_mutex_release(dev);

spin_lock_bh(&dev->mt76.sta_poll_lock);
- if (!list_empty(&msta->wcid.poll_list))
- list_del_init(&msta->wcid.poll_list);
+ if (!list_empty(&msta->deflink.wcid.poll_list))
+ list_del_init(&msta->deflink.wcid.poll_list);
spin_unlock_bh(&dev->mt76.sta_poll_lock);

- mt76_wcid_cleanup(&dev->mt76, &msta->wcid);
+ mt76_wcid_cleanup(&dev->mt76, &msta->deflink.wcid);
}
EXPORT_SYMBOL_GPL(mt792x_remove_interface);

@@ -408,7 +408,7 @@ mt792x_ethtool_worker(void *wi_data, struct ieee80211_sta *sta)
if (msta->vif->bss_conf.mt76.idx != wi->idx)
return;

- mt76_ethtool_worker(wi, &msta->wcid.stats, true);
+ mt76_ethtool_worker(wi, &msta->deflink.wcid.stats, true);
}

void mt792x_get_et_stats(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
@@ -487,7 +487,7 @@ void mt792x_sta_statistics(struct ieee80211_hw *hw,
struct station_info *sinfo)
{
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
- struct rate_info *txrate = &msta->wcid.rate;
+ struct rate_info *txrate = &msta->deflink.wcid.rate;

if (!txrate->legacy && !txrate->flags)
return;
@@ -502,19 +502,19 @@ void mt792x_sta_statistics(struct ieee80211_hw *hw,
sinfo->txrate.he_dcm = txrate->he_dcm;
sinfo->txrate.he_ru_alloc = txrate->he_ru_alloc;
}
- sinfo->tx_failed = msta->wcid.stats.tx_failed;
+ sinfo->tx_failed = msta->deflink.wcid.stats.tx_failed;
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED);

- sinfo->tx_retries = msta->wcid.stats.tx_retries;
+ sinfo->tx_retries = msta->deflink.wcid.stats.tx_retries;
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES);

sinfo->txrate.flags = txrate->flags;
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE);

- sinfo->ack_signal = (s8)msta->ack_signal;
+ sinfo->ack_signal = (s8)msta->deflink.ack_signal;
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL);

- sinfo->avg_ack_signal = -(s8)ewma_avg_signal_read(&msta->avg_ack_signal);
+ sinfo->avg_ack_signal = -(s8)ewma_avg_signal_read(&msta->deflink.avg_ack_signal);
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL_AVG);
}
EXPORT_SYMBOL_GPL(mt792x_sta_statistics);
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_mac.c b/drivers/net/wireless/mediatek/mt76/mt792x_mac.c
index 45dd94ff386d..106273935b26 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x_mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt792x_mac.c
@@ -138,6 +138,7 @@ EXPORT_SYMBOL_GPL(mt792x_mac_update_mib_stats);
struct mt76_wcid *mt792x_rx_get_wcid(struct mt792x_dev *dev, u16 idx,
bool unicast)
{
+ struct mt792x_link_sta *link;
struct mt792x_sta *sta;
struct mt76_wcid *wcid;

@@ -151,11 +152,12 @@ struct mt76_wcid *mt792x_rx_get_wcid(struct mt792x_dev *dev, u16 idx,
if (!wcid->sta)
return NULL;

- sta = container_of(wcid, struct mt792x_sta, wcid);
+ link = container_of(wcid, struct mt792x_link_sta, wcid);
+ sta = container_of(link, struct mt792x_sta, deflink);
if (!sta->vif)
return NULL;

- return &sta->vif->sta.wcid;
+ return &sta->vif->sta.deflink.wcid;
}
EXPORT_SYMBOL_GPL(mt792x_rx_get_wcid);

--
2.34.1


2024-06-13 03:03:37

by Sean Wang

[permalink] [raw]
Subject: [PATCH 11/47] wifi: mt76: mt7925: extend mt7925_mcu_bss_he_tlv for per-link BSS

From: Sean Wang <[email protected]>

Extend mt7925_mcu_bss_he_tlv with per-link BSS configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 10e38637eb83..533214403008 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -2238,7 +2238,7 @@ mt7925_mcu_bss_qos_tlv(struct sk_buff *skb, struct ieee80211_vif *vif)
}

static void
-mt7925_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
+mt7925_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *link_conf,
struct mt792x_phy *phy)
{
#define DEFAULT_HE_PE_DURATION 4
@@ -2247,16 +2247,16 @@ mt7925_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
struct bss_info_uni_he *he;
struct tlv *tlv;

- cap = mt76_connac_get_he_phy_cap(phy->mt76, vif);
+ cap = mt76_connac_get_he_phy_cap(phy->mt76, link_conf->vif);

tlv = mt76_connac_mcu_add_tlv(skb, UNI_BSS_INFO_HE_BASIC, sizeof(*he));

he = (struct bss_info_uni_he *)tlv;
- he->he_pe_duration = vif->bss_conf.htc_trig_based_pkt_ext;
+ he->he_pe_duration = link_conf->htc_trig_based_pkt_ext;
if (!he->he_pe_duration)
he->he_pe_duration = DEFAULT_HE_PE_DURATION;

- he->he_rts_thres = cpu_to_le16(vif->bss_conf.frame_time_rts_th);
+ he->he_rts_thres = cpu_to_le16(link_conf->frame_time_rts_th);
if (!he->he_rts_thres)
he->he_rts_thres = cpu_to_le16(DEFAULT_HE_DURATION_RTS_THRES);

@@ -2341,7 +2341,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
mt7925_mcu_bss_ifs_tlv(skb, link_conf);

if (link_conf->he_support) {
- mt7925_mcu_bss_he_tlv(skb, link_conf->vif, phy);
+ mt7925_mcu_bss_he_tlv(skb, link_conf, phy);
mt7925_mcu_bss_color_tlv(skb, link_conf, enable);
}

--
2.34.1


2024-06-13 03:03:41

by Sean Wang

[permalink] [raw]
Subject: [PATCH 12/47] wifi: mt76: mt7925: extend mt7925_mcu_bss_qos_tlv for per-link BSS

From: Sean Wang <[email protected]>

Extend mt7925_mcu_bss_qos_tlv with per-link BSS configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 533214403008..d6a590061e36 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -2227,14 +2227,14 @@ mt7925_mcu_bss_mld_tlv(struct sk_buff *skb,
}

static void
-mt7925_mcu_bss_qos_tlv(struct sk_buff *skb, struct ieee80211_vif *vif)
+mt7925_mcu_bss_qos_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *link_conf)
{
struct mt76_connac_bss_qos_tlv *qos;
struct tlv *tlv;

tlv = mt76_connac_mcu_add_tlv(skb, UNI_BSS_INFO_QBSS, sizeof(*qos));
qos = (struct mt76_connac_bss_qos_tlv *)tlv;
- qos->qos = vif->bss_conf.qos;
+ qos->qos = link_conf->qos;
}

static void
@@ -2336,7 +2336,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
mt7925_mcu_bss_sec_tlv(skb, link_conf->vif);

mt7925_mcu_bss_bmc_tlv(skb, phy, ctx, link_conf->vif, sta);
- mt7925_mcu_bss_qos_tlv(skb, link_conf->vif);
+ mt7925_mcu_bss_qos_tlv(skb, link_conf);
mt7925_mcu_bss_mld_tlv(skb, link_conf->vif, sta);
mt7925_mcu_bss_ifs_tlv(skb, link_conf);

--
2.34.1


2024-06-13 03:03:49

by Sean Wang

[permalink] [raw]
Subject: [PATCH 14/47] wifi: mt76: mt7925: extend mt7925_mcu_bss_bmc_tlv for per-link BSS

From: Sean Wang <[email protected]>

Extend mt7925_mcu_bss_bmc_tlv with per-link BSS configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 93ce018a0801..48b157f42db9 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -2179,12 +2179,13 @@ mt7925_mcu_bss_sec_tlv(struct sk_buff *skb, struct ieee80211_vif *vif)
static void
mt7925_mcu_bss_bmc_tlv(struct sk_buff *skb, struct mt792x_phy *phy,
struct ieee80211_chanctx_conf *ctx,
- struct ieee80211_vif *vif,
+ struct ieee80211_bss_conf *link_conf,
struct ieee80211_sta *sta)
{
struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &phy->mt76->chandef;
- struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
+ struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(link_conf);
enum nl80211_band band = chandef->chan->band;
+ struct mt76_vif *mvif = &mconf->mt76;
struct bss_rate_tlv *bmc;
struct tlv *tlv;
u8 idx = mvif->mcast_rates_idx ?
@@ -2335,7 +2336,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
mvif->sta.deflink.wcid.idx, enable);
mt7925_mcu_bss_sec_tlv(skb, link_conf->vif);

- mt7925_mcu_bss_bmc_tlv(skb, phy, ctx, link_conf->vif, sta);
+ mt7925_mcu_bss_bmc_tlv(skb, phy, ctx, link_conf, sta);
mt7925_mcu_bss_qos_tlv(skb, link_conf);
mt7925_mcu_bss_mld_tlv(skb, link_conf, sta);
mt7925_mcu_bss_ifs_tlv(skb, link_conf);
--
2.34.1


2024-06-13 03:03:56

by Sean Wang

[permalink] [raw]
Subject: [PATCH 16/47] wifi: mt76: mt7925: extend mt7925_mcu_bss_sec_tlv for per-link BSS

From: Sean Wang <[email protected]>

Extend mt7925_mcu_bss_sec_tlv with per-link BSS configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 797d4c936fec..028c94d8c21f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -2132,9 +2132,11 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb,
}

static void
-mt7925_mcu_bss_sec_tlv(struct sk_buff *skb, struct ieee80211_vif *vif)
+mt7925_mcu_bss_sec_tlv(struct sk_buff *skb,
+ struct ieee80211_bss_conf *link_conf)
{
- struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
+ struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(link_conf);
+ struct mt76_vif *mvif = &mconf->mt76;
struct bss_sec_tlv {
__le16 tag;
__le16 len;
@@ -2333,7 +2335,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
/* bss_basic must be first */
mt7925_mcu_bss_basic_tlv(skb, link_conf->vif, sta, ctx, phy->mt76,
mvif->sta.deflink.wcid.idx, enable);
- mt7925_mcu_bss_sec_tlv(skb, link_conf->vif);
+ mt7925_mcu_bss_sec_tlv(skb, link_conf);

mt7925_mcu_bss_bmc_tlv(skb, phy, ctx, link_conf);
mt7925_mcu_bss_qos_tlv(skb, link_conf);
--
2.34.1


2024-06-13 03:04:03

by Sean Wang

[permalink] [raw]
Subject: [PATCH 17/47] wifi: mt76: mt7925: extend mt7925_mcu_bss_basic_tlv for per-link BSS

From: Sean Wang <[email protected]>

Extend mt7925_mcu_bss_basic_tlv with per-link BSS configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7925/main.c | 1 +
.../net/wireless/mediatek/mt76/mt7925/mcu.c | 25 ++++++++++---------
drivers/net/wireless/mediatek/mt76/mt792x.h | 1 +
3 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 6a1afff92399..457e1fa2fde1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -338,6 +338,7 @@ mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
mvif->phy = phy;
mvif->bss_conf.mt76.band_idx = 0;
mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx % MT76_CONNAC_MAX_WMM_SETS;
+ mvif->bss_conf.vif = mvif;

if (phy->mt76->chandef.chan->band != NL80211_BAND_2GHZ)
mvif->bss_conf.mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL + 4;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 028c94d8c21f..18e19ffdbb7e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -2062,15 +2062,16 @@ mt7925_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif,

static void
mt7925_mcu_bss_basic_tlv(struct sk_buff *skb,
- struct ieee80211_vif *vif,
+ struct ieee80211_bss_conf *link_conf,
struct ieee80211_sta *sta,
struct ieee80211_chanctx_conf *ctx,
struct mt76_phy *phy, u16 wlan_idx,
bool enable)
{
- struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+ struct ieee80211_vif *vif = link_conf->vif;
+ struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(link_conf);
struct mt792x_sta *msta = sta ? (struct mt792x_sta *)sta->drv_priv :
- &mvif->sta;
+ &mconf->vif->sta;
struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &phy->chandef;
enum nl80211_band band = chandef->chan->band;
struct mt76_connac_bss_basic_tlv *basic_req;
@@ -2081,8 +2082,8 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb,
tlv = mt76_connac_mcu_add_tlv(skb, UNI_BSS_INFO_BASIC, sizeof(*basic_req));
basic_req = (struct mt76_connac_bss_basic_tlv *)tlv;

- idx = mvif->bss_conf.mt76.omac_idx > EXT_BSSID_START ? HW_BSSID_0 :
- mvif->bss_conf.mt76.omac_idx;
+ idx = mconf->mt76.omac_idx > EXT_BSSID_START ? HW_BSSID_0 :
+ mconf->mt76.omac_idx;
basic_req->hw_bss_idx = idx;

basic_req->phymode_ext = mt7925_get_phy_mode_ext(phy, vif, band, sta);
@@ -2092,15 +2093,15 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb,
else
basic_req->nonht_basic_phy = cpu_to_le16(PHY_TYPE_OFDM_INDEX);

- memcpy(basic_req->bssid, vif->bss_conf.bssid, ETH_ALEN);
+ memcpy(basic_req->bssid, link_conf->bssid, ETH_ALEN);
basic_req->phymode = mt76_connac_get_phy_mode(phy, vif, band, sta);
- basic_req->bcn_interval = cpu_to_le16(vif->bss_conf.beacon_int);
- basic_req->dtim_period = vif->bss_conf.dtim_period;
+ basic_req->bcn_interval = cpu_to_le16(link_conf->beacon_int);
+ basic_req->dtim_period = link_conf->dtim_period;
basic_req->bmc_tx_wlan_idx = cpu_to_le16(wlan_idx);
basic_req->sta_idx = cpu_to_le16(msta->deflink.wcid.idx);
- basic_req->omac_idx = mvif->bss_conf.mt76.omac_idx;
- basic_req->band_idx = mvif->bss_conf.mt76.band_idx;
- basic_req->wmm_idx = mvif->bss_conf.mt76.wmm_idx;
+ basic_req->omac_idx = mconf->mt76.omac_idx;
+ basic_req->band_idx = mconf->mt76.band_idx;
+ basic_req->wmm_idx = mconf->mt76.wmm_idx;
basic_req->conn_state = !enable;

switch (vif->type) {
@@ -2333,7 +2334,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
return PTR_ERR(skb);

/* bss_basic must be first */
- mt7925_mcu_bss_basic_tlv(skb, link_conf->vif, sta, ctx, phy->mt76,
+ mt7925_mcu_bss_basic_tlv(skb, link_conf, sta, ctx, phy->mt76,
mvif->sta.deflink.wcid.idx, enable);
mt7925_mcu_bss_sec_tlv(skb, link_conf);

diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h
index f675709f419a..9452a3592950 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x.h
+++ b/drivers/net/wireless/mediatek/mt76/mt792x.h
@@ -106,6 +106,7 @@ struct mt792x_chanctx {

struct mt792x_bss_conf {
struct mt76_vif mt76; /* must be first */
+ struct mt792x_vif *vif;
struct ewma_rssi rssi;
struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS];
};
--
2.34.1


2024-06-13 03:04:04

by Sean Wang

[permalink] [raw]
Subject: [PATCH 18/47] wifi: mt76: mt7925: extend mt7925_mcu_set_bss_pm for per-link BSS

From: Sean Wang <[email protected]>

Extend mt7925_mcu_set_bss_pm with per-link BSS configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/main.c | 4 ++--
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 15 ++++++++-------
.../net/wireless/mediatek/mt76/mt7925/mt7925.h | 3 ++-
3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 457e1fa2fde1..aeed2c777a20 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -1263,7 +1263,7 @@ mt7925_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
if (err)
goto out;

- err = mt7925_mcu_set_bss_pm(dev, vif, true);
+ err = mt7925_mcu_set_bss_pm(dev, link_conf, true);
if (err)
goto out;

@@ -1285,7 +1285,7 @@ mt7925_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,

mt792x_mutex_acquire(dev);

- err = mt7925_mcu_set_bss_pm(dev, vif, false);
+ err = mt7925_mcu_set_bss_pm(dev, link_conf, false);
if (err)
goto out;

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 18e19ffdbb7e..0350f0e34690 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1319,10 +1319,11 @@ mt7925_mcu_uni_bss_bcnft(struct mt792x_dev *dev, struct ieee80211_vif *vif,
}

int
-mt7925_mcu_set_bss_pm(struct mt792x_dev *dev, struct ieee80211_vif *vif,
+mt7925_mcu_set_bss_pm(struct mt792x_dev *dev,
+ struct ieee80211_bss_conf *link_conf,
bool enable)
{
- struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+ struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(link_conf);
struct {
struct {
u8 bss_idx;
@@ -1339,13 +1340,13 @@ mt7925_mcu_set_bss_pm(struct mt792x_dev *dev, struct ieee80211_vif *vif,
} __packed enable;
} req = {
.hdr = {
- .bss_idx = mvif->bss_conf.mt76.idx,
+ .bss_idx = mconf->mt76.idx,
},
.enable = {
.tag = cpu_to_le16(UNI_BSS_INFO_BCNFT),
.len = cpu_to_le16(sizeof(struct bcnft_tlv)),
- .dtim_period = vif->bss_conf.dtim_period,
- .bcn_interval = cpu_to_le16(vif->bss_conf.beacon_int),
+ .dtim_period = link_conf->dtim_period,
+ .bcn_interval = cpu_to_le16(link_conf->beacon_int),
},
};
struct {
@@ -1359,7 +1360,7 @@ mt7925_mcu_set_bss_pm(struct mt792x_dev *dev, struct ieee80211_vif *vif,
} __packed disable;
} req1 = {
.hdr = {
- .bss_idx = mvif->bss_conf.mt76.idx,
+ .bss_idx = mconf->mt76.idx,
},
.disable = {
.tag = cpu_to_le16(UNI_BSS_INFO_PM_DISABLE),
@@ -1693,7 +1694,7 @@ int mt7925_mcu_set_beacon_filter(struct mt792x_dev *dev,
MT_WF_RFCR_DROP_OTHER_BEACON);
}

- err = mt7925_mcu_set_bss_pm(dev, vif, false);
+ err = mt7925_mcu_set_bss_pm(dev, &vif->bss_conf, false);
if (err)
return err;

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
index f689f7a359ea..07ea03195e4e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
@@ -192,7 +192,8 @@ int __mt7925_start(struct mt792x_phy *phy);
int mt7925_register_device(struct mt792x_dev *dev);
void mt7925_unregister_device(struct mt792x_dev *dev);
int mt7925_run_firmware(struct mt792x_dev *dev);
-int mt7925_mcu_set_bss_pm(struct mt792x_dev *dev, struct ieee80211_vif *vif,
+int mt7925_mcu_set_bss_pm(struct mt792x_dev *dev,
+ struct ieee80211_bss_conf *link_conf,
bool enable);
int mt7925_mcu_sta_update(struct mt792x_dev *dev, struct ieee80211_sta *sta,
struct ieee80211_vif *vif, bool enable,
--
2.34.1


2024-06-13 03:04:07

by Sean Wang

[permalink] [raw]
Subject: [PATCH 19/47] wifi: mt76: mt7925: extend mt7925_mcu_[abort, set]_roc for per-link BSS

From: Sean Wang <[email protected]>

The channel context has to be bound with the per-link BSS, thus,
we extend mt7925_mcu_[abort, set]_roc to work with the per-link BSS
configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7925/main.c | 23 +++++++++++--------
.../net/wireless/mediatek/mt76/mt7925/mcu.c | 8 +++----
.../wireless/mediatek/mt76/mt7925/mt7925.h | 4 ++--
3 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index aeed2c777a20..bba17e51a023 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -387,7 +387,7 @@ static void mt7925_roc_iter(void *priv, u8 *mac,
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct mt792x_phy *phy = priv;

- mt7925_mcu_abort_roc(phy, mvif, phy->roc_token_id);
+ mt7925_mcu_abort_roc(phy, &mvif->bss_conf, phy->roc_token_id);
}

void mt7925_roc_work(struct work_struct *work)
@@ -408,7 +408,8 @@ void mt7925_roc_work(struct work_struct *work)
ieee80211_remain_on_channel_expired(phy->mt76->hw);
}

-static int mt7925_abort_roc(struct mt792x_phy *phy, struct mt792x_vif *vif)
+static int mt7925_abort_roc(struct mt792x_phy *phy,
+ struct mt792x_bss_conf *mconf)
{
int err = 0;

@@ -417,14 +418,14 @@ static int mt7925_abort_roc(struct mt792x_phy *phy, struct mt792x_vif *vif)

mt792x_mutex_acquire(phy->dev);
if (test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
- err = mt7925_mcu_abort_roc(phy, vif, phy->roc_token_id);
+ err = mt7925_mcu_abort_roc(phy, mconf, phy->roc_token_id);
mt792x_mutex_release(phy->dev);

return err;
}

static int mt7925_set_roc(struct mt792x_phy *phy,
- struct mt792x_vif *vif,
+ struct mt792x_bss_conf *mconf,
struct ieee80211_channel *chan,
int duration,
enum mt7925_roc_req type)
@@ -436,7 +437,7 @@ static int mt7925_set_roc(struct mt792x_phy *phy,

phy->roc_grant = false;

- err = mt7925_mcu_set_roc(phy, vif, chan, duration, type,
+ err = mt7925_mcu_set_roc(phy, mconf, chan, duration, type,
++phy->roc_token_id);
if (err < 0) {
clear_bit(MT76_STATE_ROC, &phy->mt76->state);
@@ -444,7 +445,7 @@ static int mt7925_set_roc(struct mt792x_phy *phy,
}

if (!wait_event_timeout(phy->roc_wait, phy->roc_grant, 4 * HZ)) {
- mt7925_mcu_abort_roc(phy, vif, phy->roc_token_id);
+ mt7925_mcu_abort_roc(phy, mconf, phy->roc_token_id);
clear_bit(MT76_STATE_ROC, &phy->mt76->state);
err = -ETIMEDOUT;
}
@@ -464,7 +465,8 @@ static int mt7925_remain_on_channel(struct ieee80211_hw *hw,
int err;

mt792x_mutex_acquire(phy->dev);
- err = mt7925_set_roc(phy, mvif, chan, duration, MT7925_ROC_REQ_ROC);
+ err = mt7925_set_roc(phy, &mvif->bss_conf,
+ chan, duration, MT7925_ROC_REQ_ROC);
mt792x_mutex_release(phy->dev);

return err;
@@ -476,7 +478,7 @@ static int mt7925_cancel_remain_on_channel(struct ieee80211_hw *hw,
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct mt792x_phy *phy = mt792x_hw_phy(hw);

- return mt7925_abort_roc(phy, mvif);
+ return mt7925_abort_roc(phy, &mvif->bss_conf);
}

static int mt7925_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
@@ -1345,7 +1347,8 @@ static void mt7925_mgd_prepare_tx(struct ieee80211_hw *hw,
jiffies_to_msecs(HZ);

mt792x_mutex_acquire(dev);
- mt7925_set_roc(mvif->phy, mvif, mvif->bss_conf.mt76.ctx->def.chan, duration,
+ mt7925_set_roc(mvif->phy, &mvif->bss_conf,
+ mvif->bss_conf.mt76.ctx->def.chan, duration,
MT7925_ROC_REQ_JOIN);
mt792x_mutex_release(dev);
}
@@ -1356,7 +1359,7 @@ static void mt7925_mgd_complete_tx(struct ieee80211_hw *hw,
{
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;

- mt7925_abort_roc(mvif->phy, mvif);
+ mt7925_abort_roc(mvif->phy, &mvif->bss_conf);
}

static void mt7925_vif_cfg_changed(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 0350f0e34690..a40ad1578212 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1050,7 +1050,7 @@ int mt7925_mcu_add_key(struct mt76_dev *dev, struct ieee80211_vif *vif,
return mt76_mcu_skb_send_msg(dev, skb, mcu_cmd, true);
}

-int mt7925_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_vif *vif,
+int mt7925_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf,
struct ieee80211_channel *chan, int duration,
enum mt7925_roc_req type, u8 token_id)
{
@@ -1086,7 +1086,7 @@ int mt7925_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_vif *vif,
.tokenid = token_id,
.reqtype = type,
.maxinterval = cpu_to_le32(duration),
- .bss_idx = vif->bss_conf.mt76.idx,
+ .bss_idx = mconf->mt76.idx,
.control_channel = chan->hw_value,
.bw = CMD_CBW_20MHZ,
.bw_from_ap = CMD_CBW_20MHZ,
@@ -1117,7 +1117,7 @@ int mt7925_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_vif *vif,
&req, sizeof(req), false);
}

-int mt7925_mcu_abort_roc(struct mt792x_phy *phy, struct mt792x_vif *vif,
+int mt7925_mcu_abort_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf,
u8 token_id)
{
struct mt792x_dev *dev = phy->dev;
@@ -1138,7 +1138,7 @@ int mt7925_mcu_abort_roc(struct mt792x_phy *phy, struct mt792x_vif *vif,
.tag = cpu_to_le16(UNI_ROC_ABORT),
.len = cpu_to_le16(sizeof(struct roc_abort_tlv)),
.tokenid = token_id,
- .bss_idx = vif->bss_conf.mt76.idx,
+ .bss_idx = mconf->mt76.idx,
.dbdcband = 0xff, /* auto*/
},
};
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
index 07ea03195e4e..8ab2bb01ba73 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
@@ -292,10 +292,10 @@ int mt7925_set_tx_sar_pwr(struct ieee80211_hw *hw,
int mt7925_mcu_regval(struct mt792x_dev *dev, u32 regidx, u32 *val, bool set);
int mt7925_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2,
enum environment_cap env_cap);
-int mt7925_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_vif *vif,
+int mt7925_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf,
struct ieee80211_channel *chan, int duration,
enum mt7925_roc_req type, u8 token_id);
-int mt7925_mcu_abort_roc(struct mt792x_phy *phy, struct mt792x_vif *vif,
+int mt7925_mcu_abort_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf,
u8 token_id);
int mt7925_mcu_fill_message(struct mt76_dev *mdev, struct sk_buff *skb,
int cmd, int *wait_seq);
--
2.34.1


2024-06-13 03:04:07

by Sean Wang

[permalink] [raw]
Subject: [PATCH 07/47] wifi: mt76: mt7925: extend mt7925_mcu_add_bss_info for per-link BSS

From: Sean Wang <[email protected]>

Extend mt7925_mcu_add_bss_info with per-link BSS configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7925/main.c | 35 +++++++++++++------
.../net/wireless/mediatek/mt76/mt7925/mcu.c | 22 ++++++------
.../net/wireless/mediatek/mt76/mt7925/mcu.h | 2 +-
drivers/net/wireless/mediatek/mt76/mt792x.h | 10 ++++++
4 files changed, 46 insertions(+), 23 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index d11919688bae..7b9deb586b34 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -487,9 +487,12 @@ static int mt7925_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
struct mt792x_sta *msta = sta ? (struct mt792x_sta *)sta->drv_priv :
&mvif->sta;
struct mt76_wcid *wcid = &msta->deflink.wcid;
+ struct ieee80211_bss_conf *link_conf;
u8 *wcid_keyidx = &wcid->hw_key_idx;
int idx = key->keyidx, err = 0;

+ link_conf = mt792x_vif_to_bss_conf(vif, vif->bss_conf.link_id);
+
/* The hardware does not support per-STA RX GTK, fallback
* to software mode for these.
*/
@@ -528,7 +531,8 @@ static int mt7925_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
struct mt792x_phy *phy = mt792x_hw_phy(hw);

mvif->bss_conf.mt76.cipher = mt7925_mcu_get_cipher(key->cipher);
- mt7925_mcu_add_bss_info(phy, mvif->bss_conf.mt76.ctx, vif, sta, true);
+ mt7925_mcu_add_bss_info(phy, mvif->bss_conf.mt76.ctx, link_conf,
+ sta, true);
}

if (cmd == SET_KEY)
@@ -701,6 +705,7 @@ int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+ struct ieee80211_bss_conf *link_conf;
int ret, idx;

idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT792x_WTBL_STA - 1);
@@ -725,10 +730,12 @@ int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
mt7925_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

+ link_conf = mt792x_vif_to_bss_conf(vif, vif->bss_conf.link_id);
+
/* should update bss info before STA add */
if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
- mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx, vif, sta,
- false);
+ mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx,
+ link_conf, sta, false);

ret = mt7925_mcu_sta_update(dev, sta, vif, true,
MT76_STA_INFO_STATE_NONE);
@@ -747,12 +754,15 @@ void mt7925_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+ struct ieee80211_bss_conf *link_conf;

mt792x_mutex_acquire(dev);

+ link_conf = mt792x_vif_to_bss_conf(vif, vif->bss_conf.link_id);
+
if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
- mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx, vif, sta,
- true);
+ mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx,
+ link_conf, sta, true);

ewma_avg_signal_init(&msta->deflink.avg_ack_signal);

@@ -771,6 +781,7 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
{
struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
+ struct ieee80211_bss_conf *link_conf;

mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->deflink.wcid);
mt76_connac_pm_wake(&dev->mphy, &dev->pm);
@@ -779,14 +790,16 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
mt7925_mac_wtbl_update(dev, msta->deflink.wcid.idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

+ link_conf = mt792x_vif_to_bss_conf(vif, vif->bss_conf.link_id);
+
if (vif->type == NL80211_IFTYPE_STATION) {
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;

mvif->wep_sta = NULL;
ewma_rssi_init(&mvif->bss_conf.rssi);
if (!sta->tdls)
- mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx, vif, sta,
- false);
+ mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx,
+ link_conf, sta, false);
}

spin_lock_bh(&mdev->sta_poll_lock);
@@ -1244,8 +1257,8 @@ mt7925_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,

mt792x_mutex_acquire(dev);

- err = mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx, vif, NULL,
- true);
+ err = mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx,
+ link_conf, NULL, true);
if (err)
goto out;

@@ -1275,8 +1288,8 @@ mt7925_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
if (err)
goto out;

- mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx, vif, NULL,
- false);
+ mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx, link_conf,
+ NULL, false);

out:
mt792x_mutex_release(dev);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 1c262a024dc8..fb261ee525be 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -2315,11 +2315,11 @@ int mt7925_mcu_set_timing(struct mt792x_phy *phy,

int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
struct ieee80211_chanctx_conf *ctx,
- struct ieee80211_vif *vif,
+ struct ieee80211_bss_conf *link_conf,
struct ieee80211_sta *sta,
int enable)
{
- struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+ struct mt792x_vif *mvif = (struct mt792x_vif *)link_conf->vif->drv_priv;
struct mt792x_dev *dev = phy->dev;
struct sk_buff *skb;
int err;
@@ -2330,18 +2330,18 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
return PTR_ERR(skb);

/* bss_basic must be first */
- mt7925_mcu_bss_basic_tlv(skb, vif, sta, ctx, phy->mt76,
+ mt7925_mcu_bss_basic_tlv(skb, link_conf->vif, sta, ctx, phy->mt76,
mvif->sta.deflink.wcid.idx, enable);
- mt7925_mcu_bss_sec_tlv(skb, vif);
+ mt7925_mcu_bss_sec_tlv(skb, link_conf->vif);

- mt7925_mcu_bss_bmc_tlv(skb, phy, ctx, vif, sta);
- mt7925_mcu_bss_qos_tlv(skb, vif);
- mt7925_mcu_bss_mld_tlv(skb, vif, sta);
- mt7925_mcu_bss_ifs_tlv(skb, vif);
+ mt7925_mcu_bss_bmc_tlv(skb, phy, ctx, link_conf->vif, sta);
+ mt7925_mcu_bss_qos_tlv(skb, link_conf->vif);
+ mt7925_mcu_bss_mld_tlv(skb, link_conf->vif, sta);
+ mt7925_mcu_bss_ifs_tlv(skb, link_conf->vif);

- if (vif->bss_conf.he_support) {
- mt7925_mcu_bss_he_tlv(skb, vif, phy);
- mt7925_mcu_bss_color_tlv(skb, vif, enable);
+ if (link_conf->he_support) {
+ mt7925_mcu_bss_he_tlv(skb, link_conf->vif, phy);
+ mt7925_mcu_bss_color_tlv(skb, link_conf->vif, enable);
}

err = mt76_mcu_skb_send_msg(&dev->mt76, skb,
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h
index b499b1d0531a..c692996e057c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h
@@ -578,7 +578,7 @@ int mt7925_mcu_sched_scan_enable(struct mt76_phy *phy,
bool enable);
int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
struct ieee80211_chanctx_conf *ctx,
- struct ieee80211_vif *vif,
+ struct ieee80211_bss_conf *link_conf,
struct ieee80211_sta *sta,
int enable);
int mt7925_mcu_set_timing(struct mt792x_phy *phy,
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h
index 4a7526322c30..f675709f419a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x.h
+++ b/drivers/net/wireless/mediatek/mt76/mt792x.h
@@ -244,6 +244,16 @@ mt792x_link_conf_to_mconf(struct ieee80211_bss_conf *link_conf)
return mt792x_vif_to_link(mvif, link_conf->link_id);
}

+static inline struct ieee80211_bss_conf *
+mt792x_vif_to_bss_conf(struct ieee80211_vif *vif, unsigned int link_id)
+{
+ if (!ieee80211_vif_is_mld(vif) ||
+ link_id >= IEEE80211_LINK_UNSPECIFIED)
+ return &vif->bss_conf;
+
+ return link_conf_dereference_protected(vif, link_id);
+}
+
static inline struct mt792x_dev *
mt792x_hw_dev(struct ieee80211_hw *hw)
{
--
2.34.1


2024-06-13 03:04:15

by Sean Wang

[permalink] [raw]
Subject: [PATCH 21/47] wifi: mt76: mt7925: extend mt7925_mcu_uni_bss_ps for per-link BSS

From: Sean Wang <[email protected]>

Extend mt7925_mcu_uni_bss_ps with per-link BSS configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/main.c | 2 +-
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 11 ++++++-----
drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h | 3 ++-
3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index bba17e51a023..cd20b85109b9 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -1383,7 +1383,7 @@ static void mt7925_vif_cfg_changed(struct ieee80211_hw *hw,
}

if (changed & BSS_CHANGED_PS)
- mt7925_mcu_uni_bss_ps(dev, vif);
+ mt7925_mcu_uni_bss_ps(dev, &vif->bss_conf);

mt792x_mutex_release(dev);
}
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 8950df09a025..7624ec23e064 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1243,9 +1243,10 @@ int mt7925_mcu_set_eeprom(struct mt792x_dev *dev)
}
EXPORT_SYMBOL_GPL(mt7925_mcu_set_eeprom);

-int mt7925_mcu_uni_bss_ps(struct mt792x_dev *dev, struct ieee80211_vif *vif)
+int mt7925_mcu_uni_bss_ps(struct mt792x_dev *dev,
+ struct ieee80211_bss_conf *link_conf)
{
- struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+ struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(link_conf);
struct {
struct {
u8 bss_idx;
@@ -1264,16 +1265,16 @@ int mt7925_mcu_uni_bss_ps(struct mt792x_dev *dev, struct ieee80211_vif *vif)
} __packed ps;
} __packed ps_req = {
.hdr = {
- .bss_idx = mvif->bss_conf.mt76.idx,
+ .bss_idx = mconf->mt76.idx,
},
.ps = {
.tag = cpu_to_le16(UNI_BSS_INFO_PS),
.len = cpu_to_le16(sizeof(struct ps_tlv)),
- .ps_state = vif->cfg.ps ? 2 : 0,
+ .ps_state = link_conf->vif->cfg.ps ? 2 : 0,
},
};

- if (vif->type != NL80211_IFTYPE_STATION)
+ if (link_conf->vif->type != NL80211_IFTYPE_STATION)
return -EOPNOTSUPP;

return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(BSS_INFO_UPDATE),
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
index 8ab2bb01ba73..ef37951f69d5 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
@@ -242,7 +242,8 @@ int mt7925_mcu_uni_rx_ba(struct mt792x_dev *dev,
bool enable);
void mt7925_scan_work(struct work_struct *work);
void mt7925_roc_work(struct work_struct *work);
-int mt7925_mcu_uni_bss_ps(struct mt792x_dev *dev, struct ieee80211_vif *vif);
+int mt7925_mcu_uni_bss_ps(struct mt792x_dev *dev,
+ struct ieee80211_bss_conf *link_conf);
void mt7925_coredump_work(struct work_struct *work);
int mt7925_get_txpwr_info(struct mt792x_dev *dev, u8 band_idx,
struct mt7925_txpwr *txpwr);
--
2.34.1


2024-06-13 03:04:19

by Sean Wang

[permalink] [raw]
Subject: [PATCH 22/47] wifi: mt76: mt7925: add mt7925_mcu_bss_rlm_tlv to constitue the RLM TLV

From: Sean Wang <[email protected]>

add mt7925_mcu_bss_rlm_tlv to maintain consistency with the other TLVs that
constitute the command for creating the per-link BSS.

Co-developed-by: Ming Yen Hsieh <[email protected]>
Signed-off-by: Ming Yen Hsieh <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7925/mcu.c | 64 +++++++++++++++++--
.../net/wireless/mediatek/mt76/mt7925/mcu.h | 16 +++++
2 files changed, 74 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 7624ec23e064..96b7a9df17d8 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1921,6 +1921,59 @@ mt7925_mcu_uni_add_beacon_offload(struct mt792x_dev *dev,
&req, sizeof(req), true);
}

+static
+void mt7925_mcu_bss_rlm_tlv(struct sk_buff *skb, struct mt76_phy *phy,
+ struct ieee80211_chanctx_conf *ctx)
+{
+ struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &phy->chandef;
+ int freq1 = chandef->center_freq1, freq2 = chandef->center_freq2;
+ enum nl80211_band band = chandef->chan->band;
+ struct bss_rlm_tlv *req;
+ struct tlv *tlv;
+
+ tlv = mt76_connac_mcu_add_tlv(skb, UNI_BSS_INFO_RLM, sizeof(*req));
+ req = (struct bss_rlm_tlv *)tlv;
+ req->control_channel = chandef->chan->hw_value,
+ req->center_chan = ieee80211_frequency_to_channel(freq1),
+ req->center_chan2 = ieee80211_frequency_to_channel(freq2),
+ req->tx_streams = hweight8(phy->antenna_mask),
+ req->ht_op_info = 4, /* set HT 40M allowed */
+ req->rx_streams = hweight8(phy->antenna_mask),
+ req->band = band;
+
+ switch (chandef->width) {
+ case NL80211_CHAN_WIDTH_40:
+ req->bw = CMD_CBW_40MHZ;
+ break;
+ case NL80211_CHAN_WIDTH_80:
+ req->bw = CMD_CBW_80MHZ;
+ break;
+ case NL80211_CHAN_WIDTH_80P80:
+ req->bw = CMD_CBW_8080MHZ;
+ break;
+ case NL80211_CHAN_WIDTH_160:
+ req->bw = CMD_CBW_160MHZ;
+ break;
+ case NL80211_CHAN_WIDTH_5:
+ req->bw = CMD_CBW_5MHZ;
+ break;
+ case NL80211_CHAN_WIDTH_10:
+ req->bw = CMD_CBW_10MHZ;
+ break;
+ case NL80211_CHAN_WIDTH_20_NOHT:
+ case NL80211_CHAN_WIDTH_20:
+ default:
+ req->bw = CMD_CBW_20MHZ;
+ req->ht_op_info = 0;
+ break;
+ }
+
+ if (req->control_channel < req->center_chan)
+ req->sco = 1; /* SCA */
+ else if (req->control_channel > req->center_chan)
+ req->sco = 3; /* SCB */
+}
+
int mt7925_mcu_set_chctx(struct mt76_phy *phy, struct mt76_vif *mvif,
struct ieee80211_chanctx_conf *ctx)
{
@@ -2326,9 +2379,10 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
int enable)
{
struct mt792x_vif *mvif = (struct mt792x_vif *)link_conf->vif->drv_priv;
+ struct mt792x_bss_conf *mconf = mt792x_vif_to_link(mvif,
+ link_conf->link_id);
struct mt792x_dev *dev = phy->dev;
struct sk_buff *skb;
- int err;

skb = __mt7925_mcu_alloc_bss_req(&dev->mt76, &mvif->bss_conf.mt76,
MT7925_BSS_UPDATE_MAX_SIZE);
@@ -2350,12 +2404,10 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
mt7925_mcu_bss_color_tlv(skb, link_conf, enable);
}

- err = mt76_mcu_skb_send_msg(&dev->mt76, skb,
- MCU_UNI_CMD(BSS_INFO_UPDATE), true);
- if (err < 0)
- return err;
+ mt7925_mcu_bss_rlm_tlv(skb, phy->mt76, mconf->mt76.ctx);

- return mt7925_mcu_set_chctx(phy->mt76, &mvif->bss_conf.mt76, ctx);
+ return mt76_mcu_skb_send_msg(&dev->mt76, skb,
+ MCU_UNI_CMD(BSS_INFO_UPDATE), true);
}

int mt7925_mcu_set_dbdc(struct mt76_phy *phy)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h
index d3584743c266..c5197577cdc8 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h
@@ -456,6 +456,21 @@ struct bss_ifs_time_tlv {
__le16 eifs_cck_time;
} __packed;

+struct bss_rlm_tlv {
+ __le16 tag;
+ __le16 len;
+ u8 control_channel;
+ u8 center_chan;
+ u8 center_chan2;
+ u8 bw;
+ u8 tx_streams;
+ u8 rx_streams;
+ u8 ht_op_info;
+ u8 sco;
+ u8 band;
+ u8 pad[3];
+} __packed;
+
#define MT7925_STA_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \
sizeof(struct sta_rec_basic) + \
sizeof(struct sta_rec_bf) + \
@@ -484,6 +499,7 @@ struct bss_ifs_time_tlv {
sizeof(struct bss_info_uni_he) + \
sizeof(struct bss_info_uni_bss_color) + \
sizeof(struct bss_ifs_time_tlv) + \
+ sizeof(struct bss_rlm_tlv) + \
sizeof(struct tlv))

#define MT_CONNAC3_SKU_POWER_LIMIT 449
--
2.34.1


2024-06-13 03:04:30

by Sean Wang

[permalink] [raw]
Subject: [PATCH 25/47] wifi: mt76: mt7925: extend mt7925_mcu_sta_state_v2_tlv for per-link STA

From: Sean Wang <[email protected]>

Extend mt7925_mcu_sta_state_v2_tlv with the per-link STA configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Ming Yen Hsieh <[email protected]>
Signed-off-by: Ming Yen Hsieh <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 9b69b4b178de..45437603763e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1540,7 +1540,7 @@ mt7925_mcu_sta_phy_tlv(struct sk_buff *skb,

static void
mt7925_mcu_sta_state_v2_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
- struct ieee80211_sta *sta,
+ struct ieee80211_link_sta *link_sta,
struct ieee80211_vif *vif,
u8 rcpi, u8 sta_state)
{
@@ -1560,9 +1560,9 @@ mt7925_mcu_sta_state_v2_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
state = (struct sta_rec_state_v2 *)tlv;
state->state = sta_state;

- if (sta->deflink.vht_cap.vht_supported) {
- state->vht_opmode = sta->deflink.bandwidth;
- state->vht_opmode |= sta->deflink.rx_nss <<
+ if (link_sta->vht_cap.vht_supported) {
+ state->vht_opmode = link_sta->bandwidth;
+ state->vht_opmode |= link_sta->rx_nss <<
IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT;
}
}
@@ -1643,7 +1643,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,
mt7925_mcu_sta_eht_tlv(skb, info->link_sta->sta);
mt7925_mcu_sta_rate_ctrl_tlv(skb, info->vif,
info->link_sta->sta);
- mt7925_mcu_sta_state_v2_tlv(phy, skb, info->link_sta->sta,
+ mt7925_mcu_sta_state_v2_tlv(phy, skb, info->link_sta,
info->vif, info->rcpi,
info->state);
mt7925_mcu_sta_mld_tlv(skb, info->vif, info->link_sta->sta);
--
2.34.1


2024-06-13 03:04:34

by Sean Wang

[permalink] [raw]
Subject: [PATCH 23/47] wifi: mt76: mt7925: mt7925_mcu_set_chctx rely on mt7925_mcu_bss_rlm_tlv

From: Sean Wang <[email protected]>

make mt7925_mcu_set_chctx rely on mt7925_mcu_bss_rlm_tlv to get rid of
the redundant code.

Signed-off-by: Sean Wang <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7925/mcu.c | 95 ++++---------------
1 file changed, 16 insertions(+), 79 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 96b7a9df17d8..9d56013b2f55 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1974,85 +1974,6 @@ void mt7925_mcu_bss_rlm_tlv(struct sk_buff *skb, struct mt76_phy *phy,
req->sco = 3; /* SCB */
}

-int mt7925_mcu_set_chctx(struct mt76_phy *phy, struct mt76_vif *mvif,
- struct ieee80211_chanctx_conf *ctx)
-{
- struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &phy->chandef;
- int freq1 = chandef->center_freq1, freq2 = chandef->center_freq2;
- enum nl80211_band band = chandef->chan->band;
- struct mt76_dev *mdev = phy->dev;
- struct {
- struct {
- u8 bss_idx;
- u8 pad[3];
- } __packed hdr;
- struct rlm_tlv {
- __le16 tag;
- __le16 len;
- u8 control_channel;
- u8 center_chan;
- u8 center_chan2;
- u8 bw;
- u8 tx_streams;
- u8 rx_streams;
- u8 ht_op_info;
- u8 sco;
- u8 band;
- u8 pad[3];
- } __packed rlm;
- } __packed rlm_req = {
- .hdr = {
- .bss_idx = mvif->idx,
- },
- .rlm = {
- .tag = cpu_to_le16(UNI_BSS_INFO_RLM),
- .len = cpu_to_le16(sizeof(struct rlm_tlv)),
- .control_channel = chandef->chan->hw_value,
- .center_chan = ieee80211_frequency_to_channel(freq1),
- .center_chan2 = ieee80211_frequency_to_channel(freq2),
- .tx_streams = hweight8(phy->antenna_mask),
- .ht_op_info = 4, /* set HT 40M allowed */
- .rx_streams = hweight8(phy->antenna_mask),
- .band = band,
- },
- };
-
- switch (chandef->width) {
- case NL80211_CHAN_WIDTH_40:
- rlm_req.rlm.bw = CMD_CBW_40MHZ;
- break;
- case NL80211_CHAN_WIDTH_80:
- rlm_req.rlm.bw = CMD_CBW_80MHZ;
- break;
- case NL80211_CHAN_WIDTH_80P80:
- rlm_req.rlm.bw = CMD_CBW_8080MHZ;
- break;
- case NL80211_CHAN_WIDTH_160:
- rlm_req.rlm.bw = CMD_CBW_160MHZ;
- break;
- case NL80211_CHAN_WIDTH_5:
- rlm_req.rlm.bw = CMD_CBW_5MHZ;
- break;
- case NL80211_CHAN_WIDTH_10:
- rlm_req.rlm.bw = CMD_CBW_10MHZ;
- break;
- case NL80211_CHAN_WIDTH_20_NOHT:
- case NL80211_CHAN_WIDTH_20:
- default:
- rlm_req.rlm.bw = CMD_CBW_20MHZ;
- rlm_req.rlm.ht_op_info = 0;
- break;
- }
-
- if (rlm_req.rlm.control_channel < rlm_req.rlm.center_chan)
- rlm_req.rlm.sco = 1; /* SCA */
- else if (rlm_req.rlm.control_channel > rlm_req.rlm.center_chan)
- rlm_req.rlm.sco = 3; /* SCB */
-
- return mt76_mcu_send_msg(mdev, MCU_UNI_CMD(BSS_INFO_UPDATE), &rlm_req,
- sizeof(rlm_req), true);
-}
-
static struct sk_buff *
__mt7925_mcu_alloc_bss_req(struct mt76_dev *dev, struct mt76_vif *mvif, int len)
{
@@ -2070,6 +1991,22 @@ __mt7925_mcu_alloc_bss_req(struct mt76_dev *dev, struct mt76_vif *mvif, int len)
return skb;
}

+int mt7925_mcu_set_chctx(struct mt76_phy *phy, struct mt76_vif *mvif,
+ struct ieee80211_chanctx_conf *ctx)
+{
+ struct sk_buff *skb;
+
+ skb = __mt7925_mcu_alloc_bss_req(phy->dev, mvif,
+ MT7925_BSS_UPDATE_MAX_SIZE);
+ if (IS_ERR(skb))
+ return PTR_ERR(skb);
+
+ mt7925_mcu_bss_rlm_tlv(skb, phy, ctx);
+
+ return mt76_mcu_skb_send_msg(phy->dev, skb,
+ MCU_UNI_CMD(BSS_INFO_UPDATE), true);
+}
+
static u8
mt7925_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif,
enum nl80211_band band, struct ieee80211_sta *sta)
--
2.34.1


2024-06-13 03:04:39

by Sean Wang

[permalink] [raw]
Subject: [PATCH 24/47] wifi: mt76: mt7925: extend mt7925_mcu_sta_update for per-link STA

From: Sean Wang <[email protected]>

Extend mt7925_mcu_sta_update with the per-link STA configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Signed-off-by: Sean Wang <[email protected]>
---
.../wireless/mediatek/mt76/mt76_connac_mcu.h | 5 +-
.../net/wireless/mediatek/mt76/mt7925/main.c | 6 +--
.../net/wireless/mediatek/mt76/mt7925/mcu.c | 53 +++++++++++--------
.../wireless/mediatek/mt76/mt7925/mt7925.h | 3 +-
drivers/net/wireless/mediatek/mt76/mt792x.h | 16 ++++++
5 files changed, 57 insertions(+), 26 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
index e6e8824c828e..2a858b1ca82e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
@@ -1726,7 +1726,10 @@ enum mt76_sta_info_state {
};

struct mt76_sta_cmd_info {
- struct ieee80211_sta *sta;
+ union {
+ struct ieee80211_sta *sta;
+ struct ieee80211_link_sta *link_sta;
+ };
struct mt76_wcid *wcid;

struct ieee80211_vif *vif;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index cd20b85109b9..f3a32fe9a754 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -740,7 +740,7 @@ int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx,
link_conf, sta, false);

- ret = mt7925_mcu_sta_update(dev, sta, vif, true,
+ ret = mt7925_mcu_sta_update(dev, &sta->deflink, vif, true,
MT76_STA_INFO_STATE_NONE);
if (ret)
return ret;
@@ -773,7 +773,7 @@ void mt7925_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
memset(msta->deflink.airtime_ac, 0, sizeof(msta->deflink.airtime_ac));

- mt7925_mcu_sta_update(dev, sta, vif, true, MT76_STA_INFO_STATE_ASSOC);
+ mt7925_mcu_sta_update(dev, &sta->deflink, vif, true, MT76_STA_INFO_STATE_ASSOC);

mt792x_mutex_release(dev);
}
@@ -789,7 +789,7 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->deflink.wcid);
mt76_connac_pm_wake(&dev->mphy, &dev->pm);

- mt7925_mcu_sta_update(dev, sta, vif, false, MT76_STA_INFO_STATE_NONE);
+ mt7925_mcu_sta_update(dev, &sta->deflink, vif, false, MT76_STA_INFO_STATE_NONE);
mt7925_mac_wtbl_update(dev, msta->deflink.wcid.idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 9d56013b2f55..9b69b4b178de 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1628,39 +1628,46 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,
if (IS_ERR(skb))
return PTR_ERR(skb);

- if (info->sta || !info->offload_fw)
- mt76_connac_mcu_sta_basic_tlv(dev, skb, info->vif, info->sta,
+ if (info->link_sta || !info->offload_fw)
+ mt76_connac_mcu_sta_basic_tlv(dev, skb, info->vif,
+ info->link_sta->sta,
info->enable, info->newly);
- if (info->sta && info->enable) {
- mt7925_mcu_sta_phy_tlv(skb, info->vif, info->sta);
- mt7925_mcu_sta_ht_tlv(skb, info->sta);
- mt7925_mcu_sta_vht_tlv(skb, info->sta);
- mt76_connac_mcu_sta_uapsd(skb, info->vif, info->sta);
- mt7925_mcu_sta_amsdu_tlv(skb, info->vif, info->sta);
- mt7925_mcu_sta_he_tlv(skb, info->sta);
- mt7925_mcu_sta_he_6g_tlv(skb, info->sta);
- mt7925_mcu_sta_eht_tlv(skb, info->sta);
- mt7925_mcu_sta_rate_ctrl_tlv(skb, info->vif, info->sta);
- mt7925_mcu_sta_state_v2_tlv(phy, skb, info->sta,
+ if (info->link_sta && info->enable) {
+ mt7925_mcu_sta_phy_tlv(skb, info->vif, info->link_sta->sta);
+ mt7925_mcu_sta_ht_tlv(skb, info->link_sta->sta);
+ mt7925_mcu_sta_vht_tlv(skb, info->link_sta->sta);
+ mt76_connac_mcu_sta_uapsd(skb, info->vif, info->link_sta->sta);
+ mt7925_mcu_sta_amsdu_tlv(skb, info->vif, info->link_sta->sta);
+ mt7925_mcu_sta_he_tlv(skb, info->link_sta->sta);
+ mt7925_mcu_sta_he_6g_tlv(skb, info->link_sta->sta);
+ mt7925_mcu_sta_eht_tlv(skb, info->link_sta->sta);
+ mt7925_mcu_sta_rate_ctrl_tlv(skb, info->vif,
+ info->link_sta->sta);
+ mt7925_mcu_sta_state_v2_tlv(phy, skb, info->link_sta->sta,
info->vif, info->rcpi,
info->state);
- mt7925_mcu_sta_mld_tlv(skb, info->vif, info->sta);
+ mt7925_mcu_sta_mld_tlv(skb, info->vif, info->link_sta->sta);
}

- if (info->enable)
- mt7925_mcu_sta_hdr_trans_tlv(skb, info->vif, info->sta);
+ if (info->enable) {
+ struct ieee80211_sta *sta = info->link_sta ?
+ info->link_sta->sta : NULL;
+
+ mt7925_mcu_sta_hdr_trans_tlv(skb, info->vif, sta);
+ }

return mt76_mcu_skb_send_msg(dev, skb, info->cmd, true);
}

-int mt7925_mcu_sta_update(struct mt792x_dev *dev, struct ieee80211_sta *sta,
+int mt7925_mcu_sta_update(struct mt792x_dev *dev,
+ struct ieee80211_link_sta *link_sta,
struct ieee80211_vif *vif, bool enable,
enum mt76_sta_info_state state)
{
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
int rssi = -ewma_rssi_read(&mvif->bss_conf.rssi);
struct mt76_sta_cmd_info info = {
- .sta = sta,
+ .link_sta = link_sta,
.vif = vif,
.enable = enable,
.cmd = MCU_UNI_CMD(STA_REC_UPDATE),
@@ -1669,10 +1676,14 @@ int mt7925_mcu_sta_update(struct mt792x_dev *dev, struct ieee80211_sta *sta,
.rcpi = to_rcpi(rssi),
};
struct mt792x_sta *msta;
+ struct mt792x_link_sta *mlink;

- msta = sta ? (struct mt792x_sta *)sta->drv_priv : NULL;
- info.wcid = msta ? &msta->deflink.wcid : &mvif->sta.deflink.wcid;
- info.newly = msta ? state != MT76_STA_INFO_STATE_ASSOC : true;
+ if (link_sta) {
+ msta = (struct mt792x_sta *)link_sta->sta->drv_priv;
+ mlink = mt792x_sta_to_link(msta, link_sta->link_id);
+ }
+ info.wcid = link_sta ? &mlink->wcid : &mvif->sta.deflink.wcid;
+ info.newly = link_sta ? state != MT76_STA_INFO_STATE_ASSOC : true;

return mt7925_mcu_sta_cmd(&dev->mphy, &info);
}
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
index ef37951f69d5..8ec5a3a20202 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
@@ -195,7 +195,8 @@ int mt7925_run_firmware(struct mt792x_dev *dev);
int mt7925_mcu_set_bss_pm(struct mt792x_dev *dev,
struct ieee80211_bss_conf *link_conf,
bool enable);
-int mt7925_mcu_sta_update(struct mt792x_dev *dev, struct ieee80211_sta *sta,
+int mt7925_mcu_sta_update(struct mt792x_dev *dev,
+ struct ieee80211_link_sta *link_sta,
struct ieee80211_vif *vif, bool enable,
enum mt76_sta_info_state state);
int mt7925_mcu_set_chan_info(struct mt792x_phy *phy, u16 tag);
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h
index 9452a3592950..185d56a1db11 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x.h
+++ b/drivers/net/wireless/mediatek/mt76/mt792x.h
@@ -94,6 +94,7 @@ struct mt792x_link_sta {

struct mt792x_sta {
struct mt792x_link_sta deflink; /* must be first */
+ struct mt792x_link_sta __rcu *link[IEEE80211_MLD_MAX_NUM_LINKS];

struct mt792x_vif *vif;
};
@@ -236,6 +237,21 @@ mt792x_vif_to_link(struct mt792x_vif *mvif, u8 link_id)
lockdep_is_held(&mvif->phy->dev->mt76.mutex));
}

+static inline struct mt792x_link_sta *
+mt792x_sta_to_link(struct mt792x_sta *msta, u8 link_id)
+{
+ struct ieee80211_vif *vif;
+
+ vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv);
+
+ if (!ieee80211_vif_is_mld(vif) ||
+ link_id >= IEEE80211_LINK_UNSPECIFIED)
+ return &msta->deflink;
+
+ return rcu_dereference_protected(msta->link[link_id],
+ lockdep_is_held(&msta->vif->phy->dev->mt76.mutex));
+}
+
static inline struct mt792x_bss_conf *
mt792x_link_conf_to_mconf(struct ieee80211_bss_conf *link_conf)
{
--
2.34.1


2024-06-13 03:04:43

by Sean Wang

[permalink] [raw]
Subject: [PATCH 28/47] wifi: mt76: mt7925: extend mt7925_mcu_sta_he_6g_tlv for per-link STA

From: Sean Wang <[email protected]>

Extend mt7925_mcu_sta_he_6g_tlv with the per-link STA configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Ming Yen Hsieh <[email protected]>
Signed-off-by: Ming Yen Hsieh <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 0c9cebd3ee71..e1dc8452468c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1389,18 +1389,19 @@ mt7925_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
}

static void
-mt7925_mcu_sta_he_6g_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
+mt7925_mcu_sta_he_6g_tlv(struct sk_buff *skb,
+ struct ieee80211_link_sta *link_sta)
{
struct sta_rec_he_6g_capa *he_6g;
struct tlv *tlv;

- if (!sta->deflink.he_6ghz_capa.capa)
+ if (!link_sta->he_6ghz_capa.capa)
return;

tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_HE_6G, sizeof(*he_6g));

he_6g = (struct sta_rec_he_6g_capa *)tlv;
- he_6g->capa = sta->deflink.he_6ghz_capa.capa;
+ he_6g->capa = link_sta->he_6ghz_capa.capa;
}

static void
@@ -1640,7 +1641,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,
mt76_connac_mcu_sta_uapsd(skb, info->vif, info->link_sta->sta);
mt7925_mcu_sta_amsdu_tlv(skb, info->vif, info->link_sta->sta);
mt7925_mcu_sta_he_tlv(skb, info->link_sta->sta);
- mt7925_mcu_sta_he_6g_tlv(skb, info->link_sta->sta);
+ mt7925_mcu_sta_he_6g_tlv(skb, info->link_sta);
mt7925_mcu_sta_eht_tlv(skb, info->link_sta);
mt7925_mcu_sta_rate_ctrl_tlv(skb, info->vif,
info->link_sta);
--
2.34.1


2024-06-13 03:04:49

by Sean Wang

[permalink] [raw]
Subject: [PATCH 13/47] wifi: mt76: mt7925: extend mt7925_mcu_bss_mld_tlv for per-link BSS

From: Sean Wang <[email protected]>

Extend mt7925_mcu_bss_mld_tlv with per-link BSS configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index d6a590061e36..93ce018a0801 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -2206,20 +2206,20 @@ mt7925_mcu_bss_bmc_tlv(struct sk_buff *skb, struct mt792x_phy *phy,

static void
mt7925_mcu_bss_mld_tlv(struct sk_buff *skb,
- struct ieee80211_vif *vif,
+ struct ieee80211_bss_conf *link_conf,
struct ieee80211_sta *sta)
{
- struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
- bool is_mld = ieee80211_vif_is_mld(vif);
+ struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(link_conf);
+ bool is_mld = ieee80211_vif_is_mld(link_conf->vif);
struct bss_mld_tlv *mld;
struct tlv *tlv;

tlv = mt76_connac_mcu_add_tlv(skb, UNI_BSS_INFO_MLD, sizeof(*mld));
mld = (struct bss_mld_tlv *)tlv;

- mld->link_id = sta ? (is_mld ? vif->bss_conf.link_id : 0) : 0xff;
- mld->group_mld_id = is_mld ? mvif->bss_conf.mt76.idx : 0xff;
- mld->own_mld_id = mvif->bss_conf.mt76.idx + 32;
+ mld->link_id = sta ? (is_mld ? link_conf->link_id : 0) : 0xff;
+ mld->group_mld_id = is_mld ? mconf->mt76.idx : 0xff;
+ mld->own_mld_id = mconf->mt76.idx + 32;
mld->remap_idx = 0xff;

if (sta)
@@ -2337,7 +2337,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,

mt7925_mcu_bss_bmc_tlv(skb, phy, ctx, link_conf->vif, sta);
mt7925_mcu_bss_qos_tlv(skb, link_conf);
- mt7925_mcu_bss_mld_tlv(skb, link_conf->vif, sta);
+ mt7925_mcu_bss_mld_tlv(skb, link_conf, sta);
mt7925_mcu_bss_ifs_tlv(skb, link_conf);

if (link_conf->he_support) {
--
2.34.1


2024-06-13 03:04:49

by Sean Wang

[permalink] [raw]
Subject: [PATCH 26/47] wifi: mt76: mt7925: extend mt7925_mcu_sta_rate_ctrl_tlv with per-link STA

From: Sean Wang <[email protected]>

Extend mt7925_mcu_sta_rate_ctrl_tlv with the per-link STA configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Ming Yen Hsieh <[email protected]>
Signed-off-by: Ming Yen Hsieh <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 45437603763e..266010c0e00a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1569,7 +1569,8 @@ mt7925_mcu_sta_state_v2_tlv(struct mt76_phy *mphy, struct sk_buff *skb,

static void
mt7925_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb,
- struct ieee80211_vif *vif, struct ieee80211_sta *sta)
+ struct ieee80211_vif *vif,
+ struct ieee80211_link_sta *link_sta)
{
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct cfg80211_chan_def *chandef = &mvif->bss_conf.mt76.ctx->def;
@@ -1581,7 +1582,7 @@ mt7925_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb,
tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_RA, sizeof(*ra_info));
ra_info = (struct sta_rec_ra_info *)tlv;

- supp_rates = sta->deflink.supp_rates[band];
+ supp_rates = link_sta->supp_rates[band];
if (band == NL80211_BAND_2GHZ)
supp_rates = FIELD_PREP(RA_LEGACY_OFDM, supp_rates >> 4) |
FIELD_PREP(RA_LEGACY_CCK, supp_rates & 0xf);
@@ -1590,9 +1591,9 @@ mt7925_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb,

ra_info->legacy = cpu_to_le16(supp_rates);

- if (sta->deflink.ht_cap.ht_supported)
+ if (link_sta->ht_cap.ht_supported)
memcpy(ra_info->rx_mcs_bitmask,
- sta->deflink.ht_cap.mcs.rx_mask,
+ link_sta->ht_cap.mcs.rx_mask,
HT_MCS_MASK_NUM);
}

@@ -1642,7 +1643,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,
mt7925_mcu_sta_he_6g_tlv(skb, info->link_sta->sta);
mt7925_mcu_sta_eht_tlv(skb, info->link_sta->sta);
mt7925_mcu_sta_rate_ctrl_tlv(skb, info->vif,
- info->link_sta->sta);
+ info->link_sta);
mt7925_mcu_sta_state_v2_tlv(phy, skb, info->link_sta,
info->vif, info->rcpi,
info->state);
--
2.34.1


2024-06-13 03:04:57

by Sean Wang

[permalink] [raw]
Subject: [PATCH 31/47] wifi: mt76: mt7925: extend mt7925_mcu_sta_vht_tlv for per-link STA

From: Sean Wang <[email protected]>

Extend mt7925_mcu_sta_vht_tlv with the per-link STA configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Ming Yen Hsieh <[email protected]>
Signed-off-by: Ming Yen Hsieh <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 57b89eca4e21..1b66dd26bd1e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1448,21 +1448,21 @@ mt7925_mcu_sta_ht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
}

static void
-mt7925_mcu_sta_vht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
+mt7925_mcu_sta_vht_tlv(struct sk_buff *skb, struct ieee80211_link_sta *link_sta)
{
struct sta_rec_vht *vht;
struct tlv *tlv;

/* For 6G band, this tlv is necessary to let hw work normally */
- if (!sta->deflink.he_6ghz_capa.capa && !sta->deflink.vht_cap.vht_supported)
+ if (!link_sta->he_6ghz_capa.capa && !link_sta->vht_cap.vht_supported)
return;

tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_VHT, sizeof(*vht));

vht = (struct sta_rec_vht *)tlv;
- vht->vht_cap = cpu_to_le32(sta->deflink.vht_cap.cap);
- vht->vht_rx_mcs_map = sta->deflink.vht_cap.vht_mcs.rx_mcs_map;
- vht->vht_tx_mcs_map = sta->deflink.vht_cap.vht_mcs.tx_mcs_map;
+ vht->vht_cap = cpu_to_le32(link_sta->vht_cap.cap);
+ vht->vht_rx_mcs_map = link_sta->vht_cap.vht_mcs.rx_mcs_map;
+ vht->vht_tx_mcs_map = link_sta->vht_cap.vht_mcs.tx_mcs_map;
}

static void
@@ -1641,7 +1641,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,
if (info->link_sta && info->enable) {
mt7925_mcu_sta_phy_tlv(skb, info->vif, info->link_sta->sta);
mt7925_mcu_sta_ht_tlv(skb, info->link_sta->sta);
- mt7925_mcu_sta_vht_tlv(skb, info->link_sta->sta);
+ mt7925_mcu_sta_vht_tlv(skb, info->link_sta);
mt76_connac_mcu_sta_uapsd(skb, info->vif, info->link_sta->sta);
mt7925_mcu_sta_amsdu_tlv(skb, info->vif, info->link_sta);
mt7925_mcu_sta_he_tlv(skb, info->link_sta);
--
2.34.1


2024-06-13 03:05:05

by Sean Wang

[permalink] [raw]
Subject: [PATCH 15/47] wifi: mt76: mt7925: remove unused parameters in mt7925_mcu_bss_bmc_tlv

From: Sean Wang <[email protected]>

remove unused parameters in mt7925_mcu_bss_bmc_tlv

Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 48b157f42db9..797d4c936fec 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -2179,8 +2179,7 @@ mt7925_mcu_bss_sec_tlv(struct sk_buff *skb, struct ieee80211_vif *vif)
static void
mt7925_mcu_bss_bmc_tlv(struct sk_buff *skb, struct mt792x_phy *phy,
struct ieee80211_chanctx_conf *ctx,
- struct ieee80211_bss_conf *link_conf,
- struct ieee80211_sta *sta)
+ struct ieee80211_bss_conf *link_conf)
{
struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &phy->mt76->chandef;
struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(link_conf);
@@ -2336,7 +2335,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
mvif->sta.deflink.wcid.idx, enable);
mt7925_mcu_bss_sec_tlv(skb, link_conf->vif);

- mt7925_mcu_bss_bmc_tlv(skb, phy, ctx, link_conf, sta);
+ mt7925_mcu_bss_bmc_tlv(skb, phy, ctx, link_conf);
mt7925_mcu_bss_qos_tlv(skb, link_conf);
mt7925_mcu_bss_mld_tlv(skb, link_conf, sta);
mt7925_mcu_bss_ifs_tlv(skb, link_conf);
--
2.34.1


2024-06-13 03:05:07

by Sean Wang

[permalink] [raw]
Subject: [PATCH 34/47] wifi: mt76: mt7925: extend mt7925_get_phy_mode_ext for per-link STA

From: Sean Wang <[email protected]>

Extend mt7925_get_phy_mode_ext with the per-link STA configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Ming Yen Hsieh <[email protected]>
Signed-off-by: Ming Yen Hsieh <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index a0fd02dd9551..32ea71128280 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -2035,16 +2035,17 @@ int mt7925_mcu_set_chctx(struct mt76_phy *phy, struct mt76_vif *mvif,

static u8
mt7925_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif,
- enum nl80211_band band, struct ieee80211_sta *sta)
+ enum nl80211_band band,
+ struct ieee80211_link_sta *link_sta)
{
struct ieee80211_he_6ghz_capa *he_6ghz_capa;
const struct ieee80211_sta_eht_cap *eht_cap;
__le16 capa = 0;
u8 mode = 0;

- if (sta) {
- he_6ghz_capa = &sta->deflink.he_6ghz_capa;
- eht_cap = &sta->deflink.eht_cap;
+ if (link_sta) {
+ he_6ghz_capa = &link_sta->he_6ghz_capa;
+ eht_cap = &link_sta->eht_cap;
} else {
struct ieee80211_supported_band *sband;

@@ -2104,7 +2105,8 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb,
mconf->mt76.omac_idx;
basic_req->hw_bss_idx = idx;

- basic_req->phymode_ext = mt7925_get_phy_mode_ext(phy, vif, band, sta);
+ basic_req->phymode_ext = mt7925_get_phy_mode_ext(phy, vif, band,
+ &sta->deflink);

if (band == NL80211_BAND_2GHZ)
basic_req->nonht_basic_phy = cpu_to_le16(PHY_TYPE_ERP_INDEX);
--
2.34.1


2024-06-13 03:05:15

by Sean Wang

[permalink] [raw]
Subject: [PATCH 36/47] wifi: mt76: mt792x: extend mt76_connac_get_phy_mode_v2 for per-link STA

From: Sean Wang <[email protected]>

Extend mt76_connac_get_phy_mode_v2 with the per-link STA configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Signed-off-by: Sean Wang <[email protected]>
---
.../net/wireless/mediatek/mt76/mt76_connac_mcu.c | 16 +++++++++-------
.../net/wireless/mediatek/mt76/mt76_connac_mcu.h | 3 ++-
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 2 +-
3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
index f7ba3afb3ccf..294f79ab7ca6 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
@@ -786,7 +786,8 @@ EXPORT_SYMBOL_GPL(mt76_connac_mcu_sta_he_tlv_v2);

u8
mt76_connac_get_phy_mode_v2(struct mt76_phy *mphy, struct ieee80211_vif *vif,
- enum nl80211_band band, struct ieee80211_sta *sta)
+ enum nl80211_band band,
+ struct ieee80211_link_sta *link_sta)
{
struct ieee80211_sta_ht_cap *ht_cap;
struct ieee80211_sta_vht_cap *vht_cap;
@@ -794,11 +795,11 @@ mt76_connac_get_phy_mode_v2(struct mt76_phy *mphy, struct ieee80211_vif *vif,
const struct ieee80211_sta_eht_cap *eht_cap;
u8 mode = 0;

- if (sta) {
- ht_cap = &sta->deflink.ht_cap;
- vht_cap = &sta->deflink.vht_cap;
- he_cap = &sta->deflink.he_cap;
- eht_cap = &sta->deflink.eht_cap;
+ if (link_sta) {
+ ht_cap = &link_sta->ht_cap;
+ vht_cap = &link_sta->vht_cap;
+ he_cap = &link_sta->he_cap;
+ eht_cap = &link_sta->eht_cap;
} else {
struct ieee80211_supported_band *sband;

@@ -904,7 +905,8 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,

tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_PHY, sizeof(*phy));
phy = (struct sta_rec_phy *)tlv;
- phy->phy_type = mt76_connac_get_phy_mode_v2(mphy, vif, band, sta);
+ phy->phy_type = mt76_connac_get_phy_mode_v2(mphy, vif, band,
+ &sta->deflink);
phy->basic_rate = cpu_to_le16((u16)vif->bss_conf.basic_rates);
phy->rcpi = rcpi;
phy->ampdu = FIELD_PREP(IEEE80211_HT_AMPDU_PARM_FACTOR,
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
index 5b40d51ee728..2c939468d141 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
@@ -1894,7 +1894,8 @@ int mt76_connac_mcu_sta_update_hdr_trans(struct mt76_dev *dev,
struct mt76_wcid *wcid, int cmd);
void mt76_connac_mcu_sta_he_tlv_v2(struct sk_buff *skb, struct ieee80211_sta *sta);
u8 mt76_connac_get_phy_mode_v2(struct mt76_phy *mphy, struct ieee80211_vif *vif,
- enum nl80211_band band, struct ieee80211_sta *sta);
+ enum nl80211_band band,
+ struct ieee80211_link_sta *link_sta);
int mt76_connac_mcu_wtbl_update_hdr_trans(struct mt76_dev *dev,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 3cda538307b5..321a164a6e14 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1526,7 +1526,7 @@ mt7925_mcu_sta_phy_tlv(struct sk_buff *skb,
phy = (struct sta_rec_phy *)tlv;
phy->phy_type = mt76_connac_get_phy_mode_v2(mvif->phy->mt76, vif,
chandef->chan->band,
- link_sta->sta);
+ link_sta);
phy->basic_rate = cpu_to_le16((u16)link_conf->basic_rates);
if (link_sta->ht_cap.ht_supported) {
af = link_sta->ht_cap.ampdu_factor;
--
2.34.1


2024-06-13 03:05:19

by Sean Wang

[permalink] [raw]
Subject: [PATCH 37/47] wifi: mt76: mt762x: extend mt76_connac_mcu_sta_basic_tlv for per-link STA

From: Sean Wang <[email protected]>

Extend mt76_connac_mcu_sta_basic_tlv with the per-link STA configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Ming Yen Hsieh <[email protected]>
Signed-off-by: Ming Yen Hsieh <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 4 ++--
.../wireless/mediatek/mt76/mt76_connac_mcu.c | 17 +++++++++--------
.../wireless/mediatek/mt76/mt76_connac_mcu.h | 4 ++--
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 2 +-
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 2 +-
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 2 +-
6 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
index 792ae41f7c69..25670eeaecb4 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
@@ -861,8 +861,8 @@ mt7615_mcu_wtbl_sta_add(struct mt7615_phy *phy, struct ieee80211_vif *vif,
else
mvif->sta_added = true;
}
- mt76_connac_mcu_sta_basic_tlv(&dev->mt76, sskb, vif, sta, enable,
- new_entry);
+ mt76_connac_mcu_sta_basic_tlv(&dev->mt76, sskb, vif, &sta->deflink,
+ enable, new_entry);
if (enable && sta)
mt76_connac_mcu_sta_tlv(phy->mt76, sskb, sta, vif, 0,
MT76_STA_INFO_STATE_ASSOC);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
index 294f79ab7ca6..b8ad080ad2c3 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
@@ -370,7 +370,7 @@ EXPORT_SYMBOL_GPL(mt76_connac_mcu_bss_omac_tlv);

void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
struct ieee80211_vif *vif,
- struct ieee80211_sta *sta,
+ struct ieee80211_link_sta *link_sta,
bool enable, bool newly)
{
struct sta_rec_basic *basic;
@@ -390,7 +390,7 @@ void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
basic->conn_state = CONN_STATE_DISCONNECT;
}

- if (!sta) {
+ if (!link_sta) {
basic->conn_type = cpu_to_le32(CONNECTION_INFRA_BC);
eth_broadcast_addr(basic->peer_addr);
return;
@@ -404,7 +404,7 @@ void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
else
conn_type = CONNECTION_INFRA_STA;
basic->conn_type = cpu_to_le32(conn_type);
- basic->aid = cpu_to_le16(sta->aid);
+ basic->aid = cpu_to_le16(link_sta->sta->aid);
break;
case NL80211_IFTYPE_STATION:
if (vif->p2p && !is_mt7921(dev))
@@ -416,15 +416,15 @@ void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
break;
case NL80211_IFTYPE_ADHOC:
basic->conn_type = cpu_to_le32(CONNECTION_IBSS_ADHOC);
- basic->aid = cpu_to_le16(sta->aid);
+ basic->aid = cpu_to_le16(link_sta->sta->aid);
break;
default:
WARN_ON(1);
break;
}

- memcpy(basic->peer_addr, sta->addr, ETH_ALEN);
- basic->qos = sta->wme;
+ memcpy(basic->peer_addr, link_sta->addr, ETH_ALEN);
+ basic->qos = link_sta->sta->wme;
}
EXPORT_SYMBOL_GPL(mt76_connac_mcu_sta_basic_tlv);

@@ -1049,8 +1049,9 @@ int mt76_connac_mcu_sta_cmd(struct mt76_phy *phy,
return PTR_ERR(skb);

if (info->sta || !info->offload_fw)
- mt76_connac_mcu_sta_basic_tlv(dev, skb, info->vif, info->sta,
- info->enable, info->newly);
+ mt76_connac_mcu_sta_basic_tlv(dev, skb, info->vif,
+ &info->sta->deflink, info->enable,
+ info->newly);
if (info->sta && info->enable)
mt76_connac_mcu_sta_tlv(phy, skb, info->sta,
info->vif, info->rcpi,
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
index 2c939468d141..4857c31cfb23 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
@@ -1879,8 +1879,8 @@ int mt76_connac_mcu_set_channel_domain(struct mt76_phy *phy);
int mt76_connac_mcu_set_vif_ps(struct mt76_dev *dev, struct ieee80211_vif *vif);
void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
struct ieee80211_vif *vif,
- struct ieee80211_sta *sta, bool enable,
- bool newly);
+ struct ieee80211_link_sta *link_sta,
+ bool enable, bool newly);
void mt76_connac_mcu_wtbl_generic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta, void *sta_wtbl,
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 0f50c6659802..7204866437ce 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -1668,7 +1668,7 @@ int mt7915_mcu_add_sta(struct mt7915_dev *dev, struct ieee80211_vif *vif,
return PTR_ERR(skb);

/* starec basic */
- mt76_connac_mcu_sta_basic_tlv(&dev->mt76, skb, vif, sta, enable,
+ mt76_connac_mcu_sta_basic_tlv(&dev->mt76, skb, vif, &sta->deflink, enable,
!rcu_access_pointer(dev->mt76.wcid[msta->wcid.idx]));
if (!enable)
goto out;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 321a164a6e14..5a40979c0bba 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1645,7 +1645,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,

if (info->link_sta || !info->offload_fw)
mt76_connac_mcu_sta_basic_tlv(dev, skb, info->vif,
- info->link_sta->sta,
+ info->link_sta,
info->enable, info->newly);
if (info->link_sta && info->enable) {
mt7925_mcu_sta_phy_tlv(skb, info->vif, info->link_sta);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
index f4c59eafb537..038c4a140ec8 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
@@ -2152,7 +2152,7 @@ int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif,
return PTR_ERR(skb);

/* starec basic */
- mt76_connac_mcu_sta_basic_tlv(&dev->mt76, skb, vif, sta, enable,
+ mt76_connac_mcu_sta_basic_tlv(&dev->mt76, skb, vif, &sta->deflink, enable,
!rcu_access_pointer(dev->mt76.wcid[msta->wcid.idx]));
if (!enable)
goto out;
--
2.34.1


2024-06-13 03:05:19

by Sean Wang

[permalink] [raw]
Subject: [PATCH 32/47] wifi: mt76: mt7925: extend mt7925_mcu_sta_ht_tlv for per-link STA

From: Sean Wang <[email protected]>

Extend mt7925_mcu_sta_ht_tlv with the per-link STA configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Ming Yen Hsieh <[email protected]>
Signed-off-by: Ming Yen Hsieh <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 1b66dd26bd1e..66d45d676739 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1433,18 +1433,18 @@ mt7925_mcu_sta_eht_tlv(struct sk_buff *skb, struct ieee80211_link_sta *link_sta)
}

static void
-mt7925_mcu_sta_ht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
+mt7925_mcu_sta_ht_tlv(struct sk_buff *skb, struct ieee80211_link_sta *link_sta)
{
struct sta_rec_ht *ht;
struct tlv *tlv;

- if (!sta->deflink.ht_cap.ht_supported)
+ if (!link_sta->ht_cap.ht_supported)
return;

tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_HT, sizeof(*ht));

ht = (struct sta_rec_ht *)tlv;
- ht->ht_cap = cpu_to_le16(sta->deflink.ht_cap.cap);
+ ht->ht_cap = cpu_to_le16(link_sta->ht_cap.cap);
}

static void
@@ -1640,7 +1640,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,
info->enable, info->newly);
if (info->link_sta && info->enable) {
mt7925_mcu_sta_phy_tlv(skb, info->vif, info->link_sta->sta);
- mt7925_mcu_sta_ht_tlv(skb, info->link_sta->sta);
+ mt7925_mcu_sta_ht_tlv(skb, info->link_sta);
mt7925_mcu_sta_vht_tlv(skb, info->link_sta);
mt76_connac_mcu_sta_uapsd(skb, info->vif, info->link_sta->sta);
mt7925_mcu_sta_amsdu_tlv(skb, info->vif, info->link_sta);
--
2.34.1


2024-06-13 03:05:22

by Sean Wang

[permalink] [raw]
Subject: [PATCH 38/47] wifi: mt76: mt7925: extend mt7925_mcu_sta_hdr_trans_tlv for per-link STA

From: Sean Wang <[email protected]>

Extend mt7925_mcu_sta_hdr_trans_tlv with per-link STA configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Ming Yen Hsieh <[email protected]>
Signed-off-by: Ming Yen Hsieh <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 5a40979c0bba..667ecd44392d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -847,7 +847,7 @@ EXPORT_SYMBOL_GPL(mt7925_run_firmware);
static void
mt7925_mcu_sta_hdr_trans_tlv(struct sk_buff *skb,
struct ieee80211_vif *vif,
- struct ieee80211_sta *sta)
+ struct ieee80211_link_sta *link_sta)
{
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct sta_rec_hdr_trans *hdr_trans;
@@ -863,8 +863,8 @@ mt7925_mcu_sta_hdr_trans_tlv(struct sk_buff *skb,
else
hdr_trans->from_ds = true;

- if (sta)
- wcid = (struct mt76_wcid *)sta->drv_priv;
+ if (link_sta)
+ wcid = (struct mt76_wcid *)link_sta->sta->drv_priv;
else
wcid = &mvif->sta.deflink.wcid;

@@ -895,7 +895,7 @@ int mt7925_mcu_wtbl_update_hdr_trans(struct mt792x_dev *dev,
return PTR_ERR(skb);

/* starec hdr trans */
- mt7925_mcu_sta_hdr_trans_tlv(skb, vif, sta);
+ mt7925_mcu_sta_hdr_trans_tlv(skb, vif, &sta->deflink);
return mt76_mcu_skb_send_msg(&dev->mt76, skb,
MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true);
}
@@ -1664,12 +1664,8 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,
mt7925_mcu_sta_mld_tlv(skb, info->vif, info->link_sta->sta);
}

- if (info->enable) {
- struct ieee80211_sta *sta = info->link_sta ?
- info->link_sta->sta : NULL;
-
- mt7925_mcu_sta_hdr_trans_tlv(skb, info->vif, sta);
- }
+ if (info->enable)
+ mt7925_mcu_sta_hdr_trans_tlv(skb, info->vif, info->link_sta);

return mt76_mcu_skb_send_msg(dev, skb, info->cmd, true);
}
--
2.34.1


2024-06-13 03:05:30

by Sean Wang

[permalink] [raw]
Subject: [PATCH 40/47] wifi: mt76: mt7925: extend mt7925_mcu_bss_mld_tlv for per-link STA

From: Sean Wang <[email protected]>

Extend mt7925_mcu_bss_mld_tlv with the per-link STA configuration.

Co-developed-by: Ming Yen Hsieh <[email protected]>
Signed-off-by: Ming Yen Hsieh <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index d5f94ee78623..24966e614303 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -2227,7 +2227,7 @@ mt7925_mcu_bss_bmc_tlv(struct sk_buff *skb, struct mt792x_phy *phy,
static void
mt7925_mcu_bss_mld_tlv(struct sk_buff *skb,
struct ieee80211_bss_conf *link_conf,
- struct ieee80211_sta *sta)
+ struct ieee80211_link_sta *link_sta)
{
struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(link_conf);
bool is_mld = ieee80211_vif_is_mld(link_conf->vif);
@@ -2237,13 +2237,13 @@ mt7925_mcu_bss_mld_tlv(struct sk_buff *skb,
tlv = mt76_connac_mcu_add_tlv(skb, UNI_BSS_INFO_MLD, sizeof(*mld));
mld = (struct bss_mld_tlv *)tlv;

- mld->link_id = sta ? (is_mld ? link_conf->link_id : 0) : 0xff;
+ mld->link_id = link_sta ? (is_mld ? link_conf->link_id : 0) : 0xff;
mld->group_mld_id = is_mld ? mconf->mt76.idx : 0xff;
mld->own_mld_id = mconf->mt76.idx + 32;
mld->remap_idx = 0xff;

- if (sta)
- memcpy(mld->mac_addr, sta->addr, ETH_ALEN);
+ if (link_sta)
+ memcpy(mld->mac_addr, link_sta->addr, ETH_ALEN);
}

static void
@@ -2358,7 +2358,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,

mt7925_mcu_bss_bmc_tlv(skb, phy, ctx, link_conf);
mt7925_mcu_bss_qos_tlv(skb, link_conf);
- mt7925_mcu_bss_mld_tlv(skb, link_conf, link_sta->sta);
+ mt7925_mcu_bss_mld_tlv(skb, link_conf, link_sta);
mt7925_mcu_bss_ifs_tlv(skb, link_conf);

if (link_conf->he_support) {
--
2.34.1


2024-06-13 03:05:34

by Sean Wang

[permalink] [raw]
Subject: [PATCH 41/47] wifi: mt76: mt7925: extend mt7925_mcu_bss_basic_tlv for per-link STA

From: Sean Wang <[email protected]>

Extend mt7925_mcu_bss_basic_tlv with the per-link STA configuration.

Co-developed-by: Ming Yen Hsieh <[email protected]>
Signed-off-by: Ming Yen Hsieh <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7925/mcu.c | 25 +++++++++++++------
1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 24966e614303..7156ba092302 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -2078,18 +2078,17 @@ mt7925_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif,
static void
mt7925_mcu_bss_basic_tlv(struct sk_buff *skb,
struct ieee80211_bss_conf *link_conf,
- struct ieee80211_sta *sta,
+ struct ieee80211_link_sta *link_sta,
struct ieee80211_chanctx_conf *ctx,
struct mt76_phy *phy, u16 wlan_idx,
bool enable)
{
struct ieee80211_vif *vif = link_conf->vif;
struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(link_conf);
- struct mt792x_sta *msta = sta ? (struct mt792x_sta *)sta->drv_priv :
- &mconf->vif->sta;
struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &phy->chandef;
enum nl80211_band band = chandef->chan->band;
struct mt76_connac_bss_basic_tlv *basic_req;
+ struct mt792x_link_sta *mlink;
struct tlv *tlv;
int conn_type;
u8 idx;
@@ -2102,7 +2101,7 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb,
basic_req->hw_bss_idx = idx;

basic_req->phymode_ext = mt7925_get_phy_mode_ext(phy, vif, band,
- &sta->deflink);
+ link_sta);

if (band == NL80211_BAND_2GHZ)
basic_req->nonht_basic_phy = cpu_to_le16(PHY_TYPE_ERP_INDEX);
@@ -2110,12 +2109,22 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb,
basic_req->nonht_basic_phy = cpu_to_le16(PHY_TYPE_OFDM_INDEX);

memcpy(basic_req->bssid, link_conf->bssid, ETH_ALEN);
- basic_req->phymode = mt76_connac_get_phy_mode(phy, vif, band,
- &sta->deflink);
+ basic_req->phymode = mt76_connac_get_phy_mode(phy, vif, band, link_sta);
basic_req->bcn_interval = cpu_to_le16(link_conf->beacon_int);
basic_req->dtim_period = link_conf->dtim_period;
basic_req->bmc_tx_wlan_idx = cpu_to_le16(wlan_idx);
- basic_req->sta_idx = cpu_to_le16(msta->deflink.wcid.idx);
+
+ if (link_sta) {
+ struct mt792x_sta *msta;
+
+ msta = (struct mt792x_sta *)link_sta->sta->drv_priv;
+ mlink = mt792x_sta_to_link(msta, link_sta->link_id);
+
+ } else {
+ mlink = &mconf->vif->sta.deflink;
+ }
+
+ basic_req->sta_idx = cpu_to_le16(mlink->wcid.idx);
basic_req->omac_idx = mconf->mt76.omac_idx;
basic_req->band_idx = mconf->mt76.band_idx;
basic_req->wmm_idx = mconf->mt76.wmm_idx;
@@ -2352,7 +2361,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
return PTR_ERR(skb);

/* bss_basic must be first */
- mt7925_mcu_bss_basic_tlv(skb, link_conf, link_sta->sta, ctx, phy->mt76,
+ mt7925_mcu_bss_basic_tlv(skb, link_conf, link_sta, ctx, phy->mt76,
mvif->sta.deflink.wcid.idx, enable);
mt7925_mcu_bss_sec_tlv(skb, link_conf);

--
2.34.1


2024-06-13 03:05:34

by Sean Wang

[permalink] [raw]
Subject: [PATCH 35/47] wifi: mt76: mt7925: extend mt7925_get_phy_mode for per-link STA

From: Sean Wang <[email protected]>

Extend mt7925_get_phy_mode with the per-link STA configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Ming Yen Hsieh <[email protected]>
Signed-off-by: Ming Yen Hsieh <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 11 ++++++-----
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h | 3 ++-
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 2 +-
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 3 ++-
4 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
index 87f918461051..f7ba3afb3ccf 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
@@ -1300,7 +1300,8 @@ int mt76_connac_mcu_sta_ba(struct mt76_dev *dev, struct mt76_vif *mvif,
EXPORT_SYMBOL_GPL(mt76_connac_mcu_sta_ba);

u8 mt76_connac_get_phy_mode(struct mt76_phy *phy, struct ieee80211_vif *vif,
- enum nl80211_band band, struct ieee80211_sta *sta)
+ enum nl80211_band band,
+ struct ieee80211_link_sta *link_sta)
{
struct mt76_dev *dev = phy->dev;
const struct ieee80211_sta_he_cap *he_cap;
@@ -1311,10 +1312,10 @@ u8 mt76_connac_get_phy_mode(struct mt76_phy *phy, struct ieee80211_vif *vif,
if (is_connac_v1(dev))
return 0x38;

- if (sta) {
- ht_cap = &sta->deflink.ht_cap;
- vht_cap = &sta->deflink.vht_cap;
- he_cap = &sta->deflink.he_cap;
+ if (link_sta) {
+ ht_cap = &link_sta->ht_cap;
+ vht_cap = &link_sta->vht_cap;
+ he_cap = &link_sta->he_cap;
} else {
struct ieee80211_supported_band *sband;

diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
index 2a858b1ca82e..5b40d51ee728 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
@@ -1988,7 +1988,8 @@ mt76_connac_get_he_phy_cap(struct mt76_phy *phy, struct ieee80211_vif *vif);
const struct ieee80211_sta_eht_cap *
mt76_connac_get_eht_phy_cap(struct mt76_phy *phy, struct ieee80211_vif *vif);
u8 mt76_connac_get_phy_mode(struct mt76_phy *phy, struct ieee80211_vif *vif,
- enum nl80211_band band, struct ieee80211_sta *sta);
+ enum nl80211_band band,
+ struct ieee80211_link_sta *sta);
u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif,
enum nl80211_band band);

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 2c95c69f395d..0f50c6659802 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -1503,7 +1503,7 @@ mt7915_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7915_dev *dev,

ra->valid = true;
ra->auto_rate = true;
- ra->phy_mode = mt76_connac_get_phy_mode(mphy, vif, band, sta);
+ ra->phy_mode = mt76_connac_get_phy_mode(mphy, vif, band, &sta->deflink);
ra->channel = chandef->chan->hw_value;
ra->bw = sta->deflink.bandwidth;
ra->phy.bw = sta->deflink.bandwidth;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 32ea71128280..3cda538307b5 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -2114,7 +2114,8 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb,
basic_req->nonht_basic_phy = cpu_to_le16(PHY_TYPE_OFDM_INDEX);

memcpy(basic_req->bssid, link_conf->bssid, ETH_ALEN);
- basic_req->phymode = mt76_connac_get_phy_mode(phy, vif, band, sta);
+ basic_req->phymode = mt76_connac_get_phy_mode(phy, vif, band,
+ &sta->deflink);
basic_req->bcn_interval = cpu_to_le16(link_conf->beacon_int);
basic_req->dtim_period = link_conf->dtim_period;
basic_req->bmc_tx_wlan_idx = cpu_to_le16(wlan_idx);
--
2.34.1


2024-06-13 03:05:41

by Sean Wang

[permalink] [raw]
Subject: [PATCH 43/47] wifi: mt76: mt7925: add mt7925_mac_link_sta_assoc to associate per-link STA

From: Sean Wang <[email protected]>

The mt7925_mac_link_sta_add function currently associates the per-link STA.
We will extend this function when we implement the MLO functionality.

This patch only includes structural changes and does not involve any
logic changes.

Signed-off-by: Sean Wang <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7925/main.c | 29 +++++++++++++------
1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 3911cf71462f..b159d26303ca 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -766,32 +766,43 @@ int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
}
EXPORT_SYMBOL_GPL(mt7925_mac_sta_add);

-void mt7925_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
- struct ieee80211_sta *sta)
+static void mt7925_mac_link_sta_assoc(struct mt76_dev *mdev,
+ struct ieee80211_vif *vif,
+ struct ieee80211_link_sta *link_sta)
{
struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
- struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct ieee80211_bss_conf *link_conf;
+ struct mt792x_link_sta *mlink;
+ struct mt792x_sta *msta;
+
+ msta = (struct mt792x_sta *)link_sta->sta->drv_priv;
+ mlink = mt792x_sta_to_link(msta, link_sta->link_id);

mt792x_mutex_acquire(dev);

link_conf = mt792x_vif_to_bss_conf(vif, vif->bss_conf.link_id);

- if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
+ if (vif->type == NL80211_IFTYPE_STATION && !link_sta->sta->tdls)
mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx,
- link_conf, &sta->deflink, true);
+ link_conf, link_sta, true);

- ewma_avg_signal_init(&msta->deflink.avg_ack_signal);
+ ewma_avg_signal_init(&mlink->avg_ack_signal);

- mt7925_mac_wtbl_update(dev, msta->deflink.wcid.idx,
+ mt7925_mac_wtbl_update(dev, mlink->wcid.idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
- memset(msta->deflink.airtime_ac, 0, sizeof(msta->deflink.airtime_ac));
+ memset(mlink->airtime_ac, 0, sizeof(mlink->airtime_ac));

- mt7925_mcu_sta_update(dev, &sta->deflink, vif, true, MT76_STA_INFO_STATE_ASSOC);
+ mt7925_mcu_sta_update(dev, link_sta, vif, true, MT76_STA_INFO_STATE_ASSOC);

mt792x_mutex_release(dev);
}
+
+void mt7925_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta)
+{
+ mt7925_mac_link_sta_assoc(mdev, vif, &sta->deflink);
+}
EXPORT_SYMBOL_GPL(mt7925_mac_sta_assoc);

void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
--
2.34.1


2024-06-13 03:05:44

by Sean Wang

[permalink] [raw]
Subject: [PATCH 44/47] wifi: mt76: mt7925: add mt7925_mac_link_sta_remove to remove per-link STA

From: Sean Wang <[email protected]>

The mt7925_mac_link_sta_remove function currently removes the per-link STA.
We will extend this function when we implement the MLO functionality.

This patch only includes structural changes and does not involve any
logic changes.

Signed-off-by: Sean Wang <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7925/main.c | 46 +++++++++++++------
1 file changed, 31 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index b159d26303ca..ce5379c4d55d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -805,39 +805,55 @@ void mt7925_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
}
EXPORT_SYMBOL_GPL(mt7925_mac_sta_assoc);

-void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
- struct ieee80211_sta *sta)
+static void mt7925_mac_link_sta_remove(struct mt76_dev *mdev,
+ struct ieee80211_vif *vif,
+ struct ieee80211_link_sta *link_sta)
{
struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
- struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
struct ieee80211_bss_conf *link_conf;
+ struct mt792x_link_sta *mlink;
+ struct mt792x_sta *msta;

- mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->deflink.wcid);
+ msta = (struct mt792x_sta *)link_sta->sta->drv_priv;
+ mlink = mt792x_sta_to_link(msta, link_sta->link_id);
+
+ mt76_connac_free_pending_tx_skbs(&dev->pm, &mlink->wcid);
mt76_connac_pm_wake(&dev->mphy, &dev->pm);

- mt7925_mcu_sta_update(dev, &sta->deflink, vif, false, MT76_STA_INFO_STATE_NONE);
- mt7925_mac_wtbl_update(dev, msta->deflink.wcid.idx,
+ mt7925_mcu_sta_update(dev, link_sta, vif, false,
+ MT76_STA_INFO_STATE_NONE);
+ mt7925_mac_wtbl_update(dev, mlink->wcid.idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

link_conf = mt792x_vif_to_bss_conf(vif, vif->bss_conf.link_id);

- if (vif->type == NL80211_IFTYPE_STATION) {
+ if (vif->type == NL80211_IFTYPE_STATION && !link_sta->sta->tdls) {
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
-
- mvif->wep_sta = NULL;
- ewma_rssi_init(&mvif->bss_conf.rssi);
- if (!sta->tdls)
- mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx,
- link_conf, &sta->deflink, false);
+ mt7925_mcu_add_bss_info(&dev->phy,
+ mvif->bss_conf.mt76.ctx, link_conf,
+ link_sta, false);
}

spin_lock_bh(&mdev->sta_poll_lock);
- if (!list_empty(&msta->deflink.wcid.poll_list))
- list_del_init(&msta->deflink.wcid.poll_list);
+ if (!list_empty(&mlink->wcid.poll_list))
+ list_del_init(&mlink->wcid.poll_list);
spin_unlock_bh(&mdev->sta_poll_lock);

mt76_connac_power_save_sched(&dev->mphy, &dev->pm);
}
+
+void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta)
+{
+ mt7925_mac_link_sta_remove(mdev, vif, &sta->deflink);
+
+ if (vif->type == NL80211_IFTYPE_STATION) {
+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+
+ mvif->wep_sta = NULL;
+ ewma_rssi_init(&mvif->bss_conf.rssi);
+ }
+}
EXPORT_SYMBOL_GPL(mt7925_mac_sta_remove);

static int mt7925_set_rts_threshold(struct ieee80211_hw *hw, u32 val)
--
2.34.1


2024-06-13 03:05:45

by Sean Wang

[permalink] [raw]
Subject: [PATCH 20/47] wifi: mt76: mt7925: extend mt7925_mcu_uni_bss_bcnft for per-link BSS

From: Sean Wang <[email protected]>

Extend mt7925_mcu_uni_bss_bcnft with per-link BSS configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index a40ad1578212..8950df09a025 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1281,10 +1281,10 @@ int mt7925_mcu_uni_bss_ps(struct mt792x_dev *dev, struct ieee80211_vif *vif)
}

static int
-mt7925_mcu_uni_bss_bcnft(struct mt792x_dev *dev, struct ieee80211_vif *vif,
- bool enable)
+mt7925_mcu_uni_bss_bcnft(struct mt792x_dev *dev,
+ struct ieee80211_bss_conf *link_conf, bool enable)
{
- struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+ struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(link_conf);
struct {
struct {
u8 bss_idx;
@@ -1301,17 +1301,17 @@ mt7925_mcu_uni_bss_bcnft(struct mt792x_dev *dev, struct ieee80211_vif *vif,
} __packed bcnft;
} __packed bcnft_req = {
.hdr = {
- .bss_idx = mvif->bss_conf.mt76.idx,
+ .bss_idx = mconf->mt76.idx,
},
.bcnft = {
.tag = cpu_to_le16(UNI_BSS_INFO_BCNFT),
.len = cpu_to_le16(sizeof(struct bcnft_tlv)),
- .bcn_interval = cpu_to_le16(vif->bss_conf.beacon_int),
- .dtim_period = vif->bss_conf.dtim_period,
+ .bcn_interval = cpu_to_le16(link_conf->beacon_int),
+ .dtim_period = link_conf->dtim_period,
},
};

- if (vif->type != NL80211_IFTYPE_STATION)
+ if (link_conf->vif->type != NL80211_IFTYPE_STATION)
return 0;

return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(BSS_INFO_UPDATE),
@@ -1685,7 +1685,7 @@ int mt7925_mcu_set_beacon_filter(struct mt792x_dev *dev,
int err = 0;

if (enable) {
- err = mt7925_mcu_uni_bss_bcnft(dev, vif, true);
+ err = mt7925_mcu_uni_bss_bcnft(dev, &vif->bss_conf, true);
if (err)
return err;

--
2.34.1


2024-06-13 03:05:48

by Sean Wang

[permalink] [raw]
Subject: [PATCH 45/47] wifi: mt76: mt7925: add mt7925_mac_link_bss_add to create per-link BSS

From: Sean Wang <[email protected]>

The mt7925_mac_link_bss_add function currently creates the per-link BSS.
We will extend this function when we implement the MLO functionality.

This patch only includes structural changes and does not involve any
logic changes.

Signed-off-by: Sean Wang <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7925/main.c | 80 ++++++++++++-------
1 file changed, 49 insertions(+), 31 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index ce5379c4d55d..611138acd16d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -317,63 +317,81 @@ static int mt7925_start(struct ieee80211_hw *hw)
return err;
}

-static int
-mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
+static int mt7925_mac_link_bss_add(struct mt792x_dev *dev,
+ struct ieee80211_bss_conf *link_conf,
+ struct mt792x_link_sta *mlink)
{
- struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
- struct mt792x_dev *dev = mt792x_hw_dev(hw);
- struct mt792x_phy *phy = mt792x_hw_phy(hw);
+ struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(link_conf);
+ struct ieee80211_vif *vif = link_conf->vif;
+ struct mt792x_vif *mvif = mconf->vif;
struct mt76_txq *mtxq;
int idx, ret = 0;

- mt792x_mutex_acquire(dev);
-
- mvif->bss_conf.mt76.idx = __ffs64(~dev->mt76.vif_mask);
- if (mvif->bss_conf.mt76.idx >= MT792x_MAX_INTERFACES) {
+ mconf->mt76.idx = __ffs64(~dev->mt76.vif_mask);
+ if (mconf->mt76.idx >= MT792x_MAX_INTERFACES) {
ret = -ENOSPC;
goto out;
}

- mvif->bss_conf.mt76.omac_idx = mvif->bss_conf.mt76.idx;
- mvif->phy = phy;
- mvif->bss_conf.mt76.band_idx = 0;
- mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx % MT76_CONNAC_MAX_WMM_SETS;
- mvif->bss_conf.vif = mvif;
+ mconf->mt76.omac_idx = mconf->mt76.idx;
+ mconf->mt76.band_idx = 0;
+ mconf->mt76.wmm_idx = mconf->mt76.idx % MT76_CONNAC_MAX_WMM_SETS;

- if (phy->mt76->chandef.chan->band != NL80211_BAND_2GHZ)
- mvif->bss_conf.mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL + 4;
+ if (mvif->phy->mt76->chandef.chan->band != NL80211_BAND_2GHZ)
+ mconf->mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL + 4;
else
- mvif->bss_conf.mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL;
+ mconf->mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL;

- ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, &vif->bss_conf,
- &mvif->sta.deflink.wcid, true);
+ ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, link_conf,
+ &mlink->wcid, true);
if (ret)
goto out;

- dev->mt76.vif_mask |= BIT_ULL(mvif->bss_conf.mt76.idx);
- phy->omac_mask |= BIT_ULL(mvif->bss_conf.mt76.omac_idx);
+ dev->mt76.vif_mask |= BIT_ULL(mconf->mt76.idx);
+ mvif->phy->omac_mask |= BIT_ULL(mconf->mt76.omac_idx);

- idx = MT792x_WTBL_RESERVED - mvif->bss_conf.mt76.idx;
+ idx = MT792x_WTBL_RESERVED - mconf->mt76.idx;

- INIT_LIST_HEAD(&mvif->sta.deflink.wcid.poll_list);
- mvif->sta.deflink.wcid.idx = idx;
- mvif->sta.deflink.wcid.phy_idx = mvif->bss_conf.mt76.band_idx;
- mvif->sta.deflink.wcid.hw_key_idx = -1;
- mvif->sta.deflink.wcid.tx_info |= MT_WCID_TX_INFO_SET;
- mvif->sta.vif = mvif;
- mt76_wcid_init(&mvif->sta.deflink.wcid);
+ INIT_LIST_HEAD(&mlink->wcid.poll_list);
+ mlink->wcid.idx = idx;
+ mlink->wcid.phy_idx = mconf->mt76.band_idx;
+ mlink->wcid.hw_key_idx = -1;
+ mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET;
+ mt76_wcid_init(&mlink->wcid);

mt7925_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

- ewma_rssi_init(&mvif->bss_conf.rssi);
+ ewma_rssi_init(&mconf->rssi);

- rcu_assign_pointer(dev->mt76.wcid[idx], &mvif->sta.deflink.wcid);
+ rcu_assign_pointer(dev->mt76.wcid[idx], &mlink->wcid);
if (vif->txq) {
mtxq = (struct mt76_txq *)vif->txq->drv_priv;
mtxq->wcid = idx;
}

+out:
+ return ret;
+}
+
+static int
+mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
+{
+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
+ struct mt792x_phy *phy = mt792x_hw_phy(hw);
+ int ret = 0;
+
+ mt792x_mutex_acquire(dev);
+
+ mvif->phy = phy;
+ mvif->bss_conf.vif = mvif;
+ mvif->sta.vif = mvif;
+
+ ret = mt7925_mac_link_bss_add(dev, &vif->bss_conf, &mvif->sta.deflink);
+ if (ret < 0)
+ goto out;
+
vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
out:
mt792x_mutex_release(dev);
--
2.34.1


2024-06-13 03:05:52

by Sean Wang

[permalink] [raw]
Subject: [PATCH 46/47] wifi: mt76: mt7925: add mt7925_mac_link_bss_remove to remove per-link BSS

From: Sean Wang <[email protected]>

The mt7925_mac_link_bss_remove function currently removes the per-link BSS.
We will extend this function when we implement the MLO functionality.

This patch only includes structural changes and does not involve any
logic changes.

Signed-off-by: Sean Wang <[email protected]>
---
.../net/wireless/mediatek/mt76/mt792x_core.c | 35 +++++++++++--------
1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
index 222204916b73..bec2c1eb5240 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c
+++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
@@ -113,31 +113,38 @@ void mt792x_stop(struct ieee80211_hw *hw)
}
EXPORT_SYMBOL_GPL(mt792x_stop);

-void mt792x_remove_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif)
+static void mt792x_mac_link_bss_remove(struct mt792x_dev *dev,
+ struct ieee80211_bss_conf *link_conf,
+ struct mt792x_link_sta *mlink)
{
- struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
- struct mt792x_sta *msta = &mvif->sta;
- struct mt792x_dev *dev = mt792x_hw_dev(hw);
- struct mt792x_phy *phy = mt792x_hw_phy(hw);
- int idx = msta->deflink.wcid.idx;
+ struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(link_conf);
+ int idx = mlink->wcid.idx;

mt792x_mutex_acquire(dev);
- mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->deflink.wcid);
- mt76_connac_mcu_uni_add_dev(&dev->mphy, &vif->bss_conf, &mvif->sta.deflink.wcid, false);
+ mt76_connac_free_pending_tx_skbs(&dev->pm, &mlink->wcid);
+ mt76_connac_mcu_uni_add_dev(&dev->mphy, link_conf, &mlink->wcid, false);

rcu_assign_pointer(dev->mt76.wcid[idx], NULL);

- dev->mt76.vif_mask &= ~BIT_ULL(mvif->bss_conf.mt76.idx);
- phy->omac_mask &= ~BIT_ULL(mvif->bss_conf.mt76.omac_idx);
+ dev->mt76.vif_mask &= ~BIT_ULL(mconf->mt76.idx);
+ mconf->vif->phy->omac_mask &= ~BIT_ULL(mconf->mt76.omac_idx);
mt792x_mutex_release(dev);

spin_lock_bh(&dev->mt76.sta_poll_lock);
- if (!list_empty(&msta->deflink.wcid.poll_list))
- list_del_init(&msta->deflink.wcid.poll_list);
+ if (!list_empty(&mlink->wcid.poll_list))
+ list_del_init(&mlink->wcid.poll_list);
spin_unlock_bh(&dev->mt76.sta_poll_lock);

- mt76_wcid_cleanup(&dev->mt76, &msta->deflink.wcid);
+ mt76_wcid_cleanup(&dev->mt76, &mlink->wcid);
+}
+
+void mt792x_remove_interface(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif)
+{
+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
+
+ mt792x_mac_link_bss_remove(dev, &vif->bss_conf, &mvif->sta.deflink);
}
EXPORT_SYMBOL_GPL(mt792x_remove_interface);

--
2.34.1


2024-06-13 03:05:55

by Sean Wang

[permalink] [raw]
Subject: [PATCH 39/47] wifi: mt76: mt7925: extend mt7925_mcu_add_bss_info for per-link STA

From: Sean Wang <[email protected]>

Extend mt7925_mcu_add_bss_info with the per-link STA configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Ming Yen Hsieh <[email protected]>
Signed-off-by: Ming Yen Hsieh <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/main.c | 8 ++++----
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 6 +++---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index f3a32fe9a754..b91992745462 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -535,7 +535,7 @@ static int mt7925_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,

mvif->bss_conf.mt76.cipher = mt7925_mcu_get_cipher(key->cipher);
mt7925_mcu_add_bss_info(phy, mvif->bss_conf.mt76.ctx, link_conf,
- sta, true);
+ &sta->deflink, true);
}

if (cmd == SET_KEY)
@@ -738,7 +738,7 @@ int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
/* should update bss info before STA add */
if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx,
- link_conf, sta, false);
+ link_conf, &sta->deflink, false);

ret = mt7925_mcu_sta_update(dev, &sta->deflink, vif, true,
MT76_STA_INFO_STATE_NONE);
@@ -765,7 +765,7 @@ void mt7925_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,

if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx,
- link_conf, sta, true);
+ link_conf, &sta->deflink, true);

ewma_avg_signal_init(&msta->deflink.avg_ack_signal);

@@ -802,7 +802,7 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
ewma_rssi_init(&mvif->bss_conf.rssi);
if (!sta->tdls)
mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx,
- link_conf, sta, false);
+ link_conf, &sta->deflink, false);
}

spin_lock_bh(&mdev->sta_poll_lock);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 667ecd44392d..d5f94ee78623 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -2337,7 +2337,7 @@ int mt7925_mcu_set_timing(struct mt792x_phy *phy,
int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
struct ieee80211_chanctx_conf *ctx,
struct ieee80211_bss_conf *link_conf,
- struct ieee80211_sta *sta,
+ struct ieee80211_link_sta *link_sta,
int enable)
{
struct mt792x_vif *mvif = (struct mt792x_vif *)link_conf->vif->drv_priv;
@@ -2352,13 +2352,13 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
return PTR_ERR(skb);

/* bss_basic must be first */
- mt7925_mcu_bss_basic_tlv(skb, link_conf, sta, ctx, phy->mt76,
+ mt7925_mcu_bss_basic_tlv(skb, link_conf, link_sta->sta, ctx, phy->mt76,
mvif->sta.deflink.wcid.idx, enable);
mt7925_mcu_bss_sec_tlv(skb, link_conf);

mt7925_mcu_bss_bmc_tlv(skb, phy, ctx, link_conf);
mt7925_mcu_bss_qos_tlv(skb, link_conf);
- mt7925_mcu_bss_mld_tlv(skb, link_conf, sta);
+ mt7925_mcu_bss_mld_tlv(skb, link_conf, link_sta->sta);
mt7925_mcu_bss_ifs_tlv(skb, link_conf);

if (link_conf->he_support) {
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h
index c5197577cdc8..da4e84f468d2 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h
@@ -595,7 +595,7 @@ int mt7925_mcu_sched_scan_enable(struct mt76_phy *phy,
int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
struct ieee80211_chanctx_conf *ctx,
struct ieee80211_bss_conf *link_conf,
- struct ieee80211_sta *sta,
+ struct ieee80211_link_sta *link_sta,
int enable);
int mt7925_mcu_set_timing(struct mt792x_phy *phy,
struct ieee80211_bss_conf *link_conf);
--
2.34.1


2024-06-13 03:05:56

by Sean Wang

[permalink] [raw]
Subject: [PATCH 47/47] wifi: mt76: mt7925: simpify mt7925_mcu_sta_cmd logic by removing fw_offload

From: Sean Wang <[email protected]>

The mt7925 only supports offload firmware making the fw_offload check
redundant. This update simplifies the logic in "mt7925_mcu_sta_cmd"
by removing the unnecessary check for fw_offoad.

Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 7156ba092302..c0b27d28a6d1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1643,7 +1643,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,
if (IS_ERR(skb))
return PTR_ERR(skb);

- if (info->link_sta || !info->offload_fw)
+ if (info->link_sta)
mt76_connac_mcu_sta_basic_tlv(dev, skb, info->vif,
info->link_sta,
info->enable, info->newly);
--
2.34.1


2024-06-13 03:06:10

by Sean Wang

[permalink] [raw]
Subject: [PATCH 42/47] wifi: mt76: mt7925: add mt7925_mac_link_sta_add to create per-link STA

From: Sean Wang <[email protected]>

The mt7925_mac_link_sta_add function currently adds the per-link STA.
We will extend this function when we implement the MLO functionality.

This patch only includes structural changes and does not involve any
logic changes.

Signed-off-by: Sean Wang <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7925/main.c | 47 ++++++++++++-------
1 file changed, 31 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index b91992745462..3911cf71462f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -702,45 +702,46 @@ mt7925_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
return mvif->basic_rates_idx;
}

-int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
- struct ieee80211_sta *sta)
+static int mt7925_mac_link_sta_add(struct mt76_dev *mdev,
+ struct ieee80211_vif *vif,
+ struct ieee80211_link_sta *link_sta)
{
struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
- struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct ieee80211_bss_conf *link_conf;
+ struct mt792x_link_sta *mlink;
+ struct mt792x_sta *msta;
int ret, idx;

+ msta = (struct mt792x_sta *)link_sta->sta->drv_priv;
+ mlink = mt792x_sta_to_link(msta, link_sta->link_id);
+
idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT792x_WTBL_STA - 1);
if (idx < 0)
return -ENOSPC;

- INIT_LIST_HEAD(&msta->deflink.wcid.poll_list);
- msta->vif = mvif;
- msta->deflink.wcid.sta = 1;
- msta->deflink.wcid.idx = idx;
- msta->deflink.wcid.phy_idx = mvif->bss_conf.mt76.band_idx;
- msta->deflink.wcid.tx_info |= MT_WCID_TX_INFO_SET;
- msta->deflink.last_txs = jiffies;
+ INIT_LIST_HEAD(&mlink->wcid.poll_list);
+ mlink->wcid.sta = 1;
+ mlink->wcid.idx = idx;
+ mlink->wcid.phy_idx = mvif->bss_conf.mt76.band_idx;
+ mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET;
+ mlink->last_txs = jiffies;

ret = mt76_connac_pm_wake(&dev->mphy, &dev->pm);
if (ret)
return ret;

- if (vif->type == NL80211_IFTYPE_STATION)
- mvif->wep_sta = msta;
-
mt7925_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

link_conf = mt792x_vif_to_bss_conf(vif, vif->bss_conf.link_id);

/* should update bss info before STA add */
- if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
+ if (vif->type == NL80211_IFTYPE_STATION && !link_sta->sta->tdls)
mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx,
- link_conf, &sta->deflink, false);
+ link_conf, link_sta, false);

- ret = mt7925_mcu_sta_update(dev, &sta->deflink, vif, true,
+ ret = mt7925_mcu_sta_update(dev, link_sta, vif, true,
MT76_STA_INFO_STATE_NONE);
if (ret)
return ret;
@@ -749,6 +750,20 @@ int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,

return 0;
}
+
+int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta)
+{
+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+ struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
+
+ msta->vif = mvif;
+
+ if (vif->type == NL80211_IFTYPE_STATION)
+ mvif->wep_sta = msta;
+
+ return mt7925_mac_link_sta_add(mdev, vif, &sta->deflink);
+}
EXPORT_SYMBOL_GPL(mt7925_mac_sta_add);

void mt7925_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
--
2.34.1


2024-06-13 03:06:28

by Sean Wang

[permalink] [raw]
Subject: [PATCH 27/47] wifi: mt76: mt7925: extend mt7925_mcu_sta_eht_tlv for per-link STA

From: Sean Wang <[email protected]>

Extend mt7925_mcu_sta_eht_tlv with the per-link STA configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Ming Yen Hsieh <[email protected]>
Signed-off-by: Ming Yen Hsieh <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 266010c0e00a..0c9cebd3ee71 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1404,18 +1404,18 @@ mt7925_mcu_sta_he_6g_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
}

static void
-mt7925_mcu_sta_eht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
+mt7925_mcu_sta_eht_tlv(struct sk_buff *skb, struct ieee80211_link_sta *link_sta)
{
struct ieee80211_eht_mcs_nss_supp *mcs_map;
struct ieee80211_eht_cap_elem_fixed *elem;
struct sta_rec_eht *eht;
struct tlv *tlv;

- if (!sta->deflink.eht_cap.has_eht)
+ if (!link_sta->eht_cap.has_eht)
return;

- mcs_map = &sta->deflink.eht_cap.eht_mcs_nss_supp;
- elem = &sta->deflink.eht_cap.eht_cap_elem;
+ mcs_map = &link_sta->eht_cap.eht_mcs_nss_supp;
+ elem = &link_sta->eht_cap.eht_cap_elem;

tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_EHT, sizeof(*eht));

@@ -1425,7 +1425,7 @@ mt7925_mcu_sta_eht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
eht->phy_cap = cpu_to_le64(*(u64 *)elem->phy_cap_info);
eht->phy_cap_ext = cpu_to_le64(elem->phy_cap_info[8]);

- if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_20)
+ if (link_sta->bandwidth == IEEE80211_STA_RX_BW_20)
memcpy(eht->mcs_map_bw20, &mcs_map->only_20mhz, sizeof(eht->mcs_map_bw20));
memcpy(eht->mcs_map_bw80, &mcs_map->bw._80, sizeof(eht->mcs_map_bw80));
memcpy(eht->mcs_map_bw160, &mcs_map->bw._160, sizeof(eht->mcs_map_bw160));
@@ -1641,7 +1641,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,
mt7925_mcu_sta_amsdu_tlv(skb, info->vif, info->link_sta->sta);
mt7925_mcu_sta_he_tlv(skb, info->link_sta->sta);
mt7925_mcu_sta_he_6g_tlv(skb, info->link_sta->sta);
- mt7925_mcu_sta_eht_tlv(skb, info->link_sta->sta);
+ mt7925_mcu_sta_eht_tlv(skb, info->link_sta);
mt7925_mcu_sta_rate_ctrl_tlv(skb, info->vif,
info->link_sta);
mt7925_mcu_sta_state_v2_tlv(phy, skb, info->link_sta,
--
2.34.1


2024-06-13 03:06:41

by Sean Wang

[permalink] [raw]
Subject: [PATCH 29/47] wifi: mt76: mt7925: extend mt7925_mcu_sta_he_tlv for per-link STA

From: Sean Wang <[email protected]>

Extend mt7925_mcu_sta_he_tlv with the per-link STA configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Ming Yen Hsieh <[email protected]>
Signed-off-by: Ming Yen Hsieh <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index e1dc8452468c..a57620aed63b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1380,12 +1380,12 @@ mt7925_mcu_set_bss_pm(struct mt792x_dev *dev,
}

static void
-mt7925_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
+mt7925_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_link_sta *link_sta)
{
- if (!sta->deflink.he_cap.has_he)
+ if (!link_sta->he_cap.has_he)
return;

- mt76_connac_mcu_sta_he_tlv_v2(skb, sta);
+ mt76_connac_mcu_sta_he_tlv_v2(skb, link_sta->sta);
}

static void
@@ -1640,7 +1640,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,
mt7925_mcu_sta_vht_tlv(skb, info->link_sta->sta);
mt76_connac_mcu_sta_uapsd(skb, info->vif, info->link_sta->sta);
mt7925_mcu_sta_amsdu_tlv(skb, info->vif, info->link_sta->sta);
- mt7925_mcu_sta_he_tlv(skb, info->link_sta->sta);
+ mt7925_mcu_sta_he_tlv(skb, info->link_sta);
mt7925_mcu_sta_he_6g_tlv(skb, info->link_sta);
mt7925_mcu_sta_eht_tlv(skb, info->link_sta);
mt7925_mcu_sta_rate_ctrl_tlv(skb, info->vif,
--
2.34.1


2024-06-13 03:11:59

by Sean Wang

[permalink] [raw]
Subject: [PATCH 30/47] wifi: mt76: mt7925: extend mt7925_mcu_sta_amsdu_tlv for per-link STA

From: Sean Wang <[email protected]>

Extend mt7925_mcu_sta_amsdu_tlv with the per-link STA configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Ming Yen Hsieh <[email protected]>
Signed-off-by: Ming Yen Hsieh <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index a57620aed63b..57b89eca4e21 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1467,9 +1467,11 @@ mt7925_mcu_sta_vht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)

static void
mt7925_mcu_sta_amsdu_tlv(struct sk_buff *skb,
- struct ieee80211_vif *vif, struct ieee80211_sta *sta)
+ struct ieee80211_vif *vif,
+ struct ieee80211_link_sta *link_sta)
{
- struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
+ struct mt792x_sta *msta = (struct mt792x_sta *)link_sta->sta->drv_priv;
+ struct mt792x_link_sta *mlink;
struct sta_rec_amsdu *amsdu;
struct tlv *tlv;

@@ -1477,16 +1479,18 @@ mt7925_mcu_sta_amsdu_tlv(struct sk_buff *skb,
vif->type != NL80211_IFTYPE_AP)
return;

- if (!sta->deflink.agg.max_amsdu_len)
+ if (!link_sta->agg.max_amsdu_len)
return;

tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_HW_AMSDU, sizeof(*amsdu));
amsdu = (struct sta_rec_amsdu *)tlv;
amsdu->max_amsdu_num = 8;
amsdu->amsdu_en = true;
- msta->deflink.wcid.amsdu = true;

- switch (sta->deflink.agg.max_amsdu_len) {
+ mlink = mt792x_sta_to_link(msta, link_sta->link_id);
+ mlink->wcid.amsdu = true;
+
+ switch (link_sta->agg.max_amsdu_len) {
case IEEE80211_MAX_MPDU_LEN_VHT_11454:
amsdu->max_mpdu_size =
IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454;
@@ -1639,7 +1643,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,
mt7925_mcu_sta_ht_tlv(skb, info->link_sta->sta);
mt7925_mcu_sta_vht_tlv(skb, info->link_sta->sta);
mt76_connac_mcu_sta_uapsd(skb, info->vif, info->link_sta->sta);
- mt7925_mcu_sta_amsdu_tlv(skb, info->vif, info->link_sta->sta);
+ mt7925_mcu_sta_amsdu_tlv(skb, info->vif, info->link_sta);
mt7925_mcu_sta_he_tlv(skb, info->link_sta);
mt7925_mcu_sta_he_6g_tlv(skb, info->link_sta);
mt7925_mcu_sta_eht_tlv(skb, info->link_sta);
--
2.34.1


2024-06-13 03:13:00

by Sean Wang

[permalink] [raw]
Subject: [PATCH 33/47] wifi: mt76: mt7925: extend mt7925_mcu_sta_phy_tlv for per-link STA

From: Sean Wang <[email protected]>

Extend mt7925_mcu_sta_phy_tlv with per-link STA configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Ming Yen Hsieh <[email protected]>
Signed-off-by: Ming Yen Hsieh <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7925/mcu.c | 35 ++++++++++++-------
1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 66d45d676739..a0fd02dd9551 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1507,34 +1507,43 @@ mt7925_mcu_sta_amsdu_tlv(struct sk_buff *skb,

static void
mt7925_mcu_sta_phy_tlv(struct sk_buff *skb,
- struct ieee80211_vif *vif, struct ieee80211_sta *sta)
+ struct ieee80211_vif *vif,
+ struct ieee80211_link_sta *link_sta)
{
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
- struct cfg80211_chan_def *chandef = &mvif->bss_conf.mt76.ctx->def;
+ struct ieee80211_bss_conf *link_conf;
+ struct cfg80211_chan_def *chandef;
+ struct mt792x_bss_conf *mconf;
struct sta_rec_phy *phy;
struct tlv *tlv;
u8 af = 0, mm = 0;

+ link_conf = mt792x_vif_to_bss_conf(vif, link_sta->link_id);
+ mconf = mt792x_vif_to_link(mvif, link_sta->link_id);
+ chandef = &mconf->mt76.ctx->def;
+
tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_PHY, sizeof(*phy));
phy = (struct sta_rec_phy *)tlv;
- phy->phy_type = mt76_connac_get_phy_mode_v2(mvif->phy->mt76, vif, chandef->chan->band, sta);
- phy->basic_rate = cpu_to_le16((u16)vif->bss_conf.basic_rates);
- if (sta->deflink.ht_cap.ht_supported) {
- af = sta->deflink.ht_cap.ampdu_factor;
- mm = sta->deflink.ht_cap.ampdu_density;
+ phy->phy_type = mt76_connac_get_phy_mode_v2(mvif->phy->mt76, vif,
+ chandef->chan->band,
+ link_sta->sta);
+ phy->basic_rate = cpu_to_le16((u16)link_conf->basic_rates);
+ if (link_sta->ht_cap.ht_supported) {
+ af = link_sta->ht_cap.ampdu_factor;
+ mm = link_sta->ht_cap.ampdu_density;
}

- if (sta->deflink.vht_cap.vht_supported) {
+ if (link_sta->vht_cap.vht_supported) {
u8 vht_af = FIELD_GET(IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK,
- sta->deflink.vht_cap.cap);
+ link_sta->vht_cap.cap);

af = max_t(u8, af, vht_af);
}

- if (sta->deflink.he_6ghz_capa.capa) {
- af = le16_get_bits(sta->deflink.he_6ghz_capa.capa,
+ if (link_sta->he_6ghz_capa.capa) {
+ af = le16_get_bits(link_sta->he_6ghz_capa.capa,
IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP);
- mm = le16_get_bits(sta->deflink.he_6ghz_capa.capa,
+ mm = le16_get_bits(link_sta->he_6ghz_capa.capa,
IEEE80211_HE_6GHZ_CAP_MIN_MPDU_START);
}

@@ -1639,7 +1648,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,
info->link_sta->sta,
info->enable, info->newly);
if (info->link_sta && info->enable) {
- mt7925_mcu_sta_phy_tlv(skb, info->vif, info->link_sta->sta);
+ mt7925_mcu_sta_phy_tlv(skb, info->vif, info->link_sta);
mt7925_mcu_sta_ht_tlv(skb, info->link_sta);
mt7925_mcu_sta_vht_tlv(skb, info->link_sta);
mt76_connac_mcu_sta_uapsd(skb, info->vif, info->link_sta->sta);
--
2.34.1