Skip to content

Commit 11caebc

Browse files
debdeep-armDebdeep Saha
authored andcommitted
[feature-wisun] Added API to reset MAC and Wi-SUN statistics.
1 parent 62b57ab commit 11caebc

File tree

9 files changed

+99
-0
lines changed

9 files changed

+99
-0
lines changed

features/nanostack/mbed-mesh-api/mbed-mesh-api/WisunInterface.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,16 @@ class WisunInterface : public MeshInterfaceNanostack {
559559
* */
560560
mesh_error_t enable_statistics(void);
561561

562+
/**
563+
* \brief Reset Wi-SUN statistics
564+
*
565+
* Resets MAC statistics and Wi-SUN statistics.
566+
*
567+
* \return MESH_ERROR_NONE on success.
568+
* \return MESH_ERROR_UNKNOWN on error
569+
* */
570+
mesh_error_t reset_statistics(void);
571+
562572
/**
563573
* \brief Reads Wi-SUN network statistics
564574
*

features/nanostack/mbed-mesh-api/source/WisunInterface.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,16 @@ mesh_error_t WisunInterface::enable_statistics(void)
603603
return ret_val;
604604
}
605605

606+
mesh_error_t WisunInterface::reset_statistics(void)
607+
{
608+
mesh_error_t ret_val = MESH_ERROR_NONE;
609+
int status = wisun_tasklet_statistics_reset();
610+
if (status < 0) {
611+
ret_val = MESH_ERROR_UNKNOWN;
612+
}
613+
return ret_val;
614+
}
615+
606616
mesh_error_t WisunInterface::read_nw_statistics(mesh_nw_statistics_t *statistics)
607617
{
608618
mesh_error_t ret_val = MESH_ERROR_NONE;

features/nanostack/mbed-mesh-api/source/include/wisun_tasklet.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ int wisun_tasklet_remove_trusted_certificates(void);
125125
*/
126126
int wisun_tasklet_statistics_start(void);
127127

128+
/*
129+
* \brief Reset Wi-SUN statistics
130+
*
131+
* \return 0 Statistics start successful
132+
* \return < 0 in case of errors
133+
*/
134+
int wisun_tasklet_statistics_reset(void);
135+
128136
/*
129137
* \brief Reads Wi-SUN network statistics
130138
*

features/nanostack/mbed-mesh-api/source/wisun_tasklet.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,22 @@ int wisun_tasklet_statistics_start(void)
624624
return 0;
625625
}
626626

627+
int wisun_tasklet_statistics_reset(void)
628+
{
629+
if (!wisun_tasklet_data_ptr || wisun_tasklet_data_ptr->network_interface_id < 0 || !mac_api) {
630+
return -1;
631+
}
632+
633+
if (ns_sw_mac_statistics_reset(mac_api) < 0) {
634+
return -1;
635+
}
636+
if (ws_statistics_reset(wisun_tasklet_data_ptr->network_interface_id) < 0) {
637+
return -1;
638+
}
639+
640+
return 0;
641+
}
642+
627643
static void wisun_tasklet_statistics_do_start(void)
628644
{
629645
if (!wisun_tasklet_data_ptr || wisun_tasklet_data_ptr->network_interface_id < 0 || !mac_api) {

features/nanostack/sal-stack-nanostack/nanostack/sw_mac.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ extern struct fhss_api *ns_sw_mac_get_fhss_api(struct mac_api_s *mac_api);
8989
*/
9090
extern int ns_sw_mac_statistics_start(struct mac_api_s *mac_api, struct mac_statistics_s *mac_statistics);
9191

92+
/**
93+
* @brief Reset all statistics from software MAC.
94+
* @param mac_api MAC instance.
95+
* @return 0 on success, -1 on fail.
96+
*/
97+
extern int ns_sw_mac_statistics_reset(struct mac_api_s *mac_api);
98+
9299
/**
93100
* @brief Start collecting statistics from PHY driver.
94101
* @param mac_api MAC instance.

features/nanostack/sal-stack-nanostack/nanostack/ws_management_api.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,16 @@ int ws_statistics_start(
727727
int8_t interface_id,
728728
ws_statistics_t *stats_ptr);
729729

730+
/**
731+
* Reset Wi-SUN statistics.
732+
*
733+
* \param interface_id Network interface ID.
734+
*
735+
* \return 0 Success.
736+
* \return <0 Failure.
737+
*/
738+
int ws_statistics_reset(int8_t interface_id);
739+
730740
/**
731741
* Stop collecting Wi-SUN statistics.
732742
*

features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_empty_functions.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,12 @@ int ws_statistics_start(int8_t interface_id, ws_statistics_t *stats_ptr)
434434
return -1;
435435
}
436436

437+
int ws_statistics_reset(int8_t interface_id)
438+
{
439+
(void) interface_id;
440+
return -1;
441+
}
442+
437443
int ws_statistics_stop(int8_t interface_id)
438444
{
439445
(void) interface_id;

features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_stats.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,21 @@ int ws_statistics_stop(int8_t interface_id)
4949
return 0;
5050
}
5151

52+
int ws_statistics_reset(int8_t interface_id)
53+
{
54+
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
55+
if (!cur || !ws_info(cur)) {
56+
return -1;
57+
}
58+
if (cur->ws_info->stored_stats_ptr == NULL) {
59+
/* Wi-SUN statistics is not started */
60+
return 0;
61+
}
62+
cur->ws_info->stored_stats_ptr->asynch_rx_count = 0;
63+
cur->ws_info->stored_stats_ptr->asynch_tx_count = 0;
64+
return 0;
65+
}
66+
5267
void ws_stats_update(protocol_interface_info_entry_t *cur, ws_stats_type_t type, uint32_t update_val)
5368
{
5469
if (!cur || !ws_info(cur)) {

features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/sw_mac.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,23 @@ int ns_sw_mac_statistics_start(struct mac_api_s *mac_api, struct mac_statistics_
255255
return 0;
256256
}
257257

258+
int ns_sw_mac_statistics_reset(struct mac_api_s *mac_api)
259+
{
260+
if (!mac_api) {
261+
return -1;
262+
}
263+
protocol_interface_rf_mac_setup_s *mac_setup = get_sw_mac_ptr_by_mac_api(mac_api);
264+
if (!mac_setup) {
265+
return -1;
266+
}
267+
if (mac_setup->mac_statistics == NULL) {
268+
/* MAC statics is not started */
269+
return 0;
270+
}
271+
memset(mac_setup->mac_statistics, 0, sizeof(struct mac_statistics_s));
272+
return 0;
273+
}
274+
258275
static int8_t ns_sw_mac_initialize(mac_api_t *api, mcps_data_confirm *mcps_data_conf_cb,
259276
mcps_data_indication *mcps_data_ind_cb, mcps_purge_confirm *mcps_purge_conf_cb,
260277
mlme_confirm *mlme_conf_callback, mlme_indication *mlme_ind_callback, int8_t parent_id)

0 commit comments

Comments
 (0)