cdp_txrx_misc.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2024 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: rings are empty
  829. */
  830. static inline bool
  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 true;
  836. }
  837. if (soc->ops->misc_ops->display_txrx_hw_info)
  838. return soc->ops->misc_ops->display_txrx_hw_info(soc);
  839. return true;
  840. }
  841. /**
  842. * cdp_get_tx_rings_grp_bitmap() - Get tx rings grp bitmap
  843. * @soc: soc handle
  844. *
  845. * Return: tx rings bitmap
  846. */
  847. static inline uint32_t
  848. cdp_get_tx_rings_grp_bitmap(ol_txrx_soc_handle soc)
  849. {
  850. if (!soc || !soc->ops || !soc->ops->misc_ops) {
  851. dp_cdp_debug("Invalid Instance:");
  852. return 0;
  853. }
  854. if (soc->ops->misc_ops->get_tx_rings_grp_bitmap)
  855. return soc->ops->misc_ops->get_tx_rings_grp_bitmap(soc);
  856. return 0;
  857. }
  858. #ifdef WLAN_FEATURE_PEER_TXQ_FLUSH_CONF
  859. /**
  860. * cdp_set_peer_txq_flush_config() - Set the peer txq flush configuration
  861. * @soc: Opaque handle to the DP soc object
  862. * @vdev_id: VDEV identifier
  863. * @mac: MAC address of the peer
  864. * @ac: access category mask
  865. * @tid: TID mask
  866. * @policy: Flush policy
  867. *
  868. * Return: 0 on success, errno on failure
  869. */
  870. static inline int
  871. cdp_set_peer_txq_flush_config(ol_txrx_soc_handle soc, uint8_t vdev_id,
  872. uint8_t *mac, uint8_t ac, uint32_t tid,
  873. enum cdp_peer_txq_flush_policy policy)
  874. {
  875. if (!soc || !soc->ops || !soc->ops->misc_ops || !mac) {
  876. dp_cdp_debug("Invalid parameters");
  877. return 0;
  878. }
  879. if (soc->ops->misc_ops->set_peer_txq_flush_config) {
  880. return soc->ops->misc_ops->set_peer_txq_flush_config(soc,
  881. vdev_id,
  882. mac, ac,
  883. tid,
  884. policy);
  885. }
  886. return 0;
  887. }
  888. #endif /* WLAN_FEATURE_PEER_TXQ_FLUSH_CONF */
  889. #ifdef FEATURE_RX_LINKSPEED_ROAM_TRIGGER
  890. /**
  891. * cdp_set_bus_vote_lvl_high() - have a vote on bus bandwidth lvl
  892. * @soc: datapath soc handle
  893. * @high: whether TPUT level is high or not
  894. *
  895. * Return: void
  896. */
  897. static inline void
  898. cdp_set_bus_vote_lvl_high(ol_txrx_soc_handle soc, bool high)
  899. {
  900. if (!soc || !soc->ops || !soc->ops->misc_ops ||
  901. !soc->ops->misc_ops->set_bus_vote_lvl_high) {
  902. dp_cdp_debug("Invalid Instance:");
  903. return;
  904. }
  905. soc->ops->misc_ops->set_bus_vote_lvl_high(soc, high);
  906. }
  907. /**
  908. * cdp_get_bus_lvl_high() - get high bus bandwidth lvl from dp
  909. * @soc: datapath soc handle
  910. *
  911. * Return: bool, whether TPUT level is high or not
  912. */
  913. static inline bool
  914. cdp_get_bus_lvl_high(ol_txrx_soc_handle soc)
  915. {
  916. if (!soc || !soc->ops || !soc->ops->misc_ops ||
  917. !soc->ops->misc_ops->get_bus_vote_lvl_high) {
  918. dp_cdp_debug("Invalid Instance:");
  919. return false;
  920. }
  921. return soc->ops->misc_ops->get_bus_vote_lvl_high(soc);
  922. }
  923. #else
  924. static inline void
  925. cdp_set_bus_vote_lvl_high(ol_txrx_soc_handle soc, bool high)
  926. {
  927. }
  928. static inline bool
  929. cdp_get_bus_lvl_high(ol_txrx_soc_handle soc)
  930. {
  931. /*
  932. * default bus lvl is high to
  933. * make sure not affect tput
  934. */
  935. return true;
  936. }
  937. #endif
  938. #ifdef DP_TX_PACKET_INSPECT_FOR_ILP
  939. /**
  940. * cdp_evaluate_update_tx_ilp_cfg() - Evaluate and update DP TX
  941. * ILP configuration
  942. * @soc: DP SOC handle
  943. * @num_msdu_idx_map: Number of HTT msdu index to qtype map in array
  944. * @msdu_idx_map_arr: Pointer to HTT msdu index to qtype map array
  945. *
  946. * Return: Final updated TX ILP enable result, true - enabled, false - not
  947. */
  948. static inline bool
  949. cdp_evaluate_update_tx_ilp_cfg(ol_txrx_soc_handle soc,
  950. uint8_t num_msdu_idx_map,
  951. uint8_t *msdu_idx_map_arr)
  952. {
  953. if (!soc || !soc->ops || !soc->ops->misc_ops ||
  954. !soc->ops->misc_ops->evaluate_update_tx_ilp_cfg) {
  955. dp_cdp_debug("Invalid Instance:");
  956. return false;
  957. }
  958. return soc->ops->misc_ops->evaluate_update_tx_ilp_cfg(
  959. soc, num_msdu_idx_map,
  960. msdu_idx_map_arr);
  961. }
  962. #endif /* DP_TX_PACKET_INSPECT_FOR_ILP */
  963. #endif /* _CDP_TXRX_MISC_H_ */