From patchwork Mon Mar 31 10:39:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 3913601 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 2A390BF540 for ; Mon, 31 Mar 2014 11:43:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5115C203AC for ; Mon, 31 Mar 2014 11:43:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6E8BE20386 for ; Mon, 31 Mar 2014 11:43:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753027AbaCaLnW (ORCPT ); Mon, 31 Mar 2014 07:43:22 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:45432 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753011AbaCaLnU (ORCPT ); Mon, 31 Mar 2014 07:43:20 -0400 Received: by mail-wi0-f179.google.com with SMTP id z2so1365294wiv.0 for ; Mon, 31 Mar 2014 04:43:19 -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=X9GlPrlUQV9Li2cQSzUSzH0+my6pnG270F7INxM7nZ0=; b=D1l5Ra6wj7QeRTlRsq21JaOt/NyT1cWbYEDlKipXMyyB3U66YLvROJ39E7eSjdAHCC sPlT1DCD4zdsbSfQ/OncUe3lbE7uryVvHsUTcFI8Xz9LNAbp7dtk1y2lCYh6148Y1tIV BIpzFJQNllrDyZm36ugMQm9ewTd6teafN0HBo= 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=X9GlPrlUQV9Li2cQSzUSzH0+my6pnG270F7INxM7nZ0=; b=jqdkR3BNDhB/54FoyERb30c9A8C1jP7Ewevrr5EFs/g9aBxqdLZHeKgfqSBzM2wueI ov73ggjalA8zYbK1I638R7i/kpePynx0AQbQjdRfBytKa7trp26u6K5D3gJSLDA+LNYN R3xsOMTzb7CVKeI5F4QBTQfiYBT3VKNyuxggdxIgHicf11UF8py5WYFgWretNrVlJ+dp Lv9YfFpbT4ijqg/BRCjssOCOGK5/jyimvy5hAx2ZT2cHH8TgpALQdTgIiWtZxEAYGj1y 1TA37vDrsK39o+dRZTLBx3yypDmUJe21UTDUo+jOWRsffZfIADOFNM+nUMzhkrhP/hyv oIoQ== X-Gm-Message-State: ALoCoQk5UM7WWVUiKjd7etJwQoyQwD4pqAzNZ1LW0FqmuiKKZO03XzG5CQHZ+4IVo5oN3WND5k54MS4jTFKtodUk05ISd0Zd8H7eQU8cwl3Z750csvi1uLk= X-Received: by 10.180.89.211 with SMTP id bq19mr11599131wib.58.1396266198941; Mon, 31 Mar 2014 04:43:18 -0700 (PDT) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id q49sm32467516eem.34.2014.03.31.04.43.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Mar 2014 04:43:17 -0700 (PDT) From: Michal Kazior To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, Michal Kazior Subject: [PATCH v3 07/13] mac80211: improve find_chanctx() for reservations Date: Mon, 31 Mar 2014 12:39:25 +0200 Message-Id: <1396262371-6466-8-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 This allows new vifs to be assigned to a chanctx as long as chanctx's reservation chandefs (if any) and chanctx's current chandef (implied by assigned vifs at the time, if any) and the new vif chandef are all compatible. This implies it is impossible to assign a new vif to an in-place reservation chanctx. This gives no advantages for single-channel hardware. It makes sense for multi-channel hardware only. Signed-off-by: Michal Kazior --- v2: * remove redundant calls to _chandef() [Eliad] * dont use rcu_access_pointer() [Eliad] v3: * fix commit message so it makes more sense [Johannes] net/mac80211/chan.c | 56 +++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index ad29e6e..e14d756 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -28,6 +28,29 @@ static bool ieee80211_can_create_new_chanctx(struct ieee80211_local *local) return ieee80211_num_chanctx(local) < ieee80211_max_num_channels(local); } +static const struct cfg80211_chan_def * +ieee80211_chanctx_reserved_chandef(struct ieee80211_local *local, + struct ieee80211_chanctx *ctx, + const struct cfg80211_chan_def *compat) +{ + struct ieee80211_sub_if_data *sdata; + + lockdep_assert_held(&local->chanctx_mtx); + + list_for_each_entry(sdata, &ctx->reserved_vifs, + reserved_chanctx_list) { + if (!compat) + compat = &sdata->reserved_chandef; + + compat = cfg80211_chandef_compatible(&sdata->reserved_chandef, + compat); + if (!compat) + break; + } + + return compat; +} + static enum nl80211_chan_width ieee80211_get_sta_bw(struct ieee80211_sta *sta) { switch (sta->bandwidth) { @@ -181,27 +204,6 @@ static void ieee80211_change_chanctx(struct ieee80211_local *local, } } -static bool ieee80211_chanctx_is_reserved(struct ieee80211_local *local, - struct ieee80211_chanctx *ctx) -{ - struct ieee80211_sub_if_data *sdata; - bool ret = false; - - lockdep_assert_held(&local->chanctx_mtx); - rcu_read_lock(); - list_for_each_entry_rcu(sdata, &local->interfaces, list) { - if (!ieee80211_sdata_running(sdata)) - continue; - if (sdata->reserved_chanctx == ctx) { - ret = true; - break; - } - } - - rcu_read_unlock(); - return ret; -} - static struct ieee80211_chanctx * ieee80211_find_chanctx(struct ieee80211_local *local, const struct cfg80211_chan_def *chandef, @@ -217,18 +219,18 @@ ieee80211_find_chanctx(struct ieee80211_local *local, list_for_each_entry(ctx, &local->chanctx_list, list) { const struct cfg80211_chan_def *compat; - /* We don't support chanctx reservation for multiple - * vifs yet, so don't allow reserved chanctxs to be - * reused. - */ - if ((ctx->mode == IEEE80211_CHANCTX_EXCLUSIVE) || - ieee80211_chanctx_is_reserved(local, ctx)) + if (ctx->mode == IEEE80211_CHANCTX_EXCLUSIVE) continue; compat = cfg80211_chandef_compatible(&ctx->conf.def, chandef); if (!compat) continue; + compat = ieee80211_chanctx_reserved_chandef(local, ctx, + compat); + if (!compat) + continue; + ieee80211_change_chanctx(local, ctx, compat); return ctx;