summaryrefslogtreecommitdiff
path: root/cesar/ce/rx
diff options
context:
space:
mode:
authordufour2009-10-01 12:50:15 +0000
committerdufour2009-10-01 12:50:15 +0000
commitad9be1e983ab4ccd68c31fc9dd8e7eaa57ab5db8 (patch)
treea92cf6e6deca20efe067911c67ebcb86b057d770 /cesar/ce/rx
parent122231a0b1b1c0a4ed44ffe878ee272d133c1e4b (diff)
* ce/rx (see #595):
- add a function for the CP to ask for the next SNR to the CE RX. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@5865 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/ce/rx')
-rw-r--r--cesar/ce/rx/bitloading/bitloading.h3
-rw-r--r--cesar/ce/rx/bitloading/test/src/test_fsm.c20
-rw-r--r--cesar/ce/rx/rx.h13
-rw-r--r--cesar/ce/rx/src/rx.c28
-rw-r--r--cesar/ce/rx/test/src/test_rx.c33
5 files changed, 97 insertions, 0 deletions
diff --git a/cesar/ce/rx/bitloading/bitloading.h b/cesar/ce/rx/bitloading/bitloading.h
index b820c02492..d82a828979 100644
--- a/cesar/ce/rx/bitloading/bitloading.h
+++ b/cesar/ce/rx/bitloading/bitloading.h
@@ -34,6 +34,8 @@ typedef struct ce_rx_bitloading_t
u8 noise_nrj_blk_count;
/** Mean count. */
u32 mean_count;
+ /** Get SNR for statistics for the CP. */
+ bool get_snr;
} ce_rx_bitloading_t;
BEGIN_DECLS
@@ -52,6 +54,7 @@ ce_rx_bitloading_init (ce_rx_bitloading_t *bt)
bt->fsm = 0;
bt->noise_nrj_blk_count = 0;
bt->noise_nrj = NULL;
+ bt->get_snr = false;
}
/**
diff --git a/cesar/ce/rx/bitloading/test/src/test_fsm.c b/cesar/ce/rx/bitloading/test/src/test_fsm.c
index 7274a79df2..92c2d24464 100644
--- a/cesar/ce/rx/bitloading/test/src/test_fsm.c
+++ b/cesar/ce/rx/bitloading/test/src/test_fsm.c
@@ -474,6 +474,23 @@ test_suite_ce_rx_bl_initial (test_t t)
ce_rx_bitloading_uninit (&bl);
}
+/**
+ * Test suite for the get statistics for the CP.
+ */
+static void
+test_suite_ce_rx_get_stats (test_t t)
+{
+ test_case_begin (t, "get SNR");
+
+ ce_rx_bitloading_t bl;
+ ce_rx_bitloading_init (&bl);
+
+ test_begin (t, "initialized to false")
+ {
+ test_fail_if (bl.get_snr != false);
+ } test_end;
+}
+
int
main (int argc, char **argv)
{
@@ -500,6 +517,9 @@ main (int argc, char **argv)
/* Start test suite on initial tone map generation. */
test_suite_ce_rx_bl_initial (t);
+ /* Start test of the get SNR flag when the CP wants SNR. */
+ test_suite_ce_rx_get_stats (t);
+
/* Memory check. */
test_case_begin (t, "General");
test_begin (t, "Memory")
diff --git a/cesar/ce/rx/rx.h b/cesar/ce/rx/rx.h
index ed866c28dd..3716d2f171 100644
--- a/cesar/ce/rx/rx.h
+++ b/cesar/ce/rx/rx.h
@@ -15,6 +15,7 @@
#include "mac/common/store.h"
#include "mac/sar/sar.h"
+#include "cp/types.h"
/**
* Context of the CE in RX mode (forward declaration).
@@ -42,6 +43,18 @@ ce_rx_init (mac_store_t *mac_store, sar_t *sar, pbproc_t *pbproc,
void
ce_rx_uninit (ce_rx_t *ce_rx);
+/**
+ * Ask for the CE RX to get the next noise NRJ (nsr) of a peer.
+ * \param ce_rx the CE in RX context.
+ * \param tei the TEI of the station from which we want the SNR.
+ * \param int_index the interval index on which we want the SNR.
+ * \param int_version the version of the intervals.
+ * \return true if the TEI, int_index and int_version is correct and exist.
+ */
+bool
+ce_rx_get_nsr (ce_rx_t *ce_rx, cp_tei_t tei, uint int_index,
+ uint int_version);
+
END_DECLS
#endif /* ce_rx_rx_h */
diff --git a/cesar/ce/rx/src/rx.c b/cesar/ce/rx/src/rx.c
index 07b01e7a5a..0c021f2be2 100644
--- a/cesar/ce/rx/src/rx.c
+++ b/cesar/ce/rx/src/rx.c
@@ -17,6 +17,8 @@
#include "ce/rx/inc/rx.h"
#include "ce/rx/rx.h"
#include "mac/common/timings.h"
+#include "mac/common/defs.h"
+#include "mac/common/store.h"
/**
* Static context of the CE in RX.
@@ -226,3 +228,29 @@ ce_rx_timer_prevent_tone_map_expiration (cyg_handle_t alarm_handler,
}
}
+bool
+ce_rx_get_nsr (ce_rx_t *ce_rx, cp_tei_t tei, uint int_index,
+ uint int_version)
+{
+ /* Check parameters. */
+ dbg_assert (ce_rx);
+ dbg_assert (MAC_TEI_IS_STA (tei));
+ dbg_assert (int_index < TONEMAP_INTERVAL_NB);
+
+ /* Get STA from its TEI. */
+ sta_t *sta = mac_store_sta_get (ce_rx->mac_store, tei);
+
+ if (!sta)
+ return false;
+
+ /* Add a flag in the bit-loading structure. */
+ sta->ce_rx_bt.get_snr = true;
+ /* TODO: store interval and version when intervals are implemented. */
+
+ /* Clean. */
+ blk_release (sta);
+
+ /* No error. */
+ return true;
+}
+
diff --git a/cesar/ce/rx/test/src/test_rx.c b/cesar/ce/rx/test/src/test_rx.c
index 6e92358ca2..3cb75365b8 100644
--- a/cesar/ce/rx/test/src/test_rx.c
+++ b/cesar/ce/rx/test/src/test_rx.c
@@ -97,12 +97,45 @@ test_ce_rx_measure_suite (test_t t)
}
void
+test_ce_rx_get_snr (test_t t)
+{
+ uint tei = 1;
+ mac_store_t *mac_store = mac_store_init ();
+ sar_t *sar = sar_init (mac_store, NULL, NULL, 0x1);
+ pbproc_t *pbproc = (pbproc_t *) t;
+ mac_config_t mac_config;
+
+ ce_rx_t *ce_rx = ce_rx_init (mac_store, sar, pbproc, &mac_config);
+
+ mac_store_sta_add (mac_store, tei);
+
+ test_case_begin (t, "get SNR");
+
+ test_begin (t, "get SNR flag")
+ {
+ test_fail_if (ce_rx_get_nsr (ce_rx, tei, 0, 0) != true);
+ sta_t *sta = mac_store_sta_get (mac_store, tei);
+ test_fail_if (sta == NULL);
+ test_fail_if (sta->ce_rx_bt.get_snr != true);
+ blk_release (sta);
+ } test_end;
+
+ /* Clean. */
+ dbg_assert (mac_store_sta_remove (mac_store, tei) == true);
+ ce_rx_uninit (ce_rx);
+ mac_store_uninit (mac_store);
+ sar_uninit (sar);
+}
+
+void
test_rx_ce_thread (cyg_addrword_t data)
{
test_rx_ce_suite (test);
test_ce_rx_measure_suite (test);
+ test_ce_rx_get_snr (test);
+
test_begin (test, "memory")
{
test_fail_unless (blk_check_memory ());