dp_peer.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. /**
  43. * dp_peer_find_by_id() - Returns peer object given the peer id
  44. * if delete_in_progress in not set for peer
  45. *
  46. * @soc : core DP soc context
  47. * @peer_id : peer id from peer object can be retrieved
  48. *
  49. * Return: struct dp_peer*: Pointer to DP peer object
  50. */
  51. static inline struct dp_peer *
  52. dp_peer_find_by_id(struct dp_soc *soc,
  53. uint16_t peer_id)
  54. {
  55. struct dp_peer *peer;
  56. peer = __dp_peer_find_by_id (soc, peer_id);
  57. if (peer && peer->delete_in_progress) {
  58. return NULL;
  59. }
  60. return peer;
  61. }
  62. void dp_rx_peer_map_handler(void *soc_handle, uint16_t peer_id,
  63. uint16_t hw_peer_id, uint8_t vdev_id,
  64. uint8_t *peer_mac_addr, uint16_t ast_hash,
  65. uint8_t is_wds);
  66. void dp_rx_peer_unmap_handler(void *soc_handle, uint16_t peer_id,
  67. uint8_t vdev_id, uint8_t *peer_mac_addr,
  68. uint8_t is_wds);
  69. void dp_rx_sec_ind_handler(void *soc_handle, uint16_t peer_id,
  70. enum htt_sec_type sec_type, int is_unicast,
  71. u_int32_t *michael_key, u_int32_t *rx_pn);
  72. uint8_t dp_get_peer_mac_addr_frm_id(struct cdp_soc_t *soc_handle,
  73. uint16_t peer_id, uint8_t *peer_mac);
  74. int dp_peer_add_ast(struct dp_soc *soc, struct dp_peer *peer,
  75. uint8_t *mac_addr, enum cdp_txrx_ast_entry_type type,
  76. uint32_t flags);
  77. void dp_peer_del_ast(struct dp_soc *soc, struct dp_ast_entry *ast_entry);
  78. void dp_peer_ast_unmap_handler(struct dp_soc *soc,
  79. struct dp_ast_entry *ast_entry);
  80. int dp_peer_update_ast(struct dp_soc *soc, struct dp_peer *peer,
  81. struct dp_ast_entry *ast_entry, uint32_t flags);
  82. struct dp_ast_entry *dp_peer_ast_hash_find_by_pdevid(struct dp_soc *soc,
  83. uint8_t *ast_mac_addr,
  84. uint8_t pdev_id);
  85. struct dp_ast_entry *dp_peer_ast_hash_find(struct dp_soc *soc,
  86. uint8_t *ast_mac_addr);
  87. uint8_t dp_peer_ast_get_pdev_id(struct dp_soc *soc,
  88. struct dp_ast_entry *ast_entry);
  89. uint8_t dp_peer_ast_get_next_hop(struct dp_soc *soc,
  90. struct dp_ast_entry *ast_entry);
  91. void dp_peer_ast_set_type(struct dp_soc *soc,
  92. struct dp_ast_entry *ast_entry,
  93. enum cdp_txrx_ast_entry_type type);
  94. #if defined(FEATURE_AST) && defined(AST_HKV1_WORKAROUND)
  95. void dp_peer_ast_set_cp_ctx(struct dp_soc *soc,
  96. struct dp_ast_entry *ast_entry,
  97. void *cp_ctx);
  98. void *dp_peer_ast_get_cp_ctx(struct dp_soc *soc,
  99. struct dp_ast_entry *ast_entry);
  100. void dp_peer_ast_send_wds_del(struct dp_soc *soc,
  101. struct dp_ast_entry *ast_entry);
  102. bool dp_peer_ast_get_wmi_sent(struct dp_soc *soc,
  103. struct dp_ast_entry *ast_entry);
  104. void dp_peer_ast_free_entry(struct dp_soc *soc,
  105. struct dp_ast_entry *ast_entry);
  106. #endif
  107. /*
  108. * dp_get_vdev_from_soc_vdev_id_wifi3() -
  109. * Returns vdev object given the vdev id
  110. * vdev id is unique across pdev's
  111. *
  112. * @soc : core DP soc context
  113. * @vdev_id : vdev id from vdev object can be retrieved
  114. *
  115. * Return: struct dp_vdev*: Pointer to DP vdev object
  116. */
  117. static inline struct dp_vdev *
  118. dp_get_vdev_from_soc_vdev_id_wifi3(struct dp_soc *soc,
  119. uint8_t vdev_id)
  120. {
  121. struct dp_pdev *pdev = NULL;
  122. struct dp_vdev *vdev = NULL;
  123. int i;
  124. for (i = 0; i < MAX_PDEV_CNT && soc->pdev_list[i]; i++) {
  125. pdev = soc->pdev_list[i];
  126. TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) {
  127. if (vdev->vdev_id == vdev_id) {
  128. QDF_TRACE(QDF_MODULE_ID_DP,
  129. QDF_TRACE_LEVEL_INFO,
  130. FL("Found vdev 0x%pK on pdev %d"),
  131. vdev, i);
  132. return vdev;
  133. }
  134. }
  135. }
  136. return NULL;
  137. }
  138. #endif /* _DP_PEER_H_ */