From 4a32ec52202040832424e78f144c1069d7320b0a Mon Sep 17 00:00:00 2001 From: Srinivas Dasari Date: Fri, 6 Dec 2019 20:26:30 +0530 Subject: [PATCH] qcacld-3.0: Allow/Disallow NDP creation in different concurrencies Currently in case of STA+NDI+NDI concurrency, the below scenario can occur, 1) If NDI(NDP) + NDI(NDP) exists and sta tries to connect, then all NDPs on 1st NDI is tear down. 2) If STA+NDI(NDPs) exist and then another NDI tries to establish the NDP, then it is allowed in the current driver. Fix is to reject the 2nd NDI(NDP) if STA+NDI(NDPs) concurrency already exist. Change-Id: Iadf6c9e10b9cdd59ca7beaace578a52b5e5dbb0f CRs-Fixed: 2568552 --- components/nan/dispatcher/inc/nan_ucfg_api.h | 19 ++++++ components/nan/dispatcher/src/nan_ucfg_api.c | 66 ++++++++++++++++++++ os_if/nan/src/os_if_nan.c | 12 ++++ 3 files changed, 97 insertions(+) diff --git a/components/nan/dispatcher/inc/nan_ucfg_api.h b/components/nan/dispatcher/inc/nan_ucfg_api.h index c40e647a09..de33c6a4e3 100644 --- a/components/nan/dispatcher/inc/nan_ucfg_api.h +++ b/components/nan/dispatcher/inc/nan_ucfg_api.h @@ -347,6 +347,19 @@ QDF_STATUS ucfg_ndi_remove_entry_from_policy_mgr(struct wlan_objmgr_vdev *vdev); * Return: True if NAN discovery enable/disable is in progress, false otherwise */ bool ucfg_nan_is_enable_disable_in_progress(struct wlan_objmgr_psoc *psoc); + +/** + * ucfg_nan_is_sta_ndp_concurrency_allowed() - Indicates if NDP is allowed + * @psoc: pointer to psoc object + * @vdev: pointer to vdev object + * + * If STA+NDI(NDPs) exist and another NDI tries to establish + * NDP, then reject the second NDI(NDP). + * + * Return: true if allowed, false otherwise + */ +bool ucfg_nan_is_sta_ndp_concurrency_allowed(struct wlan_objmgr_psoc *psoc, + struct wlan_objmgr_vdev *vdev); #else /* WLAN_FEATURE_NAN */ static inline @@ -392,5 +405,11 @@ bool ucfg_nan_is_enable_disable_in_progress(struct wlan_objmgr_psoc *psoc) return false; } +static inline +bool ucfg_nan_is_sta_ndp_concurrency_allowed(struct wlan_objmgr_psoc *psoc, + struct wlan_objmgr_vdev *vdev) +{ + return false; +} #endif /* WLAN_FEATURE_NAN */ #endif /* _NAN_UCFG_API_H_ */ diff --git a/components/nan/dispatcher/src/nan_ucfg_api.c b/components/nan/dispatcher/src/nan_ucfg_api.c index f3b3b606d7..8d7d042717 100644 --- a/components/nan/dispatcher/src/nan_ucfg_api.c +++ b/components/nan/dispatcher/src/nan_ucfg_api.c @@ -966,3 +966,69 @@ bool ucfg_nan_is_enable_disable_in_progress(struct wlan_objmgr_psoc *psoc) return false; } + +#ifdef NDP_SAP_CONCURRENCY_ENABLE +/** + * is_sap_ndp_concurrency_allowed() - Is SAP+NDP allowed + * + * Return: True if the NDP_SAP_CONCURRENCY_ENABLE feature define + * is enabled, false otherwise. + */ +static inline bool is_sap_ndp_concurrency_allowed(void) +{ + return true; +} +#else +static inline bool is_sap_ndp_concurrency_allowed(void) +{ + return false; +} +#endif + +bool ucfg_nan_is_sta_ndp_concurrency_allowed(struct wlan_objmgr_psoc *psoc, + struct wlan_objmgr_vdev *vdev) +{ + uint8_t vdev_id_list[MAX_NUMBER_OF_CONC_CONNECTIONS]; + uint32_t freq_list[MAX_NUMBER_OF_CONC_CONNECTIONS]; + uint32_t ndi_cnt, sta_cnt, id; + + sta_cnt = policy_mgr_mode_specific_connection_count(psoc, + PM_STA_MODE, NULL); + /* Allow if STA is not in connected state */ + if (!sta_cnt) + return true; + + /* Reject if STA+STA is present */ + if (sta_cnt > 1) { + nan_err("STA+STA+NDP concurrency is not allowed"); + return false; + } + + /* + * SAP+NDP concurrency is already validated in hdd_is_ndp_allowed(). + * If SAP+NDP concurrency is enabled, return true from here to avoid + * failure. + */ + if (is_sap_ndp_concurrency_allowed()) + return true; + + ndi_cnt = policy_mgr_get_mode_specific_conn_info(psoc, + freq_list, + vdev_id_list, + PM_NDI_MODE); + + /* Allow if no other NDP peers are present on the NDIs */ + if (!ndi_cnt) + return true; + + /* + * Allow NDP creation if the current NDP request is on + * the NDI which already has an NDP by checking the vdev id of + * the NDIs + */ + for (id = 0; id < ndi_cnt; id++) + if (wlan_vdev_get_id(vdev) == vdev_id_list[id]) + return true; + + return false; +} diff --git a/os_if/nan/src/os_if_nan.c b/os_if/nan/src/os_if_nan.c index a686d69d5b..65051f192c 100644 --- a/os_if/nan/src/os_if_nan.c +++ b/os_if/nan/src/os_if_nan.c @@ -624,6 +624,12 @@ static int __os_if_nan_process_ndp_initiator_req(struct wlan_objmgr_psoc *psoc, goto initiator_req_failed; } + if (!ucfg_nan_is_sta_ndp_concurrency_allowed(psoc, nan_vdev)) { + osif_err("NDP creation not allowed"); + ret = -EOPNOTSUPP; + goto initiator_req_failed; + } + if (!tb[QCA_WLAN_VENDOR_ATTR_NDP_TRANSACTION_ID]) { osif_err("Transaction ID is unavailable"); ret = -EINVAL; @@ -790,6 +796,12 @@ static int __os_if_nan_process_ndp_responder_req(struct wlan_objmgr_psoc *psoc, ret = -ENODEV; goto responder_req_failed; } + + if (!ucfg_nan_is_sta_ndp_concurrency_allowed(psoc, nan_vdev)) { + osif_err("NDP creation not allowed"); + ret = -EOPNOTSUPP; + goto responder_req_failed; + } } else { /* * If the data indication is rejected, the userspace