Skip to contentSkip to conversation

add common API to configure SAR

PATCH Superseded Carl Huang 3 participants 9 messages Nov 6, 2020 – Nov 20, 2020

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Carl Huang

author
#0 lore raw

cover add common API to configure SAR

This patchset is to add common API to configure SAR. The mechanism is wlan driver registers sar capability to wiphy and userspace queries it. Userspace then sets power limiation to wlan driver.

Carl Huang (3):
nl80211: add common API to configure SAR power limitations.
mac80211: add ieee80211_set_sar_specs
ath10k: allow dynamic SAR power limits via common API

 drivers/net/wireless/ath/ath10k/core.c |  16 +++
 drivers/net/wireless/ath/ath10k/core.h |   3 +
 drivers/net/wireless/ath/ath10k/hw.h   |   2 +
 drivers/net/wireless/ath/ath10k/mac.c  | 221 ++++++++++++++++++++++++---------
 include/net/cfg80211.h                 |  51 ++++++++
 include/net/mac80211.h                 |   2 +
 include/uapi/linux/nl80211.h           | 101 +++++++++++++++
 net/mac80211/cfg.c                     |  12 ++
 net/wireless/nl80211.c                 | 150 ++++++++++++++++++++++
 net/wireless/rdev-ops.h                |  12 ++
 net/wireless/trace.h                   |  19 +++
 11 files changed, 530 insertions(+), 59 deletions(-)
Signature · 7 lines
2.7.4


_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
author
#1 lore raw

PATCH 1/3 nl80211: add common API to configure SAR power limitations.

NL80211_CMD_SET_SAR_SPECS is added to configure SAR from user space. NL80211_ATTR_SAR_SPEC is used to pass the SAR power specification when used with NL80211_CMD_SET_SAR_SPECS.

Wireless driver needs to register SAR type, supported frequency ranges to wiphy, so user space can query it. The index in frequency range is used to specify which sub band the power limitation applies to. The SAR type is for compatibility, so later other SAR mechanism can be implemented without breaking the user space SAR applications.

Normal process is user space quries the SAR capability, and gets the index of supported frequency ranges and associates the power limitation with this index and sends to kernel.

Here is an example of message send to kernel:
8c 00 00 00 08 00 01 00 00 00 00 00 38 00 26 81
08 00 01 00 00 00 00 00 2c 00 02 80 14 00 00 80
05 00 02 00 00 00 00 00 05 00 01 00 38 00 00 00
14 00 01 80 05 00 02 00 01 00 00 00 05 00 01 00
48 00 00 00

NL80211_CMD_SET_SAR_SPECS:  0x8c
NL80211_ATTR_WIPHY:     0x01(phy idx is 0)
NL80211_ATTR_SAR_SPEC:  0x8126 (NLA_NESTED)
NL80211_SAR_ATTR_TYPE:  0x00 (NL80211_SAR_TYPE_POWER)
NL80211_SAR_ATTR_SPECS: 0x8002 (NLA_NESTED)
freq range 0 power: 0x38 in 0.25dbm unit (14dbm)
freq range 1 power: 0x48 in 0.25dbm unit (18dbm)
---
 include/net/cfg80211.h       |  51 +++++++++++++++
 include/uapi/linux/nl80211.h | 101 +++++++++++++++++++++++++++++
 net/wireless/nl80211.c       | 150 +++++++++++++++++++++++++++++++++++++++++++
 net/wireless/rdev-ops.h      |  12 ++++
 net/wireless/trace.h         |  19 ++++++
 5 files changed, 333 insertions(+)
include/net/cfg80211.h +51 -0
index c9bce9b..07e44d5 100644
@@ -1663,6 +1663,54 @@ struct station_info {
 	u8 connected_to_as;
 };
 
+/**
+ * struct cfg80211_sar_sub_specs - sub specs limit
+ * @power: power limitation in 0.25dbm
+ * @freq_range_index: index the power limitation applies to
+ */
+struct cfg80211_sar_sub_specs {
+	u8 power;
+	u8 freq_range_index;
+};
+
+/**
+ * struct cfg80211_sar_specs - sar limit specs
+ * @type: it's set with power in 0.25dbm or other types
+ * @num_sub_specs: number of sar sub specs
+ * @sub_specs: memory to hold the sar sub specs
+ */
+struct cfg80211_sar_specs {
+	enum nl80211_sar_type type;
+	u16 num_sub_specs;
+	struct cfg80211_sar_sub_specs sub_specs[];
+};
+
+
+/**
+ * @struct cfg80211_sar_chan_ranges - sar frequency ranges
+ * @start_freq:  start range edge frequency
+ * @end_freq:    end range edge frequency
+ */
+struct cfg80211_sar_freq_ranges {
+	u32 start_freq;
+	u32 end_freq;
+};
+
+/**
+ * struct cfg80211_sar_capa - sar limit capability
+ * @type: it's set via power in 0.25dbm or other types
+ * @num_freq_ranges: number of frequency ranges
+ * @freq_ranges: memory to hold the freq ranges.
+ *
+ * Note: WLAN driver may append new ranges or split an existing
+ * range to small ones and then append them.
+ */
+struct cfg80211_sar_capa {
+	enum nl80211_sar_type type;
+	u8 num_freq_ranges;
+	const struct cfg80211_sar_freq_ranges *freq_ranges;
+};
+
 #if IS_ENABLED(CONFIG_CFG80211)
 /**
  * cfg80211_get_station - retrieve information about a given station
@@ -4153,6 +4201,7 @@ struct cfg80211_ops {
 				  struct cfg80211_tid_config *tid_conf);
 	int	(*reset_tid_config)(struct wiphy *wiphy, struct net_device *dev,
 				    const u8 *peer, u8 tids);
+	int	(*set_sar_specs)(struct wiphy *wiphy, struct cfg80211_sar_specs *sar);
 };
 
 /*
@@ -4919,6 +4968,8 @@ struct wiphy {
 
 	u8 max_data_retry_count;
 
+	const struct cfg80211_sar_capa *sar_capa;
+
 	char priv[] __aligned(NETDEV_ALIGN);
 };
 
include/uapi/linux/nl80211.h +101 -0

129 lines not on this page · raw message

net/wireless/nl80211.c +150 -0

192 lines not on this page · raw message

net/wireless/rdev-ops.h +12 -0
index 950d574..d9931c5 100644
@@ -1356,4 +1356,16 @@ static inline int rdev_reset_tid_config(struct cfg80211_registered_device *rdev,
 	return ret;
 }
 
+static inline int rdev_set_sar_specs(struct cfg80211_registered_device *rdev,
+				     struct cfg80211_sar_specs *sar)
+{
+	int ret;
+
+	trace_rdev_set_sar_specs(&rdev->wiphy, sar);
+	ret = rdev->ops->set_sar_specs(&rdev->wiphy, sar);
+	trace_rdev_return_int(&rdev->wiphy, ret);
+
+	return ret;
+}
+
 #endif /* __CFG80211_RDEV_OPS */
net/wireless/trace.h +19 -0
index 6e218a0..116be64 100644
@@ -3547,6 +3547,25 @@ TRACE_EVENT(rdev_reset_tid_config,
 	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)
 );
+
+TRACE_EVENT(rdev_set_sar_specs,
+	TP_PROTO(struct wiphy *wiphy, struct cfg80211_sar_specs *sar),
+	TP_ARGS(wiphy, sar),
+	TP_STRUCT__entry(
+		WIPHY_ENTRY
+		__field(u16, type)
+		__field(u16, num)
+	),
+	TP_fast_assign(
+		WIPHY_ASSIGN;
+		__entry->type = sar->type;
+		__entry->num = sar->num_sub_specs;
+
+	),
+	TP_printk(WIPHY_PR_FMT ", Set type:%d, num_specs:%d",
+		  WIPHY_PR_ARG, __entry->type, __entry->num)
+);
+
 #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */
 
 #undef TRACE_INCLUDE_PATH
Signature · 7 lines
2.7.4


_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
maintainer
#2 lore raw

Re: [PATCH 1/3] nl80211: add common API to configure SAR power limitations.

Hi,

Looks pretty good. Some comments, mostly nits, below.

Quoted 2 lines

+/**
+ * nl80211_sar_attrs - Attributes for SAR spec

missing enum

Quoted 2 lines

+ *
+ * @NL80211_SAR_ATTR_TYPE: the SAR type and it's defined in %nl80211_sar_type.

better use &enum nl80211_sar_type for a link in docs

Quoted 6 lines

+ *
+ * @NL80211_SAR_ATTR_SPECS: Nested array of SAR power
+ * limit specifications. Each specification contains a set
+ * of %nl80211_sar_specs_attrs.
+ *
+ * For SET operation, it contains array of NL80211_SAR_ATTR_SPECS_POWER

some odd indent?

Usually we just use a single tab.

Quoted 2 lines

+/**
+ * nl80211_sar_specs_attrs - Attributes for SAR power limit specs

again, enum missing

Quoted 7 lines

+ *
+ * @NL80211_SAR_ATTR_SPECS_POWER: Required (u32)value to specify the actual
+ * power limit value in units of 0.25 dBm if type is
+ * NL80211_SAR_TYPE_POWER. (i.e., a value of 44 represents 11 dBm).
+ * 0 means userspace doesn't have SAR limitation on this associated range.
+ *
+ * @NL80211_SAR_ATTR_SPECS_RANGE_INDEX: Required (u32) value to specify the

Quoted 8 lines

+ * index of exported freq range table and the associated power limitation
+ * is applied to this range.
+ *
+ * Userspace isn't required to set all the ranges advertised by WLAN driver,
+ * and userspace can skip some certain ranges. These skipped ranges don't
+ * have SAR limitations, and these are same as setting the
+ * %NL80211_SAR_ATTR_SPECS_POWER to 0. But it's required to set at least one range,
+ * no matter the power limiation is 0 or not.

(typo - limitation)

Should "0" really be the magic value? Theoretically, 0 and even negative values are valid. Perhaps we should just use something big (0xffffffff) to indicate no limit, or just not have such a "no limitation" value because userspace can always set it to something very big that means no practical limitation anyway?

OK actually you have a U8 now so the high limit is 63.75dBm, but there's not really a good reason for that, since U32 takes the same space in netlink anyway.

And wait, I thought we agreed to remove the index? Now I'm confused.

And even if we do need the index, then perhaps we should use the (otherwise anyway ignored) nla_type() of the container, instead of an explicit inner attribute?

Quoted 6 lines

+ *
+ * Every SET operation overwrites previous SET operation.
+ *
+ * @NL80211_SAR_ATTR_SPECS_START_FREQ: Required (u32) value to specify the start
+ * frequency of this range edge when registering SAR capability to wiphy. It's
+ * not a channel center frequency. The unit is KHz.

"kHz" not "KHz", in a few places other than this too

net/wireless/nl80211.c nl80211_put_tid_config_support(struct cfg80211_registered_device *rdev, · line 2055

Quoted 6 lines
net/wireless/nl80211.c +6 -0
+static int
+nl80211_put_sar_specs(struct cfg80211_registered_device *rdev,
+		      struct sk_buff *msg)
+{
+	struct nlattr *sar_capa, *specs, *sub_freq_range;
+	u8  num_freq_ranges;

extra space?

net/wireless/nl80211.c nl80211_put_tid_config_support(struct cfg80211_registered_device *rdev, · line 2082

Quoted 8 lines
net/wireless/nl80211.c +8 -0
+	for (i = 0; i < num_freq_ranges; i++) {
+		sub_freq_range = nla_nest_start(msg, i + 1);
+
+		nla_put_u32(msg, NL80211_SAR_ATTR_SPECS_START_FREQ,
+			    rdev->wiphy.sar_capa->freq_ranges[i].start_freq);
+
+		nla_put_u32(msg, NL80211_SAR_ATTR_SPECS_END_FREQ,
+			    rdev->wiphy.sar_capa->freq_ranges[i].end_freq);

Need to check the return values of these three calls.

And an aside, unrelated to this particular code: Should we do some kind of validation that the ranges reported actually overlap all supported channels (taking 20 MHz bandwidth into account)?

net/wireless/nl80211.c static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb, · line 14563

Quoted 2 lines
net/wireless/nl80211.c +2 -0
+	nla_parse_nested(tb, NL80211_SAR_ATTR_MAX, info->attrs[NL80211_ATTR_SAR_SPEC],
+			 sar_policy, info->extack);

If you're not checking the return value then no point in passing a policy or extack :-)

And yes, it's already validated, so you don't have to do it again.

net/wireless/nl80211.c static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb, · line 14590

Quoted 9 lines
net/wireless/nl80211.c +9 -0
+	sar_spec->type = type;
+	specs = 0;
+	nla_for_each_nested(spec_list, tb[NL80211_SAR_ATTR_SPECS], rem) {
+		if (nla_parse(spec,
+			      NL80211_SAR_ATTR_SPECS_MAX,
+			      nla_data(spec_list),
+			      nla_len(spec_list),
+			      sar_specs_policy,
+			      NULL)) {

Similar here, don't really need to validate it since it's done by the policy.

net/wireless/nl80211.c static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb, · line 14598

Quoted 8 lines
net/wireless/nl80211.c +8 -0
+			err = -EINVAL;
+			goto error;
+		}
+
+		/* for power type, power value and index must be presented */
+		if ((!spec[NL80211_SAR_ATTR_SPECS_POWER] ||
+		     !spec[NL80211_SAR_ATTR_SPECS_RANGE_INDEX]) &&
+		    type == NL80211_SAR_TYPE_POWER) {

maybe "switch (type) {...}" or something and return -EINVAL also if it's a type not supported in the code yet, i.e. default case?

Otherwise we might add a type, and forget this pretty easily.

net/wireless/nl80211.c static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb, · line 14604

Quoted 6 lines
net/wireless/nl80211.c +6 -0
+			err = -EINVAL;
+			goto error;
+		}
+
+		power = nla_get_u8(spec[NL80211_SAR_ATTR_SPECS_POWER]);
+		sar_spec->sub_specs[specs].power = power;

and that probably should then be in a sub function or something also inside the particular type.

or maybe just all in a separate function? dunno. not really _necessary_, but the lines are getting kinda long already, and one more indentation level with the switch won't help ...

johannes

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k

author
#3 lore raw

Re: [PATCH 1/3] nl80211: add common API to configure SAR power limitations.

Quoted 4 lines · Johannes Berg

Hi,

Looks pretty good. Some comments, mostly nits, below.

Thank you for the comments, Johannes.

I don't understand below well, please help explain:

Quoted 8 lines

And even if we do need the index, then perhaps we should use the (otherwise anyway ignored) nla_type() of the container, instead of an explicit inner attribute?

Quoted 5 lines
Quoted 2 lines

+/**
+ * nl80211_sar_attrs - Attributes for SAR spec

missing enum

sure

Quoted 14 lines
Quoted 3 lines

+ *
+ * @NL80211_SAR_ATTR_TYPE: the SAR type and it's defined in %nl80211_sar_type.

better use &enum nl80211_sar_type for a link in docs

Quoted 7 lines

+ *
+ * @NL80211_SAR_ATTR_SPECS: Nested array of SAR power
+ * limit specifications. Each specification contains a set
+ * of %nl80211_sar_specs_attrs.
+ *
+ * For SET operation, it contains array of
NL80211_SAR_ATTR_SPECS_POWER

Quoted 4 lines

some odd indent?

Usually we just use a single tab.

sure

Quoted 36 lines
Quoted 2 lines

+/**
+ * nl80211_sar_specs_attrs - Attributes for SAR power limit specs

again, enum missing

Quoted 14 lines

+ *
+ * @NL80211_SAR_ATTR_SPECS_POWER: Required (u32)value to specify the actual
+ * power limit value in units of 0.25 dBm if type is
+ * NL80211_SAR_TYPE_POWER. (i.e., a value of 44 represents 11 dBm).
+ * 0 means userspace doesn't have SAR limitation on this associated
range.
+ *
+ * @NL80211_SAR_ATTR_SPECS_RANGE_INDEX: Required (u32) value to specify the
+ * index of exported freq range table and the associated power
limitation
+ * is applied to this range.
+ *

Quoted 8 lines

+ * Userspace isn't required to set all the ranges advertised by WLAN
driver,
+ * and userspace can skip some certain ranges. These skipped ranges
don't
+ * have SAR limitations, and these are same as setting the
+ * %NL80211_SAR_ATTR_SPECS_POWER to 0. But it's required to set at
least one range,
+ * no matter the power limiation is 0 or not.

(typo - limitation)

Should "0" really be the magic value? Theoretically, 0 and even negative values are valid. Perhaps we should just use something big (0xffffffff) to indicate no limit, or just not have such a "no limitation" value because userspace can always set it to something very big that means no practical limitation anyway?

Quoted 4 lines

OK actually you have a U8 now so the high limit is 63.75dBm, but there's not really a good reason for that, since U32 takes the same space in netlink anyway.

Looks 0 and negative value are not practical as it means <= 1mw, but I can use S32 instead.

Not sure if a magic value is needed? If it's needed, then perhaps 0x7fffffff is good for it?

Quoted 2 lines

And wait, I thought we agreed to remove the index? Now I'm confused.

Using index in SET operation doesn't add burden to userspace and kernel, but it provides some flexibility so userspace can skip some certain ranges.

Quoted 4 lines

And even if we do need the index, then perhaps we should use the (otherwise anyway ignored) nla_type() of the container, instead of an explicit inner attribute?

I don't understand what means here. Use nla_type for what?

Quoted 20 lines
Quoted 8 lines

+ *
+ * Every SET operation overwrites previous SET operation.
+ *
+ * @NL80211_SAR_ATTR_SPECS_START_FREQ: Required (u32) value to specify the start
+ * frequency of this range edge when registering SAR capability to
wiphy. It's
+ * not a channel center frequency. The unit is KHz.

"kHz" not "KHz", in a few places other than this too

net/wireless/nl80211.c nl80211_put_tid_config_support(struct cfg80211_registered_device *rdev, · line 2055

Quoted 6 lines
net/wireless/nl80211.c +6 -0
+static int
+nl80211_put_sar_specs(struct cfg80211_registered_device *rdev,
+		      struct sk_buff *msg)
+{
+	struct nlattr *sar_capa, *specs, *sub_freq_range;
+	u8  num_freq_ranges;

extra space?

Quoted 12 lines

net/wireless/nl80211.c nl80211_put_tid_config_support(struct cfg80211_registered_device *rdev, · line 2082

Quoted 8 lines
net/wireless/nl80211.c +8 -0
+	for (i = 0; i < num_freq_ranges; i++) {
+		sub_freq_range = nla_nest_start(msg, i + 1);
+
+		nla_put_u32(msg, NL80211_SAR_ATTR_SPECS_START_FREQ,
+			    rdev->wiphy.sar_capa->freq_ranges[i].start_freq);
+
+		nla_put_u32(msg, NL80211_SAR_ATTR_SPECS_END_FREQ,
+			    rdev->wiphy.sar_capa->freq_ranges[i].end_freq);

Need to check the return values of these three calls.

sure

Quoted 5 lines

And an aside, unrelated to this particular code: Should we do some kind of validation that the ranges reported actually overlap all supported channels (taking 20 MHz bandwidth into account)?

Quoted 9 lines

net/wireless/nl80211.c static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb, · line 14563

Quoted 3 lines
(quoted diff) +1 -0
+	nla_parse_nested(tb, NL80211_SAR_ATTR_MAX, 

info->attrs[NL80211_ATTR_SAR_SPEC],

net/wireless/nl80211.c +1 -0
+			 sar_policy, info->extack);

If you're not checking the return value then no point in passing a policy or extack :-)

And yes, it's already validated, so you don't have to do it again.

Yes, will use NULL instead of info->extack

Quoted 4 lines
Quoted 4 lines
net/wireless/nl80211.c +4 -0
+	sar_spec->type = type;
+	specs = 0;
+	nla_for_each_nested(spec_list, tb[NL80211_SAR_ATTR_SPECS], rem) {
+		if (nla_parse(spec,
Quoted 9 lines

net/wireless/nl80211.c static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb, · line 14590

Quoted 5 lines
net/wireless/nl80211.c +5 -0
+			      NL80211_SAR_ATTR_SPECS_MAX,
+			      nla_data(spec_list),
+			      nla_len(spec_list),
+			      sar_specs_policy,
+			      NULL)) {

Similar here, don't really need to validate it since it's done by the policy.

sure

Quoted 12 lines

net/wireless/nl80211.c static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb, · line 14598

Quoted 8 lines
net/wireless/nl80211.c +8 -0
+			err = -EINVAL;
+			goto error;
+		}
+
+		/* for power type, power value and index must be presented */
+		if ((!spec[NL80211_SAR_ATTR_SPECS_POWER] ||
+		     !spec[NL80211_SAR_ATTR_SPECS_RANGE_INDEX]) &&
+		    type == NL80211_SAR_TYPE_POWER) {

maybe "switch (type) {...}" or something and return -EINVAL also if it's a type not supported in the code yet, i.e. default case?

Quoted 2 lines

Otherwise we might add a type, and forget this pretty easily.

Good suggestion, will change to switch case.

Quoted 10 lines

net/wireless/nl80211.c static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb, · line 14604

Quoted 6 lines
net/wireless/nl80211.c +6 -0
+			err = -EINVAL;
+			goto error;
+		}
+
+		power = nla_get_u8(spec[NL80211_SAR_ATTR_SPECS_POWER]);
+		sar_spec->sub_specs[specs].power = power;

and that probably should then be in a sub function or something also inside the particular type.

Quoted 4 lines

or maybe just all in a separate function? dunno. not really _necessary_, but the lines are getting kinda long already, and one more indentation level with the switch won't help ...

I'll move this to a separate function.

Quoted 1 line

johannes

#4 lore raw

Re: [PATCH 1/3] nl80211: add common API to configure SAR power limitations.

Hi,

Johannes has some good comments, apart for that I have some nits.

Quoted 5 lines
Quoted 2 lines

And wait, I thought we agreed to remove the index? Now I'm confused.

Using index in SET operation doesn't add burden to userspace and kernel, but it provides some flexibility so userspace can skip some certain ranges.

I agree with Carl's comment, we do need the frequency index. If the frequency index is provided, then the order is not important which makes the data more clear or the set_sar_spec function needs to parse the frequency ranges (and ofcourse userspace has to populate that as well). If the frequency index is not provided, then the driver has to assume that the userspace is not making any error in mapping of the power and desired frequency.
Other reason is, might be a bit unlikely, but if in future there are new subbands, then it gives a flexibility to the userspace to explicitly provide the band for which it needs to set the power for.

Quoted 2 lines

+ * used with %NL80211_CMD_SET_SAR_SPECS. The message contains fileds
+ * of %nl80211_sar_attrs which specifies the sar type and related

typo: fileds .. you mean fields

-Abhishek

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k

author
#5 lore raw

Re: [PATCH 1/3] nl80211: add common API to configure SAR power limitations.

Quoted 20 lines · Abhishek Kumar

Hi,

Johannes has some good comments, apart for that I have some nits.

Quoted 5 lines
Quoted 2 lines

And wait, I thought we agreed to remove the index? Now I'm confused.

Using index in SET operation doesn't add burden to userspace and kernel, but it provides some flexibility so userspace can skip some certain ranges.

I agree with Carl's comment, we do need the frequency index. If the frequency index is provided, then the order is not important which makes the data more clear or the set_sar_spec function needs to parse the frequency ranges (and ofcourse userspace has to populate that as well). If the frequency index is not provided, then the driver has to assume that the userspace is not making any error in mapping of the power and desired frequency.
Other reason is, might be a bit unlikely, but if in future there are new subbands, then it gives a flexibility to the userspace to explicitly provide the band for which it needs to set the power for.

Quoted 6 lines
Quoted 3 lines

+ * used with %NL80211_CMD_SET_SAR_SPECS. The message contains
fileds
+ * of %nl80211_sar_attrs which specifies the sar type and related

typo: fileds .. you mean fields

I will fix all the spelling errors and send V2.

Quoted 4 lines

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k

author
#6 lore raw

PATCH 2/3 mac80211: add ieee80211_set_sar_specs

In reply to Carl Huang

This change registers ieee80211_set_sar_specs to
mac80211_config_ops, so cfg80211 can call it.

---
 include/net/mac80211.h |  2 ++
 net/mac80211/cfg.c     | 12 ++++++++++++
 2 files changed, 14 insertions(+)
include/net/mac80211.h +2 -0
index ec148b3..df758ee 100644
@@ -4125,6 +4125,8 @@ struct ieee80211_ops {
 	int (*reset_tid_config)(struct ieee80211_hw *hw,
 				struct ieee80211_vif *vif,
 				struct ieee80211_sta *sta, u8 tids);
+	int (*set_sar_specs)(struct ieee80211_hw *hw,
+			     const struct cfg80211_sar_specs *sar);
 };
 
 /**
net/mac80211/cfg.c +12 -0
index b4e39e3..cc74322 100644
@@ -3993,6 +3993,17 @@ static int ieee80211_reset_tid_config(struct wiphy *wiphy,
 	return ret;
 }
 
+static int ieee80211_set_sar_specs(struct wiphy *wiphy,
+				   struct cfg80211_sar_specs *sar)
+{
+	struct ieee80211_local *local = wiphy_priv(wiphy);
+
+	if (!local->ops->set_sar_specs)
+		return -EOPNOTSUPP;
+
+	return local->ops->set_sar_specs(&local->hw, sar);
+}
+
 const struct cfg80211_ops mac80211_config_ops = {
 	.add_virtual_intf = ieee80211_add_iface,
 	.del_virtual_intf = ieee80211_del_iface,
@@ -4096,4 +4107,5 @@ const struct cfg80211_ops mac80211_config_ops = {
 	.probe_mesh_link = ieee80211_probe_mesh_link,
 	.set_tid_config = ieee80211_set_tid_config,
 	.reset_tid_config = ieee80211_reset_tid_config,
+	.set_sar_specs = ieee80211_set_sar_specs,
 };
Signature · 7 lines
2.7.4


_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
author
#7 lore raw

PATCH 3/3 ath10k: allow dynamic SAR power limits via common API

In reply to Carl Huang

ath10k assigns ath10k_mac_set_sar_specs to ath10k_ops, and this function is called when user space application calls NL80211_CMD_SET_SAR_SPECS. ath10k also registers SAR type, and supported frequency ranges to wiphy so user space can query SAR capabilities.

This SAR power limitation is compared to regulatory txpower and selects the minimal one to set when station is connected. Otherwise, it delays until the station is connected. If the station is disconnected, it returns to regulatory txpower.

This feature is controlled by hw parameter: dynamic_sar_support.

Tested-on: QCA6174 hw3.2 PCI WLAN.RM.4.4.1-00110-QCARMSWP-1

---
 drivers/net/wireless/ath/ath10k/core.c |  16 +++
 drivers/net/wireless/ath/ath10k/core.h |   3 +
 drivers/net/wireless/ath/ath10k/hw.h   |   2 +
 drivers/net/wireless/ath/ath10k/mac.c  | 221 ++++++++++++++++++++++++---------
 4 files changed, 183 insertions(+), 59 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +16 -0
index 5f4e121..fe53ca9 100644
@@ -90,6 +90,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
 		.hw_filter_reset_required = true,
 		.fw_diag_ce_download = false,
 		.tx_stats_over_pktlog = true,
+		.dynamic_sar_support = false,
 	},
 	{
 		.id = QCA988X_HW_2_0_VERSION,
@@ -124,6 +125,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
 		.hw_filter_reset_required = true,
 		.fw_diag_ce_download = false,
 		.tx_stats_over_pktlog = true,
+		.dynamic_sar_support = false,
 	},
 	{
 		.id = QCA9887_HW_1_0_VERSION,
@@ -159,6 +161,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
 		.hw_filter_reset_required = true,
 		.fw_diag_ce_download = false,
 		.tx_stats_over_pktlog = false,
+		.dynamic_sar_support = false,
 	},
 	{
 		.id = QCA6174_HW_3_2_VERSION,
@@ -189,6 +192,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
 		.tx_stats_over_pktlog = false,
 		.bmi_large_size_download = true,
 		.supports_peer_stats_info = true,
+		.dynamic_sar_support = true,
 	},
 	{
 		.id = QCA6174_HW_2_1_VERSION,
@@ -223,6 +227,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
 		.hw_filter_reset_required = true,
 		.fw_diag_ce_download = false,
 		.tx_stats_over_pktlog = false,
+		.dynamic_sar_support = false,
 	},
 	{
 		.id = QCA6174_HW_2_1_VERSION,
@@ -257,6 +262,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
 		.hw_filter_reset_required = true,
 		.fw_diag_ce_download = false,
 		.tx_stats_over_pktlog = false,
+		.dynamic_sar_support = false,
 	},
 	{
 		.id = QCA6174_HW_3_0_VERSION,
@@ -291,6 +297,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
 		.hw_filter_reset_required = true,
 		.fw_diag_ce_download = false,
 		.tx_stats_over_pktlog = false,
+		.dynamic_sar_support = false,
 	},
 	{
 		.id = QCA6174_HW_3_2_VERSION,
@@ -329,6 +336,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
 		.fw_diag_ce_download = true,
 		.tx_stats_over_pktlog = false,
 		.supports_peer_stats_info = true,
+		.dynamic_sar_support = true,
 	},
 	{
 		.id = QCA99X0_HW_2_0_DEV_VERSION,
@@ -369,6 +377,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
 		.hw_filter_reset_required = true,
 		.fw_diag_ce_download = false,
 		.tx_stats_over_pktlog = false,
+		.dynamic_sar_support = false,
 	},
 	{
 		.id = QCA9984_HW_1_0_DEV_VERSION,
@@ -416,6 +425,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
 		.hw_filter_reset_required = true,
 		.fw_diag_ce_download = false,
 		.tx_stats_over_pktlog = false,
+		.dynamic_sar_support = false,
 	},
 	{
 		.id = QCA9888_HW_2_0_DEV_VERSION,
@@ -460,6 +470,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
 		.hw_filter_reset_required = true,
 		.fw_diag_ce_download = false,
 		.tx_stats_over_pktlog = false,
+		.dynamic_sar_support = false,
 	},
 	{
 		.id = QCA9377_HW_1_0_DEV_VERSION,
@@ -494,6 +505,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
 		.hw_filter_reset_required = true,
 		.fw_diag_ce_download = false,
 		.tx_stats_over_pktlog = false,
+		.dynamic_sar_support = false,
 	},
 	{
 		.id = QCA9377_HW_1_1_DEV_VERSION,
@@ -530,6 +542,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
 		.hw_filter_reset_required = true,
 		.fw_diag_ce_download = true,
 		.tx_stats_over_pktlog = false,
+		.dynamic_sar_support = false,
 	},
 	{
 		.id = QCA9377_HW_1_1_DEV_VERSION,
@@ -557,6 +570,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
 		.ast_skid_limit = 0x10,
 		.num_wds_entries = 0x20,
 		.uart_pin_workaround = true,
+		.dynamic_sar_support = false,
 	},
 	{
 		.id = QCA4019_HW_1_0_DEV_VERSION,
@@ -598,6 +612,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
 		.hw_filter_reset_required = true,
 		.fw_diag_ce_download = false,
 		.tx_stats_over_pktlog = false,
+		.dynamic_sar_support = false,
 	},
 	{
 		.id = WCN3990_HW_1_0_DEV_VERSION,
@@ -625,6 +640,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
 		.hw_filter_reset_required = false,
 		.fw_diag_ce_download = false,
 		.tx_stats_over_pktlog = false,
+		.dynamic_sar_support = true,
 	},
 };
 
drivers/net/wireless/ath/ath10k/core.h +3 -0
index 4cf5bd4..f90c34a 100644
@@ -1281,6 +1281,9 @@ struct ath10k {
 	bool coex_support;
 	int coex_gpio_pin;
 
+	u32 tx_power_2g_limit;
+	u32 tx_power_5g_limit;
+
 	/* must be last */
 	u8 drv_priv[] __aligned(sizeof(void *));
 };
drivers/net/wireless/ath/ath10k/hw.h +2 -0
index c6ded21..6b03c77 100644
@@ -623,6 +623,8 @@ struct ath10k_hw_params {
 
 	/* provides bitrates for sta_statistics using WMI_TLV_PEER_STATS_INFO_EVENTID */
 	bool supports_peer_stats_info;
+
+	bool dynamic_sar_support;
 };
 
 struct htt_rx_desc;
drivers/net/wireless/ath/ath10k/mac.c +162 -59

263 lines not on this page · raw message

Signature · 7 lines
2.7.4


_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
#8 lore raw

Re: [PATCH 3/3] ath10k: allow dynamic SAR power limits via common API

Hi,
This patch looks good to me, there is one small nit, If the maintainer can take care of it then probably we don't need a new rev.

drivers/net/wireless/ath/ath10k/core.c static const struct ath10k_hw_params ath10k_hw_params_list[] = { · line 340

Quoted 6 lines
drivers/net/wireless/ath/ath10k/core.c +1 -0
@@ -329,6 +336,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
                .fw_diag_ce_download = true,
                .tx_stats_over_pktlog = false,
                .supports_peer_stats_info = true,
+               .dynamic_sar_support = true,
        },

Orthogonal to this patch, other people might probably differ, I guess putting dynamic sar support as a firmware feature capability should be more scalable and then we don't need a structure table for each firmware. This might hold for other firmware features as well.

drivers/net/wireless/ath/ath10k/mac.c static int ath10k_mac_vif_recalc_txbf(struct ath10k *ar, · line 2930

Quoted 2 lines
drivers/net/wireless/ath/ath10k/mac.c +2 -0
+       ath10k_dbg(ar, ATH10K_DBG_MAC, "mac txpower 2g:%d 5g:%d\n",
+                  tx_power_2g, tx_power_5g);

just a nit: space after colon. This might throw a warning in checkpatch.pl

-Abhishek

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k