summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorAleksandar Cecaric2011-10-18 10:09:43 +0200
committerAleksandar Cecaric2011-10-18 10:09:43 +0200
commit652fe7afa35ee9dcdcf59090b0d6ee7472ff39e5 (patch)
tree8210a3e9216c858681f3b5910a60c42ab2b57d43 /cesar
parent572d57302cb0163ffa7a185a02588a72fbc56636 (diff)
parenta6bea4a24e98365390e1a5e6b1e8ebc98b1a20f4 (diff)
Merge commit 'av-1.1.11' into eoc
Conflicts: cesar/bsu/inc/context.h cesar/bsu/ntb/ntb.h cesar/bsu/ntb/src/ntb.c cesar/bsu/ntb/test/utest/src/ntb_compute.c cesar/bsu/src/bsu.c cesar/cp/sta/mgr/test/src/sta_mgr.c cesar/hal/phy/src/phy.c cesar/mac/pbproc/src/fsm_rx_sound.c cesar/mac/pbproc/src/fsm_tx_sound.c cesar/mac/pbproc/src/prep_mpdu.c cesar/mac/pbproc/test/int/sparc-Config cesar/station/src/station.c cleopatre/devkit/plcdrv/arm/inc/linux_drv.h cleopatre/linux-2.6.25.10-spc300/drivers/net/arm/synop3504.c
Diffstat (limited to 'cesar')
-rw-r--r--cesar/bsu/inc/context.h4
-rw-r--r--cesar/bsu/ntb/ntb.h11
-rw-r--r--cesar/bsu/ntb/ntb_sync.h8
-rw-r--r--cesar/bsu/ntb/src/ntb.c32
-rw-r--r--cesar/bsu/ntb/test/utest/src/ntb_compute.c32
-rw-r--r--cesar/bsu/src/bsu.c26
-rw-r--r--cesar/bsu/test/utest/src/bsut.c96
-rw-r--r--cesar/ce/rx/bitloading/inc/ber.h6
-rw-r--r--cesar/ce/rx/bitloading/inc/poly.h2
-rw-r--r--cesar/ce/rx/bitloading/nsr.h24
-rw-r--r--cesar/ce/rx/bitloading/src/nsr.c3
-rw-r--r--cesar/ce/rx/bitloading/test/src/test_bl.c3
-rw-r--r--cesar/ce/rx/test/src/test_rx.c1
-rw-r--r--cesar/cl/inc/context.h4
-rw-r--r--cesar/cl/inc/trace.h1
-rw-r--r--cesar/cl/src/bridge_table.c14
-rw-r--r--cesar/cl/src/cl.c27
-rw-r--r--cesar/cl/src/trace.c2
-rw-r--r--cesar/common/make/config.mk4
-rw-r--r--cesar/common/tests/tests19
-rw-r--r--cesar/cp/beacon/test/src/beacon.c987
-rw-r--r--cesar/cp/cco/action/test/src/action_gen_nek.c22
-rw-r--r--cesar/cp/secu/test/sparc-Makefile6
-rw-r--r--cesar/cp/src/cp.c6
-rw-r--r--cesar/cp/sta/action/src/vs.c5
-rw-r--r--cesar/cp/sta/action/test/utest/src/vs.c2
-rw-r--r--cesar/cp/sta/mgr/test/src/sta_mgr.c2
-rw-r--r--cesar/cp/test/mme/Makefile2
-rw-r--r--cesar/hal/arch/Config1
-rw-r--r--cesar/hal/arch/arch.h10
-rw-r--r--cesar/hal/arch/inc/sparc.h26
-rw-r--r--cesar/hal/phy/Module2
-rw-r--r--cesar/hal/phy/inc/context.h4
-rw-r--r--cesar/hal/phy/maximus/src/maximus_phy_ctrl.c8
-rw-r--r--cesar/hal/phy/maximus/test/src/test_phy_ctrl.c4
-rw-r--r--cesar/hal/phy/src/phy.c8
-rw-r--r--cesar/hle/inc/context.h6
-rw-r--r--cesar/hle/inc/trace.h4
-rw-r--r--cesar/hle/src/hle.c53
-rw-r--r--cesar/hle/src/trace.c4
-rw-r--r--cesar/lib/Config2
-rw-r--r--cesar/lib/Module5
-rw-r--r--cesar/lib/seq_check.h170
-rw-r--r--cesar/lib/src/seq_check.c154
-rw-r--r--cesar/lib/src/utils.c42
-rw-r--r--cesar/lib/test/fixed/src/test_fixed.c12
-rw-r--r--cesar/lib/test/heap/src/test_heap.c2
-rw-r--r--cesar/lib/test/mbox/src/mbox.c2
-rw-r--r--cesar/lib/test/seq_check/Config2
-rw-r--r--cesar/lib/test/seq_check/Makefile8
-rw-r--r--cesar/lib/test/seq_check/src/seq_check.c250
-rw-r--r--cesar/lib/test/utils/src/test_utils.c50
-rw-r--r--cesar/lib/utils.h12
-rw-r--r--cesar/mac/design/test/mfs_tx2/src/test_mfs.c7
-rw-r--r--cesar/mac/pbproc/src/fsm_rx_sound.c6
-rw-r--r--cesar/mac/pbproc/src/fsm_tx_sound.c6
-rw-r--r--cesar/mac/pbproc/src/prep_mpdu.c2
-rw-r--r--cesar/mac/pbproc/test/int/sparc-Config1
-rw-r--r--cesar/mac/sar/inc/sar_context.h4
-rw-r--r--cesar/mac/sar/inc/trace.h1
-rw-r--r--cesar/mac/sar/src/sar.c28
-rw-r--r--cesar/mac/sar/src/trace.c2
-rw-r--r--cesar/maximus/channel/src/ChannelComputerTest.cpp38
-rw-r--r--cesar/maximus/coreengine/src/Maximus.cpp1
-rw-r--r--cesar/maximus/ethernet/src/EthernetProcessor.cpp6
-rw-r--r--cesar/maximus/prototest/fcall/src/test_fcall.c11
-rw-r--r--cesar/maximus/python/maximus/ethernet/scapy.py1
-rw-r--r--cesar/maximus/python/maximus/station/sta.py94
-rw-r--r--cesar/maximus/python/src/interface_module.cpp2
-rw-r--r--cesar/maximus/python/test/test_lib_cesar.py5
-rw-r--r--cesar/maximus/python/tools/csi/csicore.py4
-rw-r--r--cesar/maximus/stationtest/src/test_send.c7
-rw-r--r--cesar/maximus/stationtest/src/test_tx_rx.c7
-rw-r--r--cesar/projects/plc/Config.traces10
-rw-r--r--cesar/station/src/station.c4
-rw-r--r--cesar/test_general/maximus/integration/interface-dp/src/station.c7
-rw-r--r--cesar/test_general/maximus/integration/sar-pbproc/src/station.c8
-rw-r--r--cesar/test_general/station/cco0/s1/py/sc12_five_stations.py2
-rw-r--r--cesar/test_general/station/cco0/s1/py/sc13_10stations.py2
-rw-r--r--cesar/test_general/station/cco0/s1/py/sc9_cco_leaving.py4
-rw-r--r--cesar/test_general/station/maximus/Makefile2
-rw-r--r--cesar/test_general/station/maximus/py/sc01_long_simu.py2
-rw-r--r--cesar/test_general/station/maximus/py/sc02_long_simu_data.py2
-rw-r--r--cesar/test_general/station/tonemap/py/sc01_bl_initial.py9
-rw-r--r--cesar/test_general/station/tonemap/py/sc02_vs_get_tonemap.py11
85 files changed, 1621 insertions, 867 deletions
diff --git a/cesar/bsu/inc/context.h b/cesar/bsu/inc/context.h
index 4447509c7d..ec25ae908a 100644
--- a/cesar/bsu/inc/context.h
+++ b/cesar/bsu/inc/context.h
@@ -121,7 +121,9 @@ struct bsu_t
/** Station's discover info updated by CP. */
bsu_beacon_bmi_discover_info_t discover_info;
/** NTB clock synchronization weight configuration. k is for 1/2^k. */
- uint bsu_ntb_clk_sync_weight_k;
+ uint ntb_clk_sync_weight_k;
+ /** Number of NTB clock synchronizations for stable error measure. */
+ uint ntb_clk_sync_nb_stable;
#if CONFIG_TRACE
/** Trace system. */
trace_buffer_t trace;
diff --git a/cesar/bsu/ntb/ntb.h b/cesar/bsu/ntb/ntb.h
index ce01f409da..b18c487126 100644
--- a/cesar/bsu/ntb/ntb.h
+++ b/cesar/bsu/ntb/ntb.h
@@ -16,22 +16,23 @@
#include "mac/common/config.h"
#include "hal/phy/phy.h"
-#define BSU_NTB_CLK_SYNC_WEIGHT_K_DEFAULT 2
+#define BSU_NTB_CLK_SYNC_WEIGHT_K_DEFAULT 6
+
+#define BSU_NTB_CLK_SYNC_NB_STABLE_DEFAULT 64
BEGIN_DECLS
-/*
+/**
* Synchronize local clock to be as close as possible to estimated value
* of the NTB clock reference.
* \param ctx the module context data.
- * \param phy the phy context.
* \param beacon_bts beacon time stamp
* \param beacon_sta_ltmr STA local time captured when receiving beacon
* \param weight_k the coefficient weight to use to smooth the NTB clock
*/
void
-bsu_ntb_clk_sync (bsu_ntb_sync_t * ctx, phy_t *phy, u32 beacon_bts,
- u32 beacon_sys_ltmr, u32 beacon_sta_ltmr, uint weight_k);
+bsu_ntb_clk_sync (bsu_ntb_sync_t * ctx, u32 beacon_bts, u32 beacon_sys_ltmr,
+ u32 beacon_sta_ltmr, uint weight_k);
/**
* Configure the clock frequency.
diff --git a/cesar/bsu/ntb/ntb_sync.h b/cesar/bsu/ntb/ntb_sync.h
index e515ab3897..4eafa76268 100644
--- a/cesar/bsu/ntb/ntb_sync.h
+++ b/cesar/bsu/ntb/ntb_sync.h
@@ -20,10 +20,8 @@ struct bsu_ntb_sync_t
{
/** Initialised ? */
bool init;
- /** First time it computes the Frequency error. This bool is useful
- * because the first computation of the frequency error is not equal to
- * the others. */
- bool second_shoot;
+ /** Number of clock synchronisations, will saturate at UINT_MAX. */
+ uint sync_nb;
/** Frequency error. */
double fe;
/** beacon time stamp. */
@@ -36,8 +34,6 @@ struct bsu_ntb_sync_t
u32 sta_numerator;
/** NTB clock tick offset. */
u32 ntb_offset_tck;
- /** Delay before processing the beacon. */
- u32 delay_systck;
};
typedef struct bsu_ntb_sync_t bsu_ntb_sync_t;
diff --git a/cesar/bsu/ntb/src/ntb.c b/cesar/bsu/ntb/src/ntb.c
index fe4a49a7f0..e5fe84bd28 100644
--- a/cesar/bsu/ntb/src/ntb.c
+++ b/cesar/bsu/ntb/src/ntb.c
@@ -14,6 +14,7 @@
#include "lib/fixed.h"
#include "bsu/ntb/ntb.h"
#include "mac/common/timings.h"
+#include "limits.h"
/** Define a security level for frequency error.
* If frequency error is greater then re-initialise freq error. */
@@ -46,22 +47,22 @@ bsu_ntb_frequency_error (bsu_ntb_sync_t *ctx, double freq_err, u32 bts,
{
double num = bts - ctx->bts;
double denum = preamble_sysdate - ctx->preamble_sysdate;
- if (!ctx->second_shoot)
+ if (!ctx->sync_nb)
{
ctx->fe = num / denum - 1;
- ctx->second_shoot = true;
}
else
{
double part2 = num / denum - 1 - freq_err;
ctx->fe = freq_err + bsu_ntb_wf * part2;
}
+ if (ctx->sync_nb < UINT_MAX)
+ ctx->sync_nb++;
}
}
/** Compute the current offset from the NTB clock and the phy clock.
* \param ctx module context.
- * \param phy the phy context.
* \param freq_error last frequency error computed.
* \param bts the last beacon time stamp received in the last beacon.
* \param preamble_stadata the sta date preamble corresponding to the last
@@ -70,19 +71,18 @@ bsu_ntb_frequency_error (bsu_ntb_sync_t *ctx, double freq_err, u32 bts,
* last beacon received.
*/
PRIVATE u32
-bsu_ntb_offset (bsu_ntb_sync_t *ctx, phy_t *phy, double freq_error,
- u32 bts, u32 preamble_stadate, u32 preamble_sysdate)
+bsu_ntb_offset (bsu_ntb_sync_t *ctx, double freq_error, u32 bts,
+ u32 preamble_stadate, u32 preamble_sysdate)
{
u32 offset;
dbg_assert (ctx);
offset = bts - preamble_stadate;
if (ctx->init)
{
- /* Get the delay in system ticks. */
- ctx->delay_systck = phy_sysdate () - preamble_sysdate;
- dbg_assert ((s32) ctx->delay_systck >= 0);
- offset += ((ctx->fe * ctx->delay_systck)
- - (freq_error * ctx->delay_systck));
+ /* Add offset for the update delay. */
+ int delay_systck = phy_sysdate () - preamble_sysdate;
+ dbg_assert (delay_systck >= 0);
+ offset += ctx->fe * delay_systck - freq_error * delay_systck;
}
return offset;
}
@@ -92,14 +92,13 @@ bsu_ntb_init (bsu_ntb_sync_t *ctx)
{
dbg_assert (ctx);
ctx->init = false;
- ctx->second_shoot = false;
+ ctx->sync_nb = 0;
ctx->fe = 0.0;
ctx->bts = 0;
ctx->preamble_sysdate = 0;
ctx->preamble_stadate = 0;
ctx->sta_numerator = 0;
ctx->ntb_offset_tck = 0;
- ctx->delay_systck = 0;
}
void
@@ -109,12 +108,11 @@ bsu_ntb_uninit (bsu_ntb_sync_t *ctx)
}
void
-bsu_ntb_clk_sync (bsu_ntb_sync_t * ctx, phy_t *phy, u32 beacon_bts,
- u32 beacon_sys_ltmr, u32 beacon_sta_ltmr, uint weight_k)
+bsu_ntb_clk_sync (bsu_ntb_sync_t * ctx, u32 beacon_bts, u32 beacon_sys_ltmr,
+ u32 beacon_sta_ltmr, uint weight_k)
{
double freq_error;
dbg_assert (ctx);
- dbg_assert (phy);
freq_error = ctx->fe;
/**
* Check the beacon received is not received N MS after the previous one,
@@ -132,10 +130,10 @@ bsu_ntb_clk_sync (bsu_ntb_sync_t * ctx, phy_t *phy, u32 beacon_bts,
freq_error = 0;
ctx->fe = 0;
ctx->init = false;
- ctx->second_shoot = false;
+ ctx->sync_nb = 0;
}
}
- ctx->ntb_offset_tck= bsu_ntb_offset (ctx, phy, freq_error, beacon_bts,
+ ctx->ntb_offset_tck= bsu_ntb_offset (ctx, freq_error, beacon_bts,
beacon_sta_ltmr, beacon_sys_ltmr);
ctx->preamble_sysdate = beacon_sys_ltmr;
ctx->preamble_stadate = beacon_sta_ltmr;
diff --git a/cesar/bsu/ntb/test/utest/src/ntb_compute.c b/cesar/bsu/ntb/test/utest/src/ntb_compute.c
index 19745c4c65..1612ddbae4 100644
--- a/cesar/bsu/ntb/test/utest/src/ntb_compute.c
+++ b/cesar/bsu/ntb/test/utest/src/ntb_compute.c
@@ -65,21 +65,21 @@ test_case_ntb_ntb_sync (test_t test, bsu_ntb_test_type_t type)
bsu_ntb_test_init (&t);
bsu_ntb_init (&sync);
/* Initialise the values. */
- sync.second_shoot = sync.init = true;
+ sync.init = true;
+ sync.sync_nb = 1;
sync.fe = freqerr [0];
sync.ntb_offset_tck = offset[0];
sync.bts = bts[0];
sync.preamble_sysdate = preamble_sysdate[0];
sync.preamble_stadate = preamble_stadate[0];
- sync.delay_systck = delay_systck [0];
for (i = 1; i < bts_nb; i++)
{
t.phy.preamble_sysdate = preamble_sysdate[i];
t.phy.sys_date = t.phy.preamble_sysdate + delay_systck[i];
/* In this test the sys_date_preamble is the same as the station
* date preamble. */
- bsu_ntb_clk_sync (&sync, (phy_t*) &t.phy, bts[i],
- preamble_sysdate[i], preamble_stadate[i], 2);
+ bsu_ntb_clk_sync (&sync, bts[i], preamble_sysdate[i],
+ preamble_stadate[i], 2);
test_fail_unless (ABS(sync.fe - freqerr[i]) < 1.0e-12,
"Freq different in loop %d", i);
test_fail_unless (sync.ntb_offset_tck == offset[i],
@@ -112,33 +112,32 @@ test_case_freq_error (test_t test)
bsu_ntb_init (&sync);
/* Configure with real data. */
sync.init = true;
- sync.second_shoot = true;
+ sync.sync_nb = 1;
sync.fe = -1.074e-05;
sync.bts = 0x8a1ad69;
sync.preamble_sysdate = 0x6f04181;
sync.preamble_stadate = 0x6f04181;
/* Compute new Frequency error. */
- bsu_ntb_clk_sync (&sync, (phy_t*) &t.phy, 0x21e04ad,
- 0x1ddf30d3, 0x1ddf30d3, 2);
+ bsu_ntb_clk_sync (&sync, 0x21e04ad, 0x1ddf30d3, 0x1ddf30d3, 2);
test_fail_unless (sync.fe == 0);
test_fail_unless (sync.init == true);
- test_fail_unless (sync.second_shoot == false);
+ test_fail_unless (sync.sync_nb == 0);
test_fail_unless (
sync.ntb_offset_tck == sync.bts - sync.preamble_stadate);
/* Negative one. */
bsu_ntb_init (&sync);
sync.init = true;
- sync.second_shoot = true;
+ sync.sync_nb = 1;
sync.fe = -2.04;
sync.bts = 0x8a1ad69;
sync.preamble_sysdate = 0x6f04181;
sync.preamble_stadate = 0x6f04181;
/* Compute new Frequency error. */
- bsu_ntb_clk_sync (&sync, (phy_t*) &t.phy, sync.bts + 1,
- sync.preamble_sysdate + 1, 0x1ddf30d3, 2);
+ bsu_ntb_clk_sync (&sync, sync.bts + 1, sync.preamble_sysdate + 1,
+ 0x1ddf30d3, 2);
test_fail_unless (sync.fe == 0);
test_fail_unless (sync.init == true);
- test_fail_unless (sync.second_shoot == false);
+ test_fail_unless (sync.sync_nb == 0);
test_fail_unless (
sync.ntb_offset_tck == sync.bts - sync.preamble_stadate);
}
@@ -149,7 +148,7 @@ test_case_freq_error (test_t test)
bsu_ntb_init (&sync);
/* Configure with real data. */
sync.init = true;
- sync.second_shoot = true;
+ sync.sync_nb = 1;
sync.fe = -1.074e-05;
sync.bts = 0x8a1ad69;
sync.preamble_sysdate = 0x6f04181;
@@ -159,15 +158,14 @@ test_case_freq_error (test_t test)
scmp.preamble_sysdate = sync.preamble_sysdate + MAC_MS_TO_TCK (500);
scmp.preamble_stadate = sync.preamble_stadate + MAC_MS_TO_TCK (500);
/* Compute new Frequency error. */
- bsu_ntb_clk_sync (
- &sync, (phy_t*) &t.phy, scmp.bts, scmp.preamble_sysdate,
- scmp.preamble_stadate, 2);
+ bsu_ntb_clk_sync (&sync, scmp.bts, scmp.preamble_sysdate,
+ scmp.preamble_stadate, 2);
test_fail_unless (sync.fe == scmp.fe);
test_fail_unless (scmp.bts == sync.bts);
test_fail_unless (scmp.preamble_sysdate == sync.preamble_sysdate);
test_fail_unless (scmp.preamble_stadate == sync.preamble_stadate);
test_fail_unless (sync.init == true);
- test_fail_unless (sync.second_shoot == true);
+ test_fail_unless (sync.sync_nb == 1);
}
test_end;
}
diff --git a/cesar/bsu/src/bsu.c b/cesar/bsu/src/bsu.c
index cfea17ce50..77cdaf9936 100644
--- a/cesar/bsu/src/bsu.c
+++ b/cesar/bsu/src/bsu.c
@@ -69,7 +69,7 @@ bsu_stats_store (bsu_t *ctx)
{
#if CONFIG_STATS
ctx->stats.ntb_offset_tck = ctx->sta_avln->sync.ntb_offset_tck;
- if (ctx->sta_avln->sync.second_shoot)
+ if (ctx->sta_avln->sync.sync_nb >= ctx->ntb_clk_sync_nb_stable)
ctx->stats.frequency_error_q30 =
FIXED (ctx->sta_avln->sync.fe, BSU_NTB_FIXED_POINT);
else
@@ -889,7 +889,11 @@ bsu_stats_init (bsu_t *ctx)
LIB_STATS_ACCESS_READ_ONLY,
LIB_STATS_USER);
lib_stats_set_stat_value_notype ("CLK_SYNC_WEIGHT_K",
- &ctx->bsu_ntb_clk_sync_weight_k,
+ &ctx->ntb_clk_sync_weight_k,
+ LIB_STATS_ACCESS_WRITE_ONLY,
+ LIB_STATS_USER);
+ lib_stats_set_stat_value_notype ("CLK_SYNC_NB_STABLE",
+ &ctx->ntb_clk_sync_nb_stable,
LIB_STATS_ACCESS_WRITE_ONLY,
LIB_STATS_USER);
#endif
@@ -945,7 +949,8 @@ bsu_init (bsu_aclf_t *aclf, mac_config_t *mac_config, phy_t *phy,
ctx->beacon_nb_sent[i] = 0;
for (i = 0; i < COUNT (ctx->ca_schedules_in_use); i++)
ctx->ca_schedules_in_use[i] = CA_SCHEDULE_NB;
- ctx->bsu_ntb_clk_sync_weight_k = BSU_NTB_CLK_SYNC_WEIGHT_K_DEFAULT;
+ ctx->ntb_clk_sync_weight_k = BSU_NTB_CLK_SYNC_WEIGHT_K_DEFAULT;
+ ctx->ntb_clk_sync_nb_stable = BSU_NTB_CLK_SYNC_NB_STABLE_DEFAULT;
/* Trace. */
bsu_trace_init (ctx);
bsu_stats_init (ctx);
@@ -990,10 +995,9 @@ bsu_beacon_process__avln_tracked (bsu_t *ctx, bsu_beacon_t *beacon,
+ bsu_aclf_beacon_period_tck (ctx->aclf));
memcpy (&ctx->sta_avln->beacon, beacon, sizeof (bsu_beacon_t));
/* NTB synchronisation. */
- bsu_ntb_clk_sync (&ctx->sta_avln->sync, ctx->phy,
- params->bts, params->preamble_sysdate,
- params->preamble_date,
- ctx->bsu_ntb_clk_sync_weight_k);
+ bsu_ntb_clk_sync (&ctx->sta_avln->sync, params->bts,
+ params->preamble_sysdate, params->preamble_date,
+ ctx->ntb_clk_sync_weight_k);
/* Configure the clock frequency. */
bsu_ntb_clock_configure (
&ctx->sta_avln->sync, ctx->mac_config, ctx->phy);
@@ -1055,10 +1059,8 @@ bsu_beacon_process__avln_not_tracked (bsu_t *ctx, bsu_beacon_t *beacon,
avln->bto[i] = params->bto[i];
memcpy (&avln->beacon, beacon, sizeof (bsu_beacon_t));
/* NTB synchronisation. */
- bsu_ntb_clk_sync (&avln->sync, ctx->phy,
- params->bts, params->preamble_sysdate,
- params->preamble_date,
- ctx->bsu_ntb_clk_sync_weight_k);
+ bsu_ntb_clk_sync (&avln->sync, params->bts, params->preamble_sysdate,
+ params->preamble_date, ctx->ntb_clk_sync_weight_k);
avln->beacon.beacon_period_start_date = params->bts -
avln->sync.ntb_offset_tck;
BSU_TRACE (BEACON_PROCESS, phy_date (), params->snid, beacon->vf.stei,
@@ -1106,7 +1108,7 @@ bsu_beacon_process (bsu_t *ctx, pb_beacon_t *beacon,
FIXED (avln->sync.fe, BSU_NTB_FIXED_POINT);
bsu_beacon->params.ntb_offset_tck = avln->sync.ntb_offset_tck;
bsu_beacon->params.frequency_error_valid =
- avln->sync.second_shoot;
+ avln->sync.sync_nb >= ctx->ntb_clk_sync_nb_stable;
}
}
else
diff --git a/cesar/bsu/test/utest/src/bsut.c b/cesar/bsu/test/utest/src/bsut.c
index b25a9cbd60..8dfe19384b 100644
--- a/cesar/bsu/test/utest/src/bsut.c
+++ b/cesar/bsu/test/utest/src/bsut.c
@@ -20,6 +20,7 @@
#include "bsu/inc/bsu.h"
#include "bsu/inc/context.h"
#include "bsu/inc/interface.h"
+#include "bsu/ntb/ntb.h"
bsu_avln_t*
bsu_avln_add (bsu_t *ctx, u64 nid, u8 snid, mac_t mac, bool *added);
@@ -36,6 +37,8 @@ bsu_update__persistent_schedules (bsu_t *ctx, bsu_beacon_t *beacon);
void
test_case_bsu_process (test_t test)
{
+ uint i;
+ uint central_beacon_nb_recv = 0;
bsu_test_t t;
bsu_test_init (&t);
bsu_activate (t.bsu, true);
@@ -51,10 +54,11 @@ test_case_bsu_process (test_t test)
pbproc_tx_beacon_params_t bp_tx;
pbproc_rx_beacon_params_t bpneighbour_rx;
pbproc_rx_beacon_params_t bp_rx;
- bsu_test_create_beacon (&t, &beacon_neighbour);
memset (&bp_rx, 0, sizeof (pbproc_rx_beacon_params_t));
memset (&bpneighbour_rx, 0, sizeof (pbproc_rx_beacon_params_t));
t.mac_config.tei = 4;
+ /* => Neighbour beacon with bad CRC. */
+ bsu_test_create_beacon (&t, &beacon_neighbour);
bpneighbour_rx.snid = 0x4;
bpneighbour_rx.bts = 0;
bneighbour = bsu_beacon_write (&beacon_neighbour,
@@ -64,80 +68,101 @@ test_case_bsu_process (test_t test)
bneighbour->phy_pb.pb_rx.pb_measurement.crc_error = true;
bprocessed = bsu_beacon_process (t.bsu, bneighbour, &bpneighbour_rx);
blk_release_desc ((blk_t*) bneighbour);
- /* Central beacon processed ? */
+ /* Central beacon processed? */
test_fail_unless (!bprocessed);
test_fail_unless (t.bsu->avlns[0].snid == 0);
test_fail_unless (t.bsu->avlns[0].beacon.vf.nid == 0);
test_fail_unless (t.bsu->beacon_nb_sent [BSU_BEACON_TYPE_CENTRAL]
== 0);
- /* NTB called ? */
+ /* NTB called? */
test_fail_unless (t.bsu->avlns[0].sync.init == false);
+ test_fail_unless (t.bsu->avlns[0].sync.sync_nb == 0);
+ /* => First neighbour beacon reception. */
bneighbour = bsu_beacon_write (&beacon_neighbour,
BSU_BEACON_TYPE_CENTRAL,
&t.mac_config,
&bpneighbour_tx);
bneighbour->phy_pb.pb_rx.pb_measurement.crc_error = false;
bprocessed = bsu_beacon_process (t.bsu, bneighbour, &bpneighbour_rx);
- /* Central beacon processed ? */
+ /* Central beacon processed? */
test_fail_unless (bprocessed);
- test_fail_unless (!bprocessed->params.frequency_error_valid);
test_fail_unless (t.bsu->avlns[0].snid == bpneighbour_rx.snid);
test_fail_unless (t.bsu->avlns[0].beacon.vf.nid
== beacon_neighbour.vf.nid);
+ central_beacon_nb_recv++;
test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
- == 1);
- blk_release (bprocessed);
- /* NTB called ? */
- test_fail_unless (t.bsu->avlns[0].sync.init == true);
- /* Second shoot... */
- bprocessed = bsu_beacon_process (t.bsu, bneighbour, &bpneighbour_rx);
- /* Central beacon processed ? */
- test_fail_unless (bprocessed);
- test_fail_unless (t.bsu->avlns[0].snid == bpneighbour_rx.snid);
- test_fail_unless (t.bsu->avlns[0].beacon.vf.nid
- == beacon_neighbour.vf.nid);
- /* NTB called ? */
+ == central_beacon_nb_recv);
+ /* NTB called? */
test_fail_unless (t.bsu->avlns[0].sync.init == true);
- test_fail_unless (bprocessed->params.frequency_error_valid);
- blk_release_desc ((blk_t*) bneighbour);
- test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
- == 2);
+ test_fail_unless (t.bsu->avlns[0].sync.sync_nb == 0);
+ test_fail_unless (!bprocessed->params.frequency_error_valid);
+ /* Cleanup. */
blk_release (bprocessed);
- /* Our AVLN. */
+ /* => Next neighbour beacon receptions. */
+ for (i = 1; i <= BSU_NTB_CLK_SYNC_NB_STABLE_DEFAULT; i++)
+ {
+ bprocessed = bsu_beacon_process (t.bsu, bneighbour,
+ &bpneighbour_rx);
+ /* Central beacon processed? */
+ test_fail_unless (bprocessed);
+ test_fail_unless (t.bsu->avlns[0].snid == bpneighbour_rx.snid);
+ test_fail_unless (t.bsu->avlns[0].beacon.vf.nid
+ == beacon_neighbour.vf.nid);
+ central_beacon_nb_recv++;
+ test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
+ == central_beacon_nb_recv);
+ /* NTB called? */
+ test_fail_unless (t.bsu->avlns[0].sync.init == true);
+ test_fail_unless (t.bsu->avlns[0].sync.sync_nb == i);
+ if (i == BSU_NTB_CLK_SYNC_NB_STABLE_DEFAULT)
+ test_fail_unless (bprocessed->params.frequency_error_valid);
+ else
+ test_fail_unless (!bprocessed->params.frequency_error_valid);
+ /* Cleanup. */
+ blk_release (bprocessed);
+ }
+ /* Cleanup. */
+ blk_release_desc ((blk_t*) bneighbour);
+ /* => Our AVLN. */
bsu_track_avln (t.bsu,
beacon_neighbour.vf.nid, 0x4, beacon_neighbour.vf.stei,
beacon_neighbour.bmis.mac_address.mac_address);
- t.bsu->sta_avln->sync.init = false;
+ /* Reset synchronisation. */
+ bsu_ntb_init (&t.bsu->sta_avln->sync);
+ /* => Beacon with bad CRC. */
bsu_test_create_beacon (&t, &beacon);
+ bp_rx.snid = 0x4;
+ bp_rx.bts = 0;
b = bsu_beacon_write (&beacon, BSU_BEACON_TYPE_CENTRAL,
&t.mac_config, &bp_tx);
b->phy_pb.pb_rx.pb_measurement.crc_error = true;
bprocessed = bsu_beacon_process (t.bsu, b, &bp_rx);
- /* Central beacon processed ? */
+ blk_release_desc ((blk_t*) b);
+ /* Central beacon processed? */
test_fail_unless (!bprocessed);
test_fail_unless (t.bsu->sta_avln->snid == t.bsu->snid_track);
test_fail_unless (t.bsu->sta_avln->beacon.vf.nid == t.bsu->nid_track);
test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
- == 2);
- blk_release_desc ((blk_t*) b);
- /* NTB called ? */
+ == central_beacon_nb_recv);
+ /* NTB called? */
test_fail_unless (t.bsu->sta_avln->sync.init == false);
- bp_rx.snid = 0x4;
- bp_rx.bts = 0;
+ /* => First beacon reception. */
b = bsu_beacon_write (&beacon, BSU_BEACON_TYPE_CENTRAL,
&t.mac_config, &bp_tx);
b->phy_pb.pb_rx.pb_measurement.crc_error = false;
bprocessed = bsu_beacon_process (t.bsu, b, &bp_rx);
- /* Central beacon processed ? */
+ /* Central beacon processed? */
test_fail_unless (bprocessed);
test_fail_unless (t.bsu->sta_avln->snid == bp_rx.snid);
test_fail_unless (t.bsu->sta_avln->beacon.vf.nid == beacon.vf.nid);
+ central_beacon_nb_recv++;
test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
- == 3);
- /* NTB called ? */
+ == central_beacon_nb_recv);
+ /* NTB called? */
test_fail_unless (t.bsu->sta_avln->sync.init == true);
- test_fail_unless (t.bsu->sta_avln->sync.second_shoot);
- test_fail_unless (bprocessed->params.frequency_error_valid);
+ test_fail_unless (t.bsu->sta_avln->sync.sync_nb == 0);
+ test_fail_unless (!bprocessed->params.frequency_error_valid);
+ /* Cleanup. */
blk_release_desc ((blk_t*) b);
blk_release (bprocessed);
}
@@ -171,8 +196,9 @@ test_case_bsu_process (test_t test)
test_fail_unless (t.sar.mfs->common.lid == MAC_LID_DISCOVER);
test_fail_unless (t.bsu->beacon_nb_sent [BSU_BEACON_TYPE_DISCOVER]
== 1);
+ central_beacon_nb_recv += 2;
test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
- == 5);
+ == central_beacon_nb_recv);
/* Upper layer receives it ? */
test_fail_unless (t.ul.beacon);
test_fail_unless (t.ul.beacon->next);
diff --git a/cesar/ce/rx/bitloading/inc/ber.h b/cesar/ce/rx/bitloading/inc/ber.h
index d1182233f9..3184bbac4c 100644
--- a/cesar/ce/rx/bitloading/inc/ber.h
+++ b/cesar/ce/rx/bitloading/inc/ber.h
@@ -51,12 +51,6 @@
#define CE_RX_BL_BPT_QUANT_FACTOR (1ull << 8)
/**
- * NSR must be rescaled before used by BER vs polynomials.
- * Rescaling is not the same if NSR is based on sound or data.
- */
-#define CE_RX_BL_BER_NSR_SOUND_RESCALE (2)
-
-/**
* Polynomials for each modulation to compute BER.
*/
struct ce_rx_bl_ber_poly_coef_t
diff --git a/cesar/ce/rx/bitloading/inc/poly.h b/cesar/ce/rx/bitloading/inc/poly.h
index 5b56bc8c85..ae35acbea9 100644
--- a/cesar/ce/rx/bitloading/inc/poly.h
+++ b/cesar/ce/rx/bitloading/inc/poly.h
@@ -36,7 +36,7 @@ BEGIN_DECLS
* Therefore, implementation uses the second forms of the polynomial.
*/
extern inline s64
-ce_rx_bl_poly (const u8 degree, const s64 const *coef, const u32 x)
+ce_rx_bl_poly (const u8 degree, const s64 * const coef, const u32 x)
{
/* Check parameter. */
dbg_assert (coef);
diff --git a/cesar/ce/rx/bitloading/nsr.h b/cesar/ce/rx/bitloading/nsr.h
new file mode 100644
index 0000000000..6d4a9a824c
--- /dev/null
+++ b/cesar/ce/rx/bitloading/nsr.h
@@ -0,0 +1,24 @@
+#ifndef ce_rx_bitloading_nsr_h
+#define ce_rx_bitloading_nsr_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/rx/bitloading/nsr.h
+ * \brief Public data
+ * \ingroup ce_rx_bl
+ *
+ * This file contains the information related to NSR.
+ */
+
+/**
+ * NSR must be rescaled before used by BER vs polynomials.
+ * Rescaling is not the same if NSR is based on sound or data.
+ */
+#define CE_RX_BL_NSR_SOUND_RESCALE (2)
+
+#endif /* ce_rx_bitloading_nsr_h */
diff --git a/cesar/ce/rx/bitloading/src/nsr.c b/cesar/ce/rx/bitloading/src/nsr.c
index d3499c2494..4da8168e0f 100644
--- a/cesar/ce/rx/bitloading/src/nsr.c
+++ b/cesar/ce/rx/bitloading/src/nsr.c
@@ -13,6 +13,7 @@
#include "common/std.h"
#include "ce/rx/bitloading/inc/nsr.h"
+#include "ce/rx/bitloading/nsr.h"
#include "ce/rx/bitloading/inc/ber.h"
#include "hal/phy/defs.h"
@@ -171,7 +172,7 @@ ce_rx_bl_nsr_compute_mean (ce_rx_bitloading_t *bl)
/* Compute mean and rescale (for NSR dynamics). */
cur_sum_nsr[j] = ce_rx_bl_nsr_mean (cur_sum_nsr[j],
bl->mean_count)
- * CE_RX_BL_BER_NSR_SOUND_RESCALE
+ * CE_RX_BL_NSR_SOUND_RESCALE
* ce_rx_bl_nsr_margin_ / CE_RX_BL_NSR_MARGIN_QUANT_FACTOR;
}
/* Next block. */
diff --git a/cesar/ce/rx/bitloading/test/src/test_bl.c b/cesar/ce/rx/bitloading/test/src/test_bl.c
index 5a1e410d5d..0fabe28917 100644
--- a/cesar/ce/rx/bitloading/test/src/test_bl.c
+++ b/cesar/ce/rx/bitloading/test/src/test_bl.c
@@ -22,6 +22,7 @@
#include "ce/rx/bitloading/inc/bitloading.h"
#include "ce/rx/bitloading/bitloading.h"
#include "ce/rx/bitloading/inc/common.h"
+#include "ce/rx/bitloading/nsr.h"
#include "lib/rnd.h"
/* Test vectors. */
@@ -1936,7 +1937,7 @@ main (int argc, char **argv)
uint i;
for (i = 0; i < mean_on_sound_nsr_height;
i++)
- mean_on_sound_nsr[i][0] *= CE_RX_BL_BER_NSR_SOUND_RESCALE;
+ mean_on_sound_nsr[i][0] *= CE_RX_BL_NSR_SOUND_RESCALE;
/* BER target margin. */
test_suite_ce_rx_bl_ber_target_margin (t);
diff --git a/cesar/ce/rx/test/src/test_rx.c b/cesar/ce/rx/test/src/test_rx.c
index 9bc9d3162c..f01deb8e65 100644
--- a/cesar/ce/rx/test/src/test_rx.c
+++ b/cesar/ce/rx/test/src/test_rx.c
@@ -143,6 +143,7 @@ test_ce_rx_measure_suite (test_t t)
{
pbproc_rx_params_t rx_params;
rx_params.tei = 1;
+ rx_params.multi_net_bcast = false;
rx_params.preamble_ntb = 0;
rx_params.beacon_period_start_ntb = 42;
mac_store_t *mac_store = mac_store_init ();
diff --git a/cesar/cl/inc/context.h b/cesar/cl/inc/context.h
index 662e56118f..965a190ccd 100644
--- a/cesar/cl/inc/context.h
+++ b/cesar/cl/inc/context.h
@@ -17,6 +17,7 @@
#include "common/defs/ethernet.h"
#include "lib/slab.h"
+#include "lib/seq_check.h"
#include "mac/common/mfs.h"
#include "mac/common/store.h"
#include "mac/common/config.h"
@@ -171,6 +172,9 @@ struct cl_t
/** cl Trace */
trace_buffer_t trace;
#endif /* !CONFIG_TRACE */
+#if CONFIG_SEQ_CHECK
+ lib_seq_check_t seq_check_rx_ctx;
+#endif
};
#endif /* CL_INC_CONTEXT_H_ */
diff --git a/cesar/cl/inc/trace.h b/cesar/cl/inc/trace.h
index e312a292f6..7192677e7c 100644
--- a/cesar/cl/inc/trace.h
+++ b/cesar/cl/inc/trace.h
@@ -47,6 +47,7 @@ enum
CL_TRACE_DATA_RECV,
CL_TRACE_DATA_BUFFER_ADD,
CL_TRACE_BRIDGE_ADD,
+ CL_TRACE_SEQ_CHECK,
};
BEGIN_DECLS
diff --git a/cesar/cl/src/bridge_table.c b/cesar/cl/src/bridge_table.c
index 94d96f0cc2..c5bd352e6b 100644
--- a/cesar/cl/src/bridge_table.c
+++ b/cesar/cl/src/bridge_table.c
@@ -146,12 +146,11 @@ bridge_table_update (cl_t *ctx)
/* The temporary local bridge is now empty. */
ctx->bridge_table.table_tmp_entry_count = 0;
- /* Remove old table. */
- if (ctx->bridge_table.table)
- mac_lookup_table_release (ctx->bridge_table.table);
-
- /* Affect new local bridge table. */
+ /* Atomically replace local bridge table. */
+ mac_lookup_table_t *old_table = ctx->bridge_table.table;
ctx->bridge_table.table = mac_lookup_table_convert (new_bridge_table);
+ if (old_table)
+ mac_lookup_table_release (old_table);
/* Bridge table has been modified. */
return true;
@@ -173,12 +172,11 @@ bridge_table_update (cl_t *ctx)
0xFFFF,
ctx->bridge_table.cycle_counter);
- /* Remove old table. */
- mac_lookup_table_release (ctx->bridge_table.table);
-
/* Affect new local bridge table. */
+ mac_lookup_table_t *old_table = ctx->bridge_table.table;
ctx->bridge_table.table
= mac_lookup_table_convert (new_bridge_table);
+ mac_lookup_table_release (old_table);
/* Bridge table has been modified. */
return true;
diff --git a/cesar/cl/src/cl.c b/cesar/cl/src/cl.c
index fc6b7d22bb..11d721149f 100644
--- a/cesar/cl/src/cl.c
+++ b/cesar/cl/src/cl.c
@@ -15,6 +15,7 @@
#include "common/std.h"
#include "common/defs/ethernet.h"
#include "lib/bitstream.h"
+#include "lib/seq_check.h"
#include "config/cl.h"
#include "cl/cl.h"
@@ -42,6 +43,26 @@
static struct cl_t cl_global;
/**
+ * Callback when the lib sequencer detect a wrong sequencing.
+ * \param user user data
+ * \param vlan the VLAN id
+ * \param seq_expected the sequence number expected
+ * \param seq_actual the actual sequence number found in the packet
+ */
+void
+cl_lib_seq_check_cb (void *user, uint vlan, uint seq_expected,
+ uint seq_actual);
+
+void
+cl_lib_seq_check_cb (void *user, uint vlan, uint seq_expected,
+ uint seq_actual)
+{
+ dbg_assert (user);
+ trace_do (cl_t *ctx = (cl_t *) user);
+ CL_TRACE (SEQ_CHECK, vlan, seq_expected, seq_actual);
+}
+
+/**
* Search for the lid in the classifier
*
* \param ctx CL context
@@ -324,6 +345,9 @@ cl_init (mac_store_t *mac_store, sar_t *sar, mac_config_t *mac_config)
CL_TRACE (INIT, phy_date ());
+ /* Initialise packet sequence check. */
+ lib_seq_check_init (&ctx->seq_check_rx_ctx, cl_lib_seq_check_cb, ctx);
+
/* Debug leds. */
GPIO_SETUP (LED_CL_RX, GPIO_DIRECTION_OUT);
GPIO_SET (LED_CL_RX, 0);
@@ -985,6 +1009,9 @@ void cl_data_recv (cl_t *ctx, u8 *buffer, uint length, mfs_rx_t *mfs)
&& (length <= ETH_PACKET_MAX_SIZE));
dbg_assert (mfs);
+ /* Check sequence number of throughput. */
+ lib_seq_check_packet (&ctx->seq_check_rx_ctx, buffer, length);
+
dbg_assert (ctx->data_rx.cb);
mac_t smac, dmac;
bitstream_direct_read_macs (buffer, &dmac, &smac);
diff --git a/cesar/cl/src/trace.c b/cesar/cl/src/trace.c
index 9ad0392a54..758caa7561 100644
--- a/cesar/cl/src/trace.c
+++ b/cesar/cl/src/trace.c
@@ -52,6 +52,8 @@ cl_trace_init (cl_t *ctx)
TRACE_EVENT (CL_TRACE_DATA_RECV, "CL_DATA_RECV buffer @ : %x, destination : %m, source : %m, length : %d", TIMESTAMP),
TRACE_EVENT (CL_TRACE_DATA_BUFFER_ADD, "CL_DATA_BUFFER_ADD buffer @ : %x", TIMESTAMP),
TRACE_EVENT (CL_TRACE_BRIDGE_ADD, "Bridging MAC %m"),
+ TRACE_EVENT (CL_TRACE_SEQ_CHECK, "[SeqCheck] input from PLC: "
+ "[%02d] expected=%04X, actual=%04X"),
};
dbg_assert (ctx);
trace_namespace_init (&namespace, event_ids, COUNT (event_ids));
diff --git a/cesar/common/make/config.mk b/cesar/common/make/config.mk
index ac46989db0..c5dbc829ff 100644
--- a/cesar/common/make/config.mk
+++ b/cesar/common/make/config.mk
@@ -64,6 +64,10 @@ $$($2_OBJ_INC_DIR)/build_info.h: $$($2_OBJ_INC_DIR_STAMP) BUILD_INFO_FORCE
endef
$(call foreach_type,CONFIG_RULES_template)
+# Check for old build system leftovers.
+$(if $(wildcard $(OBJ_INC_DIR)/build_info.h),\
+$(error old build system leftovers detected, please rm -r obj))
+
$(DEFAULT_PROJECT_CONFIG): $(OBJ_DIR_STAMP)
touch $@
diff --git a/cesar/common/tests/tests b/cesar/common/tests/tests
index 589b7a068f..b5c46c5b5f 100644
--- a/cesar/common/tests/tests
+++ b/cesar/common/tests/tests
@@ -80,8 +80,8 @@ cov test_mac_lookup_table: ./obj/test_mac_lookup_table
lib/test/mbox:
make: make COV=y
-cov test_mbox_host: ./obj/host
-cov test_mbox_ecos: ./obj/mbox.elf
+cov test_mbox_host: ./obj/mbox_host
+cov-target test_mbox_ecos: ./obj/mbox.elf
lib/test/perf:
make: make
@@ -134,6 +134,10 @@ lib/scenario/test:
make: make COV=y
cov test_scenario: ./obj/test_scenario
+lib/test/seq_check:
+make: make COV=y
+cov test_seq_check: ./obj/test_seq_check
+
maximus/stationtest:
make
@@ -480,7 +484,8 @@ sc01_long_simu: python py/sc01_long_simu.py -d false -t 25000000000
sc02_long_simu_data: python py/sc02_long_simu_data.py -d false -t 25000000000
test_general/station/tonemap:
-make
+make -f host-Makefile
+sc01_bl_initial: python py/sc01_bl_initial.py --maximus
sc02_vs_get_tonemap: python py/sc02_vs_get_tonemap.py --maximus
cp/cco/bw/test:
@@ -527,10 +532,6 @@ test_general/station/compliance:
make
6.2.1-dut_as_a_cco: python py/sc01_dut_as_a_cco.py --maximus
-test_general/station/tonemap:
-make -f host-Makefile
-tone_map_exchange_no_snr: python py/sc01_bl_initial.py --maximus
-
bsu/beacon/test/utest:
make
beacon: ./obj/beacon
@@ -546,3 +547,7 @@ bsu/ntb: ./obj/ntb
bsu/aclf/test/utest:
make
bsu/aclf: ./obj/aclf
+
+projects/plc:
+make
+make traces: make PROJECT_CONFIG=Config.traces
diff --git a/cesar/cp/beacon/test/src/beacon.c b/cesar/cp/beacon/test/src/beacon.c
index 1716547d1d..0e4b83c116 100644
--- a/cesar/cp/beacon/test/src/beacon.c
+++ b/cesar/cp/beacon/test/src/beacon.c
@@ -35,7 +35,47 @@ cp_beacon_receive (cp_t *ctx, bsu_beacon_t *beacon);
void
cp_beacon_sta_compute_schedules (cp_t *ctx, bsu_beacon_t *beacon_data);
-static cp_t cp;
+struct test_beacon_t
+{
+ cp_t cp;
+ mac_config_t mac_config;
+ cl_t cl;
+ sar_t sar;
+ bsu_aclf_t aclf;
+ uint ca;
+};
+typedef struct test_beacon_t test_beacon_t;
+
+void
+test_beacon_init (test_beacon_t *ctx)
+{
+ memset (ctx, 0, sizeof (test_beacon_t));
+ lib_rnd_init (&ctx->cp.rnd, 0x1234);
+ ctx->cp.mac_config = &ctx->mac_config;
+ ctx->cp.sar = &ctx->sar;
+ ctx->cp.cl = &ctx->cl;
+ ctx->cp.bsu_aclf = &ctx->aclf;
+ *((bsu_aclf_frequency_t*) &ctx->aclf.frequency) = BSU_ACLF_FREQ_50HZ;
+ *((bsu_aclf_bp_t*) &ctx->aclf.beacon_period_theo_tck) =
+ BSU_ACLF_BP_50HZ_TCK;
+ ctx->aclf.beacon_period_tck = ctx->aclf.beacon_period_theo_tck;
+ ctx->cp.mac_store = mac_store_init();
+ ctx->cp.ca = (ca_t*) &ctx->ca;
+ cp_sta_mgr_init (&ctx->cp);
+ cp_cco_bw_init (&ctx->cp);
+ cp_cco_region_init (&ctx->cp);
+ cp_beacon_init (&ctx->cp);
+}
+
+void
+test_beacon_uninit (test_beacon_t *ctx)
+{
+ cp_beacon_uninit (&ctx->cp);
+ cp_cco_bw_uninit (&ctx->cp);
+ cp_cco_region_uninit (&ctx->cp);
+ cp_sta_mgr_uninit (&ctx->cp);
+ mac_store_uninit (ctx->cp.mac_store);
+}
bsu_beacon_t*
test_new_beacon (void)
@@ -75,21 +115,6 @@ test_new_beacon (void)
return beacon;
}
-
-/** Initialise
- *
- * At the end of this test, all the variables present in the beacon context
- * shall be equal to zero or null for the pointers.
- */
-void
-test_case_beacon_init (test_t test)
-{
-
- cp_beacon_init (&cp);
-
- test_case_begin (test, "beacon init");
-}
-
/** Uninitialise
* \param test the test object.
*
@@ -118,8 +143,8 @@ test_case_beacon_uninit (test_t test)
test_case_begin (test, "Beacon uninit");
test_begin (test, "remove beacons received")
{
- cp_beacon_init (&cp);
- cp.mac_store = mac_store_init ();
+ test_beacon_t ctx;
+ test_beacon_init (&ctx);
bsu_beacon_t *b;
uint i;
for (i = 0; i < 2; i++)
@@ -127,10 +152,10 @@ test_case_beacon_uninit (test_t test)
b = blk_alloc ();
b->next = NULL;
b->params.direction = BSU_BEACON_DIRECTION_FROM_PLC;
- cp_beacon_receive (&cp, b);
+ cp_beacon_receive (&ctx.cp, b);
}
- cp_beacon_uninit (&cp);
- test_fail_unless (slist_empty (cp.beacon.list., bare));
+ test_beacon_uninit (&ctx);
+ test_fail_unless (slist_empty (ctx.cp.beacon.list., bare));
}
test_end;
}
@@ -139,35 +164,25 @@ void
test_case_beacon__deactivate (test_t test)
{
test_case_begin (test, "Deactivate");
-
test_begin (test, "Deactivate beacon module")
{
+ test_beacon_t ctx;
uint nb_beacons = 2;
- mac_store_t *mac_store = mac_store_init();
- uint ca;
-
- /* Configure the test. */
- memset (&cp, 0, sizeof (cp_t));
- cp.mac_store = mac_store;
- cp.ca = (ca_t *) &ca;
-
- cp_beacon_init (&cp);
-
+ test_beacon_init (&ctx);
/* Still configuring the test... */
- cp.beacon.leon_timer.status = true;
-
+ ctx.cp.beacon.leon_timer.status = true;
/* Allocate some beacons. */
uint i;
for (i = 0; i < nb_beacons; i++)
{
bsu_beacon_t *beacon = blk_alloc ();
beacon->next = NULL;
- slist_push_back (cp.beacon.list., beacon, bare);
+ slist_push_back (ctx.cp.beacon.list., beacon, bare);
}
/* test. */
- cp_beacon_deactivate (&cp);
- test_fail_unless (slist_empty (cp.beacon.list., bare));
- mac_store_uninit (mac_store);
+ cp_beacon_deactivate (&ctx.cp);
+ test_fail_unless (slist_empty (ctx.cp.beacon.list., bare));
+ test_beacon_uninit (&ctx);
test_fail_if (blk_check_memory () != true, "Memory leaks");
}
test_end;
@@ -287,30 +302,9 @@ test_beacon_bentries (test_t test, bsu_beacon_t *beacon,
void
test_suite_beacon__beacon_generation (test_t test)
{
+ test_beacon_t ctx;
bsu_beacon_t beacon;
-
- mac_config_t mac_config;
- cl_t cl;
- sar_t sar;
- bsu_aclf_t aclf;
-
- /* Configure the context. */
- memset (&mac_config, 0, sizeof (mac_config_t));
- memset (&cl, 0, sizeof (cl_t));
- memset (&sar, 0, sizeof (sar_t));
- memset (&aclf, 0, sizeof (bsu_aclf_t));
-
- cp.mac_config = &mac_config;
- cp.cl = &cl;
- cp.sar = &sar;
- cp.bsu_aclf = &aclf;
- aclf.beacon_period_tck = BSU_ACLF_BP_50HZ_TCK;
-
- cp_sta_mgr_init (&cp);
- cp_beacon_init (&cp);
- cp_cco_bw_init (&cp);
- cp_cco_region_init (&cp);
- cp.mac_store = mac_store_init();
+ test_beacon_init (&ctx);
/* Data set one */
const cp_nid_t nid_1 = 0x001456789ABCDEF0ull;
@@ -331,39 +325,39 @@ test_suite_beacon__beacon_generation (test_t test)
const u8 snid_cd = 0xA;
const cp_snid_t new_snid = 0xF;
- cp_net_t *net_1 = cp_sta_mgr_add_avln (&cp, snid_1, nid_1);
- cp_sta_own_data_set_tei (&cp, tei_1);
- cp_net_set_slot_id_and_usage (&cp, net_1, slot_id_1, 0);
- cp_sta_mgr_set_our_avln (&cp, net_1);
- cp_beacon_handover_hoipflag (&cp, hoip_flag_1);
- cp_sta_own_data_set_cco_status (&cp, cco_flag_1);
- cp_sta_own_data_set_pco_status (&cp, pco_flag_1);
- cp_sta_own_data_set_authenticated_status (&cp, authen_1);
- cp.beacon.discover.discover_interval_bp = 10;
- ((cp_sta_own_data_t *)&cp.sta_mgr.sta_own_data)->hybrid_mode = hm_1;
-
- cp_beacon_change_hm (&cp, new_hm);
- cp.beacon.eks.kccd = kc_cd;
- cp.beacon.eks.kbc = kbc;
- cp.beacon.eks.new_eks = eks;
- cp.beacon.hoip.hoipcd = hoip_cd;
- cp.beacon.hoip.cco = hoip_tei;
- cp.beacon.snids.snidcd = snid_cd;
- cp.beacon.snids.snid = new_snid;
- cp.beacon.discover.countdown_bp = 0; // so that the flag is true
+ cp_net_t *net_1 = cp_sta_mgr_add_avln (&ctx.cp, snid_1, nid_1);
+ cp_sta_own_data_set_tei (&ctx.cp, tei_1);
+ cp_net_set_slot_id_and_usage (&ctx.cp, net_1, slot_id_1, 0);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net_1);
+ cp_beacon_handover_hoipflag (&ctx.cp, hoip_flag_1);
+ cp_sta_own_data_set_cco_status (&ctx.cp, cco_flag_1);
+ cp_sta_own_data_set_pco_status (&ctx.cp, pco_flag_1);
+ cp_sta_own_data_set_authenticated_status (&ctx.cp, authen_1);
+ ctx.cp.beacon.discover.discover_interval_bp = 10;
+ ((cp_sta_own_data_t *)&ctx.cp.sta_mgr.sta_own_data)->hybrid_mode = hm_1;
+
+ cp_beacon_change_hm (&ctx.cp, new_hm);
+ ctx.cp.beacon.eks.kccd = kc_cd;
+ ctx.cp.beacon.eks.kbc = kbc;
+ ctx.cp.beacon.eks.new_eks = eks;
+ ctx.cp.beacon.hoip.hoipcd = hoip_cd;
+ ctx.cp.beacon.hoip.cco = hoip_tei;
+ ctx.cp.beacon.snids.snidcd = snid_cd;
+ ctx.cp.beacon.snids.snid = new_snid;
+ ctx.cp.beacon.discover.countdown_bp = 0; // so that the flag is true
/* Regions. */
cp_cco_region_alloc_t *region;
uint end_time_atu = 3907;
- region = cp_cco_region_alloc_init (&cp);
+ region = cp_cco_region_alloc_init (&ctx.cp);
region->type = CP_BEACON_REGION_TYPE_SHARED_CSMA;
region->end_time_atu = end_time_atu;
- cp_cco_region_alloc_add (&cp, &cp.region.region_list, region);
+ cp_cco_region_alloc_add (&ctx.cp, &ctx.cp.region.region_list, region);
slab_release (region);
/* Fill the beacon data share memory */
- cp_beacon_fill (&cp, &beacon);
+ cp_beacon_fill (&ctx.cp, &beacon);
test_suite_begin (test, "Beacon generation");
test_case_begin (test, "fill share memory");
@@ -412,32 +406,32 @@ test_suite_beacon__beacon_generation (test_t test)
const bool authen_2 = false;
const mac_coexistence_mode_t hm_2 = MAC_COEXISTENCE_NB - 1;
- cp_net_t *net_2 = cp_sta_mgr_add_avln (&cp, snid_2, nid_2);
- cp_sta_own_data_set_tei (&cp, tei_2);
- cp_net_set_slot_id_and_usage (&cp, net_2, slot_id_2, 0);
- cp_sta_mgr_set_our_avln (&cp, net_2);
- cp_beacon_handover_hoipflag (&cp, hoip_flag_2);
- cp_sta_own_data_set_cco_status (&cp, cco_flag_2);
- cp_sta_own_data_set_pco_status (&cp, pco_flag_2);
- cp_sta_own_data_set_authenticated_status (&cp, authen_2);
- ((cp_sta_own_data_t *)&cp.sta_mgr.sta_own_data)->hybrid_mode = hm_2;
-
- cp.beacon.eks.kccd = 0;
- cp.beacon.hoip.hoipcd = 0;
- cp.beacon.snids.snidcd = 0;
- cp.beacon.hm.hmcd = 0;
+ cp_net_t *net_2 = cp_sta_mgr_add_avln (&ctx.cp, snid_2, nid_2);
+ cp_sta_own_data_set_tei (&ctx.cp, tei_2);
+ cp_net_set_slot_id_and_usage (&ctx.cp, net_2, slot_id_2, 0);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net_2);
+ cp_beacon_handover_hoipflag (&ctx.cp, hoip_flag_2);
+ cp_sta_own_data_set_cco_status (&ctx.cp, cco_flag_2);
+ cp_sta_own_data_set_pco_status (&ctx.cp, pco_flag_2);
+ cp_sta_own_data_set_authenticated_status (&ctx.cp, authen_2);
+ ((cp_sta_own_data_t *)&ctx.cp.sta_mgr.sta_own_data)->hybrid_mode = hm_2;
+
+ ctx.cp.beacon.eks.kccd = 0;
+ ctx.cp.beacon.hoip.hoipcd = 0;
+ ctx.cp.beacon.snids.snidcd = 0;
+ ctx.cp.beacon.hm.hmcd = 0;
/* Regions. */
- region = cp_cco_region_alloc_init (&cp);
+ region = cp_cco_region_alloc_init (&ctx.cp);
region->type = CP_BEACON_REGION_TYPE_BEACON;
region->end_time_atu = end_time_atu - 10;
- cp_cco_region_alloc_add (&cp, &cp.region.region_list, region);
+ cp_cco_region_alloc_add (&ctx.cp, &ctx.cp.region.region_list, region);
slab_release (region);
- region = cp_cco_region_alloc_init (&cp);
+ region = cp_cco_region_alloc_init (&ctx.cp);
region->type = CP_BEACON_REGION_TYPE_STAYOUT;
region->end_time_atu = end_time_atu + 10;
- cp_cco_region_alloc_add (&cp, &cp.region.region_list, region);
+ cp_cco_region_alloc_add (&ctx.cp, &ctx.cp.region.region_list, region);
slab_release (region);
/* Schedules. */
@@ -449,7 +443,7 @@ test_suite_beacon__beacon_generation (test_t test)
{
for (ns=0; ns < 2; ns++)
{
- sched = cp_cco_bw_alloc_init (&cp);
+ sched = cp_cco_bw_alloc_init (&ctx.cp);
sched->persistence = CP_CCO_BW_ALLOC_PERSISTENCE_PERSISTENT;
sched->pscd = i;
sched->cscd = i;
@@ -457,14 +451,14 @@ test_suite_beacon__beacon_generation (test_t test)
sched->glid = 0x55 + nb;
sched->end_time_atu = end_time_atu + nb * 10 + ns * 5;
sched->start_time_atu = end_time_atu + nb * 10 + ns * 5 -4;
- cp_cco_bw_alloc_add (&cp, &cp.bw.alloc_list, sched);
+ cp_cco_bw_alloc_add (&ctx.cp, &ctx.cp.bw.alloc_list, sched);
slab_release (sched);
}
}
for (ns = 0; ns < BSU_BEACON_BMIS_SCHEDULES_SAI_MAX; ns++)
{
- sched = cp_cco_bw_alloc_init (&cp);
+ sched = cp_cco_bw_alloc_init (&ctx.cp);
sched->persistence = CP_CCO_BW_ALLOC_PERSISTENCE_NOT_PERSISTENT;
sched->pscd = ns;
sched->cscd = ns;
@@ -472,12 +466,12 @@ test_suite_beacon__beacon_generation (test_t test)
sched->glid = 0x45 + ns;
sched->start_time_atu = end_time_atu - 10 * (ns + 1) -9;
sched->end_time_atu = end_time_atu - 10 * (ns + 1);
- cp_cco_bw_alloc_add (&cp, &cp.bw.alloc_list, sched);
+ cp_cco_bw_alloc_add (&ctx.cp, &ctx.cp.bw.alloc_list, sched);
slab_release (sched);
}
/* Fill the beacon data share memory */
- cp_beacon_fill (&cp, &beacon);
+ cp_beacon_fill (&ctx.cp, &beacon);
test_suite_begin (test, "Beacon generation 2");
test_case_begin (test, "fill share memory 2");
@@ -554,9 +548,7 @@ test_suite_beacon__beacon_generation (test_t test)
test_fail_unless (beacon.bmis.nps.ns == ns);
}
test_end;
-
- cp_cco_bw_uninit (&cp);
- cp_cco_region_uninit (&cp);
+ test_beacon_uninit (&ctx);
}
void
@@ -564,53 +556,32 @@ test_case_beacon_snid_change_cco (test_t test)
{
uint snid;
cp_net_t *net;
- mac_config_t mac_config;
- cl_t cl;
- sar_t sar;
- bsu_aclf_t aclf;
+ test_beacon_t ctx;
test_case_begin (test, "CCo");
+ test_beacon_init (&ctx);
+ ctx.cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.last_countdown_date = 0;
- /* Configure the test. */
- memset (&cp, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
- memset (&cl, 0, sizeof (cl_t));
- memset (&sar, 0, sizeof (sar_t));
-
- *((bsu_aclf_frequency_t*) &aclf.frequency) = BSU_ACLF_FREQ_50HZ;
- *((bsu_aclf_bp_t*) &aclf.beacon_period_theo_tck) = BSU_ACLF_BP_50HZ_TCK;
- aclf.beacon_period_tck = aclf.beacon_period_theo_tck;
- cp.bsu_aclf = &aclf;
-
- cp_sta_mgr_init (&cp);
- cp_beacon_init (&cp);
-
- cp.mac_config = &mac_config;
- cp.cl = &cl;
- cp.sar = &sar;
- cp.mac_store = mac_store_init();
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
-
- net = cp_sta_mgr_add_avln (&cp, 0xA, 1);
- cp_sta_own_data_set_snid (&cp, 0xA);
- cp_sta_own_data_set_tei (&cp, 1);
- cp_sta_mgr_set_our_avln (&cp, net);
- cp_sta_own_data_set_cco_status (&cp, true);
- cp_sta_own_data_set_mac_address (&cp, 0x123456789ABCull);
+ net = cp_sta_mgr_add_avln (&ctx.cp, 0xA, 1);
+ cp_sta_own_data_set_snid (&ctx.cp, 0xA);
+ cp_sta_own_data_set_tei (&ctx.cp, 1);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net);
+ cp_sta_own_data_set_cco_status (&ctx.cp, true);
+ cp_sta_own_data_set_mac_address (&ctx.cp, 0x123456789ABCull);
test_begin (test, "Change SNID")
{
/* Process the test. */
- test_fail_unless (cp.beacon.snids.snid == 0);
- test_fail_unless (cp.beacon.snids.snidcd == 0);
+ test_fail_unless (ctx.cp.beacon.snids.snid == 0);
+ test_fail_unless (ctx.cp.beacon.snids.snidcd == 0);
snid = 1;
- cp_beacon_change_snid (&cp, snid);
+ cp_beacon_change_snid (&ctx.cp, snid);
- test_fail_unless (cp.beacon.snids.snid == snid);
- test_fail_unless (cp.beacon.snids.snidcd == CP_BEACON_COUNTDOWN_SNID);
+ test_fail_unless (ctx.cp.beacon.snids.snid == snid);
+ test_fail_unless (ctx.cp.beacon.snids.snidcd == CP_BEACON_COUNTDOWN_SNID);
}
test_end;
@@ -624,53 +595,51 @@ test_case_beacon_snid_change_cco (test_t test)
set_init (&set_schedules, cp_cco_bw_alloc_less);
set_init (&set_regions, cp_cco_region_alloc_less);
- cp_cco_region_init (&cp);
- cp_cco_bw_init (&cp);
+ cp_cco_region_init (&ctx.cp);
+ cp_cco_bw_init (&ctx.cp);
/* Regions. */
- region = cp_cco_region_alloc_init (&cp);
+ region = cp_cco_region_alloc_init (&ctx.cp);
region->type = CP_BEACON_REGION_TYPE_SHARED_CSMA;
region->end_time_atu = 3907;
- cp_cco_region_alloc_add (&cp, &cp.region.region_list, region);
+ cp_cco_region_alloc_add (&ctx.cp, &ctx.cp.region.region_list, region);
slab_release (region);
/* Schedules. */
- alloc = cp_cco_bw_alloc_init (&cp);
+ alloc = cp_cco_bw_alloc_init (&ctx.cp);
alloc->pscd = 7;
alloc->cscd = 7;
alloc->stpf = false;
alloc->glid = 0x45;
alloc->end_time_atu = 3907;
alloc->persistence = CP_CCO_BW_ALLOC_PERSISTENCE_PERSISTENT;
- cp_cco_bw_alloc_add (&cp, &cp.bw.alloc_list, alloc);
+ cp_cco_bw_alloc_add (&ctx.cp, &ctx.cp.bw.alloc_list, alloc);
slab_release (alloc);
- cp_beacon_fill (&cp, &beacon);
+ cp_beacon_fill (&ctx.cp, &beacon);
test_fail_unless (beacon.bmis.change_snid.present == true);
- test_fail_unless (beacon.bmis.change_snid.snidccd == cp.beacon.snids.snidcd);
- test_fail_unless (beacon.bmis.change_snid.new_snid == cp.beacon.snids.snid);
+ test_fail_unless (beacon.bmis.change_snid.snidccd == ctx.cp.beacon.snids.snidcd);
+ test_fail_unless (beacon.bmis.change_snid.new_snid == ctx.cp.beacon.snids.snid);
- cp_cco_bw_alloc_clean (&cp, &set_schedules);
- cp_cco_region_alloc_clean (&cp, &set_regions);
+ cp_cco_bw_alloc_clean (&ctx.cp, &set_schedules);
+ cp_cco_region_alloc_clean (&ctx.cp, &set_regions);
- cp_beacon_sta_compute_schedules (&cp, &beacon);
- alloc = cp_cco_bw_alloc_get_first (&cp, &cp.bw.alloc_list);
+ cp_beacon_sta_compute_schedules (&ctx.cp, &beacon);
+ alloc = cp_cco_bw_alloc_get_first (&ctx.cp, &ctx.cp.bw.alloc_list);
test_fail_unless (alloc->persistence ==
CP_CCO_BW_ALLOC_PERSISTENCE_PERSISTENT);
- alloc = cp_cco_bw_alloc_get_next (&cp, &cp.bw.alloc_list, alloc);
+ alloc = cp_cco_bw_alloc_get_next (&ctx.cp, &ctx.cp.bw.alloc_list, alloc);
test_fail_unless (!alloc);
- cp_cco_region_alloc_clean (&cp, &set_regions);
- cp_cco_bw_alloc_clean (&cp, &set_schedules);
- cp_cco_bw_uninit (&cp);
- cp_cco_region_uninit (&cp);
+ cp_cco_region_alloc_clean (&ctx.cp, &set_regions);
+ cp_cco_bw_alloc_clean (&ctx.cp, &set_schedules);
+ cp_cco_bw_uninit (&ctx.cp);
+ cp_cco_region_uninit (&ctx.cp);
}
test_end;
/* Uninit all the data. */
- cp_beacon_uninit (&cp);
- cp_sta_mgr_uninit (&cp);
- mac_store_uninit (cp.mac_store);
+ test_beacon_uninit (&ctx);
}
@@ -682,172 +651,137 @@ test_case_beacon_snid_change_sta (test_t test)
test_begin (test, "Beacon reception")
{
bsu_beacon_t *beacon;
- mac_config_t mac_config;
- cl_t cl;
- sar_t sar;
cp_net_t *net;
- bsu_aclf_t aclf;
cp_sta_own_data_t *own;
- uint phy = 0;
+ test_beacon_t ctx;
+ test_beacon_init (&ctx);
/** Init the context. */
- memset (&mac_config, 0, sizeof (mac_config_t));
- memset (&cl, 0, sizeof (cl_t));
- memset (&sar, 0, sizeof (sar_t));
- cp.mac_config = &mac_config;
- cp.cl = &cl;
- cp.sar = &sar;
- cp.phy = (phy_t *) &phy;
- cp.bsu_aclf = &aclf;
- cp.mac_store = mac_store_init ();
- cp_sta_mgr_init (&cp);
- cp_beacon_init (&cp);
- cp_cco_bw_init (&cp);
- cp_cco_region_init (&cp);
- cp.bsu_aclf->beacon_period_tck = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
+ ctx.cp.bsu_aclf->beacon_period_tck = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.last_countdown_date = 0;
/* Configure station own data. */
- net = cp_sta_mgr_add_avln (&cp, 0, 1);
- cp_sta_own_data_set_tei (&cp, 2);
- cp_sta_own_data_set_mac_address (&cp, 0x23456789abcull);
- cp_sta_mgr_set_our_avln (&cp, net);
- own = cp_sta_mgr_get_sta_own_data (&cp);
+ net = cp_sta_mgr_add_avln (&ctx.cp, 0, 1);
+ cp_sta_own_data_set_tei (&ctx.cp, 2);
+ cp_sta_own_data_set_mac_address (&ctx.cp, 0x23456789abcull);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net);
+ own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
own->nid_track = 1;
own->tei_track = 1;
/** Check snid default values. */
- test_fail_unless (cp.beacon.snids.snid == 0);
- test_fail_unless (cp.beacon.snids.snidcd == 0);
- test_fail_unless (cp_net_get_snid (&cp, net) == 0x0);
- test_fail_unless (cp_sta_own_data_get_snid (&cp) == 0x0);
+ test_fail_unless (ctx.cp.beacon.snids.snid == 0);
+ test_fail_unless (ctx.cp.beacon.snids.snidcd == 0);
+ test_fail_unless (cp_net_get_snid (&ctx.cp, net) == 0x0);
+ test_fail_unless (cp_sta_own_data_get_snid (&ctx.cp) == 0x0);
/** Create a central beacon. */
beacon = test_new_beacon ();
beacon->bmis.change_snid.present = true;
beacon->bmis.change_snid.new_snid = 0xC;
beacon->bmis.change_snid.snidccd = 3;
- cp_beacon_receive (&cp, beacon);
- cp_beacon_get_and_process_beacon (&cp);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
/** Check snid values are taken. */
- test_fail_unless (cp.beacon.snids.snid == 0xC);
- test_fail_unless (cp.beacon.snids.snidcd == 3);
- test_fail_unless (cp_net_get_snid (&cp, net) == 0x0);
- test_fail_unless (cp_sta_own_data_get_snid (&cp) == 0x0);
+ test_fail_unless (ctx.cp.beacon.snids.snid == 0xC);
+ test_fail_unless (ctx.cp.beacon.snids.snidcd == 3);
+ test_fail_unless (cp_net_get_snid (&ctx.cp, net) == 0x0);
+ test_fail_unless (cp_sta_own_data_get_snid (&ctx.cp) == 0x0);
/** Create the next beacon (countdown decreased). */
beacon = test_new_beacon ();
beacon->bmis.change_snid.snidccd = 2;
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
+ ctx.cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.last_countdown_date = 0;
/** launch the test. */
- cp_beacon_receive (&cp, beacon);
- cp_beacon_get_and_process_beacon (&cp);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
/** Check countdown. */
- test_fail_unless (cp.beacon.snids.snid == 0xC);
- test_fail_unless (cp.beacon.snids.snidcd == 2);
- test_fail_unless (cp_net_get_snid (&cp, net) == 0x0);
- test_fail_unless (cp_sta_own_data_get_snid (&cp) == 0x0);
+ test_fail_unless (ctx.cp.beacon.snids.snid == 0xC);
+ test_fail_unless (ctx.cp.beacon.snids.snidcd == 2);
+ test_fail_unless (cp_net_get_snid (&ctx.cp, net) == 0x0);
+ test_fail_unless (cp_sta_own_data_get_snid (&ctx.cp) == 0x0);
/** Create the next beacon (countdown decreased). */
beacon = test_new_beacon ();
beacon->bmis.change_snid.snidccd = 1;
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
+ ctx.cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.last_countdown_date = 0;
/** launch the test. */
- cp_beacon_receive (&cp, beacon);
- cp_beacon_get_and_process_beacon (&cp);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
/** Check countdown. */
- test_fail_unless (cp.beacon.snids.snid == 0xC);
- test_fail_unless (cp.beacon.snids.snidcd == 1);
- test_fail_unless (cp_net_get_snid (&cp, net) == 0x0);
- test_fail_unless (cp_sta_own_data_get_snid (&cp) == 0x0);
+ test_fail_unless (ctx.cp.beacon.snids.snid == 0xC);
+ test_fail_unless (ctx.cp.beacon.snids.snidcd == 1);
+ test_fail_unless (cp_net_get_snid (&ctx.cp, net) == 0x0);
+ test_fail_unless (cp_sta_own_data_get_snid (&ctx.cp) == 0x0);
/* Create the beacon. */
beacon = test_new_beacon ();
beacon->bmis.change_snid.present = false;
beacon->bmis.nbe--;
beacon->params.rx_parameters.snid = 0xC;
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
+ ctx.cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.last_countdown_date = 0;
/* launch the test. */
- cp_beacon_receive (&cp, beacon);
- cp_beacon_get_and_process_beacon (&cp);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
/** Check new snid is 0xC. */
- test_fail_unless (cp.beacon.snids.snid == 0xC);
- test_fail_unless (cp.beacon.snids.snidcd == 0);
- test_fail_unless (cp_net_get_snid (&cp, net) == 0xC);
- test_fail_unless (cp_sta_own_data_get_snid (&cp) == 0xC);
+ test_fail_unless (ctx.cp.beacon.snids.snid == 0xC);
+ test_fail_unless (ctx.cp.beacon.snids.snidcd == 0);
+ test_fail_unless (cp_net_get_snid (&ctx.cp, net) == 0xC);
+ test_fail_unless (cp_sta_own_data_get_snid (&ctx.cp) == 0xC);
- cp_beacon_uninit (&cp);
- cp_sta_mgr_uninit (&cp);
- cp_cco_bw_uninit (&cp);
- cp_cco_region_uninit (&cp);
- dbg_check (mac_store_sta_remove (cp.mac_store, 1));
- mac_store_uninit (cp.mac_store);
+ dbg_check (mac_store_sta_remove (ctx.cp.mac_store, 1));
+ test_beacon_uninit (&ctx);
}
test_end;
test_begin (test, "Beacon missed")
{
- mac_config_t mac_config;
- cl_t cl;
- sar_t sar;
+ test_beacon_t ctx;
cp_net_t *net;
cp_cco_region_alloc_t *region;
cp_cco_bw_alloc_t *alloc;
-
- memset (&mac_config, 0, sizeof (mac_config_t));
- memset (&cl, 0, sizeof (cl_t));
- memset (&sar, 0, sizeof (sar_t));
-
- cp_cco_region_init (&cp);
- cp_cco_bw_init (&cp);
-
+ test_beacon_init (&ctx);
/* Regions. */
- region = cp_cco_region_alloc_init (&cp);
+ region = cp_cco_region_alloc_init (&ctx.cp);
region->type = CP_BEACON_REGION_TYPE_SHARED_CSMA;
region->end_time_atu = 3907;
- cp_cco_region_alloc_add (&cp, &cp.region.region_list, region);
+ cp_cco_region_alloc_add (&ctx.cp, &ctx.cp.region.region_list, region);
slab_release (region);
/* Schedules. */
- alloc = cp_cco_bw_alloc_init (&cp);
+ alloc = cp_cco_bw_alloc_init (&ctx.cp);
alloc->stpf = false;
alloc->glid = 0x45;
alloc->end_time_atu = 3907;
alloc->persistence = CP_CCO_BW_ALLOC_PERSISTENCE_NOT_PERSISTENT;
- cp_cco_bw_alloc_add (&cp, &cp.bw.alloc_list, alloc);
+ cp_cco_bw_alloc_add (&ctx.cp, &ctx.cp.bw.alloc_list, alloc);
slab_release (alloc);
- cp_sta_mgr_init (&cp);
- cp_beacon_init (&cp);
-
/* Configure station own data. */
- net = cp_sta_mgr_add_avln (&cp, 1, 1);
- cp_sta_own_data_set_tei (&cp, 2);
- cp_sta_own_data_set_mac_address (&cp, 0x23456789abcull);
- cp_sta_mgr_set_our_avln (&cp, net);
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
+ net = cp_sta_mgr_add_avln (&ctx.cp, 1, 1);
+ cp_sta_own_data_set_tei (&ctx.cp, 2);
+ cp_sta_own_data_set_mac_address (&ctx.cp, 0x23456789abcull);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net);
+ ctx.cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.last_countdown_date = 0;
/* Configure the test. */
- cp.beacon.snids.snidcd = 2;
- cp.beacon.snids.snid = 0xc;
+ ctx.cp.beacon.snids.snidcd = 2;
+ ctx.cp.beacon.snids.snid = 0xc;
- cp_beacon_beacon_not_received (&cp);
+ cp_beacon_beacon_not_received (&ctx.cp);
- test_fail_unless (cp.beacon.snids.snidcd == 1);
- test_fail_unless (cp.beacon.snids.snid == 0xc);
+ test_fail_unless (ctx.cp.beacon.snids.snidcd == 1);
+ test_fail_unless (ctx.cp.beacon.snids.snid == 0xc);
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
+ ctx.cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.last_countdown_date = 0;
- cp_beacon_beacon_not_received (&cp);
+ cp_beacon_beacon_not_received (&ctx.cp);
- test_fail_unless (cp.beacon.snids.snidcd == 0);
- test_fail_unless (cp.beacon.snids.snid == 0xc);
- test_fail_unless (cp_net_get_snid (&cp, net) == 0xC);
- test_fail_unless (cp_sta_own_data_get_snid (&cp) == 0xC);
+ test_fail_unless (ctx.cp.beacon.snids.snidcd == 0);
+ test_fail_unless (ctx.cp.beacon.snids.snid == 0xc);
+ test_fail_unless (cp_net_get_snid (&ctx.cp, net) == 0xC);
+ test_fail_unless (cp_sta_own_data_get_snid (&ctx.cp) == 0xC);
- cp_beacon_uninit (&cp);
- cp_sta_mgr_uninit (&cp);
- cp_cco_region_uninit (&cp);
- cp_cco_bw_uninit (&cp);
+ test_beacon_uninit (&ctx);
}
test_end;
}
@@ -868,38 +802,22 @@ test_case_beacon_hm_change_sta (test_t test)
test_begin (test, "Beacon reception")
{
+ test_beacon_t ctx;
bsu_beacon_t *beacon;
- mac_config_t mac_config;
- cl_t cl;
- sar_t sar;
cp_net_t *net;
- uint phy = 0;
- bsu_aclf_t aclf;
cp_sta_own_data_t *own;
/** Init the context. */
- memset (&mac_config, 0, sizeof (mac_config_t));
- memset (&cl, 0, sizeof (cl_t));
- memset (&sar, 0, sizeof (sar_t));
- cp.mac_config = &mac_config;
- cp.cl = &cl;
- cp.sar = &sar;
- cp.phy = (phy_t *) &phy;
- cp.mac_store = mac_store_init ();
- cp.bsu_aclf = &aclf;
- cp_sta_mgr_init (&cp);
- cp_beacon_init (&cp);
- cp_cco_bw_init (&cp);
- cp_cco_region_init (&cp);
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.bsu_aclf->beacon_period_tck = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
+ test_beacon_init (&ctx);
+ ctx.cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.bsu_aclf->beacon_period_tck = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.last_countdown_date = 0;
/** Configure station own data. */
- own = cp_sta_mgr_get_sta_own_data (&cp);
- net = cp_sta_mgr_add_avln (&cp, 0, 1);
- cp_sta_own_data_set_tei (&cp, 2);
- cp_sta_own_data_set_mac_address (&cp, 0x23456789abcull);
- cp_sta_mgr_set_our_avln (&cp, net);
- own = cp_sta_mgr_get_sta_own_data (&cp);
+ own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
+ net = cp_sta_mgr_add_avln (&ctx.cp, 0, 1);
+ cp_sta_own_data_set_tei (&ctx.cp, 2);
+ cp_sta_own_data_set_mac_address (&ctx.cp, 0x23456789abcull);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net);
+ own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
own->nid_track = 1;
own->tei_track = 1;
own->hybrid_mode = 0;
@@ -910,126 +828,110 @@ test_case_beacon_hm_change_sta (test_t test)
beacon->bmis.change_hm.hmccd = 3;
beacon->bmis.nbe = 4;
/** Check default values. */
- test_fail_unless (cp.beacon.hm.hm == 0);
- test_fail_unless (cp.beacon.hm.hmcd == 0);
+ test_fail_unless (ctx.cp.beacon.hm.hm == 0);
+ test_fail_unless (ctx.cp.beacon.hm.hmcd == 0);
test_fail_unless (own->hybrid_mode == 0);
/* launch the test. */
- cp_beacon_receive (&cp, beacon);
- cp_beacon_get_and_process_beacon (&cp);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
/** Check values are taken. */
- test_fail_unless (cp.beacon.hm.hm == 0x1);
- test_fail_unless (cp.beacon.hm.hmcd == 3);
+ test_fail_unless (ctx.cp.beacon.hm.hm == 0x1);
+ test_fail_unless (ctx.cp.beacon.hm.hmcd == 3);
test_fail_unless (own->hybrid_mode == 0);
/** Create the new beacon. */
beacon = test_new_beacon ();
beacon->bmis.change_hm.hmccd = 2;
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
+ ctx.cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.last_countdown_date = 0;
/** launch the test. */
- cp_beacon_receive (&cp, beacon);
- cp_beacon_get_and_process_beacon (&cp);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
/** Check values are taken. */
- test_fail_unless (cp.beacon.hm.hm == 0x1);
- test_fail_unless (cp.beacon.hm.hmcd == 2);
+ test_fail_unless (ctx.cp.beacon.hm.hm == 0x1);
+ test_fail_unless (ctx.cp.beacon.hm.hmcd == 2);
test_fail_unless (own->hybrid_mode == 0);
/** Create the new beacon. */
beacon = test_new_beacon ();
beacon->bmis.change_hm.hmccd = 1;
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
+ ctx.cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.last_countdown_date = 0;
/* launch the test. */
- cp_beacon_receive (&cp, beacon);
- cp_beacon_get_and_process_beacon (&cp);
- test_fail_unless (cp.beacon.hm.hm == 0x1);
- test_fail_unless (cp.beacon.hm.hmcd == 1);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ test_fail_unless (ctx.cp.beacon.hm.hm == 0x1);
+ test_fail_unless (ctx.cp.beacon.hm.hmcd == 1);
test_fail_unless (own->hybrid_mode == 0);
/* Create the beacon. */
beacon = test_new_beacon ();
beacon->bmis.change_hm.present = false;
beacon->bmis.nbe = 3;
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
+ ctx.cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.last_countdown_date = 0;
/* launch the test. */
- cp_beacon_receive (&cp, beacon);
- cp_beacon_get_and_process_beacon (&cp);
- test_fail_unless (cp.beacon.hm.hm == 0x1);
- test_fail_unless (cp.beacon.hm.hmcd == 0);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ test_fail_unless (ctx.cp.beacon.hm.hm == 0x1);
+ test_fail_unless (ctx.cp.beacon.hm.hmcd == 0);
test_fail_unless (own->hybrid_mode == 0x1);
- cp_beacon_uninit (&cp);
- cp_sta_mgr_uninit (&cp);
- cp_cco_bw_uninit (&cp);
- cp_cco_region_uninit (&cp);
- dbg_check (mac_store_sta_remove (cp.mac_store, 1));
- mac_store_uninit (cp.mac_store);
+ dbg_check (mac_store_sta_remove (ctx.cp.mac_store, 1));
+ test_beacon_uninit (&ctx);
}
test_end;
test_begin (test, "Beacon missed")
{
- mac_config_t mac_config;
- cl_t cl;
- sar_t sar;
+ test_beacon_t ctx;
cp_net_t *net;
cp_cco_region_alloc_t *region;
cp_cco_bw_alloc_t *alloc;
cp_sta_own_data_t *own;
-
- memset (&mac_config, 0, sizeof (mac_config_t));
- memset (&cl, 0, sizeof (cl_t));
- memset (&sar, 0, sizeof (sar_t));
-
- cp_cco_region_init (&cp);
- cp_cco_bw_init (&cp);
-
+ test_beacon_init (&ctx);
/* Regions. */
- region = cp_cco_region_alloc_init (&cp);
+ region = cp_cco_region_alloc_init (&ctx.cp);
region->type = CP_BEACON_REGION_TYPE_SHARED_CSMA;
region->end_time_atu = 3907;
- cp_cco_region_alloc_add (&cp, &cp.region.region_list, region);
+ cp_cco_region_alloc_add (&ctx.cp, &ctx.cp.region.region_list, region);
slab_release (region);
/* Schedules. */
- alloc = cp_cco_bw_alloc_init (&cp);
+ alloc = cp_cco_bw_alloc_init (&ctx.cp);
alloc->stpf = false;
alloc->glid = 0x45;
alloc->end_time_atu = 3907;
alloc->persistence = CP_CCO_BW_ALLOC_PERSISTENCE_NOT_PERSISTENT;
- cp_cco_bw_alloc_add (&cp, &cp.bw.alloc_list, alloc);
+ cp_cco_bw_alloc_add (&ctx.cp, &ctx.cp.bw.alloc_list, alloc);
slab_release (alloc);
- cp_sta_mgr_init (&cp);
- cp_beacon_init (&cp);
+ cp_sta_mgr_init (&ctx.cp);
+ cp_beacon_init (&ctx.cp);
/* Configure station own data. */
- own = cp_sta_mgr_get_sta_own_data (&cp);
- net = cp_sta_mgr_add_avln (&cp, 0, 1);
- cp_sta_own_data_set_tei (&cp, 2);
- cp_sta_own_data_set_mac_address (&cp, 0x23456789abcull);
- cp_sta_mgr_set_our_avln (&cp, net);
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
+ own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
+ net = cp_sta_mgr_add_avln (&ctx.cp, 0, 1);
+ cp_sta_own_data_set_tei (&ctx.cp, 2);
+ cp_sta_own_data_set_mac_address (&ctx.cp, 0x23456789abcull);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net);
+ ctx.cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.last_countdown_date = 0;
/* Configure the test. */
- cp.beacon.hm.hmcd = 2;
- cp.beacon.hm.hm = 0x1;
+ ctx.cp.beacon.hm.hmcd = 2;
+ ctx.cp.beacon.hm.hm = 0x1;
- cp_beacon_beacon_not_received (&cp);
+ cp_beacon_beacon_not_received (&ctx.cp);
- test_fail_unless (cp.beacon.hm.hmcd == 1);
- test_fail_unless (cp.beacon.hm.hm == 0x1);
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
+ test_fail_unless (ctx.cp.beacon.hm.hmcd == 1);
+ test_fail_unless (ctx.cp.beacon.hm.hm == 0x1);
+ ctx.cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.last_countdown_date = 0;
- cp_beacon_beacon_not_received (&cp);
+ cp_beacon_beacon_not_received (&ctx.cp);
- test_fail_unless (cp.beacon.hm.hmcd == 0);
- test_fail_unless (cp.beacon.hm.hm == 0x1);
+ test_fail_unless (ctx.cp.beacon.hm.hmcd == 0);
+ test_fail_unless (ctx.cp.beacon.hm.hm == 0x1);
test_fail_unless (own->hybrid_mode == 0x1);
- cp_beacon_uninit (&cp);
- cp_sta_mgr_uninit (&cp);
- cp_cco_region_uninit (&cp);
- cp_cco_bw_uninit (&cp);
+ test_beacon_uninit (&ctx);
}
test_end;
}
@@ -1047,58 +949,43 @@ test_case_beacon_eks_change_cco (test_t test)
{
cp_key_t nek;
cp_net_t *net;
- mac_config_t mac_config;
- cl_t cl;
- sar_t sar;
-
+ test_beacon_t ctx;
test_case_begin (test, "CCo");
/** Configure the context. */
- memset (&mac_config, 0, sizeof (mac_config_t));
- memset (&cl, 0, sizeof (cl_t));
- memset (&sar, 0, sizeof (sar_t));
-
- cp_sta_mgr_init (&cp);
- cp_beacon_init (&cp);
-
- cp.mac_config = &mac_config;
- cp.cl = &cl;
- cp.sar = &sar;
- cp.mac_store = mac_store_init();
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
+ test_beacon_init (&ctx);
+ ctx.cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.last_countdown_date = 0;
/** Configure our station. */
- net = cp_sta_mgr_add_avln (&cp, 0xA, 1);
- cp_sta_own_data_set_tei (&cp, 1);
- cp_sta_mgr_set_our_avln (&cp, net);
- cp_sta_own_data_set_cco_status (&cp, true);
- cp_sta_own_data_set_mac_address (&cp, 0x123456789ABCull);
+ net = cp_sta_mgr_add_avln (&ctx.cp, 0xA, 1);
+ cp_sta_own_data_set_tei (&ctx.cp, 1);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net);
+ cp_sta_own_data_set_cco_status (&ctx.cp, true);
+ cp_sta_own_data_set_mac_address (&ctx.cp, 0x123456789ABCull);
test_begin (test, "Change EKS")
{
uint i;
/** Check default values. */
- test_fail_unless (cp.beacon.eks.kccd == 0);
- test_fail_unless (cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
- test_fail_unless (cp.beacon.eks.new_eks == 0);
+ test_fail_unless (ctx.cp.beacon.eks.kccd == 0);
+ test_fail_unless (ctx.cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
+ test_fail_unless (ctx.cp.beacon.eks.new_eks == 0);
/** Change nek. */
for (i = 0; i < COUNT (nek.key); i++)
nek.key[i] = i;
- cp_beacon_change_nek (&cp, MAC_EKS_MIN, nek, false /* not now*/);
+ cp_beacon_change_nek (&ctx.cp, MAC_EKS_MIN, nek, false /* not now*/);
/** Check new values. */
- test_fail_unless (cp.beacon.eks.new_eks == MAC_EKS_MIN);
- test_fail_unless (cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
- test_fail_unless (cp.beacon.eks.kccd == CP_BEACON_COUNTDOWN_EKS);
+ test_fail_unless (ctx.cp.beacon.eks.new_eks == MAC_EKS_MIN);
+ test_fail_unless (ctx.cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
+ test_fail_unless (ctx.cp.beacon.eks.kccd == CP_BEACON_COUNTDOWN_EKS);
}
test_end;
/* Uninit all the data. */
- cp_beacon_uninit (&cp);
- cp_sta_mgr_uninit (&cp);
- mac_store_uninit (cp.mac_store);
+ test_beacon_uninit (&ctx);
}
void
@@ -1109,37 +996,18 @@ test_case_beacon_eks_change_sta (test_t test)
test_begin (test, "Beacon reception")
{
bsu_beacon_t *beacon;
- mac_config_t mac_config;
- cl_t cl;
- sar_t sar;
cp_net_t *net;
- uint phy = 0;
- bsu_aclf_t aclf;
cp_sta_own_data_t *own;
+ test_beacon_t ctx;
/** Init the context. */
- memset (&mac_config, 0, sizeof (mac_config_t));
- memset (&cl, 0, sizeof (cl_t));
- memset (&sar, 0, sizeof (sar_t));
- cp.mac_config = &mac_config;
- cp.cl = &cl;
- cp.sar = &sar;
- cp.phy = (phy_t *) &phy;
- cp.bsu_aclf = &aclf;
- cp.mac_store = mac_store_init ();
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.bsu_aclf->beacon_period_tck = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
- cp_sta_mgr_init (&cp);
- cp_beacon_init (&cp);
- cp_cco_bw_init (&cp);
- cp_cco_region_init (&cp);
+ test_beacon_init (&ctx);
/** Configure station own data. */
- own = cp_sta_mgr_get_sta_own_data (&cp);
- net = cp_sta_mgr_add_avln (&cp, 0, 1);
- cp_sta_own_data_set_tei (&cp, 2);
- cp_sta_own_data_set_mac_address (&cp, 0x23456789abcull);
- cp_sta_mgr_set_our_avln (&cp, net);
- own = cp_sta_mgr_get_sta_own_data (&cp);
+ own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
+ net = cp_sta_mgr_add_avln (&ctx.cp, 0, 1);
+ cp_sta_own_data_set_tei (&ctx.cp, 2);
+ cp_sta_own_data_set_mac_address (&ctx.cp, 0x23456789abcull);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net);
+ own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
own->nid_track = 1;
own->tei_track = 1;
/** Create a central beacon. */
@@ -1150,134 +1018,118 @@ test_case_beacon_eks_change_sta (test_t test)
beacon->bmis.eks.new_eks = MAC_EKS_MIN + 1;
mac_eks_t ref_eks_current = MAC_EKS_MIN + 2;
mac_eks_t ref_eks_next = MAC_EKS_MIN + 3;
- mac_config.nek[bsu_nek_index_current (INVALID_PTR)].eks =
+ ctx.mac_config.nek[bsu_nek_index_current (INVALID_PTR)].eks =
ref_eks_current;
- mac_config.nek[bsu_nek_index_next (INVALID_PTR)].eks = ref_eks_next;
+ ctx.mac_config.nek[bsu_nek_index_next (INVALID_PTR)].eks = ref_eks_next;
/** Check default values. */
- test_fail_unless (cp.beacon.eks.kccd == 0);
- test_fail_unless (cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
- test_fail_unless (cp.beacon.eks.new_eks == MAC_EKS_MIN);
+ test_fail_unless (ctx.cp.beacon.eks.kccd == 0);
+ test_fail_unless (ctx.cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
+ test_fail_unless (ctx.cp.beacon.eks.new_eks == MAC_EKS_MIN);
/* launch the test. */
- cp_beacon_receive (&cp, beacon);
- cp_beacon_get_and_process_beacon (&cp);
- test_fail_unless (cp.beacon.eks.kccd == 2);
- test_fail_unless (cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
- test_fail_unless (cp.beacon.eks.new_eks == MAC_EKS_MIN + 1);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ test_fail_unless (ctx.cp.beacon.eks.kccd == 2);
+ test_fail_unless (ctx.cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
+ test_fail_unless (ctx.cp.beacon.eks.new_eks == MAC_EKS_MIN + 1);
test_fail_unless (
- mac_config.nek[bsu_nek_index_current (INVALID_PTR)].eks ==
+ ctx.mac_config.nek[bsu_nek_index_current (INVALID_PTR)].eks ==
ref_eks_current);
- test_fail_unless (mac_config.nek[bsu_nek_index_next (INVALID_PTR)].eks ==
+ test_fail_unless (ctx.mac_config.nek[bsu_nek_index_next (INVALID_PTR)].eks ==
ref_eks_next);
/* Create the beacon. */
beacon = test_new_beacon ();
beacon->bmis.eks.kccd = 1;
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
+ ctx.cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.last_countdown_date = 0;
/* launch the test. */
- cp_beacon_receive (&cp, beacon);
- cp_beacon_get_and_process_beacon (&cp);
- test_fail_unless (cp.beacon.eks.kccd == 1);
- test_fail_unless (cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
- test_fail_unless (cp.beacon.eks.new_eks == MAC_EKS_MIN + 1);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ test_fail_unless (ctx.cp.beacon.eks.kccd == 1);
+ test_fail_unless (ctx.cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
+ test_fail_unless (ctx.cp.beacon.eks.new_eks == MAC_EKS_MIN + 1);
test_fail_unless (
- mac_config.nek[bsu_nek_index_current (INVALID_PTR)].eks ==
+ ctx.mac_config.nek[bsu_nek_index_current (INVALID_PTR)].eks ==
ref_eks_current);
- test_fail_unless (mac_config.nek[bsu_nek_index_next (INVALID_PTR)].eks ==
+ test_fail_unless (ctx.mac_config.nek[bsu_nek_index_next (INVALID_PTR)].eks ==
ref_eks_next);
/* Create the beacon. */
beacon = test_new_beacon ();
beacon->bmis.eks.present = false;
beacon->bmis.nbe--;
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
+ ctx.cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.last_countdown_date = 0;
/* launch the test. */
- cp_beacon_receive (&cp, beacon);
- cp_beacon_get_and_process_beacon (&cp);
- test_fail_unless (cp.beacon.eks.kccd == 0);
- test_fail_unless (cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NB);
- test_fail_unless (cp.beacon.eks.new_eks == MAC_EKS_MIN + 1);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ test_fail_unless (ctx.cp.beacon.eks.kccd == 0);
+ test_fail_unless (ctx.cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NB);
+ test_fail_unless (ctx.cp.beacon.eks.new_eks == MAC_EKS_MIN + 1);
test_fail_unless (
- mac_config.nek[bsu_nek_index_current (INVALID_PTR)].eks ==
+ ctx.mac_config.nek[bsu_nek_index_current (INVALID_PTR)].eks ==
ref_eks_current);
- test_fail_unless (mac_config.nek[bsu_nek_index_next (INVALID_PTR)].eks ==
+ test_fail_unless (ctx.mac_config.nek[bsu_nek_index_next (INVALID_PTR)].eks ==
MAC_EKS_CLEAR);
- cp_beacon_uninit (&cp);
- cp_sta_mgr_uninit (&cp);
- dbg_check (mac_store_sta_remove (cp.mac_store, 1));
- mac_store_uninit (cp.mac_store);
- cp_cco_region_uninit (&cp);
- cp_cco_bw_uninit (&cp);
+ dbg_check (mac_store_sta_remove (ctx.cp.mac_store, 1));
+ test_beacon_uninit (&ctx);
}
test_end;
test_begin (test, "Beacon missed")
{
- mac_config_t mac_config;
- cl_t cl;
- sar_t sar;
cp_net_t *net;
cp_cco_region_alloc_t *region;
cp_cco_bw_alloc_t *alloc;
cp_sta_own_data_t *own;
-
- memset (&mac_config, 0, sizeof (mac_config_t));
- memset (&cl, 0, sizeof (cl_t));
- memset (&sar, 0, sizeof (sar_t));
-
- cp_cco_region_init (&cp);
- cp_cco_bw_init (&cp);
-
+ test_beacon_t ctx;
+ test_beacon_init (&ctx);
/* Regions. */
- region = cp_cco_region_alloc_init (&cp);
+ region = cp_cco_region_alloc_init (&ctx.cp);
region->type = CP_BEACON_REGION_TYPE_SHARED_CSMA;
region->end_time_atu = 3907;
- cp_cco_region_alloc_add (&cp, &cp.region.region_list, region);
+ cp_cco_region_alloc_add (&ctx.cp, &ctx.cp.region.region_list, region);
slab_release (region);
/* Schedules. */
- alloc = cp_cco_bw_alloc_init (&cp);
+ alloc = cp_cco_bw_alloc_init (&ctx.cp);
alloc->stpf = false;
alloc->glid = 0x45;
alloc->end_time_atu = 3907;
alloc->persistence = CP_CCO_BW_ALLOC_PERSISTENCE_NOT_PERSISTENT;
- cp_cco_bw_alloc_add (&cp, &cp.bw.alloc_list, alloc);
+ cp_cco_bw_alloc_add (&ctx.cp, &ctx.cp.bw.alloc_list, alloc);
slab_release (alloc);
- cp_sta_mgr_init (&cp);
- cp_beacon_init (&cp);
+ cp_sta_mgr_init (&ctx.cp);
+ cp_beacon_init (&ctx.cp);
/* Configure station own data. */
- own = cp_sta_mgr_get_sta_own_data (&cp);
- net = cp_sta_mgr_add_avln (&cp, 0, 1);
- cp_sta_own_data_set_tei (&cp, 2);
- cp_sta_own_data_set_mac_address (&cp, 0x23456789abcull);
- cp_sta_mgr_set_our_avln (&cp, net);
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
+ own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
+ net = cp_sta_mgr_add_avln (&ctx.cp, 0, 1);
+ cp_sta_own_data_set_tei (&ctx.cp, 2);
+ cp_sta_own_data_set_mac_address (&ctx.cp, 0x23456789abcull);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net);
+ ctx.cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.last_countdown_date = 0;
/* Configure the test. */
- cp.beacon.eks.kccd = 2;
- cp.beacon.eks.kbc = BSU_BEACON_EKS_KBC_NEK;
- cp.beacon.eks.new_eks = MAC_EKS_MIN + 1;
+ ctx.cp.beacon.eks.kccd = 2;
+ ctx.cp.beacon.eks.kbc = BSU_BEACON_EKS_KBC_NEK;
+ ctx.cp.beacon.eks.new_eks = MAC_EKS_MIN + 1;
- cp_beacon_beacon_not_received (&cp);
+ cp_beacon_beacon_not_received (&ctx.cp);
- test_fail_unless (cp.beacon.eks.kccd == 1);
- test_fail_unless (cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
- test_fail_unless (cp.beacon.eks.new_eks == MAC_EKS_MIN + 1);
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
+ test_fail_unless (ctx.cp.beacon.eks.kccd == 1);
+ test_fail_unless (ctx.cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
+ test_fail_unless (ctx.cp.beacon.eks.new_eks == MAC_EKS_MIN + 1);
+ ctx.cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.last_countdown_date = 0;
- cp_beacon_beacon_not_received (&cp);
+ cp_beacon_beacon_not_received (&ctx.cp);
- test_fail_unless (cp.beacon.eks.kccd == 0);
- test_fail_unless (cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NB);
- test_fail_unless (cp.beacon.eks.new_eks == MAC_EKS_MIN + 1);
+ test_fail_unless (ctx.cp.beacon.eks.kccd == 0);
+ test_fail_unless (ctx.cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NB);
+ test_fail_unless (ctx.cp.beacon.eks.new_eks == MAC_EKS_MIN + 1);
- cp_beacon_uninit (&cp);
- cp_sta_mgr_uninit (&cp);
- cp_cco_region_uninit (&cp);
- cp_cco_bw_uninit (&cp);
+ test_beacon_uninit (&ctx);
}
test_end;
}
@@ -1300,38 +1152,17 @@ test_suite_beacon_mac_address_bentry (test_t test)
test_begin (test, "Beacon reception")
{
bsu_beacon_t *beacon;
- mac_config_t mac_config;
- cl_t cl;
- sar_t sar;
cp_net_t *net;
- uint phy = 0;
- bsu_aclf_t aclf;
cp_sta_own_data_t *own;
+ test_beacon_t ctx;
/** Init the context. */
- memset (&mac_config, 0, sizeof (mac_config_t));
- memset (&cl, 0, sizeof (cl_t));
- memset (&sar, 0, sizeof (sar_t));
-
- cp.mac_config = &mac_config;
- cp.cl = &cl;
- cp.sar = &sar;
- cp.phy = (phy_t *) &phy;
- cp.bsu_aclf = &aclf;
- cp.mac_store = mac_store_init ();
- cp.beacon.countdown_limit_date = BSU_ACLF_BP_60HZ_TCK;
- cp.bsu_aclf->beacon_period_tck = BSU_ACLF_BP_60HZ_TCK;
- cp.beacon.last_countdown_date = 0;
- cp_sta_mgr_init (&cp);
- cp_beacon_init (&cp);
- cp_cco_bw_init (&cp);
- cp_cco_region_init (&cp);
-
+ test_beacon_init (&ctx);
/** Configure station own data. */
- own = cp_sta_mgr_get_sta_own_data (&cp);
- net = cp_sta_mgr_add_avln (&cp, 0, 1);
- cp_sta_own_data_set_tei (&cp, 2);
- cp_sta_own_data_set_mac_address (&cp, 0x23456789abcull);
- cp_sta_mgr_set_our_avln (&cp, net);
+ own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
+ net = cp_sta_mgr_add_avln (&ctx.cp, 0, 1);
+ cp_sta_own_data_set_tei (&ctx.cp, 2);
+ cp_sta_own_data_set_mac_address (&ctx.cp, 0x23456789abcull);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net);
own->nid_track = 1;
own->tei_track = 1;
own->cco_mac_addr_track = MAC_ZERO;
@@ -1339,9 +1170,9 @@ test_suite_beacon_mac_address_bentry (test_t test)
beacon = test_new_beacon ();
beacon->bmis.mac_address.present = false;
/* launch the test. */
- cp_beacon_receive (&cp, beacon);
- cp_beacon_get_and_process_beacon (&cp);
- cp_sta_t *cco = cp_net_get_cco (&cp, net);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ cp_sta_t *cco = cp_net_get_cco (&ctx.cp, net);
test_fail_unless (cco);
test_fail_unless (cp_sta_get_mac_address (cco) == MAC_BROADCAST);
test_fail_unless (cp_sta_get_cco_status (cco) == true);
@@ -1351,9 +1182,9 @@ test_suite_beacon_mac_address_bentry (test_t test)
beacon = test_new_beacon ();
beacon->bmis.mac_address.present = true;
beacon->bmis.mac_address.mac_address = 0x12345678abcull;
- cp_beacon_receive (&cp, beacon);
- cp_beacon_get_and_process_beacon (&cp);
- cco = cp_net_get_cco (&cp, net);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ cco = cp_net_get_cco (&ctx.cp, net);
test_fail_unless (cco);
/* The beacon is not processed. */
test_fail_unless (cp_sta_get_mac_address (cco)
@@ -1364,9 +1195,9 @@ test_suite_beacon_mac_address_bentry (test_t test)
beacon = test_new_beacon ();
beacon->bmis.mac_address.present = true;
beacon->bmis.mac_address.mac_address = 0x0013d7000001ull;
- cp_beacon_receive (&cp, beacon);
- cp_beacon_get_and_process_beacon (&cp);
- cco = cp_net_get_cco (&cp, net);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ cco = cp_net_get_cco (&ctx.cp, net);
test_fail_unless (cco);
test_fail_unless (cp_sta_get_mac_address (cco)
!= beacon->bmis.mac_address.mac_address);
@@ -1378,9 +1209,9 @@ test_suite_beacon_mac_address_bentry (test_t test)
beacon = test_new_beacon ();
beacon->bmis.mac_address.present = true;
beacon->bmis.mac_address.mac_address = 0x0013d7000001ull;
- cp_beacon_receive (&cp, beacon);
- cp_beacon_get_and_process_beacon (&cp);
- cco = cp_net_get_cco (&cp, net);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ cco = cp_net_get_cco (&ctx.cp, net);
test_fail_unless (cco);
test_fail_unless (cp_sta_get_mac_address (cco)
== beacon->bmis.mac_address.mac_address);
@@ -1391,23 +1222,17 @@ test_suite_beacon_mac_address_bentry (test_t test)
beacon = test_new_beacon ();
beacon->bmis.mac_address.present = true;
beacon->bmis.mac_address.mac_address = 0x12345678abcull;
- cp_beacon_receive (&cp, beacon);
- cp_beacon_get_and_process_beacon (&cp);
- cco = cp_net_get_cco (&cp, net);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ cco = cp_net_get_cco (&ctx.cp, net);
test_fail_unless (cco);
test_fail_unless (cp_sta_get_mac_address (cco) == 0x0013d7000001ull);
test_fail_unless (cp_sta_get_cco_status (cco) == true);
slab_release (cco);
- cp_beacon_uninit (&cp);
- cp_sta_mgr_uninit (&cp);
- dbg_check (mac_store_sta_remove (cp.mac_store, 1));
- mac_store_uninit (cp.mac_store);
-
- cp_cco_region_uninit (&cp);
- cp_cco_bw_uninit (&cp);
+ dbg_check (mac_store_sta_remove (ctx.cp.mac_store, 1));
+ test_beacon_uninit (&ctx);
}
test_end;
-
}
void
@@ -1466,53 +1291,48 @@ test_suite_beacon_no_net (test_t t)
void
test_suite_beacon_spoc_update (test_t test)
{
- cp_t cp;
- mac_config_t mc;
- cp.mac_config = &mc;
- mac_config_init (cp.mac_config);
- cp_beacon_init (&cp);
- cp_sta_mgr_init (&cp);
- cp_cco_region_init (&cp);
- cp_cco_bw_init (&cp);
+ test_beacon_t ctx;
+ test_beacon_init (&ctx);
test_suite_begin (test, "SPOC update");
test_case_begin (test, "Frequency error invalid and valid");
test_begin (test, "SPOC only updated if F.E. is valid")
{
- cp_sta_own_data_t *own = cp_sta_mgr_get_sta_own_data (&cp);
- cp.beacon.spoc_update_interval_ms = 1;
+ cp_sta_own_data_t *own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
+ ctx.cp.beacon.spoc_update_interval_ms = 1;
bsu_beacon_t *beacon = test_new_beacon ();
- cp_sta_mgr_add_avln (&cp, beacon->params.rx_parameters.snid,
+ cp_sta_mgr_add_avln (&ctx.cp, beacon->params.rx_parameters.snid,
beacon->vf.nid);
- cp.beacon.spoc_update_date = phy_date () - 1;
- cp_sta_own_data_set_nid (&cp, beacon->vf.nid);
+ ctx.cp.beacon.spoc_update_date = phy_date () - 1;
+ cp_sta_own_data_set_nid (&ctx.cp, beacon->vf.nid);
own->nid_track = beacon->vf.nid;
own->tei_track = beacon->vf.stei;
+ beacon->params.rx_parameters.snid =
+ cp_sta_own_data_get_snid (&ctx.cp);
/* Process a received beacon with a frequency error invalid. */
- cp_beacon_receive (&cp, beacon);
- cp_beacon_get_and_process_beacon (&cp);
- test_fail_unless (!cp.beacon.spoc_updated);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ test_fail_unless (!ctx.cp.beacon.spoc_updated);
/* This received beacon has a valid frequency error, SPOC should be
* updated. */
beacon = test_new_beacon ();
beacon->params.frequency_error_valid = true;
- cp.beacon.spoc_update_date = phy_date () - 1;
- cp_beacon_receive (&cp, beacon);
- cp_beacon_get_and_process_beacon (&cp);
- test_fail_unless (cp.beacon.spoc_updated);
+ beacon->params.rx_parameters.snid =
+ cp_sta_own_data_get_snid (&ctx.cp);
+ ctx.cp.beacon.spoc_update_date = phy_date () - 1;
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ test_fail_unless (ctx.cp.beacon.spoc_updated);
/* This received beacon has a invalid frequency error. SPOC updated
* flag stay at true. */
beacon = test_new_beacon ();
beacon->params.frequency_error_valid = false;
- cp.beacon.spoc_update_date = phy_date () - 1;
- cp_beacon_receive (&cp, beacon);
- cp_beacon_get_and_process_beacon (&cp);
- test_fail_unless (cp.beacon.spoc_updated);
+ ctx.cp.beacon.spoc_update_date = phy_date () - 1;
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ test_fail_unless (ctx.cp.beacon.spoc_updated);
}
test_end;
- cp_cco_region_uninit (&cp);
- cp_cco_bw_uninit (&cp);
- cp_sta_mgr_uninit (&cp);
- cp_beacon_uninit (&cp);
+ test_beacon_uninit (&ctx);
}
int
@@ -1521,7 +1341,6 @@ main (void)
test_t test;
test_init (test, 0, NULL);
- test_case_beacon_init (test);
test_case_beacon_uninit (test);
test_case_beacon__deactivate (test);
test_suite_beacon__beacon_generation (test);
diff --git a/cesar/cp/cco/action/test/src/action_gen_nek.c b/cesar/cp/cco/action/test/src/action_gen_nek.c
index 513d4f50a6..ea2f334c10 100644
--- a/cesar/cp/cco/action/test/src/action_gen_nek.c
+++ b/cesar/cp/cco/action/test/src/action_gen_nek.c
@@ -48,23 +48,21 @@ test_case_gen_nek (test_t test)
/* Initialise the seed of the random generator. */
cp_cco_action_init (&cp);
- lib_rnd_init (&cp.rnd, 0x12345678);
test_begin (test, "Verify first shot")
{
uint i;
- uint computed_keys [4] = {0xf48aa84f, 0xb3b084cb, 0xdf36c134,
- 0xaa4010d2};
+ cp_key_t computed_keys;
+ lib_rnd_init (&cp.rnd, 0x12345678);
+ cp_secu_generate_key(&cp, lib_rnd32 (&cp.rnd),
+ 5, &computed_keys);
+ lib_rnd_init (&cp.rnd, 0x12345678);
cp_cco_action_cco__cco_nek_change (&cp);
-
- for (i = 0; i < 4; i++)
- printf ("Keys : %x, computed : %x\n", cp.cco_action.nek_new.key[i],
- computed_keys[i]);
-
- test_fail_unless (cp.cco_action.nek_new.key[0] == computed_keys[0]);
- test_fail_unless (cp.cco_action.nek_new.key[1] == computed_keys[1]);
- test_fail_unless (cp.cco_action.nek_new.key[2] == computed_keys[2]);
- test_fail_unless (cp.cco_action.nek_new.key[3] == computed_keys[3]);
+ for (i = 0; i < COUNT (cp.cco_action.nek_new.key); i++)
+ {
+ test_fail_unless (cp.cco_action.nek_new.key[i]
+ == computed_keys.key[i]);
+ }
}
test_end;
}
diff --git a/cesar/cp/secu/test/sparc-Makefile b/cesar/cp/secu/test/sparc-Makefile
index e53439ca02..b9c0e85845 100644
--- a/cesar/cp/secu/test/sparc-Makefile
+++ b/cesar/cp/secu/test/sparc-Makefile
@@ -8,13 +8,13 @@ INCLUDES = cp/secu/test/override
TARGET_PROGRAMS = test-sha2 test-aes test-nmk
test-sha2_SOURCES = test-sha2.c
-test-sha2_MODULES = lib cp/secu cp/sta/core/stub
+test-sha2_MODULES = lib cp/secu cp/sta/core/stub hal/arch
test-aes_SOURCES = test-aes.c
-test-aes_MODULES = lib cp/secu cp/sta/core/stub
+test-aes_MODULES = lib cp/secu cp/sta/core/stub hal/arch
test-nmk_SOURCES = test-nmk.c
-test-nmk_MODULES = lib cp/secu cp/sta/core/stub
+test-nmk_MODULES = lib cp/secu cp/sta/core/stub hal/arch
VARIANT = sparc
include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/src/cp.c b/cesar/cp/src/cp.c
index dd1cc868ee..3396c61d94 100644
--- a/cesar/cp/src/cp.c
+++ b/cesar/cp/src/cp.c
@@ -62,6 +62,9 @@ cp_init (bsu_t *bsu, bsu_aclf_t* aclf, mac_config_t * mac_config,
cp_global.bsu = bsu;
cp_global.bsu_aclf = aclf;
+ /* Init the random generator. */
+ lib_rnd_init (&cp_global.rnd, seed ^ 0x87543571);
+
/* Initialise traces. */
cp_trace_init (&cp_global);
@@ -98,9 +101,6 @@ cp_init (bsu_t *bsu, bsu_aclf_t* aclf, mac_config_t * mac_config,
/* Initialise the FSM. */
cp_fsm_init (&cp_global);
- /* Init the random generator. */
- lib_rnd_init (&cp_global.rnd, seed ^ 0x87543571);
-
/* Init CE in TX. */
ce_tx_init (&cp_global);
#if CONFIG_CP_EOC_SCHEDULER && CONFIG_CP_STA_MGR_EOC
diff --git a/cesar/cp/sta/action/src/vs.c b/cesar/cp/sta/action/src/vs.c
index 1daf2482af..29c5216e82 100644
--- a/cesar/cp/sta/action/src/vs.c
+++ b/cesar/cp/sta/action/src/vs.c
@@ -19,6 +19,7 @@
#include "cp/inc/context.h"
#include "mac/common/tonemap.h"
#include "cp/sta/action/misc.h"
+#include "ce/rx/bitloading/nsr.h"
/**
* Handle STARTED => VS_GET_TONEMAP.REQ.
@@ -229,8 +230,8 @@ cp_sta_action_vs__started__vs_get_snr_req (cp_t *ctx, cp_mme_rx_t *mme)
carrier_gr)
{
data_to_send.snr[grp_snr_index] =
- data[(all_snr_index - PHY_CARRIER_OFFSET) %
- (BLK_SIZE/4)];
+ (data[(all_snr_index - PHY_CARRIER_OFFSET) %
+ (BLK_SIZE/4)]) / CE_RX_BL_NSR_SOUND_RESCALE;
grp_snr_index++;
}
}
diff --git a/cesar/cp/sta/action/test/utest/src/vs.c b/cesar/cp/sta/action/test/utest/src/vs.c
index 279d0e8205..a1b2f4dc0f 100644
--- a/cesar/cp/sta/action/test/utest/src/vs.c
+++ b/cesar/cp/sta/action/test/utest/src/vs.c
@@ -13,6 +13,7 @@
#include "common/std.h"
#include "lib/scenario/scenario.h"
#include "inc/test_sta_action.h"
+#include "ce/rx/bitloading/nsr.h"
blk_t* nsr_block;
@@ -171,6 +172,7 @@ vs_get_snr_test_case (test_t t)
{
snr[i] = -(i * CP_MSG_VS_GET_SNR_REQ_CARRIER_GR_NB + group -
PHY_CARRIER_OFFSET);
+ snr[i] /= CE_RX_BL_NSR_SOUND_RESCALE;
}
else
snr[i] = 0;
diff --git a/cesar/cp/sta/mgr/test/src/sta_mgr.c b/cesar/cp/sta/mgr/test/src/sta_mgr.c
index 67adcd4e3a..73bbf7f97b 100644
--- a/cesar/cp/sta/mgr/test/src/sta_mgr.c
+++ b/cesar/cp/sta/mgr/test/src/sta_mgr.c
@@ -1315,7 +1315,7 @@ test_case__cp_sta_mgr_partial_ack (test_t test)
}
test_fail_unless (teis[0] == false);
for (i = 1; i < COUNT (teis); i++)
- test_fail_unless (teis[i] == true);
+ test_fail_unless (teis[i] == true);
slab_release (sta);
}
test_end;
diff --git a/cesar/cp/test/mme/Makefile b/cesar/cp/test/mme/Makefile
index 8876e7cfd3..798dd377e6 100644
--- a/cesar/cp/test/mme/Makefile
+++ b/cesar/cp/test/mme/Makefile
@@ -9,6 +9,6 @@ test_mme_SOURCES = test_mme.c
test_mme_MODULES = lib
test_mme_target_SOURCES = test_mme.c
-test_mme_target_MODULES = lib
+test_mme_target_MODULES = lib hal/arch
include $(BASE)/common/make/top.mk
diff --git a/cesar/hal/arch/Config b/cesar/hal/arch/Config
new file mode 100644
index 0000000000..5d46bd1570
--- /dev/null
+++ b/cesar/hal/arch/Config
@@ -0,0 +1 @@
+CONFIG_ARCH_ILRAM_PRIO = 5
diff --git a/cesar/hal/arch/arch.h b/cesar/hal/arch/arch.h
index 81aae83a8e..a1ad0d96fa 100644
--- a/cesar/hal/arch/arch.h
+++ b/cesar/hal/arch/arch.h
@@ -21,6 +21,16 @@
#define ARCH_ILRAM
/**
+ * Put in the instruction local ram section, with lower priority.
+ * \param prio function priority
+ *
+ * Should be put between function return type and function name. Function
+ * will be included in local ram only if priority is lower than or equal to
+ * configured limit.
+ */
+#define ARCH_ILRAM_PRIO(prio)
+
+/**
* Put in the data local ram section.
*/
#define ARCH_DLRAM_DATA
diff --git a/cesar/hal/arch/inc/sparc.h b/cesar/hal/arch/inc/sparc.h
index 03f8dcab86..beafd42c3b 100644
--- a/cesar/hal/arch/inc/sparc.h
+++ b/cesar/hal/arch/inc/sparc.h
@@ -17,9 +17,35 @@
#if defined (ECOS) && ECOS
+# include "config/arch/ilram.h"
+
# undef ARCH_ILRAM
# define ARCH_ILRAM __attribute__ ((section (".ilram")))
+# undef ARCH_ILRAM_PRIO
+# define ARCH_ILRAM_PRIO(prio) PASTE (ARCH_ILRAM_PRIO_, prio)
+
+# if CONFIG_ARCH_ILRAM_PRIO >= 3
+# define ARCH_ILRAM_PRIO_3 ARCH_ILRAM
+# else
+# define ARCH_ILRAM_PRIO_3
+# endif
+# if CONFIG_ARCH_ILRAM_PRIO >= 2
+# define ARCH_ILRAM_PRIO_2 ARCH_ILRAM
+# else
+# define ARCH_ILRAM_PRIO_2
+# endif
+# if CONFIG_ARCH_ILRAM_PRIO >= 1
+# define ARCH_ILRAM_PRIO_1 ARCH_ILRAM
+# else
+# define ARCH_ILRAM_PRIO_1
+# endif
+# if CONFIG_ARCH_ILRAM_PRIO >= 0
+# define ARCH_ILRAM_PRIO_0 ARCH_ILRAM
+# else
+# define ARCH_ILRAM_PRIO_0
+# endif
+
# undef ARCH_DLRAM_DATA
# define ARCH_DLRAM_DATA __attribute__ ((section (".dlram_data")))
diff --git a/cesar/hal/phy/Module b/cesar/hal/phy/Module
index a363c5f9d3..20e833f76f 100644
--- a/cesar/hal/phy/Module
+++ b/cesar/hal/phy/Module
@@ -99,4 +99,4 @@ $(hal_phy_params_h): $(call src2src,phy_params.pl,hal/phy/src) \
endif
$(call src2obj,hal/phy/src/resys.c,$(BUILD_TYPE)): $(hal_phy_resys_prog_h) \
-$(hal_phy_resys_offsettable_h)
+$(hal_phy_resys_prog_patch_h) $(hal_phy_resys_offsettable_h)
diff --git a/cesar/hal/phy/inc/context.h b/cesar/hal/phy/inc/context.h
index df64f4a6ea..0a21e76b77 100644
--- a/cesar/hal/phy/inc/context.h
+++ b/cesar/hal/phy/inc/context.h
@@ -70,10 +70,10 @@ struct phy_t
uint resys_gil_table[PHY_GIL_NB];
/** Start PBDMA on RESYS interrupt. */
bool pbdma_start_on_resys_it;
- /** CAP activation mask. */
- u8 cap_mask;
/** Whether frequency error is synchronised. */
bool freq_error_sync;
+ /** CAP activation mask. */
+ u8 cap_mask;
/** Phy stats. */
phy_stats_t stats;
};
diff --git a/cesar/hal/phy/maximus/src/maximus_phy_ctrl.c b/cesar/hal/phy/maximus/src/maximus_phy_ctrl.c
index 5aeec9e9d9..cafe769610 100644
--- a/cesar/hal/phy/maximus/src/maximus_phy_ctrl.c
+++ b/cesar/hal/phy/maximus/src/maximus_phy_ctrl.c
@@ -2315,6 +2315,14 @@ phy_clock_get_zero_cross_captured_sysdate (phy_t *ctx)
}
+void
+phy_freq_error_set (phy_t *ctx, bool sync, s32 rho_q30)
+{
+ dbg_assert_ptr (ctx);
+ /* Ignored. */
+}
+
+
/**
* set errno to:
* - EINVAL if ctx is null
diff --git a/cesar/hal/phy/maximus/test/src/test_phy_ctrl.c b/cesar/hal/phy/maximus/test/src/test_phy_ctrl.c
index 626ad6f86f..96b1382faf 100644
--- a/cesar/hal/phy/maximus/test/src/test_phy_ctrl.c
+++ b/cesar/hal/phy/maximus/test/src/test_phy_ctrl.c
@@ -2090,10 +2090,10 @@ void phy_tx_frame_test_case(test_t t)
} test_end;
// test the fourth callback
+ phy_pb_t pb[PHY_PB_MAX_NB];
+ u8 pb_data[PHY_PB_MAX_NB][MAC_PB520_BYTES];
test_begin(t, "maximus phy tx mpdu cb")
{
- phy_pb_t pb[PHY_PB_MAX_NB];
- u8 pb_data[PHY_PB_MAX_NB][MAC_PB520_BYTES];
int i = 0;
char c = 'a';
diff --git a/cesar/hal/phy/src/phy.c b/cesar/hal/phy/src/phy.c
index 804a06f774..254bb07664 100644
--- a/cesar/hal/phy/src/phy.c
+++ b/cesar/hal/phy/src/phy.c
@@ -463,6 +463,14 @@ phy_init_tunable_param (phy_t *ctx)
&phy_tunable.spoc_rho_initial_q30,
LIB_STATS_ACCESS_WRITE_ONLY,
LIB_STATS_DEBUG);
+ lib_stats_set_stat_value_notype ("DELTA_RES_COEF_INTERNAL",
+ &phy_tunable.delta_res_coef_internal,
+ LIB_STATS_ACCESS_WRITE_ONLY,
+ LIB_STATS_DEBUG);
+ lib_stats_set_stat_value_notype ("DELTA_RES_COEF_EXTERNAL",
+ &phy_tunable.delta_res_coef_external,
+ LIB_STATS_ACCESS_WRITE_ONLY,
+ LIB_STATS_DEBUG);
lib_stats_set_stat_value_notype ("CAP_MASK",
&ctx->cap_mask,
LIB_STATS_ACCESS_WRITE_ONLY,
diff --git a/cesar/hle/inc/context.h b/cesar/hle/inc/context.h
index 9c8fb18893..8681744177 100644
--- a/cesar/hle/inc/context.h
+++ b/cesar/hle/inc/context.h
@@ -15,6 +15,7 @@
*/
#include "lib/trace.h"
+#include "lib/seq_check.h"
#include "cl/cl.h"
@@ -51,6 +52,11 @@ struct hle_t
/** HLE Trace */
trace_buffer_t trace;
#endif /* !CONFIG_TRACE */
+#if CONFIG_SEQ_CHECK
+ /** Sequence check. */
+ lib_seq_check_t seq_in;
+ lib_seq_check_t seq_out;
+#endif
};
#endif /* hle_inc_context_h */
diff --git a/cesar/hle/inc/trace.h b/cesar/hle/inc/trace.h
index 29ba7ec8c1..185b9be4d9 100644
--- a/cesar/hle/inc/trace.h
+++ b/cesar/hle/inc/trace.h
@@ -34,7 +34,9 @@ enum
HLE_TRACE_MME_SEND,
HLE_TRACE_MME_RECV,
HLE_TRACE_IPMBOX,
- HLE_TRACE_DROPPED
+ HLE_TRACE_DROPPED,
+ HLE_TRACE_SEQ_CHECK_IN,
+ HLE_TRACE_SEQ_CHECK_OUT,
};
BEGIN_DECLS
diff --git a/cesar/hle/src/hle.c b/cesar/hle/src/hle.c
index 71e2eb48a8..60080f0acd 100644
--- a/cesar/hle/src/hle.c
+++ b/cesar/hle/src/hle.c
@@ -20,6 +20,7 @@
#include "hle/inc/context.h"
#include "hle/inc/trace.h"
#include "mac/common/ntb.h"
+#include "lib/seq_check.h"
#include "common/module.h"
@@ -27,6 +28,48 @@
static hle_t hle_global;
/**
+ * Callback when the lib sequencer detect a wrong sequencing, input from
+ * Linux.
+ * \param user user data
+ * \param vlan the VLAN id
+ * \param seq_expected the sequence number expected
+ * \param seq_actual the actual sequence number found in the packet
+ */
+void
+hle_lib_seq_check_cb_in (void *user, uint vlan, uint seq_expected,
+ uint seq_actual);
+
+/**
+ * Callback when the lib sequencer detect a wrong sequencing, output to
+ * Linux.
+ * \param user user data
+ * \param vlan the VLAN id
+ * \param seq_expected the sequence number expected
+ * \param seq_actual the actual sequence number found in the packet
+ */
+void
+hle_lib_seq_check_cb_out (void *user, uint vlan, uint seq_expected,
+ uint seq_actual);
+
+void
+hle_lib_seq_check_cb_in (void *user, uint vlan, uint seq_expected,
+ uint seq_actual)
+{
+ dbg_assert (user);
+ trace_do (hle_t *ctx = (hle_t *) user);
+ HLE_TRACE (SEQ_CHECK_IN, vlan, seq_expected, seq_actual);
+}
+
+void
+hle_lib_seq_check_cb_out (void *user, uint vlan, uint seq_expected,
+ uint seq_actual)
+{
+ dbg_assert (user);
+ trace_do (hle_t *ctx = (hle_t *) user);
+ HLE_TRACE (SEQ_CHECK_OUT, vlan, seq_expected, seq_actual);
+}
+
+/**
* Send a data to the Convergence Layer to be sent over the PWL.
* \param hle the hle context.
* \param buffer the buffer containing the data to send.
@@ -40,6 +83,10 @@ hle_data_send (hle_t *ctx, u8 *buffer, uint length, uint tag,
{
dbg_assert (buffer);
dbg_assert (length <= ETH_PACKET_MAX_SIZE);
+
+ /* Check sequence. */
+ lib_seq_check_packet (&ctx->seq_in, buffer, length);
+
if (length < ETH_PACKET_MIN_SIZE_ALLOWED)
{
hle_send_done (ctx, buffer);
@@ -69,6 +116,9 @@ hle_data_recv (hle_t *ctx, u8 *buffer, uint length)
/* Tracing data. */
HLE_TRACE (DATA_RECV, phy_date (), length, buffer);
+ /* Check sequence. */
+ lib_seq_check_packet (&ctx->seq_out, buffer, length);
+
word[0] = BF_FILL (IPMBOX_REG, (MSG_TYPE, HLE_MSG_TYPE_DATA),
(MSG_LENGTH, 1), (PARAM_MSG_TYPE, 0),
(PARAM_MSG_LENGTH, length));
@@ -250,6 +300,9 @@ hle_init (cl_t *cl)
#endif
/* Tracing */
HLE_TRACE (INIT, phy_date ());
+ /* Sequence check initialization. */
+ lib_seq_check_init (&ctx->seq_in, hle_lib_seq_check_cb_in, &hle_global);
+ lib_seq_check_init (&ctx->seq_out, hle_lib_seq_check_cb_out, &hle_global);
return &hle_global;
}
diff --git a/cesar/hle/src/trace.c b/cesar/hle/src/trace.c
index 0945e876b4..630d4500e2 100644
--- a/cesar/hle/src/trace.c
+++ b/cesar/hle/src/trace.c
@@ -38,6 +38,10 @@ hle_trace_init (hle_t *ctx)
TRACE_EVENT (HLE_TRACE_MME_RECV, "HLE_MME_RECV length : %d, buffer @ : %x", TIMESTAMP),
TRACE_EVENT (HLE_TRACE_IPMBOX, "HLE_IPMBOX_ACTIVATE avctive : %d", TIMESTAMP),
TRACE_EVENT (HLE_TRACE_DROPPED, "HLE_MSG DROPPED data: %d, length: %d, buffer: %x", TIMESTAMP),
+ TRACE_EVENT (HLE_TRACE_SEQ_CHECK_IN, "[SeqCheck] input from linux: "
+ "[%02d] expected=%04X, actual=%04X"),
+ TRACE_EVENT (HLE_TRACE_SEQ_CHECK_OUT, "[SeqCheck] output to linux: "
+ "[%02d] expected=%04X, actual=%04X"),
};
dbg_assert (ctx);
trace_namespace_init (&namespace, event_ids, COUNT (event_ids));
diff --git a/cesar/lib/Config b/cesar/lib/Config
index bf0afe4a15..cb6dd037a9 100644
--- a/cesar/lib/Config
+++ b/cesar/lib/Config
@@ -27,3 +27,5 @@ CONFIG_GPIO_FATAL_BLINK_DELAY = 10000000
CONFIG_SLAB_ALLOC_SCRAMBLE = n
CONFIG_RND_MT19937 = n
CONFIG_RND_TT800 = y
+CONFIG_SEQ_CHECK = n
+CONFIG_SEQ_CHECK_VLAN_MAX = 64
diff --git a/cesar/lib/Module b/cesar/lib/Module
index 0c9d1aa51b..e57586f636 100644
--- a/cesar/lib/Module
+++ b/cesar/lib/Module
@@ -1,7 +1,7 @@
SOURCES := crc.c dbg.c heap.c test.c blk.c slab.c list.c \
aatree.c try.c fixed.c blk_table.c \
swap.c read_word.c bitstream.c circular_buffer.c mbox.c \
- mac_lookup_table.c init.c rnd.c
+ mac_lookup_table.c init.c rnd.c utils.c
ifeq ($(CONFIG_HEAP_SKEW),y)
SOURCES += skewheap.c
endif
@@ -26,3 +26,6 @@ endif
ifeq ($(CONFIG_RND_TT800),y)
SOURCES += tt800.c
endif
+ifeq ($(CONFIG_SEQ_CHECK),y)
+SOURCES += seq_check.c
+endif
diff --git a/cesar/lib/seq_check.h b/cesar/lib/seq_check.h
new file mode 100644
index 0000000000..5e0916ce29
--- /dev/null
+++ b/cesar/lib/seq_check.h
@@ -0,0 +1,170 @@
+#ifndef lib_seq_check_h
+#define lib_seq_check_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file lib/seq_check.h
+ * \brief Check sequence number in data packets
+ * \ingroup lib
+ *
+ * This lib is used to check sequence number in data packets generated by
+ * IPerf or Ixia. It supports VLAN if packets are tagged.
+ *
+ * De-sequence is stored in traces (no assert is done).
+ *
+ * You can configure:
+ * - position of the sequence number in the packet,
+ * - Ethernet type to inspect.
+ *
+ * This lib has some limitations:
+ * - you can not ignore some packets: for example during an IPerf traffic, if
+ * they are some pings, they will be inspected. If there is video traffic, it
+ * will be inspected too,
+ * - having different kind of throughput at the same time is not possible: an
+ * IPerf, an Ixia and video. You can only configure for one throughput,
+ * - you can not specify the first sequence number value,
+ * - you can not specify the size/length of the sequence number,
+ * - it can not support VLAN and non VLAN traffic at the same time (sequence
+ * position is the same for both).
+ *
+ * This lib should only be enabled when needed as it will probably impact
+ * performance (it needs to inspect packets).
+ */
+
+#include "config/seq/check.h"
+
+#if CONFIG_SEQ_CHECK
+
+/**
+ * Callback used when there is a de-sequencing in the packets.
+ * \param user an user pointer
+ * \param vlan the VLAN id which in the packet or 0 if there is none
+ * \param seq_expected the sequence number expected
+ * \param seq_actual the sequence actually in the packet
+ *
+ * This function is called by lib_seq_check_packet when there the sequence
+ * number is not the one expected.
+ */
+typedef void
+(*lib_seq_check_error_cb_t) (void *user, uint vlan, uint seq_expected,
+ uint seq_actual);
+
+/**
+ * Ethernet type IP.
+ */
+#define SEQ_CHECK_ET_IP 0x8000
+
+/**
+ * Sequence counters.
+ * This structure is used to store states of the sequence counter. There is
+ * one for each VLAN.
+ */
+typedef struct lib_seq_check_t
+{
+ /**
+ * Sequence counters, for each VLAN id.
+ * \note if no VLAN is present on frames, first index of the table is
+ * used. There should be no problem, as VLAN 0 is for management.
+ */
+ uint seq[CONFIG_SEQ_CHECK_VLAN_MAX];
+ /**
+ * Callback when sequence is wrong.
+ */
+ lib_seq_check_error_cb_t cb;
+ /**
+ * The user pointer used when calling the callback.
+ */
+ void *cb_user;
+} lib_seq_check_t;
+
+/**
+ * Configuration structure.
+ */
+typedef struct lib_seq_check_config_t
+{
+ /**
+ * Sequence number size.
+ * It only support 16 for the moment.
+ */
+ u8 seq_size;
+ /**
+ * Position of the sequence number in the packet.
+ * The position start at first bit of the Ethernet frame.
+ * This counter is expressed in byte.
+ */
+ uint seq_pos;
+ /**
+ * Ethernet type the packet has to have.
+ */
+ uint ethertype;
+} lib_seq_check_config_t;
+
+BEGIN_DECLS
+
+/**
+ * Configure lib sequencer check.
+ * \param config the new configuration structure to use.
+ *
+ * All fields are copied to the configuration. If you only want to setup one
+ * field, you need to use lib_seq_check_config_get before.
+ */
+void
+lib_seq_check_config_set (lib_seq_check_config_t *config);
+
+/**
+ * Get current configuration.
+ * \param config a configuration which will be set to the current one of the
+ * sequencer check of the lib.
+ */
+void
+lib_seq_check_config_get (lib_seq_check_config_t *config);
+
+/**
+ * Initialize lib sequencer check configuration.
+ * You need to do this only one time in the life of the station.
+ */
+void
+lib_seq_check_config_init (void);
+
+/**
+ * Initialize lib sequencer check.
+ * \param ctx the context to initialize
+ * \param cb the callback to use when there is an problem of sequence in the
+ * packet
+ * \param user an user pointer used when calling the callback
+ *
+ * This need to be done for each entry point to inspect.
+ */
+void
+lib_seq_check_init (lib_seq_check_t *ctx, lib_seq_check_error_cb_t cb,
+ void *user);
+
+/**
+ * Data packet to inspect.
+ * \param ctx the context of lib seq check
+ * \param buffer the packet buffer
+ * \param len the packet length (in byte)
+ * \return true if there is a de-sequencing in the packet and callback was
+ * called, false otherwise (this include packets which can not be inspected).
+ */
+bool
+lib_seq_check_packet (lib_seq_check_t *ctx, u8 *buffer, uint len);
+
+END_DECLS
+
+#else /* !CONFIG_SEQ_CHECK */
+
+# define lib_seq_check_config_get() ((void) 0)
+# define lib_seq_check_config_set() ((void) 0)
+# define lib_seq_check_config_init() ((void) 0)
+# define lib_seq_check_init(args...) ((void) 0)
+# define lib_seq_check_packet(args...) ((void) 0)
+
+#endif /* !CONFIG_SEQ_CHECK */
+
+#endif /* lib_seq_check_h */
diff --git a/cesar/lib/src/seq_check.c b/cesar/lib/src/seq_check.c
new file mode 100644
index 0000000000..5b7d0a1e01
--- /dev/null
+++ b/cesar/lib/src/seq_check.c
@@ -0,0 +1,154 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file lib/src/seq_check.c
+ * \brief Check sequence number in data packets
+ * \ingroup lib
+ *
+ *
+ */
+#include "common/std.h"
+#include "lib/bitstream.h"
+#include "lib/swap.h"
+#include "lib/stats.h"
+
+#include "config/seq/check/vlan/max.h"
+
+#include "lib/seq_check.h"
+
+/**
+ * Ethernet type VLAN ID.
+ */
+#define SEQ_CHECK_ET_VLAN 0x8100
+
+lib_seq_check_config_t lib_seq_check_config;
+
+void
+lib_seq_check_config_set (lib_seq_check_config_t *config)
+{
+ dbg_assert (config);
+ /* Set configuration. */
+ lib_seq_check_config = *config;
+}
+
+void
+lib_seq_check_config_get (lib_seq_check_config_t *config)
+{
+ dbg_assert (config);
+ /* Get configuration. */
+ *config = lib_seq_check_config;
+}
+
+void
+lib_seq_check_config_init (void)
+{
+ /* Set default configuration. */
+ lib_seq_check_config_t config =
+ {
+ .seq_size = 16,
+ .seq_pos = 44, /* For IPerf. */
+ .ethertype = SEQ_CHECK_ET_IP, /* No check for Ethernet type. */
+ };
+ lib_seq_check_config_set (&config);
+
+ /* Register our configuration item. */
+ lib_stats_set_stat_value_notype ("SEQ_CHECK_SEQ_POS",
+ &lib_seq_check_config.seq_pos,
+ LIB_STATS_ACCESS_READ_WRITE,
+ LIB_STATS_DEBUG);
+ lib_stats_set_stat_value_notype ("SEQ_CHECK_ETHERTYPE",
+ &lib_seq_check_config.ethertype,
+ LIB_STATS_ACCESS_READ_WRITE,
+ LIB_STATS_DEBUG);
+}
+
+void
+lib_seq_check_init (lib_seq_check_t *ctx, lib_seq_check_error_cb_t cb,
+ void *user)
+{
+ /* Check parameters. */
+ dbg_assert (ctx);
+ dbg_assert (cb);
+
+ uint i;
+ /* Initialize sequence number to 0. */
+ for (i = 0; i < CONFIG_SEQ_CHECK_VLAN_MAX; i++)
+ {
+ ctx->seq[i] = 0;
+ }
+ ctx->cb = cb;
+ ctx->cb_user = user;
+}
+
+bool
+lib_seq_check_packet (lib_seq_check_t *ctx, u8 *buffer, uint len)
+{
+ /* Check parameter. */
+ dbg_assert (ctx);
+
+ bool result = false;
+
+ /* Get Ethernet type (after SRC & DST MAC (6 bytes each)). */
+ uint ethertype = swap16 (bitstream_direct_read (buffer, 6 * 8 * 2, 2 *
+ 8));
+
+ /* Position of sequence counter index in the table. */
+ uint seq_index = 0;
+
+ /* VLAN in used? */
+ if (ethertype == SEQ_CHECK_ET_VLAN)
+ {
+ /* VLAN id on 12 bits. VLAN id is located after SRC & DST (6 bytes
+ * each) & VLAN/IEEE_802.1Q fields (TPID + PCP + CFI = 20 bits). But
+ * we can only get on 2 bytes. We need to get TCI field (PCP, CFI &
+ * VID). */
+ seq_index = swap16 (bitstream_direct_read (buffer, (6 * 2 + 2) * 8,
+ 16));
+ /* Remove PCP & CFI. */
+ seq_index &= (0xFFFF >> 4);
+ dbg_assert (seq_index < CONFIG_SEQ_CHECK_VLAN_MAX);
+
+ /* Get real Ethernet type, located after SRC & DST (6 bytes each) and
+ * VLAN/IEEE_802.1Q fields (4 bytes). */
+ ethertype = swap16 (bitstream_direct_read (buffer, (6 + 6 + 4) * 8,
+ 2 * 8));
+ }
+
+ /* If this is the expected ethertype. */
+ if (lib_seq_check_config.ethertype
+ && ethertype == lib_seq_check_config.ethertype)
+ {
+
+ /* Get sequence value. */
+ dbg_assert (lib_seq_check_config.seq_size == 16);
+ uint received_seq = swap16 (
+ bitstream_direct_read (buffer, lib_seq_check_config.seq_pos * 8,
+ lib_seq_check_config.seq_size));
+
+ /* Handle overflow. */
+ ctx->seq[seq_index] &= BITS_ONES (lib_seq_check_config.seq_size);
+
+ /* Check. */
+ if (ctx->seq[seq_index] != received_seq)
+ {
+ /* Call callback. */
+ dbg_assert (ctx->cb);
+ (*ctx->cb) (ctx->cb_user, seq_index, ctx->seq[seq_index],
+ received_seq);
+ /* Reset. */
+ ctx->seq[seq_index] = received_seq;
+ result = true;
+ }
+
+ /* Increment. */
+ ctx->seq[seq_index]++;
+ }
+
+ /* Return result. */
+ return result;
+}
diff --git a/cesar/lib/src/utils.c b/cesar/lib/src/utils.c
new file mode 100644
index 0000000000..4ca7b39654
--- /dev/null
+++ b/cesar/lib/src/utils.c
@@ -0,0 +1,42 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file lib/src/utils.c
+ * \brief Common utilities.
+ * \ingroup lib
+ */
+#include "common/std.h"
+
+/* See
+ * http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
+ */
+bool
+almost_eqf (float a, float b, int max_ulps)
+{
+ union
+ {
+ float f;
+ s32 i;
+ } aInt, bInt;
+ /* Make sure max_ulps is non-negative and small enough that the default
+ * NAN won't compare as equal to anything. */
+ dbg_assert (max_ulps > 0 && max_ulps < 4 * 1024 * 1024);
+ aInt.f = a;
+ /* Make aInt lexicographically ordered as a twos-complement int. */
+ if (aInt.i < 0)
+ aInt.i = 0x80000000 - aInt.i;
+ /* Make bInt lexicographically ordered as a twos-complement int. */
+ bInt.f = b;
+ if (bInt.i < 0)
+ bInt.i = 0x80000000 - bInt.i;
+ s32 intDiff = ABS (aInt.i - bInt.i);
+ if (intDiff <= max_ulps)
+ return true;
+ return false;
+}
+
diff --git a/cesar/lib/test/fixed/src/test_fixed.c b/cesar/lib/test/fixed/src/test_fixed.c
index 9b3ff3a8c8..15fe7ca3e0 100644
--- a/cesar/lib/test/fixed/src/test_fixed.c
+++ b/cesar/lib/test/fixed/src/test_fixed.c
@@ -36,30 +36,30 @@
void
asm_fixed_mul (void)
{
- volatile s32 a, b, r;
- volatile uint shift;
+ volatile s32 a = 0, b = 0, r;
+ volatile uint shift = 0;
r = fixed_mul (a, b, shift);
}
void
asm_fixed_mul_2 (void)
{
- volatile s32 a, b, r;
+ volatile s32 a = 0, b = 0, r;
r = fixed_mul (a, b, 24);
}
void
asm_fixed_div (void)
{
- volatile s32 a, b, r;
- volatile uint shift;
+ volatile s32 a = 0, b = 0, r;
+ volatile uint shift = 0;
r = fixed_div (a, b, shift);
}
void
asm_fixed_div_2 (void)
{
- volatile s32 a, b, r;
+ volatile s32 a = 0, b = 0, r;
r = fixed_div (a, b, 24);
}
diff --git a/cesar/lib/test/heap/src/test_heap.c b/cesar/lib/test/heap/src/test_heap.c
index 20e0d9ac14..b9be79feff 100644
--- a/cesar/lib/test/heap/src/test_heap.c
+++ b/cesar/lib/test/heap/src/test_heap.c
@@ -94,7 +94,9 @@ heap_check (test_t t, heap_t *heap)
static void
heap_stats (test_t t, heap_t *heap, uint *min, uint *max, unsigned long long *sum)
{
+#if CONFIG_HEAP_LEFTIST
test_within (t);
+#endif
heap_node_t *n;
uint path_length;
#if CONFIG_HEAP_LEFTIST
diff --git a/cesar/lib/test/mbox/src/mbox.c b/cesar/lib/test/mbox/src/mbox.c
index eea3155bd5..84fb090f1b 100644
--- a/cesar/lib/test/mbox/src/mbox.c
+++ b/cesar/lib/test/mbox/src/mbox.c
@@ -87,11 +87,11 @@ thread2_entry_function(cyg_addrword_t data)
mbox_nb = mbox_peek (&mbox);
mbox_uninit (&mbox);
- blk_print_memory ();
test_init (test, 0, NULL);
test_begin (test, "Mailbox")
{
+ test_fail_if (blk_check_memory() == false, "Memory not freed");
test_fail_unless (nb_msg == 10);
test_fail_unless (mbox_nb == 0);
}
diff --git a/cesar/lib/test/seq_check/Config b/cesar/lib/test/seq_check/Config
new file mode 100644
index 0000000000..aab2ba7dab
--- /dev/null
+++ b/cesar/lib/test/seq_check/Config
@@ -0,0 +1,2 @@
+CONFIG_SEQ_CHECK = y
+CONFIG_STATS = n
diff --git a/cesar/lib/test/seq_check/Makefile b/cesar/lib/test/seq_check/Makefile
new file mode 100644
index 0000000000..a74fa304d6
--- /dev/null
+++ b/cesar/lib/test/seq_check/Makefile
@@ -0,0 +1,8 @@
+BASE = ../../..
+
+HOST_PROGRAMS = test_seq_check
+
+test_seq_check_SOURCES = seq_check.c
+test_seq_check_MODULES = lib
+
+include $(BASE)/common/make/top.mk
diff --git a/cesar/lib/test/seq_check/src/seq_check.c b/cesar/lib/test/seq_check/src/seq_check.c
new file mode 100644
index 0000000000..574f98f017
--- /dev/null
+++ b/cesar/lib/test/seq_check/src/seq_check.c
@@ -0,0 +1,250 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file lib/test/seq_check/src/seq_check.c
+ * \brief Sequence check test
+ * \ingroup test
+ *
+ * Test sequencer check.
+ */
+#include "common/std.h"
+
+#include "lib/test.h"
+#include "lib/seq_check.h"
+#include "common/defs/ethernet.h"
+#include "lib/rnd.h"
+#include "lib/bitstream.h"
+#include "lib/swap.h"
+
+/* Test structure to use with the callback. */
+typedef struct test_seq_check_callback_t
+{
+ struct test_t *test;
+ bool cb_called;
+ uint vlan;
+ uint seq_expected;
+ uint seq_actual;
+} test_seq_check_callback_t;
+
+void
+test_seq_check_write_ethertype (u8 *p, u16 ethertype, bool vlan)
+{
+ /* Store ethertype. */
+ uint pos = 6 * 2 * 8;
+ if (vlan)
+ {
+ bitstream_direct_write (p, pos, swap16 (0x8100), 16);
+ pos += 4 * 8;
+ }
+ bitstream_direct_write (p, pos, swap16 (ethertype), 16);
+}
+
+void
+test_seq_check_cb (void *user, uint vlan, uint seq_expected, uint seq_actual)
+{
+ dbg_assert (user);
+ test_seq_check_callback_t *test_seq_check_callback_values
+ = (test_seq_check_callback_t *) user;
+
+ test_within (test_seq_check_callback_values->test);
+ test_fail_if (test_seq_check_callback_values->vlan != vlan);
+ test_fail_if (test_seq_check_callback_values->seq_expected !=
+ seq_expected);
+ test_fail_if (test_seq_check_callback_values->seq_actual != seq_actual);
+ test_seq_check_callback_values->cb_called = true;
+}
+
+void
+test_seq_check_packet (test_t t, lib_rnd_t *rnd, uint pos, u16 ethertype)
+{
+ lib_seq_check_t s;
+ uint i;
+ u32 p[ETH_PACKET_MAX_SIZE];
+ bool res;
+ test_seq_check_callback_t test_seq_check_callback_values;
+ test_seq_check_callback_values.test = t;
+
+ /* Set configuration. */
+ lib_seq_check_config_t conf;
+ lib_seq_check_config_get (&conf);
+ conf.seq_pos = pos;
+ conf.ethertype = ethertype;
+ lib_seq_check_config_set (&conf);
+
+ test_begin (t, "config")
+ {
+ lib_seq_check_config_get (&conf);
+ test_fail_if (conf.seq_pos != pos);
+ test_fail_if (conf.ethertype != ethertype);
+ } test_end;
+
+ test_begin (t, "init")
+ {
+ lib_seq_check_init (&s, test_seq_check_cb,
+ &test_seq_check_callback_values);
+
+ for (i = 0; i < CONFIG_SEQ_CHECK_VLAN_MAX; i++)
+ {
+ test_fail_if (s.seq[i] != 0);
+ }
+ } test_end;
+
+ test_begin (t, "good sequence")
+ {
+ /* Store ethertype. */
+ test_seq_check_write_ethertype ((u8 *) p, ethertype, false);
+ for (i = 0; i < 1 << 16; i++)
+ {
+ bitstream_direct_write (p, pos * 8, swap16 (i), 16);
+ test_seq_check_callback_values.cb_called = false;
+ lib_seq_check_packet (&s, (u8 *) p, ETH_PACKET_MAX_SIZE);
+ test_fail_if (test_seq_check_callback_values.cb_called == true);
+ }
+ } test_end;
+
+ test_begin (t, "good and bad sequence")
+ {
+ u16 seq, prev;
+
+ /* Re-init. */
+ lib_seq_check_init (&s, test_seq_check_cb,
+ &test_seq_check_callback_values);
+ /* Store ethertype. */
+ test_seq_check_write_ethertype ((u8 *) p, ethertype, false);
+ for (seq = 0, i = 0; i < 1 << 16; i++, seq++)
+ {
+ if (lib_rnd_uniform (rnd, 2))
+ res = true;
+ else
+ {
+ prev = seq;
+ seq = lib_rnd_uniform (rnd, 1 << 16);
+ if (seq == prev)
+ seq++;
+ test_seq_check_callback_values.vlan = 0;
+ test_seq_check_callback_values.seq_expected = prev;
+ test_seq_check_callback_values.seq_actual = seq;
+ res = false;
+ }
+ test_seq_check_callback_values.cb_called = false;
+ bitstream_direct_write (p, pos * 8, swap16 (seq), 16);
+ lib_seq_check_packet (&s, (u8 *) p, ETH_PACKET_MAX_SIZE);
+ test_fail_if (test_seq_check_callback_values.cb_called == res);
+ }
+ } test_end;
+
+ test_begin (t, "good sequence with VLAN")
+ {
+ u16 seq[CONFIG_SEQ_CHECK_VLAN_MAX];
+
+ /* Re-init. */
+ lib_seq_check_init (&s, test_seq_check_cb,
+ &test_seq_check_callback_values);
+ /* Store ethertype. */
+ test_seq_check_write_ethertype ((u8 *) p, ethertype, true);
+
+ for (i = 0; i < CONFIG_SEQ_CHECK_VLAN_MAX; i ++)
+ {
+ seq[i] = 0;
+ }
+
+ for (i = 0; i < (1 << 16) * CONFIG_SEQ_CHECK_VLAN_MAX ; i++)
+ {
+ /* Get a random VLAN. */
+ uint vlan = lib_rnd_uniform (rnd, CONFIG_SEQ_CHECK_VLAN_MAX);
+ /* Write VLAN. */
+ bitstream_direct_write ((u8 *) p, 6 * 2 * 8 + 16, swap16 (vlan),
+ 16);
+
+ test_seq_check_callback_values.cb_called = false;
+ bitstream_direct_write (p, pos * 8, swap16 (seq[vlan]), 16);
+ lib_seq_check_packet (&s, (u8 *) p, ETH_PACKET_MAX_SIZE);
+ test_fail_if (test_seq_check_callback_values.cb_called == true);
+ seq[vlan]++;
+ }
+ } test_end;
+
+ test_begin (t, "good and bad sequence with VLAN")
+ {
+ u16 seq[CONFIG_SEQ_CHECK_VLAN_MAX], prev;
+
+ /* Re-init. */
+ lib_seq_check_init (&s, test_seq_check_cb,
+ &test_seq_check_callback_values);
+ /* Store ethertype. */
+ test_seq_check_write_ethertype ((u8 *) p, ethertype, true);
+
+ for (i = 0; i < CONFIG_SEQ_CHECK_VLAN_MAX; i ++)
+ {
+ seq[i] = 0;
+ }
+
+ for (i = 0; i < (1 << 16) * CONFIG_SEQ_CHECK_VLAN_MAX ; i++)
+ {
+ /* Get a random VLAN. */
+ uint vlan = lib_rnd_uniform (rnd, CONFIG_SEQ_CHECK_VLAN_MAX);
+ /* Write VLAN. */
+ bitstream_direct_write ((u8 *) p, 6 * 2 * 8 + 16, swap16 (vlan),
+ 16);
+
+ if (lib_rnd_uniform (rnd, 2))
+ res = true;
+ else
+ {
+ prev = seq[vlan];
+ seq[vlan] = lib_rnd_uniform (rnd, 1 << 16);
+ if (seq[vlan] == prev)
+ seq[vlan]++;
+ test_seq_check_callback_values.vlan = vlan;
+ test_seq_check_callback_values.seq_expected = prev;
+ test_seq_check_callback_values.seq_actual = seq[vlan];
+ res = false;
+ }
+ test_seq_check_callback_values.cb_called = false;
+ bitstream_direct_write (p, pos * 8, swap16 (seq[vlan]), 16);
+ lib_seq_check_packet (&s, (u8 *) p, ETH_PACKET_MAX_SIZE);
+ test_fail_if (test_seq_check_callback_values.cb_called == res);
+ seq[vlan]++;
+ }
+ } test_end;
+}
+
+int
+main (int argc, char **argv)
+{
+ lib_rnd_t rnd;
+ test_t test;
+
+ lib_rnd_init (&rnd, 0x42);
+ test_init (test, argc, argv);
+
+ test_suite_begin (test, "sequence check");
+
+ lib_seq_check_config_init ();
+
+ test_begin (test, "default config")
+ {
+ lib_seq_check_config_t conf;
+ lib_seq_check_config_get (&conf);
+ test_fail_if (conf.seq_size != 16);
+ test_fail_if (conf.seq_pos != 44);
+ test_fail_if (conf.ethertype != 0x8000);
+ } test_end;
+
+ test_case_begin (test, "IPerf");
+ /* Iperf position is at 44 and we check only IP packet. */
+ test_seq_check_packet (test, &rnd, 44, 0x8000);
+
+ test_case_begin (test, "Other");
+ /* Iperf position is at 44 and we check only IP packet. */
+ test_seq_check_packet (test, &rnd, 50, 0x8042);
+
+ test_result (test);
+ return test_nb_failed (test);
+}
+
diff --git a/cesar/lib/test/utils/src/test_utils.c b/cesar/lib/test/utils/src/test_utils.c
index 8b7beab993..751a518b65 100644
--- a/cesar/lib/test/utils/src/test_utils.c
+++ b/cesar/lib/test/utils/src/test_utils.c
@@ -13,6 +13,55 @@
#include "common/std.h"
#include "lib/test.h"
+#include "float.h"
+#include "math.h"
+
+void
+eq_test_case (test_t t)
+{
+ test_case_begin (t, "eq");
+ test_begin (t, "almost_eqf basic")
+ {
+ test_fail_unless (almost_eqf (1.0f, 1.0f, 1));
+ test_fail_unless (!almost_eqf (1.0f, 2.0f, 1));
+ test_fail_unless (!almost_eqf (1000.0f, 2000.0f, 1));
+ /* FLT_EPSILON is the smallest number for which:
+ * 1.0f != 1.0f + FLT_EPSILON. */
+ test_fail_unless (almost_eqf (1.0f, 1.0f + FLT_EPSILON, 1));
+ test_fail_unless (!almost_eqf (1.0f, 1.0f + FLT_EPSILON * 2, 1));
+ test_fail_unless (almost_eqf (1.0f, 1.0f + FLT_EPSILON * 2, 2));
+ test_fail_unless (almost_eqf (512.f, 512.f + 512 * FLT_EPSILON, 1));
+ test_fail_unless (!almost_eqf (512.f, 512.f + 1024 * FLT_EPSILON, 1));
+ test_fail_unless (almost_eqf (512.f, 512.f + 1024 * FLT_EPSILON, 2));
+ } test_end;
+ test_begin (t, "almost_eqf zeroes")
+ {
+ /* IEEE floats are ordered. Compute the smallest non-zero positive and
+ * negative number. Those are subnormals. */
+ float ep = 0.0f;
+ s32 epb = *(s32 *)&ep + 1;
+ ep = *(float *) &epb;
+ float em = -0.0f;
+ s32 emb = *(s32 *)&em + 1;
+ em = *(float *) &emb;
+ /* Test around zero. */
+ test_fail_unless (almost_eqf (0.0f, -0.0f, 1));
+ test_fail_unless (almost_eqf (ep, em, 2));
+ test_fail_unless (!almost_eqf (ep, em, 1));
+ } test_end;
+ test_begin (t, "almost_eqf infinity")
+ {
+ /* Accepted complication. */
+ test_fail_unless (almost_eqf (INFINITY, FLT_MAX, 1));
+ test_fail_unless (almost_eqf (-INFINITY, -FLT_MAX, 1));
+ } test_end;
+ test_begin (t, "almost_eqf NaN")
+ {
+ test_fail_unless (!almost_eqf (NAN, 1.0f, 1));
+ /* Accepted complication. */
+ test_fail_unless (almost_eqf (NAN, NAN, 1));
+ } test_end;
+}
void
bits_test_case (test_t t)
@@ -229,6 +278,7 @@ void
utils_test_suite (test_t t)
{
test_suite_begin (t, "utils");
+ eq_test_case (t);
bits_test_case (t);
bf_test_case (t);
rot_test_case (t);
diff --git a/cesar/lib/utils.h b/cesar/lib/utils.h
index 5d0c237c37..c3229f27ce 100644
--- a/cesar/lib/utils.h
+++ b/cesar/lib/utils.h
@@ -341,4 +341,16 @@ distance_mod2p16 (u16 a, u16 b)
index = a_; \
} while (0)
+BEGIN_DECLS
+
+/** Compare floating point numbers, return true if they are almost equal.
+ * \param a first number to compare
+ * \param b second number to compare
+ * \param max_ulps maximum error as unit in the last place
+ */
+bool
+almost_eqf (float a, float b, int max_ulps);
+
+END_DECLS
+
#endif /* lib_utils_h */
diff --git a/cesar/mac/design/test/mfs_tx2/src/test_mfs.c b/cesar/mac/design/test/mfs_tx2/src/test_mfs.c
index 7336db2b9b..6031799420 100644
--- a/cesar/mac/design/test/mfs_tx2/src/test_mfs.c
+++ b/cesar/mac/design/test/mfs_tx2/src/test_mfs.c
@@ -72,7 +72,7 @@ void random_test()
test.when_to_free=lib_rnd_uniform(&rnd,0x2000);
}
-mfs_t
+void
init_mfs ()
{
mfs.head = NULL;
@@ -87,7 +87,6 @@ init_mfs ()
total_pb_released=0;
pbproc.head_tx=NULL;
pbproc.tail_tx=NULL;
- return (mfs);
}
@@ -546,7 +545,7 @@ tst(void)
{
int n=0;
int zadded=0;
- mfs=init_mfs();
+ init_mfs();
printf("take:%x free: %x\n", test.when_to_take,test.when_to_free);
for(n=0; n<10; n++)
{
@@ -569,7 +568,7 @@ int
main (void)
{
lib_rnd_init (&rnd, 456);
- mfs_t mfs = init_mfs();
+ init_mfs();
test.when_to_take=0;
test.when_to_free=0;
int t=0;
diff --git a/cesar/mac/pbproc/src/fsm_rx_sound.c b/cesar/mac/pbproc/src/fsm_rx_sound.c
index d784bbf0b5..abd7e3bce9 100644
--- a/cesar/mac/pbproc/src/fsm_rx_sound.c
+++ b/cesar/mac/pbproc/src/fsm_rx_sound.c
@@ -33,7 +33,7 @@ pbproc_frso_init (pbproc_t *ctx)
pbproc_frso__rx_sound__pbdma;
}
-void ARCH_ILRAM
+void ARCH_ILRAM_PRIO (2)
pbproc_frso__handle (pbproc_t *ctx, u32 rx_date,
const pbproc_fc_sound_t *sound)
{
@@ -198,7 +198,7 @@ pbproc_frso__handle (pbproc_t *ctx, u32 rx_date,
pbproc_frso__rx_sound__pbdma (ctx);
}
-void ARCH_ILRAM
+void ARCH_ILRAM_PRIO (2)
pbproc_frso__rx_sound__pbdma (pbproc_t *ctx)
{
dbg_claim (ctx);
@@ -292,7 +292,7 @@ pbproc_frso__rx_sound__pbdma (pbproc_t *ctx)
#if CONFIG_MAC_PBPROC_EOC_FC
static void
#else
-static void ARCH_ILRAM
+static void ARCH_ILRAM_PRIO (2)
#endif
pbproc_frso_vcs_restart (pbproc_t *ctx)
{
diff --git a/cesar/mac/pbproc/src/fsm_tx_sound.c b/cesar/mac/pbproc/src/fsm_tx_sound.c
index bca07ad9ef..98b05b6679 100644
--- a/cesar/mac/pbproc/src/fsm_tx_sound.c
+++ b/cesar/mac/pbproc/src/fsm_tx_sound.c
@@ -32,7 +32,7 @@ pbproc_ftso_init (pbproc_t *ctx)
pbproc_ftso__tx_sound_wait_ack__access;
}
-void ARCH_ILRAM
+void ARCH_ILRAM_PRIO (2)
pbproc_ftso__handle (pbproc_t *ctx)
{
dbg_claim (ctx);
@@ -50,7 +50,7 @@ pbproc_ftso__handle (pbproc_t *ctx)
ctx->stats.tx_sound++;
}
-void ARCH_ILRAM
+void ARCH_ILRAM_PRIO (2)
pbproc_ftso__tx_sound_wait_ack__rx_fc (pbproc_t *ctx, u32 rx_date,
const pbproc_fc_t *fc_av)
{
@@ -112,7 +112,7 @@ pbproc_ftso__tx_sound_wait_ack__rx_fc (pbproc_t *ctx, u32 rx_date,
#if CONFIG_MAC_PBPROC_EOC_FC
void
#else
-void ARCH_ILRAM
+void ARCH_ILRAM_PRIO (2)
#endif
pbproc_ftso__tx_sound_wait_ack__access (pbproc_t *ctx)
{
diff --git a/cesar/mac/pbproc/src/prep_mpdu.c b/cesar/mac/pbproc/src/prep_mpdu.c
index 0e34d6a0e2..52a149b38b 100644
--- a/cesar/mac/pbproc/src/prep_mpdu.c
+++ b/cesar/mac/pbproc/src/prep_mpdu.c
@@ -113,7 +113,7 @@ pbproc_get_segments_nb (mfs_tx_t *mfs)
#if (CONFIG_MAC_PBPROC_EOC_FC)
void /*ARCH_ILRAM: TODO ugly */
#else
-void ARCH_ILRAM
+void ARCH_ILRAM_PRIO (1)
#endif
pbproc_prep_beacon (pbproc_t *ctx, mfs_tx_t *mfs)
{
diff --git a/cesar/mac/pbproc/test/int/sparc-Config b/cesar/mac/pbproc/test/int/sparc-Config
index 556d1a6160..34df90d773 100644
--- a/cesar/mac/pbproc/test/int/sparc-Config
+++ b/cesar/mac/pbproc/test/int/sparc-Config
@@ -5,3 +5,4 @@ CONFIG_INTERFACE_SNIFFER = n
CONFIG_MAC_COMMON_EOC_SCHED = y
CONFIG_MAC_PBPROC_EOC_FC = y
CONFIG_MAC_COMMON_EOC_MFS = y
+CONFIG_ARCH_ILRAM_PRIO = 0
diff --git a/cesar/mac/sar/inc/sar_context.h b/cesar/mac/sar/inc/sar_context.h
index e47f2912a1..dc5aaacb42 100644
--- a/cesar/mac/sar/inc/sar_context.h
+++ b/cesar/mac/sar/inc/sar_context.h
@@ -17,6 +17,7 @@
#include "mac/pbproc/pbproc.h"
#include "lib/slist.h"
#include "lib/rnd.h"
+#include "lib/seq_check.h"
#include "hal/phy/bridgedma.h"
#ifdef STATION_H_
@@ -201,6 +202,9 @@ struct sar_t
#if CONFIG_STATS
sar_stats_t stats;
#endif
+#if CONFIG_SEQ_CHECK
+ lib_seq_check_t seq;
+#endif
};
#endif /*SAR_CONTEXT_H_*/
diff --git a/cesar/mac/sar/inc/trace.h b/cesar/mac/sar/inc/trace.h
index 93ce021c61..ebd8af078c 100644
--- a/cesar/mac/sar/inc/trace.h
+++ b/cesar/mac/sar/inc/trace.h
@@ -43,6 +43,7 @@ enum
SAR_TRACE_PB_TX_RELEASE,
SAR_TRACE_PB_RX_RELEASE,
SAR_TRACE_EXHAUSTED_MEMORY,
+ SAR_TRACE_SEQ_CHECK,
};
BEGIN_DECLS
diff --git a/cesar/mac/sar/src/sar.c b/cesar/mac/sar/src/sar.c
index 5fd30818b6..ae405375f4 100644
--- a/cesar/mac/sar/src/sar.c
+++ b/cesar/mac/sar/src/sar.c
@@ -24,6 +24,7 @@
#include "mac/sar/inc/sar_context.h"
#include "mac/sar/inc/sar.h"
#include "mac/sar/inc/sar_expiration.h"
+#include "lib/seq_check.h"
#include "hal/arch/arch.h"
#include "common/defs/priority.h"
@@ -53,6 +54,26 @@
static struct sar_t sar_global;
/**
+ * Callback when the lib sequencer detect a wrong sequencing.
+ * \param user user data
+ * \param vlan the VLAN id
+ * \param seq_expected the sequence number expected
+ * \param seq_actual the actual sequence number found in the packet
+ */
+void
+sar_lib_seq_check_cb (void *user, uint vlan, uint seq_expected,
+ uint seq_actual);
+
+void
+sar_lib_seq_check_cb (void *user, uint vlan, uint seq_expected,
+ uint seq_actual)
+{
+ dbg_assert (user);
+ trace_do (sar_t *ctx = (sar_t *) user);
+ SAR_TRACE (SEQ_CHECK, vlan, seq_expected, seq_actual);
+}
+
+/**
* Compute the gap between two SSNs.
* \param a the first SSN,
* \param b the Second SSN.
@@ -500,6 +521,8 @@ sar_init (mac_store_t *mac_store, pbproc_t *pbproc, ca_t *ca, u32 seed)
/** Trace system. */
ctx = &sar_global;
sar_trace_init(ctx);
+ /* Initialize sequence checker. */
+ lib_seq_check_init (&ctx->seq, sar_lib_seq_check_cb, &sar_global);
#if CONFIG_STATS
sar_stats_init (&ctx->stats);
#endif
@@ -827,6 +850,9 @@ sar_msdu_add (sar_t *ctx, u8 *buffer, u16 length, mfs_tx_t *mfs,
mfs->stats.num_msdus ++;
mfs->stats.octets += length;
+ /* Check sequence. */
+ lib_seq_check_packet (&ctx->seq, buffer, length);
+
/* Enough block available to send a frame and SAR is activated ? */
if ((blk_slack () || mfs->common.mme) && ctx->activate)
{
@@ -1838,7 +1864,7 @@ sar_tx_mac_framing (sar_t *ctx, sar_msdu_t *md_data)
&ctx->job_tx->job);
}
-pb_t * ARCH_ILRAM
+pb_t * ARCH_ILRAM_PRIO (1)
sar_tx_job_desc_create (sar_t *ctx, sar_msdu_t *md_data, mfs_tx_t * mfs,
sar_job_mfs_t *job_mfs)
{
diff --git a/cesar/mac/sar/src/trace.c b/cesar/mac/sar/src/trace.c
index cf4a0dcab3..a951e34075 100644
--- a/cesar/mac/sar/src/trace.c
+++ b/cesar/mac/sar/src/trace.c
@@ -51,6 +51,8 @@ sar_trace_init (sar_t *ctx)
"PB expire ssn %d in mfs : %x"),
TRACE_EVENT (SAR_TRACE_EXHAUSTED_MEMORY,
"exhausted memory, Frame drop from SSN %d to %d"),
+ TRACE_EVENT (SAR_TRACE_SEQ_CHECK, "[SeqCheck] output to PLC: "
+ "[%02d] expected=%04X, actual=%04X"),
};
dbg_assert (ctx);
trace_namespace_init (&namespace, event_ids, COUNT (event_ids));
diff --git a/cesar/maximus/channel/src/ChannelComputerTest.cpp b/cesar/maximus/channel/src/ChannelComputerTest.cpp
index 31e980c5f8..fead652382 100644
--- a/cesar/maximus/channel/src/ChannelComputerTest.cpp
+++ b/cesar/maximus/channel/src/ChannelComputerTest.cpp
@@ -145,69 +145,69 @@ void ChannelComputerTest::protectedTest (void)
// Test PowerScale
Channel_Mod modulation = MAXIMUS_CHANNEL_MOD_BPSK;
float powerScale = channelComputer.getPowerScaleTest(modulation);
- CPPUNIT_ASSERT_MESSAGE ( "getPowerScale failed", 1 == powerScale);
+ CPPUNIT_ASSERT_MESSAGE ( "getPowerScale failed", almost_eqf (1, powerScale, 5));
modulation = MAXIMUS_CHANNEL_MOD_QPSK;
powerScale = channelComputer.getPowerScaleTest(modulation);
- CPPUNIT_ASSERT_MESSAGE ( "getPowerScale failed", 2 == powerScale);
+ CPPUNIT_ASSERT_MESSAGE ( "getPowerScale failed", almost_eqf (2, powerScale, 5));
modulation = MAXIMUS_CHANNEL_MOD_QAM8;
powerScale = channelComputer.getPowerScaleTest(modulation);
- CPPUNIT_ASSERT_MESSAGE ( "getPowerScale failed", (float)(5+pow(1.29,2)) == powerScale);
+ CPPUNIT_ASSERT_MESSAGE ( "getPowerScale failed", almost_eqf (5 + pow (1.29, 2), powerScale, 5));
modulation = MAXIMUS_CHANNEL_MOD_QAM16;
powerScale = channelComputer.getPowerScaleTest(modulation);
- CPPUNIT_ASSERT_MESSAGE ( "getPowerScale failed", 10 == powerScale);
+ CPPUNIT_ASSERT_MESSAGE ( "getPowerScale failed", almost_eqf (10, powerScale, 5));
modulation = MAXIMUS_CHANNEL_MOD_QAM64;
powerScale = channelComputer.getPowerScaleTest(modulation);
- CPPUNIT_ASSERT_MESSAGE ( "getPowerScale failed", 42 == powerScale);
+ CPPUNIT_ASSERT_MESSAGE ( "getPowerScale failed", almost_eqf (42, powerScale, 5));
modulation = MAXIMUS_CHANNEL_MOD_QAM256;
powerScale = channelComputer.getPowerScaleTest(modulation);
- CPPUNIT_ASSERT_MESSAGE ( "getPowerScale failed", 170 == powerScale);
+ CPPUNIT_ASSERT_MESSAGE ( "getPowerScale failed", almost_eqf (170, powerScale, 5));
modulation = MAXIMUS_CHANNEL_MOD_QAM1024;
powerScale = channelComputer.getPowerScaleTest(modulation);
- CPPUNIT_ASSERT_MESSAGE ( "getPowerScale failed", 682 == powerScale);
+ CPPUNIT_ASSERT_MESSAGE ( "getPowerScale failed", almost_eqf (682, powerScale, 5));
// Test linear SNR
float snr = 10; // in dB
double linearSnr = channelComputer.getLinearSnrTest(snr);
- CPPUNIT_ASSERT_MESSAGE ( "getLinearSnr failed", 10 == linearSnr);
+ CPPUNIT_ASSERT_MESSAGE ( "getLinearSnr failed", almost_eqf (10, linearSnr, 5));
snr = 16; // in dB
linearSnr = channelComputer.getLinearSnrTest(snr);
- CPPUNIT_ASSERT_MESSAGE ( "getLinearSnr failed", (float)pow(10, 1.6) == linearSnr);
+ CPPUNIT_ASSERT_MESSAGE ( "getLinearSnr failed", almost_eqf (pow (10, 1.6), linearSnr, 5));
snr = 15.55555; // in dB
linearSnr = channelComputer.getLinearSnrTest(snr);
- CPPUNIT_ASSERT_MESSAGE ( "getLinearSnr failed", (float)pow(10, 1.555555) == linearSnr);
+ CPPUNIT_ASSERT_MESSAGE ( "getLinearSnr failed", almost_eqf (pow (10, 1.555555), linearSnr, 5));
// Test sigma factor
modulation = MAXIMUS_CHANNEL_MOD_BPSK;
snr = 10; // in dB
double sigma = channelComputer.getSigmaTest(modulation, snr);
- CPPUNIT_ASSERT_MESSAGE ( "getSigma failed", (double)sqrt(1/(2*channelComputer.getLinearSnrTest(snr))) == sigma);
+ CPPUNIT_ASSERT_MESSAGE ( "getSigma failed", almost_eqf (sqrt(1/(2*channelComputer.getLinearSnrTest(snr))), sigma, 5));
modulation = MAXIMUS_CHANNEL_MOD_QPSK;
snr = 11.1; // in dB
sigma = channelComputer.getSigmaTest(modulation, snr);
- CPPUNIT_ASSERT_MESSAGE ( "getSigma failed", (double)sqrt(2/(2*channelComputer.getLinearSnrTest(snr))) == sigma);
+ CPPUNIT_ASSERT_MESSAGE ( "getSigma failed", almost_eqf (sqrt(2/(2*channelComputer.getLinearSnrTest(snr))), sigma, 5));
modulation = MAXIMUS_CHANNEL_MOD_QAM8;
snr = 12.2; // in dB
sigma = channelComputer.getSigmaTest(modulation, snr);
- CPPUNIT_ASSERT_MESSAGE ( "getSigma failed", (double)sqrt((float)(5+pow(1.29, 2))/(2*channelComputer.getLinearSnrTest(snr))) == sigma);
+ CPPUNIT_ASSERT_MESSAGE ( "getSigma failed", almost_eqf (sqrt((5+pow(1.29, 2))/(2*channelComputer.getLinearSnrTest(snr))), sigma, 5));
modulation = MAXIMUS_CHANNEL_MOD_QAM16;
snr = 13.3; // in dB
sigma = channelComputer.getSigmaTest(modulation, snr);
- CPPUNIT_ASSERT_MESSAGE ( "getSigma failed", (double)sqrt(10/(2*channelComputer.getLinearSnrTest(snr))) == sigma);
+ CPPUNIT_ASSERT_MESSAGE ( "getSigma failed", almost_eqf (sqrt(10/(2*channelComputer.getLinearSnrTest(snr))), sigma, 5));
modulation = MAXIMUS_CHANNEL_MOD_QAM64;
snr = 14.4; // in dB
sigma = channelComputer.getSigmaTest(modulation, snr);
- CPPUNIT_ASSERT_MESSAGE ( "getSigma failed", (double)sqrt(42/(2*channelComputer.getLinearSnrTest(snr))) == sigma);
+ CPPUNIT_ASSERT_MESSAGE ( "getSigma failed", almost_eqf (sqrt(42/(2*channelComputer.getLinearSnrTest(snr))), sigma, 5));
modulation = MAXIMUS_CHANNEL_MOD_QAM256;
snr = 15.5; // in dB
sigma = channelComputer.getSigmaTest(modulation, snr);
- CPPUNIT_ASSERT_MESSAGE ( "getSigma failed", (double)sqrt(170/(2*channelComputer.getLinearSnrTest(snr))) == sigma);
+ CPPUNIT_ASSERT_MESSAGE ( "getSigma failed", almost_eqf (sqrt(170/(2*channelComputer.getLinearSnrTest(snr))), sigma, 5));
modulation = MAXIMUS_CHANNEL_MOD_QAM1024;
snr = 16.6; // in dB
sigma = channelComputer.getSigmaTest(modulation, snr);
- CPPUNIT_ASSERT_MESSAGE ( "getSigma failed", (double)sqrt(682/(2*channelComputer.getLinearSnrTest(snr))) == sigma);
+ CPPUNIT_ASSERT_MESSAGE ( "getSigma failed", almost_eqf (sqrt(682/(2*channelComputer.getLinearSnrTest(snr))), sigma, 5));
snr = 0; // in dB
sigma = channelComputer.getSigmaTest(modulation, snr);
- CPPUNIT_ASSERT_MESSAGE ( "getSigma failed", (double)sqrt(682/(2*channelComputer.getLinearSnrTest(snr))) == sigma);
+ CPPUNIT_ASSERT_MESSAGE ( "getSigma failed", almost_eqf (sqrt(682/(2*channelComputer.getLinearSnrTest(snr))), sigma, 5));
// Test noise point
ChannelPoint point(1, 0);
@@ -268,7 +268,7 @@ void ChannelComputerTest::protectedTest (void)
modulation = MAXIMUS_CHANNEL_MOD_BPSK;
float fer = channelComputer.computeFerTest(ber, n, modulation);
float expectedFer = pow(10, 1-(unsigned short int)100*exp(-pow((unsigned short int)50*ber, 2)))/10;
- CPPUNIT_ASSERT_MESSAGE ( "computeFer 1 failed", expectedFer == fer);
+ CPPUNIT_ASSERT_MESSAGE ( "computeFer 1 failed", almost_eqf (expectedFer, fer, 5));
modulation = MAXIMUS_CHANNEL_MOD_QPSK;
fer = channelComputer.computeFerTest(ber, n, modulation);
expectedFer = pow(10, 1-(unsigned short int)100*exp(-pow((unsigned short int)50*(ber-0.01*(float)4.6), 2)))/10;
diff --git a/cesar/maximus/coreengine/src/Maximus.cpp b/cesar/maximus/coreengine/src/Maximus.cpp
index 2dc2068d1b..8a885d6c69 100644
--- a/cesar/maximus/coreengine/src/Maximus.cpp
+++ b/cesar/maximus/coreengine/src/Maximus.cpp
@@ -1317,6 +1317,7 @@ void Maximus::stop ( )
if (0 <= mEtherLogFileDescriptor)
{
close(mEtherLogFileDescriptor);
+ mEtherLogFileDescriptor = -1;
}
// Warning: delete the Core Engine is the last task to do!
diff --git a/cesar/maximus/ethernet/src/EthernetProcessor.cpp b/cesar/maximus/ethernet/src/EthernetProcessor.cpp
index b318fc89f3..1d7c7267ef 100644
--- a/cesar/maximus/ethernet/src/EthernetProcessor.cpp
+++ b/cesar/maximus/ethernet/src/EthernetProcessor.cpp
@@ -202,6 +202,12 @@ File_Descriptor EthernetProcessor::allocTap ( char * dev ) const
}
else
{
+ /* Set persistent status */
+ if (0 > ioctl(etherLogFileDescriptor, TUNSETPERSIST, 1))
+ {
+ throw Error(__PRETTY_FUNCTION__, "enabling TUNSETPERSIST failed", errno);
+ }
+
/* We don't need checksums calculated for packets coming in this device */
ioctl(etherLogFileDescriptor, TUNSETNOCSUM, 1);
diff --git a/cesar/maximus/prototest/fcall/src/test_fcall.c b/cesar/maximus/prototest/fcall/src/test_fcall.c
index a09b7b66a7..878170d44d 100644
--- a/cesar/maximus/prototest/fcall/src/test_fcall.c
+++ b/cesar/maximus/prototest/fcall/src/test_fcall.c
@@ -14,7 +14,7 @@
*/
#include <cyg/infra/diag.h>
#include <cyg/kernel/kapi.h>
-#include <malloc.h>
+#include <stdlib.h>
#include <errno.h>
#include "common/std.h"
#include "interface/fcall/interface_fcall.h"
@@ -22,6 +22,7 @@
#include "lib/swap.h" // for 'swap16()' and 'swap32()'
#include "lib/read_word.h" // for 'read_u16_from_word()'
#include "maximus/prototest/fcall/inc/syscall.h"
+#include "common/defs/ethernet.h"
#define MY_THREAD_STACK_SIZE (8192 / sizeof(int))
@@ -47,10 +48,14 @@ void my_thread(cyg_addrword_t index)
memset(my_mme, '\0', SCI_MSG_MAX_SIZE);
while (INTERFACE_FCALL_PAYLOAD_OFFSET != len)
{
- len = read(proto_in_fd, my_mme, INTERFACE_FCALL_PAYLOAD_OFFSET);
+ int r = read (proto_in_fd, my_mme + len,
+ INTERFACE_FCALL_PAYLOAD_OFFSET - len);
+ dbg_assert (r != -1 || errno == EINTR);
+ if (r > 0)
+ len += r;
}
- dbg_assert(INTERFACE_FCALL_PAYLOAD_OFFSET == len);
data_length = swap16(read_u16_from_word(my_mme + INTERFACE_FCALL_PAYLOAD_OFFSET - sizeof(u16)));
+ data_length = MAX (ETH_PACKET_MIN_SIZE - len, data_length);
if ((len = read(proto_in_fd, my_mme + INTERFACE_FCALL_PAYLOAD_OFFSET, data_length)) < 0)
{
diag_printf("errno = %d: error when reading proto in file (data_length = %d)\n", errno, data_length);
diff --git a/cesar/maximus/python/maximus/ethernet/scapy.py b/cesar/maximus/python/maximus/ethernet/scapy.py
index a7074d4f5c..df9bde3943 100644
--- a/cesar/maximus/python/maximus/ethernet/scapy.py
+++ b/cesar/maximus/python/maximus/ethernet/scapy.py
@@ -99,7 +99,6 @@ if __name__ == "__main__":
import socket, sys, getopt, string, struct, random, code
import cPickle, copy, types, gzip, base64, re, zlib, array
-from sets import Set
from select import select
from glob import glob
from fcntl import ioctl
diff --git a/cesar/maximus/python/maximus/station/sta.py b/cesar/maximus/python/maximus/station/sta.py
index 0a867d9257..0dd9a89d07 100644
--- a/cesar/maximus/python/maximus/station/sta.py
+++ b/cesar/maximus/python/maximus/station/sta.py
@@ -157,15 +157,8 @@ class STA:
.send(self.get())
else: # we need to build an MME
- # Use the OSA with a default mac address.
- osa = DEFAULT_MAC_ADDRESS
-
- # Get the mac address provided in the Station configuration.
- if self.get_mac_address() is not None:
- oda = self.get_mac_address()
- else:
- oda = DEFAULT_MAC_ADDRESS
- mmheader = MMHeader(ODA=oda, OSA=osa, MMV=0x01, MMTYPE = DRV_STA_START + MME_TYPES['REQ'])
+ # Computes MM Header
+ mmheader = MMHeader(ODA=self.__get_oda(), OSA=DEFAULT_MAC_ADDRESS, MMV=0x01, MMTYPE = DRV_STA_START + MME_TYPES['REQ'])
# Create the MME
data = ''
@@ -196,12 +189,7 @@ class STA:
else: # we need to build an MME
# Computes MM Header
- osa = DEFAULT_MAC_ADDRESS
- if self.get_mac_address() is not None:
- oda = self.get_mac_address()
- else:
- oda = DEFAULT_MAC_ADDRESS
- mmheader = MMHeader(ODA=oda, OSA=osa, MMV=0x01, MMTYPE = DRV_STA_STOP + MME_TYPES['REQ'])
+ mmheader = MMHeader(ODA=self.__get_oda(), OSA=DEFAULT_MAC_ADDRESS, MMV=0x01, MMTYPE = DRV_STA_STOP + MME_TYPES['REQ'])
# Create the MME
mme = MME(MMHeader=mmheader)
@@ -530,6 +518,17 @@ class STA:
"""
return self.__maximus
+ def __get_oda(self):
+ """Get the ODA to be used to send DRV MME-s.
+ The ODA is a Python tuple of 6 Python integers or a Python long.
+ """
+ # Get the mac address provided in the STA config if any
+ if self.get_mac_address() is not None:
+ oda = self.get_mac_address()
+ else:
+ oda = DEFAULT_MAC_ADDRESS
+ return oda
+
def get(self):
"""Get the station.
The station is a Sta object.
@@ -658,7 +657,7 @@ class STA:
else: # we need to build an MME
# Computes MM Header
- mmheader = MMHeader(ODA=DEFAULT_MAC_ADDRESS, OSA=self.get_mac_address(), MMV=0x01, MMTYPE = DRV_STA_SET_MAC_ADDR + MME_TYPES['REQ'])
+ mmheader = MMHeader(ODA=DEFAULT_MAC_ADDRESS, OSA=DEFAULT_MAC_ADDRESS, MMV=0x01, MMTYPE = DRV_STA_SET_MAC_ADDR + MME_TYPES['REQ'])
# Computes MM Entry: Mac address of the station
# Octet Number = 0 - 5
@@ -691,12 +690,7 @@ class STA:
else: # we need to build an MME
# Computes MM Header
- osa = DEFAULT_MAC_ADDRESS
- if self.get_mac_address() is not None:
- oda = self.get_mac_address()
- else:
- oda = DEFAULT_MAC_ADDRESS
- mmheader = MMHeader(ODA=oda, OSA=osa, MMV=0x01, MMTYPE = DRV_STA_SET_CCO_PREF + MME_TYPES['REQ'])
+ mmheader = MMHeader(ODA=self.__get_oda(), OSA=DEFAULT_MAC_ADDRESS, MMV=0x01, MMTYPE = DRV_STA_SET_CCO_PREF + MME_TYPES['REQ'])
# Computes MM Entry:
# - 0x00 = Station is not CCo
@@ -733,12 +727,7 @@ class STA:
else: # we need to build an MME
# Computes MM Header
- osa = self.get_mac_address()
- if self.get_mac_address() is not None:
- oda = self.get_mac_address()
- else:
- oda = DEFAULT_MAC_ADDRESS
- mmheader = MMHeader(ODA=oda, OSA=osa, MMV=0x01, MMTYPE = DRV_STA_SET_WAS_CCO + MME_TYPES['REQ'])
+ mmheader = MMHeader(ODA=self.__get_oda(), OSA=DEFAULT_MAC_ADDRESS, MMV=0x01, MMTYPE = DRV_STA_SET_WAS_CCO + MME_TYPES['REQ'])
# Computes MM Entry:
# - 0x00 = Station was not CCo
@@ -775,12 +764,7 @@ class STA:
else: # we need to build an MME
# Computes MM Header
- osa = DEFAULT_MAC_ADDRESS
- if self.get_mac_address() is not None:
- oda = self.get_mac_address()
- else:
- oda = DEFAULT_MAC_ADDRESS
- mmheader = MMHeader(ODA=oda, OSA=osa, MMV=0x01, MMTYPE = DRV_STA_SET_NPW + MME_TYPES['REQ'])
+ mmheader = MMHeader(ODA=self.__get_oda(), OSA=DEFAULT_MAC_ADDRESS, MMV=0x01, MMTYPE = DRV_STA_SET_NPW + MME_TYPES['REQ'])
# Computes MM Entry: Human-Readable (ASCII) Station Network Password
# Octet Number = 0 - 63
@@ -813,12 +797,7 @@ class STA:
else: # we need to build an MME
# Computes MM Header
- osa = DEFAULT_MAC_ADDRESS
- if self.get_mac_address() is not None:
- oda = self.get_mac_address()
- else:
- oda = DEFAULT_MAC_ADDRESS
- mmheader = MMHeader(ODA=oda, OSA=osa, MMV=0x01, MMTYPE = DRV_STA_SET_DPW + MME_TYPES['REQ'])
+ mmheader = MMHeader(ODA=self.__get_oda(), OSA=DEFAULT_MAC_ADDRESS, MMV=0x01, MMTYPE = DRV_STA_SET_DPW + MME_TYPES['REQ'])
# Computes MM Entry: Human-Readable (ASCII) Station Device Password
# Octet Number = 0 - 63
@@ -851,12 +830,7 @@ class STA:
else: # we need to build an MME
# Computes MM Header
- osa = DEFAULT_MAC_ADDRESS
- if self.get_mac_address() is not None:
- oda = self.get_mac_address()
- else:
- oda = DEFAULT_MAC_ADDRESS
- mmheader = MMHeader(ODA=oda, OSA=osa, MMV=0x01, MMTYPE = DRV_STA_SET_M_STA_HFID + MME_TYPES['REQ'])
+ mmheader = MMHeader(ODA=self.__get_oda(), OSA=DEFAULT_MAC_ADDRESS, MMV=0x01, MMTYPE = DRV_STA_SET_M_STA_HFID + MME_TYPES['REQ'])
# Computes MM Entry: Manufacturer Station Human-Friendly ID in ASCII format
# Octet Number = 0 - 63
@@ -889,12 +863,7 @@ class STA:
else: # we need to build an MME
# Computes MM Header
- osa = DEFAULT_MAC_ADDRESS
- if self.get_mac_address() is not None:
- oda = self.get_mac_address()
- else:
- oda = DEFAULT_MAC_ADDRESS
- mmheader = MMHeader(ODA=oda, OSA=osa, MMV=0x01, MMTYPE = DRV_STA_SET_U_STA_HFID + MME_TYPES['REQ'])
+ mmheader = MMHeader(ODA=self.__get_oda(), OSA=DEFAULT_MAC_ADDRESS, MMV=0x01, MMTYPE = DRV_STA_SET_U_STA_HFID + MME_TYPES['REQ'])
# Computes MM Entry: User Station Human-Friendly ID in ASCII format
# Octet Number = 0 - 63
@@ -927,12 +896,7 @@ class STA:
else: # we need to build an MME
# Computes MM Header
- osa = DEFAULT_MAC_ADDRESS
- if self.get_mac_address() is not None:
- oda = self.get_mac_address()
- else:
- oda = DEFAULT_MAC_ADDRESS
- mmheader = MMHeader(ODA=oda, OSA=osa, MMV=0x01, MMTYPE = DRV_STA_SET_AVLN_HFID + MME_TYPES['REQ'])
+ mmheader = MMHeader(ODA=self.__get_oda(), OSA=DEFAULT_MAC_ADDRESS, MMV=0x01, MMTYPE = DRV_STA_SET_AVLN_HFID + MME_TYPES['REQ'])
# Computes MM Entry: AVLN Station Human-Readable ID in ASCII format
# Octet Number = 0 - 63
@@ -965,12 +929,7 @@ class STA:
else: # we need to build an MME
# Computes MM Header
- osa = DEFAULT_MAC_ADDRESS
- if self.get_mac_address() is not None:
- oda = self.get_mac_address()
- else:
- oda = DEFAULT_MAC_ADDRESS
- mmheader = MMHeader(ODA=oda, OSA=osa, MMV=0x01, MMTYPE = DRV_STA_SET_SL + MME_TYPES['REQ'])
+ mmheader = MMHeader(ODA=self.__get_oda(), OSA=DEFAULT_MAC_ADDRESS, MMV=0x01, MMTYPE = DRV_STA_SET_SL + MME_TYPES['REQ'])
# Computes MM Entry: Security Level for New NMK
# Octet Number = 0
@@ -1001,12 +960,7 @@ class STA:
else: # we need to build an MME
# Computes MM Header
- osa = DEFAULT_MAC_ADDRESS
- if self.get_mac_address() is not None:
- oda = self.get_mac_address()
- else:
- oda = DEFAULT_MAC_ADDRESS
- mmheader = MMHeader(ODA=oda, OSA=osa, MMV=0x01, MMTYPE = DRV_STA_SET_TONEMASK + MME_TYPES['REQ'])
+ mmheader = MMHeader(ODA=self.__get_oda(), OSA=DEFAULT_MAC_ADDRESS, MMV=0x01, MMTYPE = DRV_STA_SET_TONEMASK + MME_TYPES['REQ'])
# Computes MM Entry: Station Tonemask bitfield
# Octet Number = 0 - 191
diff --git a/cesar/maximus/python/src/interface_module.cpp b/cesar/maximus/python/src/interface_module.cpp
index 5b4e976ffb..33c66156d1 100644
--- a/cesar/maximus/python/src/interface_module.cpp
+++ b/cesar/maximus/python/src/interface_module.cpp
@@ -294,7 +294,7 @@ void init_wrap ( Maximus & m, object args )
void uninit_wrap ( Maximus & m )
{
/* Free all resources. */
- delete (&m);
+ m.stop();
}
diff --git a/cesar/maximus/python/test/test_lib_cesar.py b/cesar/maximus/python/test/test_lib_cesar.py
index bdcb694c23..d3340925d7 100644
--- a/cesar/maximus/python/test/test_lib_cesar.py
+++ b/cesar/maximus/python/test/test_lib_cesar.py
@@ -98,10 +98,7 @@ class TestMaximusDurFunctions(unittest.TestCase):
# Maximum modulations
tonemap = ''
for i in range (0, PHY_CARRIER_NB / 2):
- if PHY_CARRIER_NB % 2 == 0:
- tonemap += pack('B', 0x07)
- else:
- tonemap += pack('B', 0x77)
+ tonemap += pack('B', 0x77)
bits_ref = 917 * 10
bits = maximus_dur_bits_per_symbol(self.maximus, self.station.get(), 3, # PHY_MOD_TM
self.station.get_tonemask(), tonemap, 917)
diff --git a/cesar/maximus/python/tools/csi/csicore.py b/cesar/maximus/python/tools/csi/csicore.py
index 7b37988982..c11f387170 100644
--- a/cesar/maximus/python/tools/csi/csicore.py
+++ b/cesar/maximus/python/tools/csi/csicore.py
@@ -222,6 +222,10 @@ class csiCore:
self.__test = csiTest()
+ def process_uninit (self):
+ """Unitialise Maximus, stop it, free resources."""
+ self.__maximus.uninit ()
+
def process_sta_start (self, station = None):
"""Start a station which was not launched yet."""
if station == None:
diff --git a/cesar/maximus/stationtest/src/test_send.c b/cesar/maximus/stationtest/src/test_send.c
index 70a03398ee..bcb264b163 100644
--- a/cesar/maximus/stationtest/src/test_send.c
+++ b/cesar/maximus/stationtest/src/test_send.c
@@ -40,8 +40,11 @@ bool phy_rx_fc_cb (void *user, u32 rx_date, const u32 *fc_av)
diag_write_string("=> phy_rx_fc_cb\n");
// When the FC is received, prepare RX
- phy_rx_prepare(ctx, 1, PHY_COMBO_PARAMS (mod, fecrate, pb_size),
- (phy_gil_t)gil, 0, 1);
+ if (short_ppdu)
+ phy_rx_prepare_short (ctx);
+ else
+ phy_rx_prepare(ctx, 1, PHY_COMBO_PARAMS (mod, fecrate, pb_size),
+ (phy_gil_t)gil, 0, 1);
return true;
}
diff --git a/cesar/maximus/stationtest/src/test_tx_rx.c b/cesar/maximus/stationtest/src/test_tx_rx.c
index 9abcf09218..dcbcc23e71 100644
--- a/cesar/maximus/stationtest/src/test_tx_rx.c
+++ b/cesar/maximus/stationtest/src/test_tx_rx.c
@@ -132,8 +132,11 @@ bool phy_rx_fc_cb (void *user, u32 rx_date, const u32 *fc_av)
maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
// When the FC is received, prepare RX
- phy_rx_prepare(ctx, 1, PHY_COMBO_PARAMS (mod, fecrate, pb_size),
- (phy_gil_t)gil, 0, 1);
+ if (short_ppdu)
+ phy_rx_prepare_short (ctx);
+ else
+ phy_rx_prepare(ctx, 1, PHY_COMBO_PARAMS (mod, fecrate, pb_size),
+ (phy_gil_t)gil, 0, 1);
return true;
}
diff --git a/cesar/projects/plc/Config.traces b/cesar/projects/plc/Config.traces
new file mode 100644
index 0000000000..cb793a0b04
--- /dev/null
+++ b/cesar/projects/plc/Config.traces
@@ -0,0 +1,10 @@
+CONFIG_DEBUG_CLAIM = n
+CONFIG_BLK_NB = 6144
+CONFIG_GPIO_LED_TRAFFIC = y
+CONFIG_BLK_SLACK = 512
+CONFIG_STATS_ON_FATAL = y
+
+CONFIG_TRACE = y
+CONFIG_TRACE_ON_FATAL = y
+CONFIG_TRACE_ALL_FAST = y
+CONFIG_ARCH_ILRAM_PRIO = 0
diff --git a/cesar/station/src/station.c b/cesar/station/src/station.c
index 406ecfb272..d09a51d7ea 100644
--- a/cesar/station/src/station.c
+++ b/cesar/station/src/station.c
@@ -29,6 +29,8 @@
# include "config/hal/trace/cpu.h"
#endif
+#include "lib/seq_check.h"
+
#include "lib/init.h"
/** Static declaration. */
@@ -53,6 +55,8 @@ cesar_init (void)
lib_stats_init ();
+ lib_seq_check_config_init ();
+
/* Initialise the mac store. */
cesar.mac_store = mac_store_init ();
diff --git a/cesar/test_general/maximus/integration/interface-dp/src/station.c b/cesar/test_general/maximus/integration/interface-dp/src/station.c
index 06b59016d4..b62a7363ee 100644
--- a/cesar/test_general/maximus/integration/interface-dp/src/station.c
+++ b/cesar/test_general/maximus/integration/interface-dp/src/station.c
@@ -79,9 +79,9 @@ ce_measurement_cb (void *data, pbproc_rx_params_t *rx_params,
}
static void
-cp_beacon_recv (void *ul, pb_beacon_t * beacon, bsu_params_t *params)
+cp_beacon_recv (void *ul, bsu_beacon_t *beacon)
{
- blk_release_desc ((blk_t*) beacon);
+ blk_release (beacon);
}
static void
@@ -157,7 +157,7 @@ cp_mme_recv (void *user_data, uint tei, u8 *buffer,
mytei == 1 ? BSU_UPDATE_STA_TYPE_CCO :
BSU_UPDATE_STA_TYPE_STA);
bsu_power_on (station_test.bsu, 0);
- bsu_activate (true);
+ bsu_activate (station_test.bsu, true);
sar_activate (station_test.sar, true);
pbproc_activate (station_test.pbproc, true);
}
@@ -266,7 +266,6 @@ cyg_user_start (void)
beacon->vf.rtsbf = false;
beacon->vf.nm = BSU_BEACON_NM_CSMA_ONLY;
beacon->vf.ccocap = 0;
- beacon->vf.rsvd = 0;
/* Regions. */
beacon->bmis.region.nb = 1;
beacon->bmis.region.region[0].rt = BSU_BEACON_REGION_SHARED_CSMA;
diff --git a/cesar/test_general/maximus/integration/sar-pbproc/src/station.c b/cesar/test_general/maximus/integration/sar-pbproc/src/station.c
index 2dbf28ceda..bd2116e325 100644
--- a/cesar/test_general/maximus/integration/sar-pbproc/src/station.c
+++ b/cesar/test_general/maximus/integration/sar-pbproc/src/station.c
@@ -39,6 +39,7 @@
#include "mac/ca/ca.h"
#include "mac/sar/inc/trace.h"
+#include "mac/common/timings.h"
struct tei_node_t
{
@@ -255,7 +256,7 @@ void create_schedule_csma_only (station_test_t *int_sta, uint beacon_period_nb)
for (i = 0; i < beacon_period_nb; i++)
{
beacons_periods[i].start_date = 1000000 * i
- + my_station.current_tick_tck;
+ + my_station.current_tick_tck - MAC_MS_TO_TCK (30);
beacons_periods[i].schedule_index = int_sta->sched_index;
}
@@ -282,10 +283,11 @@ void create_schedule_csma_only (station_test_t *int_sta, uint beacon_period_nb)
void pbproc_sched (cyg_addrword_t int_sta)
{
station_test_t *station_test = (station_test_t *) int_sta;
+ cyg_thread_delay (3);
while (true)
{
create_schedule_csma_only (station_test, CA_SCHEDULE_NB / 2);
- cyg_thread_delay (1);
+ cyg_thread_delay (4);
}
}
@@ -628,7 +630,7 @@ int fc_station_init_config (fcall_ctx_t *fcall, fcall_param_t **param,
uint tei;
uint snid;
uint beacon_period_auto;
- mac_t mac;
+ mac_t mac = 0;
tei = 0;
snid = 0;
diff --git a/cesar/test_general/station/cco0/s1/py/sc12_five_stations.py b/cesar/test_general/station/cco0/s1/py/sc12_five_stations.py
index 3189b85583..3fe8b6a166 100644
--- a/cesar/test_general/station/cco0/s1/py/sc12_five_stations.py
+++ b/cesar/test_general/station/cco0/s1/py/sc12_five_stations.py
@@ -52,5 +52,7 @@ csi.process_wait_sec (1)
#csi.process_avlns_stop ()
result = csi.process_end_get_result ()
+csi.process_uninit ()
+
# For nightly build errors
sys.exit ((1, 0)[result])
diff --git a/cesar/test_general/station/cco0/s1/py/sc13_10stations.py b/cesar/test_general/station/cco0/s1/py/sc13_10stations.py
index 499e1c2c88..76ef84c079 100644
--- a/cesar/test_general/station/cco0/s1/py/sc13_10stations.py
+++ b/cesar/test_general/station/cco0/s1/py/sc13_10stations.py
@@ -67,5 +67,7 @@ csi.process_avlns_remove()
sys.stderr.write("Ending\n")
result = csi.process_end_get_result ()
+csi.process_uninit ()
+
# For nightly build errors
sys.exit ((1, 0)[result])
diff --git a/cesar/test_general/station/cco0/s1/py/sc9_cco_leaving.py b/cesar/test_general/station/cco0/s1/py/sc9_cco_leaving.py
index f75b01cca9..48ab2443a4 100644
--- a/cesar/test_general/station/cco0/s1/py/sc9_cco_leaving.py
+++ b/cesar/test_general/station/cco0/s1/py/sc9_cco_leaving.py
@@ -40,10 +40,10 @@ csi.process_wait_association (15)
csi.process_wait_authentication (15)
csi.authentication_status (avln1)
-# Deactivate the CCo.
+# Remove the CCo.
stas[0].get_sta_cesar().stop()
csi.process_wait_sec (1)
-csi.process_sta_deactivate (stas[0])
+csi.process_sta_remove (avln1, stas[0])
csi.process_wait_sec (1)
# Activate the sniffer on the second station.
diff --git a/cesar/test_general/station/maximus/Makefile b/cesar/test_general/station/maximus/Makefile
index ffcb021416..82ceb3d3fc 100644
--- a/cesar/test_general/station/maximus/Makefile
+++ b/cesar/test_general/station/maximus/Makefile
@@ -8,7 +8,7 @@ TARGET_PROGRAMS= sta_maximus
sta_maximus_SOURCES =
sta_maximus_MODULES = lib mac/common mac cl hle interface cp hal station host \
- cp/av \
+ cp/av bsu \
test_general/station/fcall \
test_general/station/common ce/stub
diff --git a/cesar/test_general/station/maximus/py/sc01_long_simu.py b/cesar/test_general/station/maximus/py/sc01_long_simu.py
index 1c5357612c..c91c282dc3 100644
--- a/cesar/test_general/station/maximus/py/sc01_long_simu.py
+++ b/cesar/test_general/station/maximus/py/sc01_long_simu.py
@@ -44,7 +44,7 @@ for i in range(avln_sta_count):
1, False, 0)
# Start the simulation.
-csi.process_init(sys.path[0] + '/../obj/sta_maximus.elf')
+csi.process_init(sys.argv + ['-e', sys.path[0] + '/../obj/sta_maximus.elf'])
# Start the AVLN and STA.
csi.process_avlns_launch()
# Wait for association.
diff --git a/cesar/test_general/station/maximus/py/sc02_long_simu_data.py b/cesar/test_general/station/maximus/py/sc02_long_simu_data.py
index ab20db1174..945471e5b5 100644
--- a/cesar/test_general/station/maximus/py/sc02_long_simu_data.py
+++ b/cesar/test_general/station/maximus/py/sc02_long_simu_data.py
@@ -50,7 +50,7 @@ for i in range(avln_sta_count):
1, False, 0)
# Start the simulation.
-csi.process_init(sys.path[0] + '/../obj/sta_maximus.elf')
+csi.process_init(sys.argv + ['-e', sys.path[0] + '/../obj/sta_maximus.elf'])
# Start the AVLN and STA.
csi.process_avlns_launch()
# Wait for association.
diff --git a/cesar/test_general/station/tonemap/py/sc01_bl_initial.py b/cesar/test_general/station/tonemap/py/sc01_bl_initial.py
index 9605b4d314..3a22ef624e 100644
--- a/cesar/test_general/station/tonemap/py/sc01_bl_initial.py
+++ b/cesar/test_general/station/tonemap/py/sc01_bl_initial.py
@@ -32,9 +32,16 @@ class TestBitloadingInitial (unittest.TestCase):
# Wait for association and authentication.
self.failUnless (csi.process_wait_association () == True)
self.failUnless (csi.process_wait_authentication () == True)
+ # Send traffic to initiate tonemap negociation.
+ packets = [ csiPacket (100, avln, sta_src = txsta, sta_dest = rxsta)
+ for txsta, rxsta in ((csista[0], csista[1]),
+ (csista[1], csista[0])) ]
+ csi.process_data_send_traffic (packets)
+ csi.process_wait_sec (1)
+ csi.process_verify_transmission ()
+ # For each STA
tmi_list_rx = []
tmi_list_tx = []
- # For each STA
for i in range (sta_count):
# Get TEI and peer TEI.
sta_own = Station_own_data ()
diff --git a/cesar/test_general/station/tonemap/py/sc02_vs_get_tonemap.py b/cesar/test_general/station/tonemap/py/sc02_vs_get_tonemap.py
index 6bf0c56e06..d4e7c2031d 100644
--- a/cesar/test_general/station/tonemap/py/sc02_vs_get_tonemap.py
+++ b/cesar/test_general/station/tonemap/py/sc02_vs_get_tonemap.py
@@ -167,8 +167,13 @@ class TestVsGetTonemap (unittest.TestCase):
# Wait for association and authentication.
self.failUnless (csi.process_wait_association () == True)
self.failUnless (csi.process_wait_authentication () == True)
- # Wait a little bit.
- csi.process_wait_sec (3)
+ # Send traffic to initiate tonemap negociation.
+ packets = [ csiPacket (100, avln, sta_src = txsta, sta_dest = rxsta)
+ for txsta, rxsta in ((csista[0], csista[1]),
+ (csista[1], csista[0])) ]
+ csi.process_data_send_traffic (packets)
+ csi.process_wait_sec (1)
+ csi.process_verify_transmission ()
print "\nGet valid tonemap indexes and intervals lists only"
req_tmi = 0xFF
@@ -208,7 +213,7 @@ class TestVsGetTonemap (unittest.TestCase):
#Check results
self.failUnless (result == 2) # 2 is bad version
print "\nTry to get a tonemap not available"
- req_tmi = 0
+ req_tmi = 0x1f
version = int_id
(result, int_id, tmi_dflt, tmi_length, tmis, int_length, int_ets, int_tmis, tmi, tm_fec, tm_gi, mods) = send_vs_get_tonemap_req (self, req_tmi, version, 1, csista[0], csista[1])
#Check results