diff --git a/components/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h b/components/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h index 97f267dd07e66..3abe534273ff0 100644 --- a/components/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h +++ b/components/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -867,7 +867,7 @@ enum policy_mgr_three_connection_mode * the current connections list * @psoc: PSOC object information * @vdev_id: vdev id - * + * @mode: Operating mode * * This function adds the new connection to the current * connections list @@ -875,7 +875,8 @@ enum policy_mgr_three_connection_mode * Return: QDF_STATUS */ QDF_STATUS policy_mgr_incr_connection_count(struct wlan_objmgr_psoc *psoc, - uint32_t vdev_id); + uint32_t vdev_id, + enum QDF_OPMODE mode); /** * policy_mgr_update_connection_info() - updates the existing diff --git a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c index e9cb42a04db7d..6dc7a4035755f 100644 --- a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c +++ b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -1668,7 +1668,7 @@ void policy_mgr_incr_active_session(struct wlan_objmgr_psoc *psoc, policy_mgr_debug("No.# of active sessions for mode %d = %d", mode, pm_ctx->no_of_active_sessions[mode]); - policy_mgr_incr_connection_count(psoc, session_id); + policy_mgr_incr_connection_count(psoc, session_id, mode); if ((policy_mgr_mode_specific_connection_count( psoc, PM_STA_MODE, NULL) > 0) && (mode != QDF_STA_MODE)) { qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); @@ -1805,8 +1805,9 @@ QDF_STATUS policy_mgr_decr_active_session(struct wlan_objmgr_psoc *psoc, return qdf_status; } -QDF_STATUS policy_mgr_incr_connection_count( - struct wlan_objmgr_psoc *psoc, uint32_t vdev_id) +QDF_STATUS policy_mgr_incr_connection_count(struct wlan_objmgr_psoc *psoc, + uint32_t vdev_id, + enum QDF_OPMODE op_mode) { QDF_STATUS status = QDF_STATUS_E_FAILURE; uint32_t conn_index; @@ -1832,7 +1833,7 @@ QDF_STATUS policy_mgr_incr_connection_count( return status; } - if (vdev_id == NAN_PSEUDO_VDEV_ID) { + if (op_mode == QDF_NAN_DISC_MODE) { status = wlan_nan_get_connection_info(psoc, &conn_table_entry); if (QDF_IS_STATUS_ERROR(status)) { policy_mgr_err("Can't get NAN Connection info"); diff --git a/components/nan/core/inc/nan_public_structs.h b/components/nan/core/inc/nan_public_structs.h index 144f9cae22c09..ab016b626f1eb 100644 --- a/components/nan/core/inc/nan_public_structs.h +++ b/components/nan/core/inc/nan_public_structs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -515,6 +515,7 @@ enum nan_event_id_types { * @evt_type: NAN Discovery event type * @is_nan_enable_success: Status from the NAN Enable Response event * @mac_id: MAC ID associated with NAN Discovery from NAN Enable Response event + * @vdev_id: vdev id of the interface created for NAN discovery * @buf_len: Event buffer length * @buf: Event buffer starts here */ @@ -523,6 +524,7 @@ struct nan_event_params { enum nan_event_id_types evt_type; bool is_nan_enable_success; uint8_t mac_id; + uint8_t vdev_id; uint32_t buf_len; /* Variable length, do not add anything after this */ uint8_t buf[]; diff --git a/components/nan/core/src/nan_main.c b/components/nan/core/src/nan_main.c index 07b14d802d1b0..1c33348b907ae 100644 --- a/components/nan/core/src/nan_main.c +++ b/components/nan/core/src/nan_main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -813,6 +813,7 @@ static QDF_STATUS nan_handle_enable_rsp(struct nan_event_params *nan_event) struct wlan_objmgr_psoc *psoc; QDF_STATUS status; void (*call_back)(void *cookie); + uint8_t vdev_id; psoc = nan_event->psoc; psoc_nan_obj = nan_get_psoc_priv_obj(psoc); @@ -822,17 +823,20 @@ static QDF_STATUS nan_handle_enable_rsp(struct nan_event_params *nan_event) } if (nan_event->is_nan_enable_success) { - status = nan_set_discovery_state(nan_event->psoc, - NAN_DISC_ENABLED); + status = nan_set_discovery_state(psoc, NAN_DISC_ENABLED); if (QDF_IS_STATUS_SUCCESS(status)) { psoc_nan_obj->nan_disc_mac_id = nan_event->mac_id; - policy_mgr_update_nan_vdev_mac_info(nan_event->psoc, - NAN_PSEUDO_VDEV_ID, - nan_event->mac_id); - + vdev_id = nan_event->vdev_id; + if (!ucfg_nan_is_vdev_creation_allowed(psoc)) { + vdev_id = NAN_PSEUDO_VDEV_ID; + } else if (vdev_id >= WLAN_MAX_VDEVS) { + nan_err("Invalid NAN vdev_id: %u", vdev_id); + goto fail; + } + nan_debug("NAN vdev_id: %u", vdev_id); policy_mgr_incr_active_session(psoc, QDF_NAN_DISC_MODE, - NAN_PSEUDO_VDEV_ID); + vdev_id); policy_mgr_nan_sap_post_enable_conc_check(psoc); } else { @@ -844,14 +848,19 @@ static QDF_STATUS nan_handle_enable_rsp(struct nan_event_params *nan_event) psoc_nan_obj->nan_social_ch_5g_freq = 0; policy_mgr_check_n_start_opportunistic_timer(psoc); } + goto done; } else { + nan_info("NAN enable has failed"); /* NAN Enable has failed, restore changes */ - psoc_nan_obj->nan_social_ch_2g_freq = 0; - psoc_nan_obj->nan_social_ch_5g_freq = 0; - nan_set_discovery_state(nan_event->psoc, NAN_DISC_DISABLED); - policy_mgr_check_n_start_opportunistic_timer(psoc); + goto fail; } +fail: + psoc_nan_obj->nan_social_ch_2g_freq = 0; + psoc_nan_obj->nan_social_ch_5g_freq = 0; + nan_set_discovery_state(psoc, NAN_DISC_DISABLED); + policy_mgr_check_n_start_opportunistic_timer(psoc); +done: call_back = psoc_nan_obj->cb_obj.ucfg_nan_request_process_cb; if (call_back) call_back(psoc_nan_obj->request_context); @@ -864,6 +873,7 @@ static QDF_STATUS nan_handle_disable_ind(struct nan_event_params *nan_event) struct nan_psoc_priv_obj *psoc_nan_obj; struct wlan_objmgr_psoc *psoc; QDF_STATUS status; + uint8_t vdev_id; psoc = nan_event->psoc; psoc_nan_obj = nan_get_psoc_priv_obj(psoc); @@ -872,18 +882,18 @@ static QDF_STATUS nan_handle_disable_ind(struct nan_event_params *nan_event) return QDF_STATUS_E_NULL_VALUE; } - status = nan_set_discovery_state(nan_event->psoc, - NAN_DISC_DISABLED); + status = nan_set_discovery_state(psoc, NAN_DISC_DISABLED); if (QDF_IS_STATUS_SUCCESS(status)) { void (*call_back)(void *cookie); call_back = psoc_nan_obj->cb_obj.ucfg_nan_request_process_cb; + vdev_id = policy_mgr_mode_specific_vdev_id(psoc, + PM_NAN_DISC_MODE); + nan_debug("NAN vdev_id: %u", vdev_id); policy_mgr_decr_session_set_pcl(psoc, QDF_NAN_DISC_MODE, - NAN_PSEUDO_VDEV_ID); - if (psoc_nan_obj->is_explicit_disable) { - if (call_back) - call_back(psoc_nan_obj->request_context); - } + vdev_id); + if (psoc_nan_obj->is_explicit_disable && call_back) + call_back(psoc_nan_obj->request_context); policy_mgr_nan_sap_post_disable_conc_check(psoc); } else {