htt.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  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. #ifdef WLAN_FEATURE_FASTPATH
  335. /**
  336. * htt_pkt_dl_len_get() HTT packet download length for fastpath case
  337. *
  338. * @htt_dev: pointer to htt device.
  339. *
  340. * As fragment one already downloaded HTT/HTC header, download length is
  341. * remaining bytes.
  342. *
  343. * Return: download length
  344. */
  345. int htt_pkt_dl_len_get(struct htt_pdev_t *htt_dev)
  346. {
  347. return htt_dev->download_len - sizeof(struct htt_host_tx_desc_t);
  348. }
  349. #else
  350. int htt_pkt_dl_len_get(struct htt_pdev_t *htt_dev)
  351. {
  352. return 0;
  353. }
  354. #endif
  355. static inline
  356. int htt_update_endpoint(struct htt_pdev_t *pdev,
  357. uint16_t service_id, HTC_ENDPOINT_ID ep)
  358. {
  359. struct hif_opaque_softc *hif_ctx;
  360. uint8_t ul = 0xff, dl = 0xff;
  361. int ul_polled, dl_polled;
  362. int tx_service = 0;
  363. int rc = 0;
  364. hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
  365. if (qdf_unlikely(NULL == hif_ctx)) {
  366. QDF_ASSERT(NULL != hif_ctx);
  367. qdf_print("%s:%d: assuming non-tx service.",
  368. __func__, __LINE__);
  369. } else {
  370. ul = dl = 0xff;
  371. if (QDF_STATUS_SUCCESS !=
  372. hif_map_service_to_pipe(hif_ctx, service_id,
  373. &ul, &dl,
  374. &ul_polled, &dl_polled))
  375. qdf_print("%s:%d: assuming non-tx srv.",
  376. __func__, __LINE__);
  377. else
  378. tx_service = (ul != 0xff);
  379. }
  380. if (tx_service) {
  381. /* currently we have only one OUT htt tx service */
  382. QDF_BUG(service_id == HTT_DATA_MSG_SVC);
  383. pdev->htc_tx_endpoint = ep;
  384. hif_save_htc_htt_config_endpoint(hif_ctx, ep);
  385. rc = 1;
  386. }
  387. return rc;
  388. }
  389. int htt_htc_attach(struct htt_pdev_t *pdev, uint16_t service_id)
  390. {
  391. HTC_SERVICE_CONNECT_REQ connect;
  392. HTC_SERVICE_CONNECT_RESP response;
  393. A_STATUS status;
  394. qdf_mem_set(&connect, sizeof(connect), 0);
  395. qdf_mem_set(&response, sizeof(response), 0);
  396. connect.pMetaData = NULL;
  397. connect.MetaDataLength = 0;
  398. connect.EpCallbacks.pContext = pdev;
  399. connect.EpCallbacks.EpTxComplete = htt_h2t_send_complete;
  400. connect.EpCallbacks.EpTxCompleteMultiple = NULL;
  401. connect.EpCallbacks.EpRecv = htt_t2h_msg_handler;
  402. connect.EpCallbacks.ep_resume_tx_queue = htt_tx_resume_handler;
  403. /* rx buffers currently are provided by HIF, not by EpRecvRefill */
  404. connect.EpCallbacks.EpRecvRefill = NULL;
  405. connect.EpCallbacks.RecvRefillWaterMark = 1;
  406. /* N/A, fill is done by HIF */
  407. connect.EpCallbacks.EpSendFull = htt_h2t_full;
  408. /*
  409. * Specify how deep to let a queue get before htc_send_pkt will
  410. * call the EpSendFull function due to excessive send queue depth.
  411. */
  412. connect.MaxSendQueueDepth = HTT_MAX_SEND_QUEUE_DEPTH;
  413. /* disable flow control for HTT data message service */
  414. #ifndef HIF_SDIO
  415. connect.ConnectionFlags |= HTC_CONNECT_FLAGS_DISABLE_CREDIT_FLOW_CTRL;
  416. #endif
  417. /* connect to control service */
  418. connect.service_id = service_id;
  419. status = htc_connect_service(pdev->htc_pdev, &connect, &response);
  420. if (status != A_OK)
  421. return -EIO; /* failure */
  422. htt_update_endpoint(pdev, service_id, response.Endpoint);
  423. return 0; /* success */
  424. }
  425. #if HTT_DEBUG_LEVEL > 5
  426. void htt_display(htt_pdev_handle pdev, int indent)
  427. {
  428. qdf_print("%*s%s:\n", indent, " ", "HTT");
  429. qdf_print("%*stx desc pool: %d elems of %d bytes, %d allocated\n",
  430. indent + 4, " ",
  431. pdev->tx_descs.pool_elems,
  432. pdev->tx_descs.size, pdev->tx_descs.alloc_cnt);
  433. qdf_print("%*srx ring: space for %d elems, filled with %d buffers\n",
  434. indent + 4, " ",
  435. pdev->rx_ring.size, pdev->rx_ring.fill_level);
  436. qdf_print("%*sat %p (%#x paddr)\n", indent + 8, " ",
  437. pdev->rx_ring.buf.paddrs_ring, pdev->rx_ring.base_paddr);
  438. qdf_print("%*snetbuf ring @ %p\n", indent + 8, " ",
  439. pdev->rx_ring.buf.netbufs_ring);
  440. qdf_print("%*sFW_IDX shadow register: vaddr = %p, paddr = %#x\n",
  441. indent + 8, " ",
  442. pdev->rx_ring.alloc_idx.vaddr, pdev->rx_ring.alloc_idx.paddr);
  443. qdf_print("%*sSW enqueue idx= %d, SW dequeue idx: desc= %d, buf= %d\n",
  444. indent + 8, " ", *pdev->rx_ring.alloc_idx.vaddr,
  445. pdev->rx_ring.sw_rd_idx.msdu_desc,
  446. pdev->rx_ring.sw_rd_idx.msdu_payld);
  447. }
  448. #endif
  449. #ifdef IPA_OFFLOAD
  450. /**
  451. * htt_ipa_uc_attach() - Allocate UC data path resources
  452. * @pdev: handle to the HTT instance
  453. *
  454. * Return: 0 success
  455. * none 0 fail
  456. */
  457. int htt_ipa_uc_attach(struct htt_pdev_t *pdev)
  458. {
  459. int error;
  460. /* TX resource attach */
  461. error = htt_tx_ipa_uc_attach(
  462. pdev,
  463. ol_cfg_ipa_uc_tx_buf_size(pdev->ctrl_pdev),
  464. ol_cfg_ipa_uc_tx_max_buf_cnt(pdev->ctrl_pdev),
  465. ol_cfg_ipa_uc_tx_partition_base(pdev->ctrl_pdev));
  466. if (error) {
  467. qdf_print("HTT IPA UC TX attach fail code %d\n", error);
  468. HTT_ASSERT0(0);
  469. return error;
  470. }
  471. /* RX resource attach */
  472. error = htt_rx_ipa_uc_attach(
  473. pdev,
  474. ol_cfg_ipa_uc_rx_ind_ring_size(pdev->ctrl_pdev));
  475. if (error) {
  476. qdf_print("HTT IPA UC RX attach fail code %d\n", error);
  477. htt_tx_ipa_uc_detach(pdev);
  478. HTT_ASSERT0(0);
  479. return error;
  480. }
  481. return 0; /* success */
  482. }
  483. /**
  484. * htt_ipa_uc_attach() - Remove UC data path resources
  485. * @pdev: handle to the HTT instance
  486. *
  487. * Return: None
  488. */
  489. void htt_ipa_uc_detach(struct htt_pdev_t *pdev)
  490. {
  491. /* TX IPA micro controller detach */
  492. htt_tx_ipa_uc_detach(pdev);
  493. /* RX IPA micro controller detach */
  494. htt_rx_ipa_uc_detach(pdev);
  495. }
  496. /**
  497. * htt_ipa_uc_get_resource() - Get uc resource from htt and lower layer
  498. * @pdev: handle to the HTT instance
  499. * @ce_sr_base_paddr: copy engine source ring base physical address
  500. * @ce_sr_ring_size: copy engine source ring size
  501. * @ce_reg_paddr: copy engine register physical address
  502. * @tx_comp_ring_base_paddr: tx comp ring base physical address
  503. * @tx_comp_ring_size: tx comp ring size
  504. * @tx_num_alloc_buffer: number of allocated tx buffer
  505. * @rx_rdy_ring_base_paddr: rx ready ring base physical address
  506. * @rx_rdy_ring_size: rx ready ring size
  507. * @rx_proc_done_idx_paddr: rx process done index physical address
  508. * @rx_proc_done_idx_vaddr: rx process done index virtual address
  509. * @rx2_rdy_ring_base_paddr: rx done ring base physical address
  510. * @rx2_rdy_ring_size: rx done ring size
  511. * @rx2_proc_done_idx_paddr: rx done index physical address
  512. * @rx2_proc_done_idx_vaddr: rx done index virtual address
  513. *
  514. * Return: 0 success
  515. */
  516. int
  517. htt_ipa_uc_get_resource(htt_pdev_handle pdev,
  518. qdf_dma_addr_t *ce_sr_base_paddr,
  519. uint32_t *ce_sr_ring_size,
  520. qdf_dma_addr_t *ce_reg_paddr,
  521. qdf_dma_addr_t *tx_comp_ring_base_paddr,
  522. uint32_t *tx_comp_ring_size,
  523. uint32_t *tx_num_alloc_buffer,
  524. qdf_dma_addr_t *rx_rdy_ring_base_paddr,
  525. uint32_t *rx_rdy_ring_size,
  526. qdf_dma_addr_t *rx_proc_done_idx_paddr,
  527. void **rx_proc_done_idx_vaddr,
  528. qdf_dma_addr_t *rx2_rdy_ring_base_paddr,
  529. uint32_t *rx2_rdy_ring_size,
  530. qdf_dma_addr_t *rx2_proc_done_idx_paddr,
  531. void **rx2_proc_done_idx_vaddr)
  532. {
  533. /* Release allocated resource to client */
  534. *tx_comp_ring_base_paddr =
  535. pdev->ipa_uc_tx_rsc.tx_comp_base.paddr;
  536. *tx_comp_ring_size =
  537. (uint32_t) ol_cfg_ipa_uc_tx_max_buf_cnt(pdev->ctrl_pdev);
  538. *tx_num_alloc_buffer = (uint32_t) pdev->ipa_uc_tx_rsc.alloc_tx_buf_cnt;
  539. *rx_rdy_ring_base_paddr =
  540. pdev->ipa_uc_rx_rsc.rx_ind_ring_base.paddr;
  541. *rx_rdy_ring_size = (uint32_t) pdev->ipa_uc_rx_rsc.rx_ind_ring_size;
  542. *rx_proc_done_idx_paddr =
  543. pdev->ipa_uc_rx_rsc.rx_ipa_prc_done_idx.paddr;
  544. *rx_proc_done_idx_vaddr =
  545. (void *)pdev->ipa_uc_rx_rsc.rx_ipa_prc_done_idx.vaddr;
  546. *rx2_rdy_ring_base_paddr =
  547. pdev->ipa_uc_rx_rsc.rx2_ind_ring_base.paddr;
  548. *rx2_rdy_ring_size = (uint32_t) pdev->ipa_uc_rx_rsc.rx2_ind_ring_size;
  549. *rx2_proc_done_idx_paddr =
  550. pdev->ipa_uc_rx_rsc.rx2_ipa_prc_done_idx.paddr;
  551. *rx2_proc_done_idx_vaddr =
  552. (void *)pdev->ipa_uc_rx_rsc.rx2_ipa_prc_done_idx.vaddr;
  553. /* Get copy engine, bus resource */
  554. htc_ipa_get_ce_resource(pdev->htc_pdev,
  555. ce_sr_base_paddr,
  556. ce_sr_ring_size, ce_reg_paddr);
  557. return 0;
  558. }
  559. /**
  560. * htt_ipa_uc_set_doorbell_paddr() - Propagate IPA doorbell address
  561. * @pdev: handle to the HTT instance
  562. * @ipa_uc_tx_doorbell_paddr: TX doorbell base physical address
  563. * @ipa_uc_rx_doorbell_paddr: RX doorbell base physical address
  564. *
  565. * Return: 0 success
  566. */
  567. int
  568. htt_ipa_uc_set_doorbell_paddr(htt_pdev_handle pdev,
  569. qdf_dma_addr_t ipa_uc_tx_doorbell_paddr,
  570. qdf_dma_addr_t ipa_uc_rx_doorbell_paddr)
  571. {
  572. pdev->ipa_uc_tx_rsc.tx_comp_idx_paddr = ipa_uc_tx_doorbell_paddr;
  573. pdev->ipa_uc_rx_rsc.rx_rdy_idx_paddr = ipa_uc_rx_doorbell_paddr;
  574. return 0;
  575. }
  576. #endif /* IPA_OFFLOAD */