summaryrefslogtreecommitdiff
path: root/cesar/ce/inc/bitloading.h
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/ce/inc/bitloading.h')
-rw-r--r--cesar/ce/inc/bitloading.h133
1 files changed, 133 insertions, 0 deletions
diff --git a/cesar/ce/inc/bitloading.h b/cesar/ce/inc/bitloading.h
new file mode 100644
index 0000000000..28b91d996f
--- /dev/null
+++ b/cesar/ce/inc/bitloading.h
@@ -0,0 +1,133 @@
+#ifndef ce_inc_bitloading_h
+#define ce_inc_bitloading_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+
+#include "ce/inc/mpdu_measure_store.h"
+#include "mac/common/store.h"
+
+/** The noise provided by the DSP is expressed in UND that is the length of
+ * the diagonal in the constellation of the modulation on which measurement has been done.
+ */
+/** noise saturation */
+#define MAX_UND 4
+/** Number of bit used to code the noise */
+#define UND_CODE_BIT_NB 16
+/** Code value of the maximum noise */
+#define MAX_UND_CODE ((1<<UND_CODE_BIT_NB)-1)
+/** Code value of one UND */
+#define UND_CODE (MAX_UND_CODE/MAX_UND)
+/** The DSP accumulate noise along the MPDU (but should provide the average)*/
+#define ACCU_MAX_NB 1 // DSP provides the average (no accumulation)
+/** Code value of the maximum accumulated noise */
+#define NOISE_MAX (ACCU_MAX_NB * MAX_UND_CODE )
+
+ /** The ROBO (include sound) frame number limit before a
+ * worst_tonemap becomes a tonemap default.*/
+#define FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP 20 //TBD
+
+/** Table of noises threshold versus modulation when measurement for ber=10^-3.
+ * Example : If noise has been computed by DSP with a tone QPSK
+ * and if THR3[QPSK][QAM256] < noise_average < THR3[QPSK][QAM1024],
+ * then we can put the modulation to QAM256 for a BER<10^-3.
+ */
+uint THR3[7][7];
+uint current_threshold[7];
+
+struct bitloading_modification_t
+{
+ /** Set of tonemap that has been changed. If hasn't, NULL.*/
+ tonemaps_t *changed_tonemaps;
+ /** frame measurement-processed source station TEI.*/
+ uint stei;
+ /** Tonemap index of the new tonemap (if there is).*/
+ uint new_tmi;
+ /** If a reference tonemap has been used to compute the new one, index of
+ * this reference tonemap. (Will allow to create a CM_UPDATE_TM.IND instead of CM_CHAN_EST.IND).*/
+ uint old_tmi;
+};
+typedef struct bitloading_modification_t bitloading_modification_t;
+
+/**
+ * Computation of tonemaps from frame measurement.
+ * \param mac_store_ctx Concerned sta with its rx_tonemaps and statistics.
+ * \param measurement Frame measurement data.
+ * \return the status of modification while computation.
+ *
+ */
+bitloading_modification_t
+bitloading_run (mac_store_t *mac_store_ctx, mpdu_measure_t *measure);
+
+bitloading_modification_t
+bitloading_initial_step (sta_t *sta, mpdu_measure_t *measure);
+
+bitloading_modification_t
+bitloading_dynamic_step (sta_t *sta, mpdu_measure_t *measure);
+
+/**
+ * Read the noise per carrier and choose the appropriate modulation. If the
+ * current modulation is higher, the modulation is modified to the lower.
+ * \param worst_tm Current tonemap to modify or allocate if null. (modulation map).
+ * \param noise_nrj Average noise on each carriers along the MPDU.
+ * \return true if at least one carrier has been down.
+ */
+bool // Has tonemap been modified?.
+bitloading_worst_tonemap_compute (tonemap_t **worst_tm, phy_chandata_t *noise_nrj);
+
+/**
+ * Detect if the noise along the frame has changed 'a lot'.
+ * \param noise_nrj_symbol Average noise by symbols along the MPDU.
+ * \return true if noise is considered as stable and so if the noise per
+ * carrier(noise_nrj) can be trust.
+ */
+bool // Is noise stable along the MPDU?.
+bitloading_mpdu_noise_stability (phy_chandata_t *noise_nrj_symbol);
+
+static inline void
+bitloading_update_threshold (uint accumulation, int measurement_mod)
+{
+ int m;
+ for (m=0; m<7; m++)
+ {
+ current_threshold[m] = accumulation * THR3[measurement_mod][m];
+ }
+}
+
+/**
+ * Find the modulation using the table of noises threshold.
+ * \param noise code value of noise.
+ * \param accumulation // MUST BE 1 (already average provided).
+ * \param measurement_mod modulation used when measurement has been
+ * computed.
+ * \return the modulation according to thresholds.
+ *
+ */
+static inline int
+bitloading_noise2mod (uint noise /*, int accumulation, int measurement_mod*/)
+{
+ int m;
+ for(m=0; m<7; m++)
+ {
+ if (noise > current_threshold[m]) //DSP should provide average. If not, update threshold before instead of multiply at each carrier... TODO
+ {
+ return (m);
+ }
+ }
+ return (7);
+}
+
+void
+bitloading_threshold_init (void);
+
+uint // date_modulo_BEACON_PERIOD_ATU
+bitloading_date_in_beacon_atu_get (uint mpdu_date_tck, uint beacon_date_tck);
+
+//void
+//manage_interval (tonemaps_t *tms, mpdu_measure_t *mpdu_measure);
+
+#endif /* ce_inc_bitloading_h */