1 // SPDX-License-Identifier: ISC 2 /* 3 * Copyright (c) 2010 Broadcom Corporation 4 */ 5 6 #ifndef BRCMFMAC_CFG80211_H 7 #define BRCMFMAC_CFG80211_H 8 9 /* for brcmu_d11inf */ 10 #include <brcmu_d11.h> 11 12 #include "core.h" 13 #include "fwil_types.h" 14 #include "p2p.h" 15 16 #define DOT11_MGMT_HDR_LEN 24 /* d11 management header len */ 17 18 #define BRCMF_SCAN_IE_LEN_MAX 2048 19 20 #define WL_NUM_SCAN_MAX 10 21 #define WL_TLV_INFO_MAX 1024 22 #define WL_BSS_INFO_MAX 2048 23 #define WL_ASSOC_INFO_MAX 512 /* assoc related fil max buf */ 24 #define WL_EXTRA_BUF_MAX 2048 25 #define WL_ROAM_TRIGGER_LEVEL -75 26 #define WL_ROAM_DELTA 20 27 28 /* WME Access Category Indices (ACIs) */ 29 #define AC_BE 0 /* Best Effort */ 30 #define AC_BK 1 /* Background */ 31 #define AC_VI 2 /* Video */ 32 #define AC_VO 3 /* Voice */ 33 #define EDCF_AC_COUNT 4 34 #define MAX_8021D_PRIO 8 35 36 #define EDCF_ACI_MASK 0x60 37 #define EDCF_ACI_SHIFT 5 38 #define EDCF_ACM_MASK 0x10 39 #define EDCF_ECWMIN_MASK 0x0f 40 #define EDCF_ECWMAX_SHIFT 4 41 #define EDCF_AIFSN_MASK 0x0f 42 #define EDCF_AIFSN_MAX 15 43 #define EDCF_ECWMAX_MASK 0xf0 44 45 /* Keep BRCMF_ESCAN_BUF_SIZE below 64K (65536). Allocing over 64K can be 46 * problematic on some systems and should be avoided. 47 */ 48 #define BRCMF_ESCAN_BUF_SIZE 65000 49 #define BRCMF_ESCAN_TIMER_INTERVAL_MS 10000 /* E-Scan timeout */ 50 51 #define WL_ESCAN_ACTION_START 1 52 #define WL_ESCAN_ACTION_CONTINUE 2 53 #define WL_ESCAN_ACTION_ABORT 3 54 55 #define WL_AUTH_SHARED_KEY 1 /* d11 shared authentication */ 56 #define IE_MAX_LEN 512 57 58 /* IE TLV processing */ 59 #define TLV_LEN_OFF 1 /* length offset */ 60 #define TLV_HDR_LEN 2 /* header length */ 61 #define TLV_BODY_OFF 2 /* body offset */ 62 #define TLV_OUI_LEN 3 /* oui id length */ 63 64 /* 802.11 Mgmt Packet flags */ 65 #define BRCMF_VNDR_IE_BEACON_FLAG 0x1 66 #define BRCMF_VNDR_IE_PRBRSP_FLAG 0x2 67 #define BRCMF_VNDR_IE_ASSOCRSP_FLAG 0x4 68 #define BRCMF_VNDR_IE_AUTHRSP_FLAG 0x8 69 #define BRCMF_VNDR_IE_PRBREQ_FLAG 0x10 70 #define BRCMF_VNDR_IE_ASSOCREQ_FLAG 0x20 71 /* vendor IE in IW advertisement protocol ID field */ 72 #define BRCMF_VNDR_IE_IWAPID_FLAG 0x40 73 /* allow custom IE id */ 74 #define BRCMF_VNDR_IE_CUSTOM_FLAG 0x100 75 76 /* P2P Action Frames flags (spec ordered) */ 77 #define BRCMF_VNDR_IE_GONREQ_FLAG 0x001000 78 #define BRCMF_VNDR_IE_GONRSP_FLAG 0x002000 79 #define BRCMF_VNDR_IE_GONCFM_FLAG 0x004000 80 #define BRCMF_VNDR_IE_INVREQ_FLAG 0x008000 81 #define BRCMF_VNDR_IE_INVRSP_FLAG 0x010000 82 #define BRCMF_VNDR_IE_DISREQ_FLAG 0x020000 83 #define BRCMF_VNDR_IE_DISRSP_FLAG 0x040000 84 #define BRCMF_VNDR_IE_PRDREQ_FLAG 0x080000 85 #define BRCMF_VNDR_IE_PRDRSP_FLAG 0x100000 86 87 #define BRCMF_VNDR_IE_P2PAF_SHIFT 12 88 89 #define BRCMF_MAX_DEFAULT_KEYS 6 90 91 /* beacon loss timeout defaults */ 92 #define BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_ON 2 93 #define BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_OFF 4 94 95 #define BRCMF_VIF_EVENT_TIMEOUT msecs_to_jiffies(1500) 96 97 /** 98 * enum brcmf_scan_status - scan engine status 99 * 100 * @BRCMF_SCAN_STATUS_BUSY: scanning in progress on dongle. 101 * @BRCMF_SCAN_STATUS_ABORT: scan being aborted on dongle. 102 * @BRCMF_SCAN_STATUS_SUPPRESS: scanning is suppressed in driver. 103 */ 104 enum brcmf_scan_status { 105 BRCMF_SCAN_STATUS_BUSY, 106 BRCMF_SCAN_STATUS_ABORT, 107 BRCMF_SCAN_STATUS_SUPPRESS, 108 }; 109 110 /* dongle configuration */ 111 struct brcmf_cfg80211_conf { 112 u32 frag_threshold; 113 u32 rts_threshold; 114 u32 retry_short; 115 u32 retry_long; 116 }; 117 118 /* security information with currently associated ap */ 119 struct brcmf_cfg80211_security { 120 u32 wpa_versions; 121 u32 auth_type; 122 u32 cipher_pairwise; 123 u32 cipher_group; 124 }; 125 126 enum brcmf_profile_fwsup { 127 BRCMF_PROFILE_FWSUP_NONE, 128 BRCMF_PROFILE_FWSUP_PSK, 129 BRCMF_PROFILE_FWSUP_1X, 130 BRCMF_PROFILE_FWSUP_SAE, 131 BRCMF_PROFILE_FWSUP_ROAM 132 }; 133 134 /** 135 * enum brcmf_profile_fwauth - firmware authenticator profile 136 * 137 * @BRCMF_PROFILE_FWAUTH_NONE: no firmware authenticator 138 * @BRCMF_PROFILE_FWAUTH_PSK: authenticator for WPA/WPA2-PSK 139 * @BRCMF_PROFILE_FWAUTH_SAE: authenticator for SAE 140 */ 141 enum brcmf_profile_fwauth { 142 BRCMF_PROFILE_FWAUTH_NONE, 143 BRCMF_PROFILE_FWAUTH_PSK, 144 BRCMF_PROFILE_FWAUTH_SAE 145 }; 146 147 /** 148 * enum brcmf_mgmt_tx_status - mgmt frame tx status 149 * 150 * @BRCMF_MGMT_TX_ACK: mgmt frame acked 151 * @BRCMF_MGMT_TX_NOACK: mgmt frame not acked 152 * @BRCMF_MGMT_TX_OFF_CHAN_COMPLETED: off-channel complete 153 * @BRCMF_MGMT_TX_SEND_FRAME: mgmt frame tx is in progres 154 */ 155 enum brcmf_mgmt_tx_status { 156 BRCMF_MGMT_TX_ACK, 157 BRCMF_MGMT_TX_NOACK, 158 BRCMF_MGMT_TX_OFF_CHAN_COMPLETED, 159 BRCMF_MGMT_TX_SEND_FRAME 160 }; 161 162 /** 163 * struct brcmf_cfg80211_profile - profile information. 164 * 165 * @bssid: bssid of joined/joining ibss. 166 * @sec: security information. 167 * @key: key information 168 * @is_okc: OKC is used for current connection. 169 */ 170 struct brcmf_cfg80211_profile { 171 u8 bssid[ETH_ALEN]; 172 struct brcmf_cfg80211_security sec; 173 struct brcmf_wsec_key key[BRCMF_MAX_DEFAULT_KEYS]; 174 enum brcmf_profile_fwsup use_fwsup; 175 u16 use_fwauth; 176 bool is_ft; 177 bool is_okc; 178 }; 179 180 /** 181 * enum brcmf_vif_status - bit indices for vif status. 182 * 183 * @BRCMF_VIF_STATUS_READY: ready for operation. 184 * @BRCMF_VIF_STATUS_CONNECTING: connect/join in progress. 185 * @BRCMF_VIF_STATUS_CONNECTED: connected/joined successfully. 186 * @BRCMF_VIF_STATUS_DISCONNECTING: disconnect/disable in progress. 187 * @BRCMF_VIF_STATUS_AP_CREATED: AP operation started. 188 * @BRCMF_VIF_STATUS_EAP_SUCCESS: EAPOL handshake successful. 189 * @BRCMF_VIF_STATUS_ASSOC_SUCCESS: successful SET_SSID received. 190 */ 191 enum brcmf_vif_status { 192 BRCMF_VIF_STATUS_READY, 193 BRCMF_VIF_STATUS_CONNECTING, 194 BRCMF_VIF_STATUS_CONNECTED, 195 BRCMF_VIF_STATUS_DISCONNECTING, 196 BRCMF_VIF_STATUS_AP_CREATED, 197 BRCMF_VIF_STATUS_EAP_SUCCESS, 198 BRCMF_VIF_STATUS_ASSOC_SUCCESS, 199 }; 200 201 /** 202 * struct vif_saved_ie - holds saved IEs for a virtual interface. 203 * 204 * @probe_req_ie: IE info for probe request. 205 * @probe_res_ie: IE info for probe response. 206 * @beacon_ie: IE info for beacon frame. 207 * @assoc_req_ie: IE info for association request frame. 208 * @assoc_res_ie: IE info for association response frame. 209 * @probe_req_ie_len: IE info length for probe request. 210 * @probe_res_ie_len: IE info length for probe response. 211 * @beacon_ie_len: IE info length for beacon frame. 212 * @assoc_req_ie_len: IE info length for association request frame. 213 * @assoc_res_ie_len: IE info length for association response frame. 214 */ 215 struct vif_saved_ie { 216 u8 probe_req_ie[IE_MAX_LEN]; 217 u8 probe_res_ie[IE_MAX_LEN]; 218 u8 beacon_ie[IE_MAX_LEN]; 219 u8 assoc_req_ie[IE_MAX_LEN]; 220 u8 assoc_res_ie[IE_MAX_LEN]; 221 u32 probe_req_ie_len; 222 u32 probe_res_ie_len; 223 u32 beacon_ie_len; 224 u32 assoc_req_ie_len; 225 u32 assoc_res_ie_len; 226 }; 227 228 /** 229 * struct brcmf_cfg80211_vif - virtual interface specific information. 230 * 231 * @ifp: lower layer interface pointer 232 * @wdev: wireless device. 233 * @profile: profile information. 234 * @sme_state: SME state using enum brcmf_vif_status bits. 235 * @saved_ie: saved IE info for a vif. 236 * @list: linked list. 237 * @mgmt_tx: completion for management frame transmit. 238 * @mgmt_tx_status: status of last management frame sent to firmware. 239 * @mgmt_tx_id: 240 * @mgmt_rx_reg: registered rx mgmt frame types. 241 * @mbss: Multiple BSS type, set if not first AP (not relevant for P2P). 242 * @is_11d: beacon contains country IE, enable regulatory 802.11d support 243 * @cqm_rssi_low: Lower RSSI limit for CQM monitoring 244 * @cqm_rssi_high: Upper RSSI limit for CQM monitoring 245 * @cqm_rssi_last: Last RSSI reading for CQM monitoring 246 */ 247 struct brcmf_cfg80211_vif { 248 struct brcmf_if *ifp; 249 struct wireless_dev wdev; 250 struct brcmf_cfg80211_profile profile; 251 unsigned long sme_state; 252 struct vif_saved_ie saved_ie; 253 struct list_head list; 254 struct completion mgmt_tx; 255 unsigned long mgmt_tx_status; 256 u32 mgmt_tx_id; 257 u16 mgmt_rx_reg; 258 bool mbss; 259 int is_11d; 260 s32 cqm_rssi_low; 261 s32 cqm_rssi_high; 262 s32 cqm_rssi_last; 263 }; 264 265 /* association inform */ 266 struct brcmf_cfg80211_connect_info { 267 u8 *req_ie; 268 s32 req_ie_len; 269 u8 *resp_ie; 270 s32 resp_ie_len; 271 }; 272 273 /* assoc ie length */ 274 struct brcmf_cfg80211_assoc_ielen_le { 275 __le32 req_len; 276 __le32 resp_len; 277 }; 278 279 struct brcmf_cfg80211_edcf_acparam { 280 u8 ACI; 281 u8 ECW; 282 u16 TXOP; /* stored in network order (ls octet first) */ 283 }; 284 285 /* dongle escan state */ 286 enum wl_escan_state { 287 WL_ESCAN_STATE_IDLE, 288 WL_ESCAN_STATE_SCANNING 289 }; 290 291 struct escan_info { 292 u32 escan_state; 293 u8 *escan_buf; 294 struct wiphy *wiphy; 295 struct brcmf_if *ifp; 296 s32 (*run)(struct brcmf_cfg80211_info *cfg, struct brcmf_if *ifp, 297 struct cfg80211_scan_request *request); 298 }; 299 300 /** 301 * struct brcmf_cfg80211_vif_event - virtual interface event information. 302 * 303 * @vif_wq: waitqueue awaiting interface event from firmware. 304 * @vif_event_lock: protects other members in this structure. 305 * @vif_complete: completion for net attach. 306 * @action: either add, change, or delete. 307 * @vif: virtual interface object related to the event. 308 */ 309 struct brcmf_cfg80211_vif_event { 310 wait_queue_head_t vif_wq; 311 spinlock_t vif_event_lock; 312 u8 action; 313 struct brcmf_cfg80211_vif *vif; 314 }; 315 316 /** 317 * struct brcmf_cfg80211_wowl - wowl related information. 318 * 319 * @active: set on suspend, cleared on resume. 320 * @pre_pmmode: firmware PM mode at entering suspend. 321 * @nd: net dectect data. 322 * @nd_info: helper struct to pass to cfg80211. 323 * @nd_data_wait: wait queue to sync net detect data. 324 * @nd_data_completed: completion for net detect data. 325 * @nd_enabled: net detect enabled. 326 */ 327 struct brcmf_cfg80211_wowl { 328 bool active; 329 u32 pre_pmmode; 330 struct cfg80211_wowlan_nd_match *nd; 331 struct cfg80211_wowlan_nd_info *nd_info; 332 wait_queue_head_t nd_data_wait; 333 bool nd_data_completed; 334 bool nd_enabled; 335 }; 336 337 /** 338 * struct brcmf_cfg80211_info - dongle private data of cfg80211 interface 339 * 340 * @wiphy: wiphy object for cfg80211 interface. 341 * @ops: pointer to copy of ops as registered with wiphy object. 342 * @conf: dongle configuration. 343 * @p2p: peer-to-peer specific information. 344 * @btcoex: Bluetooth coexistence information. 345 * @scan_request: cfg80211 scan request object. 346 * @usr_sync: mainly for dongle up/down synchronization. 347 * @bss_list: bss_list holding scanned ap information. 348 * @bss_info: bss information for cfg80211 layer. 349 * @conn_info: association info. 350 * @pmk_list: wpa2 pmk list. 351 * @scan_status: scan activity on the dongle. 352 * @pub: common driver information. 353 * @channel: current channel. 354 * @int_escan_map: bucket map for which internal e-scan is done. 355 * @ibss_starter: indicates this sta is ibss starter. 356 * @pwr_save: indicate whether dongle to support power save mode. 357 * @dongle_up: indicate whether dongle up or not. 358 * @roam_on: on/off switch for dongle self-roaming. 359 * @scan_tried: indicates if first scan attempted. 360 * @dcmd_buf: dcmd buffer. 361 * @extra_buf: mainly to grab assoc information. 362 * @debugfsdir: debugfs folder for this device. 363 * @escan_info: escan information. 364 * @escan_timeout: Timer for catch scan timeout. 365 * @escan_timeout_work: scan timeout worker. 366 * @vif_list: linked list of vif instances. 367 * @vif_cnt: number of vif instances. 368 * @vif_event: vif event signalling. 369 * @wowl: wowl related information. 370 * @pno: information of pno module. 371 */ 372 struct brcmf_cfg80211_info { 373 struct wiphy *wiphy; 374 struct brcmf_cfg80211_conf *conf; 375 struct brcmf_p2p_info p2p; 376 struct brcmf_btcoex_info *btcoex; 377 struct cfg80211_scan_request *scan_request; 378 struct mutex usr_sync; 379 struct wl_cfg80211_bss_info *bss_info; 380 struct brcmf_cfg80211_connect_info conn_info; 381 struct brcmf_pmk_list_le pmk_list; 382 unsigned long scan_status; 383 struct brcmf_pub *pub; 384 u32 channel; 385 u32 int_escan_map; 386 bool ibss_starter; 387 bool pwr_save; 388 bool dongle_up; 389 bool scan_tried; 390 u8 *dcmd_buf; 391 u8 *extra_buf; 392 struct dentry *debugfsdir; 393 struct escan_info escan_info; 394 struct timer_list escan_timeout; 395 struct work_struct escan_timeout_work; 396 struct list_head vif_list; 397 struct brcmf_cfg80211_vif_event vif_event; 398 struct completion vif_disabled; 399 struct brcmu_d11inf d11inf; 400 struct brcmf_assoclist_le assoclist; 401 struct brcmf_cfg80211_wowl wowl; 402 struct brcmf_pno_info *pno; 403 u8 ac_priority[MAX_8021D_PRIO]; 404 }; 405 406 /** 407 * struct brcmf_tlv - tag_ID/length/value_buffer tuple. 408 * 409 * @id: tag identifier. 410 * @len: number of bytes in value buffer. 411 * @data: value buffer. 412 */ 413 struct brcmf_tlv { 414 u8 id; 415 u8 len; 416 u8 data[]; 417 }; 418 419 static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *cfg) 420 { 421 return cfg->wiphy; 422 } 423 424 static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w) 425 { 426 struct brcmf_pub *drvr = wiphy_priv(w); 427 return drvr->config; 428 } 429 430 static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd) 431 { 432 return wiphy_to_cfg(wd->wiphy); 433 } 434 435 static inline struct brcmf_cfg80211_vif *wdev_to_vif(struct wireless_dev *wdev) 436 { 437 return container_of(wdev, struct brcmf_cfg80211_vif, wdev); 438 } 439 440 static inline 441 struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg) 442 { 443 return brcmf_get_ifp(cfg->pub, 0)->ndev; 444 } 445 446 static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev) 447 { 448 return wdev_to_cfg(ndev->ieee80211_ptr); 449 } 450 451 static inline struct brcmf_cfg80211_profile *ndev_to_prof(struct net_device *nd) 452 { 453 struct brcmf_if *ifp = netdev_priv(nd); 454 return &ifp->vif->profile; 455 } 456 457 static inline struct brcmf_cfg80211_vif *ndev_to_vif(struct net_device *ndev) 458 { 459 struct brcmf_if *ifp = netdev_priv(ndev); 460 return ifp->vif; 461 } 462 463 static inline struct 464 brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg) 465 { 466 return &cfg->conn_info; 467 } 468 469 struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr, 470 struct cfg80211_ops *ops, 471 bool p2pdev_forced); 472 void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg); 473 s32 brcmf_cfg80211_up(struct net_device *ndev); 474 s32 brcmf_cfg80211_down(struct net_device *ndev); 475 struct cfg80211_ops *brcmf_cfg80211_get_ops(struct brcmf_mp_device *settings); 476 477 struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg, 478 enum nl80211_iftype type); 479 void brcmf_free_vif(struct brcmf_cfg80211_vif *vif); 480 481 s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 pktflag, 482 const u8 *vndr_ie_buf, u32 vndr_ie_len); 483 s32 brcmf_vif_clear_mgmt_ies(struct brcmf_cfg80211_vif *vif); 484 u16 channel_to_chanspec(struct brcmu_d11inf *d11inf, 485 struct ieee80211_channel *ch); 486 bool brcmf_get_vif_state_any(struct brcmf_cfg80211_info *cfg, 487 unsigned long state); 488 void brcmf_cfg80211_arm_vif_event(struct brcmf_cfg80211_info *cfg, 489 struct brcmf_cfg80211_vif *vif); 490 bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg); 491 int brcmf_cfg80211_wait_vif_event(struct brcmf_cfg80211_info *cfg, 492 u8 action, ulong timeout); 493 s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg, 494 struct brcmf_if *ifp, bool aborted, 495 bool fw_abort); 496 void brcmf_set_mpc(struct brcmf_if *ndev, int mpc); 497 bool brcmf_is_apmode_operating(struct wiphy *wiphy); 498 void brcmf_abort_scanning(struct brcmf_cfg80211_info *cfg); 499 void brcmf_cfg80211_free_vif(struct net_device *ndev); 500 501 int brcmf_set_wsec(struct brcmf_if *ifp, const u8 *key, u16 key_len, u16 flags); 502 int brcmf_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, 503 struct cfg80211_mgmt_tx_params *params, u64 cookie); 504 505 #endif /* BRCMFMAC_CFG80211_H */ 506