Lines Matching refs:mpath
20 static void mesh_path_free_rcu(struct mesh_table *tbl, struct mesh_path *mpath);
72 static inline bool mpath_expired(struct mesh_path *mpath) in mpath_expired() argument
74 return (mpath->flags & MESH_PATH_ACTIVE) && in mpath_expired()
75 time_after(jiffies, mpath->exp_time) && in mpath_expired()
76 !(mpath->flags & MESH_PATH_FIXED); in mpath_expired()
81 struct mesh_path *mpath = ptr; in mesh_path_rht_free() local
84 mesh_path_free_rcu(tbl, mpath); in mesh_path_rht_free()
115 void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta) in mesh_path_assign_nexthop() argument
121 rcu_assign_pointer(mpath->next_hop, sta); in mesh_path_assign_nexthop()
123 spin_lock_irqsave(&mpath->frame_queue.lock, flags); in mesh_path_assign_nexthop()
124 skb_queue_walk(&mpath->frame_queue, skb) { in mesh_path_assign_nexthop()
127 memcpy(hdr->addr2, mpath->sdata->vif.addr, ETH_ALEN); in mesh_path_assign_nexthop()
131 spin_unlock_irqrestore(&mpath->frame_queue.lock, flags); in mesh_path_assign_nexthop()
246 struct mesh_path *mpath; in mpath_lookup() local
248 mpath = rhashtable_lookup(&tbl->rhead, dst, mesh_rht_params); in mpath_lookup()
250 if (mpath && mpath_expired(mpath)) { in mpath_lookup()
251 spin_lock_bh(&mpath->state_lock); in mpath_lookup()
252 mpath->flags &= ~MESH_PATH_ACTIVE; in mpath_lookup()
253 spin_unlock_bh(&mpath->state_lock); in mpath_lookup()
255 return mpath; in mpath_lookup()
283 struct mesh_path *mpath; in __mesh_path_lookup_by_idx() local
285 hlist_for_each_entry_rcu(mpath, &tbl->walk_head, walk_list) { in __mesh_path_lookup_by_idx()
290 if (!mpath) in __mesh_path_lookup_by_idx()
293 if (mpath_expired(mpath)) { in __mesh_path_lookup_by_idx()
294 spin_lock_bh(&mpath->state_lock); in __mesh_path_lookup_by_idx()
295 mpath->flags &= ~MESH_PATH_ACTIVE; in __mesh_path_lookup_by_idx()
296 spin_unlock_bh(&mpath->state_lock); in __mesh_path_lookup_by_idx()
298 return mpath; in __mesh_path_lookup_by_idx()
337 int mesh_path_add_gate(struct mesh_path *mpath) in mesh_path_add_gate() argument
343 tbl = &mpath->sdata->u.mesh.mesh_paths; in mesh_path_add_gate()
345 spin_lock_bh(&mpath->state_lock); in mesh_path_add_gate()
346 if (mpath->is_gate) { in mesh_path_add_gate()
348 spin_unlock_bh(&mpath->state_lock); in mesh_path_add_gate()
351 mpath->is_gate = true; in mesh_path_add_gate()
352 mpath->sdata->u.mesh.num_gates++; in mesh_path_add_gate()
355 hlist_add_head_rcu(&mpath->gate_list, &tbl->known_gates); in mesh_path_add_gate()
358 spin_unlock_bh(&mpath->state_lock); in mesh_path_add_gate()
360 mpath_dbg(mpath->sdata, in mesh_path_add_gate()
362 mpath->dst, mpath->sdata->u.mesh.num_gates); in mesh_path_add_gate()
374 static void mesh_gate_del(struct mesh_table *tbl, struct mesh_path *mpath) in mesh_gate_del() argument
376 lockdep_assert_held(&mpath->state_lock); in mesh_gate_del()
377 if (!mpath->is_gate) in mesh_gate_del()
380 mpath->is_gate = false; in mesh_gate_del()
382 hlist_del_rcu(&mpath->gate_list); in mesh_gate_del()
383 mpath->sdata->u.mesh.num_gates--; in mesh_gate_del()
386 mpath_dbg(mpath->sdata, in mesh_gate_del()
388 mpath->dst, mpath->sdata->u.mesh.num_gates); in mesh_gate_del()
445 if (!(entry->mpath->flags & MESH_PATH_ACTIVE) || in mesh_fast_tx_get()
446 mpath_expired(entry->mpath)) { in mesh_fast_tx_get()
455 mesh_path_refresh(sdata, entry->mpath, NULL); in mesh_fast_tx_get()
464 struct sk_buff *skb, struct mesh_path *mpath) in mesh_fast_tx_cache() argument
489 sta = rcu_dereference(mpath->next_hop); in mesh_fast_tx_cache()
503 mppath = mpath; in mesh_fast_tx_cache()
562 build.mpath = mpath; in mesh_fast_tx_cache()
624 void mesh_fast_tx_flush_mpath(struct mesh_path *mpath) in mesh_fast_tx_flush_mpath() argument
626 struct ieee80211_sub_if_data *sdata = mpath->sdata; in mesh_fast_tx_flush_mpath()
633 if (entry->mpath == mpath) in mesh_fast_tx_flush_mpath()
647 if (rcu_access_pointer(entry->mpath->next_hop) == sta) in mesh_fast_tx_flush_sta()
684 struct mesh_path *mpath, *new_mpath; in mesh_path_add() local
702 mpath = rhashtable_lookup_get_insert_fast(&tbl->rhead, in mesh_path_add()
705 if (!mpath) in mesh_path_add()
709 if (mpath) { in mesh_path_add()
712 if (IS_ERR(mpath)) in mesh_path_add()
713 return mpath; in mesh_path_add()
715 new_mpath = mpath; in mesh_path_add()
775 struct mesh_path *mpath; in mesh_plink_broken() local
778 hlist_for_each_entry_rcu(mpath, &tbl->walk_head, walk_list) { in mesh_plink_broken()
779 if (rcu_access_pointer(mpath->next_hop) == sta && in mesh_plink_broken()
780 mpath->flags & MESH_PATH_ACTIVE && in mesh_plink_broken()
781 !(mpath->flags & MESH_PATH_FIXED)) { in mesh_plink_broken()
782 spin_lock_bh(&mpath->state_lock); in mesh_plink_broken()
783 mpath->flags &= ~MESH_PATH_ACTIVE; in mesh_plink_broken()
784 ++mpath->sn; in mesh_plink_broken()
785 spin_unlock_bh(&mpath->state_lock); in mesh_plink_broken()
788 mpath->dst, mpath->sn, in mesh_plink_broken()
796 struct mesh_path *mpath) in mesh_path_free_rcu() argument
798 struct ieee80211_sub_if_data *sdata = mpath->sdata; in mesh_path_free_rcu()
800 spin_lock_bh(&mpath->state_lock); in mesh_path_free_rcu()
801 mpath->flags |= MESH_PATH_RESOLVING | MESH_PATH_DELETED; in mesh_path_free_rcu()
802 mesh_gate_del(tbl, mpath); in mesh_path_free_rcu()
803 spin_unlock_bh(&mpath->state_lock); in mesh_path_free_rcu()
804 timer_shutdown_sync(&mpath->timer); in mesh_path_free_rcu()
807 mesh_path_flush_pending(mpath); in mesh_path_free_rcu()
808 kfree_rcu(mpath, rcu); in mesh_path_free_rcu()
811 static void __mesh_path_del(struct mesh_table *tbl, struct mesh_path *mpath) in __mesh_path_del() argument
813 hlist_del_rcu(&mpath->walk_list); in __mesh_path_del()
814 rhashtable_remove_fast(&tbl->rhead, &mpath->rhash, mesh_rht_params); in __mesh_path_del()
815 if (tbl == &mpath->sdata->u.mesh.mpp_paths) in __mesh_path_del()
816 mesh_fast_tx_flush_addr(mpath->sdata, mpath->dst); in __mesh_path_del()
818 mesh_fast_tx_flush_mpath(mpath); in __mesh_path_del()
819 mesh_path_free_rcu(tbl, mpath); in __mesh_path_del()
837 struct mesh_path *mpath; in mesh_path_flush_by_nexthop() local
841 hlist_for_each_entry_safe(mpath, n, &tbl->walk_head, walk_list) { in mesh_path_flush_by_nexthop()
842 if (rcu_access_pointer(mpath->next_hop) == sta) in mesh_path_flush_by_nexthop()
843 __mesh_path_del(tbl, mpath); in mesh_path_flush_by_nexthop()
852 struct mesh_path *mpath; in mpp_flush_by_proxy() local
856 hlist_for_each_entry_safe(mpath, n, &tbl->walk_head, walk_list) { in mpp_flush_by_proxy()
857 if (ether_addr_equal(mpath->mpp, proxy)) in mpp_flush_by_proxy()
858 __mesh_path_del(tbl, mpath); in mpp_flush_by_proxy()
865 struct mesh_path *mpath; in table_flush_by_iface() local
869 hlist_for_each_entry_safe(mpath, n, &tbl->walk_head, walk_list) { in table_flush_by_iface()
870 __mesh_path_del(tbl, mpath); in table_flush_by_iface()
901 struct mesh_path *mpath; in table_path_del() local
904 mpath = rhashtable_lookup_fast(&tbl->rhead, addr, mesh_rht_params); in table_path_del()
905 if (!mpath) { in table_path_del()
910 __mesh_path_del(tbl, mpath); in table_path_del()
944 void mesh_path_tx_pending(struct mesh_path *mpath) in mesh_path_tx_pending() argument
946 if (mpath->flags & MESH_PATH_ACTIVE) in mesh_path_tx_pending()
947 ieee80211_add_pending_skbs(mpath->sdata->local, in mesh_path_tx_pending()
948 &mpath->frame_queue); in mesh_path_tx_pending()
963 int mesh_path_send_to_gates(struct mesh_path *mpath) in mesh_path_send_to_gates() argument
965 struct ieee80211_sub_if_data *sdata = mpath->sdata; in mesh_path_send_to_gates()
967 struct mesh_path *from_mpath = mpath; in mesh_path_send_to_gates()
993 return (from_mpath == mpath) ? -EHOSTUNREACH : 0; in mesh_path_send_to_gates()
1018 void mesh_path_flush_pending(struct mesh_path *mpath) in mesh_path_flush_pending() argument
1020 struct ieee80211_sub_if_data *sdata = mpath->sdata; in mesh_path_flush_pending()
1025 while ((skb = skb_dequeue(&mpath->frame_queue)) != NULL) in mesh_path_flush_pending()
1026 mesh_path_discard_frame(mpath->sdata, skb); in mesh_path_flush_pending()
1030 if (ether_addr_equal(mpath->dst, preq->dst)) { in mesh_path_flush_pending()
1047 void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop) in mesh_path_fix_nexthop() argument
1049 spin_lock_bh(&mpath->state_lock); in mesh_path_fix_nexthop()
1050 mesh_path_assign_nexthop(mpath, next_hop); in mesh_path_fix_nexthop()
1051 mpath->sn = 0xffff; in mesh_path_fix_nexthop()
1052 mpath->metric = 0; in mesh_path_fix_nexthop()
1053 mpath->hop_count = 0; in mesh_path_fix_nexthop()
1054 mpath->exp_time = 0; in mesh_path_fix_nexthop()
1055 mpath->flags = MESH_PATH_FIXED | MESH_PATH_SN_VALID; in mesh_path_fix_nexthop()
1056 mesh_path_activate(mpath); in mesh_path_fix_nexthop()
1057 mesh_fast_tx_flush_mpath(mpath); in mesh_path_fix_nexthop()
1058 spin_unlock_bh(&mpath->state_lock); in mesh_path_fix_nexthop()
1062 mesh_path_tx_pending(mpath); in mesh_path_fix_nexthop()
1076 struct mesh_path *mpath; in mesh_path_tbl_expire() local
1080 hlist_for_each_entry_safe(mpath, n, &tbl->walk_head, walk_list) { in mesh_path_tbl_expire()
1081 if ((!(mpath->flags & MESH_PATH_RESOLVING)) && in mesh_path_tbl_expire()
1082 (!(mpath->flags & MESH_PATH_FIXED)) && in mesh_path_tbl_expire()
1083 time_after(jiffies, mpath->exp_time + MESH_PATH_EXPIRE)) in mesh_path_tbl_expire()
1084 __mesh_path_del(tbl, mpath); in mesh_path_tbl_expire()