summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cesar/ce/Module5
-rw-r--r--cesar/ce/rx/Module2
-rw-r--r--cesar/ce/rx/inc/rx.h108
-rw-r--r--cesar/ce/rx/rx.h42
-rw-r--r--cesar/ce/rx/src/rx.c113
-rw-r--r--cesar/ce/rx/test/Makefile18
-rw-r--r--cesar/ce/rx/test/ecos.ecc.sh5
-rw-r--r--cesar/ce/rx/test/src/test_rx.c70
-rw-r--r--cesar/common/tests/tests17
-rw-r--r--cesar/cp/cp.h3
-rw-r--r--cesar/cp/inc/context.h4
-rw-r--r--cesar/cp/src/cp.c5
-rw-r--r--cesar/station/src/station.c9
-rw-r--r--cesar/station/station.h6
-rw-r--r--cesar/test_general/station/cco0/s1/Makefile2
-rw-r--r--cesar/test_general/station/cco0/s2/Makefile.mk2
-rw-r--r--cesar/test_general/station/interoperability/Makefile2
-rw-r--r--cesar/test_general/station/maximus/Makefile2
18 files changed, 383 insertions, 32 deletions
diff --git a/cesar/ce/Module b/cesar/ce/Module
index 79ce21b653..c809e17b85 100644
--- a/cesar/ce/Module
+++ b/cesar/ce/Module
@@ -1,4 +1 @@
-SOURCES := rx.c rxce_stats.c bitloading.c mpdu_measure_store.c cei_param.c
-ifeq ($(CONFIG_TRACE),y)
-SOURCES += trace.c
-endif
+MODULES := ce/common ce/tx ce/rx
diff --git a/cesar/ce/rx/Module b/cesar/ce/rx/Module
new file mode 100644
index 0000000000..399770f270
--- /dev/null
+++ b/cesar/ce/rx/Module
@@ -0,0 +1,2 @@
+# Channel Estimation (CE) in Receive (RX) mode.
+SOURCES := rx.c
diff --git a/cesar/ce/rx/inc/rx.h b/cesar/ce/rx/inc/rx.h
new file mode 100644
index 0000000000..f15f7fcdf0
--- /dev/null
+++ b/cesar/ce/rx/inc/rx.h
@@ -0,0 +1,108 @@
+#ifndef ce_rx_inc_rx_h
+#define ce_rx_inc_rx_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/rx/inc/rx.h
+ * \brief Channel Estimation in Receive mode (private part).
+ * \ingroup ce_rx
+ *
+ * This header provide the private declaration of the CE in RX.
+ */
+
+#include "mac/common/store.h"
+
+#include <cyg/kernel/kapi.h>
+#include <cyg/hal/hal_arch.h>
+
+#include "ce/rx/rx.h"
+
+/**
+ * Priority of the CE in RX thread.
+ */
+#define CE_RX_THREAD_PRIORITY 15
+/**
+ * Thread name of the CE in RX.
+ */
+#define CE_RX_THREAD_NAME "CE_RX"
+
+struct ce_rx_t
+{
+ /**
+ * Pointer to the MAC store context.
+ */
+ mac_store_t *mac_store;
+ /**
+ * Flag to know if the CE in RX thread has something to do.
+ * Basically, the CE in RX thread sleep until another thread tell it to do
+ * something (process measurements, stop, ...).
+ */
+ cyg_flag_t work_flag;
+ /**
+ * Stack used bu the thread.
+ */
+ u8 thread_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
+ /**
+ * ECos thread handler.
+ */
+ cyg_handle_t thread_handler;
+ /**
+ * The CE in RX ECos thread.
+ */
+ cyg_thread thread;
+ /**
+ * Stop the CE in RX.
+ */
+ bool stop_flag;
+};
+
+/**
+ * Function prototype to calls when flag is set.
+ */
+typedef void (*ce_rx_process_work_t) (ce_rx_t *);
+
+/**
+ * List of supported flags for work supported by the CE in RX.
+ * This list correspond to the position of the flag in the bitfield.
+ */
+typedef enum ce_rx_work_flag_t
+{
+ /** Stop the CE in RX thread. */
+ CE_RX_WORK_FLAG_QUIT = 0,
+ /** Measurements processing from SAR. */
+ CE_RX_WORK_FLAG_MEASURE = 1,
+ /** Size of this enum. */
+ CE_RX_WORK_FLAG_SIZE
+} ce_rx_work_flag_t;
+
+BEGIN_DECLS
+
+/**
+ * Main function of the CE RX thread.
+ * \param data the CE RX context.
+ */
+void
+ce_rx_thread (cyg_addrword_t data);
+
+/**
+ * Process quit request from other threads.
+ * \param ce_rx the CE in RX context.
+ */
+void
+ce_rx_process_work_quit (ce_rx_t *ce_rx);
+
+/**
+ * Process new measure from the SAR.
+ * \param ce_rx the CE in RX context.
+ */
+void
+ce_rx_process_work_measure (ce_rx_t *ce_rx);
+
+END_DECLS
+
+#endif /* ce_rx_inc_rx_h */
diff --git a/cesar/ce/rx/rx.h b/cesar/ce/rx/rx.h
new file mode 100644
index 0000000000..2f5b9cc6b6
--- /dev/null
+++ b/cesar/ce/rx/rx.h
@@ -0,0 +1,42 @@
+#ifndef ce_rx_rx_h
+#define ce_rx_rx_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/rx/rx.h
+ * \brief Channel Estimation in Receive mode.
+ * \ingroup ce_rx
+ */
+
+#include "mac/common/store.h"
+
+/**
+ * Context of the CE in RX mode (forward declaration).
+ */
+typedef struct ce_rx_t ce_rx_t;
+
+BEGIN_DECLS
+
+/**
+ * Initialize the CE in RX.
+ * \param mac_store the MAC store context.
+ * \return the context of the CE in RX.
+ */
+ce_rx_t *
+ce_rx_init (mac_store_t *mac_store);
+
+/**
+ * Un-initialize the CE in RX.
+ * \param ce_rx the CE in RX context.
+ */
+void
+ce_rx_uninit (ce_rx_t *ce_rx);
+
+END_DECLS
+
+#endif /* ce_rx_rx_h */
diff --git a/cesar/ce/rx/src/rx.c b/cesar/ce/rx/src/rx.c
new file mode 100644
index 0000000000..36d83f0602
--- /dev/null
+++ b/cesar/ce/rx/src/rx.c
@@ -0,0 +1,113 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/rx/src/rx.c
+ * \brief Channel Estimation in Receive mode (implementation).
+ * \ingroup ce_rx
+ */
+#include "common/std.h"
+
+#include "ce/rx/inc/rx.h"
+
+#include "ce/rx/rx.h"
+
+/**
+ * Static context of the CE in RX.
+ */
+static ce_rx_t ce_rx;
+
+/**
+ * Table with the list of functions to call for each flag.
+ */
+static ce_rx_process_work_t ce_rx_process_work[CE_RX_WORK_FLAG_SIZE] =
+{
+ ce_rx_process_work_quit,
+ ce_rx_process_work_measure,
+};
+
+ce_rx_t *
+ce_rx_init (mac_store_t *mac_store)
+{
+ /* Check parameters. */
+ dbg_assert (mac_store);
+
+ /* Store a pointer to the MAC store. */
+ ce_rx.mac_store = mac_store;
+
+ ce_rx.stop_flag = false;
+
+ /* ECos. */
+ /* No work to do. */
+ cyg_flag_init (&ce_rx.work_flag);
+
+ /* Create the ECos thread. */
+ cyg_thread_create (CE_RX_THREAD_PRIORITY, &ce_rx_thread,
+ (cyg_addrword_t) &ce_rx, CE_RX_THREAD_NAME,
+ ce_rx.thread_stack, sizeof (ce_rx.thread_stack),
+ &ce_rx.thread_handler, &ce_rx.thread);
+ cyg_thread_resume (ce_rx.thread_handler);
+
+ return &ce_rx;
+}
+
+void
+ce_rx_thread (cyg_addrword_t data)
+{
+ /* Check parameters. */
+ ce_rx_t *ce_rx = (ce_rx_t *) data;
+ dbg_assert (ce_rx);
+
+ cyg_flag_value_t work_flag_value, work_flag_mask;
+ uint i;
+ for (work_flag_mask = 0, i = 0; i < CE_RX_WORK_FLAG_SIZE; i++)
+ {
+ work_flag_mask |= (1 << i);
+ }
+
+ /* While we are not asked to terminate. */
+ while (!ce_rx->stop_flag)
+ {
+ /* Something to do? */
+ work_flag_value = cyg_flag_wait (&ce_rx->work_flag, work_flag_mask,
+ CYG_FLAG_WAITMODE_OR
+ | CYG_FLAG_WAITMODE_CLR);
+ for (i = 0; i < CE_RX_WORK_FLAG_SIZE; i++)
+ {
+ if (work_flag_value & (1 << i))
+ {
+ work_flag_value &= ~(1 << i);
+ ce_rx_process_work[i] (ce_rx);
+ }
+ }
+ }
+ /* If we reach this part, we have been asked to termintate this thread. */
+ cyg_flag_destroy (&ce_rx->work_flag);
+}
+
+void
+ce_rx_uninit (ce_rx_t *ce_rx)
+{
+ /* Check parameters. */
+ dbg_assert (ce_rx);
+ /* Ask for stop. */
+ cyg_flag_value_t stop = 1 << CE_RX_WORK_FLAG_QUIT;
+ cyg_flag_setbits (&ce_rx->work_flag, stop);
+}
+
+void
+ce_rx_process_work_quit (ce_rx_t *ce_rx)
+{
+ /* Check parameters. */
+ dbg_assert (ce_rx);
+ ce_rx->stop_flag = true;
+}
+
+void
+ce_rx_process_work_measure (ce_rx_t *ce_rx)
+{
+}
diff --git a/cesar/ce/rx/test/Makefile b/cesar/ce/rx/test/Makefile
new file mode 100644
index 0000000000..e63ff49b39
--- /dev/null
+++ b/cesar/ce/rx/test/Makefile
@@ -0,0 +1,18 @@
+# Base of the project.
+BASE = ../../..
+
+# Enable ECos.
+ECOS = y
+
+# Common modules.
+common_MODULES = lib ce/rx ce/common mac/common cp/msg cp/fsm/stub
+
+# Program list.
+TARGET_PROGRAMS = test_rx
+
+# Test CE RX.
+test_rx_SOURCES = test_rx.c
+test_rx_MODULES = $(common_MODULES)
+
+# Include main Makefile.
+include $(BASE)/common/make/top.mk
diff --git a/cesar/ce/rx/test/ecos.ecc.sh b/cesar/ce/rx/test/ecos.ecc.sh
new file mode 100644
index 0000000000..2443d0e40f
--- /dev/null
+++ b/cesar/ce/rx/test/ecos.ecc.sh
@@ -0,0 +1,5 @@
+config=${1:-ecos-gen.ecc}
+ecosconfig --config=$config new linux default
+cat >> $config <<'EOF'
+EOF
+ecosconfig --config=$config check
diff --git a/cesar/ce/rx/test/src/test_rx.c b/cesar/ce/rx/test/src/test_rx.c
new file mode 100644
index 0000000000..3c60f74b29
--- /dev/null
+++ b/cesar/ce/rx/test/src/test_rx.c
@@ -0,0 +1,70 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/rx/test/src/test_rx.c
+ * \brief Test the CE in RX.
+ * \ingroup test
+ *
+ */
+#include "common/std.h"
+#include "mac/common/store.h"
+#include "ce/rx/rx.h"
+#include "ce/rx/inc/rx.h"
+
+#include "lib/test.h"
+#include "lib/blk.h"
+
+#include <cyg/kernel/kapi.h>
+#include <cyg/hal/hal_arch.h>
+
+u8 thread_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
+cyg_handle_t thread_handler;
+cyg_thread thread;
+test_t test;
+
+void
+test_rx_ce_suite (test_t t)
+{
+ mac_store_t *mac_store = mac_store_init ();
+
+ test_begin (t, "launch ce_rx thread")
+ {
+ ce_rx_t *ce_rx = ce_rx_init (mac_store);
+ ce_rx_uninit (ce_rx);
+ } test_end;
+}
+
+void
+test_rx_ce_thread (cyg_addrword_t data)
+{
+ test_rx_ce_suite (test);
+
+ test_begin (test, "memory")
+ {
+ test_fail_unless (blk_check_memory ());
+ } test_end;
+
+ test_result (test);
+
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+}
+
+int
+main (int argc, char **argv)
+{
+ test_init (test, argc, argv);
+
+ /* Create the ECos thread. */
+ cyg_thread_create (CE_RX_THREAD_PRIORITY + 5, &test_rx_ce_thread,
+ (cyg_addrword_t) NULL, "Test CE RX",
+ thread_stack, sizeof (thread_stack),
+ &thread_handler, &thread);
+ cyg_thread_resume (thread_handler);
+
+ return 1;
+}
diff --git a/cesar/common/tests/tests b/cesar/common/tests/tests
index fbe43142eb..c1bc4613e2 100644
--- a/cesar/common/tests/tests
+++ b/cesar/common/tests/tests
@@ -233,27 +233,14 @@ cl/test/bridge_table:
make: make COV=y
cov bridge_table: ./obj/bridge_table
-ce/test/rx/general:
-make: make COV=y
-cov ce_test_cei: ./obj/host/test_cei_host_linux_i386
-cov ce_test_cei_param: ./obj/host/test_cei_param_host_linux_i386
-cov ce_test_mpdu_measure_store: ./obj/host/test_measure_store_host_linux_i386
-cov ce_test_bitloading: ./obj/host/test_bitloading_host_linux_i386
-ce_test_sar_integration: ./obj/target/test_sar_target_ecos_synth.elf
-ce_test_rx: ./obj/target/test_rx_target_ecos_synth.elf
-
-ce/test/rx/tonemap_refresh:
-make: make COV=y
-ce_test_tonemaps_refresh: ./obj/test_tonemaps_refresh_target_ecos_synth.elf
-
ce/tx/test:
make: make COV=y
cov ce_tx_test_mme: ./obj/test_mme
cov ce_tx_test_expiration: ./obj/test_expiration
-ce/test/rx/maximus:
+ce/rx/test:
make: make COV=y
-ce_test_rx_maximus: python send_noise.py -e ./obj/test_rx.elf -d false -t 2500000000
+cov-target ce_rx_test_rx: ./obj/test_rx.elf
maximus/unittest:
make: make COV=y
diff --git a/cesar/cp/cp.h b/cesar/cp/cp.h
index 59acbc86b2..05106691bc 100644
--- a/cesar/cp/cp.h
+++ b/cesar/cp/cp.h
@@ -21,6 +21,7 @@
#include "interface/forward.h"
#include "hal/timer/timer.h"
#include "cl/cl.h"
+#include "ce/rx/rx.h"
BEGIN_DECLS
@@ -40,7 +41,7 @@ BEGIN_DECLS
cp_t *
cp_init (mac_config_t * mac_config, interface_t * interface,
hal_timer_t *hal_timer, pbproc_t *pbproc,
- mac_store_t *mac_store, sar_t *sar, cl_t *cl,
+ mac_store_t *mac_store, sar_t *sar, cl_t *cl, ce_rx_t *ce_rx,
u32 seed);
/**
diff --git a/cesar/cp/inc/context.h b/cesar/cp/inc/context.h
index 269bf9cd9e..c386753e7c 100644
--- a/cesar/cp/inc/context.h
+++ b/cesar/cp/inc/context.h
@@ -38,6 +38,7 @@
#include "cp/fsm/fsm.h"
#include "cp/msg/msg.h"
#include "cp/secu/secu.h"
+#include "ce/rx/rx.h"
/* Private interfaces. */
#include "cp/inc/trace.h"
@@ -159,6 +160,9 @@ struct cp_t
/** Context of the CE in TX. */
ce_tx_t ce_tx;
+
+ /** Context of the CE in RX. */
+ ce_rx_t *ce_rx;
};
#endif /* cp_inc_cp_h */
diff --git a/cesar/cp/src/cp.c b/cesar/cp/src/cp.c
index 10b96e7bf4..500f47c947 100644
--- a/cesar/cp/src/cp.c
+++ b/cesar/cp/src/cp.c
@@ -29,6 +29,7 @@ static cp_t cp_global;
* \param mac_store the mac store context.
* \param sar the SAR context.
* \param cl the CL context.
+ * \param ce_rx the CE in RX context.
* \param seed the seed to initialise the random generator.
* \return The control plane context.
*
@@ -37,7 +38,7 @@ cp_t *
cp_init (mac_config_t * mac_config, interface_t * interface,
hal_timer_t *hal_timer, pbproc_t *pbproc,
mac_store_t *mac_store, sar_t *sar, cl_t *cl,
- u32 seed)
+ ce_rx_t *ce_rx, u32 seed)
{
dbg_assert (mac_config);
dbg_assert (interface);
@@ -45,6 +46,7 @@ cp_init (mac_config_t * mac_config, interface_t * interface,
dbg_assert (pbproc);
dbg_assert (sar);
dbg_assert (cl);
+ dbg_assert (ce_rx);
cp_global.mac_config = mac_config;
cp_global.interface = interface;
@@ -55,6 +57,7 @@ cp_init (mac_config_t * mac_config, interface_t * interface,
cp_global.mac_store = mac_store;
cp_global.sar = sar;
cp_global.cl = cl;
+ cp_global.ce_rx = ce_rx;
/* Initialise traces. */
cp_trace_init (&cp_global);
diff --git a/cesar/station/src/station.c b/cesar/station/src/station.c
index c9d05f006b..ac347477c3 100644
--- a/cesar/station/src/station.c
+++ b/cesar/station/src/station.c
@@ -67,12 +67,13 @@ cesar_init (void)
/* Initialise the hal timer. */
cesar.hal_timer = hal_timer_init (pbproc_get_phy(cesar.pbproc));
+ /* Initialize the CE in RX. */
+ cesar.ce_rx = ce_rx_init (cesar.mac_store);
+
/* Initialise the CP. */
cesar.cp = cp_init (&cesar.mac_config, cesar.interface, cesar.hal_timer,
cesar.pbproc, cesar.mac_store, cesar.sar, cesar.cl,
- seed);
-
- cesar.rxce = rxce_init(cesar.sar, cesar.mac_store, &cesar.mac_config, cesar.cp);
+ cesar.ce_rx, seed);
// start HLE...
hle_activate(cesar.hle, true);
@@ -94,7 +95,7 @@ cesar_uninit (cesar_t *ctx)
cl_uninit (ctx->cl);
sar_uninit (ctx->sar);
pbproc_uninit (ctx->pbproc);
- rxce_uninit (ctx->rxce);
+ ce_rx_uninit (ctx->ce_rx);
mac_store_uninit (ctx->mac_store);
hal_timer_uninit (cesar.hal_timer);
diff --git a/cesar/station/station.h b/cesar/station/station.h
index 2adb8a36d8..2876b9c3c4 100644
--- a/cesar/station/station.h
+++ b/cesar/station/station.h
@@ -21,7 +21,7 @@
#include "interface/interface.h"
#include "cp/cp.h"
#include "hal/timer/timer.h"
-#include "ce/rx.h"
+#include "ce/rx/rx.h"
struct cesar_t
{
@@ -49,8 +49,8 @@ struct cesar_t
/** Control Plane. */
cp_t *cp;
- /** CE. */
- rxce_t *rxce;
+ /** CE in RX. */
+ ce_rx_t *ce_rx;
/* Hal timer. */
hal_timer_t *hal_timer;
diff --git a/cesar/test_general/station/cco0/s1/Makefile b/cesar/test_general/station/cco0/s1/Makefile
index f99f1c1048..17e29e638f 100644
--- a/cesar/test_general/station/cco0/s1/Makefile
+++ b/cesar/test_general/station/cco0/s1/Makefile
@@ -9,7 +9,7 @@ cco0s1_SOURCES =
cco0s1_MODULES = lib mac/common mac cl hle interface cp hal station \
host test_general/station/fcall \
cp/beacon/stub \
- test_general/station/common host ce/tx ce/common
+ test_general/station/common host ce
mac_common_MODULES_SOURCES = tonemask.c
cp_cco_bw_MODULE_SOURCES = bw_lib_alloc.c
diff --git a/cesar/test_general/station/cco0/s2/Makefile.mk b/cesar/test_general/station/cco0/s2/Makefile.mk
index d7831ce977..14f7da86e4 100644
--- a/cesar/test_general/station/cco0/s2/Makefile.mk
+++ b/cesar/test_general/station/cco0/s2/Makefile.mk
@@ -10,7 +10,7 @@ cco0s2_MODULES = lib mac/common mac cl hle interface cp hal station \
$(MAXIMUS_MODULES) \
test_general/station/fcall \
cp/beacon/stub \
- test_general/station/common ce/tx ce/common
+ test_general/station/common ce
mac_common_MODULES_SOURCES = tonemask.c
cp_cco_bw_MODULE_SOURCES = bw_lib_alloc.c
diff --git a/cesar/test_general/station/interoperability/Makefile b/cesar/test_general/station/interoperability/Makefile
index 150595181a..a5572a5e64 100644
--- a/cesar/test_general/station/interoperability/Makefile
+++ b/cesar/test_general/station/interoperability/Makefile
@@ -12,7 +12,7 @@ station_MODULES = lib mac/common mac cl hle interface cp hal station \
hal/arch hal/phy \
test_general/station/fcall \
cp/beacon/stub \
- test_general/station/common host ce/tx ce/common
+ test_general/station/common host ce
mac_common_MODULES_SOURCES = tonemask.c
cp_cco_bw_MODULE_SOURCES = bw_lib_alloc.c
diff --git a/cesar/test_general/station/maximus/Makefile b/cesar/test_general/station/maximus/Makefile
index 39789bf578..120edede65 100644
--- a/cesar/test_general/station/maximus/Makefile
+++ b/cesar/test_general/station/maximus/Makefile
@@ -14,7 +14,7 @@ sta_maximus_MODULES = lib mac/common mac cl hle interface cp hal station \
$(MAXIMUS_MODULES) \
test_general/station/fcall \
cp/beacon/stub \
- test_general/station/common ce/tx ce/common
+ test_general/station/common ce
mac_common_MODULES_SOURCES = tonemask.c
cp_cco_bw_MODULE_SOURCES = bw_lib_alloc.c