| 1 |
/* SPDX-License-Identifier: BSD-3-Clause-Clear */ |
| 2 |
/* Copyright (C) 2023 MediaTek Inc. */ |
| 3 |
|
| 4 |
#ifndef __MT7925_H |
| 5 |
#define __MT7925_H |
| 6 |
|
| 7 |
#include "../mt792x.h" |
| 8 |
#include "regs.h" |
| 9 |
|
| 10 |
#define MT7925_BEACON_RATES_TBL 25 |
| 11 |
|
| 12 |
#define MT7925_TX_RING_SIZE 2048 |
| 13 |
#define MT7925_TX_MCU_RING_SIZE 256 |
| 14 |
#define MT7925_TX_FWDL_RING_SIZE 128 |
| 15 |
|
| 16 |
#define MT7925_RX_RING_SIZE 1536 |
| 17 |
#define MT7925_RX_MCU_RING_SIZE 512 |
| 18 |
|
| 19 |
#define MT7925_EEPROM_SIZE 3584 |
| 20 |
#define MT7925_TOKEN_SIZE 8192 |
| 21 |
|
| 22 |
#define MT7925_EEPROM_BLOCK_SIZE 16 |
| 23 |
|
| 24 |
#define MT7925_SKU_RATE_NUM 161 |
| 25 |
#define MT7925_SKU_MAX_DELTA_IDX MT7925_SKU_RATE_NUM |
| 26 |
#define MT7925_SKU_TABLE_SIZE (MT7925_SKU_RATE_NUM + 1) |
| 27 |
|
| 28 |
#define MCU_UNI_EVENT_ROC 0x27 |
| 29 |
|
| 30 |
#define HIF_TRAFFIC_IDLE 0x2 |
| 31 |
|
| 32 |
enum { |
| 33 |
UNI_EVENT_HIF_CTRL_BASIC = 0, |
| 34 |
UNI_EVENT_HIF_CTRL_TAG_NUM |
| 35 |
}; |
| 36 |
|
| 37 |
struct mt7925_mcu_hif_ctrl_basic_tlv { |
| 38 |
__le16 tag; |
| 39 |
__le16 len; |
| 40 |
u8 cid; |
| 41 |
u8 pad[3]; |
| 42 |
u32 status; |
| 43 |
u8 hif_type; |
| 44 |
u8 hif_tx_traffic_status; |
| 45 |
u8 hif_rx_traffic_status; |
| 46 |
u8 hifsuspend; |
| 47 |
u8 rsv[4]; |
| 48 |
} __packed; |
| 49 |
|
| 50 |
enum { |
| 51 |
UNI_ROC_ACQUIRE, |
| 52 |
UNI_ROC_ABORT, |
| 53 |
UNI_ROC_SUB_LINK = 3, |
| 54 |
UNI_ROC_NUM |
| 55 |
}; |
| 56 |
|
| 57 |
enum mt7925_roc_req { |
| 58 |
MT7925_ROC_REQ_JOIN, |
| 59 |
MT7925_ROC_REQ_ROC, |
| 60 |
MT7925_ROC_REQ_SUB_LINK, |
| 61 |
MT7925_ROC_REQ_MLSR_AG = 10, |
| 62 |
MT7925_ROC_REQ_MLSR_AA, |
| 63 |
MT7925_ROC_REQ_NUM |
| 64 |
}; |
| 65 |
|
| 66 |
enum { |
| 67 |
UNI_EVENT_ROC_GRANT = 0, |
| 68 |
UNI_EVENT_ROC_GRANT_SUB_LINK = 4, |
| 69 |
UNI_EVENT_ROC_TAG_NUM |
| 70 |
}; |
| 71 |
|
| 72 |
struct mt7925_roc_grant_tlv { |
| 73 |
__le16 tag; |
| 74 |
__le16 len; |
| 75 |
u8 bss_idx; |
| 76 |
u8 tokenid; |
| 77 |
u8 status; |
| 78 |
u8 primarychannel; |
| 79 |
u8 rfsco; |
| 80 |
u8 rfband; |
| 81 |
u8 channelwidth; |
| 82 |
u8 centerfreqseg1; |
| 83 |
u8 centerfreqseg2; |
| 84 |
u8 reqtype; |
| 85 |
u8 dbdcband; |
| 86 |
u8 rsv[1]; |
| 87 |
__le32 max_interval; |
| 88 |
} __packed; |
| 89 |
|
| 90 |
struct mt7925_beacon_loss_tlv { |
| 91 |
__le16 tag; |
| 92 |
__le16 len; |
| 93 |
u8 reason; |
| 94 |
u8 nr_btolink; |
| 95 |
u8 pad[2]; |
| 96 |
} __packed; |
| 97 |
|
| 98 |
struct mt7925_uni_beacon_loss_event { |
| 99 |
struct { |
| 100 |
u8 bss_idx; |
| 101 |
u8 pad[3]; |
| 102 |
} __packed hdr; |
| 103 |
struct mt7925_beacon_loss_tlv beacon_loss; |
| 104 |
} __packed; |
| 105 |
|
| 106 |
struct mt7925_uni_rssi_monitor_event { |
| 107 |
__le16 tag; |
| 108 |
__le16 len; |
| 109 |
__le32 rssi; |
| 110 |
} __packed; |
| 111 |
|
| 112 |
#define to_rssi(field, rxv) ((FIELD_GET(field, rxv) - 220) / 2) |
| 113 |
#define to_rcpi(rssi) (2 * (rssi) + 220) |
| 114 |
|
| 115 |
enum mt7925_txq_id { |
| 116 |
MT7925_TXQ_BAND0, |
| 117 |
MT7925_TXQ_BAND1, |
| 118 |
MT7925_TXQ_MCU_WM = 15, |
| 119 |
MT7925_TXQ_FWDL, |
| 120 |
}; |
| 121 |
|
| 122 |
enum mt7925_rxq_id { |
| 123 |
MT7925_RXQ_BAND0 = 2, |
| 124 |
MT7925_RXQ_BAND1, |
| 125 |
MT7925_RXQ_MCU_WM = 0, |
| 126 |
MT7925_RXQ_MCU_WM2, /* for tx done */ |
| 127 |
}; |
| 128 |
|
| 129 |
enum { |
| 130 |
MODE_OPEN = 0, |
| 131 |
MODE_SHARED = 1, |
| 132 |
MODE_WPA = 3, |
| 133 |
MODE_WPA_PSK = 4, |
| 134 |
MODE_WPA_NONE = 5, |
| 135 |
MODE_WPA2 = 6, |
| 136 |
MODE_WPA2_PSK = 7, |
| 137 |
MODE_WPA3_SAE = 11, |
| 138 |
}; |
| 139 |
|
| 140 |
enum { |
| 141 |
MT7925_CLC_POWER, |
| 142 |
MT7925_CLC_CHAN, |
| 143 |
MT7925_CLC_MAX_NUM, |
| 144 |
}; |
| 145 |
|
| 146 |
struct mt7925_clc_rule_v2 { |
| 147 |
u32 flag; |
| 148 |
u8 alpha2[2]; |
| 149 |
u8 rsv[10]; |
| 150 |
} __packed; |
| 151 |
|
| 152 |
struct mt7925_clc_rule { |
| 153 |
u8 alpha2[2]; |
| 154 |
u8 type[2]; |
| 155 |
u8 seg_idx; |
| 156 |
u8 flag; /* UNII4~8 ctrl flag */ |
| 157 |
u8 rsv[2]; |
| 158 |
} __packed; |
| 159 |
|
| 160 |
struct mt7925_clc_segment { |
| 161 |
u8 idx; |
| 162 |
u8 rsv1[3]; |
| 163 |
u32 offset; |
| 164 |
u32 len; |
| 165 |
u8 rsv2[4]; |
| 166 |
} __packed; |
| 167 |
|
| 168 |
struct mt7925_clc_type0 { |
| 169 |
u8 nr_country; |
| 170 |
u8 type; |
| 171 |
u8 nr_seg; |
| 172 |
u8 rsv[7]; |
| 173 |
} __packed; |
| 174 |
|
| 175 |
struct mt7925_clc_type2 { |
| 176 |
u8 type; |
| 177 |
u8 rsv[9]; |
| 178 |
} __packed; |
| 179 |
|
| 180 |
struct mt7925_clc { |
| 181 |
__le32 len; |
| 182 |
u8 idx; |
| 183 |
u8 ver; |
| 184 |
union { |
| 185 |
struct mt7925_clc_type0 t0; |
| 186 |
struct mt7925_clc_type2 t2; |
| 187 |
}; |
| 188 |
u8 data[]; |
| 189 |
} __packed; |
| 190 |
|
| 191 |
enum mt7925_eeprom_field { |
| 192 |
MT_EE_CHIP_ID = 0x000, |
| 193 |
MT_EE_VERSION = 0x002, |
| 194 |
MT_EE_MAC_ADDR = 0x004, |
| 195 |
MT_EE_HW_TYPE = 0xa71, |
| 196 |
__MT_EE_MAX = 0x9ff |
| 197 |
}; |
| 198 |
|
| 199 |
#define MT_EE_HW_TYPE_ENCAP GENMASK(1, 0) |
| 200 |
|
| 201 |
enum { |
| 202 |
TXPWR_USER, |
| 203 |
TXPWR_EEPROM, |
| 204 |
TXPWR_MAC, |
| 205 |
TXPWR_MAX_NUM, |
| 206 |
}; |
| 207 |
|
| 208 |
struct mt7925_txpwr { |
| 209 |
s8 cck[4][2]; |
| 210 |
s8 ofdm[8][2]; |
| 211 |
s8 ht20[8][2]; |
| 212 |
s8 ht40[9][2]; |
| 213 |
s8 vht20[12][2]; |
| 214 |
s8 vht40[12][2]; |
| 215 |
s8 vht80[12][2]; |
| 216 |
s8 vht160[12][2]; |
| 217 |
s8 he26[12][2]; |
| 218 |
s8 he52[12][2]; |
| 219 |
s8 he106[12][2]; |
| 220 |
s8 he242[12][2]; |
| 221 |
s8 he484[12][2]; |
| 222 |
s8 he996[12][2]; |
| 223 |
s8 he996x2[12][2]; |
| 224 |
s8 eht26[16][2]; |
| 225 |
s8 eht52[16][2]; |
| 226 |
s8 eht106[16][2]; |
| 227 |
s8 eht242[16][2]; |
| 228 |
s8 eht484[16][2]; |
| 229 |
s8 eht996[16][2]; |
| 230 |
s8 eht996x2[16][2]; |
| 231 |
s8 eht996x4[16][2]; |
| 232 |
s8 eht26_52[16][2]; |
| 233 |
s8 eht26_106[16][2]; |
| 234 |
s8 eht484_242[16][2]; |
| 235 |
s8 eht996_484[16][2]; |
| 236 |
s8 eht996_484_242[16][2]; |
| 237 |
s8 eht996x2_484[16][2]; |
| 238 |
s8 eht996x3[16][2]; |
| 239 |
s8 eht996x3_484[16][2]; |
| 240 |
}; |
| 241 |
|
| 242 |
extern const struct ieee80211_ops mt7925_ops; |
| 243 |
|
| 244 |
int __mt7925_start(struct mt792x_phy *phy); |
| 245 |
int mt7925_register_device(struct mt792x_dev *dev); |
| 246 |
void mt7925_unregister_device(struct mt792x_dev *dev); |
| 247 |
int mt7925_run_firmware(struct mt792x_dev *dev); |
| 248 |
int mt7925_mcu_set_bss_pm(struct mt792x_dev *dev, |
| 249 |
struct ieee80211_bss_conf *link_conf, |
| 250 |
bool enable); |
| 251 |
int mt7925_mcu_sta_update(struct mt792x_dev *dev, |
| 252 |
struct ieee80211_link_sta *link_sta, |
| 253 |
struct ieee80211_vif *vif, bool enable, |
| 254 |
enum mt76_sta_info_state state); |
| 255 |
int mt7925_mcu_set_chan_info(struct mt792x_phy *phy, u16 tag); |
| 256 |
int mt7925_mcu_set_tx(struct mt792x_dev *dev, struct ieee80211_bss_conf *bss_conf); |
| 257 |
int mt7925_mcu_set_eeprom(struct mt792x_dev *dev); |
| 258 |
int mt7925_mcu_get_rx_rate(struct mt792x_phy *phy, struct ieee80211_vif *vif, |
| 259 |
struct ieee80211_sta *sta, struct rate_info *rate); |
| 260 |
int mt7925_mcu_fw_log_2_host(struct mt792x_dev *dev, u8 ctrl); |
| 261 |
void mt7925_mcu_rx_event(struct mt792x_dev *dev, struct sk_buff *skb); |
| 262 |
int mt7925_mcu_chip_config(struct mt792x_dev *dev, const char *cmd); |
| 263 |
int mt7925_mcu_set_rxfilter(struct mt792x_dev *dev, u32 fif, |
| 264 |
u8 bit_op, u32 bit_map); |
| 265 |
|
| 266 |
int mt7925_mac_init(struct mt792x_dev *dev); |
| 267 |
int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
| 268 |
struct ieee80211_sta *sta); |
| 269 |
bool mt7925_mac_wtbl_update(struct mt792x_dev *dev, int idx, u32 mask); |
| 270 |
int mt7925_mac_sta_event(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
| 271 |
struct ieee80211_sta *sta, enum mt76_sta_event ev); |
| 272 |
void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
| 273 |
struct ieee80211_sta *sta); |
| 274 |
void mt7925_mac_reset_work(struct work_struct *work); |
| 275 |
int mt7925e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, |
| 276 |
enum mt76_txq_id qid, struct mt76_wcid *wcid, |
| 277 |
struct ieee80211_sta *sta, |
| 278 |
struct mt76_tx_info *tx_info); |
| 279 |
|
| 280 |
void mt7925_tx_token_put(struct mt792x_dev *dev); |
| 281 |
bool mt7925_rx_check(struct mt76_dev *mdev, void *data, int len); |
| 282 |
void mt7925_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, |
| 283 |
struct sk_buff *skb, u32 *info); |
| 284 |
void mt7925_stats_work(struct work_struct *work); |
| 285 |
void mt7925_set_stream_he_eht_caps(struct mt792x_phy *phy); |
| 286 |
int mt7925_init_mlo_caps(struct mt792x_phy *phy); |
| 287 |
int mt7925_init_debugfs(struct mt792x_dev *dev); |
| 288 |
|
| 289 |
int mt7925_mcu_set_beacon_filter(struct mt792x_dev *dev, |
| 290 |
struct ieee80211_vif *vif, |
| 291 |
bool enable); |
| 292 |
int mt7925_mcu_uni_tx_ba(struct mt792x_dev *dev, |
| 293 |
struct ieee80211_ampdu_params *params, |
| 294 |
bool enable); |
| 295 |
int mt7925_mcu_uni_rx_ba(struct mt792x_dev *dev, |
| 296 |
struct ieee80211_ampdu_params *params, |
| 297 |
bool enable); |
| 298 |
void mt7925_mlo_pm_work(struct work_struct *work); |
| 299 |
void mt7925_scan_work(struct work_struct *work); |
| 300 |
void mt7925_roc_work(struct work_struct *work); |
| 301 |
int mt7925_mcu_uni_bss_ps(struct mt792x_dev *dev, |
| 302 |
struct ieee80211_bss_conf *link_conf); |
| 303 |
void mt7925_coredump_work(struct work_struct *work); |
| 304 |
int mt7925_get_txpwr_info(struct mt792x_dev *dev, u8 band_idx, |
| 305 |
struct mt7925_txpwr *txpwr); |
| 306 |
void mt7925_mac_set_fixed_rate_table(struct mt792x_dev *dev, |
| 307 |
u8 tbl_idx, u16 rate_idx); |
| 308 |
void mt7925_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi, |
| 309 |
struct sk_buff *skb, struct mt76_wcid *wcid, |
| 310 |
struct ieee80211_key_conf *key, int pid, |
| 311 |
enum mt76_txq_id qid, u32 changed); |
| 312 |
void mt7925_txwi_free(struct mt792x_dev *dev, struct mt76_txwi_cache *t, |
| 313 |
struct ieee80211_sta *sta, struct mt76_wcid *wcid, |
| 314 |
struct list_head *free_list); |
| 315 |
int mt7925_mcu_parse_response(struct mt76_dev *mdev, int cmd, |
| 316 |
struct sk_buff *skb, int seq); |
| 317 |
|
| 318 |
int mt7925e_mac_reset(struct mt792x_dev *dev); |
| 319 |
int mt7925e_mcu_init(struct mt792x_dev *dev); |
| 320 |
void mt7925_mac_add_txs(struct mt792x_dev *dev, void *data); |
| 321 |
void mt7925_set_runtime_pm(struct mt792x_dev *dev); |
| 322 |
void mt7925_mcu_set_suspend_iter(void *priv, u8 *mac, |
| 323 |
struct ieee80211_vif *vif); |
| 324 |
void mt7925_connac_mcu_set_suspend_iter(void *priv, u8 *mac, |
| 325 |
struct ieee80211_vif *vif); |
| 326 |
void mt7925_set_ipv6_ns_work(struct work_struct *work); |
| 327 |
|
| 328 |
int mt7925_mcu_set_sniffer(struct mt792x_dev *dev, struct ieee80211_vif *vif, |
| 329 |
bool enable); |
| 330 |
int mt7925_mcu_config_sniffer(struct mt792x_vif *vif, |
| 331 |
struct ieee80211_chanctx_conf *ctx); |
| 332 |
int mt7925_mcu_get_temperature(struct mt792x_phy *phy); |
| 333 |
|
| 334 |
int mt7925_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, |
| 335 |
enum mt76_txq_id qid, struct mt76_wcid *wcid, |
| 336 |
struct ieee80211_sta *sta, |
| 337 |
struct mt76_tx_info *tx_info); |
| 338 |
void mt7925_usb_sdio_tx_complete_skb(struct mt76_dev *mdev, |
| 339 |
struct mt76_queue_entry *e); |
| 340 |
bool mt7925_usb_sdio_tx_status_data(struct mt76_dev *mdev, u8 *update); |
| 341 |
|
| 342 |
int mt7925_mcu_uni_add_beacon_offload(struct mt792x_dev *dev, |
| 343 |
struct ieee80211_hw *hw, |
| 344 |
struct ieee80211_vif *vif, |
| 345 |
bool enable); |
| 346 |
int mt7925_set_tx_sar_pwr(struct ieee80211_hw *hw, |
| 347 |
const struct cfg80211_sar_specs *sar); |
| 348 |
|
| 349 |
int mt7925_mcu_regval(struct mt792x_dev *dev, u32 regidx, u32 *val, bool set); |
| 350 |
int mt7925_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2, |
| 351 |
enum environment_cap env_cap); |
| 352 |
int mt7925_mcu_set_mlo_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf, |
| 353 |
u16 sel_links, int duration, u8 token_id); |
| 354 |
int mt7925_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf, |
| 355 |
struct ieee80211_channel *chan, int duration, |
| 356 |
enum mt7925_roc_req type, u8 token_id); |
| 357 |
int mt7925_mcu_abort_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf, |
| 358 |
u8 token_id); |
| 359 |
void mt7925_roc_abort_sync(struct mt792x_dev *dev); |
| 360 |
int mt7925_mcu_fill_message(struct mt76_dev *mdev, struct sk_buff *skb, |
| 361 |
int cmd, int *wait_seq); |
| 362 |
int mt7925_mcu_add_key(struct mt76_dev *dev, struct ieee80211_vif *vif, |
| 363 |
struct mt76_connac_sta_key_conf *sta_key_conf, |
| 364 |
struct ieee80211_key_conf *key, int mcu_cmd, |
| 365 |
struct mt76_wcid *wcid, enum set_key_cmd cmd, |
| 366 |
struct mt792x_sta *msta); |
| 367 |
int mt7925_mcu_set_rts_thresh(struct mt792x_phy *phy, u32 val); |
| 368 |
int mt7925_mcu_wtbl_update_hdr_trans(struct mt792x_dev *dev, |
| 369 |
struct ieee80211_vif *vif, |
| 370 |
struct ieee80211_sta *sta, |
| 371 |
int link_id); |
| 372 |
int mt7925_mcu_wf_rf_pin_ctrl(struct mt792x_phy *phy); |
| 373 |
|
| 374 |
int mt7925_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 375 |
void *data, int len); |
| 376 |
int mt7925_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *msg, |
| 377 |
struct netlink_callback *cb, void *data, int len); |
| 378 |
|
| 379 |
int mt7925_mcu_set_rssimonitor(struct mt792x_dev *dev, struct ieee80211_vif *vif); |
| 380 |
#endif |