cdp_txrx_misc.h 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. /**
  20. * DOC: cdp_txrx_misc.h
  21. * Define the host data path miscellaneous API functions
  22. * called by the host control SW and the OS interface module
  23. */
  24. #ifndef _CDP_TXRX_MISC_H_
  25. #define _CDP_TXRX_MISC_H_
  26. #include "cdp_txrx_handle.h"
  27. #include <cdp_txrx_cmn.h>
  28. /**
  29. * cdp_tx_non_std() - Allow the control-path SW to send data frames
  30. * @soc: data path soc handle
  31. * @vdev_id: id of vdev
  32. * @tx_spec: what non-standard handling to apply to the tx data frames
  33. * @msdu_list: NULL-terminated list of tx MSDUs
  34. *
  35. * Generally, all tx data frames come from the OS shim into the txrx layer.
  36. * However, there are rare cases such as TDLS messaging where the UMAC
  37. * control-path SW creates tx data frames.
  38. * This UMAC SW can call this function to provide the tx data frames to
  39. * the txrx layer.
  40. * The UMAC SW can request a callback for these data frames after their
  41. * transmission completes, by using the ol_txrx_data_tx_cb_set function
  42. * to register a tx completion callback, and by specifying
  43. * ol_tx_spec_no_free as the tx_spec arg when giving the frames to
  44. * ol_tx_non_std.
  45. * The MSDUs need to have the appropriate L2 header type (802.3 vs. 802.11),
  46. * as specified by ol_cfg_frame_type().
  47. *
  48. * Return: null - success, skb - failure
  49. */
  50. static inline qdf_nbuf_t
  51. cdp_tx_non_std(ol_txrx_soc_handle soc, uint8_t vdev_id,
  52. enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list)
  53. {
  54. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  55. dp_cdp_debug("invalid instance");
  56. return NULL;
  57. }
  58. if (soc->ops->misc_ops->tx_non_std)
  59. return soc->ops->misc_ops->tx_non_std(soc, vdev_id, tx_spec,
  60. msdu_list);
  61. return NULL;
  62. }
  63. /**
  64. * cdp_set_ibss_vdev_heart_beat_timer() - Update ibss vdev heart
  65. * beat timer
  66. * @soc: data path soc handle
  67. * @vdev_id: id of vdev
  68. * @timer_value_sec: new heart beat timer value
  69. *
  70. * Return: Old timer value set in vdev.
  71. */
  72. static inline uint16_t
  73. cdp_set_ibss_vdev_heart_beat_timer(ol_txrx_soc_handle soc,
  74. uint8_t vdev_id, uint16_t timer_value_sec)
  75. {
  76. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  77. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  78. "%s invalid instance", __func__);
  79. return 0;
  80. }
  81. if (soc->ops->misc_ops->set_ibss_vdev_heart_beat_timer)
  82. return soc->ops->misc_ops->set_ibss_vdev_heart_beat_timer(
  83. soc, vdev_id, timer_value_sec);
  84. return 0;
  85. }
  86. /**
  87. * cdp_set_wisa_mode() - set wisa mode
  88. * @soc: data path soc handle
  89. * @vdev_id: vdev_id
  90. * @enable: enable or disable
  91. *
  92. * Return: QDF_STATUS_SUCCESS mode enable success
  93. */
  94. static inline QDF_STATUS
  95. cdp_set_wisa_mode(ol_txrx_soc_handle soc, uint8_t vdev_id, bool enable)
  96. {
  97. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  98. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  99. "%s invalid instance", __func__);
  100. return QDF_STATUS_E_INVAL;
  101. }
  102. if (soc->ops->misc_ops->set_wisa_mode)
  103. return soc->ops->misc_ops->set_wisa_mode(soc, vdev_id, enable);
  104. return QDF_STATUS_SUCCESS;
  105. }
  106. /**
  107. * cdp_data_stall_cb_register() - register data stall callback
  108. * @soc: data path soc handle
  109. * @pdev_id: id of data path pdev handle
  110. * @cb: callback function
  111. *
  112. * Return: QDF_STATUS_SUCCESS register success
  113. */
  114. static inline QDF_STATUS cdp_data_stall_cb_register(ol_txrx_soc_handle soc,
  115. uint8_t pdev_id,
  116. data_stall_detect_cb cb)
  117. {
  118. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  119. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  120. "%s invalid instance", __func__);
  121. return QDF_STATUS_E_INVAL;
  122. }
  123. if (soc->ops->misc_ops->txrx_data_stall_cb_register)
  124. return soc->ops->misc_ops->txrx_data_stall_cb_register(
  125. soc, pdev_id, cb);
  126. return QDF_STATUS_SUCCESS;
  127. }
  128. /**
  129. * cdp_data_stall_cb_deregister() - de-register data stall callback
  130. * @soc: data path soc handle
  131. * @pdev_id: id of data path pdev handle
  132. * @cb: callback function
  133. *
  134. * Return: QDF_STATUS_SUCCESS de-register success
  135. */
  136. static inline QDF_STATUS cdp_data_stall_cb_deregister(ol_txrx_soc_handle soc,
  137. uint8_t pdev_id,
  138. data_stall_detect_cb cb)
  139. {
  140. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  141. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  142. "%s invalid instance", __func__);
  143. return QDF_STATUS_E_INVAL;
  144. }
  145. if (soc->ops->misc_ops->txrx_data_stall_cb_deregister)
  146. return soc->ops->misc_ops->txrx_data_stall_cb_deregister(
  147. soc, pdev_id, cb);
  148. return QDF_STATUS_SUCCESS;
  149. }
  150. /**
  151. * cdp_post_data_stall_event() - post data stall event
  152. * @soc: data path soc handle
  153. * @indicator: Module triggering data stall
  154. * @data_stall_type: data stall event type
  155. * @pdev_id: pdev id
  156. * @vdev_id_bitmap: vdev id bitmap
  157. * @recovery_type: data stall recovery type
  158. *
  159. * Return: None
  160. */
  161. static inline void
  162. cdp_post_data_stall_event(ol_txrx_soc_handle soc,
  163. enum data_stall_log_event_indicator indicator,
  164. enum data_stall_log_event_type data_stall_type,
  165. uint32_t pdev_id, uint32_t vdev_id_bitmap,
  166. enum data_stall_log_recovery_type recovery_type)
  167. {
  168. if (!soc || !soc->ops) {
  169. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  170. "%s invalid instance", __func__);
  171. QDF_BUG(0);
  172. return;
  173. }
  174. if (!soc->ops->misc_ops ||
  175. !soc->ops->misc_ops->txrx_post_data_stall_event)
  176. return;
  177. soc->ops->misc_ops->txrx_post_data_stall_event(
  178. soc, indicator, data_stall_type, pdev_id,
  179. vdev_id_bitmap, recovery_type);
  180. }
  181. /**
  182. * cdp_set_wmm_param() - set wmm parameter
  183. * @soc: data path soc handle
  184. * @pdev_id: id of data path pdev handle
  185. * @wmm_param: wmm parameter
  186. *
  187. * Return: none
  188. */
  189. static inline void
  190. cdp_set_wmm_param(ol_txrx_soc_handle soc, uint8_t pdev_id,
  191. struct ol_tx_wmm_param_t wmm_param)
  192. {
  193. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  194. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  195. "%s invalid instance", __func__);
  196. return;
  197. }
  198. if (soc->ops->misc_ops->set_wmm_param)
  199. return soc->ops->misc_ops->set_wmm_param(soc, pdev_id,
  200. wmm_param);
  201. return;
  202. }
  203. /**
  204. * cdp_runtime_suspend() - suspend
  205. * @soc: data path soc handle
  206. * @pdev_id: id of data path pdev handle
  207. *
  208. * Return: QDF_STATUS_SUCCESS suspend success
  209. */
  210. static inline QDF_STATUS cdp_runtime_suspend(ol_txrx_soc_handle soc,
  211. uint8_t pdev_id)
  212. {
  213. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  214. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  215. "%s invalid instance", __func__);
  216. return QDF_STATUS_E_INVAL;
  217. }
  218. if (soc->ops->misc_ops->runtime_suspend)
  219. return soc->ops->misc_ops->runtime_suspend(soc, pdev_id);
  220. return QDF_STATUS_SUCCESS;
  221. }
  222. /**
  223. * cdp_runtime_resume() - resume
  224. * @soc: data path soc handle
  225. * @pdev_id: id of data path pdev handle
  226. *
  227. * Return: QDF_STATUS_SUCCESS suspend success
  228. */
  229. static inline QDF_STATUS cdp_runtime_resume(ol_txrx_soc_handle soc,
  230. uint8_t pdev_id)
  231. {
  232. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  233. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  234. "%s invalid instance", __func__);
  235. return QDF_STATUS_E_INVAL;
  236. }
  237. if (soc->ops->misc_ops->runtime_resume)
  238. return soc->ops->misc_ops->runtime_resume(soc, pdev_id);
  239. return QDF_STATUS_SUCCESS;
  240. }
  241. /**
  242. * cdp_hl_tdls_flag_reset() - tdls flag reset
  243. * @soc: data path soc handle
  244. * @vdev_id: id of vdev
  245. * @flag: flag indicating to set/reset tdls
  246. *
  247. * Return: none
  248. */
  249. static inline void
  250. cdp_hl_tdls_flag_reset(ol_txrx_soc_handle soc, uint8_t vdev_id, bool flag)
  251. {
  252. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  253. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  254. "%s invalid instance", __func__);
  255. return;
  256. }
  257. if (soc->ops->misc_ops->hl_tdls_flag_reset)
  258. return soc->ops->misc_ops->hl_tdls_flag_reset(soc, vdev_id,
  259. flag);
  260. return;
  261. }
  262. /**
  263. * cdp_get_opmode() - get vdev operation mode
  264. * @soc: data path soc handle
  265. * @vdev_id: id of vdev
  266. *
  267. * Return: virtual device operational mode
  268. * op_mode_ap,
  269. * op_mode_ibss,
  270. * op_mode_sta,
  271. * op_mode_monitor,
  272. * op_mode_ocb,
  273. * etc.
  274. */
  275. static inline int
  276. cdp_get_opmode(ol_txrx_soc_handle soc, uint8_t vdev_id)
  277. {
  278. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  279. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  280. "%s invalid instance", __func__);
  281. return 0;
  282. }
  283. if (soc->ops->misc_ops->get_opmode)
  284. return soc->ops->misc_ops->get_opmode(soc, vdev_id);
  285. return 0;
  286. }
  287. /**
  288. * cdp_get_vdev_id() - get vdev id
  289. * @soc: data path soc handle
  290. * @vdev: virtual interface instance
  291. *
  292. * get virtual interface id
  293. *
  294. * Return: interface id
  295. * 0 unknown interface
  296. */
  297. static inline uint16_t
  298. cdp_get_vdev_id(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  299. {
  300. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  301. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  302. "%s invalid instance", __func__);
  303. return 0;
  304. }
  305. if (soc->ops->misc_ops->get_vdev_id)
  306. return soc->ops->misc_ops->get_vdev_id(vdev);
  307. return 0;
  308. }
  309. /**
  310. * cdp_get_tx_ack_stats() - get tx ack count for vdev
  311. * @soc: data path soc handle
  312. * @vdev_id: vdev id
  313. *
  314. * Return: tx ack count
  315. * 0 invalid count
  316. */
  317. static inline uint32_t
  318. cdp_get_tx_ack_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
  319. {
  320. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  321. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  322. "%s invalid instance", __func__);
  323. return 0;
  324. }
  325. if (soc->ops->misc_ops->get_tx_ack_stats)
  326. return soc->ops->misc_ops->get_tx_ack_stats(soc, vdev_id);
  327. return 0;
  328. }
  329. /**
  330. * cdp_bad_peer_txctl_set_setting() - Set peer timer balance parameters
  331. * @soc: data path soc handle
  332. * @pdev_id: id of datapath pdev handle
  333. * @enable: enable/disable peer balance state
  334. * @period: balance timer period for peer
  335. * @txq_limit: txp limit for peer
  336. *
  337. * Return: none
  338. */
  339. static inline void
  340. cdp_bad_peer_txctl_set_setting(ol_txrx_soc_handle soc, uint8_t pdev_id,
  341. int enable, int period, int txq_limit)
  342. {
  343. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  344. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  345. "%s invalid instance", __func__);
  346. return;
  347. }
  348. if (soc->ops->misc_ops->bad_peer_txctl_set_setting)
  349. return soc->ops->misc_ops->bad_peer_txctl_set_setting(
  350. soc, pdev_id, enable, period,
  351. txq_limit);
  352. return;
  353. }
  354. /**
  355. * cdp_bad_peer_txctl_update_threshold() - TBD
  356. * @soc: data path soc handle
  357. * @pdev_id: id of data path pdev handle
  358. * @level: index of the threshold configuration
  359. * @tput_thresh: peer balance throughput threshold
  360. * @tx_limit: peer balance tx limit threshold
  361. *
  362. * TBD
  363. *
  364. * Return: none
  365. */
  366. static inline void
  367. cdp_bad_peer_txctl_update_threshold(ol_txrx_soc_handle soc,
  368. uint8_t pdev_id, int level,
  369. int tput_thresh, int tx_limit)
  370. {
  371. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  372. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  373. "%s invalid instance", __func__);
  374. return;
  375. }
  376. if (soc->ops->misc_ops->bad_peer_txctl_update_threshold)
  377. return soc->ops->misc_ops->bad_peer_txctl_update_threshold(
  378. soc, pdev_id, level, tput_thresh, tx_limit);
  379. return;
  380. }
  381. /**
  382. * cdp_mark_first_wakeup_packet() - set flag to indicate that
  383. * fw is compatible for marking first packet after wow wakeup
  384. * @soc: data path soc handle
  385. * @pdev_id: id of data path pdev handle
  386. * @value: 1 for enabled/ 0 for disabled
  387. *
  388. * Return: None
  389. */
  390. static inline void cdp_mark_first_wakeup_packet(ol_txrx_soc_handle soc,
  391. uint8_t pdev_id, uint8_t value)
  392. {
  393. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  394. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  395. "%s invalid instance", __func__);
  396. return;
  397. }
  398. if (soc->ops->misc_ops->mark_first_wakeup_packet)
  399. return soc->ops->misc_ops->mark_first_wakeup_packet(
  400. soc, pdev_id, value);
  401. return;
  402. }
  403. /**
  404. * cdp_update_mac_id() - update mac_id for vdev
  405. * @psoc: data path soc handle
  406. * @vdev_id: vdev id
  407. * @mac_id: mac id
  408. *
  409. * Return: none
  410. */
  411. static inline void cdp_update_mac_id(void *psoc, uint8_t vdev_id,
  412. uint8_t mac_id)
  413. {
  414. ol_txrx_soc_handle soc = psoc;
  415. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  416. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  417. "%s invalid instance", __func__);
  418. return;
  419. }
  420. if (soc->ops->misc_ops->update_mac_id)
  421. return soc->ops->misc_ops->update_mac_id(soc, vdev_id, mac_id);
  422. return;
  423. }
  424. /**
  425. * cdp_flush_rx_frames() - flush cached rx frames
  426. * @soc: data path soc handle
  427. * @pdev_id: datapath pdev identifier
  428. * @peer_mac: peer mac address
  429. * @drop: set flag to drop frames
  430. *
  431. * Return: None
  432. */
  433. static inline void cdp_flush_rx_frames(ol_txrx_soc_handle soc, uint8_t pdev_id,
  434. uint8_t *peer_mac, bool drop)
  435. {
  436. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  437. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  438. "%s invalid instance", __func__);
  439. return;
  440. }
  441. if (soc->ops->misc_ops->flush_rx_frames)
  442. return soc->ops->misc_ops->flush_rx_frames(soc, pdev_id,
  443. peer_mac, drop);
  444. return;
  445. }
  446. /**
  447. * cdp_get_intra_bss_fwd_pkts_count() - to get the total tx and rx packets
  448. * that has been forwarded from txrx layer without going to upper layers.
  449. * @soc: Datapath soc handle
  450. * @vdev_id: vdev id
  451. * @fwd_tx_packets: pointer to forwarded tx packets count parameter
  452. * @fwd_rx_packets: pointer to forwarded rx packets count parameter
  453. *
  454. * Return: status -> A_OK - success, A_ERROR - failure
  455. */
  456. static inline A_STATUS cdp_get_intra_bss_fwd_pkts_count(
  457. ol_txrx_soc_handle soc, uint8_t vdev_id,
  458. uint64_t *fwd_tx_packets, uint64_t *fwd_rx_packets)
  459. {
  460. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  461. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  462. "%s invalid instance", __func__);
  463. return 0;
  464. }
  465. if (soc->ops->misc_ops->get_intra_bss_fwd_pkts_count)
  466. return soc->ops->misc_ops->get_intra_bss_fwd_pkts_count(
  467. soc, vdev_id, fwd_tx_packets, fwd_rx_packets);
  468. return 0;
  469. }
  470. /**
  471. * cdp_pkt_log_init() - API to initialize packet log
  472. * @soc: data path soc handle
  473. * @pdev_id: id of data path pdev handle
  474. * @scn: HIF context
  475. *
  476. * Return: void
  477. */
  478. static inline void cdp_pkt_log_init(ol_txrx_soc_handle soc,
  479. uint8_t pdev_id, void *scn)
  480. {
  481. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  482. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  483. "%s invalid instance", __func__);
  484. return;
  485. }
  486. if (soc->ops->misc_ops->pkt_log_init)
  487. return soc->ops->misc_ops->pkt_log_init(soc, pdev_id, scn);
  488. return;
  489. }
  490. /**
  491. * cdp_pkt_log_con_service() - API to connect packet log service
  492. * @soc: data path soc handle
  493. * @pdev_id: id of data path pdev handle
  494. * @scn: HIF context
  495. *
  496. * Return: void
  497. */
  498. static inline void cdp_pkt_log_con_service(ol_txrx_soc_handle soc,
  499. uint8_t pdev_id, void *scn)
  500. {
  501. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  502. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  503. "%s invalid instance", __func__);
  504. return;
  505. }
  506. if (soc->ops->misc_ops->pkt_log_con_service)
  507. return soc->ops->misc_ops->pkt_log_con_service(
  508. soc, pdev_id, scn);
  509. return;
  510. }
  511. /**
  512. * cdp_pkt_log_exit() - API to cleanup packet log info
  513. * @soc: data path soc handle
  514. * @pdev_id: id of data path pdev handle
  515. *
  516. * Return: void
  517. */
  518. static inline void cdp_pkt_log_exit(ol_txrx_soc_handle soc, uint8_t pdev_id)
  519. {
  520. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  521. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  522. "%s invalid instance", __func__);
  523. return;
  524. }
  525. if (soc->ops->misc_ops->pkt_log_exit)
  526. return soc->ops->misc_ops->pkt_log_exit(soc, pdev_id);
  527. return;
  528. }
  529. /**
  530. * cdp_get_num_rx_contexts() - API to get the number of RX contexts
  531. * @soc: soc handle
  532. *
  533. * Return: number of RX contexts
  534. */
  535. static inline int cdp_get_num_rx_contexts(ol_txrx_soc_handle soc)
  536. {
  537. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  538. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  539. "%s invalid instance", __func__);
  540. return 0;
  541. }
  542. if (soc->ops->misc_ops->get_num_rx_contexts)
  543. return soc->ops->misc_ops->get_num_rx_contexts(soc);
  544. return 0;
  545. }
  546. /**
  547. * cdp_register_packetdump_cb() - API to register packetdump callback
  548. *
  549. * Register TX/RX callback for data packets, during connection. And per packet
  550. * stats will be passed to user-space by @tx_cb/@rx_cb.
  551. *
  552. * @soc: soc handle
  553. * @pdev_id: id of data path pdev handle
  554. * @tx_cb: tx packet callback
  555. * @rx_cb: rx packet callback
  556. *
  557. * Return: void
  558. */
  559. static inline void cdp_register_packetdump_cb(ol_txrx_soc_handle soc,
  560. uint8_t pdev_id,
  561. ol_txrx_pktdump_cb tx_cb,
  562. ol_txrx_pktdump_cb rx_cb)
  563. {
  564. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  565. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  566. "%s invalid instance", __func__);
  567. return;
  568. }
  569. if (soc->ops->misc_ops->register_pktdump_cb)
  570. return soc->ops->misc_ops->register_pktdump_cb(
  571. soc, pdev_id, tx_cb, rx_cb);
  572. }
  573. /**
  574. * cdp_deregister_packetdump_cb() - API to unregister packetdump callback
  575. *
  576. * Deregister callback for TX/RX data packets.
  577. *
  578. * @soc: soc handle
  579. * @pdev_id: id of data path pdev handle
  580. *
  581. * Return: void
  582. */
  583. static inline void cdp_deregister_packetdump_cb(ol_txrx_soc_handle soc,
  584. uint8_t pdev_id)
  585. {
  586. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  587. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  588. "%s invalid instance", __func__);
  589. return;
  590. }
  591. if (soc->ops->misc_ops->unregister_pktdump_cb)
  592. return soc->ops->misc_ops->unregister_pktdump_cb(soc, pdev_id);
  593. }
  594. typedef void (*rx_mic_error_callback)(struct cdp_ctrl_objmgr_psoc *psoc,
  595. uint8_t pdev_id,
  596. struct cdp_rx_mic_err_info *info);
  597. /**
  598. * cdp_register_rx_mic_error_ind_handler() - API to register mic error
  599. * indication handler
  600. *
  601. * @soc: soc handle
  602. * @rx_mic_cb: rx mic error indication callback
  603. *
  604. * Return: void
  605. */
  606. static inline void
  607. cdp_register_rx_mic_error_ind_handler(ol_txrx_soc_handle soc,
  608. rx_mic_error_callback rx_mic_cb)
  609. {
  610. if (!soc || !soc->ol_ops) {
  611. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  612. "%s invalid instance", __func__);
  613. return;
  614. }
  615. soc->ol_ops->rx_mic_error = rx_mic_cb;
  616. }
  617. typedef void (*rx_refill_thread_sched_cb)(ol_txrx_soc_handle soc);
  618. /**
  619. * cdp_register_rx_refill_thread_sched_handler() - API to register RX refill
  620. * thread schedule handler
  621. * @soc: soc handle
  622. * @rx_sched_cb: Rx refill thread scheduler callback function
  623. *
  624. * Return: void
  625. */
  626. static inline void
  627. cdp_register_rx_refill_thread_sched_handler(ol_txrx_soc_handle soc,
  628. rx_refill_thread_sched_cb rx_sched_cb)
  629. {
  630. if (!soc || !soc->ol_ops) {
  631. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  632. "%s invalid instance", __func__);
  633. return;
  634. }
  635. soc->ol_ops->dp_rx_sched_refill_thread = rx_sched_cb;
  636. }
  637. /**
  638. * cdp_pdev_reset_driver_del_ack() - reset driver TCP delayed ack flag
  639. * @psoc: data path soc handle
  640. * @pdev_id: pdev id
  641. *
  642. * Return: none
  643. */
  644. static inline void cdp_pdev_reset_driver_del_ack(void *psoc,
  645. uint8_t pdev_id)
  646. {
  647. ol_txrx_soc_handle soc = psoc;
  648. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  649. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  650. "%s invalid instance", __func__);
  651. return;
  652. }
  653. if (soc->ops->misc_ops->pdev_reset_driver_del_ack)
  654. return soc->ops->misc_ops->pdev_reset_driver_del_ack(soc,
  655. pdev_id);
  656. }
  657. /**
  658. * cdp_vdev_set_driver_del_ack_enable() - set driver delayed ack enabled flag
  659. * @soc: data path soc handle
  660. * @vdev_id: vdev id
  661. * @rx_packets: number of rx packets
  662. * @time_in_ms: time in ms
  663. * @high_th: high threshold
  664. * @low_th: low threshold
  665. *
  666. * Return: none
  667. */
  668. static inline void cdp_vdev_set_driver_del_ack_enable(ol_txrx_soc_handle soc,
  669. uint8_t vdev_id,
  670. unsigned long rx_packets,
  671. uint32_t time_in_ms,
  672. uint32_t high_th,
  673. uint32_t low_th)
  674. {
  675. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  676. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  677. "%s invalid instance", __func__);
  678. return;
  679. }
  680. if (soc->ops->misc_ops->vdev_set_driver_del_ack_enable)
  681. return soc->ops->misc_ops->vdev_set_driver_del_ack_enable(
  682. soc, vdev_id, rx_packets, time_in_ms, high_th, low_th);
  683. }
  684. static inline void cdp_vdev_set_bundle_require_flag(ol_txrx_soc_handle soc,
  685. uint8_t vdev_id,
  686. unsigned long tx_bytes,
  687. uint32_t time_in_ms,
  688. uint32_t high_th,
  689. uint32_t low_th)
  690. {
  691. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  692. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  693. "%s invalid instance", __func__);
  694. return;
  695. }
  696. if (soc->ops->misc_ops->vdev_set_bundle_require_flag)
  697. return soc->ops->misc_ops->vdev_set_bundle_require_flag(
  698. vdev_id, tx_bytes, time_in_ms, high_th, low_th);
  699. }
  700. static inline void cdp_pdev_reset_bundle_require_flag(ol_txrx_soc_handle soc,
  701. uint8_t pdev_id)
  702. {
  703. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  704. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  705. "%s invalid instance", __func__);
  706. return;
  707. }
  708. if (soc->ops->misc_ops->pdev_reset_bundle_require_flag)
  709. return soc->ops->misc_ops->pdev_reset_bundle_require_flag(
  710. soc, pdev_id);
  711. }
  712. /**
  713. * cdp_txrx_ext_stats_request() - request dp tx and rx extended stats
  714. * @soc: soc handle
  715. * @pdev_id: pdev id
  716. * @req: stats request structure to fill
  717. *
  718. * Return: QDF_STATUS
  719. */
  720. static inline QDF_STATUS
  721. cdp_txrx_ext_stats_request(ol_txrx_soc_handle soc, uint8_t pdev_id,
  722. struct cdp_txrx_ext_stats *req)
  723. {
  724. if (!soc || !soc->ops || !soc->ops->misc_ops || !req) {
  725. dp_cdp_debug("Invalid Instance:");
  726. return QDF_STATUS_E_INVAL;
  727. }
  728. if (soc->ops->misc_ops->txrx_ext_stats_request)
  729. return soc->ops->misc_ops->txrx_ext_stats_request(soc, pdev_id,
  730. req);
  731. return QDF_STATUS_SUCCESS;
  732. }
  733. /**
  734. * cdp_request_rx_hw_stats() - request rx hw stats
  735. * @soc: soc handle
  736. * @vdev_id: vdev id
  737. *
  738. * Return: QDF_STATUS
  739. */
  740. static inline QDF_STATUS
  741. cdp_request_rx_hw_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
  742. {
  743. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  744. dp_cdp_debug("Invalid Instance:");
  745. return QDF_STATUS_E_INVAL;
  746. }
  747. if (soc->ops->misc_ops->request_rx_hw_stats)
  748. return soc->ops->misc_ops->request_rx_hw_stats(soc, vdev_id);
  749. return QDF_STATUS_SUCCESS;
  750. }
  751. /**
  752. * cdp_reset_rx_hw_ext_stats() - reset rx hw ext stats
  753. * @soc: soc handle
  754. *
  755. * Return: none
  756. */
  757. static inline void
  758. cdp_reset_rx_hw_ext_stats(ol_txrx_soc_handle soc)
  759. {
  760. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  761. dp_cdp_debug("Invalid Instance");
  762. return;
  763. }
  764. if (soc->ops->misc_ops->reset_rx_hw_ext_stats)
  765. soc->ops->misc_ops->reset_rx_hw_ext_stats(soc);
  766. }
  767. /**
  768. * cdp_vdev_inform_ll_conn() - Inform DP about the low latency connection
  769. * @soc: soc handle
  770. * @vdev_id: vdev id
  771. * @action: Action to be performed (Add/Delete)
  772. *
  773. * Return: QDF_STATUS
  774. */
  775. static inline QDF_STATUS
  776. cdp_vdev_inform_ll_conn(ol_txrx_soc_handle soc, uint8_t vdev_id,
  777. enum vdev_ll_conn_actions action)
  778. {
  779. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  780. dp_cdp_debug("Invalid Instance:");
  781. return QDF_STATUS_E_INVAL;
  782. }
  783. if (soc->ops->misc_ops->vdev_inform_ll_conn)
  784. return soc->ops->misc_ops->vdev_inform_ll_conn(soc, vdev_id,
  785. action);
  786. return QDF_STATUS_SUCCESS;
  787. }
  788. /**
  789. * cdp_soc_set_swlm_enable() - Enable or disable software latency manager
  790. * @soc: soc handle
  791. * @value: value (enable/disable)
  792. *
  793. * Return: QDF_STATUS
  794. */
  795. static inline QDF_STATUS
  796. cdp_soc_set_swlm_enable(ol_txrx_soc_handle soc, uint8_t value)
  797. {
  798. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  799. dp_cdp_debug("Invalid Instance:");
  800. return QDF_STATUS_E_INVAL;
  801. }
  802. if (soc->ops->misc_ops->set_swlm_enable)
  803. return soc->ops->misc_ops->set_swlm_enable(soc, value);
  804. return QDF_STATUS_SUCCESS;
  805. }
  806. /**
  807. * cdp_soc_is_swlm_enabled() - Check if the software latency manager is
  808. * enabled or not
  809. * @soc: soc handle
  810. *
  811. * Return: 1 if enabled, 0 if disabled
  812. */
  813. static inline uint8_t
  814. cdp_soc_is_swlm_enabled(ol_txrx_soc_handle soc)
  815. {
  816. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  817. dp_cdp_debug("Invalid Instance:");
  818. return 0;
  819. }
  820. if (soc->ops->misc_ops->is_swlm_enabled)
  821. return soc->ops->misc_ops->is_swlm_enabled(soc);
  822. return 0;
  823. }
  824. /**
  825. * cdp_display_txrx_hw_info() - Dump the DP rings info
  826. * @soc: soc handle
  827. *
  828. * Return: none
  829. */
  830. static inline void
  831. cdp_display_txrx_hw_info(ol_txrx_soc_handle soc)
  832. {
  833. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  834. dp_cdp_debug("Invalid Instance:");
  835. return;
  836. }
  837. if (soc->ops->misc_ops->display_txrx_hw_info)
  838. return soc->ops->misc_ops->display_txrx_hw_info(soc);
  839. }
  840. /**
  841. * cdp_get_tx_rings_grp_bitmap() - Get tx rings grp bitmap
  842. * @soc: soc handle
  843. *
  844. * Return: tx rings bitmap
  845. */
  846. static inline uint32_t
  847. cdp_get_tx_rings_grp_bitmap(ol_txrx_soc_handle soc)
  848. {
  849. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  850. dp_cdp_debug("Invalid Instance:");
  851. return 0;
  852. }
  853. if (soc->ops->misc_ops->get_tx_rings_grp_bitmap)
  854. return soc->ops->misc_ops->get_tx_rings_grp_bitmap(soc);
  855. return 0;
  856. }
  857. #ifdef WLAN_FEATURE_PEER_TXQ_FLUSH_CONF
  858. /**
  859. * cdp_set_peer_txq_flush_config() - Set the peer txq flush configuration
  860. * @soc: Opaque handle to the DP soc object
  861. * @vdev_id: VDEV identifier
  862. * @mac: MAC address of the peer
  863. * @ac: access category mask
  864. * @tid: TID mask
  865. * @policy: Flush policy
  866. *
  867. * Return: 0 on success, errno on failure
  868. */
  869. static inline int
  870. cdp_set_peer_txq_flush_config(ol_txrx_soc_handle soc, uint8_t vdev_id,
  871. uint8_t *mac, uint8_t ac, uint32_t tid,
  872. enum cdp_peer_txq_flush_policy policy)
  873. {
  874. if (!soc || !soc->ops || !soc->ops->misc_ops || !mac) {
  875. dp_cdp_debug("Invalid parameters");
  876. return 0;
  877. }
  878. if (soc->ops->misc_ops->set_peer_txq_flush_config) {
  879. return soc->ops->misc_ops->set_peer_txq_flush_config(soc,
  880. vdev_id,
  881. mac, ac,
  882. tid,
  883. policy);
  884. }
  885. return 0;
  886. }
  887. #endif /* WLAN_FEATURE_PEER_TXQ_FLUSH_CONF */
  888. #ifdef FEATURE_RX_LINKSPEED_ROAM_TRIGGER
  889. /**
  890. * cdp_set_bus_vote_lvl_high() - have a vote on bus bandwidth lvl
  891. * @soc: datapath soc handle
  892. * @high: whether TPUT level is high or not
  893. *
  894. * Return: void
  895. */
  896. static inline void
  897. cdp_set_bus_vote_lvl_high(ol_txrx_soc_handle soc, bool high)
  898. {
  899. if (!soc || !soc->ops || !soc->ops->misc_ops ||
  900. !soc->ops->misc_ops->set_bus_vote_lvl_high) {
  901. dp_cdp_debug("Invalid Instance:");
  902. return;
  903. }
  904. soc->ops->misc_ops->set_bus_vote_lvl_high(soc, high);
  905. }
  906. /**
  907. * cdp_get_bus_lvl_high() - get high bus bandwidth lvl from dp
  908. * @soc: datapath soc handle
  909. *
  910. * Return: bool, whether TPUT level is high or not
  911. */
  912. static inline bool
  913. cdp_get_bus_lvl_high(ol_txrx_soc_handle soc)
  914. {
  915. if (!soc || !soc->ops || !soc->ops->misc_ops ||
  916. !soc->ops->misc_ops->get_bus_vote_lvl_high) {
  917. dp_cdp_debug("Invalid Instance:");
  918. return false;
  919. }
  920. return soc->ops->misc_ops->get_bus_vote_lvl_high(soc);
  921. }
  922. #else
  923. static inline void
  924. cdp_set_bus_vote_lvl_high(ol_txrx_soc_handle soc, bool high)
  925. {
  926. }
  927. static inline bool
  928. cdp_get_bus_lvl_high(ol_txrx_soc_handle soc)
  929. {
  930. /*
  931. * default bus lvl is high to
  932. * make sure not affect tput
  933. */
  934. return true;
  935. }
  936. #endif
  937. #ifdef DP_TX_PACKET_INSPECT_FOR_ILP
  938. /**
  939. * cdp_evaluate_update_tx_ilp_cfg() - Evaluate and update DP TX
  940. * ILP configuration
  941. * @soc: DP SOC handle
  942. * @num_msdu_idx_map: Number of HTT msdu index to qtype map in array
  943. * @msdu_idx_map_arr: Pointer to HTT msdu index to qtype map array
  944. *
  945. * Return: Final updated TX ILP enable result, true - enabled, false - not
  946. */
  947. static inline bool
  948. cdp_evaluate_update_tx_ilp_cfg(ol_txrx_soc_handle soc,
  949. uint8_t num_msdu_idx_map,
  950. uint8_t *msdu_idx_map_arr)
  951. {
  952. if (!soc || !soc->ops || !soc->ops->misc_ops ||
  953. !soc->ops->misc_ops->evaluate_update_tx_ilp_cfg) {
  954. dp_cdp_debug("Invalid Instance:");
  955. return false;
  956. }
  957. return soc->ops->misc_ops->evaluate_update_tx_ilp_cfg(
  958. soc, num_msdu_idx_map,
  959. msdu_idx_map_arr);
  960. }
  961. #endif /* DP_TX_PACKET_INSPECT_FOR_ILP */
  962. #endif /* _CDP_TXRX_MISC_H_ */