1 /* 2 * Copyright (c) 2019-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 #ifndef __HAL_RX_FLOW_H 20 #define __HAL_RX_FLOW_H 21 22 #include "hal_flow.h" 23 #include "wlan_cfg.h" 24 #include "hal_api.h" 25 #include "qdf_mem.h" 26 #include "rx_flow_search_entry.h" 27 #include "hal_rx_flow_info.h" 28 29 #define HAL_FST_HASH_KEY_SIZE_BITS 315 30 #define HAL_FST_HASH_KEY_SIZE_WORDS 10 31 #define HAL_FST_HASH_DATA_SIZE 37 32 #define HAL_FST_HASH_MASK 0x7ffff 33 #define HAL_RX_FST_ENTRY_SIZE (NUM_OF_DWORDS_RX_FLOW_SEARCH_ENTRY * 4) 34 35 /** 36 * Four possible options for IP SA/DA prefix, currently use 0x0 which 37 * maps to type 2 in HW spec 38 */ 39 #define HAL_FST_IP_DA_SA_PFX_TYPE_IPV4_COMPATIBLE_IPV6 2 40 41 #define HAL_IP_DA_SA_PREFIX_IPV4_COMPATIBLE_IPV6 0x0 42 43 /** 44 * REO destination indication is a lower 4-bits of hash value 45 * This should match the REO destination used in Rx hash based routing. 46 */ 47 #define HAL_REO_DEST_IND_HASH_MASK 0xF 48 49 /** 50 * REO destinations are valid from 16-31 for Hawkeye 51 * and 0-15 are not setup for SW 52 */ 53 #define HAL_REO_DEST_IND_START_OFFSET 0x10 54 55 /** 56 * enum hal_rx_fse_reo_destination_handler 57 * @HAL_RX_FSE_REO_DEST_FT: Use this entry's destination indication 58 * @HAL_RX_FSE_REO_DEST_ASPT: Use Address Search + Peer Table's entry 59 * @HAL_RX_FSE_REO_DEST_FT2: Use FT2's destination indication 60 * @HAL_RX_FSE_REO_DEST_CCE: Use CCE's destination indication for this entry 61 */ 62 enum hal_rx_fse_reo_destination_handler { 63 HAL_RX_FSE_REO_DEST_FT = 0, 64 HAL_RX_FSE_REO_DEST_ASPT = 1, 65 HAL_RX_FSE_REO_DEST_FT2 = 2, 66 HAL_RX_FSE_REO_DEST_CCE = 3, 67 }; 68 69 /** 70 * hal_rx_flow_setup_fse() - Setup a flow search entry in HW FST 71 * @fst: Pointer to the Rx Flow Search Table 72 * @table_offset: offset into the table where the flow is to be setup 73 * @flow: Flow Parameters 74 * 75 * Return: Success/Failure 76 */ 77 void * 78 hal_rx_flow_setup_fse(hal_soc_handle_t hal_soc_hdl, 79 struct hal_rx_fst *fst, uint32_t table_offset, 80 struct hal_rx_flow *flow); 81 82 /** 83 * hal_rx_flow_setup_cmem_fse() - Setup a flow search entry in HW CMEM FST 84 * @hal_soc_hdl: HAL SOC handle 85 * @cmem_ba: CMEM base address 86 * @table_offset: offset into the table where the flow is to be setup 87 * @flow: Flow Parameters 88 * 89 * Return: Success/Failure 90 */ 91 uint32_t 92 hal_rx_flow_setup_cmem_fse(hal_soc_handle_t hal_soc_hdl, uint32_t cmem_ba, 93 uint32_t table_offset, struct hal_rx_flow *flow); 94 95 /** 96 * hal_rx_flow_get_cmem_fse_timestamp() - Get timestamp field from CMEM FSE 97 * @hal_soc_hdl: HAL SOC handle 98 * @fse_offset: CMEM FSE offset 99 * 100 * Return: Timestamp 101 */ 102 uint32_t hal_rx_flow_get_cmem_fse_timestamp(hal_soc_handle_t hal_soc_hdl, 103 uint32_t fse_offset); 104 105 /** 106 * hal_rx_flow_delete_entry() - Delete a flow from the Rx Flow Search Table 107 * @hal_soc_hdl: HAL SOC handle 108 * @fst: Pointer to the Rx Flow Search Table 109 * @hal_rx_fse: Pointer to the Rx Flow that is to be deleted from the FST 110 * 111 * Return: Success/Failure 112 */ 113 QDF_STATUS 114 hal_rx_flow_delete_entry(hal_soc_handle_t hal_soc_hdl, 115 struct hal_rx_fst *fst, void *hal_rx_fse); 116 117 /** 118 * hal_rx_flow_get_tuple_info() - Retrieve the 5-tuple flow info for an entry 119 * @hal_soc_hdl: HAL SOC handle 120 * @fst: Pointer to the Rx Flow Search Table 121 * @hal_hash: HAL 5 tuple hash 122 * @tuple_info: 5-tuple info of the flow returned to the caller 123 * 124 * Return: Success/Failure 125 */ 126 void * 127 hal_rx_flow_get_tuple_info(hal_soc_handle_t hal_soc_hdl, 128 struct hal_rx_fst *fst, 129 uint32_t hal_hash, 130 struct hal_flow_tuple_info *tuple_info); 131 132 /** 133 * hal_rx_fst_attach() - Initialize Rx flow search table in HW FST 134 * 135 * @hal_soc_hdl: HAL SOC handle 136 * @qdf_dev: QDF device handle 137 * @hal_fst_base_paddr: Pointer to the physical base address of the Rx FST 138 * @max_entries: Max number of flows allowed in the FST 139 * @max_search: Number of collisions allowed in the hash-based FST 140 * @hash_key: Toeplitz key used for the hash FST 141 * 142 * Return: 143 */ 144 struct hal_rx_fst * 145 hal_rx_fst_attach(hal_soc_handle_t hal_soc_hdl, 146 qdf_device_t qdf_dev, 147 uint64_t *hal_fst_base_paddr, uint16_t max_entries, 148 uint16_t max_search, uint8_t *hash_key, 149 uint64_t fst_cmem_base); 150 151 /** 152 * hal_rx_fst_detach() - De-init the Rx flow search table from HW 153 * 154 * @hal_soc_hdl: HAL SOC handler 155 * @rx_fst: Pointer to the Rx FST 156 * @qdf_dev: QDF device handle 157 * 158 * Return: 159 */ 160 void hal_rx_fst_detach(hal_soc_handle_t hal_soc_hdl, struct hal_rx_fst *rx_fst, 161 qdf_device_t qdf_dev, uint64_t fst_cmem_base); 162 163 /** 164 * hal_rx_insert_flow_entry() - Add a flow into the FST table 165 * @hal_soc_hdl: HAL SOC handle 166 * @hal_fst: HAL Rx FST Handle 167 * @flow_hash: Flow hash computed from flow tuple 168 * @flow_tuple_info: Flow tuple used to compute the hash 169 * @flow_index: Hash index of the flow in the table when inserted successfully 170 * 171 * Return: Success if flow is inserted into the table, error otherwise 172 */ 173 QDF_STATUS 174 hal_rx_insert_flow_entry(hal_soc_handle_t hal_soc_hdl, 175 struct hal_rx_fst *fst, uint32_t flow_hash, 176 void *flow_tuple_info, uint32_t *flow_idx); 177 178 /** 179 * hal_rx_find_flow_from_tuple() - Find a flow in the FST table 180 * 181 * @fst: HAL Rx FST Handle 182 * @flow_hash: Flow hash computed from flow tuple 183 * @flow_tuple_info: Flow tuple used to compute the hash 184 * @flow_index: Hash index of the flow in the table when found 185 * 186 * Return: Success if matching flow is found in the table, error otherwise 187 */ 188 QDF_STATUS 189 hal_rx_find_flow_from_tuple(hal_soc_handle_t hal_soc_hdl, 190 struct hal_rx_fst *fst, uint32_t flow_hash, 191 void *flow_tuple_info, uint32_t *flow_idx); 192 193 /** 194 * hal_rx_get_hal_hash() - Retrieve hash index of a flow in the FST table 195 * 196 * @hal_fst: HAL Rx FST Handle 197 * @flow_hash: Flow hash computed from flow tuple 198 * 199 * Return: hash index truncated to the size of the hash table 200 */ 201 uint32_t hal_rx_get_hal_hash(struct hal_rx_fst *hal_fst, uint32_t flow_hash); 202 203 /** 204 * hal_flow_toeplitz_hash() - Calculate Toeplitz hash by using the cached key 205 * 206 * @hal_fst: FST Handle 207 * @flow: Flow Parameters 208 * 209 * Return: Success/Failure 210 */ 211 uint32_t 212 hal_flow_toeplitz_hash(void *hal_fst, struct hal_rx_flow *flow); 213 214 void hal_rx_dump_fse_table(struct hal_rx_fst *fst); 215 216 /** 217 * hal_rx_dump_cmem_fse() - Dump flow search table entry which is in CMEM 218 * @hal_soc_hdl: HAL SOC handle 219 * @fse_offset: Offset in to the CMEM where FSE is located 220 * @index: FSE index 221 * 222 * Return: None 223 */ 224 void hal_rx_dump_cmem_fse(hal_soc_handle_t hal_soc_hdl, uint32_t fse_offset, 225 int index); 226 #endif /* HAL_RX_FLOW_H */ 227