summaryrefslogtreecommitdiff
path: root/cesar/ce/src
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/ce/src')
-rwxr-xr-xcesar/ce/src/mpdu_measure_store.c1
-rwxr-xr-xcesar/ce/src/rx.c69
-rwxr-xr-xcesar/ce/src/tx.c50
3 files changed, 80 insertions, 40 deletions
diff --git a/cesar/ce/src/mpdu_measure_store.c b/cesar/ce/src/mpdu_measure_store.c
index c1f6d051e5..7b55e8df82 100755
--- a/cesar/ce/src/mpdu_measure_store.c
+++ b/cesar/ce/src/mpdu_measure_store.c
@@ -152,6 +152,7 @@ mpdu_measure_store_append (mpdu_measure_store_t *ctx, pbproc_rx_params_t *rx_par
}
else
{
+ // TODO Check if rx_params has changed.
mpdu_measure_t *measure = &ctx->store[ctx->tail];
measure->rx_params = rx_params;
if (pb_nb) mpdu_measure_pb_add (measure, pb_nb, pb_first, pb_last, blk_offset);
diff --git a/cesar/ce/src/rx.c b/cesar/ce/src/rx.c
index 6b58c75f41..e67446b99a 100755
--- a/cesar/ce/src/rx.c
+++ b/cesar/ce/src/rx.c
@@ -30,6 +30,16 @@
#include "cp/sta/mgr/sta_mgr.h"
#include "cp/msg/msg.h"
+#ifdef AUTOSTART_RXCE_PROCESS
+#include <cyg/infra/diag.h>
+#include "cyg/kernel/kapi.h"
+#include "cyg/hal/hal_arch.h"
+#define RXCE_PRIORITY 15
+cyg_thread rxce_thread;
+cyg_handle_t rxce_handle;
+unsigned char rxce_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
+#endif
+
static rxce_t ce_global;
#ifdef EXPIRATION_TEST
@@ -64,11 +74,23 @@ rxce_init (sar_t *sar, mac_store_t *mac_store_ctx, mac_config_t *mac_config_ctx,
sar_init_measure_context (sar, ctx);
sar_init_measurement_cb (sar, rxce_mpdu_measurement_add);
#endif
+#ifdef AUTOSTART_RXCE_PROCESS
+ cyg_thread_create (RXCE_PRIORITY, &rxce_process, (cyg_addrword_t) ctx, "rxce",
+ rxce_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &rxce_handle, &rxce_thread);
+ cyg_thread_resume (rxce_handle);
+#endif
RXCE_TRACE (INIT, mac_ntb());
return (ctx);
}
void
+rxce_uninit (rxce_t *rxce)
+{
+ dbg_assert (rxce);
+}
+
+void
pbproc_need_scf_cb (uint tei, uint reason_code)
{
dbg_assert (&ce_global);
@@ -88,19 +110,27 @@ bool
rxce_mpdu_measurement_add (void *user, pbproc_rx_params_t *rx_params,
uint pb_nb, blk_t **f, blk_t **l, pb_t *noise, uint n, uint *blk_offset)
{
+ bool b;
dbg_assert (user);
rxce_t *ctx = (rxce_t *) user;
RXCE_TRACE (SAR_MEASUREMENT_CB, mac_ntb());
dbg_assert (rx_params);
- bool b;
- pb_measure_blk_t **first = (pb_measure_blk_t **) f;
- pb_measure_blk_t **last = (pb_measure_blk_t **) l;
- // Allocate block if necessary. The SAR will fill blocks after !couldn't be stopped by RXCE!.
- b = mpdu_measure_store_append (ctx->mpdu_measure_store_ctx, rx_params, pb_nb, first, last, (phy_chandata_t *) noise, n, blk_offset);
- // Give 'job' to RXCE that will process the previous frame.
- if (b) cyg_semaphore_post (&(ctx->job));
- else RXCE_TRACE (MEASURE_DROPPED, mac_ntb());
- return (b);
+ blk_addref (rx_params);
+ if (cp_sta_own_data_get_authenticated_status (ctx->cp_ctx))
+ {
+ pb_measure_blk_t **first = (pb_measure_blk_t **) f;
+ pb_measure_blk_t **last = (pb_measure_blk_t **) l;
+ // Allocate block if necessary. The SAR will fill blocks after !couldn't be stopped by RXCE!.
+ b = mpdu_measure_store_append (ctx->mpdu_measure_store_ctx, rx_params, pb_nb, first, last, (phy_chandata_t *) noise, n, blk_offset);
+ // Give 'job' to RXCE that will process the previous frame.
+ if (b) cyg_semaphore_post (&(ctx->job));
+ else RXCE_TRACE (MEASURE_DROPPED, mac_ntb());
+ return b;
+ }
+ else
+ {
+ return false;
+ }
}
/** todo Cf SPEC HPAV HPAV-FrameControl -- SoundVariantField -- SoundReasonCode */
@@ -156,9 +186,11 @@ void
rxce_next_measurement_compute (rxce_t *ctx)
{
dbg_assert (ctx);
+ bitloading_modification_t bl ;
mpdu_measure_t *measure = mpdu_measure_store_get (ctx->mpdu_measure_store_ctx);
dbg_assert (measure);
- bitloading_modification_t bl = bitloading_run (ctx->mac_store_ctx, measure);
+ bl = bitloading_run (ctx->mac_store_ctx, measure);
+
#ifdef RXCE_MONITORING
uint toto = 9 + sizeof (pbproc_rx_params_t);
write (ctx->pipe_out_fd, &toto, sizeof(toto));
@@ -175,12 +207,12 @@ rxce_next_measurement_compute (rxce_t *ctx)
{
write (ctx->pipe_out_fd, measure->pb_head->next->data, measure->pb_head->next->pb_nb * 4);
}
-
- //write (ctx->pipe_out_fd, measure->pb_head->data, 512);
-
#endif
mpdu_measure_store_release (ctx->mpdu_measure_store_ctx, measure);
- if (bl.changed_tonemaps ) rxce_job_cei_add (ctx, bl.stei, bl.changed_tonemaps, bl.new_tmi, bl.old_tmi);
+ if (bl.changed_tonemaps )
+ {
+ rxce_job_cei_add (ctx, bl.stei, bl.changed_tonemaps, bl.new_tmi, bl.old_tmi);
+ }
}
@@ -267,6 +299,7 @@ rxce_process (cyg_addrword_t data)
cp_sta_t *cp_sta;
cp_mme_tx_t *mme;
cp_mme_peer_t peer;
+ cei_created_status_t cei_status;
RXCE_TRACE (CEI_PROCESS, mac_ntb());
cei_param_t *param = cei_param_get ();
dbg_assert (param);
@@ -280,12 +313,14 @@ rxce_process (cyg_addrword_t data)
expiration_test (param->dtei);
#endif
#ifdef MAXIMUS_TEST
- cei_created_status_t cei_status = cei_create (mme->p_mme, &mme->bitstream, ctx->mask, param->tms, param->new_tmi, param->old_tmi);
+ cei_status = cei_create (mme->p_mme, &mme->bitstream, ctx->mask, param->tms, param->new_tmi, param->old_tmi);
cp_msg_mme_send (ctx->cp_ctx, mme);
sta_t *sta = mac_store_sta_get (ctx->mac_store_ctx, param->dtei);
- cei_decode (sta->tx_tonemaps, cei_status.mm_type, mme->p_mme, ctx->mask);
+ bitstream_t reader;
+ bitstream_read_init (&reader, mme->p_mme, 1536);
+ cei_decode (sta->tx_tonemaps, cei_status.mm_type, &reader, ctx->mask);
#else
- cei_create (mme->p_mme, &mme->bitstream, ctx->mask, param->tms, param->new_tmi, param->old_tmi);
+ cei_status = cei_create (mme->p_mme, &mme->bitstream, ctx->mask, param->tms, param->new_tmi, param->old_tmi);
cp_msg_mme_send (ctx->cp_ctx, mme);
#endif
}
diff --git a/cesar/ce/src/tx.c b/cesar/ce/src/tx.c
index 6d16cff6ca..f8dd2e65a5 100755
--- a/cesar/ce/src/tx.c
+++ b/cesar/ce/src/tx.c
@@ -14,14 +14,17 @@
*/
#include "common/std.h"
#include <stdio.h>
+#include "cp/cp.h"
+#include "cp/inc/context.h"
+#include "ce/tx.h"
#include "ce/inc/tx.h"
#define TXCE
#include "ce/inc/cei.h"
static txce_t txce_global;
-txce_t *
-txce_init (mac_store_t *mac_store_ctx, mac_config_t *mac_config_ctx)
+void
+txce_init (cp_t *cp_ctx, mac_store_t *mac_store_ctx, mac_config_t *mac_config_ctx)
{
dbg_assert (mac_store_ctx);
dbg_assert (mac_config_ctx);
@@ -31,8 +34,27 @@ txce_init (mac_store_t *mac_store_ctx, mac_config_t *mac_config_ctx)
cyg_handle_t sys_clk = cyg_real_time_clock();
cyg_handle_t counter_hdl;
cyg_clock_to_counter (sys_clk, &counter_hdl);
- cyg_alarm_create (counter_hdl, alarm_cb, (cyg_addrword_t) ctx, &ctx->alarm_hdl, &ctx->alarm_obj);
- return (ctx);
+ cyg_alarm_create (counter_hdl, alarm_cb, (cyg_addrword_t) cp_ctx, &ctx->alarm_hdl, &ctx->alarm_obj);
+ cp_ctx->txce = ctx;
+}
+
+void
+txce (cp_t *cp_ctx, uint stei, u32 mmtype, bitstream_t *stream_reader)
+{
+ dbg_assert (cp_ctx);
+ txce_t *ctx = cp_ctx->txce;
+ if (stream_reader)
+ {
+ dbg_assert (mmtype == CM_CHAN_EST_IND || mmtype == CM_TM_UPDATE_IND);
+ dbg_assert (stei>=MAC_TEI_STA_MIN && stei<=MAC_TEI_STA_MAX);
+ // Get concerned tonemaps from stei.
+ sta_t *source_sta = mac_store_sta_get (ctx->mac_store_ctx, stei);
+ tonemaps_t *source_tms = source_sta->tx_tonemaps;
+ cei_decode (source_tms, mmtype, stream_reader, ctx->tonemask);
+ blk_release (source_sta);
+ }
+ cyg_tick_count_t next_expiration = txce_expiration_tonemaps_management (ctx);
+ cyg_alarm_initialize (ctx->alarm_hdl, next_expiration, 0);
}
cyg_tick_count_t
@@ -76,27 +98,9 @@ txce_expiration_tonemaps_management (txce_t *ctx)
}
void
-txce (txce_t *ctx, uint stei, u32 mmtype, u8 *mm_entry)
-{
- dbg_assert (ctx);
- if (mm_entry)
- {
- dbg_assert (mmtype == CM_CHAN_EST_IND || mmtype == CM_TM_UPDATE_IND);
- dbg_assert (stei>=MAC_TEI_STA_MIN && stei<=MAC_TEI_STA_MAX);
- // Get concerned tonemaps from stei.
- sta_t *source_sta = mac_store_sta_get (ctx->mac_store_ctx, stei);
- tonemaps_t *source_tms = source_sta->tx_tonemaps;
- cei_decode (source_tms, mmtype, mm_entry, ctx->tonemask);
- blk_release (source_sta);
- }
- cyg_tick_count_t next_expiration = txce_expiration_tonemaps_management (ctx);
- cyg_alarm_initialize (ctx->alarm_hdl, next_expiration, 0);
-}
-
-void
alarm_cb (cyg_handle_t alarm_hdl, cyg_addrword_t data)
{
dbg_assert (data);
- txce_t *ctx = (txce_t *) data;
+ cp_t *ctx = (cp_t *) data;
txce (ctx, 0, 0, NULL);
}