aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/mesh_pathtbl.c
diff options
context:
space:
mode:
authorJasper Bryant-Greene <jasper@amiton.co.nz>2008-08-02 20:04:37 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-08-22 16:29:58 -0400
commitf698d856f65c3fea091cc303a135967965c5b880 (patch)
tree94c7c2d561e5191646dc5798683c0aca97973773 /net/mac80211/mesh_pathtbl.c
parentfef1643bf0cdd092a52dc3378479e4811fd65152 (diff)
replace net_device arguments with ieee80211_{local,sub_if_data} as appropriate
This patch replaces net_device arguments to mac80211 internal functions with ieee80211_{local,sub_if_data} as appropriate. It also does the same for many 802.11s mesh functions, and changes the mesh path table to be indexed on sub_if_data rather than net_device. If the mesh part needs to be a separate patch let me know, but since mesh uses a lot of mac80211 functions which were being converted anyway, the changes go hand-in-hand somewhat. This patch probably does not convert all the functions which could be converted, but it is a large chunk and followup patches will be provided. Signed-off-by: Jasper Bryant-Greene <jasper@amiton.co.nz> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/mesh_pathtbl.c')
-rw-r--r--net/mac80211/mesh_pathtbl.c76
1 files changed, 35 insertions, 41 deletions
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c
index 838ee60492ad..0a60f55f32ab 100644
--- a/net/mac80211/mesh_pathtbl.c
+++ b/net/mac80211/mesh_pathtbl.c
@@ -9,7 +9,6 @@
9 9
10#include <linux/etherdevice.h> 10#include <linux/etherdevice.h>
11#include <linux/list.h> 11#include <linux/list.h>
12#include <linux/netdevice.h>
13#include <linux/random.h> 12#include <linux/random.h>
14#include <linux/spinlock.h> 13#include <linux/spinlock.h>
15#include <linux/string.h> 14#include <linux/string.h>
@@ -62,13 +61,13 @@ void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta)
62/** 61/**
63 * mesh_path_lookup - look up a path in the mesh path table 62 * mesh_path_lookup - look up a path in the mesh path table
64 * @dst: hardware address (ETH_ALEN length) of destination 63 * @dst: hardware address (ETH_ALEN length) of destination
65 * @dev: local interface 64 * @sdata: local subif
66 * 65 *
67 * Returns: pointer to the mesh path structure, or NULL if not found 66 * Returns: pointer to the mesh path structure, or NULL if not found
68 * 67 *
69 * Locking: must be called within a read rcu section. 68 * Locking: must be called within a read rcu section.
70 */ 69 */
71struct mesh_path *mesh_path_lookup(u8 *dst, struct net_device *dev) 70struct mesh_path *mesh_path_lookup(u8 *dst, struct ieee80211_sub_if_data *sdata)
72{ 71{
73 struct mesh_path *mpath; 72 struct mesh_path *mpath;
74 struct hlist_node *n; 73 struct hlist_node *n;
@@ -78,10 +77,10 @@ struct mesh_path *mesh_path_lookup(u8 *dst, struct net_device *dev)
78 77
79 tbl = rcu_dereference(mesh_paths); 78 tbl = rcu_dereference(mesh_paths);
80 79
81 bucket = &tbl->hash_buckets[mesh_table_hash(dst, dev, tbl)]; 80 bucket = &tbl->hash_buckets[mesh_table_hash(dst, sdata, tbl)];
82 hlist_for_each_entry_rcu(node, n, bucket, list) { 81 hlist_for_each_entry_rcu(node, n, bucket, list) {
83 mpath = node->mpath; 82 mpath = node->mpath;
84 if (mpath->dev == dev && 83 if (mpath->sdata == sdata &&
85 memcmp(dst, mpath->dst, ETH_ALEN) == 0) { 84 memcmp(dst, mpath->dst, ETH_ALEN) == 0) {
86 if (MPATH_EXPIRED(mpath)) { 85 if (MPATH_EXPIRED(mpath)) {
87 spin_lock_bh(&mpath->state_lock); 86 spin_lock_bh(&mpath->state_lock);
@@ -98,13 +97,13 @@ struct mesh_path *mesh_path_lookup(u8 *dst, struct net_device *dev)
98/** 97/**
99 * mesh_path_lookup_by_idx - look up a path in the mesh path table by its index 98 * mesh_path_lookup_by_idx - look up a path in the mesh path table by its index
100 * @idx: index 99 * @idx: index
101 * @dev: local interface, or NULL for all entries 100 * @sdata: local subif, or NULL for all entries
102 * 101 *
103 * Returns: pointer to the mesh path structure, or NULL if not found. 102 * Returns: pointer to the mesh path structure, or NULL if not found.
104 * 103 *
105 * Locking: must be called within a read rcu section. 104 * Locking: must be called within a read rcu section.
106 */ 105 */
107struct mesh_path *mesh_path_lookup_by_idx(int idx, struct net_device *dev) 106struct mesh_path *mesh_path_lookup_by_idx(int idx, struct ieee80211_sub_if_data *sdata)
108{ 107{
109 struct mpath_node *node; 108 struct mpath_node *node;
110 struct hlist_node *p; 109 struct hlist_node *p;
@@ -112,7 +111,7 @@ struct mesh_path *mesh_path_lookup_by_idx(int idx, struct net_device *dev)
112 int j = 0; 111 int j = 0;
113 112
114 for_each_mesh_entry(mesh_paths, p, node, i) { 113 for_each_mesh_entry(mesh_paths, p, node, i) {
115 if (dev && node->mpath->dev != dev) 114 if (sdata && node->mpath->sdata != sdata)
116 continue; 115 continue;
117 if (j++ == idx) { 116 if (j++ == idx) {
118 if (MPATH_EXPIRED(node->mpath)) { 117 if (MPATH_EXPIRED(node->mpath)) {
@@ -131,15 +130,14 @@ struct mesh_path *mesh_path_lookup_by_idx(int idx, struct net_device *dev)
131/** 130/**
132 * mesh_path_add - allocate and add a new path to the mesh path table 131 * mesh_path_add - allocate and add a new path to the mesh path table
133 * @addr: destination address of the path (ETH_ALEN length) 132 * @addr: destination address of the path (ETH_ALEN length)
134 * @dev: local interface 133 * @sdata: local subif
135 * 134 *
136 * Returns: 0 on sucess 135 * Returns: 0 on sucess
137 * 136 *
138 * State: the initial state of the new path is set to 0 137 * State: the initial state of the new path is set to 0
139 */ 138 */
140int mesh_path_add(u8 *dst, struct net_device *dev) 139int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata)
141{ 140{
142 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
143 struct mesh_path *mpath, *new_mpath; 141 struct mesh_path *mpath, *new_mpath;
144 struct mpath_node *node, *new_node; 142 struct mpath_node *node, *new_node;
145 struct hlist_head *bucket; 143 struct hlist_head *bucket;
@@ -148,7 +146,7 @@ int mesh_path_add(u8 *dst, struct net_device *dev)
148 int err = 0; 146 int err = 0;
149 u32 hash_idx; 147 u32 hash_idx;
150 148
151 if (memcmp(dst, dev->dev_addr, ETH_ALEN) == 0) 149 if (memcmp(dst, sdata->dev->dev_addr, ETH_ALEN) == 0)
152 /* never add ourselves as neighbours */ 150 /* never add ourselves as neighbours */
153 return -ENOTSUPP; 151 return -ENOTSUPP;
154 152
@@ -169,7 +167,7 @@ int mesh_path_add(u8 *dst, struct net_device *dev)
169 167
170 read_lock(&pathtbl_resize_lock); 168 read_lock(&pathtbl_resize_lock);
171 memcpy(new_mpath->dst, dst, ETH_ALEN); 169 memcpy(new_mpath->dst, dst, ETH_ALEN);
172 new_mpath->dev = dev; 170 new_mpath->sdata = sdata;
173 new_mpath->flags = 0; 171 new_mpath->flags = 0;
174 skb_queue_head_init(&new_mpath->frame_queue); 172 skb_queue_head_init(&new_mpath->frame_queue);
175 new_node->mpath = new_mpath; 173 new_node->mpath = new_mpath;
@@ -179,7 +177,7 @@ int mesh_path_add(u8 *dst, struct net_device *dev)
179 spin_lock_init(&new_mpath->state_lock); 177 spin_lock_init(&new_mpath->state_lock);
180 init_timer(&new_mpath->timer); 178 init_timer(&new_mpath->timer);
181 179
182 hash_idx = mesh_table_hash(dst, dev, mesh_paths); 180 hash_idx = mesh_table_hash(dst, sdata, mesh_paths);
183 bucket = &mesh_paths->hash_buckets[hash_idx]; 181 bucket = &mesh_paths->hash_buckets[hash_idx];
184 182
185 spin_lock(&mesh_paths->hashwlock[hash_idx]); 183 spin_lock(&mesh_paths->hashwlock[hash_idx]);
@@ -187,7 +185,7 @@ int mesh_path_add(u8 *dst, struct net_device *dev)
187 err = -EEXIST; 185 err = -EEXIST;
188 hlist_for_each_entry(node, n, bucket, list) { 186 hlist_for_each_entry(node, n, bucket, list) {
189 mpath = node->mpath; 187 mpath = node->mpath;
190 if (mpath->dev == dev && memcmp(dst, mpath->dst, ETH_ALEN) == 0) 188 if (mpath->sdata == sdata && memcmp(dst, mpath->dst, ETH_ALEN) == 0)
191 goto err_exists; 189 goto err_exists;
192 } 190 }
193 191
@@ -241,7 +239,7 @@ void mesh_plink_broken(struct sta_info *sta)
241 struct mesh_path *mpath; 239 struct mesh_path *mpath;
242 struct mpath_node *node; 240 struct mpath_node *node;
243 struct hlist_node *p; 241 struct hlist_node *p;
244 struct net_device *dev = sta->sdata->dev; 242 struct ieee80211_sub_if_data *sdata = sta->sdata;
245 int i; 243 int i;
246 244
247 rcu_read_lock(); 245 rcu_read_lock();
@@ -256,7 +254,7 @@ void mesh_plink_broken(struct sta_info *sta)
256 spin_unlock_bh(&mpath->state_lock); 254 spin_unlock_bh(&mpath->state_lock);
257 mesh_path_error_tx(mpath->dst, 255 mesh_path_error_tx(mpath->dst,
258 cpu_to_le32(mpath->dsn), 256 cpu_to_le32(mpath->dsn),
259 dev->broadcast, dev); 257 sdata->dev->broadcast, sdata);
260 } else 258 } else
261 spin_unlock_bh(&mpath->state_lock); 259 spin_unlock_bh(&mpath->state_lock);
262 } 260 }
@@ -284,11 +282,11 @@ void mesh_path_flush_by_nexthop(struct sta_info *sta)
284 for_each_mesh_entry(mesh_paths, p, node, i) { 282 for_each_mesh_entry(mesh_paths, p, node, i) {
285 mpath = node->mpath; 283 mpath = node->mpath;
286 if (mpath->next_hop == sta) 284 if (mpath->next_hop == sta)
287 mesh_path_del(mpath->dst, mpath->dev); 285 mesh_path_del(mpath->dst, mpath->sdata);
288 } 286 }
289} 287}
290 288
291void mesh_path_flush(struct net_device *dev) 289void mesh_path_flush(struct ieee80211_sub_if_data *sdata)
292{ 290{
293 struct mesh_path *mpath; 291 struct mesh_path *mpath;
294 struct mpath_node *node; 292 struct mpath_node *node;
@@ -297,16 +295,15 @@ void mesh_path_flush(struct net_device *dev)
297 295
298 for_each_mesh_entry(mesh_paths, p, node, i) { 296 for_each_mesh_entry(mesh_paths, p, node, i) {
299 mpath = node->mpath; 297 mpath = node->mpath;
300 if (mpath->dev == dev) 298 if (mpath->sdata == sdata)
301 mesh_path_del(mpath->dst, mpath->dev); 299 mesh_path_del(mpath->dst, mpath->sdata);
302 } 300 }
303} 301}
304 302
305static void mesh_path_node_reclaim(struct rcu_head *rp) 303static void mesh_path_node_reclaim(struct rcu_head *rp)
306{ 304{
307 struct mpath_node *node = container_of(rp, struct mpath_node, rcu); 305 struct mpath_node *node = container_of(rp, struct mpath_node, rcu);
308 struct ieee80211_sub_if_data *sdata = 306 struct ieee80211_sub_if_data *sdata = node->mpath->sdata;
309 IEEE80211_DEV_TO_SUB_IF(node->mpath->dev);
310 307
311 del_timer_sync(&node->mpath->timer); 308 del_timer_sync(&node->mpath->timer);
312 atomic_dec(&sdata->u.sta.mpaths); 309 atomic_dec(&sdata->u.sta.mpaths);
@@ -318,11 +315,11 @@ static void mesh_path_node_reclaim(struct rcu_head *rp)
318 * mesh_path_del - delete a mesh path from the table 315 * mesh_path_del - delete a mesh path from the table
319 * 316 *
320 * @addr: dst address (ETH_ALEN length) 317 * @addr: dst address (ETH_ALEN length)
321 * @dev: local interface 318 * @sdata: local subif
322 * 319 *
323 * Returns: 0 if succesful 320 * Returns: 0 if succesful
324 */ 321 */
325int mesh_path_del(u8 *addr, struct net_device *dev) 322int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata)
326{ 323{
327 struct mesh_path *mpath; 324 struct mesh_path *mpath;
328 struct mpath_node *node; 325 struct mpath_node *node;
@@ -332,13 +329,13 @@ int mesh_path_del(u8 *addr, struct net_device *dev)
332 int err = 0; 329 int err = 0;
333 330
334 read_lock(&pathtbl_resize_lock); 331 read_lock(&pathtbl_resize_lock);
335 hash_idx = mesh_table_hash(addr, dev, mesh_paths); 332 hash_idx = mesh_table_hash(addr, sdata, mesh_paths);
336 bucket = &mesh_paths->hash_buckets[hash_idx]; 333 bucket = &mesh_paths->hash_buckets[hash_idx];
337 334
338 spin_lock(&mesh_paths->hashwlock[hash_idx]); 335 spin_lock(&mesh_paths->hashwlock[hash_idx]);
339 hlist_for_each_entry(node, n, bucket, list) { 336 hlist_for_each_entry(node, n, bucket, list) {
340 mpath = node->mpath; 337 mpath = node->mpath;
341 if (mpath->dev == dev && 338 if (mpath->sdata == sdata &&
342 memcmp(addr, mpath->dst, ETH_ALEN) == 0) { 339 memcmp(addr, mpath->dst, ETH_ALEN) == 0) {
343 spin_lock_bh(&mpath->state_lock); 340 spin_lock_bh(&mpath->state_lock);
344 mpath->flags |= MESH_PATH_RESOLVING; 341 mpath->flags |= MESH_PATH_RESOLVING;
@@ -378,29 +375,29 @@ void mesh_path_tx_pending(struct mesh_path *mpath)
378 * mesh_path_discard_frame - discard a frame whose path could not be resolved 375 * mesh_path_discard_frame - discard a frame whose path could not be resolved
379 * 376 *
380 * @skb: frame to discard 377 * @skb: frame to discard
381 * @dev: network device the frame was to be sent through 378 * @sdata: network subif the frame was to be sent through
382 * 379 *
383 * If the frame was beign forwarded from another MP, a PERR frame will be sent 380 * If the frame was beign forwarded from another MP, a PERR frame will be sent
384 * to the precursor. 381 * to the precursor.
385 * 382 *
386 * Locking: the function must me called within a rcu_read_lock region 383 * Locking: the function must me called within a rcu_read_lock region
387 */ 384 */
388void mesh_path_discard_frame(struct sk_buff *skb, struct net_device *dev) 385void mesh_path_discard_frame(struct sk_buff *skb,
386 struct ieee80211_sub_if_data *sdata)
389{ 387{
390 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
391 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 388 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
392 struct mesh_path *mpath; 389 struct mesh_path *mpath;
393 u32 dsn = 0; 390 u32 dsn = 0;
394 391
395 if (memcmp(hdr->addr4, dev->dev_addr, ETH_ALEN) != 0) { 392 if (memcmp(hdr->addr4, sdata->dev->dev_addr, ETH_ALEN) != 0) {
396 u8 *ra, *da; 393 u8 *ra, *da;
397 394
398 da = hdr->addr3; 395 da = hdr->addr3;
399 ra = hdr->addr2; 396 ra = hdr->addr2;
400 mpath = mesh_path_lookup(da, dev); 397 mpath = mesh_path_lookup(da, sdata);
401 if (mpath) 398 if (mpath)
402 dsn = ++mpath->dsn; 399 dsn = ++mpath->dsn;
403 mesh_path_error_tx(skb->data, cpu_to_le32(dsn), ra, dev); 400 mesh_path_error_tx(skb->data, cpu_to_le32(dsn), ra, sdata);
404 } 401 }
405 402
406 kfree_skb(skb); 403 kfree_skb(skb);
@@ -416,14 +413,11 @@ void mesh_path_discard_frame(struct sk_buff *skb, struct net_device *dev)
416 */ 413 */
417void mesh_path_flush_pending(struct mesh_path *mpath) 414void mesh_path_flush_pending(struct mesh_path *mpath)
418{ 415{
419 struct ieee80211_sub_if_data *sdata;
420 struct sk_buff *skb; 416 struct sk_buff *skb;
421 417
422 sdata = IEEE80211_DEV_TO_SUB_IF(mpath->dev);
423
424 while ((skb = skb_dequeue(&mpath->frame_queue)) && 418 while ((skb = skb_dequeue(&mpath->frame_queue)) &&
425 (mpath->flags & MESH_PATH_ACTIVE)) 419 (mpath->flags & MESH_PATH_ACTIVE))
426 mesh_path_discard_frame(skb, mpath->dev); 420 mesh_path_discard_frame(skb, mpath->sdata);
427} 421}
428 422
429/** 423/**
@@ -472,7 +466,7 @@ static int mesh_path_node_copy(struct hlist_node *p, struct mesh_table *newtbl)
472 node = hlist_entry(p, struct mpath_node, list); 466 node = hlist_entry(p, struct mpath_node, list);
473 mpath = node->mpath; 467 mpath = node->mpath;
474 new_node->mpath = mpath; 468 new_node->mpath = mpath;
475 hash_idx = mesh_table_hash(mpath->dst, mpath->dev, newtbl); 469 hash_idx = mesh_table_hash(mpath->dst, mpath->sdata, newtbl);
476 hlist_add_head(&new_node->list, 470 hlist_add_head(&new_node->list,
477 &newtbl->hash_buckets[hash_idx]); 471 &newtbl->hash_buckets[hash_idx]);
478 return 0; 472 return 0;
@@ -489,7 +483,7 @@ int mesh_pathtbl_init(void)
489 return 0; 483 return 0;
490} 484}
491 485
492void mesh_path_expire(struct net_device *dev) 486void mesh_path_expire(struct ieee80211_sub_if_data *sdata)
493{ 487{
494 struct mesh_path *mpath; 488 struct mesh_path *mpath;
495 struct mpath_node *node; 489 struct mpath_node *node;
@@ -498,7 +492,7 @@ void mesh_path_expire(struct net_device *dev)
498 492
499 read_lock(&pathtbl_resize_lock); 493 read_lock(&pathtbl_resize_lock);
500 for_each_mesh_entry(mesh_paths, p, node, i) { 494 for_each_mesh_entry(mesh_paths, p, node, i) {
501 if (node->mpath->dev != dev) 495 if (node->mpath->sdata != sdata)
502 continue; 496 continue;
503 mpath = node->mpath; 497 mpath = node->mpath;
504 spin_lock_bh(&mpath->state_lock); 498 spin_lock_bh(&mpath->state_lock);
@@ -507,7 +501,7 @@ void mesh_path_expire(struct net_device *dev)
507 time_after(jiffies, 501 time_after(jiffies,
508 mpath->exp_time + MESH_PATH_EXPIRE)) { 502 mpath->exp_time + MESH_PATH_EXPIRE)) {
509 spin_unlock_bh(&mpath->state_lock); 503 spin_unlock_bh(&mpath->state_lock);
510 mesh_path_del(mpath->dst, mpath->dev); 504 mesh_path_del(mpath->dst, mpath->sdata);
511 } else 505 } else
512 spin_unlock_bh(&mpath->state_lock); 506 spin_unlock_bh(&mpath->state_lock);
513 } 507 }