From d69425fccc2c4e4c978b8f5c0acd347d002d6cf7 Mon Sep 17 00:00:00 2001 From: Jérémy Dufour Date: Mon, 31 Jan 2011 16:35:35 +0100 Subject: cesar/ce/rx: remove call to cp_sta_mgr from CE context, closes #1425 This commit includes: - adding a new function to send a request to the CP to send a MME to make the CE restarts. --- cesar/ce/rx/cp/inc/cp.h | 8 ++++++++ cesar/ce/rx/cp/mbox.h | 9 +++++++++ cesar/ce/rx/cp/mme.h | 9 --------- cesar/ce/rx/cp/src/cp.c | 24 ++++++++++++++++++++++++ cesar/ce/rx/cp/src/mbox.c | 11 +++++++++++ cesar/ce/rx/cp/src/mme.c | 9 --------- cesar/ce/rx/cp/stub/src/cp.c | 4 ++-- cesar/ce/rx/cp/test/src/test_mbox.c | 34 ++++++++++++++++++++++++++++++++++ cesar/ce/rx/cp/test/src/test_mme.c | 13 ------------- 9 files changed, 88 insertions(+), 33 deletions(-) (limited to 'cesar/ce/rx/cp') diff --git a/cesar/ce/rx/cp/inc/cp.h b/cesar/ce/rx/cp/inc/cp.h index 9a0aeee7ca..267f05fafa 100644 --- a/cesar/ce/rx/cp/inc/cp.h +++ b/cesar/ce/rx/cp/inc/cp.h @@ -125,6 +125,14 @@ ce_rx_cp_send_mme_new_tone_map (ce_rx_t *ce_rx, sta_t *peer, u8 new_tmi, void ce_rx_cp_send_mme_refresh_tmi_list (ce_rx_t *ce_rx, sta_t *peer); +/** + * Send a MME to restart initial CE. + * \param ce_rx the CE RX context. + * \param peer the destination of the MME. + */ +void +ce_rx_cp_send_mme_restart_initial_ce (ce_rx_t *ce_rx, sta_t *peer); + END_DECLS #endif /* ce_rx_cp_inc_cp_h */ diff --git a/cesar/ce/rx/cp/mbox.h b/cesar/ce/rx/cp/mbox.h index 18a8ddbf57..bb949efd0f 100644 --- a/cesar/ce/rx/cp/mbox.h +++ b/cesar/ce/rx/cp/mbox.h @@ -46,4 +46,13 @@ ce_rx_cp_mbox_t * ce_rx_cp_mbox_node_refresh_tmi (ce_rx_t *ce_rx, cp_tei_t tei, tonemaps_t *tms); +/** + * Allocate a message to send CE restart. + * \param ce_rx the context of the CE in RX. + * \param tei the TEI of the peer STA. + * \param tms the RX tome maps. + */ +ce_rx_cp_mbox_t * +ce_rx_cp_mbox_node_restart_ce (ce_rx_t *ce_rx, cp_tei_t tei, tonemaps_t *tms); + #endif /* ce_rx_cp_mbox_h */ diff --git a/cesar/ce/rx/cp/mme.h b/cesar/ce/rx/cp/mme.h index bf244679b3..ec581b70db 100644 --- a/cesar/ce/rx/cp/mme.h +++ b/cesar/ce/rx/cp/mme.h @@ -70,15 +70,6 @@ ce_rx_mme_refresh_tone_map_list (cp_t *ctx, cp_sta_t *sta, u32 tmi_list, u8 default_tmi, tonemap_intervals_t *int_list, tonemaps_t *tms); -/** - * Send a CM_TM_UPDATE.IND to restart initial CE. - * \param ctx the Control Plane context. - * \param sta the destination of the MME. - * \param tms the tone maps structure (in RX). - */ -void -ce_rx_mme_restart_initial_ce (cp_t *ctx, cp_sta_t *sta, tonemaps_t *tms); - END_DECLS #endif /* ce_rx_cp_mme_h */ diff --git a/cesar/ce/rx/cp/src/cp.c b/cesar/ce/rx/cp/src/cp.c index 0adabdadcf..bdf09718ce 100644 --- a/cesar/ce/rx/cp/src/cp.c +++ b/cesar/ce/rx/cp/src/cp.c @@ -111,6 +111,30 @@ ce_rx_cp_send_mme_refresh_tmi_list (ce_rx_t *ce_rx, sta_t *peer) } } +void +ce_rx_cp_send_mme_restart_initial_ce (ce_rx_t *ce_rx, sta_t *peer) +{ + /* Check parameters. */ + dbg_assert (peer); + dbg_assert (ce_rx); + dbg_assert (ce_rx->cp_cb); + /* Sanity check: there should be no tone map enabled. */ + dbg_assert (tonemaps_allocated_count (peer->rx_tonemaps) == 0); + + CE_RX_TRACE (SEND_RESTART_CE, peer->tei); + + /* Create a new work. */ + ce_rx_cp_mbox_t *work = + ce_rx_cp_mbox_node_restart_ce (ce_rx, peer->tei, peer->rx_tonemaps); + /* 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); + + /* Disable expiration timer. */ + peer->rx_tonemaps->refresh_counter_s = 0; +} + void ce_rx_cp_run_work (cp_t *ctx) { diff --git a/cesar/ce/rx/cp/src/mbox.c b/cesar/ce/rx/cp/src/mbox.c index 225e9f6905..15ef3b00a9 100644 --- a/cesar/ce/rx/cp/src/mbox.c +++ b/cesar/ce/rx/cp/src/mbox.c @@ -77,3 +77,14 @@ ce_rx_cp_mbox_node_refresh_tmi (ce_rx_t *ce_rx, cp_tei_t tei, tonemaps_t *tms) return ce_rx_cp_mbox_new_node (ce_rx, tei, tms->default_tmi, tmi_list, tms->intervals, 0, 0, false); } + +ce_rx_cp_mbox_t * +ce_rx_cp_mbox_node_restart_ce (ce_rx_t *ce_rx, cp_tei_t tei, tonemaps_t *tms) +{ + /* Check parameters. */ + dbg_assert (tms); + + /* Return allocated node. */ + return ce_rx_cp_mbox_new_node (ce_rx, tei, 0, 0, tms->intervals, 0, 0, + false); +} diff --git a/cesar/ce/rx/cp/src/mme.c b/cesar/ce/rx/cp/src/mme.c index 98157a9d69..6395eef34b 100644 --- a/cesar/ce/rx/cp/src/mme.c +++ b/cesar/ce/rx/cp/src/mme.c @@ -523,12 +523,3 @@ ce_rx_mme_refresh_tone_map_list (cp_t *ctx, cp_sta_t *sta, u32 tmi_list, u8 else tms->refresh_counter_s = 0; } - -void -ce_rx_mme_restart_initial_ce (cp_t *ctx, cp_sta_t *sta, tonemaps_t *tms) -{ - ce_rx_mme_send_cm_tm_update_ind (ctx, sta, tms, 0, 0, 0, 0, - tms->intervals); - /* Disable expiration timer. */ - tms->refresh_counter_s = 0; -} diff --git a/cesar/ce/rx/cp/stub/src/cp.c b/cesar/ce/rx/cp/stub/src/cp.c index 8ef1ea4100..d621e40725 100644 --- a/cesar/ce/rx/cp/stub/src/cp.c +++ b/cesar/ce/rx/cp/stub/src/cp.c @@ -46,10 +46,10 @@ ce_rx_cp_send_mme_new_tone_map (ce_rx_t *ce_rx, sta_t *peer, u8 new_tmi, } void -ce_rx_mme_restart_initial_ce (cp_t *ctx, cp_sta_t *sta, tonemaps_t *tms) +ce_rx_cp_send_mme_restart_initial_ce (ce_rx_t *ctx, sta_t *sta) __attribute__ ((weak)); void -ce_rx_mme_restart_initial_ce (cp_t *ctx, cp_sta_t *sta, tonemaps_t *tms) +ce_rx_cp_send_mme_restart_initial_ce (ce_rx_t *ctx, sta_t *sta) { } diff --git a/cesar/ce/rx/cp/test/src/test_mbox.c b/cesar/ce/rx/cp/test/src/test_mbox.c index 1b57117838..0e7efb12dc 100644 --- a/cesar/ce/rx/cp/test/src/test_mbox.c +++ b/cesar/ce/rx/cp/test/src/test_mbox.c @@ -19,6 +19,11 @@ #include "lib/test.h" +static void +stub_cp_signal_work_cb (cp_t *ctx) +{ +} + /** * Test mailbox node allocation. */ @@ -237,6 +242,33 @@ test_suite_mbox_node (test_t t) ce_rx_cp_uninit (&ce_rx); } +/** + * Test mailbox. + */ +static void +test_suite_mbox (test_t t) +{ + test_suite_begin (t, "mailbox"); + + ce_rx_t ce_rx; + ce_rx_cp_init (&ce_rx); + ce_rx_cp_set_cp_signal_work_callback (&ce_rx, stub_cp_signal_work_cb, + INVALID_PTR); + + /* Create a station. */ + sta_t peer; + peer.rx_tonemaps = tonemaps_alloc (); + + test_begin (t, "request to send a ce restart") + { + ce_rx_cp_send_mme_restart_initial_ce (&ce_rx, &peer); + } test_end; + + /* Clean. */ + tonemaps_release (peer.rx_tonemaps); + ce_rx_cp_uninit (&ce_rx); +} + int main (int argc, char **argv) { @@ -245,6 +277,8 @@ main (int argc, char **argv) test_suite_mbox_node (t); + test_suite_mbox (t); + test_begin (t, "memory") { test_fail_unless (blk_check_memory ()); diff --git a/cesar/ce/rx/cp/test/src/test_mme.c b/cesar/ce/rx/cp/test/src/test_mme.c index 11cba0a688..de09b17eea 100644 --- a/cesar/ce/rx/cp/test/src/test_mme.c +++ b/cesar/ce/rx/cp/test/src/test_mme.c @@ -492,19 +492,6 @@ mme_test_suite (test_t t) /* Clean. */ tms->tm[default_tmi] = 0; } test_end; - test_begin (t, "CM_TM_UPDATE.IND: restart initial CE") - { - tms->refresh_counter_s = CE_RX_REFRESH_TONE_MAP_S; - cp.vect_size = mme_test_generate_cm_tm_update_ind (&cp, tms, 0, 0, - NULL, 0); - mme_test_generate_end_cm_chan_est_ind (&cp); - /* No interval. */ - tonemap_intervals_t int_list; - int_list.intervals_nb = 0; - ce_rx_mme_restart_initial_ce (&cp, &sta, tms); - /* No need to refresh when there is an empty TMI list. */ - test_fail_if (tms->refresh_counter_s != 0); - } test_end; /* Clean. */ tonemap_free (tm); -- cgit v1.2.3