dp_mlo.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /*
  2. * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef __DP_MLO_H
  17. #define __DP_MLO_H
  18. #include <dp_types.h>
  19. #include <dp_peer.h>
  20. /* Max number of chips that can participate in MLO */
  21. #define DP_MAX_MLO_CHIPS WLAN_MAX_MLO_CHIPS
  22. /* Max number of peers supported */
  23. #define DP_MAX_MLO_PEER 512
  24. /* Max number of chips supported */
  25. #define DP_MLO_MAX_DEST_CHIP_ID 4
  26. /*
  27. * NB: intentionally not using kernel-doc comment because the kernel-doc
  28. * script does not handle the TAILQ_HEAD macro
  29. * struct dp_mlo_ctxt - datapath MLO context
  30. *
  31. * @ctrl_ctxt: opaque handle of cp mlo mgr
  32. * @ml_soc_list: list of socs which are mlo enabled. This also maintains
  33. * mlo_chip_id to dp_soc mapping
  34. * @ml_soc_cnt: number of SOCs
  35. * @ml_soc_list_lock: lock to protect ml_soc_list
  36. * @mld_peer_hash: peer hash table for ML peers
  37. * Associated peer with this MAC address)
  38. * @mld_peer_hash_lock: lock to protect mld_peer_hash
  39. * @toeplitz_hash_ipv4:
  40. * @toeplitz_hash_ipv6:
  41. * @link_to_pdev_map: link to pdev mapping
  42. * @rx_fst: pointer to rx_fst handle
  43. * @rx_fst_ref_cnt: ref count of rx_fst
  44. * @grp_umac_reset_ctx: UMAC reset context at mlo group level
  45. * @mlo_dev_list: list of MLO device context
  46. * @mlo_dev_list_lock: lock to protect MLO device ctxt
  47. */
  48. struct dp_mlo_ctxt {
  49. struct cdp_ctrl_mlo_mgr *ctrl_ctxt;
  50. struct dp_soc *ml_soc_list[DP_MAX_MLO_CHIPS];
  51. uint8_t ml_soc_cnt;
  52. qdf_spinlock_t ml_soc_list_lock;
  53. struct {
  54. uint32_t mask;
  55. uint32_t idx_bits;
  56. TAILQ_HEAD(, dp_peer) * bins;
  57. } mld_peer_hash;
  58. qdf_spinlock_t mld_peer_hash_lock;
  59. uint32_t toeplitz_hash_ipv4[LRO_IPV4_SEED_ARR_SZ];
  60. uint32_t toeplitz_hash_ipv6[LRO_IPV6_SEED_ARR_SZ];
  61. struct dp_pdev_be *link_to_pdev_map[WLAN_MAX_MLO_CHIPS *
  62. WLAN_MAX_MLO_LINKS_PER_SOC];
  63. #ifdef DP_UMAC_HW_RESET_SUPPORT
  64. struct dp_soc_mlo_umac_reset_ctx grp_umac_reset_ctx;
  65. #endif
  66. /* MLO device ctxt list */
  67. TAILQ_HEAD(, dp_mlo_dev_ctxt) mlo_dev_list;
  68. qdf_spinlock_t mlo_dev_list_lock;
  69. };
  70. /**
  71. * dp_mlo_ctx_to_cdp() - typecast dp mlo context to CDP context
  72. * @mlo_ctxt: DP MLO context
  73. *
  74. * Return: struct cdp_mlo_ctxt pointer
  75. */
  76. static inline
  77. struct cdp_mlo_ctxt *dp_mlo_ctx_to_cdp(struct dp_mlo_ctxt *mlo_ctxt)
  78. {
  79. return (struct cdp_mlo_ctxt *)mlo_ctxt;
  80. }
  81. /**
  82. * cdp_mlo_ctx_to_dp() - typecast CDP MLO context to DP MLO context
  83. * @mlo_ctxt: CDP MLO context
  84. *
  85. * Return: struct dp_soc pointer
  86. */
  87. static inline
  88. struct dp_mlo_ctxt *cdp_mlo_ctx_to_dp(struct cdp_mlo_ctxt *mlo_ctxt)
  89. {
  90. return (struct dp_mlo_ctxt *)mlo_ctxt;
  91. }
  92. /**
  93. * dp_soc_mlo_fill_params() - update SOC mlo params
  94. * @soc: DP soc
  95. * @params: soc attach params
  96. *
  97. * Return: struct dp_soc pointer
  98. */
  99. void dp_soc_mlo_fill_params(struct dp_soc *soc,
  100. struct cdp_soc_attach_params *params);
  101. /**
  102. * dp_pdev_mlo_fill_params() - update PDEV mlo params
  103. * @pdev: DP PDEV
  104. * @params: PDEV attach params
  105. *
  106. * Return: struct dp_soc pointer
  107. */
  108. void dp_pdev_mlo_fill_params(struct dp_pdev *pdev,
  109. struct cdp_pdev_attach_params *params);
  110. /**
  111. * dp_mlo_get_soc_ref_by_chip_id() - Get DP soc from DP ML context.
  112. * @ml_ctxt: DP ML context handle
  113. * @chip_id: MLO chip id
  114. *
  115. * This API will increment a reference count for DP soc. Caller has
  116. * to take care for decrementing refcount.
  117. *
  118. * Return: dp_soc
  119. */
  120. struct dp_soc*
  121. dp_mlo_get_soc_ref_by_chip_id(struct dp_mlo_ctxt *ml_ctxt, uint8_t chip_id);
  122. /**
  123. * dp_mlo_get_rx_hash_key() - Get Rx hash key from MLO context
  124. * @soc: DP SOC
  125. * @lro_hash: Hash params
  126. *
  127. */
  128. void dp_mlo_get_rx_hash_key(struct dp_soc *soc,
  129. struct cdp_lro_hash_config *lro_hash);
  130. /**
  131. * dp_mlo_rx_fst_deref() - decrement rx_fst
  132. * @soc: dp soc
  133. *
  134. * return: soc cnt
  135. */
  136. uint8_t dp_mlo_rx_fst_deref(struct dp_soc *soc);
  137. /**
  138. * dp_mlo_rx_fst_ref() - increment ref of rx_fst
  139. * @soc: dp soc
  140. *
  141. */
  142. void dp_mlo_rx_fst_ref(struct dp_soc *soc);
  143. /**
  144. * dp_mlo_get_rx_fst() - Get Rx FST from MLO context
  145. * @soc: DP SOC
  146. *
  147. * Return: struct dp_rx_fst pointer
  148. */
  149. struct dp_rx_fst *dp_mlo_get_rx_fst(struct dp_soc *soc);
  150. /**
  151. * dp_mlo_set_rx_fst() - Set Rx FST in MLO context
  152. * @soc: DP SOC
  153. * @fst: pointer dp_rx_fst
  154. *
  155. */
  156. void dp_mlo_set_rx_fst(struct dp_soc *soc, struct dp_rx_fst *fst);
  157. /**
  158. * dp_mlo_update_link_to_pdev_map() - map link-id to pdev mapping
  159. * @soc: DP SOC
  160. * @pdev: DP PDEV
  161. *
  162. * Return: none
  163. */
  164. void dp_mlo_update_link_to_pdev_map(struct dp_soc *soc, struct dp_pdev *pdev);
  165. /**
  166. * dp_mlo_update_link_to_pdev_unmap() - unmap link-id to pdev mapping
  167. * @soc: DP SOC
  168. * @pdev: DP PDEV
  169. *
  170. * Return: none
  171. */
  172. void dp_mlo_update_link_to_pdev_unmap(struct dp_soc *soc, struct dp_pdev *pdev);
  173. /**
  174. * dp_mlo_get_delta_tsf2_wrt_mlo_offset() - Get delta between mlo timestamp
  175. * offset and delta tsf2
  176. * @soc: DP SOC
  177. * @hw_link_id: link id
  178. *
  179. * Return: int32_t
  180. */
  181. int32_t dp_mlo_get_delta_tsf2_wrt_mlo_offset(struct dp_soc *soc,
  182. uint8_t hw_link_id);
  183. /**
  184. * dp_mlo_get_delta_tqm_wrt_mlo_offset() - Get delta between mlo timestamp
  185. * offset and delta tqm
  186. * @soc: DP SOC
  187. *
  188. * Return: int32_t
  189. */
  190. int32_t dp_mlo_get_delta_tqm_wrt_mlo_offset(struct dp_soc *soc);
  191. /**
  192. * dp_get_interface_stats_be() - get vdev stats for ath interface
  193. * @soc_hdl: CDP SoC handle
  194. * @vdev_id: vdev Id
  195. * @buf: buffer for vdev stats
  196. * @is_aggregate: for aggregation
  197. *
  198. * Return: QDF_STATUS
  199. */
  200. QDF_STATUS
  201. dp_get_interface_stats_be(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  202. void *buf, bool is_aggregate);
  203. /*
  204. * dp_mlo_debug_print_ptnr_info() - print partner info
  205. * @vdev: DP VDEV
  206. *
  207. * Return: none
  208. */
  209. void dp_mlo_debug_print_ptnr_info(struct dp_vdev *vdev);
  210. /*
  211. * dp_mlo_get_chip_id() - return MLO chip id
  212. * @soc: DP soc
  213. *
  214. * Return: chip_id
  215. */
  216. uint8_t dp_mlo_get_chip_id(struct dp_soc *soc);
  217. /*
  218. * dp_mlo_link_peer_hash_find_by_chip_id() - returns mlo link peer on chip_id
  219. * peer_hash_table matching vdev_id and mac_address
  220. * @soc: partner soc handle in MLO
  221. * @peer_mac_addr: peer mac address
  222. * @mac_addr_is_aligned: is mac addr aligned
  223. * @vdev_id: vdev_id
  224. * @chip_id: mlo_chip_id
  225. * @mod_id: id of module requesting reference
  226. *
  227. * return: peer in success
  228. * NULL in failure
  229. */
  230. struct dp_peer *
  231. dp_mlo_link_peer_hash_find_by_chip_id(struct dp_soc *soc,
  232. uint8_t *peer_mac_addr,
  233. int mac_addr_is_aligned,
  234. uint8_t vdev_id,
  235. uint8_t chip_id,
  236. enum dp_mod_id mod_id);
  237. #endif /* __DP_MLO_H */