htt.c 18 KB

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