xref: /wlan-dirver/qca-wifi-host-cmn/umac/cp_stats/dispatcher/inc/wlan_cp_stats_public_structs.h (revision 70a19e16789e308182f63b15c75decec7bf0b342)
1 /*
2  * Copyright (c) 2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 /**
19  * DOC: contains cp_stats structure definitions
20  */
21 
22 #ifndef _WLAN_CP_STATS_PUBLIC_STRUCTS_H_
23 #define _WLAN_CP_STATS_PUBLIC_STRUCTS_H_
24 
25 #define CTRL_PATH_STATS_MAX_MAC_ADDR 1
26 #define CTRL_PATH_STATS_MAX_PDEV_ID 1
27 #define CTRL_PATH_STATS_MAX_VDEV_ID 1
28 
29 
30 #define INFRA_CP_STATS_MAX_REQ_TWT_DIALOG_ID 1
31 
32 /*
33  * Maximum of 1 TWT session can be supported per vdev.
34  * This can be extended later to support more sessions.
35  * if there is a request to retrieve stats for all existing
36  * TWT sessions then response path can have multiple session
37  * stats.
38  */
39 #define INFRA_CP_STATS_MAX_RESP_TWT_DIALOG_ID 1
40 
41 #ifdef WLAN_SUPPORT_TWT
42 /**
43  * struct twt_infra_cp_stats_event - TWT statistics event structure
44  * @vdev_id: virtual interface id
45  * @peer_mac_addr: peer mac address corresponding to a TWT session
46  * @dialog_id: Represents dialog_id of the TWT session
47  * @num_sp_cycles: Number of TWT service period elapsed so far
48  * @avg_sp_dur_us: Average of actual wake duration observed so far
49  * @min_sp_dur_us: Minimum value of wake duration observed across
50  * @max_sp_dur_us: Maximum value of wake duration observed
51  * @tx_mpdu_per_sp: Average number of MPDU's transmitted successfully
52  * @rx_mpdu_per_sp: Average number of MPDU's received successfully
53  * @tx_bytes_per_sp: Average number of bytes transmitted successfully
54  * @rx_bytes_per_sp: Average number of bytes received successfully
55  */
56 struct twt_infra_cp_stats_event {
57 	uint8_t vdev_id;
58 	struct qdf_mac_addr peer_macaddr;
59 	uint32_t dialog_id;
60 	uint32_t status;
61 	uint32_t num_sp_cycles;
62 	uint32_t avg_sp_dur_us;
63 	uint32_t min_sp_dur_us;
64 	uint32_t max_sp_dur_us;
65 	uint32_t tx_mpdu_per_sp;
66 	uint32_t rx_mpdu_per_sp;
67 	uint32_t tx_bytes_per_sp;
68 	uint32_t rx_bytes_per_sp;
69 };
70 #endif /* WLAN_SUPPORT_TWT */
71 
72 #ifdef CONFIG_WLAN_BMISS
73 /**
74  * struct bmiss_stats_rssi_samples - bmiss rssi samples structure
75  * @rssi: dBm units
76  * @sample_time: timestamp from host/target shared qtimer
77  */
78 struct bmiss_stats_rssi_samples {
79 	int32_t rssi;
80 	uint32_t sample_time;
81 };
82 
83 /**
84  * struct consecutive_bmiss_stats - consecutive bmiss sats structure
85  * @num_of_bmiss_sequences:number of consecutive bmiss > 2
86  * @num_bitmask_wraparound:number of times bitmask wrapped around
87  * @num_bcn_hist_lost:number of beacons history we have lost
88  */
89 struct consecutive_bmiss_stats {
90 	uint32_t num_of_bmiss_sequences;
91 	uint32_t num_bitmask_wraparound;
92 	uint32_t num_bcn_hist_lost;
93 };
94 
95 #define BMISS_STATS_RSSI_SAMPLES_MAX 10
96 /**
97  * struct bmiss_infra_cp_stats_event -  bmiss statistics event structure
98  * @vdev_id: virtual interface id
99  * @peer_mac_addr: peer mac address
100  * @num_pre_bmiss: number of pre_bmiss
101  * @rssi_samples: Rssi samples at pre bmiss
102  * @rssi_sample_curr_index: current index of Rssi sampelse at pre bmiss
103  * @num_first_bmiss: number of first bmiss
104  * @num_final_bmiss: number of final bmiss
105  * @num_null_sent_in_first_bmiss: number of null frames sent in first bmiss
106  * @num_null_failed_in_first_bmiss: number of failed null frames in first bmiss
107  * @num_null_sent_in_final_bmiss: number of null frames sent in final bmiss
108  * @num_null_failed_in_final_bmiss: number of failed null frames in final bmiss
109  * @cons_bmiss_stats: consecutive bmiss status
110  */
111 struct bmiss_infra_cp_stats_event  {
112 	uint8_t vdev_id;
113 	struct qdf_mac_addr peer_macaddr;
114 	uint32_t num_pre_bmiss;
115 	struct bmiss_stats_rssi_samples rssi_samples[BMISS_STATS_RSSI_SAMPLES_MAX];
116 	uint32_t rssi_sample_curr_index;
117 	uint32_t num_first_bmiss;
118 	uint32_t num_final_bmiss;
119 	uint32_t num_null_sent_in_first_bmiss;
120 	uint32_t num_null_failed_in_first_bmiss;
121 	uint32_t num_null_sent_in_final_bmiss;
122 	uint32_t num_null_failed_in_final_bmiss;
123 	struct consecutive_bmiss_stats cons_bmiss_stats;
124 };
125 #endif /* CONFIG_WLAN_BMISS */
126 
127 #ifdef WLAN_TELEMETRY_STATS_SUPPORT
128 /**
129  * struct ctrl_path_pmlo_telemetry_stats_struct - pmlo telemetry
130  * stats struct
131  * @pdev_id: pdev_id for identifying the PHY
132  * @dl_inbss_airtime_ac_be: ac_be airtime in dl inbss
133  * @dl_inbss_airtime_ac_bk: ac_bk airtime in dl inbss
134  * @dl_inbss_airtime_ac_vi: ac_vi airtime in dl inbss
135  * @dl_inbss_airtime_ac_vo: ac_vo airtime in dl inbss
136  * @ul_inbss_airtime_ac_be: ac_be airtime in ul inbss
137  * @ul_inbss_airtime_ac_bk: ac_bk airtime in ul inbss
138  * @ul_inbss_airtime_ac_vi: ac_vi airtime in ul inbss
139  * @ul_inbss_airtime_ac_vo: ac_vo airtime in ul inbss
140  * @estimated_air_time_ac_be: ac_be estimated air time
141  * @estimated_air_time_ac_bk: ac_bk estimated air time
142  * @estimated_air_time_ac_vi: ac_vi estimated air time
143  * @estimated_air_time_ac_vo: ac_vo estimated air time
144  * @avg_chan_lat_per_ac: array for Average channel latency per AC,
145  * units in micro seconds.
146  * @link_obss_airtime: Percentage of OBSS used air time per link,
147  * units in percentage.
148  * @link_idle_airtime: Idle/free airtime per link, units in percentage.
149  * @ul_inbss_airtime_non_ac: ul inBSS airtime occupied by non-AC traffic,
150  * units in percentage.
151  * @dl_inbss_airtime_non_ac: dl inBSS airtime occupied by non-AC traffic,
152  * units in percentage.
153  */
154 struct ctrl_path_pmlo_telemetry_stats_struct {
155 	uint32_t pdev_id;
156 	uint32_t dl_inbss_airtime_ac_be : 8,
157 		 dl_inbss_airtime_ac_bk : 8,
158 		 dl_inbss_airtime_ac_vi : 8,
159 		 dl_inbss_airtime_ac_vo : 8;
160 	uint32_t ul_inbss_airtime_ac_be : 8,
161 		 ul_inbss_airtime_ac_bk : 8,
162 		 ul_inbss_airtime_ac_vi : 8,
163 		 ul_inbss_airtime_ac_vo : 8;
164 	uint32_t estimated_air_time_ac_be : 8,
165 		 estimated_air_time_ac_bk : 8,
166 		 estimated_air_time_ac_vi : 8,
167 		 estimated_air_time_ac_vo : 8;
168 	uint32_t avg_chan_lat_per_ac[WIFI_AC_MAX];
169 	uint32_t link_obss_airtime : 8,
170 		 link_idle_airtime : 8,
171 		 ul_inbss_airtime_non_ac : 8,
172 		 dl_inbss_airtime_non_ac : 8;
173 };
174 #endif
175 
176 /**
177  * struct infra_cp_stats_event - Event structure to store stats
178  * @action: action for which this response was received
179  *          (get/reset/start/stop)
180  * @request_id: request cookie sent to Firmware in the command
181  * @status: status of the infra_cp_stats command processing
182  * @num_twt_infra_cp_stats: number of twt_infra_cp_stats buffers
183  *                          available
184  * @twt_infra_cp_stats: pointer to TWT session statistics structures
185  * @ctrl_path_pmlo_telemetry_stats_struct - pointer to pmlo
186  * telemetry stats struct
187  *
188  * This structure is used to store the statistics information
189  * extracted from firmware event(wmi_pdev_cp_fwstats_eventid)
190  */
191 struct infra_cp_stats_event {
192 	uint32_t action;
193 	uint32_t request_id;
194 	uint32_t status;
195 #ifdef WLAN_SUPPORT_TWT
196 	uint32_t num_twt_infra_cp_stats;
197 	struct twt_infra_cp_stats_event *twt_infra_cp_stats;
198 #endif
199 #ifdef CONFIG_WLAN_BMISS
200 	struct bmiss_infra_cp_stats_event *bmiss_infra_cp_stats;
201 #endif
202 #ifdef WLAN_TELEMETRY_STATS_SUPPORT
203 	struct ctrl_path_pmlo_telemetry_stats_struct *telemetry_stats;
204 #endif
205 	/* Extend with other required infra_cp_stats structs */
206 };
207 
208 enum infra_cp_stats_action {
209 	ACTION_REQ_CTRL_PATH_STAT_GET = 0,
210 	ACTION_REQ_CTRL_PATH_STAT_RESET,
211 	ACTION_REQ_CTRL_PATH_STAT_START,
212 	ACTION_REQ_CTRL_PATH_STAT_STOP,
213 	ACTION_REQ_CTRL_PATH_STAT_PERIODIC_PUBLISH,
214 };
215 
216 enum infra_cp_stats_id {
217 	TYPE_REQ_CTRL_PATH_PDEV_TX_STAT = 0,
218 	TYPE_REQ_CTRL_PATH_VDEV_EXTD_STAT,
219 	TYPE_REQ_CTRL_PATH_MEM_STAT,
220 	TYPE_REQ_CTRL_PATH_TWT_STAT,
221 	TYPE_REQ_CTRL_PATH_BMISS_STAT,
222 	TYPE_REQ_CTRL_PATH_PMLO_STAT,
223 };
224 
225 /**
226  * struct infra_cp_stats_cmd_info - details of infra cp stats request
227  * @stats_id: ID of the statistics type requested
228  * @action: action to be performed (get/reset/start/stop)
229  * @request_cookie: osif request cookie
230  * @request_id: request id cookie to FW
231  * @num_pdev_ids: number of pdev ids in the request
232  * @pdev_id: array of pdev_ids
233  * @num_vdev_ids: number of vdev ids in the request
234  * @vdev_id: array of vdev_ids
235  * @num_mac_addr_list: number of mac addresses in the request
236  * @peer_mac_addr: array of mac addresses
237  * @dialog_id: This is a TWT specific field. only one dialog_id
238  *             can be specified for TWT stats. 0 to 254 are
239  *             valid dialog_id's representing a single TWT session.
240  *             255 represents all twt sessions
241  * @infra_cp_stats_resp_cb: callback function to handle the response
242  */
243 struct infra_cp_stats_cmd_info {
244 	enum infra_cp_stats_id stats_id;
245 	enum infra_cp_stats_action action;
246 	void *request_cookie;
247 	uint32_t request_id;
248 	uint32_t num_pdev_ids;
249 	uint32_t pdev_id[CTRL_PATH_STATS_MAX_PDEV_ID];
250 	uint32_t num_vdev_ids;
251 	uint32_t vdev_id[CTRL_PATH_STATS_MAX_VDEV_ID];
252 	uint32_t num_mac_addr_list;
253 	uint8_t peer_mac_addr[CTRL_PATH_STATS_MAX_MAC_ADDR][QDF_MAC_ADDR_SIZE];
254 #ifdef WLAN_SUPPORT_TWT
255 	uint32_t dialog_id;
256 #endif
257 	void (*infra_cp_stats_resp_cb)(struct infra_cp_stats_event *ev,
258 				       void *cookie);
259 	uint32_t stat_periodicity;
260 };
261 #endif
262