From patchwork Mon Mar 31 10:39:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 3913571 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 2977B9F357 for ; Mon, 31 Mar 2014 11:43:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4EE78203AC for ; Mon, 31 Mar 2014 11:43:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 677A120386 for ; Mon, 31 Mar 2014 11:43:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752274AbaCaLnK (ORCPT ); Mon, 31 Mar 2014 07:43:10 -0400 Received: from mail-wi0-f182.google.com ([209.85.212.182]:40027 "EHLO mail-wi0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752623AbaCaLnG (ORCPT ); Mon, 31 Mar 2014 07:43:06 -0400 Received: by mail-wi0-f182.google.com with SMTP id d1so3124371wiv.9 for ; Mon, 31 Mar 2014 04:43:05 -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=GtBvU7CImjX5wy6bk+2cH3Cs+dzxcZlMqGFNuXXy6J8=; b=UGRHMwnFIY+jqCwL0slslSeOgbRs+o35RxJ/yXcl/XFISwLDrh98W2DigBJD3KFeI5 fN/kB7Y9seh74A2nTQaS14uhee2dtMb4zn7O96G86kgkJK1+vHOmxQrAkVT1p68BaAvA yqsDGa02r0xT4tjnYx861Vp2PmjNgUciVAmTo= 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=GtBvU7CImjX5wy6bk+2cH3Cs+dzxcZlMqGFNuXXy6J8=; b=RKM0nmBy2xKy7e84XyYr9fpR0zGy6TFlYH/tGu12EOEQZwBWVfAcGj0qN59U/CBcUz ZlzO4yaKCJbjuyV0HKlpOVeFyad2mq9NaG0ptmlc2HKloHKBEu/vMJYJIvJFJpcp6Xm9 oebpaSD4cDfDoyhKtNwELLB19MJFCIGrhlrOcK+I80iXeJNVISmbfWVyUUn5zEOQQ2nF JLwwsyJxulr0kgWrpbIwCX6j41bBK13Ucts8vln8w75ZxohFTo0lHu06ynpwoC5n1gaQ 31JHFG0ML+z3xlaUD4RJZEEXUpmUM81ApSpOqHe6p5dW/Re8rZdsfklif9aOij70RKdB Y/IQ== X-Gm-Message-State: ALoCoQl2GxOH9RMG0uOs7/y7poyQqRAn45gf9aXQzSIztK4UDJnDWJWwGoGW4jtal7B30Nsp2yGjG8whuPm1AQhTA8z+gXp0fpUCVHnzE3TcAOpLDrNAAqU= X-Received: by 10.194.57.77 with SMTP id g13mr12558125wjq.42.1396266185394; Mon, 31 Mar 2014 04:43:05 -0700 (PDT) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id q49sm32467516eem.34.2014.03.31.04.43.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Mar 2014 04:43:04 -0700 (PDT) From: Michal Kazior To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, Michal Kazior Subject: [PATCH v3 02/13] mac80211: add max channel calculation utility function Date: Mon, 31 Mar 2014 12:39:20 +0200 Message-Id: <1396262371-6466-3-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1396262371-6466-1-git-send-email-michal.kazior@tieto.com> References: <1395409651-26120-1-git-send-email-michal.kazior@tieto.com> <1396262371-6466-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 The utility function has no uses yet. It is aimed at future chanctx reservation management and channel switching. Signed-off-by: Michal Kazior --- net/mac80211/ieee80211_i.h | 1 + net/mac80211/util.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 02fe9f4..41d9e49 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1830,6 +1830,7 @@ int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata, const struct cfg80211_chan_def *chandef, enum ieee80211_chanctx_mode chanmode, u8 radar_detect); +int ieee80211_max_num_channels(struct ieee80211_local *local); #ifdef CONFIG_MAC80211_NOINLINE #define debug_noinline noinline diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 639bc13..09c4794 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -2877,3 +2877,46 @@ int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata, num_different_channels, radar_detect, num); } + +static void +ieee80211_iter_max_chans(const struct ieee80211_iface_combination *c, + void *data) +{ + u32 *max_num_different_channels = data; + + *max_num_different_channels = max(*max_num_different_channels, + c->num_different_channels); +} + +int ieee80211_max_num_channels(struct ieee80211_local *local) +{ + struct ieee80211_sub_if_data *sdata; + int num[NUM_NL80211_IFTYPES] = {}; + struct ieee80211_chanctx *ctx; + int num_different_channels = 0; + u8 radar_detect = 0; + u32 max_num_different_channels = 1; + int err; + + lockdep_assert_held(&local->chanctx_mtx); + + list_for_each_entry(ctx, &local->chanctx_list, list) { + num_different_channels++; + + if (ctx->conf.radar_enabled) + radar_detect |= BIT(ctx->conf.def.width); + } + + list_for_each_entry_rcu(sdata, &local->interfaces, list) { + num[sdata->wdev.iftype]++; + } + + err = cfg80211_iter_combinations(local->hw.wiphy, + num_different_channels, radar_detect, + num, ieee80211_iter_max_chans, + &max_num_different_channels); + if (err < 0) + return err; + + return max_num_different_channels; +}