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