trx.h 24 KB

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