hal_tx.h 32 KB

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