summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorlaranjeiro2009-12-14 10:05:03 +0000
committerlaranjeiro2009-12-14 10:05:03 +0000
commit8297b0919aab51e07d35a46f8feda481c74502fa (patch)
tree98efbf72c2ca5659d911b990af3ba864bd797a0c /cesar
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')
-rw-r--r--cesar/cl/test/functional/host-Config1
-rw-r--r--cesar/cl/test/functional/host-Makefile4
-rw-r--r--cesar/cl/test/functional/sparc-Config1
-rw-r--r--cesar/cl/test/functional/sparc-Makefile7
-rw-r--r--cesar/common/tests/tests7
-rw-r--r--cesar/hal/Module3
-rw-r--r--cesar/hal/phy/Config1
-rw-r--r--cesar/hal/phy/Module8
-rw-r--r--cesar/hal/phy/inc/bridgedma.h14
-rw-r--r--cesar/hal/phy/inc/bridgedma_common.h31
-rw-r--r--cesar/hal/phy/inc/bridgedma_soft.h125
-rw-r--r--cesar/hal/phy/maximus/Module2
-rw-r--r--cesar/hal/phy/maximus/inc/maximus_bridgedma_ctx.h64
-rw-r--r--cesar/hal/phy/maximus/src/maximus_bridgedma.c411
-rw-r--r--cesar/hal/phy/soft/bridgedma/Module1
-rw-r--r--cesar/hal/phy/soft/bridgedma/bridgedma_crc.h25
-rw-r--r--cesar/hal/phy/soft/bridgedma/inc/bridgedma.h42
-rw-r--r--cesar/hal/phy/soft/bridgedma/src/bridgedma.c375
-rw-r--r--cesar/hal/phy/src/bridgedma.c53
-rw-r--r--cesar/hal/phy/src/bridgedma_soft.c477
-rw-r--r--cesar/hal/phy/test/bridgedma-soft/Makefile13
-rw-r--r--cesar/hal/phy/test/bridgedma-soft/sparc-Config1
-rw-r--r--cesar/hal/phy/test/bridgedma-soft/sparc-Makefile31
-rw-r--r--cesar/hal/phy/test/bridgedma-soft/sparc-ecos.ecc.sh5
-rw-r--r--cesar/hal/phy/test/bridgedma-soft/src/bridgedma-crc-test.c359
-rw-r--r--cesar/hal/phy/test/bridgedma-soft/src/bridgedma-init-test.c114
-rw-r--r--cesar/hal/phy/test/bridgedma-soft/src/bridgedma-rx-test.c310
-rw-r--r--cesar/hal/phy/test/bridgedma-soft/src/bridgedma-tx-test.c381
-rw-r--r--cesar/hal/phy/test/bridgedma-soft/src/data.c545
-rw-r--r--cesar/hal/phy/test/bridgedma-soft/src/test_bridgedma.c_old1003
-rw-r--r--cesar/hal/phy/test/bridgedma-soft/synth-Config1
-rw-r--r--cesar/hal/phy/test/bridgedma-soft/synth-Makefile26
-rw-r--r--cesar/hal/phy/test/bridgedma-soft/synth-ecos.ecc.sh5
-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
-rw-r--r--cesar/test_general/hard/bridgedma/Makefile.mk24
-rw-r--r--cesar/test_general/hard/bridgedma/host-Config1
-rw-r--r--cesar/test_general/hard/bridgedma/host-Makefile29
-rw-r--r--cesar/test_general/hard/bridgedma/sparc-Config1
-rw-r--r--cesar/test_general/hard/bridgedma/sparc-Makefile32
-rw-r--r--cesar/test_general/hard/bridgedma/src/bridgedma-crc.c3
-rw-r--r--cesar/test_general/hard/bridgedma/src/bridgedma-rx-one-frame.c68
-rw-r--r--cesar/test_general/hard/bridgedma/src/bridgedma-rx.c5
-rw-r--r--cesar/test_general/hard/bridgedma/src/bridgedma-tx-one-frame.c66
-rw-r--r--cesar/test_general/hard/bridgedma/src/bridgedma-tx.c4
-rw-r--r--cesar/test_general/hard/bridgedma/src/bridgedma_init.c13
63 files changed, 685 insertions, 4452 deletions
diff --git a/cesar/cl/test/functional/host-Config b/cesar/cl/test/functional/host-Config
deleted file mode 100644
index ddad644109..0000000000
--- a/cesar/cl/test/functional/host-Config
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_BRIDGEDMA_SOFT = y
diff --git a/cesar/cl/test/functional/host-Makefile b/cesar/cl/test/functional/host-Makefile
index 6103dde3f1..8368f15a8e 100644
--- a/cesar/cl/test/functional/host-Makefile
+++ b/cesar/cl/test/functional/host-Makefile
@@ -6,9 +6,7 @@ VARIANT= host
TARGET_PROGRAMS = cl
cl_SOURCES = cl.c
-cl_MODULES = lib cl mac/common hal/phy \
+cl_MODULES = lib cl mac/common \
mac/sar/stub
-hal_phy_MODULE_SOURCES=bridgedma_soft.c
-
include $(BASE)/common/make/top.mk
diff --git a/cesar/cl/test/functional/sparc-Config b/cesar/cl/test/functional/sparc-Config
deleted file mode 100644
index e7c19d2389..0000000000
--- a/cesar/cl/test/functional/sparc-Config
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_BRIDGEDMA_SOFT = n
diff --git a/cesar/cl/test/functional/sparc-Makefile b/cesar/cl/test/functional/sparc-Makefile
index 34c1413e7d..702c58fcce 100644
--- a/cesar/cl/test/functional/sparc-Makefile
+++ b/cesar/cl/test/functional/sparc-Makefile
@@ -8,11 +8,6 @@ TARGET_PROGRAMS = cl
cl_SOURCES = cl.c
cl_MODULES = lib cl mac/common hal \
- mac/sar/stub
+ mac/sar/stub
include $(BASE)/common/make/top.mk
-
-all: $(TARGET_PROGRAMS:%=obj/$(VARIANT)/%.dis)
-
-%.dis: %.elf
- $(CROSS_COMPILE)objdump -DSht $< > $@
diff --git a/cesar/common/tests/tests b/cesar/common/tests/tests
index 3a51689361..a968ba9589 100644
--- a/cesar/common/tests/tests
+++ b/cesar/common/tests/tests
@@ -320,13 +320,6 @@ interface/fcall/test:
make: make COV=y
./obj/test_interface_fcall
-hal/phy/test/bridgedma-soft:
-make: make synth
-bridgedma-proto: ./obj/synth/test-bridgedma-proto.elf
-bridgedma-tx: ./obj/synth/test-bridgedma-proto-tx.elf
-bridgedma-rx: ./obj/synth/test-bridgedma-proto-rx.elf
-bridgedma-crc: ./obj/synth/test-bridgedma-proto-crc.elf
-
cp/test/mme:
make: make COV=y host.all
cov test_mme: ./obj/test_mme
diff --git a/cesar/hal/Module b/cesar/hal/Module
index 04b7752c5e..78109585b7 100644
--- a/cesar/hal/Module
+++ b/cesar/hal/Module
@@ -1,6 +1,7 @@
ifneq ($(TARGET),sparc)
MODULES := hal/timer hal/watchdog \
- hal/phy/maximus hal/hle/maximus hal/leon/maximus
+ hal/phy/maximus hal/hle/maximus hal/leon/maximus \
+ hal/phy/soft/bridgedma
else
MODULES := hal/timer hal/watchdog hal/arch \
hal/phy hal/hle hal/leon
diff --git a/cesar/hal/phy/Config b/cesar/hal/phy/Config
index c41ed23e52..8abf36b761 100644
--- a/cesar/hal/phy/Config
+++ b/cesar/hal/phy/Config
@@ -1,5 +1,4 @@
CONFIG_PHY_DSP_150MHZ = y
-CONFIG_BRIDGEDMA_SOFT = n
CONFIG_PHY_TRACE_MORE = n
CONFIG_PHY_TRACE_DATE_WARNING = y
CONFIG_PHY_CAP_ZERO = y
diff --git a/cesar/hal/phy/Module b/cesar/hal/phy/Module
index e1d60e2408..d1c69554a3 100644
--- a/cesar/hal/phy/Module
+++ b/cesar/hal/phy/Module
@@ -1,16 +1,10 @@
-SOURCES := access.c pbdma.c phy.c pratic.c rx.c tx.c resys.c vsr.S
+SOURCES := access.c pbdma.c phy.c pratic.c rx.c tx.c resys.c vsr.S bridgedma.c
MODULES := hal/phy/spoc
ifeq ($(CONFIG_TRACE),y)
SOURCES += trace.c
endif
-ifeq ($(CONFIG_BRIDGEDMA_SOFT),y)
-SOURCES += bridgedma_soft.c
-else
-SOURCES += bridgedma.c
-endif
-
hal_phy_resys_prog_h = $(OBJ_DIR)/inc/hal_phy_resys_prog.h
hal_phy_resys_offsettable_h = $(OBJ_DIR)/inc/hal_phy_resys_offsettable.h
hal_phy_params_h = $(OBJ_DIR)/inc/hal_phy_params.h
diff --git a/cesar/hal/phy/inc/bridgedma.h b/cesar/hal/phy/inc/bridgedma.h
index 6802d21d6f..9467a28365 100644
--- a/cesar/hal/phy/inc/bridgedma.h
+++ b/cesar/hal/phy/inc/bridgedma.h
@@ -13,10 +13,9 @@
* \ingroup hal_phy
*/
#include "hal/phy/bridgedma.h"
+#include "hal/phy/inc/bridgedma_common.h"
#include "hal/phy/inc/bridgedma_it_mgr.h"
-#include "config/bridgedma/soft.h"
-
/** Bridge DMA control and configuration. */
struct phy_bridgedma_ctrl_t
{
@@ -37,15 +36,8 @@ typedef struct phy_bridgedma_ctrl_t phy_bridgedma_ctrl_t;
/** Bridge DMA context. */
struct phy_bridgedma_t
{
- /** User data passed to any callback. */
- void *user_data;
- /** Bridge DMA interrupt callback. */
- phy_bridgedma_cb_t bridgedma_cb;
- /** DSR callback. */
- phy_deferred_cb_t deferred_cb;
- /** Bridgedma last job. */
- phy_bridgedma_job_t *job_last;
-
+ /** Bridge DMA common context. */
+ phy_bridgedma_common_t bridge;
/** Interruption manager. */
phy_bridgedma_it_mgr_t it_mgr;
};
diff --git a/cesar/hal/phy/inc/bridgedma_common.h b/cesar/hal/phy/inc/bridgedma_common.h
new file mode 100644
index 0000000000..47bb3cf8bf
--- /dev/null
+++ b/cesar/hal/phy/inc/bridgedma_common.h
@@ -0,0 +1,31 @@
+#ifndef hal_phy_inc_bridgedma_common_h
+#define hal_phy_inc_bridgedma_common_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/phy/inc/bridgedma_common.h
+ * \brief Common part of the bridge DMA structure.
+ * \ingroup hal_phy
+ *
+ */
+#include "hal/phy/bridgedma.h"
+
+struct phy_bridgedma_common_t
+{
+ /** User data passed to any callback. */
+ void *user_data;
+ /** Bridge DMA interrupt callback. */
+ phy_bridgedma_cb_t bridgedma_cb;
+ /** DSR callback. */
+ phy_deferred_cb_t deferred_cb;
+ /** Bridgedma job tail. */
+ phy_bridgedma_job_t *job_tail;
+};
+typedef struct phy_bridgedma_common_t phy_bridgedma_common_t;
+
+#endif /* hal_phy_inc_bridgedma_common_h */
diff --git a/cesar/hal/phy/inc/bridgedma_soft.h b/cesar/hal/phy/inc/bridgedma_soft.h
deleted file mode 100644
index c554853858..0000000000
--- a/cesar/hal/phy/inc/bridgedma_soft.h
+++ /dev/null
@@ -1,125 +0,0 @@
-#ifndef hal_phy_inc_bridgedma_proto_h
-#define hal_phy_inc_bridgedma_proto_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/phy/inc/bridgedma_proto.h
- * \brief Context for the bridge dma prototype version.
- * \ingroup hal_phy
- *
- */
-#include "hal/phy/bridgedma.h"
-
-#include <cyg/kernel/kapi.h>
-#include <cyg/hal/hal_arch.h>
-#include <cyg/hal/hal_intr.h>
-
-#include "lib/crc.h"
-#include "lib/utils.h"
-
-#include "hal/phy/inc/bridgedma_it_mgr.h"
-
-#define BRIDGEDMA_THREAD_PRIORITY 0
-#define BRIDGEDMA_THREAD_STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL
-
-/* Use this define to enable or disable the it. It corresponds to the bit 13
- * in the eCos it register. */
-#define BRIDGEDMA_ECOS_IT 13
-#define BRIDGEDMA_ECOS_IT_MASK (1 << BRIDGEDMA_ECOS_IT)
-
-#ifdef __sparc__
-
-#define bridgedma_crc_compute_continue_block crc_compute_continue_block_le
-#define bridgedma_crc_compute_block crc_compute_block_le
-
-#define BRIDGEDMA_PROTO_ECOS_IT_BASE_REGISTER 0x80000098
-#define BRIDGEDMA_PROTO_ECOS_IT_ENABLE_REGISTER \
- BRIDGEDMA_PROTO_ECOS_IT_BASE_REGISTER
-#define BRIDGEDMA_PROTO_ECOS_IT_DISABLE_REGISTER \
- (BRIDGEDMA_PROTO_ECOS_IT_BASE_REGISTER + 4)
-
-#else /* ! __sparc__ */
-
-#define BRIDGEDMA_PROTO_ECOS_IT_BASE_REGISTER (& synth_pending_isrs)
-#define BRIDGEDMA_PROTO_ECOS_IT_ENABLE_REGISTER \
- BRIDGEDMA_PROTO_ECOS_IT_BASE_REGISTER
-#define BRIDGEDMA_PROTO_ECOS_IT_DISABLE_REGISTER \
- BRIDGEDMA_PROTO_ECOS_IT_BASE_REGISTER
-
-#define bridgedma_crc_compute_continue_block crc_compute_continue_block
-#define bridgedma_crc_compute_block crc_compute_block
-
-#endif /* ! __sparc__ */
-
-
-#define PHY_HAL_INTERRUPT_PRIORITY 1 /* is it the right value ? */
-
-#define HPAV_CRC32_GENERATOR 0x04c11db7
-#define HPAV_CRC32_INIT 0xffffffff
-#define HPAV_CRC32_MAGIC 0x2144df1c
-
-/** 1 byte is processed into 5ns, so 8 bytes per tick (40ns) */
-#define BRIDGEDMA_BYTE_PER_TICK 8
-/** max additionnal processing time is 10us, so 250 ticks */
-#define BRIDGEDMA_ADD_MAX_TICK 250
-
-
-typedef enum
-{
- PB_TO_MACFRAME,
- MACFRAME_TO_PB
-} bridgedma_copy_dir_t;
-
-struct phy_bridgedma_t
-{
- /** The thread handle. */
- cyg_handle_t thread_handle;
- /** The thread itself. */
- cyg_thread thread;
- /** the thread stack */
- u8 thread_stack [BRIDGEDMA_THREAD_STACK_SIZE];
-
- /** crc context. */
- crc_t crc_ctx;
- uint icv_substitution;
- uint icv_current;
-
- /** Interrupt manager. */
- cyg_interrupt interrupt;
- cyg_handle_t interrupt_handle;
-
- /** Bridge DMA status. */
- phy_bridgedma_status_t status;
-
- /** Bridge job current. */
- phy_bridgedma_job_t *job_current;
- /** Bridge job first. */
- phy_bridgedma_job_t *job_first;
-
- /** Interruption manager. */
- phy_bridgedma_it_mgr_t it_mgr;
-
- /* Real phy bridgedma context. */
- /** User data passed to any callback. */
- void *user_data;
- /** Bridge DMA interrupt callback. */
- phy_bridgedma_cb_t bridgedma_cb;
- /** DSR callback. */
- phy_deferred_cb_t deferred_cb;
- /** Bridgedma last job. */
- phy_bridgedma_job_t *job_last;
-};
-
-BEGIN_DECLS
-
-void
-phy_bridgedma_proto_process (cyg_addrword_t data);
-
-END_DECLS
-
-#endif /* hal_phy_inc_bridgedma_proto_h */
diff --git a/cesar/hal/phy/maximus/Module b/cesar/hal/phy/maximus/Module
index e5f1fc8ab9..af1ef0cdb4 100644
--- a/cesar/hal/phy/maximus/Module
+++ b/cesar/hal/phy/maximus/Module
@@ -1,4 +1,4 @@
-SOURCES := maximus_phy_access.c maximus_bridgedma.c maximus_phy_ctrl.c \
+SOURCES := maximus_phy_access.c maximus_phy_ctrl.c \
maximus_phy_ctrl_cb.c maximus_pbdma.c maximus_tmdma.c \
maximus_aes.c maximus_spoc.c
MODULES := hal/phy/maximus/dur
diff --git a/cesar/hal/phy/maximus/inc/maximus_bridgedma_ctx.h b/cesar/hal/phy/maximus/inc/maximus_bridgedma_ctx.h
deleted file mode 100644
index 16cbc8b595..0000000000
--- a/cesar/hal/phy/maximus/inc/maximus_bridgedma_ctx.h
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef MAXIMUS_BRIDGEDMA_CTX_H_
-#define MAXIMUS_BRIDGEDMA_CTX_H_
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/phy/maximus/inc/maximus_bridgedma_ctx.h
- * \brief HAL Bridge DMA context for Maximus.
- * \ingroup hal_phy_maximus
- */
-
-#include "lib/crc.h"
-#include "hal/phy/bridgedma.h"
-#ifdef ECOS
-#include <cyg/hal/drv_api.h>
-#endif /* ECOS */
-#include "host/station/station.h"
-
-/** 1 byte is processed into 5ns, so 8 bytes per tick (40ns) */
-#define BRIDGEDMA_BYTE_PER_TICK 8
-/** max additionnal processing time is 10us, so 250 ticks */
-#define BRIDGEDMA_ADD_MAX_TICK 250
-
-#define HPAV_CRC32_GENERATOR 0x04c11db7
-#define HPAV_CRC32_INIT 0xffffffff
-#define HPAV_CRC32_MAGIC 0x2144df1c
-
-typedef enum
-{
- PB_TO_MACFRAME,
- MACFRAME_TO_PB
-} bridgedma_copy_dir_t;
-
-struct phy_bridgedma_t
-{
- phy_bridgedma_status_t status;
- //phy_bridgedma_ctrl_t control;
- phy_bridgedma_job_t *job_first;
- phy_bridgedma_job_t *job_current;
- phy_bridgedma_job_t *job_last;
- uint32_t icv_substitution;
- uint32_t icv_current;
- crc_t crc_ctx;
- void *user_data;
- phy_bridgedma_cb_t bridgedma_cb;
- phy_deferred_cb_t deferred_cb;
- station_ctx_t *station;
- netclock_callback_t netclock_cb;
-#ifdef ECOS
- cyg_interrupt interrupt;
- cyg_handle_t interrupt_handle;
-#endif /* ECOS */
-};
-
-#ifndef ECOS
-int _pb_data_add(blk_t **pb_current, unsigned char **pb_data_ptr, unsigned int pb_size,
- unsigned char *mac_ptr, unsigned int mac_len, bridgedma_copy_dir_t direction);
-#endif /* ECOS */
-
-#endif /*MAXIMUS_BRIDGEDMA_CTX_H_*/
diff --git a/cesar/hal/phy/maximus/src/maximus_bridgedma.c b/cesar/hal/phy/maximus/src/maximus_bridgedma.c
deleted file mode 100644
index 74123326f5..0000000000
--- a/cesar/hal/phy/maximus/src/maximus_bridgedma.c
+++ /dev/null
@@ -1,411 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/phy/maximus/src/maximus_bridgedma.c
- * \brief HAL Phy Bridge DMA functions for Maximus.
- * \ingroup hal_phy_maximus
- */
-
-#include "common/std.h"
-#include "common/defs/ethernet.h"
-#include "ecos/packages/hal/maximus/arch/current/include/hal_host_intr.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"
-#include <stdlib.h>
-#include <errno.h>
-
-#define ETH_BUFFER_MASK(job) (~((job)->eth_buffer_mask << 7))
-#define ETH_BUFFER_SIZE(job) (ETH_BUFFER_MASK(job) + 1)
-#define ETH_BUFFER_ADDR(job) (unsigned char *)((unsigned long)job->data_addr & ~ETH_BUFFER_MASK(job))
-
-/*struct job_cb_data
-{
- phy_bridgedma_t *ctx;
- int is_it;
-};*/
-
-#ifdef ECOS
-static cyg_uint32 _bridgedma_ecos_isr(cyg_vector_t vector, cyg_addrword_t data)
-{
- /* nothing to do except calling the bridgedma callback */
- phy_bridgedma_t *bridgedma_ctx;
- bridgedma_ctx = (phy_bridgedma_t *)data;
- cyg_drv_interrupt_mask(PHY_HAL_INTERRUPT_BRIDGEDMA);
- cyg_drv_interrupt_acknowledge(PHY_HAL_INTERRUPT_BRIDGEDMA);
- if((*bridgedma_ctx->bridgedma_cb)(bridgedma_ctx->user_data, *((u32 *)((void *)&bridgedma_ctx->status))))
- return CYG_ISR_CALL_DSR; // Cause DSR to be run
- else
- {
- cyg_drv_interrupt_unmask(PHY_HAL_INTERRUPT_BRIDGEDMA);
- return CYG_ISR_HANDLED;
- }
-}
-
-static void _bridgedma_ecos_dsr(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data)
-{
- /* nothing to do except calling the phy dsr */
- phy_bridgedma_t *bridgedma_ctx;
- bridgedma_ctx = (phy_bridgedma_t *)data;
- (*bridgedma_ctx->deferred_cb)(bridgedma_ctx->user_data);
- cyg_drv_interrupt_unmask(PHY_HAL_INTERRUPT_BRIDGEDMA);
- return;
-}
-#endif /* ECOS */
-
-static void _job_process_cb(void *data);
-
-/**
- * Initialise the Bridge DMA.
- * \param user_data User data passed to any callback
- * \param bridgedma_cb Bridge DMA interrupt callback
- * \param deferred_cb DSR callback
- * \return the newly created context
- */
-phy_bridgedma_t *
-phy_bridgedma_init (void *user_data, phy_bridgedma_cb_t bridgedma_cb,
- phy_deferred_cb_t deferred_cb)
-{
- static phy_bridgedma_t bridgedma_ctx;
- static u32 enc_tab[256];
-
- memset(&bridgedma_ctx, '\0', sizeof(bridgedma_ctx));
- bridgedma_ctx.user_data = user_data;
- bridgedma_ctx.bridgedma_cb = bridgedma_cb;
- bridgedma_ctx.deferred_cb = deferred_cb;
- bridgedma_ctx.status.stop = 1;
- bridgedma_ctx.station = &my_station;
-
- /* init the crc context */
- bridgedma_ctx.crc_ctx.width = 32;
- bridgedma_ctx.crc_ctx.generator = HPAV_CRC32_GENERATOR;
- bridgedma_ctx.crc_ctx.init = HPAV_CRC32_INIT;
- bridgedma_ctx.crc_ctx.refin = true;
- bridgedma_ctx.crc_ctx.refout = true;
- bridgedma_ctx.crc_ctx.xorout = 0xffffffff;
- bridgedma_ctx.crc_ctx.reg_init = 0;
- bridgedma_ctx.crc_ctx.table.t32 = enc_tab;
- crc_init(&bridgedma_ctx.crc_ctx);
-
-#ifdef ECOS
- /* register ISR et DSR to eCos */
- cyg_drv_interrupt_create(PHY_HAL_INTERRUPT_BRIDGEDMA,
- PHY_HAL_INTERRUPT_PRIORITY,
- (cyg_addrword_t)&bridgedma_ctx,
- _bridgedma_ecos_isr,
- _bridgedma_ecos_dsr,
- &bridgedma_ctx.interrupt_handle,
- &bridgedma_ctx.interrupt);
- cyg_drv_interrupt_attach(bridgedma_ctx.interrupt_handle);
- cyg_drv_interrupt_unmask(PHY_HAL_INTERRUPT_BRIDGEDMA);
-#endif /* ECOS */
- return &bridgedma_ctx;
-}
-
-
-/**
- * Reset and uninitialise the Bridge DMA.
- * \param ctx Bridge DMA context
- */
-void
-phy_bridgedma_uninit (phy_bridgedma_t *ctx)
-{
-
-}
-
-/**
- * Fragment a mac_frame data into one or several PBs.
- * Mac frame data MUST NOT cross the mac frame buffer boundary (going at beginning of circular buffer)
- * ie: we must have mac_ptr + mac_len <= end_of_mac_buffer
- * \param pb_current pointer of pointer to first pb to store data
- * \param pb_data_ptr pointer of pointer to data beginning into first pb
- * \param pb_size size of pb data (128 or 512)
- * \param mac_ptr pointer to mac_frame data
- * \param mac_len length of mac frame data
- * \param direction data copy direction: MACFRAME_TO_PB or PB_TO_MACFRAME
- * \return 0
- */
-
-#ifndef UNIT_TEST
-static int
-#else /* UNIT_TEST */
-int
-#endif /* UNIT_TEST */
-_pb_data_add(
- blk_t **pb_current,
- unsigned char **pb_data_ptr,
- unsigned int pb_size,
- unsigned char *mac_ptr,
- unsigned int mac_len,
- bridgedma_copy_dir_t direction)
-{
- unsigned int mac_cnt;
-
- mac_cnt = 0;
-
- while((mac_len - mac_cnt) > pb_size - (*pb_data_ptr - (*pb_current)->data))
- {
- if(direction == MACFRAME_TO_PB)
- memcpy(*pb_data_ptr, mac_ptr + mac_cnt, pb_size - (*pb_data_ptr - (*pb_current)->data));
- else
- memcpy(mac_ptr + mac_cnt, *pb_data_ptr, pb_size - (*pb_data_ptr - (*pb_current)->data));
- mac_cnt += pb_size - (*pb_data_ptr - (*pb_current)->data);
- *pb_current = (*pb_current)->next;
- dbg_assert(*pb_current);
- *pb_data_ptr = (*pb_current)->data;
- }
-
- if(direction == MACFRAME_TO_PB)
- memcpy(*pb_data_ptr, mac_ptr + mac_cnt, mac_len - mac_cnt);
- else
- memcpy(mac_ptr + mac_cnt, *pb_data_ptr, mac_len - mac_cnt);
- *pb_data_ptr += mac_len - mac_cnt;
- return 0;
-}
-
-/**
- * Process 1 job for fragmentation or reassembly
- * \param ctx Bridge DMA context
- * \param job job to process
- * \return 0
- * */
-static int
-_job_process(phy_bridgedma_t *ctx, phy_bridgedma_job_t *job)
-{
- unsigned char * mac_ptr, *data_ptr;
- blk_t *pb_current;
- unsigned long icv_final, icv_compare;
-
- ctx->job_current = job;
-
- dbg_assert(job->data_addr);
- dbg_assert((job->header_len == 0) || (job->header_len == 2) || (job->header_len == 6));
- dbg_assert(job->data_len <= ETH_PACKET_MAX_SIZE);
- dbg_assert(job->first_pb_desc);
- dbg_assert(job->first_pb_offset < job->segment_len);
- dbg_assert((job->segment_len == 128) || (job->segment_len == 512));
-
- /* check icv reset */
- if(job->crc_reset)
- ctx->icv_current = crc_compute_begin(&ctx->crc_ctx);
-
- pb_current = job->first_pb_desc;
- data_ptr = pb_current->data + job->first_pb_offset;
- mac_ptr = job->data_addr;
-
- if(job->direction == 0)
- {
- /* segmentation processing */
-
- if(job->header_len > 0)
- {
- /* add header */
- _pb_data_add(&pb_current,
- &data_ptr,
- job->segment_len,
- (unsigned char *)&job->mf_header1, /* little endian !!! */
- 2,
- MACFRAME_TO_PB); /* we are in little endian for simulator... */
- if(job->header_len == 6)
- {
- /* add ATS */
- _pb_data_add(&pb_current,
- &data_ptr,
- job->segment_len,
- ((unsigned char *)&job->mf_header1) + 2, /* little endian !!! */
- 4,
- MACFRAME_TO_PB); /* we are in little endian for simulator... */
- if(!job->crc_error)
- ctx->icv_current = crc_compute_continue_block(&ctx->crc_ctx, ctx->icv_current, ((unsigned char *)&job->mf_header1) + 2, 4);
- }
- }
-
- /* check if mac data must be separated into 2 parts (circular buffer rollover) */
- if((job->eth_buffer_mask != 0)
- && (job->data_addr + job->data_len >= ETH_BUFFER_ADDR(job) + ETH_BUFFER_SIZE(job)))
- {
- _pb_data_add(&pb_current, &data_ptr, job->segment_len, job->data_addr, ETH_BUFFER_ADDR(job) + ETH_BUFFER_SIZE(job) - job->data_addr, MACFRAME_TO_PB);
- if(!job->crc_error)
- ctx->icv_current = crc_compute_continue_block(&ctx->crc_ctx, ctx->icv_current, job->data_addr, ETH_BUFFER_ADDR(job) + ETH_BUFFER_SIZE(job) - job->data_addr);
- _pb_data_add(&pb_current, &data_ptr, job->segment_len, job->data_addr, ((unsigned long)(job->data_addr) + job->data_len) & ETH_BUFFER_MASK(job), MACFRAME_TO_PB);
- if(!job->crc_error)
- ctx->icv_current = crc_compute_continue_block(&ctx->crc_ctx, ctx->icv_current, job->data_addr, ((unsigned long)(job->data_addr) + job->data_len) & ETH_BUFFER_MASK(job));
- }
- else
- {
- _pb_data_add(&pb_current, &data_ptr, job->segment_len, job->data_addr, job->data_len, MACFRAME_TO_PB);
- if(!job->crc_error)
- ctx->icv_current = crc_compute_continue_block(&ctx->crc_ctx, ctx->icv_current, job->data_addr, job->data_len);
- }
- if(job->crc_store)
- {
- /* add crc */
- if(!job->crc_error)
- icv_final = crc_compute_end(&ctx->crc_ctx, ctx->icv_current);
- else
- icv_final = ctx->icv_substitution;
- _pb_data_add(&pb_current, &data_ptr, job->segment_len, (unsigned char *)&icv_final, 4, MACFRAME_TO_PB); /* we are in little endian for simulator... */
- }
- if(job->append_zero)
- {
- /* add zeroed padding */
- memset(data_ptr, '\0', job->segment_len - (data_ptr - pb_current->data));
- }
- }
- else /* job->direction != 0 */
- {
- /* reassembly processing */
- if(job->header_len > 0)
- {
- /* get the mac frame header */
- _pb_data_add(&pb_current,
- &data_ptr,
- job->segment_len,
- (unsigned char *)&job->mf_header1, /* little endian !!! */
- 2,
- PB_TO_MACFRAME); /* we are in little endian for simulator... */
- if(job->header_len == 6)
- {
- /* add ATS */
- _pb_data_add(&pb_current,
- &data_ptr,
- job->segment_len,
- ((unsigned char *)&job->mf_header1) + 2, /* little endian */
- 4,
- PB_TO_MACFRAME); /* we are in little endian for simulator... */
- ctx->icv_current = crc_compute_continue_block(&ctx->crc_ctx, ctx->icv_current, ((unsigned char *)&job->mf_header1) + 2, 4);
- }
- }
-
- /* check if mac data must be separated into 2 parts (circular buffer rollover) */
- if((job->eth_buffer_mask != 0)
- && (job->data_addr + job->data_len >= ETH_BUFFER_ADDR(job) + ETH_BUFFER_SIZE(job)))
- {
- _pb_data_add(&pb_current, &data_ptr, job->segment_len, job->data_addr, ETH_BUFFER_ADDR(job) + ETH_BUFFER_SIZE(job) - job->data_addr, PB_TO_MACFRAME);
- ctx->icv_current = crc_compute_continue_block(&ctx->crc_ctx, ctx->icv_current, job->data_addr, ETH_BUFFER_ADDR(job) + ETH_BUFFER_SIZE(job) - job->data_addr);
- _pb_data_add(&pb_current, &data_ptr, job->segment_len, (unsigned char *)((unsigned long)job->data_addr & ~ETH_BUFFER_MASK(job)), ((unsigned long)(job->data_addr) + job->data_len) & ETH_BUFFER_MASK(job), PB_TO_MACFRAME);
- ctx->icv_current = crc_compute_continue_block(&ctx->crc_ctx, ctx->icv_current, (unsigned char *)((unsigned long)job->data_addr & ~ETH_BUFFER_MASK(job)), ((unsigned long)(job->data_addr) + job->data_len) & ETH_BUFFER_MASK(job));
- }
- else
- {
- _pb_data_add(&pb_current, &data_ptr, job->segment_len, job->data_addr, job->data_len, PB_TO_MACFRAME);
- ctx->icv_current = crc_compute_continue_block(&ctx->crc_ctx, ctx->icv_current, job->data_addr, job->data_len);
- }
- if(job->crc_store)
- {
- /* check crc */
- icv_final = crc_compute_end(&ctx->crc_ctx, ctx->icv_current);
- _pb_data_add(&pb_current, &data_ptr, job->segment_len, (unsigned char *)&icv_compare, 4, PB_TO_MACFRAME); /* we are in little endian for simulator... */
- job->crc_error = (icv_compare != icv_final);
- }
- }
-
- /* job is processed without any delay (because real hardware is
- very fast */
- _job_process_cb (ctx);
-
- return 0;
-}
-
-static void _job_process_cb(void *data)
-{
- struct phy_bridgedma_t *bridgedma_ctx;
-
- dbg_assert(data);
- bridgedma_ctx = (struct phy_bridgedma_t *)data;
-
- /* set interrupt raising */
- if(bridgedma_ctx->job_current->job_it)
- maximus_pending_isrs |= (1 << PHY_HAL_INTERRUPT_BRIDGEDMA);
-
- /* check if we are the last job */
- if(bridgedma_ctx->job_current == bridgedma_ctx->job_last)
- {
- /* last job: stop the process */
- bridgedma_ctx->job_first = NULL;
- bridgedma_ctx->job_current = NULL;
- bridgedma_ctx->job_last = NULL;
-
- /* refresh bridge dma status */
- bridgedma_ctx->status.running = 0;
- bridgedma_ctx->status.stop = 1;
- }
- else
- {
- /* not the last job: process next */
- dbg_assert(bridgedma_ctx->job_current->next);
- bridgedma_ctx->job_current = bridgedma_ctx->job_current->next;
- _job_process(bridgedma_ctx, bridgedma_ctx->job_current);
- }
-
- return;
-}
-
-/**
- * Enqueue and start a list of jobs.
- * \param ctx Bridge DMA context
- * \param job_first first job to enqueue
- * \param job_last last job to enqueue
- *
- * The new jobs are added to the Bridge DMA queue and the Bridge DMA is
- * restarted if it was stopped. The \c last flag must be set in the last
- * enqueued job.
- */
-void
-phy_bridgedma_start (phy_bridgedma_t *ctx, phy_bridgedma_job_t *job_first,
- phy_bridgedma_job_t *job_last)
-{
- dbg_assert(ctx);
- dbg_assert(job_first);
- dbg_assert(job_last);
-
- /* check current job processing */
- if(ctx->job_first == NULL)
- {
- /* no more job in queue */
- ctx->job_first = job_first;
- ctx->job_current = job_first;
- ctx->job_last = job_last;
- memset(&ctx->status, '\0', sizeof(phy_bridgedma_status_t));
- ctx->status.running = 1;
- _job_process(ctx, ctx->job_current);
- }
- else
- {
- /* there are still job inside */
- dbg_assert(ctx->job_last);
- ctx->job_last->next = job_first;
- ctx->job_last = job_last;
- }
-
- return;
-}
-
-/**
- * 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)
-{
- dbg_assert (ctx);
-
- return ctx->job_current;
-}
-
-bool
-phy_bridgedma_status (phy_bridgedma_t *ctx)
-{
- dbg_assert (ctx);
- return ctx->status.running;
-}
diff --git a/cesar/hal/phy/soft/bridgedma/Module b/cesar/hal/phy/soft/bridgedma/Module
new file mode 100644
index 0000000000..07f8b7cb3c
--- /dev/null
+++ b/cesar/hal/phy/soft/bridgedma/Module
@@ -0,0 +1 @@
+SOURCES:=bridgedma.c
diff --git a/cesar/hal/phy/soft/bridgedma/bridgedma_crc.h b/cesar/hal/phy/soft/bridgedma/bridgedma_crc.h
new file mode 100644
index 0000000000..970a4e2adf
--- /dev/null
+++ b/cesar/hal/phy/soft/bridgedma/bridgedma_crc.h
@@ -0,0 +1,25 @@
+#ifndef hal_phy_soft_bridgedma_bridgedma_crc_h
+#define hal_phy_soft_bridgedma_bridgedma_crc_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/phy/soft/bridgedma/bridgedma_crc.h
+ * \brief Context for the bridge DMA soft version.
+ * \ingroup hal_phy
+ */
+
+/* Defines for bridge DMA crc computation on PC or SPARC. */
+#ifdef __sparc__
+ #define bridgedma_crc_compute_continue_block crc_compute_continue_block_le
+ #define bridgedma_crc_compute_block crc_compute_block_le
+#else
+ #define bridgedma_crc_compute_continue_block crc_compute_continue_block
+ #define bridgedma_crc_compute_block crc_compute_block
+#endif
+
+#endif /* hal_phy_soft_bridgedma_bridgedma_crc_h */
diff --git a/cesar/hal/phy/soft/bridgedma/inc/bridgedma.h b/cesar/hal/phy/soft/bridgedma/inc/bridgedma.h
new file mode 100644
index 0000000000..79fd9aedbf
--- /dev/null
+++ b/cesar/hal/phy/soft/bridgedma/inc/bridgedma.h
@@ -0,0 +1,42 @@
+#ifndef hal_phy_soft_bridgedma_inc_bridgedma_h
+#define hal_phy_soft_bridgedma_inc_bridgedma_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/phy/soft/bridgedma/inc/bridgedma.h
+ * \brief Context for the bridge DMA soft version.
+ * \ingroup hal_phy
+ *
+ */
+#include "lib/crc.h"
+#include "hal/phy/inc/bridgedma_common.h"
+
+typedef enum
+{
+ HAL_PHY_BRIDGEDMA_PB_TO_MACFRAME,
+ HAL_PHY_BRIDGEDMA_MACFRAME_TO_PB
+} bridgedma_copy_dir_t;
+
+struct phy_bridgedma_t
+{
+ /* Bridge DMA context. */
+ phy_bridgedma_common_t bridge;
+
+ /** crc context. */
+ crc_t crc_ctx;
+ uint icv_substitution;
+ uint icv_current;
+
+ /** Bridge DMA status. */
+ phy_bridgedma_status_t status;
+
+ /** Bridge job current. */
+ phy_bridgedma_job_t *job_current;
+};
+
+#endif /* hal_phy_soft_bridgedma_inc_bridgedma_h */
diff --git a/cesar/hal/phy/soft/bridgedma/src/bridgedma.c b/cesar/hal/phy/soft/bridgedma/src/bridgedma.c
new file mode 100644
index 0000000000..a484193c14
--- /dev/null
+++ b/cesar/hal/phy/soft/bridgedma/src/bridgedma.c
@@ -0,0 +1,375 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/phy/soft/bridgedma/src/bridgedma.c
+ * \brief HAL Phy Bridge DMA functions for the prototype.
+ * \ingroup hal_phy
+ */
+#include "common/std.h"
+#include "common/defs/ethernet.h"
+#include "common/defs/homeplugAV.h"
+#include "lib/bitstream.h"
+
+#include "hal/phy/soft/bridgedma/bridgedma_crc.h"
+#include "hal/phy/soft/bridgedma/inc/bridgedma.h"
+#include <stdlib.h>
+#include <string.h>
+
+#define ETH_BUFFER_MASK(job) (~((job)->eth_buffer_mask << 7))
+#define ETH_BUFFER_SIZE(job) (ETH_BUFFER_MASK(job) + 1)
+#define ETH_BUFFER_ADDR(job) \
+ (unsigned char *)((unsigned long)job->data_addr & ~ETH_BUFFER_MASK(job))
+
+phy_bridgedma_t *
+phy_bridgedma_init (void *user_data, phy_bridgedma_cb_t bridgedma_cb,
+ phy_deferred_cb_t deferred_cb)
+{
+ static phy_bridgedma_t bridgedma_ctx;
+ static u32 enc_tab[256];
+
+ memset(&bridgedma_ctx, '\0', sizeof(phy_bridgedma_t));
+ bridgedma_ctx.bridge.user_data = user_data;
+ bridgedma_ctx.bridge.bridgedma_cb = bridgedma_cb;
+ bridgedma_ctx.bridge.deferred_cb = deferred_cb;
+ bridgedma_ctx.status.stop = true;
+ bridgedma_ctx.status.running = false;
+
+ /* init the crc context */
+ bridgedma_ctx.crc_ctx.width = 32;
+ bridgedma_ctx.crc_ctx.generator = HPAV_CRC32_GENERATOR;
+ bridgedma_ctx.crc_ctx.init = HPAV_CRC32_INIT;
+ bridgedma_ctx.crc_ctx.refin = true;
+ bridgedma_ctx.crc_ctx.refout = true;
+ bridgedma_ctx.crc_ctx.xorout = 0xffffffff;
+ bridgedma_ctx.crc_ctx.reg_init = 0;
+ bridgedma_ctx.crc_ctx.table.t32 = enc_tab;
+ crc_init(&bridgedma_ctx.crc_ctx);
+
+ return &bridgedma_ctx;
+}
+
+/**
+ * Reset and uninitialise the Bridge DMA.
+ * \param ctx Bridge DMA context
+ */
+void
+phy_bridgedma_uninit (phy_bridgedma_t *ctx)
+{
+ dbg_assert (ctx);
+}
+
+/**
+ * Fragment a mac_frame data into one or several PBs.
+ * Mac frame data MUST NOT cross the mac frame buffer boundary
+ * (going at beginning of circular buffer)
+ * ie: we must have mac_ptr + mac_len <= end_of_mac_buffer
+ * \param pb_current pointer of pointer to first pb to store data
+ * \param pb_data_ptr pointer of pointer to data beginning into first pb
+ * \param pb_size size of pb data (128 or 512)
+ * \param mac_ptr pointer to mac_frame data
+ * \param mac_len length of mac frame data
+ * \param direction data copy direction: HAL_PHY_BRIDGEDMA_MACFRAME_TO_PB or HAL_PHY_BRIDGEDMA_PB_TO_MACFRAME
+ * \return 0
+ */
+
+static uint _pb_data_add(
+ blk_t **pb_current,
+ unsigned char **pb_data_ptr,
+ unsigned int pb_size,
+ unsigned char *mac_ptr,
+ unsigned int mac_len,
+ bridgedma_copy_dir_t direction)
+{
+ unsigned int mac_cnt;
+
+ mac_cnt = 0;
+
+ while((mac_len - mac_cnt) > pb_size
+ - (*pb_data_ptr - (*pb_current)->data))
+ {
+ if(direction == HAL_PHY_BRIDGEDMA_MACFRAME_TO_PB)
+ bitstream_memcpy(*pb_data_ptr,
+ mac_ptr + mac_cnt,
+ pb_size - (*pb_data_ptr - (*pb_current)->data));
+ else
+ bitstream_memcpy(mac_ptr + mac_cnt,
+ *pb_data_ptr,
+ pb_size - (*pb_data_ptr - (*pb_current)->data));
+
+ mac_cnt += pb_size - (*pb_data_ptr - (*pb_current)->data);
+ *pb_current = (*pb_current)->next;
+ dbg_assert(*pb_current);
+ *pb_data_ptr = (*pb_current)->data;
+ }
+
+ if(direction == HAL_PHY_BRIDGEDMA_MACFRAME_TO_PB)
+ bitstream_memcpy(*pb_data_ptr, mac_ptr + mac_cnt, mac_len - mac_cnt);
+ else
+ bitstream_memcpy(mac_ptr + mac_cnt, *pb_data_ptr, mac_len - mac_cnt);
+ *pb_data_ptr += mac_len - mac_cnt;
+ return 0;
+}
+
+/**
+ * Process 1 job for fragmentation or reassembly
+ * \param ctx Bridge DMA context
+ * \param job job to process
+ * \return 0
+ * */
+static int
+_job_process(phy_bridgedma_t *ctx, phy_bridgedma_job_t *job)
+{
+ unsigned char * mac_ptr, *data_ptr;
+ blk_t *pb_current;
+ unsigned long icv_final, icv_compare;
+
+ ctx->job_current = job;
+
+ dbg_assert(job->data_addr);
+ dbg_assert((job->header_len == 0) || (job->header_len == 2) ||
+ (job->header_len == 6));
+ dbg_assert(job->data_len <= ETH_PACKET_MAX_SIZE);
+ dbg_assert(job->first_pb_desc);
+ dbg_assert(job->first_pb_offset < job->segment_len);
+ dbg_assert((job->segment_len == 128) || (job->segment_len == 512));
+
+ /* check icv reset */
+ if(job->crc_reset)
+ ctx->icv_current =
+ crc_compute_begin(&ctx->crc_ctx);
+
+ pb_current = job->first_pb_desc;
+ data_ptr = pb_current->data + job->first_pb_offset;
+ mac_ptr = job->data_addr;
+
+ if(job->direction == 0)
+ {
+ /* segmentation processing */
+ if(job->header_len > 0)
+ {
+ /* add header */
+ _pb_data_add(&pb_current,
+ &data_ptr,
+ job->segment_len,
+ (unsigned char *)&job->mf_header1,
+ 2,
+ HAL_PHY_BRIDGEDMA_MACFRAME_TO_PB);
+ if(job->header_len == 6)
+ {
+ _pb_data_add(&pb_current,
+ &data_ptr,
+ job->segment_len,
+ ((unsigned char *)&job->mf_header1) + 2,
+ 4, HAL_PHY_BRIDGEDMA_MACFRAME_TO_PB);
+ }
+ }
+
+ /* check if mac data must be separated into 2 parts
+ * (circular buffer rollover) */
+ if((job->eth_buffer_mask != 0)
+ && (job->data_addr + job->data_len
+ >= ETH_BUFFER_ADDR(job) + ETH_BUFFER_SIZE(job)))
+ {
+ _pb_data_add(&pb_current, &data_ptr, job->segment_len,
+ job->data_addr,
+ ETH_BUFFER_ADDR(job) + ETH_BUFFER_SIZE(job)
+ - job->data_addr,
+ HAL_PHY_BRIDGEDMA_MACFRAME_TO_PB);
+ if(!job->crc_error)
+ ctx->icv_current =
+ bridgedma_crc_compute_continue_block(
+ &ctx->crc_ctx,
+ ctx->icv_current,
+ job->data_addr,
+ ETH_BUFFER_ADDR(job) + ETH_BUFFER_SIZE(job)
+ - job->data_addr);
+ _pb_data_add(&pb_current, &data_ptr, job->segment_len,
+ job->data_addr,
+ ((unsigned long)(job->data_addr) + job->data_len)
+ & ETH_BUFFER_MASK(job),
+ HAL_PHY_BRIDGEDMA_MACFRAME_TO_PB);
+ if(!job->crc_error)
+ ctx->icv_current =
+ bridgedma_crc_compute_continue_block(
+ &ctx->crc_ctx,
+ ctx->icv_current,
+ job->data_addr,
+ ((unsigned long)(job->data_addr) + job->data_len)
+ & ETH_BUFFER_MASK(job));
+ }
+ else
+ {
+ _pb_data_add(&pb_current, &data_ptr, job->segment_len,
+ job->data_addr, job->data_len,
+ HAL_PHY_BRIDGEDMA_MACFRAME_TO_PB);
+ if(!job->crc_error)
+ ctx->icv_current =
+ bridgedma_crc_compute_continue_block(
+ &ctx->crc_ctx,
+ ctx->icv_current,
+ job->data_addr, job->data_len);
+ }
+ if(job->crc_store)
+ {
+ /* add crc */
+ if(!job->crc_error)
+ icv_final = crc_compute_end(
+ &ctx->crc_ctx,
+ ctx->icv_current);
+ else
+ icv_final = ctx->icv_substitution;
+ _pb_data_add(&pb_current, &data_ptr,
+ job->segment_len,
+ (unsigned char *)&icv_final, 4,
+ HAL_PHY_BRIDGEDMA_MACFRAME_TO_PB);
+ }
+ if(job->append_zero)
+ {
+ /* add zeroed padding */
+ memset(data_ptr, '\0', job->segment_len
+ - (data_ptr - pb_current->data));
+ }
+ }
+ else /* job->direction != 0 */
+ {
+ /* reassembly processing */
+ if(job->header_len > 0)
+ {
+ /* get the mac frame header */
+ _pb_data_add(&pb_current,
+ &data_ptr,
+ job->segment_len,
+ (unsigned char *)&job->mf_header1, 2,
+ HAL_PHY_BRIDGEDMA_PB_TO_MACFRAME);
+ if(job->header_len == 6)
+ {
+ /* add ATS */
+ _pb_data_add(&pb_current,
+ &data_ptr,
+ job->segment_len,
+ ((unsigned char *)&job->mf_header1) + 2, 4,
+ HAL_PHY_BRIDGEDMA_PB_TO_MACFRAME);
+ }
+ }
+ /* check if mac data must be separated into 2 parts
+ * (circular buffer rollover) */
+ if((job->eth_buffer_mask != 0)
+ && (job->data_addr + job->data_len >= ETH_BUFFER_ADDR(job)
+ + ETH_BUFFER_SIZE(job)))
+ {
+ _pb_data_add(&pb_current, &data_ptr, job->segment_len,
+ job->data_addr, ETH_BUFFER_ADDR(job)
+ + ETH_BUFFER_SIZE(job) - job->data_addr,
+ HAL_PHY_BRIDGEDMA_PB_TO_MACFRAME);
+ ctx->icv_current =
+ bridgedma_crc_compute_continue_block (&ctx->crc_ctx,
+ ctx->icv_current,
+ job->data_addr,
+ ETH_BUFFER_ADDR(job)
+ + ETH_BUFFER_SIZE(job)
+ - job->data_addr);
+ _pb_data_add(&pb_current, &data_ptr, job->segment_len,
+ (unsigned char *)((unsigned long)job->data_addr
+ & ~ETH_BUFFER_MASK(job)),
+ ((unsigned long)(job->data_addr) + job->data_len)
+ & ETH_BUFFER_MASK(job),
+ HAL_PHY_BRIDGEDMA_PB_TO_MACFRAME);
+ ctx->icv_current = bridgedma_crc_compute_continue_block (
+ &ctx->crc_ctx,
+ ctx->icv_current,
+ (unsigned char *)((unsigned long)job->data_addr
+ & ~ETH_BUFFER_MASK(job)),
+ ((unsigned long)(job->data_addr) + job->data_len)
+ & ETH_BUFFER_MASK(job));
+ }
+ else
+ {
+ _pb_data_add(&pb_current, &data_ptr, job->segment_len,
+ job->data_addr, job->data_len,
+ HAL_PHY_BRIDGEDMA_PB_TO_MACFRAME);
+ ctx->icv_current =
+ bridgedma_crc_compute_continue_block(
+ &ctx->crc_ctx,
+ ctx->icv_current,
+ job->data_addr,
+ job->data_len);
+ }
+ if(job->crc_store)
+ {
+ /* check crc */
+ icv_final = crc_compute_end (&ctx->crc_ctx, ctx->icv_current);
+ _pb_data_add(&pb_current, &data_ptr, job->segment_len,
+ (unsigned char *)&icv_compare, 4,
+ HAL_PHY_BRIDGEDMA_PB_TO_MACFRAME);
+ job->crc_error = (icv_compare != icv_final);
+ }
+ }
+
+ /* Any job to process after ? */
+ if (!ctx->job_current->next)
+ ctx->status.running = false;
+
+ if(ctx->job_current->job_it)
+ {
+ /* Process interruption. */
+ if (ctx->bridge.bridgedma_cb (ctx->bridge.user_data,
+ ctx->status.running))
+ /* simulate a DSR call. */
+ ctx->bridge.deferred_cb (ctx->bridge.user_data);
+ }
+ ctx->job_current = ctx->job_current->next;
+
+ return true;
+}
+
+/**
+ * Launch the job process.
+ * \param ctx the module context.
+ */
+static void
+phy_bridgedma_process (phy_bridgedma_t *ctx)
+{
+ dbg_assert (ctx);
+
+ while (ctx->job_current)
+ _job_process(ctx, ctx->job_current);
+ /* refresh bridge dma status */
+ ctx->status.running = false;
+ ctx->status.stop = true;
+}
+
+void
+phy_bridgedma_start (phy_bridgedma_t *ctx, phy_bridgedma_job_t *job_first,
+ phy_bridgedma_job_t *job_last)
+{
+ dbg_assert (ctx);
+ dbg_assert (job_first);
+ dbg_assert (job_last);
+ dbg_assert (job_last->next == NULL);
+
+ ctx->job_current = job_first;
+ ctx->bridge.job_tail = job_last;
+ memset(&ctx->status, '\0', sizeof(phy_bridgedma_status_t));
+ ctx->status.running = true;
+ phy_bridgedma_process (ctx);
+}
+
+phy_bridgedma_job_t *
+phy_bridgedma_current_job (phy_bridgedma_t *ctx)
+{
+ dbg_assert (ctx);
+
+ return ctx->job_current;
+}
+
+bool
+phy_bridgedma_status (phy_bridgedma_t *ctx)
+{
+ dbg_assert (ctx);
+ return ctx->status.running;
+}
diff --git a/cesar/hal/phy/src/bridgedma.c b/cesar/hal/phy/src/bridgedma.c
index 45d055ee98..3abc0f24ff 100644
--- a/cesar/hal/phy/src/bridgedma.c
+++ b/cesar/hal/phy/src/bridgedma.c
@@ -45,8 +45,8 @@ _bridgedma_ecos_isr(cyg_vector_t vector, cyg_addrword_t data)
running = BF_GET (PHY_BRIDGEDMA_STATUS_ERROR__RUNNING,
PHY_BDGDMA_STATUS_ERROR);
- if((*bridgedma_ctx->bridgedma_cb)(bridgedma_ctx->user_data,
- running))
+ if((*bridgedma_ctx->bridge.bridgedma_cb)
+ (bridgedma_ctx->bridge.user_data, running))
return CYG_ISR_CALL_DSR; // Cause DSR to be run
else
{
@@ -61,21 +61,15 @@ _bridgedma_ecos_isr(cyg_vector_t vector, cyg_addrword_t data)
* \param data the user data.
*/
static void
-_bridgedma_ecos_dsr(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data)
+_bridgedma_ecos_dsr(cyg_vector_t vector, cyg_ucount32 count,
+ cyg_addrword_t data)
{
/* nothing to do except calling the phy dsr */
phy_bridgedma_t *bridgedma_ctx;
bridgedma_ctx = (phy_bridgedma_t *)data;
- (*bridgedma_ctx->deferred_cb)(bridgedma_ctx->user_data);
+ (*bridgedma_ctx->bridge.deferred_cb)(bridgedma_ctx->bridge.user_data);
}
-/**
- * Initialise the Bridge DMA.
- * \param user_data User data passed to any callback
- * \param bridgedma_cb Bridge DMA interrupt callback
- * \param deferred_cb DSR callback
- * \return the newly created context
- */
phy_bridgedma_t *
phy_bridgedma_init (void *user_data, phy_bridgedma_cb_t bridgedma_cb,
phy_deferred_cb_t deferred_cb)
@@ -85,9 +79,9 @@ phy_bridgedma_init (void *user_data, phy_bridgedma_cb_t bridgedma_cb,
memset (&phy_bridgedma_global, 0, sizeof (phy_bridgedma_t));
- phy_bridgedma_global.user_data = user_data;
- phy_bridgedma_global.bridgedma_cb = bridgedma_cb;
- phy_bridgedma_global.deferred_cb = deferred_cb;
+ phy_bridgedma_global.bridge.user_data = user_data;
+ phy_bridgedma_global.bridge.bridgedma_cb = bridgedma_cb;
+ phy_bridgedma_global.bridge.deferred_cb = deferred_cb;
/* Reset bridge DMA. */
PHY_RB_RST_MODULE = BF_SET (PHY_RB_RST_MODULE,
@@ -113,10 +107,6 @@ phy_bridgedma_init (void *user_data, phy_bridgedma_cb_t bridgedma_cb,
return &phy_bridgedma_global;
}
-/**
- * Reset and uninitialise the Bridge DMA.
- * \param ctx Bridge DMA context
- */
void
phy_bridgedma_uninit (phy_bridgedma_t *ctx)
{
@@ -146,16 +136,6 @@ phy_bridge_dma_start__configure (phy_bridgedma_t *ctx,
true);
}
-/**
- * Enqueue and start a list of jobs.
- * \param ctx Bridge DMA context
- * \param job_first first job to enqueue
- * \param job_last last job to enqueue
- *
- * The new jobs are added to the Bridge DMA queue and the Bridge DMA is
- * restarted if it was stopped. The \c last flag must be set in the last
- * enqueued job.
- */
void
phy_bridgedma_start (phy_bridgedma_t *ctx, phy_bridgedma_job_t *job_first,
phy_bridgedma_job_t *job_last)
@@ -176,13 +156,13 @@ phy_bridgedma_start (phy_bridgedma_t *ctx, phy_bridgedma_job_t *job_first,
}
else
{
- ctx->job_last->next = job_first;
+ ctx->bridge.job_tail->next = job_first;
arch_reorder_barrier ();
- ctx->job_last->last = false;
+ ctx->bridge.job_tail->last = false;
arch_write_buffer_flush ();
/* if last_job is loaded before last has been written. */
- if (PHY_BDGDMA_CURRENT_JOBD_PTR == (u32) ctx->job_last
+ if (PHY_BDGDMA_CURRENT_JOBD_PTR == (u32) ctx->bridge.job_tail
&& BF_GET (PHY_BRIDGEDMA_JOB_CONF__LAST,
PHY_BDGDMA_JOB_CONF))
{
@@ -190,18 +170,9 @@ phy_bridgedma_start (phy_bridgedma_t *ctx, phy_bridgedma_job_t *job_first,
}
}
- ctx->job_last = job_last;
+ ctx->bridge.job_tail = job_last;
}
-/**
- * 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)
{
diff --git a/cesar/hal/phy/src/bridgedma_soft.c b/cesar/hal/phy/src/bridgedma_soft.c
deleted file mode 100644
index 00c5901eb7..0000000000
--- a/cesar/hal/phy/src/bridgedma_soft.c
+++ /dev/null
@@ -1,477 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/phy/src/bridgedma.c
- * \brief HAL Phy Bridge DMA functions for the prototype.
- * \ingroup hal_phy
- *
- * Add in the config file the CONFIG_BRIDGEDMA_PROTO = y to use this
- * bridgedma.
- */
-
-#include <cyg/kernel/kapi.h>
-#include "cyg/hal/hal_io.h"
-#include "common/std.h"
-#include "common/defs/ethernet.h"
-#include "hal/phy/inc/bridgedma_soft.h"
-#include <stdlib.h>
-#include <string.h>
-
-#include "lib/bitstream.h"
-
-#define ETH_BUFFER_MASK(job) (~((job)->eth_buffer_mask << 7))
-#define ETH_BUFFER_SIZE(job) (ETH_BUFFER_MASK(job) + 1)
-#define ETH_BUFFER_ADDR(job) (unsigned char *)((unsigned long)job->data_addr & ~ETH_BUFFER_MASK(job))
-
-
-#ifdef __sparc__
- #define bridgedma_crc_compute_continue_block crc_compute_continue_block_le
- #define bridgedma_crc_compute_block crc_compute_block_le
-#else
- #define bridgedma_crc_compute_continue_block crc_compute_continue_block
- #define bridgedma_crc_compute_block crc_compute_block
-#endif
-
-static cyg_uint32 _bridgedma_ecos_isr(cyg_vector_t vector, cyg_addrword_t data)
-{
- volatile uint* ecos_it_register =
- (uint*) BRIDGEDMA_PROTO_ECOS_IT_DISABLE_REGISTER;
-
- /* nothing to do except calling the bridgedma callback */
- phy_bridgedma_t *bridgedma_ctx;
-
- /* Reset the IT interruption. */
- *ecos_it_register &= ~BRIDGEDMA_ECOS_IT_MASK;
- cyg_interrupt_mask(BRIDGEDMA_ECOS_IT);
-
- bridgedma_ctx = (phy_bridgedma_t *)data;
-
- if((*bridgedma_ctx->bridgedma_cb)(bridgedma_ctx->user_data,
- *((u32 *)((void *)&bridgedma_ctx->status))))
- return CYG_ISR_CALL_DSR; // Cause DSR to be run
- else
- {
- cyg_interrupt_unmask(BRIDGEDMA_ECOS_IT);
- return CYG_ISR_HANDLED;
- }
-}
-
-static void _bridgedma_ecos_dsr(cyg_vector_t vector,
- cyg_ucount32 count, cyg_addrword_t data)
-{
- /* nothing to do except calling the phy dsr */
- phy_bridgedma_t *bridgedma_ctx;
- bridgedma_ctx = (phy_bridgedma_t *)data;
- (*bridgedma_ctx->deferred_cb)(bridgedma_ctx->user_data);
- cyg_interrupt_unmask(BRIDGEDMA_ECOS_IT);
- return;
-}
-
-/**
- * Initialise the Bridge DMA.
- * \param user_data User data passed to any callback
- * \param bridgedma_cb Bridge DMA interrupt callback
- * \param deferred_cb DSR callback
- * \return the newly created context
- */
-phy_bridgedma_t *
-phy_bridgedma_init (void *user_data, phy_bridgedma_cb_t bridgedma_cb,
- phy_deferred_cb_t deferred_cb)
-{
- static phy_bridgedma_t bridgedma_ctx;
- static u32 enc_tab[256];
-
- memset(&bridgedma_ctx, '\0', sizeof(bridgedma_ctx));
- bridgedma_ctx.user_data = user_data;
- bridgedma_ctx.bridgedma_cb = bridgedma_cb;
- bridgedma_ctx.deferred_cb = deferred_cb;
- bridgedma_ctx.status.stop = true;
- bridgedma_ctx.status.running = false;
-
- /* init the crc context */
- bridgedma_ctx.crc_ctx.width = 32;
- bridgedma_ctx.crc_ctx.generator = HPAV_CRC32_GENERATOR;
- bridgedma_ctx.crc_ctx.init = HPAV_CRC32_INIT;
- bridgedma_ctx.crc_ctx.refin = true;
- bridgedma_ctx.crc_ctx.refout = true;
- bridgedma_ctx.crc_ctx.xorout = 0xffffffff;
- bridgedma_ctx.crc_ctx.reg_init = 0;
- bridgedma_ctx.crc_ctx.table.t32 = enc_tab;
- crc_init(&bridgedma_ctx.crc_ctx);
-
- /* register ISR et DSR to eCos */
- cyg_interrupt_create(BRIDGEDMA_ECOS_IT,
- PHY_HAL_INTERRUPT_PRIORITY,
- (cyg_addrword_t)&bridgedma_ctx,
- _bridgedma_ecos_isr,
- _bridgedma_ecos_dsr,
- &bridgedma_ctx.interrupt_handle,
- &bridgedma_ctx.interrupt);
- cyg_interrupt_attach(bridgedma_ctx.interrupt_handle);
-
- // Create the thread.
- cyg_thread_create(BRIDGEDMA_THREAD_PRIORITY,
- &phy_bridgedma_proto_process,
- (cyg_addrword_t) &bridgedma_ctx,
- "BRIDGEDMA_PROTO",
- bridgedma_ctx.thread_stack,
- BRIDGEDMA_THREAD_STACK_SIZE,
- &bridgedma_ctx.thread_handle,
- &bridgedma_ctx.thread);
-
- return &bridgedma_ctx;
-}
-
-
-/**
- * Reset and uninitialise the Bridge DMA.
- * \param ctx Bridge DMA context
- */
-void
-phy_bridgedma_uninit (phy_bridgedma_t *ctx)
-{
- cyg_thread_suspend (ctx->thread_handle);
-}
-
-/**
- * Fragment a mac_frame data into one or several PBs.
- * Mac frame data MUST NOT cross the mac frame buffer boundary
- * (going at beginning of circular buffer)
- * ie: we must have mac_ptr + mac_len <= end_of_mac_buffer
- * \param pb_current pointer of pointer to first pb to store data
- * \param pb_data_ptr pointer of pointer to data beginning into first pb
- * \param pb_size size of pb data (128 or 512)
- * \param mac_ptr pointer to mac_frame data
- * \param mac_len length of mac frame data
- * \param direction data copy direction: MACFRAME_TO_PB or PB_TO_MACFRAME
- * \return 0
- */
-
-static uint _pb_data_add(
- blk_t **pb_current,
- unsigned char **pb_data_ptr,
- unsigned int pb_size,
- unsigned char *mac_ptr,
- unsigned int mac_len,
- bridgedma_copy_dir_t direction)
-{
- unsigned int mac_cnt;
-
- mac_cnt = 0;
-
- while((mac_len - mac_cnt) > pb_size - (*pb_data_ptr - (*pb_current)->data))
- {
- if(direction == MACFRAME_TO_PB)
- bitstream_memcpy(*pb_data_ptr,
- mac_ptr + mac_cnt,
- pb_size - (*pb_data_ptr - (*pb_current)->data));
- else
- bitstream_memcpy(mac_ptr + mac_cnt,
- *pb_data_ptr,
- pb_size - (*pb_data_ptr - (*pb_current)->data));
-
- mac_cnt += pb_size - (*pb_data_ptr - (*pb_current)->data);
- *pb_current = (*pb_current)->next;
- dbg_assert(*pb_current);
- *pb_data_ptr = (*pb_current)->data;
- }
-
- if(direction == MACFRAME_TO_PB)
- bitstream_memcpy(*pb_data_ptr, mac_ptr + mac_cnt, mac_len - mac_cnt);
- else
- bitstream_memcpy(mac_ptr + mac_cnt, *pb_data_ptr, mac_len - mac_cnt);
- *pb_data_ptr += mac_len - mac_cnt;
- return 0;
-}
-
-/**
- * Process 1 job for fragmentation or reassembly
- * \param ctx Bridge DMA context
- * \param job job to process
- * \return 0
- * */
-static int
-_job_process(phy_bridgedma_t *ctx, phy_bridgedma_job_t *job)
-{
- unsigned char * mac_ptr, *data_ptr;
- blk_t *pb_current;
- unsigned long icv_final, icv_compare;
-
- /* variable to write in the ecos raising it. */
- volatile uint* ecos_enable_it =
- (uint*) BRIDGEDMA_PROTO_ECOS_IT_ENABLE_REGISTER;
- ctx->job_current = job;
-
- dbg_assert(job->data_addr);
- dbg_assert((job->header_len == 0) || (job->header_len == 2) ||
- (job->header_len == 6));
- dbg_assert(job->data_len <= ETH_PACKET_MAX_SIZE);
- dbg_assert(job->first_pb_desc);
- dbg_assert(job->first_pb_offset < job->segment_len);
- dbg_assert((job->segment_len == 128) || (job->segment_len == 512));
-
- /* check icv reset */
- if(job->crc_reset)
- ctx->icv_current =
- crc_compute_begin(&ctx->crc_ctx);
-
- pb_current = job->first_pb_desc;
- data_ptr = pb_current->data + job->first_pb_offset;
- mac_ptr = job->data_addr;
-
- if(job->direction == 0)
- {
- /* segmentation processing */
-
- if(job->header_len > 0)
- {
- /* add header */
- _pb_data_add(&pb_current,
- &data_ptr,
- job->segment_len,
- (unsigned char *)&job->mf_header1, /* little endian !!! */
- 2,
- MACFRAME_TO_PB); /* we are in little endian for simulator... */
- if(job->header_len == 6)
- {
- /* add ATS */
- _pb_data_add(&pb_current,
- &data_ptr,
- job->segment_len,
- ((unsigned char *)&job->mf_header1) + 2, /* little endian !!! */
- 4,
- MACFRAME_TO_PB); /* we are in little endian for simulator... */
- }
- }
-
- /* check if mac data must be separated into 2 parts (circular buffer rollover) */
- if((job->eth_buffer_mask != 0)
- && (job->data_addr + job->data_len >= ETH_BUFFER_ADDR(job) + ETH_BUFFER_SIZE(job)))
- {
- _pb_data_add(&pb_current, &data_ptr, job->segment_len, job->data_addr, ETH_BUFFER_ADDR(job) + ETH_BUFFER_SIZE(job) - job->data_addr, MACFRAME_TO_PB);
- if(!job->crc_error)
- ctx->icv_current =
- bridgedma_crc_compute_continue_block(
- &ctx->crc_ctx,
- ctx->icv_current,
- job->data_addr,
- ETH_BUFFER_ADDR(job) + ETH_BUFFER_SIZE(job)
- - job->data_addr);
- _pb_data_add(&pb_current, &data_ptr, job->segment_len, job->data_addr, ((unsigned long)(job->data_addr) + job->data_len) & ETH_BUFFER_MASK(job), MACFRAME_TO_PB);
- if(!job->crc_error)
- ctx->icv_current =
- bridgedma_crc_compute_continue_block(
- &ctx->crc_ctx,
- ctx->icv_current,
- job->data_addr,
- ((unsigned long)(job->data_addr) + job->data_len)
- & ETH_BUFFER_MASK(job));
- }
- else
- {
- _pb_data_add(&pb_current, &data_ptr, job->segment_len, job->data_addr, job->data_len, MACFRAME_TO_PB);
- if(!job->crc_error)
- ctx->icv_current =
- bridgedma_crc_compute_continue_block(
- &ctx->crc_ctx,
- ctx->icv_current,
- job->data_addr, job->data_len);
- }
- if(job->crc_store)
- {
- /* add crc */
- if(!job->crc_error)
- icv_final = crc_compute_end(
- &ctx->crc_ctx,
- ctx->icv_current);
- else
- icv_final = ctx->icv_substitution;
- _pb_data_add(&pb_current, &data_ptr, job->segment_len, (unsigned char *)&icv_final, 4, MACFRAME_TO_PB); /* we are in little endian for simulator... */
- }
- if(job->append_zero)
- {
- /* add zeroed padding */
- memset(data_ptr, '\0', job->segment_len - (data_ptr - pb_current->data));
- }
- }
- else /* job->direction != 0 */
- {
- /* reassembly processing */
- if(job->header_len > 0)
- {
- /* get the mac frame header */
- _pb_data_add(&pb_current,
- &data_ptr,
- job->segment_len,
- (unsigned char *)&job->mf_header1, /* little endian !!! */
- 2,
- PB_TO_MACFRAME); /* we are in little endian for simulator... */
- if(job->header_len == 6)
- {
- /* add ATS */
- _pb_data_add(&pb_current,
- &data_ptr,
- job->segment_len,
- ((unsigned char *)&job->mf_header1) + 2, /* little endian */
- 4,
- PB_TO_MACFRAME); /* we are in little endian for simulator... */
- }
- }
-
- /* check if mac data must be separated into 2 parts (circular buffer rollover) */
- if((job->eth_buffer_mask != 0)
- && (job->data_addr + job->data_len >= ETH_BUFFER_ADDR(job) + ETH_BUFFER_SIZE(job)))
- {
- _pb_data_add(&pb_current, &data_ptr, job->segment_len, job->data_addr, ETH_BUFFER_ADDR(job) + ETH_BUFFER_SIZE(job) - job->data_addr, PB_TO_MACFRAME);
- ctx->icv_current =
- bridgedma_crc_compute_continue_block(
- &ctx->crc_ctx,
- ctx->icv_current,
- job->data_addr,
- ETH_BUFFER_ADDR(job) + ETH_BUFFER_SIZE(job)
- - job->data_addr);
- _pb_data_add(&pb_current, &data_ptr, job->segment_len, (unsigned char *)((unsigned long)job->data_addr & ~ETH_BUFFER_MASK(job)), ((unsigned long)(job->data_addr) + job->data_len) & ETH_BUFFER_MASK(job), PB_TO_MACFRAME);
- ctx->icv_current =
- bridgedma_crc_compute_continue_block(
- &ctx->crc_ctx,
- ctx->icv_current,
- (unsigned char *)((unsigned long)job->data_addr & ~ETH_BUFFER_MASK(job)), ((unsigned long)(job->data_addr) + job->data_len) & ETH_BUFFER_MASK(job));
- }
- else
- {
- _pb_data_add(&pb_current, &data_ptr, job->segment_len, job->data_addr, job->data_len, PB_TO_MACFRAME);
- ctx->icv_current =
- bridgedma_crc_compute_continue_block(
- &ctx->crc_ctx,
- ctx->icv_current,
- job->data_addr,
- job->data_len);
- }
- if(job->crc_store)
- {
- /* check crc */
- icv_final = crc_compute_end(
- &ctx->crc_ctx,
- ctx->icv_current);
- _pb_data_add(&pb_current, &data_ptr, job->segment_len, (unsigned char *)&icv_compare, 4, PB_TO_MACFRAME); /* we are in little endian for simulator... */
- job->crc_error = (icv_compare != icv_final);
- }
- }
-
- /* Any job to process after ? */
- if (!ctx->job_current->next)
- ctx->status.running = false;
-
- if(ctx->job_current->job_it)
- {
- *ecos_enable_it |= BRIDGEDMA_ECOS_IT_MASK;
- cyg_interrupt_unmask(BRIDGEDMA_ECOS_IT);
-
-#ifndef __sparc__
- cyg_hal_sys_kill (cyg_hal_sys_getpid(), CYG_HAL_SYS_SIGIO);
-#endif
- }
- ctx->job_current = ctx->job_current->next;
-
- return true;
-}
-
-
-/**
- * Enqueue and start a list of jobs.
- * \param ctx Bridge DMA context
- * \param job_first first job to enqueue
- * \param job_last last job to enqueue
- *
- * The new jobs are added to the Bridge DMA queue and the Bridge DMA is
- * restarted if it was stopped. The \c last flag must be set in the last
- * enqueued job.
- */
-void
-phy_bridgedma_start (phy_bridgedma_t *ctx, phy_bridgedma_job_t *job_first,
- phy_bridgedma_job_t *job_last)
-{
- dbg_assert(ctx);
- dbg_assert(job_first);
- dbg_assert(job_last);
-
- /* check current job processing */
- if(ctx->job_first == NULL)
- {
- /* no more job in queue */
- ctx->job_first = job_first;
- ctx->job_current = job_first;
- ctx->job_last = job_last;
- memset(&ctx->status, '\0', sizeof(phy_bridgedma_status_t));
- ctx->status.running = 1;
- }
- else
- {
- /* there are still job inside */
- dbg_assert(ctx->job_last);
- ctx->job_last->next = job_first;
- ctx->job_last = job_last;
- }
-
- /* Resume the bridge dma thread to process the jobs. */
- cyg_thread_resume (ctx->thread_handle);
-}
-
-void
-phy_bridgedma_proto_process (cyg_addrword_t data)
-{
- phy_bridgedma_t *bridgedma_ctx;
-
- dbg_assert (data);
- bridgedma_ctx = (phy_bridgedma_t *) data;
-
- while (true)
- {
- cyg_thread_yield();
- if (bridgedma_ctx->job_current)
- {
- _job_process(bridgedma_ctx, bridgedma_ctx->job_current);
-
- if (bridgedma_ctx->job_current == NULL)
- bridgedma_ctx->job_first = NULL;
- }
- else
- {
- /* refresh bridge dma status */
- bridgedma_ctx->status.running = 0;
- bridgedma_ctx->status.stop = 1;
-
- /* Stop the thread. */
- cyg_thread_suspend (bridgedma_ctx->thread_handle);
- }
- }
-}
-
-/**
- * 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)
-{
- dbg_assert (ctx);
-
- return ctx->job_current;
-}
-
-bool
-phy_bridgedma_status (phy_bridgedma_t *ctx)
-{
- dbg_assert (ctx);
- return ctx->status.running;
-}
diff --git a/cesar/hal/phy/test/bridgedma-soft/Makefile b/cesar/hal/phy/test/bridgedma-soft/Makefile
deleted file mode 100644
index 27600eecea..0000000000
--- a/cesar/hal/phy/test/bridgedma-soft/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-all: synth sparc
-
-synth:
- $(MAKE) -f synth-Makefile
-
-sparc:
- $(MAKE) -f sparc-Makefile
-
-debug: $(TARGET_PROGRAMS)
- $(CROSS_COMPILE)objdump -DSt $< > $<.dis
-
-clean:
- rm -rf obj
diff --git a/cesar/hal/phy/test/bridgedma-soft/sparc-Config b/cesar/hal/phy/test/bridgedma-soft/sparc-Config
deleted file mode 100644
index ddad644109..0000000000
--- a/cesar/hal/phy/test/bridgedma-soft/sparc-Config
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_BRIDGEDMA_SOFT = y
diff --git a/cesar/hal/phy/test/bridgedma-soft/sparc-Makefile b/cesar/hal/phy/test/bridgedma-soft/sparc-Makefile
deleted file mode 100644
index fa08193943..0000000000
--- a/cesar/hal/phy/test/bridgedma-soft/sparc-Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-BASE = ../../../..
-
-TARGET = sparc
-
-ECOS = y
-
-TARGET_PROGRAMS = test-bridgedma-proto \
- test-bridgedma-proto-tx \
- test-bridgedma-proto-rx \
- test-bridgedma-proto-crc
-
-test-bridgedma-proto_SOURCES = bridgedma-init-test.c
-test-bridgedma-proto_MODULES = hal/phy lib
-
-test-bridgedma-proto-tx_SOURCES = bridgedma-tx-test.c
-test-bridgedma-proto-tx_MODULES = hal/phy lib
-
-test-bridgedma-proto-rx_SOURCES = bridgedma-rx-test.c
-test-bridgedma-proto-rx_MODULES = hal/phy lib
-
-test-bridgedma-proto-crc_SOURCES = bridgedma-crc-test.c
-test-bridgedma-proto-crc_MODULES = hal/phy lib
-
-hal_phy_MODULE_SOURCES = bridgedma_soft.c
-VARIANT = sparc
-include $(BASE)/common/make/top.mk
-
-all: $(TARGET_PROGRAMS:%=obj/sparc/%.lst)
-
-%.lst: %.elf
- $(CROSS_COMPILE)objdump -DSt $< > $@
diff --git a/cesar/hal/phy/test/bridgedma-soft/sparc-ecos.ecc.sh b/cesar/hal/phy/test/bridgedma-soft/sparc-ecos.ecc.sh
deleted file mode 100644
index db2208c6cc..0000000000
--- a/cesar/hal/phy/test/bridgedma-soft/sparc-ecos.ecc.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-config=${1:-ecos-gen.ecc}
-ecosconfig --config=$config new sparc_leon default
-cat >> $config <<'EOF'
-EOF
-ecosconfig --config=$config check
diff --git a/cesar/hal/phy/test/bridgedma-soft/src/bridgedma-crc-test.c b/cesar/hal/phy/test/bridgedma-soft/src/bridgedma-crc-test.c
deleted file mode 100644
index c42bd975c4..0000000000
--- a/cesar/hal/phy/test/bridgedma-soft/src/bridgedma-crc-test.c
+++ /dev/null
@@ -1,359 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file bridgedma-init-test.c
- * \brief « brief description »
- * \ingroup « module »
- *
- * « long description »
- */
-#include <cyg/kernel/kapi.h>
-#include <cyg/hal/hal_arch.h>
-
-#include "common/std.h"
-#include "common/defs/ethernet.h"
-
-#include "lib/test.h"
-#include "lib/list.h"
-#include "lib/bitstream.h"
-
-#include "hal/phy/inc/bridgedma.h"
-#include "hal/phy/inc/bridgedma_soft.h"
-
-#include "mac/common/pb.h"
-
-#include <string.h>
-#include <stdio.h>
-#include <cyg/infra/diag.h>
-
-#define START_OFFSET 128
-
-
-cyg_thread my_test_thread;
-cyg_handle_t my_test_thread_handle;
-u8 my_test_thread_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];
-
-pb_t *my_pb_first;
-pb_t *my_pb_last;
-phy_bridgedma_job_t *job_current;
-
-phy_bridgedma_job_t job1;
-phy_bridgedma_t *bridgedma_ctx;
-u8 frame_buffer [2048] __attribute__((aligned(2048)));
-crc_t crc_ctx;
-blk_t *pb_first, *pb_last, *pb_current;
-u32 mf_header;
-u32 enc_tab[256];
-uint ats;
-
-/* WARNING: callback are not possible to test inside UNIT TEST */
-bool _bridgedma_segmentation_cb(void *data, u32 status)
-{
- // If no more jobs to process by the bridgedma wake up the test thread to
- // continue
- if (!job_current)
- {
- cyg_thread_resume (my_test_thread_handle);
- }
-
- if (job_current)
- {
- diag_printf ("----- Bridge Cb ----\n");
- diag_printf ("SSN : %d\n",
- ((pb_t*)job_current->first_pb_desc)->header.ssn);
- diag_printf ("offset : %d\n", job_current->first_pb_offset);
- diag_printf ("length : %d\n", read_u16_from_word
- (((pb_t *)job_current->first_pb_desc)->data +
- job_current->first_pb_offset) >> 2);
- diag_printf ("---- END Bridge Cb ----\n");
- }
-
- job_current = job_current->next;
- return true;
-}
-
-/* WARNING: callback are not possible to test inside UNIT TEST */
-void _bridgedma_deffered_cb(void *data)
-{
-}
-
-void bridgedma_init_test_case(test_t t)
-{
- int user_data;
-
- test_case_begin(t, "init");
-
- test_begin(t, "init")
- {
- bridgedma_ctx = NULL;
- bridgedma_ctx = phy_bridgedma_init(&user_data, _bridgedma_segmentation_cb, _bridgedma_deffered_cb);
- test_fail_unless(
- (bridgedma_ctx != NULL)
- && (bridgedma_ctx->job_first == NULL)
- && (bridgedma_ctx->job_current == NULL)
- && (bridgedma_ctx->job_last == NULL)
- && (bridgedma_ctx->user_data == &user_data)
- && (bridgedma_ctx->bridgedma_cb == _bridgedma_segmentation_cb)
- && (bridgedma_ctx->deferred_cb == _bridgedma_deffered_cb)
- && !bridgedma_ctx->status.running
- && bridgedma_ctx->status.stop
- );
- } test_end;
- return;
-}
-
-void bridgedma_segmentation_test_case(test_t t)
-{
- uint i;
- pb_t *my_current;
- dbg_assert (bridgedma_ctx);
- test_case_begin(t, "segmentation");
-
- pb_first = blk_alloc_desc_range(4, &pb_last);
- pb_last->next = NULL;
-
- my_pb_first = (pb_t *) pb_first;
- my_pb_last = (pb_t *)pb_last;
-
- my_current = my_pb_first;
- for (i = 0; i < 4; i++)
- {
- my_current->header.ssn = i;
- my_current = my_current->next;
- }
-
- ats = 0x12345678;
-
- /************************************************************************
- * simple segmentation with 3 mac frames into 5 PBs
- * 1st mac frame: len=1518, offset=128, ATS, ICV into 1st to 4th PB
- * 2nd mac frame: len=64, ATS, ICV into 4th PB
- * 3nd mac frame: len=466, ATS, ICV, padding into 4th to 5th PB
- ***********************************************************************/
-
- memset(&job1, '\0', sizeof(job1));
- job1.next = NULL;
- job1.data_addr = frame_buffer;
- job1.header_len = 6;
- job1.data_len = ETH_PACKET_MAX_SIZE;
- job1.first_pb_desc = pb_first;
- job1.first_pb_offset = START_OFFSET;
- job1.segment_len = 512;
- job1.direction = 0;
- job1.crc_reset = 1;
- job1.crc_store = 1;
- job1.job_it = 1;
- job1.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
- job1.mf_header1 = (((job1.data_len + 4 - 1) << 2) | 0x02) | (ats << 16); /* Payload + ATS */
- job1.mf_header2 = (ats >> 16);
-
- job_current = &job1;
- phy_bridgedma_start (bridgedma_ctx, &job1, &job1);
-
- return;
-}
-
-void
-bridgedma_segmentation_crc_verify_test_case (test_t test)
-{
- uint payload_cnt;
- uint crc_current;
- pb_t *my_pb_current;
-
- uint i;
- uint length;
- uint pb_offset;
- uint qte_pb;
- uint frame_offset;
- bool cont;
-
- 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_begin(test, "segmentation of 1 frames")
- {
- for (i = 0, my_pb_current = my_pb_first; my_pb_current; my_pb_current =
- my_pb_current->next, i++)
- {
- test_fail_if (my_pb_current->header.ssn != i, "Wong sequence");
- }
-
- /* check pb content */
- /* check 1st mac frame into PB */
- payload_cnt = 0;
-
- pb_offset = START_OFFSET;
- job_current = &job1;
- frame_offset = 0;
- pb_current = pb_first;
-
- cont = true;
- 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;
-
- diag_printf ("Length read in pb : %d\n", length);
- diag_printf ("pb ssn : %d\n", ((pb_t *)pb_current)->header.ssn);
- diag_printf ("pb offset : %d\n", pb_offset);
- test_fail_unless (length == job_current->data_len,
- "Data length is wrong.");
-
- // Copy the data of the current pb.
-
- // Jump directly to the start of the payload.
- pb_offset += 6;
- if (length + pb_offset > BLK_SIZE)
- {
- test_fail_unless (
- bitstream_memcmp (frame_buffer + frame_offset,
- pb_current->data + pb_offset,
- BLK_SIZE - pb_offset),
- "data corrupted");
- frame_offset += BLK_SIZE - pb_offset;
- length -= BLK_SIZE - pb_offset;
- }
- else
- {
- test_fail_unless (
- bitstream_memcmp (frame_buffer + frame_offset,
- pb_current->data + pb_offset,
- length),
- "data corrupted");
- frame_offset += length;
- cont = false;
- }
-
-
- if (cont)
- {
- // Add 10 to the length to use the complete MF length
- // (ATS + MFH + ICV), the ATS and MFH are already include in the
- // pb_offset.
- for (qte_pb = (pb_offset + length + 4) / BLK_SIZE + 1;
- qte_pb;
- qte_pb --)
- {
- pb_current = pb_current->next;
-
- if (length > BLK_SIZE)
- {
- test_fail_unless(
- bitstream_memcmp (frame_buffer + frame_offset,
- pb_current->data ,
- BLK_SIZE),
- "data corrupted");
- length -= BLK_SIZE;
- frame_offset += BLK_SIZE;
- }
- else
- {
- test_fail_unless(
- bitstream_memcmp (frame_buffer + frame_offset,
- pb_current->data ,
- length),
- "data corrupted");
- frame_offset += length;
- }
- }
- }
-
- // The future offset is length + 4 cause of the ICV of the MF.
- // The ATS and the MFH has already been jumped above in the
- // pb_offset.
- pb_offset = (pb_offset + job_current->data_len + 4) % BLK_SIZE;
- } test_end;
-
- test_begin (test, "Verify CRC")
- {
- uint mf_length;
- uint offset;
- uint crc_pb;
- u8 buffer_reconstitute [2048] __attribute__((aligned(2048)));
-
- mf_length = (read_u16_from_word((u8 *) &job1.mf_header1)>> 2) + 3;
- offset = (job1.first_pb_offset + mf_length) % BLK_SIZE;
-
- crc_pb = read_u32_from_word (my_pb_last->data + offset);
-
- bitstream_memcpy (buffer_reconstitute, frame_buffer,
- ETH_PACKET_MAX_SIZE);
-
- crc_current = bridgedma_crc_compute_block (&crc_ctx, buffer_reconstitute,
- job1.data_len);
-
- diag_printf ("Data length = %d\n", mf_length);
- diag_printf ("ICV pos = %d\n", offset);
-
- diag_printf ("CRC pb = %x\n", crc_pb);
- diag_printf ("CRC frame = %x\n", crc_current);
- test_fail_if (crc_current != crc_pb, "Wrong CRC computed");
- }
- test_end;
-
- blk_release_desc_range((blk_t *)my_pb_first, (blk_t *) my_pb_last);
-}
-
-void
-test_thread_process (cyg_addrword_t data)
-{
- test_t *test;
-
- test = (test_t *) data;
-
- bridgedma_init_test_case (*test);
- bridgedma_segmentation_test_case (*test);
- bridgedma_segmentation_crc_verify_test_case (*test);
-
- phy_bridgedma_uninit (bridgedma_ctx);
-
- test_result (*test);
-
-#ifndef __sparc__
- HAL_PLATFORM_EXIT (test_nb_failed (*test) == 0 ? 0 : 1);
-#endif
-}
-
-int
-main (void)
-{
- test_t test;
- uint i;
-
- test_init (test, 0, NULL);
-
- pb_first = NULL;
- pb_last = NULL;
-
- my_pb_first = NULL;
- my_pb_last = 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;
-}
diff --git a/cesar/hal/phy/test/bridgedma-soft/src/bridgedma-init-test.c b/cesar/hal/phy/test/bridgedma-soft/src/bridgedma-init-test.c
deleted file mode 100644
index d228179036..0000000000
--- a/cesar/hal/phy/test/bridgedma-soft/src/bridgedma-init-test.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file bridgedma-init-test.c
- * \brief « brief description »
- * \ingroup « module »
- *
- * « long description »
- */
-#include <cyg/kernel/kapi.h>
-#include <cyg/hal/hal_arch.h>
-
-#include "common/std.h"
-#include "common/defs/ethernet.h"
-
-#include "lib/test.h"
-#include "lib/list.h"
-#include "lib/bitstream.h"
-
-#include "hal/phy/inc/bridgedma.h"
-#include "hal/phy/inc/bridgedma_soft.h"
-
-#include "mac/common/pb.h"
-
-#include <string.h>
-#include <stdio.h>
-#include <cyg/infra/diag.h>
-
-#define START_OFFSET 128
-
-cyg_thread my_test_thread;
-cyg_handle_t my_test_thread_handle;
-u8 my_test_thread_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];
-
-phy_bridgedma_t *bridgedma_ctx;
-
-/* WARNING: callback are not possible to test inside UNIT TEST */
-bool _bridgedma_segmentation_cb(void *data, u32 status)
-{
- return true;
-}
-
-/* WARNING: callback are not possible to test inside UNIT TEST */
-void _bridgedma_deffered_cb(void *data)
-{
-}
-
-void bridgedma_init_test_case(test_t t)
-{
- int user_data;
-
- test_case_begin(t, "init");
-
- test_begin(t, "init")
- {
- bridgedma_ctx = NULL;
- bridgedma_ctx = phy_bridgedma_init(&user_data, _bridgedma_segmentation_cb, _bridgedma_deffered_cb);
- test_fail_unless(
- (bridgedma_ctx != NULL)
- && (bridgedma_ctx->job_first == NULL)
- && (bridgedma_ctx->job_current == NULL)
- && (bridgedma_ctx->job_last == NULL)
- && (bridgedma_ctx->user_data == &user_data)
- && (bridgedma_ctx->bridgedma_cb == _bridgedma_segmentation_cb)
- && (bridgedma_ctx->deferred_cb == _bridgedma_deffered_cb)
- && !bridgedma_ctx->status.running
- && bridgedma_ctx->status.stop
- );
- } test_end;
- return;
-}
-
-void
-test_thread_process (cyg_addrword_t data)
-{
- test_t *test;
-
- test = (test_t *) data;
-
- bridgedma_init_test_case (*test);
- phy_bridgedma_uninit (bridgedma_ctx);
-
- test_result (*test);
-
-#ifndef __sparc__
- HAL_PLATFORM_EXIT (test_nb_failed (*test) == 0 ? 0 : 1);
-#endif
-}
-
-int
-main (void)
-{
- test_t test;
-
- test_init (test, 0, NULL);
-
- // 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;
-}
diff --git a/cesar/hal/phy/test/bridgedma-soft/src/bridgedma-rx-test.c b/cesar/hal/phy/test/bridgedma-soft/src/bridgedma-rx-test.c
deleted file mode 100644
index 890ac8a4db..0000000000
--- a/cesar/hal/phy/test/bridgedma-soft/src/bridgedma-rx-test.c
+++ /dev/null
@@ -1,310 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file bridgedma-init-test.c
- * \brief « brief description »
- * \ingroup « module »
- *
- * « long description »
- */
-#include <cyg/kernel/kapi.h>
-#include <cyg/hal/hal_arch.h>
-
-#include "common/std.h"
-#include "common/defs/ethernet.h"
-
-#include "lib/test.h"
-#include "lib/list.h"
-#include "lib/bitstream.h"
-
-#include "hal/phy/inc/bridgedma.h"
-#include "hal/phy/inc/bridgedma_soft.h"
-
-#include "mac/common/pb.h"
-
-#include <string.h>
-#include <stdio.h>
-#include <cyg/infra/diag.h>
-
-#define START_OFFSET 128
-
-cyg_thread my_test_thread;
-cyg_handle_t my_test_thread_handle;
-u8 my_test_thread_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];
-
-pb_t *my_pb_first;
-pb_t *my_pb_last;
-phy_bridgedma_job_t *job_current;
-
-phy_bridgedma_job_t job1, job2, job3;
-phy_bridgedma_t *bridgedma_ctx;
-u8 frame_buffer [2048] __attribute__((aligned(2048)));
-u8 eth_buffer [2048] __attribute__((aligned(2048)));
-
-crc_t crc_ctx;
-blk_t *pb_first, *pb_last, *pb_current;
-u32 mf_header;
-u32 enc_tab[256];
-uint ats;
-
-/* WARNING: callback are not possible to test inside UNIT TEST */
-bool _bridgedma_reassembly_cb(void *data, u32 status)
-{
- // If no more jobs to process by the bridgedma wake up the test thread to
- // continue
- if (!job_current)
- {
- cyg_thread_resume (my_test_thread_handle);
- }
-
- if (job_current)
- {
- diag_printf ("----- Bridge Cb ----\n");
- diag_printf ("SSN : %d\n",
- ((pb_t*)job_current->first_pb_desc)->header.ssn);
- diag_printf ("offset : %d\n", job_current->first_pb_offset);
- diag_printf ("length : %d\n", read_u16_from_word
- (((pb_t *)job_current->first_pb_desc)->data +
- job_current->first_pb_offset) >> 2);
- diag_printf ("---- END Bridge Cb ----\n");
- }
-
- job_current = job_current->next;
- return true;
-}
-
-/* WARNING: callback are not possible to test inside UNIT TEST */
-void _bridgedma_deffered_cb(void *data)
-{
-}
-
-void bridgedma_init_test_case(test_t t)
-{
- int user_data;
-
- test_case_begin(t, "init");
-
- test_begin(t, "init")
- {
- bridgedma_ctx = NULL;
- bridgedma_ctx = phy_bridgedma_init(&user_data, _bridgedma_reassembly_cb, _bridgedma_deffered_cb);
- test_fail_unless(
- (bridgedma_ctx != NULL)
- && (bridgedma_ctx->job_first == NULL)
- && (bridgedma_ctx->job_current == NULL)
- && (bridgedma_ctx->job_last == NULL)
- && (bridgedma_ctx->user_data == &user_data)
- && (bridgedma_ctx->bridgedma_cb == _bridgedma_reassembly_cb)
- && (bridgedma_ctx->deferred_cb == _bridgedma_deffered_cb)
- && !bridgedma_ctx->status.running
- && bridgedma_ctx->status.stop
- );
- } test_end;
- return;
-}
-
-void
-bridgedma_reassembly_test_case (test_t test)
-{
- uint user_data;
- uint data_cnt;
- uint payload_cnt;
- uint crc_current;
- uint data_bitstream;
- bitstream_t bitstream;
- test_case_begin(test, "reassembly");
-
- bridgedma_ctx = phy_bridgedma_init(&user_data, _bridgedma_reassembly_cb, _bridgedma_deffered_cb);
-
- pb_first = blk_alloc_desc_range(4, &pb_last);
- 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);
-
- /***********************************************************************
- * simple reassembly from 3 mac frames into 5 PBs
- * 1st mac frame: len=1024, mac-offset=1536, pb-offset=128, ATS, ICV into 1st to 3rd PB
- * 2nd : len=512, no-ATS, ICV into 3rd to 4th pb
- * 3rd : len=256, no-ATS, ICV, padding into 4th PB
- ***********************************************************************/
- pb_current = pb_first;
- data_cnt = START_OFFSET;
- payload_cnt = 0;
- crc_current = crc_compute_begin(&crc_ctx);
-
- bitstream_init (&bitstream, pb_current->data + data_cnt, 6,
- BITSTREAM_WRITE);
- data_bitstream = ((1024 + 4 - 1) << 2) | 0x02;
- bitstream_access (&bitstream, &data_bitstream, 16);
- data_bitstream = 0x12345678;
- bitstream_access (&bitstream, &data_bitstream, 32);
- bitstream_finalise (&bitstream);
- data_cnt += 2;
- crc_current = crc_compute_continue_block(&crc_ctx, crc_current, pb_current->data + data_cnt, 4);
- data_cnt += 4;
- bitstream_memcpy(pb_current->data + data_cnt, frame_buffer, 512 - data_cnt);
- payload_cnt += 512 - data_cnt;
- pb_current = pb_current->next;
- bitstream_memcpy(pb_current->data, frame_buffer + payload_cnt, 512);
- payload_cnt += 512;
- pb_current = pb_current->next;
- bitstream_memcpy(pb_current->data, frame_buffer + payload_cnt, 1024 - payload_cnt);
- data_cnt = 1024 - payload_cnt;
- payload_cnt = 1024;
- data_cnt += 4;
-
- data_bitstream = ((512 - 1) << 2) | 0x01;
- bitstream_init (&bitstream, pb_current->data + data_cnt, 6,
- BITSTREAM_WRITE);
- bitstream_access (&bitstream, &data_bitstream, 16);
- bitstream_finalise (&bitstream);
-
- data_cnt += 2;
- bitstream_memcpy(pb_current->data + data_cnt, frame_buffer + payload_cnt, 512 - data_cnt);
- payload_cnt += 512 - data_cnt;
- pb_current = pb_current->next;
- bitstream_memcpy(pb_current->data, frame_buffer + payload_cnt, 1024 + 512 - payload_cnt);
- data_cnt = 1024 + 512 - payload_cnt;
- payload_cnt = 1024 + 512;
- data_cnt += 4;
-
- bitstream_init (&bitstream, pb_current->data + data_cnt, 2,
- BITSTREAM_WRITE);
- data_bitstream = ((256 - 1) << 2) | 0x01;
- bitstream_access (&bitstream, &data_bitstream, 16);
- bitstream_finalise (&bitstream);
- data_cnt += 2;
- bitstream_memcpy(pb_current->data + data_cnt, frame_buffer + payload_cnt, 256);
- payload_cnt += 256;
- data_cnt += 256;
- data_cnt += 4;
-
- memset(pb_current->data + data_cnt, '\0', 512 - data_cnt);
-
- /* prepare jobs */
- memset(&job1, '\0', sizeof(job1));
- job1.next = &job2;
- job1.data_addr = eth_buffer + 1536;
- job1.header_len = 6;
- job1.data_len = 1024;
- job1.first_pb_desc = pb_first;
- job1.first_pb_offset = START_OFFSET;
- job1.segment_len = 512;
- job1.direction = 1;
- job1.crc_reset = 1;
- job1.crc_store = 1;
- job1.job_it = 1;
- job1.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
-
- memset(&job2, '\0', sizeof(job2));
- job2.next = &job3;
- job2.data_addr = eth_buffer + 512;
- job2.header_len = 2;
- job2.data_len = 512;
- job2.first_pb_desc = pb_first->next->next; /* 3rd PB */
- job2.first_pb_offset = (START_OFFSET + job1.data_len + 10) % 512;
- job2.segment_len = 512;
- job2.direction = 1;
- job2.crc_reset = 1;
- job3.crc_store = 1;
- job2.job_it = 1;
- job2.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
-
- memset(&job3, '\0', sizeof(job3));
- job3.next = NULL;
- job3.data_addr = eth_buffer + 1024;
- job3.header_len = 2;
- job3.data_len = 256;
- job3.first_pb_desc = pb_first->next->next->next; /* 4th PB */
- job3.first_pb_offset = (START_OFFSET + job1.data_len + 10 + job2.data_len + 6) % 512;
- job3.segment_len = 512;
- job3.last = 1;
- job3.direction = 1;
- job3.crc_reset = 1;
- job3.crc_store = 1;
- job3.job_it = 1;
- job3.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
-
- job_current = &job1;
- phy_bridgedma_start(bridgedma_ctx, &job1, &job3);
-}
-
-void
-bridgedma_reassembly_verify_test_case (test_t test)
-{
- test_begin (test, "Verify data.")
- {
- test_fail_unless (!bitstream_memcmp (eth_buffer, frame_buffer,
- sizeof(frame_buffer)));
- }
- test_end;
-}
-
-
-void
-test_thread_process (cyg_addrword_t data)
-{
- test_t *test;
- uint i;
-
- for (i = 0; i < sizeof (frame_buffer); i++)
- {
- frame_buffer[i] = i;
- }
-
- test = (test_t *) data;
-
- bridgedma_init_test_case (*test);
-
- bridgedma_reassembly_test_case (*test);
- bridgedma_reassembly_verify_test_case (*test);
- phy_bridgedma_uninit (bridgedma_ctx);
-
- test_result (*test);
-
-#ifndef __sparc__
- HAL_PLATFORM_EXIT (test_nb_failed (*test) == 0 ? 0 : 1);
-#endif
-}
-
-int
-main (void)
-{
- test_t test;
- uint i;
-
- test_init (test, 0, NULL);
-
- pb_first = NULL;
- pb_last = NULL;
-
- my_pb_first = NULL;
- my_pb_last = 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;
-}
diff --git a/cesar/hal/phy/test/bridgedma-soft/src/bridgedma-tx-test.c b/cesar/hal/phy/test/bridgedma-soft/src/bridgedma-tx-test.c
deleted file mode 100644
index acaf6c27ac..0000000000
--- a/cesar/hal/phy/test/bridgedma-soft/src/bridgedma-tx-test.c
+++ /dev/null
@@ -1,381 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file bridgedma-init-test.c
- * \brief « brief description »
- * \ingroup « module »
- *
- * « long description »
- */
-#include <cyg/kernel/kapi.h>
-#include <cyg/hal/hal_arch.h>
-
-#include "common/std.h"
-#include "common/defs/ethernet.h"
-
-#include "lib/test.h"
-#include "lib/list.h"
-#include "lib/bitstream.h"
-
-#include "hal/phy/inc/bridgedma.h"
-#include "hal/phy/inc/bridgedma_soft.h"
-
-#include "mac/common/pb.h"
-
-#include <string.h>
-#include <stdio.h>
-#include <cyg/infra/diag.h>
-
-#define START_OFFSET 128
-
-cyg_thread my_test_thread;
-cyg_handle_t my_test_thread_handle;
-u8 my_test_thread_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];
-
-pb_t *my_pb_first;
-pb_t *my_pb_last;
-phy_bridgedma_job_t *job_current;
-
-phy_bridgedma_job_t job1, job2, job3;
-phy_bridgedma_t *bridgedma_ctx;
-u8 frame_buffer [2048] __attribute__((aligned(2048)));
-crc_t crc_ctx;
-blk_t *pb_first, *pb_last, *pb_current;
-u32 mf_header;
-u32 enc_tab[256];
-uint ats;
-
-/* WARNING: callback are not possible to test inside UNIT TEST */
-bool _bridgedma_segmentation_cb(void *data, u32 status)
-{
- // If no more jobs to process by the bridgedma wake up the test thread to
- // continue
- if (!job_current)
- {
- cyg_thread_resume (my_test_thread_handle);
- }
-
- if (job_current)
- {
- diag_printf ("----- Bridge Cb ----\n");
- diag_printf ("SSN : %d\n",
- ((pb_t*)job_current->first_pb_desc)->header.ssn);
- diag_printf ("offset : %d\n", job_current->first_pb_offset);
- diag_printf ("length : %d\n", read_u16_from_word
- (((pb_t *)job_current->first_pb_desc)->data +
- job_current->first_pb_offset) >> 2);
- diag_printf ("---- END Bridge Cb ----\n");
- }
-
- job_current = job_current->next;
- return true;
-}
-
-/* WARNING: callback are not possible to test inside UNIT TEST */
-void _bridgedma_deffered_cb(void *data)
-{
-}
-
-void bridgedma_init_test_case(test_t t)
-{
- int user_data;
-
- test_case_begin(t, "init");
-
- test_begin(t, "init")
- {
- bridgedma_ctx = NULL;
- bridgedma_ctx = phy_bridgedma_init(&user_data, _bridgedma_segmentation_cb, _bridgedma_deffered_cb);
- test_fail_unless(
- (bridgedma_ctx != NULL)
- && (bridgedma_ctx->job_first == NULL)
- && (bridgedma_ctx->job_current == NULL)
- && (bridgedma_ctx->job_last == NULL)
- && (bridgedma_ctx->user_data == &user_data)
- && (bridgedma_ctx->bridgedma_cb == _bridgedma_segmentation_cb)
- && (bridgedma_ctx->deferred_cb == _bridgedma_deffered_cb)
- && !bridgedma_ctx->status.running
- && bridgedma_ctx->status.stop
- );
- } test_end;
- return;
-}
-
-void bridgedma_segmentation_test_case(test_t t)
-{
- uint i;
- pb_t *my_current;
- dbg_assert (bridgedma_ctx);
- test_case_begin(t, "segmentation");
-
- pb_first = blk_alloc_desc_range(5, &pb_last);
- pb_last->next = NULL;
-
- my_pb_first = (pb_t *) pb_first;
- my_pb_last = (pb_t *)pb_last;
-
- my_current = my_pb_first;
- for (i = 0; i < 5; i++)
- {
- my_current->header.ssn = i;
- my_current = my_current->next;
- }
-
- 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);
- ats = 0x12345678;
-
- /************************************************************************
- * simple segmentation with 3 mac frames into 5 PBs
- * 1st mac frame: len=1518, offset=128, ATS, ICV into 1st to 4th PB
- * 2nd mac frame: len=64, ATS, ICV into 4th PB
- * 3nd mac frame: len=466, ATS, ICV, padding into 4th to 5th PB
- ***********************************************************************/
-
- memset(&job1, '\0', sizeof(job1));
- job1.next = &job2;
- job1.data_addr = frame_buffer;
- job1.header_len = 6;
- job1.data_len = ETH_PACKET_MAX_SIZE;
- job1.first_pb_desc = pb_first;
- job1.first_pb_offset = START_OFFSET;
- job1.segment_len = 512;
- job1.direction = 0;
- job1.crc_reset = 1;
- job1.crc_store = 1;
- job1.job_it = 1;
- job1.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
- job1.mf_header1 = (((job1.data_len + 4 - 1) << 2) | 0x02) | (ats << 16); /* Payload + ATS */
- job1.mf_header2 = (ats >> 16);
-
- memset(&job2, '\0', sizeof(job2));
- job2.next = &job3;
- job2.data_addr = frame_buffer + job1.data_len;
- job2.header_len = 6;
- job2.data_len = ETH_PACKET_MIN_SIZE;
- job2.first_pb_desc = pb_first->next->next->next; /* 4th PB */
- job2.first_pb_offset = (START_OFFSET + job1.data_len + 10) % 512;
- job2.segment_len = 512;
- job2.direction = 0;
- job2.crc_reset = 1;
- job2.crc_store = 1;
- job2.job_it = 1;
- job2.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
- job2.mf_header1 = (((job2.data_len + 4 - 1) << 2) | 0x02) | (ats << 16); /* Payload + ATS */
- job2.mf_header2 = (ats >> 16);
-
- memset(&job3, '\0', sizeof(job3));
- job3.next = NULL;
- job3.data_addr = frame_buffer + job1.data_len + job2.data_len;
- job3.header_len = 6;
- job3.data_len = sizeof(frame_buffer) - ETH_PACKET_MAX_SIZE - ETH_PACKET_MIN_SIZE;
- job3.first_pb_desc = pb_first->next->next->next; /* 4th PB */
- job3.first_pb_offset = (START_OFFSET + job1.data_len + 10 + job2.data_len + 10) % 512;
- job3.segment_len = 512;
- job3.last = 1;
- job3.direction = 0;
- job3.crc_reset = 1;
- job3.crc_store = 1;
- job3.append_zero = 1;
- job3.job_it = 1;
- job3.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
- job3.mf_header1 = (((job3.data_len + 4 - 1) << 2) | 0x02) | (ats << 16); /* Payload + ATS */
- job3.mf_header2 = (ats >> 16);
-
- job_current = &job1;
- phy_bridgedma_start (bridgedma_ctx, &job1, &job3);
-
- return;
-}
-
-void
-bridgedma_segmentation_verify_test_case (test_t test)
-{
- uint payload_cnt;
- uint crc_current;
- pb_t *my_pb_current;
-
- uint i;
- uint length;
- uint pb_offset;
- uint qte_pb;
- uint frame_offset;
- bool cont;
-
- test_begin(test, "segmentation of 3 frames")
- {
- for (i = 0, my_pb_current = my_pb_first; my_pb_current; my_pb_current =
- my_pb_current->next, i++)
- {
- test_fail_if (my_pb_current->header.ssn != i, "Wong sequence");
- }
-
- /* check pb content */
- /* check 1st mac frame into PB */
- payload_cnt = 0;
- crc_current = crc_compute_begin(&crc_ctx);
-
- pb_offset = START_OFFSET;
- job_current = &job1;
- frame_offset = 0;
- for (pb_current = pb_first, i = 0; i < 3; i++, job_current =
- job_current->next)
- {
- cont = true;
- 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;
-
- diag_printf ("Length read in pb : %d\n", length);
- diag_printf ("pb ssn : %d\n", ((pb_t *)pb_current)->header.ssn);
- diag_printf ("pb offset : %d\n", pb_offset);
- test_fail_unless (length == job_current->data_len,
- "Data length is wrong.");
-
- // Copy the data of the current pb.
-
- // Jump directly to the start of the payload.
- pb_offset += 6;
- if (length + pb_offset > BLK_SIZE)
- {
- test_fail_unless (
- bitstream_memcmp (frame_buffer + frame_offset,
- pb_current->data + pb_offset,
- BLK_SIZE - pb_offset),
- "data corrupted");
-
- frame_offset += BLK_SIZE - pb_offset;
- length -= BLK_SIZE - pb_offset;
- }
- else
- {
- test_fail_unless (
- bitstream_memcmp (frame_buffer + frame_offset,
- pb_current->data + pb_offset,
- length),
- "data corrupted");
-
- frame_offset += length;
- cont = false;
- }
-
-
- if (cont)
- {
- // Add 10 to the length to use the complete MF length
- // (ATS + MFH + ICV), the ATS and MFH are already include in the
- // pb_offset.
- for (qte_pb = (pb_offset + length + 4) / BLK_SIZE + 1;
- qte_pb;
- qte_pb --)
- {
- pb_current = pb_current->next;
-
- if (length > BLK_SIZE)
- {
- test_fail_unless(
- bitstream_memcmp (frame_buffer + frame_offset,
- pb_current->data ,
- BLK_SIZE),
- "data corrupted");
-
- length -= BLK_SIZE;
- frame_offset += BLK_SIZE;
- }
- else
- {
- test_fail_unless(
- bitstream_memcmp (frame_buffer + frame_offset,
- pb_current->data ,
- length),
- "data corrupted");
-
- frame_offset += length;
- }
- }
- }
-
- // The futur offset is length + 4 cause of the ICV of the MF.
- // The ATS and the MFH has already been jumped above in the
- // pb_offset.
- pb_offset = (pb_offset + job_current->data_len + 4) % BLK_SIZE;
- }
- } test_end;
-
- blk_release_desc_range((blk_t *)my_pb_first, (blk_t *) my_pb_last);
-}
-
-void
-test_thread_process (cyg_addrword_t data)
-{
- test_t *test;
-
- test = (test_t *) data;
-
- bridgedma_init_test_case (*test);
-
- bridgedma_segmentation_test_case (*test);
-
-
- /* Just to test. */
- diag_printf ("Job 1 header : %x\n", job1.mf_header1);
- diag_printf ("Job 2 header : %x\n", job2.mf_header1);
- diag_printf ("Job 3 header : %x\n", job3.mf_header1);
-
- /* */
-
- bridgedma_segmentation_verify_test_case (*test);
-
- phy_bridgedma_uninit (bridgedma_ctx);
-
- test_result (*test);
-
-#ifndef __sparc__
- HAL_PLATFORM_EXIT (test_nb_failed (*test) == 0 ? 0 : 1);
-#endif
-}
-
-int
-main (void)
-{
- test_t test;
- uint i;
-
- test_init (test, 0, NULL);
-
- pb_first = NULL;
- pb_last = NULL;
-
- my_pb_first = NULL;
- my_pb_last = 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;
-}
diff --git a/cesar/hal/phy/test/bridgedma-soft/src/data.c b/cesar/hal/phy/test/bridgedma-soft/src/data.c
deleted file mode 100644
index 636bf51fce..0000000000
--- a/cesar/hal/phy/test/bridgedma-soft/src/data.c
+++ /dev/null
@@ -1,545 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file bridgedma-init-test.c
- * \brief « brief description »
- * \ingroup « module »
- *
- * « long description »
- */
-#include <cyg/kernel/kapi.h>
-#include <cyg/hal/hal_arch.h>
-
-#include "common/std.h"
-#include "common/defs/ethernet.h"
-
-#include "lib/test.h"
-#include "lib/list.h"
-
-#include "hal/phy/inc/bridgedma.h"
-#include "hal/phy/inc/bridgedma_proto.h"
-
-#include "mac/common/pb.h"
-
-#include <string.h>
-#include <stdio.h>
-#include <cyg/infra/diag.h>
-
-#define START_OFFSET 128
-
-cyg_thread my_test_thread;
-cyg_handle_t my_test_thread_handle;
-u8 my_test_thread_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];
-
-pb_t *my_pb_first;
-pb_t *my_pb_last;
-phy_bridgedma_job_t *job_current;
-
-phy_bridgedma_job_t job1, job2, job3;
-phy_bridgedma_t *bridgedma_ctx;
-u8 frame_buffer [2048] __attribute__((aligned(2048)));
-crc_t crc_ctx;
-blk_t *pb_first, *pb_last, *pb_current;
-u32 mf_header;
-u32 enc_tab[256];
-uint ats;
-
-/* WARNING: callback are not possible to test inside UNIT TEST */
-bool _bridgedma_segmentation_cb(void *data, u32 status)
-{
- job_current = job_current->next;
-
- // If no more jobs to process by the bridgedma wake up the test thread to
- // continue
- if (!job_current)
- {
- cyg_thread_resume (my_test_thread_handle);
- }
-
- return true;
-}
-
-/* WARNING: callback are not possible to test inside UNIT TEST */
-void _bridgedma_deffered_cb(void *data)
-{
-}
-
-void bridgedma_init_test_case(test_t t)
-{
- int user_data;
-
- test_case_begin(t, "init");
-
- test_begin(t, "init")
- {
- bridgedma_ctx = NULL;
- bridgedma_ctx = phy_bridgedma_init(&user_data, _bridgedma_segmentation_cb, _bridgedma_deffered_cb);
- test_fail_unless(
- (bridgedma_ctx != NULL)
- && (bridgedma_ctx->job_first == NULL)
- && (bridgedma_ctx->job_current == NULL)
- && (bridgedma_ctx->job_last == NULL)
- && (bridgedma_ctx->user_data == &user_data)
- && (bridgedma_ctx->bridgedma_cb == _bridgedma_segmentation_cb)
- && (bridgedma_ctx->deferred_cb == _bridgedma_deffered_cb)
- && !bridgedma_ctx->status.running
- && bridgedma_ctx->status.stop
- );
- } test_end;
- return;
-}
-
-void bridgedma_segmentation_test_case(test_t t)
-{
- uint i;
- pb_t *my_current;
- dbg_assert (bridgedma_ctx);
- test_case_begin(t, "segmentation");
-
- pb_first = blk_alloc_desc_range(5, &pb_last);
- pb_last->next = NULL;
-
- my_pb_first = (pb_t *) pb_first;
- my_pb_last = (pb_t *)pb_last;
-
- my_current = my_pb_first;
- for (i = 0; i < 5; i++)
- {
- my_current->header.ssn = i;
- my_current = my_current->next;
- }
-
- 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);
- ats = 0x12345678;
-
- /************************************************************************
- * simple segmentation with 3 mac frames into 5 PBs
- * 1st mac frame: len=1518, offset=128, ATS, ICV into 1st to 4th PB
- * 2nd mac frame: len=64, ATS, ICV into 4th PB
- * 3nd mac frame: len=466, ATS, ICV, padding into 4th to 5th PB
- ***********************************************************************/
-
- memset(&job1, '\0', sizeof(job1));
- job1.next = &job2;
- job1.data_addr = frame_buffer;
- job1.header_len = 6;
- job1.data_len = ETH_PACKET_MAX_SIZE;
- job1.first_pb_desc = pb_first;
- job1.first_pb_offset = START_OFFSET;
- job1.segment_len = 512;
- job1.direction = 0;
- job1.crc_reset = 1;
- job1.crc_store = 1;
- job1.job_it = 1;
- job1.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
- job1.mf_header1 = (((job1.data_len + 4 - 1) << 2) | 0x02) | (ats << 16); /* Payload + ATS */
- job1.mf_header2 = (ats >> 16);
-
- memset(&job2, '\0', sizeof(job2));
- job2.next = &job3;
- job2.data_addr = frame_buffer + job1.data_len;
- job2.header_len = 6;
- job2.data_len = ETH_PACKET_MIN_SIZE;
- job2.first_pb_desc = pb_first->next->next->next; /* 4th PB */
- job2.first_pb_offset = (START_OFFSET + job1.data_len + 10) % 512;
- job2.segment_len = 512;
- job2.direction = 0;
- job2.crc_reset = 1;
- job2.crc_store = 1;
- job2.job_it = 1;
- job2.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
- job2.mf_header1 = (((job2.data_len + 4 - 1) << 2) | 0x02) | (ats << 16); /* Payload + ATS */
- job2.mf_header2 = (ats >> 16);
-
- memset(&job3, '\0', sizeof(job3));
- job3.next = NULL;
- job3.data_addr = frame_buffer + job1.data_len + job2.data_len;
- job3.header_len = 6;
- job3.data_len = sizeof(frame_buffer) - ETH_PACKET_MAX_SIZE - ETH_PACKET_MIN_SIZE;
- job3.first_pb_desc = pb_first->next->next->next; /* 4th PB */
- job3.first_pb_offset = (START_OFFSET + job1.data_len + 10 + job2.data_len + 10) % 512;
- job3.segment_len = 512;
- job3.last = 1;
- job3.direction = 0;
- job3.crc_reset = 1;
- job3.crc_store = 1;
- job3.append_zero = 1;
- job3.job_it = 1;
- job3.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
- job3.mf_header1 = (((job3.data_len + 4 - 1) << 2) | 0x02) | (ats << 16); /* Payload + ATS */
- job3.mf_header2 = (ats >> 16);
-
- job_current = &job1;
- phy_bridgedma_start (bridgedma_ctx, &job1, &job3);
-
-
-// /************************************************************
-// * icv substitution + no ATS + no interrupt
-// ************************************************************/
-// memset(&job1, '\0', sizeof(job1));
-// job1.next = NULL;
-// job1.data_addr = frame_buffer;
-// job1.header_len = 2;
-// job1.data_len = 256;
-// job1.first_pb_desc = pb_first;
-// job1.first_pb_offset = 0;
-// job1.segment_len = 512;
-// job1.last = 1;
-// job1.direction = 0;
-// job1.crc_error = 1;
-// job1.crc_reset = 1;
-// job1.crc_store = 1;
-// job1.append_zero = 1;
-// job1.job_it = 0;
-// job1.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
-// job1.mf_header1 = ((job1.data_len - 1) << 2) | 0x01; /* Payload */
-// bridgedma_ctx->proto_ctx.icv_substitution = 0xdeadbeef;
-// bridgedma_ctx->proto_ctx.icv_current = 0;
-//
-// test_begin(t, "icv substitution + no ATS + no interrupt")
-// {
-// phy_bridgedma_start(bridgedma_ctx, &job1, &job1);
-// pb_current = pb_first;
-// /* check for no ats */
-// mf_header = *((u32 *)(pb_current->data));
-// test_fail_unless(
-// ((u32) (mf_header & 0x0000ffff)
-// == (u32)((((unsigned int)job1.data_len - 1) << 2) | 0x01))
-// && !memcmp(pb_current->data + 2, frame_buffer, 256)
-// );
-// /* check for icv substitution */
-// mf_header = *((u32 *)(pb_current->data + 2 + 256));
-// test_fail_unless(
-// (mf_header == 0xdeadbeef)
-// );
-//
-// } test_end;
-//
-// phy_bridgedma_start(bridgedma_ctx, &job1, &job3);
-//
-// /***************************************************************
-// * no ATS + no ICV store + no append zero
-// ***************************************************************/
-//
-// memset(&job1, '\0', sizeof(job1));
-// job1.next = NULL;
-// job1.data_addr = frame_buffer;
-// job1.header_len = 2;
-// job1.data_len = 256;
-// job1.first_pb_desc = pb_first;
-// job1.first_pb_offset = 0;
-// job1.segment_len = 512;
-// job1.last = 1;
-// job1.direction = 0;
-// job1.crc_error = 1;
-// job1.crc_reset = 1;
-// job1.crc_store = 0;
-// job1.append_zero = 0;
-// job1.job_it = 1;
-// job1.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
-// job1.mf_header1 = ((job1.data_len - 1) << 2) | 0x01; /* Payload */
-// *(u32 *)(pb_first->data + 256 +2) = 0xdeadbeef;
-//
-// test_begin(t, "no icv store + no append zero for padding")
-// {
-// int i, total;
-// phy_bridgedma_start(bridgedma_ctx, &job1, &job1);
-// /* check for no icv */
-// test_fail_unless(
-// (*(u32 *)(pb_first->data + 256 +2) == 0xdeadbeef)
-// );
-// /* check no zero padding */
-// for(i = 256 + 2 + 4, total = 0; i < 512; i++)
-// {
-// total |= pb_first->data[i];
-// }
-// test_fail_unless(
-// (total != 0)
-// );
-// } test_end;
-//
-// blk_release_desc_range(pb_first, pb_last);
-
- return;
-}
-
-void
-bridgedma_segmentation_verify_test_case (test_t test)
-{
- uint payload_cnt;
- uint crc_current;
- pb_t *my_pb_current;
-
- uint i;
- uint length;
- uint pb_offset;
- uint qte_pb;
- uint frame_offset;
- bool cont;
-
- test_begin(test, "segmentation of 3 frames")
- {
- for (i = 0, my_pb_current = my_pb_first; my_pb_current; my_pb_current =
- my_pb_current->next, i++)
- {
- test_fail_if (my_pb_current->header.ssn != i, "Wong sequence");
- }
-
- /* check pb content */
- /* check 1st mac frame into PB */
- payload_cnt = 0;
- crc_current = crc_compute_begin(&crc_ctx);
-
- pb_offset = START_OFFSET;
- job_current = &job1;
- frame_offset = 0;
- for (pb_current = pb_first, i = 0; i < 3; i++, job_current =
- job_current->next)
- {
- cont = true;
- 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 == job_current->data_len,
- "Data length is wrong.");
-
- // Copy the data of the current pb.
-
- // Jump directly to the start of the payload.
- pb_offset += 6;
- if (length + pb_offset > BLK_SIZE)
- {
- test_fail_unless (
- !memcmp (frame_buffer + frame_offset,
- pb_current->data + pb_offset,
- BLK_SIZE - pb_offset),
- "data corrupted");
-
- frame_offset += BLK_SIZE - pb_offset;
- length -= BLK_SIZE - pb_offset;
- }
- else
- {
- test_fail_unless (
- !memcmp (frame_buffer + frame_offset,
- pb_current->data + pb_offset,
- length),
- "data corrupted");
-
- frame_offset += length;
- cont = false;
- }
-
-
- if (cont)
- {
- // Add 10 to the length to use the complete MF length
- // (ATS + MFH + ICV), the ATS and MFH are already include in the
- // pb_offset.
- for (qte_pb = (pb_offset + length + 4) / BLK_SIZE + 1;
- qte_pb;
- qte_pb --)
- {
- pb_current = pb_current->next;
-
- if (length > BLK_SIZE)
- {
- test_fail_unless(
- !memcmp (frame_buffer + frame_offset,
- pb_current->data ,
- BLK_SIZE),
- "data corrupted");
-
- length -= BLK_SIZE;
- frame_offset += BLK_SIZE;
- }
- else
- {
- test_fail_unless(
- !memcmp (frame_buffer + frame_offset,
- pb_current->data ,
- length),
- "data corrupted");
-
- frame_offset += length;
- }
- }
- }
-
- // The futur offset is length + 4 cause of the ICV of the MF.
- // The ATS and the MFH has already been jumped above in the
- // pb_offset.
- pb_offset = (pb_offset + job_current->data_len + 4) % BLK_SIZE;
- }
-
-/* data_cnt += 2;
- mf_header = *((u32 *)(pb_current->data + data_cnt));
- crc_current = crc_compute_continue_block(&crc_ctx, crc_current, (unsigned char *)&mf_header, 4);
- data_cnt += 4;
- test_fail_unless(
- !memcmp(pb_current->data + data_cnt, frame_buffer, 512 - data_cnt)
- );
- payload_cnt += 512 - data_cnt;
- data_cnt = 0;
- pb_current = pb_current->next;
- test_fail_unless(
- !memcmp(pb_current->data, frame_buffer + payload_cnt, 512)
- );
- payload_cnt += 512;
- pb_current = pb_current->next;
- test_fail_unless(
- !memcmp(pb_current->data, frame_buffer + payload_cnt, 512)
- );
- payload_cnt += 512;
- pb_current = pb_current->next;
- test_fail_unless(
- !memcmp(pb_current->data, frame_buffer + payload_cnt, ETH_PACKET_MAX_SIZE - payload_cnt)
- );
- data_cnt = ETH_PACKET_MAX_SIZE - payload_cnt;
- crc_current = crc_compute_continue_block(&crc_ctx, crc_current, frame_buffer, ETH_PACKET_MAX_SIZE);
- test_fail_unless(
- (*((u32 *)(pb_current->data + data_cnt)) == crc_compute_end(&crc_ctx, crc_current))
- );
- payload_cnt = ETH_PACKET_MAX_SIZE;
- data_cnt += 4;
- */
-
- /* check 2nd mac frame into PB */
- /*
- crc_current = crc_compute_begin(&crc_ctx);
- mf_header = *((u32 *)(pb_current->data + data_cnt));
- test_fail_unless(
- ((mf_header & 0x0000ffff) == (((ETH_PACKET_MIN_SIZE + 4 - 1) << 2) | 0x02))
- );
- data_cnt += 2;
- mf_header = *((u32 *)(pb_current->data + data_cnt));
- crc_current = crc_compute_continue_block(&crc_ctx, crc_current, (unsigned char *)&mf_header, 4);
- data_cnt += 4;
- test_fail_unless(
- !memcmp(pb_current->data + data_cnt, frame_buffer + payload_cnt, ETH_PACKET_MIN_SIZE)
- );
- data_cnt += ETH_PACKET_MIN_SIZE;
- crc_current = crc_compute_continue_block(&crc_ctx, crc_current, frame_buffer + ETH_PACKET_MAX_SIZE, ETH_PACKET_MIN_SIZE);
- test_fail_unless(
- (*((u32 *)(pb_current->data + data_cnt)) == crc_compute_end(&crc_ctx, crc_current))
- );
- payload_cnt += ETH_PACKET_MIN_SIZE;
- data_cnt += 4;
- */
-
- /* check 3rd mac frame into PB */
- /*
- crc_current = crc_compute_begin(&crc_ctx);
- mf_header = *((u32 *)(pb_current->data + data_cnt));
-
- test_fail_unless(
- ((mf_header & 0x0000ffff) == (((sizeof(frame_buffer) - ETH_PACKET_MAX_SIZE - ETH_PACKET_MIN_SIZE + 4 - 1) << 2) | 0x02))
- );
-
- data_cnt += 2;
- mf_header = *((u32 *)(pb_current->data + data_cnt));
- crc_current = crc_compute_continue_block(&crc_ctx, crc_current, (unsigned char *)&mf_header, 4);
- data_cnt += 4;
-
- test_fail_unless(
- !memcmp(pb_current->data + data_cnt, frame_buffer + payload_cnt, 512 - data_cnt)
- );
-
- payload_cnt += (512 - data_cnt);
- data_cnt = 0;
- pb_current = pb_current->next;
-
- test_fail_unless(
- !memcmp(pb_current->data, frame_buffer + payload_cnt, sizeof(frame_buffer) - payload_cnt)
- );
-
- data_cnt += sizeof(frame_buffer) - payload_cnt;
- crc_current = crc_compute_continue_block(&crc_ctx, crc_current, frame_buffer + ETH_PACKET_MAX_SIZE + ETH_PACKET_MIN_SIZE, sizeof(frame_buffer) - ETH_PACKET_MAX_SIZE - ETH_PACKET_MIN_SIZE);
-
- test_fail_unless(
- (*((u32 *)(pb_current->data + data_cnt)) == crc_compute_end(&crc_ctx, crc_current))
- );
-
- data_cnt += 4;
- */
-
- /* check if there is a zeroed padding */
- /*
- {
- int i, total;
- for(i = data_cnt, total = 0; i < 512; i++)
- total |= (pb_current->data[i]);
- test_fail_unless(
- (total == 0)
- );
- }
- */
- } test_end;
-
- blk_release_desc_range((blk_t *)my_pb_first, (blk_t *) my_pb_last);
-}
-
-void
-test_thread_process (cyg_addrword_t data)
-{
- test_t *test;
-
- test = (test_t *) data;
-
- bridgedma_init_test_case (*test);
-
- bridgedma_segmentation_test_case (*test);
- bridgedma_segmentation_verify_test_case (*test);
-
- phy_bridgedma_uninit (bridgedma_ctx);
-
- test_result (*test);
- HAL_PLATFORM_EXIT (test_nb_failed (*test) == 0 ? 0 : 1);
-}
-
-int
-main (void)
-{
- test_t test;
- uint i;
-
- test_init (test, 0, NULL);
-
- pb_first = NULL;
- pb_last = NULL;
-
- my_pb_first = NULL;
- my_pb_last = 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;
-}
diff --git a/cesar/hal/phy/test/bridgedma-soft/src/test_bridgedma.c_old b/cesar/hal/phy/test/bridgedma-soft/src/test_bridgedma.c_old
deleted file mode 100644
index 06ab4fe40e..0000000000
--- a/cesar/hal/phy/test/bridgedma-soft/src/test_bridgedma.c_old
+++ /dev/null
@@ -1,1003 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/phy/maximus/test/src/test_bridgedma.c
- * \brief HAL Phy Bridge DMA test functions for Maximus.
- * \ingroup hal_phy_maximus
- */
-
-#include "common/std.h"
-#include "lib/test.h"
-
-
-#include "hal/phy/maximus/inc/maximus_bridgedma_ctx.h"
-
-#define MAC_FRAME_MAX_LEN 1518
-#define MAC_FRAME_MIN_LEN 64
-#define START_OFFSET 128
-
-unsigned char frame_buffer[2048] __attribute__((aligned(2048)));
-unsigned char eth_buffer[2048] __attribute__((aligned(2048)));
-
-static int _buffer_random_fill(unsigned char *buffer, int length)
-{
- lib_rnd_t my_rnd;
- uint i;
-
- lib_rnd_init (&my_rnd, 0x81245452);
-
- for (i = 0; i < length; i++)
- {
- buffer[i] = lib_rnd32 (&my_rnd);
- }
-
- return i;
-}
-
-struct segmentation_cb_data
-{
- phy_bridgedma_job_t *job;
-};
-
-/* WARNING: callback are not possible to test inside UNIT TEST */
-static bool _bridgedma_segmentation_cb(void *data, uint32_t status)
-{
- int *counter;
- counter = (int *)data;
- counter++;
- return 0;
-}
-
-/* WARNING: callback are not possible to test inside UNIT TEST */
-static void _bridgedma_deffered_cb(void *data)
-{
- return;
-}
-
-void bridgedma_init_test_case(test_t t)
-{
- phy_bridgedma_t *bridgedma_ctx;
- int user_data;
-
- test_case_begin(t, "init");
-
- test_begin(t, "init")
- {
- bridgedma_ctx = NULL;
- bridgedma_ctx = phy_bridgedma_init(&user_data, _bridgedma_segmentation_cb, _bridgedma_deffered_cb);
- test_fail_unless(
- (bridgedma_ctx != NULL)
- && (bridgedma_ctx->job_first == NULL)
- && (bridgedma_ctx->job_current == NULL)
- && (bridgedma_ctx->job_last == NULL)
- && (bridgedma_ctx->user_data == &user_data)
- && (bridgedma_ctx->bridgedma_cb == _bridgedma_segmentation_cb)
- && (bridgedma_ctx->deferred_cb == _bridgedma_deffered_cb)
- && !bridgedma_ctx->status.running
- && bridgedma_ctx->status.stop
- );
- } test_end;
- return;
-}
-
-void bridgedma_pb_data_add_test_case(test_t t)
-{
- blk_t *pb_first, *pb_last, *pb_current;
- unsigned char frame_buffer[2048], copy_buffer[2048], *pb_data_ptr;
-
- test_case_begin(t, "pb_data_add");
-
- pb_first = blk_alloc_desc_range(3, &pb_last);
- pb_current = pb_first;
- pb_data_ptr = pb_first->data + 128;
- _buffer_random_fill(frame_buffer, sizeof(frame_buffer));
-
- /* adding 1280 bytes into 3 PBs with 1st PB offset=128 */
- test_begin(t, "adding 1280 bytes from mac-frame into 3 pbs")
- {
- _pb_data_add(&pb_current, &pb_data_ptr, 512, frame_buffer, 1280, MACFRAME_TO_PB);
- test_fail_unless(
- (pb_current == pb_last)
- && (pb_data_ptr == pb_last->data + 384)
- && !memcmp(pb_first->data + 128, frame_buffer, 384)
- && !memcmp(pb_first->next->data, frame_buffer + 512 - 128, 512)
- && !memcmp(pb_last->data, frame_buffer + 1024 - 128, 384)
- );
- } test_end;
-
- /* adding 1280 bytes into 3 PBs with 1st PB offset=128 */
- pb_current = pb_first;
- pb_data_ptr = pb_first->data + 128;
- memset(copy_buffer, '\0', sizeof(copy_buffer));
- test_begin(t, "adding 1280 bytes from 3 pbs into mac-frame")
- {
- _pb_data_add(&pb_current, &pb_data_ptr, 512, copy_buffer, 1280, PB_TO_MACFRAME);
- test_fail_unless(
- (pb_current == pb_last)
- && (pb_data_ptr == pb_last->data + 384)
- && !memcmp(copy_buffer, frame_buffer, 1280)
- );
- } test_end;
-
- blk_release_desc_range(pb_first, pb_last);
- return;
-}
-
-void bridgedma_segmentation_test_case(test_t t)
-{
- phy_bridgedma_job_t job1, job2, job3;
- phy_bridgedma_t *bridgedma_ctx;
- blk_t *pb_first, *pb_last, *pb_current;
- struct segmentation_cb_data bridgedma_data;
- sci_msg_hdr_t *sci_hdr;
- netclock_msg_hdr_t *netclock_hdr;
- unsigned char msg_buffer[256];
- int fd_in, fd_out, data_cnt, payload_cnt;
- tick_t end_of_dma_tck, max_end_of_dma_tck, min_end_of_dma_tck;
- uint32_t mf_header;
- u32 enc_tab[256];
- crc_t crc_ctx;
- unsigned long crc_current;
- time_t ats;
-
- test_case_begin(t, "segmentation");
-
- bridgedma_ctx = phy_bridgedma_init(&bridgedma_data, _bridgedma_segmentation_cb, _bridgedma_deffered_cb);
- pb_first = blk_alloc_desc_range(5, &pb_last);
- _buffer_random_fill(frame_buffer, sizeof(frame_buffer));
- 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);
- time(&ats);
-
- /************************************************************************
- * simple segmentation with 3 mac frames into 5 PBs
- * 1st mac frame: len=1518, offset=128, ATS, ICV into 1st to 4th PB
- * 2nd mac frame: len=64, ATS, ICV into 4th PB
- * 3nd mac frame: len=466, ATS, ICV, padding into 4th to 5th PB
- ***********************************************************************/
-
- memset(&job1, '\0', sizeof(job1));
- job1.next = &job2;
- job1.data_addr = frame_buffer;
- job1.header_len = 6;
- job1.data_len = MAC_FRAME_MAX_LEN;
- job1.first_pb_desc = pb_first;
- job1.first_pb_offset = START_OFFSET;
- job1.segment_len = 512;
- job1.direction = 0;
- job1.crc_reset = 1;
- job1.crc_store = 1;
- job1.job_it = 1;
- job1.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
- job1.mf_header1 = (((job1.data_len + 4 - 1) << 2) | 0x02) | (ats << 16); /* Payload + ATS */
- job1.mf_header2 = (ats >> 16);
-
- memset(&job2, '\0', sizeof(job2));
- job2.next = &job3;
- job2.data_addr = frame_buffer + job1.data_len;
- job2.header_len = 6;
- job2.data_len = MAC_FRAME_MIN_LEN;
- job2.first_pb_desc = pb_first->next->next->next; /* 4th PB */
- job2.first_pb_offset = (START_OFFSET + job1.data_len + 10) % 512;
- job2.segment_len = 512;
- job2.direction = 0;
- job2.crc_reset = 1;
- job2.crc_store = 1;
- job2.job_it = 0;
- job2.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
- job2.mf_header1 = (((job2.data_len + 4 - 1) << 2) | 0x02) | (ats << 16); /* Payload + ATS */
- job2.mf_header2 = (ats >> 16);
-
- memset(&job3, '\0', sizeof(job3));
- job3.next = NULL;
- job3.data_addr = frame_buffer + job1.data_len + job2.data_len;
- job3.header_len = 6;
- job3.data_len = sizeof(frame_buffer) - MAC_FRAME_MAX_LEN - MAC_FRAME_MIN_LEN;
- job3.first_pb_desc = pb_first->next->next->next; /* 4th PB */
- job3.first_pb_offset = (START_OFFSET + job1.data_len + 10 + job2.data_len + 10) % 512;
- job3.segment_len = 512;
- job3.last = 1;
- job3.direction = 0;
- job3.crc_reset = 1;
- job3.crc_store = 1;
- job3.append_zero = 1;
- job3.job_it = 1;
- job3.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
- job3.mf_header1 = (((job3.data_len + 4 - 1) << 2) | 0x02) | (ats << 16); /* Payload + ATS */
- job3.mf_header2 = (ats >> 16);
-
- test_begin(t, "segmentation of 3 frames")
- {
- phy_bridgedma_start(bridgedma_ctx, &job1, &job3);
-
- /* 1st job */
- test_fail_unless(
- (bridgedma_ctx->job_current == &job1)
- && bridgedma_ctx->status.running
- && !bridgedma_ctx->status.stop
- );
-
- /* 2nd job */
- test_fail_unless(
- (bridgedma_ctx->job_current == &job2)
- && bridgedma_ctx->status.running
- && !bridgedma_ctx->status.stop
- );
-
- /* 3rd job */
- test_fail_unless(
- (bridgedma_ctx->job_current == &job3)
- && bridgedma_ctx->status.running
- && !bridgedma_ctx->status.stop
- );
-
- /* check final status */
- test_fail_unless(
- !bridgedma_ctx->status.ahb_response_error
- && !bridgedma_ctx->status.running
- && bridgedma_ctx->status.stop
- );
-
- /* check pb content */
- /* check 1st mac frame into PB */
- pb_current = pb_first;
- data_cnt = START_OFFSET;
- payload_cnt = 0;
- crc_current = crc_compute_begin(&crc_ctx);
- mf_header = *((uint32_t *)(pb_current->data + data_cnt));
- test_fail_unless(
- ((mf_header & 0x0000ffff) == (((MAC_FRAME_MAX_LEN + 4 - 1) << 2) | 0x02))
- );
- data_cnt += 2;
- mf_header = *((uint32_t *)(pb_current->data + data_cnt));
- crc_current = crc_compute_continue_block(&crc_ctx, crc_current, (unsigned char *)&mf_header, 4);
- data_cnt += 4;
- test_fail_unless(
- !memcmp(pb_current->data + data_cnt, frame_buffer, 512 - data_cnt)
- );
- payload_cnt += 512 - data_cnt;
- data_cnt = 0;
- pb_current = pb_current->next;
- test_fail_unless(
- !memcmp(pb_current->data, frame_buffer + payload_cnt, 512)
- );
- payload_cnt += 512;
- pb_current = pb_current->next;
- test_fail_unless(
- !memcmp(pb_current->data, frame_buffer + payload_cnt, 512)
- );
- payload_cnt += 512;
- pb_current = pb_current->next;
- test_fail_unless(
- !memcmp(pb_current->data, frame_buffer + payload_cnt, MAC_FRAME_MAX_LEN - payload_cnt)
- );
- data_cnt = MAC_FRAME_MAX_LEN - payload_cnt;
- crc_current = crc_compute_continue_block(&crc_ctx, crc_current, frame_buffer, MAC_FRAME_MAX_LEN);
- test_fail_unless(
- (*((uint32_t *)(pb_current->data + data_cnt)) == crc_compute_end(&crc_ctx, crc_current))
- );
- payload_cnt = MAC_FRAME_MAX_LEN;
- data_cnt += 4;
-
- /* check 2nd mac frame into PB */
- crc_current = crc_compute_begin(&crc_ctx);
- mf_header = *((uint32_t *)(pb_current->data + data_cnt));
- test_fail_unless(
- ((mf_header & 0x0000ffff) == (((MAC_FRAME_MIN_LEN + 4 - 1) << 2) | 0x02))
- );
- data_cnt += 2;
- mf_header = *((uint32_t *)(pb_current->data + data_cnt));
- crc_current = crc_compute_continue_block(&crc_ctx, crc_current, (unsigned char *)&mf_header, 4);
- data_cnt += 4;
- test_fail_unless(
- !memcmp(pb_current->data + data_cnt, frame_buffer + payload_cnt, MAC_FRAME_MIN_LEN)
- );
- data_cnt += MAC_FRAME_MIN_LEN;
- crc_current = crc_compute_continue_block(&crc_ctx, crc_current, frame_buffer + MAC_FRAME_MAX_LEN, MAC_FRAME_MIN_LEN);
- test_fail_unless(
- (*((uint32_t *)(pb_current->data + data_cnt)) == crc_compute_end(&crc_ctx, crc_current))
- );
- payload_cnt += MAC_FRAME_MIN_LEN;
- data_cnt += 4;
-
- /* check 3rd mac frame into PB */
- crc_current = crc_compute_begin(&crc_ctx);
- mf_header = *((uint32_t *)(pb_current->data + data_cnt));
- test_fail_unless(
- ((mf_header & 0x0000ffff) == (((sizeof(frame_buffer) - MAC_FRAME_MAX_LEN - MAC_FRAME_MIN_LEN + 4 - 1) << 2) | 0x02))
- );
- data_cnt += 2;
- mf_header = *((uint32_t *)(pb_current->data + data_cnt));
- crc_current = crc_compute_continue_block(&crc_ctx, crc_current, (unsigned char *)&mf_header, 4);
- data_cnt += 4;
- test_fail_unless(
- !memcmp(pb_current->data + data_cnt, frame_buffer + payload_cnt, 512 - data_cnt)
- );
- payload_cnt += (512 - data_cnt);
- data_cnt = 0;
- pb_current = pb_current->next;
- test_fail_unless(
- !memcmp(pb_current->data, frame_buffer + payload_cnt, sizeof(frame_buffer) - payload_cnt)
- );
- data_cnt += sizeof(frame_buffer) - payload_cnt;
- crc_current = crc_compute_continue_block(&crc_ctx, crc_current, frame_buffer + MAC_FRAME_MAX_LEN + MAC_FRAME_MIN_LEN, sizeof(frame_buffer) - MAC_FRAME_MAX_LEN - MAC_FRAME_MIN_LEN);
- test_fail_unless(
- (*((uint32_t *)(pb_current->data + data_cnt)) == crc_compute_end(&crc_ctx, crc_current))
- );
- data_cnt += 4;
-
- /* check if there is a zeroed padding */
- {
- int i, total;
- for(i = data_cnt, total = 0; i < 512; i++)
- total |= (pb_current->data[i]);
- test_fail_unless(
- (total == 0)
- );
- }
- } test_end;
-
- /************************************************************
- * icv substitution + no ATS + no interrupt
- ************************************************************/
- memset(&job1, '\0', sizeof(job1));
- job1.next = NULL;
- job1.data_addr = frame_buffer;
- job1.header_len = 2;
- job1.data_len = 256;
- job1.first_pb_desc = pb_first;
- job1.first_pb_offset = 0;
- job1.segment_len = 512;
- job1.last = 1;
- job1.direction = 0;
- job1.crc_error = 1;
- job1.crc_reset = 1;
- job1.crc_store = 1;
- job1.append_zero = 1;
- job1.job_it = 0;
- job1.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
- job1.mf_header1 = ((job1.data_len - 1) << 2) | 0x01; /* Payload */
- bridgedma_ctx->icv_substitution = 0xdeadbeef;
- bridgedma_ctx->icv_current = 0;
-
- test_begin(t, "icv substitution + no ATS + no interrupt")
- {
- phy_bridgedma_start(bridgedma_ctx, &job1, &job1);
- pb_current = pb_first;
- test_fail_unless(
- (read(fd_in, msg_buffer, sizeof(sci_msg_hdr_t) + sizeof(netclock_msg_hdr_t)) == sizeof(sci_msg_hdr_t) + sizeof(netclock_msg_hdr_t))
- );
- /* check for no ats */
- mf_header = *((uint32_t *)(pb_current->data));
- test_fail_unless(
- ((mf_header & 0x0000ffff) == ((((unsigned int)job1.data_len - 1) << 2) | 0x01))
- && !memcmp(pb_current->data + 2, frame_buffer, 256)
- );
- /* check for icv substitution */
- mf_header = *((uint32_t *)(pb_current->data + 2 + 256));
- test_fail_unless(
- (mf_header == 0xdeadbeef)
- );
-
- } test_end;
-
- /***************************************************************
- * CRC reset !!!!!!!!!!!!!!!!
- ***************************************************************/
- /* not made yet */
-
- /***************************************************************
- * no ATS + no ICV store + no append zero
- ***************************************************************/
- _buffer_random_fill(pb_first->data, 512);
-
- memset(&job1, '\0', sizeof(job1));
- job1.next = NULL;
- job1.data_addr = frame_buffer;
- job1.header_len = 2;
- job1.data_len = 256;
- job1.first_pb_desc = pb_first;
- job1.first_pb_offset = 0;
- job1.segment_len = 512;
- job1.last = 1;
- job1.direction = 0;
- job1.crc_error = 1;
- job1.crc_reset = 1;
- job1.crc_store = 0;
- job1.append_zero = 0;
- job1.job_it = 1;
- job1.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
- job1.mf_header1 = ((job1.data_len - 1) << 2) | 0x01; /* Payload */
- *(uint32_t *)(pb_first->data + 256 +2) = 0xdeadbeef;
-
- test_begin(t, "no icv store + no append zero for padding")
- {
- int i, total;
- phy_bridgedma_start(bridgedma_ctx, &job1, &job1);
- test_fail_unless(
- (read(fd_in, msg_buffer, sizeof(sci_msg_hdr_t) + sizeof(netclock_msg_hdr_t)) == sizeof(sci_msg_hdr_t) + sizeof(netclock_msg_hdr_t))
- );
- /* check for no icv */
- test_fail_unless(
- (*(uint32_t *)(pb_first->data + 256 +2) == 0xdeadbeef)
- );
- /* check no zero padding */
- for(i = 256 + 2 + 4, total = 0; i < 512; i++)
- {
- total |= pb_first->data[i];
- }
- test_fail_unless(
- (total != 0)
- );
- } test_end;
-
- blk_release_desc_range(pb_first, pb_last);
-
- return;
-}
-
-struct reassembly_cb_data
-{
- phy_bridgedma_job_t *job;
-};
-
-static bool _bridgedma_reassembly_cb(void *data, uint32_t status)
-{
- return 0;
-}
-
-void bridgedma_reassembly_test_case(test_t t)
-{
- phy_bridgedma_job_t job1, job2, job3;
- phy_bridgedma_t *bridgedma_ctx;
- blk_t *pb_first, *pb_last, *pb_current;
- struct reassembly_cb_data bridgedma_data;
- sci_msg_hdr_t *sci_hdr;
- netclock_msg_hdr_t *netclock_hdr;
- unsigned char msg_buffer[256];
- int fd_in, fd_out, data_cnt, payload_cnt;
- tick_t end_of_dma_tck, max_end_of_dma_tck, min_end_of_dma_tck;
- u32 enc_tab[256];
- crc_t crc_ctx;
- unsigned long crc_current;
-
- test_case_begin(t, "reassembly");
-
- bridgedma_ctx = phy_bridgedma_init(&bridgedma_data, _bridgedma_reassembly_cb, _bridgedma_deffered_cb);
-
- pb_first = blk_alloc_desc_range(4, &pb_last);
- _buffer_random_fill(frame_buffer, sizeof(frame_buffer));
- 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);
-
- /***********************************************************************
- * simple reassembly from 3 mac frames into 5 PBs
- * 1st mac frame: len=1024, mac-offset=1536, pb-offset=128, ATS, ICV into 1st to 3rd PB
- * 2nd : len=512, no-ATS, ICV into 3rd to 4th pb
- * 3rd : len=256, no-ATS, ICV, padding into 4th PB
- ***********************************************************************/
- pb_current = pb_first;
- data_cnt = START_OFFSET;
- payload_cnt = 0;
- crc_current = crc_compute_begin(&crc_ctx);
- *(uint16_t *)(pb_current->data + data_cnt) = ((1024 + 4 - 1) << 2) | 0x02;
- data_cnt += 2;
- *(uint32_t *)(pb_current->data + data_cnt) = time(NULL);
- crc_current = crc_compute_continue_block(&crc_ctx, crc_current, pb_current->data + data_cnt, 4);
- data_cnt += 4;
- memcpy(pb_current->data + data_cnt, frame_buffer, 512 - data_cnt);
- payload_cnt += 512 - data_cnt;
- pb_current = pb_current->next;
- memcpy(pb_current->data, frame_buffer + payload_cnt, 512);
- payload_cnt += 512;
- pb_current = pb_current->next;
- memcpy(pb_current->data, frame_buffer + payload_cnt, 1024 - payload_cnt);
- data_cnt = 1024 - payload_cnt;
- payload_cnt = 1024;
- crc_current = crc_compute_continue_block(&crc_ctx, crc_current, frame_buffer, 1024);
- *(uint32_t *)(pb_current->data + data_cnt) = crc_compute_end(&crc_ctx, crc_current);
- data_cnt += 4;
-
- crc_current = crc_compute_begin(&crc_ctx);
- *(uint16_t *)(pb_current->data + data_cnt) = ((512 - 1) << 2) | 0x01;
- data_cnt += 2;
- memcpy(pb_current->data + data_cnt, frame_buffer + payload_cnt, 512 - data_cnt);
- payload_cnt += 512 - data_cnt;
- pb_current = pb_current->next;
- memcpy(pb_current->data, frame_buffer + payload_cnt, 1024 + 512 - payload_cnt);
- data_cnt = 1024 + 512 - payload_cnt;
- payload_cnt = 1024 + 512;
- crc_current = crc_compute_continue_block(&crc_ctx, crc_current, frame_buffer + 1024, 512);
- *(uint32_t *)(pb_current->data + data_cnt) = crc_compute_end(&crc_ctx, crc_current);
- data_cnt += 4;
-
- crc_current = crc_compute_begin(&crc_ctx);
- *(uint16_t *)(pb_current->data + data_cnt) = ((256 - 1) << 2) | 0x01;
- data_cnt += 2;
- memcpy(pb_current->data + data_cnt, frame_buffer + payload_cnt, 256);
- payload_cnt += 256;
- data_cnt += 256;
- crc_current = crc_compute_continue_block(&crc_ctx, crc_current, frame_buffer + 1024 + 512, 256);
- *(uint32_t *)(pb_current->data + data_cnt) = crc_compute_end(&crc_ctx, crc_current);
- data_cnt += 4;
-
- memset(pb_current->data + data_cnt, '\0', 512 - data_cnt);
-
- /* prepare jobs */
- memset(&job1, '\0', sizeof(job1));
- job1.next = &job2;
- job1.data_addr = eth_buffer + 1536;
- job1.header_len = 6;
- job1.data_len = 1024;
- job1.first_pb_desc = pb_first;
- job1.first_pb_offset = START_OFFSET;
- job1.segment_len = 512;
- job1.direction = 1;
- job1.crc_reset = 1;
- job1.crc_store = 1;
- job1.job_it = 0;
- job1.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
-
- memset(&job2, '\0', sizeof(job2));
- job2.next = &job3;
- job2.data_addr = eth_buffer + 512;
- job2.header_len = 2;
- job2.data_len = 512;
- job2.first_pb_desc = pb_first->next->next; /* 3rd PB */
- job2.first_pb_offset = (START_OFFSET + job1.data_len + 10) % 512;
- job2.segment_len = 512;
- job2.direction = 1;
- job2.crc_reset = 1;
- job3.crc_store = 1;
- job2.job_it = 1;
- job2.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
-
- memset(&job3, '\0', sizeof(job3));
- job3.next = NULL;
- job3.data_addr = eth_buffer + 1024;
- job3.header_len = 2;
- job3.data_len = 256;
- job3.first_pb_desc = pb_first->next->next->next; /* 4th PB */
- job3.first_pb_offset = (START_OFFSET + job1.data_len + 10 + job2.data_len + 6) % 512;
- job3.segment_len = 512;
- job3.last = 1;
- job3.direction = 1;
- job3.crc_reset = 1;
- job3.crc_store = 1;
- job3.job_it = 1;
- job3.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
-
- test_begin(t, "reassembly of 3 frames")
- {
- phy_bridgedma_start(bridgedma_ctx, &job1, &job3);
-
- /* check job1 */
- test_fail_unless(
- (bridgedma_ctx->job_current == &job1)
- && bridgedma_ctx->status.running
- && !bridgedma_ctx->status.stop
- );
-
- /* check job2 */
- test_fail_unless(
- (bridgedma_ctx->job_current == &job2)
- && bridgedma_ctx->status.running
- && !bridgedma_ctx->status.stop
- );
-
- /* check job3 */
- test_fail_unless(
- (bridgedma_ctx->job_current == &job3)
- && bridgedma_ctx->status.running
- && !bridgedma_ctx->status.stop
- );
-
- /* check the eth_buffer content */
- test_fail_unless(
- !memcmp(eth_buffer + 1536, frame_buffer, 512)
- && !memcmp(eth_buffer, frame_buffer + 512, 512)
- );
- test_fail_unless(
- !memcmp(eth_buffer + 512, frame_buffer + 1024, 512)
- );
- test_fail_unless(
- !memcmp(eth_buffer + 1024, frame_buffer + 1536, 256)
- );
-
- /* check status */
- test_fail_unless(
- !job1.crc_error
- && !job2.crc_error
- && !job3.crc_error
- && !bridgedma_ctx->status.ahb_response_error
- && !bridgedma_ctx->status.running
- && bridgedma_ctx->status.stop
- );
- } test_end;
-
- /****************************************************************
- * bad ICV detected
- ****************************************************************/
- *(uint16_t *)(pb_first->data) = ((256 - 1) << 2) | 0x01;
- memcpy(pb_first->data + 2, frame_buffer, 256);
- *(uint32_t *)(pb_current->data + 2 + 256) = 0xdeadbeef;
- memset(&job1, '\0', sizeof(job1));
-
- job1.next = NULL;
- job1.data_addr = eth_buffer;
- job1.header_len = 2;
- job1.data_len = 256;
- job1.first_pb_desc = pb_first;
- job1.first_pb_offset = 0;
- job1.segment_len = 512;
- job1.direction = 1;
- job1.crc_reset = 1;
- job1.crc_store = 1;
- job1.job_it = 0;
- job1.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
-
- test_begin(t, "bad ICV")
- {
- phy_bridgedma_start(bridgedma_ctx, &job1, &job1);
- test_fail_unless(
- (read(fd_in, msg_buffer, sizeof(sci_msg_hdr_t) + sizeof(netclock_msg_hdr_t)) == sizeof(sci_msg_hdr_t) + sizeof(netclock_msg_hdr_t))
- );
-
- test_fail_unless(
- job1.crc_error
- && !bridgedma_ctx->status.ahb_response_error
- && !bridgedma_ctx->status.running
- && bridgedma_ctx->status.stop
- );
-
- } test_end;
-
- /**************************************************************************/
- /* 2 continuous jobs for the same mac frame */
- /* 2nd job has header_len=0 and doesn't reset the current icv computation */
- /* getting 1024 bytes of data from 3 PBs, offset=128, no ATS */
- /**************************************************************************/
- pb_current = pb_first;
- data_cnt = START_OFFSET;
- payload_cnt = 0;
- crc_current = crc_compute_begin(&crc_ctx);
- *(uint16_t *)(pb_current->data + data_cnt) = ((1024 + 4 - 1) << 2) | 0x01;
- data_cnt += 2;
- memcpy(pb_current->data + data_cnt, frame_buffer, 512 - data_cnt);
- payload_cnt += 512 - data_cnt;
- pb_current = pb_current->next;
- memcpy(pb_current->data, frame_buffer + payload_cnt, 512);
- payload_cnt += 512;
- pb_current = pb_current->next;
- memcpy(pb_current->data, frame_buffer + payload_cnt, 1024 - payload_cnt);
- data_cnt = 1024 - payload_cnt;
- payload_cnt = 1024;
- crc_current = crc_compute_continue_block(&crc_ctx, crc_current, frame_buffer, 1024);
- *(uint32_t *)(pb_current->data + data_cnt) = crc_compute_end(&crc_ctx, crc_current);
- data_cnt += 4;
- memset(pb_current->data + data_cnt, '\0', 512 - data_cnt); // padding
-
- /* prepare jobs */
- memset(&job1, '\0', sizeof(job1));
- job1.next = &job2;
- job1.data_addr = eth_buffer;
- job1.header_len = 2;
- job1.data_len = 256;
- job1.first_pb_desc = pb_first;
- job1.first_pb_offset = START_OFFSET;
- job1.segment_len = 512;
- job1.direction = 1;
- job1.crc_reset = 1;
- job1.crc_store = 0;
- job1.job_it = 0;
- job1.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
-
- memset(&job2, '\0', sizeof(job1));
- job2.next = NULL;
- job2.data_addr = eth_buffer + 256;
- job2.header_len = 0;
- job2.data_len = 1024 - 256;
- job2.first_pb_desc = pb_first;
- job2.first_pb_offset = START_OFFSET + 2 + 256;
- job2.segment_len = 512;
- job2.direction = 1;
- job2.crc_reset = 0;
- job2.crc_store = 1;
- job2.job_it = 0;
- job2.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
-
- test_begin(t, "2 jobs for 1 mac frame")
- {
- phy_bridgedma_start(bridgedma_ctx, &job1, &job2);
- /* 1st job */
- test_fail_unless(
- (read(fd_in, msg_buffer, sizeof(sci_msg_hdr_t) + sizeof(netclock_msg_hdr_t)) == sizeof(sci_msg_hdr_t) + sizeof(netclock_msg_hdr_t))
- );
-
- /* 2nd job */
- test_fail_unless(
- (read(fd_in, msg_buffer, sizeof(sci_msg_hdr_t) + sizeof(netclock_msg_hdr_t)) == sizeof(sci_msg_hdr_t) + sizeof(netclock_msg_hdr_t))
- );
-
- test_fail_unless(
- !memcmp(eth_buffer, frame_buffer, 1024)
- );
-
- test_fail_unless(
- !job2.crc_error
- && !bridgedma_ctx->status.ahb_response_error
- && !bridgedma_ctx->status.running
- && bridgedma_ctx->status.stop
- );
- } test_end;
-
- blk_release_desc_range(pb_first, pb_last);
-}
-
-#if 1
-/*************************************************************************************
- * ticket #3 fixing test unit
- * description: segmentation of a 1470 bytes length frame into 3 PBs
- * then reassembly of them
- * - during reassembly, bridge try to get a 4th unexisting PB et raise an assert failure
- * ***********************************************************************************/
-unsigned char ticket_3_packet[] __attribute__((aligned(2048))) =
-{ 0xd4, 0xc3, 0xb2, 0xa1, 0x02, 0x00, 0x04, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x9c, 0x2f, 0x9f, 0x46, 0xd1, 0x78,
- 0x02, 0x00, 0x96, 0x05, 0x00, 0x00, 0x96, 0x05, 0x00, 0x00, 0x08,
- 0x00, 0x27, 0x52, 0x20, 0x4c, 0x52, 0x54, 0x00, 0x12, 0x35, 0x02,
- 0x08, 0x00, 0x45, 0x08, 0x05, 0x88, 0x00, 0x6e, 0x00, 0x00, 0x40,
- 0x06, 0x15, 0xf1, 0xd1, 0x55, 0x81, 0xa5, 0x0a, 0x00, 0x02, 0x0f,
- 0x00, 0x50, 0x04, 0x17, 0x01, 0x76, 0x1c, 0xf4, 0xc2, 0xcc, 0x6e,
- 0x38, 0x50, 0x18, 0x22, 0x38, 0xe2, 0xf1, 0x00, 0x00, 0x7e, 0x94,
- 0xbd, 0x94, 0x2c, 0x97, 0x22, 0xd4, 0x84, 0x34, 0x0c, 0x8c, 0xfe,
- 0xfc, 0x13, 0x85, 0xd9, 0x5b, 0xc0, 0xbb, 0xb0, 0x8e, 0xb8, 0x7f,
- 0x0c, 0xa2, 0xf5, 0x7a, 0x10, 0xad, 0x45, 0x10, 0xad, 0xb7, 0x82,
- 0x68, 0xfd, 0x8f, 0x83, 0xa8, 0x2a, 0x77, 0x5a, 0xb2, 0xb3, 0xd2,
- 0x8d, 0xc0, 0x2b, 0x46, 0x76, 0x0c, 0x0c, 0xb1, 0x0b, 0x27, 0xbc,
- 0x6a, 0xd9, 0xe5, 0xdc, 0xf5, 0x69, 0x34, 0x0b, 0x6c, 0x96, 0x09,
- 0x27, 0x7c, 0x9c, 0xcd, 0x56, 0xee, 0xa3, 0x8a, 0x0b, 0x1b, 0xb2,
- 0xc7, 0x48, 0x54, 0x2d, 0xdf, 0x47, 0x9d, 0x6d, 0x81, 0x9d, 0xac,
- 0xde, 0xf0, 0x00, 0xb6, 0x43, 0x55, 0x74, 0x17, 0x79, 0x93, 0x57,
- 0x39, 0x11, 0xb9, 0x65, 0x12, 0x91, 0xfc, 0xbf, 0xf3, 0x39, 0xb5,
- 0xd5, 0xe5, 0x0a, 0x45, 0xbd, 0xa9, 0xfe, 0x72, 0xd9, 0x8e, 0x93,
- 0x2b, 0x2a, 0x7f, 0x26, 0x0f, 0x80, 0xfb, 0x4a, 0x74, 0x25, 0x3d,
- 0x7a, 0xaa, 0xc3, 0x5f, 0xe7, 0x08, 0x8e, 0x8c, 0x88, 0xd9, 0x06,
- 0x9c, 0xde, 0xd6, 0xda, 0x96, 0x0b, 0x54, 0xd0, 0x5b, 0x0d, 0xd9,
- 0x30, 0x1d, 0xc3, 0xa9, 0xd5, 0x67, 0x48, 0xf5, 0x25, 0x14, 0x1d,
- 0xc4, 0x03, 0xe2, 0x33, 0xf2, 0x60, 0x40, 0x0a, 0x4b, 0x8f, 0x45,
- 0x45, 0x3a, 0x01, 0x0f, 0x15, 0x60, 0xd8, 0x01, 0xc7, 0x45, 0x46,
- 0x0e, 0xb6, 0xaf, 0xbd, 0xbd, 0x62, 0x5a, 0x9f, 0x72, 0x30, 0x3c,
- 0xe6, 0x71, 0x44, 0x61, 0x35, 0x01, 0x4c, 0xc9, 0xfc, 0xd6, 0xb8,
- 0x3a, 0x62, 0x6c, 0xb3, 0xa4, 0xea, 0x89, 0x8f, 0xa3, 0xc8, 0x50,
- 0x16, 0x27, 0x27, 0x93, 0x65, 0x9f, 0x20, 0x42, 0x7d, 0x3f, 0x3b,
- 0xce, 0x1a, 0x5a, 0xd2, 0x53, 0xa7, 0x9c, 0xb4, 0x97, 0x6e, 0xc3,
- 0x86, 0x06, 0x5c, 0x02, 0xfe, 0x6d, 0x34, 0xc1, 0x3e, 0x73, 0x03,
- 0x63, 0x0c, 0x27, 0x18, 0xb5, 0xd7, 0xe2, 0xa5, 0x1c, 0x89, 0x92,
- 0x68, 0x2f, 0x42, 0xc2, 0x88, 0xff, 0xf0, 0x5b, 0x84, 0x0d, 0x7f,
- 0x17, 0x33, 0xa3, 0x2b, 0x07, 0x0f, 0x1f, 0x67, 0xac, 0xe1, 0x5c,
- 0x3d, 0x3e, 0xd6, 0xfa, 0xd8, 0xd2, 0x4a, 0xe6, 0x80, 0x78, 0x8f,
- 0xd7, 0xac, 0x7f, 0xee, 0xdc, 0x32, 0x76, 0xd1, 0x1f, 0x93, 0x38,
- 0x36, 0xa3, 0xde, 0xb9, 0x9c, 0x9e, 0x5c, 0x7a, 0xee, 0xf0, 0xd2,
- 0xbc, 0x72, 0xbb, 0xa7, 0xa7, 0x73, 0x8b, 0x4f, 0x2f, 0xb9, 0x79,
- 0xef, 0x9a, 0x5f, 0x7e, 0xef, 0xcf, 0xc3, 0xf7, 0x93, 0xc6, 0x9d,
- 0xfa, 0x4d, 0x3f, 0xb8, 0xa5, 0xbb, 0xa0, 0xe9, 0x72, 0xf7, 0x6c,
- 0x6c, 0x9e, 0x5c, 0xf2, 0xbb, 0xdb, 0x4f, 0x8f, 0xee, 0xf1, 0xd9,
- 0x79, 0xff, 0x56, 0x1b, 0x8e, 0x48, 0x7d, 0x38, 0x1a, 0xce, 0xcf,
- 0xad, 0xd3, 0xee, 0xc7, 0x9a, 0x5d, 0xb3, 0x67, 0xf5, 0x7b, 0x12,
- 0xf8, 0x73, 0xfb, 0xe3, 0x87, 0x08, 0xdf, 0x70, 0x79, 0x5b, 0x3d,
- 0x94, 0xd6, 0xcd, 0xd7, 0x18, 0xdf, 0x5c, 0xd5, 0x07, 0xe3, 0xba,
- 0x6f, 0x0f, 0x78, 0xb7, 0x77, 0x7f, 0x3c, 0x1b, 0x9e, 0xb8, 0xb3,
- 0xf3, 0x7e, 0xd7, 0xb9, 0xbd, 0xb9, 0x38, 0x35, 0x2f, 0x4f, 0xb0,
- 0xf9, 0x19, 0x10, 0x78, 0x72, 0x35, 0xfd, 0xc4, 0x9a, 0x13, 0x90,
- 0x52, 0x1b, 0x8c, 0xcf, 0x67, 0xf4, 0xe6, 0x5c, 0xbb, 0xbd, 0x7e,
- 0x0a, 0x29, 0xd3, 0xef, 0xad, 0xaa, 0x2e, 0xed, 0xeb, 0x7a, 0x68,
- 0x9f, 0x3c, 0xc4, 0xd6, 0xf8, 0xab, 0x36, 0x68, 0x3c, 0xf4, 0x7a,
- 0x5f, 0x9f, 0xfe, 0x98, 0x8f, 0x86, 0xa1, 0x9c, 0x37, 0xb8, 0x39,
- 0x3d, 0x39, 0x35, 0xa7, 0x0e, 0x37, 0xb5, 0x09, 0x4f, 0xde, 0xa5,
- 0xd3, 0x0f, 0x0d, 0xf3, 0xa2, 0x6b, 0x4e, 0xbe, 0xf4, 0x4d, 0x73,
- 0x68, 0x9a, 0xe6, 0x6e, 0x10, 0x8f, 0x0d, 0x7d, 0xd7, 0x75, 0x7d,
- 0x6c, 0xbb, 0x22, 0x34, 0x6a, 0xd5, 0xba, 0xf6, 0xfe, 0xfd, 0xfb,
- 0x7a, 0x32, 0x44, 0x04, 0xc5, 0xd2, 0xa8, 0x1f, 0x1c, 0xd4, 0x6b,
- 0x55, 0xbd, 0xa6, 0xef, 0xc2, 0xe9, 0x55, 0xf8, 0x0b, 0x44, 0x38,
- 0x50, 0x20, 0x08, 0x14, 0x02, 0x41, 0x1c, 0x1c, 0xc9, 0x04, 0x06,
- 0x70, 0xfa, 0x84, 0xeb, 0x93, 0x39, 0x8f, 0x05, 0x8d, 0xa3, 0xbb,
- 0x6a, 0xb9, 0x5e, 0xd6, 0xca, 0xd5, 0x32, 0x5c, 0x90, 0x76, 0x21,
- 0xb5, 0x20, 0x9b, 0x0c, 0x82, 0x4b, 0x61, 0x6c, 0x95, 0x0e, 0x0f,
- 0xb5, 0x43, 0x4d, 0x6f, 0x34, 0x35, 0xbd, 0x79, 0xd8, 0xa8, 0x69,
- 0x75, 0x75, 0x80, 0xd1, 0x92, 0xc4, 0x5c, 0xcb, 0xc3, 0x1c, 0x6c,
- 0x48, 0xab, 0xac, 0xfa, 0xef, 0x93, 0x30, 0x2b, 0x46, 0x9b, 0x9c,
- 0x69, 0x61, 0x35, 0xee, 0xa0, 0x4c, 0x00, 0x38, 0x43, 0x1c, 0x74,
- 0x46, 0xdf, 0xbf, 0xf9, 0x94, 0x78, 0x6a, 0x5c, 0xa0, 0x6c, 0x09,
- 0x68, 0xc4, 0x25, 0xf6, 0x01, 0x6a, 0x8a, 0xe0, 0xa8, 0x82, 0x37,
- 0x33, 0xd8, 0x4a, 0x78, 0xbe, 0x7f, 0x5b, 0x30, 0x01, 0xf4, 0x65,
- 0xcc, 0x64, 0x84, 0x6c, 0x8a, 0x1c, 0x46, 0x3c, 0x46, 0x45, 0x84,
- 0xd4, 0xfd, 0x0a, 0x61, 0x8b, 0x07, 0x41, 0x52, 0x71, 0x8a, 0x50,
- 0x98, 0x40, 0x24, 0xc2, 0x84, 0x7c, 0xff, 0x2b, 0x42, 0x6b, 0xb0,
- 0x5c, 0x48, 0x8d, 0x3b, 0xea, 0xc6, 0xb9, 0xe6, 0xd5, 0x8c, 0xa6,
- 0x22, 0x6d, 0xf5, 0x10, 0xea, 0xa1, 0x80, 0xb3, 0x80, 0x74, 0xc5,
- 0x67, 0xeb, 0x38, 0xd6, 0x7f, 0x1e, 0xc7, 0xfa, 0x1b, 0x2e, 0xd4,
- 0xdf, 0xc6, 0xb1, 0xfe, 0x7f, 0x82, 0x63, 0xef, 0xe6, 0xb2, 0xfb,
- 0x2a, 0x8e, 0x07, 0xe3, 0x3b, 0xf7, 0xf3, 0xa3, 0x7f, 0x6f, 0x5d,
- 0xd4, 0x33, 0x1c, 0x9b, 0xec, 0xe9, 0xf8, 0xd2, 0xf4, 0xdc, 0xde,
- 0x06, 0x8e, 0xcf, 0x4a, 0xa2, 0x84, 0xcd, 0xde, 0xed, 0xc5, 0xa4,
- 0x7e, 0x77, 0x7a, 0x76, 0xda, 0x0b, 0xdd, 0xae, 0x76, 0x76, 0x51,
- 0xed, 0x3f, 0x2a, 0x1c, 0x5e, 0x56, 0xcf, 0xfb, 0xc7, 0xb5, 0x4f,
- 0xa3, 0xe3, 0xf9, 0x70, 0x7e, 0x3d, 0x33, 0xaf, 0x24, 0x20, 0x8f,
- 0xc4, 0xb7, 0xb5, 0xdf, 0xeb, 0xa4, 0x76, 0xe5, 0x59, 0x1f, 0xfd,
- 0xc6, 0xe0, 0xfa, 0x7c, 0x62, 0x5d, 0xeb, 0xba, 0x35, 0xf6, 0x35,
- 0xfa, 0xb9, 0x1e, 0xff, 0x71, 0xf3, 0xb9, 0x61, 0x5e, 0xf2, 0xa7,
- 0xe1, 0x7d, 0xf7, 0x60, 0x78, 0x7f, 0x39, 0xbd, 0xa9, 0x7e, 0x98,
- 0xcf, 0xcc, 0xe3, 0x6e, 0xd5, 0x3d, 0xbe, 0xc7, 0x27, 0x57, 0x1a,
- 0xe9, 0xf3, 0xc9, 0xe0, 0x67, 0xea, 0x40, 0xaf, 0x64, 0x9a, 0xee,
- 0xc7, 0xd0, 0x04, 0xec, 0x5d, 0x13, 0x6d, 0x7e, 0x66, 0x91, 0xd2,
- 0xa3, 0x39, 0xec, 0xce, 0xcc, 0xe1, 0x49, 0xc3, 0x3c, 0x1f, 0x34,
- 0x92, 0xf7, 0x05, 0xeb, 0x52, 0xb7, 0x3f, 0xbd, 0x1c, 0xe8, 0xe6,
- 0xd4, 0xec, 0x2f, 0x40, 0x5c, 0xdd, 0x84, 0xa7, 0xca, 0x22, 0x97,
- 0x06, 0x10, 0x7d, 0x16, 0x4c, 0x68, 0x06, 0x50, 0x47, 0xfc, 0x3c,
- 0x12, 0xf5, 0x6d, 0x24, 0xea, 0xaf, 0x23, 0xf1, 0xe7, 0xd3, 0x68,
- 0x1b, 0x89, 0xfa, 0xeb, 0x48, 0xec, 0xf1, 0x71, 0x28, 0xe9, 0x02,
- 0x4e, 0x88, 0x06, 0xe8, 0x73, 0xcc, 0xa2, 0x88, 0xbe, 0x8d, 0xc3,
- 0xcf, 0x00, 0xc2, 0x58, 0x30, 0xf9, 0xfd, 0x1b, 0xa2, 0x12, 0xc1,
- 0x95, 0x9c, 0x88, 0xef, 0xdf, 0xb2, 0xf3, 0x98, 0xc0, 0x81, 0x64,
- 0x34, 0x42, 0x17, 0x82, 0x3b, 0x70, 0x73, 0x9e, 0x03, 0x3a, 0x01,
- 0x90, 0x13, 0x18, 0x85, 0xc4, 0x02, 0xd3, 0x22, 0xc0, 0x6a, 0x44,
- 0x70, 0xfc, 0xf4, 0x36, 0x18, 0x5f, 0x71, 0xe3, 0xcf, 0x80, 0xb2,
- 0xa2, 0x76, 0xd8, 0xcd, 0x7d, 0x57, 0xca, 0xe5, 0xbe, 0xab, 0xba,
- 0xb0, 0xcd, 0xaf, 0x00, 0x9c, 0x0e, 0x38, 0x6f, 0x33, 0xc3, 0x85,
- 0x56, 0x01, 0x24, 0x81, 0xc5, 0xaf, 0x9c, 0x4a, 0xd4, 0x2b, 0x09,
- 0xe4, 0x6f, 0x72, 0x16, 0x52, 0xa3, 0xbe, 0x2b, 0xa8, 0xcd, 0xc4,
- 0xdd, 0x22, 0x57, 0x76, 0x6a, 0x66, 0xa5, 0x12, 0x51, 0x31, 0x61,
- 0x84, 0x46, 0x99, 0xa4, 0x74, 0x95, 0x94, 0xda, 0xea, 0x5e, 0x5c,
- 0x01, 0xcd, 0x3b, 0xb5, 0x0f, 0x40, 0xbf, 0x53, 0xeb, 0x2f, 0x39,
- 0x94, 0x63, 0x88, 0x98, 0xc1, 0xd5, 0xc9, 0x67, 0x73, 0xb8, 0x34,
- 0x8f, 0xc7, 0x71, 0xc0, 0xe4, 0xac, 0x1c, 0x50, 0x59, 0xd9, 0xa9,
- 0x36, 0x3c, 0x45, 0xec, 0x08, 0x68, 0xa5, 0x09, 0x07, 0xbd, 0x37,
- 0x52, 0x0e, 0x48, 0xb0, 0xfd, 0x05, 0xe6, 0xb7, 0xea, 0x5e, 0x32,
- 0x3e, 0x82, 0xf1, 0xd1, 0x4e, 0xb5, 0xde, 0xab, 0xc1, 0xc3, 0x3c,
- 0x5c, 0x56, 0xe8, 0x9d, 0x6a, 0x37, 0xab, 0xd1, 0xd0, 0x4a, 0xaa,
- 0xf4, 0x86, 0x98, 0x57, 0x22, 0xb6, 0x14, 0x97, 0xa6, 0x17, 0xb0,
- 0x65, 0x09, 0x06, 0x2d, 0x1a, 0xc0, 0x23, 0x4d, 0x32, 0x20, 0xb3,
- 0x79, 0x40, 0x81, 0x4e, 0x87, 0xa6, 0xab, 0x56, 0xf1, 0xe1, 0x6a,
- 0x99, 0xa4, 0x96, 0x8f, 0x83, 0x87, 0x34, 0x4d, 0x51, 0x72, 0xcb,
- 0x37, 0x72, 0x8b, 0x0f, 0x40, 0x2c, 0x48, 0x3e, 0xdd, 0x64, 0xdf,
- 0x81, 0x98, 0x2f, 0xa9, 0x68, 0x85, 0x82, 0xbb, 0xcc, 0x6e, 0xf5,
- 0x6f, 0x4e, 0xc7, 0x10, 0x83, 0x91, 0xfa, 0x10, 0xe7, 0x70, 0x31,
- 0x2e, 0x0f, 0x19, 0x11, 0x3c, 0xe2, 0x8e, 0x2c, 0x9b, 0x3e, 0x1c,
- 0x5f, 0x93, 0xd9, 0x01, 0x9c, 0x08, 0xa9, 0xc8, 0xab, 0x23, 0xe7,
- 0xde, 0xaf, 0x44, 0x17, 0x82, 0xe3, 0x73, 0x97, 0xab, 0x77, 0xc9,
- 0x11, 0x25, 0xd8, 0x82, 0x49, 0x29, 0xfd, 0x36, 0x55, 0x0e, 0x03,
- 0x17, 0xae, 0xa0, 0x8b, 0x4f, 0x26, 0x8d, 0xe5, 0x77, 0x8a, 0x43,
- 0x3d, 0x7c, 0xca, 0x75, 0x8e, 0xd8, 0xd8, 0x45, 0xd8, 0x97, 0x46,
- 0xce, 0x0c, 0x02, 0x80, 0x3a, 0x20, 0xe1, 0x63, 0xa2, 0x28, 0xb7,
- 0xac, 0xd2, 0x28, 0xe5, 0x35, 0xf4, 0xc6, 0x2f, 0x1f, 0x85, 0xff,
- 0xde, 0xac, 0xcc, 0x79, 0xbf, 0xe6, 0xa6, 0x3c, 0x57, 0xdb, 0x88,
- 0x9c, 0x19, 0x5a, 0x01, 0x25, 0x0b, 0x31, 0x0e, 0xf5, 0xce, 0x7a,
- 0x51, 0xc8, 0xb0, 0x97, 0x3e, 0xd3, 0xf3, 0x70, 0xf2, 0xc1, 0xb6,
- 0xf3, 0x1f, 0xed, 0x35, 0x17, 0x11, 0xfe, 0x15, 0x00, 0x00};
-unsigned int ticket_3_packet_len = 1470;
-
-void bridgedma_ticket_3(test_t t)
-{
- phy_bridgedma_job_t job;
- phy_bridgedma_t *bridgedma_ctx;
- blk_t *pb_first, *pb_last;
- struct reassembly_cb_data bridgedma_data;
- unsigned long ats = 0x12345678;
- sci_msg_hdr_t *sci_hdr;
- netclock_msg_hdr_t *netclock_hdr;
- unsigned char msg_buffer[256];
- int fd_in, fd_out;
-
- test_case_begin(t, "ticket #3");
-
- bridgedma_ctx = phy_bridgedma_init(&bridgedma_data, _bridgedma_reassembly_cb, _bridgedma_deffered_cb);
-#ifdef STATION_SOCK
- fd_in = my_station.sock_pair_fd;
- fd_out = my_station.sock_pair_fd;
-#else /* STATION_SOCK */
- fd_in = open(bridgedma_ctx->station->pipe_out_name, O_RDONLY);
- fd_out = open(bridgedma_ctx->station->pipe_in_name, O_WRONLY);
-#endif /* STATION_SOCK */
-
- pb_first = blk_alloc_desc_range(3, &pb_last);
-
- /* prepare job for fragmentation */
- //memcpy(frame_buffer, ticket_3_packet, ticket_3_packet_len);
- memset(&job, '\0', sizeof(job));
- job.next = NULL;
- job.data_addr = ticket_3_packet;
- job.header_len = 6;
- job.data_len = ticket_3_packet_len;
- job.first_pb_desc = pb_first;
- job.first_pb_offset = 0;
- job.segment_len = 512;
- job.direction = 0;
- job.crc_reset = 1;
- job.crc_store = 1;
- job.job_it = 0;
- job.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
- job.mf_header1 = (((job.data_len + 4 - 1) << 2) | 0x02) | (ats >> 16); /* Payload + ATS */
- job.mf_header2 = (ats << 16);
-
- test_begin(t, "segmentation")
- {
- phy_bridgedma_start(bridgedma_ctx, &job, &job);
- test_fail_unless(
- bridgedma_ctx->status.running
- && !bridgedma_ctx->status.stop
- );
- } test_end;
-
-
- /* reassembly: prepare jobs */
- memset(&job, '\0', sizeof(job));
- job.next = NULL;
- job.data_addr = frame_buffer;
- job.header_len = 6;
- job.data_len = ticket_3_packet_len;
- job.first_pb_desc = pb_first;
- job.first_pb_offset = 0;
- job.segment_len = 512;
- job.direction = 1;
- job.crc_reset = 1;
- job.crc_store = 1;
- job.job_it = 0;
- job.eth_buffer_mask = 0x1fffff0; /* 2048 bytes mask */
-
- test_begin(t, "reassembly of 3 frames")
- {
- phy_bridgedma_start(bridgedma_ctx, &job, &job);
- test_fail_unless(
- bridgedma_ctx->status.running
- && !bridgedma_ctx->status.stop
- );
-
- /* check the buffer content */
- test_fail_unless(
- !memcmp(frame_buffer, ticket_3_packet, ticket_3_packet_len)
- );
- } test_end;
-
- blk_release_desc_range(pb_first, pb_last);
-
-}
-#endif /* 0 */
-
-void bridgedma_test_suite(test_t t)
-{
- test_suite_begin(t, "bridgedma");
-
- station_init (&my_station);
- station_log_set_level(&my_station, STATION_LOG_DEBUG);
- station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
- my_station.pipe_log_fd = 1;
-
- bridgedma_init_test_case(t);
- bridgedma_pb_data_add_test_case(t);
- bridgedma_segmentation_test_case(t);
- bridgedma_reassembly_test_case(t);
- bridgedma_ticket_3(t);
-
- station_down(&my_station);
-}
diff --git a/cesar/hal/phy/test/bridgedma-soft/synth-Config b/cesar/hal/phy/test/bridgedma-soft/synth-Config
deleted file mode 100644
index ddad644109..0000000000
--- a/cesar/hal/phy/test/bridgedma-soft/synth-Config
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_BRIDGEDMA_SOFT = y
diff --git a/cesar/hal/phy/test/bridgedma-soft/synth-Makefile b/cesar/hal/phy/test/bridgedma-soft/synth-Makefile
deleted file mode 100644
index 0018bbd7ca..0000000000
--- a/cesar/hal/phy/test/bridgedma-soft/synth-Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-BASE = ../../../..
-
-ECOS = y
-
-TARGET_PROGRAMS = test-bridgedma-proto \
- test-bridgedma-proto-tx \
- test-bridgedma-proto-rx \
- test-bridgedma-proto-crc
-
-test-bridgedma-proto_SOURCES = bridgedma-init-test.c
-test-bridgedma-proto_MODULES = hal/phy lib
-
-test-bridgedma-proto-tx_SOURCES = bridgedma-tx-test.c
-test-bridgedma-proto-tx_MODULES = hal/phy lib
-
-test-bridgedma-proto-rx_SOURCES = bridgedma-rx-test.c
-test-bridgedma-proto-rx_MODULES = hal/phy lib
-
-test-bridgedma-proto-crc_SOURCES = bridgedma-crc-test.c
-test-bridgedma-proto-crc_MODULES = hal/phy lib
-
-
-hal_phy_MODULE_SOURCES = bridgedma_soft.c
-VARIANT = synth
-
-include $(BASE)/common/make/top.mk
diff --git a/cesar/hal/phy/test/bridgedma-soft/synth-ecos.ecc.sh b/cesar/hal/phy/test/bridgedma-soft/synth-ecos.ecc.sh
deleted file mode 100644
index 8253d98c9a..0000000000
--- a/cesar/hal/phy/test/bridgedma-soft/synth-ecos.ecc.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-config=${1:-ecos-gen.ecc}
-ecosconfig --config=$config new linux default
-cat >> $config <<EOF
-EOF
-ecosconfig --config=$config check
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 */
diff --git a/cesar/test_general/hard/bridgedma/Makefile.mk b/cesar/test_general/hard/bridgedma/Makefile.mk
new file mode 100644
index 0000000000..45d2ced027
--- /dev/null
+++ b/cesar/test_general/hard/bridgedma/Makefile.mk
@@ -0,0 +1,24 @@
+TARGET_PROGRAMS = bridgedma_init bridgedma_it bridgedma_tx_one_frame \
+ bridgedma_rx_one_frame bridgedma_crc \
+ bridgedma_tx bridgedma_rx
+
+bridgedma_init_SOURCES = bridgedma_init.c
+bridgedma_init_MODULES = lib hal/arch $(TESTMODULES)
+
+bridgedma_it_SOURCES = bridgedma-it.c
+bridgedma_it_MODULES = lib hal/arch $(TESTMODULES)
+
+bridgedma_tx_one_frame_SOURCES = bridgedma-tx-one-frame.c
+bridgedma_tx_one_frame_MODULES = lib hal/arch $(TESTMODULES)
+
+bridgedma_rx_one_frame_SOURCES = bridgedma-rx-one-frame.c
+bridgedma_rx_one_frame_MODULES = lib hal/arch $(TESTMODULES)
+
+bridgedma_crc_SOURCES = bridgedma-crc.c
+bridgedma_crc_MODULES = lib hal/arch $(TESTMODULES)
+
+bridgedma_tx_SOURCES = bridgedma-tx.c
+bridgedma_tx_MODULES = lib hal/arch $(TESTMODULES)
+
+bridgedma_rx_SOURCES = bridgedma-rx.c
+bridgedma_rx_MODULES = lib hal/arch $(TESTMODULES)
diff --git a/cesar/test_general/hard/bridgedma/host-Config b/cesar/test_general/hard/bridgedma/host-Config
index 6e04af35df..dc2b3fd1bf 100644
--- a/cesar/test_general/hard/bridgedma/host-Config
+++ b/cesar/test_general/hard/bridgedma/host-Config
@@ -1,2 +1 @@
CONFIG_TRACE=y
-CONFIG_BRIDGEDMA_SOFT=y
diff --git a/cesar/test_general/hard/bridgedma/host-Makefile b/cesar/test_general/hard/bridgedma/host-Makefile
index 0fe8fb5b50..a5be8ec082 100644
--- a/cesar/test_general/hard/bridgedma/host-Makefile
+++ b/cesar/test_general/hard/bridgedma/host-Makefile
@@ -2,33 +2,8 @@ BASE = ../../..
ECOS = y
VARIANT=host
+TESTMODULES=hal/phy/soft/bridgedma
-TARGET_PROGRAMS = bridgedma_init bridgedma_it bridgedma_tx_one_frame \
- bridgedma_rx_one_frame bridgedma_crc \
- bridgedma_tx bridgedma_rx
-
-bridgedma_init_SOURCES = bridgedma_init.c
-bridgedma_init_MODULES = lib hal/phy hal/arch
-
-bridgedma_it_SOURCES = bridgedma-it.c
-bridgedma_it_MODULES = lib hal/phy hal/arch
-
-bridgedma_tx_one_frame_SOURCES = bridgedma-tx-one-frame.c
-bridgedma_tx_one_frame_MODULES = lib hal/phy hal/arch
-
-bridgedma_rx_one_frame_SOURCES = bridgedma-rx-one-frame.c
-bridgedma_rx_one_frame_MODULES = lib hal/phy hal/arch
-
-bridgedma_crc_SOURCES = bridgedma-crc.c
-bridgedma_crc_MODULES = lib hal/phy hal/arch
-
-bridgedma_tx_SOURCES = bridgedma-tx.c
-bridgedma_tx_MODULES = lib hal/phy hal/arch
-
-bridgedma_rx_SOURCES = bridgedma-rx.c
-bridgedma_rx_MODULES = lib hal/phy hal/arch
-
-hal_phy_MODULE_SOURCES=bridgedma_soft.c
-
+include Makefile.mk
include $(BASE)/common/make/top.mk
diff --git a/cesar/test_general/hard/bridgedma/sparc-Config b/cesar/test_general/hard/bridgedma/sparc-Config
index 86d7886882..8ae65d4913 100644
--- a/cesar/test_general/hard/bridgedma/sparc-Config
+++ b/cesar/test_general/hard/bridgedma/sparc-Config
@@ -1,3 +1,2 @@
-CONFIG_BRIDGEDMA_SOFT = n
CONFIG_TRACE_ON_FATAL = y
CONFIG_TRACE = y
diff --git a/cesar/test_general/hard/bridgedma/sparc-Makefile b/cesar/test_general/hard/bridgedma/sparc-Makefile
index 9d2b8e71de..89bfa57f54 100644
--- a/cesar/test_general/hard/bridgedma/sparc-Makefile
+++ b/cesar/test_general/hard/bridgedma/sparc-Makefile
@@ -3,35 +3,7 @@ BASE = ../../..
ECOS = y
TARGET=sparc
VARIANT=sparc
+TESTMODULES=hal/phy
-TARGET_PROGRAMS = bridgedma_init bridgedma_it bridgedma_tx_one_frame \
- bridgedma_rx_one_frame bridgedma_crc \
- bridgedma_tx bridgedma_rx
-
-bridgedma_init_SOURCES = bridgedma_init.c
-bridgedma_init_MODULES = lib hal/phy hal/arch
-
-bridgedma_it_SOURCES = bridgedma-it.c
-bridgedma_it_MODULES = lib hal/phy hal/arch
-
-bridgedma_tx_one_frame_SOURCES = bridgedma-tx-one-frame.c
-bridgedma_tx_one_frame_MODULES = lib hal/phy hal/arch
-
-bridgedma_rx_one_frame_SOURCES = bridgedma-rx-one-frame.c
-bridgedma_rx_one_frame_MODULES = lib hal/phy hal/arch
-
-bridgedma_crc_SOURCES = bridgedma-crc.c
-bridgedma_crc_MODULES = lib hal/phy hal/arch
-
-bridgedma_tx_SOURCES = bridgedma-tx.c
-bridgedma_tx_MODULES = lib hal/phy hal/arch
-
-bridgedma_rx_SOURCES = bridgedma-rx.c
-bridgedma_rx_MODULES = lib hal/phy hal/arch
-
+include Makefile.mk
include $(BASE)/common/make/top.mk
-
-all: $(TARGET_PROGRAMS:%=obj/$(VARIANT)/%.dis)
-
-%.dis: %.elf
- $(CROSS_COMPILE)objdump -DSt $< > $@
diff --git a/cesar/test_general/hard/bridgedma/src/bridgedma-crc.c b/cesar/test_general/hard/bridgedma/src/bridgedma-crc.c
index 4c1572a5b5..5779ffb4e9 100644
--- a/cesar/test_general/hard/bridgedma/src/bridgedma-crc.c
+++ b/cesar/test_general/hard/bridgedma/src/bridgedma-crc.c
@@ -27,14 +27,13 @@
#include "hal/phy/inc/bridgedma.h"
#include "hal/phy/inc/bridgedma_regs.h"
-#include "hal/phy/inc/bridgedma_soft.h"
#include <string.h>
#include <stdio.h>
#include <cyg/infra/diag.h>
#include "hal/arch/arch.h"
-#include "inc/bridgedma-regs.h"
+#include "hal/phy/soft/bridgedma/bridgedma_crc.h"
#define TEST_BRIDGEDMA_PB_NB 1
#define TEST_BRIDGEDMA_JOB_OFFSET 18
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 6bd8b69e0a..cdac54275b 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
@@ -231,74 +231,60 @@ bridgedma_verify_reception (void)
test_end;
#ifdef __sparc__
- uint data;
// Verify the register corresponding to the MF header1.
- volatile u32 *job_header_3210 = (u32 *) PHY_BRIDGEDMA_JOB_HEADER_3210;
- volatile u32 *job_header_7654 = (u32 *) PHY_BRIDGEDMA_JOB_HEADER_7654;
- volatile u32 *control = (u32 *) PHY_BRIDGEDMA_CONTROL;
- volatile u32 *job_len = (u32 *) PHY_BRIDGEDMA_JOB_LENGTH;
- volatile u32 *jobd_current = (u32 *) PHY_BRIDGEDMA_JOBD_PTR;
- volatile u32 *pb_conf = (u32 *) PHY_BRIDGEDMA_PB_CONF;
- volatile u32 *first_pb = (u32 *) PHY_BRIDGEDMA_JOB_FIRST_PB_DESC;
- volatile u32 *job_buf_addr = (u32 *) PHY_BRIDGEDMA_JOB_BUFF_ADD;
-
test_begin (test, "Verify registers")
{
- arch_load_cache ((u32 *) job, 36);
- test_fail_if (*job_header_3210 != job->mf_header1);
- test_fail_if (*job_header_7654 != job->mf_header2);
-
- data = *control;
- test_fail_if (BF_GET (PHY_BRIDGEDMA_CONTROL__STATUS, data) != 0);
+ arch_load_cache ((u32 *) &job, 36);
+ test_fail_if (PHY_BDGDMA_JOB_HEADER_3210 != job->mf_header1);
+ test_fail_if (PHY_BDGDMA_JOB_HEADER_7654 != job->mf_header2);
+ test_fail_if (phy_bridgedma_status (INVALID_PTR) != false);
- data = *pb_conf;
- test_fail_if (BF_GET (PHY_BRIDGEDMA_PB_CONF__OFFSET, data) !=
+ test_fail_if (BF_GET (PHY_BRIDGEDMA_PB_CONF__OFFSET,
+ PHY_BDGDMA_PB_CONF) !=
TEST_BRIDGEDMA_JOB_OFFSET);
- test_fail_if (BF_GET (PHY_BRIDGEDMA_PB_CONF__LENGTH, data) !=
+ test_fail_if (BF_GET (PHY_BRIDGEDMA_PB_CONF__LENGTH,
+ PHY_BDGDMA_PB_CONF) !=
BLK_SIZE);
- data = *job_len;
- test_fail_if (BF_GET (PHY_BRIDGEDMA_JOB_LENGTH__LENGTH, data) != job->data_len);
-
- result_t1 = true;
+ test_fail_if (BF_GET (PHY_BRIDGEDMA_JOB_LENGTH__LENGTH,
+ PHY_BDGDMA_JOB_LENGTH) != job->data_len);
}
test_end;
diag_printf ("******************* Debug *********************\n");
- diag_printf ("CMP Buffer : %p\n", cmp_buffer);
- diag_printf ("Frame Buffer : %p\n", job->data_addr);
- data = *control;
diag_printf ("BRIDGEDMA Status ; %x\n",
- BF_GET(PHY_BRIDGEDMA_CONTROL__STATUS, data));
- diag_printf ("[JOBD current] bridge : %x \t Cesar :%p\n", *jobd_current, job);
+ phy_bridgedma_status (INVALID_PTR));
+ diag_printf ("[JOBD current] bridge : %x \t Cesar :%p\n",
+ PHY_BDGDMA_CURRENT_JOBD_PTR, &job);
- data = *job_len;
diag_printf ("[JOBD length] bridge : %x \t Cesar :%x\n",
- BF_GET(PHY_BRIDGEDMA_JOB_LENGTH__LENGTH, data), job->data_len);
+ BF_GET(PHY_BRIDGEDMA_JOB_LENGTH__LENGTH,
+ PHY_BDGDMA_JOB_LENGTH), job->data_len);
diag_printf ("[JOBD header length] bridge : %x \t Cesar :%x\n",
- BF_GET(PHY_BRIDGEDMA_JOB_LENGTH__HEADER_LEN, data),
+ BF_GET(PHY_BRIDGEDMA_JOB_LENGTH__HEADER_LEN,
+ PHY_BDGDMA_JOB_LENGTH),
job->header_len);
diag_printf ("[JOBD header_3210] bridge : %x \t Cesar : %x\n",
- *job_header_3210, job->mf_header1);
+ PHY_BDGDMA_JOB_HEADER_3210, job->mf_header1);
diag_printf ("[JOBD header_7654] bridge : %x \t Cesar : %x\n",
- *job_header_7654, job->mf_header2);
- diag_printf ("[JOB BUFF ADDR] bridge : %x \t Cesar : %p\n", *job_buf_addr,
- job->data_addr);
+ PHY_BDGDMA_JOB_HEADER_7654, job->mf_header2);
+ diag_printf ("[JOB BUFF ADDR] bridge : %x \t Cesar : %p\n",
+ PHY_BDGDMA_JOB_BUF_ADD, job->data_addr);
- data = *pb_conf;
diag_printf ("[PB Conf length] bridge : %x \t Cesar : %x\n",
- BF_GET (PHY_BRIDGEDMA_PB_CONF__LENGTH, data), job->segment_len);
+ BF_GET (PHY_BRIDGEDMA_PB_CONF__LENGTH, PHY_BDGDMA_PB_CONF),
+ job->segment_len);
diag_printf ("[PB Conf offset] bridge : %x \t Cesar : %x\n",
- BF_GET (PHY_BRIDGEDMA_PB_CONF__OFFSET, data), job->first_pb_offset);
+ BF_GET (PHY_BRIDGEDMA_PB_CONF__OFFSET, PHY_BDGDMA_PB_CONF),
+ job->first_pb_offset);
- diag_printf ("[First PB] bridged : %x \t Cesar : %p\n", *first_pb,
- pb_first);
+ diag_printf ("[First PB] bridged : %x \t Cesar : %p\n",
+ PHY_BDGDMA_CURRENT_PBD_PTR, job->first_pb_desc);
diag_printf ("**************** END Debug *******************\n");
#endif
-
test_begin (test, "Verifying entry buffer with output buffer")
{
for (i = 0; i < job->data_len; i++)
diff --git a/cesar/test_general/hard/bridgedma/src/bridgedma-rx.c b/cesar/test_general/hard/bridgedma/src/bridgedma-rx.c
index 6cb7964f71..d17f2f2249 100644
--- a/cesar/test_general/hard/bridgedma/src/bridgedma-rx.c
+++ b/cesar/test_general/hard/bridgedma/src/bridgedma-rx.c
@@ -29,12 +29,12 @@
#include "hal/phy/inc/bridgedma.h"
#include "hal/phy/inc/bridgedma_regs.h"
-#include "hal/phy/inc/bridgedma_soft.h"
#include <string.h>
#include <stdio.h>
#include <cyg/infra/diag.h>
#include "hal/arch/arch.h"
+#include "hal/phy/soft/bridgedma/bridgedma_crc.h"
#define TEST_BRIDGEDMA_PB_NB 5
#define TEST_BRIDGEDMA_JOB_OFFSET 18
@@ -240,9 +240,6 @@ bridgedma_reassembly_verify_test_case (void)
pb_t *pb_first;
pb_t *pb_last;
- while (phy_bridgedma_current_job (bridgedma_ctx) != 0x0)
- cyg_thread_delay (1);
-
cyg_thread_delay (1);
test_begin (test, "It reception")
{
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 5d67d1a375..4917a02da0 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
@@ -240,73 +240,59 @@ bridgedma_segmentation_verify_test_case (void)
void
test_thread_process (cyg_addrword_t data)
{
-#ifdef __sparc__
- static phy_t *phy;
- /* Initialise the phy. */
- phy = phy_init (NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-#endif
-
bridgedma_segmentation_test_case ();
#ifdef __sparc__
// Verify the register corresponding to the MF header1.
- volatile u32 *job_header_3210 = (u32 *) PHY_BRIDGEDMA_JOB_HEADER_3210;
- volatile u32 *job_header_7654 = (u32 *) PHY_BRIDGEDMA_JOB_HEADER_7654;
- volatile u32 *control = (u32 *) PHY_BRIDGEDMA_CONTROL;
- volatile u32 *job_len = (u32 *) PHY_BRIDGEDMA_JOB_LENGTH;
- volatile u32 *jobd_current = (u32 *) PHY_BRIDGEDMA_JOBD_PTR;
- volatile u32 *pb_conf = (u32 *) PHY_BRIDGEDMA_PB_CONF;
- volatile u32 *first_pb = (u32 *) PHY_BRIDGEDMA_JOB_FIRST_PB_DESC;
- volatile u32 *job_buf_addr = (u32 *) PHY_BRIDGEDMA_JOB_BUFF_ADD;
-
test_begin (test, "Verify registers")
{
arch_load_cache ((u32 *) &job, 36);
- test_fail_if (*job_header_3210 != job->mf_header1);
- test_fail_if (*job_header_7654 != job->mf_header2);
-
- data = *control;
- test_fail_if (BF_GET (PHY_BRIDGEDMA_CONTROL__STATUS, data) != 0);
+ test_fail_if (PHY_BDGDMA_JOB_HEADER_3210 != job->mf_header1);
+ test_fail_if (PHY_BDGDMA_JOB_HEADER_7654 != job->mf_header2);
+ test_fail_if (phy_bridgedma_status (INVALID_PTR) != false);
- data = *pb_conf;
- test_fail_if (BF_GET (PHY_BRIDGEDMA_PB_CONF__OFFSET, data) !=
+ test_fail_if (BF_GET (PHY_BRIDGEDMA_PB_CONF__OFFSET,
+ PHY_BDGDMA_PB_CONF) !=
TEST_BRIDGEDMA_JOB_OFFSET);
- test_fail_if (BF_GET (PHY_BRIDGEDMA_PB_CONF__LENGTH, data) !=
+ test_fail_if (BF_GET (PHY_BRIDGEDMA_PB_CONF__LENGTH,
+ PHY_BDGDMA_PB_CONF) !=
BLK_SIZE);
- data = *job_len;
- test_fail_if (BF_GET (PHY_BRIDGEDMA_JOB_LENGTH__LENGTH, data) != job->data_len);
+ test_fail_if (BF_GET (PHY_BRIDGEDMA_JOB_LENGTH__LENGTH,
+ PHY_BDGDMA_JOB_LENGTH) != job->data_len);
}
test_end;
diag_printf ("******************* Debug *********************\n");
- data = *control;
diag_printf ("BRIDGEDMA Status ; %x\n",
- BF_GET(PHY_BRIDGEDMA_CONTROL__STATUS, data));
- diag_printf ("[JOBD current] bridge : %x \t Cesar :%p\n", *jobd_current, &job);
+ phy_bridgedma_status (INVALID_PTR));
+ diag_printf ("[JOBD current] bridge : %x \t Cesar :%p\n",
+ PHY_BDGDMA_CURRENT_JOBD_PTR, &job);
- data = *job_len;
diag_printf ("[JOBD length] bridge : %x \t Cesar :%x\n",
- BF_GET(PHY_BRIDGEDMA_JOB_LENGTH__LENGTH, data), job->data_len);
+ BF_GET(PHY_BRIDGEDMA_JOB_LENGTH__LENGTH,
+ PHY_BDGDMA_JOB_LENGTH), job->data_len);
diag_printf ("[JOBD header length] bridge : %x \t Cesar :%x\n",
- BF_GET(PHY_BRIDGEDMA_JOB_LENGTH__HEADER_LEN, data),
+ BF_GET(PHY_BRIDGEDMA_JOB_LENGTH__HEADER_LEN,
+ PHY_BDGDMA_JOB_LENGTH),
job->header_len);
diag_printf ("[JOBD header_3210] bridge : %x \t Cesar : %x\n",
- *job_header_3210, job->mf_header1);
+ PHY_BDGDMA_JOB_HEADER_3210, job->mf_header1);
diag_printf ("[JOBD header_7654] bridge : %x \t Cesar : %x\n",
- *job_header_7654, job->mf_header2);
- diag_printf ("[JOB BUFF ADDR] bridge : %x \t Cesar : %p\n", *job_buf_addr,
- hard_buffer);
+ PHY_BDGDMA_JOB_HEADER_7654, job->mf_header2);
+ diag_printf ("[JOB BUFF ADDR] bridge : %x \t Cesar : %p\n",
+ PHY_BDGDMA_JOB_BUF_ADD, hard_buffer);
- data = *pb_conf;
diag_printf ("[PB Conf length] bridge : %x \t Cesar : %x\n",
- BF_GET (PHY_BRIDGEDMA_PB_CONF__LENGTH, data), job->segment_len);
+ BF_GET (PHY_BRIDGEDMA_PB_CONF__LENGTH, PHY_BDGDMA_PB_CONF),
+ job->segment_len);
diag_printf ("[PB Conf offset] bridge : %x \t Cesar : %x\n",
- BF_GET (PHY_BRIDGEDMA_PB_CONF__OFFSET, data), job->first_pb_offset);
+ BF_GET (PHY_BRIDGEDMA_PB_CONF__OFFSET, PHY_BDGDMA_PB_CONF),
+ job->first_pb_offset);
- diag_printf ("[First PB] bridged : %x \t Cesar : %p\n", *first_pb,
- job->first_pb_desc);
+ diag_printf ("[First PB] bridged : %x \t Cesar : %p\n",
+ PHY_BDGDMA_CURRENT_PBD_PTR, job->first_pb_desc);
diag_printf ("**************** END Debug *******************\n");
#endif
diff --git a/cesar/test_general/hard/bridgedma/src/bridgedma-tx.c b/cesar/test_general/hard/bridgedma/src/bridgedma-tx.c
index d183c66b50..3b802899cd 100644
--- a/cesar/test_general/hard/bridgedma/src/bridgedma-tx.c
+++ b/cesar/test_general/hard/bridgedma/src/bridgedma-tx.c
@@ -29,12 +29,12 @@
#include "hal/phy/inc/bridgedma.h"
#include "hal/phy/inc/bridgedma_regs.h"
-#include "hal/phy/inc/bridgedma_soft.h"
#include <string.h>
#include <stdio.h>
#include <cyg/infra/diag.h>
#include "hal/arch/arch.h"
+#include "hal/phy/soft/bridgedma/bridgedma_crc.h"
#define TEST_BRIDGEDMA_PB_NB 5
#define TEST_BRIDGEDMA_JOB_OFFSET 18
@@ -180,8 +180,6 @@ bridgedma_segmentation_verify_test_case (void)
uint frame_offset;
uint i;
- while (phy_bridgedma_current_job (bridgedma_ctx) != 0x0)
- cyg_thread_delay (1);
cyg_thread_delay (1);
test_begin (test, "It reception")
diff --git a/cesar/test_general/hard/bridgedma/src/bridgedma_init.c b/cesar/test_general/hard/bridgedma/src/bridgedma_init.c
index 48b695dc7a..4cef5b36af 100644
--- a/cesar/test_general/hard/bridgedma/src/bridgedma_init.c
+++ b/cesar/test_general/hard/bridgedma/src/bridgedma_init.c
@@ -45,14 +45,11 @@ void bridgedma_init_test_case(test_t t)
test_fail_if (bridgedma_ctx == NULL);
- test_fail_if (bridgedma_ctx->job_first != NULL);
- test_fail_if (bridgedma_ctx->job_current != NULL);
- test_fail_if (bridgedma_ctx->job_last != NULL);
- test_fail_if (bridgedma_ctx->user_data != NULL);
- test_fail_if (bridgedma_ctx->bridgedma_cb != _bridgedma_isr_cb);
- test_fail_if (bridgedma_ctx->deferred_cb != _bridgedma_dsr_cb);
- test_fail_if (bridgedma_ctx->status.running != false);
- test_fail_if (bridgedma_ctx->status.stop != true);
+ test_fail_if (bridgedma_ctx->bridge.job_tail != NULL);
+ test_fail_if (bridgedma_ctx->bridge.user_data != NULL);
+ test_fail_if (bridgedma_ctx->bridge.bridgedma_cb != _bridgedma_isr_cb);
+ test_fail_if (bridgedma_ctx->bridge.deferred_cb != _bridgedma_dsr_cb);
+ test_fail_if (phy_bridgedma_status (bridgedma_ctx) != false);
}
test_end;
return;