From patchwork Mon Nov 18 09:36:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Puzyniak X-Patchwork-Id: 3195801 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 2E5979F3AE for ; Mon, 18 Nov 2013 09:37:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F113E2069C for ; Mon, 18 Nov 2013 09:37:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB0D0206A1 for ; Mon, 18 Nov 2013 09:37:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751339Ab3KRJhJ (ORCPT ); Mon, 18 Nov 2013 04:37:09 -0500 Received: from mail-ee0-f51.google.com ([74.125.83.51]:59868 "EHLO mail-ee0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751194Ab3KRJhI (ORCPT ); Mon, 18 Nov 2013 04:37:08 -0500 Received: by mail-ee0-f51.google.com with SMTP id d41so1633047eek.24 for ; Mon, 18 Nov 2013 01:37:06 -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=WDSF84xeB/ialgRtwIOtlwGqahgz+yvLQVRIWa2/LXE=; b=slGKRZV3TruepkYRttAH6dgBsKF/rPA95djNiTZaXMvh5xXLUVSGYZkzp+K2ksLRl+ Ic4Emn1nzwHoBwP2j6uSvH1HfHorYvEZrLGVk2NE/B9YQWVSR3FxjdtmFz5G+yRwO+qq 46Hawdco5SJq6VzoYwntlV1LHO0YBVF8nPl4Y= 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=WDSF84xeB/ialgRtwIOtlwGqahgz+yvLQVRIWa2/LXE=; b=b8nFWTEgyz8qmtNhrVjNsczRQjwT+aNmFOEg504cI4tdWozfoBom6KvUPFLccbxeBL eiJkCJzyXO0ujlW7g1BBYD/gKexgkMYpR1p90f2clbNjlTD1PXgX4DYFKCcCGTNDc59V EfeUrC1/ihXfxkB3g3eeCH6QTPf6k6If1wzrZg6asbzTME+p1QfeF7ZPSLmYnGk9a5Nw IYonG6PBYXS3dnZtiLev6Kgm7BrorM9yCH4mfffL/PWu+jE9EJpGKNB1jKu4hz0v4Q7g lyuMYhV4094SXEXqCsF5RazdKBia0eb/UJiBu+P2XeSbEn+2k/wfGhh96QXZe3WDsyR7 EPMA== X-Gm-Message-State: ALoCoQk/KQy4pAN4/b5MWOObBmDZys0JwH9QW1CAm89IfkUjHW0X9PyxKDLouwqKMnbe6fCV5Yz62EoQDuaEFd2jRAvP9jF7qas3yfRjHKcN7Imfi2naLUg= X-Received: by 10.14.3.130 with SMTP id 2mr19891688eeh.36.1384767426415; Mon, 18 Nov 2013 01:37:06 -0800 (PST) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id a45sm18780515eem.6.2013.11.18.01.37.05 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 18 Nov 2013 01:37:05 -0800 (PST) From: Marek Puzyniak To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, Marek Puzyniak Subject: [PATCH v2] cfg80211: fix dfs channel state after stopping AP Date: Mon, 18 Nov 2013 10:36:53 +0100 Message-Id: <1384767413-5648-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 This can be called when a mode of operation that can supports initiating radiation on a DFS channel leaves that channel to ensure that if the mode of operation is started again on it that it will require a new channel availability check. Signed-off-by: Marek Puzyniak --- net/wireless/ap.c | 3 +++ net/wireless/chan.c | 39 +++++++++++++++++++++++++++++++++++++++ net/wireless/core.h | 11 +++++++++++ 3 files changed, 53 insertions(+) diff --git a/net/wireless/ap.c b/net/wireless/ap.c index 324e8d8..9349773 100644 --- a/net/wireless/ap.c +++ b/net/wireless/ap.c @@ -26,6 +26,9 @@ static int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev, err = rdev_stop_ap(rdev, dev); if (!err) { + if (cfg80211_chandef_dfs_required(wdev->wiphy, &wdev->preset_chandef)) + cfg80211_leave_dfs_chandef(wdev->wiphy, &wdev->preset_chandef); + wdev->beacon_interval = 0; wdev->channel = NULL; wdev->ssid_len = 0; diff --git a/net/wireless/chan.c b/net/wireless/chan.c index 2ac4cac..bf85247 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c @@ -489,6 +489,45 @@ 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->flags & IEEE80211_CHAN_RADAR)) + continue; + if (c->dfs_state != NL80211_DFS_AVAILABLE) + continue; + + cfg80211_set_chans_dfs_state(wiphy, freq, 20, NL80211_DFS_USABLE); + } +} + +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 2888867..76dfe6b 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h @@ -401,6 +401,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,