summaryrefslogtreecommitdiff
path: root/cesar/bsu/src
diff options
context:
space:
mode:
authorNélio Laranjeiro2011-01-28 10:57:09 +0100
committerNélio Laranjeiro2011-02-07 16:19:00 +0100
commitb21bc67eb9f4df3f5a44fd04f2547f00096443ee (patch)
treed713eaffe117fe4125c424b42b61d3fabf96d4e2 /cesar/bsu/src
parent2bd01b5e3f6a743c76c4538e5c41bab0d94dbb89 (diff)
cesar/bsu: add stats, closes #2213
- current ntb_tck_offset - current frequency error in q30.
Diffstat (limited to 'cesar/bsu/src')
-rw-r--r--cesar/bsu/src/bsu.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/cesar/bsu/src/bsu.c b/cesar/bsu/src/bsu.c
index 38af466b37..3e19860e0e 100644
--- a/cesar/bsu/src/bsu.c
+++ b/cesar/bsu/src/bsu.c
@@ -37,6 +37,26 @@
static bsu_t bsu_global;
/**
+ * Store the values computed into the stats.
+ * \param ctx the module context.
+ *
+ * Stats registered are dependent on the AVLN the station is tracking/using
+ * it can change at any time.
+ */
+static void
+bsu_stats_store (bsu_t *ctx)
+{
+#if CONFIG_STATS
+ ctx->stats.ntb_offset_tck = ctx->sta_avln->sync.ntb_offset_tck;
+ if (ctx->sta_avln->sync.second_shoot)
+ ctx->stats.frequency_error_q30 =
+ FIXED (ctx->sta_avln->sync.fe, BSU_NTB_FIXED_POINT);
+ else
+ ctx->stats.frequency_error_q30 = 0;
+#endif
+}
+
+/**
* Remove the MFS beacon.
* \param ctx the module context.
* \param index the MFS index.
@@ -600,9 +620,31 @@ bsu_timer_event_process (void *ud)
bsu_avln_countdown_beacon_entries_apply_changes (ctx, ctx->sta_avln);
bsu_avln_countdown_beacon_entries (ctx, ctx->sta_avln);
bsu_reprogram_timer (ctx, bpsd[2]);
+ bsu_stats_store (ctx);
}
}
+/**
+ * Initialise stats for bsu.
+ * \param ctx the module context.
+ */
+static void
+bsu_stats_init (bsu_t *ctx)
+{
+#if CONFIG_STATS
+ dbg_assert (ctx);
+ /* Register our statistics. */
+ lib_stats_set_stat_value_notype ("ntb_offset_tck",
+ &ctx->stats.ntb_offset_tck,
+ LIB_STATS_ACCESS_READ_ONLY,
+ LIB_STATS_USER);
+ lib_stats_set_stat_value_notype ("frequency_error_q30",
+ &ctx->stats.frequency_error_q30,
+ LIB_STATS_ACCESS_READ_ONLY,
+ LIB_STATS_USER);
+#endif
+}
+
bsu_t *
bsu_init (bsu_aclf_t *aclf, mac_config_t *mac_config, phy_t *phy,
mac_store_t *mac_store, ca_t *ca, sar_t *sar, hal_timer_t *timer,
@@ -651,6 +693,7 @@ bsu_init (bsu_aclf_t *aclf, mac_config_t *mac_config, phy_t *phy,
ctx->ca_index = 0;
/* Trace. */
bsu_trace_init (ctx);
+ bsu_stats_init (ctx);
return ctx;
}
@@ -729,6 +772,7 @@ bsu_beacon_process__avln_tracked (bsu_t *ctx, bsu_beacon_t *beacon,
bsu_beacon_send_prepare (ctx, BSU_BEACON_TYPE_DISCOVER, beacon);
ctx->sta_avln->beacon.beacon_period_start_date = params->bts -
ctx->sta_avln->sync.ntb_offset_tck;
+ bsu_stats_store (ctx);
return ctx->sta_avln;
}