summaryrefslogtreecommitdiff
path: root/cesar/ce
diff options
context:
space:
mode:
authorCyril Jourdan2012-11-22 14:12:55 +0100
committerCyril Jourdan2013-01-18 11:53:47 +0100
commit31fb77de9bbf4f7719b71a1cddfa5e3862266b9c (patch)
tree565ef3f894c3e6b06aa146ee6e83dac298b7762e /cesar/ce
parentedacf4021c732eab33b0a57dfb5205e6a3044038 (diff)
cesar/ce/rx/bl: move context to a dedicated header, refs #2366
Diffstat (limited to 'cesar/ce')
-rw-r--r--cesar/ce/rx/bitloading/bitloading.h171
-rw-r--r--cesar/ce/rx/bitloading/context.h187
2 files changed, 188 insertions, 170 deletions
diff --git a/cesar/ce/rx/bitloading/bitloading.h b/cesar/ce/rx/bitloading/bitloading.h
index da90acf5a9..3d40afa434 100644
--- a/cesar/ce/rx/bitloading/bitloading.h
+++ b/cesar/ce/rx/bitloading/bitloading.h
@@ -19,179 +19,10 @@
* the state of the bit-loading).
*/
-#include "lib/blk.h"
-#include "lib/blk_table.h"
-#include "ce/rx/bitloading/pber.h"
-#include "ce/rx/bitloading/ber_margin_update.h"
+#include "ce/rx/bitloading/context.h"
#include "common/module.h"
-typedef enum ce_rx_bitloading_ber_sliding_mean_t
-{
- /** BER sliding mean fast index. */
- CE_RX_BL_BER_SLIDING_MEAN_FAST,
- /** BER sliding mean slow index. */
- CE_RX_BL_BER_SLIDING_MEAN_SLOW,
- /** BER sliding mean count. */
- CE_RX_BL_BER_SLIDING_MEAN_NB,
-} ce_rx_bitloading_ber_sliding_mean_t;
-
-/**
- * Restart reason of the CE.
- * Fields order is important for VS_GET_CE_STATS MME.
- */
-typedef enum ce_rx_bitloading_restart_reason_t
-{
- /**
- * CE restarted because BER is too low.
- */
- CE_RX_BL_RESTART_REASON_BER_LOW = 0,
- /**
- * CE restarted because PB error rate is too high.
- */
- CE_RX_BL_RESTART_REASON_PBERR_HIGH = 1,
- /**
- * CE restarted because peer requested it (frame sound received).
- */
- CE_RX_BL_RESTART_REASON_PEER_REQUEST = 2,
- /**
- * CE restarted because a tone map update has occurred.
- */
- CE_RX_BL_RESTART_REASON_TONEMAP_UPDATE = 3,
- /**
- * CE restarted because a BER margin update has occurred.
- */
- CE_RX_BL_RESTART_REASON_BER_MARGIN_UPDATE = 4,
- /**
- * Number of reason to restart the CE.
- * Should not be moved to keep numeration.
- */
- CE_RX_BL_RESTART_REASON_NB,
- /**
- * No restart yet.
- */
- CE_RX_BL_RESTART_REASON_NO_RESTART = 255
-} ce_rx_bitloading_restart_reason_t;
-
-/**
- * Next dates we are allowed to restart the CE.
- */
-typedef enum ce_rx_bitloading_date_criteria_t
-{
- /**
- * PBErrorRate criteria.
- */
- CE_RX_BL_DATE_CRITERIA_PBER,
- /**
- * BER criteria.
- */
- CE_RX_BL_DATE_CRITERIA_BER,
- /**
- * BER margin update criteria.
- */
- CE_RX_BL_DATE_BER_MARGIN_UPDATE,
- /**
- * Number of date used in bit loading algorithm.
- */
- CE_RX_BL_DATE_CRITERIA_NB,
-} ce_rx_bitloading_date_criteria_t;
-
-/**
- * Statistics of the CE/RX bit-loading.
- */
-typedef struct ce_rx_bitloading_stats_t
-{
- /**
- * Number of PB in the last received frame.
- */
- u8 curr_nb_pb;
- /**
- * Number of PB with CRC false in the last received frame.
- */
- u8 curr_nb_pb_crc_false;
- /**
- * BER sum in the last frame received.
- */
- uint curr_ber_sum;
- /**
- * Last BER sliding means after the last frame received.
- */
- u64 curr_ber_mean[CE_RX_BL_BER_SLIDING_MEAN_NB];
- /**
- * Last PB error rate mean after the last frame received.
- */
- u32 curr_pberr_rate_mean;
- /**
- * Number of restart of the CE for each reasons.
- * Those counters can overflow.
- */
- uint restart_reason[CE_RX_BL_RESTART_REASON_NB];
- /**
- * Previous BER target, before the last CE restart.
- */
- u64 prev_ber_target;
- /**
- * Previous BER reached, before the last CE restart.
- */
- u64 prev_ber_target_reached;
- /**
- * BER sliding means of the previous tone map.
- */
- u64 prev_ber_mean[CE_RX_BL_BER_SLIDING_MEAN_NB];
- /**
- * PB Error Rate of the previous tone map.
- */
- u32 prev_pberr_rate_mean;
- /**
- * 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;
-
-/**
- * Bit-loading data per station.
- */
-typedef struct ce_rx_bitloading_t
-{
- /** State of the bit loading. */
- u32 fsm;
- /** Mean of the noise NRJ (on multiple blk) per intervals. */
- blk_t *noise_nrj;
- /** Number of allocated block for the noise NRJ. */
- u8 noise_nrj_blk_count;
- /** Mean count. */
- u32 mean_count;
- /** Counter of frame with high PB error rate. */
- uint high_pb_error_rate_frame_counter;
- /** BER sliding means (-1 if they are reseted). */
- s64 ber_sliding_mean[CE_RX_BL_BER_SLIDING_MEAN_NB];
- /** Next time we are allowed to restart the CE. */
- u32 next_date_min_for_restart_rtc_date[CE_RX_BL_DATE_CRITERIA_NB];
- /** 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;
- /** Statistics of the bit-loading. */
- ce_rx_bitloading_stats_t stats;
- /** PBER context. */
- ce_rx_bl_pber_t pber;
- /** Need to resend tone map to TX? */
- bool resend_tm;
- /** Timer to know when to re-send the tone map (if TX peer does not use
- * default TMI). */
- 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;
-
/**
* Comparisons factors to know when to restart CE.
*/
diff --git a/cesar/ce/rx/bitloading/context.h b/cesar/ce/rx/bitloading/context.h
new file mode 100644
index 0000000000..2d9f86e471
--- /dev/null
+++ b/cesar/ce/rx/bitloading/context.h
@@ -0,0 +1,187 @@
+#ifndef ce_rx_bitloading_context_h
+#define ce_rx_bitloading_context_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2012 MStar
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/rx/bitloading/context.h
+ * \brief CE RX bit-loading context.
+ * \ingroup ce_rx
+ */
+
+#include "lib/blk.h"
+#include "lib/blk_table.h"
+#include "ce/rx/bitloading/pber.h"
+#include "ce/rx/bitloading/ber_margin_update.h"
+
+typedef enum ce_rx_bitloading_ber_sliding_mean_t
+{
+ /** BER sliding mean fast index. */
+ CE_RX_BL_BER_SLIDING_MEAN_FAST,
+ /** BER sliding mean slow index. */
+ CE_RX_BL_BER_SLIDING_MEAN_SLOW,
+ /** BER sliding mean count. */
+ CE_RX_BL_BER_SLIDING_MEAN_NB,
+} ce_rx_bitloading_ber_sliding_mean_t;
+
+/**
+ * Restart reason of the CE.
+ * Fields order is important for VS_GET_CE_STATS MME.
+ */
+typedef enum ce_rx_bitloading_restart_reason_t
+{
+ /**
+ * CE restarted because BER is too low.
+ */
+ CE_RX_BL_RESTART_REASON_BER_LOW = 0,
+ /**
+ * CE restarted because PB error rate is too high.
+ */
+ CE_RX_BL_RESTART_REASON_PBERR_HIGH = 1,
+ /**
+ * CE restarted because peer requested it (frame sound received).
+ */
+ CE_RX_BL_RESTART_REASON_PEER_REQUEST = 2,
+ /**
+ * CE restarted because a tone map update has occurred.
+ */
+ CE_RX_BL_RESTART_REASON_TONEMAP_UPDATE = 3,
+ /**
+ * CE restarted because a BER margin update has occurred.
+ */
+ CE_RX_BL_RESTART_REASON_BER_MARGIN_UPDATE = 4,
+ /**
+ * Number of reason to restart the CE.
+ * Should not be moved to keep numeration.
+ */
+ CE_RX_BL_RESTART_REASON_NB,
+ /**
+ * No restart yet.
+ */
+ CE_RX_BL_RESTART_REASON_NO_RESTART = 255
+} ce_rx_bitloading_restart_reason_t;
+
+/**
+ * Next dates we are allowed to restart the CE.
+ */
+typedef enum ce_rx_bitloading_date_criteria_t
+{
+ /**
+ * PBErrorRate criteria.
+ */
+ CE_RX_BL_DATE_CRITERIA_PBER,
+ /**
+ * BER criteria.
+ */
+ CE_RX_BL_DATE_CRITERIA_BER,
+ /**
+ * BER margin update criteria.
+ */
+ CE_RX_BL_DATE_BER_MARGIN_UPDATE,
+ /**
+ * Number of date used in bit loading algorithm.
+ */
+ CE_RX_BL_DATE_CRITERIA_NB,
+} ce_rx_bitloading_date_criteria_t;
+
+/**
+ * Statistics of the CE/RX bit-loading.
+ */
+typedef struct ce_rx_bitloading_stats_t
+{
+ /**
+ * Number of PB in the last received frame.
+ */
+ u8 curr_nb_pb;
+ /**
+ * Number of PB with CRC false in the last received frame.
+ */
+ u8 curr_nb_pb_crc_false;
+ /**
+ * BER sum in the last frame received.
+ */
+ uint curr_ber_sum;
+ /**
+ * Last BER sliding means after the last frame received.
+ */
+ u64 curr_ber_mean[CE_RX_BL_BER_SLIDING_MEAN_NB];
+ /**
+ * Last PB error rate mean after the last frame received.
+ */
+ u32 curr_pberr_rate_mean;
+ /**
+ * Number of restart of the CE for each reasons.
+ * Those counters can overflow.
+ */
+ uint restart_reason[CE_RX_BL_RESTART_REASON_NB];
+ /**
+ * Previous BER target, before the last CE restart.
+ */
+ u64 prev_ber_target;
+ /**
+ * Previous BER reached, before the last CE restart.
+ */
+ u64 prev_ber_target_reached;
+ /**
+ * BER sliding means of the previous tone map.
+ */
+ u64 prev_ber_mean[CE_RX_BL_BER_SLIDING_MEAN_NB];
+ /**
+ * PB Error Rate of the previous tone map.
+ */
+ u32 prev_pberr_rate_mean;
+ /**
+ * 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;
+
+/**
+ * Bit-loading data per station.
+ */
+typedef struct ce_rx_bitloading_t
+{
+ /** State of the bit loading. */
+ u32 fsm;
+ /** Mean of the noise NRJ (on multiple blk) per intervals. */
+ blk_t *noise_nrj;
+ /** Number of allocated block for the noise NRJ. */
+ u8 noise_nrj_blk_count;
+ /** Mean count. */
+ u32 mean_count;
+ /** Counter of frame with high PB error rate. */
+ uint high_pb_error_rate_frame_counter;
+ /** BER sliding means (-1 if they are reseted). */
+ s64 ber_sliding_mean[CE_RX_BL_BER_SLIDING_MEAN_NB];
+ /** Next time we are allowed to restart the CE. */
+ u32 next_date_min_for_restart_rtc_date[CE_RX_BL_DATE_CRITERIA_NB];
+ /** 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;
+ /** Statistics of the bit-loading. */
+ ce_rx_bitloading_stats_t stats;
+ /** PBER context. */
+ ce_rx_bl_pber_t pber;
+ /** Need to resend tone map to TX? */
+ bool resend_tm;
+ /** Timer to know when to re-send the tone map (if TX peer does not use
+ * default TMI). */
+ 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;
+
+#endif /* ce_rx_bitloading_context_h */