dp_mon.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
  3. * Permission to use, copy, modify, and/or distribute this software for any
  4. * purpose with or without fee is hereby granted, provided that the above
  5. * copyright notice and this permission notice appear in all copies.
  6. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  7. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  8. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  9. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  10. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  11. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  12. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  13. */
  14. struct dp_mon_ops {
  15. QDF_STATUS (*mon_soc_cfg_init)(struct dp_soc *soc);
  16. QDF_STATUS (*mon_pdev_attach)(struct dp_pdev *pdev);
  17. QDF_STATUS (*mon_pdev_detach)(struct dp_pdev *pdev);
  18. QDF_STATUS (*mon_pdev_init)(struct dp_pdev *pdev);
  19. QDF_STATUS (*mon_pdev_deinit)(struct dp_pdev *pdev);
  20. QDF_STATUS (*mon_config_debug_sniffer)(struct dp_pdev *pdev, int val);
  21. };
  22. struct dp_mon_soc {
  23. /* Holds all monitor related fields extracted from dp_soc */
  24. /* Holds pointer to monitor ops */
  25. struct dp_mon_ops *mon_ops;
  26. };
  27. struct dp_mon_pdev {
  28. };
  29. struct dp_mon_vdev {
  30. };
  31. struct dp_mon_peer {
  32. };
  33. static inline QDF_STATUS monitor_pdev_attach(struct dp_pdev *pdev)
  34. {
  35. struct dp_mon_ops *monitor_ops;
  36. struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
  37. /*
  38. * mon_soc uninitialized modular support enabled
  39. * monitor related attach/detach/init/deinit
  40. * will be done while monitor insmod
  41. */
  42. if (!mon_soc)
  43. return QDF_STATUS_SUCCESS;
  44. monitor_ops = mon_soc->mon_ops;
  45. if (!monitor_ops || !monitor_ops->mon_pdev_attach) {
  46. qdf_err("callback not registered");
  47. return QDF_STATUS_E_FAILURE;
  48. }
  49. return monitor_ops->mon_pdev_attach(pdev);
  50. }
  51. static inline QDF_STATUS monitor_pdev_detach(struct dp_pdev *pdev)
  52. {
  53. struct dp_mon_ops *monitor_ops;
  54. struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
  55. /*
  56. * mon_soc uninitialized modular support enabled
  57. * monitor related attach/detach/init/deinit
  58. * will be done while monitor insmod
  59. */
  60. if (!mon_soc)
  61. return QDF_STATUS_SUCCESS;
  62. monitor_ops = mon_soc->mon_ops;
  63. if (!monitor_ops || !monitor_ops->mon_pdev_detach) {
  64. qdf_err("callback not registered");
  65. return QDF_STATUS_E_FAILURE;
  66. }
  67. return monitor_ops->mon_pdev_detach(pdev);
  68. }
  69. static inline QDF_STATUS monitor_pdev_init(struct dp_pdev *pdev)
  70. {
  71. struct dp_mon_ops *monitor_ops;
  72. struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
  73. /*
  74. * mon_soc uninitialized modular support enabled
  75. * monitor related attach/detach/init/deinit
  76. * will be done while monitor insmod
  77. */
  78. if (!mon_soc)
  79. return QDF_STATUS_SUCCESS;
  80. monitor_ops = mon_soc->mon_ops;
  81. if (!monitor_ops || !monitor_ops->mon_pdev_init) {
  82. qdf_err("callback not registered");
  83. return QDF_STATUS_E_FAILURE;
  84. }
  85. return monitor_ops->mon_pdev_init(pdev);
  86. }
  87. static inline QDF_STATUS monitor_pdev_deinit(struct dp_pdev *pdev)
  88. {
  89. struct dp_mon_ops *monitor_ops;
  90. struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
  91. /*
  92. * mon_soc uninitialized modular support enabled
  93. * monitor related attach/detach/init/deinit
  94. * will be done while monitor insmod
  95. */
  96. if (!mon_soc)
  97. return QDF_STATUS_SUCCESS;
  98. monitor_ops = mon_soc->mon_ops;
  99. if (!monitor_ops || !monitor_ops->mon_pdev_deinit) {
  100. qdf_err("callback not registered");
  101. return QDF_STATUS_E_FAILURE;
  102. }
  103. return monitor_ops->mon_pdev_deinit(pdev);
  104. }
  105. static inline QDF_STATUS monitor_soc_cfg_init(struct dp_soc *soc)
  106. {
  107. struct dp_mon_ops *monitor_ops;
  108. struct dp_mon_soc *mon_soc = soc->monitor_soc;
  109. /*
  110. * this API is getting call from dp_soc_init,
  111. * mon_soc will be uninitialized for WIN here
  112. * So returning QDF_STATUS_SUCCESS.
  113. * For WIN, soc cfg init is done while monitor insmod.
  114. */
  115. if (!mon_soc)
  116. return QDF_STATUS_SUCCESS;
  117. monitor_ops = mon_soc->mon_ops;
  118. if (!monitor_ops || !monitor_ops->mon_soc_cfg_init) {
  119. qdf_err("callback not registered");
  120. return QDF_STATUS_E_FAILURE;
  121. }
  122. return monitor_ops->mon_soc_cfg_init(soc);
  123. }
  124. static inline QDF_STATUS monitor_config_debug_sniffer(struct dp_pdev *pdev,
  125. int val)
  126. {
  127. struct dp_mon_ops *monitor_ops;
  128. struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
  129. if (!mon_soc)
  130. return QDF_STATUS_E_FAILURE;
  131. monitor_ops = mon_soc->mon_ops;
  132. if (!monitor_ops || !monitor_ops->mon_config_debug_sniffer) {
  133. qdf_err("callback not registered");
  134. return QDF_STATUS_E_FAILURE;
  135. }
  136. return monitor_ops->mon_config_debug_sniffer(pdev, val);
  137. }