mt76_connac_mcu.h 25 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051
  1. /* SPDX-License-Identifier: ISC */
  2. /* Copyright (C) 2020 MediaTek Inc. */
  3. #ifndef __MT76_CONNAC_MCU_H
  4. #define __MT76_CONNAC_MCU_H
  5. #include "mt76_connac.h"
  6. struct tlv {
  7. __le16 tag;
  8. __le16 len;
  9. } __packed;
  10. /* sta_rec */
  11. struct sta_ntlv_hdr {
  12. u8 rsv[2];
  13. __le16 tlv_num;
  14. } __packed;
  15. struct sta_req_hdr {
  16. u8 bss_idx;
  17. u8 wlan_idx_lo;
  18. __le16 tlv_num;
  19. u8 is_tlv_append;
  20. u8 muar_idx;
  21. u8 wlan_idx_hi;
  22. u8 rsv;
  23. } __packed;
  24. struct sta_rec_basic {
  25. __le16 tag;
  26. __le16 len;
  27. __le32 conn_type;
  28. u8 conn_state;
  29. u8 qos;
  30. __le16 aid;
  31. u8 peer_addr[ETH_ALEN];
  32. #define EXTRA_INFO_VER BIT(0)
  33. #define EXTRA_INFO_NEW BIT(1)
  34. __le16 extra_info;
  35. } __packed;
  36. struct sta_rec_ht {
  37. __le16 tag;
  38. __le16 len;
  39. __le16 ht_cap;
  40. u16 rsv;
  41. } __packed;
  42. struct sta_rec_vht {
  43. __le16 tag;
  44. __le16 len;
  45. __le32 vht_cap;
  46. __le16 vht_rx_mcs_map;
  47. __le16 vht_tx_mcs_map;
  48. /* mt7921 */
  49. u8 rts_bw_sig;
  50. u8 rsv[3];
  51. } __packed;
  52. struct sta_rec_uapsd {
  53. __le16 tag;
  54. __le16 len;
  55. u8 dac_map;
  56. u8 tac_map;
  57. u8 max_sp;
  58. u8 rsv0;
  59. __le16 listen_interval;
  60. u8 rsv1[2];
  61. } __packed;
  62. struct sta_rec_ba {
  63. __le16 tag;
  64. __le16 len;
  65. u8 tid;
  66. u8 ba_type;
  67. u8 amsdu;
  68. u8 ba_en;
  69. __le16 ssn;
  70. __le16 winsize;
  71. } __packed;
  72. struct sta_rec_he {
  73. __le16 tag;
  74. __le16 len;
  75. __le32 he_cap;
  76. u8 t_frame_dur;
  77. u8 max_ampdu_exp;
  78. u8 bw_set;
  79. u8 device_class;
  80. u8 dcm_tx_mode;
  81. u8 dcm_tx_max_nss;
  82. u8 dcm_rx_mode;
  83. u8 dcm_rx_max_nss;
  84. u8 dcm_max_ru;
  85. u8 punc_pream_rx;
  86. u8 pkt_ext;
  87. u8 rsv1;
  88. __le16 max_nss_mcs[CMD_HE_MCS_BW_NUM];
  89. u8 rsv2[2];
  90. } __packed;
  91. struct sta_rec_amsdu {
  92. __le16 tag;
  93. __le16 len;
  94. u8 max_amsdu_num;
  95. u8 max_mpdu_size;
  96. u8 amsdu_en;
  97. u8 rsv;
  98. } __packed;
  99. struct sta_rec_state {
  100. __le16 tag;
  101. __le16 len;
  102. __le32 flags;
  103. u8 state;
  104. u8 vht_opmode;
  105. u8 action;
  106. u8 rsv[1];
  107. } __packed;
  108. #define HT_MCS_MASK_NUM 10
  109. struct sta_rec_ra_info {
  110. __le16 tag;
  111. __le16 len;
  112. __le16 legacy;
  113. u8 rx_mcs_bitmask[HT_MCS_MASK_NUM];
  114. } __packed;
  115. struct sta_rec_phy {
  116. __le16 tag;
  117. __le16 len;
  118. __le16 basic_rate;
  119. u8 phy_type;
  120. u8 ampdu;
  121. u8 rts_policy;
  122. u8 rcpi;
  123. u8 rsv[2];
  124. } __packed;
  125. /* wtbl_rec */
  126. struct wtbl_req_hdr {
  127. u8 wlan_idx_lo;
  128. u8 operation;
  129. __le16 tlv_num;
  130. u8 wlan_idx_hi;
  131. u8 rsv[3];
  132. } __packed;
  133. struct wtbl_generic {
  134. __le16 tag;
  135. __le16 len;
  136. u8 peer_addr[ETH_ALEN];
  137. u8 muar_idx;
  138. u8 skip_tx;
  139. u8 cf_ack;
  140. u8 qos;
  141. u8 mesh;
  142. u8 adm;
  143. __le16 partial_aid;
  144. u8 baf_en;
  145. u8 aad_om;
  146. } __packed;
  147. struct wtbl_rx {
  148. __le16 tag;
  149. __le16 len;
  150. u8 rcid;
  151. u8 rca1;
  152. u8 rca2;
  153. u8 rv;
  154. u8 rsv[4];
  155. } __packed;
  156. struct wtbl_ht {
  157. __le16 tag;
  158. __le16 len;
  159. u8 ht;
  160. u8 ldpc;
  161. u8 af;
  162. u8 mm;
  163. u8 rsv[4];
  164. } __packed;
  165. struct wtbl_vht {
  166. __le16 tag;
  167. __le16 len;
  168. u8 ldpc;
  169. u8 dyn_bw;
  170. u8 vht;
  171. u8 txop_ps;
  172. u8 rsv[4];
  173. } __packed;
  174. struct wtbl_tx_ps {
  175. __le16 tag;
  176. __le16 len;
  177. u8 txps;
  178. u8 rsv[3];
  179. } __packed;
  180. struct wtbl_hdr_trans {
  181. __le16 tag;
  182. __le16 len;
  183. u8 to_ds;
  184. u8 from_ds;
  185. u8 no_rx_trans;
  186. u8 rsv;
  187. } __packed;
  188. struct wtbl_ba {
  189. __le16 tag;
  190. __le16 len;
  191. /* common */
  192. u8 tid;
  193. u8 ba_type;
  194. u8 rsv0[2];
  195. /* originator only */
  196. __le16 sn;
  197. u8 ba_en;
  198. u8 ba_winsize_idx;
  199. __le16 ba_winsize;
  200. /* recipient only */
  201. u8 peer_addr[ETH_ALEN];
  202. u8 rst_ba_tid;
  203. u8 rst_ba_sel;
  204. u8 rst_ba_sb;
  205. u8 band_idx;
  206. u8 rsv1[4];
  207. } __packed;
  208. struct wtbl_smps {
  209. __le16 tag;
  210. __le16 len;
  211. u8 smps;
  212. u8 rsv[3];
  213. } __packed;
  214. /* mt7615 only */
  215. struct wtbl_bf {
  216. __le16 tag;
  217. __le16 len;
  218. u8 ibf;
  219. u8 ebf;
  220. u8 ibf_vht;
  221. u8 ebf_vht;
  222. u8 gid;
  223. u8 pfmu_idx;
  224. u8 rsv[2];
  225. } __packed;
  226. struct wtbl_pn {
  227. __le16 tag;
  228. __le16 len;
  229. u8 pn[6];
  230. u8 rsv[2];
  231. } __packed;
  232. struct wtbl_spe {
  233. __le16 tag;
  234. __le16 len;
  235. u8 spe_idx;
  236. u8 rsv[3];
  237. } __packed;
  238. struct wtbl_raw {
  239. __le16 tag;
  240. __le16 len;
  241. u8 wtbl_idx;
  242. u8 dw;
  243. u8 rsv[2];
  244. __le32 msk;
  245. __le32 val;
  246. } __packed;
  247. #define MT76_CONNAC_WTBL_UPDATE_MAX_SIZE (sizeof(struct wtbl_req_hdr) + \
  248. sizeof(struct wtbl_generic) + \
  249. sizeof(struct wtbl_rx) + \
  250. sizeof(struct wtbl_ht) + \
  251. sizeof(struct wtbl_vht) + \
  252. sizeof(struct wtbl_tx_ps) + \
  253. sizeof(struct wtbl_hdr_trans) +\
  254. sizeof(struct wtbl_ba) + \
  255. sizeof(struct wtbl_bf) + \
  256. sizeof(struct wtbl_smps) + \
  257. sizeof(struct wtbl_pn) + \
  258. sizeof(struct wtbl_spe))
  259. #define MT76_CONNAC_STA_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \
  260. sizeof(struct sta_rec_basic) + \
  261. sizeof(struct sta_rec_ht) + \
  262. sizeof(struct sta_rec_he) + \
  263. sizeof(struct sta_rec_ba) + \
  264. sizeof(struct sta_rec_vht) + \
  265. sizeof(struct sta_rec_uapsd) + \
  266. sizeof(struct sta_rec_amsdu) + \
  267. sizeof(struct tlv) + \
  268. MT76_CONNAC_WTBL_UPDATE_MAX_SIZE)
  269. enum {
  270. STA_REC_BASIC,
  271. STA_REC_RA,
  272. STA_REC_RA_CMM_INFO,
  273. STA_REC_RA_UPDATE,
  274. STA_REC_BF,
  275. STA_REC_AMSDU,
  276. STA_REC_BA,
  277. STA_REC_STATE,
  278. STA_REC_TX_PROC, /* for hdr trans and CSO in CR4 */
  279. STA_REC_HT,
  280. STA_REC_VHT,
  281. STA_REC_APPS,
  282. STA_REC_KEY,
  283. STA_REC_WTBL,
  284. STA_REC_HE,
  285. STA_REC_HW_AMSDU,
  286. STA_REC_WTBL_AADOM,
  287. STA_REC_KEY_V2,
  288. STA_REC_MURU,
  289. STA_REC_MUEDCA,
  290. STA_REC_BFEE,
  291. STA_REC_PHY = 0x15,
  292. STA_REC_MAX_NUM
  293. };
  294. enum {
  295. WTBL_GENERIC,
  296. WTBL_RX,
  297. WTBL_HT,
  298. WTBL_VHT,
  299. WTBL_PEER_PS, /* not used */
  300. WTBL_TX_PS,
  301. WTBL_HDR_TRANS,
  302. WTBL_SEC_KEY,
  303. WTBL_BA,
  304. WTBL_RDG, /* obsoleted */
  305. WTBL_PROTECT, /* not used */
  306. WTBL_CLEAR, /* not used */
  307. WTBL_BF,
  308. WTBL_SMPS,
  309. WTBL_RAW_DATA, /* debug only */
  310. WTBL_PN,
  311. WTBL_SPE,
  312. WTBL_MAX_NUM
  313. };
  314. #define STA_TYPE_STA BIT(0)
  315. #define STA_TYPE_AP BIT(1)
  316. #define STA_TYPE_ADHOC BIT(2)
  317. #define STA_TYPE_WDS BIT(4)
  318. #define STA_TYPE_BC BIT(5)
  319. #define NETWORK_INFRA BIT(16)
  320. #define NETWORK_P2P BIT(17)
  321. #define NETWORK_IBSS BIT(18)
  322. #define NETWORK_WDS BIT(21)
  323. #define SCAN_FUNC_RANDOM_MAC BIT(0)
  324. #define SCAN_FUNC_SPLIT_SCAN BIT(5)
  325. #define CONNECTION_INFRA_STA (STA_TYPE_STA | NETWORK_INFRA)
  326. #define CONNECTION_INFRA_AP (STA_TYPE_AP | NETWORK_INFRA)
  327. #define CONNECTION_P2P_GC (STA_TYPE_STA | NETWORK_P2P)
  328. #define CONNECTION_P2P_GO (STA_TYPE_AP | NETWORK_P2P)
  329. #define CONNECTION_IBSS_ADHOC (STA_TYPE_ADHOC | NETWORK_IBSS)
  330. #define CONNECTION_WDS (STA_TYPE_WDS | NETWORK_WDS)
  331. #define CONNECTION_INFRA_BC (STA_TYPE_BC | NETWORK_INFRA)
  332. #define CONN_STATE_DISCONNECT 0
  333. #define CONN_STATE_CONNECT 1
  334. #define CONN_STATE_PORT_SECURE 2
  335. /* HE MAC */
  336. #define STA_REC_HE_CAP_HTC BIT(0)
  337. #define STA_REC_HE_CAP_BQR BIT(1)
  338. #define STA_REC_HE_CAP_BSR BIT(2)
  339. #define STA_REC_HE_CAP_OM BIT(3)
  340. #define STA_REC_HE_CAP_AMSDU_IN_AMPDU BIT(4)
  341. /* HE PHY */
  342. #define STA_REC_HE_CAP_DUAL_BAND BIT(5)
  343. #define STA_REC_HE_CAP_LDPC BIT(6)
  344. #define STA_REC_HE_CAP_TRIG_CQI_FK BIT(7)
  345. #define STA_REC_HE_CAP_PARTIAL_BW_EXT_RANGE BIT(8)
  346. /* STBC */
  347. #define STA_REC_HE_CAP_LE_EQ_80M_TX_STBC BIT(9)
  348. #define STA_REC_HE_CAP_LE_EQ_80M_RX_STBC BIT(10)
  349. #define STA_REC_HE_CAP_GT_80M_TX_STBC BIT(11)
  350. #define STA_REC_HE_CAP_GT_80M_RX_STBC BIT(12)
  351. /* GI */
  352. #define STA_REC_HE_CAP_SU_PPDU_1LTF_8US_GI BIT(13)
  353. #define STA_REC_HE_CAP_SU_MU_PPDU_4LTF_8US_GI BIT(14)
  354. #define STA_REC_HE_CAP_ER_SU_PPDU_1LTF_8US_GI BIT(15)
  355. #define STA_REC_HE_CAP_ER_SU_PPDU_4LTF_8US_GI BIT(16)
  356. #define STA_REC_HE_CAP_NDP_4LTF_3DOT2MS_GI BIT(17)
  357. /* 242 TONE */
  358. #define STA_REC_HE_CAP_BW20_RU242_SUPPORT BIT(18)
  359. #define STA_REC_HE_CAP_TX_1024QAM_UNDER_RU242 BIT(19)
  360. #define STA_REC_HE_CAP_RX_1024QAM_UNDER_RU242 BIT(20)
  361. #define PHY_MODE_A BIT(0)
  362. #define PHY_MODE_B BIT(1)
  363. #define PHY_MODE_G BIT(2)
  364. #define PHY_MODE_GN BIT(3)
  365. #define PHY_MODE_AN BIT(4)
  366. #define PHY_MODE_AC BIT(5)
  367. #define PHY_MODE_AX_24G BIT(6)
  368. #define PHY_MODE_AX_5G BIT(7)
  369. #define PHY_MODE_AX_6G BIT(8)
  370. #define MODE_CCK BIT(0)
  371. #define MODE_OFDM BIT(1)
  372. #define MODE_HT BIT(2)
  373. #define MODE_VHT BIT(3)
  374. #define MODE_HE BIT(4)
  375. enum {
  376. PHY_TYPE_HR_DSSS_INDEX = 0,
  377. PHY_TYPE_ERP_INDEX,
  378. PHY_TYPE_ERP_P2P_INDEX,
  379. PHY_TYPE_OFDM_INDEX,
  380. PHY_TYPE_HT_INDEX,
  381. PHY_TYPE_VHT_INDEX,
  382. PHY_TYPE_HE_INDEX,
  383. PHY_TYPE_INDEX_NUM
  384. };
  385. #define PHY_TYPE_BIT_HR_DSSS BIT(PHY_TYPE_HR_DSSS_INDEX)
  386. #define PHY_TYPE_BIT_ERP BIT(PHY_TYPE_ERP_INDEX)
  387. #define PHY_TYPE_BIT_OFDM BIT(PHY_TYPE_OFDM_INDEX)
  388. #define PHY_TYPE_BIT_HT BIT(PHY_TYPE_HT_INDEX)
  389. #define PHY_TYPE_BIT_VHT BIT(PHY_TYPE_VHT_INDEX)
  390. #define PHY_TYPE_BIT_HE BIT(PHY_TYPE_HE_INDEX)
  391. #define MT_WTBL_RATE_TX_MODE GENMASK(9, 6)
  392. #define MT_WTBL_RATE_MCS GENMASK(5, 0)
  393. #define MT_WTBL_RATE_NSS GENMASK(12, 10)
  394. #define MT_WTBL_RATE_HE_GI GENMASK(7, 4)
  395. #define MT_WTBL_RATE_GI GENMASK(3, 0)
  396. #define MT_WTBL_W5_CHANGE_BW_RATE GENMASK(7, 5)
  397. #define MT_WTBL_W5_SHORT_GI_20 BIT(8)
  398. #define MT_WTBL_W5_SHORT_GI_40 BIT(9)
  399. #define MT_WTBL_W5_SHORT_GI_80 BIT(10)
  400. #define MT_WTBL_W5_SHORT_GI_160 BIT(11)
  401. #define MT_WTBL_W5_BW_CAP GENMASK(13, 12)
  402. #define MT_WTBL_W5_MPDU_FAIL_COUNT GENMASK(25, 23)
  403. #define MT_WTBL_W5_MPDU_OK_COUNT GENMASK(28, 26)
  404. #define MT_WTBL_W5_RATE_IDX GENMASK(31, 29)
  405. enum {
  406. WTBL_RESET_AND_SET = 1,
  407. WTBL_SET,
  408. WTBL_QUERY,
  409. WTBL_RESET_ALL
  410. };
  411. enum {
  412. MT_BA_TYPE_INVALID,
  413. MT_BA_TYPE_ORIGINATOR,
  414. MT_BA_TYPE_RECIPIENT
  415. };
  416. enum {
  417. RST_BA_MAC_TID_MATCH,
  418. RST_BA_MAC_MATCH,
  419. RST_BA_NO_MATCH
  420. };
  421. enum {
  422. DEV_INFO_ACTIVE,
  423. DEV_INFO_MAX_NUM
  424. };
  425. #define MCU_CMD_ACK BIT(0)
  426. #define MCU_CMD_UNI BIT(1)
  427. #define MCU_CMD_QUERY BIT(2)
  428. #define MCU_CMD_UNI_EXT_ACK (MCU_CMD_ACK | MCU_CMD_UNI | \
  429. MCU_CMD_QUERY)
  430. #define MCU_FW_PREFIX BIT(31)
  431. #define MCU_UNI_PREFIX BIT(30)
  432. #define MCU_CE_PREFIX BIT(29)
  433. #define MCU_QUERY_PREFIX BIT(28)
  434. #define MCU_CMD_MASK ~(MCU_FW_PREFIX | MCU_UNI_PREFIX | \
  435. MCU_CE_PREFIX | MCU_QUERY_PREFIX)
  436. #define MCU_QUERY_MASK BIT(16)
  437. enum {
  438. MCU_EXT_CMD_EFUSE_ACCESS = 0x01,
  439. MCU_EXT_CMD_RF_REG_ACCESS = 0x02,
  440. MCU_EXT_CMD_PM_STATE_CTRL = 0x07,
  441. MCU_EXT_CMD_CHANNEL_SWITCH = 0x08,
  442. MCU_EXT_CMD_SET_TX_POWER_CTRL = 0x11,
  443. MCU_EXT_CMD_FW_LOG_2_HOST = 0x13,
  444. MCU_EXT_CMD_EFUSE_BUFFER_MODE = 0x21,
  445. MCU_EXT_CMD_STA_REC_UPDATE = 0x25,
  446. MCU_EXT_CMD_BSS_INFO_UPDATE = 0x26,
  447. MCU_EXT_CMD_EDCA_UPDATE = 0x27,
  448. MCU_EXT_CMD_DEV_INFO_UPDATE = 0x2A,
  449. MCU_EXT_CMD_GET_TEMP = 0x2c,
  450. MCU_EXT_CMD_WTBL_UPDATE = 0x32,
  451. MCU_EXT_CMD_SET_RDD_CTRL = 0x3a,
  452. MCU_EXT_CMD_ATE_CTRL = 0x3d,
  453. MCU_EXT_CMD_PROTECT_CTRL = 0x3e,
  454. MCU_EXT_CMD_DBDC_CTRL = 0x45,
  455. MCU_EXT_CMD_MAC_INIT_CTRL = 0x46,
  456. MCU_EXT_CMD_RX_HDR_TRANS = 0x47,
  457. MCU_EXT_CMD_MUAR_UPDATE = 0x48,
  458. MCU_EXT_CMD_BCN_OFFLOAD = 0x49,
  459. MCU_EXT_CMD_SET_RX_PATH = 0x4e,
  460. MCU_EXT_CMD_TX_POWER_FEATURE_CTRL = 0x58,
  461. MCU_EXT_CMD_RXDCOC_CAL = 0x59,
  462. MCU_EXT_CMD_TXDPD_CAL = 0x60,
  463. MCU_EXT_CMD_SET_RDD_TH = 0x7c,
  464. MCU_EXT_CMD_SET_RDD_PATTERN = 0x7d,
  465. };
  466. enum {
  467. MCU_UNI_CMD_DEV_INFO_UPDATE = MCU_UNI_PREFIX | 0x01,
  468. MCU_UNI_CMD_BSS_INFO_UPDATE = MCU_UNI_PREFIX | 0x02,
  469. MCU_UNI_CMD_STA_REC_UPDATE = MCU_UNI_PREFIX | 0x03,
  470. MCU_UNI_CMD_SUSPEND = MCU_UNI_PREFIX | 0x05,
  471. MCU_UNI_CMD_OFFLOAD = MCU_UNI_PREFIX | 0x06,
  472. MCU_UNI_CMD_HIF_CTRL = MCU_UNI_PREFIX | 0x07,
  473. };
  474. enum {
  475. MCU_CMD_TARGET_ADDRESS_LEN_REQ = MCU_FW_PREFIX | 0x01,
  476. MCU_CMD_FW_START_REQ = MCU_FW_PREFIX | 0x02,
  477. MCU_CMD_INIT_ACCESS_REG = 0x3,
  478. MCU_CMD_NIC_POWER_CTRL = MCU_FW_PREFIX | 0x4,
  479. MCU_CMD_PATCH_START_REQ = MCU_FW_PREFIX | 0x05,
  480. MCU_CMD_PATCH_FINISH_REQ = MCU_FW_PREFIX | 0x07,
  481. MCU_CMD_PATCH_SEM_CONTROL = MCU_FW_PREFIX | 0x10,
  482. MCU_CMD_EXT_CID = 0xed,
  483. MCU_CMD_FW_SCATTER = MCU_FW_PREFIX | 0xee,
  484. MCU_CMD_RESTART_DL_REQ = MCU_FW_PREFIX | 0xef,
  485. };
  486. /* offload mcu commands */
  487. enum {
  488. MCU_CMD_START_HW_SCAN = MCU_CE_PREFIX | 0x03,
  489. MCU_CMD_SET_PS_PROFILE = MCU_CE_PREFIX | 0x05,
  490. MCU_CMD_SET_CHAN_DOMAIN = MCU_CE_PREFIX | 0x0f,
  491. MCU_CMD_SET_BSS_CONNECTED = MCU_CE_PREFIX | 0x16,
  492. MCU_CMD_SET_BSS_ABORT = MCU_CE_PREFIX | 0x17,
  493. MCU_CMD_CANCEL_HW_SCAN = MCU_CE_PREFIX | 0x1b,
  494. MCU_CMD_SET_ROC = MCU_CE_PREFIX | 0x1d,
  495. MCU_CMD_SET_P2P_OPPPS = MCU_CE_PREFIX | 0x33,
  496. MCU_CMD_SET_RATE_TX_POWER = MCU_CE_PREFIX | 0x5d,
  497. MCU_CMD_SCHED_SCAN_ENABLE = MCU_CE_PREFIX | 0x61,
  498. MCU_CMD_SCHED_SCAN_REQ = MCU_CE_PREFIX | 0x62,
  499. MCU_CMD_REG_WRITE = MCU_CE_PREFIX | 0xc0,
  500. MCU_CMD_REG_READ = MCU_CE_PREFIX | MCU_QUERY_MASK | 0xc0,
  501. MCU_CMD_CHIP_CONFIG = MCU_CE_PREFIX | 0xca,
  502. MCU_CMD_FWLOG_2_HOST = MCU_CE_PREFIX | 0xc5,
  503. MCU_CMD_GET_WTBL = MCU_CE_PREFIX | 0xcd,
  504. MCU_CMD_GET_TXPWR = MCU_CE_PREFIX | 0xd0,
  505. };
  506. enum {
  507. PATCH_SEM_RELEASE,
  508. PATCH_SEM_GET
  509. };
  510. enum {
  511. UNI_BSS_INFO_BASIC = 0,
  512. UNI_BSS_INFO_RLM = 2,
  513. UNI_BSS_INFO_HE_BASIC = 5,
  514. UNI_BSS_INFO_BCN_CONTENT = 7,
  515. UNI_BSS_INFO_QBSS = 15,
  516. UNI_BSS_INFO_UAPSD = 19,
  517. UNI_BSS_INFO_PS = 21,
  518. UNI_BSS_INFO_BCNFT = 22,
  519. };
  520. enum {
  521. UNI_OFFLOAD_OFFLOAD_ARP,
  522. UNI_OFFLOAD_OFFLOAD_ND,
  523. UNI_OFFLOAD_OFFLOAD_GTK_REKEY,
  524. UNI_OFFLOAD_OFFLOAD_BMC_RPY_DETECT,
  525. };
  526. #define UNI_WOW_DETECT_TYPE_MAGIC BIT(0)
  527. #define UNI_WOW_DETECT_TYPE_ANY BIT(1)
  528. #define UNI_WOW_DETECT_TYPE_DISCONNECT BIT(2)
  529. #define UNI_WOW_DETECT_TYPE_GTK_REKEY_FAIL BIT(3)
  530. #define UNI_WOW_DETECT_TYPE_BCN_LOST BIT(4)
  531. #define UNI_WOW_DETECT_TYPE_SCH_SCAN_HIT BIT(5)
  532. #define UNI_WOW_DETECT_TYPE_BITMAP BIT(6)
  533. enum {
  534. UNI_SUSPEND_MODE_SETTING,
  535. UNI_SUSPEND_WOW_CTRL,
  536. UNI_SUSPEND_WOW_GPIO_PARAM,
  537. UNI_SUSPEND_WOW_WAKEUP_PORT,
  538. UNI_SUSPEND_WOW_PATTERN,
  539. };
  540. enum {
  541. WOW_USB = 1,
  542. WOW_PCIE = 2,
  543. WOW_GPIO = 3,
  544. };
  545. struct mt76_connac_bss_basic_tlv {
  546. __le16 tag;
  547. __le16 len;
  548. u8 active;
  549. u8 omac_idx;
  550. u8 hw_bss_idx;
  551. u8 band_idx;
  552. __le32 conn_type;
  553. u8 conn_state;
  554. u8 wmm_idx;
  555. u8 bssid[ETH_ALEN];
  556. __le16 bmc_tx_wlan_idx;
  557. __le16 bcn_interval;
  558. u8 dtim_period;
  559. u8 phymode; /* bit(0): A
  560. * bit(1): B
  561. * bit(2): G
  562. * bit(3): GN
  563. * bit(4): AN
  564. * bit(5): AC
  565. */
  566. __le16 sta_idx;
  567. u8 nonht_basic_phy;
  568. u8 pad[3];
  569. } __packed;
  570. struct mt76_connac_bss_qos_tlv {
  571. __le16 tag;
  572. __le16 len;
  573. u8 qos;
  574. u8 pad[3];
  575. } __packed;
  576. struct mt76_connac_beacon_loss_event {
  577. u8 bss_idx;
  578. u8 reason;
  579. u8 pad[2];
  580. } __packed;
  581. struct mt76_connac_mcu_bss_event {
  582. u8 bss_idx;
  583. u8 is_absent;
  584. u8 free_quota;
  585. u8 pad;
  586. } __packed;
  587. struct mt76_connac_mcu_scan_ssid {
  588. __le32 ssid_len;
  589. u8 ssid[IEEE80211_MAX_SSID_LEN];
  590. } __packed;
  591. struct mt76_connac_mcu_scan_channel {
  592. u8 band; /* 1: 2.4GHz
  593. * 2: 5.0GHz
  594. * Others: Reserved
  595. */
  596. u8 channel_num;
  597. } __packed;
  598. struct mt76_connac_mcu_scan_match {
  599. __le32 rssi_th;
  600. u8 ssid[IEEE80211_MAX_SSID_LEN];
  601. u8 ssid_len;
  602. u8 rsv[3];
  603. } __packed;
  604. struct mt76_connac_hw_scan_req {
  605. u8 seq_num;
  606. u8 bss_idx;
  607. u8 scan_type; /* 0: PASSIVE SCAN
  608. * 1: ACTIVE SCAN
  609. */
  610. u8 ssid_type; /* BIT(0) wildcard SSID
  611. * BIT(1) P2P wildcard SSID
  612. * BIT(2) specified SSID + wildcard SSID
  613. * BIT(2) + ssid_type_ext BIT(0) specified SSID only
  614. */
  615. u8 ssids_num;
  616. u8 probe_req_num; /* Number of probe request for each SSID */
  617. u8 scan_func; /* BIT(0) Enable random MAC scan
  618. * BIT(1) Disable DBDC scan type 1~3.
  619. * BIT(2) Use DBDC scan type 3 (dedicated one RF to scan).
  620. */
  621. u8 version; /* 0: Not support fields after ies.
  622. * 1: Support fields after ies.
  623. */
  624. struct mt76_connac_mcu_scan_ssid ssids[4];
  625. __le16 probe_delay_time;
  626. __le16 channel_dwell_time; /* channel Dwell interval */
  627. __le16 timeout_value;
  628. u8 channel_type; /* 0: Full channels
  629. * 1: Only 2.4GHz channels
  630. * 2: Only 5GHz channels
  631. * 3: P2P social channel only (channel #1, #6 and #11)
  632. * 4: Specified channels
  633. * Others: Reserved
  634. */
  635. u8 channels_num; /* valid when channel_type is 4 */
  636. /* valid when channels_num is set */
  637. struct mt76_connac_mcu_scan_channel channels[32];
  638. __le16 ies_len;
  639. u8 ies[MT76_CONNAC_SCAN_IE_LEN];
  640. /* following fields are valid if version > 0 */
  641. u8 ext_channels_num;
  642. u8 ext_ssids_num;
  643. __le16 channel_min_dwell_time;
  644. struct mt76_connac_mcu_scan_channel ext_channels[32];
  645. struct mt76_connac_mcu_scan_ssid ext_ssids[6];
  646. u8 bssid[ETH_ALEN];
  647. u8 random_mac[ETH_ALEN]; /* valid when BIT(1) in scan_func is set. */
  648. u8 pad[63];
  649. u8 ssid_type_ext;
  650. } __packed;
  651. #define MT76_CONNAC_SCAN_DONE_EVENT_MAX_CHANNEL_NUM 64
  652. struct mt76_connac_hw_scan_done {
  653. u8 seq_num;
  654. u8 sparse_channel_num;
  655. struct mt76_connac_mcu_scan_channel sparse_channel;
  656. u8 complete_channel_num;
  657. u8 current_state;
  658. u8 version;
  659. u8 pad;
  660. __le32 beacon_scan_num;
  661. u8 pno_enabled;
  662. u8 pad2[3];
  663. u8 sparse_channel_valid_num;
  664. u8 pad3[3];
  665. u8 channel_num[MT76_CONNAC_SCAN_DONE_EVENT_MAX_CHANNEL_NUM];
  666. /* idle format for channel_idle_time
  667. * 0: first bytes: idle time(ms) 2nd byte: dwell time(ms)
  668. * 1: first bytes: idle time(8ms) 2nd byte: dwell time(8ms)
  669. * 2: dwell time (16us)
  670. */
  671. __le16 channel_idle_time[MT76_CONNAC_SCAN_DONE_EVENT_MAX_CHANNEL_NUM];
  672. /* beacon and probe response count */
  673. u8 beacon_probe_num[MT76_CONNAC_SCAN_DONE_EVENT_MAX_CHANNEL_NUM];
  674. u8 mdrdy_count[MT76_CONNAC_SCAN_DONE_EVENT_MAX_CHANNEL_NUM];
  675. __le32 beacon_2g_num;
  676. __le32 beacon_5g_num;
  677. } __packed;
  678. struct mt76_connac_sched_scan_req {
  679. u8 version;
  680. u8 seq_num;
  681. u8 stop_on_match;
  682. u8 ssids_num;
  683. u8 match_num;
  684. u8 pad;
  685. __le16 ie_len;
  686. struct mt76_connac_mcu_scan_ssid ssids[MT76_CONNAC_MAX_SCHED_SCAN_SSID];
  687. struct mt76_connac_mcu_scan_match match[MT76_CONNAC_MAX_SCAN_MATCH];
  688. u8 channel_type;
  689. u8 channels_num;
  690. u8 intervals_num;
  691. u8 scan_func; /* MT7663: BIT(0) eable random mac address */
  692. struct mt76_connac_mcu_scan_channel channels[64];
  693. __le16 intervals[MT76_CONNAC_MAX_SCHED_SCAN_INTERVAL];
  694. union {
  695. struct {
  696. u8 random_mac[ETH_ALEN];
  697. u8 pad2[58];
  698. } mt7663;
  699. struct {
  700. u8 bss_idx;
  701. u8 pad2[63];
  702. } mt7921;
  703. };
  704. } __packed;
  705. struct mt76_connac_sched_scan_done {
  706. u8 seq_num;
  707. u8 status; /* 0: ssid found */
  708. __le16 pad;
  709. } __packed;
  710. struct bss_info_uni_he {
  711. __le16 tag;
  712. __le16 len;
  713. __le16 he_rts_thres;
  714. u8 he_pe_duration;
  715. u8 su_disable;
  716. __le16 max_nss_mcs[CMD_HE_MCS_BW_NUM];
  717. u8 rsv[2];
  718. } __packed;
  719. struct mt76_connac_gtk_rekey_tlv {
  720. __le16 tag;
  721. __le16 len;
  722. u8 kek[NL80211_KEK_LEN];
  723. u8 kck[NL80211_KCK_LEN];
  724. u8 replay_ctr[NL80211_REPLAY_CTR_LEN];
  725. u8 rekey_mode; /* 0: rekey offload enable
  726. * 1: rekey offload disable
  727. * 2: rekey update
  728. */
  729. u8 keyid;
  730. u8 pad[2];
  731. __le32 proto; /* WPA-RSN-WAPI-OPSN */
  732. __le32 pairwise_cipher;
  733. __le32 group_cipher;
  734. __le32 key_mgmt; /* NONE-PSK-IEEE802.1X */
  735. __le32 mgmt_group_cipher;
  736. u8 option; /* 1: rekey data update without enabling offload */
  737. u8 reserverd[3];
  738. } __packed;
  739. #define MT76_CONNAC_WOW_MASK_MAX_LEN 16
  740. #define MT76_CONNAC_WOW_PATTEN_MAX_LEN 128
  741. struct mt76_connac_wow_pattern_tlv {
  742. __le16 tag;
  743. __le16 len;
  744. u8 index; /* pattern index */
  745. u8 enable; /* 0: disable
  746. * 1: enable
  747. */
  748. u8 data_len; /* pattern length */
  749. u8 pad;
  750. u8 mask[MT76_CONNAC_WOW_MASK_MAX_LEN];
  751. u8 pattern[MT76_CONNAC_WOW_PATTEN_MAX_LEN];
  752. u8 rsv[4];
  753. } __packed;
  754. struct mt76_connac_wow_ctrl_tlv {
  755. __le16 tag;
  756. __le16 len;
  757. u8 cmd; /* 0x1: PM_WOWLAN_REQ_START
  758. * 0x2: PM_WOWLAN_REQ_STOP
  759. * 0x3: PM_WOWLAN_PARAM_CLEAR
  760. */
  761. u8 trigger; /* 0: NONE
  762. * BIT(0): NL80211_WOWLAN_TRIG_MAGIC_PKT
  763. * BIT(1): NL80211_WOWLAN_TRIG_ANY
  764. * BIT(2): NL80211_WOWLAN_TRIG_DISCONNECT
  765. * BIT(3): NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE
  766. * BIT(4): BEACON_LOST
  767. * BIT(5): NL80211_WOWLAN_TRIG_NET_DETECT
  768. */
  769. u8 wakeup_hif; /* 0x0: HIF_SDIO
  770. * 0x1: HIF_USB
  771. * 0x2: HIF_PCIE
  772. * 0x3: HIF_GPIO
  773. */
  774. u8 pad;
  775. u8 rsv[4];
  776. } __packed;
  777. struct mt76_connac_wow_gpio_param_tlv {
  778. __le16 tag;
  779. __le16 len;
  780. u8 gpio_pin;
  781. u8 trigger_lvl;
  782. u8 pad[2];
  783. __le32 gpio_interval;
  784. u8 rsv[4];
  785. } __packed;
  786. struct mt76_connac_arpns_tlv {
  787. __le16 tag;
  788. __le16 len;
  789. u8 mode;
  790. u8 ips_num;
  791. u8 option;
  792. u8 pad[1];
  793. } __packed;
  794. struct mt76_connac_suspend_tlv {
  795. __le16 tag;
  796. __le16 len;
  797. u8 enable; /* 0: suspend mode disabled
  798. * 1: suspend mode enabled
  799. */
  800. u8 mdtim; /* LP parameter */
  801. u8 wow_suspend; /* 0: update by origin policy
  802. * 1: update by wow dtim
  803. */
  804. u8 pad[5];
  805. } __packed;
  806. struct mt76_sta_cmd_info {
  807. struct ieee80211_sta *sta;
  808. struct mt76_wcid *wcid;
  809. struct ieee80211_vif *vif;
  810. bool enable;
  811. int cmd;
  812. u8 rcpi;
  813. };
  814. #define MT_SKU_POWER_LIMIT 161
  815. struct mt76_connac_sku_tlv {
  816. u8 channel;
  817. s8 pwr_limit[MT_SKU_POWER_LIMIT];
  818. } __packed;
  819. struct mt76_connac_tx_power_limit_tlv {
  820. /* DW0 - common info*/
  821. u8 ver;
  822. u8 pad0;
  823. __le16 len;
  824. /* DW1 - cmd hint */
  825. u8 n_chan; /* # channel */
  826. u8 band; /* 2.4GHz - 5GHz */
  827. u8 last_msg;
  828. u8 pad1;
  829. /* DW3 */
  830. u8 alpha2[4]; /* regulatory_request.alpha2 */
  831. u8 pad2[32];
  832. } __packed;
  833. struct mt76_connac_config {
  834. __le16 id;
  835. u8 type;
  836. u8 resp_type;
  837. __le16 data_size;
  838. __le16 resv;
  839. u8 data[320];
  840. } __packed;
  841. #define to_wcid_lo(id) FIELD_GET(GENMASK(7, 0), (u16)id)
  842. #define to_wcid_hi(id) FIELD_GET(GENMASK(9, 8), (u16)id)
  843. static inline void
  844. mt76_connac_mcu_get_wlan_idx(struct mt76_dev *dev, struct mt76_wcid *wcid,
  845. u8 *wlan_idx_lo, u8 *wlan_idx_hi)
  846. {
  847. *wlan_idx_hi = 0;
  848. if (is_mt7921(dev)) {
  849. *wlan_idx_lo = wcid ? to_wcid_lo(wcid->idx) : 0;
  850. *wlan_idx_hi = wcid ? to_wcid_hi(wcid->idx) : 0;
  851. } else {
  852. *wlan_idx_lo = wcid ? wcid->idx : 0;
  853. }
  854. }
  855. struct sk_buff *
  856. mt76_connac_mcu_alloc_sta_req(struct mt76_dev *dev, struct mt76_vif *mvif,
  857. struct mt76_wcid *wcid);
  858. struct wtbl_req_hdr *
  859. mt76_connac_mcu_alloc_wtbl_req(struct mt76_dev *dev, struct mt76_wcid *wcid,
  860. int cmd, void *sta_wtbl, struct sk_buff **skb);
  861. struct tlv *mt76_connac_mcu_add_nested_tlv(struct sk_buff *skb, int tag,
  862. int len, void *sta_ntlv,
  863. void *sta_wtbl);
  864. static inline struct tlv *
  865. mt76_connac_mcu_add_tlv(struct sk_buff *skb, int tag, int len)
  866. {
  867. return mt76_connac_mcu_add_nested_tlv(skb, tag, len, skb->data, NULL);
  868. }
  869. int mt76_connac_mcu_set_channel_domain(struct mt76_phy *phy);
  870. int mt76_connac_mcu_set_vif_ps(struct mt76_dev *dev, struct ieee80211_vif *vif);
  871. void mt76_connac_mcu_sta_basic_tlv(struct sk_buff *skb,
  872. struct ieee80211_vif *vif,
  873. struct ieee80211_sta *sta, bool enable);
  874. void mt76_connac_mcu_wtbl_generic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
  875. struct ieee80211_vif *vif,
  876. struct ieee80211_sta *sta, void *sta_wtbl,
  877. void *wtbl_tlv);
  878. void mt76_connac_mcu_wtbl_hdr_trans_tlv(struct sk_buff *skb,
  879. struct ieee80211_vif *vif,
  880. struct mt76_wcid *wcid,
  881. void *sta_wtbl, void *wtbl_tlv);
  882. int mt76_connac_mcu_sta_update_hdr_trans(struct mt76_dev *dev,
  883. struct ieee80211_vif *vif,
  884. struct mt76_wcid *wcid, int cmd);
  885. void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
  886. struct ieee80211_sta *sta,
  887. struct ieee80211_vif *vif,
  888. u8 rcpi);
  889. void mt76_connac_mcu_wtbl_ht_tlv(struct mt76_dev *dev, struct sk_buff *skb,
  890. struct ieee80211_sta *sta, void *sta_wtbl,
  891. void *wtbl_tlv);
  892. void mt76_connac_mcu_wtbl_ba_tlv(struct mt76_dev *dev, struct sk_buff *skb,
  893. struct ieee80211_ampdu_params *params,
  894. bool enable, bool tx, void *sta_wtbl,
  895. void *wtbl_tlv);
  896. void mt76_connac_mcu_sta_ba_tlv(struct sk_buff *skb,
  897. struct ieee80211_ampdu_params *params,
  898. bool enable, bool tx);
  899. int mt76_connac_mcu_uni_add_dev(struct mt76_phy *phy,
  900. struct ieee80211_vif *vif,
  901. struct mt76_wcid *wcid,
  902. bool enable);
  903. int mt76_connac_mcu_sta_ba(struct mt76_dev *dev, struct mt76_vif *mvif,
  904. struct ieee80211_ampdu_params *params,
  905. bool enable, bool tx);
  906. int mt76_connac_mcu_uni_add_bss(struct mt76_phy *phy,
  907. struct ieee80211_vif *vif,
  908. struct mt76_wcid *wcid,
  909. bool enable);
  910. int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
  911. struct mt76_sta_cmd_info *info);
  912. void mt76_connac_mcu_beacon_loss_iter(void *priv, u8 *mac,
  913. struct ieee80211_vif *vif);
  914. int mt76_connac_mcu_set_rts_thresh(struct mt76_dev *dev, u32 val, u8 band);
  915. int mt76_connac_mcu_set_mac_enable(struct mt76_dev *dev, int band, bool enable,
  916. bool hdr_trans);
  917. int mt76_connac_mcu_init_download(struct mt76_dev *dev, u32 addr, u32 len,
  918. u32 mode);
  919. int mt76_connac_mcu_start_patch(struct mt76_dev *dev);
  920. int mt76_connac_mcu_patch_sem_ctrl(struct mt76_dev *dev, bool get);
  921. int mt76_connac_mcu_start_firmware(struct mt76_dev *dev, u32 addr, u32 option);
  922. int mt76_connac_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
  923. struct ieee80211_scan_request *scan_req);
  924. int mt76_connac_mcu_cancel_hw_scan(struct mt76_phy *phy,
  925. struct ieee80211_vif *vif);
  926. int mt76_connac_mcu_sched_scan_req(struct mt76_phy *phy,
  927. struct ieee80211_vif *vif,
  928. struct cfg80211_sched_scan_request *sreq);
  929. int mt76_connac_mcu_sched_scan_enable(struct mt76_phy *phy,
  930. struct ieee80211_vif *vif,
  931. bool enable);
  932. int mt76_connac_mcu_update_arp_filter(struct mt76_dev *dev,
  933. struct mt76_vif *vif,
  934. struct ieee80211_bss_conf *info);
  935. int mt76_connac_mcu_update_gtk_rekey(struct ieee80211_hw *hw,
  936. struct ieee80211_vif *vif,
  937. struct cfg80211_gtk_rekey_data *key);
  938. int mt76_connac_mcu_set_hif_suspend(struct mt76_dev *dev, bool suspend);
  939. void mt76_connac_mcu_set_suspend_iter(void *priv, u8 *mac,
  940. struct ieee80211_vif *vif);
  941. int mt76_connac_sta_state_dp(struct mt76_dev *dev,
  942. enum ieee80211_sta_state old_state,
  943. enum ieee80211_sta_state new_state);
  944. int mt76_connac_mcu_chip_config(struct mt76_dev *dev);
  945. int mt76_connac_mcu_set_deep_sleep(struct mt76_dev *dev, bool enable);
  946. void mt76_connac_mcu_coredump_event(struct mt76_dev *dev, struct sk_buff *skb,
  947. struct mt76_connac_coredump *coredump);
  948. int mt76_connac_mcu_set_rate_txpower(struct mt76_phy *phy);
  949. #endif /* __MT76_CONNAC_MCU_H */