cdp_txrx_misc.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2022 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. * @file cdp_txrx_misc.h
  21. * @brief 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. *
  274. * return interface id
  275. * 0 unknown interface
  276. */
  277. static inline int
  278. cdp_get_opmode(ol_txrx_soc_handle soc, uint8_t vdev_id)
  279. {
  280. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  281. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  282. "%s invalid instance", __func__);
  283. return 0;
  284. }
  285. if (soc->ops->misc_ops->get_opmode)
  286. return soc->ops->misc_ops->get_opmode(soc, vdev_id);
  287. return 0;
  288. }
  289. /**
  290. * cdp_get_vdev_id() - get vdev id
  291. * @soc - data path soc handle
  292. * @vdev - virtual interface instance
  293. *
  294. * get virtual interface id
  295. *
  296. * return interface id
  297. * 0 unknown interface
  298. */
  299. static inline uint16_t
  300. cdp_get_vdev_id(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  301. {
  302. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  303. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  304. "%s invalid instance", __func__);
  305. return 0;
  306. }
  307. if (soc->ops->misc_ops->get_vdev_id)
  308. return soc->ops->misc_ops->get_vdev_id(vdev);
  309. return 0;
  310. }
  311. /**
  312. * cdp_get_tx_ack_stats() - get tx ack count for vdev
  313. * @soc - data path soc handle
  314. * @vdev_id - vdev id
  315. *
  316. * return tx ack count
  317. * 0 invalid count
  318. */
  319. static inline uint32_t
  320. cdp_get_tx_ack_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
  321. {
  322. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  323. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  324. "%s invalid instance", __func__);
  325. return 0;
  326. }
  327. if (soc->ops->misc_ops->get_tx_ack_stats)
  328. return soc->ops->misc_ops->get_tx_ack_stats(soc, vdev_id);
  329. return 0;
  330. }
  331. /**
  332. * cdp_bad_peer_txctl_set_setting() - Set peer timer balance parameters
  333. * @soc: data path soc handle
  334. * @pdev_id: id of datapath pdev handle
  335. * @enable: enable/disable peer balance state
  336. * @period: balance timer period for peer
  337. * @txq_limit: txp limit for peer
  338. *
  339. * Return: none
  340. */
  341. static inline void
  342. cdp_bad_peer_txctl_set_setting(ol_txrx_soc_handle soc, uint8_t pdev_id,
  343. int enable, int period, int txq_limit)
  344. {
  345. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  346. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  347. "%s invalid instance", __func__);
  348. return;
  349. }
  350. if (soc->ops->misc_ops->bad_peer_txctl_set_setting)
  351. return soc->ops->misc_ops->bad_peer_txctl_set_setting(
  352. soc, pdev_id, enable, period,
  353. txq_limit);
  354. return;
  355. }
  356. /**
  357. * cdp_bad_peer_txctl_update_threshold() - TBD
  358. * @soc: data path soc handle
  359. * @pdev_id: id of data path pdev handle
  360. * @level: index of the threshold configuration
  361. * @tput_thresh: peer balance throughput threshold
  362. * @tx_limit: peer balance tx limit threshold
  363. *
  364. * TBD
  365. *
  366. * Return: none
  367. */
  368. static inline void
  369. cdp_bad_peer_txctl_update_threshold(ol_txrx_soc_handle soc,
  370. uint8_t pdev_id, int level,
  371. int tput_thresh, int tx_limit)
  372. {
  373. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  374. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  375. "%s invalid instance", __func__);
  376. return;
  377. }
  378. if (soc->ops->misc_ops->bad_peer_txctl_update_threshold)
  379. return soc->ops->misc_ops->bad_peer_txctl_update_threshold(
  380. soc, pdev_id, level, tput_thresh, tx_limit);
  381. return;
  382. }
  383. /**
  384. * cdp_mark_first_wakeup_packet() - set flag to indicate that
  385. * fw is compatible for marking first packet after wow wakeup
  386. * @soc: data path soc handle
  387. * @pdev_id: id of data path pdev handle
  388. * @value: 1 for enabled/ 0 for disabled
  389. *
  390. * Return: None
  391. */
  392. static inline void cdp_mark_first_wakeup_packet(ol_txrx_soc_handle soc,
  393. uint8_t pdev_id, uint8_t value)
  394. {
  395. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  396. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  397. "%s invalid instance", __func__);
  398. return;
  399. }
  400. if (soc->ops->misc_ops->mark_first_wakeup_packet)
  401. return soc->ops->misc_ops->mark_first_wakeup_packet(
  402. soc, pdev_id, value);
  403. return;
  404. }
  405. /**
  406. * cds_update_mac_id() - update mac_id for vdev
  407. * @psoc: data path soc handle
  408. * @vdev_id: vdev id
  409. * @mac_id: mac id
  410. *
  411. * Return: none
  412. */
  413. static inline void cdp_update_mac_id(void *psoc, uint8_t vdev_id,
  414. uint8_t mac_id)
  415. {
  416. ol_txrx_soc_handle soc = psoc;
  417. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  418. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  419. "%s invalid instance", __func__);
  420. return;
  421. }
  422. if (soc->ops->misc_ops->update_mac_id)
  423. return soc->ops->misc_ops->update_mac_id(soc, vdev_id, mac_id);
  424. return;
  425. }
  426. /**
  427. * cdp_flush_rx_frames() - flush cached rx frames
  428. * @soc: data path soc handle
  429. * @pdev_id: datapath pdev identifier
  430. * @peer_mac: peer mac address
  431. * @drop: set flag to drop frames
  432. *
  433. * Return: None
  434. */
  435. static inline void cdp_flush_rx_frames(ol_txrx_soc_handle soc, uint8_t pdev_id,
  436. uint8_t *peer_mac, bool drop)
  437. {
  438. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  439. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  440. "%s invalid instance", __func__);
  441. return;
  442. }
  443. if (soc->ops->misc_ops->flush_rx_frames)
  444. return soc->ops->misc_ops->flush_rx_frames(soc, pdev_id,
  445. peer_mac, drop);
  446. return;
  447. }
  448. /*
  449. * cdp_get_intra_bss_fwd_pkts_count() - to get the total tx and rx packets
  450. * that has been forwarded from txrx layer without going to upper layers.
  451. * @soc: Datapath soc handle
  452. * @vdev_id: vdev id
  453. * @fwd_tx_packets: pointer to forwarded tx packets count parameter
  454. * @fwd_rx_packets: pointer to forwarded rx packets count parameter
  455. *
  456. * Return: status -> A_OK - success, A_ERROR - failure
  457. */
  458. static inline A_STATUS cdp_get_intra_bss_fwd_pkts_count(
  459. ol_txrx_soc_handle soc, uint8_t vdev_id,
  460. uint64_t *fwd_tx_packets, uint64_t *fwd_rx_packets)
  461. {
  462. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  463. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  464. "%s invalid instance", __func__);
  465. return 0;
  466. }
  467. if (soc->ops->misc_ops->get_intra_bss_fwd_pkts_count)
  468. return soc->ops->misc_ops->get_intra_bss_fwd_pkts_count(
  469. soc, vdev_id, fwd_tx_packets, fwd_rx_packets);
  470. return 0;
  471. }
  472. /**
  473. * cdp_pkt_log_init() - API to initialize packet log
  474. * @soc: data path soc handle
  475. * @pdev_id: id of data path pdev handle
  476. * @scn: HIF context
  477. *
  478. * Return: void
  479. */
  480. static inline void cdp_pkt_log_init(ol_txrx_soc_handle soc,
  481. uint8_t pdev_id, void *scn)
  482. {
  483. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  484. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  485. "%s invalid instance", __func__);
  486. return;
  487. }
  488. if (soc->ops->misc_ops->pkt_log_init)
  489. return soc->ops->misc_ops->pkt_log_init(soc, pdev_id, scn);
  490. return;
  491. }
  492. /**
  493. * cdp_pkt_log_con_service() - API to connect packet log service
  494. * @soc: data path soc handle
  495. * @pdev_id: id of data path pdev handle
  496. * @scn: HIF context
  497. *
  498. * Return: void
  499. */
  500. static inline void cdp_pkt_log_con_service(ol_txrx_soc_handle soc,
  501. uint8_t pdev_id, void *scn)
  502. {
  503. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  504. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  505. "%s invalid instance", __func__);
  506. return;
  507. }
  508. if (soc->ops->misc_ops->pkt_log_con_service)
  509. return soc->ops->misc_ops->pkt_log_con_service(
  510. soc, pdev_id, scn);
  511. return;
  512. }
  513. /**
  514. * cdp_pkt_log_exit() - API to cleanup packet log info
  515. * @soc: data path soc handle
  516. * @pdev_id: id of data path pdev handle
  517. *
  518. * Return: void
  519. */
  520. static inline void cdp_pkt_log_exit(ol_txrx_soc_handle soc, uint8_t pdev_id)
  521. {
  522. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  523. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  524. "%s invalid instance", __func__);
  525. return;
  526. }
  527. if (soc->ops->misc_ops->pkt_log_exit)
  528. return soc->ops->misc_ops->pkt_log_exit(soc, pdev_id);
  529. return;
  530. }
  531. /**
  532. * cdp_get_num_rx_contexts() - API to get the number of RX contexts
  533. * @soc: soc handle
  534. *
  535. * Return: number of RX contexts
  536. */
  537. static inline int cdp_get_num_rx_contexts(ol_txrx_soc_handle soc)
  538. {
  539. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  540. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  541. "%s invalid instance", __func__);
  542. return 0;
  543. }
  544. if (soc->ops->misc_ops->get_num_rx_contexts)
  545. return soc->ops->misc_ops->get_num_rx_contexts(soc);
  546. return 0;
  547. }
  548. /**
  549. * cdp_register_packetdump_cb() - API to register packetdump callback
  550. *
  551. * Register TX/RX callback for data packets, during connection. And per packet
  552. * stats will be passed to user-space by @tx_cb/@rx_cb.
  553. *
  554. * @soc: soc handle
  555. * @pdev_id: id of data path pdev handle
  556. * @tx_cb: tx packet callback
  557. * @rx_cb: rx packet callback
  558. *
  559. * Return: void
  560. */
  561. static inline void cdp_register_packetdump_cb(ol_txrx_soc_handle soc,
  562. uint8_t pdev_id,
  563. ol_txrx_pktdump_cb tx_cb,
  564. ol_txrx_pktdump_cb rx_cb)
  565. {
  566. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  567. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  568. "%s invalid instance", __func__);
  569. return;
  570. }
  571. if (soc->ops->misc_ops->register_pktdump_cb)
  572. return soc->ops->misc_ops->register_pktdump_cb(
  573. soc, pdev_id, tx_cb, rx_cb);
  574. }
  575. /**
  576. * cdp_deregister_packetdump_cb() - API to unregister packetdump callback
  577. *
  578. * Deregister callback for TX/RX data packets.
  579. *
  580. * @soc: soc handle
  581. * @pdev_id: id of data path pdev handle
  582. *
  583. * Return: void
  584. */
  585. static inline void cdp_deregister_packetdump_cb(ol_txrx_soc_handle soc,
  586. uint8_t pdev_id)
  587. {
  588. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  589. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  590. "%s invalid instance", __func__);
  591. return;
  592. }
  593. if (soc->ops->misc_ops->unregister_pktdump_cb)
  594. return soc->ops->misc_ops->unregister_pktdump_cb(soc, pdev_id);
  595. }
  596. typedef void (*rx_mic_error_callback)(struct cdp_ctrl_objmgr_psoc *psoc,
  597. uint8_t pdev_id,
  598. struct cdp_rx_mic_err_info *info);
  599. /**
  600. * cdp_register_rx_mic_error_ind_handler() - API to register mic error
  601. * indication handler
  602. *
  603. * @soc: soc handle
  604. * @rx_mic_cb: rx mic error indication callback
  605. *
  606. * Return: void
  607. */
  608. static inline void
  609. cdp_register_rx_mic_error_ind_handler(ol_txrx_soc_handle soc,
  610. rx_mic_error_callback rx_mic_cb)
  611. {
  612. if (!soc || !soc->ol_ops) {
  613. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  614. "%s invalid instance", __func__);
  615. return;
  616. }
  617. soc->ol_ops->rx_mic_error = rx_mic_cb;
  618. }
  619. typedef void (*rx_refill_thread_sched_cb)(ol_txrx_soc_handle soc);
  620. /**
  621. * cdp_register_rx_refill_thread_sched_handler() - API to register RX refill
  622. * thread schedule handler
  623. *
  624. * @soc: soc handle
  625. *
  626. * Return: void
  627. */
  628. static inline void
  629. cdp_register_rx_refill_thread_sched_handler(ol_txrx_soc_handle soc,
  630. rx_refill_thread_sched_cb rx_sched_cb)
  631. {
  632. if (!soc || !soc->ol_ops) {
  633. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  634. "%s invalid instance", __func__);
  635. return;
  636. }
  637. soc->ol_ops->dp_rx_sched_refill_thread = rx_sched_cb;
  638. }
  639. /**
  640. * cdp_pdev_reset_driver_del_ack() - reset driver TCP delayed ack flag
  641. * @soc: data path soc handle
  642. * @pdev_id: pdev id
  643. *
  644. * Return: none
  645. */
  646. static inline void cdp_pdev_reset_driver_del_ack(void *psoc,
  647. uint8_t pdev_id)
  648. {
  649. ol_txrx_soc_handle soc = psoc;
  650. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  651. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  652. "%s invalid instance", __func__);
  653. return;
  654. }
  655. if (soc->ops->misc_ops->pdev_reset_driver_del_ack)
  656. return soc->ops->misc_ops->pdev_reset_driver_del_ack(soc,
  657. pdev_id);
  658. }
  659. /*
  660. * cdp_vdev_set_driver_del_ack_enable() - set driver delayed ack enabled flag
  661. * @soc: data path soc handle
  662. * @vdev_id: vdev id
  663. * @rx_packets: number of rx packets
  664. * @time_in_ms: time in ms
  665. * @high_th: high threshold
  666. * @low_th: low threshold
  667. *
  668. * Return: none
  669. */
  670. static inline void cdp_vdev_set_driver_del_ack_enable(ol_txrx_soc_handle soc,
  671. uint8_t vdev_id,
  672. unsigned long rx_packets,
  673. uint32_t time_in_ms,
  674. uint32_t high_th,
  675. uint32_t low_th)
  676. {
  677. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  678. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  679. "%s invalid instance", __func__);
  680. return;
  681. }
  682. if (soc->ops->misc_ops->vdev_set_driver_del_ack_enable)
  683. return soc->ops->misc_ops->vdev_set_driver_del_ack_enable(
  684. soc, vdev_id, rx_packets, time_in_ms, high_th, low_th);
  685. }
  686. static inline void cdp_vdev_set_bundle_require_flag(ol_txrx_soc_handle soc,
  687. uint8_t vdev_id,
  688. unsigned long tx_bytes,
  689. uint32_t time_in_ms,
  690. uint32_t high_th,
  691. uint32_t low_th)
  692. {
  693. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  694. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  695. "%s invalid instance", __func__);
  696. return;
  697. }
  698. if (soc->ops->misc_ops->vdev_set_bundle_require_flag)
  699. return soc->ops->misc_ops->vdev_set_bundle_require_flag(
  700. vdev_id, tx_bytes, time_in_ms, high_th, low_th);
  701. }
  702. static inline void cdp_pdev_reset_bundle_require_flag(ol_txrx_soc_handle soc,
  703. uint8_t pdev_id)
  704. {
  705. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  706. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  707. "%s invalid instance", __func__);
  708. return;
  709. }
  710. if (soc->ops->misc_ops->pdev_reset_bundle_require_flag)
  711. return soc->ops->misc_ops->pdev_reset_bundle_require_flag(
  712. soc, pdev_id);
  713. }
  714. /**
  715. * cdp_txrx_ext_stats_request(): request dp tx and rx extended stats
  716. * @soc: soc handle
  717. * @pdev_id: pdev id
  718. * @req: stats request structure to fill
  719. *
  720. * return: status
  721. */
  722. static inline QDF_STATUS
  723. cdp_txrx_ext_stats_request(ol_txrx_soc_handle soc, uint8_t pdev_id,
  724. struct cdp_txrx_ext_stats *req)
  725. {
  726. if (!soc || !soc->ops || !soc->ops->misc_ops || !req) {
  727. dp_cdp_debug("Invalid Instance:");
  728. return QDF_STATUS_E_INVAL;
  729. }
  730. if (soc->ops->misc_ops->txrx_ext_stats_request)
  731. return soc->ops->misc_ops->txrx_ext_stats_request(soc, pdev_id,
  732. req);
  733. return QDF_STATUS_SUCCESS;
  734. }
  735. /**
  736. * cdp_request_rx_hw_stats(): request rx hw stats
  737. * @soc: soc handle
  738. * @vdev_id: vdev id
  739. *
  740. * return: none
  741. */
  742. static inline QDF_STATUS
  743. cdp_request_rx_hw_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
  744. {
  745. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  746. dp_cdp_debug("Invalid Instance:");
  747. return QDF_STATUS_E_INVAL;
  748. }
  749. if (soc->ops->misc_ops->request_rx_hw_stats)
  750. return soc->ops->misc_ops->request_rx_hw_stats(soc, vdev_id);
  751. return QDF_STATUS_SUCCESS;
  752. }
  753. /**
  754. * cdp_reset_rx_hw_ext_stats(): reset rx hw ext stats
  755. * @soc: soc handle
  756. *
  757. * Return: none
  758. */
  759. static inline void
  760. cdp_reset_rx_hw_ext_stats(ol_txrx_soc_handle soc)
  761. {
  762. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  763. dp_cdp_debug("Invalid Instance");
  764. return;
  765. }
  766. if (soc->ops->misc_ops->reset_rx_hw_ext_stats)
  767. soc->ops->misc_ops->reset_rx_hw_ext_stats(soc);
  768. }
  769. /**
  770. * cdp_vdev_inform_ll_conn() - Inform DP about the low latency connection
  771. * @soc: soc handle
  772. * @vdev_id: vdev id
  773. * @action: Action to be performed (Add/Delete)
  774. *
  775. * Returns: QDF_STATUS
  776. */
  777. static inline QDF_STATUS
  778. cdp_vdev_inform_ll_conn(ol_txrx_soc_handle soc, uint8_t vdev_id,
  779. enum vdev_ll_conn_actions action)
  780. {
  781. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  782. dp_cdp_debug("Invalid Instance:");
  783. return QDF_STATUS_E_INVAL;
  784. }
  785. if (soc->ops->misc_ops->vdev_inform_ll_conn)
  786. return soc->ops->misc_ops->vdev_inform_ll_conn(soc, vdev_id,
  787. action);
  788. return QDF_STATUS_SUCCESS;
  789. }
  790. /**
  791. * cdp_soc_set_swlm_enable() - Enable or disable software latency manager
  792. * @soc: soc handle
  793. * @value: value (enable/disable)
  794. *
  795. * Returns: QDF_STATUS
  796. */
  797. static inline QDF_STATUS
  798. cdp_soc_set_swlm_enable(ol_txrx_soc_handle soc, uint8_t value)
  799. {
  800. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  801. dp_cdp_debug("Invalid Instance:");
  802. return QDF_STATUS_E_INVAL;
  803. }
  804. if (soc->ops->misc_ops->set_swlm_enable)
  805. return soc->ops->misc_ops->set_swlm_enable(soc, value);
  806. return QDF_STATUS_SUCCESS;
  807. }
  808. /**
  809. * cdp_soc_is_swlm_enabled() - Check if the software latency manager is
  810. * enabled or not
  811. * @soc: soc handle
  812. *
  813. * Returns: 1 if enabled, 0 if disabled
  814. */
  815. static inline uint8_t
  816. cdp_soc_is_swlm_enabled(ol_txrx_soc_handle soc)
  817. {
  818. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  819. dp_cdp_debug("Invalid Instance:");
  820. return 0;
  821. }
  822. if (soc->ops->misc_ops->is_swlm_enabled)
  823. return soc->ops->misc_ops->is_swlm_enabled(soc);
  824. return 0;
  825. }
  826. /**
  827. * cdp_display_txrx_hw_info() - Dump the DP rings info
  828. * @soc: soc handle
  829. *
  830. * Return: none
  831. */
  832. static inline void
  833. cdp_display_txrx_hw_info(ol_txrx_soc_handle soc)
  834. {
  835. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  836. dp_cdp_debug("Invalid Instance:");
  837. return;
  838. }
  839. if (soc->ops->misc_ops->display_txrx_hw_info)
  840. return soc->ops->misc_ops->display_txrx_hw_info(soc);
  841. }
  842. /**
  843. * cdp_get_tx_rings_grp_bitmap() - Get tx rings grp bitmap
  844. * @soc: soc handle
  845. *
  846. * Return: tx rings bitmap
  847. */
  848. static inline uint32_t
  849. cdp_get_tx_rings_grp_bitmap(ol_txrx_soc_handle soc)
  850. {
  851. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  852. dp_cdp_debug("Invalid Instance:");
  853. return 0;
  854. }
  855. if (soc->ops->misc_ops->get_tx_rings_grp_bitmap)
  856. return soc->ops->misc_ops->get_tx_rings_grp_bitmap(soc);
  857. return 0;
  858. }
  859. #ifdef WLAN_FEATURE_PEER_TXQ_FLUSH_CONF
  860. /**
  861. * cdp_set_peer_txq_flush_config() - Set the peer txq flush configuration
  862. * @soc: Opaque handle to the DP soc object
  863. * @vdev_id: VDEV identifier
  864. * @mac: MAC address of the peer
  865. * @ac: access category mask
  866. * @tid: TID mask
  867. * @policy: Flush policy
  868. *
  869. * Return: 0 on success, errno on failure
  870. */
  871. static inline int
  872. cdp_set_peer_txq_flush_config(ol_txrx_soc_handle soc, uint8_t vdev_id,
  873. uint8_t *mac, uint8_t ac, uint32_t tid,
  874. enum cdp_peer_txq_flush_policy policy)
  875. {
  876. if (!soc || !soc->ops || !soc->ops->misc_ops || !mac) {
  877. dp_cdp_debug("Invalid parameters");
  878. return 0;
  879. }
  880. if (soc->ops->misc_ops->set_peer_txq_flush_config) {
  881. return soc->ops->misc_ops->set_peer_txq_flush_config(soc,
  882. vdev_id,
  883. mac, ac,
  884. tid,
  885. policy);
  886. }
  887. return 0;
  888. }
  889. #endif /* WLAN_FEATURE_PEER_TXQ_FLUSH_CONF */
  890. #endif /* _CDP_TXRX_MISC_H_ */