htt_h2t.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025
  1. /*
  2. * Copyright (c) 2011-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_h2t.c
  28. * @brief Provide functions to send host->target HTT messages.
  29. * @details
  30. * This file contains functions related to host->target HTT messages.
  31. * There are a couple aspects of this host->target messaging:
  32. * 1. This file contains the function that is called by HTC when
  33. * a host->target send completes.
  34. * This send-completion callback is primarily relevant to HL,
  35. * to invoke the download scheduler to set up a new download,
  36. * and optionally free the tx frame whose download is completed.
  37. * For both HL and LL, this completion callback frees up the
  38. * HTC_PACKET object used to specify the download.
  39. * 2. This file contains functions for creating messages to send
  40. * from the host to the target.
  41. */
  42. #include <cdf_memory.h> /* cdf_mem_copy */
  43. #include <cdf_nbuf.h> /* cdf_nbuf_map_single */
  44. #include <htc_api.h> /* HTC_PACKET */
  45. #include <htc.h> /* HTC_HDR_ALIGNMENT_PADDING */
  46. #include <htt.h> /* HTT host->target msg defs */
  47. #include <ol_txrx_htt_api.h> /* ol_tx_completion_handler, htt_tx_status */
  48. #include <ol_htt_tx_api.h>
  49. #include <htt_internal.h>
  50. #define HTT_MSG_BUF_SIZE(msg_bytes) \
  51. ((msg_bytes) + HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING)
  52. #ifndef container_of
  53. #define container_of(ptr, type, member) \
  54. ((type *)((char *)(ptr) - (char *)(&((type *)0)->member)))
  55. #endif
  56. static void
  57. htt_h2t_send_complete_free_netbuf(void *pdev, A_STATUS status,
  58. cdf_nbuf_t netbuf, uint16_t msdu_id)
  59. {
  60. cdf_nbuf_free(netbuf);
  61. }
  62. void htt_h2t_send_complete(void *context, HTC_PACKET *htc_pkt)
  63. {
  64. void (*send_complete_part2)(void *pdev, A_STATUS status,
  65. cdf_nbuf_t msdu, uint16_t msdu_id);
  66. struct htt_pdev_t *pdev = (struct htt_pdev_t *)context;
  67. struct htt_htc_pkt *htt_pkt;
  68. cdf_nbuf_t netbuf;
  69. send_complete_part2 = htc_pkt->pPktContext;
  70. htt_pkt = container_of(htc_pkt, struct htt_htc_pkt, htc_pkt);
  71. /* process (free or keep) the netbuf that held the message */
  72. netbuf = (cdf_nbuf_t) htc_pkt->pNetBufContext;
  73. if (send_complete_part2 != NULL) {
  74. send_complete_part2(htt_pkt->pdev_ctxt, htc_pkt->Status, netbuf,
  75. htt_pkt->msdu_id);
  76. }
  77. /* free the htt_htc_pkt / HTC_PACKET object */
  78. htt_htc_pkt_free(pdev, htt_pkt);
  79. }
  80. HTC_SEND_FULL_ACTION htt_h2t_full(void *context, HTC_PACKET *pkt)
  81. {
  82. /* FIX THIS */
  83. return HTC_SEND_FULL_KEEP;
  84. }
  85. #if defined(HELIUMPLUS_PADDR64)
  86. A_STATUS htt_h2t_frag_desc_bank_cfg_msg(struct htt_pdev_t *pdev)
  87. {
  88. A_STATUS rc = A_OK;
  89. struct htt_htc_pkt *pkt;
  90. cdf_nbuf_t msg;
  91. u_int32_t *msg_word;
  92. struct htt_tx_frag_desc_bank_cfg_t *bank_cfg;
  93. pkt = htt_htc_pkt_alloc(pdev);
  94. if (!pkt)
  95. return A_ERROR; /* failure */
  96. /* show that this is not a tx frame download
  97. * (not required, but helpful)
  98. */
  99. pkt->msdu_id = HTT_TX_COMPL_INV_MSDU_ID;
  100. pkt->pdev_ctxt = NULL; /* not used during send-done callback */
  101. msg = cdf_nbuf_alloc(
  102. pdev->osdev,
  103. HTT_MSG_BUF_SIZE(sizeof(struct htt_tx_frag_desc_bank_cfg_t)),
  104. /* reserve room for the HTC header */
  105. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  106. if (!msg) {
  107. htt_htc_pkt_free(pdev, pkt);
  108. return A_ERROR; /* failure */
  109. }
  110. /*
  111. * Set the length of the message.
  112. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  113. * separately during the below call to adf_nbuf_push_head.
  114. * The contribution from the HTC header is added separately inside HTC.
  115. */
  116. cdf_nbuf_put_tail(msg, sizeof(struct htt_tx_frag_desc_bank_cfg_t));
  117. /* fill in the message contents */
  118. msg_word = (u_int32_t *) cdf_nbuf_data(msg);
  119. memset(msg_word, 0 , sizeof(struct htt_tx_frag_desc_bank_cfg_t));
  120. /* rewind beyond alignment pad to get to the HTC header reserved area */
  121. cdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  122. *msg_word = 0;
  123. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_FRAG_DESC_BANK_CFG);
  124. bank_cfg = (struct htt_tx_frag_desc_bank_cfg_t *)msg_word;
  125. /** @note @todo Hard coded to 0 Assuming just one pdev for now.*/
  126. HTT_H2T_FRAG_DESC_BANK_PDEVID_SET(*msg_word, 0);
  127. /** @note Hard coded to 1.*/
  128. HTT_H2T_FRAG_DESC_BANK_NUM_BANKS_SET(*msg_word, 1);
  129. HTT_H2T_FRAG_DESC_BANK_DESC_SIZE_SET(*msg_word, pdev->frag_descs.size);
  130. HTT_H2T_FRAG_DESC_BANK_SWAP_SET(*msg_word, 0);
  131. /** Bank specific data structure.*/
  132. #if HTT_PADDR64
  133. bank_cfg->bank_base_address[0].lo =
  134. pdev->frag_descs.desc_pages.dma_pages->page_p_addr;
  135. bank_cfg->bank_base_address[0].hi = 0;
  136. #else /* ! HTT_PADDR64 */
  137. bank_cfg->bank_base_address[0] =
  138. pdev->frag_descs.desc_pages.dma_pages->page_p_addr;
  139. #endif /* HTT_PADDR64 */
  140. /* Logical Min index */
  141. HTT_H2T_FRAG_DESC_BANK_MIN_IDX_SET(bank_cfg->bank_info[0], 0);
  142. /* Logical Max index */
  143. HTT_H2T_FRAG_DESC_BANK_MAX_IDX_SET(bank_cfg->bank_info[0],
  144. pdev->frag_descs.pool_elems-1);
  145. SET_HTC_PACKET_INFO_TX(
  146. &pkt->htc_pkt,
  147. htt_h2t_send_complete_free_netbuf,
  148. cdf_nbuf_data(msg),
  149. cdf_nbuf_len(msg),
  150. pdev->htc_endpoint,
  151. 1); /* tag - not relevant here */
  152. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  153. rc = htc_send_pkt(pdev->htc_pdev, &pkt->htc_pkt);
  154. return rc;
  155. }
  156. #endif /* defined(HELIUMPLUS_PADDR64) */
  157. A_STATUS htt_h2t_ver_req_msg(struct htt_pdev_t *pdev)
  158. {
  159. struct htt_htc_pkt *pkt;
  160. cdf_nbuf_t msg;
  161. uint32_t *msg_word;
  162. pkt = htt_htc_pkt_alloc(pdev);
  163. if (!pkt)
  164. return A_ERROR; /* failure */
  165. /* show that this is not a tx frame download
  166. * (not required, but helpful)
  167. */
  168. pkt->msdu_id = HTT_TX_COMPL_INV_MSDU_ID;
  169. pkt->pdev_ctxt = NULL; /* not used during send-done callback */
  170. /* reserve room for the HTC header */
  171. msg = cdf_nbuf_alloc(pdev->osdev, HTT_MSG_BUF_SIZE(HTT_VER_REQ_BYTES),
  172. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4,
  173. true);
  174. if (!msg) {
  175. htt_htc_pkt_free(pdev, pkt);
  176. return A_ERROR; /* failure */
  177. }
  178. /*
  179. * Set the length of the message.
  180. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  181. * separately during the below call to cdf_nbuf_push_head.
  182. * The contribution from the HTC header is added separately inside HTC.
  183. */
  184. cdf_nbuf_put_tail(msg, HTT_VER_REQ_BYTES);
  185. /* fill in the message contents */
  186. msg_word = (uint32_t *) cdf_nbuf_data(msg);
  187. /* rewind beyond alignment pad to get to the HTC header reserved area */
  188. cdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  189. *msg_word = 0;
  190. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_VERSION_REQ);
  191. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  192. htt_h2t_send_complete_free_netbuf,
  193. cdf_nbuf_data(msg), cdf_nbuf_len(msg),
  194. pdev->htc_endpoint,
  195. 1); /* tag - not relevant here */
  196. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  197. #ifdef ATH_11AC_TXCOMPACT
  198. if (htc_send_pkt(pdev->htc_pdev, &pkt->htc_pkt) == A_OK)
  199. htt_htc_misc_pkt_list_add(pdev, pkt);
  200. #else
  201. htc_send_pkt(pdev->htc_pdev, &pkt->htc_pkt);
  202. #endif
  203. return A_OK;
  204. }
  205. A_STATUS htt_h2t_rx_ring_cfg_msg_ll(struct htt_pdev_t *pdev)
  206. {
  207. struct htt_htc_pkt *pkt;
  208. cdf_nbuf_t msg;
  209. uint32_t *msg_word;
  210. int enable_ctrl_data, enable_mgmt_data,
  211. enable_null_data, enable_phy_data, enable_hdr,
  212. enable_ppdu_start, enable_ppdu_end;
  213. pkt = htt_htc_pkt_alloc(pdev);
  214. if (!pkt)
  215. return A_ERROR; /* failure */
  216. /* show that this is not a tx frame download
  217. (not required, but helpful)
  218. */
  219. pkt->msdu_id = HTT_TX_COMPL_INV_MSDU_ID;
  220. pkt->pdev_ctxt = NULL; /* not used during send-done callback */
  221. /* reserve room for the HTC header */
  222. msg = cdf_nbuf_alloc(pdev->osdev,
  223. HTT_MSG_BUF_SIZE(HTT_RX_RING_CFG_BYTES(1)),
  224. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4,
  225. true);
  226. if (!msg) {
  227. htt_htc_pkt_free(pdev, pkt);
  228. return A_ERROR; /* failure */
  229. }
  230. /*
  231. * Set the length of the message.
  232. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  233. * separately during the below call to cdf_nbuf_push_head.
  234. * The contribution from the HTC header is added separately inside HTC.
  235. */
  236. cdf_nbuf_put_tail(msg, HTT_RX_RING_CFG_BYTES(1));
  237. /* fill in the message contents */
  238. msg_word = (uint32_t *) cdf_nbuf_data(msg);
  239. /* rewind beyond alignment pad to get to the HTC header reserved area */
  240. cdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  241. *msg_word = 0;
  242. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_RING_CFG);
  243. HTT_RX_RING_CFG_NUM_RINGS_SET(*msg_word, 1);
  244. msg_word++;
  245. *msg_word = 0;
  246. #if HTT_PADDR64
  247. HTT_RX_RING_CFG_IDX_SHADOW_REG_PADDR_LO_SET(*msg_word,
  248. pdev->rx_ring.alloc_idx.paddr);
  249. msg_word++;
  250. HTT_RX_RING_CFG_IDX_SHADOW_REG_PADDR_HI_SET(*msg_word, 0);
  251. #else /* ! HTT_PADDR64 */
  252. HTT_RX_RING_CFG_IDX_SHADOW_REG_PADDR_SET(*msg_word,
  253. pdev->rx_ring.alloc_idx.paddr);
  254. #endif /* HTT_PADDR64 */
  255. msg_word++;
  256. *msg_word = 0;
  257. #if HTT_PADDR64
  258. HTT_RX_RING_CFG_BASE_PADDR_LO_SET(*msg_word,
  259. pdev->rx_ring.base_paddr);
  260. msg_word++;
  261. HTT_RX_RING_CFG_BASE_PADDR_HI_SET(*msg_word, 0);
  262. #else /* ! HTT_PADDR64 */
  263. HTT_RX_RING_CFG_BASE_PADDR_SET(*msg_word, pdev->rx_ring.base_paddr);
  264. #endif /* HTT_PADDR64 */
  265. msg_word++;
  266. *msg_word = 0;
  267. HTT_RX_RING_CFG_LEN_SET(*msg_word, pdev->rx_ring.size);
  268. HTT_RX_RING_CFG_BUF_SZ_SET(*msg_word, HTT_RX_BUF_SIZE);
  269. /* FIX THIS: if the FW creates a complete translated rx descriptor,
  270. * then the MAC DMA of the HW rx descriptor should be disabled.
  271. */
  272. msg_word++;
  273. *msg_word = 0;
  274. #ifndef REMOVE_PKT_LOG
  275. if (ol_cfg_is_packet_log_enabled(pdev->ctrl_pdev)) {
  276. enable_ctrl_data = 1;
  277. enable_mgmt_data = 1;
  278. enable_null_data = 1;
  279. enable_phy_data = 1;
  280. enable_hdr = 1;
  281. enable_ppdu_start = 1;
  282. enable_ppdu_end = 1;
  283. /* Disable ASPM when pkt log is enabled */
  284. cdf_print("Pkt log is enabled\n");
  285. htt_htc_disable_aspm();
  286. } else {
  287. cdf_print("Pkt log is disabled\n");
  288. enable_ctrl_data = 0;
  289. enable_mgmt_data = 0;
  290. enable_null_data = 0;
  291. enable_phy_data = 0;
  292. enable_hdr = 0;
  293. enable_ppdu_start = 0;
  294. enable_ppdu_end = 0;
  295. }
  296. #else
  297. enable_ctrl_data = 0;
  298. enable_mgmt_data = 0;
  299. enable_null_data = 0;
  300. enable_phy_data = 0;
  301. enable_hdr = 0;
  302. enable_ppdu_start = 0;
  303. enable_ppdu_end = 0;
  304. #endif
  305. HTT_RX_RING_CFG_ENABLED_802_11_HDR_SET(*msg_word, enable_hdr);
  306. HTT_RX_RING_CFG_ENABLED_MSDU_PAYLD_SET(*msg_word, 1);
  307. HTT_RX_RING_CFG_ENABLED_PPDU_START_SET(*msg_word, enable_ppdu_start);
  308. HTT_RX_RING_CFG_ENABLED_PPDU_END_SET(*msg_word, enable_ppdu_end);
  309. HTT_RX_RING_CFG_ENABLED_MPDU_START_SET(*msg_word, 1);
  310. HTT_RX_RING_CFG_ENABLED_MPDU_END_SET(*msg_word, 1);
  311. HTT_RX_RING_CFG_ENABLED_MSDU_START_SET(*msg_word, 1);
  312. HTT_RX_RING_CFG_ENABLED_MSDU_END_SET(*msg_word, 1);
  313. HTT_RX_RING_CFG_ENABLED_RX_ATTN_SET(*msg_word, 1);
  314. /* always present? */
  315. HTT_RX_RING_CFG_ENABLED_FRAG_INFO_SET(*msg_word, 1);
  316. HTT_RX_RING_CFG_ENABLED_UCAST_SET(*msg_word, 1);
  317. HTT_RX_RING_CFG_ENABLED_MCAST_SET(*msg_word, 1);
  318. /* Must change to dynamic enable at run time
  319. * rather than at compile time
  320. */
  321. HTT_RX_RING_CFG_ENABLED_CTRL_SET(*msg_word, enable_ctrl_data);
  322. HTT_RX_RING_CFG_ENABLED_MGMT_SET(*msg_word, enable_mgmt_data);
  323. HTT_RX_RING_CFG_ENABLED_NULL_SET(*msg_word, enable_null_data);
  324. HTT_RX_RING_CFG_ENABLED_PHY_SET(*msg_word, enable_phy_data);
  325. HTT_RX_RING_CFG_IDX_INIT_VAL_SET(*msg_word,
  326. *pdev->rx_ring.alloc_idx.vaddr);
  327. msg_word++;
  328. *msg_word = 0;
  329. HTT_RX_RING_CFG_OFFSET_802_11_HDR_SET(*msg_word,
  330. RX_DESC_HDR_STATUS_OFFSET32);
  331. HTT_RX_RING_CFG_OFFSET_MSDU_PAYLD_SET(*msg_word,
  332. HTT_RX_DESC_RESERVATION32);
  333. msg_word++;
  334. *msg_word = 0;
  335. HTT_RX_RING_CFG_OFFSET_PPDU_START_SET(*msg_word,
  336. RX_DESC_PPDU_START_OFFSET32);
  337. HTT_RX_RING_CFG_OFFSET_PPDU_END_SET(*msg_word,
  338. RX_DESC_PPDU_END_OFFSET32);
  339. msg_word++;
  340. *msg_word = 0;
  341. HTT_RX_RING_CFG_OFFSET_MPDU_START_SET(*msg_word,
  342. RX_DESC_MPDU_START_OFFSET32);
  343. HTT_RX_RING_CFG_OFFSET_MPDU_END_SET(*msg_word,
  344. RX_DESC_MPDU_END_OFFSET32);
  345. msg_word++;
  346. *msg_word = 0;
  347. HTT_RX_RING_CFG_OFFSET_MSDU_START_SET(*msg_word,
  348. RX_DESC_MSDU_START_OFFSET32);
  349. HTT_RX_RING_CFG_OFFSET_MSDU_END_SET(*msg_word,
  350. RX_DESC_MSDU_END_OFFSET32);
  351. msg_word++;
  352. *msg_word = 0;
  353. HTT_RX_RING_CFG_OFFSET_RX_ATTN_SET(*msg_word,
  354. RX_DESC_ATTN_OFFSET32);
  355. HTT_RX_RING_CFG_OFFSET_FRAG_INFO_SET(*msg_word,
  356. RX_DESC_FRAG_INFO_OFFSET32);
  357. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  358. htt_h2t_send_complete_free_netbuf,
  359. cdf_nbuf_data(msg),
  360. cdf_nbuf_len(msg),
  361. pdev->htc_endpoint,
  362. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  363. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  364. #ifdef ATH_11AC_TXCOMPACT
  365. if (htc_send_pkt(pdev->htc_pdev, &pkt->htc_pkt) == A_OK)
  366. htt_htc_misc_pkt_list_add(pdev, pkt);
  367. #else
  368. htc_send_pkt(pdev->htc_pdev, &pkt->htc_pkt);
  369. #endif
  370. return A_OK;
  371. }
  372. int
  373. htt_h2t_dbg_stats_get(struct htt_pdev_t *pdev,
  374. uint32_t stats_type_upload_mask,
  375. uint32_t stats_type_reset_mask,
  376. uint8_t cfg_stat_type, uint32_t cfg_val, uint64_t cookie)
  377. {
  378. struct htt_htc_pkt *pkt;
  379. cdf_nbuf_t msg;
  380. uint32_t *msg_word;
  381. uint16_t htc_tag = 1;
  382. pkt = htt_htc_pkt_alloc(pdev);
  383. if (!pkt)
  384. return -EINVAL; /* failure */
  385. if (stats_type_upload_mask >= 1 << HTT_DBG_NUM_STATS ||
  386. stats_type_reset_mask >= 1 << HTT_DBG_NUM_STATS) {
  387. /* FIX THIS - add more details? */
  388. cdf_print("%#x %#x stats not supported\n",
  389. stats_type_upload_mask, stats_type_reset_mask);
  390. return -EINVAL; /* failure */
  391. }
  392. if (stats_type_reset_mask)
  393. htc_tag = HTC_TX_PACKET_TAG_RUNTIME_PUT;
  394. /* show that this is not a tx frame download
  395. * (not required, but helpful)
  396. */
  397. pkt->msdu_id = HTT_TX_COMPL_INV_MSDU_ID;
  398. pkt->pdev_ctxt = NULL; /* not used during send-done callback */
  399. msg = cdf_nbuf_alloc(pdev->osdev,
  400. HTT_MSG_BUF_SIZE(HTT_H2T_STATS_REQ_MSG_SZ),
  401. /* reserve room for HTC header */
  402. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4,
  403. false);
  404. if (!msg) {
  405. htt_htc_pkt_free(pdev, pkt);
  406. return -EINVAL; /* failure */
  407. }
  408. /* set the length of the message */
  409. cdf_nbuf_put_tail(msg, HTT_H2T_STATS_REQ_MSG_SZ);
  410. /* fill in the message contents */
  411. msg_word = (uint32_t *) cdf_nbuf_data(msg);
  412. /* rewind beyond alignment pad to get to the HTC header reserved area */
  413. cdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  414. *msg_word = 0;
  415. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_STATS_REQ);
  416. HTT_H2T_STATS_REQ_UPLOAD_TYPES_SET(*msg_word, stats_type_upload_mask);
  417. msg_word++;
  418. *msg_word = 0;
  419. HTT_H2T_STATS_REQ_RESET_TYPES_SET(*msg_word, stats_type_reset_mask);
  420. msg_word++;
  421. *msg_word = 0;
  422. HTT_H2T_STATS_REQ_CFG_VAL_SET(*msg_word, cfg_val);
  423. HTT_H2T_STATS_REQ_CFG_STAT_TYPE_SET(*msg_word, cfg_stat_type);
  424. /* cookie LSBs */
  425. msg_word++;
  426. *msg_word = cookie & 0xffffffff;
  427. /* cookie MSBs */
  428. msg_word++;
  429. *msg_word = cookie >> 32;
  430. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  431. htt_h2t_send_complete_free_netbuf,
  432. cdf_nbuf_data(msg),
  433. cdf_nbuf_len(msg),
  434. pdev->htc_endpoint,
  435. htc_tag); /* tag - not relevant here */
  436. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  437. #ifdef ATH_11AC_TXCOMPACT
  438. if (htc_send_pkt(pdev->htc_pdev, &pkt->htc_pkt) == A_OK)
  439. htt_htc_misc_pkt_list_add(pdev, pkt);
  440. #else
  441. htc_send_pkt(pdev->htc_pdev, &pkt->htc_pkt);
  442. #endif
  443. return 0;
  444. }
  445. A_STATUS htt_h2t_sync_msg(struct htt_pdev_t *pdev, uint8_t sync_cnt)
  446. {
  447. struct htt_htc_pkt *pkt;
  448. cdf_nbuf_t msg;
  449. uint32_t *msg_word;
  450. pkt = htt_htc_pkt_alloc(pdev);
  451. if (!pkt)
  452. return A_NO_MEMORY;
  453. /* show that this is not a tx frame download
  454. (not required, but helpful)
  455. */
  456. pkt->msdu_id = HTT_TX_COMPL_INV_MSDU_ID;
  457. pkt->pdev_ctxt = NULL; /* not used during send-done callback */
  458. /* reserve room for HTC header */
  459. msg = cdf_nbuf_alloc(pdev->osdev, HTT_MSG_BUF_SIZE(HTT_H2T_SYNC_MSG_SZ),
  460. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4,
  461. false);
  462. if (!msg) {
  463. htt_htc_pkt_free(pdev, pkt);
  464. return A_NO_MEMORY;
  465. }
  466. /* set the length of the message */
  467. cdf_nbuf_put_tail(msg, HTT_H2T_SYNC_MSG_SZ);
  468. /* fill in the message contents */
  469. msg_word = (uint32_t *) cdf_nbuf_data(msg);
  470. /* rewind beyond alignment pad to get to the HTC header reserved area */
  471. cdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  472. *msg_word = 0;
  473. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_SYNC);
  474. HTT_H2T_SYNC_COUNT_SET(*msg_word, sync_cnt);
  475. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  476. htt_h2t_send_complete_free_netbuf,
  477. cdf_nbuf_data(msg),
  478. cdf_nbuf_len(msg),
  479. pdev->htc_endpoint,
  480. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  481. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  482. #ifdef ATH_11AC_TXCOMPACT
  483. if (htc_send_pkt(pdev->htc_pdev, &pkt->htc_pkt) == A_OK)
  484. htt_htc_misc_pkt_list_add(pdev, pkt);
  485. #else
  486. htc_send_pkt(pdev->htc_pdev, &pkt->htc_pkt);
  487. #endif
  488. return A_OK;
  489. }
  490. int
  491. htt_h2t_aggr_cfg_msg(struct htt_pdev_t *pdev,
  492. int max_subfrms_ampdu, int max_subfrms_amsdu)
  493. {
  494. struct htt_htc_pkt *pkt;
  495. cdf_nbuf_t msg;
  496. uint32_t *msg_word;
  497. pkt = htt_htc_pkt_alloc(pdev);
  498. if (!pkt)
  499. return -EINVAL; /* failure */
  500. /* show that this is not a tx frame download
  501. * (not required, but helpful)
  502. */
  503. pkt->msdu_id = HTT_TX_COMPL_INV_MSDU_ID;
  504. pkt->pdev_ctxt = NULL; /* not used during send-done callback */
  505. /* reserve room for HTC header */
  506. msg = cdf_nbuf_alloc(pdev->osdev, HTT_MSG_BUF_SIZE(HTT_AGGR_CFG_MSG_SZ),
  507. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4,
  508. false);
  509. if (!msg) {
  510. htt_htc_pkt_free(pdev, pkt);
  511. return -EINVAL; /* failure */
  512. }
  513. /* set the length of the message */
  514. cdf_nbuf_put_tail(msg, HTT_AGGR_CFG_MSG_SZ);
  515. /* fill in the message contents */
  516. msg_word = (uint32_t *) cdf_nbuf_data(msg);
  517. /* rewind beyond alignment pad to get to the HTC header reserved area */
  518. cdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  519. *msg_word = 0;
  520. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_AGGR_CFG);
  521. if (max_subfrms_ampdu && (max_subfrms_ampdu <= 64)) {
  522. HTT_AGGR_CFG_MAX_NUM_AMPDU_SUBFRM_SET(*msg_word,
  523. max_subfrms_ampdu);
  524. }
  525. if (max_subfrms_amsdu && (max_subfrms_amsdu < 32)) {
  526. HTT_AGGR_CFG_MAX_NUM_AMSDU_SUBFRM_SET(*msg_word,
  527. max_subfrms_amsdu);
  528. }
  529. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  530. htt_h2t_send_complete_free_netbuf,
  531. cdf_nbuf_data(msg),
  532. cdf_nbuf_len(msg),
  533. pdev->htc_endpoint,
  534. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  535. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  536. #ifdef ATH_11AC_TXCOMPACT
  537. if (htc_send_pkt(pdev->htc_pdev, &pkt->htc_pkt) == A_OK)
  538. htt_htc_misc_pkt_list_add(pdev, pkt);
  539. #else
  540. htc_send_pkt(pdev->htc_pdev, &pkt->htc_pkt);
  541. #endif
  542. return 0;
  543. }
  544. #ifdef IPA_OFFLOAD
  545. /**
  546. * htt_h2t_ipa_uc_rsc_cfg_msg() - Send WDI IPA config message to firmware
  547. * @pdev: handle to the HTT instance
  548. *
  549. * Return: 0 success
  550. * A_NO_MEMORY No memory fail
  551. */
  552. #ifdef QCA_WIFI_2_0
  553. /* Rome Support only WDI 1.0 */
  554. int htt_h2t_ipa_uc_rsc_cfg_msg(struct htt_pdev_t *pdev)
  555. {
  556. struct htt_htc_pkt *pkt;
  557. cdf_nbuf_t msg;
  558. uint32_t *msg_word;
  559. pkt = htt_htc_pkt_alloc(pdev);
  560. if (!pkt)
  561. return A_NO_MEMORY;
  562. /* show that this is not a tx frame download
  563. * (not required, but helpful)
  564. */
  565. pkt->msdu_id = HTT_TX_COMPL_INV_MSDU_ID;
  566. pkt->pdev_ctxt = NULL; /* not used during send-done callback */
  567. /* reserve room for HTC header */
  568. msg = cdf_nbuf_alloc(pdev->osdev, HTT_MSG_BUF_SIZE(HTT_WDI_IPA_CFG_SZ),
  569. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4,
  570. false);
  571. if (!msg) {
  572. htt_htc_pkt_free(pdev, pkt);
  573. return A_NO_MEMORY;
  574. }
  575. /* set the length of the message */
  576. cdf_nbuf_put_tail(msg, HTT_WDI_IPA_CFG_SZ);
  577. /* fill in the message contents */
  578. msg_word = (uint32_t *) cdf_nbuf_data(msg);
  579. /* rewind beyond alignment pad to get to the HTC header reserved area */
  580. cdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  581. *msg_word = 0;
  582. HTT_WDI_IPA_CFG_TX_PKT_POOL_SIZE_SET(*msg_word,
  583. pdev->ipa_uc_tx_rsc.alloc_tx_buf_cnt);
  584. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_WDI_IPA_CFG);
  585. msg_word++;
  586. *msg_word = 0;
  587. HTT_WDI_IPA_CFG_TX_COMP_RING_BASE_ADDR_SET(*msg_word,
  588. (unsigned int)pdev->ipa_uc_tx_rsc.tx_comp_base.paddr);
  589. msg_word++;
  590. *msg_word = 0;
  591. HTT_WDI_IPA_CFG_TX_COMP_RING_SIZE_SET(*msg_word,
  592. (unsigned int)ol_cfg_ipa_uc_tx_max_buf_cnt(pdev->ctrl_pdev));
  593. msg_word++;
  594. *msg_word = 0;
  595. HTT_WDI_IPA_CFG_TX_COMP_WR_IDX_ADDR_SET(*msg_word,
  596. (unsigned int)pdev->ipa_uc_tx_rsc.tx_comp_idx_paddr);
  597. msg_word++;
  598. *msg_word = 0;
  599. HTT_WDI_IPA_CFG_TX_CE_WR_IDX_ADDR_SET(*msg_word,
  600. (unsigned int)pdev->ipa_uc_tx_rsc.tx_ce_idx.paddr);
  601. msg_word++;
  602. *msg_word = 0;
  603. HTT_WDI_IPA_CFG_RX_IND_RING_BASE_ADDR_SET(*msg_word,
  604. (unsigned int)pdev->ipa_uc_rx_rsc.rx_ind_ring_base.paddr);
  605. msg_word++;
  606. *msg_word = 0;
  607. HTT_WDI_IPA_CFG_RX_IND_RING_SIZE_SET(*msg_word,
  608. (unsigned int)ol_cfg_ipa_uc_rx_ind_ring_size(pdev->ctrl_pdev));
  609. msg_word++;
  610. *msg_word = 0;
  611. HTT_WDI_IPA_CFG_RX_IND_RD_IDX_ADDR_SET(*msg_word,
  612. (unsigned int)pdev->ipa_uc_rx_rsc.rx_ipa_prc_done_idx.paddr);
  613. msg_word++;
  614. *msg_word = 0;
  615. HTT_WDI_IPA_CFG_RX_IND_WR_IDX_ADDR_SET(*msg_word,
  616. (unsigned int)pdev->ipa_uc_rx_rsc.rx_rdy_idx_paddr);
  617. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  618. htt_h2t_send_complete_free_netbuf,
  619. cdf_nbuf_data(msg),
  620. cdf_nbuf_len(msg),
  621. pdev->htc_endpoint,
  622. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  623. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  624. htc_send_pkt(pdev->htc_pdev, &pkt->htc_pkt);
  625. return A_OK;
  626. }
  627. #else
  628. int htt_h2t_ipa_uc_rsc_cfg_msg(struct htt_pdev_t *pdev)
  629. {
  630. struct htt_htc_pkt *pkt;
  631. cdf_nbuf_t msg;
  632. uint32_t *msg_word;
  633. pkt = htt_htc_pkt_alloc(pdev);
  634. if (!pkt)
  635. return -A_NO_MEMORY;
  636. /* show that this is not a tx frame download
  637. * (not required, but helpful)
  638. */
  639. pkt->msdu_id = HTT_TX_COMPL_INV_MSDU_ID;
  640. pkt->pdev_ctxt = NULL; /* not used during send-done callback */
  641. /* reserve room for HTC header */
  642. msg = cdf_nbuf_alloc(pdev->osdev, HTT_MSG_BUF_SIZE(HTT_WDI_IPA_CFG_SZ),
  643. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4,
  644. false);
  645. if (!msg) {
  646. htt_htc_pkt_free(pdev, pkt);
  647. return -A_NO_MEMORY;
  648. }
  649. /* set the length of the message */
  650. cdf_nbuf_put_tail(msg, HTT_WDI_IPA_CFG_SZ);
  651. /* fill in the message contents */
  652. msg_word = (uint32_t *) cdf_nbuf_data(msg);
  653. /* rewind beyond alignment pad to get to the HTC header reserved area */
  654. cdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  655. *msg_word = 0;
  656. HTT_WDI_IPA_CFG_TX_PKT_POOL_SIZE_SET(*msg_word,
  657. pdev->ipa_uc_tx_rsc.alloc_tx_buf_cnt);
  658. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_WDI_IPA_CFG);
  659. msg_word++;
  660. *msg_word = 0;
  661. /* TX COMP RING BASE LO */
  662. HTT_WDI_IPA_CFG_TX_COMP_RING_BASE_ADDR_LO_SET(*msg_word,
  663. (unsigned int)pdev->ipa_uc_tx_rsc.tx_comp_base.paddr);
  664. msg_word++;
  665. *msg_word = 0;
  666. /* TX COMP RING BASE HI, NONE */
  667. msg_word++;
  668. *msg_word = 0;
  669. HTT_WDI_IPA_CFG_TX_COMP_RING_SIZE_SET(*msg_word,
  670. (unsigned int)ol_cfg_ipa_uc_tx_max_buf_cnt(pdev->ctrl_pdev));
  671. msg_word++;
  672. *msg_word = 0;
  673. HTT_WDI_IPA_CFG_TX_COMP_WR_IDX_ADDR_LO_SET(*msg_word,
  674. (unsigned int)pdev->ipa_uc_tx_rsc.tx_comp_idx_paddr);
  675. msg_word++;
  676. *msg_word = 0;
  677. msg_word++;
  678. *msg_word = 0;
  679. HTT_WDI_IPA_CFG_TX_CE_WR_IDX_ADDR_LO_SET(*msg_word,
  680. (unsigned int)pdev->ipa_uc_tx_rsc.tx_ce_idx.paddr);
  681. msg_word++;
  682. *msg_word = 0;
  683. msg_word++;
  684. *msg_word = 0;
  685. HTT_WDI_IPA_CFG_RX_IND_RING_BASE_ADDR_LO_SET(*msg_word,
  686. (unsigned int)pdev->ipa_uc_rx_rsc.rx_ind_ring_base.paddr);
  687. msg_word++;
  688. *msg_word = 0;
  689. HTT_WDI_IPA_CFG_RX_IND_RING_BASE_ADDR_HI_SET(*msg_word,
  690. 0);
  691. msg_word++;
  692. *msg_word = 0;
  693. HTT_WDI_IPA_CFG_RX_IND_RING_SIZE_SET(*msg_word,
  694. (unsigned int)ol_cfg_ipa_uc_rx_ind_ring_size(pdev->ctrl_pdev));
  695. msg_word++;
  696. *msg_word = 0;
  697. HTT_WDI_IPA_CFG_RX_IND_RD_IDX_ADDR_LO_SET(*msg_word,
  698. (unsigned int)pdev->ipa_uc_rx_rsc.rx_ipa_prc_done_idx.paddr);
  699. msg_word++;
  700. *msg_word = 0;
  701. HTT_WDI_IPA_CFG_RX_IND_RD_IDX_ADDR_HI_SET(*msg_word,
  702. 0);
  703. msg_word++;
  704. *msg_word = 0;
  705. HTT_WDI_IPA_CFG_RX_IND_WR_IDX_ADDR_LO_SET(*msg_word,
  706. (unsigned int)pdev->ipa_uc_rx_rsc.rx_rdy_idx_paddr);
  707. msg_word++;
  708. *msg_word = 0;
  709. HTT_WDI_IPA_CFG_RX_IND_WR_IDX_ADDR_HI_SET(*msg_word,
  710. 0);
  711. msg_word++;
  712. *msg_word = 0;
  713. HTT_WDI_IPA_CFG_RX_RING2_BASE_ADDR_LO_SET(*msg_word,
  714. (unsigned int)pdev->ipa_uc_rx_rsc.rx2_ind_ring_base.paddr);
  715. msg_word++;
  716. *msg_word = 0;
  717. HTT_WDI_IPA_CFG_RX_RING2_BASE_ADDR_HI_SET(*msg_word,
  718. 0);
  719. msg_word++;
  720. *msg_word = 0;
  721. HTT_WDI_IPA_CFG_RX_RING2_SIZE_SET(*msg_word,
  722. (unsigned int)ol_cfg_ipa_uc_rx_ind_ring_size(pdev->ctrl_pdev));
  723. msg_word++;
  724. *msg_word = 0;
  725. HTT_WDI_IPA_CFG_RX_RING2_RD_IDX_ADDR_LO_SET(*msg_word,
  726. (unsigned int)pdev->ipa_uc_rx_rsc.rx2_ipa_prc_done_idx.paddr);
  727. msg_word++;
  728. *msg_word = 0;
  729. HTT_WDI_IPA_CFG_RX_RING2_RD_IDX_ADDR_HI_SET(*msg_word,
  730. 0);
  731. msg_word++;
  732. *msg_word = 0;
  733. HTT_WDI_IPA_CFG_RX_RING2_WR_IDX_ADDR_LO_SET(*msg_word,
  734. (unsigned int)pdev->ipa_uc_rx_rsc.rx2_ipa_prc_done_idx.paddr);
  735. msg_word++;
  736. *msg_word = 0;
  737. HTT_WDI_IPA_CFG_RX_RING2_WR_IDX_ADDR_HI_SET(*msg_word,
  738. 0);
  739. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  740. htt_h2t_send_complete_free_netbuf,
  741. cdf_nbuf_data(msg),
  742. cdf_nbuf_len(msg),
  743. pdev->htc_endpoint,
  744. 1); /* tag - not relevant here */
  745. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  746. htc_send_pkt(pdev->htc_pdev, &pkt->htc_pkt);
  747. return A_OK;
  748. }
  749. #endif
  750. /**
  751. * htt_h2t_ipa_uc_set_active() - Propagate WDI path enable/disable to firmware
  752. * @pdev: handle to the HTT instance
  753. * @uc_active: WDI UC path enable or not
  754. * @is_tx: TX path or RX path
  755. *
  756. * Return: 0 success
  757. * A_NO_MEMORY No memory fail
  758. */
  759. int htt_h2t_ipa_uc_set_active(struct htt_pdev_t *pdev,
  760. bool uc_active, bool is_tx)
  761. {
  762. struct htt_htc_pkt *pkt;
  763. cdf_nbuf_t msg;
  764. uint32_t *msg_word;
  765. uint8_t active_target = 0;
  766. pkt = htt_htc_pkt_alloc(pdev);
  767. if (!pkt)
  768. return -A_NO_MEMORY;
  769. /* show that this is not a tx frame download
  770. * (not required, but helpful)
  771. */
  772. pkt->msdu_id = HTT_TX_COMPL_INV_MSDU_ID;
  773. pkt->pdev_ctxt = NULL; /* not used during send-done callback */
  774. /* reserve room for HTC header */
  775. msg = cdf_nbuf_alloc(pdev->osdev,
  776. HTT_MSG_BUF_SIZE(HTT_WDI_IPA_OP_REQUEST_SZ),
  777. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4,
  778. false);
  779. if (!msg) {
  780. htt_htc_pkt_free(pdev, pkt);
  781. return -A_NO_MEMORY;
  782. }
  783. /* set the length of the message */
  784. cdf_nbuf_put_tail(msg, HTT_WDI_IPA_OP_REQUEST_SZ);
  785. /* fill in the message contents */
  786. msg_word = (uint32_t *) cdf_nbuf_data(msg);
  787. /* rewind beyond alignment pad to get to the HTC header reserved area */
  788. cdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  789. *msg_word = 0;
  790. if (uc_active && is_tx)
  791. active_target = HTT_WDI_IPA_OPCODE_TX_RESUME;
  792. else if (!uc_active && is_tx)
  793. active_target = HTT_WDI_IPA_OPCODE_TX_SUSPEND;
  794. else if (uc_active && !is_tx)
  795. active_target = HTT_WDI_IPA_OPCODE_RX_RESUME;
  796. else if (!uc_active && !is_tx)
  797. active_target = HTT_WDI_IPA_OPCODE_RX_SUSPEND;
  798. HTT_WDI_IPA_OP_REQUEST_OP_CODE_SET(*msg_word, active_target);
  799. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_WDI_IPA_OP_REQ);
  800. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  801. htt_h2t_send_complete_free_netbuf,
  802. cdf_nbuf_data(msg),
  803. cdf_nbuf_len(msg),
  804. pdev->htc_endpoint,
  805. 1); /* tag - not relevant here */
  806. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  807. htc_send_pkt(pdev->htc_pdev, &pkt->htc_pkt);
  808. return A_OK;
  809. }
  810. /**
  811. * htt_h2t_ipa_uc_get_stats() - WDI UC state query request to firmware
  812. * @pdev: handle to the HTT instance
  813. *
  814. * Return: 0 success
  815. * A_NO_MEMORY No memory fail
  816. */
  817. int htt_h2t_ipa_uc_get_stats(struct htt_pdev_t *pdev)
  818. {
  819. struct htt_htc_pkt *pkt;
  820. cdf_nbuf_t msg;
  821. uint32_t *msg_word;
  822. pkt = htt_htc_pkt_alloc(pdev);
  823. if (!pkt)
  824. return -A_NO_MEMORY;
  825. /* show that this is not a tx frame download
  826. * (not required, but helpful)
  827. */
  828. pkt->msdu_id = HTT_TX_COMPL_INV_MSDU_ID;
  829. pkt->pdev_ctxt = NULL; /* not used during send-done callback */
  830. /* reserve room for HTC header */
  831. msg = cdf_nbuf_alloc(pdev->osdev,
  832. HTT_MSG_BUF_SIZE(HTT_WDI_IPA_OP_REQUEST_SZ),
  833. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4,
  834. false);
  835. if (!msg) {
  836. htt_htc_pkt_free(pdev, pkt);
  837. return -A_NO_MEMORY;
  838. }
  839. /* set the length of the message */
  840. cdf_nbuf_put_tail(msg, HTT_WDI_IPA_OP_REQUEST_SZ);
  841. /* fill in the message contents */
  842. msg_word = (uint32_t *) cdf_nbuf_data(msg);
  843. /* rewind beyond alignment pad to get to the HTC header reserved area */
  844. cdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  845. *msg_word = 0;
  846. HTT_WDI_IPA_OP_REQUEST_OP_CODE_SET(*msg_word,
  847. HTT_WDI_IPA_OPCODE_DBG_STATS);
  848. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_WDI_IPA_OP_REQ);
  849. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  850. htt_h2t_send_complete_free_netbuf,
  851. cdf_nbuf_data(msg),
  852. cdf_nbuf_len(msg),
  853. pdev->htc_endpoint,
  854. 1); /* tag - not relevant here */
  855. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  856. htc_send_pkt(pdev->htc_pdev, &pkt->htc_pkt);
  857. return A_OK;
  858. }
  859. #endif /* IPA_OFFLOAD */