From 8c1916beab501ddad82037a97eedafb2fbdb4d40 Mon Sep 17 00:00:00 2001 From: Vinod Kumar Pirla Date: Wed, 28 Aug 2024 01:50:16 -0700 Subject: [PATCH] qcacld-3.0: Add wifi test cmd to restrict CSA Add changes to accept wifi test configuration attr to restrict CSA for P2P GO operating in assisted AP mode in DFS channel. Change-Id: Iab4ac8fbec839e1b66d5061895033b2bf1111ceb CRs-Fixed: 3910664 --- .../interface_mgr/src/wlan_if_mgr_roam.c | 2 +- components/p2p/core/src/wlan_p2p_main.c | 32 +++++++++++++++++-- components/p2p/core/src/wlan_p2p_main.h | 16 ++++++++++ components/p2p/dispatcher/inc/wlan_p2p_api.h | 2 ++ .../p2p/dispatcher/inc/wlan_p2p_ucfg_api.h | 15 +++++++++ components/p2p/dispatcher/src/wlan_p2p_api.c | 4 ++- .../p2p/dispatcher/src/wlan_p2p_ucfg_api.c | 10 +++++- core/hdd/src/wlan_hdd_cfg80211.c | 18 +++++++++++ core/hdd/src/wlan_hdd_hostapd.c | 2 +- core/hdd/src/wlan_hdd_main.c | 2 +- core/mac/src/pe/lim/lim_api.c | 4 +-- core/sap/src/sap_fsm.c | 3 +- 12 files changed, 100 insertions(+), 10 deletions(-) diff --git a/components/cmn_services/interface_mgr/src/wlan_if_mgr_roam.c b/components/cmn_services/interface_mgr/src/wlan_if_mgr_roam.c index 2941d322d5..2e2de0eccc 100644 --- a/components/cmn_services/interface_mgr/src/wlan_if_mgr_roam.c +++ b/components/cmn_services/interface_mgr/src/wlan_if_mgr_roam.c @@ -1063,7 +1063,7 @@ QDF_STATUS if_mgr_validate_candidate(struct wlan_objmgr_vdev *vdev, true, chan_freq, true); wlan_p2p_get_ap_assist_dfs_params(vdev, &is_dfs_owner, &is_valid_ap_assist, - NULL, NULL, NULL); + NULL, NULL, NULL, NULL); if (is_dfs_owner) goto end; diff --git a/components/p2p/core/src/wlan_p2p_main.c b/components/p2p/core/src/wlan_p2p_main.c index 044e8d4df5..87d8601515 100644 --- a/components/p2p/core/src/wlan_p2p_main.c +++ b/components/p2p/core/src/wlan_p2p_main.c @@ -1501,6 +1501,7 @@ QDF_STATUS p2p_extract_ap_assist_dfs_params(struct wlan_objmgr_vdev *vdev, QDF_STATUS p2p_get_ap_assist_dfs_params(struct wlan_objmgr_vdev *vdev, bool *is_dfs_owner, bool *is_valid_ap_assist, + bool *is_usr_restrict_csa, struct qdf_mac_addr *ap_bssid, uint8_t *opclass, uint8_t *chan) { @@ -1519,6 +1520,9 @@ QDF_STATUS p2p_get_ap_assist_dfs_params(struct wlan_objmgr_vdev *vdev, if (is_valid_ap_assist) *is_valid_ap_assist = dfs_info->is_valid_ap_assist; + if (is_usr_restrict_csa) + *is_usr_restrict_csa = dfs_info->is_user_restrict_csa; + if (ap_bssid) qdf_copy_macaddr(ap_bssid, &dfs_info->ap_info[0].ap_bssid); @@ -1531,6 +1535,25 @@ QDF_STATUS p2p_get_ap_assist_dfs_params(struct wlan_objmgr_vdev *vdev, return QDF_STATUS_SUCCESS; } +QDF_STATUS +p2p_force_restrict_dfs_go_csa(struct wlan_objmgr_vdev *vdev, bool val) +{ + struct p2p_vdev_priv_obj *p2p_vdev_obj; + + if (wlan_vdev_mlme_get_opmode(vdev) != QDF_P2P_GO_MODE) + return QDF_STATUS_E_INVAL; + + p2p_vdev_obj = + wlan_objmgr_vdev_get_comp_private_obj(vdev, WLAN_UMAC_COMP_P2P); + if (!p2p_vdev_obj) + return QDF_STATUS_E_INVAL; + + p2p_vdev_obj->ap_assist_dfs.is_user_restrict_csa = val; + p2p_debug("P2P force restrict %d", val); + + return QDF_STATUS_SUCCESS; +} + bool p2p_check_oui_and_force_1x1(uint8_t *assoc_ie, uint32_t assoc_ie_len) { const uint8_t *pos; @@ -2082,13 +2105,15 @@ QDF_STATUS p2p_check_ap_assist_dfs_group_go(struct wlan_objmgr_vdev *vdev) struct wlan_objmgr_pdev *pdev = wlan_vdev_get_pdev(vdev); struct wlan_objmgr_psoc *psoc; bool is_dfs_owner = false, is_valid_ap_assist = false; + bool is_usr_restrict_csa = false; uint8_t chan = 0; if (!pdev) return QDF_STATUS_E_INVAL; p2p_get_ap_assist_dfs_params(vdev, &is_dfs_owner, &is_valid_ap_assist, - &ap_bssid, NULL, &chan); + &is_usr_restrict_csa, &ap_bssid, + NULL, &chan); if (is_dfs_owner) return QDF_STATUS_SUCCESS; @@ -2096,6 +2121,9 @@ QDF_STATUS p2p_check_ap_assist_dfs_group_go(struct wlan_objmgr_vdev *vdev) if (!is_valid_ap_assist) return QDF_STATUS_E_INVAL; + if (is_usr_restrict_csa) + return QDF_STATUS_SUCCESS; + if (wlan_vdev_mlme_is_init_state(vdev) == QDF_STATUS_SUCCESS) { /* Ignore opclass check as the valid ap assist flag is true */ cur_freq = wlan_reg_legacy_chan_to_freq(pdev, chan); @@ -2172,7 +2200,7 @@ QDF_STATUS p2p_check_ap_assist_dfs_group_cli(struct wlan_objmgr_vdev *vdev) } p2p_get_ap_assist_dfs_params(vdev, &is_dfs_owner, &is_valid_ap_assist, - ¶ms.bssid, NULL, NULL); + NULL, ¶ms.bssid, NULL, NULL); if (is_dfs_owner) return QDF_STATUS_SUCCESS; diff --git a/components/p2p/core/src/wlan_p2p_main.h b/components/p2p/core/src/wlan_p2p_main.h index c41261b87e..4a8a1de783 100644 --- a/components/p2p/core/src/wlan_p2p_main.h +++ b/components/p2p/core/src/wlan_p2p_main.h @@ -384,6 +384,7 @@ struct p2p_ap_assist_dfs_ap_info { * to DFS owner capability and AP assisted params * @is_dfs_owner: Is DFS owner * @is_client_csa: Can client send CSA request + * @is_user_restrict_csa: User restrict CSA on P2P GO * @extn_cap_attr_found: Is extended cap attr found * @wlan_ap_info_attr_found: Is WLAN AP info attr found * @is_valid_ap_assist: Is assisted AP params valid @@ -393,6 +394,7 @@ struct p2p_ap_assist_dfs_ap_info { struct p2p_ap_assist_dfs_group_info { bool is_dfs_owner; bool is_client_csa; + bool is_user_restrict_csa; bool extn_cap_attr_found; bool wlan_ap_info_attr_found; bool is_valid_ap_assist; @@ -787,6 +789,7 @@ QDF_STATUS p2p_extract_ap_assist_dfs_params(struct wlan_objmgr_vdev *vdev, * @vdev: VDEV object manager pointer of P2P entity * @is_dfs_owner: Pointer to get DFS owner capability in extended cap of P2P2 IE * @is_valid_ap_assist: Is assisted AP params valid + * @is_usr_restrict_csa: Is user restricted CSA * @ap_bssid: Pointer to get AP BSSID of assisted AP in DFS oper extracted from * wlan ap info attribute * @opclass: Operating class of the AP pointed in @ap_bssid @@ -797,6 +800,7 @@ QDF_STATUS p2p_extract_ap_assist_dfs_params(struct wlan_objmgr_vdev *vdev, QDF_STATUS p2p_get_ap_assist_dfs_params(struct wlan_objmgr_vdev *vdev, bool *is_dfs_owner, bool *is_valid_ap_assist, + bool *is_usr_restrict_csa, struct qdf_mac_addr *ap_bssid, uint8_t *opclass, uint8_t *chan); @@ -948,4 +952,16 @@ p2p_set_rand_mac_for_p2p_dev(struct wlan_objmgr_psoc *soc, uint32_t vdev_id, uint32_t freq, uint64_t rnd_cookie, uint32_t duration); +/** + * p2p_force_restrict_dfs_go_csa() - API to handle user restricted CSA via + * test configuration. + * @vdev: VDEV object manager. + * @val: User config value. + * + * API to configure restriction of CSA from user for assisted P2P group. + * + * Return: QDF_STATUS + */ +QDF_STATUS +p2p_force_restrict_dfs_go_csa(struct wlan_objmgr_vdev *vdev, bool val); #endif /* _WLAN_P2P_MAIN_H_ */ diff --git a/components/p2p/dispatcher/inc/wlan_p2p_api.h b/components/p2p/dispatcher/inc/wlan_p2p_api.h index f94e24869f..44fe1e63fa 100644 --- a/components/p2p/dispatcher/inc/wlan_p2p_api.h +++ b/components/p2p/dispatcher/inc/wlan_p2p_api.h @@ -185,6 +185,7 @@ QDF_STATUS wlan_p2p_validate_ap_assist_dfs_group(struct wlan_objmgr_vdev *vdev); * @vdev: VDEV object manager * @is_dfs_owner: Pointer to get DFS owner cap bit * @is_valid_ap_assist: Is valid AP assist params + * @is_usr_restrict_csa: Is user restricted CSA * @ap_bssid: BSSID of the assisted AP * @opclass: Operating class of the assisted AP * @chan: Channel number of the assisted AP @@ -194,6 +195,7 @@ QDF_STATUS wlan_p2p_validate_ap_assist_dfs_group(struct wlan_objmgr_vdev *vdev); QDF_STATUS wlan_p2p_get_ap_assist_dfs_params(struct wlan_objmgr_vdev *vdev, bool *is_dfs_owner, bool *is_valid_ap_assist, + bool *is_usr_restrict_csa, struct qdf_mac_addr *ap_bssid, uint8_t *opclass, uint8_t *chan); diff --git a/components/p2p/dispatcher/inc/wlan_p2p_ucfg_api.h b/components/p2p/dispatcher/inc/wlan_p2p_ucfg_api.h index 9c9223820a..7e49bb2e46 100644 --- a/components/p2p/dispatcher/inc/wlan_p2p_ucfg_api.h +++ b/components/p2p/dispatcher/inc/wlan_p2p_ucfg_api.h @@ -610,6 +610,7 @@ ucfg_p2p_extract_ap_assist_dfs_params(struct wlan_objmgr_vdev *vdev, * @vdev: VDEV object manager * @is_dfs_owner: Pointer to get the DFS owner cap * @is_valid_ap_assist: Is valid AP assist params + * @is_usr_restrict_csa: Is CSA restricted by user * @ap_bssid: BSSID of the assisted AP * @opclass: Operating class of the assisted AP * @chan: Channel number of assisted AP @@ -619,6 +620,7 @@ ucfg_p2p_extract_ap_assist_dfs_params(struct wlan_objmgr_vdev *vdev, QDF_STATUS ucfg_p2p_get_ap_assist_dfs_params(struct wlan_objmgr_vdev *vdev, bool *is_dfs_owner, bool *is_valid_ap_assist, + bool *is_usr_restrict_csa, struct qdf_mac_addr *ap_bssid, uint8_t *opclass, uint8_t *chan); @@ -698,4 +700,17 @@ void ucfg_p2p_psoc_priv_set_sta_vdev_id(struct wlan_objmgr_psoc *psoc, * Return: vdev_id */ uint8_t ucfg_p2p_psoc_priv_get_sta_vdev_id(struct wlan_objmgr_psoc *psoc); + +/** + * ucfg_p2p_force_restrict_dfs_go_csa() - User restricted CSA for assisted P2P + * group operation + * @vdev: VDEV object manager + * @val: Value from user. + * + * Test configuration to restrict CSA from happening via assisted P2P group + * + * Return: QDF_STATUS + */ +QDF_STATUS +ucfg_p2p_force_restrict_dfs_go_csa(struct wlan_objmgr_vdev *vdev, bool val); #endif /* _WLAN_P2P_UCFG_API_H_ */ diff --git a/components/p2p/dispatcher/src/wlan_p2p_api.c b/components/p2p/dispatcher/src/wlan_p2p_api.c index c934d22a41..ae00061e37 100644 --- a/components/p2p/dispatcher/src/wlan_p2p_api.c +++ b/components/p2p/dispatcher/src/wlan_p2p_api.c @@ -181,11 +181,13 @@ bool wlan_p2p_fw_support_ap_assist_dfs_group(struct wlan_objmgr_psoc *psoc) QDF_STATUS wlan_p2p_get_ap_assist_dfs_params(struct wlan_objmgr_vdev *vdev, bool *is_dfs_owner, bool *is_valid_ap_assist, + bool *is_usr_restrict_csa, struct qdf_mac_addr *ap_bssid, uint8_t *opclass, uint8_t *chan) { return p2p_get_ap_assist_dfs_params(vdev, is_dfs_owner, - is_valid_ap_assist, ap_bssid, + is_valid_ap_assist, + is_usr_restrict_csa, ap_bssid, opclass, chan); } diff --git a/components/p2p/dispatcher/src/wlan_p2p_ucfg_api.c b/components/p2p/dispatcher/src/wlan_p2p_ucfg_api.c index a72b5750a6..02f768b5c1 100644 --- a/components/p2p/dispatcher/src/wlan_p2p_ucfg_api.c +++ b/components/p2p/dispatcher/src/wlan_p2p_ucfg_api.c @@ -808,11 +808,13 @@ ucfg_p2p_extract_ap_assist_dfs_params(struct wlan_objmgr_vdev *vdev, QDF_STATUS ucfg_p2p_get_ap_assist_dfs_params(struct wlan_objmgr_vdev *vdev, bool *is_dfs_owner, bool *is_valid_ap_assist, + bool *is_usr_restrict_csa, struct qdf_mac_addr *ap_bssid, uint8_t *opclass, uint8_t *chan) { return p2p_get_ap_assist_dfs_params(vdev, is_dfs_owner, - is_valid_ap_assist, ap_bssid, + is_valid_ap_assist, + is_usr_restrict_csa, ap_bssid, opclass, chan); } @@ -856,3 +858,9 @@ uint8_t ucfg_p2p_psoc_priv_get_sta_vdev_id(struct wlan_objmgr_psoc *psoc) { return p2p_psoc_priv_get_sta_vdev_id(psoc); } + +QDF_STATUS +ucfg_p2p_force_restrict_dfs_go_csa(struct wlan_objmgr_vdev *vdev, bool val) +{ + return p2p_force_restrict_dfs_go_csa(vdev, val); +} diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 3fcc7e38b4..5037e026aa 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -9026,6 +9026,8 @@ wlan_hdd_wifi_test_config_policy[ .type = NLA_U8}, [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_EHT_SCS_TRAFFIC_SUPPORT] = { .type = NLA_U8}, + [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_DISABLE_CHAN_SWITCH_INITIATION] = { + .type = NLA_U8}, }; /** @@ -14968,6 +14970,7 @@ __wlan_hdd_cfg80211_set_wifi_test_config(struct wiphy *wiphy, struct hdd_station_ctx *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info); uint8_t op_mode; + struct wlan_objmgr_vdev *vdev; hdd_enter_dev(dev); @@ -16116,6 +16119,21 @@ __wlan_hdd_cfg80211_set_wifi_test_config(struct wiphy *wiphy, hdd_err("Failed to set SCS traffic desc support"); } + cmd_id = QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_DISABLE_CHAN_SWITCH_INITIATION; + if (tb[cmd_id] && adapter->device_mode == QDF_P2P_GO_MODE) { + cfg_val = nla_get_u8(tb[cmd_id]); + hdd_debug("Restrict CSA params %d", cfg_val); + vdev = hdd_objmgr_get_vdev_by_user(link_info, WLAN_OSIF_ID); + if (vdev) { + status = ucfg_p2p_force_restrict_dfs_go_csa(vdev, + cfg_val); + hdd_objmgr_put_vdev_by_user(vdev, WLAN_OSIF_ID); + ret_val = qdf_status_to_os_return(status); + } else { + ret_val = qdf_status_to_os_return(QDF_STATUS_E_INVAL); + } + } + if (update_sme_cfg) sme_update_config(mac_handle, sme_config); diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index 970d0f3f32..cb2fc0a3d0 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -7927,7 +7927,7 @@ hdd_check_ap_assist_dfs_group_start_req(struct wlan_hdd_link_info *link_info, } status = ucfg_p2p_get_ap_assist_dfs_params(vdev, &is_go_dfs_owner, - &is_valid_ap_assist, + &is_valid_ap_assist, NULL, &ap_bssid, NULL, NULL); if (is_go_dfs_owner || !is_valid_ap_assist || !is_fw_cap) { diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index c8d19e078e..dc5ad22bdd 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -910,7 +910,7 @@ int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, vdev_freq = wlan_get_operation_chan_freq(vdev); ucfg_p2p_get_ap_assist_dfs_params(vdev, &is_go_dfs_owner, - &is_valid_ap_assist, + &is_valid_ap_assist, NULL, NULL, &opclass, &ap_chan); if (!wlan_reg_is_6ghz_op_class(hdd_ctx->pdev, opclass)) ap_freq = wlan_reg_legacy_chan_to_freq(hdd_ctx->pdev, diff --git a/core/mac/src/pe/lim/lim_api.c b/core/mac/src/pe/lim/lim_api.c index d54d77454e..1676cfdb0e 100644 --- a/core/mac/src/pe/lim/lim_api.c +++ b/core/mac/src/pe/lim/lim_api.c @@ -732,8 +732,8 @@ void lim_fill_dfs_p2p_group_params(struct pe_session *pe_session) } wlan_p2p_get_ap_assist_dfs_params(pe_session->vdev, &is_dfs_owner, - &is_valid_ap_assist, &ap_bssid, - NULL, NULL); + &is_valid_ap_assist, NULL, + &ap_bssid, NULL, NULL); if (is_dfs_owner || !is_valid_ap_assist) return; diff --git a/core/sap/src/sap_fsm.c b/core/sap/src/sap_fsm.c index e1dde2da97..0f0cec5dfd 100644 --- a/core/sap/src/sap_fsm.c +++ b/core/sap/src/sap_fsm.c @@ -3983,7 +3983,8 @@ static QDF_STATUS sap_fsm_state_starting(struct sap_context *sap_ctx, wlan_p2p_get_ap_assist_dfs_params(sap_ctx->vdev, &is_dfs_owner, &is_valid_ap_assist, - NULL, NULL, NULL); + NULL, NULL, + NULL, NULL); if (!is_dfs_owner && is_valid_ap_assist) is_dfs = false; }