diff --git a/umac/cmn_services/sm_engine/inc/wlan_sm_engine_dbg.h b/umac/cmn_services/sm_engine/inc/wlan_sm_engine_dbg.h index 1588df1648bf..512b860532c2 100644 --- a/umac/cmn_services/sm_engine/inc/wlan_sm_engine_dbg.h +++ b/umac/cmn_services/sm_engine/inc/wlan_sm_engine_dbg.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2018-2019 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 @@ -73,7 +73,7 @@ enum wlan_sm_trace_type { */ struct wlan_sm_history_info { enum wlan_sm_trace_type trace_type; - uint16_t event_type; + uint8_t event_type; uint8_t initial_state; uint8_t final_state; }; @@ -86,7 +86,7 @@ struct wlan_sm_history_info { */ struct wlan_sm_history { qdf_spinlock_t sm_history_lock; - int index; + uint8_t index; struct wlan_sm_history_info data[WLAN_SM_ENGINE_HISTORY_SIZE]; }; diff --git a/umac/cmn_services/sm_engine/src/wlan_sm_engine_dbg.c b/umac/cmn_services/sm_engine/src/wlan_sm_engine_dbg.c index ac6701abcba8..3676d0c70650 100644 --- a/umac/cmn_services/sm_engine/src/wlan_sm_engine_dbg.c +++ b/umac/cmn_services/sm_engine/src/wlan_sm_engine_dbg.c @@ -36,8 +36,7 @@ void wlan_sm_save_history(struct wlan_sm *sm, p_memento = &p_sm_history->data[p_sm_history->index]; p_sm_history->index++; - if (p_sm_history->index >= WLAN_SM_ENGINE_HISTORY_SIZE) - p_sm_history->index = 0; + p_sm_history->index %= WLAN_SM_ENGINE_HISTORY_SIZE; qdf_spin_unlock_bh(&p_sm_history->sm_history_lock); @@ -51,6 +50,7 @@ void wlan_sm_save_history(struct wlan_sm *sm, void wlan_sm_history_init(struct wlan_sm *sm) { qdf_spinlock_create(&sm->history.sm_history_lock); + qdf_mem_zero(&sm->history, sizeof(struct wlan_sm_history)); } void wlan_sm_history_delete(struct wlan_sm *sm) @@ -68,36 +68,51 @@ static void wlan_sm_print_history_entry(struct wlan_sm *sm, if (ent->event_type < sm->num_event_names) event_name = sm->event_names[ent->event_type]; - sm_engine_nofl_info(" (%d) trace_type: %d, event:%s[%d]", i, - ent->trace_type, - event_name ? event_name : "UNKNOWN_EVENT", - ent->event_type); - } else { - sm_engine_nofl_info(" (%d) trace_type: %d, event: %d", i, - ent->trace_type, ent->event_type); - } + if (!ent->trace_type) + return; - sm_engine_nofl_info(" (%d) initial state :%s[%d], final state: %s[%d]", - i, sm->state_info[ent->initial_state].name, - ent->initial_state, - sm->state_info[ent->final_state].name, - ent->final_state); + sm_engine_nofl_err( + "|%6d |%11d |%23s[%3d] |%19s[%2d] |%19s[%2d] |", + i, ent->trace_type, + event_name ? event_name : "UNKNOWN_EVENT", + ent->event_type, + sm->state_info[ent->initial_state].name, + ent->initial_state, + sm->state_info[ent->final_state].name, + ent->final_state); + } else { + sm_engine_nofl_err( + "|%6d |%11d |%28d |%19s[%2d] |%19s[%2d] |", + i, ent->trace_type, + ent->event_type, + sm->state_info[ent->initial_state].name, + ent->initial_state, + sm->state_info[ent->final_state].name, + ent->final_state); + } } void wlan_sm_print_history(struct wlan_sm *sm) { struct wlan_sm_history *p_sm_history = &sm->history; - uint16_t i; + uint8_t i; + uint8_t idx; /* * History saved in circular buffer. * Save a pointer to next write location and increment pointer. */ qdf_spin_lock_bh(&p_sm_history->sm_history_lock); - sm_engine_nofl_info("%s: SM History index is %d", - sm->name, p_sm_history->index); - for (i = 0; i < WLAN_SM_ENGINE_HISTORY_SIZE; i++) - wlan_sm_print_history_entry(sm, &p_sm_history->data[i], i); + + sm_engine_nofl_err("|%6s |%11s |%28s |%23s |%23s |", "Index", + "Trace Type", "Event", + "Initial State", "Final State"); + + for (i = 0; i < WLAN_SM_ENGINE_HISTORY_SIZE; i++) { + idx = (p_sm_history->index + i) % WLAN_SM_ENGINE_HISTORY_SIZE; + wlan_sm_print_history_entry( + sm, &p_sm_history->data[idx], idx); + } qdf_spin_unlock_bh(&p_sm_history->sm_history_lock); }