summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorNicolas Schodet2010-11-16 16:40:19 +0100
committerNicolas Schodet2010-11-16 16:40:19 +0100
commita6eb2bf9210b5280e9077bcce4517f19b11aa272 (patch)
treedcbd8e09147a23ce24b9609aae38d83bfa8d2598 /cesar
parent7c1bd0ba5b7b64af3454c643a537f6d3a295b022 (diff)
cesar/hal/phy/test/phy: add chandata fetch method, refs #2074
Diffstat (limited to 'cesar')
-rw-r--r--cesar/hal/phy/test/phy/doc/test_phy.txt17
-rw-r--r--cesar/hal/phy/test/phy/inc/common.h51
-rw-r--r--cesar/hal/phy/test/phy/maximus-Makefile2
-rw-r--r--cesar/hal/phy/test/phy/py/test_phy/test_phy.py41
-rw-r--r--cesar/hal/phy/test/phy/py/valid/chandata_fc.py25
-rw-r--r--cesar/hal/phy/test/phy/sparc-Makefile2
-rw-r--r--cesar/hal/phy/test/phy/src/burst.c53
-rw-r--r--cesar/hal/phy/test/phy/src/common.c74
-rw-r--r--cesar/hal/phy/test/phy/src/test_phy.c49
9 files changed, 246 insertions, 68 deletions
diff --git a/cesar/hal/phy/test/phy/doc/test_phy.txt b/cesar/hal/phy/test/phy/doc/test_phy.txt
index 1885560de9..2888de4c9f 100644
--- a/cesar/hal/phy/test/phy/doc/test_phy.txt
+++ b/cesar/hal/phy/test/phy/doc/test_phy.txt
@@ -513,6 +513,23 @@ header (uint)
data (string)
128 or 512 byte of data.
+TestPhy.chandata
+----------------
+
+Directly fetch one channel data block using PBDMA.
+
+Parameters
+~~~~~~~~~~
+
+chandata (uint, default: none)
+ Chandata transfer configuration descriptor directly given to the PBDMA.
+
+Return values
+~~~~~~~~~~~~~
+
+The function returns a chandata block using the same format as burst_stats
+chandata.
+
Direct Registers access
=======================
diff --git a/cesar/hal/phy/test/phy/inc/common.h b/cesar/hal/phy/test/phy/inc/common.h
new file mode 100644
index 0000000000..57be846487
--- /dev/null
+++ b/cesar/hal/phy/test/phy/inc/common.h
@@ -0,0 +1,51 @@
+#ifndef inc_common_h
+#define inc_common_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2010 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file inc/common.h
+ * \brief Common utilities.
+ * \ingroup test
+ */
+#include "inc/context.h"
+
+BEGIN_DECLS
+
+/**
+ * Allocate blocks for chandata reception.
+ * \param chandata chandata descriptors
+ * \param chandata_nb number of chandata descriptors
+ * \return chandata blocks
+ */
+phy_chandata_t *
+test_phy_common_chandata_alloc (u32 *chandata, uint chandata_nb);
+
+/**
+ * Get chandata descriptors from fcall parameter.
+ * \param param fcall param
+ * \param msg fcall msg
+ * \param chandata pointer to chandata descriptors table
+ * \param chandata_max_nb number of elements in chandata
+ * \return number of chandata descriptors, or -1 on error
+ */
+int
+test_phy_common_chandata_bind (fcall_param_t *param, sci_msg_t *msg,
+ u32 *chandata, uint chandata_max_nb);
+
+/**
+ * Add one chandata block to fcall return.
+ * \param param fcall param
+ * \param msg fcall msg
+ * \param chandata chandata to add
+ * \return next chandata
+ */
+phy_chandata_t *
+test_phy_common_chandata_param_add (fcall_param_t *param, sci_msg_t *msg,
+ phy_chandata_t *chandata);
+
+#endif /* inc_common_h */
diff --git a/cesar/hal/phy/test/phy/maximus-Makefile b/cesar/hal/phy/test/phy/maximus-Makefile
index 97a98f805f..668039cf2a 100644
--- a/cesar/hal/phy/test/phy/maximus-Makefile
+++ b/cesar/hal/phy/test/phy/maximus-Makefile
@@ -6,7 +6,7 @@ DEFS = -DTEST_PHY_SIMU=1
TARGET_PROGRAMS = test_phy
test_phy_SOURCES = test_phy.c basic.c clk_sync.c access.c data.c gen.c mem.c \
- burst.c
+ burst.c common.c
test_phy_MODULES = lib host hal/phy/maximus mac/common
mac_common_MODULES_SOURCES = tonemask.c
diff --git a/cesar/hal/phy/test/phy/py/test_phy/test_phy.py b/cesar/hal/phy/test/phy/py/test_phy/test_phy.py
index b753074b85..391969f21e 100644
--- a/cesar/hal/phy/test/phy/py/test_phy/test_phy.py
+++ b/cesar/hal/phy/test/phy/py/test_phy/test_phy.py
@@ -1,5 +1,17 @@
"""Provide access to test_phy fcalls."""
+def str_data (src, prefix = ''):
+ """Convert binary data to hexadecimal string."""
+ n = 0
+ length = 16
+ r = [ ]
+ while src:
+ s, src = src[:length], src[length:]
+ hexa = ' '.join (["%02x" % ord (x) for x in s])
+ r.append ("%s%04x %s" % (prefix, n, hexa))
+ n += length
+ return '\n'.join (r)
+
class TestPhy:
"""Provide access to test_phy fcalls for a STA."""
@@ -84,6 +96,10 @@ class TestPhy:
def set_pb (self, **args):
self.create_fcall ('test_phy_set_pb', **args).send (self.sta)
+ def chandata (self, **args):
+ m = self.create_fcall ('test_phy_chandata', **args).send (self.sta)
+ return m.bind_param ('chandata')
+
def mem_read (self, addr, len = None):
if len is None:
m = self.create_fcall ('test_phy_mem', access = 0, addr = addr)
@@ -232,25 +248,13 @@ class TestPhy:
s += self.str_pb (' ')
if self.chandata:
s += '\n chandata:\n'
- s += self.str_chandata (' ')
+ s += str_data (''.join (self.chandata), ' ')
return s
def str_pb (self, prefix = ''):
pbs = '\n'.join ([str (pb) for pb in self.pb])
return prefix + pbs.replace ('\n', '\n' + prefix)
- def str_chandata (self, prefix = ''):
- n = 0
- length = 16
- r = [ ]
- src = ''.join (self.chandata)
- while src:
- s, src = src[:length], src[length:]
- hexa = ' '.join (["%02x" % ord (x) for x in s])
- r.append ("%s%04x %s" % (prefix, n, hexa))
- n += length
- return '\n'.join (r)
-
class pb:
def __init__ (self, m):
self.header = m.bind_param_ulong ('header')
@@ -260,18 +264,9 @@ class TestPhy:
self.bad_crc = m.bind_param_bool ('bad_crc')
def __str__ (self):
- n = 0
- length = 16
- r = [ ]
- data = self.data
- while data:
- s, data = data[:length], data[length:]
- hexa = ' '.join (["%02x" % ord (x) for x in s])
- r.append (" %04x %s" % (n, hexa))
- n += length
s = 'header: 0x%08x ber: %d halfit: %d bad_crc: %d' % (
self.header, self.ber, self.halfit, self.bad_crc)
- s += '\ndata:\n' + '\n'.join (r)
+ s += '\ndata:\n' + str_data (self.data, ' ')
return s
def burst_stats (self):
diff --git a/cesar/hal/phy/test/phy/py/valid/chandata_fc.py b/cesar/hal/phy/test/phy/py/valid/chandata_fc.py
new file mode 100644
index 0000000000..2874b17e44
--- /dev/null
+++ b/cesar/hal/phy/test/phy/py/valid/chandata_fc.py
@@ -0,0 +1,25 @@
+"""chandata_fc - Test chandata on FC."""
+
+import common
+import test_phy
+import test_phy.chandata as cd
+from params import anticip_tck, ifs_tck
+from test_phy.enum import *
+
+t1, t2 = common.begin (test_phy, 2)
+
+params = dict (
+ fc_mode = PHY_FC_MODE_HYBRID_1,
+ anticip_tck = anticip_tck,
+ nb_frames = 1,
+ short_ppdu = True,
+ )
+t2.burst_rx (**params)
+t1.burst_tx (**params)
+stats = t2.burst_stats ()
+print stats
+chandata = cd.desc (cd.TYPE_NRJ, 0, 128, last = True)
+chandata_block = t2.chandata (chandata = chandata)
+print test_phy.test_phy.str_data (chandata_block)
+
+common.end (t1, t2)
diff --git a/cesar/hal/phy/test/phy/sparc-Makefile b/cesar/hal/phy/test/phy/sparc-Makefile
index 0f1ce771ba..dd3fb6636d 100644
--- a/cesar/hal/phy/test/phy/sparc-Makefile
+++ b/cesar/hal/phy/test/phy/sparc-Makefile
@@ -10,7 +10,7 @@ DEFS = -DTEST_PHY_SIMU=0
TARGET_PROGRAMS = test_phy
test_phy_SOURCES = test_phy.c basic.c clk_sync.c access.c data.c gen.c mem.c \
- burst.c dataplane_stub.c
+ burst.c dataplane_stub.c common.c
test_phy_MODULES = lib hal/phy mac/common interface host hal/hle hle hal/arch
mac_common_MODULES_SOURCES = tonemask.c
diff --git a/cesar/hal/phy/test/phy/src/burst.c b/cesar/hal/phy/test/phy/src/burst.c
index 6fb4625d41..1a52fa542a 100644
--- a/cesar/hal/phy/test/phy/src/burst.c
+++ b/cesar/hal/phy/test/phy/src/burst.c
@@ -16,6 +16,7 @@
#include "inc/test_phy.h"
#include "inc/data.h"
#include "inc/burst.h"
+#include "inc/common.h"
#include "lib/slist.h"
@@ -81,22 +82,6 @@ test_phy_burst_stats_frame_destructor (void *data)
}
}
-static phy_chandata_t *
-test_phy_burst_chandata_alloc (u32 *chandata, uint chandata_nb)
-{
- uint i;
- blk_t *head, *tail, *b;
- head = blk_alloc_desc_range (chandata_nb, &tail);
- tail->next = NULL;
- b = head;
- for (i = 0; i < chandata_nb; i++)
- {
- *(u32 *) (b + 1) = *chandata++;
- b = b->next;
- }
- return PARENT_OF (phy_chandata_t, blk, head);
-}
-
static void ARCH_ILRAM
test_phy_burst_tx_handle (test_phy_t *ctx)
{
@@ -669,7 +654,7 @@ test_phy_burst_rx_stats (test_phy_t *ctx)
{
sf->chandata = b->chandata_blocks;
b->chandata_blocks =
- test_phy_burst_chandata_alloc (b->chandata, b->chandata_nb);
+ test_phy_common_chandata_alloc (b->chandata, b->chandata_nb);
}
}
}
@@ -723,8 +708,8 @@ test_phy_burst_rx_allocs (test_phy_t *ctx, test_phy_msg_burst_t *b)
d->pool_head = NULL;
/* Allocate blocks for chandata. */
if (b->chandata_nb)
- b->chandata_blocks = test_phy_burst_chandata_alloc (b->chandata,
- b->chandata_nb);
+ b->chandata_blocks = test_phy_common_chandata_alloc (b->chandata,
+ b->chandata_nb);
else
b->chandata_blocks = NULL;
/* If comparison is requested, build reference PB. */
@@ -1256,24 +1241,11 @@ test_phy_burst_fcall (fcall_ctx_t *fcall, fcall_param_t **param,
m->chandata_nb = 0;
else
{
- uint size = fcall_param_bind (*param, *msg, "chandata",
- sizeof (m->chandata), m->chandata);
- uint i, n = size / 4;
- if (size == sizeof (m->chandata))
- /* There was perhaps more data, refuse. */
- return -1;
- else if (size % sizeof (m->chandata[0]))
- /* Not a list of words, refuse. */
- return -1;
- else if (n == 0)
+ int nb = test_phy_common_chandata_bind (
+ *param, *msg, m->chandata, COUNT (m->chandata));
+ if (nb == -1)
return -1;
- else
- {
- /* Accept, and convert to right endianness. */
- for (i = 0; i < n; i++)
- m->chandata[i] = ntohl (m->chandata[i]);
- m->chandata_nb = n;
- }
+ m->chandata_nb = nb;
}
if (!fcall_param_bind_helper ("collect_chandata",
m->collect_chandata))
@@ -1561,13 +1533,8 @@ test_phy_burst_request_fcall_return (test_phy_t *ctx)
sf = m->stats.stats_frames_head;
if (sf && sf->chandata)
{
- phy_chandata_t *ch = sf->chandata;
- arch_load_cache ((u32 *) ch->blk.data, BLK_SIZE / 4);
- dbg_check (fcall_param_add (&param, &msg, "chandata", BLK_SIZE,
- ch->blk.data) != -1);
- /* Release this chandata. */
- sf->chandata = PARENT_OF (phy_chandata_t, blk, ch->blk.next);
- blk_release_desc (&ch->blk);
+ sf->chandata = test_phy_common_chandata_param_add (
+ &param, &msg, sf->chandata);
}
break;
default:
diff --git a/cesar/hal/phy/test/phy/src/common.c b/cesar/hal/phy/test/phy/src/common.c
new file mode 100644
index 0000000000..60d0bd7a96
--- /dev/null
+++ b/cesar/hal/phy/test/phy/src/common.c
@@ -0,0 +1,74 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2010 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/common.c
+ * \brief Common utilities.
+ * \ingroup test
+ */
+#include "common/std.h"
+
+#include "inc/common.h"
+
+#include "hal/arch/arch.h"
+
+phy_chandata_t *
+test_phy_common_chandata_alloc (u32 *chandata, uint chandata_nb)
+{
+ uint i;
+ blk_t *head, *tail, *b;
+ head = blk_alloc_desc_range (chandata_nb, &tail);
+ tail->next = NULL;
+ b = head;
+ for (i = 0; i < chandata_nb; i++)
+ {
+ *(u32 *) (b + 1) = *chandata++;
+ b = b->next;
+ }
+ return PARENT_OF (phy_chandata_t, blk, head);
+}
+
+int
+test_phy_common_chandata_bind (fcall_param_t *param, sci_msg_t *msg,
+ u32 *chandata, uint chandata_max_nb)
+{
+ uint size = fcall_param_bind (param, msg, "chandata",
+ sizeof (u32) * chandata_max_nb, chandata);
+ uint i, n = size / 4;
+ if (size == chandata_max_nb)
+ /* There was perhaps more data, refuse. */
+ return -1;
+ else if (size % sizeof (u32))
+ /* Not a list of words, refuse. */
+ return -1;
+ else if (n == 0)
+ return -1;
+ else
+ {
+ /* Accept, and convert to right endianness. */
+ for (i = 0; i < n; i++)
+ chandata[i] = ntohl (chandata[i]);
+ return n;
+ }
+}
+
+phy_chandata_t *
+test_phy_common_chandata_param_add (fcall_param_t *param, sci_msg_t *msg,
+ phy_chandata_t *chandata)
+{
+ phy_chandata_t *next =
+ PARENT_OF (phy_chandata_t, blk, chandata->blk.next);
+ /* Flush cache and add parameter. */
+ arch_load_cache ((u32 *) chandata->blk.data, BLK_SIZE / 4);
+ dbg_check (fcall_param_add (param, msg, "chandata", BLK_SIZE,
+ chandata->blk.data) != -1);
+ /* Release this chandata. */
+ blk_release_desc (&chandata->blk);
+ /* Done. */
+ return next;
+}
+
diff --git a/cesar/hal/phy/test/phy/src/test_phy.c b/cesar/hal/phy/test/phy/src/test_phy.c
index 4a3bd2c018..83571b5802 100644
--- a/cesar/hal/phy/test/phy/src/test_phy.c
+++ b/cesar/hal/phy/test/phy/src/test_phy.c
@@ -25,6 +25,7 @@
#include "inc/data.h"
#include "inc/mem.h"
#include "inc/burst.h"
+#include "inc/common.h"
#include "mac/common/tonemask.h"
#include "mac/common/defs.h"
@@ -49,6 +50,13 @@
# include "common/defs/spidcom.h"
#endif
+/* For operations unsupported by hal/phy. */
+#if defined (__sparc__)
+# define uint32_t uint32_t_regs
+# include "hal/phy/inc/regs.h"
+# undef uint32_t
+#endif
+
#define TEST_PHY_PRIORITY 16
/** Global test Phy context. */
@@ -470,6 +478,45 @@ test_phy_set_pb_fcall (fcall_ctx_t *fcall, fcall_param_t **param,
return 0;
}
+static int
+test_phy_chandata_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_phy_t *ctx = (void *) data;
+ dbg_assert (ctx);
+#if defined (__sparc__)
+ /* If a call is pending, this is an error. */
+ if (ctx->fcall)
+ return -1;
+ /* Decode. */
+ u32 chandata;
+ if (test_phy_common_chandata_bind (*param, *msg, &chandata, 1) == -1)
+ return -1;
+ phy_chandata_t *chandata_block =
+ test_phy_common_chandata_alloc (&chandata, 1);
+ /* Get chandata, there is no hal/phy for that. */
+ ctx->pbdma_cb = test_phy_default_pbdma_cb;
+ dbg_assert (chandata_block->conf.last);
+ dbg_assert (ARCH_DMA_VALID (chandata_block));
+ arch_write_buffer_flush ();
+ PHY_PBDMA_PTR_CHANDATA = (u32) chandata;
+ PHY_PBDMA_CTRL_CONFIG = PHY_PBDMA_CTRL_CONFIG__DEFAULT
+ | BF_MASK (PHY_PBDMA_CTRL_CONFIG__START_CHANDATA);
+ /* Wait for completion. */
+ dbg_check (cyg_semaphore_wait (&ctx->event_sem));
+ ctx->pbdma_cb = NULL;
+ /* Return. */
+ fcall_param_reset (*param);
+ test_phy_common_chandata_param_add (*param, *msg, chandata_block);
+ return 0;
+#else
+ return -1;
+#endif
+}
+
/**
* Test Phy thread.
* \param data test Phy context
@@ -640,6 +687,8 @@ cyg_user_start (void)
test_phy_set_freqerror_fcall, &test_phy_global);
fcall_register (fcall, "test_phy_set_pb",
test_phy_set_pb_fcall, &test_phy_global);
+ fcall_register (fcall, "test_phy_chandata", test_phy_chandata_fcall,
+ &test_phy_global);
test_phy_burst_init (&test_phy_global, fcall);
#if !CONFIG_FCALL_MME
my_station.pipe_log_fd = 1;