Lines Matching defs:mpath
18 static void mesh_path_free_rcu(struct mesh_table *tbl, struct mesh_path *mpath);
35 static inline bool mpath_expired(struct mesh_path *mpath)
37 return (mpath->flags & MESH_PATH_ACTIVE) &&
38 time_after(jiffies, mpath->exp_time) &&
39 !(mpath->flags & MESH_PATH_FIXED);
44 struct mesh_path *mpath = ptr;
47 mesh_path_free_rcu(tbl, mpath);
73 * @mpath: mesh path to update
76 * Locking: mpath->state_lock must be held when calling this function
78 void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta)
84 rcu_assign_pointer(mpath->next_hop, sta);
86 spin_lock_irqsave(&mpath->frame_queue.lock, flags);
87 skb_queue_walk(&mpath->frame_queue, skb) {
90 memcpy(hdr->addr2, mpath->sdata->vif.addr, ETH_ALEN);
94 spin_unlock_irqrestore(&mpath->frame_queue.lock, flags);
138 * mesh_path_move_to_queue - Move or copy frames from one mpath queue to another
140 * This function is used to transfer or copy frames from an unresolved mpath to
141 * a gate mpath. The function also adds the Address Extension field and
147 * The gate mpath must be an active mpath with a valid mpath->next_hop.
149 * @gate_mpath: An active mpath the frames will be sent to (i.e. the gate)
150 * @from_mpath: The failed mpath
151 * @copy: When true, copy all the frames to the new mpath queue. When false,
176 mpath_dbg(gate_mpath->sdata, "mpath queue full!\n");
209 struct mesh_path *mpath;
211 mpath = rhashtable_lookup(&tbl->rhead, dst, mesh_rht_params);
213 if (mpath && mpath_expired(mpath)) {
214 spin_lock_bh(&mpath->state_lock);
215 mpath->flags &= ~MESH_PATH_ACTIVE;
216 spin_unlock_bh(&mpath->state_lock);
218 return mpath;
246 struct mesh_path *mpath;
248 hlist_for_each_entry_rcu(mpath, &tbl->walk_head, walk_list) {
253 if (!mpath)
256 if (mpath_expired(mpath)) {
257 spin_lock_bh(&mpath->state_lock);
258 mpath->flags &= ~MESH_PATH_ACTIVE;
259 spin_unlock_bh(&mpath->state_lock);
261 return mpath;
295 * mesh_path_add_gate - add the given mpath to a mesh gate to our path table
296 * @mpath: gate path to add to table
298 int mesh_path_add_gate(struct mesh_path *mpath)
304 tbl = &mpath->sdata->u.mesh.mesh_paths;
306 spin_lock_bh(&mpath->state_lock);
307 if (mpath->is_gate) {
309 spin_unlock_bh(&mpath->state_lock);
312 mpath->is_gate = true;
313 mpath->sdata->u.mesh.num_gates++;
316 hlist_add_head_rcu(&mpath->gate_list, &tbl->known_gates);
319 spin_unlock_bh(&mpath->state_lock);
321 mpath_dbg(mpath->sdata,
323 mpath->dst, mpath->sdata->u.mesh.num_gates);
333 * @mpath: gate mpath
335 static void mesh_gate_del(struct mesh_table *tbl, struct mesh_path *mpath)
337 lockdep_assert_held(&mpath->state_lock);
338 if (!mpath->is_gate)
341 mpath->is_gate = false;
343 hlist_del_rcu(&mpath->gate_list);
344 mpath->sdata->u.mesh.num_gates--;
347 mpath_dbg(mpath->sdata,
349 mpath->dst, mpath->sdata->u.mesh.num_gates);
397 struct mesh_path *mpath, *new_mpath;
415 mpath = rhashtable_lookup_get_insert_fast(&tbl->rhead,
418 if (!mpath)
422 if (mpath) {
425 if (IS_ERR(mpath))
426 return mpath;
428 new_mpath = mpath;
486 struct mesh_path *mpath;
489 hlist_for_each_entry_rcu(mpath, &tbl->walk_head, walk_list) {
490 if (rcu_access_pointer(mpath->next_hop) == sta &&
491 mpath->flags & MESH_PATH_ACTIVE &&
492 !(mpath->flags & MESH_PATH_FIXED)) {
493 spin_lock_bh(&mpath->state_lock);
494 mpath->flags &= ~MESH_PATH_ACTIVE;
495 ++mpath->sn;
496 spin_unlock_bh(&mpath->state_lock);
499 mpath->dst, mpath->sn,
507 struct mesh_path *mpath)
509 struct ieee80211_sub_if_data *sdata = mpath->sdata;
511 spin_lock_bh(&mpath->state_lock);
512 mpath->flags |= MESH_PATH_RESOLVING | MESH_PATH_DELETED;
513 mesh_gate_del(tbl, mpath);
514 spin_unlock_bh(&mpath->state_lock);
515 del_timer_sync(&mpath->timer);
518 mesh_path_flush_pending(mpath);
519 kfree_rcu(mpath, rcu);
522 static void __mesh_path_del(struct mesh_table *tbl, struct mesh_path *mpath)
524 hlist_del_rcu(&mpath->walk_list);
525 rhashtable_remove_fast(&tbl->rhead, &mpath->rhash, mesh_rht_params);
526 mesh_path_free_rcu(tbl, mpath);
544 struct mesh_path *mpath;
548 hlist_for_each_entry_safe(mpath, n, &tbl->walk_head, walk_list) {
549 if (rcu_access_pointer(mpath->next_hop) == sta)
550 __mesh_path_del(tbl, mpath);
559 struct mesh_path *mpath;
563 hlist_for_each_entry_safe(mpath, n, &tbl->walk_head, walk_list) {
564 if (ether_addr_equal(mpath->mpp, proxy))
565 __mesh_path_del(tbl, mpath);
572 struct mesh_path *mpath;
576 hlist_for_each_entry_safe(mpath, n, &tbl->walk_head, walk_list) {
577 __mesh_path_del(tbl, mpath);
609 struct mesh_path *mpath;
612 mpath = rhashtable_lookup_fast(&tbl->rhead, addr, mesh_rht_params);
613 if (!mpath) {
618 __mesh_path_del(tbl, mpath);
647 * @mpath: mesh path to activate
649 * Locking: the state_lock of the mpath structure must NOT be held when calling
652 void mesh_path_tx_pending(struct mesh_path *mpath)
654 if (mpath->flags & MESH_PATH_ACTIVE)
655 ieee80211_add_pending_skbs(mpath->sdata->local,
656 &mpath->frame_queue);
662 * @mpath: mesh path whose queue will be emptied
664 * If there is only one gate, the frames are transferred from the failed mpath
667 * mpath queues are emptied onto the transmission queue.
669 int mesh_path_send_to_gates(struct mesh_path *mpath)
671 struct ieee80211_sub_if_data *sdata = mpath->sdata;
673 struct mesh_path *from_mpath = mpath;
699 return (from_mpath == mpath) ? -EHOSTUNREACH : 0;
720 * @mpath: mesh path whose queue has to be freed
724 void mesh_path_flush_pending(struct mesh_path *mpath)
726 struct ieee80211_sub_if_data *sdata = mpath->sdata;
731 while ((skb = skb_dequeue(&mpath->frame_queue)) != NULL)
732 mesh_path_discard_frame(mpath->sdata, skb);
736 if (ether_addr_equal(mpath->dst, preq->dst)) {
748 * @mpath: the mesh path to modify
751 * Locking: this function must be called holding mpath->state_lock
753 void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop)
755 spin_lock_bh(&mpath->state_lock);
756 mesh_path_assign_nexthop(mpath, next_hop);
757 mpath->sn = 0xffff;
758 mpath->metric = 0;
759 mpath->hop_count = 0;
760 mpath->exp_time = 0;
761 mpath->flags = MESH_PATH_FIXED | MESH_PATH_SN_VALID;
762 mesh_path_activate(mpath);
763 spin_unlock_bh(&mpath->state_lock);
767 mesh_path_tx_pending(mpath);
780 struct mesh_path *mpath;
784 hlist_for_each_entry_safe(mpath, n, &tbl->walk_head, walk_list) {
785 if ((!(mpath->flags & MESH_PATH_RESOLVING)) &&
786 (!(mpath->flags & MESH_PATH_FIXED)) &&
787 time_after(jiffies, mpath->exp_time + MESH_PATH_EXPIRE))
788 __mesh_path_del(tbl, mpath);