cdp_txrx_mon.h 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. /**
  20. * DOC: cdp_txrx_mon.h
  21. * Define the monitor mode API functions
  22. * called by the host control SW and the OS interface module
  23. */
  24. #ifndef _CDP_TXRX_MON_H_
  25. #define _CDP_TXRX_MON_H_
  26. #include "cdp_txrx_handle.h"
  27. #include <cdp_txrx_cmn.h>
  28. static inline QDF_STATUS cdp_reset_monitor_mode(ol_txrx_soc_handle soc,
  29. uint8_t pdev_id,
  30. u_int8_t smart_monitor)
  31. {
  32. if (!soc || !soc->ops) {
  33. dp_cdp_debug("Invalid Instance");
  34. QDF_BUG(0);
  35. return 0;
  36. }
  37. if (!soc->ops->mon_ops ||
  38. !soc->ops->mon_ops->txrx_reset_monitor_mode)
  39. return 0;
  40. return soc->ops->mon_ops->txrx_reset_monitor_mode(soc, pdev_id,
  41. smart_monitor);
  42. }
  43. /**
  44. * cdp_deliver_tx_mgmt() - Deliver mgmt frame for tx capture
  45. * @soc: Datapath SOC handle
  46. * @pdev_id: id of datapath PDEV handle
  47. * @nbuf: Management frame buffer
  48. */
  49. static inline QDF_STATUS
  50. cdp_deliver_tx_mgmt(ol_txrx_soc_handle soc, uint8_t pdev_id,
  51. qdf_nbuf_t nbuf)
  52. {
  53. if (!soc || !soc->ops) {
  54. dp_cdp_debug("Invalid Instance");
  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 QCA_SUPPORT_LITE_MONITOR
  64. /**
  65. * cdp_set_lite_mon_config() - Set lite monitor config/filter
  66. *
  67. * @soc: dp soc handle
  68. * @config: lite monitor config
  69. * @pdev_id: pdev id
  70. *
  71. * This API is used to enable/disable lite monitor feature
  72. *
  73. * Return: QDF_STATUS_SUCCESS if value set successfully
  74. * QDF_STATUS_E_INVAL false if error
  75. */
  76. static inline QDF_STATUS
  77. cdp_set_lite_mon_config(ol_txrx_soc_handle soc,
  78. struct cdp_lite_mon_filter_config *config,
  79. uint8_t pdev_id)
  80. {
  81. if (!soc || !soc->ops) {
  82. dp_cdp_debug("Invalid Instance");
  83. return QDF_STATUS_E_INVAL;
  84. }
  85. if (!soc->ops->mon_ops ||
  86. !soc->ops->mon_ops->txrx_set_lite_mon_config)
  87. return QDF_STATUS_E_INVAL;
  88. return soc->ops->mon_ops->txrx_set_lite_mon_config(soc, config,
  89. pdev_id);
  90. }
  91. /**
  92. * cdp_get_lite_mon_config() - Get lite monitor config
  93. *
  94. * @soc: dp soc handle
  95. * @config: lite monitor config
  96. * @pdev_id: pdev id
  97. *
  98. * This API is used to get lite monitor feature config
  99. *
  100. * Return: QDF_STATUS_SUCCESS if get is successfully
  101. * QDF_STATUS_E_INVAL false if error
  102. */
  103. static inline QDF_STATUS
  104. cdp_get_lite_mon_config(ol_txrx_soc_handle soc,
  105. struct cdp_lite_mon_filter_config *config,
  106. uint8_t pdev_id)
  107. {
  108. if (!soc || !soc->ops) {
  109. dp_cdp_debug("Invalid Instance");
  110. return QDF_STATUS_E_INVAL;
  111. }
  112. if (!soc->ops->mon_ops ||
  113. !soc->ops->mon_ops->txrx_get_lite_mon_config)
  114. return QDF_STATUS_E_INVAL;
  115. return soc->ops->mon_ops->txrx_get_lite_mon_config(soc, config,
  116. pdev_id);
  117. }
  118. /**
  119. * cdp_set_lite_mon_peer_config() - Set lite monitor peer config
  120. *
  121. * @soc: dp soc handle
  122. * @config: lite monitor peer config
  123. * @pdev_id: pdev id
  124. *
  125. * This API is used to add/del lite monitor peers
  126. *
  127. * Return: QDF_STATUS_SUCCESS if value set successfully
  128. * QDF_STATUS_E_INVAL false if error
  129. */
  130. static inline QDF_STATUS
  131. cdp_set_lite_mon_peer_config(ol_txrx_soc_handle soc,
  132. struct cdp_lite_mon_peer_config *config,
  133. uint8_t pdev_id)
  134. {
  135. if (!soc || !soc->ops) {
  136. dp_cdp_debug("Invalid Instance");
  137. return QDF_STATUS_E_INVAL;
  138. }
  139. if (!soc->ops->mon_ops ||
  140. !soc->ops->mon_ops->txrx_set_lite_mon_peer_config)
  141. return QDF_STATUS_E_INVAL;
  142. return soc->ops->mon_ops->txrx_set_lite_mon_peer_config(soc, config,
  143. pdev_id);
  144. }
  145. /**
  146. * cdp_get_lite_mon_peer_config() - Get lite monitor peer list
  147. *
  148. * @soc: dp soc handle
  149. * @info: lite monitor peer info
  150. * @pdev_id: pdev id
  151. *
  152. * This API is used to get lite monitor peers
  153. *
  154. * Return: QDF_STATUS_SUCCESS if value set successfully
  155. * QDF_STATUS_E_INVAL false if error
  156. */
  157. static inline QDF_STATUS
  158. cdp_get_lite_mon_peer_config(ol_txrx_soc_handle soc,
  159. struct cdp_lite_mon_peer_info *info,
  160. uint8_t pdev_id)
  161. {
  162. if (!soc || !soc->ops) {
  163. dp_cdp_debug("Invalid Instance");
  164. return QDF_STATUS_E_INVAL;
  165. }
  166. if (!soc->ops->mon_ops ||
  167. !soc->ops->mon_ops->txrx_get_lite_mon_peer_config)
  168. return QDF_STATUS_E_INVAL;
  169. return soc->ops->mon_ops->txrx_get_lite_mon_peer_config(soc, info,
  170. pdev_id);
  171. }
  172. /**
  173. * cdp_is_lite_mon_enabled() - Get lite monitor enable status
  174. *
  175. * @soc: dp soc handle
  176. * @pdev_id: pdev id
  177. * @dir: direction tx/rx
  178. *
  179. * This API is used to get lite monitor enable status
  180. *
  181. * Return: 0 if disabled
  182. * 1 if enabled
  183. */
  184. static inline int
  185. cdp_is_lite_mon_enabled(ol_txrx_soc_handle soc,
  186. uint8_t pdev_id, uint8_t dir)
  187. {
  188. if (!soc || !soc->ops) {
  189. dp_cdp_debug("Invalid Instance");
  190. return 0;
  191. }
  192. if (!soc->ops->mon_ops ||
  193. !soc->ops->mon_ops->txrx_is_lite_mon_enabled)
  194. return 0;
  195. return soc->ops->mon_ops->txrx_is_lite_mon_enabled(soc, pdev_id, dir);
  196. }
  197. /*
  198. * cdp_get_lite_mon_legacy_feature_enabled() - Get the legacy feature enabled
  199. *
  200. * @soc: dp soc handle
  201. * @pdev_id: pdev id
  202. * @dir: direction tx/rx
  203. *
  204. * This API is used to get the legacy feature enabled using lite_mon
  205. *
  206. * Return: legacy feature enabled
  207. */
  208. static inline int
  209. cdp_get_lite_mon_legacy_feature_enabled(ol_txrx_soc_handle soc,
  210. uint8_t pdev_id, uint8_t dir)
  211. {
  212. if (!soc || !soc->ops) {
  213. dp_cdp_debug("Invalid Instance");
  214. return 0;
  215. }
  216. if (!soc->ops->mon_ops ||
  217. !soc->ops->mon_ops->txrx_get_lite_mon_legacy_feature_enabled)
  218. return 0;
  219. return soc->ops->mon_ops->txrx_get_lite_mon_legacy_feature_enabled(soc,
  220. pdev_id,
  221. dir);
  222. }
  223. #endif
  224. #ifdef QCA_RSSI_DB2DBM
  225. /**
  226. * cdp_set_params_rssi_dbm_conversion - Set the rssi dbm conversion params
  227. * into dp_pdev structure
  228. * @soc: soc txrx handler
  229. * @params: cdp_rssi_db2dbm_param_dp pointer
  230. *
  231. */
  232. static inline QDF_STATUS
  233. cdp_set_params_rssi_dbm_conversion(ol_txrx_soc_handle soc,
  234. struct cdp_rssi_db2dbm_param_dp *params)
  235. {
  236. if (!soc || !soc->ops) {
  237. dp_cdp_debug("Invalid Instance:");
  238. QDF_BUG(0);
  239. return QDF_STATUS_E_FAILURE;
  240. }
  241. if (!soc->ops->mon_ops ||
  242. !soc->ops->mon_ops->txrx_set_mon_pdev_params_rssi_dbm_conv)
  243. return QDF_STATUS_E_FAILURE;
  244. return soc->ops->mon_ops->txrx_set_mon_pdev_params_rssi_dbm_conv
  245. (soc, params);
  246. }
  247. #endif
  248. #ifdef WLAN_CONFIG_TELEMETRY_AGENT
  249. /*
  250. * cdp_update_pdev_mon_telemetry_airtime_stats() - update telemetry airtime
  251. * stats in monitor pdev
  252. *
  253. *@soc: dp soc handle
  254. *@pdev_id: pdev id
  255. *
  256. * This API is used to update telemetry airtime stats in monitor pdev
  257. *
  258. * Return: Success if stats are updated, else failure
  259. */
  260. static inline QDF_STATUS
  261. cdp_update_pdev_mon_telemetry_airtime_stats(ol_txrx_soc_handle soc,
  262. uint8_t pdev_id)
  263. {
  264. if (!soc || !soc->ops) {
  265. dp_cdp_debug("Invalid Instance");
  266. return QDF_STATUS_E_FAILURE;
  267. }
  268. if (!soc->ops->mon_ops ||
  269. !soc->ops->mon_ops->txrx_update_pdev_mon_telemetry_airtime_stats)
  270. return QDF_STATUS_E_FAILURE;
  271. return soc->ops->mon_ops->txrx_update_pdev_mon_telemetry_airtime_stats(
  272. soc, pdev_id);
  273. }
  274. #endif
  275. #ifdef WLAN_FEATURE_LOCAL_PKT_CAPTURE
  276. /**
  277. * cdp_start_local_pkt_capture() - start local pkt capture
  278. * @soc: opaque soc handle
  279. * @pdev_id: pdev id
  280. * @filter: monitor filter config
  281. *
  282. * Return: QDF_STATUS_SUCCESS if success
  283. * QDF_STATUS_E_FAILURE if error
  284. */
  285. static inline
  286. QDF_STATUS cdp_start_local_pkt_capture(ol_txrx_soc_handle soc,
  287. uint8_t pdev_id,
  288. struct cdp_monitor_filter *filter)
  289. {
  290. if (!soc || !soc->ops) {
  291. dp_cdp_debug("Invalid Instance");
  292. return QDF_STATUS_E_FAILURE;
  293. }
  294. if (!soc->ops->mon_ops ||
  295. !soc->ops->mon_ops->start_local_pkt_capture)
  296. return QDF_STATUS_E_FAILURE;
  297. return soc->ops->mon_ops->start_local_pkt_capture(soc, pdev_id, filter);
  298. }
  299. /**
  300. * cdp_stop_local_pkt_capture() - stop local pkt capture
  301. * @soc: opaque soc handle
  302. * @pdev_id: pdev_id
  303. *
  304. * Return: QDF_STATUS_SUCCESS if success
  305. * QDF_STATUS_E_FAILURE if error
  306. */
  307. static inline
  308. QDF_STATUS cdp_stop_local_pkt_capture(ol_txrx_soc_handle soc, uint8_t pdev_id)
  309. {
  310. if (!soc || !soc->ops) {
  311. dp_cdp_debug("Invalid Instance");
  312. QDF_BUG(0);
  313. return QDF_STATUS_E_FAILURE;
  314. }
  315. if (!soc->ops->mon_ops ||
  316. !soc->ops->mon_ops->stop_local_pkt_capture)
  317. return QDF_STATUS_E_FAILURE;
  318. return soc->ops->mon_ops->stop_local_pkt_capture(soc, pdev_id);
  319. }
  320. /**
  321. * cdp_is_local_pkt_capture_running() - get is local packet capture running
  322. * @soc: opaque soc handle
  323. * @pdev_id: pdev id
  324. *
  325. * Return: true if running
  326. * false if not running
  327. */
  328. static inline
  329. bool cdp_is_local_pkt_capture_running(ol_txrx_soc_handle soc, uint8_t pdev_id)
  330. {
  331. if (!soc || !soc->ops) {
  332. dp_cdp_debug("Invalid Instance");
  333. QDF_BUG(0);
  334. return false;
  335. }
  336. if (!soc->ops->mon_ops ||
  337. !soc->ops->mon_ops->is_local_pkt_capture_running)
  338. return false;
  339. return soc->ops->mon_ops->is_local_pkt_capture_running(soc, pdev_id);
  340. }
  341. #else
  342. static inline
  343. QDF_STATUS cdp_start_local_pkt_capture(ol_txrx_soc_handle soc,
  344. uint8_t pdev_id,
  345. struct cdp_monitor_filter *filter)
  346. {
  347. return QDF_STATUS_E_NOSUPPORT;
  348. }
  349. static inline
  350. QDF_STATUS cdp_stop_local_pkt_capture(ol_txrx_soc_handle soc, uint8_t pdev_id)
  351. {
  352. return QDF_STATUS_E_NOSUPPORT;
  353. }
  354. static inline
  355. bool cdp_is_local_pkt_capture_running(ol_txrx_soc_handle soc, uint8_t pdev_id)
  356. {
  357. return false;
  358. }
  359. #endif /* WLAN_FEATURE_LOCAL_PKT_CAPTURE */
  360. #endif