cdp_txrx_ctrl.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  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_ctrl.h
  20. * @brief Define the host data path control API functions
  21. * called by the host control SW and the OS interface module
  22. */
  23. #ifndef _CDP_TXRX_CTRL_H_
  24. #define _CDP_TXRX_CTRL_H_
  25. #include "cdp_txrx_handle.h"
  26. #include "cdp_txrx_cmn_struct.h"
  27. #include "cdp_txrx_cmn.h"
  28. #include "cdp_txrx_ops.h"
  29. static inline int cdp_is_target_ar900b
  30. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  31. {
  32. if (!soc || !soc->ops) {
  33. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  34. "%s: Invalid Instance:", __func__);
  35. QDF_BUG(0);
  36. return 0;
  37. }
  38. if (!soc->ops->ctrl_ops ||
  39. !soc->ops->ctrl_ops->txrx_is_target_ar900b)
  40. return 0;
  41. return soc->ops->ctrl_ops->txrx_is_target_ar900b(vdev);
  42. }
  43. /* WIN */
  44. static inline int
  45. cdp_mempools_attach(ol_txrx_soc_handle soc, void *ctrl_pdev)
  46. {
  47. if (!soc || !soc->ops) {
  48. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  49. "%s: Invalid Instance:", __func__);
  50. QDF_BUG(0);
  51. return 0;
  52. }
  53. if (!soc->ops->ctrl_ops ||
  54. !soc->ops->ctrl_ops->txrx_mempools_attach)
  55. return 0;
  56. return soc->ops->ctrl_ops->txrx_mempools_attach(ctrl_pdev);
  57. }
  58. /**
  59. * @brief set filter neighbour peers
  60. * @details
  61. * This defines interface function to set neighbour peer filtering.
  62. *
  63. * @param soc - the pointer to soc object
  64. * @param pdev - the pointer physical device object
  65. * @param val - the enable/disable value
  66. * @return - int
  67. */
  68. static inline int
  69. cdp_set_filter_neighbour_peers(ol_txrx_soc_handle soc,
  70. struct cdp_pdev *pdev, u_int32_t val)
  71. {
  72. if (!soc || !soc->ops) {
  73. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  74. "%s: Invalid Instance:", __func__);
  75. QDF_BUG(0);
  76. return 0;
  77. }
  78. if (!soc->ops->ctrl_ops ||
  79. !soc->ops->ctrl_ops->txrx_set_filter_neighbour_peers)
  80. return 0;
  81. return soc->ops->ctrl_ops->txrx_set_filter_neighbour_peers
  82. (pdev, val);
  83. }
  84. /**
  85. * @brief update the neighbour peer addresses
  86. * @details
  87. * This defines interface function to update neighbour peers addresses
  88. * which needs to be filtered
  89. *
  90. * @param soc - the pointer to soc object
  91. * @param vdev - the pointer to vdev
  92. * @param cmd - add/del entry into peer table
  93. * @param macaddr - the address of neighbour peer
  94. * @return - int
  95. */
  96. static inline int
  97. cdp_update_filter_neighbour_peers(ol_txrx_soc_handle soc,
  98. struct cdp_vdev *vdev, uint32_t cmd, uint8_t *macaddr)
  99. {
  100. if (!soc || !soc->ops) {
  101. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  102. "%s: Invalid Instance:", __func__);
  103. QDF_BUG(0);
  104. return 0;
  105. }
  106. if (!soc->ops->ctrl_ops ||
  107. !soc->ops->ctrl_ops->txrx_update_filter_neighbour_peers)
  108. return 0;
  109. return soc->ops->ctrl_ops->txrx_update_filter_neighbour_peers
  110. (vdev, cmd, macaddr);
  111. }
  112. /**
  113. * @brief set the safemode of the device
  114. * @details
  115. * This flag is used to bypass the encrypt and decrypt processes when send and
  116. * receive packets. It works like open AUTH mode, HW will treate all packets
  117. * as non-encrypt frames because no key installed. For rx fragmented frames,
  118. * it bypasses all the rx defragmentaion.
  119. *
  120. * @param vdev - the data virtual device object
  121. * @param val - the safemode state
  122. * @return - void
  123. */
  124. static inline void
  125. cdp_set_safemode(ol_txrx_soc_handle soc,
  126. struct cdp_vdev *vdev, u_int32_t val)
  127. {
  128. if (!soc || !soc->ops) {
  129. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  130. "%s: Invalid Instance:", __func__);
  131. QDF_BUG(0);
  132. return;
  133. }
  134. if (!soc->ops->ctrl_ops ||
  135. !soc->ops->ctrl_ops->txrx_set_safemode)
  136. return;
  137. soc->ops->ctrl_ops->txrx_set_safemode(vdev, val);
  138. }
  139. /**
  140. * @brief configure the drop unencrypted frame flag
  141. * @details
  142. * Rx related. When set this flag, all the unencrypted frames
  143. * received over a secure connection will be discarded
  144. *
  145. * @param vdev - the data virtual device object
  146. * @param val - flag
  147. * @return - void
  148. */
  149. static inline void
  150. cdp_set_drop_unenc(ol_txrx_soc_handle soc,
  151. struct cdp_vdev *vdev, u_int32_t val)
  152. {
  153. if (!soc || !soc->ops) {
  154. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  155. "%s: Invalid Instance:", __func__);
  156. QDF_BUG(0);
  157. return;
  158. }
  159. if (!soc->ops->ctrl_ops ||
  160. !soc->ops->ctrl_ops->txrx_set_drop_unenc)
  161. return;
  162. soc->ops->ctrl_ops->txrx_set_drop_unenc(vdev, val);
  163. }
  164. /**
  165. * @brief set the Tx encapsulation type of the VDEV
  166. * @details
  167. * This will be used to populate the HTT desc packet type field during Tx
  168. *
  169. * @param vdev - the data virtual device object
  170. * @param val - the Tx encap type (htt_cmn_pkt_type)
  171. * @return - void
  172. */
  173. static inline void
  174. cdp_set_tx_encap_type(ol_txrx_soc_handle soc,
  175. struct cdp_vdev *vdev, enum htt_cmn_pkt_type val)
  176. {
  177. if (!soc || !soc->ops) {
  178. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  179. "%s: Invalid Instance:", __func__);
  180. QDF_BUG(0);
  181. return;
  182. }
  183. if (!soc->ops->ctrl_ops ||
  184. !soc->ops->ctrl_ops->txrx_set_tx_encap_type)
  185. return;
  186. soc->ops->ctrl_ops->txrx_set_tx_encap_type(vdev, val);
  187. }
  188. /**
  189. * @brief set the Rx decapsulation type of the VDEV
  190. * @details
  191. * This will be used to configure into firmware and hardware which format to
  192. * decap all Rx packets into, for all peers under the VDEV.
  193. *
  194. * @param vdev - the data virtual device object
  195. * @param val - the Rx decap mode (htt_cmn_pkt_type)
  196. * @return - void
  197. */
  198. static inline void
  199. cdp_set_vdev_rx_decap_type(ol_txrx_soc_handle soc,
  200. struct cdp_vdev *vdev, enum htt_cmn_pkt_type val)
  201. {
  202. if (!soc || !soc->ops) {
  203. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  204. "%s: Invalid Instance:", __func__);
  205. QDF_BUG(0);
  206. return;
  207. }
  208. if (!soc->ops->ctrl_ops ||
  209. !soc->ops->ctrl_ops->txrx_set_vdev_rx_decap_type)
  210. return;
  211. soc->ops->ctrl_ops->txrx_set_vdev_rx_decap_type
  212. (vdev, val);
  213. }
  214. /**
  215. * @brief get the Rx decapsulation type of the VDEV
  216. *
  217. * @param vdev - the data virtual device object
  218. * @return - the Rx decap type (htt_cmn_pkt_type)
  219. */
  220. static inline enum htt_cmn_pkt_type
  221. cdp_get_vdev_rx_decap_type(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  222. {
  223. if (!soc || !soc->ops) {
  224. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  225. "%s: Invalid Instance:", __func__);
  226. QDF_BUG(0);
  227. return 0;
  228. }
  229. if (!soc->ops->ctrl_ops ||
  230. !soc->ops->ctrl_ops->txrx_get_vdev_rx_decap_type)
  231. return 0;
  232. return soc->ops->ctrl_ops->txrx_get_vdev_rx_decap_type(vdev);
  233. }
  234. /**
  235. * @brief set the Reo Destination ring for the pdev
  236. * @details
  237. * This will be used to configure the Reo Destination ring for this pdev.
  238. *
  239. * @param soc - pointer to the soc
  240. * @param pdev - the data physical device object
  241. * @param val - the Reo destination ring index (1 to 4)
  242. * @return - void
  243. */
  244. static inline void
  245. cdp_set_pdev_reo_dest(ol_txrx_soc_handle soc,
  246. struct cdp_pdev *pdev, enum cdp_host_reo_dest_ring val)
  247. {
  248. if (!soc || !soc->ops) {
  249. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  250. "%s: Invalid Instance:", __func__);
  251. QDF_BUG(0);
  252. return;
  253. }
  254. if (!soc->ops->ctrl_ops ||
  255. !soc->ops->ctrl_ops->txrx_set_pdev_reo_dest)
  256. return;
  257. soc->ops->ctrl_ops->txrx_set_pdev_reo_dest
  258. (pdev, val);
  259. }
  260. /**
  261. * @brief get the Reo Destination ring for the pdev
  262. *
  263. * @param soc - pointer to the soc
  264. * @param pdev - the data physical device object
  265. * @return - the Reo destination ring index (1 to 4), 0 if not supported.
  266. */
  267. static inline enum cdp_host_reo_dest_ring
  268. cdp_get_pdev_reo_dest(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
  269. {
  270. if (!soc || !soc->ops) {
  271. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  272. "%s: Invalid Instance:", __func__);
  273. QDF_BUG(0);
  274. return cdp_host_reo_dest_ring_unknown;
  275. }
  276. if (!soc->ops->ctrl_ops ||
  277. !soc->ops->ctrl_ops->txrx_get_pdev_reo_dest)
  278. return cdp_host_reo_dest_ring_unknown;
  279. return soc->ops->ctrl_ops->txrx_get_pdev_reo_dest(pdev);
  280. }
  281. /* Is this similar to ol_txrx_peer_state_update() in MCL */
  282. /**
  283. * @brief Update the authorize peer object at association time
  284. * @details
  285. * For the host-based implementation of rate-control, it
  286. * updates the peer/node-related parameters within rate-control
  287. * context of the peer at association.
  288. *
  289. * @param peer - pointer to the node's object
  290. * @authorize - either to authorize or unauthorize peer
  291. *
  292. * @return none
  293. */
  294. static inline void
  295. cdp_peer_authorize(ol_txrx_soc_handle soc,
  296. struct cdp_peer *peer, u_int32_t authorize)
  297. {
  298. if (!soc || !soc->ops) {
  299. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  300. "%s: Invalid Instance:", __func__);
  301. QDF_BUG(0);
  302. return;
  303. }
  304. if (!soc->ops->ctrl_ops ||
  305. !soc->ops->ctrl_ops->txrx_peer_authorize)
  306. return;
  307. soc->ops->ctrl_ops->txrx_peer_authorize
  308. (peer, authorize);
  309. }
  310. /* Should be ol_txrx_ctrl_api.h */
  311. static inline void cdp_set_mesh_mode
  312. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev, u_int32_t val)
  313. {
  314. if (!soc || !soc->ops) {
  315. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  316. "%s: Invalid Instance:", __func__);
  317. QDF_BUG(0);
  318. return;
  319. }
  320. if (!soc->ops->ctrl_ops ||
  321. !soc->ops->ctrl_ops->txrx_set_mesh_mode)
  322. return;
  323. soc->ops->ctrl_ops->txrx_set_mesh_mode(vdev, val);
  324. }
  325. /**
  326. * @brief set mesh rx filter
  327. * @details based on the bits enabled in the filter packets has to be dropped.
  328. *
  329. * @param soc - pointer to the soc
  330. * @param vdev - the data virtual device object
  331. * @param val - value to be set
  332. * @return - void
  333. */
  334. static inline
  335. void cdp_set_mesh_rx_filter(ol_txrx_soc_handle soc,
  336. struct cdp_vdev *vdev, uint32_t val)
  337. {
  338. if (!soc || !soc->ops) {
  339. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  340. "%s: Invalid Instance:", __func__);
  341. QDF_BUG(0);
  342. return;
  343. }
  344. if (!soc->ops->ctrl_ops ||
  345. !soc->ops->ctrl_ops->txrx_set_mesh_rx_filter)
  346. return;
  347. soc->ops->ctrl_ops->txrx_set_mesh_rx_filter(vdev, val);
  348. }
  349. static inline void cdp_tx_flush_buffers
  350. (ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  351. {
  352. if (!soc || !soc->ops) {
  353. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  354. "%s: Invalid Instance:", __func__);
  355. QDF_BUG(0);
  356. return;
  357. }
  358. if (!soc->ops->ctrl_ops ||
  359. !soc->ops->ctrl_ops->tx_flush_buffers)
  360. return;
  361. soc->ops->ctrl_ops->tx_flush_buffers(vdev);
  362. }
  363. static inline uint32_t cdp_txrx_get_vdev_param(ol_txrx_soc_handle soc,
  364. struct cdp_vdev *vdev,
  365. enum cdp_vdev_param_type type)
  366. {
  367. if (!soc || !soc->ops) {
  368. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  369. "%s: Invalid Instance:", __func__);
  370. QDF_BUG(0);
  371. return -1;
  372. }
  373. if (!soc->ops->ctrl_ops ||
  374. !soc->ops->ctrl_ops->txrx_get_vdev_param) {
  375. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  376. "%s: callback not registered:", __func__);
  377. return -1;
  378. }
  379. return soc->ops->ctrl_ops->txrx_get_vdev_param(vdev, type);
  380. }
  381. static inline void cdp_txrx_set_vdev_param(ol_txrx_soc_handle soc,
  382. struct cdp_vdev *vdev, enum cdp_vdev_param_type type,
  383. uint32_t val)
  384. {
  385. if (!soc || !soc->ops) {
  386. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  387. "%s: Invalid Instance:", __func__);
  388. QDF_BUG(0);
  389. return;
  390. }
  391. if (!soc->ops->ctrl_ops ||
  392. !soc->ops->ctrl_ops->txrx_set_vdev_param)
  393. return;
  394. soc->ops->ctrl_ops->txrx_set_vdev_param(vdev, type, val);
  395. }
  396. static inline void
  397. cdp_peer_set_nawds(ol_txrx_soc_handle soc,
  398. struct cdp_peer *peer, uint8_t value)
  399. {
  400. if (!soc || !soc->ops) {
  401. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  402. "%s: Invalid Instance:", __func__);
  403. QDF_BUG(0);
  404. return;
  405. }
  406. if (!soc->ops->ctrl_ops ||
  407. !soc->ops->ctrl_ops->txrx_peer_set_nawds)
  408. return;
  409. soc->ops->ctrl_ops->txrx_peer_set_nawds
  410. (peer, value);
  411. }
  412. /**
  413. * cdp_txrx_set_pdev_param() - set pdev parameter
  414. * @soc: opaque soc handle
  415. * @pdev: data path pdev handle
  416. * @type: param type
  417. * @val: value of pdev_tx_capture
  418. *
  419. * Return: status: 0 - Success, non-zero: Failure
  420. */
  421. static inline QDF_STATUS cdp_txrx_set_pdev_param(ol_txrx_soc_handle soc,
  422. struct cdp_pdev *pdev,
  423. enum cdp_pdev_param_type type,
  424. uint8_t val)
  425. {
  426. if (!soc || !soc->ops) {
  427. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  428. "%s: Invalid Instance:", __func__);
  429. QDF_BUG(0);
  430. return QDF_STATUS_SUCCESS;
  431. }
  432. if (!soc->ops->ctrl_ops ||
  433. !soc->ops->ctrl_ops->txrx_set_pdev_param)
  434. return QDF_STATUS_SUCCESS;
  435. return soc->ops->ctrl_ops->txrx_set_pdev_param
  436. (pdev, type, val);
  437. }
  438. /**
  439. * cdp_enable_peer_based_pktlog()- Set flag in peer structure
  440. *
  441. * @soc: pointer to the soc
  442. * @pdev: the data physical device object
  443. * @enable: enable or disable peer based filter based pktlog
  444. * @peer_macaddr: Mac address of peer which needs to be
  445. * filtered
  446. *
  447. * This function will set flag in peer structure if peer based filtering
  448. * is enabled for pktlog
  449. *
  450. * Return: int
  451. */
  452. static inline int
  453. cdp_enable_peer_based_pktlog(ol_txrx_soc_handle soc,
  454. struct cdp_pdev *pdev, char *peer_macaddr,
  455. uint8_t enable)
  456. {
  457. if (!soc || !soc->ops) {
  458. QDF_TRACE_ERROR(QDF_MODULE_ID_DP,
  459. "%s invalid instance", __func__);
  460. QDF_BUG(0);
  461. return 0;
  462. }
  463. if (!soc->ops->ctrl_ops ||
  464. !soc->ops->ctrl_ops->enable_peer_based_pktlog)
  465. return 0;
  466. return soc->ops->ctrl_ops->enable_peer_based_pktlog
  467. (pdev, peer_macaddr, enable);
  468. }
  469. /**
  470. * cdp_calculate_delay_stats()- get rx delay stats
  471. *
  472. * @soc: pointer to the soc
  473. * @vdev: vdev handle
  474. * @nbuf: nbuf which is passed
  475. *
  476. * This function will calculate rx delay statistics.
  477. */
  478. static inline void
  479. cdp_calculate_delay_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  480. qdf_nbuf_t nbuf)
  481. {
  482. if (!soc || !soc->ops) {
  483. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  484. "%s: Invalid Instance:", __func__);
  485. QDF_BUG(0);
  486. return;
  487. }
  488. if (!soc->ops->ctrl_ops ||
  489. !soc->ops->ctrl_ops->calculate_delay_stats) {
  490. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  491. "%s: callback not registered:", __func__);
  492. return;
  493. }
  494. return soc->ops->ctrl_ops->calculate_delay_stats(vdev, nbuf);
  495. }
  496. /**
  497. * @brief Subscribe to a specified WDI event.
  498. * @details
  499. * This function adds the provided wdi_event_subscribe object to a list of
  500. * subscribers for the specified WDI event.
  501. * When the event in question happens, each subscriber for the event will
  502. * have their callback function invoked.
  503. * The order in which callback functions from multiple subscribers are
  504. * invoked is unspecified.
  505. *
  506. * @param soc - pointer to the soc
  507. * @param pdev - the data physical device object
  508. * @param event_cb_sub - the callback and context for the event subscriber
  509. * @param event - which event's notifications are being subscribed to
  510. * @return - int
  511. */
  512. static inline int
  513. cdp_wdi_event_sub(ol_txrx_soc_handle soc,
  514. struct cdp_pdev *pdev, void *event_cb_sub, uint32_t event)
  515. {
  516. if (!soc || !soc->ops) {
  517. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  518. "%s invalid instance", __func__);
  519. QDF_BUG(0);
  520. return 0;
  521. }
  522. if (!soc->ops->ctrl_ops ||
  523. !soc->ops->ctrl_ops->txrx_wdi_event_sub)
  524. return 0;
  525. return soc->ops->ctrl_ops->txrx_wdi_event_sub
  526. (pdev, event_cb_sub, event);
  527. }
  528. /**
  529. * @brief Unsubscribe from a specified WDI event.
  530. * @details
  531. * This function removes the provided event subscription object from the
  532. * list of subscribers for its event.
  533. * This function shall only be called if there was a successful prior call
  534. * to event_sub() on the same wdi_event_subscribe object.
  535. *
  536. * @param soc - pointer to the soc
  537. * @param pdev - the data physical device object
  538. * @param event_cb_sub - the callback and context for the event subscriber
  539. * @param event - which event's notifications are being subscribed to
  540. * @return - int
  541. */
  542. static inline int
  543. cdp_wdi_event_unsub(ol_txrx_soc_handle soc,
  544. struct cdp_pdev *pdev, void *event_cb_sub, uint32_t event)
  545. {
  546. if (!soc || !soc->ops) {
  547. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  548. "%s invalid instance", __func__);
  549. QDF_BUG(0);
  550. return 0;
  551. }
  552. if (!soc->ops->ctrl_ops ||
  553. !soc->ops->ctrl_ops->txrx_wdi_event_unsub)
  554. return 0;
  555. return soc->ops->ctrl_ops->txrx_wdi_event_unsub
  556. (pdev, event_cb_sub, event);
  557. }
  558. /**
  559. * @brief Get security type from the from peer.
  560. * @details
  561. * This function gets the Security information from the peer handler.
  562. * The security information is got from the rx descriptor and filled in
  563. * to the peer handler.
  564. *
  565. * @param soc - pointer to the soc
  566. * @param peer - peer handler
  567. * @param sec_idx - mcast or ucast frame type.
  568. * @return - int
  569. */
  570. static inline int
  571. cdp_get_sec_type(ol_txrx_soc_handle soc, struct cdp_peer *peer, uint8_t sec_idx)
  572. {
  573. if (!soc || !soc->ops) {
  574. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  575. "%s invalid instance", __func__);
  576. QDF_BUG(0);
  577. return A_ERROR;
  578. }
  579. if (!soc->ops->ctrl_ops ||
  580. !soc->ops->ctrl_ops->txrx_get_sec_type)
  581. return A_ERROR;
  582. return soc->ops->ctrl_ops->txrx_get_sec_type
  583. (peer, sec_idx);
  584. }
  585. /**
  586. * cdp_set_mgmt_tx_power(): function to set tx power for mgmt frames
  587. * @vdev_handle: vdev handle
  588. * @subtype_index: subtype
  589. * @tx_power: Tx power
  590. * Return: None
  591. */
  592. static inline int cdp_set_mgmt_tx_power(ol_txrx_soc_handle soc,
  593. struct cdp_vdev *vdev, uint8_t subtype, uint8_t tx_power)
  594. {
  595. if (!soc || !soc->ops) {
  596. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  597. "%s: Invalid Instance:", __func__);
  598. QDF_BUG(0);
  599. return 0;
  600. }
  601. if (!soc->ops->ctrl_ops ||
  602. !soc->ops->ctrl_ops->txrx_update_mgmt_txpow_vdev)
  603. return 0;
  604. soc->ops->ctrl_ops->txrx_update_mgmt_txpow_vdev(vdev,
  605. subtype, tx_power);
  606. return 0;
  607. }
  608. static inline void *
  609. cdp_get_pldev(ol_txrx_soc_handle soc,
  610. struct cdp_pdev *pdev)
  611. {
  612. if (!soc || !soc->ops) {
  613. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  614. "%s invalid instance", __func__);
  615. QDF_BUG(0);
  616. return NULL;
  617. }
  618. if (!soc->ops->ctrl_ops || !soc->ops->ctrl_ops->txrx_get_pldev)
  619. return NULL;
  620. return soc->ops->ctrl_ops->txrx_get_pldev(pdev);
  621. }
  622. #ifdef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG
  623. /**
  624. * cdp_update_pdev_rx_protocol_tag() - wrapper function to set the protocol
  625. * tag in CDP layer from cfg layer
  626. * @soc: SOC TXRX handle
  627. * @pdev: CDP pdev pointer
  628. * @protocol_mask: Bitmap for protocol for which tagging is enabled
  629. * @protocol_type: Protocol type for which the tag should be update
  630. * @tag: Actual tag value for the given prototype
  631. * Return: Returns QDF_STATUS_SUCCESS/FAILURE
  632. */
  633. static inline QDF_STATUS
  634. cdp_update_pdev_rx_protocol_tag(ol_txrx_soc_handle soc,
  635. struct cdp_pdev *pdev, uint32_t protocol_mask,
  636. uint16_t protocol_type, uint16_t tag)
  637. {
  638. if (!soc || !soc->ops) {
  639. dp_err("Invalid SOC instance");
  640. QDF_BUG(0);
  641. return QDF_STATUS_E_FAILURE;
  642. }
  643. if (!soc->ops->ctrl_ops ||
  644. !soc->ops->ctrl_ops->txrx_update_pdev_rx_protocol_tag)
  645. return QDF_STATUS_E_FAILURE;
  646. return soc->ops->ctrl_ops->txrx_update_pdev_rx_protocol_tag
  647. (pdev, protocol_mask, protocol_type, tag);
  648. }
  649. #ifdef WLAN_SUPPORT_RX_TAG_STATISTICS
  650. /**
  651. * cdp_dump_pdev_rx_protocol_tag_stats() - wrapper function to dump the protocol
  652. tag statistics for given or all protocols
  653. * @soc: SOC TXRX handle
  654. * @pdev: CDP pdev pointer
  655. * @protocol_type: Protocol type for which the tag should be update
  656. * Return: Returns QDF_STATUS_SUCCESS/FAILURE
  657. */
  658. static inline QDF_STATUS
  659. cdp_dump_pdev_rx_protocol_tag_stats(ol_txrx_soc_handle soc,
  660. struct cdp_pdev *pdev,
  661. uint16_t protocol_type)
  662. {
  663. if (!soc || !soc->ops) {
  664. dp_err("Invalid SOC instance");
  665. QDF_BUG(0);
  666. return QDF_STATUS_E_FAILURE;
  667. }
  668. if (!soc->ops->ctrl_ops ||
  669. !soc->ops->ctrl_ops->txrx_dump_pdev_rx_protocol_tag_stats)
  670. return QDF_STATUS_E_FAILURE;
  671. soc->ops->ctrl_ops->txrx_dump_pdev_rx_protocol_tag_stats(pdev,
  672. protocol_type);
  673. return QDF_STATUS_SUCCESS;
  674. }
  675. #endif /* WLAN_SUPPORT_RX_TAG_STATISTICS */
  676. #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
  677. #ifdef ATH_SUPPORT_NAC_RSSI
  678. /**
  679. * cdp_vdev_config_for_nac_rssi(): To invoke dp callback for nac rssi config
  680. * @soc: soc pointer
  681. * @vdev: vdev pointer
  682. * @nac_cmd: specfies nac_rss config action add, del, list
  683. * @bssid: Neighbour bssid
  684. * @client_macaddr: Non-Associated client MAC
  685. * @chan_num: channel number to scan
  686. *
  687. * Return: QDF_STATUS
  688. */
  689. static inline QDF_STATUS cdp_vdev_config_for_nac_rssi(ol_txrx_soc_handle soc,
  690. struct cdp_vdev *vdev, enum cdp_nac_param_cmd nac_cmd,
  691. char *bssid, char *client_macaddr, uint8_t chan_num)
  692. {
  693. if (!soc || !soc->ops) {
  694. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  695. "%s invalid instance", __func__);
  696. QDF_BUG(0);
  697. return QDF_STATUS_E_FAILURE;
  698. }
  699. if (!soc->ops->ctrl_ops ||
  700. !soc->ops->ctrl_ops->txrx_vdev_config_for_nac_rssi)
  701. return QDF_STATUS_E_FAILURE;
  702. return soc->ops->ctrl_ops->txrx_vdev_config_for_nac_rssi(vdev,
  703. nac_cmd, bssid, client_macaddr, chan_num);
  704. }
  705. /*
  706. * cdp_vdev_get_neighbour_rssi(): To invoke dp callback to get rssi value of nac
  707. * @soc: soc pointer
  708. * @vdev: vdev pointer
  709. * @macaddr: Non-Associated client MAC
  710. * @rssi: rssi
  711. *
  712. * Return: QDF_STATUS
  713. */
  714. static inline QDF_STATUS cdp_vdev_get_neighbour_rssi(ol_txrx_soc_handle soc,
  715. struct cdp_vdev *vdev,
  716. char *macaddr,
  717. uint8_t *rssi)
  718. {
  719. if (!soc || !soc->ops) {
  720. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  721. "%s invalid instance", __func__);
  722. QDF_BUG(0);
  723. return QDF_STATUS_E_FAILURE;
  724. }
  725. if (!soc->ops->ctrl_ops ||
  726. !soc->ops->ctrl_ops->txrx_vdev_get_neighbour_rssi)
  727. return QDF_STATUS_E_FAILURE;
  728. return soc->ops->ctrl_ops->txrx_vdev_get_neighbour_rssi(vdev, macaddr,
  729. rssi);
  730. }
  731. #endif
  732. #endif