xref: /wlan-driver/qca-wifi-host-cmn/hal/wifi3.0/qca8074v1/hal_8074v1_tx.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved.
3*5113495bSYour Name  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name  *
5*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for
6*5113495bSYour Name  * any purpose with or without fee is hereby granted, provided that the
7*5113495bSYour Name  * above copyright notice and this permission notice appear in all
8*5113495bSYour Name  * copies.
9*5113495bSYour Name  *
10*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11*5113495bSYour Name  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12*5113495bSYour Name  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13*5113495bSYour Name  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14*5113495bSYour Name  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15*5113495bSYour Name  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16*5113495bSYour Name  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17*5113495bSYour Name  * PERFORMANCE OF THIS SOFTWARE.
18*5113495bSYour Name  */
19*5113495bSYour Name #include "hal_hw_headers.h"
20*5113495bSYour Name #include "hal_internal.h"
21*5113495bSYour Name #include "cdp_txrx_mon_struct.h"
22*5113495bSYour Name #include "qdf_trace.h"
23*5113495bSYour Name #include "hal_rx.h"
24*5113495bSYour Name #include "hal_tx.h"
25*5113495bSYour Name #include "dp_types.h"
26*5113495bSYour Name #include "hal_api_mon.h"
27*5113495bSYour Name 
28*5113495bSYour Name /**
29*5113495bSYour Name  * hal_tx_desc_set_dscp_tid_table_id_8074() - Sets DSCP to TID conversion
30*5113495bSYour Name  *                                            table ID
31*5113495bSYour Name  * @desc: Handle to Tx Descriptor
32*5113495bSYour Name  * @id: DSCP to tid conversion table to be used for this frame
33*5113495bSYour Name  *
34*5113495bSYour Name  * Return: void
35*5113495bSYour Name  */
36*5113495bSYour Name 
hal_tx_desc_set_dscp_tid_table_id_8074(void * desc,uint8_t id)37*5113495bSYour Name static void hal_tx_desc_set_dscp_tid_table_id_8074(void *desc, uint8_t id)
38*5113495bSYour Name {
39*5113495bSYour Name 	HAL_SET_FLD(desc, TCL_DATA_CMD_3,
40*5113495bSYour Name 		    DSCP_TO_TID_PRIORITY_TABLE_ID) |=
41*5113495bSYour Name 	HAL_TX_SM(TCL_DATA_CMD_3,
42*5113495bSYour Name 		  DSCP_TO_TID_PRIORITY_TABLE_ID, id);
43*5113495bSYour Name }
44*5113495bSYour Name 
45*5113495bSYour Name /**
46*5113495bSYour Name  * hal_tx_set_dscp_tid_map_8074() - Configure default DSCP to TID map table
47*5113495bSYour Name  * @soc: HAL SoC context
48*5113495bSYour Name  * @map: DSCP-TID mapping table
49*5113495bSYour Name  * @id: mapping table ID - 0,1
50*5113495bSYour Name  *
51*5113495bSYour Name  * DSCP are mapped to 8 TID values using TID values programmed
52*5113495bSYour Name  * in two set of mapping registers DSCP_TID1_MAP_<0 to 6> (id = 0)
53*5113495bSYour Name  * and DSCP_TID2_MAP_<0 to 6> (id = 1)
54*5113495bSYour Name  * Each mapping register has TID mapping for 10 DSCP values
55*5113495bSYour Name  *
56*5113495bSYour Name  * Return: none
57*5113495bSYour Name  */
hal_tx_set_dscp_tid_map_8074(struct hal_soc * soc,uint8_t * map,uint8_t id)58*5113495bSYour Name static void hal_tx_set_dscp_tid_map_8074(struct hal_soc *soc, uint8_t *map,
59*5113495bSYour Name 					 uint8_t id)
60*5113495bSYour Name {
61*5113495bSYour Name 	int i;
62*5113495bSYour Name 	uint32_t addr;
63*5113495bSYour Name 	uint32_t value;
64*5113495bSYour Name 
65*5113495bSYour Name 	if (id == HAL_TX_DSCP_TID_MAP_TABLE_DEFAULT) {
66*5113495bSYour Name 		addr = HWIO_TCL_R0_DSCP_TID1_MAP_0_ADDR(
67*5113495bSYour Name 				SEQ_WCSS_UMAC_MAC_TCL_REG_OFFSET);
68*5113495bSYour Name 	} else {
69*5113495bSYour Name 		addr = HWIO_TCL_R0_DSCP_TID2_MAP_0_ADDR(
70*5113495bSYour Name 				SEQ_WCSS_UMAC_MAC_TCL_REG_OFFSET);
71*5113495bSYour Name 	}
72*5113495bSYour Name 
73*5113495bSYour Name 	for (i = 0; i < 64; i += 10) {
74*5113495bSYour Name 		value =
75*5113495bSYour Name 		  (map[i] |
76*5113495bSYour Name 		  (map[i + 1] << HWIO_TCL_R0_DSCP_TID1_MAP_0_DSCP_1_SHFT) |
77*5113495bSYour Name 		  (map[i + 2] << HWIO_TCL_R0_DSCP_TID1_MAP_0_DSCP_2_SHFT) |
78*5113495bSYour Name 		  (map[i + 3] << HWIO_TCL_R0_DSCP_TID1_MAP_0_DSCP_3_SHFT) |
79*5113495bSYour Name 		  (map[i + 4] << HWIO_TCL_R0_DSCP_TID1_MAP_0_DSCP_4_SHFT) |
80*5113495bSYour Name 		  (map[i + 5] << HWIO_TCL_R0_DSCP_TID1_MAP_0_DSCP_5_SHFT) |
81*5113495bSYour Name 		  (map[i + 6] << HWIO_TCL_R0_DSCP_TID1_MAP_0_DSCP_6_SHFT) |
82*5113495bSYour Name 		  (map[i + 7] << HWIO_TCL_R0_DSCP_TID1_MAP_0_DSCP_7_SHFT) |
83*5113495bSYour Name 		  (map[i + 8] << HWIO_TCL_R0_DSCP_TID1_MAP_0_DSCP_8_SHFT) |
84*5113495bSYour Name 		  (map[i + 9] << HWIO_TCL_R0_DSCP_TID1_MAP_0_DSCP_9_SHFT));
85*5113495bSYour Name 
86*5113495bSYour Name 		HAL_REG_WRITE(soc, addr,
87*5113495bSYour Name 			      (value & HWIO_TCL_R0_DSCP_TID1_MAP_1_RMSK));
88*5113495bSYour Name 
89*5113495bSYour Name 		addr += 4;
90*5113495bSYour Name 	}
91*5113495bSYour Name }
92*5113495bSYour Name 
93*5113495bSYour Name /**
94*5113495bSYour Name  * hal_tx_update_dscp_tid_8074() - Update the dscp tid map table as
95*5113495bSYour Name  *                                 updated by user
96*5113495bSYour Name  * @soc: HAL SoC context
97*5113495bSYour Name  * @tid: TID
98*5113495bSYour Name  * @id: MAP ID
99*5113495bSYour Name  * @dscp: DSCP
100*5113495bSYour Name  *
101*5113495bSYour Name  * Return: void
102*5113495bSYour Name  */
103*5113495bSYour Name static
hal_tx_update_dscp_tid_8074(struct hal_soc * soc,uint8_t tid,uint8_t id,uint8_t dscp)104*5113495bSYour Name void hal_tx_update_dscp_tid_8074(struct hal_soc *soc, uint8_t tid,
105*5113495bSYour Name 				 uint8_t id, uint8_t dscp)
106*5113495bSYour Name {
107*5113495bSYour Name 	int index;
108*5113495bSYour Name 	uint32_t addr;
109*5113495bSYour Name 	uint32_t value;
110*5113495bSYour Name 	uint32_t regval;
111*5113495bSYour Name 
112*5113495bSYour Name 	if (id == HAL_TX_DSCP_TID_MAP_TABLE_DEFAULT)
113*5113495bSYour Name 		addr = HWIO_TCL_R0_DSCP_TID1_MAP_0_ADDR(
114*5113495bSYour Name 				SEQ_WCSS_UMAC_MAC_TCL_REG_OFFSET);
115*5113495bSYour Name 	else
116*5113495bSYour Name 		addr = HWIO_TCL_R0_DSCP_TID2_MAP_0_ADDR(
117*5113495bSYour Name 				SEQ_WCSS_UMAC_MAC_TCL_REG_OFFSET);
118*5113495bSYour Name 
119*5113495bSYour Name 	index = dscp % HAL_TX_NUM_DSCP_PER_REGISTER;
120*5113495bSYour Name 	addr += 4 * (dscp / HAL_TX_NUM_DSCP_PER_REGISTER);
121*5113495bSYour Name 	value = tid << (HAL_TX_BITS_PER_TID * index);
122*5113495bSYour Name 
123*5113495bSYour Name 	/* Read back previous DSCP TID config and update
124*5113495bSYour Name 	 * with new config.
125*5113495bSYour Name 	 */
126*5113495bSYour Name 	regval = HAL_REG_READ(soc, addr);
127*5113495bSYour Name 	regval &= ~(HAL_TX_TID_BITS_MASK << (HAL_TX_BITS_PER_TID * index));
128*5113495bSYour Name 	regval |= value;
129*5113495bSYour Name 
130*5113495bSYour Name 	HAL_REG_WRITE(soc, addr,
131*5113495bSYour Name 		      (regval & HWIO_TCL_R0_DSCP_TID1_MAP_1_RMSK));
132*5113495bSYour Name }
133*5113495bSYour Name 
134*5113495bSYour Name /**
135*5113495bSYour Name  * hal_tx_desc_set_lmac_id_8074() - Set the lmac_id value
136*5113495bSYour Name  * @desc: Handle to Tx Descriptor
137*5113495bSYour Name  * @lmac_id: mac Id to ast matching
138*5113495bSYour Name  *		     b00 – mac 0
139*5113495bSYour Name  *		     b01 – mac 1
140*5113495bSYour Name  *		     b10 – mac 2
141*5113495bSYour Name  *		     b11 – all macs (legacy HK way)
142*5113495bSYour Name  *
143*5113495bSYour Name  * Return: void
144*5113495bSYour Name  */
hal_tx_desc_set_lmac_id_8074(void * desc,uint8_t lmac_id)145*5113495bSYour Name static void hal_tx_desc_set_lmac_id_8074(void *desc, uint8_t lmac_id)
146*5113495bSYour Name {
147*5113495bSYour Name }
148*5113495bSYour Name 
149*5113495bSYour Name /**
150*5113495bSYour Name  * hal_tx_init_cmd_credit_ring_8074v1() - Initialize command/credit SRNG
151*5113495bSYour Name  * @hal_soc_hdl: Handle to HAL SoC structure
152*5113495bSYour Name  * @hal_ring_hdl: Handle to HAL SRNG structure
153*5113495bSYour Name  *
154*5113495bSYour Name  * Return: none
155*5113495bSYour Name  */
hal_tx_init_cmd_credit_ring_8074v1(hal_soc_handle_t hal_soc_hdl,hal_ring_handle_t hal_ring_hdl)156*5113495bSYour Name static inline void hal_tx_init_cmd_credit_ring_8074v1(hal_soc_handle_t hal_soc_hdl,
157*5113495bSYour Name 						      hal_ring_handle_t hal_ring_hdl)
158*5113495bSYour Name {
159*5113495bSYour Name 	uint8_t *desc_addr;
160*5113495bSYour Name 	struct hal_srng_params srng_params;
161*5113495bSYour Name 	uint32_t desc_size;
162*5113495bSYour Name 	uint32_t num_desc;
163*5113495bSYour Name 
164*5113495bSYour Name 	hal_get_srng_params(hal_soc_hdl, hal_ring_hdl, &srng_params);
165*5113495bSYour Name 
166*5113495bSYour Name 	desc_addr = (uint8_t *)srng_params.ring_base_vaddr;
167*5113495bSYour Name 	desc_size = sizeof(struct tcl_data_cmd);
168*5113495bSYour Name 	num_desc = srng_params.num_entries;
169*5113495bSYour Name 
170*5113495bSYour Name 	while (num_desc) {
171*5113495bSYour Name 		/* using CMD/CREDIT Ring to send DATA CMD tag */
172*5113495bSYour Name 		HAL_TX_DESC_SET_TLV_HDR(desc_addr, WIFITCL_DATA_CMD_E,
173*5113495bSYour Name 					desc_size);
174*5113495bSYour Name 		desc_addr += (desc_size + sizeof(struct tlv_32_hdr));
175*5113495bSYour Name 		num_desc--;
176*5113495bSYour Name 	}
177*5113495bSYour Name }
178