From 5e9395298847310fbe0a806140645a1c8f9f6dcc Mon Sep 17 00:00:00 2001 From: Jérémy Dufour Date: Tue, 6 Dec 2011 16:28:05 +0100 Subject: cesar/ce/rx/bl: add a stat when BL can not optimize tone map, refs #2376 --- cesar/ce/rx/bitloading/bitloading.h | 9 +++++++++ cesar/ce/rx/bitloading/inc/bitloading.h | 5 ++++- cesar/ce/rx/bitloading/src/bitloading.c | 23 +++++++++++++++-------- cesar/ce/rx/bitloading/test/src/test_bl.c | 19 +++++++++++++------ cesar/ce/rx/bitloading/test/src/test_fsm.c | 1 + 5 files changed, 42 insertions(+), 15 deletions(-) (limited to 'cesar/ce/rx') diff --git a/cesar/ce/rx/bitloading/bitloading.h b/cesar/ce/rx/bitloading/bitloading.h index d764ebeaa0..91d03777c0 100644 --- a/cesar/ce/rx/bitloading/bitloading.h +++ b/cesar/ce/rx/bitloading/bitloading.h @@ -142,6 +142,11 @@ typedef struct ce_rx_bitloading_stats_t * Last CE restart reason. */ ce_rx_bitloading_restart_reason_t last_restart_reason; + /** + * Count of times when bit-loading can not optimize tone map as much as + * possible (out of optimization table). + */ + uint optimization_failure; } ce_rx_bitloading_stats_t; /** @@ -179,6 +184,8 @@ typedef struct ce_rx_bitloading_t uint resend_tm_date; /** BER margin update context. */ ce_rx_bl_bmu_t bmu; + /** Actual bit-loading failed to optimize tone map as much as possible. */ + bool optimization_failed; } ce_rx_bitloading_t; /** @@ -246,6 +253,7 @@ ce_rx_bl_stats_init (ce_rx_bitloading_t *bl) bl->stats.prev_ber_target_reached = 0; bl->stats.prev_pberr_rate_mean = 0; bl->stats.last_restart_reason = CE_RX_BL_RESTART_REASON_NO_RESTART; + bl->stats.optimization_failure = 0; } /** @@ -272,6 +280,7 @@ ce_rx_bitloading_init (ce_rx_bitloading_t *bt) bt->resend_tm = false; bt->resend_tm_date = 0; ce_rx_bl_bmu_reset (&bt->bmu); + bt->optimization_failed = false; } /** diff --git a/cesar/ce/rx/bitloading/inc/bitloading.h b/cesar/ce/rx/bitloading/inc/bitloading.h index ea631d4f56..12ecf3628f 100644 --- a/cesar/ce/rx/bitloading/inc/bitloading.h +++ b/cesar/ce/rx/bitloading/inc/bitloading.h @@ -125,6 +125,8 @@ ce_rx_bl_update_tone_map_under_ber_consign (u64 ber_pt, * \param ber_weighted_sum_q49 the sum of theoretical BER pondered by * modulation for the tone map (Q49U64) * \param tone_en tone enabled count (active but not 0). + * \param opti_failed set to true if not possible to optimize tone map, + * false otherwise * \return The position of the cursor in the optimization table. * * This function updates a tone map to make it perfectly respect the BER @@ -137,7 +139,8 @@ ce_rx_bl_update_tone_map_at_ber_consign (u64 ber_pt, tonemap_t *tm, ce_rx_bl_ber_impact_t *opti, u64 *ber_weighted_sum_q49, - uint *tone_en); + uint *tone_en, + bool *opti_failed); /** * Compute a tone map which iterates on the BER consign. diff --git a/cesar/ce/rx/bitloading/src/bitloading.c b/cesar/ce/rx/bitloading/src/bitloading.c index 5000df9d13..0bed98e35a 100644 --- a/cesar/ce/rx/bitloading/src/bitloading.c +++ b/cesar/ce/rx/bitloading/src/bitloading.c @@ -173,7 +173,8 @@ ce_rx_bl_update_tone_map_at_ber_consign (u64 ber_pt, tonemap_t *tm, ce_rx_bl_ber_impact_t *opti, u64 *ber_weighted_sum_q49, - uint *tone_en) + uint *tone_en, + bool *opti_failed) { /* Check parameters. */ dbg_assert (ber_pt < CE_RX_BL_BER_DEFAULT_OVER); @@ -182,12 +183,14 @@ ce_rx_bl_update_tone_map_at_ber_consign (u64 ber_pt, dbg_assert (bl); dbg_assert (opti); dbg_assert (tone_en); + dbg_assert (opti_failed); dbg_assert (ber_weighted_sum_q49); uint pos = 0; u32 *tone_word; s8 mod = -1; u64 ber_pt_q49 = fixed_round_64 (ber_pt, CE_RX_BL_BER_WEIGHTED_SUM_SHIFT); + *opti_failed = false; /* Optimize tone map until we reach the BER consign or we are out of * table. */ @@ -200,7 +203,10 @@ 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) + { + *opti_failed = true; 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. */ @@ -279,6 +285,7 @@ ce_rx_bl_compute_tone_map_iterative (const u64 bpt_initial[PHY_FEC_RATE_NB], tonemap_t *tm[PHY_FEC_RATE_NB]; uint tone_en; s64 tmp_ber; + bool opti_failed[PHY_FEC_RATE_NB] = { false, false }; phy_fecrate_t fec_rate; /* For each FEC rate. */ @@ -313,13 +320,9 @@ ce_rx_bl_compute_tone_map_iterative (const u64 bpt_initial[PHY_FEC_RATE_NB], /* Optimize tone map to reach BER consign. */ opti_cursor[fec_rate] = - ce_rx_bl_update_tone_map_at_ber_consign (ber_cur, - reducedtm, - bl, - tm[fec_rate], - opti[fec_rate], - &ber_weighted_sum_q49, - &tone_en); + ce_rx_bl_update_tone_map_at_ber_consign + (ber_cur, reducedtm, bl, tm[fec_rate], opti[fec_rate], + &ber_weighted_sum_q49, &tone_en, &opti_failed[fec_rate]); /* Store previous BER consign. */ ber_prev[fec_rate] = ber_cur; /* We may have zero bit per symbol (when NSR is high for example). @@ -401,6 +404,10 @@ ce_rx_bl_compute_tone_map_iterative (const u64 bpt_initial[PHY_FEC_RATE_NB], } /* Store the cursor of the optimization table for this tone map. */ bl->opti_table_cursor = opti_cursor[good]; + /* Store optimization result and update corresponding stats. */ + bl->optimization_failed = opti_failed[good]; + if (bl->optimization_failed) + bl->stats.optimization_failure++; /* Return best tone map. */ return tm[good]; } diff --git a/cesar/ce/rx/bitloading/test/src/test_bl.c b/cesar/ce/rx/bitloading/test/src/test_bl.c index 3ca35b99f4..13bcd1459d 100644 --- a/cesar/ce/rx/bitloading/test/src/test_bl.c +++ b/cesar/ce/rx/bitloading/test/src/test_bl.c @@ -303,6 +303,7 @@ test_suite_ce_rx_bl_nsr_sum (test_t t) tm = tonemap_alloc (); test_begin (t, "initial tone map (optimized)") { + bool of; u64 ber_pt = ce_rx_bl_ber_pt_bpt (fec_rate, ti.carrier_nb, ce_rx_bl_initial_bpt[fec_rate]); u64 ber_weighted_sum = @@ -310,7 +311,8 @@ test_suite_ce_rx_bl_nsr_sum (test_t t) opti, &tone_en); ce_rx_bl_sort_optimization (opti, ti.carrier_nb); ce_rx_bl_update_tone_map_at_ber_consign (ber_pt, &ti, &bl, tm, opti, - &ber_weighted_sum, &tone_en); + &ber_weighted_sum, &tone_en, + &of); uint tone, i = 0; uint tone_diff = 0; #define TONEMAP_READ_OPEN { @@ -361,11 +363,12 @@ test_suite_ce_rx_bl_nsr_sum (test_t t) u64 ber_weighted_sum = CE_RX_BL_BER_DEFAULT_OVER - 1; bool assert = false; + bool of; dbg_fatal_try_begin { ce_rx_bl_update_tone_map_at_ber_consign (ber_pt, &ti, &bl, tm, opti, &ber_weighted_sum, - &tone_en); + &tone_en, &of); } dbg_fatal_try_catch_void () { @@ -888,10 +891,11 @@ test_suite_ce_rx_bl_nsr_margin (test_t t) &bl, tm, opti, &tone_en); ce_rx_bl_sort_optimization (opti, ti.carrier_nb); + bool of; ce_rx_bl_update_tone_map_at_ber_consign (ber_pt, &ti, &bl, tm, opti, &ber_weighted_sum, - &tone_en); + &tone_en, &of); /* Check vectors. */ uint tone, c = 0; uint tone_diff = 0; @@ -1073,9 +1077,10 @@ test_suite_ce_rx_bl_optimization_table (test_t t) dbg_fatal_try_begin { + bool of; ce_rx_bl_update_tone_map_at_ber_consign (CE_RX_BL_BER_DEFAULT_OVER - 1, &ti, &bl, tm, opti, - &berws, &tone_en); + &berws, &tone_en, &of); } dbg_fatal_try_catch_void () { @@ -1113,8 +1118,9 @@ test_suite_ce_rx_bl_optimization_table (test_t t) opti[i].ber_diff = 1; } tone_en = berws = 0; + bool of; ce_rx_bl_update_tone_map_at_ber_consign - (1, &ti, &bl, tm, opti, &berws, &tone_en); + (1, &ti, &bl, tm, opti, &berws, &tone_en, &of); test_fail_if (tone_en != target); /* Clean. */ tonemap_free (tm); @@ -1137,9 +1143,10 @@ test_suite_ce_rx_bl_optimization_table (test_t t) opti[i].ber_diff = 1; } tone_en = berws = 0; + bool of; ce_rx_bl_update_tone_map_at_ber_consign (CE_RX_BL_BER_DEFAULT_OVER - 1, &ti, &bl, tm, opti, &berws, - &tone_en); + &tone_en, &of); test_fail_if (tone_en != ti.carrier_nb); /* Clean. */ tonemap_free (tm); diff --git a/cesar/ce/rx/bitloading/test/src/test_fsm.c b/cesar/ce/rx/bitloading/test/src/test_fsm.c index d27c4d4a52..c6e0f199ad 100644 --- a/cesar/ce/rx/bitloading/test/src/test_fsm.c +++ b/cesar/ce/rx/bitloading/test/src/test_fsm.c @@ -111,6 +111,7 @@ test_ce_rx_bl_stats (test_t t, ce_rx_bitloading_stats_t *s1, test_fail_if (s1->prev_ber_target_reached != s2->prev_ber_target_reached); test_fail_if (s1->prev_pberr_rate_mean != s2->prev_pberr_rate_mean); test_fail_if (s1->last_restart_reason != s2->last_restart_reason); + test_fail_if (s1->optimization_failure != s2->optimization_failure); } static void -- cgit v1.2.3