cdp_txrx_ipa.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. /**
  20. * @file cdp_txrx_ipa.h
  21. * @brief 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. /**
  35. * cdp_ipa_get_resource() - Get allocated WLAN resources for IPA data path
  36. * @soc - data path soc handle
  37. * @pdev_id - device instance id
  38. *
  39. * Get allocated WLAN resources for IPA data path
  40. *
  41. * return QDF_STATUS_SUCCESS
  42. */
  43. static inline QDF_STATUS
  44. cdp_ipa_get_resource(ol_txrx_soc_handle soc, uint8_t pdev_id)
  45. {
  46. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  47. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  48. "%s invalid instance", __func__);
  49. return QDF_STATUS_E_FAILURE;
  50. }
  51. if (soc->ops->ipa_ops->ipa_get_resource)
  52. return soc->ops->ipa_ops->ipa_get_resource(soc, pdev_id);
  53. return QDF_STATUS_SUCCESS;
  54. }
  55. /**
  56. * cdp_ipa_set_doorbell_paddr() - give IPA db paddr to FW
  57. * @soc - data path soc handle
  58. * @pdev_id - device instance id
  59. *
  60. * give IPA db paddr to FW
  61. *
  62. * return QDF_STATUS_SUCCESS
  63. */
  64. static inline QDF_STATUS
  65. cdp_ipa_set_doorbell_paddr(ol_txrx_soc_handle soc, uint8_t pdev_id)
  66. {
  67. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  68. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  69. "%s invalid instance", __func__);
  70. return QDF_STATUS_E_FAILURE;
  71. }
  72. if (soc->ops->ipa_ops->ipa_set_doorbell_paddr)
  73. return soc->ops->ipa_ops->ipa_set_doorbell_paddr(soc, pdev_id);
  74. return QDF_STATUS_SUCCESS;
  75. }
  76. /**
  77. * cdp_ipa_iounmap_doorbell_vaddr() - unmap IPA RX db vaddr
  78. * @soc - data path soc handle
  79. * @pdev_id - device instance id
  80. *
  81. * Unmap IPA RX db vaddr
  82. *
  83. * return QDF_STATUS_SUCCESS
  84. */
  85. static inline QDF_STATUS
  86. cdp_ipa_iounmap_doorbell_vaddr(ol_txrx_soc_handle soc, uint8_t pdev_id)
  87. {
  88. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  89. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  90. "%s invalid instance", __func__);
  91. return QDF_STATUS_E_FAILURE;
  92. }
  93. if (soc->ops->ipa_ops->ipa_iounmap_doorbell_vaddr)
  94. return soc->ops->ipa_ops->ipa_iounmap_doorbell_vaddr(
  95. soc, pdev_id);
  96. return QDF_STATUS_SUCCESS;
  97. }
  98. /**
  99. * cdp_ipa_set_active() - activate/de-ctivate IPA offload path
  100. * @soc - data path soc handle
  101. * @pdev_id - device instance id
  102. * @uc_active - activate or de-activate
  103. * @is_tx - toggle tx or rx data path
  104. *
  105. * activate/de-ctivate IPA offload path
  106. *
  107. * return QDF_STATUS_SUCCESS
  108. */
  109. static inline QDF_STATUS
  110. cdp_ipa_set_active(ol_txrx_soc_handle soc, uint8_t pdev_id, bool uc_active,
  111. bool is_tx)
  112. {
  113. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  114. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  115. "%s invalid instance", __func__);
  116. return QDF_STATUS_E_FAILURE;
  117. }
  118. if (soc->ops->ipa_ops->ipa_set_active)
  119. return soc->ops->ipa_ops->ipa_set_active(soc, pdev_id,
  120. uc_active, is_tx);
  121. return QDF_STATUS_SUCCESS;
  122. }
  123. /**
  124. * cdp_ipa_op_response() - event handler from FW
  125. * @soc - data path soc handle
  126. * @pdev_id - device instance id
  127. * @op_msg - event contents from firmware
  128. *
  129. * event handler from FW
  130. *
  131. * return QDF_STATUS_SUCCESS
  132. */
  133. static inline QDF_STATUS
  134. cdp_ipa_op_response(ol_txrx_soc_handle soc, uint8_t pdev_id, uint8_t *op_msg)
  135. {
  136. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  137. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  138. "%s invalid instance", __func__);
  139. return QDF_STATUS_E_FAILURE;
  140. }
  141. if (soc->ops->ipa_ops->ipa_op_response)
  142. return soc->ops->ipa_ops->ipa_op_response(soc, pdev_id, op_msg);
  143. return QDF_STATUS_SUCCESS;
  144. }
  145. /**
  146. * cdp_ipa_register_op_cb() - register event handler function pointer
  147. * @soc - data path soc handle
  148. * @pdev_id - device instance id
  149. * @op_cb - event handler callback function pointer
  150. * @usr_ctxt - user context to registered
  151. *
  152. * register event handler function pointer
  153. *
  154. * return QDF_STATUS_SUCCESS
  155. */
  156. static inline QDF_STATUS
  157. cdp_ipa_register_op_cb(ol_txrx_soc_handle soc, uint8_t pdev_id,
  158. ipa_uc_op_cb_type op_cb, void *usr_ctxt)
  159. {
  160. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  161. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  162. "%s invalid instance", __func__);
  163. return QDF_STATUS_E_FAILURE;
  164. }
  165. if (soc->ops->ipa_ops->ipa_register_op_cb)
  166. return soc->ops->ipa_ops->ipa_register_op_cb(soc, pdev_id,
  167. op_cb, usr_ctxt);
  168. return QDF_STATUS_SUCCESS;
  169. }
  170. /**
  171. * cdp_ipa_deregister_op_cb() - deregister event handler function pointer
  172. * @soc - data path soc handle
  173. * @pdev_id - device instance id
  174. *
  175. * Deregister event handler function pointer from pdev
  176. *
  177. * return QDF_STATUS_SUCCESS
  178. */
  179. static inline
  180. void cdp_ipa_deregister_op_cb(ol_txrx_soc_handle soc, uint8_t pdev_id)
  181. {
  182. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  183. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  184. "%s invalid instance", __func__);
  185. return;
  186. }
  187. if (soc->ops->ipa_ops->ipa_deregister_op_cb)
  188. soc->ops->ipa_ops->ipa_deregister_op_cb(soc, pdev_id);
  189. }
  190. /**
  191. * cdp_ipa_get_stat() - get IPA data path stats from FW
  192. * @soc - data path soc handle
  193. * @pdev_id - device instance id
  194. *
  195. * get IPA data path stats from FW async
  196. *
  197. * return QDF_STATUS_SUCCESS
  198. */
  199. static inline QDF_STATUS
  200. cdp_ipa_get_stat(ol_txrx_soc_handle soc, uint8_t pdev_id)
  201. {
  202. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  203. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  204. "%s invalid instance", __func__);
  205. return QDF_STATUS_E_FAILURE;
  206. }
  207. if (soc->ops->ipa_ops->ipa_get_stat)
  208. return soc->ops->ipa_ops->ipa_get_stat(soc, pdev_id);
  209. return QDF_STATUS_SUCCESS;
  210. }
  211. /**
  212. * cdp_tx_send_ipa_data_frame() - send IPA data frame
  213. * @soc - data path soc handle
  214. * @vdev_id: vdev id
  215. * @skb: skb
  216. *
  217. * Return: skb/ NULL is for success
  218. */
  219. static inline qdf_nbuf_t cdp_ipa_tx_send_data_frame(ol_txrx_soc_handle soc,
  220. uint8_t vdev_id,
  221. qdf_nbuf_t skb)
  222. {
  223. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  224. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  225. "%s invalid instance", __func__);
  226. return skb;
  227. }
  228. if (soc->ops->ipa_ops->ipa_tx_data_frame)
  229. return soc->ops->ipa_ops->ipa_tx_data_frame(soc, vdev_id, skb);
  230. return skb;
  231. }
  232. /**
  233. * cdp_ipa_set_uc_tx_partition_base() - set tx packet partition base
  234. * @soc - data path soc handle
  235. * @cfg_pdev: physical device instance config
  236. * @value: partition base value
  237. *
  238. * Return: QDF_STATUS
  239. */
  240. static inline QDF_STATUS
  241. cdp_ipa_set_uc_tx_partition_base(ol_txrx_soc_handle soc,
  242. struct cdp_cfg *cfg_pdev, uint32_t value)
  243. {
  244. if (!soc || !soc->ops || !soc->ops->ipa_ops || !cfg_pdev) {
  245. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  246. "%s invalid instance", __func__);
  247. return QDF_STATUS_E_FAILURE;
  248. }
  249. if (soc->ops->ipa_ops->ipa_set_uc_tx_partition_base)
  250. soc->ops->ipa_ops->ipa_set_uc_tx_partition_base(cfg_pdev,
  251. value);
  252. return QDF_STATUS_SUCCESS;
  253. }
  254. #ifdef FEATURE_METERING
  255. /**
  256. * cdp_ipa_uc_get_share_stats() - get Tx/Rx byte stats from FW
  257. * @soc - data path soc handle
  258. * @pdev_id: physical device instance number
  259. * @value: reset stats
  260. *
  261. * Return: QDF_STATUS
  262. */
  263. static inline QDF_STATUS
  264. cdp_ipa_uc_get_share_stats(ol_txrx_soc_handle soc, uint8_t pdev_id,
  265. uint8_t value)
  266. {
  267. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  268. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  269. "%s invalid instance", __func__);
  270. return QDF_STATUS_E_FAILURE;
  271. }
  272. if (soc->ops->ipa_ops->ipa_uc_get_share_stats)
  273. return soc->ops->ipa_ops->ipa_uc_get_share_stats(soc, pdev_id,
  274. value);
  275. return QDF_STATUS_SUCCESS;
  276. }
  277. /**
  278. * cdp_ipa_uc_set_quota() - set quota limit to FW
  279. * @soc - data path soc handle
  280. * @pdev_id: physical device instance number
  281. * @value: quota limit bytes
  282. *
  283. * Return: QDF_STATUS
  284. */
  285. static inline QDF_STATUS
  286. cdp_ipa_uc_set_quota(ol_txrx_soc_handle soc, uint8_t pdev_id, uint64_t value)
  287. {
  288. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  289. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  290. "%s invalid instance", __func__);
  291. return QDF_STATUS_E_FAILURE;
  292. }
  293. if (soc->ops->ipa_ops->ipa_uc_set_quota)
  294. return soc->ops->ipa_ops->ipa_uc_set_quota(soc, pdev_id, value);
  295. return QDF_STATUS_SUCCESS;
  296. }
  297. #endif
  298. /**
  299. * cdp_ipa_enable_autonomy() - Enable autonomy RX data path
  300. * @soc: data path soc handle
  301. * @pdev_id: physical device instance number
  302. *
  303. * IPA Data path is enabled and resumed.
  304. * All autonomy data path elements are ready to deliver packet
  305. * All RX packet should routed to IPA_REO ring, then IPA can receive packet
  306. * from WLAN
  307. *
  308. * Return: QDF_STATUS
  309. */
  310. static inline QDF_STATUS
  311. cdp_ipa_enable_autonomy(ol_txrx_soc_handle soc, uint8_t pdev_id)
  312. {
  313. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  314. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  315. "%s invalid instance", __func__);
  316. return QDF_STATUS_E_FAILURE;
  317. }
  318. if (soc->ops->ipa_ops->ipa_enable_autonomy)
  319. return soc->ops->ipa_ops->ipa_enable_autonomy(soc, pdev_id);
  320. return QDF_STATUS_SUCCESS;
  321. }
  322. /**
  323. * cdp_ipa_disable_autonomy() - Disable autonomy RX data path
  324. * @soc: data path soc handle
  325. * @pdev_id: physical device instance number
  326. *
  327. * IPA Data path is enabled and resumed.
  328. * All autonomy datapath elements are ready to deliver packet
  329. * All RX packet should routed to IPA_REO ring, then IPA can receive packet
  330. * from WLAN
  331. *
  332. * Return: QDF_STATUS
  333. */
  334. static inline QDF_STATUS
  335. cdp_ipa_disable_autonomy(ol_txrx_soc_handle soc, uint8_t pdev_id)
  336. {
  337. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  338. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  339. "%s invalid instance", __func__);
  340. return QDF_STATUS_E_FAILURE;
  341. }
  342. if (soc->ops->ipa_ops->ipa_disable_autonomy)
  343. return soc->ops->ipa_ops->ipa_disable_autonomy(soc, pdev_id);
  344. return QDF_STATUS_SUCCESS;
  345. }
  346. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)) || \
  347. defined(CONFIG_IPA_WDI_UNIFIED_API)
  348. /**
  349. * cdp_ipa_setup() - Setup and connect IPA pipes
  350. * @soc: data path soc handle
  351. * @pdev_id: handle to the device instance number
  352. * @ipa_i2w_cb: IPA to WLAN callback
  353. * @ipa_w2i_cb: WLAN to IPA callback
  354. * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
  355. * @ipa_desc_size: IPA descriptor size
  356. * @ipa_priv: handle to the HTT instance
  357. * @is_rm_enabled: Is IPA RM enabled or not
  358. * @tx_pipe_handle: pointer to Tx pipe handle
  359. * @rx_pipe_handle: pointer to Rx pipe handle
  360. * @is_smmu_enabled: Is SMMU enabled or not
  361. * @sys_in: parameters to setup sys pipe in mcc mode
  362. * @over_gsi: Is IPA using GSI
  363. * @hdl: IPA handle
  364. * @id: IPA instance id
  365. *
  366. * Return: QDF_STATUS
  367. */
  368. static inline QDF_STATUS
  369. cdp_ipa_setup(ol_txrx_soc_handle soc, uint8_t pdev_id, void *ipa_i2w_cb,
  370. void *ipa_w2i_cb, void *ipa_wdi_meter_notifier_cb,
  371. uint32_t ipa_desc_size, void *ipa_priv, bool is_rm_enabled,
  372. uint32_t *tx_pipe_handle, uint32_t *rx_pipe_handle,
  373. bool is_smmu_enabled, qdf_ipa_sys_connect_params_t *sys_in,
  374. bool over_gsi, qdf_ipa_wdi_hdl_t hdl, qdf_ipa_wdi_hdl_t id)
  375. {
  376. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  377. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  378. "%s invalid instance", __func__);
  379. return QDF_STATUS_E_FAILURE;
  380. }
  381. if (soc->ops->ipa_ops->ipa_setup)
  382. return soc->ops->ipa_ops->ipa_setup(soc, pdev_id, ipa_i2w_cb,
  383. ipa_w2i_cb,
  384. ipa_wdi_meter_notifier_cb,
  385. ipa_desc_size, ipa_priv,
  386. is_rm_enabled,
  387. tx_pipe_handle,
  388. rx_pipe_handle,
  389. is_smmu_enabled,
  390. sys_in, over_gsi, hdl, id);
  391. return QDF_STATUS_SUCCESS;
  392. }
  393. #else /* CONFIG_IPA_WDI_UNIFIED_API */
  394. /**
  395. * cdp_ipa_setup() - Setup and connect IPA pipes
  396. * @soc: data path soc handle
  397. * @pdev_id: handle to the device instance number
  398. * @ipa_i2w_cb: IPA to WLAN callback
  399. * @ipa_w2i_cb: WLAN to IPA callback
  400. * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
  401. * @ipa_desc_size: IPA descriptor size
  402. * @ipa_priv: handle to the HTT instance
  403. * @is_rm_enabled: Is IPA RM enabled or not
  404. * @tx_pipe_handle: pointer to Tx pipe handle
  405. * @rx_pipe_handle: pointer to Rx pipe handle
  406. *
  407. * Return: QDF_STATUS
  408. */
  409. static inline QDF_STATUS
  410. cdp_ipa_setup(ol_txrx_soc_handle soc, uint8_t pdev_id, void *ipa_i2w_cb,
  411. void *ipa_w2i_cb, void *ipa_wdi_meter_notifier_cb,
  412. uint32_t ipa_desc_size, void *ipa_priv, bool is_rm_enabled,
  413. uint32_t *tx_pipe_handle, uint32_t *rx_pipe_handle)
  414. {
  415. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  416. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  417. "%s invalid instance", __func__);
  418. return QDF_STATUS_E_FAILURE;
  419. }
  420. if (soc->ops->ipa_ops->ipa_setup)
  421. return soc->ops->ipa_ops->ipa_setup(soc, pdev_id, ipa_i2w_cb,
  422. ipa_w2i_cb,
  423. ipa_wdi_meter_notifier_cb,
  424. ipa_desc_size, ipa_priv,
  425. is_rm_enabled,
  426. tx_pipe_handle,
  427. rx_pipe_handle);
  428. return QDF_STATUS_SUCCESS;
  429. }
  430. #endif /* CONFIG_IPA_WDI_UNIFIED_API */
  431. /**
  432. * cdp_ipa_cleanup() - Disconnect IPA pipes
  433. * @soc: data path soc handle
  434. * @pdev_id: handle to the device instance number
  435. * @tx_pipe_handle: Tx pipe handle
  436. * @rx_pipe_handle: Rx pipe handle
  437. * @hdl: IPA handle
  438. *
  439. * Return: QDF_STATUS
  440. */
  441. static inline QDF_STATUS
  442. cdp_ipa_cleanup(ol_txrx_soc_handle soc, uint8_t pdev_id,
  443. uint32_t tx_pipe_handle, uint32_t rx_pipe_handle,
  444. qdf_ipa_wdi_hdl_t hdl)
  445. {
  446. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  447. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  448. "%s invalid instance", __func__);
  449. return QDF_STATUS_E_FAILURE;
  450. }
  451. if (soc->ops->ipa_ops->ipa_cleanup)
  452. return soc->ops->ipa_ops->ipa_cleanup(soc, pdev_id,
  453. tx_pipe_handle,
  454. rx_pipe_handle, hdl);
  455. return QDF_STATUS_SUCCESS;
  456. }
  457. /**
  458. * cdp_ipa_setup_iface() - Setup IPA header and register interface
  459. * @soc: data path soc handle
  460. * @ifname: Interface name
  461. * @mac_addr: Interface MAC address
  462. * @prod_client: IPA prod client type
  463. * @cons_client: IPA cons client type
  464. * @session_id: Session ID
  465. * @is_ipv6_enabled: Is IPV6 enabled or not
  466. * @hdl: IPA handle
  467. *
  468. * Return: QDF_STATUS
  469. */
  470. static inline QDF_STATUS
  471. cdp_ipa_setup_iface(ol_txrx_soc_handle soc, char *ifname, uint8_t *mac_addr,
  472. qdf_ipa_client_type_t prod_client,
  473. qdf_ipa_client_type_t cons_client,
  474. uint8_t session_id, bool is_ipv6_enabled,
  475. qdf_ipa_wdi_hdl_t hdl)
  476. {
  477. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  478. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  479. "%s invalid instance", __func__);
  480. return QDF_STATUS_E_FAILURE;
  481. }
  482. if (soc->ops->ipa_ops->ipa_setup_iface)
  483. return soc->ops->ipa_ops->ipa_setup_iface(ifname, mac_addr,
  484. prod_client,
  485. cons_client,
  486. session_id,
  487. is_ipv6_enabled,
  488. hdl);
  489. return QDF_STATUS_SUCCESS;
  490. }
  491. /**
  492. * cdp_ipa_cleanup_iface() - Cleanup IPA header and deregister interface
  493. * @soc: data path soc handle
  494. * @ifname: Interface name
  495. * @is_ipv6_enabled: Is IPV6 enabled or not
  496. * @hdl: IPA handle
  497. *
  498. * Return: QDF_STATUS
  499. */
  500. static inline QDF_STATUS
  501. cdp_ipa_cleanup_iface(ol_txrx_soc_handle soc, char *ifname,
  502. bool is_ipv6_enabled, qdf_ipa_wdi_hdl_t hdl)
  503. {
  504. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  505. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  506. "%s invalid instance", __func__);
  507. return QDF_STATUS_E_FAILURE;
  508. }
  509. if (soc->ops->ipa_ops->ipa_cleanup_iface)
  510. return soc->ops->ipa_ops->ipa_cleanup_iface(ifname,
  511. is_ipv6_enabled,
  512. hdl);
  513. return QDF_STATUS_SUCCESS;
  514. }
  515. /**
  516. * cdp_ipa_uc_enable_pipes() - Enable and resume traffic on Tx/Rx pipes
  517. * @soc - data path soc handle
  518. * @pdev_id - device instance id
  519. * @hdl: IPA handle
  520. *
  521. * Return: QDF_STATUS
  522. */
  523. static inline QDF_STATUS
  524. cdp_ipa_enable_pipes(ol_txrx_soc_handle soc, uint8_t pdev_id,
  525. qdf_ipa_wdi_hdl_t hdl)
  526. {
  527. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  528. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  529. "%s invalid instance", __func__);
  530. return QDF_STATUS_E_FAILURE;
  531. }
  532. if (soc->ops->ipa_ops->ipa_enable_pipes)
  533. return soc->ops->ipa_ops->ipa_enable_pipes(soc, pdev_id, hdl);
  534. return QDF_STATUS_SUCCESS;
  535. }
  536. /**
  537. * cdp_ipa_uc_disable_pipes() - Suspend traffic and disable Tx/Rx pipes
  538. * @soc: data path soc handle
  539. * @pdev_id - device instance id
  540. * @hdl: IPA handle
  541. *
  542. * Return: QDF_STATUS
  543. */
  544. static inline QDF_STATUS
  545. cdp_ipa_disable_pipes(ol_txrx_soc_handle soc, uint8_t pdev_id,
  546. qdf_ipa_wdi_hdl_t hdl)
  547. {
  548. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  549. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  550. "%s invalid instance", __func__);
  551. return QDF_STATUS_E_FAILURE;
  552. }
  553. if (soc->ops->ipa_ops->ipa_disable_pipes)
  554. return soc->ops->ipa_ops->ipa_disable_pipes(soc, pdev_id, hdl);
  555. return QDF_STATUS_SUCCESS;
  556. }
  557. /**
  558. * cdp_ipa_set_perf_level() - Set IPA clock bandwidth based on data rates
  559. * @soc: data path soc handle
  560. * @client: WLAN Client ID
  561. * @max_supported_bw_mbps: Maximum bandwidth needed (in Mbps)
  562. * @hdl: IPA handle
  563. *
  564. * Return: 0 on success, negative errno on error
  565. */
  566. static inline QDF_STATUS
  567. cdp_ipa_set_perf_level(ol_txrx_soc_handle soc, int client,
  568. uint32_t max_supported_bw_mbps, qdf_ipa_wdi_hdl_t hdl)
  569. {
  570. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  571. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  572. "%s invalid instance", __func__);
  573. return QDF_STATUS_E_FAILURE;
  574. }
  575. if (soc->ops->ipa_ops->ipa_set_perf_level)
  576. return soc->ops->ipa_ops->ipa_set_perf_level(client,
  577. max_supported_bw_mbps, hdl);
  578. return QDF_STATUS_SUCCESS;
  579. }
  580. /**
  581. * cdp_ipa_rx_intrabss_fwd() - Perform intra-bss fwd for IPA RX path
  582. *
  583. * @soc: data path soc handle
  584. * @vdev_id: vdev id
  585. * @nbuf: pointer to skb of ethernet packet received from IPA RX path
  586. * @fwd_success: pointer to indicate if skb succeeded in intra-bss TX
  587. *
  588. * This function performs intra-bss forwarding for WDI 3.0 IPA RX path.
  589. *
  590. * Return: true if packet is intra-bss fwd-ed and no need to pass to
  591. * network stack. false if packet needs to be passed to network stack.
  592. */
  593. static inline bool
  594. cdp_ipa_rx_intrabss_fwd(ol_txrx_soc_handle soc, uint8_t vdev_id,
  595. qdf_nbuf_t nbuf, bool *fwd_success)
  596. {
  597. if (!soc || !soc->ops || !soc->ops->ipa_ops || !fwd_success) {
  598. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  599. "%s invalid instance", __func__);
  600. return QDF_STATUS_E_FAILURE;
  601. }
  602. if (soc->ops->ipa_ops->ipa_rx_intrabss_fwd)
  603. return soc->ops->ipa_ops->ipa_rx_intrabss_fwd(soc, vdev_id,
  604. nbuf,
  605. fwd_success);
  606. /* Fall back to pass up to stack */
  607. return false;
  608. }
  609. /**
  610. * cdp_ipa_tx_buf_smmu_mapping() - Create SMMU mappings for Tx
  611. * buffers allocated to IPA
  612. * @soc: data path soc handle
  613. * @pdev_id: device instance id
  614. *
  615. * Create SMMU mappings for Tx buffers allocated to IPA
  616. *
  617. * return QDF_STATUS_SUCCESS
  618. */
  619. static inline QDF_STATUS
  620. cdp_ipa_tx_buf_smmu_mapping(ol_txrx_soc_handle soc, uint8_t pdev_id)
  621. {
  622. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  623. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  624. "%s invalid instance", __func__);
  625. return QDF_STATUS_E_FAILURE;
  626. }
  627. if (soc->ops->ipa_ops->ipa_tx_buf_smmu_mapping)
  628. return soc->ops->ipa_ops->ipa_tx_buf_smmu_mapping(soc, pdev_id);
  629. return QDF_STATUS_SUCCESS;
  630. }
  631. /**
  632. * cdp_ipa_tx_buf_smmu_unmapping() - Release SMMU mappings for Tx
  633. * buffers allocated to IPA
  634. * @soc: data path soc handle
  635. * @pdev_id: device instance id
  636. *
  637. * Release SMMU mappings for Tx buffers allocated to IPA
  638. *
  639. * return QDF_STATUS_SUCCESS
  640. */
  641. static inline QDF_STATUS
  642. cdp_ipa_tx_buf_smmu_unmapping(ol_txrx_soc_handle soc, uint8_t pdev_id)
  643. {
  644. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  645. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  646. "%s invalid instance", __func__);
  647. return QDF_STATUS_E_FAILURE;
  648. }
  649. if (soc->ops->ipa_ops->ipa_tx_buf_smmu_unmapping)
  650. return soc->ops->ipa_ops->ipa_tx_buf_smmu_unmapping(soc,
  651. pdev_id);
  652. return QDF_STATUS_SUCCESS;
  653. }
  654. #endif /* IPA_OFFLOAD */
  655. #endif /* _CDP_TXRX_IPA_H_ */