Lines Matching defs: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)
73 return (mpath->flags & MESH_PATH_ACTIVE) &&
74 time_after(jiffies, mpath->exp_time) &&
75 !(mpath->flags & MESH_PATH_FIXED);
80 struct mesh_path *mpath = ptr;
83 mesh_path_free_rcu(tbl, mpath);
109 * @mpath: mesh path to update
112 * Locking: mpath->state_lock must be held when calling this function
114 void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta)
120 rcu_assign_pointer(mpath->next_hop, sta);
122 spin_lock_irqsave(&mpath->frame_queue.lock, flags);
123 skb_queue_walk(&mpath->frame_queue, skb) {
126 memcpy(hdr->addr2, mpath->sdata->vif.addr, ETH_ALEN);
130 spin_unlock_irqrestore(&mpath->frame_queue.lock, flags);
174 * mesh_path_move_to_queue - Move or copy frames from one mpath queue to another
176 * This function is used to transfer or copy frames from an unresolved mpath to
177 * a gate mpath. The function also adds the Address Extension field and
183 * The gate mpath must be an active mpath with a valid mpath->next_hop.
185 * @gate_mpath: An active mpath the frames will be sent to (i.e. the gate)
186 * @from_mpath: The failed mpath
187 * @copy: When true, copy all the frames to the new mpath queue. When false,
212 mpath_dbg(gate_mpath->sdata, "mpath queue full!\n");
245 struct mesh_path *mpath;
247 mpath = rhashtable_lookup(&tbl->rhead, dst, mesh_rht_params);
249 if (mpath && mpath_expired(mpath)) {
250 spin_lock_bh(&mpath->state_lock);
251 mpath->flags &= ~MESH_PATH_ACTIVE;
252 spin_unlock_bh(&mpath->state_lock);
254 return mpath;
282 struct mesh_path *mpath;
284 hlist_for_each_entry_rcu(mpath, &tbl->walk_head, walk_list) {
289 if (!mpath)
292 if (mpath_expired(mpath)) {
293 spin_lock_bh(&mpath->state_lock);
294 mpath->flags &= ~MESH_PATH_ACTIVE;
295 spin_unlock_bh(&mpath->state_lock);
297 return mpath;
331 * mesh_path_add_gate - add the given mpath to a mesh gate to our path table
332 * @mpath: gate path to add to table
334 int mesh_path_add_gate(struct mesh_path *mpath)
340 tbl = &mpath->sdata->u.mesh.mesh_paths;
342 spin_lock_bh(&mpath->state_lock);
343 if (mpath->is_gate) {
345 spin_unlock_bh(&mpath->state_lock);
348 mpath->is_gate = true;
349 mpath->sdata->u.mesh.num_gates++;
352 hlist_add_head_rcu(&mpath->gate_list, &tbl->known_gates);
355 spin_unlock_bh(&mpath->state_lock);
357 mpath_dbg(mpath->sdata,
359 mpath->dst, mpath->sdata->u.mesh.num_gates);
369 * @mpath: gate mpath
371 static void mesh_gate_del(struct mesh_table *tbl, struct mesh_path *mpath)
373 lockdep_assert_held(&mpath->state_lock);
374 if (!mpath->is_gate)
377 mpath->is_gate = false;
379 hlist_del_rcu(&mpath->gate_list);
380 mpath->sdata->u.mesh.num_gates--;
383 mpath_dbg(mpath->sdata,
385 mpath->dst, mpath->sdata->u.mesh.num_gates);
439 if (!(entry->mpath->flags & MESH_PATH_ACTIVE) ||
440 mpath_expired(entry->mpath)) {
449 mesh_path_refresh(sdata, entry->mpath, NULL);
458 struct sk_buff *skb, struct mesh_path *mpath)
483 sta = rcu_dereference(mpath->next_hop);
494 mppath = mpath;
550 build.mpath = mpath;
578 * replacing it with a different type (e.g. mpath -> mpp)
613 void mesh_fast_tx_flush_mpath(struct mesh_path *mpath)
615 struct ieee80211_sub_if_data *sdata = mpath->sdata;
623 if (entry->mpath == mpath)
638 if (rcu_access_pointer(entry->mpath->next_hop) == sta)
670 struct mesh_path *mpath, *new_mpath;
688 mpath = rhashtable_lookup_get_insert_fast(&tbl->rhead,
691 if (!mpath)
695 if (mpath) {
698 if (IS_ERR(mpath))
699 return mpath;
701 new_mpath = mpath;
761 struct mesh_path *mpath;
764 hlist_for_each_entry_rcu(mpath, &tbl->walk_head, walk_list) {
765 if (rcu_access_pointer(mpath->next_hop) == sta &&
766 mpath->flags & MESH_PATH_ACTIVE &&
767 !(mpath->flags & MESH_PATH_FIXED)) {
768 spin_lock_bh(&mpath->state_lock);
769 mpath->flags &= ~MESH_PATH_ACTIVE;
770 ++mpath->sn;
771 spin_unlock_bh(&mpath->state_lock);
774 mpath->dst, mpath->sn,
782 struct mesh_path *mpath)
784 struct ieee80211_sub_if_data *sdata = mpath->sdata;
786 spin_lock_bh(&mpath->state_lock);
787 mpath->flags |= MESH_PATH_RESOLVING | MESH_PATH_DELETED;
788 mesh_gate_del(tbl, mpath);
789 spin_unlock_bh(&mpath->state_lock);
790 timer_shutdown_sync(&mpath->timer);
793 mesh_path_flush_pending(mpath);
794 kfree_rcu(mpath, rcu);
797 static void __mesh_path_del(struct mesh_table *tbl, struct mesh_path *mpath)
799 hlist_del_rcu(&mpath->walk_list);
800 rhashtable_remove_fast(&tbl->rhead, &mpath->rhash, mesh_rht_params);
801 if (tbl == &mpath->sdata->u.mesh.mpp_paths)
802 mesh_fast_tx_flush_addr(mpath->sdata, mpath->dst);
804 mesh_fast_tx_flush_mpath(mpath);
805 mesh_path_free_rcu(tbl, mpath);
823 struct mesh_path *mpath;
827 hlist_for_each_entry_safe(mpath, n, &tbl->walk_head, walk_list) {
828 if (rcu_access_pointer(mpath->next_hop) == sta)
829 __mesh_path_del(tbl, mpath);
838 struct mesh_path *mpath;
842 hlist_for_each_entry_safe(mpath, n, &tbl->walk_head, walk_list) {
843 if (ether_addr_equal(mpath->mpp, proxy))
844 __mesh_path_del(tbl, mpath);
851 struct mesh_path *mpath;
855 hlist_for_each_entry_safe(mpath, n, &tbl->walk_head, walk_list) {
856 __mesh_path_del(tbl, mpath);
888 struct mesh_path *mpath;
891 mpath = rhashtable_lookup_fast(&tbl->rhead, addr, mesh_rht_params);
892 if (!mpath) {
897 __mesh_path_del(tbl, mpath);
926 * @mpath: mesh path to activate
928 * Locking: the state_lock of the mpath structure must NOT be held when calling
931 void mesh_path_tx_pending(struct mesh_path *mpath)
933 if (mpath->flags & MESH_PATH_ACTIVE)
934 ieee80211_add_pending_skbs(mpath->sdata->local,
935 &mpath->frame_queue);
941 * @mpath: mesh path whose queue will be emptied
943 * If there is only one gate, the frames are transferred from the failed mpath
946 * mpath queues are emptied onto the transmission queue.
948 int mesh_path_send_to_gates(struct mesh_path *mpath)
950 struct ieee80211_sub_if_data *sdata = mpath->sdata;
952 struct mesh_path *from_mpath = mpath;
978 return (from_mpath == mpath) ? -EHOSTUNREACH : 0;
999 * @mpath: mesh path whose queue has to be freed
1003 void mesh_path_flush_pending(struct mesh_path *mpath)
1007 while ((skb = skb_dequeue(&mpath->frame_queue)) != NULL)
1008 mesh_path_discard_frame(mpath->sdata, skb);
1014 * @mpath: the mesh path to modify
1017 * Locking: this function must be called holding mpath->state_lock
1019 void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop)
1021 spin_lock_bh(&mpath->state_lock);
1022 mesh_path_assign_nexthop(mpath, next_hop);
1023 mpath->sn = 0xffff;
1024 mpath->metric = 0;
1025 mpath->hop_count = 0;
1026 mpath->exp_time = 0;
1027 mpath->flags = MESH_PATH_FIXED | MESH_PATH_SN_VALID;
1028 mesh_path_activate(mpath);
1029 mesh_fast_tx_flush_mpath(mpath);
1030 spin_unlock_bh(&mpath->state_lock);
1034 mesh_path_tx_pending(mpath);
1048 struct mesh_path *mpath;
1052 hlist_for_each_entry_safe(mpath, n, &tbl->walk_head, walk_list) {
1053 if ((!(mpath->flags & MESH_PATH_RESOLVING)) &&
1054 (!(mpath->flags & MESH_PATH_FIXED)) &&
1055 time_after(jiffies, mpath->exp_time + MESH_PATH_EXPIRE))
1056 __mesh_path_del(tbl, mpath);