1 /*
2  * Copyright (c) 2022 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 /**
19  * DOC: wlan_twt_tgt_if_ext_tx_api.c
20  *
21  * This file provides definitions for twt tgt_if APIs, which will
22  * further call target_if component using LMAC TWT txops
23  */
24 #include <qdf_types.h>
25 #include <wlan_objmgr_psoc_obj.h>
26 #include <wlan_twt_public_structs.h>
27 #include <wlan_twt_api.h>
28 #include <wlan_twt_tgt_if_ext_tx_api.h>
29 #include <wlan_lmac_if_def.h>
30 
31 QDF_STATUS
tgt_twt_setup_req_send(struct wlan_objmgr_psoc * psoc,struct twt_add_dialog_param * req)32 tgt_twt_setup_req_send(struct wlan_objmgr_psoc *psoc,
33 		       struct twt_add_dialog_param *req)
34 {
35 	struct wlan_lmac_if_twt_tx_ops *tx_ops;
36 	QDF_STATUS status;
37 
38 	if (!psoc) {
39 		twt_err("psoc is null");
40 		return QDF_STATUS_E_INVAL;
41 	}
42 
43 	if (!req) {
44 		twt_err("Invalid input");
45 		return QDF_STATUS_E_INVAL;
46 	}
47 
48 	tx_ops = wlan_twt_get_tx_ops(psoc);
49 	if (!tx_ops || !tx_ops->setup_req) {
50 		twt_err("setup_req tx_ops is null");
51 		status = QDF_STATUS_E_NULL_VALUE;
52 		return status;
53 	}
54 
55 	status = tx_ops->setup_req(psoc, req);
56 
57 	return status;
58 }
59 
60 QDF_STATUS
tgt_twt_teardown_req_send(struct wlan_objmgr_psoc * psoc,struct twt_del_dialog_param * req)61 tgt_twt_teardown_req_send(struct wlan_objmgr_psoc *psoc,
62 			  struct twt_del_dialog_param *req)
63 {
64 	struct wlan_lmac_if_twt_tx_ops *tx_ops;
65 	QDF_STATUS status;
66 
67 	if (!psoc) {
68 		twt_err("psoc is null");
69 		return QDF_STATUS_E_INVAL;
70 	}
71 
72 	if (!req) {
73 		twt_err("Invalid input");
74 		return QDF_STATUS_E_INVAL;
75 	}
76 
77 	tx_ops = wlan_twt_get_tx_ops(psoc);
78 	if (!tx_ops || !tx_ops->teardown_req) {
79 		twt_err("teardown_req tx_ops is null");
80 		status = QDF_STATUS_E_NULL_VALUE;
81 		return status;
82 	}
83 
84 	status = tx_ops->teardown_req(psoc, req);
85 
86 	return status;
87 }
88 
89 QDF_STATUS
tgt_twt_pause_req_send(struct wlan_objmgr_psoc * psoc,struct twt_pause_dialog_cmd_param * req)90 tgt_twt_pause_req_send(struct wlan_objmgr_psoc *psoc,
91 		       struct twt_pause_dialog_cmd_param *req)
92 {
93 	struct wlan_lmac_if_twt_tx_ops *tx_ops;
94 	QDF_STATUS status;
95 
96 	if (!psoc) {
97 		twt_err("psoc is null");
98 		return QDF_STATUS_E_INVAL;
99 	}
100 
101 	if (!req) {
102 		twt_err("Invalid input");
103 		return QDF_STATUS_E_INVAL;
104 	}
105 
106 	tx_ops = wlan_twt_get_tx_ops(psoc);
107 	if (!tx_ops || !tx_ops->pause_req) {
108 		twt_err("pause tx_ops is null");
109 		status = QDF_STATUS_E_NULL_VALUE;
110 		return status;
111 	}
112 
113 	status = tx_ops->pause_req(psoc, req);
114 
115 	return status;
116 }
117 
118 QDF_STATUS
tgt_twt_resume_req_send(struct wlan_objmgr_psoc * psoc,struct twt_resume_dialog_cmd_param * req)119 tgt_twt_resume_req_send(struct wlan_objmgr_psoc *psoc,
120 			struct twt_resume_dialog_cmd_param *req)
121 {
122 	struct wlan_lmac_if_twt_tx_ops *tx_ops;
123 	QDF_STATUS status;
124 
125 	if (!psoc) {
126 		twt_err("psoc is null");
127 		return QDF_STATUS_E_INVAL;
128 	}
129 
130 	if (!req) {
131 		twt_err("Invalid input");
132 		return QDF_STATUS_E_INVAL;
133 	}
134 
135 	tx_ops = wlan_twt_get_tx_ops(psoc);
136 	if (!tx_ops || !tx_ops->resume_req) {
137 		twt_err("resume tx_ops is null");
138 		status = QDF_STATUS_E_NULL_VALUE;
139 		return status;
140 	}
141 
142 	status = tx_ops->resume_req(psoc, req);
143 
144 	return status;
145 }
146 
147 QDF_STATUS
tgt_twt_nudge_req_send(struct wlan_objmgr_psoc * psoc,struct twt_nudge_dialog_cmd_param * req)148 tgt_twt_nudge_req_send(struct wlan_objmgr_psoc *psoc,
149 		       struct twt_nudge_dialog_cmd_param *req)
150 {
151 	struct wlan_lmac_if_twt_tx_ops *tx_ops;
152 	QDF_STATUS status;
153 
154 	if (!psoc) {
155 		twt_err("psoc is null");
156 		return QDF_STATUS_E_INVAL;
157 	}
158 
159 	if (!req) {
160 		twt_err("Invalid input");
161 		return QDF_STATUS_E_INVAL;
162 	}
163 
164 	tx_ops = wlan_twt_get_tx_ops(psoc);
165 	if (!tx_ops || !tx_ops->nudge_req) {
166 		twt_err("nudge tx_ops is null");
167 		status = QDF_STATUS_E_NULL_VALUE;
168 		return status;
169 	}
170 
171 	status = tx_ops->nudge_req(psoc, req);
172 
173 	return status;
174 }
175 
176 QDF_STATUS
tgt_twt_ac_pdev_param_send(struct wlan_objmgr_psoc * psoc,enum twt_traffic_ac twt_ac)177 tgt_twt_ac_pdev_param_send(struct wlan_objmgr_psoc *psoc,
178 			   enum twt_traffic_ac twt_ac)
179 {
180 	struct wlan_lmac_if_twt_tx_ops *tx_ops;
181 	QDF_STATUS status;
182 
183 	if (!psoc) {
184 		twt_err("psoc is null");
185 		return QDF_STATUS_E_INVAL;
186 	}
187 
188 	tx_ops = wlan_twt_get_tx_ops(psoc);
189 	if (!tx_ops || !tx_ops->set_ac_param) {
190 		twt_err("set_ac_param is null");
191 		status = QDF_STATUS_E_NULL_VALUE;
192 		return status;
193 	}
194 
195 	status = tx_ops->set_ac_param(psoc, twt_ac, 0);
196 
197 	return status;
198 }
199 
200