hal_tx.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #if !defined(HAL_TX_H)
  20. #define HAL_TX_H
  21. /*---------------------------------------------------------------------------
  22. Include files
  23. ---------------------------------------------------------------------------*/
  24. #include "hal_api.h"
  25. #include "wcss_version.h"
  26. #include "hal_hw_headers.h"
  27. #include "hal_tx_hw_defines.h"
  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 NUM_OF_DWORDS_TX_MSDU_EXTENSION 18
  62. #define HAL_TX_DESC_LEN_DWORDS (NUM_OF_DWORDS_TCL_DATA_CMD)
  63. #define HAL_TX_DESC_LEN_BYTES (NUM_OF_DWORDS_TCL_DATA_CMD * 4)
  64. #define HAL_TX_EXTENSION_DESC_LEN_DWORDS (NUM_OF_DWORDS_TX_MSDU_EXTENSION)
  65. #define HAL_TX_EXTENSION_DESC_LEN_BYTES (NUM_OF_DWORDS_TX_MSDU_EXTENSION * 4)
  66. #define NUM_OF_DWORDS_WBM_RELEASE_RING 8
  67. #define HAL_TX_COMPLETION_DESC_LEN_DWORDS (NUM_OF_DWORDS_WBM_RELEASE_RING)
  68. #define HAL_TX_COMPLETION_DESC_LEN_BYTES (NUM_OF_DWORDS_WBM_RELEASE_RING*4)
  69. #define HAL_TX_BITS_PER_TID 3
  70. #define HAL_TX_TID_BITS_MASK ((1 << HAL_TX_BITS_PER_TID) - 1)
  71. #define HAL_TX_NUM_DSCP_PER_REGISTER 10
  72. #define HAL_MAX_HW_DSCP_TID_MAPS 2
  73. #define HAL_MAX_HW_DSCP_TID_MAPS_11AX 32
  74. #define HAL_MAX_HW_DSCP_TID_V2_MAPS 48
  75. #define HTT_META_HEADER_LEN_BYTES 64
  76. #define HAL_TX_EXT_DESC_WITH_META_DATA \
  77. (HTT_META_HEADER_LEN_BYTES + HAL_TX_EXTENSION_DESC_LEN_BYTES)
  78. #define HAL_TX_NUM_PCP_PER_REGISTER 8
  79. /* Length of WBM release ring without the status words */
  80. #define HAL_TX_COMPLETION_DESC_BASE_LEN 12
  81. #define HAL_TX_COMP_RELEASE_SOURCE_TQM 0
  82. #define HAL_TX_COMP_RELEASE_SOURCE_REO 2
  83. #define HAL_TX_COMP_RELEASE_SOURCE_FW 3
  84. /* Define a place-holder release reason for FW */
  85. #define HAL_TX_COMP_RELEASE_REASON_FW 99
  86. /*
  87. * Offset of HTT Tx Descriptor in WBM Completion
  88. * HTT Tx Desc structure is passed from firmware to host overlayed
  89. * on wbm_release_ring DWORDs 2,3 ,4 and 5for software based completions
  90. * (Exception frames and TQM bypass frames)
  91. */
  92. #define HAL_TX_COMP_HTT_STATUS_OFFSET 8
  93. #define HAL_TX_COMP_HTT_STATUS_LEN 16
  94. #define HAL_TX_BUF_TYPE_BUFFER 0
  95. #define HAL_TX_BUF_TYPE_EXT_DESC 1
  96. #define HAL_TX_EXT_DESC_BUF_OFFSET TX_MSDU_EXTENSION_6_BUF0_PTR_31_0_OFFSET
  97. #define HAL_TX_EXT_BUF_LOW_MASK TX_MSDU_EXTENSION_6_BUF0_PTR_31_0_MASK
  98. #define HAL_TX_EXT_BUF_HI_MASK TX_MSDU_EXTENSION_7_BUF0_PTR_39_32_MASK
  99. #define HAL_TX_EXT_BUF_LEN_MASK TX_MSDU_EXTENSION_7_BUF0_LEN_MASK
  100. #define HAL_TX_EXT_BUF_LEN_LSB TX_MSDU_EXTENSION_7_BUF0_LEN_LSB
  101. #define HAL_TX_EXT_BUF_WD_SIZE 2
  102. #define HAL_TX_DESC_ADDRX_EN 0x1
  103. #define HAL_TX_DESC_ADDRY_EN 0x2
  104. #define HAL_TX_DESC_DEFAULT_LMAC_ID 0x3
  105. #define HAL_TX_ADDR_SEARCH_DEFAULT 0x0
  106. #define HAL_TX_ADDR_INDEX_SEARCH 0x1
  107. #define HAL_TX_FLOW_INDEX_SEARCH 0x2
  108. #define HAL_WBM2SW_RELEASE_SRC_GET(wbm_desc)(((*(((uint32_t *)wbm_desc) + \
  109. (HAL_WBM2SW_RING_RELEASE_SOURCE_MODULE_OFFSET >> 2))) & \
  110. HAL_WBM2SW_RING_RELEASE_SOURCE_MODULE_MASK) >> \
  111. HAL_WBM2SW_RING_RELEASE_SOURCE_MODULE_LSB)
  112. #define HAL_WBM_SW0_BM_ID(sw0_bm_id) (sw0_bm_id)
  113. #define HAL_WBM_SW1_BM_ID(sw0_bm_id) ((sw0_bm_id) + 1)
  114. #define HAL_WBM_SW2_BM_ID(sw0_bm_id) ((sw0_bm_id) + 2)
  115. #define HAL_WBM_SW3_BM_ID(sw0_bm_id) ((sw0_bm_id) + 3)
  116. #define HAL_WBM_SW4_BM_ID(sw0_bm_id) ((sw0_bm_id) + 4)
  117. #define HAL_WBM_SW5_BM_ID(sw0_bm_id) ((sw0_bm_id) + 5)
  118. #define HAL_WBM_SW6_BM_ID(sw0_bm_id) ((sw0_bm_id) + 6)
  119. /*---------------------------------------------------------------------------
  120. Structures
  121. ---------------------------------------------------------------------------*/
  122. /**
  123. * struct hal_tx_completion_status - HAL Tx completion descriptor contents
  124. * @status: frame acked/failed
  125. * @release_src: release source = TQM/FW
  126. * @ack_frame_rssi: RSSI of the received ACK or BA frame
  127. * @first_msdu: Indicates this MSDU is the first MSDU in AMSDU
  128. * @last_msdu: Indicates this MSDU is the last MSDU in AMSDU
  129. * @msdu_part_of_amsdu : Indicates this MSDU was part of an A-MSDU in MPDU
  130. * @bw: Indicates the BW of the upcoming transmission -
  131. * <enum 0 transmit_bw_20_MHz>
  132. * <enum 1 transmit_bw_40_MHz>
  133. * <enum 2 transmit_bw_80_MHz>
  134. * <enum 3 transmit_bw_160_MHz>
  135. * @pkt_type: Transmit Packet Type
  136. * @stbc: When set, STBC transmission rate was used
  137. * @ldpc: When set, use LDPC transmission rates
  138. * @sgi: <enum 0 0_8_us_sgi > Legacy normal GI
  139. * <enum 1 0_4_us_sgi > Legacy short GI
  140. * <enum 2 1_6_us_sgi > HE related GI
  141. * <enum 3 3_2_us_sgi > HE
  142. * @mcs: Transmit MCS Rate
  143. * @ofdma: Set when the transmission was an OFDMA transmission
  144. * @tones_in_ru: The number of tones in the RU used.
  145. * @tsf: Lower 32 bits of the TSF
  146. * @ppdu_id: TSF, snapshot of this value when transmission of the
  147. * PPDU containing the frame finished.
  148. * @transmit_cnt: Number of times this frame has been transmitted
  149. * @tid: TID of the flow or MPDU queue
  150. * @peer_id: Peer ID of the flow or MPDU queue
  151. * @buffer_timestamp: Frame system entrance timestamp in units of 1024
  152. * microseconds
  153. */
  154. struct hal_tx_completion_status {
  155. uint8_t status;
  156. uint8_t release_src;
  157. uint8_t ack_frame_rssi;
  158. uint8_t first_msdu:1,
  159. last_msdu:1,
  160. msdu_part_of_amsdu:1;
  161. uint32_t bw:2,
  162. pkt_type:4,
  163. stbc:1,
  164. ldpc:1,
  165. sgi:2,
  166. mcs:4,
  167. ofdma:1,
  168. tones_in_ru:12,
  169. valid:1;
  170. uint32_t tsf;
  171. uint32_t ppdu_id;
  172. uint8_t transmit_cnt;
  173. uint8_t tid;
  174. uint16_t peer_id;
  175. #ifdef WLAN_FEATURE_TSF_UPLINK_DELAY
  176. uint32_t buffer_timestamp:19;
  177. #endif
  178. };
  179. /**
  180. * struct hal_tx_desc_comp_s - hal tx completion descriptor contents
  181. * @desc: Transmit status information from descriptor
  182. */
  183. struct hal_tx_desc_comp_s {
  184. uint32_t desc[HAL_TX_COMPLETION_DESC_LEN_DWORDS];
  185. };
  186. /*
  187. * enum hal_tx_encrypt_type - Type of decrypt cipher used (valid only for RAW)
  188. * @HAL_TX_ENCRYPT_TYPE_WEP_40: WEP 40-bit
  189. * @HAL_TX_ENCRYPT_TYPE_WEP_10: WEP 10-bit
  190. * @HAL_TX_ENCRYPT_TYPE_TKIP_NO_MIC: TKIP without MIC
  191. * @HAL_TX_ENCRYPT_TYPE_WEP_128: WEP_128
  192. * @HAL_TX_ENCRYPT_TYPE_TKIP_WITH_MIC: TKIP_WITH_MIC
  193. * @HAL_TX_ENCRYPT_TYPE_WAPI: WAPI
  194. * @HAL_TX_ENCRYPT_TYPE_AES_CCMP_128: AES_CCMP_128
  195. * @HAL_TX_ENCRYPT_TYPE_NO_CIPHER: NO CIPHER
  196. * @HAL_TX_ENCRYPT_TYPE_AES_CCMP_256: AES_CCMP_256
  197. * @HAL_TX_ENCRYPT_TYPE_AES_GCMP_128: AES_GCMP_128
  198. * @HAL_TX_ENCRYPT_TYPE_AES_GCMP_256: AES_GCMP_256
  199. * @HAL_TX_ENCRYPT_TYPE_WAPI_GCM_SM4: WAPI GCM SM4
  200. */
  201. enum hal_tx_encrypt_type {
  202. HAL_TX_ENCRYPT_TYPE_WEP_40 = 0,
  203. HAL_TX_ENCRYPT_TYPE_WEP_104 = 1 ,
  204. HAL_TX_ENCRYPT_TYPE_TKIP_NO_MIC = 2,
  205. HAL_TX_ENCRYPT_TYPE_WEP_128 = 3,
  206. HAL_TX_ENCRYPT_TYPE_TKIP_WITH_MIC = 4,
  207. HAL_TX_ENCRYPT_TYPE_WAPI = 5,
  208. HAL_TX_ENCRYPT_TYPE_AES_CCMP_128 = 6,
  209. HAL_TX_ENCRYPT_TYPE_NO_CIPHER = 7,
  210. HAL_TX_ENCRYPT_TYPE_AES_CCMP_256 = 8,
  211. HAL_TX_ENCRYPT_TYPE_AES_GCMP_128 = 9,
  212. HAL_TX_ENCRYPT_TYPE_AES_GCMP_256 = 10,
  213. HAL_TX_ENCRYPT_TYPE_WAPI_GCM_SM4 = 11,
  214. };
  215. /*
  216. * enum hal_tx_encap_type - Encapsulation type that HW will perform
  217. * @HAL_TX_ENCAP_TYPE_RAW: Raw Packet Type
  218. * @HAL_TX_ENCAP_TYPE_NWIFI: Native WiFi Type
  219. * @HAL_TX_ENCAP_TYPE_ETHERNET: Ethernet
  220. * @HAL_TX_ENCAP_TYPE_802_3: 802.3 Frame
  221. */
  222. enum hal_tx_encap_type {
  223. HAL_TX_ENCAP_TYPE_RAW = 0,
  224. HAL_TX_ENCAP_TYPE_NWIFI = 1,
  225. HAL_TX_ENCAP_TYPE_ETHERNET = 2,
  226. HAL_TX_ENCAP_TYPE_802_3 = 3,
  227. };
  228. /**
  229. * enum hal_tx_tqm_release_reason - TQM Release reason codes
  230. *
  231. * @HAL_TX_TQM_RR_FRAME_ACKED : ACK of BA for it was received
  232. * @HAL_TX_TQM_RR_REM_CMD_REM : Remove cmd of type “Remove_mpdus” initiated
  233. * by SW
  234. * @HAL_TX_TQM_RR_REM_CMD_TX : Remove command of type Remove_transmitted_mpdus
  235. * initiated by SW
  236. * @HAL_TX_TQM_RR_REM_CMD_NOTX : Remove cmd of type Remove_untransmitted_mpdus
  237. * initiated by SW
  238. * @HAL_TX_TQM_RR_REM_CMD_AGED : Remove command of type “Remove_aged_mpdus” or
  239. * “Remove_aged_msdus” initiated by SW
  240. * @HAL_TX_TQM_RR_FW_REASON1 : Remove command where fw indicated that
  241. * remove reason is fw_reason1
  242. * @HAL_TX_TQM_RR_FW_REASON2 : Remove command where fw indicated that
  243. * remove reason is fw_reason2
  244. * @HAL_TX_TQM_RR_FW_REASON3 : Remove command where fw indicated that
  245. * remove reason is fw_reason3
  246. * @HAL_TX_TQM_RR_REM_CMD_DISABLE_QUEUE : Remove command where fw indicated that
  247. * remove reason is remove disable queue
  248. */
  249. enum hal_tx_tqm_release_reason {
  250. HAL_TX_TQM_RR_FRAME_ACKED,
  251. HAL_TX_TQM_RR_REM_CMD_REM,
  252. HAL_TX_TQM_RR_REM_CMD_TX,
  253. HAL_TX_TQM_RR_REM_CMD_NOTX,
  254. HAL_TX_TQM_RR_REM_CMD_AGED,
  255. HAL_TX_TQM_RR_FW_REASON1,
  256. HAL_TX_TQM_RR_FW_REASON2,
  257. HAL_TX_TQM_RR_FW_REASON3,
  258. HAL_TX_TQM_RR_REM_CMD_DISABLE_QUEUE,
  259. };
  260. /* enum - Table IDs for 2 DSCP-TID mapping Tables that TCL H/W supports
  261. * @HAL_TX_DSCP_TID_MAP_TABLE_DEFAULT: Default DSCP-TID mapping table
  262. * @HAL_TX_DSCP_TID_MAP_TABLE_OVERRIDE: DSCP-TID map override table
  263. */
  264. enum hal_tx_dscp_tid_table_id {
  265. HAL_TX_DSCP_TID_MAP_TABLE_DEFAULT,
  266. HAL_TX_DSCP_TID_MAP_TABLE_OVERRIDE,
  267. };
  268. /*---------------------------------------------------------------------------
  269. Function declarations and documentation
  270. ---------------------------------------------------------------------------*/
  271. /*---------------------------------------------------------------------------
  272. Tx MSDU Extension Descriptor accessor APIs
  273. ---------------------------------------------------------------------------*/
  274. /**
  275. * hal_tx_ext_desc_set_tso_enable() - Set TSO Enable Flag
  276. * @desc: Handle to Tx MSDU Extension Descriptor
  277. * @tso_en: bool value set to true if TSO is enabled
  278. *
  279. * Return: none
  280. */
  281. static inline void hal_tx_ext_desc_set_tso_enable(void *desc,
  282. uint8_t tso_en)
  283. {
  284. HAL_SET_FLD(desc, HAL_TX_MSDU_EXTENSION, TSO_ENABLE) |=
  285. HAL_TX_SM(HAL_TX_MSDU_EXTENSION, TSO_ENABLE, tso_en);
  286. }
  287. /**
  288. * hal_tx_ext_desc_set_tso_flags() - Set TSO Flags
  289. * @desc: Handle to Tx MSDU Extension Descriptor
  290. * @falgs: 32-bit word with all TSO flags consolidated
  291. *
  292. * Return: none
  293. */
  294. static inline void hal_tx_ext_desc_set_tso_flags(void *desc,
  295. uint32_t tso_flags)
  296. {
  297. HAL_SET_FLD_OFFSET(desc, HAL_TX_MSDU_EXTENSION, TSO_ENABLE, 0) =
  298. tso_flags;
  299. }
  300. /**
  301. * hal_tx_ext_desc_set_tcp_flags() - Enable HW Checksum offload
  302. * @desc: Handle to Tx MSDU Extension Descriptor
  303. * @tcp_flags: TCP flags {NS,CWR,ECE,URG,ACK,PSH, RST ,SYN,FIN}
  304. * @mask: TCP flag mask. Tcp_flag is inserted into the header
  305. * based on the mask, if tso is enabled
  306. *
  307. * Return: none
  308. */
  309. static inline void hal_tx_ext_desc_set_tcp_flags(void *desc,
  310. uint16_t tcp_flags,
  311. uint16_t mask)
  312. {
  313. HAL_SET_FLD(desc, HAL_TX_MSDU_EXTENSION, TCP_FLAG) |=
  314. ((HAL_TX_SM(HAL_TX_MSDU_EXTENSION, TCP_FLAG, tcp_flags)) |
  315. (HAL_TX_SM(HAL_TX_MSDU_EXTENSION, TCP_FLAG_MASK, mask)));
  316. }
  317. /**
  318. * hal_tx_ext_desc_set_msdu_length() - Set L2 and IP Lengths
  319. * @desc: Handle to Tx MSDU Extension Descriptor
  320. * @l2_len: L2 length for the msdu, if tso is enabled
  321. * @ip_len: IP length for the msdu, if tso is enabled
  322. *
  323. * Return: none
  324. */
  325. static inline void hal_tx_ext_desc_set_msdu_length(void *desc,
  326. uint16_t l2_len,
  327. uint16_t ip_len)
  328. {
  329. HAL_SET_FLD(desc, HAL_TX_MSDU_EXTENSION, L2_LENGTH) |=
  330. ((HAL_TX_SM(HAL_TX_MSDU_EXTENSION, L2_LENGTH, l2_len)) |
  331. (HAL_TX_SM(HAL_TX_MSDU_EXTENSION, IP_LENGTH, ip_len)));
  332. }
  333. /**
  334. * hal_tx_ext_desc_set_tcp_seq() - Set TCP Sequence number
  335. * @desc: Handle to Tx MSDU Extension Descriptor
  336. * @seq_num: Tcp_seq_number for the msdu, if tso is enabled
  337. *
  338. * Return: none
  339. */
  340. static inline void hal_tx_ext_desc_set_tcp_seq(void *desc,
  341. uint32_t seq_num)
  342. {
  343. HAL_SET_FLD(desc, HAL_TX_MSDU_EXTENSION, TCP_SEQ_NUMBER) |=
  344. ((HAL_TX_SM(HAL_TX_MSDU_EXTENSION, TCP_SEQ_NUMBER, seq_num)));
  345. }
  346. /**
  347. * hal_tx_ext_desc_set_ip_id() - Set IP Identification field
  348. * @desc: Handle to Tx MSDU Extension Descriptor
  349. * @id: IP Id field for the msdu, if tso is enabled
  350. *
  351. * Return: none
  352. */
  353. static inline void hal_tx_ext_desc_set_ip_id(void *desc,
  354. uint16_t id)
  355. {
  356. HAL_SET_FLD(desc, HAL_TX_MSDU_EXTENSION, IP_IDENTIFICATION) |=
  357. ((HAL_TX_SM(HAL_TX_MSDU_EXTENSION, IP_IDENTIFICATION, id)));
  358. }
  359. /**
  360. * hal_tx_ext_desc_set_buffer() - Set Buffer Pointer and Length for a fragment
  361. * @desc: Handle to Tx MSDU Extension Descriptor
  362. * @frag_num: Fragment number (value can be 0 to 5)
  363. * @paddr_lo: Lower 32-bit of Buffer Physical address
  364. * @paddr_hi: Upper 32-bit of Buffer Physical address
  365. * @length: Buffer Length
  366. *
  367. * Return: none
  368. */
  369. static inline void hal_tx_ext_desc_set_buffer(void *desc,
  370. uint8_t frag_num,
  371. uint32_t paddr_lo,
  372. uint16_t paddr_hi,
  373. uint16_t length)
  374. {
  375. HAL_SET_FLD_OFFSET(desc, HAL_TX_MSDU_EXTENSION, BUF0_PTR_31_0,
  376. (frag_num << 3)) |=
  377. ((HAL_TX_SM(HAL_TX_MSDU_EXTENSION, BUF0_PTR_31_0, paddr_lo)));
  378. HAL_SET_FLD_OFFSET(desc, HAL_TX_MSDU_EXTENSION, BUF0_PTR_39_32,
  379. (frag_num << 3)) |=
  380. ((HAL_TX_SM(HAL_TX_MSDU_EXTENSION, BUF0_PTR_39_32,
  381. (paddr_hi))));
  382. HAL_SET_FLD_OFFSET(desc, HAL_TX_MSDU_EXTENSION, BUF0_LEN,
  383. (frag_num << 3)) |=
  384. ((HAL_TX_SM(HAL_TX_MSDU_EXTENSION, BUF0_LEN, length)));
  385. }
  386. /**
  387. * hal_tx_ext_desc_set_buffer0_param() - Set Buffer 0 Pointer and Length
  388. * @desc: Handle to Tx MSDU Extension Descriptor
  389. * @paddr_lo: Lower 32-bit of Buffer Physical address
  390. * @paddr_hi: Upper 32-bit of Buffer Physical address
  391. * @length: Buffer 0 Length
  392. *
  393. * Return: none
  394. */
  395. static inline void hal_tx_ext_desc_set_buffer0_param(void *desc,
  396. uint32_t paddr_lo,
  397. uint16_t paddr_hi,
  398. uint16_t length)
  399. {
  400. HAL_SET_FLD(desc, HAL_TX_MSDU_EXTENSION, BUF0_PTR_31_0) |=
  401. ((HAL_TX_SM(HAL_TX_MSDU_EXTENSION, BUF0_PTR_31_0, paddr_lo)));
  402. HAL_SET_FLD(desc, HAL_TX_MSDU_EXTENSION, BUF0_PTR_39_32) |=
  403. ((HAL_TX_SM(HAL_TX_MSDU_EXTENSION,
  404. BUF0_PTR_39_32, paddr_hi)));
  405. HAL_SET_FLD(desc, HAL_TX_MSDU_EXTENSION, BUF0_LEN) |=
  406. ((HAL_TX_SM(HAL_TX_MSDU_EXTENSION, BUF0_LEN, length)));
  407. }
  408. /**
  409. * hal_tx_ext_desc_set_buffer1_param() - Set Buffer 1 Pointer and Length
  410. * @desc: Handle to Tx MSDU Extension Descriptor
  411. * @paddr_lo: Lower 32-bit of Buffer Physical address
  412. * @paddr_hi: Upper 32-bit of Buffer Physical address
  413. * @length: Buffer 1 Length
  414. *
  415. * Return: none
  416. */
  417. static inline void hal_tx_ext_desc_set_buffer1_param(void *desc,
  418. uint32_t paddr_lo,
  419. uint16_t paddr_hi,
  420. uint16_t length)
  421. {
  422. HAL_SET_FLD(desc, HAL_TX_MSDU_EXTENSION, BUF1_PTR_31_0) |=
  423. ((HAL_TX_SM(HAL_TX_MSDU_EXTENSION, BUF1_PTR_31_0, paddr_lo)));
  424. HAL_SET_FLD(desc, HAL_TX_MSDU_EXTENSION, BUF1_PTR_39_32) |=
  425. ((HAL_TX_SM(HAL_TX_MSDU_EXTENSION,
  426. BUF1_PTR_39_32, paddr_hi)));
  427. HAL_SET_FLD(desc, HAL_TX_MSDU_EXTENSION, BUF1_LEN) |=
  428. ((HAL_TX_SM(HAL_TX_MSDU_EXTENSION, BUF1_LEN, length)));
  429. }
  430. /**
  431. * hal_tx_ext_desc_set_buffer2_param() - Set Buffer 2 Pointer and Length
  432. * @desc: Handle to Tx MSDU Extension Descriptor
  433. * @paddr_lo: Lower 32-bit of Buffer Physical address
  434. * @paddr_hi: Upper 32-bit of Buffer Physical address
  435. * @length: Buffer 2 Length
  436. *
  437. * Return: none
  438. */
  439. static inline void hal_tx_ext_desc_set_buffer2_param(void *desc,
  440. uint32_t paddr_lo,
  441. uint16_t paddr_hi,
  442. uint16_t length)
  443. {
  444. HAL_SET_FLD(desc, HAL_TX_MSDU_EXTENSION, BUF2_PTR_31_0) |=
  445. ((HAL_TX_SM(HAL_TX_MSDU_EXTENSION, BUF2_PTR_31_0,
  446. paddr_lo)));
  447. HAL_SET_FLD(desc, HAL_TX_MSDU_EXTENSION, BUF2_PTR_39_32) |=
  448. ((HAL_TX_SM(HAL_TX_MSDU_EXTENSION, BUF2_PTR_39_32,
  449. paddr_hi)));
  450. HAL_SET_FLD(desc, HAL_TX_MSDU_EXTENSION, BUF2_LEN) |=
  451. ((HAL_TX_SM(HAL_TX_MSDU_EXTENSION, BUF2_LEN, length)));
  452. }
  453. /**
  454. * hal_tx_ext_desc_sync - Commit the descriptor to Hardware
  455. * @desc_cached: Cached descriptor that software maintains
  456. * @hw_desc: Hardware descriptor to be updated
  457. *
  458. * Return: none
  459. */
  460. static inline void hal_tx_ext_desc_sync(uint8_t *desc_cached,
  461. uint8_t *hw_desc)
  462. {
  463. qdf_mem_copy(&hw_desc[0], &desc_cached[0],
  464. HAL_TX_EXT_DESC_WITH_META_DATA);
  465. }
  466. /**
  467. * hal_tx_ext_desc_get_tso_enable() - Set TSO Enable Flag
  468. * @hal_tx_ext_desc: Handle to Tx MSDU Extension Descriptor
  469. *
  470. * Return: tso_enable value in the descriptor
  471. */
  472. static inline uint32_t hal_tx_ext_desc_get_tso_enable(void *hal_tx_ext_desc)
  473. {
  474. uint32_t *desc = (uint32_t *) hal_tx_ext_desc;
  475. return (*desc & HAL_TX_MSDU_EXTENSION_TSO_ENABLE_MASK) >>
  476. HAL_TX_MSDU_EXTENSION_TSO_ENABLE_LSB;
  477. }
  478. /*---------------------------------------------------------------------------
  479. WBM Descriptor accessor APIs for Tx completions
  480. ---------------------------------------------------------------------------*/
  481. /**
  482. * hal_tx_comp_get_buffer_type() - Buffer or Descriptor type
  483. * @hal_desc: completion ring descriptor pointer
  484. *
  485. * This function will return the type of pointer - buffer or descriptor
  486. *
  487. * Return: buffer type
  488. */
  489. static inline uint32_t hal_tx_comp_get_buffer_type(void *hal_desc)
  490. {
  491. uint32_t comp_desc =
  492. *(uint32_t *) (((uint8_t *) hal_desc) +
  493. HAL_TX_COMP_BUFFER_OR_DESC_TYPE_OFFSET);
  494. return (comp_desc & HAL_TX_COMP_BUFFER_OR_DESC_TYPE_MASK) >>
  495. HAL_TX_COMP_BUFFER_OR_DESC_TYPE_LSB;
  496. }
  497. #ifdef QCA_WIFI_KIWI
  498. /**
  499. * hal_tx_comp_get_buffer_source() - Get buffer release source value
  500. * @hal_desc: completion ring descriptor pointer
  501. *
  502. * This function will get buffer release source from Tx completion descriptor
  503. *
  504. * Return: buffer release source
  505. */
  506. static inline uint32_t
  507. hal_tx_comp_get_buffer_source(hal_soc_handle_t hal_soc_hdl,
  508. void *hal_desc)
  509. {
  510. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  511. return hal_soc->ops->hal_tx_comp_get_buffer_source(hal_desc);
  512. }
  513. #else
  514. static inline uint32_t
  515. hal_tx_comp_get_buffer_source(hal_soc_handle_t hal_soc_hdl,
  516. void *hal_desc)
  517. {
  518. return HAL_WBM2SW_RELEASE_SRC_GET(hal_desc);
  519. }
  520. #endif
  521. /**
  522. * hal_tx_comp_get_release_reason() - TQM Release reason
  523. * @hal_desc: completion ring descriptor pointer
  524. *
  525. * This function will return the type of pointer - buffer or descriptor
  526. *
  527. * Return: buffer type
  528. */
  529. static inline
  530. uint8_t hal_tx_comp_get_release_reason(void *hal_desc,
  531. hal_soc_handle_t hal_soc_hdl)
  532. {
  533. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  534. return hal_soc->ops->hal_tx_comp_get_release_reason(hal_desc);
  535. }
  536. /**
  537. * hal_tx_comp_get_peer_id() - Get peer_id value()
  538. * @hal_desc: completion ring descriptor pointer
  539. *
  540. * This function will get peer_id value from Tx completion descriptor
  541. *
  542. * Return: buffer release source
  543. */
  544. static inline uint16_t hal_tx_comp_get_peer_id(void *hal_desc)
  545. {
  546. uint32_t comp_desc =
  547. *(uint32_t *)(((uint8_t *)hal_desc) +
  548. HAL_TX_COMP_SW_PEER_ID_OFFSET);
  549. return (comp_desc & HAL_TX_COMP_SW_PEER_ID_MASK) >>
  550. HAL_TX_COMP_SW_PEER_ID_LSB;
  551. }
  552. /**
  553. * hal_tx_comp_get_tx_status() - Get tx transmission status()
  554. * @hal_desc: completion ring descriptor pointer
  555. *
  556. * This function will get transmit status value from Tx completion descriptor
  557. *
  558. * Return: buffer release source
  559. */
  560. static inline uint8_t hal_tx_comp_get_tx_status(void *hal_desc)
  561. {
  562. uint32_t comp_desc =
  563. *(uint32_t *)(((uint8_t *)hal_desc) +
  564. HAL_TX_COMP_TQM_RELEASE_REASON_OFFSET);
  565. return (comp_desc & HAL_TX_COMP_TQM_RELEASE_REASON_MASK) >>
  566. HAL_TX_COMP_TQM_RELEASE_REASON_LSB;
  567. }
  568. /**
  569. * hal_tx_comp_desc_sync() - collect hardware descriptor contents
  570. * @hal_desc: hardware descriptor pointer
  571. * @comp: software descriptor pointer
  572. * @read_status: 0 - Do not read status words from descriptors
  573. * 1 - Enable reading of status words from descriptor
  574. *
  575. * This function will collect hardware release ring element contents and
  576. * translate to software descriptor content
  577. *
  578. * Return: none
  579. */
  580. static inline void hal_tx_comp_desc_sync(void *hw_desc,
  581. struct hal_tx_desc_comp_s *comp,
  582. bool read_status)
  583. {
  584. if (!read_status)
  585. qdf_mem_copy(comp, hw_desc, HAL_TX_COMPLETION_DESC_BASE_LEN);
  586. else
  587. qdf_mem_copy(comp, hw_desc, HAL_TX_COMPLETION_DESC_LEN_BYTES);
  588. }
  589. /**
  590. * hal_dump_comp_desc() - dump tx completion descriptor
  591. * @hal_desc: hardware descriptor pointer
  592. *
  593. * This function will print tx completion descriptor
  594. *
  595. * Return: none
  596. */
  597. static inline void hal_dump_comp_desc(void *hw_desc)
  598. {
  599. struct hal_tx_desc_comp_s *comp =
  600. (struct hal_tx_desc_comp_s *)hw_desc;
  601. uint32_t i;
  602. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_FATAL,
  603. "Current tx completion descriptor is");
  604. for (i = 0; i < HAL_TX_COMPLETION_DESC_LEN_DWORDS; i++) {
  605. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_FATAL,
  606. "DWORD[i] = 0x%x", comp->desc[i]);
  607. }
  608. }
  609. /**
  610. * hal_tx_comp_get_htt_desc() - Read the HTT portion of WBM Descriptor
  611. * @hal_desc: Hardware (WBM) descriptor pointer
  612. * @htt_desc: Software HTT descriptor pointer
  613. *
  614. * This function will read the HTT structure overlaid on WBM descriptor
  615. * into a cached software descriptor
  616. *
  617. */
  618. static inline void hal_tx_comp_get_htt_desc(void *hw_desc, uint8_t *htt_desc)
  619. {
  620. uint8_t *desc = hw_desc + HAL_TX_COMP_HTT_STATUS_OFFSET;
  621. qdf_mem_copy(htt_desc, desc, HAL_TX_COMP_HTT_STATUS_LEN);
  622. }
  623. /**
  624. * hal_tx_init_data_ring() - Initialize all the TCL Descriptors in SRNG
  625. * @hal_soc_hdl: Handle to HAL SoC structure
  626. * @hal_srng: Handle to HAL SRNG structure
  627. *
  628. * Return: none
  629. */
  630. static inline void hal_tx_init_data_ring(hal_soc_handle_t hal_soc_hdl,
  631. hal_ring_handle_t hal_ring_hdl)
  632. {
  633. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  634. hal_soc->ops->hal_tx_init_data_ring(hal_soc_hdl, hal_ring_hdl);
  635. }
  636. /**
  637. * hal_tx_set_dscp_tid_map_default() - Configure default DSCP to TID map table
  638. *
  639. * @soc: HAL SoC context
  640. * @map: DSCP-TID mapping table
  641. * @id: mapping table ID - 0,1
  642. *
  643. * Return: void
  644. */
  645. static inline void hal_tx_set_dscp_tid_map(hal_soc_handle_t hal_soc_hdl,
  646. uint8_t *map, uint8_t id)
  647. {
  648. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  649. hal_soc->ops->hal_tx_set_dscp_tid_map(hal_soc, map, id);
  650. }
  651. /**
  652. * hal_tx_update_dscp_tid() - Update the dscp tid map table as updated by user
  653. *
  654. * @soc: HAL SoC context
  655. * @map: DSCP-TID mapping table
  656. * @id : MAP ID
  657. * @dscp: DSCP_TID map index
  658. *
  659. * Return: void
  660. */
  661. static inline
  662. void hal_tx_update_dscp_tid(hal_soc_handle_t hal_soc_hdl, uint8_t tid,
  663. uint8_t id, uint8_t dscp)
  664. {
  665. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  666. hal_soc->ops->hal_tx_update_dscp_tid(hal_soc, tid, id, dscp);
  667. }
  668. /**
  669. * hal_tx_comp_get_status() - TQM Release reason
  670. * @hal_desc: completion ring Tx status
  671. *
  672. * This function will parse the WBM completion descriptor and populate in
  673. * HAL structure
  674. *
  675. * Return: none
  676. */
  677. static inline void hal_tx_comp_get_status(void *desc, void *ts,
  678. hal_soc_handle_t hal_soc_hdl)
  679. {
  680. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  681. hal_soc->ops->hal_tx_comp_get_status(desc, ts, hal_soc);
  682. }
  683. /**
  684. * hal_tx_set_pcp_tid_map_default() - Configure default PCP to TID map table
  685. *
  686. * @soc: HAL SoC context
  687. * @map: PCP-TID mapping table
  688. *
  689. * Return: void
  690. */
  691. static inline void hal_tx_set_pcp_tid_map_default(hal_soc_handle_t hal_soc_hdl,
  692. uint8_t *map)
  693. {
  694. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  695. hal_soc->ops->hal_tx_set_pcp_tid_map(hal_soc, map);
  696. }
  697. /**
  698. * hal_tx_update_pcp_tid_map() - Update PCP to TID map table
  699. *
  700. * @soc: HAL SoC context
  701. * @pcp: pcp value
  702. * @tid: tid no
  703. *
  704. * Return: void
  705. */
  706. static inline void hal_tx_update_pcp_tid_map(hal_soc_handle_t hal_soc_hdl,
  707. uint8_t pcp, uint8_t tid)
  708. {
  709. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  710. hal_soc->ops->hal_tx_update_pcp_tid_map(hal_soc, tid, tid);
  711. }
  712. /**
  713. * hal_tx_set_tidmap_prty() - Configure TIDmap priority
  714. *
  715. * @soc: HAL SoC context
  716. * @val: priority value
  717. *
  718. * Return: void
  719. */
  720. static inline
  721. void hal_tx_set_tidmap_prty(hal_soc_handle_t hal_soc_hdl, uint8_t val)
  722. {
  723. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  724. hal_soc->ops->hal_tx_set_tidmap_prty(hal_soc, val);
  725. }
  726. /**
  727. * hal_get_wbm_internal_error() - wbm internal error
  728. * @hal_desc: completion ring descriptor pointer
  729. *
  730. * This function will return the type of pointer - buffer or descriptor
  731. *
  732. * Return: buffer type
  733. */
  734. static inline
  735. uint8_t hal_get_wbm_internal_error(hal_soc_handle_t hal_soc_hdl, void *hal_desc)
  736. {
  737. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  738. return hal_soc->ops->hal_get_wbm_internal_error(hal_desc);
  739. }
  740. #endif /* HAL_TX_H */