Lines Matching refs:mpath
382 struct mesh_path *mpath; in hwmp_route_info_get() local
439 mpath = mesh_path_lookup(sdata, orig_addr); in hwmp_route_info_get()
440 if (mpath) { in hwmp_route_info_get()
441 spin_lock_bh(&mpath->state_lock); in hwmp_route_info_get()
442 if (mpath->flags & MESH_PATH_FIXED) in hwmp_route_info_get()
444 else if ((mpath->flags & MESH_PATH_ACTIVE) && in hwmp_route_info_get()
445 (mpath->flags & MESH_PATH_SN_VALID)) { in hwmp_route_info_get()
446 if (SN_GT(mpath->sn, orig_sn) || in hwmp_route_info_get()
447 (mpath->sn == orig_sn && in hwmp_route_info_get()
448 (rcu_access_pointer(mpath->next_hop) != in hwmp_route_info_get()
451 new_metric) >= mpath->metric)) { in hwmp_route_info_get()
455 } else if (!(mpath->flags & MESH_PATH_ACTIVE)) { in hwmp_route_info_get()
458 have_sn = mpath->flags & MESH_PATH_SN_VALID; in hwmp_route_info_get()
459 newer_sn = have_sn && SN_GT(orig_sn, mpath->sn); in hwmp_route_info_get()
461 (SN_DELTA(orig_sn, mpath->sn) > in hwmp_route_info_get()
477 mpath = mesh_path_add(sdata, orig_addr); in hwmp_route_info_get()
478 if (IS_ERR(mpath)) { in hwmp_route_info_get()
482 spin_lock_bh(&mpath->state_lock); in hwmp_route_info_get()
486 if (rcu_access_pointer(mpath->next_hop) != sta) in hwmp_route_info_get()
487 mpath->path_change_count++; in hwmp_route_info_get()
488 mesh_path_assign_nexthop(mpath, sta); in hwmp_route_info_get()
489 mpath->flags |= MESH_PATH_SN_VALID; in hwmp_route_info_get()
490 mpath->metric = new_metric; in hwmp_route_info_get()
491 mpath->sn = orig_sn; in hwmp_route_info_get()
492 mpath->exp_time = time_after(mpath->exp_time, exp_time) in hwmp_route_info_get()
493 ? mpath->exp_time : exp_time; in hwmp_route_info_get()
494 mpath->hop_count = hopcount; in hwmp_route_info_get()
495 mesh_path_activate(mpath); in hwmp_route_info_get()
496 spin_unlock_bh(&mpath->state_lock); in hwmp_route_info_get()
500 mesh_path_tx_pending(mpath); in hwmp_route_info_get()
505 spin_unlock_bh(&mpath->state_lock); in hwmp_route_info_get()
515 mpath = mesh_path_lookup(sdata, ta); in hwmp_route_info_get()
516 if (mpath) { in hwmp_route_info_get()
517 spin_lock_bh(&mpath->state_lock); in hwmp_route_info_get()
518 if ((mpath->flags & MESH_PATH_FIXED) || in hwmp_route_info_get()
519 ((mpath->flags & MESH_PATH_ACTIVE) && in hwmp_route_info_get()
520 ((rcu_access_pointer(mpath->next_hop) != sta ? in hwmp_route_info_get()
522 last_hop_metric) > mpath->metric))) in hwmp_route_info_get()
525 mpath = mesh_path_add(sdata, ta); in hwmp_route_info_get()
526 if (IS_ERR(mpath)) { in hwmp_route_info_get()
530 spin_lock_bh(&mpath->state_lock); in hwmp_route_info_get()
534 if (rcu_access_pointer(mpath->next_hop) != sta) in hwmp_route_info_get()
535 mpath->path_change_count++; in hwmp_route_info_get()
536 mesh_path_assign_nexthop(mpath, sta); in hwmp_route_info_get()
537 mpath->metric = last_hop_metric; in hwmp_route_info_get()
538 mpath->exp_time = time_after(mpath->exp_time, exp_time) in hwmp_route_info_get()
539 ? mpath->exp_time : exp_time; in hwmp_route_info_get()
540 mpath->hop_count = 1; in hwmp_route_info_get()
541 mesh_path_activate(mpath); in hwmp_route_info_get()
542 spin_unlock_bh(&mpath->state_lock); in hwmp_route_info_get()
546 mesh_path_tx_pending(mpath); in hwmp_route_info_get()
548 spin_unlock_bh(&mpath->state_lock); in hwmp_route_info_get()
561 struct mesh_path *mpath = NULL; in hwmp_preq_frame_process() local
601 mpath = mesh_path_lookup(sdata, orig_addr); in hwmp_preq_frame_process()
602 if (mpath) { in hwmp_preq_frame_process()
611 mesh_path_add_gate(mpath); in hwmp_preq_frame_process()
616 mpath = mesh_path_lookup(sdata, target_addr); in hwmp_preq_frame_process()
617 if (mpath) { in hwmp_preq_frame_process()
618 if ((!(mpath->flags & MESH_PATH_SN_VALID)) || in hwmp_preq_frame_process()
619 SN_LT(mpath->sn, target_sn)) { in hwmp_preq_frame_process()
620 mpath->sn = target_sn; in hwmp_preq_frame_process()
621 mpath->flags |= MESH_PATH_SN_VALID; in hwmp_preq_frame_process()
623 (mpath->flags & MESH_PATH_ACTIVE)) { in hwmp_preq_frame_process()
625 target_metric = mpath->metric; in hwmp_preq_frame_process()
626 target_sn = mpath->sn; in hwmp_preq_frame_process()
663 da = (mpath && mpath->is_root) ? in hwmp_preq_frame_process()
664 mpath->rann_snd_addr : broadcast_addr; in hwmp_preq_frame_process()
685 next_hop_deref_protected(struct mesh_path *mpath) in next_hop_deref_protected() argument
687 return rcu_dereference_protected(mpath->next_hop, in next_hop_deref_protected()
688 lockdep_is_held(&mpath->state_lock)); in next_hop_deref_protected()
697 struct mesh_path *mpath; in hwmp_prep_frame_process() local
721 mpath = mesh_path_lookup(sdata, orig_addr); in hwmp_prep_frame_process()
722 if (mpath) in hwmp_prep_frame_process()
723 spin_lock_bh(&mpath->state_lock); in hwmp_prep_frame_process()
726 if (!(mpath->flags & MESH_PATH_ACTIVE)) { in hwmp_prep_frame_process()
727 spin_unlock_bh(&mpath->state_lock); in hwmp_prep_frame_process()
730 memcpy(next_hop, next_hop_deref_protected(mpath)->sta.addr, ETH_ALEN); in hwmp_prep_frame_process()
731 spin_unlock_bh(&mpath->state_lock); in hwmp_prep_frame_process()
759 struct mesh_path *mpath; in hwmp_perr_frame_process() local
777 mpath = mesh_path_lookup(sdata, target_addr); in hwmp_perr_frame_process()
778 if (mpath) { in hwmp_perr_frame_process()
781 spin_lock_bh(&mpath->state_lock); in hwmp_perr_frame_process()
782 sta = next_hop_deref_protected(mpath); in hwmp_perr_frame_process()
783 if (mpath->flags & MESH_PATH_ACTIVE && in hwmp_perr_frame_process()
785 !(mpath->flags & MESH_PATH_FIXED) && in hwmp_perr_frame_process()
786 (!(mpath->flags & MESH_PATH_SN_VALID) || in hwmp_perr_frame_process()
787 SN_GT(target_sn, mpath->sn) || target_sn == 0)) { in hwmp_perr_frame_process()
788 mpath->flags &= ~MESH_PATH_ACTIVE; in hwmp_perr_frame_process()
790 mpath->sn = target_sn; in hwmp_perr_frame_process()
792 mpath->sn += 1; in hwmp_perr_frame_process()
793 spin_unlock_bh(&mpath->state_lock); in hwmp_perr_frame_process()
800 spin_unlock_bh(&mpath->state_lock); in hwmp_perr_frame_process()
813 struct mesh_path *mpath; in hwmp_rann_frame_process() local
849 mpath = mesh_path_lookup(sdata, orig_addr); in hwmp_rann_frame_process()
850 if (!mpath) { in hwmp_rann_frame_process()
851 mpath = mesh_path_add(sdata, orig_addr); in hwmp_rann_frame_process()
852 if (IS_ERR(mpath)) { in hwmp_rann_frame_process()
859 if (!(SN_LT(mpath->sn, orig_sn)) && in hwmp_rann_frame_process()
860 !(mpath->sn == orig_sn && new_metric < mpath->rann_metric)) { in hwmp_rann_frame_process()
865 if ((!(mpath->flags & (MESH_PATH_ACTIVE | MESH_PATH_RESOLVING)) || in hwmp_rann_frame_process()
866 (time_after(jiffies, mpath->last_preq_to_root + in hwmp_rann_frame_process()
868 time_before(jiffies, mpath->last_preq_to_root))) && in hwmp_rann_frame_process()
869 !(mpath->flags & MESH_PATH_FIXED) && (ttl != 0)) { in hwmp_rann_frame_process()
873 mesh_queue_preq(mpath, PREQ_Q_F_START | PREQ_Q_F_REFRESH); in hwmp_rann_frame_process()
874 mpath->last_preq_to_root = jiffies; in hwmp_rann_frame_process()
877 mpath->sn = orig_sn; in hwmp_rann_frame_process()
878 mpath->rann_metric = new_metric; in hwmp_rann_frame_process()
879 mpath->is_root = true; in hwmp_rann_frame_process()
882 memcpy(mpath->rann_snd_addr, mgmt->sa, ETH_ALEN); in hwmp_rann_frame_process()
885 mesh_path_add_gate(mpath); in hwmp_rann_frame_process()
968 static void mesh_queue_preq(struct mesh_path *mpath, u8 flags) in mesh_queue_preq() argument
970 struct ieee80211_sub_if_data *sdata = mpath->sdata; in mesh_queue_preq()
989 spin_lock(&mpath->state_lock); in mesh_queue_preq()
990 if (mpath->flags & MESH_PATH_REQ_QUEUED) { in mesh_queue_preq()
991 spin_unlock(&mpath->state_lock); in mesh_queue_preq()
997 memcpy(preq_node->dst, mpath->dst, ETH_ALEN); in mesh_queue_preq()
1000 mpath->flags |= MESH_PATH_REQ_QUEUED; in mesh_queue_preq()
1001 spin_unlock(&mpath->state_lock); in mesh_queue_preq()
1030 struct mesh_path *mpath; in mesh_path_start_discovery() local
1050 mpath = mesh_path_lookup(sdata, preq_node->dst); in mesh_path_start_discovery()
1051 if (!mpath) in mesh_path_start_discovery()
1054 spin_lock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1055 if (mpath->flags & (MESH_PATH_DELETED | MESH_PATH_FIXED)) { in mesh_path_start_discovery()
1056 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1059 mpath->flags &= ~MESH_PATH_REQ_QUEUED; in mesh_path_start_discovery()
1061 if (mpath->flags & MESH_PATH_RESOLVING) { in mesh_path_start_discovery()
1062 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1065 mpath->flags &= ~MESH_PATH_RESOLVED; in mesh_path_start_discovery()
1066 mpath->flags |= MESH_PATH_RESOLVING; in mesh_path_start_discovery()
1067 mpath->discovery_retries = 0; in mesh_path_start_discovery()
1068 mpath->discovery_timeout = disc_timeout_jiff(sdata); in mesh_path_start_discovery()
1070 } else if (!(mpath->flags & MESH_PATH_RESOLVING) || in mesh_path_start_discovery()
1071 mpath->flags & MESH_PATH_RESOLVED) { in mesh_path_start_discovery()
1072 mpath->flags &= ~MESH_PATH_RESOLVING; in mesh_path_start_discovery()
1073 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1089 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1098 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1099 da = (mpath->is_root) ? mpath->rann_snd_addr : broadcast_addr; in mesh_path_start_discovery()
1101 target_flags, mpath->dst, mpath->sn, da, 0, in mesh_path_start_discovery()
1103 mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout); in mesh_path_start_discovery()
1127 struct mesh_path *mpath; in mesh_nexthop_resolve() local
1143 mpath = mesh_path_lookup(sdata, target_addr); in mesh_nexthop_resolve()
1144 if (!mpath) { in mesh_nexthop_resolve()
1145 mpath = mesh_path_add(sdata, target_addr); in mesh_nexthop_resolve()
1146 if (IS_ERR(mpath)) { in mesh_nexthop_resolve()
1148 return PTR_ERR(mpath); in mesh_nexthop_resolve()
1152 if (!(mpath->flags & MESH_PATH_RESOLVING)) in mesh_nexthop_resolve()
1153 mesh_queue_preq(mpath, PREQ_Q_F_START); in mesh_nexthop_resolve()
1155 if (skb_queue_len(&mpath->frame_queue) >= MESH_FRAME_QUEUE_LEN) in mesh_nexthop_resolve()
1156 skb_to_free = skb_dequeue(&mpath->frame_queue); in mesh_nexthop_resolve()
1160 skb_queue_tail(&mpath->frame_queue, skb); in mesh_nexthop_resolve()
1180 struct mesh_path *mpath; in mesh_nexthop_lookup() local
1185 mpath = mesh_path_lookup(sdata, target_addr); in mesh_nexthop_lookup()
1186 if (!mpath || !(mpath->flags & MESH_PATH_ACTIVE)) in mesh_nexthop_lookup()
1190 mpath->exp_time - in mesh_nexthop_lookup()
1193 !(mpath->flags & MESH_PATH_RESOLVING) && in mesh_nexthop_lookup()
1194 !(mpath->flags & MESH_PATH_FIXED)) in mesh_nexthop_lookup()
1195 mesh_queue_preq(mpath, PREQ_Q_F_START | PREQ_Q_F_REFRESH); in mesh_nexthop_lookup()
1197 next_hop = rcu_dereference(mpath->next_hop); in mesh_nexthop_lookup()
1210 struct mesh_path *mpath = from_timer(mpath, t, timer); in mesh_path_timer() local
1211 struct ieee80211_sub_if_data *sdata = mpath->sdata; in mesh_path_timer()
1217 spin_lock_bh(&mpath->state_lock); in mesh_path_timer()
1218 if (mpath->flags & MESH_PATH_RESOLVED || in mesh_path_timer()
1219 (!(mpath->flags & MESH_PATH_RESOLVING))) { in mesh_path_timer()
1220 mpath->flags &= ~(MESH_PATH_RESOLVING | MESH_PATH_RESOLVED); in mesh_path_timer()
1221 spin_unlock_bh(&mpath->state_lock); in mesh_path_timer()
1222 } else if (mpath->discovery_retries < max_preq_retries(sdata)) { in mesh_path_timer()
1223 ++mpath->discovery_retries; in mesh_path_timer()
1224 mpath->discovery_timeout *= 2; in mesh_path_timer()
1225 mpath->flags &= ~MESH_PATH_REQ_QUEUED; in mesh_path_timer()
1226 spin_unlock_bh(&mpath->state_lock); in mesh_path_timer()
1227 mesh_queue_preq(mpath, 0); in mesh_path_timer()
1229 mpath->flags &= ~(MESH_PATH_RESOLVING | in mesh_path_timer()
1232 mpath->exp_time = jiffies; in mesh_path_timer()
1233 spin_unlock_bh(&mpath->state_lock); in mesh_path_timer()
1234 if (!mpath->is_gate && mesh_gate_num(sdata) > 0) { in mesh_path_timer()
1235 ret = mesh_path_send_to_gates(mpath); in mesh_path_timer()
1239 mesh_path_flush_pending(mpath); in mesh_path_timer()