1 /* 2 * Copyright (c) 2018 The Linux Foundation. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * * Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * * Redistributions in binary form must reproduce the above 10 * copyright notice, this list of conditions and the following 11 * disclaimer in the documentation and/or other materials provided 12 * with the distribution. 13 * * Neither the name of The Linux Foundation nor the names of its 14 * contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 #include "tcl_data_cmd.h" 31 #include "mac_tcl_reg_seq_hwioreg.h" 32 #include "phyrx_rssi_legacy.h" 33 #include "hal_hw_headers.h" 34 #include "hal_internal.h" 35 #include "cdp_txrx_mon_struct.h" 36 #include "qdf_trace.h" 37 #include "hal_rx.h" 38 #include "hal_tx.h" 39 #include "dp_types.h" 40 #include "hal_api_mon.h" 41 42 /** 43 * hal_tx_desc_set_dscp_tid_table_id_6390() - Sets DSCP to TID conversion 44 * table ID 45 * @desc: Handle to Tx Descriptor 46 * @id: DSCP to tid conversion table to be used for this frame 47 * 48 * Return: void 49 */ 50 static void hal_tx_desc_set_dscp_tid_table_id_6390(void *desc, uint8_t id) 51 { 52 HAL_SET_FLD(desc, TCL_DATA_CMD_5, 53 DSCP_TID_TABLE_NUM) |= 54 HAL_TX_SM(TCL_DATA_CMD_5, 55 DSCP_TID_TABLE_NUM, id); 56 } 57 58 #define DSCP_TID_TABLE_SIZE 24 59 #define NUM_WORDS_PER_DSCP_TID_TABLE (DSCP_TID_TABLE_SIZE / 4) 60 61 /** 62 * hal_tx_set_dscp_tid_map_6390() - Configure default DSCP to TID map table 63 * @soc: HAL SoC context 64 * @map: DSCP-TID mapping table 65 * @id: mapping table ID - 0-31 66 * 67 * DSCP are mapped to 8 TID values using TID values programmed 68 * in any of the 32 DSCP_TID_MAPS (id = 0-31). 69 * 70 * Return: none 71 */ 72 static void hal_tx_set_dscp_tid_map_6390(void *hal_soc, uint8_t *map, 73 uint8_t id) 74 { 75 int i; 76 uint32_t addr, cmn_reg_addr; 77 uint32_t value = 0, regval; 78 uint8_t val[DSCP_TID_TABLE_SIZE], cnt = 0; 79 80 struct hal_soc *soc = (struct hal_soc *)hal_soc; 81 82 if (id >= HAL_MAX_HW_DSCP_TID_MAPS_11AX) 83 return; 84 85 cmn_reg_addr = HWIO_TCL_R0_CONS_RING_CMN_CTRL_REG_ADDR( 86 SEQ_WCSS_UMAC_MAC_TCL_REG_OFFSET); 87 88 addr = HWIO_TCL_R0_DSCP_TID_MAP_n_ADDR( 89 SEQ_WCSS_UMAC_MAC_TCL_REG_OFFSET, 90 id * NUM_WORDS_PER_DSCP_TID_TABLE); 91 92 /* Enable read/write access */ 93 regval = HAL_REG_READ(soc, cmn_reg_addr); 94 regval |= 95 (1 << HWIO_TCL_R0_CONS_RING_CMN_CTRL_REG_DSCP_TID_MAP_PROGRAM_EN_SHFT); 96 97 HAL_REG_WRITE(soc, cmn_reg_addr, regval); 98 99 /* Write 8 (24 bits) DSCP-TID mappings in each interation */ 100 for (i = 0; i < 64; i += 8) { 101 value = (map[i] | 102 (map[i + 1] << 0x3) | 103 (map[i + 2] << 0x6) | 104 (map[i + 3] << 0x9) | 105 (map[i + 4] << 0xc) | 106 (map[i + 5] << 0xf) | 107 (map[i + 6] << 0x12) | 108 (map[i + 7] << 0x15)); 109 110 qdf_mem_copy(&val[cnt], (void *)&value, 3); 111 cnt += 3; 112 } 113 114 for (i = 0; i < DSCP_TID_TABLE_SIZE; i += 4) { 115 regval = *(uint32_t *)(val + i); 116 HAL_REG_WRITE(soc, addr, 117 (regval & HWIO_TCL_R0_DSCP_TID_MAP_n_RMSK)); 118 addr += 4; 119 } 120 121 /* Diasble read/write access */ 122 regval = HAL_REG_READ(soc, cmn_reg_addr); 123 regval &= 124 ~(HWIO_TCL_R0_CONS_RING_CMN_CTRL_REG_DSCP_TID_MAP_PROGRAM_EN_BMSK); 125 126 HAL_REG_WRITE(soc, cmn_reg_addr, regval); 127 } 128 129 /** 130 * hal_tx_update_dscp_tid_6390() - Update the dscp tid map table as updated 131 * by the user 132 * @soc: HAL SoC context 133 * @map: DSCP-TID mapping table 134 * @id : MAP ID 135 * @dscp: DSCP_TID map index 136 * 137 * Return: void 138 */ 139 static void hal_tx_update_dscp_tid_6390(void *hal_soc, uint8_t tid, 140 uint8_t id, uint8_t dscp) 141 { 142 int index; 143 uint32_t addr; 144 uint32_t value; 145 uint32_t regval; 146 struct hal_soc *soc = (struct hal_soc *)hal_soc; 147 148 addr = HWIO_TCL_R0_DSCP_TID_MAP_n_ADDR( 149 SEQ_WCSS_UMAC_MAC_TCL_REG_OFFSET, id); 150 151 index = dscp % HAL_TX_NUM_DSCP_PER_REGISTER; 152 addr += 4 * (dscp / HAL_TX_NUM_DSCP_PER_REGISTER); 153 value = tid << (HAL_TX_BITS_PER_TID * index); 154 155 regval = HAL_REG_READ(soc, addr); 156 regval &= ~(HAL_TX_TID_BITS_MASK << (HAL_TX_BITS_PER_TID * index)); 157 regval |= value; 158 159 HAL_REG_WRITE(soc, addr, (regval & HWIO_TCL_R0_DSCP_TID_MAP_n_RMSK)); 160 } 161 162 /** 163 * hal_tx_desc_set_lmac_id - Set the lmac_id value 164 * @desc: Handle to Tx Descriptor 165 * @lmac_id: mac Id to ast matching 166 * b00 – mac 0 167 * b01 – mac 1 168 * b10 – mac 2 169 * b11 – all macs (legacy HK way) 170 * 171 * Return: void 172 */ 173 static void hal_tx_desc_set_lmac_id_6390(void *desc, uint8_t lmac_id) 174 { 175 HAL_SET_FLD(desc, TCL_DATA_CMD_4, LMAC_ID) |= 176 HAL_TX_SM(TCL_DATA_CMD_4, LMAC_ID, lmac_id); 177 } 178 179