cdp_txrx_ctrl.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935
  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. #ifdef QCA_MULTIPASS_SUPPORT
  413. static inline void
  414. cdp_peer_set_vlan_id(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  415. uint8_t *peer_mac, uint8_t vlan_id)
  416. {
  417. if (!soc || !soc->ops) {
  418. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  419. "%s: Invalid Instance:", __func__);
  420. QDF_BUG(0);
  421. return;
  422. }
  423. if (!soc->ops->ctrl_ops ||
  424. !soc->ops->ctrl_ops->txrx_peer_set_vlan_id)
  425. return;
  426. soc->ops->ctrl_ops->txrx_peer_set_vlan_id(soc, vdev, peer_mac, vlan_id);
  427. }
  428. #endif
  429. /**
  430. * cdp_txrx_set_pdev_param() - set pdev parameter
  431. * @soc: opaque soc handle
  432. * @pdev: data path pdev handle
  433. * @type: param type
  434. * @val: value of pdev_tx_capture
  435. *
  436. * Return: status: 0 - Success, non-zero: Failure
  437. */
  438. static inline QDF_STATUS cdp_txrx_set_pdev_param(ol_txrx_soc_handle soc,
  439. struct cdp_pdev *pdev,
  440. enum cdp_pdev_param_type type,
  441. uint8_t val)
  442. {
  443. if (!soc || !soc->ops) {
  444. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  445. "%s: Invalid Instance:", __func__);
  446. QDF_BUG(0);
  447. return QDF_STATUS_SUCCESS;
  448. }
  449. if (!soc->ops->ctrl_ops ||
  450. !soc->ops->ctrl_ops->txrx_set_pdev_param)
  451. return QDF_STATUS_SUCCESS;
  452. return soc->ops->ctrl_ops->txrx_set_pdev_param
  453. (pdev, type, val);
  454. }
  455. /**
  456. * cdp_enable_peer_based_pktlog()- Set flag in peer structure
  457. *
  458. * @soc: pointer to the soc
  459. * @pdev: the data physical device object
  460. * @enable: enable or disable peer based filter based pktlog
  461. * @peer_macaddr: Mac address of peer which needs to be
  462. * filtered
  463. *
  464. * This function will set flag in peer structure if peer based filtering
  465. * is enabled for pktlog
  466. *
  467. * Return: int
  468. */
  469. static inline int
  470. cdp_enable_peer_based_pktlog(ol_txrx_soc_handle soc,
  471. struct cdp_pdev *pdev, char *peer_macaddr,
  472. uint8_t enable)
  473. {
  474. if (!soc || !soc->ops) {
  475. QDF_TRACE_ERROR(QDF_MODULE_ID_DP,
  476. "%s invalid instance", __func__);
  477. QDF_BUG(0);
  478. return 0;
  479. }
  480. if (!soc->ops->ctrl_ops ||
  481. !soc->ops->ctrl_ops->enable_peer_based_pktlog)
  482. return 0;
  483. return soc->ops->ctrl_ops->enable_peer_based_pktlog
  484. (pdev, peer_macaddr, enable);
  485. }
  486. /**
  487. * cdp_calculate_delay_stats()- get rx delay stats
  488. *
  489. * @soc: pointer to the soc
  490. * @vdev: vdev handle
  491. * @nbuf: nbuf which is passed
  492. *
  493. * This function will calculate rx delay statistics.
  494. */
  495. static inline void
  496. cdp_calculate_delay_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  497. qdf_nbuf_t nbuf)
  498. {
  499. if (!soc || !soc->ops) {
  500. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  501. "%s: Invalid Instance:", __func__);
  502. QDF_BUG(0);
  503. return;
  504. }
  505. if (!soc->ops->ctrl_ops ||
  506. !soc->ops->ctrl_ops->calculate_delay_stats) {
  507. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  508. "%s: callback not registered:", __func__);
  509. return;
  510. }
  511. return soc->ops->ctrl_ops->calculate_delay_stats(vdev, nbuf);
  512. }
  513. /**
  514. * @brief Subscribe to a specified WDI event.
  515. * @details
  516. * This function adds the provided wdi_event_subscribe object to a list of
  517. * subscribers for the specified WDI event.
  518. * When the event in question happens, each subscriber for the event will
  519. * have their callback function invoked.
  520. * The order in which callback functions from multiple subscribers are
  521. * invoked is unspecified.
  522. *
  523. * @param soc - pointer to the soc
  524. * @param pdev - the data physical device object
  525. * @param event_cb_sub - the callback and context for the event subscriber
  526. * @param event - which event's notifications are being subscribed to
  527. * @return - int
  528. */
  529. static inline int
  530. cdp_wdi_event_sub(ol_txrx_soc_handle soc,
  531. struct cdp_pdev *pdev, void *event_cb_sub, uint32_t event)
  532. {
  533. if (!soc || !soc->ops) {
  534. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  535. "%s invalid instance", __func__);
  536. QDF_BUG(0);
  537. return 0;
  538. }
  539. if (!soc->ops->ctrl_ops ||
  540. !soc->ops->ctrl_ops->txrx_wdi_event_sub)
  541. return 0;
  542. return soc->ops->ctrl_ops->txrx_wdi_event_sub
  543. (pdev, event_cb_sub, event);
  544. }
  545. /**
  546. * @brief Unsubscribe from a specified WDI event.
  547. * @details
  548. * This function removes the provided event subscription object from the
  549. * list of subscribers for its event.
  550. * This function shall only be called if there was a successful prior call
  551. * to event_sub() on the same wdi_event_subscribe object.
  552. *
  553. * @param soc - pointer to the soc
  554. * @param pdev - the data physical device object
  555. * @param event_cb_sub - the callback and context for the event subscriber
  556. * @param event - which event's notifications are being subscribed to
  557. * @return - int
  558. */
  559. static inline int
  560. cdp_wdi_event_unsub(ol_txrx_soc_handle soc,
  561. struct cdp_pdev *pdev, void *event_cb_sub, uint32_t event)
  562. {
  563. if (!soc || !soc->ops) {
  564. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  565. "%s invalid instance", __func__);
  566. QDF_BUG(0);
  567. return 0;
  568. }
  569. if (!soc->ops->ctrl_ops ||
  570. !soc->ops->ctrl_ops->txrx_wdi_event_unsub)
  571. return 0;
  572. return soc->ops->ctrl_ops->txrx_wdi_event_unsub
  573. (pdev, event_cb_sub, event);
  574. }
  575. /**
  576. * @brief Get security type from the from peer.
  577. * @details
  578. * This function gets the Security information from the peer handler.
  579. * The security information is got from the rx descriptor and filled in
  580. * to the peer handler.
  581. *
  582. * @param soc - pointer to the soc
  583. * @param peer - peer handler
  584. * @param sec_idx - mcast or ucast frame type.
  585. * @return - int
  586. */
  587. static inline int
  588. cdp_get_sec_type(ol_txrx_soc_handle soc, struct cdp_peer *peer, uint8_t sec_idx)
  589. {
  590. if (!soc || !soc->ops) {
  591. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  592. "%s invalid instance", __func__);
  593. QDF_BUG(0);
  594. return A_ERROR;
  595. }
  596. if (!soc->ops->ctrl_ops ||
  597. !soc->ops->ctrl_ops->txrx_get_sec_type)
  598. return A_ERROR;
  599. return soc->ops->ctrl_ops->txrx_get_sec_type
  600. (peer, sec_idx);
  601. }
  602. /**
  603. * cdp_set_mgmt_tx_power(): function to set tx power for mgmt frames
  604. * @vdev_handle: vdev handle
  605. * @subtype_index: subtype
  606. * @tx_power: Tx power
  607. * Return: None
  608. */
  609. static inline int cdp_set_mgmt_tx_power(ol_txrx_soc_handle soc,
  610. struct cdp_vdev *vdev, uint8_t subtype, uint8_t tx_power)
  611. {
  612. if (!soc || !soc->ops) {
  613. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  614. "%s: Invalid Instance:", __func__);
  615. QDF_BUG(0);
  616. return 0;
  617. }
  618. if (!soc->ops->ctrl_ops ||
  619. !soc->ops->ctrl_ops->txrx_update_mgmt_txpow_vdev)
  620. return 0;
  621. soc->ops->ctrl_ops->txrx_update_mgmt_txpow_vdev(vdev,
  622. subtype, tx_power);
  623. return 0;
  624. }
  625. static inline void *
  626. cdp_get_pldev(ol_txrx_soc_handle soc,
  627. struct cdp_pdev *pdev)
  628. {
  629. if (!soc || !soc->ops) {
  630. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  631. "%s invalid instance", __func__);
  632. QDF_BUG(0);
  633. return NULL;
  634. }
  635. if (!soc->ops->ctrl_ops || !soc->ops->ctrl_ops->txrx_get_pldev)
  636. return NULL;
  637. return soc->ops->ctrl_ops->txrx_get_pldev(pdev);
  638. }
  639. #if defined(WLAN_TX_PKT_CAPTURE_ENH) || defined(WLAN_RX_PKT_CAPTURE_ENH)
  640. /**
  641. * cdp_update_peer_pkt_capture_params() - Sets Rx & Tx Capture params for a peer
  642. * @soc: SOC TXRX handle
  643. * @pdev: CDP pdev pointer
  644. * @is_rx_pkt_cap_enable: enable/disable rx pkt capture for this peer
  645. * @is_tx_pkt_cap_enable: enable/disable tx pkt capture for this peer
  646. * @peer_mac: MAC address of peer for which pkt_cap is to be enabled/disabled
  647. *
  648. * Return: Success when matching peer is found & flags are set, error otherwise
  649. */
  650. static inline QDF_STATUS
  651. cdp_update_peer_pkt_capture_params(ol_txrx_soc_handle soc,
  652. struct cdp_pdev *pdev,
  653. bool is_rx_pkt_cap_enable,
  654. bool is_tx_pkt_cap_enable,
  655. uint8_t *peer_mac)
  656. {
  657. if (!soc || !soc->ops) {
  658. dp_err("Invalid SOC instance");
  659. QDF_BUG(0);
  660. return QDF_STATUS_E_FAILURE;
  661. }
  662. if (!soc->ops->ctrl_ops ||
  663. !soc->ops->ctrl_ops->txrx_update_peer_pkt_capture_params)
  664. return QDF_STATUS_E_FAILURE;
  665. return soc->ops->ctrl_ops->txrx_update_peer_pkt_capture_params
  666. (pdev, is_rx_pkt_cap_enable, is_tx_pkt_cap_enable,
  667. peer_mac);
  668. }
  669. #endif /* WLAN_TX_PKT_CAPTURE_ENH || WLAN_RX_PKT_CAPTURE_ENH */
  670. #ifdef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG
  671. /**
  672. * cdp_update_pdev_rx_protocol_tag() - wrapper function to set the protocol
  673. * tag in CDP layer from cfg layer
  674. * @soc: SOC TXRX handle
  675. * @pdev: CDP pdev pointer
  676. * @protocol_mask: Bitmap for protocol for which tagging is enabled
  677. * @protocol_type: Protocol type for which the tag should be update
  678. * @tag: Actual tag value for the given prototype
  679. * Return: Returns QDF_STATUS_SUCCESS/FAILURE
  680. */
  681. static inline QDF_STATUS
  682. cdp_update_pdev_rx_protocol_tag(ol_txrx_soc_handle soc,
  683. struct cdp_pdev *pdev, uint32_t protocol_mask,
  684. uint16_t protocol_type, uint16_t tag)
  685. {
  686. if (!soc || !soc->ops) {
  687. dp_err("Invalid SOC instance");
  688. QDF_BUG(0);
  689. return QDF_STATUS_E_FAILURE;
  690. }
  691. if (!soc->ops->ctrl_ops ||
  692. !soc->ops->ctrl_ops->txrx_update_pdev_rx_protocol_tag)
  693. return QDF_STATUS_E_FAILURE;
  694. return soc->ops->ctrl_ops->txrx_update_pdev_rx_protocol_tag
  695. (pdev, protocol_mask, protocol_type, tag);
  696. }
  697. #ifdef WLAN_SUPPORT_RX_TAG_STATISTICS
  698. /**
  699. * cdp_dump_pdev_rx_protocol_tag_stats() - wrapper function to dump the protocol
  700. tag statistics for given or all protocols
  701. * @soc: SOC TXRX handle
  702. * @pdev: CDP pdev pointer
  703. * @protocol_type: Protocol type for which the tag should be update
  704. * Return: Returns QDF_STATUS_SUCCESS/FAILURE
  705. */
  706. static inline QDF_STATUS
  707. cdp_dump_pdev_rx_protocol_tag_stats(ol_txrx_soc_handle soc,
  708. struct cdp_pdev *pdev,
  709. uint16_t protocol_type)
  710. {
  711. if (!soc || !soc->ops) {
  712. dp_err("Invalid SOC instance");
  713. QDF_BUG(0);
  714. return QDF_STATUS_E_FAILURE;
  715. }
  716. if (!soc->ops->ctrl_ops ||
  717. !soc->ops->ctrl_ops->txrx_dump_pdev_rx_protocol_tag_stats)
  718. return QDF_STATUS_E_FAILURE;
  719. soc->ops->ctrl_ops->txrx_dump_pdev_rx_protocol_tag_stats(pdev,
  720. protocol_type);
  721. return QDF_STATUS_SUCCESS;
  722. }
  723. #endif /* WLAN_SUPPORT_RX_TAG_STATISTICS */
  724. #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
  725. #ifdef ATH_SUPPORT_NAC_RSSI
  726. /**
  727. * cdp_vdev_config_for_nac_rssi(): To invoke dp callback for nac rssi config
  728. * @soc: soc pointer
  729. * @vdev: vdev pointer
  730. * @nac_cmd: specfies nac_rss config action add, del, list
  731. * @bssid: Neighbour bssid
  732. * @client_macaddr: Non-Associated client MAC
  733. * @chan_num: channel number to scan
  734. *
  735. * Return: QDF_STATUS
  736. */
  737. static inline QDF_STATUS cdp_vdev_config_for_nac_rssi(ol_txrx_soc_handle soc,
  738. struct cdp_vdev *vdev, enum cdp_nac_param_cmd nac_cmd,
  739. char *bssid, char *client_macaddr, uint8_t chan_num)
  740. {
  741. if (!soc || !soc->ops) {
  742. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  743. "%s invalid instance", __func__);
  744. QDF_BUG(0);
  745. return QDF_STATUS_E_FAILURE;
  746. }
  747. if (!soc->ops->ctrl_ops ||
  748. !soc->ops->ctrl_ops->txrx_vdev_config_for_nac_rssi)
  749. return QDF_STATUS_E_FAILURE;
  750. return soc->ops->ctrl_ops->txrx_vdev_config_for_nac_rssi(vdev,
  751. nac_cmd, bssid, client_macaddr, chan_num);
  752. }
  753. /*
  754. * cdp_vdev_get_neighbour_rssi(): To invoke dp callback to get rssi value of nac
  755. * @soc: soc pointer
  756. * @vdev: vdev pointer
  757. * @macaddr: Non-Associated client MAC
  758. * @rssi: rssi
  759. *
  760. * Return: QDF_STATUS
  761. */
  762. static inline QDF_STATUS cdp_vdev_get_neighbour_rssi(ol_txrx_soc_handle soc,
  763. struct cdp_vdev *vdev,
  764. char *macaddr,
  765. uint8_t *rssi)
  766. {
  767. if (!soc || !soc->ops) {
  768. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  769. "%s invalid instance", __func__);
  770. QDF_BUG(0);
  771. return QDF_STATUS_E_FAILURE;
  772. }
  773. if (!soc->ops->ctrl_ops ||
  774. !soc->ops->ctrl_ops->txrx_vdev_get_neighbour_rssi)
  775. return QDF_STATUS_E_FAILURE;
  776. return soc->ops->ctrl_ops->txrx_vdev_get_neighbour_rssi(vdev, macaddr,
  777. rssi);
  778. }
  779. #endif
  780. #ifdef WLAN_SUPPORT_RX_FLOW_TAG
  781. /**
  782. * cdp_set_rx_flow_tag() - wrapper function to set the flow
  783. * tag in CDP layer from cfg layer
  784. * @soc: SOC TXRX handle
  785. * @pdev: CDP pdev pointer
  786. * @flow_info: Flow 5-tuple, along with tag, if any, that needs to added/deleted
  787. *
  788. * Return: Success when add/del operation is successful, error otherwise
  789. */
  790. static inline QDF_STATUS
  791. cdp_set_rx_flow_tag(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  792. struct cdp_rx_flow_info *flow_info)
  793. {
  794. if (!soc || !soc->ops) {
  795. dp_err("Invalid SOC instance");
  796. QDF_BUG(0);
  797. return QDF_STATUS_E_FAILURE;
  798. }
  799. if (!soc->ops->ctrl_ops ||
  800. !soc->ops->ctrl_ops->txrx_set_rx_flow_tag)
  801. return QDF_STATUS_E_FAILURE;
  802. return soc->ops->ctrl_ops->txrx_set_rx_flow_tag(pdev, flow_info);
  803. }
  804. /**
  805. * cdp_dump_rx_flow_tag_stats() - wrapper function to dump the flow
  806. * tag statistics for given flow
  807. * @soc: SOC TXRX handle
  808. * @pdev: CDP pdev pointer
  809. * @flow_info: Flow tuple for which we want to print the statistics
  810. *
  811. * Return: Success when flow is found and stats are printed, error otherwise
  812. */
  813. static inline QDF_STATUS
  814. cdp_dump_rx_flow_tag_stats(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  815. struct cdp_rx_flow_info *flow_info)
  816. {
  817. if (!soc || !soc->ops) {
  818. dp_err("Invalid SOC instance");
  819. QDF_BUG(0);
  820. return QDF_STATUS_E_FAILURE;
  821. }
  822. if (!soc->ops->ctrl_ops ||
  823. !soc->ops->ctrl_ops->txrx_dump_rx_flow_tag_stats)
  824. return QDF_STATUS_E_FAILURE;
  825. return soc->ops->ctrl_ops->txrx_dump_rx_flow_tag_stats(pdev, flow_info);
  826. }
  827. #endif /* WLAN_SUPPORT_RX_FLOW_TAG */
  828. #endif /* _CDP_TXRX_CTRL_H_ */