Skip to content

Commit 60854fd

Browse files
bcopelandjmberg-intel
authored andcommitted
mac80211: mesh: convert path table to rhashtable
In the time since the mesh path table was implemented as an RCU-traversable, dynamically growing hash table, a generic RCU hashtable implementation was added to the kernel. Switch the mesh path table over to rhashtable to remove some code and also gain some features like automatic shrinking. Cc: Thomas Graf <[email protected]> Cc: [email protected] Signed-off-by: Bob Copeland <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent 8f6fd83 commit 60854fd

File tree

4 files changed

+259
-575
lines changed

4 files changed

+259
-575
lines changed

net/mac80211/ieee80211_i.h

+2-9
Original file line numberDiff line numberDiff line change
@@ -697,17 +697,10 @@ struct ieee80211_if_mesh {
697697
/* offset from skb->data while building IE */
698698
int meshconf_offset;
699699

700-
struct mesh_table __rcu *mesh_paths;
701-
struct mesh_table __rcu *mpp_paths; /* Store paths for MPP&MAP */
700+
struct mesh_table *mesh_paths;
701+
struct mesh_table *mpp_paths; /* Store paths for MPP&MAP */
702702
int mesh_paths_generation;
703703
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;
711704
};
712705

713706
#ifdef CONFIG_MAC80211_MESH

net/mac80211/mesh.c

-6
Original file line numberDiff line numberDiff line change
@@ -1347,12 +1347,6 @@ void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata)
13471347
ifmsh->last_preq + msecs_to_jiffies(ifmsh->mshcfg.dot11MeshHWMPpreqMinInterval)))
13481348
mesh_path_start_discovery(sdata);
13491349

1350-
if (test_and_clear_bit(MESH_WORK_GROW_MPATH_TABLE, &ifmsh->wrkq_flags))
1351-
mesh_mpath_table_grow(sdata);
1352-
1353-
if (test_and_clear_bit(MESH_WORK_GROW_MPP_TABLE, &ifmsh->wrkq_flags))
1354-
mesh_mpp_table_grow(sdata);
1355-
13561350
if (test_and_clear_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags))
13571351
ieee80211_mesh_housekeeping(sdata);
13581352

net/mac80211/mesh.h

+3-28
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,13 @@ enum mesh_path_flags {
5151
*
5252
*
5353
* @MESH_WORK_HOUSEKEEPING: run the periodic mesh housekeeping tasks
54-
* @MESH_WORK_GROW_MPATH_TABLE: the mesh path table is full and needs
55-
* to grow.
56-
* @MESH_WORK_GROW_MPP_TABLE: the mesh portals table is full and needs to
57-
* grow
5854
* @MESH_WORK_ROOT: the mesh root station needs to send a frame
5955
* @MESH_WORK_DRIFT_ADJUST: time to compensate for clock drift relative to other
6056
* mesh nodes
6157
* @MESH_WORK_MBSS_CHANGED: rebuild beacon and notify driver of BSS changes
6258
*/
6359
enum mesh_deferred_task_flags {
6460
MESH_WORK_HOUSEKEEPING,
65-
MESH_WORK_GROW_MPATH_TABLE,
66-
MESH_WORK_GROW_MPP_TABLE,
6761
MESH_WORK_ROOT,
6862
MESH_WORK_DRIFT_ADJUST,
6963
MESH_WORK_MBSS_CHANGED,
@@ -105,6 +99,7 @@ enum mesh_deferred_task_flags {
10599
struct mesh_path {
106100
u8 dst[ETH_ALEN];
107101
u8 mpp[ETH_ALEN]; /* used for MPP or MAP */
102+
struct rhash_head rhash;
108103
struct hlist_node gate_list;
109104
struct ieee80211_sub_if_data *sdata;
110105
struct sta_info __rcu *next_hop;
@@ -129,34 +124,17 @@ struct mesh_path {
129124
/**
130125
* struct mesh_table
131126
*
132-
* @hash_buckets: array of hash buckets of the table
133-
* @hashwlock: array of locks to protect write operations, one per bucket
134-
* @hash_mask: 2^size_order - 1, used to compute hash idx
135-
* @hash_rnd: random value used for hash computations
136127
* @entries: number of entries in the table
137-
* @free_node: function to free nodes of the table
138-
* @copy_node: function to copy nodes of the table
139-
* @size_order: determines size of the table, there will be 2^size_order hash
140-
* buckets
141128
* @known_gates: list of known mesh gates and their mpaths by the station. The
142129
* gate's mpath may or may not be resolved and active.
143-
*
144-
* rcu_head: RCU head to free the table
130+
* @rhash: the rhashtable containing struct mesh_paths, keyed by dest addr
145131
*/
146132
struct mesh_table {
147-
/* Number of buckets will be 2^N */
148-
struct hlist_head *hash_buckets;
149-
spinlock_t *hashwlock; /* One per bucket, for add/del */
150-
unsigned int hash_mask; /* (2^size_order) - 1 */
151-
__u32 hash_rnd; /* Used for hash generation */
152133
atomic_t entries; /* Up to MAX_MESH_NEIGHBOURS */
153-
void (*free_node) (struct hlist_node *p, bool free_leafs);
154-
int (*copy_node) (struct hlist_node *p, struct mesh_table *newtbl);
155-
int size_order;
156134
struct hlist_head *known_gates;
157135
spinlock_t gates_lock;
158136

159-
struct rcu_head rcu_head;
137+
struct rhashtable rhead;
160138
};
161139

162140
/* Recent multicast cache */
@@ -300,9 +278,6 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
300278
void mesh_sta_cleanup(struct sta_info *sta);
301279

302280
/* Private interfaces */
303-
/* Mesh tables */
304-
void mesh_mpath_table_grow(struct ieee80211_sub_if_data *sdata);
305-
void mesh_mpp_table_grow(struct ieee80211_sub_if_data *sdata);
306281
/* Mesh paths */
307282
int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata,
308283
u8 ttl, const u8 *target, u32 target_sn,

0 commit comments

Comments
 (0)