From patchwork Mon Mar 3 10:10:53 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: 325756 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 533722C00D5 for ; Mon, 3 Mar 2014 21:11:26 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id F403B9D2C1; Mon, 3 Mar 2014 05:11:22 -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 frOZTavDT-9l; Mon, 3 Mar 2014 05:11:22 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id F03849D2B1; Mon, 3 Mar 2014 05:11:17 -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 5AEB99D2B1 for ; Mon, 3 Mar 2014 05:11:15 -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 3B6dxOv3jl3a for ; Mon, 3 Mar 2014 05:11:09 -0500 (EST) Received: from mail-ea0-f181.google.com (mail-ea0-f181.google.com [209.85.215.181]) (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 A67139C14A for ; Mon, 3 Mar 2014 05:11:09 -0500 (EST) Received: by mail-ea0-f181.google.com with SMTP id k10so4301326eaj.40 for ; Mon, 03 Mar 2014 02:11:07 -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=nnl/w7GeMTv7H0yHmNIB4/JLMR7FFxDKpch6wGR9zQU=; b=qqd146kcH62vc/Q3+cJiT81yXoNJJvKGNmyDgInoav7UiC1I8LItOPfoVNcQR4rl4/ +2S0QmEeu6oLOvi8VZxbomhJeDQAgRDdL7a7SMcuRXZiu0EF+uQF7GoAc2+pxc0TW+sn Bdc+g0Qirn5uxLXFQc+/hTA9ghY/aYjbbANLM= 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=nnl/w7GeMTv7H0yHmNIB4/JLMR7FFxDKpch6wGR9zQU=; b=hodmwUdqlHWq8rIFZjO/4mnHGgT4zJkM4/KUDg4pmXiXrgQDQXKJuHUZxbeSN6VjZb kOnK1DVVgap3bT2zPgik3ilyhoKmtm4N7yxmDtoJ2jyFsalupAxx7pZcSG8s8ybWWNNd K0rVs0xDEV6NkEwhHK49NmWxHOqlQT3IgDl6bHbBLzOjyze5kieIRB1KOxAJf/XLIi/i 8aL0oyy9tj34se6H9zr0lQVV2FvcuwAbGsZewUKJV9DBWtXWy4fy6eCJa89xQ2sMUFuQ ihYTGql6Be3o3xU6MhRNiM9ro1hCVhG1jqe4BXeH46O8yOOE/rjx/1vgTvsaPUiLofXL dSUg== X-Gm-Message-State: ALoCoQkjW9ILdMjRSO4/mxZHvOEX+6ZByVvP0JS/RDT7l4vQ0OwpNUrpIJmOAi5ytuibi9D9JjsIuB4KUCZo6GIiEG2ysdxO7ev6OKa7QgnaB/z9pPu3EGk= X-Received: by 10.14.1.68 with SMTP id 44mr39162720eec.0.1393841467088; Mon, 03 Mar 2014 02:11:07 -0800 (PST) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id x3sm48072217eep.17.2014.03.03.02.11.05 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Mar 2014 02:11:06 -0800 (PST) From: Janusz Dziedzic To: hostap@lists.shmoo.com Subject: [PATCH] hostapd: DFS add cac_time cli command Date: Mon, 3 Mar 2014 11:10:53 +0100 Message-Id: <1393841453-3846-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 Add cac_time cli command, that will display currently configured and left CAC time. Print cac_time also in status command. Signed-off-by: Janusz Dziedzic --- hostapd/ctrl_iface.c | 3 +++ hostapd/hostapd_cli.c | 7 +++++++ src/ap/ap_drv_ops.c | 4 +++- src/ap/ctrl_iface_ap.c | 40 ++++++++++++++++++++++++++++++++++++++-- src/ap/ctrl_iface_ap.h | 3 ++- src/ap/dfs.c | 30 ++++++++++++++++++++++++++++-- src/ap/hostapd.h | 3 +++ src/drivers/driver.h | 3 +++ src/drivers/driver_nl80211.c | 4 ++++ 9 files changed, 91 insertions(+), 6 deletions(-) diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index dbdc8c6..a56a068 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -1470,6 +1470,9 @@ static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx, } else if (os_strncmp(buf, "CHAN_SWITCH ", 12) == 0) { if (hostapd_ctrl_iface_chan_switch(hapd, buf + 12)) reply_len = -1; + } else if (os_strncmp(buf, "CAC_TIME", 8) == 0) { + reply_len = hostapd_ctrl_iface_cac_time(hapd, reply, + reply_size); } else { os_memcpy(reply, "UNKNOWN COMMAND\n", 16); reply_len = 16; diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c index 8caca4f..9431b58 100644 --- a/hostapd/hostapd_cli.c +++ b/hostapd/hostapd_cli.c @@ -940,6 +940,12 @@ static int hostapd_cli_cmd_chan_switch(struct wpa_ctrl *ctrl, } +static int hostapd_cli_cmd_cac_time(struct wpa_ctrl *ctrl, + int argc, char *argv[]) +{ + return wpa_ctrl_command(ctrl, "CAC_TIME"); +} + struct hostapd_cli_cmd { const char *cmd; int (*handler)(struct wpa_ctrl *ctrl, int argc, char *argv[]); @@ -988,6 +994,7 @@ static struct hostapd_cli_cmd hostapd_cli_commands[] = { { "chan_switch", hostapd_cli_cmd_chan_switch }, { "hs20_wnm_notif", hostapd_cli_cmd_hs20_wnm_notif }, { "hs20_deauth_req", hostapd_cli_cmd_hs20_deauth_req }, + { "cac_time", hostapd_cli_cmd_cac_time }, { NULL, NULL } }; diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c index b8b260a..21f88fa 100644 --- a/src/ap/ap_drv_ops.c +++ b/src/ap/ap_drv_ops.c @@ -771,8 +771,10 @@ int hostapd_start_dfs_cac(struct hostapd_iface *iface, int mode, int freq, return -1; res = hapd->driver->start_dfs_cac(hapd->drv_priv, &data); - if (!res) + if (!res) { iface->cac_started = 1; + os_get_time(&iface->dfs_cac_start); + } return res; } diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c index 8c0cbab..dbdba36 100644 --- a/src/ap/ctrl_iface_ap.c +++ b/src/ap/ctrl_iface_ap.c @@ -409,7 +409,8 @@ int hostapd_ctrl_iface_status(struct hostapd_data *hapd, char *buf, "num_sta_no_ht=%d\n" "num_sta_ht_20_mhz=%d\n" "olbc_ht=%d\n" - "ht_op_mode=0x%x\n", + "ht_op_mode=0x%x\n" + "dfs_cac_ms=%d\n", hostapd_state_text(iface->state), iface->phy, iface->freq, @@ -421,7 +422,8 @@ int hostapd_ctrl_iface_status(struct hostapd_data *hapd, char *buf, iface->num_sta_no_ht, iface->num_sta_ht_20mhz, iface->olbc_ht, - iface->ht_op_mode); + iface->ht_op_mode, + iface->dfs_cac_ms); if (ret < 0 || (size_t) ret >= buflen - len) return len; len += ret; @@ -508,3 +510,37 @@ int hostapd_parse_csa_settings(const char *pos, return 0; } + +int hostapd_ctrl_iface_cac_time(struct hostapd_data *hapd, char *buf, + size_t buflen) +{ + struct hostapd_iface *iface = hapd->iface; + int ret; + struct os_time now; + int left_time = 0; + + if (!iface->cac_started || !iface->dfs_cac_ms) { + ret = os_snprintf(buf, buflen, + "cac_time: %us\n" + "cac_left_time: N/A\n", + iface->dfs_cac_ms/1000); + if (ret < 0 || (size_t) ret >= buflen) + return 0; + return ret; + } + + /* CAC started and CAC time set - calc left time */ + os_get_time(&now); + left_time = iface->dfs_cac_ms/1000 - (now.sec - iface->dfs_cac_start.sec); + if (left_time < 0) + left_time = 0; + ret = os_snprintf(buf, buflen, + "cac_time: %us\n" + "cac_left_time: %ds\n", + iface->dfs_cac_ms/1000, + left_time); + if (ret < 0 || (size_t) ret >= buflen) + return 0; + + return ret; +} diff --git a/src/ap/ctrl_iface_ap.h b/src/ap/ctrl_iface_ap.h index ee58b4c..eb7947f 100644 --- a/src/ap/ctrl_iface_ap.h +++ b/src/ap/ctrl_iface_ap.h @@ -23,6 +23,7 @@ int hostapd_ctrl_iface_status(struct hostapd_data *hapd, char *buf, size_t buflen); int hostapd_parse_csa_settings(const char *pos, struct csa_settings *settings); - +int hostapd_ctrl_iface_cac_time(struct hostapd_data *hapd, char *buf, + size_t buflen); #endif /* CTRL_IFACE_AP_H */ diff --git a/src/ap/dfs.c b/src/ap/dfs.c index 2b8b90f..af26c68 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,9 +633,10 @@ 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", + "freq=%d chan=%d sec_chan=%d, cac_time: %ds", iface->freq, - iface->conf->channel, iface->conf->secondary_channel); + iface->conf->channel, iface->conf->secondary_channel, + iface->dfs_cac_ms/1000); if (hostapd_start_dfs_cac(iface, iface->conf->hw_mode, iface->freq, iface->conf->channel, diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h index 489ab16..e69e1d1 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_time 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 d2aad24..2d84cac 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 c509170..091559d 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -6154,6 +6154,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; @@ -6180,6 +6181,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]); }