Lines Matching refs:mpath
390 struct mesh_path *mpath; in hwmp_route_info_get() local
448 mpath = mesh_path_lookup(sdata, orig_addr); in hwmp_route_info_get()
449 if (mpath) { in hwmp_route_info_get()
450 spin_lock_bh(&mpath->state_lock); in hwmp_route_info_get()
451 if (mpath->flags & MESH_PATH_FIXED) in hwmp_route_info_get()
453 else if ((mpath->flags & MESH_PATH_ACTIVE) && in hwmp_route_info_get()
454 (mpath->flags & MESH_PATH_SN_VALID)) { in hwmp_route_info_get()
455 if (SN_GT(mpath->sn, orig_sn) || in hwmp_route_info_get()
456 (mpath->sn == orig_sn && in hwmp_route_info_get()
457 (rcu_access_pointer(mpath->next_hop) != in hwmp_route_info_get()
460 new_metric) >= mpath->metric)) { in hwmp_route_info_get()
464 } else if (!(mpath->flags & MESH_PATH_ACTIVE)) { in hwmp_route_info_get()
467 have_sn = mpath->flags & MESH_PATH_SN_VALID; in hwmp_route_info_get()
468 newer_sn = have_sn && SN_GT(orig_sn, mpath->sn); in hwmp_route_info_get()
470 (SN_DELTA(orig_sn, mpath->sn) > in hwmp_route_info_get()
486 mpath = mesh_path_add(sdata, orig_addr); in hwmp_route_info_get()
487 if (IS_ERR(mpath)) { in hwmp_route_info_get()
491 spin_lock_bh(&mpath->state_lock); in hwmp_route_info_get()
495 if (rcu_access_pointer(mpath->next_hop) != sta) { in hwmp_route_info_get()
496 mpath->path_change_count++; in hwmp_route_info_get()
499 mesh_path_assign_nexthop(mpath, sta); in hwmp_route_info_get()
500 mpath->flags |= MESH_PATH_SN_VALID; in hwmp_route_info_get()
501 mpath->metric = new_metric; in hwmp_route_info_get()
502 mpath->sn = orig_sn; in hwmp_route_info_get()
503 mpath->exp_time = time_after(mpath->exp_time, exp_time) in hwmp_route_info_get()
504 ? mpath->exp_time : exp_time; in hwmp_route_info_get()
505 mpath->hop_count = hopcount; in hwmp_route_info_get()
506 mesh_path_activate(mpath); in hwmp_route_info_get()
507 spin_unlock_bh(&mpath->state_lock); in hwmp_route_info_get()
509 mesh_fast_tx_flush_mpath(mpath); in hwmp_route_info_get()
513 mesh_path_tx_pending(mpath); in hwmp_route_info_get()
518 spin_unlock_bh(&mpath->state_lock); in hwmp_route_info_get()
528 mpath = mesh_path_lookup(sdata, ta); in hwmp_route_info_get()
529 if (mpath) { in hwmp_route_info_get()
530 spin_lock_bh(&mpath->state_lock); in hwmp_route_info_get()
531 if ((mpath->flags & MESH_PATH_FIXED) || in hwmp_route_info_get()
532 ((mpath->flags & MESH_PATH_ACTIVE) && in hwmp_route_info_get()
533 ((rcu_access_pointer(mpath->next_hop) != sta ? in hwmp_route_info_get()
535 last_hop_metric) > mpath->metric))) in hwmp_route_info_get()
538 mpath = mesh_path_add(sdata, ta); in hwmp_route_info_get()
539 if (IS_ERR(mpath)) { in hwmp_route_info_get()
543 spin_lock_bh(&mpath->state_lock); in hwmp_route_info_get()
547 if (rcu_access_pointer(mpath->next_hop) != sta) { in hwmp_route_info_get()
548 mpath->path_change_count++; in hwmp_route_info_get()
551 mesh_path_assign_nexthop(mpath, sta); in hwmp_route_info_get()
552 mpath->metric = last_hop_metric; in hwmp_route_info_get()
553 mpath->exp_time = time_after(mpath->exp_time, exp_time) in hwmp_route_info_get()
554 ? mpath->exp_time : exp_time; in hwmp_route_info_get()
555 mpath->hop_count = 1; in hwmp_route_info_get()
556 mesh_path_activate(mpath); in hwmp_route_info_get()
557 spin_unlock_bh(&mpath->state_lock); in hwmp_route_info_get()
559 mesh_fast_tx_flush_mpath(mpath); in hwmp_route_info_get()
563 mesh_path_tx_pending(mpath); in hwmp_route_info_get()
565 spin_unlock_bh(&mpath->state_lock); in hwmp_route_info_get()
578 struct mesh_path *mpath = NULL; in hwmp_preq_frame_process() local
618 mpath = mesh_path_lookup(sdata, orig_addr); in hwmp_preq_frame_process()
619 if (mpath) { in hwmp_preq_frame_process()
628 mesh_path_add_gate(mpath); in hwmp_preq_frame_process()
633 mpath = mesh_path_lookup(sdata, target_addr); in hwmp_preq_frame_process()
634 if (mpath) { in hwmp_preq_frame_process()
635 if ((!(mpath->flags & MESH_PATH_SN_VALID)) || in hwmp_preq_frame_process()
636 SN_LT(mpath->sn, target_sn)) { in hwmp_preq_frame_process()
637 mpath->sn = target_sn; in hwmp_preq_frame_process()
638 mpath->flags |= MESH_PATH_SN_VALID; in hwmp_preq_frame_process()
640 (mpath->flags & MESH_PATH_ACTIVE)) { in hwmp_preq_frame_process()
642 target_metric = mpath->metric; in hwmp_preq_frame_process()
643 target_sn = mpath->sn; in hwmp_preq_frame_process()
680 da = (mpath && mpath->is_root) ? in hwmp_preq_frame_process()
681 mpath->rann_snd_addr : broadcast_addr; in hwmp_preq_frame_process()
702 next_hop_deref_protected(struct mesh_path *mpath) in next_hop_deref_protected() argument
704 return rcu_dereference_protected(mpath->next_hop, in next_hop_deref_protected()
705 lockdep_is_held(&mpath->state_lock)); in next_hop_deref_protected()
714 struct mesh_path *mpath; in hwmp_prep_frame_process() local
738 mpath = mesh_path_lookup(sdata, orig_addr); in hwmp_prep_frame_process()
739 if (mpath) in hwmp_prep_frame_process()
740 spin_lock_bh(&mpath->state_lock); in hwmp_prep_frame_process()
743 if (!(mpath->flags & MESH_PATH_ACTIVE)) { in hwmp_prep_frame_process()
744 spin_unlock_bh(&mpath->state_lock); in hwmp_prep_frame_process()
747 memcpy(next_hop, next_hop_deref_protected(mpath)->sta.addr, ETH_ALEN); in hwmp_prep_frame_process()
748 spin_unlock_bh(&mpath->state_lock); in hwmp_prep_frame_process()
776 struct mesh_path *mpath; in hwmp_perr_frame_process() local
794 mpath = mesh_path_lookup(sdata, target_addr); in hwmp_perr_frame_process()
795 if (mpath) { in hwmp_perr_frame_process()
798 spin_lock_bh(&mpath->state_lock); in hwmp_perr_frame_process()
799 sta = next_hop_deref_protected(mpath); in hwmp_perr_frame_process()
800 if (mpath->flags & MESH_PATH_ACTIVE && in hwmp_perr_frame_process()
802 !(mpath->flags & MESH_PATH_FIXED) && in hwmp_perr_frame_process()
803 (!(mpath->flags & MESH_PATH_SN_VALID) || in hwmp_perr_frame_process()
804 SN_GT(target_sn, mpath->sn) || target_sn == 0)) { in hwmp_perr_frame_process()
805 mpath->flags &= ~MESH_PATH_ACTIVE; in hwmp_perr_frame_process()
807 mpath->sn = target_sn; in hwmp_perr_frame_process()
809 mpath->sn += 1; in hwmp_perr_frame_process()
810 spin_unlock_bh(&mpath->state_lock); in hwmp_perr_frame_process()
817 spin_unlock_bh(&mpath->state_lock); in hwmp_perr_frame_process()
830 struct mesh_path *mpath; in hwmp_rann_frame_process() local
866 mpath = mesh_path_lookup(sdata, orig_addr); in hwmp_rann_frame_process()
867 if (!mpath) { in hwmp_rann_frame_process()
868 mpath = mesh_path_add(sdata, orig_addr); in hwmp_rann_frame_process()
869 if (IS_ERR(mpath)) { in hwmp_rann_frame_process()
876 if (!(SN_LT(mpath->sn, orig_sn)) && in hwmp_rann_frame_process()
877 !(mpath->sn == orig_sn && new_metric < mpath->rann_metric)) { in hwmp_rann_frame_process()
882 if ((!(mpath->flags & (MESH_PATH_ACTIVE | MESH_PATH_RESOLVING)) || in hwmp_rann_frame_process()
883 (time_after(jiffies, mpath->last_preq_to_root + in hwmp_rann_frame_process()
885 time_before(jiffies, mpath->last_preq_to_root))) && in hwmp_rann_frame_process()
886 !(mpath->flags & MESH_PATH_FIXED) && (ttl != 0)) { in hwmp_rann_frame_process()
890 mesh_queue_preq(mpath, PREQ_Q_F_START | PREQ_Q_F_REFRESH); in hwmp_rann_frame_process()
891 mpath->last_preq_to_root = jiffies; in hwmp_rann_frame_process()
894 mpath->sn = orig_sn; in hwmp_rann_frame_process()
895 mpath->rann_metric = new_metric; in hwmp_rann_frame_process()
896 mpath->is_root = true; in hwmp_rann_frame_process()
899 memcpy(mpath->rann_snd_addr, mgmt->sa, ETH_ALEN); in hwmp_rann_frame_process()
902 mesh_path_add_gate(mpath); in hwmp_rann_frame_process()
989 static void mesh_queue_preq(struct mesh_path *mpath, u8 flags) in mesh_queue_preq() argument
991 struct ieee80211_sub_if_data *sdata = mpath->sdata; in mesh_queue_preq()
1010 spin_lock(&mpath->state_lock); in mesh_queue_preq()
1011 if (mpath->flags & MESH_PATH_REQ_QUEUED) { in mesh_queue_preq()
1012 spin_unlock(&mpath->state_lock); in mesh_queue_preq()
1018 memcpy(preq_node->dst, mpath->dst, ETH_ALEN); in mesh_queue_preq()
1021 mpath->flags |= MESH_PATH_REQ_QUEUED; in mesh_queue_preq()
1022 spin_unlock(&mpath->state_lock); in mesh_queue_preq()
1051 struct mesh_path *mpath; in mesh_path_start_discovery() local
1071 mpath = mesh_path_lookup(sdata, preq_node->dst); in mesh_path_start_discovery()
1072 if (!mpath) in mesh_path_start_discovery()
1075 spin_lock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1076 if (mpath->flags & (MESH_PATH_DELETED | MESH_PATH_FIXED)) { in mesh_path_start_discovery()
1077 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1080 mpath->flags &= ~MESH_PATH_REQ_QUEUED; in mesh_path_start_discovery()
1082 if (mpath->flags & MESH_PATH_RESOLVING) { in mesh_path_start_discovery()
1083 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1086 mpath->flags &= ~MESH_PATH_RESOLVED; in mesh_path_start_discovery()
1087 mpath->flags |= MESH_PATH_RESOLVING; in mesh_path_start_discovery()
1088 mpath->discovery_retries = 0; in mesh_path_start_discovery()
1089 mpath->discovery_timeout = disc_timeout_jiff(sdata); in mesh_path_start_discovery()
1091 } else if (!(mpath->flags & MESH_PATH_RESOLVING) || in mesh_path_start_discovery()
1092 mpath->flags & MESH_PATH_RESOLVED) { in mesh_path_start_discovery()
1093 mpath->flags &= ~MESH_PATH_RESOLVING; in mesh_path_start_discovery()
1094 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1110 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1119 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1120 da = (mpath->is_root) ? mpath->rann_snd_addr : broadcast_addr; in mesh_path_start_discovery()
1122 target_flags, mpath->dst, mpath->sn, da, 0, in mesh_path_start_discovery()
1125 spin_lock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1126 if (!(mpath->flags & MESH_PATH_DELETED)) in mesh_path_start_discovery()
1127 mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout); in mesh_path_start_discovery()
1128 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1152 struct mesh_path *mpath; in mesh_nexthop_resolve() local
1168 mpath = mesh_path_lookup(sdata, target_addr); in mesh_nexthop_resolve()
1169 if (!mpath) { in mesh_nexthop_resolve()
1170 mpath = mesh_path_add(sdata, target_addr); in mesh_nexthop_resolve()
1171 if (IS_ERR(mpath)) { in mesh_nexthop_resolve()
1173 return PTR_ERR(mpath); in mesh_nexthop_resolve()
1177 if (!(mpath->flags & MESH_PATH_RESOLVING) && in mesh_nexthop_resolve()
1179 mesh_queue_preq(mpath, PREQ_Q_F_START); in mesh_nexthop_resolve()
1181 if (skb_queue_len(&mpath->frame_queue) >= MESH_FRAME_QUEUE_LEN) in mesh_nexthop_resolve()
1182 skb_to_free = skb_dequeue(&mpath->frame_queue); in mesh_nexthop_resolve()
1186 skb_queue_tail(&mpath->frame_queue, skb); in mesh_nexthop_resolve()
1228 struct mesh_path *mpath, const u8 *addr) in mesh_path_refresh() argument
1230 if (mpath->flags & (MESH_PATH_REQ_QUEUED | MESH_PATH_FIXED | in mesh_path_refresh()
1235 mpath->exp_time - in mesh_path_refresh()
1238 mesh_queue_preq(mpath, PREQ_Q_F_START | PREQ_Q_F_REFRESH); in mesh_path_refresh()
1255 struct mesh_path *mpath; in mesh_nexthop_lookup() local
1264 mpath = mesh_path_lookup(sdata, target_addr); in mesh_nexthop_lookup()
1265 if (!mpath || !(mpath->flags & MESH_PATH_ACTIVE)) in mesh_nexthop_lookup()
1268 mesh_path_refresh(sdata, mpath, hdr->addr4); in mesh_nexthop_lookup()
1270 next_hop = rcu_dereference(mpath->next_hop); in mesh_nexthop_lookup()
1276 mesh_fast_tx_cache(sdata, skb, mpath); in mesh_nexthop_lookup()
1285 struct mesh_path *mpath = from_timer(mpath, t, timer); in mesh_path_timer() local
1286 struct ieee80211_sub_if_data *sdata = mpath->sdata; in mesh_path_timer()
1292 spin_lock_bh(&mpath->state_lock); in mesh_path_timer()
1293 if (mpath->flags & MESH_PATH_RESOLVED || in mesh_path_timer()
1294 (!(mpath->flags & MESH_PATH_RESOLVING))) { in mesh_path_timer()
1295 mpath->flags &= ~(MESH_PATH_RESOLVING | MESH_PATH_RESOLVED); in mesh_path_timer()
1296 spin_unlock_bh(&mpath->state_lock); in mesh_path_timer()
1297 } else if (mpath->discovery_retries < max_preq_retries(sdata)) { in mesh_path_timer()
1298 ++mpath->discovery_retries; in mesh_path_timer()
1299 mpath->discovery_timeout *= 2; in mesh_path_timer()
1300 mpath->flags &= ~MESH_PATH_REQ_QUEUED; in mesh_path_timer()
1301 spin_unlock_bh(&mpath->state_lock); in mesh_path_timer()
1302 mesh_queue_preq(mpath, 0); in mesh_path_timer()
1304 mpath->flags &= ~(MESH_PATH_RESOLVING | in mesh_path_timer()
1307 mpath->exp_time = jiffies; in mesh_path_timer()
1308 spin_unlock_bh(&mpath->state_lock); in mesh_path_timer()
1309 if (!mpath->is_gate && mesh_gate_num(sdata) > 0) { in mesh_path_timer()
1310 ret = mesh_path_send_to_gates(mpath); in mesh_path_timer()
1314 mesh_path_flush_pending(mpath); in mesh_path_timer()