xref: /wlan-dirver/qca-wifi-host-cmn/umac/cp_stats/dispatcher/inc/wlan_cp_stats_public_structs.h (revision 2f4b444fb7e689b83a4ab0e7b3b38f0bf4def8e0)
1 /*
2  * Copyright (c) 2021 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 /**
18  * DOC: contains cp_stats structure definitions
19  */
20 
21 #ifndef _WLAN_CP_STATS_PUBLIC_STRUCTS_H_
22 #define _WLAN_CP_STATS_PUBLIC_STRUCTS_H_
23 
24 #define CTRL_PATH_STATS_MAX_MAC_ADDR 1
25 #define CTRL_PATH_STATS_MAX_PDEV_ID 1
26 #define CTRL_PATH_STATS_MAX_VDEV_ID 1
27 
28 
29 #define INFRA_CP_STATS_MAX_REQ_TWT_DIALOG_ID 1
30 
31 /*
32  * Maximum of 1 TWT session can be supported per vdev.
33  * This can be extended later to support more sessions.
34  * if there is a request to retrieve stats for all existing
35  * TWT sessions then response path can have multiple session
36  * stats.
37  */
38 #define INFRA_CP_STATS_MAX_RESP_TWT_DIALOG_ID 1
39 
40 #ifdef WLAN_SUPPORT_TWT
41 /**
42  * struct twt_infra_cp_stats_event - TWT statistics event structure
43  * @vdev_id: virtual interface id
44  * @peer_mac_addr: peer mac address corresponding to a TWT session
45  * @dialog_id: Represents dialog_id of the TWT session
46  * @num_sp_cycles: Number of TWT service period elapsed so far
47  * @avg_sp_dur_us: Average of actual wake duration observed so far
48  * @min_sp_dur_us: Minimum value of wake duration observed across
49  * @max_sp_dur_us: Maximum value of wake duration observed
50  * @tx_mpdu_per_sp: Average number of MPDU's transmitted successfully
51  * @rx_mpdu_per_sp: Average number of MPDU's received successfully
52  * @tx_bytes_per_sp: Average number of bytes transmitted successfully
53  * @rx_bytes_per_sp: Average number of bytes received successfully
54  */
55 struct twt_infra_cp_stats_event {
56 	uint8_t vdev_id;
57 	struct qdf_mac_addr peer_macaddr;
58 	uint32_t dialog_id;
59 	uint32_t status;
60 	uint32_t num_sp_cycles;
61 	uint32_t avg_sp_dur_us;
62 	uint32_t min_sp_dur_us;
63 	uint32_t max_sp_dur_us;
64 	uint32_t tx_mpdu_per_sp;
65 	uint32_t rx_mpdu_per_sp;
66 	uint32_t tx_bytes_per_sp;
67 	uint32_t rx_bytes_per_sp;
68 };
69 #endif /* WLAN_SUPPORT_TWT */
70 
71 /**
72  * struct infra_cp_stats_event - Event structure to store stats
73  * @action: action for which this response was recevied
74  *          (get/reset/start/stop)
75  * @request_id: request cookie sent to Firmware in the command
76  * @status: status of the infra_cp_stats command processing
77  * @num_twt_infra_cp_stats: number of twt_infra_cp_stats buffers
78  *                          available
79  * @twt_infra_cp_stats: pointer to TWT session statistics structures
80  *
81  * This structure is used to store the statistics information
82  * extracted from firmware event(wmi_pdev_cp_fwstats_eventid)
83  */
84 struct infra_cp_stats_event {
85 	uint32_t action;
86 	uint32_t request_id;
87 	uint32_t status;
88 #ifdef WLAN_SUPPORT_TWT
89 	uint32_t num_twt_infra_cp_stats;
90 	struct twt_infra_cp_stats_event *twt_infra_cp_stats;
91 #endif
92 	/* Extend with other required infra_cp_stats structs */
93 };
94 
95 enum infra_cp_stats_action {
96 	ACTION_REQ_CTRL_PATH_STAT_GET = 0,
97 	ACTION_REQ_CTRL_PATH_STAT_RESET,
98 	ACTION_REQ_CTRL_PATH_STAT_START,
99 	ACTION_REQ_CTRL_PATH_STAT_STOP,
100 };
101 
102 enum infra_cp_stats_id {
103 	TYPE_REQ_CTRL_PATH_PDEV_TX_STAT = 0,
104 	TYPE_REQ_CTRL_PATH_VDEV_EXTD_STAT,
105 	TYPE_REQ_CTRL_PATH_MEM_STAT,
106 	TYPE_REQ_CTRL_PATH_TWT_STAT,
107 };
108 
109 /**
110  * struct infra_cp_stats_cmd_info - details of infra cp stats request
111  * @stats_id: ID of the statistics type requested
112  * @action: action to be performed (get/reset/start/stop)
113  * @request_cookie: osif request cookie
114  * @request_id: request id cookie to FW
115  * @num_pdev_ids: number of pdev ids in the request
116  * @pdev_id: array of pdev_ids
117  * @num_vdev_ids: number of vdev ids in the request
118  * @vdev_id: array of vdev_ids
119  * @num_mac_addr_list: number of mac addresses in the request
120  * @peer_mac_addr: array of mac addresses
121  * @dialog_id: This is a TWT specific field. only one dialog_id
122  *             can be specified for TWT stats. 0 to 254 are
123  *             valid dialog_id's representing a single TWT session.
124  *             255 represents all twt sessions
125  * @infra_cp_stats_resp_cb: callback function to handle the response
126  */
127 struct infra_cp_stats_cmd_info {
128 	enum infra_cp_stats_id stats_id;
129 	enum infra_cp_stats_action action;
130 	void *request_cookie;
131 	uint32_t request_id;
132 	uint32_t num_pdev_ids;
133 	uint32_t pdev_id[CTRL_PATH_STATS_MAX_PDEV_ID];
134 	uint32_t num_vdev_ids;
135 	uint32_t vdev_id[CTRL_PATH_STATS_MAX_VDEV_ID];
136 	uint32_t num_mac_addr_list;
137 	uint8_t peer_mac_addr[CTRL_PATH_STATS_MAX_MAC_ADDR][QDF_MAC_ADDR_SIZE];
138 #ifdef WLAN_SUPPORT_TWT
139 	uint32_t dialog_id;
140 #endif
141 	void (*infra_cp_stats_resp_cb)(struct infra_cp_stats_event *ev,
142 				       void *cookie);
143 };
144 #endif
145