dp_peer.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. * Copyright (c) 2016-2019 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 _DP_PEER_H_
  19. #define _DP_PEER_H_
  20. #include <qdf_types.h>
  21. #include <qdf_lock.h>
  22. #include "dp_types.h"
  23. #define DP_INVALID_PEER_ID 0xffff
  24. #define DP_FW_PEER_STATS_CMP_TIMEOUT_MSEC 5000
  25. /**
  26. * __dp_peer_find_by_id() - Returns peer object given the peer id
  27. *
  28. * @soc : core DP soc context
  29. * @peer_id : peer id from peer object can be retrieved
  30. *
  31. * Return: struct dp_peer*: Pointer to DP peer object
  32. */
  33. static inline struct dp_peer *
  34. __dp_peer_find_by_id(struct dp_soc *soc,
  35. uint16_t peer_id)
  36. {
  37. struct dp_peer *peer;
  38. /* TODO: Hold lock */
  39. peer = (peer_id >= soc->max_peers) ? NULL :
  40. soc->peer_id_to_obj_map[peer_id];
  41. return peer;
  42. }
  43. #ifdef PEER_PROTECTED_ACCESS
  44. /**
  45. * dp_peer_find_by_id() - Returns peer object given the peer id
  46. * if delete_in_progress in not set for peer
  47. *
  48. * @soc : core DP soc context
  49. * @peer_id : peer id from peer object can be retrieved
  50. *
  51. * Return: struct dp_peer*: Pointer to DP peer object
  52. */
  53. static inline
  54. struct dp_peer *dp_peer_find_by_id(struct dp_soc *soc,
  55. uint16_t peer_id)
  56. {
  57. struct dp_peer *peer;
  58. qdf_spin_lock_bh(&soc->peer_ref_mutex);
  59. peer = __dp_peer_find_by_id(soc, peer_id);
  60. if (!peer || (peer && peer->delete_in_progress)) {
  61. qdf_spin_unlock_bh(&soc->peer_ref_mutex);
  62. return NULL;
  63. }
  64. qdf_atomic_inc(&peer->ref_cnt);
  65. qdf_spin_unlock_bh(&soc->peer_ref_mutex);
  66. return peer;
  67. }
  68. #else
  69. static inline struct dp_peer *
  70. dp_peer_find_by_id(struct dp_soc *soc,
  71. uint16_t peer_id)
  72. {
  73. struct dp_peer *peer;
  74. peer = __dp_peer_find_by_id (soc, peer_id);
  75. if (peer && peer->delete_in_progress) {
  76. return NULL;
  77. }
  78. return peer;
  79. }
  80. #endif /* PEER_LOCK_REF_PROTECT */
  81. void dp_print_ast_stats(struct dp_soc *soc);
  82. void dp_rx_peer_map_handler(void *soc_handle, uint16_t peer_id,
  83. uint16_t hw_peer_id, uint8_t vdev_id,
  84. uint8_t *peer_mac_addr, uint16_t ast_hash,
  85. uint8_t is_wds);
  86. void dp_rx_peer_unmap_handler(void *soc_handle, uint16_t peer_id,
  87. uint8_t vdev_id, uint8_t *peer_mac_addr,
  88. uint8_t is_wds);
  89. void dp_rx_sec_ind_handler(void *soc_handle, uint16_t peer_id,
  90. enum cdp_sec_type sec_type, int is_unicast,
  91. u_int32_t *michael_key, u_int32_t *rx_pn);
  92. uint8_t dp_get_peer_mac_addr_frm_id(struct cdp_soc_t *soc_handle,
  93. uint16_t peer_id, uint8_t *peer_mac);
  94. int dp_peer_add_ast(struct dp_soc *soc, struct dp_peer *peer,
  95. uint8_t *mac_addr, enum cdp_txrx_ast_entry_type type,
  96. uint32_t flags);
  97. void dp_peer_del_ast(struct dp_soc *soc, struct dp_ast_entry *ast_entry);
  98. void dp_peer_ast_unmap_handler(struct dp_soc *soc,
  99. struct dp_ast_entry *ast_entry);
  100. int dp_peer_update_ast(struct dp_soc *soc, struct dp_peer *peer,
  101. struct dp_ast_entry *ast_entry, uint32_t flags);
  102. struct dp_ast_entry *dp_peer_ast_hash_find_by_pdevid(struct dp_soc *soc,
  103. uint8_t *ast_mac_addr,
  104. uint8_t pdev_id);
  105. struct dp_ast_entry *dp_peer_ast_hash_find_soc(struct dp_soc *soc,
  106. uint8_t *ast_mac_addr);
  107. struct dp_ast_entry *dp_peer_ast_list_find(struct dp_soc *soc,
  108. struct dp_peer *peer,
  109. uint8_t *ast_mac_addr);
  110. uint8_t dp_peer_ast_get_pdev_id(struct dp_soc *soc,
  111. struct dp_ast_entry *ast_entry);
  112. uint8_t dp_peer_ast_get_next_hop(struct dp_soc *soc,
  113. struct dp_ast_entry *ast_entry);
  114. void dp_peer_ast_set_type(struct dp_soc *soc,
  115. struct dp_ast_entry *ast_entry,
  116. enum cdp_txrx_ast_entry_type type);
  117. void dp_peer_ast_send_wds_del(struct dp_soc *soc,
  118. struct dp_ast_entry *ast_entry);
  119. void dp_peer_free_hmwds_cb(struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
  120. void *dp_soc,
  121. void *cookie,
  122. enum cdp_ast_free_status status);
  123. void dp_peer_ast_hash_remove(struct dp_soc *soc,
  124. struct dp_ast_entry *ase);
  125. /*
  126. * dp_get_vdev_from_soc_vdev_id_wifi3() -
  127. * Returns vdev object given the vdev id
  128. * vdev id is unique across pdev's
  129. *
  130. * @soc : core DP soc context
  131. * @vdev_id : vdev id from vdev object can be retrieved
  132. *
  133. * Return: struct dp_vdev*: Pointer to DP vdev object
  134. */
  135. static inline struct dp_vdev *
  136. dp_get_vdev_from_soc_vdev_id_wifi3(struct dp_soc *soc,
  137. uint8_t vdev_id)
  138. {
  139. struct dp_pdev *pdev = NULL;
  140. struct dp_vdev *vdev = NULL;
  141. int i;
  142. for (i = 0; i < MAX_PDEV_CNT && soc->pdev_list[i]; i++) {
  143. pdev = soc->pdev_list[i];
  144. qdf_spin_lock_bh(&pdev->vdev_list_lock);
  145. TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) {
  146. if (vdev->vdev_id == vdev_id) {
  147. QDF_TRACE(QDF_MODULE_ID_DP,
  148. QDF_TRACE_LEVEL_INFO,
  149. FL("Found vdev 0x%pK on pdev %d"),
  150. vdev, i);
  151. qdf_spin_unlock_bh(&pdev->vdev_list_lock);
  152. return vdev;
  153. }
  154. }
  155. qdf_spin_unlock_bh(&pdev->vdev_list_lock);
  156. }
  157. return NULL;
  158. }
  159. /*
  160. * dp_peer_find_by_id_exist - check if peer exists for given id
  161. * @soc: core DP soc context
  162. * @peer_id: peer id from peer object can be retrieved
  163. *
  164. * Return: true if peer exists of false otherwise
  165. */
  166. bool dp_peer_find_by_id_valid(struct dp_soc *soc, uint16_t peer_id);
  167. #define DP_AST_ASSERT(_condition) \
  168. do { \
  169. if (!(_condition)) { \
  170. dp_print_ast_stats(soc);\
  171. QDF_BUG(_condition); \
  172. } \
  173. } while (0)
  174. /**
  175. * dp_peer_update_inactive_time - Update inactive time for peer
  176. * @pdev: pdev object
  177. * @tag_type: htt_tlv_tag type
  178. * #tag_buf: buf message
  179. */
  180. void
  181. dp_peer_update_inactive_time(struct dp_pdev *pdev, uint32_t tag_type,
  182. uint32_t *tag_buf);
  183. #endif /* _DP_PEER_H_ */