hal_tx.h 36 KB

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