summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyril Jourdan2012-11-21 17:15:06 +0100
committerCyril Jourdan2013-01-18 11:27:21 +0100
commit711ffd426f5144f2f2247c366da323e1fa4dae8a (patch)
tree8f4676703b760c78cba32d72d1c2aecb535028c1
parentbf2c0ff938490ec4b1a7544a9a6de65497aec11f (diff)
cesar/ce/rx: include bsu_aclf context pointer in CE RX, refs #2366
-rw-r--r--cesar/ce/rx/bitloading/inc/common.h4
-rw-r--r--cesar/ce/rx/bitloading/src/common.c98
-rw-r--r--cesar/ce/rx/bitloading/src/transition.c2
-rw-r--r--cesar/ce/rx/bitloading/test/src/scenario_events.c2
-rw-r--r--cesar/ce/rx/bitloading/test/src/test_fsm.c1
-rw-r--r--cesar/ce/rx/inc/trace.h2
-rw-r--r--cesar/ce/rx/src/trace.c6
7 files changed, 82 insertions, 33 deletions
diff --git a/cesar/ce/rx/bitloading/inc/common.h b/cesar/ce/rx/bitloading/inc/common.h
index 48e6ce3479..cd54986874 100644
--- a/cesar/ce/rx/bitloading/inc/common.h
+++ b/cesar/ce/rx/bitloading/inc/common.h
@@ -33,13 +33,13 @@ BEGIN_DECLS
* Start initial bit loading when we receive a sound complete flag.
* \param ce_rx the ce_rx context.
* \param sta the peer station.
- * \param ts the tone mask.
+ * \param fsm_id FSM id, CE_RX_MEASURE_NO_INTERVAL refers to main FSM.
*
* This function compute the tone map, set it and send the required MME to the
* peer.
*/
void
-ce_rx_bl_start_bl (ce_rx_t *ce_rx, sta_t *sta, tonemask_info_t *ts);
+ce_rx_bl_start_bl (ce_rx_t *ce_rx, sta_t *sta, int fsm_id);
/**
* Compare tone map to ROBO.
diff --git a/cesar/ce/rx/bitloading/src/common.c b/cesar/ce/rx/bitloading/src/common.c
index ac985b5fb4..fa1f8db1f7 100644
--- a/cesar/ce/rx/bitloading/src/common.c
+++ b/cesar/ce/rx/bitloading/src/common.c
@@ -16,6 +16,8 @@
#include "ce/rx/bitloading/inc/initial.h"
#include "ce/rx/bitloading/inc/common.h"
#include "ce/rx/bitloading/inc/ber.h"
+#include "ce/rx/bitloading/inc/intervals.h"
+#include "ce/rx/inc/measure.h"
#include "ce/rx/cp/inc/cp.h"
#include "ce/rx/inc/trace.h"
#include "ce/rx/ce_rx_param.h"
@@ -32,37 +34,61 @@ uint ce_rx_bl_min_time_between_ce_restart_ms[CE_RX_BL_DATE_CRITERIA_NB] =
};
void
-ce_rx_bl_start_bl (ce_rx_t *ce_rx, sta_t *sta, tonemask_info_t *ts)
+ce_rx_bl_start_bl (ce_rx_t *ce_rx, sta_t *sta, int fsm_id)
{
/* Check parameters. */
+ dbg_assert (ce_rx);
dbg_assert (sta);
+ dbg_assert (ce_rx->mac_config);
/* Not using ts directly. */
/* Not using ce_rx directly. */
-
+ ce_rx_bitloading_t *bt;
+ /* Initial CE is used when this is the first time we use a tone map with
+ * the station. */
+ bool initial_ce;
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, &ce_rx->tonemask,
- &sta->ce_rx_bt);
+ tonemask_info_t *ts = &ce_rx->mac_config->tonemask_info;
+ /* This is the default tone map. */
+ if (fsm_id == CE_RX_MEASURE_NO_INTERVAL)
+ {
+ bt = &sta->ce_rx_bt;
+ initial_ce = true;
+ }
+ /* Tone map for an interval. */
+ else
+ {
+ dbg_assert (sta->intervals);
+ bt = sta->intervals->intervals[fsm_id];
+ /* We don't have an initial CE here because with intervals, we already
+ * have a default tone map. */
+ initial_ce = false;
+ }
+
+ /* Compute new tone map. */
+ tonemap_t *new_tm = ce_rx_bl_initial (ts, &ce_rx->tonemask, bt);
/* Dump tone map in trace. */
if (CONFIG_TRACE)
{
dbg_assert (ts);
#define OFFSET 3
- int mod_count[OFFSET + CE_MOD_COUNT];
+ /* The last field of mod_count is used to store the fsm id in the
+ * trace */
+ int mod_count[OFFSET + CE_MOD_COUNT + 1];
+ mod_count [OFFSET + CE_MOD_COUNT] = fsm_id;
uint m;
uint sum = 0;
/* Initialize. */
mod_count[0] = phy_date ();
mod_count[1] = sta->tei;
- for (m = OFFSET; m < COUNT (mod_count); m++)
+ for (m = OFFSET; m < COUNT (mod_count) - 1; m++)
mod_count[m] = 0;
/* Count. */
- if (initial_tm)
+ if (new_tm)
{
- TONEMAP_READ_BEGIN (initial_tm, ts->tonemask, m)
+ TONEMAP_READ_BEGIN (new_tm, ts->tonemask, m)
{
mod_count[m + OFFSET]++;
sum += m;
@@ -75,39 +101,61 @@ ce_rx_bl_start_bl (ce_rx_t *ce_rx, sta_t *sta, tonemask_info_t *ts)
#undef OFFSET
}
- u8 tmi;
+ u8 new_tmi, old_tmi;
+ u64 ber;
/* Compare with ROBO. */
- if (initial_tm != NULL && ce_rx_bl_tonemap_better_than_robo (initial_tm, ts))
+ if (new_tm != NULL && ce_rx_bl_tonemap_better_than_robo (new_tm, ts))
{
/* Set it. */
- tmi = tonemaps_set_first_free_tmi (sta->rx_tonemaps, initial_tm);
+ new_tmi = tonemaps_set_first_free_tmi (sta->rx_tonemaps, new_tm);
/* This assert is required because this is the first time we ever
* set a tone map in the life of this STA. So we MUST have an
* empty tone map index available! */
- dbg_assert (tmi != 0);
- ce_rx_bl_ber_sliding_mean_update (&sta->ce_rx_bt,
- initial_tm->ber_target_reached);
+ dbg_assert (new_tmi != 0);
+ ber = new_tm->ber_target_reached;
}
else
{
ce_debug_gpio_event (CE_DEBUG_GPIO_EVENT_CE_RX_BL_ROBO_BETTER, true);
/* TMI ROBO. */
- tmi = PHY_MOD_ROBO;
+ new_tmi = PHY_MOD_ROBO;
/* Remove computed tone map. */
- if (initial_tm != NULL)
- tonemap_free (initial_tm);
- ce_rx_bl_ber_sliding_mean_update
- (&sta->ce_rx_bt, ce_rx_bl_ber_pt_robo (ts->carrier_nb));
+ if (new_tm != NULL)
+ tonemap_free (new_tm);
+ ber = ce_rx_bl_ber_pt_robo (ts->carrier_nb);
/* Trace it. */
- CE_RX_TRACE (INITIAL_WORSE_THAN_ROBO, sta->tei);
+ CE_RX_TRACE (WORSE_THAN_ROBO, fsm_id, sta->tei);
}
- sta->rx_tonemaps->default_tmi = tmi;
+
+ /* Update BER sliding means. */
+ ce_rx_bl_ber_sliding_mean_update (bt, ber);
+
+ if (fsm_id == CE_RX_MEASURE_NO_INTERVAL)
+ sta->rx_tonemaps->default_tmi = new_tmi;
+ else
+ {
+ old_tmi = sta->intervals->tmi[fsm_id];
+ sta->intervals->tmi[fsm_id] = new_tmi;
+ /* Update intervals in rx_tonemaps. */
+ ce_rx_bl_intervals_update_tmi (sta,
+ ce_rx->aclf->beacon_period_theo_tck);
+
+ /* Mark old TM as to be release (unless it is used as global default
+ * tonemap). */
+ if (old_tmi != sta->rx_tonemaps->default_tmi
+ && TONEMAP_INDEX_IS_NEGOTIATED (old_tmi))
+ tonemap_disable (sta->rx_tonemaps, old_tmi);
+ }
+
+ /* Send new tone map. */
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. */
+ (ce_rx, sta, TONEMAP_INDEX_IS_NEGOTIATED (new_tmi) ? new_tmi : 0, 0,
+ initial_ce);
+
+ /* Store next time the we can restart. */
uint i;
for (i = 0; i < CE_RX_BL_DATE_CRITERIA_NB; i++)
- sta->ce_rx_bt.next_date_min_for_restart_rtc_date[i]
+ bt->next_date_min_for_restart_rtc_date[i]
= cyg_current_time ()
+ MAC_MS_TO_TCK (ce_rx_bl_min_time_between_ce_restart_ms[i])
/ ce_rx->tck_per_rtc;
diff --git a/cesar/ce/rx/bitloading/src/transition.c b/cesar/ce/rx/bitloading/src/transition.c
index 8dc3ef47be..08c99e1430 100644
--- a/cesar/ce/rx/bitloading/src/transition.c
+++ b/cesar/ce/rx/bitloading/src/transition.c
@@ -78,7 +78,7 @@ ce_rx_bl__common_initial_sound_measure_received (ce_rx_t *ce_rx, sta_t *sta,
/* Compute NSR mean (in every case). */
ce_rx_bl_nsr_compute_mean (&sta->ce_rx_bt);
/* Start initial tone map. */
- ce_rx_bl_start_bl (ce_rx, sta, &ce_rx->mac_config->tonemask_info);
+ ce_rx_bl_start_bl (ce_rx, sta, CE_RX_MEASURE_NO_INTERVAL);
return true;
}
ce_debug_gpio_event
diff --git a/cesar/ce/rx/bitloading/test/src/scenario_events.c b/cesar/ce/rx/bitloading/test/src/scenario_events.c
index 619e833f72..f37b6febb1 100644
--- a/cesar/ce/rx/bitloading/test/src/scenario_events.c
+++ b/cesar/ce/rx/bitloading/test/src/scenario_events.c
@@ -33,7 +33,7 @@ __event_empty_def (void, ce_rx_bl_nsr_sum_add, ce_rx_bitloading_t
*bl, phy_chandata_t *chan_data, uint chan_data_count)
__event_empty_def (void, ce_rx_bl_nsr_compute_mean, ce_rx_bitloading_t *bl);
__event_empty_def (void, ce_rx_bl_start_bl, ce_rx_t *ce_rx, sta_t *sta,
- tonemask_info_t *ts);
+ int fsm_id);
__event_empty_def (void, ce_rx_bl_ber_sliding_mean_update, ce_rx_bitloading_t *bl,
u64 ber);
__event_empty_def (void, ce_rx_bl_pber_update, ce_rx_bl_pber_t *ctx,
diff --git a/cesar/ce/rx/bitloading/test/src/test_fsm.c b/cesar/ce/rx/bitloading/test/src/test_fsm.c
index 477b3536f8..1498b26f5a 100644
--- a/cesar/ce/rx/bitloading/test/src/test_fsm.c
+++ b/cesar/ce/rx/bitloading/test/src/test_fsm.c
@@ -80,6 +80,7 @@ test_ce_rx_bl_measure_empty (ce_rx_measure_mbox_t *m)
m->rx_params.sound = false;
m->rx_params.sound_complete = false;
m->rx_params.pb_size = PHY_PB_SIZE_520;
+ m->fsm_id = CE_RX_MEASURE_NO_INTERVAL;
}
/**
diff --git a/cesar/ce/rx/inc/trace.h b/cesar/ce/rx/inc/trace.h
index 3e1e4783db..4f56c3072f 100644
--- a/cesar/ce/rx/inc/trace.h
+++ b/cesar/ce/rx/inc/trace.h
@@ -43,7 +43,7 @@ enum
CE_RX_TRACE_SEND_RESTART_CE,
CE_RX_TRACE_FSM_FROM_TO,
CE_RX_TRACE_TONEMAP,
- CE_RX_TRACE_INITIAL_WORSE_THAN_ROBO,
+ CE_RX_TRACE_WORSE_THAN_ROBO,
CE_RX_TRACE_RESTART_FORCED,
CE_RX_TRACE_PB_ERR_RATE_HIGH,
CE_RX_TRACE_RESTART_PB_ERR,
diff --git a/cesar/ce/rx/src/trace.c b/cesar/ce/rx/src/trace.c
index bf80366ee9..0ab23d023c 100644
--- a/cesar/ce/rx/src/trace.c
+++ b/cesar/ce/rx/src/trace.c
@@ -98,9 +98,9 @@ ce_rx_trace_init (ce_rx_t *ctx)
"[fsm] %S == %E ==> %S", TIMESTAMP),
TRACE_EVENT (CE_RX_TRACE_TONEMAP, "tei %d: "
"tone map generated: sum = %d => %dx0, %dx1, %dx2, %dx3 "
- "%dx4, %dx5, %dx6, %dx7", TIMESTAMP),
- TRACE_EVENT (CE_RX_TRACE_INITIAL_WORSE_THAN_ROBO, "tei %d: "
- "ROBO is better", TIMESTAMP),
+ "%dx4, %dx5, %dx6, %dx7 (fsm id: %dx8)", TIMESTAMP),
+ TRACE_EVENT (CE_RX_TRACE_WORSE_THAN_ROBO, "tei %d: "
+ "ROBO is better (fsm id: %d)", TIMESTAMP),
TRACE_EVENT (CE_RX_TRACE_RESTART_FORCED, "tei %d: "
"forced restart of ce rx - sound received",
TIMESTAMP),