Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dc58762f authored by Johannes Berg's avatar Johannes Berg Committed by Greg Kroah-Hartman
Browse files

BACKPORT: nl80211: modify TID-config API



Make some changes to the TID-config API:
 * use u16 in nl80211 (only, and restrict to using 8 bits for now),
   to avoid issues in the future if we ever want to use higher TIDs.
 * reject empty TIDs mask (via netlink policy)
 * change feature advertising to not use extended feature flags but
   have own mechanism for this, which simplifies the code
 * fix all variable names from 'tid' to 'tids' since it's a mask
 * change to cfg80211_ name prefixes, not ieee80211_
 * fix some minor docs/spelling things.

Bug: 154782456
Change-Id: Ia234d464b3f914cdeab82f540e018855be580dce
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
(cherry picked from commit 3710a8a6284f58a78ba4fe9c4b6672207636a223)
Signed-off-by: default avatarVamsi Krishna <vamsin@codeaurora.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 7a59f8ca
Loading
Loading
Loading
Loading
+25 −18
Original line number Diff line number Diff line
@@ -611,36 +611,32 @@ struct cfg80211_chan_def {
	struct ieee80211_edmg edmg;
};

enum ieee80211_tid_conf_mask {
	IEEE80211_TID_CONF_NOACK	= BIT(NL80211_TID_CONFIG_ATTR_NOACK),
};

/**
 * struct ieee80211_tid_cfg - TID specific configuration
 * struct cfg80211_tid_cfg - TID specific configuration
 * @config_override: Flag to notify driver to reset TID configuration
 *	of the peer.
 * @tid: TID number
 * @tid_conf_mask: bitmap indicating which parameter changed
 *	see &enum ieee80211_tid_conf_mask
 * @tids: bitmap of TIDs to modify
 * @mask: bitmap of attributes indicating which parameter changed,
 *	similar to &nl80211_tid_config_supp.
 * @noack: noack configuration value for the TID
 */
struct ieee80211_tid_cfg {
struct cfg80211_tid_cfg {
	bool config_override;
	u8 tid;
	u32 tid_conf_mask;
	u8 tids;
	u32 mask;
	enum nl80211_tid_config noack;
};

/**
 * struct ieee80211_tid_config - TID configuration
 * struct cfg80211_tid_config - TID configuration
 * @peer: Station's MAC address
 * @n_tid_conf: Number of TID specific configurations to be applied
 * @tid_conf: Configuration change info
 */
struct ieee80211_tid_config {
struct cfg80211_tid_config {
	const u8 *peer;
	u32 n_tid_conf;
	struct ieee80211_tid_cfg tid_conf[];
	struct cfg80211_tid_cfg tid_conf[];
};

/**
@@ -3683,8 +3679,8 @@ struct cfg80211_update_owe_info {
 *	and overrule HWMP path selection algorithm.
 * @set_tid_config: TID specific configuration, this can be peer or BSS specific
 *	This callback may sleep.
 * @reset_tid_config: Reset TID specific configuration for the peer.
 *	This callback may sleep.
 * @reset_tid_config: Reset TID specific configuration for the peer, for the
 *	given TIDs. This callback may sleep.
 */
struct cfg80211_ops {
	int	(*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -4009,9 +4005,9 @@ struct cfg80211_ops {
	int	(*probe_mesh_link)(struct wiphy *wiphy, struct net_device *dev,
				   const u8 *buf, size_t len);
	int     (*set_tid_config)(struct wiphy *wiphy, struct net_device *dev,
				  struct ieee80211_tid_config *tid_conf);
				  struct cfg80211_tid_config *tid_conf);
	int	(*reset_tid_config)(struct wiphy *wiphy, struct net_device *dev,
				    const u8 *peer, u8 tid);
				    const u8 *peer, u8 tids);
};

/*
@@ -4624,6 +4620,13 @@ struct wiphy_iftype_akm_suites {
 *	@support_mbssid must be set for this to have any effect.
 *
 * @pmsr_capa: peer measurement capabilities
 *
 * @tid_config_support: describes the per-TID config support that the
 *	device has
 * @tid_config_support.vif: bitmap of attributes (configurations)
 *	supported by the driver for each vif
 * @tid_config_support.peer: bitmap of attributes (configurations)
 *	supported by the driver for each peer
 */
struct wiphy {
	/* assign these fields before you register the wiphy */
@@ -4771,6 +4774,10 @@ struct wiphy {

	const struct cfg80211_pmsr_capabilities *pmsr_capa;

	struct {
		u64 peer, vif;
	} tid_config_support;

	char priv[0] __aligned(NETDEV_ALIGN);
};

+29 −22
Original line number Diff line number Diff line
@@ -267,20 +267,22 @@
/**
 * DOC: TID configuration
 *
 * TID configuration support can be advertised by drivers by setting
 * @NL80211_EXT_FEATURE_PER_TID_* and/or @NL80211_EXT_FEATURE_PER_STA_* config
 * mentioned in &enum nl80211_tid_config_attr.
 * Needed configuration parameters are mentioned in
 * &enum nl80211_tid_config_attr and it will be passed using
 * %NL80211_CMD_SET_TID_CONFIG through %NL80211_ATTR_TID_CONFIG.
 * If the configuration needs to be applied for specific peer then MAC address
 * of the peer needs to be passed in %NL80211_ATT_MAC, otherwise the
 * TID config support can be checked in the %NL80211_ATTR_TID_CONFIG
 * attribute given in wiphy capabilities.
 *
 * The necessary configuration parameters are mentioned in
 * &enum nl80211_tid_config_attr and it will be passed to the
 * %NL80211_CMD_SET_TID_CONFIG command in %NL80211_ATTR_TID_CONFIG.
 *
 * If the configuration needs to be applied for specific peer then the MAC
 * address of the peer needs to be passed in %NL80211_ATTR_MAC, otherwise the
 * configuration will be applied for all the connected peers in the vif except
 * the peer which has peer specific configuration for the TID.
 * And the peer specific configuration will be overridden if
 * %NL80211_TID_CONFIG_ATTR_OVERRIDE flag is set.
 * All this configurations are valid only for STA's current connection
 * i.e. the configurations will be reset to default when the STA connects back
 * any peers that have peer specific configuration for the TID by default; if
 * the %NL80211_TID_CONFIG_ATTR_OVERRIDE flag is set, peer specific values
 * will be overwritten.
 *
 * All this configuration is valid only for STA's current connection
 * i.e. the configuration will be reset to default when the STA connects back
 * after disconnection/roaming, and this configuration will be cleared when
 * the interface goes down.
 */
@@ -2428,7 +2430,9 @@ enum nl80211_commands {
 *	advertised for a specific interface type.
 *
 * @NL80211_ATTR_TID_CONFIG: TID specific configuration in a
 *	nested attribute with &enum nl80211_tid_config_attr sub-attributes.
 *	nested attribute with &enum nl80211_tid_config_attr sub-attributes;
 *	on output (in wiphy attributes) it contains only the feature sub-
 *	attributes.
 *
 * @NUM_NL80211_ATTR: total number of nl80211_attrs available
 * @NL80211_ATTR_MAX: highest attribute number currently defined
@@ -4751,6 +4755,12 @@ enum nl80211_tid_config {
};

/* enum nl80211_tid_config_attr - TID specific configuration.
 * @NL80211_TID_CONFIG_ATTR_PAD: pad attribute for 64-bit values
 * @NL80211_TID_CONFIG_ATTR_VIF_SUPP: a bitmap (u64) of attributes supported
 *	for per-vif configuration; doesn't list the ones that are generic
 *	(%NL80211_TID_CONFIG_ATTR_TIDS, %NL80211_TID_CONFIG_ATTR_OVERRIDE).
 * @NL80211_TID_CONFIG_ATTR_PEER_SUPP: same as the previous per-vif one, but
 *	per peer instead.
 * @NL80211_TID_CONFIG_ATTR_OVERRIDE: flag attribue, if no peer
 *	is selected, if set indicates that the new configuration overrides
 *	all previous peer configurations, otherwise previous peer specific
@@ -4758,13 +4768,16 @@ enum nl80211_tid_config {
 *	it will reset particular TID configuration of that peer and it will
 *	not accept other TID config attributes along with peer.
 * @NL80211_TID_CONFIG_ATTR_TIDS: a bitmask value of TIDs (bit 0 to 7)
 *	Its type is u8.
 *	Its type is u16.
 * @NL80211_TID_CONFIG_ATTR_NOACK: Configure ack policy for the TID.
 *	specified in %NL80211_TID_CONFIG_ATTR_TID. see %enum nl80211_tid_config.
 *	Its type is u8.
 */
enum nl80211_tid_config_attr {
	__NL80211_TID_CONFIG_ATTR_INVALID,
	NL80211_TID_CONFIG_ATTR_PAD,
	NL80211_TID_CONFIG_ATTR_VIF_SUPP,
	NL80211_TID_CONFIG_ATTR_PEER_SUPP,
	NL80211_TID_CONFIG_ATTR_OVERRIDE,
	NL80211_TID_CONFIG_ATTR_TIDS,
	NL80211_TID_CONFIG_ATTR_NOACK,
@@ -5588,10 +5601,6 @@ enum nl80211_feature_flags {
 * @NL80211_EXT_FEATURE_VLAN_OFFLOAD: The driver supports a single netdev
 *	with VLAN tagged frames and separate VLAN-specific netdevs added using
 *	vconfig similarly to the Ethernet case.
 * @NL80211_EXT_FEATURE_PER_TID_NOACK_CONFIG: Driver supports per TID NoAck
 *	policy functionality.
 * @NL80211_EXT_FEATURE_PER_STA_NOACK_CONFIG: Driver supports STA specific NoAck
 *	policy functionality.
 *
 * @NL80211_EXT_FEATURE_BEACON_PROTECTION: The driver supports Beacon protection
 *	and can receive key configuration for BIGTK using key indexes 6 and 7.
@@ -5644,8 +5653,6 @@ enum nl80211_ext_feature_index {
	NL80211_EXT_FEATURE_VLAN_OFFLOAD,
	NL80211_EXT_FEATURE_AQL,
	NL80211_EXT_FEATURE_BEACON_PROTECTION,
	NL80211_EXT_FEATURE_PER_TID_NOACK_CONFIG,
	NL80211_EXT_FEATURE_PER_STA_NOACK_CONFIG,

	/* add new features before the definition below */
	NUM_NL80211_EXT_FEATURES,
+56 −43
Original line number Diff line number Diff line
@@ -330,8 +330,10 @@ he_bss_color_policy[NL80211_HE_BSS_COLOR_ATTR_MAX + 1] = {

static const struct nla_policy
nl80211_tid_config_attr_policy[NL80211_TID_CONFIG_ATTR_MAX + 1] = {
	[NL80211_TID_CONFIG_ATTR_VIF_SUPP] = { .type = NLA_U64 },
	[NL80211_TID_CONFIG_ATTR_PEER_SUPP] = { .type = NLA_U64 },
	[NL80211_TID_CONFIG_ATTR_OVERRIDE] = { .type = NLA_FLAG },
	[NL80211_TID_CONFIG_ATTR_TIDS] = { .type = NLA_U8 },
	[NL80211_TID_CONFIG_ATTR_TIDS] = NLA_POLICY_RANGE(NLA_U16, 1, 0xff),
	[NL80211_TID_CONFIG_ATTR_NOACK] =
			NLA_POLICY_MAX(NLA_U8, NL80211_TID_CONFIG_DISABLE),
};
@@ -1957,6 +1959,40 @@ nl80211_put_iftype_akm_suites(struct cfg80211_registered_device *rdev,
	return 0;
}

static int
nl80211_put_tid_config_support(struct cfg80211_registered_device *rdev,
			       struct sk_buff *msg)
{
	struct nlattr *supp;

	if (!rdev->wiphy.tid_config_support.vif &&
	    !rdev->wiphy.tid_config_support.peer)
		return 0;

	supp = nla_nest_start(msg, NL80211_ATTR_TID_CONFIG);
	if (!supp)
		return -ENOSPC;

	if (rdev->wiphy.tid_config_support.vif &&
	    nla_put_u64_64bit(msg, NL80211_TID_CONFIG_ATTR_VIF_SUPP,
			      rdev->wiphy.tid_config_support.vif,
			      NL80211_TID_CONFIG_ATTR_PAD))
		goto fail;

	if (rdev->wiphy.tid_config_support.peer &&
	    nla_put_u64_64bit(msg, NL80211_TID_CONFIG_ATTR_PEER_SUPP,
			      rdev->wiphy.tid_config_support.peer,
			      NL80211_TID_CONFIG_ATTR_PAD))
		goto fail;

	nla_nest_end(msg, supp);

	return 0;
fail:
	nla_nest_cancel(msg, supp);
	return -ENOBUFS;
}

struct nl80211_dump_wiphy_state {
	s64 filter_wiphy;
	long start;
@@ -2518,6 +2554,9 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
		if (nl80211_put_iftype_akm_suites(rdev, msg))
			goto nla_put_failure;

		if (nl80211_put_tid_config_support(rdev, msg))
			goto nla_put_failure;

		/* done */
		state->split_start = 0;
		break;
@@ -13946,44 +13985,13 @@ static int nl80211_probe_mesh_link(struct sk_buff *skb, struct genl_info *info)
	return rdev_probe_mesh_link(rdev, dev, dest, buf, len);
}

static int
__nl80211_check_tid_conf_support(struct cfg80211_registered_device *rdev,
				 struct netlink_ext_ack *extack,
				 const u8 *peer, struct nlattr *attrs[],
				 struct ieee80211_tid_cfg *tid_conf,
				 enum nl80211_tid_config_attr attr,
				 enum nl80211_ext_feature_index per_tid_config,
				 enum nl80211_ext_feature_index per_sta_config)
{
	if (!wiphy_ext_feature_isset(&rdev->wiphy, per_tid_config)) {
		NL_SET_ERR_MSG_ATTR(extack, attrs[attr],
				    "TID specific configuration not supported");
		return -ENOTSUPP;
	}

	if (peer && !wiphy_ext_feature_isset(&rdev->wiphy, per_sta_config)) {
		NL_SET_ERR_MSG_ATTR(extack, attrs[attr],
				    "peer specific TID configuration not supported");
		return -ENOTSUPP;
	}

	tid_conf->tid_conf_mask |= BIT(attr);
	return 0;
}

#define nl80211_check_tid_config_support(rdev, extack, peer, attrs, tid_conf, \
					 conf)	\
	__nl80211_check_tid_conf_support(rdev, extack, peer, attrs, tid_conf, \
				 NL80211_TID_CONFIG_ATTR_##conf,	\
				 NL80211_EXT_FEATURE_PER_TID_##conf##_CONFIG, \
				 NL80211_EXT_FEATURE_PER_STA_##conf##_CONFIG)

static int parse_tid_conf(struct cfg80211_registered_device *rdev,
			  struct nlattr *attrs[], struct net_device *dev,
			  struct ieee80211_tid_cfg *tid_conf,
			  struct cfg80211_tid_cfg *tid_conf,
			  struct genl_info *info, const u8 *peer)
{
	struct netlink_ext_ack *extack = info->extack;
	u64 mask;
	int err;

	if (!attrs[NL80211_TID_CONFIG_ATTR_TIDS])
@@ -13991,12 +13999,12 @@ static int parse_tid_conf(struct cfg80211_registered_device *rdev,

	tid_conf->config_override =
			nla_get_flag(attrs[NL80211_TID_CONFIG_ATTR_OVERRIDE]);
	tid_conf->tid = nla_get_u8(attrs[NL80211_TID_CONFIG_ATTR_TIDS]);
	tid_conf->tids = nla_get_u16(attrs[NL80211_TID_CONFIG_ATTR_TIDS]);

	if (tid_conf->config_override) {
		if (rdev->ops->reset_tid_config) {
			err = rdev_reset_tid_config(rdev, dev, peer,
						    tid_conf->tid);
						    tid_conf->tids);
			/* If peer is there no other configuration will be
			 * allowed
			 */
@@ -14008,16 +14016,21 @@ static int parse_tid_conf(struct cfg80211_registered_device *rdev,
	}

	if (attrs[NL80211_TID_CONFIG_ATTR_NOACK]) {
		err = nl80211_check_tid_config_support(rdev, extack, peer,
						       attrs, tid_conf,
						       NOACK);
		if (err)
			return err;

		tid_conf->mask |= BIT(NL80211_TID_CONFIG_ATTR_NOACK);
		tid_conf->noack =
			nla_get_u8(attrs[NL80211_TID_CONFIG_ATTR_NOACK]);
	}

	if (peer)
		mask = rdev->wiphy.tid_config_support.peer;
	else
		mask = rdev->wiphy.tid_config_support.vif;

	if (tid_conf->mask & ~mask) {
		NL_SET_ERR_MSG(extack, "unsupported TID configuration");
		return -ENOTSUPP;
	}

	return 0;
}

@@ -14027,7 +14040,7 @@ static int nl80211_set_tid_config(struct sk_buff *skb,
	struct cfg80211_registered_device *rdev = info->user_ptr[0];
	struct nlattr *attrs[NL80211_TID_CONFIG_ATTR_MAX + 1];
	struct net_device *dev = info->user_ptr[1];
	struct ieee80211_tid_config *tid_config;
	struct cfg80211_tid_config *tid_config;
	struct nlattr *tid;
	int conf_idx = 0, rem_conf;
	int ret = -EINVAL;
+4 −4
Original line number Diff line number Diff line
@@ -1328,7 +1328,7 @@ rdev_probe_mesh_link(struct cfg80211_registered_device *rdev,

static inline int rdev_set_tid_config(struct cfg80211_registered_device *rdev,
				      struct net_device *dev,
				      struct ieee80211_tid_config *tid_conf)
				      struct cfg80211_tid_config *tid_conf)
{
	int ret;

@@ -1340,12 +1340,12 @@ static inline int rdev_set_tid_config(struct cfg80211_registered_device *rdev,

static inline int rdev_reset_tid_config(struct cfg80211_registered_device *rdev,
					struct net_device *dev, const u8 *peer,
					u8 tid)
					u8 tids)
{
	int ret;

	trace_rdev_reset_tid_config(&rdev->wiphy, dev, peer, tid);
	ret = rdev->ops->reset_tid_config(&rdev->wiphy, dev, peer, tid);
	trace_rdev_reset_tid_config(&rdev->wiphy, dev, peer, tids);
	ret = rdev->ops->reset_tid_config(&rdev->wiphy, dev, peer, tids);
	trace_rdev_return_int(&rdev->wiphy, ret);
	return ret;
}
+7 −7
Original line number Diff line number Diff line
@@ -3482,7 +3482,7 @@ TRACE_EVENT(rdev_probe_mesh_link,

TRACE_EVENT(rdev_set_tid_config,
	TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
		 struct ieee80211_tid_config *tid_conf),
		 struct cfg80211_tid_config *tid_conf),
	TP_ARGS(wiphy, netdev, tid_conf),
	TP_STRUCT__entry(
		WIPHY_ENTRY
@@ -3500,22 +3500,22 @@ TRACE_EVENT(rdev_set_tid_config,

TRACE_EVENT(rdev_reset_tid_config,
	TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
		 const u8 *peer, u8 tid),
	TP_ARGS(wiphy, netdev, peer, tid),
		 const u8 *peer, u8 tids),
	TP_ARGS(wiphy, netdev, peer, tids),
	TP_STRUCT__entry(
		WIPHY_ENTRY
		NETDEV_ENTRY
		MAC_ENTRY(peer)
		__field(u8, tid)
		__field(u8, tids)
	),
	TP_fast_assign(
		WIPHY_ASSIGN;
		NETDEV_ASSIGN;
		MAC_ASSIGN(peer, peer);
		__entry->tid = tid;
		__entry->tids = tids;
	),
	TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", peer: " MAC_PR_FMT ", tid: %u",
		  WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer), __entry->tid)
	TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", peer: " MAC_PR_FMT ", tids: 0x%x",
		  WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer), __entry->tids)
);
#endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */