From patchwork Wed Mar 5 08:23:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz.Dziedzic@tieto.com X-Patchwork-Id: 326631 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 9F9622C0090 for ; Wed, 5 Mar 2014 19:24:11 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 276329D2ED; Wed, 5 Mar 2014 03:24:09 -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 6eSrJOmBjMfc; Wed, 5 Mar 2014 03:24:08 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 493509D2F0; Wed, 5 Mar 2014 03:24:04 -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 4D9929D2F0 for ; Wed, 5 Mar 2014 03:24:03 -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 E7+MO+bB1Igc for ; Wed, 5 Mar 2014 03:23:58 -0500 (EST) Received: from mail-ee0-f51.google.com (mail-ee0-f51.google.com [74.125.83.51]) (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 F1B679D2ED for ; Wed, 5 Mar 2014 03:23:57 -0500 (EST) Received: by mail-ee0-f51.google.com with SMTP id c13so266836eek.10 for ; Wed, 05 Mar 2014 00:23:57 -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; bh=F0IYPb7FcedZa3soCkrutc2cc+knRmgM9a+x+1MRUC0=; b=KvCP+bvpPGYf+sL/dWR9/iCEOkyex6t1PGj4QG1iPj5V2ImtWuP2unU1FWLFRji2J1 GeytuTTFy+tIRm3hxKHoQ3UqmTmog5nZi/dRBKs72B/2i2jkVi4OronFSzrmBtvjIS7i mcUFWfUFFILjokTjjLwNQzn2E7GHvKwOlB8dM= 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; bh=F0IYPb7FcedZa3soCkrutc2cc+knRmgM9a+x+1MRUC0=; b=mGvnBH9OsXRV5J3vzHHgHw7l1vCVX5OqFwa4q6i94+xiGB46HTsTW7w7/erL1nibyI Axr52nzpXQforyJ6iRVLxjLjC6a9RUdIqo5FQ13tb2frD24o3taILUCq3R343FoSmJpn 6qCfLBHY3/jtfmGcxd383hO+Ks6NgVkfSZt/6aKEqYEZyO+txZNEwstQUy+eR1qyns8X NBwxyOPF6XdJ5qSpvIeUePwNUKNYciqafFC8bc3bZI67wAYIU2OEZzwIjg2We2xm4pWx N8nsb+6k8v+lCkc0MayAWxUTVoREtjjo6GdTetTNf+VTOCoRZ5w8YFX8e/NgdhAYI4PX aV4A== X-Gm-Message-State: ALoCoQmE7ON4g/RnN8WfqzkprH2fikX65FA6y7TX5lWGWHlS/ePDqn4gmNYzQlbVkFqRNTWToCF85KTCdwKqHCJ6/IEwj4rdX8GmFVIw6BpRfcOM2K56/pU= X-Received: by 10.14.208.195 with SMTP id q43mr1059240eeo.102.1394007836944; Wed, 05 Mar 2014 00:23:56 -0800 (PST) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id m42sm5930655eex.21.2014.03.05.00.23.55 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Mar 2014 00:23:55 -0800 (PST) From: Janusz Dziedzic To: hostap@lists.shmoo.com Subject: [PATCH v2] hostapd: DFS print CAC info in status cli command Date: Wed, 5 Mar 2014 09:23:42 +0100 Message-Id: <1394007822-3252-1-git-send-email-janusz.dziedzic@tieto.com> X-Mailer: git-send-email 1.7.9.5 X-DomainID: tieto.com Cc: j@w1.fi 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 Print CAC time and CAC left time in status, cli command. Signed-off-by: Janusz Dziedzic --- *V2 print this only in status command, use reltime src/ap/ap_drv_ops.c | 4 +++- src/ap/ctrl_iface_ap.c | 26 ++++++++++++++++++++++++++ src/ap/dfs.c | 30 ++++++++++++++++++++++++++++-- src/ap/hostapd.h | 3 +++ src/drivers/driver.h | 3 +++ src/drivers/driver_nl80211.c | 4 ++++ 6 files changed, 67 insertions(+), 3 deletions(-) diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c index 5ba48c9..24eaff1 100644 --- a/src/ap/ap_drv_ops.c +++ b/src/ap/ap_drv_ops.c @@ -773,8 +773,10 @@ int hostapd_start_dfs_cac(struct hostapd_iface *iface, int mode, int freq, } res = hapd->driver->start_dfs_cac(hapd->drv_priv, &data); - if (!res) + if (!res) { iface->cac_started = 1; + os_get_reltime(&iface->dfs_cac_start); + } return res; } diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c index 8c0cbab..ed915a8 100644 --- a/src/ap/ctrl_iface_ap.c +++ b/src/ap/ctrl_iface_ap.c @@ -395,6 +395,7 @@ int hostapd_ctrl_iface_status(struct hostapd_data *hapd, char *buf, { struct hostapd_iface *iface = hapd->iface; int len = 0, ret; + char cac_time[100]; size_t i; ret = os_snprintf(buf + len, buflen - len, @@ -426,6 +427,31 @@ int hostapd_ctrl_iface_status(struct hostapd_data *hapd, char *buf, return len; len += ret; + if (!iface->cac_started || !iface->dfs_cac_ms) { + os_snprintf(cac_time, sizeof(cac_time), + "cac_time_seconds=%d\n" + "cac_time_left_seconds=N/A\n", + iface->dfs_cac_ms/1000); + } else { + /* CAC started and CAC time set - calc left time */ + struct os_reltime now; + unsigned int left_time; + + os_reltime_age(&iface->dfs_cac_start, &now); + left_time = iface->dfs_cac_ms/1000 - now.sec; + os_snprintf(cac_time, sizeof(cac_time), + "cac_time_seconds=%u\n" + "cac_time_left_seconds=%u\n", + iface->dfs_cac_ms/1000, + left_time); + } + + ret = os_snprintf(buf + len, buflen - len, + "%s", cac_time); + if (ret < 0 || (size_t) ret >= buflen -len) + return len; + len += ret; + ret = os_snprintf(buf + len, buflen - len, "channel=%u\n" "secondary_channel=%d\n" diff --git a/src/ap/dfs.c b/src/ap/dfs.c index 92eda21..9e876ad 100644 --- a/src/ap/dfs.c +++ b/src/ap/dfs.c @@ -541,6 +541,28 @@ static int dfs_are_channels_overlapped(struct hostapd_iface *iface, int freq, } +static unsigned int dfs_get_cac_time(struct hostapd_iface *iface, + int start_chan_idx, + int n_chans) +{ + struct hostapd_channel_data *channel; + struct hostapd_hw_modes *mode; + int i; + unsigned int cac_time_ms = 0; + + mode = iface->current_mode; + + for (i = 0; i < n_chans; i++) { + channel = &mode->channels[start_chan_idx + i]; + if (!(channel->flag & HOSTAPD_CHAN_RADAR)) + continue; + if (channel->dfs_cac_ms > cac_time_ms) + cac_time_ms = channel->dfs_cac_ms; + } + + return cac_time_ms; +} + /* * Main DFS handler * 1 - continue channel/ap setup @@ -564,6 +586,9 @@ int hostapd_handle_dfs(struct hostapd_iface *iface) /* Get number of used channels, depend on width */ n_chans = dfs_get_used_n_chans(iface); + /* Setup CAC time */ + iface->dfs_cac_ms = dfs_get_cac_time(iface, start_chan_idx, n_chans); + /* Check if any of configured channels require DFS */ res = dfs_check_chans_radar(iface, start_chan_idx, n_chans); wpa_printf(MSG_DEBUG, @@ -608,12 +633,13 @@ int hostapd_handle_dfs(struct hostapd_iface *iface) hostapd_set_state(iface, HAPD_IFACE_DFS); wpa_printf(MSG_DEBUG, "DFS start CAC on %d MHz", iface->freq); wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_CAC_START - "freq=%d chan=%d sec_chan=%d, width=%d, seg0=%d, seg1=%d", + "freq=%d chan=%d sec_chan=%d, width=%d, seg0=%d, seg1=%d, cac_time=%ds", iface->freq, iface->conf->channel, iface->conf->secondary_channel, iface->conf->vht_oper_chwidth, iface->conf->vht_oper_centr_freq_seg0_idx, - iface->conf->vht_oper_centr_freq_seg1_idx); + iface->conf->vht_oper_centr_freq_seg1_idx, + iface->dfs_cac_ms/1000); res = hostapd_start_dfs_cac(iface, iface->conf->hw_mode, iface->freq, diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h index 489ab16..29b8ad0 100644 --- a/src/ap/hostapd.h +++ b/src/ap/hostapd.h @@ -345,6 +345,9 @@ struct hostapd_iface { unsigned int cs_c_off_proberesp; int csa_in_progress; + u32 dfs_cac_ms; + struct os_reltime dfs_cac_start; + #ifdef CONFIG_ACS unsigned int acs_num_completed_scans; #endif /* CONFIG_ACS */ diff --git a/src/drivers/driver.h b/src/drivers/driver.h index b6434c2..0a7bf12 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -93,6 +93,9 @@ struct hostapd_channel_data { */ long double interference_factor; #endif /* CONFIG_ACS */ + + /* DFS CAC time in milliseconds */ + u32 dfs_cac_ms; }; #define HOSTAPD_MODE_FLAG_HT_INFO_KNOWN BIT(0) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 7468e5d..8f77c67 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -6164,6 +6164,7 @@ static void phy_info_freq(struct hostapd_hw_modes *mode, u8 channel; chan->freq = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]); chan->flag = 0; + chan->dfs_cac_ms = 0; if (ieee80211_freq_to_chan(chan->freq, &channel) != NUM_HOSTAPD_MODES) chan->chan = channel; @@ -6190,6 +6191,9 @@ static void phy_info_freq(struct hostapd_hw_modes *mode, break; } } + + if (tb_freq[NL80211_FREQUENCY_ATTR_DFS_CAC_TIME]) + chan->dfs_cac_ms = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_DFS_CAC_TIME]); }