hal_tx.h 29 KB

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