In Wi-Fi 7, peer ID assignment is split: the host allocates ML peer IDs locally (and marks them with ATH12K_PEER_ML_ID_VALID), while firmware assigns link peer IDs for non-ML and link peers and notifies the host via the HTT_T2H Peer MAP event. The host must wait for this event before the dp_peer RCU table entry can be published. The two ID spaces are at different granularities (hw vs device), requiring a device-ID-based shift when computing the RCU table index for link/non-ML peers. Wi-Fi 8 moves to a fully host-managed global peer ID model. A single unified ID space covers both ML and non-ML peers, and the host assigns the sw_peer_id before sending the WMI peer create command. HTT Peer MAP and MLO Peer MAP events are removed; there is no async firmware response for peer ID assignment. This simplifies the peer create path and eliminates the HTT event wait. Introduce a global_peer_id_supported flag on ath12k_dp to distinguish the two models. Move the peer index to RCU table index translation into a common inline helper ath12k_dp_peer_get_peerid_index() in dp.h: when global peer ID is supported the index is the peer_id directly; otherwise the existing device-ID shift applies. Also refactor ath12k_peer_ml_alloc() to accept the dp pointer and return an error code. On devices with global peer IDs, it sets the peer_id to ATH12K_MLO_PEER_ID_INVALID (the dp layer assigns the real ID during peer creation) and returns 0. On devices where firmware assigns the ML peer ID, it sets ATH12K_MLO_PEER_ID_PENDING. On host-allocating Wi-Fi 7 devices it allocates from the bitmap as before. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.6-01243-QCAHKSWPL_SILICONZ-1 Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3 Signed-off-by: Sriram R --- drivers/net/wireless/ath/ath12k/core.h | 4 --- drivers/net/wireless/ath/ath12k/dp.h | 13 +++++++++ drivers/net/wireless/ath/ath12k/dp_peer.c | 17 ------------ drivers/net/wireless/ath/ath12k/dp_peer.h | 27 ++++++++++++++++--- drivers/net/wireless/ath/ath12k/mac.c | 21 +++++---------- drivers/net/wireless/ath/ath12k/peer.c | 31 +++++++++++++++++++--- drivers/net/wireless/ath/ath12k/peer.h | 2 +- drivers/net/wireless/ath/ath12k/wifi7/dp.c | 1 + 8 files changed, 73 insertions(+), 43 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h index 56b509841126..5b9a247b8c40 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -69,10 +69,6 @@ #define ATH12K_INVALID_GROUP_ID 0xFF #define ATH12K_INVALID_DEVICE_ID 0xFF -#define ATH12K_MAX_MLO_PEERS 256 -#define ATH12K_MLO_PEER_ID_INVALID 0xFFFF -#define ATH12K_MLO_PEER_ID_PENDING 0xFFFE - #define ATH12K_INVALID_RSSI_FULL -1 #define ATH12K_INVALID_RSSI_EMPTY -128 diff --git a/drivers/net/wireless/ath/ath12k/dp.h b/drivers/net/wireless/ath/ath12k/dp.h index d7a1ecd7cb0b..f439f43ed302 100644 --- a/drivers/net/wireless/ath/ath12k/dp.h +++ b/drivers/net/wireless/ath/ath12k/dp.h @@ -284,6 +284,12 @@ struct ath12k_pdev_dp { #define DP_REO_QREF_NUM GENMASK(31, 16) #define DP_MAX_PEER_ID 2047 +#define ATH12K_MAX_MLO_PEERS 256 +#define ATH12K_MLO_PEER_ID_INVALID 0xFFFF +#define ATH12K_MLO_PEER_ID_PENDING 0xFFFE + +#define ATH12K_PEER_ML_ID_VALID BIT(13) + /* Total size of the LUT is based on 2K peers, each having reference * for 17tids, note each entry is of type ath12k_reo_queue_ref * hence total size is 2048 * 17 * 8 = 278528 @@ -531,6 +537,13 @@ struct ath12k_dp { struct ath12k_hw_group *ag; u8 device_id; + /* + * When enabled, the device uses a single peer id allocator + * common for ML and non ML peer in host instead of separate + * ml peer id at host and firmware allocated link peer id/non ML peer ID + */ + bool global_peer_id_supported; + /* Lock for protection of peers and rhead_peer_addr */ spinlock_t dp_lock; diff --git a/drivers/net/wireless/ath/ath12k/dp_peer.c b/drivers/net/wireless/ath/ath12k/dp_peer.c index dc3da9e6d38a..7e45aef396a2 100644 --- a/drivers/net/wireless/ath/ath12k/dp_peer.c +++ b/drivers/net/wireless/ath/ath12k/dp_peer.c @@ -458,23 +458,6 @@ ath12k_dp_peer_create_find(struct ath12k_dp_hw *dp_hw, } EXPORT_SYMBOL(ath12k_dp_peer_create_find); -/* - * Index of ath12k_dp_peer for MLO client is same as peer id of ath12k_dp_peer, - * while for ath12k_dp_link_peer(mlo and non-mlo) and ath12k_dp_peer for - * Non-MLO client it is derived as ((DEVICE_ID << 10) | (10 bits of peer id)). - * - * This is done because ml_peer_id and peer_id_table are at hw granularity, - * while link_peer_id is at device granularity, hence in order to avoid - * conflict this approach is followed. - */ -#define ATH12K_DP_PEER_TABLE_DEVICE_ID_SHIFT 10 - -u16 ath12k_dp_peer_get_peerid_index(struct ath12k_dp *dp, u16 peer_id) -{ - return (peer_id & ATH12K_PEER_ML_ID_VALID) ? peer_id : - ((dp->device_id << ATH12K_DP_PEER_TABLE_DEVICE_ID_SHIFT) | peer_id); -} - struct ath12k_dp_peer *ath12k_dp_peer_find_by_peerid(struct ath12k_pdev_dp *dp_pdev, u16 peer_id) { diff --git a/drivers/net/wireless/ath/ath12k/dp_peer.h b/drivers/net/wireless/ath/ath12k/dp_peer.h index 5357b812959d..3ef0d7f3465b 100644 --- a/drivers/net/wireless/ath/ath12k/dp_peer.h +++ b/drivers/net/wireless/ath/ath12k/dp_peer.h @@ -10,6 +10,7 @@ #include "dp_rx.h" #define ATH12K_DP_PEER_ID_INVALID 0x3FFF +#define ATH12K_DP_PEER_TABLE_DEVICE_ID_SHIFT 10 struct ppdu_user_delayba { u16 sw_peer_id; @@ -21,8 +22,6 @@ struct ppdu_user_delayba { u32 resp_rate_flags; }; -#define ATH12K_PEER_ML_ID_VALID BIT(13) - struct ath12k_rx_peer_rate_stats { u64 ht_mcs_count[HAL_RX_MAX_MCS_HT + 1]; u64 vht_mcs_count[HAL_RX_MAX_MCS_VHT + 1]; @@ -189,7 +188,6 @@ struct ath12k_dp_peer *ath12k_dp_peer_find_by_addr(struct ath12k_dp_hw *dp_hw, u struct ath12k_dp_peer *ath12k_dp_peer_find_by_addr_and_sta(struct ath12k_dp_hw *dp_hw, u8 *addr, struct ieee80211_sta *sta); -u16 ath12k_dp_peer_get_peerid_index(struct ath12k_dp *dp, u16 peer_id); struct ath12k_dp_peer *ath12k_dp_peer_find_by_peerid(struct ath12k_pdev_dp *dp_pdev, u16 peer_id); struct ath12k_dp_link_peer * @@ -218,4 +216,27 @@ void ath12k_dp_peer_hash_table_add(struct ath12k_dp_hw *dp_hw, struct ath12k_dp_peer *dp_peer); void ath12k_dp_peer_hash_table_delete(struct ath12k_dp_hw *dp_hw, struct ath12k_dp_peer *dp_peer); + +/* + * When global_peer_id is supported, the index is same as the peer_id and no + * specific ml peer id or peer index per device is used. + * + * In other cases, + * Index of ath12k_dp_peer for MLO client is same as peer id of ath12k_dp_peer, + * while for ath12k_dp_link_peer(mlo and non-mlo) and ath12k_dp_peer for + * Non-MLO client it is derived as ((DEVICE_ID << 10) | (10 bits of peer id)). + * + * This is done because ml_peer_id and peer_id_table are at hw granularity, + * while link_peer_id is at device granularity, hence in order to avoid + * conflict this approach is followed. + */ +static inline u16 +ath12k_dp_peer_get_peerid_index(struct ath12k_dp *dp, u16 peer_id) +{ + if (dp->global_peer_id_supported) + return peer_id; + + return (peer_id & ATH12K_PEER_ML_ID_VALID) ? peer_id + : ((dp->device_id << ATH12K_DP_PEER_TABLE_DEVICE_ID_SHIFT) | peer_id); +} #endif diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index 4850fb6a77f5..3baf317e375c 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -7860,23 +7860,16 @@ int ath12k_mac_op_sta_state(struct ieee80211_hw *hw, /* ML sta */ if (sta->mlo && !ahsta->links_map && (hweight16(sta->valid_links) == 1)) { - if (ah->host_alloc_ml_id) { - ahsta->ml_peer_id = ath12k_peer_ml_alloc(ah); - if (ahsta->ml_peer_id == ATH12K_MLO_PEER_ID_INVALID) { - ath12k_hw_warn(ah, "unable to allocate ML peer id for sta %pM", - sta->addr); - goto exit; - } - } else { - /* - * firmware allocates the ML peer ID and notifies - * the host via HTT_T2H_MSG_TYPE_MLO_RX_PEER_MAP - */ - ahsta->ml_peer_id = ATH12K_MLO_PEER_ID_PENDING; + ret = ath12k_peer_ml_alloc(ah, dp, + &dp_params.peer_id); + if (ret) { + ath12k_hw_warn(ah, "unable to allocate ML peer id for sta %pM", + sta->addr); + goto exit; } + ahsta->ml_peer_id = dp_params.peer_id; dp_params.is_mlo = true; - dp_params.peer_id = ahsta->ml_peer_id; } dp_params.sta = sta; diff --git a/drivers/net/wireless/ath/ath12k/peer.c b/drivers/net/wireless/ath/ath12k/peer.c index 0e894408e97f..a989981dd72c 100644 --- a/drivers/net/wireless/ath/ath12k/peer.c +++ b/drivers/net/wireless/ath/ath12k/peer.c @@ -327,12 +327,32 @@ int ath12k_peer_create(struct ath12k *ar, struct ath12k_link_vif *arvif, return ret; } -u16 ath12k_peer_ml_alloc(struct ath12k_hw *ah) +int ath12k_peer_ml_alloc(struct ath12k_hw *ah, struct ath12k_dp *dp, u16 *peer_id) { u16 ml_peer_id; lockdep_assert_wiphy(ah->hw->wiphy); + /* + * On devices that use globally unique peer IDs the peer ID is allocated + * at host and is used as a common id to represent ML peer and its link peers + * for MLO cases or just as the link peer id for non ML cases. + */ + if (dp->global_peer_id_supported) { + *peer_id = ATH12K_MLO_PEER_ID_INVALID; + return 0; + } + + if (!ah->host_alloc_ml_id) { + /* + * On devices where firmware assigns the ML peer ID, defer the + * RCU table publish to the HTT_T2H_MSG_TYPE_MLO_RX_PEER_MAP + * handler. + */ + *peer_id = ATH12K_MLO_PEER_ID_PENDING; + return 0; + } + for (ml_peer_id = 0; ml_peer_id < ATH12K_MAX_MLO_PEERS; ml_peer_id++) { if (test_bit(ml_peer_id, ah->free_ml_peer_id_map)) continue; @@ -341,10 +361,13 @@ u16 ath12k_peer_ml_alloc(struct ath12k_hw *ah) break; } - if (ml_peer_id == ATH12K_MAX_MLO_PEERS) - return ATH12K_MLO_PEER_ID_INVALID; + if (ml_peer_id == ATH12K_MAX_MLO_PEERS) { + *peer_id = ATH12K_MLO_PEER_ID_INVALID; + return -ENOMEM; + } - return ml_peer_id | ATH12K_PEER_ML_ID_VALID; + *peer_id = ml_peer_id | ATH12K_PEER_ML_ID_VALID; + return 0; } void ath12k_peer_ml_free(struct ath12k_hw *ah, struct ath12k_sta *ahsta) diff --git a/drivers/net/wireless/ath/ath12k/peer.h b/drivers/net/wireless/ath/ath12k/peer.h index 3f4ac17b9aa6..c08f1e4d800d 100644 --- a/drivers/net/wireless/ath/ath12k/peer.h +++ b/drivers/net/wireless/ath/ath12k/peer.h @@ -35,6 +35,6 @@ void ath12k_link_sta_rhash_delete(struct ath12k_base *ab, struct ath12k_link_sta int ath12k_link_sta_rhash_add(struct ath12k_base *ab, struct ath12k_link_sta *arsta); struct ath12k_link_sta *ath12k_link_sta_find_by_addr(struct ath12k_base *ab, const u8 *addr); -u16 ath12k_peer_ml_alloc(struct ath12k_hw *ah); +int ath12k_peer_ml_alloc(struct ath12k_hw *ah, struct ath12k_dp *dp, u16 *peer_id); void ath12k_peer_ml_free(struct ath12k_hw *ah, struct ath12k_sta *ahsta); #endif /* _PEER_H_ */ diff --git a/drivers/net/wireless/ath/ath12k/wifi7/dp.c b/drivers/net/wireless/ath/ath12k/wifi7/dp.c index b8b915884c7f..fbdcb5bf05ab 100644 --- a/drivers/net/wireless/ath/ath12k/wifi7/dp.c +++ b/drivers/net/wireless/ath/ath12k/wifi7/dp.c @@ -174,6 +174,7 @@ struct ath12k_dp *ath12k_wifi7_dp_device_alloc(struct ath12k_base *ab) dp->hal = &ab->hal; dp->ops = &ath12k_wifi7_dp_arch_ops; + dp->global_peer_id_supported = false; return dp; } -- 2.34.1