blob: ee5b4abb402a7ffa3aa1db2dfbc73ccb3eff9b27 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Nirav Shahc657ef52016-07-26 14:22:38 +05302 * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28#ifndef REMOVE_PKT_LOG
29#ifndef _PKTLOG_FMT_H_
30#define _PKTLOG_FMT_H_
31
32#define CUR_PKTLOG_VER 10010 /* Packet log version */
33#define PKTLOG_MAGIC_NUM 7735225
34
35#ifdef __linux__
Samuel Ahnc9c48ca2016-09-19 15:46:36 +053036#ifdef MULTI_IF_NAME
37#define PKTLOG_PROC_DIR "ath_pktlog" MULTI_IF_NAME
38#define WLANDEV_BASENAME "cld" MULTI_IF_NAME
39#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080040#define PKTLOG_PROC_DIR "ath_pktlog"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080041#define WLANDEV_BASENAME "cld"
42#endif
Samuel Ahnc9c48ca2016-09-19 15:46:36 +053043#endif
44#define PKTLOG_PROC_SYSTEM "system"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045#ifdef WIN32
46#pragma pack(push, pktlog_fmt, 1)
47#define __ATTRIB_PACK
48#elif defined(__EFI__)
49#define __ATTRIB_PACK
50#else
51#ifndef __ATTRIB_PACK
52#define __ATTRIB_PACK __attribute__ ((packed))
53#endif
54#endif
55#include <a_types.h>
56/*
57 * Each packet log entry consists of the following fixed length header
58 * followed by variable length log information determined by log_type
59 */
60
61struct ath_pktlog_hdr {
62 uint16_t flags;
63 uint16_t missed_cnt;
Nirav Shahc657ef52016-07-26 14:22:38 +053064#ifdef HELIUMPLUS
65 uint8_t log_type;
66 uint8_t macId;
67#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068 uint16_t log_type;
Nirav Shahc657ef52016-07-26 14:22:38 +053069#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070 uint16_t size;
71 uint32_t timestamp;
72#ifdef HELIUMPLUS
73 uint32_t type_specific_data;
74#endif
75} __ATTRIB_PACK;
76
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053077/**
78 * enum pkt_type - packet type
79 * @START_MONITOR: indicates parser to start packetdump parsing
80 * @STOP_MONITOR: indicates parser to stop packetdump parsing
81 * @TX_MGMT_PKT: TX management Packet
82 * @TX_DATA_PKT: TX data Packet
83 * @RX_MGMT_PKT: RX management Packet
84 * @RX_DATA_PKT: RX data Packet
85 *
86 * This enum has packet types
87 */
88enum pkt_type {
89 START_MONITOR = 1,
90 STOP_MONITOR,
91 TX_MGMT_PKT,
92 TX_DATA_PKT,
93 RX_MGMT_PKT,
94 RX_DATA_PKT,
95};
96
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080097#define ATH_PKTLOG_HDR_FLAGS_MASK 0xffff
98#define ATH_PKTLOG_HDR_FLAGS_SHIFT 0
99#define ATH_PKTLOG_HDR_FLAGS_OFFSET 0
100#define ATH_PKTLOG_HDR_MISSED_CNT_MASK 0xffff0000
101#define ATH_PKTLOG_HDR_MISSED_CNT_SHIFT 16
102#define ATH_PKTLOG_HDR_MISSED_CNT_OFFSET 0
Nirav Shahc657ef52016-07-26 14:22:38 +0530103#ifdef HELIUMPLUS
104#define ATH_PKTLOG_HDR_LOG_TYPE_MASK 0x00ff
105#define ATH_PKTLOG_HDR_LOG_TYPE_SHIFT 0
106#define ATH_PKTLOG_HDR_LOG_TYPE_OFFSET 1
107#define ATH_PKTLOG_HDR_MAC_ID_MASK 0xff00
108#define ATH_PKTLOG_HDR_MAC_ID_SHIFT 8
109#define ATH_PKTLOG_HDR_MAC_ID_OFFSET 1
110#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111#define ATH_PKTLOG_HDR_LOG_TYPE_MASK 0xffff
112#define ATH_PKTLOG_HDR_LOG_TYPE_SHIFT 0
113#define ATH_PKTLOG_HDR_LOG_TYPE_OFFSET 1
Nirav Shahc657ef52016-07-26 14:22:38 +0530114#endif
115
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800116#define ATH_PKTLOG_HDR_SIZE_MASK 0xffff0000
117#define ATH_PKTLOG_HDR_SIZE_SHIFT 16
118#define ATH_PKTLOG_HDR_SIZE_OFFSET 1
119#define ATH_PKTLOG_HDR_TIMESTAMP_OFFSET 2
120#define ATH_PKTLOG_HDR_TYPE_SPECIFIC_DATA_OFFSET 3
121
122/**
123 * enum - Pktlog flag field details
124 * packet origin [1:0]
125 * 00 - Local
126 * 01 - Remote
127 * 10 - Unknown/Not applicable
128 * 11 - Reserved
129 * reserved [15:2]
130 */
131enum {
132 PKTLOG_FLG_FRM_TYPE_LOCAL_S = 0,
133 PKTLOG_FLG_FRM_TYPE_REMOTE_S,
134 PKTLOG_FLG_FRM_TYPE_CLONE_S,
135 PKTLOG_FLG_FRM_TYPE_CBF_S,
136 PKTLOG_FLG_FRM_TYPE_UNKNOWN_S
137};
138
139#define PHFLAGS_INTERRUPT_CONTEXT 0x80000000
140
141/* Masks for setting pktlog events filters */
142#define ATH_PKTLOG_TX 0x000000001
143#define ATH_PKTLOG_RX 0x000000002
144#define ATH_PKTLOG_RCFIND 0x000000004
145#define ATH_PKTLOG_RCUPDATE 0x000000008
146#define ATH_PKTLOG_ANI 0x000000010
147#define ATH_PKTLOG_TEXT 0x000000020
148#define ATH_PKTLOG_PHYERR 0x000000040
149#define ATH_PKTLOG_PROMISC 0x000000080
Nirav Shahdcc4c872016-07-28 11:35:26 +0530150#define ATH_PKTLOG_SW_EVENT 0x000000100
151
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152
153/* Types of packet log events */
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +0530154#define PKTLOG_TYPE_TX_CTRL 1
155#define PKTLOG_TYPE_TX_STAT 2
156#define PKTLOG_TYPE_TX_MSDU_ID 3
157#define PKTLOG_TYPE_TX_FRM_HDR 4
158#define PKTLOG_TYPE_RX_STAT 5
159#define PKTLOG_TYPE_RC_FIND 6
160#define PKTLOG_TYPE_RC_UPDATE 7
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800161#define PKTLOG_TYPE_TX_VIRT_ADDR 8
Nirav Shahdcc4c872016-07-28 11:35:26 +0530162#define PKTLOG_TYPE_SMART_ANTENNA 9
163#define PKTLOG_TYPE_SW_EVENT 10
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +0530164#define PKTLOG_TYPE_PKT_DUMP 11
165#define PKTLOG_TYPE_MAX 12
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166
167#define PKTLOG_MAX_TXCTL_WORDS 57 /* +2 words for bitmap */
168#define PKTLOG_MAX_TXSTATUS_WORDS 32
169#define PKTLOG_MAX_PROTO_WORDS 16
170#define PKTLOG_MAX_RXDESC_WORDS 62
Himanshu Agarwal6e224f62016-12-05 18:27:35 +0530171#define PKTLOG_HDR_SIZE_16 0x8000
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172
173struct txctl_frm_hdr {
174 uint16_t framectrl; /* frame control field from header */
175 uint16_t seqctrl; /* frame control field from header */
176 uint16_t bssid_tail; /* last two octets of bssid */
177 uint16_t sa_tail; /* last two octets of SA */
178 uint16_t da_tail; /* last two octets of DA */
179 uint16_t resvd;
180};
181
182#if defined(HELIUMPLUS)
183/* Peregrine 11ac based */
184#define MAX_PKT_INFO_MSDU_ID 1
185#else
186/* Peregrine 11ac based */
187#define MAX_PKT_INFO_MSDU_ID 192
188#endif /* defined(HELIUMPLUS) */
189
190/*
191 * msdu_id_info_t is defined for reference only
192 */
193struct msdu_id_info {
194 uint32_t num_msdu;
195 uint8_t bound_bmap[(MAX_PKT_INFO_MSDU_ID + 7)>>3];
196 /* TODO:
197 * Convert the id's to uint32_t
198 * Reduces computation in the driver code
199 */
200 uint16_t id[MAX_PKT_INFO_MSDU_ID];
201} __ATTRIB_PACK;
202#define MSDU_ID_INFO_NUM_MSDU_OFFSET 0 /* char offset */
203#define MSDU_ID_INFO_BOUND_BM_OFFSET offsetof(struct msdu_id_info, bound_bmap)
204#define MSDU_ID_INFO_ID_OFFSET offsetof(struct msdu_id_info, id)
205
206
207struct ath_pktlog_txctl {
208 struct ath_pktlog_hdr pl_hdr;
209 /* struct txctl_frm_hdr frm_hdr; */
210 void *txdesc_hdr_ctl; /* frm_hdr + Tx descriptor words */
211 struct {
212 struct txctl_frm_hdr frm_hdr;
213 uint32_t txdesc_ctl[PKTLOG_MAX_TXCTL_WORDS];
214 /* uint32_t *proto_hdr; / * protocol header (variable length!) * / */
215 /* uint32_t *misc; / * Can be used for HT specific or other misc info * / */
216 } priv;
217} __ATTRIB_PACK;
218
219struct ath_pktlog_tx_status {
220 struct ath_pktlog_hdr pl_hdr;
221 void *ds_status;
222 int32_t misc[0]; /* Can be used for HT specific or other misc info */
223} __ATTRIB_PACK;
224
225struct ath_pktlog_msdu_info {
226 struct ath_pktlog_hdr pl_hdr;
227 void *ath_msdu_info;
228 A_UINT32 num_msdu;
229 struct {
230 /*
231 * Provision to add more information fields
232 */
233 struct msdu_info_t {
234 A_UINT32 num_msdu;
235 A_UINT8 bound_bmap[MAX_PKT_INFO_MSDU_ID >> 3];
236 } msdu_id_info;
237 /*
238 * array of num_msdu
239 * Static implementation will consume unwanted memory
240 * Need to split the pktlog_get_buf to get the buffer pointer only
241 */
242 uint16_t msdu_len[MAX_PKT_INFO_MSDU_ID];
243 } priv;
244 size_t priv_size;
245
246} __ATTRIB_PACK;
247
248struct ath_pktlog_rx_info {
249 struct ath_pktlog_hdr pl_hdr;
250 void *rx_desc;
251} __ATTRIB_PACK;
252
253struct ath_pktlog_rc_find {
254 struct ath_pktlog_hdr pl_hdr;
255 void *rcFind;
256} __ATTRIB_PACK;
257
Nirav Shahdcc4c872016-07-28 11:35:26 +0530258struct ath_pktlog_sw_event {
259 struct ath_pktlog_hdr pl_hdr;
260 void *sw_event;
261} __ATTRIB_PACK;
262
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800263struct ath_pktlog_rc_update {
264 struct ath_pktlog_hdr pl_hdr;
265 void *txRateCtrl; /* rate control state proper */
266} __ATTRIB_PACK;
267
268#ifdef WIN32
269#pragma pack(pop, pktlog_fmt)
270#endif
271#ifdef __ATTRIB_PACK
272#undef __ATTRIB_PACK
273#endif /* __ATTRIB_PACK */
274
275/*
276 * The following header is included in the beginning of the file,
277 * followed by log entries when the log buffer is read through procfs
278 */
279
280struct ath_pktlog_bufhdr {
281 uint32_t magic_num; /* Used by post processing scripts */
282 uint32_t version; /* Set to CUR_PKTLOG_VER */
283};
284
285struct ath_pktlog_buf {
286 struct ath_pktlog_bufhdr bufhdr;
287 int32_t rd_offset;
288 volatile int32_t wr_offset;
289 /* Whenever this bytes written value croses 4K bytes,
290 * logging will be triggered
291 */
292 int32_t bytes_written;
293 /* Index of the messages sent to userspace */
294 uint32_t msg_index;
295 /* Offset for read */
296 loff_t offset;
297 char log_data[0];
298};
299
300#define PKTLOG_MOV_RD_IDX(_rd_offset, _log_buf, _log_size) \
301 do { \
302 if((_rd_offset + sizeof(struct ath_pktlog_hdr) + \
303 ((struct ath_pktlog_hdr *)((_log_buf)->log_data + \
304 (_rd_offset)))->size) <= _log_size) { \
305 _rd_offset = ((_rd_offset) + sizeof(struct ath_pktlog_hdr) + \
306 ((struct ath_pktlog_hdr *)((_log_buf)->log_data + \
307 (_rd_offset)))->size); \
308 } else { \
309 _rd_offset = ((struct ath_pktlog_hdr *)((_log_buf)->log_data + \
310 (_rd_offset)))->size; \
311 } \
312 (_rd_offset) = (((_log_size) - (_rd_offset)) >= \
313 sizeof(struct ath_pktlog_hdr)) ? _rd_offset : 0; \
314 } while(0)
315
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +0530316/**
317 * enum tx_pkt_fate - tx packet fate
318 * @TX_PKT_FATE_ACKED: Sent over air and ACKed
319 * @TX_PKT_FATE_SENT: Sent over air but not ACKed.
320 * @TX_PKT_FATE_FW_QUEUED: Queued within firmware,
321 * but not yet sent over air
322 * @TX_PKT_FATE_FW_DROP_INVALID: Dropped by firmware as invalid.
323 * E.g. bad source address, bad checksum, or invalid for current state.
324 * @TX_PKT_FATE_FW_DROP_NOBUFS: Dropped by firmware due
325 * to lack of buffer space
326 * @TX_PKT_FATE_FW_DROP_OTHER: Dropped by firmware for any other
327 * reason. Includes frames that were sent by driver to firmware, but
328 * unaccounted for by firmware.
329 * @TX_PKT_FATE_DRV_QUEUED: Queued within driver, not yet sent to firmware.
330 * @TX_PKT_FATE_DRV_DROP_INVALID: Dropped by driver as invalid.
331 * E.g. bad source address, or invalid for current state.
332 * @TX_PKT_FATE_DRV_DROP_NOBUFS: Dropped by driver due to lack of buffer space
333 * @TX_PKT_FATE_DRV_DROP_OTHER: Dropped by driver for any other reason.
334 * E.g. out of buffers.
335 *
336 * This enum has packet fate types
337 */
338
339enum tx_pkt_fate {
340 TX_PKT_FATE_ACKED,
341 TX_PKT_FATE_SENT,
342 TX_PKT_FATE_FW_QUEUED,
343 TX_PKT_FATE_FW_DROP_INVALID,
344 TX_PKT_FATE_FW_DROP_NOBUFS,
345 TX_PKT_FATE_FW_DROP_OTHER,
346 TX_PKT_FATE_DRV_QUEUED,
347 TX_PKT_FATE_DRV_DROP_INVALID,
348 TX_PKT_FATE_DRV_DROP_NOBUFS,
349 TX_PKT_FATE_DRV_DROP_OTHER,
350};
351
352/**
353 * enum rx_pkt_fate - rx packet fate
354 * @RX_PKT_FATE_SUCCESS: Valid and delivered to
355 * network stack (e.g., netif_rx()).
356 * @RX_PKT_FATE_FW_QUEUED: Queued within firmware,
357 * but not yet sent to driver.
358 * @RX_PKT_FATE_FW_DROP_FILTER: Dropped by firmware
359 * due to host-programmable filters.
360 * @RX_PKT_FATE_FW_DROP_INVALID: Dropped by firmware
361 * as invalid. E.g. bad checksum, decrypt failed, or invalid for current state.
362 * @RX_PKT_FATE_FW_DROP_NOBUFS: Dropped by firmware
363 * due to lack of buffer space.
364 * @RX_PKT_FATE_FW_DROP_OTHER: Dropped by firmware
365 * for any other reason.
366 * @RX_PKT_FATE_DRV_QUEUED: Queued within driver,
367 * not yet delivered to network stack.
368 * @RX_PKT_FATE_DRV_DROP_FILTER: Dropped by driver
369 * due to filter rules.
370 * @RX_PKT_FATE_DRV_DROP_INVALID: Dropped by driver as invalid.
371 * E.g. not permitted in current state.
372 * @RX_PKT_FATE_DRV_DROP_NOBUFS: Dropped by driver
373 * due to lack of buffer space.
374 * @RX_PKT_FATE_DRV_DROP_OTHER: Dropped by driver for any other reason.
375 *
376 * This enum has packet fate types
377 */
378
379enum rx_pkt_fate {
380 RX_PKT_FATE_SUCCESS,
381 RX_PKT_FATE_FW_QUEUED,
382 RX_PKT_FATE_FW_DROP_FILTER,
383 RX_PKT_FATE_FW_DROP_INVALID,
384 RX_PKT_FATE_FW_DROP_NOBUFS,
385 RX_PKT_FATE_FW_DROP_OTHER,
386 RX_PKT_FATE_DRV_QUEUED,
387 RX_PKT_FATE_DRV_DROP_FILTER,
388 RX_PKT_FATE_DRV_DROP_INVALID,
389 RX_PKT_FATE_DRV_DROP_NOBUFS,
390 RX_PKT_FATE_DRV_DROP_OTHER,
391};
392
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800393#endif /* _PKTLOG_FMT_H_ */
394#endif /* REMOVE_PKT_LOG */