blob: b1e017c2e7855901dd592b16f6db9990e92b6163 [file] [log] [blame]
developerd0c89452024-10-11 16:53:27 +08001From 2e58003c154277e36f759a53975c61cbecb9af02 Mon Sep 17 00:00:00 2001
developer66e89bc2024-04-23 14:50:01 +08002From: Shayne Chen <shayne.chen@mediatek.com>
3Date: Mon, 11 Dec 2023 18:45:00 +0800
developerd0c89452024-10-11 16:53:27 +08004Subject: [PATCH 091/223] mtk: mt76: rework connac helpers
developer66e89bc2024-04-23 14:50:01 +08005
6Rework connac helpers related to rate and phymode.
7This is a preliminary patch to add MLO support for mt7996 chipsets.
8
9Co-developed-by: Bo Jiao <Bo.Jiao@mediatek.com>
10Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
11Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
12---
13 mt76_connac.h | 2 +-
14 mt76_connac_mac.c | 17 ++++++++---------
15 mt76_connac_mcu.c | 6 +++---
16 mt76_connac_mcu.h | 2 +-
17 mt7925/main.c | 2 +-
18 mt7996/main.c | 2 +-
19 mt7996/mcu.c | 2 +-
20 7 files changed, 16 insertions(+), 17 deletions(-)
21
22diff --git a/mt76_connac.h b/mt76_connac.h
developer05f3b2b2024-08-19 19:17:34 +080023index 445d0f0a..f7766a98 100644
developer66e89bc2024-04-23 14:50:01 +080024--- a/mt76_connac.h
25+++ b/mt76_connac.h
26@@ -427,7 +427,7 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
27 struct ieee80211_key_conf *key, int pid,
28 enum mt76_txq_id qid, u32 changed);
29 u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
30- struct ieee80211_vif *vif,
31+ struct ieee80211_bss_conf *conf,
32 bool beacon, bool mcast);
33 bool mt76_connac2_mac_fill_txs(struct mt76_dev *dev, struct mt76_wcid *wcid,
34 __le32 *txs_data);
35diff --git a/mt76_connac_mac.c b/mt76_connac_mac.c
developerd0c89452024-10-11 16:53:27 +080036index a72551ba..e58570c2 100644
developer66e89bc2024-04-23 14:50:01 +080037--- a/mt76_connac_mac.c
38+++ b/mt76_connac_mac.c
39@@ -291,12 +291,11 @@ EXPORT_SYMBOL_GPL(mt76_connac_init_tx_queues);
40 })
41
42 u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
43- struct ieee80211_vif *vif,
44+ struct ieee80211_bss_conf *conf,
45 bool beacon, bool mcast)
46 {
47- struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
48- struct cfg80211_chan_def *chandef = mvif->ctx ?
49- &mvif->ctx->def : &mphy->chandef;
50+ struct ieee80211_vif *vif = conf->vif;
51+ struct cfg80211_chan_def *chandef = &mphy->chandef;
52 u8 nss = 0, mode = 0, band = chandef->chan->band;
53 int rateidx = 0, mcast_rate;
developerd0c89452024-10-11 16:53:27 +080054 int offset = 0;
55@@ -305,14 +304,14 @@ u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
developer66e89bc2024-04-23 14:50:01 +080056 goto legacy;
57
58 if (is_mt7921(mphy->dev)) {
59- rateidx = ffs(vif->bss_conf.basic_rates) - 1;
60+ rateidx = ffs(conf->basic_rates) - 1;
61 goto legacy;
62 }
63
64 if (beacon) {
65 struct cfg80211_bitrate_mask *mask;
66
67- mask = &vif->bss_conf.beacon_tx_rate;
68+ mask = &conf->beacon_tx_rate;
69
70 __bitrate_mask_check(he_mcs, HE_SU);
71 __bitrate_mask_check(vht_mcs, VHT);
developerd0c89452024-10-11 16:53:27 +080072@@ -324,11 +323,11 @@ u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
developer66e89bc2024-04-23 14:50:01 +080073 }
74 }
75
76- mcast_rate = vif->bss_conf.mcast_rate[band];
77+ mcast_rate = conf->mcast_rate[band];
78 if (mcast && mcast_rate > 0)
79 rateidx = mcast_rate - 1;
80 else
81- rateidx = ffs(vif->bss_conf.basic_rates) - 1;
82+ rateidx = ffs(conf->basic_rates) - 1;
83
84 legacy:
developerd0c89452024-10-11 16:53:27 +080085 if (band != NL80211_BAND_2GHZ)
86@@ -581,7 +580,7 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
developer66e89bc2024-04-23 14:50:01 +080087 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
88 bool multicast = ieee80211_is_data(hdr->frame_control) &&
89 is_multicast_ether_addr(hdr->addr1);
90- u16 rate = mt76_connac2_mac_tx_rate_val(mphy, vif, beacon,
91+ u16 rate = mt76_connac2_mac_tx_rate_val(mphy, &vif->bss_conf, beacon,
92 multicast);
93 u32 val = MT_TXD6_FIXED_BW;
94
95diff --git a/mt76_connac_mcu.c b/mt76_connac_mcu.c
developerd0c89452024-10-11 16:53:27 +080096index 0c89222b..e4e6c0d3 100644
developer66e89bc2024-04-23 14:50:01 +080097--- a/mt76_connac_mcu.c
98+++ b/mt76_connac_mcu.c
developerd0c89452024-10-11 16:53:27 +080099@@ -1368,7 +1368,7 @@ u8 mt76_connac_get_phy_mode(struct mt76_phy *phy, struct ieee80211_vif *vif,
developer66e89bc2024-04-23 14:50:01 +0800100 }
101 EXPORT_SYMBOL_GPL(mt76_connac_get_phy_mode);
102
103-u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif,
104+u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_bss_conf *conf,
105 enum nl80211_band band)
106 {
107 const struct ieee80211_sta_eht_cap *eht_cap;
developerd0c89452024-10-11 16:53:27 +0800108@@ -1379,9 +1379,9 @@ u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif,
developer66e89bc2024-04-23 14:50:01 +0800109 mode |= PHY_MODE_AX_6G;
110
111 sband = phy->hw->wiphy->bands[band];
112- eht_cap = ieee80211_get_eht_iftype_cap(sband, vif->type);
113+ eht_cap = ieee80211_get_eht_iftype_cap(sband, conf->vif->type);
114
115- if (!eht_cap || !eht_cap->has_eht || !vif->bss_conf.eht_support)
116+ if (!eht_cap || !eht_cap->has_eht || !conf->eht_support)
117 return mode;
118
119 switch (band) {
120diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
developerd0c89452024-10-11 16:53:27 +0800121index ff8a314c..1dcd1696 100644
developer66e89bc2024-04-23 14:50:01 +0800122--- a/mt76_connac_mcu.h
123+++ b/mt76_connac_mcu.h
developerd0c89452024-10-11 16:53:27 +0800124@@ -2041,7 +2041,7 @@ mt76_connac_get_eht_phy_cap(struct mt76_phy *phy, struct ieee80211_vif *vif);
developer66e89bc2024-04-23 14:50:01 +0800125 u8 mt76_connac_get_phy_mode(struct mt76_phy *phy, struct ieee80211_vif *vif,
126 enum nl80211_band band,
developer05f3b2b2024-08-19 19:17:34 +0800127 struct ieee80211_link_sta *sta);
developer66e89bc2024-04-23 14:50:01 +0800128-u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif,
129+u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_bss_conf *conf,
130 enum nl80211_band band);
131
132 int mt76_connac_mcu_add_key(struct mt76_dev *dev, struct ieee80211_vif *vif,
133diff --git a/mt7925/main.c b/mt7925/main.c
developerd0c89452024-10-11 16:53:27 +0800134index 791c8b00..147b71e7 100644
developer66e89bc2024-04-23 14:50:01 +0800135--- a/mt7925/main.c
136+++ b/mt7925/main.c
developerd0c89452024-10-11 16:53:27 +0800137@@ -806,7 +806,7 @@ mt7925_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developer66e89bc2024-04-23 14:50:01 +0800138 u16 rate;
139 u8 i, idx, ht;
140
141- rate = mt76_connac2_mac_tx_rate_val(mphy, vif, beacon, mcast);
142+ rate = mt76_connac2_mac_tx_rate_val(mphy, &vif->bss_conf, beacon, mcast);
143 ht = FIELD_GET(MT_TX_RATE_MODE, rate) > MT_PHY_TYPE_OFDM;
144
145 if (beacon && ht) {
146diff --git a/mt7996/main.c b/mt7996/main.c
developerd0c89452024-10-11 16:53:27 +0800147index cadfee9f..68234032 100644
developer66e89bc2024-04-23 14:50:01 +0800148--- a/mt7996/main.c
149+++ b/mt7996/main.c
developerd0c89452024-10-11 16:53:27 +0800150@@ -802,7 +802,7 @@ mt7996_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_bss_conf *conf,
developer66e89bc2024-04-23 14:50:01 +0800151 u16 rate;
152 u8 i, idx;
153
154- rate = mt76_connac2_mac_tx_rate_val(mphy, conf->vif, beacon, mcast);
155+ rate = mt76_connac2_mac_tx_rate_val(mphy, conf, beacon, mcast);
156
157 if (beacon) {
158 struct mt7996_phy *phy = mphy->priv;
159diff --git a/mt7996/mcu.c b/mt7996/mcu.c
developerd0c89452024-10-11 16:53:27 +0800160index 7b77cab2..edaf8814 100644
developer66e89bc2024-04-23 14:50:01 +0800161--- a/mt7996/mcu.c
162+++ b/mt7996/mcu.c
developerd0c89452024-10-11 16:53:27 +0800163@@ -1224,7 +1224,7 @@ mt7996_mcu_bss_basic_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *conf,
developer66e89bc2024-04-23 14:50:01 +0800164 bss->dtim_period = conf->dtim_period;
165 bss->phymode = mt76_connac_get_phy_mode(phy, vif,
166 chandef->chan->band, NULL);
167- bss->phymode_ext = mt76_connac_get_phy_mode_ext(phy, vif,
168+ bss->phymode_ext = mt76_connac_get_phy_mode_ext(phy, conf,
169 chandef->chan->band);
170
171 return 0;
172--
developerd0c89452024-10-11 16:53:27 +08001732.45.2
developer66e89bc2024-04-23 14:50:01 +0800174