Path: blob/main/sys/contrib/dev/broadcom/brcm80211/brcmfmac/cfg80211.h
178665 views
// SPDX-License-Identifier: ISC1/*2* Copyright (c) 2010 Broadcom Corporation3*/45#ifndef BRCMFMAC_CFG80211_H6#define BRCMFMAC_CFG80211_H78/* for brcmu_d11inf */9#include <brcmu_d11.h>1011#include "core.h"12#include "fwil_types.h"13#include "p2p.h"1415#define DOT11_MGMT_HDR_LEN 24 /* d11 management header len */1617#define BRCMF_SCAN_IE_LEN_MAX 20481819#define WL_NUM_SCAN_MAX 1020#define WL_TLV_INFO_MAX 102421#define WL_BSS_INFO_MAX 204822#define WL_ASSOC_INFO_MAX 512 /* assoc related fil max buf */23#define WL_EXTRA_BUF_MAX 204824#define WL_ROAM_TRIGGER_LEVEL -7525#define WL_ROAM_DELTA 202627/* WME Access Category Indices (ACIs) */28#define AC_BE 0 /* Best Effort */29#define AC_BK 1 /* Background */30#define AC_VI 2 /* Video */31#define AC_VO 3 /* Voice */32#define EDCF_AC_COUNT 433#define MAX_8021D_PRIO 83435#define EDCF_ACI_MASK 0x6036#define EDCF_ACI_SHIFT 537#define EDCF_ACM_MASK 0x1038#define EDCF_ECWMIN_MASK 0x0f39#define EDCF_ECWMAX_SHIFT 440#define EDCF_AIFSN_MASK 0x0f41#define EDCF_AIFSN_MAX 1542#define EDCF_ECWMAX_MASK 0xf04344/* Keep BRCMF_ESCAN_BUF_SIZE below 64K (65536). Allocing over 64K can be45* problematic on some systems and should be avoided.46*/47#define BRCMF_ESCAN_BUF_SIZE 6500048#define BRCMF_ESCAN_TIMER_INTERVAL_MS 10000 /* E-Scan timeout */4950#define WL_ESCAN_ACTION_START 151#define WL_ESCAN_ACTION_CONTINUE 252#define WL_ESCAN_ACTION_ABORT 35354#define WL_AUTH_SHARED_KEY 1 /* d11 shared authentication */55#define IE_MAX_LEN 5125657/* IE TLV processing */58#define TLV_LEN_OFF 1 /* length offset */59#define TLV_HDR_LEN 2 /* header length */60#define TLV_BODY_OFF 2 /* body offset */61#define TLV_OUI_LEN 3 /* oui id length */6263/* 802.11 Mgmt Packet flags */64#define BRCMF_VNDR_IE_BEACON_FLAG 0x165#define BRCMF_VNDR_IE_PRBRSP_FLAG 0x266#define BRCMF_VNDR_IE_ASSOCRSP_FLAG 0x467#define BRCMF_VNDR_IE_AUTHRSP_FLAG 0x868#define BRCMF_VNDR_IE_PRBREQ_FLAG 0x1069#define BRCMF_VNDR_IE_ASSOCREQ_FLAG 0x2070/* vendor IE in IW advertisement protocol ID field */71#define BRCMF_VNDR_IE_IWAPID_FLAG 0x4072/* allow custom IE id */73#define BRCMF_VNDR_IE_CUSTOM_FLAG 0x1007475/* P2P Action Frames flags (spec ordered) */76#define BRCMF_VNDR_IE_GONREQ_FLAG 0x00100077#define BRCMF_VNDR_IE_GONRSP_FLAG 0x00200078#define BRCMF_VNDR_IE_GONCFM_FLAG 0x00400079#define BRCMF_VNDR_IE_INVREQ_FLAG 0x00800080#define BRCMF_VNDR_IE_INVRSP_FLAG 0x01000081#define BRCMF_VNDR_IE_DISREQ_FLAG 0x02000082#define BRCMF_VNDR_IE_DISRSP_FLAG 0x04000083#define BRCMF_VNDR_IE_PRDREQ_FLAG 0x08000084#define BRCMF_VNDR_IE_PRDRSP_FLAG 0x1000008586#define BRCMF_VNDR_IE_P2PAF_SHIFT 128788#define BRCMF_MAX_DEFAULT_KEYS 68990/* beacon loss timeout defaults */91#define BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_ON 292#define BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_OFF 49394#define BRCMF_VIF_EVENT_TIMEOUT msecs_to_jiffies(1500)9596/**97* enum brcmf_scan_status - scan engine status98*99* @BRCMF_SCAN_STATUS_BUSY: scanning in progress on dongle.100* @BRCMF_SCAN_STATUS_ABORT: scan being aborted on dongle.101* @BRCMF_SCAN_STATUS_SUPPRESS: scanning is suppressed in driver.102*/103enum brcmf_scan_status {104BRCMF_SCAN_STATUS_BUSY,105BRCMF_SCAN_STATUS_ABORT,106BRCMF_SCAN_STATUS_SUPPRESS,107};108109/* dongle configuration */110struct brcmf_cfg80211_conf {111u32 frag_threshold;112u32 rts_threshold;113u32 retry_short;114u32 retry_long;115};116117/* security information with currently associated ap */118struct brcmf_cfg80211_security {119u32 wpa_versions;120u32 auth_type;121u32 cipher_pairwise;122u32 cipher_group;123};124125enum brcmf_profile_fwsup {126BRCMF_PROFILE_FWSUP_NONE,127BRCMF_PROFILE_FWSUP_PSK,128BRCMF_PROFILE_FWSUP_1X,129BRCMF_PROFILE_FWSUP_SAE130};131132/**133* enum brcmf_profile_fwauth - firmware authenticator profile134*135* @BRCMF_PROFILE_FWAUTH_NONE: no firmware authenticator136* @BRCMF_PROFILE_FWAUTH_PSK: authenticator for WPA/WPA2-PSK137* @BRCMF_PROFILE_FWAUTH_SAE: authenticator for SAE138*/139enum brcmf_profile_fwauth {140BRCMF_PROFILE_FWAUTH_NONE,141BRCMF_PROFILE_FWAUTH_PSK,142BRCMF_PROFILE_FWAUTH_SAE143};144145/**146* enum brcmf_mgmt_tx_status - mgmt frame tx status147*148* @BRCMF_MGMT_TX_ACK: mgmt frame acked149* @BRCMF_MGMT_TX_NOACK: mgmt frame not acked150* @BRCMF_MGMT_TX_OFF_CHAN_COMPLETED: off-channel complete151* @BRCMF_MGMT_TX_SEND_FRAME: mgmt frame tx is in progres152*/153enum brcmf_mgmt_tx_status {154BRCMF_MGMT_TX_ACK,155BRCMF_MGMT_TX_NOACK,156BRCMF_MGMT_TX_OFF_CHAN_COMPLETED,157BRCMF_MGMT_TX_SEND_FRAME158};159160/**161* struct brcmf_cfg80211_profile - profile information.162*163* @bssid: bssid of joined/joining ibss.164* @sec: security information.165* @key: key information166*/167struct brcmf_cfg80211_profile {168u8 bssid[ETH_ALEN];169struct brcmf_cfg80211_security sec;170struct brcmf_wsec_key key[BRCMF_MAX_DEFAULT_KEYS];171enum brcmf_profile_fwsup use_fwsup;172u16 use_fwauth;173bool is_ft;174};175176/**177* enum brcmf_vif_status - bit indices for vif status.178*179* @BRCMF_VIF_STATUS_READY: ready for operation.180* @BRCMF_VIF_STATUS_CONNECTING: connect/join in progress.181* @BRCMF_VIF_STATUS_CONNECTED: connected/joined successfully.182* @BRCMF_VIF_STATUS_DISCONNECTING: disconnect/disable in progress.183* @BRCMF_VIF_STATUS_AP_CREATED: AP operation started.184* @BRCMF_VIF_STATUS_EAP_SUCCUSS: EAPOL handshake successful.185* @BRCMF_VIF_STATUS_ASSOC_SUCCESS: successful SET_SSID received.186*/187enum brcmf_vif_status {188BRCMF_VIF_STATUS_READY,189BRCMF_VIF_STATUS_CONNECTING,190BRCMF_VIF_STATUS_CONNECTED,191BRCMF_VIF_STATUS_DISCONNECTING,192BRCMF_VIF_STATUS_AP_CREATED,193BRCMF_VIF_STATUS_EAP_SUCCESS,194BRCMF_VIF_STATUS_ASSOC_SUCCESS,195};196197/**198* struct vif_saved_ie - holds saved IEs for a virtual interface.199*200* @probe_req_ie: IE info for probe request.201* @probe_res_ie: IE info for probe response.202* @beacon_ie: IE info for beacon frame.203* @assoc_res_ie: IE info for association response frame.204* @probe_req_ie_len: IE info length for probe request.205* @probe_res_ie_len: IE info length for probe response.206* @beacon_ie_len: IE info length for beacon frame.207* @assoc_res_ie_len: IE info length for association response frame.208*/209struct vif_saved_ie {210u8 probe_req_ie[IE_MAX_LEN];211u8 probe_res_ie[IE_MAX_LEN];212u8 beacon_ie[IE_MAX_LEN];213u8 assoc_req_ie[IE_MAX_LEN];214u8 assoc_res_ie[IE_MAX_LEN];215u32 probe_req_ie_len;216u32 probe_res_ie_len;217u32 beacon_ie_len;218u32 assoc_req_ie_len;219u32 assoc_res_ie_len;220};221222/**223* struct brcmf_cfg80211_vif - virtual interface specific information.224*225* @ifp: lower layer interface pointer226* @wdev: wireless device.227* @profile: profile information.228* @sme_state: SME state using enum brcmf_vif_status bits.229* @list: linked list.230* @mgmt_tx: completion for management frame transmit.231* @mgmt_tx_status: status of last management frame sent to firmware.232* @mgmt_tx_id:233* @mgmt_rx_reg: registered rx mgmt frame types.234* @mbss: Multiple BSS type, set if not first AP (not relevant for P2P).235* @cqm_rssi_low: Lower RSSI limit for CQM monitoring236* @cqm_rssi_high: Upper RSSI limit for CQM monitoring237* @cqm_rssi_last: Last RSSI reading for CQM monitoring238*/239struct brcmf_cfg80211_vif {240struct brcmf_if *ifp;241struct wireless_dev wdev;242struct brcmf_cfg80211_profile profile;243unsigned long sme_state;244struct vif_saved_ie saved_ie;245struct list_head list;246struct completion mgmt_tx;247unsigned long mgmt_tx_status;248u32 mgmt_tx_id;249u16 mgmt_rx_reg;250bool mbss;251int is_11d;252s32 cqm_rssi_low;253s32 cqm_rssi_high;254s32 cqm_rssi_last;255};256257/* association inform */258struct brcmf_cfg80211_connect_info {259u8 *req_ie;260s32 req_ie_len;261u8 *resp_ie;262s32 resp_ie_len;263};264265/* assoc ie length */266struct brcmf_cfg80211_assoc_ielen_le {267__le32 req_len;268__le32 resp_len;269};270271struct brcmf_cfg80211_edcf_acparam {272u8 ACI;273u8 ECW;274u16 TXOP; /* stored in network order (ls octet first) */275};276277/* dongle escan state */278enum wl_escan_state {279WL_ESCAN_STATE_IDLE,280WL_ESCAN_STATE_SCANNING281};282283struct escan_info {284u32 escan_state;285u8 *escan_buf;286struct wiphy *wiphy;287struct brcmf_if *ifp;288s32 (*run)(struct brcmf_cfg80211_info *cfg, struct brcmf_if *ifp,289struct cfg80211_scan_request *request);290};291292/**293* struct brcmf_cfg80211_vif_event - virtual interface event information.294*295* @vif_wq: waitqueue awaiting interface event from firmware.296* @vif_event_lock: protects other members in this structure.297* @vif_complete: completion for net attach.298* @action: either add, change, or delete.299* @vif: virtual interface object related to the event.300*/301struct brcmf_cfg80211_vif_event {302wait_queue_head_t vif_wq;303spinlock_t vif_event_lock;304u8 action;305struct brcmf_cfg80211_vif *vif;306};307308/**309* struct brcmf_cfg80211_wowl - wowl related information.310*311* @active: set on suspend, cleared on resume.312* @pre_pmmode: firmware PM mode at entering suspend.313* @nd: net dectect data.314* @nd_info: helper struct to pass to cfg80211.315* @nd_data_wait: wait queue to sync net detect data.316* @nd_data_completed: completion for net detect data.317* @nd_enabled: net detect enabled.318*/319struct brcmf_cfg80211_wowl {320bool active;321u32 pre_pmmode;322struct cfg80211_wowlan_nd_match *nd;323struct cfg80211_wowlan_nd_info *nd_info;324wait_queue_head_t nd_data_wait;325bool nd_data_completed;326bool nd_enabled;327};328329/**330* struct brcmf_cfg80211_info - dongle private data of cfg80211 interface331*332* @wiphy: wiphy object for cfg80211 interface.333* @ops: pointer to copy of ops as registered with wiphy object.334* @conf: dongle configuration.335* @p2p: peer-to-peer specific information.336* @btcoex: Bluetooth coexistence information.337* @scan_request: cfg80211 scan request object.338* @usr_sync: mainly for dongle up/down synchronization.339* @bss_list: bss_list holding scanned ap information.340* @bss_info: bss information for cfg80211 layer.341* @conn_info: association info.342* @pmk_list: wpa2 pmk list.343* @scan_status: scan activity on the dongle.344* @pub: common driver information.345* @channel: current channel.346* @int_escan_map: bucket map for which internal e-scan is done.347* @ibss_starter: indicates this sta is ibss starter.348* @pwr_save: indicate whether dongle to support power save mode.349* @dongle_up: indicate whether dongle up or not.350* @roam_on: on/off switch for dongle self-roaming.351* @scan_tried: indicates if first scan attempted.352* @dcmd_buf: dcmd buffer.353* @extra_buf: mainly to grab assoc information.354* @debugfsdir: debugfs folder for this device.355* @escan_info: escan information.356* @escan_timeout: Timer for catch scan timeout.357* @escan_timeout_work: scan timeout worker.358* @vif_list: linked list of vif instances.359* @vif_cnt: number of vif instances.360* @vif_event: vif event signalling.361* @wowl: wowl related information.362* @pno: information of pno module.363*/364struct brcmf_cfg80211_info {365struct wiphy *wiphy;366struct brcmf_cfg80211_conf *conf;367struct brcmf_p2p_info p2p;368struct brcmf_btcoex_info *btcoex;369struct cfg80211_scan_request *scan_request;370struct mutex usr_sync;371struct wl_cfg80211_bss_info *bss_info;372struct brcmf_cfg80211_connect_info conn_info;373struct brcmf_pmk_list_le pmk_list;374unsigned long scan_status;375struct brcmf_pub *pub;376u32 channel;377u32 int_escan_map;378bool ibss_starter;379bool pwr_save;380bool dongle_up;381bool scan_tried;382u8 *dcmd_buf;383u8 *extra_buf;384struct dentry *debugfsdir;385struct escan_info escan_info;386struct timer_list escan_timeout;387struct work_struct escan_timeout_work;388struct list_head vif_list;389struct brcmf_cfg80211_vif_event vif_event;390struct completion vif_disabled;391struct brcmu_d11inf d11inf;392struct brcmf_assoclist_le assoclist;393struct brcmf_cfg80211_wowl wowl;394struct brcmf_pno_info *pno;395u8 ac_priority[MAX_8021D_PRIO];396};397398/**399* struct brcmf_tlv - tag_ID/length/value_buffer tuple.400*401* @id: tag identifier.402* @len: number of bytes in value buffer.403* @data: value buffer.404*/405struct brcmf_tlv {406u8 id;407u8 len;408u8 data[];409};410411static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *cfg)412{413return cfg->wiphy;414}415416static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w)417{418struct brcmf_pub *drvr = wiphy_priv(w);419return drvr->config;420}421422static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd)423{424return wiphy_to_cfg(wd->wiphy);425}426427static inline struct brcmf_cfg80211_vif *wdev_to_vif(struct wireless_dev *wdev)428{429return container_of(wdev, struct brcmf_cfg80211_vif, wdev);430}431432static inline433struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg)434{435return brcmf_get_ifp(cfg->pub, 0)->ndev;436}437438static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev)439{440return wdev_to_cfg(ndev->ieee80211_ptr);441}442443static inline struct brcmf_cfg80211_profile *ndev_to_prof(struct net_device *nd)444{445struct brcmf_if *ifp = netdev_priv(nd);446return &ifp->vif->profile;447}448449static inline struct brcmf_cfg80211_vif *ndev_to_vif(struct net_device *ndev)450{451struct brcmf_if *ifp = netdev_priv(ndev);452return ifp->vif;453}454455static inline struct456brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg)457{458return &cfg->conn_info;459}460461struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,462struct cfg80211_ops *ops,463bool p2pdev_forced);464void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg);465s32 brcmf_cfg80211_up(struct net_device *ndev);466s32 brcmf_cfg80211_down(struct net_device *ndev);467struct cfg80211_ops *brcmf_cfg80211_get_ops(struct brcmf_mp_device *settings);468469struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg,470enum nl80211_iftype type);471void brcmf_free_vif(struct brcmf_cfg80211_vif *vif);472473s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 pktflag,474const u8 *vndr_ie_buf, u32 vndr_ie_len);475s32 brcmf_vif_clear_mgmt_ies(struct brcmf_cfg80211_vif *vif);476u16 channel_to_chanspec(struct brcmu_d11inf *d11inf,477struct ieee80211_channel *ch);478bool brcmf_get_vif_state_any(struct brcmf_cfg80211_info *cfg,479unsigned long state);480void brcmf_cfg80211_arm_vif_event(struct brcmf_cfg80211_info *cfg,481struct brcmf_cfg80211_vif *vif);482bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg);483int brcmf_cfg80211_wait_vif_event(struct brcmf_cfg80211_info *cfg,484u8 action, ulong timeout);485s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg,486struct brcmf_if *ifp, bool aborted,487bool fw_abort);488void brcmf_set_mpc(struct brcmf_if *ndev, int mpc);489bool brcmf_is_apmode_operating(struct wiphy *wiphy);490void brcmf_abort_scanning(struct brcmf_cfg80211_info *cfg);491void brcmf_cfg80211_free_netdev(struct net_device *ndev);492493int brcmf_set_wsec(struct brcmf_if *ifp, const u8 *key, u16 key_len, u16 flags);494int brcmf_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,495struct cfg80211_mgmt_tx_params *params, u64 *cookie);496497#endif /* BRCMFMAC_CFG80211_H */498499500