diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index d7a827e81991..dd8f25189421 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -6269,6 +6269,8 @@ QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, (SME_DISCONNECT_TIMEOUT)); if (!rc) hdd_warn("disconn_comp_var wait fail"); + if (adapter->device_mode == QDF_NDI_MODE) + hdd_cleanup_ndi(hdd_ctx, adapter); } if (QDF_IS_STATUS_ERROR(status)) hdd_warn("failed to post disconnect"); @@ -13845,6 +13847,11 @@ static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { return true; } + + if (adapter->device_mode == QDF_NDI_MODE && + WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> + conn_info.conn_state == eConnectionState_NdiConnected) + return true; } return false; diff --git a/core/hdd/src/wlan_hdd_nan_datapath.c b/core/hdd/src/wlan_hdd_nan_datapath.c index 1b0557763a30..3975fbd9af58 100644 --- a/core/hdd/src/wlan_hdd_nan_datapath.c +++ b/core/hdd/src/wlan_hdd_nan_datapath.c @@ -888,6 +888,25 @@ int hdd_ndp_new_peer_handler(uint8_t vdev_id, uint16_t sta_id, return 0; } +void hdd_cleanup_ndi(struct hdd_context *hdd_ctx, + struct hdd_adapter *adapter) +{ + struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); + + if (sta_ctx->conn_info.conn_state != eConnectionState_NdiConnected) { + hdd_debug("NDI has no NDPs"); + return; + } + sta_ctx->conn_info.conn_state = eConnectionState_NdiDisconnected; + hdd_conn_set_connection_state(adapter, + eConnectionState_NdiDisconnected); + hdd_info("Stop netif tx queues."); + wlan_hdd_netif_queue_control(adapter, WLAN_STOP_ALL_NETIF_QUEUE, + WLAN_CONTROL_PATH); + hdd_bus_bw_compute_reset_prev_txrx_stats(adapter); + hdd_bus_bw_compute_timer_try_stop(hdd_ctx); +} + /** * hdd_ndp_peer_departed_handler() - Handle NDP peer departed indication * @adapter: pointer to adapter context @@ -927,14 +946,7 @@ void hdd_ndp_peer_departed_handler(uint8_t vdev_id, uint16_t sta_id, if (last_peer) { hdd_info("No more ndp peers."); - sta_ctx->conn_info.conn_state = eConnectionState_NdiDisconnected; - hdd_conn_set_connection_state(adapter, - eConnectionState_NdiDisconnected); - hdd_info("Stop netif tx queues."); - wlan_hdd_netif_queue_control(adapter, WLAN_STOP_ALL_NETIF_QUEUE, - WLAN_CONTROL_PATH); - hdd_bus_bw_compute_reset_prev_txrx_stats(adapter); - hdd_bus_bw_compute_timer_try_stop(hdd_ctx); + hdd_cleanup_ndi(hdd_ctx, adapter); } hdd_exit(); diff --git a/core/hdd/src/wlan_hdd_nan_datapath.h b/core/hdd/src/wlan_hdd_nan_datapath.h index bd13ec326c87..efbc1c812384 100644 --- a/core/hdd/src/wlan_hdd_nan_datapath.h +++ b/core/hdd/src/wlan_hdd_nan_datapath.h @@ -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 @@ -99,5 +99,17 @@ int hdd_ndp_new_peer_handler(uint8_t vdev_id, uint16_t sta_id, struct qdf_mac_addr *peer_mac_addr, bool fist_peer); void hdd_ndp_peer_departed_handler(uint8_t vdev_id, uint16_t sta_id, struct qdf_mac_addr *peer_mac_addr, bool last_peer); +/** + * hdd_cleanup_ndi(): Cleanup NDI state/resources + * @hdd_ctx: HDD context + * @adapter: Pointer to the NDI adapter + * + * Cleanup NDI state/resources allocated when NDPs are created on that NDI. + * + * Return: None + */ + +void hdd_cleanup_ndi(struct hdd_context *hdd_ctx, + struct hdd_adapter *adapter); #endif /* __WLAN_HDD_NAN_DATAPATH_H */