summaryrefslogtreecommitdiff
path: root/cesar/test_general
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/test_general')
-rw-r--r--cesar/test_general/maximus/integration/sar-pbproc/src/station.c162
-rw-r--r--cesar/test_general/maximus/integration/sar-pbproc/test1.py11
-rw-r--r--cesar/test_general/maximus/integration/sar-pbproc/test2.py100
3 files changed, 235 insertions, 38 deletions
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 0cd2dfb40a..072f7120fc 100644
--- a/cesar/test_general/maximus/integration/sar-pbproc/src/station.c
+++ b/cesar/test_general/maximus/integration/sar-pbproc/src/station.c
@@ -7,11 +7,11 @@
* }}} */
/**
* \file test_general/integration/interface-dp/src/station.c
- * \brief Station interface - DP.
+ * \brief Station interface - DP.
* \ingroup test_general
*
* Test the integration of the interface with the data plane.
- * The sniffer will be added to this test later.
+ * The sniffer will be added to this test later.
*/
#include <cyg/kernel/kapi.h>
#include <cyg/hal/hal_arch.h>
@@ -56,7 +56,7 @@ struct station_test_t
u8 snid;
/** The mac store. */
mac_store_t *mac_store;
-
+
// Layers
/** Pbproc context. */
pbproc_t *pbproc;
@@ -72,13 +72,14 @@ struct station_test_t
cyg_thread sched_thread;
/** Used to memorize the list of TEI inserted in the mac_Store to remove it
- * in the future.
+ * in the future.
*/
list_t tei_list;
};
typedef struct station_test_t station_test_t;
+u8 mme_buffer [2048] __attribute__((aligned (2048)));
u8 sched_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];
//----------------------------------------------------------------------------
@@ -135,13 +136,41 @@ void sar_reassembly_ul_done (void *user, u8* buffer, uint length,
printf ("******************************************\n");
free (buffer);
+
+ blk_print_memory ();
+}
+
+/**
+ * Implementation of the sar_reassembly_done_cb_t call back.
+ * Only used in this test.
+ * The buffer and the mfs shall be release.
+ *
+ * \param user, User data
+ * \param buffer the buffer address containing the data
+ * \param length the data length
+ * \param mfs the mfs used
+ */
+void sar_reassembly_mme_done (void *user, u8* buffer, uint length,
+ mfs_rx_t *mfs, bool encrypted)
+{
+ dbg_assert (buffer);
+ dbg_assert (length >= 60 && length <= 1518);
+ dbg_assert (mfs);
+
+ printf ("******************************************\n");
+ printf (" sar Reassembly MME done\n");
+ printf ("******************************************\n");
+
+ sar_mme_buffer_add (station_test.sar, buffer);
+
+ blk_print_memory ();
}
// ---------------------------- Station functions --------------------------
/**
* Add a link to the STAtion i.e. will create a MFS
- *
+ *
* \param ctx the station context.
* \param type TX or RX link, it is a short 1 for TX 0 for RX.
* \param bcast short indicating if the link is a broadcast link
@@ -154,11 +183,20 @@ void station_test_link_add (station_test_t *ctx, uint type, uint bcast,
{
bool added;
mfs_t *mfs;
+ sta_t *sta;
dbg_assert (ctx);
dbg_assert (ctx->mac_store);
dbg_assert (ctx->sar);
+ if (MAC_TEI_IS_STA (tei))
+ {
+ mac_store_sta_add (ctx->mac_store, tei);
+ sta = mac_store_sta_get (ctx->mac_store, tei);
+ sta->authenticated = true;
+ blk_release (sta);
+ }
+
mfs = mac_store_mfs_add (ctx->mac_store, type, bcast, mme, lid, tei,
&added);
dbg_assert (added);
@@ -166,12 +204,14 @@ void station_test_link_add (station_test_t *ctx, uint type, uint bcast,
// add the link to the sar.
sar_mfs_add (ctx->sar, mfs);
+ /* Authenticated the station. */
+
blk_release (mfs);
}
/**
* Remove a link to the STAtion i.e. will create a MFS
- *
+ *
* \param ctx the station context.
* \param type TX or RX link, it is a short 1 for TX 0 for RX.
* \param bcast short indicating if the link is a broadcast link
@@ -182,13 +222,19 @@ void station_test_link_add (station_test_t *ctx, uint type, uint bcast,
void station_test_link_remove (station_test_t *ctx, uint type, uint bcast,
uint mme, uint lid, uint tei)
{
+ /*
mfs_t *mfs;
pb_t *pb;
+ */
dbg_assert (ctx);
dbg_assert (ctx->mac_store);
dbg_assert (ctx->sar);
+ dbg_assert (MAC_TEI_IS_STA (tei));
+
+ sar_sta_remove (ctx->sar, tei);
+ /*
mfs = mac_store_mfs_get (ctx->mac_store, type, bcast, mme, lid, tei);
if (mfs != NULL)
@@ -212,6 +258,7 @@ void station_test_link_remove (station_test_t *ctx, uint type, uint bcast,
blk_release (mfs);
}
+ */
}
/**
@@ -270,7 +317,7 @@ void create_schedule_csma_only (station_test_t *int_sta, uint beacon_period_nb)
/**
* Thread entry finction
- *
+ *
* \param int_sta the sta context.
*/
void pbproc_sched (cyg_addrword_t int_sta)
@@ -282,7 +329,7 @@ void pbproc_sched (cyg_addrword_t int_sta)
{
create_schedule_csma_only (station_test, 14);
station_test->sched_index ++;
-
+
//create the second schedule.
create_schedule_csma_only (station_test, 14);
station_test->sched_index ++;
@@ -298,7 +345,7 @@ void pbproc_sched (cyg_addrword_t int_sta)
/**
* Provides the Tei of the STA and the SNID
- *
+ *
* \param ctx the station context
* \param tei the tei of the station
* \param snid the snid of the AVLN
@@ -333,16 +380,19 @@ void station_test_config (station_test_t *ctx, uint tei, uint snid,
printf ("[STATION] PBproc Activated\n");
}
+
+ sar_mme_buffer_add (ctx->sar, mme_buffer);
+ sar_activate (ctx->sar, true);
}
/**
* Provides the TEI of all the station in the AVLN.
- *
+ *
* \param ctx the station context.
* \param tei the tei list of the stations
* \param qte the quantity of TEIs in the list.
*/
-void station_test_discover (station_test_t *ctx, uint *tei,
+void station_test_discover (station_test_t *ctx, uint *tei,
uint qte)
{
tei_node_t *node;
@@ -365,13 +415,47 @@ void station_test_discover (station_test_t *ctx, uint *tei,
// ---------------------------- Function calls -----------------------------
+/** Uninitialise the function
+ */
+int fc_station_uninit (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ uint i;
+ list_node_t *node;
+ ce_rx_params_node_t *ce;
+
+ sar_activate (station_test.sar, false);
+ pbproc_activate (station_test.pbproc, false);
+
+ for (i = MAC_TEI_STA_MIN; MAC_TEI_IS_STA (i); i++)
+ sar_sta_remove (station_test.sar, i);
+
+ sar_uninit (station_test.sar);
+ pbproc_uninit (station_test.pbproc);
+ mac_store_uninit (station_test.mac_store);
+
+ while (!list_empty (&ce_rx_params_list))
+ {
+ node = list_begin (&ce_rx_params_list);
+ ce = PARENT_OF (ce_rx_params_node_t, node, node);
+ if (ce->rx_params)
+ blk_release (ce->rx_params);
+ list_remove (&ce_rx_params_list, &ce->node);
+ blk_release (ce);
+ }
+
+ blk_print_memory ();
+
+ return true;
+}
+
/** Creates a link in the STA.
*
* - dtei the tei of the station.
* - fw forward link
* - rw reverse link
* - bcast broadcast.
- *
+ *
* \param fcall the fcall context.
* \param param the fcall param
* \param msg the message
@@ -399,7 +483,7 @@ int fc_add_mme_link (fcall_ctx_t *fcall, fcall_param_t **param,
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;
@@ -410,7 +494,7 @@ int fc_add_mme_link (fcall_ctx_t *fcall, fcall_param_t **param,
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;
@@ -422,7 +506,7 @@ int fc_add_mme_link (fcall_ctx_t *fcall, fcall_param_t **param,
}
/** Initialise the station parameters data as the mac address the tei.
- *
+ *
* - stei.
* - mac_addr.
*
@@ -442,6 +526,8 @@ int fc_station_config (fcall_ctx_t *fcall, fcall_param_t **param,
station_test.mac_config.sta_mac_address = mac_address;
station_test.mac_config.tei = stei;
+ station_test.mac_config.authenticated = true;
+ sar_activate (station_test.sar, true);
fcall_param_reset (*param);
@@ -453,7 +539,7 @@ int fc_station_config (fcall_ctx_t *fcall, fcall_param_t **param,
* 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
@@ -495,13 +581,13 @@ int fc_station_start (fcall_ctx_t *fcall, fcall_param_t **param,
/**
* Add a link to the Station in order to receive or transmit data.
- *
+ *
* - type TX or RX link, it is a short 1 for TX 0 for RX.
* - bcast short indicating if the link is a broadcast link
* - mme short indicating if the link will be use to transmit MMEs
* - lid short indicating if it is a link identitier.
* - tei short the destination station.
- *
+ *
* \param fcall the fcall context.
* \param param the fcall param
* \param msg the message
@@ -546,13 +632,13 @@ int fc_station_link_add (fcall_ctx_t *fcall, fcall_param_t **param,
/**
* Remove a link to the Station in order to receive or transmit data.
- *
+ *
* - type TX or RX link, it is a short 1 for TX 0 for RX.
* - bcast short indicating if the link is a broadcast link
* - mme short indicating if the link will be use to transmit MMEs
* - lid short indicating if it is a link identitier.
* - tei short the destination station.
- *
+ *
* \param fcall the fcall context.
* \param param the fcall param
* \param msg the message
@@ -599,7 +685,7 @@ int fc_station_link_remove (fcall_ctx_t *fcall, fcall_param_t **param,
* Initialize the configuration of the STA.
* The parameters we must provide are the TEI of the STA, the SNID and the
* boolean to indicate the auto generation of the beacon periods.
- *
+ *
* \param fcall the fcall context.
* \param param the fcall param
* \param msg the message
@@ -630,7 +716,7 @@ int fc_station_init_config (fcall_ctx_t *fcall, fcall_param_t **param,
/**
* Add a data buffer to the SAR.
- *
+ *
* \param fcall the fcall context.
* \param param the fcall param
* \param msg the message
@@ -651,14 +737,14 @@ int fc_sar_data_buffer_add (fcall_ctx_t *fcall, fcall_param_t **param,
/**
* Add Msdu to send
- *
+ *
* - lid the link to use
* - tei the destination
* - bcast if the link is a bcast link
* - mme if it is a mme
* - buffer the buffer containing a frame
* - length the buffer length
- *
+ *
* \param fcall the fcall context.
* \param param the fcall param
* \param msg the message
@@ -717,7 +803,7 @@ int fc_sar_msdu_add (fcall_ctx_t *fcall, fcall_param_t **param,
* This will be use to add the STA's to the mac store, the STA will keep a
* list of theses TEI to remove the STA during the uninit procedure.
*
- *
+ *
* \param fcall the fcall context.
* \param param the fcall param
* \param msg the message
@@ -760,7 +846,7 @@ int fc_station_discover (fcall_ctx_t *fcall, fcall_param_t **param,
* print the sar traces for the tests.
* if the trace_config == y the traces are printed to the stdio.
* otherwise nothing is printed.
- *
+ *
* \param fcall the fcall context.
* \param param the fcall param
* \param msg the message
@@ -781,24 +867,24 @@ int fc_sar_print_trace (fcall_ctx_t *fcall, fcall_param_t **param,
/**
* CE measurements. To be replace by the CE function to get the measurements
- *
+ *
* Pb measurement RX callback for Channel estimation.
- * This call back will return one or two block in order to insert all the
+ * This call back will return one or two block in order to insert all the
* measurements contained in each PB of the mpdu received.
- * Two cases can happen, the first the pb_nb is lesser than the blk capacity,
- * this callback will return only a blk pointed by the first and the last
+ * Two cases can happen, the first the pb_nb is lesser than the blk capacity,
+ * this callback will return only a blk pointed by the first and the last
* pointer.
* In the second case the quantity of PB are greater than one blk capacity, this
* callback will return two blk (chained) the first pointed by the first pointer
* and the last one by the last pointer.
- *
- * \param user User data
+ *
+ * \param user User data
* \param rx_params Frame control information to know date and tonemap used
* \param number of pbs
* \param first blk to insert the measurements.
* \param last blk to insert the measurements.
* \param chandata chan data measurements
- *
+ *
* \return boolean to indicate if a block had been returned or not.
*/
bool ce_measurements (void *user, pbproc_rx_params_t *rx_params, uint pb_nb,
@@ -820,7 +906,7 @@ bool ce_measurements (void *user, pbproc_rx_params_t *rx_params, uint pb_nb,
if (chandata)
{
- blk_release (chandata);
+ blk_release_desc_range_nb ((blk_t *) chandata, nb_chandata);
}
return false;
@@ -947,12 +1033,16 @@ cyg_user_start (void)
fcall_register (my_station.fcall, "fc_sar_print_trace",
&fc_sar_print_trace, NULL);
+ fcall_register (my_station.fcall, "fc_station_uninit",
+ &fc_station_uninit, NULL);
+
sar_init_data_context (station_test.sar, station_test.sar);
sar_init_mme_context (station_test.sar, station_test.sar);
sar_init_segmentation_data_cb (station_test.sar, sar_segmentation_ul_done);
- sar_init_reassembly_ul (station_test.sar, sar_reassembly_ul_done, true);
- sar_init_reassembly_ul (station_test.sar, sar_reassembly_ul_done, false);
+ sar_init_segmentation_mme_cb (station_test.sar, sar_segmentation_ul_done);
+ sar_init_reassembly_data_cb (station_test.sar, sar_reassembly_ul_done);
+ sar_init_reassembly_mme_cb (station_test.sar, sar_reassembly_mme_done);
sar_init_measure_context (station_test.sar, &station_test.sar);
sar_init_measurement_cb (station_test.sar, ce_measurements);
diff --git a/cesar/test_general/maximus/integration/sar-pbproc/test1.py b/cesar/test_general/maximus/integration/sar-pbproc/test1.py
index 5211cf9f27..c382ad6179 100644
--- a/cesar/test_general/maximus/integration/sar-pbproc/test1.py
+++ b/cesar/test_general/maximus/integration/sar-pbproc/test1.py
@@ -102,14 +102,17 @@ fc2.add_param_ushort ("lid", 1)
fc2.add_param_ushort ("tei", 1)
fc2.send()
-
-#maximus.wait(1000)
+maximus.wait(10000)
print "\n************ STATION 1 TRACE ***************\n"
fc1 = maximus.create_fcall ("fc_sar_print_trace")
fc1.set_sta(station1)
fc1.send();
+fc1 = maximus.create_fcall ("fc_station_uninit")
+fc1.set_sta(station1)
+fc1.send();
+
station1.remove()
@@ -118,4 +121,8 @@ fc1 = maximus.create_fcall ("fc_sar_print_trace")
fc1.set_sta(station2)
fc1.send();
+fc1 = maximus.create_fcall ("fc_station_uninit")
+fc1.set_sta(station2)
+fc1.send();
+
station2.remove()
diff --git a/cesar/test_general/maximus/integration/sar-pbproc/test2.py b/cesar/test_general/maximus/integration/sar-pbproc/test2.py
new file mode 100644
index 0000000000..54620f372f
--- /dev/null
+++ b/cesar/test_general/maximus/integration/sar-pbproc/test2.py
@@ -0,0 +1,100 @@
+#!/usr/bin/env python
+
+import sys
+sys.path.append('../../../../maximus/python/obj');
+
+from interface import *
+from string import *
+from struct import *
+
+maximus = Maximus()
+maximus.init (sys.argv + ['-e', './obj/sar-pbproc.elf'])
+
+# TEI of station 1 will be 1
+station1 = maximus.create_sta()
+#station1.debug()
+
+# TEI of station 2 will be 2
+station2 = maximus.create_sta()
+station2.debug()
+
+fc1 = maximus.create_fcall ("fc_station_init_config")
+fc1.set_sta (station1)
+fc1.add_param_ushort ("snid", 1)
+fc1.add_param_ushort ("tei", 1)
+fc1.add_param_ushort ("auto_sched", 1)
+fc1.send()
+
+fc2 = maximus.create_fcall ("fc_station_init_config")
+fc2.set_sta (station2)
+fc2.add_param_ushort ("snid", 1)
+fc2.add_param_ushort ("tei", 2)
+fc2.add_param_ushort ("auto_sched", 1)
+fc2.send()
+
+fc1 = maximus.create_fcall ("fc_station_link_add")
+fc1.set_sta (station1)
+fc1.add_param_ushort ("type", 1)
+fc1.add_param_ushort ("bcast", 1)
+fc1.add_param_ushort ("mme", 1)
+fc1.add_param_ushort ("lid", 248)
+fc1.add_param_ushort ("tei", 255)
+fc1.send()
+
+fc1 = maximus.create_fcall ("fc_sar_msdu_add")
+fc1.set_sta (station1)
+fc1.add_param_ushort ("tei", 255)
+fc1.add_param_ushort ("lid", 248)
+fc1.add_param_ushort ("bcast", 1)
+fc1.add_param_ushort ("mme", 1)
+fc1.add_param_ushort ("length", 106)
+f = open ('../../packet1','r')
+fc1.add_param ("buffer", f.read())
+fc1.send()
+
+
+maximus.wait (1000)
+fc1 = maximus.create_fcall ("fc_sar_msdu_add")
+fc1.set_sta (station1)
+fc1.add_param_ushort ("tei", 255)
+fc1.add_param_ushort ("lid", 248)
+fc1.add_param_ushort ("bcast", 1)
+fc1.add_param_ushort ("mme", 1)
+fc1.add_param_ushort ("length", 106)
+f = open ('../../packet1','r')
+fc1.add_param ("buffer", f.read())
+fc1.send()
+
+maximus.wait (10000000)
+
+fc2 = maximus.create_fcall ("fc_station_link_remove")
+fc2.set_sta (station2)
+fc2.add_param_ushort ("type", 0)
+fc2.add_param_ushort ("bcast", 1)
+fc2.add_param_ushort ("mme", 1)
+fc2.add_param_ushort ("lid", 248)
+fc2.add_param_ushort ("tei", 1)
+fc2.send()
+
+print "\n************ STATION 1 TRACE ***************\n"
+fc1 = maximus.create_fcall ("fc_sar_print_trace")
+fc1.set_sta(station1)
+fc1.send();
+
+fc1 = maximus.create_fcall ("fc_station_uninit")
+fc1.set_sta(station1)
+fc1.send();
+
+station1.remove()
+
+
+print "\n************ STATION 2 TRACE ***************\n"
+fc1 = maximus.create_fcall ("fc_sar_print_trace")
+fc1.set_sta(station2)
+fc1.send();
+
+fc1 = maximus.create_fcall ("fc_station_uninit")
+fc1.set_sta(station2)
+fc1.send();
+
+station2.remove()