From patchwork Tue Mar 18 13:55:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 331432 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 69E3A2C00A6 for ; Wed, 19 Mar 2014 01:01:26 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id C40029C145; Tue, 18 Mar 2014 10:01:22 -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 TfWNRO9kSju8; Tue, 18 Mar 2014 10:01:22 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id E68BB9C15A; Tue, 18 Mar 2014 10:01:03 -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 B4CE89C15A for ; Tue, 18 Mar 2014 10:01:02 -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 8OVr7abCUINY for ; Tue, 18 Mar 2014 10:00:57 -0400 (EDT) Received: from mail-ee0-f48.google.com (mail-ee0-f48.google.com [74.125.83.48]) (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 7621A9C145 for ; Tue, 18 Mar 2014 10:00:57 -0400 (EDT) Received: by mail-ee0-f48.google.com with SMTP id b57so4703616eek.7 for ; Tue, 18 Mar 2014 07:00:56 -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=uqamwjYNYwMQQB2GuxSGxqKzhyVDNq0ocHrx0qesD2s=; b=zMWfF9YKaZ6geQKA8B+7mYg/wwD8hr6cU3avQ19d8dQHekiyQz1a4L+nAHTH6tbR4i DdCawvWpCx2AUKwDnKZp0zor2MTPFeNcVMbMRk5Hl4XEo0S/eCmMrPXa9562v74yv8cv zOhFgxmliy6/qB4ugMtD1oNU23EvZdxtCrRbU= 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=uqamwjYNYwMQQB2GuxSGxqKzhyVDNq0ocHrx0qesD2s=; b=kQKjJZYYLUcd+EYLyQuW284q2yxuqKUINHnSwUR+hmRHE9pESe4ZZdUkjeDY6RFfQJ +9NYx+c2twqyPX1BTiNO1yQcam1tbEFAA4NpfbocNwf6MGSpj5DgSAKukjCF14Yi6Ach 0LPNoGsQ9YoeUe5QSg/gopFL2S/67T8rNaHFgvb3oMIhTLchK5j3ehqVWd6Vp88tccOW AzR6tQLk0Qjg8EG9YBUsXJocFTbZFeRVnDa2We3qPyHuxagpWekA9NRf3fqU8tUxUmg+ 8HRwVUdgHWE4/lWpWdj+ArAVXirzdr7ZPzpbcwm7XF56E7z4U0cDcQW9wVb7G02O2UIf lUjQ== X-Gm-Message-State: ALoCoQlteuYdgZNdsdIQYHYXBDMpP8eN0zLnJT2bxDoz+ZgGc5emNuDjx63+1dwTOiDrp3SAZquL/8U/7W74h2oTO1CNWQBBVGqAT4qPW2TUSjc/Th+XW7I= X-Received: by 10.14.6.195 with SMTP id 43mr2909112een.101.1395151256003; Tue, 18 Mar 2014 07:00:56 -0700 (PDT) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id m8sm47532977eeg.11.2014.03.18.07.00.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Mar 2014 07:00:55 -0700 (PDT) From: Michal Kazior To: j@w1.fi Subject: [RFC 1/3] hostapd: Move CSA structures to hostapd_data Date: Tue, 18 Mar 2014 14:55:08 +0100 Message-Id: <1395150910-20595-2-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1395150910-20595-1-git-send-email-michal.kazior@tieto.com> References: <1395150910-20595-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 This prepares CSA structure and logic in hostapd for multi-BSS support. Signed-hostap: Michal Kazior --- src/ap/beacon.c | 20 ++++++++++---------- src/ap/dfs.c | 14 ++++++++++++-- src/ap/drv_callbacks.c | 8 +++++--- src/ap/hostapd.c | 40 ++++++++++++++++++++-------------------- src/ap/hostapd.h | 16 ++++++++-------- src/drivers/driver_nl80211.c | 4 ++-- 6 files changed, 57 insertions(+), 45 deletions(-) diff --git a/src/ap/beacon.c b/src/ap/beacon.c index e06ce77..c4341f2 100644 --- a/src/ap/beacon.c +++ b/src/ap/beacon.c @@ -265,18 +265,18 @@ static u8 * hostapd_eid_csa(struct hostapd_data *hapd, u8 *eid) { u8 chan; - if (!hapd->iface->cs_freq_params.freq) + if (!hapd->cs_freq_params.freq) return eid; - if (ieee80211_freq_to_chan(hapd->iface->cs_freq_params.freq, &chan) == + if (ieee80211_freq_to_chan(hapd->cs_freq_params.freq, &chan) == NUM_HOSTAPD_MODES) return eid; *eid++ = WLAN_EID_CHANNEL_SWITCH; *eid++ = 3; - *eid++ = hapd->iface->cs_block_tx; + *eid++ = hapd->cs_block_tx; *eid++ = chan; - *eid++ = hapd->iface->cs_count; + *eid++ = hapd->cs_count; return eid; } @@ -286,12 +286,12 @@ static u8 * hostapd_eid_secondary_channel(struct hostapd_data *hapd, u8 *eid) { u8 sec_ch; - if (!hapd->iface->cs_freq_params.sec_channel_offset) + if (!hapd->cs_freq_params.sec_channel_offset) return eid; - if (hapd->iface->cs_freq_params.sec_channel_offset == -1) + if (hapd->cs_freq_params.sec_channel_offset == -1) sec_ch = HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW; - else if (hapd->iface->cs_freq_params.sec_channel_offset == 1) + else if (hapd->cs_freq_params.sec_channel_offset == 1) sec_ch = HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE; else return eid; @@ -409,7 +409,7 @@ static u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd, pos = hostapd_eid_roaming_consortium(hapd, pos); pos = hostapd_add_csa_elems(hapd, pos, (u8 *)resp, - &hapd->iface->cs_c_off_proberesp); + &hapd->cs_c_off_proberesp); #ifdef CONFIG_IEEE80211AC pos = hostapd_eid_vht_capabilities(hapd, pos); pos = hostapd_eid_vht_operation(hapd, pos); @@ -823,7 +823,7 @@ int ieee802_11_build_ap_params(struct hostapd_data *hapd, tailpos = hostapd_eid_adv_proto(hapd, tailpos); tailpos = hostapd_eid_roaming_consortium(hapd, tailpos); tailpos = hostapd_add_csa_elems(hapd, tailpos, tail, - &hapd->iface->cs_c_off_beacon); + &hapd->cs_c_off_beacon); #ifdef CONFIG_IEEE80211AC tailpos = hostapd_eid_vht_capabilities(hapd, tailpos); tailpos = hostapd_eid_vht_operation(hapd, tailpos); @@ -953,7 +953,7 @@ int ieee802_11_set_beacon(struct hostapd_data *hapd) struct wpabuf *beacon, *proberesp, *assocresp; int res, ret = -1; - if (hapd->iface->csa_in_progress) { + if (hapd->csa_in_progress) { wpa_printf(MSG_ERROR, "Cannot set beacons during CSA period"); return -1; } diff --git a/src/ap/dfs.c b/src/ap/dfs.c index 0f262ce..9e8389f 100644 --- a/src/ap/dfs.c +++ b/src/ap/dfs.c @@ -729,6 +729,16 @@ static int hostapd_dfs_start_channel_switch_cac(struct hostapd_iface *iface) } +static int hostapd_csa_in_progress(struct hostapd_iface *iface) +{ + int i; + for (i = 0; i < iface->num_bss; i++) + if (iface->bss[0]->csa_in_progress) + return 1; + return 0; +} + + static int hostapd_dfs_start_channel_switch(struct hostapd_iface *iface) { struct hostapd_channel_data *channel; @@ -742,10 +752,10 @@ static int hostapd_dfs_start_channel_switch(struct hostapd_iface *iface) wpa_printf(MSG_DEBUG, "%s called (CAC active: %s, CSA active: %s)", __func__, iface->cac_started ? "yes" : "no", - iface->csa_in_progress ? "yes" : "no"); + hostapd_csa_in_progress(iface) ? "yes" : "no"); /* Check if CSA in progress */ - if (iface->csa_in_progress) + if (hostapd_csa_in_progress(iface)) return 0; /* Check if active CAC */ diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c index 3c6a376..e3b1e7b 100644 --- a/src/ap/drv_callbacks.c +++ b/src/ap/drv_callbacks.c @@ -30,6 +30,7 @@ #include "ap_config.h" #include "hw_features.h" #include "dfs.h" +#include "beacon.h" int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr, @@ -483,11 +484,12 @@ void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht, else hapd->iconf->ht_capab &= ~HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET; - if (hapd->iface->csa_in_progress && - freq == hapd->iface->cs_freq_params.freq) { - hapd->iconf->ieee80211ac = hapd->iface->cs_freq_params.vht_enabled; + if (hapd->csa_in_progress && + freq == hapd->cs_freq_params.freq) { + hapd->iconf->ieee80211ac = hapd->cs_freq_params.vht_enabled; hostapd_cleanup_cs_params(hapd); + ieee802_11_set_beacon(hapd); wpa_msg(hapd->msg_ctx, MSG_INFO, AP_CSA_FINISHED "freq=%d", freq); diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index 4ed718c..06b3f5b 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -2118,13 +2118,12 @@ static void free_beacon_data(struct beacon_data *beacon) } -static int hostapd_build_beacon_data(struct hostapd_iface *iface, +static int hostapd_build_beacon_data(struct hostapd_data *hapd, struct beacon_data *beacon) { struct wpabuf *beacon_extra, *proberesp_extra, *assocresp_extra; struct wpa_driver_ap_params params; int ret; - struct hostapd_data *hapd = iface->bss[0]; os_memset(beacon, 0, sizeof(*beacon)); ret = ieee802_11_build_ap_params(hapd, ¶ms); @@ -2248,14 +2247,15 @@ static int hostapd_change_config_freq(struct hostapd_data *hapd, } -static int hostapd_fill_csa_settings(struct hostapd_iface *iface, +static int hostapd_fill_csa_settings(struct hostapd_data *hapd, struct csa_settings *settings) { + struct hostapd_iface *iface = hapd->iface; struct hostapd_freq_params old_freq; int ret; os_memset(&old_freq, 0, sizeof(old_freq)); - if (!iface || !iface->freq || iface->csa_in_progress) + if (!iface || !iface->freq || hapd->csa_in_progress) return -1; ret = hostapd_change_config_freq(iface->bss[0], iface->conf, @@ -2264,7 +2264,7 @@ static int hostapd_fill_csa_settings(struct hostapd_iface *iface, if (ret) return ret; - ret = hostapd_build_beacon_data(iface, &settings->beacon_after); + ret = hostapd_build_beacon_data(hapd, &settings->beacon_after); /* change back the configuration */ hostapd_change_config_freq(iface->bss[0], iface->conf, @@ -2274,18 +2274,18 @@ static int hostapd_fill_csa_settings(struct hostapd_iface *iface, return ret; /* set channel switch parameters for csa ie */ - iface->cs_freq_params = settings->freq_params; - iface->cs_count = settings->cs_count; - iface->cs_block_tx = settings->block_tx; + hapd->cs_freq_params = settings->freq_params; + hapd->cs_count = settings->cs_count; + hapd->cs_block_tx = settings->block_tx; - ret = hostapd_build_beacon_data(iface, &settings->beacon_csa); + ret = hostapd_build_beacon_data(hapd, &settings->beacon_csa); if (ret) { free_beacon_data(&settings->beacon_after); return ret; } - settings->counter_offset_beacon = iface->cs_c_off_beacon; - settings->counter_offset_presp = iface->cs_c_off_proberesp; + settings->counter_offset_beacon = hapd->cs_c_off_beacon; + settings->counter_offset_presp = hapd->cs_c_off_proberesp; return 0; } @@ -2293,13 +2293,13 @@ static int hostapd_fill_csa_settings(struct hostapd_iface *iface, void hostapd_cleanup_cs_params(struct hostapd_data *hapd) { - os_memset(&hapd->iface->cs_freq_params, 0, - sizeof(hapd->iface->cs_freq_params)); - hapd->iface->cs_count = 0; - hapd->iface->cs_block_tx = 0; - hapd->iface->cs_c_off_beacon = 0; - hapd->iface->cs_c_off_proberesp = 0; - hapd->iface->csa_in_progress = 0; + os_memset(&hapd->cs_freq_params, 0, + sizeof(hapd->cs_freq_params)); + hapd->cs_count = 0; + hapd->cs_block_tx = 0; + hapd->cs_c_off_beacon = 0; + hapd->cs_c_off_proberesp = 0; + hapd->csa_in_progress = 0; } @@ -2307,7 +2307,7 @@ int hostapd_switch_channel(struct hostapd_data *hapd, struct csa_settings *settings) { int ret; - ret = hostapd_fill_csa_settings(hapd->iface, settings); + ret = hostapd_fill_csa_settings(hapd, settings); if (ret) return ret; @@ -2321,7 +2321,7 @@ int hostapd_switch_channel(struct hostapd_data *hapd, return ret; } - hapd->iface->csa_in_progress = 1; + hapd->csa_in_progress = 1; return 0; } diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h index 9a705a4..ad1a0ee 100644 --- a/src/ap/hostapd.h +++ b/src/ap/hostapd.h @@ -210,6 +210,14 @@ struct hostapd_data { size_t psk_len); void *new_psk_cb_ctx; + /* channel switch parameters */ + struct hostapd_freq_params cs_freq_params; + u8 cs_count; + int cs_block_tx; + unsigned int cs_c_off_beacon; + unsigned int cs_c_off_proberesp; + int csa_in_progress; + #ifdef CONFIG_P2P struct p2p_data *p2p; struct p2p_group *p2p_group; @@ -340,14 +348,6 @@ struct hostapd_iface { /* lowest observed noise floor in dBm */ s8 lowest_nf; - /* channel switch parameters */ - struct hostapd_freq_params cs_freq_params; - u8 cs_count; - int cs_block_tx; - unsigned int cs_c_off_beacon; - unsigned int cs_c_off_proberesp; - int csa_in_progress; - #ifdef CONFIG_ACS unsigned int acs_num_completed_scans; #endif /* CONFIG_ACS */ diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index d60f95b..dd119c4 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -1653,7 +1653,7 @@ static void mlme_event_ch_switch(struct wpa_driver_nl80211_data *drv, bss->freq = data.ch_switch.freq; - wpa_supplicant_event(drv->ctx, EVENT_CH_SWITCH, &data); + wpa_supplicant_event(bss->ctx, EVENT_CH_SWITCH, &data); } @@ -11700,7 +11700,7 @@ static int nl80211_switch_channel(void *priv, struct csa_settings *settings) return -ENOMEM; nl80211_cmd(drv, msg, 0, NL80211_CMD_CHANNEL_SWITCH); - NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex); + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, bss->ifindex); NLA_PUT_U32(msg, NL80211_ATTR_CH_SWITCH_COUNT, settings->cs_count); ret = nl80211_put_freq_params(msg, &settings->freq_params); if (ret)