cdp_txrx_mon.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. /*
  2. * Copyright (c) 2016-2019 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 void cdp_monitor_set_filter_ucast_data
  27. (ol_txrx_soc_handle soc, struct cdp_pdev *pdev, u_int8_t val)
  28. {
  29. if (!soc || !soc->ops) {
  30. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  31. "%s: Invalid Instance", __func__);
  32. QDF_BUG(0);
  33. return;
  34. }
  35. if (!soc->ops->mon_ops ||
  36. !soc->ops->mon_ops->txrx_monitor_set_filter_ucast_data)
  37. return;
  38. soc->ops->mon_ops->txrx_monitor_set_filter_ucast_data
  39. (pdev, val);
  40. }
  41. static inline void cdp_monitor_set_filter_mcast_data
  42. (ol_txrx_soc_handle soc, struct cdp_pdev *pdev, u_int8_t val)
  43. {
  44. if (!soc || !soc->ops) {
  45. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  46. "%s: Invalid Instance", __func__);
  47. QDF_BUG(0);
  48. return;
  49. }
  50. if (!soc->ops->mon_ops ||
  51. !soc->ops->mon_ops->txrx_monitor_set_filter_mcast_data)
  52. return;
  53. soc->ops->mon_ops->txrx_monitor_set_filter_mcast_data
  54. (pdev, val);
  55. }
  56. static inline void cdp_monitor_set_filter_non_data
  57. (ol_txrx_soc_handle soc, struct cdp_pdev *pdev, u_int8_t val)
  58. {
  59. if (!soc || !soc->ops) {
  60. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  61. "%s: Invalid Instance", __func__);
  62. QDF_BUG(0);
  63. return;
  64. }
  65. if (!soc->ops->mon_ops ||
  66. !soc->ops->mon_ops->txrx_monitor_set_filter_non_data)
  67. return;
  68. soc->ops->mon_ops->txrx_monitor_set_filter_non_data
  69. (pdev, val);
  70. }
  71. static inline bool cdp_monitor_get_filter_ucast_data
  72. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev_txrx_handle)
  73. {
  74. if (!soc || !soc->ops) {
  75. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  76. "%s: Invalid Instance", __func__);
  77. QDF_BUG(0);
  78. return 0;
  79. }
  80. if (!soc->ops->mon_ops ||
  81. !soc->ops->mon_ops->txrx_monitor_get_filter_ucast_data)
  82. return 0;
  83. return soc->ops->mon_ops->txrx_monitor_get_filter_ucast_data
  84. (vdev_txrx_handle);
  85. }
  86. static inline bool cdp_monitor_get_filter_mcast_data
  87. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev_txrx_handle)
  88. {
  89. if (!soc || !soc->ops) {
  90. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  91. "%s: Invalid Instance", __func__);
  92. QDF_BUG(0);
  93. return 0;
  94. }
  95. if (!soc->ops->mon_ops ||
  96. !soc->ops->mon_ops->txrx_monitor_get_filter_mcast_data)
  97. return 0;
  98. return soc->ops->mon_ops->txrx_monitor_get_filter_mcast_data
  99. (vdev_txrx_handle);
  100. }
  101. static inline bool cdp_monitor_get_filter_non_data
  102. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev_txrx_handle)
  103. {
  104. if (!soc || !soc->ops) {
  105. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  106. "%s: Invalid Instance", __func__);
  107. QDF_BUG(0);
  108. return 0;
  109. }
  110. if (!soc->ops->mon_ops ||
  111. !soc->ops->mon_ops->txrx_monitor_get_filter_non_data)
  112. return 0;
  113. return soc->ops->mon_ops->txrx_monitor_get_filter_non_data
  114. (vdev_txrx_handle);
  115. }
  116. static inline QDF_STATUS cdp_reset_monitor_mode
  117. (ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
  118. {
  119. if (!soc || !soc->ops) {
  120. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  121. "%s: Invalid Instance", __func__);
  122. QDF_BUG(0);
  123. return 0;
  124. }
  125. if (!soc->ops->mon_ops ||
  126. !soc->ops->mon_ops->txrx_reset_monitor_mode)
  127. return 0;
  128. return soc->ops->mon_ops->txrx_reset_monitor_mode(pdev);
  129. }
  130. static inline void cdp_record_monitor_chan_num
  131. (ol_txrx_soc_handle soc, struct cdp_pdev *pdev, int chan_num)
  132. {
  133. if (!soc || !soc->ops) {
  134. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  135. "%s: Invalid Instance", __func__);
  136. QDF_BUG(0);
  137. return;
  138. }
  139. if (!soc->ops->mon_ops ||
  140. !soc->ops->mon_ops->txrx_monitor_record_channel)
  141. return;
  142. soc->ops->mon_ops->txrx_monitor_record_channel(pdev, chan_num);
  143. }
  144. /**
  145. * cdp_deliver_tx_mgmt() - Deliver mgmt frame for tx capture
  146. * @soc: Datapath SOC handle
  147. * @pdev: Datapath PDEV handle
  148. * @nbuf: Management frame buffer
  149. */
  150. static inline void
  151. cdp_deliver_tx_mgmt(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  152. qdf_nbuf_t nbuf)
  153. {
  154. if (!soc || !soc->ops) {
  155. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  156. "%s: Invalid Instance", __func__);
  157. QDF_BUG(0);
  158. return;
  159. }
  160. if (!soc->ops->mon_ops ||
  161. !soc->ops->mon_ops->txrx_deliver_tx_mgmt)
  162. return;
  163. soc->ops->mon_ops->txrx_deliver_tx_mgmt(pdev, nbuf);
  164. }
  165. static inline void
  166. cdp_set_bsscolor(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  167. uint8_t bsscolor)
  168. {
  169. if (!soc || !soc->ops) {
  170. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  171. "%s: Invalid Instance", __func__);
  172. QDF_BUG(0);
  173. return;
  174. }
  175. if (!soc->ops->mon_ops ||
  176. !soc->ops->mon_ops->txrx_set_bsscolor)
  177. return;
  178. soc->ops->mon_ops->txrx_set_bsscolor(pdev, bsscolor);
  179. }
  180. #ifdef WLAN_FEATURE_PKT_CAPTURE
  181. static inline void
  182. cdp_pktcapture_record_channel(
  183. ol_txrx_soc_handle soc,
  184. uint8_t pdev_id,
  185. int chan_num)
  186. {
  187. if (!soc || !soc->ops) {
  188. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  189. "%s invalid instance", __func__);
  190. QDF_BUG(0);
  191. return;
  192. }
  193. if (!soc->ops->pktcapture_ops ||
  194. !soc->ops->pktcapture_ops->txrx_pktcapture_record_channel)
  195. return;
  196. soc->ops->pktcapture_ops->txrx_pktcapture_record_channel(soc,
  197. pdev_id,
  198. chan_num);
  199. }
  200. static inline void
  201. cdp_set_packet_capture_mode(ol_txrx_soc_handle soc,
  202. uint8_t pdev_id,
  203. uint8_t val)
  204. {
  205. if (!soc || !soc->ops) {
  206. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  207. "%s invalid instance", __func__);
  208. QDF_BUG(0);
  209. return;
  210. }
  211. if (!soc->ops->pktcapture_ops ||
  212. !soc->ops->pktcapture_ops->txrx_pktcapture_set_mode)
  213. return;
  214. soc->ops->pktcapture_ops->txrx_pktcapture_set_mode(soc, pdev_id, val);
  215. }
  216. static inline uint8_t
  217. cdp_get_packet_capture_mode(ol_txrx_soc_handle soc, uint8_t pdev_id)
  218. {
  219. if (!soc || !soc->ops) {
  220. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  221. "%s invalid instance", __func__);
  222. QDF_BUG(0);
  223. return 0;
  224. }
  225. if (!soc->ops->pktcapture_ops ||
  226. !soc->ops->pktcapture_ops->txrx_pktcapture_get_mode)
  227. return 0;
  228. return soc->ops->pktcapture_ops->txrx_pktcapture_get_mode(soc,
  229. pdev_id);
  230. }
  231. static inline QDF_STATUS
  232. cdp_register_pktcapture_cb(
  233. ol_txrx_soc_handle soc, uint8_t pdev_id, void *ctx,
  234. QDF_STATUS(txrx_pktcapture_cb)(void *, qdf_nbuf_t))
  235. {
  236. if (!soc || !soc->ops) {
  237. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  238. "%s invalid instance", __func__);
  239. return QDF_STATUS_E_INVAL;
  240. }
  241. if (!soc->ops->pktcapture_ops ||
  242. !soc->ops->pktcapture_ops->txrx_pktcapture_cb_register)
  243. return QDF_STATUS_E_INVAL;
  244. return soc->ops->pktcapture_ops->txrx_pktcapture_cb_register(
  245. soc,
  246. pdev_id,
  247. ctx,
  248. txrx_pktcapture_cb);
  249. }
  250. static inline QDF_STATUS
  251. cdp_deregister_pktcapture_cb(ol_txrx_soc_handle soc, uint8_t pdev_id)
  252. {
  253. if (!soc || !soc->ops) {
  254. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  255. "%s invalid instance", __func__);
  256. return QDF_STATUS_E_INVAL;
  257. }
  258. if (!soc->ops->pktcapture_ops ||
  259. !soc->ops->pktcapture_ops->txrx_pktcapture_cb_deregister)
  260. return QDF_STATUS_E_INVAL;
  261. return soc->ops->pktcapture_ops->txrx_pktcapture_cb_deregister(soc,
  262. pdev_id);
  263. }
  264. static inline QDF_STATUS
  265. cdp_pktcapture_mgmtpkt_process(
  266. ol_txrx_soc_handle soc,
  267. uint8_t pdev_id,
  268. struct mon_rx_status *txrx_status,
  269. qdf_nbuf_t nbuf,
  270. uint8_t status)
  271. {
  272. if (!soc || !soc->ops) {
  273. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  274. "%s invalid instance", __func__);
  275. return QDF_STATUS_E_INVAL;
  276. }
  277. if (!soc->ops->pktcapture_ops ||
  278. !soc->ops->pktcapture_ops->txrx_pktcapture_mgmtpkt_process)
  279. return QDF_STATUS_E_INVAL;
  280. return soc->ops->pktcapture_ops->txrx_pktcapture_mgmtpkt_process(
  281. soc,
  282. pdev_id,
  283. txrx_status,
  284. nbuf,
  285. status);
  286. }
  287. #else
  288. static inline uint8_t
  289. cdp_get_packet_capture_mode(ol_txrx_soc_handle soc, uint8_t pdev_id)
  290. {
  291. return 0;
  292. }
  293. static inline void
  294. cdp_pktcapture_record_channel(ol_txrx_soc_handle soc,
  295. uint8_t pdev_id,
  296. int chan_num)
  297. {
  298. }
  299. #endif /* WLAN_FEATURE_PKT_CAPTURE */
  300. #endif