diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2008-09-10 18:01:49 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-09-15 16:48:20 -0400 |
commit | 472dbc45dc1966284de72d7de15690c17ed2cf33 (patch) | |
tree | e8bfb88067f7fd8845978d1613f868e6a4499999 /net/mac80211/mesh_hwmp.c | |
parent | 7c95069522d02ff144cd421be6618dce619caf7e (diff) |
mac80211: split off mesh handling entirely
This patch splits off mesh handling from the STA/IBSS.
Unfortunately it increases mesh code size a bit, but I
think it makes things clearer. The patch also reduces
per-interface run-time memory usage.
Also clean up a few places where ifdef is not required.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/mesh_hwmp.c')
-rw-r--r-- | net/mac80211/mesh_hwmp.c | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index 210d6b852406..1fad792ad258 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c | |||
@@ -64,14 +64,14 @@ static inline u32 u32_field_get(u8 *preq_elem, int offset, bool ae) | |||
64 | #define DSN_LT(x, y) ((long) (x) - (long) (y) < 0) | 64 | #define DSN_LT(x, y) ((long) (x) - (long) (y) < 0) |
65 | 65 | ||
66 | #define net_traversal_jiffies(s) \ | 66 | #define net_traversal_jiffies(s) \ |
67 | msecs_to_jiffies(s->u.sta.mshcfg.dot11MeshHWMPnetDiameterTraversalTime) | 67 | msecs_to_jiffies(s->u.mesh.mshcfg.dot11MeshHWMPnetDiameterTraversalTime) |
68 | #define default_lifetime(s) \ | 68 | #define default_lifetime(s) \ |
69 | MSEC_TO_TU(s->u.sta.mshcfg.dot11MeshHWMPactivePathTimeout) | 69 | MSEC_TO_TU(s->u.mesh.mshcfg.dot11MeshHWMPactivePathTimeout) |
70 | #define min_preq_int_jiff(s) \ | 70 | #define min_preq_int_jiff(s) \ |
71 | (msecs_to_jiffies(s->u.sta.mshcfg.dot11MeshHWMPpreqMinInterval)) | 71 | (msecs_to_jiffies(s->u.mesh.mshcfg.dot11MeshHWMPpreqMinInterval)) |
72 | #define max_preq_retries(s) (s->u.sta.mshcfg.dot11MeshHWMPmaxPREQretries) | 72 | #define max_preq_retries(s) (s->u.mesh.mshcfg.dot11MeshHWMPmaxPREQretries) |
73 | #define disc_timeout_jiff(s) \ | 73 | #define disc_timeout_jiff(s) \ |
74 | msecs_to_jiffies(sdata->u.sta.mshcfg.min_discovery_timeout) | 74 | msecs_to_jiffies(sdata->u.mesh.mshcfg.min_discovery_timeout) |
75 | 75 | ||
76 | enum mpath_frame_type { | 76 | enum mpath_frame_type { |
77 | MPATH_PREQ = 0, | 77 | MPATH_PREQ = 0, |
@@ -395,7 +395,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | |||
395 | static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, | 395 | static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, |
396 | struct ieee80211_mgmt *mgmt, | 396 | struct ieee80211_mgmt *mgmt, |
397 | u8 *preq_elem, u32 metric) { | 397 | u8 *preq_elem, u32 metric) { |
398 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | 398 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
399 | struct mesh_path *mpath; | 399 | struct mesh_path *mpath; |
400 | u8 *dst_addr, *orig_addr; | 400 | u8 *dst_addr, *orig_addr; |
401 | u8 dst_flags, ttl; | 401 | u8 dst_flags, ttl; |
@@ -414,11 +414,11 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, | |||
414 | forward = false; | 414 | forward = false; |
415 | reply = true; | 415 | reply = true; |
416 | metric = 0; | 416 | metric = 0; |
417 | if (time_after(jiffies, ifsta->last_dsn_update + | 417 | if (time_after(jiffies, ifmsh->last_dsn_update + |
418 | net_traversal_jiffies(sdata)) || | 418 | net_traversal_jiffies(sdata)) || |
419 | time_before(jiffies, ifsta->last_dsn_update)) { | 419 | time_before(jiffies, ifmsh->last_dsn_update)) { |
420 | dst_dsn = ++ifsta->dsn; | 420 | dst_dsn = ++ifmsh->dsn; |
421 | ifsta->last_dsn_update = jiffies; | 421 | ifmsh->last_dsn_update = jiffies; |
422 | } | 422 | } |
423 | } else { | 423 | } else { |
424 | rcu_read_lock(); | 424 | rcu_read_lock(); |
@@ -444,7 +444,7 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, | |||
444 | 444 | ||
445 | if (reply) { | 445 | if (reply) { |
446 | lifetime = PREQ_IE_LIFETIME(preq_elem); | 446 | lifetime = PREQ_IE_LIFETIME(preq_elem); |
447 | ttl = ifsta->mshcfg.dot11MeshTTL; | 447 | ttl = ifmsh->mshcfg.dot11MeshTTL; |
448 | if (ttl != 0) | 448 | if (ttl != 0) |
449 | mesh_path_sel_frame_tx(MPATH_PREP, 0, dst_addr, | 449 | mesh_path_sel_frame_tx(MPATH_PREP, 0, dst_addr, |
450 | cpu_to_le32(dst_dsn), 0, orig_addr, | 450 | cpu_to_le32(dst_dsn), 0, orig_addr, |
@@ -452,7 +452,7 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, | |||
452 | cpu_to_le32(lifetime), cpu_to_le32(metric), | 452 | cpu_to_le32(lifetime), cpu_to_le32(metric), |
453 | 0, sdata); | 453 | 0, sdata); |
454 | else | 454 | else |
455 | ifsta->mshstats.dropped_frames_ttl++; | 455 | ifmsh->mshstats.dropped_frames_ttl++; |
456 | } | 456 | } |
457 | 457 | ||
458 | if (forward) { | 458 | if (forward) { |
@@ -462,7 +462,7 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, | |||
462 | ttl = PREQ_IE_TTL(preq_elem); | 462 | ttl = PREQ_IE_TTL(preq_elem); |
463 | lifetime = PREQ_IE_LIFETIME(preq_elem); | 463 | lifetime = PREQ_IE_LIFETIME(preq_elem); |
464 | if (ttl <= 1) { | 464 | if (ttl <= 1) { |
465 | ifsta->mshstats.dropped_frames_ttl++; | 465 | ifmsh->mshstats.dropped_frames_ttl++; |
466 | return; | 466 | return; |
467 | } | 467 | } |
468 | --ttl; | 468 | --ttl; |
@@ -475,7 +475,7 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, | |||
475 | hopcount, ttl, cpu_to_le32(lifetime), | 475 | hopcount, ttl, cpu_to_le32(lifetime), |
476 | cpu_to_le32(metric), cpu_to_le32(preq_id), | 476 | cpu_to_le32(metric), cpu_to_le32(preq_id), |
477 | sdata); | 477 | sdata); |
478 | ifsta->mshstats.fwded_frames++; | 478 | ifmsh->mshstats.fwded_frames++; |
479 | } | 479 | } |
480 | } | 480 | } |
481 | 481 | ||
@@ -503,7 +503,7 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, | |||
503 | 503 | ||
504 | ttl = PREP_IE_TTL(prep_elem); | 504 | ttl = PREP_IE_TTL(prep_elem); |
505 | if (ttl <= 1) { | 505 | if (ttl <= 1) { |
506 | sdata->u.sta.mshstats.dropped_frames_ttl++; | 506 | sdata->u.mesh.mshstats.dropped_frames_ttl++; |
507 | return; | 507 | return; |
508 | } | 508 | } |
509 | 509 | ||
@@ -533,12 +533,12 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, | |||
533 | cpu_to_le32(lifetime), cpu_to_le32(metric), | 533 | cpu_to_le32(lifetime), cpu_to_le32(metric), |
534 | 0, sdata); | 534 | 0, sdata); |
535 | rcu_read_unlock(); | 535 | rcu_read_unlock(); |
536 | sdata->u.sta.mshstats.fwded_frames++; | 536 | sdata->u.mesh.mshstats.fwded_frames++; |
537 | return; | 537 | return; |
538 | 538 | ||
539 | fail: | 539 | fail: |
540 | rcu_read_unlock(); | 540 | rcu_read_unlock(); |
541 | sdata->u.sta.mshstats.dropped_frames_no_route++; | 541 | sdata->u.mesh.mshstats.dropped_frames_no_route++; |
542 | return; | 542 | return; |
543 | } | 543 | } |
544 | 544 | ||
@@ -631,7 +631,7 @@ void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata, | |||
631 | static void mesh_queue_preq(struct mesh_path *mpath, u8 flags) | 631 | static void mesh_queue_preq(struct mesh_path *mpath, u8 flags) |
632 | { | 632 | { |
633 | struct ieee80211_sub_if_data *sdata = mpath->sdata; | 633 | struct ieee80211_sub_if_data *sdata = mpath->sdata; |
634 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | 634 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
635 | struct mesh_preq_queue *preq_node; | 635 | struct mesh_preq_queue *preq_node; |
636 | 636 | ||
637 | preq_node = kmalloc(sizeof(struct mesh_preq_queue), GFP_KERNEL); | 637 | preq_node = kmalloc(sizeof(struct mesh_preq_queue), GFP_KERNEL); |
@@ -640,9 +640,9 @@ static void mesh_queue_preq(struct mesh_path *mpath, u8 flags) | |||
640 | return; | 640 | return; |
641 | } | 641 | } |
642 | 642 | ||
643 | spin_lock(&ifsta->mesh_preq_queue_lock); | 643 | spin_lock(&ifmsh->mesh_preq_queue_lock); |
644 | if (ifsta->preq_queue_len == MAX_PREQ_QUEUE_LEN) { | 644 | if (ifmsh->preq_queue_len == MAX_PREQ_QUEUE_LEN) { |
645 | spin_unlock(&ifsta->mesh_preq_queue_lock); | 645 | spin_unlock(&ifmsh->mesh_preq_queue_lock); |
646 | kfree(preq_node); | 646 | kfree(preq_node); |
647 | if (printk_ratelimit()) | 647 | if (printk_ratelimit()) |
648 | printk(KERN_DEBUG "Mesh HWMP: PREQ node queue full\n"); | 648 | printk(KERN_DEBUG "Mesh HWMP: PREQ node queue full\n"); |
@@ -652,21 +652,21 @@ static void mesh_queue_preq(struct mesh_path *mpath, u8 flags) | |||
652 | memcpy(preq_node->dst, mpath->dst, ETH_ALEN); | 652 | memcpy(preq_node->dst, mpath->dst, ETH_ALEN); |
653 | preq_node->flags = flags; | 653 | preq_node->flags = flags; |
654 | 654 | ||
655 | list_add_tail(&preq_node->list, &ifsta->preq_queue.list); | 655 | list_add_tail(&preq_node->list, &ifmsh->preq_queue.list); |
656 | ++ifsta->preq_queue_len; | 656 | ++ifmsh->preq_queue_len; |
657 | spin_unlock(&ifsta->mesh_preq_queue_lock); | 657 | spin_unlock(&ifmsh->mesh_preq_queue_lock); |
658 | 658 | ||
659 | if (time_after(jiffies, ifsta->last_preq + min_preq_int_jiff(sdata))) | 659 | if (time_after(jiffies, ifmsh->last_preq + min_preq_int_jiff(sdata))) |
660 | queue_work(sdata->local->hw.workqueue, &ifsta->work); | 660 | queue_work(sdata->local->hw.workqueue, &ifmsh->work); |
661 | 661 | ||
662 | else if (time_before(jiffies, ifsta->last_preq)) { | 662 | else if (time_before(jiffies, ifmsh->last_preq)) { |
663 | /* avoid long wait if did not send preqs for a long time | 663 | /* avoid long wait if did not send preqs for a long time |
664 | * and jiffies wrapped around | 664 | * and jiffies wrapped around |
665 | */ | 665 | */ |
666 | ifsta->last_preq = jiffies - min_preq_int_jiff(sdata) - 1; | 666 | ifmsh->last_preq = jiffies - min_preq_int_jiff(sdata) - 1; |
667 | queue_work(sdata->local->hw.workqueue, &ifsta->work); | 667 | queue_work(sdata->local->hw.workqueue, &ifmsh->work); |
668 | } else | 668 | } else |
669 | mod_timer(&ifsta->mesh_path_timer, ifsta->last_preq + | 669 | mod_timer(&ifmsh->mesh_path_timer, ifmsh->last_preq + |
670 | min_preq_int_jiff(sdata)); | 670 | min_preq_int_jiff(sdata)); |
671 | } | 671 | } |
672 | 672 | ||
@@ -677,25 +677,25 @@ static void mesh_queue_preq(struct mesh_path *mpath, u8 flags) | |||
677 | */ | 677 | */ |
678 | void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) | 678 | void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) |
679 | { | 679 | { |
680 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | 680 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
681 | struct mesh_preq_queue *preq_node; | 681 | struct mesh_preq_queue *preq_node; |
682 | struct mesh_path *mpath; | 682 | struct mesh_path *mpath; |
683 | u8 ttl, dst_flags; | 683 | u8 ttl, dst_flags; |
684 | u32 lifetime; | 684 | u32 lifetime; |
685 | 685 | ||
686 | spin_lock(&ifsta->mesh_preq_queue_lock); | 686 | spin_lock(&ifmsh->mesh_preq_queue_lock); |
687 | if (!ifsta->preq_queue_len || | 687 | if (!ifmsh->preq_queue_len || |
688 | time_before(jiffies, ifsta->last_preq + | 688 | time_before(jiffies, ifmsh->last_preq + |
689 | min_preq_int_jiff(sdata))) { | 689 | min_preq_int_jiff(sdata))) { |
690 | spin_unlock(&ifsta->mesh_preq_queue_lock); | 690 | spin_unlock(&ifmsh->mesh_preq_queue_lock); |
691 | return; | 691 | return; |
692 | } | 692 | } |
693 | 693 | ||
694 | preq_node = list_first_entry(&ifsta->preq_queue.list, | 694 | preq_node = list_first_entry(&ifmsh->preq_queue.list, |
695 | struct mesh_preq_queue, list); | 695 | struct mesh_preq_queue, list); |
696 | list_del(&preq_node->list); | 696 | list_del(&preq_node->list); |
697 | --ifsta->preq_queue_len; | 697 | --ifmsh->preq_queue_len; |
698 | spin_unlock(&ifsta->mesh_preq_queue_lock); | 698 | spin_unlock(&ifmsh->mesh_preq_queue_lock); |
699 | 699 | ||
700 | rcu_read_lock(); | 700 | rcu_read_lock(); |
701 | mpath = mesh_path_lookup(preq_node->dst, sdata); | 701 | mpath = mesh_path_lookup(preq_node->dst, sdata); |
@@ -720,18 +720,18 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) | |||
720 | goto enddiscovery; | 720 | goto enddiscovery; |
721 | } | 721 | } |
722 | 722 | ||
723 | ifsta->last_preq = jiffies; | 723 | ifmsh->last_preq = jiffies; |
724 | 724 | ||
725 | if (time_after(jiffies, ifsta->last_dsn_update + | 725 | if (time_after(jiffies, ifmsh->last_dsn_update + |
726 | net_traversal_jiffies(sdata)) || | 726 | net_traversal_jiffies(sdata)) || |
727 | time_before(jiffies, ifsta->last_dsn_update)) { | 727 | time_before(jiffies, ifmsh->last_dsn_update)) { |
728 | ++ifsta->dsn; | 728 | ++ifmsh->dsn; |
729 | sdata->u.sta.last_dsn_update = jiffies; | 729 | sdata->u.mesh.last_dsn_update = jiffies; |
730 | } | 730 | } |
731 | lifetime = default_lifetime(sdata); | 731 | lifetime = default_lifetime(sdata); |
732 | ttl = sdata->u.sta.mshcfg.dot11MeshTTL; | 732 | ttl = sdata->u.mesh.mshcfg.dot11MeshTTL; |
733 | if (ttl == 0) { | 733 | if (ttl == 0) { |
734 | sdata->u.sta.mshstats.dropped_frames_ttl++; | 734 | sdata->u.mesh.mshstats.dropped_frames_ttl++; |
735 | spin_unlock_bh(&mpath->state_lock); | 735 | spin_unlock_bh(&mpath->state_lock); |
736 | goto enddiscovery; | 736 | goto enddiscovery; |
737 | } | 737 | } |
@@ -743,10 +743,10 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) | |||
743 | 743 | ||
744 | spin_unlock_bh(&mpath->state_lock); | 744 | spin_unlock_bh(&mpath->state_lock); |
745 | mesh_path_sel_frame_tx(MPATH_PREQ, 0, sdata->dev->dev_addr, | 745 | mesh_path_sel_frame_tx(MPATH_PREQ, 0, sdata->dev->dev_addr, |
746 | cpu_to_le32(ifsta->dsn), dst_flags, mpath->dst, | 746 | cpu_to_le32(ifmsh->dsn), dst_flags, mpath->dst, |
747 | cpu_to_le32(mpath->dsn), sdata->dev->broadcast, 0, | 747 | cpu_to_le32(mpath->dsn), sdata->dev->broadcast, 0, |
748 | ttl, cpu_to_le32(lifetime), 0, | 748 | ttl, cpu_to_le32(lifetime), 0, |
749 | cpu_to_le32(ifsta->preq_id++), sdata); | 749 | cpu_to_le32(ifmsh->preq_id++), sdata); |
750 | mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout); | 750 | mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout); |
751 | 751 | ||
752 | enddiscovery: | 752 | enddiscovery: |
@@ -783,7 +783,7 @@ int mesh_nexthop_lookup(struct sk_buff *skb, | |||
783 | mpath = mesh_path_lookup(dst_addr, sdata); | 783 | mpath = mesh_path_lookup(dst_addr, sdata); |
784 | if (!mpath) { | 784 | if (!mpath) { |
785 | dev_kfree_skb(skb); | 785 | dev_kfree_skb(skb); |
786 | sdata->u.sta.mshstats.dropped_frames_no_route++; | 786 | sdata->u.mesh.mshstats.dropped_frames_no_route++; |
787 | err = -ENOSPC; | 787 | err = -ENOSPC; |
788 | goto endlookup; | 788 | goto endlookup; |
789 | } | 789 | } |
@@ -791,7 +791,7 @@ int mesh_nexthop_lookup(struct sk_buff *skb, | |||
791 | 791 | ||
792 | if (mpath->flags & MESH_PATH_ACTIVE) { | 792 | if (mpath->flags & MESH_PATH_ACTIVE) { |
793 | if (time_after(jiffies, mpath->exp_time - | 793 | if (time_after(jiffies, mpath->exp_time - |
794 | msecs_to_jiffies(sdata->u.sta.mshcfg.path_refresh_time)) | 794 | msecs_to_jiffies(sdata->u.mesh.mshcfg.path_refresh_time)) |
795 | && !memcmp(sdata->dev->dev_addr, hdr->addr4, | 795 | && !memcmp(sdata->dev->dev_addr, hdr->addr4, |
796 | ETH_ALEN) | 796 | ETH_ALEN) |
797 | && !(mpath->flags & MESH_PATH_RESOLVING) | 797 | && !(mpath->flags & MESH_PATH_RESOLVING) |