summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaranjeiro2010-05-17 09:57:17 +0000
committerlaranjeiro2010-05-17 09:57:17 +0000
commit4a0f75368eb4ad5b3476b51c62ea6f29dbfee15a (patch)
tree99366ae1acad5267d9e2f1699a1e0d16fc0a0872
parent90ca77eda29003d926b9ce86421b259c5548b30c (diff)
cesar/bsu: add UCCo support
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7063 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--cesar/bsu/bsu.h11
-rw-r--r--cesar/bsu/inc/context.h2
-rw-r--r--cesar/bsu/src/bsu.c31
-rw-r--r--cesar/bsu/test/utest/src/bsut.c113
-rw-r--r--cesar/bsu/test/utest/src/tests.c7
5 files changed, 124 insertions, 40 deletions
diff --git a/cesar/bsu/bsu.h b/cesar/bsu/bsu.h
index 53ae8fdf63..6030048b41 100644
--- a/cesar/bsu/bsu.h
+++ b/cesar/bsu/bsu.h
@@ -27,6 +27,15 @@ typedef struct bsu_t bsu_t;
typedef struct bsu_avln_t bsu_avln_t;
typedef struct bsu_avln_ntb_t bsu_avln_ntb_t;
+enum bsu_update_sta_type_t
+{
+ BSU_UPDATE_STA_TYPE_STA,
+ BSU_UPDATE_STA_TYPE_UCCO,
+ BSU_UPDATE_STA_TYPE_CCO,
+ BSU_UPDATE_STA_TYPE_NB
+};
+typedef enum bsu_update_sta_type_t bsu_update_sta_type_t;
+
enum bsu_beacon_direction_t
{
BSU_BEACON_DIRECTION_TO_PLC,
@@ -94,7 +103,7 @@ bsu_uninit (bsu_t *ctx);
* \param sta true if the station acts as a STA.
*/
void
-bsu_update (bsu_beacon_t *beacon, bool sta);
+bsu_update (bsu_beacon_t *beacon, bsu_update_sta_type_t sta);
/**
* Update the tracking AVLN's identification.
diff --git a/cesar/bsu/inc/context.h b/cesar/bsu/inc/context.h
index 03583c6fae..8c11d49e43 100644
--- a/cesar/bsu/inc/context.h
+++ b/cesar/bsu/inc/context.h
@@ -76,7 +76,7 @@ struct bsu_t
/** CA schedule index. */
u8 ca_index;
/** Is station */
- bool is_sta;
+ bsu_update_sta_type_t is_sta;
/** Beacon data to use. */
bsu_beacon_t beacon;
/** HAL timer context. */
diff --git a/cesar/bsu/src/bsu.c b/cesar/bsu/src/bsu.c
index d0fb885f1f..18b45854d5 100644
--- a/cesar/bsu/src/bsu.c
+++ b/cesar/bsu/src/bsu.c
@@ -326,7 +326,7 @@ bsu_timer_event_process (void *ud)
{
u32 bpsd[BSU_BEACON_PERIOD_NB];
dbg_assert (ctx);
- if (ctx->is_sta)
+ if (ctx->is_sta == BSU_UPDATE_STA_TYPE_STA)
{
/* If it reached this point, the beacon has not been received. */
bsu_aclf_beacon_period_start_date (ctx->aclf, bpsd, COUNT (bpsd));
@@ -342,10 +342,26 @@ bsu_timer_event_process (void *ud)
if (less_mod2p32 (ctx->beacon.beacon_period_start_date, bpsd[0]))
/* Create and send the beacon. */
bsu_beacon_countdown (&ctx->beacon);
- beacon = bsu_beacon_write (&ctx->beacon, BSU_BEACON_TYPE_CENTRAL,
- ctx->mac_config, &params);
- /* Send the beacon. */
- bsu_beacon_send (ctx, BSU_BEACON_TYPE_CENTRAL, beacon, &params);
+ if (ctx->is_sta == BSU_UPDATE_STA_TYPE_CCO)
+ {
+ beacon = bsu_beacon_write (&ctx->beacon,
+ BSU_BEACON_TYPE_CENTRAL,
+ ctx->mac_config, &params);
+ /* Send the beacon. */
+ bsu_beacon_send (ctx, BSU_BEACON_TYPE_CENTRAL, beacon,
+ &params);
+ }
+ if (ctx->is_sta == BSU_UPDATE_STA_TYPE_UCCO
+ || (ctx->beacon.bmis.discover.present
+ && ctx->beacon.bmis.discover.tei == ctx->mac_config->tei))
+ {
+ beacon = bsu_beacon_write (&ctx->beacon,
+ BSU_BEACON_TYPE_DISCOVER,
+ ctx->mac_config, &params);
+ /* Send the beacon. */
+ bsu_beacon_send (ctx, BSU_BEACON_TYPE_DISCOVER, beacon,
+ &params);
+ }
}
bsu_ca_schedules (ctx, ctx->sta_avln);
/* Reprogram the timer. */
@@ -390,6 +406,7 @@ bsu_init (bsu_aclf_t *aclf, mac_config_t *mac_config, phy_t *phy,
hal_timer_instance_init (timer, &ctx->timer, ctx,
bsu_timer_event_process);
ctx->activate = false;
+ ctx->is_sta = BSU_UPDATE_STA_TYPE_STA;
return ctx;
}
@@ -492,13 +509,13 @@ bsu_update__persistent_schedules (bsu_t *ctx, bsu_beacon_t *beacon)
}
void
-bsu_update (bsu_beacon_t *beacon, bool is_sta)
+bsu_update (bsu_beacon_t *beacon, bsu_update_sta_type_t is_sta)
{
bsu_t *ctx = &bsu_global;
dbg_assert (ctx);
dbg_assert (beacon);
ctx->is_sta = is_sta;
- bsu_aclf_aclsc (ctx->aclf, !is_sta);
+ bsu_aclf_aclsc (ctx->aclf, is_sta != BSU_UPDATE_STA_TYPE_STA);
/* If persistent schedules are present and there is more than one. The
* second can only be present if the first one has its PSCD equal to 0.
* See specification section 5.1.2 Beacon Period Structure Figure 5-3. */
diff --git a/cesar/bsu/test/utest/src/bsut.c b/cesar/bsu/test/utest/src/bsut.c
index 89d1349c4e..197c027c9b 100644
--- a/cesar/bsu/test/utest/src/bsut.c
+++ b/cesar/bsu/test/utest/src/bsut.c
@@ -224,6 +224,67 @@ test_case_bsu_update (test_t test)
}
void
+test_case_bsu_timer_event_cco_ucco (test_t test, bsu_test_t *t,
+ bsu_update_sta_type_t type)
+{
+ test_within (test);
+ bsu_beacon_t beacon;
+ mfs_t *mfs;
+ uint i,j, lid = type == BSU_UPDATE_STA_TYPE_CCO ? MAC_LID_SPC_CENTRAL :
+ MAC_LID_DISCOVER;
+ bsu_avln_t cmp_avln;
+ bsu_test_init (t);
+ bsu_activate (true);
+ bsu_test_avln_create (t, &cmp_avln);
+ for (i = 0; i < BSU_ACLF_BPSD_NB; i++)
+ t->bsu->aclf->bpsd[i] = i * BSU_ACLF_BP_50HZ_TCK;
+ bsu_test_create_beacon (t, &beacon);
+ /* First case, update beacon in time. */
+ bsu_test_upper_layer_beacon_received_init (t);
+ beacon.beacon_period_start_date =
+ bsu_aclf_beacon_period_start_date_next (t->bsu->aclf);
+ bsu_update (&beacon, type);
+ bsu_timer_event_process (t->bsu);
+ test_fail_unless (t->ul.beacon != INVALID_PTR);
+ test_fail_unless (t->ul.bparams != INVALID_PTR);
+ test_fail_unless (t->ul.beacon->next == NULL);
+ /* 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,
+ lid, MAC_TEI_BCAST);
+ mfs->tx.head = NULL;
+ test_fail_unless (mfs != NULL);
+ blk_release (mfs);
+ /* Second case, beacon not updated. */
+ bsu_test_upper_layer_beacon_received_init (t);
+ t->bsu->beacon.beacon_period_start_date = t->bsu->aclf->bpsd[0] - 1;
+ for (i = 0; i < 7; i++)
+ {
+ 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.bparams != INVALID_PTR);
+ blk_release_desc ((blk_t*) t->ul.beacon);
+ for (j = 0; j < cmp_avln.bs.schedules.ps.nb; j++)
+ {
+ test_fail_unless (cmp_avln.bs.schedules.ps.ps[j].pscd
+ == t->bsu->beacon.bmis.ps.ps[j].pscd);
+ test_fail_unless (cmp_avln.bs.schedules.ps.ps[j].cscd
+ == t->bsu->beacon.bmis.ps.ps[j].cscd);
+ test_fail_unless (t->bsu->beacon.bmis.ps.nb ==
+ cmp_avln.bs.schedules.ps.nb);
+ }
+ }
+ mfs = mac_store_mfs_get (t->mac_store, true, true, false,
+ lid, MAC_TEI_BCAST);
+ test_fail_unless (mfs != NULL);
+ /* Release MFS. */
+ mac_store_mfs_remove (t->mac_store, mfs);
+ blk_release (mfs);
+ bsu_test_uninit (t);
+}
+
+void
test_case_bsu_timer_event (test_t test)
{
test_case_begin (test, "Timer event called");
@@ -238,7 +299,6 @@ test_case_bsu_timer_event (test_t test)
bsu_test_avln_create (&t, &cmp_avln);
for (i = 0; i < BSU_ACLF_BPSD_NB; i++)
t.bsu->aclf->bpsd[i] = i * BSU_ACLF_BP_50HZ_TCK;
- t.bsu->is_sta = true;
for (j = 0; j < 10; j++)
{
bsu_timer_event_process (t.bsu);
@@ -260,9 +320,11 @@ test_case_bsu_timer_event (test_t test)
test_begin (test, "CCo")
{
bsu_test_t t;
+ test_case_bsu_timer_event_cco_ucco (test, &t,
+ BSU_UPDATE_STA_TYPE_CCO);
bsu_beacon_t beacon;
mfs_t *mfs;
- uint i,j;
+ uint i;
bsu_avln_t cmp_avln;
bsu_test_init (&t);
bsu_activate (true);
@@ -270,50 +332,41 @@ test_case_bsu_timer_event (test_t test)
for (i = 0; i < BSU_ACLF_BPSD_NB; i++)
t.bsu->aclf->bpsd[i] = i * BSU_ACLF_BP_50HZ_TCK;
bsu_test_create_beacon (&t, &beacon);
+ beacon.bmis.discover.tei = t.mac_config.tei;
/* First case, update beacon in time. */
bsu_test_upper_layer_beacon_received_init (&t);
beacon.beacon_period_start_date =
bsu_aclf_beacon_period_start_date_next (t.bsu->aclf);
- bsu_update (&beacon, false /* CCo */);
+ bsu_update (&beacon, BSU_UPDATE_STA_TYPE_CCO);
bsu_timer_event_process (t.bsu);
- test_fail_unless (t.ul.beacon != INVALID_PTR);
- test_fail_unless (t.ul.bparams != INVALID_PTR);
- /* Release the reference handled by the CP. */
+ test_fail_unless (t.ul.beacon);
+ test_fail_unless (t.ul.beacon->next);
+ blk_release_desc ((blk_t*) t.ul.beacon->next);
blk_release_desc ((blk_t*) t.ul.beacon);
mfs = mac_store_mfs_get (t.mac_store, true, true, false,
MAC_LID_SPC_CENTRAL, MAC_TEI_BCAST);
- mfs->tx.head = NULL;
test_fail_unless (mfs != NULL);
+ mfs->tx.head = NULL;
blk_release (mfs);
- /* Second case, beacon not updated. */
- bsu_test_upper_layer_beacon_received_init (&t);
- t.bsu->beacon.beacon_period_start_date = t.bsu->aclf->bpsd[0] - 1;
- for (i = 0; i < 7; i++)
- {
- 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.bparams != INVALID_PTR);
- blk_release_desc ((blk_t*) t.ul.beacon);
- for (j = 0; j < cmp_avln.bs.schedules.ps.nb; j++)
- {
- test_fail_unless (cmp_avln.bs.schedules.ps.ps[j].pscd
- == t.bsu->beacon.bmis.ps.ps[j].pscd);
- test_fail_unless (cmp_avln.bs.schedules.ps.ps[j].cscd
- == t.bsu->beacon.bmis.ps.ps[j].cscd);
- test_fail_unless (t.bsu->beacon.bmis.ps.nb ==
- cmp_avln.bs.schedules.ps.nb);
- }
- }
+ /* Release MFS. */
+ mac_store_mfs_remove (t.mac_store, mfs);
mfs = mac_store_mfs_get (t.mac_store, true, true, false,
- MAC_LID_SPC_CENTRAL, MAC_TEI_BCAST);
+ MAC_LID_DISCOVER, MAC_TEI_BCAST);
test_fail_unless (mfs != NULL);
+ mfs->tx.head = NULL;
+ blk_release (mfs);
/* Release MFS. */
mac_store_mfs_remove (t.mac_store, mfs);
- blk_release (mfs);
bsu_test_uninit (&t);
}
test_end;
+ test_begin (test, "UCCo")
+ {
+ bsu_test_t t;
+ test_case_bsu_timer_event_cco_ucco (test, &t,
+ BSU_UPDATE_STA_TYPE_UCCO);
+ }
+ test_end;
}
void
@@ -351,7 +404,7 @@ test_case_bsu_power_on (test_t test)
{
bsu_beacon_t beacon;
bsu_test_create_beacon (&t, &beacon);
- bsu_update (&beacon, true);
+ bsu_update (&beacon, BSU_UPDATE_STA_TYPE_STA);
bsu_power_on (0xa);
test_fail_unless (t.bsu->sta_avln == &t.bsu->poweron);
uint i;
diff --git a/cesar/bsu/test/utest/src/tests.c b/cesar/bsu/test/utest/src/tests.c
index d9ba191f26..ca9c403913 100644
--- a/cesar/bsu/test/utest/src/tests.c
+++ b/cesar/bsu/test/utest/src/tests.c
@@ -24,7 +24,11 @@ bsu_test_upper_layer_beacon_received (void *ctx, pb_beacon_t *beacon,
{
bsu_test_t *test = (bsu_test_t*) ctx;
dbg_assert (ctx);
- test->ul.beacon = beacon;
+ beacon->next = NULL;
+ if (test->ul.beacon == INVALID_PTR)
+ test->ul.beacon = beacon;
+ else
+ test->ul.beacon->next = beacon;
test->ul.bparams = bparams;
}
@@ -52,6 +56,7 @@ bsu_test_init (bsu_test_t *ctx)
ctx);
/* Warn just for the test. */
ctx->bsu->sta_avln = &ctx->bsu->avlns[0];
+ bsu_test_upper_layer_beacon_received_init (ctx);
}
void