cdp_txrx_ipa.h 25 KB

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