diff mbox

hostapd: Use max tx power from regulatory domain

Message ID 1380718198-2331-1-git-send-email-helmut.schaa@googlemail.com
State Accepted
Commit 6651f1f9f19de900474895396c8abfb8d97bff94
Headers show

Commit Message

Helmut Schaa Oct. 2, 2013, 12:49 p.m. UTC
Previously the 11d IE contained the max tx power the local hardware was
capable of. Change this to just use the regulatory limit.

Signed-hostap: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
---
 src/drivers/driver.h         |    2 +-
 src/drivers/driver_nl80211.c |   36 ++++++++++++++++++++++++++++++++----
 2 files changed, 33 insertions(+), 5 deletions(-)

Comments

Kalle Valo Oct. 6, 2013, 7:04 a.m. UTC | #1
Helmut Schaa <helmut.schaa@googlemail.com> writes:

> Previously the 11d IE contained the max tx power the local hardware was
> capable of. Change this to just use the regulatory limit.
>
> Signed-hostap: Helmut Schaa <helmut.schaa@googlemail.com>
> Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>

Isn't the S-o-b line useless?
Helmut Schaa Oct. 6, 2013, 7:42 a.m. UTC | #2
Kalle Valo <kvalo@adurom.com> schrieb:
>Helmut Schaa <helmut.schaa@googlemail.com> writes:
>
>> Previously the 11d IE contained the max tx power the local hardware
>was
>> capable of. Change this to just use the regulatory limit.
>>
>> Signed-hostap: Helmut Schaa <helmut.schaa@googlemail.com>
>> Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
>
>Isn't the S-o-b line useless?

Actually, yes, it is. Should not hurt however :-)
Jouni Malinen Oct. 27, 2013, 4:56 p.m. UTC | #3
On Wed, Oct 02, 2013 at 02:49:58PM +0200, Helmut Schaa wrote:
> Previously the 11d IE contained the max tx power the local hardware was
> capable of. Change this to just use the regulatory limit.

Thanks, applied.
diff mbox

Patch

diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index ad62c47..141a1f8 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -57,7 +57,7 @@  struct hostapd_channel_data {
 	int flag;
 
 	/**
-	 * max_tx_power - Maximum transmit power in dBm
+	 * max_tx_power - Regulatory transmit power limit in dBm
 	 */
 	u8 max_tx_power;
 
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index b62c5ec..2da34fd 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -5564,10 +5564,6 @@  static void phy_info_freq(struct hostapd_hw_modes *mode,
 	if (tb_freq[NL80211_FREQUENCY_ATTR_RADAR])
 		chan->flag |= HOSTAPD_CHAN_RADAR;
 
-	if (tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER] &&
-	    !tb_freq[NL80211_FREQUENCY_ATTR_DISABLED])
-		chan->max_tx_power = nla_get_u32(
-			tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER]) / 100;
 	if (tb_freq[NL80211_FREQUENCY_ATTR_DFS_STATE]) {
 		enum nl80211_dfs_state state =
 			nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_DFS_STATE]);
@@ -5890,6 +5886,37 @@  static void nl80211_set_ht40_mode_sec(struct hostapd_hw_modes *mode, int start,
 }
 
 
+static void nl80211_reg_rule_max_eirp(struct nlattr *tb[],
+				      struct phy_info_arg *results)
+{
+	u32 start, end, max_eirp;
+	u16 m;
+
+	if (tb[NL80211_ATTR_FREQ_RANGE_START] == NULL ||
+	    tb[NL80211_ATTR_FREQ_RANGE_END] == NULL ||
+	    tb[NL80211_ATTR_POWER_RULE_MAX_EIRP] == NULL)
+		return;
+
+	start = nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_START]) / 1000;
+	end = nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_END]) / 1000;
+	max_eirp = nla_get_u32(tb[NL80211_ATTR_POWER_RULE_MAX_EIRP]) / 100;
+
+	wpa_printf(MSG_DEBUG, "nl80211: %u-%u @ %u mBm",
+		   start, end, max_eirp);
+
+	for (m = 0; m < *results->num_modes; m++) {
+		int c;
+		struct hostapd_hw_modes *mode = &results->modes[m];
+
+		for (c = 0; c < mode->num_channels; c++) {
+			struct hostapd_channel_data *chan = &mode->channels[c];
+			if (chan->freq - 10 >= start && chan->freq + 10 <= end)
+				chan->max_tx_power = max_eirp;
+		}
+	}
+}
+
+
 static void nl80211_reg_rule_ht40(struct nlattr *tb[],
 				  struct phy_info_arg *results)
 {
@@ -5980,6 +6007,7 @@  static int nl80211_get_reg(struct nl_msg *msg, void *arg)
 		nla_parse(tb_rule, NL80211_FREQUENCY_ATTR_MAX,
 			  nla_data(nl_rule), nla_len(nl_rule), reg_policy);
 		nl80211_reg_rule_ht40(tb_rule, results);
+		nl80211_reg_rule_max_eirp(tb_rule, results);
 	}
 
 	nla_for_each_nested(nl_rule, tb_msg[NL80211_ATTR_REG_RULES], rem_rule)