cdp_txrx_ipa.h 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054
  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. #ifdef QCA_SUPPORT_WDS_EXTENDED
  587. /**
  588. * cdp_ipa_rx_wdsext_iface() - Forward RX exception packets to wdsext interface
  589. * @soc: data path soc handle
  590. * @peer_id: Peer id to get respective peer
  591. * @skb: socket buffer
  592. *
  593. * Return: true if packets sent to wds ext interface, else false.
  594. */
  595. static inline bool
  596. cdp_ipa_rx_wdsext_iface(ol_txrx_soc_handle soc, uint8_t peer_id,
  597. qdf_nbuf_t skb)
  598. {
  599. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  600. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  601. "%s invalid instance", __func__);
  602. return false;
  603. }
  604. if (soc->ops->ipa_ops->ipa_rx_wdsext_iface)
  605. return soc->ops->ipa_ops->ipa_rx_wdsext_iface(soc, peer_id,
  606. skb);
  607. return false;
  608. }
  609. #endif
  610. /**
  611. * cdp_ipa_rx_intrabss_fwd() - Perform intra-bss fwd for IPA RX path
  612. *
  613. * @soc: data path soc handle
  614. * @vdev_id: vdev id
  615. * @nbuf: pointer to skb of ethernet packet received from IPA RX path
  616. * @fwd_success: pointer to indicate if skb succeeded in intra-bss TX
  617. *
  618. * This function performs intra-bss forwarding for WDI 3.0 IPA RX path.
  619. *
  620. * Return: true if packet is intra-bss fwd-ed and no need to pass to
  621. * network stack. false if packet needs to be passed to network stack.
  622. */
  623. static inline bool
  624. cdp_ipa_rx_intrabss_fwd(ol_txrx_soc_handle soc, uint8_t vdev_id,
  625. qdf_nbuf_t nbuf, bool *fwd_success)
  626. {
  627. if (!soc || !soc->ops || !soc->ops->ipa_ops || !fwd_success) {
  628. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  629. "%s invalid instance", __func__);
  630. return QDF_STATUS_E_FAILURE;
  631. }
  632. if (soc->ops->ipa_ops->ipa_rx_intrabss_fwd)
  633. return soc->ops->ipa_ops->ipa_rx_intrabss_fwd(soc, vdev_id,
  634. nbuf,
  635. fwd_success);
  636. /* Fall back to pass up to stack */
  637. return false;
  638. }
  639. /**
  640. * cdp_ipa_tx_buf_smmu_mapping() - Create SMMU mappings for Tx
  641. * buffers allocated to IPA
  642. * @soc: data path soc handle
  643. * @pdev_id: device instance id
  644. * @line: line number
  645. * @func: function name
  646. *
  647. * Create SMMU mappings for Tx buffers allocated to IPA
  648. *
  649. * return QDF_STATUS_SUCCESS
  650. */
  651. static inline QDF_STATUS
  652. cdp_ipa_tx_buf_smmu_mapping(ol_txrx_soc_handle soc, uint8_t pdev_id,
  653. const char *func, uint32_t line)
  654. {
  655. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  656. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  657. "%s invalid instance", __func__);
  658. return QDF_STATUS_E_FAILURE;
  659. }
  660. if (soc->ops->ipa_ops->ipa_tx_buf_smmu_mapping)
  661. return soc->ops->ipa_ops->ipa_tx_buf_smmu_mapping(soc, pdev_id,
  662. func,
  663. line);
  664. return QDF_STATUS_SUCCESS;
  665. }
  666. /**
  667. * cdp_ipa_tx_buf_smmu_unmapping() - Release SMMU mappings for Tx
  668. * buffers allocated to IPA
  669. * @soc: data path soc handle
  670. * @pdev_id: device instance id
  671. * @line: line number
  672. * @func: function name
  673. *
  674. * Release SMMU mappings for Tx buffers allocated to IPA
  675. *
  676. * return QDF_STATUS_SUCCESS
  677. */
  678. static inline QDF_STATUS
  679. cdp_ipa_tx_buf_smmu_unmapping(ol_txrx_soc_handle soc, uint8_t pdev_id,
  680. const char *func, uint32_t line)
  681. {
  682. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  683. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  684. "%s invalid instance", __func__);
  685. return QDF_STATUS_E_FAILURE;
  686. }
  687. if (soc->ops->ipa_ops->ipa_tx_buf_smmu_unmapping)
  688. return soc->ops->ipa_ops->ipa_tx_buf_smmu_unmapping(soc,
  689. pdev_id,
  690. func,
  691. line);
  692. return QDF_STATUS_SUCCESS;
  693. }
  694. /**
  695. * cdp_ipa_rx_buf_smmu_pool_mapping() - Create SMMU mappings for Rx pool
  696. * @soc: data path soc handle
  697. * @pdev_id: pdev id
  698. * @create: Map/unmap
  699. * @line: line number
  700. * @func: function name
  701. *
  702. * Create SMMU map/unmap for Rx buffers allocated to IPA
  703. *
  704. * return QDF_STATUS_SUCCESS
  705. */
  706. static inline QDF_STATUS
  707. cdp_ipa_rx_buf_smmu_pool_mapping(ol_txrx_soc_handle soc, uint8_t pdev_id,
  708. bool create, const char *func, uint32_t line)
  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_rx_buf_smmu_pool_mapping)
  716. return soc->ops->ipa_ops->ipa_rx_buf_smmu_pool_mapping(soc,
  717. pdev_id, create, func, line);
  718. return QDF_STATUS_SUCCESS;
  719. }
  720. static inline QDF_STATUS cdp_ipa_set_smmu_mapped(ol_txrx_soc_handle soc,
  721. int val)
  722. {
  723. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  724. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  725. "%s invalid instance", __func__);
  726. return QDF_STATUS_E_FAILURE;
  727. }
  728. if (soc->ops->ipa_ops->ipa_set_smmu_mapped)
  729. return soc->ops->ipa_ops->ipa_set_smmu_mapped(soc, val);
  730. return QDF_STATUS_SUCCESS;
  731. }
  732. static inline int cdp_ipa_get_smmu_mapped(ol_txrx_soc_handle soc)
  733. {
  734. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  735. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  736. "%s invalid instance", __func__);
  737. return QDF_STATUS_E_FAILURE;
  738. }
  739. if (soc->ops->ipa_ops->ipa_get_smmu_mapped)
  740. return soc->ops->ipa_ops->ipa_get_smmu_mapped(soc);
  741. return QDF_STATUS_SUCCESS;
  742. }
  743. #ifdef IPA_WDS_EASYMESH_FEATURE
  744. /**
  745. * cdp_ipa_ast_create() - Create/update AST entry in AST table
  746. * for learning/roaming packets from IPA
  747. * @soc: data path soc handle
  748. * @data: Structure used for updating the AST table
  749. *
  750. * Create/update AST entry in AST table for learning/roaming packets from IPA
  751. *
  752. * Return: QDF_STATUS
  753. */
  754. static inline QDF_STATUS
  755. cdp_ipa_ast_create(ol_txrx_soc_handle soc, qdf_ipa_ast_info_type_t *data)
  756. {
  757. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  758. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  759. "%s invalid instance", __func__);
  760. return QDF_STATUS_E_FAILURE;
  761. }
  762. if (soc->ops->ipa_ops->ipa_ast_create)
  763. return soc->ops->ipa_ops->ipa_ast_create(soc, data);
  764. return QDF_STATUS_SUCCESS;
  765. }
  766. #endif
  767. #ifdef IPA_OPT_WIFI_DP
  768. /*
  769. * cdp_ipa_pcie_link_up() - Send request to hold PCIe link in L0
  770. * @soc - cdp soc handle
  771. *
  772. * Return: 0 for success, negative for failure
  773. */
  774. static inline int
  775. cdp_ipa_pcie_link_up(ol_txrx_soc_handle soc)
  776. {
  777. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  778. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  779. "%s invalid instance", __func__);
  780. return QDF_STATUS_E_FAILURE;
  781. }
  782. if (soc->ops->ipa_ops->ipa_pcie_link_up)
  783. return soc->ops->ipa_ops->ipa_pcie_link_up(soc);
  784. return QDF_STATUS_SUCCESS;
  785. }
  786. /*
  787. * cdp_ipa_pcie_link_down() - Release request to hold PCIe link in L0
  788. * @soc - cdp soc handle
  789. *
  790. * Return: 0 for success, negative for failure
  791. */
  792. static inline int
  793. cdp_ipa_pcie_link_down(ol_txrx_soc_handle soc)
  794. {
  795. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  796. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  797. "%s invalid instance", __func__);
  798. return QDF_STATUS_E_FAILURE;
  799. }
  800. if (soc->ops->ipa_ops->ipa_pcie_link_down)
  801. soc->ops->ipa_ops->ipa_pcie_link_down(soc);
  802. return QDF_STATUS_SUCCESS;
  803. }
  804. #endif
  805. /**
  806. * cdp_ipa_update_peer_rx_stats() - update peer rx stats
  807. * @soc: data path soc handle
  808. * @vdev_id: vdev id
  809. * @peer_mac: Peer Mac Address
  810. * @nbuf: pointer to data packet
  811. *
  812. * Return: QDF_STATUS
  813. */
  814. static inline QDF_STATUS
  815. cdp_ipa_update_peer_rx_stats(ol_txrx_soc_handle soc, uint8_t vdev_id,
  816. uint8_t *peer_mac, qdf_nbuf_t nbuf)
  817. {
  818. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  819. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  820. "%s invalid instance", __func__);
  821. return QDF_STATUS_E_FAILURE;
  822. }
  823. if (soc->ops->ipa_ops->ipa_update_peer_rx_stats)
  824. return soc->ops->ipa_ops->ipa_update_peer_rx_stats(soc,
  825. vdev_id,
  826. peer_mac,
  827. nbuf);
  828. return QDF_STATUS_SUCCESS;
  829. }
  830. #ifdef IPA_OPT_WIFI_DP
  831. #define RX_CCE_SUPER_RULE_SETUP_NUM 2
  832. struct addr_params {
  833. uint8_t valid;
  834. uint8_t src_ipv4_addr[4];
  835. uint8_t dst_ipv4_addr[4];
  836. uint8_t src_ipv6_addr[16];
  837. uint8_t dst_ipv6_addr[16];
  838. uint8_t l4_type;
  839. uint16_t l3_type;
  840. uint16_t src_port;
  841. uint16_t dst_port;
  842. uint32_t flt_hdl;
  843. uint8_t ipa_flt_evnt_required;
  844. bool ipa_flt_in_use;
  845. };
  846. struct wifi_dp_flt_setup {
  847. uint8_t pdev_id;
  848. uint8_t op;
  849. uint8_t num_filters;
  850. uint32_t ipa_flt_evnt_response;
  851. struct addr_params flt_addr_params[RX_CCE_SUPER_RULE_SETUP_NUM];
  852. };
  853. static inline QDF_STATUS
  854. cdp_ipa_rx_cce_super_rule_setup(ol_txrx_soc_handle soc,
  855. void *flt_params)
  856. {
  857. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  858. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  859. "%s invalid instance", __func__);
  860. return QDF_STATUS_E_FAILURE;
  861. }
  862. if (soc->ops->ipa_ops->ipa_rx_super_rule_setup)
  863. return soc->ops->ipa_ops->ipa_rx_super_rule_setup(soc,
  864. flt_params);
  865. return QDF_STATUS_SUCCESS;
  866. }
  867. static inline QDF_STATUS
  868. cdp_ipa_opt_dp_enable_disable_low_power_mode(struct wlan_objmgr_pdev *pdev,
  869. uint32_t pdev_id, int param_val)
  870. {
  871. wmi_unified_t wmi_handle;
  872. struct wmi_unified *pdev_wmi_handle = NULL;
  873. struct wlan_objmgr_psoc *psoc;
  874. struct pdev_params pparam;
  875. uint32_t vdev_id, val;
  876. QDF_STATUS status;
  877. psoc = wlan_pdev_get_psoc(pdev);
  878. wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
  879. if (!wmi_handle) {
  880. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  881. "Unable to get wmi handle");
  882. return QDF_STATUS_E_NULL_VALUE;
  883. }
  884. pdev_wmi_handle = pdev->tgt_if_handle->wmi_handle;
  885. qdf_mem_set(&pparam, sizeof(pparam), 0);
  886. pparam.is_host_pdev_id = false;
  887. /* Enable-disable IMPS */
  888. pparam.param_id = WMI_PDEV_PARAM_IDLE_PS_CONFIG;
  889. pparam.param_value = param_val;
  890. status = wmi_unified_pdev_param_send(wmi_handle,
  891. &pparam, pdev_id);
  892. if (status != QDF_STATUS_SUCCESS) {
  893. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  894. "%s Unable to enable/disable:(%d) IMPS", __func__,
  895. param_val);
  896. return QDF_STATUS_E_FAILURE;
  897. }
  898. /* Enable-disable ILP */
  899. pparam.param_id = WMI_PDEV_PARAM_PCIE_HW_ILP;
  900. pparam.param_value = param_val;
  901. status = wmi_unified_pdev_param_send(pdev_wmi_handle,
  902. &pparam, pdev_id);
  903. if (status != QDF_STATUS_SUCCESS) {
  904. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  905. "%s Unable to enable/disable:(%d) ILP", __func__,
  906. param_val);
  907. return QDF_STATUS_E_FAILURE;
  908. }
  909. /* Enable-disable BMPS */
  910. val = param_val;
  911. vdev_id = 0; //TODO fix vdev_id
  912. status = wmi_unified_set_sta_ps_mode(wmi_handle, vdev_id, val);
  913. if (status != QDF_STATUS_SUCCESS) {
  914. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  915. "%s Unable to enable/disable:(%d) BMPS", __func__,
  916. param_val);
  917. return QDF_STATUS_E_FAILURE;
  918. }
  919. return status;
  920. }
  921. #endif /* IPA_OPT_WIFI_DP */
  922. /**
  923. * cdp_ipa_get_wdi_version - Get WDI version
  924. * @soc: data path soc handle
  925. * @wdi_ver: Out param for wdi version
  926. *
  927. * Return: None
  928. */
  929. static inline void
  930. cdp_ipa_get_wdi_version(ol_txrx_soc_handle soc, uint8_t *wdi_ver)
  931. {
  932. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  933. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  934. "%s invalid instance", __func__);
  935. return;
  936. }
  937. if (soc->ops->ipa_ops->ipa_get_wdi_version)
  938. soc->ops->ipa_ops->ipa_get_wdi_version(soc, wdi_ver);
  939. }
  940. #endif /* IPA_OFFLOAD */
  941. #endif /* _CDP_TXRX_IPA_H_ */