dp_mlo.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. #include <dp_be.h>
  22. /*
  23. * dp_mlo_ctxt_attach_wifi3 () – Attach DP MLO context
  24. *
  25. * Return: DP MLO context handle on success, NULL on failure
  26. */
  27. struct cdp_mlo_ctxt *
  28. dp_mlo_ctxt_attach_wifi3(struct cdp_ctrl_mlo_mgr *ctrl_ctxt)
  29. {
  30. struct dp_mlo_ctxt *mlo_ctxt =
  31. qdf_mem_malloc(sizeof(struct dp_mlo_ctxt));
  32. if (!mlo_ctxt) {
  33. dp_err("Failed to allocate DP MLO Context");
  34. return NULL;
  35. }
  36. mlo_ctxt->ctrl_ctxt = ctrl_ctxt;
  37. return dp_mlo_ctx_to_cdp(mlo_ctxt);
  38. }
  39. qdf_export_symbol(dp_mlo_ctxt_attach_wifi3);
  40. /*
  41. * dp_mlo_ctxt_detach_wifi3 () – Detach DP MLO context
  42. *
  43. * @ml_ctxt: pointer to DP MLO context
  44. *
  45. * Return: void
  46. */
  47. void dp_mlo_ctxt_detach_wifi3(struct cdp_mlo_ctxt *ml_ctxt)
  48. {
  49. qdf_mem_free(ml_ctxt);
  50. }
  51. qdf_export_symbol(dp_mlo_ctxt_detach_wifi3);
  52. /*
  53. * dp_mlo_set_soc_by_chip_id() – Add DP soc to ML context soc list
  54. *
  55. * @ml_ctxt: DP ML context handle
  56. * @soc: DP soc handle
  57. * @chip_id: MLO chip id
  58. *
  59. * Return: void
  60. */
  61. void dp_mlo_set_soc_by_chip_id(struct dp_mlo_ctxt *ml_ctxt,
  62. struct dp_soc *soc,
  63. uint8_t chip_id)
  64. {
  65. qdf_spin_lock_bh(&ml_ctxt->ml_soc_list_lock);
  66. ml_ctxt->ml_soc_list[chip_id] = soc;
  67. qdf_spin_unlock_bh(&ml_ctxt->ml_soc_list_lock);
  68. }
  69. /*
  70. * dp_mlo_get_soc_ref_by_chip_id() – Get DP soc from DP ML context.
  71. * This API will increment a reference count for DP soc. Caller has
  72. * to take care for decrementing refcount.
  73. *
  74. * @ml_ctxt: DP ML context handle
  75. * @chip_id: MLO chip id
  76. *
  77. * Return: dp_soc
  78. */
  79. struct dp_soc*
  80. dp_mlo_get_soc_ref_by_chip_id(struct dp_mlo_ctxt *ml_ctxt,
  81. uint8_t chip_id)
  82. {
  83. struct dp_soc *soc = NULL;
  84. qdf_spin_lock_bh(&ml_ctxt->ml_soc_list_lock);
  85. qdf_atomic_inc(&soc->ref_count);
  86. soc = ml_ctxt->ml_soc_list[chip_id];
  87. qdf_spin_unlock_bh(&ml_ctxt->ml_soc_list_lock);
  88. return soc;
  89. }
  90. void dp_soc_mlo_fill_params(struct dp_soc *soc,
  91. struct cdp_soc_attach_params *params)
  92. {
  93. struct dp_soc_be *be_soc = dp_get_be_soc_from_dp_soc(soc);
  94. if (!params->mlo_enabled) {
  95. dp_warn("MLO not enabled on SOC");
  96. return;
  97. }
  98. be_soc->mlo_chip_id = params->mlo_chip_id;
  99. be_soc->ml_ctxt = cdp_mlo_ctx_to_dp(params->ml_context);
  100. be_soc->mlo_enabled = 1;
  101. }
  102. void dp_pdev_mlo_fill_params(struct dp_pdev *pdev,
  103. struct cdp_pdev_attach_params *params)
  104. {
  105. struct dp_soc_be *be_soc = dp_get_be_soc_from_dp_soc(pdev->soc);
  106. struct dp_pdev_be *be_pdev = dp_get_be_pdev_from_dp_pdev(pdev);
  107. if (!be_soc->mlo_enabled) {
  108. dp_info("MLO not enabled on SOC");
  109. return;
  110. }
  111. be_pdev->mlo_link_id = params->mlo_link_id;
  112. }