summaryrefslogtreecommitdiff
path: root/cesar/mac/sar/test/src/ce.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/mac/sar/test/src/ce.c')
-rw-r--r--cesar/mac/sar/test/src/ce.c140
1 files changed, 140 insertions, 0 deletions
diff --git a/cesar/mac/sar/test/src/ce.c b/cesar/mac/sar/test/src/ce.c
new file mode 100644
index 0000000000..a56c7019c9
--- /dev/null
+++ b/cesar/mac/sar/test/src/ce.c
@@ -0,0 +1,140 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce.c
+ * \brief Context of the CE
+ * \ingroup mac/sar/test/src
+ *
+ * contains a minimum of the CE data to take the measurement of the PBs.
+ *
+ */
+
+#include "common/std.h"
+#include "mac/sar/test/inc/ce.h"
+
+/**
+ * Init the CE and get the context pointer.
+ */
+ce_t *ce_init (void)
+{
+ ce_ctx.measurement_head = NULL;
+ ce_ctx.measurement_tail = NULL;
+
+ ce_ctx.rx_params_head = NULL;
+ ce_ctx.rx_params_tail = NULL;
+
+ return &ce_ctx;
+}
+
+/**
+ * Pb measurement RX callback for Channel estimation.
+ * This call back will return one or two block in order to insert all the
+ * measurements contained in each PB of the mpdu received.
+ * Two cases can happen, the first the pb_nb is lesser than the blk capacity,
+ * this callback will return only a blk pointed by the first and the last
+ * pointer.
+ * In the second case the quantity of PB are greater than one blk capacity, this
+ * callback will return two blk (chained) the first pointed by the first pointer
+ * and the last one by the last pointer.
+ *
+ * \param user User data
+ * \param rx_params Frame control information to know date and tonemap used
+ * \param number of pbs
+ * \param first blk to insert the measurements.
+ * \param last blk to insert the measurements.
+ * \param chandata chan data measurements
+ *
+ * \return boolean to indicate if a block had been returned or not.
+ */
+bool ce_measurements (void *user, pbproc_rx_params_t *rx_params, uint pb_nb,
+ blk_t **first, blk_t **last, pb_t *chandata, uint nb_chandata, uint
+ *blk_offset)
+{
+ ce_store_rx_params_t *ce_rx_params = NULL;
+
+ /*
+ * author nelio
+ * 26 sept. 07 - 09:56:56
+ *
+ * Not use by the SAR the rx_params are only copied from the CA to provide
+ * it to the CE.
+ */
+
+ dbg_assert (rx_params);
+ ce_rx_params = blk_alloc ();
+
+ /* If the quantity of PBs are greater than 128 allocates two BLK */
+ if (pb_nb > 128)
+ {
+ *first = blk_alloc_desc ();
+ *last = blk_alloc_desc ();
+ ((blk_t *)*first)->next = *last;
+ }
+ else
+ {
+ *first = blk_alloc_desc ();
+ *last = *first;
+ }
+
+ /* Keep it in the structure */
+ if (ce_ctx.measurement_head == NULL)
+ {
+ ce_ctx.measurement_head = *first;
+ ce_ctx.measurement_tail = *last;
+ }
+ else
+ {
+ ce_ctx.measurement_tail->next = *first;
+ ce_ctx.measurement_tail = *last;
+ }
+
+ /* allocate the structure to store the rx_params */
+ ce_rx_params->rx_params = rx_params;
+
+ /* Store the rx_params to the structure */
+ if (ce_ctx.rx_params_head == NULL)
+ {
+ ce_ctx.rx_params_head = ce_rx_params;
+ ce_ctx.rx_params_tail = ce_rx_params;
+ }
+ else
+ {
+ ce_ctx.rx_params_tail->next = ce_rx_params;
+ ce_ctx.rx_params_tail = ce_rx_params;
+ }
+ ce_ctx.rx_params_tail->next = NULL;
+
+ ce_ctx.chandata = chandata;
+
+ ((blk_t *)*last)->next = NULL;
+ *blk_offset = 0;
+
+ return true;
+}
+
+void ce_uninit (void)
+{
+ ce_store_rx_params_t *tmp;
+
+ blk_t *curr;
+ while (ce_ctx.measurement_head)
+ {
+ curr = ce_ctx.measurement_head;
+ ce_ctx.measurement_head = ce_ctx.measurement_head->next;
+
+ blk_release_desc (curr);
+ }
+
+ while (ce_ctx.rx_params_head)
+ {
+ tmp = ce_ctx.rx_params_head;
+ ce_ctx.rx_params_head = ce_ctx.rx_params_head->next;
+ blk_release (tmp->rx_params);
+ blk_release (tmp);
+ }
+}