hal_tx.h 36 KB

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