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_macaddr: peer mac address corresponding to a TWT session 46 * @dialog_id: Represents dialog_id of the TWT session 47 * @status: 48 * @num_sp_cycles: Number of TWT service period elapsed so far 49 * @avg_sp_dur_us: Average of actual wake duration observed so far 50 * @min_sp_dur_us: Minimum value of wake duration observed across 51 * @max_sp_dur_us: Maximum value of wake duration observed 52 * @tx_mpdu_per_sp: Average number of MPDU's transmitted successfully 53 * @rx_mpdu_per_sp: Average number of MPDU's received successfully 54 * @tx_bytes_per_sp: Average number of bytes transmitted successfully 55 * @rx_bytes_per_sp: Average number of bytes received successfully 56 */ 57 struct twt_infra_cp_stats_event { 58 uint8_t vdev_id; 59 struct qdf_mac_addr peer_macaddr; 60 uint32_t dialog_id; 61 uint32_t status; 62 uint32_t num_sp_cycles; 63 uint32_t avg_sp_dur_us; 64 uint32_t min_sp_dur_us; 65 uint32_t max_sp_dur_us; 66 uint32_t tx_mpdu_per_sp; 67 uint32_t rx_mpdu_per_sp; 68 uint32_t tx_bytes_per_sp; 69 uint32_t rx_bytes_per_sp; 70 }; 71 #endif /* WLAN_SUPPORT_TWT */ 72 73 #ifdef CONFIG_WLAN_BMISS 74 /** 75 * struct bmiss_stats_rssi_samples - bmiss rssi samples structure 76 * @rssi: dBm units 77 * @sample_time: timestamp from host/target shared qtimer 78 */ 79 struct bmiss_stats_rssi_samples { 80 int32_t rssi; 81 uint32_t sample_time; 82 }; 83 84 /** 85 * struct consecutive_bmiss_stats - consecutive bmiss sats structure 86 * @num_of_bmiss_sequences:number of consecutive bmiss > 2 87 * @num_bitmask_wraparound:number of times bitmask wrapped around 88 * @num_bcn_hist_lost:number of beacons history we have lost 89 */ 90 struct consecutive_bmiss_stats { 91 uint32_t num_of_bmiss_sequences; 92 uint32_t num_bitmask_wraparound; 93 uint32_t num_bcn_hist_lost; 94 }; 95 96 #define BMISS_STATS_RSSI_SAMPLES_MAX 10 97 /** 98 * struct bmiss_infra_cp_stats_event - bmiss statistics event structure 99 * @vdev_id: virtual interface id 100 * @peer_macaddr: peer mac address 101 * @num_pre_bmiss: number of pre_bmiss 102 * @rssi_samples: Rssi samples at pre bmiss 103 * @rssi_sample_curr_index: current index of Rssi sampelse at pre bmiss 104 * @num_first_bmiss: number of first bmiss 105 * @num_final_bmiss: number of final bmiss 106 * @num_null_sent_in_first_bmiss: number of null frames sent in first bmiss 107 * @num_null_failed_in_first_bmiss: number of failed null frames in first bmiss 108 * @num_null_sent_in_final_bmiss: number of null frames sent in final bmiss 109 * @num_null_failed_in_final_bmiss: number of failed null frames in final bmiss 110 * @cons_bmiss_stats: consecutive bmiss status 111 */ 112 struct bmiss_infra_cp_stats_event { 113 uint8_t vdev_id; 114 struct qdf_mac_addr peer_macaddr; 115 uint32_t num_pre_bmiss; 116 struct bmiss_stats_rssi_samples rssi_samples[BMISS_STATS_RSSI_SAMPLES_MAX]; 117 uint32_t rssi_sample_curr_index; 118 uint32_t num_first_bmiss; 119 uint32_t num_final_bmiss; 120 uint32_t num_null_sent_in_first_bmiss; 121 uint32_t num_null_failed_in_first_bmiss; 122 uint32_t num_null_sent_in_final_bmiss; 123 uint32_t num_null_failed_in_final_bmiss; 124 struct consecutive_bmiss_stats cons_bmiss_stats; 125 }; 126 #endif /* CONFIG_WLAN_BMISS */ 127 128 #ifdef WLAN_CONFIG_TELEMETRY_AGENT 129 /** 130 * struct ctrl_path_pmlo_telemetry_stats_struct - pmlo telemetry 131 * stats struct 132 * @pdev_id: pdev_id for identifying the PHY 133 * @dl_inbss_airtime_ac_be: ac_be airtime in dl inbss 134 * @dl_inbss_airtime_ac_bk: ac_bk airtime in dl inbss 135 * @dl_inbss_airtime_ac_vi: ac_vi airtime in dl inbss 136 * @dl_inbss_airtime_ac_vo: ac_vo airtime in dl inbss 137 * @ul_inbss_airtime_ac_be: ac_be airtime in ul inbss 138 * @ul_inbss_airtime_ac_bk: ac_bk airtime in ul inbss 139 * @ul_inbss_airtime_ac_vi: ac_vi airtime in ul inbss 140 * @ul_inbss_airtime_ac_vo: ac_vo airtime in ul inbss 141 * @estimated_air_time_ac_be: ac_be estimated air time 142 * @estimated_air_time_ac_bk: ac_bk estimated air time 143 * @estimated_air_time_ac_vi: ac_vi estimated air time 144 * @estimated_air_time_ac_vo: ac_vo estimated air time 145 * @avg_chan_lat_per_ac: array for Average channel latency per AC, 146 * units in micro seconds. 147 * @link_obss_airtime: Percentage of OBSS used air time per link, 148 * units in percentage. 149 * @link_idle_airtime: Idle/free airtime per link, units in percentage. 150 * @ul_inbss_airtime_non_ac: ul inBSS airtime occupied by non-AC traffic, 151 * units in percentage. 152 * @dl_inbss_airtime_non_ac: dl inBSS airtime occupied by non-AC traffic, 153 * units in percentage. 154 */ 155 struct ctrl_path_pmlo_telemetry_stats_struct { 156 uint32_t pdev_id; 157 uint32_t dl_inbss_airtime_ac_be : 8, 158 dl_inbss_airtime_ac_bk : 8, 159 dl_inbss_airtime_ac_vi : 8, 160 dl_inbss_airtime_ac_vo : 8; 161 uint32_t ul_inbss_airtime_ac_be : 8, 162 ul_inbss_airtime_ac_bk : 8, 163 ul_inbss_airtime_ac_vi : 8, 164 ul_inbss_airtime_ac_vo : 8; 165 uint32_t estimated_air_time_ac_be : 8, 166 estimated_air_time_ac_bk : 8, 167 estimated_air_time_ac_vi : 8, 168 estimated_air_time_ac_vo : 8; 169 uint32_t avg_chan_lat_per_ac[WIFI_AC_MAX]; 170 uint32_t link_obss_airtime : 8, 171 link_idle_airtime : 8, 172 ul_inbss_airtime_non_ac : 8, 173 dl_inbss_airtime_non_ac : 8; 174 }; 175 #endif 176 177 /** 178 * struct group_id_0: stats for group id 0 179 * @group_transmitted_frame_count: group transmitted frame count 180 * @failed_count: failed count 181 * @group_received_frame_count: group received frame count 182 * @fcs_error_count: fcs error count 183 * @transmitted_frame_count: transmitted frame count 184 */ 185 struct group_id_0 { 186 uint32_t group_transmitted_frame_count; 187 uint32_t failed_count; 188 uint32_t group_received_frame_count; 189 uint32_t fcs_error_count; 190 uint32_t transmitted_frame_count; 191 }; 192 193 /** 194 * struct group_id_1: stats of group id 1 195 * @rts_success_count: rts success count 196 * @rts_failure_count: rts failure count 197 * @ack_failure_count: ack failure count 198 */ 199 struct group_id_1 { 200 uint32_t rts_success_count; 201 uint32_t rts_failure_count; 202 uint32_t ack_failure_count; 203 }; 204 205 /** 206 * struct group_id_stats : stats for group provided group id 207 * @counter_stats: stats for group id 0 208 * @mac_stats: stats for group id 1 209 */ 210 struct group_id_stats { 211 struct group_id_0 counter_stats; 212 struct group_id_1 mac_stats; 213 }; 214 215 /** 216 * struct cp_sta_stats - cp sta stats 217 * @sta_stats_group_id: group id 218 * @group: group for group stats 219 */ 220 struct cp_sta_stats { 221 uint8_t sta_stats_group_id; 222 struct group_id_stats group; 223 }; 224 225 /** 226 * struct infra_cp_stats_event - Event structure to store stats 227 * @action: action for which this response was received 228 * (get/reset/start/stop) 229 * @request_id: request cookie sent to Firmware in the command 230 * @status: status of the infra_cp_stats command processing 231 * @num_twt_infra_cp_stats: number of twt_infra_cp_stats buffers 232 * available 233 * @twt_infra_cp_stats: pointer to TWT session statistics structures 234 * @bmiss_infra_cp_stats: pointer to beacon miss statistics 235 * @telemetry_stats: pointer to pmlo telemetry stats struct 236 * @sta_stats: pointer to RRM sta stats struct 237 * 238 * This structure is used to store the statistics information 239 * extracted from firmware event(wmi_pdev_cp_fwstats_eventid) 240 */ 241 struct infra_cp_stats_event { 242 uint32_t action; 243 uint32_t request_id; 244 uint32_t status; 245 #ifdef WLAN_SUPPORT_TWT 246 uint32_t num_twt_infra_cp_stats; 247 struct twt_infra_cp_stats_event *twt_infra_cp_stats; 248 #endif 249 #ifdef CONFIG_WLAN_BMISS 250 struct bmiss_infra_cp_stats_event *bmiss_infra_cp_stats; 251 #endif 252 #ifdef WLAN_CONFIG_TELEMETRY_AGENT 253 struct ctrl_path_pmlo_telemetry_stats_struct *telemetry_stats; 254 #endif 255 struct cp_sta_stats *sta_stats; 256 /* Extend with other required infra_cp_stats structs */ 257 }; 258 259 enum infra_cp_stats_action { 260 ACTION_REQ_CTRL_PATH_STAT_GET = 0, 261 ACTION_REQ_CTRL_PATH_STAT_RESET, 262 ACTION_REQ_CTRL_PATH_STAT_START, 263 ACTION_REQ_CTRL_PATH_STAT_STOP, 264 ACTION_REQ_CTRL_PATH_STAT_PERIODIC_PUBLISH, 265 }; 266 267 enum infra_cp_stats_id { 268 TYPE_REQ_CTRL_PATH_PDEV_TX_STAT = 0, 269 TYPE_REQ_CTRL_PATH_VDEV_EXTD_STAT, 270 TYPE_REQ_CTRL_PATH_MEM_STAT, 271 TYPE_REQ_CTRL_PATH_TWT_STAT, 272 TYPE_REQ_CTRL_PATH_BMISS_STAT, 273 TYPE_REQ_CTRL_PATH_PMLO_STAT, 274 TYPE_REQ_CTRL_PATH_RRM_STA_STAT, 275 }; 276 277 /** 278 * struct infra_cp_stats_cmd_info - details of infra cp stats request 279 * @stats_id: ID of the statistics type requested 280 * @action: action to be performed (get/reset/start/stop) 281 * @request_cookie: osif request cookie 282 * @request_id: request id cookie to FW 283 * @num_pdev_ids: number of pdev ids in the request 284 * @pdev_id: array of pdev_ids 285 * @num_vdev_ids: number of vdev ids in the request 286 * @vdev_id: array of vdev_ids 287 * @num_mac_addr_list: number of mac addresses in the request 288 * @peer_mac_addr: array of mac addresses 289 * @dialog_id: This is a TWT specific field. only one dialog_id 290 * can be specified for TWT stats. 0 to 254 are 291 * valid dialog_id's representing a single TWT session. 292 * 255 represents all twt sessions 293 * @infra_cp_stats_resp_cb: callback function to handle the response 294 * @stat_periodicity: WMI ctrl-path stats event periodicity 295 */ 296 struct infra_cp_stats_cmd_info { 297 enum infra_cp_stats_id stats_id; 298 enum infra_cp_stats_action action; 299 void *request_cookie; 300 uint32_t request_id; 301 uint32_t num_pdev_ids; 302 uint32_t pdev_id[CTRL_PATH_STATS_MAX_PDEV_ID]; 303 uint32_t num_vdev_ids; 304 uint32_t vdev_id[CTRL_PATH_STATS_MAX_VDEV_ID]; 305 uint32_t num_mac_addr_list; 306 uint8_t peer_mac_addr[CTRL_PATH_STATS_MAX_MAC_ADDR][QDF_MAC_ADDR_SIZE]; 307 #ifdef WLAN_SUPPORT_TWT 308 uint32_t dialog_id; 309 #endif 310 void (*infra_cp_stats_resp_cb)(struct infra_cp_stats_event *ev, 311 void *cookie); 312 uint32_t stat_periodicity; 313 }; 314 #endif 315