developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1 | From bb417654387169098f02664031be303d1f1a7f16 Mon Sep 17 00:00:00 2001 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2 | From: Shayne Chen <shayne.chen@mediatek.com> |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 3 | Date: Mon, 27 Nov 2023 10:43:34 +0800 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 091/199] mtk: mt76: mt7996: switch to per-link data structure |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 5 | of sta |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 6 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 7 | Introduce struct mt7996_link_sta, data structure for per-link STA. |
| 8 | Note that mt7996_sta now represents a peer legacy or MLD device. |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 9 | This is a preliminary patch to add MLO support for mt7996 chipsets. |
| 10 | |
| 11 | Co-developed-by: Bo Jiao <Bo.Jiao@mediatek.com> |
| 12 | Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com> |
| 13 | Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> |
| 14 | --- |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 15 | mt7996/debugfs.c | 20 ++- |
| 16 | mt7996/mac.c | 109 ++++++------ |
| 17 | mt7996/main.c | 223 +++++++++++++++--------- |
| 18 | mt7996/mcu.c | 430 ++++++++++++++++++++++++---------------------- |
| 19 | mt7996/mt7996.h | 44 +++-- |
| 20 | mt7996/testmode.c | 6 +- |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 21 | 6 files changed, 461 insertions(+), 371 deletions(-) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 22 | |
| 23 | diff --git a/mt7996/debugfs.c b/mt7996/debugfs.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 24 | index 5d4d69ea..62658dbc 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 25 | --- a/mt7996/debugfs.c |
| 26 | +++ b/mt7996/debugfs.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 27 | @@ -726,14 +726,15 @@ static void |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 28 | mt7996_sta_hw_queue_read(void *data, struct ieee80211_sta *sta) |
| 29 | { |
| 30 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 31 | + struct mt7996_link_sta *mlink = &msta->deflink; |
| 32 | struct mt7996_dev *dev = msta->vif->deflink.phy->dev; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 33 | struct seq_file *s = data; |
| 34 | u8 ac; |
| 35 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 36 | for (ac = 0; ac < 4; ac++) { |
| 37 | u32 qlen, ctrl, val; |
| 38 | - u32 idx = msta->wcid.idx >> 5; |
| 39 | - u8 offs = msta->wcid.idx & GENMASK(4, 0); |
| 40 | + u32 idx = mlink->wcid.idx >> 5; |
| 41 | + u8 offs = mlink->wcid.idx & GENMASK(4, 0); |
| 42 | |
| 43 | ctrl = BIT(31) | BIT(11) | (ac << 24); |
| 44 | val = mt76_rr(dev, MT_PLE_AC_QEMPTY(ac, idx)); |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 45 | @@ -741,11 +742,11 @@ mt7996_sta_hw_queue_read(void *data, struct ieee80211_sta *sta) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 46 | if (val & BIT(offs)) |
| 47 | continue; |
| 48 | |
| 49 | - mt76_wr(dev, MT_FL_Q0_CTRL, ctrl | msta->wcid.idx); |
| 50 | + mt76_wr(dev, MT_FL_Q0_CTRL, ctrl | mlink->wcid.idx); |
| 51 | qlen = mt76_get_field(dev, MT_FL_Q3_CTRL, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 52 | GENMASK(11, 0)); |
| 53 | seq_printf(s, "\tSTA %pM wcid %d: AC%d%d queued:%d\n", |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 54 | - sta->addr, msta->wcid.idx, |
| 55 | + sta->addr, mlink->wcid.idx, |
| 56 | msta->vif->deflink.mt76.wmm_idx, ac, qlen); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 57 | } |
| 58 | } |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 59 | @@ -1028,7 +1029,7 @@ mt7996_airtime_read(struct seq_file *s, void *data) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 60 | struct mt76_dev *mdev = &dev->mt76; |
| 61 | struct mt76_sta_stats *stats; |
| 62 | struct ieee80211_sta *sta; |
| 63 | - struct mt7996_sta *msta; |
| 64 | + struct mt7996_link_sta *mlink; |
| 65 | struct mt76_wcid *wcid; |
| 66 | struct mt76_vif *vif; |
| 67 | u16 i; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 68 | @@ -1040,9 +1041,9 @@ mt7996_airtime_read(struct seq_file *s, void *data) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 69 | if (!wcid || !wcid->sta) |
| 70 | continue; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 71 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 72 | - msta = container_of(wcid, struct mt7996_sta, wcid); |
| 73 | - sta = container_of((void *)msta, struct ieee80211_sta, drv_priv); |
| 74 | - vif = &msta->vif->deflink.mt76; |
| 75 | + mlink = container_of(wcid, struct mt7996_link_sta, wcid); |
| 76 | + sta = container_of((void *)mlink->sta, struct ieee80211_sta, drv_priv); |
| 77 | + vif = &mlink->sta->vif->deflink.mt76; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 78 | stats = &wcid->stats; |
| 79 | |
| 80 | seq_printf(s, "%pM WCID: %hu BandIdx: %hhu OmacIdx: 0x%hhx\t" |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 81 | @@ -1217,6 +1218,7 @@ static ssize_t mt7996_sta_fixed_rate_set(struct file *file, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 82 | #define LONG_PREAMBLE 1 |
| 83 | struct ieee80211_sta *sta = file->private_data; |
| 84 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 85 | + struct mt7996_link_sta *mlink = &msta->deflink; |
| 86 | struct mt7996_dev *dev = msta->vif->deflink.phy->dev; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 87 | struct ra_rate phy = {}; |
| 88 | char buf[100]; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 89 | @@ -1252,7 +1254,7 @@ static ssize_t mt7996_sta_fixed_rate_set(struct file *file, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 90 | goto out; |
| 91 | } |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 92 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 93 | - phy.wlan_idx = cpu_to_le16(msta->wcid.idx); |
| 94 | + phy.wlan_idx = cpu_to_le16(mlink->wcid.idx); |
| 95 | phy.gi = cpu_to_le16(gi); |
| 96 | phy.ltf = cpu_to_le16(ltf); |
| 97 | phy.ldpc = phy.ldpc ? 7 : 0; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 98 | diff --git a/mt7996/mac.c b/mt7996/mac.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 99 | index 5fbcfc74..fbe6c0bd 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 100 | --- a/mt7996/mac.c |
| 101 | +++ b/mt7996/mac.c |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 102 | @@ -54,7 +54,7 @@ static const struct mt7996_dfs_radar_spec jp_radar_specs = { |
| 103 | static struct mt76_wcid *mt7996_rx_get_wcid(struct mt7996_dev *dev, |
| 104 | u16 idx, bool unicast) |
| 105 | { |
| 106 | - struct mt7996_sta *sta; |
| 107 | + struct mt7996_link_sta *mlink; |
| 108 | struct mt76_wcid *wcid; |
| 109 | |
| 110 | if (idx >= ARRAY_SIZE(dev->mt76.wcid)) |
| 111 | @@ -67,11 +67,11 @@ static struct mt76_wcid *mt7996_rx_get_wcid(struct mt7996_dev *dev, |
| 112 | if (!wcid->sta) |
| 113 | return NULL; |
| 114 | |
| 115 | - sta = container_of(wcid, struct mt7996_sta, wcid); |
| 116 | - if (!sta->vif) |
| 117 | + mlink = container_of(wcid, struct mt7996_link_sta, wcid); |
| 118 | + if (!mlink->sta->vif) |
| 119 | return NULL; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 120 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 121 | - return &sta->vif->sta.wcid; |
| 122 | + return &mlink->wcid; |
| 123 | } |
| 124 | |
| 125 | bool mt7996_mac_wtbl_update(struct mt7996_dev *dev, int idx, u32 mask) |
| 126 | @@ -92,12 +92,11 @@ u32 mt7996_mac_wtbl_lmac_addr(struct mt7996_dev *dev, u16 wcid, u8 dw) |
| 127 | } |
| 128 | |
| 129 | void mt7996_mac_enable_rtscts(struct mt7996_dev *dev, |
| 130 | - struct ieee80211_vif *vif, bool enable) |
| 131 | + struct mt7996_link_sta *mlink, bool enable) |
| 132 | { |
| 133 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 134 | u32 addr; |
| 135 | |
| 136 | - addr = mt7996_mac_wtbl_lmac_addr(dev, mvif->sta.wcid.idx, 5); |
| 137 | + addr = mt7996_mac_wtbl_lmac_addr(dev, mlink->wcid.idx, 5); |
| 138 | if (enable) |
| 139 | mt76_set(dev, addr, BIT(5)); |
| 140 | else |
| 141 | @@ -349,7 +348,7 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q, |
| 142 | __le16 fc = 0; |
| 143 | int idx; |
| 144 | u8 hw_aggr = false; |
| 145 | - struct mt7996_sta *msta = NULL; |
| 146 | + struct mt7996_link_sta *mlink = NULL; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 147 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 148 | hw_aggr = status->aggr; |
| 149 | memset(status, 0, sizeof(*status)); |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 150 | @@ -378,10 +377,10 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 151 | status->wcid = mt7996_rx_get_wcid(dev, idx, unicast); |
| 152 | |
| 153 | if (status->wcid) { |
| 154 | - msta = container_of(status->wcid, struct mt7996_sta, wcid); |
| 155 | + mlink = container_of(status->wcid, struct mt7996_link_sta, wcid); |
| 156 | spin_lock_bh(&dev->mt76.sta_poll_lock); |
| 157 | - if (list_empty(&msta->wcid.poll_list)) |
| 158 | - list_add_tail(&msta->wcid.poll_list, |
| 159 | + if (list_empty(&mlink->wcid.poll_list)) |
| 160 | + list_add_tail(&mlink->wcid.poll_list, |
| 161 | &dev->mt76.sta_poll_list); |
| 162 | spin_unlock_bh(&dev->mt76.sta_poll_lock); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 163 | } |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 164 | @@ -586,7 +585,7 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 165 | #endif |
| 166 | } else { |
| 167 | status->flag |= RX_FLAG_8023; |
| 168 | - mt7996_wed_check_ppe(dev, &dev->mt76.q_rx[q], msta, skb, |
| 169 | + mt7996_wed_check_ppe(dev, &dev->mt76.q_rx[q], mlink ? mlink->sta : NULL, skb, |
| 170 | *info); |
| 171 | } |
| 172 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 173 | @@ -945,6 +944,7 @@ static void |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 174 | mt7996_tx_check_aggr(struct ieee80211_sta *sta, struct sk_buff *skb) |
| 175 | { |
| 176 | struct mt7996_sta *msta; |
| 177 | + struct mt7996_link_sta *mlink; |
| 178 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
| 179 | bool is_8023 = info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP; |
| 180 | u16 fc, tid; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 181 | @@ -973,7 +973,8 @@ mt7996_tx_check_aggr(struct ieee80211_sta *sta, struct sk_buff *skb) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 182 | return; |
| 183 | |
| 184 | msta = (struct mt7996_sta *)sta->drv_priv; |
| 185 | - if (!test_and_set_bit(tid, &msta->wcid.ampdu_state)) |
| 186 | + mlink = rcu_dereference(msta->link[0]); |
| 187 | + if (!test_and_set_bit(tid, &mlink->wcid.ampdu_state)) |
| 188 | ieee80211_start_tx_ba_session(sta, tid, 0); |
| 189 | } |
| 190 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 191 | @@ -1051,7 +1052,7 @@ mt7996_mac_tx_free(struct mt7996_dev *dev, void *data, int len) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 192 | */ |
| 193 | info = le32_to_cpu(*cur_info); |
| 194 | if (info & MT_TXFREE_INFO_PAIR) { |
| 195 | - struct mt7996_sta *msta; |
| 196 | + struct mt7996_link_sta *mlink; |
| 197 | u16 idx; |
| 198 | |
| 199 | idx = FIELD_GET(MT_TXFREE_INFO_WLAN_ID, info); |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 200 | @@ -1060,10 +1061,10 @@ mt7996_mac_tx_free(struct mt7996_dev *dev, void *data, int len) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 201 | if (!sta) |
| 202 | continue; |
| 203 | |
| 204 | - msta = container_of(wcid, struct mt7996_sta, wcid); |
| 205 | + mlink = container_of(wcid, struct mt7996_link_sta, wcid); |
| 206 | spin_lock_bh(&mdev->sta_poll_lock); |
| 207 | - if (list_empty(&msta->wcid.poll_list)) |
| 208 | - list_add_tail(&msta->wcid.poll_list, |
| 209 | + if (list_empty(&mlink->wcid.poll_list)) |
| 210 | + list_add_tail(&mlink->wcid.poll_list, |
| 211 | &mdev->sta_poll_list); |
| 212 | spin_unlock_bh(&mdev->sta_poll_lock); |
| 213 | continue; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 214 | @@ -1268,7 +1269,7 @@ out: |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 215 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 216 | static void mt7996_mac_add_txs(struct mt7996_dev *dev, void *data) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 217 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 218 | - struct mt7996_sta *msta = NULL; |
| 219 | + struct mt7996_link_sta *mlink; |
| 220 | struct mt76_wcid *wcid; |
| 221 | __le32 *txs_data = data; |
| 222 | u16 wcidx; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 223 | @@ -1289,16 +1290,15 @@ static void mt7996_mac_add_txs(struct mt7996_dev *dev, void *data) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 224 | if (!wcid) |
| 225 | goto out; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 226 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 227 | - msta = container_of(wcid, struct mt7996_sta, wcid); |
| 228 | - |
| 229 | mt7996_mac_add_txs_skb(dev, wcid, pid, txs_data); |
| 230 | |
| 231 | if (!wcid->sta) |
| 232 | goto out; |
| 233 | |
| 234 | + mlink = container_of(wcid, struct mt7996_link_sta, wcid); |
| 235 | spin_lock_bh(&dev->mt76.sta_poll_lock); |
| 236 | - if (list_empty(&msta->wcid.poll_list)) |
| 237 | - list_add_tail(&msta->wcid.poll_list, &dev->mt76.sta_poll_list); |
| 238 | + if (list_empty(&mlink->wcid.poll_list)) |
| 239 | + list_add_tail(&mlink->wcid.poll_list, &dev->mt76.sta_poll_list); |
| 240 | spin_unlock_bh(&dev->mt76.sta_poll_lock); |
| 241 | |
| 242 | out: |
| 243 | @@ -2242,8 +2242,9 @@ void mt7996_mac_sta_rc_work(struct work_struct *work) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 244 | struct ieee80211_sta *sta; |
| 245 | struct ieee80211_vif *vif; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 246 | struct ieee80211_bss_conf *conf; |
| 247 | + struct ieee80211_link_sta *link_sta; |
| 248 | struct mt7996_bss_conf *mconf; |
| 249 | - struct mt7996_sta *msta; |
| 250 | + struct mt7996_link_sta *mlink; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 251 | u32 changed; |
| 252 | LIST_HEAD(list); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 253 | |
| 254 | @@ -2251,24 +2252,25 @@ void mt7996_mac_sta_rc_work(struct work_struct *work) |
| 255 | list_splice_init(&dev->sta_rc_list, &list); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 256 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 257 | while (!list_empty(&list)) { |
| 258 | - msta = list_first_entry(&list, struct mt7996_sta, rc_list); |
| 259 | - list_del_init(&msta->rc_list); |
| 260 | - changed = msta->changed; |
| 261 | - msta->changed = 0; |
| 262 | + mlink = list_first_entry(&list, struct mt7996_link_sta, rc_list); |
| 263 | + list_del_init(&mlink->rc_list); |
| 264 | + changed = mlink->changed; |
| 265 | + mlink->changed = 0; |
| 266 | spin_unlock_bh(&dev->mt76.sta_poll_lock); |
| 267 | |
| 268 | - sta = container_of((void *)msta, struct ieee80211_sta, drv_priv); |
| 269 | - vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv); |
| 270 | + sta = container_of((void *)mlink->sta, struct ieee80211_sta, drv_priv); |
| 271 | + link_sta = &sta->deflink; |
| 272 | + vif = container_of((void *)mlink->sta->vif, struct ieee80211_vif, drv_priv); |
| 273 | conf = &vif->bss_conf; |
| 274 | - mconf = &msta->vif->deflink; |
| 275 | + mconf = &mlink->sta->vif->deflink; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 276 | |
| 277 | if (changed & (IEEE80211_RC_SUPP_RATES_CHANGED | |
| 278 | IEEE80211_RC_NSS_CHANGED | |
| 279 | IEEE80211_RC_BW_CHANGED)) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 280 | - mt7996_mcu_add_rate_ctrl(dev, conf, mconf, sta, true); |
| 281 | + mt7996_mcu_add_rate_ctrl(dev, conf, mconf, link_sta, mlink, true); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 282 | |
| 283 | if (changed & IEEE80211_RC_SMPS_CHANGED) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 284 | - mt7996_mcu_set_fixed_field(dev, mconf, sta, NULL, |
| 285 | + mt7996_mcu_set_fixed_field(dev, mconf, link_sta, mlink, NULL, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 286 | RATE_PARAM_MMPS_UPDATE); |
| 287 | |
| 288 | spin_lock_bh(&dev->mt76.sta_poll_lock); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 289 | @@ -2561,7 +2563,7 @@ static int mt7996_mac_check_twt_req(struct ieee80211_twt_setup *twt) |
| 290 | } |
| 291 | |
| 292 | static bool |
| 293 | -mt7996_mac_twt_param_equal(struct mt7996_sta *msta, |
| 294 | +mt7996_mac_twt_param_equal(struct mt7996_link_sta *mlink, |
| 295 | struct ieee80211_twt_params *twt_agrt) |
| 296 | { |
| 297 | u16 type = le16_to_cpu(twt_agrt->req_type); |
| 298 | @@ -2572,10 +2574,10 @@ mt7996_mac_twt_param_equal(struct mt7996_sta *msta, |
| 299 | for (i = 0; i < MT7996_MAX_STA_TWT_AGRT; i++) { |
| 300 | struct mt7996_twt_flow *f; |
| 301 | |
| 302 | - if (!(msta->twt.flowid_mask & BIT(i))) |
| 303 | + if (!(mlink->twt.flowid_mask & BIT(i))) |
| 304 | continue; |
| 305 | |
| 306 | - f = &msta->twt.flow[i]; |
| 307 | + f = &mlink->twt.flow[i]; |
| 308 | if (f->duration == twt_agrt->min_twt_dur && |
| 309 | f->mantissa == twt_agrt->mantissa && |
| 310 | f->exp == exp && |
| 311 | @@ -2594,6 +2596,7 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw, |
| 312 | { |
| 313 | enum ieee80211_twt_setup_cmd setup_cmd = TWT_SETUP_CMD_REJECT; |
| 314 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 315 | + struct mt7996_link_sta *mlink; |
| 316 | struct ieee80211_twt_params *twt_agrt = (void *)twt->params; |
| 317 | u16 req_type = le16_to_cpu(twt_agrt->req_type); |
| 318 | enum ieee80211_twt_setup_cmd sta_setup_cmd; |
| 319 | @@ -2605,11 +2608,12 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw, |
| 320 | goto out; |
| 321 | |
| 322 | mutex_lock(&dev->mt76.mutex); |
| 323 | + mlink = mlink_dereference_protected(msta, 0); |
| 324 | |
| 325 | if (dev->twt.n_agrt == MT7996_MAX_TWT_AGRT) |
| 326 | goto unlock; |
| 327 | |
| 328 | - if (hweight8(msta->twt.flowid_mask) == ARRAY_SIZE(msta->twt.flow)) |
| 329 | + if (hweight8(mlink->twt.flowid_mask) == ARRAY_SIZE(mlink->twt.flow)) |
| 330 | goto unlock; |
| 331 | |
| 332 | if (twt_agrt->min_twt_dur < MT7996_MIN_TWT_DUR) { |
| 333 | @@ -2618,10 +2622,10 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw, |
| 334 | goto unlock; |
| 335 | } |
| 336 | |
| 337 | - if (mt7996_mac_twt_param_equal(msta, twt_agrt)) |
| 338 | + if (mt7996_mac_twt_param_equal(mlink, twt_agrt)) |
| 339 | goto unlock; |
| 340 | |
| 341 | - flowid = ffs(~msta->twt.flowid_mask) - 1; |
| 342 | + flowid = ffs(~mlink->twt.flowid_mask) - 1; |
| 343 | twt_agrt->req_type &= ~cpu_to_le16(IEEE80211_TWT_REQTYPE_FLOWID); |
| 344 | twt_agrt->req_type |= le16_encode_bits(flowid, |
| 345 | IEEE80211_TWT_REQTYPE_FLOWID); |
| 346 | @@ -2630,10 +2634,10 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw, |
| 347 | exp = FIELD_GET(IEEE80211_TWT_REQTYPE_WAKE_INT_EXP, req_type); |
| 348 | sta_setup_cmd = FIELD_GET(IEEE80211_TWT_REQTYPE_SETUP_CMD, req_type); |
| 349 | |
| 350 | - flow = &msta->twt.flow[flowid]; |
| 351 | + flow = &mlink->twt.flow[flowid]; |
| 352 | memset(flow, 0, sizeof(*flow)); |
| 353 | INIT_LIST_HEAD(&flow->list); |
| 354 | - flow->wcid = msta->wcid.idx; |
| 355 | + flow->wcid = mlink->wcid.idx; |
| 356 | flow->table_id = table_id; |
| 357 | flow->id = flowid; |
| 358 | flow->duration = twt_agrt->min_twt_dur; |
| 359 | @@ -2651,7 +2655,7 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 360 | |
| 361 | flow->sched = true; |
| 362 | flow->start_tsf = mt7996_mac_twt_sched_list_add(dev, flow); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 363 | - curr_tsf = __mt7996_get_tsf(hw, &msta->vif->deflink); |
| 364 | + curr_tsf = __mt7996_get_tsf(hw, &mlink->sta->vif->deflink); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 365 | div_u64_rem(curr_tsf - flow->start_tsf, interval, &rem); |
| 366 | flow_tsf = curr_tsf + interval - rem; |
| 367 | twt_agrt->twt = cpu_to_le64(flow_tsf); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 368 | @@ -2660,13 +2664,13 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 369 | } |
| 370 | flow->tsf = le64_to_cpu(twt_agrt->twt); |
| 371 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 372 | - if (mt7996_mcu_twt_agrt_update(dev, &msta->vif->deflink, flow, |
| 373 | + if (mt7996_mcu_twt_agrt_update(dev, &mlink->sta->vif->deflink, flow, |
| 374 | MCU_TWT_AGRT_ADD)) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 375 | goto unlock; |
| 376 | |
| 377 | setup_cmd = TWT_SETUP_CMD_ACCEPT; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 378 | dev->twt.table_mask |= BIT(table_id); |
| 379 | - msta->twt.flowid_mask |= BIT(flowid); |
| 380 | + mlink->twt.flowid_mask |= BIT(flowid); |
| 381 | dev->twt.n_agrt++; |
| 382 | |
| 383 | unlock: |
| 384 | @@ -2679,26 +2683,25 @@ out: |
| 385 | } |
| 386 | |
| 387 | void mt7996_mac_twt_teardown_flow(struct mt7996_dev *dev, |
| 388 | - struct mt7996_sta *msta, |
| 389 | - u8 flowid) |
| 390 | + struct mt7996_link_sta *mlink, u8 flowid) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 391 | { |
| 392 | struct mt7996_twt_flow *flow; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 393 | - struct mt7996_bss_conf *mconf = mconf_dereference_protected(msta->vif, 0); |
| 394 | + struct mt7996_bss_conf *mconf = mconf_dereference_protected(mlink->sta->vif, 0); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 395 | |
| 396 | lockdep_assert_held(&dev->mt76.mutex); |
| 397 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 398 | - if (flowid >= ARRAY_SIZE(msta->twt.flow)) |
| 399 | + if (flowid >= ARRAY_SIZE(mlink->twt.flow)) |
| 400 | return; |
| 401 | |
| 402 | - if (!(msta->twt.flowid_mask & BIT(flowid))) |
| 403 | + if (!(mlink->twt.flowid_mask & BIT(flowid))) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 404 | return; |
| 405 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 406 | - flow = &msta->twt.flow[flowid]; |
| 407 | + flow = &mlink->twt.flow[flowid]; |
| 408 | if (mt7996_mcu_twt_agrt_update(dev, mconf, flow, MCU_TWT_AGRT_DELETE)) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 409 | return; |
| 410 | |
| 411 | list_del_init(&flow->list); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 412 | - msta->twt.flowid_mask &= ~BIT(flowid); |
| 413 | + mlink->twt.flowid_mask &= ~BIT(flowid); |
| 414 | dev->twt.table_mask &= ~BIT(flow->table_id); |
| 415 | dev->twt.n_agrt--; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 416 | } |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 417 | @@ -2711,7 +2714,7 @@ mt7996_scan_send_probe(struct mt7996_phy *phy, struct cfg80211_ssid *ssid, |
| 418 | struct cfg80211_scan_request *req = phy->scan_req; |
| 419 | struct ieee80211_vif *vif = phy->scan_vif; |
| 420 | struct mt7996_vif *mvif; |
| 421 | - struct mt76_wcid *wcid; |
| 422 | + struct mt7996_link_sta *mlink; |
| 423 | struct ieee80211_tx_info *info; |
| 424 | struct sk_buff *skb; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 425 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 426 | @@ -2719,7 +2722,6 @@ mt7996_scan_send_probe(struct mt7996_phy *phy, struct cfg80211_ssid *ssid, |
| 427 | return; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 428 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 429 | mvif = (struct mt7996_vif *)vif->drv_priv; |
| 430 | - wcid = &mvif->sta.wcid; |
| 431 | |
| 432 | skb = ieee80211_probereq_get(hw, vif->addr, |
| 433 | ssid->ssid, ssid->ssid_len, req->ie_len); |
| 434 | @@ -2752,7 +2754,8 @@ mt7996_scan_send_probe(struct mt7996_phy *phy, struct cfg80211_ssid *ssid, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 435 | } |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 436 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 437 | local_bh_disable(); |
| 438 | - mt76_tx(phy->mt76, NULL, wcid, skb); |
| 439 | + mlink = rcu_dereference(mvif->sta.link[0]); |
| 440 | + mt76_tx(phy->mt76, NULL, &mlink->wcid, skb); |
| 441 | local_bh_enable(); |
| 442 | |
| 443 | rcu_read_unlock(); |
| 444 | diff --git a/mt7996/main.c b/mt7996/main.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 445 | index 8a32ec69..e071c5fa 100644 |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 446 | --- a/mt7996/main.c |
| 447 | +++ b/mt7996/main.c |
| 448 | @@ -229,6 +229,7 @@ static int mt7996_add_interface(struct ieee80211_hw *hw, |
| 449 | struct ieee80211_bss_conf *conf = &vif->bss_conf; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 450 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 451 | struct mt7996_bss_conf *mconf = &mvif->deflink; |
| 452 | + struct mt7996_link_sta *mlink = &mvif->sta.deflink; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 453 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 454 | struct mt7996_phy *phy = mt7996_hw_phy(hw); |
| 455 | struct mt76_txq *mtxq; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 456 | @@ -268,14 +269,15 @@ static int mt7996_add_interface(struct ieee80211_hw *hw, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 457 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 458 | idx = MT7996_WTBL_RESERVED - mconf->mt76.idx; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 459 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 460 | - INIT_LIST_HEAD(&mvif->sta.rc_list); |
| 461 | - INIT_LIST_HEAD(&mvif->sta.wcid.poll_list); |
| 462 | - mvif->sta.wcid.idx = idx; |
| 463 | - mvif->sta.wcid.phy_idx = band_idx; |
| 464 | - mvif->sta.wcid.hw_key_idx = -1; |
| 465 | - mvif->sta.wcid.tx_info |= MT_WCID_TX_INFO_SET; |
| 466 | - mvif->sta.vif = mvif; |
| 467 | - mt76_wcid_init(&mvif->sta.wcid); |
| 468 | + INIT_LIST_HEAD(&mlink->rc_list); |
| 469 | + INIT_LIST_HEAD(&mlink->wcid.poll_list); |
| 470 | + mlink->wcid.idx = idx; |
| 471 | + mlink->wcid.phy_idx = band_idx; |
| 472 | + mlink->wcid.hw_key_idx = -1; |
| 473 | + mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET; |
| 474 | + mlink->sta = &mvif->sta; |
| 475 | + mlink->sta->vif = mvif; |
| 476 | + mt76_wcid_init(&mlink->wcid); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 477 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 478 | mt7996_mac_wtbl_update(dev, idx, |
| 479 | MT_WTBL_UPDATE_ADM_COUNT_CLEAR); |
| 480 | @@ -297,14 +299,15 @@ static int mt7996_add_interface(struct ieee80211_hw *hw, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 481 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 482 | mt7996_init_bitrate_mask(mconf); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 483 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 484 | - mt7996_mcu_add_bss_info(phy, conf, mconf, true); |
| 485 | + mt7996_mcu_add_bss_info(phy, conf, mconf, mlink, true); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 486 | /* defer the first STA_REC of BMC entry to BSS_CHANGED_BSSID for STA |
| 487 | * interface, since firmware only records BSSID when the entry is new |
| 488 | */ |
| 489 | if (vif->type != NL80211_IFTYPE_STATION) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 490 | - mt7996_mcu_add_sta(dev, conf, mconf, NULL, true, true); |
| 491 | - rcu_assign_pointer(dev->mt76.wcid[idx], &mvif->sta.wcid); |
| 492 | + mt7996_mcu_add_sta(dev, conf, mconf, NULL, mlink, true, true); |
| 493 | + rcu_assign_pointer(dev->mt76.wcid[idx], &mlink->wcid); |
| 494 | rcu_assign_pointer(mvif->link[0], mconf); |
| 495 | + rcu_assign_pointer(mvif->sta.link[0], mlink); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 496 | |
| 497 | out: |
| 498 | mutex_unlock(&dev->mt76.mutex); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 499 | @@ -318,10 +321,10 @@ static void mt7996_remove_interface(struct ieee80211_hw *hw, |
| 500 | struct ieee80211_bss_conf *conf; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 501 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 502 | struct mt7996_bss_conf *mconf; |
| 503 | - struct mt7996_sta *msta = &mvif->sta; |
| 504 | + struct mt7996_link_sta *mlink = &mvif->sta.deflink; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 505 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 506 | struct mt7996_phy *phy = mt7996_hw_phy(hw); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 507 | - int idx = msta->wcid.idx; |
| 508 | + int idx = mlink->wcid.idx; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 509 | |
| 510 | cancel_delayed_work_sync(&phy->scan_work); |
| 511 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 512 | @@ -329,8 +332,8 @@ static void mt7996_remove_interface(struct ieee80211_hw *hw, |
| 513 | |
| 514 | conf = link_conf_dereference_protected(vif, 0); |
| 515 | mconf = mconf_dereference_protected(mvif, 0); |
| 516 | - mt7996_mcu_add_sta(dev, conf, mconf, NULL, false, false); |
| 517 | - mt7996_mcu_add_bss_info(phy, conf, mconf, false); |
| 518 | + mt7996_mcu_add_sta(dev, conf, mconf, NULL, mlink, false, false); |
| 519 | + mt7996_mcu_add_bss_info(phy, conf, mconf, mlink, false); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 520 | |
| 521 | if (vif == phy->monitor_vif) |
| 522 | phy->monitor_vif = NULL; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 523 | @@ -343,12 +346,13 @@ static void mt7996_remove_interface(struct ieee80211_hw *hw, |
| 524 | phy->omac_mask &= ~BIT_ULL(mconf->mt76.omac_idx); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 525 | |
| 526 | spin_lock_bh(&dev->mt76.sta_poll_lock); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 527 | - if (!list_empty(&msta->wcid.poll_list)) |
| 528 | - list_del_init(&msta->wcid.poll_list); |
| 529 | + if (!list_empty(&mlink->wcid.poll_list)) |
| 530 | + list_del_init(&mlink->wcid.poll_list); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 531 | spin_unlock_bh(&dev->mt76.sta_poll_lock); |
| 532 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 533 | - mt76_wcid_cleanup(&dev->mt76, &msta->wcid); |
| 534 | + mt76_wcid_cleanup(&dev->mt76, &mlink->wcid); |
| 535 | rcu_assign_pointer(mvif->link[0], NULL); |
| 536 | + rcu_assign_pointer(mvif->sta.link[0], NULL); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 537 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 538 | mutex_unlock(&dev->mt76.mutex); |
| 539 | } |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 540 | @@ -451,10 +455,10 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 541 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 542 | struct mt7996_sta *msta = sta ? (struct mt7996_sta *)sta->drv_priv : |
| 543 | &mvif->sta; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 544 | - struct mt76_wcid *wcid = &msta->wcid; |
| 545 | struct mt7996_bss_conf *mconf; |
| 546 | + struct mt7996_link_sta *mlink; |
| 547 | struct ieee80211_bss_conf *conf; |
| 548 | - u8 *wcid_keyidx = &wcid->hw_key_idx; |
| 549 | + u8 *wcid_keyidx; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 550 | int idx = key->keyidx; |
| 551 | int err = 0; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 552 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 553 | @@ -468,6 +472,12 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 554 | !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) |
| 555 | return -EOPNOTSUPP; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 556 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 557 | + mutex_lock(&dev->mt76.mutex); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 558 | + conf = link_conf_dereference_protected(vif, 0); |
| 559 | + mconf = mconf_dereference_protected(mvif, 0); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 560 | + mlink = mlink_dereference_protected(msta, 0); |
| 561 | + wcid_keyidx = &mlink->wcid.hw_key_idx; |
| 562 | + |
| 563 | /* fall back to sw encryption for unsupported ciphers */ |
| 564 | switch (key->cipher) { |
| 565 | case WLAN_CIPHER_SUITE_TKIP: |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 566 | @@ -490,16 +500,13 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 567 | case WLAN_CIPHER_SUITE_WEP40: |
| 568 | case WLAN_CIPHER_SUITE_WEP104: |
| 569 | default: |
| 570 | + mutex_unlock(&dev->mt76.mutex); |
| 571 | return -EOPNOTSUPP; |
| 572 | } |
| 573 | |
| 574 | - mutex_lock(&dev->mt76.mutex); |
| 575 | - |
| 576 | - conf = link_conf_dereference_protected(vif, 0); |
| 577 | - mconf = mconf_dereference_protected(mvif, 0); |
| 578 | if (cmd == SET_KEY && !sta && !mconf->mt76.cipher) { |
| 579 | mconf->mt76.cipher = mt76_connac_mcu_get_cipher(key->cipher); |
| 580 | - mt7996_mcu_add_bss_info(phy, conf, mconf, true); |
| 581 | + mt7996_mcu_add_bss_info(phy, conf, mconf, mlink, true); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 582 | } |
| 583 | |
| 584 | if (cmd == SET_KEY) { |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 585 | @@ -510,14 +517,14 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 586 | goto out; |
| 587 | } |
| 588 | |
| 589 | - mt76_wcid_key_setup(&dev->mt76, wcid, key); |
| 590 | + mt76_wcid_key_setup(&dev->mt76, &mlink->wcid, key); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 591 | |
| 592 | if (key->keyidx == 6 || key->keyidx == 7) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 593 | - err = mt7996_mcu_bcn_prot_enable(dev, conf, mconf, key); |
| 594 | + err = mt7996_mcu_bcn_prot_enable(dev, conf, mconf, mlink, key); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 595 | else |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 596 | err = mt7996_mcu_add_key(&dev->mt76, mconf, key, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 597 | MCU_WMWA_UNI_CMD(STA_REC_UPDATE), |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 598 | - &msta->wcid, cmd); |
| 599 | + &mlink->wcid, cmd); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 600 | out: |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 601 | mutex_unlock(&dev->mt76.mutex); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 602 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 603 | @@ -720,25 +727,27 @@ static void mt7996_bss_info_changed(struct ieee80211_hw *hw, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 604 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 605 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 606 | struct mt7996_bss_conf *mconf; |
| 607 | + struct mt7996_link_sta *mlink; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 608 | struct mt7996_phy *phy = mt7996_hw_phy(hw); |
| 609 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 610 | |
| 611 | mutex_lock(&dev->mt76.mutex); |
| 612 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 613 | mconf = mconf_dereference_protected(mvif, 0); |
| 614 | + mlink = mlink_dereference_protected(&mvif->sta, 0); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 615 | /* station mode uses BSSID to map the wlan entry to a peer, |
| 616 | * and then peer references bss_info_rfch to set bandwidth cap. |
| 617 | */ |
| 618 | if ((changed & BSS_CHANGED_BSSID && !is_zero_ether_addr(info->bssid)) || |
| 619 | (changed & BSS_CHANGED_ASSOC && vif->cfg.assoc) || |
| 620 | (changed & BSS_CHANGED_BEACON_ENABLED && info->enable_beacon)) { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 621 | - mt7996_mcu_add_bss_info(phy, info, mconf, true); |
| 622 | - mt7996_mcu_add_sta(dev, info, mconf, NULL, true, |
| 623 | + mt7996_mcu_add_bss_info(phy, info, mconf, mlink, true); |
| 624 | + mt7996_mcu_add_sta(dev, info, mconf, NULL, mlink, true, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 625 | !!(changed & BSS_CHANGED_BSSID)); |
| 626 | } |
| 627 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 628 | if (changed & BSS_CHANGED_ERP_CTS_PROT) |
| 629 | - mt7996_mac_enable_rtscts(dev, vif, info->use_cts_prot); |
| 630 | + mt7996_mac_enable_rtscts(dev, mlink, info->use_cts_prot); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 631 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 632 | if (changed & BSS_CHANGED_ERP_SLOT) { |
| 633 | int slottime = info->use_short_slot ? 9 : 20; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 634 | @@ -809,6 +818,7 @@ int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 635 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 636 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 637 | struct mt7996_bss_conf *mconf = mconf_dereference_protected(mvif, 0); |
| 638 | + struct mt7996_link_sta *mlink = &msta->deflink; |
| 639 | u8 band_idx = mconf->phy->mt76->band_idx; |
| 640 | int idx; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 641 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 642 | @@ -820,13 +830,16 @@ int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 643 | if (idx < 0) |
| 644 | return -ENOSPC; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 645 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 646 | - INIT_LIST_HEAD(&msta->rc_list); |
| 647 | - INIT_LIST_HEAD(&msta->wcid.poll_list); |
| 648 | + INIT_LIST_HEAD(&mlink->rc_list); |
| 649 | + INIT_LIST_HEAD(&mlink->wcid.poll_list); |
| 650 | msta->vif = mvif; |
| 651 | - msta->wcid.sta = 1; |
| 652 | - msta->wcid.idx = idx; |
| 653 | - msta->wcid.phy_idx = band_idx; |
| 654 | - msta->wcid.tx_info |= MT_WCID_TX_INFO_SET; |
| 655 | + mlink->wcid.sta = 1; |
| 656 | + mlink->wcid.idx = idx; |
| 657 | + mlink->wcid.phy_idx = band_idx; |
| 658 | + mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET; |
| 659 | + mlink->sta = msta; |
| 660 | + |
| 661 | + rcu_assign_pointer(msta->link[0], mlink); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 662 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 663 | #ifdef CONFIG_MTK_VENDOR |
| 664 | mt7996_vendor_amnt_sta_remove(mconf->phy, sta); |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 665 | @@ -859,19 +872,25 @@ void mt7996_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 666 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 667 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 668 | struct mt7996_bss_conf *mconf; |
| 669 | + struct mt7996_link_sta *mlink; |
| 670 | struct ieee80211_bss_conf *conf; |
| 671 | + struct ieee80211_link_sta *link_sta; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 672 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 673 | mutex_lock(&dev->mt76.mutex); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 674 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 675 | - mt7996_mac_wtbl_update(dev, msta->wcid.idx, |
| 676 | - MT_WTBL_UPDATE_ADM_COUNT_CLEAR); |
| 677 | - |
| 678 | conf = link_conf_dereference_protected(vif, 0); |
| 679 | mconf = mconf_dereference_protected(mvif, 0); |
| 680 | - mt7996_mcu_add_sta(dev, conf, mconf, sta, true, true); |
| 681 | - mt7996_mcu_add_rate_ctrl(dev, conf, mconf, sta, false); |
| 682 | + link_sta = link_sta_dereference_protected(sta, 0); |
| 683 | + mlink = mlink_dereference_protected(msta, 0); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 684 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 685 | - ewma_avg_signal_init(&msta->avg_ack_signal); |
| 686 | + mt7996_mac_wtbl_update(dev, mlink->wcid.idx, |
| 687 | + MT_WTBL_UPDATE_ADM_COUNT_CLEAR); |
| 688 | + |
| 689 | + mt7996_mcu_add_sta(dev, conf, mconf, link_sta, mlink, true, true); |
| 690 | + mt7996_mcu_add_rate_ctrl(dev, conf, mconf, link_sta, mlink, false); |
| 691 | + mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET; |
| 692 | + |
| 693 | + ewma_avg_signal_init(&mlink->avg_ack_signal); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 694 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 695 | mutex_unlock(&dev->mt76.mutex); |
| 696 | } |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 697 | @@ -883,25 +902,31 @@ void mt7996_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 698 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 699 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 700 | struct mt7996_bss_conf *mconf; |
| 701 | + struct mt7996_link_sta *mlink; |
| 702 | struct ieee80211_bss_conf *conf; |
| 703 | + struct ieee80211_link_sta *link_sta; |
| 704 | int i; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 705 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 706 | conf = link_conf_dereference_protected(vif, 0); |
| 707 | mconf = mconf_dereference_protected(mvif, 0); |
| 708 | - mt7996_mcu_add_sta(dev, conf, mconf, sta, false, false); |
| 709 | + link_sta = link_sta_dereference_protected(sta, 0); |
| 710 | + mlink = mlink_dereference_protected(msta, 0); |
| 711 | + mt7996_mcu_add_sta(dev, conf, mconf, link_sta, mlink, false, false); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 712 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 713 | - mt7996_mac_wtbl_update(dev, msta->wcid.idx, |
| 714 | + mt7996_mac_wtbl_update(dev, mlink->wcid.idx, |
| 715 | MT_WTBL_UPDATE_ADM_COUNT_CLEAR); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 716 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 717 | - for (i = 0; i < ARRAY_SIZE(msta->twt.flow); i++) |
| 718 | - mt7996_mac_twt_teardown_flow(dev, msta, i); |
| 719 | + for (i = 0; i < ARRAY_SIZE(mlink->twt.flow); i++) |
| 720 | + mt7996_mac_twt_teardown_flow(dev, mlink, i); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 721 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 722 | spin_lock_bh(&mdev->sta_poll_lock); |
| 723 | - if (!list_empty(&msta->wcid.poll_list)) |
| 724 | - list_del_init(&msta->wcid.poll_list); |
| 725 | - if (!list_empty(&msta->rc_list)) |
| 726 | - list_del_init(&msta->rc_list); |
| 727 | + if (!list_empty(&mlink->wcid.poll_list)) |
| 728 | + list_del_init(&mlink->wcid.poll_list); |
| 729 | + if (!list_empty(&mlink->rc_list)) |
| 730 | + list_del_init(&mlink->rc_list); |
| 731 | spin_unlock_bh(&mdev->sta_poll_lock); |
| 732 | + |
| 733 | + rcu_assign_pointer(msta->link[0], NULL); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 734 | } |
| 735 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 736 | static void mt7996_tx(struct ieee80211_hw *hw, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 737 | @@ -913,19 +938,22 @@ static void mt7996_tx(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 738 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
| 739 | struct ieee80211_vif *vif = info->control.vif; |
| 740 | struct mt76_wcid *wcid = &dev->mt76.global_wcid; |
| 741 | + struct mt7996_link_sta *mlink; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 742 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 743 | if (control->sta) { |
| 744 | - struct mt7996_sta *sta; |
| 745 | + struct mt7996_sta *msta; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 746 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 747 | - sta = (struct mt7996_sta *)control->sta->drv_priv; |
| 748 | - wcid = &sta->wcid; |
| 749 | + msta = (struct mt7996_sta *)control->sta->drv_priv; |
| 750 | + mlink = rcu_dereference(msta->link[0]); |
| 751 | + wcid = &mlink->wcid; |
| 752 | } |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 753 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 754 | if (vif && !control->sta) { |
| 755 | struct mt7996_vif *mvif; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 756 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 757 | mvif = (struct mt7996_vif *)vif->drv_priv; |
| 758 | - wcid = &mvif->sta.wcid; |
| 759 | + mlink = rcu_dereference(mvif->sta.link[0]); |
| 760 | + wcid = &mlink->wcid; |
| 761 | } |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 762 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 763 | mt76_tx(mphy, control->sta, wcid, skb); |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 764 | @@ -952,6 +980,7 @@ mt7996_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 765 | struct ieee80211_sta *sta = params->sta; |
| 766 | struct ieee80211_txq *txq = sta->txq[params->tid]; |
| 767 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 768 | + struct mt7996_link_sta *mlink; |
| 769 | u16 tid = params->tid; |
| 770 | u16 ssn = params->ssn; |
| 771 | struct mt76_txq *mtxq; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 772 | @@ -963,14 +992,15 @@ mt7996_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 773 | mtxq = (struct mt76_txq *)txq->drv_priv; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 774 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 775 | mutex_lock(&dev->mt76.mutex); |
| 776 | + mlink = mlink_dereference_protected(msta, 0); |
| 777 | switch (action) { |
| 778 | case IEEE80211_AMPDU_RX_START: |
| 779 | - mt76_rx_aggr_start(&dev->mt76, &msta->wcid, tid, ssn, |
| 780 | + mt76_rx_aggr_start(&dev->mt76, &mlink->wcid, tid, ssn, |
| 781 | params->buf_size); |
| 782 | ret = mt7996_mcu_add_rx_ba(dev, params, true); |
| 783 | break; |
| 784 | case IEEE80211_AMPDU_RX_STOP: |
| 785 | - mt76_rx_aggr_stop(&dev->mt76, &msta->wcid, tid); |
| 786 | + mt76_rx_aggr_stop(&dev->mt76, &mlink->wcid, tid); |
| 787 | ret = mt7996_mcu_add_rx_ba(dev, params, false); |
| 788 | break; |
| 789 | case IEEE80211_AMPDU_TX_OPERATIONAL: |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 790 | @@ -981,16 +1011,16 @@ mt7996_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 791 | case IEEE80211_AMPDU_TX_STOP_FLUSH: |
| 792 | case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: |
| 793 | mtxq->aggr = false; |
| 794 | - clear_bit(tid, &msta->wcid.ampdu_state); |
| 795 | + clear_bit(tid, &mlink->wcid.ampdu_state); |
| 796 | ret = mt7996_mcu_add_tx_ba(dev, params, false); |
| 797 | break; |
| 798 | case IEEE80211_AMPDU_TX_START: |
| 799 | - set_bit(tid, &msta->wcid.ampdu_state); |
| 800 | + set_bit(tid, &mlink->wcid.ampdu_state); |
| 801 | ret = IEEE80211_AMPDU_TX_START_IMMEDIATE; |
| 802 | break; |
| 803 | case IEEE80211_AMPDU_TX_STOP_CONT: |
| 804 | mtxq->aggr = false; |
| 805 | - clear_bit(tid, &msta->wcid.ampdu_state); |
| 806 | + clear_bit(tid, &mlink->wcid.ampdu_state); |
| 807 | ret = mt7996_mcu_add_tx_ba(dev, params, false); |
| 808 | ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); |
| 809 | break; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 810 | @@ -1169,10 +1199,19 @@ static void mt7996_sta_statistics(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 811 | struct ieee80211_sta *sta, |
| 812 | struct station_info *sinfo) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 813 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 814 | + struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 815 | struct mt7996_phy *phy = mt7996_hw_phy(hw); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 816 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 817 | - struct rate_info *txrate = &msta->wcid.rate; |
| 818 | + struct mt7996_link_sta *mlink; |
| 819 | + struct rate_info *txrate; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 820 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 821 | + /* TODO: support per-link rate report */ |
| 822 | + mutex_lock(&dev->mt76.mutex); |
| 823 | + mlink = mlink_dereference_protected(msta, 0); |
| 824 | + if (!mlink) |
| 825 | + goto out; |
| 826 | + |
| 827 | + txrate = &mlink->wcid.rate; |
| 828 | if (txrate->legacy || txrate->flags) { |
| 829 | if (txrate->legacy) { |
| 830 | sinfo->txrate.legacy = txrate->legacy; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 831 | @@ -1191,44 +1230,52 @@ static void mt7996_sta_statistics(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 832 | sinfo->txrate.flags = txrate->flags; |
| 833 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 834 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 835 | - sinfo->tx_failed = msta->wcid.stats.tx_failed; |
| 836 | + sinfo->tx_failed = mlink->wcid.stats.tx_failed; |
| 837 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 838 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 839 | - sinfo->tx_retries = msta->wcid.stats.tx_retries; |
| 840 | + sinfo->tx_retries = mlink->wcid.stats.tx_retries; |
| 841 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 842 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 843 | - sinfo->ack_signal = (s8)msta->ack_signal; |
| 844 | + sinfo->ack_signal = (s8)mlink->ack_signal; |
| 845 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 846 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 847 | - sinfo->avg_ack_signal = -(s8)ewma_avg_signal_read(&msta->avg_ack_signal); |
| 848 | + sinfo->avg_ack_signal = -(s8)ewma_avg_signal_read(&mlink->avg_ack_signal); |
| 849 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL_AVG); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 850 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 851 | if (mtk_wed_device_active(&phy->dev->mt76.mmio.wed)) { |
| 852 | - sinfo->tx_bytes = msta->wcid.stats.tx_bytes; |
| 853 | + sinfo->tx_bytes = mlink->wcid.stats.tx_bytes; |
| 854 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BYTES64); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 855 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 856 | - sinfo->rx_bytes = msta->wcid.stats.rx_bytes; |
| 857 | + sinfo->rx_bytes = mlink->wcid.stats.rx_bytes; |
| 858 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES64); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 859 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 860 | - sinfo->tx_packets = msta->wcid.stats.tx_packets; |
| 861 | + sinfo->tx_packets = mlink->wcid.stats.tx_packets; |
| 862 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 863 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 864 | - sinfo->rx_packets = msta->wcid.stats.rx_packets; |
| 865 | + sinfo->rx_packets = mlink->wcid.stats.rx_packets; |
| 866 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_PACKETS); |
| 867 | } |
| 868 | +out: |
| 869 | + mutex_unlock(&dev->mt76.mutex); |
| 870 | } |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 871 | |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 872 | static void mt7996_sta_rc_work(void *data, struct ieee80211_sta *sta) |
| 873 | { |
| 874 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 875 | + struct mt7996_link_sta *mlink; |
| 876 | struct mt7996_dev *dev = msta->vif->dev; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 877 | u32 *changed = data; |
| 878 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 879 | + rcu_read_lock(); |
| 880 | + mlink = rcu_dereference(msta->link[0]); |
| 881 | + |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 882 | spin_lock_bh(&dev->mt76.sta_poll_lock); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 883 | - msta->changed |= *changed; |
| 884 | - if (list_empty(&msta->rc_list)) |
| 885 | - list_add_tail(&msta->rc_list, &dev->sta_rc_list); |
| 886 | + mlink->changed |= *changed; |
| 887 | + if (list_empty(&mlink->rc_list)) |
| 888 | + list_add_tail(&mlink->rc_list, &dev->sta_rc_list); |
| 889 | spin_unlock_bh(&dev->mt76.sta_poll_lock); |
| 890 | + |
| 891 | + rcu_read_unlock(); |
| 892 | } |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 893 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 894 | static void mt7996_sta_rc_update(struct ieee80211_hw *hw, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 895 | @@ -1242,7 +1289,7 @@ static void mt7996_sta_rc_update(struct ieee80211_hw *hw, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 896 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 897 | if (!msta->vif) { |
| 898 | dev_warn(dev->mt76.dev, "Un-initialized STA %pM wcid %d in rc_work\n", |
| 899 | - sta->addr, msta->wcid.idx); |
| 900 | + sta->addr, msta->deflink.wcid.idx); |
| 901 | return; |
| 902 | } |
| 903 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 904 | @@ -1288,16 +1335,18 @@ static void mt7996_sta_set_4addr(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 905 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 906 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 907 | struct mt7996_bss_conf *mconf; |
| 908 | + struct mt7996_link_sta *mlink; |
| 909 | |
| 910 | mutex_lock(&dev->mt76.mutex); |
| 911 | mconf = mconf_dereference_protected(mvif, 0); |
| 912 | + mlink = mlink_dereference_protected(msta, 0); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 913 | |
| 914 | if (enabled) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 915 | - set_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags); |
| 916 | + set_bit(MT_WCID_FLAG_4ADDR, &mlink->wcid.flags); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 917 | else |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 918 | - clear_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags); |
| 919 | + clear_bit(MT_WCID_FLAG_4ADDR, &mlink->wcid.flags); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 920 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 921 | - mt7996_mcu_wtbl_update_hdr_trans(dev, vif, mconf, sta); |
| 922 | + mt7996_mcu_wtbl_update_hdr_trans(dev, vif, mconf, mlink); |
| 923 | mutex_unlock(&dev->mt76.mutex); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 924 | } |
| 925 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 926 | @@ -1310,16 +1359,18 @@ static void mt7996_sta_set_decap_offload(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 927 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 928 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 929 | struct mt7996_bss_conf *mconf; |
| 930 | + struct mt7996_link_sta *mlink; |
| 931 | |
| 932 | mutex_lock(&dev->mt76.mutex); |
| 933 | mconf = mconf_dereference_protected(mvif, 0); |
| 934 | + mlink = mlink_dereference_protected(msta, 0); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 935 | |
| 936 | if (enabled) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 937 | - set_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags); |
| 938 | + set_bit(MT_WCID_FLAG_HDR_TRANS, &mlink->wcid.flags); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 939 | else |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 940 | - clear_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags); |
| 941 | + clear_bit(MT_WCID_FLAG_HDR_TRANS, &mlink->wcid.flags); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 942 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 943 | - mt7996_mcu_wtbl_update_hdr_trans(dev, vif, mconf, sta); |
| 944 | + mt7996_mcu_wtbl_update_hdr_trans(dev, vif, mconf, mlink); |
| 945 | mutex_unlock(&dev->mt76.mutex); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 946 | } |
| 947 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 948 | @@ -1452,11 +1503,12 @@ static void mt7996_ethtool_worker(void *wi_data, struct ieee80211_sta *sta) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 949 | { |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 950 | struct mt76_ethtool_worker_info *wi = wi_data; |
| 951 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 952 | + struct mt7996_link_sta *mlink = &msta->deflink; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 953 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 954 | if (msta->vif->deflink.mt76.idx != wi->idx) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 955 | return; |
| 956 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 957 | - mt76_ethtool_worker(wi, &msta->wcid.stats, true); |
| 958 | + mt76_ethtool_worker(wi, &mlink->wcid.stats, true); |
| 959 | } |
| 960 | |
| 961 | static |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 962 | @@ -1559,10 +1611,12 @@ mt7996_twt_teardown_request(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 963 | u8 flowid) |
| 964 | { |
| 965 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 966 | + struct mt7996_link_sta *mlink; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 967 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 968 | |
| 969 | mutex_lock(&dev->mt76.mutex); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 970 | - mt7996_mac_twt_teardown_flow(dev, msta, flowid); |
| 971 | + mlink = mlink_dereference_protected(msta, 0); |
| 972 | + mt7996_mac_twt_teardown_flow(dev, mlink, flowid); |
| 973 | mutex_unlock(&dev->mt76.mutex); |
| 974 | } |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 975 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 976 | @@ -1685,6 +1739,7 @@ mt7996_net_fill_forward_path(struct ieee80211_hw *hw, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 977 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 978 | struct mt7996_bss_conf *mconf = &mvif->deflink; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 979 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 980 | + struct mt7996_link_sta *mlink = &msta->deflink; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 981 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 982 | struct mt7996_phy *phy = mt7996_hw_phy(hw); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 983 | struct mtk_wed_device *wed = &dev->mt76.mmio.wed; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 984 | @@ -1707,7 +1762,7 @@ mt7996_net_fill_forward_path(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 985 | if (!mtk_wed_device_active(wed)) |
| 986 | return -ENODEV; |
| 987 | |
| 988 | - if (msta->wcid.idx > MT7996_WTBL_STA) |
| 989 | + if (mlink->wcid.idx > MT7996_WTBL_STA) |
| 990 | return -EIO; |
| 991 | |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 992 | path->type = DEV_PATH_MTK_WDMA; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 993 | @@ -1715,11 +1770,11 @@ mt7996_net_fill_forward_path(struct ieee80211_hw *hw, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 994 | path->mtk_wdma.wdma_idx = wed->wdma_idx; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 995 | path->mtk_wdma.bss = mconf->mt76.idx; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 996 | path->mtk_wdma.queue = 0; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 997 | - path->mtk_wdma.wcid = msta->wcid.idx; |
| 998 | + path->mtk_wdma.wcid = mlink->wcid.idx; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 999 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1000 | if (ieee80211_hw_check(hw, SUPPORTS_AMSDU_IN_AMPDU) && |
| 1001 | mtk_wed_is_amsdu_supported(wed)) |
| 1002 | - path->mtk_wdma.amsdu = msta->wcid.amsdu; |
| 1003 | + path->mtk_wdma.amsdu = mlink->wcid.amsdu; |
| 1004 | else |
| 1005 | path->mtk_wdma.amsdu = 0; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1006 | |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1007 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1008 | index 1e0fca2d..20b84c93 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1009 | --- a/mt7996/mcu.c |
| 1010 | +++ b/mt7996/mcu.c |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1011 | @@ -117,13 +117,13 @@ mt7996_mcu_get_sta_nss(u16 mcs_map) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1012 | } |
| 1013 | |
| 1014 | static void |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1015 | -mt7996_mcu_set_sta_he_mcs(struct ieee80211_sta *sta, |
| 1016 | +mt7996_mcu_set_sta_he_mcs(struct ieee80211_link_sta *link_sta, |
| 1017 | struct mt7996_bss_conf *mconf, |
| 1018 | __le16 *he_mcs, u16 mcs_map) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1019 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1020 | enum nl80211_band band = mconf->phy->mt76->chandef.chan->band; |
| 1021 | const u16 *mask = mconf->bitrate_mask.control[band].he_mcs; |
| 1022 | - int nss, max_nss = sta->deflink.rx_nss > 3 ? 4 : sta->deflink.rx_nss; |
| 1023 | + int nss, max_nss = link_sta->rx_nss > 3 ? 4 : link_sta->rx_nss; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1024 | |
| 1025 | for (nss = 0; nss < max_nss; nss++) { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1026 | int mcs; |
| 1027 | @@ -166,11 +166,11 @@ mt7996_mcu_set_sta_he_mcs(struct ieee80211_sta *sta, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1028 | } |
| 1029 | |
| 1030 | static void |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1031 | -mt7996_mcu_set_sta_vht_mcs(struct ieee80211_sta *sta, __le16 *vht_mcs, |
| 1032 | - const u16 *mask) |
| 1033 | +mt7996_mcu_set_sta_vht_mcs(struct ieee80211_link_sta *link_sta, |
| 1034 | + __le16 *vht_mcs, const u16 *mask) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1035 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1036 | - u16 mcs, mcs_map = le16_to_cpu(sta->deflink.vht_cap.vht_mcs.rx_mcs_map); |
| 1037 | - int nss, max_nss = sta->deflink.rx_nss > 3 ? 4 : sta->deflink.rx_nss; |
| 1038 | + u16 mcs, mcs_map = le16_to_cpu(link_sta->vht_cap.vht_mcs.rx_mcs_map); |
| 1039 | + int nss, max_nss = link_sta->rx_nss > 3 ? 4 : link_sta->rx_nss; |
| 1040 | |
| 1041 | for (nss = 0; nss < max_nss; nss++, mcs_map >>= 2) { |
| 1042 | switch (mcs_map & 0x3) { |
| 1043 | @@ -192,13 +192,13 @@ mt7996_mcu_set_sta_vht_mcs(struct ieee80211_sta *sta, __le16 *vht_mcs, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1044 | } |
| 1045 | |
| 1046 | static void |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1047 | -mt7996_mcu_set_sta_ht_mcs(struct ieee80211_sta *sta, u8 *ht_mcs, |
| 1048 | +mt7996_mcu_set_sta_ht_mcs(struct ieee80211_link_sta *link_sta, u8 *ht_mcs, |
| 1049 | const u8 *mask) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1050 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1051 | - int nss, max_nss = sta->deflink.rx_nss > 3 ? 4 : sta->deflink.rx_nss; |
| 1052 | + int nss, max_nss = link_sta->rx_nss > 3 ? 4 : link_sta->rx_nss; |
| 1053 | |
| 1054 | for (nss = 0; nss < max_nss; nss++) |
| 1055 | - ht_mcs[nss] = sta->deflink.ht_cap.mcs.rx_mask[nss] & mask[nss]; |
| 1056 | + ht_mcs[nss] = link_sta->ht_cap.mcs.rx_mask[nss] & mask[nss]; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1057 | } |
| 1058 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1059 | static int |
| 1060 | @@ -531,14 +531,14 @@ static inline void __mt7996_stat_to_netdev(struct mt76_phy *mphy, |
| 1061 | u32 tx_bytes, u32 rx_bytes, |
| 1062 | u32 tx_packets, u32 rx_packets) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1063 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1064 | - struct mt7996_sta *msta; |
| 1065 | + struct mt7996_link_sta *mlink; |
| 1066 | struct ieee80211_vif *vif; |
| 1067 | struct wireless_dev *wdev; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1068 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1069 | if (wiphy_ext_feature_isset(mphy->hw->wiphy, |
| 1070 | NL80211_EXT_FEATURE_STAS_COUNT)) { |
| 1071 | - msta = container_of(wcid, struct mt7996_sta, wcid); |
| 1072 | - vif = container_of((void *)msta->vif, struct ieee80211_vif, |
| 1073 | + mlink = container_of(wcid, struct mt7996_link_sta, wcid); |
| 1074 | + vif = container_of((void *)mlink->sta->vif, struct ieee80211_vif, |
| 1075 | drv_priv); |
| 1076 | wdev = ieee80211_vif_to_wdev(vif); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1077 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1078 | @@ -1236,10 +1236,10 @@ __mt7996_mcu_alloc_bss_req(struct mt76_dev *dev, struct mt76_vif *mvif, int len) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1079 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1080 | int mt7996_mcu_add_bss_info(struct mt7996_phy *phy, |
| 1081 | struct ieee80211_bss_conf *conf, |
| 1082 | - struct mt7996_bss_conf *mconf, int enable) |
| 1083 | + struct mt7996_bss_conf *mconf, |
| 1084 | + struct mt7996_link_sta *mlink, int enable) |
| 1085 | { |
| 1086 | struct ieee80211_vif *vif = conf->vif; |
| 1087 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1088 | struct mt7996_dev *dev = phy->dev; |
| 1089 | struct sk_buff *skb; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1090 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1091 | @@ -1255,7 +1255,7 @@ int mt7996_mcu_add_bss_info(struct mt7996_phy *phy, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1092 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1093 | /* bss_basic must be first */ |
| 1094 | mt7996_mcu_bss_basic_tlv(skb, conf, mconf, NULL, phy->mt76, |
| 1095 | - mvif->sta.wcid.idx, enable); |
| 1096 | + mlink->wcid.idx, enable); |
| 1097 | mt7996_mcu_bss_sec_tlv(skb, mconf); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1098 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1099 | if (vif->type == NL80211_IFTYPE_MONITOR) |
| 1100 | @@ -1335,9 +1335,10 @@ int mt7996_mcu_add_tx_ba(struct mt7996_dev *dev, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1101 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1102 | struct mt7996_sta *msta = (struct mt7996_sta *)params->sta->drv_priv; |
| 1103 | struct mt7996_bss_conf *mconf = mconf_dereference_protected(msta->vif, 0); |
| 1104 | + struct mt7996_link_sta *mlink = mlink_dereference_protected(msta, 0); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1105 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1106 | if (enable && !params->amsdu) |
| 1107 | - msta->wcid.amsdu = false; |
| 1108 | + mlink->wcid.amsdu = false; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1109 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1110 | return mt7996_mcu_sta_ba(dev, &mconf->mt76, params, enable, true); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1111 | } |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1112 | @@ -1355,15 +1356,15 @@ int mt7996_mcu_add_rx_ba(struct mt7996_dev *dev, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1113 | static void |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1114 | mt7996_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *conf, |
| 1115 | struct mt7996_bss_conf *mconf, |
| 1116 | - struct ieee80211_sta *sta) |
| 1117 | + struct ieee80211_link_sta *link_sta) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1118 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1119 | - struct ieee80211_he_cap_elem *elem = &sta->deflink.he_cap.he_cap_elem; |
| 1120 | + struct ieee80211_he_cap_elem *elem = &link_sta->he_cap.he_cap_elem; |
| 1121 | struct ieee80211_he_mcs_nss_supp mcs_map; |
| 1122 | struct sta_rec_he_v2 *he; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1123 | struct tlv *tlv; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1124 | int i = 0; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1125 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1126 | - if (!sta->deflink.he_cap.has_he) |
| 1127 | + if (!link_sta->he_cap.has_he) |
| 1128 | return; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1129 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1130 | tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_HE_V2, sizeof(*he)); |
| 1131 | @@ -1380,21 +1381,21 @@ mt7996_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *conf, |
| 1132 | u8p_replace_bits(&he->he_phy_cap[1], conf->he_ldpc, |
| 1133 | IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1134 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1135 | - mcs_map = sta->deflink.he_cap.he_mcs_nss_supp; |
| 1136 | - switch (sta->deflink.bandwidth) { |
| 1137 | + mcs_map = link_sta->he_cap.he_mcs_nss_supp; |
| 1138 | + switch (link_sta->bandwidth) { |
| 1139 | case IEEE80211_STA_RX_BW_160: |
| 1140 | if (elem->phy_cap_info[0] & |
| 1141 | IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G) |
| 1142 | - mt7996_mcu_set_sta_he_mcs(sta, mconf, |
| 1143 | + mt7996_mcu_set_sta_he_mcs(link_sta, mconf, |
| 1144 | &he->max_nss_mcs[CMD_HE_MCS_BW8080], |
| 1145 | le16_to_cpu(mcs_map.rx_mcs_80p80)); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1146 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1147 | - mt7996_mcu_set_sta_he_mcs(sta, mconf, |
| 1148 | + mt7996_mcu_set_sta_he_mcs(link_sta, mconf, |
| 1149 | &he->max_nss_mcs[CMD_HE_MCS_BW160], |
| 1150 | le16_to_cpu(mcs_map.rx_mcs_160)); |
| 1151 | fallthrough; |
| 1152 | default: |
| 1153 | - mt7996_mcu_set_sta_he_mcs(sta, mconf, |
| 1154 | + mt7996_mcu_set_sta_he_mcs(link_sta, mconf, |
| 1155 | &he->max_nss_mcs[CMD_HE_MCS_BW80], |
| 1156 | le16_to_cpu(mcs_map.rx_mcs_80)); |
| 1157 | break; |
| 1158 | @@ -1404,24 +1405,25 @@ mt7996_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *conf, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1159 | } |
| 1160 | |
| 1161 | static void |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1162 | -mt7996_mcu_sta_he_6g_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) |
| 1163 | +mt7996_mcu_sta_he_6g_tlv(struct sk_buff *skb, |
| 1164 | + struct ieee80211_link_sta *link_sta) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1165 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1166 | struct sta_rec_he_6g_capa *he_6g; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1167 | struct tlv *tlv; |
| 1168 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1169 | - if (!sta->deflink.he_6ghz_capa.capa) |
| 1170 | + if (!link_sta->he_6ghz_capa.capa) |
| 1171 | return; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1172 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1173 | tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_HE_6G, sizeof(*he_6g)); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1174 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1175 | he_6g = (struct sta_rec_he_6g_capa *)tlv; |
| 1176 | - he_6g->capa = sta->deflink.he_6ghz_capa.capa; |
| 1177 | + he_6g->capa = link_sta->he_6ghz_capa.capa; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1178 | } |
| 1179 | |
| 1180 | static void |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1181 | -mt7996_mcu_sta_eht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) |
| 1182 | +mt7996_mcu_sta_eht_tlv(struct sk_buff *skb, struct ieee80211_link_sta *link_sta) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1183 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1184 | - struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 1185 | + struct mt7996_sta *msta = (struct mt7996_sta *)link_sta->sta->drv_priv; |
| 1186 | struct ieee80211_vif *vif = container_of((void *)msta->vif, |
| 1187 | struct ieee80211_vif, drv_priv); |
| 1188 | struct ieee80211_eht_mcs_nss_supp *mcs_map; |
| 1189 | @@ -1429,11 +1431,11 @@ mt7996_mcu_sta_eht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) |
| 1190 | struct sta_rec_eht *eht; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1191 | struct tlv *tlv; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1192 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1193 | - if (!sta->deflink.eht_cap.has_eht) |
| 1194 | + if (!link_sta->eht_cap.has_eht) |
| 1195 | return; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1196 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1197 | - mcs_map = &sta->deflink.eht_cap.eht_mcs_nss_supp; |
| 1198 | - elem = &sta->deflink.eht_cap.eht_cap_elem; |
| 1199 | + mcs_map = &link_sta->eht_cap.eht_mcs_nss_supp; |
| 1200 | + elem = &link_sta->eht_cap.eht_cap_elem; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1201 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1202 | tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_EHT, sizeof(*eht)); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1203 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1204 | @@ -1444,7 +1446,7 @@ mt7996_mcu_sta_eht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) |
| 1205 | eht->phy_cap_ext = cpu_to_le64(elem->phy_cap_info[8]); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1206 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1207 | if (vif->type != NL80211_IFTYPE_STATION && |
| 1208 | - (sta->deflink.he_cap.he_cap_elem.phy_cap_info[0] & |
| 1209 | + (link_sta->he_cap.he_cap_elem.phy_cap_info[0] & |
| 1210 | (IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G | |
| 1211 | IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G | |
| 1212 | IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G | |
| 1213 | @@ -1460,44 +1462,44 @@ mt7996_mcu_sta_eht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1214 | } |
| 1215 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1216 | static void |
| 1217 | -mt7996_mcu_sta_ht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) |
| 1218 | +mt7996_mcu_sta_ht_tlv(struct sk_buff *skb, struct ieee80211_link_sta *link_sta) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1219 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1220 | struct sta_rec_ht_uni *ht; |
| 1221 | struct tlv *tlv; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1222 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1223 | - if (!sta->deflink.ht_cap.ht_supported) |
| 1224 | + if (!link_sta->ht_cap.ht_supported) |
| 1225 | return; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1226 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1227 | tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_HT, sizeof(*ht)); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1228 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1229 | ht = (struct sta_rec_ht_uni *)tlv; |
| 1230 | - ht->ht_cap = cpu_to_le16(sta->deflink.ht_cap.cap); |
| 1231 | - ht->ampdu_param = u8_encode_bits(sta->deflink.ht_cap.ampdu_factor, |
| 1232 | + ht->ht_cap = cpu_to_le16(link_sta->ht_cap.cap); |
| 1233 | + ht->ampdu_param = u8_encode_bits(link_sta->ht_cap.ampdu_factor, |
| 1234 | IEEE80211_HT_AMPDU_PARM_FACTOR) | |
| 1235 | - u8_encode_bits(sta->deflink.ht_cap.ampdu_density, |
| 1236 | + u8_encode_bits(link_sta->ht_cap.ampdu_density, |
| 1237 | IEEE80211_HT_AMPDU_PARM_DENSITY); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1238 | } |
| 1239 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1240 | static void |
| 1241 | -mt7996_mcu_sta_vht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) |
| 1242 | +mt7996_mcu_sta_vht_tlv(struct sk_buff *skb, struct ieee80211_link_sta *link_sta) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1243 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1244 | struct sta_rec_vht *vht; |
| 1245 | struct tlv *tlv; |
| 1246 | #ifdef CONFIG_MTK_VENDOR |
| 1247 | - struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 1248 | + struct mt7996_sta *msta = (struct mt7996_sta *)link_sta->sta->drv_priv; |
| 1249 | struct mt7996_phy *phy = (struct mt7996_phy *)msta->vif->deflink.phy; |
| 1250 | #endif |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1251 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1252 | /* For 6G band, this tlv is necessary to let hw work normally */ |
| 1253 | - if (!sta->deflink.he_6ghz_capa.capa && !sta->deflink.vht_cap.vht_supported) |
| 1254 | + if (!link_sta->he_6ghz_capa.capa && !link_sta->vht_cap.vht_supported) |
| 1255 | return; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1256 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1257 | tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_VHT, sizeof(*vht)); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1258 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1259 | vht = (struct sta_rec_vht *)tlv; |
| 1260 | - vht->vht_cap = cpu_to_le32(sta->deflink.vht_cap.cap); |
| 1261 | - vht->vht_rx_mcs_map = sta->deflink.vht_cap.vht_mcs.rx_mcs_map; |
| 1262 | - vht->vht_tx_mcs_map = sta->deflink.vht_cap.vht_mcs.tx_mcs_map; |
| 1263 | + vht->vht_cap = cpu_to_le32(link_sta->vht_cap.cap); |
| 1264 | + vht->vht_rx_mcs_map = link_sta->vht_cap.vht_mcs.rx_mcs_map; |
| 1265 | + vht->vht_tx_mcs_map = link_sta->vht_cap.vht_mcs.tx_mcs_map; |
| 1266 | #ifdef CONFIG_MTK_VENDOR |
| 1267 | vht->rts_bw_sig = phy->rts_bw_sig; |
| 1268 | #endif |
| 1269 | @@ -1505,9 +1507,10 @@ mt7996_mcu_sta_vht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1270 | |
| 1271 | static void |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1272 | mt7996_mcu_sta_amsdu_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
| 1273 | - struct ieee80211_vif *vif, struct ieee80211_sta *sta) |
| 1274 | + struct ieee80211_vif *vif, |
| 1275 | + struct ieee80211_link_sta *link_sta, |
| 1276 | + struct mt7996_link_sta *mlink) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1277 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1278 | - struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 1279 | struct sta_rec_amsdu *amsdu; |
| 1280 | struct tlv *tlv; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1281 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1282 | @@ -1516,16 +1519,16 @@ mt7996_mcu_sta_amsdu_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
| 1283 | vif->type != NL80211_IFTYPE_AP) |
| 1284 | return; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1285 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1286 | - if (!sta->deflink.agg.max_amsdu_len) |
| 1287 | + if (!link_sta->agg.max_amsdu_len) |
| 1288 | return; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1289 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1290 | tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_HW_AMSDU, sizeof(*amsdu)); |
| 1291 | amsdu = (struct sta_rec_amsdu *)tlv; |
| 1292 | amsdu->max_amsdu_num = 8; |
| 1293 | amsdu->amsdu_en = true; |
| 1294 | - msta->wcid.amsdu = true; |
| 1295 | + mlink->wcid.amsdu = true; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1296 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1297 | - switch (sta->deflink.agg.max_amsdu_len) { |
| 1298 | + switch (link_sta->agg.max_amsdu_len) { |
| 1299 | case IEEE80211_MAX_MPDU_LEN_VHT_11454: |
| 1300 | amsdu->max_mpdu_size = |
| 1301 | IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1302 | @@ -1544,10 +1547,10 @@ static void |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1303 | mt7996_mcu_sta_muru_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1304 | struct ieee80211_bss_conf *conf, |
| 1305 | struct mt7996_bss_conf *mconf, |
| 1306 | - struct ieee80211_sta *sta) |
| 1307 | + struct ieee80211_link_sta *link_sta) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1308 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1309 | struct mt7996_phy *phy = mconf->phy; |
| 1310 | - struct ieee80211_he_cap_elem *elem = &sta->deflink.he_cap.he_cap_elem; |
| 1311 | + struct ieee80211_he_cap_elem *elem = &link_sta->he_cap.he_cap_elem; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1312 | struct sta_rec_muru *muru; |
| 1313 | struct tlv *tlv; |
| 1314 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1315 | @@ -1567,11 +1570,11 @@ mt7996_mcu_sta_muru_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
| 1316 | muru->cfg.ofdma_dl_en = !!(phy->muru_onoff & OFDMA_DL); |
| 1317 | muru->cfg.ofdma_ul_en = !!(phy->muru_onoff & OFDMA_UL); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1318 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1319 | - if (sta->deflink.vht_cap.vht_supported) |
| 1320 | + if (link_sta->vht_cap.vht_supported) |
| 1321 | muru->mimo_dl.vht_mu_bfee = |
| 1322 | - !!(sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE); |
| 1323 | + !!(link_sta->vht_cap.cap & IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1324 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1325 | - if (!sta->deflink.he_cap.has_he) |
| 1326 | + if (!link_sta->he_cap.has_he) |
| 1327 | return; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1328 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1329 | muru->mimo_dl.partial_bw_dl_mimo = |
| 1330 | @@ -1604,7 +1607,7 @@ mt7996_mcu_sta_muru_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1331 | static inline bool |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1332 | mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_bss_conf *conf, |
| 1333 | struct mt7996_bss_conf *mconf, |
| 1334 | - struct ieee80211_sta *sta, bool bfee) |
| 1335 | + struct ieee80211_link_sta *link_sta, bool bfee) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1336 | { |
| 1337 | int sts = hweight16(phy->mt76->chainmask); |
| 1338 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1339 | @@ -1615,8 +1618,8 @@ mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_bss_conf *conf, |
| 1340 | if (!bfee && sts < 2) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1341 | return false; |
| 1342 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1343 | - if (sta->deflink.eht_cap.has_eht) { |
| 1344 | - struct ieee80211_sta_eht_cap *pc = &sta->deflink.eht_cap; |
| 1345 | + if (link_sta->eht_cap.has_eht) { |
| 1346 | + struct ieee80211_sta_eht_cap *pc = &link_sta->eht_cap; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1347 | struct ieee80211_eht_cap_elem_fixed *pe = &pc->eht_cap_elem; |
| 1348 | |
| 1349 | if (bfee) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1350 | @@ -1627,8 +1630,8 @@ mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_bss_conf *conf, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1351 | EHT_PHY(CAP0_SU_BEAMFORMEE, pe->phy_cap_info[0]); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1352 | } |
| 1353 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1354 | - if (sta->deflink.he_cap.has_he) { |
| 1355 | - struct ieee80211_he_cap_elem *pe = &sta->deflink.he_cap.he_cap_elem; |
| 1356 | + if (link_sta->he_cap.has_he) { |
| 1357 | + struct ieee80211_he_cap_elem *pe = &link_sta->he_cap.he_cap_elem; |
| 1358 | |
| 1359 | if (bfee) |
| 1360 | return conf->he_su_beamformee && |
| 1361 | @@ -1638,8 +1641,8 @@ mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_bss_conf *conf, |
| 1362 | HE_PHY(CAP4_SU_BEAMFORMEE, pe->phy_cap_info[4]); |
| 1363 | } |
| 1364 | |
| 1365 | - if (sta->deflink.vht_cap.vht_supported) { |
| 1366 | - u32 cap = sta->deflink.vht_cap.cap; |
| 1367 | + if (link_sta->vht_cap.vht_supported) { |
| 1368 | + u32 cap = link_sta->vht_cap.cap; |
| 1369 | |
| 1370 | if (bfee) |
| 1371 | return conf->vht_su_beamformee && |
| 1372 | @@ -1662,10 +1665,10 @@ mt7996_mcu_sta_sounding_rate(struct sta_rec_bf *bf) |
| 1373 | } |
| 1374 | |
| 1375 | static void |
| 1376 | -mt7996_mcu_sta_bfer_ht(struct ieee80211_sta *sta, struct mt7996_phy *phy, |
| 1377 | - struct sta_rec_bf *bf) |
| 1378 | +mt7996_mcu_sta_bfer_ht(struct ieee80211_link_sta *link_sta, |
| 1379 | + struct mt7996_phy *phy, struct sta_rec_bf *bf) |
| 1380 | { |
| 1381 | - struct ieee80211_mcs_info *mcs = &sta->deflink.ht_cap.mcs; |
| 1382 | + struct ieee80211_mcs_info *mcs = &link_sta->ht_cap.mcs; |
| 1383 | u8 n = 0; |
| 1384 | |
| 1385 | bf->tx_mode = MT_PHY_TYPE_HT; |
| 1386 | @@ -1687,10 +1690,11 @@ mt7996_mcu_sta_bfer_ht(struct ieee80211_sta *sta, struct mt7996_phy *phy, |
| 1387 | } |
| 1388 | |
| 1389 | static void |
| 1390 | -mt7996_mcu_sta_bfer_vht(struct ieee80211_sta *sta, struct mt7996_phy *phy, |
| 1391 | - struct sta_rec_bf *bf, bool explicit) |
| 1392 | +mt7996_mcu_sta_bfer_vht(struct ieee80211_link_sta *link_sta, |
| 1393 | + struct mt7996_phy *phy, struct sta_rec_bf *bf, |
| 1394 | + bool explicit) |
| 1395 | { |
| 1396 | - struct ieee80211_sta_vht_cap *pc = &sta->deflink.vht_cap; |
| 1397 | + struct ieee80211_sta_vht_cap *pc = &link_sta->vht_cap; |
| 1398 | struct ieee80211_sta_vht_cap *vc = &phy->mt76->sband_5g.sband.vht_cap; |
| 1399 | u16 mcs_map = le16_to_cpu(pc->vht_mcs.rx_mcs_map); |
| 1400 | u8 nss_mcs = mt7996_mcu_get_sta_nss(mcs_map); |
| 1401 | @@ -1711,23 +1715,24 @@ mt7996_mcu_sta_bfer_vht(struct ieee80211_sta *sta, struct mt7996_phy *phy, |
| 1402 | bf->ncol = min_t(u8, nss_mcs, bf->nrow); |
| 1403 | bf->ibf_ncol = bf->ncol; |
| 1404 | |
| 1405 | - if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) |
| 1406 | + if (link_sta->bandwidth == IEEE80211_STA_RX_BW_160) |
| 1407 | bf->nrow = 1; |
| 1408 | } else { |
| 1409 | bf->nrow = tx_ant; |
| 1410 | bf->ncol = min_t(u8, nss_mcs, bf->nrow); |
| 1411 | bf->ibf_ncol = nss_mcs; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1412 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1413 | - if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) |
| 1414 | + if (link_sta->bandwidth == IEEE80211_STA_RX_BW_160) |
| 1415 | bf->ibf_nrow = 1; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1416 | } |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1417 | } |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1418 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1419 | static void |
| 1420 | -mt7996_mcu_sta_bfer_he(struct ieee80211_sta *sta, struct ieee80211_vif *vif, |
| 1421 | - struct mt7996_phy *phy, struct sta_rec_bf *bf) |
| 1422 | +mt7996_mcu_sta_bfer_he(struct ieee80211_link_sta *link_sta, |
| 1423 | + struct ieee80211_vif *vif, struct mt7996_phy *phy, |
| 1424 | + struct sta_rec_bf *bf) |
| 1425 | { |
| 1426 | - struct ieee80211_sta_he_cap *pc = &sta->deflink.he_cap; |
| 1427 | + struct ieee80211_sta_he_cap *pc = &link_sta->he_cap; |
| 1428 | struct ieee80211_he_cap_elem *pe = &pc->he_cap_elem; |
| 1429 | const struct ieee80211_sta_he_cap *vc = |
| 1430 | mt76_connac_get_he_phy_cap(phy->mt76, vif); |
| 1431 | @@ -1752,7 +1757,7 @@ mt7996_mcu_sta_bfer_he(struct ieee80211_sta *sta, struct ieee80211_vif *vif, |
| 1432 | bf->ncol = min_t(u8, nss_mcs, bf->nrow); |
| 1433 | bf->ibf_ncol = bf->ncol; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1434 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1435 | - if (sta->deflink.bandwidth != IEEE80211_STA_RX_BW_160) |
| 1436 | + if (link_sta->bandwidth != IEEE80211_STA_RX_BW_160) |
| 1437 | return; |
| 1438 | |
| 1439 | /* go over for 160MHz and 80p80 */ |
| 1440 | @@ -1784,10 +1789,11 @@ mt7996_mcu_sta_bfer_he(struct ieee80211_sta *sta, struct ieee80211_vif *vif, |
| 1441 | } |
| 1442 | |
| 1443 | static void |
| 1444 | -mt7996_mcu_sta_bfer_eht(struct ieee80211_sta *sta, struct ieee80211_vif *vif, |
| 1445 | - struct mt7996_phy *phy, struct sta_rec_bf *bf) |
| 1446 | +mt7996_mcu_sta_bfer_eht(struct ieee80211_link_sta *link_sta, |
| 1447 | + struct ieee80211_vif *vif, struct mt7996_phy *phy, |
| 1448 | + struct sta_rec_bf *bf) |
| 1449 | { |
| 1450 | - struct ieee80211_sta_eht_cap *pc = &sta->deflink.eht_cap; |
| 1451 | + struct ieee80211_sta_eht_cap *pc = &link_sta->eht_cap; |
| 1452 | struct ieee80211_eht_cap_elem_fixed *pe = &pc->eht_cap_elem; |
| 1453 | struct ieee80211_eht_mcs_nss_supp *eht_nss = &pc->eht_mcs_nss_supp; |
| 1454 | const struct ieee80211_sta_eht_cap *vc = |
| 1455 | @@ -1810,10 +1816,10 @@ mt7996_mcu_sta_bfer_eht(struct ieee80211_sta *sta, struct ieee80211_vif *vif, |
| 1456 | bf->ncol = min_t(u8, nss_mcs, bf->nrow); |
| 1457 | bf->ibf_ncol = bf->ncol; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1458 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1459 | - if (sta->deflink.bandwidth < IEEE80211_STA_RX_BW_160) |
| 1460 | + if (link_sta->bandwidth < IEEE80211_STA_RX_BW_160) |
| 1461 | return; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1462 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1463 | - switch (sta->deflink.bandwidth) { |
| 1464 | + switch (link_sta->bandwidth) { |
| 1465 | case IEEE80211_STA_RX_BW_160: |
| 1466 | snd_dim = EHT_PHY(CAP2_SOUNDING_DIM_160MHZ_MASK, ve->phy_cap_info[2]); |
| 1467 | sts = EHT_PHY(CAP1_BEAMFORMEE_SS_160MHZ_MASK, pe->phy_cap_info[1]); |
| 1468 | @@ -1842,7 +1848,7 @@ mt7996_mcu_sta_bfer_eht(struct ieee80211_sta *sta, struct ieee80211_vif *vif, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1469 | static void |
| 1470 | mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1471 | struct ieee80211_bss_conf *conf, struct mt7996_bss_conf *mconf, |
| 1472 | - struct ieee80211_sta *sta) |
| 1473 | + struct ieee80211_link_sta *link_sta) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1474 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1475 | struct mt7996_phy *phy = mconf->phy; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1476 | int tx_ant = hweight16(phy->mt76->chainmask) - 1; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1477 | @@ -1856,10 +1862,10 @@ mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
| 1478 | }; |
| 1479 | bool ebf; |
| 1480 | |
| 1481 | - if (!(sta->deflink.ht_cap.ht_supported || sta->deflink.he_cap.has_he)) |
| 1482 | + if (!(link_sta->ht_cap.ht_supported || link_sta->he_cap.has_he)) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1483 | return; |
| 1484 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1485 | - ebf = mt7996_is_ebf_supported(phy, conf, mconf, sta, false); |
| 1486 | + ebf = mt7996_is_ebf_supported(phy, conf, mconf, link_sta, false); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1487 | if (!ebf && !dev->ibf) |
| 1488 | return; |
| 1489 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1490 | @@ -1870,23 +1876,23 @@ mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
| 1491 | * vht: support eBF and iBF |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1492 | * ht: iBF only, since mac80211 lacks of eBF support |
| 1493 | */ |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1494 | - if (sta->deflink.eht_cap.has_eht && ebf) |
| 1495 | - mt7996_mcu_sta_bfer_eht(sta, conf->vif, phy, bf); |
| 1496 | - else if (sta->deflink.he_cap.has_he && ebf) |
| 1497 | - mt7996_mcu_sta_bfer_he(sta, conf->vif, phy, bf); |
| 1498 | - else if (sta->deflink.vht_cap.vht_supported) |
| 1499 | - mt7996_mcu_sta_bfer_vht(sta, phy, bf, ebf); |
| 1500 | - else if (sta->deflink.ht_cap.ht_supported) |
| 1501 | - mt7996_mcu_sta_bfer_ht(sta, phy, bf); |
| 1502 | + if (link_sta->eht_cap.has_eht && ebf) |
| 1503 | + mt7996_mcu_sta_bfer_eht(link_sta, conf->vif, phy, bf); |
| 1504 | + else if (link_sta->he_cap.has_he && ebf) |
| 1505 | + mt7996_mcu_sta_bfer_he(link_sta, conf->vif, phy, bf); |
| 1506 | + else if (link_sta->vht_cap.vht_supported) |
| 1507 | + mt7996_mcu_sta_bfer_vht(link_sta, phy, bf, ebf); |
| 1508 | + else if (link_sta->ht_cap.ht_supported) |
| 1509 | + mt7996_mcu_sta_bfer_ht(link_sta, phy, bf); |
| 1510 | else |
| 1511 | return; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1512 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1513 | bf->bf_cap = ebf ? ebf : dev->ibf << 1; |
| 1514 | - bf->bw = sta->deflink.bandwidth; |
| 1515 | - bf->ibf_dbw = sta->deflink.bandwidth; |
| 1516 | + bf->bw = link_sta->bandwidth; |
| 1517 | + bf->ibf_dbw = link_sta->bandwidth; |
| 1518 | bf->ibf_nrow = tx_ant; |
| 1519 | |
| 1520 | - if (!ebf && sta->deflink.bandwidth <= IEEE80211_STA_RX_BW_40 && !bf->ncol) |
| 1521 | + if (!ebf && link_sta->bandwidth <= IEEE80211_STA_RX_BW_40 && !bf->ncol) |
| 1522 | bf->ibf_timeout = 0x48; |
| 1523 | else |
| 1524 | bf->ibf_timeout = 0x18; |
| 1525 | @@ -1896,7 +1902,7 @@ mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
| 1526 | else |
| 1527 | bf->mem_20m = matrix[bf->nrow][bf->ncol]; |
| 1528 | |
| 1529 | - switch (sta->deflink.bandwidth) { |
| 1530 | + switch (link_sta->bandwidth) { |
| 1531 | case IEEE80211_STA_RX_BW_160: |
| 1532 | case IEEE80211_STA_RX_BW_80: |
| 1533 | bf->mem_total = bf->mem_20m * 2; |
| 1534 | @@ -1913,7 +1919,8 @@ mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1535 | static void |
| 1536 | mt7996_mcu_sta_bfee_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1537 | struct ieee80211_bss_conf *conf, |
| 1538 | - struct mt7996_bss_conf *mconf, struct ieee80211_sta *sta) |
| 1539 | + struct mt7996_bss_conf *mconf, |
| 1540 | + struct ieee80211_link_sta *link_sta) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1541 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1542 | struct mt7996_phy *phy = mconf->phy; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1543 | int tx_ant = hweight8(phy->mt76->antenna_mask) - 1; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1544 | @@ -1921,22 +1928,22 @@ mt7996_mcu_sta_bfee_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1545 | struct tlv *tlv; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1546 | u8 nrow = 0; |
| 1547 | |
| 1548 | - if (!(sta->deflink.vht_cap.vht_supported || sta->deflink.he_cap.has_he)) |
| 1549 | + if (!(link_sta->vht_cap.vht_supported || link_sta->he_cap.has_he)) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1550 | return; |
| 1551 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1552 | - if (!mt7996_is_ebf_supported(phy, conf, mconf, sta, true)) |
| 1553 | + if (!mt7996_is_ebf_supported(phy, conf, mconf, link_sta, true)) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1554 | return; |
| 1555 | |
| 1556 | tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_BFEE, sizeof(*bfee)); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1557 | bfee = (struct sta_rec_bfee *)tlv; |
| 1558 | |
| 1559 | - if (sta->deflink.he_cap.has_he) { |
| 1560 | - struct ieee80211_he_cap_elem *pe = &sta->deflink.he_cap.he_cap_elem; |
| 1561 | + if (link_sta->he_cap.has_he) { |
| 1562 | + struct ieee80211_he_cap_elem *pe = &link_sta->he_cap.he_cap_elem; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1563 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1564 | nrow = HE_PHY(CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK, |
| 1565 | pe->phy_cap_info[5]); |
| 1566 | - } else if (sta->deflink.vht_cap.vht_supported) { |
| 1567 | - struct ieee80211_sta_vht_cap *pc = &sta->deflink.vht_cap; |
| 1568 | + } else if (link_sta->vht_cap.vht_supported) { |
| 1569 | + struct ieee80211_sta_vht_cap *pc = &link_sta->vht_cap; |
| 1570 | |
| 1571 | nrow = FIELD_GET(IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK, |
| 1572 | pc->cap); |
| 1573 | @@ -1973,25 +1980,24 @@ mt7996_mcu_sta_hdrt_tlv(struct mt7996_dev *dev, struct sk_buff *skb) |
| 1574 | static void |
| 1575 | mt7996_mcu_sta_hdr_trans_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
| 1576 | struct ieee80211_vif *vif, |
| 1577 | - struct ieee80211_sta *sta) |
| 1578 | + struct mt7996_link_sta *mlink) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1579 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1580 | struct sta_rec_hdr_trans *hdr_trans; |
| 1581 | - struct mt76_wcid *wcid; |
| 1582 | + struct mt76_wcid *wcid = &mlink->wcid; |
| 1583 | struct tlv *tlv; |
| 1584 | |
| 1585 | tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_HDR_TRANS, sizeof(*hdr_trans)); |
| 1586 | hdr_trans = (struct sta_rec_hdr_trans *)tlv; |
| 1587 | hdr_trans->dis_rx_hdr_tran = true; |
| 1588 | |
| 1589 | + if (!wcid->sta) |
| 1590 | + return; |
| 1591 | + |
| 1592 | if (vif->type == NL80211_IFTYPE_STATION) |
| 1593 | hdr_trans->to_ds = true; |
| 1594 | else |
| 1595 | hdr_trans->from_ds = true; |
| 1596 | |
| 1597 | - if (!sta) |
| 1598 | - return; |
| 1599 | - |
| 1600 | - wcid = (struct mt76_wcid *)sta->drv_priv; |
| 1601 | hdr_trans->dis_rx_hdr_tran = !test_bit(MT_WCID_FLAG_HDR_TRANS, &wcid->flags); |
| 1602 | if (test_bit(MT_WCID_FLAG_4ADDR, &wcid->flags)) { |
| 1603 | hdr_trans->to_ds = true; |
| 1604 | @@ -2048,16 +2054,17 @@ int mt7996_mcu_set_fixed_rate_ctrl(struct mt7996_dev *dev, |
| 1605 | |
| 1606 | int mt7996_mcu_set_fixed_field(struct mt7996_dev *dev, |
| 1607 | struct mt7996_bss_conf *mconf, |
| 1608 | - struct ieee80211_sta *sta, void *data, u32 field) |
| 1609 | + struct ieee80211_link_sta *link_sta, |
| 1610 | + struct mt7996_link_sta *mlink, void *data, |
| 1611 | + u32 field) |
| 1612 | { |
| 1613 | - struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1614 | struct sta_phy_uni *phy = data; |
| 1615 | struct sta_rec_ra_fixed_uni *ra; |
| 1616 | struct sk_buff *skb; |
| 1617 | struct tlv *tlv; |
| 1618 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1619 | skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76, |
| 1620 | - &msta->wcid, |
| 1621 | + &mlink->wcid, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1622 | MT7996_STA_UPDATE_MAX_SIZE); |
| 1623 | if (IS_ERR(skb)) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1624 | return PTR_ERR(skb); |
| 1625 | @@ -2076,7 +2083,7 @@ int mt7996_mcu_set_fixed_field(struct mt7996_dev *dev, |
| 1626 | ra->phy = *phy; |
| 1627 | break; |
| 1628 | case RATE_PARAM_MMPS_UPDATE: |
| 1629 | - ra->mmps_mode = mt7996_mcu_get_mmps_mode(sta->deflink.smps_mode); |
| 1630 | + ra->mmps_mode = mt7996_mcu_get_mmps_mode(link_sta->smps_mode); |
| 1631 | break; |
| 1632 | default: |
| 1633 | break; |
| 1634 | @@ -2091,7 +2098,8 @@ static int |
| 1635 | mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev, |
| 1636 | struct ieee80211_bss_conf *conf, |
| 1637 | struct mt7996_bss_conf *mconf, |
| 1638 | - struct ieee80211_sta *sta) |
| 1639 | + struct ieee80211_link_sta *link_sta, |
| 1640 | + struct mt7996_link_sta *mlink) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1641 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1642 | struct cfg80211_chan_def *chandef = &mconf->phy->mt76->chandef; |
| 1643 | struct cfg80211_bitrate_mask *mask = &mconf->bitrate_mask; |
| 1644 | @@ -2115,11 +2123,11 @@ mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev, |
| 1645 | } \ |
| 1646 | } while (0) |
| 1647 | |
| 1648 | - if (sta->deflink.he_cap.has_he) { |
| 1649 | + if (link_sta->he_cap.has_he) { |
| 1650 | __sta_phy_bitrate_mask_check(he_mcs, he_gi, 0, 1); |
| 1651 | - } else if (sta->deflink.vht_cap.vht_supported) { |
| 1652 | + } else if (link_sta->vht_cap.vht_supported) { |
| 1653 | __sta_phy_bitrate_mask_check(vht_mcs, gi, 0, 0); |
| 1654 | - } else if (sta->deflink.ht_cap.ht_supported) { |
| 1655 | + } else if (link_sta->ht_cap.ht_supported) { |
| 1656 | __sta_phy_bitrate_mask_check(ht_mcs, gi, 1, 0); |
| 1657 | } else { |
| 1658 | nrates = hweight32(mask->control[band].legacy); |
| 1659 | @@ -2136,8 +2144,8 @@ mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1660 | |
| 1661 | /* fixed single rate */ |
| 1662 | if (nrates == 1) { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1663 | - ret = mt7996_mcu_set_fixed_field(dev, mconf, sta, &phy, |
| 1664 | - RATE_PARAM_FIXED_MCS); |
| 1665 | + ret = mt7996_mcu_set_fixed_field(dev, mconf, link_sta, mlink, |
| 1666 | + &phy, RATE_PARAM_FIXED_MCS); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1667 | if (ret) |
| 1668 | return ret; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1669 | } |
| 1670 | @@ -2145,29 +2153,28 @@ mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev, |
| 1671 | /* fixed GI */ |
| 1672 | if (mask->control[band].gi != NL80211_TXRATE_DEFAULT_GI || |
| 1673 | mask->control[band].he_gi != GENMASK(7, 0)) { |
| 1674 | - struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 1675 | u32 addr; |
| 1676 | |
| 1677 | /* firmware updates only TXCMD but doesn't take WTBL into |
| 1678 | * account, so driver should update here to reflect the |
| 1679 | * actual txrate hardware sends out. |
| 1680 | */ |
| 1681 | - addr = mt7996_mac_wtbl_lmac_addr(dev, msta->wcid.idx, 7); |
| 1682 | - if (sta->deflink.he_cap.has_he) |
| 1683 | + addr = mt7996_mac_wtbl_lmac_addr(dev, mlink->wcid.idx, 7); |
| 1684 | + if (link_sta->he_cap.has_he) |
| 1685 | mt76_rmw_field(dev, addr, GENMASK(31, 24), phy.sgi); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1686 | else |
| 1687 | mt76_rmw_field(dev, addr, GENMASK(15, 12), phy.sgi); |
| 1688 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1689 | - ret = mt7996_mcu_set_fixed_field(dev, mconf, sta, &phy, |
| 1690 | - RATE_PARAM_FIXED_GI); |
| 1691 | + ret = mt7996_mcu_set_fixed_field(dev, mconf, link_sta, mlink, |
| 1692 | + &phy, RATE_PARAM_FIXED_GI); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1693 | if (ret) |
| 1694 | return ret; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1695 | } |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1696 | |
| 1697 | /* fixed HE_LTF */ |
| 1698 | if (mask->control[band].he_ltf != GENMASK(7, 0)) { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1699 | - ret = mt7996_mcu_set_fixed_field(dev, mconf, sta, &phy, |
| 1700 | - RATE_PARAM_FIXED_HE_LTF); |
| 1701 | + ret = mt7996_mcu_set_fixed_field(dev, mconf, link_sta, mlink, |
| 1702 | + &phy, RATE_PARAM_FIXED_HE_LTF); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1703 | if (ret) |
| 1704 | return ret; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1705 | } |
| 1706 | @@ -2179,7 +2186,7 @@ static void |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1707 | mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1708 | struct ieee80211_bss_conf *conf, |
| 1709 | struct mt7996_bss_conf *mconf, |
| 1710 | - struct ieee80211_sta *sta) |
| 1711 | + struct ieee80211_link_sta *link_sta) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1712 | { |
| 1713 | #define INIT_RCPI 180 |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1714 | struct mt76_phy *mphy = mconf->phy->mt76; |
| 1715 | @@ -2188,20 +2195,20 @@ mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1716 | enum nl80211_band band = chandef->chan->band; |
| 1717 | struct sta_rec_ra_uni *ra; |
| 1718 | struct tlv *tlv; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1719 | - u32 supp_rate = sta->deflink.supp_rates[band]; |
| 1720 | - u32 cap = sta->wme ? STA_CAP_WMM : 0; |
| 1721 | + u32 supp_rate = link_sta->supp_rates[band]; |
| 1722 | + u32 cap = link_sta->sta->wme ? STA_CAP_WMM : 0; |
| 1723 | |
| 1724 | tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_RA, sizeof(*ra)); |
| 1725 | ra = (struct sta_rec_ra_uni *)tlv; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1726 | |
| 1727 | ra->valid = true; |
| 1728 | ra->auto_rate = true; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1729 | - ra->phy_mode = mt76_connac_get_phy_mode(mphy, conf->vif, band, &sta->deflink); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1730 | + ra->phy_mode = mt76_connac_get_phy_mode(mphy, conf->vif, band, link_sta); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1731 | ra->channel = chandef->chan->hw_value; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1732 | - ra->bw = (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_320) ? |
| 1733 | - CMD_CBW_320MHZ : sta->deflink.bandwidth; |
| 1734 | + ra->bw = (link_sta->bandwidth == IEEE80211_STA_RX_BW_320) ? |
| 1735 | + CMD_CBW_320MHZ : link_sta->bandwidth; |
| 1736 | ra->phy.bw = ra->bw; |
| 1737 | - ra->mmps_mode = mt7996_mcu_get_mmps_mode(sta->deflink.smps_mode); |
| 1738 | + ra->mmps_mode = mt7996_mcu_get_mmps_mode(link_sta->smps_mode); |
| 1739 | |
| 1740 | if (supp_rate) { |
| 1741 | supp_rate &= mask->control[band].legacy; |
| 1742 | @@ -2221,60 +2228,60 @@ mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev, |
| 1743 | } |
| 1744 | } |
| 1745 | |
| 1746 | - if (sta->deflink.ht_cap.ht_supported) { |
| 1747 | + if (link_sta->ht_cap.ht_supported) { |
| 1748 | ra->supp_mode |= MODE_HT; |
| 1749 | - ra->af = sta->deflink.ht_cap.ampdu_factor; |
| 1750 | - ra->ht_gf = !!(sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD); |
| 1751 | + ra->af = link_sta->ht_cap.ampdu_factor; |
| 1752 | + ra->ht_gf = !!(link_sta->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD); |
| 1753 | |
| 1754 | cap |= STA_CAP_HT; |
| 1755 | - if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_SGI_20) |
| 1756 | + if (link_sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) |
| 1757 | cap |= STA_CAP_SGI_20; |
| 1758 | - if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_SGI_40) |
| 1759 | + if (link_sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) |
| 1760 | cap |= STA_CAP_SGI_40; |
| 1761 | - if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_TX_STBC) |
| 1762 | + if (link_sta->ht_cap.cap & IEEE80211_HT_CAP_TX_STBC) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1763 | cap |= STA_CAP_TX_STBC; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1764 | - if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_RX_STBC) |
| 1765 | + if (link_sta->ht_cap.cap & IEEE80211_HT_CAP_RX_STBC) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1766 | cap |= STA_CAP_RX_STBC; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1767 | if (conf->ht_ldpc && |
| 1768 | - (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_LDPC_CODING)) |
| 1769 | + (link_sta->ht_cap.cap & IEEE80211_HT_CAP_LDPC_CODING)) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1770 | cap |= STA_CAP_LDPC; |
| 1771 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1772 | - mt7996_mcu_set_sta_ht_mcs(sta, ra->ht_mcs, |
| 1773 | + mt7996_mcu_set_sta_ht_mcs(link_sta, ra->ht_mcs, |
| 1774 | mask->control[band].ht_mcs); |
| 1775 | ra->supp_ht_mcs = *(__le32 *)ra->ht_mcs; |
| 1776 | } |
| 1777 | |
| 1778 | - if (sta->deflink.vht_cap.vht_supported) { |
| 1779 | + if (link_sta->vht_cap.vht_supported) { |
| 1780 | u8 af; |
| 1781 | |
| 1782 | ra->supp_mode |= MODE_VHT; |
| 1783 | af = FIELD_GET(IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK, |
| 1784 | - sta->deflink.vht_cap.cap); |
| 1785 | + link_sta->vht_cap.cap); |
| 1786 | ra->af = max_t(u8, ra->af, af); |
| 1787 | |
| 1788 | cap |= STA_CAP_VHT; |
| 1789 | - if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80) |
| 1790 | + if (link_sta->vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80) |
| 1791 | cap |= STA_CAP_VHT_SGI_80; |
| 1792 | - if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_160) |
| 1793 | + if (link_sta->vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_160) |
| 1794 | cap |= STA_CAP_VHT_SGI_160; |
| 1795 | - if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_TXSTBC) |
| 1796 | + if (link_sta->vht_cap.cap & IEEE80211_VHT_CAP_TXSTBC) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1797 | cap |= STA_CAP_VHT_TX_STBC; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1798 | - if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_RXSTBC_1) |
| 1799 | + if (link_sta->vht_cap.cap & IEEE80211_VHT_CAP_RXSTBC_1) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1800 | cap |= STA_CAP_VHT_RX_STBC; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1801 | if (conf->vht_ldpc && |
| 1802 | - (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_RXLDPC)) |
| 1803 | + (link_sta->vht_cap.cap & IEEE80211_VHT_CAP_RXLDPC)) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1804 | cap |= STA_CAP_VHT_LDPC; |
| 1805 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1806 | - mt7996_mcu_set_sta_vht_mcs(sta, ra->supp_vht_mcs, |
| 1807 | + mt7996_mcu_set_sta_vht_mcs(link_sta, ra->supp_vht_mcs, |
| 1808 | mask->control[band].vht_mcs); |
| 1809 | } |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1810 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1811 | - if (sta->deflink.he_cap.has_he) { |
| 1812 | + if (link_sta->he_cap.has_he) { |
| 1813 | ra->supp_mode |= MODE_HE; |
| 1814 | cap |= STA_CAP_HE; |
| 1815 | |
| 1816 | - if (sta->deflink.he_6ghz_capa.capa) |
| 1817 | - ra->af = le16_get_bits(sta->deflink.he_6ghz_capa.capa, |
| 1818 | + if (link_sta->he_6ghz_capa.capa) |
| 1819 | + ra->af = le16_get_bits(link_sta->he_6ghz_capa.capa, |
| 1820 | IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP); |
| 1821 | } |
| 1822 | ra->sta_cap = cpu_to_le32(cap); |
| 1823 | @@ -2285,14 +2292,14 @@ mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev, |
| 1824 | int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev, |
| 1825 | struct ieee80211_bss_conf *conf, |
| 1826 | struct mt7996_bss_conf *mconf, |
| 1827 | - struct ieee80211_sta *sta, bool changed) |
| 1828 | + struct ieee80211_link_sta *link_sta, |
| 1829 | + struct mt7996_link_sta *mlink, bool changed) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1830 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1831 | - struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1832 | struct sk_buff *skb; |
| 1833 | int ret; |
| 1834 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1835 | skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76, |
| 1836 | - &msta->wcid, |
| 1837 | + &mlink->wcid, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1838 | MT7996_STA_UPDATE_MAX_SIZE); |
| 1839 | if (IS_ERR(skb)) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1840 | return PTR_ERR(skb); |
| 1841 | @@ -2302,26 +2309,27 @@ int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1842 | * update sta_rec_he here. |
| 1843 | */ |
| 1844 | if (changed) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1845 | - mt7996_mcu_sta_he_tlv(skb, conf, mconf, sta); |
| 1846 | + mt7996_mcu_sta_he_tlv(skb, conf, mconf, link_sta); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1847 | |
| 1848 | /* sta_rec_ra accommodates BW, NSS and only MCS range format |
| 1849 | * i.e 0-{7,8,9} for VHT. |
| 1850 | */ |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1851 | - mt7996_mcu_sta_rate_ctrl_tlv(skb, dev, conf, mconf, sta); |
| 1852 | + mt7996_mcu_sta_rate_ctrl_tlv(skb, dev, conf, mconf, link_sta); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1853 | |
| 1854 | ret = mt76_mcu_skb_send_msg(&dev->mt76, skb, |
| 1855 | MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true); |
| 1856 | if (ret) |
| 1857 | return ret; |
| 1858 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1859 | - return mt7996_mcu_add_rate_ctrl_fixed(dev, conf, mconf, sta); |
| 1860 | + return mt7996_mcu_add_rate_ctrl_fixed(dev, conf, mconf, link_sta, mlink); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1861 | } |
| 1862 | |
| 1863 | static int |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1864 | -mt7996_mcu_sta_init_vow(struct mt7996_bss_conf *mconf, struct mt7996_sta *msta) |
| 1865 | +mt7996_mcu_sta_init_vow(struct mt7996_bss_conf *mconf, |
| 1866 | + struct mt7996_link_sta *mlink) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1867 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1868 | struct mt7996_phy *phy = mconf->phy; |
| 1869 | - struct mt7996_vow_sta_ctrl *vow = &msta->vow; |
| 1870 | + struct mt7996_vow_sta_ctrl *vow = &mlink->vow; |
| 1871 | u8 omac_idx = mconf->mt76.omac_idx; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1872 | int ret; |
| 1873 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1874 | @@ -2339,33 +2347,28 @@ mt7996_mcu_sta_init_vow(struct mt7996_bss_conf *mconf, struct mt7996_sta *msta) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1875 | vow->drr_quantum[IEEE80211_AC_BE] = VOW_DRR_QUANTUM_IDX2; |
| 1876 | vow->drr_quantum[IEEE80211_AC_BK] = VOW_DRR_QUANTUM_IDX2; |
| 1877 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1878 | - ret = mt7996_mcu_set_vow_drr_ctrl(phy, mconf, msta, VOW_DRR_CTRL_STA_BSS_GROUP); |
| 1879 | + ret = mt7996_mcu_set_vow_drr_ctrl(phy, mconf, mlink, VOW_DRR_CTRL_STA_BSS_GROUP); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1880 | if (ret) |
| 1881 | return ret; |
| 1882 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1883 | - ret = mt7996_mcu_set_vow_drr_ctrl(phy, mconf, msta, VOW_DRR_CTRL_STA_PAUSE); |
| 1884 | + ret = mt7996_mcu_set_vow_drr_ctrl(phy, mconf, mlink, VOW_DRR_CTRL_STA_PAUSE); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1885 | if (ret) |
| 1886 | return ret; |
| 1887 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1888 | - return mt7996_mcu_set_vow_drr_ctrl(phy, mconf, msta, VOW_DRR_CTRL_STA_ALL); |
| 1889 | + return mt7996_mcu_set_vow_drr_ctrl(phy, mconf, mlink, VOW_DRR_CTRL_STA_ALL); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1890 | } |
| 1891 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1892 | int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_bss_conf *conf, |
| 1893 | - struct mt7996_bss_conf *mconf, struct ieee80211_sta *sta, |
| 1894 | - bool enable, bool newly) |
| 1895 | + struct mt7996_bss_conf *mconf, |
| 1896 | + struct ieee80211_link_sta *link_sta, |
| 1897 | + struct mt7996_link_sta *mlink, bool enable, bool newly) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1898 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1899 | struct ieee80211_vif *vif = conf->vif; |
| 1900 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1901 | - struct ieee80211_link_sta *link_sta; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1902 | - struct mt7996_sta *msta; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1903 | struct sk_buff *skb; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1904 | int ret; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1905 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1906 | - msta = sta ? (struct mt7996_sta *)sta->drv_priv : &mvif->sta; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1907 | - link_sta = sta ? &sta->deflink : NULL; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1908 | - |
| 1909 | skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76, |
| 1910 | - &msta->wcid, |
| 1911 | + &mlink->wcid, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1912 | MT7996_STA_UPDATE_MAX_SIZE); |
| 1913 | if (IS_ERR(skb)) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1914 | return PTR_ERR(skb); |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1915 | @@ -2378,37 +2381,37 @@ int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_bss_conf *conf, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1916 | goto out; |
| 1917 | |
| 1918 | /* starec hdr trans */ |
| 1919 | - mt7996_mcu_sta_hdr_trans_tlv(dev, skb, vif, sta); |
| 1920 | + mt7996_mcu_sta_hdr_trans_tlv(dev, skb, vif, mlink); |
| 1921 | /* starec tx proc */ |
| 1922 | mt7996_mcu_sta_tx_proc_tlv(skb); |
| 1923 | |
| 1924 | /* tag order is in accordance with firmware dependency. */ |
| 1925 | - if (sta) { |
| 1926 | + if (link_sta) { |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1927 | /* starec hdrt mode */ |
| 1928 | mt7996_mcu_sta_hdrt_tlv(dev, skb); |
| 1929 | /* starec bfer */ |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1930 | - mt7996_mcu_sta_bfer_tlv(dev, skb, conf, mconf, sta); |
| 1931 | + mt7996_mcu_sta_bfer_tlv(dev, skb, conf, mconf, link_sta); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1932 | /* starec ht */ |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1933 | - mt7996_mcu_sta_ht_tlv(skb, sta); |
| 1934 | + mt7996_mcu_sta_ht_tlv(skb, link_sta); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1935 | /* starec vht */ |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1936 | - mt7996_mcu_sta_vht_tlv(skb, sta); |
| 1937 | + mt7996_mcu_sta_vht_tlv(skb, link_sta); |
| 1938 | /* starec uapsd */ |
| 1939 | - mt76_connac_mcu_sta_uapsd(skb, vif, sta); |
| 1940 | + mt76_connac_mcu_sta_uapsd(skb, vif, link_sta->sta); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1941 | /* starec amsdu */ |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1942 | - mt7996_mcu_sta_amsdu_tlv(dev, skb, vif, sta); |
| 1943 | + mt7996_mcu_sta_amsdu_tlv(dev, skb, vif, link_sta, mlink); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1944 | /* starec he */ |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1945 | - mt7996_mcu_sta_he_tlv(skb, conf, mconf, sta); |
| 1946 | + mt7996_mcu_sta_he_tlv(skb, conf, mconf, link_sta); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1947 | /* starec he 6g*/ |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1948 | - mt7996_mcu_sta_he_6g_tlv(skb, sta); |
| 1949 | + mt7996_mcu_sta_he_6g_tlv(skb, link_sta); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1950 | /* starec eht */ |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1951 | - mt7996_mcu_sta_eht_tlv(skb, sta); |
| 1952 | + mt7996_mcu_sta_eht_tlv(skb, link_sta); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1953 | /* starec muru */ |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1954 | - mt7996_mcu_sta_muru_tlv(dev, skb, conf, mconf, sta); |
| 1955 | + mt7996_mcu_sta_muru_tlv(dev, skb, conf, mconf, link_sta); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1956 | /* starec bfee */ |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1957 | - mt7996_mcu_sta_bfee_tlv(dev, skb, conf, mconf, sta); |
| 1958 | + mt7996_mcu_sta_bfee_tlv(dev, skb, conf, mconf, link_sta); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1959 | } |
| 1960 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1961 | - ret = mt7996_mcu_sta_init_vow(mconf, msta); |
| 1962 | + ret = mt7996_mcu_sta_init_vow(mconf, mlink); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1963 | if (ret) { |
| 1964 | dev_kfree_skb(skb); |
| 1965 | return ret; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1966 | @@ -2484,16 +2487,16 @@ int mt7996_mcu_add_key(struct mt76_dev *dev, struct mt7996_bss_conf *mconf, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1967 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1968 | static int mt7996_mcu_get_pn(struct mt7996_dev *dev, |
| 1969 | struct ieee80211_bss_conf *conf, |
| 1970 | - struct mt7996_bss_conf *mconf, u8 *pn) |
| 1971 | + struct mt7996_bss_conf *mconf, |
| 1972 | + struct mt7996_link_sta *mlink, u8 *pn) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1973 | { |
| 1974 | #define TSC_TYPE_BIGTK_PN 2 |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1975 | - struct mt7996_vif *mvif = (struct mt7996_vif *)conf->vif->drv_priv; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1976 | struct sta_rec_pn_info *pn_info; |
| 1977 | struct sk_buff *skb, *rskb; |
| 1978 | struct tlv *tlv; |
| 1979 | int ret; |
| 1980 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1981 | - skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76, &mvif->sta.wcid); |
| 1982 | + skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76, &mlink->wcid); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1983 | if (IS_ERR(skb)) |
| 1984 | return PTR_ERR(skb); |
| 1985 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1986 | @@ -2520,6 +2523,7 @@ static int mt7996_mcu_get_pn(struct mt7996_dev *dev, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1987 | int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev, |
| 1988 | struct ieee80211_bss_conf *conf, |
| 1989 | struct mt7996_bss_conf *mconf, |
| 1990 | + struct mt7996_link_sta *mlink, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1991 | struct ieee80211_key_conf *key) |
| 1992 | { |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1993 | struct mt7996_mcu_bcn_prot_tlv *bcn_prot; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1994 | @@ -2538,7 +2542,7 @@ int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1995 | |
| 1996 | bcn_prot = (struct mt7996_mcu_bcn_prot_tlv *)tlv; |
| 1997 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1998 | - ret = mt7996_mcu_get_pn(dev, conf, mconf, pn); |
| 1999 | + ret = mt7996_mcu_get_pn(dev, conf, mconf, mlink, pn); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2000 | if (ret) { |
| 2001 | dev_kfree_skb(skb); |
| 2002 | return ret; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2003 | @@ -4814,21 +4818,18 @@ int mt7996_mcu_rdd_background_disable_timer(struct mt7996_dev *dev, bool disable |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2004 | int mt7996_mcu_wtbl_update_hdr_trans(struct mt7996_dev *dev, |
| 2005 | struct ieee80211_vif *vif, |
| 2006 | struct mt7996_bss_conf *mconf, |
| 2007 | - struct ieee80211_sta *sta) |
| 2008 | + struct mt7996_link_sta *mlink) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2009 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2010 | - struct mt7996_sta *msta; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2011 | struct sk_buff *skb; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2012 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2013 | - msta = sta ? (struct mt7996_sta *)sta->drv_priv : &mconf->vif->sta; |
| 2014 | - |
| 2015 | skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76, |
| 2016 | - &msta->wcid, |
| 2017 | + &mlink->wcid, |
| 2018 | MT7996_STA_UPDATE_MAX_SIZE); |
| 2019 | if (IS_ERR(skb)) |
| 2020 | return PTR_ERR(skb); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2021 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2022 | /* starec hdr trans */ |
| 2023 | - mt7996_mcu_sta_hdr_trans_tlv(dev, skb, vif, sta); |
| 2024 | + mt7996_mcu_sta_hdr_trans_tlv(dev, skb, vif, mlink); |
| 2025 | return mt76_mcu_skb_send_msg(&dev->mt76, skb, |
| 2026 | MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2027 | } |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2028 | @@ -5017,7 +5018,7 @@ int mt7996_mcu_get_per_sta_info(struct mt76_dev *dev, u16 tag, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2029 | switch (tag) { |
| 2030 | case UNI_PER_STA_RSSI: |
| 2031 | for (i = 0; i < sta_num; ++i) { |
| 2032 | - struct mt7996_sta *msta; |
| 2033 | + struct mt7996_link_sta *mlink; |
| 2034 | struct mt76_phy *phy; |
| 2035 | s8 rssi[4]; |
| 2036 | u8 *rcpi; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2037 | @@ -5031,10 +5032,10 @@ int mt7996_mcu_get_per_sta_info(struct mt76_dev *dev, u16 tag, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2038 | rssi[2] = to_rssi(MT_PRXV_RCPI0, rcpi[2]); |
| 2039 | rssi[3] = to_rssi(MT_PRXV_RCPI0, rcpi[3]); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2040 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2041 | - msta = container_of(wcid, struct mt7996_sta, wcid); |
| 2042 | - phy = msta->vif->phy->mt76; |
| 2043 | - msta->ack_signal = mt76_rx_signal(phy->antenna_mask, rssi); |
| 2044 | - ewma_avg_signal_add(&msta->avg_ack_signal, -msta->ack_signal); |
| 2045 | + mlink = container_of(wcid, struct mt7996_link_sta, wcid); |
| 2046 | + phy = mlink->sta->vif->deflink.phy->mt76; |
| 2047 | + mlink->ack_signal = mt76_rx_signal(phy->antenna_mask, rssi); |
| 2048 | + ewma_avg_signal_add(&mlink->avg_ack_signal, -mlink->ack_signal); |
| 2049 | } else { |
| 2050 | ret = -EINVAL; |
| 2051 | dev_err(dev->dev, "Failed to update RSSI for " |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2052 | @@ -5056,7 +5057,7 @@ int mt7996_mcu_get_rssi(struct mt76_dev *dev) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2053 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2054 | u16 sta_list[PER_STA_INFO_MAX_NUM]; |
| 2055 | LIST_HEAD(sta_poll_list); |
| 2056 | - struct mt7996_sta *msta; |
| 2057 | + struct mt7996_link_sta *mlink; |
| 2058 | int i, ret; |
| 2059 | bool empty = false; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2060 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2061 | @@ -5076,13 +5077,13 @@ int mt7996_mcu_get_rssi(struct mt76_dev *dev) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2062 | empty = true; |
| 2063 | break; |
| 2064 | } |
| 2065 | - msta = list_first_entry(&sta_poll_list, |
| 2066 | - struct mt7996_sta, |
| 2067 | + mlink = list_first_entry(&sta_poll_list, |
| 2068 | + struct mt7996_link_sta, |
| 2069 | wcid.poll_list); |
| 2070 | - list_del_init(&msta->wcid.poll_list); |
| 2071 | + list_del_init(&mlink->wcid.poll_list); |
| 2072 | spin_unlock_bh(&dev->sta_poll_lock); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2073 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2074 | - sta_list[i] = msta->wcid.idx; |
| 2075 | + sta_list[i] = mlink->wcid.idx; |
| 2076 | } |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2077 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2078 | ret = mt7996_mcu_get_per_sta_info(dev, UNI_PER_STA_RSSI, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2079 | @@ -5372,10 +5373,18 @@ int mt7996_mcu_set_scs_stats(struct mt7996_phy *phy) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2080 | void mt7996_sta_rssi_work(void *data, struct ieee80211_sta *sta) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2081 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2082 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 2083 | + struct mt7996_link_sta *mlink; |
| 2084 | struct mt7996_phy *poll_phy = (struct mt7996_phy *) data; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2085 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2086 | - if (poll_phy->scs_ctrl.sta_min_rssi > msta->ack_signal) |
| 2087 | - poll_phy->scs_ctrl.sta_min_rssi = msta->ack_signal; |
| 2088 | + mutex_lock(&poll_phy->dev->mt76.mutex); |
| 2089 | + mlink = mlink_dereference_protected(msta, 0); |
| 2090 | + if (!mlink) |
| 2091 | + goto out; |
| 2092 | + |
| 2093 | + if (poll_phy->scs_ctrl.sta_min_rssi > mlink->ack_signal) |
| 2094 | + poll_phy->scs_ctrl.sta_min_rssi = mlink->ack_signal; |
| 2095 | +out: |
| 2096 | + mutex_unlock(&poll_phy->dev->mt76.mutex); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2097 | } |
| 2098 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2099 | void mt7996_mcu_scs_sta_poll(struct work_struct *work) |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2100 | @@ -5451,9 +5460,10 @@ int mt7996_mcu_set_scs(struct mt7996_phy *phy, u8 enable) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2101 | |
| 2102 | int mt7996_mcu_set_vow_drr_ctrl(struct mt7996_phy *phy, |
| 2103 | struct mt7996_bss_conf *mconf, |
| 2104 | - struct mt7996_sta *msta, enum vow_drr_ctrl_id id) |
| 2105 | + struct mt7996_link_sta *mlink, |
| 2106 | + enum vow_drr_ctrl_id id) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2107 | { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2108 | - struct mt7996_vow_sta_ctrl *vow = msta ? &msta->vow : NULL; |
| 2109 | + struct mt7996_vow_sta_ctrl *vow = mlink ? &mlink->vow : NULL; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2110 | u32 val = 0; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2111 | struct { |
| 2112 | u8 __rsv1[4]; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2113 | @@ -5475,11 +5485,11 @@ int mt7996_mcu_set_vow_drr_ctrl(struct mt7996_phy *phy, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2114 | } __packed req = { |
| 2115 | .tag = cpu_to_le16(UNI_VOW_DRR_CTRL), |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2116 | .len = cpu_to_le16(sizeof(req) - 4), |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2117 | - .wlan_idx = cpu_to_le16(msta ? msta->wcid.idx : 0), |
| 2118 | + .wlan_idx = cpu_to_le16(mlink ? mlink->wcid.idx : 0), |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2119 | .band_idx = phy->mt76->band_idx, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2120 | - .wmm_idx = msta ? mconf->mt76.wmm_idx : 0, |
| 2121 | + .wmm_idx = mlink ? mconf->mt76.wmm_idx : 0, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2122 | .ctrl_id = cpu_to_le32(id), |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2123 | - .omac_idx = msta ? mconf->mt76.omac_idx : 0 |
| 2124 | + .omac_idx = mlink ? mconf->mt76.omac_idx : 0 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2125 | }; |
| 2126 | |
| 2127 | switch (id) { |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2128 | diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2129 | index 46964079..1732ff36 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2130 | --- a/mt7996/mt7996.h |
| 2131 | +++ b/mt7996/mt7996.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2132 | @@ -303,10 +303,10 @@ struct mt7996_vow_sta_ctrl { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2133 | u8 drr_quantum[IEEE80211_NUM_ACS]; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2134 | }; |
| 2135 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2136 | -struct mt7996_sta { |
| 2137 | +struct mt7996_link_sta { |
| 2138 | struct mt76_wcid wcid; /* must be first */ |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2139 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2140 | - struct mt7996_vif *vif; |
| 2141 | + struct mt7996_sta *sta; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2142 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2143 | struct list_head rc_list; |
| 2144 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2145 | @@ -325,6 +325,13 @@ struct mt7996_sta { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2146 | struct mt7996_vow_sta_ctrl vow; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2147 | }; |
| 2148 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2149 | +struct mt7996_sta { |
| 2150 | + struct mt7996_link_sta deflink; |
| 2151 | + struct mt7996_link_sta __rcu *link[IEEE80211_MLD_MAX_NUM_LINKS]; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2152 | + |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2153 | + struct mt7996_vif *vif; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2154 | +}; |
| 2155 | + |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2156 | struct mt7996_bss_conf { |
| 2157 | struct mt76_vif mt76; /* must be first */ |
| 2158 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2159 | @@ -784,6 +791,13 @@ mconf_dereference_protected(struct mt7996_vif *mvif, u8 link_id) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2160 | lockdep_is_held(&mvif->dev->mt76.mutex)); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2161 | } |
| 2162 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2163 | +static inline struct mt7996_link_sta * |
| 2164 | +mlink_dereference_protected(struct mt7996_sta *msta, u8 link_id) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2165 | +{ |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2166 | + return rcu_dereference_protected(msta->link[link_id], |
| 2167 | + lockdep_is_held(&msta->vif->dev->mt76.mutex)); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2168 | +} |
| 2169 | + |
| 2170 | extern const struct ieee80211_ops mt7996_ops; |
| 2171 | extern struct pci_driver mt7996_pci_driver; |
| 2172 | extern struct pci_driver mt7996_hif_driver; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2173 | @@ -828,10 +842,12 @@ int mt7996_mcu_add_dev_info(struct mt7996_phy *phy, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2174 | struct mt7996_bss_conf *mconf, bool enable); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2175 | int mt7996_mcu_add_bss_info(struct mt7996_phy *phy, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2176 | struct ieee80211_bss_conf *conf, |
| 2177 | - struct mt7996_bss_conf *mconf, int enable); |
| 2178 | + struct mt7996_bss_conf *mconf, |
| 2179 | + struct mt7996_link_sta *mlink, int enable); |
| 2180 | int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_bss_conf *conf, |
| 2181 | - struct mt7996_bss_conf *mconf, struct ieee80211_sta *sta, |
| 2182 | - bool enable, bool newly); |
| 2183 | + struct mt7996_bss_conf *mconf, |
| 2184 | + struct ieee80211_link_sta *link_sta, |
| 2185 | + struct mt7996_link_sta *mlink, bool enable, bool newly); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2186 | int mt7996_mcu_add_tx_ba(struct mt7996_dev *dev, |
| 2187 | struct ieee80211_ampdu_params *params, |
| 2188 | bool add); |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2189 | @@ -853,7 +869,8 @@ int mt7996_mcu_add_obss_spr(struct mt7996_phy *phy, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2190 | int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev, |
| 2191 | struct ieee80211_bss_conf *conf, |
| 2192 | struct mt7996_bss_conf *mconf, |
| 2193 | - struct ieee80211_sta *sta, bool changed); |
| 2194 | + struct ieee80211_link_sta *link_sta, |
| 2195 | + struct mt7996_link_sta *mlink, bool changed); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2196 | int mt7996_set_channel(struct mt7996_phy *phy, struct cfg80211_chan_def *chandef); |
| 2197 | int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2198 | int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct mt7996_bss_conf *mconf); |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2199 | @@ -861,7 +878,9 @@ int mt7996_mcu_set_fixed_rate_ctrl(struct mt7996_dev *dev, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2200 | void *data, u16 version); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2201 | int mt7996_mcu_set_fixed_field(struct mt7996_dev *dev, |
| 2202 | struct mt7996_bss_conf *mconf, |
| 2203 | - struct ieee80211_sta *sta, void *data, u32 field); |
| 2204 | + struct ieee80211_link_sta *link_sta, |
| 2205 | + struct mt7996_link_sta *mlink, void *data, |
| 2206 | + u32 field); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2207 | int mt7996_mcu_set_eeprom(struct mt7996_dev *dev); |
| 2208 | int mt7996_mcu_get_eeprom(struct mt7996_dev *dev, u32 offset, u8 *read_buf); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2209 | int mt7996_mcu_get_eeprom_free_block(struct mt7996_dev *dev, u8 *block_num); |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2210 | @@ -917,7 +936,8 @@ void mt7996_mcu_scs_sta_poll(struct work_struct *work); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2211 | int mt7996_mcu_set_band_confg(struct mt7996_phy *phy, u16 option, bool enable); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2212 | int mt7996_mcu_set_vow_drr_ctrl(struct mt7996_phy *phy, |
| 2213 | struct mt7996_bss_conf *mconf, |
| 2214 | - struct mt7996_sta *msta, enum vow_drr_ctrl_id id); |
| 2215 | + struct mt7996_link_sta *mlink, |
| 2216 | + enum vow_drr_ctrl_id id); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2217 | int mt7996_mcu_set_vow_feature_ctrl(struct mt7996_phy *phy); |
| 2218 | void mt7996_mcu_wmm_pbc_work(struct work_struct *work); |
| 2219 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2220 | @@ -984,7 +1004,7 @@ void mt7996_mac_reset_counters(struct mt7996_phy *phy); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2221 | void mt7996_mac_cca_stats_reset(struct mt7996_phy *phy); |
| 2222 | void mt7996_mac_enable_nf(struct mt7996_dev *dev, u8 band); |
| 2223 | void mt7996_mac_enable_rtscts(struct mt7996_dev *dev, |
| 2224 | - struct ieee80211_vif *vif, bool enable); |
| 2225 | + struct mt7996_link_sta *mlink, bool enable); |
| 2226 | void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi, |
| 2227 | struct sk_buff *skb, struct mt76_wcid *wcid, |
| 2228 | struct ieee80211_key_conf *key, int pid, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2229 | @@ -1002,8 +1022,7 @@ void mt7996_mac_dump_work(struct work_struct *work); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2230 | void mt7996_mac_sta_rc_work(struct work_struct *work); |
| 2231 | void mt7996_mac_update_stats(struct mt7996_phy *phy); |
| 2232 | void mt7996_mac_twt_teardown_flow(struct mt7996_dev *dev, |
| 2233 | - struct mt7996_sta *msta, |
| 2234 | - u8 flowid); |
| 2235 | + struct mt7996_link_sta *mlink, u8 flowid); |
| 2236 | void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw, |
| 2237 | struct ieee80211_sta *sta, |
| 2238 | struct ieee80211_twt_setup *twt); |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2239 | @@ -1032,11 +1051,12 @@ int mt7996_mcu_add_key(struct mt76_dev *dev, struct mt7996_bss_conf *mconf, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2240 | int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev, |
| 2241 | struct ieee80211_bss_conf *conf, |
| 2242 | struct mt7996_bss_conf *mconf, |
| 2243 | + struct mt7996_link_sta *mlink, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2244 | struct ieee80211_key_conf *key); |
| 2245 | int mt7996_mcu_wtbl_update_hdr_trans(struct mt7996_dev *dev, |
| 2246 | struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2247 | struct mt7996_bss_conf *mconf, |
| 2248 | - struct ieee80211_sta *sta); |
| 2249 | + struct mt7996_link_sta *mlink); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2250 | int mt7996_mcu_cp_support(struct mt7996_dev *dev, u8 mode); |
| 2251 | int mt7996_mcu_set_pp_en(struct mt7996_phy *phy, u8 mode, u16 bitmap); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2252 | #ifdef CONFIG_MAC80211_DEBUGFS |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2253 | diff --git a/mt7996/testmode.c b/mt7996/testmode.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 2254 | index bf55b430..ba17f947 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2255 | --- a/mt7996/testmode.c |
| 2256 | +++ b/mt7996/testmode.c |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2257 | @@ -235,8 +235,8 @@ mt7996_tm_init(struct mt7996_phy *phy, bool en) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2258 | |
| 2259 | mt7996_tm_rf_switch_mode(dev, rf_test_mode); |
| 2260 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2261 | - mt7996_mcu_add_bss_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, en); |
| 2262 | - mt7996_mcu_add_sta(dev, &phy->monitor_vif->bss_conf, &mvif->deflink, NULL, en, false); |
| 2263 | + mt7996_mcu_add_bss_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, &mvif->sta.deflink, en); |
| 2264 | + mt7996_mcu_add_sta(dev, &phy->monitor_vif->bss_conf, &mvif->deflink, NULL, &mvif->sta.deflink, en, false); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2265 | |
| 2266 | mt7996_tm_set(dev, SET_ID(BAND_IDX), phy->mt76->band_idx); |
| 2267 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2268 | @@ -1186,7 +1186,7 @@ mt7996_tm_txbf_init(struct mt7996_phy *phy, u16 *val) |
| 2269 | phy->omac_mask |= BIT_ULL(mvif->deflink.mt76.omac_idx); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2270 | |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2271 | mt7996_mcu_add_dev_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, true); |
| 2272 | - mt7996_mcu_add_bss_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, true); |
| 2273 | + mt7996_mcu_add_bss_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, &mvif->sta.deflink, true); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2274 | |
| 2275 | if (td->ibf) { |
| 2276 | if (td->is_txbf_dut) { |
| 2277 | -- |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2278 | 2.18.0 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2279 | |