Skip to content

Commit a051865

Browse files
author
Jarkko Paso
authored
Merge pull request #2135 from ARMmbed/IOTTHD-3232
MAC: Implemented PHY statistics
2 parents ff771b1 + 09d4b06 commit a051865

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

nanostack/platform/arm_hal_phy.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ typedef struct phy_device_channel_page_s {
184184
const phy_rf_channel_configuration_s *rf_channel_configuration; ///< Pointer to channel configuration
185185
} phy_device_channel_page_s;
186186

187+
/** PHY statistics */
188+
typedef struct phy_rf_statistics_s {
189+
uint32_t crc_fails; ///< CRC failures
190+
uint32_t tx_timeouts; ///< transmission timeouts
191+
uint32_t rx_timeouts; ///< reception timeouts
192+
} phy_rf_statistics_s;
193+
187194
/** Virtual data request */
188195
typedef struct virtual_data_req_s {
189196
uint16_t parameter_length; /**< Length of user specified header. Can be zero. */
@@ -283,6 +290,7 @@ typedef struct phy_device_driver_s {
283290
arm_net_virtual_config_tx_fn *virtual_config_tx_cb; /**< Virtual config send callback. Initialized by \ref arm_net_phy_register(). */
284291
arm_net_virtual_confirmation_rx_fn *virtual_confirmation_rx_cb; /**< Virtual confirmation receive callback. Initialized by \ref arm_net_phy_register(). */
285292
uint16_t tunnel_type; /**< Tun driver type. */
293+
phy_rf_statistics_s *phy_rf_statistics; /**< PHY statistics. */
286294
} phy_device_driver_s;
287295

288296

nanostack/sw_mac.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct mac_api_s;
3333
struct mac_description_storage_size_s;
3434
struct fhss_api;
3535
struct mac_statistics_s;
36+
struct phy_rf_statistics_s;
3637

3738
/**
3839
* @brief Creates 802.15.4 MAC API instance which will use RF driver given
@@ -81,6 +82,14 @@ extern struct fhss_api *ns_sw_mac_get_fhss_api(struct mac_api_s *mac_api);
8182
*/
8283
extern int ns_sw_mac_statistics_start(struct mac_api_s *mac_api, struct mac_statistics_s *mac_statistics);
8384

85+
/**
86+
* @brief Start collecting statistics from PHY driver.
87+
* @param mac_api MAC instance.
88+
* @param phy_statistics Statistics storage.
89+
* @return 0 on success, -1 on fail.
90+
*/
91+
extern int ns_sw_mac_phy_statistics_start(struct mac_api_s *mac_api, struct phy_rf_statistics_s *phy_statistics);
92+
8493
/**
8594
* @brief Read current timestamp.
8695
* @param mac_api MAC instance.

source/MAC/IEEE802_15_4/sw_mac.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,19 @@ void sw_mac_stats_update(protocol_interface_rf_mac_setup_s *setup, mac_stats_typ
700700
}
701701
}
702702

703+
int ns_sw_mac_phy_statistics_start(struct mac_api_s *mac_api, phy_rf_statistics_s *phy_statistics)
704+
{
705+
if (!mac_api || !phy_statistics) {
706+
return -1;
707+
}
708+
protocol_interface_rf_mac_setup_s *mac_setup = get_sw_mac_ptr_by_mac_api(mac_api);
709+
if (!mac_setup) {
710+
return -1;
711+
}
712+
mac_setup->dev_driver->phy_driver->phy_rf_statistics = phy_statistics;
713+
return 0;
714+
}
715+
703716
uint32_t ns_sw_mac_read_current_timestamp(struct mac_api_s *mac_api)
704717
{
705718
if (!mac_api) {

0 commit comments

Comments
 (0)