summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cesar/ce/rx/inc/rx.h23
-rw-r--r--cesar/ce/rx/src/rx.c20
-rw-r--r--cesar/ce/rx/test/src/test_rx.c25
3 files changed, 68 insertions, 0 deletions
diff --git a/cesar/ce/rx/inc/rx.h b/cesar/ce/rx/inc/rx.h
index 6f34da968a..9af53960dd 100644
--- a/cesar/ce/rx/inc/rx.h
+++ b/cesar/ce/rx/inc/rx.h
@@ -39,6 +39,18 @@
*/
#define CE_RX_THREAD_NAME "CE_RX"
+/**
+ * Statistics of the CE in RX.
+ */
+typedef struct ce_rx_stat_t
+{
+ /**
+ * How many times we have re-sent (not just send) the tone map because TX
+ * is not using it.
+ */
+ uint resend_tm;
+} ce_rx_stat_t;
+
struct ce_rx_t
{
/**
@@ -137,6 +149,10 @@ struct ce_rx_t
* Extra tone mask context used to handle faulty carriers.
*/
tonemask_info_t tonemask;
+ /**
+ * Statistics.
+ */
+ ce_rx_stat_t stats;
};
/**
@@ -204,6 +220,13 @@ ce_rx_timer_prevent_tone_map_expiration (cyg_handle_t alarm_handler,
cyg_addrword_t data);
#endif
+/**
+ * Initialize statistics of the CE in RX.
+ * \param ce_rx the CE in RX context.
+ */
+void
+ce_rx_stats_init (ce_rx_t *ce_rx);
+
END_DECLS
#endif /* ce_rx_inc_rx_h */
diff --git a/cesar/ce/rx/src/rx.c b/cesar/ce/rx/src/rx.c
index e852a846d9..593a1e5c8c 100644
--- a/cesar/ce/rx/src/rx.c
+++ b/cesar/ce/rx/src/rx.c
@@ -27,6 +27,8 @@
#include "ce/rx/bitloading/inc/ber.h"
#include "ce/rx/bitloading/inc/common.h"
+#include <string.h>
+
/**
* Static context of the CE in RX.
*/
@@ -50,6 +52,7 @@ ce_rx_init (mac_store_t *mac_store, sar_t *sar, pbproc_t *pbproc,
dbg_assert (mac_config);
ce_rx_trace_init (&ce_rx);
+ ce_rx_stats_init (&ce_rx);
/* Store a pointer to the MAC store. */
ce_rx.mac_store = mac_store;
@@ -347,3 +350,20 @@ ce_rx_get_nsr (ce_rx_t *ce_rx, cp_tei_t tei, uint int_index,
return ret;
}
+
+void
+ce_rx_stats_init (ce_rx_t *ce_rx)
+{
+ dbg_assert (ce_rx);
+
+ /* Clear all statistics. */
+ memset (&ce_rx->stats, 0, sizeof (ce_rx->stats));
+
+#if CONFIG_STATS
+ /* Register statistics of the whole CE RX. */
+ lib_stats_set_stat_value_notype ("ce_rx_resend_tm",
+ &ce_rx->stats.resend_tm,
+ LIB_STATS_ACCESS_READ_ONLY,
+ LIB_STATS_DEBUG);
+#endif
+}
diff --git a/cesar/ce/rx/test/src/test_rx.c b/cesar/ce/rx/test/src/test_rx.c
index 159b106ed5..4d5952aa0c 100644
--- a/cesar/ce/rx/test/src/test_rx.c
+++ b/cesar/ce/rx/test/src/test_rx.c
@@ -353,6 +353,29 @@ test_ce_rx_get_snr (test_t t)
}
void
+test_ce_rx_stats (test_t t)
+{
+ test_case_begin (t, "stats");
+
+ mac_store_t *mac_store = mac_store_init ();
+ sar_t *sar = sar_init (mac_store, NULL, NULL, NULL, 0x1);
+ pbproc_t *pbproc = (pbproc_t *) t;
+ mac_config_t mac_config;
+
+ test_begin (t, "init")
+ {
+ ce_rx_t *ce_rx = ce_rx_init (mac_store, sar, pbproc, &mac_config);
+ test_fail_if (ce_rx->stats.resend_tm != 0);
+
+ ce_rx->stats.resend_tm = 0x42;
+ ce_rx_stats_init (ce_rx);
+ test_fail_if (ce_rx->stats.resend_tm != 0);
+
+ ce_rx_uninit (ce_rx);
+ } test_end;
+}
+
+void
test_rx_ce_thread (cyg_addrword_t data)
{
lib_stats_init ();
@@ -363,6 +386,8 @@ test_rx_ce_thread (cyg_addrword_t data)
test_ce_rx_get_snr (test);
+ test_ce_rx_stats (test);
+
lib_stats_uninit ();
test_begin (test, "memory")