htt.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. /*
  2. * Copyright (c) 2011, 2014-2016 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 htt.c
  28. * @brief Provide functions to create+init and destroy a HTT instance.
  29. * @details
  30. * This file contains functions for creating a HTT instance; initializing
  31. * the HTT instance, e.g. by allocating a pool of HTT tx descriptors and
  32. * connecting the HTT service with HTC; and deleting a HTT instance.
  33. */
  34. #include <qdf_mem.h> /* qdf_mem_malloc */
  35. #include <qdf_types.h> /* qdf_device_t, qdf_print */
  36. #include <htt.h> /* htt_tx_msdu_desc_t */
  37. #include <ol_cfg.h>
  38. #include <ol_txrx_htt_api.h> /* ol_tx_dowload_done_ll, etc. */
  39. #include <ol_htt_api.h>
  40. #include <htt_internal.h>
  41. #include <ol_htt_tx_api.h>
  42. #include <cds_api.h>
  43. #include "hif.h"
  44. #define HTT_HTC_PKT_POOL_INIT_SIZE 100 /* enough for a large A-MPDU */
  45. A_STATUS(*htt_h2t_rx_ring_cfg_msg)(struct htt_pdev_t *pdev);
  46. #ifdef IPA_OFFLOAD
  47. A_STATUS htt_ipa_config(htt_pdev_handle pdev, A_STATUS status)
  48. {
  49. if ((A_OK == status) &&
  50. ol_cfg_ipa_uc_offload_enabled(pdev->ctrl_pdev))
  51. status = htt_h2t_ipa_uc_rsc_cfg_msg(pdev);
  52. return status;
  53. }
  54. #define HTT_IPA_CONFIG htt_ipa_config
  55. #else
  56. #define HTT_IPA_CONFIG(pdev, status) status /* no-op */
  57. #endif /* IPA_OFFLOAD */
  58. struct htt_htc_pkt *htt_htc_pkt_alloc(struct htt_pdev_t *pdev)
  59. {
  60. struct htt_htc_pkt_union *pkt = NULL;
  61. HTT_TX_MUTEX_ACQUIRE(&pdev->htt_tx_mutex);
  62. if (pdev->htt_htc_pkt_freelist) {
  63. pkt = pdev->htt_htc_pkt_freelist;
  64. pdev->htt_htc_pkt_freelist = pdev->htt_htc_pkt_freelist->u.next;
  65. }
  66. HTT_TX_MUTEX_RELEASE(&pdev->htt_tx_mutex);
  67. if (pkt == NULL)
  68. pkt = qdf_mem_malloc(sizeof(*pkt));
  69. return &pkt->u.pkt; /* not actually a dereference */
  70. }
  71. void htt_htc_pkt_free(struct htt_pdev_t *pdev, struct htt_htc_pkt *pkt)
  72. {
  73. struct htt_htc_pkt_union *u_pkt = (struct htt_htc_pkt_union *)pkt;
  74. HTT_TX_MUTEX_ACQUIRE(&pdev->htt_tx_mutex);
  75. u_pkt->u.next = pdev->htt_htc_pkt_freelist;
  76. pdev->htt_htc_pkt_freelist = u_pkt;
  77. HTT_TX_MUTEX_RELEASE(&pdev->htt_tx_mutex);
  78. }
  79. void htt_htc_pkt_pool_free(struct htt_pdev_t *pdev)
  80. {
  81. struct htt_htc_pkt_union *pkt, *next;
  82. pkt = pdev->htt_htc_pkt_freelist;
  83. while (pkt) {
  84. next = pkt->u.next;
  85. qdf_mem_free(pkt);
  86. pkt = next;
  87. }
  88. pdev->htt_htc_pkt_freelist = NULL;
  89. }
  90. #ifdef ATH_11AC_TXCOMPACT
  91. void htt_htc_misc_pkt_list_add(struct htt_pdev_t *pdev, struct htt_htc_pkt *pkt)
  92. {
  93. struct htt_htc_pkt_union *u_pkt = (struct htt_htc_pkt_union *)pkt;
  94. HTT_TX_MUTEX_ACQUIRE(&pdev->htt_tx_mutex);
  95. if (pdev->htt_htc_pkt_misclist) {
  96. u_pkt->u.next = pdev->htt_htc_pkt_misclist;
  97. pdev->htt_htc_pkt_misclist = u_pkt;
  98. } else {
  99. pdev->htt_htc_pkt_misclist = u_pkt;
  100. }
  101. HTT_TX_MUTEX_RELEASE(&pdev->htt_tx_mutex);
  102. }
  103. void htt_htc_misc_pkt_pool_free(struct htt_pdev_t *pdev)
  104. {
  105. struct htt_htc_pkt_union *pkt, *next;
  106. qdf_nbuf_t netbuf;
  107. pkt = pdev->htt_htc_pkt_misclist;
  108. while (pkt) {
  109. next = pkt->u.next;
  110. netbuf = (qdf_nbuf_t) (pkt->u.pkt.htc_pkt.pNetBufContext);
  111. qdf_nbuf_unmap(pdev->osdev, netbuf, QDF_DMA_TO_DEVICE);
  112. qdf_nbuf_free(netbuf);
  113. qdf_mem_free(pkt);
  114. pkt = next;
  115. }
  116. pdev->htt_htc_pkt_misclist = NULL;
  117. }
  118. #endif
  119. /**
  120. * htt_pdev_alloc() - allocate HTT pdev
  121. * @txrx_pdev: txrx pdev
  122. * @ctrl_pdev: cfg pdev
  123. * @htc_pdev: HTC pdev
  124. * @osdev: os device
  125. *
  126. * Return: HTT pdev handle
  127. */
  128. htt_pdev_handle
  129. htt_pdev_alloc(ol_txrx_pdev_handle txrx_pdev,
  130. ol_pdev_handle ctrl_pdev,
  131. HTC_HANDLE htc_pdev, qdf_device_t osdev)
  132. {
  133. struct htt_pdev_t *pdev;
  134. pdev = qdf_mem_malloc(sizeof(*pdev));
  135. if (!pdev)
  136. goto fail1;
  137. pdev->osdev = osdev;
  138. pdev->ctrl_pdev = ctrl_pdev;
  139. pdev->txrx_pdev = txrx_pdev;
  140. pdev->htc_pdev = htc_pdev;
  141. qdf_mem_set(&pdev->stats, sizeof(pdev->stats), 0);
  142. pdev->htt_htc_pkt_freelist = NULL;
  143. #ifdef ATH_11AC_TXCOMPACT
  144. pdev->htt_htc_pkt_misclist = NULL;
  145. #endif
  146. pdev->cfg.default_tx_comp_req =
  147. !ol_cfg_tx_free_at_download(pdev->ctrl_pdev);
  148. pdev->cfg.is_full_reorder_offload =
  149. ol_cfg_is_full_reorder_offload(pdev->ctrl_pdev);
  150. qdf_print("is_full_reorder_offloaded? %d\n",
  151. (int)pdev->cfg.is_full_reorder_offload);
  152. pdev->cfg.ce_classify_enabled =
  153. ol_cfg_is_ce_classify_enabled(ctrl_pdev);
  154. qdf_print("ce_classify_enabled %d\n",
  155. pdev->cfg.ce_classify_enabled);
  156. pdev->targetdef = htc_get_targetdef(htc_pdev);
  157. #if defined(HELIUMPLUS_PADDR64)
  158. /* TODO: OKA: Remove hard-coding */
  159. HTT_SET_WIFI_IP(pdev, 2, 0);
  160. #endif /* defined(HELIUMPLUS_PADDR64) */
  161. /*
  162. * Connect to HTC service.
  163. * This has to be done before calling htt_rx_attach,
  164. * since htt_rx_attach involves sending a rx ring configure
  165. * message to the target.
  166. */
  167. /* AR6004 don't need HTT layer. */
  168. #ifndef AR6004_HW
  169. if (htt_htc_attach(pdev, HTT_DATA_MSG_SVC))
  170. goto fail2;
  171. if (htt_htc_attach(pdev, HTT_DATA2_MSG_SVC))
  172. ;
  173. /* TODO: enable the following line once FW is ready */
  174. /* goto fail2; */
  175. if (htt_htc_attach(pdev, HTT_DATA3_MSG_SVC))
  176. ;
  177. /* TODO: enable the following line once FW is ready */
  178. /* goto fail2; */
  179. if (hif_ce_fastpath_cb_register(htt_t2h_msg_handler_fast, pdev))
  180. qdf_print("failed to register fastpath callback\n");
  181. #endif
  182. return pdev;
  183. fail2:
  184. qdf_mem_free(pdev);
  185. fail1:
  186. return NULL;
  187. }
  188. /**
  189. * htt_attach() - Allocate and setup HTT TX/RX descriptors
  190. * @pdev: pdev ptr
  191. * @desc_pool_size: size of tx descriptors
  192. *
  193. * Return: 0 for success or error code.
  194. */
  195. int
  196. htt_attach(struct htt_pdev_t *pdev, int desc_pool_size)
  197. {
  198. int i;
  199. enum wlan_frm_fmt frm_type;
  200. int ret = 0;
  201. ret = htt_tx_attach(pdev, desc_pool_size);
  202. if (ret)
  203. goto fail1;
  204. ret = htt_rx_attach(pdev);
  205. if (ret)
  206. goto fail2;
  207. HTT_TX_MUTEX_INIT(&pdev->htt_tx_mutex);
  208. HTT_TX_NBUF_QUEUE_MUTEX_INIT(pdev);
  209. /* pre-allocate some HTC_PACKET objects */
  210. for (i = 0; i < HTT_HTC_PKT_POOL_INIT_SIZE; i++) {
  211. struct htt_htc_pkt_union *pkt;
  212. pkt = qdf_mem_malloc(sizeof(*pkt));
  213. if (!pkt)
  214. break;
  215. htt_htc_pkt_free(pdev, &pkt->u.pkt);
  216. }
  217. /*
  218. * LL - download just the initial portion of the frame.
  219. * Download enough to cover the encapsulation headers checked
  220. * by the target's tx classification descriptor engine.
  221. */
  222. /* account for the 802.3 or 802.11 header */
  223. frm_type = ol_cfg_frame_type(pdev->ctrl_pdev);
  224. if (frm_type == wlan_frm_fmt_native_wifi) {
  225. pdev->download_len = HTT_TX_HDR_SIZE_NATIVE_WIFI;
  226. } else if (frm_type == wlan_frm_fmt_802_3) {
  227. pdev->download_len = HTT_TX_HDR_SIZE_ETHERNET;
  228. } else {
  229. qdf_print("Unexpected frame type spec: %d\n", frm_type);
  230. HTT_ASSERT0(0);
  231. }
  232. /*
  233. * Account for the optional L2 / ethernet header fields:
  234. * 802.1Q, LLC/SNAP
  235. */
  236. pdev->download_len +=
  237. HTT_TX_HDR_SIZE_802_1Q + HTT_TX_HDR_SIZE_LLC_SNAP;
  238. /*
  239. * Account for the portion of the L3 (IP) payload that the
  240. * target needs for its tx classification.
  241. */
  242. pdev->download_len += ol_cfg_tx_download_size(pdev->ctrl_pdev);
  243. /*
  244. * Account for the HTT tx descriptor, including the
  245. * HTC header + alignment padding.
  246. */
  247. pdev->download_len += sizeof(struct htt_host_tx_desc_t);
  248. /*
  249. * The TXCOMPACT htt_tx_sched function uses pdev->download_len
  250. * to apply for all requeued tx frames. Thus,
  251. * pdev->download_len has to be the largest download length of
  252. * any tx frame that will be downloaded.
  253. * This maximum download length is for management tx frames,
  254. * which have an 802.11 header.
  255. */
  256. #ifdef ATH_11AC_TXCOMPACT
  257. pdev->download_len = sizeof(struct htt_host_tx_desc_t)
  258. + HTT_TX_HDR_SIZE_OUTER_HDR_MAX /* worst case */
  259. + HTT_TX_HDR_SIZE_802_1Q
  260. + HTT_TX_HDR_SIZE_LLC_SNAP
  261. + ol_cfg_tx_download_size(pdev->ctrl_pdev);
  262. #endif
  263. pdev->tx_send_complete_part2 = ol_tx_download_done_ll;
  264. /*
  265. * For LL, the FW rx desc is alongside the HW rx desc fields in
  266. * the htt_host_rx_desc_base struct/.
  267. */
  268. pdev->rx_fw_desc_offset = RX_STD_DESC_FW_MSDU_OFFSET;
  269. htt_h2t_rx_ring_cfg_msg = htt_h2t_rx_ring_cfg_msg_ll;
  270. return 0;
  271. fail2:
  272. htt_tx_detach(pdev);
  273. fail1:
  274. return ret;
  275. }
  276. A_STATUS htt_attach_target(htt_pdev_handle pdev)
  277. {
  278. A_STATUS status;
  279. status = htt_h2t_ver_req_msg(pdev);
  280. if (status != A_OK)
  281. return status;
  282. #if defined(HELIUMPLUS_PADDR64)
  283. /*
  284. * Send the frag_desc info to target.
  285. */
  286. htt_h2t_frag_desc_bank_cfg_msg(pdev);
  287. #endif /* defined(HELIUMPLUS_PADDR64) */
  288. /*
  289. * If applicable, send the rx ring config message to the target.
  290. * The host could wait for the HTT version number confirmation message
  291. * from the target before sending any further HTT messages, but it's
  292. * reasonable to assume that the host and target HTT version numbers
  293. * match, and proceed immediately with the remaining configuration
  294. * handshaking.
  295. */
  296. status = htt_h2t_rx_ring_cfg_msg(pdev);
  297. status = HTT_IPA_CONFIG(pdev, status);
  298. return status;
  299. }
  300. void htt_detach(htt_pdev_handle pdev)
  301. {
  302. htt_rx_detach(pdev);
  303. htt_tx_detach(pdev);
  304. htt_htc_pkt_pool_free(pdev);
  305. #ifdef ATH_11AC_TXCOMPACT
  306. htt_htc_misc_pkt_pool_free(pdev);
  307. #endif
  308. HTT_TX_MUTEX_DESTROY(&pdev->htt_tx_mutex);
  309. HTT_TX_NBUF_QUEUE_MUTEX_DESTROY(pdev);
  310. htt_rx_dbg_rxbuf_deinit(pdev);
  311. }
  312. /**
  313. * htt_pdev_free() - Free HTT pdev
  314. * @pdev: htt pdev
  315. *
  316. * Return: none
  317. */
  318. void htt_pdev_free(htt_pdev_handle pdev)
  319. {
  320. qdf_mem_free(pdev);
  321. }
  322. void htt_detach_target(htt_pdev_handle pdev)
  323. {
  324. }
  325. #ifdef WLAN_FEATURE_FASTPATH
  326. /**
  327. * htt_pkt_dl_len_get() HTT packet download length for fastpath case
  328. *
  329. * @htt_dev: pointer to htt device.
  330. *
  331. * As fragment one already downloaded HTT/HTC header, download length is
  332. * remaining bytes.
  333. *
  334. * Return: download length
  335. */
  336. int htt_pkt_dl_len_get(struct htt_pdev_t *htt_dev)
  337. {
  338. return htt_dev->download_len - sizeof(struct htt_host_tx_desc_t);
  339. }
  340. #else
  341. int htt_pkt_dl_len_get(struct htt_pdev_t *htt_dev)
  342. {
  343. return 0;
  344. }
  345. #endif
  346. static inline
  347. int htt_update_endpoint(struct htt_pdev_t *pdev,
  348. uint16_t service_id, HTC_ENDPOINT_ID ep)
  349. {
  350. struct hif_opaque_softc *hif_ctx;
  351. uint8_t ul = 0xff, dl = 0xff;
  352. int ul_polled, dl_polled;
  353. int tx_service = 0;
  354. int rc = 0;
  355. hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
  356. if (qdf_unlikely(NULL == hif_ctx)) {
  357. QDF_ASSERT(NULL != hif_ctx);
  358. qdf_print("%s:%d: assuming non-tx service.",
  359. __func__, __LINE__);
  360. } else {
  361. ul = dl = 0xff;
  362. if (QDF_STATUS_SUCCESS !=
  363. hif_map_service_to_pipe(hif_ctx, service_id,
  364. &ul, &dl,
  365. &ul_polled, &dl_polled))
  366. qdf_print("%s:%d: assuming non-tx srv.",
  367. __func__, __LINE__);
  368. else
  369. tx_service = (ul != 0xff);
  370. }
  371. if (tx_service) {
  372. /* currently we have only one OUT htt tx service */
  373. QDF_BUG(service_id == HTT_DATA_MSG_SVC);
  374. pdev->htc_tx_endpoint = ep;
  375. hif_save_htc_htt_config_endpoint(hif_ctx, ep);
  376. rc = 1;
  377. }
  378. return rc;
  379. }
  380. int htt_htc_attach(struct htt_pdev_t *pdev, uint16_t service_id)
  381. {
  382. HTC_SERVICE_CONNECT_REQ connect;
  383. HTC_SERVICE_CONNECT_RESP response;
  384. A_STATUS status;
  385. qdf_mem_set(&connect, sizeof(connect), 0);
  386. qdf_mem_set(&response, sizeof(response), 0);
  387. connect.pMetaData = NULL;
  388. connect.MetaDataLength = 0;
  389. connect.EpCallbacks.pContext = pdev;
  390. connect.EpCallbacks.EpTxComplete = htt_h2t_send_complete;
  391. connect.EpCallbacks.EpTxCompleteMultiple = NULL;
  392. connect.EpCallbacks.EpRecv = htt_t2h_msg_handler;
  393. connect.EpCallbacks.ep_resume_tx_queue = htt_tx_resume_handler;
  394. /* rx buffers currently are provided by HIF, not by EpRecvRefill */
  395. connect.EpCallbacks.EpRecvRefill = NULL;
  396. connect.EpCallbacks.RecvRefillWaterMark = 1;
  397. /* N/A, fill is done by HIF */
  398. connect.EpCallbacks.EpSendFull = htt_h2t_full;
  399. /*
  400. * Specify how deep to let a queue get before htc_send_pkt will
  401. * call the EpSendFull function due to excessive send queue depth.
  402. */
  403. connect.MaxSendQueueDepth = HTT_MAX_SEND_QUEUE_DEPTH;
  404. /* disable flow control for HTT data message service */
  405. #ifndef HIF_SDIO
  406. connect.ConnectionFlags |= HTC_CONNECT_FLAGS_DISABLE_CREDIT_FLOW_CTRL;
  407. #endif
  408. /* connect to control service */
  409. connect.service_id = service_id;
  410. status = htc_connect_service(pdev->htc_pdev, &connect, &response);
  411. if (status != A_OK)
  412. return -EIO; /* failure */
  413. htt_update_endpoint(pdev, service_id, response.Endpoint);
  414. return 0; /* success */
  415. }
  416. #if HTT_DEBUG_LEVEL > 5
  417. void htt_display(htt_pdev_handle pdev, int indent)
  418. {
  419. qdf_print("%*s%s:\n", indent, " ", "HTT");
  420. qdf_print("%*stx desc pool: %d elems of %d bytes, %d allocated\n",
  421. indent + 4, " ",
  422. pdev->tx_descs.pool_elems,
  423. pdev->tx_descs.size, pdev->tx_descs.alloc_cnt);
  424. qdf_print("%*srx ring: space for %d elems, filled with %d buffers\n",
  425. indent + 4, " ",
  426. pdev->rx_ring.size, pdev->rx_ring.fill_level);
  427. qdf_print("%*sat %p (%#x paddr)\n", indent + 8, " ",
  428. pdev->rx_ring.buf.paddrs_ring, pdev->rx_ring.base_paddr);
  429. qdf_print("%*snetbuf ring @ %p\n", indent + 8, " ",
  430. pdev->rx_ring.buf.netbufs_ring);
  431. qdf_print("%*sFW_IDX shadow register: vaddr = %p, paddr = %#x\n",
  432. indent + 8, " ",
  433. pdev->rx_ring.alloc_idx.vaddr, pdev->rx_ring.alloc_idx.paddr);
  434. qdf_print("%*sSW enqueue idx= %d, SW dequeue idx: desc= %d, buf= %d\n",
  435. indent + 8, " ", *pdev->rx_ring.alloc_idx.vaddr,
  436. pdev->rx_ring.sw_rd_idx.msdu_desc,
  437. pdev->rx_ring.sw_rd_idx.msdu_payld);
  438. }
  439. #endif
  440. #ifdef IPA_OFFLOAD
  441. /**
  442. * htt_ipa_uc_attach() - Allocate UC data path resources
  443. * @pdev: handle to the HTT instance
  444. *
  445. * Return: 0 success
  446. * none 0 fail
  447. */
  448. int htt_ipa_uc_attach(struct htt_pdev_t *pdev)
  449. {
  450. int error;
  451. /* TX resource attach */
  452. error = htt_tx_ipa_uc_attach(
  453. pdev,
  454. ol_cfg_ipa_uc_tx_buf_size(pdev->ctrl_pdev),
  455. ol_cfg_ipa_uc_tx_max_buf_cnt(pdev->ctrl_pdev),
  456. ol_cfg_ipa_uc_tx_partition_base(pdev->ctrl_pdev));
  457. if (error) {
  458. qdf_print("HTT IPA UC TX attach fail code %d\n", error);
  459. HTT_ASSERT0(0);
  460. return error;
  461. }
  462. /* RX resource attach */
  463. error = htt_rx_ipa_uc_attach(
  464. pdev,
  465. ol_cfg_ipa_uc_rx_ind_ring_size(pdev->ctrl_pdev));
  466. if (error) {
  467. qdf_print("HTT IPA UC RX attach fail code %d\n", error);
  468. htt_tx_ipa_uc_detach(pdev);
  469. HTT_ASSERT0(0);
  470. return error;
  471. }
  472. return 0; /* success */
  473. }
  474. /**
  475. * htt_ipa_uc_attach() - Remove UC data path resources
  476. * @pdev: handle to the HTT instance
  477. *
  478. * Return: None
  479. */
  480. void htt_ipa_uc_detach(struct htt_pdev_t *pdev)
  481. {
  482. /* TX IPA micro controller detach */
  483. htt_tx_ipa_uc_detach(pdev);
  484. /* RX IPA micro controller detach */
  485. htt_rx_ipa_uc_detach(pdev);
  486. }
  487. /**
  488. * htt_ipa_uc_get_resource() - Get uc resource from htt and lower layer
  489. * @pdev: handle to the HTT instance
  490. * @ce_sr_base_paddr: copy engine source ring base physical address
  491. * @ce_sr_ring_size: copy engine source ring size
  492. * @ce_reg_paddr: copy engine register physical address
  493. * @tx_comp_ring_base_paddr: tx comp ring base physical address
  494. * @tx_comp_ring_size: tx comp ring size
  495. * @tx_num_alloc_buffer: number of allocated tx buffer
  496. * @rx_rdy_ring_base_paddr: rx ready ring base physical address
  497. * @rx_rdy_ring_size: rx ready ring size
  498. * @rx_proc_done_idx_paddr: rx process done index physical address
  499. * @rx_proc_done_idx_vaddr: rx process done index virtual address
  500. * @rx2_rdy_ring_base_paddr: rx done ring base physical address
  501. * @rx2_rdy_ring_size: rx done ring size
  502. * @rx2_proc_done_idx_paddr: rx done index physical address
  503. * @rx2_proc_done_idx_vaddr: rx done index virtual address
  504. *
  505. * Return: 0 success
  506. */
  507. int
  508. htt_ipa_uc_get_resource(htt_pdev_handle pdev,
  509. qdf_dma_addr_t *ce_sr_base_paddr,
  510. uint32_t *ce_sr_ring_size,
  511. qdf_dma_addr_t *ce_reg_paddr,
  512. qdf_dma_addr_t *tx_comp_ring_base_paddr,
  513. uint32_t *tx_comp_ring_size,
  514. uint32_t *tx_num_alloc_buffer,
  515. qdf_dma_addr_t *rx_rdy_ring_base_paddr,
  516. uint32_t *rx_rdy_ring_size,
  517. qdf_dma_addr_t *rx_proc_done_idx_paddr,
  518. void **rx_proc_done_idx_vaddr,
  519. qdf_dma_addr_t *rx2_rdy_ring_base_paddr,
  520. uint32_t *rx2_rdy_ring_size,
  521. qdf_dma_addr_t *rx2_proc_done_idx_paddr,
  522. void **rx2_proc_done_idx_vaddr)
  523. {
  524. /* Release allocated resource to client */
  525. *tx_comp_ring_base_paddr =
  526. pdev->ipa_uc_tx_rsc.tx_comp_base.paddr;
  527. *tx_comp_ring_size =
  528. (uint32_t) ol_cfg_ipa_uc_tx_max_buf_cnt(pdev->ctrl_pdev);
  529. *tx_num_alloc_buffer = (uint32_t) pdev->ipa_uc_tx_rsc.alloc_tx_buf_cnt;
  530. *rx_rdy_ring_base_paddr =
  531. pdev->ipa_uc_rx_rsc.rx_ind_ring_base.paddr;
  532. *rx_rdy_ring_size = (uint32_t) pdev->ipa_uc_rx_rsc.rx_ind_ring_size;
  533. *rx_proc_done_idx_paddr =
  534. pdev->ipa_uc_rx_rsc.rx_ipa_prc_done_idx.paddr;
  535. *rx_proc_done_idx_vaddr =
  536. (void *)pdev->ipa_uc_rx_rsc.rx_ipa_prc_done_idx.vaddr;
  537. *rx2_rdy_ring_base_paddr =
  538. pdev->ipa_uc_rx_rsc.rx2_ind_ring_base.paddr;
  539. *rx2_rdy_ring_size = (uint32_t) pdev->ipa_uc_rx_rsc.rx2_ind_ring_size;
  540. *rx2_proc_done_idx_paddr =
  541. pdev->ipa_uc_rx_rsc.rx2_ipa_prc_done_idx.paddr;
  542. *rx2_proc_done_idx_vaddr =
  543. (void *)pdev->ipa_uc_rx_rsc.rx2_ipa_prc_done_idx.vaddr;
  544. /* Get copy engine, bus resource */
  545. htc_ipa_get_ce_resource(pdev->htc_pdev,
  546. ce_sr_base_paddr,
  547. ce_sr_ring_size, ce_reg_paddr);
  548. return 0;
  549. }
  550. /**
  551. * htt_ipa_uc_set_doorbell_paddr() - Propagate IPA doorbell address
  552. * @pdev: handle to the HTT instance
  553. * @ipa_uc_tx_doorbell_paddr: TX doorbell base physical address
  554. * @ipa_uc_rx_doorbell_paddr: RX doorbell base physical address
  555. *
  556. * Return: 0 success
  557. */
  558. int
  559. htt_ipa_uc_set_doorbell_paddr(htt_pdev_handle pdev,
  560. qdf_dma_addr_t ipa_uc_tx_doorbell_paddr,
  561. qdf_dma_addr_t ipa_uc_rx_doorbell_paddr)
  562. {
  563. pdev->ipa_uc_tx_rsc.tx_comp_idx_paddr = ipa_uc_tx_doorbell_paddr;
  564. pdev->ipa_uc_rx_rsc.rx_rdy_idx_paddr = ipa_uc_rx_doorbell_paddr;
  565. return 0;
  566. }
  567. #endif /* IPA_OFFLOAD */