1 /*
2  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. 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 #include <wlan_twt_ucfg_ext_api.h>
19 #include <wlan_twt_ucfg_ext_cfg.h>
20 #include "twt/core/src/wlan_twt_cfg.h"
21 #include "twt/core/src/wlan_twt_main.h"
22 
ucfg_twt_psoc_open(struct wlan_objmgr_psoc * psoc)23 QDF_STATUS ucfg_twt_psoc_open(struct wlan_objmgr_psoc *psoc)
24 {
25 	return wlan_twt_cfg_init(psoc);
26 }
27 
ucfg_twt_psoc_close(struct wlan_objmgr_psoc * psoc)28 QDF_STATUS ucfg_twt_psoc_close(struct wlan_objmgr_psoc *psoc)
29 {
30 	return wlan_twt_cfg_deinit(psoc);
31 }
32 
ucfg_twt_update_psoc_config(struct wlan_objmgr_psoc * psoc)33 QDF_STATUS ucfg_twt_update_psoc_config(struct wlan_objmgr_psoc *psoc)
34 {
35 	return wlan_twt_cfg_update(psoc);
36 }
37 
38 QDF_STATUS
ucfg_twt_cfg_get_requestor(struct wlan_objmgr_psoc * psoc,bool * val)39 ucfg_twt_cfg_get_requestor(struct wlan_objmgr_psoc *psoc, bool *val)
40 {
41 	return wlan_twt_cfg_get_requestor(psoc, val);
42 }
43 
44 QDF_STATUS
ucfg_twt_cfg_get_responder(struct wlan_objmgr_psoc * psoc,bool * val)45 ucfg_twt_cfg_get_responder(struct wlan_objmgr_psoc *psoc, bool *val)
46 {
47 	return wlan_twt_cfg_get_responder(psoc, val);
48 }
49 
50 QDF_STATUS
ucfg_twt_cfg_set_responder(struct wlan_objmgr_psoc * psoc,bool val)51 ucfg_twt_cfg_set_responder(struct wlan_objmgr_psoc *psoc, bool val)
52 {
53 	return wlan_twt_cfg_set_responder(psoc, val);
54 }
55 
56 QDF_STATUS
ucfg_twt_setup_req(struct wlan_objmgr_psoc * psoc,struct twt_add_dialog_param * params,void * context)57 ucfg_twt_setup_req(struct wlan_objmgr_psoc *psoc,
58 		   struct twt_add_dialog_param *params,
59 		   void *context)
60 {
61 	return wlan_twt_setup_req(psoc, params, context);
62 }
63 
ucfg_twt_teardown_req(struct wlan_objmgr_psoc * psoc,struct twt_del_dialog_param * params,void * context)64 QDF_STATUS ucfg_twt_teardown_req(struct wlan_objmgr_psoc *psoc,
65 				 struct twt_del_dialog_param *params,
66 				 void *context)
67 {
68 	return wlan_twt_teardown_req(psoc, params, context);
69 }
70 
71 QDF_STATUS
ucfg_twt_pause_req(struct wlan_objmgr_psoc * psoc,struct twt_pause_dialog_cmd_param * params,void * context)72 ucfg_twt_pause_req(struct wlan_objmgr_psoc *psoc,
73 		   struct twt_pause_dialog_cmd_param *params,
74 		   void *context)
75 {
76 	return wlan_twt_pause_req(psoc, params, context);
77 }
78 
79 QDF_STATUS
ucfg_twt_resume_req(struct wlan_objmgr_psoc * psoc,struct twt_resume_dialog_cmd_param * params,void * context)80 ucfg_twt_resume_req(struct wlan_objmgr_psoc *psoc,
81 		    struct twt_resume_dialog_cmd_param *params,
82 		    void *context)
83 {
84 	return wlan_twt_resume_req(psoc, params, context);
85 }
86 
87 QDF_STATUS
ucfg_twt_nudge_req(struct wlan_objmgr_psoc * psoc,struct twt_nudge_dialog_cmd_param * params,void * context)88 ucfg_twt_nudge_req(struct wlan_objmgr_psoc *psoc,
89 				   struct twt_nudge_dialog_cmd_param *params,
90 				   void *context)
91 {
92 	return wlan_twt_nudge_req(psoc, params, context);
93 }
94 
95 QDF_STATUS
ucfg_twt_ac_pdev_param_send(struct wlan_objmgr_psoc * psoc,enum twt_traffic_ac twt_ac)96 ucfg_twt_ac_pdev_param_send(struct wlan_objmgr_psoc *psoc,
97 			    enum twt_traffic_ac twt_ac)
98 {
99 	return wlan_twt_ac_pdev_param_send(psoc, twt_ac);
100 }
101 
ucfg_twt_is_max_sessions_reached(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * peer_mac,uint8_t dialog_id)102 bool ucfg_twt_is_max_sessions_reached(struct wlan_objmgr_psoc *psoc,
103 				      struct qdf_mac_addr *peer_mac,
104 				      uint8_t dialog_id)
105 {
106 	return wlan_twt_is_max_sessions_reached(psoc, peer_mac, dialog_id);
107 }
108 
ucfg_twt_is_setup_in_progress(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * peer_mac,uint8_t dialog_id)109 bool ucfg_twt_is_setup_in_progress(struct wlan_objmgr_psoc *psoc,
110 				   struct qdf_mac_addr *peer_mac,
111 				   uint8_t dialog_id)
112 {
113 	return wlan_twt_is_setup_in_progress(psoc, peer_mac, dialog_id);
114 }
115 
ucfg_twt_cfg_is_twt_enabled(struct wlan_objmgr_psoc * psoc)116 bool ucfg_twt_cfg_is_twt_enabled(struct wlan_objmgr_psoc *psoc)
117 {
118 	return wlan_twt_cfg_is_twt_enabled(psoc);
119 }
120 
121 QDF_STATUS
ucfg_twt_cfg_get_congestion_timeout(struct wlan_objmgr_psoc * psoc,uint32_t * val)122 ucfg_twt_cfg_get_congestion_timeout(struct wlan_objmgr_psoc *psoc,
123 				    uint32_t *val)
124 {
125 	return wlan_twt_cfg_get_congestion_timeout(psoc, val);
126 }
127 
128 QDF_STATUS
ucfg_twt_cfg_set_congestion_timeout(struct wlan_objmgr_psoc * psoc,uint32_t val)129 ucfg_twt_cfg_set_congestion_timeout(struct wlan_objmgr_psoc *psoc, uint32_t val)
130 {
131 	return wlan_twt_cfg_set_congestion_timeout(psoc, val);
132 }
133 
134 QDF_STATUS
ucfg_twt_cfg_get_24ghz_enabled(struct wlan_objmgr_psoc * psoc,bool * val)135 ucfg_twt_cfg_get_24ghz_enabled(struct wlan_objmgr_psoc *psoc, bool *val)
136 {
137 	return wlan_twt_cfg_get_24ghz_enabled(psoc, val);
138 }
139 
140 QDF_STATUS
ucfg_twt_cfg_get_bcast_requestor(struct wlan_objmgr_psoc * psoc,bool * val)141 ucfg_twt_cfg_get_bcast_requestor(struct wlan_objmgr_psoc *psoc, bool *val)
142 {
143 	return wlan_twt_cfg_get_bcast_requestor(psoc, val);
144 }
145 
146 QDF_STATUS
ucfg_twt_cfg_get_bcast_responder(struct wlan_objmgr_psoc * psoc,bool * val)147 ucfg_twt_cfg_get_bcast_responder(struct wlan_objmgr_psoc *psoc, bool *val)
148 {
149 	return wlan_twt_cfg_get_bcast_responder(psoc, val);
150 }
151 
152 QDF_STATUS
ucfg_twt_cfg_get_rtwt_requestor(struct wlan_objmgr_psoc * psoc,bool * val)153 ucfg_twt_cfg_get_rtwt_requestor(struct wlan_objmgr_psoc *psoc, bool *val)
154 {
155 	return wlan_twt_cfg_get_rtwt_requestor(psoc, val);
156 }
157 
158 QDF_STATUS
ucfg_twt_cfg_get_flex_sched(struct wlan_objmgr_psoc * psoc,bool * val)159 ucfg_twt_cfg_get_flex_sched(struct wlan_objmgr_psoc *psoc, bool *val)
160 {
161 	return wlan_twt_cfg_get_flex_sched(psoc, val);
162 }
163 
164 QDF_STATUS
ucfg_twt_init_context(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * peer_mac,uint8_t dialog_id)165 ucfg_twt_init_context(struct wlan_objmgr_psoc *psoc,
166 		      struct qdf_mac_addr *peer_mac,
167 		      uint8_t dialog_id)
168 {
169 	return wlan_twt_init_context(psoc, peer_mac, dialog_id);
170 }
171 
172 QDF_STATUS
ucfg_twt_set_osif_cb(osif_twt_get_global_ops_cb osif_twt_ops)173 ucfg_twt_set_osif_cb(osif_twt_get_global_ops_cb osif_twt_ops)
174 {
175 	mlme_set_osif_twt_cb(osif_twt_ops);
176 	return QDF_STATUS_SUCCESS;
177 }
178 
179 QDF_STATUS
ucfg_twt_set_command_in_progress(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * peer_mac,uint8_t dialog_id,enum wlan_twt_commands cmd)180 ucfg_twt_set_command_in_progress(struct wlan_objmgr_psoc *psoc,
181 				 struct qdf_mac_addr *peer_mac,
182 				 uint8_t dialog_id,
183 				 enum wlan_twt_commands cmd)
184 {
185 	return wlan_twt_set_command_in_progress(psoc, peer_mac,
186 						dialog_id, cmd);
187 }
188 
189 QDF_STATUS
ucfg_twt_reset_active_command(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * peer_mac,uint8_t dialog_id)190 ucfg_twt_reset_active_command(struct wlan_objmgr_psoc *psoc,
191 			      struct qdf_mac_addr *peer_mac,
192 			      uint8_t dialog_id)
193 {
194 	return wlan_twt_set_command_in_progress(psoc, peer_mac, dialog_id,
195 						WLAN_TWT_NONE);
196 }
197 
ucfg_twt_update_beacon_template(void)198 QDF_STATUS ucfg_twt_update_beacon_template(void)
199 {
200 	return wlan_twt_update_beacon_template();
201 }
202 
203 bool
ucfg_twt_is_setup_done(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * peer_mac,uint8_t dialog_id)204 ucfg_twt_is_setup_done(struct wlan_objmgr_psoc *psoc,
205 		       struct qdf_mac_addr *peer_mac, uint8_t dialog_id)
206 {
207 	return wlan_twt_is_setup_done(psoc, peer_mac, dialog_id);
208 }
209 
210 enum wlan_twt_session_state
ucfg_twt_get_session_state(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * peer_mac,uint8_t dialog_id)211 ucfg_twt_get_session_state(struct wlan_objmgr_psoc *psoc,
212 			   struct qdf_mac_addr *peer_mac, uint8_t dialog_id)
213 {
214 	return wlan_twt_get_session_state(psoc, peer_mac, dialog_id);
215 }
216 
ucfg_twt_is_command_in_progress(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * peer_mac,uint8_t dialog_id,enum wlan_twt_commands cmd,enum wlan_twt_commands * pactive_cmd)217 bool ucfg_twt_is_command_in_progress(struct wlan_objmgr_psoc *psoc,
218 				     struct qdf_mac_addr *peer_mac,
219 				     uint8_t dialog_id,
220 				     enum wlan_twt_commands cmd,
221 				     enum wlan_twt_commands *pactive_cmd)
222 {
223 	return wlan_twt_is_command_in_progress(psoc, peer_mac, dialog_id, cmd,
224 					       pactive_cmd);
225 }
226 
ucfg_twt_set_work_params(struct wlan_objmgr_vdev * vdev,struct qdf_mac_addr * peer_mac,uint8_t dialog_id,bool is_ps_disabled,uint32_t twt_next_action)227 void ucfg_twt_set_work_params(
228 		struct wlan_objmgr_vdev *vdev,
229 		struct qdf_mac_addr *peer_mac,
230 		uint8_t dialog_id,
231 		bool is_ps_disabled,
232 		uint32_t twt_next_action)
233 {
234 	return wlan_twt_set_work_params(vdev, peer_mac, dialog_id,
235 					is_ps_disabled, twt_next_action);
236 }
237 
ucfg_twt_get_work_params(struct wlan_objmgr_vdev * vdev,struct twt_work_params * params,uint32_t * next_action)238 void ucfg_twt_get_work_params(
239 		struct wlan_objmgr_vdev *vdev,
240 		struct twt_work_params *params,
241 		uint32_t *next_action)
242 {
243 	return wlan_twt_get_work_params(vdev, params, next_action);
244 }
245 
ucfg_twt_get_pmo_allowed(struct wlan_objmgr_psoc * psoc)246 bool ucfg_twt_get_pmo_allowed(struct wlan_objmgr_psoc *psoc)
247 {
248 	return wlan_twt_get_pmo_allowed(psoc);
249 }
250 
251