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