From patchwork Fri Mar 21 13:47:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 3874311 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 CE64E9F382 for ; Fri, 21 Mar 2014 13:53:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F1DBA2027D for ; Fri, 21 Mar 2014 13:53:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1123F20279 for ; Fri, 21 Mar 2014 13:53:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760945AbaCUNxe (ORCPT ); Fri, 21 Mar 2014 09:53:34 -0400 Received: from mail-ee0-f44.google.com ([74.125.83.44]:54086 "EHLO mail-ee0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760937AbaCUNxc (ORCPT ); Fri, 21 Mar 2014 09:53:32 -0400 Received: by mail-ee0-f44.google.com with SMTP id e49so1829180eek.17 for ; Fri, 21 Mar 2014 06:53:31 -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=jEqap6zhA2jcDg9sGN5Ef3GmZxdYubnDbgBgzuo3wDk=; b=NdSN+AIHwvHGdNHaOLc8hDjLqUj3S6Y0Q+MpcpD1pAICsC6Q8HJniOmOveteOpGSjm UNezwsND6gZ12gbfEYh2//F+M8Lfzq4lC7UEZggXcw/PgZSIE4v0ehM0B8Q4irIEQpsb rWyy8Kp5+JQPmo/NkyFU7gXhzWLLVuGPMArAo= 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=jEqap6zhA2jcDg9sGN5Ef3GmZxdYubnDbgBgzuo3wDk=; b=Cs8Fhj4W9FYVu8s0L+jF1LP+BDIheqyWzSBnPnm0c/32ZnwK0REVhVy6UBqS6UANWV o9AT81olnAqdanPH+tIVHAolJfWg2tSG6MvqW7Ll/LP2jX5YQrAZB/l+YqM3zTPyS3kv UqpvuRt+3cgnx3h8ChEjZGQ3XXf+79Uo4l4WXwZxoNOsx76sS7c9gBFe908ThbjV0Cyg 7sgB4JRCYY8N85kZDlGAoWOwVOvN2+0Vgie2303WKHLwb6j08b69m1BbcQMwkwQd2E6Q IuPiPAM8NX0GTRMDD+ZNhEBumFuHU2+EM4c9c0N6iEYHcI1atrjUr3wQuW/KjP3Yswiq 5s5w== X-Gm-Message-State: ALoCoQkDC2PBz8rtCtkUliDKx2uG8G1i3+IAa/BcSSFQ+GiqMr0Gbt8Ut57qQ/K0D1ZkU5rGw6oxwZoUUSkgemJMwKKh3yvPxjZURcjy1w2VN3b5mzKlx3s= X-Received: by 10.14.251.204 with SMTP id b52mr25935774ees.36.1395410011154; Fri, 21 Mar 2014 06:53:31 -0700 (PDT) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id o7sm11719458eew.25.2014.03.21.06.53.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Mar 2014 06:53:30 -0700 (PDT) From: Michal Kazior To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, Michal Kazior Subject: [PATCH v2 01/13] cfg80211: allow drivers to iterate over matching combinations Date: Fri, 21 Mar 2014 14:47:19 +0100 Message-Id: <1395409651-26120-2-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1395409651-26120-1-git-send-email-michal.kazior@tieto.com> References: <1395150804-24090-1-git-send-email-michal.kazior@tieto.com> <1395409651-26120-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=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,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 patch splits cfg80211_check_combinations() into an iterator function and a simple iteration user. This makes it possible for drivers to asses how many channels can use given iftype setup. This in turn can be used for future multi-interface/multi-channel channel switching. Signed-off-by: Michal Kazior --- include/net/cfg80211.h | 27 +++++++++++++++++++++++++++ net/wireless/util.c | 44 +++++++++++++++++++++++++++++++++++++------- 2 files changed, 64 insertions(+), 7 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 7f0cbfb..21766b9 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -4720,6 +4720,33 @@ int cfg80211_check_combinations(struct wiphy *wiphy, */ void cfg80211_stop_iface(struct wiphy *wiphy, struct wireless_dev *wdev); +/** + * cfg80211_iter_combinations - iterate over matching combinations + * + * @wiphy: the wiphy + * @num_different_channels: the number of different channels we want + * to use for verification + * @radar_detect: a bitmap where each bit corresponds to a channel + * width where radar detection is needed, as in the definition of + * &struct ieee80211_iface_combination.@radar_detect_widths + * @iftype_num: array with the numbers of interfaces of each interface + * type. The index is the interface type as specified in &enum + * nl80211_iftype. + * @iter: function to call for each matching combination + * @data: pointer to pass to iter function + * + * This function can be called by the driver to check what possible + * combinations it fits in at a given moment, e.g. for channel switching + * purposes. + */ +int cfg80211_iter_combinations(struct wiphy *wiphy, + const int num_different_channels, + const u8 radar_detect, + const int iftype_num[NUM_NL80211_IFTYPES], + void (*iter)(const struct ieee80211_iface_combination *c, + void *data), + void *data); + /* Logging, debugging and troubleshooting/diagnostic helpers. */ /* wiphy_printk helpers, similar to dev_printk */ diff --git a/net/wireless/util.c b/net/wireless/util.c index 241f0ad..7fa3503 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -1252,10 +1252,13 @@ int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev, return res; } -int cfg80211_check_combinations(struct wiphy *wiphy, - const int num_different_channels, - const u8 radar_detect, - const int iftype_num[NUM_NL80211_IFTYPES]) +int cfg80211_iter_combinations(struct wiphy *wiphy, + const int num_different_channels, + const u8 radar_detect, + const int iftype_num[NUM_NL80211_IFTYPES], + void (*iter)(const struct ieee80211_iface_combination *c, + void *data), + void *data) { int i, j, iftype; int num_interfaces = 0; @@ -1312,13 +1315,40 @@ int cfg80211_check_combinations(struct wiphy *wiphy, /* This combination covered all interface types and * supported the requested numbers, so we're good. */ - kfree(limits); - return 0; + + (*iter)(c, data); cont: kfree(limits); } - return -EBUSY; + return 0; +} +EXPORT_SYMBOL(cfg80211_iter_combinations); + +static void +cfg80211_iter_sum_ifcombs(const struct ieee80211_iface_combination *c, + void *data) +{ + int *num = data; + (*num)++; +} + +int cfg80211_check_combinations(struct wiphy *wiphy, + const int num_different_channels, + const u8 radar_detect, + const int iftype_num[NUM_NL80211_IFTYPES]) +{ + int err, num = 0; + + err = cfg80211_iter_combinations(wiphy, num_different_channels, + radar_detect, iftype_num, + cfg80211_iter_sum_ifcombs, &num); + if (err) + return err; + if (num == 0) + return -EBUSY; + + return 0; } EXPORT_SYMBOL(cfg80211_check_combinations);