8229 lines · 320.2 KB · C
RawDownload
/* SPDX-License-Identifier: GPL-2.0-only *//* * mac80211 <-> driver interface * * Copyright 2002-2005, Devicescape Software, Inc. * Copyright 2006-2007	Jiri Benc <jbenc@suse.cz> * Copyright 2007-2010	Johannes Berg <johannes@sipsolutions.net> * Copyright 2013-2014  Intel Mobile Communications GmbH * Copyright (C) 2015 - 2017 Intel Deutschland GmbH * Copyright (C) 2018 - 2026 Intel Corporation */ #ifndef MAC80211_H#define MAC80211_H #include <linux/bug.h>#include <linux/kernel.h>#include <linux/if_ether.h>#include <linux/skbuff.h>#include <linux/ieee80211.h>#include <linux/lockdep.h>#include <net/cfg80211.h>#include <net/codel.h>#include <net/ieee80211_radiotap.h>#include <linux/unaligned.h> /** * DOC: Introduction * * mac80211 is the Linux stack for 802.11 hardware that implements * only partial functionality in hard- or firmware. This document * defines the interface between mac80211 and low-level hardware * drivers. */ /** * DOC: Calling mac80211 from interrupts * * Only ieee80211_tx_status_irqsafe() and ieee80211_rx_irqsafe() can be * called in hardware interrupt context. The low-level driver must not call any * other functions in hardware interrupt context. If there is a need for such * call, the low-level driver should first ACK the interrupt and perform the * IEEE 802.11 code call after this, e.g. from a scheduled workqueue or even * tasklet function. * * NOTE: If the driver opts to use the _irqsafe() functions, it may not also *	 use the non-IRQ-safe functions! */ /** * DOC: Warning * * If you're reading this document and not the header file itself, it will * be incomplete because not all documentation has been converted yet. */ /** * DOC: Frame format * * As a general rule, when frames are passed between mac80211 and the driver, * they start with the IEEE 802.11 header and include the same octets that are * sent over the air except for the FCS which should be calculated by the * hardware. * * There are, however, various exceptions to this rule for advanced features: * * The first exception is for hardware encryption and decryption offload * where the IV/ICV may or may not be generated in hardware. * * Secondly, when the hardware handles fragmentation, the frame handed to * the driver from mac80211 is the MSDU, not the MPDU. */ /** * DOC: mac80211 workqueue * * mac80211 provides its own workqueue for drivers and internal mac80211 use. * The workqueue is a single threaded workqueue and can only be accessed by * helpers for sanity checking. Drivers must ensure all work added onto the * mac80211 workqueue should be cancelled on the driver stop() callback. * * mac80211 will flush the workqueue upon interface removal and during * suspend. * * All work performed on the mac80211 workqueue must not acquire the RTNL lock. * */ /** * DOC: mac80211 software tx queueing * * mac80211 uses an intermediate queueing implementation, designed to allow the * driver to keep hardware queues short and to provide some fairness between * different stations/interfaces. * * Drivers must provide the .wake_tx_queue driver operation by either * linking it to ieee80211_handle_wake_tx_queue() or implementing a custom * handler. * * Intermediate queues (struct ieee80211_txq) are kept per-sta per-tid, with * another per-sta for non-data/non-mgmt and bufferable management frames, and * a single per-vif queue for multicast data frames. * * The driver is expected to initialize its private per-queue data for stations * and interfaces in the .add_interface and .sta_add ops. * * The driver can't access the internal TX queues (iTXQs) directly. * Whenever mac80211 adds a new frame to a queue, it calls the .wake_tx_queue * driver op. * Drivers implementing a custom .wake_tx_queue op can get them by calling * ieee80211_tx_dequeue(). Drivers using ieee80211_handle_wake_tx_queue() will * simply get the individual frames pushed via the .tx driver operation. * * Drivers can optionally delegate responsibility for scheduling queues to * mac80211, to take advantage of airtime fairness accounting. In this case, to * obtain the next queue to pull frames from, the driver calls * ieee80211_next_txq(). The driver is then expected to return the txq using * ieee80211_return_txq(). * * For AP powersave TIM handling, the driver only needs to indicate if it has * buffered packets in the driver specific data structures by calling * ieee80211_sta_set_buffered(). For frames buffered in the ieee80211_txq * struct, mac80211 sets the appropriate TIM PVB bits and calls * .release_buffered_frames(). * In that callback the driver is therefore expected to release its own * buffered frames and afterwards also frames from the ieee80211_txq (obtained * via the usual ieee80211_tx_dequeue). */ /** * DOC: HW timestamping * * Timing Measurement and Fine Timing Measurement require accurate timestamps * of the action frames TX/RX and their respective acks. * * To report hardware timestamps for Timing Measurement or Fine Timing * Measurement frame RX, the low level driver should set the SKB's hwtstamp * field to the frame RX timestamp and report the ack TX timestamp in the * ieee80211_rx_status struct. * * Similarly, to report hardware timestamps for Timing Measurement or Fine * Timing Measurement frame TX, the driver should set the SKB's hwtstamp field * to the frame TX timestamp and report the ack RX timestamp in the * ieee80211_tx_status struct. */struct device; /** * enum ieee80211_max_queues - maximum number of queues * * @IEEE80211_MAX_QUEUES: Maximum number of regular device queues. * @IEEE80211_MAX_QUEUE_MAP: bitmap with maximum queues set */enum ieee80211_max_queues {	IEEE80211_MAX_QUEUES =		16,	IEEE80211_MAX_QUEUE_MAP =	BIT(IEEE80211_MAX_QUEUES) - 1,}; #define IEEE80211_INVAL_HW_QUEUE	0xff /** * enum ieee80211_ac_numbers - AC numbers as used in mac80211 * @IEEE80211_AC_VO: voice * @IEEE80211_AC_VI: video * @IEEE80211_AC_BE: best effort * @IEEE80211_AC_BK: background */enum ieee80211_ac_numbers {	IEEE80211_AC_VO		= 0,	IEEE80211_AC_VI		= 1,	IEEE80211_AC_BE		= 2,	IEEE80211_AC_BK		= 3,}; /** * struct ieee80211_tx_queue_params - transmit queue configuration * * The information provided in this structure is required for QoS * transmit queue configuration. Cf. IEEE 802.11 7.3.2.29. * * @aifs: arbitration interframe space [0..255] * @cw_min: minimum contention window [a value of the form *	2^n-1 in the range 1..32767] * @cw_max: maximum contention window [like @cw_min] * @txop: maximum burst time in units of 32 usecs, 0 meaning disabled * @acm: is mandatory admission control required for the access category * @uapsd: is U-APSD mode enabled for the queue * @mu_edca: is the MU EDCA configured * @mu_edca_param_rec: MU EDCA Parameter Record for HE */struct ieee80211_tx_queue_params {	u16 txop;	u16 cw_min;	u16 cw_max;	u8 aifs;	bool acm;	bool uapsd;	bool mu_edca;	struct ieee80211_he_mu_edca_param_ac_rec mu_edca_param_rec;}; struct ieee80211_low_level_stats {	unsigned int dot11ACKFailureCount;	unsigned int dot11RTSFailureCount;	unsigned int dot11FCSErrorCount;	unsigned int dot11RTSSuccessCount;}; /** * enum ieee80211_chanctx_change - change flag for channel context * @IEEE80211_CHANCTX_CHANGE_WIDTH: The channel width changed * @IEEE80211_CHANCTX_CHANGE_RX_CHAINS: The number of RX chains changed * @IEEE80211_CHANCTX_CHANGE_RADAR: radar detection flag changed * @IEEE80211_CHANCTX_CHANGE_CHANNEL: switched to another operating channel, *	this is used only with channel switching with CSA * @IEEE80211_CHANCTX_CHANGE_MIN_DEF: The min chandef changed * @IEEE80211_CHANCTX_CHANGE_AP: The AP channel definition changed, so (wider *	bandwidth) OFDMA settings need to be changed * @IEEE80211_CHANCTX_CHANGE_PUNCTURING: The punctured channel(s) bitmap *	was changed. * @IEEE80211_CHANCTX_CHANGE_NPCA: NPCA configuration changed * @IEEE80211_CHANCTX_CHANGE_NPCA_PUNCT: NPCA puncturing changed */enum ieee80211_chanctx_change {	IEEE80211_CHANCTX_CHANGE_WIDTH		= BIT(0),	IEEE80211_CHANCTX_CHANGE_RX_CHAINS	= BIT(1),	IEEE80211_CHANCTX_CHANGE_RADAR		= BIT(2),	IEEE80211_CHANCTX_CHANGE_CHANNEL	= BIT(3),	IEEE80211_CHANCTX_CHANGE_MIN_DEF	= BIT(4),	IEEE80211_CHANCTX_CHANGE_AP		= BIT(5),	IEEE80211_CHANCTX_CHANGE_PUNCTURING	= BIT(6),	IEEE80211_CHANCTX_CHANGE_NPCA		= BIT(7),	IEEE80211_CHANCTX_CHANGE_NPCA_PUNCT	= BIT(8),}; /** * struct ieee80211_chan_req - A channel "request" * @oper: channel definition to use for operation * @ap: the channel definition of the AP, if any *	(otherwise the chan member is %NULL) * @require_npca: If NPCA is configured, require it to *	remain, this is used by AP interfaces */struct ieee80211_chan_req {	struct cfg80211_chan_def oper;	struct cfg80211_chan_def ap;	bool require_npca;}; /** * struct ieee80211_chanctx_conf - channel context that vifs may be tuned to * * This is the driver-visible part. The ieee80211_chanctx * that contains it is visible in mac80211 only. * * @def: the channel definition * @min_def: the minimum channel definition currently required. * @ap: the channel definition the AP actually is operating as, *	for use with (wider bandwidth) OFDMA * @radio_idx: index of the wiphy radio used used for this channel * @rx_chains_static: The number of RX chains that must always be *	active on the channel to receive MIMO transmissions * @rx_chains_dynamic: The number of RX chains that must be enabled *	after RTS/CTS handshake to receive SMPS MIMO transmissions; *	this will always be >= @rx_chains_static. * @radar_enabled: whether radar detection is enabled on this channel. * @drv_priv: data area for driver use, will always be aligned to *	sizeof(void *), size is determined in hw information. */struct ieee80211_chanctx_conf {	struct cfg80211_chan_def def;	struct cfg80211_chan_def min_def;	struct cfg80211_chan_def ap; 	int radio_idx;	u8 rx_chains_static, rx_chains_dynamic; 	bool radar_enabled; 	u8 drv_priv[] __aligned(sizeof(void *));}; /** * enum ieee80211_chanctx_switch_mode - channel context switch mode * @CHANCTX_SWMODE_REASSIGN_VIF: Both old and new contexts already *	exist (and will continue to exist), but the virtual interface *	needs to be switched from one to the other. * @CHANCTX_SWMODE_SWAP_CONTEXTS: The old context exists but will stop *      to exist with this call, the new context doesn't exist but *      will be active after this call, the virtual interface switches *      from the old to the new (note that the driver may of course *      implement this as an on-the-fly chandef switch of the existing *      hardware context, but the mac80211 pointer for the old context *      will cease to exist and only the new one will later be used *      for changes/removal.) */enum ieee80211_chanctx_switch_mode {	CHANCTX_SWMODE_REASSIGN_VIF,	CHANCTX_SWMODE_SWAP_CONTEXTS,}; /** * struct ieee80211_vif_chanctx_switch - vif chanctx switch information * * This is structure is used to pass information about a vif that * needs to switch from one chanctx to another.  The * &ieee80211_chanctx_switch_mode defines how the switch should be * done. * * @vif: the vif that should be switched from old_ctx to new_ctx * @link_conf: the link conf that's switching * @old_ctx: the old context to which the vif was assigned * @new_ctx: the new context to which the vif must be assigned */struct ieee80211_vif_chanctx_switch {	struct ieee80211_vif *vif;	struct ieee80211_bss_conf *link_conf;	struct ieee80211_chanctx_conf *old_ctx;	struct ieee80211_chanctx_conf *new_ctx;}; /** * enum ieee80211_bss_change - BSS change notification flags * * These flags are used with the bss_info_changed(), link_info_changed() * and vif_cfg_changed() callbacks to indicate which parameter(s) changed. * * @BSS_CHANGED_ASSOC: association status changed (associated/disassociated), *	also implies a change in the AID. * @BSS_CHANGED_ERP_CTS_PROT: CTS protection changed * @BSS_CHANGED_ERP_PREAMBLE: preamble changed * @BSS_CHANGED_ERP_SLOT: slot timing changed * @BSS_CHANGED_HT: 802.11n parameters changed * @BSS_CHANGED_BASIC_RATES: Basic rateset changed * @BSS_CHANGED_BEACON_INT: Beacon interval changed * @BSS_CHANGED_BSSID: BSSID changed, for whatever *	reason (IBSS and managed mode) * @BSS_CHANGED_BEACON: Beacon data changed, retrieve *	new beacon (beaconing modes) * @BSS_CHANGED_BEACON_ENABLED: Beaconing should be *	enabled/disabled (beaconing modes) * @BSS_CHANGED_CQM: Connection quality monitor config changed * @BSS_CHANGED_IBSS: IBSS join status changed * @BSS_CHANGED_ARP_FILTER: Hardware ARP filter address list or state changed. * @BSS_CHANGED_QOS: QoS for this association was enabled/disabled. Note *	that it is only ever disabled for station mode. * @BSS_CHANGED_IDLE: Idle changed for this BSS/interface. * @BSS_CHANGED_SSID: SSID changed for this BSS (AP and IBSS mode) * @BSS_CHANGED_AP_PROBE_RESP: Probe Response changed for this BSS (AP mode) * @BSS_CHANGED_PS: PS changed for this BSS (STA mode) * @BSS_CHANGED_TXPOWER: TX power setting changed for this interface * @BSS_CHANGED_P2P_PS: P2P powersave settings (CTWindow, opportunistic PS) *	changed * @BSS_CHANGED_BEACON_INFO: Data from the AP's beacon became available: *	currently dtim_period only is under consideration. * @BSS_CHANGED_BANDWIDTH: The bandwidth used by this interface changed, *	note that this is only called when it changes after the channel *	context had been assigned. * @BSS_CHANGED_OCB: OCB join status changed * @BSS_CHANGED_MU_GROUPS: VHT MU-MIMO group id or user position changed * @BSS_CHANGED_KEEP_ALIVE: keep alive options (idle period or protected *	keep alive) changed. * @BSS_CHANGED_MCAST_RATE: Multicast Rate setting changed for this interface * @BSS_CHANGED_FTM_RESPONDER: fine timing measurement request responder *	functionality changed for this BSS (AP mode). * @BSS_CHANGED_TWT: TWT status changed * @BSS_CHANGED_HE_OBSS_PD: OBSS Packet Detection status changed. * @BSS_CHANGED_HE_BSS_COLOR: BSS Color has changed * @BSS_CHANGED_FILS_DISCOVERY: FILS discovery status changed. * @BSS_CHANGED_UNSOL_BCAST_PROBE_RESP: Unsolicited broadcast probe response *	status changed. * @BSS_CHANGED_MLD_VALID_LINKS: MLD valid links status changed. * @BSS_CHANGED_MLD_TTLM: negotiated TID to link mapping was changed * @BSS_CHANGED_TPE: transmit power envelope changed * @BSS_CHANGED_NAN_LOCAL_SCHED: NAN local schedule changed (NAN mode only) * @BSS_CHANGED_NPCA: NPCA parameters changed */enum ieee80211_bss_change {	BSS_CHANGED_ASSOC		= 1<<0,	BSS_CHANGED_ERP_CTS_PROT	= 1<<1,	BSS_CHANGED_ERP_PREAMBLE	= 1<<2,	BSS_CHANGED_ERP_SLOT		= 1<<3,	BSS_CHANGED_HT			= 1<<4,	BSS_CHANGED_BASIC_RATES		= 1<<5,	BSS_CHANGED_BEACON_INT		= 1<<6,	BSS_CHANGED_BSSID		= 1<<7,	BSS_CHANGED_BEACON		= 1<<8,	BSS_CHANGED_BEACON_ENABLED	= 1<<9,	BSS_CHANGED_CQM			= 1<<10,	BSS_CHANGED_IBSS		= 1<<11,	BSS_CHANGED_ARP_FILTER		= 1<<12,	BSS_CHANGED_QOS			= 1<<13,	BSS_CHANGED_IDLE		= 1<<14,	BSS_CHANGED_SSID		= 1<<15,	BSS_CHANGED_AP_PROBE_RESP	= 1<<16,	BSS_CHANGED_PS			= 1<<17,	BSS_CHANGED_TXPOWER		= 1<<18,	BSS_CHANGED_P2P_PS		= 1<<19,	BSS_CHANGED_BEACON_INFO		= 1<<20,	BSS_CHANGED_BANDWIDTH		= 1<<21,	BSS_CHANGED_OCB                 = 1<<22,	BSS_CHANGED_MU_GROUPS		= 1<<23,	BSS_CHANGED_KEEP_ALIVE		= 1<<24,	BSS_CHANGED_MCAST_RATE		= 1<<25,	BSS_CHANGED_FTM_RESPONDER	= 1<<26,	BSS_CHANGED_TWT			= 1<<27,	BSS_CHANGED_HE_OBSS_PD		= 1<<28,	BSS_CHANGED_HE_BSS_COLOR	= 1<<29,	BSS_CHANGED_FILS_DISCOVERY      = 1<<30,	BSS_CHANGED_UNSOL_BCAST_PROBE_RESP = BIT_ULL(31),	BSS_CHANGED_MLD_VALID_LINKS	= BIT_ULL(33),	BSS_CHANGED_MLD_TTLM		= BIT_ULL(34),	BSS_CHANGED_TPE			= BIT_ULL(35),	BSS_CHANGED_NAN_LOCAL_SCHED	= BIT_ULL(36),	BSS_CHANGED_NPCA		= BIT_ULL(37), 	/* when adding here, make sure to change ieee80211_reconfig */}; /* * The maximum number of IPv4 addresses listed for ARP filtering. If the number * of addresses for an interface increase beyond this value, hardware ARP * filtering will be disabled. */#define IEEE80211_BSS_ARP_ADDR_LIST_LEN 4 /** * enum ieee80211_event_type - event to be notified to the low level driver * @RSSI_EVENT: AP's rssi crossed the a threshold set by the driver. * @MLME_EVENT: event related to MLME * @BAR_RX_EVENT: a BAR was received * @BA_FRAME_TIMEOUT: Frames were released from the reordering buffer because *	they timed out. This won't be called for each frame released, but only *	once each time the timeout triggers. */enum ieee80211_event_type {	RSSI_EVENT,	MLME_EVENT,	BAR_RX_EVENT,	BA_FRAME_TIMEOUT,}; /** * enum ieee80211_rssi_event_data - relevant when event type is %RSSI_EVENT * @RSSI_EVENT_HIGH: AP's rssi went below the threshold set by the driver. * @RSSI_EVENT_LOW: AP's rssi went above the threshold set by the driver. */enum ieee80211_rssi_event_data {	RSSI_EVENT_HIGH,	RSSI_EVENT_LOW,}; /** * struct ieee80211_rssi_event - data attached to an %RSSI_EVENT * @data: See &enum ieee80211_rssi_event_data */struct ieee80211_rssi_event {	enum ieee80211_rssi_event_data data;}; /** * enum ieee80211_mlme_event_data - relevant when event type is %MLME_EVENT * @AUTH_EVENT: the MLME operation is authentication * @ASSOC_EVENT: the MLME operation is association * @DEAUTH_RX_EVENT: deauth received.. * @DEAUTH_TX_EVENT: deauth sent. */enum ieee80211_mlme_event_data {	AUTH_EVENT,	ASSOC_EVENT,	DEAUTH_RX_EVENT,	DEAUTH_TX_EVENT,}; /** * enum ieee80211_mlme_event_status - relevant when event type is %MLME_EVENT * @MLME_SUCCESS: the MLME operation completed successfully. * @MLME_DENIED: the MLME operation was denied by the peer. * @MLME_TIMEOUT: the MLME operation timed out. */enum ieee80211_mlme_event_status {	MLME_SUCCESS,	MLME_DENIED,	MLME_TIMEOUT,}; /** * struct ieee80211_mlme_event - data attached to an %MLME_EVENT * @data: See &enum ieee80211_mlme_event_data * @status: See &enum ieee80211_mlme_event_status * @reason: the reason code if applicable */struct ieee80211_mlme_event {	enum ieee80211_mlme_event_data data;	enum ieee80211_mlme_event_status status;	u16 reason;}; /** * struct ieee80211_ba_event - data attached for BlockAck related events

Lines 1–500 of 8229.