hal_tx.h 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093
  1. /*
  2. * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #if !defined(HAL_TX_H)
  19. #define HAL_TX_H
  20. /*---------------------------------------------------------------------------
  21. Include files
  22. ---------------------------------------------------------------------------*/
  23. #include "hal_api.h"
  24. #include "wcss_version.h"
  25. #define WBM_RELEASE_RING_5_TX_RATE_STATS_OFFSET 0x00000014
  26. #define WBM_RELEASE_RING_5_TX_RATE_STATS_LSB 0
  27. #define WBM_RELEASE_RING_5_TX_RATE_STATS_MASK 0xffffffff
  28. /*---------------------------------------------------------------------------
  29. Preprocessor definitions and constants
  30. ---------------------------------------------------------------------------*/
  31. #define HAL_OFFSET(block, field) block ## _ ## field ## _OFFSET
  32. #define HAL_SET_FLD(desc, block , field) \
  33. (*(uint32_t *) ((uint8_t *) desc + HAL_OFFSET(block, field)))
  34. #define HAL_SET_FLD_OFFSET(desc, block , field, offset) \
  35. (*(uint32_t *) ((uint8_t *) desc + HAL_OFFSET(block, field) + (offset)))
  36. #define HAL_TX_DESC_SET_TLV_HDR(desc, tag, len) \
  37. do { \
  38. ((struct tlv_32_hdr *) desc)->tlv_tag = (tag); \
  39. ((struct tlv_32_hdr *) desc)->tlv_len = (len); \
  40. } while (0)
  41. #define HAL_TX_TCL_DATA_TAG WIFITCL_DATA_CMD_E
  42. #define HAL_TX_TCL_CMD_TAG WIFITCL_GSE_CMD_E
  43. #define HAL_TX_SM(block, field, value) \
  44. ((value << (block ## _ ## field ## _LSB)) & \
  45. (block ## _ ## field ## _MASK))
  46. #define HAL_TX_MS(block, field, value) \
  47. (((value) & (block ## _ ## field ## _MASK)) >> \
  48. (block ## _ ## field ## _LSB))
  49. #define HAL_TX_DESC_GET(desc, block, field) \
  50. HAL_TX_MS(block, field, HAL_SET_FLD(desc, block, field))
  51. #define HAL_TX_DESC_SUBBLOCK_GET(desc, block, sub, field) \
  52. HAL_TX_MS(sub, field, HAL_SET_FLD(desc, block, sub))
  53. #define HAL_TX_BUF_TYPE_BUFFER 0
  54. #define HAL_TX_BUF_TYPE_EXT_DESC 1
  55. #define HAL_TX_DESC_LEN_DWORDS (NUM_OF_DWORDS_TCL_DATA_CMD)
  56. #define HAL_TX_DESC_LEN_BYTES (NUM_OF_DWORDS_TCL_DATA_CMD * 4)
  57. #define HAL_TX_EXTENSION_DESC_LEN_DWORDS (NUM_OF_DWORDS_TX_MSDU_EXTENSION)
  58. #define HAL_TX_EXTENSION_DESC_LEN_BYTES (NUM_OF_DWORDS_TX_MSDU_EXTENSION * 4)
  59. #define HAL_TX_COMPLETION_DESC_LEN_DWORDS (NUM_OF_DWORDS_WBM_RELEASE_RING)
  60. #define HAL_TX_COMPLETION_DESC_LEN_BYTES (NUM_OF_DWORDS_WBM_RELEASE_RING*4)
  61. #define HAL_TX_BITS_PER_TID 3
  62. #define HAL_TX_NUM_DSCP_PER_REGISTER 10
  63. #define HAL_MAX_HW_DSCP_TID_MAPS 2
  64. #define HTT_META_HEADER_LEN_BYTES 64
  65. #define HAL_TX_EXT_DESC_WITH_META_DATA \
  66. (HTT_META_HEADER_LEN_BYTES + HAL_TX_EXTENSION_DESC_LEN_BYTES)
  67. /* Length of WBM release ring without the status words */
  68. #define HAL_TX_COMPLETION_DESC_BASE_LEN 12
  69. #define HAL_TX_COMP_RELEASE_SOURCE_TQM 0
  70. #define HAL_TX_COMP_RELEASE_SOURCE_FW 3
  71. /* Define a place-holder release reason for FW */
  72. #define HAL_TX_COMP_RELEASE_REASON_FW 99
  73. /*
  74. * Offset of HTT Tx Descriptor in WBM Completion
  75. * HTT Tx Desc structure is passed from firmware to host overlayed
  76. * on wbm_release_ring DWORD 3 and 4 for software based completions
  77. * (Exception frames and TQM bypass frames)
  78. */
  79. #define HAL_TX_COMP_HTT_STATUS_OFFSET 12
  80. #define HAL_TX_COMP_HTT_STATUS_LEN 8
  81. #define HAL_TX_BUF_TYPE_BUFFER 0
  82. #define HAL_TX_BUF_TYPE_EXT_DESC 1
  83. #define HAL_TX_EXT_DESC_BUF_OFFSET TX_MSDU_EXTENSION_6_BUF0_PTR_31_0_OFFSET
  84. #define HAL_TX_EXT_BUF_LOW_MASK TX_MSDU_EXTENSION_6_BUF0_PTR_31_0_MASK
  85. #define HAL_TX_EXT_BUF_HI_MASK TX_MSDU_EXTENSION_7_BUF0_PTR_39_32_MASK
  86. #define HAL_TX_EXT_BUF_LEN_MASK TX_MSDU_EXTENSION_7_BUF0_LEN_MASK
  87. #define HAL_TX_EXT_BUF_LEN_LSB TX_MSDU_EXTENSION_7_BUF0_LEN_LSB
  88. #define HAL_TX_EXT_BUF_WD_SIZE 2
  89. #define HAL_TX_DESC_ADDRX_EN 0x1
  90. #define HAL_TX_DESC_ADDRY_EN 0x2
  91. enum hal_tx_ret_buf_manager {
  92. HAL_WBM_SW0_BM_ID = 3,
  93. HAL_WBM_SW1_BM_ID = 4,
  94. HAL_WBM_SW2_BM_ID = 5,
  95. HAL_WBM_SW3_BM_ID = 6,
  96. };
  97. /*---------------------------------------------------------------------------
  98. Structures
  99. ---------------------------------------------------------------------------*/
  100. /**
  101. * struct hal_tx_completion_status - HAL Tx completion descriptor contents
  102. * @ack_frame_rssi: RSSI of the received ACK or BA frame
  103. * @first_msdu: Indicates this MSDU is the first MSDU in AMSDU
  104. * @last_msdu: Indicates this MSDU is the last MSDU in AMSDU
  105. * @msdu_part_of_amsdu : Indicates this MSDU was part of an A-MSDU in MPDU
  106. * @bw: Indicates the BW of the upcoming transmission -
  107. * <enum 0 transmit_bw_20_MHz>
  108. * <enum 1 transmit_bw_40_MHz>
  109. * <enum 2 transmit_bw_80_MHz>
  110. * <enum 3 transmit_bw_160_MHz>
  111. * @pkt_type: Transmit Packet Type
  112. * @stbc: When set, STBC transmission rate was used
  113. * @ldpc: When set, use LDPC transmission rates
  114. * @sgi: <enum 0 0_8_us_sgi > Legacy normal GI
  115. * <enum 1 0_4_us_sgi > Legacy short GI
  116. * <enum 2 1_6_us_sgi > HE related GI
  117. * <enum 3 3_2_us_sgi > HE
  118. * @mcs: Transmit MCS Rate
  119. * @ofdma: Set when the transmission was an OFDMA transmission
  120. * @tones_in_ru: The number of tones in the RU used.
  121. * @tsf: Lower 32 bits of the TSF
  122. * @ppdu_id: TSF, snapshot of this value when transmission of the
  123. * PPDU containing the frame finished.
  124. * @transmit_cnt: Number of times this frame has been transmitted
  125. * @tid: TID of the flow or MPDU queue
  126. * @peer_id: Peer ID of the flow or MPDU queue
  127. */
  128. struct hal_tx_completion_status {
  129. uint8_t ack_frame_rssi;
  130. uint8_t first_msdu:1,
  131. last_msdu:1,
  132. msdu_part_of_amsdu:1;
  133. uint32_t bw:2,
  134. pkt_type:4,
  135. stbc:1,
  136. ldpc:1,
  137. sgi:2,
  138. mcs:2,
  139. ofdma:1,
  140. tones_in_ru:10,
  141. valid:1;
  142. uint32_t tsf;
  143. uint32_t ppdu_id;
  144. uint8_t transmit_cnt;
  145. uint8_t tid;
  146. uint16_t peer_id;
  147. };
  148. /**
  149. * struct hal_tx_desc_comp_s - hal tx completion descriptor contents
  150. * @desc: Transmit status information from descriptor
  151. */
  152. struct hal_tx_desc_comp_s {
  153. uint32_t desc[HAL_TX_COMPLETION_DESC_LEN_DWORDS];
  154. };
  155. /*
  156. * enum hal_tx_encrypt_type - Type of decrypt cipher used (valid only for RAW)
  157. * @HAL_TX_ENCRYPT_TYPE_WEP_40: WEP 40-bit
  158. * @HAL_TX_ENCRYPT_TYPE_WEP_10: WEP 10-bit
  159. * @HAL_TX_ENCRYPT_TYPE_TKIP_NO_MIC: TKIP without MIC
  160. * @HAL_TX_ENCRYPT_TYPE_WEP_128: WEP_128
  161. * @HAL_TX_ENCRYPT_TYPE_TKIP_WITH_MIC: TKIP_WITH_MIC
  162. * @HAL_TX_ENCRYPT_TYPE_WAPI: WAPI
  163. * @HAL_TX_ENCRYPT_TYPE_AES_CCMP_128: AES_CCMP_128
  164. * @HAL_TX_ENCRYPT_TYPE_NO_CIPHER: NO CIPHER
  165. * @HAL_TX_ENCRYPT_TYPE_AES_CCMP_256: AES_CCMP_256
  166. * @HAL_TX_ENCRYPT_TYPE_AES_GCMP_128: AES_GCMP_128
  167. * @HAL_TX_ENCRYPT_TYPE_AES_GCMP_256: AES_GCMP_256
  168. * @HAL_TX_ENCRYPT_TYPE_WAPI_GCM_SM4: WAPI GCM SM4
  169. */
  170. enum hal_tx_encrypt_type {
  171. HAL_TX_ENCRYPT_TYPE_WEP_40 = 0,
  172. HAL_TX_ENCRYPT_TYPE_WEP_104 = 1 ,
  173. HAL_TX_ENCRYPT_TYPE_TKIP_NO_MIC = 2,
  174. HAL_TX_ENCRYPT_TYPE_WEP_128 = 3,
  175. HAL_TX_ENCRYPT_TYPE_TKIP_WITH_MIC = 4,
  176. HAL_TX_ENCRYPT_TYPE_WAPI = 5,
  177. HAL_TX_ENCRYPT_TYPE_AES_CCMP_128 = 6,
  178. HAL_TX_ENCRYPT_TYPE_NO_CIPHER = 7,
  179. HAL_TX_ENCRYPT_TYPE_AES_CCMP_256 = 8,
  180. HAL_TX_ENCRYPT_TYPE_AES_GCMP_128 = 9,
  181. HAL_TX_ENCRYPT_TYPE_AES_GCMP_256 = 10,
  182. HAL_TX_ENCRYPT_TYPE_WAPI_GCM_SM4 = 11,
  183. };
  184. /*
  185. * enum hal_tx_encap_type - Encapsulation type that HW will perform
  186. * @HAL_TX_ENCAP_TYPE_RAW: Raw Packet Type
  187. * @HAL_TX_ENCAP_TYPE_NWIFI: Native WiFi Type
  188. * @HAL_TX_ENCAP_TYPE_ETHERNET: Ethernet
  189. * @HAL_TX_ENCAP_TYPE_802_3: 802.3 Frame
  190. */
  191. enum hal_tx_encap_type {
  192. HAL_TX_ENCAP_TYPE_RAW = 0,
  193. HAL_TX_ENCAP_TYPE_NWIFI = 1,
  194. HAL_TX_ENCAP_TYPE_ETHERNET = 2,
  195. HAL_TX_ENCAP_TYPE_802_3 = 3,
  196. };
  197. /**
  198. * enum hal_tx_tqm_release_reason - TQM Release reason codes
  199. *
  200. * @HAL_TX_TQM_RR_FRAME_ACKED : ACK of BA for it was received
  201. * @HAL_TX_TQM_RR_REM_CMD_REM : Remove cmd of type “Remove_mpdus” initiated
  202. * by SW
  203. * @HAL_TX_TQM_RR_REM_CMD_TX : Remove command of type Remove_transmitted_mpdus
  204. * initiated by SW
  205. * @HAL_TX_TQM_RR_REM_CMD_NOTX : Remove cmd of type Remove_untransmitted_mpdus
  206. * initiated by SW
  207. * @HAL_TX_TQM_RR_REM_CMD_AGED : Remove command of type “Remove_aged_mpdus” or
  208. * “Remove_aged_msdus” initiated by SW
  209. * @HAL_TX_TQM_RR_FW_REASON1 : Remove command where fw indicated that
  210. * remove reason is fw_reason1
  211. * @HAL_TX_TQM_RR_FW_REASON2 : Remove command where fw indicated that
  212. * remove reason is fw_reason2
  213. * @HAL_TX_TQM_RR_FW_REASON3 : Remove command where fw indicated that
  214. * remove reason is fw_reason3
  215. */
  216. enum hal_tx_tqm_release_reason {
  217. HAL_TX_TQM_RR_FRAME_ACKED,
  218. HAL_TX_TQM_RR_REM_CMD_REM,
  219. HAL_TX_TQM_RR_REM_CMD_TX,
  220. HAL_TX_TQM_RR_REM_CMD_NOTX,
  221. HAL_TX_TQM_RR_REM_CMD_AGED,
  222. HAL_TX_TQM_RR_FW_REASON1,
  223. HAL_TX_TQM_RR_FW_REASON2,
  224. HAL_TX_TQM_RR_FW_REASON3,
  225. };
  226. /* enum - Table IDs for 2 DSCP-TID mapping Tables that TCL H/W supports
  227. * @HAL_TX_DSCP_TID_MAP_TABLE_DEFAULT: Default DSCP-TID mapping table
  228. * @HAL_TX_DSCP_TID_MAP_TABLE_OVERRIDE: DSCP-TID map override table
  229. */
  230. enum hal_tx_dscp_tid_table_id {
  231. HAL_TX_DSCP_TID_MAP_TABLE_DEFAULT,
  232. HAL_TX_DSCP_TID_MAP_TABLE_OVERRIDE,
  233. };
  234. /*---------------------------------------------------------------------------
  235. Function declarations and documentation
  236. ---------------------------------------------------------------------------*/
  237. /*---------------------------------------------------------------------------
  238. TCL Descriptor accessor APIs
  239. ---------------------------------------------------------------------------*/
  240. /**
  241. * hal_tx_desc_set_buf_addr - Fill Buffer Address information in Tx Descriptor
  242. * @desc: Handle to Tx Descriptor
  243. * @paddr: Physical Address
  244. * @pool_id: Return Buffer Manager ID
  245. * @desc_id: Descriptor ID
  246. * @type: 0 - Address points to a MSDU buffer
  247. * 1 - Address points to MSDU extension descriptor
  248. *
  249. * Return: void
  250. */
  251. static inline void hal_tx_desc_set_buf_addr(void *desc,
  252. dma_addr_t paddr, uint8_t pool_id,
  253. uint32_t desc_id, uint8_t type)
  254. {
  255. /* Set buffer_addr_info.buffer_addr_31_0 */
  256. HAL_SET_FLD(desc, TCL_DATA_CMD_0, BUFFER_ADDR_INFO_BUF_ADDR_INFO) =
  257. HAL_TX_SM(BUFFER_ADDR_INFO_0, BUFFER_ADDR_31_0, paddr);
  258. /* Set buffer_addr_info.buffer_addr_39_32 */
  259. HAL_SET_FLD(desc, TCL_DATA_CMD_1,
  260. BUFFER_ADDR_INFO_BUF_ADDR_INFO) |=
  261. HAL_TX_SM(BUFFER_ADDR_INFO_1, BUFFER_ADDR_39_32,
  262. (((uint64_t) paddr) >> 32));
  263. /* Set buffer_addr_info.return_buffer_manager = pool id */
  264. HAL_SET_FLD(desc, TCL_DATA_CMD_1,
  265. BUFFER_ADDR_INFO_BUF_ADDR_INFO) |=
  266. HAL_TX_SM(BUFFER_ADDR_INFO_1,
  267. RETURN_BUFFER_MANAGER, (pool_id + HAL_WBM_SW0_BM_ID));
  268. /* Set buffer_addr_info.sw_buffer_cookie = desc_id */
  269. HAL_SET_FLD(desc, TCL_DATA_CMD_1,
  270. BUFFER_ADDR_INFO_BUF_ADDR_INFO) |=
  271. HAL_TX_SM(BUFFER_ADDR_INFO_1, SW_BUFFER_COOKIE, desc_id);
  272. /* Set Buffer or Ext Descriptor Type */
  273. HAL_SET_FLD(desc, TCL_DATA_CMD_2,
  274. BUF_OR_EXT_DESC_TYPE) |=
  275. HAL_TX_SM(TCL_DATA_CMD_2, BUF_OR_EXT_DESC_TYPE, type);
  276. }
  277. /**
  278. * hal_tx_desc_set_buf_length - Set Data length in bytes in Tx Descriptor
  279. * @desc: Handle to Tx Descriptor
  280. * @data_length: MSDU length in case of direct descriptor.
  281. * Length of link extension descriptor in case of Link extension
  282. * descriptor.Includes the length of Metadata
  283. * Return: None
  284. */
  285. static inline void hal_tx_desc_set_buf_length(void *desc,
  286. uint16_t data_length)
  287. {
  288. HAL_SET_FLD(desc, TCL_DATA_CMD_3, DATA_LENGTH) |=
  289. HAL_TX_SM(TCL_DATA_CMD_3, DATA_LENGTH, data_length);
  290. }
  291. /**
  292. * hal_tx_desc_set_buf_offset - Sets Packet Offset field in Tx descriptor
  293. * @desc: Handle to Tx Descriptor
  294. * @offset: Packet offset from Metadata in case of direct buffer descriptor.
  295. *
  296. * Return: void
  297. */
  298. static inline void hal_tx_desc_set_buf_offset(void *desc,
  299. uint8_t offset)
  300. {
  301. HAL_SET_FLD(desc, TCL_DATA_CMD_3, PACKET_OFFSET) |=
  302. HAL_TX_SM(TCL_DATA_CMD_3, PACKET_OFFSET, offset);
  303. }
  304. /**
  305. * hal_tx_desc_set_encap_type - Set encapsulation type in Tx Descriptor
  306. * @desc: Handle to Tx Descriptor
  307. * @encap_type: Encapsulation that HW will perform
  308. *
  309. * Return: void
  310. *
  311. */
  312. static inline void hal_tx_desc_set_encap_type(void *desc,
  313. enum hal_tx_encap_type encap_type)
  314. {
  315. HAL_SET_FLD(desc, TCL_DATA_CMD_2, ENCAP_TYPE) |=
  316. HAL_TX_SM(TCL_DATA_CMD_2, ENCAP_TYPE, encap_type);
  317. }
  318. /**
  319. * hal_tx_desc_set_encrypt_type - Sets the Encrypt Type in Tx Descriptor
  320. * @desc: Handle to Tx Descriptor
  321. * @type: Encrypt Type
  322. *
  323. * Return: void
  324. */
  325. static inline void hal_tx_desc_set_encrypt_type(void *desc,
  326. enum hal_tx_encrypt_type type)
  327. {
  328. HAL_SET_FLD(desc, TCL_DATA_CMD_2, ENCRYPT_TYPE) |=
  329. HAL_TX_SM(TCL_DATA_CMD_2, ENCRYPT_TYPE, type);
  330. }
  331. /**
  332. * hal_tx_desc_set_addr_search_flags - Enable AddrX and AddrY search flags
  333. * @desc: Handle to Tx Descriptor
  334. * @flags: Bit 0 - AddrY search enable, Bit 1 - AddrX search enable
  335. *
  336. * Return: void
  337. */
  338. static inline void hal_tx_desc_set_addr_search_flags(void *desc,
  339. uint8_t flags)
  340. {
  341. HAL_SET_FLD(desc, TCL_DATA_CMD_2, ADDRX_EN) |=
  342. HAL_TX_SM(TCL_DATA_CMD_2, ADDRX_EN, (flags & 0x1));
  343. HAL_SET_FLD(desc, TCL_DATA_CMD_2, ADDRY_EN) |=
  344. HAL_TX_SM(TCL_DATA_CMD_2, ADDRY_EN, (flags >> 1));
  345. }
  346. /**
  347. * hal_tx_desc_set_l4_checksum_en - Set TCP/IP checksum enable flags
  348. * Tx Descriptor for MSDU_buffer type
  349. * @desc: Handle to Tx Descriptor
  350. * @en: UDP/TCP over ipv4/ipv6 checksum enable flags (5 bits)
  351. *
  352. * Return: void
  353. */
  354. static inline void hal_tx_desc_set_l4_checksum_en(void *desc,
  355. uint8_t en)
  356. {
  357. HAL_SET_FLD(desc, TCL_DATA_CMD_3, IPV4_CHECKSUM_EN) |=
  358. (HAL_TX_SM(TCL_DATA_CMD_3, UDP_OVER_IPV4_CHECKSUM_EN, en) |
  359. HAL_TX_SM(TCL_DATA_CMD_3, UDP_OVER_IPV6_CHECKSUM_EN, en) |
  360. HAL_TX_SM(TCL_DATA_CMD_3, TCP_OVER_IPV4_CHECKSUM_EN, en) |
  361. HAL_TX_SM(TCL_DATA_CMD_3, TCP_OVER_IPV6_CHECKSUM_EN, en));
  362. }
  363. /**
  364. * hal_tx_desc_set_l3_checksum_en - Set IPv4 checksum enable flag in
  365. * Tx Descriptor for MSDU_buffer type
  366. * @desc: Handle to Tx Descriptor
  367. * @checksum_en_flags: ipv4 checksum enable flags
  368. *
  369. * Return: void
  370. */
  371. static inline void hal_tx_desc_set_l3_checksum_en(void *desc,
  372. uint8_t en)
  373. {
  374. HAL_SET_FLD(desc, TCL_DATA_CMD_3, IPV4_CHECKSUM_EN) |=
  375. HAL_TX_SM(TCL_DATA_CMD_3, IPV4_CHECKSUM_EN, en);
  376. }
  377. /**
  378. * hal_tx_desc_set_fw_metadata- Sets the metadata that is part of TCL descriptor
  379. * @desc:Handle to Tx Descriptor
  380. * @metadata: Metadata to be sent to Firmware
  381. *
  382. * Return: void
  383. */
  384. static inline void hal_tx_desc_set_fw_metadata(void *desc,
  385. uint16_t metadata)
  386. {
  387. HAL_SET_FLD(desc, TCL_DATA_CMD_2, TCL_CMD_NUMBER) |=
  388. HAL_TX_SM(TCL_DATA_CMD_2, TCL_CMD_NUMBER, metadata);
  389. }
  390. /**
  391. * hal_tx_desc_set_to_fw - Set To_FW bit in Tx Descriptor.
  392. * @desc:Handle to Tx Descriptor
  393. * @to_fw: if set, Forward packet to FW along with classification result
  394. *
  395. * Return: void
  396. */
  397. static inline void hal_tx_desc_set_to_fw(void *desc, uint8_t to_fw)
  398. {
  399. HAL_SET_FLD(desc, TCL_DATA_CMD_3, TO_FW) |=
  400. HAL_TX_SM(TCL_DATA_CMD_3, TO_FW, to_fw);
  401. }
  402. /**
  403. * hal_tx_desc_set_dscp_tid_table_id - Sets DSCP to TID conversion table ID
  404. * @desc: Handle to Tx Descriptor
  405. * @id: DSCP to tid conversion table to be used for this frame
  406. *
  407. * Return: void
  408. */
  409. static inline void hal_tx_desc_set_dscp_tid_table_id(void *desc,
  410. uint8_t id)
  411. {
  412. HAL_SET_FLD(desc, TCL_DATA_CMD_3,
  413. DSCP_TO_TID_PRIORITY_TABLE_ID) |=
  414. HAL_TX_SM(TCL_DATA_CMD_3,
  415. DSCP_TO_TID_PRIORITY_TABLE_ID, id);
  416. }
  417. /**
  418. * hal_tx_desc_set_mesh_en - Set mesh_enable flag in Tx descriptor
  419. * @desc: Handle to Tx Descriptor
  420. * @en: For raw WiFi frames, this indicates transmission to a mesh STA,
  421. * enabling the interpretation of the 'Mesh Control Present' bit
  422. * (bit 8) of QoS Control (otherwise this bit is ignored),
  423. * For native WiFi frames, this indicates that a 'Mesh Control' field
  424. * is present between the header and the LLC.
  425. *
  426. * Return: void
  427. */
  428. static inline void hal_tx_desc_set_mesh_en(void *desc, uint8_t en)
  429. {
  430. HAL_SET_FLD(desc, TCL_DATA_CMD_4, MESH_ENABLE) |=
  431. HAL_TX_SM(TCL_DATA_CMD_4, MESH_ENABLE, en);
  432. }
  433. /**
  434. * hal_tx_desc_set_hlos_tid - Set the TID value (override DSCP/PCP fields in
  435. * frame) to be used for Tx Frame
  436. * @desc: Handle to Tx Descriptor
  437. * @hlos_tid: HLOS TID
  438. *
  439. * Return: void
  440. */
  441. static inline void hal_tx_desc_set_hlos_tid(void *desc,
  442. uint8_t hlos_tid)
  443. {
  444. HAL_SET_FLD(desc, TCL_DATA_CMD_4, HLOS_TID) |=
  445. HAL_TX_SM(TCL_DATA_CMD_4, HLOS_TID, hlos_tid);
  446. HAL_SET_FLD(desc, TCL_DATA_CMD_4, HLOS_TID_OVERWRITE) |=
  447. HAL_TX_SM(TCL_DATA_CMD_4, HLOS_TID_OVERWRITE, 1);
  448. }
  449. /**
  450. * hal_tx_desc_sync - Commit the descriptor to Hardware
  451. * @hal_tx_des_cached: Cached descriptor that software maintains
  452. * @hw_desc: Hardware descriptor to be updated
  453. */
  454. static inline void hal_tx_desc_sync(void *hal_tx_desc_cached,
  455. void *hw_desc)
  456. {
  457. qdf_mem_copy((hw_desc + sizeof(struct tlv_32_hdr)),
  458. hal_tx_desc_cached, 20);
  459. }
  460. /*---------------------------------------------------------------------------
  461. Tx MSDU Extension Descriptor accessor APIs
  462. ---------------------------------------------------------------------------*/
  463. /**
  464. * hal_tx_ext_desc_set_tso_enable() - Set TSO Enable Flag
  465. * @desc: Handle to Tx MSDU Extension Descriptor
  466. * @tso_en: bool value set to true if TSO is enabled
  467. *
  468. * Return: none
  469. */
  470. static inline void hal_tx_ext_desc_set_tso_enable(void *desc,
  471. uint8_t tso_en)
  472. {
  473. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_0, TSO_ENABLE) |=
  474. HAL_TX_SM(TX_MSDU_EXTENSION_0, TSO_ENABLE, tso_en);
  475. }
  476. /**
  477. * hal_tx_ext_desc_set_tso_flags() - Set TSO Flags
  478. * @desc: Handle to Tx MSDU Extension Descriptor
  479. * @falgs: 32-bit word with all TSO flags consolidated
  480. *
  481. * Return: none
  482. */
  483. static inline void hal_tx_ext_desc_set_tso_flags(void *desc,
  484. uint32_t tso_flags)
  485. {
  486. HAL_SET_FLD_OFFSET(desc, TX_MSDU_EXTENSION_0, TSO_ENABLE, 0) =
  487. tso_flags;
  488. }
  489. /**
  490. * hal_tx_ext_desc_set_checksum_en() - Enable HW Checksum offload
  491. * @desc: Handle to Tx MSDU Extension Descriptor
  492. * @en: Checksum offload enable
  493. *
  494. * Return: none
  495. */
  496. static inline void hal_tx_ext_desc_set_checksum_en(void *desc,
  497. uint8_t en)
  498. {
  499. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_0, IPV4_CHECKSUM_EN) |=
  500. ((HAL_TX_SM(TX_MSDU_EXTENSION_0, IPV4_CHECKSUM_EN, en)) |
  501. (HAL_TX_SM(TX_MSDU_EXTENSION_0, UDP_OVER_IPV4_CHECKSUM_EN, en)) |
  502. (HAL_TX_SM(TX_MSDU_EXTENSION_0, UDP_OVER_IPV6_CHECKSUM_EN, en)) |
  503. (HAL_TX_SM(TX_MSDU_EXTENSION_0, TCP_OVER_IPV4_CHECKSUM_EN, en)) |
  504. (HAL_TX_SM(TX_MSDU_EXTENSION_0, TCP_OVER_IPV6_CHECKSUM_EN, en)));
  505. }
  506. /**
  507. * hal_tx_ext_desc_set_tcp_flags() - Enable HW Checksum offload
  508. * @desc: Handle to Tx MSDU Extension Descriptor
  509. * @tcp_flags: TCP flags {NS,CWR,ECE,URG,ACK,PSH, RST ,SYN,FIN}
  510. * @mask: TCP flag mask. Tcp_flag is inserted into the header
  511. * based on the mask, if tso is enabled
  512. *
  513. * Return: none
  514. */
  515. static inline void hal_tx_ext_desc_set_tcp_flags(void *desc,
  516. uint16_t tcp_flags,
  517. uint16_t mask)
  518. {
  519. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_0, TCP_FLAG) |=
  520. ((HAL_TX_SM(TX_MSDU_EXTENSION_0, TCP_FLAG, tcp_flags)) |
  521. (HAL_TX_SM(TX_MSDU_EXTENSION_0, TCP_FLAG_MASK, mask)));
  522. }
  523. /**
  524. * hal_tx_ext_desc_set_msdu_length() - Set L2 and IP Lengths
  525. * @desc: Handle to Tx MSDU Extension Descriptor
  526. * @l2_len: L2 length for the msdu, if tso is enabled
  527. * @ip_len: IP length for the msdu, if tso is enabled
  528. *
  529. * Return: none
  530. */
  531. static inline void hal_tx_ext_desc_set_msdu_length(void *desc,
  532. uint16_t l2_len,
  533. uint16_t ip_len)
  534. {
  535. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_1, L2_LENGTH) |=
  536. ((HAL_TX_SM(TX_MSDU_EXTENSION_1, L2_LENGTH, l2_len)) |
  537. (HAL_TX_SM(TX_MSDU_EXTENSION_1, IP_LENGTH, ip_len)));
  538. }
  539. /**
  540. * hal_tx_ext_desc_set_tcp_seq() - Set TCP Sequence number
  541. * @desc: Handle to Tx MSDU Extension Descriptor
  542. * @seq_num: Tcp_seq_number for the msdu, if tso is enabled
  543. *
  544. * Return: none
  545. */
  546. static inline void hal_tx_ext_desc_set_tcp_seq(void *desc,
  547. uint32_t seq_num)
  548. {
  549. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_2, TCP_SEQ_NUMBER) |=
  550. ((HAL_TX_SM(TX_MSDU_EXTENSION_2, TCP_SEQ_NUMBER, seq_num)));
  551. }
  552. /**
  553. * hal_tx_ext_desc_set_ip_id() - Set IP Identification field
  554. * @desc: Handle to Tx MSDU Extension Descriptor
  555. * @id: IP Id field for the msdu, if tso is enabled
  556. *
  557. * Return: none
  558. */
  559. static inline void hal_tx_ext_desc_set_ip_id(void *desc,
  560. uint16_t id)
  561. {
  562. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_3, IP_IDENTIFICATION) |=
  563. ((HAL_TX_SM(TX_MSDU_EXTENSION_3, IP_IDENTIFICATION, id)));
  564. }
  565. /**
  566. * hal_tx_ext_desc_set_buffer() - Set Buffer Pointer and Length for a fragment
  567. * @desc: Handle to Tx MSDU Extension Descriptor
  568. * @frag_num: Fragment number (value can be 0 to 5)
  569. * @paddr_lo: Lower 32-bit of Buffer Physical address
  570. * @paddr_hi: Upper 32-bit of Buffer Physical address
  571. * @length: Buffer Length
  572. *
  573. * Return: none
  574. */
  575. static inline void hal_tx_ext_desc_set_buffer(void *desc,
  576. uint8_t frag_num,
  577. uint32_t paddr_lo,
  578. uint16_t paddr_hi,
  579. uint16_t length)
  580. {
  581. HAL_SET_FLD_OFFSET(desc, TX_MSDU_EXTENSION_6, BUF0_PTR_31_0,
  582. (frag_num << 3)) |=
  583. ((HAL_TX_SM(TX_MSDU_EXTENSION_6, BUF0_PTR_31_0, paddr_lo)));
  584. HAL_SET_FLD_OFFSET(desc, TX_MSDU_EXTENSION_7, BUF0_PTR_39_32,
  585. (frag_num << 3)) |=
  586. ((HAL_TX_SM(TX_MSDU_EXTENSION_7, BUF0_PTR_39_32,
  587. (paddr_hi))));
  588. HAL_SET_FLD_OFFSET(desc, TX_MSDU_EXTENSION_7, BUF0_LEN,
  589. (frag_num << 3)) |=
  590. ((HAL_TX_SM(TX_MSDU_EXTENSION_7, BUF0_LEN, length)));
  591. }
  592. /**
  593. * hal_tx_ext_desc_set_buffer0_param() - Set Buffer 0 Pointer and Length
  594. * @desc: Handle to Tx MSDU Extension Descriptor
  595. * @paddr_lo: Lower 32-bit of Buffer Physical address
  596. * @paddr_hi: Upper 32-bit of Buffer Physical address
  597. * @length: Buffer 0 Length
  598. *
  599. * Return: none
  600. */
  601. static inline void hal_tx_ext_desc_set_buffer0_param(void *desc,
  602. uint32_t paddr_lo,
  603. uint16_t paddr_hi,
  604. uint16_t length)
  605. {
  606. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_6, BUF0_PTR_31_0) |=
  607. ((HAL_TX_SM(TX_MSDU_EXTENSION_6, BUF0_PTR_31_0, paddr_lo)));
  608. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_7, BUF0_PTR_39_32) |=
  609. ((HAL_TX_SM(TX_MSDU_EXTENSION_7,
  610. BUF0_PTR_39_32, paddr_hi)));
  611. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_7, BUF0_LEN) |=
  612. ((HAL_TX_SM(TX_MSDU_EXTENSION_7, BUF0_LEN, length)));
  613. }
  614. /**
  615. * hal_tx_ext_desc_set_buffer1_param() - Set Buffer 1 Pointer and Length
  616. * @desc: Handle to Tx MSDU Extension Descriptor
  617. * @paddr_lo: Lower 32-bit of Buffer Physical address
  618. * @paddr_hi: Upper 32-bit of Buffer Physical address
  619. * @length: Buffer 1 Length
  620. *
  621. * Return: none
  622. */
  623. static inline void hal_tx_ext_desc_set_buffer1_param(void *desc,
  624. uint32_t paddr_lo,
  625. uint16_t paddr_hi,
  626. uint16_t length)
  627. {
  628. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_8, BUF1_PTR_31_0) |=
  629. ((HAL_TX_SM(TX_MSDU_EXTENSION_8, BUF1_PTR_31_0, paddr_lo)));
  630. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_9, BUF1_PTR_39_32) |=
  631. ((HAL_TX_SM(TX_MSDU_EXTENSION_9,
  632. BUF1_PTR_39_32, paddr_hi)));
  633. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_9, BUF1_LEN) |=
  634. ((HAL_TX_SM(TX_MSDU_EXTENSION_9, BUF1_LEN, length)));
  635. }
  636. /**
  637. * hal_tx_ext_desc_set_buffer2_param() - Set Buffer 2 Pointer and Length
  638. * @desc: Handle to Tx MSDU Extension Descriptor
  639. * @paddr_lo: Lower 32-bit of Buffer Physical address
  640. * @paddr_hi: Upper 32-bit of Buffer Physical address
  641. * @length: Buffer 2 Length
  642. *
  643. * Return: none
  644. */
  645. static inline void hal_tx_ext_desc_set_buffer2_param(void *desc,
  646. uint32_t paddr_lo,
  647. uint16_t paddr_hi,
  648. uint16_t length)
  649. {
  650. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_10, BUF2_PTR_31_0) |=
  651. ((HAL_TX_SM(TX_MSDU_EXTENSION_10, BUF2_PTR_31_0,
  652. paddr_lo)));
  653. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_11, BUF2_PTR_39_32) |=
  654. ((HAL_TX_SM(TX_MSDU_EXTENSION_11, BUF2_PTR_39_32,
  655. paddr_hi)));
  656. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_11, BUF2_LEN) |=
  657. ((HAL_TX_SM(TX_MSDU_EXTENSION_11, BUF2_LEN, length)));
  658. }
  659. /**
  660. * hal_tx_ext_desc_sync - Commit the descriptor to Hardware
  661. * @desc_cached: Cached descriptor that software maintains
  662. * @hw_desc: Hardware descriptor to be updated
  663. *
  664. * Return: none
  665. */
  666. static inline void hal_tx_ext_desc_sync(uint8_t *desc_cached,
  667. uint8_t *hw_desc)
  668. {
  669. qdf_mem_copy(&hw_desc[0], &desc_cached[0],
  670. HAL_TX_EXT_DESC_WITH_META_DATA);
  671. }
  672. /**
  673. * hal_tx_ext_desc_get_tso_enable() - Set TSO Enable Flag
  674. * @hal_tx_ext_desc: Handle to Tx MSDU Extension Descriptor
  675. *
  676. * Return: tso_enable value in the descriptor
  677. */
  678. static inline uint32_t hal_tx_ext_desc_get_tso_enable(void *hal_tx_ext_desc)
  679. {
  680. uint32_t *desc = (uint32_t *) hal_tx_ext_desc;
  681. return (*desc & TX_MSDU_EXTENSION_0_TSO_ENABLE_MASK) >>
  682. TX_MSDU_EXTENSION_0_TSO_ENABLE_LSB;
  683. }
  684. /*---------------------------------------------------------------------------
  685. WBM Descriptor accessor APIs for Tx completions
  686. ---------------------------------------------------------------------------*/
  687. /**
  688. * hal_tx_comp_get_desc_id() - Get TX descriptor id within comp descriptor
  689. * @hal_desc: completion ring descriptor pointer
  690. *
  691. * This function will tx descriptor id, cookie, within hardware completion
  692. * descriptor
  693. *
  694. * Return: cookie
  695. */
  696. static inline uint32_t hal_tx_comp_get_desc_id(void *hal_desc)
  697. {
  698. uint32_t comp_desc =
  699. *(uint32_t *) (((uint8_t *) hal_desc) +
  700. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET);
  701. /* Cookie is placed on 2nd word */
  702. return (comp_desc & BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_MASK) >>
  703. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_LSB;
  704. }
  705. /**
  706. * hal_tx_comp_get_paddr() - Get paddr within comp descriptor
  707. * @hal_desc: completion ring descriptor pointer
  708. *
  709. * This function will get buffer physical address within hardware completion
  710. * descriptor
  711. *
  712. * Return: Buffer physical address
  713. */
  714. static inline qdf_dma_addr_t hal_tx_comp_get_paddr(void *hal_desc)
  715. {
  716. uint32_t paddr_lo;
  717. uint32_t paddr_hi;
  718. paddr_lo = *(uint32_t *) (((uint8_t *) hal_desc) +
  719. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_OFFSET);
  720. paddr_hi = *(uint32_t *) (((uint8_t *) hal_desc) +
  721. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_OFFSET);
  722. paddr_hi = (paddr_hi & BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_MASK) >>
  723. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_LSB;
  724. return (qdf_dma_addr_t) (paddr_lo | (((uint64_t) paddr_hi) << 32));
  725. }
  726. /**
  727. * hal_tx_comp_get_buffer_source() - Get buffer release source value
  728. * @hal_desc: completion ring descriptor pointer
  729. *
  730. * This function will get buffer release source from Tx completion descriptor
  731. *
  732. * Return: buffer release source
  733. */
  734. static inline uint32_t hal_tx_comp_get_buffer_source(void *hal_desc)
  735. {
  736. uint32_t comp_desc =
  737. *(uint32_t *) (((uint8_t *) hal_desc) +
  738. WBM_RELEASE_RING_2_RELEASE_SOURCE_MODULE_OFFSET);
  739. return (comp_desc & WBM_RELEASE_RING_2_RELEASE_SOURCE_MODULE_MASK) >>
  740. WBM_RELEASE_RING_2_RELEASE_SOURCE_MODULE_LSB;
  741. }
  742. /**
  743. * hal_tx_comp_get_buffer_type() - Buffer or Descriptor type
  744. * @hal_desc: completion ring descriptor pointer
  745. *
  746. * This function will return the type of pointer - buffer or descriptor
  747. *
  748. * Return: buffer type
  749. */
  750. static inline uint32_t hal_tx_comp_get_buffer_type(void *hal_desc)
  751. {
  752. uint32_t comp_desc =
  753. *(uint32_t *) (((uint8_t *) hal_desc) +
  754. WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_OFFSET);
  755. return (comp_desc & WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_MASK) >>
  756. WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_LSB;
  757. }
  758. /**
  759. * hal_tx_comp_get_release_reason() - TQM Release reason
  760. * @hal_desc: completion ring descriptor pointer
  761. *
  762. * This function will return the type of pointer - buffer or descriptor
  763. *
  764. * Return: buffer type
  765. */
  766. static inline uint8_t hal_tx_comp_get_release_reason(void *hal_desc)
  767. {
  768. uint32_t comp_desc =
  769. *(uint32_t *) (((uint8_t *) hal_desc) +
  770. WBM_RELEASE_RING_2_TQM_RELEASE_REASON_OFFSET);
  771. return (comp_desc & WBM_RELEASE_RING_2_TQM_RELEASE_REASON_MASK) >>
  772. WBM_RELEASE_RING_2_TQM_RELEASE_REASON_LSB;
  773. }
  774. /**
  775. * hal_tx_comp_get_status() - TQM Release reason
  776. * @hal_desc: completion ring Tx status
  777. *
  778. * This function will parse the WBM completion descriptor and populate in
  779. * HAL structure
  780. *
  781. * Return: none
  782. */
  783. #if defined(WCSS_VERSION) && \
  784. ((defined(CONFIG_WIN) && (WCSS_VERSION > 81)) || \
  785. (defined(CONFIG_MCL) && (WCSS_VERSION >= 72)))
  786. static inline void hal_tx_comp_get_status(void *desc,
  787. struct hal_tx_completion_status *ts)
  788. {
  789. uint8_t rate_stats_valid = 0;
  790. uint32_t rate_stats = 0;
  791. ts->ppdu_id = HAL_TX_DESC_GET(desc, WBM_RELEASE_RING_3,
  792. TQM_STATUS_NUMBER);
  793. ts->ack_frame_rssi = HAL_TX_DESC_GET(desc, WBM_RELEASE_RING_4,
  794. ACK_FRAME_RSSI);
  795. ts->first_msdu = HAL_TX_DESC_GET(desc, WBM_RELEASE_RING_4, FIRST_MSDU);
  796. ts->last_msdu = HAL_TX_DESC_GET(desc, WBM_RELEASE_RING_4, LAST_MSDU);
  797. ts->msdu_part_of_amsdu = HAL_TX_DESC_GET(desc, WBM_RELEASE_RING_4,
  798. MSDU_PART_OF_AMSDU);
  799. ts->peer_id = HAL_TX_DESC_GET(desc, WBM_RELEASE_RING_7, SW_PEER_ID);
  800. ts->tid = HAL_TX_DESC_GET(desc, WBM_RELEASE_RING_7, TID);
  801. ts->transmit_cnt = HAL_TX_DESC_GET(desc, WBM_RELEASE_RING_3,
  802. TRANSMIT_COUNT);
  803. rate_stats = HAL_TX_DESC_GET(desc, WBM_RELEASE_RING_5,
  804. TX_RATE_STATS_INFO_TX_RATE_STATS);
  805. rate_stats_valid = HAL_TX_MS(TX_RATE_STATS_INFO_0,
  806. TX_RATE_STATS_INFO_VALID, rate_stats);
  807. ts->valid = rate_stats_valid;
  808. if (rate_stats_valid) {
  809. ts->bw = HAL_TX_MS(TX_RATE_STATS_INFO_0, TRANSMIT_BW,
  810. rate_stats);
  811. ts->pkt_type = HAL_TX_MS(TX_RATE_STATS_INFO_0,
  812. TRANSMIT_PKT_TYPE, rate_stats);
  813. ts->stbc = HAL_TX_MS(TX_RATE_STATS_INFO_0,
  814. TRANSMIT_STBC, rate_stats);
  815. ts->ldpc = HAL_TX_MS(TX_RATE_STATS_INFO_0, TRANSMIT_LDPC,
  816. rate_stats);
  817. ts->sgi = HAL_TX_MS(TX_RATE_STATS_INFO_0, TRANSMIT_SGI,
  818. rate_stats);
  819. ts->mcs = HAL_TX_MS(TX_RATE_STATS_INFO_0, TRANSMIT_MCS,
  820. rate_stats);
  821. ts->ofdma = HAL_TX_MS(TX_RATE_STATS_INFO_0, OFDMA_TRANSMISSION,
  822. rate_stats);
  823. ts->tones_in_ru = HAL_TX_MS(TX_RATE_STATS_INFO_0, TONES_IN_RU,
  824. rate_stats);
  825. }
  826. ts->tsf = HAL_TX_DESC_GET(desc, WBM_RELEASE_RING_6,
  827. TX_RATE_STATS_INFO_TX_RATE_STATS);
  828. }
  829. #else
  830. static inline void hal_tx_comp_get_status(void *desc,
  831. struct hal_tx_completion_status *ts)
  832. {
  833. ts->ppdu_id = HAL_TX_DESC_GET(desc, WBM_RELEASE_RING_3,
  834. TQM_STATUS_NUMBER);
  835. ts->ack_frame_rssi = HAL_TX_DESC_GET(desc, WBM_RELEASE_RING_4,
  836. ACK_FRAME_RSSI);
  837. ts->first_msdu = HAL_TX_DESC_GET(desc, WBM_RELEASE_RING_4, FIRST_MSDU);
  838. ts->last_msdu = HAL_TX_DESC_GET(desc, WBM_RELEASE_RING_4, LAST_MSDU);
  839. ts->msdu_part_of_amsdu = HAL_TX_DESC_GET(desc, WBM_RELEASE_RING_4,
  840. MSDU_PART_OF_AMSDU);
  841. }
  842. #endif
  843. /**
  844. * hal_tx_comp_desc_sync() - collect hardware descriptor contents
  845. * @hal_desc: hardware descriptor pointer
  846. * @comp: software descriptor pointer
  847. * @read_status: 0 - Do not read status words from descriptors
  848. * 1 - Enable reading of status words from descriptor
  849. *
  850. * This function will collect hardware release ring element contents and
  851. * translate to software descriptor content
  852. *
  853. * Return: none
  854. */
  855. static inline void hal_tx_comp_desc_sync(void *hw_desc,
  856. struct hal_tx_desc_comp_s *comp,
  857. bool read_status)
  858. {
  859. if (!read_status)
  860. qdf_mem_copy(comp, hw_desc, HAL_TX_COMPLETION_DESC_BASE_LEN);
  861. else
  862. qdf_mem_copy(comp, hw_desc, HAL_TX_COMPLETION_DESC_LEN_BYTES);
  863. }
  864. /**
  865. * hal_tx_comp_get_htt_desc() - Read the HTT portion of WBM Descriptor
  866. * @hal_desc: Hardware (WBM) descriptor pointer
  867. * @htt_desc: Software HTT descriptor pointer
  868. *
  869. * This function will read the HTT structure overlaid on WBM descriptor
  870. * into a cached software descriptor
  871. *
  872. */
  873. static inline void hal_tx_comp_get_htt_desc(void *hw_desc, uint8_t *htt_desc)
  874. {
  875. uint8_t *desc = hw_desc + HAL_TX_COMP_HTT_STATUS_OFFSET;
  876. qdf_mem_copy(htt_desc, desc, HAL_TX_COMP_HTT_STATUS_LEN);
  877. }
  878. /**
  879. * hal_tx_set_dscp_tid_map_default() - Configure default DSCP to TID map table
  880. * @soc: HAL SoC context
  881. * @map: DSCP-TID mapping table
  882. * @id: mapping table ID - 0,1
  883. *
  884. * DSCP are mapped to 8 TID values using TID values programmed
  885. * in two set of mapping registers DSCP_TID1_MAP_<0 to 6> (id = 0)
  886. * and DSCP_TID2_MAP_<0 to 6> (id = 1)
  887. * Each mapping register has TID mapping for 10 DSCP values
  888. *
  889. * Return: none
  890. */
  891. static inline void hal_tx_set_dscp_tid_map(void *hal_soc, uint8_t *map,
  892. uint8_t id)
  893. {
  894. int i;
  895. uint32_t addr;
  896. uint32_t value;
  897. struct hal_soc *soc = (struct hal_soc *)hal_soc;
  898. if (id == HAL_TX_DSCP_TID_MAP_TABLE_DEFAULT) {
  899. addr =
  900. HWIO_TCL_R0_DSCP_TID1_MAP_0_ADDR(
  901. SEQ_WCSS_UMAC_MAC_TCL_REG_OFFSET);
  902. } else {
  903. addr =
  904. HWIO_TCL_R0_DSCP_TID2_MAP_0_ADDR(
  905. SEQ_WCSS_UMAC_MAC_TCL_REG_OFFSET);
  906. }
  907. for (i = 0; i < 64; i += 10) {
  908. value = (map[i] |
  909. (map[i+1] << HWIO_TCL_R0_DSCP_TID1_MAP_0_DSCP_1_SHFT) |
  910. (map[i+2] << HWIO_TCL_R0_DSCP_TID1_MAP_0_DSCP_2_SHFT) |
  911. (map[i+3] << HWIO_TCL_R0_DSCP_TID1_MAP_0_DSCP_3_SHFT) |
  912. (map[i+4] << HWIO_TCL_R0_DSCP_TID1_MAP_0_DSCP_4_SHFT) |
  913. (map[i+5] << HWIO_TCL_R0_DSCP_TID1_MAP_0_DSCP_5_SHFT) |
  914. (map[i+6] << HWIO_TCL_R0_DSCP_TID1_MAP_0_DSCP_6_SHFT) |
  915. (map[i+7] << HWIO_TCL_R0_DSCP_TID1_MAP_0_DSCP_7_SHFT) |
  916. (map[i+8] << HWIO_TCL_R0_DSCP_TID1_MAP_0_DSCP_8_SHFT) |
  917. (map[i+9] << HWIO_TCL_R0_DSCP_TID1_MAP_0_DSCP_9_SHFT));
  918. HAL_REG_WRITE(soc, addr,
  919. (value & HWIO_TCL_R0_DSCP_TID1_MAP_1_RMSK));
  920. addr += 4;
  921. }
  922. }
  923. /**
  924. * hal_tx_update_dscp_tid() - Update the dscp tid map table as updated by user
  925. * @soc: HAL SoC context
  926. * @map: DSCP-TID mapping table
  927. * @id : MAP ID
  928. * @dscp: DSCP_TID map index
  929. *
  930. * Return: void
  931. */
  932. static inline void hal_tx_update_dscp_tid(void *hal_soc, uint8_t tid,
  933. uint8_t id, uint8_t dscp)
  934. {
  935. int index;
  936. uint32_t addr;
  937. uint32_t value;
  938. struct hal_soc *soc = (struct hal_soc *)hal_soc;
  939. if (id == HAL_TX_DSCP_TID_MAP_TABLE_DEFAULT)
  940. addr =
  941. HWIO_TCL_R0_DSCP_TID1_MAP_0_ADDR(
  942. SEQ_WCSS_UMAC_MAC_TCL_REG_OFFSET);
  943. else
  944. addr =
  945. HWIO_TCL_R0_DSCP_TID2_MAP_0_ADDR(
  946. SEQ_WCSS_UMAC_MAC_TCL_REG_OFFSET);
  947. index = dscp % HAL_TX_NUM_DSCP_PER_REGISTER;
  948. addr += 4 * (dscp/HAL_TX_NUM_DSCP_PER_REGISTER);
  949. value = tid << (HAL_TX_BITS_PER_TID * index);
  950. HAL_REG_WRITE(soc, addr,
  951. (value & HWIO_TCL_R0_DSCP_TID1_MAP_1_RMSK));
  952. }
  953. /**
  954. * hal_tx_init_data_ring() - Initialize all the TCL Descriptors in SRNG
  955. * @hal_soc: Handle to HAL SoC structure
  956. * @hal_srng: Handle to HAL SRNG structure
  957. *
  958. * Return: none
  959. */
  960. static inline void hal_tx_init_data_ring(void *hal_soc, void *hal_srng)
  961. {
  962. uint8_t *desc_addr;
  963. struct hal_srng_params srng_params;
  964. uint32_t desc_size;
  965. uint32_t num_desc;
  966. hal_get_srng_params(hal_soc, hal_srng, &srng_params);
  967. desc_addr = (uint8_t *) srng_params.ring_base_vaddr;
  968. desc_size = sizeof(struct tcl_data_cmd);
  969. num_desc = srng_params.num_entries;
  970. while (num_desc) {
  971. HAL_TX_DESC_SET_TLV_HDR(desc_addr, HAL_TX_TCL_DATA_TAG,
  972. desc_size);
  973. desc_addr += (desc_size + sizeof(struct tlv_32_hdr));
  974. num_desc--;
  975. }
  976. }
  977. #endif /* HAL_TX_H */