| 1 |
// SPDX-License-Identifier: BSD-3-Clause-Clear |
| 2 |
/* Copyright (C) 2023 MediaTek Inc. */ |
| 3 |
|
| 4 |
#include <linux/etherdevice.h> |
| 5 |
#include <linux/platform_device.h> |
| 6 |
#include <linux/pci.h> |
| 7 |
#include <linux/module.h> |
| 8 |
#include <linux/ctype.h> |
| 9 |
#include <net/ipv6.h> |
| 10 |
#include "mt7925.h" |
| 11 |
#include "regd.h" |
| 12 |
#include "mcu.h" |
| 13 |
#include "mac.h" |
| 14 |
|
| 15 |
static void |
| 16 |
mt7925_init_he_caps(struct mt792x_phy *phy, enum nl80211_band band, |
| 17 |
struct ieee80211_sband_iftype_data *data, |
| 18 |
enum nl80211_iftype iftype) |
| 19 |
{ |
| 20 |
struct ieee80211_sta_he_cap *he_cap = &data->he_cap; |
| 21 |
struct ieee80211_he_cap_elem *he_cap_elem = &he_cap->he_cap_elem; |
| 22 |
struct ieee80211_he_mcs_nss_supp *he_mcs = &he_cap->he_mcs_nss_supp; |
| 23 |
int i, nss = hweight8(phy->mt76->antenna_mask); |
| 24 |
u16 mcs_map = 0; |
| 25 |
|
| 26 |
for (i = 0; i < 8; i++) { |
| 27 |
if (i < nss) |
| 28 |
mcs_map |= (IEEE80211_HE_MCS_SUPPORT_0_11 << (i * 2)); |
| 29 |
else |
| 30 |
mcs_map |= (IEEE80211_HE_MCS_NOT_SUPPORTED << (i * 2)); |
| 31 |
} |
| 32 |
|
| 33 |
he_cap->has_he = true; |
| 34 |
|
| 35 |
he_cap_elem->mac_cap_info[0] = IEEE80211_HE_MAC_CAP0_HTC_HE; |
| 36 |
he_cap_elem->mac_cap_info[3] = IEEE80211_HE_MAC_CAP3_OMI_CONTROL | |
| 37 |
IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_3; |
| 38 |
he_cap_elem->mac_cap_info[4] = IEEE80211_HE_MAC_CAP4_AMSDU_IN_AMPDU; |
| 39 |
|
| 40 |
if (band == NL80211_BAND_2GHZ) |
| 41 |
he_cap_elem->phy_cap_info[0] = |
| 42 |
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G; |
| 43 |
else |
| 44 |
he_cap_elem->phy_cap_info[0] = |
| 45 |
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G | |
| 46 |
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G; |
| 47 |
|
| 48 |
he_cap_elem->phy_cap_info[1] = |
| 49 |
IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD; |
| 50 |
he_cap_elem->phy_cap_info[2] = |
| 51 |
IEEE80211_HE_PHY_CAP2_NDP_4x_LTF_AND_3_2US | |
| 52 |
IEEE80211_HE_PHY_CAP2_STBC_TX_UNDER_80MHZ | |
| 53 |
IEEE80211_HE_PHY_CAP2_STBC_RX_UNDER_80MHZ | |
| 54 |
IEEE80211_HE_PHY_CAP2_UL_MU_FULL_MU_MIMO | |
| 55 |
IEEE80211_HE_PHY_CAP2_UL_MU_PARTIAL_MU_MIMO; |
| 56 |
|
| 57 |
switch (iftype) { |
| 58 |
case NL80211_IFTYPE_AP: |
| 59 |
he_cap_elem->mac_cap_info[2] |= |
| 60 |
IEEE80211_HE_MAC_CAP2_BSR; |
| 61 |
he_cap_elem->mac_cap_info[4] |= |
| 62 |
IEEE80211_HE_MAC_CAP4_BQR; |
| 63 |
he_cap_elem->mac_cap_info[5] |= |
| 64 |
IEEE80211_HE_MAC_CAP5_OM_CTRL_UL_MU_DATA_DIS_RX; |
| 65 |
he_cap_elem->phy_cap_info[3] |= |
| 66 |
IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_QPSK | |
| 67 |
IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_QPSK; |
| 68 |
he_cap_elem->phy_cap_info[6] |= |
| 69 |
IEEE80211_HE_PHY_CAP6_PARTIAL_BW_EXT_RANGE | |
| 70 |
IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT; |
| 71 |
he_cap_elem->phy_cap_info[9] |= |
| 72 |
IEEE80211_HE_PHY_CAP9_TX_1024_QAM_LESS_THAN_242_TONE_RU | |
| 73 |
IEEE80211_HE_PHY_CAP9_RX_1024_QAM_LESS_THAN_242_TONE_RU; |
| 74 |
break; |
| 75 |
case NL80211_IFTYPE_STATION: |
| 76 |
he_cap_elem->mac_cap_info[1] |= |
| 77 |
IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_16US; |
| 78 |
|
| 79 |
if (band == NL80211_BAND_2GHZ) |
| 80 |
he_cap_elem->phy_cap_info[0] |= |
| 81 |
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_2G; |
| 82 |
else |
| 83 |
he_cap_elem->phy_cap_info[0] |= |
| 84 |
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_5G; |
| 85 |
|
| 86 |
he_cap_elem->phy_cap_info[1] |= |
| 87 |
IEEE80211_HE_PHY_CAP1_DEVICE_CLASS_A | |
| 88 |
IEEE80211_HE_PHY_CAP1_HE_LTF_AND_GI_FOR_HE_PPDUS_0_8US; |
| 89 |
he_cap_elem->phy_cap_info[3] |= |
| 90 |
IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_QPSK | |
| 91 |
IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_QPSK; |
| 92 |
he_cap_elem->phy_cap_info[4] |= |
| 93 |
IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE | |
| 94 |
IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_4 | |
| 95 |
IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_4; |
| 96 |
he_cap_elem->phy_cap_info[5] |= |
| 97 |
IEEE80211_HE_PHY_CAP5_NG16_SU_FEEDBACK | |
| 98 |
IEEE80211_HE_PHY_CAP5_NG16_MU_FEEDBACK; |
| 99 |
he_cap_elem->phy_cap_info[6] |= |
| 100 |
IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_42_SU | |
| 101 |
IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_75_MU | |
| 102 |
IEEE80211_HE_PHY_CAP6_TRIG_CQI_FB | |
| 103 |
IEEE80211_HE_PHY_CAP6_PARTIAL_BW_EXT_RANGE | |
| 104 |
IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT; |
| 105 |
he_cap_elem->phy_cap_info[7] |= |
| 106 |
IEEE80211_HE_PHY_CAP7_POWER_BOOST_FACTOR_SUPP | |
| 107 |
IEEE80211_HE_PHY_CAP7_HE_SU_MU_PPDU_4XLTF_AND_08_US_GI; |
| 108 |
he_cap_elem->phy_cap_info[8] |= |
| 109 |
IEEE80211_HE_PHY_CAP8_20MHZ_IN_40MHZ_HE_PPDU_IN_2G | |
| 110 |
IEEE80211_HE_PHY_CAP8_20MHZ_IN_160MHZ_HE_PPDU | |
| 111 |
IEEE80211_HE_PHY_CAP8_80MHZ_IN_160MHZ_HE_PPDU | |
| 112 |
IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_484; |
| 113 |
he_cap_elem->phy_cap_info[9] |= |
| 114 |
IEEE80211_HE_PHY_CAP9_LONGER_THAN_16_SIGB_OFDM_SYM | |
| 115 |
IEEE80211_HE_PHY_CAP9_NON_TRIGGERED_CQI_FEEDBACK | |
| 116 |
IEEE80211_HE_PHY_CAP9_TX_1024_QAM_LESS_THAN_242_TONE_RU | |
| 117 |
IEEE80211_HE_PHY_CAP9_RX_1024_QAM_LESS_THAN_242_TONE_RU | |
| 118 |
IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_COMP_SIGB | |
| 119 |
IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_NON_COMP_SIGB; |
| 120 |
break; |
| 121 |
default: |
| 122 |
break; |
| 123 |
} |
| 124 |
|
| 125 |
he_mcs->rx_mcs_80 = cpu_to_le16(mcs_map); |
| 126 |
he_mcs->tx_mcs_80 = cpu_to_le16(mcs_map); |
| 127 |
he_mcs->rx_mcs_160 = cpu_to_le16(mcs_map); |
| 128 |
he_mcs->tx_mcs_160 = cpu_to_le16(mcs_map); |
| 129 |
|
| 130 |
memset(he_cap->ppe_thres, 0, sizeof(he_cap->ppe_thres)); |
| 131 |
|
| 132 |
if (he_cap_elem->phy_cap_info[6] & |
| 133 |
IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT) { |
| 134 |
mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss, band); |
| 135 |
} else { |
| 136 |
he_cap_elem->phy_cap_info[9] |= |
| 137 |
u8_encode_bits(IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US, |
| 138 |
IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_MASK); |
| 139 |
} |
| 140 |
|
| 141 |
if (band == NL80211_BAND_6GHZ) { |
| 142 |
struct ieee80211_supported_band *sband = |
| 143 |
&phy->mt76->sband_5g.sband; |
| 144 |
struct ieee80211_sta_ht_cap *ht_cap = &sband->ht_cap; |
| 145 |
|
| 146 |
u16 cap = IEEE80211_HE_6GHZ_CAP_TX_ANTPAT_CONS | |
| 147 |
IEEE80211_HE_6GHZ_CAP_RX_ANTPAT_CONS; |
| 148 |
|
| 149 |
cap |= u16_encode_bits(ht_cap->ampdu_density, |
| 150 |
IEEE80211_HE_6GHZ_CAP_MIN_MPDU_START) | |
| 151 |
u16_encode_bits(IEEE80211_VHT_MAX_AMPDU_1024K, |
| 152 |
IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP) | |
| 153 |
u16_encode_bits(IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454, |
| 154 |
IEEE80211_HE_6GHZ_CAP_MAX_MPDU_LEN); |
| 155 |
|
| 156 |
data->he_6ghz_capa.capa = cpu_to_le16(cap); |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
static void |
| 161 |
mt7925_init_eht_caps(struct mt792x_phy *phy, enum nl80211_band band, |
| 162 |
struct ieee80211_sband_iftype_data *data) |
| 163 |
{ |
| 164 |
struct ieee80211_sta_eht_cap *eht_cap = &data->eht_cap; |
| 165 |
struct ieee80211_eht_cap_elem_fixed *eht_cap_elem = &eht_cap->eht_cap_elem; |
| 166 |
struct ieee80211_eht_mcs_nss_supp *eht_nss = &eht_cap->eht_mcs_nss_supp; |
| 167 |
enum nl80211_chan_width width = phy->mt76->chandef.width; |
| 168 |
int nss = hweight8(phy->mt76->antenna_mask); |
| 169 |
int sts = hweight16(phy->mt76->chainmask); |
| 170 |
u8 val; |
| 171 |
|
| 172 |
if (!phy->dev->has_eht) |
| 173 |
return; |
| 174 |
|
| 175 |
eht_cap->has_eht = true; |
| 176 |
|
| 177 |
eht_cap_elem->mac_cap_info[0] = |
| 178 |
IEEE80211_EHT_MAC_CAP0_EPCS_PRIO_ACCESS | |
| 179 |
IEEE80211_EHT_MAC_CAP0_OM_CONTROL; |
| 180 |
|
| 181 |
eht_cap_elem->phy_cap_info[0] = |
| 182 |
IEEE80211_EHT_PHY_CAP0_NDP_4_EHT_LFT_32_GI | |
| 183 |
IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMER | |
| 184 |
IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMEE; |
| 185 |
|
| 186 |
eht_cap_elem->phy_cap_info[0] |= |
| 187 |
u8_encode_bits(u8_get_bits(sts - 1, BIT(0)), |
| 188 |
IEEE80211_EHT_PHY_CAP0_BEAMFORMEE_SS_80MHZ_MASK); |
| 189 |
|
| 190 |
eht_cap_elem->phy_cap_info[1] = |
| 191 |
u8_encode_bits(u8_get_bits(sts - 1, GENMASK(2, 1)), |
| 192 |
IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_80MHZ_MASK) | |
| 193 |
u8_encode_bits(sts - 1, |
| 194 |
IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_160MHZ_MASK); |
| 195 |
|
| 196 |
eht_cap_elem->phy_cap_info[2] = |
| 197 |
u8_encode_bits(sts - 1, IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_80MHZ_MASK) | |
| 198 |
u8_encode_bits(sts - 1, IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_160MHZ_MASK); |
| 199 |
|
| 200 |
eht_cap_elem->phy_cap_info[3] = |
| 201 |
IEEE80211_EHT_PHY_CAP3_NG_16_SU_FEEDBACK | |
| 202 |
IEEE80211_EHT_PHY_CAP3_NG_16_MU_FEEDBACK | |
| 203 |
IEEE80211_EHT_PHY_CAP3_CODEBOOK_4_2_SU_FDBK | |
| 204 |
IEEE80211_EHT_PHY_CAP3_CODEBOOK_7_5_MU_FDBK | |
| 205 |
IEEE80211_EHT_PHY_CAP3_TRIG_SU_BF_FDBK | |
| 206 |
IEEE80211_EHT_PHY_CAP3_TRIG_MU_BF_PART_BW_FDBK | |
| 207 |
IEEE80211_EHT_PHY_CAP3_TRIG_CQI_FDBK; |
| 208 |
|
| 209 |
eht_cap_elem->phy_cap_info[4] = |
| 210 |
u8_encode_bits(min_t(int, sts - 1, 2), |
| 211 |
IEEE80211_EHT_PHY_CAP4_MAX_NC_MASK); |
| 212 |
|
| 213 |
eht_cap_elem->phy_cap_info[5] = |
| 214 |
IEEE80211_EHT_PHY_CAP5_NON_TRIG_CQI_FEEDBACK | |
| 215 |
u8_encode_bits(IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_16US, |
| 216 |
IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_MASK) | |
| 217 |
u8_encode_bits(u8_get_bits(0x11, GENMASK(1, 0)), |
| 218 |
IEEE80211_EHT_PHY_CAP5_MAX_NUM_SUPP_EHT_LTF_MASK); |
| 219 |
|
| 220 |
val = width == NL80211_CHAN_WIDTH_160 ? 0x7 : |
| 221 |
width == NL80211_CHAN_WIDTH_80 ? 0x3 : 0x1; |
| 222 |
eht_cap_elem->phy_cap_info[6] = |
| 223 |
u8_encode_bits(u8_get_bits(0x11, GENMASK(4, 2)), |
| 224 |
IEEE80211_EHT_PHY_CAP6_MAX_NUM_SUPP_EHT_LTF_MASK) | |
| 225 |
u8_encode_bits(val, IEEE80211_EHT_PHY_CAP6_MCS15_SUPP_MASK); |
| 226 |
|
| 227 |
eht_cap_elem->phy_cap_info[7] = |
| 228 |
IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_80MHZ | |
| 229 |
IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_160MHZ | |
| 230 |
IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_80MHZ | |
| 231 |
IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_160MHZ; |
| 232 |
|
| 233 |
val = u8_encode_bits(nss, IEEE80211_EHT_MCS_NSS_RX) | |
| 234 |
u8_encode_bits(nss, IEEE80211_EHT_MCS_NSS_TX); |
| 235 |
|
| 236 |
eht_nss->bw._80.rx_tx_mcs9_max_nss = val; |
| 237 |
eht_nss->bw._80.rx_tx_mcs11_max_nss = val; |
| 238 |
eht_nss->bw._80.rx_tx_mcs13_max_nss = val; |
| 239 |
eht_nss->bw._160.rx_tx_mcs9_max_nss = val; |
| 240 |
eht_nss->bw._160.rx_tx_mcs11_max_nss = val; |
| 241 |
eht_nss->bw._160.rx_tx_mcs13_max_nss = val; |
| 242 |
} |
| 243 |
|
| 244 |
int mt7925_init_mlo_caps(struct mt792x_phy *phy) |
| 245 |
{ |
| 246 |
struct wiphy *wiphy = phy->mt76->hw->wiphy; |
| 247 |
static const u8 ext_capa_sta[] = { |
| 248 |
[2] = WLAN_EXT_CAPA3_MULTI_BSSID_SUPPORT, |
| 249 |
[7] = WLAN_EXT_CAPA8_OPMODE_NOTIF, |
| 250 |
}; |
| 251 |
static struct wiphy_iftype_ext_capab ext_capab[] = { |
| 252 |
{ |
| 253 |
.iftype = NL80211_IFTYPE_STATION, |
| 254 |
.extended_capabilities = ext_capa_sta, |
| 255 |
.extended_capabilities_mask = ext_capa_sta, |
| 256 |
.extended_capabilities_len = sizeof(ext_capa_sta), |
| 257 |
}, |
| 258 |
}; |
| 259 |
|
| 260 |
if (!(phy->chip_cap & MT792x_CHIP_CAP_MLO_EN)) |
| 261 |
return 0; |
| 262 |
|
| 263 |
ext_capab[0].eml_capabilities = phy->eml_cap; |
| 264 |
ext_capab[0].mld_capa_and_ops = |
| 265 |
u16_encode_bits(0, IEEE80211_MLD_CAP_OP_MAX_SIMUL_LINKS); |
| 266 |
|
| 267 |
wiphy->flags |= WIPHY_FLAG_SUPPORTS_MLO; |
| 268 |
wiphy->iftype_ext_capab = ext_capab; |
| 269 |
wiphy->num_iftype_ext_capab = ARRAY_SIZE(ext_capab); |
| 270 |
|
| 271 |
return 0; |
| 272 |
} |
| 273 |
|
| 274 |
static void |
| 275 |
__mt7925_set_stream_he_eht_caps(struct mt792x_phy *phy, |
| 276 |
struct ieee80211_supported_band *sband, |
| 277 |
enum nl80211_band band) |
| 278 |
{ |
| 279 |
struct ieee80211_sband_iftype_data *data = phy->iftype[band]; |
| 280 |
int i, n = 0; |
| 281 |
|
| 282 |
for (i = 0; i < NUM_NL80211_IFTYPES; i++) { |
| 283 |
switch (i) { |
| 284 |
case NL80211_IFTYPE_STATION: |
| 285 |
case NL80211_IFTYPE_AP: |
| 286 |
break; |
| 287 |
default: |
| 288 |
continue; |
| 289 |
} |
| 290 |
|
| 291 |
data[n].types_mask = BIT(i); |
| 292 |
mt7925_init_he_caps(phy, band, &data[n], i); |
| 293 |
mt7925_init_eht_caps(phy, band, &data[n]); |
| 294 |
|
| 295 |
n++; |
| 296 |
} |
| 297 |
|
| 298 |
_ieee80211_set_sband_iftype_data(sband, data, n); |
| 299 |
} |
| 300 |
|
| 301 |
void mt7925_set_stream_he_eht_caps(struct mt792x_phy *phy) |
| 302 |
{ |
| 303 |
if (phy->mt76->cap.has_2ghz) |
| 304 |
__mt7925_set_stream_he_eht_caps(phy, &phy->mt76->sband_2g.sband, |
| 305 |
NL80211_BAND_2GHZ); |
| 306 |
|
| 307 |
if (phy->mt76->cap.has_5ghz) |
| 308 |
__mt7925_set_stream_he_eht_caps(phy, &phy->mt76->sband_5g.sband, |
| 309 |
NL80211_BAND_5GHZ); |
| 310 |
|
| 311 |
if (phy->mt76->cap.has_6ghz) |
| 312 |
__mt7925_set_stream_he_eht_caps(phy, &phy->mt76->sband_6g.sband, |
| 313 |
NL80211_BAND_6GHZ); |
| 314 |
} |
| 315 |
|
| 316 |
int __mt7925_start(struct mt792x_phy *phy) |
| 317 |
{ |
| 318 |
struct mt76_phy *mphy = phy->mt76; |
| 319 |
int err; |
| 320 |
|
| 321 |
err = mt7925_mcu_set_channel_domain(mphy); |
| 322 |
if (err) |
| 323 |
return err; |
| 324 |
|
| 325 |
err = mt7925_mcu_set_rts_thresh(phy, 0x92b); |
| 326 |
if (err) |
| 327 |
return err; |
| 328 |
|
| 329 |
mt792x_mac_reset_counters(phy); |
| 330 |
set_bit(MT76_STATE_RUNNING, &mphy->state); |
| 331 |
|
| 332 |
ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, |
| 333 |
MT792x_WATCHDOG_TIME); |
| 334 |
|
| 335 |
if (phy->chip_cap & MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN) |
| 336 |
wiphy_rfkill_start_polling(mphy->hw->wiphy); |
| 337 |
|
| 338 |
return 0; |
| 339 |
} |
| 340 |
EXPORT_SYMBOL_GPL(__mt7925_start); |
| 341 |
|
| 342 |
static int mt7925_start(struct ieee80211_hw *hw) |
| 343 |
{ |
| 344 |
struct mt792x_phy *phy = mt792x_hw_phy(hw); |
| 345 |
int err; |
| 346 |
|
| 347 |
mt792x_mutex_acquire(phy->dev); |
| 348 |
err = __mt7925_start(phy); |
| 349 |
mt792x_mutex_release(phy->dev); |
| 350 |
|
| 351 |
return err; |
| 352 |
} |
| 353 |
|
| 354 |
static int mt7925_mac_link_bss_add(struct mt792x_dev *dev, |
| 355 |
struct ieee80211_bss_conf *link_conf, |
| 356 |
struct mt792x_link_sta *mlink) |
| 357 |
{ |
| 358 |
struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(link_conf); |
| 359 |
struct ieee80211_vif *vif = link_conf->vif; |
| 360 |
struct mt792x_vif *mvif = mconf->vif; |
| 361 |
struct mt76_txq *mtxq; |
| 362 |
int idx, ret = 0; |
| 363 |
|
| 364 |
if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
| 365 |
mconf->mt76.idx = MT792x_MAX_INTERFACES; |
| 366 |
} else { |
| 367 |
mconf->mt76.idx = __ffs64(~dev->mt76.vif_mask); |
| 368 |
|
| 369 |
if (mconf->mt76.idx >= MT792x_MAX_INTERFACES) { |
| 370 |
ret = -ENOSPC; |
| 371 |
goto out; |
| 372 |
} |
| 373 |
} |
| 374 |
|
| 375 |
mconf->mt76.omac_idx = ieee80211_vif_is_mld(vif) ? |
| 376 |
0 : mconf->mt76.idx; |
| 377 |
mconf->mt76.band_idx = 0xff; |
| 378 |
mconf->mt76.wmm_idx = ieee80211_vif_is_mld(vif) ? |
| 379 |
0 : mconf->mt76.idx % MT76_CONNAC_MAX_WMM_SETS; |
| 380 |
mconf->mt76.link_idx = hweight16(mvif->valid_links); |
| 381 |
|
| 382 |
if (mvif->phy->mt76->chandef.chan->band != NL80211_BAND_2GHZ) |
| 383 |
mconf->mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL + 4; |
| 384 |
else |
| 385 |
mconf->mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL; |
| 386 |
|
| 387 |
dev->mt76.vif_mask |= BIT_ULL(mconf->mt76.idx); |
| 388 |
mvif->phy->omac_mask |= BIT_ULL(mconf->mt76.omac_idx); |
| 389 |
|
| 390 |
idx = MT792x_WTBL_RESERVED - mconf->mt76.idx; |
| 391 |
|
| 392 |
mlink->wcid.idx = idx; |
| 393 |
mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET; |
| 394 |
mt76_wcid_init(&mlink->wcid, 0); |
| 395 |
|
| 396 |
mt7925_mac_wtbl_update(dev, idx, |
| 397 |
MT_WTBL_UPDATE_ADM_COUNT_CLEAR); |
| 398 |
|
| 399 |
ewma_rssi_init(&mconf->rssi); |
| 400 |
|
| 401 |
rcu_assign_pointer(dev->mt76.wcid[idx], &mlink->wcid); |
| 402 |
|
| 403 |
ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, link_conf, &mconf->mt76, |
| 404 |
&mlink->wcid, true); |
| 405 |
if (ret) |
| 406 |
goto out; |
| 407 |
|
| 408 |
if (vif->txq) { |
| 409 |
mtxq = (struct mt76_txq *)vif->txq->drv_priv; |
| 410 |
mtxq->wcid = idx; |
| 411 |
} |
| 412 |
|
| 413 |
out: |
| 414 |
return ret; |
| 415 |
} |
| 416 |
|
| 417 |
static int |
| 418 |
mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) |
| 419 |
{ |
| 420 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 421 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 422 |
struct mt792x_phy *phy = mt792x_hw_phy(hw); |
| 423 |
int ret = 0; |
| 424 |
|
| 425 |
mt792x_mutex_acquire(dev); |
| 426 |
|
| 427 |
mvif->phy = phy; |
| 428 |
mvif->bss_conf.vif = mvif; |
| 429 |
mvif->sta.vif = mvif; |
| 430 |
mvif->deflink_id = IEEE80211_LINK_UNSPECIFIED; |
| 431 |
mvif->mlo_pm_state = MT792x_MLO_LINK_DISASSOC; |
| 432 |
|
| 433 |
ret = mt7925_mac_link_bss_add(dev, &vif->bss_conf, &mvif->sta.deflink); |
| 434 |
if (ret < 0) |
| 435 |
goto out; |
| 436 |
|
| 437 |
vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; |
| 438 |
if (phy->chip_cap & MT792x_CHIP_CAP_RSSI_NOTIFY_EVT_EN) |
| 439 |
vif->driver_flags |= IEEE80211_VIF_SUPPORTS_CQM_RSSI; |
| 440 |
|
| 441 |
out: |
| 442 |
mt792x_mutex_release(dev); |
| 443 |
|
| 444 |
return ret; |
| 445 |
} |
| 446 |
|
| 447 |
static void mt7925_roc_iter(void *priv, u8 *mac, |
| 448 |
struct ieee80211_vif *vif) |
| 449 |
{ |
| 450 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 451 |
struct mt792x_phy *phy = priv; |
| 452 |
|
| 453 |
mt7925_mcu_abort_roc(phy, &mvif->bss_conf, phy->roc_token_id); |
| 454 |
} |
| 455 |
|
| 456 |
void mt7925_roc_abort_sync(struct mt792x_dev *dev) |
| 457 |
{ |
| 458 |
struct mt792x_phy *phy = &dev->phy; |
| 459 |
|
| 460 |
if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state)) |
| 461 |
return; |
| 462 |
|
| 463 |
timer_delete_sync(&phy->roc_timer); |
| 464 |
|
| 465 |
cancel_work(&phy->roc_work); |
| 466 |
|
| 467 |
ieee80211_iterate_interfaces(mt76_hw(dev), |
| 468 |
IEEE80211_IFACE_ITER_RESUME_ALL, |
| 469 |
mt7925_roc_iter, (void *)phy); |
| 470 |
} |
| 471 |
EXPORT_SYMBOL_GPL(mt7925_roc_abort_sync); |
| 472 |
|
| 473 |
void mt7925_roc_work(struct work_struct *work) |
| 474 |
{ |
| 475 |
struct mt792x_phy *phy; |
| 476 |
|
| 477 |
phy = (struct mt792x_phy *)container_of(work, struct mt792x_phy, |
| 478 |
roc_work); |
| 479 |
|
| 480 |
if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state)) |
| 481 |
return; |
| 482 |
|
| 483 |
mt792x_mutex_acquire(phy->dev); |
| 484 |
ieee80211_iterate_active_interfaces(phy->mt76->hw, |
| 485 |
IEEE80211_IFACE_ITER_RESUME_ALL, |
| 486 |
mt7925_roc_iter, phy); |
| 487 |
mt792x_mutex_release(phy->dev); |
| 488 |
ieee80211_remain_on_channel_expired(phy->mt76->hw); |
| 489 |
} |
| 490 |
|
| 491 |
static int mt7925_abort_roc(struct mt792x_phy *phy, |
| 492 |
struct mt792x_bss_conf *mconf) |
| 493 |
{ |
| 494 |
int err = 0; |
| 495 |
|
| 496 |
timer_delete_sync(&phy->roc_timer); |
| 497 |
cancel_work_sync(&phy->roc_work); |
| 498 |
|
| 499 |
mt792x_mutex_acquire(phy->dev); |
| 500 |
if (test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state)) |
| 501 |
err = mt7925_mcu_abort_roc(phy, mconf, phy->roc_token_id); |
| 502 |
mt792x_mutex_release(phy->dev); |
| 503 |
|
| 504 |
return err; |
| 505 |
} |
| 506 |
|
| 507 |
static int mt7925_set_roc(struct mt792x_phy *phy, |
| 508 |
struct mt792x_bss_conf *mconf, |
| 509 |
struct ieee80211_channel *chan, |
| 510 |
int duration, |
| 511 |
enum mt7925_roc_req type) |
| 512 |
{ |
| 513 |
int err; |
| 514 |
|
| 515 |
if (test_and_set_bit(MT76_STATE_ROC, &phy->mt76->state)) |
| 516 |
return -EBUSY; |
| 517 |
|
| 518 |
phy->roc_grant = false; |
| 519 |
|
| 520 |
err = mt7925_mcu_set_roc(phy, mconf, chan, duration, type, |
| 521 |
++phy->roc_token_id); |
| 522 |
if (err < 0) { |
| 523 |
clear_bit(MT76_STATE_ROC, &phy->mt76->state); |
| 524 |
goto out; |
| 525 |
} |
| 526 |
|
| 527 |
if (!wait_event_timeout(phy->roc_wait, phy->roc_grant, 4 * HZ)) { |
| 528 |
mt7925_mcu_abort_roc(phy, mconf, phy->roc_token_id); |
| 529 |
clear_bit(MT76_STATE_ROC, &phy->mt76->state); |
| 530 |
err = -ETIMEDOUT; |
| 531 |
} |
| 532 |
|
| 533 |
out: |
| 534 |
return err; |
| 535 |
} |
| 536 |
|
| 537 |
static int mt7925_set_mlo_roc(struct mt792x_phy *phy, |
| 538 |
struct mt792x_bss_conf *mconf, |
| 539 |
u16 sel_links) |
| 540 |
{ |
| 541 |
int err; |
| 542 |
|
| 543 |
if (WARN_ON_ONCE(test_and_set_bit(MT76_STATE_ROC, &phy->mt76->state))) |
| 544 |
return -EBUSY; |
| 545 |
|
| 546 |
phy->roc_grant = false; |
| 547 |
|
| 548 |
err = mt7925_mcu_set_mlo_roc(phy, mconf, sel_links, 5, ++phy->roc_token_id); |
| 549 |
if (err < 0) { |
| 550 |
clear_bit(MT76_STATE_ROC, &phy->mt76->state); |
| 551 |
goto out; |
| 552 |
} |
| 553 |
|
| 554 |
if (!wait_event_timeout(phy->roc_wait, phy->roc_grant, 4 * HZ)) { |
| 555 |
mt7925_mcu_abort_roc(phy, mconf, phy->roc_token_id); |
| 556 |
clear_bit(MT76_STATE_ROC, &phy->mt76->state); |
| 557 |
err = -ETIMEDOUT; |
| 558 |
} |
| 559 |
|
| 560 |
out: |
| 561 |
return err; |
| 562 |
} |
| 563 |
|
| 564 |
static int mt7925_remain_on_channel(struct ieee80211_hw *hw, |
| 565 |
struct ieee80211_vif *vif, |
| 566 |
struct ieee80211_channel *chan, |
| 567 |
int duration, |
| 568 |
enum ieee80211_roc_type type) |
| 569 |
{ |
| 570 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 571 |
struct mt792x_phy *phy = mt792x_hw_phy(hw); |
| 572 |
int err; |
| 573 |
|
| 574 |
mt792x_mutex_acquire(phy->dev); |
| 575 |
err = mt7925_set_roc(phy, &mvif->bss_conf, |
| 576 |
chan, duration, MT7925_ROC_REQ_ROC); |
| 577 |
mt792x_mutex_release(phy->dev); |
| 578 |
|
| 579 |
return err; |
| 580 |
} |
| 581 |
|
| 582 |
static int mt7925_cancel_remain_on_channel(struct ieee80211_hw *hw, |
| 583 |
struct ieee80211_vif *vif) |
| 584 |
{ |
| 585 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 586 |
struct mt792x_phy *phy = mt792x_hw_phy(hw); |
| 587 |
|
| 588 |
return mt7925_abort_roc(phy, &mvif->bss_conf); |
| 589 |
} |
| 590 |
|
| 591 |
static int mt7925_set_link_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
| 592 |
struct ieee80211_vif *vif, struct ieee80211_sta *sta, |
| 593 |
struct ieee80211_key_conf *key, int link_id) |
| 594 |
{ |
| 595 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 596 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 597 |
struct mt792x_sta *msta = sta ? (struct mt792x_sta *)sta->drv_priv : |
| 598 |
&mvif->sta; |
| 599 |
struct ieee80211_bss_conf *link_conf; |
| 600 |
struct ieee80211_link_sta *link_sta; |
| 601 |
int idx = key->keyidx, err = 0; |
| 602 |
struct mt792x_link_sta *mlink; |
| 603 |
struct mt792x_bss_conf *mconf; |
| 604 |
struct mt76_wcid *wcid; |
| 605 |
u8 *wcid_keyidx; |
| 606 |
|
| 607 |
link_conf = mt792x_vif_to_bss_conf(vif, link_id); |
| 608 |
link_sta = sta ? mt792x_sta_to_link_sta(vif, sta, link_id) : NULL; |
| 609 |
mconf = mt792x_vif_to_link(mvif, link_id); |
| 610 |
mlink = mt792x_sta_to_link(msta, link_id); |
| 611 |
wcid = &mlink->wcid; |
| 612 |
wcid_keyidx = &wcid->hw_key_idx; |
| 613 |
|
| 614 |
/* fall back to sw encryption for unsupported ciphers */ |
| 615 |
switch (key->cipher) { |
| 616 |
case WLAN_CIPHER_SUITE_AES_CMAC: |
| 617 |
key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIE; |
| 618 |
wcid_keyidx = &wcid->hw_key_idx2; |
| 619 |
break; |
| 620 |
case WLAN_CIPHER_SUITE_WEP40: |
| 621 |
case WLAN_CIPHER_SUITE_WEP104: |
| 622 |
if (!mvif->wep_sta) |
| 623 |
return -EOPNOTSUPP; |
| 624 |
break; |
| 625 |
case WLAN_CIPHER_SUITE_TKIP: |
| 626 |
case WLAN_CIPHER_SUITE_CCMP: |
| 627 |
case WLAN_CIPHER_SUITE_CCMP_256: |
| 628 |
case WLAN_CIPHER_SUITE_GCMP: |
| 629 |
case WLAN_CIPHER_SUITE_GCMP_256: |
| 630 |
case WLAN_CIPHER_SUITE_SMS4: |
| 631 |
break; |
| 632 |
default: |
| 633 |
return -EOPNOTSUPP; |
| 634 |
} |
| 635 |
|
| 636 |
if (cmd == SET_KEY && !mconf->mt76.cipher) { |
| 637 |
struct mt792x_phy *phy = mt792x_hw_phy(hw); |
| 638 |
|
| 639 |
mconf->mt76.cipher = mt7925_mcu_get_cipher(key->cipher); |
| 640 |
mt7925_mcu_add_bss_info(phy, mconf->mt76.ctx, link_conf, |
| 641 |
link_sta, true); |
| 642 |
} |
| 643 |
|
| 644 |
if (cmd == SET_KEY) |
| 645 |
*wcid_keyidx = idx; |
| 646 |
else if (idx == *wcid_keyidx) |
| 647 |
*wcid_keyidx = -1; |
| 648 |
else |
| 649 |
goto out; |
| 650 |
|
| 651 |
mt76_wcid_key_setup(&dev->mt76, wcid, |
| 652 |
cmd == SET_KEY ? key : NULL); |
| 653 |
|
| 654 |
err = mt7925_mcu_add_key(&dev->mt76, vif, &mlink->bip, |
| 655 |
key, MCU_UNI_CMD(STA_REC_UPDATE), |
| 656 |
&mlink->wcid, cmd, msta); |
| 657 |
|
| 658 |
if (err) |
| 659 |
goto out; |
| 660 |
|
| 661 |
if (key->cipher == WLAN_CIPHER_SUITE_WEP104 || |
| 662 |
key->cipher == WLAN_CIPHER_SUITE_WEP40) |
| 663 |
err = mt7925_mcu_add_key(&dev->mt76, vif, &mvif->wep_sta->deflink.bip, |
| 664 |
key, MCU_WMWA_UNI_CMD(STA_REC_UPDATE), |
| 665 |
&mvif->wep_sta->deflink.wcid, cmd, msta); |
| 666 |
out: |
| 667 |
return err; |
| 668 |
} |
| 669 |
|
| 670 |
static int mt7925_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
| 671 |
struct ieee80211_vif *vif, struct ieee80211_sta *sta, |
| 672 |
struct ieee80211_key_conf *key) |
| 673 |
{ |
| 674 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 675 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 676 |
struct mt792x_sta *msta = sta ? (struct mt792x_sta *)sta->drv_priv : |
| 677 |
&mvif->sta; |
| 678 |
int err; |
| 679 |
|
| 680 |
/* The hardware does not support per-STA RX GTK, fallback |
| 681 |
* to software mode for these. |
| 682 |
*/ |
| 683 |
if ((vif->type == NL80211_IFTYPE_ADHOC || |
| 684 |
vif->type == NL80211_IFTYPE_MESH_POINT) && |
| 685 |
(key->cipher == WLAN_CIPHER_SUITE_TKIP || |
| 686 |
key->cipher == WLAN_CIPHER_SUITE_CCMP) && |
| 687 |
!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) |
| 688 |
return -EOPNOTSUPP; |
| 689 |
|
| 690 |
mt792x_mutex_acquire(dev); |
| 691 |
|
| 692 |
if (ieee80211_vif_is_mld(vif)) { |
| 693 |
unsigned int link_id; |
| 694 |
unsigned long add; |
| 695 |
|
| 696 |
add = key->link_id != -1 ? BIT(key->link_id) : msta->valid_links; |
| 697 |
|
| 698 |
for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 699 |
err = mt7925_set_link_key(hw, cmd, vif, sta, key, link_id); |
| 700 |
if (err < 0) |
| 701 |
break; |
| 702 |
} |
| 703 |
} else { |
| 704 |
err = mt7925_set_link_key(hw, cmd, vif, sta, key, vif->bss_conf.link_id); |
| 705 |
} |
| 706 |
|
| 707 |
mt792x_mutex_release(dev); |
| 708 |
|
| 709 |
return err; |
| 710 |
} |
| 711 |
|
| 712 |
static void |
| 713 |
mt7925_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif) |
| 714 |
{ |
| 715 |
struct mt792x_dev *dev = priv; |
| 716 |
struct ieee80211_hw *hw = mt76_hw(dev); |
| 717 |
bool pm_enable = dev->pm.enable; |
| 718 |
int err; |
| 719 |
|
| 720 |
err = mt7925_mcu_set_beacon_filter(dev, vif, pm_enable); |
| 721 |
if (err < 0) |
| 722 |
return; |
| 723 |
|
| 724 |
if (pm_enable) { |
| 725 |
vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; |
| 726 |
ieee80211_hw_set(hw, CONNECTION_MONITOR); |
| 727 |
} else { |
| 728 |
vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER; |
| 729 |
__clear_bit(IEEE80211_HW_CONNECTION_MONITOR, hw->flags); |
| 730 |
} |
| 731 |
} |
| 732 |
|
| 733 |
static void |
| 734 |
mt7925_sniffer_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif) |
| 735 |
{ |
| 736 |
struct mt792x_dev *dev = priv; |
| 737 |
struct ieee80211_hw *hw = mt76_hw(dev); |
| 738 |
struct mt76_connac_pm *pm = &dev->pm; |
| 739 |
bool monitor = !!(hw->conf.flags & IEEE80211_CONF_MONITOR); |
| 740 |
|
| 741 |
mt7925_mcu_set_sniffer(dev, vif, monitor); |
| 742 |
pm->enable = pm->enable_user && !monitor; |
| 743 |
pm->ds_enable = pm->ds_enable_user && !monitor; |
| 744 |
|
| 745 |
mt7925_mcu_set_deep_sleep(dev, pm->ds_enable); |
| 746 |
|
| 747 |
if (monitor) |
| 748 |
mt7925_mcu_set_beacon_filter(dev, vif, false); |
| 749 |
} |
| 750 |
|
| 751 |
void mt7925_set_runtime_pm(struct mt792x_dev *dev) |
| 752 |
{ |
| 753 |
struct ieee80211_hw *hw = mt76_hw(dev); |
| 754 |
struct mt76_connac_pm *pm = &dev->pm; |
| 755 |
bool monitor = !!(hw->conf.flags & IEEE80211_CONF_MONITOR); |
| 756 |
|
| 757 |
pm->enable = pm->enable_user && !monitor; |
| 758 |
ieee80211_iterate_active_interfaces(hw, |
| 759 |
IEEE80211_IFACE_ITER_RESUME_ALL, |
| 760 |
mt7925_pm_interface_iter, dev); |
| 761 |
pm->ds_enable = pm->ds_enable_user && !monitor; |
| 762 |
mt7925_mcu_set_deep_sleep(dev, pm->ds_enable); |
| 763 |
} |
| 764 |
|
| 765 |
static int mt7925_config(struct ieee80211_hw *hw, int radio_idx, u32 changed) |
| 766 |
{ |
| 767 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 768 |
int ret = 0; |
| 769 |
|
| 770 |
mt792x_mutex_acquire(dev); |
| 771 |
|
| 772 |
if (changed & IEEE80211_CONF_CHANGE_POWER) { |
| 773 |
ret = mt7925_set_tx_sar_pwr(hw, NULL); |
| 774 |
if (ret) |
| 775 |
goto out; |
| 776 |
} |
| 777 |
|
| 778 |
if (changed & IEEE80211_CONF_CHANGE_MONITOR) { |
| 779 |
ieee80211_iterate_active_interfaces(hw, |
| 780 |
IEEE80211_IFACE_ITER_RESUME_ALL, |
| 781 |
mt7925_sniffer_interface_iter, dev); |
| 782 |
} |
| 783 |
|
| 784 |
out: |
| 785 |
mt792x_mutex_release(dev); |
| 786 |
|
| 787 |
return ret; |
| 788 |
} |
| 789 |
|
| 790 |
static void mt7925_configure_filter(struct ieee80211_hw *hw, |
| 791 |
unsigned int changed_flags, |
| 792 |
unsigned int *total_flags, |
| 793 |
u64 multicast) |
| 794 |
{ |
| 795 |
#define MT7925_FILTER_FCSFAIL BIT(2) |
| 796 |
#define MT7925_FILTER_CONTROL BIT(5) |
| 797 |
#define MT7925_FILTER_OTHER_BSS BIT(6) |
| 798 |
#define MT7925_FILTER_ENABLE BIT(31) |
| 799 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 800 |
u32 flags = MT7925_FILTER_ENABLE; |
| 801 |
|
| 802 |
#define MT7925_FILTER(_fif, _type) do { \ |
| 803 |
if (*total_flags & (_fif)) \ |
| 804 |
flags |= MT7925_FILTER_##_type; \ |
| 805 |
} while (0) |
| 806 |
|
| 807 |
MT7925_FILTER(FIF_FCSFAIL, FCSFAIL); |
| 808 |
MT7925_FILTER(FIF_CONTROL, CONTROL); |
| 809 |
MT7925_FILTER(FIF_OTHER_BSS, OTHER_BSS); |
| 810 |
|
| 811 |
mt792x_mutex_acquire(dev); |
| 812 |
mt7925_mcu_set_rxfilter(dev, flags, 0, 0); |
| 813 |
mt792x_mutex_release(dev); |
| 814 |
|
| 815 |
*total_flags &= (FIF_OTHER_BSS | FIF_FCSFAIL | FIF_CONTROL); |
| 816 |
} |
| 817 |
|
| 818 |
static u8 |
| 819 |
mt7925_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 820 |
bool beacon, bool mcast) |
| 821 |
{ |
| 822 |
struct mt76_vif_link *mvif = (struct mt76_vif_link *)vif->drv_priv; |
| 823 |
struct mt76_phy *mphy = hw->priv; |
| 824 |
u16 rate; |
| 825 |
u8 i, idx, ht; |
| 826 |
|
| 827 |
rate = mt76_connac2_mac_tx_rate_val(mphy, &vif->bss_conf, beacon, mcast); |
| 828 |
ht = FIELD_GET(MT_TX_RATE_MODE, rate) > MT_PHY_TYPE_OFDM; |
| 829 |
|
| 830 |
if (beacon && ht) { |
| 831 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 832 |
|
| 833 |
/* must odd index */ |
| 834 |
idx = MT7925_BEACON_RATES_TBL + 2 * (mvif->idx % 20); |
| 835 |
mt7925_mac_set_fixed_rate_table(dev, idx, rate); |
| 836 |
return idx; |
| 837 |
} |
| 838 |
|
| 839 |
idx = FIELD_GET(MT_TX_RATE_IDX, rate); |
| 840 |
for (i = 0; i < ARRAY_SIZE(mt76_rates); i++) |
| 841 |
if ((mt76_rates[i].hw_value & GENMASK(7, 0)) == idx) |
| 842 |
return MT792x_BASIC_RATES_TBL + i; |
| 843 |
|
| 844 |
return mvif->basic_rates_idx; |
| 845 |
} |
| 846 |
|
| 847 |
static int mt7925_mac_link_sta_add(struct mt76_dev *mdev, |
| 848 |
struct ieee80211_vif *vif, |
| 849 |
struct ieee80211_link_sta *link_sta) |
| 850 |
{ |
| 851 |
struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); |
| 852 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 853 |
struct ieee80211_bss_conf *link_conf; |
| 854 |
struct mt792x_bss_conf *mconf; |
| 855 |
u8 link_id = link_sta->link_id; |
| 856 |
struct mt792x_link_sta *mlink; |
| 857 |
struct mt792x_sta *msta; |
| 858 |
struct mt76_wcid *wcid; |
| 859 |
int ret, idx; |
| 860 |
|
| 861 |
msta = (struct mt792x_sta *)link_sta->sta->drv_priv; |
| 862 |
mlink = mt792x_sta_to_link(msta, link_id); |
| 863 |
|
| 864 |
idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT792x_WTBL_STA - 1); |
| 865 |
if (idx < 0) |
| 866 |
return -ENOSPC; |
| 867 |
|
| 868 |
mconf = mt792x_vif_to_link(mvif, link_id); |
| 869 |
mt76_wcid_init(&mlink->wcid, 0); |
| 870 |
mlink->wcid.sta = 1; |
| 871 |
mlink->wcid.idx = idx; |
| 872 |
mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET; |
| 873 |
mlink->last_txs = jiffies; |
| 874 |
mlink->wcid.link_id = link_sta->link_id; |
| 875 |
mlink->wcid.link_valid = !!link_sta->sta->valid_links; |
| 876 |
mlink->sta = msta; |
| 877 |
|
| 878 |
wcid = &mlink->wcid; |
| 879 |
ewma_signal_init(&wcid->rssi); |
| 880 |
rcu_assign_pointer(dev->mt76.wcid[wcid->idx], wcid); |
| 881 |
mt76_wcid_init(wcid, 0); |
| 882 |
ewma_avg_signal_init(&mlink->avg_ack_signal); |
| 883 |
memset(mlink->airtime_ac, 0, |
| 884 |
sizeof(msta->deflink.airtime_ac)); |
| 885 |
|
| 886 |
ret = mt76_connac_pm_wake(&dev->mphy, &dev->pm); |
| 887 |
if (ret) |
| 888 |
return ret; |
| 889 |
|
| 890 |
mt7925_mac_wtbl_update(dev, idx, |
| 891 |
MT_WTBL_UPDATE_ADM_COUNT_CLEAR); |
| 892 |
|
| 893 |
link_conf = mt792x_vif_to_bss_conf(vif, link_id); |
| 894 |
|
| 895 |
/* should update bss info before STA add */ |
| 896 |
if (vif->type == NL80211_IFTYPE_STATION && !link_sta->sta->tdls) { |
| 897 |
if (ieee80211_vif_is_mld(vif)) |
| 898 |
mt7925_mcu_add_bss_info(&dev->phy, mconf->mt76.ctx, |
| 899 |
link_conf, link_sta, link_sta != mlink->pri_link); |
| 900 |
else |
| 901 |
mt7925_mcu_add_bss_info(&dev->phy, mconf->mt76.ctx, |
| 902 |
link_conf, link_sta, false); |
| 903 |
} |
| 904 |
|
| 905 |
if (ieee80211_vif_is_mld(vif) && |
| 906 |
link_sta == mlink->pri_link) { |
| 907 |
ret = mt7925_mcu_sta_update(dev, link_sta, vif, true, |
| 908 |
MT76_STA_INFO_STATE_NONE); |
| 909 |
if (ret) |
| 910 |
return ret; |
| 911 |
} else if (ieee80211_vif_is_mld(vif) && |
| 912 |
link_sta != mlink->pri_link) { |
| 913 |
ret = mt7925_mcu_sta_update(dev, mlink->pri_link, vif, |
| 914 |
true, MT76_STA_INFO_STATE_ASSOC); |
| 915 |
if (ret) |
| 916 |
return ret; |
| 917 |
|
| 918 |
ret = mt7925_mcu_sta_update(dev, link_sta, vif, true, |
| 919 |
MT76_STA_INFO_STATE_ASSOC); |
| 920 |
if (ret) |
| 921 |
return ret; |
| 922 |
} else { |
| 923 |
ret = mt7925_mcu_sta_update(dev, link_sta, vif, true, |
| 924 |
MT76_STA_INFO_STATE_NONE); |
| 925 |
if (ret) |
| 926 |
return ret; |
| 927 |
} |
| 928 |
|
| 929 |
mt76_connac_power_save_sched(&dev->mphy, &dev->pm); |
| 930 |
|
| 931 |
return 0; |
| 932 |
} |
| 933 |
|
| 934 |
static int |
| 935 |
mt7925_mac_sta_add_links(struct mt792x_dev *dev, struct ieee80211_vif *vif, |
| 936 |
struct ieee80211_sta *sta, unsigned long new_links) |
| 937 |
{ |
| 938 |
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; |
| 939 |
unsigned int link_id; |
| 940 |
int err = 0; |
| 941 |
|
| 942 |
for_each_set_bit(link_id, &new_links, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 943 |
struct ieee80211_link_sta *link_sta; |
| 944 |
struct mt792x_link_sta *mlink; |
| 945 |
|
| 946 |
if (msta->deflink_id == IEEE80211_LINK_UNSPECIFIED) { |
| 947 |
mlink = &msta->deflink; |
| 948 |
msta->deflink_id = link_id; |
| 949 |
} else { |
| 950 |
mlink = devm_kzalloc(dev->mt76.dev, sizeof(*mlink), GFP_KERNEL); |
| 951 |
if (!mlink) { |
| 952 |
err = -ENOMEM; |
| 953 |
break; |
| 954 |
} |
| 955 |
} |
| 956 |
|
| 957 |
msta->valid_links |= BIT(link_id); |
| 958 |
rcu_assign_pointer(msta->link[link_id], mlink); |
| 959 |
mlink->sta = msta; |
| 960 |
mlink->pri_link = &sta->deflink; |
| 961 |
mlink->wcid.def_wcid = &msta->deflink.wcid; |
| 962 |
|
| 963 |
link_sta = mt792x_sta_to_link_sta(vif, sta, link_id); |
| 964 |
mt7925_mac_link_sta_add(&dev->mt76, vif, link_sta); |
| 965 |
} |
| 966 |
|
| 967 |
return err; |
| 968 |
} |
| 969 |
|
| 970 |
int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
| 971 |
struct ieee80211_sta *sta) |
| 972 |
{ |
| 973 |
struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); |
| 974 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 975 |
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; |
| 976 |
int err; |
| 977 |
|
| 978 |
msta->vif = mvif; |
| 979 |
|
| 980 |
if (vif->type == NL80211_IFTYPE_STATION) |
| 981 |
mvif->wep_sta = msta; |
| 982 |
|
| 983 |
if (ieee80211_vif_is_mld(vif)) { |
| 984 |
msta->deflink_id = IEEE80211_LINK_UNSPECIFIED; |
| 985 |
|
| 986 |
err = mt7925_mac_sta_add_links(dev, vif, sta, sta->valid_links); |
| 987 |
} else { |
| 988 |
err = mt7925_mac_link_sta_add(mdev, vif, &sta->deflink); |
| 989 |
} |
| 990 |
|
| 991 |
return err; |
| 992 |
} |
| 993 |
EXPORT_SYMBOL_GPL(mt7925_mac_sta_add); |
| 994 |
|
| 995 |
static void |
| 996 |
mt7925_mac_set_links(struct mt76_dev *mdev, struct ieee80211_vif *vif) |
| 997 |
{ |
| 998 |
struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); |
| 999 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 1000 |
struct ieee80211_bss_conf *link_conf = |
| 1001 |
mt792x_vif_to_bss_conf(vif, mvif->deflink_id); |
| 1002 |
struct cfg80211_chan_def *chandef = &link_conf->chanreq.oper; |
| 1003 |
enum nl80211_band band = chandef->chan->band, secondary_band; |
| 1004 |
|
| 1005 |
u16 sel_links = mt76_select_links(vif, 2); |
| 1006 |
u8 secondary_link_id = __ffs(~BIT(mvif->deflink_id) & sel_links); |
| 1007 |
|
| 1008 |
if (!ieee80211_vif_is_mld(vif) || hweight16(sel_links) < 2) |
| 1009 |
return; |
| 1010 |
|
| 1011 |
link_conf = mt792x_vif_to_bss_conf(vif, secondary_link_id); |
| 1012 |
secondary_band = link_conf->chanreq.oper.chan->band; |
| 1013 |
|
| 1014 |
if (band == NL80211_BAND_2GHZ || |
| 1015 |
(band == NL80211_BAND_5GHZ && secondary_band == NL80211_BAND_6GHZ)) { |
| 1016 |
mt7925_abort_roc(mvif->phy, &mvif->bss_conf); |
| 1017 |
|
| 1018 |
mt792x_mutex_acquire(dev); |
| 1019 |
|
| 1020 |
mt7925_set_mlo_roc(mvif->phy, &mvif->bss_conf, sel_links); |
| 1021 |
|
| 1022 |
mt792x_mutex_release(dev); |
| 1023 |
} |
| 1024 |
|
| 1025 |
ieee80211_set_active_links_async(vif, sel_links); |
| 1026 |
} |
| 1027 |
|
| 1028 |
static void mt7925_mac_link_sta_assoc(struct mt76_dev *mdev, |
| 1029 |
struct ieee80211_vif *vif, |
| 1030 |
struct ieee80211_link_sta *link_sta) |
| 1031 |
{ |
| 1032 |
struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); |
| 1033 |
struct ieee80211_bss_conf *link_conf; |
| 1034 |
struct mt792x_link_sta *mlink; |
| 1035 |
struct mt792x_sta *msta; |
| 1036 |
|
| 1037 |
msta = (struct mt792x_sta *)link_sta->sta->drv_priv; |
| 1038 |
mlink = mt792x_sta_to_link(msta, link_sta->link_id); |
| 1039 |
|
| 1040 |
mt792x_mutex_acquire(dev); |
| 1041 |
|
| 1042 |
if (ieee80211_vif_is_mld(vif)) { |
| 1043 |
link_conf = mt792x_vif_to_bss_conf(vif, msta->deflink_id); |
| 1044 |
} else { |
| 1045 |
link_conf = mt792x_vif_to_bss_conf(vif, vif->bss_conf.link_id); |
| 1046 |
} |
| 1047 |
|
| 1048 |
if (vif->type == NL80211_IFTYPE_STATION && !link_sta->sta->tdls) { |
| 1049 |
struct mt792x_bss_conf *mconf; |
| 1050 |
|
| 1051 |
mconf = mt792x_link_conf_to_mconf(link_conf); |
| 1052 |
mt7925_mcu_add_bss_info(&dev->phy, mconf->mt76.ctx, |
| 1053 |
link_conf, link_sta, true); |
| 1054 |
} |
| 1055 |
|
| 1056 |
ewma_avg_signal_init(&mlink->avg_ack_signal); |
| 1057 |
|
| 1058 |
mt7925_mac_wtbl_update(dev, mlink->wcid.idx, |
| 1059 |
MT_WTBL_UPDATE_ADM_COUNT_CLEAR); |
| 1060 |
memset(mlink->airtime_ac, 0, sizeof(mlink->airtime_ac)); |
| 1061 |
|
| 1062 |
mt7925_mcu_sta_update(dev, link_sta, vif, true, MT76_STA_INFO_STATE_ASSOC); |
| 1063 |
|
| 1064 |
mt792x_mutex_release(dev); |
| 1065 |
} |
| 1066 |
|
| 1067 |
int mt7925_mac_sta_event(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
| 1068 |
struct ieee80211_sta *sta, enum mt76_sta_event ev) |
| 1069 |
{ |
| 1070 |
struct ieee80211_link_sta *link_sta = &sta->deflink; |
| 1071 |
|
| 1072 |
if (ev != MT76_STA_EVENT_ASSOC) |
| 1073 |
return 0; |
| 1074 |
|
| 1075 |
if (ieee80211_vif_is_mld(vif)) { |
| 1076 |
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; |
| 1077 |
|
| 1078 |
link_sta = mt792x_sta_to_link_sta(vif, sta, msta->deflink_id); |
| 1079 |
mt7925_mac_set_links(mdev, vif); |
| 1080 |
} |
| 1081 |
|
| 1082 |
mt7925_mac_link_sta_assoc(mdev, vif, link_sta); |
| 1083 |
|
| 1084 |
return 0; |
| 1085 |
} |
| 1086 |
EXPORT_SYMBOL_GPL(mt7925_mac_sta_event); |
| 1087 |
|
| 1088 |
static void mt7925_mac_link_sta_remove(struct mt76_dev *mdev, |
| 1089 |
struct ieee80211_vif *vif, |
| 1090 |
struct ieee80211_link_sta *link_sta) |
| 1091 |
{ |
| 1092 |
struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); |
| 1093 |
struct ieee80211_bss_conf *link_conf; |
| 1094 |
u8 link_id = link_sta->link_id; |
| 1095 |
struct mt792x_link_sta *mlink; |
| 1096 |
struct mt792x_sta *msta; |
| 1097 |
|
| 1098 |
msta = (struct mt792x_sta *)link_sta->sta->drv_priv; |
| 1099 |
mlink = mt792x_sta_to_link(msta, link_id); |
| 1100 |
|
| 1101 |
mt7925_roc_abort_sync(dev); |
| 1102 |
|
| 1103 |
mt76_connac_free_pending_tx_skbs(&dev->pm, &mlink->wcid); |
| 1104 |
mt76_connac_pm_wake(&dev->mphy, &dev->pm); |
| 1105 |
|
| 1106 |
mt7925_mcu_sta_update(dev, link_sta, vif, false, |
| 1107 |
MT76_STA_INFO_STATE_NONE); |
| 1108 |
mt7925_mac_wtbl_update(dev, mlink->wcid.idx, |
| 1109 |
MT_WTBL_UPDATE_ADM_COUNT_CLEAR); |
| 1110 |
|
| 1111 |
link_conf = mt792x_vif_to_bss_conf(vif, link_id); |
| 1112 |
|
| 1113 |
if (vif->type == NL80211_IFTYPE_STATION && !link_sta->sta->tdls) { |
| 1114 |
struct mt792x_bss_conf *mconf; |
| 1115 |
|
| 1116 |
mconf = mt792x_link_conf_to_mconf(link_conf); |
| 1117 |
|
| 1118 |
if (ieee80211_vif_is_mld(vif)) |
| 1119 |
mt792x_mac_link_bss_remove(dev, mconf, mlink); |
| 1120 |
else |
| 1121 |
mt7925_mcu_add_bss_info(&dev->phy, mconf->mt76.ctx, link_conf, |
| 1122 |
link_sta, false); |
| 1123 |
} |
| 1124 |
|
| 1125 |
spin_lock_bh(&mdev->sta_poll_lock); |
| 1126 |
if (!list_empty(&mlink->wcid.poll_list)) |
| 1127 |
list_del_init(&mlink->wcid.poll_list); |
| 1128 |
spin_unlock_bh(&mdev->sta_poll_lock); |
| 1129 |
|
| 1130 |
mt76_connac_power_save_sched(&dev->mphy, &dev->pm); |
| 1131 |
} |
| 1132 |
|
| 1133 |
static int |
| 1134 |
mt7925_mac_sta_remove_links(struct mt792x_dev *dev, struct ieee80211_vif *vif, |
| 1135 |
struct ieee80211_sta *sta, unsigned long old_links) |
| 1136 |
{ |
| 1137 |
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; |
| 1138 |
struct mt76_dev *mdev = &dev->mt76; |
| 1139 |
struct mt76_wcid *wcid; |
| 1140 |
unsigned int link_id; |
| 1141 |
|
| 1142 |
/* clean up bss before starec */ |
| 1143 |
for_each_set_bit(link_id, &old_links, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 1144 |
struct ieee80211_link_sta *link_sta; |
| 1145 |
struct ieee80211_bss_conf *link_conf; |
| 1146 |
struct mt792x_bss_conf *mconf; |
| 1147 |
struct mt792x_link_sta *mlink; |
| 1148 |
|
| 1149 |
if (vif->type == NL80211_IFTYPE_AP) |
| 1150 |
break; |
| 1151 |
|
| 1152 |
link_sta = mt792x_sta_to_link_sta(vif, sta, link_id); |
| 1153 |
if (!link_sta) |
| 1154 |
continue; |
| 1155 |
|
| 1156 |
mlink = mt792x_sta_to_link(msta, link_id); |
| 1157 |
if (!mlink) |
| 1158 |
continue; |
| 1159 |
|
| 1160 |
link_conf = mt792x_vif_to_bss_conf(vif, link_id); |
| 1161 |
if (!link_conf) |
| 1162 |
continue; |
| 1163 |
|
| 1164 |
mconf = mt792x_link_conf_to_mconf(link_conf); |
| 1165 |
|
| 1166 |
mt7925_mcu_add_bss_info(&dev->phy, mconf->mt76.ctx, link_conf, |
| 1167 |
link_sta, false); |
| 1168 |
} |
| 1169 |
|
| 1170 |
for_each_set_bit(link_id, &old_links, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 1171 |
struct ieee80211_link_sta *link_sta; |
| 1172 |
struct mt792x_link_sta *mlink; |
| 1173 |
|
| 1174 |
link_sta = mt792x_sta_to_link_sta(vif, sta, link_id); |
| 1175 |
if (!link_sta) |
| 1176 |
continue; |
| 1177 |
|
| 1178 |
mlink = mt792x_sta_to_link(msta, link_id); |
| 1179 |
if (!mlink) |
| 1180 |
continue; |
| 1181 |
|
| 1182 |
mt7925_mac_link_sta_remove(&dev->mt76, vif, link_sta); |
| 1183 |
|
| 1184 |
wcid = &mlink->wcid; |
| 1185 |
rcu_assign_pointer(msta->link[link_id], NULL); |
| 1186 |
msta->valid_links &= ~BIT(link_id); |
| 1187 |
mlink->sta = NULL; |
| 1188 |
mlink->pri_link = NULL; |
| 1189 |
|
| 1190 |
if (link_sta != mlink->pri_link) { |
| 1191 |
mt76_wcid_cleanup(mdev, wcid); |
| 1192 |
mt76_wcid_mask_clear(mdev->wcid_mask, wcid->idx); |
| 1193 |
} |
| 1194 |
|
| 1195 |
if (msta->deflink_id == link_id) |
| 1196 |
msta->deflink_id = IEEE80211_LINK_UNSPECIFIED; |
| 1197 |
} |
| 1198 |
|
| 1199 |
return 0; |
| 1200 |
} |
| 1201 |
|
| 1202 |
void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
| 1203 |
struct ieee80211_sta *sta) |
| 1204 |
{ |
| 1205 |
struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); |
| 1206 |
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; |
| 1207 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 1208 |
unsigned long rem; |
| 1209 |
|
| 1210 |
rem = ieee80211_vif_is_mld(vif) ? msta->valid_links : BIT(0); |
| 1211 |
|
| 1212 |
mt7925_mac_sta_remove_links(dev, vif, sta, rem); |
| 1213 |
|
| 1214 |
if (ieee80211_vif_is_mld(vif)) |
| 1215 |
mt7925_mcu_del_dev(mdev, vif); |
| 1216 |
|
| 1217 |
if (vif->type == NL80211_IFTYPE_STATION) { |
| 1218 |
mvif->wep_sta = NULL; |
| 1219 |
ewma_rssi_init(&mvif->bss_conf.rssi); |
| 1220 |
} |
| 1221 |
|
| 1222 |
mvif->mlo_pm_state = MT792x_MLO_LINK_DISASSOC; |
| 1223 |
} |
| 1224 |
EXPORT_SYMBOL_GPL(mt7925_mac_sta_remove); |
| 1225 |
|
| 1226 |
static int mt7925_set_rts_threshold(struct ieee80211_hw *hw, int radio_idx, |
| 1227 |
u32 val) |
| 1228 |
{ |
| 1229 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1230 |
|
| 1231 |
mt792x_mutex_acquire(dev); |
| 1232 |
mt7925_mcu_set_rts_thresh(&dev->phy, val); |
| 1233 |
mt792x_mutex_release(dev); |
| 1234 |
|
| 1235 |
return 0; |
| 1236 |
} |
| 1237 |
|
| 1238 |
static int |
| 1239 |
mt7925_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 1240 |
struct ieee80211_ampdu_params *params) |
| 1241 |
{ |
| 1242 |
enum ieee80211_ampdu_mlme_action action = params->action; |
| 1243 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1244 |
struct ieee80211_sta *sta = params->sta; |
| 1245 |
struct ieee80211_txq *txq = sta->txq[params->tid]; |
| 1246 |
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; |
| 1247 |
u16 tid = params->tid; |
| 1248 |
u16 ssn = params->ssn; |
| 1249 |
struct mt76_txq *mtxq; |
| 1250 |
int ret = 0; |
| 1251 |
|
| 1252 |
if (!txq) |
| 1253 |
return -EINVAL; |
| 1254 |
|
| 1255 |
mtxq = (struct mt76_txq *)txq->drv_priv; |
| 1256 |
|
| 1257 |
mt792x_mutex_acquire(dev); |
| 1258 |
switch (action) { |
| 1259 |
case IEEE80211_AMPDU_RX_START: |
| 1260 |
mt76_rx_aggr_start(&dev->mt76, &msta->deflink.wcid, tid, ssn, |
| 1261 |
params->buf_size); |
| 1262 |
mt7925_mcu_uni_rx_ba(dev, params, true); |
| 1263 |
break; |
| 1264 |
case IEEE80211_AMPDU_RX_STOP: |
| 1265 |
mt76_rx_aggr_stop(&dev->mt76, &msta->deflink.wcid, tid); |
| 1266 |
mt7925_mcu_uni_rx_ba(dev, params, false); |
| 1267 |
break; |
| 1268 |
case IEEE80211_AMPDU_TX_OPERATIONAL: |
| 1269 |
mtxq->aggr = true; |
| 1270 |
mtxq->send_bar = false; |
| 1271 |
mt7925_mcu_uni_tx_ba(dev, params, true); |
| 1272 |
break; |
| 1273 |
case IEEE80211_AMPDU_TX_STOP_FLUSH: |
| 1274 |
case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: |
| 1275 |
mtxq->aggr = false; |
| 1276 |
clear_bit(tid, &msta->deflink.wcid.ampdu_state); |
| 1277 |
mt7925_mcu_uni_tx_ba(dev, params, false); |
| 1278 |
break; |
| 1279 |
case IEEE80211_AMPDU_TX_START: |
| 1280 |
set_bit(tid, &msta->deflink.wcid.ampdu_state); |
| 1281 |
ret = IEEE80211_AMPDU_TX_START_IMMEDIATE; |
| 1282 |
break; |
| 1283 |
case IEEE80211_AMPDU_TX_STOP_CONT: |
| 1284 |
mtxq->aggr = false; |
| 1285 |
clear_bit(tid, &msta->deflink.wcid.ampdu_state); |
| 1286 |
mt7925_mcu_uni_tx_ba(dev, params, false); |
| 1287 |
ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); |
| 1288 |
break; |
| 1289 |
} |
| 1290 |
mt792x_mutex_release(dev); |
| 1291 |
|
| 1292 |
return ret; |
| 1293 |
} |
| 1294 |
|
| 1295 |
static void |
| 1296 |
mt7925_mlo_pm_iter(void *priv, u8 *mac, struct ieee80211_vif *vif) |
| 1297 |
{ |
| 1298 |
struct mt792x_dev *dev = priv; |
| 1299 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 1300 |
unsigned long valid = ieee80211_vif_is_mld(vif) ? |
| 1301 |
mvif->valid_links : BIT(0); |
| 1302 |
struct ieee80211_bss_conf *bss_conf; |
| 1303 |
int i; |
| 1304 |
|
| 1305 |
if (mvif->mlo_pm_state != MT792x_MLO_CHANGED_PS) |
| 1306 |
return; |
| 1307 |
|
| 1308 |
mt792x_mutex_acquire(dev); |
| 1309 |
for_each_set_bit(i, &valid, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 1310 |
bss_conf = mt792x_vif_to_bss_conf(vif, i); |
| 1311 |
mt7925_mcu_uni_bss_ps(dev, bss_conf); |
| 1312 |
} |
| 1313 |
mt792x_mutex_release(dev); |
| 1314 |
} |
| 1315 |
|
| 1316 |
void mt7925_mlo_pm_work(struct work_struct *work) |
| 1317 |
{ |
| 1318 |
struct mt792x_dev *dev = container_of(work, struct mt792x_dev, |
| 1319 |
mlo_pm_work.work); |
| 1320 |
struct ieee80211_hw *hw = mt76_hw(dev); |
| 1321 |
|
| 1322 |
ieee80211_iterate_active_interfaces(hw, |
| 1323 |
IEEE80211_IFACE_ITER_RESUME_ALL, |
| 1324 |
mt7925_mlo_pm_iter, dev); |
| 1325 |
} |
| 1326 |
|
| 1327 |
void mt7925_scan_work(struct work_struct *work) |
| 1328 |
{ |
| 1329 |
struct mt792x_phy *phy; |
| 1330 |
|
| 1331 |
phy = (struct mt792x_phy *)container_of(work, struct mt792x_phy, |
| 1332 |
scan_work.work); |
| 1333 |
|
| 1334 |
while (true) { |
| 1335 |
struct sk_buff *skb; |
| 1336 |
struct tlv *tlv; |
| 1337 |
int tlv_len; |
| 1338 |
|
| 1339 |
spin_lock_bh(&phy->dev->mt76.lock); |
| 1340 |
skb = __skb_dequeue(&phy->scan_event_list); |
| 1341 |
spin_unlock_bh(&phy->dev->mt76.lock); |
| 1342 |
|
| 1343 |
if (!skb) |
| 1344 |
break; |
| 1345 |
|
| 1346 |
skb_pull(skb, sizeof(struct mt7925_mcu_rxd) + 4); |
| 1347 |
tlv = (struct tlv *)skb->data; |
| 1348 |
tlv_len = skb->len; |
| 1349 |
|
| 1350 |
while (tlv_len > 0 && le16_to_cpu(tlv->len) <= tlv_len) { |
| 1351 |
struct mt7925_mcu_scan_chinfo_event *evt; |
| 1352 |
|
| 1353 |
switch (le16_to_cpu(tlv->tag)) { |
| 1354 |
case UNI_EVENT_SCAN_DONE_BASIC: |
| 1355 |
if (test_and_clear_bit(MT76_HW_SCANNING, &phy->mt76->state)) { |
| 1356 |
struct cfg80211_scan_info info = { |
| 1357 |
.aborted = false, |
| 1358 |
}; |
| 1359 |
ieee80211_scan_completed(phy->mt76->hw, &info); |
| 1360 |
} |
| 1361 |
break; |
| 1362 |
case UNI_EVENT_SCAN_DONE_CHNLINFO: |
| 1363 |
evt = (struct mt7925_mcu_scan_chinfo_event *)tlv->data; |
| 1364 |
|
| 1365 |
mt7925_regd_change(phy, evt->alpha2); |
| 1366 |
|
| 1367 |
break; |
| 1368 |
case UNI_EVENT_SCAN_DONE_NLO: |
| 1369 |
ieee80211_sched_scan_results(phy->mt76->hw); |
| 1370 |
break; |
| 1371 |
default: |
| 1372 |
break; |
| 1373 |
} |
| 1374 |
|
| 1375 |
tlv_len -= le16_to_cpu(tlv->len); |
| 1376 |
tlv = (struct tlv *)((char *)(tlv) + le16_to_cpu(tlv->len)); |
| 1377 |
} |
| 1378 |
|
| 1379 |
dev_kfree_skb(skb); |
| 1380 |
} |
| 1381 |
} |
| 1382 |
|
| 1383 |
static int |
| 1384 |
mt7925_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 1385 |
struct ieee80211_scan_request *req) |
| 1386 |
{ |
| 1387 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1388 |
struct mt76_phy *mphy = hw->priv; |
| 1389 |
int err; |
| 1390 |
|
| 1391 |
mt792x_mutex_acquire(dev); |
| 1392 |
err = mt7925_mcu_hw_scan(mphy, vif, req); |
| 1393 |
mt792x_mutex_release(dev); |
| 1394 |
|
| 1395 |
return err; |
| 1396 |
} |
| 1397 |
|
| 1398 |
static void |
| 1399 |
mt7925_cancel_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif) |
| 1400 |
{ |
| 1401 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1402 |
struct mt76_phy *mphy = hw->priv; |
| 1403 |
|
| 1404 |
mt792x_mutex_acquire(dev); |
| 1405 |
mt7925_mcu_cancel_hw_scan(mphy, vif); |
| 1406 |
mt792x_mutex_release(dev); |
| 1407 |
} |
| 1408 |
|
| 1409 |
static int |
| 1410 |
mt7925_start_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 1411 |
struct cfg80211_sched_scan_request *req, |
| 1412 |
struct ieee80211_scan_ies *ies) |
| 1413 |
{ |
| 1414 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1415 |
struct mt76_phy *mphy = hw->priv; |
| 1416 |
int err; |
| 1417 |
|
| 1418 |
mt792x_mutex_acquire(dev); |
| 1419 |
|
| 1420 |
err = mt7925_mcu_sched_scan_req(mphy, vif, req, ies); |
| 1421 |
if (err < 0) |
| 1422 |
goto out; |
| 1423 |
|
| 1424 |
err = mt7925_mcu_sched_scan_enable(mphy, vif, true); |
| 1425 |
out: |
| 1426 |
mt792x_mutex_release(dev); |
| 1427 |
|
| 1428 |
return err; |
| 1429 |
} |
| 1430 |
|
| 1431 |
static int |
| 1432 |
mt7925_stop_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif) |
| 1433 |
{ |
| 1434 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1435 |
struct mt76_phy *mphy = hw->priv; |
| 1436 |
int err; |
| 1437 |
|
| 1438 |
mt792x_mutex_acquire(dev); |
| 1439 |
err = mt7925_mcu_sched_scan_enable(mphy, vif, false); |
| 1440 |
mt792x_mutex_release(dev); |
| 1441 |
|
| 1442 |
return err; |
| 1443 |
} |
| 1444 |
|
| 1445 |
static int |
| 1446 |
mt7925_set_antenna(struct ieee80211_hw *hw, int radio_idx, |
| 1447 |
u32 tx_ant, u32 rx_ant) |
| 1448 |
{ |
| 1449 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1450 |
struct mt792x_phy *phy = mt792x_hw_phy(hw); |
| 1451 |
int max_nss = hweight8(hw->wiphy->available_antennas_tx); |
| 1452 |
|
| 1453 |
if (!tx_ant || tx_ant != rx_ant || ffs(tx_ant) > max_nss) |
| 1454 |
return -EINVAL; |
| 1455 |
|
| 1456 |
if ((BIT(hweight8(tx_ant)) - 1) != tx_ant) |
| 1457 |
tx_ant = BIT(ffs(tx_ant) - 1) - 1; |
| 1458 |
|
| 1459 |
mt792x_mutex_acquire(dev); |
| 1460 |
|
| 1461 |
phy->mt76->antenna_mask = tx_ant; |
| 1462 |
phy->mt76->chainmask = tx_ant; |
| 1463 |
|
| 1464 |
mt76_set_stream_caps(phy->mt76, true); |
| 1465 |
mt7925_set_stream_he_eht_caps(phy); |
| 1466 |
|
| 1467 |
/* TODO: update bmc_wtbl spe_idx when antenna changes */ |
| 1468 |
mt792x_mutex_release(dev); |
| 1469 |
|
| 1470 |
return 0; |
| 1471 |
} |
| 1472 |
|
| 1473 |
#ifdef CONFIG_PM |
| 1474 |
static int mt7925_suspend(struct ieee80211_hw *hw, |
| 1475 |
struct cfg80211_wowlan *wowlan) |
| 1476 |
{ |
| 1477 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1478 |
struct mt792x_phy *phy = mt792x_hw_phy(hw); |
| 1479 |
|
| 1480 |
cancel_delayed_work_sync(&phy->scan_work); |
| 1481 |
cancel_delayed_work_sync(&phy->mt76->mac_work); |
| 1482 |
|
| 1483 |
cancel_delayed_work_sync(&dev->pm.ps_work); |
| 1484 |
mt76_connac_free_pending_tx_skbs(&dev->pm, NULL); |
| 1485 |
|
| 1486 |
mt792x_mutex_acquire(dev); |
| 1487 |
|
| 1488 |
clear_bit(MT76_STATE_RUNNING, &phy->mt76->state); |
| 1489 |
ieee80211_iterate_active_interfaces(hw, |
| 1490 |
IEEE80211_IFACE_ITER_RESUME_ALL, |
| 1491 |
mt7925_mcu_set_suspend_iter, |
| 1492 |
&dev->mphy); |
| 1493 |
|
| 1494 |
mt792x_mutex_release(dev); |
| 1495 |
|
| 1496 |
return 0; |
| 1497 |
} |
| 1498 |
|
| 1499 |
static int mt7925_resume(struct ieee80211_hw *hw) |
| 1500 |
{ |
| 1501 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1502 |
struct mt792x_phy *phy = mt792x_hw_phy(hw); |
| 1503 |
|
| 1504 |
mt792x_mutex_acquire(dev); |
| 1505 |
|
| 1506 |
set_bit(MT76_STATE_RUNNING, &phy->mt76->state); |
| 1507 |
ieee80211_iterate_active_interfaces(hw, |
| 1508 |
IEEE80211_IFACE_ITER_RESUME_ALL, |
| 1509 |
mt7925_mcu_set_suspend_iter, |
| 1510 |
&dev->mphy); |
| 1511 |
|
| 1512 |
ieee80211_queue_delayed_work(hw, &phy->mt76->mac_work, |
| 1513 |
MT792x_WATCHDOG_TIME); |
| 1514 |
|
| 1515 |
mt792x_mutex_release(dev); |
| 1516 |
|
| 1517 |
return 0; |
| 1518 |
} |
| 1519 |
|
| 1520 |
static void mt7925_set_rekey_data(struct ieee80211_hw *hw, |
| 1521 |
struct ieee80211_vif *vif, |
| 1522 |
struct cfg80211_gtk_rekey_data *data) |
| 1523 |
{ |
| 1524 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1525 |
|
| 1526 |
mt792x_mutex_acquire(dev); |
| 1527 |
mt76_connac_mcu_update_gtk_rekey(hw, vif, data); |
| 1528 |
mt792x_mutex_release(dev); |
| 1529 |
} |
| 1530 |
#endif /* CONFIG_PM */ |
| 1531 |
|
| 1532 |
static void mt7925_sta_set_decap_offload(struct ieee80211_hw *hw, |
| 1533 |
struct ieee80211_vif *vif, |
| 1534 |
struct ieee80211_sta *sta, |
| 1535 |
bool enabled) |
| 1536 |
{ |
| 1537 |
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; |
| 1538 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 1539 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1540 |
unsigned long valid = mvif->valid_links; |
| 1541 |
u8 i; |
| 1542 |
|
| 1543 |
if (!msta->vif) |
| 1544 |
return; |
| 1545 |
|
| 1546 |
mt792x_mutex_acquire(dev); |
| 1547 |
|
| 1548 |
valid = ieee80211_vif_is_mld(vif) ? mvif->valid_links : BIT(0); |
| 1549 |
|
| 1550 |
for_each_set_bit(i, &valid, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 1551 |
struct mt792x_link_sta *mlink; |
| 1552 |
|
| 1553 |
mlink = mt792x_sta_to_link(msta, i); |
| 1554 |
|
| 1555 |
if (enabled) |
| 1556 |
set_bit(MT_WCID_FLAG_HDR_TRANS, &mlink->wcid.flags); |
| 1557 |
else |
| 1558 |
clear_bit(MT_WCID_FLAG_HDR_TRANS, &mlink->wcid.flags); |
| 1559 |
|
| 1560 |
if (!mlink->wcid.sta) |
| 1561 |
continue; |
| 1562 |
|
| 1563 |
mt7925_mcu_wtbl_update_hdr_trans(dev, vif, sta, i); |
| 1564 |
} |
| 1565 |
|
| 1566 |
mt792x_mutex_release(dev); |
| 1567 |
} |
| 1568 |
|
| 1569 |
#if IS_ENABLED(CONFIG_IPV6) |
| 1570 |
static void __mt7925_ipv6_addr_change(struct ieee80211_hw *hw, |
| 1571 |
struct ieee80211_bss_conf *link_conf, |
| 1572 |
struct inet6_dev *idev) |
| 1573 |
{ |
| 1574 |
struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(link_conf); |
| 1575 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1576 |
struct inet6_ifaddr *ifa; |
| 1577 |
struct sk_buff *skb; |
| 1578 |
u8 idx = 0; |
| 1579 |
|
| 1580 |
struct { |
| 1581 |
struct { |
| 1582 |
u8 bss_idx; |
| 1583 |
u8 pad[3]; |
| 1584 |
} __packed hdr; |
| 1585 |
struct mt7925_arpns_tlv arpns; |
| 1586 |
struct in6_addr ns_addrs[IEEE80211_BSS_ARP_ADDR_LIST_LEN]; |
| 1587 |
} req_hdr = { |
| 1588 |
.hdr = { |
| 1589 |
.bss_idx = mconf->mt76.idx, |
| 1590 |
}, |
| 1591 |
.arpns = { |
| 1592 |
.tag = cpu_to_le16(UNI_OFFLOAD_OFFLOAD_ND), |
| 1593 |
.len = cpu_to_le16(sizeof(req_hdr) - 4), |
| 1594 |
.enable = true, |
| 1595 |
}, |
| 1596 |
}; |
| 1597 |
|
| 1598 |
read_lock_bh(&idev->lock); |
| 1599 |
list_for_each_entry(ifa, &idev->addr_list, if_list) { |
| 1600 |
if (ifa->flags & IFA_F_TENTATIVE) |
| 1601 |
continue; |
| 1602 |
req_hdr.ns_addrs[idx] = ifa->addr; |
| 1603 |
if (++idx >= IEEE80211_BSS_ARP_ADDR_LIST_LEN) |
| 1604 |
break; |
| 1605 |
} |
| 1606 |
read_unlock_bh(&idev->lock); |
| 1607 |
|
| 1608 |
if (!idx) |
| 1609 |
return; |
| 1610 |
|
| 1611 |
req_hdr.arpns.ips_num = idx; |
| 1612 |
|
| 1613 |
skb = __mt76_mcu_msg_alloc(&dev->mt76, NULL, sizeof(req_hdr), |
| 1614 |
0, GFP_ATOMIC); |
| 1615 |
if (!skb) |
| 1616 |
return; |
| 1617 |
|
| 1618 |
skb_put_data(skb, &req_hdr, sizeof(req_hdr)); |
| 1619 |
|
| 1620 |
skb_queue_tail(&dev->ipv6_ns_list, skb); |
| 1621 |
|
| 1622 |
ieee80211_queue_work(dev->mt76.hw, &dev->ipv6_ns_work); |
| 1623 |
} |
| 1624 |
|
| 1625 |
static void mt7925_ipv6_addr_change(struct ieee80211_hw *hw, |
| 1626 |
struct ieee80211_vif *vif, |
| 1627 |
struct inet6_dev *idev) |
| 1628 |
{ |
| 1629 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 1630 |
unsigned long valid = ieee80211_vif_is_mld(vif) ? |
| 1631 |
mvif->valid_links : BIT(0); |
| 1632 |
struct ieee80211_bss_conf *bss_conf; |
| 1633 |
int i; |
| 1634 |
|
| 1635 |
for_each_set_bit(i, &valid, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 1636 |
bss_conf = mt792x_vif_to_bss_conf(vif, i); |
| 1637 |
__mt7925_ipv6_addr_change(hw, bss_conf, idev); |
| 1638 |
} |
| 1639 |
} |
| 1640 |
|
| 1641 |
#endif |
| 1642 |
|
| 1643 |
int mt7925_set_tx_sar_pwr(struct ieee80211_hw *hw, |
| 1644 |
const struct cfg80211_sar_specs *sar) |
| 1645 |
{ |
| 1646 |
struct mt76_phy *mphy = hw->priv; |
| 1647 |
|
| 1648 |
if (sar) { |
| 1649 |
int err = mt76_init_sar_power(hw, sar); |
| 1650 |
|
| 1651 |
if (err) |
| 1652 |
return err; |
| 1653 |
} |
| 1654 |
mt792x_init_acpi_sar_power(mt792x_hw_phy(hw), !sar); |
| 1655 |
|
| 1656 |
return mt7925_mcu_set_rate_txpower(mphy); |
| 1657 |
} |
| 1658 |
|
| 1659 |
static int mt7925_set_sar_specs(struct ieee80211_hw *hw, |
| 1660 |
const struct cfg80211_sar_specs *sar) |
| 1661 |
{ |
| 1662 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1663 |
int err; |
| 1664 |
|
| 1665 |
mt792x_mutex_acquire(dev); |
| 1666 |
err = mt7925_set_tx_sar_pwr(hw, sar); |
| 1667 |
mt792x_mutex_release(dev); |
| 1668 |
|
| 1669 |
return err; |
| 1670 |
} |
| 1671 |
|
| 1672 |
static void |
| 1673 |
mt7925_channel_switch_beacon(struct ieee80211_hw *hw, |
| 1674 |
struct ieee80211_vif *vif, |
| 1675 |
struct cfg80211_chan_def *chandef) |
| 1676 |
{ |
| 1677 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1678 |
|
| 1679 |
mt792x_mutex_acquire(dev); |
| 1680 |
mt7925_mcu_uni_add_beacon_offload(dev, hw, vif, true); |
| 1681 |
mt792x_mutex_release(dev); |
| 1682 |
} |
| 1683 |
|
| 1684 |
static int |
| 1685 |
mt7925_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 1686 |
unsigned int link_id, u16 queue, |
| 1687 |
const struct ieee80211_tx_queue_params *params) |
| 1688 |
{ |
| 1689 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 1690 |
struct mt792x_bss_conf *mconf = mt792x_vif_to_link(mvif, link_id); |
| 1691 |
static const u8 mq_to_aci[] = { |
| 1692 |
[IEEE80211_AC_VO] = 3, |
| 1693 |
[IEEE80211_AC_VI] = 2, |
| 1694 |
[IEEE80211_AC_BE] = 0, |
| 1695 |
[IEEE80211_AC_BK] = 1, |
| 1696 |
}; |
| 1697 |
|
| 1698 |
/* firmware uses access class index */ |
| 1699 |
mconf->queue_params[mq_to_aci[queue]] = *params; |
| 1700 |
|
| 1701 |
return 0; |
| 1702 |
} |
| 1703 |
|
| 1704 |
static int |
| 1705 |
mt7925_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 1706 |
struct ieee80211_bss_conf *link_conf) |
| 1707 |
{ |
| 1708 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 1709 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1710 |
int err; |
| 1711 |
|
| 1712 |
mt792x_mutex_acquire(dev); |
| 1713 |
|
| 1714 |
err = mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx, |
| 1715 |
link_conf, NULL, true); |
| 1716 |
if (err) |
| 1717 |
goto out; |
| 1718 |
|
| 1719 |
err = mt7925_mcu_set_bss_pm(dev, link_conf, true); |
| 1720 |
if (err) |
| 1721 |
goto out; |
| 1722 |
|
| 1723 |
err = mt7925_mcu_sta_update(dev, NULL, vif, true, |
| 1724 |
MT76_STA_INFO_STATE_NONE); |
| 1725 |
out: |
| 1726 |
mt792x_mutex_release(dev); |
| 1727 |
|
| 1728 |
return err; |
| 1729 |
} |
| 1730 |
|
| 1731 |
static void |
| 1732 |
mt7925_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 1733 |
struct ieee80211_bss_conf *link_conf) |
| 1734 |
{ |
| 1735 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 1736 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1737 |
int err; |
| 1738 |
|
| 1739 |
mt792x_mutex_acquire(dev); |
| 1740 |
|
| 1741 |
err = mt7925_mcu_set_bss_pm(dev, link_conf, false); |
| 1742 |
if (err) |
| 1743 |
goto out; |
| 1744 |
|
| 1745 |
mt7925_mcu_add_bss_info(&dev->phy, mvif->bss_conf.mt76.ctx, link_conf, |
| 1746 |
NULL, false); |
| 1747 |
|
| 1748 |
out: |
| 1749 |
mt792x_mutex_release(dev); |
| 1750 |
} |
| 1751 |
|
| 1752 |
static int |
| 1753 |
mt7925_add_chanctx(struct ieee80211_hw *hw, |
| 1754 |
struct ieee80211_chanctx_conf *ctx) |
| 1755 |
{ |
| 1756 |
return 0; |
| 1757 |
} |
| 1758 |
|
| 1759 |
static void |
| 1760 |
mt7925_remove_chanctx(struct ieee80211_hw *hw, |
| 1761 |
struct ieee80211_chanctx_conf *ctx) |
| 1762 |
{ |
| 1763 |
} |
| 1764 |
|
| 1765 |
static void |
| 1766 |
mt7925_change_chanctx(struct ieee80211_hw *hw, |
| 1767 |
struct ieee80211_chanctx_conf *ctx, |
| 1768 |
u32 changed) |
| 1769 |
{ |
| 1770 |
struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv; |
| 1771 |
struct mt792x_phy *phy = mt792x_hw_phy(hw); |
| 1772 |
struct mt792x_bss_conf *mconf; |
| 1773 |
struct ieee80211_vif *vif; |
| 1774 |
struct mt792x_vif *mvif; |
| 1775 |
|
| 1776 |
if (!mctx->bss_conf) |
| 1777 |
return; |
| 1778 |
|
| 1779 |
mconf = mctx->bss_conf; |
| 1780 |
mvif = mconf->vif; |
| 1781 |
vif = container_of((void *)mvif, struct ieee80211_vif, drv_priv); |
| 1782 |
|
| 1783 |
mt792x_mutex_acquire(phy->dev); |
| 1784 |
if (vif->type == NL80211_IFTYPE_MONITOR) { |
| 1785 |
mt7925_mcu_set_sniffer(mvif->phy->dev, vif, true); |
| 1786 |
mt7925_mcu_config_sniffer(mvif, ctx); |
| 1787 |
} else { |
| 1788 |
if (ieee80211_vif_is_mld(vif)) { |
| 1789 |
unsigned long valid = mvif->valid_links; |
| 1790 |
u8 i; |
| 1791 |
|
| 1792 |
for_each_set_bit(i, &valid, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 1793 |
mconf = mt792x_vif_to_link(mvif, i); |
| 1794 |
if (mconf && mconf->mt76.ctx == ctx) |
| 1795 |
break; |
| 1796 |
} |
| 1797 |
|
| 1798 |
} else { |
| 1799 |
mconf = &mvif->bss_conf; |
| 1800 |
} |
| 1801 |
|
| 1802 |
if (mconf) { |
| 1803 |
struct ieee80211_bss_conf *link_conf; |
| 1804 |
|
| 1805 |
link_conf = mt792x_vif_to_bss_conf(vif, mconf->link_id); |
| 1806 |
mt7925_mcu_set_chctx(mvif->phy->mt76, &mconf->mt76, |
| 1807 |
link_conf, ctx); |
| 1808 |
|
| 1809 |
if (changed & IEEE80211_CHANCTX_CHANGE_PUNCTURING) |
| 1810 |
mt7925_mcu_set_eht_pp(mvif->phy->mt76, &mconf->mt76, |
| 1811 |
link_conf, ctx); |
| 1812 |
} |
| 1813 |
} |
| 1814 |
|
| 1815 |
mt792x_mutex_release(phy->dev); |
| 1816 |
} |
| 1817 |
|
| 1818 |
static void mt7925_mgd_prepare_tx(struct ieee80211_hw *hw, |
| 1819 |
struct ieee80211_vif *vif, |
| 1820 |
struct ieee80211_prep_tx_info *info) |
| 1821 |
{ |
| 1822 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 1823 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1824 |
u16 duration = info->duration ? info->duration : |
| 1825 |
jiffies_to_msecs(HZ); |
| 1826 |
|
| 1827 |
mt792x_mutex_acquire(dev); |
| 1828 |
mt7925_set_roc(mvif->phy, &mvif->bss_conf, |
| 1829 |
mvif->bss_conf.mt76.ctx->def.chan, duration, |
| 1830 |
MT7925_ROC_REQ_JOIN); |
| 1831 |
mt792x_mutex_release(dev); |
| 1832 |
} |
| 1833 |
|
| 1834 |
static void mt7925_mgd_complete_tx(struct ieee80211_hw *hw, |
| 1835 |
struct ieee80211_vif *vif, |
| 1836 |
struct ieee80211_prep_tx_info *info) |
| 1837 |
{ |
| 1838 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 1839 |
|
| 1840 |
mt7925_abort_roc(mvif->phy, &mvif->bss_conf); |
| 1841 |
} |
| 1842 |
|
| 1843 |
static void mt7925_vif_cfg_changed(struct ieee80211_hw *hw, |
| 1844 |
struct ieee80211_vif *vif, |
| 1845 |
u64 changed) |
| 1846 |
{ |
| 1847 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 1848 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1849 |
unsigned long valid = ieee80211_vif_is_mld(vif) ? |
| 1850 |
mvif->valid_links : BIT(0); |
| 1851 |
struct ieee80211_bss_conf *bss_conf; |
| 1852 |
int i; |
| 1853 |
|
| 1854 |
mt792x_mutex_acquire(dev); |
| 1855 |
|
| 1856 |
if (changed & BSS_CHANGED_ASSOC) { |
| 1857 |
mt7925_mcu_sta_update(dev, NULL, vif, true, |
| 1858 |
MT76_STA_INFO_STATE_ASSOC); |
| 1859 |
mt7925_mcu_set_beacon_filter(dev, vif, vif->cfg.assoc); |
| 1860 |
|
| 1861 |
if (ieee80211_vif_is_mld(vif)) |
| 1862 |
mvif->mlo_pm_state = MT792x_MLO_LINK_ASSOC; |
| 1863 |
} |
| 1864 |
|
| 1865 |
if (changed & BSS_CHANGED_ARP_FILTER) { |
| 1866 |
for_each_set_bit(i, &valid, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 1867 |
bss_conf = mt792x_vif_to_bss_conf(vif, i); |
| 1868 |
mt7925_mcu_update_arp_filter(&dev->mt76, bss_conf); |
| 1869 |
} |
| 1870 |
} |
| 1871 |
|
| 1872 |
if (changed & BSS_CHANGED_PS) { |
| 1873 |
if (hweight16(mvif->valid_links) < 2) { |
| 1874 |
/* legacy */ |
| 1875 |
bss_conf = &vif->bss_conf; |
| 1876 |
mt7925_mcu_uni_bss_ps(dev, bss_conf); |
| 1877 |
} else { |
| 1878 |
if (mvif->mlo_pm_state == MT792x_MLO_LINK_ASSOC) { |
| 1879 |
mvif->mlo_pm_state = MT792x_MLO_CHANGED_PS_PENDING; |
| 1880 |
} else if (mvif->mlo_pm_state == MT792x_MLO_CHANGED_PS) { |
| 1881 |
for_each_set_bit(i, &valid, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 1882 |
bss_conf = mt792x_vif_to_bss_conf(vif, i); |
| 1883 |
mt7925_mcu_uni_bss_ps(dev, bss_conf); |
| 1884 |
} |
| 1885 |
} |
| 1886 |
} |
| 1887 |
} |
| 1888 |
|
| 1889 |
mt792x_mutex_release(dev); |
| 1890 |
} |
| 1891 |
|
| 1892 |
static void mt7925_link_info_changed(struct ieee80211_hw *hw, |
| 1893 |
struct ieee80211_vif *vif, |
| 1894 |
struct ieee80211_bss_conf *info, |
| 1895 |
u64 changed) |
| 1896 |
{ |
| 1897 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 1898 |
struct mt792x_phy *phy = mt792x_hw_phy(hw); |
| 1899 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1900 |
struct mt792x_bss_conf *mconf; |
| 1901 |
|
| 1902 |
mconf = mt792x_vif_to_link(mvif, info->link_id); |
| 1903 |
|
| 1904 |
mt792x_mutex_acquire(dev); |
| 1905 |
|
| 1906 |
if (changed & BSS_CHANGED_ERP_SLOT) { |
| 1907 |
int slottime = info->use_short_slot ? 9 : 20; |
| 1908 |
|
| 1909 |
if (slottime != phy->slottime) { |
| 1910 |
phy->slottime = slottime; |
| 1911 |
mt7925_mcu_set_timing(phy, info); |
| 1912 |
} |
| 1913 |
} |
| 1914 |
|
| 1915 |
if (changed & BSS_CHANGED_MCAST_RATE) |
| 1916 |
mconf->mt76.mcast_rates_idx = |
| 1917 |
mt7925_get_rates_table(hw, vif, false, true); |
| 1918 |
|
| 1919 |
if (changed & BSS_CHANGED_BASIC_RATES) |
| 1920 |
mconf->mt76.basic_rates_idx = |
| 1921 |
mt7925_get_rates_table(hw, vif, false, false); |
| 1922 |
|
| 1923 |
if (changed & (BSS_CHANGED_BEACON | |
| 1924 |
BSS_CHANGED_BEACON_ENABLED)) { |
| 1925 |
mconf->mt76.beacon_rates_idx = |
| 1926 |
mt7925_get_rates_table(hw, vif, true, false); |
| 1927 |
|
| 1928 |
mt7925_mcu_uni_add_beacon_offload(dev, hw, vif, |
| 1929 |
info->enable_beacon); |
| 1930 |
} |
| 1931 |
|
| 1932 |
/* ensure that enable txcmd_mode after bss_info */ |
| 1933 |
if (changed & (BSS_CHANGED_QOS | BSS_CHANGED_BEACON_ENABLED)) |
| 1934 |
mt7925_mcu_set_tx(dev, info); |
| 1935 |
|
| 1936 |
if (mvif->mlo_pm_state == MT792x_MLO_CHANGED_PS_PENDING) { |
| 1937 |
/* Indicate the secondary setup done */ |
| 1938 |
mt7925_mcu_uni_bss_bcnft(dev, info, true); |
| 1939 |
|
| 1940 |
ieee80211_queue_delayed_work(hw, &dev->mlo_pm_work, 5 * HZ); |
| 1941 |
mvif->mlo_pm_state = MT792x_MLO_CHANGED_PS; |
| 1942 |
} |
| 1943 |
|
| 1944 |
if (changed & BSS_CHANGED_CQM) |
| 1945 |
mt7925_mcu_set_rssimonitor(dev, vif); |
| 1946 |
|
| 1947 |
mt792x_mutex_release(dev); |
| 1948 |
} |
| 1949 |
|
| 1950 |
static int |
| 1951 |
mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 1952 |
u16 old_links, u16 new_links, |
| 1953 |
struct ieee80211_bss_conf *old[IEEE80211_MLD_MAX_NUM_LINKS]) |
| 1954 |
{ |
| 1955 |
struct mt792x_bss_conf *mconfs[IEEE80211_MLD_MAX_NUM_LINKS] = {}, *mconf; |
| 1956 |
struct mt792x_link_sta *mlinks[IEEE80211_MLD_MAX_NUM_LINKS] = {}, *mlink; |
| 1957 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 1958 |
unsigned long add = new_links & ~old_links; |
| 1959 |
unsigned long rem = old_links & ~new_links; |
| 1960 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 1961 |
struct mt792x_phy *phy = mt792x_hw_phy(hw); |
| 1962 |
struct ieee80211_bss_conf *link_conf; |
| 1963 |
unsigned int link_id; |
| 1964 |
int err; |
| 1965 |
|
| 1966 |
if (old_links == new_links) |
| 1967 |
return 0; |
| 1968 |
|
| 1969 |
mt792x_mutex_acquire(dev); |
| 1970 |
|
| 1971 |
for_each_set_bit(link_id, &rem, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 1972 |
mconf = mt792x_vif_to_link(mvif, link_id); |
| 1973 |
mlink = mt792x_sta_to_link(&mvif->sta, link_id); |
| 1974 |
|
| 1975 |
if (!mconf || !mlink) |
| 1976 |
continue; |
| 1977 |
|
| 1978 |
if (mconf != &mvif->bss_conf) { |
| 1979 |
mt792x_mac_link_bss_remove(dev, mconf, mlink); |
| 1980 |
devm_kfree(dev->mt76.dev, mconf); |
| 1981 |
devm_kfree(dev->mt76.dev, mlink); |
| 1982 |
} |
| 1983 |
|
| 1984 |
rcu_assign_pointer(mvif->link_conf[link_id], NULL); |
| 1985 |
rcu_assign_pointer(mvif->sta.link[link_id], NULL); |
| 1986 |
} |
| 1987 |
|
| 1988 |
for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 1989 |
if (!old_links) { |
| 1990 |
mvif->deflink_id = link_id; |
| 1991 |
mconf = &mvif->bss_conf; |
| 1992 |
mlink = &mvif->sta.deflink; |
| 1993 |
} else { |
| 1994 |
mconf = devm_kzalloc(dev->mt76.dev, sizeof(*mconf), |
| 1995 |
GFP_KERNEL); |
| 1996 |
mlink = devm_kzalloc(dev->mt76.dev, sizeof(*mlink), |
| 1997 |
GFP_KERNEL); |
| 1998 |
if (!mconf || !mlink) { |
| 1999 |
mt792x_mutex_release(dev); |
| 2000 |
return -ENOMEM; |
| 2001 |
} |
| 2002 |
} |
| 2003 |
|
| 2004 |
mconfs[link_id] = mconf; |
| 2005 |
mlinks[link_id] = mlink; |
| 2006 |
mconf->link_id = link_id; |
| 2007 |
mconf->vif = mvif; |
| 2008 |
mlink->wcid.link_id = link_id; |
| 2009 |
mlink->wcid.link_valid = !!vif->valid_links; |
| 2010 |
mlink->wcid.def_wcid = &mvif->sta.deflink.wcid; |
| 2011 |
} |
| 2012 |
|
| 2013 |
if (hweight16(mvif->valid_links) == 0) |
| 2014 |
mt792x_mac_link_bss_remove(dev, &mvif->bss_conf, |
| 2015 |
&mvif->sta.deflink); |
| 2016 |
|
| 2017 |
for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 2018 |
mconf = mconfs[link_id]; |
| 2019 |
mlink = mlinks[link_id]; |
| 2020 |
link_conf = mt792x_vif_to_bss_conf(vif, link_id); |
| 2021 |
|
| 2022 |
rcu_assign_pointer(mvif->link_conf[link_id], mconf); |
| 2023 |
rcu_assign_pointer(mvif->sta.link[link_id], mlink); |
| 2024 |
|
| 2025 |
err = mt7925_mac_link_bss_add(dev, link_conf, mlink); |
| 2026 |
if (err < 0) |
| 2027 |
goto free; |
| 2028 |
|
| 2029 |
if (mconf != &mvif->bss_conf) { |
| 2030 |
err = mt7925_set_mlo_roc(phy, &mvif->bss_conf, |
| 2031 |
vif->active_links); |
| 2032 |
if (err < 0) |
| 2033 |
goto free; |
| 2034 |
} |
| 2035 |
} |
| 2036 |
|
| 2037 |
mvif->valid_links = new_links; |
| 2038 |
|
| 2039 |
mt792x_mutex_release(dev); |
| 2040 |
|
| 2041 |
return 0; |
| 2042 |
|
| 2043 |
free: |
| 2044 |
for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 2045 |
rcu_assign_pointer(mvif->link_conf[link_id], NULL); |
| 2046 |
rcu_assign_pointer(mvif->sta.link[link_id], NULL); |
| 2047 |
|
| 2048 |
if (mconf != &mvif->bss_conf) |
| 2049 |
devm_kfree(dev->mt76.dev, mconfs[link_id]); |
| 2050 |
if (mlink != &mvif->sta.deflink) |
| 2051 |
devm_kfree(dev->mt76.dev, mlinks[link_id]); |
| 2052 |
} |
| 2053 |
|
| 2054 |
mt792x_mutex_release(dev); |
| 2055 |
|
| 2056 |
return err; |
| 2057 |
} |
| 2058 |
|
| 2059 |
static int |
| 2060 |
mt7925_change_sta_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 2061 |
struct ieee80211_sta *sta, u16 old_links, u16 new_links) |
| 2062 |
{ |
| 2063 |
unsigned long add = new_links & ~old_links; |
| 2064 |
unsigned long rem = old_links & ~new_links; |
| 2065 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 2066 |
int err = 0; |
| 2067 |
|
| 2068 |
if (old_links == new_links) |
| 2069 |
return 0; |
| 2070 |
|
| 2071 |
mt792x_mutex_acquire(dev); |
| 2072 |
|
| 2073 |
err = mt7925_mac_sta_remove_links(dev, vif, sta, rem); |
| 2074 |
if (err < 0) |
| 2075 |
goto out; |
| 2076 |
|
| 2077 |
err = mt7925_mac_sta_add_links(dev, vif, sta, add); |
| 2078 |
if (err < 0) |
| 2079 |
goto out; |
| 2080 |
|
| 2081 |
out: |
| 2082 |
mt792x_mutex_release(dev); |
| 2083 |
|
| 2084 |
return err; |
| 2085 |
} |
| 2086 |
|
| 2087 |
static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw, |
| 2088 |
struct ieee80211_vif *vif, |
| 2089 |
struct ieee80211_bss_conf *link_conf, |
| 2090 |
struct ieee80211_chanctx_conf *ctx) |
| 2091 |
{ |
| 2092 |
struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv; |
| 2093 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 2094 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 2095 |
struct ieee80211_bss_conf *pri_link_conf; |
| 2096 |
struct mt792x_bss_conf *mconf; |
| 2097 |
|
| 2098 |
mutex_lock(&dev->mt76.mutex); |
| 2099 |
|
| 2100 |
if (ieee80211_vif_is_mld(vif)) { |
| 2101 |
mconf = mt792x_vif_to_link(mvif, link_conf->link_id); |
| 2102 |
pri_link_conf = mt792x_vif_to_bss_conf(vif, mvif->deflink_id); |
| 2103 |
|
| 2104 |
if (vif->type == NL80211_IFTYPE_STATION && |
| 2105 |
mconf == &mvif->bss_conf) |
| 2106 |
mt7925_mcu_add_bss_info(&dev->phy, NULL, pri_link_conf, |
| 2107 |
NULL, true); |
| 2108 |
} else { |
| 2109 |
mconf = &mvif->bss_conf; |
| 2110 |
} |
| 2111 |
|
| 2112 |
mconf->mt76.ctx = ctx; |
| 2113 |
mctx->bss_conf = mconf; |
| 2114 |
mutex_unlock(&dev->mt76.mutex); |
| 2115 |
|
| 2116 |
return 0; |
| 2117 |
} |
| 2118 |
|
| 2119 |
static void mt7925_unassign_vif_chanctx(struct ieee80211_hw *hw, |
| 2120 |
struct ieee80211_vif *vif, |
| 2121 |
struct ieee80211_bss_conf *link_conf, |
| 2122 |
struct ieee80211_chanctx_conf *ctx) |
| 2123 |
{ |
| 2124 |
struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv; |
| 2125 |
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
| 2126 |
struct mt792x_dev *dev = mt792x_hw_dev(hw); |
| 2127 |
struct mt792x_bss_conf *mconf; |
| 2128 |
|
| 2129 |
mutex_lock(&dev->mt76.mutex); |
| 2130 |
|
| 2131 |
if (ieee80211_vif_is_mld(vif)) { |
| 2132 |
mconf = mt792x_vif_to_link(mvif, link_conf->link_id); |
| 2133 |
|
| 2134 |
if (vif->type == NL80211_IFTYPE_STATION && |
| 2135 |
mconf == &mvif->bss_conf) |
| 2136 |
mt7925_mcu_add_bss_info(&dev->phy, NULL, link_conf, |
| 2137 |
NULL, false); |
| 2138 |
} else { |
| 2139 |
mconf = &mvif->bss_conf; |
| 2140 |
} |
| 2141 |
|
| 2142 |
mctx->bss_conf = NULL; |
| 2143 |
mconf->mt76.ctx = NULL; |
| 2144 |
mutex_unlock(&dev->mt76.mutex); |
| 2145 |
} |
| 2146 |
|
| 2147 |
static void mt7925_rfkill_poll(struct ieee80211_hw *hw) |
| 2148 |
{ |
| 2149 |
struct mt792x_phy *phy = mt792x_hw_phy(hw); |
| 2150 |
int ret; |
| 2151 |
|
| 2152 |
mt792x_mutex_acquire(phy->dev); |
| 2153 |
ret = mt7925_mcu_wf_rf_pin_ctrl(phy); |
| 2154 |
mt792x_mutex_release(phy->dev); |
| 2155 |
|
| 2156 |
wiphy_rfkill_set_hw_state(hw->wiphy, ret == 0); |
| 2157 |
} |
| 2158 |
|
| 2159 |
const struct ieee80211_ops mt7925_ops = { |
| 2160 |
.tx = mt792x_tx, |
| 2161 |
.start = mt7925_start, |
| 2162 |
.stop = mt792x_stop, |
| 2163 |
.add_interface = mt7925_add_interface, |
| 2164 |
.remove_interface = mt792x_remove_interface, |
| 2165 |
.config = mt7925_config, |
| 2166 |
.conf_tx = mt7925_conf_tx, |
| 2167 |
.configure_filter = mt7925_configure_filter, |
| 2168 |
.start_ap = mt7925_start_ap, |
| 2169 |
.stop_ap = mt7925_stop_ap, |
| 2170 |
.sta_state = mt76_sta_state, |
| 2171 |
.sta_pre_rcu_remove = mt76_sta_pre_rcu_remove, |
| 2172 |
.set_key = mt7925_set_key, |
| 2173 |
.sta_set_decap_offload = mt7925_sta_set_decap_offload, |
| 2174 |
#if IS_ENABLED(CONFIG_IPV6) |
| 2175 |
.ipv6_addr_change = mt7925_ipv6_addr_change, |
| 2176 |
#endif /* CONFIG_IPV6 */ |
| 2177 |
.ampdu_action = mt7925_ampdu_action, |
| 2178 |
.set_rts_threshold = mt7925_set_rts_threshold, |
| 2179 |
.wake_tx_queue = mt76_wake_tx_queue, |
| 2180 |
.release_buffered_frames = mt76_release_buffered_frames, |
| 2181 |
.channel_switch_beacon = mt7925_channel_switch_beacon, |
| 2182 |
.get_txpower = mt76_get_txpower, |
| 2183 |
.get_stats = mt792x_get_stats, |
| 2184 |
.get_et_sset_count = mt792x_get_et_sset_count, |
| 2185 |
.get_et_strings = mt792x_get_et_strings, |
| 2186 |
.get_et_stats = mt792x_get_et_stats, |
| 2187 |
.get_tsf = mt792x_get_tsf, |
| 2188 |
.set_tsf = mt792x_set_tsf, |
| 2189 |
.get_survey = mt76_get_survey, |
| 2190 |
.get_antenna = mt76_get_antenna, |
| 2191 |
.set_antenna = mt7925_set_antenna, |
| 2192 |
.set_coverage_class = mt792x_set_coverage_class, |
| 2193 |
.hw_scan = mt7925_hw_scan, |
| 2194 |
.cancel_hw_scan = mt7925_cancel_hw_scan, |
| 2195 |
.sta_statistics = mt792x_sta_statistics, |
| 2196 |
.sched_scan_start = mt7925_start_sched_scan, |
| 2197 |
.sched_scan_stop = mt7925_stop_sched_scan, |
| 2198 |
CFG80211_TESTMODE_CMD(mt7925_testmode_cmd) |
| 2199 |
CFG80211_TESTMODE_DUMP(mt7925_testmode_dump) |
| 2200 |
#ifdef CONFIG_PM |
| 2201 |
.suspend = mt7925_suspend, |
| 2202 |
.resume = mt7925_resume, |
| 2203 |
.set_wakeup = mt792x_set_wakeup, |
| 2204 |
.set_rekey_data = mt7925_set_rekey_data, |
| 2205 |
#endif /* CONFIG_PM */ |
| 2206 |
.flush = mt792x_flush, |
| 2207 |
.set_sar_specs = mt7925_set_sar_specs, |
| 2208 |
.remain_on_channel = mt7925_remain_on_channel, |
| 2209 |
.cancel_remain_on_channel = mt7925_cancel_remain_on_channel, |
| 2210 |
.add_chanctx = mt7925_add_chanctx, |
| 2211 |
.remove_chanctx = mt7925_remove_chanctx, |
| 2212 |
.change_chanctx = mt7925_change_chanctx, |
| 2213 |
.assign_vif_chanctx = mt7925_assign_vif_chanctx, |
| 2214 |
.unassign_vif_chanctx = mt7925_unassign_vif_chanctx, |
| 2215 |
.mgd_prepare_tx = mt7925_mgd_prepare_tx, |
| 2216 |
.mgd_complete_tx = mt7925_mgd_complete_tx, |
| 2217 |
.vif_cfg_changed = mt7925_vif_cfg_changed, |
| 2218 |
.link_info_changed = mt7925_link_info_changed, |
| 2219 |
.change_vif_links = mt7925_change_vif_links, |
| 2220 |
.change_sta_links = mt7925_change_sta_links, |
| 2221 |
.rfkill_poll = mt7925_rfkill_poll, |
| 2222 |
}; |
| 2223 |
EXPORT_SYMBOL_GPL(mt7925_ops); |
| 2224 |
|
| 2225 |
MODULE_AUTHOR("Deren Wu <[email protected]>"); |
| 2226 |
MODULE_DESCRIPTION("MediaTek MT7925 core driver"); |
| 2227 |
MODULE_LICENSE("Dual BSD/GPL"); |