developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1 | From 7ee1d3297a47a4e1d14fef747bee991dadd6298b 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> |
| 3 | Date: Mon, 11 Dec 2023 18:45:00 +0800 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 103/199] mtk: mt76: rework connac helpers |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 5 | |
| 6 | Rework connac helpers related to rate and phymode. |
| 7 | This is a preliminary patch to add MLO support for mt7996 chipsets. |
| 8 | |
| 9 | Co-developed-by: Bo Jiao <Bo.Jiao@mediatek.com> |
| 10 | Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com> |
| 11 | Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> |
| 12 | --- |
| 13 | mt76_connac.h | 2 +- |
| 14 | mt76_connac_mac.c | 17 ++++++++--------- |
| 15 | mt76_connac_mcu.c | 6 +++--- |
| 16 | mt76_connac_mcu.h | 2 +- |
| 17 | mt7925/main.c | 2 +- |
| 18 | mt7996/main.c | 2 +- |
| 19 | mt7996/mcu.c | 2 +- |
| 20 | 7 files changed, 16 insertions(+), 17 deletions(-) |
| 21 | |
| 22 | diff --git a/mt76_connac.h b/mt76_connac.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 23 | index 445d0f0a..f7766a98 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 24 | --- a/mt76_connac.h |
| 25 | +++ b/mt76_connac.h |
| 26 | @@ -427,7 +427,7 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi, |
| 27 | struct ieee80211_key_conf *key, int pid, |
| 28 | enum mt76_txq_id qid, u32 changed); |
| 29 | u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy, |
| 30 | - struct ieee80211_vif *vif, |
| 31 | + struct ieee80211_bss_conf *conf, |
| 32 | bool beacon, bool mcast); |
| 33 | bool mt76_connac2_mac_fill_txs(struct mt76_dev *dev, struct mt76_wcid *wcid, |
| 34 | __le32 *txs_data); |
| 35 | diff --git a/mt76_connac_mac.c b/mt76_connac_mac.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 36 | index b841bf62..c1e9ba0f 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 37 | --- a/mt76_connac_mac.c |
| 38 | +++ b/mt76_connac_mac.c |
| 39 | @@ -291,12 +291,11 @@ EXPORT_SYMBOL_GPL(mt76_connac_init_tx_queues); |
| 40 | }) |
| 41 | |
| 42 | u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy, |
| 43 | - struct ieee80211_vif *vif, |
| 44 | + struct ieee80211_bss_conf *conf, |
| 45 | bool beacon, bool mcast) |
| 46 | { |
| 47 | - struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; |
| 48 | - struct cfg80211_chan_def *chandef = mvif->ctx ? |
| 49 | - &mvif->ctx->def : &mphy->chandef; |
| 50 | + struct ieee80211_vif *vif = conf->vif; |
| 51 | + struct cfg80211_chan_def *chandef = &mphy->chandef; |
| 52 | u8 nss = 0, mode = 0, band = chandef->chan->band; |
| 53 | int rateidx = 0, mcast_rate; |
| 54 | |
| 55 | @@ -304,14 +303,14 @@ u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy, |
| 56 | goto legacy; |
| 57 | |
| 58 | if (is_mt7921(mphy->dev)) { |
| 59 | - rateidx = ffs(vif->bss_conf.basic_rates) - 1; |
| 60 | + rateidx = ffs(conf->basic_rates) - 1; |
| 61 | goto legacy; |
| 62 | } |
| 63 | |
| 64 | if (beacon) { |
| 65 | struct cfg80211_bitrate_mask *mask; |
| 66 | |
| 67 | - mask = &vif->bss_conf.beacon_tx_rate; |
| 68 | + mask = &conf->beacon_tx_rate; |
| 69 | |
| 70 | __bitrate_mask_check(he_mcs, HE_SU); |
| 71 | __bitrate_mask_check(vht_mcs, VHT); |
| 72 | @@ -323,11 +322,11 @@ u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy, |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | - mcast_rate = vif->bss_conf.mcast_rate[band]; |
| 77 | + mcast_rate = conf->mcast_rate[band]; |
| 78 | if (mcast && mcast_rate > 0) |
| 79 | rateidx = mcast_rate - 1; |
| 80 | else |
| 81 | - rateidx = ffs(vif->bss_conf.basic_rates) - 1; |
| 82 | + rateidx = ffs(conf->basic_rates) - 1; |
| 83 | |
| 84 | legacy: |
| 85 | rateidx = mt76_calculate_default_rate(mphy, vif, rateidx); |
| 86 | @@ -561,7 +560,7 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi, |
| 87 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
| 88 | bool multicast = ieee80211_is_data(hdr->frame_control) && |
| 89 | is_multicast_ether_addr(hdr->addr1); |
| 90 | - u16 rate = mt76_connac2_mac_tx_rate_val(mphy, vif, beacon, |
| 91 | + u16 rate = mt76_connac2_mac_tx_rate_val(mphy, &vif->bss_conf, beacon, |
| 92 | multicast); |
| 93 | u32 val = MT_TXD6_FIXED_BW; |
| 94 | |
| 95 | diff --git a/mt76_connac_mcu.c b/mt76_connac_mcu.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 96 | index de4e0019..ab7cf4a6 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 97 | --- a/mt76_connac_mcu.c |
| 98 | +++ b/mt76_connac_mcu.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 99 | @@ -1366,7 +1366,7 @@ u8 mt76_connac_get_phy_mode(struct mt76_phy *phy, struct ieee80211_vif *vif, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 100 | } |
| 101 | EXPORT_SYMBOL_GPL(mt76_connac_get_phy_mode); |
| 102 | |
| 103 | -u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif, |
| 104 | +u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_bss_conf *conf, |
| 105 | enum nl80211_band band) |
| 106 | { |
| 107 | const struct ieee80211_sta_eht_cap *eht_cap; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 108 | @@ -1377,9 +1377,9 @@ u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 109 | mode |= PHY_MODE_AX_6G; |
| 110 | |
| 111 | sband = phy->hw->wiphy->bands[band]; |
| 112 | - eht_cap = ieee80211_get_eht_iftype_cap(sband, vif->type); |
| 113 | + eht_cap = ieee80211_get_eht_iftype_cap(sband, conf->vif->type); |
| 114 | |
| 115 | - if (!eht_cap || !eht_cap->has_eht || !vif->bss_conf.eht_support) |
| 116 | + if (!eht_cap || !eht_cap->has_eht || !conf->eht_support) |
| 117 | return mode; |
| 118 | |
| 119 | switch (band) { |
| 120 | diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 121 | index 226e9a94..f6a0d328 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 122 | --- a/mt76_connac_mcu.h |
| 123 | +++ b/mt76_connac_mcu.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 124 | @@ -2036,7 +2036,7 @@ mt76_connac_get_eht_phy_cap(struct mt76_phy *phy, struct ieee80211_vif *vif); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 125 | u8 mt76_connac_get_phy_mode(struct mt76_phy *phy, struct ieee80211_vif *vif, |
| 126 | enum nl80211_band band, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 127 | struct ieee80211_link_sta *sta); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 128 | -u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif, |
| 129 | +u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_bss_conf *conf, |
| 130 | enum nl80211_band band); |
| 131 | |
| 132 | int mt76_connac_mcu_add_key(struct mt76_dev *dev, struct ieee80211_vif *vif, |
| 133 | diff --git a/mt7925/main.c b/mt7925/main.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 134 | index 8c0768bf..c1b1cd8a 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 135 | --- a/mt7925/main.c |
| 136 | +++ b/mt7925/main.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 137 | @@ -793,7 +793,7 @@ mt7925_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 138 | u16 rate; |
| 139 | u8 i, idx, ht; |
| 140 | |
| 141 | - rate = mt76_connac2_mac_tx_rate_val(mphy, vif, beacon, mcast); |
| 142 | + rate = mt76_connac2_mac_tx_rate_val(mphy, &vif->bss_conf, beacon, mcast); |
| 143 | ht = FIELD_GET(MT_TX_RATE_MODE, rate) > MT_PHY_TYPE_OFDM; |
| 144 | |
| 145 | if (beacon && ht) { |
| 146 | diff --git a/mt7996/main.c b/mt7996/main.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 147 | index 65e244da..1ea81d62 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 148 | --- a/mt7996/main.c |
| 149 | +++ b/mt7996/main.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 150 | @@ -808,7 +808,7 @@ mt7996_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_bss_conf *conf, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 151 | u16 rate; |
| 152 | u8 i, idx; |
| 153 | |
| 154 | - rate = mt76_connac2_mac_tx_rate_val(mphy, conf->vif, beacon, mcast); |
| 155 | + rate = mt76_connac2_mac_tx_rate_val(mphy, conf, beacon, mcast); |
| 156 | |
| 157 | if (beacon) { |
| 158 | struct mt7996_phy *phy = mphy->priv; |
| 159 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 160 | index 1f320a7b..bf7231cd 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 161 | --- a/mt7996/mcu.c |
| 162 | +++ b/mt7996/mcu.c |
| 163 | @@ -1219,7 +1219,7 @@ mt7996_mcu_bss_basic_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *conf, |
| 164 | bss->dtim_period = conf->dtim_period; |
| 165 | bss->phymode = mt76_connac_get_phy_mode(phy, vif, |
| 166 | chandef->chan->band, NULL); |
| 167 | - bss->phymode_ext = mt76_connac_get_phy_mode_ext(phy, vif, |
| 168 | + bss->phymode_ext = mt76_connac_get_phy_mode_ext(phy, conf, |
| 169 | chandef->chan->band); |
| 170 | |
| 171 | return 0; |
| 172 | -- |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 173 | 2.18.0 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 174 | |