summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaranjeiro2009-11-23 13:28:32 +0000
committerlaranjeiro2009-11-23 13:28:32 +0000
commit7674b62619729b4a3d19b2ec243a56cec5087521 (patch)
treeaf781f74636d8814aa257299cb14291159f5ec97
parent5667dfd7ff8014927adae9039eecb58aee3c9bd5 (diff)
cesar/mac/sar: add a performance rx test
sar_rx_perf: Full initialised test with MFS already created to put the SAR in a normal performance flow test. This only simulate reception of a single MPDU containing a full Ethernet packet i.e. 1518 bytes long. sar_rx_perf_hudge_mpdu: A MPDU containing 200 Ethernet frames of 60 bytes each in a single MPDU. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@6449 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--cesar/mac/sar/test/functional/host-Makefile11
-rw-r--r--cesar/mac/sar/test/functional/sparc-Makefile12
-rw-r--r--cesar/mac/sar/test/functional/src/sar_rx_perf.c53
-rw-r--r--cesar/mac/sar/test/functional/src/sar_rx_perf_huge_mpdu.c48
-rw-r--r--cesar/mac/sar/test/functional/src/test_functions.c311
-rw-r--r--cesar/mac/sar/test/functional/test_functions.h59
6 files changed, 492 insertions, 2 deletions
diff --git a/cesar/mac/sar/test/functional/host-Makefile b/cesar/mac/sar/test/functional/host-Makefile
index 82753889aa..3f8299b539 100644
--- a/cesar/mac/sar/test/functional/host-Makefile
+++ b/cesar/mac/sar/test/functional/host-Makefile
@@ -3,7 +3,7 @@ BASE = ../../../..
ECOS = y
VARIANT= host
-TARGET_PROGRAMS = sar_rx sar_tx
+TARGET_PROGRAMS = sar_rx sar_tx sar_rx_perf sar_rx_perf_huge_mpdu
sar_rx_SOURCES = sar_rx.c pbproc_stub.c ca_stub.c
sar_rx_MODULES = hal/arch hal/phy lib mac/common mac/sar mac/pbproc
@@ -11,6 +11,15 @@ sar_rx_MODULES = hal/arch hal/phy lib mac/common mac/sar mac/pbproc
sar_tx_SOURCES = sar_tx.c pbproc_stub.c ca_stub.c
sar_tx_MODULES = hal/arch hal/phy lib mac/common mac/sar mac/pbproc
+sar_rx_perf_SOURCES = sar_rx_perf.c pbproc_stub.c ca_stub.c test_functions.c
+sar_rx_perf_MODULES = hal/arch hal/phy lib mac/common mac/sar mac/pbproc
+
+sar_rx_perf_huge_mpdu_SOURCES = sar_rx_perf_huge_mpdu.c pbproc_stub.c \
+ ca_stub.c test_functions.c
+sar_rx_perf_huge_mpdu_MODULES = hal/arch hal/phy lib mac/common mac/sar \
+ mac/pbproc
+
+
mac_pbproc_MODULE_SOURCES = mfs.c
hal_phy_MODULE_SOURCES=bridgedma_soft.c
diff --git a/cesar/mac/sar/test/functional/sparc-Makefile b/cesar/mac/sar/test/functional/sparc-Makefile
index 36595c19db..5508d4ae53 100644
--- a/cesar/mac/sar/test/functional/sparc-Makefile
+++ b/cesar/mac/sar/test/functional/sparc-Makefile
@@ -5,7 +5,7 @@ TARGET = sparc
VARIANT= sparc
TARGET_OPTIMIZE = -Os
-TARGET_PROGRAMS = sar_rx sar_tx
+TARGET_PROGRAMS = sar_rx sar_tx sar_rx_perf sar_rx_perf_huge_mpdu
sar_rx_SOURCES = sar_rx.c pbproc_stub.c ca_stub.c
sar_rx_MODULES = hal/arch hal/phy lib mac/common mac/sar mac/pbproc
@@ -13,6 +13,16 @@ sar_rx_MODULES = hal/arch hal/phy lib mac/common mac/sar mac/pbproc
sar_tx_SOURCES = sar_tx.c pbproc_stub.c ca_stub.c
sar_tx_MODULES = hal/arch hal/phy lib mac/common mac/sar mac/pbproc
+sar_rx_perf_SOURCES = sar_rx_perf.c pbproc_stub.c ca_stub.c test_functions.c
+sar_rx_perf_MODULES = hal/arch hal/phy lib mac/common mac/sar mac/pbproc \
+ hal/trace
+
+sar_rx_perf_huge_mpdu_SOURCES = sar_rx_perf_huge_mpdu.c pbproc_stub.c \
+ ca_stub.c test_functions.c
+sar_rx_perf_huge_mpdu_MODULES = hal/arch hal/phy lib mac/common mac/sar \
+ mac/pbproc hal/trace
+
+
mac_pbproc_MODULE_SOURCES = mfs.c
include $(BASE)/common/make/top.mk
diff --git a/cesar/mac/sar/test/functional/src/sar_rx_perf.c b/cesar/mac/sar/test/functional/src/sar_rx_perf.c
new file mode 100644
index 0000000000..2cd29fcb5d
--- /dev/null
+++ b/cesar/mac/sar/test/functional/src/sar_rx_perf.c
@@ -0,0 +1,53 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/sar/test/functional/src/sar_rx_perf.c
+ * \brief SAR performance test for RX.
+ * \ingroup mac_sar
+ *
+ */
+#include "common/std.h"
+#include "common/defs/homeplugAV.h"
+
+#include "lib/test.h"
+#include "lib/trace.h"
+#include "lib/bitstream.h"
+
+#include <cyg/kernel/kapi.h>
+#include <cyg/hal/hal_arch.h>
+
+#include "mac/sar/inc/sar_context.h"
+#include "mac/sar/test/functional/test_functions.h"
+
+/* Thread data for the test. */
+cyg_thread my_test_thread;
+cyg_handle_t my_test_thread_handle;
+u8 my_test_thread_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+void
+test_thread_process (cyg_addrword_t data)
+{
+ sar_test_rx_multiple_frames (1, ETH_PACKET_MAX_SIZE);
+}
+
+int
+cyg_user_start (void)
+{
+ // Create the thread.
+ cyg_thread_create( 10,
+ &test_thread_process,
+ (cyg_addrword_t) 0,
+ "TEST_THREAD",
+ my_test_thread_stack,
+ CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &my_test_thread_handle,
+ &my_test_thread);
+ cyg_thread_resume (my_test_thread_handle);
+
+ return 0;
+}
diff --git a/cesar/mac/sar/test/functional/src/sar_rx_perf_huge_mpdu.c b/cesar/mac/sar/test/functional/src/sar_rx_perf_huge_mpdu.c
new file mode 100644
index 0000000000..2fcccf789c
--- /dev/null
+++ b/cesar/mac/sar/test/functional/src/sar_rx_perf_huge_mpdu.c
@@ -0,0 +1,48 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/sar/test/functional/src/sar_rx_perf_huge_mpdu.c
+ * \brief SAR performance test for RX.
+ * \ingroup mac_sar
+ *
+ */
+#include "common/std.h"
+#include "common/defs/homeplugAV.h"
+
+#include <cyg/kernel/kapi.h>
+#include <cyg/hal/hal_arch.h>
+
+#include "mac/sar/test/functional/test_functions.h"
+
+/* Thread data for the test. */
+cyg_thread my_test_thread;
+cyg_handle_t my_test_thread_handle;
+u8 my_test_thread_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+void
+test_thread_process (cyg_addrword_t data)
+{
+ sar_test_rx_multiple_frames (100, 60);
+}
+
+int
+cyg_user_start (void)
+{
+ // Create the thread.
+ cyg_thread_create( 10,
+ &test_thread_process,
+ (cyg_addrword_t) 0,
+ "TEST_THREAD",
+ my_test_thread_stack,
+ CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &my_test_thread_handle,
+ &my_test_thread);
+ cyg_thread_resume (my_test_thread_handle);
+
+ return 0;
+}
diff --git a/cesar/mac/sar/test/functional/src/test_functions.c b/cesar/mac/sar/test/functional/src/test_functions.c
new file mode 100644
index 0000000000..7ea8b45a39
--- /dev/null
+++ b/cesar/mac/sar/test/functional/src/test_functions.c
@@ -0,0 +1,311 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/sar/test/functional/src/test_functions.c
+ * \brief Common functions for tests.
+ * \ingroup mac_sar
+ */
+#include "common/std.h"
+#include "common/defs/homeplugAV.h"
+
+#include "lib/test.h"
+#include "lib/trace.h"
+#include "lib/blk.h"
+#include "lib/crc.h"
+#include "lib/bitstream.h"
+
+#include "mac/common/ntb.h"
+#include "lib/bitstream.h"
+#include "mac/sar/test/functional/test_functions.h"
+
+#include "hal/arch/arch.h"
+#include "hal/trace/trace.h"
+#include "hal/phy/inc/bridgedma_soft.h"
+
+#include <stdio.h>
+#include <cyg/kernel/kapi.h>
+#include <cyg/hal/hal_arch.h>
+
+
+#define BUFFERS_MAX 100
+
+/* Variables needed by the test. */
+#ifdef __sparc__
+static u8 buffers[BUFFERS_MAX][2048] __attribute__ ((section(".private")));
+#else
+static u8 buffers[BUFFERS_MAX][2048];
+#endif
+
+static uint nb_frames;
+
+/* Stubbed Functions. */
+static bool
+ce_measurements (void *user, pbproc_rx_params_t *rx_params, uint pb_nb,
+ blk_t **first, blk_t **last, pb_t *chandata, uint nb_chandata, uint
+ *blk_offset)
+{
+ if (nb_chandata)
+ blk_release_desc_range_nb ((blk_t *) chandata, nb_chandata);
+ return false;
+}
+
+static void
+sar_test_segmentation_done__do_nothing (void *user,
+ u8* buffer,
+ void *user_data) { }
+
+static void
+sar_reassembly_done__do_nothing (void *user, u8* buffer, uint length,
+ mfs_rx_t *mfs, bool encrypted)
+{
+ nb_frames++;
+}
+/*-- End stubbed functions. --*/
+
+void
+sar_test_init (sar_test_ctx_t *test_ctx)
+{
+ dbg_assert (test_ctx);
+
+ /* Initialise the mac NTB. */
+ mac_ntb_init (INVALID_PTR, &test_ctx->mac_config);
+
+ /* Initialise the store. */
+ test_ctx->mac_store = mac_store_init ();
+
+ /* Initialise the SAR. */
+ test_ctx->sar = sar_init (test_ctx->mac_store, INVALID_PTR, INVALID_PTR,
+ 2);
+ /* CE. */
+ sar_init_measure_context (test_ctx->sar, INVALID_PTR);
+ sar_init_measurement_cb (test_ctx->sar, ce_measurements);
+ sar_init_data_context (test_ctx->sar, INVALID_PTR);
+ sar_init_segmentation_data_cb (test_ctx->sar,
+ sar_test_segmentation_done__do_nothing);
+ sar_init_mme_context (test_ctx->sar, INVALID_PTR);
+ sar_init_segmentation_mme_cb (test_ctx->sar,
+ sar_test_segmentation_done__do_nothing);
+ sar_init_reassembly_data_cb (test_ctx->sar,
+ sar_reassembly_done__do_nothing);
+ sar_init_reassembly_mme_cb (test_ctx->sar,
+ sar_reassembly_done__do_nothing);
+
+ nb_frames = 0;
+}
+
+void
+sar_test_uninit (sar_test_ctx_t *test_ctx)
+{
+ dbg_assert (test_ctx);
+
+ sar_cleanup (test_ctx->sar);
+ sar_uninit (test_ctx->sar);
+ mac_store_uninit (test_ctx->mac_store);
+}
+
+static void
+sar_test_change_pb (bitstream_t *ctx, void *user_data)
+{
+ pb_t **pb = user_data;
+ dbg_assert (ctx);
+ dbg_assert (user_data);
+
+ *pb = (*pb)->next;
+ bitstream_set_buffer (ctx, (*pb)->data, BLK_SIZE);
+}
+
+void
+test_simulate_mpdu_reception (sar_test_ctx_t *ctx, uint eth_frame_nb,
+ uint eth_frame_len)
+{
+ crc_t crc_ctx;
+ u32 enc_tab[256];
+ u32 crc;
+ u8 *buffer;
+ blk_t *pb_first, *pb_last;
+ pb_t *pb_current;
+ mfs_rx_t *mfs;
+ bool added;
+ pbproc_rx_desc_t *sar_mpdu;
+ uint pb_nb;
+ u16 ssn = 0;
+ uint i, j;
+ bitstream_t stream;
+
+ dbg_assert (eth_frame_nb <= BUFFERS_MAX);
+
+ /* Compute PB number. */
+ pb_nb = (eth_frame_nb * (eth_frame_len + 6) + BLK_SIZE - 1) / BLK_SIZE;
+ dbg_assert (pb_nb <= 200);
+
+ /* Store the Frame in the PBs. */
+ pb_first = blk_alloc_desc_range (pb_nb, &pb_last);
+ ((pb_t*)pb_last)->next = NULL;
+
+ for (pb_current = (pb_t*) pb_first;
+ pb_current;
+ pb_current = pb_current->next, ssn++)
+ {
+ pb_current->phy_pb.pb_rx.pb_measurement.crc_error = false;
+ pb_current->header.ssn = ssn;
+ pb_current->header.vpbf = true;
+ pb_current->header.mmqf = false;
+ pb_current->header.opsf = false;
+ pb_current->header.mfbf = false;
+ pb_current->header.mfbo = 0;
+ }
+
+ /* 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,
+ eth_frame_len);
+ crc = crc_compute_end (&crc_ctx, crc);
+
+ /* Store a Full size Ethernet Packet in it. */
+ pb_current = (pb_t*) pb_first;
+ bitstream_write_init (&stream, pb_current->data, BLK_SIZE);
+ for (i = 0; i < eth_frame_nb; i++)
+ {
+ bitstream_init_buffer_cb (&stream, sar_test_change_pb,
+ &pb_current);
+ if (pb_current->header.mfbf == false)
+ {
+ pb_current->header.mfbf = true;
+ pb_current->header.mfbo = bitstream_written_bits (&stream) / 8;
+ }
+
+ bitstream_write (&stream, SAR_MF_TYPE_DATA, 2);
+ bitstream_write (&stream, eth_frame_len - 1, 14);
+ for (j = 0; j < eth_frame_len; j++)
+ bitstream_write (&stream, 0xff, 8);
+ bitstream_write (&stream, crc, 32);
+ }
+
+ /* Request the Leon processor to write all the data buffered. */
+ arch_write_buffer_flush ();
+
+ /* Activate the SAR. */
+ sar_activate (ctx->sar, true);
+
+ /* Provide the buffer to the SAR. */
+ for (i = 0; i < eth_frame_nb; i++)
+ {
+ buffer = ARCH_CPU_TO_UNCACHEABLE (buffers[i]);
+ memset (buffer, 0x0, ETH_PACKET_MAX_SIZE);
+
+ sar_data_buffer_add (ctx->sar, buffer);
+ }
+
+ /* Prepare the MPDU for the SAR. */
+ sar_mpdu = (pbproc_rx_desc_t*) blk_alloc_desc ();
+ sar_mpdu->rx->params.tei = 1;
+ sar_mpdu->rx->params.lid = 2;
+ sar_mpdu->rx->params.eks = 0;
+ sar_mpdu->rx->params.mfs_cmd_data = MFS_FSM_CMD_NOP;
+ sar_mpdu->rx->params.mfs_cmd_mme = MFS_FSM_CMD_NOP;
+ sar_mpdu->rx->params.multi_net_bcast = false;
+ sar_mpdu->rx->params.bcast = false;
+ sar_mpdu->rx->params.sound = false;
+ sar_mpdu->rx->mfs = NULL;
+ sar_mpdu->rx->mfs_mme = NULL;
+ sar_mpdu->rx->pb_first = (pb_t*) pb_first;
+ sar_mpdu->rx->pb_last = (pb_t*) pb_last;
+ sar_mpdu->rx->pb_nb = pb_nb;
+ sar_mpdu->rx->chandata_first = NULL;
+ sar_mpdu->rx->chandata_nb = 0;
+ sar_mpdu->rx->params.preamble_ntb = mac_ntb();
+
+ /* Crete the necessary MFS. */
+ mfs = mac_store_mfs_add_rx (ctx->mac_store, sar_mpdu->rx->params.bcast,
+ false /* mme */, sar_mpdu->rx->params.lid,
+ sar_mpdu->rx->params.tei, &added);
+ mfs->ssn_min = 0;
+ dbg_assert (added);
+ /* Add the MFS to the expiration mechanism of the SAR. */
+ sar_mfs_add (ctx->sar, (mfs_t*) mfs);
+ /* Release the current reference on the MFS. */
+ blk_release (mfs);
+
+ /* Add the mpdu. */
+ sar_mpdu_add (ctx->sar, sar_mpdu);
+}
+
+u8*
+sar_test_get_buffer (uint buffer_nb)
+{
+ dbg_assert (buffer_nb < BUFFERS_MAX);
+ return ARCH_CPU_TO_UNCACHEABLE (buffers[buffer_nb]);
+}
+
+uint
+sar_test_nb_ethernet_frames_received (void)
+{
+ return nb_frames;
+}
+
+void
+sar_test_rx_multiple_frames (uint frames_nb, uint frames_len)
+{
+ test_t test;
+ u8 *buffer;
+ sar_test_ctx_t ctx;
+
+ trace_init ();
+ hal_trace_init ();
+ test_init (test, 0, NULL);
+
+ /* Initialise the test. */
+ sar_test_init (&ctx);
+
+ /* 200 frames of 60 bytes each. */
+ test_simulate_mpdu_reception (&ctx, frames_nb, frames_len);
+
+ /* Wait some time. */
+ cyg_thread_delay (50);
+
+ /* Uninitialise the test. */
+ sar_test_uninit (&ctx);
+
+ test_case_begin (test, "Verify reassembly");
+
+ test_begin (test, "Sar reassembly")
+ {
+ uint i, j;
+ test_fail_unless (frames_nb ==
+ sar_test_nb_ethernet_frames_received());
+
+ for (j = 0; j < frames_nb; j++)
+ {
+ buffer = sar_test_get_buffer (j);
+ for (i = 0; i < frames_len; i++)
+ test_fail_unless (bitstream_direct_read (buffer, i*8, 8)
+ == 0xFF);
+ }
+ }
+ test_end;
+
+ test_result (test);
+#ifndef __sparc__
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+#endif
+}
diff --git a/cesar/mac/sar/test/functional/test_functions.h b/cesar/mac/sar/test/functional/test_functions.h
new file mode 100644
index 0000000000..231e5dcf27
--- /dev/null
+++ b/cesar/mac/sar/test/functional/test_functions.h
@@ -0,0 +1,59 @@
+#ifndef mac_sar_test_functional_test_functions_h
+#define mac_sar_test_functional_test_functions_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/sar/test/functional/test_functions.h
+ * \brief Common functions for tests.
+ * \ingroup mac_sar
+ */
+#include "mac/sar/sar.h"
+
+struct sar_test_ctx_t
+{
+ sar_t *sar;
+ mac_store_t *mac_store;
+ mac_config_t mac_config;
+};
+typedef struct sar_test_ctx_t sar_test_ctx_t;
+
+BEGIN_DECLS
+
+/**
+ * Initialise the test context.
+ * \param ctx the sar test context.
+ */
+void
+sar_test_init (sar_test_ctx_t *test_ctx);
+
+/**
+ * Uninitialise the sar test context.
+ * \param ctx the sar test context.
+ */
+void
+sar_test_uninit (sar_test_ctx_t *test_ctx);
+
+/**
+ * Get the number of frames reassemblied.
+ * \return the number of correctly reassemblied Ethernet frames.
+ */
+uint
+sar_test_nb_ethernet_frames_received (void);
+
+/**
+ * Create N frames_nb Ethernet packet of frames_len bytes long embedded in a
+ * MUPDU.
+ * \param frames_nb number of expected reassembly frames.
+ * \param frames_len the length of the frames.
+ */
+void
+sar_test_rx_multiple_frames (uint frames_nb, uint frames_len);
+
+END_DECLS
+
+#endif /* mac_sar_test_functional_test_functions_h */