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