From patchwork Thu Jul 2 13:28:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Copeland X-Patchwork-Id: 6709741 X-Patchwork-Delegate: johannes@sipsolutions.net 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 73ED6C05AC for ; Thu, 2 Jul 2015 13:29:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 66FB020435 for ; Thu, 2 Jul 2015 13:29:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C0F3B206F4 for ; Thu, 2 Jul 2015 13:29:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750798AbbGBN3J (ORCPT ); Thu, 2 Jul 2015 09:29:09 -0400 Received: from mail-ie0-f177.google.com ([209.85.223.177]:33672 "EHLO mail-ie0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752619AbbGBN25 (ORCPT ); Thu, 2 Jul 2015 09:28:57 -0400 Received: by ieqy10 with SMTP id y10so56555815ieq.0 for ; Thu, 02 Jul 2015 06:28:56 -0700 (PDT) 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=9LA2u178U943kSx9nWf8LRnzlLRbUX9dpwkaKUc3zWM=; b=h+oo9bICT1S1DgH3qeq7EM+Vh6SrphrV2hmjPVfo+9Rd0fqMykOiELn92ZD1o8dDST Te5cHukZcIZExj2/RA0nvRHLG7EnVyJYugpwA86KvCoaHMiHpEZurbGIFVVaIfVPJkaN Jsck/mKx22Lh/lENj2OR1JV66i5aVGXldlHjKquXTbuliIiz+QPozd2F6pTpGgOHJJIh D09A/EUfNS12jkCKGDIMWhEb8rOAzK7L4+LDAhii4ohVn4T+r9YiswJ8IX1nLk/2gmCT 0ZpCiReixEpwVJYCI9GPChGuNEQQxpOnp80Q/ZA0ye2uDJcuQNU/243ES4ro0I6t2cod t+QA== X-Gm-Message-State: ALoCoQmP4RfG3agYczRHy85QXhFsy1I2UOcIJ9CSh3PDkNK+jI5eFzvwblkXsYn7RHym20Un+Kd9 X-Received: by 10.107.132.211 with SMTP id o80mr29123078ioi.52.1435843736301; Thu, 02 Jul 2015 06:28:56 -0700 (PDT) Received: from hash ([2001:470:1d:6db:230:48ff:fe9d:9c89]) by mx.google.com with ESMTPSA id 76sm3857864iom.12.2015.07.02.06.28.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jul 2015 06:28:53 -0700 (PDT) Received: from bob by hash with local (Exim 4.84) (envelope-from ) id 1ZAeXd-0000l0-1M; Thu, 02 Jul 2015 09:28:37 -0400 From: Bob Copeland To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, devel@lists.open80211s.org, Bob Copeland Subject: [PATCH 3/3] mac80211: select an AID when creating new mesh STAs Date: Thu, 2 Jul 2015 09:28:10 -0400 Message-Id: <1435843690-2856-4-git-send-email-me@bobcopeland.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435843690-2856-1-git-send-email-me@bobcopeland.com> References: <1435843690-2856-1-git-send-email-me@bobcopeland.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.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Instead of using peer link id for AID, generate a new AID when creating mesh STAs in the kernel peering manager. This enables smaller TIM elements and more closely follows the standard, and it also enables mesh to work on drivers that require a valid AID when the STA is inserted (ath10k firmware has this requirement, for example). In the case of userspace-managed stations, we use the AID from NL80211_CMD_NEW_STATION. Signed-off-by: Bob Copeland --- net/mac80211/cfg.c | 3 +++ net/mac80211/ieee80211_i.h | 1 + net/mac80211/mesh.c | 7 +++++++ net/mac80211/mesh_plink.c | 30 ++++++++++++++++++++++++------ 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 5789d8353505..25f0ff84900e 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -1027,6 +1027,9 @@ static void sta_apply_mesh_params(struct ieee80211_local *local, struct ieee80211_sub_if_data *sdata = sta->sdata; u32 changed = 0; + if (params->aid) + set_bit(params->aid, sdata->u.mesh.aid_map); + if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) { switch (params->plink_state) { case NL80211_PLINK_ESTAB: diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 52930e91c0fd..d691515259a7 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -689,6 +689,7 @@ struct ieee80211_if_mesh { int ps_peers_light_sleep; int ps_peers_deep_sleep; struct ps_data ps; + DECLARE_BITMAP(aid_map, IEEE80211_MAX_AID + 1); /* Channel Switching Support */ struct mesh_csa_settings __rcu *csa; enum { diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index e06a5ca7c9a9..f26df5fc29c9 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c @@ -150,6 +150,9 @@ void mesh_sta_cleanup(struct sta_info *sta) struct ieee80211_sub_if_data *sdata = sta->sdata; u32 changed; + if (sta->sta.aid) + clear_bit(sta->sta.aid, sdata->u.mesh.aid_map); + /* * maybe userspace handles peer allocation and peering, but in either * case the beacon is still generated by the kernel and we might need @@ -1323,6 +1326,10 @@ void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata) ifmsh->accepting_plinks = true; atomic_set(&ifmsh->mpaths, 0); mesh_rmc_init(sdata); + + /* reserve aid 0 used for mcast indication */ + set_bit(0, ifmsh->aid_map); + ifmsh->last_preq = jiffies; ifmsh->next_perr = jiffies; ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_NONE; diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index 9dca16bd3eb9..deab8be39627 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c @@ -421,20 +421,43 @@ out: spin_unlock_bh(&sta->mesh->plink_lock); } +static int mesh_allocate_aid(struct ieee80211_sub_if_data *sdata) +{ + int aid; + + /* mark first empty bit as used in aid_map and return it */ + do { + aid = find_first_zero_bit(sdata->u.mesh.aid_map, + IEEE80211_MAX_AID + 1); + } while (aid <= IEEE80211_MAX_AID && + test_and_set_bit(aid, sdata->u.mesh.aid_map)); + + if (aid > IEEE80211_MAX_AID) + return -ENOBUFS; + + return aid; +} + static struct sta_info * __mesh_sta_info_alloc(struct ieee80211_sub_if_data *sdata, u8 *hw_addr) { struct sta_info *sta; + int aid; if (sdata->local->num_sta >= MESH_MAX_PLINKS) return NULL; + aid = mesh_allocate_aid(sdata); + if (aid < 0) + return NULL; + sta = sta_info_alloc(sdata, hw_addr, GFP_KERNEL); if (!sta) return NULL; sta->mesh->plink_state = NL80211_PLINK_LISTEN; sta->sta.wme = true; + sta->sta.aid = aid; sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC); @@ -658,8 +681,6 @@ static u16 mesh_get_new_llid(struct ieee80211_sub_if_data *sdata) do { get_random_bytes(&llid, sizeof(llid)); - /* for mesh PS we still only have the AID range for TIM bits */ - llid = (llid % IEEE80211_MAX_AID) + 1; } while (llid_in_use(sdata, llid)); return llid; @@ -1068,7 +1089,6 @@ mesh_process_plink_frame(struct ieee80211_sub_if_data *sdata, goto unlock_rcu; } sta->mesh->plid = plid; - sta->sta.aid = plid; } else if (!sta && event == OPN_RJCT) { mesh_plink_frame_tx(sdata, NULL, WLAN_SP_MESH_PEERING_CLOSE, mgmt->sa, 0, plid, @@ -1080,10 +1100,8 @@ mesh_process_plink_frame(struct ieee80211_sub_if_data *sdata, } /* 802.11-2012 13.3.7.2 - update plid on CNF if not set */ - if (!sta->mesh->plid && event == CNF_ACPT) { + if (!sta->mesh->plid && event == CNF_ACPT) sta->mesh->plid = plid; - sta->sta.aid = sta->mesh->plid; - } changed |= mesh_plink_fsm(sdata, sta, event);