mac80211: HE: add Spatial Reuse element parsing support
[carl9170fw.git] / include / linux / ieee80211.h
index d21efe6726dccaa3869f74265e0d8abe2502fe93..8b84b71fdf242c91f3024ebe0825c7623d44f4e8 100644 (file)
@@ -1652,6 +1652,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
  *
@@ -2090,6 +2102,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 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);
+       u32 he_spr_params;
+
+       /* Make sure the input is not NULL */
+       if (!he_spr_ie)
+               return 0;
+
+       /* Calc required length */
+       he_spr_params = le32_to_cpu(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
@@ -2512,6 +2560,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,