From patchwork Fri Apr 4 11:28:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 3937811 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 D6D9BC0DA2 for ; Fri, 4 Apr 2014 11:40:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E43E3203F1 for ; Fri, 4 Apr 2014 11:40:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EE28D203E9 for ; Fri, 4 Apr 2014 11:40:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752706AbaDDLkn (ORCPT ); Fri, 4 Apr 2014 07:40:43 -0400 Received: from mail-we0-f176.google.com ([74.125.82.176]:44579 "EHLO mail-we0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752562AbaDDLfB (ORCPT ); Fri, 4 Apr 2014 07:35:01 -0400 Received: by mail-we0-f176.google.com with SMTP id x48so3180398wes.7 for ; Fri, 04 Apr 2014 04:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PY7zehGU8+t7j2RsdOJtyAyNn0DkOuv7H1d9DGxtowQ=; b=MRCSbY7pmZN/2J++9HuqPQFDze/9L1/0g1rrPsi1LvNqWPGnBDkubUMEHeSOnK2k3s x9t/FK4baLHaAyqMzdl7qoxtR5AvEHml/K17VJS2OaYtpv/C+CLmzdYYZWEntcfZ7mSp D/brcoU7OY7NVLH0jujIvPolv9uUdT8LJpodQ= 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:in-reply-to :references; bh=PY7zehGU8+t7j2RsdOJtyAyNn0DkOuv7H1d9DGxtowQ=; b=H2wfCxLYhFmehJaVTJT34RBm96G8wWG7lBHE/YtstdamkHJ9G/hVWaFkk0tX7Jo4St kOBSMyh5yxQvlY8SjhD+96FYXRjJQbi3TroDhjlAw+JOOHIb3WAKch/Dm7blyv2/YsMq ztj3UN+vfR5uwF6uanGbQSxVyeieq/F1CucdxwMM0aQzEEjXggBhbiXUaYFagz4KPFqE +KuIauK1SqfJVQWYVwUZWZiRlLUTLtsF3l8+R3OhSsztItz8XBXMItn92O+jB5d56ouY SYj7obLA6Vbg+UpQS5ijizkfhCzPFvRrFgQSd4cZO+9qCssjTaJuBPSFlNGUE9O12ELA ahAw== X-Gm-Message-State: ALoCoQkhNmYyhexkSQzl65GTClHPIokimfdvSRl9QfMo4iICpQUj3aXvB8X4DlGmX20dunYIsOwWz4I2z9HL7aIKRPgRiZF1C831vVsMZK3qpRWp1q7zaJg= X-Received: by 10.180.211.208 with SMTP id ne16mr3723134wic.21.1396611299524; Fri, 04 Apr 2014 04:34:59 -0700 (PDT) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id 48sm18988131eee.2.2014.04.04.04.34.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Apr 2014 04:34:59 -0700 (PDT) From: Michal Kazior To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Michal Kazior Subject: [PATCH v2 2/2] ath10k: refactor radar detection code Date: Fri, 4 Apr 2014 13:28:46 +0200 Message-Id: <1396610926-5787-3-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1396610926-5787-1-git-send-email-michal.kazior@tieto.com> References: <1396337123-12622-1-git-send-email-michal.kazior@tieto.com> <1396610926-5787-1-git-send-email-michal.kazior@tieto.com> 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.4 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 If 20MHz CAC completed successfully then subsequent CAC with wider bandwidth (40Mhz, 80Mhz) with identical control frequency did not start monitor vdev making it impossible to detect any radar pulses during intended CAC. It also was incorrect to assume ath10k_config() will be called after CAC is finished. Theoretically for non-HT channels nothing changes between CAC and start_ap() (albeit in practice this can be different). The incorrect assumption led to CAC not being stopped on non-HT chandefs leading to all Rx being drooped making it impossible for clients to associate. While at it clean up the code a bit. Signed-off-by: Michal Kazior --- v2: * change locking comment style [Kalle] * get rid of forward declaration [Kalle] * fix vdev_stop / WARN_ON (missing !) [Kalle] * change commit message (the original issue found was CAC not being stopped for non-HT channels but this was a side-effect of a mac80211 bug, although the use of hw->conf.radar_enabled in ath10k was also incorrect either way) drivers/net/wireless/ath/ath10k/core.h | 4 +++ drivers/net/wireless/ath/ath10k/mac.c | 54 +++++++++++----------------------- 2 files changed, 21 insertions(+), 37 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h index 8edd6da..5cb9903 100644 --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h @@ -435,6 +435,10 @@ struct ath10k { unsigned long dev_flags; u32 dfs_block_radar_events; + /* protected by conf_mutex */ + bool radar_enabled; + int num_started_vdevs; + struct wmi_pdev_set_wmm_params_arg wmm_params; struct completion install_key_done; diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index e1f4227..3333b1f 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -719,49 +719,18 @@ static int ath10k_stop_cac(struct ath10k *ar) return 0; } -static const char *ath10k_dfs_state(enum nl80211_dfs_state dfs_state) +static void ath10k_recalc_radar_detection(struct ath10k *ar) { - switch (dfs_state) { - case NL80211_DFS_USABLE: - return "USABLE"; - case NL80211_DFS_UNAVAILABLE: - return "UNAVAILABLE"; - case NL80211_DFS_AVAILABLE: - return "AVAILABLE"; - default: - WARN_ON(1); - return "bug"; - } -} - -static void ath10k_config_radar_detection(struct ath10k *ar) -{ - struct ieee80211_channel *chan = ar->hw->conf.chandef.chan; - bool radar = ar->hw->conf.radar_enabled; - bool chan_radar = !!(chan->flags & IEEE80211_CHAN_RADAR); - enum nl80211_dfs_state dfs_state = chan->dfs_state; int ret; lockdep_assert_held(&ar->conf_mutex); - ath10k_dbg(ATH10K_DBG_MAC, - "mac radar config update: chan %dMHz radar %d chan radar %d chan state %s\n", - chan->center_freq, radar, chan_radar, - ath10k_dfs_state(dfs_state)); - - /* - * It's safe to call it even if CAC is not started. - * This call here guarantees changing channel, etc. will stop CAC. - */ ath10k_stop_cac(ar); - if (!radar) - return; - - if (!chan_radar) + if (!ar->radar_enabled) return; - if (dfs_state != NL80211_DFS_USABLE) + if (ar->num_started_vdevs > 0) return; ret = ath10k_start_cac(ar); @@ -832,6 +801,9 @@ static int ath10k_vdev_start(struct ath10k_vif *arvif) return ret; } + ar->num_started_vdevs++; + ath10k_recalc_radar_detection(ar); + return ret; } @@ -858,6 +830,11 @@ static int ath10k_vdev_stop(struct ath10k_vif *arvif) return ret; } + if (!WARN_ON(ar->num_started_vdevs == 0)) { + ar->num_started_vdevs--; + ath10k_recalc_radar_detection(ar); + } + return ret; } @@ -2341,6 +2318,7 @@ static int ath10k_start(struct ieee80211_hw *hw) goto exit; } + ar->num_started_vdevs = 0; ath10k_regd_update(ar); ret = 0; @@ -2490,15 +2468,17 @@ static int ath10k_config(struct ieee80211_hw *hw, u32 changed) if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { ath10k_dbg(ATH10K_DBG_MAC, - "mac config channel %d mhz flags 0x%x\n", + "mac config channel %dMHz flags 0x%x radar %d\n", conf->chandef.chan->center_freq, - conf->chandef.chan->flags); + conf->chandef.chan->flags, + conf->radar_enabled); spin_lock_bh(&ar->data_lock); ar->rx_channel = conf->chandef.chan; spin_unlock_bh(&ar->data_lock); - ath10k_config_radar_detection(ar); + ar->radar_enabled = conf->radar_enabled; + ath10k_recalc_radar_detection(ar); if (!cfg80211_chandef_identical(&ar->chandef, &conf->chandef)) { ar->chandef = conf->chandef;