cdp_txrx_mon.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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 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
  131. cdp_record_monitor_chan_num(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  132. int chan_num)
  133. {
  134. if (!soc || !soc->ops) {
  135. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  136. "%s: Invalid Instance", __func__);
  137. QDF_BUG(0);
  138. return;
  139. }
  140. if (!soc->ops->mon_ops ||
  141. !soc->ops->mon_ops->txrx_monitor_record_channel)
  142. return;
  143. soc->ops->mon_ops->txrx_monitor_record_channel(pdev, chan_num);
  144. }
  145. static inline void
  146. cdp_record_monitor_chan_freq(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  147. qdf_freq_t chan_freq)
  148. {
  149. if (!soc || !soc->ops) {
  150. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  151. "%s: Invalid Instance", __func__);
  152. QDF_BUG(0);
  153. return;
  154. }
  155. if (!soc->ops->mon_ops ||
  156. !soc->ops->mon_ops->txrx_monitor_record_frequency)
  157. return;
  158. soc->ops->mon_ops->txrx_monitor_record_frequency(pdev, chan_freq);
  159. }
  160. /**
  161. * cdp_deliver_tx_mgmt() - Deliver mgmt frame for tx capture
  162. * @soc: Datapath SOC handle
  163. * @pdev: Datapath PDEV handle
  164. * @nbuf: Management frame buffer
  165. */
  166. static inline void
  167. cdp_deliver_tx_mgmt(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  168. qdf_nbuf_t nbuf)
  169. {
  170. if (!soc || !soc->ops) {
  171. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  172. "%s: Invalid Instance", __func__);
  173. QDF_BUG(0);
  174. return;
  175. }
  176. if (!soc->ops->mon_ops ||
  177. !soc->ops->mon_ops->txrx_deliver_tx_mgmt)
  178. return;
  179. soc->ops->mon_ops->txrx_deliver_tx_mgmt(pdev, nbuf);
  180. }
  181. static inline void
  182. cdp_set_bsscolor(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  183. uint8_t bsscolor)
  184. {
  185. if (!soc || !soc->ops) {
  186. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  187. "%s: Invalid Instance", __func__);
  188. QDF_BUG(0);
  189. return;
  190. }
  191. if (!soc->ops->mon_ops ||
  192. !soc->ops->mon_ops->txrx_set_bsscolor)
  193. return;
  194. soc->ops->mon_ops->txrx_set_bsscolor(pdev, bsscolor);
  195. }
  196. #ifdef WLAN_FEATURE_PKT_CAPTURE
  197. static inline void
  198. cdp_pktcapture_record_channel(
  199. ol_txrx_soc_handle soc,
  200. uint8_t pdev_id,
  201. int chan_num)
  202. {
  203. if (!soc || !soc->ops) {
  204. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  205. "%s invalid instance", __func__);
  206. QDF_BUG(0);
  207. return;
  208. }
  209. if (!soc->ops->pktcapture_ops ||
  210. !soc->ops->pktcapture_ops->txrx_pktcapture_record_channel)
  211. return;
  212. soc->ops->pktcapture_ops->txrx_pktcapture_record_channel(soc,
  213. pdev_id,
  214. chan_num);
  215. }
  216. static inline void
  217. cdp_set_packet_capture_mode(ol_txrx_soc_handle soc,
  218. uint8_t pdev_id,
  219. uint8_t val)
  220. {
  221. if (!soc || !soc->ops) {
  222. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  223. "%s invalid instance", __func__);
  224. QDF_BUG(0);
  225. return;
  226. }
  227. if (!soc->ops->pktcapture_ops ||
  228. !soc->ops->pktcapture_ops->txrx_pktcapture_set_mode)
  229. return;
  230. soc->ops->pktcapture_ops->txrx_pktcapture_set_mode(soc, pdev_id, val);
  231. }
  232. static inline uint8_t
  233. cdp_get_packet_capture_mode(ol_txrx_soc_handle soc, uint8_t pdev_id)
  234. {
  235. if (!soc || !soc->ops) {
  236. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  237. "%s invalid instance", __func__);
  238. QDF_BUG(0);
  239. return 0;
  240. }
  241. if (!soc->ops->pktcapture_ops ||
  242. !soc->ops->pktcapture_ops->txrx_pktcapture_get_mode)
  243. return 0;
  244. return soc->ops->pktcapture_ops->txrx_pktcapture_get_mode(soc,
  245. pdev_id);
  246. }
  247. static inline QDF_STATUS
  248. cdp_register_pktcapture_cb(
  249. ol_txrx_soc_handle soc, uint8_t pdev_id, void *ctx,
  250. QDF_STATUS(txrx_pktcapture_cb)(void *, qdf_nbuf_t))
  251. {
  252. if (!soc || !soc->ops) {
  253. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  254. "%s invalid instance", __func__);
  255. return QDF_STATUS_E_INVAL;
  256. }
  257. if (!soc->ops->pktcapture_ops ||
  258. !soc->ops->pktcapture_ops->txrx_pktcapture_cb_register)
  259. return QDF_STATUS_E_INVAL;
  260. return soc->ops->pktcapture_ops->txrx_pktcapture_cb_register(
  261. soc,
  262. pdev_id,
  263. ctx,
  264. txrx_pktcapture_cb);
  265. }
  266. static inline QDF_STATUS
  267. cdp_deregister_pktcapture_cb(ol_txrx_soc_handle soc, uint8_t pdev_id)
  268. {
  269. if (!soc || !soc->ops) {
  270. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  271. "%s invalid instance", __func__);
  272. return QDF_STATUS_E_INVAL;
  273. }
  274. if (!soc->ops->pktcapture_ops ||
  275. !soc->ops->pktcapture_ops->txrx_pktcapture_cb_deregister)
  276. return QDF_STATUS_E_INVAL;
  277. return soc->ops->pktcapture_ops->txrx_pktcapture_cb_deregister(soc,
  278. pdev_id);
  279. }
  280. static inline QDF_STATUS
  281. cdp_pktcapture_mgmtpkt_process(
  282. ol_txrx_soc_handle soc,
  283. uint8_t pdev_id,
  284. struct mon_rx_status *txrx_status,
  285. qdf_nbuf_t nbuf,
  286. uint8_t status)
  287. {
  288. if (!soc || !soc->ops) {
  289. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  290. "%s invalid instance", __func__);
  291. return QDF_STATUS_E_INVAL;
  292. }
  293. if (!soc->ops->pktcapture_ops ||
  294. !soc->ops->pktcapture_ops->txrx_pktcapture_mgmtpkt_process)
  295. return QDF_STATUS_E_INVAL;
  296. return soc->ops->pktcapture_ops->txrx_pktcapture_mgmtpkt_process(
  297. soc,
  298. pdev_id,
  299. txrx_status,
  300. nbuf,
  301. status);
  302. }
  303. #else
  304. static inline uint8_t
  305. cdp_get_packet_capture_mode(ol_txrx_soc_handle soc, uint8_t pdev_id)
  306. {
  307. return 0;
  308. }
  309. static inline void
  310. cdp_pktcapture_record_channel(ol_txrx_soc_handle soc,
  311. uint8_t pdev_id,
  312. int chan_num)
  313. {
  314. }
  315. #endif /* WLAN_FEATURE_PKT_CAPTURE */
  316. #endif