cdp_txrx_mon.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /*
  2. * Copyright (c) 2016-2020 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. /**
  19. * @file cdp_txrx_mon.h
  20. * @brief Define the monitor mode API functions
  21. * called by the host control SW and the OS interface module
  22. */
  23. #ifndef _CDP_TXRX_MON_H_
  24. #define _CDP_TXRX_MON_H_
  25. #include "cdp_txrx_handle.h"
  26. static inline QDF_STATUS cdp_reset_monitor_mode(ol_txrx_soc_handle soc,
  27. uint8_t pdev_id,
  28. u_int8_t smart_monitor)
  29. {
  30. if (!soc || !soc->ops) {
  31. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  32. "%s: Invalid Instance", __func__);
  33. QDF_BUG(0);
  34. return 0;
  35. }
  36. if (!soc->ops->mon_ops ||
  37. !soc->ops->mon_ops->txrx_reset_monitor_mode)
  38. return 0;
  39. return soc->ops->mon_ops->txrx_reset_monitor_mode(soc, pdev_id,
  40. smart_monitor);
  41. }
  42. /**
  43. * cdp_deliver_tx_mgmt() - Deliver mgmt frame for tx capture
  44. * @soc: Datapath SOC handle
  45. * @pdev_id: id of datapath PDEV handle
  46. * @nbuf: Management frame buffer
  47. */
  48. static inline QDF_STATUS
  49. cdp_deliver_tx_mgmt(ol_txrx_soc_handle soc, uint8_t pdev_id,
  50. qdf_nbuf_t nbuf)
  51. {
  52. if (!soc || !soc->ops) {
  53. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  54. "%s: Invalid Instance", __func__);
  55. QDF_BUG(0);
  56. return QDF_STATUS_E_FAILURE;
  57. }
  58. if (!soc->ops->mon_ops ||
  59. !soc->ops->mon_ops->txrx_deliver_tx_mgmt)
  60. return QDF_STATUS_E_FAILURE;
  61. return soc->ops->mon_ops->txrx_deliver_tx_mgmt(soc, pdev_id, nbuf);
  62. }
  63. #ifdef WLAN_FEATURE_PKT_CAPTURE
  64. static inline void
  65. cdp_pktcapture_record_channel(
  66. ol_txrx_soc_handle soc,
  67. uint8_t pdev_id,
  68. int chan_num)
  69. {
  70. if (!soc || !soc->ops) {
  71. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  72. "%s invalid instance", __func__);
  73. QDF_BUG(0);
  74. return;
  75. }
  76. if (!soc->ops->pktcapture_ops ||
  77. !soc->ops->pktcapture_ops->txrx_pktcapture_record_channel)
  78. return;
  79. soc->ops->pktcapture_ops->txrx_pktcapture_record_channel(soc,
  80. pdev_id,
  81. chan_num);
  82. }
  83. static inline void
  84. cdp_set_packet_capture_mode(ol_txrx_soc_handle soc,
  85. uint8_t pdev_id,
  86. uint8_t val)
  87. {
  88. if (!soc || !soc->ops) {
  89. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  90. "%s invalid instance", __func__);
  91. QDF_BUG(0);
  92. return;
  93. }
  94. if (!soc->ops->pktcapture_ops ||
  95. !soc->ops->pktcapture_ops->txrx_pktcapture_set_mode)
  96. return;
  97. soc->ops->pktcapture_ops->txrx_pktcapture_set_mode(soc, pdev_id, val);
  98. }
  99. static inline uint8_t
  100. cdp_get_packet_capture_mode(ol_txrx_soc_handle soc, uint8_t pdev_id)
  101. {
  102. if (!soc || !soc->ops) {
  103. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  104. "%s invalid instance", __func__);
  105. QDF_BUG(0);
  106. return 0;
  107. }
  108. if (!soc->ops->pktcapture_ops ||
  109. !soc->ops->pktcapture_ops->txrx_pktcapture_get_mode)
  110. return 0;
  111. return soc->ops->pktcapture_ops->txrx_pktcapture_get_mode(soc,
  112. pdev_id);
  113. }
  114. static inline QDF_STATUS
  115. cdp_register_pktcapture_cb(
  116. ol_txrx_soc_handle soc, uint8_t pdev_id, void *ctx,
  117. QDF_STATUS(txrx_pktcapture_cb)(void *, qdf_nbuf_t))
  118. {
  119. if (!soc || !soc->ops) {
  120. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  121. "%s invalid instance", __func__);
  122. return QDF_STATUS_E_INVAL;
  123. }
  124. if (!soc->ops->pktcapture_ops ||
  125. !soc->ops->pktcapture_ops->txrx_pktcapture_cb_register)
  126. return QDF_STATUS_E_INVAL;
  127. return soc->ops->pktcapture_ops->txrx_pktcapture_cb_register(
  128. soc,
  129. pdev_id,
  130. ctx,
  131. txrx_pktcapture_cb);
  132. }
  133. static inline QDF_STATUS
  134. cdp_deregister_pktcapture_cb(ol_txrx_soc_handle soc, uint8_t pdev_id)
  135. {
  136. if (!soc || !soc->ops) {
  137. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  138. "%s invalid instance", __func__);
  139. return QDF_STATUS_E_INVAL;
  140. }
  141. if (!soc->ops->pktcapture_ops ||
  142. !soc->ops->pktcapture_ops->txrx_pktcapture_cb_deregister)
  143. return QDF_STATUS_E_INVAL;
  144. return soc->ops->pktcapture_ops->txrx_pktcapture_cb_deregister(soc,
  145. pdev_id);
  146. }
  147. static inline QDF_STATUS
  148. cdp_pktcapture_mgmtpkt_process(
  149. ol_txrx_soc_handle soc,
  150. uint8_t pdev_id,
  151. struct mon_rx_status *txrx_status,
  152. qdf_nbuf_t nbuf,
  153. uint8_t status)
  154. {
  155. if (!soc || !soc->ops) {
  156. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  157. "%s invalid instance", __func__);
  158. return QDF_STATUS_E_INVAL;
  159. }
  160. if (!soc->ops->pktcapture_ops ||
  161. !soc->ops->pktcapture_ops->txrx_pktcapture_mgmtpkt_process)
  162. return QDF_STATUS_E_INVAL;
  163. return soc->ops->pktcapture_ops->txrx_pktcapture_mgmtpkt_process(
  164. soc,
  165. pdev_id,
  166. txrx_status,
  167. nbuf,
  168. status);
  169. }
  170. #else
  171. static inline uint8_t
  172. cdp_get_packet_capture_mode(ol_txrx_soc_handle soc, uint8_t pdev_id)
  173. {
  174. return 0;
  175. }
  176. static inline void
  177. cdp_pktcapture_record_channel(ol_txrx_soc_handle soc,
  178. uint8_t pdev_id,
  179. int chan_num)
  180. {
  181. }
  182. #endif /* WLAN_FEATURE_PKT_CAPTURE */
  183. #endif