From patchwork Mon Dec 16 15:50:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Puzyniak X-Patchwork-Id: 3355401 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C1B159F314 for ; Mon, 16 Dec 2013 15:51:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7987420107 for ; Mon, 16 Dec 2013 15:51:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 22BCF200E7 for ; Mon, 16 Dec 2013 15:51:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754327Ab3LPPvI (ORCPT ); Mon, 16 Dec 2013 10:51:08 -0500 Received: from mail-ee0-f42.google.com ([74.125.83.42]:60182 "EHLO mail-ee0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754143Ab3LPPvG (ORCPT ); Mon, 16 Dec 2013 10:51:06 -0500 Received: by mail-ee0-f42.google.com with SMTP id e53so2336063eek.1 for ; Mon, 16 Dec 2013 07:51:05 -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=izNWiLCYCLw3d4j1VmdbxwrbqANybqme8w07G0gqn/Y=; b=VwhsPWDtCnhY/V4RISMqEZ829FOuDLReCSbEMKE/8Vyb9zARZ4dsGk9corSNoVXtNv VbCrhRZ96RwcxnGBLFN63wT4Ws9VzOyGtC0mc/seSPDq1+YQyFioPe4pJ5i3lfHcy37C R851JzRVo7YWcfUcBRhVmvoykXjFuS3bq1MUM= 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=izNWiLCYCLw3d4j1VmdbxwrbqANybqme8w07G0gqn/Y=; b=fBtvjIpm4d5KZZtU9MPEbXE+aZGIEWvAije0yXXePV1iNBA+9Pwqo2xoH9o+x8YvF9 YTKgSOmWWijeiU85h7aVNV++NoUklUPgNgsIMOTwUicxYsQdLmqAs6t7iNGHFg2S+zWn CMY3CQeI6HL3tnONkLVgu/GONUGXFdrtQg1ktJCPU3I5xrRU2g9kYt2ORjiaGrCHZJ6a SVzf9yX7foQbg8PG3FWGGUFblJsvFAiiYCbJcxRFRDro2SGQfieFkLOHTa4yPBnepEfi ptqHOA9J/jrZCk5zmzVGssxal9erhpZKlDvANjAAZoh7WgxDI40d9htZj8hW7RXo4vIc mRXQ== X-Gm-Message-State: ALoCoQkmPQrbWG2udWJnF5T4bXBTmdRQW/jjmarD+r2MvrIWkQYlcx97FW093r93vSECt7fYqQK51y6GeV0dzyrxMArkpXaVvqxM2KCrU96vF+8+nvrkvWw= X-Received: by 10.14.114.71 with SMTP id b47mr17802230eeh.26.1387209065538; Mon, 16 Dec 2013 07:51:05 -0800 (PST) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id o1sm43644867eea.10.2013.12.16.07.51.04 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Dec 2013 07:51:04 -0800 (PST) From: Marek Puzyniak To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, Marek Puzyniak Subject: [PATCH v5] cfg80211: fix dfs channel state after stopping AP Date: Mon, 16 Dec 2013 16:50:49 +0100 Message-Id: <1387209049-25529-1-git-send-email-marek.puzyniak@tieto.com> X-Mailer: git-send-email 1.8.1.2 X-DomainID: tieto.com Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In AP mode DFS channel state is changed to DFS_AVAILABLE after successful CAC and remains as such until a radar signal is detected during the In-Service Monitoring. When AP is stopped it is no longer monitoring current channel for radar signals. DFS channel state should be changed to DFS_USABLE when last AP interface is stopped. Starting AP again on that channel will start CAC instead of starting radiation. Signed-off-by: Marek Puzyniak --- Patch v1: *Initial version. Partially in mac80211 and cfg80211. Patch v2: *Moved all implementation to cfg80211. Patch v3: *Rephrase patch description. Patch v4: *Fix coding style, *Do not check if RADAR flag is set, when dfs channel state was AVAILABLE change it to USABLE, *Handle multiBSSID APs - Change DFS channel state when last AP was stoped. Patch v5: *Fix coding style, *Remove unnecessary and nested wdev_lock. net/wireless/ap.c | 36 ++++++++++++++++++++++++++++++++++++ net/wireless/chan.c | 38 ++++++++++++++++++++++++++++++++++++++ net/wireless/core.h | 11 +++++++++++ 3 files changed, 85 insertions(+) diff --git a/net/wireless/ap.c b/net/wireless/ap.c index 324e8d8..28d1a3c 100644 --- a/net/wireless/ap.c +++ b/net/wireless/ap.c @@ -6,6 +6,39 @@ #include "rdev-ops.h" +static bool cfg80211_is_last_ap_running(struct cfg80211_registered_device *rdev, + struct net_device *dev) +{ + struct wireless_dev *wdev = dev->ieee80211_ptr; + struct wireless_dev *wdev_iter; + + ASSERT_WDEV_LOCK(wdev); + + if (rdev->num_running_ifaces == 1) { + /* Last running AP iface */ + return true; + } + + /* More running interfaces */ + list_for_each_entry(wdev_iter, &rdev->wdev_list, list) { + if (wdev_iter == wdev) + continue; + + if (!wdev_iter->netdev) + continue; + + if (!netif_running(wdev_iter->netdev)) { + continue; + } + + if (wdev_iter->iftype == NL80211_IFTYPE_AP) { + return false; + } + } + + return true; +} + static int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev, struct net_device *dev) { @@ -31,6 +64,9 @@ static int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev, wdev->ssid_len = 0; } + if (cfg80211_is_last_ap_running(rdev, dev)) + cfg80211_leave_dfs_chandef(wdev->wiphy, &wdev->preset_chandef); + return err; } diff --git a/net/wireless/chan.c b/net/wireless/chan.c index 78559b5..54c217a 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c @@ -490,6 +490,44 @@ static bool cfg80211_chandef_dfs_available(struct wiphy *wiphy, return r; } +static void cfg80211_leave_dfs_chans(struct wiphy *wiphy, + u32 center_freq, + u32 bandwidth) +{ + struct ieee80211_channel *c; + u32 freq, start_freq, end_freq; + + start_freq = cfg80211_get_start_freq(center_freq, bandwidth); + end_freq = cfg80211_get_end_freq(center_freq, bandwidth); + + for (freq = start_freq; freq <= end_freq; freq += 20) { + c = ieee80211_get_channel(wiphy, freq); + if (!c) + continue; + if (c->dfs_state != NL80211_DFS_AVAILABLE) + continue; + + c->dfs_state = NL80211_DFS_USABLE; + c->dfs_state_entered = jiffies; + } +} + +void cfg80211_leave_dfs_chandef(struct wiphy *wiphy, + struct cfg80211_chan_def *chandef) +{ + int width; + + if (WARN_ON(!cfg80211_chandef_valid(chandef))) + return; + + width = cfg80211_chandef_get_width(chandef); + cfg80211_leave_dfs_chans(wiphy, chandef->center_freq1, width); + + if (!chandef->center_freq2) + return; + + cfg80211_leave_dfs_chans(wiphy, chandef->center_freq2, width); +} static bool cfg80211_secondary_chans_ok(struct wiphy *wiphy, u32 center_freq, u32 bandwidth, diff --git a/net/wireless/core.h b/net/wireless/core.h index 37ec16d..4ed2c81 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h @@ -398,6 +398,17 @@ void cfg80211_set_dfs_state(struct wiphy *wiphy, void cfg80211_dfs_channels_update_work(struct work_struct *work); +/** + * cfg80211_leave_dfs_chandef - Leaving dfs chandef + * @wiphy: the wiphy + * @chandef: chandef for the current channel + * + * This function is called when dfs chandef is being not used for different + * reasons. Change channels DFS_AVAILABLE to DFS_USABLE again. Leave channels + * DFS_UNAVAILABLE untouched. + */ +void cfg80211_leave_dfs_chandef(struct wiphy *wiphy, + struct cfg80211_chan_def *chandef); static inline int cfg80211_can_change_interface(struct cfg80211_registered_device *rdev,