From patchwork Fri Feb 7 21:19:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Puzyniak X-Patchwork-Id: 318206 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 ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A423C2C00A3 for ; Sat, 8 Feb 2014 08:20:38 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 684739C0B5; Fri, 7 Feb 2014 16:20:35 -0500 (EST) 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 IrPbRQbmbXPe; Fri, 7 Feb 2014 16:20:35 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 255009C0B6; Fri, 7 Feb 2014 16:20:30 -0500 (EST) 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 51C729C0B5 for ; Fri, 7 Feb 2014 16:20:29 -0500 (EST) 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 1yxJ+tC8KfJA for ; Fri, 7 Feb 2014 16:20:24 -0500 (EST) Received: from mail-ee0-f49.google.com (mail-ee0-f49.google.com [74.125.83.49]) (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 1CCEA9C0B6 for ; Fri, 7 Feb 2014 16:20:15 -0500 (EST) Received: by mail-ee0-f49.google.com with SMTP id d17so1778684eek.8 for ; Fri, 07 Feb 2014 13:20:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ETyb4hGUcm/QCRQdpitRA8OUYnXEuZgKH3mBNkFZSSI=; b=i1H0+eiwa9cdeR4b0+JEzX/dMnhEYMKiVfIe86yfbmKBcd8IhrOg0JTsdB1An/0r2E 8k1Or0JwEHT870zl9WxvVBNmULjr9vfHjFzn3jWm2r3rmyVna3Da0tpakyKQSgXduisC Jobrky8+s9mhNiTxTB0S26GoF3ALIKQqWSZuo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ETyb4hGUcm/QCRQdpitRA8OUYnXEuZgKH3mBNkFZSSI=; b=CzRSMgjAgljPi+Xj2eVdLDRMoZZ0nCq+1NOBMCPtwyyZDDTRoWu7GUHXY0KJbmuHq9 Gn2I6J4R/oNrjXHPgAww76e5VYtqGTpDYl3nSyphK464hSMtWoX+1xNQ4wjnnIcWdk+K vx24BVVkdUKKQjG9iB3PY0K+sWLppiF3AQ5Kg7o5j60S7I4QB6WoDUuWLBA+GzIzdcW1 rpfA9Gpw1kGIWFQD2oda1xm5whrTVOvkUpBSFR6KIgpL1sGMsSS7v41lhJWlsgJXW3gL /o7gYNu4UfKcCTtHAPG0XdMF1lvA4IsQRQYCVxytheXOCleKlljUj3cGvKyaxNyrVdPz faQw== X-Gm-Message-State: ALoCoQmI3eV94gexac46J7KDUIAft/WCOT7cIm22hMHrrUpBGw4DxRsFOxVXDlQ0P6hqyi76oIR/E+ZX33xiIRdddUevvtO8Bn45DkYs4Ykd8B2LZi1fk6U= X-Received: by 10.15.45.194 with SMTP id b42mr5654526eew.103.1391808015059; Fri, 07 Feb 2014 13:20:15 -0800 (PST) Received: from dell.chello.pl (89-70-159-20.dynamic.chello.pl. [89.70.159.20]) by mx.google.com with ESMTPSA id k6sm20985006eep.17.2014.02.07.13.20.14 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Feb 2014 13:20:14 -0800 (PST) From: Marek Puzyniak To: hostap@lists.shmoo.com Subject: [PATCH 2/2] hostapd: Configure spectrum management capability Date: Fri, 7 Feb 2014 22:19:14 +0100 Message-Id: <1391807954-4016-2-git-send-email-marek.puzyniak@tieto.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1391807954-4016-1-git-send-email-marek.puzyniak@tieto.com> References: <1391807954-4016-1-git-send-email-marek.puzyniak@tieto.com> X-DomainID: tieto.com Cc: Chaitanya T K 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 From: Chaitanya T K Add configuration of Spectrum Managment subfield in the Capability Information of Beacon, Probe Response and Association Response. Spectrum Management bit is set when directly requested by new configuration option spectrum_mgmt_required=1 or when AP is running on DFS channels. In future also TPC shall require this bit to be set. Signed-hostap: Srinivasan Signed-hostap: Chaitanya T K Signed-hostap: Marek Puzyniak --- hostapd/config_file.c | 2 ++ hostapd/hostapd.conf | 7 +++++++ src/ap/ap_config.c | 6 ++++++ src/ap/ap_config.h | 3 +++ src/ap/beacon.c | 43 +++++++++++++++++++++++++++++++++++++++---- src/ap/dfs.c | 19 +++++++++++++++++++ src/ap/dfs.h | 2 ++ src/ap/ieee802_11.c | 21 +++++++++++++++++++++ 8 files changed, 99 insertions(+), 4 deletions(-) diff --git a/hostapd/config_file.c b/hostapd/config_file.c index 4f989ac..1cf54de 100644 --- a/hostapd/config_file.c +++ b/hostapd/config_file.c @@ -2914,6 +2914,8 @@ static int hostapd_config_fill(struct hostapd_config *conf, errors++; } else conf->local_pwr_constraint = val; + } else if (os_strcmp(buf, "spectrum_mgmt_required") == 0) { + conf->spectrum_mgmt_required = atoi(pos); } else { wpa_printf(MSG_ERROR, "Line %d: unknown configuration " "item '%s'", line, buf); diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf index 1357c03..354e1c7 100644 --- a/hostapd/hostapd.conf +++ b/hostapd/hostapd.conf @@ -116,6 +116,13 @@ ssid=test # Valid values are 0..255. #local_pwr_constraint=3 +# Set Spectrum Managment subfield in the Capability Information field. +# This config option forces Spectrum Management bit to be set. When this +# option is not set then value of Spectrum Management bit depends on whether +# DFS or TPC is reuired by regulatory authorities.This can be used only with +# ieee80211d=1 and local_pwr_constraint configured. +#spectrum_mgmt_required=1 + # Operation mode (a = IEEE 802.11a, b = IEEE 802.11b, g = IEEE 802.11g, # ad = IEEE 802.11ad (60 GHz); a/g options are used with IEEE 802.11n, too, to # specify band) diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c index 6c80e48..cc64f92 100644 --- a/src/ap/ap_config.c +++ b/src/ap/ap_config.c @@ -838,6 +838,12 @@ int hostapd_config_check(struct hostapd_config *conf, int full_config) return -1; } + if (full_config && conf->spectrum_mgmt_required && + conf->local_pwr_constraint == -1) { + wpa_printf(MSG_ERROR, "Cannot set Spectrum Management bit " + "without Country and Power Constraint elements"); + return -1; + } for (i = 0; i < conf->num_bss; i++) { if (hostapd_config_check_bss(conf->bss[i], conf, full_config)) return -1; diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h index 8c3bddb..3cbfc8f 100644 --- a/src/ap/ap_config.h +++ b/src/ap/ap_config.h @@ -525,6 +525,9 @@ struct hostapd_config { */ int local_pwr_constraint; + /* Control Spectrum Management bit */ + int spectrum_mgmt_required; + struct hostapd_tx_queue_params tx_queue[NUM_TX_QUEUES]; /* diff --git a/src/ap/beacon.c b/src/ap/beacon.c index fd7c547..7daea0c 100644 --- a/src/ap/beacon.c +++ b/src/ap/beacon.c @@ -27,6 +27,7 @@ #include "ap_drv_ops.h" #include "beacon.h" #include "hs20.h" +#include "dfs.h" #ifdef NEED_AP_MLME @@ -105,13 +106,44 @@ static u8 * hostapd_eid_erp_info(struct hostapd_data *hapd, u8 *eid) static u8 * hostapd_eid_pwr_constraint(struct hostapd_data *hapd, u8 *eid) { u8 *pos = eid; + int local_pwr_constraint = 0; + int dfs; - if (hapd->iconf->local_pwr_constraint == -1 || - hapd->iface->current_mode == NULL || - hapd->iface->current_mode->mode != HOSTAPD_MODE_IEEE80211A) + if (hapd->iface->current_mode == NULL || + hapd->iface->current_mode->mode != HOSTAPD_MODE_IEEE80211A) + return eid; + + /* + * There is no DFS support and power constraint was not direcly + * requested by config option. + */ + if (!hapd->iconf->ieee80211h && + hapd->iconf->local_pwr_constraint == -1) + return eid; + + /* Check if DFS is required by regulatory. */ + dfs = hostapd_is_dfs_required(hapd->iface); + if (dfs < 0 ) { + wpa_printf(MSG_WARNING, "Failed to check if dfs " + "is required ret=%d", dfs); + dfs = 0; + } + + if (dfs == 0 && hapd->iconf->local_pwr_constraint == -1) return eid; /* + * ieee80211h (DFS) is enabled so Power Constraint element shall + * be added when running on DFS channel whenever local_pwr_constraint + * is configured or not. In order to meet regulations when TPC is not + * implemented using a transmit power that is below the legal maximum + * (including any mitigation factor) should help. In this case 3dB below + * maximum allowed transmit power. + */ + if (hapd->iconf->local_pwr_constraint == -1) + local_pwr_constraint = 3; + + /* * CRDA provides reduced TX power than actual regulatory max TX power. * Value of 0 to the local power constraint provides an opportunity * for the client devices to operate at the power limit provided by CRDA @@ -124,7 +156,10 @@ static u8 * hostapd_eid_pwr_constraint(struct hostapd_data *hapd, u8 *eid) /* Length */ *pos++ = 1; /* Local Power Constraint */ - *pos++ = hapd->iconf->local_pwr_constraint; + if (local_pwr_constraint) + *pos++ = local_pwr_constraint; + else + *pos++ = hapd->iconf->local_pwr_constraint; return pos; } diff --git a/src/ap/dfs.c b/src/ap/dfs.c index e4c00f8..1597139 100644 --- a/src/ap/dfs.c +++ b/src/ap/dfs.c @@ -801,3 +801,22 @@ int hostapd_dfs_nop_finished(struct hostapd_iface *iface, int freq, cf1, cf2, HOSTAPD_CHAN_DFS_USABLE); return 0; } + +int hostapd_is_dfs_required(struct hostapd_iface *iface) +{ + int n_chans, start_chan_idx; + int res = 0; + + /* Get start (first) channel for current configuration */ + start_chan_idx = dfs_get_start_chan_idx(iface); + if (start_chan_idx == -1) + return -1; + + /* Get number of used channels, depend on width */ + n_chans = dfs_get_used_n_chans(iface); + + /* Check if any of configured channels require DFS */ + res = dfs_check_chans_radar(iface, start_chan_idx, n_chans); + + return res; +} diff --git a/src/ap/dfs.h b/src/ap/dfs.h index 859ff79..2710021 100644 --- a/src/ap/dfs.h +++ b/src/ap/dfs.h @@ -21,5 +21,7 @@ int hostapd_dfs_radar_detected(struct hostapd_iface *iface, int freq, int hostapd_dfs_nop_finished(struct hostapd_iface *iface, int freq, int ht_enabled, int chan_offset, int chan_width, int cf1, int cf2); +int hostapd_is_dfs_required(struct hostapd_iface *iface); + #endif /* DFS_H */ diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index 0f67883..0e85da8 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -38,6 +38,7 @@ #include "ap_drv_ops.h" #include "wnm_ap.h" #include "ieee802_11.h" +#include "dfs.h" u8 * hostapd_eid_supp_rates(struct hostapd_data *hapd, u8 *eid) @@ -137,6 +138,15 @@ u16 hostapd_own_capab_info(struct hostapd_data *hapd, struct sta_info *sta, { int capab = WLAN_CAPABILITY_ESS; int privacy; + int dfs; + + /* Check if any of configured channels require DFS */ + dfs = hostapd_is_dfs_required(hapd->iface); + if (dfs < 0 ) { + wpa_printf(MSG_WARNING, "Failed to check if dfs " + "is required ret=%d", dfs); + dfs = 0; + } if (hapd->iface->num_sta_no_short_preamble == 0 && hapd->iconf->preamble == SHORT_PREAMBLE) @@ -174,6 +184,17 @@ u16 hostapd_own_capab_info(struct hostapd_data *hapd, struct sta_info *sta, hapd->iface->num_sta_no_short_slot_time == 0) capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME; + /* + * Currently Spectrum Management capability bit is set when directly + * requested in configuration by spectrum_mgmt_required or when AP is + * running on DFS channel. + * TODO: Also consider driver support for TPC to set Spectrum Mgmt bit + */ + if (hapd->iface->current_mode && + hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A && + (hapd->iconf->spectrum_mgmt_required || dfs)) + capab |= WLAN_CAPABILITY_SPECTRUM_MGMT; + return capab; }