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