Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/include/drivers/net/mac80211.h need to be fixed.

0001 /*                    The Quest Operating System
0002  *  Copyright (C) 2005-2010  Richard West, Boston University
0003  *
0004  *  This program is free software: you can redistribute it and/or modify
0005  *  it under the terms of the GNU General Public License as published by
0006  *  the Free Software Foundation, either version 3 of the License, or
0007  *  (at your option) any later version.
0008  *
0009  *  This program is distributed in the hope that it will be useful,
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *  GNU General Public License for more details.
0013  *
0014  *  You should have received a copy of the GNU General Public License
0015  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 /* Based on Linux */
0019 
0020 /*
0021  * mac80211 <-> driver interface
0022  *
0023  * Copyright 2002-2005, Devicescape Software, Inc.
0024  * Copyright 2006-2007  Jiri Benc <jbenc@suse.cz>
0025  * Copyright 2007-2008  Johannes Berg <johannes@sipsolutions.net>
0026  *
0027  * This program is free software; you can redistribute it and/or modify
0028  * it under the terms of the GNU General Public License version 2 as
0029  * published by the Free Software Foundation.
0030  */
0031 
0032 #ifndef MAC80211_H
0033 #define MAC80211_H
0034 
0035 #include <kernel.h>
0036 #include <drivers/net/skbuff.h>
0037 #include <drivers/net/ieee80211.h>
0038 #include <drivers/net/cfg80211.h>
0039 
0040 /**
0041  * enum nl80211_iftype - (virtual) interface types
0042  *
0043  * @NL80211_IFTYPE_UNSPECIFIED: unspecified type, driver decides
0044  * @NL80211_IFTYPE_ADHOC: independent BSS member
0045  * @NL80211_IFTYPE_STATION: managed BSS member
0046  * @NL80211_IFTYPE_AP: access point
0047  * @NL80211_IFTYPE_AP_VLAN: VLAN interface for access points
0048  * @NL80211_IFTYPE_WDS: wireless distribution interface
0049  * @NL80211_IFTYPE_MONITOR: monitor interface receiving all frames
0050  * @NL80211_IFTYPE_MESH_POINT: mesh point
0051  * @NL80211_IFTYPE_MAX: highest interface type number currently defined
0052  * @__NL80211_IFTYPE_AFTER_LAST: internal use
0053  *
0054  * These values are used with the %NL80211_ATTR_IFTYPE
0055  * to set the type of an interface.
0056  *
0057  */
0058 enum nl80211_iftype {
0059   NL80211_IFTYPE_UNSPECIFIED,
0060   NL80211_IFTYPE_ADHOC,
0061   NL80211_IFTYPE_STATION,
0062   NL80211_IFTYPE_AP,
0063   NL80211_IFTYPE_AP_VLAN,
0064   NL80211_IFTYPE_WDS,
0065   NL80211_IFTYPE_MONITOR,
0066   NL80211_IFTYPE_MESH_POINT,
0067 
0068   /* keep last */
0069   __NL80211_IFTYPE_AFTER_LAST,
0070   NL80211_IFTYPE_MAX = __NL80211_IFTYPE_AFTER_LAST - 1
0071 };
0072 
0073 /**
0074  * enum ieee80211_bss_change - BSS change notification flags
0075  *
0076  * These flags are used with the bss_info_changed() callback
0077  * to indicate which BSS parameter changed.
0078  *
0079  * @BSS_CHANGED_ASSOC: association status changed (associated/disassociated),
0080  *      also implies a change in the AID.
0081  * @BSS_CHANGED_ERP_CTS_PROT: CTS protection changed
0082  * @BSS_CHANGED_ERP_PREAMBLE: preamble changed
0083  * @BSS_CHANGED_ERP_SLOT: slot timing changed
0084  * @BSS_CHANGED_HT: 802.11n parameters changed
0085  * @BSS_CHANGED_BASIC_RATES: Basic rateset changed
0086  * @BSS_CHANGED_BEACON_INT: Beacon interval changed
0087  * @BSS_CHANGED_BSSID: BSSID changed, for whatever
0088  *      reason (IBSS and managed mode)
0089  * @BSS_CHANGED_BEACON: Beacon data changed, retrieve
0090  *      new beacon (beaconing modes)
0091  * @BSS_CHANGED_BEACON_ENABLED: Beaconing should be
0092  *      enabled/disabled (beaconing modes)
0093  */
0094 enum ieee80211_bss_change {
0095   BSS_CHANGED_ASSOC             = 1<<0,
0096   BSS_CHANGED_ERP_CTS_PROT      = 1<<1,
0097   BSS_CHANGED_ERP_PREAMBLE      = 1<<2,
0098   BSS_CHANGED_ERP_SLOT          = 1<<3,
0099   BSS_CHANGED_HT                  = 1<<4,
0100   BSS_CHANGED_BASIC_RATES               = 1<<5,
0101   BSS_CHANGED_BEACON_INT                = 1<<6,
0102   BSS_CHANGED_BSSID             = 1<<7,
0103   BSS_CHANGED_BEACON            = 1<<8,
0104   BSS_CHANGED_BEACON_ENABLED    = 1<<9,
0105 };
0106 
0107 /**
0108  * struct ieee80211_bss_conf - holds the BSS's changing parameters
0109  *
0110  * This structure keeps information about a BSS (and an association
0111  * to that BSS) that can change during the lifetime of the BSS.
0112  *
0113  * @assoc: association status
0114  * @aid: association ID number, valid only when @assoc is true
0115  * @use_cts_prot: use CTS protection
0116  * @use_short_preamble: use 802.11b short preamble;
0117  *      if the hardware cannot handle this it must set the
0118  *      IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE hardware flag
0119  * @use_short_slot: use short slot time (only relevant for ERP);
0120  *      if the hardware cannot handle this it must set the
0121  *      IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE hardware flag
0122  * @dtim_period: num of beacons before the next DTIM, for PSM
0123  * @timestamp: beacon timestamp
0124  * @beacon_int: beacon interval
0125  * @assoc_capability: capabilities taken from assoc resp
0126  * @basic_rates: bitmap of basic rates, each bit stands for an
0127  *      index into the rate table configured by the driver in
0128  *      the current band.
0129  * @bssid: The BSSID for this BSS
0130  * @enable_beacon: whether beaconing should be enabled or not
0131  * @ht_operation_mode: HT operation mode (like in &struct ieee80211_ht_info).
0132  *      This field is only valid when the channel type is one of the HT types.
0133  */
0134 struct ieee80211_bss_conf {
0135   const u8 *bssid;
0136   /* association related data */
0137   bool assoc;
0138   u16 aid;
0139   /* erp related data */
0140   bool use_cts_prot;
0141   bool use_short_preamble;
0142   bool use_short_slot;
0143   bool enable_beacon;
0144   u8 dtim_period;
0145   u16 beacon_int;
0146   u16 assoc_capability;
0147   u64 timestamp;
0148   u32 basic_rates;
0149   u16 ht_operation_mode;
0150 };
0151 
0152 /**
0153  * struct ieee80211_vif - per-interface data
0154  *
0155  * Data in this structure is continually present for driver
0156  * use during the life of a virtual interface.
0157  *
0158  * @type: type of this virtual interface
0159  * @bss_conf: BSS configuration for this interface, either our own
0160  *      or the BSS we're associated to
0161  * @drv_priv: data area for driver use, will always be aligned to
0162  *      sizeof(void *).
0163  */
0164 struct ieee80211_vif {
0165   enum nl80211_iftype type;
0166   struct ieee80211_bss_conf bss_conf;
0167   /* must be last */
0168   u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
0169 };
0170 
0171 /**
0172  * struct ieee80211_if_init_conf - initial configuration of an interface
0173  *
0174  * @vif: pointer to a driver-use per-interface structure. The pointer
0175  *      itself is also used for various functions including
0176  *      ieee80211_beacon_get() and ieee80211_get_buffered_bc().
0177  * @type: one of &enum nl80211_iftype constants. Determines the type of
0178  *      added/removed interface.
0179  * @mac_addr: pointer to MAC address of the interface. This pointer is valid
0180  *      until the interface is removed (i.e. it cannot be used after
0181  *      remove_interface() callback was called for this interface).
0182  *
0183  * This structure is used in add_interface() and remove_interface()
0184  * callbacks of &struct ieee80211_hw.
0185  *
0186  * When you allow multiple interfaces to be added to your PHY, take care
0187  * that the hardware can actually handle multiple MAC addresses. However,
0188  * also take care that when there's no interface left with mac_addr != %NULL
0189  * you remove the MAC address from the device to avoid acknowledging packets
0190  * in pure monitor mode.
0191  */
0192 struct ieee80211_if_init_conf {
0193   enum nl80211_iftype type;
0194   struct ieee80211_vif *vif;
0195   void *mac_addr;
0196 };
0197 
0198 /**
0199  * struct ieee80211_hw - hardware information and state
0200  *
0201  * This structure contains the configuration and hardware
0202  * information for an 802.11 PHY.
0203  *
0204  * @wiphy: This points to the &struct wiphy allocated for this
0205  *      802.11 PHY. You must fill in the @perm_addr and @dev
0206  *      members of this structure using SET_IEEE80211_DEV()
0207  *      and SET_IEEE80211_PERM_ADDR(). Additionally, all supported
0208  *      bands (with channels, bitrates) are registered here.
0209  *
0210  * @conf: &struct ieee80211_conf, device configuration, don't use.
0211  *
0212  * @priv: pointer to private area that was allocated for driver use
0213  *      along with this structure.
0214  *
0215  * @flags: hardware flags, see &enum ieee80211_hw_flags.
0216  *
0217  * @extra_tx_headroom: headroom to reserve in each transmit skb
0218  *      for use by the driver (e.g. for transmit headers.)
0219  *
0220  * @channel_change_time: time (in microseconds) it takes to change channels.
0221  *
0222  * @max_signal: Maximum value for signal (rssi) in RX information, used
0223  *     only when @IEEE80211_HW_SIGNAL_UNSPEC or @IEEE80211_HW_SIGNAL_DB
0224  *
0225  * @max_listen_interval: max listen interval in units of beacon interval
0226  *     that HW supports
0227  *
0228  * @queues: number of available hardware transmit queues for
0229  *      data packets. WMM/QoS requires at least four, these
0230  *      queues need to have configurable access parameters.
0231  *
0232  * @rate_control_algorithm: rate control algorithm for this hardware.
0233  *      If unset (NULL), the default algorithm will be used. Must be
0234  *      set before calling ieee80211_register_hw().
0235  *
0236  * @vif_data_size: size (in bytes) of the drv_priv data area
0237  *      within &struct ieee80211_vif.
0238  * @sta_data_size: size (in bytes) of the drv_priv data area
0239  *      within &struct ieee80211_sta.
0240  *
0241  * @max_rates: maximum number of alternate rate retry stages
0242  * @max_rate_tries: maximum number of tries for each stage
0243  */
0244 struct ieee80211_hw {
0245   struct ieee80211_conf conf;
0246   struct wiphy *wiphy;
0247   const char *rate_control_algorithm;
0248   void *priv;
0249   u32 flags;
0250   unsigned int extra_tx_headroom;
0251   int channel_change_time;
0252   int vif_data_size;
0253   int sta_data_size;
0254   u16 queues;
0255   u16 max_listen_interval;
0256   s8 max_signal;
0257   u8 max_rates;
0258   u8 max_rate_tries;
0259 };
0260 
0261 /**
0262  * struct ieee80211_ops - callbacks from mac80211 to the driver
0263  *
0264  * This structure contains various callbacks that the driver may
0265  * handle or, in some cases, must handle, for example to configure
0266  * the hardware to a new channel or to transmit a frame.
0267  *
0268  * @tx: Handler that 802.11 module calls for each transmitted frame.
0269  *      skb contains the buffer starting from the IEEE 802.11 header.
0270  *      The low-level driver should send the frame out based on
0271  *      configuration in the TX control data. This handler should,
0272  *      preferably, never fail and stop queues appropriately, more
0273  *      importantly, however, it must never fail for A-MPDU-queues.
0274  *      This function should return NETDEV_TX_OK except in very
0275  *      limited cases.
0276  *      Must be implemented and atomic.
0277  *
0278  * @start: Called before the first netdevice attached to the hardware
0279  *      is enabled. This should turn on the hardware and must turn on
0280  *      frame reception (for possibly enabled monitor interfaces.)
0281  *      Returns negative error codes, these may be seen in userspace,
0282  *      or zero.
0283  *      When the device is started it should not have a MAC address
0284  *      to avoid acknowledging frames before a non-monitor device
0285  *      is added.
0286  *      Must be implemented.
0287  *
0288  * @stop: Called after last netdevice attached to the hardware
0289  *      is disabled. This should turn off the hardware (at least
0290  *      it must turn off frame reception.)
0291  *      May be called right after add_interface if that rejects
0292  *      an interface. If you added any work onto the mac80211 workqueue
0293  *      you should ensure to cancel it on this callback.
0294  *      Must be implemented.
0295  *
0296  * @add_interface: Called when a netdevice attached to the hardware is
0297  *      enabled. Because it is not called for monitor mode devices, @start
0298  *      and @stop must be implemented.
0299  *      The driver should perform any initialization it needs before
0300  *      the device can be enabled. The initial configuration for the
0301  *      interface is given in the conf parameter.
0302  *      The callback may refuse to add an interface by returning a
0303  *      negative error code (which will be seen in userspace.)
0304  *      Must be implemented.
0305  *
0306  * @remove_interface: Notifies a driver that an interface is going down.
0307  *      The @stop callback is called after this if it is the last interface
0308  *      and no monitor interfaces are present.
0309  *      When all interfaces are removed, the MAC address in the hardware
0310  *      must be cleared so the device no longer acknowledges packets,
0311  *      the mac_addr member of the conf structure is, however, set to the
0312  *      MAC address of the device going away.
0313  *      Hence, this callback must be implemented.
0314  *
0315  * @config: Handler for configuration requests. IEEE 802.11 code calls this
0316  *      function to change hardware configuration, e.g., channel.
0317  *      This function should never fail but returns a negative error code
0318  *      if it does.
0319  *
0320  * @bss_info_changed: Handler for configuration requests related to BSS
0321  *      parameters that may vary during BSS's lifespan, and may affect low
0322  *      level driver (e.g. assoc/disassoc status, erp parameters).
0323  *      This function should not be used if no BSS has been set, unless
0324  *      for association indication. The @changed parameter indicates which
0325  *      of the bss parameters has changed when a call is made.
0326  *
0327  * @prepare_multicast: Prepare for multicast filter configuration.
0328  *      This callback is optional, and its return value is passed
0329  *      to configure_filter(). This callback must be atomic.
0330  *
0331  * @configure_filter: Configure the device's RX filter.
0332  *      See the section "Frame filtering" for more information.
0333  *      This callback must be implemented.
0334  *
0335  * @set_tim: Set TIM bit. mac80211 calls this function when a TIM bit
0336  *      must be set or cleared for a given STA. Must be atomic.
0337  *
0338  * @set_key: See the section "Hardware crypto acceleration"
0339  *      This callback can sleep, and is only called between add_interface
0340  *      and remove_interface calls, i.e. while the given virtual interface
0341  *      is enabled.
0342  *      Returns a negative error code if the key can't be added.
0343  *
0344  * @update_tkip_key: See the section "Hardware crypto acceleration"
0345  *      This callback will be called in the context of Rx. Called for drivers
0346  *      which set IEEE80211_KEY_FLAG_TKIP_REQ_RX_P1_KEY.
0347  *
0348  * @hw_scan: Ask the hardware to service the scan request, no need to start
0349  *      the scan state machine in stack. The scan must honour the channel
0350  *      configuration done by the regulatory agent in the wiphy's
0351  *      registered bands. The hardware (or the driver) needs to make sure
0352  *      that power save is disabled.
0353  *      The @req ie/ie_len members are rewritten by mac80211 to contain the
0354  *      entire IEs after the SSID, so that drivers need not look at these
0355  *      at all but just send them after the SSID -- mac80211 includes the
0356  *      (extended) supported rates and HT information (where applicable).
0357  *      When the scan finishes, ieee80211_scan_completed() must be called;
0358  *      note that it also must be called when the scan cannot finish due to
0359  *      any error unless this callback returned a negative error code.
0360  *
0361  * @sw_scan_start: Notifier function that is called just before a software scan
0362  *      is started. Can be NULL, if the driver doesn't need this notification.
0363  *
0364  * @sw_scan_complete: Notifier function that is called just after a software scan
0365  *      finished. Can be NULL, if the driver doesn't need this notification.
0366  *
0367  * @get_stats: Return low-level statistics.
0368  *      Returns zero if statistics are available.
0369  *
0370  * @get_tkip_seq: If your device implements TKIP encryption in hardware this
0371  *      callback should be provided to read the TKIP transmit IVs (both IV32
0372  *      and IV16) for the given key from hardware.
0373  *
0374  * @set_rts_threshold: Configuration of RTS threshold (if device needs it)
0375  *
0376  * @sta_notify: Notifies low level driver about addition, removal or power
0377  *      state transition of an associated station, AP,  IBSS/WDS/mesh peer etc.
0378  *      Must be atomic.
0379  *
0380  * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
0381  *      bursting) for a hardware TX queue.
0382  *      Returns a negative error code on failure.
0383  *
0384  * @get_tx_stats: Get statistics of the current TX queue status. This is used
0385  *      to get number of currently queued packets (queue length), maximum queue
0386  *      size (limit), and total number of packets sent using each TX queue
0387  *      (count). The 'stats' pointer points to an array that has hw->queues
0388  *      items.
0389  *
0390  * @get_tsf: Get the current TSF timer value from firmware/hardware. Currently,
0391  *      this is only used for IBSS mode BSSID merging and debugging. Is not a
0392  *      required function.
0393  *
0394  * @set_tsf: Set the TSF timer to the specified value in the firmware/hardware.
0395  *      Currently, this is only used for IBSS mode debugging. Is not a
0396  *      required function.
0397  *
0398  * @reset_tsf: Reset the TSF timer and allow firmware/hardware to synchronize
0399  *      with other STAs in the IBSS. This is only used in IBSS mode. This
0400  *      function is optional if the firmware/hardware takes full care of
0401  *      TSF synchronization.
0402  *
0403  * @tx_last_beacon: Determine whether the last IBSS beacon was sent by us.
0404  *      This is needed only for IBSS mode and the result of this function is
0405  *      used to determine whether to reply to Probe Requests.
0406  *      Returns non-zero if this device sent the last beacon.
0407  *
0408  * @ampdu_action: Perform a certain A-MPDU action
0409  *      The RA/TID combination determines the destination and TID we want
0410  *      the ampdu action to be performed for. The action is defined through
0411  *      ieee80211_ampdu_mlme_action. Starting sequence number (@ssn)
0412  *      is the first frame we expect to perform the action on. Notice
0413  *      that TX/RX_STOP can pass NULL for this parameter.
0414  *      Returns a negative error code on failure.
0415  *
0416  * @rfkill_poll: Poll rfkill hardware state. If you need this, you also
0417  *      need to set wiphy->rfkill_poll to %true before registration,
0418  *      and need to call wiphy_rfkill_set_hw_state() in the callback.
0419  *
0420  * @testmode_cmd: Implement a cfg80211 test mode command.
0421  */
0422 struct ieee80211_ops {
0423   bool (*start)(struct ieee80211_hw *hw);
0424   void (*stop)(struct ieee80211_hw *hw);
0425   int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb);
0426   bool (*config)(struct ieee80211_hw *hw, u32 changed);
0427   bool (*add_interface)(struct ieee80211_hw *hw,
0428                         struct ieee80211_if_init_conf *conf);
0429   void (*remove_interface)(struct ieee80211_hw *hw,
0430                            struct ieee80211_if_init_conf *conf);
0431   void (*bss_info_changed)(struct ieee80211_hw *hw,
0432                            struct ieee80211_vif *vif,
0433                            struct ieee80211_bss_conf *info,
0434                            u32 changed);
0435   bool (*conf_tx)(struct ieee80211_hw *hw, u16 queue,
0436                   const struct ieee80211_tx_queue_params *params);
0437 #if 0
0438   u64 (*prepare_multicast)(struct ieee80211_hw *hw,
0439                            int mc_count, struct dev_addr_list *mc_list);
0440   void (*configure_filter)(struct ieee80211_hw *hw,
0441                            unsigned int changed_flags,
0442                            unsigned int *total_flags,
0443                            u64 multicast);
0444   int (*set_tim)(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
0445                  bool set);
0446   int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd,
0447                  struct ieee80211_vif *vif, struct ieee80211_sta *sta,
0448                  struct ieee80211_key_conf *key);
0449   void (*update_tkip_key)(struct ieee80211_hw *hw,
0450                           struct ieee80211_key_conf *conf, const u8 *address,
0451                           u32 iv32, u16 *phase1key);
0452   int (*hw_scan)(struct ieee80211_hw *hw,
0453                  struct cfg80211_scan_request *req);
0454   void (*sw_scan_start)(struct ieee80211_hw *hw);
0455   void (*sw_scan_complete)(struct ieee80211_hw *hw);
0456   int (*get_stats)(struct ieee80211_hw *hw,
0457                    struct ieee80211_low_level_stats *stats);
0458   void (*get_tkip_seq)(struct ieee80211_hw *hw, u8 hw_key_idx,
0459                        u32 *iv32, u16 *iv16);
0460   int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value);
0461   void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
0462                      enum sta_notify_cmd, struct ieee80211_sta *sta);
0463   int (*get_tx_stats)(struct ieee80211_hw *hw,
0464                       struct ieee80211_tx_queue_stats *stats);
0465   u64 (*get_tsf)(struct ieee80211_hw *hw);
0466   void (*set_tsf)(struct ieee80211_hw *hw, u64 tsf);
0467   void (*reset_tsf)(struct ieee80211_hw *hw);
0468   int (*tx_last_beacon)(struct ieee80211_hw *hw);
0469   int (*ampdu_action)(struct ieee80211_hw *hw,
0470                       enum ieee80211_ampdu_mlme_action action,
0471                       struct ieee80211_sta *sta, u16 tid, u16 *ssn);
0472 
0473   void (*rfkill_poll)(struct ieee80211_hw *hw);
0474 #ifdef CONFIG_NL80211_TESTMODE
0475   int (*testmode_cmd)(struct ieee80211_hw *hw, void *data, int len);
0476 #endif
0477 #endif
0478 };
0479 
0480 /**
0481  * ieee80211_alloc_hw -  Allocate a new hardware device
0482  *
0483  * This must be called once for each hardware device. The returned pointer
0484  * must be used to refer to this device when calling other functions.
0485  * mac80211 allocates a private data area for the driver pointed to by
0486  * @priv in &struct ieee80211_hw, the size of this area is given as
0487  * @priv_data_len.
0488  *
0489  * @priv_data_len: length of private data
0490  * @ops: callbacks for this device
0491  */
0492 struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
0493                                         const struct ieee80211_ops *ops);
0494 
0495 /**
0496  * ieee80211_register_hw - Register hardware device
0497  *
0498  * You must call this function before any other functions in
0499  * mac80211. Note that before a hardware can be registered, you
0500  * need to fill the contained wiphy's information.
0501  *
0502  * @hw: the device to register as returned by ieee80211_alloc_hw()
0503  */
0504 bool ieee80211_register_hw(struct ieee80211_hw *hw);
0505 
0506 
0507 #if 0
0508 
0509 /**
0510  * DOC: Introduction
0511  *
0512  * mac80211 is the Linux stack for 802.11 hardware that implements
0513  * only partial functionality in hard- or firmware. This document
0514  * defines the interface between mac80211 and low-level hardware
0515  * drivers.
0516  */
0517 
0518 /**
0519  * DOC: Calling mac80211 from interrupts
0520  *
0521  * Only ieee80211_tx_status_irqsafe() and ieee80211_rx_irqsafe() can be
0522  * called in hardware interrupt context. The low-level driver must not call any
0523  * other functions in hardware interrupt context. If there is a need for such
0524  * call, the low-level driver should first ACK the interrupt and perform the
0525  * IEEE 802.11 code call after this, e.g. from a scheduled workqueue or even
0526  * tasklet function.
0527  *
0528  * NOTE: If the driver opts to use the _irqsafe() functions, it may not also
0529  *       use the non-IRQ-safe functions!
0530  */
0531 
0532 /**
0533  * DOC: Warning
0534  *
0535  * If you're reading this document and not the header file itself, it will
0536  * be incomplete because not all documentation has been converted yet.
0537  */
0538 
0539 /**
0540  * DOC: Frame format
0541  *
0542  * As a general rule, when frames are passed between mac80211 and the driver,
0543  * they start with the IEEE 802.11 header and include the same octets that are
0544  * sent over the air except for the FCS which should be calculated by the
0545  * hardware.
0546  *
0547  * There are, however, various exceptions to this rule for advanced features:
0548  *
0549  * The first exception is for hardware encryption and decryption offload
0550  * where the IV/ICV may or may not be generated in hardware.
0551  *
0552  * Secondly, when the hardware handles fragmentation, the frame handed to
0553  * the driver from mac80211 is the MSDU, not the MPDU.
0554  *
0555  * Finally, for received frames, the driver is able to indicate that it has
0556  * filled a radiotap header and put that in front of the frame; if it does
0557  * not do so then mac80211 may add this under certain circumstances.
0558  */
0559 
0560 /**
0561  * DOC: mac80211 workqueue
0562  *
0563  * mac80211 provides its own workqueue for drivers and internal mac80211 use.
0564  * The workqueue is a single threaded workqueue and can only be accessed by
0565  * helpers for sanity checking. Drivers must ensure all work added onto the
0566  * mac80211 workqueue should be cancelled on the driver stop() callback.
0567  *
0568  * mac80211 will flushed the workqueue upon interface removal and during
0569  * suspend.
0570  *
0571  * All work performed on the mac80211 workqueue must not acquire the RTNL lock.
0572  *
0573  */
0574 
0575 /**
0576  * enum ieee80211_max_queues - maximum number of queues
0577  *
0578  * @IEEE80211_MAX_QUEUES: Maximum number of regular device queues.
0579  */
0580 enum ieee80211_max_queues {
0581   IEEE80211_MAX_QUEUES =          4,
0582 };
0583 
0584 /**
0585  * struct ieee80211_tx_queue_params - transmit queue configuration
0586  *
0587  * The information provided in this structure is required for QoS
0588  * transmit queue configuration. Cf. IEEE 802.11 7.3.2.29.
0589  *
0590  * @aifs: arbitration interframe space [0..255]
0591  * @cw_min: minimum contention window [a value of the form
0592  *      2^n-1 in the range 1..32767]
0593  * @cw_max: maximum contention window [like @cw_min]
0594  * @txop: maximum burst time in units of 32 usecs, 0 meaning disabled
0595  */
0596 struct ieee80211_tx_queue_params {
0597   u16 txop;
0598   u16 cw_min;
0599   u16 cw_max;
0600   u8 aifs;
0601 };
0602 
0603 /**
0604  * struct ieee80211_tx_queue_stats - transmit queue statistics
0605  *
0606  * @len: number of packets in queue
0607  * @limit: queue length limit
0608  * @count: number of frames sent
0609  */
0610 struct ieee80211_tx_queue_stats {
0611   unsigned int len;
0612   unsigned int limit;
0613   unsigned int count;
0614 };
0615 
0616 struct ieee80211_low_level_stats {
0617   unsigned int dot11ACKFailureCount;
0618   unsigned int dot11RTSFailureCount;
0619   unsigned int dot11FCSErrorCount;
0620   unsigned int dot11RTSSuccessCount;
0621 };
0622 
0623 /**
0624  * enum ieee80211_bss_change - BSS change notification flags
0625  *
0626  * These flags are used with the bss_info_changed() callback
0627  * to indicate which BSS parameter changed.
0628  *
0629  * @BSS_CHANGED_ASSOC: association status changed (associated/disassociated),
0630  *      also implies a change in the AID.
0631  * @BSS_CHANGED_ERP_CTS_PROT: CTS protection changed
0632  * @BSS_CHANGED_ERP_PREAMBLE: preamble changed
0633  * @BSS_CHANGED_ERP_SLOT: slot timing changed
0634  * @BSS_CHANGED_HT: 802.11n parameters changed
0635  * @BSS_CHANGED_BASIC_RATES: Basic rateset changed
0636  * @BSS_CHANGED_BEACON_INT: Beacon interval changed
0637  * @BSS_CHANGED_BSSID: BSSID changed, for whatever
0638  *      reason (IBSS and managed mode)
0639  * @BSS_CHANGED_BEACON: Beacon data changed, retrieve
0640  *      new beacon (beaconing modes)
0641  * @BSS_CHANGED_BEACON_ENABLED: Beaconing should be
0642  *      enabled/disabled (beaconing modes)
0643  */
0644 enum ieee80211_bss_change {
0645   BSS_CHANGED_ASSOC               = 1<<0,
0646   BSS_CHANGED_ERP_CTS_PROT        = 1<<1,
0647   BSS_CHANGED_ERP_PREAMBLE        = 1<<2,
0648   BSS_CHANGED_ERP_SLOT            = 1<<3,
0649   BSS_CHANGED_HT                  = 1<<4,
0650   BSS_CHANGED_BASIC_RATES         = 1<<5,
0651   BSS_CHANGED_BEACON_INT          = 1<<6,
0652   BSS_CHANGED_BSSID               = 1<<7,
0653   BSS_CHANGED_BEACON              = 1<<8,
0654   BSS_CHANGED_BEACON_ENABLED      = 1<<9,
0655 };
0656 
0657 /**
0658  * struct ieee80211_bss_conf - holds the BSS's changing parameters
0659  *
0660  * This structure keeps information about a BSS (and an association
0661  * to that BSS) that can change during the lifetime of the BSS.
0662  *
0663  * @assoc: association status
0664  * @aid: association ID number, valid only when @assoc is true
0665  * @use_cts_prot: use CTS protection
0666  * @use_short_preamble: use 802.11b short preamble;
0667  *      if the hardware cannot handle this it must set the
0668  *      IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE hardware flag
0669  * @use_short_slot: use short slot time (only relevant for ERP);
0670  *      if the hardware cannot handle this it must set the
0671  *      IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE hardware flag
0672  * @dtim_period: num of beacons before the next DTIM, for PSM
0673  * @timestamp: beacon timestamp
0674  * @beacon_int: beacon interval
0675  * @assoc_capability: capabilities taken from assoc resp
0676  * @basic_rates: bitmap of basic rates, each bit stands for an
0677  *      index into the rate table configured by the driver in
0678  *      the current band.
0679  * @bssid: The BSSID for this BSS
0680  * @enable_beacon: whether beaconing should be enabled or not
0681  * @ht_operation_mode: HT operation mode (like in &struct ieee80211_ht_info).
0682  *      This field is only valid when the channel type is one of the HT types.
0683  */
0684 struct ieee80211_bss_conf {
0685   const u8 *bssid;
0686   /* association related data */
0687   bool assoc;
0688   u16 aid;
0689   /* erp related data */
0690   bool use_cts_prot;
0691   bool use_short_preamble;
0692   bool use_short_slot;
0693   bool enable_beacon;
0694   u8 dtim_period;
0695   u16 beacon_int;
0696   u16 assoc_capability;
0697   u64 timestamp;
0698   u32 basic_rates;
0699   u16 ht_operation_mode;
0700 };
0701 
0702 /**
0703  * enum mac80211_tx_control_flags - flags to describe transmission information/status
0704  *
0705  * These flags are used with the @flags member of &ieee80211_tx_info.
0706  *
0707  * @IEEE80211_TX_CTL_REQ_TX_STATUS: request TX status callback for this frame.
0708  * @IEEE80211_TX_CTL_ASSIGN_SEQ: The driver has to assign a sequence
0709  *      number to this frame, taking care of not overwriting the fragment
0710  *      number and increasing the sequence number only when the
0711  *      IEEE80211_TX_CTL_FIRST_FRAGMENT flag is set. mac80211 will properly
0712  *      assign sequence numbers to QoS-data frames but cannot do so correctly
0713  *      for non-QoS-data and management frames because beacons need them from
0714  *      that counter as well and mac80211 cannot guarantee proper sequencing.
0715  *      If this flag is set, the driver should instruct the hardware to
0716  *      assign a sequence number to the frame or assign one itself. Cf. IEEE
0717  *      802.11-2007 7.1.3.4.1 paragraph 3. This flag will always be set for
0718  *      beacons and always be clear for frames without a sequence number field.
0719  * @IEEE80211_TX_CTL_NO_ACK: tell the low level not to wait for an ack
0720  * @IEEE80211_TX_CTL_CLEAR_PS_FILT: clear powersave filter for destination
0721  *      station
0722  * @IEEE80211_TX_CTL_FIRST_FRAGMENT: this is a first fragment of the frame
0723  * @IEEE80211_TX_CTL_SEND_AFTER_DTIM: send this frame after DTIM beacon
0724  * @IEEE80211_TX_CTL_AMPDU: this frame should be sent as part of an A-MPDU
0725  * @IEEE80211_TX_CTL_INJECTED: Frame was injected, internal to mac80211.
0726  * @IEEE80211_TX_STAT_TX_FILTERED: The frame was not transmitted
0727  *      because the destination STA was in powersave mode. Note that to
0728  *      avoid race conditions, the filter must be set by the hardware or
0729  *      firmware upon receiving a frame that indicates that the station
0730  *      went to sleep (must be done on device to filter frames already on
0731  *      the queue) and may only be unset after mac80211 gives the OK for
0732  *      that by setting the IEEE80211_TX_CTL_CLEAR_PS_FILT (see above),
0733  *      since only then is it guaranteed that no more frames are in the
0734  *      hardware queue.
0735  * @IEEE80211_TX_STAT_ACK: Frame was acknowledged
0736  * @IEEE80211_TX_STAT_AMPDU: The frame was aggregated, so status
0737  *      is for the whole aggregation.
0738  * @IEEE80211_TX_STAT_AMPDU_NO_BACK: no block ack was returned,
0739  *      so consider using block ack request (BAR).
0740  * @IEEE80211_TX_CTL_RATE_CTRL_PROBE: internal to mac80211, can be
0741  *      set by rate control algorithms to indicate probe rate, will
0742  *      be cleared for fragmented frames (except on the last fragment)
0743  * @IEEE80211_TX_INTFL_RCALGO: mac80211 internal flag, do not test or
0744  *      set this flag in the driver; indicates that the rate control
0745  *      algorithm was used and should be notified of TX status
0746  * @IEEE80211_TX_INTFL_NEED_TXPROCESSING: completely internal to mac80211,
0747  *      used to indicate that a pending frame requires TX processing before
0748  *      it can be sent out.
0749  * @IEEE80211_TX_INTFL_RETRIED: completely internal to mac80211,
0750  *      used to indicate that a frame was already retried due to PS
0751  * @IEEE80211_TX_INTFL_DONT_ENCRYPT: completely internal to mac80211,
0752  *      used to indicate frame should not be encrypted
0753  * @IEEE80211_TX_CTL_PSPOLL_RESPONSE: (internal?)
0754  *      This frame is a response to a PS-poll frame and should be sent
0755  *      although the station is in powersave mode.
0756  * @IEEE80211_TX_CTL_MORE_FRAMES: More frames will be passed to the
0757  *      transmit function after the current frame, this can be used
0758  *      by drivers to kick the DMA queue only if unset or when the
0759  *      queue gets full.
0760  */
0761 enum mac80211_tx_control_flags {
0762   IEEE80211_TX_CTL_REQ_TX_STATUS          = BIT(0),
0763   IEEE80211_TX_CTL_ASSIGN_SEQ             = BIT(1),
0764   IEEE80211_TX_CTL_NO_ACK                 = BIT(2),
0765   IEEE80211_TX_CTL_CLEAR_PS_FILT          = BIT(3),
0766   IEEE80211_TX_CTL_FIRST_FRAGMENT         = BIT(4),
0767   IEEE80211_TX_CTL_SEND_AFTER_DTIM        = BIT(5),
0768   IEEE80211_TX_CTL_AMPDU                  = BIT(6),
0769   IEEE80211_TX_CTL_INJECTED               = BIT(7),
0770   IEEE80211_TX_STAT_TX_FILTERED           = BIT(8),
0771   IEEE80211_TX_STAT_ACK                   = BIT(9),
0772   IEEE80211_TX_STAT_AMPDU                 = BIT(10),
0773   IEEE80211_TX_STAT_AMPDU_NO_BACK         = BIT(11),
0774   IEEE80211_TX_CTL_RATE_CTRL_PROBE        = BIT(12),
0775   IEEE80211_TX_INTFL_RCALGO               = BIT(13),
0776   IEEE80211_TX_INTFL_NEED_TXPROCESSING    = BIT(14),
0777   IEEE80211_TX_INTFL_RETRIED              = BIT(15),
0778   IEEE80211_TX_INTFL_DONT_ENCRYPT         = BIT(16),
0779   IEEE80211_TX_CTL_PSPOLL_RESPONSE        = BIT(17),
0780   IEEE80211_TX_CTL_MORE_FRAMES            = BIT(18),
0781 };
0782 
0783 /**
0784  * enum mac80211_rate_control_flags - per-rate flags set by the
0785  *      Rate Control algorithm.
0786  *
0787  * These flags are set by the Rate control algorithm for each rate during tx,
0788  * in the @flags member of struct ieee80211_tx_rate.
0789  *
0790  * @IEEE80211_TX_RC_USE_RTS_CTS: Use RTS/CTS exchange for this rate.
0791  * @IEEE80211_TX_RC_USE_CTS_PROTECT: CTS-to-self protection is required.
0792  *      This is set if the current BSS requires ERP protection.
0793  * @IEEE80211_TX_RC_USE_SHORT_PREAMBLE: Use short preamble.
0794  * @IEEE80211_TX_RC_MCS: HT rate.
0795  * @IEEE80211_TX_RC_GREEN_FIELD: Indicates whether this rate should be used in
0796  *      Greenfield mode.
0797  * @IEEE80211_TX_RC_40_MHZ_WIDTH: Indicates if the Channel Width should be 40 MHz.
0798  * @IEEE80211_TX_RC_DUP_DATA: The frame should be transmitted on both of the
0799  *      adjacent 20 MHz channels, if the current channel type is
0800  *      NL80211_CHAN_HT40MINUS or NL80211_CHAN_HT40PLUS.
0801  * @IEEE80211_TX_RC_SHORT_GI: Short Guard interval should be used for this rate.
0802  */
0803 enum mac80211_rate_control_flags {
0804   IEEE80211_TX_RC_USE_RTS_CTS             = BIT(0),
0805   IEEE80211_TX_RC_USE_CTS_PROTECT         = BIT(1),
0806   IEEE80211_TX_RC_USE_SHORT_PREAMBLE      = BIT(2),
0807 
0808   /* rate index is an MCS rate number instead of an index */
0809   IEEE80211_TX_RC_MCS                     = BIT(3),
0810   IEEE80211_TX_RC_GREEN_FIELD             = BIT(4),
0811   IEEE80211_TX_RC_40_MHZ_WIDTH            = BIT(5),
0812   IEEE80211_TX_RC_DUP_DATA                = BIT(6),
0813   IEEE80211_TX_RC_SHORT_GI                = BIT(7),
0814 };
0815 
0816 
0817 /* there are 40 bytes if you don't need the rateset to be kept */
0818 #define IEEE80211_TX_INFO_DRIVER_DATA_SIZE 40
0819 
0820 /* if you do need the rateset, then you have less space */
0821 #define IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE 24
0822 
0823 /* maximum number of rate stages */
0824 #define IEEE80211_TX_MAX_RATES  5
0825 
0826 /**
0827  * struct ieee80211_tx_rate - rate selection/status
0828  *
0829  * @idx: rate index to attempt to send with
0830  * @flags: rate control flags (&enum mac80211_rate_control_flags)
0831  * @count: number of tries in this rate before going to the next rate
0832  *
0833  * A value of -1 for @idx indicates an invalid rate and, if used
0834  * in an array of retry rates, that no more rates should be tried.
0835  *
0836  * When used for transmit status reporting, the driver should
0837  * always report the rate along with the flags it used.
0838  *
0839  * &struct ieee80211_tx_info contains an array of these structs
0840  * in the control information, and it will be filled by the rate
0841  * control algorithm according to what should be sent. For example,
0842  * if this array contains, in the format { <idx>, <count> } the
0843  * information
0844  *    { 3, 2 }, { 2, 2 }, { 1, 4 }, { -1, 0 }, { -1, 0 }
0845  * then this means that the frame should be transmitted
0846  * up to twice at rate 3, up to twice at rate 2, and up to four
0847  * times at rate 1 if it doesn't get acknowledged. Say it gets
0848  * acknowledged by the peer after the fifth attempt, the status
0849  * information should then contain
0850  *   { 3, 2 }, { 2, 2 }, { 1, 1 }, { -1, 0 } ...
0851  * since it was transmitted twice at rate 3, twice at rate 2
0852  * and once at rate 1 after which we received an acknowledgement.
0853  */
0854 struct ieee80211_tx_rate {
0855   s8 idx;
0856   u8 count;
0857   u8 flags;
0858 } __attribute__((packed));
0859 
0860 /**
0861  * struct ieee80211_tx_info - skb transmit information
0862  *
0863  * This structure is placed in skb->cb for three uses:
0864  *  (1) mac80211 TX control - mac80211 tells the driver what to do
0865  *  (2) driver internal use (if applicable)
0866  *  (3) TX status information - driver tells mac80211 what happened
0867  *
0868  * The TX control's sta pointer is only valid during the ->tx call,
0869  * it may be NULL.
0870  *
0871  * @flags: transmit info flags, defined above
0872  * @band: the band to transmit on (use for checking for races)
0873  * @antenna_sel_tx: antenna to use, 0 for automatic diversity
0874  * @pad: padding, ignore
0875  * @control: union for control data
0876  * @status: union for status data
0877  * @driver_data: array of driver_data pointers
0878  * @ampdu_ack_len: number of aggregated frames.
0879  *      relevant only if IEEE80211_TX_STATUS_AMPDU was set.
0880  * @ampdu_ack_map: block ack bit map for the aggregation.
0881  *      relevant only if IEEE80211_TX_STATUS_AMPDU was set.
0882  * @ack_signal: signal strength of the ACK frame
0883  */
0884 struct ieee80211_tx_info {
0885   /* common information */
0886   u32 flags;
0887   u8 band;
0888 
0889   u8 antenna_sel_tx;
0890 
0891   /* 2 byte hole */
0892   u8 pad[2];
0893 
0894   union {
0895     struct {
0896       union {
0897         /* rate control */
0898         struct {
0899           struct ieee80211_tx_rate rates[
0900                                          IEEE80211_TX_MAX_RATES];
0901           s8 rts_cts_rate_idx;
0902         };
0903         /* only needed before rate control */
0904         unsigned long jiffies;
0905       };
0906       /* NB: vif can be NULL for injected frames */
0907       struct ieee80211_vif *vif;
0908       struct ieee80211_key_conf *hw_key;
0909       struct ieee80211_sta *sta;
0910     } control;
0911     struct {
0912       struct ieee80211_tx_rate rates[IEEE80211_TX_MAX_RATES];
0913       u8 ampdu_ack_len;
0914       u64 ampdu_ack_map;
0915       int ack_signal;
0916       /* 8 bytes free */
0917     } status;
0918     struct {
0919       struct ieee80211_tx_rate driver_rates[
0920                                             IEEE80211_TX_MAX_RATES];
0921       void *rate_driver_data[
0922                              IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE / sizeof(void *)];
0923     };
0924     void *driver_data[
0925                       IEEE80211_TX_INFO_DRIVER_DATA_SIZE / sizeof(void *)];
0926   };
0927 };
0928 
0929 static inline struct ieee80211_tx_info *IEEE80211_SKB_CB(struct sk_buff *skb)
0930 {
0931   return (struct ieee80211_tx_info *)skb->cb;
0932 }
0933 
0934 static inline struct ieee80211_rx_status *IEEE80211_SKB_RXCB(struct sk_buff *skb)
0935 {
0936   return (struct ieee80211_rx_status *)skb->cb;
0937 }
0938 
0939 /**
0940  * ieee80211_tx_info_clear_status - clear TX status
0941  *
0942  * @info: The &struct ieee80211_tx_info to be cleared.
0943  *
0944  * When the driver passes an skb back to mac80211, it must report
0945  * a number of things in TX status. This function clears everything
0946  * in the TX status but the rate control information (it does clear
0947  * the count since you need to fill that in anyway).
0948  *
0949  * NOTE: You can only use this function if you do NOT use
0950  *       info->driver_data! Use info->rate_driver_data
0951  *       instead if you need only the less space that allows.
0952  */
0953 static inline void
0954 ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
0955 {
0956   int i;
0957 
0958   BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) !=
0959                offsetof(struct ieee80211_tx_info, control.rates));
0960   BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) !=
0961                offsetof(struct ieee80211_tx_info, driver_rates));
0962   BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) != 8);
0963   /* clear the rate counts */
0964   for (i = 0; i < IEEE80211_TX_MAX_RATES; i++)
0965     info->status.rates[i].count = 0;
0966 
0967   BUILD_BUG_ON(
0968                offsetof(struct ieee80211_tx_info, status.ampdu_ack_len) != 23);
0969   memset(&info->status.ampdu_ack_len, 0,
0970          sizeof(struct ieee80211_tx_info) -
0971          offsetof(struct ieee80211_tx_info, status.ampdu_ack_len));
0972 }
0973 
0974 
0975 /**
0976  * enum mac80211_rx_flags - receive flags
0977  *
0978  * These flags are used with the @flag member of &struct ieee80211_rx_status.
0979  * @RX_FLAG_MMIC_ERROR: Michael MIC error was reported on this frame.
0980  *      Use together with %RX_FLAG_MMIC_STRIPPED.
0981  * @RX_FLAG_DECRYPTED: This frame was decrypted in hardware.
0982  * @RX_FLAG_RADIOTAP: This frame starts with a radiotap header.
0983  * @RX_FLAG_MMIC_STRIPPED: the Michael MIC is stripped off this frame,
0984  *      verification has been done by the hardware.
0985  * @RX_FLAG_IV_STRIPPED: The IV/ICV are stripped from this frame.
0986  *      If this flag is set, the stack cannot do any replay detection
0987  *      hence the driver or hardware will have to do that.
0988  * @RX_FLAG_FAILED_FCS_CRC: Set this flag if the FCS check failed on
0989  *      the frame.
0990  * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on
0991  *      the frame.
0992  * @RX_FLAG_TSFT: The timestamp passed in the RX status (@mactime field)
0993  *      is valid. This is useful in monitor mode and necessary for beacon frames
0994  *      to enable IBSS merging.
0995  * @RX_FLAG_SHORTPRE: Short preamble was used for this frame
0996  * @RX_FLAG_HT: HT MCS was used and rate_idx is MCS index
0997  * @RX_FLAG_40MHZ: HT40 (40 MHz) was used
0998  * @RX_FLAG_SHORT_GI: Short guard interval was used
0999  */
1000 enum mac80211_rx_flags {
1001   RX_FLAG_MMIC_ERROR      = 1<<0,
1002   RX_FLAG_DECRYPTED       = 1<<1,
1003   RX_FLAG_RADIOTAP        = 1<<2,
1004   RX_FLAG_MMIC_STRIPPED   = 1<<3,
1005   RX_FLAG_IV_STRIPPED     = 1<<4,
1006   RX_FLAG_FAILED_FCS_CRC  = 1<<5,
1007   RX_FLAG_FAILED_PLCP_CRC = 1<<6,
1008   RX_FLAG_TSFT            = 1<<7,
1009   RX_FLAG_SHORTPRE        = 1<<8,
1010   RX_FLAG_HT              = 1<<9,
1011   RX_FLAG_40MHZ           = 1<<10,
1012   RX_FLAG_SHORT_GI        = 1<<11,
1013 };
1014 
1015 /**
1016  * struct ieee80211_rx_status - receive status
1017  *
1018  * The low-level driver should provide this information (the subset
1019  * supported by hardware) to the 802.11 code with each received
1020  * frame, in the skb's control buffer (cb).
1021  *
1022  * @mactime: value in microseconds of the 64-bit Time Synchronization Function
1023  *      (TSF) timer when the first data symbol (MPDU) arrived at the hardware.
1024  * @band: the active band when this frame was received
1025  * @freq: frequency the radio was tuned to when receiving this frame, in MHz
1026  * @signal: signal strength when receiving this frame, either in dBm, in dB or
1027  *      unspecified depending on the hardware capabilities flags
1028  *      @IEEE80211_HW_SIGNAL_*
1029  * @noise: noise when receiving this frame, in dBm.
1030  * @qual: overall signal quality indication, in percent (0-100).
1031  * @antenna: antenna used
1032  * @rate_idx: index of data rate into band's supported rates or MCS index if
1033  *      HT rates are use (RX_FLAG_HT)
1034  * @flag: %RX_FLAG_*
1035  */
1036 struct ieee80211_rx_status {
1037   u64 mactime;
1038   enum ieee80211_band band;
1039   int freq;
1040   int signal;
1041   int noise;
1042   int qual;
1043   int antenna;
1044   int rate_idx;
1045   int flag;
1046 };
1047 
1048 /**
1049  * enum ieee80211_conf_flags - configuration flags
1050  *
1051  * Flags to define PHY configuration options
1052  *
1053  * @IEEE80211_CONF_RADIOTAP: add radiotap header at receive time (if supported)
1054  * @IEEE80211_CONF_PS: Enable 802.11 power save mode (managed mode only)
1055  * @IEEE80211_CONF_IDLE: The device is running, but idle; if the flag is set
1056  *      the driver should be prepared to handle configuration requests but
1057  *      may turn the device off as much as possible. Typically, this flag will
1058  *      be set when an interface is set UP but not associated or scanning, but
1059  *      it can also be unset in that case when monitor interfaces are active.
1060  */
1061 enum ieee80211_conf_flags {
1062   IEEE80211_CONF_RADIOTAP         = (1<<0),
1063   IEEE80211_CONF_PS               = (1<<1),
1064   IEEE80211_CONF_IDLE             = (1<<2),
1065 };
1066 
1067 
1068 /**
1069  * enum ieee80211_conf_changed - denotes which configuration changed
1070  *
1071  * @IEEE80211_CONF_CHANGE_LISTEN_INTERVAL: the listen interval changed
1072  * @IEEE80211_CONF_CHANGE_RADIOTAP: the radiotap flag changed
1073  * @IEEE80211_CONF_CHANGE_PS: the PS flag or dynamic PS timeout changed
1074  * @IEEE80211_CONF_CHANGE_POWER: the TX power changed
1075  * @IEEE80211_CONF_CHANGE_CHANNEL: the channel/channel_type changed
1076  * @IEEE80211_CONF_CHANGE_RETRY_LIMITS: retry limits changed
1077  * @IEEE80211_CONF_CHANGE_IDLE: Idle flag changed
1078  */
1079 enum ieee80211_conf_changed {
1080   IEEE80211_CONF_CHANGE_LISTEN_INTERVAL   = BIT(2),
1081   IEEE80211_CONF_CHANGE_RADIOTAP          = BIT(3),
1082   IEEE80211_CONF_CHANGE_PS                = BIT(4),
1083   IEEE80211_CONF_CHANGE_POWER             = BIT(5),
1084   IEEE80211_CONF_CHANGE_CHANNEL           = BIT(6),
1085   IEEE80211_CONF_CHANGE_RETRY_LIMITS      = BIT(7),
1086   IEEE80211_CONF_CHANGE_IDLE              = BIT(8),
1087 };
1088 
1089 /**
1090  * struct ieee80211_conf - configuration of the device
1091  *
1092  * This struct indicates how the driver shall configure the hardware.
1093  *
1094  * @flags: configuration flags defined above
1095  *
1096  * @listen_interval: listen interval in units of beacon interval
1097  * @max_sleep_period: the maximum number of beacon intervals to sleep for
1098  *      before checking the beacon for a TIM bit (managed mode only); this
1099  *      value will be only achievable between DTIM frames, the hardware
1100  *      needs to check for the multicast traffic bit in DTIM beacons.
1101  *      This variable is valid only when the CONF_PS flag is set.
1102  * @dynamic_ps_timeout: The dynamic powersave timeout (in ms), see the
1103  *      powersave documentation below. This variable is valid only when
1104  *      the CONF_PS flag is set.
1105  *
1106  * @power_level: requested transmit power (in dBm)
1107  *
1108  * @channel: the channel to tune to
1109  * @channel_type: the channel (HT) type
1110  *
1111  * @long_frame_max_tx_count: Maximum number of transmissions for a "long" frame
1112  *    (a frame not RTS protected), called "dot11LongRetryLimit" in 802.11,
1113  *    but actually means the number of transmissions not the number of retries
1114  * @short_frame_max_tx_count: Maximum number of transmissions for a "short"
1115  *    frame, called "dot11ShortRetryLimit" in 802.11, but actually means the
1116  *    number of transmissions not the number of retries
1117  */
1118 struct ieee80211_conf {
1119   u32 flags;
1120   int power_level, dynamic_ps_timeout;
1121   int max_sleep_period;
1122 
1123   u16 listen_interval;
1124 
1125   u8 long_frame_max_tx_count, short_frame_max_tx_count;
1126 
1127   struct ieee80211_channel *channel;
1128   enum nl80211_channel_type channel_type;
1129 };
1130 
1131 /**
1132  * struct ieee80211_vif - per-interface data
1133  *
1134  * Data in this structure is continually present for driver
1135  * use during the life of a virtual interface.
1136  *
1137  * @type: type of this virtual interface
1138  * @bss_conf: BSS configuration for this interface, either our own
1139  *      or the BSS we're associated to
1140  * @drv_priv: data area for driver use, will always be aligned to
1141  *      sizeof(void *).
1142  */
1143 struct ieee80211_vif {
1144   enum nl80211_iftype type;
1145   struct ieee80211_bss_conf bss_conf;
1146   /* must be last */
1147   u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
1148 };
1149 
1150 static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
1151 {
1152 #ifdef CONFIG_MAC80211_MESH
1153   return vif->type == NL80211_IFTYPE_MESH_POINT;
1154 #endif
1155   return false;
1156 }
1157 
1158 /**
1159  * enum ieee80211_key_alg - key algorithm
1160  * @ALG_WEP: WEP40 or WEP104
1161  * @ALG_TKIP: TKIP
1162  * @ALG_CCMP: CCMP (AES)
1163  * @ALG_AES_CMAC: AES-128-CMAC
1164  */
1165 enum ieee80211_key_alg {
1166   ALG_WEP,
1167   ALG_TKIP,
1168   ALG_CCMP,
1169   ALG_AES_CMAC,
1170 };
1171 
1172 /**
1173  * enum ieee80211_key_flags - key flags
1174  *
1175  * These flags are used for communication about keys between the driver
1176  * and mac80211, with the @flags parameter of &struct ieee80211_key_conf.
1177  *
1178  * @IEEE80211_KEY_FLAG_WMM_STA: Set by mac80211, this flag indicates
1179  *      that the STA this key will be used with could be using QoS.
1180  * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the
1181  *      driver to indicate that it requires IV generation for this
1182  *      particular key.
1183  * @IEEE80211_KEY_FLAG_GENERATE_MMIC: This flag should be set by
1184  *      the driver for a TKIP key if it requires Michael MIC
1185  *      generation in software.
1186  * @IEEE80211_KEY_FLAG_PAIRWISE: Set by mac80211, this flag indicates
1187  *      that the key is pairwise rather then a shared key.
1188  * @IEEE80211_KEY_FLAG_SW_MGMT: This flag should be set by the driver for a
1189  *      CCMP key if it requires CCMP encryption of management frames (MFP) to
1190  *      be done in software.
1191  */
1192 enum ieee80211_key_flags {
1193   IEEE80211_KEY_FLAG_WMM_STA      = 1<<0,
1194   IEEE80211_KEY_FLAG_GENERATE_IV  = 1<<1,
1195   IEEE80211_KEY_FLAG_GENERATE_MMIC= 1<<2,
1196   IEEE80211_KEY_FLAG_PAIRWISE     = 1<<3,
1197   IEEE80211_KEY_FLAG_SW_MGMT      = 1<<4,
1198 };
1199 
1200 /**
1201  * struct ieee80211_key_conf - key information
1202  *
1203  * This key information is given by mac80211 to the driver by
1204  * the set_key() callback in &struct ieee80211_ops.
1205  *
1206  * @hw_key_idx: To be set by the driver, this is the key index the driver
1207  *      wants to be given when a frame is transmitted and needs to be
1208  *      encrypted in hardware.
1209  * @alg: The key algorithm.
1210  * @flags: key flags, see &enum ieee80211_key_flags.
1211  * @keyidx: the key index (0-3)
1212  * @keylen: key material length
1213  * @key: key material. For ALG_TKIP the key is encoded as a 256-bit (32 byte)
1214  *      data block:
1215  *      - Temporal Encryption Key (128 bits)
1216  *      - Temporal Authenticator Tx MIC Key (64 bits)
1217  *      - Temporal Authenticator Rx MIC Key (64 bits)
1218  * @icv_len: The ICV length for this key type
1219  * @iv_len: The IV length for this key type
1220  */
1221 struct ieee80211_key_conf {
1222   enum ieee80211_key_alg alg;
1223   u8 icv_len;
1224   u8 iv_len;
1225   u8 hw_key_idx;
1226   u8 flags;
1227   s8 keyidx;
1228   u8 keylen;
1229   u8 key[0];
1230 };
1231 
1232 /**
1233  * enum set_key_cmd - key command
1234  *
1235  * Used with the set_key() callback in &struct ieee80211_ops, this
1236  * indicates whether a key is being removed or added.
1237  *
1238  * @SET_KEY: a key is set
1239  * @DISABLE_KEY: a key must be disabled
1240  */
1241 enum set_key_cmd {
1242   SET_KEY, DISABLE_KEY,
1243 };
1244 
1245 /**
1246  * struct ieee80211_sta - station table entry
1247  *
1248  * A station table entry represents a station we are possibly
1249  * communicating with. Since stations are RCU-managed in
1250  * mac80211, any ieee80211_sta pointer you get access to must
1251  * either be protected by rcu_read_lock() explicitly or implicitly,
1252  * or you must take good care to not use such a pointer after a
1253  * call to your sta_notify callback that removed it.
1254  *
1255  * @addr: MAC address
1256  * @aid: AID we assigned to the station if we're an AP
1257  * @supp_rates: Bitmap of supported rates (per band)
1258  * @ht_cap: HT capabilities of this STA; restricted to our own TX capabilities
1259  * @drv_priv: data area for driver use, will always be aligned to
1260  *      sizeof(void *), size is determined in hw information.
1261  */
1262 struct ieee80211_sta {
1263   u32 supp_rates[IEEE80211_NUM_BANDS];
1264   u8 addr[ETH_ALEN];
1265   u16 aid;
1266   struct ieee80211_sta_ht_cap ht_cap;
1267 
1268   /* must be last */
1269   u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
1270 };
1271 
1272 /**
1273  * enum sta_notify_cmd - sta notify command
1274  *
1275  * Used with the sta_notify() callback in &struct ieee80211_ops, this
1276  * indicates addition and removal of a station to station table,
1277  * or if a associated station made a power state transition.
1278  *
1279  * @STA_NOTIFY_ADD: a station was added to the station table
1280  * @STA_NOTIFY_REMOVE: a station being removed from the station table
1281  * @STA_NOTIFY_SLEEP: a station is now sleeping
1282  * @STA_NOTIFY_AWAKE: a sleeping station woke up
1283  */
1284 enum sta_notify_cmd {
1285   STA_NOTIFY_ADD, STA_NOTIFY_REMOVE,
1286   STA_NOTIFY_SLEEP, STA_NOTIFY_AWAKE,
1287 };
1288 
1289 /**
1290  * enum ieee80211_tkip_key_type - get tkip key
1291  *
1292  * Used by drivers which need to get a tkip key for skb. Some drivers need a
1293  * phase 1 key, others need a phase 2 key. A single function allows the driver
1294  * to get the key, this enum indicates what type of key is required.
1295  *
1296  * @IEEE80211_TKIP_P1_KEY: the driver needs a phase 1 key
1297  * @IEEE80211_TKIP_P2_KEY: the driver needs a phase 2 key
1298  */
1299 enum ieee80211_tkip_key_type {
1300   IEEE80211_TKIP_P1_KEY,
1301   IEEE80211_TKIP_P2_KEY,
1302 };
1303 
1304 /**
1305  * enum ieee80211_hw_flags - hardware flags
1306  *
1307  * These flags are used to indicate hardware capabilities to
1308  * the stack. Generally, flags here should have their meaning
1309  * done in a way that the simplest hardware doesn't need setting
1310  * any particular flags. There are some exceptions to this rule,
1311  * however, so you are advised to review these flags carefully.
1312  *
1313  * @IEEE80211_HW_RX_INCLUDES_FCS:
1314  *      Indicates that received frames passed to the stack include
1315  *      the FCS at the end.
1316  *
1317  * @IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING:
1318  *      Some wireless LAN chipsets buffer broadcast/multicast frames
1319  *      for power saving stations in the hardware/firmware and others
1320  *      rely on the host system for such buffering. This option is used
1321  *      to configure the IEEE 802.11 upper layer to buffer broadcast and
1322  *      multicast frames when there are power saving stations so that
1323  *      the driver can fetch them with ieee80211_get_buffered_bc().
1324  *
1325  * @IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE:
1326  *      Hardware is not capable of short slot operation on the 2.4 GHz band.
1327  *
1328  * @IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE:
1329  *      Hardware is not capable of receiving frames with short preamble on
1330  *      the 2.4 GHz band.
1331  *
1332  * @IEEE80211_HW_SIGNAL_UNSPEC:
1333  *      Hardware can provide signal values but we don't know its units. We
1334  *      expect values between 0 and @max_signal.
1335  *      If possible please provide dB or dBm instead.
1336  *
1337  * @IEEE80211_HW_SIGNAL_DBM:
1338  *      Hardware gives signal values in dBm, decibel difference from
1339  *      one milliwatt. This is the preferred method since it is standardized
1340  *      between different devices. @max_signal does not need to be set.
1341  *
1342  * @IEEE80211_HW_NOISE_DBM:
1343  *      Hardware can provide noise (radio interference) values in units dBm,
1344  *      decibel difference from one milliwatt.
1345  *
1346  * @IEEE80211_HW_SPECTRUM_MGMT:
1347  *      Hardware supports spectrum management defined in 802.11h
1348  *      Measurement, Channel Switch, Quieting, TPC
1349  *
1350  * @IEEE80211_HW_AMPDU_AGGREGATION:
1351  *      Hardware supports 11n A-MPDU aggregation.
1352  *
1353  * @IEEE80211_HW_SUPPORTS_PS:
1354  *      Hardware has power save support (i.e. can go to sleep).
1355  *
1356  * @IEEE80211_HW_PS_NULLFUNC_STACK:
1357  *      Hardware requires nullfunc frame handling in stack, implies
1358  *      stack support for dynamic PS.
1359  *
1360  * @IEEE80211_HW_SUPPORTS_DYNAMIC_PS:
1361  *      Hardware has support for dynamic PS.
1362  *
1363  * @IEEE80211_HW_MFP_CAPABLE:
1364  *      Hardware supports management frame protection (MFP, IEEE 802.11w).
1365  *
1366  * @IEEE80211_HW_BEACON_FILTER:
1367  *      Hardware supports dropping of irrelevant beacon frames to
1368  *      avoid waking up cpu.
1369  */
1370 enum ieee80211_hw_flags {
1371   IEEE80211_HW_RX_INCLUDES_FCS                    = 1<<1,
1372   IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING        = 1<<2,
1373   IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE          = 1<<3,
1374   IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE      = 1<<4,
1375   IEEE80211_HW_SIGNAL_UNSPEC                      = 1<<5,
1376   IEEE80211_HW_SIGNAL_DBM                         = 1<<6,
1377   IEEE80211_HW_NOISE_DBM                          = 1<<7,
1378   IEEE80211_HW_SPECTRUM_MGMT                      = 1<<8,
1379   IEEE80211_HW_AMPDU_AGGREGATION                  = 1<<9,
1380   IEEE80211_HW_SUPPORTS_PS                        = 1<<10,
1381   IEEE80211_HW_PS_NULLFUNC_STACK                  = 1<<11,
1382   IEEE80211_HW_SUPPORTS_DYNAMIC_PS                = 1<<12,
1383   IEEE80211_HW_MFP_CAPABLE                        = 1<<13,
1384   IEEE80211_HW_BEACON_FILTER                      = 1<<14,
1385 };
1386 
1387 /**
1388  * struct ieee80211_hw - hardware information and state
1389  *
1390  * This structure contains the configuration and hardware
1391  * information for an 802.11 PHY.
1392  *
1393  * @wiphy: This points to the &struct wiphy allocated for this
1394  *      802.11 PHY. You must fill in the @perm_addr and @dev
1395  *      members of this structure using SET_IEEE80211_DEV()
1396  *      and SET_IEEE80211_PERM_ADDR(). Additionally, all supported
1397  *      bands (with channels, bitrates) are registered here.
1398  *
1399  * @conf: &struct ieee80211_conf, device configuration, don't use.
1400  *
1401  * @priv: pointer to private area that was allocated for driver use
1402  *      along with this structure.
1403  *
1404  * @flags: hardware flags, see &enum ieee80211_hw_flags.
1405  *
1406  * @extra_tx_headroom: headroom to reserve in each transmit skb
1407  *      for use by the driver (e.g. for transmit headers.)
1408  *
1409  * @channel_change_time: time (in microseconds) it takes to change channels.
1410  *
1411  * @max_signal: Maximum value for signal (rssi) in RX information, used
1412  *     only when @IEEE80211_HW_SIGNAL_UNSPEC or @IEEE80211_HW_SIGNAL_DB
1413  *
1414  * @max_listen_interval: max listen interval in units of beacon interval
1415  *     that HW supports
1416  *
1417  * @queues: number of available hardware transmit queues for
1418  *      data packets. WMM/QoS requires at least four, these
1419  *      queues need to have configurable access parameters.
1420  *
1421  * @rate_control_algorithm: rate control algorithm for this hardware.
1422  *      If unset (NULL), the default algorithm will be used. Must be
1423  *      set before calling ieee80211_register_hw().
1424  *
1425  * @vif_data_size: size (in bytes) of the drv_priv data area
1426  *      within &struct ieee80211_vif.
1427  * @sta_data_size: size (in bytes) of the drv_priv data area
1428  *      within &struct ieee80211_sta.
1429  *
1430  * @max_rates: maximum number of alternate rate retry stages
1431  * @max_rate_tries: maximum number of tries for each stage
1432  */
1433 struct ieee80211_hw {
1434   struct ieee80211_conf conf;
1435   struct wiphy *wiphy;
1436   const char *rate_control_algorithm;
1437   void *priv;
1438   u32 flags;
1439   unsigned int extra_tx_headroom;
1440   int channel_change_time;
1441   int vif_data_size;
1442   int sta_data_size;
1443   u16 queues;
1444   u16 max_listen_interval;
1445   s8 max_signal;
1446   u8 max_rates;
1447   u8 max_rate_tries;
1448 };
1449 
1450 /**
1451  * wiphy_to_ieee80211_hw - return a mac80211 driver hw struct from a wiphy
1452  *
1453  * @wiphy: the &struct wiphy which we want to query
1454  *
1455  * mac80211 drivers can use this to get to their respective
1456  * &struct ieee80211_hw. Drivers wishing to get to their own private
1457  * structure can then access it via hw->priv. Note that mac802111 drivers should
1458  * not use wiphy_priv() to try to get their private driver structure as this
1459  * is already used internally by mac80211.
1460  */
1461 struct ieee80211_hw *wiphy_to_ieee80211_hw(struct wiphy *wiphy);
1462 
1463 /**
1464  * SET_IEEE80211_DEV - set device for 802.11 hardware
1465  *
1466  * @hw: the &struct ieee80211_hw to set the device for
1467  * @dev: the &struct device of this 802.11 device
1468  */
1469 static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev)
1470 {
1471   set_wiphy_dev(hw->wiphy, dev);
1472 }
1473 
1474 /**
1475  * SET_IEEE80211_PERM_ADDR - set the permanent MAC address for 802.11 hardware
1476  *
1477  * @hw: the &struct ieee80211_hw to set the MAC address for
1478  * @addr: the address to set
1479  */
1480 static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr)
1481 {
1482   memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
1483 }
1484 
1485 static inline struct ieee80211_rate *
1486 ieee80211_get_tx_rate(const struct ieee80211_hw *hw,
1487                       const struct ieee80211_tx_info *c)
1488 {
1489   if (WARN_ON(c->control.rates[0].idx < 0))
1490     return NULL;
1491   return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[0].idx];
1492 }
1493 
1494 static inline struct ieee80211_rate *
1495 ieee80211_get_rts_cts_rate(const struct ieee80211_hw *hw,
1496                            const struct ieee80211_tx_info *c)
1497 {
1498   if (c->control.rts_cts_rate_idx < 0)
1499     return NULL;
1500   return &hw->wiphy->bands[c->band]->bitrates[c->control.rts_cts_rate_idx];
1501 }
1502 
1503 static inline struct ieee80211_rate *
1504 ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw,
1505                              const struct ieee80211_tx_info *c, int idx)
1506 {
1507   if (c->control.rates[idx + 1].idx < 0)
1508     return NULL;
1509   return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[idx + 1].idx];
1510 }
1511 
1512 /**
1513  * DOC: Hardware crypto acceleration
1514  *
1515  * mac80211 is capable of taking advantage of many hardware
1516  * acceleration designs for encryption and decryption operations.
1517  *
1518  * The set_key() callback in the &struct ieee80211_ops for a given
1519  * device is called to enable hardware acceleration of encryption and
1520  * decryption. The callback takes a @sta parameter that will be NULL
1521  * for default keys or keys used for transmission only, or point to
1522  * the station information for the peer for individual keys.
1523  * Multiple transmission keys with the same key index may be used when
1524  * VLANs are configured for an access point.
1525  *
1526  * When transmitting, the TX control data will use the @hw_key_idx
1527  * selected by the driver by modifying the &struct ieee80211_key_conf
1528  * pointed to by the @key parameter to the set_key() function.
1529  *
1530  * The set_key() call for the %SET_KEY command should return 0 if
1531  * the key is now in use, -%EOPNOTSUPP or -%ENOSPC if it couldn't be
1532  * added; if you return 0 then hw_key_idx must be assigned to the
1533  * hardware key index, you are free to use the full u8 range.
1534  *
1535  * When the cmd is %DISABLE_KEY then it must succeed.
1536  *
1537  * Note that it is permissible to not decrypt a frame even if a key
1538  * for it has been uploaded to hardware, the stack will not make any
1539  * decision based on whether a key has been uploaded or not but rather
1540  * based on the receive flags.
1541  *
1542  * The &struct ieee80211_key_conf structure pointed to by the @key
1543  * parameter is guaranteed to be valid until another call to set_key()
1544  * removes it, but it can only be used as a cookie to differentiate
1545  * keys.
1546  *
1547  * In TKIP some HW need to be provided a phase 1 key, for RX decryption
1548  * acceleration (i.e. iwlwifi). Those drivers should provide update_tkip_key
1549  * handler.
1550  * The update_tkip_key() call updates the driver with the new phase 1 key.
1551  * This happens everytime the iv16 wraps around (every 65536 packets). The
1552  * set_key() call will happen only once for each key (unless the AP did
1553  * rekeying), it will not include a valid phase 1 key. The valid phase 1 key is
1554  * provided by update_tkip_key only. The trigger that makes mac80211 call this
1555  * handler is software decryption with wrap around of iv16.
1556  */
1557 
1558 /**
1559  * DOC: Powersave support
1560  *
1561  * mac80211 has support for various powersave implementations.
1562  *
1563  * First, it can support hardware that handles all powersaving by
1564  * itself, such hardware should simply set the %IEEE80211_HW_SUPPORTS_PS
1565  * hardware flag. In that case, it will be told about the desired
1566  * powersave mode depending on the association status, and the driver
1567  * must take care of sending nullfunc frames when necessary, i.e. when
1568  * entering and leaving powersave mode. The driver is required to look at
1569  * the AID in beacons and signal to the AP that it woke up when it finds
1570  * traffic directed to it. This mode supports dynamic PS by simply
1571  * enabling/disabling PS.
1572  *
1573  * Additionally, such hardware may set the %IEEE80211_HW_SUPPORTS_DYNAMIC_PS
1574  * flag to indicate that it can support dynamic PS mode itself (see below).
1575  *
1576  * Other hardware designs cannot send nullfunc frames by themselves and also
1577  * need software support for parsing the TIM bitmap. This is also supported
1578  * by mac80211 by combining the %IEEE80211_HW_SUPPORTS_PS and
1579  * %IEEE80211_HW_PS_NULLFUNC_STACK flags. The hardware is of course still
1580  * required to pass up beacons. The hardware is still required to handle
1581  * waking up for multicast traffic; if it cannot the driver must handle that
1582  * as best as it can, mac80211 is too slow.
1583  *
1584  * Dynamic powersave mode is an extension to normal powersave mode in which
1585  * the hardware stays awake for a user-specified period of time after sending
1586  * a frame so that reply frames need not be buffered and therefore delayed
1587  * to the next wakeup. This can either be supported by hardware, in which case
1588  * the driver needs to look at the @dynamic_ps_timeout hardware configuration
1589  * value, or by the stack if all nullfunc handling is in the stack.
1590  */
1591 
1592 /**
1593  * DOC: Beacon filter support
1594  *
1595  * Some hardware have beacon filter support to reduce host cpu wakeups
1596  * which will reduce system power consumption. It usuallly works so that
1597  * the firmware creates a checksum of the beacon but omits all constantly
1598  * changing elements (TSF, TIM etc). Whenever the checksum changes the
1599  * beacon is forwarded to the host, otherwise it will be just dropped. That
1600  * way the host will only receive beacons where some relevant information
1601  * (for example ERP protection or WMM settings) have changed.
1602  *
1603  * Beacon filter support is advertised with the %IEEE80211_HW_BEACON_FILTER
1604  * hardware capability. The driver needs to enable beacon filter support
1605  * whenever power save is enabled, that is %IEEE80211_CONF_PS is set. When
1606  * power save is enabled, the stack will not check for beacon loss and the
1607  * driver needs to notify about loss of beacons with ieee80211_beacon_loss().
1608  *
1609  * The time (or number of beacons missed) until the firmware notifies the
1610  * driver of a beacon loss event (which in turn causes the driver to call
1611  * ieee80211_beacon_loss()) should be configurable and will be controlled
1612  * by mac80211 and the roaming algorithm in the future.
1613  *
1614  * Since there may be constantly changing information elements that nothing
1615  * in the software stack cares about, we will, in the future, have mac80211
1616  * tell the driver which information elements are interesting in the sense
1617  * that we want to see changes in them. This will include
1618  *  - a list of information element IDs
1619  *  - a list of OUIs for the vendor information element
1620  *
1621  * Ideally, the hardware would filter out any beacons without changes in the
1622  * requested elements, but if it cannot support that it may, at the expense
1623  * of some efficiency, filter out only a subset. For example, if the device
1624  * doesn't support checking for OUIs it should pass up all changes in all
1625  * vendor information elements.
1626  *
1627  * Note that change, for the sake of simplification, also includes information
1628  * elements appearing or disappearing from the beacon.
1629  *
1630  * Some hardware supports an "ignore list" instead, just make sure nothing
1631  * that was requested is on the ignore list, and include commonly changing
1632  * information element IDs in the ignore list, for example 11 (BSS load) and
1633  * the various vendor-assigned IEs with unknown contents (128, 129, 133-136,
1634  * 149, 150, 155, 156, 173, 176, 178, 179, 219); for forward compatibility
1635  * it could also include some currently unused IDs.
1636  *
1637  *
1638  * In addition to these capabilities, hardware should support notifying the
1639  * host of changes in the beacon RSSI. This is relevant to implement roaming
1640  * when no traffic is flowing (when traffic is flowing we see the RSSI of
1641  * the received data packets). This can consist in notifying the host when
1642  * the RSSI changes significantly or when it drops below or rises above
1643  * configurable thresholds. In the future these thresholds will also be
1644  * configured by mac80211 (which gets them from userspace) to implement
1645  * them as the roaming algorithm requires.
1646  *
1647  * If the hardware cannot implement this, the driver should ask it to
1648  * periodically pass beacon frames to the host so that software can do the
1649  * signal strength threshold checking.
1650  */
1651 
1652 /**
1653  * DOC: Frame filtering
1654  *
1655  * mac80211 requires to see many management frames for proper
1656  * operation, and users may want to see many more frames when
1657  * in monitor mode. However, for best CPU usage and power consumption,
1658  * having as few frames as possible percolate through the stack is
1659  * desirable. Hence, the hardware should filter as much as possible.
1660  *
1661  * To achieve this, mac80211 uses filter flags (see below) to tell
1662  * the driver's configure_filter() function which frames should be
1663  * passed to mac80211 and which should be filtered out.
1664  *
1665  * Before configure_filter() is invoked, the prepare_multicast()
1666  * callback is invoked with the parameters @mc_count and @mc_list
1667  * for the combined multicast address list of all virtual interfaces.
1668  * It's use is optional, and it returns a u64 that is passed to
1669  * configure_filter(). Additionally, configure_filter() has the
1670  * arguments @changed_flags telling which flags were changed and
1671  * @total_flags with the new flag states.
1672  *
1673  * If your device has no multicast address filters your driver will
1674  * need to check both the %FIF_ALLMULTI flag and the @mc_count
1675  * parameter to see whether multicast frames should be accepted
1676  * or dropped.
1677  *
1678  * All unsupported flags in @total_flags must be cleared.
1679  * Hardware does not support a flag if it is incapable of _passing_
1680  * the frame to the stack. Otherwise the driver must ignore
1681  * the flag, but not clear it.
1682  * You must _only_ clear the flag (announce no support for the
1683  * flag to mac80211) if you are not able to pass the packet type
1684  * to the stack (so the hardware always filters it).
1685  * So for example, you should clear @FIF_CONTROL, if your hardware
1686  * always filters control frames. If your hardware always passes
1687  * control frames to the kernel and is incapable of filtering them,
1688  * you do _not_ clear the @FIF_CONTROL flag.
1689  * This rule applies to all other FIF flags as well.
1690  */
1691 
1692 /**
1693  * enum ieee80211_filter_flags - hardware filter flags
1694  *
1695  * These flags determine what the filter in hardware should be
1696  * programmed to let through and what should not be passed to the
1697  * stack. It is always safe to pass more frames than requested,
1698  * but this has negative impact on power consumption.
1699  *
1700  * @FIF_PROMISC_IN_BSS: promiscuous mode within your BSS,
1701  *      think of the BSS as your network segment and then this corresponds
1702  *      to the regular ethernet device promiscuous mode.
1703  *
1704  * @FIF_ALLMULTI: pass all multicast frames, this is used if requested
1705  *      by the user or if the hardware is not capable of filtering by
1706  *      multicast address.
1707  *
1708  * @FIF_FCSFAIL: pass frames with failed FCS (but you need to set the
1709  *      %RX_FLAG_FAILED_FCS_CRC for them)
1710  *
1711  * @FIF_PLCPFAIL: pass frames with failed PLCP CRC (but you need to set
1712  *      the %RX_FLAG_FAILED_PLCP_CRC for them
1713  *
1714  * @FIF_BCN_PRBRESP_PROMISC: This flag is set during scanning to indicate
1715  *      to the hardware that it should not filter beacons or probe responses
1716  *      by BSSID. Filtering them can greatly reduce the amount of processing
1717  *      mac80211 needs to do and the amount of CPU wakeups, so you should
1718  *      honour this flag if possible.
1719  *
1720  * @FIF_CONTROL: pass control frames (except for PS Poll), if PROMISC_IN_BSS
1721  *  is not set then only those addressed to this station.
1722  *
1723  * @FIF_OTHER_BSS: pass frames destined to other BSSes
1724  *
1725  * @FIF_PSPOLL: pass PS Poll frames, if PROMISC_IN_BSS  is not set then only
1726  *  those addressed to this station.
1727  */
1728 enum ieee80211_filter_flags {
1729   FIF_PROMISC_IN_BSS      = 1<<0,
1730   FIF_ALLMULTI            = 1<<1,
1731   FIF_FCSFAIL             = 1<<2,
1732   FIF_PLCPFAIL            = 1<<3,
1733   FIF_BCN_PRBRESP_PROMISC = 1<<4,
1734   FIF_CONTROL             = 1<<5,
1735   FIF_OTHER_BSS           = 1<<6,
1736   FIF_PSPOLL              = 1<<7,
1737 };
1738 
1739 /**
1740  * enum ieee80211_ampdu_mlme_action - A-MPDU actions
1741  *
1742  * These flags are used with the ampdu_action() callback in
1743  * &struct ieee80211_ops to indicate which action is needed.
1744  *
1745  * Note that drivers MUST be able to deal with a TX aggregation
1746  * session being stopped even before they OK'ed starting it by
1747  * calling ieee80211_start_tx_ba_cb(_irqsafe), because the peer
1748  * might receive the addBA frame and send a delBA right away!
1749  *
1750  * @IEEE80211_AMPDU_RX_START: start Rx aggregation
1751  * @IEEE80211_AMPDU_RX_STOP: stop Rx aggregation
1752  * @IEEE80211_AMPDU_TX_START: start Tx aggregation
1753  * @IEEE80211_AMPDU_TX_STOP: stop Tx aggregation
1754  * @IEEE80211_AMPDU_TX_OPERATIONAL: TX aggregation has become operational
1755  */
1756 enum ieee80211_ampdu_mlme_action {
1757   IEEE80211_AMPDU_RX_START,
1758   IEEE80211_AMPDU_RX_STOP,
1759   IEEE80211_AMPDU_TX_START,
1760   IEEE80211_AMPDU_TX_STOP,
1761   IEEE80211_AMPDU_TX_OPERATIONAL,
1762 };
1763 
1764 #ifdef CONFIG_MAC80211_LEDS
1765 extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw);
1766 extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw);
1767 extern char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw);
1768 extern char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw);
1769 #endif
1770 /**
1771  * ieee80211_get_tx_led_name - get name of TX LED
1772  *
1773  * mac80211 creates a transmit LED trigger for each wireless hardware
1774  * that can be used to drive LEDs if your driver registers a LED device.
1775  * This function returns the name (or %NULL if not configured for LEDs)
1776  * of the trigger so you can automatically link the LED device.
1777  *
1778  * @hw: the hardware to get the LED trigger name for
1779  */
1780 static inline char *ieee80211_get_tx_led_name(struct ieee80211_hw *hw)
1781 {
1782 #ifdef CONFIG_MAC80211_LEDS
1783   return __ieee80211_get_tx_led_name(hw);
1784 #else
1785   return NULL;
1786 #endif
1787 }
1788 
1789 /**
1790  * ieee80211_get_rx_led_name - get name of RX LED
1791  *
1792  * mac80211 creates a receive LED trigger for each wireless hardware
1793  * that can be used to drive LEDs if your driver registers a LED device.
1794  * This function returns the name (or %NULL if not configured for LEDs)
1795  * of the trigger so you can automatically link the LED device.
1796  *
1797  * @hw: the hardware to get the LED trigger name for
1798  */
1799 static inline char *ieee80211_get_rx_led_name(struct ieee80211_hw *hw)
1800 {
1801 #ifdef CONFIG_MAC80211_LEDS
1802   return __ieee80211_get_rx_led_name(hw);
1803 #else
1804   return NULL;
1805 #endif
1806 }
1807 
1808 /**
1809  * ieee80211_get_assoc_led_name - get name of association LED
1810  *
1811  * mac80211 creates a association LED trigger for each wireless hardware
1812  * that can be used to drive LEDs if your driver registers a LED device.
1813  * This function returns the name (or %NULL if not configured for LEDs)
1814  * of the trigger so you can automatically link the LED device.
1815  *
1816  * @hw: the hardware to get the LED trigger name for
1817  */
1818 static inline char *ieee80211_get_assoc_led_name(struct ieee80211_hw *hw)
1819 {
1820 #ifdef CONFIG_MAC80211_LEDS
1821   return __ieee80211_get_assoc_led_name(hw);
1822 #else
1823   return NULL;
1824 #endif
1825 }
1826 
1827 /**
1828  * ieee80211_get_radio_led_name - get name of radio LED
1829  *
1830  * mac80211 creates a radio change LED trigger for each wireless hardware
1831  * that can be used to drive LEDs if your driver registers a LED device.
1832  * This function returns the name (or %NULL if not configured for LEDs)
1833  * of the trigger so you can automatically link the LED device.
1834  *
1835  * @hw: the hardware to get the LED trigger name for
1836  */
1837 static inline char *ieee80211_get_radio_led_name(struct ieee80211_hw *hw)
1838 {
1839 #ifdef CONFIG_MAC80211_LEDS
1840   return __ieee80211_get_radio_led_name(hw);
1841 #else
1842   return NULL;
1843 #endif
1844 }
1845 
1846 /**
1847  * ieee80211_unregister_hw - Unregister a hardware device
1848  *
1849  * This function instructs mac80211 to free allocated resources
1850  * and unregister netdevices from the networking subsystem.
1851  *
1852  * @hw: the hardware to unregister
1853  */
1854 void ieee80211_unregister_hw(struct ieee80211_hw *hw);
1855 
1856 /**
1857  * ieee80211_free_hw - free hardware descriptor
1858  *
1859  * This function frees everything that was allocated, including the
1860  * private data for the driver. You must call ieee80211_unregister_hw()
1861  * before calling this function.
1862  *
1863  * @hw: the hardware to free
1864  */
1865 void ieee80211_free_hw(struct ieee80211_hw *hw);
1866 
1867 /**
1868  * ieee80211_restart_hw - restart hardware completely
1869  *
1870  * Call this function when the hardware was restarted for some reason
1871  * (hardware error, ...) and the driver is unable to restore its state
1872  * by itself. mac80211 assumes that at this point the driver/hardware
1873  * is completely uninitialised and stopped, it starts the process by
1874  * calling the ->start() operation. The driver will need to reset all
1875  * internal state that it has prior to calling this function.
1876  *
1877  * @hw: the hardware to restart
1878  */
1879 void ieee80211_restart_hw(struct ieee80211_hw *hw);
1880 
1881 #endif
1882 
1883 /**
1884  * ieee80211_rx - receive frame
1885  *
1886  * Use this function to hand received frames to mac80211. The receive
1887  * buffer in @skb must start with an IEEE 802.11 header or a radiotap
1888  * header if %RX_FLAG_RADIOTAP is set in the @status flags.
1889  *
1890  * This function may not be called in IRQ context. Calls to this function
1891  * for a single hardware must be synchronized against each other. Calls
1892  * to this function and ieee80211_rx_irqsafe() may not be mixed for a
1893  * single hardware.
1894  *
1895  * Note that right now, this function must be called with softirqs disabled.
1896  *
1897  * @hw: the hardware this frame came in on
1898  * @skb: the buffer to receive, owned by mac80211 after this call
1899  */
1900 void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb);
1901 
1902 #if 0
1903 
1904 /**
1905  * ieee80211_rx_irqsafe - receive frame
1906  *
1907  * Like ieee80211_rx() but can be called in IRQ context
1908  * (internally defers to a tasklet.)
1909  *
1910  * Calls to this function and ieee80211_rx() may not be mixed for a
1911  * single hardware.
1912  *
1913  * @hw: the hardware this frame came in on
1914  * @skb: the buffer to receive, owned by mac80211 after this call
1915  */
1916 void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb);
1917 
1918 /**
1919  * ieee80211_tx_status - transmit status callback
1920  *
1921  * Call this function for all transmitted frames after they have been
1922  * transmitted. It is permissible to not call this function for
1923  * multicast frames but this can affect statistics.
1924  *
1925  * This function may not be called in IRQ context. Calls to this function
1926  * for a single hardware must be synchronized against each other. Calls
1927  * to this function and ieee80211_tx_status_irqsafe() may not be mixed
1928  * for a single hardware.
1929  *
1930  * @hw: the hardware the frame was transmitted by
1931  * @skb: the frame that was transmitted, owned by mac80211 after this call
1932  */
1933 void ieee80211_tx_status(struct ieee80211_hw *hw,
1934                          struct sk_buff *skb);
1935 
1936 /**
1937  * ieee80211_tx_status_irqsafe - IRQ-safe transmit status callback
1938  *
1939  * Like ieee80211_tx_status() but can be called in IRQ context
1940  * (internally defers to a tasklet.)
1941  *
1942  * Calls to this function and ieee80211_tx_status() may not be mixed for a
1943  * single hardware.
1944  *
1945  * @hw: the hardware the frame was transmitted by
1946  * @skb: the frame that was transmitted, owned by mac80211 after this call
1947  */
1948 void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
1949                                  struct sk_buff *skb);
1950 
1951 /**
1952  * ieee80211_beacon_get - beacon generation function
1953  * @hw: pointer obtained from ieee80211_alloc_hw().
1954  * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
1955  *
1956  * If the beacon frames are generated by the host system (i.e., not in
1957  * hardware/firmware), the low-level driver uses this function to receive
1958  * the next beacon frame from the 802.11 code. The low-level is responsible
1959  * for calling this function before beacon data is needed (e.g., based on
1960  * hardware interrupt). Returned skb is used only once and low-level driver
1961  * is responsible for freeing it.
1962  */
1963 struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
1964                                      struct ieee80211_vif *vif);
1965 
1966 /**
1967  * ieee80211_rts_get - RTS frame generation function
1968  * @hw: pointer obtained from ieee80211_alloc_hw().
1969  * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
1970  * @frame: pointer to the frame that is going to be protected by the RTS.
1971  * @frame_len: the frame length (in octets).
1972  * @frame_txctl: &struct ieee80211_tx_info of the frame.
1973  * @rts: The buffer where to store the RTS frame.
1974  *
1975  * If the RTS frames are generated by the host system (i.e., not in
1976  * hardware/firmware), the low-level driver uses this function to receive
1977  * the next RTS frame from the 802.11 code. The low-level is responsible
1978  * for calling this function before and RTS frame is needed.
1979  */
1980 void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1981                        const void *frame, size_t frame_len,
1982                        const struct ieee80211_tx_info *frame_txctl,
1983                        struct ieee80211_rts *rts);
1984 
1985 /**
1986  * ieee80211_rts_duration - Get the duration field for an RTS frame
1987  * @hw: pointer obtained from ieee80211_alloc_hw().
1988  * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
1989  * @frame_len: the length of the frame that is going to be protected by the RTS.
1990  * @frame_txctl: &struct ieee80211_tx_info of the frame.
1991  *
1992  * If the RTS is generated in firmware, but the host system must provide
1993  * the duration field, the low-level driver uses this function to receive
1994  * the duration field value in little-endian byteorder.
1995  */
1996 __le16 ieee80211_rts_duration(struct ieee80211_hw *hw,
1997                               struct ieee80211_vif *vif, size_t frame_len,
1998                               const struct ieee80211_tx_info *frame_txctl);
1999 
2000 /**
2001  * ieee80211_ctstoself_get - CTS-to-self frame generation function
2002  * @hw: pointer obtained from ieee80211_alloc_hw().
2003  * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
2004  * @frame: pointer to the frame that is going to be protected by the CTS-to-self.
2005  * @frame_len: the frame length (in octets).
2006  * @frame_txctl: &struct ieee80211_tx_info of the frame.
2007  * @cts: The buffer where to store the CTS-to-self frame.
2008  *
2009  * If the CTS-to-self frames are generated by the host system (i.e., not in
2010  * hardware/firmware), the low-level driver uses this function to receive
2011  * the next CTS-to-self frame from the 802.11 code. The low-level is responsible
2012  * for calling this function before and CTS-to-self frame is needed.
2013  */
2014 void ieee80211_ctstoself_get(struct ieee80211_hw *hw,
2015                              struct ieee80211_vif *vif,
2016                              const void *frame, size_t frame_len,
2017                              const struct ieee80211_tx_info *frame_txctl,
2018                              struct ieee80211_cts *cts);
2019 
2020 /**
2021  * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame
2022  * @hw: pointer obtained from ieee80211_alloc_hw().
2023  * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
2024  * @frame_len: the length of the frame that is going to be protected by the CTS-to-self.
2025  * @frame_txctl: &struct ieee80211_tx_info of the frame.
2026  *
2027  * If the CTS-to-self is generated in firmware, but the host system must provide
2028  * the duration field, the low-level driver uses this function to receive
2029  * the duration field value in little-endian byteorder.
2030  */
2031 __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw,
2032                                     struct ieee80211_vif *vif,
2033                                     size_t frame_len,
2034                                     const struct ieee80211_tx_info *frame_txctl);
2035 
2036 /**
2037  * ieee80211_generic_frame_duration - Calculate the duration field for a frame
2038  * @hw: pointer obtained from ieee80211_alloc_hw().
2039  * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
2040  * @frame_len: the length of the frame.
2041  * @rate: the rate at which the frame is going to be transmitted.
2042  *
2043  * Calculate the duration field of some generic frame, given its
2044  * length and transmission rate (in 100kbps).
2045  */
2046 __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw,
2047                                         struct ieee80211_vif *vif,
2048                                         size_t frame_len,
2049                                         struct ieee80211_rate *rate);
2050 
2051 /**
2052  * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames
2053  * @hw: pointer as obtained from ieee80211_alloc_hw().
2054  * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
2055  *
2056  * Function for accessing buffered broadcast and multicast frames. If
2057  * hardware/firmware does not implement buffering of broadcast/multicast
2058  * frames when power saving is used, 802.11 code buffers them in the host
2059  * memory. The low-level driver uses this function to fetch next buffered
2060  * frame. In most cases, this is used when generating beacon frame. This
2061  * function returns a pointer to the next buffered skb or NULL if no more
2062  * buffered frames are available.
2063  *
2064  * Note: buffered frames are returned only after DTIM beacon frame was
2065  * generated with ieee80211_beacon_get() and the low-level driver must thus
2066  * call ieee80211_beacon_get() first. ieee80211_get_buffered_bc() returns
2067  * NULL if the previous generated beacon was not DTIM, so the low-level driver
2068  * does not need to check for DTIM beacons separately and should be able to
2069  * use common code for all beacons.
2070  */
2071 struct sk_buff *
2072 ieee80211_get_buffered_bc(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
2073 
2074 /**
2075  * ieee80211_get_tkip_key - get a TKIP rc4 for skb
2076  *
2077  * This function computes a TKIP rc4 key for an skb. It computes
2078  * a phase 1 key if needed (iv16 wraps around). This function is to
2079  * be used by drivers which can do HW encryption but need to compute
2080  * to phase 1/2 key in SW.
2081  *
2082  * @keyconf: the parameter passed with the set key
2083  * @skb: the skb for which the key is needed
2084  * @type: TBD
2085  * @key: a buffer to which the key will be written
2086  */
2087 void ieee80211_get_tkip_key(struct ieee80211_key_conf *keyconf,
2088                             struct sk_buff *skb,
2089                             enum ieee80211_tkip_key_type type, u8 *key);
2090 /**
2091  * ieee80211_wake_queue - wake specific queue
2092  * @hw: pointer as obtained from ieee80211_alloc_hw().
2093  * @queue: queue number (counted from zero).
2094  *
2095  * Drivers should use this function instead of netif_wake_queue.
2096  */
2097 void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue);
2098 
2099 /**
2100  * ieee80211_stop_queue - stop specific queue
2101  * @hw: pointer as obtained from ieee80211_alloc_hw().
2102  * @queue: queue number (counted from zero).
2103  *
2104  * Drivers should use this function instead of netif_stop_queue.
2105  */
2106 void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue);
2107 
2108 /**
2109  * ieee80211_queue_stopped - test status of the queue
2110  * @hw: pointer as obtained from ieee80211_alloc_hw().
2111  * @queue: queue number (counted from zero).
2112  *
2113  * Drivers should use this function instead of netif_stop_queue.
2114  */
2115 
2116 int ieee80211_queue_stopped(struct ieee80211_hw *hw, int queue);
2117 
2118 /**
2119  * ieee80211_stop_queues - stop all queues
2120  * @hw: pointer as obtained from ieee80211_alloc_hw().
2121  *
2122  * Drivers should use this function instead of netif_stop_queue.
2123  */
2124 void ieee80211_stop_queues(struct ieee80211_hw *hw);
2125 
2126 /**
2127  * ieee80211_wake_queues - wake all queues
2128  * @hw: pointer as obtained from ieee80211_alloc_hw().
2129  *
2130  * Drivers should use this function instead of netif_wake_queue.
2131  */
2132 void ieee80211_wake_queues(struct ieee80211_hw *hw);
2133 
2134 /**
2135  * ieee80211_scan_completed - completed hardware scan
2136  *
2137  * When hardware scan offload is used (i.e. the hw_scan() callback is
2138  * assigned) this function needs to be called by the driver to notify
2139  * mac80211 that the scan finished.
2140  *
2141  * @hw: the hardware that finished the scan
2142  * @aborted: set to true if scan was aborted
2143  */
2144 void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted);
2145 
2146 /**
2147  * ieee80211_iterate_active_interfaces - iterate active interfaces
2148  *
2149  * This function iterates over the interfaces associated with a given
2150  * hardware that are currently active and calls the callback for them.
2151  * This function allows the iterator function to sleep, when the iterator
2152  * function is atomic @ieee80211_iterate_active_interfaces_atomic can
2153  * be used.
2154  *
2155  * @hw: the hardware struct of which the interfaces should be iterated over
2156  * @iterator: the iterator function to call
2157  * @data: first argument of the iterator function
2158  */
2159 void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw,
2160                                          void (*iterator)(void *data, u8 *mac,
2161                                                           struct ieee80211_vif *vif),
2162                                          void *data);
2163 
2164 /**
2165  * ieee80211_iterate_active_interfaces_atomic - iterate active interfaces
2166  *
2167  * This function iterates over the interfaces associated with a given
2168  * hardware that are currently active and calls the callback for them.
2169  * This function requires the iterator callback function to be atomic,
2170  * if that is not desired, use @ieee80211_iterate_active_interfaces instead.
2171  *
2172  * @hw: the hardware struct of which the interfaces should be iterated over
2173  * @iterator: the iterator function to call, cannot sleep
2174  * @data: first argument of the iterator function
2175  */
2176 void ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw,
2177                                                 void (*iterator)(void *data,
2178                                                                  u8 *mac,
2179                                                                  struct ieee80211_vif *vif),
2180                                                 void *data);
2181 
2182 /**
2183  * ieee80211_queue_work - add work onto the mac80211 workqueue
2184  *
2185  * Drivers and mac80211 use this to add work onto the mac80211 workqueue.
2186  * This helper ensures drivers are not queueing work when they should not be.
2187  *
2188  * @hw: the hardware struct for the interface we are adding work for
2189  * @work: the work we want to add onto the mac80211 workqueue
2190  */
2191 void ieee80211_queue_work(struct ieee80211_hw *hw, struct work_struct *work);
2192 
2193 /**
2194  * ieee80211_queue_delayed_work - add work onto the mac80211 workqueue
2195  *
2196  * Drivers and mac80211 use this to queue delayed work onto the mac80211
2197  * workqueue.
2198  *
2199  * @hw: the hardware struct for the interface we are adding work for
2200  * @dwork: delayable work to queue onto the mac80211 workqueue
2201  * @delay: number of jiffies to wait before queueing
2202  */
2203 void ieee80211_queue_delayed_work(struct ieee80211_hw *hw,
2204                                   struct delayed_work *dwork,
2205                                   unsigned long delay);
2206 
2207 /**
2208  * ieee80211_start_tx_ba_session - Start a tx Block Ack session.
2209  * @hw: pointer as obtained from ieee80211_alloc_hw().
2210  * @ra: receiver address of the BA session recipient
2211  * @tid: the TID to BA on.
2212  *
2213  * Return: success if addBA request was sent, failure otherwise
2214  *
2215  * Although mac80211/low level driver/user space application can estimate
2216  * the need to start aggregation on a certain RA/TID, the session level
2217  * will be managed by the mac80211.
2218  */
2219 int ieee80211_start_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid);
2220 
2221 /**
2222  * ieee80211_start_tx_ba_cb - low level driver ready to aggregate.
2223  * @hw: pointer as obtained from ieee80211_alloc_hw().
2224  * @ra: receiver address of the BA session recipient.
2225  * @tid: the TID to BA on.
2226  *
2227  * This function must be called by low level driver once it has
2228  * finished with preparations for the BA session.
2229  */
2230 void ieee80211_start_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u16 tid);
2231 
2232 /**
2233  * ieee80211_start_tx_ba_cb_irqsafe - low level driver ready to aggregate.
2234  * @hw: pointer as obtained from ieee80211_alloc_hw().
2235  * @ra: receiver address of the BA session recipient.
2236  * @tid: the TID to BA on.
2237  *
2238  * This function must be called by low level driver once it has
2239  * finished with preparations for the BA session.
2240  * This version of the function is IRQ-safe.
2241  */
2242 void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_hw *hw, const u8 *ra,
2243                                       u16 tid);
2244 
2245 /**
2246  * ieee80211_stop_tx_ba_session - Stop a Block Ack session.
2247  * @hw: pointer as obtained from ieee80211_alloc_hw().
2248  * @ra: receiver address of the BA session recipient
2249  * @tid: the TID to stop BA.
2250  * @initiator: if indicates initiator DELBA frame will be sent.
2251  *
2252  * Return: error if no sta with matching da found, success otherwise
2253  *
2254  * Although mac80211/low level driver/user space application can estimate
2255  * the need to stop aggregation on a certain RA/TID, the session level
2256  * will be managed by the mac80211.
2257  */
2258 int ieee80211_stop_tx_ba_session(struct ieee80211_hw *hw,
2259                                  u8 *ra, u16 tid,
2260                                  enum ieee80211_back_parties initiator);
2261 
2262 /**
2263  * ieee80211_stop_tx_ba_cb - low level driver ready to stop aggregate.
2264  * @hw: pointer as obtained from ieee80211_alloc_hw().
2265  * @ra: receiver address of the BA session recipient.
2266  * @tid: the desired TID to BA on.
2267  *
2268  * This function must be called by low level driver once it has
2269  * finished with preparations for the BA session tear down.
2270  */
2271 void ieee80211_stop_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u8 tid);
2272 
2273 /**
2274  * ieee80211_stop_tx_ba_cb_irqsafe - low level driver ready to stop aggregate.
2275  * @hw: pointer as obtained from ieee80211_alloc_hw().
2276  * @ra: receiver address of the BA session recipient.
2277  * @tid: the desired TID to BA on.
2278  *
2279  * This function must be called by low level driver once it has
2280  * finished with preparations for the BA session tear down.
2281  * This version of the function is IRQ-safe.
2282  */
2283 void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_hw *hw, const u8 *ra,
2284                                      u16 tid);
2285 
2286 /**
2287  * ieee80211_find_sta - find a station
2288  *
2289  * @hw: pointer as obtained from ieee80211_alloc_hw()
2290  * @addr: station's address
2291  *
2292  * This function must be called under RCU lock and the
2293  * resulting pointer is only valid under RCU lock as well.
2294  */
2295 struct ieee80211_sta *ieee80211_find_sta(struct ieee80211_hw *hw,
2296                                          const u8 *addr);
2297 
2298 /**
2299  * ieee80211_beacon_loss - inform hardware does not receive beacons
2300  *
2301  * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
2302  *
2303  * When beacon filtering is enabled with IEEE80211_HW_BEACON_FILTERING and
2304  * IEEE80211_CONF_PS is set, the driver needs to inform whenever the
2305  * hardware is not receiving beacons with this function.
2306  */
2307 void ieee80211_beacon_loss(struct ieee80211_vif *vif);
2308 
2309 /* Rate control API */
2310 
2311 /**
2312  * enum rate_control_changed - flags to indicate which parameter changed
2313  *
2314  * @IEEE80211_RC_HT_CHANGED: The HT parameters of the operating channel have
2315  *      changed, rate control algorithm can update its internal state if needed.
2316  */
2317 enum rate_control_changed {
2318   IEEE80211_RC_HT_CHANGED = BIT(0)
2319 };
2320 
2321 /**
2322  * struct ieee80211_tx_rate_control - rate control information for/from RC algo
2323  *
2324  * @hw: The hardware the algorithm is invoked for.
2325  * @sband: The band this frame is being transmitted on.
2326  * @bss_conf: the current BSS configuration
2327  * @reported_rate: The rate control algorithm can fill this in to indicate
2328  *      which rate should be reported to userspace as the current rate and
2329  *      used for rate calculations in the mesh network.
2330  * @rts: whether RTS will be used for this frame because it is longer than the
2331  *      RTS threshold
2332  * @short_preamble: whether mac80211 will request short-preamble transmission
2333  *      if the selected rate supports it
2334  * @max_rate_idx: user-requested maximum rate (not MCS for now)
2335  * @skb: the skb that will be transmitted, the control information in it needs
2336  *      to be filled in
2337  */
2338 struct ieee80211_tx_rate_control {
2339   struct ieee80211_hw *hw;
2340   struct ieee80211_supported_band *sband;
2341   struct ieee80211_bss_conf *bss_conf;
2342   struct sk_buff *skb;
2343   struct ieee80211_tx_rate reported_rate;
2344   bool rts, short_preamble;
2345   u8 max_rate_idx;
2346 };
2347 
2348 struct rate_control_ops {
2349   struct module *module;
2350   const char *name;
2351   void *(*alloc)(struct ieee80211_hw *hw, struct dentry *debugfsdir);
2352   void (*free)(void *priv);
2353 
2354   void *(*alloc_sta)(void *priv, struct ieee80211_sta *sta, gfp_t gfp);
2355   void (*rate_init)(void *priv, struct ieee80211_supported_band *sband,
2356                     struct ieee80211_sta *sta, void *priv_sta);
2357   void (*rate_update)(void *priv, struct ieee80211_supported_band *sband,
2358                       struct ieee80211_sta *sta,
2359                       void *priv_sta, u32 changed);
2360   void (*free_sta)(void *priv, struct ieee80211_sta *sta,
2361                    void *priv_sta);
2362 
2363   void (*tx_status)(void *priv, struct ieee80211_supported_band *sband,
2364                     struct ieee80211_sta *sta, void *priv_sta,
2365                     struct sk_buff *skb);
2366   void (*get_rate)(void *priv, struct ieee80211_sta *sta, void *priv_sta,
2367                    struct ieee80211_tx_rate_control *txrc);
2368 
2369   void (*add_sta_debugfs)(void *priv, void *priv_sta,
2370                           struct dentry *dir);
2371   void (*remove_sta_debugfs)(void *priv, void *priv_sta);
2372 };
2373 
2374 static inline int rate_supported(struct ieee80211_sta *sta,
2375                                  enum ieee80211_band band,
2376                                  int index)
2377 {
2378   return (sta == NULL || sta->supp_rates[band] & BIT(index));
2379 }
2380 
2381 /**
2382  * rate_control_send_low - helper for drivers for management/no-ack frames
2383  *
2384  * Rate control algorithms that agree to use the lowest rate to
2385  * send management frames and NO_ACK data with the respective hw
2386  * retries should use this in the beginning of their mac80211 get_rate
2387  * callback. If true is returned the rate control can simply return.
2388  * If false is returned we guarantee that sta and sta and priv_sta is
2389  * not null.
2390  *
2391  * Rate control algorithms wishing to do more intelligent selection of
2392  * rate for multicast/broadcast frames may choose to not use this.
2393  *
2394  * @sta: &struct ieee80211_sta pointer to the target destination. Note
2395  *      that this may be null.
2396  * @priv_sta: private rate control structure. This may be null.
2397  * @txrc: rate control information we sholud populate for mac80211.
2398  */
2399 bool rate_control_send_low(struct ieee80211_sta *sta,
2400                            void *priv_sta,
2401                            struct ieee80211_tx_rate_control *txrc);
2402 
2403 
2404 static inline s8
2405 rate_lowest_index(struct ieee80211_supported_band *sband,
2406                   struct ieee80211_sta *sta)
2407 {
2408   int i;
2409 
2410   for (i = 0; i < sband->n_bitrates; i++)
2411     if (rate_supported(sta, sband->band, i))
2412       return i;
2413 
2414   /* warn when we cannot find a rate. */
2415   WARN_ON(1);
2416 
2417   return 0;
2418 }
2419 
2420 static inline
2421 bool rate_usable_index_exists(struct ieee80211_supported_band *sband,
2422                               struct ieee80211_sta *sta)
2423 {
2424   unsigned int i;
2425 
2426   for (i = 0; i < sband->n_bitrates; i++)
2427     if (rate_supported(sta, sband->band, i))
2428       return true;
2429   return false;
2430 }
2431 
2432 int ieee80211_rate_control_register(struct rate_control_ops *ops);
2433 void ieee80211_rate_control_unregister(struct rate_control_ops *ops);
2434 
2435 static inline bool
2436 conf_is_ht20(struct ieee80211_conf *conf)
2437 {
2438   return conf->channel_type == NL80211_CHAN_HT20;
2439 }
2440 
2441 static inline bool
2442 conf_is_ht40_minus(struct ieee80211_conf *conf)
2443 {
2444   return conf->channel_type == NL80211_CHAN_HT40MINUS;
2445 }
2446 
2447 static inline bool
2448 conf_is_ht40_plus(struct ieee80211_conf *conf)
2449 {
2450   return conf->channel_type == NL80211_CHAN_HT40PLUS;
2451 }
2452 
2453 static inline bool
2454 conf_is_ht40(struct ieee80211_conf *conf)
2455 {
2456   return conf_is_ht40_minus(conf) || conf_is_ht40_plus(conf);
2457 }
2458 
2459 static inline bool
2460 conf_is_ht(struct ieee80211_conf *conf)
2461 {
2462   return conf->channel_type != NL80211_CHAN_NO_HT;
2463 }
2464 
2465 #endif
2466 
2467 u16 ieee80211_calc_duration (u32 len, s16 rate);
2468 
2469 #endif /* MAC80211_H */
2470 
2471 /*
2472  * Local Variables:
2473  * indent-tabs-mode: nil
2474  * mode: C
2475  * c-file-style: "gnu"
2476  * c-basic-offset: 2
2477  * End:
2478  */
2479 
2480 /* vi: set et sw=2 sts=2: */