From patchwork Wed Feb 6 11:48:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Porsch X-Patchwork-Id: 2103791 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 06956DF2A1 for ; Wed, 6 Feb 2013 11:49:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753822Ab3BFLtP (ORCPT ); Wed, 6 Feb 2013 06:49:15 -0500 Received: from mail-bk0-f46.google.com ([209.85.214.46]:46742 "EHLO mail-bk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753390Ab3BFLtO (ORCPT ); Wed, 6 Feb 2013 06:49:14 -0500 Received: by mail-bk0-f46.google.com with SMTP id j5so585178bkw.5 for ; Wed, 06 Feb 2013 03:49:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=tCyJQHjvVh9R13G9fsKmGbdHeLI1GP7Vl4ogK5VJmTY=; b=DaosDsfRGf4xg+qQJQV73Ls6Wb5gD3eYQIQklytoYhYUPzVcaqsfafg3TuhZfstLJt tz51JHD1b9TNUFU55gERt38T+LInMZZNGJ+VJqJdZnflTJZHikKvPpYhowQoLWsEmcnX R2r66Rrj1o5D3KvFGh14edTA4ID6EkkJa5kkoqq+lMpu33HvhwVpYYPBRhS0LqD/3VQ2 MaP51ePP0ONRZB7serXRFh35adW9JKOUwIV/3719VlqNaja9ZlyF8e02+Fxr30ygjv6r riFvsANqIs4R1NVljLV6C5iYAA4emHtHLoYMotwQ+DB8mpISbZI9WshWE0aULD1vrv7H wREw== X-Received: by 10.205.122.80 with SMTP id gf16mr6913248bkc.130.1360151352373; Wed, 06 Feb 2013 03:49:12 -0800 (PST) Received: from X220-marco.infotech.tu-chemnitz.de (perseus.infotech.tu-chemnitz.de. [134.109.4.8]) by mx.google.com with ESMTPS id i20sm7811105bkw.5.2013.02.06.03.49.11 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 06 Feb 2013 03:49:11 -0800 (PST) From: Marco Porsch To: johannes@sipsolutions.net, mcgrof@qca.qualcomm.com, jouni@qca.qualcomm.com, vthiagar@qca.qualcomm.com, senthilb@qca.qualcomm.com Cc: linux-wireless@vger.kernel.org, devel@lists.open80211s.org, ath9k-devel@lists.ath9k.org, Marco Porsch Subject: [RFCv2 1/3] mac80211: move mesh sync beacon handler into neighbour_update Date: Wed, 6 Feb 2013 12:48:43 +0100 Message-Id: <1360151325-6368-2-git-send-email-marco@cozybit.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1360151325-6368-1-git-send-email-marco@cozybit.com> References: <1360151325-6368-1-git-send-email-marco@cozybit.com> X-Gm-Message-State: ALoCoQm6JM1OmvKCAY55dejmsqX8DxMck6u/z5uXwbaotRbEAI+bB6OSRsce7LGEqhlxWRea89H6 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Move the beacon handler into mesh_neighbour_update where the STA pointer is already available. This avoids additional overhead and simplifies the handler. The repositioning will also benefit mesh PS which uses the T_offset value right after it has been updated. Rename the handler to better reflect its purpose. Signed-off-by: Marco Porsch --- net/mac80211/ieee80211_i.h | 10 +++++----- net/mac80211/mesh.c | 8 ++------ net/mac80211/mesh.h | 5 +++-- net/mac80211/mesh_plink.c | 16 ++++++++++++--- net/mac80211/mesh_sync.c | 47 +++++++++++++++----------------------------- 5 files changed, 39 insertions(+), 47 deletions(-) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 650f758..bba2b10 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -560,11 +560,11 @@ struct ieee80211_if_ibss { */ struct ieee802_11_elems; struct ieee80211_mesh_sync_ops { - void (*rx_bcn_presp)(struct ieee80211_sub_if_data *sdata, - u16 stype, - struct ieee80211_mgmt *mgmt, - struct ieee802_11_elems *elems, - struct ieee80211_rx_status *rx_status); + void (*rx_bcn)(struct sta_info *sta, + struct ieee80211_mgmt *mgmt, + struct ieee802_11_elems *elems, + struct ieee80211_rx_status *rx_status, + u64 tsf); void (*adjust_tbtt)(struct ieee80211_sub_if_data *sdata); /* add other framework functions here */ }; diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index e39a3f8..643262b 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c @@ -714,7 +714,6 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, struct ieee80211_rx_status *rx_status) { struct ieee80211_local *local = sdata->local; - struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; struct ieee802_11_elems elems; struct ieee80211_channel *channel; size_t baselen; @@ -750,13 +749,10 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, return; if (mesh_matches_local(sdata, &elems)) - mesh_neighbour_update(sdata, mgmt->sa, &elems); - - if (ifmsh->sync_ops) - ifmsh->sync_ops->rx_bcn_presp(sdata, - stype, mgmt, &elems, rx_status); + mesh_neighbour_update(sdata, mgmt, &elems, rx_status); } + static void ieee80211_mesh_rx_mgmt_action(struct ieee80211_sub_if_data *sdata, struct ieee80211_mgmt *mgmt, size_t len, diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h index eb33625..d6d9933 100644 --- a/net/mac80211/mesh.h +++ b/net/mac80211/mesh.h @@ -283,8 +283,9 @@ int mesh_path_send_to_gates(struct mesh_path *mpath); int mesh_gate_num(struct ieee80211_sub_if_data *sdata); /* Mesh plinks */ void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata, - u8 *hw_addr, - struct ieee802_11_elems *ie); + struct ieee80211_mgmt *mgmt, + struct ieee802_11_elems *ie, + struct ieee80211_rx_status *rx_status); bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie); u32 mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata); void mesh_plink_broken(struct sta_info *sta); diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index 57e7267..af6fbfd 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c @@ -12,6 +12,7 @@ #include "ieee80211_i.h" #include "rate.h" #include "mesh.h" +#include "driver-ops.h" #define PLINK_GET_LLID(p) (p + 2) #define PLINK_GET_PLID(p) (p + 4) @@ -391,13 +392,19 @@ static struct sta_info *mesh_peer_init(struct ieee80211_sub_if_data *sdata, } void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata, - u8 *hw_addr, - struct ieee802_11_elems *elems) + struct ieee80211_mgmt *mgmt, + struct ieee802_11_elems *elems, + struct ieee80211_rx_status *rx_status) { + struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; struct sta_info *sta; + u64 tsf; + + /* get tsf before entering rcu-read section */ + tsf = drv_get_tsf(sdata->local, sdata); rcu_read_lock(); - sta = mesh_peer_init(sdata, hw_addr, elems); + sta = mesh_peer_init(sdata, mgmt->sa, elems); if (!sta) goto out; @@ -408,6 +415,9 @@ void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata, rssi_threshold_check(sta, sdata)) mesh_plink_open(sta); + if (ifmsh->sync_ops) + ifmsh->sync_ops->rx_bcn(sta, mgmt, elems, rx_status, tsf); + ieee80211_mps_frame_release(sta, elems); out: rcu_read_unlock(); diff --git a/net/mac80211/mesh_sync.c b/net/mac80211/mesh_sync.c index aa8d1e4..2275de4 100644 --- a/net/mac80211/mesh_sync.c +++ b/net/mac80211/mesh_sync.c @@ -75,35 +75,23 @@ void mesh_sync_adjust_tbtt(struct ieee80211_sub_if_data *sdata) drv_set_tsf(local, sdata, tsf + tsfdelta); } -static void mesh_sync_offset_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, - u16 stype, - struct ieee80211_mgmt *mgmt, - struct ieee802_11_elems *elems, - struct ieee80211_rx_status *rx_status) +static void mesh_sync_offset_rx_bcn(struct sta_info *sta, + struct ieee80211_mgmt *mgmt, + struct ieee802_11_elems *elems, + struct ieee80211_rx_status *rx_status, + u64 t_r) { + struct ieee80211_sub_if_data *sdata = sta->sdata; struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; struct ieee80211_local *local = sdata->local; - struct sta_info *sta; - u64 t_t, t_r; + u64 t_t; WARN_ON(ifmsh->mesh_sp_id != IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET); /* standard mentions only beacons */ - if (stype != IEEE80211_STYPE_BEACON) + if (!ieee80211_is_beacon(mgmt->frame_control)) return; - /* The current tsf is a first approximation for the timestamp - * for the received beacon. Further down we try to get a - * better value from the rx_status->mactime field if - * available. Also we have to call drv_get_tsf() before - * entering the rcu-read section.*/ - t_r = drv_get_tsf(local, sdata); - - rcu_read_lock(); - sta = sta_info_get(sdata, mgmt->sa); - if (!sta) - goto no_sync; - /* check offset sync conditions (13.13.2.2.1) * * TODO also sync to @@ -113,11 +101,15 @@ static void mesh_sync_offset_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, if (elems->mesh_config && mesh_peer_tbtt_adjusting(elems)) { clear_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN); msync_dbg(sdata, "STA %pM : is adjusting TBTT\n", sta->sta.addr); - goto no_sync; + return; } + /* + * The current tsf is a first approximation of the beacon RX time. + * If available, get a better value from the rx_status->mactime field + * (time when timestamp field was received). + */ if (ieee80211_have_rx_timestamp(rx_status)) - /* time when timestamp field was received */ t_r = ieee80211_calculate_rx_timestamp(local, rx_status, 24 + 12 + elems->total_len + @@ -146,11 +138,9 @@ static void mesh_sync_offset_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, sta->sta.addr, (long long) t_clockdrift); clear_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN); - goto no_sync; + return; } - rcu_read_unlock(); - spin_lock_bh(&ifmsh->sync_offset_lock); if (t_clockdrift > ifmsh->sync_offset_clockdrift_max) @@ -165,12 +155,7 @@ static void mesh_sync_offset_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, "STA %pM : offset was invalid, sta->t_offset=%lld\n", sta->sta.addr, (long long) sta->t_offset); - rcu_read_unlock(); } - return; - -no_sync: - rcu_read_unlock(); } static void mesh_sync_offset_adjust_tbtt(struct ieee80211_sub_if_data *sdata) @@ -212,7 +197,7 @@ static const struct sync_method sync_methods[] = { { .method = IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET, .ops = { - .rx_bcn_presp = &mesh_sync_offset_rx_bcn_presp, + .rx_bcn = &mesh_sync_offset_rx_bcn, .adjust_tbtt = &mesh_sync_offset_adjust_tbtt, } },