From patchwork Mon Dec 15 17:20:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arik Nemtsov X-Patchwork-Id: 5495891 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 A39DEBEEA8 for ; Mon, 15 Dec 2014 17:21:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C90BC209F9 for ; Mon, 15 Dec 2014 17:21:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB31820A13 for ; Mon, 15 Dec 2014 17:21:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750881AbaLORVE (ORCPT ); Mon, 15 Dec 2014 12:21:04 -0500 Received: from mail-wi0-f182.google.com ([209.85.212.182]:33801 "EHLO mail-wi0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750768AbaLORVD (ORCPT ); Mon, 15 Dec 2014 12:21:03 -0500 Received: by mail-wi0-f182.google.com with SMTP id h11so9757100wiw.15 for ; Mon, 15 Dec 2014 09:21:01 -0800 (PST) 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=PE4ndT9gPwzPS3QCvfekRAt6zG+Z6Esh8SA0rZQmgtU=; b=ZROYL7AxEoS5vChJw51xc0YICplvfnnDOflqbZvNVSdYsWqkH8Xr5/qJCe0iijd+DM rvqkFE1F8U1LUxjA85Ez2WixdIdKZxNOvlKZWKejywODfJsFsDZz4xfnPg+1VLj3vrfT LaXpRZBhCxlCI8pdsbr6R9e4NoUk4+ACNU1jtceD1DY6kwxwdeW4nDT3QiUBygUXRZ8W uI6z9VOjlpJ3SiKeRTwOqpnqJKCjLEKB7P2GNaxRZhoFJ1AjCevwdHnWOp5VY2a0BoM/ M5dPVvjs0J3ejR/wkogeoXJ4XkfG88C2iTZjgUDNwPdImBOShSbEatDG+5oXOx7gvN+U Uhqg== X-Gm-Message-State: ALoCoQlo90llOtO4Jq1y9vj9r2Fogjbaf60ZiByn+lFXbdtSp55vpawELdk/d6G48t08LvDUuY7v X-Received: by 10.194.172.72 with SMTP id ba8mr54838717wjc.13.1418664061132; Mon, 15 Dec 2014 09:21:01 -0800 (PST) Received: from athena.amr.corp.intel.com (85-250-108-142.bb.netvision.net.il. [85.250.108.142]) by mx.google.com with ESMTPSA id ry19sm13792860wjb.3.2014.12.15.09.20.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Dec 2014 09:21:00 -0800 (PST) From: Arik Nemtsov To: Cc: Johannes Berg , "Luis R. Rodriguez" , Arik Nemtsov Subject: [PATCH v9 4/4] cfg80211: avoid intersection when applying self-managed reg Date: Mon, 15 Dec 2014 19:20:55 +0200 Message-Id: <1418664055-3963-4-git-send-email-arik@wizery.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418664055-3963-1-git-send-email-arik@wizery.com> References: <1418664055-3963-1-git-send-email-arik@wizery.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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, 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 The custom-reg handling function can currently only add flags to a given channel. This results in stale flags being left applied. In some cases a channel was disabled and even the orig_flags were changed to reflect this. Previously the API was designed for a single invocation before wiphy registration, so this didn't matter. The previous approach doesn't scale well to self-managed regulatory devices, particularly when a more permissive regdom is applied after a restrictive one. Signed-off-by: Arik Nemtsov --- net/wireless/reg.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 87ef745..8aaff02 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -1686,8 +1686,12 @@ static void handle_channel_custom(struct wiphy *wiphy, if (IS_ERR(reg_rule)) { REG_DBG_PRINT("Disabling freq %d MHz as custom regd has no rule that fits it\n", chan->center_freq); - chan->orig_flags |= IEEE80211_CHAN_DISABLED; - chan->flags = chan->orig_flags; + if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) { + chan->flags |= IEEE80211_CHAN_DISABLED; + } else { + chan->orig_flags |= IEEE80211_CHAN_DISABLED; + chan->flags = chan->orig_flags; + } return; } @@ -1712,7 +1716,13 @@ static void handle_channel_custom(struct wiphy *wiphy, chan->dfs_state = NL80211_DFS_USABLE; chan->beacon_found = false; - chan->flags |= map_regdom_flags(reg_rule->flags) | bw_flags; + + if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) + chan->flags = chan->orig_flags | bw_flags | + map_regdom_flags(reg_rule->flags); + else + chan->flags |= map_regdom_flags(reg_rule->flags) | bw_flags; + chan->max_antenna_gain = (int) MBI_TO_DBI(power_rule->max_antenna_gain); chan->max_reg_power = chan->max_power = (int) MBM_TO_DBM(power_rule->max_eirp);