Lines Matching refs:mpath
385 struct mesh_path *mpath; in hwmp_route_info_get() local
442 mpath = mesh_path_lookup(sdata, orig_addr); in hwmp_route_info_get()
443 if (mpath) { in hwmp_route_info_get()
444 spin_lock_bh(&mpath->state_lock); in hwmp_route_info_get()
445 if (mpath->flags & MESH_PATH_FIXED) in hwmp_route_info_get()
447 else if ((mpath->flags & MESH_PATH_ACTIVE) && in hwmp_route_info_get()
448 (mpath->flags & MESH_PATH_SN_VALID)) { in hwmp_route_info_get()
449 if (SN_GT(mpath->sn, orig_sn) || in hwmp_route_info_get()
450 (mpath->sn == orig_sn && in hwmp_route_info_get()
451 (rcu_access_pointer(mpath->next_hop) != in hwmp_route_info_get()
454 new_metric) >= mpath->metric)) { in hwmp_route_info_get()
458 } else if (!(mpath->flags & MESH_PATH_ACTIVE)) { in hwmp_route_info_get()
461 have_sn = mpath->flags & MESH_PATH_SN_VALID; in hwmp_route_info_get()
462 newer_sn = have_sn && SN_GT(orig_sn, mpath->sn); in hwmp_route_info_get()
464 (SN_DELTA(orig_sn, mpath->sn) > in hwmp_route_info_get()
480 mpath = mesh_path_add(sdata, orig_addr); in hwmp_route_info_get()
481 if (IS_ERR(mpath)) { in hwmp_route_info_get()
485 spin_lock_bh(&mpath->state_lock); in hwmp_route_info_get()
489 if (rcu_access_pointer(mpath->next_hop) != sta) in hwmp_route_info_get()
490 mpath->path_change_count++; in hwmp_route_info_get()
491 mesh_path_assign_nexthop(mpath, sta); in hwmp_route_info_get()
492 mpath->flags |= MESH_PATH_SN_VALID; in hwmp_route_info_get()
493 mpath->metric = new_metric; in hwmp_route_info_get()
494 mpath->sn = orig_sn; in hwmp_route_info_get()
495 mpath->exp_time = time_after(mpath->exp_time, exp_time) in hwmp_route_info_get()
496 ? mpath->exp_time : exp_time; in hwmp_route_info_get()
497 mpath->hop_count = hopcount; in hwmp_route_info_get()
498 mesh_path_activate(mpath); in hwmp_route_info_get()
499 spin_unlock_bh(&mpath->state_lock); in hwmp_route_info_get()
503 mesh_path_tx_pending(mpath); in hwmp_route_info_get()
508 spin_unlock_bh(&mpath->state_lock); in hwmp_route_info_get()
518 mpath = mesh_path_lookup(sdata, ta); in hwmp_route_info_get()
519 if (mpath) { in hwmp_route_info_get()
520 spin_lock_bh(&mpath->state_lock); in hwmp_route_info_get()
521 if ((mpath->flags & MESH_PATH_FIXED) || in hwmp_route_info_get()
522 ((mpath->flags & MESH_PATH_ACTIVE) && in hwmp_route_info_get()
523 ((rcu_access_pointer(mpath->next_hop) != sta ? in hwmp_route_info_get()
525 last_hop_metric) > mpath->metric))) in hwmp_route_info_get()
528 mpath = mesh_path_add(sdata, ta); in hwmp_route_info_get()
529 if (IS_ERR(mpath)) { in hwmp_route_info_get()
533 spin_lock_bh(&mpath->state_lock); in hwmp_route_info_get()
537 if (rcu_access_pointer(mpath->next_hop) != sta) in hwmp_route_info_get()
538 mpath->path_change_count++; in hwmp_route_info_get()
539 mesh_path_assign_nexthop(mpath, sta); in hwmp_route_info_get()
540 mpath->metric = last_hop_metric; in hwmp_route_info_get()
541 mpath->exp_time = time_after(mpath->exp_time, exp_time) in hwmp_route_info_get()
542 ? mpath->exp_time : exp_time; in hwmp_route_info_get()
543 mpath->hop_count = 1; in hwmp_route_info_get()
544 mesh_path_activate(mpath); in hwmp_route_info_get()
545 spin_unlock_bh(&mpath->state_lock); in hwmp_route_info_get()
549 mesh_path_tx_pending(mpath); in hwmp_route_info_get()
551 spin_unlock_bh(&mpath->state_lock); in hwmp_route_info_get()
564 struct mesh_path *mpath = NULL; in hwmp_preq_frame_process() local
604 mpath = mesh_path_lookup(sdata, orig_addr); in hwmp_preq_frame_process()
605 if (mpath) { in hwmp_preq_frame_process()
614 mesh_path_add_gate(mpath); in hwmp_preq_frame_process()
619 mpath = mesh_path_lookup(sdata, target_addr); in hwmp_preq_frame_process()
620 if (mpath) { in hwmp_preq_frame_process()
621 if ((!(mpath->flags & MESH_PATH_SN_VALID)) || in hwmp_preq_frame_process()
622 SN_LT(mpath->sn, target_sn)) { in hwmp_preq_frame_process()
623 mpath->sn = target_sn; in hwmp_preq_frame_process()
624 mpath->flags |= MESH_PATH_SN_VALID; in hwmp_preq_frame_process()
626 (mpath->flags & MESH_PATH_ACTIVE)) { in hwmp_preq_frame_process()
628 target_metric = mpath->metric; in hwmp_preq_frame_process()
629 target_sn = mpath->sn; in hwmp_preq_frame_process()
666 da = (mpath && mpath->is_root) ? in hwmp_preq_frame_process()
667 mpath->rann_snd_addr : broadcast_addr; in hwmp_preq_frame_process()
688 next_hop_deref_protected(struct mesh_path *mpath) in next_hop_deref_protected() argument
690 return rcu_dereference_protected(mpath->next_hop, in next_hop_deref_protected()
691 lockdep_is_held(&mpath->state_lock)); in next_hop_deref_protected()
700 struct mesh_path *mpath; in hwmp_prep_frame_process() local
724 mpath = mesh_path_lookup(sdata, orig_addr); in hwmp_prep_frame_process()
725 if (mpath) in hwmp_prep_frame_process()
726 spin_lock_bh(&mpath->state_lock); in hwmp_prep_frame_process()
729 if (!(mpath->flags & MESH_PATH_ACTIVE)) { in hwmp_prep_frame_process()
730 spin_unlock_bh(&mpath->state_lock); in hwmp_prep_frame_process()
733 memcpy(next_hop, next_hop_deref_protected(mpath)->sta.addr, ETH_ALEN); in hwmp_prep_frame_process()
734 spin_unlock_bh(&mpath->state_lock); in hwmp_prep_frame_process()
762 struct mesh_path *mpath; in hwmp_perr_frame_process() local
780 mpath = mesh_path_lookup(sdata, target_addr); in hwmp_perr_frame_process()
781 if (mpath) { in hwmp_perr_frame_process()
784 spin_lock_bh(&mpath->state_lock); in hwmp_perr_frame_process()
785 sta = next_hop_deref_protected(mpath); in hwmp_perr_frame_process()
786 if (mpath->flags & MESH_PATH_ACTIVE && in hwmp_perr_frame_process()
788 !(mpath->flags & MESH_PATH_FIXED) && in hwmp_perr_frame_process()
789 (!(mpath->flags & MESH_PATH_SN_VALID) || in hwmp_perr_frame_process()
790 SN_GT(target_sn, mpath->sn) || target_sn == 0)) { in hwmp_perr_frame_process()
791 mpath->flags &= ~MESH_PATH_ACTIVE; in hwmp_perr_frame_process()
793 mpath->sn = target_sn; in hwmp_perr_frame_process()
795 mpath->sn += 1; in hwmp_perr_frame_process()
796 spin_unlock_bh(&mpath->state_lock); in hwmp_perr_frame_process()
803 spin_unlock_bh(&mpath->state_lock); in hwmp_perr_frame_process()
816 struct mesh_path *mpath; in hwmp_rann_frame_process() local
852 mpath = mesh_path_lookup(sdata, orig_addr); in hwmp_rann_frame_process()
853 if (!mpath) { in hwmp_rann_frame_process()
854 mpath = mesh_path_add(sdata, orig_addr); in hwmp_rann_frame_process()
855 if (IS_ERR(mpath)) { in hwmp_rann_frame_process()
862 if (!(SN_LT(mpath->sn, orig_sn)) && in hwmp_rann_frame_process()
863 !(mpath->sn == orig_sn && new_metric < mpath->rann_metric)) { in hwmp_rann_frame_process()
868 if ((!(mpath->flags & (MESH_PATH_ACTIVE | MESH_PATH_RESOLVING)) || in hwmp_rann_frame_process()
869 (time_after(jiffies, mpath->last_preq_to_root + in hwmp_rann_frame_process()
871 time_before(jiffies, mpath->last_preq_to_root))) && in hwmp_rann_frame_process()
872 !(mpath->flags & MESH_PATH_FIXED) && (ttl != 0)) { in hwmp_rann_frame_process()
876 mesh_queue_preq(mpath, PREQ_Q_F_START | PREQ_Q_F_REFRESH); in hwmp_rann_frame_process()
877 mpath->last_preq_to_root = jiffies; in hwmp_rann_frame_process()
880 mpath->sn = orig_sn; in hwmp_rann_frame_process()
881 mpath->rann_metric = new_metric; in hwmp_rann_frame_process()
882 mpath->is_root = true; in hwmp_rann_frame_process()
885 memcpy(mpath->rann_snd_addr, mgmt->sa, ETH_ALEN); in hwmp_rann_frame_process()
888 mesh_path_add_gate(mpath); in hwmp_rann_frame_process()
971 static void mesh_queue_preq(struct mesh_path *mpath, u8 flags) in mesh_queue_preq() argument
973 struct ieee80211_sub_if_data *sdata = mpath->sdata; in mesh_queue_preq()
992 spin_lock(&mpath->state_lock); in mesh_queue_preq()
993 if (mpath->flags & MESH_PATH_REQ_QUEUED) { in mesh_queue_preq()
994 spin_unlock(&mpath->state_lock); in mesh_queue_preq()
1000 memcpy(preq_node->dst, mpath->dst, ETH_ALEN); in mesh_queue_preq()
1003 mpath->flags |= MESH_PATH_REQ_QUEUED; in mesh_queue_preq()
1004 spin_unlock(&mpath->state_lock); in mesh_queue_preq()
1033 struct mesh_path *mpath; in mesh_path_start_discovery() local
1053 mpath = mesh_path_lookup(sdata, preq_node->dst); in mesh_path_start_discovery()
1054 if (!mpath) in mesh_path_start_discovery()
1057 spin_lock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1058 if (mpath->flags & (MESH_PATH_DELETED | MESH_PATH_FIXED)) { in mesh_path_start_discovery()
1059 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1062 mpath->flags &= ~MESH_PATH_REQ_QUEUED; in mesh_path_start_discovery()
1064 if (mpath->flags & MESH_PATH_RESOLVING) { in mesh_path_start_discovery()
1065 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1068 mpath->flags &= ~MESH_PATH_RESOLVED; in mesh_path_start_discovery()
1069 mpath->flags |= MESH_PATH_RESOLVING; in mesh_path_start_discovery()
1070 mpath->discovery_retries = 0; in mesh_path_start_discovery()
1071 mpath->discovery_timeout = disc_timeout_jiff(sdata); in mesh_path_start_discovery()
1073 } else if (!(mpath->flags & MESH_PATH_RESOLVING) || in mesh_path_start_discovery()
1074 mpath->flags & MESH_PATH_RESOLVED) { in mesh_path_start_discovery()
1075 mpath->flags &= ~MESH_PATH_RESOLVING; in mesh_path_start_discovery()
1076 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1092 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1101 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1102 da = (mpath->is_root) ? mpath->rann_snd_addr : broadcast_addr; in mesh_path_start_discovery()
1104 target_flags, mpath->dst, mpath->sn, da, 0, in mesh_path_start_discovery()
1107 spin_lock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1108 if (!(mpath->flags & MESH_PATH_DELETED)) in mesh_path_start_discovery()
1109 mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout); in mesh_path_start_discovery()
1110 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1134 struct mesh_path *mpath; in mesh_nexthop_resolve() local
1150 mpath = mesh_path_lookup(sdata, target_addr); in mesh_nexthop_resolve()
1151 if (!mpath) { in mesh_nexthop_resolve()
1152 mpath = mesh_path_add(sdata, target_addr); in mesh_nexthop_resolve()
1153 if (IS_ERR(mpath)) { in mesh_nexthop_resolve()
1155 return PTR_ERR(mpath); in mesh_nexthop_resolve()
1159 if (!(mpath->flags & MESH_PATH_RESOLVING) && in mesh_nexthop_resolve()
1161 mesh_queue_preq(mpath, PREQ_Q_F_START); in mesh_nexthop_resolve()
1163 if (skb_queue_len(&mpath->frame_queue) >= MESH_FRAME_QUEUE_LEN) in mesh_nexthop_resolve()
1164 skb_to_free = skb_dequeue(&mpath->frame_queue); in mesh_nexthop_resolve()
1168 skb_queue_tail(&mpath->frame_queue, skb); in mesh_nexthop_resolve()
1223 struct mesh_path *mpath; in mesh_nexthop_lookup() local
1232 mpath = mesh_path_lookup(sdata, target_addr); in mesh_nexthop_lookup()
1233 if (!mpath || !(mpath->flags & MESH_PATH_ACTIVE)) in mesh_nexthop_lookup()
1237 mpath->exp_time - in mesh_nexthop_lookup()
1240 !(mpath->flags & MESH_PATH_RESOLVING) && in mesh_nexthop_lookup()
1241 !(mpath->flags & MESH_PATH_FIXED)) in mesh_nexthop_lookup()
1242 mesh_queue_preq(mpath, PREQ_Q_F_START | PREQ_Q_F_REFRESH); in mesh_nexthop_lookup()
1244 next_hop = rcu_dereference(mpath->next_hop); in mesh_nexthop_lookup()
1257 struct mesh_path *mpath = from_timer(mpath, t, timer); in mesh_path_timer() local
1258 struct ieee80211_sub_if_data *sdata = mpath->sdata; in mesh_path_timer()
1264 spin_lock_bh(&mpath->state_lock); in mesh_path_timer()
1265 if (mpath->flags & MESH_PATH_RESOLVED || in mesh_path_timer()
1266 (!(mpath->flags & MESH_PATH_RESOLVING))) { in mesh_path_timer()
1267 mpath->flags &= ~(MESH_PATH_RESOLVING | MESH_PATH_RESOLVED); in mesh_path_timer()
1268 spin_unlock_bh(&mpath->state_lock); in mesh_path_timer()
1269 } else if (mpath->discovery_retries < max_preq_retries(sdata)) { in mesh_path_timer()
1270 ++mpath->discovery_retries; in mesh_path_timer()
1271 mpath->discovery_timeout *= 2; in mesh_path_timer()
1272 mpath->flags &= ~MESH_PATH_REQ_QUEUED; in mesh_path_timer()
1273 spin_unlock_bh(&mpath->state_lock); in mesh_path_timer()
1274 mesh_queue_preq(mpath, 0); in mesh_path_timer()
1276 mpath->flags &= ~(MESH_PATH_RESOLVING | in mesh_path_timer()
1279 mpath->exp_time = jiffies; in mesh_path_timer()
1280 spin_unlock_bh(&mpath->state_lock); in mesh_path_timer()
1281 if (!mpath->is_gate && mesh_gate_num(sdata) > 0) { in mesh_path_timer()
1282 ret = mesh_path_send_to_gates(mpath); in mesh_path_timer()
1286 mesh_path_flush_pending(mpath); in mesh_path_timer()