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