hal_tx.h 33 KB

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