cdp_txrx_ipa.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. /*
  2. * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. /**
  27. * @file cdp_txrx_ipa.h
  28. * @brief Define the host data path IP Acceleraor API functions
  29. */
  30. #ifndef _CDP_TXRX_IPA_H_
  31. #define _CDP_TXRX_IPA_H_
  32. #ifdef IPA_OFFLOAD
  33. #include <qdf_ipa.h>
  34. #include <cdp_txrx_mob_def.h>
  35. #include "cdp_txrx_handle.h"
  36. /**
  37. * cdp_ipa_get_resource() - Get allocated WLAN resources for IPA data path
  38. * @soc - data path soc handle
  39. * @pdev - device instance pointer
  40. *
  41. * Get allocated WLAN resources for IPA data path
  42. *
  43. * return QDF_STATUS_SUCCESS
  44. */
  45. static inline QDF_STATUS
  46. cdp_ipa_get_resource(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
  47. {
  48. if (!soc || !soc->ops || !soc->ops->ipa_ops || !pdev) {
  49. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  50. "%s invalid instance", __func__);
  51. return QDF_STATUS_E_FAILURE;
  52. }
  53. if (soc->ops->ipa_ops->ipa_get_resource)
  54. return soc->ops->ipa_ops->ipa_get_resource(pdev);
  55. return QDF_STATUS_SUCCESS;
  56. }
  57. /**
  58. * cdp_ipa_set_doorbell_paddr() - give IPA db paddr to FW
  59. * @soc - data path soc handle
  60. * @pdev - device instance pointer
  61. *
  62. * give IPA db paddr to FW
  63. *
  64. * return QDF_STATUS_SUCCESS
  65. */
  66. static inline QDF_STATUS
  67. cdp_ipa_set_doorbell_paddr(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
  68. {
  69. if (!soc || !soc->ops || !soc->ops->ipa_ops || !pdev) {
  70. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  71. "%s invalid instance", __func__);
  72. return QDF_STATUS_E_FAILURE;
  73. }
  74. if (soc->ops->ipa_ops->ipa_set_doorbell_paddr)
  75. return soc->ops->ipa_ops->ipa_set_doorbell_paddr(pdev);
  76. return QDF_STATUS_SUCCESS;
  77. }
  78. /**
  79. * cdp_ipa_set_active() - activate/de-ctivate IPA offload path
  80. * @soc - data path soc handle
  81. * @pdev - device instance pointer
  82. * @uc_active - activate or de-activate
  83. * @is_tx - toggle tx or rx data path
  84. *
  85. * activate/de-ctivate IPA offload path
  86. *
  87. * return QDF_STATUS_SUCCESS
  88. */
  89. static inline QDF_STATUS
  90. cdp_ipa_set_active(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  91. bool uc_active, bool is_tx)
  92. {
  93. if (!soc || !soc->ops || !soc->ops->ipa_ops || !pdev) {
  94. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  95. "%s invalid instance", __func__);
  96. return QDF_STATUS_E_FAILURE;
  97. }
  98. if (soc->ops->ipa_ops->ipa_set_active)
  99. return soc->ops->ipa_ops->ipa_set_active(pdev, uc_active,
  100. is_tx);
  101. return QDF_STATUS_SUCCESS;
  102. }
  103. /**
  104. * cdp_ipa_op_response() - event handler from FW
  105. * @soc - data path soc handle
  106. * @pdev - device instance pointer
  107. * @op_msg - event contents from firmware
  108. *
  109. * event handler from FW
  110. *
  111. * return QDF_STATUS_SUCCESS
  112. */
  113. static inline QDF_STATUS
  114. cdp_ipa_op_response(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  115. uint8_t *op_msg)
  116. {
  117. if (!soc || !soc->ops || !soc->ops->ipa_ops || !pdev) {
  118. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  119. "%s invalid instance", __func__);
  120. return QDF_STATUS_E_FAILURE;
  121. }
  122. if (soc->ops->ipa_ops->ipa_op_response)
  123. return soc->ops->ipa_ops->ipa_op_response(pdev, op_msg);
  124. return QDF_STATUS_SUCCESS;
  125. }
  126. /**
  127. * cdp_ipa_register_op_cb() - register event handler function pointer
  128. * @soc - data path soc handle
  129. * @pdev - device instance pointer
  130. * @op_cb - event handler callback function pointer
  131. * @usr_ctxt - user context to registered
  132. *
  133. * register event handler function pointer
  134. *
  135. * return QDF_STATUS_SUCCESS
  136. */
  137. static inline QDF_STATUS
  138. cdp_ipa_register_op_cb(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  139. ipa_uc_op_cb_type op_cb, void *usr_ctxt)
  140. {
  141. if (!soc || !soc->ops || !soc->ops->ipa_ops || !pdev) {
  142. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  143. "%s invalid instance", __func__);
  144. return QDF_STATUS_E_FAILURE;
  145. }
  146. if (soc->ops->ipa_ops->ipa_register_op_cb)
  147. return soc->ops->ipa_ops->ipa_register_op_cb(pdev, op_cb,
  148. usr_ctxt);
  149. return QDF_STATUS_SUCCESS;
  150. }
  151. /**
  152. * cdp_ipa_get_stat() - get IPA data path stats from FW
  153. * @soc - data path soc handle
  154. * @pdev - device instance pointer
  155. *
  156. * get IPA data path stats from FW async
  157. *
  158. * return QDF_STATUS_SUCCESS
  159. */
  160. static inline QDF_STATUS
  161. cdp_ipa_get_stat(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
  162. {
  163. if (!soc || !soc->ops || !soc->ops->ipa_ops || !pdev) {
  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_get_stat)
  169. return soc->ops->ipa_ops->ipa_get_stat(pdev);
  170. return QDF_STATUS_SUCCESS;
  171. }
  172. /**
  173. * cdp_tx_send_ipa_data_frame() - send IPA data frame
  174. * @vdev: vdev
  175. * @skb: skb
  176. *
  177. * Return: skb/ NULL is for success
  178. */
  179. static inline qdf_nbuf_t cdp_ipa_tx_send_data_frame(ol_txrx_soc_handle soc,
  180. struct cdp_vdev *vdev, qdf_nbuf_t skb)
  181. {
  182. if (!soc || !soc->ops || !soc->ops->ipa_ops || !vdev) {
  183. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  184. "%s invalid instance", __func__);
  185. return skb;
  186. }
  187. if (soc->ops->ipa_ops->ipa_tx_data_frame)
  188. return soc->ops->ipa_ops->ipa_tx_data_frame(vdev, skb);
  189. return skb;
  190. }
  191. /**
  192. * cdp_ipa_set_uc_tx_partition_base() - set tx packet partition base
  193. * @pdev: physical device instance
  194. * @value: partition base value
  195. *
  196. * Return: QDF_STATUS
  197. */
  198. static inline QDF_STATUS
  199. cdp_ipa_set_uc_tx_partition_base(ol_txrx_soc_handle soc,
  200. struct cdp_cfg *cfg_pdev, uint32_t value)
  201. {
  202. if (!soc || !soc->ops || !soc->ops->ipa_ops || !cfg_pdev) {
  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_set_uc_tx_partition_base)
  208. soc->ops->ipa_ops->ipa_set_uc_tx_partition_base(cfg_pdev,
  209. value);
  210. return QDF_STATUS_SUCCESS;
  211. }
  212. #ifdef FEATURE_METERING
  213. /**
  214. * cdp_ipa_uc_get_share_stats() - get Tx/Rx byte stats from FW
  215. * @pdev: physical device instance
  216. * @value: reset stats
  217. *
  218. * Return: QDF_STATUS
  219. */
  220. static inline QDF_STATUS
  221. cdp_ipa_uc_get_share_stats(ol_txrx_soc_handle soc,
  222. struct cdp_pdev *pdev, uint8_t value)
  223. {
  224. if (!soc || !soc->ops || !soc->ops->ipa_ops || !pdev) {
  225. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  226. "%s invalid instance", __func__);
  227. return QDF_STATUS_E_FAILURE;
  228. }
  229. if (soc->ops->ipa_ops->ipa_uc_get_share_stats)
  230. return soc->ops->ipa_ops->ipa_uc_get_share_stats(pdev,
  231. value);
  232. return QDF_STATUS_SUCCESS;
  233. }
  234. /**
  235. * cdp_ipa_uc_set_quota() - set quota limit to FW
  236. * @pdev: physical device instance
  237. * @value: quota limit bytes
  238. *
  239. * Return: QDF_STATUS
  240. */
  241. static inline QDF_STATUS
  242. cdp_ipa_uc_set_quota(ol_txrx_soc_handle soc,
  243. struct cdp_pdev *pdev, uint64_t value)
  244. {
  245. if (!soc || !soc->ops || !soc->ops->ipa_ops || !pdev) {
  246. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  247. "%s invalid instance", __func__);
  248. return QDF_STATUS_E_FAILURE;
  249. }
  250. if (soc->ops->ipa_ops->ipa_uc_set_quota)
  251. return soc->ops->ipa_ops->ipa_uc_set_quota(pdev,
  252. value);
  253. return QDF_STATUS_SUCCESS;
  254. }
  255. #endif
  256. /**
  257. * cdp_ipa_enable_autonomy() - Enable autonomy RX data path
  258. * @soc: data path soc handle
  259. * @pdev: handle to the device instance
  260. *
  261. * IPA Data path is enabled and resumed.
  262. * All autonomy data path elements are ready to deliver packet
  263. * All RX packet should routed to IPA_REO ring, then IPA can receive packet
  264. * from WLAN
  265. *
  266. * Return: QDF_STATUS
  267. */
  268. static inline QDF_STATUS
  269. cdp_ipa_enable_autonomy(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
  270. {
  271. if (!soc || !soc->ops || !soc->ops->ipa_ops || !pdev) {
  272. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  273. "%s invalid instance", __func__);
  274. return QDF_STATUS_E_FAILURE;
  275. }
  276. if (soc->ops->ipa_ops->ipa_enable_autonomy)
  277. return soc->ops->ipa_ops->ipa_enable_autonomy(pdev);
  278. return QDF_STATUS_SUCCESS;
  279. }
  280. /**
  281. * cdp_ipa_disable_autonomy() - Disable autonomy RX data path
  282. * @soc: data path soc handle
  283. * @pdev: handle to the device instance
  284. *
  285. * IPA Data path is enabled and resumed.
  286. * All autonomy datapath elements are ready to deliver packet
  287. * All RX packet should routed to IPA_REO ring, then IPA can receive packet
  288. * from WLAN
  289. *
  290. * Return: QDF_STATUS
  291. */
  292. static inline QDF_STATUS
  293. cdp_ipa_disable_autonomy(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
  294. {
  295. if (!soc || !soc->ops || !soc->ops->ipa_ops || !pdev) {
  296. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  297. "%s invalid instance", __func__);
  298. return QDF_STATUS_E_FAILURE;
  299. }
  300. if (soc->ops->ipa_ops->ipa_enable_autonomy)
  301. return soc->ops->ipa_ops->ipa_disable_autonomy(pdev);
  302. return QDF_STATUS_SUCCESS;
  303. }
  304. /**
  305. * cdp_ipa_setup() - Setup and connect IPA pipes
  306. * @soc: data path soc handle
  307. * @pdev: handle to the device instance
  308. * @ipa_i2w_cb: IPA to WLAN callback
  309. * @ipa_w2i_cb: WLAN to IPA callback
  310. * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
  311. * @ipa_desc_size: IPA descriptor size
  312. * @ipa_priv: handle to the HTT instance
  313. * @is_rm_enabled: Is IPA RM enabled or not
  314. * @tx_pipe_handle: pointer to Tx pipe handle
  315. * @rx_pipe_handle: pointer to Rx pipe handle
  316. *
  317. * Return: QDF_STATUS
  318. */
  319. static inline QDF_STATUS
  320. cdp_ipa_setup(ol_txrx_soc_handle soc, struct cdp_pdev *pdev, void *ipa_i2w_cb,
  321. void *ipa_w2i_cb, void *ipa_wdi_meter_notifier_cb,
  322. uint32_t ipa_desc_size, void *ipa_priv, bool is_rm_enabled,
  323. uint32_t *tx_pipe_handle, uint32_t *rx_pipe_handle)
  324. {
  325. if (!soc || !soc->ops || !soc->ops->ipa_ops || !pdev) {
  326. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  327. "%s invalid instance", __func__);
  328. return QDF_STATUS_E_FAILURE;
  329. }
  330. if (soc->ops->ipa_ops->ipa_setup)
  331. return soc->ops->ipa_ops->ipa_setup(pdev, ipa_i2w_cb,
  332. ipa_w2i_cb,
  333. ipa_wdi_meter_notifier_cb,
  334. ipa_desc_size, ipa_priv,
  335. is_rm_enabled,
  336. tx_pipe_handle,
  337. rx_pipe_handle);
  338. return QDF_STATUS_SUCCESS;
  339. }
  340. /**
  341. * cdp_ipa_cleanup() - Disconnect IPA pipes
  342. * @soc: data path soc handle
  343. * @tx_pipe_handle: Tx pipe handle
  344. * @rx_pipe_handle: Rx pipe handle
  345. *
  346. * Return: QDF_STATUS
  347. */
  348. static inline QDF_STATUS
  349. cdp_ipa_cleanup(ol_txrx_soc_handle soc, uint32_t tx_pipe_handle,
  350. uint32_t rx_pipe_handle)
  351. {
  352. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  353. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  354. "%s invalid instance", __func__);
  355. return QDF_STATUS_E_FAILURE;
  356. }
  357. if (soc->ops->ipa_ops->ipa_cleanup)
  358. return soc->ops->ipa_ops->ipa_cleanup(tx_pipe_handle,
  359. rx_pipe_handle);
  360. return QDF_STATUS_SUCCESS;
  361. }
  362. /**
  363. * cdp_ipa_setup_iface() - Setup IPA header and register interface
  364. * @soc: data path soc handle
  365. * @ifname: Interface name
  366. * @mac_addr: Interface MAC address
  367. * @prod_client: IPA prod client type
  368. * @cons_client: IPA cons client type
  369. * @session_id: Session ID
  370. * @is_ipv6_enabled: Is IPV6 enabled or not
  371. *
  372. * Return: QDF_STATUS
  373. */
  374. static inline QDF_STATUS
  375. cdp_ipa_setup_iface(ol_txrx_soc_handle soc, char *ifname, uint8_t *mac_addr,
  376. qdf_ipa_client_type_t prod_client,
  377. qdf_ipa_client_type_t cons_client,
  378. uint8_t session_id, bool is_ipv6_enabled)
  379. {
  380. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  381. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  382. "%s invalid instance", __func__);
  383. return QDF_STATUS_E_FAILURE;
  384. }
  385. if (soc->ops->ipa_ops->ipa_setup_iface)
  386. return soc->ops->ipa_ops->ipa_setup_iface(ifname, mac_addr,
  387. prod_client,
  388. cons_client,
  389. session_id,
  390. is_ipv6_enabled);
  391. return QDF_STATUS_SUCCESS;
  392. }
  393. /**
  394. * cdp_ipa_cleanup_iface() - Cleanup IPA header and deregister interface
  395. * @soc: data path soc handle
  396. * @ifname: Interface name
  397. * @is_ipv6_enabled: Is IPV6 enabled or not
  398. *
  399. * Return: QDF_STATUS
  400. */
  401. static inline QDF_STATUS
  402. cdp_ipa_cleanup_iface(ol_txrx_soc_handle soc, char *ifname,
  403. bool is_ipv6_enabled)
  404. {
  405. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  406. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  407. "%s invalid instance", __func__);
  408. return QDF_STATUS_E_FAILURE;
  409. }
  410. if (soc->ops->ipa_ops->ipa_cleanup_iface)
  411. return soc->ops->ipa_ops->ipa_cleanup_iface(ifname,
  412. is_ipv6_enabled);
  413. return QDF_STATUS_SUCCESS;
  414. }
  415. /**
  416. * cdp_ipa_uc_enable_pipes() - Enable and resume traffic on Tx/Rx pipes
  417. * @soc: data path soc handle
  418. * @pdev: handle to the device instance
  419. *
  420. * Return: QDF_STATUS
  421. */
  422. static inline QDF_STATUS
  423. cdp_ipa_enable_pipes(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
  424. {
  425. if (!soc || !soc->ops || !soc->ops->ipa_ops || !pdev) {
  426. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  427. "%s invalid instance", __func__);
  428. return QDF_STATUS_E_FAILURE;
  429. }
  430. if (soc->ops->ipa_ops->ipa_enable_pipes)
  431. return soc->ops->ipa_ops->ipa_enable_pipes(pdev);
  432. return QDF_STATUS_SUCCESS;
  433. }
  434. /**
  435. * cdp_ipa_uc_disable_pipes() - Suspend traffic and disable Tx/Rx pipes
  436. * @soc: data path soc handle
  437. * @pdev: handle to the device instance
  438. *
  439. * Return: QDF_STATUS
  440. */
  441. static inline QDF_STATUS
  442. cdp_ipa_disable_pipes(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
  443. {
  444. if (!soc || !soc->ops || !soc->ops->ipa_ops || !pdev) {
  445. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  446. "%s invalid instance", __func__);
  447. return QDF_STATUS_E_FAILURE;
  448. }
  449. if (soc->ops->ipa_ops->ipa_disable_pipes)
  450. return soc->ops->ipa_ops->ipa_disable_pipes(pdev);
  451. return QDF_STATUS_SUCCESS;
  452. }
  453. /**
  454. * cdp_ipa_set_perf_level() - Set IPA clock bandwidth based on data rates
  455. * @soc: data path soc handle
  456. * @client: WLAN Client ID
  457. * @max_supported_bw_mbps: Maximum bandwidth needed (in Mbps)
  458. *
  459. * Return: 0 on success, negative errno on error
  460. */
  461. static inline QDF_STATUS
  462. cdp_ipa_set_perf_level(ol_txrx_soc_handle soc, int client,
  463. uint32_t max_supported_bw_mbps)
  464. {
  465. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  466. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  467. "%s invalid instance", __func__);
  468. return QDF_STATUS_E_FAILURE;
  469. }
  470. if (soc->ops->ipa_ops->ipa_set_perf_level)
  471. return soc->ops->ipa_ops->ipa_set_perf_level(client,
  472. max_supported_bw_mbps);
  473. return QDF_STATUS_SUCCESS;
  474. }
  475. #endif /* IPA_OFFLOAD */
  476. #endif /* _CDP_TXRX_IPA_H_ */