[PATCH ath-next] wifi: ath12k: add hash table for peer lookup in struct ath12k_dp_hw
Aishwarya R
aishwarya.r at oss.qualcomm.com
Thu Nov 19 21:12:33 PST 2026
On 11/16/2026 11:52 AM, Baochen Qiang wrote:
>
>
> On 10/26/2026 2:21 PM, Aishwarya R wrote:
>> Peer lookup by MAC address in struct ath12k_dp_hw is currently performed by
>> walking the dp_peers_list, resulting in O(n) lookup complexity. As the
>> driver supports up to 1536 clients, frequent lookups on critical paths
>> such as TX/RX processing, peer management, control operations and
>> debug/statistics handling can incur noticeable overhead in dense
>> deployment scenarios.
>>
>> Replace the peer list with a generic kernel hash table for MAC address
>> based peer management and lookup, providing O(1) average-case lookup
>> performance. The hash table is implemented using DECLARE_HASHTABLE()
>> with 2048 buckets (2^11), derived from
>> order_base_2(ATH12K_MAX_DEVICES * ATH12K_MAX_CLIENTS), and uses jhash()
>> over the peer MAC address as the hash key.
>>
>> The hash table is used both for address-based lookups and peer
>> traversal operations, eliminating the need for maintaining a separate
>> peer list.
>>
>> The maximum single-radio client limit is defined as
>> ATH12K_MAX_CLIENTS and reused by the memory profile and hardware
>> params. This keeps the peer hash sizing aligned with the per-device
>> client limit and the maximum number of devices in a hardware group.
>>
>> Key changes:
>> - Add peer_hash table to ath12k_dp_hw and initialize it during
>> hardware allocation.
>> - Add hash_node to ath12k_dp_peer for hash table membership.
>> - Introduce helper APIs for hash computation, insertion, deletion and
>> lookup.
>> - Convert MAC-address-based peer searches from list traversal to
>> hash-table lookup.
>> - Replace peer list traversal with hash table iteration.
>>
>> Peer creation inserts the peer into the hash table, while deletion
>> removes it from the hash table. Peer cleanup paths are updated to
>> iterate over the hash table and safely free peer objects.
>>
>> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.6-01243-QCAHKSWPL_SILICONZ-1
>>
>> Co-developed-by: Harsh Kumar Bijlani <harsh.bijlani at oss.qualcomm.com>
>> Signed-off-by: Harsh Kumar Bijlani <harsh.bijlani at oss.qualcomm.com>
>> Signed-off-by: Aishwarya R <aishwarya.r at oss.qualcomm.com>
>
>
> QCN6432 support recently get merged upstream, so you might want to rebase to have its
> max_client_single modified as well in ath12k_wifi7_hw_params.
QCN6432 uses 256 for max_client_single. The newly introduced
ATH12K_MAX_CLIENTS define is only for hardware supporting 512 clients,
so no change is needed for QCN6432.
>
> with that fixed:
> Reviewed-by: Baochen Qiang <baochen.qiang at oss.qualcomm.com>
>
More information about the ath12k
mailing list