hal_tx.h 36 KB

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