dp_peer.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Copyright (c) 2016-2017 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. void dp_rx_peer_map_handler(void *soc_handle, uint16_t peer_id,
  43. uint16_t hw_peer_id, uint8_t vdev_id, uint8_t *peer_mac_addr);
  44. void dp_rx_peer_unmap_handler(void *soc_handle, uint16_t peer_id);
  45. void dp_rx_sec_ind_handler(void *soc_handle, uint16_t peer_id,
  46. enum htt_sec_type sec_type, int is_unicast,
  47. u_int32_t *michael_key, u_int32_t *rx_pn);
  48. uint8_t dp_get_peer_mac_addr_frm_id(struct cdp_soc_t *soc_handle,
  49. uint16_t peer_id, uint8_t *peer_mac);
  50. #ifdef FEATURE_WDS
  51. int dp_peer_add_ast(struct dp_soc *soc, struct dp_peer *peer,
  52. uint8_t *mac_addr, uint8_t is_self);
  53. void dp_peer_del_ast(struct dp_soc *soc,
  54. struct dp_ast_entry *ast_entry);
  55. struct dp_ast_entry *dp_peer_ast_hash_find(struct dp_soc *soc,
  56. uint8_t *ast_mac_addr, int mac_addr_is_aligned);
  57. #else
  58. static inline int dp_peer_add_ast(struct dp_soc *soc, struct dp_peer *peer,
  59. uint8_t *mac_addr, uint8_t is_self)
  60. {
  61. return 0;
  62. }
  63. static inline void dp_peer_del_ast(struct dp_soc *soc,
  64. struct dp_ast_entry *ast_entry)
  65. {
  66. }
  67. static inline struct dp_ast_entry *dp_peer_ast_hash_find(struct dp_soc *soc,
  68. uint8_t *ast_mac_addr, int mac_addr_is_aligned)
  69. {
  70. return NULL;
  71. }
  72. #endif
  73. /*
  74. * dp_get_vdev_from_soc_vdev_id_wifi3() -
  75. * Returns vdev object given the vdev id
  76. * vdev id is unique across pdev's
  77. *
  78. * @soc : core DP soc context
  79. * @vdev_id : vdev id from vdev object can be retrieved
  80. *
  81. * Return: struct dp_vdev*: Pointer to DP vdev object
  82. */
  83. static inline struct dp_vdev *
  84. dp_get_vdev_from_soc_vdev_id_wifi3(struct dp_soc *soc,
  85. uint8_t vdev_id)
  86. {
  87. struct dp_pdev *pdev = NULL;
  88. struct dp_vdev *vdev = NULL;
  89. int i;
  90. for (i = 0; i < MAX_PDEV_CNT && soc->pdev_list[i]; i++) {
  91. pdev = soc->pdev_list[i];
  92. TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) {
  93. if (vdev->vdev_id == vdev_id) {
  94. QDF_TRACE(QDF_MODULE_ID_DP,
  95. QDF_TRACE_LEVEL_INFO,
  96. FL("Found vdev 0x%p on pdev %d\n"),
  97. vdev, i);
  98. return vdev;
  99. }
  100. }
  101. }
  102. return NULL;
  103. }
  104. #endif /* _DP_PEER_H_ */