summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNélio Laranjeiro2012-11-13 15:42:42 +0100
committerNélio Laranjeiro2012-12-12 14:20:51 +0100
commita858e5a442d6b92b419398543e82e41edfb57cea (patch)
tree485072e0a14545de665edf0c7f89858a5dd5f150
parent0081943c805fbb963f226333cfb1371f21d0d436 (diff)
cesar/bsu: modify special patch for atheros in csma only mode, closes #3503
-rw-r--r--cesar/bsu/src/bsu.c28
-rw-r--r--cesar/bsu/test/utest/src/schedules.c98
2 files changed, 54 insertions, 72 deletions
diff --git a/cesar/bsu/src/bsu.c b/cesar/bsu/src/bsu.c
index 9b2f3610bd..2b98eadd85 100644
--- a/cesar/bsu/src/bsu.c
+++ b/cesar/bsu/src/bsu.c
@@ -515,22 +515,20 @@ bsu_ca_schedules_settings (bsu_t *ctx, bsu_avln_t *avln,
inline void
bsu_ca_schedules_nm_csma_only (bsu_t *ctx, bsu_beacon_t *beacon)
{
- if (beacon->vf.nm == MAC_NM_CSMA_ONLY)
+ if (beacon->vf.nm == MAC_NM_CSMA_ONLY
+ && (beacon->bmis.ps.nb == 0
+ || (beacon->bmis.ps.nb == 1
+ && beacon->bmis.ps.ps[0].cscd == 0
+ && beacon->bmis.ps.ps[0].pscd == 0)))
{
- if (beacon->bmis.ps.nb == 0
- || !(beacon->bmis.ps.nb == 1
- && BSU_BEACON_PERSISTENT_ALLOC_IS_PERMANENT(
- beacon->bmis.ps.ps[0])))
- {
- beacon->bmis.nps.ns = 0;
- beacon->bmis.ps.nb = 1;
- beacon->bmis.ps.ps[0].ns = 1;
- beacon->bmis.ps.ps[0].pscd = 0;
- beacon->bmis.ps.ps[0].cscd =
- BSU_BEACON_PERSISTENT_SCHEDULES_PERMANENT_COUNTDOWN;
- beacon->bmis.ps.ps[0].sais[0].stpf = false;
- beacon->bmis.ps.ps[0].sais[0].glid = MAC_LID_SHARED_CSMA & 0x7f;
- }
+ beacon->bmis.nps.ns = 0;
+ beacon->bmis.ps.nb = 1;
+ beacon->bmis.ps.ps[0].ns = 1;
+ beacon->bmis.ps.ps[0].pscd = 0;
+ beacon->bmis.ps.ps[0].cscd =
+ BSU_BEACON_PERSISTENT_SCHEDULES_PERMANENT_COUNTDOWN;
+ beacon->bmis.ps.ps[0].sais[0].stpf = false;
+ beacon->bmis.ps.ps[0].sais[0].glid = MAC_LID_SHARED_CSMA & 0x7f;
}
}
diff --git a/cesar/bsu/test/utest/src/schedules.c b/cesar/bsu/test/utest/src/schedules.c
index 73f20b0061..6b9a64bb69 100644
--- a/cesar/bsu/test/utest/src/schedules.c
+++ b/cesar/bsu/test/utest/src/schedules.c
@@ -39,6 +39,9 @@ bsu_beacon_process__avln_tracked (bsu_t *ctx, bsu_beacon_t *beacon,
pbproc_rx_beacon_params_t *params);
void
+bsu_ca_schedules_nm_csma_only (bsu_t *ctx, bsu_beacon_t *beacon);
+
+void
test_case_ca_schedules (test_t test)
{
bsu_test_t t;
@@ -150,68 +153,49 @@ void
test_case_ca_schedules_intellon (test_t test)
{
test_case_begin (test, "Intellon central beacons");
- test_begin (
- test, "Persistent schedule valid for the current beacon period")
+ test_begin (test, "Test all kind of persistent schedule")
{
+ uint cscd = 0;
bsu_test_t t;
bsu_test_init (&t);
bsu_beacon_t beacon;
- bsu_beacon_t *bprocessed;
- pb_beacon_t *pbbeacon;
bsu_test_create_beacon (&t, &beacon);
- beacon.bmis.nps.ns = 0;
- beacon.bmis.ps.nb = 1;
- beacon.bmis.ps.ps[0].ns = 1;
- beacon.bmis.ps.ps[0].pscd = 0;
- beacon.bmis.ps.ps[0].cscd = 0;
- beacon.bmis.ps.ps[0].sais[0].stpf = true;
- beacon.bmis.ps.ps[0].sais[0].start_time_atu = 52;
- beacon.bmis.ps.ps[0].sais[0].end_time_atu = 3907;
- beacon.bmis.ps.ps[0].sais[0].glid = MAC_LID_SHARED_CSMA & 0x7f;
- uint i;
- for (i = 0; i < COUNT (t.bsu->aclf->bpsd); i++)
- t.bsu->aclf->bpsd[i] = i * BSU_ACLF_BP_50HZ_TCK - 10;
- t.bsu->aclf->bpsd[i] = i * BSU_ACLF_BP_50HZ_TCK;
- t.bsu->aclf->beacon_period_tck = BSU_ACLF_BP_50HZ_TCK;
- *((uint*) &t.bsu->aclf->beacon_period_theo_tck) =
- BSU_ACLF_BP_50HZ_TCK;
- pbproc_tx_beacon_params_t btx;
- pbproc_rx_beacon_params_t brx;
- memset (&brx, 0, sizeof (pbproc_rx_beacon_params_t));
- pbbeacon = bsu_beacon_write (
- &beacon, BSU_BEACON_TYPE_CENTRAL, &t.mac_config, &btx);
- pbbeacon->phy_pb.pb_rx.pb_measurement.crc_error = false;
- /* The first time bsu receives a beacon of an AVLN. */
- brx.bts = BSU_ACLF_BP_50HZ_TCK / 2;
- bprocessed = bsu_beacon_process (t.bsu, pbbeacon, &brx);
- blk_release (bprocessed);
- /* Control plane request to track this AVLN. */
- bsu_track_avln (t.bsu, beacon.vf.nid, brx.snid, 0,
- beacon.bmis.mac_address.mac_address);
- t.bsu->track_new = false;
- t.bsu->is_sta = BSU_UPDATE_STA_TYPE_STA;
- /* BSU receives the next beacon. */
- bprocessed = bsu_beacon_process (t.bsu, pbbeacon, &brx);
- /* Schedules which should be present. */
- test_fail_unless (bprocessed);
- test_fail_unless (t.bsu->sta_avln->beacon.bmis.ps.nb == 1);
- test_fail_unless (t.bsu->sta_avln->beacon.bmis.ps.ps[0].pscd == 0);
- test_fail_unless (t.bsu->sta_avln->beacon.bmis.ps.ps[0].cscd == 7);
- test_fail_unless (
- t.bsu->sta_avln->beacon.bmis.ps.ps[0].sais[0].glid ==
- (MAC_LID_SHARED_CSMA & 0x7f));
- test_fail_unless (
- t.bsu->sta_avln->beacon.bmis.ps.ps[0].sais[0].end_time_atu ==
- 3907);
- test_fail_unless (
- t.bsu->sta_avln->beacon.bmis.ps.ps[0].sais[0].stpf == false);
- u32 bpsd[4];
- bsu_aclf_beacon_period_start_date (t.bsu->aclf, bpsd, COUNT (bpsd));
- for (i = 1; i < COUNT (bpsd); i++)
- test_fail_unless (brx.bts + i * BSU_ACLF_BP_50HZ_TCK == bpsd[i] +
- t.bsu->sta_avln->sync.ntb_offset_tck);
- blk_release_desc ((blk_t*) pbbeacon);
- blk_release (bprocessed);
+ for (cscd = 0; cscd <= 7; cscd++)
+ {
+ beacon.bmis.nps.ns = 0;
+ beacon.bmis.ps.nb = 1;
+ beacon.bmis.ps.ps[0].ns = 1;
+ beacon.bmis.ps.ps[0].pscd = 0;
+ beacon.bmis.ps.ps[0].sais[0].stpf = true;
+ beacon.bmis.ps.ps[0].sais[0].start_time_atu = 52;
+ beacon.bmis.ps.ps[0].sais[0].end_time_atu = 3907;
+ beacon.bmis.ps.ps[0].sais[0].glid = MAC_LID_SHARED_CSMA & 0x7f;
+ beacon.bmis.ps.ps[0].cscd = cscd;
+ bsu_ca_schedules_nm_csma_only (t.bsu, &beacon);
+ /* verify */
+ test_fail_unless (beacon.bmis.nps.ns == 0);
+ test_fail_unless (beacon.bmis.ps.nb == 1);
+ test_fail_unless (beacon.bmis.ps.ps[0].ns == 1);
+ test_fail_unless (beacon.bmis.ps.ps[0].pscd == 0);
+ test_fail_unless (beacon.bmis.ps.ps[0].sais[0].glid ==
+ (MAC_LID_SHARED_CSMA & 0x7f));
+ test_fail_unless (
+ beacon.bmis.ps.ps[0].sais[0].end_time_atu == 3907);
+ if (!cscd)
+ {
+ test_fail_unless (beacon.bmis.ps.ps[0].cscd ==
+ BSU_BEACON_PERSISTENT_SCHEDULES_PERMANENT_COUNTDOWN);
+ test_fail_unless (beacon.bmis.ps.ps[0].sais[0].stpf == false);
+ test_fail_unless (beacon.bmis.ps.ps[0].cscd == 7);
+ }
+ else
+ {
+ test_fail_unless (beacon.bmis.ps.ps[0].sais[0].stpf == true);
+ test_fail_unless (
+ beacon.bmis.ps.ps[0].sais[0].start_time_atu == 52);
+ test_fail_unless (beacon.bmis.ps.ps[0].cscd == cscd);
+ }
+ }
bsu_test_uninit (&t);
}
test_end;