summaryrefslogtreecommitdiff
path: root/cesar/test_general/maximus
diff options
context:
space:
mode:
authorlaranjeiro2010-06-14 14:23:49 +0000
committerlaranjeiro2010-06-14 14:23:49 +0000
commita6629fef0fe1e12ddebfea366b0758fc2eb047e8 (patch)
tree2d25dcdbaf2e05a47629c99251c9b12cf463dece /cesar/test_general/maximus
parent43dc87c394e59e34eb5333179375acd2b6004272 (diff)
cesar/test_general/maximus/integration/interface-dp: replace old test
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7211 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/test_general/maximus')
-rw-r--r--cesar/test_general/maximus/integration/interface-dp/Makefile4
-rw-r--r--cesar/test_general/maximus/integration/interface-dp/src/station.c650
-rw-r--r--cesar/test_general/maximus/integration/interface-dp/test01.py104
-rw-r--r--cesar/test_general/maximus/integration/interface-dp/test1.py165
4 files changed, 292 insertions, 631 deletions
diff --git a/cesar/test_general/maximus/integration/interface-dp/Makefile b/cesar/test_general/maximus/integration/interface-dp/Makefile
index cd10139fbd..887e03f600 100644
--- a/cesar/test_general/maximus/integration/interface-dp/Makefile
+++ b/cesar/test_general/maximus/integration/interface-dp/Makefile
@@ -5,8 +5,6 @@ ECOS = y
TARGET_PROGRAMS = station
station_SOURCES = station.c
-station_MODULES = mac/common mac/ca mac/pbproc mac/sar cl hle \
- lib hal/phy/maximus host hal/hle/maximus \
- interface hal/phy/soft/bridgedma
+station_MODULES = lib hal mac cl hle interface station bsu host
include $(BASE)/common/make/top.mk
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 489566ceb8..502b58032f 100644
--- a/cesar/test_general/maximus/integration/interface-dp/src/station.c
+++ b/cesar/test_general/maximus/integration/interface-dp/src/station.c
@@ -13,25 +13,17 @@
* Test the integration of the interface with the data plane.
* The sniffer will be added to this test later.
*/
-#include <cyg/kernel/kapi.h>
-#include <cyg/hal/hal_arch.h>
-
#include "common/std.h"
#include "host/station/station.h"
-#include <stdio.h>
-
/** Library include. */
#include "lib/trace.h"
#include "lib/stats.h"
-#include "lib/circular_buffer.h"
+#include "lib/mbox.h"
#include "cl/cl_mactotei.h"
-#include "lib/read_word.h"
-
/** Data include. */
#include "mac/common/config.h"
-#include "mac/common/ntb.h"
#include "mac/common/store.h"
-
+#include "mac/common/ntb.h"
/** Layers include. */
#include "interface/interface.h"
#include "hle/hle.h"
@@ -39,7 +31,9 @@
#include "mac/sar/sar.h"
#include "mac/pbproc/pbproc.h"
#include "mac/ca/ca.h"
-
+#include "bsu/beacon/beacon.h"
+/** MME MMtypes */
+#include "cp/mme.h"
/** station context. */
struct station_test_t
{
@@ -49,8 +43,6 @@ struct station_test_t
u8 snid;
/** The mac store. */
mac_store_t *mac_store;
-
- // Layers
/** Pbproc context. */
pbproc_t *pbproc;
/** Sar context. */
@@ -59,505 +51,237 @@ struct station_test_t
cl_t *cl;
/** HLE context. */
hle_t *hle;
-
/** Interface context. */
interface_t *interface;
-
-
/** Circular buffer to simulate the CP. */
- circular_buffer_t cp_buffers;
- u8 *cp_buffer_list [20];
-
- /** Cl mac to tei table. */
- cl_mactotei_blk_t *cl_table;
-
- // Create the Thread for the SAR.
- cyg_thread sar_thread;
- cyg_handle_t sar_thread_handle;
- u8 sar_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];
-
- /** Cp thread. */
- cyg_thread cp_thread;
- cyg_handle_t cp_thread_handle;
-
- u8 cp_thread_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];
+ mbox_t cp_buffers;
+ /** The beacon to update the BSU. */
+ bsu_beacon_t beacon;
+ /** BSU aclf context. */
+ bsu_aclf_t *aclf;
+ /** BSU context. */
+ bsu_t *bsu;
+ /** Hal timer */
+ hal_timer_t *hal_timer;
};
typedef struct station_test_t station_test_t;
-struct ce_rx_params_node_t
-{
- list_node_t node;
- pbproc_rx_params_t rx_params;
-};
-typedef struct ce_rx_params_node_t ce_rx_params_node_t;
-
-struct cp_send_data_t
-{
- uint beacon;
- uint tei;
- uint length;
- uint bcast;
- u8 *buffer;
- uint msg_id;
-};
-typedef struct cp_send_data_t cp_send_data_t;
-
static station_test_t station_test;
-/* Use to keep a list of rx params in the CE */
-list_t ce_rx_params_list;
-
-/* Fill this to send a MME. */
-cp_send_data_t cp_data;
-
-// ---------------------------- Function calls -----------------------------
-
-/** Creates a link in the STA.
- *
- * - dtei the tei of the station.
- * - dmac_addr the destination mac address.
- * - fw forward link
- * - rw reverse link
- * - bcast broadcast.
- *
- * \param fcall the fcall context.
- * \param param the fcall param
- * \param msg the message
- * \param data anything
- */
-int fc_add_mme_link (fcall_ctx_t *fcall, fcall_param_t **param,
- sci_msg_t **msg, void *data)
+static void
+ce_measurement_cb (void *data, pbproc_rx_params_t *rx_params,
+ uint total_pb_count, pb_t *chan_data,
+ uint chan_data_count, u8 false_pb_count,
+ u32 ber_sum)
{
- uint dtei = 0;
- mac_t mac_address = 0;
- uint fw = 0;
- uint rw = 0;
- uint bcast = 0;
-
- mfs_tx_t *mfs_tx;
- mfs_rx_t *mfs_rx;
- bool added;
-
- fcall_param_bind_short (*param, *msg, "dtei", &dtei);
- fcall_param_bind (*param, *msg, "dmac_addr", sizeof(mac_t), &mac_address);
- fcall_param_bind_short (*param, *msg, "fw", &fw);
- fcall_param_bind_short (*param, *msg, "rw", &rw);
- fcall_param_bind_short (*param, *msg, "bcast", &bcast);
-
- fcall_param_reset (*param);
-
- if (mac_address == 0)
- return false;
-
- if (fw)
- {
- mfs_tx = mac_store_mfs_add_tx (station_test.mac_store, bcast, true, MAC_LID_NONE, dtei, &added);
-
- if (mfs_tx == NULL)
- return false;
-
- sar_mfs_add (station_test.sar, (mfs_t *) mfs_tx);
- blk_release (mfs_tx);
- }
-
- if (rw)
- {
- mfs_rx = mac_store_mfs_add_rx (station_test.mac_store, bcast, true, MAC_LID_NONE, dtei, &added);
-
- if (mfs_rx == NULL)
- return false;
-
- sar_mfs_add (station_test.sar, (mfs_t *) mfs_rx);
- blk_release (mfs_rx);
- }
-
- if (!station_test.cl_table)
- station_test.cl_table = cl_mactotei_new ();
-
- cl_mactotei_addr_add (station_test.cl_table, mac_address, dtei, dtei);
-
-
- return true;
+ if (chan_data)
+ blk_release_desc_range_nb ((blk_t*) chan_data, chan_data_count);
}
-/** Initialise the station parameters data as the mac address the tei.
- *
- * - stei.
- * - mac_addr.
- *
- * \param fcall the fcall context.
- * \param param the fcall param
- * \param msg the message
- * \param data anything
- */
-int fc_station_config (fcall_ctx_t *fcall, fcall_param_t **param,
- sci_msg_t **msg, void *data)
+static void
+cp_beacon_recv (void *ul, pb_beacon_t * beacon, bsu_params_t *params)
{
- uint stei = 0;
- mac_t mac_address = 0;
-
- fcall_param_bind_short (*param, *msg, "stei", &stei);
- fcall_param_bind (*param, *msg, "mac_addr", sizeof(mac_t), &mac_address);
-
- station_test.mac_config.sta_mac_address = mac_address;
- station_test.mac_config.tei = stei;
-
- fcall_param_reset (*param);
-
- return true;
+ blk_release_desc ((blk_t*) beacon);
}
-
-/** Prepare the station to work.
- * It will create default schedules for the Channel Access in CSMA-only mode
- * and activate the pbproc to start the communication with the others
- * stations.
- *
- * \param fcall the fcall context.
- * \param param the fcall param
- * \param msg the message
- * \param data anything
- */
-int fc_station_start (fcall_ctx_t *fcall, fcall_param_t **param,
- sci_msg_t **msg, void *data)
+static void
+cp_mme_recv (void *user_data, uint tei, u8 *buffer,
+ uint length, bool mme_recv, bool encryption)
{
- ca_beacon_period_t beacons_periods[4];
- uint i;
-
- /* Get and fill the schedule */
- ca_schedule_t *sched = ca_alloc_get_schedule (pbproc_get_ca (station_test.pbproc),0);
-
- sched->coexistence_mode = MAC_COEXISTENCE_SHARED_CSMA_HYBRID_MODE;
- sched->snid = station_test.snid;
- sched->nek_switch = 0; //TODO
- sched->allocations_nb = 1;
- sched->allocations[0].end_offset_tck = BITS_ONES (24);
- sched->allocations[0].glid = 0xff;
-
- /* Create a schedule for 14 beacon period */
- for (i = 0; i < 4; i++)
+ mac_t osa, oda;
+ u16 mtype, mmtype;
+ u8 mmv;
+ u32 fmi;
+ bitstream_t stream;
+ bitstream_read_init (&stream, buffer, length);
+ oda = bitstream_read_large (&stream, 48);
+ osa = bitstream_read_large (&stream, 48);
+ mtype = bitstream_read (&stream, 16);
+ mmv = bitstream_read (&stream, 8);
+ mmtype = bitstream_read (&stream, 16);
+ fmi = bitstream_read (&stream, 16);
+ bitstream_finalise (&stream);
+ if (mmtype <= DRV_MAX && mmtype >= DRV_MIN)
{
- beacons_periods[i].start_date = BITS_ONES(24) * i
- + my_station.current_tick_tck;
- beacons_periods[i].schedule_index = 0;
+ interface_mme_recv_done (station_test.interface, buffer, mme_recv);
+ /* Answer. */
+ u8 *buffer_tx = (u8*) mbox_get (&station_test.cp_buffers);
+ bitstream_write_init (&stream, buffer_tx, 1518);
+ bitstream_write_large (&stream, osa, 48);
+ bitstream_write_large (&stream, oda, 48);
+ bitstream_write (&stream, mtype, 16);
+ bitstream_write (&stream, mmv, 8);
+ bitstream_write (&stream, mmtype | CP_MME_CNF, 16);
+ bitstream_write (&stream, fmi, 16);
+ bitstream_write (&stream, 0, 8);
+ length = bitstream_written_bits (&stream) / 8;
+ uint i;
+ for (i = 0; i < ETH_PACKET_MIN_SIZE - length; i++)
+ bitstream_write (&stream, 0, 8);
+ length = bitstream_finalise (&stream) / 8;
+ interface_mme_send (station_test.interface, buffer_tx, length,
+ MAC_TEI_FOREIGN);
+ /** Configure the station for the test. */
+ if (mmtype == DRV_STA_MAC_START_REQ)
+ {
+ u8 mytei = (oda >> 40) & 0xff;
+ u8 dtei = mytei == 2 ? 1 : 2;
+ station_test.mac_config.sta_mac_address = oda;
+ station_test.mac_config.tei = mytei;
+ /* Mac to TEI table. */
+ cl_mactotei_blk_t *table = cl_mactotei_new ();
+ if (dtei > mytei)
+ cl_mactotei_addr_add (table, oda + ((u64) 1 << 40), dtei, 0);
+ else
+ cl_mactotei_addr_add (table, oda - ((u64) 1 << 40), dtei, 0);
+ cl_mactotei_use_table (station_test.cl, table);
+ /* Nek encryption. */
+ station_test.mac_config.nek[0].nek_enc[0] = 1550912579u;
+ station_test.mac_config.nek[0].nek_enc[1] = 203738576u;
+ station_test.mac_config.nek[0].nek_enc[2] = 1871202866u;
+ station_test.mac_config.nek[0].nek_enc[3] = 3556881139u;
+ station_test.mac_config.nek[0].nek_dec[0] = 2027356331u;
+ station_test.mac_config.nek[0].nek_dec[1] = 1490249495u;
+ station_test.mac_config.nek[0].nek_dec[2] = 3540691450u;
+ station_test.mac_config.nek[0].nek_dec[3] = 2269506147u;
+ station_test.mac_config.nek[0].eks = MAC_EKS_MIN;
+ /* Add station in the mac store. */
+ mac_store_sta_add (station_test.mac_store, dtei);
+ sta_t *sta = mac_store_sta_get (station_test.mac_store, dtei);
+ sta->authenticated = true;
+ blk_release (sta);
+ /* We are authenticated too. */
+ station_test.mac_config.authenticated = true;
+ /* Start datapath. */
+ bsu_update (&station_test.beacon,
+ mytei == 1 ? BSU_UPDATE_STA_TYPE_CCO :
+ BSU_UPDATE_STA_TYPE_STA);
+ bsu_power_on (0);
+ bsu_activate (true);
+ sar_activate (station_test.sar, true);
+ pbproc_activate (station_test.pbproc, true);
+ }
}
-
- /* Use the new schedule */
- ca_alloc_update_beacon_periods (pbproc_get_ca (station_test.pbproc), beacons_periods,
- 4);
-
- /* Only run this one !!! */
- pbproc_activate (station_test.pbproc, true);
-
-
- /* request the CL to use the cl_mactotei table. */
- cl_mactotei_use_table (station_test.cl, station_test.cl_table);
-
- return true;
-}
-
-/** Send a MME over the PLC.
- *
- * - tei the destination tei
- * - mme the mme buffer to send
- * - length the MME length
- * - bcast the bradcast flag
- *
- * \param fcall the fcall context.
- * \param param the fcall param
- * \param msg the message
- * \param data anything
- */
-int fc_station_mme_send (fcall_ctx_t *fcall, fcall_param_t **param,
- sci_msg_t **msg, void *data)
-{
- uint dtei = 0;
- uint length = 0;
- u8 *buffer;
- uint bcast = 0;
-
- buffer = circular_buffer_get (&station_test.cp_buffers);
-
- if (buffer == NULL)
+ else if (mmtype == CC_WHO_RU_REQ)
{
- printf ("Warning : No MME buffer available");
- fcall_param_reset (*param);
- return false;
- }
-
- fcall_param_bind_short (*param, *msg, "tei", &dtei);
- fcall_param_bind_short (*param, *msg, "length", &length);
- fcall_param_bind_short (*param, *msg, "bcast", &bcast);
- fcall_param_bind (*param, *msg, "mme", length, buffer);
-
- cp_data.beacon = false;
- cp_data.tei = dtei;
- cp_data.length = length;
- cp_data.bcast = bcast;
- cp_data.buffer = buffer;
- cp_data.msg_id = (*param)->msg_id;
-
- cyg_thread_resume (station_test.cp_thread_handle);
-
- fcall_param_reset (*param);
- return true;
-}
-
-/** Send a beacon over the PLC.
- *
- * \param fcall the fcall context.
- * \param param the fcall param
- * \param msg the message
- * \param data anything
- */
-int fc_station_beacon_send(fcall_ctx_t *fcall, fcall_param_t **param,
- sci_msg_t **msg, void *data)
-{
- cp_data.beacon = true;
- cp_data.msg_id = (*param)->msg_id;
-
- cyg_thread_resume (station_test.cp_thread_handle);
-
- fcall_param_reset (*param);
- return true;
-}
-
-// ---------------------------- Stub functions ----------------------------
-
-/**
- * Cp run function..
- * Use to send MMEs... on maximus request.
- */
-void
-cp_run (cyg_addrword_t data)
-{
- while (true)
- {
- cyg_thread_delay (10);
-
- if (cp_data.beacon)
+ u8 *buffer_tx = (u8*) mbox_get (&station_test.cp_buffers);
+ u8 dtei;
+ if (osa == station_test.mac_config.sta_mac_address)
{
- pb_beacon_t *beacon;
- mfs_tx_t *mfs;
- uint i;
- bool added;
-
- mfs = mac_store_mfs_add_tx (station_test.mac_store, true, false,
- MAC_LID_SPC_CENTRAL, 0xff, &added);
-
- if (mfs)
- {
- if (added)
- {
- mfs->cap = 0x3;
- mfs->beacon = true;
- mfs->common.ats = false;
- ca_mfs_add (pbproc_get_ca (station_test.pbproc), mfs);
- }
-
- beacon = (pb_beacon_t *) blk_alloc_desc ();
- beacon->first_data_word = 0x12345678;
-
- for (i = 0; i < 128; i++)
- beacon->data[i] = i;
-
- // send the beacon.
- interface_beacon_prepare (station_test.interface, beacon,
- mfs, &beacon->data[128]);
-
- interface_beacon_add (station_test.interface, beacon,
- (pbproc_rx_beacon_params_t *)&beacon->data[128]);
-
- blk_release_desc ((blk_t *) beacon);
- blk_release (mfs);
- }
+ bitstream_memcpy (buffer_tx, buffer, length);
+ dtei = cl_mactotei_table_find_tei_from_mac (station_test.cl, oda);
}
else
{
- interface_mme_send (station_test.interface, cp_data.buffer,
- cp_data.length, cp_data.tei);
+ char msg[] = "hi hello";
+ bitstream_t s;
+ bitstream_write_init (&s, buffer_tx, ETH_PACKET_MAX_SIZE);
+ bitstream_write_large (&s, osa, 48);
+ bitstream_write_large (&s, oda, 48);
+ bitstream_write (&s, mtype, 16);
+ bitstream_write (&s, mmv, 8);
+ bitstream_write (&s, mmtype | CP_MME_CNF, 16);
+ bitstream_write (&s, fmi, 16);
+ bitstream_write_large (&s, 0x0011223344ull, 54);
+ bitstream_write_large (&s, oda, 48);
+ bitstream_write_str (&s, msg, sizeof (msg));
+ length = bitstream_finalise (&s) / 8;
+ uint i;
+ for (i = 0; i < ETH_PACKET_MIN_SIZE - length; i++)
+ bitstream_write (&s, 0, 8);
+ length = bitstream_finalise (&s) / 8;
+ dtei = cl_mactotei_table_find_tei_from_mac (station_test.cl, osa);
}
-
- cyg_thread_suspend(station_test.cp_thread_handle);
+ interface_mme_recv_done (station_test.interface, buffer, mme_recv);
+ interface_mme_send (station_test.interface, buffer_tx, length, dtei);
}
+ else if (mmtype == CC_WHO_RU_CNF)
+ {
+ /* Special for this test, send it to linux. */
+ u8 *buffer_tx = (u8*) mbox_get (&station_test.cp_buffers);
+ bitstream_memcpy (buffer_tx, buffer, length);
+ interface_mme_recv_done (station_test.interface, buffer, mme_recv);
+ interface_mme_send (station_test.interface, buffer_tx, length,
+ MAC_TEI_FOREIGN);
+ }
+ else
+ interface_mme_recv_done (station_test.interface, buffer, mme_recv);
}
-/** Stubs the CP init function.
- * It will just initialise the buffer list within the station_test structure.
- */
-void
-cp_init (void)
-{
- circular_buffer_init (&station_test.cp_buffers,
- station_test.cp_buffer_list, 20);
-
- cyg_thread_create(9, cp_run, 0, "Cp_run", station_test.cp_thread_stack,
- CYGNUM_HAL_STACK_SIZE_TYPICAL, &station_test.cp_thread_handle,
- &station_test.cp_thread);
-}
-
-void
-ce_measurements (void *data, pbproc_rx_params_t *rx_params,
- uint total_pb_count, pb_t *chan_data,
- uint chan_data_count, u8 false_pb_count, u32 ber_sum)
-{
- if (chan_data)
- blk_release_desc_range_nb ((blk_t*) chan_data, chan_data_count);
-}
-
-
-/**
-* CP receives a new MME.
-* \param user_data the data registered by the actor in the init function.
-* \param mfs the mfs
-* \param buffer the buffer containing the MME.
-* \param length the MME length
-* \param mme_recv data use by the data plane.
-* \param encryption inform if the packet comes from the PWL if it had been
-* crypted or not.
-*/
-void
-cp_mme_recv (void *user_data, uint tei, u8 *buffer, uint length,
- bool mme_recv, bool encryption)
-{
- printf ("/*************************************************/\n");
- printf ("/ STATION : %d Receive a MME **********/\n",
- station_test.mac_config.tei);
- printf ("/ MME length : %d **********/\n", length);
- printf ("/ MME encrypted : %d **********/\n",
- encryption);
- printf ("/*************************************************/\n");
-}
-
-/**
-* CP receives a empty buffer.
-* \param user_data the data registered by the actor in the init function.
-* \param buffer the buffer to add.
-*/
-void
+static void
cp_mme_buffer_add (void *user_data, u8 *buffer)
{
- printf ("/*************************************************/\n");
- printf ("/ STATION : %d Receive a new MME Buffer ********/\n",
- station_test.mac_config.tei);
- printf ("/*************************************************/\n");
-
-
- // Keep the buffer as the control plane will do.
- circular_buffer_add (&station_test.cp_buffers, buffer);
-}
-
-
-/**
-* CP receives a beacon.
-* \param user_data the data registered by the actor in the init function.
-* \param beacon the beacon freshly received.
-*/
-void
-cp_beacon_add (void *user_data, pb_beacon_t *beacon)
-{
- printf ("/*************************************************/\n");
- printf ("/ STATION : %d Receive a beacon ********/\n",
- station_test.mac_config.tei);
- printf ("/*************************************************/\n");
-
-
- // release the beacon.
- blk_release_desc ((blk_t *) beacon);
+ mbox_put (&station_test.cp_buffers, (mbox_node_t*) buffer);
}
-// -------------------------------------------------------------------------
-
-
-/** Cesar init function as described in the wiki
- * http://pessac/cesar/trac/wiki/20071128Cesar#LEONcore
- */
-void
-cesar_init (void)
+int
+cyg_user_start (void)
{
- // Initialise the trace system.
+ lib_stats_init ();
+ station_log_set_level(&my_station, STATION_LOG_DEBUG);
+ my_station.pipe_log_fd = 1;
trace_init ();
-
- // Initialise the mac_store.
station_test.mac_store = mac_store_init ();
-
- // Initialise the mac config.
mac_config_init (&station_test.mac_config);
-
- // Intialise the pbproc.
+ mac_ntb_init (&station_test.mac_config);
station_test.pbproc = pbproc_init (&station_test.mac_config,
station_test.mac_store);
-
- // Initialise the mac ntb.
- mac_ntb_init (&station_test.mac_config);
-
- // Initialise the SAR.
+ station_test.hal_timer = hal_timer_init ();
station_test.sar = sar_init (station_test.mac_store, station_test.pbproc,
pbproc_get_ca (station_test.pbproc),
station_test.mac_config.seed);
-
- // Initialise the CL.
+ station_test.aclf = bsu_aclf_init (pbproc_get_phy (station_test.pbproc),
+ &station_test.mac_config,
+ station_test.hal_timer);
+ station_test.bsu = bsu_init (station_test.aclf, &station_test.mac_config,
+ pbproc_get_phy (station_test.pbproc),
+ station_test.mac_store,
+ pbproc_get_ca (station_test.pbproc),
+ station_test.sar, station_test.hal_timer);
station_test.cl = cl_init (station_test.mac_store, station_test.sar,
&station_test.mac_config);
-
- // Initialise the HLE
station_test.hle = hle_init (station_test.cl);
-
- // Interface init.
station_test.interface = interface_init (station_test.hle,
station_test.cl, station_test.sar,
&station_test.mac_config);
-
- // Init the control plane.
- cp_init ();
-
- // activate the reception of driver messages
hle_activate (station_test.hle, true);
-}
-
-
-/* ---------------------- Main function -------------------*/
-int
-cyg_user_start (void)
-{
- lib_stats_init ();
- cesar_init ();
-
- station_log_set_level(&my_station, STATION_LOG_DEBUG);
- my_station.pipe_log_fd = 1;
-
- // Stub the CE functionalities.
sar_init_measure_context (station_test.sar, station_test.sar);
- sar_init_measurement_cb (station_test.sar, ce_measurements);
-
- // Stub the interface communication with the CP.
+ sar_init_measurement_cb (station_test.sar, ce_measurement_cb);
interface_callback_init (station_test.interface, cp_mme_recv,
cp_mme_buffer_add, NULL);
- interface_callback_beacon_init (station_test.interface,
- cp_beacon_add, NULL);
-
-
- station_test.cl_table = NULL;
-
- list_init (&ce_rx_params_list);
-
-
- // Register the function calls.
- fcall_register (my_station.fcall, "fc_add_mme_link",
- &fc_add_mme_link , NULL);
-
- fcall_register (my_station.fcall, "fc_station_config",
- &fc_station_config, NULL);
-
- fcall_register (my_station.fcall, "fc_station_start",
- &fc_station_start, NULL);
-
- fcall_register (my_station.fcall, "fc_station_mme_send",
- &fc_station_mme_send , NULL);
-
- fcall_register (my_station.fcall, "fc_station_beacon_send",
- &fc_station_beacon_send, NULL);
-
+ bsu_init_beacon_cb (cp_beacon_recv, INVALID_PTR);
+ mbox_init (&station_test.cp_buffers);
+ /* Prepare beacon shared memory. */
+ bsu_beacon_t *beacon = &station_test.beacon;
+ memset (beacon, 0, sizeof (bsu_beacon_t));
+ beacon->vf.nid = 0x123456789ull;
+ beacon->vf.hm = MAC_COEXISTENCE_FULL_HYBRID_MODE;
+ beacon->vf.ncnr = false;
+ beacon->vf.npsm = false;
+ beacon->vf.numslots = 0;
+ beacon->vf.slotusage = 0;
+ beacon->vf.slotid = 0;
+ beacon->vf.aclsss = true;
+ beacon->vf.hoip = false;
+ 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;
+ beacon->bmis.region.region[0].end_time_atu = 3907;
+ /* Persistent schedules. */
+ beacon->bmis.ps.nb = 1;
+ beacon->bmis.ps.ps[0].pscd = 0;
+ beacon->bmis.ps.ps[0].cscd = 7;
+ beacon->bmis.ps.ps[0].ns = 1;
+ beacon->bmis.ps.ps[0].sais[0].stpf = false;
+ beacon->bmis.ps.ps[0].sais[0].glid = MAC_LID_SHARED_CSMA & 0x7f;
+ beacon->bmis.ps.ps[0].sais[0].end_time_atu = 3907;
+ /* BSPTO. */
+ beacon->bmis.bpsto.present = true;
+ beacon->bmis.bpsto.bpsto = 0xfed0;
return 0;
}
diff --git a/cesar/test_general/maximus/integration/interface-dp/test01.py b/cesar/test_general/maximus/integration/interface-dp/test01.py
new file mode 100644
index 0000000000..016f447f52
--- /dev/null
+++ b/cesar/test_general/maximus/integration/interface-dp/test01.py
@@ -0,0 +1,104 @@
+#!/usr/bin/python
+
+#############################################################################
+# Copyright (C) 2010 Spidcom
+#
+# Test the communication between the Interface module and the Datapath
+# module.
+#
+# MMe send pass throw the interface module and is sent to the peer station.
+#
+#############################################################################
+
+import sys, unittest, os
+sys.path.append(sys.path[0] + '/../../../../maximus/python/tools/csi/')
+sys.path.append(sys.path[0] + '/../../../../maximus/python/obj/')
+sys.path.append(sys.path[0] + '/../../../../maximus/python/')
+sys.path.append(sys.path[0] + '/../../../../maximus/python/lib/cesar')
+# Import some classes from the CSI module.
+from csicore import csiCore, csiSta
+from csitime import ms_to_tck
+from maximus.mme import MME
+from maximus.mme.mmheader import MMHeader
+from maximus.ethernet.eth import Eth
+from struct import unpack
+
+MAC_ADDR_BASE = '00:13:d7:00:00:%02x'
+
+def filter_mme (msdu):
+ return msdu.get_type () == 'ETHERNET_TYPE_MME'
+
+def filter_data (msdu):
+ return msdu.get_type () == 'ETHERNET_TYPE_DATA'
+
+csi = csiCore(4242);
+csi.process_init(sys.argv + ['-e', sys.path[0] + '/obj/station.elf'])
+avln = csi.avln_add("HomePlug_AVLN", "AVLN")
+for i in range (0,2):
+ avln.sta_add (MAC_ADDR_BASE % (i+1),
+ False, False, "Homeplug_Station_%02d" % i,
+ "spidcom_spc300_sta_%02d" % i, "station_%02d" % i, 1,
+ False)
+# Start the AVLN and STA.
+csi.process_avlns_launch()
+csi.process_wait_sec (1)
+sta1 = avln.get_sta (0)
+sta2 = avln.get_sta (1)
+
+class TestInitFunctions(unittest.TestCase):
+
+ def setUp (self):
+ pass
+
+ def tearDown (self):
+ pass
+
+ def testMME (self):
+ """Send the MME from STA 1 to STA 2."""
+ # Station executable is configured to send MME to the peer STA, in a
+ # real executable this MMe should be handled by the CP.
+ mme = MME (MMHeader=MMHeader(ODA=sta2.get_mac_addr (),
+ OSA=sta1.get_mac_addr (), MTYPE=0x88E1, MMV=1,
+ MMTYPE=0x002C, FMI=0))
+ db = mme.sendnrecv (csi.get_maximus (), sta1.get_sta_cesar (),
+ filter = filter_mme, timeout = ms_to_tck (40))
+ self.failUnless (db != None)
+ for i in db:
+ e = Eth ()
+ e.set_msdu_attr (i.get ())
+ self.failUnless (e.src == sta2.get_mac_addr ())
+ self.failUnless (e.dst == sta1.get_mac_addr ())
+ self.failUnless (e.type == 0x88E1)
+ # Get the MMType.
+ mmheader = i.get_mmheader ()
+ mmtype = unpack ('B' * len (mmheader), mmheader)[15:17]
+ mmtype = mmtype[0] | mmtype[1] << 8
+ self.failUnless (mmtype == 0x002d)
+
+ def testDATA (self):
+ """Send data from STA 1 to STA 2."""
+ frame = Eth()
+ frame.src = sta1.get_mac_addr ()
+ frame.dst = sta2.get_mac_addr ()
+ frame.type = 0x4F50
+ frame.payload = "aabbccddeeffjj"
+ db = frame.sendnrecv (csi.get_maximus (), sta1.get_sta_cesar (),
+ timeout = ms_to_tck (40), filter = filter_data)
+ self.failUnless (db != None)
+ self.failUnless (len (db) == 1)
+ for i in db:
+ self.failUnless (i.src == frame.src)
+ self.failUnless (i.dst == frame.dst)
+ self.failUnless (i.type == frame.type)
+ self.failUnless (i.payload == frame.payload)
+
+suite = unittest.TestLoader().loadTestsFromTestCase(TestInitFunctions)
+testResult = unittest.TextTestRunner(verbosity=2).run(suite)
+
+csi.process_avlns_stop ()
+csi.process_avlns_remove ()
+os.system ('killall station.elf')
+
+# For nightly build errors
+sys.exit ((1, 0)[testResult.wasSuccessful ()])
+
diff --git a/cesar/test_general/maximus/integration/interface-dp/test1.py b/cesar/test_general/maximus/integration/interface-dp/test1.py
deleted file mode 100644
index f36247e0a7..0000000000
--- a/cesar/test_general/maximus/integration/interface-dp/test1.py
+++ /dev/null
@@ -1,165 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-sys.path.append('../../../../maximus/python');
-sys.path.append('../../../../maximus/python/obj');
-
-from interface import *
-from string import *
-from struct import *
-from maximus import *
-
-realloc_buffer ( True )
-trace_print = False
-
-def my_eth_filter(eth):
- if eth.get_type() is 'ETHERNET_TYPE_SNIFFER':
- # The received object is an MSDU
- return True
- else:
- return False
-
-
-sta1_mac = 0x23456789abcd
-sta1_mac_str = pack ('Q', sta1_mac)[0:6]
-
-sta2_mac = 0x123456789abc
-sta2_mac_str = pack('Q', sta2_mac)[0:6]
-
-maximus = Maximus()
-maximus.init (sys.argv + ['-e', './obj/station.elf'])
-
-sta1 = maximus.create_sta()
-#sta1.debug()
-
-sta2 = maximus.create_sta()
-#sta2.debug()
-
-# Configure the station.
-fc = maximus.create_fcall ("fc_station_config")
-fc.add_param_ushort ("stei", 1)
-fc.add_param ("mac_addr", sta1_mac_str);
-fc.set_sta (sta1)
-fc.send()
-
-fc = maximus.create_fcall ("fc_station_config")
-fc.add_param_ushort ("stei", 2)
-fc.add_param ("mac_addr", sta2_mac_str);
-fc.set_sta (sta2)
-fc.send()
-
-
-fc = maximus.create_fcall ("fc_add_mme_link")
-fc.add_param_ushort ("dtei", 2)
-fc.add_param ("dmac_addr", sta2_mac_str);
-fc.add_param_ushort ("fw", True);
-fc.add_param_ushort ("rw", True);
-fc.add_param_ushort ("bcast", False);
-fc.set_sta (sta1)
-fc.send()
-
-fc = maximus.create_fcall ("fc_add_mme_link")
-fc.add_param_ushort ("dtei", 1)
-fc.add_param ("dmac_addr", sta1_mac_str);
-fc.add_param_ushort ("fw", True);
-fc.add_param_ushort ("rw", True);
-fc.add_param_ushort ("bcast", False);
-fc.set_sta (sta2)
-fc.send()
-
-# read the ethernet full packet
-packet_file = open ('../packet_max','r')
-packet = packet_file.read()
-packet_file.close();
-
-fc = maximus.create_fcall ("fc_station_start")
-fc.set_sta (sta1)
-fc.send()
-
-fc.set_sta (sta2)
-fc.send()
-
-# Alloc mme buffers the first two ones will be kept by the interface module.
-alloc_mme_buffer (maximus, sta2)
-alloc_mme_buffer (maximus, sta2)
-alloc_interface_buffer (maximus, sta2)
-alloc_interface_buffer (maximus, sta2)
-
-alloc_mme_buffer (maximus, sta1)
-alloc_mme_buffer (maximus, sta1)
-alloc_interface_buffer (maximus, sta1)
-alloc_interface_buffer (maximus, sta1)
-
-# The station 1 will now send a MME to the second station.
-print "Configure sniffer on station 2"
-mme = MME(MMHeader=MMHeader(ODA=sta2_mac_str, OSA=sta2_mac_str, MTYPE=0x88E1,
- MMV=1, MMTYPE=0xA02C, FMI=0),MMEntry=MMEntry(pack(4*'B', 0x00, 0x13, 0xd7, 0xF)))
-mme.send(maximus, sta2)
-rsp = recv(maximus, count = 1, filter = my_eth_filter)
-if rsp is None:
- print "No confirmation received"
-
-# The sniffer shall sniff this one...
-print "Send a MME to be sniffed"
-mme = MME(MMHeader=MMHeader(ODA=sta2_mac_str, OSA=sta2_mac_str, MTYPE=0x88E1,
- MMV=0, MMTYPE=0x0030, FMI=0),MMEntry=MMEntry(pack('B', 1)))
-mme.send(maximus, sta2)
-
-#Catch the ethernet packets
-rsp = recv(maximus, count=1, filter=my_eth_filter)
-
-if rsp is not None:
- #Shall receive a TX ethernet packet.
- dir (rsp[0])
-else:
- raise Error ("An Sniffed packet should be received")
-
-# Request the Station 2 to send a MME to station 1.
-fc = maximus.create_fcall ("fc_station_mme_send")
-fc.set_sta (sta2)
-fc.add_param_ushort ("tei", 1)
-fc.add_param_ushort ("length", 160)
-fc.add_param_ushort ("bcast", 0)
-fc.add_param ("mme", mme.get())
-fc.send()
-
-#Catch the ethernet packets
-rsp = recv(maximus, count=1, filter=my_eth_filter)
-if rsp is not None:
- #Shall receive a TX ethernet packet.
- dir (rsp[0])
-else:
- raise Error ("An Sniffed packet should be received")
-
-#send a beacon
-alloc_interface_buffer (maximus, sta2);
-alloc_mme_buffer (maximus, sta2);
-fc = maximus.create_fcall ("fc_station_beacon_send")
-fc.set_sta (sta2)
-fc.send()
-
-#Catch the ethernet packets
-rsp = recv(maximus, count=2, filter=my_eth_filter)
-#alloc_interface_buffer (maximus, sta2)
-#alloc_interface_buffer (maximus, sta1)
-
-if rsp is not None:
- #Shall receive a TX ethernet packet.
- dir (rsp[0])
-else:
- raise Error ("An Sniffed packet should be received")
-
-if rsp is not None:
- #Shall receive a TX ethernet packet.
- dir (rsp[0])
-else:
- raise Error ("An Sniffed packet should be received")
-
-# Verify the data contained in the packet.
-mme_res = rsp[0].get()
-
-print "End of the tests, removing the station"
-sta1.remove()
-sta2.remove()
-
-print "SUCCSEED"