summaryrefslogtreecommitdiff
path: root/cesar/test_general/dataplane
diff options
context:
space:
mode:
authorschodet2009-04-03 15:41:50 +0000
committerschodet2009-04-03 15:41:50 +0000
commitebb494d20deba31dae7530146a164f7d97139189 (patch)
tree66929265bdca090e6e46f617951757a4d849fa44 /cesar/test_general/dataplane
parentbe1a71bb4c1ba2f6275966ccb854e8eb8fdd0675 (diff)
* test_general/dataplane:
- added trace dump. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@4398 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/test_general/dataplane')
-rw-r--r--cesar/test_general/dataplane/inc/context.h34
-rw-r--r--cesar/test_general/dataplane/inc/trace_dump.h35
-rw-r--r--cesar/test_general/dataplane/maximus-Makefile2
-rw-r--r--cesar/test_general/dataplane/sparc-Makefile2
-rw-r--r--cesar/test_general/dataplane/src/test_dataplane.c24
-rw-r--r--cesar/test_general/dataplane/src/trace_dump.c134
6 files changed, 228 insertions, 3 deletions
diff --git a/cesar/test_general/dataplane/inc/context.h b/cesar/test_general/dataplane/inc/context.h
index c27e0d195c..d4bad68871 100644
--- a/cesar/test_general/dataplane/inc/context.h
+++ b/cesar/test_general/dataplane/inc/context.h
@@ -24,6 +24,28 @@
#include "mac/ca/test/fcall/beacon_period.h"
+/* Forward declaration. */
+typedef struct test_dataplane_t test_dataplane_t;
+typedef struct test_dataplane_msg_t test_dataplane_msg_t;
+
+#include "inc/trace_dump.h"
+
+/** Asynchronous message callback. */
+typedef void (*test_dataplane_msg_cb_t) (test_dataplane_t *ctx,
+ test_dataplane_msg_t *msg);
+
+/** Data plane asynchronous messages. */
+struct test_dataplane_msg_t
+{
+ /** Message callback. */
+ test_dataplane_msg_cb_t cb;
+ /** Message data. */
+ union {
+ test_dataplane_msg_trace_dump_t trace_dump;
+ } msg;
+};
+/* Forward declared above. */
+
/** Data plane test context. */
struct test_dataplane_t
{
@@ -47,6 +69,16 @@ struct test_dataplane_t
/** Add/set beacon period. */
ca_test_fcall_beacon_period_t beacon_period;
+ /** Function call context for return. */
+ fcall_ctx_t *fcall;
+ /** Function call identifier for return. */
+ unsigned short fcall_msg_id;
+
+ /** Asynchronous messages. */
+ test_dataplane_msg_t msg;
+ /** Asynchronous message semaphore. */
+ cyg_sem_t msg_sem;
+
/** Kernel thread handle. */
cyg_handle_t thread;
/** Kernel thread storage. */
@@ -54,6 +86,6 @@ struct test_dataplane_t
/* Thread stack. */
u8 thread_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
};
-typedef struct test_dataplane_t test_dataplane_t;
+/* Forward declared above. */
#endif /* inc_context_h */
diff --git a/cesar/test_general/dataplane/inc/trace_dump.h b/cesar/test_general/dataplane/inc/trace_dump.h
new file mode 100644
index 0000000000..7635079caa
--- /dev/null
+++ b/cesar/test_general/dataplane/inc/trace_dump.h
@@ -0,0 +1,35 @@
+#ifndef inc_trace_dump_h
+#define inc_trace_dump_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file inc/trace_dump.h
+ * \brief Module trace dumps.
+ * \ingroup test
+ */
+
+/** Trace dump message. */
+struct test_dataplane_msg_trace_dump_t
+{
+ /** Bundle name. */
+ char name[64];
+ /** Trace what? */
+ bool all, phy, ca, pbproc, sar, cl, hle;
+};
+typedef struct test_dataplane_msg_trace_dump_t
+ test_dataplane_msg_trace_dump_t;
+
+/**
+ * Initialise (register fcall).
+ * \param ctx dataplane test context
+ * \param fcall fcall context
+ */
+void
+test_dataplane_trace_dump_init (test_dataplane_t *ctx, fcall_ctx_t *fcall);
+
+#endif /* inc_trace_dump_h */
diff --git a/cesar/test_general/dataplane/maximus-Makefile b/cesar/test_general/dataplane/maximus-Makefile
index 538dfcf092..0e6a40be1b 100644
--- a/cesar/test_general/dataplane/maximus-Makefile
+++ b/cesar/test_general/dataplane/maximus-Makefile
@@ -3,7 +3,7 @@ BASE = ../..
ECOS = y
TARGET_PROGRAMS = test_dataplane
-test_dataplane_SOURCES = test_dataplane.c
+test_dataplane_SOURCES = test_dataplane.c trace_dump.c
test_dataplane_MODULES = lib hal mac cl hle \
host mac/ca/test/fcall
diff --git a/cesar/test_general/dataplane/sparc-Makefile b/cesar/test_general/dataplane/sparc-Makefile
index 41e0977107..030e8d3bad 100644
--- a/cesar/test_general/dataplane/sparc-Makefile
+++ b/cesar/test_general/dataplane/sparc-Makefile
@@ -7,7 +7,7 @@ TARGET = sparc
TARGET_OPTIMIZE = -O2
TARGET_PROGRAMS = test_dataplane
-test_dataplane_SOURCES = test_dataplane.c
+test_dataplane_SOURCES = test_dataplane.c trace_dump.c
test_dataplane_MODULES = lib hal mac cl hle \
host interface mac/ca/test/fcall
diff --git a/cesar/test_general/dataplane/src/test_dataplane.c b/cesar/test_general/dataplane/src/test_dataplane.c
index b515487531..1a6334718f 100644
--- a/cesar/test_general/dataplane/src/test_dataplane.c
+++ b/cesar/test_general/dataplane/src/test_dataplane.c
@@ -19,6 +19,8 @@
#include "host/fcall/fcall.h"
+#define TEST_DATAPLANE_PRIORITY 16
+
/** Global Data plane test context. */
static test_dataplane_t test_dataplane_global;
@@ -52,6 +54,21 @@ cp_mme_buffer_add (void *user_data, u8 *buffer)
#endif /* CONFIG_FCALL_MME */
static void
+test_dataplane_thread (cyg_addrword_t data)
+{
+ test_dataplane_t *ctx = (void *) data;
+ dbg_assert (ctx);
+ /* Handle messages. */
+ while (1)
+ {
+ dbg_check (cyg_semaphore_wait (&ctx->msg_sem));
+ dbg_assert (ctx->msg.cb);
+ ctx->msg.cb (ctx, &ctx->msg);
+ ctx->msg.cb = NULL;
+ }
+}
+
+static void
test_dataplane_init (test_dataplane_t *ctx)
{
dbg_assert (ctx);
@@ -86,6 +103,13 @@ test_dataplane_init (test_dataplane_t *ctx)
pbproc_get_phy (ctx->pbproc),
pbproc_get_ca (ctx->pbproc),
ctx->hal_timer, fcall, ctx->snid);
+ test_dataplane_trace_dump_init (ctx, fcall);
+ /* Test thread. */
+ cyg_thread_create (TEST_DATAPLANE_PRIORITY, &test_dataplane_thread,
+ (cyg_addrword_t) ctx, "test_dataplane",
+ ctx->thread_stack, sizeof (ctx->thread_stack),
+ &ctx->thread, &ctx->thread_storage);
+ cyg_thread_resume (ctx->thread);
}
/** Entry point. */
diff --git a/cesar/test_general/dataplane/src/trace_dump.c b/cesar/test_general/dataplane/src/trace_dump.c
new file mode 100644
index 0000000000..46bfe1a034
--- /dev/null
+++ b/cesar/test_general/dataplane/src/trace_dump.c
@@ -0,0 +1,134 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/trace_dump.c
+ * \brief Module trace dumps.
+ * \ingroup test
+ */
+#include "common/std.h"
+
+#include "lib/trace.h"
+#include "hal/arch/io.h"
+#include "host/fcall/fcall.h"
+
+#include "inc/context.h"
+
+static void
+test_dataplane_trace_dump_fcall_return (test_dataplane_t *ctx)
+{
+ fcall_param_t param;
+ sci_msg_t msg;
+ u8 buffer[64];
+ dbg_assert (ctx);
+ dbg_assert (ctx->fcall);
+ fcall_param_init (&param, "trace_dump", ctx->fcall_msg_id);
+ sci_msg_init (&msg, buffer, sizeof (buffer));
+ fcall_param_reset (&param);
+ dbg_check (fcall_return (ctx->fcall, &param, &msg) != -1);
+ ctx->fcall = NULL;
+}
+
+static int
+trace_buffer_dbg_dump_callback (void *user, const char *text, uint text_size)
+{
+ dbg_assert (text && text_size);
+ arch_io_write (text, text_size);
+ return text_size;
+}
+
+static void
+test_dataplane_trace_dump (test_dataplane_t *ctx, test_dataplane_msg_t *msg)
+{
+ dbg_assert (ctx);
+ test_dataplane_msg_trace_dump_t *m = &msg->msg.trace_dump;
+ /* Dump traces. */
+ if (m->all)
+ {
+ trace_bundle_dump_all (m->name, trace_buffer_dbg_dump_callback, NULL);
+ }
+ else
+ {
+ trace_bundle_start (m->name, trace_buffer_dbg_dump_callback, NULL);
+ if (m->phy)
+ trace_buffer_dump (trace_buffer_get ("phy"),
+ trace_buffer_dbg_dump_callback, NULL);
+ if (m->ca)
+ trace_buffer_dump (trace_buffer_get ("ca"),
+ trace_buffer_dbg_dump_callback, NULL);
+ if (m->pbproc)
+ trace_buffer_dump (trace_buffer_get ("pbproc"),
+ trace_buffer_dbg_dump_callback, NULL);
+ if (m->sar)
+ trace_buffer_dump (trace_buffer_get ("sar"),
+ trace_buffer_dbg_dump_callback, NULL);
+ if (m->cl)
+ trace_buffer_dump (trace_buffer_get ("cl"),
+ trace_buffer_dbg_dump_callback, NULL);
+ if (m->hle)
+ trace_buffer_dump (trace_buffer_get ("hle"),
+ trace_buffer_dbg_dump_callback, NULL);
+ trace_bundle_stop (trace_buffer_dbg_dump_callback, NULL);
+ }
+ /* Return. */
+ test_dataplane_trace_dump_fcall_return (ctx);
+}
+
+static int
+test_dataplane_trace_dump_fcall (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ dbg_assert (fcall);
+ dbg_assert (param && *param);
+ dbg_assert (msg && *msg);
+ test_dataplane_t *ctx = (void *) data;
+ dbg_assert (ctx);
+ /* Only one message at a time. */
+ if (ctx->msg.cb)
+ return -1;
+ ctx->msg.cb = test_dataplane_trace_dump;
+ /* Read message. */
+ test_dataplane_msg_trace_dump_t *m = &ctx->msg.msg.trace_dump;
+ uint name_len = fcall_param_bind (*param, *msg, "bundle",
+ sizeof (m->name), m->name);
+ m->name[name_len] = '\0';
+ if (name_len == sizeof (m->name) || name_len == (uint) -1)
+ return -1;
+ if (!fcall_param_bind_helper ("all", m->all))
+ m->all = false;
+ if (!m->all)
+ {
+ if (!fcall_param_bind_helper ("phy", m->phy))
+ m->phy = false;
+ if (!fcall_param_bind_helper ("ca", m->ca))
+ m->ca = false;
+ if (!fcall_param_bind_helper ("pbproc", m->pbproc))
+ m->pbproc = false;
+ if (!fcall_param_bind_helper ("sar", m->sar))
+ m->sar = false;
+ if (!fcall_param_bind_helper ("cl", m->cl))
+ m->cl = false;
+ if (!fcall_param_bind_helper ("hle", m->hle))
+ m->hle = false;
+ }
+ /* Message accepted, will return later. */
+ fcall_param_set_async (*param, 1);
+ dbg_assert (ctx->fcall == NULL);
+ ctx->fcall = fcall;
+ ctx->fcall_msg_id = fcall_param_get_msg_id (*param);
+ /* Post message. */
+ cyg_semaphore_post (&ctx->msg_sem);
+ return 0;
+}
+
+void
+test_dataplane_trace_dump_init (test_dataplane_t *ctx, fcall_ctx_t *fcall)
+{
+ fcall_register (fcall, "trace_dump", test_dataplane_trace_dump_fcall,
+ ctx);
+}
+