1 /*
2 * Copyright (c) 2012-2017, 2020 The Linux Foundation. All rights reserved.
3 * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for
6 * any purpose with or without fee is hereby granted, provided that the
7 * above copyright notice and this permission notice appear in all
8 * copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
18 */
19
20 /**
21 * DOC: os_if_wifi_pos.h
22 * This file provide declaration of wifi_pos's os_if APIs
23 */
24 #ifndef _OS_IF_WIFI_POS_H_
25 #define _OS_IF_WIFI_POS_H_
26
27 #include "qdf_types.h"
28 #include "qdf_status.h"
29 #include <wlan_objmgr_cmn.h>
30 #include "wifi_pos_public_struct.h"
31 #include "wlan_cfg80211.h"
32
33 /* forward declaration */
34 struct wifi_pos_ch_info;
35 struct wlan_objmgr_psoc;
36 struct wifi_pos_driver_caps;
37
38 #ifdef WIFI_POS_CONVERGED
39 #define FEATURE_WIFI_POS_11AZ_AUTH_EVENTS \
40 [QCA_NL80211_VENDOR_SUBCMD_PASN_AUTH_STATUS_INDEX] = { \
41 .vendor_id = QCA_NL80211_VENDOR_ID, \
42 .subcmd = QCA_NL80211_VENDOR_SUBCMD_PASN, \
43 },
44
45 /**
46 * os_if_wifi_pos_register_nl() - abstraction API to register callback with GENL
47 * socket.
48 *
49 * Return: status of operation
50 */
51 int os_if_wifi_pos_register_nl(void);
52
53 /**
54 * os_if_wifi_pos_deregister_nl() - abstraction API to deregister callback with
55 * GENL socket.
56 *
57 * Return: status of operation
58 */
59 int os_if_wifi_pos_deregister_nl(void);
60
61 /**
62 * os_if_wifi_pos_send_peer_status() - Function to send peer status to a
63 * registered application
64 * @peer_mac: MAC address of peer
65 * @peer_status: ePeerConnected or ePeerDisconnected
66 * @peer_timing_meas_cap: 0: RTT/RTT2, 1: RTT3. Default is 0
67 * @session_id: SME session id, i.e. vdev_id
68 * @chan_info: operating channel information
69 * @dev_mode: dev mode for which indication is sent
70 *
71 * Return: none
72 */
73 void os_if_wifi_pos_send_peer_status(struct qdf_mac_addr *peer_mac,
74 uint8_t peer_status,
75 uint8_t peer_timing_meas_cap,
76 uint8_t session_id,
77 struct wifi_pos_ch_info *chan_info,
78 enum QDF_OPMODE dev_mode);
79
80 /**
81 * os_if_wifi_pos_populate_caps() - populate oem capabilities
82 * @psoc: psoc object
83 * @caps: pointer to populate the capabilities
84 *
85 * Return: error code
86 */
87 int os_if_wifi_pos_populate_caps(struct wlan_objmgr_psoc *psoc,
88 struct wifi_pos_driver_caps *caps);
89 #else
90 #define FEATURE_WIFI_POS_11AZ_AUTH_EVENTS
91
os_if_wifi_pos_register_nl(void)92 static inline int os_if_wifi_pos_register_nl(void)
93 {
94 return 0;
95 }
96
os_if_wifi_pos_deregister_nl(void)97 static inline int os_if_wifi_pos_deregister_nl(void)
98 {
99 return 0;
100 }
101
os_if_wifi_pos_send_peer_status(struct qdf_mac_addr * peer_mac,uint8_t peer_status,uint8_t peer_timing_meas_cap,uint8_t session_id,struct wifi_pos_ch_info * chan_info,enum QDF_OPMODE dev_mode)102 static inline void os_if_wifi_pos_send_peer_status(
103 struct qdf_mac_addr *peer_mac,
104 uint8_t peer_status,
105 uint8_t peer_timing_meas_cap,
106 uint8_t session_id,
107 struct wifi_pos_ch_info *chan_info,
108 enum QDF_OPMODE dev_mode)
109 {
110 }
111
os_if_wifi_pos_populate_caps(struct wlan_objmgr_psoc * psoc,struct wifi_pos_driver_caps * caps)112 static inline int os_if_wifi_pos_populate_caps(struct wlan_objmgr_psoc *psoc,
113 struct wifi_pos_driver_caps *caps)
114 {
115 return 0;
116 }
117 #endif
118
119 #ifdef CNSS_GENL
120 /**
121 * enum cld80211_vendor_sub_cmds
122 * @CLD80211_VENDOR_SUB_CMD_INVALID: invalid cmd type
123 * @CLD80211_VENDOR_SUB_CMD_REGISTRATION: app registration
124 * @CLD80211_VENDOR_SUB_CMD_SET_CAPS: set driver capabilities
125 * @CLD80211_VENDOR_SUB_CMD_GET_CAPS: get driver capabilities
126 * @CLD80211_VENDOR_SUB_CMD_GET_CH_INFO: get channel info
127 * @CLD80211_VENDOR_SUB_CMD_OEM_DATA: oem data req/rsp
128 * @CLD80211_VENDOR_SUB_CMD_OEM_ERROR: oem error rsp
129 * @CLD80211_VENDOR_SUB_CMD_PEER_STATUS_IND: peer status indication
130 * @CLD80211_VENDOR_SUB_CMD__AFTER_LAST: internal marker
131 * @CLD80211_VENDOR_SUB_CMD_MAX: Max cld80211 vendor sub cmds
132 */
133 enum cld80211_vendor_sub_cmds {
134 CLD80211_VENDOR_SUB_CMD_INVALID = 0,
135 CLD80211_VENDOR_SUB_CMD_REGISTRATION = 1,
136 CLD80211_VENDOR_SUB_CMD_SET_CAPS = 2,
137 CLD80211_VENDOR_SUB_CMD_GET_CAPS = 3,
138 CLD80211_VENDOR_SUB_CMD_GET_CH_INFO = 4,
139 CLD80211_VENDOR_SUB_CMD_OEM_DATA = 5,
140 CLD80211_VENDOR_SUB_CMD_OEM_ERROR = 6,
141 CLD80211_VENDOR_SUB_CMD_PEER_STATUS_IND = 7,
142 /* keep last */
143 CLD80211_VENDOR_SUB_CMD__AFTER_LAST,
144 CLD80211_VENDOR_SUB_CMD_MAX =
145 CLD80211_VENDOR_SUB_CMD__AFTER_LAST - 1
146 };
147
148 /**
149 * enum cld80211_sub_attr_cap_rsp - Capability response sub attribute
150 * @CLD80211_SUB_ATTR_CAPS_INVALID: Invalid capability
151 * @CLD80211_SUB_ATTR_CAPS_OEM_TARGET_SIGNATURE: OEM target signature
152 * @CLD80211_SUB_ATTR_CAPS_OEM_TARGET_TYPE: OEM target type
153 * @CLD80211_SUB_ATTR_CAPS_OEM_FW_VERSION: OEM firmware version
154 * @CLD80211_SUB_ATTR_CAPS_DRIVER_VERSION_MAJOR: Driver version major
155 * @CLD80211_SUB_ATTR_CAPS_DRIVER_VERSION_MINOR: Driver version minor
156 * @CLD80211_SUB_ATTR_CAPS_DRIVER_VERSION_PATCH: Driver version patch
157 * @CLD80211_SUB_ATTR_CAPS_DRIVER_VERSION_BUILD: Driver version build
158 * @CLD80211_SUB_ATTR_CAPS_ALLOWED_DWELL_TIME_MIN: Allowed dwell time min
159 * @CLD80211_SUB_ATTR_CAPS_ALLOWED_DWELL_TIME_MAX: Allowed dwell time max
160 * @CLD80211_SUB_ATTR_CAPS_CURRENT_DWELL_TIME_MIN: Current dwell time min
161 * @CLD80211_SUB_ATTR_CAPS_CURRENT_DWELL_TIME_MAX: Current dwell time max
162 * @CLD80211_SUB_ATTR_CAPS_SUPPORTED_BANDS: Supported bands
163 * @CLD80211_SUB_ATTR_CAPS_USER_DEFINED_CAPS: User defined capabilities
164 * @CLD80211_SUB_ATTR_CAPS_AFTER_LAST: internal marker
165 * @CLD80211_SUB_ATTR_CAPS_MAX: Max number for CAP sub attribute
166 *
167 */
168 enum cld80211_sub_attr_cap_rsp {
169 CLD80211_SUB_ATTR_CAPS_INVALID = 0,
170 CLD80211_SUB_ATTR_CAPS_OEM_TARGET_SIGNATURE = 1,
171 CLD80211_SUB_ATTR_CAPS_OEM_TARGET_TYPE = 2,
172 CLD80211_SUB_ATTR_CAPS_OEM_FW_VERSION = 3,
173 CLD80211_SUB_ATTR_CAPS_DRIVER_VERSION_MAJOR = 4,
174 CLD80211_SUB_ATTR_CAPS_DRIVER_VERSION_MINOR = 5,
175 CLD80211_SUB_ATTR_CAPS_DRIVER_VERSION_PATCH = 6,
176 CLD80211_SUB_ATTR_CAPS_DRIVER_VERSION_BUILD = 7,
177 CLD80211_SUB_ATTR_CAPS_ALLOWED_DWELL_TIME_MIN = 8,
178 CLD80211_SUB_ATTR_CAPS_ALLOWED_DWELL_TIME_MAX = 9,
179 CLD80211_SUB_ATTR_CAPS_CURRENT_DWELL_TIME_MIN = 10,
180 CLD80211_SUB_ATTR_CAPS_CURRENT_DWELL_TIME_MAX = 11,
181 CLD80211_SUB_ATTR_CAPS_SUPPORTED_BANDS = 12,
182 CLD80211_SUB_ATTR_CAPS_USER_DEFINED_CAPS = 13,
183
184 /* keep last */
185 CLD80211_SUB_ATTR_CAPS_AFTER_LAST,
186 CLD80211_SUB_ATTR_CAPS_MAX =
187 CLD80211_SUB_ATTR_CAPS_AFTER_LAST - 1
188 };
189
190 /**
191 * enum cld80211_sub_attr_channel_rsp - Chan info response sub attribute
192 * @CLD80211_SUB_ATTR_CH_RESP_INVALID: Invalid channel resp
193 * @CLD80211_SUB_ATTR_CH_MORE_DATA: More date sub attr for frag response
194 * @CLD80211_SUB_ATTR_CHANNEL_NUM_CHAN: Number of channels in response
195 * @CLD80211_SUB_ATTR_CH_LIST: Channel list nesting
196 * @CLD80211_SUB_ATTR_CH_CHAN_ID: Channel number
197 * @CLD80211_SUB_ATTR_CH_MHZ: Channel frequency
198 * @CLD80211_SUB_ATTR_CH_BAND_CF_1: Center frequency 1
199 * @CLD80211_SUB_ATTR_CH_BAND_CF_2: Center frequency 2
200 * @CLD80211_SUB_ATTR_CH_INFO: channel info
201 * @CLD80211_SUB_ATTR_CH_REG_INFO_1: regulatory info field 1
202 * @CLD80211_SUB_ATTR_CH_REG_INFO_2: regulatory info field 2
203 * @CLD80211_SUB_ATTR_CH_AFTER_LAST: internal marker
204 * @CLD80211_SUB_ATTR_CH_MAX: Max number for CHAN Info sub attribute
205 *
206 */
207 enum cld80211_sub_attr_channel_rsp {
208 CLD80211_SUB_ATTR_CH_RESP_INVALID = 0,
209 CLD80211_SUB_ATTR_CH_MORE_DATA = 1,
210 CLD80211_SUB_ATTR_CHANNEL_NUM_CHAN = 2,
211 CLD80211_SUB_ATTR_CH_LIST = 3,
212 /* CH_* belongs to CH_LIST */
213 CLD80211_SUB_ATTR_CH_CHAN_ID = 4,
214 CLD80211_SUB_ATTR_CH_MHZ = 5,
215 CLD80211_SUB_ATTR_CH_BAND_CF_1 = 6,
216 CLD80211_SUB_ATTR_CH_BAND_CF_2 = 7,
217 CLD80211_SUB_ATTR_CH_INFO = 8,
218 CLD80211_SUB_ATTR_CH_REG_INFO_1 = 9,
219 CLD80211_SUB_ATTR_CH_REG_INFO_2 = 10,
220
221 /* keep last */
222 CLD80211_SUB_ATTR_CH_AFTER_LAST,
223 CLD80211_SUB_ATTR_CH_MAX =
224 CLD80211_SUB_ATTR_CH_AFTER_LAST - 1
225
226 };
227
228 /**
229 * enum cld80211_sub_attr_oem_data_req - OEM data req sub attribute
230 * @CLD80211_SUB_ATTR_MSG_OEM_DATA_INVALID: Invalid OEM data request
231 * @CLD80211_SUB_ATTR_MSG_OEM_DATA_FW: Data to Firmware
232 * @CLD80211_SUB_ATTR_MSG_OEM_DATA_DRIVER: Data to driver
233 * @CLD80211_SUB_ATTR_MSG_OEM_DATA_REQ_AFTER_LAST: internal marker
234 * @CLD80211_SUB_ATTR_MSG_OEM_DATA_REQ_MAX: Max number for OEM data req sub
235 * attribute
236 *
237 * OEM data request sub attributes are NLA attributes in NLA type OEM data
238 * request.
239 *
240 */
241 enum cld80211_sub_attr_oem_data_req {
242 CLD80211_SUB_ATTR_MSG_OEM_DATA_INVALID = 0,
243 CLD80211_SUB_ATTR_MSG_OEM_DATA_FW = 1,
244 CLD80211_SUB_ATTR_MSG_OEM_DATA_DRIVER = 2,
245
246 /* keep last */
247 CLD80211_SUB_ATTR_MSG_OEM_DATA_REQ_AFTER_LAST,
248 CLD80211_SUB_ATTR_MSG_OEM_DATA_REQ_MAX =
249 CLD80211_SUB_ATTR_MSG_OEM_DATA_REQ_AFTER_LAST - 1
250 };
251
252 /**
253 * enum cld80211_sub_attr_oem_data_resp - OEM message sub attribute
254 * @CLD80211_SUB_ATTR_OEM_DATA_INVALID: Invalid oem data resp
255 * @CLD80211_SUB_ATTR_OEM_MORE_DATA: more date sub attribute
256 * @CLD80211_SUB_ATTR_BINARY_DATA: Binary data sub attribute
257 * @CLD80211_SUB_ATTR_OEM_DATA_RESP_AFTER_LAST: internal marker
258 * @CLD80211_SUB_ATTR_OEM_DATA_RESP_MAX: Max number for OEM data resp
259 * sub attribute
260 *
261 * OEM message sub attributes are interface between apps and driver to
262 * process NLA type request and response messages.
263 *
264 */
265 enum cld80211_sub_attr_oem_data_resp {
266 CLD80211_SUB_ATTR_OEM_DATA_INVALID = 0,
267 CLD80211_SUB_ATTR_OEM_MORE_DATA = 1,
268 CLD80211_SUB_ATTR_BINARY_DATA = 2,
269
270 /* keep last */
271 CLD80211_SUB_ATTR_OEM_DATA_RESP_AFTER_LAST,
272 CLD80211_SUB_ATTR_OEM_DATA_RESP_MAX =
273 CLD80211_SUB_ATTR_OEM_DATA_RESP_AFTER_LAST - 1
274 };
275
276 /**
277 * enum cld80211_sub_attr_peer_info - peer info sub attribute
278 * @CLD80211_SUB_ATTR_PEER_INVALID: Invalid peer info
279 * @CLD80211_SUB_ATTR_PEER_MAC_ADDR: peer mac address
280 * @CLD80211_SUB_ATTR_PEER_STATUS: peer status
281 * @CLD80211_SUB_ATTR_PEER_VDEV_ID: peer vdevid
282 * @CLD80211_SUB_ATTR_PEER_CAPABILITY: peer capabilities
283 * @CLD80211_SUB_ATTR_PEER_RESERVED: reserved bytes
284 * @CLD80211_SUB_ATTR_PEER_CHAN_INFO: peer channel info
285 * @CLD80211_SUB_ATTR_PEER_AFTER_LAST: internal marker
286 * @CLD80211_SUB_ATTR_PEER_MAX: Max number for peer sub attribute
287 *
288 */
289 enum cld80211_sub_attr_peer_info {
290 CLD80211_SUB_ATTR_PEER_INVALID = 0,
291 CLD80211_SUB_ATTR_PEER_MAC_ADDR = 1,
292 CLD80211_SUB_ATTR_PEER_STATUS = 2,
293 CLD80211_SUB_ATTR_PEER_VDEV_ID = 3,
294 CLD80211_SUB_ATTR_PEER_CAPABILITY = 4,
295 CLD80211_SUB_ATTR_PEER_RESERVED = 5,
296 CLD80211_SUB_ATTR_PEER_CHAN_INFO = 6,
297
298 /* keep last */
299 CLD80211_SUB_ATTR_PEER_AFTER_LAST,
300 CLD80211_SUB_ATTR_PEER_MAX =
301 CLD80211_SUB_ATTR_PEER_AFTER_LAST - 1
302 };
303 #endif
304
305 #if defined(WIFI_POS_CONVERGED) && defined(WLAN_FEATURE_RTT_11AZ_SUPPORT)
306 /**
307 * os_if_wifi_pos_initiate_pasn_auth() - Initiate PASN authentication from
308 * userspace
309 * @vdev: Vdev object pointer
310 * @pasn_peer: PASN Peer list
311 * @num_pasn_peers: number of PASN peers
312 * @is_initiate_pasn: Initiate pasn or initiate flush keys
313 *
314 * Return: QDF_STATUS
315 */
316 QDF_STATUS os_if_wifi_pos_initiate_pasn_auth(struct wlan_objmgr_vdev *vdev,
317 struct wlan_pasn_request *pasn_peer,
318 uint8_t num_pasn_peers,
319 bool is_initiate_pasn);
320 #else
321 static inline
os_if_wifi_pos_initiate_pasn_auth(struct wlan_objmgr_vdev * vdev,struct wlan_pasn_request * pasn_peer,uint8_t num_pasn_peers,bool is_initiate_pasn)322 QDF_STATUS os_if_wifi_pos_initiate_pasn_auth(struct wlan_objmgr_vdev *vdev,
323 struct wlan_pasn_request *pasn_peer,
324 uint8_t num_pasn_peers,
325 bool is_initiate_pasn)
326 {
327 return QDF_STATUS_E_NOSUPPORT;
328 }
329 #endif /* WLAN_FEATURE_RTT_11AZ_SUPPORT */
330 #endif /* _OS_IF_WIFI_POS_H_ */
331