diff --git a/target_if/core/inc/target_if.h b/target_if/core/inc/target_if.h index 298fad562cab..12c723ad2f03 100644 --- a/target_if/core/inc/target_if.h +++ b/target_if/core/inc/target_if.h @@ -2404,4 +2404,34 @@ static inline uint32_t target_psoc_get_chan_width_switch_num_peers( return psoc_info->info.service_ext2_param.chwidth_num_peer_caps; } + +/** + * target_if_is_scan_radio_supported() - API to check scan radio + * support for the given radio + * @pdev: pointer to pdev + * @is_scan_radio_supported: pointer to scan radio support flag + * + * API to check scan radio support for the given radio + * + * Return: QDF_STATUS + */ +QDF_STATUS +target_pdev_is_scan_radio_supported(struct wlan_objmgr_pdev *pdev, + bool *is_scan_radio_supported); + +/** + * target_pdev_scan_radio_is_dfs_enabled() - API to check + * whether DFS needs to be enabled/disabled for scan radio. + * @pdev: pointer to pdev + * @is_dfs_en: Pointer to DFS enable flag + * + * API to check whether DFS needs to be enabled/disabled for + * scan radio. This API should be used only for a scan radio + * pdev. + * + * Return: QDF_STATUS + */ +QDF_STATUS +target_pdev_scan_radio_is_dfs_enabled(struct wlan_objmgr_pdev *pdev, + bool *is_dfs_en); #endif diff --git a/target_if/core/src/target_if_main.c b/target_if/core/src/target_if_main.c index e14c0657cafb..44878de826b1 100644 --- a/target_if/core/src/target_if_main.c +++ b/target_if/core/src/target_if_main.c @@ -679,3 +679,141 @@ bool target_is_tgt_type_qcn9000(uint32_t target_type) { return target_type == TARGET_TYPE_QCN9000; } + +QDF_STATUS +target_pdev_is_scan_radio_supported(struct wlan_objmgr_pdev *pdev, + bool *is_scan_radio_supported) +{ + struct wlan_objmgr_psoc *psoc; + struct wlan_psoc_host_scan_radio_caps *scan_radio_caps; + uint8_t cap_idx; + uint32_t num_scan_radio_caps; + int32_t phy_id; + struct target_psoc_info *tgt_psoc_info; + struct target_pdev_info *tgt_pdev; + + if (!is_scan_radio_supported) { + target_if_err("input argument is null"); + return QDF_STATUS_E_INVAL; + } + *is_scan_radio_supported = false; + + if (!pdev) { + target_if_err("pdev is null"); + return QDF_STATUS_E_INVAL; + } + + psoc = wlan_pdev_get_psoc(pdev); + if (!psoc) { + target_if_err("psoc is null"); + return QDF_STATUS_E_INVAL; + } + + tgt_psoc_info = wlan_psoc_get_tgt_if_handle(psoc); + if (!tgt_psoc_info) { + target_if_err("target_psoc_info is null"); + return QDF_STATUS_E_INVAL; + } + + num_scan_radio_caps = + target_psoc_get_num_scan_radio_caps(tgt_psoc_info); + if (!num_scan_radio_caps) + return QDF_STATUS_SUCCESS; + + scan_radio_caps = target_psoc_get_scan_radio_caps(tgt_psoc_info); + if (!scan_radio_caps) { + target_if_err("scan radio capabilities is null"); + return QDF_STATUS_E_INVAL; + } + + tgt_pdev = (struct target_pdev_info *)wlan_pdev_get_tgt_if_handle(pdev); + if (!tgt_pdev) { + target_if_err("target_pdev_info is null"); + return QDF_STATUS_E_INVAL; + } + + phy_id = target_pdev_get_phy_idx(tgt_pdev); + if (phy_id < 0) { + target_if_err("phy_id is invalid"); + return QDF_STATUS_E_INVAL; + } + + for (cap_idx = 0; cap_idx < num_scan_radio_caps; cap_idx++) + if (scan_radio_caps[cap_idx].phy_id == phy_id) + *is_scan_radio_supported = + scan_radio_caps[cap_idx].scan_radio_supported; + + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS +target_pdev_scan_radio_is_dfs_enabled(struct wlan_objmgr_pdev *pdev, + bool *is_dfs_en) +{ + struct wlan_objmgr_psoc *psoc; + struct wlan_psoc_host_scan_radio_caps *scan_radio_caps; + uint8_t cap_idx; + uint32_t num_scan_radio_caps, pdev_id; + int32_t phy_id; + struct target_psoc_info *tgt_psoc_info; + struct target_pdev_info *tgt_pdev; + + if (!is_dfs_en) { + target_if_err("input argument is null"); + return QDF_STATUS_E_INVAL; + } + *is_dfs_en = true; + + if (!pdev) { + target_if_err("pdev is null"); + return QDF_STATUS_E_INVAL; + } + + psoc = wlan_pdev_get_psoc(pdev); + if (!psoc) { + target_if_err("psoc is null"); + return QDF_STATUS_E_INVAL; + } + + tgt_psoc_info = wlan_psoc_get_tgt_if_handle(psoc); + if (!tgt_psoc_info) { + target_if_err("target_psoc_info is null"); + return QDF_STATUS_E_INVAL; + } + + num_scan_radio_caps = + target_psoc_get_num_scan_radio_caps(tgt_psoc_info); + if (!num_scan_radio_caps) { + target_if_err("scan radio not supported for psoc"); + return QDF_STATUS_E_INVAL; + } + + scan_radio_caps = target_psoc_get_scan_radio_caps(tgt_psoc_info); + if (!scan_radio_caps) { + target_if_err("scan radio capabilities is null"); + return QDF_STATUS_E_INVAL; + } + + tgt_pdev = (struct target_pdev_info *)wlan_pdev_get_tgt_if_handle(pdev); + if (!tgt_pdev) { + target_if_err("target_pdev_info is null"); + return QDF_STATUS_E_INVAL; + } + + pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); + phy_id = target_pdev_get_phy_idx(tgt_pdev); + if (phy_id < 0) { + target_if_err("phy_id is invalid"); + return QDF_STATUS_E_INVAL; + } + + for (cap_idx = 0; cap_idx < num_scan_radio_caps; cap_idx++) + if (scan_radio_caps[cap_idx].phy_id == phy_id) { + *is_dfs_en = scan_radio_caps[cap_idx].dfs_en; + return QDF_STATUS_SUCCESS; + } + + target_if_err("No scan radio cap found in pdev %d", pdev_id); + + return QDF_STATUS_E_INVAL; +}