hal_tx.h 35 KB

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