1 /*
2  * Copyright (C) 2015-2018 Alibaba Group Holding Limited
3  */
4 
5 #ifndef __AWSS_STATIS_H__
6 #define __AWSS_STATIS_H__
7 
8 #include <stdint.h>
9 #ifdef AWSS_SUPPORT_DEV_AP
10 #include "awss_dev_ap.h"
11 #endif
12 
13 enum {
14     AWSS_STATIS_CONN_ROUTER_IDX = 0, /* Statistic for connection with router */
15     AWSS_STATIS_SM_IDX,              /* Statistic for smartconfig with bcast */
16     AWSS_STATIS_WPS_IDX,             /* Statistic for smartconfig with wps */
17     AWSS_STATIS_PAP_IDX,             /* Statistic for phone as AP */
18     AWSS_STATIS_DAP_IDX,             /* Statistic for device AP */
19     AWSS_STATIS_ROUTE_IDX,           /* Statistic for route solution */
20     AWSS_STATIS_ZCONFIG_IDX,         /* Statistic for zero config */
21 };
22 
23 enum {
24     AWSS_STATIS_TYPE_TIME_START = 0, /* Begining of operation */
25     AWSS_STATIS_TYPE_TIME_SUC,       /* Success of operation */
26     AWSS_STATIS_TYPE_PASSWD_ERR,     /* Failure of parsing PASSWD of router*/
27     AWSS_STATIS_TYPE_CRC_ERR,        /* Failure of CRC check */
28     AWSS_STATIS_TYPE_SCAN_START,     /* Start of scan operation */
29     AWSS_STATIS_TYPE_SCAN_STOP,      /* Stop of scan operation */
30     AWSS_STATIS_TYPE_SWITCHAP        /* Increase count of switch ap */
31 };
32 
33 #ifndef AWSS_SUPPORT_STATIS
34 #define AWSS_SUPPORT_STATIS
35 #endif
36 
37 #ifdef AWSS_SUPPORT_STATIS
38 
39 struct awss_statis_conn_router_t {
40     uint32_t conn_router_cnt;       /* the count of connect router */
41     uint32_t conn_router_suc;       /* the success count of connect router */
42     uint32_t conn_router_time_mean; /* the mean time of success connection with
43                                        router */
44     uint32_t conn_router_time_max;  /* the max time of success connection with
45                                        router */
46     uint32_t conn_router_time_min;  /* the min time of success connection with
47                                        router */
48     uint32_t conn_router_start;     /* the start time to connect router */
49     uint32_t conn_router_end;       /* the end time of connect router */
50 };                                  /* statistics for connection with router */
51 
52 struct awss_statis_sm_t {
53     uint32_t sm_parse_cnt;        /* the count of smartconfig */
54     uint32_t sm_parse_crc_err;    /* the count of crc error */
55     uint32_t sm_parse_passwd_err; /* the count of passwd error */
56     uint32_t sm_parse_suc;        /* the count of smartconfig success */
57     uint32_t sm_parse_start;      /* the start time to smartconfig */
58     uint32_t sm_parse_end;        /* the ene time of smartconfig */
59     uint32_t sm_time_mean;        /* the mean time of smartconfig */
60     uint32_t sm_time_max;         /* the max time of smartconfig */
61     uint32_t sm_time_min;         /* the min time of smartconfig */
62 };                                /* smartconfig-bcast statistic  */
63 
64 struct awss_statis_wps_t {
65     uint32_t wps_parse_cnt;        /* the count of smartconfig-wps */
66     uint32_t wps_parse_crc_err;    /* the count of crc error */
67     uint32_t wps_parse_passwd_err; /* the count of passwd error */
68     uint32_t wps_parse_suc;        /* the count of smartconfig-wps success */
69 };                                 /* smartconfig-wps statistic  */
70 
71 struct awss_statis_phone_ap_t {
72     uint32_t aha_cnt;
73     uint32_t aha_suc;
74     uint32_t aha_time_mean; /* mean time of phone as AP solution */
75     uint32_t aha_time_max;  /* max time of phone as AP solution */
76     uint32_t aha_time_min;  /* min time of phone as AP solution */
77     uint32_t aha_start;
78     uint32_t aha_end;
79     uint32_t aha_scan_start;
80     uint32_t aha_scan_end;
81     uint32_t aha_switch_ap;
82     uint32_t aha_passwd_err;
83 }; /* Phone as AP */
84 
85 struct awss_statis_dev_ap_t {
86     uint32_t dev_ap_cnt;
87     uint32_t dev_ap_suc;
88     uint32_t dev_ap_time_mean; /* mean time of device AP solution */
89     uint32_t dev_ap_time_max;  /* max time of device AP solution */
90     uint32_t dev_ap_time_min;  /* min time of device AP solution */
91     uint32_t dev_ap_start;
92     uint32_t dev_ap_end;
93     uint32_t dev_ap_passwd_err;
94 }; /* device work as AP */
95 
96 struct awss_statis_zconfig_t {
97     uint32_t zc_cnt;
98     uint32_t zc_suc;
99     uint32_t zc_passwd_err;
100 }; /* zero configure solution */
101 
102 struct awss_statis_t {
103     struct awss_statis_conn_router_t droute;
104 #ifdef AWSS_SUPPORT_SMARTCONFIG
105     struct awss_statis_sm_t sm;
106 #ifdef AWSS_SUPPORT_SMARTCONFIG_WPS
107     struct awss_statis_wps_t wps;
108 #endif
109 #endif
110 #ifdef AWSS_SUPPORT_AHA
111     struct awss_statis_phone_ap_t pap;
112 #endif
113 #ifdef AWSS_SUPPORT_DEV_AP
114     struct awss_statis_dev_ap_t dap;
115 #endif
116 #ifndef AWSS_DISABLE_ENROLLEE
117     struct awss_statis_zconfig_t zconfig;
118 #endif
119 };
120 
121 int awss_report_statis(const char *module);
122 void awss_update_statis(int awss_statis_idx, int type);
123 void awss_clear_statis();
124 void awss_disp_statis();
125 
126 #define AWSS_UPDATE_STATIS(idx, type) awss_update_statis(idx, type)
127 #define AWSS_CLEAR_STATIS()           awss_clear_statis()
128 #define AWSS_DISP_STATIS()            awss_disp_statis()
129 #define AWSS_REPORT_STATIS(m)         awss_disp_statis(m)
130 #else
131 #define AWSS_UPDATE_STATIS(idx, type)
132 #define AWSS_CLEAR_STATIS()
133 #define AWSS_DISP_STATIS()
134 #define AWSS_REPORT_STATIS(m)
135 #endif
136 
137 #endif
138