1 /* 2 * Copyright (c) 2019-2020 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_delete_entry() - Delete a flow from the Rx Flow Search Table 83 * @fst: Pointer to the Rx Flow Search Table 84 * @hal_rx_fse: Pointer to the Rx Flow that is to be deleted from the FST 85 * 86 * Return: Success/Failure 87 */ 88 QDF_STATUS 89 hal_rx_flow_delete_entry(struct hal_rx_fst *fst, void *hal_rx_fse); 90 91 /** 92 * hal_rx_flow_get_tuple_info() - Retrieve the 5-tuple flow info for an entry 93 * @hal_fse: Pointer to the Flow in Rx FST 94 * @tuple_info: 5-tuple info of the flow returned to the caller 95 * 96 * Return: Success/Failure 97 */ 98 QDF_STATUS hal_rx_flow_get_tuple_info(void *hal_fse, 99 struct hal_flow_tuple_info *tuple_info); 100 101 /** 102 * hal_rx_fst_attach() - Initialize Rx flow search table in HW FST 103 * 104 * @qdf_dev: QDF device handle 105 * @hal_fst_base_paddr: Pointer to the physical base address of the Rx FST 106 * @max_entries: Max number of flows allowed in the FST 107 * @max_search: Number of collisions allowed in the hash-based FST 108 * @hash_key: Toeplitz key used for the hash FST 109 * 110 * Return: 111 */ 112 struct hal_rx_fst * 113 hal_rx_fst_attach(qdf_device_t qdf_dev, 114 uint64_t *hal_fst_base_paddr, uint16_t max_entries, 115 uint16_t max_search, uint8_t *hash_key); 116 117 /** 118 * hal_rx_fst_detach() - De-init the Rx flow search table from HW 119 * 120 * @rx_fst: Pointer to the Rx FST 121 * @qdf_dev: QDF device handle 122 * 123 * Return: 124 */ 125 void hal_rx_fst_detach(struct hal_rx_fst *rx_fst, qdf_device_t qdf_dev); 126 127 /** 128 * hal_rx_insert_flow_entry() - Add a flow into the FST table 129 * 130 * @hal_fst: HAL Rx FST Handle 131 * @flow_hash: Flow hash computed from flow tuple 132 * @flow_tuple_info: Flow tuple used to compute the hash 133 * @flow_index: Hash index of the flow in the table when inserted successfully 134 * 135 * Return: Success if flow is inserted into the table, error otherwise 136 */ 137 QDF_STATUS 138 hal_rx_insert_flow_entry(struct hal_rx_fst *fst, uint32_t flow_hash, 139 void *flow_tuple_info, uint32_t *flow_idx); 140 141 /** 142 * hal_rx_find_flow_from_tuple() - Find a flow in the FST table 143 * 144 * @fst: HAL Rx FST Handle 145 * @flow_hash: Flow hash computed from flow tuple 146 * @flow_tuple_info: Flow tuple used to compute the hash 147 * @flow_index: Hash index of the flow in the table when found 148 * 149 * Return: Success if matching flow is found in the table, error otherwise 150 */ 151 QDF_STATUS 152 hal_rx_find_flow_from_tuple(struct hal_rx_fst *fst, uint32_t flow_hash, 153 void *flow_tuple_info, uint32_t *flow_idx); 154 155 /** 156 * hal_rx_get_hal_hash() - Retrieve hash index of a flow in the FST table 157 * 158 * @hal_fst: HAL Rx FST Handle 159 * @flow_hash: Flow hash computed from flow tuple 160 * 161 * Return: hash index truncated to the size of the hash table 162 */ 163 uint32_t hal_rx_get_hal_hash(struct hal_rx_fst *hal_fst, uint32_t flow_hash); 164 165 /** 166 * hal_flow_toeplitz_hash() - Calculate Toeplitz hash by using the cached key 167 * 168 * @hal_fst: FST Handle 169 * @flow: Flow Parameters 170 * 171 * Return: Success/Failure 172 */ 173 uint32_t 174 hal_flow_toeplitz_hash(void *hal_fst, struct hal_rx_flow *flow); 175 176 void hal_rx_dump_fse_table(struct hal_rx_fst *fst); 177 #endif /* HAL_RX_FLOW_H */ 178