hal_tx.h 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133
  1. /*
  2. * Copyright (c) 2016-2019 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. #define WBM_RELEASE_RING_5_TX_RATE_STATS_OFFSET 0x00000014
  26. #define WBM_RELEASE_RING_5_TX_RATE_STATS_LSB 0
  27. #define WBM_RELEASE_RING_5_TX_RATE_STATS_MASK 0xffffffff
  28. /*---------------------------------------------------------------------------
  29. Preprocessor definitions and constants
  30. ---------------------------------------------------------------------------*/
  31. #define HAL_OFFSET(block, field) block ## _ ## field ## _OFFSET
  32. #define HAL_SET_FLD(desc, block , field) \
  33. (*(uint32_t *) ((uint8_t *) desc + HAL_OFFSET(block, field)))
  34. #define HAL_SET_FLD_OFFSET(desc, block , field, offset) \
  35. (*(uint32_t *) ((uint8_t *) desc + HAL_OFFSET(block, field) + (offset)))
  36. #define HAL_TX_DESC_SET_TLV_HDR(desc, tag, len) \
  37. do { \
  38. ((struct tlv_32_hdr *) desc)->tlv_tag = (tag); \
  39. ((struct tlv_32_hdr *) desc)->tlv_len = (len); \
  40. } while (0)
  41. #define HAL_TX_TCL_DATA_TAG WIFITCL_DATA_CMD_E
  42. #define HAL_TX_TCL_CMD_TAG WIFITCL_GSE_CMD_E
  43. #define HAL_TX_SM(block, field, value) \
  44. ((value << (block ## _ ## field ## _LSB)) & \
  45. (block ## _ ## field ## _MASK))
  46. #define HAL_TX_MS(block, field, value) \
  47. (((value) & (block ## _ ## field ## _MASK)) >> \
  48. (block ## _ ## field ## _LSB))
  49. #define HAL_TX_DESC_GET(desc, block, field) \
  50. HAL_TX_MS(block, field, HAL_SET_FLD(desc, block, field))
  51. #define HAL_TX_DESC_SUBBLOCK_GET(desc, block, sub, field) \
  52. HAL_TX_MS(sub, field, HAL_SET_FLD(desc, block, sub))
  53. #define HAL_TX_BUF_TYPE_BUFFER 0
  54. #define HAL_TX_BUF_TYPE_EXT_DESC 1
  55. #define HAL_TX_DESC_LEN_DWORDS (NUM_OF_DWORDS_TCL_DATA_CMD)
  56. #define HAL_TX_DESC_LEN_BYTES (NUM_OF_DWORDS_TCL_DATA_CMD * 4)
  57. #define HAL_TX_EXTENSION_DESC_LEN_DWORDS (NUM_OF_DWORDS_TX_MSDU_EXTENSION)
  58. #define HAL_TX_EXTENSION_DESC_LEN_BYTES (NUM_OF_DWORDS_TX_MSDU_EXTENSION * 4)
  59. #define HAL_TX_COMPLETION_DESC_LEN_DWORDS (NUM_OF_DWORDS_WBM_RELEASE_RING)
  60. #define HAL_TX_COMPLETION_DESC_LEN_BYTES (NUM_OF_DWORDS_WBM_RELEASE_RING*4)
  61. #define HAL_TX_BITS_PER_TID 3
  62. #define HAL_TX_TID_BITS_MASK ((1 << HAL_TX_BITS_PER_TID) - 1)
  63. #define HAL_TX_NUM_DSCP_PER_REGISTER 10
  64. #define HAL_MAX_HW_DSCP_TID_MAPS 2
  65. #define HAL_MAX_HW_DSCP_TID_MAPS_11AX 32
  66. #define HAL_MAX_HW_DSCP_TID_V2_MAPS 48
  67. #define HTT_META_HEADER_LEN_BYTES 64
  68. #define HAL_TX_EXT_DESC_WITH_META_DATA \
  69. (HTT_META_HEADER_LEN_BYTES + HAL_TX_EXTENSION_DESC_LEN_BYTES)
  70. #define HAL_TX_NUM_PCP_PER_REGISTER 8
  71. /* Length of WBM release ring without the status words */
  72. #define HAL_TX_COMPLETION_DESC_BASE_LEN 12
  73. #define HAL_TX_COMP_RELEASE_SOURCE_TQM 0
  74. #define HAL_TX_COMP_RELEASE_SOURCE_FW 3
  75. /* Define a place-holder release reason for FW */
  76. #define HAL_TX_COMP_RELEASE_REASON_FW 99
  77. /*
  78. * Offset of HTT Tx Descriptor in WBM Completion
  79. * HTT Tx Desc structure is passed from firmware to host overlayed
  80. * on wbm_release_ring DWORDs 2,3 ,4 and 5for software based completions
  81. * (Exception frames and TQM bypass frames)
  82. */
  83. #define HAL_TX_COMP_HTT_STATUS_OFFSET 8
  84. #define HAL_TX_COMP_HTT_STATUS_LEN 16
  85. #define HAL_TX_BUF_TYPE_BUFFER 0
  86. #define HAL_TX_BUF_TYPE_EXT_DESC 1
  87. #define HAL_TX_EXT_DESC_BUF_OFFSET TX_MSDU_EXTENSION_6_BUF0_PTR_31_0_OFFSET
  88. #define HAL_TX_EXT_BUF_LOW_MASK TX_MSDU_EXTENSION_6_BUF0_PTR_31_0_MASK
  89. #define HAL_TX_EXT_BUF_HI_MASK TX_MSDU_EXTENSION_7_BUF0_PTR_39_32_MASK
  90. #define HAL_TX_EXT_BUF_LEN_MASK TX_MSDU_EXTENSION_7_BUF0_LEN_MASK
  91. #define HAL_TX_EXT_BUF_LEN_LSB TX_MSDU_EXTENSION_7_BUF0_LEN_LSB
  92. #define HAL_TX_EXT_BUF_WD_SIZE 2
  93. #define HAL_TX_DESC_ADDRX_EN 0x1
  94. #define HAL_TX_DESC_ADDRY_EN 0x2
  95. #define HAL_TX_DESC_DEFAULT_LMAC_ID 0x3
  96. #define HAL_TX_ADDR_SEARCH_DEFAULT 0x0
  97. #define HAL_TX_ADDR_INDEX_SEARCH 0x1
  98. #define HAL_TX_FLOW_INDEX_SEARCH 0x2
  99. enum hal_tx_ret_buf_manager {
  100. HAL_WBM_SW0_BM_ID = 3,
  101. HAL_WBM_SW1_BM_ID = 4,
  102. HAL_WBM_SW2_BM_ID = 5,
  103. HAL_WBM_SW3_BM_ID = 6,
  104. };
  105. /*---------------------------------------------------------------------------
  106. Structures
  107. ---------------------------------------------------------------------------*/
  108. /**
  109. * struct hal_tx_completion_status - HAL Tx completion descriptor contents
  110. * @status: frame acked/failed
  111. * @release_src: release source = TQM/FW
  112. * @ack_frame_rssi: RSSI of the received ACK or BA frame
  113. * @first_msdu: Indicates this MSDU is the first MSDU in AMSDU
  114. * @last_msdu: Indicates this MSDU is the last MSDU in AMSDU
  115. * @msdu_part_of_amsdu : Indicates this MSDU was part of an A-MSDU in MPDU
  116. * @bw: Indicates the BW of the upcoming transmission -
  117. * <enum 0 transmit_bw_20_MHz>
  118. * <enum 1 transmit_bw_40_MHz>
  119. * <enum 2 transmit_bw_80_MHz>
  120. * <enum 3 transmit_bw_160_MHz>
  121. * @pkt_type: Transmit Packet Type
  122. * @stbc: When set, STBC transmission rate was used
  123. * @ldpc: When set, use LDPC transmission rates
  124. * @sgi: <enum 0 0_8_us_sgi > Legacy normal GI
  125. * <enum 1 0_4_us_sgi > Legacy short GI
  126. * <enum 2 1_6_us_sgi > HE related GI
  127. * <enum 3 3_2_us_sgi > HE
  128. * @mcs: Transmit MCS Rate
  129. * @ofdma: Set when the transmission was an OFDMA transmission
  130. * @tones_in_ru: The number of tones in the RU used.
  131. * @tsf: Lower 32 bits of the TSF
  132. * @ppdu_id: TSF, snapshot of this value when transmission of the
  133. * PPDU containing the frame finished.
  134. * @transmit_cnt: Number of times this frame has been transmitted
  135. * @tid: TID of the flow or MPDU queue
  136. * @peer_id: Peer ID of the flow or MPDU queue
  137. */
  138. struct hal_tx_completion_status {
  139. uint8_t status;
  140. uint8_t release_src;
  141. uint8_t ack_frame_rssi;
  142. uint8_t first_msdu:1,
  143. last_msdu:1,
  144. msdu_part_of_amsdu:1;
  145. uint32_t bw:2,
  146. pkt_type:4,
  147. stbc:1,
  148. ldpc:1,
  149. sgi:2,
  150. mcs:4,
  151. ofdma:1,
  152. tones_in_ru:12,
  153. valid:1;
  154. uint32_t tsf;
  155. uint32_t ppdu_id;
  156. uint8_t transmit_cnt;
  157. uint8_t tid;
  158. uint16_t peer_id;
  159. };
  160. /**
  161. * struct hal_tx_desc_comp_s - hal tx completion descriptor contents
  162. * @desc: Transmit status information from descriptor
  163. */
  164. struct hal_tx_desc_comp_s {
  165. uint32_t desc[HAL_TX_COMPLETION_DESC_LEN_DWORDS];
  166. };
  167. /*
  168. * enum hal_tx_encrypt_type - Type of decrypt cipher used (valid only for RAW)
  169. * @HAL_TX_ENCRYPT_TYPE_WEP_40: WEP 40-bit
  170. * @HAL_TX_ENCRYPT_TYPE_WEP_10: WEP 10-bit
  171. * @HAL_TX_ENCRYPT_TYPE_TKIP_NO_MIC: TKIP without MIC
  172. * @HAL_TX_ENCRYPT_TYPE_WEP_128: WEP_128
  173. * @HAL_TX_ENCRYPT_TYPE_TKIP_WITH_MIC: TKIP_WITH_MIC
  174. * @HAL_TX_ENCRYPT_TYPE_WAPI: WAPI
  175. * @HAL_TX_ENCRYPT_TYPE_AES_CCMP_128: AES_CCMP_128
  176. * @HAL_TX_ENCRYPT_TYPE_NO_CIPHER: NO CIPHER
  177. * @HAL_TX_ENCRYPT_TYPE_AES_CCMP_256: AES_CCMP_256
  178. * @HAL_TX_ENCRYPT_TYPE_AES_GCMP_128: AES_GCMP_128
  179. * @HAL_TX_ENCRYPT_TYPE_AES_GCMP_256: AES_GCMP_256
  180. * @HAL_TX_ENCRYPT_TYPE_WAPI_GCM_SM4: WAPI GCM SM4
  181. */
  182. enum hal_tx_encrypt_type {
  183. HAL_TX_ENCRYPT_TYPE_WEP_40 = 0,
  184. HAL_TX_ENCRYPT_TYPE_WEP_104 = 1 ,
  185. HAL_TX_ENCRYPT_TYPE_TKIP_NO_MIC = 2,
  186. HAL_TX_ENCRYPT_TYPE_WEP_128 = 3,
  187. HAL_TX_ENCRYPT_TYPE_TKIP_WITH_MIC = 4,
  188. HAL_TX_ENCRYPT_TYPE_WAPI = 5,
  189. HAL_TX_ENCRYPT_TYPE_AES_CCMP_128 = 6,
  190. HAL_TX_ENCRYPT_TYPE_NO_CIPHER = 7,
  191. HAL_TX_ENCRYPT_TYPE_AES_CCMP_256 = 8,
  192. HAL_TX_ENCRYPT_TYPE_AES_GCMP_128 = 9,
  193. HAL_TX_ENCRYPT_TYPE_AES_GCMP_256 = 10,
  194. HAL_TX_ENCRYPT_TYPE_WAPI_GCM_SM4 = 11,
  195. };
  196. /*
  197. * enum hal_tx_encap_type - Encapsulation type that HW will perform
  198. * @HAL_TX_ENCAP_TYPE_RAW: Raw Packet Type
  199. * @HAL_TX_ENCAP_TYPE_NWIFI: Native WiFi Type
  200. * @HAL_TX_ENCAP_TYPE_ETHERNET: Ethernet
  201. * @HAL_TX_ENCAP_TYPE_802_3: 802.3 Frame
  202. */
  203. enum hal_tx_encap_type {
  204. HAL_TX_ENCAP_TYPE_RAW = 0,
  205. HAL_TX_ENCAP_TYPE_NWIFI = 1,
  206. HAL_TX_ENCAP_TYPE_ETHERNET = 2,
  207. HAL_TX_ENCAP_TYPE_802_3 = 3,
  208. };
  209. /**
  210. * enum hal_tx_tqm_release_reason - TQM Release reason codes
  211. *
  212. * @HAL_TX_TQM_RR_FRAME_ACKED : ACK of BA for it was received
  213. * @HAL_TX_TQM_RR_REM_CMD_REM : Remove cmd of type “Remove_mpdus” initiated
  214. * by SW
  215. * @HAL_TX_TQM_RR_REM_CMD_TX : Remove command of type Remove_transmitted_mpdus
  216. * initiated by SW
  217. * @HAL_TX_TQM_RR_REM_CMD_NOTX : Remove cmd of type Remove_untransmitted_mpdus
  218. * initiated by SW
  219. * @HAL_TX_TQM_RR_REM_CMD_AGED : Remove command of type “Remove_aged_mpdus” or
  220. * “Remove_aged_msdus” initiated by SW
  221. * @HAL_TX_TQM_RR_FW_REASON1 : Remove command where fw indicated that
  222. * remove reason is fw_reason1
  223. * @HAL_TX_TQM_RR_FW_REASON2 : Remove command where fw indicated that
  224. * remove reason is fw_reason2
  225. * @HAL_TX_TQM_RR_FW_REASON3 : Remove command where fw indicated that
  226. * remove reason is fw_reason3
  227. * @HAL_TX_TQM_RR_REM_CMD_DISABLE_QUEUE : Remove command where fw indicated that
  228. * remove reason is remove disable queue
  229. */
  230. enum hal_tx_tqm_release_reason {
  231. HAL_TX_TQM_RR_FRAME_ACKED,
  232. HAL_TX_TQM_RR_REM_CMD_REM,
  233. HAL_TX_TQM_RR_REM_CMD_TX,
  234. HAL_TX_TQM_RR_REM_CMD_NOTX,
  235. HAL_TX_TQM_RR_REM_CMD_AGED,
  236. HAL_TX_TQM_RR_FW_REASON1,
  237. HAL_TX_TQM_RR_FW_REASON2,
  238. HAL_TX_TQM_RR_FW_REASON3,
  239. HAL_TX_TQM_RR_REM_CMD_DISABLE_QUEUE,
  240. };
  241. /* enum - Table IDs for 2 DSCP-TID mapping Tables that TCL H/W supports
  242. * @HAL_TX_DSCP_TID_MAP_TABLE_DEFAULT: Default DSCP-TID mapping table
  243. * @HAL_TX_DSCP_TID_MAP_TABLE_OVERRIDE: DSCP-TID map override table
  244. */
  245. enum hal_tx_dscp_tid_table_id {
  246. HAL_TX_DSCP_TID_MAP_TABLE_DEFAULT,
  247. HAL_TX_DSCP_TID_MAP_TABLE_OVERRIDE,
  248. };
  249. /*---------------------------------------------------------------------------
  250. Function declarations and documentation
  251. ---------------------------------------------------------------------------*/
  252. /*---------------------------------------------------------------------------
  253. TCL Descriptor accessor APIs
  254. ---------------------------------------------------------------------------*/
  255. /**
  256. * hal_tx_desc_set_buf_length - Set Data length in bytes in Tx Descriptor
  257. * @desc: Handle to Tx Descriptor
  258. * @data_length: MSDU length in case of direct descriptor.
  259. * Length of link extension descriptor in case of Link extension
  260. * descriptor.Includes the length of Metadata
  261. * Return: None
  262. */
  263. static inline void hal_tx_desc_set_buf_length(void *desc,
  264. uint16_t data_length)
  265. {
  266. HAL_SET_FLD(desc, TCL_DATA_CMD_3, DATA_LENGTH) |=
  267. HAL_TX_SM(TCL_DATA_CMD_3, DATA_LENGTH, data_length);
  268. }
  269. /**
  270. * hal_tx_desc_set_buf_offset - Sets Packet Offset field in Tx descriptor
  271. * @desc: Handle to Tx Descriptor
  272. * @offset: Packet offset from Metadata in case of direct buffer descriptor.
  273. *
  274. * Return: void
  275. */
  276. static inline void hal_tx_desc_set_buf_offset(void *desc,
  277. uint8_t offset)
  278. {
  279. HAL_SET_FLD(desc, TCL_DATA_CMD_3, PACKET_OFFSET) |=
  280. HAL_TX_SM(TCL_DATA_CMD_3, PACKET_OFFSET, offset);
  281. }
  282. /**
  283. * hal_tx_desc_set_encap_type - Set encapsulation type in Tx Descriptor
  284. * @desc: Handle to Tx Descriptor
  285. * @encap_type: Encapsulation that HW will perform
  286. *
  287. * Return: void
  288. *
  289. */
  290. static inline void hal_tx_desc_set_encap_type(void *desc,
  291. enum hal_tx_encap_type encap_type)
  292. {
  293. HAL_SET_FLD(desc, TCL_DATA_CMD_2, ENCAP_TYPE) |=
  294. HAL_TX_SM(TCL_DATA_CMD_2, ENCAP_TYPE, encap_type);
  295. }
  296. /**
  297. * hal_tx_desc_set_encrypt_type - Sets the Encrypt Type in Tx Descriptor
  298. * @desc: Handle to Tx Descriptor
  299. * @type: Encrypt Type
  300. *
  301. * Return: void
  302. */
  303. static inline void hal_tx_desc_set_encrypt_type(void *desc,
  304. enum hal_tx_encrypt_type type)
  305. {
  306. HAL_SET_FLD(desc, TCL_DATA_CMD_2, ENCRYPT_TYPE) |=
  307. HAL_TX_SM(TCL_DATA_CMD_2, ENCRYPT_TYPE, type);
  308. }
  309. /**
  310. * hal_tx_desc_set_addr_search_flags - Enable AddrX and AddrY search flags
  311. * @desc: Handle to Tx Descriptor
  312. * @flags: Bit 0 - AddrY search enable, Bit 1 - AddrX search enable
  313. *
  314. * Return: void
  315. */
  316. static inline void hal_tx_desc_set_addr_search_flags(void *desc,
  317. uint8_t flags)
  318. {
  319. HAL_SET_FLD(desc, TCL_DATA_CMD_2, ADDRX_EN) |=
  320. HAL_TX_SM(TCL_DATA_CMD_2, ADDRX_EN, (flags & 0x1));
  321. HAL_SET_FLD(desc, TCL_DATA_CMD_2, ADDRY_EN) |=
  322. HAL_TX_SM(TCL_DATA_CMD_2, ADDRY_EN, (flags >> 1));
  323. }
  324. /**
  325. * hal_tx_desc_set_l4_checksum_en - Set TCP/IP checksum enable flags
  326. * Tx Descriptor for MSDU_buffer type
  327. * @desc: Handle to Tx Descriptor
  328. * @en: UDP/TCP over ipv4/ipv6 checksum enable flags (5 bits)
  329. *
  330. * Return: void
  331. */
  332. static inline void hal_tx_desc_set_l4_checksum_en(void *desc,
  333. uint8_t en)
  334. {
  335. HAL_SET_FLD(desc, TCL_DATA_CMD_3, IPV4_CHECKSUM_EN) |=
  336. (HAL_TX_SM(TCL_DATA_CMD_3, UDP_OVER_IPV4_CHECKSUM_EN, en) |
  337. HAL_TX_SM(TCL_DATA_CMD_3, UDP_OVER_IPV6_CHECKSUM_EN, en) |
  338. HAL_TX_SM(TCL_DATA_CMD_3, TCP_OVER_IPV4_CHECKSUM_EN, en) |
  339. HAL_TX_SM(TCL_DATA_CMD_3, TCP_OVER_IPV6_CHECKSUM_EN, en));
  340. }
  341. /**
  342. * hal_tx_desc_set_l3_checksum_en - Set IPv4 checksum enable flag in
  343. * Tx Descriptor for MSDU_buffer type
  344. * @desc: Handle to Tx Descriptor
  345. * @checksum_en_flags: ipv4 checksum enable flags
  346. *
  347. * Return: void
  348. */
  349. static inline void hal_tx_desc_set_l3_checksum_en(void *desc,
  350. uint8_t en)
  351. {
  352. HAL_SET_FLD(desc, TCL_DATA_CMD_3, IPV4_CHECKSUM_EN) |=
  353. HAL_TX_SM(TCL_DATA_CMD_3, IPV4_CHECKSUM_EN, en);
  354. }
  355. /**
  356. * hal_tx_desc_set_fw_metadata- Sets the metadata that is part of TCL descriptor
  357. * @desc:Handle to Tx Descriptor
  358. * @metadata: Metadata to be sent to Firmware
  359. *
  360. * Return: void
  361. */
  362. static inline void hal_tx_desc_set_fw_metadata(void *desc,
  363. uint16_t metadata)
  364. {
  365. HAL_SET_FLD(desc, TCL_DATA_CMD_2, TCL_CMD_NUMBER) |=
  366. HAL_TX_SM(TCL_DATA_CMD_2, TCL_CMD_NUMBER, metadata);
  367. }
  368. /**
  369. * hal_tx_desc_set_to_fw - Set To_FW bit in Tx Descriptor.
  370. * @desc:Handle to Tx Descriptor
  371. * @to_fw: if set, Forward packet to FW along with classification result
  372. *
  373. * Return: void
  374. */
  375. static inline void hal_tx_desc_set_to_fw(void *desc, uint8_t to_fw)
  376. {
  377. HAL_SET_FLD(desc, TCL_DATA_CMD_3, TO_FW) |=
  378. HAL_TX_SM(TCL_DATA_CMD_3, TO_FW, to_fw);
  379. }
  380. /**
  381. * hal_tx_desc_set_mesh_en - Set mesh_enable flag in Tx descriptor
  382. * @hal_soc_hdl: hal soc handle
  383. * @desc: Handle to Tx Descriptor
  384. * @en: For raw WiFi frames, this indicates transmission to a mesh STA,
  385. * enabling the interpretation of the 'Mesh Control Present' bit
  386. * (bit 8) of QoS Control (otherwise this bit is ignored),
  387. * For native WiFi frames, this indicates that a 'Mesh Control' field
  388. * is present between the header and the LLC.
  389. *
  390. * Return: void
  391. */
  392. static inline void hal_tx_desc_set_mesh_en(hal_soc_handle_t hal_soc_hdl,
  393. void *desc, uint8_t en)
  394. {
  395. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  396. hal_soc->ops->hal_tx_desc_set_mesh_en(desc, en);
  397. }
  398. /**
  399. * hal_tx_desc_set_hlos_tid - Set the TID value (override DSCP/PCP fields in
  400. * frame) to be used for Tx Frame
  401. * @desc: Handle to Tx Descriptor
  402. * @hlos_tid: HLOS TID
  403. *
  404. * Return: void
  405. */
  406. static inline void hal_tx_desc_set_hlos_tid(void *desc,
  407. uint8_t hlos_tid)
  408. {
  409. HAL_SET_FLD(desc, TCL_DATA_CMD_4, HLOS_TID) |=
  410. HAL_TX_SM(TCL_DATA_CMD_4, HLOS_TID, hlos_tid);
  411. HAL_SET_FLD(desc, TCL_DATA_CMD_4, HLOS_TID_OVERWRITE) |=
  412. HAL_TX_SM(TCL_DATA_CMD_4, HLOS_TID_OVERWRITE, 1);
  413. }
  414. /**
  415. * hal_tx_desc_sync - Commit the descriptor to Hardware
  416. * @hal_tx_des_cached: Cached descriptor that software maintains
  417. * @hw_desc: Hardware descriptor to be updated
  418. */
  419. static inline void hal_tx_desc_sync(void *hal_tx_desc_cached,
  420. void *hw_desc)
  421. {
  422. qdf_mem_copy((hw_desc + sizeof(struct tlv_32_hdr)),
  423. hal_tx_desc_cached, HAL_TX_DESC_LEN_BYTES);
  424. }
  425. /*---------------------------------------------------------------------------
  426. Tx MSDU Extension Descriptor accessor APIs
  427. ---------------------------------------------------------------------------*/
  428. /**
  429. * hal_tx_ext_desc_set_tso_enable() - Set TSO Enable Flag
  430. * @desc: Handle to Tx MSDU Extension Descriptor
  431. * @tso_en: bool value set to true if TSO is enabled
  432. *
  433. * Return: none
  434. */
  435. static inline void hal_tx_ext_desc_set_tso_enable(void *desc,
  436. uint8_t tso_en)
  437. {
  438. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_0, TSO_ENABLE) |=
  439. HAL_TX_SM(TX_MSDU_EXTENSION_0, TSO_ENABLE, tso_en);
  440. }
  441. /**
  442. * hal_tx_ext_desc_set_tso_flags() - Set TSO Flags
  443. * @desc: Handle to Tx MSDU Extension Descriptor
  444. * @falgs: 32-bit word with all TSO flags consolidated
  445. *
  446. * Return: none
  447. */
  448. static inline void hal_tx_ext_desc_set_tso_flags(void *desc,
  449. uint32_t tso_flags)
  450. {
  451. HAL_SET_FLD_OFFSET(desc, TX_MSDU_EXTENSION_0, TSO_ENABLE, 0) =
  452. tso_flags;
  453. }
  454. /**
  455. * hal_tx_ext_desc_set_tcp_flags() - Enable HW Checksum offload
  456. * @desc: Handle to Tx MSDU Extension Descriptor
  457. * @tcp_flags: TCP flags {NS,CWR,ECE,URG,ACK,PSH, RST ,SYN,FIN}
  458. * @mask: TCP flag mask. Tcp_flag is inserted into the header
  459. * based on the mask, if tso is enabled
  460. *
  461. * Return: none
  462. */
  463. static inline void hal_tx_ext_desc_set_tcp_flags(void *desc,
  464. uint16_t tcp_flags,
  465. uint16_t mask)
  466. {
  467. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_0, TCP_FLAG) |=
  468. ((HAL_TX_SM(TX_MSDU_EXTENSION_0, TCP_FLAG, tcp_flags)) |
  469. (HAL_TX_SM(TX_MSDU_EXTENSION_0, TCP_FLAG_MASK, mask)));
  470. }
  471. /**
  472. * hal_tx_ext_desc_set_msdu_length() - Set L2 and IP Lengths
  473. * @desc: Handle to Tx MSDU Extension Descriptor
  474. * @l2_len: L2 length for the msdu, if tso is enabled
  475. * @ip_len: IP length for the msdu, if tso is enabled
  476. *
  477. * Return: none
  478. */
  479. static inline void hal_tx_ext_desc_set_msdu_length(void *desc,
  480. uint16_t l2_len,
  481. uint16_t ip_len)
  482. {
  483. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_1, L2_LENGTH) |=
  484. ((HAL_TX_SM(TX_MSDU_EXTENSION_1, L2_LENGTH, l2_len)) |
  485. (HAL_TX_SM(TX_MSDU_EXTENSION_1, IP_LENGTH, ip_len)));
  486. }
  487. /**
  488. * hal_tx_ext_desc_set_tcp_seq() - Set TCP Sequence number
  489. * @desc: Handle to Tx MSDU Extension Descriptor
  490. * @seq_num: Tcp_seq_number for the msdu, if tso is enabled
  491. *
  492. * Return: none
  493. */
  494. static inline void hal_tx_ext_desc_set_tcp_seq(void *desc,
  495. uint32_t seq_num)
  496. {
  497. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_2, TCP_SEQ_NUMBER) |=
  498. ((HAL_TX_SM(TX_MSDU_EXTENSION_2, TCP_SEQ_NUMBER, seq_num)));
  499. }
  500. /**
  501. * hal_tx_ext_desc_set_ip_id() - Set IP Identification field
  502. * @desc: Handle to Tx MSDU Extension Descriptor
  503. * @id: IP Id field for the msdu, if tso is enabled
  504. *
  505. * Return: none
  506. */
  507. static inline void hal_tx_ext_desc_set_ip_id(void *desc,
  508. uint16_t id)
  509. {
  510. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_3, IP_IDENTIFICATION) |=
  511. ((HAL_TX_SM(TX_MSDU_EXTENSION_3, IP_IDENTIFICATION, id)));
  512. }
  513. /**
  514. * hal_tx_ext_desc_set_buffer() - Set Buffer Pointer and Length for a fragment
  515. * @desc: Handle to Tx MSDU Extension Descriptor
  516. * @frag_num: Fragment number (value can be 0 to 5)
  517. * @paddr_lo: Lower 32-bit of Buffer Physical address
  518. * @paddr_hi: Upper 32-bit of Buffer Physical address
  519. * @length: Buffer Length
  520. *
  521. * Return: none
  522. */
  523. static inline void hal_tx_ext_desc_set_buffer(void *desc,
  524. uint8_t frag_num,
  525. uint32_t paddr_lo,
  526. uint16_t paddr_hi,
  527. uint16_t length)
  528. {
  529. HAL_SET_FLD_OFFSET(desc, TX_MSDU_EXTENSION_6, BUF0_PTR_31_0,
  530. (frag_num << 3)) |=
  531. ((HAL_TX_SM(TX_MSDU_EXTENSION_6, BUF0_PTR_31_0, paddr_lo)));
  532. HAL_SET_FLD_OFFSET(desc, TX_MSDU_EXTENSION_7, BUF0_PTR_39_32,
  533. (frag_num << 3)) |=
  534. ((HAL_TX_SM(TX_MSDU_EXTENSION_7, BUF0_PTR_39_32,
  535. (paddr_hi))));
  536. HAL_SET_FLD_OFFSET(desc, TX_MSDU_EXTENSION_7, BUF0_LEN,
  537. (frag_num << 3)) |=
  538. ((HAL_TX_SM(TX_MSDU_EXTENSION_7, BUF0_LEN, length)));
  539. }
  540. /**
  541. * hal_tx_ext_desc_set_buffer0_param() - Set Buffer 0 Pointer and Length
  542. * @desc: Handle to Tx MSDU Extension Descriptor
  543. * @paddr_lo: Lower 32-bit of Buffer Physical address
  544. * @paddr_hi: Upper 32-bit of Buffer Physical address
  545. * @length: Buffer 0 Length
  546. *
  547. * Return: none
  548. */
  549. static inline void hal_tx_ext_desc_set_buffer0_param(void *desc,
  550. uint32_t paddr_lo,
  551. uint16_t paddr_hi,
  552. uint16_t length)
  553. {
  554. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_6, BUF0_PTR_31_0) |=
  555. ((HAL_TX_SM(TX_MSDU_EXTENSION_6, BUF0_PTR_31_0, paddr_lo)));
  556. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_7, BUF0_PTR_39_32) |=
  557. ((HAL_TX_SM(TX_MSDU_EXTENSION_7,
  558. BUF0_PTR_39_32, paddr_hi)));
  559. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_7, BUF0_LEN) |=
  560. ((HAL_TX_SM(TX_MSDU_EXTENSION_7, BUF0_LEN, length)));
  561. }
  562. /**
  563. * hal_tx_ext_desc_set_buffer1_param() - Set Buffer 1 Pointer and Length
  564. * @desc: Handle to Tx MSDU Extension Descriptor
  565. * @paddr_lo: Lower 32-bit of Buffer Physical address
  566. * @paddr_hi: Upper 32-bit of Buffer Physical address
  567. * @length: Buffer 1 Length
  568. *
  569. * Return: none
  570. */
  571. static inline void hal_tx_ext_desc_set_buffer1_param(void *desc,
  572. uint32_t paddr_lo,
  573. uint16_t paddr_hi,
  574. uint16_t length)
  575. {
  576. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_8, BUF1_PTR_31_0) |=
  577. ((HAL_TX_SM(TX_MSDU_EXTENSION_8, BUF1_PTR_31_0, paddr_lo)));
  578. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_9, BUF1_PTR_39_32) |=
  579. ((HAL_TX_SM(TX_MSDU_EXTENSION_9,
  580. BUF1_PTR_39_32, paddr_hi)));
  581. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_9, BUF1_LEN) |=
  582. ((HAL_TX_SM(TX_MSDU_EXTENSION_9, BUF1_LEN, length)));
  583. }
  584. /**
  585. * hal_tx_ext_desc_set_buffer2_param() - Set Buffer 2 Pointer and Length
  586. * @desc: Handle to Tx MSDU Extension Descriptor
  587. * @paddr_lo: Lower 32-bit of Buffer Physical address
  588. * @paddr_hi: Upper 32-bit of Buffer Physical address
  589. * @length: Buffer 2 Length
  590. *
  591. * Return: none
  592. */
  593. static inline void hal_tx_ext_desc_set_buffer2_param(void *desc,
  594. uint32_t paddr_lo,
  595. uint16_t paddr_hi,
  596. uint16_t length)
  597. {
  598. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_10, BUF2_PTR_31_0) |=
  599. ((HAL_TX_SM(TX_MSDU_EXTENSION_10, BUF2_PTR_31_0,
  600. paddr_lo)));
  601. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_11, BUF2_PTR_39_32) |=
  602. ((HAL_TX_SM(TX_MSDU_EXTENSION_11, BUF2_PTR_39_32,
  603. paddr_hi)));
  604. HAL_SET_FLD(desc, TX_MSDU_EXTENSION_11, BUF2_LEN) |=
  605. ((HAL_TX_SM(TX_MSDU_EXTENSION_11, BUF2_LEN, length)));
  606. }
  607. /**
  608. * hal_tx_ext_desc_sync - Commit the descriptor to Hardware
  609. * @desc_cached: Cached descriptor that software maintains
  610. * @hw_desc: Hardware descriptor to be updated
  611. *
  612. * Return: none
  613. */
  614. static inline void hal_tx_ext_desc_sync(uint8_t *desc_cached,
  615. uint8_t *hw_desc)
  616. {
  617. qdf_mem_copy(&hw_desc[0], &desc_cached[0],
  618. HAL_TX_EXT_DESC_WITH_META_DATA);
  619. }
  620. /**
  621. * hal_tx_ext_desc_get_tso_enable() - Set TSO Enable Flag
  622. * @hal_tx_ext_desc: Handle to Tx MSDU Extension Descriptor
  623. *
  624. * Return: tso_enable value in the descriptor
  625. */
  626. static inline uint32_t hal_tx_ext_desc_get_tso_enable(void *hal_tx_ext_desc)
  627. {
  628. uint32_t *desc = (uint32_t *) hal_tx_ext_desc;
  629. return (*desc & TX_MSDU_EXTENSION_0_TSO_ENABLE_MASK) >>
  630. TX_MSDU_EXTENSION_0_TSO_ENABLE_LSB;
  631. }
  632. /*---------------------------------------------------------------------------
  633. WBM Descriptor accessor APIs for Tx completions
  634. ---------------------------------------------------------------------------*/
  635. /**
  636. * hal_tx_comp_get_desc_id() - Get TX descriptor id within comp descriptor
  637. * @hal_desc: completion ring descriptor pointer
  638. *
  639. * This function will tx descriptor id, cookie, within hardware completion
  640. * descriptor
  641. *
  642. * Return: cookie
  643. */
  644. static inline uint32_t hal_tx_comp_get_desc_id(void *hal_desc)
  645. {
  646. uint32_t comp_desc =
  647. *(uint32_t *) (((uint8_t *) hal_desc) +
  648. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET);
  649. /* Cookie is placed on 2nd word */
  650. return (comp_desc & BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_MASK) >>
  651. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_LSB;
  652. }
  653. /**
  654. * hal_tx_comp_get_paddr() - Get paddr within comp descriptor
  655. * @hal_desc: completion ring descriptor pointer
  656. *
  657. * This function will get buffer physical address within hardware completion
  658. * descriptor
  659. *
  660. * Return: Buffer physical address
  661. */
  662. static inline qdf_dma_addr_t hal_tx_comp_get_paddr(void *hal_desc)
  663. {
  664. uint32_t paddr_lo;
  665. uint32_t paddr_hi;
  666. paddr_lo = *(uint32_t *) (((uint8_t *) hal_desc) +
  667. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_OFFSET);
  668. paddr_hi = *(uint32_t *) (((uint8_t *) hal_desc) +
  669. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_OFFSET);
  670. paddr_hi = (paddr_hi & BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_MASK) >>
  671. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_LSB;
  672. return (qdf_dma_addr_t) (paddr_lo | (((uint64_t) paddr_hi) << 32));
  673. }
  674. /**
  675. * hal_tx_comp_get_buffer_source() - Get buffer release source value
  676. * @hal_desc: completion ring descriptor pointer
  677. *
  678. * This function will get buffer release source from Tx completion descriptor
  679. *
  680. * Return: buffer release source
  681. */
  682. static inline uint32_t hal_tx_comp_get_buffer_source(void *hal_desc)
  683. {
  684. uint32_t comp_desc =
  685. *(uint32_t *) (((uint8_t *) hal_desc) +
  686. WBM_RELEASE_RING_2_RELEASE_SOURCE_MODULE_OFFSET);
  687. return (comp_desc & WBM_RELEASE_RING_2_RELEASE_SOURCE_MODULE_MASK) >>
  688. WBM_RELEASE_RING_2_RELEASE_SOURCE_MODULE_LSB;
  689. }
  690. /**
  691. * hal_tx_comp_get_buffer_type() - Buffer or Descriptor type
  692. * @hal_desc: completion ring descriptor pointer
  693. *
  694. * This function will return the type of pointer - buffer or descriptor
  695. *
  696. * Return: buffer type
  697. */
  698. static inline uint32_t hal_tx_comp_get_buffer_type(void *hal_desc)
  699. {
  700. uint32_t comp_desc =
  701. *(uint32_t *) (((uint8_t *) hal_desc) +
  702. WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_OFFSET);
  703. return (comp_desc & WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_MASK) >>
  704. WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_LSB;
  705. }
  706. /**
  707. * hal_tx_comp_get_release_reason() - TQM Release reason
  708. * @hal_desc: completion ring descriptor pointer
  709. *
  710. * This function will return the type of pointer - buffer or descriptor
  711. *
  712. * Return: buffer type
  713. */
  714. static inline
  715. uint8_t hal_tx_comp_get_release_reason(void *hal_desc,
  716. hal_soc_handle_t hal_soc_hdl)
  717. {
  718. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  719. return hal_soc->ops->hal_tx_comp_get_release_reason(hal_desc);
  720. }
  721. /**
  722. * hal_tx_comp_desc_sync() - collect hardware descriptor contents
  723. * @hal_desc: hardware descriptor pointer
  724. * @comp: software descriptor pointer
  725. * @read_status: 0 - Do not read status words from descriptors
  726. * 1 - Enable reading of status words from descriptor
  727. *
  728. * This function will collect hardware release ring element contents and
  729. * translate to software descriptor content
  730. *
  731. * Return: none
  732. */
  733. static inline void hal_tx_comp_desc_sync(void *hw_desc,
  734. struct hal_tx_desc_comp_s *comp,
  735. bool read_status)
  736. {
  737. if (!read_status)
  738. qdf_mem_copy(comp, hw_desc, HAL_TX_COMPLETION_DESC_BASE_LEN);
  739. else
  740. qdf_mem_copy(comp, hw_desc, HAL_TX_COMPLETION_DESC_LEN_BYTES);
  741. }
  742. /**
  743. * hal_dump_comp_desc() - dump tx completion descriptor
  744. * @hal_desc: hardware descriptor pointer
  745. *
  746. * This function will print tx completion descriptor
  747. *
  748. * Return: none
  749. */
  750. static inline void hal_dump_comp_desc(void *hw_desc)
  751. {
  752. struct hal_tx_desc_comp_s *comp =
  753. (struct hal_tx_desc_comp_s *)hw_desc;
  754. uint32_t i;
  755. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_FATAL,
  756. "Current tx completion descriptor is");
  757. for (i = 0; i < HAL_TX_COMPLETION_DESC_LEN_DWORDS; i++) {
  758. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_FATAL,
  759. "DWORD[i] = 0x%x", comp->desc[i]);
  760. }
  761. }
  762. /**
  763. * hal_tx_comp_get_htt_desc() - Read the HTT portion of WBM Descriptor
  764. * @hal_desc: Hardware (WBM) descriptor pointer
  765. * @htt_desc: Software HTT descriptor pointer
  766. *
  767. * This function will read the HTT structure overlaid on WBM descriptor
  768. * into a cached software descriptor
  769. *
  770. */
  771. static inline void hal_tx_comp_get_htt_desc(void *hw_desc, uint8_t *htt_desc)
  772. {
  773. uint8_t *desc = hw_desc + HAL_TX_COMP_HTT_STATUS_OFFSET;
  774. qdf_mem_copy(htt_desc, desc, HAL_TX_COMP_HTT_STATUS_LEN);
  775. }
  776. /**
  777. * hal_tx_init_data_ring() - Initialize all the TCL Descriptors in SRNG
  778. * @hal_soc_hdl: Handle to HAL SoC structure
  779. * @hal_srng: Handle to HAL SRNG structure
  780. *
  781. * Return: none
  782. */
  783. static inline void hal_tx_init_data_ring(hal_soc_handle_t hal_soc_hdl,
  784. hal_ring_handle_t hal_ring_hdl)
  785. {
  786. uint8_t *desc_addr;
  787. struct hal_srng_params srng_params;
  788. uint32_t desc_size;
  789. uint32_t num_desc;
  790. hal_get_srng_params(hal_soc_hdl, hal_ring_hdl, &srng_params);
  791. desc_addr = (uint8_t *)srng_params.ring_base_vaddr;
  792. desc_size = sizeof(struct tcl_data_cmd);
  793. num_desc = srng_params.num_entries;
  794. while (num_desc) {
  795. HAL_TX_DESC_SET_TLV_HDR(desc_addr, HAL_TX_TCL_DATA_TAG,
  796. desc_size);
  797. desc_addr += (desc_size + sizeof(struct tlv_32_hdr));
  798. num_desc--;
  799. }
  800. }
  801. /**
  802. * hal_tx_desc_set_dscp_tid_table_id() - Sets DSCP to TID conversion table ID
  803. * @hal_soc: Handle to HAL SoC structure
  804. * @desc: Handle to Tx Descriptor
  805. * @id: DSCP to tid conversion table to be used for this frame
  806. *
  807. * Return: void
  808. */
  809. static inline
  810. void hal_tx_desc_set_dscp_tid_table_id(hal_soc_handle_t hal_soc_hdl,
  811. void *desc, uint8_t id)
  812. {
  813. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  814. hal_soc->ops->hal_tx_desc_set_dscp_tid_table_id(desc, id);
  815. }
  816. /**
  817. * hal_tx_set_dscp_tid_map_default() - Configure default DSCP to TID map table
  818. *
  819. * @soc: HAL SoC context
  820. * @map: DSCP-TID mapping table
  821. * @id: mapping table ID - 0,1
  822. *
  823. * Return: void
  824. */
  825. static inline void hal_tx_set_dscp_tid_map(hal_soc_handle_t hal_soc_hdl,
  826. uint8_t *map, uint8_t id)
  827. {
  828. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  829. hal_soc->ops->hal_tx_set_dscp_tid_map(hal_soc, map, id);
  830. }
  831. /**
  832. * hal_tx_update_dscp_tid() - Update the dscp tid map table as updated by user
  833. *
  834. * @soc: HAL SoC context
  835. * @map: DSCP-TID mapping table
  836. * @id : MAP ID
  837. * @dscp: DSCP_TID map index
  838. *
  839. * Return: void
  840. */
  841. static inline
  842. void hal_tx_update_dscp_tid(hal_soc_handle_t hal_soc_hdl, uint8_t tid,
  843. uint8_t id, uint8_t dscp)
  844. {
  845. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  846. hal_soc->ops->hal_tx_update_dscp_tid(hal_soc, tid, id, dscp);
  847. }
  848. /**
  849. * hal_tx_desc_set_lmac_id - Set the lmac_id value
  850. * @desc: Handle to Tx Descriptor
  851. * @lmac_id: mac Id to ast matching
  852. * b00 – mac 0
  853. * b01 – mac 1
  854. * b10 – mac 2
  855. * b11 – all macs (legacy HK way)
  856. *
  857. * Return: void
  858. */
  859. static inline void hal_tx_desc_set_lmac_id(hal_soc_handle_t hal_soc_hdl,
  860. void *desc, uint8_t lmac_id)
  861. {
  862. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  863. hal_soc->ops->hal_tx_desc_set_lmac_id(desc, lmac_id);
  864. }
  865. /**
  866. * hal_tx_desc_set_search_type - Set the search type value
  867. * @desc: Handle to Tx Descriptor
  868. * @search_type: search type
  869. * 0 – Normal search
  870. * 1 – Index based address search
  871. * 2 – Index based flow search
  872. *
  873. * Return: void
  874. */
  875. static inline void hal_tx_desc_set_search_type(hal_soc_handle_t hal_soc_hdl,
  876. void *desc, uint8_t search_type)
  877. {
  878. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  879. hal_soc->ops->hal_tx_desc_set_search_type(desc, search_type);
  880. }
  881. /**
  882. * hal_tx_desc_set_search_index - Set the search index value
  883. * @desc: Handle to Tx Descriptor
  884. * @search_index: The index that will be used for index based address or
  885. * flow search. The field is valid when 'search_type' is
  886. * 1 0r 2
  887. *
  888. * Return: void
  889. */
  890. static inline void hal_tx_desc_set_search_index(hal_soc_handle_t hal_soc_hdl,
  891. void *desc,
  892. uint32_t search_index)
  893. {
  894. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  895. hal_soc->ops->hal_tx_desc_set_search_index(desc, search_index);
  896. }
  897. /**
  898. * hal_tx_desc_set_cache_set_num - Set the cache-set-num value
  899. * @desc: Handle to Tx Descriptor
  900. * @cache_num: Cache set number that should be used to cache the index
  901. * based search results, for address and flow search.
  902. * This value should be equal to LSB four bits of the hash value
  903. * of match data, in case of search index points to an entry
  904. * which may be used in content based search also. The value can
  905. * be anything when the entry pointed by search index will not be
  906. * used for content based search.
  907. *
  908. * Return: void
  909. */
  910. static inline void hal_tx_desc_set_cache_set_num(hal_soc_handle_t hal_soc_hdl,
  911. void *desc,
  912. uint8_t cache_num)
  913. {
  914. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  915. hal_soc->ops->hal_tx_desc_set_cache_set_num(desc, cache_num);
  916. }
  917. /**
  918. * hal_tx_comp_get_status() - TQM Release reason
  919. * @hal_desc: completion ring Tx status
  920. *
  921. * This function will parse the WBM completion descriptor and populate in
  922. * HAL structure
  923. *
  924. * Return: none
  925. */
  926. static inline void hal_tx_comp_get_status(void *desc, void *ts,
  927. hal_soc_handle_t hal_soc_hdl)
  928. {
  929. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  930. hal_soc->ops->hal_tx_comp_get_status(desc, ts, hal_soc);
  931. }
  932. /**
  933. * hal_tx_desc_set_buf_addr - Fill Buffer Address information in Tx Descriptor
  934. * @desc: Handle to Tx Descriptor
  935. * @paddr: Physical Address
  936. * @pool_id: Return Buffer Manager ID
  937. * @desc_id: Descriptor ID
  938. * @type: 0 - Address points to a MSDU buffer
  939. * 1 - Address points to MSDU extension descriptor
  940. *
  941. * Return: void
  942. */
  943. static inline
  944. void hal_tx_desc_set_buf_addr(void *desc, dma_addr_t paddr,
  945. uint8_t pool_id, uint32_t desc_id,
  946. uint8_t type, hal_soc_handle_t hal_soc_hdl)
  947. {
  948. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  949. hal_soc->ops->hal_tx_desc_set_buf_addr(desc, paddr, pool_id,
  950. desc_id, type);
  951. }
  952. /**
  953. * hal_tx_set_pcp_tid_map_default() - Configure default PCP to TID map table
  954. *
  955. * @soc: HAL SoC context
  956. * @map: PCP-TID mapping table
  957. *
  958. * Return: void
  959. */
  960. static inline void hal_tx_set_pcp_tid_map_default(hal_soc_handle_t hal_soc_hdl,
  961. uint8_t *map)
  962. {
  963. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  964. hal_soc->ops->hal_tx_set_pcp_tid_map(hal_soc, map);
  965. }
  966. /**
  967. * hal_tx_update_pcp_tid_map() - Update PCP to TID map table
  968. *
  969. * @soc: HAL SoC context
  970. * @pcp: pcp value
  971. * @tid: tid no
  972. *
  973. * Return: void
  974. */
  975. static inline void hal_tx_update_pcp_tid_map(hal_soc_handle_t hal_soc_hdl,
  976. uint8_t pcp, uint8_t tid)
  977. {
  978. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  979. hal_soc->ops->hal_tx_update_pcp_tid_map(hal_soc, tid, tid);
  980. }
  981. /**
  982. * hal_tx_set_tidmap_prty() - Configure TIDmap priority
  983. *
  984. * @soc: HAL SoC context
  985. * @val: priority value
  986. *
  987. * Return: void
  988. */
  989. static inline
  990. void hal_tx_set_tidmap_prty(hal_soc_handle_t hal_soc_hdl, uint8_t val)
  991. {
  992. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  993. hal_soc->ops->hal_tx_set_tidmap_prty(hal_soc, val);
  994. }
  995. /**
  996. * hal_get_wbm_internal_error() - wbm internal error
  997. * @hal_desc: completion ring descriptor pointer
  998. *
  999. * This function will return the type of pointer - buffer or descriptor
  1000. *
  1001. * Return: buffer type
  1002. */
  1003. static inline uint8_t hal_get_wbm_internal_error(void *hal_desc)
  1004. {
  1005. uint32_t comp_desc =
  1006. *(uint32_t *)(((uint8_t *)hal_desc) +
  1007. WBM_RELEASE_RING_2_WBM_INTERNAL_ERROR_OFFSET);
  1008. return (comp_desc & WBM_RELEASE_RING_2_WBM_INTERNAL_ERROR_MASK) >>
  1009. WBM_RELEASE_RING_2_WBM_INTERNAL_ERROR_LSB;
  1010. }
  1011. #endif /* HAL_TX_H */