1 /* 2 * Copyright (c) 2019-2021 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 #ifndef __HAL_RX_FLOW_H 19 #define __HAL_RX_FLOW_H 20 21 #include "hal_flow.h" 22 #include "wlan_cfg.h" 23 #include "hal_api.h" 24 #include "qdf_mem.h" 25 #include "rx_flow_search_entry.h" 26 #include "hal_rx_flow_info.h" 27 28 #define HAL_FST_HASH_KEY_SIZE_BITS 315 29 #define HAL_FST_HASH_KEY_SIZE_WORDS 10 30 #define HAL_FST_HASH_DATA_SIZE 37 31 #define HAL_FST_HASH_MASK 0x7ffff 32 #define HAL_RX_FST_ENTRY_SIZE (NUM_OF_DWORDS_RX_FLOW_SEARCH_ENTRY * 4) 33 34 /** 35 * Four possible options for IP SA/DA prefix, currently use 0x0 which 36 * maps to type 2 in HW spec 37 */ 38 #define HAL_FST_IP_DA_SA_PFX_TYPE_IPV4_COMPATIBLE_IPV6 2 39 40 #define HAL_IP_DA_SA_PREFIX_IPV4_COMPATIBLE_IPV6 0x0 41 42 /** 43 * REO destination indication is a lower 4-bits of hash value 44 * This should match the REO destination used in Rx hash based routing. 45 */ 46 #define HAL_REO_DEST_IND_HASH_MASK 0xF 47 48 /** 49 * REO destinations are valid from 16-31 for Hawkeye 50 * and 0-15 are not setup for SW 51 */ 52 #define HAL_REO_DEST_IND_START_OFFSET 0x10 53 54 /** 55 * enum hal_rx_fse_reo_destination_handler 56 * @HAL_RX_FSE_REO_DEST_FT: Use this entry's destination indication 57 * @HAL_RX_FSE_REO_DEST_ASPT: Use Address Search + Peer Table's entry 58 * @HAL_RX_FSE_REO_DEST_FT2: Use FT2's destination indication 59 * @HAL_RX_FSE_REO_DEST_CCE: Use CCE's destination indication for this entry 60 */ 61 enum hal_rx_fse_reo_destination_handler { 62 HAL_RX_FSE_REO_DEST_FT = 0, 63 HAL_RX_FSE_REO_DEST_ASPT = 1, 64 HAL_RX_FSE_REO_DEST_FT2 = 2, 65 HAL_RX_FSE_REO_DEST_CCE = 3, 66 }; 67 68 /** 69 * hal_rx_flow_setup_fse() - Setup a flow search entry in HW FST 70 * @fst: Pointer to the Rx Flow Search Table 71 * @table_offset: offset into the table where the flow is to be setup 72 * @flow: Flow Parameters 73 * 74 * Return: Success/Failure 75 */ 76 void * 77 hal_rx_flow_setup_fse(hal_soc_handle_t hal_soc_hdl, 78 struct hal_rx_fst *fst, uint32_t table_offset, 79 struct hal_rx_flow *flow); 80 81 /** 82 * hal_rx_flow_setup_cmem_fse() - Setup a flow search entry in HW CMEM FST 83 * @hal_soc_hdl: HAL SOC handle 84 * @cmem_ba: CMEM base address 85 * @table_offset: offset into the table where the flow is to be setup 86 * @flow: Flow Parameters 87 * 88 * Return: Success/Failure 89 */ 90 uint32_t 91 hal_rx_flow_setup_cmem_fse(hal_soc_handle_t hal_soc_hdl, uint32_t cmem_ba, 92 uint32_t table_offset, struct hal_rx_flow *flow); 93 94 /** 95 * hal_rx_flow_get_cmem_fse_timestamp() - Get timestamp field from CMEM FSE 96 * @hal_soc_hdl: HAL SOC handle 97 * @fse_offset: CMEM FSE offset 98 * 99 * Return: Timestamp 100 */ 101 uint32_t hal_rx_flow_get_cmem_fse_timestamp(hal_soc_handle_t hal_soc_hdl, 102 uint32_t fse_offset); 103 104 /** 105 * hal_rx_flow_delete_entry() - Delete a flow from the Rx Flow Search Table 106 * @fst: Pointer to the Rx Flow Search Table 107 * @hal_rx_fse: Pointer to the Rx Flow that is to be deleted from the FST 108 * 109 * Return: Success/Failure 110 */ 111 QDF_STATUS 112 hal_rx_flow_delete_entry(struct hal_rx_fst *fst, void *hal_rx_fse); 113 114 /** 115 * hal_rx_flow_get_tuple_info() - Retrieve the 5-tuple flow info for an entry 116 * @hal_fse: Pointer to the Flow in Rx FST 117 * @tuple_info: 5-tuple info of the flow returned to the caller 118 * 119 * Return: Success/Failure 120 */ 121 QDF_STATUS hal_rx_flow_get_tuple_info(void *hal_fse, 122 struct hal_flow_tuple_info *tuple_info); 123 124 125 /** 126 * hal_rx_fst_attach() - Initialize Rx flow search table in HW FST 127 * 128 * @qdf_dev: QDF device handle 129 * @hal_fst_base_paddr: Pointer to the physical base address of the Rx FST 130 * @max_entries: Max number of flows allowed in the FST 131 * @max_search: Number of collisions allowed in the hash-based FST 132 * @hash_key: Toeplitz key used for the hash FST 133 * 134 * Return: 135 */ 136 struct hal_rx_fst * 137 hal_rx_fst_attach(qdf_device_t qdf_dev, 138 uint64_t *hal_fst_base_paddr, uint16_t max_entries, 139 uint16_t max_search, uint8_t *hash_key); 140 141 /** 142 * hal_rx_fst_detach() - De-init the Rx flow search table from HW 143 * 144 * @rx_fst: Pointer to the Rx FST 145 * @qdf_dev: QDF device handle 146 * 147 * Return: 148 */ 149 void hal_rx_fst_detach(struct hal_rx_fst *rx_fst, qdf_device_t qdf_dev); 150 151 /** 152 * hal_rx_insert_flow_entry() - Add a flow into the FST table 153 * 154 * @hal_fst: HAL Rx FST Handle 155 * @flow_hash: Flow hash computed from flow tuple 156 * @flow_tuple_info: Flow tuple used to compute the hash 157 * @flow_index: Hash index of the flow in the table when inserted successfully 158 * 159 * Return: Success if flow is inserted into the table, error otherwise 160 */ 161 QDF_STATUS 162 hal_rx_insert_flow_entry(struct hal_rx_fst *fst, uint32_t flow_hash, 163 void *flow_tuple_info, uint32_t *flow_idx); 164 165 /** 166 * hal_rx_find_flow_from_tuple() - Find a flow in the FST table 167 * 168 * @fst: HAL Rx FST Handle 169 * @flow_hash: Flow hash computed from flow tuple 170 * @flow_tuple_info: Flow tuple used to compute the hash 171 * @flow_index: Hash index of the flow in the table when found 172 * 173 * Return: Success if matching flow is found in the table, error otherwise 174 */ 175 QDF_STATUS 176 hal_rx_find_flow_from_tuple(struct hal_rx_fst *fst, uint32_t flow_hash, 177 void *flow_tuple_info, uint32_t *flow_idx); 178 179 /** 180 * hal_rx_get_hal_hash() - Retrieve hash index of a flow in the FST table 181 * 182 * @hal_fst: HAL Rx FST Handle 183 * @flow_hash: Flow hash computed from flow tuple 184 * 185 * Return: hash index truncated to the size of the hash table 186 */ 187 uint32_t hal_rx_get_hal_hash(struct hal_rx_fst *hal_fst, uint32_t flow_hash); 188 189 /** 190 * hal_flow_toeplitz_hash() - Calculate Toeplitz hash by using the cached key 191 * 192 * @hal_fst: FST Handle 193 * @flow: Flow Parameters 194 * 195 * Return: Success/Failure 196 */ 197 uint32_t 198 hal_flow_toeplitz_hash(void *hal_fst, struct hal_rx_flow *flow); 199 200 void hal_rx_dump_fse_table(struct hal_rx_fst *fst); 201 202 /** 203 * hal_rx_dump_cmem_fse() - Dump flow search table entry which is in CMEM 204 * @hal_soc_hdl: HAL SOC handle 205 * @fse_offset: Offset in to the CMEM where FSE is located 206 * @index: FSE index 207 * 208 * Return: None 209 */ 210 void hal_rx_dump_cmem_fse(hal_soc_handle_t hal_soc_hdl, uint32_t fse_offset, 211 int index); 212 #endif /* HAL_RX_FLOW_H */ 213