summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorlaranjeiro2010-05-17 09:38:52 +0000
committerlaranjeiro2010-05-17 09:38:52 +0000
commitf5a355cc8f70003a498f1414c8255ace115e6be6 (patch)
treee880ec0b68d33d15b7a0b1b12aeba6523b906c23 /cesar
parentec5cabf8246f4d99df4ad7bd59cd6283d8575e29 (diff)
cesar/bsu: add bsu params at the end of the beacon block,
* add pbproc_rx_beacon_params_t into bsu_params_t * change the callback params type. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7038 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar')
-rw-r--r--cesar/bsu/bsu.h11
-rw-r--r--cesar/bsu/src/interface.c34
-rw-r--r--cesar/bsu/test/utest/src/bsut.c4
-rw-r--r--cesar/bsu/test/utest/src/interface.c14
-rw-r--r--cesar/bsu/test/utest/src/tests.c10
-rw-r--r--cesar/bsu/test/utest/tests.h4
6 files changed, 44 insertions, 33 deletions
diff --git a/cesar/bsu/bsu.h b/cesar/bsu/bsu.h
index 92c8e03666..9be8b2c61b 100644
--- a/cesar/bsu/bsu.h
+++ b/cesar/bsu/bsu.h
@@ -20,6 +20,7 @@
#include "mac/sar/sar.h"
#include "hal/timer/timer.h"
#include "bsu/beacon/beacon.h"
+#include "bsu/beacon/defs.h"
/** Forward declaration. */
typedef struct bsu_t bsu_t;
@@ -37,27 +38,27 @@ typedef enum bsu_beacon_direction_t bsu_beacon_direction_t;
/** BSU computed parameters. */
struct bsu_params_t
{
+ /** Pbproc RX parameters. */
+ pbproc_rx_beacon_params_t rx_parameters;
/** Direction */
bsu_beacon_direction_t direction;
/** Frequency error. */
s32 frequency_error;
/** Tick offset, difference between the NTB and PHY Date clock. */
- u32 tick_offset;
+ u32 ntb_offset_tck;
};
typedef struct bsu_params_t bsu_params_t;
/** Function to call on beacon reception or beacon sending.
* \param ctx upper layer context.
* \param beacon the beacon sent or received.
- * \param params the reception parameters contained in the Frame Control.
- * \param bparams the BSU computed data, set only if the BSU is the emitter.
+ * \param bparams the BSU computed data.
* \warn the upper layer is responsible for releasing the reference on the
* beacon.
*/
typedef void
(*bsu_beacon_processed_t) (void *ctx, pb_beacon_t *beacon,
- pbproc_rx_beacon_params_t *params,
- bsu_params_t bparams);
+ bsu_params_t *bparams);
BEGIN_DECLS
diff --git a/cesar/bsu/src/interface.c b/cesar/bsu/src/interface.c
index 5fa6772b56..db1b7626fd 100644
--- a/cesar/bsu/src/interface.c
+++ b/cesar/bsu/src/interface.c
@@ -20,6 +20,26 @@
#include "bsu/inc/context.h"
+/**
+ * Store the BSU params in the beacon.
+ * \param ctx the module context.
+ * \param beacon the beacon.
+ * \param direction the reception or transmission.
+ * \param avln the avln synchronisation data.
+ */
+static inline bsu_params_t*
+bsu_params_store (bsu_t *ctx, pb_beacon_t *beacon,
+ bsu_beacon_direction_t direction,
+ bsu_avln_t *avln)
+{
+ bsu_params_t *bsu_params =
+ (bsu_params_t *) (beacon->data + BSU_BEACON_SIZE);
+ bsu_params->direction = direction;
+ bsu_params->frequency_error = FIXED (avln->sync.fe, BSU_NTB_FIXED_POINT);
+ bsu_params->ntb_offset_tck = avln->sync.ntb_offset_tck;
+ return bsu_params;
+}
+
void
bsu_beacon_send (bsu_t *ctx, bsu_beacon_type_t beacon_type,
pb_beacon_t *beacon, void *bto_bpsto)
@@ -67,10 +87,9 @@ bsu_beacon_send (bsu_t *ctx, bsu_beacon_type_t beacon_type,
/* Provide the beacon to the SAR. */
sar_beacon_send (ctx->sar, beacon, beacon_mfs, bto_bpsto);
/* Send the beacon to the upper layer. */
- bsu_params_t bsu_params = {BSU_BEACON_DIRECTION_TO_PLC,
- FIXED (ctx->sta_avln->sync.fe, BSU_NTB_FIXED_POINT),
- ctx->sta_avln->sync.ntb_offset_tck};
- (*ctx->ul_cb) (ctx->ul_data, beacon, NULL, bsu_params);
+ bsu_params_t * bsu_params = bsu_params_store (
+ ctx, beacon, BSU_BEACON_DIRECTION_TO_PLC, ctx->sta_avln);
+ (*ctx->ul_cb) (ctx->ul_data, beacon, bsu_params);
}
void
@@ -86,8 +105,7 @@ bsu_beacon_recv (bsu_t *ctx, pb_beacon_t *beacon,
/* Process the beacon received from the SAR. */
bsu_beacon_process (ctx, beacon, params);
/* Send it to the upper layer. */
- bsu_params_t bsu_params = {BSU_BEACON_DIRECTION_FROM_PLC,
- FIXED (ctx->sta_avln->sync.fe, BSU_NTB_FIXED_POINT),
- ctx->sta_avln->sync.ntb_offset_tck};
- (*ctx->ul_cb) (ctx->ul_data, beacon, params, bsu_params);
+ bsu_params_t * bsu_params = bsu_params_store (
+ ctx, beacon, BSU_BEACON_DIRECTION_FROM_PLC, ctx->sta_avln);
+ (*ctx->ul_cb) (ctx->ul_data, beacon, bsu_params);
}
diff --git a/cesar/bsu/test/utest/src/bsut.c b/cesar/bsu/test/utest/src/bsut.c
index 139e2a7acf..77ff1e7ed3 100644
--- a/cesar/bsu/test/utest/src/bsut.c
+++ b/cesar/bsu/test/utest/src/bsut.c
@@ -273,7 +273,7 @@ test_case_bsu_timer_event (test_t test)
bsu_update (&beacon, false /* CCo */);
bsu_timer_event_process (t.bsu);
test_fail_unless (t.ul.beacon != INVALID_PTR);
- test_fail_unless (t.ul.pparams != INVALID_PTR);
+ test_fail_unless (t.ul.bparams != INVALID_PTR);
/* Release the reference handled by the CP. */
blk_release_desc ((blk_t*) t.ul.beacon);
mfs = mac_store_mfs_get (t.mac_store, true, true, false,
@@ -289,7 +289,7 @@ test_case_bsu_timer_event (test_t test)
bsu_avln_schedules_beacon_not_received (t.bsu, &cmp_avln);
bsu_timer_event_process (t.bsu);
test_fail_unless (t.ul.beacon != INVALID_PTR);
- test_fail_unless (t.ul.pparams != INVALID_PTR);
+ test_fail_unless (t.ul.bparams != INVALID_PTR);
blk_release_desc ((blk_t*) t.ul.beacon);
for (j = 0; j < cmp_avln.bs.schedules.ps.nb; j++)
{
diff --git a/cesar/bsu/test/utest/src/interface.c b/cesar/bsu/test/utest/src/interface.c
index 308d322ea0..fc18c5707f 100644
--- a/cesar/bsu/test/utest/src/interface.c
+++ b/cesar/bsu/test/utest/src/interface.c
@@ -62,13 +62,12 @@ test_case_bsu_interface_tx (test_t t, bsu_beacon_type_t type)
else
test_fail_unless (test.sar.mfs->cap == 0x2);
test_fail_unless (test.ul.beacon == beacon);
- test_fail_unless (test.ul.pparams == NULL);
- test_fail_unless (test.ul.bparams.direction
+ test_fail_unless (test.ul.bparams->direction
== BSU_BEACON_DIRECTION_TO_PLC);
- test_fail_unless (test.ul.bparams.frequency_error
+ test_fail_unless (test.ul.bparams->frequency_error
== FIXED(test.bsu->avlns[0].sync.fe,
BSU_NTB_FIXED_POINT));
- test_fail_unless (test.ul.bparams.tick_offset
+ test_fail_unless (test.ul.bparams->ntb_offset_tck
== test.bsu->avlns[0].sync.ntb_offset_tck);
/* Free the beacon. */
blk_release_desc ((blk_t*) beacon);
@@ -104,13 +103,12 @@ test_case_bsu_interface_rx (test_t t)
beacon->phy_pb.pb_rx.pb_measurement.crc_error = false;
bsu_beacon_recv (test.bsu, beacon, &rx_params);
test_fail_unless (test.ul.beacon == beacon);
- test_fail_unless (test.ul.pparams == &rx_params);
- test_fail_unless (test.ul.bparams.direction
+ test_fail_unless (test.ul.bparams->direction
== BSU_BEACON_DIRECTION_FROM_PLC);
- test_fail_unless (test.ul.bparams.frequency_error
+ test_fail_unless (test.ul.bparams->frequency_error
== FIXED(test.bsu->avlns[0].sync.fe,
BSU_NTB_FIXED_POINT));
- test_fail_unless (test.ul.bparams.tick_offset
+ test_fail_unless (test.ul.bparams->ntb_offset_tck
== test.bsu->avlns[0].sync.ntb_offset_tck);
bsu_test_uninit (&test);
blk_release_desc ((blk_t*) beacon);
diff --git a/cesar/bsu/test/utest/src/tests.c b/cesar/bsu/test/utest/src/tests.c
index 1fd72598ad..d1804717df 100644
--- a/cesar/bsu/test/utest/src/tests.c
+++ b/cesar/bsu/test/utest/src/tests.c
@@ -20,16 +20,12 @@
static void
bsu_test_upper_layer_beacon_received (void *ctx, pb_beacon_t *beacon,
- pbproc_rx_beacon_params_t *params,
- bsu_params_t bparams)
+ bsu_params_t *bparams)
{
bsu_test_t *test = (bsu_test_t*) ctx;
dbg_assert (ctx);
test->ul.beacon = beacon;
- test->ul.pparams = params;
- test->ul.bparams.direction = bparams.direction;
- test->ul.bparams.frequency_error = bparams.frequency_error;
- test->ul.bparams.tick_offset = bparams.tick_offset;
+ test->ul.bparams = bparams;
}
void
@@ -37,7 +33,7 @@ bsu_test_upper_layer_beacon_received_init (bsu_test_t *ctx)
{
dbg_assert (ctx);
ctx->ul.beacon = INVALID_PTR;
- ctx->ul.pparams = INVALID_PTR;
+ ctx->ul.bparams = INVALID_PTR;
}
void
diff --git a/cesar/bsu/test/utest/tests.h b/cesar/bsu/test/utest/tests.h
index a649bd5a3d..ff59576c09 100644
--- a/cesar/bsu/test/utest/tests.h
+++ b/cesar/bsu/test/utest/tests.h
@@ -52,10 +52,8 @@ struct bsu_test_ul_t
{
/** Beacon sent. */
pb_beacon_t *beacon;
- /** PHY RX params. */
- pbproc_rx_beacon_params_t *pparams;
/** BSU beacon params. */
- bsu_params_t bparams;
+ bsu_params_t *bparams;
};
typedef struct bsu_test_ul_t bsu_test_ul_t;