wifi: update bcm driver to 101.10.240 to support android r [1/2]
[GitHub/LineageOS/G12/android_hardware_amlogic_kernel-modules_dhd-driver.git] / bcmdhd.101.10.240.x / dhd_statlog.h
CommitLineData
1b4a7c03
LJ
1/*
2 * DHD debugability: Header file for the Status Information Logging
3 *
4 * Copyright (C) 2020, Broadcom.
5 *
6 * Unless you and Broadcom execute a separate written software license
7 * agreement governing use of this software, this software is licensed to you
8 * under the terms of the GNU General Public License version 2 (the "GPL"),
9 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
10 * following added to such license:
11 *
12 * As a special exception, the copyright holders of this software give you
13 * permission to link this software with independent modules, and to copy and
14 * distribute the resulting executable under terms of your choice, provided that
15 * you also meet, for each linked independent module, the terms and conditions of
16 * the license of that module. An independent module is a module which is not
17 * derived from this software. The special exception does not apply to any
18 * modifications of the software.
19 *
20 *
21 * <<Broadcom-WL-IPTag/Open:>>
22 *
23 * $Id$
24 */
25
26#ifndef __DHD_STATLOG_H_
27#define __DHD_STATLOG_H_
28
29#ifdef DHD_STATUS_LOGGING
30
31/* status element */
32typedef struct stat_elem {
33 uint16 stat; /* store status */
34 uint64 ts; /* local timestamp(ns) */
35 uint64 ts_tz; /* timestamp applied timezone(us) */
36 uint8 ifidx; /* ifidx */
37 uint8 dir; /* direction (TX/RX) */
38 uint8 reason; /* reason code from dongle */
39 uint8 status; /* status code from dongle */
40 uint8 resv[2]; /* reserved for future use */
41} stat_elem_t;
42
43/* status logging info */
44#define DHD_STAT_BDMASK_SIZE 16
45typedef struct dhd_statlog {
46 uint8 *logbuf; /* log buffer */
47 uint32 logbuf_len; /* length of the log buffer */
48 void *ringbuf; /* fixed ring buffer */
49 uint32 bufsize; /* size of ring buffer */
50 void *bdlog_ringbuf; /* fixed ring buffer for bigdata logging */
51 uint32 bdlog_bufsize; /* size of ring buffer for bigdata logging */
52 uint8 bdmask[DHD_STAT_BDMASK_SIZE]; /* bitmask for bigdata */
53} dhd_statlog_t;
54
55/* status query format */
56typedef struct stat_query {
57 uint8 *req_buf; /* request buffer to interested status */
58 uint32 req_buf_len; /* length of the request buffer */
59 uint8 *resp_buf; /* response buffer */
60 uint32 resp_buf_len; /* length of the response buffer */
61 uint32 req_num; /* total number of items to query */
62} stat_query_t;
63
64/* bitmask generation request format */
65typedef struct stat_bdmask_req {
66 uint8 *req_buf; /* request buffer to gernerate bitmask */
67 uint32 req_buf_len; /* length of the request buffer */
68} stat_bdmask_req_t;
69
70typedef void * dhd_statlog_handle_t; /* opaque handle to status log */
71
72/* enums */
73#define ST(x) STATE_## x
74#define STDIR(x) STATE_DIR_## x
75
76/* status direction */
77typedef enum stat_log_dir {
78 STDIR(TX) = 1,
79 STDIR(RX) = 2,
80 STDIR(MAX) = 3
81} stat_dir_t;
82
83/* status definition */
84typedef enum stat_log_stat {
85 ST(INVALID) = 0, /* invalid status */
86 ST(WLAN_POWER_ON) = 1, /* Wi-Fi Power on */
87 ST(WLAN_POWER_OFF) = 2, /* Wi-Fi Power off */
88 ST(ASSOC_START) = 3, /* connect to the AP triggered by upper layer */
89 ST(AUTH_DONE) = 4, /* complete to authenticate with the AP */
90 ST(ASSOC_REQ) = 5, /* send or receive Assoc Req */
91 ST(ASSOC_RESP) = 6, /* send or receive Assoc Resp */
92 ST(ASSOC_DONE) = 7, /* complete to disconnect to the associated AP */
93 ST(DISASSOC_START) = 8, /* disconnect to the associated AP by upper layer */
94 ST(DISASSOC_INT_START) = 9, /* initiate the disassoc by DHD */
95 ST(DISASSOC_DONE) = 10, /* complete to disconnect to the associated AP */
96 ST(DISASSOC) = 11, /* send or receive Disassoc */
97 ST(DEAUTH) = 12, /* send or receive Deauth */
98 ST(LINKDOWN) = 13, /* receive the link down event */
99 ST(REASSOC_START) = 14, /* reassoc the candidate AP */
100 ST(REASSOC_INFORM) = 15, /* inform reassoc completion to upper layer */
101 ST(REASSOC_DONE) = 16, /* complete to reassoc */
102 ST(EAPOL_M1) = 17, /* send or receive the EAPOL M1 */
103 ST(EAPOL_M2) = 18, /* send or receive the EAPOL M2 */
104 ST(EAPOL_M3) = 19, /* send or receive the EAPOL M3 */
105 ST(EAPOL_M4) = 20, /* send or receive the EAPOL M4 */
106 ST(EAPOL_GROUPKEY_M1) = 21, /* send or receive the EAPOL Group key handshake M1 */
107 ST(EAPOL_GROUPKEY_M2) = 22, /* send or receive the EAPOL Group key handshake M2 */
108 ST(EAP_REQ_IDENTITY) = 23, /* send or receive the EAP REQ IDENTITY */
109 ST(EAP_RESP_IDENTITY) = 24, /* send or receive the EAP RESP IDENTITY */
110 ST(EAP_REQ_TLS) = 25, /* send or receive the EAP REQ TLS */
111 ST(EAP_RESP_TLS) = 26, /* send or receive the EAP RESP TLS */
112 ST(EAP_REQ_LEAP) = 27, /* send or receive the EAP REQ LEAP */
113 ST(EAP_RESP_LEAP) = 28, /* send or receive the EAP RESP LEAP */
114 ST(EAP_REQ_TTLS) = 29, /* send or receive the EAP REQ TTLS */
115 ST(EAP_RESP_TTLS) = 30, /* send or receive the EAP RESP TTLS */
116 ST(EAP_REQ_AKA) = 31, /* send or receive the EAP REQ AKA */
117 ST(EAP_RESP_AKA) = 32, /* send or receive the EAP RESP AKA */
118 ST(EAP_REQ_PEAP) = 33, /* send or receive the EAP REQ PEAP */
119 ST(EAP_RESP_PEAP) = 34, /* send or receive the EAP RESP PEAP */
120 ST(EAP_REQ_FAST) = 35, /* send or receive the EAP REQ FAST */
121 ST(EAP_RESP_FAST) = 36, /* send or receive the EAP RESP FAST */
122 ST(EAP_REQ_PSK) = 37, /* send or receive the EAP REQ PSK */
123 ST(EAP_RESP_PSK) = 38, /* send or receive the EAP RESP PSK */
124 ST(EAP_REQ_AKAP) = 39, /* send or receive the EAP REQ AKAP */
125 ST(EAP_RESP_AKAP) = 40, /* send or receive the EAP RESP AKAP */
126 ST(EAP_SUCCESS) = 41, /* send or receive the EAP SUCCESS */
127 ST(EAP_FAILURE) = 42, /* send or receive the EAP FAILURE */
128 ST(EAPOL_START) = 43, /* send or receive the EAPOL-START */
129 ST(WSC_START) = 44, /* send or receive the WSC START */
130 ST(WSC_DONE) = 45, /* send or receive the WSC DONE */
131 ST(WPS_M1) = 46, /* send or receive the WPS M1 */
132 ST(WPS_M2) = 47, /* send or receive the WPS M2 */
133 ST(WPS_M3) = 48, /* send or receive the WPS M3 */
134 ST(WPS_M4) = 49, /* send or receive the WPS M4 */
135 ST(WPS_M5) = 50, /* send or receive the WPS M5 */
136 ST(WPS_M6) = 51, /* send or receive the WPS M6 */
137 ST(WPS_M7) = 52, /* send or receive the WPS M7 */
138 ST(WPS_M8) = 53, /* send or receive the WPS M8 */
139 ST(8021X_OTHER) = 54, /* send or receive the other 8021X frames */
140 ST(INSTALL_KEY) = 55, /* install the key */
141 ST(DELETE_KEY) = 56, /* remove the key */
142 ST(INSTALL_PMKSA) = 57, /* install PMKID information */
143 ST(INSTALL_OKC_PMK) = 58, /* install PMKID information for OKC */
144 ST(DHCP_DISCOVER) = 59, /* send or recv DHCP Discover */
145 ST(DHCP_OFFER) = 60, /* send or recv DHCP Offer */
146 ST(DHCP_REQUEST) = 61, /* send or recv DHCP Request */
147 ST(DHCP_DECLINE) = 62, /* send or recv DHCP Decline */
148 ST(DHCP_ACK) = 63, /* send or recv DHCP ACK */
149 ST(DHCP_NAK) = 64, /* send or recv DHCP NACK */
150 ST(DHCP_RELEASE) = 65, /* send or recv DHCP Release */
151 ST(DHCP_INFORM) = 66, /* send or recv DHCP Inform */
152 ST(ICMP_PING_REQ) = 67, /* send or recv ICMP PING Req */
153 ST(ICMP_PING_RESP) = 68, /* send or recv ICMP PING Resp */
154 ST(ICMP_DEST_UNREACH) = 69, /* send or recv ICMP DEST UNREACH message */
155 ST(ICMP_OTHER) = 70, /* send or recv other ICMP */
156 ST(ARP_REQ) = 71, /* send or recv ARP Req */
157 ST(ARP_RESP) = 72, /* send or recv ARP Resp */
158 ST(DNS_QUERY) = 73, /* send or recv DNS Query */
159 ST(DNS_RESP) = 74, /* send or recv DNS Resp */
160 ST(REASSOC_SUCCESS) = 75, /* reassociation success */
161 ST(REASSOC_FAILURE) = 76, /* reassociation failure */
162 ST(AUTH_TIMEOUT) = 77, /* authentication timeout */
163 ST(AUTH_FAIL) = 78, /* authentication failure */
164 ST(AUTH_NO_ACK) = 79, /* authentication failure due to no ACK */
165 ST(AUTH_OTHERS) = 80, /* authentication failure with other status */
166 ST(ASSOC_TIMEOUT) = 81, /* association timeout */
167 ST(ASSOC_FAIL) = 82, /* association failure */
168 ST(ASSOC_NO_ACK) = 83, /* association failure due to no ACK */
169 ST(ASSOC_ABORT) = 84, /* association abort */
170 ST(ASSOC_UNSOLICITED) = 85, /* association unsolicited */
171 ST(ASSOC_NO_NETWORKS) = 86, /* association failure due to no networks */
172 ST(ASSOC_OTHERS) = 87, /* association failure due to no networks */
173 ST(REASSOC_DONE_OTHERS) = 88, /* complete to reassoc with other reason */
174 ST(MAX) = 89 /* Max Status */
175} stat_log_stat_t;
176
177/* functions */
178extern dhd_statlog_handle_t *dhd_attach_statlog(dhd_pub_t *dhdp, uint32 num_items,
179 uint32 bdlog_num_items, uint32 logbuf_len);
180extern void dhd_detach_statlog(dhd_pub_t *dhdp);
181extern int dhd_statlog_ring_log_data(dhd_pub_t *dhdp, uint16 stat, uint8 ifidx,
182 uint8 dir, bool cond);
183extern int dhd_statlog_ring_log_data_reason(dhd_pub_t *dhdp, uint16 stat,
184 uint8 ifidx, uint8 dir, uint16 reason);
185extern int dhd_statlog_ring_log_ctrl(dhd_pub_t *dhdp, uint16 stat, uint8 ifidx,
186 uint16 reason);
187extern int dhd_statlog_process_event(dhd_pub_t *dhdp, int type, uint8 ifidx,
188 uint16 status, uint16 reason, uint16 flags);
189extern int dhd_statlog_get_latest_info(dhd_pub_t *dhdp, void *reqbuf);
190extern void dhd_statlog_dump_scr(dhd_pub_t *dhdp);
191extern int dhd_statlog_query(dhd_pub_t *dhdp, char *cmd, int total_len);
192extern uint32 dhd_statlog_get_logbuf_len(dhd_pub_t *dhdp);
193extern void *dhd_statlog_get_logbuf(dhd_pub_t *dhdp);
194extern int dhd_statlog_generate_bdmask(dhd_pub_t *dhdp, void *reqbuf);
195#ifdef DHD_LOG_DUMP
196extern int dhd_statlog_write_logdump(dhd_pub_t *dhdp, const void *user_buf,
197 void *fp, uint32 len, unsigned long *pos);
198#endif /* DHD_LOG_DUMP */
199
200/* macros */
201#define MAX_STATLOG_ITEM 512
202#define MAX_STATLOG_REQ_ITEM 32
203#define STATLOG_LOGBUF_LEN (64 * 1024)
204#define DHD_STATLOG_VERSION_V1 0x1
205#define DHD_STATLOG_VERSION DHD_STATLOG_VERSION_V1
206#define DHD_STATLOG_ITEM_SIZE (sizeof(stat_elem_t))
207#define DHD_STATLOG_RING_SIZE(items) ((items) * (DHD_STATLOG_ITEM_SIZE))
208#define DHD_STATLOG_STATSTR_BUF_LEN 32
209#define DHD_STATLOG_TZFMT_BUF_LEN 20
210#define DHD_STATLOG_TZFMT_YYMMDDHHMMSSMS "%02d%02d%02d%02d%02d%02d%04d"
211
212#define DHD_STATLOG_CTRL(dhdp, stat, ifidx, reason) \
213 dhd_statlog_ring_log_ctrl((dhdp), (stat), (ifidx), (reason))
214#define DHD_STATLOG_DATA(dhdp, stat, ifidx, dir, cond) \
215 dhd_statlog_ring_log_data((dhdp), (stat), (ifidx), (dir), (cond))
216#define DHD_STATLOG_DATA_RSN(dhdp, stat, ifidx, dir, reason) \
217 dhd_statlog_ring_log_data_reason((dhdp), (stat), (ifidx), \
218 (dir), (reason))
219
220#endif /* DHD_STATUS_LOGGING */
221#endif /* __DHD_STATLOG_H_ */