Преглед на файлове

qcacmn: Handle connect and disconnect events in connection manager

Handle connect and disconnect events in connection manager state
machine.

Change-Id: I62cba42ed726c3cc61343109c4e3208eba0d7e9e
CRs-Fixed: 2740300
gaurank kathpalia преди 5 години
родител
ревизия
26ea02a1ea

+ 55 - 0
umac/mlme/connection_mgr/core/src/wlan_cm_connect.c

@@ -17,3 +17,58 @@
 /**
  * DOC: Implements connect specific APIs of connection manager
  */
+
+#include "wlan_cm_main_api.h"
+
+QDF_STATUS cm_connect_start(struct cnx_mgr *cm_ctx, struct cm_connect_req *req)
+{
+	/*
+	 * TODO: Interface event, get candidate list, do hw mode change and
+	 * serialize. Also move to scan state from here if required.
+	 * If candidate found and all are blacklisted or serialization fails
+	 * post WLAN_CM_SM_EV_CONNECT_REQ_FAIL.
+	 */
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS cm_connect_active(struct cnx_mgr *cm_ctx, wlan_cm_id *cm_id)
+{
+	/*
+	 * TODO: get first valid candidate, create bss peer.
+	 * fill vdev crypto for the peer.
+	 * call vdev sm to start connect for the candidate.
+	 */
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS cm_try_next_candidate(struct cnx_mgr *cm_ctx,
+				 struct wlan_cm_connect_rsp *resp)
+{
+	/*
+	 * TODO: get next valid candidate, if no candidate left, post
+	 * WLAN_CM_SM_EV_CONNECT_FAILURE to SM, inform osif about failure for
+	 * the candidate if its not last one. and initiate the connect for
+	 * next candidate.
+	 */
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS cm_connect_cmd_timeout(struct cnx_mgr *cm_ctx, wlan_cm_id cm_id)
+{
+	/*
+	 * TODO: get the connect req from connect list and post
+	 * WLAN_CM_SM_EV_CONNECT_FAILURE.
+	 */
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS cm_connect_complete(struct cnx_mgr *cm_ctx,
+			       struct wlan_cm_connect_rsp *resp)
+{
+	/*
+	 * TODO: inform osif about success/failure, inform interface manager
+	 * update fils/wep key and inform legacy, update bcn filter and scan
+	 * entry mlme info, blm action and remove from serialization at the end.
+	 */
+	return QDF_STATUS_SUCCESS;
+}

+ 24 - 0
umac/mlme/connection_mgr/core/src/wlan_cm_connect_scan.c

@@ -18,3 +18,27 @@
  * DOC: Implements connect scan (scan for ssid) specific apis of
  * connection manager
  */
+
+#include "wlan_cm_main_api.h"
+
+QDF_STATUS cm_connect_scan_start(struct cnx_mgr *cm_ctx,
+				 struct cm_connect_req *req)
+{
+	/*
+	 * TODO: initiate connect scan and scan timer.
+	 * post WLAN_CM_SM_EV_CONNECT_SCAN_FAILURE on scan req failure.
+	 */
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS cm_connect_scan_resp(struct cnx_mgr *cm_ctx, wlan_scan_id *scan_id,
+				QDF_STATUS status)
+{
+	/*
+	 * TODO: get connect req from head and check if scan_id match
+	 * if not drop else proceed with success or failure handling
+	 * (post WLAN_CM_SM_EV_CONNECT_FAILURE in case of status failure or if
+	 * no candidate found again after scan)
+	 */
+	return QDF_STATUS_SUCCESS;
+}

+ 31 - 0
umac/mlme/connection_mgr/core/src/wlan_cm_disconnect.c

@@ -17,3 +17,34 @@
 /**
  * DOC: Implements disconnect specific apis of connection manager
  */
+#include "wlan_cm_main_api.h"
+
+QDF_STATUS cm_disconnect_start(struct cnx_mgr *cm_ctx,
+			       struct cm_disconnect_req *req)
+{
+	/*
+	 * TODO: Interface event, stop scan, disconnect TDLS, P2P roc cleanup
+	 * queue serialization.
+	 */
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS cm_disconnect_active(struct cnx_mgr *cm_ctx, wlan_cm_id *cm_id)
+{
+	/*
+	 * TODO: call vdev sm to start disconnect.
+	 */
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS cm_disconnect_complete(struct cnx_mgr *cm_ctx,
+				  struct wlan_cm_discon_rsp *resp)
+{
+	/*
+	 * TODO: inform osif, inform interface manager
+	 * update fils/wep key and inform legacy, update bcn filter and scan
+	 * entry mlme info, blm action and remove from serialization at the end.
+	 */
+	return QDF_STATUS_SUCCESS;
+}
+

+ 24 - 30
umac/mlme/connection_mgr/core/src/wlan_cm_main.h

@@ -73,19 +73,19 @@ enum wlan_cm_sm_state {
 
 /**
  * enum wlan_cm_sm_evt - connection manager related events
- * @WLAN_CM_SM_EV_CONNECT_REQ:            Connect request event
- * @WLAN_CM_SM_EV_SCAN_FOR_SSID:          Event for scan for SSID
- * @WLAN_CM_SM_EV_SCAN_FOR_SSID_SUCCESS:  Scan for SSID success event
- * @WLAN_CM_SM_EV_SCAN_FOR_SSID_FAILURE:  Scan for SSID fail event
- * @WLAN_CM_SM_EV_CONNECT_START_REQ:      Connect start request after BSSID list
- *                                        is prepared
- * @WLAN_CM_SM_EV_CONNECT_START:          Connect request for a particular BSSID
+ * @WLAN_CM_SM_EV_CONNECT_REQ:            Connect request event from requester
+ * @WLAN_CM_SM_EV_SCAN:                   Event to start connect scan
+ * @WLAN_CM_SM_EV_SCAN_SUCCESS:           Connect scan success event
+ * @WLAN_CM_SM_EV_SCAN_FAILURE:           Connect scan fail event
+ * @WLAN_CM_SM_EV_CONNECT_START:          Connect start process initiate
+ * @WLAN_CM_SM_EV_CONNECT_ACTIVE:         Connect request is activated
  * @WLAN_CM_SM_EV_CONNECT_SUCCESS:        Connect success
- * @WLAN_CM_SM_EV_CONNECT_NEXT_CANDIDATE: Select next candidate for connection
- * @WLAN_CM_SM_EV_CONNECT_FAILURE:        Connect failed event
- * @WLAN_CM_SM_EV_DISCONNECT_REQ:         Disconnect request event
- * @WLAN_CM_SM_EV_DISCONNECT_START_REQ:   Start disconnect sequence
- * @WLAN_CM_SM_EV_DISCONNECT_START:       Disconnect process start event
+ * @WLAN_CM_SM_EV_CONNECT_GET_NEXT_CANDIDATE: Get next candidate for connection
+ * @WLAN_CM_SM_EV_CONNECT_FAILURE:        Connect failed for all candidate
+ * @WLAN_CM_SM_EV_DISCONNECT_REQ:         Disconnect request event from
+ * requester
+ * @WLAN_CM_SM_EV_DISCONNECT_START:       Start disconnect sequence
+ * @WLAN_CM_SM_EV_DISCONNECT_ACTIVE:      Process disconnect after in active cmd
  * @WLAN_CM_SM_EV_DISCONNECT_DONE:        Disconnect done event
  * @WLAN_CM_SM_EV_ROAM_START:             Roam start event
  * @WLAN_CM_SM_EV_ROAM_SYNC:              Roam sync event
@@ -98,24 +98,21 @@ enum wlan_cm_sm_state {
  * @WLAN_CM_SM_EV_REASSOC_DONE:           Reassoc completed
  * @WLAN_CM_SM_EV_REASSOC_FAILURE:        Reassoc failed
  * @WLAN_CM_SM_EV_ROAM_COMPLETE:          Roaming completed
- * @WLAN_CM_SM_EV_CONNECT_TIMEOUT:        Connect timeout event
- * @WLAN_CM_SM_EV_CONNECT_SER_FAIL:       Connect request failed to serialize
- * @WLAN_CM_SM_EV_HW_MODE_CHANGE_FAIL:    HW mode change failed event
  * @WLAN_CM_SM_EV_MAX:                    Max event
  */
 enum wlan_cm_sm_evt {
 	WLAN_CM_SM_EV_CONNECT_REQ = 0,
-	WLAN_CM_SM_EV_SCAN_FOR_SSID = 1,
-	WLAN_CM_SM_EV_SCAN_FOR_SSID_SUCCESS = 2,
-	WLAN_CM_SM_EV_SCAN_FOR_SSID_FAILURE = 3,
-	WLAN_CM_SM_EV_CONNECT_START_REQ = 4,
-	WLAN_CM_SM_EV_CONNECT_START = 5,
+	WLAN_CM_SM_EV_SCAN = 1,
+	WLAN_CM_SM_EV_SCAN_SUCCESS = 2,
+	WLAN_CM_SM_EV_SCAN_FAILURE = 3,
+	WLAN_CM_SM_EV_CONNECT_START = 4,
+	WLAN_CM_SM_EV_CONNECT_ACTIVE = 5,
 	WLAN_CM_SM_EV_CONNECT_SUCCESS = 6,
-	WLAN_CM_SM_EV_CONNECT_NEXT_CANDIDATE = 7,
+	WLAN_CM_SM_EV_CONNECT_GET_NEXT_CANDIDATE = 7,
 	WLAN_CM_SM_EV_CONNECT_FAILURE = 8,
 	WLAN_CM_SM_EV_DISCONNECT_REQ = 9,
-	WLAN_CM_SM_EV_DISCONNECT_START_REQ = 10,
-	WLAN_CM_SM_EV_DISCONNECT_START = 11,
+	WLAN_CM_SM_EV_DISCONNECT_START = 10,
+	WLAN_CM_SM_EV_DISCONNECT_ACTIVE = 11,
 	WLAN_CM_SM_EV_DISCONNECT_DONE = 12,
 	WLAN_CM_SM_EV_ROAM_START = 13,
 	WLAN_CM_SM_EV_ROAM_SYNC = 14,
@@ -128,9 +125,6 @@ enum wlan_cm_sm_evt {
 	WLAN_CM_SM_EV_REASSOC_DONE = 21,
 	WLAN_CM_SM_EV_REASSOC_FAILURE = 22,
 	WLAN_CM_SM_EV_ROAM_COMPLETE = 23,
-	WLAN_CM_SM_EV_CONNECT_TIMEOUT = 24,
-	WLAN_CM_SM_EV_CONNECT_SER_FAIL = 25,
-	WLAN_CM_SM_EV_HW_MODE_CHANGE_FAIL = 26,
 	WLAN_CM_SM_EV_MAX,
 };
 
@@ -164,8 +158,8 @@ struct cm_state_sm {
  * @cur_candidate: current candidate
  */
 struct cm_connect_req {
-	uint64_t cm_id;
-	uint64_t scan_id;
+	wlan_cm_id cm_id;
+	wlan_scan_id scan_id;
 	qdf_timer_t scan_timer;
 	qdf_timer_t hw_mode_timer;
 	struct wlan_cm_connect_req req;
@@ -180,7 +174,7 @@ struct cm_connect_req {
  * @req: disconnect connect req from osif
  */
 struct cm_disconnect_req {
-	uint64_t cm_id;
+	wlan_cm_id cm_id;
 	struct wlan_cm_disconnect_req req;
 };
 
@@ -195,7 +189,7 @@ struct cm_disconnect_req {
 struct cm_req {
 	qdf_list_node_t node;
 	enum wlan_cm_source source;
-	uint64_t cm_id;
+	wlan_cm_id cm_id;
 	union {
 		struct cm_connect_req connect_req;
 		struct cm_disconnect_req discon_req;

+ 114 - 0
umac/mlme/connection_mgr/core/src/wlan_cm_main_api.h

@@ -23,4 +23,118 @@
 #ifndef __WLAN_CM_MAIN_API_H__
 #define __WLAN_CM_MAIN_API_H__
 
+#include "wlan_cm_main.h"
+
+/*************** CONNECT APIs ****************/
+/**
+ * cm_connect_start() - This API will be called to initiate the connect
+ * process
+ * @cm_ctx: connection manager context
+ * @req: Connect request.
+ *
+ * Return: QDF status
+ */
+QDF_STATUS cm_connect_start(struct cnx_mgr *cm_ctx, struct cm_connect_req *req);
+
+/**
+ * cm_connect_scan_start() - This API will be called to initiate the connect
+ * scan if no candidate are found in scan db.
+ * @cm_ctx: connection manager context
+ * @req: Connect request.
+ *
+ * Return: QDF status
+ */
+QDF_STATUS cm_connect_scan_start(struct cnx_mgr *cm_ctx,
+				 struct cm_connect_req *req);
+
+/**
+ * cm_connect_scan_resp() - Handle the connect scan resp and next action
+ * scan if no candidate are found in scan db.
+ * @scan_id: scan id of the req
+ * @status: Connect scan status
+ *
+ * Return: QDF status
+ */
+QDF_STATUS cm_connect_scan_resp(struct cnx_mgr *cm_ctx, wlan_scan_id *scan_id,
+				QDF_STATUS status);
+
+/**
+ * cm_connect_active() - This API would be called after the connect
+ * request gets activated in serialization.
+ * @cm_ctx: connection manager context
+ * @cm_id: Connection mgr ID assigned to this connect request.
+ *
+ * Return: QDF status
+ */
+QDF_STATUS cm_connect_active(struct cnx_mgr *cm_ctx, wlan_cm_id *cm_id);
+
+/**
+ * cm_try_next_candidate() - This API would try to connect to next valid
+ * candidate and fail if no candidate left
+ * request gets activated in serialization.
+ * @cm_ctx: connection manager context
+ * @connect_resp: connect resp.
+ *
+ * Return: QDF status
+ */
+QDF_STATUS cm_try_next_candidate(struct cnx_mgr *cm_ctx,
+				 struct wlan_cm_connect_rsp *connect_resp);
+
+/**
+ * cm_connect_cmd_timeout() - Called if active connect command timeout
+ * @cm_ctx: connection manager context
+ * @cm_id: Connection mgr ID assigned to this connect request.
+ *
+ * Return: QDF status
+ */
+QDF_STATUS cm_connect_cmd_timeout(struct cnx_mgr *cm_ctx, wlan_cm_id cm_id);
+
+/**
+ * cm_connect_complete() - This API would be called after connect complete
+ * request from the serialization.
+ * @cm_ctx: connection manager context
+ * @resp: Connection complete resp.
+ *
+ * This API would be called after connection completion resp from VDEV mgr
+ *
+ * Return: QDF status
+ */
+QDF_STATUS cm_connect_complete(struct cnx_mgr *cm_ctx,
+			       struct wlan_cm_connect_rsp *resp);
+
+/*************** DISCONNECT APIs ****************/
+
+/**
+ * cm_disconnect_start() - Initiate the disconnect process
+ * @cm_ctx: connection manager context
+ * @req: Disconnect request.
+ *
+ * Return: QDF status
+ */
+QDF_STATUS cm_disconnect_start(struct cnx_mgr *cm_ctx,
+			       struct cm_disconnect_req *req);
+
+/**
+ * cm_disconnect_active() - This API would be called after the disconnect
+ * request gets activated in serialization.
+ * @cm_ctx: connection manager context
+ * @cm_id: Connection mgr ID assigned to this connect request.
+ *
+ * Return: QDF status
+ */
+QDF_STATUS cm_disconnect_active(struct cnx_mgr *cm_ctx, wlan_cm_id *cm_id);
+
+/**
+ * cm_connect_complete() - This API would be called after connect complete
+ * request from the serialization.
+ * @cm_ctx: connection manager context
+ * @resp: disconnection complete resp.
+ *
+ * This API would be called after connection completion resp from VDEV mgr
+ *
+ * Return: QDF status
+ */
+QDF_STATUS cm_disconnect_complete(struct cnx_mgr *cm_ctx,
+				  struct wlan_cm_discon_rsp *resp);
+
 #endif /* __WLAN_CM_MAIN_API_H__ */

+ 131 - 52
umac/mlme/connection_mgr/core/src/wlan_cm_sm.c

@@ -18,7 +18,7 @@
  * DOC: Implements general SM framework for connection manager
  */
 
-#include "wlan_cm_main.h"
+#include "wlan_cm_main_api.h"
 #include "wlan_cm_sm.h"
 #include "wlan_cm_roam_sm.h"
 
@@ -62,7 +62,7 @@ void mlme_cm_sm_state_update(struct cnx_mgr *cm_ctx,
  */
 static void mlme_cm_state_init_entry(void *ctx)
 {
-	struct cnx_mgr *cm_ctx = (struct cnx_mgr *)ctx;
+	struct cnx_mgr *cm_ctx = ctx;
 
 	mlme_cm_sm_state_update(cm_ctx, WLAN_CM_S_INIT, WLAN_CM_SS_IDLE);
 }
@@ -88,13 +88,27 @@ static void mlme_cm_state_init_exit(void *ctx)
  * Return: bool
  */
 static bool mlme_cm_state_init_event(void *ctx, uint16_t event,
-				     uint16_t event_data_len,
-				     void *event_data)
+				     uint16_t data_len, void *data)
 {
-//	struct cnx_mgr *cm_ctx = (struct cnx_mgr *)ctx;
+	struct cnx_mgr *cm_ctx = ctx;
 	bool status;
 
 	switch (event) {
+	case WLAN_CM_SM_EV_CONNECT_REQ:
+		mlme_cm_sm_transition_to(cm_ctx, WLAN_CM_S_CONNECTING);
+		mlme_cm_sm_deliver_event(cm_ctx,
+					 WLAN_CM_SM_EV_CONNECT_START,
+					 data_len, data);
+		status = true;
+		break;
+	case WLAN_CM_SM_EV_CONNECT_FAILURE:
+		cm_connect_complete(cm_ctx, data);
+		status = true;
+		break;
+	case WLAN_CM_SM_EV_DISCONNECT_DONE:
+		cm_disconnect_complete(cm_ctx, data);
+		status = true;
+		break;
 	default:
 		status = false;
 		break;
@@ -114,7 +128,7 @@ static bool mlme_cm_state_init_event(void *ctx, uint16_t event,
  */
 static void mlme_cm_state_connecting_entry(void *ctx)
 {
-	struct cnx_mgr *cm_ctx = (struct cnx_mgr *)ctx;
+	struct cnx_mgr *cm_ctx = ctx;
 
 	mlme_cm_sm_state_update(cm_ctx, WLAN_CM_S_CONNECTING, WLAN_CM_SS_IDLE);
 }
@@ -142,13 +156,17 @@ static void mlme_cm_state_connecting_exit(void *ctx)
  * Return: bool
  */
 static bool mlme_cm_state_connecting_event(void *ctx, uint16_t event,
-					   uint16_t event_data_len,
-					   void *event_data)
+					   uint16_t data_len, void *data)
 {
-//	struct cnx_mgr *cm_ctx = (struct cnx_mgr *)ctx;
+	struct cnx_mgr *cm_ctx = ctx;
 	bool status;
 
 	switch (event) {
+	case WLAN_CM_SM_EV_CONNECT_START:
+		mlme_cm_sm_transition_to(cm_ctx, WLAN_CM_SS_JOIN_PENDING);
+		mlme_cm_sm_deliver_event(cm_ctx, event, data_len, data);
+		status = true;
+		break;
 	default:
 		status = false;
 		break;
@@ -168,7 +186,7 @@ static bool mlme_cm_state_connecting_event(void *ctx, uint16_t event,
  */
 static void mlme_cm_state_connected_entry(void *ctx)
 {
-	struct cnx_mgr *cm_ctx = (struct cnx_mgr *)ctx;
+	struct cnx_mgr *cm_ctx = ctx;
 
 	mlme_cm_sm_state_update(cm_ctx, WLAN_CM_S_CONNECTED, WLAN_CM_SS_IDLE);
 }
@@ -196,13 +214,23 @@ static void mlme_cm_state_connected_exit(void *ctx)
  * Return: bool
  */
 static bool mlme_cm_state_connected_event(void *ctx, uint16_t event,
-					  uint16_t event_data_len,
-					  void *event_data)
+					  uint16_t data_len, void *data)
 {
-//	struct cnx_mgr *cm_ctx = (struct cnx_mgr *)ctx;
+	struct cnx_mgr *cm_ctx = ctx;
 	bool status;
 
 	switch (event) {
+	case WLAN_CM_SM_EV_CONNECT_SUCCESS:
+		cm_connect_complete(cm_ctx, data);
+		status = true;
+		break;
+	case WLAN_CM_SM_EV_DISCONNECT_REQ:
+		mlme_cm_sm_transition_to(cm_ctx, WLAN_CM_S_DISCONNECTING);
+		mlme_cm_sm_deliver_event(cm_ctx,
+					 WLAN_CM_SM_EV_DISCONNECT_START,
+					 data_len, data);
+		status = true;
+		break;
 	default:
 		status = false;
 		break;
@@ -222,7 +250,7 @@ static bool mlme_cm_state_connected_event(void *ctx, uint16_t event,
  */
 static void mlme_cm_state_disconnecting_entry(void *ctx)
 {
-	struct cnx_mgr *cm_ctx = (struct cnx_mgr *)ctx;
+	struct cnx_mgr *cm_ctx = ctx;
 
 	mlme_cm_sm_state_update(cm_ctx, WLAN_CM_S_DISCONNECTING,
 				WLAN_CM_SS_IDLE);
@@ -251,13 +279,25 @@ static void mlme_cm_state_disconnecting_exit(void *ctx)
  * Return: bool
  */
 static bool mlme_cm_state_disconnecting_event(void *ctx, uint16_t event,
-					      uint16_t event_data_len,
-					      void *event_data)
+					      uint16_t data_len, void *data)
 {
-//	struct cnx_mgr *cm_ctx = (struct cnx_mgr *)ctx;
+	struct cnx_mgr *cm_ctx = ctx;
 	bool status;
 
 	switch (event) {
+	case WLAN_CM_SM_EV_DISCONNECT_START:
+		cm_disconnect_start(cm_ctx, data);
+		status = true;
+		break;
+	case WLAN_CM_SM_EV_DISCONNECT_ACTIVE:
+		cm_disconnect_active(cm_ctx, data);
+		status = true;
+		break;
+	case WLAN_CM_SM_EV_DISCONNECT_DONE:
+		mlme_cm_sm_transition_to(cm_ctx, WLAN_CM_S_INIT);
+		mlme_cm_sm_deliver_event(cm_ctx, event, data_len, data);
+		status = true;
+		break;
 	default:
 		status = false;
 		break;
@@ -277,7 +317,7 @@ static bool mlme_cm_state_disconnecting_event(void *ctx, uint16_t event,
  */
 static void mlme_cm_subst_join_pending_entry(void *ctx)
 {
-	struct cnx_mgr *cm_ctx = (struct cnx_mgr *)ctx;
+	struct cnx_mgr *cm_ctx = ctx;
 
 	if (mlme_cm_get_state(cm_ctx) != WLAN_CM_S_CONNECTING)
 		QDF_BUG(0);
@@ -308,13 +348,39 @@ static void mlme_cm_subst_join_pending_exit(void *ctx)
  * Return: bool
  */
 static bool mlme_cm_subst_join_pending_event(void *ctx, uint16_t event,
-					     uint16_t event_data_len,
-					     void *event_data)
+					     uint16_t data_len, void *data)
 {
-//	struct cnx_mgr *cm_ctx = (struct cnx_mgr *)ctx;
+	struct cnx_mgr *cm_ctx = ctx;
 	bool status;
+	QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
 
 	switch (event) {
+	case WLAN_CM_SM_EV_CONNECT_START:
+		cm_connect_start(cm_ctx, data);
+		status = true;
+		break;
+	case WLAN_CM_SM_EV_CONNECT_ACTIVE:
+		mlme_cm_sm_transition_to(cm_ctx, WLAN_CM_SS_JOIN_ACTIVE);
+		mlme_cm_sm_deliver_event(cm_ctx, event, data_len, data);
+		status = true;
+		break;
+	case WLAN_CM_SM_EV_SCAN:
+		mlme_cm_sm_transition_to(cm_ctx, WLAN_CM_SS_SCAN);
+		mlme_cm_sm_deliver_event(cm_ctx, event, data_len, data);
+		status = true;
+		break;
+	case WLAN_CM_SM_EV_SCAN_FAILURE:
+		qdf_status = QDF_STATUS_E_FAILURE;
+		/* Fall through after setting status failure */
+	case WLAN_CM_SM_EV_SCAN_SUCCESS:
+		cm_connect_scan_resp(cm_ctx, data, qdf_status);
+		status = true;
+		break;
+	case WLAN_CM_SM_EV_CONNECT_FAILURE:
+		mlme_cm_sm_transition_to(cm_ctx, WLAN_CM_S_INIT);
+		mlme_cm_sm_deliver_event(cm_ctx, event, data_len, data);
+		status = true;
+		break;
 	default:
 		status = false;
 		break;
@@ -334,7 +400,7 @@ static bool mlme_cm_subst_join_pending_event(void *ctx, uint16_t event,
  */
 static void mlme_cm_subst_scan_entry(void *ctx)
 {
-	struct cnx_mgr *cm_ctx = (struct cnx_mgr *)ctx;
+	struct cnx_mgr *cm_ctx = ctx;
 
 	if (mlme_cm_get_state(cm_ctx) != WLAN_CM_S_CONNECTING)
 		QDF_BUG(0);
@@ -365,12 +431,22 @@ static void mlme_cm_subst_scan_exit(void *ctx)
  * Return: bool
  */
 static bool mlme_cm_subst_scan_event(void *ctx, uint16_t event,
-				     uint16_t event_data_len, void *event_data)
+				     uint16_t data_len, void *data)
 {
-//	struct cnx_mgr *cm_ctx = (struct cnx_mgr *)ctx;
+	struct cnx_mgr *cm_ctx = ctx;
 	bool status;
 
 	switch (event) {
+	case WLAN_CM_SM_EV_SCAN:
+		cm_connect_scan_start(cm_ctx, data);
+		status = true;
+		break;
+	case WLAN_CM_SM_EV_SCAN_SUCCESS:
+	case WLAN_CM_SM_EV_SCAN_FAILURE:
+		mlme_cm_sm_transition_to(cm_ctx, WLAN_CM_SS_JOIN_PENDING);
+		mlme_cm_sm_deliver_event(cm_ctx, event, data_len, data);
+		status = true;
+		break;
 	default:
 		status = false;
 		break;
@@ -390,7 +466,7 @@ static bool mlme_cm_subst_scan_event(void *ctx, uint16_t event,
  */
 static void mlme_cm_subst_join_active_entry(void *ctx)
 {
-	struct cnx_mgr *cm_ctx = (struct cnx_mgr *)ctx;
+	struct cnx_mgr *cm_ctx = ctx;
 
 	if (mlme_cm_get_state(cm_ctx) != WLAN_CM_S_CONNECTING)
 		QDF_BUG(0);
@@ -421,13 +497,30 @@ static void mlme_cm_subst_join_active_exit(void *ctx)
  * Return: bool
  */
 static bool mlme_cm_subst_join_active_event(void *ctx, uint16_t event,
-					    uint16_t event_data_len,
-					    void *event_data)
+					    uint16_t data_len, void *data)
 {
-//	struct cnx_mgr *cm_ctx = (struct cnx_mgr *)ctx;
+	struct cnx_mgr *cm_ctx = ctx;
 	bool status;
 
 	switch (event) {
+	case WLAN_CM_SM_EV_CONNECT_ACTIVE:
+		cm_connect_active(cm_ctx, data);
+		status = true;
+		break;
+	case WLAN_CM_SM_EV_CONNECT_SUCCESS:
+		mlme_cm_sm_transition_to(cm_ctx, WLAN_CM_S_CONNECTED);
+		mlme_cm_sm_deliver_event(cm_ctx, event, data_len, data);
+		status = true;
+		break;
+	case WLAN_CM_SM_EV_CONNECT_GET_NEXT_CANDIDATE:
+		cm_try_next_candidate(cm_ctx, data);
+		status = true;
+		break;
+	case WLAN_CM_SM_EV_CONNECT_FAILURE:
+		mlme_cm_sm_transition_to(cm_ctx, WLAN_CM_S_INIT);
+		mlme_cm_sm_deliver_event(cm_ctx, event, data_len, data);
+		status = true;
+		break;
 	default:
 		status = false;
 		break;
@@ -595,17 +688,17 @@ struct wlan_sm_state_info cm_sm_info[] = {
 
 static const char *cm_sm_event_names[] = {
 	"EV_CONNECT_REQ",
-	"EV_SCAN_FOR_SSID",
-	"EV_SCAN_FOR_SSID_SUCCESS",
-	"EV_SCAN_FOR_SSID_FAILURE",
-	"EV_CONNECT_START_REQ",
+	"EV_SCAN",
+	"EV_SCAN_SUCCESS",
+	"EV_SCAN_FAILURE",
 	"EV_CONNECT_START",
+	"EV_CONNECT_ACTIVE",
 	"EV_CONNECT_SUCCESS",
-	"EV_CONNECT_NEXT_CANDIDATE",
+	"EV_CONNECT_GET_NXT_CANDIDATE",
 	"EV_CONNECT_FAILURE",
 	"EV_DISCONNECT_REQ",
-	"EV_DISCONNECT_START_REQ",
 	"EV_DISCONNECT_START",
+	"EV_DISCONNECT_ACTIVE",
 	"EV_DISCONNECT_DONE",
 	"EV_ROAM_START",
 	"EV_ROAM_SYNC",
@@ -618,9 +711,6 @@ static const char *cm_sm_event_names[] = {
 	"EV_REASSOC_DONE",
 	"EV_REASSOC_FAILURE",
 	"EV_ROAM_COMPLETE",
-	"EV_CONNECT_TIMEOUT",
-	"EV_CONNECT_SER_FAIL",
-	"EV_HW_MODE_CHANGE_FAIL",
 };
 
 enum wlan_cm_sm_state mlme_cm_get_state(struct cnx_mgr *cm_ctx)
@@ -653,15 +743,6 @@ enum wlan_cm_sm_state mlme_cm_get_sub_state(struct cnx_mgr *cm_ctx)
 	return cm_ctx->sm.cm_substate;
 }
 
-static inline
-QDF_STATUS mlme_cm_sm_deliver_event(struct cnx_mgr *cm_ctx,
-				    enum wlan_cm_sm_evt event,
-				    uint16_t event_data_len, void *event_data)
-{
-	return wlan_sm_dispatch(cm_ctx->sm.sm_hdl, event,
-				event_data_len, event_data);
-}
-
 static void mlme_cm_sm_print_state_event(struct cnx_mgr *cm_ctx,
 					 enum wlan_cm_sm_evt event)
 {
@@ -688,10 +769,9 @@ static void mlme_cm_sm_print_state(struct cnx_mgr *cm_ctx)
 			cm_sm_info[state].name, cm_sm_info[substate].name);
 }
 
-QDF_STATUS mlme_cm_sm_deliver_evt(struct wlan_objmgr_vdev *vdev,
-				  enum wlan_cm_sm_evt event,
-				  uint16_t event_data_len,
-				  void *event_data)
+QDF_STATUS wlan_mlme_cm_sm_deliver_evt(struct wlan_objmgr_vdev *vdev,
+				       enum wlan_cm_sm_evt event,
+				       uint16_t data_len, void *data)
 {
 	struct vdev_mlme_obj *vdev_mlme;
 	QDF_STATUS status;
@@ -718,8 +798,7 @@ QDF_STATUS mlme_cm_sm_deliver_evt(struct wlan_objmgr_vdev *vdev,
 	substate_entry = mlme_cm_get_sub_state(cm_ctx);
 	mlme_cm_sm_print_state_event(cm_ctx, event);
 
-	status = mlme_cm_sm_deliver_event(cm_ctx, event, event_data_len,
-					  event_data);
+	status = mlme_cm_sm_deliver_event(cm_ctx, event, data_len, data);
 	/* Take exit state, exit substate for prints */
 	state_exit = mlme_cm_get_state(cm_ctx);
 	substate_exit = mlme_cm_get_sub_state(cm_ctx);

+ 26 - 7
umac/mlme/connection_mgr/core/src/wlan_cm_sm.h

@@ -217,21 +217,40 @@ void mlme_cm_sm_state_update(struct cnx_mgr *cm_ctx,
 			     enum wlan_cm_sm_state substate);
 
 /**
- * mlme_cm_sm_deliver_evt() - Delivers event to CM SM
+ * mlme_cm_sm_deliver_event() - Delivers event to connection manager SM
+ * @cm_ctx: cm ctx
+ * @event: CM event
+ * @data_len: data size
+ * @data: event data
+ *
+ * API to dispatch event to VDEV MLME SM without lock
+ *
+ * Return: SUCCESS: on handling event
+ *         FAILURE: on ignoring the event
+ */
+static inline
+QDF_STATUS mlme_cm_sm_deliver_event(struct cnx_mgr *cm_ctx,
+				    enum wlan_cm_sm_evt event,
+				    uint16_t data_len, void *data)
+{
+	return wlan_sm_dispatch(cm_ctx->sm.sm_hdl, event, data_len, data);
+}
+
+/**
+ * wlan_mlme_cm_sm_deliver_evt() - Delivers event to CM SM
  * @vdev: Object manager VDEV object
  * @event: CM event
- * @event_data_len: data size
- * @event_data: event data
+ * @data_len: data size
+ * @data: event data
  *
  * API to dispatch event to VDEV MLME SM with lock acquired
  *
  * Return: SUCCESS: on handling event
  *         FAILURE: on ignoring the event
  */
-QDF_STATUS mlme_cm_sm_deliver_evt(struct wlan_objmgr_vdev *vdev,
-				  enum wlan_cm_sm_evt event,
-				  uint16_t event_data_len,
-				  void *event_data);
+QDF_STATUS wlan_mlme_cm_sm_deliver_evt(struct wlan_objmgr_vdev *vdev,
+				       enum wlan_cm_sm_evt event,
+				       uint16_t data_len, void *data);
 
 #endif /* FEATURE_CM_ENABLE */
 #endif /* __WLAN_CM_SM_H__ */

+ 5 - 3
umac/mlme/connection_mgr/dispatcher/inc/wlan_cm_public_struct.h

@@ -26,6 +26,8 @@
 #ifdef FEATURE_CM_ENABLE
 #include <wlan_scan_public_structs.h>
 
+typedef uint32_t wlan_cm_id;
+
 /**
  * struct wlan_cm_wep_key_params - store wep key info
  * @key: key info
@@ -170,7 +172,7 @@ struct wlan_cm_connect_req {
  */
 struct wlan_cm_vdev_connect_req {
 	uint8_t vdev_id;
-	uint8_t cm_id;
+	wlan_cm_id cm_id;
 	struct scan_cache_node *bss;
 };
 
@@ -197,7 +199,7 @@ struct wlan_cm_disconnect_req {
  * @req: disconnect req
  */
 struct wlan_cm_vdev_discon_req {
-	uint8_t cm_id;
+	wlan_cm_id cm_id;
 	struct wlan_cm_disconnect_req req;
 };
 
@@ -299,7 +301,7 @@ struct wlan_connect_rsp_ies {
  */
 struct wlan_cm_connect_rsp {
 	uint8_t vdev_id;
-	uint8_t cm_id;
+	wlan_cm_id cm_id;
 	uint8_t connect_status;
 	enum wlan_cm_connect_fail_reason reason;
 	uint8_t reason_code;