Lines Matching full:ab

11 static struct ath11k_peer *ath11k_peer_find_list_by_id(struct ath11k_base *ab,  in ath11k_peer_find_list_by_id()  argument
16 lockdep_assert_held(&ab->base_lock); in ath11k_peer_find_list_by_id()
18 list_for_each_entry(peer, &ab->peers, list) { in ath11k_peer_find_list_by_id()
28 struct ath11k_peer *ath11k_peer_find(struct ath11k_base *ab, int vdev_id, in ath11k_peer_find() argument
33 lockdep_assert_held(&ab->base_lock); in ath11k_peer_find()
35 list_for_each_entry(peer, &ab->peers, list) { in ath11k_peer_find()
47 struct ath11k_peer *ath11k_peer_find_by_addr(struct ath11k_base *ab, in ath11k_peer_find_by_addr() argument
52 lockdep_assert_held(&ab->base_lock); in ath11k_peer_find_by_addr()
54 if (!ab->rhead_peer_addr) in ath11k_peer_find_by_addr()
57 peer = rhashtable_lookup_fast(ab->rhead_peer_addr, addr, in ath11k_peer_find_by_addr()
58 ab->rhash_peer_addr_param); in ath11k_peer_find_by_addr()
63 struct ath11k_peer *ath11k_peer_find_by_id(struct ath11k_base *ab, in ath11k_peer_find_by_id() argument
68 lockdep_assert_held(&ab->base_lock); in ath11k_peer_find_by_id()
70 if (!ab->rhead_peer_id) in ath11k_peer_find_by_id()
73 peer = rhashtable_lookup_fast(ab->rhead_peer_id, &peer_id, in ath11k_peer_find_by_id()
74 ab->rhash_peer_id_param); in ath11k_peer_find_by_id()
79 struct ath11k_peer *ath11k_peer_find_by_vdev_id(struct ath11k_base *ab, in ath11k_peer_find_by_vdev_id() argument
84 spin_lock_bh(&ab->base_lock); in ath11k_peer_find_by_vdev_id()
86 list_for_each_entry(peer, &ab->peers, list) { in ath11k_peer_find_by_vdev_id()
88 spin_unlock_bh(&ab->base_lock); in ath11k_peer_find_by_vdev_id()
92 spin_unlock_bh(&ab->base_lock); in ath11k_peer_find_by_vdev_id()
96 void ath11k_peer_unmap_event(struct ath11k_base *ab, u16 peer_id) in ath11k_peer_unmap_event() argument
100 spin_lock_bh(&ab->base_lock); in ath11k_peer_unmap_event()
102 peer = ath11k_peer_find_list_by_id(ab, peer_id); in ath11k_peer_unmap_event()
104 ath11k_warn(ab, "peer-unmap-event: unknown peer id %d\n", in ath11k_peer_unmap_event()
109 ath11k_dbg(ab, ATH11K_DBG_DP_HTT, "htt peer unmap vdev %d peer %pM id %d\n", in ath11k_peer_unmap_event()
114 wake_up(&ab->peer_mapping_wq); in ath11k_peer_unmap_event()
117 spin_unlock_bh(&ab->base_lock); in ath11k_peer_unmap_event()
120 void ath11k_peer_map_event(struct ath11k_base *ab, u8 vdev_id, u16 peer_id, in ath11k_peer_map_event() argument
125 spin_lock_bh(&ab->base_lock); in ath11k_peer_map_event()
126 peer = ath11k_peer_find(ab, vdev_id, mac_addr); in ath11k_peer_map_event()
137 list_add(&peer->list, &ab->peers); in ath11k_peer_map_event()
138 wake_up(&ab->peer_mapping_wq); in ath11k_peer_map_event()
141 ath11k_dbg(ab, ATH11K_DBG_DP_HTT, "htt peer map vdev %d peer %pM id %d\n", in ath11k_peer_map_event()
145 spin_unlock_bh(&ab->base_lock); in ath11k_peer_map_event()
148 static int ath11k_wait_for_peer_common(struct ath11k_base *ab, int vdev_id, in ath11k_wait_for_peer_common() argument
153 ret = wait_event_timeout(ab->peer_mapping_wq, ({ in ath11k_wait_for_peer_common()
156 spin_lock_bh(&ab->base_lock); in ath11k_wait_for_peer_common()
157 mapped = !!ath11k_peer_find(ab, vdev_id, addr); in ath11k_wait_for_peer_common()
158 spin_unlock_bh(&ab->base_lock); in ath11k_wait_for_peer_common()
161 test_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags)); in ath11k_wait_for_peer_common()
170 static inline int ath11k_peer_rhash_insert(struct ath11k_base *ab, in ath11k_peer_rhash_insert() argument
178 lockdep_assert_held(&ab->tbl_mtx_lock); in ath11k_peer_rhash_insert()
190 static inline int ath11k_peer_rhash_remove(struct ath11k_base *ab, in ath11k_peer_rhash_remove() argument
197 lockdep_assert_held(&ab->tbl_mtx_lock); in ath11k_peer_rhash_remove()
206 static int ath11k_peer_rhash_add(struct ath11k_base *ab, struct ath11k_peer *peer) in ath11k_peer_rhash_add() argument
210 lockdep_assert_held(&ab->base_lock); in ath11k_peer_rhash_add()
211 lockdep_assert_held(&ab->tbl_mtx_lock); in ath11k_peer_rhash_add()
213 if (!ab->rhead_peer_id || !ab->rhead_peer_addr) in ath11k_peer_rhash_add()
216 ret = ath11k_peer_rhash_insert(ab, ab->rhead_peer_id, &peer->rhash_id, in ath11k_peer_rhash_add()
217 &ab->rhash_peer_id_param, &peer->peer_id); in ath11k_peer_rhash_add()
219 ath11k_warn(ab, "failed to add peer %pM with id %d in rhash_id ret %d\n", in ath11k_peer_rhash_add()
224 ret = ath11k_peer_rhash_insert(ab, ab->rhead_peer_addr, &peer->rhash_addr, in ath11k_peer_rhash_add()
225 &ab->rhash_peer_addr_param, &peer->addr); in ath11k_peer_rhash_add()
227 ath11k_warn(ab, "failed to add peer %pM with id %d in rhash_addr ret %d\n", in ath11k_peer_rhash_add()
235 ath11k_peer_rhash_remove(ab, ab->rhead_peer_id, &peer->rhash_id, in ath11k_peer_rhash_add()
236 &ab->rhash_peer_id_param); in ath11k_peer_rhash_add()
243 struct ath11k_base *ab = ar->ab; in ath11k_peer_cleanup() local
247 mutex_lock(&ab->tbl_mtx_lock); in ath11k_peer_cleanup()
248 spin_lock_bh(&ab->base_lock); in ath11k_peer_cleanup()
249 list_for_each_entry_safe(peer, tmp, &ab->peers, list) { in ath11k_peer_cleanup()
253 ath11k_warn(ab, "removing stale peer %pM from vdev_id %d\n", in ath11k_peer_cleanup()
256 ath11k_peer_rhash_delete(ab, peer); in ath11k_peer_cleanup()
262 spin_unlock_bh(&ab->base_lock); in ath11k_peer_cleanup()
263 mutex_unlock(&ab->tbl_mtx_lock); in ath11k_peer_cleanup()
268 return ath11k_wait_for_peer_common(ar->ab, vdev_id, addr, false); in ath11k_wait_for_peer_deleted()
279 ath11k_warn(ar->ab, "failed wait for peer deleted"); in ath11k_wait_for_peer_delete_done()
286 ath11k_warn(ar->ab, "Timeout in receiving peer delete response\n"); in ath11k_wait_for_peer_delete_done()
297 struct ath11k_base *ab = ar->ab; in __ath11k_peer_delete() local
301 mutex_lock(&ab->tbl_mtx_lock); in __ath11k_peer_delete()
302 spin_lock_bh(&ab->base_lock); in __ath11k_peer_delete()
304 peer = ath11k_peer_find_by_addr(ab, addr); in __ath11k_peer_delete()
311 ath11k_peer_rhash_delete(ab, peer); in __ath11k_peer_delete()
318 peer = ath11k_peer_find(ab, vdev_id, addr); in __ath11k_peer_delete()
321 spin_unlock_bh(&ab->base_lock); in __ath11k_peer_delete()
322 mutex_unlock(&ab->tbl_mtx_lock); in __ath11k_peer_delete()
324 ath11k_warn(ab, in __ath11k_peer_delete()
330 spin_unlock_bh(&ab->base_lock); in __ath11k_peer_delete()
331 mutex_unlock(&ab->tbl_mtx_lock); in __ath11k_peer_delete()
337 ath11k_warn(ab, in __ath11k_peer_delete()
367 return ath11k_wait_for_peer_common(ar->ab, vdev_id, addr, true); in ath11k_wait_for_peer_created()
380 ath11k_warn(ar->ab, in ath11k_peer_create()
385 spin_lock_bh(&ar->ab->base_lock); in ath11k_peer_create()
386 peer = ath11k_peer_find_by_addr(ar->ab, param->peer_addr); in ath11k_peer_create()
389 spin_unlock_bh(&ar->ab->base_lock); in ath11k_peer_create()
396 mutex_lock(&ar->ab->tbl_mtx_lock); in ath11k_peer_create()
397 ath11k_peer_rhash_delete(ar->ab, peer); in ath11k_peer_create()
398 mutex_unlock(&ar->ab->tbl_mtx_lock); in ath11k_peer_create()
400 spin_unlock_bh(&ar->ab->base_lock); in ath11k_peer_create()
404 ath11k_warn(ar->ab, in ath11k_peer_create()
415 mutex_lock(&ar->ab->tbl_mtx_lock); in ath11k_peer_create()
416 spin_lock_bh(&ar->ab->base_lock); in ath11k_peer_create()
418 peer = ath11k_peer_find(ar->ab, param->vdev_id, param->peer_addr); in ath11k_peer_create()
420 spin_unlock_bh(&ar->ab->base_lock); in ath11k_peer_create()
421 mutex_unlock(&ar->ab->tbl_mtx_lock); in ath11k_peer_create()
422 ath11k_warn(ar->ab, "failed to find peer %pM on vdev %i after creation\n", in ath11k_peer_create()
429 ret = ath11k_peer_rhash_add(ar->ab, peer); in ath11k_peer_create()
431 spin_unlock_bh(&ar->ab->base_lock); in ath11k_peer_create()
432 mutex_unlock(&ar->ab->tbl_mtx_lock); in ath11k_peer_create()
459 spin_unlock_bh(&ar->ab->base_lock); in ath11k_peer_create()
460 mutex_unlock(&ar->ab->tbl_mtx_lock); in ath11k_peer_create()
467 ath11k_warn(ar->ab, "failed peer %pM delete vdev_id %d fallback ret %d\n", in ath11k_peer_create()
473 int ath11k_peer_rhash_delete(struct ath11k_base *ab, struct ath11k_peer *peer) in ath11k_peer_rhash_delete() argument
477 lockdep_assert_held(&ab->base_lock); in ath11k_peer_rhash_delete()
478 lockdep_assert_held(&ab->tbl_mtx_lock); in ath11k_peer_rhash_delete()
480 if (!ab->rhead_peer_id || !ab->rhead_peer_addr) in ath11k_peer_rhash_delete()
483 ret = ath11k_peer_rhash_remove(ab, ab->rhead_peer_addr, &peer->rhash_addr, in ath11k_peer_rhash_delete()
484 &ab->rhash_peer_addr_param); in ath11k_peer_rhash_delete()
486 ath11k_warn(ab, "failed to remove peer %pM id %d in rhash_addr ret %d\n", in ath11k_peer_rhash_delete()
491 ret = ath11k_peer_rhash_remove(ab, ab->rhead_peer_id, &peer->rhash_id, in ath11k_peer_rhash_delete()
492 &ab->rhash_peer_id_param); in ath11k_peer_rhash_delete()
494 ath11k_warn(ab, "failed to remove peer %pM id %d in rhash_id ret %d\n", in ath11k_peer_rhash_delete()
502 static int ath11k_peer_rhash_id_tbl_init(struct ath11k_base *ab) in ath11k_peer_rhash_id_tbl_init() argument
509 lockdep_assert_held(&ab->tbl_mtx_lock); in ath11k_peer_rhash_id_tbl_init()
511 if (ab->rhead_peer_id) in ath11k_peer_rhash_id_tbl_init()
514 size = sizeof(*ab->rhead_peer_id); in ath11k_peer_rhash_id_tbl_init()
517 ath11k_warn(ab, "failed to init rhash id table due to no mem (size %zu)\n", in ath11k_peer_rhash_id_tbl_init()
522 param = &ab->rhash_peer_id_param; in ath11k_peer_rhash_id_tbl_init()
528 param->nelem_hint = ab->num_radios * TARGET_NUM_PEERS_PDEV(ab); in ath11k_peer_rhash_id_tbl_init()
532 ath11k_warn(ab, "failed to init peer id rhash table %d\n", ret); in ath11k_peer_rhash_id_tbl_init()
536 spin_lock_bh(&ab->base_lock); in ath11k_peer_rhash_id_tbl_init()
538 if (!ab->rhead_peer_id) { in ath11k_peer_rhash_id_tbl_init()
539 ab->rhead_peer_id = rhash_id_tbl; in ath11k_peer_rhash_id_tbl_init()
541 spin_unlock_bh(&ab->base_lock); in ath11k_peer_rhash_id_tbl_init()
545 spin_unlock_bh(&ab->base_lock); in ath11k_peer_rhash_id_tbl_init()
557 static int ath11k_peer_rhash_addr_tbl_init(struct ath11k_base *ab) in ath11k_peer_rhash_addr_tbl_init() argument
564 lockdep_assert_held(&ab->tbl_mtx_lock); in ath11k_peer_rhash_addr_tbl_init()
566 if (ab->rhead_peer_addr) in ath11k_peer_rhash_addr_tbl_init()
569 size = sizeof(*ab->rhead_peer_addr); in ath11k_peer_rhash_addr_tbl_init()
572 ath11k_warn(ab, "failed to init rhash addr table due to no mem (size %zu)\n", in ath11k_peer_rhash_addr_tbl_init()
577 param = &ab->rhash_peer_addr_param; in ath11k_peer_rhash_addr_tbl_init()
583 param->nelem_hint = ab->num_radios * TARGET_NUM_PEERS_PDEV(ab); in ath11k_peer_rhash_addr_tbl_init()
587 ath11k_warn(ab, "failed to init peer addr rhash table %d\n", ret); in ath11k_peer_rhash_addr_tbl_init()
591 spin_lock_bh(&ab->base_lock); in ath11k_peer_rhash_addr_tbl_init()
593 if (!ab->rhead_peer_addr) { in ath11k_peer_rhash_addr_tbl_init()
594 ab->rhead_peer_addr = rhash_addr_tbl; in ath11k_peer_rhash_addr_tbl_init()
596 spin_unlock_bh(&ab->base_lock); in ath11k_peer_rhash_addr_tbl_init()
600 spin_unlock_bh(&ab->base_lock); in ath11k_peer_rhash_addr_tbl_init()
612 static inline void ath11k_peer_rhash_id_tbl_destroy(struct ath11k_base *ab) in ath11k_peer_rhash_id_tbl_destroy() argument
614 lockdep_assert_held(&ab->tbl_mtx_lock); in ath11k_peer_rhash_id_tbl_destroy()
616 if (!ab->rhead_peer_id) in ath11k_peer_rhash_id_tbl_destroy()
619 rhashtable_destroy(ab->rhead_peer_id); in ath11k_peer_rhash_id_tbl_destroy()
620 kfree(ab->rhead_peer_id); in ath11k_peer_rhash_id_tbl_destroy()
621 ab->rhead_peer_id = NULL; in ath11k_peer_rhash_id_tbl_destroy()
624 static inline void ath11k_peer_rhash_addr_tbl_destroy(struct ath11k_base *ab) in ath11k_peer_rhash_addr_tbl_destroy() argument
626 lockdep_assert_held(&ab->tbl_mtx_lock); in ath11k_peer_rhash_addr_tbl_destroy()
628 if (!ab->rhead_peer_addr) in ath11k_peer_rhash_addr_tbl_destroy()
631 rhashtable_destroy(ab->rhead_peer_addr); in ath11k_peer_rhash_addr_tbl_destroy()
632 kfree(ab->rhead_peer_addr); in ath11k_peer_rhash_addr_tbl_destroy()
633 ab->rhead_peer_addr = NULL; in ath11k_peer_rhash_addr_tbl_destroy()
636 int ath11k_peer_rhash_tbl_init(struct ath11k_base *ab) in ath11k_peer_rhash_tbl_init() argument
640 mutex_lock(&ab->tbl_mtx_lock); in ath11k_peer_rhash_tbl_init()
642 ret = ath11k_peer_rhash_id_tbl_init(ab); in ath11k_peer_rhash_tbl_init()
646 ret = ath11k_peer_rhash_addr_tbl_init(ab); in ath11k_peer_rhash_tbl_init()
650 mutex_unlock(&ab->tbl_mtx_lock); in ath11k_peer_rhash_tbl_init()
655 ath11k_peer_rhash_id_tbl_destroy(ab); in ath11k_peer_rhash_tbl_init()
657 mutex_unlock(&ab->tbl_mtx_lock); in ath11k_peer_rhash_tbl_init()
661 void ath11k_peer_rhash_tbl_destroy(struct ath11k_base *ab) in ath11k_peer_rhash_tbl_destroy() argument
663 mutex_lock(&ab->tbl_mtx_lock); in ath11k_peer_rhash_tbl_destroy()
665 ath11k_peer_rhash_addr_tbl_destroy(ab); in ath11k_peer_rhash_tbl_destroy()
666 ath11k_peer_rhash_id_tbl_destroy(ab); in ath11k_peer_rhash_tbl_destroy()
668 mutex_unlock(&ab->tbl_mtx_lock); in ath11k_peer_rhash_tbl_destroy()