Central UMAC (CUMAC) designates one device in a multi-device group as the master MAC for coordinating shared resources. Add WMI command support to configure which device ID acts as CUMAC during hardware group initialisation. All devices in the group that support the command receive WMI_PDEV_SET_CUMAC_DEVICE_CMDID carrying the CUMAC device ID, so each device learns which one acts as the central coordinator. The driver checks WMI_TLV_SERVICE_PDEV_SET_CUMAC_DEVICE_CMD_SUPPORT in the service bitmap to determine whether to send the configuration. When supported, WMI_RSRC_CFG_HOST_SVC_FLAG_CUMAC_CMD_SUPPORT_BIT is also set in the host service flags during resource config. The first device is selected as CUMAC by default; selection logic will be extended later to pick the optimal device. Failure to configure CUMAC on any device aborts the hardware group start. 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 | 71 ++++++++++++++++++++ drivers/net/wireless/ath/ath12k/core.h | 2 + drivers/net/wireless/ath/ath12k/mac.c | 1 + drivers/net/wireless/ath/ath12k/wmi.c | 90 ++++++++++++++++++++++++++ drivers/net/wireless/ath/ath12k/wmi.h | 23 +++++++ 5 files changed, 187 insertions(+) diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c index 677eb6335008..1c2b7e4ee411 100644 --- a/drivers/net/wireless/ath/ath12k/core.c +++ b/drivers/net/wireless/ath/ath12k/core.c @@ -1192,6 +1192,67 @@ static int ath12k_core_mlo_setup(struct ath12k_hw_group *ag) return ret; } +static int ath12k_core_send_cumac_config(struct ath12k_hw_group *ag) +{ + /* Select device 0 as CUMAC; selection logic to be extended later */ + u8 cumac_device_id = 0; + int i; + + if (ath12k_ftm_mode) + return 0; + + for (i = 0; i < ag->num_devices; i++) { + struct ath12k_base *cab = ag->ab[i]; + int j, ret; + + if (!cab) + continue; + + if (!test_bit(WMI_TLV_SERVICE_PDEV_SET_CUMAC_DEVICE_CMD_SUPPORT, + cab->wmi_ab.svc_map)) + continue; + + ath12k_dbg(cab, ATH12K_DBG_BOOT, + "cumac: selected device_id=%u as cumac\n", + cumac_device_id); + + for (j = 0; j < cab->num_radios; j++) { + struct ath12k *car = cab->pdevs[j].ar; + + if (!car) + continue; + + reinit_completion(&car->cumac_setup_done); + ret = ath12k_wmi_send_cumac_config(car, cumac_device_id); + if (ret) { + ath12k_warn(cab, "cumac: failed to send config pdev_id=%u: %d\n", + car->pdev->pdev_id, ret); + return ret; + } + + if (!wait_for_completion_timeout(&car->cumac_setup_done, + ATH12K_CUMAC_SETUP_TIMEOUT_HZ)) { + ath12k_warn(cab, "cumac: timeout pdev_id=%u\n", + car->pdev->pdev_id); + return -ETIMEDOUT; + } + + ath12k_dbg(cab, ATH12K_DBG_BOOT, + "cumac: config sent successfully pdev_id=%u\n", + car->pdev->pdev_id); + + /* + * CUMAC config is a per-device setting. One WMI command + * per device is sufficient. So break after sending + * to the first active radio on the device. + */ + break; + } + } + + return 0; +} + static int ath12k_core_hw_group_start(struct ath12k_hw_group *ag) { struct ath12k_base *ab; @@ -1200,6 +1261,12 @@ static int ath12k_core_hw_group_start(struct ath12k_hw_group *ag) lockdep_assert_held(&ag->mutex); if (test_bit(ATH12K_GROUP_FLAG_REGISTERED, &ag->flags)) { + ret = ath12k_core_send_cumac_config(ag); + if (WARN_ON(ret)) { + ath12k_mac_unregister(ag); + goto err_mac_destroy; + } + ret = ath12k_core_mlo_setup(ag); if (WARN_ON(ret)) { ath12k_mac_unregister(ag); @@ -1212,6 +1279,10 @@ static int ath12k_core_hw_group_start(struct ath12k_hw_group *ag) if (WARN_ON(ret)) return ret; + ret = ath12k_core_send_cumac_config(ag); + if (WARN_ON(ret)) + goto err_mac_destroy; + ret = ath12k_core_mlo_setup(ag); if (WARN_ON(ret)) goto err_mac_destroy; diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h index 796d78f84bb6..359fda7e9eab 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -57,6 +57,7 @@ #define ATH12K_INVALID_HW_MAC_ID 0xFF #define ATH12K_CONNECTION_LOSS_HZ (3 * HZ) +#define ATH12K_CUMAC_SETUP_TIMEOUT_HZ (3 * HZ) #define ATH12K_MON_TIMER_INTERVAL 10 #define ATH12K_RESET_TIMEOUT_HZ (20 * HZ) @@ -774,6 +775,7 @@ struct ath12k { struct completion fw_stats_done; struct completion mlo_setup_done; + struct completion cumac_setup_done; u32 mlo_setup_status; u8 ftm_msgref; struct ath12k_fw_stats fw_stats; diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index a2cdcfd485e9..d97cb9877ecb 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -15309,6 +15309,7 @@ static void ath12k_mac_setup(struct ath12k *ar) init_completion(&ar->scan.completed); init_completion(&ar->scan.on_channel); init_completion(&ar->mlo_setup_done); + init_completion(&ar->cumac_setup_done); init_completion(&ar->completed_11d_scan); init_completion(&ar->regd_update_completed); init_completion(&ar->thermal.wmi_sync); diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c index b51137193e1d..0bf199bc5b05 100644 --- a/drivers/net/wireless/ath/ath12k/wmi.c +++ b/drivers/net/wireless/ath/ath12k/wmi.c @@ -157,6 +157,8 @@ static const struct ath12k_wmi_tlv_policy ath12k_wmi_tlv_policies[] = { .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_PDEV_SET_CUMAC_COMPLETE] = { + .min_len = sizeof(struct wmi_mlo_send_cumac_complete_event) }, [WMI_TAG_OFFLOAD_BCN_TX_STATUS_EVENT] = { .min_len = sizeof(struct wmi_bcn_tx_status_event) }, [WMI_TAG_VDEV_STOPPED_EVENT] = { @@ -4274,6 +4276,12 @@ ath12k_wmi_copy_resource_config(struct ath12k_base *ab, if (ab->hw_params->reoq_lut_support) wmi_cfg->host_service_flags |= cpu_to_le32(1 << WMI_RSRC_CFG_HOST_SVC_FLAG_REO_QREF_SUPPORT_BIT); + if (test_bit(WMI_TLV_SERVICE_PDEV_SET_CUMAC_DEVICE_CMD_SUPPORT, + ab->wmi_ab.svc_map) && !ath12k_ftm_mode) { + wmi_cfg->host_service_flags |= + cpu_to_le32(1 << + WMI_RSRC_CFG_HOST_SVC_FLAG_CUMAC_CMD_SUPPORT_BIT); + } wmi_cfg->ema_max_vap_cnt = cpu_to_le32(tg_cfg->ema_max_vap_cnt); wmi_cfg->ema_max_profile_period = cpu_to_le32(tg_cfg->ema_max_profile_period); wmi_cfg->flags2 |= cpu_to_le32(WMI_RSRC_CFG_FLAGS2_CALC_NEXT_DTIM_COUNT_SET | @@ -10459,6 +10467,57 @@ ath12k_wmi_rssi_dbm_conversion_params_info_event(struct ath12k_base *ab, rcu_read_unlock(); } +static void ath12k_wmi_cumac_device_id_confirmation_event(struct ath12k_base *ab, + struct sk_buff *skb) +{ + const struct wmi_mlo_send_cumac_complete_event *ev; + struct ath12k *ar = NULL; + struct ath12k_pdev *pdev; + u32 pdev_id, status; + const void **tb; + int i; + + tb = ath12k_wmi_tlv_parse(ab, skb); + if (IS_ERR(tb)) { + ath12k_warn(ab, "failed to parse cumac complete event: %ld\n", + PTR_ERR(tb)); + return; + } + + ev = tb[WMI_TAG_PDEV_SET_CUMAC_COMPLETE]; + if (!ev) { + ath12k_warn(ab, "failed to fetch cumac complete event\n"); + return; + } + + pdev_id = le32_to_cpu(ev->pdev_id); + status = le32_to_cpu(ev->status); + + for (i = 0; i < ab->num_radios; i++) { + pdev = &ab->pdevs[i]; + if (pdev && pdev->pdev_id == pdev_id) { + ar = pdev->ar; + break; + } + } + + if (!ar) { + ath12k_warn(ab, "invalid pdev id in cumac completion: %d\n", + pdev_id); + return; + } + + if (status == WMI_PDEV_SET_CUMAC_DEVICE_ID_SUCCESS) { + ath12k_dbg(ab, ATH12K_DBG_WMI, + "cumac device id confirmation success pdev %d\n", + pdev_id); + complete(&ar->cumac_setup_done); + } else { + ath12k_err(ab, "cumac device id confirmation failure pdev %d status %d\n", + pdev_id, status); + } +} + static void ath12k_wmi_op_rx(struct ath12k_base *ab, struct sk_buff *skb) { struct wmi_cmd_hdr *cmd_hdr; @@ -10599,6 +10658,9 @@ static void ath12k_wmi_op_rx(struct ath12k_base *ab, struct sk_buff *skb) case WMI_PDEV_RSSI_DBM_CONVERSION_PARAMS_INFO_EVENTID: ath12k_wmi_rssi_dbm_conversion_params_info_event(ab, skb); break; + case WMI_PDEV_SET_CUMAC_DEVICE_ID_CONFIRMATION_EVENTID: + ath12k_wmi_cumac_device_id_confirmation_event(ab, skb); + break; case WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID: ath12k_wmi_obss_color_collision_event(ab, skb); break; @@ -11996,6 +12058,34 @@ int ath12k_wmi_send_mlo_link_set_active_cmd(struct ath12k_base *ab, return ret; } +int ath12k_wmi_send_cumac_config(struct ath12k *ar, u32 cumac_device_id) +{ + struct ath12k_wmi_pdev *wmi = ar->wmi; + struct ath12k_base *ab = wmi->wmi_ab->ab; + struct wmi_send_cumac_cmd *cmd; + struct sk_buff *skb; + int ret; + + skb = ath12k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); + if (!skb) + return -ENOMEM; + + cmd = (struct wmi_send_cumac_cmd *)skb->data; + cmd->tlv_header = ath12k_wmi_tlv_cmd_hdr(WMI_TAG_PDEV_SET_CUMAC_DEVICE, + sizeof(*cmd)); + cmd->pdev_id = cpu_to_le32(ar->pdev->pdev_id); + cmd->cumac_device_id = cpu_to_le32(cumac_device_id); + + ret = ath12k_wmi_cmd_send(wmi, skb, WMI_PDEV_SET_CUMAC_DEVICE_CMDID); + if (ret) { + ath12k_warn(ab, + "failed to send WMI_PDEV_SET_CUMAC_DEVICE_CMDID: %d\n", + ret); + dev_kfree_skb(skb); + } + return ret; +} + int ath12k_wmi_alloc(void) { guard(mutex)(&ath12k_wmi_mutex); diff --git a/drivers/net/wireless/ath/ath12k/wmi.h b/drivers/net/wireless/ath/ath12k/wmi.h index 513974b3b4eb..dd14bda5d191 100644 --- a/drivers/net/wireless/ath/ath12k/wmi.h +++ b/drivers/net/wireless/ath/ath12k/wmi.h @@ -384,6 +384,7 @@ enum wmi_tlv_cmd_id { WMI_PDEV_SET_BIOS_SAR_TABLE_CMDID = 0x4044, WMI_PDEV_SET_BIOS_GEO_TABLE_CMDID = 0x4045, WMI_PDEV_SET_BIOS_INTERFACE_CMDID = 0x404A, + WMI_PDEV_SET_CUMAC_DEVICE_CMDID = 0x405D, WMI_VDEV_CREATE_CMDID = WMI_TLV_CMD(WMI_GRP_VDEV), WMI_VDEV_DELETE_CMDID, WMI_VDEV_START_REQUEST_CMDID, @@ -760,6 +761,7 @@ enum wmi_tlv_event_id { WMI_SERVICE_READY_EXT2_EVENTID + 4, WMI_PDEV_RSSI_DBM_CONVERSION_PARAMS_INFO_EVENTID = WMI_PDEV_GET_HALPHY_CAL_STATUS_EVENTID + 5, + WMI_PDEV_SET_CUMAC_DEVICE_ID_CONFIRMATION_EVENTID = 0x4038, WMI_VDEV_START_RESP_EVENTID = WMI_TLV_CMD(WMI_GRP_VDEV), WMI_VDEV_STOPPED_EVENTID, WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID, @@ -2040,6 +2042,8 @@ enum wmi_tlv_tag { WMI_TAG_RSSI_DBM_CONVERSION_TEMP_OFFSET_INFO, WMI_TAG_HALPHY_CTRL_PATH_CMD_FIXED_PARAM = 0x442, WMI_TAG_HALPHY_CTRL_PATH_EVENT_FIXED_PARAM, + WMI_TAG_PDEV_SET_CUMAC_DEVICE = 0x57A, + WMI_TAG_PDEV_SET_CUMAC_COMPLETE = 0x57B, WMI_TAG_MAX }; @@ -2289,6 +2293,8 @@ enum wmi_tlv_service { WMI_TLV_SERVICE_THERM_THROT_5_LEVELS = 429, WMI_TLV_SERVICE_ETH_OFFLOAD = 461, + WMI_TLV_SERVICE_PDEV_SET_CUMAC_DEVICE_CMD_SUPPORT = 520, + WMI_MAX_EXT2_SERVICE, }; @@ -2578,6 +2584,7 @@ struct wmi_init_cmd { #define WMI_RSRC_CFG_HOST_SVC_FLAG_REG_CC_EXT_SUPPORT_BIT 4 #define WMI_RSRC_CFG_HOST_SVC_FLAG_REO_QREF_SUPPORT_BIT 12 +#define WMI_RSRC_CFG_HOST_SVC_FLAG_CUMAC_CMD_SUPPORT_BIT 27 #define WMI_RSRC_CFG_FLAGS2_RX_PEER_METADATA_VERSION GENMASK(5, 4) #define WMI_RSRC_CFG_FLAG1_BSS_CHANNEL_INFO_64 BIT(5) #define WMI_RSRC_CFG_FLAGS2_CALC_NEXT_DTIM_COUNT_SET BIT(9) @@ -6793,6 +6800,22 @@ int ath12k_wmi_send_mlo_link_set_active_cmd(struct ath12k_base *ab, struct wmi_mlo_link_set_active_arg *param); int ath12k_wmi_simulate_incumbent_signal_interference(struct ath12k *ar, u32 chan_bw_interference_bitmap); +struct wmi_send_cumac_cmd { + __le32 tlv_header; + __le32 pdev_id; + __le32 cumac_device_id; +} __packed; + +enum wmi_cumac_device_id_status { + WMI_PDEV_SET_CUMAC_DEVICE_ID_SUCCESS = 0, +}; + +struct wmi_mlo_send_cumac_complete_event { + __le32 pdev_id; + __le32 status; +} __packed; + +int ath12k_wmi_send_cumac_config(struct ath12k *ar, u32 cumac_device_id); int ath12k_wmi_alloc(void); void ath12k_wmi_free(void); -- 2.34.1