summaryrefslogtreecommitdiff
path: root/cesar/test_general/hard
diff options
context:
space:
mode:
authorlaranjeiro2008-08-25 11:40:04 +0000
committerlaranjeiro2008-08-25 11:40:04 +0000
commitf3c26d7ec8b3b12fc00493165f7222bd48fddf17 (patch)
tree674e2cdd4b0a4ee76dd413b32037d3a8c425d7c6 /cesar/test_general/hard
parent6ccea8e110a2b1bca8406d5d85554d9c7861c188 (diff)
test_general/hard/bridgedma: Added a test and replace the uint it_recv by a bool it_recv.
* Added a test to verify the TX path on the bridgedma (3 jobs with CRC control). git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2753 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/test_general/hard')
-rw-r--r--cesar/test_general/hard/bridgedma/common-Makefile6
-rw-r--r--cesar/test_general/hard/bridgedma/src/bridgedma-crc.c7
-rw-r--r--cesar/test_general/hard/bridgedma/src/bridgedma-it.c2
-rw-r--r--cesar/test_general/hard/bridgedma/src/bridgedma-rx-one-frame.c45
-rw-r--r--cesar/test_general/hard/bridgedma/src/bridgedma-tx-one-frame.c2
-rw-r--r--cesar/test_general/hard/bridgedma/src/bridgedma-tx.c358
6 files changed, 375 insertions, 45 deletions
diff --git a/cesar/test_general/hard/bridgedma/common-Makefile b/cesar/test_general/hard/bridgedma/common-Makefile
index 2b469ca2f7..62d3707ade 100644
--- a/cesar/test_general/hard/bridgedma/common-Makefile
+++ b/cesar/test_general/hard/bridgedma/common-Makefile
@@ -3,7 +3,8 @@ BASE = ../../..
ECOS = y
TARGET_PROGRAMS = bridgedma_init bridgedma_it bridgedma_tx_one_frame \
- bridgedma_rx_one_frame bridgedma_crc
+ bridgedma_rx_one_frame bridgedma_crc \
+ bridgedma_tx
bridgedma_init_SOURCES = bridgedma_init.c
bridgedma_init_MODULES = lib hal/phy
@@ -20,6 +21,9 @@ bridgedma_rx_one_frame_MODULES = lib hal/phy
bridgedma_crc_SOURCES = bridgedma-crc.c
bridgedma_crc_MODULES = lib hal/phy
+bridgedma_tx_SOURCES = bridgedma-tx.c
+bridgedma_tx_MODULES = lib hal/phy
+
include $(BASE)/common/make/top.mk
all: $(TARGET_PROGRAMS:%=obj/$(VARIANT)/%.dis) $(TARGET_PROGRAMS:%=obj/$(VARIANT)/%.hex)
diff --git a/cesar/test_general/hard/bridgedma/src/bridgedma-crc.c b/cesar/test_general/hard/bridgedma/src/bridgedma-crc.c
index c31fe7a33c..85dadaaf9a 100644
--- a/cesar/test_general/hard/bridgedma/src/bridgedma-crc.c
+++ b/cesar/test_general/hard/bridgedma/src/bridgedma-crc.c
@@ -44,8 +44,13 @@ u8 my_test_thread_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];
static test_t test;
static phy_bridgedma_job_t job;
+#ifdef __sparc__
+static u8 frame_buffer [2048] __attribute__ ((section(".private")));
+#else
static u8 frame_buffer [2048];
-static uint it_recv = false;
+#endif
+
+static bool it_recv = false;
static pb_t *pb;
u32 enc_tab[256];
diff --git a/cesar/test_general/hard/bridgedma/src/bridgedma-it.c b/cesar/test_general/hard/bridgedma/src/bridgedma-it.c
index 0c53c75825..45ab0d31fc 100644
--- a/cesar/test_general/hard/bridgedma/src/bridgedma-it.c
+++ b/cesar/test_general/hard/bridgedma/src/bridgedma-it.c
@@ -38,7 +38,7 @@ cyg_handle_t my_test_thread_handle;
u8 my_test_thread_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];
static test_t test;
-static uint it_recv = false;
+static bool it_recv = false;
static phy_bridgedma_job_t job1;
static u8 frame_buffer [2048];
diff --git a/cesar/test_general/hard/bridgedma/src/bridgedma-rx-one-frame.c b/cesar/test_general/hard/bridgedma/src/bridgedma-rx-one-frame.c
index 3c083add4a..98fef67220 100644
--- a/cesar/test_general/hard/bridgedma/src/bridgedma-rx-one-frame.c
+++ b/cesar/test_general/hard/bridgedma/src/bridgedma-rx-one-frame.c
@@ -53,7 +53,7 @@ static u8 source_buffer[2048];
#endif
static phy_bridgedma_job_t *job;
-static uint it_recv;
+static bool it_recv;
static test_t test;
static pb_t *pb_first;
static pb_t *pb_last;
@@ -61,9 +61,6 @@ static uint mf_header1;
static uint mf_header2;
static u8 *error_addr;
-/* Used for the signal TAP. */
-static uint error_signal_tap;
-
/* Job configuration. */
static uint TEST_BRIDGEDMA_JOB_OFFSET;
static uint TEST_BRIDGEDMA_JOB_LENGTH;
@@ -89,7 +86,6 @@ bridgedma_test (void)
{
phy_bridgedma_t *bridgedma;
uint ats = 0x12345678;
- uint i;
uint frame_buffer_offset;
bitstream_t bitstream;
pb_t *pb_current;
@@ -134,11 +130,6 @@ bridgedma_test (void)
/* Reset the destination buffer. */
memset ((u8 *)frame_buffer, 0, 2048);
-// /* Fill the frame. */
-// for (i = 0; i < 2048; i++)
-// {
-// source_buffer [i] = (u8) i;
-// }
memset (source_buffer, 0xff, 2048);
bitstream_init (&bitstream, (u8 *) cmp_buffer, 2048, BITSTREAM_WRITE);
@@ -209,8 +200,6 @@ bridgedma_verify_reception (void)
bool result_t1 = false;
bool result_t2 = false;
test_case_begin (test, "RX - Frame reception");
- uint read_cmp_val;
- uint read_des_val;
test_begin (test, "It reception")
{
@@ -285,46 +274,20 @@ bridgedma_verify_reception (void)
diag_printf ("**************** END Debug *******************\n");
#endif
- /*
+
test_begin (test, "Verifying entry buffer with output buffer")
{
for (i = 0; i < job->data_len; i++)
test_fail_if (read_u8_from_word(cmp_buffer + i)
- != read_u8_from_word(job.data_addr + i),
+ != read_u8_from_word(job->data_addr + i),
"Wrong result on buffer at index : %d, value \
expected : %x, value read : %x\n", i,
read_u8_from_word(cmp_buffer + i),
- read_u8_from_word(job.data_addr + i));
+ read_u8_from_word(job->data_addr + i));
result_t2 = true;
}
test_end;
- if (!result_t2)
- {
-#ifdef __sparc__
- error_signal_tap = 0xDEADDEAD;
- abort();
-#endif
- }
- */
-
- for (i = 0; i < job->data_len; i++)
- {
- read_cmp_val = read_u8_from_word((u8 *) cmp_buffer + i);
- read_des_val = read_u8_from_word(job->data_addr + i);
-
- if (read_cmp_val != read_des_val)
- {
- error_signal_tap = 0xDEADDEAD;
- diag_printf ("Wrong data at : %p\n", job->data_addr + i);
- diag_printf ("Expected value : %x \t read : %x\n", read_cmp_val,
- read_des_val);
-#ifdef __sparc__
- abort();
-#endif
- }
- }
-
if (i < (uint) (job->data_len - 1))
{
diff --git a/cesar/test_general/hard/bridgedma/src/bridgedma-tx-one-frame.c b/cesar/test_general/hard/bridgedma/src/bridgedma-tx-one-frame.c
index 3c1dd97ed5..0959d4e1e4 100644
--- a/cesar/test_general/hard/bridgedma/src/bridgedma-tx-one-frame.c
+++ b/cesar/test_general/hard/bridgedma/src/bridgedma-tx-one-frame.c
@@ -40,7 +40,7 @@ cyg_handle_t my_test_thread_handle;
u8 my_test_thread_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];
static test_t test;
-static uint it_recv = false;
+static bool it_recv = false;
static phy_bridgedma_job_t job;
static u8 frame_buffer [2048];
diff --git a/cesar/test_general/hard/bridgedma/src/bridgedma-tx.c b/cesar/test_general/hard/bridgedma/src/bridgedma-tx.c
new file mode 100644
index 0000000000..3b52e97de3
--- /dev/null
+++ b/cesar/test_general/hard/bridgedma/src/bridgedma-tx.c
@@ -0,0 +1,358 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file test_general/hard/bridgedma/src/bridgedma-tx.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+
+#include <cyg/kernel/kapi.h>
+#include <cyg/hal/hal_arch.h>
+
+#include "common/defs/ethernet.h"
+
+#include "lib/test.h"
+#include "lib/list.h"
+#include "lib/read_word.h"
+#include "lib/bitstream.h"
+#include "mac/common/pb.h"
+
+#include "hal/phy/inc/bridgedma.h"
+#include "hal/phy/inc/bridgedma_regs.h"
+
+#include <string.h>
+#include <stdio.h>
+#include <cyg/infra/diag.h>
+#include "hal/arch/arch.h"
+
+#define TEST_BRIDGEDMA_PB_NB 5
+#define TEST_BRIDGEDMA_JOB_OFFSET 18
+
+cyg_thread my_test_thread;
+cyg_handle_t my_test_thread_handle;
+u8 my_test_thread_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+static test_t test;
+static bool it_recv = false;
+static uint it_nb = 0;
+
+static phy_bridgedma_job_t job1, job2, job3;
+static u8 frame_buffer [2048];
+
+/* WARNING: callback are not possible to test inside UNIT TEST */
+bool _bridgedma_segmentation_cb(void *data, u32 status)
+{
+ it_recv = true;
+ it_nb ++;
+ return true;
+}
+
+/* WARNING: callback are not possible to test inside UNIT TEST */
+void _bridgedma_deffered_cb(void *data)
+{
+}
+
+void bridgedma_segmentation_test_case(void)
+{
+ uint ats;
+ pb_t *pb_current, *pb_first, *pb_last;
+ phy_bridgedma_t *bridgedma_ctx;
+
+ test_case_begin(test, "segmentation");
+
+ pb_first = (pb_t*) blk_alloc_desc_range(TEST_BRIDGEDMA_PB_NB, (blk_t **) &pb_last);
+ pb_last->next = NULL;
+
+ pb_current = pb_first;
+ for (pb_current = pb_first; pb_current; pb_current = pb_current->next)
+ {
+ /* Reset the PBs. */
+ memset (pb_current->data, 0, BLK_SIZE);
+ }
+
+ ats = 0x12345678;
+
+ memset(&job1, '\0', sizeof(job1));
+ job1.next = &job2;
+ job1.data_addr = frame_buffer;
+ job1.header_len = 6;
+ job1.data_len = 1490;
+ job1.first_pb_desc = (blk_t *)pb_first;
+ job1.first_pb_offset = TEST_BRIDGEDMA_JOB_OFFSET;
+ job1.segment_len = 512;
+ job1.direction = 0;
+ job1.crc_reset = 1;
+ job1.crc_store = 1;
+ job1.append_zero = 1;
+ job1.job_it = 1;
+ job1.eth_buffer_mask = 0x0;
+ /* Payload + ATS */
+ job1.mf_header1 = (((job1.data_len + 4 - 1) << 2) | 0x02) | (ats << 16);
+ job1.mf_header2 = (ats >> 16);
+
+ memset(&job2, '\0', sizeof(job2));
+ job2.next = &job3;
+ job2.data_addr = frame_buffer;
+ job2.header_len = 6;
+ job2.data_len = 390;
+ job2.first_pb_desc = (blk_t *)pb_first->next->next;
+ job2.first_pb_offset = 494;
+ job2.segment_len = 512;
+ job2.direction = 0;
+ job2.crc_reset = 1;
+ job2.crc_store = 1;
+ job2.append_zero = 1;
+ job2.job_it = 1;
+ job2.eth_buffer_mask = 0x0;
+ /* Payload + ATS */
+ job2.mf_header1 = (((job2.data_len + 4 - 1) << 2) | 0x02) | (ats << 16);
+ job2.mf_header2 = (ats >> 16);
+
+ memset(&job3, '\0', sizeof(job3));
+ job3.next = NULL;
+ job3.data_addr = frame_buffer;
+ job3.header_len = 6;
+ job3.data_len = 290;
+ job3.first_pb_desc = (blk_t *)pb_first->next->next->next;
+ job3.first_pb_offset = 382;
+ job3.segment_len = 512;
+ job3.direction = 0;
+ job3.crc_reset = 1;
+ job3.crc_store = 1;
+ job3.append_zero = 1;
+ job3.job_it = 1;
+ job3.eth_buffer_mask = 0x0;
+ /* Payload + ATS */
+ job3.mf_header1 = (((job3.data_len + 4 - 1) << 2) | 0x02) | (ats << 16);
+ job3.mf_header2 = (ats >> 16);
+
+ /* Initialise the frame buffer. */
+ memset (frame_buffer, 0xFF, 2048);
+
+ bridgedma_ctx = phy_bridgedma_init(NULL, _bridgedma_segmentation_cb,
+ _bridgedma_deffered_cb);
+
+ cyg_thread_delay (1);
+
+ phy_bridgedma_start (bridgedma_ctx, &job1, &job3);
+}
+
+void
+bridgedma_segmentation_verify_test_case (void)
+{
+ uint payload_cnt;
+ pb_t *pb_current;
+ pb_t *pb_first;
+ pb_t *pb_last;
+ crc_t crc_ctx;
+ u32 enc_tab[256];
+ uint crc;
+ uint crc_in_pb;
+
+ uint length;
+ uint pb_offset;
+ uint frame_offset;
+ uint i;
+
+ test_begin (test, "It reception")
+ {
+ test_fail_if (it_recv == false);
+ }
+ test_end;
+
+ test_begin(test, "segmentation of a frame")
+ {
+ /* check pb content */
+ /* check 1st mac frame into PB */
+ payload_cnt = 0;
+
+ /********************* First Frame *********************/
+ pb_offset = TEST_BRIDGEDMA_JOB_OFFSET;
+ frame_offset = 0;
+ pb_current = (pb_t *) job1.first_pb_desc;
+
+ length = 1 + (read_u16_from_word (pb_current->data + pb_offset) >> 2);
+
+ // To get the payload length, the frame length is 10
+ // bytes greater.
+ length -= 4;
+
+ test_fail_unless (length == job1.data_len, "Data length is wrong.");
+
+ payload_cnt = TEST_BRIDGEDMA_JOB_OFFSET + job1.header_len;
+
+ for (i = 0; i < BLK_SIZE - payload_cnt; i++)
+ test_fail_if (0xFF !=
+ read_u8_from_word(pb_current->data + i + payload_cnt));
+
+ pb_current = pb_current->next;
+ payload_cnt = BLK_SIZE - payload_cnt;
+
+ for (i = 0; i < BLK_SIZE; i++)
+ test_fail_if (0xFF !=
+ read_u8_from_word(pb_current->data + i));
+
+
+ pb_current = pb_current->next;
+ for (i = 0; i < 490; i++)
+ test_fail_if ( 0xFF !=
+ read_u8_from_word(pb_current->data + i));
+
+ /********************* Second Frame *********************/
+ pb_offset = 494;
+ frame_offset = 0;
+ pb_current = (pb_t *) job2.first_pb_desc;
+
+ length = 1 + (read_u16_from_word (pb_current->data + pb_offset) >> 2);
+
+ // To get the payload length, the frame length is 10
+ // bytes greater.
+ length -= 4;
+
+ test_fail_unless (length == job2.data_len, "Data length is wrong.");
+
+ payload_cnt = pb_offset + job2.header_len;
+
+ for (i = 0; i < BLK_SIZE - payload_cnt; i++)
+ test_fail_if ( 0xFF !=
+ read_u8_from_word(pb_current->data + i + payload_cnt));
+
+ pb_current = pb_current->next;
+ for (i = 0; i < 378; i++)
+ test_fail_if ( 0xFF !=
+ read_u8_from_word(pb_current->data + i));
+
+ /********************* Third Frame *********************/
+ pb_offset = 382;
+ frame_offset = 0;
+ pb_current = (pb_t *) job3.first_pb_desc;
+
+ length = 1 + (read_u16_from_word (pb_current->data + pb_offset) >> 2);
+
+ // To get the payload length, the frame length is 10
+ // bytes greater.
+ length -= 4;
+
+ test_fail_unless (length == job3.data_len, "Data length is wrong.");
+
+ payload_cnt = pb_offset + job3.header_len;
+
+ for (i = 0; i < BLK_SIZE - payload_cnt; i++)
+ test_fail_if ( 0xFF !=
+ read_u8_from_word(pb_current->data + i + payload_cnt));
+
+ pb_current = pb_current->next;
+
+ for (i = 0; i < 166; i++)
+ test_fail_if ( 0xFF !=
+ read_u8_from_word(pb_current->data + i));
+ }
+ test_end;
+
+ /* Test the CRC computation. */
+ 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);
+
+ test_case_begin (test, "Verifying the CRC");
+
+ test_begin (test, "First frame")
+ {
+ pb_current = (pb_t *) job1.first_pb_desc;
+ crc = bridgedma_crc_compute_block (&crc_ctx, frame_buffer, job1.data_len);
+ crc_in_pb = read_u32_from_word (pb_current->next->next->data + 490);
+
+ test_fail_if (crc != crc_in_pb);
+ }
+ test_end;
+
+ test_begin (test, "Second Frame")
+ {
+ pb_current = (pb_t *) job2.first_pb_desc;
+ crc = bridgedma_crc_compute_block (&crc_ctx, frame_buffer, job2.data_len);
+ crc_in_pb = read_u32_from_word (pb_current->next->data + 378);
+
+ test_fail_if (crc != crc_in_pb);
+ }
+ test_end;
+
+ test_begin (test, "Third Frame")
+ {
+ pb_current = (pb_t *) job3.first_pb_desc;
+ crc = bridgedma_crc_compute_block (&crc_ctx, frame_buffer, job3.data_len);
+ crc_in_pb = read_u32_from_word (pb_current->next->data + 166);
+
+ test_fail_if (crc != crc_in_pb);
+ }
+ test_end;
+
+ pb_first = (pb_t *) job1.first_pb_desc;
+ for (pb_current = pb_first ; pb_current;
+ pb_current = pb_current->next)
+ {
+ pb_last = pb_current;
+ }
+
+ blk_release_desc_range((blk_t *)pb_first, (blk_t *) pb_last);
+}
+
+
+void
+test_thread_process (cyg_addrword_t data)
+{
+ bridgedma_segmentation_test_case ();
+
+ /* Wait the three interruptions. */
+ while (it_nb != 3)
+ {
+ cyg_thread_delay (1);
+ diag_printf ("Waiting interruption. (it recv : %d\n", it_nb);
+ }
+
+ bridgedma_segmentation_verify_test_case ();
+
+ test_result (test);
+
+#ifndef __sparc__
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+#endif
+}
+
+int
+main (void)
+{
+ uint i;
+
+ test_init (test, 0, NULL);
+
+ for (i = 0; i < 2048; i++)
+ frame_buffer[i] = i;
+
+ // Create the thread.
+ cyg_thread_create( 9,
+ &test_thread_process,
+ (cyg_addrword_t) &test,
+ "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;
+}