cdp_txrx_ctrl.h 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108
  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_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)
  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(soc);
  42. }
  43. /* WIN */
  44. static inline int
  45. cdp_mempools_attach(ol_txrx_soc_handle soc)
  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(soc);
  57. }
  58. #if defined(ATH_SUPPORT_NAC) || defined(ATH_SUPPORT_NAC_RSSI)
  59. /**
  60. * @brief update the neighbour peer addresses
  61. * @details
  62. * This defines interface function to update neighbour peers addresses
  63. * which needs to be filtered
  64. *
  65. * @param soc - the pointer to soc object
  66. * @param vdev_id - id of the pointer to vdev
  67. * @param cmd - add/del entry into peer table
  68. * @param macaddr - the address of neighbour peer
  69. * @return - int
  70. */
  71. static inline int
  72. cdp_update_filter_neighbour_peers(ol_txrx_soc_handle soc,
  73. uint8_t vdev_id, uint32_t cmd, uint8_t *macaddr)
  74. {
  75. if (!soc || !soc->ops) {
  76. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  77. "%s: Invalid Instance:", __func__);
  78. QDF_BUG(0);
  79. return 0;
  80. }
  81. if (!soc->ops->ctrl_ops ||
  82. !soc->ops->ctrl_ops->txrx_update_filter_neighbour_peers)
  83. return 0;
  84. return soc->ops->ctrl_ops->txrx_update_filter_neighbour_peers
  85. (soc, vdev_id, cmd, macaddr);
  86. }
  87. #endif /* ATH_SUPPORT_NAC || ATH_SUPPORT_NAC_RSSI*/
  88. /**
  89. * @brief set the Reo Destination ring for the pdev
  90. * @details
  91. * This will be used to configure the Reo Destination ring for this pdev.
  92. *
  93. * @param soc - pointer to the soc
  94. * @param pdev_id - id of the data physical device object
  95. * @param val - the Reo destination ring index (1 to 4)
  96. * @return - QDF_STATUS
  97. */
  98. static inline QDF_STATUS
  99. cdp_set_pdev_reo_dest(ol_txrx_soc_handle soc,
  100. uint8_t pdev_id, enum cdp_host_reo_dest_ring val)
  101. {
  102. if (!soc || !soc->ops) {
  103. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  104. "%s: Invalid Instance:", __func__);
  105. QDF_BUG(0);
  106. return QDF_STATUS_E_FAILURE;
  107. }
  108. if (!soc->ops->ctrl_ops ||
  109. !soc->ops->ctrl_ops->txrx_set_pdev_reo_dest)
  110. return QDF_STATUS_E_FAILURE;
  111. return soc->ops->ctrl_ops->txrx_set_pdev_reo_dest
  112. (soc, pdev_id, val);
  113. }
  114. /**
  115. * @brief get the Reo Destination ring for the pdev
  116. *
  117. * @param soc - pointer to the soc
  118. * @param pdev_id - id of physical device object
  119. * @return - the Reo destination ring index (1 to 4), 0 if not supported.
  120. */
  121. static inline enum cdp_host_reo_dest_ring
  122. cdp_get_pdev_reo_dest(ol_txrx_soc_handle soc, uint8_t pdev_id)
  123. {
  124. if (!soc || !soc->ops) {
  125. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  126. "%s: Invalid Instance:", __func__);
  127. QDF_BUG(0);
  128. return cdp_host_reo_dest_ring_unknown;
  129. }
  130. if (!soc->ops->ctrl_ops ||
  131. !soc->ops->ctrl_ops->txrx_get_pdev_reo_dest)
  132. return cdp_host_reo_dest_ring_unknown;
  133. return soc->ops->ctrl_ops->txrx_get_pdev_reo_dest(soc, pdev_id);
  134. }
  135. /* Is this similar to ol_txrx_peer_state_update() in MCL */
  136. /**
  137. * @brief Update the authorize peer object at association time
  138. * @details
  139. * For the host-based implementation of rate-control, it
  140. * updates the peer/node-related parameters within rate-control
  141. * context of the peer at association.
  142. *
  143. * @param soc - pointer to the soc
  144. * @param vdev_id - id of the pointer to vdev
  145. * @param peer_mac - mac address of the node's object
  146. * @authorize - either to authorize or unauthorize peer
  147. *
  148. * @return QDF_STATUS
  149. */
  150. static inline QDF_STATUS
  151. cdp_peer_authorize(ol_txrx_soc_handle soc, uint8_t vdev_id, uint8_t *peer_mac,
  152. u_int32_t authorize)
  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 QDF_STATUS_E_FAILURE;
  159. }
  160. if (!soc->ops->ctrl_ops ||
  161. !soc->ops->ctrl_ops->txrx_peer_authorize)
  162. return QDF_STATUS_E_FAILURE;
  163. return soc->ops->ctrl_ops->txrx_peer_authorize
  164. (soc, vdev_id, peer_mac, authorize);
  165. }
  166. static inline void cdp_tx_flush_buffers
  167. (ol_txrx_soc_handle soc, uint8_t vdev_id)
  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->ctrl_ops ||
  176. !soc->ops->ctrl_ops->tx_flush_buffers)
  177. return;
  178. soc->ops->ctrl_ops->tx_flush_buffers(soc, vdev_id);
  179. }
  180. static inline QDF_STATUS cdp_txrx_get_vdev_param(ol_txrx_soc_handle soc,
  181. uint8_t vdev_id,
  182. enum cdp_vdev_param_type type,
  183. cdp_config_param_type *val)
  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 QDF_STATUS_E_FAILURE;
  190. }
  191. if (!soc->ops->ctrl_ops ||
  192. !soc->ops->ctrl_ops->txrx_get_vdev_param) {
  193. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  194. "%s: callback not registered:", __func__);
  195. return QDF_STATUS_E_FAILURE;
  196. }
  197. return soc->ops->ctrl_ops->txrx_get_vdev_param(soc, vdev_id,
  198. type, val);
  199. }
  200. static inline QDF_STATUS
  201. cdp_txrx_set_vdev_param(ol_txrx_soc_handle soc,
  202. uint8_t vdev_id, enum cdp_vdev_param_type type,
  203. cdp_config_param_type val)
  204. {
  205. if (!soc || !soc->ops) {
  206. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  207. "%s: Invalid Instance:", __func__);
  208. QDF_BUG(0);
  209. return QDF_STATUS_E_FAILURE;
  210. }
  211. if (!soc->ops->ctrl_ops ||
  212. !soc->ops->ctrl_ops->txrx_set_vdev_param)
  213. return QDF_STATUS_E_FAILURE;
  214. return soc->ops->ctrl_ops->txrx_set_vdev_param(soc, vdev_id,
  215. type, val);
  216. }
  217. static inline QDF_STATUS
  218. cdp_txrx_set_psoc_param(ol_txrx_soc_handle soc,
  219. enum cdp_psoc_param_type type,
  220. cdp_config_param_type val)
  221. {
  222. if (!soc || !soc->ops) {
  223. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  224. "%s: Invalid Instance:", __func__);
  225. QDF_BUG(0);
  226. return QDF_STATUS_E_FAILURE;
  227. }
  228. if (!soc->ops->ctrl_ops ||
  229. !soc->ops->ctrl_ops->txrx_set_psoc_param)
  230. return QDF_STATUS_E_FAILURE;
  231. return soc->ops->ctrl_ops->txrx_set_psoc_param(soc, type, val);
  232. }
  233. static inline QDF_STATUS
  234. cdp_txrx_get_psoc_param(ol_txrx_soc_handle soc,
  235. enum cdp_psoc_param_type type,
  236. cdp_config_param_type *val)
  237. {
  238. if (!soc || !soc->ops) {
  239. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  240. "%s: Invalid Instance:", __func__);
  241. QDF_BUG(0);
  242. return QDF_STATUS_E_FAILURE;
  243. }
  244. if (!soc->ops->ctrl_ops ||
  245. !soc->ops->ctrl_ops->txrx_get_psoc_param)
  246. return QDF_STATUS_E_FAILURE;
  247. return soc->ops->ctrl_ops->txrx_get_psoc_param(soc, type, val);
  248. }
  249. #ifdef VDEV_PEER_PROTOCOL_COUNT
  250. /**
  251. * cdp_set_vdev_peer_protocol_count() - set per-peer protocol count tracking
  252. *
  253. * @soc - pointer to the soc
  254. * @vdev - the data virtual device object
  255. * @enable - enable per-peer protocol count
  256. *
  257. * Set per-peer protocol count feature enable
  258. *
  259. * Return: void
  260. */
  261. static inline
  262. void cdp_set_vdev_peer_protocol_count(ol_txrx_soc_handle soc, int8_t vdev_id,
  263. bool enable)
  264. {
  265. if (!soc || !soc->ops) {
  266. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  267. "%s: Invalid Instance:", __func__);
  268. QDF_BUG(0);
  269. return;
  270. }
  271. if (!soc->ops->ctrl_ops ||
  272. !soc->ops->ctrl_ops->txrx_enable_peer_protocol_count)
  273. return;
  274. soc->ops->ctrl_ops->txrx_enable_peer_protocol_count(soc, vdev_id,
  275. enable);
  276. }
  277. /**
  278. * cdp_set_vdev_peer_protocol_drop_mask() - set per-peer protocol drop mask
  279. *
  280. * @soc - pointer to the soc
  281. * @vdev - the data virtual device object
  282. * @drop_mask - drop_mask
  283. *
  284. * Set per-peer protocol drop_mask
  285. *
  286. * Return - void
  287. */
  288. static inline
  289. void cdp_set_vdev_peer_protocol_drop_mask(ol_txrx_soc_handle soc,
  290. int8_t vdev_id, int drop_mask)
  291. {
  292. if (!soc || !soc->ops) {
  293. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  294. "%s: Invalid Instance:", __func__);
  295. QDF_BUG(0);
  296. return;
  297. }
  298. if (!soc->ops->ctrl_ops ||
  299. !soc->ops->ctrl_ops->txrx_set_peer_protocol_drop_mask)
  300. return;
  301. soc->ops->ctrl_ops->txrx_set_peer_protocol_drop_mask(soc, vdev_id,
  302. drop_mask);
  303. }
  304. /**
  305. * cdp_is_vdev_peer_protocol_count_enabled() - whether peer-protocol tracking
  306. * enabled
  307. *
  308. * @soc - pointer to the soc
  309. * @vdev - the data virtual device object
  310. *
  311. * Get whether peer protocol count feature enabled or not
  312. *
  313. * Return: whether feature enabled or not
  314. */
  315. static inline
  316. int cdp_is_vdev_peer_protocol_count_enabled(ol_txrx_soc_handle soc,
  317. int8_t vdev_id)
  318. {
  319. if (!soc || !soc->ops) {
  320. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  321. "%s: Invalid Instance:", __func__);
  322. QDF_BUG(0);
  323. return 0;
  324. }
  325. if (!soc->ops->ctrl_ops ||
  326. !soc->ops->ctrl_ops->txrx_is_peer_protocol_count_enabled)
  327. return 0;
  328. return soc->ops->ctrl_ops->txrx_is_peer_protocol_count_enabled(soc,
  329. vdev_id);
  330. }
  331. /**
  332. * cdp_get_peer_protocol_drop_mask() - get per-peer protocol count drop-mask
  333. *
  334. * @soc - pointer to the soc
  335. * @vdev - the data virtual device object
  336. *
  337. * Get peer-protocol-count drop-mask
  338. *
  339. * Return: peer-protocol-count drop-mask
  340. */
  341. static inline
  342. int cdp_get_peer_protocol_drop_mask(ol_txrx_soc_handle soc, int8_t vdev_id)
  343. {
  344. if (!soc || !soc->ops) {
  345. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  346. "%s: Invalid Instance:", __func__);
  347. QDF_BUG(0);
  348. return 0;
  349. }
  350. if (!soc->ops->ctrl_ops ||
  351. !soc->ops->ctrl_ops->txrx_get_peer_protocol_drop_mask)
  352. return 0;
  353. return soc->ops->ctrl_ops->txrx_get_peer_protocol_drop_mask(soc,
  354. vdev_id);
  355. }
  356. /*
  357. * Rx-Ingress and Tx-Egress are in the lower level DP layer
  358. * Rx-Egress and Tx-ingress are handled in osif layer for DP
  359. * So
  360. * Rx-Ingress and Tx-Egress definitions are in DP layer
  361. * Rx-Egress and Tx-ingress mask definitions are here below
  362. */
  363. #define VDEV_PEER_PROTOCOL_RX_INGRESS_MASK 1
  364. #define VDEV_PEER_PROTOCOL_TX_INGRESS_MASK 2
  365. #define VDEV_PEER_PROTOCOL_RX_EGRESS_MASK 4
  366. #define VDEV_PEER_PROTOCOL_TX_EGRESS_MASK 8
  367. #else
  368. #define cdp_set_vdev_peer_protocol_count(soc, vdev_id, enable)
  369. #define cdp_set_vdev_peer_protocol_drop_mask(soc, vdev_id, drop_mask)
  370. #define cdp_is_vdev_peer_protocol_count_enabled(soc, vdev_id) 0
  371. #define cdp_get_peer_protocol_drop_mask(soc, vdev_id) 0
  372. #endif
  373. /**
  374. * cdp_txrx_set_pdev_param() - set pdev parameter
  375. * @soc: opaque soc handle
  376. * @pdev_id: id of data path pdev handle
  377. * @type: param type
  378. * @val: value
  379. *
  380. * Return: status: 0 - Success, non-zero: Failure
  381. */
  382. static inline QDF_STATUS cdp_txrx_set_pdev_param(ol_txrx_soc_handle soc,
  383. uint8_t pdev_id,
  384. enum cdp_pdev_param_type type,
  385. cdp_config_param_type val)
  386. {
  387. if (!soc || !soc->ops) {
  388. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  389. "%s: Invalid Instance:", __func__);
  390. QDF_BUG(0);
  391. return QDF_STATUS_E_FAILURE;
  392. }
  393. if (!soc->ops->ctrl_ops ||
  394. !soc->ops->ctrl_ops->txrx_set_pdev_param)
  395. return QDF_STATUS_E_FAILURE;
  396. return soc->ops->ctrl_ops->txrx_set_pdev_param
  397. (soc, pdev_id, type, val);
  398. }
  399. /**
  400. * cdp_txrx_set_peer_param() - set pdev parameter
  401. * @soc: opaque soc handle
  402. * @vdev_id: id of data path vdev handle
  403. * @peer_mac: peer mac address
  404. * @type: param type
  405. * @val: value
  406. *
  407. * Return: status: 0 - Success, non-zero: Failure
  408. */
  409. static inline QDF_STATUS cdp_txrx_set_peer_param(ol_txrx_soc_handle soc,
  410. uint8_t vdev_id,
  411. uint8_t *peer_mac,
  412. enum cdp_peer_param_type type,
  413. cdp_config_param_type val)
  414. {
  415. if (!soc || !soc->ops) {
  416. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  417. "%s: Invalid Instance:", __func__);
  418. QDF_BUG(0);
  419. return QDF_STATUS_E_FAILURE;
  420. }
  421. if (!soc->ops->ctrl_ops ||
  422. !soc->ops->ctrl_ops->txrx_set_peer_param)
  423. return QDF_STATUS_E_FAILURE;
  424. return soc->ops->ctrl_ops->txrx_set_peer_param
  425. (soc, vdev_id, peer_mac, type, val);
  426. }
  427. /**
  428. * cdp_txrx_get_peer_param() - set pdev parameter
  429. * @soc: opaque soc handle
  430. * @vdev_id: id of data path vdev handle
  431. * @peer_mac: peer mac address
  432. * @type: param type
  433. * @val: address of buffer
  434. *
  435. * Return: status
  436. */
  437. static inline QDF_STATUS cdp_txrx_get_peer_param(ol_txrx_soc_handle soc,
  438. uint8_t vdev_id,
  439. uint8_t *peer_mac,
  440. enum cdp_peer_param_type type,
  441. cdp_config_param_type *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_E_FAILURE;
  448. }
  449. if (!soc->ops->ctrl_ops ||
  450. !soc->ops->ctrl_ops->txrx_get_peer_param)
  451. return QDF_STATUS_E_FAILURE;
  452. return soc->ops->ctrl_ops->txrx_get_peer_param
  453. (soc, vdev_id, peer_mac, type, val);
  454. }
  455. #ifdef QCA_MULTIPASS_SUPPORT
  456. static inline void
  457. cdp_peer_set_vlan_id(ol_txrx_soc_handle soc, uint8_t vdev_id,
  458. uint8_t *peer_mac, uint8_t vlan_id)
  459. {
  460. if (!soc || !soc->ops) {
  461. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  462. "%s: Invalid Instance:", __func__);
  463. QDF_BUG(0);
  464. return;
  465. }
  466. if (!soc->ops->ctrl_ops ||
  467. !soc->ops->ctrl_ops->txrx_peer_set_vlan_id)
  468. return;
  469. soc->ops->ctrl_ops->txrx_peer_set_vlan_id(soc, vdev_id, peer_mac,
  470. vlan_id);
  471. }
  472. #endif
  473. /**
  474. * cdp_txrx_get_pdev_param() - get pdev parameter
  475. * @soc: opaque soc handle
  476. * @pdev_id: id of data path pdev handle
  477. * @type: param type
  478. * @value: address of value buffer
  479. *
  480. * Return: status
  481. */
  482. static inline QDF_STATUS cdp_txrx_get_pdev_param(ol_txrx_soc_handle soc,
  483. uint8_t pdev_id,
  484. enum cdp_pdev_param_type type,
  485. cdp_config_param_type *value)
  486. {
  487. if (!soc || !soc->ops) {
  488. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  489. "%s: Invalid Instance:", __func__);
  490. QDF_BUG(0);
  491. return QDF_STATUS_E_FAILURE;
  492. }
  493. if (!soc->ops->ctrl_ops ||
  494. !soc->ops->ctrl_ops->txrx_get_pdev_param)
  495. return QDF_STATUS_E_FAILURE;
  496. return soc->ops->ctrl_ops->txrx_get_pdev_param
  497. (soc, pdev_id, type, value);
  498. }
  499. /**
  500. * cdp_txrx_peer_protocol_cnt() - set peer protocol count
  501. * @soc: opaque soc handle
  502. * @vdev: opaque vdev handle
  503. * @nbuf: data packet
  504. * @is_egress: whether egress or ingress
  505. * @is_rx: whether tx or rx
  506. *
  507. * Return: void
  508. */
  509. #ifdef VDEV_PEER_PROTOCOL_COUNT
  510. static inline void
  511. cdp_txrx_peer_protocol_cnt(ol_txrx_soc_handle soc,
  512. int8_t vdev_id,
  513. qdf_nbuf_t nbuf,
  514. enum vdev_peer_protocol_enter_exit is_egress,
  515. enum vdev_peer_protocol_tx_rx is_rx)
  516. {
  517. if (!soc || !soc->ops) {
  518. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  519. "%s: Invalid Instance:", __func__);
  520. QDF_BUG(0);
  521. return;
  522. }
  523. if (!soc->ops->ctrl_ops ||
  524. !soc->ops->ctrl_ops->txrx_peer_protocol_cnt)
  525. return;
  526. soc->ops->ctrl_ops->txrx_peer_protocol_cnt(soc, vdev_id, nbuf,
  527. is_egress, is_rx);
  528. }
  529. #else
  530. #define cdp_txrx_peer_protocol_cnt(soc, vdev_id, nbuf, is_egress, is_rx)
  531. #endif
  532. /**
  533. * cdp_enable_peer_based_pktlog()- Set flag in peer structure
  534. *
  535. * @soc: pointer to the soc
  536. * @pdev_id: id of the data physical device object
  537. * @enable: enable or disable peer based filter based pktlog
  538. * @peer_macaddr: Mac address of peer which needs to be
  539. * filtered
  540. *
  541. * This function will set flag in peer structure if peer based filtering
  542. * is enabled for pktlog
  543. *
  544. * Return: int
  545. */
  546. static inline int
  547. cdp_enable_peer_based_pktlog(ol_txrx_soc_handle soc, uint8_t pdev_id,
  548. char *peer_macaddr,
  549. uint8_t enable)
  550. {
  551. if (!soc || !soc->ops) {
  552. QDF_TRACE_ERROR(QDF_MODULE_ID_DP,
  553. "%s invalid instance", __func__);
  554. QDF_BUG(0);
  555. return 0;
  556. }
  557. if (!soc->ops->ctrl_ops ||
  558. !soc->ops->ctrl_ops->enable_peer_based_pktlog)
  559. return 0;
  560. return soc->ops->ctrl_ops->enable_peer_based_pktlog
  561. (soc, pdev_id, peer_macaddr, enable);
  562. }
  563. /**
  564. * cdp_calculate_delay_stats()- get rx delay stats
  565. *
  566. * @soc: pointer to the soc
  567. * @vdev_id: id of vdev handle
  568. * @nbuf: nbuf which is passed
  569. *
  570. * This function will calculate rx delay statistics.
  571. */
  572. static inline QDF_STATUS
  573. cdp_calculate_delay_stats(ol_txrx_soc_handle soc, uint8_t vdev_id,
  574. qdf_nbuf_t nbuf)
  575. {
  576. if (!soc || !soc->ops) {
  577. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  578. "%s: Invalid Instance:", __func__);
  579. QDF_BUG(0);
  580. return QDF_STATUS_E_FAILURE;
  581. }
  582. if (!soc->ops->ctrl_ops ||
  583. !soc->ops->ctrl_ops->calculate_delay_stats) {
  584. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  585. "%s: callback not registered:", __func__);
  586. return QDF_STATUS_E_FAILURE;
  587. }
  588. return soc->ops->ctrl_ops->calculate_delay_stats(soc, vdev_id, nbuf);
  589. }
  590. /**
  591. * @brief Subscribe to a specified WDI event.
  592. * @details
  593. * This function adds the provided wdi_event_subscribe object to a list of
  594. * subscribers for the specified WDI event.
  595. * When the event in question happens, each subscriber for the event will
  596. * have their callback function invoked.
  597. * The order in which callback functions from multiple subscribers are
  598. * invoked is unspecified.
  599. *
  600. * @param soc - pointer to the soc
  601. * @param pdev_id - id of the data physical device object
  602. * @param event_cb_sub - the callback and context for the event subscriber
  603. * @param event - which event's notifications are being subscribed to
  604. * @return - int
  605. */
  606. static inline int
  607. cdp_wdi_event_sub(ol_txrx_soc_handle soc, uint8_t pdev_id,
  608. wdi_event_subscribe *event_cb_sub, uint32_t event)
  609. {
  610. if (!soc || !soc->ops) {
  611. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  612. "%s invalid instance", __func__);
  613. QDF_BUG(0);
  614. return 0;
  615. }
  616. if (!soc->ops->ctrl_ops ||
  617. !soc->ops->ctrl_ops->txrx_wdi_event_sub)
  618. return 0;
  619. return soc->ops->ctrl_ops->txrx_wdi_event_sub
  620. (soc, pdev_id, event_cb_sub, event);
  621. }
  622. /**
  623. * @brief Unsubscribe from a specified WDI event.
  624. * @details
  625. * This function removes the provided event subscription object from the
  626. * list of subscribers for its event.
  627. * This function shall only be called if there was a successful prior call
  628. * to event_sub() on the same wdi_event_subscribe object.
  629. *
  630. * @param soc - pointer to the soc
  631. * @param pdev_id - id of the data physical device object
  632. * @param event_cb_sub - the callback and context for the event subscriber
  633. * @param event - which event's notifications are being subscribed to
  634. * @return - int
  635. */
  636. static inline int
  637. cdp_wdi_event_unsub(ol_txrx_soc_handle soc,
  638. uint8_t pdev_id, wdi_event_subscribe *event_cb_sub,
  639. uint32_t event)
  640. {
  641. if (!soc || !soc->ops) {
  642. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  643. "%s invalid instance", __func__);
  644. QDF_BUG(0);
  645. return 0;
  646. }
  647. if (!soc->ops->ctrl_ops ||
  648. !soc->ops->ctrl_ops->txrx_wdi_event_unsub)
  649. return 0;
  650. return soc->ops->ctrl_ops->txrx_wdi_event_unsub
  651. (soc, pdev_id, event_cb_sub, event);
  652. }
  653. /**
  654. * @brief Get security type from the from peer.
  655. * @details
  656. * This function gets the Security information from the peer handler.
  657. * The security information is got from the rx descriptor and filled in
  658. * to the peer handler.
  659. *
  660. * @param soc - pointer to the soc
  661. * @param vdev_id - id of vdev handle
  662. * @param peer mac - peer mac address
  663. * @param sec_idx - mcast or ucast frame type.
  664. * @return - int
  665. */
  666. static inline int
  667. cdp_get_sec_type(ol_txrx_soc_handle soc, uint8_t vdev_id, uint8_t *peer_mac,
  668. uint8_t sec_idx)
  669. {
  670. if (!soc || !soc->ops) {
  671. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  672. "%s invalid instance", __func__);
  673. QDF_BUG(0);
  674. return A_ERROR;
  675. }
  676. if (!soc->ops->ctrl_ops ||
  677. !soc->ops->ctrl_ops->txrx_get_sec_type)
  678. return A_ERROR;
  679. return soc->ops->ctrl_ops->txrx_get_sec_type
  680. (soc, vdev_id, peer_mac, sec_idx);
  681. }
  682. /**
  683. * cdp_set_mgmt_tx_power(): function to set tx power for mgmt frames
  684. * @param soc - pointer to the soc
  685. * @vdev_id : id of vdev handle
  686. * @subtype_index: subtype
  687. * @tx_power: Tx power
  688. * Return: QDF_STATUS
  689. */
  690. static inline QDF_STATUS
  691. cdp_set_mgmt_tx_power(ol_txrx_soc_handle soc,
  692. uint8_t vdev_id, uint8_t subtype, uint8_t tx_power)
  693. {
  694. if (!soc || !soc->ops) {
  695. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  696. "%s: Invalid Instance:", __func__);
  697. QDF_BUG(0);
  698. return QDF_STATUS_E_FAILURE;
  699. }
  700. if (!soc->ops->ctrl_ops ||
  701. !soc->ops->ctrl_ops->txrx_update_mgmt_txpow_vdev)
  702. return QDF_STATUS_E_FAILURE;
  703. return soc->ops->ctrl_ops->txrx_update_mgmt_txpow_vdev(soc, vdev_id,
  704. subtype, tx_power);
  705. }
  706. /**
  707. * cdp_get_pldev() - function to get pktlog device handle
  708. * @soc: datapath soc handle
  709. * @pdev_id: physical device id
  710. *
  711. * Return: pktlog device handle or NULL
  712. */
  713. static inline void *
  714. cdp_get_pldev(ol_txrx_soc_handle soc, uint8_t pdev_id)
  715. {
  716. if (!soc || !soc->ops) {
  717. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  718. "%s invalid instance", __func__);
  719. QDF_BUG(0);
  720. return NULL;
  721. }
  722. if (!soc->ops->ctrl_ops || !soc->ops->ctrl_ops->txrx_get_pldev)
  723. return NULL;
  724. return soc->ops->ctrl_ops->txrx_get_pldev(soc, pdev_id);
  725. }
  726. #if defined(WLAN_CFR_ENABLE) && defined(WLAN_ENH_CFR_ENABLE)
  727. /**
  728. * cdp_cfr_filter() - Configure Host RX monitor status ring for CFR
  729. * @soc: SOC TXRX handle
  730. * @pdev_id: ID of the physical device object
  731. * @enable: Enable or disable CFR
  732. * @filter_val: Flag to select filter for monitor mode
  733. */
  734. static inline void
  735. cdp_cfr_filter(ol_txrx_soc_handle soc,
  736. uint8_t pdev_id,
  737. bool enable,
  738. struct cdp_monitor_filter *filter_val)
  739. {
  740. if (!soc || !soc->ops) {
  741. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  742. "%s invalid instance", __func__);
  743. QDF_BUG(0);
  744. return;
  745. }
  746. if (!soc->ops->cfr_ops || !soc->ops->cfr_ops->txrx_cfr_filter)
  747. return;
  748. soc->ops->cfr_ops->txrx_cfr_filter(soc, pdev_id, enable, filter_val);
  749. }
  750. /**
  751. * cdp_get_cfr_rcc() - get cfr rcc config
  752. * @soc: Datapath soc handle
  753. * @pdev_id: id of objmgr pdev
  754. *
  755. * Return: true/false based on cfr mode setting
  756. */
  757. static inline
  758. bool cdp_get_cfr_rcc(ol_txrx_soc_handle soc, uint8_t pdev_id)
  759. {
  760. if (!soc || !soc->ops) {
  761. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  762. "%s invalid instance", __func__);
  763. QDF_BUG(0);
  764. return 0;
  765. }
  766. if (!soc->ops->cfr_ops || !soc->ops->cfr_ops->txrx_get_cfr_rcc)
  767. return 0;
  768. return soc->ops->cfr_ops->txrx_get_cfr_rcc(soc, pdev_id);
  769. }
  770. /**
  771. * cdp_set_cfr_rcc() - enable/disable cfr rcc config
  772. * @soc: Datapath soc handle
  773. * @pdev_id: id of objmgr pdev
  774. * @enable: Enable/Disable cfr rcc mode
  775. *
  776. * Return: none
  777. */
  778. static inline
  779. void cdp_set_cfr_rcc(ol_txrx_soc_handle soc, uint8_t pdev_id, bool enable)
  780. {
  781. if (!soc || !soc->ops) {
  782. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  783. "%s invalid instance", __func__);
  784. QDF_BUG(0);
  785. return;
  786. }
  787. if (!soc->ops->cfr_ops || !soc->ops->cfr_ops->txrx_set_cfr_rcc)
  788. return;
  789. return soc->ops->cfr_ops->txrx_set_cfr_rcc(soc, pdev_id, enable);
  790. }
  791. #endif
  792. #if defined(WLAN_TX_PKT_CAPTURE_ENH) || defined(WLAN_RX_PKT_CAPTURE_ENH)
  793. /**
  794. * cdp_update_peer_pkt_capture_params() - Sets Rx & Tx Capture params for a peer
  795. * @soc: SOC TXRX handle
  796. * @pdev_id: id of CDP pdev pointer
  797. * @is_rx_pkt_cap_enable: enable/disable rx pkt capture for this peer
  798. * @is_tx_pkt_cap_enable: enable/disable tx pkt capture for this peer
  799. * @peer_mac: MAC address of peer for which pkt_cap is to be enabled/disabled
  800. *
  801. * Return: Success when matching peer is found & flags are set, error otherwise
  802. */
  803. static inline QDF_STATUS
  804. cdp_update_peer_pkt_capture_params(ol_txrx_soc_handle soc,
  805. uint8_t pdev_id,
  806. bool is_rx_pkt_cap_enable,
  807. bool is_tx_pkt_cap_enable,
  808. uint8_t *peer_mac)
  809. {
  810. if (!soc || !soc->ops) {
  811. dp_err("Invalid SOC instance");
  812. QDF_BUG(0);
  813. return QDF_STATUS_E_FAILURE;
  814. }
  815. if (!soc->ops->ctrl_ops ||
  816. !soc->ops->ctrl_ops->txrx_update_peer_pkt_capture_params)
  817. return QDF_STATUS_E_FAILURE;
  818. return soc->ops->ctrl_ops->txrx_update_peer_pkt_capture_params
  819. (soc, pdev_id, is_rx_pkt_cap_enable,
  820. is_tx_pkt_cap_enable,
  821. peer_mac);
  822. }
  823. #endif /* WLAN_TX_PKT_CAPTURE_ENH || WLAN_RX_PKT_CAPTURE_ENH */
  824. #ifdef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG
  825. /**
  826. * cdp_update_pdev_rx_protocol_tag() - wrapper function to set the protocol
  827. * tag in CDP layer from cfg layer
  828. * @soc: SOC TXRX handle
  829. * @pdev_id: id of CDP pdev pointer
  830. * @protocol_mask: Bitmap for protocol for which tagging is enabled
  831. * @protocol_type: Protocol type for which the tag should be update
  832. * @tag: Actual tag value for the given prototype
  833. * Return: Returns QDF_STATUS_SUCCESS/FAILURE
  834. */
  835. static inline QDF_STATUS
  836. cdp_update_pdev_rx_protocol_tag(ol_txrx_soc_handle soc,
  837. uint8_t pdev_id, uint32_t protocol_mask,
  838. uint16_t protocol_type, uint16_t tag)
  839. {
  840. if (!soc || !soc->ops) {
  841. dp_err("Invalid SOC instance");
  842. QDF_BUG(0);
  843. return QDF_STATUS_E_FAILURE;
  844. }
  845. if (!soc->ops->ctrl_ops ||
  846. !soc->ops->ctrl_ops->txrx_update_pdev_rx_protocol_tag)
  847. return QDF_STATUS_E_FAILURE;
  848. return soc->ops->ctrl_ops->txrx_update_pdev_rx_protocol_tag
  849. (soc, pdev_id, protocol_mask, protocol_type, tag);
  850. }
  851. #ifdef WLAN_SUPPORT_RX_TAG_STATISTICS
  852. /**
  853. * cdp_dump_pdev_rx_protocol_tag_stats() - wrapper function to dump the protocol
  854. tag statistics for given or all protocols
  855. * @soc: SOC TXRX handle
  856. * @pdev_id: id of CDP pdev pointer
  857. * @protocol_type: Protocol type for which the tag should be update
  858. * Return: Returns QDF_STATUS_SUCCESS/FAILURE
  859. */
  860. static inline QDF_STATUS
  861. cdp_dump_pdev_rx_protocol_tag_stats(ol_txrx_soc_handle soc,
  862. uint8_t pdev_id,
  863. uint16_t protocol_type)
  864. {
  865. if (!soc || !soc->ops) {
  866. dp_err("Invalid SOC instance");
  867. QDF_BUG(0);
  868. return QDF_STATUS_E_FAILURE;
  869. }
  870. if (!soc->ops->ctrl_ops ||
  871. !soc->ops->ctrl_ops->txrx_dump_pdev_rx_protocol_tag_stats)
  872. return QDF_STATUS_E_FAILURE;
  873. soc->ops->ctrl_ops->txrx_dump_pdev_rx_protocol_tag_stats(soc, pdev_id,
  874. protocol_type);
  875. return QDF_STATUS_SUCCESS;
  876. }
  877. #endif /* WLAN_SUPPORT_RX_TAG_STATISTICS */
  878. #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
  879. #ifdef ATH_SUPPORT_NAC_RSSI
  880. /**
  881. * cdp_vdev_config_for_nac_rssi(): To invoke dp callback for nac rssi config
  882. * @soc: soc pointer
  883. * @vdev_id: id of vdev
  884. * @nac_cmd: specfies nac_rss config action add, del, list
  885. * @bssid: Neighbour bssid
  886. * @client_macaddr: Non-Associated client MAC
  887. * @chan_num: channel number to scan
  888. *
  889. * Return: QDF_STATUS
  890. */
  891. static inline QDF_STATUS cdp_vdev_config_for_nac_rssi(ol_txrx_soc_handle soc,
  892. uint8_t vdev_id, enum cdp_nac_param_cmd nac_cmd,
  893. char *bssid, char *client_macaddr, uint8_t chan_num)
  894. {
  895. if (!soc || !soc->ops) {
  896. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  897. "%s invalid instance", __func__);
  898. QDF_BUG(0);
  899. return QDF_STATUS_E_FAILURE;
  900. }
  901. if (!soc->ops->ctrl_ops ||
  902. !soc->ops->ctrl_ops->txrx_vdev_config_for_nac_rssi)
  903. return QDF_STATUS_E_FAILURE;
  904. return soc->ops->ctrl_ops->txrx_vdev_config_for_nac_rssi(soc, vdev_id,
  905. nac_cmd, bssid, client_macaddr, chan_num);
  906. }
  907. /*
  908. * cdp_vdev_get_neighbour_rssi(): To invoke dp callback to get rssi value of nac
  909. * @soc: soc pointer
  910. * @vdev_id: id of vdev
  911. * @macaddr: Non-Associated client MAC
  912. * @rssi: rssi
  913. *
  914. * Return: QDF_STATUS
  915. */
  916. static inline QDF_STATUS cdp_vdev_get_neighbour_rssi(ol_txrx_soc_handle soc,
  917. uint8_t vdev_id,
  918. char *macaddr,
  919. uint8_t *rssi)
  920. {
  921. if (!soc || !soc->ops) {
  922. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  923. "%s invalid instance", __func__);
  924. QDF_BUG(0);
  925. return QDF_STATUS_E_FAILURE;
  926. }
  927. if (!soc->ops->ctrl_ops ||
  928. !soc->ops->ctrl_ops->txrx_vdev_get_neighbour_rssi)
  929. return QDF_STATUS_E_FAILURE;
  930. return soc->ops->ctrl_ops->txrx_vdev_get_neighbour_rssi(soc, vdev_id,
  931. macaddr,
  932. rssi);
  933. }
  934. #endif
  935. #ifdef WLAN_SUPPORT_RX_FLOW_TAG
  936. /**
  937. * cdp_set_rx_flow_tag() - wrapper function to set the flow
  938. * tag in CDP layer from cfg layer
  939. * @soc: SOC TXRX handle
  940. * @pdev_id: id of CDP pdev pointer
  941. * @flow_info: Flow 5-tuple, along with tag, if any, that needs to added/deleted
  942. *
  943. * Return: Success when add/del operation is successful, error otherwise
  944. */
  945. static inline QDF_STATUS
  946. cdp_set_rx_flow_tag(ol_txrx_soc_handle soc, uint8_t pdev_id,
  947. struct cdp_rx_flow_info *flow_info)
  948. {
  949. if (!soc || !soc->ops) {
  950. dp_err("Invalid SOC instance");
  951. QDF_BUG(0);
  952. return QDF_STATUS_E_FAILURE;
  953. }
  954. if (!soc->ops->ctrl_ops ||
  955. !soc->ops->ctrl_ops->txrx_set_rx_flow_tag)
  956. return QDF_STATUS_E_FAILURE;
  957. return soc->ops->ctrl_ops->txrx_set_rx_flow_tag(soc, pdev_id,
  958. flow_info);
  959. }
  960. /**
  961. * cdp_dump_rx_flow_tag_stats() - wrapper function to dump the flow
  962. * tag statistics for given flow
  963. * @soc: SOC TXRX handle
  964. * @pdev_id: id of CDP pdev
  965. * @flow_info: Flow tuple for which we want to print the statistics
  966. *
  967. * Return: Success when flow is found and stats are printed, error otherwise
  968. */
  969. static inline QDF_STATUS
  970. cdp_dump_rx_flow_tag_stats(ol_txrx_soc_handle soc, uint8_t pdev_id,
  971. struct cdp_rx_flow_info *flow_info)
  972. {
  973. if (!soc || !soc->ops) {
  974. dp_err("Invalid SOC instance");
  975. QDF_BUG(0);
  976. return QDF_STATUS_E_FAILURE;
  977. }
  978. if (!soc->ops->ctrl_ops ||
  979. !soc->ops->ctrl_ops->txrx_dump_rx_flow_tag_stats)
  980. return QDF_STATUS_E_FAILURE;
  981. return soc->ops->ctrl_ops->txrx_dump_rx_flow_tag_stats(soc,
  982. pdev_id,
  983. flow_info);
  984. }
  985. #endif /* WLAN_SUPPORT_RX_FLOW_TAG */
  986. #endif /* _CDP_TXRX_CTRL_H_ */