hal_tx.h 33 KB

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