From patchwork Tue Dec 3 12:24:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Puzyniak X-Patchwork-Id: 3275401 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4A664C0D4A for ; Tue, 3 Dec 2013 12:25:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 11A512037F for ; Tue, 3 Dec 2013 12:25:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 879C02037D for ; Tue, 3 Dec 2013 12:24:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753252Ab3LCMYu (ORCPT ); Tue, 3 Dec 2013 07:24:50 -0500 Received: from mail-ee0-f45.google.com ([74.125.83.45]:49841 "EHLO mail-ee0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753212Ab3LCMYq (ORCPT ); Tue, 3 Dec 2013 07:24:46 -0500 Received: by mail-ee0-f45.google.com with SMTP id d49so1436934eek.32 for ; Tue, 03 Dec 2013 04:24:44 -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=GngSFUaaIs2NCjoUmxgEuE/kejLeiE7xPGAOTYwvvD8=; b=QCjM/jzA5qjoazSbvgbvtYUq2byDPoOFjPQF5adDSWIrGa6iSKKRMVM9QvO9WPyBcL bRYJZjHNuA+1h+Ghm4x8me4monInID8Gawr6txck+T24dPPWdOvANJ9khjWHb5u8l67j 8X78j5YG+ezlDvPPjRZYWA+dYY5wVj1Ndlib0= 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=GngSFUaaIs2NCjoUmxgEuE/kejLeiE7xPGAOTYwvvD8=; b=PX3RIe49URbXbrt6UMBTvrzOrvZV1iE889QQ1x7lNcdh8/wNcwrVWDwwKIp4bNoZar idI5dKD0x7YqJDP9SfmIwXZlsrXh+tDrUxSy9RHDvnxJWiHtDz2Fb16Qqrlei6bVMDDh 01xS3aBUIa245OjpTnBiSlJIoyr5tyCrW87urdL0HNyjFZuGDK5Nn/xcALem2KCOjQrM kA6QfH63hhEXkH6Xsxu4gn2zqTTi8Hoa1hcemxV7mgI/sNqq+h0iyUAmOOksY9dxHni8 OSSGgORWO/L4ouhoWi+PlQOYM47y4SrwGyneiab0vplEenp8LYcIJ7+G4lBfNAjr/zuj /iuQ== X-Gm-Message-State: ALoCoQkRQyzKJpJN23lsbHxx2aIhcPe+rCLMNk4AP5P9APolnsd6V2sFSghgXJ2p0Hj5FKOk1t/5vctTqoFammiNSTPgXqb2xZgUvG5G0yt0hfGhVzLtiQQ= X-Received: by 10.14.150.5 with SMTP id y5mr2547241eej.73.1386073484629; Tue, 03 Dec 2013 04:24:44 -0800 (PST) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id g47sm82024124eeo.19.2013.12.03.04.24.43 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Dec 2013 04:24:44 -0800 (PST) From: Marek Puzyniak To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, Marek Puzyniak Subject: [PATCH v3] cfg80211: fix dfs channel state after stopping AP Date: Tue, 3 Dec 2013 13:24:26 +0100 Message-Id: <1386073466-2641-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=-6.8 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 back to DFS_USABLE. Starting AP again on that channel will start CAC instead of starting radiation. 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 78559b5..f0cf780 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c @@ -490,6 +490,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 6716c5c..ca230a2 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h @@ -400,6 +400,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,