hal_rx_flow.h 6.5 KB

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