From patchwork Mon Mar 31 10:39:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 3913611 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 CE5749F357 for ; Mon, 31 Mar 2014 11:43:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F0B2E203AC for ; Mon, 31 Mar 2014 11:43:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 23E3D20386 for ; Mon, 31 Mar 2014 11:43:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753011AbaCaLnY (ORCPT ); Mon, 31 Mar 2014 07:43:24 -0400 Received: from mail-wi0-f182.google.com ([209.85.212.182]:52118 "EHLO mail-wi0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752981AbaCaLnP (ORCPT ); Mon, 31 Mar 2014 07:43:15 -0400 Received: by mail-wi0-f182.google.com with SMTP id d1so3124581wiv.9 for ; Mon, 31 Mar 2014 04:43:14 -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=DL7Wg0KLExPcYDMBquvd+VlmC7SzMLnMQC9thfj/n38=; b=axqntbU8tLSR1bAfkM2KH/l/Neck5ir5u5NcqlpJroXfWs8kkQfIiXKog9WaaFwWzH dvOq9l5lz9OxOxbmDKRARQJbOcDprpiHfUFbL+f+jDqOqP2h5c7PFKXtTv568rbcFRtn snl9qos6cGX+z1Fg0qySBUd4p555GYUfk9DYg= 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=DL7Wg0KLExPcYDMBquvd+VlmC7SzMLnMQC9thfj/n38=; b=g3eFPAqOamrwxl1JGDp0hPWaGSnB3SMotV9EwcyO31KNJNeb80Fpc2SROXx0Q6r5fZ nze9gI91S8Rg8wFSnaB+hY2Cj/wbAAVK/YZ44MJL+x++tjtV13daaD3BD5oraKj9bZWC WNUcqAgA2gRVeUwFUsAoqUDROS4Zj2OCWlZ6fQdfENIVfWk5u9Fb0i7NFLWlnEKg/VBT RalQ+9dE6zyuVnoOmoXoVZV8R2YiYMx/zxigeT8cF+ArFQIkcO1oPZTF68OvEmfT23Bz 8zF6gsq4QYmIpXOCQD9s8i8D7gRr3qcMknAVIGOdvD0VH7KhFVLQTvlyyHwImd5aTiVP Hyiw== X-Gm-Message-State: ALoCoQl8A7bsvKUa797T6oqhMcFziEK0xwzi2F/8hXt8hvaD/4m75p9kyT/MJG/epOohox+EnoTG9hPoqW9YxZDC8waeIqVhOZr9wMkzZ7eQ/c8jLThXbpU= X-Received: by 10.180.105.65 with SMTP id gk1mr11808210wib.12.1396266194662; Mon, 31 Mar 2014 04:43:14 -0700 (PDT) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id q49sm32467516eem.34.2014.03.31.04.43.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Mar 2014 04:43:13 -0700 (PDT) From: Michal Kazior To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, Michal Kazior Subject: [PATCH v3 05/13] mac80211: track assigned vifs in chanctx Date: Mon, 31 Mar 2014 12:39:23 +0200 Message-Id: <1396262371-6466-6-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 can be useful. Provides a more straghtforward way to iterate over interfaces bound to a given chanctx and allows tracking chanctx usage explicitly. The structure is protected by local->chanctx_mtx. Signed-off-by: Michal Kazior --- v3: * update commit message [Johannes] * add locking information [Johannes] net/mac80211/chan.c | 4 ++++ net/mac80211/ieee80211_i.h | 4 ++++ net/mac80211/iface.c | 1 + 3 files changed, 9 insertions(+) diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index cc85ad8..88aeb40 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -270,6 +270,7 @@ ieee80211_new_chanctx(struct ieee80211_local *local, if (!ctx) return ERR_PTR(-ENOMEM); + INIT_LIST_HEAD(&ctx->assigned_vifs); ctx->conf.def = *chandef; ctx->conf.rx_chains_static = 1; ctx->conf.rx_chains_dynamic = 1; @@ -414,6 +415,7 @@ static int ieee80211_assign_vif_chanctx(struct ieee80211_sub_if_data *sdata, curr_ctx->refcount--; drv_unassign_vif_chanctx(local, sdata, curr_ctx); conf = NULL; + list_del(&sdata->assigned_chanctx_list); } if (new_ctx) { @@ -423,6 +425,8 @@ static int ieee80211_assign_vif_chanctx(struct ieee80211_sub_if_data *sdata, new_ctx->refcount++; conf = &new_ctx->conf; + list_add(&sdata->assigned_chanctx_list, + &new_ctx->assigned_vifs); } out: diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index a96e375..d39f32d 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -691,6 +691,8 @@ struct ieee80211_chanctx { struct list_head list; struct rcu_head rcu_head; + struct list_head assigned_vifs; + enum ieee80211_chanctx_mode mode; int refcount; bool driver_present; @@ -757,6 +759,8 @@ struct ieee80211_sub_if_data { bool csa_block_tx; /* write-protected by sdata_lock and local->mtx */ struct cfg80211_chan_def csa_chandef; + struct list_head assigned_chanctx_list; /* protected by chanctx_mtx */ + /* context reservation -- protected with chanctx_mtx */ struct ieee80211_chanctx *reserved_chanctx; struct cfg80211_chan_def reserved_chandef; diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 52dccd6..8da4a0d 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -1296,6 +1296,7 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata, INIT_WORK(&sdata->work, ieee80211_iface_work); 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); switch (type) { case NL80211_IFTYPE_P2P_GO: