Prechádzať zdrojové kódy

qcacld-3.0: Add hdd api to check different vdev states

Currently there are no hdd apis to check different
vdev states.
Add hdd apis to check if vdev is connecting to some ap
or disconnecting or vdev is in disconnected state with
the help of connection manager api for the same purpose.

Change-Id: I3b653fa1090a0e701f235520fa4e1028bac6ad7d
CRs-Fixed: 2853413
Ashish Kumar Dhanotiya 4 rokov pred
rodič
commit
d1c0c54b5f

+ 0 - 8
core/hdd/inc/wlan_hdd_assoc.h

@@ -198,14 +198,6 @@ struct hdd_adapter;
 struct hdd_station_ctx;
 struct hdd_context;
 
-/**
- * hdd_is_connecting() - Function to check connection progress
- * @hdd_sta_ctx:    pointer to global HDD Station context
- *
- * Return: true if connecting, false otherwise
- */
-bool hdd_is_connecting(struct hdd_station_ctx *hdd_sta_ctx);
-
 /*
  * hdd_is_fils_connection: API to determine if connection is FILS
  * @adapter: hdd adapter

+ 7 - 19
core/hdd/src/wlan_hdd_assoc.c

@@ -380,12 +380,6 @@ hdd_conn_get_connection_state(struct hdd_station_ctx *sta_ctx,
 	}
 }
 
-bool hdd_is_connecting(struct hdd_station_ctx *hdd_sta_ctx)
-{
-	return hdd_sta_ctx->conn_info.conn_state ==
-		eConnectionState_Connecting;
-}
-
 bool hdd_conn_is_connected(struct hdd_station_ctx *sta_ctx)
 {
 	return hdd_conn_get_connection_state(sta_ctx, NULL);
@@ -460,8 +454,7 @@ struct hdd_adapter *hdd_get_sta_connection_in_progress(
 		if ((QDF_STA_MODE == adapter->device_mode) ||
 		    (QDF_P2P_CLIENT_MODE == adapter->device_mode) ||
 		    (QDF_P2P_DEVICE_MODE == adapter->device_mode)) {
-			if (eConnectionState_Connecting ==
-			    hdd_sta_ctx->conn_info.conn_state) {
+			if (hdd_cm_is_connecting(adapter)) {
 				hdd_debug("vdev_id %d: Connection is in progress",
 					  adapter->vdev_id);
 				hdd_adapter_dev_put_debug(adapter, dbgid);
@@ -1850,12 +1843,9 @@ static QDF_STATUS hdd_dis_connect_handler(struct hdd_adapter *adapter,
 	 * initiated disconnect will be handled by disconnect handler call
 	 * to cfg80211_disconnected.
 	 */
-	if ((eConnectionState_Disconnecting ==
-	    sta_ctx->conn_info.conn_state) ||
-	    (eConnectionState_NotConnected ==
-	    sta_ctx->conn_info.conn_state) ||
-	    (eConnectionState_Connecting ==
-	    sta_ctx->conn_info.conn_state)) {
+	if (hdd_cm_is_disconnecting(adapter) ||
+	    hdd_cm_is_disconnected(adapter) ||
+	    hdd_cm_is_connecting(adapter)) {
 		if (hdd_ctx->disconnect_for_sta_mon_conc) {
 			hdd_debug("Disconnect triggered by HDD to add monitor intf notify kernel");
 			hdd_ctx->disconnect_for_sta_mon_conc = false;
@@ -1947,7 +1937,7 @@ static QDF_STATUS hdd_dis_connect_handler(struct hdd_adapter *adapter,
 	* eConnectionState_Connecting state mean that connection is in
 	* progress so no need to set state to eConnectionState_NotConnected
 	*/
-	if ((eConnectionState_Connecting != sta_ctx->conn_info.conn_state))
+	if (!hdd_cm_is_connecting(adapter))
 		hdd_conn_set_connection_state(adapter,
 					       eConnectionState_NotConnected);
 
@@ -2722,10 +2712,8 @@ hdd_association_completion_handler(struct hdd_adapter *adapter,
 	/* HDD has initiated disconnect, do not send connect result indication
 	 * to kernel as it will be handled by __cfg80211_disconnect.
 	 */
-	if (((eConnectionState_Disconnecting ==
-	    sta_ctx->conn_info.conn_state) ||
-	    (eConnectionState_NotConnected ==
-	    sta_ctx->conn_info.conn_state)) &&
+	if ((hdd_cm_is_disconnecting(adapter) ||
+	     hdd_cm_is_disconnected(adapter)) &&
 	    ((eCSR_ROAM_RESULT_ASSOCIATED == roam_result) ||
 	    (eCSR_ROAM_ASSOCIATION_FAILURE == roam_status))) {
 		hdd_info("hddDisconInProgress state=%d, result=%d, status=%d",

+ 3 - 3
core/hdd/src/wlan_hdd_cfg80211.c

@@ -20466,11 +20466,11 @@ static int wlan_hdd_wait_for_disconnect(mac_handle_t mac_handle,
 	void *hif_ctx;
 
 	/* Return if already disconnected */
-	if (sta_ctx->conn_info.conn_state == eConnectionState_NotConnected)
+	if (hdd_cm_is_disconnected(adapter))
 		return 0;
 
 	/* If already in disconnecting state just wait for its completion */
-	if (sta_ctx->conn_info.conn_state == eConnectionState_Disconnecting)
+	if (hdd_cm_is_disconnecting(adapter))
 		goto wait_for_disconnect;
 
 	hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
@@ -21170,7 +21170,7 @@ static int __wlan_hdd_cfg80211_disconnect(struct wiphy *wiphy,
 
 	/* Issue disconnect request to SME, if station is in connected state */
 	if (hdd_cm_is_vdev_associated(adapter) ||
-	    (sta_ctx->conn_info.conn_state == eConnectionState_Connecting)) {
+	    hdd_cm_is_connecting(adapter)) {
 		eCsrRoamDisconnectReason reasonCode =
 			eCSR_DISCONNECT_REASON_UNSPECIFIED;
 

+ 24 - 0
core/hdd/src/wlan_hdd_cm_api.h

@@ -230,4 +230,28 @@ void hdd_cm_save_connect_status(struct hdd_adapter *adapter,
  */
 bool hdd_cm_is_vdev_associated(struct hdd_adapter *adapter);
 
+/**
+ * hdd_cm_is_connecting() - Function to check connection in progress
+ * @adapter: pointer to the adapter structure
+ *
+ * Return: true if connecting, false otherwise
+ */
+bool hdd_cm_is_connecting(struct hdd_adapter *adapter);
+
+/**
+ * hdd_cm_is_disconnected() - Function to check if vdev is disconnected or not
+ * @adapter: pointer to the adapter structure
+ *
+ * Return: true if disconnected, false otherwise
+ */
+bool hdd_cm_is_disconnected(struct hdd_adapter *adapter);
+
+/**
+ * hdd_cm_is_disconnecting() - Function to check disconnection in progress
+ * @adapter: pointer to the adapter structure
+ *
+ * Return: true if disconnecting, false otherwise
+ */
+bool hdd_cm_is_disconnecting(struct hdd_adapter *adapter);
+
 #endif

+ 94 - 0
core/hdd/src/wlan_hdd_cm_connect.c

@@ -68,6 +68,79 @@ bool hdd_cm_is_vdev_associated(struct hdd_adapter *adapter)
 
 	return is_vdev_active;
 }
+
+bool hdd_cm_is_connecting(struct hdd_adapter *adapter)
+{
+	struct wlan_objmgr_vdev *vdev;
+	bool is_vdev_connecting;
+
+	vdev = hdd_objmgr_get_vdev_by_user(adapter, WLAN_OSIF_CM_ID);
+
+	if (!vdev) {
+		mlme_err("vdev_id: %d: vdev not found", adapter->vdev_id);
+		return false;
+	}
+
+	if (wlan_vdev_mlme_get_opmode(vdev) != QDF_STA_MODE &&
+	    wlan_vdev_mlme_get_opmode(vdev) != QDF_P2P_CLIENT_MODE) {
+		hdd_objmgr_put_vdev_by_user(vdev, WLAN_OSIF_CM_ID);
+		return false;
+	}
+	is_vdev_connecting = ucfg_cm_is_vdev_connecting(vdev);
+
+	hdd_objmgr_put_vdev_by_user(vdev, WLAN_OSIF_CM_ID);
+
+	return is_vdev_connecting;
+}
+
+bool hdd_cm_is_disconnected(struct hdd_adapter *adapter)
+{
+	struct wlan_objmgr_vdev *vdev;
+	bool is_vdev_disconnected;
+
+	vdev = hdd_objmgr_get_vdev_by_user(adapter, WLAN_OSIF_CM_ID);
+
+	if (!vdev) {
+		mlme_err("vdev_id: %d: vdev not found", adapter->vdev_id);
+		return false;
+	}
+
+	if (wlan_vdev_mlme_get_opmode(vdev) != QDF_STA_MODE &&
+	    wlan_vdev_mlme_get_opmode(vdev) != QDF_P2P_CLIENT_MODE) {
+		hdd_objmgr_put_vdev_by_user(vdev, WLAN_OSIF_CM_ID);
+		return false;
+	}
+	is_vdev_disconnected = ucfg_cm_is_vdev_disconnected(vdev);
+
+	hdd_objmgr_put_vdev_by_user(vdev, WLAN_OSIF_CM_ID);
+
+	return is_vdev_disconnected;
+}
+
+bool hdd_cm_is_disconnecting(struct hdd_adapter *adapter)
+{
+	struct wlan_objmgr_vdev *vdev;
+	bool is_vdev_disconnecting;
+
+	vdev = hdd_objmgr_get_vdev_by_user(adapter, WLAN_OSIF_CM_ID);
+
+	if (!vdev) {
+		mlme_err("vdev_id: %d: vdev not found", adapter->vdev_id);
+		return false;
+	}
+
+	if (wlan_vdev_mlme_get_opmode(vdev) != QDF_STA_MODE &&
+	    wlan_vdev_mlme_get_opmode(vdev) != QDF_P2P_CLIENT_MODE) {
+		hdd_objmgr_put_vdev_by_user(vdev, WLAN_OSIF_CM_ID);
+		return false;
+	}
+	is_vdev_disconnecting = ucfg_cm_is_vdev_disconnecting(vdev);
+
+	hdd_objmgr_put_vdev_by_user(vdev, WLAN_OSIF_CM_ID);
+
+	return is_vdev_disconnecting;
+}
+
 #else
 bool hdd_cm_is_vdev_associated(struct hdd_adapter *adapter)
 {
@@ -75,6 +148,27 @@ bool hdd_cm_is_vdev_associated(struct hdd_adapter *adapter)
 
 	return (sta_ctx->conn_info.conn_state == eConnectionState_Associated);
 }
+
+bool hdd_cm_is_connecting(struct hdd_adapter *adapter)
+{
+	struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
+
+	return sta_ctx->conn_info.conn_state == eConnectionState_Connecting;
+}
+
+bool hdd_cm_is_disconnected(struct hdd_adapter *adapter)
+{
+	struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
+
+	return sta_ctx->conn_info.conn_state == eConnectionState_NotConnected;
+}
+
+bool hdd_cm_is_disconnecting(struct hdd_adapter *adapter)
+{
+	struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
+
+	return sta_ctx->conn_info.conn_state == eConnectionState_Disconnecting;
+}
 #endif
 
 void hdd_cm_update_rssi_snr_by_bssid(struct hdd_adapter *adapter)

+ 2 - 4
core/hdd/src/wlan_hdd_hostapd.c

@@ -2959,10 +2959,8 @@ static bool hdd_is_any_sta_connecting(struct hdd_context *hdd_ctx)
 					   dbgid) {
 		sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
 		if ((adapter->device_mode == QDF_STA_MODE) ||
-		    (adapter->device_mode == QDF_P2P_CLIENT_MODE) ||
-		    (adapter->device_mode == QDF_P2P_DEVICE_MODE)) {
-			if (sta_ctx->conn_info.conn_state ==
-			    eConnectionState_Connecting) {
+		    (adapter->device_mode == QDF_P2P_CLIENT_MODE)) {
+			if (hdd_cm_is_connecting(adapter)) {
 				hdd_debug("vdev_id %d: connecting",
 					  adapter->vdev_id);
 				hdd_adapter_dev_put_debug(adapter, dbgid);

+ 2 - 4
core/hdd/src/wlan_hdd_main.c

@@ -7087,7 +7087,7 @@ QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx,
 		    adapter->device_mode == QDF_P2P_CLIENT_MODE
 #else
 		    hdd_conn_is_connected(sta_ctx) ||
-		    hdd_is_connecting(sta_ctx)
+		    hdd_cm_is_connecting(adapter)
 #endif
 		    ) {
 			INIT_COMPLETION(adapter->disconnect_comp_var);
@@ -18046,9 +18046,7 @@ static QDF_STATUS hdd_is_connection_in_progress_iterator(
 	if (((QDF_STA_MODE == adapter->device_mode)
 		|| (QDF_P2P_CLIENT_MODE == adapter->device_mode)
 		|| (QDF_P2P_DEVICE_MODE == adapter->device_mode))
-		&& (eConnectionState_Connecting ==
-			(WLAN_HDD_GET_STATION_CTX_PTR(adapter))->
-				conn_info.conn_state)) {
+		&& hdd_cm_is_connecting(adapter)) {
 		hdd_debug("%pK(%d) mode %d Connection is in progress",
 			  WLAN_HDD_GET_STATION_CTX_PTR(adapter),
 			  adapter->vdev_id, adapter->device_mode);

+ 2 - 2
core/hdd/src/wlan_hdd_nan_datapath.c

@@ -142,7 +142,7 @@ static bool hdd_is_ndp_allowed(struct hdd_context *hdd_ctx)
 		case QDF_P2P_CLIENT_MODE:
 			sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
 			if (hdd_conn_is_connected(sta_ctx) ||
-			    hdd_is_connecting(sta_ctx)) {
+			    hdd_cm_is_connecting(adapter)) {
 				hdd_adapter_dev_put_debug(adapter, dbgid);
 				if (next_adapter)
 					hdd_adapter_dev_put_debug(next_adapter,
@@ -182,7 +182,7 @@ static bool hdd_is_ndp_allowed(struct hdd_context *hdd_ctx)
 		case QDF_P2P_CLIENT_MODE:
 			sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
 			if (hdd_conn_is_connected(sta_ctx) ||
-			    hdd_is_connecting(sta_ctx)) {
+			    hdd_cm_is_connecting(adapter)) {
 				hdd_adapter_dev_put_debug(adapter, dbgid);
 				if (next_adapter)
 					hdd_adapter_dev_put_debug(next_adapter,

+ 2 - 4
core/hdd/src/wlan_hdd_stats.c

@@ -750,12 +750,10 @@ bool hdd_get_interface_info(struct hdd_adapter *adapter,
 	     (QDF_P2P_CLIENT_MODE == adapter->device_mode) ||
 	     (QDF_P2P_DEVICE_MODE == adapter->device_mode))) {
 		sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-		if (eConnectionState_NotConnected ==
-		    sta_ctx->conn_info.conn_state) {
+		if (hdd_cm_is_disconnected(adapter)) {
 			info->state = WIFI_DISCONNECTED;
 		}
-		if (eConnectionState_Connecting ==
-		    sta_ctx->conn_info.conn_state) {
+		if (hdd_cm_is_connecting(adapter)) {
 			hdd_debug("Session ID %d, Connection is in progress",
 				  adapter->vdev_id);
 			info->state = WIFI_ASSOCIATING;