summaryrefslogtreecommitdiff
path: root/cesar/ce
diff options
context:
space:
mode:
authordufour2010-04-14 08:57:04 +0000
committerdufour2010-04-14 08:57:04 +0000
commitf57b67f6b2c243c5acc90aa2a3e830c6ba2b0bd5 (patch)
treee3f2bb3d753fd98532ec28ca857a2e20948c90d8 /cesar/ce
parent00d554ff3f2bd8f7b047319c4c4a5f41bb5adc26 (diff)
cesar/{mac/sar,ce/rx}: update SAR callback to get BER, closes #1442
PB measurements are no longer given by the SAR CB: it directly pre-computes the BER sum (on PBs with no CRC error), the total count of PBs inside the frame and the count of PBs with CRC error in the frame. In the CE, measure now contains: - RX params, - channel data if there are some, - some statistics (total PBs count, total false PBs, BER sum) No need any more to give some pointer to the SAR, measure data are directly delivered from the SAR for copy. Configuration for "PB measurements get flag" is now removed from the CE. Tests have been updated. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@6922 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/ce')
-rw-r--r--cesar/ce/rx/bitloading/test/src/test_fsm.c4
-rw-r--r--cesar/ce/rx/inc/measure.h16
-rw-r--r--cesar/ce/rx/inc/rx.h4
-rw-r--r--cesar/ce/rx/measure.h15
-rw-r--r--cesar/ce/rx/src/measure.c149
-rw-r--r--cesar/ce/rx/src/rx.c2
-rw-r--r--cesar/ce/rx/src/trace.c2
-rw-r--r--cesar/ce/rx/stub/src/rx.c22
-rw-r--r--cesar/ce/rx/test/src/test_rx.c95
9 files changed, 75 insertions, 234 deletions
diff --git a/cesar/ce/rx/bitloading/test/src/test_fsm.c b/cesar/ce/rx/bitloading/test/src/test_fsm.c
index 8ad78b2b06..122f441a85 100644
--- a/cesar/ce/rx/bitloading/test/src/test_fsm.c
+++ b/cesar/ce/rx/bitloading/test/src/test_fsm.c
@@ -31,9 +31,9 @@ u8 ce_rx_bl_min_frame_with_high_pb_err_rate_;
static void
test_ce_rx_bl_measure_empty (ce_rx_measure_mbox_t *m)
{
- m->pb_measurements = NULL;
m->chan_data = NULL;
- m->pb_measurements_count = m->chan_data_count = 0;
+ m->chan_data_count = 0;
+ m->total_pb_count = m->false_pb_count = m->ber_sum = 0;
m->rx_params.tmi_av = 24;
m->rx_params.sound = false;
m->rx_params.sound_complete = false;
diff --git a/cesar/ce/rx/inc/measure.h b/cesar/ce/rx/inc/measure.h
index 26a215cc73..420ef676d8 100644
--- a/cesar/ce/rx/inc/measure.h
+++ b/cesar/ce/rx/inc/measure.h
@@ -46,21 +46,17 @@ typedef struct ce_rx_measure_mbox_t
*/
uint chan_data_count;
/**
- * Count of PB measurements.
- */
- uint pb_measurements_count;
- /**
- * PB measurements.
- */
- blk_t *pb_measurements;
- /**
- * Count of false PB (or -1 if none).
+ * Count of false PB (CRC wrong) in the frame.
*/
u8 false_pb_count;
/**
- * Total PB.
+ * Total count of PB in the frame.
*/
u8 total_pb_count;
+ /**
+ * BER sum of PBs with good CRC in the frame.
+ */
+ u32 ber_sum;
} ce_rx_measure_mbox_t;
diff --git a/cesar/ce/rx/inc/rx.h b/cesar/ce/rx/inc/rx.h
index 4000b11fb1..9be3e1174d 100644
--- a/cesar/ce/rx/inc/rx.h
+++ b/cesar/ce/rx/inc/rx.h
@@ -125,10 +125,6 @@ struct ce_rx_t
*/
trace_buffer_t trace_verbose;
#endif
- /**
- * Get PB measurements from the SAR?
- */
- bool measure_get_pbm;
};
/**
diff --git a/cesar/ce/rx/measure.h b/cesar/ce/rx/measure.h
index 526e3e3046..409b751f0e 100644
--- a/cesar/ce/rx/measure.h
+++ b/cesar/ce/rx/measure.h
@@ -34,22 +34,19 @@ BEGIN_DECLS
* Call back called by the SAR to give the measures.
* \param data the context of the CE RX.
* \param rx_params general information on measures (date, from).
- * \param pbm_count number of PB measurements available.
- * \param first_pbm the first block used to store the PB measurements.
- * \param last_pbm the last block used to store the PB measurements.
+ * \param total_pb_count number of PBs available in the frame.
* \param chan_data the head of the channel data.
* \param chan_data_count the count of PBs in the channel data.
* \param false_pb_count number of false PBs (CRC error) inside the frame.
- * \return true if there are one or more blocks allocated to store the
- * measurements.
+ * \param ber_sum BER sum of each PBs with no CRC error inside the frame.
*
* Have a look at \sa sar_measurement_cb_t.
*/
-bool
+void
ce_rx_measure_sar_cb (void *data, pbproc_rx_params_t *rx_params,
- uint pbm_count, blk_t **first_pbm, blk_t **last_pbm,
- pb_t *chan_data, uint chan_data_count,
- u8 **false_pb_count);
+ uint total_pb_count, pb_t *chan_data,
+ uint chan_data_count, u8 false_pb_count,
+ u32 ber_sum);
END_DECLS
diff --git a/cesar/ce/rx/src/measure.c b/cesar/ce/rx/src/measure.c
index 961caecf26..6c30a97041 100644
--- a/cesar/ce/rx/src/measure.c
+++ b/cesar/ce/rx/src/measure.c
@@ -17,30 +17,6 @@
#include "ce/rx/inc/rx.h"
#include "lib/utils.h"
-
-/**
- * Do we need to get the PB measurements from the SAR?
- * \param ce_rx the CE/RX context.
- * \param rx_params the RX parameters.
- * \param pbm_count number of PB measurements possible to get.
- * \return true if we need to get the PB measurements, false otherwise.
- *
- * This function will be quite useful to optimize the performance, in order to
- * get the PB measurements only when required.
- */
-static inline bool
-ce_rx_measure_get_pbm (ce_rx_t *ce_rx, pbproc_rx_params_t *rx_params,
- uint pbm_count)
-{
- /* Check parameters. */
- dbg_assert (ce_rx);
-
- /* PB measurements enabled and some PB measurements? */
- if (ce_rx->measure_get_pbm && pbm_count)
- return true;
- return false;
-}
-
/**
* Destructor for a measure.
*/
@@ -54,104 +30,57 @@ ce_rx_measure_cache_destructor (void *object)
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
+void
ce_rx_measure_sar_cb (void *data, pbproc_rx_params_t *rx_params,
- uint pbm_count, blk_t **first_pbm, blk_t **last_pbm,
- pb_t *chan_data, uint chan_data_count,
- u8 **false_pb_count)
+ uint total_pb_count, pb_t *chan_data,
+ uint chan_data_count, u8 false_pb_count,
+ u32 ber_sum)
{
- /* Check needed parameters. */
- dbg_assert (data);
+ /* Check parameter required for test. */
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;
+ /* Only handle measures for a "valid" STA. */
+ if (MAC_TEI_IS_STA (rx_params->tei))
+ {
+ /* Check all parameters. */
+ dbg_assert (data);
+ /* We must have something to do. */
+ dbg_assert (chan_data || total_pb_count);
- /* No PB measurements by default. */
- bool ret = false;
+ /* Get the context of the CE RX. */
+ ce_rx_t *ce_rx = (ce_rx_t *) data;
- CE_RX_TRACE_VERBOSE (SAR_CB, rx_params->tei, chan_data_count, pbm_count);
+ /* Trace it. */
+ CE_RX_TRACE_VERBOSE (SAR_CB, rx_params->tei, chan_data_count, total_pb_count);
- if (false_pb_count)
- /* By default, do not get false PB count. */
- *false_pb_count = NULL;
+ /* Allocate a measure. */
+ ce_rx_measure_mbox_t *measure = slab_alloc (&ce_rx->measure_cache);
- /* Only handle measures for a "valid" STA. */
- if (MAC_TEI_IS_STA (rx_params->tei))
- {
- /* Even if we have something to do, sometimes we do not want. */
- /* Get PB measurements? */
- bool get_pbm = ce_rx_measure_get_pbm (ce_rx, rx_params, pbm_count);
- /* Something to get? */
- if (chan_data_count || (get_pbm || pbm_count))
+ /* Copy needed information. */
+ measure->rx_params = *rx_params;
+ measure->total_pb_count = total_pb_count;
+ measure->false_pb_count = false_pb_count;
+ measure->ber_sum = ber_sum;
+
+ /* Any channel data? */
+ measure->chan_data_count = chan_data_count;
+ if (chan_data_count)
{
- /* Allocate a measure. */
- ce_rx_measure_mbox_t *measure = slab_alloc (&ce_rx->measure_cache);
- /* Copy needed information. */
- measure->rx_params = *rx_params;
-
- measure->false_pb_count = 0;
- measure->total_pb_count = pbm_count;
- if (false_pb_count)
- /* Get count of false PB. */
- *false_pb_count = &measure->false_pb_count;
-
- /* 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 to get? */
- if (get_pbm)
- {
- dbg_assert (first_pbm);
- dbg_assert (last_pbm);
- dbg_assert (pbm_count);
- dbg_assert (false_pb_count);
-
- measure->pb_measurements_count = pbm_count;
- /* 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;
- ret = true;
- }
- else
- {
- measure->pb_measurements_count = 0;
- 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);
+ dbg_assert (chan_data);
+ measure->chan_data = (phy_chandata_t *) chan_data;
+ }
+ else
+ {
+ dbg_invalid_ptr (measure->chan_data);
}
- }
- return ret;
+ /* 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);
+ }
}
void
@@ -168,8 +97,6 @@ ce_rx_measure_init (ce_rx_t *ce_rx, sar_t *sar, pbproc_t *pbproc)
slab_cache_init (&ce_rx->measure_cache, "ce_rx_measure",
sizeof (ce_rx_measure_mbox_t),
&ce_rx_measure_cache_destructor);
- /* Disable PB measurements for the moment being (FIXME). */
- ce_rx->measure_get_pbm = false;
/* Register our callback to get measures. */
sar_init_measure_context (sar, ce_rx);
sar_init_measurement_cb (sar, ce_rx_measure_sar_cb);
diff --git a/cesar/ce/rx/src/rx.c b/cesar/ce/rx/src/rx.c
index c046e5b9b5..f8bb6bbd0e 100644
--- a/cesar/ce/rx/src/rx.c
+++ b/cesar/ce/rx/src/rx.c
@@ -206,7 +206,7 @@ ce_rx_process_work_measure (ce_rx_t *ce_rx)
CE_RX_TRACE_VERBOSE (MEASURE_HANDLING, measure->rx_params.tei,
measure->rx_params.tmi_av,
measure->chan_data_count,
- measure->pb_measurements_count,
+ measure->total_pb_count,
measure->rx_params.sound,
measure->rx_params.sound_complete);
diff --git a/cesar/ce/rx/src/trace.c b/cesar/ce/rx/src/trace.c
index 95a9707ccc..148e782239 100644
--- a/cesar/ce/rx/src/trace.c
+++ b/cesar/ce/rx/src/trace.c
@@ -70,7 +70,7 @@ 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_HANDLING, "Handling measure for "
- "TEI %d on TMI %d: CD = %d & PBM = %d (Si = %d, "
+ "TEI %d on TMI %d: CD = %d & PBs = %d (Si = %d, "
"SC = %d)"),
TRACE_EVENT (CE_RX_TRACE_SAR_CB, "Callback from SAR for TEI %d: "
"CD = %d & PBM = %d"),
diff --git a/cesar/ce/rx/stub/src/rx.c b/cesar/ce/rx/stub/src/rx.c
index ff45ef2798..6ccd3650d2 100644
--- a/cesar/ce/rx/stub/src/rx.c
+++ b/cesar/ce/rx/stub/src/rx.c
@@ -22,21 +22,13 @@
static ce_rx_t ce_rx;
-bool
-ce_measurement (void *user, pbproc_rx_params_t *rx_params,
- uint pb_nb, blk_t **first_blk, blk_t **last_blk,
- pb_t *chan_data, uint nb_chandata, u8 **pb_false_count)
+void
+ce_measurements (void *data, pbproc_rx_params_t *rx_params,
+ uint total_pb_count, pb_t *chan_data,
+ uint chan_data_count, u8 false_pb_count, u32 ber_sum)
{
- if (nb_chandata)
- blk_release_desc_range_nb ((blk_t *) chan_data, nb_chandata);
-
- if (pb_false_count)
- {
- dbg_assert (pb_nb);
- *pb_false_count = NULL;
- }
-
- return false;
+ if (chan_data)
+ blk_release_desc_range_nb ((blk_t*) chan_data, chan_data_count);
}
ce_rx_t *
@@ -48,7 +40,7 @@ ce_rx_init (mac_store_t *mac_store, sar_t *sar, pbproc_t *pbproc,
mac_config_t *mac_config)
{
sar_init_measure_context (sar, NULL);
- sar_init_measurement_cb (sar, ce_measurement);
+ sar_init_measurement_cb (sar, ce_measurements);
return &ce_rx;
}
diff --git a/cesar/ce/rx/test/src/test_rx.c b/cesar/ce/rx/test/src/test_rx.c
index 322207d55b..b3c080161d 100644
--- a/cesar/ce/rx/test/src/test_rx.c
+++ b/cesar/ce/rx/test/src/test_rx.c
@@ -71,7 +71,7 @@ test_rx_ce_suite (test_t t)
}
void
-test_ce_rx_measure_suite (test_t t, bool measure_get_pbm)
+test_ce_rx_measure_suite (test_t t)
{
pbproc_rx_params_t rx_params;
rx_params.tei = 1;
@@ -79,27 +79,17 @@ test_ce_rx_measure_suite (test_t t, bool measure_get_pbm)
sar_t *sar = sar_init (mac_store, NULL, NULL, 0x1);
pbproc_t *pbproc = (pbproc_t *) t;
mac_config_t mac_config;
- u8 *false_pb;
- dbg_invalid_ptr (false_pb);
ce_rx_t *ce_rx = ce_rx_init (mac_store, sar, pbproc, &mac_config);
- if (measure_get_pbm)
- test_case_begin (t, "measure with PB measurement enabled");
- else
- test_case_begin (t, "measure with PB measurement disabled");
-
- ce_rx->measure_get_pbm = measure_get_pbm;
-
- test_begin (t, "no RX params, no channel data & no PB measurements")
+ test_begin (t, "no RX params, no channel data & no PB stats")
{
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,
- &false_pb);
+ ce_rx_measure_sar_cb (ce_rx, NULL, 0, NULL, 0, 0, 0);
}
dbg_fatal_try_catch (message)
{
@@ -113,15 +103,14 @@ test_ce_rx_measure_suite (test_t t, bool measure_get_pbm)
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")
+ test_begin (t, "some RX params, but no channel data & no PB stats")
{
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,
- &false_pb);
+ ce_rx_measure_sar_cb (ce_rx, &rx_params, 0, NULL, 0, 0, 0);
}
dbg_fatal_try_catch (message)
{
@@ -135,90 +124,35 @@ test_ce_rx_measure_suite (test_t t, bool measure_get_pbm)
test_fail_if (mbox_peek (&ce_rx->measure_mbox) != 0);
} test_end;
- test_begin (t, "some RX params & some channel data & no PB measurements")
+ test_begin (t, "some RX params & some channel data & no PB stats")
{
pb_t *pb = (pb_t *) blk_alloc_desc ();
mbox_size = 1;
- ce_rx_measure_sar_cb (ce_rx, &rx_params, 0, NULL, NULL, pb, 1,
- &false_pb);
+ ce_rx_measure_sar_cb (ce_rx, &rx_params, 0, pb, 1, 0, 0);
test_fail_if (test_measure == 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 (test_measure->total_pb_count != 0);
test_fail_if (test_measure->false_pb_count != 0);
+ test_fail_if (test_measure->ber_sum != 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")
+ test_begin (t, "some RX params & some channel data & PB stats")
{
pb_t *pb = (pb_t *) blk_alloc_desc ();
- blk_t *fpm = NULL, *lpm = NULL;
mbox_size = 1;
- false_pb = NULL;
- ce_rx_measure_sar_cb (ce_rx, &rx_params, 1, &fpm, &lpm, pb, 1,
- &false_pb);
+ ce_rx_measure_sar_cb (ce_rx, &rx_params, 42, pb, 1, 24, 4242);
test_fail_if (mbox_size != 0);
test_fail_if (test_measure == 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->total_pb_count != 1);
- test_fail_if (&test_measure->false_pb_count != false_pb);
- if (measure_get_pbm)
- {
- test_fail_if (fpm == NULL);
- test_fail_if (lpm == NULL);
- test_fail_if (fpm != lpm);
- test_fail_if (test_measure->pb_measurements_count != 1);
- test_fail_if (test_measure->pb_measurements != fpm);
- }
- else
- {
- test_fail_if (fpm != NULL);
- test_fail_if (lpm != NULL);
- test_fail_if (test_measure->pb_measurements_count != 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 & many PB measurements")
- {
- pb_t *pb = (pb_t *) blk_alloc_desc ();
- blk_t *fpm = NULL, *lpm = NULL;
- mbox_size = 1;
- false_pb = NULL;
- /* 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, &false_pb);
- test_fail_if (test_measure == NULL);
- test_fail_if (test_measure->chan_data_count != 1);
- test_fail_if (test_measure->chan_data != (phy_chandata_t *) pb);
- test_fail_if (mbox_size != 0);
- test_fail_if (test_measure->total_pb_count
- != BLK_SIZE / sizeof (pb_measurement_t) + 1);
- test_fail_if (&test_measure->false_pb_count != false_pb);
- if (measure_get_pbm)
- {
- test_fail_if (fpm == NULL);
- test_fail_if (lpm == NULL);
- test_fail_if (fpm == lpm);
- test_fail_if (fpm->next != lpm);
- test_fail_if (test_measure->pb_measurements_count != BLK_SIZE / sizeof
- (pb_measurement_t) + 1);
- test_fail_if (test_measure->pb_measurements != fpm);
- }
- else
- {
- test_fail_if (fpm != NULL);
- test_fail_if (lpm != NULL);
- test_fail_if (test_measure->pb_measurements_count != 0);
- }
+ test_fail_if (test_measure->total_pb_count != 42);
+ test_fail_if (test_measure->false_pb_count != 24);
+ test_fail_if (test_measure->ber_sum != 4242);
/* Resume CE thread. */
cyg_thread_resume (ce_rx->thread_handler);
test_fail_if (mbox_peek (&ce_rx->measure_mbox) != 0);
@@ -293,8 +227,7 @@ test_rx_ce_thread (cyg_addrword_t data)
test_rx_ce_suite (test);
- test_ce_rx_measure_suite (test, true);
- test_ce_rx_measure_suite (test, false);
+ test_ce_rx_measure_suite (test);
test_ce_rx_get_snr (test);