Jelajahi Sumber

qcacld-3.0: Set NDP state to disconnect if no peers exist

Currently, host driver checks if there are peers present on the NDI
and clean them up as part of NDI cleanup. Cleanup is done in below steps,
1. Set the state to NAN_DATA_END_STATE
2. Send NDP_END_ALL to firmware to end all existing NDP sessions on the
NDI and to cleanup corresponding peers
3. Move the state to NAN_DATA_DISCONNECTED_STATE finally if NDP_END_ALL
goes fine.
But if no peers are present on NDP, none of the above happens and NDI
state stays and doesn't move to DELETED. So, set the NDI state to
DISCONNECTED if no peers are present.

Change-Id: I0d22c240b3e3eee5f62ba8b369bab500e27487b7
CRs-Fixed: 3463614
Rahul Gusain 2 tahun lalu
induk
melakukan
583019cf27
2 mengubah file dengan 56 tambahan dan 4 penghapusan
  1. 55 3
      core/hdd/src/wlan_hdd_main.c
  2. 1 1
      os_if/nan/src/os_if_nan.c

+ 55 - 3
core/hdd/src/wlan_hdd_main.c

@@ -8068,14 +8068,55 @@ void hdd_ipa_ap_disconnect_evt(struct hdd_context *hdd_ctx,
 	}
 }
 
+#ifdef WLAN_FEATURE_NAN
+/**
+ * hdd_ndp_state_cleanup() - API to set NDP state to Disconnected
+ * @psoc: pointer to psoc object
+ * @ndi_vdev_id: vdev_id of the NDI
+ *
+ * Return: None
+ */
 static void
-hdd_peer_cleanup(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter)
+hdd_ndp_state_cleanup(struct wlan_objmgr_psoc *psoc, uint8_t ndi_vdev_id)
+{
+	struct wlan_objmgr_vdev *ndi_vdev;
+
+	ndi_vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, ndi_vdev_id,
+							WLAN_NAN_ID);
+	if (!ndi_vdev) {
+		hdd_err("Cannot obtain NDI vdev object!");
+		return;
+	}
+
+	ucfg_nan_set_ndi_state(ndi_vdev, NAN_DATA_DISCONNECTED_STATE);
+
+	wlan_objmgr_vdev_release_ref(ndi_vdev, WLAN_NAN_ID);
+}
+
+/**
+ * hdd_ndp_peer_cleanup() - This API will delete NDP peer if exist and modifies
+ * the NDP state.
+ * @hdd_ctx: hdd context
+ * @adapter: hdd adapter
+ *
+ * Return: None
+ */
+static void
+hdd_ndp_peer_cleanup(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter)
 {
 	QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
 
 	/* Check if there is any peer present on the adapter */
-	if (!hdd_any_valid_peer_present(adapter))
+	if (!hdd_any_valid_peer_present(adapter)) {
+		/*
+		 * No peers are connected to the NDI. So, set the NDI state to
+		 * DISCONNECTED. If there are any peers, ucfg_nan_disable_ndi()
+		 * would take care of cleanup all the peers and setting the
+		 * state to DISCONNECTED.
+		 */
+		hdd_ndp_state_cleanup(hdd_ctx->psoc, adapter->deflink->vdev_id);
 		return;
+	}
 
 	if (adapter->device_mode == QDF_NDI_MODE)
 		qdf_status = ucfg_nan_disable_ndi(hdd_ctx->psoc,
@@ -8089,6 +8130,17 @@ hdd_peer_cleanup(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter)
 	if (QDF_IS_STATUS_ERROR(qdf_status))
 		hdd_debug("peer_cleanup_done wait fail");
 }
+#else
+static inline void
+hdd_ndp_state_cleanup(struct wlan_objmgr_psoc *psoc, uint8_t ndi_vdev_id)
+{
+}
+
+static inline void
+hdd_ndp_peer_cleanup(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter)
+{
+}
+#endif /* WLAN_FEATURE_NAN */
 
 #ifdef FUNC_CALL_MAP
 
@@ -8177,7 +8229,7 @@ QDF_STATUS hdd_stop_adapter_ext(struct hdd_context *hdd_ctx,
 
 			/* For NDI do not use roam_profile */
 			if (adapter->device_mode == QDF_NDI_MODE) {
-				hdd_peer_cleanup(hdd_ctx, adapter);
+				hdd_ndp_peer_cleanup(hdd_ctx, adapter);
 				status = sme_roam_ndi_stop(
 						mac_handle,
 						adapter->deflink->vdev_id);

+ 1 - 1
os_if/nan/src/os_if_nan.c

@@ -2531,7 +2531,7 @@ void os_if_nan_ndi_session_end(struct wlan_objmgr_vdev *vdev)
 	 * call and NDI state remains to created "NAN_DATA_NDI_CREATED_STATE".
 	 */
 	if (state == NAN_DATA_NDI_CREATED_STATE) {
-		osif_err("NDI interface is just created: %u", state);
+		osif_debug("NDI interface is just created: %u", state);
 		return;
 	} else if (state != NAN_DATA_NDI_DELETING_STATE &&
 		   state != NAN_DATA_DISCONNECTED_STATE) {