dp_peer.h 5.8 KB

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