summaryrefslogtreecommitdiff
path: root/cesar/mac/sar
diff options
context:
space:
mode:
authorlaranjeiro2009-12-14 10:05:03 +0000
committerlaranjeiro2009-12-14 10:05:03 +0000
commit8297b0919aab51e07d35a46f8feda481c74502fa (patch)
tree98efbf72c2ca5659d911b990af3ba864bd797a0c /cesar/mac/sar
parent4a99648b17caa0012eb187b9681d596b9e246be2 (diff)
cesar/{hal/phy,mac/sar}: merge all bridgedma simulation code, closes #855
* remove bridgedma_soft, maximus_bridgedma. * add hal/phy/soft/bridge to use in unit test and maximus. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@6543 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/mac/sar')
-rw-r--r--cesar/mac/sar/bridgedma/Module1
-rw-r--r--cesar/mac/sar/bridgedma/inc/bridge.h58
-rw-r--r--cesar/mac/sar/bridgedma/src/bridge.c258
-rw-r--r--cesar/mac/sar/inc/sar_context.h3
-rw-r--r--cesar/mac/sar/inc/sar_job_mfs.h5
-rw-r--r--cesar/mac/sar/src/bridge_dma.c1
-rw-r--r--cesar/mac/sar/test/functional/Makefile2
-rw-r--r--cesar/mac/sar/test/functional/Makefile.mk16
-rw-r--r--cesar/mac/sar/test/functional/host-Config1
-rw-r--r--cesar/mac/sar/test/functional/host-Makefile3
-rw-r--r--cesar/mac/sar/test/functional/sparc-Makefile2
-rw-r--r--cesar/mac/sar/test/functional/src/sar_rx.c3
-rw-r--r--cesar/mac/sar/test/functional/src/sar_tx.c3
-rw-r--r--cesar/mac/sar/test/functional/src/test_functions.c2
-rw-r--r--cesar/mac/sar/test/functional/test_functions.h1
-rw-r--r--cesar/mac/sar/test/unit_test/ecos/Makefile4
-rw-r--r--cesar/mac/sar/test/unit_test/ecos/src/reassembly.c5
-rw-r--r--cesar/mac/sar/test/unit_test/ecos/src/tests.c51
-rw-r--r--cesar/mac/sar/test/unit_test/ecos/tests.h26
19 files changed, 101 insertions, 344 deletions
diff --git a/cesar/mac/sar/bridgedma/Module b/cesar/mac/sar/bridgedma/Module
deleted file mode 100644
index dc07b476c1..0000000000
--- a/cesar/mac/sar/bridgedma/Module
+++ /dev/null
@@ -1 +0,0 @@
-SOURCES := bridge.c \ No newline at end of file
diff --git a/cesar/mac/sar/bridgedma/inc/bridge.h b/cesar/mac/sar/bridgedma/inc/bridge.h
deleted file mode 100644
index 7f60c252aa..0000000000
--- a/cesar/mac/sar/bridgedma/inc/bridge.h
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef BRIDGE_H_
-#define BRIDGE_H_
-
-#include <cyg/kernel/kapi.h>
-#include <cyg/hal/hal_arch.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "lib/rnd.h"
-
-#include "mac/pbproc/pbproc.h"
-
-#include "hal/phy/bridgedma.h"
-#include "mac/sar/sar_mf.h"
-
-struct bridge_dma_test_t
-{
- phy_bridgedma_job_t *head;
- phy_bridgedma_job_t *tail;
-
- phy_deferred_cb_t deferred_cb;
- void *user_data;
-
- phy_bridgedma_job_t *curr;
-};
-typedef struct bridge_dma_test_t bridge_dma_test_t;
-
-
-struct pb_bridged_list_t
-{
- pb_t *first;
- pb_t *last;
-};
-typedef struct pb_bridged_list_t pb_bridged_list_t;
-
-phy_bridgedma_t *
-phy_bridgedma_init (void *user_data, phy_bridgedma_cb_t bridgedma_cb,
- phy_deferred_cb_t deferred_cb);
-
-void phy_bridgedma_start (phy_bridgedma_t *ctx,
- phy_bridgedma_job_t *job_first, phy_bridgedma_job_t *job_last);
-
-/**
- * Reset and uninitialise the Bridge DMA.
- * \param ctx Bridge DMA context
- */
-void
-phy_bridgedma_uninit (phy_bridgedma_t *ctx);
-
-void bridge_run (void);
-
-u16 mix_up_pbs (pb_t **first, pb_t **last);
-
-bridge_dma_test_t bridge;
-pb_bridged_list_t pb_list;
-
-#endif /*BRIDGE_H_*/
diff --git a/cesar/mac/sar/bridgedma/src/bridge.c b/cesar/mac/sar/bridgedma/src/bridge.c
deleted file mode 100644
index b0fb30b368..0000000000
--- a/cesar/mac/sar/bridgedma/src/bridge.c
+++ /dev/null
@@ -1,258 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2009 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cesar/mac/sar/bridgedma/src/bridge.c
- * \brief bridgedma functionalities for unit tests.
- * \ingroup mac_sar
- */
-#include "common/std.h"
-#include "common/defs/homeplugAV.h"
-#include "mac/sar/bridgedma/inc/bridge.h"
-#include "lib/bitstream.h"
-#include "lib/crc.h"
-#include "hal/phy/inc/bridgedma_soft.h"
-
-phy_bridgedma_t *phy_bridgedma_init (void *user_data,
- phy_bridgedma_cb_t bridgedma_cb, phy_deferred_cb_t deferred_cb)
-{
- bridge.deferred_cb = deferred_cb;
- bridge.user_data = user_data;
-
- bridge.head = NULL;
- bridge.tail = NULL;
- bridge.curr = NULL;
-
- pb_list.first = NULL;
- pb_list.last = NULL;
-
- return NULL;
-}
-
-void phy_bridgedma_start (phy_bridgedma_t *ctx,
- phy_bridgedma_job_t *job_first, phy_bridgedma_job_t *job_last)
-{
- if (bridge.head == NULL)
- {
- bridge.head = job_first;
- bridge.tail = job_last;
-
- bridge.curr = job_first;
- }
- else
- {
- bridge.tail->next = job_first;
- bridge.tail = job_last;
- }
-
- job_last->next = NULL;
- bridge_run ();
-}
-
-static void
-phy_bridgedma_change_pb (bitstream_t *stream, void *user_data)
-{
- pb_t **pb = user_data;
- dbg_assert (stream);
- dbg_assert (user_data);
- dbg_assert ((*pb)->next);
- *pb = (*pb)->next;
- bitstream_set_buffer (stream, (*pb)->data, BLK_SIZE);
-}
-
-void bridge_run (void)
-{
- phy_bridgedma_job_t *bridge_job;
-
- while (bridge.curr)
- {
- bridge_job = bridge.curr;
- dbg_assert (bridge_job->first_pb_offset < BLK_SIZE);
-
- /* TX part. */
- if (bridge_job->direction == 0)
- {
- pb_t *current = (pb_t*)bridge_job->first_pb_desc;
- bitstream_t stream;
- uint i;
- /* Store the header of the mac frame in the PB. */
- bitstream_write_init (&stream,
- current->data + bridge_job->first_pb_offset,
- BLK_SIZE - bridge_job->first_pb_offset);
- bitstream_init_buffer_cb (&stream, phy_bridgedma_change_pb,
- &current);
-
- if (bridge_job->header_len == 2)
- bitstream_write (&stream, bridge_job->mf_header1, 16);
- else
- {
- bitstream_write (&stream, bridge_job->mf_header1, 32);
- bitstream_write (&stream, bridge_job->mf_header2, 16);
- }
-
- for (i = 0; i < bridge_job->data_len; i++)
- bitstream_write (&stream, bridge_job->data_addr[i], 8);
-
- /* Compute the CRC and store it. */
- crc_t crc_ctx;
- u32 enc_tab[256];
- u32 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);
-
- crc = crc_compute_begin (&crc_ctx);
- crc = bridgedma_crc_compute_continue_block (&crc_ctx, crc,
- bridge_job->data_addr,
- bridge_job->data_len);
- crc = crc_compute_end (&crc_ctx, crc);
- bitstream_write (&stream, crc, 32);
- }
- /* RX part. */
- else
- {
- pb_t *current = (pb_t*)bridge_job->first_pb_desc;
- bitstream_t stream;
- uint i;
- uint header1;
- uint header2 = 0;
- /* Read the data from the PB. */
- bitstream_read_init (&stream,
- current->data,
- BLK_SIZE - bridge_job->first_pb_offset);
- bitstream_init_buffer_cb (&stream, phy_bridgedma_change_pb,
- &current);
-
- if (bridge_job->header_len == 2)
- header1 = bitstream_read (&stream, 16);
- else
- {
- header1 = bitstream_read (&stream, 32);
- header2 = bitstream_read (&stream, 16);
- }
-
- for (i = 0; i < bridge_job->data_len; i++)
- bridge_job->data_addr[i] = bitstream_read (&stream, 8);
-
- /* Compute the CRC and store it. */
- crc_t crc_ctx;
- u32 enc_tab[256];
- u32 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);
-
- crc = crc_compute_begin (&crc_ctx);
- crc = bridgedma_crc_compute_continue_block (&crc_ctx, crc,
- bridge_job->data_addr,
- bridge_job->data_len);
- crc = crc_compute_end (&crc_ctx, crc);
- if (crc == bitstream_read (&stream, 32))
- bridge_job->crc_error = 1;
- }
-
- bridge.curr = bridge.head->next;
- if (bridge.head)
- {
- bridge.head = bridge.head->next;
- }
-
- if (bridge_job->job_it)
- (*bridge.deferred_cb) (bridge.user_data);
- }
-}
-
-u16 mix_up_pbs (pb_t **first, pb_t **last)
-{
- pb_t *list[100];
- u16 size;
- pb_t *head;
- pb_t *tmp;
- lib_rnd_t rnd_ctx1;
- lib_rnd_t rnd_ctx2;
- int i;
- u16 slot1;
- u16 slot2;
-
- lib_rnd_init (&rnd_ctx1, 123456);
- lib_rnd_init (&rnd_ctx2, 234567);
-
- //count the quantity of PBs.
- for (size = 0, head = pb_list.first; head != NULL; head = head->next,
- size++)
- {
- list[size] = head;
- }
- list[size] = NULL;
-
- // randomize the list
- for (i = 0; i < size; i++)
- {
- slot1 = lib_rnd32 (&rnd_ctx1) % size;
- slot2 = lib_rnd32 (&rnd_ctx2) % size;
-
- tmp = list[slot1];
- list[slot1] = list[slot2];
- list[slot2] = tmp;
- }
-
- //Chain the PB list
- for (i = 0; i < size - 1; i++)
- {
- list[i]->next = list[i+1];
- }
-
- *first = list[0];
- *last = list[size - 1];
- list[size - 1]->next = NULL;
-
- return size;
-}
-
-/**
- * Reset and uninitialise the Bridge DMA.
- * \param ctx Bridge DMA context
- */
-void
-phy_bridgedma_uninit (phy_bridgedma_t *ctx)
-{
-}
-
-/**
- * Get the current job descriptor from the bridgedma.
- * \param ctx the Bridge DMA context.
- * \return the address of the current job descriptor beeing processed by the
- * bridge DMA.
- *
- * It corresponds to the current job which is being processed by the
- * bridgedma when the Interruption arrived.
- */
-phy_bridgedma_job_t *
-phy_bridgedma_current_job (phy_bridgedma_t *ctx)
-{
- return bridge.head;
-}
-
-bool
-phy_bridgedma_status (phy_bridgedma_t *ctx)
-{
- return false;
-}
diff --git a/cesar/mac/sar/inc/sar_context.h b/cesar/mac/sar/inc/sar_context.h
index 92336ec2da..669445f939 100644
--- a/cesar/mac/sar/inc/sar_context.h
+++ b/cesar/mac/sar/inc/sar_context.h
@@ -23,9 +23,6 @@
#include "hal/phy/forward.h"
#include "hal/phy/maximus/inc/maximus_interrupts.h"
#include "hal/phy/maximus/inc/maximus_phy_ctx.h"
-#include "hal/phy/maximus/inc/maximus_bridgedma_ctx.h"
-#else
-#include "mac/sar/bridgedma/inc/bridge.h"
#endif
#include "mac/sar/sar_mf.h"
diff --git a/cesar/mac/sar/inc/sar_job_mfs.h b/cesar/mac/sar/inc/sar_job_mfs.h
index c011fc67a0..31862fdf72 100644
--- a/cesar/mac/sar/inc/sar_job_mfs.h
+++ b/cesar/mac/sar/inc/sar_job_mfs.h
@@ -16,12 +16,7 @@
#include "mac/pbproc/pbproc.h"
#include "mac/common/mfs.h"
-
-#ifndef STATION_H_
#include "hal/phy/bridgedma.h"
-#else
-#include "mac/sar/bridgedma/inc/bridge.h"
-#endif
struct sar_job_mfs_t
{
diff --git a/cesar/mac/sar/src/bridge_dma.c b/cesar/mac/sar/src/bridge_dma.c
index 6073de9c0e..78a023a6ac 100644
--- a/cesar/mac/sar/src/bridge_dma.c
+++ b/cesar/mac/sar/src/bridge_dma.c
@@ -12,6 +12,7 @@
*/
#include "common/std.h"
+#include "hal/phy/bridgedma.h"
#include "mac/sar/inc/bridge_dma.h"
void
diff --git a/cesar/mac/sar/test/functional/Makefile b/cesar/mac/sar/test/functional/Makefile
index 127ceb385c..adfb3e3b5f 100644
--- a/cesar/mac/sar/test/functional/Makefile
+++ b/cesar/mac/sar/test/functional/Makefile
@@ -3,7 +3,7 @@ all: sparc host
sparc: sparc-Makefile
make -f sparc-Makefile
-host: host-Makefile host-Config
+host: host-Makefile
make -f host-Makefile
clean: sparc-Makefile host-Makefile
diff --git a/cesar/mac/sar/test/functional/Makefile.mk b/cesar/mac/sar/test/functional/Makefile.mk
index ec08ea6230..9a1ac2608c 100644
--- a/cesar/mac/sar/test/functional/Makefile.mk
+++ b/cesar/mac/sar/test/functional/Makefile.mk
@@ -3,41 +3,41 @@ TARGET_PROGRAMS = sar_rx sar_tx sar_rx_perf sar_rx_perf_huge_mpdu \
sar_tx_rx sar_rx_tx
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 \
+sar_rx_MODULES = hal/arch lib mac/common mac/sar mac/pbproc \
$(HOST_MODULES) $(SPARC_MODULES)
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_tx_MODULES = hal/arch lib mac/common mac/sar mac/pbproc \
$(HOST_MODULES) $(SPARC_MODULES)
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_MODULES = hal/arch lib mac/common mac/sar mac/pbproc \
$(HOST_MODULES) $(SPARC_MODULES)
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 \
+sar_rx_perf_huge_mpdu_MODULES = hal/arch lib mac/common mac/sar \
mac/pbproc \
$(HOST_MODULES) $(SPARC_MODULES)
sar_rx_perf_huge_mpdu_1518_SOURCES = sar_rx_perf_huge_mpdu_1518.c \
pbproc_stub.c ca_stub.c test_functions.c
-sar_rx_perf_huge_mpdu_1518_MODULES = hal/arch hal/phy lib mac/common mac/sar \
+sar_rx_perf_huge_mpdu_1518_MODULES = hal/arch lib mac/common mac/sar \
mac/pbproc \
$(HOST_MODULES) $(SPARC_MODULES)
sar_tx_perf_SOURCES = sar_tx_perf.c pbproc_stub.c ca_stub.c test_functions.c
-sar_tx_perf_MODULES = hal/arch hal/phy lib mac/common mac/sar mac/pbproc \
+sar_tx_perf_MODULES = hal/arch lib mac/common mac/sar mac/pbproc \
$(HOST_MODULES) $(SPARC_MODULES)
sar_tx_rx_SOURCES = sar_tx_rx.c pbproc_stub.c ca_stub.c \
test_functions.c
-sar_tx_rx_MODULES = hal/arch hal/phy lib mac/common mac/sar mac/pbproc \
+sar_tx_rx_MODULES = hal/arch lib mac/common mac/sar mac/pbproc \
$(HOST_MODULES) $(SPARC_MODULES)
sar_rx_tx_SOURCES = sar_rx_tx.c pbproc_stub.c ca_stub.c \
test_functions.c
-sar_rx_tx_MODULES = hal/arch hal/phy lib mac/common mac/sar mac/pbproc \
+sar_rx_tx_MODULES = hal/arch lib mac/common mac/sar mac/pbproc \
$(HOST_MODULES) $(SPARC_MODULES)
mac_pbproc_MODULE_SOURCES = mfs.c
diff --git a/cesar/mac/sar/test/functional/host-Config b/cesar/mac/sar/test/functional/host-Config
deleted file mode 100644
index e056cc06de..0000000000
--- a/cesar/mac/sar/test/functional/host-Config
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_BRIDGEDMA_SOFT=y
diff --git a/cesar/mac/sar/test/functional/host-Makefile b/cesar/mac/sar/test/functional/host-Makefile
index d562313914..0fc1f21396 100644
--- a/cesar/mac/sar/test/functional/host-Makefile
+++ b/cesar/mac/sar/test/functional/host-Makefile
@@ -3,8 +3,7 @@ BASE = ../../../..
ECOS = y
VARIANT= host
-HOST_MODULES=
-hal_phy_MODULE_SOURCES=bridgedma_soft.c
+HOST_MODULES=hal/phy/soft/bridgedma
include Makefile.mk
include $(BASE)/common/make/top.mk
diff --git a/cesar/mac/sar/test/functional/sparc-Makefile b/cesar/mac/sar/test/functional/sparc-Makefile
index 5843989633..b7ecbb98e9 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
-SPARC_MODULES=hal/trace
+SPARC_MODULES=hal/trace hal/phy
include Makefile.mk
include $(BASE)/common/make/top.mk
diff --git a/cesar/mac/sar/test/functional/src/sar_rx.c b/cesar/mac/sar/test/functional/src/sar_rx.c
index 883ad833c4..b8ff50bdfd 100644
--- a/cesar/mac/sar/test/functional/src/sar_rx.c
+++ b/cesar/mac/sar/test/functional/src/sar_rx.c
@@ -30,7 +30,8 @@
#include "mac/sar/sar.h"
#include "hal/arch/arch.h"
-#include "hal/phy/inc/bridgedma_soft.h"
+#include "hal/phy/bridgedma.h"
+#include "hal/phy/soft/bridgedma/inc/bridgedma.h"
/* Variables needed by the test. */
#ifdef __sparc__
diff --git a/cesar/mac/sar/test/functional/src/sar_tx.c b/cesar/mac/sar/test/functional/src/sar_tx.c
index 9a61ba2c25..0c4d7c5e16 100644
--- a/cesar/mac/sar/test/functional/src/sar_tx.c
+++ b/cesar/mac/sar/test/functional/src/sar_tx.c
@@ -31,9 +31,10 @@
#include "mac/pbproc/pbproc.h"
#include "mac/sar/sar.h"
-#include "hal/phy/inc/bridgedma_soft.h"
+#include "hal/phy/bridgedma.h"
#include "mac/sar/inc/sar_context.h"
+#include "hal/phy/soft/bridgedma/inc/bridgedma.h"
/* Variables needed by the test. */
#ifdef __sparc__
diff --git a/cesar/mac/sar/test/functional/src/test_functions.c b/cesar/mac/sar/test/functional/src/test_functions.c
index 7bd89584de..b56d98c8b1 100644
--- a/cesar/mac/sar/test/functional/src/test_functions.c
+++ b/cesar/mac/sar/test/functional/src/test_functions.c
@@ -25,7 +25,7 @@
#include "hal/arch/arch.h"
#include "hal/trace/trace.h"
-#include "hal/phy/inc/bridgedma_soft.h"
+#include "hal/phy/bridgedma.h"
#include <cyg/kernel/kapi.h>
#include <cyg/hal/hal_arch.h>
diff --git a/cesar/mac/sar/test/functional/test_functions.h b/cesar/mac/sar/test/functional/test_functions.h
index f1eb3a996d..856dca1187 100644
--- a/cesar/mac/sar/test/functional/test_functions.h
+++ b/cesar/mac/sar/test/functional/test_functions.h
@@ -13,6 +13,7 @@
* \ingroup mac_sar
*/
#include "mac/sar/sar.h"
+#include "hal/phy/soft/bridgedma/inc/bridgedma.h"
struct sar_test_ctx_t
{
diff --git a/cesar/mac/sar/test/unit_test/ecos/Makefile b/cesar/mac/sar/test/unit_test/ecos/Makefile
index 4a32c49034..2474feb0c9 100644
--- a/cesar/mac/sar/test/unit_test/ecos/Makefile
+++ b/cesar/mac/sar/test/unit_test/ecos/Makefile
@@ -12,8 +12,8 @@ sar_SOURCES = sar.c activate.c sar_work_get.c mfs_ssn_resize.c \
reassembly_measurement.c expiration.c sar_call_back_ul.c \
msdu_timeout.c sar_remove_sta.c segmentation.c detect_mf.c \
get_associated_mfs.c sar_tx_job_desc_create.c \
- ca_stub.c pbproc_stub.c
-sar_MODULES = lib mac/sar mac/common mac/pbproc mac/sar/bridgedma \
+ ca_stub.c pbproc_stub.c tests.c
+sar_MODULES = lib mac/sar mac/common mac/pbproc hal/phy/soft/bridgedma \
mac/sar/test/unit_test/ecos/override/ce/rx
mac_pbproc_MODULE_SOURCES = mfs.c
diff --git a/cesar/mac/sar/test/unit_test/ecos/src/reassembly.c b/cesar/mac/sar/test/unit_test/ecos/src/reassembly.c
index 16fd9b5c5f..85ad614f48 100644
--- a/cesar/mac/sar/test/unit_test/ecos/src/reassembly.c
+++ b/cesar/mac/sar/test/unit_test/ecos/src/reassembly.c
@@ -33,6 +33,9 @@
#include "ce/rx/rx.h"
#include <string.h>
+#include "mac/sar/test/unit_test/ecos/tests.h"
+#include <stdio.h>
+
bool
sar_bridge_dma_interruption (void *user, u32 status_word);
@@ -1225,7 +1228,7 @@ test_case_reassembly (test_t test)
for (j = 0; j < 60 / 4; j++)
bitstream_write (&stream, 0, 32);
/* CRC. */
- bitstream_write (&stream, 0, 32);
+ bitstream_write (&stream, sar_test_compute_frame_crc (60, 0), 32);
/* If the Frame does not ends at the end of the first PB then
* write the none MF after the CRC. */
diff --git a/cesar/mac/sar/test/unit_test/ecos/src/tests.c b/cesar/mac/sar/test/unit_test/ecos/src/tests.c
new file mode 100644
index 0000000000..0b6a8a387a
--- /dev/null
+++ b/cesar/mac/sar/test/unit_test/ecos/src/tests.c
@@ -0,0 +1,51 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/sar/test/unit_test/ecos/src/tests.c
+ * \brief Library for the unit tests.
+ * \ingroup mac_sar
+ *
+ */
+#include "common/std.h"
+#include "common/defs/homeplugAV.h"
+#include "common/defs/ethernet.h"
+#include "lib/crc.h"
+#include "string.h"
+
+static inline u32
+sar_test_compute_crc (u8 *buffer, uint length)
+{
+ crc_t crc_ctx;
+ u32 crc;
+ u32 enc_tab[256];
+
+ /* 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);
+
+ crc = crc_compute_begin (&crc_ctx);
+ crc = crc_compute_continue_block (&crc_ctx, crc, buffer, length);
+ crc = crc_compute_end (&crc_ctx, crc);
+
+ return crc;
+}
+
+u32
+sar_test_compute_frame_crc (uint length, uint data_inside)
+{
+ u8 buffer[ETH_PACKET_MAX_SIZE];
+ memset (buffer, data_inside, length);
+ return sar_test_compute_crc (buffer, length);
+}
diff --git a/cesar/mac/sar/test/unit_test/ecos/tests.h b/cesar/mac/sar/test/unit_test/ecos/tests.h
new file mode 100644
index 0000000000..0b758d9cad
--- /dev/null
+++ b/cesar/mac/sar/test/unit_test/ecos/tests.h
@@ -0,0 +1,26 @@
+#ifndef mac_sar_test_unit_test_ecos_tests_h
+#define mac_sar_test_unit_test_ecos_tests_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/sar/test/unit_test/ecos/tests.h
+ * \brief Library tests
+ * \ingroup mac_sar
+ */
+
+/**
+ * Compute the CRC of a frame containing the same symbol inside.
+ * \param length the frame length.
+ * \param data_inside the symbol inside the frame.
+ *
+ * Only for non ATS frames.
+ */
+u32
+sar_test_compute_frame_crc (uint length, uint data_inside);
+
+#endif /* mac_sar_test_unit_test_ecos_tests_h */