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, "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, "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 mutex_lock(&ar->ab->tbl_mtx_lock); in ath11k_peer_create()
386 spin_lock_bh(&ar->ab->base_lock); in ath11k_peer_create()
387 peer = ath11k_peer_find_by_addr(ar->ab, param->peer_addr); in ath11k_peer_create()
390 spin_unlock_bh(&ar->ab->base_lock); in ath11k_peer_create()
391 mutex_unlock(&ar->ab->tbl_mtx_lock); in ath11k_peer_create()
398 ath11k_peer_rhash_delete(ar->ab, peer); in ath11k_peer_create()
400 spin_unlock_bh(&ar->ab->base_lock); in ath11k_peer_create()
401 mutex_unlock(&ar->ab->tbl_mtx_lock); in ath11k_peer_create()
405 ath11k_warn(ar->ab, in ath11k_peer_create()
416 mutex_lock(&ar->ab->tbl_mtx_lock); in ath11k_peer_create()
417 spin_lock_bh(&ar->ab->base_lock); in ath11k_peer_create()
419 peer = ath11k_peer_find(ar->ab, param->vdev_id, param->peer_addr); in ath11k_peer_create()
421 spin_unlock_bh(&ar->ab->base_lock); in ath11k_peer_create()
422 mutex_unlock(&ar->ab->tbl_mtx_lock); in ath11k_peer_create()
423 ath11k_warn(ar->ab, "failed to find peer %pM on vdev %i after creation\n", in ath11k_peer_create()
430 ret = ath11k_peer_rhash_add(ar->ab, peer); in ath11k_peer_create()
432 spin_unlock_bh(&ar->ab->base_lock); in ath11k_peer_create()
433 mutex_unlock(&ar->ab->tbl_mtx_lock); in ath11k_peer_create()
460 spin_unlock_bh(&ar->ab->base_lock); in ath11k_peer_create()
461 mutex_unlock(&ar->ab->tbl_mtx_lock); in ath11k_peer_create()
468 ath11k_warn(ar->ab, "failed peer %pM delete vdev_id %d fallback ret %d\n", in ath11k_peer_create()
474 int ath11k_peer_rhash_delete(struct ath11k_base *ab, struct ath11k_peer *peer) in ath11k_peer_rhash_delete() argument
478 lockdep_assert_held(&ab->base_lock); in ath11k_peer_rhash_delete()
479 lockdep_assert_held(&ab->tbl_mtx_lock); in ath11k_peer_rhash_delete()
481 if (!ab->rhead_peer_id || !ab->rhead_peer_addr) in ath11k_peer_rhash_delete()
484 ret = ath11k_peer_rhash_remove(ab, ab->rhead_peer_addr, &peer->rhash_addr, in ath11k_peer_rhash_delete()
485 &ab->rhash_peer_addr_param); in ath11k_peer_rhash_delete()
487 ath11k_warn(ab, "failed to remove peer %pM id %d in rhash_addr ret %d\n", in ath11k_peer_rhash_delete()
492 ret = ath11k_peer_rhash_remove(ab, ab->rhead_peer_id, &peer->rhash_id, in ath11k_peer_rhash_delete()
493 &ab->rhash_peer_id_param); in ath11k_peer_rhash_delete()
495 ath11k_warn(ab, "failed to remove peer %pM id %d in rhash_id ret %d\n", in ath11k_peer_rhash_delete()
503 static int ath11k_peer_rhash_id_tbl_init(struct ath11k_base *ab) in ath11k_peer_rhash_id_tbl_init() argument
510 lockdep_assert_held(&ab->tbl_mtx_lock); in ath11k_peer_rhash_id_tbl_init()
512 if (ab->rhead_peer_id) in ath11k_peer_rhash_id_tbl_init()
515 size = sizeof(*ab->rhead_peer_id); in ath11k_peer_rhash_id_tbl_init()
518 ath11k_warn(ab, "failed to init rhash id table due to no mem (size %zu)\n", in ath11k_peer_rhash_id_tbl_init()
523 param = &ab->rhash_peer_id_param; in ath11k_peer_rhash_id_tbl_init()
529 param->nelem_hint = ab->num_radios * TARGET_NUM_PEERS_PDEV(ab); in ath11k_peer_rhash_id_tbl_init()
533 ath11k_warn(ab, "failed to init peer id rhash table %d\n", ret); in ath11k_peer_rhash_id_tbl_init()
537 spin_lock_bh(&ab->base_lock); in ath11k_peer_rhash_id_tbl_init()
539 if (!ab->rhead_peer_id) { in ath11k_peer_rhash_id_tbl_init()
540 ab->rhead_peer_id = rhash_id_tbl; in ath11k_peer_rhash_id_tbl_init()
542 spin_unlock_bh(&ab->base_lock); in ath11k_peer_rhash_id_tbl_init()
546 spin_unlock_bh(&ab->base_lock); in ath11k_peer_rhash_id_tbl_init()
558 static int ath11k_peer_rhash_addr_tbl_init(struct ath11k_base *ab) in ath11k_peer_rhash_addr_tbl_init() argument
565 lockdep_assert_held(&ab->tbl_mtx_lock); in ath11k_peer_rhash_addr_tbl_init()
567 if (ab->rhead_peer_addr) in ath11k_peer_rhash_addr_tbl_init()
570 size = sizeof(*ab->rhead_peer_addr); in ath11k_peer_rhash_addr_tbl_init()
573 ath11k_warn(ab, "failed to init rhash addr table due to no mem (size %zu)\n", in ath11k_peer_rhash_addr_tbl_init()
578 param = &ab->rhash_peer_addr_param; in ath11k_peer_rhash_addr_tbl_init()
584 param->nelem_hint = ab->num_radios * TARGET_NUM_PEERS_PDEV(ab); in ath11k_peer_rhash_addr_tbl_init()
588 ath11k_warn(ab, "failed to init peer addr rhash table %d\n", ret); in ath11k_peer_rhash_addr_tbl_init()
592 spin_lock_bh(&ab->base_lock); in ath11k_peer_rhash_addr_tbl_init()
594 if (!ab->rhead_peer_addr) { in ath11k_peer_rhash_addr_tbl_init()
595 ab->rhead_peer_addr = rhash_addr_tbl; in ath11k_peer_rhash_addr_tbl_init()
597 spin_unlock_bh(&ab->base_lock); in ath11k_peer_rhash_addr_tbl_init()
601 spin_unlock_bh(&ab->base_lock); in ath11k_peer_rhash_addr_tbl_init()
613 static inline void ath11k_peer_rhash_id_tbl_destroy(struct ath11k_base *ab) in ath11k_peer_rhash_id_tbl_destroy() argument
615 lockdep_assert_held(&ab->tbl_mtx_lock); in ath11k_peer_rhash_id_tbl_destroy()
617 if (!ab->rhead_peer_id) in ath11k_peer_rhash_id_tbl_destroy()
620 rhashtable_destroy(ab->rhead_peer_id); in ath11k_peer_rhash_id_tbl_destroy()
621 kfree(ab->rhead_peer_id); in ath11k_peer_rhash_id_tbl_destroy()
622 ab->rhead_peer_id = NULL; in ath11k_peer_rhash_id_tbl_destroy()
625 static inline void ath11k_peer_rhash_addr_tbl_destroy(struct ath11k_base *ab) in ath11k_peer_rhash_addr_tbl_destroy() argument
627 lockdep_assert_held(&ab->tbl_mtx_lock); in ath11k_peer_rhash_addr_tbl_destroy()
629 if (!ab->rhead_peer_addr) in ath11k_peer_rhash_addr_tbl_destroy()
632 rhashtable_destroy(ab->rhead_peer_addr); in ath11k_peer_rhash_addr_tbl_destroy()
633 kfree(ab->rhead_peer_addr); in ath11k_peer_rhash_addr_tbl_destroy()
634 ab->rhead_peer_addr = NULL; in ath11k_peer_rhash_addr_tbl_destroy()
637 int ath11k_peer_rhash_tbl_init(struct ath11k_base *ab) in ath11k_peer_rhash_tbl_init() argument
641 mutex_lock(&ab->tbl_mtx_lock); in ath11k_peer_rhash_tbl_init()
643 ret = ath11k_peer_rhash_id_tbl_init(ab); in ath11k_peer_rhash_tbl_init()
647 ret = ath11k_peer_rhash_addr_tbl_init(ab); in ath11k_peer_rhash_tbl_init()
651 mutex_unlock(&ab->tbl_mtx_lock); in ath11k_peer_rhash_tbl_init()
656 ath11k_peer_rhash_id_tbl_destroy(ab); in ath11k_peer_rhash_tbl_init()
658 mutex_unlock(&ab->tbl_mtx_lock); in ath11k_peer_rhash_tbl_init()
662 void ath11k_peer_rhash_tbl_destroy(struct ath11k_base *ab) in ath11k_peer_rhash_tbl_destroy() argument
664 mutex_lock(&ab->tbl_mtx_lock); in ath11k_peer_rhash_tbl_destroy()
666 ath11k_peer_rhash_addr_tbl_destroy(ab); in ath11k_peer_rhash_tbl_destroy()
667 ath11k_peer_rhash_id_tbl_destroy(ab); in ath11k_peer_rhash_tbl_destroy()
669 mutex_unlock(&ab->tbl_mtx_lock); in ath11k_peer_rhash_tbl_destroy()