xref: /wlan-dirver/qca-wifi-host-cmn/hal/wifi3.0/hal_rx_flow.h (revision 97f44cd39e4ff816eaa1710279d28cf6b9e65ad9)
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_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  * hal_rx_fst_attach() - Initialize Rx flow search table in HW FST
126  *
127  * @qdf_dev: QDF device handle
128  * @hal_fst_base_paddr: Pointer to the physical base address of the Rx FST
129  * @max_entries: Max number of flows allowed in the FST
130  * @max_search: Number of collisions allowed in the hash-based FST
131  * @hash_key: Toeplitz key used for the hash FST
132  *
133  * Return:
134  */
135 struct hal_rx_fst *
136 hal_rx_fst_attach(qdf_device_t qdf_dev,
137 		  uint64_t *hal_fst_base_paddr, uint16_t max_entries,
138 		  uint16_t max_search, uint8_t *hash_key);
139 
140 /**
141  * hal_rx_fst_detach() - De-init the Rx flow search table from HW
142  *
143  * @rx_fst: Pointer to the Rx FST
144  * @qdf_dev: QDF device handle
145  *
146  * Return:
147  */
148 void hal_rx_fst_detach(struct hal_rx_fst *rx_fst, qdf_device_t qdf_dev);
149 
150 /**
151  * hal_rx_insert_flow_entry() - Add a flow into the FST table
152  *
153  * @hal_fst: HAL Rx FST Handle
154  * @flow_hash: Flow hash computed from flow tuple
155  * @flow_tuple_info: Flow tuple used to compute the hash
156  * @flow_index: Hash index of the flow in the table when inserted successfully
157  *
158  * Return: Success if flow is inserted into the table, error otherwise
159  */
160 QDF_STATUS
161 hal_rx_insert_flow_entry(struct hal_rx_fst *fst, uint32_t flow_hash,
162 			 void *flow_tuple_info, uint32_t *flow_idx);
163 
164 /**
165  * hal_rx_find_flow_from_tuple() - Find a flow in the FST table
166  *
167  * @fst: HAL Rx FST Handle
168  * @flow_hash: Flow hash computed from flow tuple
169  * @flow_tuple_info: Flow tuple used to compute the hash
170  * @flow_index: Hash index of the flow in the table when found
171  *
172  * Return: Success if matching flow is found in the table, error otherwise
173  */
174 QDF_STATUS
175 hal_rx_find_flow_from_tuple(struct hal_rx_fst *fst, uint32_t flow_hash,
176 			    void *flow_tuple_info, uint32_t *flow_idx);
177 
178 /**
179  * hal_rx_get_hal_hash() - Retrieve hash index of a flow in the FST table
180  *
181  * @hal_fst: HAL Rx FST Handle
182  * @flow_hash: Flow hash computed from flow tuple
183  *
184  * Return: hash index truncated to the size of the hash table
185  */
186 uint32_t hal_rx_get_hal_hash(struct hal_rx_fst *hal_fst, uint32_t flow_hash);
187 
188 /**
189  * hal_flow_toeplitz_hash() - Calculate Toeplitz hash by using the cached key
190  *
191  * @hal_fst: FST Handle
192  * @flow: Flow Parameters
193  *
194  * Return: Success/Failure
195  */
196 uint32_t
197 hal_flow_toeplitz_hash(void *hal_fst, struct hal_rx_flow *flow);
198 
199 void hal_rx_dump_fse_table(struct hal_rx_fst *fst);
200 
201 /**
202  * hal_rx_dump_cmem_fse() - Dump flow search table entry which is in CMEM
203  * @hal_soc_hdl: HAL SOC handle
204  * @fse_offset: Offset in to the CMEM where FSE is located
205  * @index: FSE index
206  *
207  * Return: None
208  */
209 void hal_rx_dump_cmem_fse(hal_soc_handle_t hal_soc_hdl, uint32_t fse_offset,
210 			  int index);
211 #endif /* HAL_RX_FLOW_H */
212