cdp_txrx_ipa.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021 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. *
  364. * Return: QDF_STATUS
  365. */
  366. static inline QDF_STATUS
  367. cdp_ipa_setup(ol_txrx_soc_handle soc, uint8_t pdev_id, void *ipa_i2w_cb,
  368. void *ipa_w2i_cb, void *ipa_wdi_meter_notifier_cb,
  369. uint32_t ipa_desc_size, void *ipa_priv, bool is_rm_enabled,
  370. uint32_t *tx_pipe_handle, uint32_t *rx_pipe_handle,
  371. bool is_smmu_enabled, qdf_ipa_sys_connect_params_t *sys_in,
  372. bool over_gsi)
  373. {
  374. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  375. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  376. "%s invalid instance", __func__);
  377. return QDF_STATUS_E_FAILURE;
  378. }
  379. if (soc->ops->ipa_ops->ipa_setup)
  380. return soc->ops->ipa_ops->ipa_setup(soc, pdev_id, ipa_i2w_cb,
  381. ipa_w2i_cb,
  382. ipa_wdi_meter_notifier_cb,
  383. ipa_desc_size, ipa_priv,
  384. is_rm_enabled,
  385. tx_pipe_handle,
  386. rx_pipe_handle,
  387. is_smmu_enabled,
  388. sys_in, over_gsi);
  389. return QDF_STATUS_SUCCESS;
  390. }
  391. #else /* CONFIG_IPA_WDI_UNIFIED_API */
  392. /**
  393. * cdp_ipa_setup() - Setup and connect IPA pipes
  394. * @soc: data path soc handle
  395. * @pdev_id: handle to the device instance number
  396. * @ipa_i2w_cb: IPA to WLAN callback
  397. * @ipa_w2i_cb: WLAN to IPA callback
  398. * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
  399. * @ipa_desc_size: IPA descriptor size
  400. * @ipa_priv: handle to the HTT instance
  401. * @is_rm_enabled: Is IPA RM enabled or not
  402. * @tx_pipe_handle: pointer to Tx pipe handle
  403. * @rx_pipe_handle: pointer to Rx pipe handle
  404. *
  405. * Return: QDF_STATUS
  406. */
  407. static inline QDF_STATUS
  408. cdp_ipa_setup(ol_txrx_soc_handle soc, uint8_t pdev_id, void *ipa_i2w_cb,
  409. void *ipa_w2i_cb, void *ipa_wdi_meter_notifier_cb,
  410. uint32_t ipa_desc_size, void *ipa_priv, bool is_rm_enabled,
  411. uint32_t *tx_pipe_handle, uint32_t *rx_pipe_handle)
  412. {
  413. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  414. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  415. "%s invalid instance", __func__);
  416. return QDF_STATUS_E_FAILURE;
  417. }
  418. if (soc->ops->ipa_ops->ipa_setup)
  419. return soc->ops->ipa_ops->ipa_setup(soc, pdev_id, ipa_i2w_cb,
  420. ipa_w2i_cb,
  421. ipa_wdi_meter_notifier_cb,
  422. ipa_desc_size, ipa_priv,
  423. is_rm_enabled,
  424. tx_pipe_handle,
  425. rx_pipe_handle);
  426. return QDF_STATUS_SUCCESS;
  427. }
  428. #endif /* CONFIG_IPA_WDI_UNIFIED_API */
  429. /**
  430. * cdp_ipa_cleanup() - Disconnect IPA pipes
  431. * @soc: data path soc handle
  432. * @pdev_id: handle to the device instance number
  433. * @tx_pipe_handle: Tx pipe handle
  434. * @rx_pipe_handle: Rx pipe handle
  435. *
  436. * Return: QDF_STATUS
  437. */
  438. static inline QDF_STATUS
  439. cdp_ipa_cleanup(ol_txrx_soc_handle soc, uint8_t pdev_id,
  440. uint32_t tx_pipe_handle, uint32_t rx_pipe_handle)
  441. {
  442. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  443. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  444. "%s invalid instance", __func__);
  445. return QDF_STATUS_E_FAILURE;
  446. }
  447. if (soc->ops->ipa_ops->ipa_cleanup)
  448. return soc->ops->ipa_ops->ipa_cleanup(soc, pdev_id,
  449. tx_pipe_handle,
  450. rx_pipe_handle);
  451. return QDF_STATUS_SUCCESS;
  452. }
  453. /**
  454. * cdp_ipa_setup_iface() - Setup IPA header and register interface
  455. * @soc: data path soc handle
  456. * @ifname: Interface name
  457. * @mac_addr: Interface MAC address
  458. * @prod_client: IPA prod client type
  459. * @cons_client: IPA cons client type
  460. * @session_id: Session ID
  461. * @is_ipv6_enabled: Is IPV6 enabled or not
  462. *
  463. * Return: QDF_STATUS
  464. */
  465. static inline QDF_STATUS
  466. cdp_ipa_setup_iface(ol_txrx_soc_handle soc, char *ifname, uint8_t *mac_addr,
  467. qdf_ipa_client_type_t prod_client,
  468. qdf_ipa_client_type_t cons_client,
  469. uint8_t session_id, bool is_ipv6_enabled)
  470. {
  471. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  472. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  473. "%s invalid instance", __func__);
  474. return QDF_STATUS_E_FAILURE;
  475. }
  476. if (soc->ops->ipa_ops->ipa_setup_iface)
  477. return soc->ops->ipa_ops->ipa_setup_iface(ifname, mac_addr,
  478. prod_client,
  479. cons_client,
  480. session_id,
  481. is_ipv6_enabled);
  482. return QDF_STATUS_SUCCESS;
  483. }
  484. /**
  485. * cdp_ipa_cleanup_iface() - Cleanup IPA header and deregister interface
  486. * @soc: data path soc handle
  487. * @ifname: Interface name
  488. * @is_ipv6_enabled: Is IPV6 enabled or not
  489. *
  490. * Return: QDF_STATUS
  491. */
  492. static inline QDF_STATUS
  493. cdp_ipa_cleanup_iface(ol_txrx_soc_handle soc, char *ifname,
  494. bool is_ipv6_enabled)
  495. {
  496. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  497. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  498. "%s invalid instance", __func__);
  499. return QDF_STATUS_E_FAILURE;
  500. }
  501. if (soc->ops->ipa_ops->ipa_cleanup_iface)
  502. return soc->ops->ipa_ops->ipa_cleanup_iface(ifname,
  503. is_ipv6_enabled);
  504. return QDF_STATUS_SUCCESS;
  505. }
  506. /**
  507. * cdp_ipa_uc_enable_pipes() - Enable and resume traffic on Tx/Rx pipes
  508. * @soc - data path soc handle
  509. * @pdev_id - device instance id
  510. *
  511. * Return: QDF_STATUS
  512. */
  513. static inline QDF_STATUS
  514. cdp_ipa_enable_pipes(ol_txrx_soc_handle soc, uint8_t pdev_id)
  515. {
  516. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  517. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  518. "%s invalid instance", __func__);
  519. return QDF_STATUS_E_FAILURE;
  520. }
  521. if (soc->ops->ipa_ops->ipa_enable_pipes)
  522. return soc->ops->ipa_ops->ipa_enable_pipes(soc, pdev_id);
  523. return QDF_STATUS_SUCCESS;
  524. }
  525. /**
  526. * cdp_ipa_uc_disable_pipes() - Suspend traffic and disable Tx/Rx pipes
  527. * @soc: data path soc handle
  528. * @pdev_id - device instance id
  529. *
  530. * Return: QDF_STATUS
  531. */
  532. static inline QDF_STATUS
  533. cdp_ipa_disable_pipes(ol_txrx_soc_handle soc, uint8_t pdev_id)
  534. {
  535. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  536. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  537. "%s invalid instance", __func__);
  538. return QDF_STATUS_E_FAILURE;
  539. }
  540. if (soc->ops->ipa_ops->ipa_disable_pipes)
  541. return soc->ops->ipa_ops->ipa_disable_pipes(soc, pdev_id);
  542. return QDF_STATUS_SUCCESS;
  543. }
  544. /**
  545. * cdp_ipa_set_perf_level() - Set IPA clock bandwidth based on data rates
  546. * @soc: data path soc handle
  547. * @client: WLAN Client ID
  548. * @max_supported_bw_mbps: Maximum bandwidth needed (in Mbps)
  549. *
  550. * Return: 0 on success, negative errno on error
  551. */
  552. static inline QDF_STATUS
  553. cdp_ipa_set_perf_level(ol_txrx_soc_handle soc, int client,
  554. uint32_t max_supported_bw_mbps)
  555. {
  556. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  557. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  558. "%s invalid instance", __func__);
  559. return QDF_STATUS_E_FAILURE;
  560. }
  561. if (soc->ops->ipa_ops->ipa_set_perf_level)
  562. return soc->ops->ipa_ops->ipa_set_perf_level(client,
  563. max_supported_bw_mbps);
  564. return QDF_STATUS_SUCCESS;
  565. }
  566. /**
  567. * cdp_ipa_rx_intrabss_fwd() - Perform intra-bss fwd for IPA RX path
  568. *
  569. * @soc: data path soc handle
  570. * @vdev_id: vdev id
  571. * @nbuf: pointer to skb of ethernet packet received from IPA RX path
  572. * @fwd_success: pointer to indicate if skb succeeded in intra-bss TX
  573. *
  574. * This function performs intra-bss forwarding for WDI 3.0 IPA RX path.
  575. *
  576. * Return: true if packet is intra-bss fwd-ed and no need to pass to
  577. * network stack. false if packet needs to be passed to network stack.
  578. */
  579. static inline bool
  580. cdp_ipa_rx_intrabss_fwd(ol_txrx_soc_handle soc, uint8_t vdev_id,
  581. qdf_nbuf_t nbuf, bool *fwd_success)
  582. {
  583. if (!soc || !soc->ops || !soc->ops->ipa_ops || !fwd_success) {
  584. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  585. "%s invalid instance", __func__);
  586. return QDF_STATUS_E_FAILURE;
  587. }
  588. if (soc->ops->ipa_ops->ipa_rx_intrabss_fwd)
  589. return soc->ops->ipa_ops->ipa_rx_intrabss_fwd(soc, vdev_id,
  590. nbuf,
  591. fwd_success);
  592. /* Fall back to pass up to stack */
  593. return false;
  594. }
  595. /**
  596. * cdp_ipa_tx_buf_smmu_mapping() - Create SMMU mappings for Tx
  597. * buffers allocated to IPA
  598. * @soc: data path soc handle
  599. * @pdev_id: device instance id
  600. *
  601. * Create SMMU mappings for Tx buffers allocated to IPA
  602. *
  603. * return QDF_STATUS_SUCCESS
  604. */
  605. static inline QDF_STATUS
  606. cdp_ipa_tx_buf_smmu_mapping(ol_txrx_soc_handle soc, uint8_t pdev_id)
  607. {
  608. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  609. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  610. "%s invalid instance", __func__);
  611. return QDF_STATUS_E_FAILURE;
  612. }
  613. if (soc->ops->ipa_ops->ipa_tx_buf_smmu_mapping)
  614. return soc->ops->ipa_ops->ipa_tx_buf_smmu_mapping(soc, pdev_id);
  615. return QDF_STATUS_SUCCESS;
  616. }
  617. /**
  618. * cdp_ipa_tx_buf_smmu_unmapping() - Release SMMU mappings for Tx
  619. * buffers allocated to IPA
  620. * @soc: data path soc handle
  621. * @pdev_id: device instance id
  622. *
  623. * Release 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_unmapping(ol_txrx_soc_handle soc, uint8_t pdev_id)
  629. {
  630. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  631. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  632. "%s invalid instance", __func__);
  633. return QDF_STATUS_E_FAILURE;
  634. }
  635. if (soc->ops->ipa_ops->ipa_tx_buf_smmu_unmapping)
  636. return soc->ops->ipa_ops->ipa_tx_buf_smmu_unmapping(soc,
  637. pdev_id);
  638. return QDF_STATUS_SUCCESS;
  639. }
  640. #endif /* IPA_OFFLOAD */
  641. #endif /* _CDP_TXRX_IPA_H_ */