1 /*
2  *  Copyright 2008-2024 NXP
3  *
4  *  SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 /*! \file wmstats.h
9  *
10  * \brief Wireless Microcontroller statistics
11  */
12 
13 #ifndef _WMSTATS_H_
14 #define _WMSTATS_H_
15 
16 typedef enum
17 {
18     CONN_STATS,
19     DHCP_STATS,
20     HTTP_CLIENT_STATS,
21     CLOUD_CUMUL_STATS,
22     CLOUD_STATS,
23     HTTPD_STATS,
24     NET_STATS,
25     IP_ADDR,
26     TIME,
27     PROV_TYPE,
28     WD_STATUS,
29 } wm_stat_type_t;
30 
31 /*! Define return values */
32 typedef enum
33 {
34     /** */
35     REASON_ADV_SETTINGS_DONE,
36     /** */
37     REASON_NW_ADD_FAIL,
38     /** */
39     REASON_NW_FAILURE,
40     /** */
41     REASON_SWITCH_TO_PROV,
42     /** */
43     REASON_AUTH_FAILURES,
44     /** */
45     REASON_USER_REBOOT,
46     /** */
47     REASON_CLOUD_WATCHDOG,
48     /** */
49     REASON_CLOUD_FW_UPDATE,
50     /** */
51     REASON_WLAN_FW_UNRESPONSIVE,
52 } wm_reboot_reason_t;
53 
54 struct wm_stats
55 {
56     unsigned short wm_lloss;
57     /** The number of connection attempts.
58      * wm_conn_att == wm_conn_succ + wm_conn_fail
59      */
60     unsigned short wm_conn_att;
61     /** The connection success indicates successful association+authentication
62         attempt. This does NOT include the address configuration step */
63     unsigned short wm_conn_succ;
64     /** This should be split up into multiple types of failures
65      * wm_conn_fail = wm_auth_fail + wm_nwnt_found + others
66      */
67     unsigned short wm_conn_fail;
68     unsigned short wm_auth_fail;
69     unsigned short wm_nwnt_found;
70     /** DHCP Address assignment */
71     unsigned short wm_dhcp_succ;
72     unsigned short wm_dhcp_fail;
73     /** DHCP Lease renewal */
74     unsigned short wm_leas_succ;
75     unsigned short wm_leas_fail;
76     /** 1 if DHCP */
77     char wm_addr_type;
78     unsigned int wm_dhcp_req_cnt;
79     /** HTTP Client */
80     unsigned short wm_ht_dns_fail;
81     unsigned short wm_ht_sock_fail;
82     unsigned short wm_ht_conn_no_route;
83     unsigned short wm_ht_conn_timeout;
84     unsigned short wm_ht_conn_reset;
85     unsigned short wm_ht_conn_other;
86     /** Cloud Stats */
87     unsigned long wm_cl_post_succ;
88     unsigned long wm_cl_post_fail;
89     unsigned long wm_cl_total;
90     unsigned int wm_cl_cum_total;
91 #if CONFIG_ENABLE_HTTPD_STATS
92     /** HTTP Stats */
93     /* Note: wm_hd_file is always included in hd_wsgi_call count */
94     unsigned short wm_hd_wsgi_call;
95     unsigned short wm_hd_file;
96     httpd_useragent_t wm_hd_useragent;
97     unsigned int wm_hd_time;
98 #endif /* CONFIG_ENABLE_HTTPD_STATS */
99     /** Provisioning type */
100     /* Tells whether the module was in NORMAL mode, PROVISIONING mode or
101      * TIMED PROVISIONING mode immediately after rebooting*/
102     unsigned short wm_prov_type;
103 
104     /** Reboot reason of the device */
105     wm_reboot_reason_t reboot_reason;
106 };
107 
108 extern struct wm_stats g_wm_stats;
109 
110 /** Note: This should be in sync with definition in firmware file
111  * tcpip_custom.h.
112  * */
113 
114 #endif /* ! _WMSTATS_H_ */
115