From patchwork Tue Mar 18 13:53:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 3853541 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 B03C0BF540 for ; Wed, 19 Mar 2014 17:45:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D478620035 for ; Wed, 19 Mar 2014 17:45:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E199D2011B for ; Wed, 19 Mar 2014 17:45:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754478AbaCRN72 (ORCPT ); Tue, 18 Mar 2014 09:59:28 -0400 Received: from mail-ee0-f47.google.com ([74.125.83.47]:45032 "EHLO mail-ee0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754469AbaCRN7N (ORCPT ); Tue, 18 Mar 2014 09:59:13 -0400 Received: by mail-ee0-f47.google.com with SMTP id b15so5346985eek.6 for ; Tue, 18 Mar 2014 06:59:12 -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=kJADAEdOoWCxzXTsGDv/6+nZkppuvu37iV2Kp6lszsY=; b=KXi0Vp1Shk7wtamGyQaOkeANAGmdnHiV72D6teBWgQeGggaZI9fQlUPsRGVax8BPCZ q0lDtl6XvdotAdMBn+ge2pxtN/0CPogaOtG6fCEgCJjxuwgImlBPucAtaXGfq2leyfss Gj3SDohqm4zy5WLsyV6o0EFm2TNNWzldzCdvI= 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=kJADAEdOoWCxzXTsGDv/6+nZkppuvu37iV2Kp6lszsY=; b=OsI0x9S5dotR3BH/vEUbgpLVxCrcKUKH9dxicJiWwEmmBvYkE74u6qmIyIoXckEUc4 VycanAu5NV3KOGZ1Q5udIEd5smMr6grOWZ8gHmvvtIXMKdT6GIrTPwkSVMV7KMfxR8nO sENQSFhsYhhyAsnQeKQI8mOeKIdL1QXNZuQq9PE82AIwVc5z15gENNxIdg5zj1wR5YGW UDBMM3svzBmkZknklc1pFsEH/S9rH3l9Ddrn3FdUR239xwlaf0wSCyijzVfQzWHs0FwW g7S3EMojoaU+YnZV9TeNf9ezFb3/lZi229T0jtmIiQ2+ro1e2i6pO3DvqMLEquxlbv/Y y0AA== X-Gm-Message-State: ALoCoQkdy6RTTsXCTdJUL4WVGALOcoCwkbnmFSGlNY4Wj5EgGvcju0o9XyEBHe+xqTwJE9LZ/1aioQdaE8RqT5ZC9CJoz8b2H9po1NNbyYpYqhTmlPs/5SU= X-Received: by 10.15.77.134 with SMTP id p6mr963732eey.113.1395151152925; Tue, 18 Mar 2014 06:59:12 -0700 (PDT) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id x45sm35223167eeu.23.2014.03.18.06.59.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Mar 2014 06:59:12 -0700 (PDT) From: Michal Kazior To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, Michal Kazior Subject: [RFC 06/21] mac80211: track reserved vifs in chanctx Date: Tue, 18 Mar 2014 14:53:09 +0100 Message-Id: <1395150804-24090-7-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1395150804-24090-1-git-send-email-michal.kazior@tieto.com> References: <1395150804-24090-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 This can be useful. Signed-off-by: Michal Kazior --- net/mac80211/chan.c | 14 ++++++++++---- net/mac80211/ieee80211_i.h | 2 ++ net/mac80211/iface.c | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index aca70a6..525739b 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -277,6 +277,7 @@ ieee80211_new_chanctx(struct ieee80211_local *local, return ERR_PTR(-ENOMEM); INIT_LIST_HEAD(&ctx->assigned_vifs); + INIT_LIST_HEAD(&ctx->reserved_vifs); ctx->conf.def = *chandef; ctx->conf.rx_chains_static = 1; ctx->conf.rx_chains_dynamic = 1; @@ -731,16 +732,19 @@ void ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata, int ieee80211_vif_unreserve_chanctx(struct ieee80211_sub_if_data *sdata) { + struct ieee80211_chanctx *ctx = sdata->reserved_chanctx; + lockdep_assert_held(&sdata->local->chanctx_mtx); - if (WARN_ON(!sdata->reserved_chanctx)) + if (WARN_ON(!ctx)) return -EINVAL; - if (--sdata->reserved_chanctx->refcount == 0) - ieee80211_free_chanctx(sdata->local, sdata->reserved_chanctx); - + list_del(&sdata->reserved_chanctx_list); sdata->reserved_chanctx = NULL; + if (--ctx->refcount == 0) + ieee80211_free_chanctx(sdata->local, ctx); + return 0; } @@ -788,6 +792,7 @@ int ieee80211_vif_reserve_chanctx(struct ieee80211_sub_if_data *sdata, } } + list_add(&sdata->reserved_chanctx_list, &new_ctx->reserved_vifs); new_ctx->refcount++; sdata->reserved_chanctx = new_ctx; sdata->reserved_chandef = *chandef; @@ -837,6 +842,7 @@ int ieee80211_vif_use_reserved_context(struct ieee80211_sub_if_data *sdata, ctx->refcount--; sdata->reserved_chanctx = NULL; sdata->radar_required = sdata->reserved_radar_required; + list_del(&sdata->reserved_chanctx_list); if (old_ctx == ctx) { /* This is our own context, just change it */ diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 6e3d137..0701631 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -692,6 +692,7 @@ struct ieee80211_chanctx { struct rcu_head rcu_head; struct list_head assigned_vifs; + struct list_head reserved_vifs; enum ieee80211_chanctx_mode mode; int refcount; @@ -759,6 +760,7 @@ struct ieee80211_sub_if_data { struct cfg80211_chan_def csa_chandef; struct list_head assigned_chanctx_list; + struct list_head reserved_chanctx_list; /* context reservation -- protected with chanctx_mtx */ struct ieee80211_chanctx *reserved_chanctx; diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 3b5b6d3..d09185b 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -1292,6 +1292,7 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata, INIT_WORK(&sdata->recalc_smps, ieee80211_recalc_smps_work); INIT_WORK(&sdata->csa_finalize_work, ieee80211_csa_finalize_work); INIT_LIST_HEAD(&sdata->assigned_chanctx_list); + INIT_LIST_HEAD(&sdata->reserved_chanctx_list); switch (type) { case NL80211_IFTYPE_P2P_GO: