Lines Matching refs:mpath
19 static void mesh_path_free_rcu(struct mesh_table *tbl, struct mesh_path *mpath);
71 static inline bool mpath_expired(struct mesh_path *mpath) in mpath_expired() argument
73 return (mpath->flags & MESH_PATH_ACTIVE) && in mpath_expired()
74 time_after(jiffies, mpath->exp_time) && in mpath_expired()
75 !(mpath->flags & MESH_PATH_FIXED); in mpath_expired()
80 struct mesh_path *mpath = ptr; in mesh_path_rht_free() local
83 mesh_path_free_rcu(tbl, mpath); in mesh_path_rht_free()
114 void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta) in mesh_path_assign_nexthop() argument
120 rcu_assign_pointer(mpath->next_hop, sta); in mesh_path_assign_nexthop()
122 spin_lock_irqsave(&mpath->frame_queue.lock, flags); in mesh_path_assign_nexthop()
123 skb_queue_walk(&mpath->frame_queue, skb) { in mesh_path_assign_nexthop()
126 memcpy(hdr->addr2, mpath->sdata->vif.addr, ETH_ALEN); in mesh_path_assign_nexthop()
130 spin_unlock_irqrestore(&mpath->frame_queue.lock, flags); in mesh_path_assign_nexthop()
245 struct mesh_path *mpath; in mpath_lookup() local
247 mpath = rhashtable_lookup(&tbl->rhead, dst, mesh_rht_params); in mpath_lookup()
249 if (mpath && mpath_expired(mpath)) { in mpath_lookup()
250 spin_lock_bh(&mpath->state_lock); in mpath_lookup()
251 mpath->flags &= ~MESH_PATH_ACTIVE; in mpath_lookup()
252 spin_unlock_bh(&mpath->state_lock); in mpath_lookup()
254 return mpath; in mpath_lookup()
282 struct mesh_path *mpath; in __mesh_path_lookup_by_idx() local
284 hlist_for_each_entry_rcu(mpath, &tbl->walk_head, walk_list) { in __mesh_path_lookup_by_idx()
289 if (!mpath) in __mesh_path_lookup_by_idx()
292 if (mpath_expired(mpath)) { in __mesh_path_lookup_by_idx()
293 spin_lock_bh(&mpath->state_lock); in __mesh_path_lookup_by_idx()
294 mpath->flags &= ~MESH_PATH_ACTIVE; in __mesh_path_lookup_by_idx()
295 spin_unlock_bh(&mpath->state_lock); in __mesh_path_lookup_by_idx()
297 return mpath; in __mesh_path_lookup_by_idx()
334 int mesh_path_add_gate(struct mesh_path *mpath) in mesh_path_add_gate() argument
340 tbl = &mpath->sdata->u.mesh.mesh_paths; in mesh_path_add_gate()
342 spin_lock_bh(&mpath->state_lock); in mesh_path_add_gate()
343 if (mpath->is_gate) { in mesh_path_add_gate()
345 spin_unlock_bh(&mpath->state_lock); in mesh_path_add_gate()
348 mpath->is_gate = true; in mesh_path_add_gate()
349 mpath->sdata->u.mesh.num_gates++; in mesh_path_add_gate()
352 hlist_add_head_rcu(&mpath->gate_list, &tbl->known_gates); in mesh_path_add_gate()
355 spin_unlock_bh(&mpath->state_lock); in mesh_path_add_gate()
357 mpath_dbg(mpath->sdata, in mesh_path_add_gate()
359 mpath->dst, mpath->sdata->u.mesh.num_gates); in mesh_path_add_gate()
371 static void mesh_gate_del(struct mesh_table *tbl, struct mesh_path *mpath) in mesh_gate_del() argument
373 lockdep_assert_held(&mpath->state_lock); in mesh_gate_del()
374 if (!mpath->is_gate) in mesh_gate_del()
377 mpath->is_gate = false; in mesh_gate_del()
379 hlist_del_rcu(&mpath->gate_list); in mesh_gate_del()
380 mpath->sdata->u.mesh.num_gates--; in mesh_gate_del()
383 mpath_dbg(mpath->sdata, in mesh_gate_del()
385 mpath->dst, mpath->sdata->u.mesh.num_gates); in mesh_gate_del()
439 if (!(entry->mpath->flags & MESH_PATH_ACTIVE) || in mesh_fast_tx_get()
440 mpath_expired(entry->mpath)) { in mesh_fast_tx_get()
449 mesh_path_refresh(sdata, entry->mpath, NULL); in mesh_fast_tx_get()
458 struct sk_buff *skb, struct mesh_path *mpath) in mesh_fast_tx_cache() argument
483 sta = rcu_dereference(mpath->next_hop); in mesh_fast_tx_cache()
494 mppath = mpath; in mesh_fast_tx_cache()
550 build.mpath = mpath; in mesh_fast_tx_cache()
613 void mesh_fast_tx_flush_mpath(struct mesh_path *mpath) in mesh_fast_tx_flush_mpath() argument
615 struct ieee80211_sub_if_data *sdata = mpath->sdata; in mesh_fast_tx_flush_mpath()
623 if (entry->mpath == mpath) in mesh_fast_tx_flush_mpath()
638 if (rcu_access_pointer(entry->mpath->next_hop) == sta) in mesh_fast_tx_flush_sta()
670 struct mesh_path *mpath, *new_mpath; in mesh_path_add() local
688 mpath = rhashtable_lookup_get_insert_fast(&tbl->rhead, in mesh_path_add()
691 if (!mpath) in mesh_path_add()
695 if (mpath) { in mesh_path_add()
698 if (IS_ERR(mpath)) in mesh_path_add()
699 return mpath; in mesh_path_add()
701 new_mpath = mpath; in mesh_path_add()
761 struct mesh_path *mpath; in mesh_plink_broken() local
764 hlist_for_each_entry_rcu(mpath, &tbl->walk_head, walk_list) { in mesh_plink_broken()
765 if (rcu_access_pointer(mpath->next_hop) == sta && in mesh_plink_broken()
766 mpath->flags & MESH_PATH_ACTIVE && in mesh_plink_broken()
767 !(mpath->flags & MESH_PATH_FIXED)) { in mesh_plink_broken()
768 spin_lock_bh(&mpath->state_lock); in mesh_plink_broken()
769 mpath->flags &= ~MESH_PATH_ACTIVE; in mesh_plink_broken()
770 ++mpath->sn; in mesh_plink_broken()
771 spin_unlock_bh(&mpath->state_lock); in mesh_plink_broken()
774 mpath->dst, mpath->sn, in mesh_plink_broken()
782 struct mesh_path *mpath) in mesh_path_free_rcu() argument
784 struct ieee80211_sub_if_data *sdata = mpath->sdata; in mesh_path_free_rcu()
786 spin_lock_bh(&mpath->state_lock); in mesh_path_free_rcu()
787 mpath->flags |= MESH_PATH_RESOLVING | MESH_PATH_DELETED; in mesh_path_free_rcu()
788 mesh_gate_del(tbl, mpath); in mesh_path_free_rcu()
789 spin_unlock_bh(&mpath->state_lock); in mesh_path_free_rcu()
790 timer_shutdown_sync(&mpath->timer); in mesh_path_free_rcu()
793 mesh_path_flush_pending(mpath); in mesh_path_free_rcu()
794 kfree_rcu(mpath, rcu); in mesh_path_free_rcu()
797 static void __mesh_path_del(struct mesh_table *tbl, struct mesh_path *mpath) in __mesh_path_del() argument
799 hlist_del_rcu(&mpath->walk_list); in __mesh_path_del()
800 rhashtable_remove_fast(&tbl->rhead, &mpath->rhash, mesh_rht_params); in __mesh_path_del()
801 if (tbl == &mpath->sdata->u.mesh.mpp_paths) in __mesh_path_del()
802 mesh_fast_tx_flush_addr(mpath->sdata, mpath->dst); in __mesh_path_del()
804 mesh_fast_tx_flush_mpath(mpath); in __mesh_path_del()
805 mesh_path_free_rcu(tbl, mpath); in __mesh_path_del()
823 struct mesh_path *mpath; in mesh_path_flush_by_nexthop() local
827 hlist_for_each_entry_safe(mpath, n, &tbl->walk_head, walk_list) { in mesh_path_flush_by_nexthop()
828 if (rcu_access_pointer(mpath->next_hop) == sta) in mesh_path_flush_by_nexthop()
829 __mesh_path_del(tbl, mpath); in mesh_path_flush_by_nexthop()
838 struct mesh_path *mpath; in mpp_flush_by_proxy() local
842 hlist_for_each_entry_safe(mpath, n, &tbl->walk_head, walk_list) { in mpp_flush_by_proxy()
843 if (ether_addr_equal(mpath->mpp, proxy)) in mpp_flush_by_proxy()
844 __mesh_path_del(tbl, mpath); in mpp_flush_by_proxy()
851 struct mesh_path *mpath; in table_flush_by_iface() local
855 hlist_for_each_entry_safe(mpath, n, &tbl->walk_head, walk_list) { in table_flush_by_iface()
856 __mesh_path_del(tbl, mpath); in table_flush_by_iface()
888 struct mesh_path *mpath; in table_path_del() local
891 mpath = rhashtable_lookup_fast(&tbl->rhead, addr, mesh_rht_params); in table_path_del()
892 if (!mpath) { in table_path_del()
897 __mesh_path_del(tbl, mpath); in table_path_del()
931 void mesh_path_tx_pending(struct mesh_path *mpath) in mesh_path_tx_pending() argument
933 if (mpath->flags & MESH_PATH_ACTIVE) in mesh_path_tx_pending()
934 ieee80211_add_pending_skbs(mpath->sdata->local, in mesh_path_tx_pending()
935 &mpath->frame_queue); in mesh_path_tx_pending()
948 int mesh_path_send_to_gates(struct mesh_path *mpath) in mesh_path_send_to_gates() argument
950 struct ieee80211_sub_if_data *sdata = mpath->sdata; in mesh_path_send_to_gates()
952 struct mesh_path *from_mpath = mpath; in mesh_path_send_to_gates()
978 return (from_mpath == mpath) ? -EHOSTUNREACH : 0; in mesh_path_send_to_gates()
1003 void mesh_path_flush_pending(struct mesh_path *mpath) in mesh_path_flush_pending() argument
1007 while ((skb = skb_dequeue(&mpath->frame_queue)) != NULL) in mesh_path_flush_pending()
1008 mesh_path_discard_frame(mpath->sdata, skb); in mesh_path_flush_pending()
1019 void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop) in mesh_path_fix_nexthop() argument
1021 spin_lock_bh(&mpath->state_lock); in mesh_path_fix_nexthop()
1022 mesh_path_assign_nexthop(mpath, next_hop); in mesh_path_fix_nexthop()
1023 mpath->sn = 0xffff; in mesh_path_fix_nexthop()
1024 mpath->metric = 0; in mesh_path_fix_nexthop()
1025 mpath->hop_count = 0; in mesh_path_fix_nexthop()
1026 mpath->exp_time = 0; in mesh_path_fix_nexthop()
1027 mpath->flags = MESH_PATH_FIXED | MESH_PATH_SN_VALID; in mesh_path_fix_nexthop()
1028 mesh_path_activate(mpath); in mesh_path_fix_nexthop()
1029 mesh_fast_tx_flush_mpath(mpath); in mesh_path_fix_nexthop()
1030 spin_unlock_bh(&mpath->state_lock); in mesh_path_fix_nexthop()
1034 mesh_path_tx_pending(mpath); in mesh_path_fix_nexthop()
1048 struct mesh_path *mpath; in mesh_path_tbl_expire() local
1052 hlist_for_each_entry_safe(mpath, n, &tbl->walk_head, walk_list) { in mesh_path_tbl_expire()
1053 if ((!(mpath->flags & MESH_PATH_RESOLVING)) && in mesh_path_tbl_expire()
1054 (!(mpath->flags & MESH_PATH_FIXED)) && in mesh_path_tbl_expire()
1055 time_after(jiffies, mpath->exp_time + MESH_PATH_EXPIRE)) in mesh_path_tbl_expire()
1056 __mesh_path_del(tbl, mpath); in mesh_path_tbl_expire()