hal_tx.h 28 KB

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