txrx.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
  2. /* Copyright(c) 2020 Realtek Corporation
  3. */
  4. #ifndef __RTW89_TXRX_H__
  5. #define __RTW89_TXRX_H__
  6. #include "debug.h"
  7. #define DATA_RATE_MODE_CTRL_MASK GENMASK(8, 7)
  8. #define DATA_RATE_MODE_CTRL_MASK_V1 GENMASK(10, 8)
  9. #define DATA_RATE_NOT_HT_IDX_MASK GENMASK(3, 0)
  10. #define DATA_RATE_MODE_NON_HT 0x0
  11. #define DATA_RATE_HT_IDX_MASK GENMASK(4, 0)
  12. #define DATA_RATE_HT_IDX_MASK_V1 GENMASK(4, 0)
  13. #define DATA_RATE_MODE_HT 0x1
  14. #define DATA_RATE_VHT_HE_NSS_MASK GENMASK(6, 4)
  15. #define DATA_RATE_VHT_HE_IDX_MASK GENMASK(3, 0)
  16. #define DATA_RATE_NSS_MASK_V1 GENMASK(7, 5)
  17. #define DATA_RATE_MCS_MASK_V1 GENMASK(4, 0)
  18. #define DATA_RATE_MODE_VHT 0x2
  19. #define DATA_RATE_MODE_HE 0x3
  20. #define DATA_RATE_MODE_EHT 0x4
  21. static inline u8 rtw89_get_data_rate_mode(struct rtw89_dev *rtwdev, u16 hw_rate)
  22. {
  23. if (rtwdev->chip->chip_gen == RTW89_CHIP_BE)
  24. return u16_get_bits(hw_rate, DATA_RATE_MODE_CTRL_MASK_V1);
  25. return u16_get_bits(hw_rate, DATA_RATE_MODE_CTRL_MASK);
  26. }
  27. static inline u8 rtw89_get_data_not_ht_idx(struct rtw89_dev *rtwdev, u16 hw_rate)
  28. {
  29. return u16_get_bits(hw_rate, DATA_RATE_NOT_HT_IDX_MASK);
  30. }
  31. static inline u8 rtw89_get_data_ht_mcs(struct rtw89_dev *rtwdev, u16 hw_rate)
  32. {
  33. if (rtwdev->chip->chip_gen == RTW89_CHIP_BE)
  34. return u16_get_bits(hw_rate, DATA_RATE_HT_IDX_MASK_V1);
  35. return u16_get_bits(hw_rate, DATA_RATE_HT_IDX_MASK);
  36. }
  37. static inline u8 rtw89_get_data_mcs(struct rtw89_dev *rtwdev, u16 hw_rate)
  38. {
  39. if (rtwdev->chip->chip_gen == RTW89_CHIP_BE)
  40. return u16_get_bits(hw_rate, DATA_RATE_MCS_MASK_V1);
  41. return u16_get_bits(hw_rate, DATA_RATE_VHT_HE_IDX_MASK);
  42. }
  43. static inline u8 rtw89_get_data_nss(struct rtw89_dev *rtwdev, u16 hw_rate)
  44. {
  45. if (rtwdev->chip->chip_gen == RTW89_CHIP_BE)
  46. return u16_get_bits(hw_rate, DATA_RATE_NSS_MASK_V1);
  47. return u16_get_bits(hw_rate, DATA_RATE_VHT_HE_NSS_MASK);
  48. }
  49. /* TX WD BODY DWORD 0 */
  50. #define RTW89_TXWD_BODY0_WP_OFFSET GENMASK(31, 24)
  51. #define RTW89_TXWD_BODY0_WP_OFFSET_V1 GENMASK(28, 24)
  52. #define RTW89_TXWD_BODY0_MORE_DATA BIT(23)
  53. #define RTW89_TXWD_BODY0_WD_INFO_EN BIT(22)
  54. #define RTW89_TXWD_BODY0_FW_DL BIT(20)
  55. #define RTW89_TXWD_BODY0_CHANNEL_DMA GENMASK(19, 16)
  56. #define RTW89_TXWD_BODY0_HDR_LLC_LEN GENMASK(15, 11)
  57. #define RTW89_TXWD_BODY0_WD_PAGE BIT(7)
  58. #define RTW89_TXWD_BODY0_HW_AMSDU BIT(5)
  59. #define RTW89_TXWD_BODY0_HW_SSN_SEL GENMASK(3, 2)
  60. #define RTW89_TXWD_BODY0_HW_SSN_MODE GENMASK(1, 0)
  61. /* TX WD BODY DWORD 1 */
  62. #define RTW89_TXWD_BODY1_ADDR_INFO_NUM GENMASK(31, 26)
  63. #define RTW89_TXWD_BODY1_PAYLOAD_ID GENMASK(31, 16)
  64. #define RTW89_TXWD_BODY1_SEC_KEYID GENMASK(5, 4)
  65. #define RTW89_TXWD_BODY1_SEC_TYPE GENMASK(3, 0)
  66. /* TX WD BODY DWORD 2 */
  67. #define RTW89_TXWD_BODY2_MACID GENMASK(30, 24)
  68. #define RTW89_TXWD_BODY2_TID_INDICATE BIT(23)
  69. #define RTW89_TXWD_BODY2_QSEL GENMASK(22, 17)
  70. #define RTW89_TXWD_BODY2_TXPKT_SIZE GENMASK(13, 0)
  71. /* TX WD BODY DWORD 3 */
  72. #define RTW89_TXWD_BODY3_BK BIT(13)
  73. #define RTW89_TXWD_BODY3_AGG_EN BIT(12)
  74. #define RTW89_TXWD_BODY3_SW_SEQ GENMASK(11, 0)
  75. /* TX WD BODY DWORD 4 */
  76. #define RTW89_TXWD_BODY4_SEC_IV_L1 GENMASK(31, 24)
  77. #define RTW89_TXWD_BODY4_SEC_IV_L0 GENMASK(23, 16)
  78. /* TX WD BODY DWORD 5 */
  79. #define RTW89_TXWD_BODY5_SEC_IV_H5 GENMASK(31, 24)
  80. #define RTW89_TXWD_BODY5_SEC_IV_H4 GENMASK(23, 16)
  81. #define RTW89_TXWD_BODY5_SEC_IV_H3 GENMASK(15, 8)
  82. #define RTW89_TXWD_BODY5_SEC_IV_H2 GENMASK(7, 0)
  83. /* TX WD BODY DWORD 6 (V1) */
  84. /* TX WD BODY DWORD 7 (V1) */
  85. #define RTW89_TXWD_BODY7_USE_RATE_V1 BIT(31)
  86. #define RTW89_TXWD_BODY7_DATA_BW GENMASK(29, 28)
  87. #define RTW89_TXWD_BODY7_GI_LTF GENMASK(27, 25)
  88. #define RTW89_TXWD_BODY7_DATA_RATE GENMASK(24, 16)
  89. /* TX WD INFO DWORD 0 */
  90. #define RTW89_TXWD_INFO0_USE_RATE BIT(30)
  91. #define RTW89_TXWD_INFO0_DATA_BW GENMASK(29, 28)
  92. #define RTW89_TXWD_INFO0_GI_LTF GENMASK(27, 25)
  93. #define RTW89_TXWD_INFO0_DATA_RATE GENMASK(24, 16)
  94. #define RTW89_TXWD_INFO0_DATA_ER BIT(15)
  95. #define RTW89_TXWD_INFO0_DISDATAFB BIT(10)
  96. #define RTW89_TXWD_INFO0_DATA_BW_ER BIT(8)
  97. #define RTW89_TXWD_INFO0_MULTIPORT_ID GENMASK(6, 4)
  98. /* TX WD INFO DWORD 1 */
  99. #define RTW89_TXWD_INFO1_DATA_RTY_LOWEST_RATE GENMASK(24, 16)
  100. #define RTW89_TXWD_INFO1_A_CTRL_BSR BIT(14)
  101. #define RTW89_TXWD_INFO1_MAX_AGGNUM GENMASK(7, 0)
  102. /* TX WD INFO DWORD 2 */
  103. #define RTW89_TXWD_INFO2_AMPDU_DENSITY GENMASK(20, 18)
  104. #define RTW89_TXWD_INFO2_SEC_TYPE GENMASK(12, 9)
  105. #define RTW89_TXWD_INFO2_SEC_HW_ENC BIT(8)
  106. #define RTW89_TXWD_INFO2_FORCE_KEY_EN BIT(8)
  107. #define RTW89_TXWD_INFO2_SEC_CAM_IDX GENMASK(7, 0)
  108. /* TX WD INFO DWORD 3 */
  109. /* TX WD INFO DWORD 4 */
  110. #define RTW89_TXWD_INFO4_RTS_EN BIT(27)
  111. #define RTW89_TXWD_INFO4_HW_RTS_EN BIT(31)
  112. /* TX WD INFO DWORD 5 */
  113. /* TX WD BODY DWORD 0 */
  114. #define BE_TXD_BODY0_EN_HWSEQ_MODE GENMASK(1, 0)
  115. #define BE_TXD_BODY0_HW_SSN_SEL GENMASK(4, 2)
  116. #define BE_TXD_BODY0_HWAMSDU BIT(5)
  117. #define BE_TXD_BODY0_HW_SEC_IV BIT(6)
  118. #define BE_TXD_BODY0_WD_PAGE BIT(7)
  119. #define BE_TXD_BODY0_CHK_EN BIT(8)
  120. #define BE_TXD_BODY0_WP_INT BIT(9)
  121. #define BE_TXD_BODY0_STF_MODE BIT(10)
  122. #define BE_TXD_BODY0_HDR_LLC_LEN GENMASK(15, 11)
  123. #define BE_TXD_BODY0_CH_DMA GENMASK(19, 16)
  124. #define BE_TXD_BODY0_SMH_EN BIT(20)
  125. #define BE_TXD_BODY0_PKT_OFFSET BIT(21)
  126. #define BE_TXD_BODY0_WDINFO_EN BIT(22)
  127. #define BE_TXD_BODY0_MOREDATA BIT(23)
  128. #define BE_TXD_BODY0_WP_OFFSET_V1 GENMASK(27, 24)
  129. #define BE_TXD_BODY0_AZ_FTM_SEC_V1 BIT(28)
  130. #define BE_TXD_BODY0_WD_SOURCE GENMASK(30, 29)
  131. #define BE_TXD_BODY0_HCI_SEQNUM_MODE BIT(31)
  132. /* TX WD BODY DWORD 1 */
  133. #define BE_TXD_BODY1_DMA_TXAGG_NUM GENMASK(6, 0)
  134. #define BE_TXD_BODY1_REUSE_NUM GENMASK(11, 7)
  135. #define BE_TXD_BODY1_SEC_TYPE GENMASK(15, 12)
  136. #define BE_TXD_BODY1_SEC_KEYID GENMASK(17, 16)
  137. #define BE_TXD_BODY1_SW_SEC_IV BIT(18)
  138. #define BE_TXD_BODY1_REUSE_SIZE GENMASK(23, 20)
  139. #define BE_TXD_BODY1_REUSE_START_OFFSET GENMASK(25, 24)
  140. #define BE_TXD_BODY1_ADDR_INFO_NUM GENMASK(31, 26)
  141. /* TX WD BODY DWORD 2 */
  142. #define BE_TXD_BODY2_TXPKTSIZE GENMASK(13, 0)
  143. #define BE_TXD_BODY2_AGG_EN BIT(14)
  144. #define BE_TXD_BODY2_BK BIT(15)
  145. #define BE_TXD_BODY2_MACID_EXTEND BIT(16)
  146. #define BE_TXD_BODY2_QSEL GENMASK(22, 17)
  147. #define BE_TXD_BODY2_TID_IND BIT(23)
  148. #define BE_TXD_BODY2_MACID GENMASK(31, 24)
  149. /* TX WD BODY DWORD 3 */
  150. #define BE_TXD_BODY3_WIFI_SEQ GENMASK(11, 0)
  151. #define BE_TXD_BODY3_MLO_FLAG BIT(12)
  152. #define BE_TXD_BODY3_IS_MLD_SW_EN BIT(13)
  153. #define BE_TXD_BODY3_TRY_RATE BIT(14)
  154. #define BE_TXD_BODY3_RELINK_FLAG_V1 BIT(15)
  155. #define BE_TXD_BODY3_BAND0_SU_TC_V1 GENMASK(21, 16)
  156. #define BE_TXD_BODY3_TOTAL_TC GENMASK(27, 22)
  157. #define BE_TXD_BODY3_RU_RTY BIT(28)
  158. #define BE_TXD_BODY3_MU_PRI_RTY BIT(29)
  159. #define BE_TXD_BODY3_MU_2ND_RTY BIT(30)
  160. #define BE_TXD_BODY3_BAND1_SU_RTY_V1 BIT(31)
  161. /* TX WD BODY DWORD 4 */
  162. #define BE_TXD_BODY4_TXDESC_CHECKSUM GENMASK(15, 0)
  163. #define BE_TXD_BODY4_SEC_IV_L0 GENMASK(23, 16)
  164. #define BE_TXD_BODY4_SEC_IV_L1 GENMASK(31, 24)
  165. /* TX WD BODY DWORD 5 */
  166. #define BE_TXD_BODY5_SEC_IV_H2 GENMASK(7, 0)
  167. #define BE_TXD_BODY5_SEC_IV_H3 GENMASK(15, 8)
  168. #define BE_TXD_BODY5_SEC_IV_H4 GENMASK(23, 16)
  169. #define BE_TXD_BODY5_SEC_IV_H5 GENMASK(31, 24)
  170. /* TX WD BODY DWORD 6 */
  171. #define BE_TXD_BODY6_MU_TC GENMASK(4, 0)
  172. #define BE_TXD_BODY6_RU_TC GENMASK(9, 5)
  173. #define BE_TXD_BODY6_PS160 BIT(10)
  174. #define BE_TXD_BODY6_BMC BIT(11)
  175. #define BE_TXD_BODY6_NO_ACK BIT(12)
  176. #define BE_TXD_BODY6_UPD_WLAN_HDR BIT(13)
  177. #define BE_TXD_BODY6_A4_HDR BIT(14)
  178. #define BE_TXD_BODY6_EOSP_BIT BIT(15)
  179. #define BE_TXD_BODY6_S_IDX GENMASK(23, 16)
  180. #define BE_TXD_BODY6_RU_POS GENMASK(31, 24)
  181. /* TX WD BODY DWORD 7 */
  182. #define BE_TXD_BODY7_RTS_TC GENMASK(5, 0)
  183. #define BE_TXD_BODY7_MSDU_NUM GENMASK(9, 6)
  184. #define BE_TXD_BODY7_DATA_ER BIT(10)
  185. #define BE_TXD_BODY7_DATA_BW_ER BIT(11)
  186. #define BE_TXD_BODY7_DATA_DCM BIT(12)
  187. #define BE_TXD_BODY7_GI_LTF GENMASK(15, 13)
  188. #define BE_TXD_BODY7_DATARATE GENMASK(27, 16)
  189. #define BE_TXD_BODY7_DATA_BW GENMASK(30, 28)
  190. #define BE_TXD_BODY7_USERATE_SEL BIT(31)
  191. /* TX WD INFO DWORD 0 */
  192. #define BE_TXD_INFO0_MBSSID GENMASK(3, 0)
  193. #define BE_TXD_INFO0_MULTIPORT_ID GENMASK(6, 4)
  194. #define BE_TXD_INFO0_DISRTSFB BIT(9)
  195. #define BE_TXD_INFO0_DISDATAFB BIT(10)
  196. #define BE_TXD_INFO0_DATA_LDPC BIT(11)
  197. #define BE_TXD_INFO0_DATA_STBC BIT(12)
  198. #define BE_TXD_INFO0_DATA_TXCNT_LMT GENMASK(21, 16)
  199. #define BE_TXD_INFO0_DATA_TXCNT_LMT_SEL BIT(22)
  200. #define BE_TXD_INFO0_RESP_PHYSTS_CSI_EN_V1 BIT(23)
  201. #define BE_TXD_INFO0_RLS_TO_CPUIO BIT(30)
  202. #define BE_TXD_INFO0_ACK_CH_INFO BIT(31)
  203. /* TX WD INFO DWORD 1 */
  204. #define BE_TXD_INFO1_MAX_AGG_NUM GENMASK(7, 0)
  205. #define BE_TXD_INFO1_BCN_SRCH_SEQ GENMASK(9, 8)
  206. #define BE_TXD_INFO1_NAVUSEHDR BIT(10)
  207. #define BE_TXD_INFO1_A_CTRL_BQR BIT(12)
  208. #define BE_TXD_INFO1_A_CTRL_BSR BIT(14)
  209. #define BE_TXD_INFO1_A_CTRL_CAS BIT(15)
  210. #define BE_TXD_INFO1_DATA_RTY_LOWEST_RATE GENMASK(27, 16)
  211. #define BE_TXD_INFO1_SW_DEFINE GENMASK(31, 28)
  212. /* TX WD INFO DWORD 2 */
  213. #define BE_TXD_INFO2_SEC_CAM_IDX GENMASK(7, 0)
  214. #define BE_TXD_INFO2_FORCE_KEY_EN BIT(8)
  215. #define BE_TXD_INFO2_LIFETIME_SEL GENMASK(15, 13)
  216. #define BE_TXD_INFO2_FORCE_TXOP BIT(17)
  217. #define BE_TXD_INFO2_AMPDU_DENSITY GENMASK(20, 18)
  218. #define BE_TXD_INFO2_LSIG_TXOP_EN BIT(21)
  219. #define BE_TXD_INFO2_OBW_CTS2SELF_DUP_TYPE GENMASK(29, 26)
  220. #define BE_TXD_INFO2_SPE_RPT_V1 BIT(30)
  221. #define BE_TXD_INFO2_SIFS_TX_V1 BIT(31)
  222. /* TX WD INFO DWORD 3 */
  223. #define BE_TXD_INFO3_SPE_PKT GENMASK(3, 0)
  224. #define BE_TXD_INFO3_SPE_PKT_TYPE GENMASK(7, 4)
  225. #define BE_TXD_INFO3_CQI_SND BIT(8)
  226. #define BE_TXD_INFO3_RTT_EN BIT(9)
  227. #define BE_TXD_INFO3_HT_DATA_SND_V1 BIT(10)
  228. #define BE_TXD_INFO3_BT_NULL BIT(11)
  229. #define BE_TXD_INFO3_TRI_FRAME BIT(12)
  230. #define BE_TXD_INFO3_NULL_0 BIT(13)
  231. #define BE_TXD_INFO3_NULL_1 BIT(14)
  232. #define BE_TXD_INFO3_RAW BIT(15)
  233. #define BE_TXD_INFO3_GROUP_BIT_IE_OFFSET GENMASK(23, 16)
  234. #define BE_TXD_INFO3_SIGNALING_TA_PKT_EN BIT(25)
  235. #define BE_TXD_INFO3_BCNPKT_TSF_CTRL BIT(26)
  236. #define BE_TXD_INFO3_SIGNALING_TA_PKT_SC GENMASK(30, 27)
  237. #define BE_TXD_INFO3_FORCE_BSS_CLR BIT(31)
  238. /* TX WD INFO DWORD 4 */
  239. #define BE_TXD_INFO4_PUNCTURE_PATTERN GENMASK(15, 0)
  240. #define BE_TXD_INFO4_PUNC_MODE GENMASK(17, 16)
  241. #define BE_TXD_INFO4_SW_TX_OK_0 BIT(18)
  242. #define BE_TXD_INFO4_SW_TX_OK_1 BIT(19)
  243. #define BE_TXD_INFO4_SW_TX_PWR_DBM GENMASK(26, 23)
  244. #define BE_TXD_INFO4_RTS_EN BIT(27)
  245. #define BE_TXD_INFO4_CTS2SELF BIT(28)
  246. #define BE_TXD_INFO4_CCA_RTS GENMASK(30, 29)
  247. #define BE_TXD_INFO4_HW_RTS_EN BIT(31)
  248. /* TX WD INFO DWORD 5 */
  249. #define BE_TXD_INFO5_SR_RATE_V1 GENMASK(4, 0)
  250. #define BE_TXD_INFO5_SR_EN_V1 BIT(5)
  251. #define BE_TXD_INFO5_NDPA_DURATION GENMASK(31, 16)
  252. /* TX WD INFO DWORD 6 */
  253. #define BE_TXD_INFO6_UL_APEP_LEN GENMASK(11, 0)
  254. #define BE_TXD_INFO6_UL_GI_LTF GENMASK(14, 12)
  255. #define BE_TXD_INFO6_UL_DOPPLER BIT(15)
  256. #define BE_TXD_INFO6_UL_STBC BIT(16)
  257. #define BE_TXD_INFO6_UL_LENGTH_REF GENMASK(21, 18)
  258. #define BE_TXD_INFO6_UL_RF_GAIN_IDX GENMASK(31, 22)
  259. /* TX WD INFO DWORD 7 */
  260. #define BE_TXD_INFO7_UL_FIXED_GAIN_EN BIT(0)
  261. #define BE_TXD_INFO7_UL_PRI_EXP_RSSI_DBM GENMASK(7, 1)
  262. #define BE_TXD_INFO7_ELNA_IDX BIT(8)
  263. #define BE_TXD_INFO7_UL_APEP_UNIT GENMASK(10, 9)
  264. #define BE_TXD_INFO7_UL_TRI_PAD GENMASK(13, 11)
  265. #define BE_TXD_INFO7_UL_T_PE GENMASK(15, 14)
  266. #define BE_TXD_INFO7_UL_EHT_USR_PRES BIT(16)
  267. #define BE_TXD_INFO7_UL_HELTF_SYMBOL_NUM GENMASK(19, 17)
  268. #define BE_TXD_INFO7_ULBW GENMASK(21, 20)
  269. #define BE_TXD_INFO7_ULBW_EXT GENMASK(23, 22)
  270. #define BE_TXD_INFO7_USE_WD_UL GENMASK(25, 24)
  271. #define BE_TXD_INFO7_EXTEND_MODE_SEL GENMASK(31, 28)
  272. /* RX WD dword0 */
  273. #define AX_RXD_RPKT_LEN_MASK GENMASK(13, 0)
  274. #define AX_RXD_SHIFT_MASK GENMASK(15, 14)
  275. #define AX_RXD_WL_HD_IV_LEN_MASK GENMASK(21, 16)
  276. #define AX_RXD_BB_SEL BIT(22)
  277. #define AX_RXD_MAC_INFO_VLD BIT(23)
  278. #define AX_RXD_RPKT_TYPE_MASK GENMASK(27, 24)
  279. #define AX_RXD_DRV_INFO_SIZE_MASK GENMASK(30, 28)
  280. #define AX_RXD_LONG_RXD BIT(31)
  281. /* RX WD dword1 */
  282. #define AX_RXD_PPDU_TYPE_MASK GENMASK(3, 0)
  283. #define AX_RXD_PPDU_CNT_MASK GENMASK(6, 4)
  284. #define AX_RXD_SR_EN BIT(7)
  285. #define AX_RXD_USER_ID_MASK GENMASK(15, 8)
  286. #define AX_RXD_USER_ID_v1_MASK GENMASK(13, 8)
  287. #define AX_RXD_RX_DATARATE_MASK GENMASK(24, 16)
  288. #define AX_RXD_RX_GI_LTF_MASK GENMASK(27, 25)
  289. #define AX_RXD_NON_SRG_PPDU BIT(28)
  290. #define AX_RXD_INTER_PPDU BIT(29)
  291. #define AX_RXD_NON_SRG_PPDU_v1 BIT(14)
  292. #define AX_RXD_INTER_PPDU_v1 BIT(15)
  293. #define AX_RXD_BW_MASK GENMASK(31, 30)
  294. #define AX_RXD_BW_v1_MASK GENMASK(31, 29)
  295. /* RX WD dword2 */
  296. #define AX_RXD_FREERUN_CNT_MASK GENMASK(31, 0)
  297. /* RX WD dword3 */
  298. #define AX_RXD_A1_MATCH BIT(0)
  299. #define AX_RXD_SW_DEC BIT(1)
  300. #define AX_RXD_HW_DEC BIT(2)
  301. #define AX_RXD_AMPDU BIT(3)
  302. #define AX_RXD_AMPDU_END_PKT BIT(4)
  303. #define AX_RXD_AMSDU BIT(5)
  304. #define AX_RXD_AMSDU_CUT BIT(6)
  305. #define AX_RXD_LAST_MSDU BIT(7)
  306. #define AX_RXD_BYPASS BIT(8)
  307. #define AX_RXD_CRC32_ERR BIT(9)
  308. #define AX_RXD_ICV_ERR BIT(10)
  309. #define AX_RXD_MAGIC_WAKE BIT(11)
  310. #define AX_RXD_UNICAST_WAKE BIT(12)
  311. #define AX_RXD_PATTERN_WAKE BIT(13)
  312. #define AX_RXD_GET_CH_INFO_MASK GENMASK(15, 14)
  313. #define AX_RXD_PATTERN_IDX_MASK GENMASK(20, 16)
  314. #define AX_RXD_TARGET_IDC_MASK GENMASK(23, 21)
  315. #define AX_RXD_CHKSUM_OFFLOAD_EN BIT(24)
  316. #define AX_RXD_WITH_LLC BIT(25)
  317. #define AX_RXD_RX_STATISTICS BIT(26)
  318. /* RX WD dword4 */
  319. #define AX_RXD_TYPE_MASK GENMASK(1, 0)
  320. #define AX_RXD_MC BIT(2)
  321. #define AX_RXD_BC BIT(3)
  322. #define AX_RXD_MD BIT(4)
  323. #define AX_RXD_MF BIT(5)
  324. #define AX_RXD_PWR BIT(6)
  325. #define AX_RXD_QOS BIT(7)
  326. #define AX_RXD_TID_MASK GENMASK(11, 8)
  327. #define AX_RXD_EOSP BIT(12)
  328. #define AX_RXD_HTC BIT(13)
  329. #define AX_RXD_QNULL BIT(14)
  330. #define AX_RXD_SEQ_MASK GENMASK(27, 16)
  331. #define AX_RXD_FRAG_MASK GENMASK(31, 28)
  332. /* RX WD dword5 */
  333. #define AX_RXD_SEC_CAM_IDX_MASK GENMASK(7, 0)
  334. #define AX_RXD_ADDR_CAM_MASK GENMASK(15, 8)
  335. #define AX_RXD_MAC_ID_MASK GENMASK(23, 16)
  336. #define AX_RXD_RX_PL_ID_MASK GENMASK(27, 24)
  337. #define AX_RXD_ADDR_CAM_VLD BIT(28)
  338. #define AX_RXD_ADDR_FWD_EN BIT(29)
  339. #define AX_RXD_RX_PL_MATCH BIT(30)
  340. /* RX WD dword6 */
  341. #define AX_RXD_MAC_ADDR_MASK GENMASK(31, 0)
  342. /* RX WD dword7 */
  343. #define AX_RXD_MAC_ADDR_H_MASK GENMASK(15, 0)
  344. #define AX_RXD_SMART_ANT BIT(16)
  345. #define AX_RXD_SEC_TYPE_MASK GENMASK(20, 17)
  346. #define AX_RXD_HDR_CNV BIT(21)
  347. #define AX_RXD_HDR_OFFSET_MASK GENMASK(26, 22)
  348. #define AX_RXD_BIP_KEYID BIT(27)
  349. #define AX_RXD_BIP_ENC BIT(28)
  350. struct rtw89_rxinfo_user {
  351. __le32 w0;
  352. };
  353. #define RTW89_RXINFO_USER_MAC_ID_VALID BIT(0)
  354. #define RTW89_RXINFO_USER_DATA BIT(1)
  355. #define RTW89_RXINFO_USER_CTRL BIT(2)
  356. #define RTW89_RXINFO_USER_MGMT BIT(3)
  357. #define RTW89_RXINFO_USER_BCM BIT(4)
  358. #define RTW89_RXINFO_USER_MACID GENMASK(15, 8)
  359. struct rtw89_rxinfo {
  360. __le32 w0;
  361. __le32 w1;
  362. struct rtw89_rxinfo_user user[];
  363. } __packed;
  364. #define RTW89_RXINFO_W0_USR_NUM GENMASK(3, 0)
  365. #define RTW89_RXINFO_W0_FW_DEFINE GENMASK(15, 8)
  366. #define RTW89_RXINFO_W0_LSIG_LEN GENMASK(27, 16)
  367. #define RTW89_RXINFO_W0_IS_TO_SELF BIT(28)
  368. #define RTW89_RXINFO_W0_RX_CNT_VLD BIT(29)
  369. #define RTW89_RXINFO_W0_LONG_RXD GENMASK(31, 30)
  370. #define RTW89_RXINFO_W1_SERVICE GENMASK(15, 0)
  371. #define RTW89_RXINFO_W1_PLCP_LEN GENMASK(23, 16)
  372. struct rtw89_phy_sts_hdr {
  373. __le32 w0;
  374. __le32 w1;
  375. } __packed;
  376. #define RTW89_PHY_STS_HDR_W0_IE_MAP GENMASK(4, 0)
  377. #define RTW89_PHY_STS_HDR_W0_LEN GENMASK(15, 8)
  378. #define RTW89_PHY_STS_HDR_W0_RSSI_AVG GENMASK(31, 24)
  379. #define RTW89_PHY_STS_HDR_W1_RSSI_A GENMASK(7, 0)
  380. #define RTW89_PHY_STS_HDR_W1_RSSI_B GENMASK(15, 8)
  381. #define RTW89_PHY_STS_HDR_W1_RSSI_C GENMASK(23, 16)
  382. #define RTW89_PHY_STS_HDR_W1_RSSI_D GENMASK(31, 24)
  383. struct rtw89_phy_sts_iehdr {
  384. __le32 w0;
  385. };
  386. #define RTW89_PHY_STS_IEHDR_TYPE GENMASK(4, 0)
  387. #define RTW89_PHY_STS_IEHDR_LEN GENMASK(11, 5)
  388. /* BE RXD dword0 */
  389. #define BE_RXD_RPKT_LEN_MASK GENMASK(13, 0)
  390. #define BE_RXD_SHIFT_MASK GENMASK(15, 14)
  391. #define BE_RXD_DRV_INFO_SZ_MASK GENMASK(19, 18)
  392. #define BE_RXD_HDR_CNV_SZ_MASK GENMASK(21, 20)
  393. #define BE_RXD_PHY_RPT_SZ_MASK GENMASK(23, 22)
  394. #define BE_RXD_RPKT_TYPE_MASK GENMASK(29, 24)
  395. #define BE_RXD_BB_SEL BIT(30)
  396. #define BE_RXD_LONG_RXD BIT(31)
  397. /* BE RXD dword1 */
  398. #define BE_RXD_PKT_ID_MASK GENMASK(11, 0)
  399. #define BE_RXD_FWD_TARGET_MASK GENMASK(23, 16)
  400. #define BE_RXD_BCN_FW_INFO_MASK GENMASK(25, 24)
  401. #define BE_RXD_FW_RLS BIT(26)
  402. /* BE RXD dword2 */
  403. #define BE_RXD_MAC_ID_MASK GENMASK(7, 0)
  404. #define BE_RXD_TYPE_MASK GENMASK(11, 10)
  405. #define BE_RXD_LAST_MSDU BIT(12)
  406. #define BE_RXD_AMSDU_CUT BIT(13)
  407. #define BE_RXD_ADDR_CAM_VLD BIT(14)
  408. #define BE_RXD_REORDER BIT(15)
  409. #define BE_RXD_SEQ_MASK GENMASK(27, 16)
  410. #define BE_RXD_TID_MASK GENMASK(31, 28)
  411. /* BE RXD dword3 */
  412. #define BE_RXD_SEC_TYPE_MASK GENMASK(3, 0)
  413. #define BE_RXD_BIP_KEYID BIT(4)
  414. #define BE_RXD_BIP_ENC BIT(5)
  415. #define BE_RXD_CRC32_ERR BIT(6)
  416. #define BE_RXD_ICV_ERR BIT(7)
  417. #define BE_RXD_HW_DEC BIT(8)
  418. #define BE_RXD_SW_DEC BIT(9)
  419. #define BE_RXD_A1_MATCH BIT(10)
  420. #define BE_RXD_AMPDU BIT(11)
  421. #define BE_RXD_AMPDU_EOF BIT(12)
  422. #define BE_RXD_AMSDU BIT(13)
  423. #define BE_RXD_MC BIT(14)
  424. #define BE_RXD_BC BIT(15)
  425. #define BE_RXD_MD BIT(16)
  426. #define BE_RXD_MF BIT(17)
  427. #define BE_RXD_PWR BIT(18)
  428. #define BE_RXD_QOS BIT(19)
  429. #define BE_RXD_EOSP BIT(20)
  430. #define BE_RXD_HTC BIT(21)
  431. #define BE_RXD_QNULL BIT(22)
  432. #define BE_RXD_A4_FRAME BIT(23)
  433. #define BE_RXD_FRAG_MASK GENMASK(27, 24)
  434. #define BE_RXD_GET_CH_INFO_V1_MASK GENMASK(31, 30)
  435. /* BE RXD dword4 */
  436. #define BE_RXD_PPDU_TYPE_MASK GENMASK(7, 0)
  437. #define BE_RXD_PPDU_CNT_MASK GENMASK(10, 8)
  438. #define BE_RXD_BW_MASK GENMASK(14, 12)
  439. #define BE_RXD_RX_GI_LTF_MASK GENMASK(18, 16)
  440. #define BE_RXD_RX_REORDER_FIELD_EN BIT(19)
  441. #define BE_RXD_RX_DATARATE_MASK GENMASK(31, 20)
  442. /* BE RXD dword5 */
  443. #define BE_RXD_FREERUN_CNT_MASK GENMASK(31, 0)
  444. /* BE RXD dword6 */
  445. #define BE_RXD_ADDR_CAM_MASK GENMASK(7, 0)
  446. #define BE_RXD_SR_EN BIT(13)
  447. #define BE_RXD_NON_SRG_PPDU BIT(14)
  448. #define BE_RXD_INTER_PPDU BIT(15)
  449. #define BE_RXD_USER_ID_MASK GENMASK(21, 16)
  450. #define BE_RXD_RX_STATISTICS BIT(22)
  451. #define BE_RXD_SMART_ANT BIT(23)
  452. #define BE_RXD_SEC_CAM_IDX_MASK GENMASK(31, 24)
  453. /* BE RXD dword7 */
  454. #define BE_RXD_PATTERN_IDX_MASK GENMASK(4, 0)
  455. #define BE_RXD_MAGIC_WAKE BIT(5)
  456. #define BE_RXD_UNICAST_WAKE BIT(6)
  457. #define BE_RXD_PATTERN_WAKE BIT(7)
  458. #define BE_RXD_RX_PL_MATCH BIT(8)
  459. #define BE_RXD_RX_PL_ID_MASK GENMASK(15, 12)
  460. #define BE_RXD_HDR_CNV BIT(16)
  461. #define BE_RXD_NAT25_HIT BIT(17)
  462. #define BE_RXD_IS_DA BIT(18)
  463. #define BE_RXD_CHKSUM_OFFLOAD_EN BIT(19)
  464. #define BE_RXD_RXSC_ENTRY_MASK GENMASK(22, 20)
  465. #define BE_RXD_RXSC_HIT BIT(23)
  466. #define BE_RXD_WITH_LLC BIT(24)
  467. #define BE_RXD_RX_AGG_FIELD_EN BIT(25)
  468. /* BE RXD dword8 */
  469. #define BE_RXD_MAC_ADDR_MASK GENMASK(31, 0)
  470. /* BE RXD dword9 */
  471. #define BE_RXD_MAC_ADDR_H_MASK GENMASK(15, 0)
  472. #define BE_RXD_HDR_OFFSET_MASK GENMASK(20, 16)
  473. #define BE_RXD_WL_HD_IV_LEN_MASK GENMASK(26, 21)
  474. struct rtw89_phy_sts_ie0 {
  475. __le32 w0;
  476. __le32 w1;
  477. __le32 w2;
  478. } __packed;
  479. #define RTW89_PHY_STS_IE01_W0_CH_IDX GENMASK(23, 16)
  480. #define RTW89_PHY_STS_IE01_W1_FD_CFO GENMASK(19, 8)
  481. #define RTW89_PHY_STS_IE01_W1_PREMB_CFO GENMASK(31, 20)
  482. #define RTW89_PHY_STS_IE01_W2_AVG_SNR GENMASK(5, 0)
  483. #define RTW89_PHY_STS_IE01_W2_EVM_MAX GENMASK(15, 8)
  484. #define RTW89_PHY_STS_IE01_W2_EVM_MIN GENMASK(23, 16)
  485. enum rtw89_tx_channel {
  486. RTW89_TXCH_ACH0 = 0,
  487. RTW89_TXCH_ACH1 = 1,
  488. RTW89_TXCH_ACH2 = 2,
  489. RTW89_TXCH_ACH3 = 3,
  490. RTW89_TXCH_ACH4 = 4,
  491. RTW89_TXCH_ACH5 = 5,
  492. RTW89_TXCH_ACH6 = 6,
  493. RTW89_TXCH_ACH7 = 7,
  494. RTW89_TXCH_CH8 = 8, /* MGMT Band 0 */
  495. RTW89_TXCH_CH9 = 9, /* HI Band 0 */
  496. RTW89_TXCH_CH10 = 10, /* MGMT Band 1 */
  497. RTW89_TXCH_CH11 = 11, /* HI Band 1 */
  498. RTW89_TXCH_CH12 = 12, /* FW CMD */
  499. /* keep last */
  500. RTW89_TXCH_NUM,
  501. RTW89_TXCH_MAX = RTW89_TXCH_NUM - 1
  502. };
  503. enum rtw89_rx_channel {
  504. RTW89_RXCH_RXQ = 0,
  505. RTW89_RXCH_RPQ = 1,
  506. /* keep last */
  507. RTW89_RXCH_NUM,
  508. RTW89_RXCH_MAX = RTW89_RXCH_NUM - 1
  509. };
  510. enum rtw89_tx_qsel {
  511. RTW89_TX_QSEL_BE_0 = 0x00,
  512. RTW89_TX_QSEL_BK_0 = 0x01,
  513. RTW89_TX_QSEL_VI_0 = 0x02,
  514. RTW89_TX_QSEL_VO_0 = 0x03,
  515. RTW89_TX_QSEL_BE_1 = 0x04,
  516. RTW89_TX_QSEL_BK_1 = 0x05,
  517. RTW89_TX_QSEL_VI_1 = 0x06,
  518. RTW89_TX_QSEL_VO_1 = 0x07,
  519. RTW89_TX_QSEL_BE_2 = 0x08,
  520. RTW89_TX_QSEL_BK_2 = 0x09,
  521. RTW89_TX_QSEL_VI_2 = 0x0a,
  522. RTW89_TX_QSEL_VO_2 = 0x0b,
  523. RTW89_TX_QSEL_BE_3 = 0x0c,
  524. RTW89_TX_QSEL_BK_3 = 0x0d,
  525. RTW89_TX_QSEL_VI_3 = 0x0e,
  526. RTW89_TX_QSEL_VO_3 = 0x0f,
  527. RTW89_TX_QSEL_B0_BCN = 0x10,
  528. RTW89_TX_QSEL_B0_HI = 0x11,
  529. RTW89_TX_QSEL_B0_MGMT = 0x12,
  530. RTW89_TX_QSEL_B0_NOPS = 0x13,
  531. RTW89_TX_QSEL_B0_MGMT_FAST = 0x14,
  532. /* reserved */
  533. /* reserved */
  534. /* reserved */
  535. RTW89_TX_QSEL_B1_BCN = 0x18,
  536. RTW89_TX_QSEL_B1_HI = 0x19,
  537. RTW89_TX_QSEL_B1_MGMT = 0x1a,
  538. RTW89_TX_QSEL_B1_NOPS = 0x1b,
  539. RTW89_TX_QSEL_B1_MGMT_FAST = 0x1c,
  540. /* reserved */
  541. /* reserved */
  542. /* reserved */
  543. };
  544. static inline u8 rtw89_core_get_qsel(struct rtw89_dev *rtwdev, u8 tid)
  545. {
  546. switch (tid) {
  547. default:
  548. rtw89_warn(rtwdev, "Should use tag 1d: %d\n", tid);
  549. fallthrough;
  550. case 0:
  551. case 3:
  552. return RTW89_TX_QSEL_BE_0;
  553. case 1:
  554. case 2:
  555. return RTW89_TX_QSEL_BK_0;
  556. case 4:
  557. case 5:
  558. return RTW89_TX_QSEL_VI_0;
  559. case 6:
  560. case 7:
  561. return RTW89_TX_QSEL_VO_0;
  562. }
  563. }
  564. static inline u8 rtw89_core_get_ch_dma(struct rtw89_dev *rtwdev, u8 qsel)
  565. {
  566. switch (qsel) {
  567. default:
  568. rtw89_warn(rtwdev, "Cannot map qsel to dma: %d\n", qsel);
  569. fallthrough;
  570. case RTW89_TX_QSEL_BE_0:
  571. return RTW89_TXCH_ACH0;
  572. case RTW89_TX_QSEL_BK_0:
  573. return RTW89_TXCH_ACH1;
  574. case RTW89_TX_QSEL_VI_0:
  575. return RTW89_TXCH_ACH2;
  576. case RTW89_TX_QSEL_VO_0:
  577. return RTW89_TXCH_ACH3;
  578. case RTW89_TX_QSEL_B0_MGMT:
  579. return RTW89_TXCH_CH8;
  580. case RTW89_TX_QSEL_B0_HI:
  581. return RTW89_TXCH_CH9;
  582. case RTW89_TX_QSEL_B1_MGMT:
  583. return RTW89_TXCH_CH10;
  584. case RTW89_TX_QSEL_B1_HI:
  585. return RTW89_TXCH_CH11;
  586. }
  587. }
  588. static inline u8 rtw89_core_get_tid_indicate(struct rtw89_dev *rtwdev, u8 tid)
  589. {
  590. switch (tid) {
  591. case 3:
  592. case 2:
  593. case 5:
  594. case 7:
  595. return 1;
  596. default:
  597. rtw89_warn(rtwdev, "Should use tag 1d: %d\n", tid);
  598. fallthrough;
  599. case 0:
  600. case 1:
  601. case 4:
  602. case 6:
  603. return 0;
  604. }
  605. }
  606. #endif