git: f4aa407e89fe - stable/14 - LinuxKPI: 802.11: CONFIG_PM_SLEEP / WoWLAN header adjustments

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Fri, 18 Apr 2025 14:37:10 UTC
The branch stable/14 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=f4aa407e89fe8961efe722a53ae463c25ef5ea20

commit f4aa407e89fe8961efe722a53ae463c25ef5ea20
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2025-03-15 00:30:38 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2025-04-18 14:36:00 +0000

    LinuxKPI: 802.11: CONFIG_PM_SLEEP / WoWLAN header adjustments
    
    Sort out some (though not yet all) changes needed for CONFIG_PM_SLEEP
    and respectively WoWLAN support (so we can compile it in).  This is
    just one further step towards proper suspend/resume support.
    
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit b42c339c59fd00f2d97f6854b17b54b340019d0c)
---
 .../linuxkpi/common/include/linux/ieee80211.h      |  7 ++++++
 sys/compat/linuxkpi/common/include/net/cfg80211.h  | 26 +++++++++++++++++-----
 sys/compat/linuxkpi/common/include/net/mac80211.h  | 16 +++++++++----
 3 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/ieee80211.h b/sys/compat/linuxkpi/common/include/linux/ieee80211.h
index 964fd970ecf0..efac2a26e27e 100644
--- a/sys/compat/linuxkpi/common/include/linux/ieee80211.h
+++ b/sys/compat/linuxkpi/common/include/linux/ieee80211.h
@@ -147,6 +147,7 @@ enum ieee80211_key_len {
 	WLAN_KEY_LEN_WEP104			= 13,
 	WLAN_KEY_LEN_TKIP			= 32,
 	WLAN_KEY_LEN_CCMP			= 16,
+	WLAN_KEY_LEN_CCMP_256			= 32,
 	WLAN_KEY_LEN_GCMP			= 16,
 	WLAN_KEY_LEN_AES_CMAC			= 16,
 	WLAN_KEY_LEN_GCMP_256			= 32,
@@ -507,6 +508,12 @@ struct ieee80211_mgmt {
 			uint16_t	capab_info;
 			uint8_t		variable[0];
 		} beacon;
+		/* 9.3.3.5 Association Request frame format */
+		struct  {
+			uint16_t	capab_info;
+			uint16_t	listen_interval;
+			uint8_t		variable[0];
+		} assoc_req;
 		/* 9.3.3.10 Probe Request frame format */
 		struct {
 			uint8_t		variable[0];
diff --git a/sys/compat/linuxkpi/common/include/net/cfg80211.h b/sys/compat/linuxkpi/common/include/net/cfg80211.h
index 3454b58f1db7..2cdb96ffccdf 100644
--- a/sys/compat/linuxkpi/common/include/net/cfg80211.h
+++ b/sys/compat/linuxkpi/common/include/net/cfg80211.h
@@ -1033,9 +1033,12 @@ struct cfg80211_wowlan_nd_info {
 
 enum wiphy_wowlan_support_flags {
 	WIPHY_WOWLAN_DISCONNECT,
-	WIPHY_WOWLAN_GTK_REKEY_FAILURE,
 	WIPHY_WOWLAN_MAGIC_PKT,
 	WIPHY_WOWLAN_SUPPORTS_GTK_REKEY,
+	WIPHY_WOWLAN_GTK_REKEY_FAILURE,
+	WIPHY_WOWLAN_EAP_IDENTITY_REQ,
+	WIPHY_WOWLAN_4WAY_HANDSHAKE,
+	WIPHY_WOWLAN_RFKILL_RELEASE,
 	WIPHY_WOWLAN_NET_DETECT,
 };
 
@@ -1049,6 +1052,7 @@ struct cfg80211_wowlan_wakeup {
 	/* XXX TODO */
 	uint16_t				pattern_idx;
 	bool					disconnect;
+	bool					unprot_deauth_disassoc;
 	bool					eap_identity_req;
 	bool					four_way_handshake;
 	bool					gtk_rekey_failure;
@@ -1066,11 +1070,22 @@ struct cfg80211_wowlan_wakeup {
 
 struct cfg80211_wowlan {
 	/* XXX TODO */
-	int	disconnect, gtk_rekey_failure, magic_pkt;
-	int	eap_identity_req, four_way_handshake, rfkill_release, tcp, any;
+	bool					any;
+	bool					disconnect;
+	bool					magic_pkt;
+	bool					gtk_rekey_failure;
+	bool					eap_identity_req;
+	bool					four_way_handshake;
+	bool					rfkill_release;
+
+	/* Magic packet patterns. */
 	int					n_patterns;
-	struct cfg80211_sched_scan_request	*nd_config;
 	struct cfg80211_pkt_pattern		*patterns;
+
+	/* netdetect? if not assoc? */
+	struct cfg80211_sched_scan_request	*nd_config;
+
+	void					*tcp;		/* XXX ? */
 };
 
 struct cfg80211_gtk_rekey_data {
@@ -1244,7 +1259,8 @@ struct wiphy {
 
 	unsigned long				ext_features[BITS_TO_LONGS(NUM_NL80211_EXT_FEATURES)];
 	struct dentry				*debugfsdir;
-	struct cfg80211_wowlan_support		*wowlan;
+	const struct wiphy_wowlan_support	*wowlan;
+	struct cfg80211_wowlan			*wowlan_config;
 	/* Lower layer (driver/mac80211) specific data. */
 	/* Must stay last. */
 	uint8_t					priv[0] __aligned(CACHE_LINE_SIZE);
diff --git a/sys/compat/linuxkpi/common/include/net/mac80211.h b/sys/compat/linuxkpi/common/include/net/mac80211.h
index baac9fe67fdd..5c155a4c1cc8 100644
--- a/sys/compat/linuxkpi/common/include/net/mac80211.h
+++ b/sys/compat/linuxkpi/common/include/net/mac80211.h
@@ -42,6 +42,7 @@
 #include <linux/workqueue.h>
 #include <linux/dcache.h>
 #include <net/cfg80211.h>
+#include <net/if_inet6.h>
 
 #define	ARPHRD_IEEE80211_RADIOTAP		__LINE__ /* XXX TODO brcmfmac */
 
@@ -1075,9 +1076,7 @@ struct ieee80211_ops {
 	int  (*set_tim)(struct ieee80211_hw *, struct ieee80211_sta *, bool);
 
 	int  (*set_key)(struct ieee80211_hw *, enum set_key_cmd, struct ieee80211_vif *, struct ieee80211_sta *, struct ieee80211_key_conf *);
-	void (*set_default_unicast_key)(struct ieee80211_hw *, struct ieee80211_vif *, int);
 	void (*update_tkip_key)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_key_conf *, struct ieee80211_sta *, u32, u16 *);
-	void (*set_rekey_data)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_gtk_rekey_data *);
 
 	int  (*start_pmsr)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_pmsr_request *);
 	void (*abort_pmsr)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_pmsr_request *);
@@ -1121,9 +1120,18 @@ struct ieee80211_ops {
 	void (*link_sta_add_debugfs)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_link_sta *, struct dentry *);
 	void (*link_add_debugfs)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, struct dentry *);
 /* #endif */
+/* #ifdef CONFIG_PM_SLEEP */		/* Do not change depending on compile-time option. */
+	int (*suspend)(struct ieee80211_hw *, struct cfg80211_wowlan *);
+	int (*resume)(struct ieee80211_hw *);
+	void (*set_wakeup)(struct ieee80211_hw *, bool);
+	void (*set_rekey_data)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_gtk_rekey_data *);
+	void (*set_default_unicast_key)(struct ieee80211_hw *, struct ieee80211_vif *, int);
+/* #if IS_ENABLED(CONFIG_IPV6) */
+	void (*ipv6_addr_change)(struct ieee80211_hw *, struct ieee80211_vif *, struct inet6_dev *);
+/* #endif */
+/* #endif CONFIG_PM_SLEEP */
 };
 
-
 /* -------------------------------------------------------------------------- */
 
 /* linux_80211.c */
@@ -2411,7 +2419,7 @@ ieee80211_get_tkip_p1k_iv(struct ieee80211_key_conf *key,
 
 static __inline struct ieee80211_key_conf *
 ieee80211_gtk_rekey_add(struct ieee80211_vif *vif,
-    struct ieee80211_key_conf *key)
+    struct ieee80211_key_conf *key, int link_id)
 {
         TODO();
         return (NULL);