summaryrefslogtreecommitdiff
path: root/cesar/ce/rx/cp
diff options
context:
space:
mode:
authordufour2009-07-16 09:13:20 +0000
committerdufour2009-07-16 09:13:20 +0000
commit3a694cd8c015ddb7888f49f589b06c655bdec652 (patch)
treed5eb8cf4899f6af74e759507a62d21dbb2c53ccf /cesar/ce/rx/cp
parentb158eb75227dfcee44602f32bfb9ae30cb678493 (diff)
* ce/rx, common/tests, cp/sta/core
- move all cp part of the CE RX in the ce/rx/cp sub-modules (with the stub), - update test build system, - update cp/sta/core build. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@4978 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/ce/rx/cp')
-rw-r--r--cesar/ce/rx/cp/Module2
-rw-r--r--cesar/ce/rx/cp/cp.h66
-rw-r--r--cesar/ce/rx/cp/inc/cp.h120
-rw-r--r--cesar/ce/rx/cp/mme.h4
-rw-r--r--cesar/ce/rx/cp/src/cp.c198
-rw-r--r--cesar/ce/rx/cp/stub/Module2
-rw-r--r--cesar/ce/rx/cp/stub/src/cp.c34
-rw-r--r--cesar/ce/rx/cp/test/Makefile7
-rw-r--r--cesar/ce/rx/cp/test/ecos.ecc.sh5
-rw-r--r--cesar/ce/rx/cp/test/override/cp/inc/context.h39
10 files changed, 474 insertions, 3 deletions
diff --git a/cesar/ce/rx/cp/Module b/cesar/ce/rx/cp/Module
index 49f41ff83e..8ba4bd956a 100644
--- a/cesar/ce/rx/cp/Module
+++ b/cesar/ce/rx/cp/Module
@@ -1,2 +1,2 @@
# Channel Estimation (CE) in Receive (RX) mode, interface with the CP.
-SOURCES := mme.c
+SOURCES := mme.c cp.c
diff --git a/cesar/ce/rx/cp/cp.h b/cesar/ce/rx/cp/cp.h
new file mode 100644
index 0000000000..07a2d6bc62
--- /dev/null
+++ b/cesar/ce/rx/cp/cp.h
@@ -0,0 +1,66 @@
+#ifndef ce_rx_cp_cp_h
+#define ce_rx_cp_cp_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/rx/cp/cp.h
+ * \brief Interface to use the CE RX in the CP context.
+ * \ingroup ce_rx
+ *
+ * CE RX need to send some MME, but it can do not in its context: for example,
+ * when a new tone map need to be sent to the peer, a MME should be generated
+ * in the context of the CP. This sub-module CP of the CE RX is responsible to
+ * assure the communication with the CP and the CE RX.
+ *
+ * The communication is asynchronous: work are posted from the CE RX and the
+ * CP will try to process it when it can.
+ *
+ * This header contains functions which can be used by the CP:
+ * - to register itself to the CE RX,
+ * - to process the work it needs to do.
+ *
+ * This functions must be executed in the context of the CP.
+ */
+
+#include "cp/cp.h"
+
+/**
+ * Callback used by the CE RX to set a flag in the CP.
+ * This function is used by the CE RX to let the CP knows it has some works to
+ * perform.
+ * A typical implementation of this call back is to call
+ * cp_sta_core_signal_ce_rx_work_event.
+ * \param ctx the Control Plane context.
+ */
+typedef void
+(*ce_rx_cp_signal_work_t) (cp_t *ctx);
+
+BEGIN_DECLS
+
+/**
+ * Set the call back used by the CE RX to tell the CP we have some works for him.
+ * \param ce_rx the CE RX context.
+ * \param cb the callback used to set a work flag for the CP.
+ * \param ctx the Control Plane context.
+ */
+void
+ce_rx_cp_set_cp_signal_work_callback (ce_rx_t *ce_rx,
+ ce_rx_cp_signal_work_t cb, cp_t *ctx);
+
+/**
+ * Run the works posted by the CE RX in the context of the CP.
+ * It looks at the mailbox to see if there are some jobs that required to be
+ * done and perform them.
+ * @warning this function must be executed in the context of the CP.
+ */
+void
+ce_rx_cp_run_work (cp_t *ctx);
+
+END_DECLS
+
+#endif /* ce_rx_cp_cp_h */
diff --git a/cesar/ce/rx/cp/inc/cp.h b/cesar/ce/rx/cp/inc/cp.h
new file mode 100644
index 0000000000..0d40b6d3b4
--- /dev/null
+++ b/cesar/ce/rx/cp/inc/cp.h
@@ -0,0 +1,120 @@
+#ifndef ce_rx_cp_inc_cp_h
+#define ce_rx_cp_inc_cp_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/rx/cp/inc/cp.h
+ * \brief Interface to use the CE RX in the CP context (private part).
+ * \ingroup ce_rx
+ *
+ * This header contains the private part of the functions used for the
+ * interface between the communication of the CP and the CE RX.
+ *
+ * This functions must be called in the context of the CE RX and are used to
+ * set-up the works that must be executed by the CP.
+ */
+
+#include "lib/mbox.h"
+#include "cp/types.h"
+
+/**
+ * Mailbox used for the exchange of work between the CE RX and the CP.
+ * The work that can be posted from the CE RX to the CP is quite simple:
+ * sending MME to the peer. It can be divided into two sub-parts:
+ * - sending a tone map,
+ * - preventing tone map expiration on the other side (by sending a refresh).
+ * The information contains in this node are enough to send a tone map
+ * (pointed with the tone map index) to a peer (pointed by its TEI).
+ *
+ * When the CP process a mail, the state of the structure tone maps has maybe
+ * changed (the CE RX can maybe generate multiple tone maps and during this
+ * time, the CP has maybe not process our mail). That's why, the mail contains
+ * some copy of the fields of the tone maps structure (default TMI, TMI list
+ * and intervals list).
+ */
+typedef struct ce_rx_cp_mbox_t
+{
+ /**
+ * The mailbox node.
+ */
+ mbox_node_t mbox_node;
+ /**
+ * The TEI of the peer.
+ */
+ cp_tei_t tei;
+ /**
+ * Default TMI.
+ */
+ u8 default_tmi;
+ /**
+ * The list of valid tone map index.
+ * This field is a bit field (bit is set to one when the tone map is
+ * active).
+ */
+ u32 tmi_list;
+ /**
+ * List of valid intervals.
+ */
+ tonemap_intervals_t intervals_list;
+ /**
+ * The tone map index.
+ * If this field is set to 0, no tone map should be sent, just a refresh
+ * MME (to prevent tone maps expiration).
+ */
+ u8 new_tmi;
+ /**
+ * The old tone map index.
+ * When the bit loading of the CE RX creates a new tone map based on an
+ * old one, it can give an hint on the tone map index used.
+ */
+ u8 old_tmi;
+ /**
+ * Initial CE?
+ */
+ bool initial_ce;
+} ce_rx_cp_mbox_t;
+
+BEGIN_DECLS
+
+/**
+ * Initialize the communication between the CE RX and the CP.
+ * \param ce_rx the CE RX context.
+ */
+void
+ce_rx_cp_init (ce_rx_t *ce_rx);
+
+/**
+ * Uninitialize the communication between the CE RX and the CP.
+ * \param ce_rx the CE RX context.
+ */
+void
+ce_rx_cp_uninit (ce_rx_t *ce_rx);
+
+/**
+ * Add work for the CP from the CE RX context.
+ * \param ce_rx the context of the CE in RX.
+ * \param peer the peer STA.
+ * \param new_tmi the new TMI of the tone map to send.
+ * \param old_tmi the old TMI used (if there is one, 0 otherwise).
+ * \param initial_ce initial channel estimation?
+ */
+void
+ce_rx_cp_send_mme_new_tone_map (ce_rx_t *ce_rx, sta_t *peer, u8 new_tmi,
+ u8 old_tmi, bool initial_ce);
+
+/**
+ * Add work to prevent expirations of the valid tone maps list of a peer.
+ * \param ce_rx the context of the CE in RX.
+ * \param peer the peer STA.
+ */
+void
+ce_rx_cp_send_mme_refresh_tmi_list (ce_rx_t *ce_rx, sta_t *peer);
+
+END_DECLS
+
+#endif /* ce_rx_cp_inc_cp_h */
diff --git a/cesar/ce/rx/cp/mme.h b/cesar/ce/rx/cp/mme.h
index 5c2082acd4..8327205669 100644
--- a/cesar/ce/rx/cp/mme.h
+++ b/cesar/ce/rx/cp/mme.h
@@ -23,6 +23,10 @@
* \warning this function must be executed in the context of the CP.
*/
+#include "cp/cp.h"
+#include "cp/sta/mgr/sta.h"
+
+
BEGIN_DECLS
/**
diff --git a/cesar/ce/rx/cp/src/cp.c b/cesar/ce/rx/cp/src/cp.c
new file mode 100644
index 0000000000..1708bc8c95
--- /dev/null
+++ b/cesar/ce/rx/cp/src/cp.c
@@ -0,0 +1,198 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/rx/cp/src/cp.c
+ * \brief Interface to use the CE RX in the CP context.
+ * \ingroup ce_rx
+ */
+#include "common/std.h"
+
+#include "cp/inc/context.h"
+#include "cp/sta/mgr/sta_mgr.h"
+#include "ce/rx/cp/mme.h"
+#include "ce/rx/inc/rx.h"
+#include "ce/rx/cp/inc/cp.h"
+#include "ce/rx/cp/cp.h"
+
+/**
+ * Get a pre-filed mailbox node for the communication with the CP.
+ * \param ce_rx the context of the CE in RX.
+ * \param peer the TEI of the peer STA.
+ * \param tms the RX tome maps.
+ */
+ce_rx_cp_mbox_t *
+ce_rx_cp_new_cp_mbox_node (ce_rx_t *ce_rx, cp_tei_t peer, tonemaps_t *tms)
+{
+ /* Check parameters. */
+ dbg_assert (ce_rx);
+ dbg_assert (tms);
+ dbg_assert (MAC_TEI_IS_STA (peer));
+
+ /* Create node. */
+ ce_rx_cp_mbox_t *work = slab_alloc (&ce_rx->cp_mbox_cache);
+ dbg_assert (work);
+ /* Pre filed it. */
+ work->tei = peer;
+ /* Copy some information. */
+ /* Default TMI. */
+ work->default_tmi = tms->default_tmi;
+ /* TMI list. */
+ uint i;
+ for (i = NEGOCIATED_TONEMAP_INDEX_FIRST; i < TONEMAP_INDEX_NB; i++)
+ {
+ if (tms->tm[i])
+ work->tmi_list |= (1 << i);
+ }
+ /* Intervals. */
+ work->intervals_list.intervals_nb = tms->intervals->intervals_nb;
+ for (i = 0; i < work->intervals_list.intervals_nb; i++)
+ {
+ work->intervals_list.interval[i] = tms->intervals->interval[i];
+ }
+ return work;
+}
+
+
+void
+ce_rx_cp_set_cp_signal_work_callback (ce_rx_t *ce_rx,
+ ce_rx_cp_signal_work_t cb, cp_t *ctx)
+{
+ /* Check parameters. */
+ dbg_assert (ce_rx);
+ dbg_assert (cb);
+ dbg_assert (ctx);
+
+ ce_rx->cp_ctx = ctx;
+ ce_rx->cp_cb = cb;
+}
+
+void
+ce_rx_cp_init (ce_rx_t *ce_rx)
+{
+ /* Check parameter. */
+ dbg_assert (ce_rx);
+
+ /* Initialize the mailbox between the CP and the CE RX. */
+ mbox_init (&ce_rx->cp_mbox);
+ /* Initialize the allocator for the CP mailbox. */
+ slab_cache_init (&ce_rx->cp_mbox_cache, "ce_rx_cp",
+ sizeof (ce_rx_cp_mbox_t), NULL);
+}
+
+void
+ce_rx_cp_uninit (ce_rx_t *ce_rx)
+{
+ /* Check parameters. */
+ dbg_assert (ce_rx);
+
+ /* Clean the mailbox. */
+ mbox_node_t *node;
+ ce_rx_cp_mbox_t *work;
+ while ((node = mbox_try_get (&ce_rx->cp_mbox)))
+ {
+ /* Convert. */
+ work = PARENT_OF (ce_rx_cp_mbox_t, mbox_node, node);
+ /* Delete. */
+ slab_release (work);
+ }
+ /* Clean. */
+ mbox_uninit (&ce_rx->cp_mbox);
+}
+
+void
+ce_rx_cp_send_mme_new_tone_map (ce_rx_t *ce_rx, sta_t *peer, u8 new_tmi,
+ u8 old_tmi, bool initial_ce)
+{
+ /* Check parameters. */
+ dbg_assert (ce_rx);
+ dbg_assert (peer);
+ dbg_assert (IS_NEGOCIATED_TONEMAP_INDEX (new_tmi));
+ dbg_assert (IS_NEGOCIATED_TONEMAP_INDEX (old_tmi));
+
+ if (ce_rx->cp_ctx)
+ {
+ /* Create a new work. */
+ ce_rx_cp_mbox_t *work = ce_rx_cp_new_cp_mbox_node (ce_rx, peer->tei,
+ peer->rx_tonemaps);
+ work->new_tmi = new_tmi;
+ work->old_tmi = old_tmi;
+ /* Add it to the list. */
+ mbox_put (&ce_rx->cp_mbox, &work->mbox_node);
+ /* Post a flag for the CP. */
+ ce_rx->cp_cb (ce_rx->cp_ctx);
+ }
+}
+
+void
+ce_rx_cp_send_mme_refresh_tmi_list (ce_rx_t *ce_rx, sta_t *peer)
+{
+ /* Check parameters. */
+ dbg_assert (ce_rx);
+ dbg_assert (peer);
+
+ if (ce_rx->cp_ctx)
+ {
+ /* Create a new work. */
+ ce_rx_cp_mbox_t *work = ce_rx_cp_new_cp_mbox_node (ce_rx, peer->tei,
+ peer->rx_tonemaps);
+ /* No tone map to send, just a refresh. */
+ work->new_tmi = work->old_tmi = 0;
+ /* Add it to the list. */
+ mbox_put (&ce_rx->cp_mbox, &work->mbox_node);
+ /* Post a flag for the CP. */
+ ce_rx->cp_cb (ce_rx->cp_ctx);
+ }
+}
+
+void
+ce_rx_cp_run_work (cp_t *ctx)
+{
+ /* Check parameter. */
+ dbg_assert (ctx);
+
+ /* Get the CE RX context. */
+ ce_rx_t *ce_rx = ctx->ce_rx;
+ dbg_assert (ce_rx);
+ /* Get my net. */
+ cp_net_t *my_net = cp_sta_mgr_get_our_avln (ctx);
+ /* Get a mbox node */
+ mbox_node_t *node;
+ /* Maybe we have more than one mail do deal with. */
+ while ((node = mbox_try_get (&ce_rx->cp_mbox)))
+ {
+ dbg_assert (node);
+ ce_rx_cp_mbox_t *work = PARENT_OF (ce_rx_cp_mbox_t, mbox_node, node);
+
+ /* Get the STA. */
+ cp_sta_t *cp_sta = cp_sta_mgr_sta_get_assoc (ctx, my_net, work->tei);
+ dbg_assert (cp_sta);
+ /* Get the MAC store STA. */
+ sta_t *sta = mac_store_sta_get (ctx->mac_store, work->tei);
+ dbg_assert (sta);
+ dbg_assert (sta->rx_tonemaps);
+
+ /* No new TMI, refresh. */
+ if (!work->new_tmi)
+ ce_rx_mme_refresh_tone_map_list (ctx, cp_sta, work->tmi_list,
+ work->default_tmi,
+ &work->intervals_list,
+ sta->rx_tonemaps);
+ /* FIXME: should compute best MME to send. */
+ /* Send the new tone map. */
+ ce_rx_cp_mme_send_tone_map (ctx, cp_sta, work->tmi_list,
+ work->default_tmi, &work->intervals_list,
+ work->new_tmi,
+ work->old_tmi, sta->rx_tonemaps,
+ work->initial_ce);
+
+ /* Clean. */
+ blk_release (sta);
+ slab_release (cp_sta);
+ slab_release (work);
+ }
+}
diff --git a/cesar/ce/rx/cp/stub/Module b/cesar/ce/rx/cp/stub/Module
new file mode 100644
index 0000000000..62ea4e1b1c
--- /dev/null
+++ b/cesar/ce/rx/cp/stub/Module
@@ -0,0 +1,2 @@
+# Channel Estimation (CE) in Receive (RX) mode, CP sub-module, stub part.
+SOURCES := cp.c
diff --git a/cesar/ce/rx/cp/stub/src/cp.c b/cesar/ce/rx/cp/stub/src/cp.c
new file mode 100644
index 0000000000..b3eda70c76
--- /dev/null
+++ b/cesar/ce/rx/cp/stub/src/cp.c
@@ -0,0 +1,34 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/rx/cp/stub/src/cp.c
+ * \brief Interface to use the CE RX in the CP context (stub part).
+ * \ingroup ce_rx
+ */
+#include "common/std.h"
+
+#include "ce/rx/cp/cp.h"
+
+void
+ce_rx_cp_set_cp_signal_work_callback (ce_rx_t *ce_rx,
+ ce_rx_cp_signal_work_t cb, cp_t *ctx)
+__attribute__ ((weak));
+
+void
+ce_rx_cp_set_cp_signal_work_callback (ce_rx_t *ce_rx,
+ ce_rx_cp_signal_work_t cb, cp_t *ctx)
+{
+}
+
+void
+ce_rx_cp_run_work (cp_t *ctx) __attribute__ ((weak));
+
+void
+ce_rx_cp_run_work (cp_t *ctx)
+{
+}
diff --git a/cesar/ce/rx/cp/test/Makefile b/cesar/ce/rx/cp/test/Makefile
index 6c0db51735..ecec285c2e 100644
--- a/cesar/ce/rx/cp/test/Makefile
+++ b/cesar/ce/rx/cp/test/Makefile
@@ -1,11 +1,14 @@
# Base of the project.
BASE = ../../../..
+# Enable ECos.
+ECOS = y
+
# Common includes.
-INCLUDES = ce/tx/test/override
+INCLUDES = ce/rx/cp/test/override
# For host program.
-HOST_PROGRAMS = test_mme
+TARGET_PROGRAMS = test_mme
test_mme_SOURCES = test_mme.c stub.c
test_mme_MODULES = lib mac/common ce/rx/cp ce/common cp/msg/stub
diff --git a/cesar/ce/rx/cp/test/ecos.ecc.sh b/cesar/ce/rx/cp/test/ecos.ecc.sh
new file mode 100644
index 0000000000..2443d0e40f
--- /dev/null
+++ b/cesar/ce/rx/cp/test/ecos.ecc.sh
@@ -0,0 +1,5 @@
+config=${1:-ecos-gen.ecc}
+ecosconfig --config=$config new linux default
+cat >> $config <<'EOF'
+EOF
+ecosconfig --config=$config check
diff --git a/cesar/ce/rx/cp/test/override/cp/inc/context.h b/cesar/ce/rx/cp/test/override/cp/inc/context.h
new file mode 100644
index 0000000000..bec9798a2b
--- /dev/null
+++ b/cesar/ce/rx/cp/test/override/cp/inc/context.h
@@ -0,0 +1,39 @@
+#ifndef override_cp_inc_context_h
+#define override_cp_inc_context_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file override/cp/inc/context.h
+ * \brief Control plane context override.
+ * \ingroup ce
+ */
+
+#include "mac/common/config.h"
+#include "mac/common/store.h"
+#include "ce/rx/rx.h"
+#include "lib/bitstream.h"
+
+struct cp_t
+{
+ /** Mac store context. */
+ mac_store_t *mac_store;
+
+ /** The mac config context. */
+ mac_config_t *mac_config;
+
+ /** CE RX context. */
+ ce_rx_t *ce_rx;
+
+ /** For test. */
+ u8 *vect;
+ bitstream_t *vect_bt;
+ uint vect_size;
+ struct test_t *t;
+};
+
+#endif /* override_cp_inc_context_h */