trx.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2009-2012 Realtek Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * The full GNU General Public License is included in this distribution in the
  15. * file called LICENSE.
  16. *
  17. * Contact Information:
  18. * wlanfae <wlanfae@realtek.com>
  19. * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  20. * Hsinchu 300, Taiwan.
  21. *
  22. * Larry Finger <Larry.Finger@lwfinger.net>
  23. *
  24. *****************************************************************************/
  25. #ifndef __RTL92CE_TRX_H__
  26. #define __RTL92CE_TRX_H__
  27. #define TX_DESC_SIZE 64
  28. #define TX_DESC_AGGR_SUBFRAME_SIZE 32
  29. #define RX_DESC_SIZE 32
  30. #define RX_DRV_INFO_SIZE_UNIT 8
  31. #define TX_DESC_NEXT_DESC_OFFSET 40
  32. #define USB_HWDESC_HEADER_LEN 32
  33. #define CRCLENGTH 4
  34. /* Define a macro that takes a le32 word, converts it to host ordering,
  35. * right shifts by a specified count, creates a mask of the specified
  36. * bit count, and extracts that number of bits.
  37. */
  38. #define SHIFT_AND_MASK_LE(__pdesc, __shift, __mask) \
  39. ((le32_to_cpu(*(((__le32 *)(__pdesc)))) >> (__shift)) & \
  40. BIT_LEN_MASK_32(__mask))
  41. /* Define a macro that clears a bit field in an le32 word and
  42. * sets the specified value into that bit field. The resulting
  43. * value remains in le32 ordering; however, it is properly converted
  44. * to host ordering for the clear and set operations before conversion
  45. * back to le32.
  46. */
  47. #define SET_BITS_OFFSET_LE(__pdesc, __shift, __len, __val) \
  48. (*(__le32 *)(__pdesc) = \
  49. (cpu_to_le32((le32_to_cpu(*((__le32 *)(__pdesc))) & \
  50. (~(BIT_OFFSET_LEN_MASK_32((__shift), __len)))) | \
  51. (((u32)(__val) & BIT_LEN_MASK_32(__len)) << (__shift)))));
  52. /* macros to read/write various fields in RX or TX descriptors */
  53. #define SET_TX_DESC_PKT_SIZE(__pdesc, __val) \
  54. SET_BITS_OFFSET_LE(__pdesc, 0, 16, __val)
  55. #define SET_TX_DESC_OFFSET(__pdesc, __val) \
  56. SET_BITS_OFFSET_LE(__pdesc, 16, 8, __val)
  57. #define SET_TX_DESC_BMC(__pdesc, __val) \
  58. SET_BITS_OFFSET_LE(__pdesc, 24, 1, __val)
  59. #define SET_TX_DESC_HTC(__pdesc, __val) \
  60. SET_BITS_OFFSET_LE(__pdesc, 25, 1, __val)
  61. #define SET_TX_DESC_LAST_SEG(__pdesc, __val) \
  62. SET_BITS_OFFSET_LE(__pdesc, 26, 1, __val)
  63. #define SET_TX_DESC_FIRST_SEG(__pdesc, __val) \
  64. SET_BITS_OFFSET_LE(__pdesc, 27, 1, __val)
  65. #define SET_TX_DESC_LINIP(__pdesc, __val) \
  66. SET_BITS_OFFSET_LE(__pdesc, 28, 1, __val)
  67. #define SET_TX_DESC_NO_ACM(__pdesc, __val) \
  68. SET_BITS_OFFSET_LE(__pdesc, 29, 1, __val)
  69. #define SET_TX_DESC_GF(__pdesc, __val) \
  70. SET_BITS_OFFSET_LE(__pdesc, 30, 1, __val)
  71. #define SET_TX_DESC_OWN(__pdesc, __val) \
  72. SET_BITS_OFFSET_LE(__pdesc, 31, 1, __val)
  73. #define GET_TX_DESC_PKT_SIZE(__pdesc) \
  74. SHIFT_AND_MASK_LE(__pdesc, 0, 16)
  75. #define GET_TX_DESC_OFFSET(__pdesc) \
  76. SHIFT_AND_MASK_LE(__pdesc, 16, 8)
  77. #define GET_TX_DESC_BMC(__pdesc) \
  78. SHIFT_AND_MASK_LE(__pdesc, 24, 1)
  79. #define GET_TX_DESC_HTC(__pdesc) \
  80. SHIFT_AND_MASK_LE(__pdesc, 25, 1)
  81. #define GET_TX_DESC_LAST_SEG(__pdesc) \
  82. SHIFT_AND_MASK_LE(__pdesc, 26, 1)
  83. #define GET_TX_DESC_FIRST_SEG(__pdesc) \
  84. SHIFT_AND_MASK_LE(__pdesc, 27, 1)
  85. #define GET_TX_DESC_LINIP(__pdesc) \
  86. SHIFT_AND_MASK_LE(__pdesc, 28, 1)
  87. #define GET_TX_DESC_NO_ACM(__pdesc) \
  88. SHIFT_AND_MASK_LE(__pdesc, 29, 1)
  89. #define GET_TX_DESC_GF(__pdesc) \
  90. SHIFT_AND_MASK_LE(__pdesc, 30, 1)
  91. #define GET_TX_DESC_OWN(__pdesc) \
  92. SHIFT_AND_MASK_LE(__pdesc, 31, 1)
  93. #define SET_TX_DESC_MACID(__pdesc, __val) \
  94. SET_BITS_OFFSET_LE(__pdesc+4, 0, 5, __val)
  95. #define SET_TX_DESC_AGG_BREAK(__pdesc, __val) \
  96. SET_BITS_OFFSET_LE(__pdesc+4, 5, 1, __val)
  97. #define SET_TX_DESC_BK(__pdesc, __val) \
  98. SET_BITS_OFFSET_LE(__pdesc+4, 6, 1, __val)
  99. #define SET_TX_DESC_RDG_ENABLE(__pdesc, __val) \
  100. SET_BITS_OFFSET_LE(__pdesc+4, 7, 1, __val)
  101. #define SET_TX_DESC_QUEUE_SEL(__pdesc, __val) \
  102. SET_BITS_OFFSET_LE(__pdesc+4, 8, 5, __val)
  103. #define SET_TX_DESC_RDG_NAV_EXT(__pdesc, __val) \
  104. SET_BITS_OFFSET_LE(__pdesc+4, 13, 1, __val)
  105. #define SET_TX_DESC_LSIG_TXOP_EN(__pdesc, __val) \
  106. SET_BITS_OFFSET_LE(__pdesc+4, 14, 1, __val)
  107. #define SET_TX_DESC_PIFS(__pdesc, __val) \
  108. SET_BITS_OFFSET_LE(__pdesc+4, 15, 1, __val)
  109. #define SET_TX_DESC_RATE_ID(__pdesc, __val) \
  110. SET_BITS_OFFSET_LE(__pdesc+4, 16, 4, __val)
  111. #define SET_TX_DESC_NAV_USE_HDR(__pdesc, __val) \
  112. SET_BITS_OFFSET_LE(__pdesc+4, 20, 1, __val)
  113. #define SET_TX_DESC_EN_DESC_ID(__pdesc, __val) \
  114. SET_BITS_OFFSET_LE(__pdesc+4, 21, 1, __val)
  115. #define SET_TX_DESC_SEC_TYPE(__pdesc, __val) \
  116. SET_BITS_OFFSET_LE(__pdesc+4, 22, 2, __val)
  117. #define SET_TX_DESC_PKT_OFFSET(__pdesc, __val) \
  118. SET_BITS_OFFSET_LE(__pdesc+4, 24, 8, __val)
  119. #define GET_TX_DESC_MACID(__pdesc) \
  120. SHIFT_AND_MASK_LE(__pdesc+4, 0, 5)
  121. #define GET_TX_DESC_AGG_ENABLE(__pdesc) \
  122. SHIFT_AND_MASK_LE(__pdesc+4, 5, 1)
  123. #define GET_TX_DESC_AGG_BREAK(__pdesc) \
  124. SHIFT_AND_MASK_LE(__pdesc+4, 6, 1)
  125. #define GET_TX_DESC_RDG_ENABLE(__pdesc) \
  126. SHIFT_AND_MASK_LE(__pdesc+4, 7, 1)
  127. #define GET_TX_DESC_QUEUE_SEL(__pdesc) \
  128. SHIFT_AND_MASK_LE(__pdesc+4, 8, 5)
  129. #define GET_TX_DESC_RDG_NAV_EXT(__pdesc) \
  130. SHIFT_AND_MASK_LE(__pdesc+4, 13, 1)
  131. #define GET_TX_DESC_LSIG_TXOP_EN(__pdesc) \
  132. SHIFT_AND_MASK_LE(__pdesc+4, 14, 1)
  133. #define GET_TX_DESC_PIFS(__pdesc) \
  134. SHIFT_AND_MASK_LE(__pdesc+4, 15, 1)
  135. #define GET_TX_DESC_RATE_ID(__pdesc) \
  136. SHIFT_AND_MASK_LE(__pdesc+4, 16, 4)
  137. #define GET_TX_DESC_NAV_USE_HDR(__pdesc) \
  138. SHIFT_AND_MASK_LE(__pdesc+4, 20, 1)
  139. #define GET_TX_DESC_EN_DESC_ID(__pdesc) \
  140. SHIFT_AND_MASK_LE(__pdesc+4, 21, 1)
  141. #define GET_TX_DESC_SEC_TYPE(__pdesc) \
  142. SHIFT_AND_MASK_LE(__pdesc+4, 22, 2)
  143. #define GET_TX_DESC_PKT_OFFSET(__pdesc) \
  144. SHIFT_AND_MASK_LE(__pdesc+4, 24, 8)
  145. #define SET_TX_DESC_RTS_RC(__pdesc, __val) \
  146. SET_BITS_OFFSET_LE(__pdesc+8, 0, 6, __val)
  147. #define SET_TX_DESC_DATA_RC(__pdesc, __val) \
  148. SET_BITS_OFFSET_LE(__pdesc+8, 6, 6, __val)
  149. #define SET_TX_DESC_BAR_RTY_TH(__pdesc, __val) \
  150. SET_BITS_OFFSET_LE(__pdesc+8, 14, 2, __val)
  151. #define SET_TX_DESC_MORE_FRAG(__pdesc, __val) \
  152. SET_BITS_OFFSET_LE(__pdesc+8, 17, 1, __val)
  153. #define SET_TX_DESC_RAW(__pdesc, __val) \
  154. SET_BITS_OFFSET_LE(__pdesc+8, 18, 1, __val)
  155. #define SET_TX_DESC_CCX(__pdesc, __val) \
  156. SET_BITS_OFFSET_LE(__pdesc+8, 19, 1, __val)
  157. #define SET_TX_DESC_AMPDU_DENSITY(__pdesc, __val) \
  158. SET_BITS_OFFSET_LE(__pdesc+8, 20, 3, __val)
  159. #define SET_TX_DESC_ANTSEL_A(__pdesc, __val) \
  160. SET_BITS_OFFSET_LE(__pdesc+8, 24, 1, __val)
  161. #define SET_TX_DESC_ANTSEL_B(__pdesc, __val) \
  162. SET_BITS_OFFSET_LE(__pdesc+8, 25, 1, __val)
  163. #define SET_TX_DESC_TX_ANT_CCK(__pdesc, __val) \
  164. SET_BITS_OFFSET_LE(__pdesc+8, 26, 2, __val)
  165. #define SET_TX_DESC_TX_ANTL(__pdesc, __val) \
  166. SET_BITS_OFFSET_LE(__pdesc+8, 28, 2, __val)
  167. #define SET_TX_DESC_TX_ANT_HT(__pdesc, __val) \
  168. SET_BITS_OFFSET_LE(__pdesc+8, 30, 2, __val)
  169. #define GET_TX_DESC_RTS_RC(__pdesc) \
  170. SHIFT_AND_MASK_LE(__pdesc+8, 0, 6)
  171. #define GET_TX_DESC_DATA_RC(__pdesc) \
  172. SHIFT_AND_MASK_LE(__pdesc+8, 6, 6)
  173. #define GET_TX_DESC_BAR_RTY_TH(__pdesc) \
  174. SHIFT_AND_MASK_LE(__pdesc+8, 14, 2)
  175. #define GET_TX_DESC_MORE_FRAG(__pdesc) \
  176. SHIFT_AND_MASK_LE(__pdesc+8, 17, 1)
  177. #define GET_TX_DESC_RAW(__pdesc) \
  178. SHIFT_AND_MASK_LE(__pdesc+8, 18, 1)
  179. #define GET_TX_DESC_CCX(__pdesc) \
  180. SHIFT_AND_MASK_LE(__pdesc+8, 19, 1)
  181. #define GET_TX_DESC_AMPDU_DENSITY(__pdesc) \
  182. SHIFT_AND_MASK_LE(__pdesc+8, 20, 3)
  183. #define GET_TX_DESC_ANTSEL_A(__pdesc) \
  184. SHIFT_AND_MASK_LE(__pdesc+8, 24, 1)
  185. #define GET_TX_DESC_ANTSEL_B(__pdesc) \
  186. SHIFT_AND_MASK_LE(__pdesc+8, 25, 1)
  187. #define GET_TX_DESC_TX_ANT_CCK(__pdesc) \
  188. SHIFT_AND_MASK_LE(__pdesc+8, 26, 2)
  189. #define GET_TX_DESC_TX_ANTL(__pdesc) \
  190. SHIFT_AND_MASK_LE(__pdesc+8, 28, 2)
  191. #define GET_TX_DESC_TX_ANT_HT(__pdesc) \
  192. SHIFT_AND_MASK_LE(__pdesc+8, 30, 2)
  193. #define SET_TX_DESC_NEXT_HEAP_PAGE(__pdesc, __val) \
  194. SET_BITS_OFFSET_LE(__pdesc+12, 0, 8, __val)
  195. #define SET_TX_DESC_TAIL_PAGE(__pdesc, __val) \
  196. SET_BITS_OFFSET_LE(__pdesc+12, 8, 8, __val)
  197. #define SET_TX_DESC_SEQ(__pdesc, __val) \
  198. SET_BITS_OFFSET_LE(__pdesc+12, 16, 12, __val)
  199. #define SET_TX_DESC_PKT_ID(__pdesc, __val) \
  200. SET_BITS_OFFSET_LE(__pdesc+12, 28, 4, __val)
  201. #define GET_TX_DESC_NEXT_HEAP_PAGE(__pdesc) \
  202. SHIFT_AND_MASK_LE(__pdesc+12, 0, 8)
  203. #define GET_TX_DESC_TAIL_PAGE(__pdesc) \
  204. SHIFT_AND_MASK_LE(__pdesc+12, 8, 8)
  205. #define GET_TX_DESC_SEQ(__pdesc) \
  206. SHIFT_AND_MASK_LE(__pdesc+12, 16, 12)
  207. #define GET_TX_DESC_PKT_ID(__pdesc) \
  208. SHIFT_AND_MASK_LE(__pdesc+12, 28, 4)
  209. #define SET_TX_DESC_RTS_RATE(__pdesc, __val) \
  210. SET_BITS_OFFSET_LE(__pdesc+16, 0, 5, __val)
  211. #define SET_TX_DESC_AP_DCFE(__pdesc, __val) \
  212. SET_BITS_OFFSET_LE(__pdesc+16, 5, 1, __val)
  213. #define SET_TX_DESC_QOS(__pdesc, __val) \
  214. SET_BITS_OFFSET_LE(__pdesc+16, 6, 1, __val)
  215. #define SET_TX_DESC_HWSEQ_EN(__pdesc, __val) \
  216. SET_BITS_OFFSET_LE(__pdesc+16, 7, 1, __val)
  217. #define SET_TX_DESC_USE_RATE(__pdesc, __val) \
  218. SET_BITS_OFFSET_LE(__pdesc+16, 8, 1, __val)
  219. #define SET_TX_DESC_DISABLE_RTS_FB(__pdesc, __val) \
  220. SET_BITS_OFFSET_LE(__pdesc+16, 9, 1, __val)
  221. #define SET_TX_DESC_DISABLE_FB(__pdesc, __val) \
  222. SET_BITS_OFFSET_LE(__pdesc+16, 10, 1, __val)
  223. #define SET_TX_DESC_CTS2SELF(__pdesc, __val) \
  224. SET_BITS_OFFSET_LE(__pdesc+16, 11, 1, __val)
  225. #define SET_TX_DESC_RTS_ENABLE(__pdesc, __val) \
  226. SET_BITS_OFFSET_LE(__pdesc+16, 12, 1, __val)
  227. #define SET_TX_DESC_HW_RTS_ENABLE(__pdesc, __val) \
  228. SET_BITS_OFFSET_LE(__pdesc+16, 13, 1, __val)
  229. #define SET_TX_DESC_PORT_ID(__pdesc, __val) \
  230. SET_BITS_OFFSET_LE(__pdesc+16, 14, 1, __val)
  231. #define SET_TX_DESC_WAIT_DCTS(__pdesc, __val) \
  232. SET_BITS_OFFSET_LE(__pdesc+16, 18, 1, __val)
  233. #define SET_TX_DESC_CTS2AP_EN(__pdesc, __val) \
  234. SET_BITS_OFFSET_LE(__pdesc+16, 19, 1, __val)
  235. #define SET_TX_DESC_TX_SUB_CARRIER(__pdesc, __val) \
  236. SET_BITS_OFFSET_LE(__pdesc+16, 20, 2, __val)
  237. #define SET_TX_DESC_TX_STBC(__pdesc, __val) \
  238. SET_BITS_OFFSET_LE(__pdesc+16, 22, 2, __val)
  239. #define SET_TX_DESC_DATA_SHORT(__pdesc, __val) \
  240. SET_BITS_OFFSET_LE(__pdesc+16, 24, 1, __val)
  241. #define SET_TX_DESC_DATA_BW(__pdesc, __val) \
  242. SET_BITS_OFFSET_LE(__pdesc+16, 25, 1, __val)
  243. #define SET_TX_DESC_RTS_SHORT(__pdesc, __val) \
  244. SET_BITS_OFFSET_LE(__pdesc+16, 26, 1, __val)
  245. #define SET_TX_DESC_RTS_BW(__pdesc, __val) \
  246. SET_BITS_OFFSET_LE(__pdesc+16, 27, 1, __val)
  247. #define SET_TX_DESC_RTS_SC(__pdesc, __val) \
  248. SET_BITS_OFFSET_LE(__pdesc+16, 28, 2, __val)
  249. #define SET_TX_DESC_RTS_STBC(__pdesc, __val) \
  250. SET_BITS_OFFSET_LE(__pdesc+16, 30, 2, __val)
  251. #define GET_TX_DESC_RTS_RATE(__pdesc) \
  252. SHIFT_AND_MASK_LE(__pdesc+16, 0, 5)
  253. #define GET_TX_DESC_AP_DCFE(__pdesc) \
  254. SHIFT_AND_MASK_LE(__pdesc+16, 5, 1)
  255. #define GET_TX_DESC_QOS(__pdesc) \
  256. SHIFT_AND_MASK_LE(__pdesc+16, 6, 1)
  257. #define GET_TX_DESC_HWSEQ_EN(__pdesc) \
  258. SHIFT_AND_MASK_LE(__pdesc+16, 7, 1)
  259. #define GET_TX_DESC_USE_RATE(__pdesc) \
  260. SHIFT_AND_MASK_LE(__pdesc+16, 8, 1)
  261. #define GET_TX_DESC_DISABLE_RTS_FB(__pdesc) \
  262. SHIFT_AND_MASK_LE(__pdesc+16, 9, 1)
  263. #define GET_TX_DESC_DISABLE_FB(__pdesc) \
  264. SHIFT_AND_MASK_LE(__pdesc+16, 10, 1)
  265. #define GET_TX_DESC_CTS2SELF(__pdesc) \
  266. SHIFT_AND_MASK_LE(__pdesc+16, 11, 1)
  267. #define GET_TX_DESC_RTS_ENABLE(__pdesc) \
  268. SHIFT_AND_MASK_LE(__pdesc+16, 12, 1)
  269. #define GET_TX_DESC_HW_RTS_ENABLE(__pdesc) \
  270. SHIFT_AND_MASK_LE(__pdesc+16, 13, 1)
  271. #define GET_TX_DESC_PORT_ID(__pdesc) \
  272. SHIFT_AND_MASK_LE(__pdesc+16, 14, 1)
  273. #define GET_TX_DESC_WAIT_DCTS(__pdesc) \
  274. SHIFT_AND_MASK_LE(__pdesc+16, 18, 1)
  275. #define GET_TX_DESC_CTS2AP_EN(__pdesc) \
  276. SHIFT_AND_MASK_LE(__pdesc+16, 19, 1)
  277. #define GET_TX_DESC_TX_SUB_CARRIER(__pdesc) \
  278. SHIFT_AND_MASK_LE(__pdesc+16, 20, 2)
  279. #define GET_TX_DESC_TX_STBC(__pdesc) \
  280. SHIFT_AND_MASK_LE(__pdesc+16, 22, 2)
  281. #define GET_TX_DESC_DATA_SHORT(__pdesc) \
  282. SHIFT_AND_MASK_LE(__pdesc+16, 24, 1)
  283. #define GET_TX_DESC_DATA_BW(__pdesc) \
  284. SHIFT_AND_MASK_LE(__pdesc+16, 25, 1)
  285. #define GET_TX_DESC_RTS_SHORT(__pdesc) \
  286. SHIFT_AND_MASK_LE(__pdesc+16, 26, 1)
  287. #define GET_TX_DESC_RTS_BW(__pdesc) \
  288. SHIFT_AND_MASK_LE(__pdesc+16, 27, 1)
  289. #define GET_TX_DESC_RTS_SC(__pdesc) \
  290. SHIFT_AND_MASK_LE(__pdesc+16, 28, 2)
  291. #define GET_TX_DESC_RTS_STBC(__pdesc) \
  292. SHIFT_AND_MASK_LE(__pdesc+16, 30, 2)
  293. #define SET_TX_DESC_TX_RATE(__pdesc, __val) \
  294. SET_BITS_OFFSET_LE(__pdesc+20, 0, 6, __val)
  295. #define SET_TX_DESC_DATA_SHORTGI(__pdesc, __val) \
  296. SET_BITS_OFFSET_LE(__pdesc+20, 6, 1, __val)
  297. #define SET_TX_DESC_CCX_TAG(__pdesc, __val) \
  298. SET_BITS_OFFSET_LE(__pdesc+20, 7, 1, __val)
  299. #define SET_TX_DESC_DATA_RATE_FB_LIMIT(__pdesc, __val) \
  300. SET_BITS_OFFSET_LE(__pdesc+20, 8, 5, __val)
  301. #define SET_TX_DESC_RTS_RATE_FB_LIMIT(__pdesc, __val) \
  302. SET_BITS_OFFSET_LE(__pdesc+20, 13, 4, __val)
  303. #define SET_TX_DESC_RETRY_LIMIT_ENABLE(__pdesc, __val) \
  304. SET_BITS_OFFSET_LE(__pdesc+20, 17, 1, __val)
  305. #define SET_TX_DESC_DATA_RETRY_LIMIT(__pdesc, __val) \
  306. SET_BITS_OFFSET_LE(__pdesc+20, 18, 6, __val)
  307. #define SET_TX_DESC_USB_TXAGG_NUM(__pdesc, __val) \
  308. SET_BITS_OFFSET_LE(__pdesc+20, 24, 8, __val)
  309. #define GET_TX_DESC_TX_RATE(__pdesc) \
  310. SHIFT_AND_MASK_LE(__pdesc+20, 0, 6)
  311. #define GET_TX_DESC_DATA_SHORTGI(__pdesc) \
  312. SHIFT_AND_MASK_LE(__pdesc+20, 6, 1)
  313. #define GET_TX_DESC_CCX_TAG(__pdesc) \
  314. SHIFT_AND_MASK_LE(__pdesc+20, 7, 1)
  315. #define GET_TX_DESC_DATA_RATE_FB_LIMIT(__pdesc) \
  316. SHIFT_AND_MASK_LE(__pdesc+20, 8, 5)
  317. #define GET_TX_DESC_RTS_RATE_FB_LIMIT(__pdesc) \
  318. SHIFT_AND_MASK_LE(__pdesc+20, 13, 4)
  319. #define GET_TX_DESC_RETRY_LIMIT_ENABLE(__pdesc) \
  320. SHIFT_AND_MASK_LE(__pdesc+20, 17, 1)
  321. #define GET_TX_DESC_DATA_RETRY_LIMIT(__pdesc) \
  322. SHIFT_AND_MASK_LE(__pdesc+20, 18, 6)
  323. #define GET_TX_DESC_USB_TXAGG_NUM(__pdesc) \
  324. SHIFT_AND_MASK_LE(__pdesc+20, 24, 8)
  325. #define SET_TX_DESC_TXAGC_A(__pdesc, __val) \
  326. SET_BITS_OFFSET_LE(__pdesc+24, 0, 5, __val)
  327. #define SET_TX_DESC_TXAGC_B(__pdesc, __val) \
  328. SET_BITS_OFFSET_LE(__pdesc+24, 5, 5, __val)
  329. #define SET_TX_DESC_USE_MAX_LEN(__pdesc, __val) \
  330. SET_BITS_OFFSET_LE(__pdesc+24, 10, 1, __val)
  331. #define SET_TX_DESC_MAX_AGG_NUM(__pdesc, __val) \
  332. SET_BITS_OFFSET_LE(__pdesc+24, 11, 5, __val)
  333. #define SET_TX_DESC_MCSG1_MAX_LEN(__pdesc, __val) \
  334. SET_BITS_OFFSET_LE(__pdesc+24, 16, 4, __val)
  335. #define SET_TX_DESC_MCSG2_MAX_LEN(__pdesc, __val) \
  336. SET_BITS_OFFSET_LE(__pdesc+24, 20, 4, __val)
  337. #define SET_TX_DESC_MCSG3_MAX_LEN(__pdesc, __val) \
  338. SET_BITS_OFFSET_LE(__pdesc+24, 24, 4, __val)
  339. #define SET_TX_DESC_MCS7_SGI_MAX_LEN(__pdesc, __val) \
  340. SET_BITS_OFFSET_LE(__pdesc+24, 28, 4, __val)
  341. #define GET_TX_DESC_TXAGC_A(__pdesc) \
  342. SHIFT_AND_MASK_LE(__pdesc+24, 0, 5)
  343. #define GET_TX_DESC_TXAGC_B(__pdesc) \
  344. SHIFT_AND_MASK_LE(__pdesc+24, 5, 5)
  345. #define GET_TX_DESC_USE_MAX_LEN(__pdesc) \
  346. SHIFT_AND_MASK_LE(__pdesc+24, 10, 1)
  347. #define GET_TX_DESC_MAX_AGG_NUM(__pdesc) \
  348. SHIFT_AND_MASK_LE(__pdesc+24, 11, 5)
  349. #define GET_TX_DESC_MCSG1_MAX_LEN(__pdesc) \
  350. SHIFT_AND_MASK_LE(__pdesc+24, 16, 4)
  351. #define GET_TX_DESC_MCSG2_MAX_LEN(__pdesc) \
  352. SHIFT_AND_MASK_LE(__pdesc+24, 20, 4)
  353. #define GET_TX_DESC_MCSG3_MAX_LEN(__pdesc) \
  354. SHIFT_AND_MASK_LE(__pdesc+24, 24, 4)
  355. #define GET_TX_DESC_MCS7_SGI_MAX_LEN(__pdesc) \
  356. SHIFT_AND_MASK_LE(__pdesc+24, 28, 4)
  357. #define SET_TX_DESC_TX_BUFFER_SIZE(__pdesc, __val) \
  358. SET_BITS_OFFSET_LE(__pdesc+28, 0, 16, __val)
  359. #define SET_TX_DESC_MCSG4_MAX_LEN(__pdesc, __val) \
  360. SET_BITS_OFFSET_LE(__pdesc+28, 16, 4, __val)
  361. #define SET_TX_DESC_MCSG5_MAX_LEN(__pdesc, __val) \
  362. SET_BITS_OFFSET_LE(__pdesc+28, 20, 4, __val)
  363. #define SET_TX_DESC_MCSG6_MAX_LEN(__pdesc, __val) \
  364. SET_BITS_OFFSET_LE(__pdesc+28, 24, 4, __val)
  365. #define SET_TX_DESC_MCS15_SGI_MAX_LEN(__pdesc, __val) \
  366. SET_BITS_OFFSET_LE(__pdesc+28, 28, 4, __val)
  367. #define GET_TX_DESC_TX_BUFFER_SIZE(__pdesc) \
  368. SHIFT_AND_MASK_LE(__pdesc+28, 0, 16)
  369. #define GET_TX_DESC_MCSG4_MAX_LEN(__pdesc) \
  370. SHIFT_AND_MASK_LE(__pdesc+28, 16, 4)
  371. #define GET_TX_DESC_MCSG5_MAX_LEN(__pdesc) \
  372. SHIFT_AND_MASK_LE(__pdesc+28, 20, 4)
  373. #define GET_TX_DESC_MCSG6_MAX_LEN(__pdesc) \
  374. SHIFT_AND_MASK_LE(__pdesc+28, 24, 4)
  375. #define GET_TX_DESC_MCS15_SGI_MAX_LEN(__pdesc) \
  376. SHIFT_AND_MASK_LE(__pdesc+28, 28, 4)
  377. #define SET_TX_DESC_TX_BUFFER_ADDRESS(__pdesc, __val) \
  378. SET_BITS_OFFSET_LE(__pdesc+32, 0, 32, __val)
  379. #define SET_TX_DESC_TX_BUFFER_ADDRESS64(__pdesc, __val) \
  380. SET_BITS_OFFSET_LE(__pdesc+36, 0, 32, __val)
  381. #define GET_TX_DESC_TX_BUFFER_ADDRESS(__pdesc) \
  382. SHIFT_AND_MASK_LE(__pdesc+32, 0, 32)
  383. #define GET_TX_DESC_TX_BUFFER_ADDRESS64(__pdesc) \
  384. SHIFT_AND_MASK_LE(__pdesc+36, 0, 32)
  385. #define SET_TX_DESC_NEXT_DESC_ADDRESS(__pdesc, __val) \
  386. SET_BITS_OFFSET_LE(__pdesc+40, 0, 32, __val)
  387. #define SET_TX_DESC_NEXT_DESC_ADDRESS64(__pdesc, __val) \
  388. SET_BITS_OFFSET_LE(__pdesc+44, 0, 32, __val)
  389. #define GET_TX_DESC_NEXT_DESC_ADDRESS(__pdesc) \
  390. SHIFT_AND_MASK_LE(__pdesc+40, 0, 32)
  391. #define GET_TX_DESC_NEXT_DESC_ADDRESS64(__pdesc) \
  392. SHIFT_AND_MASK_LE(__pdesc+44, 0, 32)
  393. #define GET_RX_DESC_PKT_LEN(__pdesc) \
  394. SHIFT_AND_MASK_LE(__pdesc, 0, 14)
  395. #define GET_RX_DESC_CRC32(__pdesc) \
  396. SHIFT_AND_MASK_LE(__pdesc, 14, 1)
  397. #define GET_RX_DESC_ICV(__pdesc) \
  398. SHIFT_AND_MASK_LE(__pdesc, 15, 1)
  399. #define GET_RX_DESC_DRV_INFO_SIZE(__pdesc) \
  400. SHIFT_AND_MASK_LE(__pdesc, 16, 4)
  401. #define GET_RX_DESC_SECURITY(__pdesc) \
  402. SHIFT_AND_MASK_LE(__pdesc, 20, 3)
  403. #define GET_RX_DESC_QOS(__pdesc) \
  404. SHIFT_AND_MASK_LE(__pdesc, 23, 1)
  405. #define GET_RX_DESC_SHIFT(__pdesc) \
  406. SHIFT_AND_MASK_LE(__pdesc, 24, 2)
  407. #define GET_RX_DESC_PHYST(__pdesc) \
  408. SHIFT_AND_MASK_LE(__pdesc, 26, 1)
  409. #define GET_RX_DESC_SWDEC(__pdesc) \
  410. SHIFT_AND_MASK_LE(__pdesc, 27, 1)
  411. #define GET_RX_DESC_LS(__pdesc) \
  412. SHIFT_AND_MASK_LE(__pdesc, 28, 1)
  413. #define GET_RX_DESC_FS(__pdesc) \
  414. SHIFT_AND_MASK_LE(__pdesc, 29, 1)
  415. #define GET_RX_DESC_EOR(__pdesc) \
  416. SHIFT_AND_MASK_LE(__pdesc, 30, 1)
  417. #define GET_RX_DESC_OWN(__pdesc) \
  418. SHIFT_AND_MASK_LE(__pdesc, 31, 1)
  419. #define SET_RX_DESC_PKT_LEN(__pdesc, __val) \
  420. SET_BITS_OFFSET_LE(__pdesc, 0, 14, __val)
  421. #define SET_RX_DESC_EOR(__pdesc, __val) \
  422. SET_BITS_OFFSET_LE(__pdesc, 30, 1, __val)
  423. #define SET_RX_DESC_OWN(__pdesc, __val) \
  424. SET_BITS_OFFSET_LE(__pdesc, 31, 1, __val)
  425. #define GET_RX_DESC_MACID(__pdesc) \
  426. SHIFT_AND_MASK_LE(__pdesc+4, 0, 5)
  427. #define GET_RX_DESC_TID(__pdesc) \
  428. SHIFT_AND_MASK_LE(__pdesc+4, 5, 4)
  429. #define GET_RX_DESC_HWRSVD(__pdesc) \
  430. SHIFT_AND_MASK_LE(__pdesc+4, 9, 5)
  431. #define GET_RX_DESC_PAGGR(__pdesc) \
  432. SHIFT_AND_MASK_LE(__pdesc+4, 14, 1)
  433. #define GET_RX_DESC_FAGGR(__pdesc) \
  434. SHIFT_AND_MASK_LE(__pdesc+4, 15, 1)
  435. #define GET_RX_DESC_A1_FIT(__pdesc) \
  436. SHIFT_AND_MASK_LE(__pdesc+4, 16, 4)
  437. #define GET_RX_DESC_A2_FIT(__pdesc) \
  438. SHIFT_AND_MASK_LE(__pdesc+4, 20, 4)
  439. #define GET_RX_DESC_PAM(__pdesc) \
  440. SHIFT_AND_MASK_LE(__pdesc+4, 24, 1)
  441. #define GET_RX_DESC_PWR(__pdesc) \
  442. SHIFT_AND_MASK_LE(__pdesc+4, 25, 1)
  443. #define GET_RX_DESC_MD(__pdesc) \
  444. SHIFT_AND_MASK_LE(__pdesc+4, 26, 1)
  445. #define GET_RX_DESC_MF(__pdesc) \
  446. SHIFT_AND_MASK_LE(__pdesc+4, 27, 1)
  447. #define GET_RX_DESC_TYPE(__pdesc) \
  448. SHIFT_AND_MASK_LE(__pdesc+4, 28, 2)
  449. #define GET_RX_DESC_MC(__pdesc) \
  450. SHIFT_AND_MASK_LE(__pdesc+4, 30, 1)
  451. #define GET_RX_DESC_BC(__pdesc) \
  452. SHIFT_AND_MASK_LE(__pdesc+4, 31, 1)
  453. #define GET_RX_DESC_SEQ(__pdesc) \
  454. SHIFT_AND_MASK_LE(__pdesc+8, 0, 12)
  455. #define GET_RX_DESC_FRAG(__pdesc) \
  456. SHIFT_AND_MASK_LE(__pdesc+8, 12, 4)
  457. #define GET_RX_DESC_NEXT_PKT_LEN(__pdesc) \
  458. SHIFT_AND_MASK_LE(__pdesc+8, 16, 14)
  459. #define GET_RX_DESC_NEXT_IND(__pdesc) \
  460. SHIFT_AND_MASK_LE(__pdesc+8, 30, 1)
  461. #define GET_RX_DESC_RSVD(__pdesc) \
  462. SHIFT_AND_MASK_LE(__pdesc+8, 31, 1)
  463. #define GET_RX_DESC_RXMCS(__pdesc) \
  464. SHIFT_AND_MASK_LE(__pdesc+12, 0, 6)
  465. #define GET_RX_DESC_RXHT(__pdesc) \
  466. SHIFT_AND_MASK_LE(__pdesc+12, 6, 1)
  467. #define GET_RX_DESC_SPLCP(__pdesc) \
  468. SHIFT_AND_MASK_LE(__pdesc+12, 8, 1)
  469. #define GET_RX_DESC_BW(__pdesc) \
  470. SHIFT_AND_MASK_LE(__pdesc+12, 9, 1)
  471. #define GET_RX_DESC_HTC(__pdesc) \
  472. SHIFT_AND_MASK_LE(__pdesc+12, 10, 1)
  473. #define GET_RX_DESC_HWPC_ERR(__pdesc) \
  474. SHIFT_AND_MASK_LE(__pdesc+12, 14, 1)
  475. #define GET_RX_DESC_HWPC_IND(__pdesc) \
  476. SHIFT_AND_MASK_LE(__pdesc+12, 15, 1)
  477. #define GET_RX_DESC_IV0(__pdesc) \
  478. SHIFT_AND_MASK_LE(__pdesc+12, 16, 16)
  479. #define GET_RX_DESC_IV1(__pdesc) \
  480. SHIFT_AND_MASK_LE(__pdesc+16, 0, 32)
  481. #define GET_RX_DESC_TSFL(__pdesc) \
  482. SHIFT_AND_MASK_LE(__pdesc+20, 0, 32)
  483. #define GET_RX_DESC_BUFF_ADDR(__pdesc) \
  484. SHIFT_AND_MASK_LE(__pdesc+24, 0, 32)
  485. #define GET_RX_DESC_BUFF_ADDR64(__pdesc) \
  486. SHIFT_AND_MASK_LE(__pdesc+28, 0, 32)
  487. #define SET_RX_DESC_BUFF_ADDR(__pdesc, __val) \
  488. SET_BITS_OFFSET_LE(__pdesc+24, 0, 32, __val)
  489. #define SET_RX_DESC_BUFF_ADDR64(__pdesc, __val) \
  490. SET_BITS_OFFSET_LE(__pdesc+28, 0, 32, __val)
  491. #define CLEAR_PCI_TX_DESC_CONTENT(__pdesc, _size) \
  492. memset(__pdesc, 0, min_t(size_t, _size, TX_DESC_NEXT_DESC_OFFSET))
  493. struct rx_fwinfo_92c {
  494. u8 gain_trsw[4];
  495. u8 pwdb_all;
  496. u8 cfosho[4];
  497. u8 cfotail[4];
  498. s8 rxevm[2];
  499. s8 rxsnr[4];
  500. u8 pdsnr[2];
  501. u8 csi_current[2];
  502. u8 csi_target[2];
  503. u8 sigevm;
  504. u8 max_ex_pwr;
  505. u8 ex_intf_flag:1;
  506. u8 sgi_en:1;
  507. u8 rxsc:2;
  508. u8 reserve:4;
  509. } __packed;
  510. struct tx_desc_92c {
  511. u32 pktsize:16;
  512. u32 offset:8;
  513. u32 bmc:1;
  514. u32 htc:1;
  515. u32 lastseg:1;
  516. u32 firstseg:1;
  517. u32 linip:1;
  518. u32 noacm:1;
  519. u32 gf:1;
  520. u32 own:1;
  521. u32 macid:5;
  522. u32 agg_en:1;
  523. u32 bk:1;
  524. u32 rdg_en:1;
  525. u32 queuesel:5;
  526. u32 rd_nav_ext:1;
  527. u32 lsig_txop_en:1;
  528. u32 pifs:1;
  529. u32 rateid:4;
  530. u32 nav_usehdr:1;
  531. u32 en_descid:1;
  532. u32 sectype:2;
  533. u32 pktoffset:8;
  534. u32 rts_rc:6;
  535. u32 data_rc:6;
  536. u32 rsvd0:2;
  537. u32 bar_retryht:2;
  538. u32 rsvd1:1;
  539. u32 morefrag:1;
  540. u32 raw:1;
  541. u32 ccx:1;
  542. u32 ampdudensity:3;
  543. u32 rsvd2:1;
  544. u32 ant_sela:1;
  545. u32 ant_selb:1;
  546. u32 txant_cck:2;
  547. u32 txant_l:2;
  548. u32 txant_ht:2;
  549. u32 nextheadpage:8;
  550. u32 tailpage:8;
  551. u32 seq:12;
  552. u32 pktid:4;
  553. u32 rtsrate:5;
  554. u32 apdcfe:1;
  555. u32 qos:1;
  556. u32 hwseq_enable:1;
  557. u32 userrate:1;
  558. u32 dis_rtsfb:1;
  559. u32 dis_datafb:1;
  560. u32 cts2self:1;
  561. u32 rts_en:1;
  562. u32 hwrts_en:1;
  563. u32 portid:1;
  564. u32 rsvd3:3;
  565. u32 waitdcts:1;
  566. u32 cts2ap_en:1;
  567. u32 txsc:2;
  568. u32 stbc:2;
  569. u32 txshort:1;
  570. u32 txbw:1;
  571. u32 rtsshort:1;
  572. u32 rtsbw:1;
  573. u32 rtssc:2;
  574. u32 rtsstbc:2;
  575. u32 txrate:6;
  576. u32 shortgi:1;
  577. u32 ccxt:1;
  578. u32 txrate_fb_lmt:5;
  579. u32 rtsrate_fb_lmt:4;
  580. u32 retrylmt_en:1;
  581. u32 txretrylmt:6;
  582. u32 usb_txaggnum:8;
  583. u32 txagca:5;
  584. u32 txagcb:5;
  585. u32 usemaxlen:1;
  586. u32 maxaggnum:5;
  587. u32 mcsg1maxlen:4;
  588. u32 mcsg2maxlen:4;
  589. u32 mcsg3maxlen:4;
  590. u32 mcs7sgimaxlen:4;
  591. u32 txbuffersize:16;
  592. u32 mcsg4maxlen:4;
  593. u32 mcsg5maxlen:4;
  594. u32 mcsg6maxlen:4;
  595. u32 mcsg15sgimaxlen:4;
  596. u32 txbuffaddr;
  597. u32 txbufferaddr64;
  598. u32 nextdescaddress;
  599. u32 nextdescaddress64;
  600. u32 reserve_pass_pcie_mm_limit[4];
  601. } __packed;
  602. struct rx_desc_92c {
  603. u32 length:14;
  604. u32 crc32:1;
  605. u32 icverror:1;
  606. u32 drv_infosize:4;
  607. u32 security:3;
  608. u32 qos:1;
  609. u32 shift:2;
  610. u32 phystatus:1;
  611. u32 swdec:1;
  612. u32 lastseg:1;
  613. u32 firstseg:1;
  614. u32 eor:1;
  615. u32 own:1;
  616. u32 macid:5;
  617. u32 tid:4;
  618. u32 hwrsvd:5;
  619. u32 paggr:1;
  620. u32 faggr:1;
  621. u32 a1_fit:4;
  622. u32 a2_fit:4;
  623. u32 pam:1;
  624. u32 pwr:1;
  625. u32 moredata:1;
  626. u32 morefrag:1;
  627. u32 type:2;
  628. u32 mc:1;
  629. u32 bc:1;
  630. u32 seq:12;
  631. u32 frag:4;
  632. u32 nextpktlen:14;
  633. u32 nextind:1;
  634. u32 rsvd:1;
  635. u32 rxmcs:6;
  636. u32 rxht:1;
  637. u32 amsdu:1;
  638. u32 splcp:1;
  639. u32 bandwidth:1;
  640. u32 htc:1;
  641. u32 tcpchk_rpt:1;
  642. u32 ipcchk_rpt:1;
  643. u32 tcpchk_valid:1;
  644. u32 hwpcerr:1;
  645. u32 hwpcind:1;
  646. u32 iv0:16;
  647. u32 iv1;
  648. u32 tsfl;
  649. u32 bufferaddress;
  650. u32 bufferaddress64;
  651. } __packed;
  652. void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw,
  653. struct ieee80211_hdr *hdr, u8 *pdesc,
  654. u8 *pbd_desc_tx, struct ieee80211_tx_info *info,
  655. struct ieee80211_sta *sta,
  656. struct sk_buff *skb, u8 hw_queue,
  657. struct rtl_tcb_desc *ptcb_desc);
  658. bool rtl92ce_rx_query_desc(struct ieee80211_hw *hw,
  659. struct rtl_stats *stats,
  660. struct ieee80211_rx_status *rx_status,
  661. u8 *pdesc, struct sk_buff *skb);
  662. void rtl92ce_set_desc(struct ieee80211_hw *hw, u8 *pdesc, bool istx,
  663. u8 desc_name, u8 *val);
  664. u64 rtl92ce_get_desc(struct ieee80211_hw *hw, u8 *p_desc,
  665. bool istx, u8 desc_name);
  666. bool rtl92ce_is_tx_desc_closed(struct ieee80211_hw *hw,
  667. u8 hw_queue, u16 index);
  668. void rtl92ce_tx_polling(struct ieee80211_hw *hw, u8 hw_queue);
  669. void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc,
  670. bool b_firstseg, bool b_lastseg,
  671. struct sk_buff *skb);
  672. #endif