[feature-wisun] Added API to reset MAC and Wi-SUN statistics.

pull/14439/head
Debdeep Saha 2021-03-17 19:56:20 +05:30 committed by Debdeep Saha
parent 62b57abd67
commit 11caebcc04
9 changed files with 99 additions and 0 deletions

View File

@ -559,6 +559,16 @@ public:
* */
mesh_error_t enable_statistics(void);
/**
* \brief Reset Wi-SUN statistics
*
* Resets MAC statistics and Wi-SUN statistics.
*
* \return MESH_ERROR_NONE on success.
* \return MESH_ERROR_UNKNOWN on error
* */
mesh_error_t reset_statistics(void);
/**
* \brief Reads Wi-SUN network statistics
*

View File

@ -603,6 +603,16 @@ mesh_error_t WisunInterface::enable_statistics(void)
return ret_val;
}
mesh_error_t WisunInterface::reset_statistics(void)
{
mesh_error_t ret_val = MESH_ERROR_NONE;
int status = wisun_tasklet_statistics_reset();
if (status < 0) {
ret_val = MESH_ERROR_UNKNOWN;
}
return ret_val;
}
mesh_error_t WisunInterface::read_nw_statistics(mesh_nw_statistics_t *statistics)
{
mesh_error_t ret_val = MESH_ERROR_NONE;

View File

@ -125,6 +125,14 @@ int wisun_tasklet_remove_trusted_certificates(void);
*/
int wisun_tasklet_statistics_start(void);
/*
* \brief Reset Wi-SUN statistics
*
* \return 0 Statistics start successful
* \return < 0 in case of errors
*/
int wisun_tasklet_statistics_reset(void);
/*
* \brief Reads Wi-SUN network statistics
*

View File

@ -624,6 +624,22 @@ int wisun_tasklet_statistics_start(void)
return 0;
}
int wisun_tasklet_statistics_reset(void)
{
if (!wisun_tasklet_data_ptr || wisun_tasklet_data_ptr->network_interface_id < 0 || !mac_api) {
return -1;
}
if (ns_sw_mac_statistics_reset(mac_api) < 0) {
return -1;
}
if (ws_statistics_reset(wisun_tasklet_data_ptr->network_interface_id) < 0) {
return -1;
}
return 0;
}
static void wisun_tasklet_statistics_do_start(void)
{
if (!wisun_tasklet_data_ptr || wisun_tasklet_data_ptr->network_interface_id < 0 || !mac_api) {

View File

@ -89,6 +89,13 @@ extern struct fhss_api *ns_sw_mac_get_fhss_api(struct mac_api_s *mac_api);
*/
extern int ns_sw_mac_statistics_start(struct mac_api_s *mac_api, struct mac_statistics_s *mac_statistics);
/**
* @brief Reset all statistics from software MAC.
* @param mac_api MAC instance.
* @return 0 on success, -1 on fail.
*/
extern int ns_sw_mac_statistics_reset(struct mac_api_s *mac_api);
/**
* @brief Start collecting statistics from PHY driver.
* @param mac_api MAC instance.

View File

@ -727,6 +727,16 @@ int ws_statistics_start(
int8_t interface_id,
ws_statistics_t *stats_ptr);
/**
* Reset Wi-SUN statistics.
*
* \param interface_id Network interface ID.
*
* \return 0 Success.
* \return <0 Failure.
*/
int ws_statistics_reset(int8_t interface_id);
/**
* Stop collecting Wi-SUN statistics.
*

View File

@ -434,6 +434,12 @@ int ws_statistics_start(int8_t interface_id, ws_statistics_t *stats_ptr)
return -1;
}
int ws_statistics_reset(int8_t interface_id)
{
(void) interface_id;
return -1;
}
int ws_statistics_stop(int8_t interface_id)
{
(void) interface_id;

View File

@ -49,6 +49,21 @@ int ws_statistics_stop(int8_t interface_id)
return 0;
}
int ws_statistics_reset(int8_t interface_id)
{
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
if (!cur || !ws_info(cur)) {
return -1;
}
if (cur->ws_info->stored_stats_ptr == NULL) {
/* Wi-SUN statistics is not started */
return 0;
}
cur->ws_info->stored_stats_ptr->asynch_rx_count = 0;
cur->ws_info->stored_stats_ptr->asynch_tx_count = 0;
return 0;
}
void ws_stats_update(protocol_interface_info_entry_t *cur, ws_stats_type_t type, uint32_t update_val)
{
if (!cur || !ws_info(cur)) {

View File

@ -255,6 +255,23 @@ int ns_sw_mac_statistics_start(struct mac_api_s *mac_api, struct mac_statistics_
return 0;
}
int ns_sw_mac_statistics_reset(struct mac_api_s *mac_api)
{
if (!mac_api) {
return -1;
}
protocol_interface_rf_mac_setup_s *mac_setup = get_sw_mac_ptr_by_mac_api(mac_api);
if (!mac_setup) {
return -1;
}
if (mac_setup->mac_statistics == NULL) {
/* MAC statics is not started */
return 0;
}
memset(mac_setup->mac_statistics, 0, sizeof(struct mac_statistics_s));
return 0;
}
static int8_t ns_sw_mac_initialize(mac_api_t *api, mcps_data_confirm *mcps_data_conf_cb,
mcps_data_indication *mcps_data_ind_cb, mcps_purge_confirm *mcps_purge_conf_cb,
mlme_confirm *mlme_conf_callback, mlme_indication *mlme_ind_callback, int8_t parent_id)