From: Ramya Gnanasekar On devices with global_peer_id_supported enabled, the host allocates peer_id and sta_id from local bitmaps before issuing WMI peer create. Extend the WMI peer create command to carry these host-allocated IDs so firmware can use them directly. peer_id (sw_peer_id in firmware) is the sw peer identifier. It covers all peer types including remote peers, self peers, with additional bubble space to handle simultaneous create/delete races. sta_id (hw_peer_id in firmware) is the hardware station index allocated exclusively for actual remote peers and its usage in firmware. Add sta_id to ath12k_dp_peer_create_params and ath12k_dp_peer. Add peer_id and sta_id accessor helpers to retrieve the values from the dp_peer table by address and sta object. These accessor apis are planned to be used only in station association path where a valid sta object is available. Pass the allocated IDs into the WMI peer create command when valid. 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: Ramya Gnanasekar Co-developed-by: Sriram R Signed-off-by: Sriram R --- drivers/net/wireless/ath/ath12k/core.h | 2 ++ drivers/net/wireless/ath/ath12k/dp_cmn.h | 5 ++++ drivers/net/wireless/ath/ath12k/dp_peer.c | 30 +++++++++++++++++++ drivers/net/wireless/ath/ath12k/dp_peer.h | 3 +- drivers/net/wireless/ath/ath12k/mac.c | 19 ++++++++++-- .../net/wireless/ath/ath12k/wifi7/dp_peer.c | 1 + drivers/net/wireless/ath/ath12k/wmi.c | 13 ++++++-- drivers/net/wireless/ath/ath12k/wmi.h | 7 +++++ 8 files changed, 74 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h index e1602236c3c1..796d78f84bb6 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -69,6 +69,8 @@ #define ATH12K_INVALID_GROUP_ID 0xFF #define ATH12K_INVALID_DEVICE_ID 0xFF +#define ATH12K_STA_ID_INVALID 0xFFFF + #define ATH12K_INVALID_RSSI_FULL -1 #define ATH12K_INVALID_RSSI_EMPTY -128 diff --git a/drivers/net/wireless/ath/ath12k/dp_cmn.h b/drivers/net/wireless/ath/ath12k/dp_cmn.h index 317da91ea92a..8be1d92e1b65 100644 --- a/drivers/net/wireless/ath/ath12k/dp_cmn.h +++ b/drivers/net/wireless/ath/ath12k/dp_cmn.h @@ -83,6 +83,7 @@ struct ath12k_dp_peer_create_params { struct ieee80211_sta *sta; bool is_mlo; u16 peer_id; + u16 sta_id; bool ucast_ra_only; }; @@ -117,4 +118,8 @@ void ath12k_dp_link_peer_get_sta_rate_info_stats(struct ath12k_dp *dp, const u8 *addr, struct ath12k_dp_link_peer_rate_info *info); void ath12k_dp_link_peer_reset_rx_stats(struct ath12k_dp *dp, const u8 *addr); +u16 ath12k_dp_peer_get_peer_id(struct ath12k_dp_hw *dp_hw, + struct ieee80211_sta *sta); +u16 ath12k_dp_peer_get_sta_id(struct ath12k_dp_hw *dp_hw, + struct ieee80211_sta *sta); #endif diff --git a/drivers/net/wireless/ath/ath12k/dp_peer.c b/drivers/net/wireless/ath/ath12k/dp_peer.c index 79fc8416a59f..e945e4fc7b59 100644 --- a/drivers/net/wireless/ath/ath12k/dp_peer.c +++ b/drivers/net/wireless/ath/ath12k/dp_peer.c @@ -541,6 +541,36 @@ static void ath12k_dp_peer_free_logical_link_id(struct ath12k_dp *dp, dp_peer->free_slot_map |= BIT(peer->drv_link_id); } +u16 ath12k_dp_peer_get_peer_id(struct ath12k_dp_hw *dp_hw, + struct ieee80211_sta *sta) +{ + u16 peer_id = ATH12K_MLO_PEER_ID_INVALID; + struct ath12k_dp_peer *dp_peer; + + spin_lock_bh(&dp_hw->peer_lock); + dp_peer = ath12k_dp_peer_find_by_addr_and_sta(dp_hw, sta->addr, sta); + if (dp_peer) + peer_id = dp_peer->peer_id; + spin_unlock_bh(&dp_hw->peer_lock); + + return peer_id; +} + +u16 ath12k_dp_peer_get_sta_id(struct ath12k_dp_hw *dp_hw, + struct ieee80211_sta *sta) +{ + u16 sta_id = ATH12K_STA_ID_INVALID; + struct ath12k_dp_peer *dp_peer; + + spin_lock_bh(&dp_hw->peer_lock); + dp_peer = ath12k_dp_peer_find_by_addr_and_sta(dp_hw, sta->addr, sta); + if (dp_peer) + sta_id = dp_peer->sta_id; + spin_unlock_bh(&dp_hw->peer_lock); + + return sta_id; +} + int ath12k_dp_link_peer_assign(struct ath12k_dp *dp, struct ath12k_dp_hw *dp_hw, u8 vdev_id, struct ieee80211_sta *sta, u8 *addr, u8 link_id, u32 hw_link_id) diff --git a/drivers/net/wireless/ath/ath12k/dp_peer.h b/drivers/net/wireless/ath/ath12k/dp_peer.h index 3ef0d7f3465b..f43c3337aa37 100644 --- a/drivers/net/wireless/ath/ath12k/dp_peer.h +++ b/drivers/net/wireless/ath/ath12k/dp_peer.h @@ -134,7 +134,8 @@ struct ath12k_dp_peer { u8 mcast_keyidx; bool ucast_ra_only; - int peer_id; + u16 peer_id; + u16 sta_id; struct ieee80211_sta *sta; /* diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index d61dd251eeef..a2cdcfd485e9 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -3570,7 +3570,9 @@ static void ath12k_peer_assoc_h_mlo(struct ath12k_link_sta *arsta, /* * Only chips that allocate the MLD peer ID on the host send a valid * ml_peer_id in WMI_PEER_ASSOC_CMDID. For chips where the firmware - * picks the ID, leave peer_id_valid false to avoid unexpected issues. + * picks the ID, leave peer_id_valid false to avoid unexpected issue. + * On devices that use a single host-allocated peer ID, ml_peer_id is + * not applicable and peer_id_valid is also left false. */ ml->peer_id_valid = ah->host_alloc_ml_id; ml->logical_link_idx_valid = true; @@ -7249,6 +7251,12 @@ static int ath12k_mac_station_add(struct ath12k *ar, peer_param.peer_addr = arsta->addr; peer_param.peer_type = WMI_PEER_TYPE_DEFAULT; peer_param.ml_enabled = sta->mlo; + peer_param.peer_id = ATH12K_MLO_PEER_ID_INVALID; + peer_param.sta_id = ATH12K_STA_ID_INVALID; + if (ab->dp->global_peer_id_supported) { + peer_param.peer_id = ath12k_dp_peer_get_peer_id(&ar->ah->dp_hw, sta); + peer_param.sta_id = ath12k_dp_peer_get_sta_id(&ar->ah->dp_hw, sta); + } ret = ath12k_peer_create(ar, arvif, sta, &peer_param); if (ret) { @@ -10495,13 +10503,16 @@ int ath12k_mac_vdev_create(struct ath12k *ar, struct ath12k_link_vif *arvif) struct ath12k_wmi_vdev_create_arg vdev_arg = {}; struct ath12k_wmi_peer_create_arg peer_param = {}; struct ieee80211_bss_conf *link_conf = NULL; + struct ath12k_dp_peer_create_params params = { + .peer_id = ATH12K_MLO_PEER_ID_INVALID, + .sta_id = ATH12K_STA_ID_INVALID, + }; + struct ath12k_dp_link_vif *dp_link_vif = NULL; u32 param_id, param_value; u16 nss; int i; int ret, vdev_id; u8 link_id; - struct ath12k_dp_link_vif *dp_link_vif = NULL; - struct ath12k_dp_peer_create_params params = {}; bool dp_peer_created = false; lockdep_assert_wiphy(hw->wiphy); @@ -10608,6 +10619,8 @@ int ath12k_mac_vdev_create(struct ath12k *ar, struct ath12k_link_vif *arvif) peer_param.vdev_id = arvif->vdev_id; peer_param.peer_addr = arvif->bssid; peer_param.peer_type = WMI_PEER_TYPE_DEFAULT; + peer_param.peer_id = params.peer_id; + peer_param.sta_id = params.sta_id; ret = ath12k_peer_create(ar, arvif, NULL, &peer_param); if (ret) { ath12k_warn(ab, "failed to vdev %d create peer for AP: %d\n", diff --git a/drivers/net/wireless/ath/ath12k/wifi7/dp_peer.c b/drivers/net/wireless/ath/ath12k/wifi7/dp_peer.c index 73034ae7d0cd..c2636e87b4c2 100644 --- a/drivers/net/wireless/ath/ath12k/wifi7/dp_peer.c +++ b/drivers/net/wireless/ath/ath12k/wifi7/dp_peer.c @@ -40,6 +40,7 @@ int ath12k_wifi7_dp_peer_create(struct ath12k_hw *ah, * assigned at the time of link peer creation */ dp_peer->peer_id = params->is_mlo ? params->peer_id : ATH12K_DP_PEER_ID_INVALID; + dp_peer->sta_id = ATH12K_STA_ID_INVALID; dp_peer->ucast_ra_only = params->ucast_ra_only; dp_peer->sec_type = HAL_ENCRYPT_TYPE_OPEN; diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c index 76f93a4f14b1..b51137193e1d 100644 --- a/drivers/net/wireless/ath/ath12k/wmi.c +++ b/drivers/net/wireless/ath/ath12k/wmi.c @@ -1368,6 +1368,14 @@ int ath12k_wmi_send_peer_create_cmd(struct ath12k *ar, cmd->peer_type = cpu_to_le32(arg->peer_type); cmd->vdev_id = cpu_to_le32(arg->vdev_id); + if (arg->peer_id != ATH12K_MLO_PEER_ID_INVALID) + cmd->peer_id = cpu_to_le32(arg->peer_id); + + if (arg->sta_id != ATH12K_STA_ID_INVALID) { + cmd->flags = cpu_to_le32(ATH12K_WMI_PEER_CREATE_FLAG_STA_ID_VALID); + cmd->sta_id = cpu_to_le32(arg->sta_id); + } + ptr = skb->data + sizeof(*cmd); tlv = ptr; tlv->header = ath12k_wmi_tlv_hdr(WMI_TAG_ARRAY_STRUCT, @@ -1383,8 +1391,9 @@ int ath12k_wmi_send_peer_create_cmd(struct ath12k *ar, ptr += sizeof(*ml_param); ath12k_dbg(ar->ab, ATH12K_DBG_WMI, - "WMI peer create vdev_id %d peer_addr %pM ml_flags 0x%x\n", - arg->vdev_id, arg->peer_addr, ml_param->flags); + "WMI peer create vdev_id %d peer_addr %pM ml_flags 0x%x peer_id %d sta_id %d\n", + arg->vdev_id, arg->peer_addr, ml_param->flags, + arg->peer_id, arg->sta_id); ret = ath12k_wmi_cmd_send(wmi, skb, WMI_PEER_CREATE_CMDID); if (ret) { diff --git a/drivers/net/wireless/ath/ath12k/wmi.h b/drivers/net/wireless/ath/ath12k/wmi.h index ab39c33ef61a..513974b3b4eb 100644 --- a/drivers/net/wireless/ath/ath12k/wmi.h +++ b/drivers/net/wireless/ath/ath12k/wmi.h @@ -3197,6 +3197,8 @@ struct ath12k_wmi_peer_create_arg { u32 peer_type; u32 vdev_id; bool ml_enabled; + u32 peer_id; + u32 sta_id; }; struct wmi_peer_create_mlo_params { @@ -3304,11 +3306,16 @@ enum wmi_peer_type { WMI_PEER_TYPE_TDLS = 2, }; +#define ATH12K_WMI_PEER_CREATE_FLAG_STA_ID_VALID BIT(0) + struct wmi_peer_create_cmd { __le32 tlv_header; __le32 vdev_id; struct ath12k_wmi_mac_addr_params peer_macaddr; __le32 peer_type; + __le32 flags; + __le32 peer_id; + __le32 sta_id; } __packed; struct wmi_peer_delete_cmd { -- 2.34.1