hal_rx_flow.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. #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. #define HAL_FST_HASH_KEY_SIZE_BITS 315
  26. #define HAL_FST_HASH_KEY_SIZE_BYTES 40
  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. * struct hal_rx_flow - Rx Flow parameters to be sent to HW
  49. * @tuple_info: Rx Flow 5-tuple (src & dest IP, src & dest ports, L4 protocol)
  50. * @reo_destination_handler: REO destination for this flow
  51. * @reo_destination_indication: REO indication for this flow
  52. * @fse_metadata: Flow metadata or tag passed to HW for marking packets
  53. */
  54. struct hal_rx_flow {
  55. struct hal_flow_tuple_info tuple_info;
  56. uint8_t reo_destination_handler;
  57. uint8_t reo_destination_indication;
  58. uint32_t fse_metadata;
  59. };
  60. /**
  61. * enum hal_rx_fse_reo_destination_handler
  62. * @HAL_RX_FSE_REO_DEST_FT: Use this entry's destination indication
  63. * @HAL_RX_FSE_REO_DEST_ASPT: Use Address Search + Peer Table's entry
  64. * @HAL_RX_FSE_REO_DEST_FT2: Use FT2's destination indication
  65. * @HAL_RX_FSE_REO_DEST_CCE: Use CCE's destination indication for this entry
  66. */
  67. enum hal_rx_fse_reo_destination_handler {
  68. HAL_RX_FSE_REO_DEST_FT = 0,
  69. HAL_RX_FSE_REO_DEST_ASPT = 1,
  70. HAL_RX_FSE_REO_DEST_FT2 = 2,
  71. HAL_RX_FSE_REO_DEST_CCE = 3,
  72. };
  73. /**
  74. * struct hal_rx_fst - HAL RX Flow search table context
  75. * @base_vaddr: Virtual Base address of HW FST
  76. * @base_paddr: Physical Base address of HW FST
  77. * @key: Pointer to 320-bit Key read from cfg
  78. * @shifted_key: Pointer to left-shifted 320-bit Key used for Toeplitz Hash
  79. * @max_entries : Max number of entries in flow searchh table
  80. * @max_skid_length : Max search length if there is hash collision
  81. * @hash_mask: Hash mask to apply to index into FST
  82. * @key_cache: Toepliz Key Cache configured key
  83. */
  84. struct hal_rx_fst {
  85. uint8_t *base_vaddr;
  86. qdf_dma_addr_t base_paddr;
  87. uint8_t *key;
  88. uint8_t shifted_key[HAL_FST_HASH_KEY_SIZE_BYTES];
  89. uint16_t max_entries;
  90. uint16_t max_skid_length;
  91. uint16_t hash_mask;
  92. uint32_t key_cache[HAL_FST_HASH_KEY_SIZE_BYTES][1 << 8];
  93. uint32_t add_flow_count;
  94. uint32_t del_flow_count;
  95. };
  96. /**
  97. * hal_rx_flow_setup_fse() - Setup a flow search entry in HW FST
  98. * @fst: Pointer to the Rx Flow Search Table
  99. * @table_offset: offset into the table where the flow is to be setup
  100. * @flow: Flow Parameters
  101. *
  102. * Return: Success/Failure
  103. */
  104. void *hal_rx_flow_setup_fse(struct hal_rx_fst *fst,
  105. uint32_t table_offset,
  106. struct hal_rx_flow *flow);
  107. /**
  108. * hal_rx_flow_delete_entry() - Delete a flow from the Rx Flow Search Table
  109. * @fst: Pointer to the Rx Flow Search Table
  110. * @hal_rx_fse: Pointer to the Rx Flow that is to be deleted from the FST
  111. *
  112. * Return: Success/Failure
  113. */
  114. QDF_STATUS
  115. hal_rx_flow_delete_entry(struct hal_rx_fst *fst, void *hal_rx_fse);
  116. /**
  117. * hal_rx_flow_get_tuple_info() - Retrieve the 5-tuple flow info for an entry
  118. * @hal_fse: Pointer to the Flow in Rx FST
  119. * @tuple_info: 5-tuple info of the flow returned to the caller
  120. *
  121. * Return: Success/Failure
  122. */
  123. QDF_STATUS hal_rx_flow_get_tuple_info(void *hal_fse,
  124. struct hal_flow_tuple_info *tuple_info);
  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. * 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. * hal_rx_insert_flow_entry() - Add a flow into the FST table
  151. *
  152. * @hal_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_index: 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(struct hal_rx_fst *fst, uint32_t flow_hash,
  161. void *flow_tuple_info, uint32_t *flow_idx);
  162. /**
  163. * hal_rx_find_flow_from_tuple() - Find a flow in the FST table
  164. *
  165. * @fst: HAL Rx FST Handle
  166. * @flow_hash: Flow hash computed from flow tuple
  167. * @flow_tuple_info: Flow tuple used to compute the hash
  168. * @flow_index: Hash index of the flow in the table when found
  169. *
  170. * Return: Success if matching flow is found in the table, error otherwise
  171. */
  172. QDF_STATUS
  173. hal_rx_find_flow_from_tuple(struct hal_rx_fst *fst, uint32_t flow_hash,
  174. void *flow_tuple_info, uint32_t *flow_idx);
  175. /**
  176. * hal_rx_get_hal_hash() - Retrieve hash index of a flow in the FST table
  177. *
  178. * @hal_fst: HAL Rx FST Handle
  179. * @flow_hash: Flow hash computed from flow tuple
  180. *
  181. * Return: hash index truncated to the size of the hash table
  182. */
  183. uint32_t hal_rx_get_hal_hash(struct hal_rx_fst *hal_fst, uint32_t flow_hash);
  184. /**
  185. * hal_flow_toeplitz_hash() - Calculate Toeplitz hash by using the cached key
  186. *
  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. void hal_rx_dump_fse_table(struct hal_rx_fst *fst);
  195. #endif /* HAL_RX_FLOW_H */