summaryrefslogtreecommitdiff
path: root/cesar/mac/sar/test/functional/src/test_functions.c
diff options
context:
space:
mode:
authorlaranjeiro2009-11-23 13:28:41 +0000
committerlaranjeiro2009-11-23 13:28:41 +0000
commitf473a9e4c2368db3731ed5fbf11baaa51ae6a8d9 (patch)
tree83dbc45fd337d2d1d249c1092707b56b3b8bb052 /cesar/mac/sar/test/functional/src/test_functions.c
parentffcc89ad3e38c147875c1dd00ab413e136288a48 (diff)
cesar/mac/sar: tx performance test
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@6454 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/mac/sar/test/functional/src/test_functions.c')
-rw-r--r--cesar/mac/sar/test/functional/src/test_functions.c131
1 files changed, 130 insertions, 1 deletions
diff --git a/cesar/mac/sar/test/functional/src/test_functions.c b/cesar/mac/sar/test/functional/src/test_functions.c
index 7ea8b45a39..cd47604f1b 100644
--- a/cesar/mac/sar/test/functional/src/test_functions.c
+++ b/cesar/mac/sar/test/functional/src/test_functions.c
@@ -31,6 +31,7 @@
#include <cyg/kernel/kapi.h>
#include <cyg/hal/hal_arch.h>
+#include "mac/sar/inc/sar_context.h"
#define BUFFERS_MAX 100
@@ -57,7 +58,10 @@ ce_measurements (void *user, pbproc_rx_params_t *rx_params, uint pb_nb,
static void
sar_test_segmentation_done__do_nothing (void *user,
u8* buffer,
- void *user_data) { }
+ void *user_data)
+{
+ nb_frames++;
+}
static void
sar_reassembly_done__do_nothing (void *user, u8* buffer, uint length,
@@ -309,3 +313,128 @@ sar_test_rx_multiple_frames (uint frames_nb, uint frames_len)
HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
#endif
}
+
+static void
+test_simulate_msdu_emission (sar_test_ctx_t *ctx,
+ uint frames_nb, uint frames_len)
+{
+ mfs_tx_t *mfs;
+ bool added;
+ u8 *buffer;
+ uint i;
+
+ /* Activate the SAR. */
+ sar_activate (ctx->sar, true);
+
+ /* Create the MFS to send data. */
+ mfs = mac_store_mfs_add_tx (ctx->mac_store, false, false, 1, 1, &added);
+
+ if (added)
+ sar_mfs_add (ctx->sar, (mfs_t*) mfs);
+
+ /* Get the buffer. */
+ buffer = sar_test_get_buffer (0);
+ memset (buffer, 0xff, 2048);
+
+ /* Disallow the SAR to expire MFS. */
+ ctx->sar->expiration_last_ntb = mac_ntb() + 100;
+ for (i = 0; i < frames_nb; i++)
+ sar_msdu_add (ctx->sar, buffer, frames_len, mfs, INVALID_PTR,
+ mac_ntb());
+
+ blk_release (mfs);
+}
+
+void
+test_simulate_msdu_emission_check (sar_test_ctx_t *ctx, test_t test,
+ uint frames_nb, uint frames_len)
+{
+ mfs_tx_t *mfs;
+ crc_t crc_ctx;
+ u32 enc_tab[256];
+ u32 crc;
+ u8 *buffer;
+ pb_t *pb_current;
+ bitstream_t stream;
+
+ mfs = mac_store_mfs_get_tx (ctx->mac_store, false, false, 1, 1);
+
+ /* Compute the CRC. */
+ crc_ctx.width = 32;
+ crc_ctx.generator = HPAV_CRC32_GENERATOR;
+ crc_ctx.init = HPAV_CRC32_INIT;
+ crc_ctx.refin = true;
+ crc_ctx.refout = true;
+ crc_ctx.xorout = 0xffffffff;
+ crc_ctx.reg_init = 0;
+ crc_ctx.table.t32 = enc_tab;
+ crc_init(&crc_ctx);
+
+ buffer = buffers[0];
+ memset (buffer, 0xff, 2048);
+ /* Request the Leon processor to write all the data buffered. */
+ arch_write_buffer_flush ();
+
+ crc = crc_compute_begin (&crc_ctx);
+ crc = bridgedma_crc_compute_continue_block (&crc_ctx, crc, buffer,
+ frames_len);
+ crc = crc_compute_end (&crc_ctx, crc);
+
+ test_begin (test, "Sar")
+ {
+ test_fail_unless (frames_nb ==
+ sar_test_nb_ethernet_frames_received());
+
+
+ pb_current = mfs->head;
+ bitstream_read_init (&stream, pb_current->data, BLK_SIZE);
+ for (;
+ pb_current;
+ pb_current = pb_current->next)
+ {
+ bitstream_init_buffer_cb (&stream, sar_test_change_pb,
+ &pb_current);
+ test_fail_unless (bitstream_read (&stream, 2)
+ == SAR_MF_TYPE_DATA);
+ test_fail_unless (bitstream_read (&stream, 14)
+ == frames_len - 1);
+ bitstream_skip (&stream, frames_len * 8);
+ test_fail_unless (bitstream_read (&stream, 32) == crc);
+ }
+ }
+ test_end;
+
+ /* Release the memory. */
+ sar_mfs_free_tx (ctx->sar, mfs);
+ blk_release (mfs);
+}
+
+
+void
+sar_test_tx_multiple_frames (uint frames_nb, uint frames_len)
+{
+ test_t test;
+ sar_test_ctx_t ctx;
+
+ trace_init ();
+ hal_trace_init ();
+ test_init (test, 0, NULL);
+
+ /* Initialise the test. */
+ sar_test_init (&ctx);
+
+ test_simulate_msdu_emission (&ctx, frames_nb, frames_len);
+
+ /* Wait some time. */
+ cyg_thread_delay (50);
+
+ test_simulate_msdu_emission_check (&ctx, test, frames_nb, frames_len);
+
+ /* Uninitialise the test. */
+ sar_test_uninit (&ctx);
+
+ test_result (test);
+#ifndef __sparc__
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+#endif
+}