cdp_txrx_ipa.h 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027
  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_ipa.h
  21. * Define the host data path IP Acceleraor API functions
  22. */
  23. #ifndef _CDP_TXRX_IPA_H_
  24. #define _CDP_TXRX_IPA_H_
  25. #ifdef IPA_OFFLOAD
  26. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)) || \
  27. defined(CONFIG_IPA_WDI_UNIFIED_API)
  28. #include <qdf_ipa_wdi3.h>
  29. #else
  30. #include <qdf_ipa.h>
  31. #endif
  32. #include <cdp_txrx_cmn.h>
  33. #include "cdp_txrx_handle.h"
  34. #ifdef IPA_OPT_WIFI_DP
  35. #include <target_if.h>
  36. #endif
  37. /**
  38. * cdp_ipa_get_resource() - Get allocated WLAN resources for IPA data path
  39. * @soc: data path soc handle
  40. * @pdev_id: device instance id
  41. *
  42. * Get allocated WLAN resources for IPA data path
  43. *
  44. * return QDF_STATUS_SUCCESS
  45. */
  46. static inline QDF_STATUS
  47. cdp_ipa_get_resource(ol_txrx_soc_handle soc, uint8_t pdev_id)
  48. {
  49. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  50. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  51. "%s invalid instance", __func__);
  52. return QDF_STATUS_E_FAILURE;
  53. }
  54. if (soc->ops->ipa_ops->ipa_get_resource)
  55. return soc->ops->ipa_ops->ipa_get_resource(soc, pdev_id);
  56. return QDF_STATUS_SUCCESS;
  57. }
  58. /**
  59. * cdp_ipa_set_doorbell_paddr() - give IPA db paddr to FW
  60. * @soc: data path soc handle
  61. * @pdev_id: device instance id
  62. *
  63. * give IPA db paddr to FW
  64. *
  65. * return QDF_STATUS_SUCCESS
  66. */
  67. static inline QDF_STATUS
  68. cdp_ipa_set_doorbell_paddr(ol_txrx_soc_handle soc, uint8_t pdev_id)
  69. {
  70. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  71. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  72. "%s invalid instance", __func__);
  73. return QDF_STATUS_E_FAILURE;
  74. }
  75. if (soc->ops->ipa_ops->ipa_set_doorbell_paddr)
  76. return soc->ops->ipa_ops->ipa_set_doorbell_paddr(soc, pdev_id);
  77. return QDF_STATUS_SUCCESS;
  78. }
  79. /**
  80. * cdp_ipa_iounmap_doorbell_vaddr() - unmap IPA RX db vaddr
  81. * @soc: data path soc handle
  82. * @pdev_id: device instance id
  83. *
  84. * Unmap IPA RX db vaddr
  85. *
  86. * return QDF_STATUS_SUCCESS
  87. */
  88. static inline QDF_STATUS
  89. cdp_ipa_iounmap_doorbell_vaddr(ol_txrx_soc_handle soc, uint8_t pdev_id)
  90. {
  91. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  92. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  93. "%s invalid instance", __func__);
  94. return QDF_STATUS_E_FAILURE;
  95. }
  96. if (soc->ops->ipa_ops->ipa_iounmap_doorbell_vaddr)
  97. return soc->ops->ipa_ops->ipa_iounmap_doorbell_vaddr(
  98. soc, pdev_id);
  99. return QDF_STATUS_SUCCESS;
  100. }
  101. /**
  102. * cdp_ipa_set_active() - activate/de-ctivate IPA offload path
  103. * @soc: data path soc handle
  104. * @pdev_id: device instance id
  105. * @uc_active: activate or de-activate
  106. * @is_tx: toggle tx or rx data path
  107. *
  108. * activate/de-ctivate IPA offload path
  109. *
  110. * return QDF_STATUS_SUCCESS
  111. */
  112. static inline QDF_STATUS
  113. cdp_ipa_set_active(ol_txrx_soc_handle soc, uint8_t pdev_id, bool uc_active,
  114. bool is_tx)
  115. {
  116. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  117. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  118. "%s invalid instance", __func__);
  119. return QDF_STATUS_E_FAILURE;
  120. }
  121. if (soc->ops->ipa_ops->ipa_set_active)
  122. return soc->ops->ipa_ops->ipa_set_active(soc, pdev_id,
  123. uc_active, is_tx);
  124. return QDF_STATUS_SUCCESS;
  125. }
  126. /**
  127. * cdp_ipa_op_response() - event handler from FW
  128. * @soc: data path soc handle
  129. * @pdev_id: device instance id
  130. * @op_msg: event contents from firmware
  131. *
  132. * event handler from FW
  133. *
  134. * return QDF_STATUS_SUCCESS
  135. */
  136. static inline QDF_STATUS
  137. cdp_ipa_op_response(ol_txrx_soc_handle soc, uint8_t pdev_id, uint8_t *op_msg)
  138. {
  139. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  140. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  141. "%s invalid instance", __func__);
  142. return QDF_STATUS_E_FAILURE;
  143. }
  144. if (soc->ops->ipa_ops->ipa_op_response)
  145. return soc->ops->ipa_ops->ipa_op_response(soc, pdev_id, op_msg);
  146. return QDF_STATUS_SUCCESS;
  147. }
  148. /**
  149. * cdp_ipa_register_op_cb() - register event handler function pointer
  150. * @soc: data path soc handle
  151. * @pdev_id: device instance id
  152. * @op_cb: event handler callback function pointer
  153. * @usr_ctxt: user context to registered
  154. *
  155. * register event handler function pointer
  156. *
  157. * return QDF_STATUS_SUCCESS
  158. */
  159. static inline QDF_STATUS
  160. cdp_ipa_register_op_cb(ol_txrx_soc_handle soc, uint8_t pdev_id,
  161. ipa_uc_op_cb_type op_cb, void *usr_ctxt)
  162. {
  163. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  164. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  165. "%s invalid instance", __func__);
  166. return QDF_STATUS_E_FAILURE;
  167. }
  168. if (soc->ops->ipa_ops->ipa_register_op_cb)
  169. return soc->ops->ipa_ops->ipa_register_op_cb(soc, pdev_id,
  170. op_cb, usr_ctxt);
  171. return QDF_STATUS_SUCCESS;
  172. }
  173. /**
  174. * cdp_ipa_deregister_op_cb() - deregister event handler function pointer
  175. * @soc: data path soc handle
  176. * @pdev_id: device instance id
  177. *
  178. * Deregister event handler function pointer from pdev
  179. *
  180. * return QDF_STATUS_SUCCESS
  181. */
  182. static inline
  183. void cdp_ipa_deregister_op_cb(ol_txrx_soc_handle soc, uint8_t pdev_id)
  184. {
  185. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  186. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  187. "%s invalid instance", __func__);
  188. return;
  189. }
  190. if (soc->ops->ipa_ops->ipa_deregister_op_cb)
  191. soc->ops->ipa_ops->ipa_deregister_op_cb(soc, pdev_id);
  192. }
  193. /**
  194. * cdp_ipa_get_stat() - get IPA data path stats from FW
  195. * @soc: data path soc handle
  196. * @pdev_id: device instance id
  197. *
  198. * get IPA data path stats from FW async
  199. *
  200. * return QDF_STATUS_SUCCESS
  201. */
  202. static inline QDF_STATUS
  203. cdp_ipa_get_stat(ol_txrx_soc_handle soc, uint8_t pdev_id)
  204. {
  205. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  206. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  207. "%s invalid instance", __func__);
  208. return QDF_STATUS_E_FAILURE;
  209. }
  210. if (soc->ops->ipa_ops->ipa_get_stat)
  211. return soc->ops->ipa_ops->ipa_get_stat(soc, pdev_id);
  212. return QDF_STATUS_SUCCESS;
  213. }
  214. /**
  215. * cdp_ipa_tx_send_data_frame() - send IPA data frame
  216. * @soc: data path soc handle
  217. * @vdev_id: vdev id
  218. * @skb: skb
  219. *
  220. * Return: skb/ NULL is for success
  221. */
  222. static inline qdf_nbuf_t cdp_ipa_tx_send_data_frame(ol_txrx_soc_handle soc,
  223. uint8_t vdev_id,
  224. qdf_nbuf_t skb)
  225. {
  226. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  227. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  228. "%s invalid instance", __func__);
  229. return skb;
  230. }
  231. if (soc->ops->ipa_ops->ipa_tx_data_frame)
  232. return soc->ops->ipa_ops->ipa_tx_data_frame(soc, vdev_id, skb);
  233. return skb;
  234. }
  235. /**
  236. * cdp_ipa_set_uc_tx_partition_base() - set tx packet partition base
  237. * @soc: data path soc handle
  238. * @cfg_pdev: physical device instance config
  239. * @value: partition base value
  240. *
  241. * Return: QDF_STATUS
  242. */
  243. static inline QDF_STATUS
  244. cdp_ipa_set_uc_tx_partition_base(ol_txrx_soc_handle soc,
  245. struct cdp_cfg *cfg_pdev, uint32_t value)
  246. {
  247. if (!soc || !soc->ops || !soc->ops->ipa_ops || !cfg_pdev) {
  248. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  249. "%s invalid instance", __func__);
  250. return QDF_STATUS_E_FAILURE;
  251. }
  252. if (soc->ops->ipa_ops->ipa_set_uc_tx_partition_base)
  253. soc->ops->ipa_ops->ipa_set_uc_tx_partition_base(cfg_pdev,
  254. value);
  255. return QDF_STATUS_SUCCESS;
  256. }
  257. #ifdef FEATURE_METERING
  258. /**
  259. * cdp_ipa_uc_get_share_stats() - get Tx/Rx byte stats from FW
  260. * @soc: data path soc handle
  261. * @pdev_id: physical device instance number
  262. * @value: reset stats
  263. *
  264. * Return: QDF_STATUS
  265. */
  266. static inline QDF_STATUS
  267. cdp_ipa_uc_get_share_stats(ol_txrx_soc_handle soc, uint8_t pdev_id,
  268. uint8_t value)
  269. {
  270. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  271. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  272. "%s invalid instance", __func__);
  273. return QDF_STATUS_E_FAILURE;
  274. }
  275. if (soc->ops->ipa_ops->ipa_uc_get_share_stats)
  276. return soc->ops->ipa_ops->ipa_uc_get_share_stats(soc, pdev_id,
  277. value);
  278. return QDF_STATUS_SUCCESS;
  279. }
  280. /**
  281. * cdp_ipa_uc_set_quota() - set quota limit to FW
  282. * @soc: data path soc handle
  283. * @pdev_id: physical device instance number
  284. * @value: quota limit bytes
  285. *
  286. * Return: QDF_STATUS
  287. */
  288. static inline QDF_STATUS
  289. cdp_ipa_uc_set_quota(ol_txrx_soc_handle soc, uint8_t pdev_id, uint64_t value)
  290. {
  291. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  292. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  293. "%s invalid instance", __func__);
  294. return QDF_STATUS_E_FAILURE;
  295. }
  296. if (soc->ops->ipa_ops->ipa_uc_set_quota)
  297. return soc->ops->ipa_ops->ipa_uc_set_quota(soc, pdev_id, value);
  298. return QDF_STATUS_SUCCESS;
  299. }
  300. #endif
  301. /**
  302. * cdp_ipa_enable_autonomy() - Enable autonomy RX data path
  303. * @soc: data path soc handle
  304. * @pdev_id: physical device instance number
  305. *
  306. * IPA Data path is enabled and resumed.
  307. * All autonomy data path elements are ready to deliver packet
  308. * All RX packet should routed to IPA_REO ring, then IPA can receive packet
  309. * from WLAN
  310. *
  311. * Return: QDF_STATUS
  312. */
  313. static inline QDF_STATUS
  314. cdp_ipa_enable_autonomy(ol_txrx_soc_handle soc, uint8_t pdev_id)
  315. {
  316. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  317. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  318. "%s invalid instance", __func__);
  319. return QDF_STATUS_E_FAILURE;
  320. }
  321. if (soc->ops->ipa_ops->ipa_enable_autonomy)
  322. return soc->ops->ipa_ops->ipa_enable_autonomy(soc, pdev_id);
  323. return QDF_STATUS_SUCCESS;
  324. }
  325. /**
  326. * cdp_ipa_disable_autonomy() - Disable autonomy RX data path
  327. * @soc: data path soc handle
  328. * @pdev_id: physical device instance number
  329. *
  330. * IPA Data path is enabled and resumed.
  331. * All autonomy datapath elements are ready to deliver packet
  332. * All RX packet should routed to IPA_REO ring, then IPA can receive packet
  333. * from WLAN
  334. *
  335. * Return: QDF_STATUS
  336. */
  337. static inline QDF_STATUS
  338. cdp_ipa_disable_autonomy(ol_txrx_soc_handle soc, uint8_t pdev_id)
  339. {
  340. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  341. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  342. "%s invalid instance", __func__);
  343. return QDF_STATUS_E_FAILURE;
  344. }
  345. if (soc->ops->ipa_ops->ipa_disable_autonomy)
  346. return soc->ops->ipa_ops->ipa_disable_autonomy(soc, pdev_id);
  347. return QDF_STATUS_SUCCESS;
  348. }
  349. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)) || \
  350. defined(CONFIG_IPA_WDI_UNIFIED_API)
  351. /**
  352. * cdp_ipa_setup() - Setup and connect IPA pipes
  353. * @soc: data path soc handle
  354. * @pdev_id: handle to the device instance number
  355. * @ipa_i2w_cb: IPA to WLAN callback
  356. * @ipa_w2i_cb: WLAN to IPA callback
  357. * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
  358. * @ipa_desc_size: IPA descriptor size
  359. * @ipa_priv: handle to the HTT instance
  360. * @is_rm_enabled: Is IPA RM enabled or not
  361. * @tx_pipe_handle: pointer to Tx pipe handle
  362. * @rx_pipe_handle: pointer to Rx pipe handle
  363. * @is_smmu_enabled: Is SMMU enabled or not
  364. * @sys_in: parameters to setup sys pipe in mcc mode
  365. * @over_gsi: Is IPA using GSI
  366. * @hdl: IPA handle
  367. * @id: IPA instance id
  368. * @ipa_ast_notify_cb: IPA to WLAN callback for ast create
  369. *
  370. * Return: QDF_STATUS
  371. */
  372. static inline QDF_STATUS
  373. cdp_ipa_setup(ol_txrx_soc_handle soc, uint8_t pdev_id, void *ipa_i2w_cb,
  374. void *ipa_w2i_cb, void *ipa_wdi_meter_notifier_cb,
  375. uint32_t ipa_desc_size, void *ipa_priv, bool is_rm_enabled,
  376. uint32_t *tx_pipe_handle, uint32_t *rx_pipe_handle,
  377. bool is_smmu_enabled, qdf_ipa_sys_connect_params_t *sys_in,
  378. bool over_gsi, qdf_ipa_wdi_hdl_t hdl, qdf_ipa_wdi_hdl_t id,
  379. void *ipa_ast_notify_cb)
  380. {
  381. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  382. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  383. "%s invalid instance", __func__);
  384. return QDF_STATUS_E_FAILURE;
  385. }
  386. if (soc->ops->ipa_ops->ipa_setup)
  387. return soc->ops->ipa_ops->ipa_setup(soc, pdev_id, ipa_i2w_cb,
  388. ipa_w2i_cb,
  389. ipa_wdi_meter_notifier_cb,
  390. ipa_desc_size, ipa_priv,
  391. is_rm_enabled,
  392. tx_pipe_handle,
  393. rx_pipe_handle,
  394. is_smmu_enabled,
  395. sys_in, over_gsi, hdl, id,
  396. ipa_ast_notify_cb);
  397. return QDF_STATUS_SUCCESS;
  398. }
  399. #else /* CONFIG_IPA_WDI_UNIFIED_API */
  400. /**
  401. * cdp_ipa_setup() - Setup and connect IPA pipes
  402. * @soc: data path soc handle
  403. * @pdev_id: handle to the device instance number
  404. * @ipa_i2w_cb: IPA to WLAN callback
  405. * @ipa_w2i_cb: WLAN to IPA callback
  406. * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
  407. * @ipa_desc_size: IPA descriptor size
  408. * @ipa_priv: handle to the HTT instance
  409. * @is_rm_enabled: Is IPA RM enabled or not
  410. * @tx_pipe_handle: pointer to Tx pipe handle
  411. * @rx_pipe_handle: pointer to Rx pipe handle
  412. *
  413. * Return: QDF_STATUS
  414. */
  415. static inline QDF_STATUS
  416. cdp_ipa_setup(ol_txrx_soc_handle soc, uint8_t pdev_id, void *ipa_i2w_cb,
  417. void *ipa_w2i_cb, void *ipa_wdi_meter_notifier_cb,
  418. uint32_t ipa_desc_size, void *ipa_priv, bool is_rm_enabled,
  419. uint32_t *tx_pipe_handle, uint32_t *rx_pipe_handle)
  420. {
  421. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  422. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  423. "%s invalid instance", __func__);
  424. return QDF_STATUS_E_FAILURE;
  425. }
  426. if (soc->ops->ipa_ops->ipa_setup)
  427. return soc->ops->ipa_ops->ipa_setup(soc, pdev_id, ipa_i2w_cb,
  428. ipa_w2i_cb,
  429. ipa_wdi_meter_notifier_cb,
  430. ipa_desc_size, ipa_priv,
  431. is_rm_enabled,
  432. tx_pipe_handle,
  433. rx_pipe_handle);
  434. return QDF_STATUS_SUCCESS;
  435. }
  436. #endif /* CONFIG_IPA_WDI_UNIFIED_API */
  437. /**
  438. * cdp_ipa_cleanup() - Disconnect IPA pipes
  439. * @soc: data path soc handle
  440. * @pdev_id: handle to the device instance number
  441. * @tx_pipe_handle: Tx pipe handle
  442. * @rx_pipe_handle: Rx pipe handle
  443. * @hdl: IPA handle
  444. *
  445. * Return: QDF_STATUS
  446. */
  447. static inline QDF_STATUS
  448. cdp_ipa_cleanup(ol_txrx_soc_handle soc, uint8_t pdev_id,
  449. uint32_t tx_pipe_handle, uint32_t rx_pipe_handle,
  450. qdf_ipa_wdi_hdl_t hdl)
  451. {
  452. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  453. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  454. "%s invalid instance", __func__);
  455. return QDF_STATUS_E_FAILURE;
  456. }
  457. if (soc->ops->ipa_ops->ipa_cleanup)
  458. return soc->ops->ipa_ops->ipa_cleanup(soc, pdev_id,
  459. tx_pipe_handle,
  460. rx_pipe_handle, hdl);
  461. return QDF_STATUS_SUCCESS;
  462. }
  463. /**
  464. * cdp_ipa_setup_iface() - Setup IPA header and register interface
  465. * @soc: data path soc handle
  466. * @ifname: Interface name
  467. * @mac_addr: Interface MAC address
  468. * @prod_client: IPA prod client type
  469. * @cons_client: IPA cons client type
  470. * @session_id: Session ID
  471. * @is_ipv6_enabled: Is IPV6 enabled or not
  472. * @hdl: IPA handle
  473. *
  474. * Return: QDF_STATUS
  475. */
  476. static inline QDF_STATUS
  477. cdp_ipa_setup_iface(ol_txrx_soc_handle soc, char *ifname, uint8_t *mac_addr,
  478. qdf_ipa_client_type_t prod_client,
  479. qdf_ipa_client_type_t cons_client,
  480. uint8_t session_id, bool is_ipv6_enabled,
  481. qdf_ipa_wdi_hdl_t hdl)
  482. {
  483. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  484. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  485. "%s invalid instance", __func__);
  486. return QDF_STATUS_E_FAILURE;
  487. }
  488. if (soc->ops->ipa_ops->ipa_setup_iface)
  489. return soc->ops->ipa_ops->ipa_setup_iface(ifname, mac_addr,
  490. prod_client,
  491. cons_client,
  492. session_id,
  493. is_ipv6_enabled,
  494. hdl);
  495. return QDF_STATUS_SUCCESS;
  496. }
  497. /**
  498. * cdp_ipa_cleanup_iface() - Cleanup IPA header and deregister interface
  499. * @soc: data path soc handle
  500. * @ifname: Interface name
  501. * @is_ipv6_enabled: Is IPV6 enabled or not
  502. * @hdl: IPA handle
  503. *
  504. * Return: QDF_STATUS
  505. */
  506. static inline QDF_STATUS
  507. cdp_ipa_cleanup_iface(ol_txrx_soc_handle soc, char *ifname,
  508. bool is_ipv6_enabled, qdf_ipa_wdi_hdl_t hdl)
  509. {
  510. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  511. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  512. "%s invalid instance", __func__);
  513. return QDF_STATUS_E_FAILURE;
  514. }
  515. if (soc->ops->ipa_ops->ipa_cleanup_iface)
  516. return soc->ops->ipa_ops->ipa_cleanup_iface(ifname,
  517. is_ipv6_enabled,
  518. hdl);
  519. return QDF_STATUS_SUCCESS;
  520. }
  521. /**
  522. * cdp_ipa_uc_enable_pipes() - Enable and resume traffic on Tx/Rx pipes
  523. * @soc: data path soc handle
  524. * @pdev_id: device instance id
  525. * @hdl: IPA handle
  526. *
  527. * Return: QDF_STATUS
  528. */
  529. static inline QDF_STATUS
  530. cdp_ipa_enable_pipes(ol_txrx_soc_handle soc, uint8_t pdev_id,
  531. qdf_ipa_wdi_hdl_t hdl)
  532. {
  533. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  534. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  535. "%s invalid instance", __func__);
  536. return QDF_STATUS_E_FAILURE;
  537. }
  538. if (soc->ops->ipa_ops->ipa_enable_pipes)
  539. return soc->ops->ipa_ops->ipa_enable_pipes(soc, pdev_id, hdl);
  540. return QDF_STATUS_SUCCESS;
  541. }
  542. /**
  543. * cdp_ipa_disable_pipes() - Suspend traffic and disable Tx/Rx pipes
  544. * @soc: data path soc handle
  545. * @pdev_id: device instance id
  546. * @hdl: IPA handle
  547. *
  548. * Return: QDF_STATUS
  549. */
  550. static inline QDF_STATUS
  551. cdp_ipa_disable_pipes(ol_txrx_soc_handle soc, uint8_t pdev_id,
  552. qdf_ipa_wdi_hdl_t hdl)
  553. {
  554. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  555. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  556. "%s invalid instance", __func__);
  557. return QDF_STATUS_E_FAILURE;
  558. }
  559. if (soc->ops->ipa_ops->ipa_disable_pipes)
  560. return soc->ops->ipa_ops->ipa_disable_pipes(soc, pdev_id, hdl);
  561. return QDF_STATUS_SUCCESS;
  562. }
  563. /**
  564. * cdp_ipa_set_perf_level() - Set IPA clock bandwidth based on data rates
  565. * @soc: data path soc handle
  566. * @client: WLAN Client ID
  567. * @max_supported_bw_mbps: Maximum bandwidth needed (in Mbps)
  568. * @hdl: IPA handle
  569. *
  570. * Return: 0 on success, negative errno on error
  571. */
  572. static inline QDF_STATUS
  573. cdp_ipa_set_perf_level(ol_txrx_soc_handle soc, int client,
  574. uint32_t max_supported_bw_mbps, qdf_ipa_wdi_hdl_t hdl)
  575. {
  576. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  577. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  578. "%s invalid instance", __func__);
  579. return QDF_STATUS_E_FAILURE;
  580. }
  581. if (soc->ops->ipa_ops->ipa_set_perf_level)
  582. return soc->ops->ipa_ops->ipa_set_perf_level(client,
  583. max_supported_bw_mbps, hdl);
  584. return QDF_STATUS_SUCCESS;
  585. }
  586. /**
  587. * cdp_ipa_rx_intrabss_fwd() - Perform intra-bss fwd for IPA RX path
  588. *
  589. * @soc: data path soc handle
  590. * @vdev_id: vdev id
  591. * @nbuf: pointer to skb of ethernet packet received from IPA RX path
  592. * @fwd_success: pointer to indicate if skb succeeded in intra-bss TX
  593. *
  594. * This function performs intra-bss forwarding for WDI 3.0 IPA RX path.
  595. *
  596. * Return: true if packet is intra-bss fwd-ed and no need to pass to
  597. * network stack. false if packet needs to be passed to network stack.
  598. */
  599. static inline bool
  600. cdp_ipa_rx_intrabss_fwd(ol_txrx_soc_handle soc, uint8_t vdev_id,
  601. qdf_nbuf_t nbuf, bool *fwd_success)
  602. {
  603. if (!soc || !soc->ops || !soc->ops->ipa_ops || !fwd_success) {
  604. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  605. "%s invalid instance", __func__);
  606. return QDF_STATUS_E_FAILURE;
  607. }
  608. if (soc->ops->ipa_ops->ipa_rx_intrabss_fwd)
  609. return soc->ops->ipa_ops->ipa_rx_intrabss_fwd(soc, vdev_id,
  610. nbuf,
  611. fwd_success);
  612. /* Fall back to pass up to stack */
  613. return false;
  614. }
  615. /**
  616. * cdp_ipa_tx_buf_smmu_mapping() - Create SMMU mappings for Tx
  617. * buffers allocated to IPA
  618. * @soc: data path soc handle
  619. * @pdev_id: device instance id
  620. * @line: line number
  621. * @func: function name
  622. *
  623. * Create SMMU mappings for Tx buffers allocated to IPA
  624. *
  625. * return QDF_STATUS_SUCCESS
  626. */
  627. static inline QDF_STATUS
  628. cdp_ipa_tx_buf_smmu_mapping(ol_txrx_soc_handle soc, uint8_t pdev_id,
  629. const char *func, uint32_t line)
  630. {
  631. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  632. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  633. "%s invalid instance", __func__);
  634. return QDF_STATUS_E_FAILURE;
  635. }
  636. if (soc->ops->ipa_ops->ipa_tx_buf_smmu_mapping)
  637. return soc->ops->ipa_ops->ipa_tx_buf_smmu_mapping(soc, pdev_id,
  638. func,
  639. line);
  640. return QDF_STATUS_SUCCESS;
  641. }
  642. /**
  643. * cdp_ipa_tx_buf_smmu_unmapping() - Release SMMU mappings for Tx
  644. * buffers allocated to IPA
  645. * @soc: data path soc handle
  646. * @pdev_id: device instance id
  647. * @line: line number
  648. * @func: function name
  649. *
  650. * Release SMMU mappings for Tx buffers allocated to IPA
  651. *
  652. * return QDF_STATUS_SUCCESS
  653. */
  654. static inline QDF_STATUS
  655. cdp_ipa_tx_buf_smmu_unmapping(ol_txrx_soc_handle soc, uint8_t pdev_id,
  656. const char *func, uint32_t line)
  657. {
  658. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  659. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  660. "%s invalid instance", __func__);
  661. return QDF_STATUS_E_FAILURE;
  662. }
  663. if (soc->ops->ipa_ops->ipa_tx_buf_smmu_unmapping)
  664. return soc->ops->ipa_ops->ipa_tx_buf_smmu_unmapping(soc,
  665. pdev_id,
  666. func,
  667. line);
  668. return QDF_STATUS_SUCCESS;
  669. }
  670. /**
  671. * cdp_ipa_rx_buf_smmu_pool_mapping() - Create SMMU mappings for Rx pool
  672. * @soc: data path soc handle
  673. * @pdev_id: pdev id
  674. * @create: Map/unmap
  675. * @line: line number
  676. * @func: function name
  677. *
  678. * Create SMMU map/unmap for Rx buffers allocated to IPA
  679. *
  680. * return QDF_STATUS_SUCCESS
  681. */
  682. static inline QDF_STATUS
  683. cdp_ipa_rx_buf_smmu_pool_mapping(ol_txrx_soc_handle soc, uint8_t pdev_id,
  684. bool create, const char *func, uint32_t line)
  685. {
  686. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  687. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  688. "%s invalid instance", __func__);
  689. return QDF_STATUS_E_FAILURE;
  690. }
  691. if (soc->ops->ipa_ops->ipa_rx_buf_smmu_pool_mapping)
  692. return soc->ops->ipa_ops->ipa_rx_buf_smmu_pool_mapping(soc,
  693. pdev_id, create, func, line);
  694. return QDF_STATUS_SUCCESS;
  695. }
  696. static inline QDF_STATUS cdp_ipa_set_smmu_mapped(ol_txrx_soc_handle soc,
  697. int val)
  698. {
  699. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  700. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  701. "%s invalid instance", __func__);
  702. return QDF_STATUS_E_FAILURE;
  703. }
  704. if (soc->ops->ipa_ops->ipa_set_smmu_mapped)
  705. return soc->ops->ipa_ops->ipa_set_smmu_mapped(soc, val);
  706. return QDF_STATUS_SUCCESS;
  707. }
  708. static inline int cdp_ipa_get_smmu_mapped(ol_txrx_soc_handle soc)
  709. {
  710. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  711. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  712. "%s invalid instance", __func__);
  713. return QDF_STATUS_E_FAILURE;
  714. }
  715. if (soc->ops->ipa_ops->ipa_get_smmu_mapped)
  716. return soc->ops->ipa_ops->ipa_get_smmu_mapped(soc);
  717. return QDF_STATUS_SUCCESS;
  718. }
  719. #ifdef IPA_WDS_EASYMESH_FEATURE
  720. /**
  721. * cdp_ipa_ast_create() - Create/update AST entry in AST table
  722. * for learning/roaming packets from IPA
  723. * @soc: data path soc handle
  724. * @data: Structure used for updating the AST table
  725. *
  726. * Create/update AST entry in AST table for learning/roaming packets from IPA
  727. *
  728. * Return: QDF_STATUS
  729. */
  730. static inline QDF_STATUS
  731. cdp_ipa_ast_create(ol_txrx_soc_handle soc, qdf_ipa_ast_info_type_t *data)
  732. {
  733. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  734. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  735. "%s invalid instance", __func__);
  736. return QDF_STATUS_E_FAILURE;
  737. }
  738. if (soc->ops->ipa_ops->ipa_ast_create)
  739. return soc->ops->ipa_ops->ipa_ast_create(soc, data);
  740. return QDF_STATUS_SUCCESS;
  741. }
  742. #endif
  743. #ifdef IPA_OPT_WIFI_DP
  744. /*
  745. * cdp_ipa_pcie_link_up() - Send request to hold PCIe link in L0
  746. * @soc - cdp soc handle
  747. *
  748. * Return: 0 for success, negative for failure
  749. */
  750. static inline int
  751. cdp_ipa_pcie_link_up(ol_txrx_soc_handle soc)
  752. {
  753. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  754. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  755. "%s invalid instance", __func__);
  756. return QDF_STATUS_E_FAILURE;
  757. }
  758. if (soc->ops->ipa_ops->ipa_pcie_link_up)
  759. return soc->ops->ipa_ops->ipa_pcie_link_up(soc);
  760. return QDF_STATUS_SUCCESS;
  761. }
  762. /*
  763. * cdp_ipa_pcie_link_down() - Release request to hold PCIe link in L0
  764. * @soc - cdp soc handle
  765. *
  766. * Return: 0 for success, negative for failure
  767. */
  768. static inline int
  769. cdp_ipa_pcie_link_down(ol_txrx_soc_handle soc)
  770. {
  771. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  772. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  773. "%s invalid instance", __func__);
  774. return QDF_STATUS_E_FAILURE;
  775. }
  776. if (soc->ops->ipa_ops->ipa_pcie_link_down)
  777. soc->ops->ipa_ops->ipa_pcie_link_down(soc);
  778. return QDF_STATUS_SUCCESS;
  779. }
  780. #endif
  781. /**
  782. * cdp_ipa_update_peer_rx_stats() - update peer rx stats
  783. * @soc: data path soc handle
  784. * @vdev_id: vdev id
  785. * @peer_mac: Peer Mac Address
  786. * @nbuf: pointer to data packet
  787. *
  788. * Return: QDF_STATUS
  789. */
  790. static inline QDF_STATUS
  791. cdp_ipa_update_peer_rx_stats(ol_txrx_soc_handle soc, uint8_t vdev_id,
  792. uint8_t *peer_mac, qdf_nbuf_t nbuf)
  793. {
  794. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  795. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  796. "%s invalid instance", __func__);
  797. return QDF_STATUS_E_FAILURE;
  798. }
  799. if (soc->ops->ipa_ops->ipa_update_peer_rx_stats)
  800. return soc->ops->ipa_ops->ipa_update_peer_rx_stats(soc,
  801. vdev_id,
  802. peer_mac,
  803. nbuf);
  804. return QDF_STATUS_SUCCESS;
  805. }
  806. #ifdef IPA_OPT_WIFI_DP
  807. #define RX_CCE_SUPER_RULE_SETUP_NUM 2
  808. struct addr_params {
  809. uint8_t valid;
  810. uint8_t src_ipv4_addr[4];
  811. uint8_t dst_ipv4_addr[4];
  812. uint8_t src_ipv6_addr[16];
  813. uint8_t dst_ipv6_addr[16];
  814. uint8_t l4_type;
  815. uint16_t l3_type;
  816. uint16_t src_port;
  817. uint16_t dst_port;
  818. uint32_t flt_hdl;
  819. uint8_t ipa_flt_evnt_required;
  820. bool ipa_flt_in_use;
  821. };
  822. struct wifi_dp_flt_setup {
  823. uint8_t pdev_id;
  824. uint8_t op;
  825. uint8_t num_filters;
  826. uint32_t ipa_flt_evnt_response;
  827. struct addr_params flt_addr_params[RX_CCE_SUPER_RULE_SETUP_NUM];
  828. };
  829. static inline QDF_STATUS
  830. cdp_ipa_rx_cce_super_rule_setup(ol_txrx_soc_handle soc,
  831. void *flt_params)
  832. {
  833. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  834. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  835. "%s invalid instance", __func__);
  836. return QDF_STATUS_E_FAILURE;
  837. }
  838. if (soc->ops->ipa_ops->ipa_rx_super_rule_setup)
  839. return soc->ops->ipa_ops->ipa_rx_super_rule_setup(soc,
  840. flt_params);
  841. return QDF_STATUS_SUCCESS;
  842. }
  843. static inline QDF_STATUS
  844. cdp_ipa_opt_dp_enable_disable_low_power_mode(struct wlan_objmgr_pdev *pdev,
  845. uint32_t pdev_id, int param_val)
  846. {
  847. wmi_unified_t wmi_handle;
  848. struct wmi_unified *pdev_wmi_handle = NULL;
  849. struct wlan_objmgr_psoc *psoc;
  850. struct pdev_params pparam;
  851. uint32_t vdev_id, val;
  852. QDF_STATUS status;
  853. psoc = wlan_pdev_get_psoc(pdev);
  854. wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
  855. if (!wmi_handle) {
  856. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  857. "Unable to get wmi handle");
  858. return QDF_STATUS_E_NULL_VALUE;
  859. }
  860. pdev_wmi_handle = pdev->tgt_if_handle->wmi_handle;
  861. qdf_mem_set(&pparam, sizeof(pparam), 0);
  862. pparam.is_host_pdev_id = false;
  863. /* Enable-disable IMPS */
  864. pparam.param_id = WMI_PDEV_PARAM_IDLE_PS_CONFIG;
  865. pparam.param_value = param_val;
  866. status = wmi_unified_pdev_param_send(wmi_handle,
  867. &pparam, pdev_id);
  868. if (status != QDF_STATUS_SUCCESS) {
  869. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  870. "%s Unable to enable/disable:(%d) IMPS", __func__,
  871. param_val);
  872. return QDF_STATUS_E_FAILURE;
  873. }
  874. /* Enable-disable ILP */
  875. pparam.param_id = WMI_PDEV_PARAM_PCIE_HW_ILP;
  876. pparam.param_value = param_val;
  877. status = wmi_unified_pdev_param_send(pdev_wmi_handle,
  878. &pparam, pdev_id);
  879. if (status != QDF_STATUS_SUCCESS) {
  880. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  881. "%s Unable to enable/disable:(%d) ILP", __func__,
  882. param_val);
  883. return QDF_STATUS_E_FAILURE;
  884. }
  885. /* Enable-disable BMPS */
  886. val = param_val;
  887. vdev_id = 0; //TODO fix vdev_id
  888. status = wmi_unified_set_sta_ps_mode(wmi_handle, vdev_id, val);
  889. if (status != QDF_STATUS_SUCCESS) {
  890. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  891. "%s Unable to enable/disable:(%d) BMPS", __func__,
  892. param_val);
  893. return QDF_STATUS_E_FAILURE;
  894. }
  895. return status;
  896. }
  897. #endif /* IPA_OPT_WIFI_DP */
  898. /**
  899. * cdp_ipa_get_wdi_version - Get WDI version
  900. * @soc: data path soc handle
  901. * @wdi_ver: Out param for wdi version
  902. *
  903. * Return: None
  904. */
  905. static inline void
  906. cdp_ipa_get_wdi_version(ol_txrx_soc_handle soc, uint8_t *wdi_ver)
  907. {
  908. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  909. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  910. "%s invalid instance", __func__);
  911. return;
  912. }
  913. if (soc->ops->ipa_ops->ipa_get_wdi_version)
  914. soc->ops->ipa_ops->ipa_get_wdi_version(soc, wdi_ver);
  915. }
  916. #endif /* IPA_OFFLOAD */
  917. #endif /* _CDP_TXRX_IPA_H_ */