summaryrefslogtreecommitdiff
path: root/cesar/ce
diff options
context:
space:
mode:
authorMilenko Jelisavcic2011-03-03 12:25:08 +0100
committerMilenko Jelisavcic2011-03-03 12:41:57 +0100
commitc2f9aaebc0c0fac178035c584b692c7e0f6d9627 (patch)
tree92ab2c7c17509e0cf70c88a11b63e668ba6acfff /cesar/ce
parentf046b5af5d2e24f999f0c03fc894a31b8181afe7 (diff)
parent36782c42c342a6567aca7d0008fb631e6da10c57 (diff)
Merge branch 'master' of jelisavcic@pessac:/git/cesar into eoc
Conflicts: cesar/bsu/aclf/aclf.h cesar/bsu/aclf/src/aclf.c cesar/bsu/src/bsu.c cesar/ce/rx/bitloading/fsm/src/fsm.c cesar/ce/rx/bitloading/src/transition.c cesar/ce/rx/inc/trace.h cesar/ce/rx/src/trace.c cesar/cp/beacon/src/beacon.c cesar/cp/inc/trace.h cesar/cp/src/trace.c cesar/mac/pbproc/src/fsm_tx_data.c cesar/mac/sar/Config cesar/mac/sar/src/sar.c cesar/tools/sniffer_phy/src/lowlevel.c cleopatre/devkit/plcdrv/arm/src/linux_drv.c cleopatre/devkit/plcdrv/arm/src/mailbox.c
Diffstat (limited to 'cesar/ce')
-rw-r--r--cesar/ce/rx/bitloading/bitloading.h12
-rw-r--r--cesar/ce/rx/bitloading/fsm/src/fsm.c10
-rw-r--r--cesar/ce/rx/bitloading/inc/bitloading.h28
-rw-r--r--cesar/ce/rx/bitloading/src/bitloading.c97
-rw-r--r--cesar/ce/rx/bitloading/src/common.c39
-rw-r--r--cesar/ce/rx/bitloading/src/transition.c23
-rw-r--r--cesar/ce/rx/bitloading/test/common-define.mk2
-rw-r--r--cesar/ce/rx/bitloading/test/fsm-Makefile2
-rw-r--r--cesar/ce/rx/bitloading/test/src/cp_sta_mgr_stub.c34
-rw-r--r--cesar/ce/rx/bitloading/test/src/test_bl.c156
-rw-r--r--cesar/ce/rx/cp/inc/cp.h8
-rw-r--r--cesar/ce/rx/cp/mbox.h9
-rw-r--r--cesar/ce/rx/cp/mme.h9
-rw-r--r--cesar/ce/rx/cp/src/cp.c24
-rw-r--r--cesar/ce/rx/cp/src/mbox.c11
-rw-r--r--cesar/ce/rx/cp/src/mme.c9
-rw-r--r--cesar/ce/rx/cp/stub/src/cp.c4
-rw-r--r--cesar/ce/rx/cp/test/src/test_mbox.c34
-rw-r--r--cesar/ce/rx/cp/test/src/test_mme.c13
-rw-r--r--cesar/ce/rx/inc/trace.h16
-rw-r--r--cesar/ce/rx/src/measure.c4
-rw-r--r--cesar/ce/rx/src/trace.c57
-rw-r--r--cesar/ce/tx/inc/tx.h3
-rw-r--r--cesar/ce/tx/mme.h2
-rw-r--r--cesar/ce/tx/src/mme.c43
-rw-r--r--cesar/ce/tx/src/tx.c18
-rw-r--r--cesar/ce/tx/test/src/test_tm.c10
27 files changed, 415 insertions, 262 deletions
diff --git a/cesar/ce/rx/bitloading/bitloading.h b/cesar/ce/rx/bitloading/bitloading.h
index 8c9867bb65..1765665245 100644
--- a/cesar/ce/rx/bitloading/bitloading.h
+++ b/cesar/ce/rx/bitloading/bitloading.h
@@ -20,6 +20,7 @@
*/
#include "lib/blk.h"
+#include "lib/blk_table.h"
typedef enum ce_rx_bitloading_ber_sliding_mean_t
{
@@ -51,6 +52,12 @@ typedef struct ce_rx_bitloading_t
/** Next time we are allowed to restart the CE. First one is for
* PBErrorRate criteria, second one is for BER criteria. */
u32 next_date_min_for_restart_rtc_date[2];
+ /** Optimisation table of the station, this table only contain the index
+ * of the carrier sorted by impact on the ber. */
+ blk_table_t *opti_table;
+ /**
+ * Index of the optimization cursor in the optimization table. */
+ uint opti_table_cursor;
} ce_rx_bitloading_t;
/**
@@ -109,6 +116,7 @@ ce_rx_bitloading_init (ce_rx_bitloading_t *bt)
dbg_invalid_ptr (bt->noise_nrj);
bt->high_pb_error_rate_frame_counter = 0;
ce_rx_bl_ber_sliding_mean_reset (bt);
+ bt->opti_table = NULL;
}
/**
@@ -145,6 +153,10 @@ ce_rx_bitloading_uninit (ce_rx_bitloading_t *bt)
ce_rx_bl_nsr_clean (bt);
}
/* Letting the FSM in its current state. */
+
+ /* Free optimization table. */
+ if (bt->opti_table != NULL)
+ blk_table_free (bt->opti_table);
}
/**
diff --git a/cesar/ce/rx/bitloading/fsm/src/fsm.c b/cesar/ce/rx/bitloading/fsm/src/fsm.c
index 4f4d847ecd..169e411d49 100644
--- a/cesar/ce/rx/bitloading/fsm/src/fsm.c
+++ b/cesar/ce/rx/bitloading/fsm/src/fsm.c
@@ -29,11 +29,6 @@ ce_rx_bl_fsm_handle_event (ce_rx_t *ce_rx, sta_t *sta, ce_rx_bl_fsm_event_type_t
dbg_assert (fsm < CE_RX_BL_FSM_STATE_NB);
dbg_assert (e < CE_RX_BL_FSM_EVENT_TYPE_NB);
- dbg_assert (sta->rx_tonemaps);
- CE_RX_TRACE_VERBOSE (FSM_HANDLING_EVENT, sta->tei, fsm, e,
- sta->ce_rx_bt.mean_count,
- sta->rx_tonemaps->sound_frame_counter);
-
/* Get transition. */
ce_rx_bl_fsm_transition_t tr = ce_rx_bl_fsm_transition_table[fsm][e];
/* A non managed event is an error. */
@@ -44,9 +39,8 @@ ce_rx_bl_fsm_handle_event (ce_rx_t *ce_rx, sta_t *sta, ce_rx_bl_fsm_event_type_t
dbg_assert (((br >> 8) & 0xff) == e);
sta->ce_rx_bt.fsm = br & 0xff;
- CE_RX_TRACE_VERBOSE (FSM_FROM_TO, sta->tei, fsm, e, sta->ce_rx_bt.fsm,
- sta->ce_rx_bt.mean_count,
- sta->rx_tonemaps->sound_frame_counter);
+ if (fsm != sta->ce_rx_bt.fsm)
+ CE_RX_TRACE (FSM_FROM_TO, sta->tei, fsm, e, sta->ce_rx_bt.fsm);
ce_debug_gpio_event
(CE_DEBUG_GPIO_EVENT_CE_RX_BL_FSM_IDLE + sta->ce_rx_bt.fsm, true);
ce_debug_gpio_event
diff --git a/cesar/ce/rx/bitloading/inc/bitloading.h b/cesar/ce/rx/bitloading/inc/bitloading.h
index 86b0fb26b7..9dd76e5366 100644
--- a/cesar/ce/rx/bitloading/inc/bitloading.h
+++ b/cesar/ce/rx/bitloading/inc/bitloading.h
@@ -127,11 +127,12 @@ ce_rx_bl_update_tone_map_under_ber_consign (u64 ber_pt,
* \param ber_weighted_sum the sum of theoretical BER pondered by modulation
* for the tone map.
* \param tone_en tone enabled count (active but not 0).
+ * \return The position of the cursor in the optimization table.
*
* This function updates a tone map to make it perfectly respect the BER
* consign (or just under).
*/
-void
+u16
ce_rx_bl_update_tone_map_at_ber_consign (u64 ber_pt,
tonemask_info_t *tonemask,
ce_rx_bitloading_t *bl,
@@ -207,14 +208,14 @@ ce_rx_bl_tone_map_update_action (u64 ber_target,
u64 means[CE_RX_BL_BER_SLIDING_MEAN_NB]);
/**
- * Compute the number of tones to shift in the optimisation table depend on
+ * Compute the number of tones to shift in the optimization table depend on
* the BER target, the action to perform and the current BER sliding means.
* \param action action to perform
* \param ber_target ber target
* \param means ber sliding means
- * \return number of shift you may theoretically do on the optimisation
+ * \return number of shift you may theoretically do on the optimization
* table (this number can be out of range).
- * The direction of optimisation only depends on action value.
+ * The direction of optimization only depends on action value.
*/
u16
ce_rx_bl_tone_map_update_count (ce_rx_bl_tone_map_update_actions_t action,
@@ -232,9 +233,9 @@ typedef enum ce_rx_bl_tone_map_update_status_t
CE_RX_BL_TONE_MAP_UPDATE_STATUS_OK,
/** No action to perform, it's ok. */
CE_RX_BL_TONE_MAP_UPDATE_STATUS_NOTHING,
- /** Update ok but minimal limit of optimisation table reached. */
+ /** Update ok but minimal limit of optimization table reached. */
CE_RX_BL_TONE_MAP_UPDATE_STATUS_OUT_OF_RANGE_MIN,
- /** Update ok but maximal limit of optimisation table reached. */
+ /** Update ok but maximal limit of optimization table reached. */
CE_RX_BL_TONE_MAP_UPDATE_STATUS_OUT_OF_RANGE_MAX,
/** Update ok but we stop at first maximum carriage. */
CE_RX_BL_TONE_MAP_UPDATE_STATUS_MAX_CARRIAGE,
@@ -248,14 +249,13 @@ typedef enum ce_rx_bl_tone_map_update_status_t
/**
* Create a new tone map based on old one with some adjustments
- * done using the optimisation table. The new tone map is copied
+ * done using the optimization table. The new tone map is copied
* in new_tonemap depending of the return value. Except if the ERROR status
- * occurs, the number of shift done in the optimisation table is updated.
+ * occurs, the number of shift done in the optimization table is updated.
* \see ce_rx_bl_tone_map_update_status_t).
+ * \param bl pointer to ce_rx_bitloading_t for optimization table access,
+ * ber sliding means and optimization cursor.
* \param ber_target ber target.
- * \param means ber sliding means.
- * \param opti optimisation table (index table).
- * \param opti_cursor position of the cursor in the optimisation table.
* \param tm tone map to update (which stay unedited and is copied to
* new_tonemap in case of successful update).
* \param tone_en tone enabled count.
@@ -263,10 +263,8 @@ typedef enum ce_rx_bl_tone_map_update_status_t
* \return operation status (see ce_rx_bl_tone_map_update_status_t).
*/
ce_rx_bl_tone_map_update_status_t
-ce_rx_bl_tone_map_update_compute_new_tonemap (u64 ber_target,
- u64 means[CE_RX_BL_BER_SLIDING_MEAN_NB],
- u16 *opti,
- uint *opti_cursor,
+ce_rx_bl_tone_map_update_compute_new_tonemap (ce_rx_bitloading_t *bl,
+ u64 ber_target,
tonemap_t *tm,
uint tone_en,
tonemap_t **new_tonemap);
diff --git a/cesar/ce/rx/bitloading/src/bitloading.c b/cesar/ce/rx/bitloading/src/bitloading.c
index 618af43796..8c189a6302 100644
--- a/cesar/ce/rx/bitloading/src/bitloading.c
+++ b/cesar/ce/rx/bitloading/src/bitloading.c
@@ -11,6 +11,7 @@
* \ingroup ce_rx_bl
*/
#include "common/std.h"
+#include "lib/blk_table.h"
#include "ce_rx_bl_fsm_defs.h"
#include "ce/rx/bitloading/inc/ber.h"
#include "ce/rx/bitloading/inc/bitloading.h"
@@ -136,7 +137,7 @@ ce_rx_bl_update_tone_map_under_ber_consign (u64 ber_pt,
return ber_weighted_sum;
}
-void
+u16
ce_rx_bl_update_tone_map_at_ber_consign (u64 ber_pt,
tonemask_info_t *tonemask,
ce_rx_bitloading_t *bl,
@@ -169,7 +170,7 @@ ce_rx_bl_update_tone_map_at_ber_consign (u64 ber_pt,
* all the remaining tone that can be increase are already at the
* maximum too. So basically, we should stop the algorithm here. */
if (mod == CE_MOD_COUNT - 1)
- return;
+ return pos;
/* Remove from number of bits of the tone map the current value. */
tm->bits_per_symbol -= CE_BIT_PER_MOD[mod];
/* Remove from the summed BER of the tone map the current value. */
@@ -210,6 +211,7 @@ ce_rx_bl_update_tone_map_at_ber_consign (u64 ber_pt,
if (mod == 0)
(*tone_en)--;
}
+ return pos;
}
tonemap_t *
@@ -228,7 +230,9 @@ ce_rx_bl_compute_tone_map_iterative (const u64 bpt_initial[PHY_FEC_RATE_NB],
/* Dynamic table size is not possible (because of compiler bug on stack).
* For the moment being we use a define (even if table is too big). */
dbg_assert (tonemask && tonemask->carrier_nb <= PHY_CARRIER_NB);
- ce_rx_bl_ber_impact_t opti[PHY_CARRIER_NB];
+ ce_rx_bl_ber_impact_t opti[PHY_FEC_RATE_NB][PHY_CARRIER_NB];
+ u16 opti_cursor[PHY_FEC_RATE_NB];
+ uint cpt;
u32 sort[PHY_FEC_RATE_NB];
tonemap_t *tm[PHY_FEC_RATE_NB];
uint tone_en;
@@ -256,15 +260,21 @@ ce_rx_bl_compute_tone_map_iterative (const u64 bpt_initial[PHY_FEC_RATE_NB],
ce_rx_bl_update_tone_map_under_ber_consign (ber_cur, tonemask,
fec_rate, bl,
tm[fec_rate],
- opti, &tone_en);
+ opti[fec_rate],
+ &tone_en);
/* Sort optimization table. */
- ce_rx_bl_sort_optimization (opti, tonemask->carrier_nb);
+ ce_rx_bl_sort_optimization (opti[fec_rate], tonemask->carrier_nb);
/* Optimize tone map to reach BER consign. */
- ce_rx_bl_update_tone_map_at_ber_consign
- (ber_cur, tonemask, bl, tm[fec_rate], opti, &ber_weighted_sum,
- &tone_en);
+ opti_cursor[fec_rate] =
+ ce_rx_bl_update_tone_map_at_ber_consign (ber_cur,
+ tonemask,
+ bl,
+ tm[fec_rate],
+ opti[fec_rate],
+ &ber_weighted_sum,
+ &tone_en);
/* Store previous BER consign. */
ber_prev[fec_rate] = ber_cur;
/* We may have zero bit per symbol (when NSR is high for example).
@@ -332,6 +342,17 @@ ce_rx_bl_compute_tone_map_iterative (const u64 bpt_initial[PHY_FEC_RATE_NB],
tm[good]->ber_target_reached = ber_reached[good];
/* Configure tone map for usage. */
tm[good]->cpf = true;
+ /* Copy the optimization table corresponding to the best tone map. */
+ u16 *carrier;
+ if (bl->opti_table == NULL)
+ bl->opti_table = blk_table_init (sizeof (u16), tonemask->carrier_nb);
+ for (cpt = 0; cpt < tonemask->carrier_nb; cpt++)
+ {
+ carrier = (u16 *) blk_table_get (bl->opti_table, cpt);
+ *carrier = opti[good][cpt].carrier_index;
+ }
+ /* Store the cursor of the optimization table for this tone map. */
+ bl->opti_table_cursor = opti_cursor[good];
/* Return best tone map. */
return tm[good];
}
@@ -371,7 +392,7 @@ ce_rx_bl_tone_map_update_count (ce_rx_bl_tone_map_update_actions_t action,
if (action == CE_RX_BL_TONE_MAP_UPDATE_MINUS)
{
- /* Number of carriers we may shift in the optimisation table. */
+ /* Number of carriers we may shift in the optimization table. */
nb = ROUND_DIV (CE_RX_BL_TONE_MAP_UPDATE_MINUS_COEFF *
MAX (means[CE_RX_BL_BER_SLIDING_MEAN_FAST],
means[CE_RX_BL_BER_SLIDING_MEAN_SLOW]),
@@ -385,7 +406,7 @@ ce_rx_bl_tone_map_update_count (ce_rx_bl_tone_map_update_actions_t action,
u64 middle_limit = ber_target
- (u64) (ber_target / CE_RX_BL_TONE_MAP_UPDATE_MIDDLE_PERCENTAGE);
- /* Number of carriers we may shift in the optimisation table. */
+ /* Number of carriers we may shift in the optimization table. */
nb = -1 * ROUND_DIV (CE_RX_BL_TONE_MAP_UPDATE_PLUS_COEFF *
MAX (means[CE_RX_BL_BER_SLIDING_MEAN_FAST],
means[CE_RX_BL_BER_SLIDING_MEAN_SLOW]),
@@ -400,19 +421,19 @@ ce_rx_bl_tone_map_update_count (ce_rx_bl_tone_map_update_actions_t action,
}
ce_rx_bl_tone_map_update_status_t
-ce_rx_bl_tone_map_update_compute_new_tonemap (u64 ber_target,
- u64 means
- [CE_RX_BL_BER_SLIDING_MEAN_NB],
- u16 *opti,
- uint *opti_cursor,
- tonemap_t *tm, uint tone_en,
+ce_rx_bl_tone_map_update_compute_new_tonemap (ce_rx_bitloading_t *bl,
+ u64 ber_target,
+ tonemap_t *tm,
+ uint tone_en,
tonemap_t **new_tonemap)
{
/* New generated tone map. */
tonemap_t *new_tm = NULL;
uint new_opti_cursor = 0;
- /* Number of tones to shift in the optimisation table. */
+ /* Number of tones to shift in the optimization table. */
u16 shift_count = 0;
+ /* Temporary variable of optimization table manipulation. */
+ u16 *tmp;
uint cpt = 0;
ce_rx_bl_tone_map_update_actions_t action = CE_RX_BL_TONE_MAP_UPDATE_NONE;
u32 *tone_word = NULL;
@@ -421,42 +442,44 @@ ce_rx_bl_tone_map_update_compute_new_tonemap (u64 ber_target,
ce_rx_bl_tone_map_update_status_t out = CE_RX_BL_TONE_MAP_UPDATE_STATUS_OK;
/* Check parameters. */
- dbg_assert (opti);
- dbg_assert (opti_cursor);
+ dbg_assert (bl);
dbg_assert (tm);
dbg_assert (new_tonemap);
/* Compute action and shift count. */
- action = ce_rx_bl_tone_map_update_action (ber_target, means);
- shift_count = ce_rx_bl_tone_map_update_count (action, ber_target, means);
+ action = ce_rx_bl_tone_map_update_action (ber_target,
+ (u64 *) bl->ber_sliding_mean);
+ shift_count = ce_rx_bl_tone_map_update_count (action,
+ ber_target,
+ (u64 *) bl->ber_sliding_mean);
- /* Check optimisation table limits and action result. */
+ /* Check optimization table limits and action result. */
switch (action)
{
case CE_RX_BL_TONE_MAP_UPDATE_NONE:
return CE_RX_BL_TONE_MAP_UPDATE_STATUS_NOTHING;
break;
case CE_RX_BL_TONE_MAP_UPDATE_MINUS:
- if (*opti_cursor == 0)
+ if (bl->opti_table_cursor == 0)
return CE_RX_BL_TONE_MAP_UPDATE_STATUS_OUT_OF_RANGE_MIN;
- if ((int) (*opti_cursor - shift_count) < 0)
+ if ((int) (bl->opti_table_cursor - shift_count) < 0)
{
out = CE_RX_BL_TONE_MAP_UPDATE_STATUS_OUT_OF_RANGE_MIN;
new_opti_cursor = 0;
}
else
- new_opti_cursor = *opti_cursor - shift_count;
+ new_opti_cursor = bl->opti_table_cursor - shift_count;
break;
case CE_RX_BL_TONE_MAP_UPDATE_PLUS:
- if (*opti_cursor >= tone_en)
+ if (bl->opti_table_cursor >= tone_en)
return CE_RX_BL_TONE_MAP_UPDATE_STATUS_OUT_OF_RANGE_MAX;
- if (*opti_cursor + shift_count >= tone_en)
+ if (bl->opti_table_cursor + shift_count >= tone_en)
{
out = CE_RX_BL_TONE_MAP_UPDATE_STATUS_OUT_OF_RANGE_MAX;
new_opti_cursor = tone_en - 1;
}
else
- new_opti_cursor = *opti_cursor + shift_count;
+ new_opti_cursor = bl->opti_table_cursor + shift_count;
break;
default:
dbg_assert (action < CE_RX_BL_TONE_MAP_UPDATE_NB);
@@ -471,20 +494,21 @@ ce_rx_bl_tone_map_update_compute_new_tonemap (u64 ber_target,
tonemap_copy (new_tm, tm);
/*
- * For each adjusted tones from the optimisation table,
+ * For each adjusted tones from the optimization table,
* update new tone map.
*/
if (action == CE_RX_BL_TONE_MAP_UPDATE_MINUS)
for (cpt = new_opti_cursor;
- cpt < *opti_cursor;
+ cpt < bl->opti_table_cursor;
cpt++)
{
tone_word = NULL;
- mod = tonemap_get_tone (new_tm, opti[cpt], &tone_word);
+ tmp = (u16 *) blk_table_get (bl->opti_table, cpt);
+ mod = tonemap_get_tone (new_tm, *tmp, &tone_word);
dbg_assert (tone_word);
/* Decrease tone. */
- dbg_check (tonemap_decrease_tone (new_tm, opti[cpt]));
+ dbg_check (tonemap_decrease_tone (new_tm, *tmp));
/* Update bits per symbols. */
new_tm->bits_per_symbol -= CE_BIT_PER_MOD[mod];
@@ -493,15 +517,16 @@ ce_rx_bl_tone_map_update_compute_new_tonemap (u64 ber_target,
if (action == CE_RX_BL_TONE_MAP_UPDATE_PLUS)
/* We must start to boost at the cursor position and stop before new
* cursor position. */
- for (cpt = *opti_cursor;
+ for (cpt = bl->opti_table_cursor;
cpt != new_opti_cursor;
cpt++)
{
tone_word = NULL;
- mod = tonemap_get_tone (new_tm, opti[cpt], &tone_word);
+ tmp = (u16 *) blk_table_get (bl->opti_table, cpt);
+ mod = tonemap_get_tone (new_tm, *tmp, &tone_word);
dbg_assert (tone_word);
/* Increase tone. */
- if (!tonemap_increase_tone (new_tm, opti[cpt]))
+ if (!tonemap_increase_tone (new_tm, *tmp))
{
out = CE_RX_BL_TONE_MAP_UPDATE_STATUS_MAX_CARRIAGE;
break;
@@ -513,6 +538,6 @@ ce_rx_bl_tone_map_update_compute_new_tonemap (u64 ber_target,
}
*new_tonemap = new_tm;
- *opti_cursor = new_opti_cursor;
+ bl->opti_table_cursor = new_opti_cursor;
return out;
}
diff --git a/cesar/ce/rx/bitloading/src/common.c b/cesar/ce/rx/bitloading/src/common.c
index 1a6fef5816..0b9c933b63 100644
--- a/cesar/ce/rx/bitloading/src/common.c
+++ b/cesar/ce/rx/bitloading/src/common.c
@@ -32,27 +32,37 @@ ce_rx_bl_start_bl (ce_rx_t *ce_rx, sta_t *sta, tonemask_info_t *ts)
/* Not using ts directly. */
/* Not using ce_rx directly. */
- CE_RX_TRACE (BL_INITIAL);
+ CE_RX_TRACE (BL_INITIAL, sta->tei);
ce_debug_gpio_event (CE_DEBUG_GPIO_EVENT_CE_RX_BL_WORKING, true);
/* Compute initial tone map. */
tonemap_t *initial_tm = ce_rx_bl_initial (ts, &sta->ce_rx_bt);
- uint i;
-#if CONFIG_TRACE
/* Dump tone map in trace. */
- if (initial_tm != NULL)
- for (i = 0; i < PHY_CARRIER_NB - 8; i += 8)
+ if (CONFIG_TRACE)
+ {
+ dbg_assert (ts);
+#define OFFSET 2
+ int mod_count[OFFSET + CE_MOD_COUNT];
+ uint m;
+ /* Initialize. */
+ mod_count[0] = phy_date ();
+ mod_count[1] = sta->tei;
+ for (m = OFFSET; m < COUNT (mod_count); m++)
+ mod_count[m] = 0;
+ /* Count. */
+ if (initial_tm)
{
- u32 tm_words[4];
- uint j = 0;
- for (j = 0; j < 4; j++)
- tm_words[j] =
- *tonemap_get_tone_word (initial_tm, i + j * 2);
- CE_RX_TRACE_VERBOSE (TONEMAP_INITIAL, tm_words[0], tm_words[1],
- tm_words[2], tm_words[3]);
+ TONEMAP_READ_BEGIN (initial_tm, ts->tonemask, m)
+ {
+ mod_count[m + OFFSET]++;
+ }
+ TONEMAP_READ_END;
}
-#endif
+ /* Trace result. */
+ CE_RX_TRACE_N (TONEMAP, mod_count, COUNT (mod_count));
+#undef OFFSET
+ }
u8 tmi;
/* Compare with ROBO. */
@@ -78,12 +88,13 @@ ce_rx_bl_start_bl (ce_rx_t *ce_rx, sta_t *sta, tonemask_info_t *ts)
ce_rx_bl_ber_sliding_mean_update
(&sta->ce_rx_bt, ce_rx_bl_ber_pt_robo (ts->carrier_nb));
/* Trace it. */
- CE_RX_TRACE (INITIAL_WORSE_THAN_ROBO);
+ CE_RX_TRACE (INITIAL_WORSE_THAN_ROBO, sta->tei);
}
sta->rx_tonemaps->default_tmi = tmi;
ce_rx_cp_send_mme_new_tone_map
(ce_rx, sta, TONEMAP_INDEX_IS_NEGOTIATED (tmi) ? tmi : 0, 0, true);
/* Store next time the CE can restart. */
+ uint i;
for (i = 0; i < COUNT (ce_rx_bl_min_time_between_ce_restart_ms); i++)
sta->ce_rx_bt.next_date_min_for_restart_rtc_date[i]
= cyg_current_time ()
diff --git a/cesar/ce/rx/bitloading/src/transition.c b/cesar/ce/rx/bitloading/src/transition.c
index b414438610..22e593ffa7 100644
--- a/cesar/ce/rx/bitloading/src/transition.c
+++ b/cesar/ce/rx/bitloading/src/transition.c
@@ -100,8 +100,6 @@ ce_rx_bl__common__restart_ce_rx (ce_rx_t *ce_rx, sta_t *sta)
sta->ce_rx_bt.high_pb_error_rate_frame_counter = 0;
/* Reset BER sliding means. */
ce_rx_bl_ber_sliding_mean_reset (&sta->ce_rx_bt);
-
- CE_RX_TRACE_VERBOSE (RESTART_CE, sta->tei);
}
/**
@@ -113,20 +111,13 @@ static void
ce_rx_bl__common__restart_ce (ce_rx_t *ce_rx, sta_t *sta)
{
/* Check parameter. */
- dbg_assert (ce_rx);
dbg_assert (sta);
/* Restart CE in RX. */
ce_rx_bl__common__restart_ce_rx (ce_rx, sta);
- /* Send the MME to the other side. */
- cp_sta_t *cp_sta = cp_sta_mgr_sta_get_assoc
- (ce_rx->cp_ctx, cp_sta_mgr_get_our_avln (ce_rx->cp_ctx), sta->tei);
- dbg_assert (cp_sta);
/* Send MME to restart CE. */
- ce_rx_mme_restart_initial_ce (ce_rx->cp_ctx, cp_sta, sta->rx_tonemaps);
- /* Clean. */
- slab_release (cp_sta);
+ ce_rx_cp_send_mme_restart_initial_ce (ce_rx, sta);
/* In TX, reset default tone map and remove tone maps. */
/* FIXME: this is a dirty hack: we force the TX to re-estimate the
@@ -231,6 +222,7 @@ ce_rx_bl__TRACKING__measure_received (ce_rx_t *ce_rx, sta_t *sta,
ce_debug_gpio_event
(CE_DEBUG_GPIO_EVENT_CE_RX_BL_MEASURE_SOUND, true);
/* Restart CE in RX. */
+ CE_RX_TRACE (RESTART_FORCED, sta->tei);
ce_rx_bl__common__restart_ce_rx (ce_rx, sta);
/* Initialize sum of NSR. */
ce_rx_bl_nsr_sum_init (&sta->ce_rx_bt, measure->chan_data,
@@ -268,9 +260,11 @@ ce_rx_bl__TRACKING__measure_received (ce_rx_t *ce_rx, sta_t *sta,
{
/* Increase frame counter. */
sta->ce_rx_bt.high_pb_error_rate_frame_counter++;
- CE_RX_TRACE (PB_ERR_RATE_HIGH, sta->tei,
- measure->false_pb_count, measure->total_pb_count,
- sta->ce_rx_bt.high_pb_error_rate_frame_counter);
+ CE_RX_TRACE_VERBOSE
+ (PB_ERR_RATE_HIGH, sta->tei,
+ measure->rx_params.tmi_av, measure->false_pb_count,
+ measure->total_pb_count,
+ sta->ce_rx_bt.high_pb_error_rate_frame_counter);
/* Enough frame in this case and not too soon? */
if ((sta->ce_rx_bt.high_pb_error_rate_frame_counter
>= ce_rx_bl_min_frame_with_high_pb_err_rate_)
@@ -280,6 +274,8 @@ ce_rx_bl__TRACKING__measure_received (ce_rx_t *ce_rx, sta_t *sta,
{
ce_debug_gpio_event
(CE_DEBUG_GPIO_EVENT_CE_RX_BL_MEASURE_DATA_HIGH_PB_ERROR_RATE, true);
+ CE_RX_TRACE (RESTART_PB_ERR, sta->tei,
+ sta->ce_rx_bt.high_pb_error_rate_frame_counter);
/* Restart CE. */
ce_rx_bl__common__restart_ce (ce_rx, sta);
@@ -334,6 +330,7 @@ ce_rx_bl__TRACKING__measure_received (ce_rx_t *ce_rx, sta_t *sta,
{
ce_debug_gpio_event
(CE_DEBUG_GPIO_EVENT_CE_RX_BL_MEASURE_DATA_BER_LOW, true);
+ CE_RX_TRACE (RESTART_BER, sta->tei);
/* Restart CE. */
ce_rx_bl__common__restart_ce (ce_rx, sta);
return ce_rx_bl_fsm_next_branch (TRACKING,
diff --git a/cesar/ce/rx/bitloading/test/common-define.mk b/cesar/ce/rx/bitloading/test/common-define.mk
index 0e8dd22ced..1c8e7bd229 100644
--- a/cesar/ce/rx/bitloading/test/common-define.mk
+++ b/cesar/ce/rx/bitloading/test/common-define.mk
@@ -4,7 +4,7 @@
BASE = ../../../..
# Common sources.
-ce_rx_bl_test_sources_common = test_bl.c vector.c cp_sta_mgr_stub.c
+ce_rx_bl_test_sources_common = test_bl.c vector.c
# Common modules.
ce_rx_bl_modules_common = lib \
ce/rx/bitloading/fsm ce/rx/bitloading ce/rx/cp/stub \
diff --git a/cesar/ce/rx/bitloading/test/fsm-Makefile b/cesar/ce/rx/bitloading/test/fsm-Makefile
index f02e52d916..0d61911e79 100644
--- a/cesar/ce/rx/bitloading/test/fsm-Makefile
+++ b/cesar/ce/rx/bitloading/test/fsm-Makefile
@@ -8,7 +8,7 @@ include common-define.mk
HOST_PROGRAMS = test_ce_fsm
test_ce_fsm_SOURCES = scenario_actions.c test_fsm.c scenario_events.c \
- cp_sta_mgr_stub.c ce_rx_bl_stub.c ecos_stub.c
+ ce_rx_bl_stub.c ecos_stub.c
test_ce_fsm_MODULES = $(ce_rx_bl_modules_common) lib/scenario
test_ce_fsm_MODULES_CONFIG = mac/sar cl cp/sta/mgr
diff --git a/cesar/ce/rx/bitloading/test/src/cp_sta_mgr_stub.c b/cesar/ce/rx/bitloading/test/src/cp_sta_mgr_stub.c
deleted file mode 100644
index 87f216a558..0000000000
--- a/cesar/ce/rx/bitloading/test/src/cp_sta_mgr_stub.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2010 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file ce/rx/bitloading/test/src/cp_sta_mgr_stub.c
- * \brief CP Sta Manager stub
- * \ingroup test
- */
-#include "common/std.h"
-
-#include "cp/sta/mgr/sta_mgr.h"
-
-cp_sta_t *
-cp_sta_mgr_sta_get_assoc (cp_t *ctx, cp_net_t *net, cp_tei_t tei)
-{
- static uint init = 0;
- static slab_cache_t slab_cache;
- if (!init)
- {
- init = 1;
- slab_cache_init (&slab_cache, "stub_cp_sta_mgr", 42, NULL);
- }
- return slab_alloc (&slab_cache);
-}
-
-cp_net_t *
-cp_sta_mgr_get_our_avln (cp_t *ctx)
-{
- return INVALID_PTR;
-}
diff --git a/cesar/ce/rx/bitloading/test/src/test_bl.c b/cesar/ce/rx/bitloading/test/src/test_bl.c
index f0729b55d8..bcfd9b6d63 100644
--- a/cesar/ce/rx/bitloading/test/src/test_bl.c
+++ b/cesar/ce/rx/bitloading/test/src/test_bl.c
@@ -538,7 +538,7 @@ test_suite_ce_rx_bl_initial (test_t t)
{
test_case_begin (t, "initial");
- test_begin (t, "test initial tone map generation with special SNR") // XXX
+ test_begin (t, "test initial tone map generation with special SNR")
{
ce_rx_bitloading_t bl;
tonemask_info_t ti;
@@ -1130,10 +1130,10 @@ static void
test_suite_ce_rx_bl_tm_update (test_t t)
{
/**
- * Test for the number of tones to shift in the optimisation table
+ * Test for the number of tones to shift in the optimization table
* depending of a BER target.
*/
- test_begin (t, "test the optimisation table shift counter")
+ test_begin (t, "test the optimization table shift counter")
{
ce_rx_bl_tone_map_update_actions_t out_action;
u16 out;
@@ -1221,10 +1221,10 @@ test_suite_ce_rx_bl_tm_update (test_t t)
} test_end;
/**
- * Test for the number of tones to shift in the optimisation table
+ * Test for the number of tones to shift in the optimization table
* depending of a BER target. Data used here come from vector test.
*/
- test_begin (t, "test the optimisation table shift counter (test vector)")
+ test_begin (t, "test the optimization table shift counter (test vector)")
{
/* Input data from test vector. */
u64 ber_target;
@@ -1397,7 +1397,7 @@ test_suite_ce_rx_bl_tm_update (test_t t)
/**
* Test for creating a new tone map based on old one with some
- * adjustments done using the optimisation table.
+ * adjustments done using the optimization table.
* This test verify that we do not compute a new tone map when we
* we don't need to.
*/
@@ -1405,34 +1405,34 @@ test_suite_ce_rx_bl_tm_update (test_t t)
{
ce_rx_bl_tone_map_update_status_t out = 0;
u64 ber_target = 0;
- u64 means[CE_RX_BL_BER_SLIDING_MEAN_NB];
- u16 opti[PHY_CARRIER_NB];
- uint opti_cursor = 0;
+ ce_rx_bitloading_t bl;
uint tone_en = 0;
tonemap_t *new_tonemap = NULL;
tonemap_t *tm = NULL;
tm = tonemap_alloc ();
ber_target = 100;
- means[CE_RX_BL_BER_SLIDING_MEAN_FAST] = 99;
- means[CE_RX_BL_BER_SLIDING_MEAN_SLOW] = 98;
- opti_cursor = 100;
- out = ce_rx_bl_tone_map_update_compute_new_tonemap (ber_target,
- means,
- opti,
- &opti_cursor,
+ ce_rx_bitloading_init (&bl);
+ bl.ber_sliding_mean[CE_RX_BL_BER_SLIDING_MEAN_FAST] = 99;
+ bl.ber_sliding_mean[CE_RX_BL_BER_SLIDING_MEAN_SLOW] = 98;
+ bl.opti_table_cursor = 100;
+ bl.opti_table = blk_table_init (sizeof (u16), PHY_CARRIER_NB);
+
+ out = ce_rx_bl_tone_map_update_compute_new_tonemap (&bl,
+ ber_target,
tm,
tone_en,
&new_tonemap);
test_fail_if (out != CE_RX_BL_TONE_MAP_UPDATE_STATUS_NOTHING);
test_fail_if (new_tonemap != NULL);
- test_fail_if (opti_cursor != 100);
+ test_fail_if (bl.opti_table_cursor != 100);
tonemap_free (tm);
+ ce_rx_bitloading_uninit (&bl);
} test_end;
/**
* Test for creating a new tone map based on old one with some
- * adjustments done using the optimisation table.
+ * adjustments done using the optimization table.
* This test verify that we correctly compute a new tone when we have
* to do a Tone Map +.
*/
@@ -1440,9 +1440,7 @@ test_suite_ce_rx_bl_tm_update (test_t t)
{
ce_rx_bl_tone_map_update_status_t out = 0;
u64 ber_target = 0;
- u64 means[CE_RX_BL_BER_SLIDING_MEAN_NB];
- u16 opti[PHY_CARRIER_NB];
- uint opti_cursor = 0;
+ ce_rx_bitloading_t bl;
uint tone_en = 0;
tonemap_t *new_tonemap = NULL;
tonemap_t *tm = NULL;
@@ -1451,18 +1449,22 @@ test_suite_ce_rx_bl_tm_update (test_t t)
uint i = 0;
uint old_opti_cursor = 0;
uint bits_per_symbol = 0;
+ u16 *tmp;
/* Preparing input data and supposed output. */
ti.carrier_nb = tonemask_default (ti.tonemask);
tm = tonemap_alloc ();
tone_en = ti.carrier_nb;
+ ce_rx_bitloading_init (&bl);
+ bl.opti_table = blk_table_init (sizeof (u16), tone_en);
uint pos_opti = 0;
uint tone_index_real = 0;
#define TONEMAP_WRITE_OPEN {
#define TONEMAP_WRITE_CLOSE }
TONEMAP_WRITE_BEGIN (tm, ti.tonemask)
{
- opti[pos_opti++] = tone_index_real++;
+ tmp = (u16 *) blk_table_get (bl.opti_table, pos_opti++);
+ *tmp = tone_index_real++;
TONEMAP_WRITE_MOD (1);
tm->bits_per_symbol += CE_BIT_PER_MOD[1];
}
@@ -1475,49 +1477,49 @@ test_suite_ce_rx_bl_tm_update (test_t t)
TONEMAP_WRITE_END;
#undef TONEMAP_WRITE_OPEN
#undef TONEMAP_WRITE_CLOSE
- opti_cursor = tone_en / 2;
- old_opti_cursor = opti_cursor;
+ bl.opti_table_cursor = tone_en / 2;
+ old_opti_cursor = bl.opti_table_cursor;
/* Produce a TM+ operation. */
ber_target = 100;
- means[CE_RX_BL_BER_SLIDING_MEAN_FAST] = 40;
- means[CE_RX_BL_BER_SLIDING_MEAN_SLOW] = 30;
+ bl.ber_sliding_mean[CE_RX_BL_BER_SLIDING_MEAN_FAST] = 40;
+ bl.ber_sliding_mean[CE_RX_BL_BER_SLIDING_MEAN_SLOW] = 30;
/* Test. */
- out = ce_rx_bl_tone_map_update_compute_new_tonemap (ber_target,
- means,
- opti,
- &opti_cursor,
+ out = ce_rx_bl_tone_map_update_compute_new_tonemap (&bl,
+ ber_target,
tm,
tone_en,
&new_tonemap);
/* Check basic errors. */
if (ce_rx_bl_tone_map_update_count (CE_RX_BL_TONE_MAP_UPDATE_PLUS,
- ber_target, means) + opti_cursor <= tone_en)
+ ber_target, (u64 *) bl.ber_sliding_mean)
+ + bl.opti_table_cursor <= tone_en)
{
test_fail_if (out != CE_RX_BL_TONE_MAP_UPDATE_STATUS_OK);
- test_fail_if (opti_cursor != old_opti_cursor
+ test_fail_if (bl.opti_table_cursor != old_opti_cursor
+ ce_rx_bl_tone_map_update_count (
- CE_RX_BL_TONE_MAP_UPDATE_PLUS, ber_target, means));
+ CE_RX_BL_TONE_MAP_UPDATE_PLUS, ber_target, (u64 *) bl.ber_sliding_mean));
}
else
{
test_fail_if (out !=
CE_RX_BL_TONE_MAP_UPDATE_STATUS_OUT_OF_RANGE_MAX);
- test_fail_if (opti_cursor != tone_en - 1);
+ test_fail_if (bl.opti_table_cursor != tone_en - 1);
}
test_fail_if (new_tonemap == NULL);
/* Verify updated values in the new tone map */
- for (i = old_opti_cursor; i < opti_cursor; i++)
+ for (i = old_opti_cursor; i < bl.opti_table_cursor; i++)
{
u32 *word_ptr_old = NULL;
u32 *word_ptr_new = NULL;
+ tmp = (u16 *) blk_table_get (bl.opti_table, i);
u8 mod_old = tonemap_get_tone (tm,
- opti[i],
+ *tmp,
&word_ptr_old);
u8 mod_new = tonemap_get_tone (new_tonemap,
- opti[i],
+ *tmp,
&word_ptr_new);
test_fail_if (mod_old != 1);
test_fail_if (mod_new != 2);
@@ -1531,13 +1533,14 @@ test_suite_ce_rx_bl_tm_update (test_t t)
new_tonemap->bits_per_symbol);
/* Cleanup */
+ ce_rx_bitloading_uninit (&bl);
tonemap_free (tm);
tonemap_free (new_tonemap);
} test_end;
/**
* Test for creating a new tone map based on old one with some
- * adjustments done using the optimisation table.
+ * adjustments done using the optimization table.
* This test verify that we correctly compute a new tone when we have
* to do a Tone Map -.
*/
@@ -1545,9 +1548,7 @@ test_suite_ce_rx_bl_tm_update (test_t t)
{
ce_rx_bl_tone_map_update_status_t out = 0;
u64 ber_target = 0;
- u64 means[CE_RX_BL_BER_SLIDING_MEAN_NB];
- u16 opti[PHY_CARRIER_NB];
- uint opti_cursor = 0;
+ ce_rx_bitloading_t bl;
uint tone_en = 0;
tonemap_t *new_tonemap = NULL;
tonemap_t *tm = NULL;
@@ -1556,18 +1557,22 @@ test_suite_ce_rx_bl_tm_update (test_t t)
uint i = 0;
uint old_opti_cursor = 0;
uint bits_per_symbol = 0;
+ u16 *tmp;
/* Preparing input data and supposed output. */
ti.carrier_nb = tonemask_default (ti.tonemask);
tm = tonemap_alloc ();
tone_en = ti.carrier_nb;
+ ce_rx_bitloading_init (&bl);
+ bl.opti_table = blk_table_init (sizeof (u16), tone_en);
uint pos_opti = 0;
uint tone_index_real = 0;
#define TONEMAP_WRITE_OPEN {
#define TONEMAP_WRITE_CLOSE }
TONEMAP_WRITE_BEGIN (tm, ti.tonemask)
{
- opti[pos_opti++] = tone_index_real++;
+ tmp = (u16 *) blk_table_get (bl.opti_table, pos_opti++);
+ *tmp = tone_index_real++;
TONEMAP_WRITE_MOD (1);
tm->bits_per_symbol += CE_BIT_PER_MOD[1];
}
@@ -1580,51 +1585,51 @@ test_suite_ce_rx_bl_tm_update (test_t t)
TONEMAP_WRITE_END;
#undef TONEMAP_WRITE_OPEN
#undef TONEMAP_WRITE_CLOSE
- opti_cursor = tone_en / 2;
- old_opti_cursor = opti_cursor;
+ bl.opti_table_cursor = tone_en / 2;
+ old_opti_cursor = bl.opti_table_cursor;
/* Produce a TM- operation. */
ber_target = 100;
- means[CE_RX_BL_BER_SLIDING_MEAN_FAST] = 120;
- means[CE_RX_BL_BER_SLIDING_MEAN_SLOW] = 123;
+ bl.ber_sliding_mean[CE_RX_BL_BER_SLIDING_MEAN_FAST] = 120;
+ bl.ber_sliding_mean[CE_RX_BL_BER_SLIDING_MEAN_SLOW] = 123;
/* Test. */
- out = ce_rx_bl_tone_map_update_compute_new_tonemap (ber_target,
- means,
- opti,
- &opti_cursor,
+ out = ce_rx_bl_tone_map_update_compute_new_tonemap (&bl,
+ ber_target,
tm,
tone_en,
&new_tonemap);
/* Check basic errors. */
- if ((int) opti_cursor - (int) ce_rx_bl_tone_map_update_count (
- CE_RX_BL_TONE_MAP_UPDATE_MINUS, ber_target, means) >= 0)
+ if ((int) bl.opti_table_cursor - (int) ce_rx_bl_tone_map_update_count (
+ CE_RX_BL_TONE_MAP_UPDATE_MINUS,
+ ber_target, (u64 *) bl.ber_sliding_mean) >= 0)
{
test_fail_if (out != CE_RX_BL_TONE_MAP_UPDATE_STATUS_OK);
- test_fail_if (opti_cursor != old_opti_cursor -
+ test_fail_if (bl.opti_table_cursor != old_opti_cursor -
ce_rx_bl_tone_map_update_count (CE_RX_BL_TONE_MAP_UPDATE_MINUS
- , ber_target, means));
+ , ber_target, (u64 *) bl.ber_sliding_mean));
}
else
{
test_fail_if (out !=
CE_RX_BL_TONE_MAP_UPDATE_STATUS_OUT_OF_RANGE_MIN);
- test_fail_if (opti_cursor != tone_en - 1);
+ test_fail_if (bl.opti_table_cursor != tone_en - 1);
}
test_fail_if (new_tonemap == NULL);
/* Verify updated values in the new tone map */
- for (i = opti_cursor;
+ for (i = bl.opti_table_cursor;
i < old_opti_cursor;
i++)
{
u32 *word_ptr_old = NULL;
u32 *word_ptr_new = NULL;
+ tmp = (u16 *) blk_table_get (bl.opti_table, i);
u8 mod_old = tonemap_get_tone (tm,
- opti[i],
+ *tmp,
&word_ptr_old);
u8 mod_new = tonemap_get_tone (new_tonemap,
- opti[i],
+ *tmp,
&word_ptr_new);
test_fail_if (mod_old != 1);
@@ -1639,9 +1644,9 @@ test_suite_ce_rx_bl_tm_update (test_t t)
new_tonemap->bits_per_symbol);
/* Cleanup */
+ ce_rx_bitloading_uninit (&bl);
tonemap_free (tm);
- if (new_tonemap)
- tonemap_free (new_tonemap);
+ tonemap_free (new_tonemap);
} test_end;
/*
@@ -1674,7 +1679,7 @@ test_suite_ce_rx_bl_tm_update (test_t t)
uint curs_out;
/* Default tonemask. */
tonemask_info_t dtmask;
- tonemask_default (dtmask.tonemask);
+ dtmask.carrier_nb = tonemask_default (dtmask.tonemask);
/* Variables to check sanity of test vectors. */
u16 shift_count;
ce_rx_bl_tone_map_update_actions_t action;
@@ -1688,7 +1693,7 @@ test_suite_ce_rx_bl_tm_update (test_t t)
ce_mod_per_bit[CE_BIT_PER_MOD[i]] = i;
/* For each tone maps, test the computation of the new tone map based
- * on the optimisation table and ber parameters. */
+ * on the optimization table and ber parameters. */
for (t = 0;
t < bl_iteratif_tm_update_new_tm_IN_1_tone_map_input_width;
t++)
@@ -1769,7 +1774,7 @@ test_suite_ce_rx_bl_tm_update (test_t t)
ber_target,
means));
- /* Sanity check: is the optimisation table valid ?
+ /* Sanity check: is the optimization table valid ?
* At the cursor position and after, tones should be strictly
* under a modulation of 10 bits (except the end of the table).
* Below the cursor, tones should > 0. */
@@ -1783,16 +1788,35 @@ test_suite_ce_rx_bl_tm_update (test_t t)
test_fail_if (mod == 0);
}
+ /* Fill input data in ce_rx_bitloading_t structure. */
+ ce_rx_bitloading_t bl;
+ ce_rx_bitloading_init (&bl);
+ u16 *tmp;
+ for (i = 0; i < CE_RX_BL_BER_SLIDING_MEAN_NB; i++)
+ bl.ber_sliding_mean[i] = (s64) means[i];
+ bl.opti_table_cursor = test_curs;
+ bl.opti_table = blk_table_init (sizeof (u16),
+ bl_iteratif_tm_update_new_tm_IN_2_opti_table_height);
+ for (i = 0;
+ i < bl_iteratif_tm_update_new_tm_IN_2_opti_table_height;
+ i++)
+ {
+ tmp = (u16 *) blk_table_get (bl.opti_table, i);
+ *tmp = opti[i];
+ }
+
/* Test function. */
status = ce_rx_bl_tone_map_update_compute_new_tonemap (
+ &bl,
ber_target,
- means,
- opti,
- &test_curs,
tm_in,
dtmask.carrier_nb,
&computed_tm);
+ /* Re-import data from ce_rx_bitloading_t and free it. */
+ test_curs = bl.opti_table_cursor;
+ ce_rx_bitloading_uninit (&bl);
+
/* Check status. */
test_fail_if (status == CE_RX_BL_TONE_MAP_UPDATE_STATUS_ERROR);
diff --git a/cesar/ce/rx/cp/inc/cp.h b/cesar/ce/rx/cp/inc/cp.h
index 9a0aeee7ca..267f05fafa 100644
--- a/cesar/ce/rx/cp/inc/cp.h
+++ b/cesar/ce/rx/cp/inc/cp.h
@@ -125,6 +125,14 @@ ce_rx_cp_send_mme_new_tone_map (ce_rx_t *ce_rx, sta_t *peer, u8 new_tmi,
void
ce_rx_cp_send_mme_refresh_tmi_list (ce_rx_t *ce_rx, sta_t *peer);
+/**
+ * Send a MME to restart initial CE.
+ * \param ce_rx the CE RX context.
+ * \param peer the destination of the MME.
+ */
+void
+ce_rx_cp_send_mme_restart_initial_ce (ce_rx_t *ce_rx, sta_t *peer);
+
END_DECLS
#endif /* ce_rx_cp_inc_cp_h */
diff --git a/cesar/ce/rx/cp/mbox.h b/cesar/ce/rx/cp/mbox.h
index 18a8ddbf57..bb949efd0f 100644
--- a/cesar/ce/rx/cp/mbox.h
+++ b/cesar/ce/rx/cp/mbox.h
@@ -46,4 +46,13 @@ ce_rx_cp_mbox_t *
ce_rx_cp_mbox_node_refresh_tmi (ce_rx_t *ce_rx, cp_tei_t tei,
tonemaps_t *tms);
+/**
+ * Allocate a message to send CE restart.
+ * \param ce_rx the context of the CE in RX.
+ * \param tei the TEI of the peer STA.
+ * \param tms the RX tome maps.
+ */
+ce_rx_cp_mbox_t *
+ce_rx_cp_mbox_node_restart_ce (ce_rx_t *ce_rx, cp_tei_t tei, tonemaps_t *tms);
+
#endif /* ce_rx_cp_mbox_h */
diff --git a/cesar/ce/rx/cp/mme.h b/cesar/ce/rx/cp/mme.h
index bf244679b3..ec581b70db 100644
--- a/cesar/ce/rx/cp/mme.h
+++ b/cesar/ce/rx/cp/mme.h
@@ -70,15 +70,6 @@ ce_rx_mme_refresh_tone_map_list (cp_t *ctx, cp_sta_t *sta, u32 tmi_list, u8
default_tmi, tonemap_intervals_t *int_list,
tonemaps_t *tms);
-/**
- * Send a CM_TM_UPDATE.IND to restart initial CE.
- * \param ctx the Control Plane context.
- * \param sta the destination of the MME.
- * \param tms the tone maps structure (in RX).
- */
-void
-ce_rx_mme_restart_initial_ce (cp_t *ctx, cp_sta_t *sta, tonemaps_t *tms);
-
END_DECLS
#endif /* ce_rx_cp_mme_h */
diff --git a/cesar/ce/rx/cp/src/cp.c b/cesar/ce/rx/cp/src/cp.c
index 0adabdadcf..bdf09718ce 100644
--- a/cesar/ce/rx/cp/src/cp.c
+++ b/cesar/ce/rx/cp/src/cp.c
@@ -112,6 +112,30 @@ ce_rx_cp_send_mme_refresh_tmi_list (ce_rx_t *ce_rx, sta_t *peer)
}
void
+ce_rx_cp_send_mme_restart_initial_ce (ce_rx_t *ce_rx, sta_t *peer)
+{
+ /* Check parameters. */
+ dbg_assert (peer);
+ dbg_assert (ce_rx);
+ dbg_assert (ce_rx->cp_cb);
+ /* Sanity check: there should be no tone map enabled. */
+ dbg_assert (tonemaps_allocated_count (peer->rx_tonemaps) == 0);
+
+ CE_RX_TRACE (SEND_RESTART_CE, peer->tei);
+
+ /* Create a new work. */
+ ce_rx_cp_mbox_t *work =
+ ce_rx_cp_mbox_node_restart_ce (ce_rx, peer->tei, peer->rx_tonemaps);
+ /* Add it to the list. */
+ mbox_put (&ce_rx->cp_mbox, &work->mbox_node);
+ /* Post a flag for the CP. */
+ ce_rx->cp_cb (ce_rx->cp_ctx);
+
+ /* Disable expiration timer. */
+ peer->rx_tonemaps->refresh_counter_s = 0;
+}
+
+void
ce_rx_cp_run_work (cp_t *ctx)
{
/* Check parameter. */
diff --git a/cesar/ce/rx/cp/src/mbox.c b/cesar/ce/rx/cp/src/mbox.c
index 225e9f6905..15ef3b00a9 100644
--- a/cesar/ce/rx/cp/src/mbox.c
+++ b/cesar/ce/rx/cp/src/mbox.c
@@ -77,3 +77,14 @@ ce_rx_cp_mbox_node_refresh_tmi (ce_rx_t *ce_rx, cp_tei_t tei, tonemaps_t *tms)
return ce_rx_cp_mbox_new_node (ce_rx, tei, tms->default_tmi, tmi_list,
tms->intervals, 0, 0, false);
}
+
+ce_rx_cp_mbox_t *
+ce_rx_cp_mbox_node_restart_ce (ce_rx_t *ce_rx, cp_tei_t tei, tonemaps_t *tms)
+{
+ /* Check parameters. */
+ dbg_assert (tms);
+
+ /* Return allocated node. */
+ return ce_rx_cp_mbox_new_node (ce_rx, tei, 0, 0, tms->intervals, 0, 0,
+ false);
+}
diff --git a/cesar/ce/rx/cp/src/mme.c b/cesar/ce/rx/cp/src/mme.c
index 98157a9d69..6395eef34b 100644
--- a/cesar/ce/rx/cp/src/mme.c
+++ b/cesar/ce/rx/cp/src/mme.c
@@ -523,12 +523,3 @@ ce_rx_mme_refresh_tone_map_list (cp_t *ctx, cp_sta_t *sta, u32 tmi_list, u8
else
tms->refresh_counter_s = 0;
}
-
-void
-ce_rx_mme_restart_initial_ce (cp_t *ctx, cp_sta_t *sta, tonemaps_t *tms)
-{
- ce_rx_mme_send_cm_tm_update_ind (ctx, sta, tms, 0, 0, 0, 0,
- tms->intervals);
- /* Disable expiration timer. */
- tms->refresh_counter_s = 0;
-}
diff --git a/cesar/ce/rx/cp/stub/src/cp.c b/cesar/ce/rx/cp/stub/src/cp.c
index 8ef1ea4100..d621e40725 100644
--- a/cesar/ce/rx/cp/stub/src/cp.c
+++ b/cesar/ce/rx/cp/stub/src/cp.c
@@ -46,10 +46,10 @@ ce_rx_cp_send_mme_new_tone_map (ce_rx_t *ce_rx, sta_t *peer, u8 new_tmi,
}
void
-ce_rx_mme_restart_initial_ce (cp_t *ctx, cp_sta_t *sta, tonemaps_t *tms)
+ce_rx_cp_send_mme_restart_initial_ce (ce_rx_t *ctx, sta_t *sta)
__attribute__ ((weak));
void
-ce_rx_mme_restart_initial_ce (cp_t *ctx, cp_sta_t *sta, tonemaps_t *tms)
+ce_rx_cp_send_mme_restart_initial_ce (ce_rx_t *ctx, sta_t *sta)
{
}
diff --git a/cesar/ce/rx/cp/test/src/test_mbox.c b/cesar/ce/rx/cp/test/src/test_mbox.c
index 1b57117838..0e7efb12dc 100644
--- a/cesar/ce/rx/cp/test/src/test_mbox.c
+++ b/cesar/ce/rx/cp/test/src/test_mbox.c
@@ -19,6 +19,11 @@
#include "lib/test.h"
+static void
+stub_cp_signal_work_cb (cp_t *ctx)
+{
+}
+
/**
* Test mailbox node allocation.
*/
@@ -237,6 +242,33 @@ test_suite_mbox_node (test_t t)
ce_rx_cp_uninit (&ce_rx);
}
+/**
+ * Test mailbox.
+ */
+static void
+test_suite_mbox (test_t t)
+{
+ test_suite_begin (t, "mailbox");
+
+ ce_rx_t ce_rx;
+ ce_rx_cp_init (&ce_rx);
+ ce_rx_cp_set_cp_signal_work_callback (&ce_rx, stub_cp_signal_work_cb,
+ INVALID_PTR);
+
+ /* Create a station. */
+ sta_t peer;
+ peer.rx_tonemaps = tonemaps_alloc ();
+
+ test_begin (t, "request to send a ce restart")
+ {
+ ce_rx_cp_send_mme_restart_initial_ce (&ce_rx, &peer);
+ } test_end;
+
+ /* Clean. */
+ tonemaps_release (peer.rx_tonemaps);
+ ce_rx_cp_uninit (&ce_rx);
+}
+
int
main (int argc, char **argv)
{
@@ -245,6 +277,8 @@ main (int argc, char **argv)
test_suite_mbox_node (t);
+ test_suite_mbox (t);
+
test_begin (t, "memory")
{
test_fail_unless (blk_check_memory ());
diff --git a/cesar/ce/rx/cp/test/src/test_mme.c b/cesar/ce/rx/cp/test/src/test_mme.c
index 11cba0a688..de09b17eea 100644
--- a/cesar/ce/rx/cp/test/src/test_mme.c
+++ b/cesar/ce/rx/cp/test/src/test_mme.c
@@ -492,19 +492,6 @@ mme_test_suite (test_t t)
/* Clean. */
tms->tm[default_tmi] = 0;
} test_end;
- test_begin (t, "CM_TM_UPDATE.IND: restart initial CE")
- {
- tms->refresh_counter_s = CE_RX_REFRESH_TONE_MAP_S;
- cp.vect_size = mme_test_generate_cm_tm_update_ind (&cp, tms, 0, 0,
- NULL, 0);
- mme_test_generate_end_cm_chan_est_ind (&cp);
- /* No interval. */
- tonemap_intervals_t int_list;
- int_list.intervals_nb = 0;
- ce_rx_mme_restart_initial_ce (&cp, &sta, tms);
- /* No need to refresh when there is an empty TMI list. */
- test_fail_if (tms->refresh_counter_s != 0);
- } test_end;
/* Clean. */
tonemap_free (tm);
diff --git a/cesar/ce/rx/inc/trace.h b/cesar/ce/rx/inc/trace.h
index 63977d2387..89b9b5d6cc 100644
--- a/cesar/ce/rx/inc/trace.h
+++ b/cesar/ce/rx/inc/trace.h
@@ -20,10 +20,14 @@
* Shortcut for tracing inside CE RX.
*/
#define CE_RX_TRACE(id, args...) \
- TRACE_SHORT (CE_RX_TRACE_, &ce_rx->trace, id, ## args)
+ TRACE_SHORT (CE_RX_TRACE_, &ce_rx->trace, id, phy_date (), ## args)
+
+#define CE_RX_TRACE_N(id, args, nb_args) \
+ TRACE_N_SHORT (CE_RX_TRACE_, &ce_rx->trace, id, args, nb_args)
#define CE_RX_TRACE_VERBOSE(id, args...) \
- TRACE_FAST_SHORT (CE_RX_TRACE_, &ce_rx->trace_verbose, id, ## args)
+ TRACE_FAST_SHORT (CE_RX_TRACE_, &ce_rx->trace_verbose, id, phy_date (), \
+ ## args)
#if CONFIG_TRACE
@@ -36,12 +40,14 @@ enum
CE_RX_TRACE_BL_INITIAL,
CE_RX_TRACE_SEND_TONEMAP,
CE_RX_TRACE_SEND_TONEMAP_REFRESH,
+ CE_RX_TRACE_SEND_RESTART_CE,
CE_RX_TRACE_FSM_FROM_TO,
- CE_RX_TRACE_FSM_HANDLING_EVENT,
- CE_RX_TRACE_TONEMAP_INITIAL,
+ CE_RX_TRACE_TONEMAP,
CE_RX_TRACE_INITIAL_WORSE_THAN_ROBO,
- CE_RX_TRACE_RESTART_CE,
+ CE_RX_TRACE_RESTART_FORCED,
CE_RX_TRACE_PB_ERR_RATE_HIGH,
+ CE_RX_TRACE_RESTART_PB_ERR,
+ CE_RX_TRACE_RESTART_BER,
CE_RX_TRACE_MISSING_STA,
CE_RX_TRACE_RESET_SFC,
};
diff --git a/cesar/ce/rx/src/measure.c b/cesar/ce/rx/src/measure.c
index 3bca62ac35..d960a3c6de 100644
--- a/cesar/ce/rx/src/measure.c
+++ b/cesar/ce/rx/src/measure.c
@@ -64,7 +64,9 @@ ce_rx_measure_sar_cb (void *data, pbproc_rx_params_t *rx_params,
< CE_RX_MEASURE_MBOX_MAX_SIZE))
{
/* Trace it. */
- CE_RX_TRACE_VERBOSE (SAR_CB, rx_params->tei, chan_data_count, total_pb_count);
+ CE_RX_TRACE_VERBOSE (SAR_CB, rx_params->tei, rx_params->tmi_av,
+ chan_data_count, total_pb_count,
+ rx_params->sound, rx_params->sound_complete);
/* Allocate a measure. */
ce_rx_measure_mbox_t *measure = slab_alloc (&ce_rx->measure_cache);
diff --git a/cesar/ce/rx/src/trace.c b/cesar/ce/rx/src/trace.c
index 272a8faa68..9df66cf518 100644
--- a/cesar/ce/rx/src/trace.c
+++ b/cesar/ce/rx/src/trace.c
@@ -68,27 +68,42 @@ ce_rx_trace_init (ce_rx_t *ctx)
static const trace_event_id_t event_ids[] =
{
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 & PBs = %d (Si = %d, "
- "SC = %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)"),
- TRACE_EVENT (CE_RX_TRACE_SEND_TONEMAP_REFRESH,
- "Sending tone map refresh list to TEI %d"),
- TRACE_EVENT (CE_RX_TRACE_FSM_FROM_TO,
- "FSM[%d]: %S == %E ==> %S (bc=%d, sfc=%d)"),
- TRACE_EVENT (CE_RX_TRACE_FSM_HANDLING_EVENT,
- "FSM[%d]: %S == %E ==... (bc=%d, sfc=%d)"),
- TRACE_EVENT (CE_RX_TRACE_TONEMAP_INITIAL, "Tone map initial : %x %x %x %x"),
- TRACE_EVENT (CE_RX_TRACE_INITIAL_WORSE_THAN_ROBO, "Using ROBO rather "
- "than CE generated tone map"),
- TRACE_EVENT (CE_RX_TRACE_RESTART_CE, "Restart CE for TEI %d"),
- TRACE_EVENT (CE_RX_TRACE_PB_ERR_RATE_HIGH, "PB Error Rate high (for "
- "%d, %d / %d since %d frames)"),
+ TRACE_EVENT (CE_RX_TRACE_UNINIT, "uninit", TIMESTAMP),
+ TRACE_EVENT (CE_RX_TRACE_MEASURE_HANDLING, "tei %d: "
+ "handling measure: tmi=%d, channel_data=%d, "
+ "pb_count=%d, sound=%d, sound_complete=%d",
+ TIMESTAMP),
+ TRACE_EVENT (CE_RX_TRACE_SAR_CB, "tei %d: "
+ "[sar] enqueue measure: tmi=%d, channel_data=%d, "
+ "pb_count=%d, sound=%d, sound_complete=%d",
+ TIMESTAMP),
+ TRACE_EVENT (CE_RX_TRACE_BL_INITIAL, "tei %d: "
+ "initial bit-loading", TIMESTAMP),
+ TRACE_EVENT (CE_RX_TRACE_SEND_TONEMAP, "tei %d: "
+ "send tm: new_tmi=%d, old_tmi=%d, initial_ce=%d",
+ TIMESTAMP),
+ TRACE_EVENT (CE_RX_TRACE_SEND_TONEMAP_REFRESH, "tei %d: "
+ "send tm refresh", TIMESTAMP),
+ TRACE_EVENT (CE_RX_TRACE_SEND_RESTART_CE, "tei %d: "
+ "send ce restart", TIMESTAMP),
+ TRACE_EVENT (CE_RX_TRACE_FSM_FROM_TO, "tei %d: "
+ "[fsm] %S == %E ==> %S", TIMESTAMP),
+ TRACE_EVENT (CE_RX_TRACE_TONEMAP, "tei %d: "
+ "tone map generated: %dx0, %dx1, %dx2, %dx3 "
+ "%dx4, %dx5, %dx6, %dx7", TIMESTAMP),
+ TRACE_EVENT (CE_RX_TRACE_INITIAL_WORSE_THAN_ROBO, "tei %d: "
+ "ROBO is better", TIMESTAMP),
+ TRACE_EVENT (CE_RX_TRACE_RESTART_FORCED, "tei %d: "
+ "forced restart of ce rx - sound received",
+ TIMESTAMP),
+ TRACE_EVENT (CE_RX_TRACE_PB_ERR_RATE_HIGH, "tei %d: "
+ "PBErrRate high: on tmi %d, %d false on %d total "
+ "since %d frames)", TIMESTAMP),
+ TRACE_EVENT (CE_RX_TRACE_RESTART_PB_ERR, "tei %d: "
+ "restart PB error rate too high "
+ "(since %d frames)", TIMESTAMP),
+ TRACE_EVENT (CE_RX_TRACE_RESTART_BER, "tei %d: "
+ "restart BER low", TIMESTAMP),
TRACE_EVENT (CE_RX_TRACE_MISSING_STA, "STA %d does not exist, "
"creating"),
TRACE_EVENT (CE_RX_TRACE_RESET_SFC, "SFC reset, TEI=%d, "
diff --git a/cesar/ce/tx/inc/tx.h b/cesar/ce/tx/inc/tx.h
index 6035c293c9..f535a72280 100644
--- a/cesar/ce/tx/inc/tx.h
+++ b/cesar/ce/tx/inc/tx.h
@@ -39,8 +39,9 @@ BEGIN_DECLS
/**
* Clean tone maps when error detected in them by the PBProc.
* \param tone_maps tone maps to clean.
+ * \return true if the tone maps where cleaned
*/
-void
+bool
ce_tx_clean_tonemaps (tonemaps_t *tone_maps);
END_DECLS
diff --git a/cesar/ce/tx/mme.h b/cesar/ce/tx/mme.h
index 5e74370650..e59e629615 100644
--- a/cesar/ce/tx/mme.h
+++ b/cesar/ce/tx/mme.h
@@ -49,6 +49,8 @@ typedef enum ce_tx_mme_error_code_t
CE_TX_MME_TOO_SHORT,
/** Wrong old TMI. */
CE_TX_MME_OLD_TMI,
+ /** Old TMI is not know by station. */
+ CE_TX_MME_OLD_TMI_NOT_FOUND,
/** Size of the enum or unknown error. */
CE_TX_MME_NB,
} ce_tx_mme_error_code_t;
diff --git a/cesar/ce/tx/src/mme.c b/cesar/ce/tx/src/mme.c
index 123a87a734..41076a712e 100644
--- a/cesar/ce/tx/src/mme.c
+++ b/cesar/ce/tx/src/mme.c
@@ -501,7 +501,9 @@ ce_tx_cm_chan_est_ind_receive (cp_t *ctx, cp_mme_rx_t *mme)
dbg_assert (sta_s_tx_tonemap);
/* Clean tone maps if error detected by the PBProc. */
- ce_tx_clean_tonemaps (sta_s_tx_tonemap);
+ if (ce_tx_clean_tonemaps (sta_s_tx_tonemap))
+ CP_TRACE (CE_TX_RESETED_BY_PBPROC, phy_date (),
+ sta_s_tx_tonemap->default_tmi);
/* Decode CM_CHAN_EST.IND MME. */
@@ -536,6 +538,7 @@ ce_tx_cm_chan_est_ind_receive (cp_t *ctx, cp_mme_rx_t *mme)
* the intervals? Is it useful? */
if (!ntmi)
{
+ CP_TRACE (CE_TX_RESETED_BY_PEER, phy_date (), mme->peer.tei);
sta_s_tx_tonemap->default_tmi = TONEMAP_INDEX_INITIAL_START;
/* Cleaning will be done later (see ce_tx_clean_tonemaps). */
blk_release (sta_s);
@@ -596,7 +599,8 @@ ce_tx_cm_chan_est_ind_receive (cp_t *ctx, cp_mme_rx_t *mme)
/* Clean if needed. */
if (tone_map_tmp)
tonemap_free (tone_map_tmp);
- CP_TRACE (CE_TX_NEW_TONEMAP, new_tmi_av);
+ CP_TRACE (CE_TX_NEW_TONEMAP, phy_date (), mme->peer.tei,
+ new_tmi_av);
}
else
{
@@ -628,14 +632,19 @@ ce_tx_cm_chan_est_ind_receive (cp_t *ctx, cp_mme_rx_t *mme)
sta_s_tx_tonemap->scl_cfp = header.scl_cfp;
/* If default TMI point to a unallocated tone map, it's an error. */
if (header.cp_tmi_av > 3 && !sta_s_tx_tonemap->tm[header.cp_tmi_av])
+ {
sta_s_tx_tonemap->default_tmi = TONEMAP_INDEX_INITIAL_ERROR;
+ CP_TRACE (CE_TX_DEFAULT_TMI_UNAVAILABLE, phy_date (), mme->peer.tei,
+ header.cp_tmi_av);
+ }
else
{
if (sta_s_tx_tonemap->default_tmi != header.cp_tmi_av)
{
ce_debug_gpio_event
(CE_DEBUG_GPIO_EVENT_CE_TX_MME_DEFAULT_TMI_CHANGE, true);
- CP_TRACE (CE_TX_NEW_DEFAULT_TMI, header.cp_tmi_av);
+ CP_TRACE (CE_TX_NEW_DEFAULT_TMI, phy_date (), mme->peer.tei,
+ sta_s_tx_tonemap->default_tmi, header.cp_tmi_av);
sta_s_tx_tonemap->default_tmi = header.cp_tmi_av;
ce_debug_gpio_event
(CE_DEBUG_GPIO_EVENT_CE_TX_MME_DEFAULT_TMI_CHANGE, false);
@@ -656,6 +665,8 @@ ce_tx_cm_chan_est_ind_receive (cp_t *ctx, cp_mme_rx_t *mme)
/* Release tone map. */
tonemap_release_forced (sta_s_tx_tonemap, i);
}
+ CP_TRACE (CE_TX_TMI_AVAILABLE_LIST, phy_date (), mme->peer.tei,
+ tmi_av_list, sta_s_tx_tonemap->default_tmi);
/* Reset expiration value. */
sta_s_tx_tonemap->expiration_s = TONEMAPS_LIFE_DURATION_S;
/* Release reference. */
@@ -682,7 +693,9 @@ ce_tx_cm_tm_update_ind_receive (cp_t *ctx, cp_mme_rx_t *mme)
dbg_assert (sta_s_tx_tonemap);
/* Clean tone maps if error detected by the PBProc. */
- ce_tx_clean_tonemaps (sta_s_tx_tonemap);
+ if (ce_tx_clean_tonemaps (sta_s_tx_tonemap))
+ CP_TRACE (CE_TX_RESETED_BY_PBPROC, phy_date (),
+ sta_s_tx_tonemap->default_tmi);
u8 default_tmi;
u32 tmi_av_list;
@@ -712,6 +725,7 @@ ce_tx_cm_tm_update_ind_receive (cp_t *ctx, cp_mme_rx_t *mme)
* the intervals? Is it useful? */
if (!ntmi)
{
+ CP_TRACE (CE_TX_RESETED_BY_PEER, phy_date (), mme->peer.tei);
sta_s_tx_tonemap->default_tmi = TONEMAP_INDEX_INITIAL_START;
/* Cleaning will be done later (see ce_tx_clean_tonemaps). */
blk_release (sta_s);
@@ -736,8 +750,7 @@ ce_tx_cm_tm_update_ind_receive (cp_t *ctx, cp_mme_rx_t *mme)
/* Get old TMI. */
u8 old_tmi;
- if (!ce_tx_mme_read_tmi (ctx, &mme->bitstream, &old_tmi)
- || !sta_s_tx_tonemap->tm[old_tmi])
+ if (!ce_tx_mme_read_tmi (ctx, &mme->bitstream, &old_tmi))
{
/* Error while decoding MME. */
blk_release (sta_s);
@@ -761,6 +774,13 @@ ce_tx_cm_tm_update_ind_receive (cp_t *ctx, cp_mme_rx_t *mme)
blk_release (sta_s);
return CE_TX_MME_NEW_TMI_DISABLED;
}
+ /* Old TMI should exist. */
+ if (!sta_s_tx_tonemap->tm[old_tmi])
+ {
+ /* Error while decoding MME. */
+ blk_release (sta_s);
+ return CE_TX_MME_OLD_TMI_NOT_FOUND;
+ }
/* Allocate tone map. */
tonemap_t *new_tone_map = tonemap_alloc ();
/* Update the new tone map from the old one. */
@@ -781,7 +801,7 @@ ce_tx_cm_tm_update_ind_receive (cp_t *ctx, cp_mme_rx_t *mme)
/* Clean if needed. */
if (tone_map_tmp)
tonemap_free (tone_map_tmp);
- CP_TRACE (CE_TX_NEW_TONEMAP, new_tmi);
+ CP_TRACE (CE_TX_NEW_TONEMAP, phy_date (), mme->peer.tei, new_tmi);
}
else
{
@@ -802,14 +822,19 @@ ce_tx_cm_tm_update_ind_receive (cp_t *ctx, cp_mme_rx_t *mme)
/* Commit changes. */
/* If default TMI point to a unallocated tone map, it's an error. */
if (default_tmi > 3 && !sta_s_tx_tonemap->tm[default_tmi])
+ {
sta_s_tx_tonemap->default_tmi = TONEMAP_INDEX_INITIAL_ERROR;
+ CP_TRACE (CE_TX_DEFAULT_TMI_UNAVAILABLE, phy_date (), mme->peer.tei,
+ default_tmi);
+ }
else
{
if (sta_s_tx_tonemap->default_tmi != default_tmi)
{
ce_debug_gpio_event
(CE_DEBUG_GPIO_EVENT_CE_TX_MME_DEFAULT_TMI_CHANGE, true);
- CP_TRACE (CE_TX_NEW_DEFAULT_TMI, default_tmi);
+ CP_TRACE (CE_TX_NEW_DEFAULT_TMI, phy_date (), mme->peer.tei,
+ sta_s_tx_tonemap->default_tmi, default_tmi);
sta_s_tx_tonemap->default_tmi = default_tmi;
ce_debug_gpio_event
(CE_DEBUG_GPIO_EVENT_CE_TX_MME_DEFAULT_TMI_CHANGE, false);
@@ -830,6 +855,8 @@ ce_tx_cm_tm_update_ind_receive (cp_t *ctx, cp_mme_rx_t *mme)
/* Release tone map. */
tonemap_release_forced (sta_s_tx_tonemap, i);
}
+ CP_TRACE (CE_TX_TMI_AVAILABLE_LIST, phy_date (), mme->peer.tei,
+ tmi_av_list, sta_s_tx_tonemap->default_tmi);
/* Reset expiration value. */
sta_s_tx_tonemap->expiration_s = TONEMAPS_LIFE_DURATION_S;
diff --git a/cesar/ce/tx/src/tx.c b/cesar/ce/tx/src/tx.c
index dda4395cd7..f1b4255554 100644
--- a/cesar/ce/tx/src/tx.c
+++ b/cesar/ce/tx/src/tx.c
@@ -38,19 +38,25 @@ ce_tx_init (cp_t *cp)
void
ce_tx_process__cm_chan_est_ind (cp_t *ctx, cp_mme_rx_t *mme)
{
+ /* Check parameter. */
+ dbg_assert (mme);
+
ce_tx_mme_error_code_t ret
= ce_tx_cm_chan_est_ind_receive (ctx, mme);
if (ret != CE_TX_MME_OK)
- CP_TRACE (CE_TX_MME_CHAN_EST_ERROR, ret);
+ CP_TRACE (CE_TX_MME_CHAN_EST_ERROR, phy_date (), mme->peer.tei, ret);
}
void
ce_tx_process__cm_update_tm_ind (cp_t *ctx, cp_mme_rx_t *mme)
{
+ /* Check parameter. */
+ dbg_assert (mme);
+
ce_tx_mme_error_code_t ret
= ce_tx_cm_tm_update_ind_receive (ctx, mme);
if (ret != CE_TX_MME_OK)
- CP_TRACE (CE_TX_MME_TM_UPDATE_ERROR, ret);
+ CP_TRACE (CE_TX_MME_TM_UPDATE_ERROR, phy_date (), mme->peer.tei, ret);
}
void
@@ -75,7 +81,8 @@ ce_tx_update_tone_map (cp_t *ctx)
cp_sta = cp_net_sta_get_next (ctx, net, cp_sta))
{
/* Get from mac store a sta from its TEI. */
- sta = mac_store_sta_get (ctx->mac_store, cp_sta_get_tei (cp_sta));
+ cp_tei_t sta_tei = cp_sta_get_tei (cp_sta);
+ sta = mac_store_sta_get (ctx->mac_store, sta_tei);
/* Sta must exist. */
dbg_assert (sta);
dbg_assert (sta->tx_tonemaps);
@@ -84,6 +91,7 @@ ce_tx_update_tone_map (cp_t *ctx)
/* Decrement expiration timer. */
if (sta->tx_tonemaps->expiration_s && !--sta->tx_tonemaps->expiration_s)
{
+ CP_TRACE (CE_TX_TM_EXPIRATION, phy_date (), sta_tei);
/* Reset interval. */
sta->tx_tonemaps->intervals->intervals_nb = 0;
sta->tx_tonemaps->default_tmi = TONEMAP_INDEX_INITIAL_START;
@@ -102,7 +110,7 @@ ce_tx_update_tone_map (cp_t *ctx)
}
}
-void
+bool
ce_tx_clean_tonemaps (tonemaps_t *tone_maps)
{
/* Check parameters. */
@@ -133,5 +141,7 @@ ce_tx_clean_tonemaps (tonemaps_t *tone_maps)
if (tone_maps->tm[i])
tonemap_release_forced (tone_maps, i);
}
+ return true;
}
+ return false;
}
diff --git a/cesar/ce/tx/test/src/test_tm.c b/cesar/ce/tx/test/src/test_tm.c
index 5287e913b5..841e4ebb2c 100644
--- a/cesar/ce/tx/test/src/test_tm.c
+++ b/cesar/ce/tx/test/src/test_tm.c
@@ -32,21 +32,29 @@ ce_test_tm_clean (test_t t)
{
version = 42;
nb = 0;
+ bool cleaned;
/* Configure default tmi for deferent cases. */
switch (i)
{
case 0:
tms->default_tmi = TONEMAP_INDEX_INITIAL_START;
+ cleaned = true;
break;
case 1:
tms->default_tmi = TONEMAP_INDEX_INITIAL_ERROR;
+ cleaned = true;
break;
case 2:
tms->default_tmi = TONEMAP_INDEX_INITIAL_SOUND_COMPLETE;
+ cleaned = true;
break;
case 3:
tms->default_tmi = TONEMAP_INDEX_NEGOTIATED_FIRST;
+ cleaned = false;
+ break;
+ default:
+ dbg_assert_default ();
break;
}
@@ -63,7 +71,7 @@ ce_test_tm_clean (test_t t)
test_fail_if (tms->intervals->intervals_nb != nb);
/* Tests tone maps cleaning. */
- ce_tx_clean_tonemaps (tms);
+ test_fail_if (ce_tx_clean_tonemaps (tms) != cleaned);
if (tms->default_tmi == TONEMAP_INDEX_NEGOTIATED_FIRST)
{