1 /*
2  * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /**
20  * DOC: wlan_cfg80211_ic_cp_stats.c
21  *
22  * This file provide definitions to os_if cp_stats APIs
23  */
24 #include <wlan_cfg80211_ic_cp_stats.h>
25 #include <wlan_cp_stats_ic_ucfg_api.h>
26 #include <wlan_cfg80211.h>
27 #include <qdf_util.h>
28 
wlan_cfg80211_get_peer_cp_stats(struct wlan_objmgr_peer * peer_obj,struct peer_ic_cp_stats * peer_cp_stats)29 int wlan_cfg80211_get_peer_cp_stats(struct wlan_objmgr_peer *peer_obj,
30 				    struct peer_ic_cp_stats *peer_cp_stats)
31 {
32 	QDF_STATUS status;
33 
34 	if (!peer_obj) {
35 		osif_err("Invalid input, peer obj NULL");
36 		return -EINVAL;
37 	}
38 
39 	if (!peer_cp_stats) {
40 		osif_err("Invalid input, peer cp obj is NULL");
41 		return -EINVAL;
42 	}
43 
44 	status = wlan_ucfg_get_peer_cp_stats(peer_obj, peer_cp_stats);
45 	if (QDF_IS_STATUS_ERROR(status)) {
46 		osif_err("wlan_cfg80211_get_peer_cp_stats status: %d",
47 			 status);
48 	}
49 
50 	return qdf_status_to_os_return(status);
51 }
52 
wlan_cfg80211_get_vdev_cp_stats(struct wlan_objmgr_vdev * vdev_obj,struct vdev_ic_cp_stats * vdev_cp_stats)53 int wlan_cfg80211_get_vdev_cp_stats(struct wlan_objmgr_vdev *vdev_obj,
54 				    struct vdev_ic_cp_stats *vdev_cp_stats)
55 {
56 	QDF_STATUS status;
57 
58 	if (!vdev_obj) {
59 		osif_err("Invalid input, vdev obj is NULL");
60 		return -EINVAL;
61 	}
62 
63 	if (!vdev_cp_stats) {
64 		osif_err("Invalid input, vdev cp obj is NULL");
65 		return -EINVAL;
66 	}
67 
68 	status = wlan_ucfg_get_vdev_cp_stats(vdev_obj, vdev_cp_stats);
69 	if (QDF_IS_STATUS_ERROR(status)) {
70 		osif_err("wlan_cfg80211_get_vdev_cp_stats status: %d",
71 			 status);
72 	}
73 
74 	return qdf_status_to_os_return(status);
75 }
76 
wlan_cfg80211_get_pdev_cp_stats(struct wlan_objmgr_pdev * pdev_obj,struct pdev_ic_cp_stats * pdev_cp_stats)77 int wlan_cfg80211_get_pdev_cp_stats(struct wlan_objmgr_pdev *pdev_obj,
78 				    struct pdev_ic_cp_stats *pdev_cp_stats)
79 {
80 	QDF_STATUS status;
81 
82 	if (!pdev_obj) {
83 		osif_err("Invalid input, pdev obj is NULL");
84 		return -EINVAL;
85 	}
86 
87 	if (!pdev_cp_stats) {
88 		osif_err("Invalid input, pdev cp obj is NULL");
89 		return -EINVAL;
90 	}
91 
92 	status = wlan_ucfg_get_pdev_cp_stats(pdev_obj, pdev_cp_stats);
93 	if (QDF_IS_STATUS_ERROR(status)) {
94 		osif_err("wlan_cfg80211_get_pdev_cp_stats status: %d",
95 			 status);
96 	}
97 
98 	return qdf_status_to_os_return(status);
99 }
100 
101 qdf_export_symbol(wlan_cfg80211_get_pdev_cp_stats);
102 
103 #ifdef WLAN_ATF_ENABLE
104 int
wlan_cfg80211_get_atf_peer_cp_stats(struct wlan_objmgr_peer * peer_obj,struct atf_peer_cp_stats * atf_cp_stats)105 wlan_cfg80211_get_atf_peer_cp_stats(struct wlan_objmgr_peer *peer_obj,
106 				    struct atf_peer_cp_stats *atf_cp_stats)
107 {
108 	QDF_STATUS status;
109 
110 	if (!peer_obj) {
111 		osif_err("Invalid input, peer obj is NULL");
112 		return -EINVAL;
113 	}
114 
115 	if (!atf_cp_stats) {
116 		osif_err("Invalid input, ATF peer cp obj is NULL!");
117 		return -EINVAL;
118 	}
119 
120 	status = wlan_ucfg_get_atf_peer_cp_stats(peer_obj, atf_cp_stats);
121 	if (QDF_IS_STATUS_ERROR(status)) {
122 		osif_err("wlan_cfg80211_get_atf_peer_cp_stats status: %d",
123 			 status);
124 	}
125 
126 	return qdf_status_to_os_return(status);
127 }
128 
wlan_cfg80211_get_atf_peer_cp_stats_from_mac(struct wlan_objmgr_vdev * vdev_obj,uint8_t * mac,struct atf_peer_cp_stats * atf_cp_stats)129 int wlan_cfg80211_get_atf_peer_cp_stats_from_mac(
130 		struct wlan_objmgr_vdev *vdev_obj,
131 		uint8_t *mac,
132 		struct atf_peer_cp_stats *atf_cp_stats)
133 {
134 	QDF_STATUS status;
135 
136 	if (!vdev_obj) {
137 		osif_err("Invalid input, vdev obj is NULL");
138 		return -EINVAL;
139 	}
140 
141 	if (!mac) {
142 		osif_err("Invalid input, peer mac is NULL");
143 		return -EINVAL;
144 	}
145 
146 	if (!atf_cp_stats) {
147 		osif_err("Invalid input, ATF peer cp stats obj is NULL");
148 		return -EINVAL;
149 	}
150 
151 	status = wlan_ucfg_get_atf_peer_cp_stats_from_mac(vdev_obj, mac,
152 							  atf_cp_stats);
153 	if (QDF_IS_STATUS_ERROR(status)) {
154 		osif_err("wlan_cfg80211_get_cp_stats_from_mac status: %d",
155 			 status);
156 	}
157 
158 	return qdf_status_to_os_return(status);
159 }
160 #endif
161 
162 int
wlan_cfg80211_get_dcs_pdev_cp_stats(struct wlan_objmgr_pdev * pdev_obj,struct pdev_dcs_chan_stats * dcs_chan_stats)163 wlan_cfg80211_get_dcs_pdev_cp_stats(struct wlan_objmgr_pdev *pdev_obj,
164 				    struct pdev_dcs_chan_stats *dcs_chan_stats)
165 {
166 	QDF_STATUS status;
167 
168 	if (!pdev_obj) {
169 		osif_err("Invalid input, pdev obj is NULL");
170 		return -EINVAL;
171 	}
172 
173 	if (!dcs_chan_stats) {
174 		osif_err("Invalid input, dcs chan stats is NULL");
175 		return -EINVAL;
176 	}
177 
178 	status = wlan_ucfg_get_dcs_chan_stats(pdev_obj, dcs_chan_stats);
179 	if (QDF_IS_STATUS_ERROR(status)) {
180 		osif_err("wlan_cfg80211_get_dcs_pdev_cp_stats status: %d",
181 			 status);
182 	}
183 
184 	return qdf_status_to_os_return(status);
185 }
186