cdp_txrx_ipa.h 21 KB

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