hal_tx.h 26 KB

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