Wi-Fi 7 relies on the HTT peer-map event to confirm peer creation, but Wi-Fi 8 firmware does not send this event. Add a WMI PEER_CREATE_CONF event handler and a per-architecture map_event_required hw_param to distinguish the two families. Wi-Fi 7 sets map_event_required true and returns immediately after the HTT peer-map event completes, since that is the exclusive confirmation signal for this path. Wi-Fi 8 sets it false and relies solely on the WMI PEER_CREATE_CONF event. Gate the PEER_CREATE_CONF event handler with !map_event_required so Wi-Fi 7 devices do not process it. 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.c | 1 + drivers/net/wireless/ath/ath12k/core.h | 1 + drivers/net/wireless/ath/ath12k/hw.h | 1 + drivers/net/wireless/ath/ath12k/mac.c | 1 + drivers/net/wireless/ath/ath12k/peer.c | 33 +++++++++- drivers/net/wireless/ath/ath12k/wifi7/hw.c | 7 +++ drivers/net/wireless/ath/ath12k/wmi.c | 71 ++++++++++++++++++++++ drivers/net/wireless/ath/ath12k/wmi.h | 23 +++++++ 8 files changed, 135 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c index 6e0bb1fecc09..677eb6335008 100644 --- a/drivers/net/wireless/ath/ath12k/core.c +++ b/drivers/net/wireless/ath/ath12k/core.c @@ -1567,6 +1567,7 @@ static void ath12k_core_pre_reconfigure_recovery(struct ath12k_base *ab) complete(&ar->scan.started); complete_all(&ar->scan.completed); complete(&ar->scan.on_channel); + complete(&ar->peer_create_done); complete(&ar->peer_assoc_done); complete(&ar->peer_ext_event_done); ath12k_peer_delete_wait_flush(ar); diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h index 5b9a247b8c40..ffe686f95864 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -693,6 +693,7 @@ struct ath12k { u8 hw_link_id; u8 radio_idx; + struct completion peer_create_done; struct completion peer_assoc_done; struct completion peer_ext_event_done; struct list_head peer_delete_waits; diff --git a/drivers/net/wireless/ath/ath12k/hw.h b/drivers/net/wireless/ath/ath12k/hw.h index b8045b33ca0d..ad6f074a1a67 100644 --- a/drivers/net/wireless/ath/ath12k/hw.h +++ b/drivers/net/wireless/ath/ath12k/hw.h @@ -168,6 +168,7 @@ struct ath12k_hw_params { u8 max_radios; u8 max_htc_eps; bool single_pdev_only:1; + bool map_event_required:1; u32 qmi_service_ins_id; u32 qmi_max_chunk_size; bool internal_sleep_clock:1; diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index 3baf317e375c..f494684d7eaf 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -15286,6 +15286,7 @@ static void ath12k_mac_setup(struct ath12k *ar) init_completion(&ar->vdev_setup_done); init_completion(&ar->vdev_delete_done); + init_completion(&ar->peer_create_done); init_completion(&ar->peer_assoc_done); init_completion(&ar->peer_ext_event_done); init_completion(&ar->install_key_done); diff --git a/drivers/net/wireless/ath/ath12k/peer.c b/drivers/net/wireless/ath/ath12k/peer.c index a989981dd72c..982c62a208a3 100644 --- a/drivers/net/wireless/ath/ath12k/peer.c +++ b/drivers/net/wireless/ath/ath12k/peer.c @@ -182,11 +182,36 @@ int ath12k_peer_delete(struct ath12k *ar, u32 vdev_id, u8 *addr) return ret; } -static int ath12k_wait_for_peer_created(struct ath12k *ar, int vdev_id, const u8 *addr) +static int ath12k_wait_for_peer_map_event(struct ath12k *ar, int vdev_id, const u8 *addr) { return ath12k_wait_for_dp_link_peer_common(ar->ab, vdev_id, addr, true); } +static int ath12k_wait_for_peer_create_done(struct ath12k *ar, u32 vdev_id, + const u8 *addr) +{ + struct ath12k_base *ab = ar->ab; + unsigned long time_left; + + /* + * On devices that confirm peer creation via the HTT peer-map event, + * peer_create_done is not used - the peer-map is the exclusive signal. + */ + if (ab->hw_params->map_event_required) + return ath12k_wait_for_peer_map_event(ar, vdev_id, addr); + + /* On devices that use WMI PEER_CREATE_CONF instead of HTT peer-map. */ + time_left = wait_for_completion_timeout(&ar->peer_create_done, 3 * HZ); + if (!time_left) { + ath12k_warn(ar->ab, + "timeout waiting for peer_create_done peer_addr:%pM\n", + addr); + return -ETIMEDOUT; + } + + return 0; +} + int ath12k_peer_create(struct ath12k *ar, struct ath12k_link_vif *arvif, struct ieee80211_sta *sta, struct ath12k_wmi_peer_create_arg *arg) @@ -221,6 +246,8 @@ int ath12k_peer_create(struct ath12k *ar, struct ath12k_link_vif *arvif, } spin_unlock_bh(&dp->dp_lock); + reinit_completion(&ar->peer_create_done); + ret = ath12k_wmi_send_peer_create_cmd(ar, arg); if (ret) { ath12k_warn(ar->ab, @@ -229,8 +256,8 @@ int ath12k_peer_create(struct ath12k *ar, struct ath12k_link_vif *arvif, return ret; } - ret = ath12k_wait_for_peer_created(ar, arg->vdev_id, - arg->peer_addr); + ret = ath12k_wait_for_peer_create_done(ar, arg->vdev_id, + arg->peer_addr); if (ret) return ret; diff --git a/drivers/net/wireless/ath/ath12k/wifi7/hw.c b/drivers/net/wireless/ath/ath12k/wifi7/hw.c index 978f2e0ce7e7..05cdb8e88827 100644 --- a/drivers/net/wireless/ath/ath12k/wifi7/hw.c +++ b/drivers/net/wireless/ath/ath12k/wifi7/hw.c @@ -418,6 +418,7 @@ static const struct ath12k_hw_params ath12k_wifi7_hw_params[] = { .max_radios = 1, .max_htc_eps = 9, .single_pdev_only = false, + .map_event_required = true, .qmi_service_ins_id = ATH12K_QMI_WLFW_SERVICE_INS_ID_V01_QCN9274, .qmi_max_chunk_size = SZ_2M, .internal_sleep_clock = false, @@ -517,6 +518,7 @@ static const struct ath12k_hw_params ath12k_wifi7_hw_params[] = { .max_radios = 1, .max_htc_eps = 9, .single_pdev_only = true, + .map_event_required = true, .qmi_service_ins_id = ATH12K_QMI_WLFW_SERVICE_INS_ID_V01_WCN7850, .qmi_max_chunk_size = SZ_512K, .internal_sleep_clock = true, @@ -616,6 +618,7 @@ static const struct ath12k_hw_params ath12k_wifi7_hw_params[] = { .max_radios = 2, .max_htc_eps = 9, .single_pdev_only = false, + .map_event_required = true, .qmi_service_ins_id = ATH12K_QMI_WLFW_SERVICE_INS_ID_V01_QCN9274, .qmi_max_chunk_size = SZ_2M, .internal_sleep_clock = false, @@ -713,6 +716,7 @@ static const struct ath12k_hw_params ath12k_wifi7_hw_params[] = { .max_radios = 1, .max_htc_eps = 9, .single_pdev_only = false, + .map_event_required = true, .qmi_service_ins_id = ATH12K_QMI_WLFW_SERVICE_INS_ID_V01_IPQ5332, .qmi_max_chunk_size = SZ_2M, .internal_sleep_clock = false, @@ -806,6 +810,7 @@ static const struct ath12k_hw_params ath12k_wifi7_hw_params[] = { .max_radios = 1, .max_htc_eps = 9, .single_pdev_only = true, + .map_event_required = true, .qmi_service_ins_id = ATH12K_QMI_WLFW_SERVICE_INS_ID_V01_WCN7850, .qmi_max_chunk_size = SZ_512K, .internal_sleep_clock = true, @@ -906,6 +911,7 @@ static const struct ath12k_hw_params ath12k_wifi7_hw_params[] = { .max_radios = 1, .max_htc_eps = 9, .single_pdev_only = false, + .map_event_required = true, .qmi_service_ins_id = ATH12K_QMI_WLFW_SERVICE_INS_ID_V01_IPQ5332, .qmi_max_chunk_size = SZ_2M, .internal_sleep_clock = false, @@ -1000,6 +1006,7 @@ static const struct ath12k_hw_params ath12k_wifi7_hw_params[] = { .max_radios = 1, .max_htc_eps = 9, .single_pdev_only = false, + .map_event_required = true, .qmi_service_ins_id = ATH12K_QMI_WLFW_SERVICE_INS_ID_V01_QCN6432, .qmi_max_chunk_size = SZ_2M, .internal_sleep_clock = false, diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c index f41138a7c68e..76f93a4f14b1 100644 --- a/drivers/net/wireless/ath/ath12k/wmi.c +++ b/drivers/net/wireless/ath/ath12k/wmi.c @@ -155,6 +155,8 @@ static const struct ath12k_wmi_tlv_policy ath12k_wmi_tlv_policies[] = { .min_len = sizeof(struct wmi_vdev_start_resp_event) }, [WMI_TAG_PEER_DELETE_RESP_EVENT] = { .min_len = sizeof(struct wmi_peer_delete_resp_event) }, + [WMI_TAG_PEER_CREATE_RESP_EVENT] = { + .min_len = sizeof(struct ath12k_wmi_peer_create_conf_event) }, [WMI_TAG_OFFLOAD_BCN_TX_STATUS_EVENT] = { .min_len = sizeof(struct wmi_bcn_tx_status_event) }, [WMI_TAG_VDEV_STOPPED_EVENT] = { @@ -7998,6 +8000,72 @@ static int ath12k_service_available_event(struct ath12k_base *ab, struct sk_buff return ret; } +static int ath12k_pull_peer_create_conf_ev(struct ath12k_base *ab, + struct sk_buff *skb, + struct ath12k_wmi_peer_create_conf_arg *arg) +{ + const struct ath12k_wmi_peer_create_conf_event *ev; + const void **tb; + + tb = ath12k_wmi_tlv_parse(ab, skb); + if (IS_ERR(tb)) { + ath12k_warn(ab, "failed to parse peer create conf tlv\n"); + return PTR_ERR(tb); + } + + ev = tb[WMI_TAG_PEER_CREATE_RESP_EVENT]; + if (!ev) { + ath12k_warn(ab, "failed to fetch peer create conf ev\n"); + return -EPROTO; + } + + arg->vdev_id = le32_to_cpu(ev->vdev_id); + ether_addr_copy(arg->mac_addr, ev->peer_macaddr.addr); + arg->status = le32_to_cpu(ev->status); + + return 0; +} + +static void ath12k_wmi_peer_create_conf_event(struct ath12k_base *ab, + struct sk_buff *skb) +{ + struct ath12k_wmi_peer_create_conf_arg arg = {}; + struct ath12k *ar; + + /* + * Wi-Fi 7 firmware also sends this event, but devices that rely on + * the HTT peer-map as the authoritative creation signal return here + * and process the peer-map instead. + */ + if (ab->hw_params->map_event_required) + return; + + if (ath12k_pull_peer_create_conf_ev(ab, skb, &arg)) { + ath12k_warn(ab, "failed to extract peer create conf event\n"); + return; + } + + if (arg.status != ATH12K_WMI_PEER_CREATE_SUCCESS) { + ath12k_warn(ab, "peer %pM create failed status %d\n", + arg.mac_addr, arg.status); + return; + } + + rcu_read_lock(); + ar = ath12k_mac_get_ar_by_vdev_id(ab, arg.vdev_id); + if (!ar) { + ath12k_warn(ab, "invalid vdev id in peer create conf %d\n", + arg.vdev_id); + rcu_read_unlock(); + return; + } + + complete(&ar->peer_create_done); + rcu_read_unlock(); + + ath12k_dbg(ab, ATH12K_DBG_WMI, "peer create conf %pM\n", arg.mac_addr); +} + static void ath12k_peer_assoc_conf_event(struct ath12k_base *ab, struct sk_buff *skb) { struct wmi_peer_assoc_conf_arg peer_assoc_conf = {}; @@ -10410,6 +10478,9 @@ static void ath12k_wmi_op_rx(struct ath12k_base *ab, struct sk_buff *skb) case WMI_READY_EVENTID: ath12k_ready_event(ab, skb); break; + case WMI_PEER_CREATE_CONF_EVENTID: + ath12k_wmi_peer_create_conf_event(ab, skb); + break; case WMI_PEER_DELETE_RESP_EVENTID: ath12k_peer_delete_resp_event(ab, skb); break; diff --git a/drivers/net/wireless/ath/ath12k/wmi.h b/drivers/net/wireless/ath/ath12k/wmi.h index 843f1d11f9c8..ab39c33ef61a 100644 --- a/drivers/net/wireless/ath/ath12k/wmi.h +++ b/drivers/net/wireless/ath/ath12k/wmi.h @@ -791,6 +791,7 @@ enum wmi_tlv_event_id { WMI_PEER_RESERVED9_EVENTID, WMI_PEER_RESERVED10_EVENTID, WMI_PEER_OPER_MODE_CHANGE_EVENTID, + WMI_PEER_CREATE_CONF_EVENTID = WMI_PEER_OPER_MODE_CHANGE_EVENTID + 3, WMI_MGMT_RX_EVENTID = WMI_TLV_CMD(WMI_GRP_MGMT), WMI_HOST_SWBA_EVENTID, WMI_TBTTOFFSET_UPDATE_EVENTID, @@ -1998,6 +1999,7 @@ enum wmi_tlv_tag { WMI_TAG_PDEV_PEER_PKTLOG_FILTER_INFO, WMI_TAG_SERVICE_READY_EXT2_EVENT = 0x334, WMI_TAG_FILS_DISCOVERY_TMPL_CMD = 0x344, + WMI_TAG_PEER_CREATE_RESP_EVENT = 0x364, WMI_TAG_MAC_PHY_CAPABILITIES_EXT = 0x36F, WMI_TAG_PDEV_SRG_BSS_COLOR_BITMAP_CMD = 0x37b, WMI_TAG_PDEV_SRG_PARTIAL_BSSID_BITMAP_CMD, @@ -6579,6 +6581,27 @@ int ath12k_wmi_attach(struct ath12k_base *ab); void ath12k_wmi_detach(struct ath12k_base *ab); int ath12k_wmi_vdev_create(struct ath12k *ar, u8 *macaddr, struct ath12k_wmi_vdev_create_arg *arg); + +enum ath12k_peer_create_conf_status { + ATH12K_WMI_PEER_CREATE_SUCCESS, + ATH12K_WMI_PEER_BSS_PEER_EXISTS, + ATH12K_WMI_PEER_AST_FULL, + ATH12K_WMI_PEER_SW_PEER_ID_INVALID, + ATH12K_WMI_PEER_CREATE_STATUS_MAX +}; + +struct ath12k_wmi_peer_create_conf_event { + __le32 vdev_id; + struct ath12k_wmi_mac_addr_params peer_macaddr; + __le32 status; +} __packed; + +struct ath12k_wmi_peer_create_conf_arg { + u32 vdev_id; + u8 mac_addr[ETH_ALEN]; + u32 status; +}; + int ath12k_wmi_send_peer_create_cmd(struct ath12k *ar, struct ath12k_wmi_peer_create_arg *arg); int ath12k_wmi_vdev_set_param_cmd(struct ath12k *ar, u32 vdev_id, -- 2.34.1