]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: cfg80211: Advertise supported NAN capabilities
authorIlan Peer <ilan.peer@intel.com>
Mon, 8 Sep 2025 11:12:59 +0000 (14:12 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 19 Sep 2025 09:26:22 +0000 (11:26 +0200)
Allow drivers to specify the supported NAN capabilities and support
advertising the NAN capabilities to user space.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20250908140015.2976966556f5.Ic6e43b10049573180c909dad806f279cfb31143e@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/linux/ieee80211.h
include/net/cfg80211.h
net/wireless/nl80211.c

index d350263f23f3296158f8a66b09021f1b015bb675..2110345de8efe951ec866a27508f7969331db216 100644 (file)
@@ -6065,4 +6065,21 @@ static inline u32 ieee80211_eml_trans_timeout_in_us(u16 eml_cap)
                                 _data + ieee80211_mle_common_size(_data),\
                                 _len - ieee80211_mle_common_size(_data))
 
+/* NAN operation mode, as defined in Wi-Fi Aware (TM) specification Table 81 */
+#define NAN_OP_MODE_PHY_MODE_VHT       0x01
+#define NAN_OP_MODE_PHY_MODE_HE                0x10
+#define NAN_OP_MODE_PHY_MODE_MASK      0x11
+#define NAN_OP_MODE_80P80MHZ           0x02
+#define NAN_OP_MODE_160MHZ             0x04
+#define NAN_OP_MODE_PNDL_SUPPRTED      0x08
+
+/* NAN Device capabilities, as defined in Wi-Fi Aware (TM) specification
+ * Table 79
+ */
+#define NAN_DEV_CAPA_DFS_OWNER                 0x01
+#define NAN_DEV_CAPA_EXT_KEY_ID_SUPPORTED      0x02
+#define NAN_DEV_CAPA_SIM_NDP_RX_SUPPORTED      0x04
+#define NAN_DEV_CAPA_NDPE_SUPPORTED            0x08
+#define NAN_DEV_CAPA_S3_SUPPORTED              0x10
+
 #endif /* LINUX_IEEE80211_H */
index 1b10bd31bdd6c0c179dd00dc28dd77a2461210c6..e30c1886c5304f39202477426eb6a10f7b5a6926 100644 (file)
@@ -5711,6 +5711,42 @@ struct wiphy_radio {
        u32 antenna_mask;
 };
 
+/**
+ * enum wiphy_nan_flags - NAN capabilities
+ *
+ * @WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC: Device supports NAN configurable
+ *     synchronization.
+ * @WIPHY_NAN_FLAGS_USERSPACE_DE: Device doesn't support DE offload.
+ */
+enum wiphy_nan_flags {
+       WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC = BIT(0),
+       WIPHY_NAN_FLAGS_USERSPACE_DE   = BIT(1),
+};
+
+/**
+ * struct wiphy_nan_capa - NAN capabilities
+ *
+ * This structure describes the NAN capabilities of a wiphy.
+ *
+ * @flags: NAN capabilities flags, see &enum wiphy_nan_flags
+ * @op_mode: NAN operation mode, as defined in Wi-Fi Aware (TM) specification
+ *     Table 81.
+ * @n_antennas: number of antennas supported by the device for Tx/Rx. Lower
+ *     nibble indicates the number of TX antennas and upper nibble indicates the
+ *     number of RX antennas. Value 0 indicates the information is not
+ *     available.
+ * @max_channel_switch_time: maximum channel switch time in milliseconds.
+ * @dev_capabilities: NAN device capabilities as defined in Wi-Fi Aware (TM)
+ *     specification Table 79 (Capabilities field).
+ */
+struct wiphy_nan_capa {
+       u32 flags;
+       u8 op_mode;
+       u8 n_antennas;
+       u16 max_channel_switch_time;
+       u8 dev_capabilities;
+};
+
 #define CFG80211_HW_TIMESTAMP_ALL_PEERS        0xffff
 
 /**
@@ -5884,6 +5920,7 @@ struct wiphy_radio {
  *     bitmap of &enum nl80211_band values.  For instance, for
  *     NL80211_BAND_2GHZ, bit 0 would be set
  *     (i.e. BIT(NL80211_BAND_2GHZ)).
+ * @nan_capa: NAN capabilities
  *
  * @txq_limit: configuration of internal TX queue frame limit
  * @txq_memory_limit: configuration internal TX queue memory limit
@@ -6065,6 +6102,7 @@ struct wiphy {
        u32 bss_select_support;
 
        u8 nan_supported_bands;
+       struct wiphy_nan_capa nan_capa;
 
        u32 txq_limit;
        u32 txq_memory_limit;
index 904a725a4f4ab8a26df0d85d22f9894fad383496..bcd18ae59e8495e5e2113b2864e8917960f190db 100644 (file)
@@ -2605,6 +2605,41 @@ fail:
        return -ENOBUFS;
 }
 
+static int nl80211_put_nan_capa(struct wiphy *wiphy, struct sk_buff *msg)
+{
+       struct nlattr *nan_caps;
+
+       nan_caps = nla_nest_start(msg, NL80211_ATTR_NAN_CAPABILITIES);
+       if (!nan_caps)
+               return -ENOBUFS;
+
+       if (wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC &&
+           nla_put_flag(msg, NL80211_NAN_CAPA_CONFIGURABLE_SYNC))
+               goto fail;
+
+       if ((wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_USERSPACE_DE) &&
+           nla_put_flag(msg, NL80211_NAN_CAPA_USERSPACE_DE))
+               goto fail;
+
+       if (nla_put_u8(msg, NL80211_NAN_CAPA_OP_MODE,
+                      wiphy->nan_capa.op_mode) ||
+           nla_put_u8(msg, NL80211_NAN_CAPA_NUM_ANTENNAS,
+                      wiphy->nan_capa.n_antennas) ||
+           nla_put_u16(msg, NL80211_NAN_CAPA_MAX_CHANNEL_SWITCH_TIME,
+                       wiphy->nan_capa.max_channel_switch_time) ||
+           nla_put_u8(msg, NL80211_NAN_CAPA_CAPABILITIES,
+                      wiphy->nan_capa.dev_capabilities))
+               goto fail;
+
+       nla_nest_end(msg, nan_caps);
+
+       return 0;
+
+fail:
+       nla_nest_cancel(msg, nan_caps);
+       return -ENOBUFS;
+}
+
 struct nl80211_dump_wiphy_state {
        s64 filter_wiphy;
        long start;
@@ -3257,6 +3292,12 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
                if (nl80211_put_radios(&rdev->wiphy, msg))
                        goto nla_put_failure;
 
+               state->split_start++;
+               break;
+       case 18:
+               if (nl80211_put_nan_capa(&rdev->wiphy, msg))
+                       goto nla_put_failure;
+
                /* done */
                state->split_start = 0;
                break;