summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
Diffstat (limited to 'cesar')
-rw-r--r--cesar/bsu/bsu.h11
-rw-r--r--cesar/bsu/src/bsu.c13
-rw-r--r--cesar/bsu/test/utest/src/tests.c4
-rw-r--r--cesar/cp/beacon/src/beacon.c43
-rw-r--r--cesar/interface/inc/context.h4
-rw-r--r--cesar/interface/interface.h39
-rw-r--r--cesar/interface/src/interface.c65
-rw-r--r--cesar/interface/stub/src/interface.c10
-rw-r--r--cesar/station/src/station.c4
9 files changed, 52 insertions, 141 deletions
diff --git a/cesar/bsu/bsu.h b/cesar/bsu/bsu.h
index 6030048b41..c2a7d65c56 100644
--- a/cesar/bsu/bsu.h
+++ b/cesar/bsu/bsu.h
@@ -87,8 +87,15 @@ BEGIN_DECLS
*/
bsu_t *
bsu_init (bsu_aclf_t *aclf, mac_config_t *mac_config, phy_t *phy,
- mac_store_t *mac_store, ca_t *ca, sar_t *sar, hal_timer_t *timer,
- bsu_beacon_processed_t cb, void *cb_ud);
+ mac_store_t *mac_store, ca_t *ca, sar_t *sar, hal_timer_t *timer);
+
+/**
+ * Initialise the beacon callback to send to upper layer.
+ * \param cb the function to call.
+ * \param ul the upper layer user data.
+ */
+void
+bsu_init_beacon_cb (bsu_beacon_processed_t cb, void *cb_ud);
/**
* Uninitialise the module.
diff --git a/cesar/bsu/src/bsu.c b/cesar/bsu/src/bsu.c
index 31265712ab..997eac6b2f 100644
--- a/cesar/bsu/src/bsu.c
+++ b/cesar/bsu/src/bsu.c
@@ -373,8 +373,7 @@ bsu_timer_event_process (void *ud)
bsu_t *
bsu_init (bsu_aclf_t *aclf, mac_config_t *mac_config, phy_t *phy,
- mac_store_t *mac_store, ca_t *ca, sar_t *sar, hal_timer_t *timer,
- bsu_beacon_processed_t cb, void *cb_ud)
+ mac_store_t *mac_store, ca_t *ca, sar_t *sar, hal_timer_t *timer)
{
bsu_t *ctx = &bsu_global;
dbg_assert (aclf);
@@ -384,7 +383,6 @@ bsu_init (bsu_aclf_t *aclf, mac_config_t *mac_config, phy_t *phy,
dbg_assert (ca);
dbg_assert (sar);
dbg_assert (timer);
- dbg_assert (cb);
/* Initialise the context. */
ctx->aclf = aclf;
ctx->mac_config = mac_config;
@@ -392,8 +390,6 @@ bsu_init (bsu_aclf_t *aclf, mac_config_t *mac_config, phy_t *phy,
ctx->mac_store = mac_store;
ctx->ca = ca;
ctx->sar = sar;
- ctx->ul_cb = cb;
- ctx->ul_data = cb_ud;
ctx->hal_timer = timer;
/* Initialise the NTB. */
uint i;
@@ -411,6 +407,13 @@ bsu_init (bsu_aclf_t *aclf, mac_config_t *mac_config, phy_t *phy,
}
void
+bsu_init_beacon_cb (bsu_beacon_processed_t cb, void *cb_ud)
+{
+ bsu_global.ul_cb = cb;
+ bsu_global.ul_data = cb_ud;
+}
+
+void
bsu_uninit (bsu_t *ctx)
{
dbg_assert (ctx);
diff --git a/cesar/bsu/test/utest/src/tests.c b/cesar/bsu/test/utest/src/tests.c
index b82f3d0126..d46749f270 100644
--- a/cesar/bsu/test/utest/src/tests.c
+++ b/cesar/bsu/test/utest/src/tests.c
@@ -52,8 +52,8 @@ bsu_test_init (bsu_test_t *ctx)
ctx->timer);
ctx->bsu = bsu_init (aclf, &ctx->mac_config, (phy_t*) &ctx->phy,
ctx->mac_store, (ca_t*) &ctx->ca, (sar_t*) ctx,
- ctx->timer, bsu_test_upper_layer_beacon_received,
- ctx);
+ ctx->timer);
+ bsu_init_beacon_cb (bsu_test_upper_layer_beacon_received, ctx);
/* Warn just for the test. */
memset (&ctx->bsu->beacon, 0, sizeof (bsu_beacon_t));
ctx->bsu->sta_avln = &ctx->bsu->avlns[0];
diff --git a/cesar/cp/beacon/src/beacon.c b/cesar/cp/beacon/src/beacon.c
index f6cc0a5936..d3dddde43d 100644
--- a/cesar/cp/beacon/src/beacon.c
+++ b/cesar/cp/beacon/src/beacon.c
@@ -275,25 +275,34 @@ cp_beacon_fill_share_memory (cp_t *ctx)
* beacon received in STA_CORE
*/
void
-cp_beacon_receive (cp_t *ctx, pb_beacon_t * beacon)
+cp_beacon_receive (void *ul, pb_beacon_t * beacon, bsu_params_t *params)
{
- dbg_assert (ctx);
+ cp_t *ctx = (cp_t *) ul;
+ dbg_assert (ul);
dbg_assert (beacon);
-
- beacon->next = NULL;
- if (ctx->beacon.list)
+ dbg_assert (params);
+ interface_beacon (ctx->interface, beacon, params);
+ if (params->direction == BSU_BEACON_DIRECTION_FROM_PLC)
{
- ctx->beacon.list_tail->next = beacon;
- ctx->beacon.list_tail = beacon;
+ beacon->next = NULL;
+ if (ctx->beacon.list)
+ {
+ ctx->beacon.list_tail->next = beacon;
+ ctx->beacon.list_tail = beacon;
+ }
+ else
+ {
+ ctx->beacon.list = beacon;
+ ctx->beacon.list_tail = beacon;
+ }
+ // Raise the flag.
+ cp_sta_core_signal_recv_beacon_event (ctx);
}
else
{
- ctx->beacon.list = beacon;
- ctx->beacon.list_tail = beacon;
+ /* The station is CCo, release the beacon. */
+ blk_release_desc ((blk_t*) beacon);
}
-
- // Raise the flag.
- cp_sta_core_signal_recv_beacon_event (ctx);
}
/**
@@ -556,28 +565,20 @@ void
cp_beacon_init (cp_t *ctx)
{
dbg_assert (ctx);
-
// Initialise the beacon module.
memset (&ctx->beacon, 0, sizeof (cp_beacon_t));
-
// Initialise the instance of the leon timer.
hal_timer_instance_init (ctx->hal_timer, &ctx->beacon.leon_timer,
ctx,
(hal_timer_instance_cb_t)cp_beacon_timer_expires);
-
- // Initialise the callback in the interface module.
- interface_callback_beacon_init (ctx->interface,
- (interface_beacon_add_cb_t)cp_beacon_receive,
- ctx);
-
// Initialise the mem_share_slot_id so that the next slot is 0.
ctx->beacon.shared_mem_slot_id = CP_SHARED_MEM_SLOT_NB - 1;
ctx->beacon.last_countdown_date = phy_date ();
ctx->beacon.countdown_limit_date = ctx->beacon.last_countdown_date;
-
/* Setup beacon indicator. */
GPIO_SETUP (LED_BEACON_TX_RX, GPIO_DIRECTION_OUT);
GPIO_SET (LED_BEACON_TX_RX, 0);
+ bsu_init_beacon_cb (cp_beacon_receive, ctx);
}
/**
diff --git a/cesar/interface/inc/context.h b/cesar/interface/inc/context.h
index 6b3dd887a1..cf19dbbd07 100644
--- a/cesar/interface/inc/context.h
+++ b/cesar/interface/inc/context.h
@@ -57,10 +57,6 @@ struct interface_t
interface_mme_buffer_add_cb_t buffer_add_cb;
/** Interface MME user data. */
void *interface_mme_user_data;
- /** Callback on beacon add. */
- interface_beacon_add_cb_t beacon_add_cb;
- /** beacon user data. */
- void *beacon_user_data;
/** Buffer mailbox. */
mbox_t buffers_mbox;
diff --git a/cesar/interface/interface.h b/cesar/interface/interface.h
index 17edc16e19..787cee3396 100644
--- a/cesar/interface/interface.h
+++ b/cesar/interface/interface.h
@@ -46,14 +46,6 @@ typedef void
typedef void
(*interface_mme_buffer_add_cb_t) (void *user_data, u8 *buffer);
-/**
- * Function to call when the interface receives a beacon.
- * \param user_data the data registered by the actor in the init function.
- * \param beacon the beacon freshly received.
- */
-typedef void
-(*interface_beacon_add_cb_t) (void *user_data, pb_beacon_t *beacon);
-
BEGIN_DECLS
/**
@@ -87,17 +79,6 @@ void
interface_callback_init (interface_t *ctx, interface_mme_recv_cb_t mme_recv_cb,
interface_mme_buffer_add_cb_t buffer_add_cb, void *user_data);
-/**
- * Initialise the callbacks functions.
- * \param ctx the interface context.
- * \param beacon_add_cb the function to call on beacon reception
- * \param user_data the data to provide on each callback function.
- */
-void
-interface_callback_beacon_init (interface_t *ctx,
- interface_beacon_add_cb_t beacon_add_cb,
- void *user_data);
-
/** Receives an MME from the PWL or the HLE.
* \param ctx the interface context
* \param tei the station's source TEI.
@@ -134,25 +115,11 @@ interface_mme_send (interface_t *ctx, u8* buffer, uint length, uint tei);
* Sends a beacon, the interface will provide it to the SAR.
* \param ctx the interface context.
* \param beacon the beacon to send.
- * \param beacon_mfs the mfs to use to send the beacon.
- * \param bto_bpsto the four bto to use for the beacon and the bpsto address
- * to be stamp by the pbproc.
+ * \param params the bsu parameters.
*/
void
-interface_beacon_prepare (interface_t *ctx, pb_beacon_t *beacon,
- mfs_tx_t *beacon_mfs, void *bto_bpsto);
-
-/**
-* add a beacon to the interface.
-* It will provide it to the CP to process the beacon.
-*
-* \param ctx the interface context.
-* \param pb pb containing the beacon
-* \param params the rx params.
-* \param bparams the bsu computed params.
-*/
-void interface_beacon_add (interface_t *ctx, pb_beacon_t *pb,
- bsu_params_t *bparams);
+interface_beacon (interface_t *ctx, pb_beacon_t *beacon,
+ bsu_params_t *params);
/**
* Sends a message to the IPMbox
diff --git a/cesar/interface/src/interface.c b/cesar/interface/src/interface.c
index dcb6d9eb90..823401da43 100644
--- a/cesar/interface/src/interface.c
+++ b/cesar/interface/src/interface.c
@@ -118,9 +118,6 @@ interface_init (hle_t *hle, cl_t *cl, sar_t *sar, mac_config_t
cl_mme_recv_init (cl,(cl_mme_recv_cb_t) interface_mme_recv,
&interface_global);
- // Integrate the SAR.
- sar_init_beacon_cb (sar, &interface_global,
- (sar_beacon_cb_t) interface_beacon_add);
// Create the mailbox.
mbox_init (&interface_global.mailbox);
@@ -182,26 +179,6 @@ interface_callback_init (interface_t *ctx, interface_mme_recv_cb_t mme_recv_cb,
ctx->interface_mme_user_data = user_data;
}
-
-/**
- * Initialise the callbacks functions.
- * \param ctx the interface context.
- * \param beacon_add_cb the function to call on beacon reception
- * \param user_data the data to provide on each callback function.
- */
-void
-interface_callback_beacon_init (interface_t *ctx,
- interface_beacon_add_cb_t beacon_add_cb,
- void *user_data)
-{
- dbg_assert (ctx);
- dbg_assert (beacon_add_cb);
-
- ctx->beacon_add_cb = beacon_add_cb;
- ctx->beacon_user_data = user_data;
-}
-
-
/** Receives an MME from the PWL or the HLE.
* \param ctx the interface context
* \param tei the station's source TEI.
@@ -279,58 +256,30 @@ interface_mme_send (interface_t *ctx, u8* buffer, uint length, uint tei)
cl_mme_send (ctx->cl, buffer, length, tei);
}
-
void
-interface_beacon_prepare (interface_t *ctx, pb_beacon_t *beacon,
- mfs_tx_t *beacon_mfs, void *bto_bpsto)
+interface_beacon (interface_t *ctx, pb_beacon_t *beacon, bsu_params_t *params)
{
u8 *buffer;
-
dbg_assert (ctx);
dbg_assert (beacon);
- dbg_assert (ctx->sar);
+ dbg_assert (params);
- if (interface_sniffer_beacon_status_tx (ctx->sniffer))
+ if (params->direction == BSU_BEACON_DIRECTION_TO_PLC
+ && interface_sniffer_beacon_status_tx (ctx->sniffer))
{
buffer = interface_buffer_work_get (ctx);
-
if (buffer)
- {
interface_sniffer_copy_beacon_tx (ctx->sniffer, beacon, buffer);
- }
}
-
- sar_beacon_send (ctx->sar, beacon, beacon_mfs, bto_bpsto);
-}
-
-void interface_beacon_add (interface_t *ctx, pb_beacon_t *pb,
- bsu_params_t *bparams)
-{
- u8 *buffer;
-
- dbg_assert (ctx);
- dbg_assert (pb);
- dbg_assert (ctx->mac_config);
-
- /* Get the buffer to copy the data. */
- if (interface_sniffer_beacon_status_rx (ctx->sniffer))
+ else if (params->direction == BSU_BEACON_DIRECTION_FROM_PLC
+ && interface_sniffer_beacon_status_rx (ctx->sniffer))
{
buffer = interface_buffer_work_get (ctx);
-
if (buffer)
- {
- interface_sniffer_copy_beacon_rx (ctx->sniffer, pb, buffer);
- }
- }
-
- if (bparams->direction == BSU_BEACON_DIRECTION_FROM_PLC)
- {
- dbg_assert (ctx->beacon_add_cb);
- (*ctx->beacon_add_cb) (ctx->beacon_user_data, pb);
+ interface_sniffer_copy_beacon_rx (ctx->sniffer, beacon, buffer);
}
}
-
/**
* Sends a message to the IPMbox
* \param ctx the interface context
diff --git a/cesar/interface/stub/src/interface.c b/cesar/interface/stub/src/interface.c
index 17d0fd1410..68a4b87a9d 100644
--- a/cesar/interface/stub/src/interface.c
+++ b/cesar/interface/stub/src/interface.c
@@ -26,11 +26,6 @@ interface_callback_init (interface_t *ctx, interface_mme_recv_cb_t mme_recv_cb,
interface_mme_buffer_add_cb_t buffer_add_cb, void *user_data)__attribute__((weak));
void
-interface_callback_beacon_init (interface_t *ctx,
- interface_beacon_add_cb_t beacon_add_cb,
- void *user_data)__attribute__((weak));
-
-void
interface_mme_recv (interface_t *ctx, uint tei, u8 *buffer, uint length,
bool mme_data, bool encrypted)__attribute__((weak));
@@ -67,11 +62,6 @@ interface_callback_init (interface_t *ctx, interface_mme_recv_cb_t mme_recv_cb,
interface_mme_buffer_add_cb_t buffer_add_cb, void *user_data){}
void
-interface_callback_beacon_init (interface_t *ctx,
- interface_beacon_add_cb_t beacon_add_cb,
- void *user_data){}
-
-void
interface_mme_recv (interface_t *ctx, uint tei, u8 *buffer, uint length,
bool mme_data, bool encrypted){}
diff --git a/cesar/station/src/station.c b/cesar/station/src/station.c
index 347408a381..b719879409 100644
--- a/cesar/station/src/station.c
+++ b/cesar/station/src/station.c
@@ -89,9 +89,7 @@ cesar_init (void)
bsu_init (cesar.bsu_aclf, &cesar.mac_config,
pbproc_get_phy (cesar.pbproc),
cesar.mac_store, pbproc_get_ca (cesar.pbproc), cesar.sar,
- cesar.hal_timer, (bsu_beacon_processed_t)interface_beacon_add,
- cesar.interface);
-
+ cesar.hal_timer);
/* Initialize the CE in RX. */
cesar.ce_rx = ce_rx_init (cesar.mac_store, cesar.sar, cesar.pbproc,
&cesar.mac_config);