blob: a37b3e2c721876caa1ff71660c191366c3fcd9d8 [file] [log] [blame]
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07001/*
Jeff Johnson2cb8fc72016-12-17 10:45:08 -08002 * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07003 *
4 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#include <htt.h>
20#include <hal_api.h>
Leo Chang5ea93a42016-11-03 12:39:49 -070021#include "dp_htt.h"
Jeff Johnson2cb8fc72016-12-17 10:45:08 -080022#include "dp_peer.h"
Dhanashri Atre2ea8c0f2017-02-08 11:09:56 -080023#include "dp_types.h"
Pramod Simhab17d0672017-03-06 17:20:13 -080024#include "dp_internal.h"
Kai Chen6eca1a62017-01-12 10:17:53 -080025#include "dp_rx_mon.h"
Ishank Jain6290a3c2017-03-21 10:49:39 +053026#include "htt_stats.h"
Pamidipati, Vijay038d0902017-07-17 09:53:31 +053027#include "htt_ppdu_stats.h"
Keyur Parekhfad6d082017-05-07 08:54:47 -070028#include "qdf_mem.h" /* qdf_mem_malloc,free */
Pamidipati, Vijay038d0902017-07-17 09:53:31 +053029#include "cdp_txrx_cmn_struct.h"
Ishank Jain6290a3c2017-03-21 10:49:39 +053030
31#define HTT_TLV_HDR_LEN HTT_T2H_EXT_STATS_CONF_TLV_HDR_SIZE
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -070032
33#define HTT_HTC_PKT_POOL_INIT_SIZE 64
Keyur Parekhfad6d082017-05-07 08:54:47 -070034#define HTT_T2H_MAX_MSG_SIZE 2048
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -070035
36#define HTT_MSG_BUF_SIZE(msg_bytes) \
37 ((msg_bytes) + HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING)
38
Ishank Jain6290a3c2017-03-21 10:49:39 +053039#define DP_EXT_MSG_LENGTH 2048
Pramod Simhae0baa442017-06-27 15:21:39 -070040#define DP_HTT_SEND_HTC_PKT(soc, pkt) \
41do { \
42 if (htc_send_pkt(soc->htc_soc, &pkt->htc_pkt) == \
43 QDF_STATUS_SUCCESS) \
44 htt_htc_misc_pkt_list_add(soc, pkt); \
45} while (0)
46
Soumya Bhatcfbb8952017-10-03 15:04:09 +053047#define HTT_MGMT_CTRL_TLV_RESERVERD_LEN 12
48
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -070049/*
Pamidipati, Vijay038d0902017-07-17 09:53:31 +053050 * dp_tx_stats_update() - Update per-peer statistics
51 * @soc: Datapath soc handle
52 * @peer: Datapath peer handle
53 * @ppdu: PPDU Descriptor
54 * @ack_rssi: RSSI of last ack received
55 *
56 * Return: None
57 */
58#ifdef FEATURE_PERPKT_INFO
59static void dp_tx_stats_update(struct dp_soc *soc, struct dp_peer *peer,
60 struct cdp_tx_completion_ppdu_user *ppdu, uint32_t ack_rssi)
61{
Soumya Bhat1c73aa62017-09-20 22:18:22 +053062 struct dp_pdev *pdev = peer->vdev->pdev;
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +053063 uint8_t preamble, mcs;
64 uint16_t num_msdu;
65
66 preamble = ppdu->preamble;
67 mcs = ppdu->mcs;
68 num_msdu = ppdu->num_msdu;
Pamidipati, Vijay038d0902017-07-17 09:53:31 +053069
Pamidipati, Vijaybd9c13f2017-10-17 20:12:03 +053070 /* If the peer statistics are already processed as part of
71 * per-MSDU completion handler, do not process these again in per-PPDU
72 * indications */
73 if (soc->process_tx_status)
74 return;
75
Pamidipati, Vijay038d0902017-07-17 09:53:31 +053076 DP_STATS_INC_PKT(peer, tx.comp_pkt,
Pranita Solankea12b4b32017-11-20 23:04:14 +053077 num_msdu, (ppdu->success_bytes +
78 ppdu->retry_bytes + ppdu->failed_bytes));
Pamidipati, Vijay038d0902017-07-17 09:53:31 +053079 DP_STATS_INC(peer, tx.tx_failed, ppdu->failed_msdus);
Pranita Solankea12b4b32017-11-20 23:04:14 +053080 DP_STATS_UPD(peer, tx.tx_rate, ppdu->tx_rate);
81 DP_STATS_INC(peer, tx.sgi_count[ppdu->gi], num_msdu);
82 DP_STATS_INC(peer, tx.bw[ppdu->bw], num_msdu);
Pamidipati, Vijay038d0902017-07-17 09:53:31 +053083 DP_STATS_UPD(peer, tx.last_ack_rssi, ack_rssi);
Pranita Solankea12b4b32017-11-20 23:04:14 +053084 DP_STATS_INC(peer, tx.wme_ac_type[TID_TO_WME_AC(ppdu->tid)], num_msdu);
85 DP_STATS_INCC(peer, tx.stbc, num_msdu, ppdu->stbc);
86 DP_STATS_INCC(peer, tx.ldpc, num_msdu, ppdu->ldpc);
Pamidipati, Vijay038d0902017-07-17 09:53:31 +053087 DP_STATS_INC_PKT(peer, tx.tx_success, ppdu->success_msdus,
88 ppdu->success_bytes);
Pranita Solankea12b4b32017-11-20 23:04:14 +053089 if (ppdu->is_mcast) {
90 DP_STATS_INC_PKT(peer, tx.mcast, num_msdu, (ppdu->success_bytes
91 + ppdu->retry_bytes +
92 ppdu->failed_bytes));
93 } else {
94 DP_STATS_INC_PKT(peer, tx.ucast, num_msdu, (ppdu->success_bytes
95 + ppdu->retry_bytes +
96 ppdu->failed_bytes));
97 }
98
Pamidipati, Vijay038d0902017-07-17 09:53:31 +053099 DP_STATS_INC(peer, tx.retries,
100 (ppdu->long_retries + ppdu->short_retries));
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530101 DP_STATS_INCC(peer,
102 tx.pkt_type[preamble].mcs_count[MAX_MCS], num_msdu,
103 ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A)));
104 DP_STATS_INCC(peer,
105 tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
106 ((mcs < MAX_MCS_11A) && (preamble == DOT11_A)));
107 DP_STATS_INCC(peer,
108 tx.pkt_type[preamble].mcs_count[MAX_MCS], num_msdu,
109 ((mcs >= MAX_MCS_11B) && (preamble == DOT11_B)));
110 DP_STATS_INCC(peer,
111 tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
112 ((mcs < (MAX_MCS_11B)) && (preamble == DOT11_B)));
113 DP_STATS_INCC(peer,
114 tx.pkt_type[preamble].mcs_count[MAX_MCS], num_msdu,
115 ((mcs >= MAX_MCS_11A) && (preamble == DOT11_N)));
116 DP_STATS_INCC(peer,
117 tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
118 ((mcs < MAX_MCS_11A) && (preamble == DOT11_N)));
119 DP_STATS_INCC(peer,
120 tx.pkt_type[preamble].mcs_count[MAX_MCS], num_msdu,
121 ((mcs >= MAX_MCS_11AC) && (preamble == DOT11_AC)));
122 DP_STATS_INCC(peer,
123 tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
124 ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC)));
125 DP_STATS_INCC(peer,
126 tx.pkt_type[preamble].mcs_count[MAX_MCS], num_msdu,
127 ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX)));
128 DP_STATS_INCC(peer,
129 tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
130 ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX)));
Pamidipati, Vijay038d0902017-07-17 09:53:31 +0530131
132 if (soc->cdp_soc.ol_ops->update_dp_stats) {
133 soc->cdp_soc.ol_ops->update_dp_stats(pdev->osif_pdev,
134 &peer->stats, ppdu->peer_id,
135 UPDATE_PEER_STATS);
136 }
137}
138#endif
139
140/*
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -0700141 * htt_htc_pkt_alloc() - Allocate HTC packet buffer
142 * @htt_soc: HTT SOC handle
143 *
144 * Return: Pointer to htc packet buffer
145 */
146static struct dp_htt_htc_pkt *
147htt_htc_pkt_alloc(struct htt_soc *soc)
148{
149 struct dp_htt_htc_pkt_union *pkt = NULL;
150
151 HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
152 if (soc->htt_htc_pkt_freelist) {
153 pkt = soc->htt_htc_pkt_freelist;
154 soc->htt_htc_pkt_freelist = soc->htt_htc_pkt_freelist->u.next;
155 }
156 HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
157
158 if (pkt == NULL)
159 pkt = qdf_mem_malloc(sizeof(*pkt));
160 return &pkt->u.pkt; /* not actually a dereference */
161}
162
163/*
164 * htt_htc_pkt_free() - Free HTC packet buffer
165 * @htt_soc: HTT SOC handle
166 */
167static void
168htt_htc_pkt_free(struct htt_soc *soc, struct dp_htt_htc_pkt *pkt)
169{
170 struct dp_htt_htc_pkt_union *u_pkt =
171 (struct dp_htt_htc_pkt_union *)pkt;
172
173 HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
174 u_pkt->u.next = soc->htt_htc_pkt_freelist;
175 soc->htt_htc_pkt_freelist = u_pkt;
176 HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
177}
178
179/*
180 * htt_htc_pkt_pool_free() - Free HTC packet pool
181 * @htt_soc: HTT SOC handle
182 */
183static void
184htt_htc_pkt_pool_free(struct htt_soc *soc)
185{
186 struct dp_htt_htc_pkt_union *pkt, *next;
187 pkt = soc->htt_htc_pkt_freelist;
188 while (pkt) {
189 next = pkt->u.next;
190 qdf_mem_free(pkt);
191 pkt = next;
192 }
193 soc->htt_htc_pkt_freelist = NULL;
194}
195
196/*
Pramod Simhae0baa442017-06-27 15:21:39 -0700197 * htt_htc_misc_pkt_list_trim() - trim misc list
198 * @htt_soc: HTT SOC handle
199 * @level: max no. of pkts in list
200 */
201static void
202htt_htc_misc_pkt_list_trim(struct htt_soc *soc, int level)
203{
204 struct dp_htt_htc_pkt_union *pkt, *next, *prev = NULL;
205 int i = 0;
206 qdf_nbuf_t netbuf;
207
208 HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
209 pkt = soc->htt_htc_pkt_misclist;
210 while (pkt) {
211 next = pkt->u.next;
212 /* trim the out grown list*/
213 if (++i > level) {
214 netbuf =
215 (qdf_nbuf_t)(pkt->u.pkt.htc_pkt.pNetBufContext);
216 qdf_nbuf_unmap(soc->osdev, netbuf, QDF_DMA_TO_DEVICE);
217 qdf_nbuf_free(netbuf);
218 qdf_mem_free(pkt);
219 pkt = NULL;
220 if (prev)
221 prev->u.next = NULL;
222 }
223 prev = pkt;
224 pkt = next;
225 }
226 HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
227}
228
229/*
230 * htt_htc_misc_pkt_list_add() - Add pkt to misc list
231 * @htt_soc: HTT SOC handle
232 * @dp_htt_htc_pkt: pkt to be added to list
233 */
234static void
235htt_htc_misc_pkt_list_add(struct htt_soc *soc, struct dp_htt_htc_pkt *pkt)
236{
237 struct dp_htt_htc_pkt_union *u_pkt =
238 (struct dp_htt_htc_pkt_union *)pkt;
239 int misclist_trim_level = htc_get_tx_queue_depth(soc->htc_soc,
240 pkt->htc_pkt.Endpoint)
241 + DP_HTT_HTC_PKT_MISCLIST_SIZE;
242
243 HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
244 if (soc->htt_htc_pkt_misclist) {
245 u_pkt->u.next = soc->htt_htc_pkt_misclist;
246 soc->htt_htc_pkt_misclist = u_pkt;
247 } else {
248 soc->htt_htc_pkt_misclist = u_pkt;
249 }
250 HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
251
252 /* only ce pipe size + tx_queue_depth could possibly be in use
253 * free older packets in the misclist
254 */
255 htt_htc_misc_pkt_list_trim(soc, misclist_trim_level);
256}
257
258/*
259 * htt_htc_misc_pkt_pool_free() - free pkts in misc list
260 * @htt_soc: HTT SOC handle
261 */
262static void
263htt_htc_misc_pkt_pool_free(struct htt_soc *soc)
264{
265 struct dp_htt_htc_pkt_union *pkt, *next;
266 qdf_nbuf_t netbuf;
267
268 pkt = soc->htt_htc_pkt_misclist;
269
270 while (pkt) {
271 next = pkt->u.next;
272 netbuf = (qdf_nbuf_t) (pkt->u.pkt.htc_pkt.pNetBufContext);
273 qdf_nbuf_unmap(soc->osdev, netbuf, QDF_DMA_TO_DEVICE);
274
275 soc->stats.htc_pkt_free++;
Houston Hoffman41b912c2017-08-30 14:27:51 -0700276 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
Pramod Simhae0baa442017-06-27 15:21:39 -0700277 "%s: Pkt free count %d\n",
278 __func__, soc->stats.htc_pkt_free);
279
280 qdf_nbuf_free(netbuf);
281 qdf_mem_free(pkt);
282 pkt = next;
283 }
284 soc->htt_htc_pkt_misclist = NULL;
285}
286
287/*
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -0700288 * htt_t2h_mac_addr_deswizzle() - Swap MAC addr bytes if FW endianess differ
289 * @tgt_mac_addr: Target MAC
290 * @buffer: Output buffer
291 */
292static u_int8_t *
293htt_t2h_mac_addr_deswizzle(u_int8_t *tgt_mac_addr, u_int8_t *buffer)
294{
295#ifdef BIG_ENDIAN_HOST
296 /*
297 * The host endianness is opposite of the target endianness.
298 * To make u_int32_t elements come out correctly, the target->host
299 * upload has swizzled the bytes in each u_int32_t element of the
300 * message.
301 * For byte-array message fields like the MAC address, this
302 * upload swizzling puts the bytes in the wrong order, and needs
303 * to be undone.
304 */
305 buffer[0] = tgt_mac_addr[3];
306 buffer[1] = tgt_mac_addr[2];
307 buffer[2] = tgt_mac_addr[1];
308 buffer[3] = tgt_mac_addr[0];
309 buffer[4] = tgt_mac_addr[7];
310 buffer[5] = tgt_mac_addr[6];
311 return buffer;
312#else
313 /*
314 * The host endianness matches the target endianness -
315 * we can use the mac addr directly from the message buffer.
316 */
317 return tgt_mac_addr;
318#endif
319}
320
321/*
322 * dp_htt_h2t_send_complete_free_netbuf() - Free completed buffer
323 * @soc: SOC handle
324 * @status: Completion status
325 * @netbuf: HTT buffer
326 */
327static void
328dp_htt_h2t_send_complete_free_netbuf(
329 void *soc, A_STATUS status, qdf_nbuf_t netbuf)
330{
331 qdf_nbuf_free(netbuf);
332}
333
334/*
335 * dp_htt_h2t_send_complete() - H2T completion handler
336 * @context: Opaque context (HTT SOC handle)
337 * @htc_pkt: HTC packet
338 */
Jeff Johnson32140742017-01-05 15:30:47 -0800339static void
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -0700340dp_htt_h2t_send_complete(void *context, HTC_PACKET *htc_pkt)
341{
342 void (*send_complete_part2)(
343 void *soc, A_STATUS status, qdf_nbuf_t msdu);
344 struct htt_soc *soc = (struct htt_soc *) context;
345 struct dp_htt_htc_pkt *htt_pkt;
346 qdf_nbuf_t netbuf;
347
348 send_complete_part2 = htc_pkt->pPktContext;
349
350 htt_pkt = container_of(htc_pkt, struct dp_htt_htc_pkt, htc_pkt);
351
352 /* process (free or keep) the netbuf that held the message */
353 netbuf = (qdf_nbuf_t) htc_pkt->pNetBufContext;
354 /*
355 * adf sendcomplete is required for windows only
356 */
357 /* qdf_nbuf_set_sendcompleteflag(netbuf, TRUE); */
358 if (send_complete_part2 != NULL) {
359 send_complete_part2(
360 htt_pkt->soc_ctxt, htc_pkt->Status, netbuf);
361 }
362 /* free the htt_htc_pkt / HTC_PACKET object */
363 htt_htc_pkt_free(soc, htt_pkt);
364}
365
366/*
367 * htt_h2t_ver_req_msg() - Send HTT version request message to target
368 * @htt_soc: HTT SOC handle
369 *
370 * Return: 0 on success; error code on failure
371 */
372static int htt_h2t_ver_req_msg(struct htt_soc *soc)
373{
374 struct dp_htt_htc_pkt *pkt;
375 qdf_nbuf_t msg;
376 uint32_t *msg_word;
377
378 msg = qdf_nbuf_alloc(
379 soc->osdev,
380 HTT_MSG_BUF_SIZE(HTT_VER_REQ_BYTES),
381 /* reserve room for the HTC header */
382 HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
383 if (!msg)
384 return QDF_STATUS_E_NOMEM;
385
386 /*
387 * Set the length of the message.
388 * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
389 * separately during the below call to qdf_nbuf_push_head.
390 * The contribution from the HTC header is added separately inside HTC.
391 */
392 if (qdf_nbuf_put_tail(msg, HTT_VER_REQ_BYTES) == NULL) {
393 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
394 "%s: Failed to expand head for HTT_H2T_MSG_TYPE_VERSION_REQ msg\n",
395 __func__);
396 return QDF_STATUS_E_FAILURE;
397 }
398
399 /* fill in the message contents */
400 msg_word = (u_int32_t *) qdf_nbuf_data(msg);
401
402 /* rewind beyond alignment pad to get to the HTC header reserved area */
403 qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
404
405 *msg_word = 0;
406 HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_VERSION_REQ);
407
408 pkt = htt_htc_pkt_alloc(soc);
409 if (!pkt) {
410 qdf_nbuf_free(msg);
411 return QDF_STATUS_E_FAILURE;
412 }
413 pkt->soc_ctxt = NULL; /* not used during send-done callback */
414
415 SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
416 dp_htt_h2t_send_complete_free_netbuf, qdf_nbuf_data(msg),
417 qdf_nbuf_len(msg), soc->htc_endpoint,
418 1); /* tag - not relevant here */
419
420 SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
Pramod Simhae0baa442017-06-27 15:21:39 -0700421 DP_HTT_SEND_HTC_PKT(soc, pkt);
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -0700422 return 0;
423}
424
425/*
426 * htt_srng_setup() - Send SRNG setup message to target
427 * @htt_soc: HTT SOC handle
Dhanashri Atred4032ab2017-01-17 15:05:41 -0800428 * @mac_id: MAC Id
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -0700429 * @hal_srng: Opaque HAL SRNG pointer
430 * @hal_ring_type: SRNG ring type
431 *
432 * Return: 0 on success; error code on failure
433 */
Dhanashri Atred4032ab2017-01-17 15:05:41 -0800434int htt_srng_setup(void *htt_soc, int mac_id, void *hal_srng,
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -0700435 int hal_ring_type)
436{
437 struct htt_soc *soc = (struct htt_soc *)htt_soc;
438 struct dp_htt_htc_pkt *pkt;
439 qdf_nbuf_t htt_msg;
440 uint32_t *msg_word;
441 struct hal_srng_params srng_params;
442 qdf_dma_addr_t hp_addr, tp_addr;
443 uint32_t ring_entry_size =
444 hal_srng_get_entrysize(soc->hal_soc, hal_ring_type);
445 int htt_ring_type, htt_ring_id;
446
447 /* Sizes should be set in 4-byte words */
448 ring_entry_size = ring_entry_size >> 2;
449
450 htt_msg = qdf_nbuf_alloc(soc->osdev,
451 HTT_MSG_BUF_SIZE(HTT_SRING_SETUP_SZ),
452 /* reserve room for the HTC header */
453 HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
454 if (!htt_msg)
455 goto fail0;
456
457 hal_get_srng_params(soc->hal_soc, hal_srng, &srng_params);
458 hp_addr = hal_srng_get_hp_addr(soc->hal_soc, hal_srng);
459 tp_addr = hal_srng_get_tp_addr(soc->hal_soc, hal_srng);
460
461 switch (hal_ring_type) {
462 case RXDMA_BUF:
Dhanashri Atre7351d172016-10-12 13:08:09 -0700463#ifdef QCA_HOST2FW_RXBUF_RING
Manoj Ekbote46c03162017-02-16 21:32:00 -0800464 if (srng_params.ring_id ==
Yun Parkfde6b9e2017-06-26 17:13:11 -0700465 (HAL_SRNG_WMAC1_SW2RXDMA0_BUF0)) {
Dhanashri Atre7351d172016-10-12 13:08:09 -0700466 htt_ring_id = HTT_HOST1_TO_FW_RXBUF_RING;
467 htt_ring_type = HTT_SW_TO_SW_RING;
Yun Parkfde6b9e2017-06-26 17:13:11 -0700468#ifdef IPA_OFFLOAD
469 } else if (srng_params.ring_id ==
470 (HAL_SRNG_WMAC1_SW2RXDMA0_BUF2)) {
471 htt_ring_id = HTT_HOST2_TO_FW_RXBUF_RING;
472 htt_ring_type = HTT_SW_TO_SW_RING;
473#endif
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -0700474#else
Manoj Ekbote46c03162017-02-16 21:32:00 -0800475 if (srng_params.ring_id ==
Yun Parkfde6b9e2017-06-26 17:13:11 -0700476 (HAL_SRNG_WMAC1_SW2RXDMA0_BUF0 +
Manoj Ekbote46c03162017-02-16 21:32:00 -0800477 (mac_id * HAL_MAX_RINGS_PER_LMAC))) {
Dhanashri Atre7351d172016-10-12 13:08:09 -0700478 htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
479 htt_ring_type = HTT_SW_TO_HW_RING;
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -0700480#endif
Dhanashri Atred4032ab2017-01-17 15:05:41 -0800481 } else if (srng_params.ring_id ==
Yun Parkfde6b9e2017-06-26 17:13:11 -0700482#ifdef IPA_OFFLOAD
483 (HAL_SRNG_WMAC1_SW2RXDMA0_BUF1 +
484#else
Dhanashri Atred4032ab2017-01-17 15:05:41 -0800485 (HAL_SRNG_WMAC1_SW2RXDMA1_BUF +
Yun Parkfde6b9e2017-06-26 17:13:11 -0700486#endif
Dhanashri Atred4032ab2017-01-17 15:05:41 -0800487 (mac_id * HAL_MAX_RINGS_PER_LMAC))) {
Dhanashri Atre7351d172016-10-12 13:08:09 -0700488 htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
489 htt_ring_type = HTT_SW_TO_HW_RING;
Dhanashri Atred4032ab2017-01-17 15:05:41 -0800490 } else {
Dhanashri Atre7351d172016-10-12 13:08:09 -0700491 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
Yun Parkfde6b9e2017-06-26 17:13:11 -0700492 "%s: Ring %d currently not supported\n",
493 __func__, srng_params.ring_id);
Dhanashri Atre7351d172016-10-12 13:08:09 -0700494 goto fail1;
495 }
Dhanashri Atred4032ab2017-01-17 15:05:41 -0800496
Dhanashri Atre7351d172016-10-12 13:08:09 -0700497 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
498 "%s: ring_type %d ring_id %d\n",
499 __func__, hal_ring_type, srng_params.ring_id);
500 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
Dhanashri Atred4032ab2017-01-17 15:05:41 -0800501 "%s: hp_addr 0x%llx tp_addr 0x%llx\n",
502 __func__, (uint64_t)hp_addr, (uint64_t)tp_addr);
Dhanashri Atre7351d172016-10-12 13:08:09 -0700503 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
Dhanashri Atred4032ab2017-01-17 15:05:41 -0800504 "%s: htt_ring_id %d\n", __func__, htt_ring_id);
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -0700505 break;
506 case RXDMA_MONITOR_BUF:
507 htt_ring_id = HTT_RXDMA_MONITOR_BUF_RING;
508 htt_ring_type = HTT_SW_TO_HW_RING;
509 break;
510 case RXDMA_MONITOR_STATUS:
511 htt_ring_id = HTT_RXDMA_MONITOR_STATUS_RING;
512 htt_ring_type = HTT_SW_TO_HW_RING;
513 break;
514 case RXDMA_MONITOR_DST:
515 htt_ring_id = HTT_RXDMA_MONITOR_DEST_RING;
516 htt_ring_type = HTT_HW_TO_SW_RING;
517 break;
Kai Chen6eca1a62017-01-12 10:17:53 -0800518 case RXDMA_MONITOR_DESC:
519 htt_ring_id = HTT_RXDMA_MONITOR_DESC_RING;
520 htt_ring_type = HTT_SW_TO_HW_RING;
521 break;
Pramod Simhae382ff82017-06-05 18:09:26 -0700522 case RXDMA_DST:
523 htt_ring_id = HTT_RXDMA_NON_MONITOR_DEST_RING;
524 htt_ring_type = HTT_HW_TO_SW_RING;
525 break;
Kai Chen6eca1a62017-01-12 10:17:53 -0800526
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -0700527 default:
528 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
529 "%s: Ring currently not supported\n", __func__);
530 goto fail1;
531 }
532
533 /*
534 * Set the length of the message.
535 * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
536 * separately during the below call to qdf_nbuf_push_head.
537 * The contribution from the HTC header is added separately inside HTC.
538 */
539 if (qdf_nbuf_put_tail(htt_msg, HTT_SRING_SETUP_SZ) == NULL) {
540 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
541 "%s: Failed to expand head for SRING_SETUP msg\n",
542 __func__);
543 return QDF_STATUS_E_FAILURE;
544 }
545
546 msg_word = (uint32_t *)qdf_nbuf_data(htt_msg);
547
548 /* rewind beyond alignment pad to get to the HTC header reserved area */
549 qdf_nbuf_push_head(htt_msg, HTC_HDR_ALIGNMENT_PADDING);
550
551 /* word 0 */
552 *msg_word = 0;
553 HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_SRING_SETUP);
Dhanashri Atre2ea8c0f2017-02-08 11:09:56 -0800554
Kai Chencbe4c342017-06-12 20:06:35 -0700555 if ((htt_ring_type == HTT_SW_TO_HW_RING) ||
Ravi Joshi8851f4e2017-06-07 21:22:08 -0700556 (htt_ring_type == HTT_HW_TO_SW_RING))
Dhanashri Atre2ea8c0f2017-02-08 11:09:56 -0800557 HTT_SRING_SETUP_PDEV_ID_SET(*msg_word,
558 DP_SW2HW_MACID(mac_id));
559 else
560 HTT_SRING_SETUP_PDEV_ID_SET(*msg_word, mac_id);
561
Dhanashri Atred4032ab2017-01-17 15:05:41 -0800562 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
563 "%s: mac_id %d\n", __func__, mac_id);
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -0700564 HTT_SRING_SETUP_RING_TYPE_SET(*msg_word, htt_ring_type);
565 /* TODO: Discuss with FW on changing this to unique ID and using
566 * htt_ring_type to send the type of ring
567 */
568 HTT_SRING_SETUP_RING_ID_SET(*msg_word, htt_ring_id);
569
570 /* word 1 */
571 msg_word++;
572 *msg_word = 0;
573 HTT_SRING_SETUP_RING_BASE_ADDR_LO_SET(*msg_word,
574 srng_params.ring_base_paddr & 0xffffffff);
575
576 /* word 2 */
577 msg_word++;
578 *msg_word = 0;
579 HTT_SRING_SETUP_RING_BASE_ADDR_HI_SET(*msg_word,
580 (uint64_t)srng_params.ring_base_paddr >> 32);
581
582 /* word 3 */
583 msg_word++;
584 *msg_word = 0;
585 HTT_SRING_SETUP_ENTRY_SIZE_SET(*msg_word, ring_entry_size);
586 HTT_SRING_SETUP_RING_SIZE_SET(*msg_word,
587 (ring_entry_size * srng_params.num_entries));
Dhanashri Atred4032ab2017-01-17 15:05:41 -0800588 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
589 "%s: entry_size %d\n", __func__,
590 ring_entry_size);
591 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
592 "%s: num_entries %d\n", __func__,
593 srng_params.num_entries);
594 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
595 "%s: ring_size %d\n", __func__,
596 (ring_entry_size * srng_params.num_entries));
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -0700597 if (htt_ring_type == HTT_SW_TO_HW_RING)
Leo Chang5ea93a42016-11-03 12:39:49 -0700598 HTT_SRING_SETUP_RING_MISC_CFG_FLAG_LOOPCOUNT_DISABLE_SET(
599 *msg_word, 1);
600 HTT_SRING_SETUP_RING_MISC_CFG_FLAG_MSI_SWAP_SET(*msg_word,
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -0700601 !!(srng_params.flags & HAL_SRNG_MSI_SWAP));
Leo Chang5ea93a42016-11-03 12:39:49 -0700602 HTT_SRING_SETUP_RING_MISC_CFG_FLAG_TLV_SWAP_SET(*msg_word,
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -0700603 !!(srng_params.flags & HAL_SRNG_DATA_TLV_SWAP));
Leo Chang5ea93a42016-11-03 12:39:49 -0700604 HTT_SRING_SETUP_RING_MISC_CFG_FLAG_HOST_FW_SWAP_SET(*msg_word,
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -0700605 !!(srng_params.flags & HAL_SRNG_RING_PTR_SWAP));
606
607 /* word 4 */
608 msg_word++;
609 *msg_word = 0;
610 HTT_SRING_SETUP_HEAD_OFFSET32_REMOTE_BASE_ADDR_LO_SET(*msg_word,
611 hp_addr & 0xffffffff);
612
613 /* word 5 */
614 msg_word++;
615 *msg_word = 0;
616 HTT_SRING_SETUP_HEAD_OFFSET32_REMOTE_BASE_ADDR_HI_SET(*msg_word,
617 (uint64_t)hp_addr >> 32);
618
619 /* word 6 */
620 msg_word++;
621 *msg_word = 0;
622 HTT_SRING_SETUP_TAIL_OFFSET32_REMOTE_BASE_ADDR_LO_SET(*msg_word,
623 tp_addr & 0xffffffff);
624
625 /* word 7 */
626 msg_word++;
627 *msg_word = 0;
628 HTT_SRING_SETUP_TAIL_OFFSET32_REMOTE_BASE_ADDR_HI_SET(*msg_word,
629 (uint64_t)tp_addr >> 32);
630
631 /* word 8 */
632 msg_word++;
633 *msg_word = 0;
634 HTT_SRING_SETUP_RING_MSI_ADDR_LO_SET(*msg_word,
635 srng_params.msi_addr & 0xffffffff);
636
637 /* word 9 */
638 msg_word++;
639 *msg_word = 0;
640 HTT_SRING_SETUP_RING_MSI_ADDR_HI_SET(*msg_word,
641 (uint64_t)(srng_params.msi_addr) >> 32);
642
643 /* word 10 */
644 msg_word++;
645 *msg_word = 0;
646 HTT_SRING_SETUP_RING_MSI_DATA_SET(*msg_word,
647 srng_params.msi_data);
648
649 /* word 11 */
650 msg_word++;
651 *msg_word = 0;
652 HTT_SRING_SETUP_INTR_BATCH_COUNTER_TH_SET(*msg_word,
653 srng_params.intr_batch_cntr_thres_entries *
654 ring_entry_size);
655 HTT_SRING_SETUP_INTR_TIMER_TH_SET(*msg_word,
656 srng_params.intr_timer_thres_us >> 3);
657
658 /* word 12 */
659 msg_word++;
660 *msg_word = 0;
661 if (srng_params.flags & HAL_SRNG_LOW_THRES_INTR_ENABLE) {
662 /* TODO: Setting low threshold to 1/8th of ring size - see
663 * if this needs to be configurable
664 */
665 HTT_SRING_SETUP_INTR_LOW_TH_SET(*msg_word,
666 srng_params.low_threshold);
667 }
668 /* "response_required" field should be set if a HTT response message is
669 * required after setting up the ring.
670 */
671 pkt = htt_htc_pkt_alloc(soc);
672 if (!pkt)
673 goto fail1;
674
675 pkt->soc_ctxt = NULL; /* not used during send-done callback */
676
677 SET_HTC_PACKET_INFO_TX(
678 &pkt->htc_pkt,
679 dp_htt_h2t_send_complete_free_netbuf,
680 qdf_nbuf_data(htt_msg),
681 qdf_nbuf_len(htt_msg),
682 soc->htc_endpoint,
Yue Ma245b47b2017-02-21 16:35:31 -0800683 HTC_TX_PACKET_TAG_RUNTIME_PUT); /* tag for no FW response msg */
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -0700684
685 SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
Pramod Simhae0baa442017-06-27 15:21:39 -0700686 DP_HTT_SEND_HTC_PKT(soc, pkt);
Kai Chen6eca1a62017-01-12 10:17:53 -0800687
688 return QDF_STATUS_SUCCESS;
689
690fail1:
691 qdf_nbuf_free(htt_msg);
692fail0:
693 return QDF_STATUS_E_FAILURE;
694}
695
696/*
697 * htt_h2t_rx_ring_cfg() - Send SRNG packet and TLV filter
698 * config message to target
699 * @htt_soc: HTT SOC handle
700 * @pdev_id: PDEV Id
701 * @hal_srng: Opaque HAL SRNG pointer
702 * @hal_ring_type: SRNG ring type
703 * @ring_buf_size: SRNG buffer size
704 * @htt_tlv_filter: Rx SRNG TLV and filter setting
705 * Return: 0 on success; error code on failure
706 */
707int htt_h2t_rx_ring_cfg(void *htt_soc, int pdev_id, void *hal_srng,
708 int hal_ring_type, int ring_buf_size,
709 struct htt_rx_ring_tlv_filter *htt_tlv_filter)
710{
711 struct htt_soc *soc = (struct htt_soc *)htt_soc;
712 struct dp_htt_htc_pkt *pkt;
713 qdf_nbuf_t htt_msg;
714 uint32_t *msg_word;
715 struct hal_srng_params srng_params;
716 uint32_t htt_ring_type, htt_ring_id;
717 uint32_t tlv_filter;
718
719 htt_msg = qdf_nbuf_alloc(soc->osdev,
720 HTT_MSG_BUF_SIZE(HTT_RX_RING_SELECTION_CFG_SZ),
721 /* reserve room for the HTC header */
722 HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
723 if (!htt_msg)
724 goto fail0;
725
726 hal_get_srng_params(soc->hal_soc, hal_srng, &srng_params);
727
728 switch (hal_ring_type) {
729 case RXDMA_BUF:
730#if QCA_HOST2FW_RXBUF_RING
731 htt_ring_id = HTT_HOST1_TO_FW_RXBUF_RING;
732 htt_ring_type = HTT_SW_TO_SW_RING;
733#else
734 htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
735 htt_ring_type = HTT_SW_TO_HW_RING;
736#endif
737 break;
738 case RXDMA_MONITOR_BUF:
739 htt_ring_id = HTT_RXDMA_MONITOR_BUF_RING;
740 htt_ring_type = HTT_SW_TO_HW_RING;
741 break;
742 case RXDMA_MONITOR_STATUS:
743 htt_ring_id = HTT_RXDMA_MONITOR_STATUS_RING;
744 htt_ring_type = HTT_SW_TO_HW_RING;
745 break;
746 case RXDMA_MONITOR_DST:
747 htt_ring_id = HTT_RXDMA_MONITOR_DEST_RING;
748 htt_ring_type = HTT_HW_TO_SW_RING;
749 break;
750 case RXDMA_MONITOR_DESC:
751 htt_ring_id = HTT_RXDMA_MONITOR_DESC_RING;
752 htt_ring_type = HTT_SW_TO_HW_RING;
753 break;
Pramod Simhae382ff82017-06-05 18:09:26 -0700754 case RXDMA_DST:
755 htt_ring_id = HTT_RXDMA_NON_MONITOR_DEST_RING;
756 htt_ring_type = HTT_HW_TO_SW_RING;
757 break;
Kai Chen6eca1a62017-01-12 10:17:53 -0800758
759 default:
760 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
761 "%s: Ring currently not supported\n", __func__);
762 goto fail1;
763 }
764
765 /*
766 * Set the length of the message.
767 * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
768 * separately during the below call to qdf_nbuf_push_head.
769 * The contribution from the HTC header is added separately inside HTC.
770 */
771 if (qdf_nbuf_put_tail(htt_msg, HTT_RX_RING_SELECTION_CFG_SZ) == NULL) {
772 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
773 "%s: Failed to expand head for RX Ring Cfg msg\n",
774 __func__);
775 goto fail1; /* failure */
776 }
777
778 msg_word = (uint32_t *)qdf_nbuf_data(htt_msg);
779
780 /* rewind beyond alignment pad to get to the HTC header reserved area */
781 qdf_nbuf_push_head(htt_msg, HTC_HDR_ALIGNMENT_PADDING);
782
783 /* word 0 */
784 *msg_word = 0;
785 HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_RING_SELECTION_CFG);
Ravi Joshi8851f4e2017-06-07 21:22:08 -0700786
787 /*
788 * pdev_id is indexed from 0 whereas mac_id is indexed from 1
789 * SW_TO_SW and SW_TO_HW rings are unaffected by this
790 */
791 if (htt_ring_type == HTT_SW_TO_SW_RING ||
792 htt_ring_type == HTT_SW_TO_HW_RING)
793 HTT_RX_RING_SELECTION_CFG_PDEV_ID_SET(*msg_word,
794 DP_SW2HW_MACID(pdev_id));
795
Kai Chen6eca1a62017-01-12 10:17:53 -0800796 /* TODO: Discuss with FW on changing this to unique ID and using
797 * htt_ring_type to send the type of ring
798 */
799 HTT_RX_RING_SELECTION_CFG_RING_ID_SET(*msg_word, htt_ring_id);
800
801 HTT_RX_RING_SELECTION_CFG_STATUS_TLV_SET(*msg_word,
802 !!(srng_params.flags & HAL_SRNG_MSI_SWAP));
803
804 HTT_RX_RING_SELECTION_CFG_PKT_TLV_SET(*msg_word,
805 !!(srng_params.flags & HAL_SRNG_DATA_TLV_SWAP));
806
807 /* word 1 */
808 msg_word++;
809 *msg_word = 0;
810 HTT_RX_RING_SELECTION_CFG_RING_BUFFER_SIZE_SET(*msg_word,
811 ring_buf_size);
812
813 /* word 2 */
814 msg_word++;
815 *msg_word = 0;
816
817 if (htt_tlv_filter->enable_fp) {
nobeljd124b742017-10-16 11:59:12 -0700818 /* TYPE: MGMT */
819 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
820 FP, MGMT, 0000,
821 (htt_tlv_filter->fp_mgmt_filter &
822 FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
823 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
824 FP, MGMT, 0001,
825 (htt_tlv_filter->fp_mgmt_filter &
826 FILTER_MGMT_ASSOC_RES) ? 1 : 0);
827 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
828 FP, MGMT, 0010,
829 (htt_tlv_filter->fp_mgmt_filter &
830 FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
831 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
832 FP, MGMT, 0011,
833 (htt_tlv_filter->fp_mgmt_filter &
834 FILTER_MGMT_REASSOC_RES) ? 1 : 0);
835 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
836 FP, MGMT, 0100,
837 (htt_tlv_filter->fp_mgmt_filter &
838 FILTER_MGMT_PROBE_REQ) ? 1 : 0);
839 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
840 FP, MGMT, 0101,
841 (htt_tlv_filter->fp_mgmt_filter &
842 FILTER_MGMT_PROBE_RES) ? 1 : 0);
843 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
844 FP, MGMT, 0110,
845 (htt_tlv_filter->fp_mgmt_filter &
846 FILTER_MGMT_TIM_ADVT) ? 1 : 0);
847 /* reserved */
Kai Chen6eca1a62017-01-12 10:17:53 -0800848 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, FP,
nobeljd124b742017-10-16 11:59:12 -0700849 MGMT, 0111,
850 (htt_tlv_filter->fp_mgmt_filter &
851 FILTER_MGMT_RESERVED_7) ? 1 : 0);
852 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
853 FP, MGMT, 1000,
854 (htt_tlv_filter->fp_mgmt_filter &
855 FILTER_MGMT_BEACON) ? 1 : 0);
856 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
857 FP, MGMT, 1001,
858 (htt_tlv_filter->fp_mgmt_filter &
859 FILTER_MGMT_ATIM) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -0800860 }
861
862 if (htt_tlv_filter->enable_md) {
863 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -0700864 MGMT, 0000, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -0800865 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -0700866 MGMT, 0001, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -0800867 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -0700868 MGMT, 0010, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -0800869 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -0700870 MGMT, 0011, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -0800871 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -0700872 MGMT, 0100, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -0800873 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -0700874 MGMT, 0101, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -0800875 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -0700876 MGMT, 0110, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -0800877 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -0700878 MGMT, 0111, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -0800879 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -0700880 MGMT, 1000, 1);
881 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
882 MGMT, 1001, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -0800883 }
884
885 if (htt_tlv_filter->enable_mo) {
nobeljd124b742017-10-16 11:59:12 -0700886 /* TYPE: MGMT */
887 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
888 MO, MGMT, 0000,
889 (htt_tlv_filter->mo_mgmt_filter &
890 FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
891 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
892 MO, MGMT, 0001,
893 (htt_tlv_filter->mo_mgmt_filter &
894 FILTER_MGMT_ASSOC_RES) ? 1 : 0);
895 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
896 MO, MGMT, 0010,
897 (htt_tlv_filter->mo_mgmt_filter &
898 FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
899 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
900 MO, MGMT, 0011,
901 (htt_tlv_filter->mo_mgmt_filter &
902 FILTER_MGMT_REASSOC_RES) ? 1 : 0);
903 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
904 MO, MGMT, 0100,
905 (htt_tlv_filter->mo_mgmt_filter &
906 FILTER_MGMT_PROBE_REQ) ? 1 : 0);
907 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
908 MO, MGMT, 0101,
909 (htt_tlv_filter->mo_mgmt_filter &
910 FILTER_MGMT_PROBE_RES) ? 1 : 0);
911 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
912 MO, MGMT, 0110,
913 (htt_tlv_filter->mo_mgmt_filter &
914 FILTER_MGMT_TIM_ADVT) ? 1 : 0);
915 /* reserved */
Kai Chen6eca1a62017-01-12 10:17:53 -0800916 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MO,
nobeljd124b742017-10-16 11:59:12 -0700917 MGMT, 0111,
918 (htt_tlv_filter->mo_mgmt_filter &
919 FILTER_MGMT_RESERVED_7) ? 1 : 0);
920 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
921 MO, MGMT, 1000,
922 (htt_tlv_filter->mo_mgmt_filter &
923 FILTER_MGMT_BEACON) ? 1 : 0);
924 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
925 MO, MGMT, 1001,
926 (htt_tlv_filter->mo_mgmt_filter &
927 FILTER_MGMT_ATIM) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -0800928 }
Ravi Joshi2320b6f2017-05-24 15:43:04 -0700929
Kai Chen6eca1a62017-01-12 10:17:53 -0800930 /* word 3 */
931 msg_word++;
932 *msg_word = 0;
933
934 if (htt_tlv_filter->enable_fp) {
nobeljd124b742017-10-16 11:59:12 -0700935 /* TYPE: MGMT */
936 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
937 FP, MGMT, 1010,
938 (htt_tlv_filter->fp_mgmt_filter &
939 FILTER_MGMT_DISASSOC) ? 1 : 0);
940 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
941 FP, MGMT, 1011,
942 (htt_tlv_filter->fp_mgmt_filter &
943 FILTER_MGMT_AUTH) ? 1 : 0);
944 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
945 FP, MGMT, 1100,
946 (htt_tlv_filter->fp_mgmt_filter &
947 FILTER_MGMT_DEAUTH) ? 1 : 0);
948 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
949 FP, MGMT, 1101,
950 (htt_tlv_filter->fp_mgmt_filter &
951 FILTER_MGMT_ACTION) ? 1 : 0);
952 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
953 FP, MGMT, 1110,
954 (htt_tlv_filter->fp_mgmt_filter &
955 FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
956 /* reserved*/
Kai Chen6eca1a62017-01-12 10:17:53 -0800957 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, FP,
nobeljd124b742017-10-16 11:59:12 -0700958 MGMT, 1111,
959 (htt_tlv_filter->fp_mgmt_filter &
960 FILTER_MGMT_RESERVED_15) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -0800961 }
962
963 if (htt_tlv_filter->enable_md) {
964 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -0700965 MGMT, 1010, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -0800966 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -0700967 MGMT, 1011, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -0800968 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -0700969 MGMT, 1100, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -0800970 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -0700971 MGMT, 1101, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -0800972 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -0700973 MGMT, 1110, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -0800974 }
975
976 if (htt_tlv_filter->enable_mo) {
nobeljd124b742017-10-16 11:59:12 -0700977 /* TYPE: MGMT */
978 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
979 MO, MGMT, 1010,
980 (htt_tlv_filter->mo_mgmt_filter &
981 FILTER_MGMT_DISASSOC) ? 1 : 0);
982 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
983 MO, MGMT, 1011,
984 (htt_tlv_filter->mo_mgmt_filter &
985 FILTER_MGMT_AUTH) ? 1 : 0);
986 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
987 MO, MGMT, 1100,
988 (htt_tlv_filter->mo_mgmt_filter &
989 FILTER_MGMT_DEAUTH) ? 1 : 0);
990 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
991 MO, MGMT, 1101,
992 (htt_tlv_filter->mo_mgmt_filter &
993 FILTER_MGMT_ACTION) ? 1 : 0);
994 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
995 MO, MGMT, 1110,
996 (htt_tlv_filter->mo_mgmt_filter &
997 FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
998 /* reserved*/
Kai Chen6eca1a62017-01-12 10:17:53 -0800999 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, MO,
nobeljd124b742017-10-16 11:59:12 -07001000 MGMT, 1111,
1001 (htt_tlv_filter->mo_mgmt_filter &
1002 FILTER_MGMT_RESERVED_15) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001003 }
1004
1005 /* word 4 */
1006 msg_word++;
1007 *msg_word = 0;
1008
1009 if (htt_tlv_filter->enable_fp) {
nobeljd124b742017-10-16 11:59:12 -07001010 /* TYPE: CTRL */
1011 /* reserved */
Keyur Parekhdb0fa142017-07-13 19:40:22 -07001012 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
nobeljd124b742017-10-16 11:59:12 -07001013 CTRL, 0000,
1014 (htt_tlv_filter->fp_ctrl_filter &
1015 FILTER_CTRL_RESERVED_1) ? 1 : 0);
1016 /* reserved */
Keyur Parekhdb0fa142017-07-13 19:40:22 -07001017 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
nobeljd124b742017-10-16 11:59:12 -07001018 CTRL, 0001,
1019 (htt_tlv_filter->fp_ctrl_filter &
1020 FILTER_CTRL_RESERVED_2) ? 1 : 0);
Keyur Parekhdb0fa142017-07-13 19:40:22 -07001021 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
nobeljd124b742017-10-16 11:59:12 -07001022 CTRL, 0010,
1023 (htt_tlv_filter->fp_ctrl_filter &
1024 FILTER_CTRL_TRIGGER) ? 1 : 0);
1025 /* reserved */
Keyur Parekhdb0fa142017-07-13 19:40:22 -07001026 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
nobeljd124b742017-10-16 11:59:12 -07001027 CTRL, 0011,
1028 (htt_tlv_filter->fp_ctrl_filter &
1029 FILTER_CTRL_RESERVED_4) ? 1 : 0);
Keyur Parekhdb0fa142017-07-13 19:40:22 -07001030 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
nobeljd124b742017-10-16 11:59:12 -07001031 CTRL, 0100,
1032 (htt_tlv_filter->fp_ctrl_filter &
1033 FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
Keyur Parekhdb0fa142017-07-13 19:40:22 -07001034 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
nobeljd124b742017-10-16 11:59:12 -07001035 CTRL, 0101,
1036 (htt_tlv_filter->fp_ctrl_filter &
1037 FILTER_CTRL_VHT_NDP) ? 1 : 0);
Keyur Parekhdb0fa142017-07-13 19:40:22 -07001038 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
nobeljd124b742017-10-16 11:59:12 -07001039 CTRL, 0110,
1040 (htt_tlv_filter->fp_ctrl_filter &
1041 FILTER_CTRL_FRAME_EXT) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001042 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
nobeljd124b742017-10-16 11:59:12 -07001043 CTRL, 0111,
1044 (htt_tlv_filter->fp_ctrl_filter &
1045 FILTER_CTRL_CTRLWRAP) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001046 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
nobeljd124b742017-10-16 11:59:12 -07001047 CTRL, 1000,
1048 (htt_tlv_filter->fp_ctrl_filter &
1049 FILTER_CTRL_BA_REQ) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001050 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
nobeljd124b742017-10-16 11:59:12 -07001051 CTRL, 1001,
1052 (htt_tlv_filter->fp_ctrl_filter &
1053 FILTER_CTRL_BA) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001054 }
1055
1056 if (htt_tlv_filter->enable_md) {
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001057 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
1058 CTRL, 0000, 1);
1059 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
1060 CTRL, 0001, 1);
1061 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
1062 CTRL, 0010, 1);
1063 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
1064 CTRL, 0011, 1);
1065 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
1066 CTRL, 0100, 1);
1067 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
1068 CTRL, 0101, 1);
1069 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
1070 CTRL, 0110, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -08001071 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001072 CTRL, 0111, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -08001073 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001074 CTRL, 1000, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -08001075 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001076 CTRL, 1001, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -08001077 }
1078
1079 if (htt_tlv_filter->enable_mo) {
nobeljd124b742017-10-16 11:59:12 -07001080 /* TYPE: CTRL */
1081 /* reserved */
Kai Chen6eca1a62017-01-12 10:17:53 -08001082 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
nobeljd124b742017-10-16 11:59:12 -07001083 CTRL, 0000,
1084 (htt_tlv_filter->mo_ctrl_filter &
1085 FILTER_CTRL_RESERVED_1) ? 1 : 0);
1086 /* reserved */
Kai Chen6eca1a62017-01-12 10:17:53 -08001087 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
nobeljd124b742017-10-16 11:59:12 -07001088 CTRL, 0001,
1089 (htt_tlv_filter->mo_ctrl_filter &
1090 FILTER_CTRL_RESERVED_2) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001091 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
nobeljd124b742017-10-16 11:59:12 -07001092 CTRL, 0010,
1093 (htt_tlv_filter->mo_ctrl_filter &
1094 FILTER_CTRL_TRIGGER) ? 1 : 0);
1095 /* reserved */
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001096 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
nobeljd124b742017-10-16 11:59:12 -07001097 CTRL, 0011,
1098 (htt_tlv_filter->mo_ctrl_filter &
1099 FILTER_CTRL_RESERVED_4) ? 1 : 0);
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001100 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
nobeljd124b742017-10-16 11:59:12 -07001101 CTRL, 0100,
1102 (htt_tlv_filter->mo_ctrl_filter &
1103 FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001104 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
nobeljd124b742017-10-16 11:59:12 -07001105 CTRL, 0101,
1106 (htt_tlv_filter->mo_ctrl_filter &
1107 FILTER_CTRL_VHT_NDP) ? 1 : 0);
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001108 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
nobeljd124b742017-10-16 11:59:12 -07001109 CTRL, 0110,
1110 (htt_tlv_filter->mo_ctrl_filter &
1111 FILTER_CTRL_FRAME_EXT) ? 1 : 0);
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001112 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
nobeljd124b742017-10-16 11:59:12 -07001113 CTRL, 0111,
1114 (htt_tlv_filter->mo_ctrl_filter &
1115 FILTER_CTRL_CTRLWRAP) ? 1 : 0);
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001116 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
nobeljd124b742017-10-16 11:59:12 -07001117 CTRL, 1000,
1118 (htt_tlv_filter->mo_ctrl_filter &
1119 FILTER_CTRL_BA_REQ) ? 1 : 0);
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001120 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
nobeljd124b742017-10-16 11:59:12 -07001121 CTRL, 1001,
1122 (htt_tlv_filter->mo_ctrl_filter &
1123 FILTER_CTRL_BA) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001124 }
1125
1126 /* word 5 */
1127 msg_word++;
1128 *msg_word = 0;
1129 if (htt_tlv_filter->enable_fp) {
nobeljd124b742017-10-16 11:59:12 -07001130 /* TYPE: CTRL */
Kai Chen6eca1a62017-01-12 10:17:53 -08001131 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
nobeljd124b742017-10-16 11:59:12 -07001132 CTRL, 1010,
1133 (htt_tlv_filter->fp_ctrl_filter &
1134 FILTER_CTRL_PSPOLL) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001135 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
nobeljd124b742017-10-16 11:59:12 -07001136 CTRL, 1011,
1137 (htt_tlv_filter->fp_ctrl_filter &
1138 FILTER_CTRL_RTS) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001139 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
nobeljd124b742017-10-16 11:59:12 -07001140 CTRL, 1100,
1141 (htt_tlv_filter->fp_ctrl_filter &
1142 FILTER_CTRL_CTS) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001143 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
nobeljd124b742017-10-16 11:59:12 -07001144 CTRL, 1101,
1145 (htt_tlv_filter->fp_ctrl_filter &
1146 FILTER_CTRL_ACK) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001147 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
nobeljd124b742017-10-16 11:59:12 -07001148 CTRL, 1110,
1149 (htt_tlv_filter->fp_ctrl_filter &
1150 FILTER_CTRL_CFEND) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001151 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
nobeljd124b742017-10-16 11:59:12 -07001152 CTRL, 1111,
1153 (htt_tlv_filter->fp_ctrl_filter &
1154 FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
1155 /* TYPE: DATA */
Kai Chen6eca1a62017-01-12 10:17:53 -08001156 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
nobeljd124b742017-10-16 11:59:12 -07001157 DATA, MCAST,
1158 (htt_tlv_filter->fp_data_filter &
1159 FILTER_DATA_MCAST) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001160 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
nobeljd124b742017-10-16 11:59:12 -07001161 DATA, UCAST,
1162 (htt_tlv_filter->fp_data_filter &
1163 FILTER_DATA_UCAST) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001164 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
nobeljd124b742017-10-16 11:59:12 -07001165 DATA, NULL,
1166 (htt_tlv_filter->fp_data_filter &
1167 FILTER_DATA_NULL) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001168 }
1169
1170 if (htt_tlv_filter->enable_md) {
1171 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001172 CTRL, 1010, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -08001173 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001174 CTRL, 1011, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -08001175 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001176 CTRL, 1100, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -08001177 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001178 CTRL, 1101, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -08001179 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001180 CTRL, 1110, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -08001181 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001182 CTRL, 1111, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -08001183 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001184 DATA, MCAST, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -08001185 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001186 DATA, UCAST, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -08001187 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001188 DATA, NULL, 1);
Kai Chen6eca1a62017-01-12 10:17:53 -08001189 }
Ravi Joshi2320b6f2017-05-24 15:43:04 -07001190
Kai Chen6eca1a62017-01-12 10:17:53 -08001191 if (htt_tlv_filter->enable_mo) {
nobeljd124b742017-10-16 11:59:12 -07001192 /* TYPE: CTRL */
Kai Chen6eca1a62017-01-12 10:17:53 -08001193 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
nobeljd124b742017-10-16 11:59:12 -07001194 CTRL, 1010,
1195 (htt_tlv_filter->mo_ctrl_filter &
1196 FILTER_CTRL_PSPOLL) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001197 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
nobeljd124b742017-10-16 11:59:12 -07001198 CTRL, 1011,
1199 (htt_tlv_filter->mo_ctrl_filter &
1200 FILTER_CTRL_RTS) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001201 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
nobeljd124b742017-10-16 11:59:12 -07001202 CTRL, 1100,
1203 (htt_tlv_filter->mo_ctrl_filter &
1204 FILTER_CTRL_CTS) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001205 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
nobeljd124b742017-10-16 11:59:12 -07001206 CTRL, 1101,
1207 (htt_tlv_filter->mo_ctrl_filter &
1208 FILTER_CTRL_ACK) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001209 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
nobeljd124b742017-10-16 11:59:12 -07001210 CTRL, 1110,
1211 (htt_tlv_filter->mo_ctrl_filter &
1212 FILTER_CTRL_CFEND) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001213 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
nobeljd124b742017-10-16 11:59:12 -07001214 CTRL, 1111,
1215 (htt_tlv_filter->mo_ctrl_filter &
1216 FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
1217 /* TYPE: DATA */
Kai Chen6eca1a62017-01-12 10:17:53 -08001218 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
nobeljd124b742017-10-16 11:59:12 -07001219 DATA, MCAST,
1220 (htt_tlv_filter->mo_data_filter &
1221 FILTER_DATA_MCAST) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001222 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
nobeljd124b742017-10-16 11:59:12 -07001223 DATA, UCAST,
1224 (htt_tlv_filter->mo_data_filter &
1225 FILTER_DATA_UCAST) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001226 htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
nobeljd124b742017-10-16 11:59:12 -07001227 DATA, NULL,
1228 (htt_tlv_filter->mo_data_filter &
1229 FILTER_DATA_NULL) ? 1 : 0);
Kai Chen6eca1a62017-01-12 10:17:53 -08001230 }
1231
1232 /* word 6 */
1233 msg_word++;
1234 *msg_word = 0;
1235 tlv_filter = 0;
1236 htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MPDU_START,
1237 htt_tlv_filter->mpdu_start);
1238 htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MSDU_START,
1239 htt_tlv_filter->msdu_start);
1240 htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PACKET,
1241 htt_tlv_filter->packet);
1242 htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MSDU_END,
1243 htt_tlv_filter->msdu_end);
1244 htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MPDU_END,
1245 htt_tlv_filter->mpdu_end);
1246 htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PACKET_HEADER,
1247 htt_tlv_filter->packet_header);
1248 htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, ATTENTION,
Karunakar Dasineni40555682017-03-26 22:44:39 -07001249 htt_tlv_filter->attention);
Kai Chen6eca1a62017-01-12 10:17:53 -08001250 htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_START,
1251 htt_tlv_filter->ppdu_start);
1252 htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END,
1253 htt_tlv_filter->ppdu_end);
1254 htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END_USER_STATS,
1255 htt_tlv_filter->ppdu_end_user_stats);
1256 htt_rx_ring_tlv_filter_in_enable_set(tlv_filter,
1257 PPDU_END_USER_STATS_EXT,
1258 htt_tlv_filter->ppdu_end_user_stats_ext);
1259 htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END_STATUS_DONE,
1260 htt_tlv_filter->ppdu_end_status_done);
sumedh baikady308ff002017-09-18 16:24:36 -07001261 /* RESERVED bit maps to header_per_msdu in htt_tlv_filter*/
1262 htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, RESERVED,
1263 htt_tlv_filter->header_per_msdu);
Kai Chen6eca1a62017-01-12 10:17:53 -08001264
1265 HTT_RX_RING_SELECTION_CFG_TLV_FILTER_IN_FLAG_SET(*msg_word, tlv_filter);
1266
1267 /* "response_required" field should be set if a HTT response message is
1268 * required after setting up the ring.
1269 */
1270 pkt = htt_htc_pkt_alloc(soc);
1271 if (!pkt)
1272 goto fail1;
1273
1274 pkt->soc_ctxt = NULL; /* not used during send-done callback */
1275
1276 SET_HTC_PACKET_INFO_TX(
1277 &pkt->htc_pkt,
1278 dp_htt_h2t_send_complete_free_netbuf,
1279 qdf_nbuf_data(htt_msg),
1280 qdf_nbuf_len(htt_msg),
1281 soc->htc_endpoint,
1282 1); /* tag - not relevant here */
1283
1284 SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
Pramod Simhae0baa442017-06-27 15:21:39 -07001285 DP_HTT_SEND_HTC_PKT(soc, pkt);
Kai Chen6eca1a62017-01-12 10:17:53 -08001286 return QDF_STATUS_SUCCESS;
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07001287
1288fail1:
1289 qdf_nbuf_free(htt_msg);
1290fail0:
1291 return QDF_STATUS_E_FAILURE;
1292}
1293
Chaithanya Garrepalli30927c52017-11-22 14:31:47 +05301294#if defined(CONFIG_WIN) && WDI_EVENT_ENABLE
1295static inline QDF_STATUS dp_send_htt_stat_resp(struct htt_stats_context *htt_stats,
1296 struct dp_soc *soc, qdf_nbuf_t htt_msg)
1297
1298{
1299 uint32_t pdev_id;
1300 uint32_t *msg_word = NULL;
1301 uint32_t msg_remain_len = 0;
1302
1303 msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
1304
1305 /*COOKIE MSB*/
1306 pdev_id = *(msg_word + 2);
1307
1308 /* stats message length + 16 size of HTT header*/
1309 msg_remain_len = qdf_min(htt_stats->msg_len + 16,
1310 (uint32_t)DP_EXT_MSG_LENGTH);
1311
1312 dp_wdi_event_handler(WDI_EVENT_HTT_STATS, soc,
1313 msg_word, msg_remain_len,
1314 WDI_NO_VAL, pdev_id);
1315
1316 if (htt_stats->msg_len >= DP_EXT_MSG_LENGTH) {
1317 htt_stats->msg_len -= DP_EXT_MSG_LENGTH;
1318 }
1319 /* Need to be freed here as WDI handler will
1320 * make a copy of pkt to send data to application
1321 */
1322 qdf_nbuf_free(htt_msg);
1323 return QDF_STATUS_SUCCESS;
1324}
1325#else
1326static inline QDF_STATUS dp_send_htt_stat_resp(struct htt_stats_context *htt_stats,
1327 struct dp_soc *soc, qdf_nbuf_t htt_msg)
1328{
1329 return QDF_STATUS_E_NOSUPPORT;
1330}
1331#endif
1332
Ishank Jain6290a3c2017-03-21 10:49:39 +05301333/**
1334 * dp_process_htt_stat_msg(): Process the list of buffers of HTT EXT stats
Om Prakash Tripathi12126822017-08-03 10:21:24 +05301335 * @htt_stats: htt stats info
Ishank Jain6290a3c2017-03-21 10:49:39 +05301336 *
1337 * The FW sends the HTT EXT STATS as a stream of T2H messages. Each T2H message
1338 * contains sub messages which are identified by a TLV header.
1339 * In this function we will process the stream of T2H messages and read all the
1340 * TLV contained in the message.
1341 *
1342 * THe following cases have been taken care of
1343 * Case 1: When the tlv_remain_length <= msg_remain_length of HTT MSG buffer
1344 * In this case the buffer will contain multiple tlvs.
1345 * Case 2: When the tlv_remain_length > msg_remain_length of HTT MSG buffer.
1346 * Only one tlv will be contained in the HTT message and this tag
1347 * will extend onto the next buffer.
1348 * Case 3: When the buffer is the continuation of the previous message
1349 * Case 4: tlv length is 0. which will indicate the end of message
1350 *
1351 * return: void
1352 */
Chaithanya Garrepalli30927c52017-11-22 14:31:47 +05301353static inline void dp_process_htt_stat_msg(struct htt_stats_context *htt_stats,
1354 struct dp_soc *soc)
Ishank Jain6290a3c2017-03-21 10:49:39 +05301355{
1356 htt_tlv_tag_t tlv_type = 0xff;
1357 qdf_nbuf_t htt_msg = NULL;
1358 uint32_t *msg_word;
1359 uint8_t *tlv_buf_head = NULL;
1360 uint8_t *tlv_buf_tail = NULL;
1361 uint32_t msg_remain_len = 0;
1362 uint32_t tlv_remain_len = 0;
1363 uint32_t *tlv_start;
Chaithanya Garrepalli30927c52017-11-22 14:31:47 +05301364 int cookie_val;
Ishank Jain6290a3c2017-03-21 10:49:39 +05301365
1366 /* Process node in the HTT message queue */
Om Prakash Tripathi12126822017-08-03 10:21:24 +05301367 while ((htt_msg = qdf_nbuf_queue_remove(&htt_stats->msg))
1368 != NULL) {
Ishank Jain6290a3c2017-03-21 10:49:39 +05301369 msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
Chaithanya Garrepalli30927c52017-11-22 14:31:47 +05301370 cookie_val = *(msg_word + 1);
1371 if (cookie_val) {
1372 if (dp_send_htt_stat_resp(htt_stats, soc, htt_msg)
1373 == QDF_STATUS_SUCCESS) {
1374 continue;
1375 }
1376 }
Ishank Jain6290a3c2017-03-21 10:49:39 +05301377 /* read 5th word */
1378 msg_word = msg_word + 4;
Om Prakash Tripathi12126822017-08-03 10:21:24 +05301379 msg_remain_len = qdf_min(htt_stats->msg_len,
1380 (uint32_t) DP_EXT_MSG_LENGTH);
Ishank Jain6290a3c2017-03-21 10:49:39 +05301381
1382 /* Keep processing the node till node length is 0 */
1383 while (msg_remain_len) {
1384 /*
1385 * if message is not a continuation of previous message
1386 * read the tlv type and tlv length
1387 */
1388 if (!tlv_buf_head) {
1389 tlv_type = HTT_STATS_TLV_TAG_GET(
1390 *msg_word);
1391 tlv_remain_len = HTT_STATS_TLV_LENGTH_GET(
1392 *msg_word);
1393 }
1394
1395 if (tlv_remain_len == 0) {
1396 msg_remain_len = 0;
1397
1398 if (tlv_buf_head) {
1399 qdf_mem_free(tlv_buf_head);
1400 tlv_buf_head = NULL;
1401 tlv_buf_tail = NULL;
1402 }
1403
1404 goto error;
1405 }
1406
chenguo26495542017-12-14 21:56:46 +08001407 if (!tlv_buf_head)
1408 tlv_remain_len += HTT_TLV_HDR_LEN;
Ishank Jain6290a3c2017-03-21 10:49:39 +05301409
1410 if ((tlv_remain_len <= msg_remain_len)) {
1411 /* Case 3 */
1412 if (tlv_buf_head) {
1413 qdf_mem_copy(tlv_buf_tail,
1414 (uint8_t *)msg_word,
1415 tlv_remain_len);
1416 tlv_start = (uint32_t *)tlv_buf_head;
1417 } else {
1418 /* Case 1 */
1419 tlv_start = msg_word;
1420 }
1421
1422 dp_htt_stats_print_tag(tlv_type, tlv_start);
1423
1424 msg_remain_len -= tlv_remain_len;
1425
1426 msg_word = (uint32_t *)
1427 (((uint8_t *)msg_word) +
1428 tlv_remain_len);
1429
1430 tlv_remain_len = 0;
1431
1432 if (tlv_buf_head) {
1433 qdf_mem_free(tlv_buf_head);
1434 tlv_buf_head = NULL;
1435 tlv_buf_tail = NULL;
1436 }
1437
1438 } else { /* tlv_remain_len > msg_remain_len */
1439 /* Case 2 & 3 */
1440 if (!tlv_buf_head) {
1441 tlv_buf_head = qdf_mem_malloc(
1442 tlv_remain_len);
1443
1444 if (!tlv_buf_head) {
1445 QDF_TRACE(QDF_MODULE_ID_TXRX,
1446 QDF_TRACE_LEVEL_ERROR,
1447 "Alloc failed");
1448 goto error;
1449 }
1450
1451 tlv_buf_tail = tlv_buf_head;
1452 }
1453
1454 qdf_mem_copy(tlv_buf_tail, (uint8_t *)msg_word,
1455 msg_remain_len);
1456 tlv_remain_len -= msg_remain_len;
1457 tlv_buf_tail += msg_remain_len;
Ishank Jain6290a3c2017-03-21 10:49:39 +05301458 }
1459 }
1460
Om Prakash Tripathi12126822017-08-03 10:21:24 +05301461 if (htt_stats->msg_len >= DP_EXT_MSG_LENGTH) {
1462 htt_stats->msg_len -= DP_EXT_MSG_LENGTH;
Ishank Jain6290a3c2017-03-21 10:49:39 +05301463 }
1464
1465 qdf_nbuf_free(htt_msg);
1466 }
Ishank Jain6290a3c2017-03-21 10:49:39 +05301467 return;
1468
1469error:
1470 qdf_nbuf_free(htt_msg);
Om Prakash Tripathi12126822017-08-03 10:21:24 +05301471 while ((htt_msg = qdf_nbuf_queue_remove(&htt_stats->msg))
Ishank Jain6290a3c2017-03-21 10:49:39 +05301472 != NULL)
1473 qdf_nbuf_free(htt_msg);
1474}
1475
Om Prakash Tripathi2cd7fab2017-07-07 20:27:25 +05301476void htt_t2h_stats_handler(void *context)
1477{
1478 struct dp_soc *soc = (struct dp_soc *)context;
Om Prakash Tripathi12126822017-08-03 10:21:24 +05301479 struct htt_stats_context htt_stats;
1480 uint32_t length;
1481 uint32_t *msg_word;
1482 qdf_nbuf_t htt_msg = NULL;
1483 uint8_t done;
1484 uint8_t rem_stats;
Om Prakash Tripathi2cd7fab2017-07-07 20:27:25 +05301485
Om Prakash Tripathi12126822017-08-03 10:21:24 +05301486 if (!soc || !qdf_atomic_read(&soc->cmn_init_done)) {
1487 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
Jeff Johnson3f217e22017-09-18 10:13:35 -07001488 "soc: 0x%pK, init_done: %d", soc,
Om Prakash Tripathi12126822017-08-03 10:21:24 +05301489 qdf_atomic_read(&soc->cmn_init_done));
1490 return;
1491 }
Om Prakash Tripathi2cd7fab2017-07-07 20:27:25 +05301492
Om Prakash Tripathi12126822017-08-03 10:21:24 +05301493 qdf_mem_zero(&htt_stats, sizeof(htt_stats));
1494 qdf_nbuf_queue_init(&htt_stats.msg);
1495
1496 /* pull one completed stats from soc->htt_stats_msg and process */
1497 qdf_spin_lock_bh(&soc->htt_stats.lock);
1498 if (!soc->htt_stats.num_stats) {
1499 qdf_spin_unlock_bh(&soc->htt_stats.lock);
1500 return;
1501 }
1502 while ((htt_msg = qdf_nbuf_queue_remove(&soc->htt_stats.msg)) != NULL) {
1503 msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
1504 msg_word = msg_word + HTT_T2H_EXT_STATS_TLV_START_OFFSET;
1505 length = HTT_T2H_EXT_STATS_CONF_TLV_LENGTH_GET(*msg_word);
1506 done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
1507 qdf_nbuf_queue_add(&htt_stats.msg, htt_msg);
1508 /*
1509 * HTT EXT stats response comes as stream of TLVs which span over
1510 * multiple T2H messages.
1511 * The first message will carry length of the response.
1512 * For rest of the messages length will be zero.
1513 */
1514 if (length)
1515 htt_stats.msg_len = length;
1516 /*
1517 * Done bit signifies that this is the last T2H buffer in the
1518 * stream of HTT EXT STATS message
1519 */
1520 if (done)
1521 break;
1522 }
1523 rem_stats = --soc->htt_stats.num_stats;
1524 qdf_spin_unlock_bh(&soc->htt_stats.lock);
1525
Chaithanya Garrepalli30927c52017-11-22 14:31:47 +05301526 dp_process_htt_stat_msg(&htt_stats, soc);
Om Prakash Tripathi12126822017-08-03 10:21:24 +05301527 /* If there are more stats to process, schedule stats work again */
1528 if (rem_stats)
1529 qdf_sched_work(0, &soc->htt_stats.work);
Om Prakash Tripathi2cd7fab2017-07-07 20:27:25 +05301530}
1531
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301532/*
1533 * dp_get_ppdu_info_user_index: Find place holder for the received
1534 * ppdu stats info
1535 * pdev: DP pdev handle
1536 *
1537 * return:user index to be populated
1538 */
1539#ifdef FEATURE_PERPKT_INFO
1540static uint8_t dp_get_ppdu_info_user_index(struct dp_pdev *pdev,
Soumya Bhat835033e2017-10-04 22:21:46 +05301541 uint16_t peer_id)
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301542{
1543 uint8_t user_index = 0;
1544 struct cdp_tx_completion_ppdu *ppdu_desc;
1545 struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
1546
1547 ppdu_desc =
1548 (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(pdev->tx_ppdu_info.buf);
1549
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301550 while ((user_index + 1) <= pdev->tx_ppdu_info.last_user) {
1551 ppdu_user_desc = &ppdu_desc->user[user_index];
1552 if (ppdu_user_desc->peer_id != peer_id) {
1553 user_index++;
1554 continue;
1555 } else {
Soumya Bhat835033e2017-10-04 22:21:46 +05301556 /* Max users possible is 8 so user array index should
1557 * not exceed 7
1558 */
1559 qdf_assert_always(user_index <= CDP_MU_MAX_USER_INDEX);
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301560 return user_index;
1561 }
1562 }
1563
1564 pdev->tx_ppdu_info.last_user++;
Soumya Bhat835033e2017-10-04 22:21:46 +05301565 /* Max users possible is 8 so last user should not exceed 8 */
1566 qdf_assert_always(pdev->tx_ppdu_info.last_user <= CDP_MU_MAX_USERS);
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301567 return pdev->tx_ppdu_info.last_user - 1;
1568}
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301569
1570/*
1571 * dp_process_ppdu_stats_common_tlv: Process htt_ppdu_stats_common_tlv
1572 * pdev: DP pdev handle
1573 * @tag_buf: buffer containing the tlv htt_ppdu_stats_common_tlv
1574 *
1575 * return:void
1576 */
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301577static void dp_process_ppdu_stats_common_tlv(struct dp_pdev *pdev,
1578 uint32_t *tag_buf)
1579{
Pamidipati, Vijayd7eb83e2017-09-20 21:19:56 +05301580 uint16_t frame_type;
Venkateswara Swamy Bandaru2907bc52017-11-15 19:04:49 +05301581 uint16_t freq;
1582 struct dp_soc *soc = NULL;
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301583 struct cdp_tx_completion_ppdu *ppdu_desc;
1584 htt_ppdu_stats_common_tlv *dp_stats_buf =
1585 (htt_ppdu_stats_common_tlv *)tag_buf;
1586
1587 ppdu_desc =
1588 (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(pdev->tx_ppdu_info.buf);
1589
1590 ppdu_desc->ppdu_id = dp_stats_buf->ppdu_id;
1591 tag_buf += 2;
1592 ppdu_desc->num_users =
1593 HTT_PPDU_STATS_COMMON_TLV_NUM_USERS_GET(*tag_buf);
1594 tag_buf++;
Pamidipati, Vijayd7eb83e2017-09-20 21:19:56 +05301595 frame_type = HTT_PPDU_STATS_COMMON_TLV_FRM_TYPE_GET(*tag_buf);
1596
1597 if ((frame_type == HTT_STATS_FTYPE_TIDQ_DATA_SU) ||
1598 (frame_type == HTT_STATS_FTYPE_TIDQ_DATA_MU))
1599 ppdu_desc->frame_type = CDP_PPDU_FTYPE_DATA;
1600 else
1601 ppdu_desc->frame_type = CDP_PPDU_FTYPE_CTRL;
1602
Pranita Solankea12b4b32017-11-20 23:04:14 +05301603 tag_buf += 2;
1604 ppdu_desc->tx_duration = *tag_buf;
1605 tag_buf += 3;
1606 ppdu_desc->ppdu_start_timestamp = *tag_buf;
1607 ppdu_desc->ppdu_end_timestamp = 0; /*TODO: value to be provided by FW */
1608 tag_buf++;
1609
Venkateswara Swamy Bandaru2907bc52017-11-15 19:04:49 +05301610 freq = HTT_PPDU_STATS_COMMON_TLV_CHAN_MHZ_GET(*tag_buf);
1611 if (freq != ppdu_desc->channel) {
1612 soc = pdev->soc;
1613 ppdu_desc->channel = freq;
1614 if (soc && soc->cdp_soc.ol_ops->freq_to_channel)
1615 pdev->operating_channel =
1616 soc->cdp_soc.ol_ops->freq_to_channel(pdev->osif_pdev, freq);
1617 }
Pranita Solankea12b4b32017-11-20 23:04:14 +05301618
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301619 ppdu_desc->phy_mode = HTT_PPDU_STATS_COMMON_TLV_PHY_MODE_GET(*tag_buf);
1620}
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301621
1622/*
1623 * dp_process_ppdu_stats_user_common_tlv: Process ppdu_stats_user_common
1624 * @tag_buf: buffer containing the tlv htt_ppdu_stats_user_common_tlv
1625 *
1626 * return:void
1627 */
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301628static void dp_process_ppdu_stats_user_common_tlv(
1629 struct dp_pdev *pdev, uint32_t *tag_buf)
1630{
Soumya Bhat835033e2017-10-04 22:21:46 +05301631 uint16_t peer_id;
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301632 struct dp_peer *peer;
1633 struct cdp_tx_completion_ppdu *ppdu_desc;
1634 struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
1635 uint8_t curr_user_index = 0;
1636
1637 ppdu_desc =
1638 (struct cdp_tx_completion_ppdu *) qdf_nbuf_data(pdev->tx_ppdu_info.buf);
1639
1640 tag_buf++;
1641 peer_id = HTT_PPDU_STATS_USER_COMMON_TLV_SW_PEER_ID_GET(*tag_buf);
1642 peer = dp_peer_find_by_id(pdev->soc, peer_id);
1643
1644 if (!peer)
1645 return;
Soumya Bhat835033e2017-10-04 22:21:46 +05301646
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301647 curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id);
1648 ppdu_user_desc = &ppdu_desc->user[curr_user_index];
1649
1650 ppdu_user_desc->peer_id = peer_id;
1651
1652 tag_buf++;
1653
Soumya Bhat1c73aa62017-09-20 22:18:22 +05301654 if (HTT_PPDU_STATS_USER_COMMON_TLV_MCAST_GET(*tag_buf)) {
1655 ppdu_user_desc->is_mcast = true;
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301656 ppdu_user_desc->mpdu_tried_mcast =
1657 HTT_PPDU_STATS_USER_COMMON_TLV_MPDUS_TRIED_GET(*tag_buf);
Soumya Bhat1c73aa62017-09-20 22:18:22 +05301658 } else {
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301659 ppdu_user_desc->mpdu_tried_ucast =
1660 HTT_PPDU_STATS_USER_COMMON_TLV_MPDUS_TRIED_GET(*tag_buf);
Soumya Bhat606fb392017-10-27 12:42:45 +05301661 }
1662
1663 tag_buf++;
1664
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301665 ppdu_user_desc->qos_ctrl =
1666 HTT_PPDU_STATS_USER_COMMON_TLV_QOS_CTRL_GET(*tag_buf);
1667 ppdu_user_desc->frame_ctrl =
1668 HTT_PPDU_STATS_USER_COMMON_TLV_FRAME_CTRL_GET(*tag_buf);
1669}
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301670
1671
Ishank Jain6290a3c2017-03-21 10:49:39 +05301672/**
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05301673 * dp_process_ppdu_stats_user_rate_tlv() - Process htt_ppdu_stats_user_rate_tlv
1674 * @pdev: DP pdev handle
1675 * @tag_buf: T2H message buffer carrying the user rate TLV
1676 *
1677 * return:void
1678 */
1679static void dp_process_ppdu_stats_user_rate_tlv(struct dp_pdev *pdev,
1680 uint32_t *tag_buf)
1681{
Soumya Bhat835033e2017-10-04 22:21:46 +05301682 uint16_t peer_id;
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05301683 struct dp_peer *peer;
1684 struct cdp_tx_completion_ppdu *ppdu_desc;
1685 struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301686 uint8_t curr_user_index = 0;
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05301687
1688 ppdu_desc =
1689 (struct cdp_tx_completion_ppdu *) qdf_nbuf_data(pdev->tx_ppdu_info.buf);
1690
1691 tag_buf++;
1692 peer_id = HTT_PPDU_STATS_USER_RATE_TLV_SW_PEER_ID_GET(*tag_buf);
1693 peer = dp_peer_find_by_id(pdev->soc, peer_id);
1694
1695 if (!peer)
1696 return;
1697
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301698 curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id);
1699
1700 ppdu_user_desc = &ppdu_desc->user[curr_user_index];
1701 ppdu_user_desc->peer_id = peer_id;
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05301702
1703 ppdu_user_desc->tid =
1704 HTT_PPDU_STATS_USER_RATE_TLV_TID_NUM_GET(*tag_buf);
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05301705
1706 qdf_mem_copy(ppdu_user_desc->mac_addr, peer->mac_addr.raw,
1707 DP_MAC_ADDR_LEN);
1708
Soumya Bhat28541112017-11-22 16:58:29 +05301709 tag_buf += 2;
1710
1711 ppdu_user_desc->ru_tones = (HTT_PPDU_STATS_USER_RATE_TLV_RU_END_GET(*tag_buf) -
1712 HTT_PPDU_STATS_USER_RATE_TLV_RU_START_GET(*tag_buf)) + 1;
1713
1714 tag_buf += 2;
Soumya Bhat606fb392017-10-27 12:42:45 +05301715
1716 ppdu_user_desc->ppdu_type =
1717 HTT_PPDU_STATS_USER_RATE_TLV_PPDU_TYPE_GET(*tag_buf);
1718
1719 tag_buf++;
Pranita Solankea12b4b32017-11-20 23:04:14 +05301720 ppdu_user_desc->tx_rate = *tag_buf;
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05301721
1722 ppdu_user_desc->ltf_size =
1723 HTT_PPDU_STATS_USER_RATE_TLV_LTF_SIZE_GET(*tag_buf);
1724 ppdu_user_desc->stbc =
1725 HTT_PPDU_STATS_USER_RATE_TLV_STBC_GET(*tag_buf);
1726 ppdu_user_desc->he_re =
1727 HTT_PPDU_STATS_USER_RATE_TLV_HE_RE_GET(*tag_buf);
1728 ppdu_user_desc->txbf =
1729 HTT_PPDU_STATS_USER_RATE_TLV_TXBF_GET(*tag_buf);
1730 ppdu_user_desc->bw =
1731 HTT_PPDU_STATS_USER_RATE_TLV_BW_GET(*tag_buf);
1732 ppdu_user_desc->nss = HTT_PPDU_STATS_USER_RATE_TLV_NSS_GET(*tag_buf);
1733 ppdu_user_desc->mcs = HTT_PPDU_STATS_USER_RATE_TLV_MCS_GET(*tag_buf);
1734 ppdu_user_desc->preamble =
1735 HTT_PPDU_STATS_USER_RATE_TLV_PREAMBLE_GET(*tag_buf);
1736 ppdu_user_desc->gi = HTT_PPDU_STATS_USER_RATE_TLV_GI_GET(*tag_buf);
1737 ppdu_user_desc->dcm = HTT_PPDU_STATS_USER_RATE_TLV_DCM_GET(*tag_buf);
1738 ppdu_user_desc->ldpc = HTT_PPDU_STATS_USER_RATE_TLV_LDPC_GET(*tag_buf);
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05301739}
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301740
1741/*
1742 * dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv: Process
1743 * htt_ppdu_stats_enq_mpdu_bitmap_64_tlv
Soumya Bhat1c73aa62017-09-20 22:18:22 +05301744 * pdev: DP PDEV handle
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301745 * @tag_buf: buffer containing the tlv htt_ppdu_stats_enq_mpdu_bitmap_64_tlv
1746 *
1747 * return:void
1748 */
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301749static void dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv(
1750 struct dp_pdev *pdev, uint32_t *tag_buf)
1751{
1752 htt_ppdu_stats_enq_mpdu_bitmap_64_tlv *dp_stats_buf =
1753 (htt_ppdu_stats_enq_mpdu_bitmap_64_tlv *)tag_buf;
1754
1755 struct cdp_tx_completion_ppdu *ppdu_desc;
1756 struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
1757 uint8_t curr_user_index = 0;
Soumya Bhat835033e2017-10-04 22:21:46 +05301758 uint16_t peer_id;
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301759 struct dp_peer *peer;
1760
1761 ppdu_desc =
1762 (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(pdev->tx_ppdu_info.buf);
1763
1764 tag_buf++;
1765
1766 peer_id =
Soumya Bhat835033e2017-10-04 22:21:46 +05301767 HTT_PPDU_STATS_ENQ_MPDU_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301768
1769 peer = dp_peer_find_by_id(pdev->soc, peer_id);
1770
1771 if (!peer)
1772 return;
1773
1774 curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id);
1775
1776 ppdu_user_desc = &ppdu_desc->user[curr_user_index];
Soumya Bhat835033e2017-10-04 22:21:46 +05301777 ppdu_user_desc->peer_id = peer_id;
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301778
1779 ppdu_user_desc->start_seq = dp_stats_buf->start_seq;
1780 qdf_mem_copy(&ppdu_user_desc->enq_bitmap, &dp_stats_buf->enq_bitmap,
1781 CDP_BA_64_BIT_MAP_SIZE_DWORDS);
1782}
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301783
1784/*
1785 * dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv: Process
1786 * htt_ppdu_stats_enq_mpdu_bitmap_256_tlv
1787 * soc: DP SOC handle
1788 * @tag_buf: buffer containing the tlv htt_ppdu_stats_enq_mpdu_bitmap_256_tlv
1789 *
1790 * return:void
1791 */
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301792static void dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv(
1793 struct dp_pdev *pdev, uint32_t *tag_buf)
1794{
1795 htt_ppdu_stats_enq_mpdu_bitmap_256_tlv *dp_stats_buf =
1796 (htt_ppdu_stats_enq_mpdu_bitmap_256_tlv *)tag_buf;
1797
1798 struct cdp_tx_completion_ppdu *ppdu_desc;
1799 struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
1800 uint8_t curr_user_index = 0;
Soumya Bhat835033e2017-10-04 22:21:46 +05301801 uint16_t peer_id;
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301802 struct dp_peer *peer;
1803
1804 ppdu_desc =
1805 (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(pdev->tx_ppdu_info.buf);
1806
1807 tag_buf++;
1808
1809 peer_id =
Soumya Bhat835033e2017-10-04 22:21:46 +05301810 HTT_PPDU_STATS_ENQ_MPDU_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301811
1812 peer = dp_peer_find_by_id(pdev->soc, peer_id);
1813
1814 if (!peer)
1815 return;
1816
1817 curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id);
1818
1819 ppdu_user_desc = &ppdu_desc->user[curr_user_index];
Soumya Bhat835033e2017-10-04 22:21:46 +05301820 ppdu_user_desc->peer_id = peer_id;
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301821
1822 ppdu_user_desc->start_seq = dp_stats_buf->start_seq;
1823 qdf_mem_copy(&ppdu_user_desc->enq_bitmap, &dp_stats_buf->enq_bitmap,
1824 CDP_BA_256_BIT_MAP_SIZE_DWORDS);
1825}
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301826
1827/*
1828 * dp_process_ppdu_stats_user_cmpltn_common_tlv: Process
1829 * htt_ppdu_stats_user_cmpltn_common_tlv
1830 * soc: DP SOC handle
1831 * @tag_buf: buffer containing the tlv htt_ppdu_stats_user_cmpltn_common_tlv
1832 *
1833 * return:void
1834 */
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301835static void dp_process_ppdu_stats_user_cmpltn_common_tlv(
1836 struct dp_pdev *pdev, uint32_t *tag_buf)
1837{
Soumya Bhat835033e2017-10-04 22:21:46 +05301838 uint16_t peer_id;
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301839 struct dp_peer *peer;
1840 struct cdp_tx_completion_ppdu *ppdu_desc;
1841 struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
1842 uint8_t curr_user_index = 0;
1843 htt_ppdu_stats_user_cmpltn_common_tlv *dp_stats_buf =
1844 (htt_ppdu_stats_user_cmpltn_common_tlv *)tag_buf;
1845
1846 ppdu_desc =
1847 (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(pdev->tx_ppdu_info.buf);
1848
1849 tag_buf++;
1850 peer_id =
1851 HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_SW_PEER_ID_GET(*tag_buf);
1852 peer = dp_peer_find_by_id(pdev->soc, peer_id);
1853
1854 if (!peer)
1855 return;
1856
1857 curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id);
1858 ppdu_user_desc = &ppdu_desc->user[curr_user_index];
1859 ppdu_user_desc->peer_id = peer_id;
1860
1861 ppdu_user_desc->completion_status =
1862 HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_COMPLETION_STATUS_GET(
1863 *tag_buf);
1864
1865 ppdu_user_desc->tid =
1866 HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_TID_NUM_GET(*tag_buf);
1867
1868
1869 tag_buf++;
1870 ppdu_desc->ack_rssi = dp_stats_buf->ack_rssi;
1871
1872 tag_buf++;
1873
1874 ppdu_user_desc->mpdu_success =
1875 HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MPDU_SUCCESS_GET(*tag_buf);
1876
1877 tag_buf++;
1878
1879 ppdu_user_desc->long_retries =
1880 HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_LONG_RETRY_GET(*tag_buf);
1881
1882 ppdu_user_desc->short_retries =
1883 HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_SHORT_RETRY_GET(*tag_buf);
Pranita Solankea12b4b32017-11-20 23:04:14 +05301884 ppdu_user_desc->retry_msdus =
1885 ppdu_user_desc->long_retries + ppdu_user_desc->short_retries;
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301886
1887 ppdu_user_desc->is_ampdu =
1888 HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_IS_AMPDU_GET(*tag_buf);
1889
1890}
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301891
1892/*
1893 * dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv: Process
1894 * htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv
Soumya Bhat1c73aa62017-09-20 22:18:22 +05301895 * pdev: DP PDEV handle
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301896 * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv
1897 *
1898 * return:void
1899 */
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301900static void dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv(
1901 struct dp_pdev *pdev, uint32_t *tag_buf)
1902{
1903 htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv *dp_stats_buf =
1904 (htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv *)tag_buf;
1905 struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
1906 struct cdp_tx_completion_ppdu *ppdu_desc;
1907 uint8_t curr_user_index = 0;
Soumya Bhat835033e2017-10-04 22:21:46 +05301908 uint16_t peer_id;
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301909 struct dp_peer *peer;
1910
1911 ppdu_desc =
1912 (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(pdev->tx_ppdu_info.buf);
1913
1914 tag_buf++;
1915
1916 peer_id =
1917 HTT_PPDU_STATS_USER_CMPLTN_BA_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
1918
1919 peer = dp_peer_find_by_id(pdev->soc, peer_id);
1920
1921 if (!peer)
1922 return;
1923
1924 curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id);
1925
1926 ppdu_user_desc = &ppdu_desc->user[curr_user_index];
Soumya Bhat835033e2017-10-04 22:21:46 +05301927 ppdu_user_desc->peer_id = peer_id;
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301928
1929 ppdu_user_desc->ba_seq_no = dp_stats_buf->ba_seq_no;
1930 qdf_mem_copy(&ppdu_user_desc->ba_bitmap, &dp_stats_buf->ba_bitmap,
1931 CDP_BA_64_BIT_MAP_SIZE_DWORDS);
1932}
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301933
1934/*
1935 * dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv: Process
1936 * htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv
Soumya Bhat1c73aa62017-09-20 22:18:22 +05301937 * pdev: DP PDEV handle
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301938 * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv
1939 *
1940 * return:void
1941 */
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301942static void dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv(
1943 struct dp_pdev *pdev, uint32_t *tag_buf)
1944{
1945 htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv *dp_stats_buf =
1946 (htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv *)tag_buf;
1947 struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
1948 struct cdp_tx_completion_ppdu *ppdu_desc;
1949 uint8_t curr_user_index = 0;
Soumya Bhat835033e2017-10-04 22:21:46 +05301950 uint16_t peer_id;
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301951 struct dp_peer *peer;
1952
1953 ppdu_desc =
1954 (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(pdev->tx_ppdu_info.buf);
1955
1956 tag_buf++;
1957
1958 peer_id =
1959 HTT_PPDU_STATS_USER_CMPLTN_BA_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
1960
1961 peer = dp_peer_find_by_id(pdev->soc, peer_id);
1962
1963 if (!peer)
1964 return;
1965
1966 curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id);
1967
1968 ppdu_user_desc = &ppdu_desc->user[curr_user_index];
Soumya Bhat835033e2017-10-04 22:21:46 +05301969 ppdu_user_desc->peer_id = peer_id;
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301970
1971 ppdu_user_desc->ba_seq_no = dp_stats_buf->ba_seq_no;
1972 qdf_mem_copy(&ppdu_user_desc->ba_bitmap, &dp_stats_buf->ba_bitmap,
1973 CDP_BA_256_BIT_MAP_SIZE_DWORDS);
1974}
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301975
1976/*
1977 * dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv: Process
1978 * htt_ppdu_stats_user_compltn_ack_ba_status_tlv
Soumya Bhat1c73aa62017-09-20 22:18:22 +05301979 * pdev: DP PDE handle
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301980 * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ack_ba_status_tlv
1981 *
1982 * return:void
1983 */
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301984static void dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv(
1985 struct dp_pdev *pdev, uint32_t *tag_buf)
1986{
Soumya Bhat835033e2017-10-04 22:21:46 +05301987 uint16_t peer_id;
Soumya Bhat539ecfa2017-09-08 12:50:30 +05301988 struct dp_peer *peer;
1989 struct cdp_tx_completion_ppdu *ppdu_desc;
1990 struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
1991 uint8_t curr_user_index = 0;
1992
1993 ppdu_desc =
1994 (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(pdev->tx_ppdu_info.buf);
1995
1996 tag_buf += 2;
1997 peer_id =
1998 HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_SW_PEER_ID_GET(*tag_buf);
1999
2000 peer = dp_peer_find_by_id(pdev->soc, peer_id);
2001
2002 if (!peer)
2003 return;
2004
2005 curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id);
2006
2007 ppdu_user_desc = &ppdu_desc->user[curr_user_index];
Soumya Bhat835033e2017-10-04 22:21:46 +05302008 ppdu_user_desc->peer_id = peer_id;
Soumya Bhat539ecfa2017-09-08 12:50:30 +05302009
Soumya Bhat606fb392017-10-27 12:42:45 +05302010 tag_buf++;
Soumya Bhat539ecfa2017-09-08 12:50:30 +05302011 ppdu_user_desc->num_mpdu =
2012 HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_NUM_MPDU_GET(*tag_buf);
2013
2014 ppdu_user_desc->num_msdu =
2015 HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_NUM_MSDU_GET(*tag_buf);
Pranita Solankea12b4b32017-11-20 23:04:14 +05302016
2017 ppdu_user_desc->success_msdus = ppdu_user_desc->num_msdu;
2018
2019 tag_buf += 2;
2020 ppdu_user_desc->success_bytes = *tag_buf;
2021
Soumya Bhat539ecfa2017-09-08 12:50:30 +05302022}
Soumya Bhat1c73aa62017-09-20 22:18:22 +05302023
2024/*
2025 * dp_process_ppdu_stats_user_common_array_tlv: Process
2026 * htt_ppdu_stats_user_common_array_tlv
2027 * pdev: DP PDEV handle
2028 * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ack_ba_status_tlv
2029 *
2030 * return:void
2031 */
2032static void dp_process_ppdu_stats_user_common_array_tlv(struct dp_pdev *pdev,
2033 uint32_t *tag_buf)
2034{
2035 uint32_t peer_id;
2036 struct dp_peer *peer;
2037 struct cdp_tx_completion_ppdu *ppdu_desc;
2038 struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
2039 uint8_t curr_user_index = 0;
2040 struct htt_tx_ppdu_stats_info *dp_stats_buf;
2041
2042 ppdu_desc =
2043 (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(pdev->tx_ppdu_info.buf);
2044
Pranita Solankea12b4b32017-11-20 23:04:14 +05302045 tag_buf++;
Soumya Bhat1c73aa62017-09-20 22:18:22 +05302046 dp_stats_buf = (struct htt_tx_ppdu_stats_info *)tag_buf;
Pranita Solankea12b4b32017-11-20 23:04:14 +05302047 tag_buf += 3;
Soumya Bhat1c73aa62017-09-20 22:18:22 +05302048 peer_id =
2049 HTT_PPDU_STATS_ARRAY_ITEM_TLV_PEERID_GET(*tag_buf);
2050
2051 peer = dp_peer_find_by_id(pdev->soc, peer_id);
2052
2053 if (!peer) {
2054 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
2055 "Invalid peer");
2056 return;
2057 }
2058
2059 curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id);
2060
2061 ppdu_user_desc = &ppdu_desc->user[curr_user_index];
2062
Soumya Bhat1c73aa62017-09-20 22:18:22 +05302063 ppdu_user_desc->retry_bytes = dp_stats_buf->tx_retry_bytes;
2064 ppdu_user_desc->failed_bytes = dp_stats_buf->tx_failed_bytes;
2065
2066 tag_buf++;
Pranita Solankea12b4b32017-11-20 23:04:14 +05302067
Soumya Bhat1c73aa62017-09-20 22:18:22 +05302068 ppdu_user_desc->success_msdus =
2069 HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_SUCC_MSDUS_GET(*tag_buf);
2070 ppdu_user_desc->retry_bytes =
2071 HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_RETRY_MSDUS_GET(*tag_buf);
2072 tag_buf++;
2073 ppdu_user_desc->failed_msdus =
2074 HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_FAILED_MSDUS_GET(*tag_buf);
Pranita Solankea12b4b32017-11-20 23:04:14 +05302075}
2076
2077/*
2078 * dp_process_ppdu_stats_flush_tlv: Process
2079 * htt_ppdu_stats_flush_tlv
2080 * @pdev: DP PDEV handle
2081 * @tag_buf: buffer containing the htt_ppdu_stats_flush_tlv
2082 *
2083 * return:void
2084 */
2085static void dp_process_ppdu_stats_user_compltn_flush_tlv(struct dp_pdev *pdev,
2086 uint32_t *tag_buf)
2087{
2088 uint32_t peer_id;
2089 uint32_t drop_reason;
2090 uint8_t tid;
2091 uint32_t num_msdu;
2092 struct dp_peer *peer;
2093
2094 tag_buf++;
2095 drop_reason = *tag_buf;
2096
2097 tag_buf++;
2098 num_msdu = HTT_PPDU_STATS_FLUSH_TLV_NUM_MSDU_GET(*tag_buf);
2099
2100 tag_buf++;
2101 peer_id =
2102 HTT_PPDU_STATS_FLUSH_TLV_SW_PEER_ID_GET(*tag_buf);
2103
2104 peer = dp_peer_find_by_id(pdev->soc, peer_id);
2105 if (!peer)
2106 return;
2107
2108 tid = HTT_PPDU_STATS_FLUSH_TLV_TID_NUM_GET(*tag_buf);
2109
2110 if (drop_reason == HTT_FLUSH_EXCESS_RETRIES) {
2111 DP_STATS_INC(peer, tx.excess_retries[TID_TO_WME_AC(tid)],
2112 num_msdu);
2113 }
Soumya Bhat1c73aa62017-09-20 22:18:22 +05302114}
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05302115
Soumya Bhatcfbb8952017-10-03 15:04:09 +05302116/*
2117 * dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv: Process
2118 * htt_ppdu_stats_tx_mgmtctrl_payload_tlv
2119 * @pdev: DP PDEV handle
2120 * @tag_buf: buffer containing the htt_ppdu_stats_tx_mgmtctrl_payload_tlv
2121 * @length: tlv_length
2122 *
2123 * return:void
2124 */
2125static void dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv(
2126 struct dp_pdev *pdev, uint32_t *tag_buf, uint32_t length)
2127{
2128 htt_ppdu_stats_tx_mgmtctrl_payload_tlv *dp_stats_buf =
2129 (htt_ppdu_stats_tx_mgmtctrl_payload_tlv *)tag_buf;
2130
2131 qdf_nbuf_t nbuf = NULL;
2132
2133 uint32_t payload_size = length - HTT_MGMT_CTRL_TLV_RESERVERD_LEN;
2134
2135 nbuf = qdf_nbuf_alloc(pdev->soc->osdev, payload_size, 0, 4, true);
2136
2137 if (!nbuf) {
2138 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
2139 "Nbuf Allocation failed for Mgmt. payload");
2140 qdf_assert(0);
2141 return;
2142 }
2143
2144 qdf_nbuf_put_tail(nbuf, payload_size);
2145 qdf_mem_copy(qdf_nbuf_data(nbuf), dp_stats_buf->payload, payload_size);
2146
2147 dp_wdi_event_handler(WDI_EVENT_TX_MGMT_CTRL, pdev->soc,
2148 nbuf, HTT_INVALID_PEER,
2149 WDI_NO_VAL, pdev->pdev_id);
2150}
2151
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05302152/**
2153 * dp_process_ppdu_tag(): Function to process the PPDU TLVs
2154 * @soc: DP Physical device (radio) handle
2155 * @tag_buf: TLV buffer
2156 *
2157 * return: void
2158 */
2159static void dp_process_ppdu_tag(struct dp_pdev *pdev, uint32_t *tag_buf,
2160 uint32_t tlv_len)
2161{
2162 uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05302163 switch (tlv_type) {
Soumya Bhat539ecfa2017-09-08 12:50:30 +05302164 case HTT_PPDU_STATS_COMMON_TLV:
2165 dp_process_ppdu_stats_common_tlv(pdev, tag_buf);
2166 break;
2167 case HTT_PPDU_STATS_USR_COMMON_TLV:
2168 dp_process_ppdu_stats_user_common_tlv(pdev, tag_buf);
2169 break;
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05302170 case HTT_PPDU_STATS_USR_RATE_TLV:
2171 qdf_assert_always(tlv_len ==
2172 sizeof(htt_ppdu_stats_user_rate_tlv));
2173 dp_process_ppdu_stats_user_rate_tlv(pdev, tag_buf);
2174 break;
Soumya Bhat539ecfa2017-09-08 12:50:30 +05302175 case HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_64_TLV:
2176 dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv(pdev, tag_buf);
2177 break;
2178 case HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_256_TLV:
2179 dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv(pdev, tag_buf);
2180 break;
2181 case HTT_PPDU_STATS_USR_COMPLTN_COMMON_TLV:
2182 dp_process_ppdu_stats_user_cmpltn_common_tlv(pdev, tag_buf);
2183 break;
2184 case HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_64_TLV:
2185 dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv(pdev,
2186 tag_buf);
2187 break;
2188 case HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_256_TLV:
2189 dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv(pdev,
2190 tag_buf);
2191 break;
2192 case HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV:
2193 dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv(pdev,
2194 tag_buf);
2195 break;
Soumya Bhat1c73aa62017-09-20 22:18:22 +05302196 case HTT_PPDU_STATS_USR_COMMON_ARRAY_TLV:
2197 dp_process_ppdu_stats_user_common_array_tlv(pdev,
2198 tag_buf);
2199 break;
Pranita Solankea12b4b32017-11-20 23:04:14 +05302200 case HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV:
2201 dp_process_ppdu_stats_user_compltn_flush_tlv(pdev,
2202 tag_buf);
2203 break;
Soumya Bhatcfbb8952017-10-03 15:04:09 +05302204 case HTT_PPDU_STATS_TX_MGMTCTRL_PAYLOAD_TLV:
2205 dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv(pdev,
2206 tag_buf, tlv_len);
2207 break;
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05302208 default:
2209 break;
2210 }
2211}
2212
2213static QDF_STATUS dp_htt_process_tlv(struct dp_pdev *pdev,
2214 qdf_nbuf_t htt_t2h_msg)
2215{
2216 uint32_t length;
2217 uint32_t ppdu_id;
2218 uint8_t tlv_type;
2219 uint32_t tlv_length;
2220 uint8_t *tlv_buf;
2221 QDF_STATUS status = QDF_STATUS_E_PENDING;
2222
2223 uint32_t *msg_word = (uint32_t *) qdf_nbuf_data(htt_t2h_msg);
2224
2225 length = HTT_T2H_PPDU_STATS_PAYLOAD_SIZE_GET(*msg_word);
2226
2227 msg_word = msg_word + 1;
2228 ppdu_id = HTT_T2H_PPDU_STATS_PPDU_ID_GET(*msg_word);
2229
2230 msg_word = msg_word + 3;
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05302231 while (length > 0) {
2232 tlv_buf = (uint8_t *)msg_word;
2233 tlv_type = HTT_STATS_TLV_TAG_GET(*msg_word);
2234 tlv_length = HTT_STATS_TLV_LENGTH_GET(*msg_word);
2235
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05302236 if (tlv_length == 0)
2237 break;
2238
2239 if (tlv_type == HTT_PPDU_STATS_SCH_CMD_STATUS_TLV)
2240 status = QDF_STATUS_SUCCESS;
2241
2242 tlv_length += HTT_TLV_HDR_LEN;
2243 dp_process_ppdu_tag(pdev, msg_word, tlv_length);
2244
Pranita Solankea12b4b32017-11-20 23:04:14 +05302245
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05302246 msg_word = (uint32_t *)((uint8_t *)tlv_buf + tlv_length);
2247 length -= (tlv_length);
2248 }
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05302249 return status;
2250}
Soumya Bhat1c73aa62017-09-20 22:18:22 +05302251#endif /* FEATURE_PERPKT_INFO */
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05302252
2253/**
2254 * dp_txrx_ppdu_stats_handler() - Function to process HTT PPDU stats from FW
2255 * @soc: DP SOC handle
2256 * @pdev_id: pdev id
2257 * @htt_t2h_msg: HTT message nbuf
2258 *
2259 * return:void
2260 */
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -07002261#if defined(WDI_EVENT_ENABLE)
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05302262#ifdef FEATURE_PERPKT_INFO
2263static void dp_txrx_ppdu_stats_handler(struct dp_soc *soc,
2264 uint8_t pdev_id, qdf_nbuf_t htt_t2h_msg)
2265{
2266 struct dp_pdev *pdev = soc->pdev_list[pdev_id];
2267 struct dp_vdev *vdev;
2268 struct dp_peer *peer;
2269 struct cdp_tx_completion_ppdu *ppdu_desc;
2270 int status;
2271 int i;
2272
Soumya Bhat89647ef2017-11-16 17:23:48 +05302273 if (!pdev->enhanced_stats_en && !pdev->tx_sniffer_enable &&
2274 !pdev->am_copy_mode)
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05302275 return;
2276
2277 if (!pdev->tx_ppdu_info.buf) {
2278 /*
2279 * Todo: For MU/OFDMA, we need to account for multiple user
2280 * descriptors in a PPDU, in skb size.
2281 * The allocation has to be moved to ppdu_cmn tlv processing
2282 */
2283 pdev->tx_ppdu_info.buf = qdf_nbuf_alloc(soc->osdev,
2284 sizeof(struct cdp_tx_completion_ppdu), 0, 4,
2285 TRUE);
2286
2287 if (!pdev->tx_ppdu_info.buf) {
2288 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
2289 "Nbuf Allocation failed for HTT PPDU");
2290 return;
2291 }
2292
Soumya Bhat1c73aa62017-09-20 22:18:22 +05302293 qdf_mem_zero(qdf_nbuf_data(pdev->tx_ppdu_info.buf),
2294 sizeof(struct cdp_tx_completion_ppdu));
2295
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05302296 if (qdf_nbuf_put_tail(pdev->tx_ppdu_info.buf,
2297 sizeof(struct cdp_tx_completion_ppdu)) == NULL) {
2298 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
2299 "No tailroom for HTT PPDU");
2300 return;
2301 }
Soumya Bhat1c73aa62017-09-20 22:18:22 +05302302
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05302303 }
2304
2305 status = dp_htt_process_tlv(pdev, htt_t2h_msg);
2306
2307 if (status == QDF_STATUS_SUCCESS) {
2308 ppdu_desc = (struct cdp_tx_completion_ppdu *)
2309 qdf_nbuf_data(pdev->tx_ppdu_info.buf);
2310
2311 vdev = dp_get_vdev_from_soc_vdev_id_wifi3(soc,
2312 ppdu_desc->vdev_id);
2313
2314 for (i = 0; i < ppdu_desc->num_users; i++) {
2315 peer = dp_peer_find_by_id(soc,
2316 ppdu_desc->user[i].peer_id);
Soumya Bhat1c73aa62017-09-20 22:18:22 +05302317 if (!peer)
2318 continue;
2319
2320 ppdu_desc->num_mpdu += ppdu_desc->user[i].num_mpdu;
2321 ppdu_desc->num_msdu += ppdu_desc->user[i].num_msdu;
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +05302322
2323 if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_DATA) {
2324 dp_tx_stats_update(soc, peer,
2325 &ppdu_desc->user[i],
2326 ppdu_desc->ack_rssi);
2327 }
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05302328 }
2329
2330 dp_wdi_event_handler(WDI_EVENT_TX_PPDU_DESC, soc,
2331 pdev->tx_ppdu_info.buf, HTT_INVALID_PEER,
2332 WDI_NO_VAL, pdev_id);
2333
2334 pdev->tx_ppdu_info.buf = NULL;
Soumya Bhat539ecfa2017-09-08 12:50:30 +05302335 pdev->tx_ppdu_info.last_user = 0;
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05302336 }
2337}
2338#else
2339static void dp_txrx_ppdu_stats_handler(struct dp_soc *soc,
2340 uint8_t pdev_id, qdf_nbuf_t htt_t2h_msg)
2341{
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -07002342
Pamidipati, Vijay038d0902017-07-17 09:53:31 +05302343}
2344#endif
2345#endif
2346
2347/**
2348 * dp_txrx_fw_stats_handler() - Function to process HTT EXT stats
Ishank Jain6290a3c2017-03-21 10:49:39 +05302349 * @soc: DP SOC handle
2350 * @htt_t2h_msg: HTT message nbuf
2351 *
2352 * return:void
2353 */
2354static inline void dp_txrx_fw_stats_handler(struct dp_soc *soc,
2355 qdf_nbuf_t htt_t2h_msg)
2356{
Ishank Jain6290a3c2017-03-21 10:49:39 +05302357 uint8_t done;
2358 qdf_nbuf_t msg_copy;
2359 uint32_t *msg_word;
2360
2361 msg_word = (uint32_t *) qdf_nbuf_data(htt_t2h_msg);
2362 msg_word = msg_word + 3;
Ishank Jain6290a3c2017-03-21 10:49:39 +05302363 done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
2364
2365 /*
2366 * HTT EXT stats response comes as stream of TLVs which span over
2367 * multiple T2H messages.
2368 * The first message will carry length of the response.
2369 * For rest of the messages length will be zero.
Om Prakash Tripathi12126822017-08-03 10:21:24 +05302370 *
Ishank Jain6290a3c2017-03-21 10:49:39 +05302371 * Clone the T2H message buffer and store it in a list to process
2372 * it later.
2373 *
2374 * The original T2H message buffers gets freed in the T2H HTT event
2375 * handler
2376 */
2377 msg_copy = qdf_nbuf_clone(htt_t2h_msg);
2378
2379 if (!msg_copy) {
2380 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
2381 "T2H messge clone failed for HTT EXT STATS");
Ishank Jain6290a3c2017-03-21 10:49:39 +05302382 goto error;
2383 }
2384
Om Prakash Tripathi12126822017-08-03 10:21:24 +05302385 qdf_spin_lock_bh(&soc->htt_stats.lock);
2386 qdf_nbuf_queue_add(&soc->htt_stats.msg, msg_copy);
Ishank Jain6290a3c2017-03-21 10:49:39 +05302387 /*
2388 * Done bit signifies that this is the last T2H buffer in the stream of
2389 * HTT EXT STATS message
2390 */
Om Prakash Tripathi12126822017-08-03 10:21:24 +05302391 if (done) {
2392 soc->htt_stats.num_stats++;
2393 qdf_sched_work(0, &soc->htt_stats.work);
2394 }
2395 qdf_spin_unlock_bh(&soc->htt_stats.lock);
Ishank Jain6290a3c2017-03-21 10:49:39 +05302396
2397 return;
2398
2399error:
Om Prakash Tripathi12126822017-08-03 10:21:24 +05302400 qdf_spin_lock_bh(&soc->htt_stats.lock);
2401 while ((msg_copy = qdf_nbuf_queue_remove(&soc->htt_stats.msg))
Ishank Jain6290a3c2017-03-21 10:49:39 +05302402 != NULL) {
2403 qdf_nbuf_free(msg_copy);
2404 }
Om Prakash Tripathi12126822017-08-03 10:21:24 +05302405 soc->htt_stats.num_stats = 0;
2406 qdf_spin_unlock_bh(&soc->htt_stats.lock);
Ishank Jain6290a3c2017-03-21 10:49:39 +05302407 return;
2408
2409}
2410
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07002411/*
2412 * htt_soc_attach_target() - SOC level HTT setup
2413 * @htt_soc: HTT SOC handle
2414 *
2415 * Return: 0 on success; error code on failure
2416 */
2417int htt_soc_attach_target(void *htt_soc)
2418{
2419 struct htt_soc *soc = (struct htt_soc *)htt_soc;
2420
2421 return htt_h2t_ver_req_msg(soc);
2422}
2423
2424
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -07002425#if defined(WDI_EVENT_ENABLE) && !defined(REMOVE_PKT_LOG)
2426/*
2427 * dp_ppdu_stats_ind_handler() - PPDU stats msg handler
2428 * @htt_soc: HTT SOC handle
2429 * @msg_word: Pointer to payload
2430 * @htt_t2h_msg: HTT msg nbuf
2431 *
2432 * Return: None
2433 */
2434static void
2435dp_ppdu_stats_ind_handler(struct htt_soc *soc,
2436 uint32_t *msg_word,
2437 qdf_nbuf_t htt_t2h_msg)
2438{
2439 u_int8_t pdev_id;
2440 qdf_nbuf_set_pktlen(htt_t2h_msg, HTT_T2H_MAX_MSG_SIZE);
2441 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
2442 "received HTT_T2H_MSG_TYPE_PPDU_STATS_IND\n");
2443 pdev_id = HTT_T2H_PPDU_STATS_MAC_ID_GET(*msg_word);
2444 pdev_id = DP_HW2SW_MACID(pdev_id);
2445 dp_txrx_ppdu_stats_handler(soc->dp_soc, pdev_id,
2446 htt_t2h_msg);
2447 dp_wdi_event_handler(WDI_EVENT_LITE_T2H, soc->dp_soc,
2448 htt_t2h_msg, HTT_INVALID_PEER, WDI_NO_VAL,
2449 pdev_id);
2450}
2451#else
2452dp_ppdu_stats_ind_handler(struct htt_soc *soc,
2453 qdf_nbuf_t htt_t2h_msg)
2454{
2455}
2456#endif
2457
2458#if defined(WDI_EVENT_ENABLE) && \
2459 !defined(REMOVE_PKT_LOG) && defined(CONFIG_WIN)
2460/*
2461 * dp_pktlog_msg_handler() - Pktlog msg handler
2462 * @htt_soc: HTT SOC handle
2463 * @msg_word: Pointer to payload
2464 *
2465 * Return: None
2466 */
2467static void
2468dp_pktlog_msg_handler(struct htt_soc *soc,
2469 uint32_t *msg_word)
2470{
2471 uint8_t pdev_id;
2472 uint32_t *pl_hdr;
2473 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
2474 "received HTT_T2H_MSG_TYPE_PKTLOG\n");
2475 pdev_id = HTT_T2H_PKTLOG_MAC_ID_GET(*msg_word);
2476 pdev_id = DP_HW2SW_MACID(pdev_id);
2477 pl_hdr = (msg_word + 1);
2478 dp_wdi_event_handler(WDI_EVENT_OFFLOAD_ALL, soc->dp_soc,
2479 pl_hdr, HTT_INVALID_PEER, WDI_NO_VAL,
2480 pdev_id);
2481}
2482#else
2483static void
2484dp_pktlog_msg_handler(struct htt_soc *soc,
2485 uint32_t *msg_word)
2486{
2487}
2488#endif
2489
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07002490/*
2491 * dp_htt_t2h_msg_handler() - Generic Target to host Msg/event handler
2492 * @context: Opaque context (HTT SOC handle)
2493 * @pkt: HTC packet
2494 */
2495static void dp_htt_t2h_msg_handler(void *context, HTC_PACKET *pkt)
2496{
2497 struct htt_soc *soc = (struct htt_soc *) context;
2498 qdf_nbuf_t htt_t2h_msg = (qdf_nbuf_t) pkt->pPktContext;
2499 u_int32_t *msg_word;
2500 enum htt_t2h_msg_type msg_type;
2501
2502 /* check for successful message reception */
Rakesh Pillai13146452017-06-22 12:52:31 +05302503 if (pkt->Status != QDF_STATUS_SUCCESS) {
2504 if (pkt->Status != QDF_STATUS_E_CANCELED)
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07002505 soc->stats.htc_err_cnt++;
2506
2507 qdf_nbuf_free(htt_t2h_msg);
2508 return;
2509 }
2510
2511 /* TODO: Check if we should pop the HTC/HTT header alignment padding */
2512
2513 msg_word = (u_int32_t *) qdf_nbuf_data(htt_t2h_msg);
2514 msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
2515 switch (msg_type) {
2516 case HTT_T2H_MSG_TYPE_PEER_MAP:
2517 {
2518 u_int8_t mac_addr_deswizzle_buf[HTT_MAC_ADDR_LEN];
2519 u_int8_t *peer_mac_addr;
2520 u_int16_t peer_id;
Tallapragada Kalyan6f6166e2017-02-17 17:00:23 +05302521 u_int16_t hw_peer_id;
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07002522 u_int8_t vdev_id;
2523
2524 peer_id = HTT_RX_PEER_MAP_PEER_ID_GET(*msg_word);
Tallapragada Kalyan6f6166e2017-02-17 17:00:23 +05302525 hw_peer_id =
2526 HTT_RX_PEER_MAP_HW_PEER_ID_GET(*(msg_word+2));
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07002527 vdev_id = HTT_RX_PEER_MAP_VDEV_ID_GET(*msg_word);
2528 peer_mac_addr = htt_t2h_mac_addr_deswizzle(
2529 (u_int8_t *) (msg_word+1),
2530 &mac_addr_deswizzle_buf[0]);
Pramod Simhab17d0672017-03-06 17:20:13 -08002531 QDF_TRACE(QDF_MODULE_ID_TXRX,
2532 QDF_TRACE_LEVEL_INFO,
2533 "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
2534 peer_id, vdev_id);
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07002535
Tallapragada Kalyan6f6166e2017-02-17 17:00:23 +05302536 dp_rx_peer_map_handler(soc->dp_soc, peer_id, hw_peer_id,
2537 vdev_id, peer_mac_addr);
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07002538 break;
2539 }
2540 case HTT_T2H_MSG_TYPE_PEER_UNMAP:
2541 {
2542 u_int16_t peer_id;
2543 peer_id = HTT_RX_PEER_UNMAP_PEER_ID_GET(*msg_word);
2544
2545 dp_rx_peer_unmap_handler(soc->dp_soc, peer_id);
2546 break;
2547 }
2548 case HTT_T2H_MSG_TYPE_SEC_IND:
2549 {
2550 u_int16_t peer_id;
2551 enum htt_sec_type sec_type;
2552 int is_unicast;
2553
2554 peer_id = HTT_SEC_IND_PEER_ID_GET(*msg_word);
2555 sec_type = HTT_SEC_IND_SEC_TYPE_GET(*msg_word);
2556 is_unicast = HTT_SEC_IND_UNICAST_GET(*msg_word);
2557 /* point to the first part of the Michael key */
2558 msg_word++;
2559 dp_rx_sec_ind_handler(
2560 soc->dp_soc, peer_id, sec_type, is_unicast,
2561 msg_word, msg_word + 2);
2562 break;
2563 }
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -07002564
Keyur Parekhfad6d082017-05-07 08:54:47 -07002565 case HTT_T2H_MSG_TYPE_PPDU_STATS_IND:
2566 {
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -07002567 dp_ppdu_stats_ind_handler(soc, msg_word, htt_t2h_msg);
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07002568 break;
2569 }
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -07002570
Karunakar Dasineniead27fb2017-09-28 14:28:48 -07002571 case HTT_T2H_MSG_TYPE_PKTLOG:
2572 {
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -07002573 dp_pktlog_msg_handler(soc, msg_word);
Karunakar Dasineniead27fb2017-09-28 14:28:48 -07002574 break;
2575 }
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -07002576
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07002577 case HTT_T2H_MSG_TYPE_VERSION_CONF:
2578 {
Yue Ma245b47b2017-02-21 16:35:31 -08002579 htc_pm_runtime_put(soc->htc_soc);
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07002580 soc->tgt_ver.major = HTT_VER_CONF_MAJOR_GET(*msg_word);
2581 soc->tgt_ver.minor = HTT_VER_CONF_MINOR_GET(*msg_word);
2582 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_HIGH,
2583 "target uses HTT version %d.%d; host uses %d.%d\n",
2584 soc->tgt_ver.major, soc->tgt_ver.minor,
2585 HTT_CURRENT_VERSION_MAJOR,
2586 HTT_CURRENT_VERSION_MINOR);
2587 if (soc->tgt_ver.major != HTT_CURRENT_VERSION_MAJOR) {
2588 QDF_TRACE(QDF_MODULE_ID_TXRX,
2589 QDF_TRACE_LEVEL_ERROR,
2590 "*** Incompatible host/target HTT versions!\n");
2591 }
2592 /* abort if the target is incompatible with the host */
2593 qdf_assert(soc->tgt_ver.major ==
2594 HTT_CURRENT_VERSION_MAJOR);
2595 if (soc->tgt_ver.minor != HTT_CURRENT_VERSION_MINOR) {
2596 QDF_TRACE(QDF_MODULE_ID_TXRX,
2597 QDF_TRACE_LEVEL_WARN,
2598 "*** Warning: host/target HTT versions"
2599 " are different, though compatible!\n");
2600 }
2601 break;
2602 }
Pramod Simhab17d0672017-03-06 17:20:13 -08002603 case HTT_T2H_MSG_TYPE_RX_ADDBA:
2604 {
2605 uint16_t peer_id;
2606 uint8_t tid;
2607 uint8_t win_sz;
2608 uint16_t status;
2609 struct dp_peer *peer;
2610
2611 /*
2612 * Update REO Queue Desc with new values
2613 */
2614 peer_id = HTT_RX_ADDBA_PEER_ID_GET(*msg_word);
2615 tid = HTT_RX_ADDBA_TID_GET(*msg_word);
2616 win_sz = HTT_RX_ADDBA_WIN_SIZE_GET(*msg_word);
2617 peer = dp_peer_find_by_id(soc->dp_soc, peer_id);
2618
Pramod Simha30e81352017-03-27 10:03:31 -07002619 /*
2620 * Window size needs to be incremented by 1
2621 * since fw needs to represent a value of 256
2622 * using just 8 bits
2623 */
Pramod Simhab17d0672017-03-06 17:20:13 -08002624 if (peer) {
2625 status = dp_addba_requestprocess_wifi3(peer,
Pramod Simha30e81352017-03-27 10:03:31 -07002626 0, tid, 0, win_sz + 1, 0xffff);
Pramod Simhab17d0672017-03-06 17:20:13 -08002627 QDF_TRACE(QDF_MODULE_ID_TXRX,
2628 QDF_TRACE_LEVEL_INFO,
2629 FL("PeerID %d BAW %d TID %d stat %d\n"),
2630 peer_id, win_sz, tid, status);
2631
2632 } else {
2633 QDF_TRACE(QDF_MODULE_ID_TXRX,
2634 QDF_TRACE_LEVEL_ERROR,
2635 FL("Peer not found peer id %d\n"),
2636 peer_id);
2637 }
2638 break;
2639 }
Ishank Jain6290a3c2017-03-21 10:49:39 +05302640 case HTT_T2H_MSG_TYPE_EXT_STATS_CONF:
2641 {
2642 dp_txrx_fw_stats_handler(soc->dp_soc, htt_t2h_msg);
2643 break;
2644 }
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07002645 default:
2646 break;
2647 };
2648
2649 /* Free the indication buffer */
2650 qdf_nbuf_free(htt_t2h_msg);
2651}
2652
2653/*
2654 * dp_htt_h2t_full() - Send full handler (called from HTC)
2655 * @context: Opaque context (HTT SOC handle)
2656 * @pkt: HTC packet
2657 *
Manikandan Mohan50ec7042017-04-19 11:37:47 -07002658 * Return: enum htc_send_full_action
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07002659 */
Manikandan Mohan50ec7042017-04-19 11:37:47 -07002660static enum htc_send_full_action
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07002661dp_htt_h2t_full(void *context, HTC_PACKET *pkt)
2662{
2663 return HTC_SEND_FULL_KEEP;
2664}
2665
2666/*
Karunakar Dasineniead27fb2017-09-28 14:28:48 -07002667 * dp_htt_hif_t2h_hp_callback() - HIF callback for high priority T2H messages
2668 * @context: Opaque context (HTT SOC handle)
2669 * @nbuf: nbuf containing T2H message
2670 * @pipe_id: HIF pipe ID
2671 *
2672 * Return: QDF_STATUS
2673 *
2674 * TODO: Temporary change to bypass HTC connection for this new HIF pipe, which
2675 * will be used for packet log and other high-priority HTT messsages. Proper
2676 * HTC connection to be added later once required FW changes are available
2677 */
2678static QDF_STATUS
2679dp_htt_hif_t2h_hp_callback (void *context, qdf_nbuf_t nbuf, uint8_t pipe_id)
2680{
2681 A_STATUS rc = QDF_STATUS_SUCCESS;
2682 HTC_PACKET htc_pkt;
2683
2684 qdf_assert_always(pipe_id == DP_HTT_T2H_HP_PIPE);
2685 qdf_mem_zero(&htc_pkt, sizeof(htc_pkt));
2686 htc_pkt.Status = QDF_STATUS_SUCCESS;
2687 htc_pkt.pPktContext = (void *)nbuf;
2688 dp_htt_t2h_msg_handler(context, &htc_pkt);
2689
2690 return rc;
2691}
2692
2693/*
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07002694 * htt_htc_soc_attach() - Register SOC level HTT instance with HTC
2695 * @htt_soc: HTT SOC handle
2696 *
2697 * Return: 0 on success; error code on failure
2698 */
2699static int
2700htt_htc_soc_attach(struct htt_soc *soc)
2701{
Manikandan Mohan50ec7042017-04-19 11:37:47 -07002702 struct htc_service_connect_req connect;
2703 struct htc_service_connect_resp response;
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07002704 A_STATUS status;
2705
2706 qdf_mem_set(&connect, sizeof(connect), 0);
2707 qdf_mem_set(&response, sizeof(response), 0);
2708
2709 connect.pMetaData = NULL;
2710 connect.MetaDataLength = 0;
2711 connect.EpCallbacks.pContext = soc;
2712 connect.EpCallbacks.EpTxComplete = dp_htt_h2t_send_complete;
2713 connect.EpCallbacks.EpTxCompleteMultiple = NULL;
2714 connect.EpCallbacks.EpRecv = dp_htt_t2h_msg_handler;
2715
2716 /* rx buffers currently are provided by HIF, not by EpRecvRefill */
2717 connect.EpCallbacks.EpRecvRefill = NULL;
2718
2719 /* N/A, fill is done by HIF */
2720 connect.EpCallbacks.RecvRefillWaterMark = 1;
2721
2722 connect.EpCallbacks.EpSendFull = dp_htt_h2t_full;
2723 /*
2724 * Specify how deep to let a queue get before htc_send_pkt will
2725 * call the EpSendFull function due to excessive send queue depth.
2726 */
2727 connect.MaxSendQueueDepth = DP_HTT_MAX_SEND_QUEUE_DEPTH;
2728
2729 /* disable flow control for HTT data message service */
2730 connect.ConnectionFlags |= HTC_CONNECT_FLAGS_DISABLE_CREDIT_FLOW_CTRL;
2731
2732 /* connect to control service */
2733 connect.service_id = HTT_DATA_MSG_SVC;
2734
2735 status = htc_connect_service(soc->htc_soc, &connect, &response);
2736
2737 if (status != A_OK)
2738 return QDF_STATUS_E_FAILURE;
2739
2740 soc->htc_endpoint = response.Endpoint;
2741
Karunakar Dasineniead27fb2017-09-28 14:28:48 -07002742 dp_hif_update_pipe_callback(soc->dp_soc, (void *)soc,
2743 dp_htt_hif_t2h_hp_callback, DP_HTT_T2H_HP_PIPE);
2744
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07002745 return 0; /* success */
2746}
2747
2748/*
2749 * htt_soc_attach() - SOC level HTT initialization
2750 * @dp_soc: Opaque Data path SOC handle
2751 * @osif_soc: Opaque OSIF SOC handle
2752 * @htc_soc: SOC level HTC handle
2753 * @hal_soc: Opaque HAL SOC handle
2754 * @osdev: QDF device
2755 *
2756 * Return: HTT handle on success; NULL on failure
2757 */
2758void *
2759htt_soc_attach(void *dp_soc, void *osif_soc, HTC_HANDLE htc_soc,
2760 void *hal_soc, qdf_device_t osdev)
2761{
2762 struct htt_soc *soc;
2763 int i;
2764
2765 soc = qdf_mem_malloc(sizeof(*soc));
2766
2767 if (!soc)
2768 goto fail1;
2769
2770 soc->osdev = osdev;
2771 soc->osif_soc = osif_soc;
2772 soc->dp_soc = dp_soc;
2773 soc->htc_soc = htc_soc;
2774 soc->hal_soc = hal_soc;
2775
2776 /* TODO: See if any NSS related context is requred in htt_soc */
2777
2778 soc->htt_htc_pkt_freelist = NULL;
2779
2780 if (htt_htc_soc_attach(soc))
2781 goto fail2;
2782
2783 /* TODO: See if any Rx data specific intialization is required. For
2784 * MCL use cases, the data will be received as single packet and
2785 * should not required any descriptor or reorder handling
2786 */
2787
2788 HTT_TX_MUTEX_INIT(&soc->htt_tx_mutex);
2789
2790 /* pre-allocate some HTC_PACKET objects */
2791 for (i = 0; i < HTT_HTC_PKT_POOL_INIT_SIZE; i++) {
2792 struct dp_htt_htc_pkt_union *pkt;
2793 pkt = qdf_mem_malloc(sizeof(*pkt));
2794 if (!pkt)
2795 break;
2796
2797 htt_htc_pkt_free(soc, &pkt->u.pkt);
2798 }
2799
2800 return soc;
2801
2802fail2:
2803 qdf_mem_free(soc);
2804
2805fail1:
2806 return NULL;
2807}
2808
2809
2810/*
2811 * htt_soc_detach() - Detach SOC level HTT
2812 * @htt_soc: HTT SOC handle
2813 */
2814void
2815htt_soc_detach(void *htt_soc)
2816{
Kiran Venkatappa3ec0b302016-12-20 11:30:46 +05302817 struct htt_soc *soc = (struct htt_soc *)htt_soc;
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07002818
Pramod Simhae0baa442017-06-27 15:21:39 -07002819 htt_htc_misc_pkt_pool_free(soc);
Karunakar Dasineni9b814ce2016-09-01 15:00:09 -07002820 htt_htc_pkt_pool_free(soc);
2821 HTT_TX_MUTEX_DESTROY(&soc->htt_tx_mutex);
2822 qdf_mem_free(soc);
2823}
2824
Ishank Jain6290a3c2017-03-21 10:49:39 +05302825/**
2826 * dp_h2t_ext_stats_msg_send(): function to contruct HTT message to pass to FW
2827 * @pdev: DP PDEV handle
2828 * @stats_type_upload_mask: stats type requested by user
2829 * @config_param_0: extra configuration parameters
2830 * @config_param_1: extra configuration parameters
2831 * @config_param_2: extra configuration parameters
2832 * @config_param_3: extra configuration parameters
2833 *
2834 * return: QDF STATUS
2835 */
2836QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
2837 uint32_t stats_type_upload_mask, uint32_t config_param_0,
2838 uint32_t config_param_1, uint32_t config_param_2,
Chaithanya Garrepalli30927c52017-11-22 14:31:47 +05302839 uint32_t config_param_3, int cookie_val)
Ishank Jain6290a3c2017-03-21 10:49:39 +05302840{
2841 struct htt_soc *soc = pdev->soc->htt_handle;
2842 struct dp_htt_htc_pkt *pkt;
2843 qdf_nbuf_t msg;
2844 uint32_t *msg_word;
2845 uint8_t pdev_mask;
2846
2847 msg = qdf_nbuf_alloc(
2848 soc->osdev,
2849 HTT_MSG_BUF_SIZE(HTT_H2T_EXT_STATS_REQ_MSG_SZ),
2850 HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
2851
2852 if (!msg)
2853 return QDF_STATUS_E_NOMEM;
2854
2855 /*TODO:Add support for SOC stats
2856 * Bit 0: SOC Stats
2857 * Bit 1: Pdev stats for pdev id 0
2858 * Bit 2: Pdev stats for pdev id 1
2859 * Bit 3: Pdev stats for pdev id 2
2860 */
2861 pdev_mask = 1 << (pdev->pdev_id + 1);
2862
2863 /*
2864 * Set the length of the message.
2865 * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
2866 * separately during the below call to qdf_nbuf_push_head.
2867 * The contribution from the HTC header is added separately inside HTC.
2868 */
2869 if (qdf_nbuf_put_tail(msg, HTT_H2T_EXT_STATS_REQ_MSG_SZ) == NULL) {
2870 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
2871 "Failed to expand head for HTT_EXT_STATS");
2872 qdf_nbuf_free(msg);
2873 return QDF_STATUS_E_FAILURE;
2874 }
2875
Chaithanya Garrepalli30927c52017-11-22 14:31:47 +05302876 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
2877 "-----%s:%d----\n cookie <-> %d\n config_param_0 %u\n"
2878 "config_param_1 %u\n config_param_2 %u\n"
2879 "config_param_4 %u\n -------------\n",
2880 __func__, __LINE__, cookie_val, config_param_0,
2881 config_param_1, config_param_2, config_param_3);
2882
Ishank Jain6290a3c2017-03-21 10:49:39 +05302883 msg_word = (uint32_t *) qdf_nbuf_data(msg);
2884
2885 qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
2886 *msg_word = 0;
2887 HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_EXT_STATS_REQ);
2888 HTT_H2T_EXT_STATS_REQ_PDEV_MASK_SET(*msg_word, pdev_mask);
2889 HTT_H2T_EXT_STATS_REQ_STATS_TYPE_SET(*msg_word, stats_type_upload_mask);
2890
2891 /* word 1 */
2892 msg_word++;
2893 *msg_word = 0;
2894 HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_0);
2895
2896 /* word 2 */
2897 msg_word++;
2898 *msg_word = 0;
2899 HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_1);
2900
2901 /* word 3 */
2902 msg_word++;
2903 *msg_word = 0;
2904 HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_2);
2905
2906 /* word 4 */
2907 msg_word++;
2908 *msg_word = 0;
2909 HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_3);
2910
2911 HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, 0);
Chaithanya Garrepalli30927c52017-11-22 14:31:47 +05302912
2913 /* word 5 */
2914 msg_word++;
2915
2916 /* word 6 */
2917 msg_word++;
2918 *msg_word = 0;
2919 HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_val);
2920
2921 /* word 7 */
2922 msg_word++;
2923 *msg_word = 0;
2924 HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, pdev->pdev_id);
2925
Ishank Jain6290a3c2017-03-21 10:49:39 +05302926 pkt = htt_htc_pkt_alloc(soc);
2927 if (!pkt) {
2928 qdf_nbuf_free(msg);
2929 return QDF_STATUS_E_NOMEM;
2930 }
2931
2932 pkt->soc_ctxt = NULL; /* not used during send-done callback */
2933
2934 SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
2935 dp_htt_h2t_send_complete_free_netbuf,
2936 qdf_nbuf_data(msg), qdf_nbuf_len(msg),
2937 soc->htc_endpoint,
2938 1); /* tag - not relevant here */
2939
2940 SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
Pramod Simhae0baa442017-06-27 15:21:39 -07002941 DP_HTT_SEND_HTC_PKT(soc, pkt);
2942 return 0;
Ishank Jain6290a3c2017-03-21 10:49:39 +05302943}
Keyur Parekhdb0fa142017-07-13 19:40:22 -07002944
2945/* This macro will revert once proper HTT header will define for
2946 * HTT_H2T_MSG_TYPE_PPDU_STATS_CFG in htt.h file
2947 * */
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -07002948#if defined(WDI_EVENT_ENABLE)
Keyur Parekhdb0fa142017-07-13 19:40:22 -07002949/**
2950 * dp_h2t_cfg_stats_msg_send(): function to construct HTT message to pass to FW
2951 * @pdev: DP PDEV handle
2952 * @stats_type_upload_mask: stats type requested by user
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -07002953 * @mac_id: Mac id number
Keyur Parekhdb0fa142017-07-13 19:40:22 -07002954 *
2955 * return: QDF STATUS
2956 */
2957QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -07002958 uint32_t stats_type_upload_mask, uint8_t mac_id)
Keyur Parekhdb0fa142017-07-13 19:40:22 -07002959{
2960 struct htt_soc *soc = pdev->soc->htt_handle;
2961 struct dp_htt_htc_pkt *pkt;
2962 qdf_nbuf_t msg;
2963 uint32_t *msg_word;
2964 uint8_t pdev_mask;
2965
2966 msg = qdf_nbuf_alloc(
2967 soc->osdev,
2968 HTT_MSG_BUF_SIZE(HTT_H2T_PPDU_STATS_CFG_MSG_SZ),
2969 HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
2970
2971 if (!msg) {
2972 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
2973 "Fail to allocate HTT_H2T_PPDU_STATS_CFG_MSG_SZ msg buffer\n");
2974 qdf_assert(0);
2975 return QDF_STATUS_E_NOMEM;
2976 }
2977
2978 /*TODO:Add support for SOC stats
2979 * Bit 0: SOC Stats
2980 * Bit 1: Pdev stats for pdev id 0
2981 * Bit 2: Pdev stats for pdev id 1
2982 * Bit 3: Pdev stats for pdev id 2
2983 */
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -07002984 pdev_mask = 1 << DP_SW2HW_MACID(mac_id);
Keyur Parekhdb0fa142017-07-13 19:40:22 -07002985
2986 /*
2987 * Set the length of the message.
2988 * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
2989 * separately during the below call to qdf_nbuf_push_head.
2990 * The contribution from the HTC header is added separately inside HTC.
2991 */
2992 if (qdf_nbuf_put_tail(msg, HTT_H2T_PPDU_STATS_CFG_MSG_SZ) == NULL) {
2993 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
2994 "Failed to expand head for HTT_CFG_STATS\n");
2995 qdf_nbuf_free(msg);
2996 return QDF_STATUS_E_FAILURE;
2997 }
2998
2999 msg_word = (uint32_t *) qdf_nbuf_data(msg);
3000
3001 qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
3002 *msg_word = 0;
3003 HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG);
3004 HTT_H2T_PPDU_STATS_CFG_PDEV_MASK_SET(*msg_word, pdev_mask);
3005 HTT_H2T_PPDU_STATS_CFG_TLV_BITMASK_SET(*msg_word,
3006 stats_type_upload_mask);
3007
3008 pkt = htt_htc_pkt_alloc(soc);
3009 if (!pkt) {
3010 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
3011 "Fail to allocate dp_htt_htc_pkt buffer\n");
3012 qdf_assert(0);
3013 qdf_nbuf_free(msg);
3014 return QDF_STATUS_E_NOMEM;
3015 }
3016
3017 pkt->soc_ctxt = NULL; /* not used during send-done callback */
3018
3019 SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
3020 dp_htt_h2t_send_complete_free_netbuf,
3021 qdf_nbuf_data(msg), qdf_nbuf_len(msg),
3022 soc->htc_endpoint,
3023 1); /* tag - not relevant here */
3024
3025 SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
3026 DP_HTT_SEND_HTC_PKT(soc, pkt);
3027 return 0;
3028}
3029#endif