From patchwork Wed Oct 2 12:49:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helmut Schaa X-Patchwork-Id: 279738 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id A7D362C0085 for ; Wed, 2 Oct 2013 22:50:22 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 3543A9D28F; Wed, 2 Oct 2013 08:50:18 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5eMFUlv1oGG1; Wed, 2 Oct 2013 08:50:17 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 2B9679D292; Wed, 2 Oct 2013 08:50:13 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 3AAD79D28F for ; Wed, 2 Oct 2013 08:50:11 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lLew+Yxe3tn4 for ; Wed, 2 Oct 2013 08:50:06 -0400 (EDT) Received: from mail-ee0-f41.google.com (mail-ee0-f41.google.com [74.125.83.41]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (not verified)) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 2732D9D28E for ; Wed, 2 Oct 2013 08:50:06 -0400 (EDT) Received: by mail-ee0-f41.google.com with SMTP id d17so373765eek.28 for ; Wed, 02 Oct 2013 05:50:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=p4Be77MLM6PbeL8UPVZJ9nr8uXC3HgHlpfVsXW7cRLM=; b=ajvEtfC8ocHiJpzXnlHgA7aNMjLoP241bROiKIh8a5nuOcy9cLRX/fzgyZ2nlX/KKd bT/Qsw+AB356k3B8CUy+6yHKtRJwetkJTTWdWwfKRv7yOnTCI0lL8euWwY2hURmWPbrf LMZzzfrYDAQQBBcA5Ffdxf1nHDBBX4m7fY2f+WXcxVHIE1RHizg3iVeQzG4VdvXQoomL iiv6/r2gy+JYrc7mMB906hNpT0rTGqqR2Sns3E3oq5c2ax5HyPWs3sTUbIqLSyiF6K2f byACNxpk+LJF31pq6mnusPknheP+GudnaGv0/NPXDFwx+qnpyr6/G9g+qo3+2FJ9XMSX wWyw== X-Received: by 10.14.1.132 with SMTP id 4mr1923861eed.84.1380718204850; Wed, 02 Oct 2013 05:50:04 -0700 (PDT) Received: from hschaa-desktop.site ([217.8.58.223]) by mx.google.com with ESMTPSA id j7sm3460729eeo.15.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Oct 2013 05:50:04 -0700 (PDT) From: Helmut Schaa To: hostap@lists.shmoo.com Subject: [PATCH] hostapd: Use max tx power from regulatory domain Date: Wed, 2 Oct 2013 14:49:58 +0200 Message-Id: <1380718198-2331-1-git-send-email-helmut.schaa@googlemail.com> X-Mailer: git-send-email 1.7.10.4 X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com 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 Signed-off-by: Helmut Schaa --- src/drivers/driver.h | 2 +- src/drivers/driver_nl80211.c | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 5 deletions(-) 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)