From patchwork Wed Jun 25 11:20:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 363946 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]) by ozlabs.org (Postfix) with ESMTP id 8FED91400A7 for ; Wed, 25 Jun 2014 21:29:53 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 87CC49C1F9; Wed, 25 Jun 2014 07:29:46 -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 FgJFikbqfPAj; Wed, 25 Jun 2014 07:29:46 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 414279D2E5; Wed, 25 Jun 2014 07:28:55 -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 3E6119D2BA for ; Wed, 25 Jun 2014 07:28:53 -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 0tUopX296-yq for ; Wed, 25 Jun 2014 07:28:47 -0400 (EDT) Received: from mail-we0-f180.google.com (mail-we0-f180.google.com [74.125.82.180]) (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 C6B3417C013 for ; Wed, 25 Jun 2014 07:28:33 -0400 (EDT) Received: by mail-we0-f180.google.com with SMTP id x48so1827936wes.25 for ; Wed, 25 Jun 2014 04:28:31 -0700 (PDT) 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=87ct3cYSrOvcSPqfT3TGT9vJMAZcYxA6PQcBJoPqrRA=; b=CkGpTJC8ahVub+Ho5ulht/MoIYao2Or8f2Ibo4ocpyj2QRHyp0OOrBmmX7oQ4XyUbh OXFtjz7Wr585n/EJUrayqEw2EwD+usBAd5+3arH6iHg4JlfmXHmhT5QaZMJYh5J5qimY VKjOPyR1yB5JwgitaVL0iEKwI9B4cMbxsZAQw= 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=87ct3cYSrOvcSPqfT3TGT9vJMAZcYxA6PQcBJoPqrRA=; b=MdnAGX5HbZOfqZpk46fmtnA4T/0c3MrHH74XoQHCiI+Jmuife28sT+kKFgDKMH5sAW 6XBZA9ysijlUNk8SR/846bCIMXSFuFb2Ri5r3+dO76qSzgQWOfk2n6LxzdIrhKQV6nO2 NCwvt3YFC56xGPxIozC+2qWISuNg9W4iLYmr8h3rbk/l+Lc8ByqAf7Ecu/ZXhYTzNcJM 82vwtyZ/cQlAkCFqc0R+SeK9I1DwhP5bh90XVGRd3CmRyo/bumqgYzh9NZSUEY4xl7bF 4v69F1OkXLd8SIA22EYmrCpRsSNpE/JEWI6Iq+U4mX8d8JqqhFp87XqL+MpYTkb2E39B g5CA== X-Gm-Message-State: ALoCoQl0om7Tm5+NeFdGWDzR4dDo+7PdFk/jofQq7i0a2uey8T6SFkGTpxSq696Xf3Y31vbUCQ5AQGydfaxICJaWRu2L8QR0hQR67eOPtAtGz+k6GFHp3so= X-Received: by 10.194.119.228 with SMTP id kx4mr9248836wjb.108.1403695710283; Wed, 25 Jun 2014 04:28:30 -0700 (PDT) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id lo18sm11382382wic.1.2014.06.25.04.28.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jun 2014 04:28:29 -0700 (PDT) From: Michal Kazior To: j@w1.fi Subject: [PATCH 4/4] hostapd: Use channel switch fallback on error Date: Wed, 25 Jun 2014 13:20:26 +0200 Message-Id: <1403695226-29139-5-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1403695226-29139-1-git-send-email-michal.kazior@tieto.com> References: <1403695226-29139-1-git-send-email-michal.kazior@tieto.com> X-DomainID: tieto.com Cc: hostap@lists.shmoo.com 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 It's worth giving a try to fallback to re-starting BSSes at least once hoping it works out instead of just leaving BSSes disabled. Signed-off-by: Michal Kazior --- src/ap/drv_callbacks.c | 11 +++++++++++ src/ap/hostapd.c | 51 +++++++++++++++++++++++++++++++++++++++++++++----- src/ap/hostapd.h | 8 ++++++++ src/drivers/driver.h | 3 ++- 4 files changed, 67 insertions(+), 6 deletions(-) diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c index ac5732c..561cbf9 100644 --- a/src/ap/drv_callbacks.c +++ b/src/ap/drv_callbacks.c @@ -885,6 +885,14 @@ static void hostapd_event_get_survey(struct hostapd_data *hapd, #ifdef NEED_AP_MLME + +static void hostapd_event_iface_unavailable(struct hostapd_data *hapd) +{ + wpa_printf(MSG_DEBUG, "Interface is unavailable -- stopped"); + hostapd_switch_channel_fallback(hapd); +} + + static void hostapd_event_dfs_radar_detected(struct hostapd_data *hapd, struct dfs_event *radar) { @@ -1072,6 +1080,9 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, hostapd_event_get_survey(hapd, &data->survey_results); break; #ifdef NEED_AP_MLME + case EVENT_INTERFACE_UNAVAILABLE: + hostapd_event_iface_unavailable(hapd); + break; case EVENT_DFS_RADAR_DETECTED: if (!data) break; diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index 4da5a3d..c504364 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -2280,13 +2280,13 @@ static int hostapd_change_config_freq(struct hostapd_data *hapd, if (!params->channel) { /* check if the new channel is supported by hw */ - channel = hostapd_hw_get_channel(hapd, params->freq); - if (!channel) - return -1; - } else { - channel = params->channel; + params->channel = hostapd_hw_get_channel(hapd, params->freq); } + channel = params->channel; + if (!channel) + return -1; + /* if a pointer to old_params is provided we save previous state */ if (old_params) { old_params->channel = conf->channel; @@ -2363,11 +2363,25 @@ void hostapd_cleanup_cs_params(struct hostapd_data *hapd) int hostapd_switch_channel(struct hostapd_data *hapd, struct csa_settings *settings) { + struct hostapd_iface *iface = hapd->iface; int ret; + ret = hostapd_fill_csa_settings(hapd, settings); if (ret) return ret; + iface->csa_freq = settings->freq_params.freq; + iface->csa_channel = settings->freq_params.channel; + iface->csa_secondary_channel = settings->freq_params.sec_channel_offset; + + if (settings->freq_params.center_freq1) + iface->csa_vht_oper_centr_freq_seg0_idx = + 36 + (settings->freq_params.center_freq1 - 5180) / 5; + + if (settings->freq_params.center_freq2) + iface->csa_vht_oper_centr_freq_seg1_idx = + 36 + (settings->freq_params.center_freq2 - 5180) / 5; + ret = hostapd_drv_switch_channel(hapd, settings); free_beacon_data(&settings->beacon_csa); free_beacon_data(&settings->beacon_after); @@ -2382,4 +2396,31 @@ int hostapd_switch_channel(struct hostapd_data *hapd, return 0; } +void hostapd_switch_channel_fallback(struct hostapd_data *hapd) +{ + struct hostapd_iface *iface = hapd->iface; + int i; + + if (!hapd->csa_in_progress) + return; + + for (i = 0; i < iface->num_bss; i++) { + iface->bss[i]->csa_in_progress = 0; + iface->bss[i]->cs_freq_params.freq = 0; + } + + wpa_printf(MSG_WARNING, "CSA failed, trying fallback by toggling interface"); + + iface->freq = iface->csa_freq; + iface->conf->channel = iface->csa_channel; + iface->conf->secondary_channel = iface->csa_secondary_channel; + iface->conf->vht_oper_centr_freq_seg0_idx = + iface->csa_vht_oper_centr_freq_seg0_idx; + iface->conf->vht_oper_centr_freq_seg1_idx = + iface->csa_vht_oper_centr_freq_seg1_idx; + + hostapd_disable_iface(iface); + hostapd_enable_iface(iface); +} + #endif /* NEED_AP_MLME */ diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h index d413f7e..011dc51 100644 --- a/src/ap/hostapd.h +++ b/src/ap/hostapd.h @@ -362,6 +362,13 @@ struct hostapd_iface { unsigned int acs_num_completed_scans; #endif /* CONFIG_ACS */ + /* channel switch parameters - used for fallback if CSA itself fails */ + int csa_freq; + short csa_channel; + int csa_secondary_channel; + u8 csa_vht_oper_centr_freq_seg0_idx; + u8 csa_vht_oper_centr_freq_seg1_idx; + void (*scan_cb)(struct hostapd_iface *iface); int num_ht40_scan_tries; }; @@ -397,6 +404,7 @@ void hostapd_set_state(struct hostapd_iface *iface, enum hostapd_iface_state s); const char * hostapd_state_text(enum hostapd_iface_state s); int hostapd_switch_channel(struct hostapd_data *hapd, struct csa_settings *settings); +void hostapd_switch_channel_fallback(struct hostapd_data *hapd); void hostapd_cleanup_cs_params(struct hostapd_data *hapd); /* utils.c */ diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 33f53af..352c163 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -3316,7 +3316,8 @@ enum wpa_event_type { * the driver does not support radar detection and another virtual * interfaces caused the operating channel to change. Other similar * resource conflicts could also trigger this for station mode - * interfaces. + * interfaces. This event can be propagated when channel switching + * fails. */ EVENT_INTERFACE_UNAVAILABLE,