Commit b9c3d426 authored by Ilan Peer's avatar Ilan Peer Committed by Johannes Berg
Browse files

wifi: cfg80211: Advertise supported NAN capabilities



Allow drivers to specify the supported NAN capabilities and support
advertising the NAN capabilities to user space.

Signed-off-by: default avatarIlan Peer <ilan.peer@intel.com>
Signed-off-by: default avatarMiri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20250908140015.2976966556f5.Ic6e43b10049573180c909dad806f279cfb31143e@changeid


Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 3cbadd84
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -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 */
+38 −0
Original line number Diff line number Diff line
@@ -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;
+41 −0
Original line number Diff line number Diff line
@@ -2605,6 +2605,41 @@ static int nl80211_put_radios(struct wiphy *wiphy, struct sk_buff *msg)
	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;