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

Commit 7a59f8ca authored by Tamizh chelvam's avatar Tamizh chelvam Committed by Greg Kroah-Hartman
Browse files

BACKPORT: nl80211: Add NL command to support TID speicific configurations



Add the new NL80211_CMD_SET_TID_CONFIG command to support
data TID specific configuration. Per TID configuration is
passed in the nested NL80211_ATTR_TID_CONFIG attribute.

This patch adds support to configure per TID noack policy
through the NL80211_TID_CONFIG_ATTR_NOACK attribute.

Bug: 154782456
Signed-off-by: default avatarTamizh chelvam <tamizhr@codeaurora.org>
Link: https://lore.kernel.org/r/1579506687-18296-2-git-send-email-tamizhr@codeaurora.org


Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Change-Id: Ia2e2c125aaba64571453838baac052014e386cd6
(cherry picked from commit 77f576deaa393b54a0f2ca8ab1ab5b2d3c6b971b)
Signed-off-by: default avatarVamsi Krishna <vamsin@codeaurora.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 02d9f7e3
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -611,6 +611,38 @@ 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
 * @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
 * @noack: noack configuration value for the TID
 */
struct ieee80211_tid_cfg {
	bool config_override;
	u8 tid;
	u32 tid_conf_mask;
	enum nl80211_tid_config noack;
};

/**
 * struct ieee80211_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 {
	const u8 *peer;
	u32 n_tid_conf;
	struct ieee80211_tid_cfg tid_conf[];
};

/**
 * cfg80211_get_chandef_type - return old channel type from chandef
 * @chandef: the channel definition
@@ -3649,6 +3681,10 @@ struct cfg80211_update_owe_info {
 *
 * @probe_mesh_link: Probe direct Mesh peer's link quality by sending data frame
 *	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.
 */
struct cfg80211_ops {
	int	(*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -3972,6 +4008,10 @@ struct cfg80211_ops {
				   struct cfg80211_update_owe_info *owe_info);
	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);
	int	(*reset_tid_config)(struct wiphy *wiphy, struct net_device *dev,
				    const u8 *peer, u8 tid);
};

/*
+71 −0
Original line number Diff line number Diff line
@@ -264,6 +264,27 @@
 * %NL80211_ATTR_VLAN_ID.
 */

/**
 * 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
 * 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
 * after disconnection/roaming, and this configuration will be cleared when
 * the interface goes down.
 */

/**
 * enum nl80211_commands - supported nl80211 commands
 *
@@ -1117,6 +1138,9 @@
 *	peer MAC address and %NL80211_ATTR_FRAME is used to specify the frame
 *	content. The frame is ethernet data.
 *
 * @NL80211_CMD_SET_TID_CONFIG: Data frame TID specific configuration
 *	is passed using %NL80211_ATTR_TID_CONFIG attribute.
 *
 * @NL80211_CMD_MAX: highest used command number
 * @__NL80211_CMD_AFTER_LAST: internal use
 */
@@ -1341,6 +1365,8 @@ enum nl80211_commands {

	NL80211_CMD_PROBE_MESH_LINK,

	NL80211_CMD_SET_TID_CONFIG,

	/* add new commands above here */

	/* used to define NL80211_CMD_MAX below */
@@ -2401,6 +2427,9 @@ enum nl80211_commands {
 *	%NL80211_ATTR_AKM_SUITES are default capabilities if AKM suites not
 *	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.
 *
 * @NUM_NL80211_ATTR: total number of nl80211_attrs available
 * @NL80211_ATTR_MAX: highest attribute number currently defined
 * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2869,6 +2898,8 @@ enum nl80211_attrs {

	NL80211_ATTR_IFTYPE_AKM_SUITES,

	NL80211_ATTR_TID_CONFIG,

	/* add attributes here, update the policy in nl80211.c */

	__NL80211_ATTR_AFTER_LAST,
@@ -4709,6 +4740,40 @@ enum nl80211_tx_power_setting {
	NL80211_TX_POWER_FIXED,
};

/**
 * enum nl80211_tid_config - TID config state
 * @NL80211_TID_CONFIG_ENABLE: Enable config for the TID
 * @NL80211_TID_CONFIG_DISABLE: Disable config for the TID
 */
enum nl80211_tid_config {
	NL80211_TID_CONFIG_ENABLE,
	NL80211_TID_CONFIG_DISABLE,
};

/* enum nl80211_tid_config_attr - TID specific configuration.
 * @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
 *	configurations should be left untouched. If peer is selected then
 *	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.
 * @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_OVERRIDE,
	NL80211_TID_CONFIG_ATTR_TIDS,
	NL80211_TID_CONFIG_ATTR_NOACK,

	/* keep last */
	__NL80211_TID_CONFIG_ATTR_AFTER_LAST,
	NL80211_TID_CONFIG_ATTR_MAX = __NL80211_TID_CONFIG_ATTR_AFTER_LAST - 1
};

/**
 * enum nl80211_packet_pattern_attr - packet pattern attribute
 * @__NL80211_PKTPAT_INVALID: invalid number for nested attribute
@@ -5523,6 +5588,10 @@ 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.
@@ -5575,6 +5644,8 @@ 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,
+148 −0
Original line number Diff line number Diff line
@@ -328,6 +328,14 @@ he_bss_color_policy[NL80211_HE_BSS_COLOR_ATTR_MAX + 1] = {
	[NL80211_HE_BSS_COLOR_ATTR_PARTIAL] = { .type = NLA_FLAG },
};

static const struct nla_policy
nl80211_tid_config_attr_policy[NL80211_TID_CONFIG_ATTR_MAX + 1] = {
	[NL80211_TID_CONFIG_ATTR_OVERRIDE] = { .type = NLA_FLAG },
	[NL80211_TID_CONFIG_ATTR_TIDS] = { .type = NLA_U8 },
	[NL80211_TID_CONFIG_ATTR_NOACK] =
			NLA_POLICY_MAX(NLA_U8, NL80211_TID_CONFIG_DISABLE),
};

const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
	[0] = { .strict_start_type = NL80211_ATTR_HE_OBSS_PD },
	[NL80211_ATTR_WIPHY] = { .type = NLA_U32 },
@@ -637,6 +645,8 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
	[NL80211_ATTR_HE_OBSS_PD] = NLA_POLICY_NESTED(he_obss_pd_policy),
	[NL80211_ATTR_VLAN_ID] = NLA_POLICY_RANGE(NLA_U16, 1, VLAN_N_VID - 2),
	[NL80211_ATTR_HE_BSS_COLOR] = NLA_POLICY_NESTED(he_bss_color_policy),
	[NL80211_ATTR_TID_CONFIG] =
		NLA_POLICY_NESTED_ARRAY(nl80211_tid_config_attr_policy),
};

/* policy for the key attributes */
@@ -13936,6 +13946,137 @@ 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 genl_info *info, const u8 *peer)
{
	struct netlink_ext_ack *extack = info->extack;
	int err;

	if (!attrs[NL80211_TID_CONFIG_ATTR_TIDS])
		return -EINVAL;

	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]);

	if (tid_conf->config_override) {
		if (rdev->ops->reset_tid_config) {
			err = rdev_reset_tid_config(rdev, dev, peer,
						    tid_conf->tid);
			/* If peer is there no other configuration will be
			 * allowed
			 */
			if (err || peer)
				return err;
		} else {
			return -EINVAL;
		}
	}

	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->noack =
			nla_get_u8(attrs[NL80211_TID_CONFIG_ATTR_NOACK]);
	}

	return 0;
}

static int nl80211_set_tid_config(struct sk_buff *skb,
				  struct genl_info *info)
{
	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 nlattr *tid;
	int conf_idx = 0, rem_conf;
	int ret = -EINVAL;
	u32 num_conf = 0;

	if (!info->attrs[NL80211_ATTR_TID_CONFIG])
		return -EINVAL;

	if (!rdev->ops->set_tid_config)
		return -EOPNOTSUPP;

	nla_for_each_nested(tid, info->attrs[NL80211_ATTR_TID_CONFIG],
			    rem_conf)
		num_conf++;

	tid_config = kzalloc(struct_size(tid_config, tid_conf, num_conf),
			     GFP_KERNEL);
	if (!tid_config)
		return -ENOMEM;

	tid_config->n_tid_conf = num_conf;

	if (info->attrs[NL80211_ATTR_MAC])
		tid_config->peer = nla_data(info->attrs[NL80211_ATTR_MAC]);

	nla_for_each_nested(tid, info->attrs[NL80211_ATTR_TID_CONFIG],
			    rem_conf) {
		ret = nla_parse_nested(attrs, NL80211_TID_CONFIG_ATTR_MAX,
				       tid, NULL, NULL);

		if (ret)
			goto bad_tid_conf;

		ret = parse_tid_conf(rdev, attrs, dev,
				     &tid_config->tid_conf[conf_idx],
				     info, tid_config->peer);
		if (ret)
			goto bad_tid_conf;

		conf_idx++;
	}

	ret = rdev_set_tid_config(rdev, dev, tid_config);

bad_tid_conf:
	kfree(tid_config);
	return ret;
}

#define NL80211_FLAG_NEED_WIPHY		0x01
#define NL80211_FLAG_NEED_NETDEV	0x02
#define NL80211_FLAG_NEED_RTNL		0x04
@@ -14890,6 +15031,13 @@ static const struct genl_ops nl80211_ops[] = {
		.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
				  NL80211_FLAG_NEED_RTNL,
	},
	{
		.cmd = NL80211_CMD_SET_TID_CONFIG,
		.doit = nl80211_set_tid_config,
		.flags = GENL_UNS_ADMIN_PERM,
		.internal_flags = NL80211_FLAG_NEED_NETDEV |
				  NL80211_FLAG_NEED_RTNL,
	},
};

static struct genl_family nl80211_fam __ro_after_init = {
+24 −0
Original line number Diff line number Diff line
@@ -1326,4 +1326,28 @@ rdev_probe_mesh_link(struct cfg80211_registered_device *rdev,
	return ret;
}

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

	trace_rdev_set_tid_config(&rdev->wiphy, dev, tid_conf);
	ret = rdev->ops->set_tid_config(&rdev->wiphy, dev, tid_conf);
	trace_rdev_return_int(&rdev->wiphy, ret);
	return ret;
}

static inline int rdev_reset_tid_config(struct cfg80211_registered_device *rdev,
					struct net_device *dev, const u8 *peer,
					u8 tid)
{
	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_return_int(&rdev->wiphy, ret);
	return ret;
}

#endif /* __CFG80211_RDEV_OPS */
+37 −0
Original line number Diff line number Diff line
@@ -3480,6 +3480,43 @@ TRACE_EVENT(rdev_probe_mesh_link,
		  WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(dest))
);

TRACE_EVENT(rdev_set_tid_config,
	TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
		 struct ieee80211_tid_config *tid_conf),
	TP_ARGS(wiphy, netdev, tid_conf),
	TP_STRUCT__entry(
		WIPHY_ENTRY
		NETDEV_ENTRY
		MAC_ENTRY(peer)
	),
	TP_fast_assign(
		WIPHY_ASSIGN;
		NETDEV_ASSIGN;
		MAC_ASSIGN(peer, tid_conf->peer);
	),
	TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", peer: " MAC_PR_FMT,
		  WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer))
);

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),
	TP_STRUCT__entry(
		WIPHY_ENTRY
		NETDEV_ENTRY
		MAC_ENTRY(peer)
		__field(u8, tid)
	),
	TP_fast_assign(
		WIPHY_ASSIGN;
		NETDEV_ASSIGN;
		MAC_ASSIGN(peer, peer);
		__entry->tid = tid;
	),
	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)
);
#endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */

#undef TRACE_INCLUDE_PATH