Lines Matching refs:mpath

370 	struct mesh_path *mpath;  in hwmp_route_info_get()  local
424 mpath = mesh_path_lookup(sdata, orig_addr); in hwmp_route_info_get()
425 if (mpath) { in hwmp_route_info_get()
426 spin_lock_bh(&mpath->state_lock); in hwmp_route_info_get()
427 if (mpath->flags & MESH_PATH_FIXED) in hwmp_route_info_get()
429 else if ((mpath->flags & MESH_PATH_ACTIVE) && in hwmp_route_info_get()
430 (mpath->flags & MESH_PATH_SN_VALID)) { in hwmp_route_info_get()
431 if (SN_GT(mpath->sn, orig_sn) || in hwmp_route_info_get()
432 (mpath->sn == orig_sn && in hwmp_route_info_get()
433 new_metric >= mpath->metric)) { in hwmp_route_info_get()
437 } else if (!(mpath->flags & MESH_PATH_ACTIVE)) { in hwmp_route_info_get()
440 have_sn = mpath->flags & MESH_PATH_SN_VALID; in hwmp_route_info_get()
441 newer_sn = have_sn && SN_GT(orig_sn, mpath->sn); in hwmp_route_info_get()
443 (SN_DELTA(orig_sn, mpath->sn) > in hwmp_route_info_get()
459 mpath = mesh_path_add(sdata, orig_addr); in hwmp_route_info_get()
460 if (IS_ERR(mpath)) { in hwmp_route_info_get()
464 spin_lock_bh(&mpath->state_lock); in hwmp_route_info_get()
468 mesh_path_assign_nexthop(mpath, sta); in hwmp_route_info_get()
469 mpath->flags |= MESH_PATH_SN_VALID; in hwmp_route_info_get()
470 mpath->metric = new_metric; in hwmp_route_info_get()
471 mpath->sn = orig_sn; in hwmp_route_info_get()
472 mpath->exp_time = time_after(mpath->exp_time, exp_time) in hwmp_route_info_get()
473 ? mpath->exp_time : exp_time; in hwmp_route_info_get()
474 mesh_path_activate(mpath); in hwmp_route_info_get()
475 spin_unlock_bh(&mpath->state_lock); in hwmp_route_info_get()
476 mesh_path_tx_pending(mpath); in hwmp_route_info_get()
481 spin_unlock_bh(&mpath->state_lock); in hwmp_route_info_get()
491 mpath = mesh_path_lookup(sdata, ta); in hwmp_route_info_get()
492 if (mpath) { in hwmp_route_info_get()
493 spin_lock_bh(&mpath->state_lock); in hwmp_route_info_get()
494 if ((mpath->flags & MESH_PATH_FIXED) || in hwmp_route_info_get()
495 ((mpath->flags & MESH_PATH_ACTIVE) && in hwmp_route_info_get()
496 (last_hop_metric > mpath->metric))) in hwmp_route_info_get()
499 mpath = mesh_path_add(sdata, ta); in hwmp_route_info_get()
500 if (IS_ERR(mpath)) { in hwmp_route_info_get()
504 spin_lock_bh(&mpath->state_lock); in hwmp_route_info_get()
508 mesh_path_assign_nexthop(mpath, sta); in hwmp_route_info_get()
509 mpath->metric = last_hop_metric; in hwmp_route_info_get()
510 mpath->exp_time = time_after(mpath->exp_time, exp_time) in hwmp_route_info_get()
511 ? mpath->exp_time : exp_time; in hwmp_route_info_get()
512 mesh_path_activate(mpath); in hwmp_route_info_get()
513 spin_unlock_bh(&mpath->state_lock); in hwmp_route_info_get()
514 mesh_path_tx_pending(mpath); in hwmp_route_info_get()
516 spin_unlock_bh(&mpath->state_lock); in hwmp_route_info_get()
529 struct mesh_path *mpath = NULL; in hwmp_preq_frame_process() local
565 mpath = mesh_path_lookup(sdata, orig_addr); in hwmp_preq_frame_process()
566 if (mpath) { in hwmp_preq_frame_process()
575 mesh_path_add_gate(mpath); in hwmp_preq_frame_process()
580 mpath = mesh_path_lookup(sdata, target_addr); in hwmp_preq_frame_process()
581 if (mpath) { in hwmp_preq_frame_process()
582 if ((!(mpath->flags & MESH_PATH_SN_VALID)) || in hwmp_preq_frame_process()
583 SN_LT(mpath->sn, target_sn)) { in hwmp_preq_frame_process()
584 mpath->sn = target_sn; in hwmp_preq_frame_process()
585 mpath->flags |= MESH_PATH_SN_VALID; in hwmp_preq_frame_process()
587 (mpath->flags & MESH_PATH_ACTIVE)) { in hwmp_preq_frame_process()
589 target_metric = mpath->metric; in hwmp_preq_frame_process()
590 target_sn = mpath->sn; in hwmp_preq_frame_process()
627 da = (mpath && mpath->is_root) ? in hwmp_preq_frame_process()
628 mpath->rann_snd_addr : broadcast_addr; in hwmp_preq_frame_process()
649 next_hop_deref_protected(struct mesh_path *mpath) in next_hop_deref_protected() argument
651 return rcu_dereference_protected(mpath->next_hop, in next_hop_deref_protected()
652 lockdep_is_held(&mpath->state_lock)); in next_hop_deref_protected()
661 struct mesh_path *mpath; in hwmp_prep_frame_process() local
685 mpath = mesh_path_lookup(sdata, orig_addr); in hwmp_prep_frame_process()
686 if (mpath) in hwmp_prep_frame_process()
687 spin_lock_bh(&mpath->state_lock); in hwmp_prep_frame_process()
690 if (!(mpath->flags & MESH_PATH_ACTIVE)) { in hwmp_prep_frame_process()
691 spin_unlock_bh(&mpath->state_lock); in hwmp_prep_frame_process()
694 memcpy(next_hop, next_hop_deref_protected(mpath)->sta.addr, ETH_ALEN); in hwmp_prep_frame_process()
695 spin_unlock_bh(&mpath->state_lock); in hwmp_prep_frame_process()
723 struct mesh_path *mpath; in hwmp_perr_frame_process() local
741 mpath = mesh_path_lookup(sdata, target_addr); in hwmp_perr_frame_process()
742 if (mpath) { in hwmp_perr_frame_process()
745 spin_lock_bh(&mpath->state_lock); in hwmp_perr_frame_process()
746 sta = next_hop_deref_protected(mpath); in hwmp_perr_frame_process()
747 if (mpath->flags & MESH_PATH_ACTIVE && in hwmp_perr_frame_process()
749 (!(mpath->flags & MESH_PATH_SN_VALID) || in hwmp_perr_frame_process()
750 SN_GT(target_sn, mpath->sn) || target_sn == 0)) { in hwmp_perr_frame_process()
751 mpath->flags &= ~MESH_PATH_ACTIVE; in hwmp_perr_frame_process()
753 mpath->sn = target_sn; in hwmp_perr_frame_process()
755 mpath->sn += 1; in hwmp_perr_frame_process()
756 spin_unlock_bh(&mpath->state_lock); in hwmp_perr_frame_process()
763 spin_unlock_bh(&mpath->state_lock); in hwmp_perr_frame_process()
776 struct mesh_path *mpath; in hwmp_rann_frame_process() local
809 mpath = mesh_path_lookup(sdata, orig_addr); in hwmp_rann_frame_process()
810 if (!mpath) { in hwmp_rann_frame_process()
811 mpath = mesh_path_add(sdata, orig_addr); in hwmp_rann_frame_process()
812 if (IS_ERR(mpath)) { in hwmp_rann_frame_process()
819 if (!(SN_LT(mpath->sn, orig_sn)) && in hwmp_rann_frame_process()
820 !(mpath->sn == orig_sn && metric < mpath->rann_metric)) { in hwmp_rann_frame_process()
825 if ((!(mpath->flags & (MESH_PATH_ACTIVE | MESH_PATH_RESOLVING)) || in hwmp_rann_frame_process()
826 (time_after(jiffies, mpath->last_preq_to_root + in hwmp_rann_frame_process()
828 time_before(jiffies, mpath->last_preq_to_root))) && in hwmp_rann_frame_process()
829 !(mpath->flags & MESH_PATH_FIXED) && (ttl != 0)) { in hwmp_rann_frame_process()
833 mesh_queue_preq(mpath, PREQ_Q_F_START | PREQ_Q_F_REFRESH); in hwmp_rann_frame_process()
834 mpath->last_preq_to_root = jiffies; in hwmp_rann_frame_process()
837 mpath->sn = orig_sn; in hwmp_rann_frame_process()
838 mpath->rann_metric = metric + metric_txsta; in hwmp_rann_frame_process()
839 mpath->is_root = true; in hwmp_rann_frame_process()
842 memcpy(mpath->rann_snd_addr, mgmt->sa, ETH_ALEN); in hwmp_rann_frame_process()
845 mesh_path_add_gate(mpath); in hwmp_rann_frame_process()
928 static void mesh_queue_preq(struct mesh_path *mpath, u8 flags) in mesh_queue_preq() argument
930 struct ieee80211_sub_if_data *sdata = mpath->sdata; in mesh_queue_preq()
949 spin_lock(&mpath->state_lock); in mesh_queue_preq()
950 if (mpath->flags & MESH_PATH_REQ_QUEUED) { in mesh_queue_preq()
951 spin_unlock(&mpath->state_lock); in mesh_queue_preq()
957 memcpy(preq_node->dst, mpath->dst, ETH_ALEN); in mesh_queue_preq()
960 mpath->flags |= MESH_PATH_REQ_QUEUED; in mesh_queue_preq()
961 spin_unlock(&mpath->state_lock); in mesh_queue_preq()
990 struct mesh_path *mpath; in mesh_path_start_discovery() local
1010 mpath = mesh_path_lookup(sdata, preq_node->dst); in mesh_path_start_discovery()
1011 if (!mpath) in mesh_path_start_discovery()
1014 spin_lock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1015 mpath->flags &= ~MESH_PATH_REQ_QUEUED; in mesh_path_start_discovery()
1017 if (mpath->flags & MESH_PATH_RESOLVING) { in mesh_path_start_discovery()
1018 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1021 mpath->flags &= ~MESH_PATH_RESOLVED; in mesh_path_start_discovery()
1022 mpath->flags |= MESH_PATH_RESOLVING; in mesh_path_start_discovery()
1023 mpath->discovery_retries = 0; in mesh_path_start_discovery()
1024 mpath->discovery_timeout = disc_timeout_jiff(sdata); in mesh_path_start_discovery()
1026 } else if (!(mpath->flags & MESH_PATH_RESOLVING) || in mesh_path_start_discovery()
1027 mpath->flags & MESH_PATH_RESOLVED) { in mesh_path_start_discovery()
1028 mpath->flags &= ~MESH_PATH_RESOLVING; in mesh_path_start_discovery()
1029 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1045 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1054 spin_unlock_bh(&mpath->state_lock); in mesh_path_start_discovery()
1055 da = (mpath->is_root) ? mpath->rann_snd_addr : broadcast_addr; in mesh_path_start_discovery()
1057 target_flags, mpath->dst, mpath->sn, da, 0, in mesh_path_start_discovery()
1059 mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout); in mesh_path_start_discovery()
1083 struct mesh_path *mpath; in mesh_nexthop_resolve() local
1098 mpath = mesh_path_lookup(sdata, target_addr); in mesh_nexthop_resolve()
1099 if (!mpath) { in mesh_nexthop_resolve()
1100 mpath = mesh_path_add(sdata, target_addr); in mesh_nexthop_resolve()
1101 if (IS_ERR(mpath)) { in mesh_nexthop_resolve()
1103 err = PTR_ERR(mpath); in mesh_nexthop_resolve()
1108 if (!(mpath->flags & MESH_PATH_RESOLVING)) in mesh_nexthop_resolve()
1109 mesh_queue_preq(mpath, PREQ_Q_F_START); in mesh_nexthop_resolve()
1111 if (skb_queue_len(&mpath->frame_queue) >= MESH_FRAME_QUEUE_LEN) in mesh_nexthop_resolve()
1112 skb_to_free = skb_dequeue(&mpath->frame_queue); in mesh_nexthop_resolve()
1116 skb_queue_tail(&mpath->frame_queue, skb); in mesh_nexthop_resolve()
1139 struct mesh_path *mpath; in mesh_nexthop_lookup() local
1146 mpath = mesh_path_lookup(sdata, target_addr); in mesh_nexthop_lookup()
1148 if (!mpath || !(mpath->flags & MESH_PATH_ACTIVE)) in mesh_nexthop_lookup()
1152 mpath->exp_time - in mesh_nexthop_lookup()
1155 !(mpath->flags & MESH_PATH_RESOLVING) && in mesh_nexthop_lookup()
1156 !(mpath->flags & MESH_PATH_FIXED)) in mesh_nexthop_lookup()
1157 mesh_queue_preq(mpath, PREQ_Q_F_START | PREQ_Q_F_REFRESH); in mesh_nexthop_lookup()
1159 next_hop = rcu_dereference(mpath->next_hop); in mesh_nexthop_lookup()
1174 struct mesh_path *mpath = (void *) data; in mesh_path_timer() local
1175 struct ieee80211_sub_if_data *sdata = mpath->sdata; in mesh_path_timer()
1181 spin_lock_bh(&mpath->state_lock); in mesh_path_timer()
1182 if (mpath->flags & MESH_PATH_RESOLVED || in mesh_path_timer()
1183 (!(mpath->flags & MESH_PATH_RESOLVING))) { in mesh_path_timer()
1184 mpath->flags &= ~(MESH_PATH_RESOLVING | MESH_PATH_RESOLVED); in mesh_path_timer()
1185 spin_unlock_bh(&mpath->state_lock); in mesh_path_timer()
1186 } else if (mpath->discovery_retries < max_preq_retries(sdata)) { in mesh_path_timer()
1187 ++mpath->discovery_retries; in mesh_path_timer()
1188 mpath->discovery_timeout *= 2; in mesh_path_timer()
1189 mpath->flags &= ~MESH_PATH_REQ_QUEUED; in mesh_path_timer()
1190 spin_unlock_bh(&mpath->state_lock); in mesh_path_timer()
1191 mesh_queue_preq(mpath, 0); in mesh_path_timer()
1193 mpath->flags &= ~(MESH_PATH_RESOLVING | in mesh_path_timer()
1196 mpath->exp_time = jiffies; in mesh_path_timer()
1197 spin_unlock_bh(&mpath->state_lock); in mesh_path_timer()
1198 if (!mpath->is_gate && mesh_gate_num(sdata) > 0) { in mesh_path_timer()
1199 ret = mesh_path_send_to_gates(mpath); in mesh_path_timer()
1203 mesh_path_flush_pending(mpath); in mesh_path_timer()