hal_rx_flow.h 7.3 KB

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