1 /* 2 * Copyright (c) 2012-2015, 2020-2021 The Linux Foundation. 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: osif_cm_util.h 19 * 20 * This header file maintains declarations of connect, disconnect, roam 21 * common apis. 22 */ 23 24 #ifndef __OSIF_CM_UTIL_H 25 #define __OSIF_CM_UTIL_H 26 27 #include <qca_vendor.h> 28 #include "wlan_cm_ucfg_api.h" 29 #include "wlan_cm_public_struct.h" 30 #ifdef CONN_MGR_ADV_FEATURE 31 #include <cdp_txrx_mob_def.h> 32 #endif 33 34 /** 35 * osif_cm_mac_to_qca_connect_fail_reason() - Convert to qca internal connect 36 * fail reason 37 * @internal_reason: Mac reason code of type @wlan_status_code 38 * 39 * Check if it is internal status code and convert it to the 40 * enum qca_sta_connect_fail_reason_codes. 41 * 42 * Return: Reason code of type enum qca_sta_connect_fail_reason_codes 43 */ 44 enum qca_sta_connect_fail_reason_codes 45 osif_cm_mac_to_qca_connect_fail_reason(enum wlan_status_code internal_reason); 46 47 /** 48 * osif_cm_qca_reason_to_str() - return string conversion of qca reason code 49 * @reason: enum qca_disconnect_reason_codes 50 * 51 * This utility function helps log string conversion of qca reason code. 52 * 53 * Return: string conversion of reason code, if match found; 54 * "Unknown" otherwise. 55 */ 56 const char * 57 osif_cm_qca_reason_to_str(enum qca_disconnect_reason_codes reason); 58 59 /** 60 * osif_cm_mac_to_qca_reason() - Convert to qca internal disconnect reason 61 * @internal_reason: Mac reason code of type @wlan_reason_code 62 * 63 * Check if it is internal reason code and convert it to the 64 * enum qca_disconnect_reason_codes. 65 * 66 * Return: Reason code of type enum qca_disconnect_reason_codes 67 */ 68 enum qca_disconnect_reason_codes 69 osif_cm_mac_to_qca_reason(enum wlan_reason_code internal_reason); 70 71 #ifdef FEATURE_CM_ENABLE 72 /** 73 * osif_cm_register_cb() - API to register connection manager 74 * callbacks. 75 * 76 * Return: QDF_STATUS 77 */ 78 QDF_STATUS osif_cm_register_cb(void); 79 80 /** 81 * osif_cm_osif_priv_init() - API to init osif priv data for connection manager 82 * @vdev: vdev pointer 83 * 84 * Return: QDF_STATUS 85 */ 86 QDF_STATUS osif_cm_osif_priv_init(struct wlan_objmgr_vdev *vdev); 87 88 /** 89 * osif_cm_osif_priv_deinit() - API to deinit osif priv data for connection 90 * manager 91 * @vdev: vdev pointer 92 * 93 * Return: QDF_STATUS 94 */ 95 QDF_STATUS osif_cm_osif_priv_deinit(struct wlan_objmgr_vdev *vdev); 96 97 /** 98 * osif_cm_reset_id_and_src_no_lock() - Function to resets last 99 * connection manager command id and source in osif 100 * @osif_priv: Pointer to vdev osif priv 101 * 102 * This function resets the last connection manager command id 103 * and source. 104 * 105 * Context: Any context. This function should be called by holding 106 * cmd id spinlock 107 * Return: None 108 */ 109 110 void osif_cm_reset_id_and_src_no_lock(struct vdev_osif_priv *osif_priv); 111 112 /** 113 * osif_cm_reset_id_and_src() - Function to resets last 114 * connection manager command id and source in osif 115 * @vdev: vdev pointer 116 * 117 * This function resets the last connection manager command id 118 * and source. 119 * 120 * Context: Any context. Takes and release cmd id spinlock 121 * Return: None 122 */ 123 QDF_STATUS osif_cm_reset_id_and_src(struct wlan_objmgr_vdev *vdev); 124 125 /** 126 * enum osif_cb_type - Type of the update from osif to legacy module 127 * @OSIF_POST_USERSPACE_UPDATE: Indicates that when this update is received 128 * userspace is already updated. 129 * @OSIF_PRE_USERSPACE_UPDATE: Indicates that when this update is received 130 * userspace is not yet updated. 131 * @OSIF_NOT_HANDLED: Indicates that last command is not handled 132 */ 133 134 enum osif_cb_type { 135 OSIF_POST_USERSPACE_UPDATE, 136 OSIF_PRE_USERSPACE_UPDATE, 137 OSIF_NOT_HANDLED, 138 }; 139 140 /** 141 * typedef osif_cm_connect_comp_cb - Connect complete callback 142 * @vdev: vdev pointer 143 * @rsp: connect response 144 * @type: indicates update type 145 * 146 * This callback indicates connect complete to the legacy module 147 * 148 * Context: Any context. 149 * Return: QDF_STATUS 150 */ 151 typedef QDF_STATUS 152 (*osif_cm_connect_comp_cb)(struct wlan_objmgr_vdev *vdev, 153 struct wlan_cm_connect_resp *rsp, 154 enum osif_cb_type type); 155 156 #ifdef WLAN_FEATURE_FILS_SK 157 /** 158 * typedef osif_cm_save_gtk_cb - save gtk callback 159 * @vdev: vdev pointer 160 * @rsp: connect response 161 * 162 * this callback save gtk to the legacy module 163 * 164 * context: any context. 165 * return: qdf_status 166 */ 167 typedef QDF_STATUS (*osif_cm_save_gtk_cb)(struct wlan_objmgr_vdev *vdev, 168 struct wlan_cm_connect_resp *rsp); 169 170 /** 171 * typedef osif_cm_set_hlp_data_cb - set hlp data for dhcp callback 172 * @dev: pointer to net device 173 * @vdev: vdev pointer 174 * @rsp: connect response 175 * 176 * this callback sets hlp data for dhcp to the legacy module 177 * 178 * context: any context. 179 * return: qdf_status 180 */ 181 typedef QDF_STATUS (*osif_cm_set_hlp_data_cb)(struct net_device *dev, 182 struct wlan_objmgr_vdev *vdev, 183 struct wlan_cm_connect_resp *rsp); 184 #endif 185 186 /** 187 * typedef osif_cm_reassoc_comp_cb - Reassoc complete callback 188 * @vdev: vdev pointer 189 * @rsp: Reassoc response 190 * @type: indicates update type 191 * 192 * This callback indicates reassoc complete to the legacy module 193 * 194 * Context: Any context. 195 * Return: QDF_STATUS 196 */ 197 typedef QDF_STATUS 198 (*osif_cm_reassoc_comp_cb)(struct wlan_objmgr_vdev *vdev, 199 struct wlan_cm_roam_resp *rsp, 200 enum osif_cb_type type); 201 202 /** 203 * typedef osif_cm_disconnect_comp_cb: Disonnect complete callback 204 * @vdev: vdev pointer 205 * @rsp: disconnect response 206 * @type: indicates update type 207 * 208 * This callback indicates disconnect complete to the legacy module 209 * 210 * Context: Any context. 211 * Return: QDF_STATUS 212 */ 213 typedef QDF_STATUS 214 (*osif_cm_disconnect_comp_cb)(struct wlan_objmgr_vdev *vdev, 215 struct wlan_cm_discon_rsp *rsp, 216 enum osif_cb_type type); 217 218 #ifdef CONN_MGR_ADV_FEATURE 219 /** 220 * typedef osif_cm_netif_queue_ctrl_cb: Callback to update netif queue 221 * @vdev: vdev pointer 222 * @action: Action to take on netif queue 223 * @reason: netif reason type 224 * 225 * This callback indicates legacy modules to take the actions related to netif 226 * queue 227 * 228 * Context: Any context. 229 * Return: QDF_STATUS 230 */ 231 typedef QDF_STATUS 232 (*osif_cm_netif_queue_ctrl_cb)(struct wlan_objmgr_vdev *vdev, 233 enum netif_action_type action, 234 enum netif_reason_type reason); 235 236 /** 237 * osif_cm_unlink_bss() - function to unlink bss from kernel and scan database 238 * on connect timeouts reasons 239 * @vdev: vdev pointer 240 * @osif_priv: Pointer to vdev osif priv 241 * @bssid: bssid to flush 242 * @ssid: optional ssid to flush 243 * @ssid_len: optional ssid length 244 * 245 * This function flush the bss from scan db of kernel and driver matching the 246 * bssid. ssid is optional to pass to match the bss. 247 * 248 * Return: void 249 */ 250 void osif_cm_unlink_bss(struct wlan_objmgr_vdev *vdev, 251 struct vdev_osif_priv *osif_priv, 252 struct qdf_mac_addr *bssid, 253 uint8_t *ssid, uint8_t ssid_len); 254 #else 255 static inline 256 void osif_cm_unlink_bss(struct wlan_objmgr_vdev *vdev, 257 struct vdev_osif_priv *osif_priv, 258 struct qdf_mac_addr *bssid, 259 uint8_t *ssid, uint8_t ssid_len) {} 260 #endif 261 262 /** 263 * osif_cm_ops: connection manager legacy callbacks 264 * osif_cm_connect_comp_cb: callback for connect complete to legacy 265 * modules 266 * osif_cm_disconnect_comp_cb: callback for disconnect complete to 267 * legacy modules 268 * osif_cm_reassoc_comp_cb: callback for reassoc complete to legacy 269 * modules 270 * osif_cm_netif_queue_ctrl_cb: callback to legacy module to take 271 * actions on netif queue 272 */ 273 struct osif_cm_ops { 274 osif_cm_connect_comp_cb connect_complete_cb; 275 osif_cm_disconnect_comp_cb disconnect_complete_cb; 276 osif_cm_reassoc_comp_cb reassoc_complete_cb; 277 #ifdef CONN_MGR_ADV_FEATURE 278 osif_cm_netif_queue_ctrl_cb netif_queue_control_cb; 279 #endif 280 #ifdef WLAN_FEATURE_FILS_SK 281 osif_cm_save_gtk_cb save_gtk_cb; 282 osif_cm_set_hlp_data_cb set_hlp_data_cb; 283 #endif 284 }; 285 286 /** 287 * osif_cm_connect_comp_ind() - Function to indicate connect 288 * complete to legacy module 289 * @vdev: vdev pointer 290 * @rsp: connect response 291 * @type: indicates update type 292 * 293 * This function indicates connect complete to the legacy module 294 * 295 * Context: Any context. 296 * Return: QDF_STATUS 297 */ 298 QDF_STATUS osif_cm_connect_comp_ind(struct wlan_objmgr_vdev *vdev, 299 struct wlan_cm_connect_resp *rsp, 300 enum osif_cb_type type); 301 302 /** 303 * osif_cm_reassoc_comp_ind() - Function to indicate reassoc 304 * complete to legacy module 305 * @vdev: vdev pointer 306 * @rsp: Roam response 307 * @type: indicates update type 308 * 309 * This function indicates connect complete to the legacy module 310 * 311 * Context: Any context. 312 * Return: QDF_STATUS 313 */ 314 QDF_STATUS osif_cm_reassoc_comp_ind(struct wlan_objmgr_vdev *vdev, 315 struct wlan_cm_roam_resp *rsp, 316 enum osif_cb_type type); 317 318 /** 319 * osif_cm_disconnect_comp_ind() - Function to indicate disconnect 320 * complete to legacy module 321 * @vdev: vdev pointer 322 * @rsp: disconnect response 323 * @type: indicates update type 324 * 325 * This function indicates disconnect complete to the legacy module 326 * 327 * Context: Any context. 328 * Return: QDF_STATUS 329 */ 330 QDF_STATUS osif_cm_disconnect_comp_ind(struct wlan_objmgr_vdev *vdev, 331 struct wlan_cm_discon_rsp *rsp, 332 enum osif_cb_type type); 333 334 #ifdef CONN_MGR_ADV_FEATURE 335 /** 336 * osif_cm_netif_queue_ind() - Function to indicate netif queue update 337 * complete to legacy module 338 * @vdev: vdev pointer 339 * @action: Action to take on netif queue 340 * @reason: netif reason type 341 * 342 * This function indicates to take the actions related to netif queue 343 * 344 * Context: Any context. 345 * Return: QDF_STATUS 346 */ 347 QDF_STATUS osif_cm_netif_queue_ind(struct wlan_objmgr_vdev *vdev, 348 enum netif_action_type action, 349 enum netif_reason_type reason); 350 #endif 351 352 #ifdef WLAN_FEATURE_FILS_SK 353 /** 354 * osif_cm_save_gtk() - Function to save gtk in legacy module 355 * @vdev: vdev pointer 356 * @rsp: Pointer to connect response 357 * 358 * This function saves gtk in legacy module 359 * 360 * Context: Any context. 361 * Return: QDF_STATUS 362 */ 363 QDF_STATUS osif_cm_save_gtk(struct wlan_objmgr_vdev *vdev, 364 struct wlan_cm_connect_resp *rsp); 365 366 /** 367 * osif_cm_set_hlp_data() - Function to set hlp data for dhcp in legacy module 368 * @dev: Pointer to net device 369 * @vdev: vdev pointer 370 * @rsp: Pointer to connect response 371 * 372 * This function sets hlp data for dhcp in legacy module 373 * 374 * Context: Any context. 375 * Return: QDF_STATUS 376 */ 377 QDF_STATUS osif_cm_set_hlp_data(struct net_device *dev, 378 struct wlan_objmgr_vdev *vdev, 379 struct wlan_cm_connect_resp *rsp); 380 #endif 381 382 /** 383 * osif_cm_set_legacy_cb() - Sets legacy callbacks to osif 384 * @osif_legacy_ops: Function pointer to legacy ops structure 385 * 386 * API to set legacy callbacks to osif 387 * Context: Any context. 388 * 389 * Return: void 390 */ 391 void osif_cm_set_legacy_cb(struct osif_cm_ops *osif_legacy_ops); 392 393 /** 394 * osif_cm_reset_legacy_cb() - Resets legacy callbacks to osif 395 * 396 * API to reset legacy callbacks to osif 397 * Context: Any context. 398 * 399 * Return: void 400 */ 401 void osif_cm_reset_legacy_cb(void); 402 403 #else 404 static inline QDF_STATUS osif_cm_osif_priv_init(struct wlan_objmgr_vdev *vdev) 405 { 406 return QDF_STATUS_SUCCESS; 407 } 408 409 static inline QDF_STATUS osif_cm_osif_priv_deinit(struct wlan_objmgr_vdev *vdev) 410 { 411 return QDF_STATUS_SUCCESS; 412 } 413 414 static inline QDF_STATUS osif_cm_register_cb(void) 415 { 416 return QDF_STATUS_SUCCESS; 417 } 418 #endif 419 420 #endif /* __OSIF_CM_UTIL_H */ 421