From 83f49ec2d0db45d417a0c76dcd021f0941775687 Mon Sep 17 00:00:00 2001 From: Vijay Patil Date: Mon, 1 Nov 2021 17:21:56 +0530 Subject: [PATCH] qcacld-3.0: Don't proceed with NDP peer handling if NDI is not UP Firmware might send NDP peer indication/NDP responder response while NDI deletion is in progress. Currently, NDP peer entry gets added though vdev is moved to DOWN state and cleanup is in progress. This leads to stale peer entry on that NDI vdev and doesn't allow vdev delete when IFF_DOWN comes, as a peer is present. Check the vdev state before creating peer for NDP and skip peer creation if NDI vdev is not in UP state(which indicates that the vdev down is happening). Also, don't process the NDP confirm if NDP peer is not created. Change-Id: I73e79cc33b1a294e3f4a4a6e2f371033862c5709 CRs-Fixed: 3061756 --- components/mlme/core/inc/wlan_mlme_main.h | 11 ++++++++++- components/mlme/core/src/wlan_mlme_main.c | 19 +++++++++++++++++++ components/nan/core/src/nan_main.c | 11 +++++++++++ core/mac/src/pe/nan/nan_datapath.c | 6 ++++++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/components/mlme/core/inc/wlan_mlme_main.h b/components/mlme/core/inc/wlan_mlme_main.h index a5f29a35dffd..6b23f8401592 100644 --- a/components/mlme/core/inc/wlan_mlme_main.h +++ b/components/mlme/core/inc/wlan_mlme_main.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved. - * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. 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 @@ -774,4 +774,13 @@ QDF_STATUS mlme_get_cfg_wlm_reset(struct wlan_objmgr_psoc *psoc, */ void mlme_reinit_control_config_lfr_params(struct wlan_objmgr_psoc *psoc, struct wlan_mlme_lfr_cfg *lfr); + +/** + * wlan_is_vdev_id_up() - check if vdev id is in UP state + * @pdev: Pointer to pdev + * @vdev_id: vdev id + * + * Return: if vdev is up + */ +bool wlan_is_vdev_id_up(struct wlan_objmgr_pdev *pdev, uint8_t vdev_id); #endif diff --git a/components/mlme/core/src/wlan_mlme_main.c b/components/mlme/core/src/wlan_mlme_main.c index e3cae446be31..f2d633104945 100644 --- a/components/mlme/core/src/wlan_mlme_main.c +++ b/components/mlme/core/src/wlan_mlme_main.c @@ -3276,3 +3276,22 @@ QDF_STATUS mlme_get_fw_scan_channels(struct wlan_objmgr_psoc *psoc, return QDF_STATUS_SUCCESS; } #endif + +bool wlan_is_vdev_id_up(struct wlan_objmgr_pdev *pdev, uint8_t vdev_id) +{ + struct wlan_objmgr_vdev *vdev; + bool is_up = false; + + if (!pdev) + return is_up; + + vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev, vdev_id, + WLAN_LEGACY_MAC_ID); + + if (vdev) { + is_up = QDF_IS_STATUS_SUCCESS(wlan_vdev_is_up(vdev)); + wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID); + } + + return is_up; +} diff --git a/components/nan/core/src/nan_main.c b/components/nan/core/src/nan_main.c index 264c23bb771e..80a30d2c1c27 100644 --- a/components/nan/core/src/nan_main.c +++ b/components/nan/core/src/nan_main.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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 @@ -550,6 +551,7 @@ static QDF_STATUS nan_handle_confirm(struct nan_datapath_confirm_event *confirm) struct wlan_objmgr_psoc *psoc; struct nan_psoc_priv_obj *psoc_nan_obj; struct nan_vdev_priv_obj *vdev_nan_obj; + struct wlan_objmgr_peer *peer; vdev_id = wlan_vdev_get_id(confirm->vdev); psoc = wlan_vdev_get_psoc(confirm->vdev); @@ -558,6 +560,15 @@ static QDF_STATUS nan_handle_confirm(struct nan_datapath_confirm_event *confirm) return QDF_STATUS_E_NULL_VALUE; } + peer = wlan_objmgr_get_peer_by_mac(psoc, + confirm->peer_ndi_mac_addr.bytes, + WLAN_NAN_ID); + if (!peer) { + nan_debug("Drop NDP confirm as peer isn't available"); + return QDF_STATUS_E_NULL_VALUE; + } + wlan_objmgr_peer_release_ref(peer, WLAN_NAN_ID); + psoc_nan_obj = nan_get_psoc_priv_obj(psoc); if (!psoc_nan_obj) { nan_err("psoc_nan_obj is null"); diff --git a/core/mac/src/pe/nan/nan_datapath.c b/core/mac/src/pe/nan/nan_datapath.c index 07375fcb07f1..099fd49bedcd 100644 --- a/core/mac/src/pe/nan/nan_datapath.c +++ b/core/mac/src/pe/nan/nan_datapath.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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 @@ -50,6 +51,11 @@ static QDF_STATUS lim_add_ndi_peer(struct mac_context *mac_ctx, QDF_STATUS status; uint8_t zero_mac_addr[QDF_MAC_ADDR_SIZE] = { 0, 0, 0, 0, 0, 0 }; + if (!wlan_is_vdev_id_up(mac_ctx->pdev, vdev_id)) { + pe_err_rl("NDI vdev is not up"); + return QDF_STATUS_E_FAILURE; + } + if (!qdf_mem_cmp(&zero_mac_addr, &peer_mac_addr.bytes[0], QDF_MAC_ADDR_SIZE)) { pe_err("Failing to add peer with all zero mac addr");