Search Linux Wireless

[PATCH v3 7/9] wifi: cfg80211: save 6 GHz power mode of the regulatory rules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently when user space demands the reg rules via NL80211_CMD_GET_REG
command, along with Power Spectral Denity (PSD) values, power mode
needs to be advertised since in 6 GHz AP beacon, Tx power envelope
should have PSD info as well which can be opted based on the power
mode. Similarly, via NL80211_CMD_SET_REG command, user space can try
to set regulatory rules and cfg80211 needs to store the incoming power
mode for the rule.

Add support for 6 GHz power mode advertisement in
NL80211_CMD_GET_REG command and saving 6 GHz power mode for reg rules
via NL80211_CMD_SET_REG command.

Signed-off-by: Aditya Kumar Singh <quic_adisi@xxxxxxxxxxx>
---
 include/uapi/linux/nl80211.h |  4 ++++
 net/wireless/nl80211.c       | 20 ++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index bff81489fa8a..aa0fcf98aab1 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -4358,6 +4358,8 @@ enum nl80211_reg_type {
  *	If not present or 0 default CAC time will be used.
  * @NL80211_ATTR_POWER_RULE_PSD: power spectral density (in dBm).
  *	This could be negative.
+ * @NL80211_ATTR_REG_POWER_MODE: the regulatory power mode for 6 GHz rules.
+ *	Referenced from &enum nl80211_regulatory_power_modes
  * @NL80211_REG_RULE_ATTR_MAX: highest regulatory rule attribute number
  *	currently defined
  * @__NL80211_REG_RULE_ATTR_AFTER_LAST: internal use
@@ -4377,6 +4379,8 @@ enum nl80211_reg_rule_attr {
 
 	NL80211_ATTR_POWER_RULE_PSD,
 
+	NL80211_ATTR_REG_POWER_MODE,
+
 	/* keep last */
 	__NL80211_REG_RULE_ATTR_AFTER_LAST,
 	NL80211_REG_RULE_ATTR_MAX = __NL80211_REG_RULE_ATTR_AFTER_LAST - 1
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 042035f26e9f..cdb26aac24d1 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -8481,6 +8481,13 @@ static int nl80211_put_regdom(const struct ieee80211_regdomain *regdom,
 				reg_rule->dfs_cac_ms))
 			goto nla_put_failure;
 
+		/* Put power mode as well if its a 6 GHz reg rule */
+		if (freq_range->start_freq_khz >= MHZ_TO_KHZ(5925) &&
+		    freq_range->end_freq_khz <= MHZ_TO_KHZ(7125) &&
+		    nla_put_u8(msg, NL80211_ATTR_REG_POWER_MODE,
+			       reg_rule->power_mode))
+			goto nla_put_failure;
+
 		if ((reg_rule->flags & NL80211_RRF_PSD) &&
 		    nla_put_s8(msg, NL80211_ATTR_POWER_RULE_PSD,
 			       reg_rule->psd))
@@ -8660,6 +8667,10 @@ static const struct nla_policy reg_rule_policy[NL80211_REG_RULE_ATTR_MAX + 1] =
 	[NL80211_ATTR_POWER_RULE_MAX_EIRP]	= { .type = NLA_U32 },
 	[NL80211_ATTR_DFS_CAC_TIME]		= { .type = NLA_U32 },
 	[NL80211_ATTR_POWER_RULE_PSD]		= { .type = NLA_S8 },
+	[NL80211_ATTR_REG_POWER_MODE]		=
+			  NLA_POLICY_RANGE(NLA_U8,
+					   NL80211_REG_PWR_MODE_AP_LPI,
+					   NL80211_REG_PWR_MODE_MAX - 1),
 };
 
 static int parse_reg_rule(struct nlattr *tb[],
@@ -8707,6 +8718,15 @@ static int parse_reg_rule(struct nlattr *tb[],
 		reg_rule->dfs_cac_ms =
 			nla_get_u32(tb[NL80211_ATTR_DFS_CAC_TIME]);
 
+	if (freq_range->start_freq_khz >= MHZ_TO_KHZ(5925) &&
+	    freq_range->end_freq_khz <= MHZ_TO_KHZ(7125)) {
+		if (!tb[NL80211_ATTR_REG_POWER_MODE])
+			return -EINVAL;
+
+		reg_rule->power_mode =
+			nla_get_u8(tb[NL80211_ATTR_REG_POWER_MODE]);
+	}
+
 	return 0;
 }
 
-- 
2.17.1




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux