Skip to content

Commit 2bdaf38

Browse files
bcopelandjmberg-intel
authored andcommitted
mac80211: mesh: move path tables into if_mesh
The mesh path and mesh gate hashtables are global, containing all of the mpaths for every mesh interface, but the paths are all tied logically to a single interface. The common case is just a single mesh interface, so optimize for that by moving the global hashtable into the per-interface struct. Doing so allows us to drop sdata pointer comparisons inside the lookups and also saves a few bytes of BSS and data. Signed-off-by: Bob Copeland <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent 12880d1 commit 2bdaf38

File tree

6 files changed

+104
-115
lines changed

6 files changed

+104
-115
lines changed

net/mac80211/cfg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
14991499

15001500
memset(pinfo, 0, sizeof(*pinfo));
15011501

1502-
pinfo->generation = mesh_paths_generation;
1502+
pinfo->generation = mpath->sdata->u.mesh.mesh_paths_generation;
15031503

15041504
pinfo->filled = MPATH_INFO_FRAME_QLEN |
15051505
MPATH_INFO_SN |
@@ -1577,7 +1577,7 @@ static void mpp_set_pinfo(struct mesh_path *mpath, u8 *mpp,
15771577
memset(pinfo, 0, sizeof(*pinfo));
15781578
memcpy(mpp, mpath->mpp, ETH_ALEN);
15791579

1580-
pinfo->generation = mpp_paths_generation;
1580+
pinfo->generation = mpath->sdata->u.mesh.mpp_paths_generation;
15811581
}
15821582

15831583
static int ieee80211_get_mpp(struct wiphy *wiphy, struct net_device *dev,

net/mac80211/ieee80211_i.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,18 @@ struct ieee80211_if_mesh {
696696

697697
/* offset from skb->data while building IE */
698698
int meshconf_offset;
699+
700+
struct mesh_table __rcu *mesh_paths;
701+
struct mesh_table __rcu *mpp_paths; /* Store paths for MPP&MAP */
702+
int mesh_paths_generation;
703+
int mpp_paths_generation;
704+
705+
/* Protects assignment of the mesh_paths/mpp_paths table
706+
* pointer for resize against reading it for add/delete
707+
* of individual paths. Pure readers (lookups) just use
708+
* RCU.
709+
*/
710+
rwlock_t pathtbl_resize_lock;
699711
};
700712

701713
#ifdef CONFIG_MAC80211_MESH

net/mac80211/mesh.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt)
2525

2626
void ieee80211s_init(void)
2727
{
28-
mesh_pathtbl_init();
2928
mesh_allocated = 1;
3029
rm_cache = kmem_cache_create("mesh_rmc", sizeof(struct rmc_entry),
3130
0, 0, NULL);
@@ -35,7 +34,6 @@ void ieee80211s_stop(void)
3534
{
3635
if (!mesh_allocated)
3736
return;
38-
mesh_pathtbl_unregister();
3937
kmem_cache_destroy(rm_cache);
4038
}
4139

@@ -902,6 +900,7 @@ void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata)
902900
/* flush STAs and mpaths on this iface */
903901
sta_info_flush(sdata);
904902
mesh_path_flush_by_iface(sdata);
903+
mesh_pathtbl_unregister(sdata);
905904

906905
/* free all potentially still buffered group-addressed frames */
907906
local->total_ps_buffered -= skb_queue_len(&ifmsh->ps.bc_buf);
@@ -1349,10 +1348,10 @@ void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata)
13491348
mesh_path_start_discovery(sdata);
13501349

13511350
if (test_and_clear_bit(MESH_WORK_GROW_MPATH_TABLE, &ifmsh->wrkq_flags))
1352-
mesh_mpath_table_grow();
1351+
mesh_mpath_table_grow(sdata);
13531352

13541353
if (test_and_clear_bit(MESH_WORK_GROW_MPP_TABLE, &ifmsh->wrkq_flags))
1355-
mesh_mpp_table_grow();
1354+
mesh_mpp_table_grow(sdata);
13561355

13571356
if (test_and_clear_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags))
13581357
ieee80211_mesh_housekeeping(sdata);
@@ -1388,6 +1387,9 @@ void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata)
13881387
/* Allocate all mesh structures when creating the first mesh interface. */
13891388
if (!mesh_allocated)
13901389
ieee80211s_init();
1390+
1391+
mesh_pathtbl_init(sdata);
1392+
13911393
setup_timer(&ifmsh->mesh_path_timer,
13921394
ieee80211_mesh_path_timer,
13931395
(unsigned long) sdata);

net/mac80211/mesh.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,17 +300,17 @@ void mesh_sta_cleanup(struct sta_info *sta);
300300

301301
/* Private interfaces */
302302
/* Mesh tables */
303-
void mesh_mpath_table_grow(void);
304-
void mesh_mpp_table_grow(void);
303+
void mesh_mpath_table_grow(struct ieee80211_sub_if_data *sdata);
304+
void mesh_mpp_table_grow(struct ieee80211_sub_if_data *sdata);
305305
/* Mesh paths */
306306
int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata,
307307
u8 ttl, const u8 *target, u32 target_sn,
308308
u16 target_rcode, const u8 *ra);
309309
void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta);
310310
void mesh_path_flush_pending(struct mesh_path *mpath);
311311
void mesh_path_tx_pending(struct mesh_path *mpath);
312-
int mesh_pathtbl_init(void);
313-
void mesh_pathtbl_unregister(void);
312+
int mesh_pathtbl_init(struct ieee80211_sub_if_data *sdata);
313+
void mesh_pathtbl_unregister(struct ieee80211_sub_if_data *sdata);
314314
int mesh_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr);
315315
void mesh_path_timer(unsigned long data);
316316
void mesh_path_flush_by_nexthop(struct sta_info *sta);
@@ -319,8 +319,6 @@ void mesh_path_discard_frame(struct ieee80211_sub_if_data *sdata,
319319
void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata);
320320

321321
bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt);
322-
extern int mesh_paths_generation;
323-
extern int mpp_paths_generation;
324322

325323
#ifdef CONFIG_MAC80211_MESH
326324
static inline

0 commit comments

Comments
 (0)