Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: ISC
0002 /*
0003  * Copyright (c) 2010 Broadcom Corporation
0004  */
0005 
0006 #ifndef BRCMFMAC_CFG80211_H
0007 #define BRCMFMAC_CFG80211_H
0008 
0009 /* for brcmu_d11inf */
0010 #include <brcmu_d11.h>
0011 
0012 #include "core.h"
0013 #include "fwil_types.h"
0014 #include "p2p.h"
0015 
0016 #define BRCMF_SCAN_IE_LEN_MAX       2048
0017 
0018 #define WL_NUM_SCAN_MAX         10
0019 #define WL_TLV_INFO_MAX         1024
0020 #define WL_BSS_INFO_MAX         2048
0021 #define WL_ASSOC_INFO_MAX       512 /* assoc related fil max buf */
0022 #define WL_EXTRA_BUF_MAX        2048
0023 #define WL_ROAM_TRIGGER_LEVEL       -75
0024 #define WL_ROAM_DELTA           20
0025 
0026 /* WME Access Category Indices (ACIs) */
0027 #define AC_BE           0   /* Best Effort */
0028 #define AC_BK           1   /* Background */
0029 #define AC_VI           2   /* Video */
0030 #define AC_VO           3   /* Voice */
0031 #define EDCF_AC_COUNT       4
0032 #define MAX_8021D_PRIO      8
0033 
0034 #define EDCF_ACI_MASK           0x60
0035 #define EDCF_ACI_SHIFT          5
0036 #define EDCF_ACM_MASK                  0x10
0037 #define EDCF_ECWMIN_MASK        0x0f
0038 #define EDCF_ECWMAX_SHIFT       4
0039 #define EDCF_AIFSN_MASK         0x0f
0040 #define EDCF_AIFSN_MAX          15
0041 #define EDCF_ECWMAX_MASK        0xf0
0042 
0043 /* Keep BRCMF_ESCAN_BUF_SIZE below 64K (65536). Allocing over 64K can be
0044  * problematic on some systems and should be avoided.
0045  */
0046 #define BRCMF_ESCAN_BUF_SIZE        65000
0047 #define BRCMF_ESCAN_TIMER_INTERVAL_MS   10000   /* E-Scan timeout */
0048 
0049 #define WL_ESCAN_ACTION_START       1
0050 #define WL_ESCAN_ACTION_CONTINUE    2
0051 #define WL_ESCAN_ACTION_ABORT       3
0052 
0053 #define WL_AUTH_SHARED_KEY      1   /* d11 shared authentication */
0054 #define IE_MAX_LEN          512
0055 
0056 /* IE TLV processing */
0057 #define TLV_LEN_OFF         1   /* length offset */
0058 #define TLV_HDR_LEN         2   /* header length */
0059 #define TLV_BODY_OFF            2   /* body offset */
0060 #define TLV_OUI_LEN         3   /* oui id length */
0061 
0062 /* 802.11 Mgmt Packet flags */
0063 #define BRCMF_VNDR_IE_BEACON_FLAG   0x1
0064 #define BRCMF_VNDR_IE_PRBRSP_FLAG   0x2
0065 #define BRCMF_VNDR_IE_ASSOCRSP_FLAG 0x4
0066 #define BRCMF_VNDR_IE_AUTHRSP_FLAG  0x8
0067 #define BRCMF_VNDR_IE_PRBREQ_FLAG   0x10
0068 #define BRCMF_VNDR_IE_ASSOCREQ_FLAG 0x20
0069 /* vendor IE in IW advertisement protocol ID field */
0070 #define BRCMF_VNDR_IE_IWAPID_FLAG   0x40
0071 /* allow custom IE id */
0072 #define BRCMF_VNDR_IE_CUSTOM_FLAG   0x100
0073 
0074 /* P2P Action Frames flags (spec ordered) */
0075 #define BRCMF_VNDR_IE_GONREQ_FLAG     0x001000
0076 #define BRCMF_VNDR_IE_GONRSP_FLAG     0x002000
0077 #define BRCMF_VNDR_IE_GONCFM_FLAG     0x004000
0078 #define BRCMF_VNDR_IE_INVREQ_FLAG     0x008000
0079 #define BRCMF_VNDR_IE_INVRSP_FLAG     0x010000
0080 #define BRCMF_VNDR_IE_DISREQ_FLAG     0x020000
0081 #define BRCMF_VNDR_IE_DISRSP_FLAG     0x040000
0082 #define BRCMF_VNDR_IE_PRDREQ_FLAG     0x080000
0083 #define BRCMF_VNDR_IE_PRDRSP_FLAG     0x100000
0084 
0085 #define BRCMF_VNDR_IE_P2PAF_SHIFT   12
0086 
0087 #define BRCMF_MAX_DEFAULT_KEYS      6
0088 
0089 /* beacon loss timeout defaults */
0090 #define BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_ON   2
0091 #define BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_OFF  4
0092 
0093 #define BRCMF_VIF_EVENT_TIMEOUT     msecs_to_jiffies(1500)
0094 
0095 /**
0096  * enum brcmf_scan_status - scan engine status
0097  *
0098  * @BRCMF_SCAN_STATUS_BUSY: scanning in progress on dongle.
0099  * @BRCMF_SCAN_STATUS_ABORT: scan being aborted on dongle.
0100  * @BRCMF_SCAN_STATUS_SUPPRESS: scanning is suppressed in driver.
0101  */
0102 enum brcmf_scan_status {
0103     BRCMF_SCAN_STATUS_BUSY,
0104     BRCMF_SCAN_STATUS_ABORT,
0105     BRCMF_SCAN_STATUS_SUPPRESS,
0106 };
0107 
0108 /* dongle configuration */
0109 struct brcmf_cfg80211_conf {
0110     u32 frag_threshold;
0111     u32 rts_threshold;
0112     u32 retry_short;
0113     u32 retry_long;
0114 };
0115 
0116 /* security information with currently associated ap */
0117 struct brcmf_cfg80211_security {
0118     u32 wpa_versions;
0119     u32 auth_type;
0120     u32 cipher_pairwise;
0121     u32 cipher_group;
0122 };
0123 
0124 enum brcmf_profile_fwsup {
0125     BRCMF_PROFILE_FWSUP_NONE,
0126     BRCMF_PROFILE_FWSUP_PSK,
0127     BRCMF_PROFILE_FWSUP_1X,
0128     BRCMF_PROFILE_FWSUP_SAE
0129 };
0130 
0131 /**
0132  * enum brcmf_profile_fwauth - firmware authenticator profile
0133  *
0134  * @BRCMF_PROFILE_FWAUTH_NONE: no firmware authenticator
0135  * @BRCMF_PROFILE_FWAUTH_PSK: authenticator for WPA/WPA2-PSK
0136  * @BRCMF_PROFILE_FWAUTH_SAE: authenticator for SAE
0137  */
0138 enum brcmf_profile_fwauth {
0139     BRCMF_PROFILE_FWAUTH_NONE,
0140     BRCMF_PROFILE_FWAUTH_PSK,
0141     BRCMF_PROFILE_FWAUTH_SAE
0142 };
0143 
0144 /**
0145  * struct brcmf_cfg80211_profile - profile information.
0146  *
0147  * @bssid: bssid of joined/joining ibss.
0148  * @sec: security information.
0149  * @key: key information
0150  */
0151 struct brcmf_cfg80211_profile {
0152     u8 bssid[ETH_ALEN];
0153     struct brcmf_cfg80211_security sec;
0154     struct brcmf_wsec_key key[BRCMF_MAX_DEFAULT_KEYS];
0155     enum brcmf_profile_fwsup use_fwsup;
0156     u16 use_fwauth;
0157     bool is_ft;
0158 };
0159 
0160 /**
0161  * enum brcmf_vif_status - bit indices for vif status.
0162  *
0163  * @BRCMF_VIF_STATUS_READY: ready for operation.
0164  * @BRCMF_VIF_STATUS_CONNECTING: connect/join in progress.
0165  * @BRCMF_VIF_STATUS_CONNECTED: connected/joined successfully.
0166  * @BRCMF_VIF_STATUS_DISCONNECTING: disconnect/disable in progress.
0167  * @BRCMF_VIF_STATUS_AP_CREATED: AP operation started.
0168  * @BRCMF_VIF_STATUS_EAP_SUCCUSS: EAPOL handshake successful.
0169  * @BRCMF_VIF_STATUS_ASSOC_SUCCESS: successful SET_SSID received.
0170  */
0171 enum brcmf_vif_status {
0172     BRCMF_VIF_STATUS_READY,
0173     BRCMF_VIF_STATUS_CONNECTING,
0174     BRCMF_VIF_STATUS_CONNECTED,
0175     BRCMF_VIF_STATUS_DISCONNECTING,
0176     BRCMF_VIF_STATUS_AP_CREATED,
0177     BRCMF_VIF_STATUS_EAP_SUCCESS,
0178     BRCMF_VIF_STATUS_ASSOC_SUCCESS,
0179 };
0180 
0181 /**
0182  * struct vif_saved_ie - holds saved IEs for a virtual interface.
0183  *
0184  * @probe_req_ie: IE info for probe request.
0185  * @probe_res_ie: IE info for probe response.
0186  * @beacon_ie: IE info for beacon frame.
0187  * @assoc_res_ie: IE info for association response frame.
0188  * @probe_req_ie_len: IE info length for probe request.
0189  * @probe_res_ie_len: IE info length for probe response.
0190  * @beacon_ie_len: IE info length for beacon frame.
0191  * @assoc_res_ie_len: IE info length for association response frame.
0192  */
0193 struct vif_saved_ie {
0194     u8  probe_req_ie[IE_MAX_LEN];
0195     u8  probe_res_ie[IE_MAX_LEN];
0196     u8  beacon_ie[IE_MAX_LEN];
0197     u8  assoc_req_ie[IE_MAX_LEN];
0198     u8  assoc_res_ie[IE_MAX_LEN];
0199     u32 probe_req_ie_len;
0200     u32 probe_res_ie_len;
0201     u32 beacon_ie_len;
0202     u32 assoc_req_ie_len;
0203     u32 assoc_res_ie_len;
0204 };
0205 
0206 /**
0207  * struct brcmf_cfg80211_vif - virtual interface specific information.
0208  *
0209  * @ifp: lower layer interface pointer
0210  * @wdev: wireless device.
0211  * @profile: profile information.
0212  * @sme_state: SME state using enum brcmf_vif_status bits.
0213  * @list: linked list.
0214  * @mgmt_rx_reg: registered rx mgmt frame types.
0215  * @mbss: Multiple BSS type, set if not first AP (not relevant for P2P).
0216  * @cqm_rssi_low: Lower RSSI limit for CQM monitoring
0217  * @cqm_rssi_high: Upper RSSI limit for CQM monitoring
0218  * @cqm_rssi_last: Last RSSI reading for CQM monitoring
0219  */
0220 struct brcmf_cfg80211_vif {
0221     struct brcmf_if *ifp;
0222     struct wireless_dev wdev;
0223     struct brcmf_cfg80211_profile profile;
0224     unsigned long sme_state;
0225     struct vif_saved_ie saved_ie;
0226     struct list_head list;
0227     u16 mgmt_rx_reg;
0228     bool mbss;
0229     int is_11d;
0230     s32 cqm_rssi_low;
0231     s32 cqm_rssi_high;
0232     s32 cqm_rssi_last;
0233 };
0234 
0235 /* association inform */
0236 struct brcmf_cfg80211_connect_info {
0237     u8 *req_ie;
0238     s32 req_ie_len;
0239     u8 *resp_ie;
0240     s32 resp_ie_len;
0241 };
0242 
0243 /* assoc ie length */
0244 struct brcmf_cfg80211_assoc_ielen_le {
0245     __le32 req_len;
0246     __le32 resp_len;
0247 };
0248 
0249 struct brcmf_cfg80211_edcf_acparam {
0250     u8 ACI;
0251     u8 ECW;
0252     u16 TXOP;        /* stored in network order (ls octet first) */
0253 };
0254 
0255 /* dongle escan state */
0256 enum wl_escan_state {
0257     WL_ESCAN_STATE_IDLE,
0258     WL_ESCAN_STATE_SCANNING
0259 };
0260 
0261 struct escan_info {
0262     u32 escan_state;
0263     u8 *escan_buf;
0264     struct wiphy *wiphy;
0265     struct brcmf_if *ifp;
0266     s32 (*run)(struct brcmf_cfg80211_info *cfg, struct brcmf_if *ifp,
0267            struct cfg80211_scan_request *request);
0268 };
0269 
0270 /**
0271  * struct brcmf_cfg80211_vif_event - virtual interface event information.
0272  *
0273  * @vif_wq: waitqueue awaiting interface event from firmware.
0274  * @vif_event_lock: protects other members in this structure.
0275  * @vif_complete: completion for net attach.
0276  * @action: either add, change, or delete.
0277  * @vif: virtual interface object related to the event.
0278  */
0279 struct brcmf_cfg80211_vif_event {
0280     wait_queue_head_t vif_wq;
0281     spinlock_t vif_event_lock;
0282     u8 action;
0283     struct brcmf_cfg80211_vif *vif;
0284 };
0285 
0286 /**
0287  * struct brcmf_cfg80211_wowl - wowl related information.
0288  *
0289  * @active: set on suspend, cleared on resume.
0290  * @pre_pmmode: firmware PM mode at entering suspend.
0291  * @nd: net dectect data.
0292  * @nd_info: helper struct to pass to cfg80211.
0293  * @nd_data_wait: wait queue to sync net detect data.
0294  * @nd_data_completed: completion for net detect data.
0295  * @nd_enabled: net detect enabled.
0296  */
0297 struct brcmf_cfg80211_wowl {
0298     bool active;
0299     u32 pre_pmmode;
0300     struct cfg80211_wowlan_nd_match *nd;
0301     struct cfg80211_wowlan_nd_info *nd_info;
0302     wait_queue_head_t nd_data_wait;
0303     bool nd_data_completed;
0304     bool nd_enabled;
0305 };
0306 
0307 /**
0308  * struct brcmf_cfg80211_info - dongle private data of cfg80211 interface
0309  *
0310  * @wiphy: wiphy object for cfg80211 interface.
0311  * @ops: pointer to copy of ops as registered with wiphy object.
0312  * @conf: dongle configuration.
0313  * @p2p: peer-to-peer specific information.
0314  * @btcoex: Bluetooth coexistence information.
0315  * @scan_request: cfg80211 scan request object.
0316  * @usr_sync: mainly for dongle up/down synchronization.
0317  * @bss_list: bss_list holding scanned ap information.
0318  * @bss_info: bss information for cfg80211 layer.
0319  * @conn_info: association info.
0320  * @pmk_list: wpa2 pmk list.
0321  * @scan_status: scan activity on the dongle.
0322  * @pub: common driver information.
0323  * @channel: current channel.
0324  * @int_escan_map: bucket map for which internal e-scan is done.
0325  * @ibss_starter: indicates this sta is ibss starter.
0326  * @pwr_save: indicate whether dongle to support power save mode.
0327  * @dongle_up: indicate whether dongle up or not.
0328  * @roam_on: on/off switch for dongle self-roaming.
0329  * @scan_tried: indicates if first scan attempted.
0330  * @dcmd_buf: dcmd buffer.
0331  * @extra_buf: mainly to grab assoc information.
0332  * @debugfsdir: debugfs folder for this device.
0333  * @escan_info: escan information.
0334  * @escan_timeout: Timer for catch scan timeout.
0335  * @escan_timeout_work: scan timeout worker.
0336  * @vif_list: linked list of vif instances.
0337  * @vif_cnt: number of vif instances.
0338  * @vif_event: vif event signalling.
0339  * @wowl: wowl related information.
0340  * @pno: information of pno module.
0341  */
0342 struct brcmf_cfg80211_info {
0343     struct wiphy *wiphy;
0344     struct brcmf_cfg80211_conf *conf;
0345     struct brcmf_p2p_info p2p;
0346     struct brcmf_btcoex_info *btcoex;
0347     struct cfg80211_scan_request *scan_request;
0348     struct mutex usr_sync;
0349     struct wl_cfg80211_bss_info *bss_info;
0350     struct brcmf_cfg80211_connect_info conn_info;
0351     struct brcmf_pmk_list_le pmk_list;
0352     unsigned long scan_status;
0353     struct brcmf_pub *pub;
0354     u32 channel;
0355     u32 int_escan_map;
0356     bool ibss_starter;
0357     bool pwr_save;
0358     bool dongle_up;
0359     bool scan_tried;
0360     u8 *dcmd_buf;
0361     u8 *extra_buf;
0362     struct dentry *debugfsdir;
0363     struct escan_info escan_info;
0364     struct timer_list escan_timeout;
0365     struct work_struct escan_timeout_work;
0366     struct list_head vif_list;
0367     struct brcmf_cfg80211_vif_event vif_event;
0368     struct completion vif_disabled;
0369     struct brcmu_d11inf d11inf;
0370     struct brcmf_assoclist_le assoclist;
0371     struct brcmf_cfg80211_wowl wowl;
0372     struct brcmf_pno_info *pno;
0373     u8 ac_priority[MAX_8021D_PRIO];
0374 };
0375 
0376 /**
0377  * struct brcmf_tlv - tag_ID/length/value_buffer tuple.
0378  *
0379  * @id: tag identifier.
0380  * @len: number of bytes in value buffer.
0381  * @data: value buffer.
0382  */
0383 struct brcmf_tlv {
0384     u8 id;
0385     u8 len;
0386     u8 data[1];
0387 };
0388 
0389 static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *cfg)
0390 {
0391     return cfg->wiphy;
0392 }
0393 
0394 static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w)
0395 {
0396     struct brcmf_pub *drvr = wiphy_priv(w);
0397     return drvr->config;
0398 }
0399 
0400 static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd)
0401 {
0402     return wiphy_to_cfg(wd->wiphy);
0403 }
0404 
0405 static inline struct brcmf_cfg80211_vif *wdev_to_vif(struct wireless_dev *wdev)
0406 {
0407     return container_of(wdev, struct brcmf_cfg80211_vif, wdev);
0408 }
0409 
0410 static inline
0411 struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg)
0412 {
0413     return brcmf_get_ifp(cfg->pub, 0)->ndev;
0414 }
0415 
0416 static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev)
0417 {
0418     return wdev_to_cfg(ndev->ieee80211_ptr);
0419 }
0420 
0421 static inline struct brcmf_cfg80211_profile *ndev_to_prof(struct net_device *nd)
0422 {
0423     struct brcmf_if *ifp = netdev_priv(nd);
0424     return &ifp->vif->profile;
0425 }
0426 
0427 static inline struct brcmf_cfg80211_vif *ndev_to_vif(struct net_device *ndev)
0428 {
0429     struct brcmf_if *ifp = netdev_priv(ndev);
0430     return ifp->vif;
0431 }
0432 
0433 static inline struct
0434 brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg)
0435 {
0436     return &cfg->conn_info;
0437 }
0438 
0439 struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
0440                           struct cfg80211_ops *ops,
0441                           bool p2pdev_forced);
0442 void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg);
0443 s32 brcmf_cfg80211_up(struct net_device *ndev);
0444 s32 brcmf_cfg80211_down(struct net_device *ndev);
0445 struct cfg80211_ops *brcmf_cfg80211_get_ops(struct brcmf_mp_device *settings);
0446 enum nl80211_iftype brcmf_cfg80211_get_iftype(struct brcmf_if *ifp);
0447 
0448 struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg,
0449                        enum nl80211_iftype type);
0450 void brcmf_free_vif(struct brcmf_cfg80211_vif *vif);
0451 
0452 s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 pktflag,
0453               const u8 *vndr_ie_buf, u32 vndr_ie_len);
0454 s32 brcmf_vif_clear_mgmt_ies(struct brcmf_cfg80211_vif *vif);
0455 u16 channel_to_chanspec(struct brcmu_d11inf *d11inf,
0456             struct ieee80211_channel *ch);
0457 bool brcmf_get_vif_state_any(struct brcmf_cfg80211_info *cfg,
0458                  unsigned long state);
0459 void brcmf_cfg80211_arm_vif_event(struct brcmf_cfg80211_info *cfg,
0460                   struct brcmf_cfg80211_vif *vif);
0461 bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg);
0462 int brcmf_cfg80211_wait_vif_event(struct brcmf_cfg80211_info *cfg,
0463                   u8 action, ulong timeout);
0464 s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg,
0465                 struct brcmf_if *ifp, bool aborted,
0466                 bool fw_abort);
0467 void brcmf_set_mpc(struct brcmf_if *ndev, int mpc);
0468 void brcmf_abort_scanning(struct brcmf_cfg80211_info *cfg);
0469 void brcmf_cfg80211_free_netdev(struct net_device *ndev);
0470 
0471 #endif /* BRCMFMAC_CFG80211_H */