فهرست منبع

qcacmn: Add change to support logging request to conn_mgr

Support logging history of the requests being sent to connection
manager.

Change-Id: Ifcc3a460e7694f6b6feb1b35121e6fc8e3333935
CRs-Fixed: 2860578
Santosh Anbu 4 سال پیش
والد
کامیت
2f71a62bab

+ 2 - 0
umac/mlme/connection_mgr/core/src/wlan_cm_main.c

@@ -107,6 +107,7 @@ QDF_STATUS wlan_cm_init(struct vdev_mlme_obj *vdev_mlme)
 					     wlan_cm_scan_cb,
 					     vdev_mlme->cnx_mgr_ctx);
 	qdf_event_create(&vdev_mlme->cnx_mgr_ctx->disconnect_complete);
+	cm_req_history_init(vdev_mlme->cnx_mgr_ctx);
 
 	return QDF_STATUS_SUCCESS;
 }
@@ -121,6 +122,7 @@ QDF_STATUS wlan_cm_deinit(struct vdev_mlme_obj *vdev_mlme)
 	if (op_mode != QDF_STA_MODE && op_mode != QDF_P2P_CLIENT_MODE)
 		return QDF_STATUS_SUCCESS;
 
+	cm_req_history_deinit(vdev_mlme->cnx_mgr_ctx);
 	qdf_event_destroy(&vdev_mlme->cnx_mgr_ctx->disconnect_complete);
 	scan_requester_id = vdev_mlme->cnx_mgr_ctx->scan_requester_id;
 	wlan_scan_unregister_requester(psoc,

+ 54 - 0
umac/mlme/connection_mgr/core/src/wlan_cm_main.h

@@ -179,6 +179,56 @@ struct connect_ies {
 	struct element_info discon_ie;
 };
 
+/**
+ * enum cm_req_del_type - Context in which a request is removed from
+ * connection manager request list
+ * @CM_REQ_DEL_ACTIVE: Remove request from active queue
+ * @CM_REQ_DEL_PENDING: Remove request from pending queue
+ * @CM_REQ_DEL_FLUSH: Request removed due to request list flush
+ */
+enum cm_req_del_type {
+	CM_REQ_DEL_ACTIVE,
+	CM_REQ_DEL_PENDING,
+	CM_REQ_DEL_FLUSH,
+	CM_REQ_DEL_MAX,
+};
+
+#ifdef SM_ENG_HIST_ENABLE
+
+#define CM_REQ_HISTORY_SIZE 30
+
+/**
+ * struct cm_req_history_info - History element structure
+ * @cm_id: Request id
+ * @add_time: Timestamp when the request was added to the list
+ * @del_time: Timestamp when the request was removed from list
+ * @add_cm_state: Conn_SM state when req was added
+ * @del_cm_state: Conn_SM state when req was deleted
+ * @del_type: Context in which delete was triggered. i.e active removal,
+ * pending removal or flush from queue.
+ */
+struct cm_req_history_info {
+	wlan_cm_id cm_id;
+	uint64_t add_time;
+	uint64_t del_time;
+	enum wlan_cm_sm_state add_cm_state;
+	enum wlan_cm_sm_state del_cm_state;
+	enum cm_req_del_type del_type;
+};
+
+/**
+ * struct cm_req_history - Connection manager history
+ * @cm_req_hist_lock: CM request history lock
+ * @index: Index of next entry that will be updated
+ * @data: Array of history element
+ */
+struct cm_req_history {
+	qdf_spinlock_t cm_req_hist_lock;
+	uint8_t index;
+	struct cm_req_history_info data[CM_REQ_HISTORY_SIZE];
+};
+#endif
+
 /**
  * struct cnx_mgr - connect manager req
  * @vdev: vdev back pointer
@@ -198,6 +248,7 @@ struct connect_ies {
  * @scan_requester_id: scan requester id.
  * @disconnect_complete: disconnect completion wait event
  * @ext_cm_ptr: connection manager ext pointer
+ * @history: Holds the connection manager history
  */
 struct cnx_mgr {
 	struct wlan_objmgr_vdev *vdev;
@@ -219,6 +270,9 @@ struct cnx_mgr {
 	wlan_scan_requester scan_requester_id;
 	qdf_event_t disconnect_complete;
 	cm_ext_t *ext_cm_ptr;
+#ifdef SM_ENG_HIST_ENABLE
+	struct cm_req_history req_history;
+#endif
 };
 
 /**

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

@@ -963,4 +963,73 @@ void cm_req_lock_acquire(struct cnx_mgr *cm_ctx);
  * Return: void
  */
 void cm_req_lock_release(struct cnx_mgr *cm_ctx);
+
+#ifdef SM_ENG_HIST_ENABLE
+/**
+ * cm_req_history_add() - Save request history
+ * @cm_ctx: Connection manager context
+ * @cm_req: Connection manager request
+ *
+ * Return: void
+ */
+void cm_req_history_add(struct cnx_mgr *cm_ctx,
+			struct cm_req *cm_req);
+/**
+ * cm_req_history_del() - Update history on request deletion
+ * @cm_ctx: Connection manager context
+ * @cm_req: Connection manager request
+ * @del_type: Context in which the request is deleted
+ *
+ * Return: void
+ */
+void cm_req_history_del(struct cnx_mgr *cm_ctx,
+			struct cm_req *cm_req,
+			enum cm_req_del_type del_type);
+
+/**
+ * cm_history_init() - Initialize the history data struct
+ * @cm_ctx: Connection manager context
+ *
+ * Return: void
+ */
+void cm_req_history_init(struct cnx_mgr *cm_ctx);
+
+/**
+ * cm_history_deinit() - Deinitialize the history data struct
+ * @cm_ctx: Connection manager context
+ *
+ * Return: void
+ */
+void cm_req_history_deinit(struct cnx_mgr *cm_ctx);
+
+/**
+ * cm_history_print() - Print the history data struct
+ * @cm_ctx: Connection manager context
+ *
+ * Return: void
+ */
+void cm_req_history_print(struct cnx_mgr *cm_ctx);
+extern struct wlan_sm_state_info cm_sm_info[];
+#else
+static inline
+void cm_req_history_add(struct cnx_mgr *cm_ctx,
+			struct cm_req *cm_req)
+{}
+
+static inline
+void cm_req_history_del(struct cnx_mgr *cm_ctx,
+			struct cm_req *cm_req,
+			enum cm_req_del_type del_type)
+{}
+
+static inline void cm_req_history_init(struct cnx_mgr *cm_ctx)
+{}
+
+static inline void cm_req_history_deinit(struct cnx_mgr *cm_ctx)
+{}
+
+static inline void cm_req_history_print(struct cnx_mgr *cm_ctx)
+{}
+#endif
+
 #endif /* __WLAN_CM_MAIN_API_H__ */

+ 117 - 0
umac/mlme/connection_mgr/core/src/wlan_cm_util.c

@@ -534,6 +534,8 @@ cm_flush_pending_request(struct cnx_mgr *cm_ctx, uint32_t prefix,
 			cm_handle_disconnect_flush(cm_ctx, cm_req);
 			cm_ctx->disconnect_count--;
 		}
+
+		cm_req_history_del(cm_ctx, cm_req, CM_REQ_DEL_FLUSH);
 		mlme_debug(CM_PREFIX_FMT,
 			   CM_PREFIX_REF(wlan_vdev_get_id(cm_ctx->vdev),
 					 cm_req->cm_id));
@@ -638,6 +640,7 @@ QDF_STATUS cm_add_req_to_list_and_indicate_osif(struct cnx_mgr *cm_ctx,
 	else if (prefix == DISCONNECT_REQ_PREFIX)
 		cm_ctx->disconnect_count++;
 
+	cm_req_history_add(cm_ctx, cm_req);
 	cm_req_lock_release(cm_ctx);
 	mlme_debug(CM_PREFIX_FMT,
 		   CM_PREFIX_REF(wlan_vdev_get_id(cm_ctx->vdev),
@@ -714,6 +717,12 @@ cm_delete_req_from_list(struct cnx_mgr *cm_ctx, wlan_cm_id cm_id)
 	} else {
 		cm_ctx->disconnect_count--;
 	}
+
+	if (cm_id == cm_ctx->active_cm_id)
+		cm_req_history_del(cm_ctx, cm_req, CM_REQ_DEL_ACTIVE);
+	else
+		cm_req_history_del(cm_ctx, cm_req, CM_REQ_DEL_PENDING);
+
 	mlme_debug(CM_PREFIX_FMT,
 		   CM_PREFIX_REF(wlan_vdev_get_id(cm_ctx->vdev),
 				 cm_req->cm_id));
@@ -1260,3 +1269,111 @@ void cm_calculate_scores(struct wlan_objmgr_pdev *pdev,
 	wlan_cm_calculate_bss_score(pdev, NULL, list, &filter->bssid_hint);
 }
 #endif
+
+#ifdef SM_ENG_HIST_ENABLE
+static const char *cm_id_to_string(wlan_cm_id cm_id)
+{
+	uint32_t prefix = CM_ID_GET_PREFIX(cm_id);
+
+	switch (prefix) {
+	case CONNECT_REQ_PREFIX:
+		return "CONNECT";
+	case DISCONNECT_REQ_PREFIX:
+		return "DISCONNECT";
+	case ROAM_REQ_PREFIX:
+		return "ROAM";
+	default:
+		return "INVALID";
+	}
+}
+
+void cm_req_history_add(struct cnx_mgr *cm_ctx,
+			struct cm_req *cm_req)
+{
+	struct cm_req_history *history = &cm_ctx->req_history;
+	struct cm_req_history_info *data;
+
+	qdf_spin_lock_bh(&history->cm_req_hist_lock);
+	data = &history->data[history->index];
+	history->index++;
+	history->index %= CM_REQ_HISTORY_SIZE;
+
+	qdf_mem_zero(data, sizeof(*data));
+	data->cm_id = cm_req->cm_id;
+	data->add_time = qdf_get_log_timestamp();
+	data->add_cm_state = cm_get_state(cm_ctx);
+	qdf_spin_unlock_bh(&history->cm_req_hist_lock);
+}
+
+void cm_req_history_del(struct cnx_mgr *cm_ctx,
+			struct cm_req *cm_req,
+			enum cm_req_del_type del_type)
+{
+	uint8_t i, idx;
+	struct cm_req_history_info *data;
+	struct cm_req_history *history = &cm_ctx->req_history;
+
+	qdf_spin_lock_bh(&history->cm_req_hist_lock);
+	for (i = 0; i < CM_REQ_HISTORY_SIZE; i++) {
+		if (history->index < i)
+			idx = CM_REQ_HISTORY_SIZE + history->index - i;
+		else
+			idx = history->index - i;
+
+		data = &history->data[idx];
+		if (data->cm_id == cm_req->cm_id) {
+			data->del_time = qdf_get_log_timestamp();
+			data->del_cm_state = cm_get_state(cm_ctx);
+			data->del_type = del_type;
+			break;
+		}
+
+		if (!data->cm_id)
+			break;
+	}
+	qdf_spin_unlock_bh(&history->cm_req_hist_lock);
+}
+
+void cm_req_history_init(struct cnx_mgr *cm_ctx)
+{
+	qdf_spinlock_create(&cm_ctx->req_history.cm_req_hist_lock);
+	qdf_mem_zero(&cm_ctx->req_history, sizeof(struct cm_req_history));
+}
+
+void cm_req_history_deinit(struct cnx_mgr *cm_ctx)
+{
+	qdf_spinlock_destroy(&cm_ctx->req_history.cm_req_hist_lock);
+}
+
+static inline void cm_req_history_print_entry(uint16_t idx,
+					      struct cm_req_history_info *data)
+{
+	if (!data->cm_id)
+		return;
+
+	mlme_nofl_err("    |%6u | 0x%016llx | 0x%016llx |%12s | 0x%08x |%15s |%15s |%8u",
+		      idx, data->add_time, data->del_time,
+		      cm_id_to_string(data->cm_id), data->cm_id,
+		      cm_sm_info[data->add_cm_state].name,
+		      cm_sm_info[data->del_cm_state].name,
+		      data->del_type);
+}
+
+void cm_req_history_print(struct cnx_mgr *cm_ctx)
+{
+	struct cm_req_history *history = &cm_ctx->req_history;
+	uint8_t i, idx;
+
+	mlme_nofl_err("CM Request history is as below");
+	mlme_nofl_err("|%6s |%19s |%19s |%12s |%11s |%15s |%15s |%8s",
+		      "Index", "Add Time", "Del Time", "Req type",
+		      "Cm Id", "Add State", "Del State", "Del Type");
+
+	qdf_spin_lock_bh(&history->cm_req_hist_lock);
+	for (i = 0; i < CM_REQ_HISTORY_SIZE; i++) {
+		idx = (history->index + i) % CM_REQ_HISTORY_SIZE;
+		cm_req_history_print_entry(idx, &history->data[idx]);
+	}
+	qdf_spin_unlock_bh(&history->cm_req_hist_lock);
+}
+#endif

+ 15 - 1
umac/mlme/connection_mgr/dispatcher/inc/wlan_cm_api.h

@@ -370,6 +370,7 @@ void wlan_cm_hw_mode_change_resp(struct wlan_objmgr_pdev *pdev, uint8_t vdev_id,
 				 wlan_cm_id cm_id, QDF_STATUS status);
 #endif /* ifdef POLICY_MGR_ENABLE */
 
+#ifdef SM_ENG_HIST_ENABLE
 /**
  * wlan_cm_sm_history_print() - Prints SM history
  * @vdev: Objmgr vdev
@@ -378,13 +379,26 @@ void wlan_cm_hw_mode_change_resp(struct wlan_objmgr_pdev *pdev, uint8_t vdev_id,
  *
  * Return: void
  */
-#ifdef SM_ENG_HIST_ENABLE
 void wlan_cm_sm_history_print(struct wlan_objmgr_vdev *vdev);
+
+/**
+ * wlan_cm_req_history_print() - Prints CM request history
+ * @vdev: Objmgr vdev
+ *
+ * API to print CM request history
+ *
+ * Return: void
+ */
+void wlan_cm_req_history_print(struct wlan_objmgr_vdev *vdev);
 #else
 static inline void wlan_cm_sm_history_print(struct wlan_objmgr_vdev *vdev)
 {
 }
+
+static inline void wlan_cm_req_history_print(struct wlan_objmgr_vdev *vdev)
+{}
 #endif
+
 #else
 
 #ifdef WLAN_POLICY_MGR_ENABLE

+ 8 - 1
umac/mlme/connection_mgr/dispatcher/src/wlan_cm_api.c

@@ -302,4 +302,11 @@ void wlan_cm_sm_history_print(struct wlan_objmgr_vdev *vdev)
 {
 	return cm_sm_history_print(vdev);
 }
-#endif
+
+void wlan_cm_req_history_print(struct wlan_objmgr_vdev *vdev)
+{
+	struct cnx_mgr *cm_ctx = cm_get_cm_ctx(vdev);
+
+	cm_req_history_print(cm_ctx);
+}
+#endif /* SM_ENG_HIST_ENABLE */