cfg80211: convert S1G beacon to scan results
authorThomas Pedersen <thomas@adapt-ip.com>
Tue, 22 Sep 2020 02:28:06 +0000 (19:28 -0700)
committerChristian Lamparter <chunkeey@gmail.com>
Fri, 5 Feb 2021 10:39:41 +0000 (11:39 +0100)
The S1G beacon is an extension frame as opposed to
management frame for the regular beacon. This means we may
have to occasionally cast the frame buffer to a different
header type. Luckily this isn't too bad as scan results
mostly only care about the IEs.

Signed-off-by: Thomas Pedersen <thomas@adapt-ip.com>
Link: https://lore.kernel.org/r/20200922022818.15855-6-thomas@adapt-ip.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
include/linux/ieee80211.h

index c7d78dfe042efd1c5370f20bfb6411fe9a3d4a56..38606456e3b638d8a930d99bd195b5fd88182d5a 100644 (file)
 
 #define IEEE80211_ANO_NETTYPE_WILD              15
 
+/* bits unique to S1G beacon */
+#define IEEE80211_S1G_BCN_NEXT_TBTT    0x100
+
 /* control extension - for IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTL_EXT */
 #define IEEE80211_CTL_EXT_POLL         0x2000
 #define IEEE80211_CTL_EXT_SPR          0x3000
@@ -542,6 +545,28 @@ static inline bool ieee80211_is_s1g_beacon(__le16 fc)
               cpu_to_le16(IEEE80211_FTYPE_EXT | IEEE80211_STYPE_S1G_BEACON);
 }
 
+/**
+ * ieee80211_next_tbtt_present - check if IEEE80211_FTYPE_EXT &&
+ * IEEE80211_STYPE_S1G_BEACON && IEEE80211_S1G_BCN_NEXT_TBTT
+ * @fc: frame control bytes in little-endian byteorder
+ */
+static inline bool ieee80211_next_tbtt_present(__le16 fc)
+{
+       return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
+              cpu_to_le16(IEEE80211_FTYPE_EXT | IEEE80211_STYPE_S1G_BEACON) &&
+              fc & cpu_to_le16(IEEE80211_S1G_BCN_NEXT_TBTT);
+}
+
+/**
+ * ieee80211_is_s1g_short_beacon - check if next tbtt present bit is set. Only
+ * true for S1G beacons when they're short.
+ * @fc: frame control bytes in little-endian byteorder
+ */
+static inline bool ieee80211_is_s1g_short_beacon(__le16 fc)
+{
+       return ieee80211_is_s1g_beacon(fc) && ieee80211_next_tbtt_present(fc);
+}
+
 /**
  * ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM
  * @fc: frame control bytes in little-endian byteorder
@@ -1036,6 +1061,13 @@ struct ieee80211_ext {
                        u8 change_seq;
                        u8 variable[0];
                } __packed s1g_beacon;
+               struct {
+                       u8 sa[6];
+                       __le32 timestamp;
+                       u8 change_seq;
+                       u8 next_tbtt[3];
+                       u8 variable[0];
+               } __packed s1g_short_beacon;
        } u;
 } __packed __aligned(2);
 
@@ -1070,6 +1102,11 @@ struct ieee80211_mgmt {
                        /* followed by Supported rates */
                        u8 variable[0];
                } __packed __aligned(4) assoc_resp, reassoc_resp;
+               struct {
+                       __le16 capab_info;
+                       __le16 status_code;
+                       u8 variable[0];
+               } __packed __aligned(4) s1g_assoc_resp, s1g_reassoc_resp;
                struct {
                        __le16 capab_info;
                        __le16 listen_interval;