hal_tx.h 32 KB

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