dp_mlo.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (c) 2021 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. #include <wlan_utility.h>
  17. #include <dp_internal.h>
  18. #include <dp_htt.h>
  19. #include <hal_be_api.h>
  20. #include "dp_mlo.h"
  21. /*
  22. * dp_mlo_ctxt_attach_wifi3 () – Attach DP MLO context
  23. *
  24. * Return: DP MLO context handle on success, NULL on failure
  25. */
  26. struct cdp_mlo_ctxt *
  27. dp_mlo_ctxt_attach_wifi3(struct cdp_ctrl_mlo_mgr *ctrl_ctxt)
  28. {
  29. struct dp_mlo_ctxt *mlo_ctxt =
  30. qdf_mem_malloc(sizeof(struct dp_mlo_ctxt));
  31. if (!mlo_ctxt) {
  32. dp_err("Failed to allocate DP MLO Context");
  33. return NULL;
  34. }
  35. mlo_ctxt->ctrl_ctxt = ctrl_ctxt;
  36. return dp_mlo_ctx_to_cdp(mlo_ctxt);
  37. }
  38. qdf_export_symbol(dp_mlo_ctxt_attach_wifi3);
  39. /*
  40. * dp_mlo_ctxt_detach_wifi3 () – Detach DP MLO context
  41. *
  42. * @ml_ctxt: pointer to DP MLO context
  43. *
  44. * Return: void
  45. */
  46. void dp_mlo_ctxt_detach_wifi3(struct cdp_mlo_ctxt *ml_ctxt)
  47. {
  48. qdf_mem_free(ml_ctxt);
  49. }
  50. qdf_export_symbol(dp_mlo_ctxt_detach_wifi3);
  51. /*
  52. * dp_mlo_set_soc_by_chip_id() – Add DP soc to ML context soc list
  53. *
  54. * @ml_ctxt: DP ML context handle
  55. * @soc: DP soc handle
  56. * @chip_id: MLO chip id
  57. *
  58. * Return: void
  59. */
  60. void dp_mlo_set_soc_by_chip_id(struct dp_mlo_ctxt *ml_ctxt,
  61. struct dp_soc *soc,
  62. uint8_t chip_id)
  63. {
  64. qdf_spin_lock_bh(&ml_ctxt->ml_soc_list_lock);
  65. ml_ctxt->ml_soc_list[chip_id] = soc;
  66. qdf_spin_unlock_bh(&ml_ctxt->ml_soc_list_lock);
  67. }
  68. /*
  69. * dp_mlo_get_soc_ref_by_chip_id() – Get DP soc from DP ML context.
  70. * This API will increment a reference count for DP soc. Caller has
  71. * to take care for decrementing refcount.
  72. *
  73. * @ml_ctxt: DP ML context handle
  74. * @chip_id: MLO chip id
  75. *
  76. * Return: dp_soc
  77. */
  78. struct dp_soc*
  79. dp_mlo_get_soc_ref_by_chip_id(struct dp_mlo_ctxt *ml_ctxt,
  80. uint8_t chip_id)
  81. {
  82. struct dp_soc *soc = NULL;
  83. qdf_spin_lock_bh(&ml_ctxt->ml_soc_list_lock);
  84. qdf_atomic_inc(&soc->ref_count);
  85. soc = ml_ctxt->ml_soc_list[chip_id];
  86. qdf_spin_unlock_bh(&ml_ctxt->ml_soc_list_lock);
  87. return soc;
  88. }