summaryrefslogtreecommitdiff
path: root/cesar/ce
diff options
context:
space:
mode:
authordufour2009-12-01 14:23:53 +0000
committerdufour2009-12-01 14:23:53 +0000
commitd78701daaab8f1f5f0e2e07d9d1cbe9fa4be6f01 (patch)
tree294265be4d4f9deb7cacbbce2d40546230237449 /cesar/ce
parent9e647f8f9999cc25755c0169275093ff01efb8fd (diff)
cesar/ce/rx: get PB measurements from the SAR callback
This will be used latter for the bit loading tracking. This commit also add some other changes to correctly handle PB measurements : * measures for an unassociated STA are ignored, * if measure data does not correspond to SAR callback callee behavior, an assertion is generated, * traces now print what there is in the measure/callback of the SAR. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@6499 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/ce')
-rw-r--r--cesar/ce/rx/inc/measure.h20
-rw-r--r--cesar/ce/rx/inc/trace.h4
-rw-r--r--cesar/ce/rx/src/measure.c103
-rw-r--r--cesar/ce/rx/src/rx.c7
-rw-r--r--cesar/ce/rx/src/trace.c10
-rw-r--r--cesar/ce/rx/test/Makefile7
-rw-r--r--cesar/ce/rx/test/src/test_rx.c104
7 files changed, 184 insertions, 71 deletions
diff --git a/cesar/ce/rx/inc/measure.h b/cesar/ce/rx/inc/measure.h
index 271884b30d..af64b7586b 100644
--- a/cesar/ce/rx/inc/measure.h
+++ b/cesar/ce/rx/inc/measure.h
@@ -45,6 +45,15 @@ typedef struct ce_rx_measure_mbox_t
* Count of channel data elements.
*/
uint chan_data_count;
+ /**
+ * Count of PB measurements.
+ */
+ uint pb_measurements_count;
+ /**
+ * PB measurements.
+ */
+ blk_t *pb_measurements;
+
} ce_rx_measure_mbox_t;
BEGIN_DECLS
@@ -65,17 +74,6 @@ ce_rx_measure_init (ce_rx_t *ce_rx, sar_t *sar, pbproc_t *pbproc);
void
ce_rx_measure_uninit (ce_rx_t *ce_rx);
-/**
- * Add a channel data measure to the mailbox and wake-up the CE RX.
- * \param ce_rx the CE RX context.
- * \param rx_params the RX params of the measure.
- * \param chan_data the channel data received.
- * \param chan_data_count number of elements of chan_data.
- */
-void
-ce_rx_measure_add_chan_data (ce_rx_t *ce_rx, pbproc_rx_params_t *rx_params,
- phy_chandata_t *chan_data, uint chan_data_count);
-
END_DECLS
#endif /* ce_rx_inc_measure_h */
diff --git a/cesar/ce/rx/inc/trace.h b/cesar/ce/rx/inc/trace.h
index 8af5c6e5d7..8a891255ae 100644
--- a/cesar/ce/rx/inc/trace.h
+++ b/cesar/ce/rx/inc/trace.h
@@ -28,8 +28,7 @@ enum
{
CE_RX_TRACE_INIT,
CE_RX_TRACE_UNINIT,
- CE_RX_TRACE_MEASURE_ADD_CHAN_DATA,
- CE_RX_TRACE_CHAN_DATA_HANDLING,
+ CE_RX_TRACE_MEASURE_HANDLING,
CE_RX_TRACE_SAR_CB,
CE_RX_TRACE_BL_INITIAL,
CE_RX_TRACE_SEND_TONEMAP,
@@ -37,7 +36,6 @@ enum
CE_RX_TRACE_FSM_FROM_TO,
CE_RX_TRACE_FSM_HANDLING_EVENT,
CE_RX_TRACE_TONEMAP_INITIAL,
- CE_RX_TRACE_USING_TONEMAP,
};
BEGIN_DECLS
diff --git a/cesar/ce/rx/src/measure.c b/cesar/ce/rx/src/measure.c
index ffa8ca7f22..909aded35a 100644
--- a/cesar/ce/rx/src/measure.c
+++ b/cesar/ce/rx/src/measure.c
@@ -12,8 +12,10 @@
*/
#include "common/std.h"
+#include "hal/phy/pbdma.h"
#include "ce/rx/inc/measure.h"
#include "ce/rx/inc/rx.h"
+#include "lib/utils.h"
/**
* Destructor for a measure.
@@ -25,9 +27,14 @@ ce_rx_measure_cache_destructor (void *object)
dbg_assert (object);
ce_rx_measure_mbox_t *measure = (ce_rx_measure_mbox_t *) object;
- if (measure->chan_data)
+ if (measure->chan_data_count)
blk_release_desc_range_nb ((blk_t *) measure->chan_data,
measure->chan_data_count);
+ if (measure->pb_measurements_count)
+ blk_release_desc_range_nb (measure->pb_measurements,
+ CEIL_DIV (measure->pb_measurements_count *
+ sizeof (pb_measurement_t),
+ BLK_SIZE));
}
bool
@@ -38,26 +45,70 @@ ce_rx_measure_sar_cb (void *data, pbproc_rx_params_t *rx_params,
{
/* Check needed parameters. */
dbg_assert (data);
+ dbg_assert (rx_params);
+ /* When this callback is called by the SAR, there is always something to
+ * do. There is no case when there is nothing to do. */
+ dbg_assert (chan_data_count || pbm_count);
/* Get the context of the CE RX. */
ce_rx_t *ce_rx = (ce_rx_t *) data;
- CE_RX_TRACE (SAR_CB);
+ /* No PB measurements by default. */
+ bool ret = false;
- /* Get channel data if they are some. */
- if (chan_data_count)
- {
- ce_rx_measure_add_chan_data (ce_rx, rx_params,
- (phy_chandata_t *) chan_data,
- chan_data_count);
- }
- if (pbm_count)
+ CE_RX_TRACE (SAR_CB, rx_params->tei, chan_data_count, pbm_count);
+
+ /* Only handle measures for a "valid" STA. */
+ if (MAC_TEI_IS_STA (rx_params->tei))
{
- /* FIXME: for the moment, PB measurements are not needed and therefore,
- * ignored. */
- return false;
+ /* Allocate a measure. */
+ ce_rx_measure_mbox_t *measure = slab_alloc (&ce_rx->measure_cache);
+ /* Copy needed information. */
+ measure->rx_params = *rx_params;
+ /* Any channel data? */
+ measure->chan_data_count = chan_data_count;
+ if (chan_data_count)
+ {
+ dbg_assert (chan_data);
+ measure->chan_data = (phy_chandata_t *) chan_data;
+ }
+ else
+ {
+ dbg_invalid_ptr (measure->chan_data);
+ }
+
+ /* Any PB measurements? */
+ measure->pb_measurements_count = pbm_count;
+ if (pbm_count)
+ {
+ dbg_assert (first_pbm);
+ dbg_assert (last_pbm);
+ dbg_assert (pbm_blk_offset);
+ /* Allocate necessary blocks directly it stores it in the SAR
+ * variables. */
+ *first_pbm
+ = blk_alloc_desc_range (CEIL_DIV (measure->pb_measurements_count
+ * sizeof (pb_measurement_t),
+ BLK_SIZE),
+ last_pbm);
+ /* Store PB measurements in the measure. */
+ measure->pb_measurements = *first_pbm;
+ /* Offset is always 0 (for the moment being only?). */
+ *pbm_blk_offset = 0;
+ ret = true;
+ }
+ else
+ {
+ dbg_invalid_ptr (measure->pb_measurements);
+ }
+
+ /* Add the measure to the mailbox. */
+ mbox_put (&ce_rx->measure_mbox, &measure->mbox_node);
+ /* Wake up the CE RX. */
+ ce_rx_work_add (ce_rx, CE_RX_WORK_FLAG_MEASURE);
}
- return false;
+
+ return ret;
}
void
@@ -116,27 +167,3 @@ ce_rx_measure_uninit (ce_rx_t *ce_rx)
}
mbox_uninit (&ce_rx->measure_mbox);
}
-
-void
-ce_rx_measure_add_chan_data (ce_rx_t *ce_rx, pbproc_rx_params_t *rx_params,
- phy_chandata_t *chan_data, uint chan_data_count)
-{
- /* Check parameters. */
- dbg_assert (ce_rx);
- dbg_assert (rx_params);
- dbg_assert (chan_data);
- dbg_assert (chan_data_count);
-
- CE_RX_TRACE (MEASURE_ADD_CHAN_DATA, rx_params->tei);
-
- /* Allocate a measure. */
- ce_rx_measure_mbox_t *measure = slab_alloc (&ce_rx->measure_cache);
- /* Copy needed information. */
- measure->rx_params = *rx_params;
- measure->chan_data = chan_data;
- measure->chan_data_count = chan_data_count;
- /* Add the measure to the mailbox. */
- mbox_put (&ce_rx->measure_mbox, &measure->mbox_node);
- /* Wake up the CE RX. */
- ce_rx_work_add (ce_rx, CE_RX_WORK_FLAG_MEASURE);
-}
diff --git a/cesar/ce/rx/src/rx.c b/cesar/ce/rx/src/rx.c
index 62c15d611a..32caf6bfde 100644
--- a/cesar/ce/rx/src/rx.c
+++ b/cesar/ce/rx/src/rx.c
@@ -176,10 +176,9 @@ ce_rx_process_work_measure (ce_rx_t *ce_rx)
ce_rx_measure_mbox_t * measure = PARENT_OF (ce_rx_measure_mbox_t,
mbox_node, node);
- CE_RX_TRACE (CHAN_DATA_HANDLING, measure->rx_params.tei);
-
- if (TONEMAP_INDEX_IS_NEGOTIATED (measure->rx_params.tmi_av))
- CE_RX_TRACE (USING_TONEMAP, measure->rx_params.tmi_av);
+ CE_RX_TRACE (MEASURE_HANDLING, measure->rx_params.tei,
+ measure->rx_params.tmi_av, measure->chan_data_count,
+ measure->pb_measurements_count);
/* Ensure STA is created. */
mac_store_sta_add (ce_rx->mac_store,
diff --git a/cesar/ce/rx/src/trace.c b/cesar/ce/rx/src/trace.c
index 2752211dbb..3f4f1d167c 100644
--- a/cesar/ce/rx/src/trace.c
+++ b/cesar/ce/rx/src/trace.c
@@ -69,11 +69,10 @@ ce_rx_trace_init (ce_rx_t *ctx)
{
TRACE_EVENT (CE_RX_TRACE_INIT, "init"),
TRACE_EVENT (CE_RX_TRACE_UNINIT, "uninit"),
- TRACE_EVENT (CE_RX_TRACE_MEASURE_ADD_CHAN_DATA, "New chandata "
- "received from peer TEI %d"),
- TRACE_EVENT (CE_RX_TRACE_CHAN_DATA_HANDLING, "Handling chandata for "
- "TEI %d"),
- TRACE_EVENT (CE_RX_TRACE_SAR_CB, "Callback from SAR"),
+ TRACE_EVENT (CE_RX_TRACE_MEASURE_HANDLING, "Handling measure for "
+ "TEI %d on TMI %d: CD = %d & PBM = %d"),
+ TRACE_EVENT (CE_RX_TRACE_SAR_CB, "Callback from SAR for TEI %d: "
+ "CD = %d & PBM = %d"),
TRACE_EVENT (CE_RX_TRACE_BL_INITIAL, "Starting initial bit-loading"),
TRACE_EVENT (CE_RX_TRACE_SEND_TONEMAP, "Sending tone map to TEI %d "
"(TMI: new %d - old %d, initial_ce : %d)"),
@@ -84,7 +83,6 @@ ce_rx_trace_init (ce_rx_t *ctx)
TRACE_EVENT (CE_RX_TRACE_FSM_HANDLING_EVENT,
"FSM: %S == %E ==..."),
TRACE_EVENT (CE_RX_TRACE_TONEMAP_INITIAL, "Tone map initial : %x %x %x %x"),
- TRACE_EVENT (CE_RX_TRACE_USING_TONEMAP, "Using tone map index in RX : %d"),
};
dbg_assert (ctx);
trace_namespace_init (&namespace, event_ids, COUNT (event_ids));
diff --git a/cesar/ce/rx/test/Makefile b/cesar/ce/rx/test/Makefile
index 317a8d03e6..593d280ab2 100644
--- a/cesar/ce/rx/test/Makefile
+++ b/cesar/ce/rx/test/Makefile
@@ -8,7 +8,7 @@ ECOS = y
INCLUDES = ce/rx/test/override
# Common modules.
-common_MODULES = ce/rx ce/rx/cp ce/common ce/rx/bitloading \
+common_MODULES = ce/rx ce/rx/cp ce/common \
ce/rx/bitloading/fsm \
lib \
mac/common cp/msg/stub \
@@ -16,9 +16,8 @@ common_MODULES = ce/rx ce/rx/cp ce/common ce/rx/bitloading \
cp/sta/core/stub cl/stub
common_MODULES_CONFIG = mac/pbproc
-# Dirty hack, no bitloading.
-ce_rx_MODULE_SOURCES = rx.c measure.c
-#../$(BASE)/ce/rx/src/bitloading.c
+# Override sources for BL (we only want our stubbed handle event for the FSM).
+ce_rx_bitloading_fsm_MODULE_SOURCES =
# Program list.
TARGET_PROGRAMS = test_rx
diff --git a/cesar/ce/rx/test/src/test_rx.c b/cesar/ce/rx/test/src/test_rx.c
index 3cb75365b8..10ae32f8a2 100644
--- a/cesar/ce/rx/test/src/test_rx.c
+++ b/cesar/ce/rx/test/src/test_rx.c
@@ -17,6 +17,7 @@
#include "ce/rx/measure.h"
#include "ce/rx/inc/measure.h"
#include "ce/rx/inc/rx.h"
+#include "ce/rx/bitloading/fsm/fsm.h"
#include "lib/test.h"
#include "lib/blk.h"
@@ -29,12 +30,22 @@ cyg_handle_t thread_handler;
cyg_thread thread;
test_t test;
static int mbox_size = 0;
+static ce_rx_measure_mbox_t test_measure;
/* Stub bitloadling. */
void
-ce_rx_bitloading_update (ce_rx_t *ce_rx, ce_rx_measure_mbox_t *measure)
+ce_rx_bl_fsm_handle_event (ce_rx_t *ce_rx, sta_t *sta,
+ ce_rx_bl_fsm_event_type_t e,
+ ce_rx_bitloading_fsm_event_param_t data)
{
mbox_size--;
+ /* Copy measure for analysis in test. */
+ test_measure = *data.measure;
+ /* Suspend CE thread otherwise measure will be directly processed and can
+ * not be used any more.
+ * This is the normal behavior because SAR has higher priority than
+ * CE. */
+ cyg_thread_suspend (ce_rx->thread_handler);
}
void
@@ -71,21 +82,104 @@ test_ce_rx_measure_suite (test_t t)
test_begin (t, "no RX params, no channel data & no PB measurements")
{
- ce_rx_measure_sar_cb (ce_rx, NULL, 0, NULL, NULL, NULL, 0, NULL);
+ bool catch = false;
+ char *message;
+ mbox_size = 1;
+ dbg_fatal_try_begin
+ {
+ ce_rx_measure_sar_cb (ce_rx, NULL, 0, NULL, NULL, NULL, 0, NULL);
+ }
+ dbg_fatal_try_catch (message)
+ {
+ catch = true;
+ }
+ dbg_fatal_try_end;
+ test_fail_if (!catch);
+ test_fail_if (mbox_size != 1);
+ /* Resume CE thread. */
+ cyg_thread_resume (ce_rx->thread_handler);
test_fail_if (mbox_peek (&ce_rx->measure_mbox) != 0);
} test_end;
test_begin (t, "some RX params, but no channel data & no PB measurements")
{
- ce_rx_measure_sar_cb (ce_rx, &rx_params, 0, NULL, NULL, NULL, 0, NULL);
+ bool catch = false;
+ char *message;
+ mbox_size = 1;
+ dbg_fatal_try_begin
+ {
+ ce_rx_measure_sar_cb (ce_rx, &rx_params, 0, NULL, NULL, NULL, 0, NULL);
+ }
+ dbg_fatal_try_catch (message)
+ {
+ catch = true;
+ }
+ dbg_fatal_try_end;
+ test_fail_if (!catch);
+ test_fail_if (mbox_size != 1);
+ /* Resume CE thread. */
+ cyg_thread_resume (ce_rx->thread_handler);
test_fail_if (mbox_peek (&ce_rx->measure_mbox) != 0);
} test_end;
- test_begin (t, "some RX params and some channel data & no PB measurements")
+ test_begin (t, "some RX params & some channel data & no PB measurements")
{
pb_t *pb = (pb_t *) blk_alloc_desc ();
- mbox_size++;
+ mbox_size = 1;
ce_rx_measure_sar_cb (ce_rx, &rx_params, 0, NULL, NULL, pb, 1, NULL);
+ test_fail_if (test_measure.chan_data_count != 1);
+ test_fail_if (test_measure.chan_data != (phy_chandata_t *) pb);
+ test_fail_if (test_measure.pb_measurements_count != 0);
+ test_fail_if (mbox_size != 0);
+ /* Resume CE thread. */
+ cyg_thread_resume (ce_rx->thread_handler);
+ test_fail_if (mbox_peek (&ce_rx->measure_mbox) != 0);
+ } test_end;
+
+ test_begin (t, "some RX params & some channel data & one PB measurements")
+ {
+ pb_t *pb = (pb_t *) blk_alloc_desc ();
+ blk_t *fpm = NULL, *lpm = NULL;
+ uint offset = 4242;
+ mbox_size = 1;
+ ce_rx_measure_sar_cb (ce_rx, &rx_params, 1, &fpm, &lpm, pb, 1, &offset);
+ test_fail_if (fpm == NULL);
+ test_fail_if (lpm == NULL);
+ test_fail_if (fpm != lpm);
+ test_fail_if (offset != 0);
+ test_fail_if (mbox_size != 0);
+ test_fail_if (test_measure.chan_data_count != 1);
+ test_fail_if (test_measure.chan_data != (phy_chandata_t *) pb);
+ test_fail_if (test_measure.pb_measurements_count != 1);
+ test_fail_if (test_measure.pb_measurements != fpm);
+ /* Resume CE thread. */
+ cyg_thread_resume (ce_rx->thread_handler);
+ test_fail_if (mbox_peek (&ce_rx->measure_mbox) != 0);
+ } test_end;
+
+ test_begin (t, "some RX params & some channel data & many PB measurements")
+ {
+ pb_t *pb = (pb_t *) blk_alloc_desc ();
+ blk_t *fpm = NULL, *lpm = NULL;
+ uint offset = 4242;
+ mbox_size = 1;
+ /* More than one block of PB measurements. */
+ ce_rx_measure_sar_cb (ce_rx, &rx_params,
+ BLK_SIZE / sizeof (pb_measurement_t) + 1,
+ &fpm, &lpm, pb, 1, &offset);
+ test_fail_if (fpm == NULL);
+ test_fail_if (lpm == NULL);
+ test_fail_if (fpm == lpm);
+ test_fail_if (fpm->next != lpm);
+ test_fail_if (offset != 0);
+ test_fail_if (test_measure.chan_data_count != 1);
+ test_fail_if (test_measure.chan_data != (phy_chandata_t *) pb);
+ test_fail_if (test_measure.pb_measurements_count != BLK_SIZE / sizeof
+ (pb_measurement_t) + 1);
+ test_fail_if (test_measure.pb_measurements != fpm);
+ test_fail_if (mbox_size != 0);
+ /* Resume CE thread. */
+ cyg_thread_resume (ce_rx->thread_handler);
test_fail_if (mbox_peek (&ce_rx->measure_mbox) != 0);
} test_end;