cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

cfg80211.h (13823B)


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