mac80211: implement Operating Mode Notification extended NSS support
[carl9170fw.git] / include / linux / ieee80211.h
index fafe733aa909dd2aa6e076121e7b77eb8cf6cdaf..0aa180a0b6d18ca627d6bf615c06f6340d567f66 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * IEEE 802.11 defines
  *
@@ -8,11 +9,7 @@
  * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
  * Copyright (c) 2013 - 2014 Intel Mobile Communications GmbH
  * Copyright (c) 2016 - 2017 Intel Deutschland GmbH
- * Copyright (c) 2018 - 2019 Intel Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * Copyright (c) 2018 - 2020 Intel Corporation
  */
 
 #ifndef __LINUX_IEEE80211_H
@@ -627,6 +624,15 @@ static inline unsigned int ieee80211_hdrlen(__le16 fc)
         return hdrlen;
 }
 
+/**
+ * ieee80211_is_any_nullfunc - check if frame is regular or QoS nullfunc frame
+ * @fc: frame control bytes in little-endian byteorder
+ */
+static inline bool ieee80211_is_any_nullfunc(__le16 fc)
+{
+       return (ieee80211_is_nullfunc(fc) || ieee80211_is_qos_nullfunc(fc));
+}
+
 /**
  * ieee80211_is_bufferable_mmpdu - check if frame is bufferable MMPDU
  * @fc: frame control field in little-endian byteorder
@@ -855,6 +861,7 @@ enum ieee80211_ht_chanwidth_values {
  * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_40MHZ: 40 MHz channel width
  * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_80MHZ: 80 MHz channel width
  * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_160MHZ: 160 MHz or 80+80 MHz channel width
+ * @IEEE80211_OPMODE_NOTIF_BW_160_80P80: 160 / 80+80 MHz indicator flag
  * @IEEE80211_OPMODE_NOTIF_RX_NSS_MASK: number of spatial streams mask
  *     (the NSS value is the value of this field + 1)
  * @IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT: number of spatial streams shift
@@ -862,11 +869,12 @@ enum ieee80211_ht_chanwidth_values {
  *     using a beamforming steering matrix
  */
 enum ieee80211_vht_opmode_bits {
-       IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK   = 3,
+       IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK   = 0x03,
        IEEE80211_OPMODE_NOTIF_CHANWIDTH_20MHZ  = 0,
        IEEE80211_OPMODE_NOTIF_CHANWIDTH_40MHZ  = 1,
        IEEE80211_OPMODE_NOTIF_CHANWIDTH_80MHZ  = 2,
        IEEE80211_OPMODE_NOTIF_CHANWIDTH_160MHZ = 3,
+       IEEE80211_OPMODE_NOTIF_BW_160_80P80     = 0x04,
        IEEE80211_OPMODE_NOTIF_RX_NSS_MASK      = 0x70,
        IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT     = 4,
        IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF   = 0x80,
@@ -886,6 +894,14 @@ struct ieee80211_tpc_report_ie {
        u8 link_margin;
 } __packed;
 
+#define IEEE80211_ADDBA_EXT_FRAG_LEVEL_MASK    GENMASK(2, 1)
+#define IEEE80211_ADDBA_EXT_FRAG_LEVEL_SHIFT   1
+#define IEEE80211_ADDBA_EXT_NO_FRAG            BIT(0)
+
+struct ieee80211_addba_ext_ie {
+       u8 data;
+} __packed;
+
 struct ieee80211_mgmt {
        __le16 frame_control;
        __le16 duration;
@@ -978,6 +994,8 @@ struct ieee80211_mgmt {
                                        __le16 capab;
                                        __le16 timeout;
                                        __le16 start_seq_num;
+                                       /* followed by BA Extension */
+                                       u8 variable[0];
                                } __packed addba_req;
                                struct{
                                        u8 action_code;
@@ -1647,6 +1665,18 @@ struct ieee80211_he_operation {
        u8 optional[0];
 } __packed;
 
+/**
+ * struct ieee80211_he_spr - HE spatial reuse element
+ *
+ * This structure is the "HE spatial reuse element" element as
+ * described in P802.11ax_D4.0 section 9.4.2.241
+ */
+struct ieee80211_he_spr {
+       u8 he_sr_control;
+       /* Optional 0 to 19 bytes: depends on @he_sr_control */
+       u8 optional[0];
+} __packed;
+
 /**
  * struct ieee80211_he_mu_edca_param_ac_rec - MU AC Parameter Record field
  *
@@ -1722,6 +1752,9 @@ struct ieee80211_mu_edca_param_set {
  * @ext_nss_bw_capable: indicates whether or not the local transmitter
  *     (rate scaling algorithm) can deal with the new logic
  *     (dot11VHTExtendedNSSBWCapable)
+ * @max_vht_nss: current maximum NSS as advertised by the STA in
+ *     operating mode notification, can be 0 in which case the
+ *     capability data will be used to derive this (from MCS support)
  *
  * Due to the VHT Extended NSS Bandwidth Support, the maximum NSS can
  * vary for a given BW/MCS. This function parses the data.
@@ -1730,7 +1763,8 @@ struct ieee80211_mu_edca_param_set {
  */
 int ieee80211_get_vht_max_nss(struct ieee80211_vht_cap *cap,
                              enum ieee80211_vht_chanwidth bw,
-                             int mcs, bool ext_nss_bw_capable);
+                             int mcs, bool ext_nss_bw_capable,
+                             unsigned int max_vht_nss);
 
 /* 802.11ax HE MAC capabilities */
 #define IEEE80211_HE_MAC_CAP0_HTC_HE                           0x01
@@ -2047,16 +2081,16 @@ ieee80211_he_ppe_size(u8 ppe_thres_hdr, const u8 *phy_cap_info)
 #define IEEE80211_HE_OPERATION_ER_SU_DISABLE                   0x00010000
 #define IEEE80211_HE_OPERATION_6GHZ_OP_INFO                    0x00020000
 #define IEEE80211_HE_OPERATION_BSS_COLOR_MASK                  0x3f000000
-#define IEEE80211_HE_OPERATION_BSS_COLOR_OFFSET                24
+#define IEEE80211_HE_OPERATION_BSS_COLOR_OFFSET                        24
 #define IEEE80211_HE_OPERATION_PARTIAL_BSS_COLOR               0x40000000
 #define IEEE80211_HE_OPERATION_BSS_COLOR_DISABLED              0x80000000
 
 /*
  * ieee80211_he_oper_size - calculate 802.11ax HE Operations IE size
- * @he_oper_ie: byte data of the He Operations IE, stating from the the byte
+ * @he_oper_ie: byte data of the He Operations IE, stating from the byte
  *     after the ext ID byte. It is assumed that he_oper_ie has at least
- *     sizeof(struct ieee80211_he_operation) bytes, checked already in
- *     ieee802_11_parse_elems_crc()
+ *     sizeof(struct ieee80211_he_operation) bytes, the caller must have
+ *     validated this.
  * @return the actual size of the IE data (not including header), or 0 on error
  */
 static inline u8
@@ -2085,6 +2119,42 @@ ieee80211_he_oper_size(const u8 *he_oper_ie)
        return oper_len;
 }
 
+/* HE Spatial Reuse defines */
+#define IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT                        0x4
+#define IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT               0x8
+
+/*
+ * ieee80211_he_spr_size - calculate 802.11ax HE Spatial Reuse IE size
+ * @he_spr_ie: byte data of the He Spatial Reuse IE, stating from the byte
+ *     after the ext ID byte. It is assumed that he_spr_ie has at least
+ *     sizeof(struct ieee80211_he_spr) bytes, the caller must have validated
+ *     this
+ * @return the actual size of the IE data (not including header), or 0 on error
+ */
+static inline u8
+ieee80211_he_spr_size(const u8 *he_spr_ie)
+{
+       struct ieee80211_he_spr *he_spr = (void *)he_spr_ie;
+       u8 spr_len = sizeof(struct ieee80211_he_spr);
+       u8 he_spr_params;
+
+       /* Make sure the input is not NULL */
+       if (!he_spr_ie)
+               return 0;
+
+       /* Calc required length */
+       he_spr_params = he_spr->he_sr_control;
+       if (he_spr_params & IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT)
+               spr_len++;
+       if (he_spr_params & IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT)
+               spr_len += 18;
+
+       /* Add the first byte (extension ID) to the total length */
+       spr_len++;
+
+       return spr_len;
+}
+
 /* Authentication algorithms */
 #define WLAN_AUTH_OPEN 0
 #define WLAN_AUTH_SHARED_KEY 1
@@ -2487,6 +2557,7 @@ enum ieee80211_eid {
        WLAN_EID_FILS_INDICATION = 240,
        WLAN_EID_DILS = 241,
        WLAN_EID_FRAGMENT = 242,
+       WLAN_EID_RSNX = 244,
        WLAN_EID_EXTENSION = 255
 };
 
@@ -2507,6 +2578,7 @@ enum ieee80211_eid_ext {
        WLAN_EID_EXT_HE_OPERATION = 36,
        WLAN_EID_EXT_UORA = 37,
        WLAN_EID_EXT_HE_MU_EDCA = 38,
+       WLAN_EID_EXT_HE_SPR = 39,
        WLAN_EID_EXT_MAX_CHANNEL_SWITCH_TIME = 52,
        WLAN_EID_EXT_MULTIPLE_BSSID_CONFIGURATION = 55,
        WLAN_EID_EXT_NON_INHERITANCE = 56,
@@ -2697,7 +2769,7 @@ enum ieee80211_tdls_actioncode {
  */
 #define WLAN_EXT_CAPA3_MULTI_BSSID_SUPPORT     BIT(6)
 
-/* TDLS capabilities in the the 4th byte of @WLAN_EID_EXT_CAPABILITY */
+/* TDLS capabilities in the 4th byte of @WLAN_EID_EXT_CAPABILITY */
 #define WLAN_EXT_CAPA4_TDLS_BUFFER_STA         BIT(4)
 #define WLAN_EXT_CAPA4_TDLS_PEER_PSM           BIT(5)
 #define WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH                BIT(6)
@@ -2732,6 +2804,13 @@ enum ieee80211_tdls_actioncode {
 #define WLAN_EXT_CAPA10_TWT_REQUESTER_SUPPORT  BIT(5)
 #define WLAN_EXT_CAPA10_TWT_RESPONDER_SUPPORT  BIT(6)
 
+/*
+ * When set, indicates that the AP is able to tolerate 26-tone RU UL
+ * OFDMA transmissions using HE TB PPDU from OBSS (not falsely classify the
+ * 26-tone RU UL OFDMA transmissions as radar pulses).
+ */
+#define WLAN_EXT_CAPA10_OBSS_NARROW_BW_RU_TOLERANCE_SUPPORT BIT(7)
+
 /* Defines support for enhanced multi-bssid advertisement*/
 #define WLAN_EXT_CAPA11_EMA_SUPPORT    BIT(1)
 
@@ -2990,6 +3069,7 @@ struct ieee80211_multiple_bssid_configuration {
 #define WLAN_AKM_SUITE_FILS_SHA384             SUITE(0x000FAC, 15)
 #define WLAN_AKM_SUITE_FT_FILS_SHA256          SUITE(0x000FAC, 16)
 #define WLAN_AKM_SUITE_FT_FILS_SHA384          SUITE(0x000FAC, 17)
+#define WLAN_AKM_SUITE_OWE                     SUITE(0x000FAC, 18)
 
 #define WLAN_MAX_KEY_LEN               32
 
@@ -3279,4 +3359,11 @@ static inline bool for_each_element_completed(const struct element *element,
        return (const u8 *)element == (const u8 *)data + datalen;
 }
 
+/**
+ * RSNX Capabilities:
+ * bits 0-3: Field length (n-1)
+ */
+#define WLAN_RSNX_CAPA_PROTECTED_TWT BIT(4)
+#define WLAN_RSNX_CAPA_SAE_H2E BIT(5)
+
 #endif /* __LINUX_IEEE80211_H */