xref: /wlan-driver/qcacld-3.0/os_if/qmi/inc/os_if_qmi.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
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 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: os_if_qmi.h
19  *
20  * This file contains declarations for wrapper APIs for QMI HLOS APIs
21  */
22 
23 #ifndef _OS_IF_QMI_H_
24 #define _OS_IF_QMI_H_
25 
26 #include "wlan_qmi_public_struct.h"
27 #include <qdf_types.h>
28 #include <linux/soc/qcom/qmi.h>
29 #include <linux/net.h>
30 #include <linux/types.h>
31 #include "wlan_cfg80211.h"
32 #include "wlan_objmgr_psoc_obj.h"
33 #include <qdf_time.h>
34 
35 #define QMI_WFDS_MAX_RECV_BUF_SIZE  4096
36 #define QMI_WFDS_SERVICE_INS_ID_V01 0x0
37 #define QMI_WFDS_TIMEOUT_MS         10000
38 #define QMI_WFDS_TIMEOUT_JF         \
39 	qdf_system_msecs_to_ticks(QMI_WFDS_TIMEOUT_MS)
40 
41 /**
42  * enum os_if_qmi_wfds_ut_cmd_type - WFDS unit test command type
43  * @WFDS_STOP_TRAFFIC: Stop WFDS traffic
44  * @WFDS_START_TRAFFIC: Start WFDS Traffic
45  * @WFDS_GET_STATS: Get WFDS traffic stats
46  * @WFDS_START_WHC: Start WHC traffic
47  * @WFDS_START_TSF: Start TSF handshake
48  * @WFDS_CMD_MISC: Miscellaneous test
49  * @WFDS_CMD_MAX: Max test commands
50  */
51 enum os_if_qmi_wfds_ut_cmd_type {
52 	WFDS_STOP_TRAFFIC,
53 	WFDS_START_TRAFFIC,
54 	WFDS_GET_STATS,
55 	WFDS_START_WHC,
56 	WFDS_START_TSF,
57 	WFDS_CMD_MISC,
58 	WFDS_CMD_MAX,
59 };
60 
61 /**
62  * struct os_if_qmi_wfds_ut_cmd_info - WFDS UT cmd info structure
63  * @cmd: Command type
64  * @duration: Traffic duration
65  * @num_pkts: Buffers per flush
66  * @flush_period: Buffer flushing periodicity
67  * @buf_size: Buffer size
68  * @ether_type: ether_type of packet
69  * @dest_mac: Destination MAC address
70  * @src_mac: Source MAC address
71  * @dest_ip: Destination IPv4 address
72  * @src_ip: Source IPv4 address
73  * @dest_port: Destination port
74  */
75 struct os_if_qmi_wfds_ut_cmd_info {
76 	enum os_if_qmi_wfds_ut_cmd_type cmd;
77 	uint32_t duration;
78 	uint32_t flush_period;
79 	uint32_t num_pkts;
80 	uint32_t buf_size;
81 	uint16_t ether_type;
82 	struct qdf_mac_addr dest_mac;
83 	struct qdf_mac_addr src_mac;
84 	struct qdf_ipv4_addr dest_ip;
85 	struct qdf_ipv4_addr src_ip;
86 	uint16_t dest_port;
87 };
88 
89 #ifdef QMI_COMPONENT_ENABLE
90 /**
91  * os_if_qmi_handle_init() - Initialize QMI handle
92  * @qmi_hdl: QMI handle to initialize
93  * @recv_buf_size: maximum size of incoming message
94  * @ops: reference to callbacks for QRTR notifications
95  * @qmi_msg_handlers: NULL-terminated list of QMI message handlers
96  *
97  * Returns: QDF status
98  */
99 QDF_STATUS
100 os_if_qmi_handle_init(struct qmi_handle *qmi_hdl, qdf_size_t recv_buf_size,
101 		      const struct qmi_ops *ops,
102 		      const struct qmi_msg_handler *qmi_msg_handlers);
103 
104 /**
105  * os_if_qmi_handle_release() - Release QMI handle
106  * @qmi_hdl: QMI handle to release
107  *
108  * Returns: None
109  */
110 void os_if_qmi_handle_release(struct qmi_handle *qmi_hdl);
111 
112 /**
113  * os_if_qmi_add_lookup() - Register a new lookup with the name service
114  * @qmi_hdl: QMI handle
115  * @service: service id of the request
116  * @instance: instance id of the request
117  * @version: version number of the request
118  *
119  * Return: QDF status
120  */
121 QDF_STATUS os_if_qmi_add_lookup(struct qmi_handle *qmi_hdl,
122 				unsigned int service, unsigned int version,
123 				unsigned int instance);
124 
125 /**
126  * os_if_qmi_connect_to_svc() - Connect to QMI service
127  * @qmi_hdl: QMI handle
128  * @qmi_svc: QMI service handle
129  *
130  * Return: QDF status
131  */
132 QDF_STATUS os_if_qmi_connect_to_svc(struct qmi_handle *qmi_hdl,
133 				    struct qmi_service *qmi_svc);
134 
135 /**
136  * os_if_qmi_txn_init() - Initialize QMI transaction
137  * @qmi_hdl: QMI handle
138  * @qmi_txn: QMI transaction handle
139  * @qmi_ei: description of how to decode a matching response (optional)
140  * @resp: pointer to the object to decode the response into (optional)
141  *
142  * Return: QDF status
143  */
144 QDF_STATUS os_if_qmi_txn_init(struct qmi_handle *qmi_hdl,
145 			      struct qmi_txn *qmi_txn,
146 			      struct qmi_elem_info *qmi_ei, void *resp);
147 
148 /**
149  * os_if_qmi_send_request() - Connect to QMI service
150  * @qmi_hdl: QMI handle
151  * @sq: destination sockaddr
152  * @qmi_txn: QMI transaction handle
153  * @msg_id: message id
154  * @len: max length of the QMI message
155  * @ei: QMI message description
156  * @req: message to be encoded
157  *
158  * Return: QDF status
159  */
160 QDF_STATUS os_if_qmi_send_request(struct qmi_handle *qmi_hdl,
161 				  struct sockaddr_qrtr *sq,
162 				  struct qmi_txn *qmi_txn, int msg_id,
163 				  uint32_t len, struct qmi_elem_info *ei,
164 				  const void *req);
165 
166 /**
167  * os_if_qmi_txn_wait() - Wait for transaction response
168  * @qmi_txn: QMI transaction handle
169  * @timeout: Timeout value in jiffies
170  *
171  * Return: QDF status
172  */
173 QDF_STATUS os_if_qmi_txn_wait(struct qmi_txn *qmi_txn, unsigned long timeout);
174 
175 /**
176  * os_if_qmi_txn_cancel() - Cancel the QMI transaction
177  * @qmi_txn: QMI transaction handle
178  *
179  * Return: None
180  */
181 void os_if_qmi_txn_cancel(struct qmi_txn *qmi_txn);
182 
183 /**
184  * os_if_qmi_register_callbacks() - Register callback handlers
185  * @psoc: Pointer to psoc context
186  * @cb_obj: Callback object pointer
187  *
188  * Return: None
189  */
190 void os_if_qmi_register_callbacks(struct wlan_objmgr_psoc *psoc,
191 				  struct wlan_qmi_psoc_callbacks *cb_obj);
192 
193 #ifdef QMI_WFDS
194 /**
195  * os_if_qmi_wfds_register_callbacks() - Register WFDS callback handlers
196  * @cb_obj: Callback object pointer
197  *
198  * Return: None
199  */
200 void os_if_qmi_wfds_register_callbacks(struct wlan_qmi_psoc_callbacks *cb_obj);
201 
202 /**
203  * os_if_qmi_wfds_send_ut_cmd_req_msg() - Send WFDS unit test command
204  * @cmd_info: Unit test command info
205  *
206  * Return: QDF_STATUS
207  */
208 QDF_STATUS
209 os_if_qmi_wfds_send_ut_cmd_req_msg(struct os_if_qmi_wfds_ut_cmd_info *cmd_info);
210 
211 #else
212 static inline
os_if_qmi_wfds_register_callbacks(struct wlan_qmi_psoc_callbacks * cb_obj)213 void os_if_qmi_wfds_register_callbacks(struct wlan_qmi_psoc_callbacks *cb_obj)
214 {
215 }
216 
217 static inline QDF_STATUS
os_if_qmi_wfds_send_ut_cmd_req_msg(struct os_if_qmi_wfds_ut_cmd_info * cmd_info)218 os_if_qmi_wfds_send_ut_cmd_req_msg(struct os_if_qmi_wfds_ut_cmd_info *cmd_info)
219 {
220 }
221 #endif
222 #else
223 static inline
os_if_qmi_handle_init(struct qmi_handle * qmi_hdl,qdf_size_t recv_buf_size,const struct qmi_ops * ops,const struct qmi_msg_handler * qmi_msg_handlers)224 QDF_STATUS os_if_qmi_handle_init(struct qmi_handle *qmi_hdl,
225 				 qdf_size_t recv_buf_size,
226 				 const struct qmi_ops *ops,
227 				 const struct qmi_msg_handler *qmi_msg_handlers)
228 {
229 	return QDF_STATUS_E_NOSUPPORT;
230 }
231 
232 static inline
os_if_qmi_handle_release(struct qmi_handle * qmi_hdl)233 void os_if_qmi_handle_release(struct qmi_handle *qmi_hdl)
234 {
235 }
236 
237 static inline
os_if_qmi_add_lookup(struct qmi_handle * qmi_hdl,unsigned int service,unsigned int version,unsigned int instance)238 QDF_STATUS os_if_qmi_add_lookup(struct qmi_handle *qmi_hdl,
239 				unsigned int service, unsigned int version,
240 				unsigned int instance)
241 {
242 	return QDF_STATUS_E_NOSUPPORT;
243 }
244 
245 static inline
os_if_qmi_connect_to_svc(struct qmi_handle * qmi_hdl,struct qmi_service * qmi_svc)246 QDF_STATUS os_if_qmi_connect_to_svc(struct qmi_handle *qmi_hdl,
247 				    struct qmi_service *qmi_svc)
248 {
249 	return QDF_STATUS_E_NOSUPPORT;
250 }
251 
252 static inline
os_if_qmi_txn_init(struct qmi_handle * qmi_hdl,struct qmi_txn * qmi_txn,struct qmi_elem_info * qmi_ei,void * resp)253 QDF_STATUS os_if_qmi_txn_init(struct qmi_handle *qmi_hdl,
254 			      struct qmi_txn *qmi_txn,
255 			      struct qmi_elem_info *qmi_ei, void *resp)
256 {
257 	return QDF_STATUS_E_NOSUPPORT;
258 }
259 
260 static inline
os_if_qmi_send_request(struct qmi_handle * qmi_hdl,struct sockaddr_qrtr * sq,struct qmi_txn * qmi_txn,int msg_id,uint32_t len,struct qmi_elem_info * ei,const void * req)261 QDF_STATUS os_if_qmi_send_request(struct qmi_handle *qmi_hdl,
262 				  struct sockaddr_qrtr *sq,
263 				  struct qmi_txn *qmi_txn, int msg_id,
264 				  uint32_t len, struct qmi_elem_info *ei,
265 				  const void *req)
266 {
267 	return QDF_STATUS_E_NOSUPPORT;
268 }
269 
270 static inline
os_if_qmi_txn_wait(struct qmi_txn * qmi_txn,unsigned long timeout)271 QDF_STATUS os_if_qmi_txn_wait(struct qmi_txn *qmi_txn, unsigned long timeout)
272 {
273 	return QDF_STATUS_E_NOSUPPORT;
274 }
275 
276 static inline
os_if_qmi_txn_cancel(struct qmi_txn * qmi_txn)277 void os_if_qmi_txn_cancel(struct qmi_txn *qmi_txn)
278 {
279 }
280 
281 static inline
os_if_qmi_register_callbacks(struct wlan_objmgr_psoc * psoc,struct wlan_qmi_psoc_callbacks * cb_obj)282 void os_if_qmi_register_callbacks(struct wlan_objmgr_psoc *psoc,
283 				  struct wlan_qmi_psoc_callbacks *cb_obj)
284 {
285 }
286 #endif
287 #endif
288