summaryrefslogtreecommitdiff
path: root/cesar/hal
diff options
context:
space:
mode:
authorThierry Carré2013-02-20 14:30:53 +0100
committerThierry Carré2013-02-22 16:45:33 +0100
commit5df7bdbbb6c6391ba4ae52103925790d6f085075 (patch)
treee68e9c81bbd108d67ef1fdb7616fcee6e95d5fc4 /cesar/hal
parent63936e7074cd12c5d3e518c0a7cee34d80e471be (diff)
parentf331b4132348339883b49760852240c73f3fc1ff (diff)
Merge branch 't2979_maximus_pipe' into eoc-drv
Conflicts: cesar/hal/ipmbox/maximus/test/Makefile cesar/hal/leon/maximus/test/Makefile cesar/hal/phy/maximus/test/Config cesar/hal/phy/maximus/test/Makefile cesar/host/test/Makefile
Diffstat (limited to 'cesar/hal')
-rw-r--r--cesar/hal/ipmbox/maximus/test/Config2
-rw-r--r--cesar/hal/ipmbox/maximus/test/Makefile10
-rw-r--r--cesar/hal/ipmbox/maximus/test/inc/test_maximus_hal.h56
-rw-r--r--cesar/hal/ipmbox/maximus/test/src/test_maximus_ether.c650
-rw-r--r--cesar/hal/ipmbox/maximus/test/src/test_maximus_hal.c85
-rw-r--r--cesar/hal/ipmbox/maximus/test/src/test_maximus_ipmbox.c355
-rw-r--r--cesar/hal/leon/maximus/test/Config3
-rw-r--r--cesar/hal/leon/maximus/test/Makefile9
-rw-r--r--cesar/hal/leon/maximus/test/inc/test_maximus_timer.h40
-rw-r--r--cesar/hal/leon/maximus/test/src/test_maximus_timer.c311
-rw-r--r--cesar/hal/phy/maximus/test/Config4
-rw-r--r--cesar/hal/phy/maximus/test/Makefile11
-rw-r--r--cesar/hal/phy/maximus/test/inc/test_phy_maximus.h93
-rw-r--r--cesar/hal/phy/maximus/test/src/test_aes.c34
-rw-r--r--cesar/hal/phy/maximus/test/src/test_pbdma.c315
-rw-r--r--cesar/hal/phy/maximus/test/src/test_phy_access.c884
-rw-r--r--cesar/hal/phy/maximus/test/src/test_phy_ctrl.c3856
-rw-r--r--cesar/hal/phy/maximus/test/src/test_phy_maximus.c106
-rw-r--r--cesar/hal/phy/maximus/test/src/test_tmdma.c144
-rw-r--r--cesar/hal/phy/test/phy/src/test_phy.c5
20 files changed, 0 insertions, 6973 deletions
diff --git a/cesar/hal/ipmbox/maximus/test/Config b/cesar/hal/ipmbox/maximus/test/Config
deleted file mode 100644
index 5077dbafd3..0000000000
--- a/cesar/hal/ipmbox/maximus/test/Config
+++ /dev/null
@@ -1,2 +0,0 @@
-CONFIG_DEBUG = y
-CONFIG_DEBUG_FATAL_CATCH = y
diff --git a/cesar/hal/ipmbox/maximus/test/Makefile b/cesar/hal/ipmbox/maximus/test/Makefile
deleted file mode 100644
index e0bfb92708..0000000000
--- a/cesar/hal/ipmbox/maximus/test/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-BASE = ../../../..
-EXTRA_HOST_CFLAGS += -DUNIT_TEST
-HOST_PROGRAMS = test_maximus_hal
-test_maximus_hal_SOURCES = test_maximus_hal.c test_maximus_ipmbox.c test_maximus_ether.c
-test_maximus_hal_MODULES = lib hal/ipmbox/maximus host
-test_maximus_hal_CONFIG_MODULES = mac/common
-
-INCLUDES = hal/ipmbox/maximus/test/inc
-
-include $(BASE)/common/make/top.mk
diff --git a/cesar/hal/ipmbox/maximus/test/inc/test_maximus_hal.h b/cesar/hal/ipmbox/maximus/test/inc/test_maximus_hal.h
deleted file mode 100644
index 6f1249d97e..0000000000
--- a/cesar/hal/ipmbox/maximus/test/inc/test_maximus_hal.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef hal_ipmbox_maximus_test_inc_test_maximus_hal_h
-#define hal_ipmbox_maximus_test_inc_test_maximus_hal_h
-
-/* Cesar project {{{
- *
- * Copyright (C) 2007-2012 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/ipmbox/maximus/test/inc/test_maximus_hal.h
- * \brief Test header for Maximus.
- * \ingroup hal_ipmbox_maximus
- */
-
-#include "host/fwd.h" /* for 'station_ctx_t' */
-
-#define RX_CB_DATA_USER_DATA 111
-#define RX_CB_MBX_USER_DATA 222
-#define EMPTY_BUF_CB_USER_DATA 333
-
-/**
- * RX DSR callback function.
- * \param user_data user data
- * \param first_msg pointer to the first received message header
- * \param length total length (in words) of received messages
- */
-void
-rx_cb_data (void *user_data, u32 *first_msg, uint length);
-void
-rx_cb_mbx (void *user_data, u32 *first_msg, uint length);
-
-/**
- * Empty buffer DSR callback function.
- * \param user_data user data
- */
-void
-empty_buf_cb (void *user_data);
-
-/**
- * Open pipe or socket.
- * \param station pointer to the station context
- * \return file descriptor for pipe or socket
- */
-int
-maximus_ether_open (station_ctx_t *station);
-
-/**
- * Close pipe.
- * \param fd file descriptor for pipe or socket
- */
-void
-maximus_ether_close (int fd);
-
-#endif /* hal_ipmbox_maximus_test_inc_test_maximus_hal_h */
diff --git a/cesar/hal/ipmbox/maximus/test/src/test_maximus_ether.c b/cesar/hal/ipmbox/maximus/test/src/test_maximus_ether.c
deleted file mode 100644
index 7124f11465..0000000000
--- a/cesar/hal/ipmbox/maximus/test/src/test_maximus_ether.c
+++ /dev/null
@@ -1,650 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007-2012 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/ipmbox/maximus/test/src/test_maximus_ipmbox.c
- * \brief HAL ipmbox test functions for Maximus.
- * \ingroup hal_ipmbox_maximus
- */
-
-#include "common/std.h"
-#include "lib/test.h"
-#include "hal/ipmbox/maximus/test/inc/test_maximus_hal.h"
-#include "hal/ipmbox/maximus/inc/maximus_ether.h"
-#include "hal/ipmbox/maximus/inc/maximus_ipmbox_ctx.h"
-#include "hal/ipmbox/maximus/inc/maximus_interrupts.h"
-#include "hal/ipmbox/ipmbox.h"
-#include "host/station/station.h" /* for 'station_ctx_t' */
-#include "maximus/common/types/ethernet_types.h" /* for 'ETHERNET_TYPE_...' */
-#include "common/ipmbox/msg.h"
-#include "lib/swap.h" /* for 'swap16()' */
-#include <stdio.h> /* for 'printf' */
-#include <string.h> /* for 'memset' */
-#include <unistd.h> /* for 'read' */
-#include <fcntl.h> /* for 'read' */
-#include <stdlib.h> /* for 'free' */
-#include <errno.h>
-
-extern uint32_t maximus_pending_isrs; /* used in 'station.c' */
-extern station_ctx_t my_station;
-ipmbox_t *ctx;
-
-void
-maximus_ether_fill_hdr_test_case (test_t t)
-{
- test_case_begin (t, "fill hdr");
-
- sci_msg_t msg;
- unsigned char buffer[SCI_MSG_MAX_SIZE];
- uint8_t type = ETHERNET_TYPE_DATA;
- uint8_t flags = ETHERNET_FLAG_NONE;
-
- test_begin (t, "sci init")
- {
- memset (buffer, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((0 == sci_msg_init (&msg, buffer, SCI_MSG_MAX_SIZE))
- && (EINVAL != errno));
- msg.length = 0;
- } test_end;
-
- test_begin (t, "fill hdr")
- {
- test_fail_unless ((0 == maximus_ether_fill_hdr (ctx, &msg, type, flags))
- && (EINVAL != errno)
- && (ETHERNET_VERSION == msg.hdr.ether->version)
- && (type == msg.hdr.ether->type)
- && (flags == msg.hdr.ether->flags)
- && (0 == msg.hdr.ether->reserved));
- } test_end;
-
- test_begin (t, "fill hdr with incorrect type")
- {
- type = ETHERNET_TYPE_NONE;
-
- dbg_fatal_try_begin
- {
- test_fail_unless ((-1 == maximus_ether_fill_hdr(ctx, &msg, type,
- flags))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("fill hdr with incorrect type\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
-
- /* Reset type to correct value. */
- type = ETHERNET_TYPE_DATA;
- } test_end;
-
- test_begin (t, "fill hdr with incorrect flags")
- {
- flags = ETHERNET_FLAG_MAX + 1;
-
- dbg_fatal_try_begin
- {
- test_fail_unless ((-1 == maximus_ether_fill_hdr (ctx, &msg, type,
- flags))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("fill hdr with incorrect flags\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
- } test_end;
-}
-
-void
-maximus_ether_recv_test_case (test_t t)
-{
- sci_msg_t msg;
- unsigned char buffer[SCI_MSG_MAX_SIZE];
-
- test_case_begin (t, "recv");
-
- test_begin (t, "sci init")
- {
- memset (buffer, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((0 == sci_msg_init (&msg, buffer, SCI_MSG_MAX_SIZE))
- && (EINVAL != errno));
- msg.length = 0;
- } test_end;
-
- test_begin (t, "NULL msg")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_ether_recv (NULL, ctx)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("NULL msg\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
- } test_end;
-
- test_begin (t, "NULL ipmbox")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_ether_recv (&msg, NULL)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("NULL ipmbox\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
- } test_end;
-
- test_begin (t, "recv")
- {
- u32 buf_id = 1;
- u32 total_buf_nb = 10;
- maximus_ipmbox_buffer_t *first_buffer = NULL;
- maximus_ipmbox_buffer_t *current_buffer = NULL;
-
- /* Ether header. */
- ether_msg_hdr_t ether_hdr;
-
- /* Sci header. */
- sci_msg_hdr_t sci_hdr;
-
- /* Sci data. */
- uint data_length = 1500;
- u8 data[data_length];
-
- /* Initialize sci data. */
- memset (data, '\0', data_length);
-
- /* Set ether header values. */
- ether_hdr.version = ETHERNET_VERSION;
- ether_hdr.type = ETHERNET_TYPE_NONE;
- ether_hdr.flags = ETHERNET_FLAG_NONE;
- ether_hdr.reserved = 0;
-
- for (ether_hdr.type = ETHERNET_TYPE_DATA;
- ether_hdr.type < ETHERNET_TYPE_BUFFER_RELEASED;
- ether_hdr.type++)
- {
- /* Fill sci data. */
-
- /* Ether type data or mme. */
- if ((ETHERNET_TYPE_DATA == ether_hdr.type)
- || (ETHERNET_TYPE_MME == ether_hdr.type))
- {
- uint i;
- for (i=0; i < data_length; i++)
- {
- data[i] = (u8) i;
- }
- test_fail_unless (0 <= sci_msg_push (&msg, data_length)
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy (msg.data_begin, data, data_length);
- }
- /* Ether type buffer add. */
- else if (ETHERNET_TYPE_BUFFER_ADD == ether_hdr.type)
- {
- for (buf_id = total_buf_nb; buf_id > 0; buf_id--)
- {
- test_fail_unless (0 <= sci_msg_push (&msg, sizeof (u32))
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy (msg.data_begin, &buf_id, sizeof (u32));
- }
- test_fail_unless (0 <= sci_msg_push (&msg, sizeof (u32))
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy (msg.data_begin, &total_buf_nb, sizeof (u32));
- }
-
- /* Fill ether header. */
- test_fail_unless (0 <= sci_msg_push (&msg, sizeof (ether_msg_hdr_t))
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy (msg.data_begin, &ether_hdr, sizeof (ether_msg_hdr_t));
-
- /* Fill sci header. */
- memcpy ((u8 *) &sci_hdr.magic_id, SCI_MSG_MAGIC, 4);
- sci_hdr.version = SCI_MSG_VERSION;
- sci_hdr.type = SCI_MSG_TYPE_ETHERNET;
- sci_hdr.flags = 0;
- sci_hdr.station_id = my_station.id;
- sci_hdr.length = msg.length - sizeof (sci_msg_hdr_t);
- sci_hdr.msg_id = my_station.sci->current_msg_id | SCI_MSG_ID_STATION;
- sci_hdr.netclock_high = my_station.current_tick_tck >> 32;
- sci_hdr.netclock_low = my_station.current_tick_tck & 0xffffffff;
- msg.sci_hdr = &sci_hdr;
-
- test_fail_unless ((0 <= (maximus_ether_recv (&msg, ctx)))
- && (EINVAL != errno)
- && (EPROTO != errno));
-
- test_fail_unless ((ether_hdr.version == msg.hdr.ether->version)
- && (ether_hdr.type == msg.hdr.ether->type)
- && (ether_hdr.flags == msg.hdr.ether->flags)
- && (ether_hdr.reserved == msg.hdr.ether->reserved));
-
- /* Check results. */
-
- /* Test ether type data or mme. */
- if (ETHERNET_TYPE_DATA == ether_hdr.type)
- {
- ipmbox_msg_data_t msg_data;
- msg_data.header = ipmbox_msg_create_header_data (data_length, 0);
-
- test_begin (t, "ether type data")
- {
- test_fail_unless ((maximus_pending_isrs & \
- (1 << HAL_IPMBOX_RX_INTERRUPT))
- && (2 == ctx->rx_data.length)
- && (ctx->rx_data.mailbox[0] == msg_data.header)
- && (0 == memcmp ((u8 *) ctx->rx_data.mailbox[1], data,
- data_length)));
- (*ctx->rx_cb_data) (ctx->rx_data_user_data, ctx->rx_data.mailbox,
- ctx->rx_data.length);
- maximus_pending_isrs &= ~(1 << HAL_IPMBOX_RX_INTERRUPT);
- ctx->rx_data.length = 0;
-
- /* Release allocated buffer. */
- test_fail_unless (NULL != (u32 *) ctx->rx_data.mailbox[1]);
- free ((u32 *) ctx->rx_data.mailbox[1]);
- } test_end;
- }
- else if (ETHERNET_TYPE_MME == ether_hdr.type)
- {
- ipmbox_msg_mbx_t msg_mbx;
- msg_mbx.header = ipmbox_msg_create_header_mme_priv (data_length);
-
- test_begin (t, "ether type mme")
- {
- test_fail_unless ((maximus_pending_isrs & \
- (1 << HAL_IPMBOX_RX_INTERRUPT))
- && (2 == ctx->rx_mbx.length)
- && (ctx->rx_mbx.mailbox[0] == msg_mbx.header)
- && (0 == memcmp ((u8 *) ctx->rx_mbx.mailbox[1], data,
- data_length)));
- (*ctx->rx_cb_mbx) (ctx->rx_mbx_user_data, ctx->rx_mbx.mailbox,
- ctx->rx_mbx.length);
- maximus_pending_isrs &= ~(1 << HAL_IPMBOX_RX_INTERRUPT);
- ctx->rx_mbx.length = 0;
-
- /* Release allocated buffer. */
- test_fail_unless (NULL != (u32 *) ctx->rx_mbx.mailbox[1]);
- free ((u32 *) ctx->rx_mbx.mailbox[1]);
- } test_end;
- }
- /* Test ether type buffer add. */
- else if (ETHERNET_TYPE_BUFFER_ADD == ether_hdr.type)
- {
- uint i;
-
- test_begin (t, "ether type buffer add")
- {
- ipmbox_msg_empty_buf_t expected_msg[total_buf_nb];
- first_buffer = ctx->first_buffer->next;
- current_buffer = first_buffer;
- for (i = 0; i < total_buf_nb; i++)
- {
- expected_msg[i].buffer_addr = (u32) current_buffer->data;
- current_buffer = current_buffer->next;
- }
-
- /* Check mailbox contents. */
- test_fail_unless ((maximus_pending_isrs & \
- (1 << HAL_IPMBOX_BUF_INTERRUPT))
- && (total_buf_nb == \
- ctx->rx_empty_buf.length)
- && (0 == memcmp (ctx->rx_empty_buf.mailbox,
- expected_msg,
- total_buf_nb * sizeof (u32))));
-
- /* Check list of the 10 allocated buffers. */
- current_buffer = first_buffer;
- for (i = 1; i < total_buf_nb; i++)
- {
- test_fail_unless ((NULL != current_buffer->next)
- && (i == current_buffer->id)
- && (NULL != current_buffer->data));
- current_buffer = current_buffer->next;
- }
- test_fail_unless ((NULL == current_buffer->next)
- && (total_buf_nb == current_buffer->id)
- && (NULL != current_buffer->data));
-
- (*ctx->empty_buf_cb) (ctx->buf_user_data);
- maximus_pending_isrs &= ~(1 << HAL_IPMBOX_BUF_INTERRUPT);
- test_fail_unless (ctx->rx_empty_buf.length != 0);
- } test_end;
-
- test_begin (t, "empty buf get")
- {
- uint nb_requested = 4;
- u32 msg_buf[IPMBOX_PROTOCOL_QUEUE_SIZE_A2L_EMPTY_BUF];
- test_fail_unless (ipmbox_empty_buf_get (ctx, msg_buf,
- nb_requested) == nb_requested);
- test_fail_unless (ctx->rx_empty_buf.length == \
- total_buf_nb - nb_requested);
- current_buffer = first_buffer;
- for (i = 0; i < nb_requested; i++)
- {
- test_fail_unless ((u32) current_buffer->data == \
- msg_buf[i]);
- current_buffer = current_buffer->next;
- }
-
- uint remaining_length = ctx->rx_empty_buf.length;
- nb_requested = 22;
- test_fail_unless (ipmbox_empty_buf_get (ctx, msg_buf,
- nb_requested) == remaining_length);
- for (i = 0; i < remaining_length; i++)
- {
- test_fail_unless ((u32) current_buffer->data == \
- msg_buf[i]);
- current_buffer = current_buffer->next;
- }
-
- test_fail_unless (ctx->rx_empty_buf.length == 0);
- } test_end;
-
- test_begin (t, "release allocated buffers")
- {
- uint rls_buf_nb = 0;
- maximus_ipmbox_buffer_t *next_buffer = NULL;
- current_buffer = ctx->first_buffer->next;
- while (NULL != current_buffer)
- {
- next_buffer = current_buffer->next;
- free (current_buffer->data);
- free (current_buffer);
- current_buffer = next_buffer;
- rls_buf_nb++;
- }
- ctx->first_buffer->next = NULL;
- test_fail_unless (total_buf_nb == rls_buf_nb);
- } test_end;
- }
- }
-
- /* Test ether type none. */
- ether_hdr.type = ETHERNET_TYPE_NONE;
-
- /* Fill ether header. */
- test_fail_unless (0 <= sci_msg_push (&msg, sizeof (ether_msg_hdr_t))
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy (msg.data_begin, &ether_hdr, sizeof (ether_msg_hdr_t));
-
- test_begin (t, "ether type none")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_ether_recv (&msg, ctx)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("ether type none\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
- } test_end;
-
- /* Test ether type buffer released. */
- ether_hdr.type = ETHERNET_TYPE_BUFFER_RELEASED;
-
- /* Fill ether header. */
- test_fail_unless (0 <= sci_msg_push (&msg, sizeof (ether_msg_hdr_t))
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy (msg.data_begin, &ether_hdr, sizeof (ether_msg_hdr_t));
-
- test_begin (t, "ether type buffer released")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_ether_recv (&msg, ctx)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("ether type buffer released\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
- } test_end;
- } test_end;
-}
-
-void
-maximus_ether_send_test_case (test_t t)
-{
- /* Ether type. */
- u8 type = ETHERNET_TYPE_DATA;
- u8 flags = ETHERNET_FLAG_NONE;
-
- /* Data. */
- int data_length = 1500;
- u8 data[1500];
-
- /* Initialize data. */
- memset (data, '\0', data_length);
-
- test_case_begin (t, "send");
-
- test_begin (t, "send incorrect flags")
- {
- flags = ETHERNET_FLAG_MAX + 1;
-
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_ether_send (ctx, type, flags,
- data_length, (u32 *)data)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("send incorrect flags\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
-
- /* Set flags to correct value. */
- flags = ETHERNET_FLAG_MAX;
- } test_end;
-
- test_begin (t, "send incorrect data length")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_ether_send (ctx, type, flags, 0,
- (u32 *) data)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("send incorrect data length\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
- } test_end;
-
- test_begin (t, "send null data")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_ether_send (ctx, type, flags,
- data_length, NULL)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("send null data\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
- } test_end;
-
- for (type = ETHERNET_TYPE_NONE; type < ETHERNET_TYPE_NB; type++)
- {
- /* Ether type none or buffer add. */
- if ((ETHERNET_TYPE_NONE == type)
- || (ETHERNET_TYPE_BUFFER_ADD == type))
- {
- test_begin (t, "send invalid")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_ether_send (ctx, type, flags,
- data_length, (u32 *) data)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("send invalid\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
- } test_end;
- }
-
- // Ether type data, mme or buffer released. */
- else if ((ETHERNET_TYPE_DATA == type)
- || (ETHERNET_TYPE_MME == type)
- || (ETHERNET_TYPE_BUFFER_RELEASED == type))
- {
- /* Ether type data or mme. */
- if ((ETHERNET_TYPE_DATA == type)
- || (ETHERNET_TYPE_MME == type))
- {
- /* Set data. */
- int i;
- for (i = 0; i < data_length; i++)
- {
- data[i] = (u8) i;
- }
- }
-
- /* Ether type buffer released. */
- else
- {
- /* Set data length and data. */
- int i;
- data_length = 4;
- for (i = 0; i < data_length; i++)
- {
- data[i] = i;
- }
- }
-
- test_begin (t, "send ether")
- {
- test_fail_unless ((0 == maximus_ether_send (ctx, type, flags,
- data_length, (u32 *) data))
- && (EINVAL != errno));
- } test_end;
-
- /* Check results. */
-
- /* Check that the correct ether message has been sent to Maximus. */
- test_begin (t, "ether message")
- {
- unsigned char buffer[SCI_MSG_MAX_SIZE];
- ether_msg_hdr_t *ether_hdr;
- int fd_in = -1;
-
- /* Open pipe or socket. */
- fd_in = maximus_ether_open (&my_station);
-
- /* Read sci and ether headers. */
- memset (buffer, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof (sci_msg_hdr_t) == \
- read (fd_in, buffer, sizeof(sci_msg_hdr_t)))
- && (sizeof (ether_msg_hdr_t) == \
- read (fd_in, buffer + \
- sizeof (sci_msg_hdr_t),
- sizeof(ether_msg_hdr_t))));
-
- /* Set sci and ether headers pointers. */
- ether_hdr = (ether_msg_hdr_t *) (buffer + sizeof (sci_msg_hdr_t));
-
- /* Check ether header. */
- test_fail_unless ((type == ether_hdr->type)
- && (flags == ether_hdr->flags));
-
- /* Read the remaining part of message. */
- test_fail_unless (data_length == read (fd_in, buffer + \
- sizeof (sci_msg_hdr_t) + sizeof(ether_msg_hdr_t),
- data_length));
-
- /* Check ether data. */
- test_fail_unless (0 == memcmp (data, buffer + \
- sizeof (sci_msg_hdr_t) + sizeof (ether_msg_hdr_t),
- data_length));
-
- // close pipe
- maximus_ether_close (fd_in);
- } test_end;
- }
- }
-}
-
-void ether_test_suite (test_t t)
-{
- int rx_user_data = 0x12345678;
- int buf_user_data = 0xFFFFFFFF;
-
- /* Reset errno. */
- errno = 0;
-
- station_init (&my_station);
- station_log_set_level (&my_station, STATION_LOG_DEBUG);
- station_log_set_mask (&my_station, STATION_LOGTYPE_ALL);
-
- ctx = ipmbox_init ();
- ctx->warning_assert = true;
- ipmbox_register_rx_data_cb (ctx, (void *) &rx_user_data, &rx_cb_data);
- ipmbox_register_rx_mbx_cb (ctx, (void *) &rx_user_data, &rx_cb_mbx);
- ipmbox_register_empty_buf_cb (ctx, (void *) &buf_user_data, &empty_buf_cb);
- ipmbox_activate (ctx, true);
-
- test_suite_begin (t, "ether");
- maximus_ether_fill_hdr_test_case (t);
- maximus_ether_recv_test_case (t);
- maximus_ether_send_test_case (t);
-
- ipmbox_uninit (ctx);
- station_down (&my_station);
-}
diff --git a/cesar/hal/ipmbox/maximus/test/src/test_maximus_hal.c b/cesar/hal/ipmbox/maximus/test/src/test_maximus_hal.c
deleted file mode 100644
index 2a30eb074b..0000000000
--- a/cesar/hal/ipmbox/maximus/test/src/test_maximus_hal.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007-2012 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/ipmbox/maximus/test/src/test_maximus_hal.c
- * \brief HAL IPMBox main test function for Maximus.
- * \ingroup hal_ipmbox_maximus
- */
-
-#include "common/std.h"
-#include "lib/test.h"
-#include "host/station/station.h" /* for 'station_ctx_t' */
-#include "inc/test_maximus_hal.h"
-#include <unistd.h> /* for 'open()' and 'close()' */
-#include <fcntl.h> /* for 'open()' and 'close()' */
-
-void
-ipmbox_test_suite (test_t t);
-void
-ether_test_suite (test_t t);
-
-uint32_t maximus_pending_isrs;
-station_ctx_t my_station;
-
-void
-rx_cb_data (void *user_data, u32 *first_msg, uint length)
-{
- int *my_data = (int *) user_data;
- *my_data = RX_CB_DATA_USER_DATA;
- return;
-}
-
-void
-rx_cb_mbx (void *user_data, u32 *first_msg, uint length)
-{
- int *my_data = (int *) user_data;
- *my_data = RX_CB_MBX_USER_DATA;
- return;
-}
-
-void empty_buf_cb (void *user_data)
-{
- int *my_data = (int *) user_data;
- *my_data = EMPTY_BUF_CB_USER_DATA;
- return;
-}
-
-int
-maximus_ether_open (station_ctx_t *station)
-{
- int fd;
-
-#ifdef STATION_SOCK
- fd = station->sock_pair_fd;
-#else /* STATION_SOCK */
- fd = open (station->pipe_out_name, O_RDONLY);
-#endif /* STATION_SOCK */
-
- return fd;
-}
-
-void
-maximus_ether_close (int fd)
-{
-#ifndef STATION_SOCK
- close (fd);
-#endif /* !STATION_SOCK */
-}
-
-int
-main (int argc, char **argv)
-{
- test_t t;
- test_init (t, argc, argv);
-
- ether_test_suite (t);
- ipmbox_test_suite (t);
-
- test_result (t);
- return test_nb_failed (t) == 0 ? 0 : 1;
-}
diff --git a/cesar/hal/ipmbox/maximus/test/src/test_maximus_ipmbox.c b/cesar/hal/ipmbox/maximus/test/src/test_maximus_ipmbox.c
deleted file mode 100644
index 88db6e3780..0000000000
--- a/cesar/hal/ipmbox/maximus/test/src/test_maximus_ipmbox.c
+++ /dev/null
@@ -1,355 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007-2012 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/ipmbox/maximus/test/src/test_maximus_ipmbox.c
- * \brief HAL ipmbox test functions for Maximus.
- * \ingroup hal_ipmbox_maximus
- */
-
-#include "common/std.h"
-#include "lib/test.h"
-#include "hal/ipmbox/maximus/test/inc/test_maximus_hal.h"
-#include "hal/ipmbox/maximus/inc/maximus_ipmbox_ctx.h" /* for 'ipmbox_t' */
-#include "hal/ipmbox/ipmbox.h"
-#include "host/station/station.h" /* for 'station_ctx_t' */
-#include "host/fwd.h" /* for 'sci_msg_t' */
-#include "maximus/common/types/ethernet_types.h" /* for 'ether_msg_hdr_t' */
-#include "common/ipmbox/msg.h"
-#include <stdio.h> /* for 'printf' */
-#include <string.h> /* for 'memset' */
-#include <unistd.h> /* for 'read' */
-#include <fcntl.h> /* for 'read' */
-#include <stdlib.h> /* for 'malloc' */
-#include <errno.h>
-
-extern uint32_t maximus_pending_isrs; /* used in 'station.c' */
-extern station_ctx_t my_station;
-ipmbox_t *ctx;
-
-static void
-test_buffer_released (test_t t, u32 buffer_id)
-{
- test_begin (t, "ether message BUFFER RELEASED")
- {
- unsigned char buffer[SCI_MSG_MAX_SIZE];
- ether_msg_hdr_t *ether_hdr;
- int fd_in = -1;
-
- /* Open pipe or socket. */
- fd_in = maximus_ether_open (&my_station);
-
- /* Read sci and ether headers. */
- memset (buffer, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof (sci_msg_hdr_t) == read (fd_in, buffer,
- sizeof (sci_msg_hdr_t)))
- && (sizeof (ether_msg_hdr_t) == read (fd_in, buffer + \
- sizeof (sci_msg_hdr_t), sizeof (ether_msg_hdr_t))));
-
- /* Set sci and ether headers pointers. */
- ether_hdr = (ether_msg_hdr_t *) (buffer + sizeof (sci_msg_hdr_t));
-
- /* Check ether header. */
- test_fail_unless ((ETHERNET_TYPE_BUFFER_RELEASED == ether_hdr->type)
- && (ETHERNET_FLAG_NONE == ether_hdr->flags));
-
- /* Read the remaining part of message. */
- test_fail_unless (sizeof (u32) == read (fd_in, buffer + \
- sizeof (sci_msg_hdr_t) + sizeof (ether_msg_hdr_t), sizeof (u32)));
-
- /* Check ether data. */
- test_fail_unless (buffer_id == *(buffer + sizeof (sci_msg_hdr_t) + \
- sizeof (ether_msg_hdr_t)));
-
- /* Close pipe. */
- maximus_ether_close (fd_in);
- } test_end;
-}
-
-static void
-test_ether_msg (test_t t, u8 *frame, int frame_length, u8 ether_type)
-{
- /* Check that the correct ether message has been sent to Maximus. */
- test_begin (t, "ether message")
- {
- unsigned char buffer[SCI_MSG_MAX_SIZE];
- ether_msg_hdr_t *ether_hdr;
- int fd_in = -1;
-
- /* Open pipe or socket. */
- fd_in = maximus_ether_open (&my_station);
-
- /* Read sci and ether headers. */
- memset (buffer, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof (sci_msg_hdr_t) == read (fd_in, buffer,
- sizeof(sci_msg_hdr_t)))
- && (sizeof (ether_msg_hdr_t) == read (fd_in,
- buffer + sizeof (sci_msg_hdr_t),
- sizeof (ether_msg_hdr_t))));
-
- /* Set sci and ether headers pointers. */
- ether_hdr = (ether_msg_hdr_t *) (buffer + sizeof (sci_msg_hdr_t));
-
- /* Check ether header. */
- test_fail_unless ((ether_type == ether_hdr->type)
- && (ETHERNET_FLAG_NONE == ether_hdr->flags));
-
- /* Read the remaining part of message. */
- test_fail_unless (frame_length == read (fd_in, buffer + \
- sizeof (sci_msg_hdr_t) + sizeof (ether_msg_hdr_t), frame_length));
-
- /* Check ether data. */
- test_fail_unless (0 == memcmp (frame, buffer + sizeof (sci_msg_hdr_t) + \
- sizeof (ether_msg_hdr_t), frame_length));
-
- /* Close pipe. */
- maximus_ether_close (fd_in);
- } test_end;
-}
-
-void
-ipmbox_init_test_case (test_t t)
-{
- test_case_begin (t, "init");
-
- test_begin (t, "init")
- {
- ctx = ipmbox_init ();
- test_fail_unless ((EINVAL != errno)
- && (NULL != ctx)
- && (NULL != ctx->first_buffer)
- && (NULL == ctx->first_buffer->next)
- && (0 == ctx->first_buffer->id)
- && (NULL == ctx->first_buffer->data)
- && (ctx->last_buffer == ctx->first_buffer)
- && (0 == ctx->rx_data.length)
- && (0 == ctx->rx_mbx.length)
- && (0 == ctx->rx_empty_buf.length));
- ctx->warning_assert = true;
- } test_end;
-
- maximus_pending_isrs = 0;
-
- return;
-}
-
-void
-ipmbox_register_rx_cb_test_case (test_t t)
-{
- test_case_begin (t, "register rx cb");
-
- test_begin (t, "register rx cb")
- {
- int rx_user_data = 42;
-
- ipmbox_register_rx_data_cb (ctx, (void *) &rx_user_data,
- &rx_cb_data);
- ipmbox_register_rx_mbx_cb (ctx, (void *) &rx_user_data,
- &rx_cb_mbx);
- test_fail_unless (ctx->rx_cb_data != NULL);
- test_fail_unless (ctx->rx_cb_mbx != NULL);
- test_fail_unless (*(int *) ctx->rx_data_user_data == 42);
- /* Check that the correct callback is registered. */
- (*ctx->rx_cb_data) ((void *) &rx_user_data, NULL, 0);
- test_fail_unless (rx_user_data == RX_CB_DATA_USER_DATA);
- /* Check that the correct callback is registered. */
- (*ctx->rx_cb_mbx) ((void *) &rx_user_data, NULL, 0);
- test_fail_unless (rx_user_data == RX_CB_MBX_USER_DATA);
- } test_end;
-}
-
-void
-ipmbox_register_empty_buf_cb_test_case (test_t t)
-{
- test_case_begin (t, "register empty buf cb");
-
- test_begin (t, "register empty buf cb")
- {
- int buf_user_data = 24;
-
- ipmbox_register_empty_buf_cb (ctx, (void *) &buf_user_data,
- &empty_buf_cb);
- test_fail_unless (ctx->empty_buf_cb != NULL);
- test_fail_unless (*(int *) ctx->buf_user_data == 24);
- /* Check that the correct callback is registered. */
- (*ctx->empty_buf_cb) ((void *) &buf_user_data);
- test_fail_unless (buf_user_data == EMPTY_BUF_CB_USER_DATA);
- } test_end;
-}
-
-void
-ipmbox_activate_test_case (test_t t)
-{
- test_case_begin (t, "activate");
-
- test_begin (t, "NULL ipmbox")
- {
- dbg_fatal_try_begin
- {
- ipmbox_activate (NULL, false);
- test_fail_unless (EINVAL == errno);
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("NULL ipmbox\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
- } test_end;
-
- test_begin (t, "activate")
- {
- ipmbox_activate (ctx, true);
- test_fail_unless (EINVAL != errno);
- } test_end;
-
- return;
-}
-
-void
-ipmbox_uninit_test_case (test_t t)
-{
- test_case_begin (t, "uninit");
-
- test_begin (t, "uninit")
- {
- ipmbox_uninit (ctx);
- test_fail_unless (EINVAL != errno);
- } test_end;
-
- return;
-}
-
-void
-ipmbox_tx_data_test_case (test_t t)
-{
- test_case_begin (t, "tx data");
-
- /* Ethernet frame data. */
- int frame_length = 1200;
- u8 frame[1200];
- memset (frame, '\0', frame_length); /* init frame */
-
- /* Mailbox msg. */
- ipmbox_msg_data_t msg_data;
- u32 buf_id = 32;
- int i;
-
- maximus_ipmbox_buffer_t *second_buffer = (maximus_ipmbox_buffer_t *) \
- calloc (1, sizeof (maximus_ipmbox_buffer_t));
- second_buffer->next = NULL;
- second_buffer->id = buf_id;
- second_buffer->data = (u32 *) calloc (frame_length, sizeof (u8));
- for (i = 0; i < frame_length; i++)
- {
- frame[i] = (u8)i;
- *((u8*) second_buffer->data + i) = frame[i];
- }
- ctx->first_buffer->next = second_buffer;
-
- /* Fill data message to send. */
- msg_data.header = ipmbox_msg_create_header_data (frame_length, 0);
- msg_data.buffer_addr = (u32) second_buffer->data;
-
- test_begin (t, "tx data")
- {
- ipmbox_tx_data (ctx, (u32 *) &msg_data, 2);
- test_fail_unless (EINVAL != errno);
- } test_end;
-
- /* Check results. */
- test_ether_msg (t, frame, frame_length, ETHERNET_TYPE_DATA);
- test_buffer_released (t, buf_id);
-}
-
-void
-ipmbox_tx_mbx_test_case (test_t t)
-{
- test_case_begin (t, "tx mbx");
-
- /* Ethernet frame data. */
- int frame_length = 1200;
- u8 frame[1200];
- memset (frame, '\0', frame_length); /* init frame */
-
- /* Mailbox msg. */
- ipmbox_msg_mbx_t msg_mbx;
- u32 buf_id = 32;
- int i;
-
- maximus_ipmbox_buffer_t *second_buffer = (maximus_ipmbox_buffer_t *) \
- calloc (1, sizeof (maximus_ipmbox_buffer_t));
- second_buffer->next = NULL;
- second_buffer->id = buf_id;
- second_buffer->data = (u32 *) calloc (frame_length, sizeof (u8));
- for (i = 0; i < frame_length; i++)
- {
- frame[i] = (u8)i;
- *((u8*) second_buffer->data + i) = frame[i];
- }
- ctx->first_buffer->next = second_buffer;
-
- /* Fill mailbox message to send. */
- msg_mbx.header = ipmbox_msg_create_header_mme_priv (frame_length);
- msg_mbx.buffer_addr = (u32) second_buffer->data;
-
- test_begin (t, "tx mme")
- {
- ipmbox_tx_mbx (ctx, (u32 *) &msg_mbx, 2);
- test_fail_unless (EINVAL != errno);
- } test_end;
-
- /* Check results. */
- test_ether_msg (t, frame, frame_length, ETHERNET_TYPE_MME);
- test_buffer_released (t, buf_id);
-}
-
-void
-ipmbox_tx_empty_buf_test_case (test_t t)
-{
- test_case_begin (t, "tx empty buf");
-
- test_begin (t, "tx empty buf")
- {
- /* Allocate buffer. */
- u32 *data = (u32 *) malloc (1500);
-
- /* Fill empty buffer message to send. */
- ipmbox_msg_empty_buf_t empty_buf_msg;
- empty_buf_msg.buffer_addr = (u32) data;
-
- ipmbox_tx_empty_buf (ctx, (u32 *) &empty_buf_msg, 1);
- test_fail_unless (EINVAL != errno);
- } test_end;
-}
-
-void
-ipmbox_test_suite (test_t t)
-{
- /* Reset errno. */
- errno = 0;
-
- station_init (&my_station);
- station_log_set_level (&my_station, STATION_LOG_DEBUG);
- station_log_set_mask (&my_station, STATION_LOGTYPE_ALL);
-
- test_suite_begin (t, "ipmbox");
- ipmbox_init_test_case (t);
- ipmbox_register_rx_cb_test_case (t);
- ipmbox_register_empty_buf_cb_test_case (t);
- ipmbox_activate_test_case (t);
- ipmbox_tx_data_test_case (t);
- ipmbox_tx_empty_buf_test_case (t);
- ipmbox_tx_mbx_test_case (t);
- ipmbox_uninit_test_case (t);
-
- station_down (&my_station);
-}
diff --git a/cesar/hal/leon/maximus/test/Config b/cesar/hal/leon/maximus/test/Config
deleted file mode 100644
index cba3c8284a..0000000000
--- a/cesar/hal/leon/maximus/test/Config
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_DEBUG = y
-CONFIG_DEBUG_FATAL_CATCH = y
-CONFIG_TRACE = y \ No newline at end of file
diff --git a/cesar/hal/leon/maximus/test/Makefile b/cesar/hal/leon/maximus/test/Makefile
deleted file mode 100644
index 8b594c12a8..0000000000
--- a/cesar/hal/leon/maximus/test/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-BASE = ../../../..
-EXTRA_HOST_CFLAGS+= -DUNIT_TEST
-HOST_PROGRAMS = test_maximus_timer
-test_maximus_timer_SOURCES = test_maximus_timer.c
-test_maximus_timer_MODULES = lib host hal/leon/maximus
-test_maximus_timer_CONFIG_MODULES = mac/common
-INCLUDES = hal/leon/maximus/test/inc
-
-include $(BASE)/common/make/top.mk
diff --git a/cesar/hal/leon/maximus/test/inc/test_maximus_timer.h b/cesar/hal/leon/maximus/test/inc/test_maximus_timer.h
deleted file mode 100644
index ff8a323380..0000000000
--- a/cesar/hal/leon/maximus/test/inc/test_maximus_timer.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef hal_leon_maximus_test_inc_test_maximus_timer_h
-#define hal_leon_maximus_test_inc_test_maximus_timer_h
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/leon/maximus/test/inc/test_maximus_timer.h
- * \brief test header for Maximus.
- * \ingroup hal_leon_maximus
- */
-
-#include "host/fwd.h" // for 'station_ctx_t'
-
-/**
- * DSR callback function.
- * \param user_data user data
- */
-void
-leon_timer_cb (void *user_data);
-
-/**
- * Open pipe or socket.
- * \param station pointer to the station context
- * \return file descriptor for pipe or socket
- */
-int
-maximus_timer_open (station_ctx_t *station);
-
-/**
- * Close pipe.
- * \param fd file descriptor for pipe or socket
- */
-void
-maximus_timer_close (int fd);
-
-#endif /* hal_leon_maximus_test_inc_test_maximus_timer_h */
diff --git a/cesar/hal/leon/maximus/test/src/test_maximus_timer.c b/cesar/hal/leon/maximus/test/src/test_maximus_timer.c
deleted file mode 100644
index 36607c4275..0000000000
--- a/cesar/hal/leon/maximus/test/src/test_maximus_timer.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/leon/maximus/test/src/test_maximus_timer.c
- * \brief HAL leon timer test functions for Maximus.
- * \ingroup hal_leon_maximus
- */
-
-#include "common/std.h"
-#include "lib/test.h"
-#include "lib/trace.h"
-#include "hal/leon/maximus/inc/maximus_timer_ctx.h"
-#include "hal/leon/maximus/inc/maximus_timer.h"
-#include "hal/leon/maximus/inc/maximus_interrupts.h"
-#include "hal/leon/maximus/test/inc/test_maximus_timer.h"
-#include <stdio.h> // for 'printf'
-#include <string.h> // for 'memset'
-#include <netinet/in.h> // for 'ntohl' and 'ntohs' functions
-#include <unistd.h> // for 'read', 'open()' and 'close()'
-#include <fcntl.h> // for 'read', 'open()' and 'close()'
-#include <errno.h>
-
-void leon_timer_test_suite (test_t t);
-
-uint32_t maximus_pending_isrs;
-station_ctx_t my_station;
-leon_timer_t *ctx;
-int user_data = 123456789;
-
-void
-leon_timer_cb (void *data)
-{
- int *my_data = (int *)data;
- *my_data = 987654321;
- return;
-}
-
-int
-maximus_timer_open (station_ctx_t *station)
-{
- int fd;
-
- #ifdef STATION_SOCK
- fd = station->sock_pair_fd;
- #else /* STATION_SOCK */
- fd = open(station->pipe_out_name, O_RDONLY);
- #endif /* STATION_SOCK */
-
- return fd;
-}
-
-void
-maximus_timer_close (int fd)
-{
- #ifndef STATION_SOCK
- close(fd);
- #endif /* !STATION_SOCK */
-}
-
-void
-leon_timer_init_test_case(test_t t)
-{
- printf("init\n");
- test_case_begin(t, "init");
-
- test_begin(t, "init")
- {
- ctx = leon_timer_init ((void *)&user_data, &leon_timer_cb);
- test_fail_unless ((EINVAL != errno)
- && (NULL != ctx)
- && (user_data == *((int *)ctx->user_data))
- && (&leon_timer_cb == ctx->cb));
- ctx->warning_assert = true;
- } test_end;
-
- test_begin(t, "cb")
- {
- (*ctx->cb)(ctx->user_data);
- test_fail_unless (987654321 == *((int *)ctx->user_data));
- } test_end;
-
- maximus_pending_isrs = 0;
-
- return;
-}
-
-void leon_timer_program_test_case(test_t t)
-{
- u32 date = 10;
- netclock_id_t id = 0;
-
- printf("leon timer program\n");
- test_case_begin(t, "leon timer program");
-
- // test a date in the past
- my_station.current_tick_tck = date;
- leon_timer_program (ctx, date-1);
- // test the callback
- test_begin(t, "past date - maximus leon timer cb")
- {
- test_fail_unless ((EINVAL != errno)
- && (maximus_pending_isrs & (1 << HAL_LEON_TIMER_INTERRUPT)));
- } test_end;
- maximus_pending_isrs &= (0 << HAL_LEON_TIMER_INTERRUPT);
-
- date = 0xDEADBEEE;
- leon_timer_program (ctx, date);
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_timer_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'leon_timer_cancel()'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->netclock_id);
-
- // close pipe
- maximus_timer_close(fd_in);
- } test_end;
-
- // test the callback
- test_begin(t, "maximus leon timer cb")
- {
- maximus_leon_timer_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (maximus_pending_isrs & (1 << HAL_LEON_TIMER_INTERRUPT)));
- } test_end;
-
- test_begin(t, "leon timer cb")
- {
- test_fail_unless (NULL != ctx->cb);
- (*ctx->cb)(ctx->user_data);
- maximus_pending_isrs &= (0 << HAL_LEON_TIMER_INTERRUPT);
- } test_end;
-
- id = ctx->netclock_id;
- leon_timer_program (ctx, date+1);
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "cancel netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_timer_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_timer_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "program netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_timer_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date+1 == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'phy_access_timer_cancel'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->netclock_id);
-
- // close pipe
- maximus_timer_close(fd_in);
- } test_end;
-
- return;
-}
-
-void leon_timer_cancel_test_case(test_t t)
-{
- netclock_id_t id = 0;
-
- printf("leon timer cancel\n");
- test_case_begin(t, "leon timer cancel");
-
- test_begin(t, "leon timer cancel")
- {
- id = ctx->netclock_id;
- leon_timer_cancel (ctx);
- test_fail_unless ((EINVAL != errno)
- && (0 == ctx->netclock_id));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_timer_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_timer_close(fd_in);
- } test_end;
-
- return;
-}
-
-void leon_timer_uninit_test_case(test_t t)
-{
- printf("uninit\n");
- test_case_begin(t, "uninit");
-
- test_begin(t, "uninit")
- {
- leon_timer_uninit(ctx);
- test_fail_unless (EINVAL != errno);
- } test_end;
-
- return;
-}
-
-void leon_timer_test_suite(test_t t)
-{
- // reset errno
- errno = 0;
-
- 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;
-
- test_suite_begin(t, "leon timer");
- leon_timer_init_test_case(t);
- leon_timer_program_test_case(t);
- leon_timer_cancel_test_case(t);
- printf("BEGIN_TRACE\n");
- trace_buffer_dbg_dump(&ctx->trace);
- printf("END_TRACE\n");
- leon_timer_uninit_test_case(t);
-
- station_down (&my_station);
-}
-
-int
-main (int argc, char **argv)
-{
- test_t t;
- test_init(t, argc, argv);
-
- trace_init();
- leon_timer_test_suite(t);
- trace_uninit();
-
- test_result(t);
- return test_nb_failed(t) == 0 ? 0 : 1;
-}
diff --git a/cesar/hal/phy/maximus/test/Config b/cesar/hal/phy/maximus/test/Config
deleted file mode 100644
index 0788d5a0df..0000000000
--- a/cesar/hal/phy/maximus/test/Config
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_DEBUG = y
-CONFIG_DEBUG_FATAL_CATCH = y
-CONFIG_TRACE = n
-CONFIG_MAC_COMMON_EOC_TEI = y
diff --git a/cesar/hal/phy/maximus/test/Makefile b/cesar/hal/phy/maximus/test/Makefile
deleted file mode 100644
index a85c0e911a..0000000000
--- a/cesar/hal/phy/maximus/test/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-BASE = ../../../..
-EXTRA_HOST_CFLAGS+= -DUNIT_TEST
-HOST_PROGRAMS = test_phy_maximus
-test_phy_maximus_SOURCES = test_phy_maximus.c test_phy_access.c \
- test_phy_ctrl.c test_pbdma.c \
- test_tmdma.c test_aes.c
-test_phy_maximus_MODULES = lib hal/phy/maximus host
-test_phy_maximus_CONFIG_MODULES = mac
-INCLUDES = hal/phy/maximus/test/inc
-
-include $(BASE)/common/make/top.mk
diff --git a/cesar/hal/phy/maximus/test/inc/test_phy_maximus.h b/cesar/hal/phy/maximus/test/inc/test_phy_maximus.h
deleted file mode 100644
index a4e206e48f..0000000000
--- a/cesar/hal/phy/maximus/test/inc/test_phy_maximus.h
+++ /dev/null
@@ -1,93 +0,0 @@
-#ifndef hal_phy_maximus_test_inc_test_phy_maximus_h
-#define hal_phy_maximus_test_inc_test_phy_maximus_h
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/phy/maximus/test/inc/test_phy_maximus.h
- * \brief test header for Maximus.
- * \ingroup hal_phy_maximus
- */
-
-#include "host/fwd.h" // for 'station_ctx_t'
-
-/**
- * ACCESS event callback.
- * \param user user data
- * \return true if a DSR is requested
- */
-bool phy_access_cb (void *user);
-
-/**
- * ACCESS CONFIRM event callback.
- * \param user user data
- * \return true if a DSR is requested
- */
-bool phy_access_conf_cb (void *user);
-
-/**
- * RX FC event callback.
- * \param user user data
- * \param rx_date start of preamble date
- * \param fc_av frame control, or NULL if FCCS error
- * \return true if a DSR is requested
- */
-bool phy_rx_fc_cb (void *user, u32 rx_date, const u32 *fc_av);
-
-/**
- * TX FALSE ALARM event callback.
- * \param user user data
- * \return true if a DSR is requested
- */
-bool phy_tx_false_alarm_cb (void *user);
-
-/**
- * Zero-cross event callback.
- * \param user user data
- * \return true if a DSR is requested
- *
- * Zero-cross event happens every 20 ms (or 16,67 ms).
- */
-bool phy_zero_cross_cb (void *user, const u32 zero_cross_date);
-
-/**
- * If a DSR was requested, this callback is called.
- * \param user user data
- */
-void phy_deferred_cb (void *user);
-
-/**
- * PB DMA callback called when an interrupt occurs.
- * \param user user data
- * \param status_word status read from PB DMA
- * \return true if a DSR is requested
- */
-bool phy_pbdma_cb (void *user, u32 status_word);
-
-/**
- * Extra timer callback.
- * \param user user data
- * \return true if a DSR is requested
- */
-bool phy_extra_timer_cb (void *user);
-
-/**
- * Open pipe or socket.
- * \param station pointer to the station context
- * \return file descriptor for pipe or socket
- */
-int
-maximus_phy_open (station_ctx_t *station);
-
-/**
- * Close pipe.
- * \param fd file descriptor for pipe or socket
- */
-void
-maximus_phy_close (int fd);
-
-#endif /* hal_phy_maximus_test_inc_test_phy_maximus_h */
diff --git a/cesar/hal/phy/maximus/test/src/test_aes.c b/cesar/hal/phy/maximus/test/src/test_aes.c
deleted file mode 100644
index 8f301ce341..0000000000
--- a/cesar/hal/phy/maximus/test/src/test_aes.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2009 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file src/test_aes.c
- * \brief Test AES functions.
- * \ingroup test
- */
-#include "common/std.h"
-#include "lib/test.h"
-#include "hal/phy/maximus/inc/maximus_aes.h"
-
-void
-aes_test_suite (test_t t)
-{
- test_suite_begin (t, "aes");
- test_case_begin (t, "decryption key");
- test_begin (t, "vectors")
- {
- u32 enc[4] = { 0x68a87ed4, 0x654b7514, 0x11a8efd5, 0x3cf2f390 };
- u32 dec_ref[4] = { 0x159f280b, 0x91a47793, 0x1330fc87, 0x6530c66d };
- u32 dec[4];
- maximus_aes_decryption_key (enc, dec);
- test_fail_unless (dec_ref[0] == dec[0]
- && dec_ref[1] == dec[1]
- && dec_ref[2] == dec[2]
- && dec_ref[3] == dec[3]);
- } test_end;
-}
-
diff --git a/cesar/hal/phy/maximus/test/src/test_pbdma.c b/cesar/hal/phy/maximus/test/src/test_pbdma.c
deleted file mode 100644
index 670d24ab14..0000000000
--- a/cesar/hal/phy/maximus/test/src/test_pbdma.c
+++ /dev/null
@@ -1,315 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/phy/maximus/test/src/test_pbdma.c
- * \brief HAL Phy PB DMA test functions for Maximus.
- * \ingroup hal_phy_maximus
- */
-
-#include "common/std.h"
-#include "lib/test.h"
-#include "lib/trace.h"
-#include "hal/phy/maximus/inc/maximus_phy_ctx.h"
-#include "hal/phy/maximus/inc/maximus_phy_ctrl.h"
-#include "hal/phy/maximus/inc/maximus_interrupts.h"
-#include "hal/phy/maximus/test/inc/test_phy_maximus.h"
-#include "mac/common/defs.h" // for 'MAC_PB520_BYTES'
-#include <stdio.h> // for 'printf'
-#include <string.h> // for 'memset'
-#include <errno.h>
-
-extern station_ctx_t my_station;
-phy_t *ctx;
-
-void phy_pbdma_start_test_case(test_t t)
-{
- printf("pbdma start\n");
- test_case_begin(t, "pbdma start");
-
- bool bypass_aes = false;
- u32 nek[4];
- uint nb_total = PHY_PB_MAX_NB;
- uint nb_pb_it = PHY_PB_MAX_NB-1;
- phy_pb_t pb[PHY_PB_MAX_NB];
- u8 pb_data[PHY_PB_MAX_NB][MAC_PB520_BYTES];
- int i = 0;
- char c = 'a';
-
- memset(nek, 'n', 4*sizeof(u32));
-
- // set pb size (set by 'phy_rx_prepare' in Rx and 'phy_tx_param' in Tx)
- ctx->control.current_tx_param.pb_size = PHY_PB_SIZE_520;
-
- test_begin(t, "pbdma start in Tx")
- {
- // fill PBs for Tx
- for (i=0; i<PHY_PB_MAX_NB; i++)
- {
- memset(pb_data[i], c, MAC_PB520_BYTES);
- pb[i].pb_tx.blk.data = pb_data[i];
- pb[i].pb_tx.header = i+1;
- if (PHY_PB_MAX_NB-1 != i)
- {
- pb[i].pb_tx.blk.next = &pb[i+1].pb_tx.blk;
- }
- else
- {
- pb[i].pb_tx.blk.next = NULL;
- }
- c++;
- }
-
- phy_pbdma_start (ctx, bypass_aes,
- nek, nb_total,
- nb_pb_it, &pb[0], NULL, false);
- test_fail_unless ((EINVAL != errno)
- && (bypass_aes == ctx->pbdma.bypass_aes)
- && (0 == memcmp(nek, ctx->pbdma.nek, 4*sizeof(u32)))
- && (nb_total == ctx->pbdma.nb_total)
- && (nb_total == ctx->pbdma.nb_ready)
- && (nb_pb_it == ctx->pbdma.nb_pb_it)
- && (pb == ctx->pbdma.first_pb)
- && (!ctx->pbdma.chandata_transfer)
- && (ctx->pbdma.current_pb == &ctx->pbdma.first_pb->pb_rx));
- phy_pb_tx_t * current_pb = &ctx->pbdma.first_pb->pb_tx;
- for (i=0; i<PHY_PB_MAX_NB; i++)
- {
- test_fail_unless (0 == memcmp(pb_data[i], current_pb->blk.data, MAC_PB520_BYTES));
- current_pb = PARENT_OF(phy_pb_tx_t, blk, current_pb->blk.next);
- }
- } test_end;
-
- // set pb size (set by 'phy_rx_prepare' in Rx and 'phy_tx_param' in Tx)
- ctx->control.rx_param.pb_size = PHY_PB_SIZE_520;
-
- test_begin(t, "pbdma start in Rx")
- {
- // reset PBs for Rx
- for (i=0; i<PHY_PB_MAX_NB; i++)
- {
- memset(pb_data[i], '\0', MAC_PB520_BYTES);
- pb[i].pb_rx.blk.data = pb_data[i];
- pb[i].pb_rx.header = 0;
- memset(&pb[i].pb_rx.pb_measurement, '\0', sizeof(pb_measurement_t));
- if (PHY_PB_MAX_NB-1 != i)
- {
- pb[i].pb_rx.blk.next = &pb[i+1].pb_rx.blk;
- }
- else
- {
- pb[i].pb_rx.blk.next = NULL;
- }
- c++;
- }
-
- phy_pbdma_start (ctx, bypass_aes,
- nek, nb_total,
- nb_pb_it, &pb[0], NULL, false);
- test_fail_unless ((EINVAL != errno)
- && (bypass_aes == ctx->pbdma.bypass_aes)
- && (0 == memcmp(nek, ctx->pbdma.nek, 4*sizeof(u32)))
- && (nb_total == ctx->pbdma.nb_total)
- && (nb_total == ctx->pbdma.nb_ready)
- && (nb_pb_it == ctx->pbdma.nb_pb_it)
- && (pb == ctx->pbdma.first_pb)
- && (!ctx->pbdma.chandata_transfer)
- && (ctx->pbdma.current_pb == &ctx->pbdma.first_pb->pb_rx));
- } test_end;
-}
-
-void phy_pbdma_update_test_case(test_t t)
-{
- printf("pbdma update\n");
- test_case_begin(t, "pbdma update");
-
- test_begin(t, "pbdma update")
- {
- uint nb_pb_it = PHY_PB_MAX_NB-1;
-
- phy_pbdma_update (ctx, nb_pb_it);
- test_fail_unless ((EINVAL != errno)
- && (nb_pb_it == ctx->pbdma.nb_pb_it));
- } test_end;
-}
-
-void phy_pbdma_get_tail_test_case(test_t t)
-{
- printf("pbdma get tail\n");
- test_case_begin(t, "pbdma get tail");
-
- /* To test the 'phy_pbdma_get_tail()' function, an MPDU frame has to be received by the station,
- * to check if the current PB of the PHY context points to the last PB, as expected. */
-
- test_begin(t, "pbdma get tail")
- {
- unsigned short int pb_counter;
- sci_msg_t msg;
- unsigned char buffer[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t phy_hdr;
- sci_msg_hdr_t sci_hdr;
- u8 pb_data[PHY_PB_MAX_NB][MAC_PB520_BYTES];
- phy_pb_t phy_pb[PHY_PB_MAX_NB];
-
- // set PBDMA
- ctx->pbdma.first_pb = phy_pb;
- ctx->pbdma.current_pb = &ctx->pbdma.first_pb->pb_rx;
-
- // set MPDU reception conditions
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_RX_MPDU;
- ctx->control.rx_prepared = true;
-
- // fill in the SCI data with an MPDU composed of 3 PBs
- test_fail_unless ((0 == sci_msg_init(&msg, buffer, SCI_MSG_MAX_SIZE))
- && (EINVAL != errno));
- for (pb_counter = 0; pb_counter < PHY_PB_MAX_NB; pb_counter++)
- {
- test_fail_unless (0 <= sci_msg_push (&msg, MAC_PB520_BYTES)
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memset(&pb_data[pb_counter][0], '\0', MAC_PB520_BYTES);
- memcpy(msg.data_begin, &pb_data[pb_counter][0], MAC_PB520_BYTES);
- phy_pb[pb_counter].pb_rx.blk.data = &pb_data[pb_counter][0];
- if (PHY_PB_MAX_NB-1 != pb_counter)
- {
- phy_pb[pb_counter].pb_rx.blk.next = &phy_pb[pb_counter+1].pb_rx.blk;
- }
- else
- {
- phy_pb[pb_counter].pb_rx.blk.next = NULL;
- }
- }
-
- // set the expected current PB pointer
- phy_pb_rx_t *current_pb = ctx->pbdma.current_pb;
- for (pb_counter = 1; pb_counter < PHY_PB_MAX_NB; pb_counter++)
- {
- current_pb = PARENT_OF(phy_pb_rx_t, blk, current_pb->blk.next);
- }
-
- // fill in the PHY header
- memset(&phy_hdr, '\0', sizeof(phy_msg_hdr_t));
- phy_hdr.version = PHY_VERSION;
- phy_hdr.type = PHY_TYPE_MPDU_PAYLOAD;
- phy_hdr.mpdu_format = PHY_MPDU_FORMAT_BEACON;
- phy_hdr.pb_nb = PHY_PB_MAX_NB;
- phy_hdr.msg_nb = 1;
- phy_hdr.fc_mode = PHY_FC_MODE_AV_2;
- phy_hdr.short_ppdu = false;
- phy_hdr.mod = PHY_MOD_ROBO;
- phy_hdr.fecrate = PHY_FEC_RATE_1_2;
- phy_hdr.gil = PHY_GIL_417;
- phy_hdr.tonemap_index = 0;
- phy_hdr.reserved = 0;
- phy_hdr.tx_id = 0;
- phy_hdr.flags = ntohs(0x0006);
- phy_hdr.symbol_nb = 0;
-
- // fill in the SCI data with the PHY header
- test_fail_unless (0 <= sci_msg_push (&msg, sizeof (phy_msg_hdr_t))
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy(msg.data_begin, &phy_hdr, sizeof(phy_msg_hdr_t));
-
- // fill in the SCI header
- memcpy((unsigned char *)&sci_hdr.magic_id, SCI_MSG_MAGIC, 4);
- sci_hdr.version = SCI_MSG_VERSION;
- sci_hdr.type = SCI_MSG_TYPE_PHY;
- sci_hdr.flags = 0;
- sci_hdr.station_id = htons(my_station.id);
- sci_hdr.length = msg.length - sizeof(sci_msg_hdr_t);
- sci_hdr.msg_id = my_station.sci->current_msg_id | SCI_MSG_ID_STATION;
- sci_hdr.netclock_high = my_station.current_tick_tck >> 32;
- sci_hdr.netclock_low = my_station.current_tick_tck & 0xffffffff;
- msg.sci_hdr = &sci_hdr;
-
- // set station id
- ctx->control.rx_param.src_station_id = my_station.id;
-
- // simulates the fact that the station receives the built MPDU
- test_fail_unless ((0 <= (maximus_phy_recv(&msg, ctx)))
- && (EINVAL != errno)
- && (EPROTO != errno));
-
- // test if the 'phy_pbdma_get_tail()' result points to the expected PB
- test_fail_unless ((EINVAL != errno)
- && (PARENT_OF(phy_pb_t, pb_rx, current_pb) == phy_pbdma_get_tail(ctx)));
- } test_end;
-}
-
-void phy_pbdma_start_chandata_test_case(test_t t)
-{
- printf("pbdma start chandata\n");
- test_case_begin(t, "pbdma start chandata");
-
- phy_chandata_t chandata;
- unsigned short int chandata_size = 128;
- u8 chandata_data[4*chandata_size];
-
- test_begin(t, "pbdma start chandata in Tx")
- {
- // fill chandata for Tx
- memset(chandata_data, 'd', 4*chandata_size);
- chandata.blk.next = NULL;
- chandata.blk.data = chandata_data;
- chandata.conf.size = chandata_size;
- chandata.conf.last = 1;
- chandata.conf.type = PHY_CHANDATA_TYPE_NRJ_SYMBOL;
- chandata.conf.address = 0;
-
- phy_pbdma_start_chandata (ctx, &chandata);
- test_fail_unless ((EINVAL != errno)
- && (&chandata == ctx->pbdma.first_chandata)
- && (0 == memcmp(chandata_data, ctx->pbdma.first_chandata->blk.data, 4*chandata_size))
- && (ctx->pbdma.chandata_transfer));
- } test_end;
-
- test_begin(t, "pbdma start chandata in Rx")
- {
- phy_pbdma_start_chandata (ctx, &chandata);
- test_fail_unless ((EINVAL != errno)
- && (&chandata == ctx->pbdma.first_chandata)
- && (ctx->pbdma.chandata_transfer));
- } test_end;
-}
-
-void pbdma_test_suite(test_t t)
-{
- int user_data = 1234567890;
-
- // reset errno
- errno = 0;
-
- 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;
- trace_init();
- ctx = phy_init ((void*)&user_data,
- &phy_rx_fc_cb,
- &phy_access_cb,
- &phy_access_conf_cb,
- &phy_pbdma_cb,
- &phy_tx_false_alarm_cb,
- &phy_deferred_cb);
- ctx->warning_assert = true;
-
- test_suite_begin(t, "pb dma");
- phy_pbdma_start_test_case(t);
- phy_pbdma_update_test_case(t);
- phy_pbdma_get_tail_test_case(t);
- phy_pbdma_start_chandata_test_case(t);
-
-#if CONFIG_TRACE
- printf("BEGIN_TRACE\n");
- trace_buffer_dbg_dump(&ctx->trace);
- printf("END_TRACE\n");
-#endif
- phy_uninit (ctx);
- trace_uninit();
- station_down (&my_station);
-}
diff --git a/cesar/hal/phy/maximus/test/src/test_phy_access.c b/cesar/hal/phy/maximus/test/src/test_phy_access.c
deleted file mode 100644
index efeffb3b36..0000000000
--- a/cesar/hal/phy/maximus/test/src/test_phy_access.c
+++ /dev/null
@@ -1,884 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/phy/maximus/test/src/test_phy_access.c
- * \brief HAL Phy access test functions for Maximus.
- * \ingroup hal_phy_maximus
- */
-
-#include "common/std.h"
-#include "lib/test.h"
-#include "lib/trace.h"
-#include "maximus/common/types/phy_types.h"
-#include "host/fwd.h" // for 'phy_msg_hdr_t'
-#include "hal/phy/maximus/inc/maximus_phy_ctx.h"
-#include "hal/phy/maximus/inc/maximus_phy_access.h"
-#include "hal/phy/maximus/inc/maximus_phy_ctrl.h" // for 'maximus_phy_recv_preamble_cb()'
-#include "hal/phy/maximus/inc/maximus_interrupts.h"
-#include "hal/phy/maximus/test/inc/test_phy_maximus.h"
-#include "mac/common/timings.h" // for 'MAC_SLOT_TCK'
-#include <stdio.h> // for 'printf'
-#include <string.h> // for 'memset'
-#include <netinet/in.h> // for 'ntohl' and 'ntohs' functions
-#include <unistd.h> // for 'read'
-#include <fcntl.h> // for 'read'
-#include <errno.h>
-
-extern uint32_t maximus_pending_isrs; // used in 'station.c'
-extern station_ctx_t my_station;
-phy_t *ctx;
-
-void phy_access_backoff_start_test_case(test_t t)
-{
- u32 date = 10;
- uint cap = 3;
- tick_t msg_tick_tck;
- netclock_id_t id;
-
- printf("backoff start\n");
- test_case_begin(t, "backoff start");
-
- test_begin(t, "backoff start")
- {
- phy_access_backoff_start (ctx, date, cap);
- test_fail_unless (EINVAL != errno);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message for backoff cb")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr->tick_low));
-
- // close pipe
- maximus_phy_close(fd_in);
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr->tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr->tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr->id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the backoff callback
- test_begin(t, "backoff cb")
- {
- maximus_phy_access_backoff_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno) && (EPROTO != errno));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message for slot count cb")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless ((my_station.current_tick_tck & 0x00000000FFFFFFFF) + (unsigned long)MAC_SLOT_TCK == ntohl(netclock_hdr->tick_low));
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr->id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message for prs0 cb")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless ((my_station.current_tick_tck & 0x00000000FFFFFFFF) + (unsigned long)MAXIMUS_PHY_PRS_DETECTION_DELAY_TCK == ntohl(netclock_hdr->tick_low));
-
- // close pipe
- maximus_phy_close(fd_in);
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr->tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr->tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr->id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the PRS0 callback
- test_begin(t, "prs0 cb")
- {
- maximus_phy_access_prs0_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (MAXIMUS_PHY_MEDIUM_PRS0 == ctx->access.medium_state));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "phy message for PRS0")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
- uint8_t prs0 = 1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && ((int)(sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)) == read(fd_in, data, sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_PRS == phy_hdr->type);
-
- // read the remaining part of message
- test_fail_unless (sizeof(uint8_t) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint8_t)));
-
- // check phy data
- test_fail_unless (0 == memcmp(&prs0, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(u8)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message for prs0 result cb")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- sci_msg_hdr_t *sci_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set sci and netclock headers pointers
- sci_hdr = (sci_msg_hdr_t *)(data);
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless ((my_station.current_tick_tck & 0x00000000FFFFFFFF) + (unsigned long)MAC_SLOT_TCK - (unsigned long)MAXIMUS_PHY_PRS_DETECTION_DELAY_TCK == ntohl(netclock_hdr->tick_low));
-
- // close pipe
- maximus_phy_close(fd_in);
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(sci_hdr->netclock_high))) << 32)
- | (unsigned long long)(ntohl(sci_hdr->netclock_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr->id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the slot count callback
- test_begin(t, "slot count cb")
- {
- maximus_phy_access_slot_count_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (EPROTO != errno)
- && (1 == ctx->access.slot_count));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message for slot count cb")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless ((my_station.current_tick_tck & 0x00000000FFFFFFFF) + (unsigned long)MAC_SLOT_TCK == ntohl(netclock_hdr->tick_low));
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr->id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
-
- // reset slot count netclock id (because callback will not be called)
- ctx->access.backoff_slot_count_netclock_id = 0;
- } test_end;
-
- // test the prs0 result callback
- test_begin(t, "prs0 result cb")
- {
- maximus_phy_access_prs0_result_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (MAXIMUS_PHY_MEDIUM_PRS1 == ctx->access.medium_state)
- && ctx->access.prp_result);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message for prs1 cb")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- sci_msg_hdr_t *sci_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set sci and netclock headers pointers
- sci_hdr = (sci_msg_hdr_t *)(data);
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless ((my_station.current_tick_tck & 0x00000000FFFFFFFF) + (unsigned long)MAXIMUS_PHY_PRS_DETECTION_DELAY_TCK == ntohl(netclock_hdr->tick_low));
-
- // close pipe
- maximus_phy_close(fd_in);
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(sci_hdr->netclock_high))) << 32)
- | (unsigned long long)(ntohl(sci_hdr->netclock_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr->id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the prs1 callback
- test_begin(t, "prs1 cb")
- {
- maximus_phy_access_prs1_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (MAXIMUS_PHY_MEDIUM_PRS1 == ctx->access.medium_state));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "phy message for PRS1")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
- uint8_t prs1 = 1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && ((int)(sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)) == read(fd_in, data, sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_PRS == phy_hdr->type);
-
- // read the remaining part of message
- test_fail_unless (sizeof(uint8_t) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint8_t)));
-
- // check phy data
- test_fail_unless (0 == memcmp(&prs1, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(u8)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message for prp result cb")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- sci_msg_hdr_t *sci_hdr;
- int fd_in = -1;
-
- // open pipe ro socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set sci and netclock headers pointers
- sci_hdr = (sci_msg_hdr_t *)(data);
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless ((my_station.current_tick_tck & 0x00000000FFFFFFFF) + (unsigned long)MAC_SLOT_TCK - (unsigned long)MAXIMUS_PHY_PRS_DETECTION_DELAY_TCK - 1 == ntohl(netclock_hdr->tick_low));
-
- // close pipe
- maximus_phy_close(fd_in);
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(sci_hdr->netclock_high))) << 32)
- | (unsigned long long)(ntohl(sci_hdr->netclock_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- /* Do not remove netclock callback (for next test). */
- } test_end;
-
- id = ctx->access.backoff_start_netclock_id;
-
- test_begin(t, "backoff start again")
- {
- phy_access_backoff_start (ctx, date+100000, cap);
- test_fail_unless (EINVAL != errno);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "cancel netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "backoff start netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date+100000 == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'phy_access_timer_cancel'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->access.backoff_start_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // test the prp result callback
- test_begin(t, "prp result cb")
- {
- maximus_phy_access_prp_result_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (MAXIMUS_PHY_MEDIUM_CW == ctx->access.medium_state)
- && ctx->control.pre_detection
- && ctx->access.prp_result);
- } test_end;
-
- return;
-}
-
-void phy_access_backoff_update_test_case(test_t t)
-{
- printf("backoff update\n");
- test_case_begin(t, "backoff update");
-
- test_begin(t, "backoff update")
- {
- uint cap = 2;
-
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_IDLE;
- phy_access_backoff_update (ctx, cap);
- test_fail_unless ((EINVAL != errno)
- && (cap == (uint)ctx->access.cap_mpdu));
- } test_end;
-
- return;
-}
-
-void phy_access_backoff_slot_count_test_case(test_t t)
-{
- printf("backoff slot count\n");
- test_case_begin(t, "backoff slot count");
-
- test_begin(t, "backoff slot count")
- {
- test_fail_unless ((ctx->access.slot_count == phy_access_backoff_slot_count(ctx))
- && (EINVAL != errno));
- } test_end;
-
- return;
-}
-
-void phy_access_backoff_prp_won_test_case(test_t t)
-{
- printf("backoff prp won\n");
- test_case_begin(t, "backoff prp won");
-
- test_begin(t, "backoff prp won")
- {
- if (NULL != ctx)
- {
- ctx->access.prp_result = true;
- }
- test_fail_unless ((ctx->access.prp_result == phy_access_backoff_prp_won(ctx))
- && (EINVAL != errno));
- } test_end;
-
- return;
-}
-
-void phy_access_timer_program_test_case(test_t t)
-{
- u32 date = my_station.current_tick_tck + 20;
- netclock_id_t id = 0;
-
- printf("timer program\n");
- test_case_begin(t, "timer program");
-
- test_begin(t, "timer program")
- {
- phy_access_timer_program (ctx, date);
- test_fail_unless(EINVAL != errno);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'phy_access_timer_cancel'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->access.timer_program_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- id = ctx->access.timer_program_netclock_id;
- phy_access_timer_program (ctx, date+1);
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "cancel netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "program netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date+1 == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'phy_access_timer_cancel'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->access.timer_program_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- /* Test that access timer is cancelled when entering into BUSY-RX state. */
- id = ctx->access.timer_program_netclock_id;
- maximus_phy_recv_preamble_t data;
- data.ctx = ctx;
- data.wrong_preamble = false;
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_WAIT_CONF;
- ctx->control.pre_detection = true;
- maximus_phy_recv_preamble_cb (&data);
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "cancel netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- phy_access_timer_program (ctx, date+1);
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "program netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date+1 == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'phy_access_timer_cancel'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->access.timer_program_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr->id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the callback
- test_begin(t, "maximus acces timer cb")
- {
- maximus_phy_access_timer_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PHY))
- && (ctx->control.current_cb == ctx->control.access_cb));
- } test_end;
-
- test_begin(t, "access cb")
- {
- test_fail_unless ((NULL != ctx->control.access_cb)
- && ((*ctx->control.access_cb)(ctx->control.user_data)));
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
- } test_end;
-
- return;
-}
-
-void phy_access_timer_cancel_test_case(test_t t)
-{
- netclock_id_t id = 0;
-
- printf("timer cancel\n");
- test_case_begin(t, "timer cancel");
-
- test_begin(t, "timer cancel")
- {
- phy_access_timer_program (ctx, my_station.current_tick_tck+1);
- id = ctx->access.timer_program_netclock_id;
- phy_access_timer_cancel (ctx);
- test_fail_unless ( (EINVAL != errno)
- && (0 == ctx->access.timer_program_netclock_id) );
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- return;
-}
-
-void phy_access_test_suite(test_t t)
-{
- int user_data = 1234567890;
-
- // reset errno
- errno = 0;
-
- 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;
- trace_init();
- ctx = phy_init ((void*)&user_data,
- &phy_rx_fc_cb,
- &phy_access_cb,
- &phy_access_conf_cb,
- &phy_pbdma_cb,
- &phy_tx_false_alarm_cb,
- &phy_deferred_cb);
- ctx->warning_assert = true;
-
- test_suite_begin(t, "phy access");
- phy_access_backoff_start_test_case(t);
- phy_access_backoff_update_test_case(t);
- phy_access_backoff_slot_count_test_case(t);
- phy_access_backoff_prp_won_test_case(t);
- phy_access_timer_program_test_case(t);
- phy_access_timer_cancel_test_case(t);
-
-#if CONFIG_TRACE
- printf("BEGIN_TRACE\n");
- trace_buffer_dbg_dump(&ctx->trace);
- printf("END_TRACE\n");
-#endif
- phy_uninit (ctx);
- trace_uninit();
- station_down (&my_station);
-}
diff --git a/cesar/hal/phy/maximus/test/src/test_phy_ctrl.c b/cesar/hal/phy/maximus/test/src/test_phy_ctrl.c
deleted file mode 100644
index 1d0b0d9da2..0000000000
--- a/cesar/hal/phy/maximus/test/src/test_phy_ctrl.c
+++ /dev/null
@@ -1,3856 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/phy/maximus/test/src/test_phy_ctrl.c
- * \brief HAL Phy control test functions for Maximus.
- * \ingroup hal_phy_maximus
- */
-
-#include "common/std.h"
-#include "lib/test.h"
-#include "lib/trace.h"
-#include "hal/phy/maximus/inc/maximus_phy_ctx.h"
-#include "hal/phy/maximus/inc/maximus_phy_ctrl.h"
-#include "hal/phy/maximus/inc/maximus_interrupts.h"
-#include "hal/phy/maximus/dur/inc/maximus_dur.h"
-#include "hal/phy/maximus/inc/maximus_defs.h"
-#include "hal/phy/maximus/test/inc/test_phy_maximus.h"
-#include "mac/common/timings.h" // for 'MAC_PREAMBLE_TCK', 'MAC_PREAMBLE_HYBRID_TCK', 'MAC_FC_10_TCK' and 'MAC_FC_AV_TCK'
-#include "mac/common/defs.h" // for 'MAC_PB520_BYTES', 'MAC_MAX_SYMB_PER_MPDU' and 'MAC_MAX_PB_PER_MPDU'
-#include <stdio.h> // for 'printf'
-#include <string.h> // for 'memset'
-#include <netinet/in.h> // for 'ntohl' and 'ntohs' functions
-#include <unistd.h> // for 'read'
-#include <fcntl.h> // for 'read'
-#include <errno.h>
-
-#define PHY_PB_NB 96 //MAC_MAX_PB_PER_MPDU // for 'maximus_phy_recv_test_case' (PHY_TYPE_MPDU_PAYLOAD) and 'maximus_phy_send_test_case'
-
-extern uint32_t maximus_pending_isrs; // used in 'station.c'
-extern station_ctx_t my_station;
-phy_t *ctx;
-int user_data = 1234567890;
-
-void maximus_phy_get_medium_state_test_case(test_t t)
-{
- printf("get medium state\n");
- test_case_begin(t, "get medium state");
-
- test_begin(t, "NULL ctx")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ( (NULL == maximus_phy_get_medium_state(NULL))
- && (EINVAL == errno) );
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("get medium state with NULL ctx\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "invalid medium state")
- {
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_STATE_NB;
-
- dbg_fatal_try_begin
- {
- test_fail_unless ( (NULL == maximus_phy_get_medium_state(ctx))
- && (EINVAL == errno) );
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("get medium state with invalid medium state\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "valid medium states")
- {
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_TX;
- test_fail_unless ( !strcmp(maximus_phy_get_medium_state(ctx), "MAXIMUS_PHY_MEDIUM_BUSY_TX")
- && (EINVAL != errno) );
-
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_IDLE;
- test_fail_unless ( !strcmp(maximus_phy_get_medium_state(ctx), "MAXIMUS_PHY_MEDIUM_IDLE")
- && (EINVAL != errno) );
- } test_end;
-}
-
-void maximus_phy_fill_hdr_test_case(test_t t)
-{
- printf("fill hdr\n");
- test_case_begin(t, "fill hdr");
-
- sci_msg_t msg;
- unsigned char buffer[SCI_MSG_MAX_SIZE];
- uint8_t type = PHY_TYPE_MPDU_PAYLOAD;
- uint8_t mpdu_format = PHY_MPDU_FORMAT_SOF;
- uint8_t pb_nb = PHY_PB_MAX_NB;
- uint8_t msg_nb = 1;
- uint8_t fc_mode = PHY_FC_MODE_HYBRID_1;
- uint8_t short_ppdu = 0;
- uint8_t mod = PHY_MOD_ROBO;
- uint8_t fecrate = PHY_FEC_RATE_1_2;
- uint8_t gil = PHY_GIL_417;
- uint8_t tonemap_index = 0;
- uint16_t tx_id = 0;
- uint16_t flags = 0x0006;
- uint32_t symbol_nb = 0;
- uint32_t iv[3];
- uint32_t nek[4];
- uint32_t pb_measurement[PHY_PB_MAX_NB];
- uint32_t pb_header[PHY_PB_MAX_NB];
-
- memset(iv, 'a', 3*sizeof(uint32_t));
- memset(nek, 'b', 4*sizeof(uint32_t));
- memset(pb_measurement, 'c', PHY_PB_MAX_NB*sizeof(uint32_t));
- memset(pb_header, 'd', PHY_PB_MAX_NB*sizeof(uint32_t));
-
- test_begin(t, "sci init")
- {
- memset(buffer, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((0 == sci_msg_init(&msg, buffer, SCI_MSG_MAX_SIZE))
- && (EINVAL != errno));
- msg.length = 0;
- } test_end;
-
- test_begin(t, "fill hdr")
- {
- test_fail_unless ((0 == maximus_phy_fill_hdr(ctx,
- &msg,
- type,
- mpdu_format,
- pb_nb,
- msg_nb,
- fc_mode,
- short_ppdu,
- mod,
- fecrate,
- gil,
- tonemap_index,
- tx_id,
- flags,
- symbol_nb,
- iv,
- nek,
- pb_measurement,
- pb_header))
- && (EINVAL != errno)
- && (PHY_VERSION == msg.hdr.phy->version)
- && (type == msg.hdr.phy->type)
- && (mpdu_format == msg.hdr.phy->mpdu_format)
- && (pb_nb == msg.hdr.phy->pb_nb)
- && (msg_nb == msg.hdr.phy->msg_nb)
- && (fc_mode == msg.hdr.phy->fc_mode)
- && (short_ppdu == msg.hdr.phy->short_ppdu)
- && (mod == msg.hdr.phy->mod)
- && (fecrate == msg.hdr.phy->fecrate)
- && (gil == msg.hdr.phy->gil)
- && (tonemap_index == msg.hdr.phy->tonemap_index)
- && (tx_id == ntohs(msg.hdr.phy->tx_id))
- && (flags == ntohs(msg.hdr.phy->flags))
- && (symbol_nb == ntohl(msg.hdr.phy->symbol_nb))
- && (0 == memcmp (iv, msg.hdr.phy->iv, 3*sizeof(uint32_t)))
- && (0 == memcmp (nek, msg.hdr.phy->nek, 4*sizeof(uint32_t)))
- && (0 == memcmp (pb_measurement, msg.hdr.phy->pb_measurement, pb_nb*sizeof(uint32_t)))
- && (0 == memcmp (pb_header, msg.hdr.phy->pb_header, pb_nb*sizeof(uint32_t))));
- } test_end;
-
- test_begin(t, "fill hdr with incorrect flags")
- {
- flags = 0x0010;
-
- dbg_fatal_try_begin
- {
- test_fail_unless ((-1 == maximus_phy_fill_hdr(ctx,
- &msg,
- type,
- mpdu_format,
- pb_nb,
- msg_nb,
- fc_mode,
- short_ppdu,
- mod,
- fecrate,
- gil,
- tonemap_index,
- tx_id,
- flags,
- symbol_nb,
- iv,
- nek,
- pb_measurement,
- pb_header))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("fill hdr with incorrect flags\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "fill hdr with incorrect number of PBs")
- {
- flags = 0x0000;
- pb_nb = MAC_MAX_PB_PER_MPDU + 1;
-
- dbg_fatal_try_begin
- {
- test_fail_unless ((-1 == maximus_phy_fill_hdr(ctx,
- &msg,
- type,
- mpdu_format,
- pb_nb,
- msg_nb,
- fc_mode,
- short_ppdu,
- mod,
- fecrate,
- gil,
- tonemap_index,
- tx_id,
- flags,
- symbol_nb,
- iv,
- nek,
- pb_measurement,
- pb_header))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("fill hdr with incorrect number of PBs\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
- } test_end;
-}
-
-void maximus_phy_recv_test_case(test_t t)
-{
- // for PHY_TYPE_NOISE
- static phy_noise_energy_t freq_noise[PHY_CARRIER_NB];
- static phy_noise_energy_t time_noise[MAC_MAX_SYMB_PER_MPDU];
- const unsigned short int max_transfer_size = 128; // in words
- const unsigned short int freq_noise_count = ((PHY_CARRIER_NB * sizeof(phy_noise_energy_t)) + ((max_transfer_size * 4) - 1)) / (max_transfer_size * 4);
- const unsigned short int time_noise_count = ((MAC_MAX_SYMB_PER_MPDU * sizeof(phy_noise_energy_t)) + ((max_transfer_size * 4) - 1)) / (max_transfer_size * 4);
- static phy_chandata_t freq_noise_chandata[10];
- static phy_chandata_t time_noise_chandata[1];
- static u8 freq_noise_data[10*MAC_PB520_BYTES];
- static u8 time_noise_data[1*MAC_PB520_BYTES];
- phy_chandata_t *current_chandata = NULL;
- unsigned int i = 0;
-
- sci_msg_t msg;
- unsigned char buffer[SCI_MSG_MAX_SIZE];
-
- printf("recv\n");
- test_case_begin(t, "recv");
-
- test_begin(t, "sci init")
- {
- memset(buffer, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((0 == sci_msg_init(&msg, buffer, SCI_MSG_MAX_SIZE))
- && (EINVAL != errno));
- msg.length = 0;
- } test_end;
-
- test_begin(t, "NULL msg")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_phy_recv(NULL, ctx)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("NULL msg\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "NULL phy")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_phy_recv(&msg, NULL)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("NULL phy\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "recv")
- {
- unsigned short int pb_counter;
-
- // phy header
- phy_msg_hdr_t phy_hdr;
- u32 iv[3];
- u32 nek[4];
- pb_measurement_t pb_measurement[PHY_PB_MAX_NB];
- u32 pb_header[PHY_PB_MAX_NB];
-
- // sci header
- sci_msg_hdr_t sci_hdr;
-
- // sci data
- u32 fc_10 = 1234567890; // for PHY_TYPE_FC_HYBRID_MODE
- u32 fc_av[4]; // for PHY_TYPE_FC_HYBRID_MODE and PHY_TYPE_FC_AV_ONLY_MODE
- u32 prs = 1; // for PHY_TYPE_PRS
- // for PHY_TYPE_MPDU_PAYLOAD
- u8 pb_data[PHY_PB_NB][MAC_PB520_BYTES];
- phy_pb_t phy_pb[PHY_PB_NB];
- // for PHY_TYPE_TONEMAP
- u8 tonemap1_data[MAC_PB520_BYTES];
- u8 tonemap2_data[(PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES];
-
- // initialize sci data
- char c = '1';
- memset(iv, 'z', 3*sizeof(u32));
- memset(nek, 'a', 4*sizeof(u32));
- memset(pb_measurement, '0', PHY_PB_MAX_NB*sizeof(pb_measurement_t));
- memset(pb_header, '0', PHY_PB_MAX_NB*sizeof(u32));
- memset(fc_av, 'b', 4*sizeof(u32));
- memset(freq_noise_data, '\0', freq_noise_count*MAC_PB520_BYTES);
- memset(time_noise_data, '\0', time_noise_count*MAC_PB520_BYTES);
- for (i=0; i<PHY_CARRIER_NB; i++)
- {
- freq_noise[i] = 2*i;
- }
- for (i=0; i<MAC_MAX_SYMB_PER_MPDU; i++)
- {
- time_noise[i] = PHY_CARRIER_NB + i;
- }
- for (pb_counter = 0; pb_counter < PHY_PB_MAX_NB; pb_counter++)
- {
- memset(&pb_measurement[pb_counter], c, sizeof(pb_measurement_t));
- c++;
- memset(&pb_header[pb_counter], c, sizeof(u32));
- c++;
- }
- c = 0x00;
- for (pb_counter = 0; pb_counter < PHY_PB_NB; pb_counter++)
- {
- memset(&pb_data[pb_counter][0], c, MAC_PB520_BYTES*sizeof(u8));
- c++;
- }
- memset(tonemap1_data, '9', MAC_PB520_BYTES);
- memset(tonemap2_data, '8', (PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES);
-
- // fill the phy header
- phy_hdr.version = PHY_VERSION;
- phy_hdr.type = PHY_TYPE_NONE;
- phy_hdr.mpdu_format = PHY_MPDU_FORMAT_NONE;
- phy_hdr.pb_nb = PHY_PB_MAX_NB;
- phy_hdr.msg_nb = 1;
- phy_hdr.fc_mode = PHY_FC_MODE_AV_2;
- phy_hdr.short_ppdu = 0;
- phy_hdr.mod = PHY_MOD_ROBO;
- phy_hdr.fecrate = PHY_FEC_RATE_1_2;
- phy_hdr.gil = PHY_GIL_417;
- phy_hdr.tonemap_index = 0;
- phy_hdr.reserved = 0;
- phy_hdr.tx_id = 10;
- phy_hdr.flags = htons(0x0006);
- phy_hdr.symbol_nb = 0;
- memcpy(phy_hdr.iv, iv, 3*sizeof(uint32_t));
- memcpy(phy_hdr.nek, nek, 4*sizeof(uint32_t));
- memcpy(phy_hdr.pb_measurement, pb_measurement, PHY_PB_MAX_NB*sizeof(uint32_t));
- memcpy(phy_hdr.pb_header, pb_header, PHY_PB_MAX_NB*sizeof(uint32_t));
-
- // set RX parameters
- ctx->control.rx_param.fc_mode = phy_hdr.fc_mode;
-
- for (phy_hdr.type = PHY_TYPE_NONE; phy_hdr.type < PHY_TYPE_NB; phy_hdr.type++)
- {
- /* Fill the sci data. */
- // test phy type none
- if (PHY_TYPE_NONE == phy_hdr.type)
- {
- test_begin(t, "phy type none")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_phy_recv(&msg, ctx)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("phy type none\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
- // reset errno
- errno = 0;
- } test_end;
- }
- // preamble
- if (PHY_TYPE_PREAMBLE == phy_hdr.type)
- {
- // set medium state
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_IDLE;
- // activate preamble detection
- ctx->control.pre_detection = true;
- // set RX FC mode
- ctx->control.rx_param.fc_mode = PHY_FC_MODE_AV_2;
- }
- // AV Frame Control (16 octets)
- if (PHY_TYPE_FC_AV_ONLY_MODE == phy_hdr.type)
- {
- // set medium state
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_RX_FC;
- }
- if ((PHY_TYPE_FC_HYBRID_MODE == phy_hdr.type)
- || (PHY_TYPE_FC_AV_ONLY_MODE == phy_hdr.type))
- {
- ctx->control.rx_param.short_ppdu = false;
- test_fail_unless (0 <= sci_msg_push (&msg, 16)
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy(msg.data_begin, fc_av, 16);
- }
- // HP1.0.1 Frame Control (4 octets)
- if (PHY_TYPE_FC_HYBRID_MODE == phy_hdr.type)
- {
- test_fail_unless (0 <= sci_msg_push (&msg, 4)
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy(msg.data_begin, &fc_10, 4);
- }
- // PRS (1 octet, but must be aligned on 4 octets)
- if (PHY_TYPE_PRS == phy_hdr.type)
- {
- // reset TX ID
- phy_hdr.tx_id = 0;
- // set medium state
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_PRS0;
- test_fail_unless (0 <= sci_msg_push (&msg, 4)
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy(msg.data_begin, &prs, 4);
- }
- // PBs
- if (PHY_TYPE_MPDU_PAYLOAD == phy_hdr.type)
- {
- // set medium state
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_RX_MPDU;
- // indicate that RX has been prepared
- ctx->control.rx_prepared = true;
- // set mpdu format
- phy_hdr.mpdu_format = PHY_MPDU_FORMAT_BEACON;
-
- // set pb dma
- ctx->pbdma.first_pb = phy_pb;
- ctx->pbdma.current_pb = &ctx->pbdma.first_pb->pb_rx;
- ctx->pbdma.nb_total = PHY_PB_NB;
- ctx->pbdma.nb_ready = PHY_PB_NB;
- ctx->pbdma.nb_pb_it = PHY_PB_NB;
- ctx->pbdma.index_current_pb = 0;
- memset(ctx->pbdma.crc_bitmap, '\0', 8 * sizeof(u32));
- u32 expected_crc_bitmap[8];
- memset(expected_crc_bitmap, '\0', 8 * sizeof(u32));
-
- unsigned short int msg_nb = 1;
- uint8_t last_msg_pb_nb = PHY_PB_MAX_NB;
- unsigned short int msg_counter = 0;
-
- if (PHY_PB_NB > PHY_PB_MAX_NB)
- {
- msg_nb = (unsigned short int)(PHY_PB_NB/PHY_PB_MAX_NB);
- if (0 != (PHY_PB_NB % PHY_PB_MAX_NB))
- {
- last_msg_pb_nb = (uint8_t)(PHY_PB_NB % PHY_PB_MAX_NB);
- msg_nb++;
- }
- }
- else
- {
- phy_hdr.pb_nb = PHY_PB_NB;
- }
-
- for (msg_counter = 0; msg_counter < msg_nb; msg_counter++)
- {
- if ((1 != msg_nb) && (msg_nb-1 == msg_counter))
- {
- phy_hdr.pb_nb = last_msg_pb_nb;
- }
-
- for (pb_counter = 0; pb_counter < phy_hdr.pb_nb; pb_counter++)
- {
- test_fail_unless (0 <= sci_msg_push (&msg, MAC_PB520_BYTES)
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy(msg.data_begin, &pb_data[pb_counter][0], MAC_PB520_BYTES);
- phy_pb[pb_counter].pb_rx.blk.data = &pb_data[pb_counter][0];
- phy_pb[pb_counter].pb_rx.blk.next = &phy_pb[pb_counter+1].pb_rx.blk;
- if (phy_hdr.pb_nb-1 == pb_counter)
- {
- phy_pb[pb_counter].pb_rx.blk.next = &phy_pb[0].pb_rx.blk;
- }
- }
-
- // phy header
- test_fail_unless (0 <= sci_msg_push (&msg, sizeof (phy_msg_hdr_t))
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy(msg.data_begin, &phy_hdr, sizeof(phy_msg_hdr_t));
-
- // fill the sci header
- memcpy((unsigned char *)&sci_hdr.magic_id, SCI_MSG_MAGIC, 4);
- sci_hdr.version = SCI_MSG_VERSION;
- sci_hdr.type = SCI_MSG_TYPE_PHY;
- sci_hdr.flags = 0;
- sci_hdr.station_id = my_station.id;
- sci_hdr.length = msg.length - sizeof(sci_msg_hdr_t);
- sci_hdr.msg_id = my_station.sci->current_msg_id | SCI_MSG_ID_STATION;
- sci_hdr.netclock_high = my_station.current_tick_tck >> 32;
- sci_hdr.netclock_low = my_station.current_tick_tck & 0xffffffff;
- msg.sci_hdr = &sci_hdr;
-
- test_fail_unless ((0 <= (maximus_phy_recv(&msg, ctx)))
- && (EINVAL != errno)
- && (EPROTO != errno));
-
- test_fail_unless ((phy_hdr.version == msg.hdr.phy->version)
- && (phy_hdr.type == msg.hdr.phy->type)
- && (phy_hdr.mpdu_format == msg.hdr.phy->mpdu_format)
- && (phy_hdr.pb_nb == msg.hdr.phy->pb_nb)
- && (phy_hdr.fc_mode == msg.hdr.phy->fc_mode)
- && (phy_hdr.short_ppdu == msg.hdr.phy->short_ppdu)
- && (phy_hdr.mod == msg.hdr.phy->mod)
- && (phy_hdr.fecrate == msg.hdr.phy->fecrate)
- && (phy_hdr.gil == msg.hdr.phy->gil)
- && (phy_hdr.tonemap_index == msg.hdr.phy->tonemap_index)
- && (phy_hdr.tx_id == msg.hdr.phy->tx_id)
- && (phy_hdr.flags == msg.hdr.phy->flags)
- && (phy_hdr.reserved == msg.hdr.phy->reserved)
- && (phy_hdr.symbol_nb == msg.hdr.phy->symbol_nb)
- && (0 == memcmp(phy_hdr.iv, msg.hdr.phy->iv, 3*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.nek, msg.hdr.phy->nek, 4*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_measurement, msg.hdr.phy->pb_measurement, msg.hdr.phy->pb_nb*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_header, msg.hdr.phy->pb_header, msg.hdr.phy->pb_nb*sizeof(uint32_t))));
-
- // test PBs
- phy_pb_rx_t *current_pb = &ctx->pbdma.first_pb->pb_rx;
-
- for (pb_counter = 0; pb_counter < phy_hdr.pb_nb; pb_counter++)
- {
- test_fail_unless (pb_header[pb_counter] == current_pb->header);
- test_fail_unless (0 == memcmp(&pb_measurement[pb_counter], &current_pb->pb_measurement, sizeof(pb_measurement_t)));
- test_fail_unless (0 == memcmp(&pb_data[pb_counter][0], current_pb->blk.data, MAC_PB520_BYTES*sizeof(u8)));
- current_pb = PARENT_OF(phy_pb_rx_t, blk, current_pb->blk.next);
- }
-
- // test crc bitmap registers
- for (pb_counter = 0; pb_counter < phy_hdr.pb_nb; pb_counter++)
- {
- u32 tmp = *(u32 *)&pb_measurement[pb_counter];
- tmp = ntohl(tmp);
- expected_crc_bitmap[(msg_counter * PHY_PB_MAX_NB + pb_counter) / 32] |= ((tmp & 0x200000) >> 21) << ((msg_counter * PHY_PB_MAX_NB + pb_counter) % 32); /* crc_error */
- }
- }
- test_fail_unless (0 == memcmp(expected_crc_bitmap, ctx->pbdma.crc_bitmap, 8 * sizeof(u32)));
- }
- // tonemask
- if (PHY_TYPE_TONEMASK == phy_hdr.type)
- {
- test_begin(t, "phy type tonemask")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_phy_recv(&msg, ctx)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("phy type tonemask\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
- // reset errno
- errno = 0;
- } test_end;
- }
- // tonemap
- if (PHY_TYPE_TONEMAP == phy_hdr.type)
- {
- test_begin(t, "phy type tonemap")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_phy_recv(&msg, ctx)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("phy type tonemap\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
- // reset errno
- errno = 0;
- } test_end;
- }
- // noise
- if (PHY_TYPE_NOISE == phy_hdr.type)
- {
- // reset SCI message
- memset(buffer, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((0 == sci_msg_init(&msg, buffer, SCI_MSG_MAX_SIZE))
- && (EINVAL != errno));
- msg.length = 0;
-
- // set chandata transfer
- ctx->pbdma.chandata_transfer = true;
-
- // frequency noise
- ctx->pbdma.first_chandata = freq_noise_chandata;
- current_chandata = ctx->pbdma.first_chandata;
- for (i=0; i<freq_noise_count; i++)
- {
- current_chandata->conf.type = 1; // frequency noise
- current_chandata->conf.size = max_transfer_size;
- current_chandata->blk.data = &freq_noise_data[i*MAC_PB520_BYTES];
- current_chandata->conf.last = 0;
- if (freq_noise_count != i+1)
- {
- current_chandata->blk.next = &(freq_noise_chandata[i+1].blk);
- }
- else
- {
- // for last chandata
- current_chandata->blk.next = &(time_noise_chandata[0].blk);
- }
- current_chandata = PARENT_OF(phy_chandata_t, blk, current_chandata->blk.next);
- }
-
- // time noise
- for (i=0; i<time_noise_count; i++)
- {
- current_chandata->conf.type = 2; // time noise
- current_chandata->conf.size = max_transfer_size;
- current_chandata->blk.data = &time_noise_data[i*MAC_PB520_BYTES];
- if (time_noise_count != i+1)
- {
- current_chandata->conf.last = 0;
- current_chandata->blk.next = &(time_noise_chandata[i+1].blk);
- current_chandata = PARENT_OF(phy_chandata_t, blk, current_chandata->blk.next);
- }
- else
- {
- // for last chandata
- current_chandata->conf.last = 1;
- current_chandata->blk.next = NULL;
- }
- }
-
- // fill sci data
- test_fail_unless (
- 0 <= sci_msg_push (
- &msg,
- MAC_MAX_SYMB_PER_MPDU * sizeof (phy_noise_energy_t))
- && EINVAL != errno
- && ENOSPC != errno);
- memcpy(msg.data_begin, time_noise, MAC_MAX_SYMB_PER_MPDU*sizeof(phy_noise_energy_t));
- test_fail_unless (
- 0 <= sci_msg_push (
- &msg,
- PHY_CARRIER_NB * sizeof (phy_noise_energy_t))
- && EINVAL != errno
- && ENOSPC != errno);
- memcpy(msg.data_begin, freq_noise, PHY_CARRIER_NB*sizeof(phy_noise_energy_t));
- }
- // RX
- if (PHY_TYPE_RX == phy_hdr.type)
- {
- test_begin(t, "phy type rx")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_phy_recv(&msg, ctx)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("phy type rx\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
- // reset errno
- errno = 0;
- } test_end;
- }
- if ((PHY_TYPE_PREAMBLE == phy_hdr.type)
- || (PHY_TYPE_FC_HYBRID_MODE == phy_hdr.type)
- || (PHY_TYPE_FC_AV_ONLY_MODE == phy_hdr.type)
- || (PHY_TYPE_PRS == phy_hdr.type)
- || (PHY_TYPE_NOISE == phy_hdr.type)
- || (PHY_TYPE_ZERO_CROSS == phy_hdr.type))
- {
- // phy header
- test_fail_unless (
- 0 <= sci_msg_push (&msg, sizeof (phy_msg_hdr_t))
- && EINVAL != errno
- && ENOSPC != errno);
- memcpy(msg.data_begin, &phy_hdr, sizeof(phy_msg_hdr_t));
-
- // fill the sci header
- memcpy((unsigned char *)&sci_hdr.magic_id, SCI_MSG_MAGIC, 4);
- sci_hdr.version = SCI_MSG_VERSION;
- sci_hdr.type = SCI_MSG_TYPE_PHY;
- sci_hdr.flags = 0;
- sci_hdr.station_id = my_station.id;
- sci_hdr.length = msg.length - sizeof(sci_msg_hdr_t);
- sci_hdr.msg_id = my_station.sci->current_msg_id | SCI_MSG_ID_STATION;
- sci_hdr.netclock_high = my_station.current_tick_tck >> 32;
- sci_hdr.netclock_low = my_station.current_tick_tck & 0xffffffff;
- msg.sci_hdr = &sci_hdr;
-
- test_fail_unless ((0 <= (maximus_phy_recv(&msg, ctx)))
- && (EINVAL != errno)
- && (EPROTO != errno));
-
- test_fail_unless ((phy_hdr.version == msg.hdr.phy->version)
- && (phy_hdr.type == msg.hdr.phy->type)
- && (phy_hdr.mpdu_format == msg.hdr.phy->mpdu_format)
- && (phy_hdr.pb_nb == msg.hdr.phy->pb_nb)
- && (phy_hdr.fc_mode == msg.hdr.phy->fc_mode)
- && (phy_hdr.short_ppdu == msg.hdr.phy->short_ppdu)
- && (phy_hdr.mod == msg.hdr.phy->mod)
- && (phy_hdr.fecrate == msg.hdr.phy->fecrate)
- && (phy_hdr.gil == msg.hdr.phy->gil)
- && (phy_hdr.tonemap_index == msg.hdr.phy->tonemap_index)
- && (phy_hdr.tx_id == msg.hdr.phy->tx_id)
- && (phy_hdr.flags == msg.hdr.phy->flags)
- && (phy_hdr.reserved == msg.hdr.phy->reserved)
- && (phy_hdr.symbol_nb == msg.hdr.phy->symbol_nb)
- && (0 == memcmp(phy_hdr.iv, msg.hdr.phy->iv, 3*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.nek, msg.hdr.phy->nek, 4*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_measurement, msg.hdr.phy->pb_measurement, msg.hdr.phy->pb_nb*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_header, msg.hdr.phy->pb_header, msg.hdr.phy->pb_nb*sizeof(uint32_t))));
- }
- /* Check results. */
- // test preamble
- if (PHY_TYPE_PREAMBLE == phy_hdr.type)
- {
- test_fail_unless ((MAXIMUS_PHY_MEDIUM_WAIT_CONF == ctx->access.medium_state)
- && ctx->control.pre_detection);
-
- /* Check that the correct netclock message has been sent to Maximus. */
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless ((u32) (my_station.current_tick_tck \
- - MAXIMUS_PHY_PREAMBLE_DETECTION_DELAY_TCK \
- + PHY_PREAMBLE_CONFIRMATION_DELAY_TCK) \
- == ntohl (netclock_hdr->tick_low));
-
- // check netclock id for 'maximus_phy_recv_preamble_cb'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->control.rx_param.recv_preamble_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr->id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
-
- // reset netclock id
- ctx->control.rx_param.recv_preamble_netclock_id = 0;
-
- /* Test RX collision. */
-
- // reset rx collision
- ctx->control.rx_collision = false;
-
- // phy header
- test_fail_unless (
- 0 <= sci_msg_push (&msg, sizeof (phy_msg_hdr_t))
- && EINVAL != errno
- && ENOSPC != errno);
- memcpy(msg.data_begin, &phy_hdr, sizeof(phy_msg_hdr_t));
-
- test_fail_unless ((0 <= (maximus_phy_recv(&msg, ctx)))
- && (EINVAL != errno)
- && (EPROTO != errno));
-
- test_fail_unless ((phy_hdr.version == msg.hdr.phy->version)
- && (phy_hdr.type == msg.hdr.phy->type)
- && (phy_hdr.mpdu_format == msg.hdr.phy->mpdu_format)
- && (phy_hdr.pb_nb == msg.hdr.phy->pb_nb)
- && (phy_hdr.fc_mode == msg.hdr.phy->fc_mode)
- && (phy_hdr.short_ppdu == msg.hdr.phy->short_ppdu)
- && (phy_hdr.mod == msg.hdr.phy->mod)
- && (phy_hdr.fecrate == msg.hdr.phy->fecrate)
- && (phy_hdr.gil == msg.hdr.phy->gil)
- && (phy_hdr.tonemap_index == msg.hdr.phy->tonemap_index)
- && (phy_hdr.tx_id == msg.hdr.phy->tx_id)
- && (phy_hdr.flags == msg.hdr.phy->flags)
- && (phy_hdr.reserved == msg.hdr.phy->reserved)
- && (phy_hdr.symbol_nb == msg.hdr.phy->symbol_nb)
- && (0 == memcmp(phy_hdr.iv, msg.hdr.phy->iv, 3*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.nek, msg.hdr.phy->nek, 4*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_measurement, msg.hdr.phy->pb_measurement, msg.hdr.phy->pb_nb*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_header, msg.hdr.phy->pb_header, msg.hdr.phy->pb_nb*sizeof(uint32_t))));
-
- test_fail_unless (ctx->control.rx_collision);
-
- // reset rx collision
- ctx->control.rx_collision = false;
-
- /* Test callback:
- * - with a wrong preamble;
- * - then, with a correct preamble. */
- maximus_phy_recv_preamble_t preamble_data;
- preamble_data.ctx = ctx;
- preamble_data.wrong_preamble = true;
- preamble_data.src_tx_id = ntohs(phy_hdr.tx_id);
- preamble_data.src_station_id = ntohs(sci_hdr.station_id);
- ctx->control.tx_blocked_on_false_alarm = true; // set TX blocked
- maximus_phy_recv_preamble_cb((void *)&preamble_data);
- test_fail_unless ((EINVAL != errno)
- && (MAXIMUS_PHY_MEDIUM_IDLE == ctx->access.medium_state)
- && ctx->control.pre_detection
- && (maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PHY))
- && (ctx->control.current_cb == ctx->control.tx_false_alarm_cb));
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
-
- preamble_data.wrong_preamble = false;
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_WAIT_CONF;
- maximus_phy_recv_preamble_cb((void *)&preamble_data);
- test_fail_unless ((EINVAL != errno)
- && (MAXIMUS_PHY_MEDIUM_BUSY_RX_FC == ctx->access.medium_state)
- && !ctx->control.pre_detection
- && (ctx->control.rx_param.src_tx_id == preamble_data.src_tx_id)
- && (ctx->control.rx_param.src_station_id == preamble_data.src_station_id));
- }
- // test fc_av
- if ((PHY_TYPE_FC_HYBRID_MODE == phy_hdr.type)
- || (PHY_TYPE_FC_AV_ONLY_MODE == phy_hdr.type))
- {
- test_fail_unless ((maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PHY))
- && (ctx->control.current_cb == ctx->control.rx_fc_cb)
- && (0 == memcmp(fc_av, ctx->control.rx_fc_param.fc_av, 4*sizeof(u32))));
- (*ctx->control.rx_fc_cb)(ctx->control.user_data, ctx->control.rx_fc_param.rx_date, ctx->control.rx_fc_param.fc_av);
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
- }
- // test fc_10
- if (PHY_TYPE_FC_HYBRID_MODE == phy_hdr.type)
- {
- test_fail_unless (fc_10 == ctx->control.rx_param.fc_10);
- }
- // test RX collision
- if (PHY_TYPE_FC_AV_ONLY_MODE == phy_hdr.type)
- {
- // set rx collision
- ctx->control.rx_collision = true;
-
- // phy header
- test_fail_unless (
- 0 <= sci_msg_push (&msg, sizeof (phy_msg_hdr_t))
- && EINVAL != errno
- && ENOSPC != errno);
- memcpy(msg.data_begin, &phy_hdr, sizeof(phy_msg_hdr_t));
-
- // set medium state
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_RX_FC;
-
- test_fail_unless ((0 <= (maximus_phy_recv(&msg, ctx)))
- && (EINVAL != errno)
- && (EPROTO != errno));
-
- test_fail_unless ((phy_hdr.version == msg.hdr.phy->version)
- && (phy_hdr.type == msg.hdr.phy->type)
- && (phy_hdr.mpdu_format == msg.hdr.phy->mpdu_format)
- && (phy_hdr.pb_nb == msg.hdr.phy->pb_nb)
- && (phy_hdr.fc_mode == msg.hdr.phy->fc_mode)
- && (phy_hdr.short_ppdu == msg.hdr.phy->short_ppdu)
- && (phy_hdr.mod == msg.hdr.phy->mod)
- && (phy_hdr.fecrate == msg.hdr.phy->fecrate)
- && (phy_hdr.gil == msg.hdr.phy->gil)
- && (phy_hdr.tonemap_index == msg.hdr.phy->tonemap_index)
- && (phy_hdr.tx_id == msg.hdr.phy->tx_id)
- && (phy_hdr.flags == msg.hdr.phy->flags)
- && (phy_hdr.reserved == msg.hdr.phy->reserved)
- && (phy_hdr.symbol_nb == msg.hdr.phy->symbol_nb)
- && (0 == memcmp(phy_hdr.iv, msg.hdr.phy->iv, 3*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.nek, msg.hdr.phy->nek, 4*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_measurement, msg.hdr.phy->pb_measurement, msg.hdr.phy->pb_nb*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_header, msg.hdr.phy->pb_header, msg.hdr.phy->pb_nb*sizeof(uint32_t))));
-
- test_fail_unless ((maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PHY))
- && (ctx->control.current_cb == ctx->control.rx_fc_cb)
- && (NULL == ctx->control.rx_fc_param.fc_av)
- && ((u32)-1 == ctx->control.rx_param.fc_10));
- (*ctx->control.rx_fc_cb)(ctx->control.user_data, ctx->control.rx_fc_param.rx_date, ctx->control.rx_fc_param.fc_av);
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
-
- // sci header => FC coming from another station
- sci_hdr.station_id = my_station.id + 1;
-
- // phy header
- test_fail_unless (
- 0 <= sci_msg_push (&msg, sizeof (phy_msg_hdr_t))
- && EINVAL != errno
- && ENOSPC != errno);
- memcpy(msg.data_begin, &phy_hdr, sizeof(phy_msg_hdr_t));
-
- // set medium state
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_RX_FC;
-
- test_fail_unless ((0 <= (maximus_phy_recv(&msg, ctx)))
- && (EINVAL != errno)
- && (EPROTO != errno));
-
- test_fail_unless ((phy_hdr.version == msg.hdr.phy->version)
- && (phy_hdr.type == msg.hdr.phy->type)
- && (phy_hdr.mpdu_format == msg.hdr.phy->mpdu_format)
- && (phy_hdr.pb_nb == msg.hdr.phy->pb_nb)
- && (phy_hdr.fc_mode == msg.hdr.phy->fc_mode)
- && (phy_hdr.short_ppdu == msg.hdr.phy->short_ppdu)
- && (phy_hdr.mod == msg.hdr.phy->mod)
- && (phy_hdr.fecrate == msg.hdr.phy->fecrate)
- && (phy_hdr.gil == msg.hdr.phy->gil)
- && (phy_hdr.tonemap_index == msg.hdr.phy->tonemap_index)
- && (phy_hdr.tx_id == msg.hdr.phy->tx_id)
- && (phy_hdr.flags == msg.hdr.phy->flags)
- && (phy_hdr.reserved == msg.hdr.phy->reserved)
- && (phy_hdr.symbol_nb == msg.hdr.phy->symbol_nb)
- && (0 == memcmp(phy_hdr.iv, msg.hdr.phy->iv, 3*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.nek, msg.hdr.phy->nek, 4*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_measurement, msg.hdr.phy->pb_measurement, msg.hdr.phy->pb_nb*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_header, msg.hdr.phy->pb_header, msg.hdr.phy->pb_nb*sizeof(uint32_t))));
-
- test_fail_unless (0 == maximus_pending_isrs);
-
- // reset rx collision
- ctx->control.rx_collision = false;
- }
- // test PBs
- if (PHY_TYPE_MPDU_PAYLOAD == phy_hdr.type)
- {
- test_fail_unless ((maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PBDMA))
- && (0 == ctx->pbdma.status_word.bf.pb_null)
- && (0 == ctx->pbdma.status_word.bf.null_pb_index)
- && (1 == ctx->pbdma.status_word.bf.pb_it)
- && (1 == ctx->pbdma.status_word.bf.end_rx_pb)
- && !ctx->control.rx_prepared);
- // pb_it
- ctx->pbdma.status_word.bf.end_rx_pb = 0;
- (*ctx->control.pbdma_cb) (ctx->control.user_data,
- ctx->pbdma.status_word.value);
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PBDMA);
- }
- // test PRS
- if (PHY_TYPE_PRS == phy_hdr.type)
- {
- test_fail_unless (2 == ctx->access.cap_medium);
- // set TX ID
- phy_hdr.tx_id = 10;
- }
- // test noise
- if (PHY_TYPE_NOISE == phy_hdr.type)
- {
- // test frequency noise
- current_chandata = ctx->pbdma.first_chandata;
- for (i=0; i<freq_noise_count; i++)
- {
- if (freq_noise_count != i+1)
- {
- test_fail_unless (0 == memcmp(&freq_noise[i*max_transfer_size], current_chandata->blk.data, MAC_PB520_BYTES));
- }
- else
- {
- // for last chandata
- test_fail_unless (0 == memcmp(&freq_noise[i*max_transfer_size], current_chandata->blk.data, PHY_CARRIER_NB*sizeof(phy_noise_energy_t) - i*MAC_PB520_BYTES));
- }
- current_chandata = PARENT_OF(phy_chandata_t, blk, current_chandata->blk.next);
- }
-
- // test time noise
- for (i=0; i<time_noise_count; i++)
- {
- if (time_noise_count != i+1)
- {
- test_fail_unless (0 == memcmp(&time_noise[i*max_transfer_size], current_chandata->blk.data, MAC_PB520_BYTES));
- current_chandata = PARENT_OF(phy_chandata_t, blk, current_chandata->blk.next);
- }
- else
- {
- // for last chandata
- test_fail_unless (0 == memcmp(&time_noise[i*max_transfer_size], current_chandata->blk.data, MAC_MAX_SYMB_PER_MPDU*sizeof(phy_noise_energy_t) - i*MAC_PB520_BYTES));
- }
- }
-
- // end_chandata
- test_fail_unless((maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PBDMA))
- && (0 == ctx->pbdma.status_word.bf.pb_null)
- && (0 == ctx->pbdma.status_word.bf.null_pb_index)
- && (0 == ctx->pbdma.status_word.bf.pb_it)
- && (0 == ctx->pbdma.status_word.bf.end_rx_pb)
- && (1 == ctx->pbdma.status_word.bf.end_chandata));
- (*ctx->control.pbdma_cb) (ctx->control.user_data,
- ctx->pbdma.status_word.value);
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PBDMA);
- }
- // test zero-cross
- if (PHY_TYPE_ZERO_CROSS == phy_hdr.type)
- {
- test_fail_unless ((u32)my_station.current_tick_tck == ctx->control.zero_cross_date);
- }
- }
- } test_end;
-}
-
-void maximus_phy_recv_mpdu_payload_sound_test_case(test_t t)
-{
- sci_msg_t msg;
- unsigned char buffer[SCI_MSG_MAX_SIZE];
-
- printf("recv sound\n");
- test_case_begin(t, "recv sound");
-
- test_begin(t, "sci init")
- {
- memset(buffer, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((0 == sci_msg_init(&msg, buffer, SCI_MSG_MAX_SIZE))
- && (EINVAL != errno));
- msg.length = 0;
- } test_end;
-
- test_begin(t, "recv sound")
- {
- // phy header
- phy_msg_hdr_t phy_hdr;
- u32 iv[3];
- u32 nek[4];
- pb_measurement_t pb_measurement[MAXIMUS_PHY_SOUND_MAX_PB_NB];
- u32 pb_header[MAXIMUS_PHY_SOUND_MAX_PB_NB];
-
- // sci header
- sci_msg_hdr_t sci_hdr;
-
- // sci data
- u8 pb_data[MAXIMUS_PHY_SOUND_MAX_PB_NB][MAC_PB520_BYTES];
-
- u8 null_pb[MAC_PB520_BYTES];
- unsigned short int pb_counter = 0;
-
- // initialize sci data
- memset(iv, 0, 3*sizeof(u32));
- memset(nek, 0, 4*sizeof(u32));
- memset(pb_measurement, 0, MAXIMUS_PHY_SOUND_MAX_PB_NB*sizeof(pb_measurement_t));
- memset(pb_header, 0, MAXIMUS_PHY_SOUND_MAX_PB_NB*sizeof(u32));
- memset(pb_data, 0x00, MAXIMUS_PHY_SOUND_MAX_PB_NB*MAC_PB520_BYTES*sizeof(u8));
-
- // fill the phy header
- phy_hdr.version = PHY_VERSION;
- phy_hdr.type = PHY_TYPE_MPDU_PAYLOAD;
- phy_hdr.mpdu_format = PHY_MPDU_FORMAT_SOUND;
- phy_hdr.pb_nb = MAXIMUS_PHY_SOUND_MAX_PB_NB;
- phy_hdr.msg_nb = 1;
- phy_hdr.fc_mode = PHY_FC_MODE_AV_2;
- phy_hdr.short_ppdu = 0;
- phy_hdr.mod = PHY_MOD_ROBO;
- phy_hdr.fecrate = PHY_FEC_RATE_1_2;
- phy_hdr.gil = PHY_GIL_417;
- phy_hdr.tonemap_index = 0;
- phy_hdr.reserved = 0;
- phy_hdr.tx_id = 10;
- phy_hdr.flags = htons(0x0006);
- phy_hdr.symbol_nb = 0;
- memcpy(phy_hdr.iv, iv, 3*sizeof(uint32_t));
- memcpy(phy_hdr.nek, nek, 4*sizeof(uint32_t));
- memcpy(phy_hdr.pb_measurement, pb_measurement, MAXIMUS_PHY_SOUND_MAX_PB_NB*sizeof(uint32_t));
- memcpy(phy_hdr.pb_header, pb_header, MAXIMUS_PHY_SOUND_MAX_PB_NB*sizeof(uint32_t));
-
- // set RX parameters
- ctx->control.rx_param.fc_mode = phy_hdr.fc_mode;
- ctx->control.rx_param.short_ppdu = false;
- // set medium state
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_RX_MPDU;
- // indicate that RX has been prepared
- ctx->control.rx_prepared = true;
-
- /* Fill the sci data. */
- for (pb_counter = 0; pb_counter < phy_hdr.pb_nb; pb_counter++)
- {
- test_fail_unless (0 <= sci_msg_push (&msg, MAC_PB520_BYTES)
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy(msg.data_begin, &pb_data[pb_counter][0], MAC_PB520_BYTES);
- }
-
- // phy header
- test_fail_unless (0 <= sci_msg_push (&msg, sizeof (phy_msg_hdr_t))
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy(msg.data_begin, &phy_hdr, sizeof(phy_msg_hdr_t));
-
- // fill the sci header
- memcpy((unsigned char *)&sci_hdr.magic_id, SCI_MSG_MAGIC, 4);
- sci_hdr.version = SCI_MSG_VERSION;
- sci_hdr.type = SCI_MSG_TYPE_PHY;
- sci_hdr.flags = 0;
- sci_hdr.station_id = my_station.id;
- sci_hdr.length = msg.length - sizeof(sci_msg_hdr_t);
- sci_hdr.msg_id = my_station.sci->current_msg_id | SCI_MSG_ID_STATION;
- sci_hdr.netclock_high = my_station.current_tick_tck >> 32;
- sci_hdr.netclock_low = my_station.current_tick_tck & 0xffffffff;
- msg.sci_hdr = &sci_hdr;
-
- test_fail_unless ((0 <= (maximus_phy_recv(&msg, ctx)))
- && (EINVAL != errno)
- && (EPROTO != errno));
-
- test_fail_unless ((phy_hdr.version == msg.hdr.phy->version)
- && (phy_hdr.type == msg.hdr.phy->type)
- && (phy_hdr.mpdu_format == msg.hdr.phy->mpdu_format)
- && (phy_hdr.pb_nb == msg.hdr.phy->pb_nb)
- && (phy_hdr.fc_mode == msg.hdr.phy->fc_mode)
- && (phy_hdr.short_ppdu == msg.hdr.phy->short_ppdu)
- && (phy_hdr.mod == msg.hdr.phy->mod)
- && (phy_hdr.fecrate == msg.hdr.phy->fecrate)
- && (phy_hdr.gil == msg.hdr.phy->gil)
- && (phy_hdr.tonemap_index == msg.hdr.phy->tonemap_index)
- && (phy_hdr.tx_id == msg.hdr.phy->tx_id)
- && (phy_hdr.flags == msg.hdr.phy->flags)
- && (phy_hdr.reserved == msg.hdr.phy->reserved)
- && (phy_hdr.symbol_nb == msg.hdr.phy->symbol_nb)
- && (0 == memcmp(phy_hdr.iv, msg.hdr.phy->iv, 3*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.nek, msg.hdr.phy->nek, 4*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_measurement, msg.hdr.phy->pb_measurement, msg.hdr.phy->pb_nb*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_header, msg.hdr.phy->pb_header, msg.hdr.phy->pb_nb*sizeof(uint32_t))));
-
- // test PBs
- memset(null_pb, 0, MAC_PB520_BYTES);
- for (pb_counter = 0; pb_counter < phy_hdr.pb_nb; pb_counter++)
- {
- test_fail_unless (0 == pb_header[pb_counter]);
- test_fail_unless (0 == memcmp(&pb_measurement[pb_counter], null_pb, sizeof(pb_measurement_t)));
- test_fail_unless (0 == memcmp(&pb_data[pb_counter][0], null_pb, MAC_PB520_BYTES*sizeof(u8)));
- }
-
- test_fail_unless (!ctx->control.rx_prepared);
- } test_end;
-}
-
-void phy_init_test_case(test_t t)
-{
- printf("init\n");
- test_case_begin(t, "init");
-
- test_begin(t, "init")
- {
- ctx = phy_init ((void*)&user_data,
- &phy_rx_fc_cb,
- &phy_access_cb,
- &phy_access_conf_cb,
- &phy_pbdma_cb,
- &phy_tx_false_alarm_cb,
- &phy_deferred_cb);
- test_fail_unless ((EINVAL != errno)
- && (NULL != ctx)
- && (1234567890 == *((int*)ctx->control.user_data))
- && (&phy_rx_fc_cb == ctx->control.rx_fc_cb)
- && (&phy_access_cb == ctx->control.access_cb)
- && (&phy_access_conf_cb == ctx->control.access_conf_cb)
- && (&phy_pbdma_cb == ctx->control.pbdma_cb)
- && (&phy_tx_false_alarm_cb == ctx->control.tx_false_alarm_cb)
- && (&phy_deferred_cb == ctx->control.deferred_cb)
- && !ctx->pbdma.chandata_transfer
- && ctx->access.prp_result);
- ctx->warning_assert = true;
- } test_end;
-
- test_begin(t, "rx fc cb")
- {
- test_fail_unless ((NULL != ctx->control.rx_fc_cb)
- && ((*ctx->control.rx_fc_cb)(ctx->control.user_data, (u32)my_station.current_tick_tck, ctx->control.rx_param.fc_av)));
- } test_end;
-
- test_begin(t, "deferred cb")
- {
- test_fail_unless (NULL != ctx->control.deferred_cb);
- (*ctx->control.deferred_cb)(ctx->control.user_data);
- } test_end;
-
- maximus_pending_isrs = 0;
-
- return;
-}
-
-void phy_zero_cross_init_test_case(test_t t)
-{
- printf("zero cross init\n");
- test_case_begin(t, "zero cross init");
-
- test_begin(t, "zero cross init")
- {
- phy_zero_cross_init (ctx, &phy_zero_cross_cb);
- test_fail_unless ((NULL != ctx->control.zero_cross_cb)
- && ((*ctx->control.zero_cross_cb)(ctx->control.user_data, ctx->control.zero_cross_date)));
- } test_end;
-
- return;
-}
-void phy_reset_test_case(test_t t)
-{
- printf("reset\n");
- test_case_begin(t, "reset");
-
- test_begin(t, "reset")
- {
- // save tmdma data
- uint carrier_nb = ctx->tmdma.carrier_nb;
- u8 tonemask[(PHY_CARRIER_NB+7)/8]; // uses 192 bytes (1 bit per carrier)
- u8 tonemap1_data[TONEMAP_INDEX_NB][MAC_PB520_BYTES];
- u8 tonemap2_data[TONEMAP_INDEX_NB][(PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES]; // 4 bits per carrier
- unsigned short int tonemap_index;
- memcpy(tonemask, ctx->tmdma.tonemask, (PHY_CARRIER_NB+7)/8);
- memset(tonemap1_data, '\0', TONEMAP_INDEX_NB*MAC_PB520_BYTES);
- memset(tonemap2_data, '\0', TONEMAP_INDEX_NB*((PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES));
- for (tonemap_index=0; tonemap_index<TONEMAP_INDEX_NB; tonemap_index++)
- {
- memcpy(&tonemap1_data[tonemap_index][0], ctx->tmdma.tonemap[tonemap_index]->data, MAC_PB520_BYTES);
- memcpy(&tonemap2_data[tonemap_index][0], ctx->tmdma.tonemap[tonemap_index]->next->data, (PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES);
- }
-
- phy_reset (ctx);
- test_fail_unless ((EINVAL != errno)
- && (NULL != ctx)
- && (NULL != (int*)ctx->control.user_data)
- && (NULL != (unsigned long*)ctx->control.extra_timer_user_data)
- && (NULL != ctx->control.rx_fc_cb)
- && (NULL != ctx->control.access_cb)
- && (NULL != ctx->control.access_conf_cb)
- && (NULL != ctx->control.pbdma_cb)
- && (NULL != ctx->control.tx_false_alarm_cb)
- && (NULL != ctx->control.zero_cross_cb)
- && (NULL != ctx->control.deferred_cb)
- && (NULL != ctx->control.extra_timer_cb)
- && (NULL != ctx->access.backoff_start_netclock_cb)
- && (NULL != ctx->access.backoff_slot_count_netclock_cb)
- && (NULL != ctx->access.timer_program_netclock_cb)
- && (NULL != ctx->control.next_tx_param.tx_frame_netclock_cb)
- && (NULL != ctx->control.current_tx_param.tx_frame_netclock_cb)
- && (NULL != ctx->control.rx_param.rx_activate_netclock_cb)
- && (NULL != ctx->control.extra_timer_program_netclock_cb)
- && (carrier_nb == ctx->tmdma.carrier_nb)
- && (0 == memcmp(tonemask, ctx->tmdma.tonemask, (PHY_CARRIER_NB+7)/8))
- && ctx->access.prp_result);
-
- // check tonemap data
- for (tonemap_index=0; tonemap_index<TONEMAP_INDEX_NB; tonemap_index++)
- {
- test_fail_unless ((0 == memcmp(&tonemap1_data[tonemap_index][0], ctx->tmdma.tonemap[tonemap_index]->data, MAC_PB520_BYTES))
- && (0 == memcmp(&tonemap2_data[tonemap_index][0], ctx->tmdma.tonemap[tonemap_index]->next->data, (PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES)));
- }
- } test_end;
-
- return;
-}
-
-void phy_uninit_test_case(test_t t)
-{
- netclock_id_t id;
- u32 date = (u32)my_station.current_tick_tck;
-
- printf("uninit\n");
- test_case_begin(t, "uninit");
-
- phy_extra_timer_program (ctx, date);
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "extra timer program netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'phy_extra_timer_cancel'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->control.extra_timer_program_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- id = ctx->control.extra_timer_program_netclock_id;
-
- test_begin(t, "uninit")
- {
- char data[sizeof(phy_t)];
-
- memset(data, '\0', sizeof(phy_t));
- phy_uninit (ctx);
- test_fail_unless ((EINVAL != errno)
- && (NULL != ctx)
- && (0 == memcmp(ctx, data, sizeof(phy_t))));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "extra timer cancel netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- maximus_pending_isrs = 0;
-
- return;
-}
-
-void phy_deferred_schedule_test_case (test_t t)
-{
- printf ("deferred schedule\n");
- test_case_begin (t, "deferred schedule");
-
- test_begin (t, "NULL ctx")
- {
- dbg_fatal_try_begin
- {
- phy_deferred_schedule (NULL);
- test_fail_unless (EINVAL == errno);
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("deferred schedule with NULL ctx\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* reset errno */
- errno = 0;
- } test_end;
-
- return;
-}
-
-void phy_date_test_case(test_t t)
-{
- printf("date\n");
- test_case_begin(t, "date");
-
- test_begin(t, "date")
- {
- my_station.current_tick_tck = 5;
- test_fail_unless (((u32)my_station.current_tick_tck == phy_date())
- && (EINVAL != errno));
- } test_end;
-
- return;
-}
-
-void phy_seed_test_case(test_t t)
-{
- printf("seed\n");
- test_case_begin(t, "seed");
-
- test_begin(t, "seed")
- {
- my_station.seed = 0x12345678;
- test_fail_unless ((my_station.seed == phy_seed())
- && (EINVAL != errno));
- } test_end;
-
- return;
-}
-
-void phy_tx_fc10_test_case(test_t t)
-{
- printf("tx fc10\n");
- test_case_begin(t, "tx fc10");
-
- test_begin(t, "tx fc10")
- {
- u32 fc_10 = 10;
- phy_tx_fc10 (ctx, 0, fc_10);
- test_fail_unless ((EINVAL != errno)
- && (fc_10 == ctx->control.next_tx_param.fc_10)
- && (my_station.current_tick_tck + PHY_FC_10_PREPARATION_DELAY_TCK == ctx->control.next_tx_param.fc_10_tick));
- } test_end;
-
- return;
-}
-
-void phy_tx_param_test_case(test_t t)
-{
- phy_fc_mode_t fc_mode = PHY_FC_MODE_HYBRID_1;
- bool short_ppdu = false;
- phy_mod_t mod;
- phy_fecrate_t fecrate = PHY_FEC_RATE_16_21;
- phy_pb_size_t pb_size = PHY_PB_SIZE_136;
- phy_gil_t gil = PHY_GIL_417;
- uint tonemap_index = 0;
-
- printf("tx param\n");
- test_case_begin(t, "tx param");
-
- test_begin(t, "tx param with TM modulation")
- {
- mod = PHY_MOD_TM;
-
- phy_tx_param (ctx, fc_mode, PHY_COMBO_PARAMS (mod, fecrate, pb_size),
- gil, 0);
- test_fail_unless((EINVAL != errno)
- && (fc_mode == ctx->control.next_tx_param.fc_mode)
- && (short_ppdu == ctx->control.next_tx_param.short_ppdu)
- && (mod == ctx->control.next_tx_param.mod)
- && (fecrate == ctx->control.next_tx_param.fecrate)
- && (pb_size == ctx->control.next_tx_param.pb_size)
- && (gil == ctx->control.next_tx_param.gil)
- && (tonemap_index == ctx->control.next_tx_param.tonemap_index)
- && (0 == ctx->control.next_tx_param.nb_pb));
- } test_end;
-
- test_begin(t, "tx param with HS ROBO modulation")
- {
- mod = PHY_MOD_HS_ROBO;
-
- phy_tx_param (ctx, fc_mode, PHY_COMBO_PARAMS (mod, fecrate, pb_size),
- gil, 0);
- test_fail_unless((EINVAL != errno)
- && (fc_mode == ctx->control.next_tx_param.fc_mode)
- && (short_ppdu == ctx->control.next_tx_param.short_ppdu)
- && (mod == ctx->control.next_tx_param.mod)
- && (PHY_FEC_RATE_1_2 == ctx->control.next_tx_param.fecrate)
- && (PHY_PB_SIZE_520 == ctx->control.next_tx_param.pb_size)
- && (PHY_GIL_417 == ctx->control.next_tx_param.gil)
- && (0 == ctx->control.next_tx_param.tonemap_index)
- && (0 == ctx->control.next_tx_param.nb_pb));
- } test_end;
-
- test_begin(t, "tx param with MINI ROBO modulation")
- {
- mod = PHY_MOD_MINI_ROBO;
-
- phy_tx_param (ctx, fc_mode, PHY_COMBO_PARAMS (mod, fecrate, pb_size),
- gil, 0);
- test_fail_unless((EINVAL != errno)
- && (fc_mode == ctx->control.next_tx_param.fc_mode)
- && (short_ppdu == ctx->control.next_tx_param.short_ppdu)
- && (mod == ctx->control.next_tx_param.mod)
- && (PHY_FEC_RATE_1_2 == ctx->control.next_tx_param.fecrate)
- && (PHY_PB_SIZE_136 == ctx->control.next_tx_param.pb_size)
- && (PHY_GIL_567 == ctx->control.next_tx_param.gil)
- && (0 == ctx->control.next_tx_param.tonemap_index)
- && (0 == ctx->control.next_tx_param.nb_pb));
- } test_end;
-
- return;
-}
-
-void phy_tx_param_sound_test_case(test_t t)
-{
- phy_fc_mode_t fc_mode = PHY_FC_MODE_HYBRID_1;
- uint nb_pb = MAXIMUS_PHY_SOUND_MAX_PB_NB;
- phy_mod_t mod;
- phy_fecrate_t fecrate = PHY_FEC_RATE_1_2;
- phy_pb_size_t pb_size = PHY_PB_SIZE_136;
- phy_gil_t gil = PHY_GIL_567;
-
- printf("tx param sound\n");
- test_case_begin(t, "tx param sound");
-
- test_begin(t, "tx param sound with MINI ROBO modulation")
- {
- mod = PHY_MOD_MINI_ROBO;
-
- phy_tx_param_sound (ctx, fc_mode, nb_pb,
- PHY_COMBO_PARAMS (mod, fecrate, pb_size), gil, 0);
- test_fail_unless((EINVAL != errno)
- && (fc_mode == ctx->control.next_tx_param.fc_mode)
- && !ctx->control.next_tx_param.short_ppdu
- && (nb_pb == ctx->control.next_tx_param.nb_pb)
- && (mod == ctx->control.next_tx_param.mod)
- && (PHY_FEC_RATE_1_2 == ctx->control.next_tx_param.fecrate)
- && (PHY_PB_SIZE_136 == ctx->control.next_tx_param.pb_size)
- && (PHY_GIL_567 == ctx->control.next_tx_param.gil)
- && (0 == ctx->control.next_tx_param.tonemap_index));
- } test_end;
-
- test_begin(t, "tx param sound with HS ROBO modulation")
- {
- mod = PHY_MOD_HS_ROBO;
- pb_size = PHY_PB_SIZE_520;
- gil = PHY_GIL_417;
-
- phy_tx_param_sound (ctx, fc_mode, nb_pb,
- PHY_COMBO_PARAMS (mod, fecrate, pb_size), gil, 0);
- test_fail_unless((EINVAL != errno)
- && (fc_mode == ctx->control.next_tx_param.fc_mode)
- && !ctx->control.next_tx_param.short_ppdu
- && (nb_pb == ctx->control.next_tx_param.nb_pb)
- && (mod == ctx->control.next_tx_param.mod)
- && (PHY_FEC_RATE_1_2 == ctx->control.next_tx_param.fecrate)
- && (PHY_PB_SIZE_520 == ctx->control.next_tx_param.pb_size)
- && (PHY_GIL_417 == ctx->control.next_tx_param.gil)
- && (0 == ctx->control.next_tx_param.tonemap_index));
- } test_end;
-
- test_begin(t, "tx param sound with ROBO modulation")
- {
- mod = PHY_MOD_ROBO;
-
- phy_tx_param_sound (ctx, fc_mode, nb_pb,
- PHY_COMBO_PARAMS (mod, fecrate, pb_size), gil, 0);
- test_fail_unless((EINVAL != errno)
- && (fc_mode == ctx->control.next_tx_param.fc_mode)
- && !ctx->control.next_tx_param.short_ppdu
- && (nb_pb == ctx->control.next_tx_param.nb_pb)
- && (mod == ctx->control.next_tx_param.mod)
- && (PHY_FEC_RATE_1_2 == ctx->control.next_tx_param.fecrate)
- && (PHY_PB_SIZE_520 == ctx->control.next_tx_param.pb_size)
- && (PHY_GIL_417 == ctx->control.next_tx_param.gil)
- && (0 == ctx->control.next_tx_param.tonemap_index));
- } test_end;
-
- return;
-}
-
-void phy_tx_frame_test_case(test_t t)
-{
- u32 date = 10;
- u32 date2 = 500000;
- u32 date3 = 300000;
- bool want_conf = true;
- bool stop_tx_on_prp_lost = true;
- u32 fc_av[4];
- tick_t msg_tick_tck;
- netclock_id_t id;
-
- // for tonemask
- uint carrier_nb = PHY_CARRIER_NB;
- u8 tonemask[(PHY_CARRIER_NB+7)/8];
-
- // for tonemap
- blk_t tonemap1;
- blk_t tonemap2;
- u8 tonemap1_data[MAC_PB520_BYTES];
- u8 tonemap2_data[(PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES];
- uint tonemap_index = 0;
-
- printf("tx frame\n");
- test_case_begin(t, "tx frame");
-
- // set tonemask: all carriers enabled
- memset(tonemask, 0x00, ((PHY_CARRIER_NB+7)/8)*sizeof(u8));
- phy_set_tonemask (ctx, (u32 *)tonemask, carrier_nb);
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "tonemask phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_TONEMASK == phy_hdr->type);
-
- // read the remaining part of message
- test_fail_unless (sizeof(uint) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint)));
- test_fail_unless ((PHY_CARRIER_NB+7)/8 == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+sizeof(uint), (PHY_CARRIER_NB+7)/8));
-
- // check phy data
- test_fail_unless (0 == memcmp(&carrier_nb, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint)));
- test_fail_unless (0 == memcmp(tonemask, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+sizeof(uint), (PHY_CARRIER_NB+7)/8));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // set tonemap: QAM1024 for all carriers
- memset(tonemap1_data, 0x77, MAC_PB520_BYTES*sizeof(u8));
- memset(tonemap2_data, 0x77, ((PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES)*sizeof(u8));
- tonemap2.next = NULL;
- tonemap2.data = tonemap2_data;
- tonemap1.next = &tonemap2;
- tonemap1.data = tonemap1_data;
- ctx->control.next_tx_param.mod = PHY_MOD_TM;
- phy_set_tonemap (ctx, &tonemap1);
-
- // set fc av
- memset(&fc_av, '\0', 4*sizeof(u32));
- fc_av[0] = 0x00000001; // DT_AV = SOF
-
- // set PHY context for transmission/reception time calculation
- ctx->control.next_tx_param.fecrate = PHY_FEC_RATE_1_2;
- ctx->control.next_tx_param.gil = PHY_GIL_417;
- ctx->control.next_tx_param.pb_size = PHY_PB_SIZE_520;
- ctx->control.next_tx_param.mod = PHY_MOD_TM;
- ctx->pbdma.nb_total = PHY_PB_MAX_NB;
- ctx->pbdma.nb_pb_it = ctx->pbdma.nb_total;
- ctx->control.next_tx_param.short_ppdu = false;
- ctx->control.next_tx_param.tonemap_index = tonemap_index;
-
- test_begin(t, "tx frame")
- {
- phy_tx_frame (ctx, date, want_conf, stop_tx_on_prp_lost, fc_av);
- test_fail_unless ((EINVAL != errno)
- && (stop_tx_on_prp_lost == ctx->control.stop_tx_on_prp_lost)
- && (0 == memcmp(fc_av, ctx->control.next_tx_param.fc_av, 4*sizeof(u32))));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "first netclock message")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless (sizeof(netclock_msg_hdr_t) == read(fd_in, &netclock_hdr, sizeof(netclock_msg_hdr_t)));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr.tick_low));
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr.tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr.tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr.id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the first callback
-
- test_begin(t, "maximus phy tx frame cb with FC 1.0 not ready")
- {
- maximus_phy_tx_frame_t tx_frame;
-
- tx_frame.ctx = ctx;
- tx_frame.want_conf = want_conf;
-
- ctx->control.next_tx_param.fc_10_tick = my_station.current_tick_tck + 1;
-
- dbg_fatal_try_begin
- {
- maximus_phy_tx_frame_cb ((void*)&tx_frame);
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("maximus phy tx frame cb with FC 1.0 not ready\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
- } test_end;
-
- test_begin(t, "maximus phy tx frame cb")
- {
- maximus_phy_tx_frame_t tx_frame;
-
- tx_frame.ctx = ctx;
- tx_frame.want_conf = want_conf;
-
- ctx->control.next_tx_param.fc_10_tick = my_station.current_tick_tck;
-
- maximus_phy_tx_frame_cb ((void*)&tx_frame);
-
- test_fail_unless ((EINVAL != errno)
- && (maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PHY))
- && (ctx->control.current_cb == ctx->control.access_conf_cb)
- && (ctx->control.current_tx_param.fc_10 == ctx->control.next_tx_param.fc_10)
- && (ctx->control.current_tx_param.fc_10_tick == ctx->control.next_tx_param.fc_10_tick)
- && (ctx->control.current_tx_param.fc_mode == ctx->control.next_tx_param.fc_mode)
- && (ctx->control.current_tx_param.short_ppdu == ctx->control.next_tx_param.short_ppdu)
- && (ctx->control.current_tx_param.mod == ctx->control.next_tx_param.mod)
- && (ctx->control.current_tx_param.fecrate == ctx->control.next_tx_param.fecrate)
- && (ctx->control.current_tx_param.pb_size == ctx->control.next_tx_param.pb_size)
- && (ctx->control.current_tx_param.gil == ctx->control.next_tx_param.gil)
- && (ctx->control.current_tx_param.tonemap_index == ctx->control.next_tx_param.tonemap_index)
- && (ctx->control.current_tx_param.symbol_nb == ctx->control.next_tx_param.symbol_nb)
- && (0 == memcmp(ctx->control.current_tx_param.fc_av, ctx->control.next_tx_param.fc_av, 4*sizeof(u32)))
- && (0 == ctx->control.next_tx_param.tx_frame_netclock_id)
- && (0 != ctx->control.current_tx_param.tx_frame_netclock_id)
- && (ctx->control.current_tx_param.nb_pb == ctx->control.next_tx_param.nb_pb));
- } test_end;
-
- test_begin(t, "maximus phy tx frame cb blocked")
- {
- maximus_phy_tx_frame_t tx_frame;
-
- tx_frame.ctx = ctx;
- tx_frame.want_conf = want_conf;
-
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_WAIT_CONF;
-
- maximus_phy_tx_frame_cb ((void*)&tx_frame);
-
- test_fail_unless ((EINVAL != errno)
- && ctx->control.tx_blocked_on_false_alarm);
-
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_TX;
- } test_end;
-
- test_begin(t, "access conf cb")
- {
- test_fail_unless ((NULL != ctx->control.access_conf_cb)
- && ((*ctx->control.access_conf_cb)(ctx->control.user_data)));
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "second netclock message")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
- uint duration_in_ticks;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // set preamble transimission time
- duration_in_ticks = MAXIMUS_PHY_PREAMBLE_DETECTION_DELAY_TCK;
- date += duration_in_ticks;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless(sizeof(netclock_msg_hdr_t) == read(fd_in, &netclock_hdr, sizeof(netclock_msg_hdr_t)));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr.tick_low));
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr.tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr.tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr.id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- test_begin(t, "second tx frame")
- {
- phy_tx_frame (ctx, date2, want_conf, stop_tx_on_prp_lost, fc_av);
- test_fail_unless ((EINVAL != errno)
- && (stop_tx_on_prp_lost == ctx->control.stop_tx_on_prp_lost)
- && (0 == memcmp(fc_av, ctx->control.next_tx_param.fc_av, 4*sizeof(u32))));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message of second tx frame")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless (sizeof(netclock_msg_hdr_t) == read(fd_in, &netclock_hdr, sizeof(netclock_msg_hdr_t)));
-
- // check netclock tick value
- test_fail_unless (date2 == ntohl(netclock_hdr.tick_low));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // test the second callback
- test_begin(t, "maximus phy tx pre cb")
- {
- maximus_phy_tx_pre_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno) && (EPROTO != errno));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "first phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_PREAMBLE == phy_hdr->type);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "thrid netclock message")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
- uint pre_duration = MAC_PREAMBLE_TCK; // in AV mode
- uint fc_duration = MAC_FC_AV_TCK; // in AV mode
- uint duration_in_ticks;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // calculate frame control transimission time
- if ((PHY_FC_MODE_HYBRID_2 == ctx->control.current_tx_param.fc_mode)
- || (PHY_FC_MODE_AV_2 == ctx->control.current_tx_param.fc_mode))
- {
- fc_duration *= 2; // 2 symbols
- }
- if ((PHY_FC_MODE_HYBRID_1 == ctx->control.current_tx_param.fc_mode)
- || (PHY_FC_MODE_HYBRID_2 == ctx->control.current_tx_param.fc_mode))
- {
- pre_duration = MAC_PREAMBLE_HYBRID_TCK; // in Hybrid mode
- fc_duration += MAC_FC_10_TCK; // in Hybrid mode
- }
- duration_in_ticks = (pre_duration \
- - MAXIMUS_PHY_PREAMBLE_DETECTION_DELAY_TCK) \
- + fc_duration \
- + MAXIMUS_PHY_FC_RECEPTION_DELAY_TCK;
- date += duration_in_ticks;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless(sizeof(netclock_msg_hdr_t) == read(fd_in, &netclock_hdr, sizeof(netclock_msg_hdr_t)));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr.tick_low));
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr.tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr.tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr.id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the third callback
- test_begin(t, "maximus phy tx fc cb")
- {
- maximus_phy_tx_fc_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno) && (EPROTO != errno));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "second phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_FC_HYBRID_MODE == phy_hdr->type);
-
- // read the remaining part of message
- test_fail_unless (5*sizeof(u32) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), 5*sizeof(u32)));
-
- // check phy data
- test_fail_unless (0 == memcmp(&ctx->control.current_tx_param.fc_10, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(u32)));
- test_fail_unless (0 == memcmp(&ctx->control.current_tx_param.fc_av, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+sizeof(u32), 4*sizeof(u32)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "fourth netclock message")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
- uint bits_per_symbol;
- uint symbol_nb;
- uint duration_in_ticks;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // calculate MPDU payload transimission time
- bits_per_symbol = maximus_dur_bits_per_symbol (ctx->control.current_tx_param.mod,
- ctx->tmdma.tonemask,
- ctx->tmdma.tonemap[ctx->control.current_tx_param.tonemap_index],
- ctx->tmdma.carrier_nb);
- symbol_nb = maximus_dur_symbol_nb (ctx->control.current_tx_param.mod,
- ctx->control.current_tx_param.fecrate,
- ctx->control.current_tx_param.pb_size,
- bits_per_symbol,
- ctx->pbdma.nb_total);
- duration_in_ticks = maximus_dur_data_tck(ctx->control.current_tx_param.gil, symbol_nb) \
- - MAXIMUS_PHY_FC_RECEPTION_DELAY_TCK \
- + MAXIMUS_PHY_MPDU_RECEPTION_DELAY_TCK;
- date += duration_in_ticks;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless(sizeof(netclock_msg_hdr_t) == read(fd_in, &netclock_hdr, sizeof(netclock_msg_hdr_t)));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr.tick_low));
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr.tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr.tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr.id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the fourth callback
- phy_pb_t pb[PHY_PB_MAX_NB];
- u8 pb_data[PHY_PB_MAX_NB][MAC_PB520_BYTES];
- test_begin(t, "maximus phy tx mpdu cb")
- {
- int i = 0;
- char c = 'a';
-
- for (i=0; i<PHY_PB_MAX_NB; i++)
- {
- memset(&pb_data[i][0], c, MAC_PB520_BYTES);
- pb[i].pb_tx.blk.data = &pb_data[i][0];
- pb[i].pb_tx.header = i;
- if (PHY_PB_MAX_NB-1 != i)
- {
- pb[i].pb_tx.blk.next = &pb[i+1].pb_tx.blk;
- }
- else
- {
- pb[i].pb_tx.blk.next = NULL;
- }
- c++;
- }
-
- ctx->pbdma.nb_ready = PHY_PB_MAX_NB;
- ctx->pbdma.first_pb = pb;
-
- maximus_phy_tx_mpdu_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (EPROTO != errno)
- && (maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PBDMA))
- && (0 == ctx->pbdma.status_word.bf.pb_null)
- && (0 == ctx->pbdma.status_word.bf.null_pb_index)
- && (1 == ctx->pbdma.status_word.bf.pb_it)
- && (1 == ctx->pbdma.status_word.bf.end_tx_pb));
- // pb_it
- ctx->pbdma.status_word.bf.end_tx_pb = 0;
- (*ctx->control.pbdma_cb) (ctx->control.user_data,
- ctx->pbdma.status_word.value);
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PBDMA);
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "third phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- sci_msg_hdr_t *sci_hdr;
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
- unsigned int pb_counter;
- phy_pb_tx_t *current_pb = &ctx->pbdma.first_pb->pb_tx;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- /* TONEMAP */
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_TONEMAP == phy_hdr->type);
- test_fail_unless (ctx->control.current_tx_param.tx_id == ntohs(phy_hdr->tx_id));
-
- // read the remaining part of message
- test_fail_unless ((PHY_CARRIER_NB+1)/2 == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), (PHY_CARRIER_NB+1)/2));
-
- // check phy data
- test_fail_unless (0 == memcmp(tonemap2_data, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), (PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES));
- test_fail_unless (0 == memcmp(tonemap1_data, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+(PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES, MAC_PB520_BYTES));
-
- /* MPDU */
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- // set sci and phy headers pointers
- sci_hdr = (sci_msg_hdr_t *)(data);
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_MPDU_PAYLOAD == phy_hdr->type);
- test_fail_unless (PHY_MPDU_FORMAT_SOF == phy_hdr->mpdu_format);
- test_fail_unless (ctx->pbdma.nb_ready == phy_hdr->pb_nb);
-
- // read the remaining part of message
- test_fail_unless (phy_hdr->pb_nb*MAC_PB520_BYTES == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), phy_hdr->pb_nb*MAC_PB520_BYTES));
-
- // check pb header and phy data
- for (pb_counter = 0; pb_counter < phy_hdr->pb_nb; pb_counter++)
- {
- test_fail_unless (phy_hdr->pb_header[pb_counter] == htonl(current_pb->header));
- test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+(phy_hdr->pb_nb-1-pb_counter)*MAC_PB520_BYTES, current_pb->blk.data, MAC_PB520_BYTES));
- current_pb = PARENT_OF(phy_pb_tx_t, blk, current_pb->blk.next);
- }
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(sci_hdr->netclock_high))) << 32)
- | (unsigned long long)(ntohl(sci_hdr->netclock_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- test_begin(t, "short ppdu")
- {
- // for phy message
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // test the callback
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_TX;
- ctx->control.current_tx_param.short_ppdu = true;
- maximus_phy_tx_fc_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno) && (EPROTO != errno));
-
- // check that the correct phy message has been sent to Maximus
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_FC_HYBRID_MODE == phy_hdr->type);
-
- // read the remaining part of message
- test_fail_unless (5*sizeof(u32) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), 5*sizeof(u32)));
-
- // check phy data
- test_fail_unless (0 == memcmp(&ctx->control.current_tx_param.fc_10, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(u32)));
- test_fail_unless (0 == memcmp(&ctx->control.current_tx_param.fc_av, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+sizeof(u32), 4*sizeof(u32)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- id = ctx->control.next_tx_param.tx_frame_netclock_id;
-
- test_begin(t, "third tx frame")
- {
- phy_tx_frame (ctx, date3, want_conf, stop_tx_on_prp_lost, fc_av);
- test_fail_unless ((EINVAL != errno)
- && (stop_tx_on_prp_lost == ctx->control.stop_tx_on_prp_lost)
- && (0 == memcmp(fc_av, ctx->control.next_tx_param.fc_av, 4*sizeof(u32))));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message to cancel second tx frame")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message of third tx frame")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless (sizeof(netclock_msg_hdr_t) == read(fd_in, &netclock_hdr, sizeof(netclock_msg_hdr_t)));
-
- // check netclock tick value
- test_fail_unless (date3 == ntohl(netclock_hdr.tick_low));
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr.id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
-
- // reset next tx frame netclock id (because callback will not be called)
- ctx->control.next_tx_param.tx_frame_netclock_id = 0;
- } test_end;
-
- return;
-}
-
-void maximus_phy_tx_frame_sound_test_case(test_t t)
-{
- u32 date = 400000;
- bool want_conf = false;
- bool stop_tx_on_prp_lost = false;
- u32 fc_av[4];
- tick_t msg_tick_tck;
- uint nb_pb = MAXIMUS_PHY_SOUND_MAX_PB_NB;
-
- printf("tx frame (sound)\n");
- test_case_begin(t, "tx frame (sound)");
-
- // set fc av
- memset(&fc_av, '\0', 4*sizeof(u32));
- fc_av[0] = 0x00000004; // DT_AV = SOUND
-
- test_begin(t, "tx frame (sound)")
- {
- phy_tx_frame (ctx, date, want_conf, stop_tx_on_prp_lost, fc_av);
- test_fail_unless ((EINVAL != errno)
- && (stop_tx_on_prp_lost == ctx->control.stop_tx_on_prp_lost)
- && (0 == memcmp(fc_av, ctx->control.next_tx_param.fc_av, 4*sizeof(u32))));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "first netclock message")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless (sizeof(netclock_msg_hdr_t) == read(fd_in, &netclock_hdr, sizeof(netclock_msg_hdr_t)));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr.tick_low));
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr.tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr.tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr.id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the first callback
- test_begin(t, "maximus phy tx frame cb (sound)")
- {
- maximus_phy_tx_frame_t tx_frame;
-
- tx_frame.ctx = ctx;
- tx_frame.want_conf = want_conf;
-
- ctx->control.next_tx_param.fc_10_tick = my_station.current_tick_tck;
-
- maximus_phy_tx_frame_cb ((void*)&tx_frame);
-
- test_fail_unless ((EINVAL != errno)
- && (0 == maximus_pending_isrs)
- && (ctx->control.current_tx_param.fc_10 == ctx->control.next_tx_param.fc_10)
- && (ctx->control.current_tx_param.fc_10_tick == ctx->control.next_tx_param.fc_10_tick)
- && (ctx->control.current_tx_param.fc_mode == ctx->control.next_tx_param.fc_mode)
- && (ctx->control.current_tx_param.short_ppdu == ctx->control.next_tx_param.short_ppdu)
- && (ctx->control.current_tx_param.mod == ctx->control.next_tx_param.mod)
- && (ctx->control.current_tx_param.fecrate == ctx->control.next_tx_param.fecrate)
- && (ctx->control.current_tx_param.pb_size == ctx->control.next_tx_param.pb_size)
- && (ctx->control.current_tx_param.gil == ctx->control.next_tx_param.gil)
- && (ctx->control.current_tx_param.tonemap_index == ctx->control.next_tx_param.tonemap_index)
- && (ctx->control.current_tx_param.symbol_nb == ctx->control.next_tx_param.symbol_nb)
- && (0 == memcmp(ctx->control.current_tx_param.fc_av, ctx->control.next_tx_param.fc_av, 4*sizeof(u32)))
- && (0 == ctx->control.next_tx_param.tx_frame_netclock_id)
- && (0 != ctx->control.current_tx_param.tx_frame_netclock_id)
- && (ctx->control.current_tx_param.nb_pb == ctx->control.next_tx_param.nb_pb));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "second netclock message")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
- uint duration_in_ticks;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // set preamble transimission time
- duration_in_ticks = MAXIMUS_PHY_PREAMBLE_DETECTION_DELAY_TCK;
- date += duration_in_ticks;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless(sizeof(netclock_msg_hdr_t) == read(fd_in, &netclock_hdr, sizeof(netclock_msg_hdr_t)));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr.tick_low));
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr.tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr.tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr.id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the second callback
- test_begin(t, "maximus phy tx pre cb (sound)")
- {
- maximus_phy_tx_pre_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno) && (EPROTO != errno));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "first phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_PREAMBLE == phy_hdr->type);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "thrid netclock message")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
- uint pre_duration = MAC_PREAMBLE_TCK; // in AV mode
- uint fc_duration = MAC_FC_AV_TCK; // in AV mode
- uint duration_in_ticks;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // calculate frame control transimission time
- if ((PHY_FC_MODE_HYBRID_2 == ctx->control.current_tx_param.fc_mode)
- || (PHY_FC_MODE_AV_2 == ctx->control.current_tx_param.fc_mode))
- {
- fc_duration *= 2; // 2 symbols
- }
- if ((PHY_FC_MODE_HYBRID_1 == ctx->control.current_tx_param.fc_mode)
- || (PHY_FC_MODE_HYBRID_2 == ctx->control.current_tx_param.fc_mode))
- {
- pre_duration = MAC_PREAMBLE_HYBRID_TCK; // in Hybrid mode
- fc_duration += MAC_FC_10_TCK; // in Hybrid mode
- }
- duration_in_ticks = (pre_duration \
- - MAXIMUS_PHY_PREAMBLE_DETECTION_DELAY_TCK) \
- + fc_duration \
- + MAXIMUS_PHY_FC_RECEPTION_DELAY_TCK;
- date += duration_in_ticks;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless(sizeof(netclock_msg_hdr_t) == read(fd_in, &netclock_hdr, sizeof(netclock_msg_hdr_t)));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr.tick_low));
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr.tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr.tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr.id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the third callback
- test_begin(t, "maximus phy tx fc cb (sound)")
- {
- maximus_phy_tx_fc_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno) && (EPROTO != errno));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "second phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_FC_HYBRID_MODE == phy_hdr->type);
-
- // read the remaining part of message
- test_fail_unless (5*sizeof(u32) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), 5*sizeof(u32)));
-
- // check phy data
- test_fail_unless (0 == memcmp(&ctx->control.current_tx_param.fc_10, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(u32)));
- test_fail_unless (0 == memcmp(&ctx->control.current_tx_param.fc_av, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+sizeof(u32), 4*sizeof(u32)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "fourth netclock message")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
- uint bits_per_symbol;
- uint symbol_nb;
- uint duration_in_ticks;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // calculate MPDU payload transimission time
- bits_per_symbol = maximus_dur_bits_per_symbol (ctx->control.current_tx_param.mod,
- ctx->tmdma.tonemask,
- ctx->tmdma.tonemap[ctx->control.current_tx_param.tonemap_index],
- ctx->tmdma.carrier_nb);
- symbol_nb = maximus_dur_symbol_nb (ctx->control.current_tx_param.mod,
- ctx->control.current_tx_param.fecrate,
- ctx->control.current_tx_param.pb_size,
- bits_per_symbol,
- nb_pb);
- duration_in_ticks = maximus_dur_data_tck(ctx->control.current_tx_param.gil, symbol_nb) \
- - MAXIMUS_PHY_FC_RECEPTION_DELAY_TCK \
- + MAXIMUS_PHY_MPDU_RECEPTION_DELAY_TCK;
- date += duration_in_ticks;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless(sizeof(netclock_msg_hdr_t) == read(fd_in, &netclock_hdr, sizeof(netclock_msg_hdr_t)));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr.tick_low));
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr.tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr.tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr.id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the fourth callback
- test_begin(t, "maximus phy tx mpdu cb (sound)")
- {
- maximus_phy_tx_mpdu_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (EPROTO != errno));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "third phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- unsigned char null_pb[MAC_PB520_BYTES];
- sci_msg_hdr_t *sci_hdr;
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
- unsigned int pb_counter;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- // set sci and phy headers pointers
- sci_hdr = (sci_msg_hdr_t *)(data);
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_MPDU_PAYLOAD == phy_hdr->type);
- test_fail_unless (PHY_MPDU_FORMAT_SOUND == phy_hdr->mpdu_format);
- test_fail_unless (nb_pb == phy_hdr->pb_nb);
-
- // read the remaining part of message
- test_fail_unless (phy_hdr->pb_nb*MAC_PB520_BYTES == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), phy_hdr->pb_nb*MAC_PB520_BYTES));
-
- // check pb header and phy data
- memset(null_pb, 0, MAC_PB520_BYTES);
- for (pb_counter = 0; pb_counter < phy_hdr->pb_nb; pb_counter++)
- {
- test_fail_unless (phy_hdr->pb_header[pb_counter] == 0);
- test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+(phy_hdr->pb_nb-1-pb_counter)*MAC_PB520_BYTES, null_pb, MAC_PB520_BYTES));
- }
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(sci_hdr->netclock_high))) << 32)
- | (unsigned long long)(ntohl(sci_hdr->netclock_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- return;
-}
-
-void maximus_phy_send_test_case(test_t t)
-{
- // for tonemap
- blk_t tonemap1;
- blk_t tonemap2;
- u8 tonemap1_data[MAC_PB520_BYTES];
- u8 tonemap2_data[(PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES];
-
- printf("maximus phy send\n");
- test_case_begin(t, "maximus phy send");
-
- // set tonemap
- memset(tonemap1_data, '1', MAC_PB520_BYTES*sizeof(u8));
- memset(tonemap2_data, '2', ((PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES)*sizeof(u8));
- tonemap2.next = NULL;
- tonemap2.data = tonemap2_data;
- tonemap1.next = &tonemap2;
- tonemap1.data = tonemap1_data;
- phy_set_tonemap (ctx, &tonemap1);
- ctx->control.current_tx_param.mod = PHY_MOD_ROBO;
-
- // set medium state
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_TX;
-
- test_begin(t, "maximus phy tx mpdu cb")
- {
- u8 pb_data[PHY_PB_NB][MAC_PB520_BYTES];
- phy_pb_t phy_pb[PHY_PB_NB];
- unsigned short int pb_counter = 0;
- char c = 0x00;
- u32 hdr = 0;
-
- unsigned short int msg_nb = 1;
- uint8_t last_msg_pb_nb = PHY_PB_MAX_NB;
- unsigned short int msg_counter = 0;
- uint8_t pb_nb = PHY_PB_NB;
- phy_pb_tx_t *current_pb;
-
- if (PHY_PB_NB > PHY_PB_MAX_NB)
- {
- msg_nb = (unsigned short int)(PHY_PB_NB/PHY_PB_MAX_NB);
- pb_nb = PHY_PB_MAX_NB;
- if (0 != (PHY_PB_NB % PHY_PB_MAX_NB))
- {
- last_msg_pb_nb = (uint8_t)(PHY_PB_NB % PHY_PB_MAX_NB);
- msg_nb++;
- }
- }
-
- // set pb dma
- ctx->pbdma.first_pb = phy_pb;
- ctx->pbdma.nb_total = PHY_PB_NB;
- ctx->pbdma.nb_ready = PHY_PB_NB;
- ctx->pbdma.nb_pb_it = PHY_PB_NB-1;
-
- current_pb = &ctx->pbdma.first_pb->pb_tx;
-
- for (pb_counter = 0; pb_counter < PHY_PB_NB; pb_counter++)
- {
- memset(&pb_data[pb_counter][0], c, MAC_PB520_BYTES);
- phy_pb[pb_counter].pb_tx.blk.data = &pb_data[pb_counter][0];
- phy_pb[pb_counter].pb_tx.header = hdr;
- phy_pb[pb_counter].pb_tx.blk.next = &phy_pb[pb_counter+1].pb_tx.blk;
- if (PHY_PB_NB-1 == pb_counter)
- {
- phy_pb[pb_counter].pb_tx.blk.next = NULL;
- }
- c++;
- hdr += 10;
- }
-
- maximus_phy_tx_mpdu_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (EPROTO != errno)
- && (maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PBDMA))
- && (0 == ctx->pbdma.status_word.bf.pb_null)
- && (0 == ctx->pbdma.status_word.bf.null_pb_index)
- && (1 == ctx->pbdma.status_word.bf.pb_it)
- && (1 == ctx->pbdma.status_word.bf.end_tx_pb));
- // pb_it
- ctx->pbdma.status_word.bf.end_tx_pb = 0;
- (*ctx->control.pbdma_cb) (ctx->control.user_data,
- ctx->pbdma.status_word.value);
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PBDMA);
-
- // check that the correct phy messages have been sent to Maximus
-
- for (msg_counter = 0; msg_counter < msg_nb; msg_counter++)
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- if ((1 != msg_nb) && (msg_nb-1 == msg_counter))
- {
- pb_nb = last_msg_pb_nb;
- }
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_MPDU_PAYLOAD == phy_hdr->type);
- test_fail_unless (pb_nb == phy_hdr->pb_nb);
-
- // read the remaining part of message
- test_fail_unless (phy_hdr->pb_nb*MAC_PB520_BYTES == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), phy_hdr->pb_nb*MAC_PB520_BYTES));
-
- // check pb header and phy data
- for (pb_counter = 0; pb_counter < phy_hdr->pb_nb; pb_counter++)
- {
- test_fail_unless (phy_hdr->pb_header[pb_counter] == htonl(current_pb->header));
- test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+(phy_hdr->pb_nb-1-pb_counter)*MAC_PB520_BYTES, current_pb->blk.data, MAC_PB520_BYTES));
- current_pb = PARENT_OF(phy_pb_tx_t, blk, current_pb->blk.next);
- }
- // close pipe
- maximus_phy_close(fd_in);
- }
- } test_end;
-
- // set tx id
- ctx->control.current_tx_param.tx_id = 20;
-
- // test the tonemap transmission
- test_begin(t, "maximus phy send tonemap")
- {
- test_fail_unless ((0 == maximus_phy_send_tonemap(ctx))
- && (EINVAL != errno)
- && (EPROTO != errno));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "tonemap phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_TONEMAP == phy_hdr->type);
- test_fail_unless (ctx->control.current_tx_param.tx_id == ntohs(phy_hdr->tx_id));
-
- // read the remaining part of message
- test_fail_unless ((PHY_CARRIER_NB+1)/2 == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), (PHY_CARRIER_NB+1)/2));
-
- // check phy data
- test_fail_unless (0 == memcmp(tonemap2_data, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), (PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES));
- test_fail_unless (0 == memcmp(tonemap1_data, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+(PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES, MAC_PB520_BYTES));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // test send RX
- test_begin(t, "maximus phy send rx")
- {
- test_fail_unless ((0 == maximus_phy_send_rx(ctx))
- && (EINVAL != errno)
- && (EPROTO != errno));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "rx phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_RX == phy_hdr->type);
- test_fail_unless (ctx->control.rx_param.src_tx_id == ntohs(phy_hdr->tx_id));
-
- // read source station ID
- test_fail_unless (sizeof(uint16_t) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint16_t)));
-
- // check phy data
- test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), &ctx->control.rx_param.src_station_id, sizeof(uint16_t)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-}
-
-void phy_rx_param_test_case(test_t t)
-{
- printf("rx param\n");
- test_case_begin(t, "rx param");
-
- test_begin(t, "rx param")
- {
- phy_fc_mode_t fc_mode = PHY_FC_MODE_HYBRID_2;
-
- phy_rx_param (ctx, fc_mode);
- test_fail_unless ((EINVAL != errno)
- && (fc_mode == ctx->control.rx_param.fc_mode));
- } test_end;
-
- return;
-}
-
-void phy_rx_activate_test_case(test_t t)
-{
- u32 date = 1234567891;
- bool pre_detection = true;
- bool now = false;
- netclock_id_t id1, id2;
- uint cap = 3;
-
- printf("rx activate\n");
- test_case_begin(t, "rx activate");
-
- test_begin(t, "rx activate")
- {
- phy_rx_activate (ctx, now, date, pre_detection);
- test_fail_unless(EINVAL != errno);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "rx activate netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header and netclock header
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr->tick_low));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->control.rx_param.rx_activate_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- phy_access_backoff_start (ctx, date+10, cap);
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "backoff start netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date+10 == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'phy_access_timer_cancel'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->access.backoff_start_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- pre_detection = false;
- id1 = ctx->control.rx_param.rx_activate_netclock_id;
- id2 = ctx->access.backoff_start_netclock_id;
-
- test_begin(t, "rx activate")
- {
- phy_rx_activate (ctx, now, date+1, pre_detection);
- test_fail_unless(EINVAL != errno);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "cancel rx activate netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id1);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "cancel backoff start netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id2);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "rx activate netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date+1 == ntohl(netclock_hdr->tick_low));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->control.rx_param.rx_activate_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- bool prp_result = ctx->access.prp_result;
-
- // test the callback
- test_begin(t, "maximus rx activate cb")
- {
- maximus_phy_rx_activate_t rx_activate;
- rx_activate.ctx = ctx;
- rx_activate.pre_detection = pre_detection;
-
- maximus_phy_rx_activate_cb ((void*)&rx_activate);
- test_fail_unless ((EINVAL != errno)
- && (pre_detection == ctx->control.pre_detection)
- && (prp_result == ctx->access.prp_result));
- } test_end;
-
- now = true;
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_PRS1;
- phy_rx_activate (ctx, now, date, pre_detection);
- test_begin(t, "activate rx now")
- {
- test_fail_unless ((EINVAL != errno)
- && (pre_detection == ctx->control.pre_detection)
- && (prp_result == ctx->access.prp_result)
- && (MAXIMUS_PHY_MEDIUM_IDLE == ctx->access.medium_state));
- } test_end;
-
- pre_detection = true;
- phy_rx_activate (ctx, now, date, pre_detection);
- test_begin(t, "activate rx now")
- {
- test_fail_unless ((EINVAL != errno)
- && (pre_detection == ctx->control.pre_detection)
- && ctx->access.prp_result);
- } test_end;
-
- return;
-}
-
-void phy_rx_prepare_test_case(test_t t)
-{
- bool short_ppdu = false;
- phy_mod_t mod;
- phy_fecrate_t fecrate = PHY_FEC_RATE_1_2;
- phy_pb_size_t pb_size = PHY_PB_SIZE_136;
- phy_gil_t gil = PHY_GIL_417;
- uint tonemap_index = 0;
- uint symbol_nb = 0;
-
- printf("rx prepare\n");
- test_case_begin(t, "rx prepare");
-
- test_begin(t, "rx prepare with TM modulation")
- {
- mod = PHY_MOD_TM;
-
- phy_rx_prepare (ctx, 1, PHY_COMBO_PARAMS (mod, fecrate, pb_size), gil,
- symbol_nb, 1);
- test_fail_unless ((EINVAL != errno)
- && (short_ppdu == ctx->control.rx_param.short_ppdu)
- && (mod == ctx->control.rx_param.mod)
- && (fecrate == ctx->control.rx_param.fecrate)
- && (pb_size == ctx->control.rx_param.pb_size)
- && (gil == ctx->control.rx_param.gil)
- && (tonemap_index == ctx->control.rx_param.tonemap_index)
- && (symbol_nb == ctx->control.rx_param.symbol_nb)
- && ctx->control.rx_prepared
- && (0 == ctx->pbdma.index_current_pb));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "rx phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_RX == phy_hdr->type);
- test_fail_unless (ctx->control.rx_param.src_tx_id == ntohs(phy_hdr->tx_id));
-
- // read source station ID
- test_fail_unless (sizeof(uint16_t) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint16_t)));
-
- // check phy data
- test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), &ctx->control.rx_param.src_station_id, sizeof(uint16_t)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- test_begin(t, "rx prepare with ROBO modulation")
- {
- mod = PHY_MOD_ROBO;
-
- phy_rx_prepare (ctx, 1, PHY_COMBO_PARAMS (mod, fecrate, pb_size), gil,
- symbol_nb, 1);
- test_fail_unless ((EINVAL != errno)
- && (short_ppdu == ctx->control.rx_param.short_ppdu)
- && (mod == ctx->control.rx_param.mod)
- && (PHY_FEC_RATE_1_2 == ctx->control.rx_param.fecrate)
- && (PHY_PB_SIZE_520 == ctx->control.rx_param.pb_size)
- && (PHY_GIL_417 == ctx->control.rx_param.gil)
- && (0 == ctx->control.rx_param.tonemap_index)
- && (symbol_nb == ctx->control.rx_param.symbol_nb)
- && ctx->control.rx_prepared
- && (0 == ctx->pbdma.index_current_pb));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "rx phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_RX == phy_hdr->type);
- test_fail_unless (ctx->control.rx_param.src_tx_id == ntohs(phy_hdr->tx_id));
-
- // read source station ID
- test_fail_unless (sizeof(uint16_t) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint16_t)));
-
- // check phy data
- test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), &ctx->control.rx_param.src_station_id, sizeof(uint16_t)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- test_begin(t, "rx prepare with MINI ROBO modulation")
- {
- mod = PHY_MOD_MINI_ROBO;
-
- phy_rx_prepare (ctx, 1, PHY_COMBO_PARAMS (mod, fecrate, pb_size), gil,
- symbol_nb, 1);
- test_fail_unless ((EINVAL != errno)
- && (short_ppdu == ctx->control.rx_param.short_ppdu)
- && (mod == ctx->control.rx_param.mod)
- && (PHY_FEC_RATE_1_2 == ctx->control.rx_param.fecrate)
- && (PHY_PB_SIZE_136 == ctx->control.rx_param.pb_size)
- && (PHY_GIL_567 == ctx->control.rx_param.gil)
- && (0 == ctx->control.rx_param.tonemap_index)
- && (symbol_nb == ctx->control.rx_param.symbol_nb)
- && ctx->control.rx_prepared
- && (0 == ctx->pbdma.index_current_pb));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "rx phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_RX == phy_hdr->type);
- test_fail_unless (ctx->control.rx_param.src_tx_id == ntohs(phy_hdr->tx_id));
-
- // read source station ID
- test_fail_unless (sizeof(uint16_t) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint16_t)));
-
- // check phy data
- test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), &ctx->control.rx_param.src_station_id, sizeof(uint16_t)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- return;
-}
-
-void phy_rx_prepare_sound_test_case(test_t t)
-{
- phy_mod_t mod;
- phy_fecrate_t fecrate = PHY_FEC_RATE_1_2;
- phy_pb_size_t pb_size = PHY_PB_SIZE_520;
- phy_gil_t gil = PHY_GIL_417;
- uint symbol_nb = 100;
-
- printf("rx prepare sound\n");
- test_case_begin(t, "rx prepare sound");
-
- test_begin(t, "rx prepare sound with ROBO modulation")
- {
- mod = PHY_MOD_ROBO;
-
- phy_rx_prepare_sound (ctx, 0,
- PHY_COMBO_PARAMS (mod, fecrate, pb_size), gil,
- symbol_nb);
- test_fail_unless ((EINVAL != errno)
- && !ctx->control.rx_param.short_ppdu
- && (mod == ctx->control.rx_param.mod)
- && (PHY_FEC_RATE_1_2 == ctx->control.rx_param.fecrate)
- && (PHY_PB_SIZE_520 == ctx->control.rx_param.pb_size)
- && (PHY_GIL_417 == ctx->control.rx_param.gil)
- && (0 == ctx->control.rx_param.tonemap_index)
- && (symbol_nb == ctx->control.rx_param.symbol_nb)
- && ctx->control.rx_prepared
- && (0 == ctx->pbdma.index_current_pb));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "rx phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_RX == phy_hdr->type);
- test_fail_unless (ctx->control.rx_param.src_tx_id == ntohs(phy_hdr->tx_id));
-
- // read source station ID
- test_fail_unless (sizeof(uint16_t) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint16_t)));
-
- // check phy data
- test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), &ctx->control.rx_param.src_station_id, sizeof(uint16_t)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- test_begin(t, "rx prepare sound with MINI ROBO modulation")
- {
- mod = PHY_MOD_MINI_ROBO;
- pb_size = PHY_PB_SIZE_136;
- gil = PHY_GIL_567;
-
- phy_rx_prepare_sound (ctx, 0,
- PHY_COMBO_PARAMS (mod, fecrate, pb_size), gil,
- symbol_nb);
- test_fail_unless ((EINVAL != errno)
- && !ctx->control.rx_param.short_ppdu
- && (mod == ctx->control.rx_param.mod)
- && (PHY_FEC_RATE_1_2 == ctx->control.rx_param.fecrate)
- && (PHY_PB_SIZE_136 == ctx->control.rx_param.pb_size)
- && (PHY_GIL_567 == ctx->control.rx_param.gil)
- && (0 == ctx->control.rx_param.tonemap_index)
- && (symbol_nb == ctx->control.rx_param.symbol_nb)
- && ctx->control.rx_prepared
- && (0 == ctx->pbdma.index_current_pb));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "rx phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_RX == phy_hdr->type);
- test_fail_unless (ctx->control.rx_param.src_tx_id == ntohs(phy_hdr->tx_id));
-
- // read source station ID
- test_fail_unless (sizeof(uint16_t) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint16_t)));
-
- // check phy data
- test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), &ctx->control.rx_param.src_station_id, sizeof(uint16_t)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- return;
-}
-
-void phy_rx_fc10_test_case(test_t t)
-{
- printf("rx fc10\n");
- test_case_begin(t, "rx fc10");
-
- test_begin(t, "rx fc10")
- {
- u32 fc_10 = phy_rx_fc10 (ctx);
- test_fail_unless ((EINVAL != errno)
- && (fc_10 == ctx->control.rx_param.fc_10));
- } test_end;
-
- return;
-}
-
-void phy_rx_sysdate_test_case(test_t t)
-{
- printf("rx sysdate\n");
- test_case_begin(t, "rx sysdate");
-
- test_begin(t, "rx sysdate")
- {
- u32 sysdate = phy_rx_sysdate (ctx);
- test_fail_unless ((EINVAL != errno)
- && (sysdate == ctx->control.rx_param.preamble_start_date));
- } test_end;
-
- return;
-}
-
-void phy_extra_timer_init_test_case(test_t t)
-{
- printf("extra timer init\n");
- test_case_begin(t, "extra timer init");
-
- test_begin(t, "extra timer init")
- {
- unsigned long extra_timer_user_data = 6543210;
- phy_extra_timer_init (ctx,
- (void*)&extra_timer_user_data,
- &phy_extra_timer_cb);
- test_fail_unless ((EINVAL != errno)
- && ((void*)&extra_timer_user_data == ctx->control.extra_timer_user_data)
- && (&phy_extra_timer_cb == ctx->control.extra_timer_cb));
- } test_end;
-
- return;
-}
-
-void phy_extra_timer_program_test_case(test_t t)
-{
- u32 date = 1234567899;
- netclock_id_t id = 0;
-
- printf("extra timer program\n");
- test_case_begin(t, "extra timer program");
-
- phy_extra_timer_program (ctx, date);
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'phy_extra_timer_cancel'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->control.extra_timer_program_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // test the callback
- test_begin(t, "maximus extra timer cb")
- {
- maximus_phy_extra_timer_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PHY))
- && (ctx->control.current_cb == ctx->control.extra_timer_cb));
- } test_end;
-
- test_begin(t, "extra timer cb")
- {
- test_fail_unless ((NULL != ctx->control.extra_timer_cb)
- && ((*ctx->control.extra_timer_cb)(ctx->control.extra_timer_user_data)));
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
- } test_end;
-
- id = ctx->control.extra_timer_program_netclock_id;
- phy_extra_timer_program (ctx, date+1);
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "cancel netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "program netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date+1 == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'phy_access_timer_cancel'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->control.extra_timer_program_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- return;
-}
-
-void phy_extra_timer_cancel_test_case(test_t t)
-{
- netclock_id_t id = 0;
-
- printf("extra timer cancel\n");
- test_case_begin(t, "extra timer cancel");
-
- test_begin(t, "extra timer cancel")
- {
- id = ctx->control.extra_timer_program_netclock_id;
- phy_extra_timer_cancel (ctx);
- test_fail_unless ((EINVAL != errno)
- && (0 == ctx->control.extra_timer_program_netclock_id));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- return;
-}
-
-void maximus_phy_schedule_tick_test_case(test_t t)
-{
- u32 date, tick_high;
-
- printf("schedule tick\n");
- test_case_begin(t, "schedule tick");
-
- test_begin(t, "date now")
- {
- my_station.current_tick_tck = 0x00001234LL;
- date = 0x00001234;
- tick_high = my_station.current_tick_tck >> 32;
- test_fail_unless (((((tick_t)tick_high << 32) | (tick_t)date) == maximus_phy_schedule_tick(date))
- && (EINVAL != errno));
- } test_end;
-
- test_begin(t, "date in the future")
- {
- my_station.current_tick_tck = 0xFFFFFFFF00001234LL;
- date = 0xF0001233;
- tick_high = my_station.current_tick_tck >> 32;
- test_fail_unless (((((tick_t)tick_high << 32) | (tick_t)date) == maximus_phy_schedule_tick(date))
- && (EINVAL != errno));
-
- my_station.current_tick_tck = 0xFFFF1234LL;
- date = 0xFFFF2222;
- tick_high = my_station.current_tick_tck >> 32;
- test_fail_unless (((((tick_t)tick_high << 32) | (tick_t)date) == maximus_phy_schedule_tick(date))
- && (EINVAL != errno));
- } test_end;
-
- test_begin(t, "date after rollover")
- {
- my_station.current_tick_tck = 0x0000000412341234LL;
- date = 0x02341233;
- tick_high = my_station.current_tick_tck >> 32;
- test_fail_unless (((((tick_t)(tick_high+1) << 32) | (tick_t)date) == maximus_phy_schedule_tick(date))
- && (EINVAL != errno));
-
- my_station.current_tick_tck = 0x12341234LL;
- date = 0x00001234;
- tick_high = my_station.current_tick_tck >> 32;
- test_fail_unless (((((tick_t)(tick_high+1) << 32) | (tick_t)date) == maximus_phy_schedule_tick(date))
- && (EINVAL != errno));
-
- my_station.current_tick_tck = 0x00000000FFFFB1E0LL;
- date = 20000;
- test_fail_unless ((0x0000000100004E20LL == maximus_phy_schedule_tick(date))
- && (EINVAL != errno));
- } test_end;
-
- test_begin(t, "date in the past")
- {
- dbg_fatal_try_begin
- {
- my_station.current_tick_tck = 0x12341234LL;
- date = 0x12341233;
- test_fail_unless (((tick_t)-1 == maximus_phy_schedule_tick(date))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("date in the past\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
-
- dbg_fatal_try_begin
- {
- my_station.current_tick_tck = 0x0000FFFF12341234LL;
- date = 0x02341234;
- test_fail_unless (((tick_t)-1 == maximus_phy_schedule_tick(date))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("date in the past\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
-
- dbg_fatal_try_begin
- {
- my_station.current_tick_tck = 0x0000000100000010LL;
- date = 0xFFFFFFF0;
- test_fail_unless (((tick_t)-1 == maximus_phy_schedule_tick(date))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("date in the past\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
-
- dbg_fatal_try_begin
- {
- my_station.current_tick_tck = 0xFFFFFFFF00001234LL;
- date = 0xFFFF0000;
- test_fail_unless (((tick_t)-1 == maximus_phy_schedule_tick(date))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("date in the past\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
- } test_end;
-
- return;
-}
-
-void phy_ctrl_test_suite(test_t t)
-{
- // reset errno
- errno = 0;
-
- 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;
-
- test_suite_begin(t, "phy control");
- trace_init();
- phy_init_test_case(t);
- phy_zero_cross_init_test_case(t);
- maximus_phy_get_medium_state_test_case(t);
- maximus_phy_fill_hdr_test_case(t);
- maximus_phy_recv_test_case(t);
- phy_deferred_schedule_test_case (t);
- phy_date_test_case(t);
- phy_seed_test_case(t);
- phy_tx_fc10_test_case(t);
- phy_tx_param_test_case(t);
- phy_tx_frame_test_case(t);
- maximus_phy_send_test_case(t);
- phy_tx_param_sound_test_case(t);
- maximus_phy_tx_frame_sound_test_case(t);
- phy_rx_param_test_case(t);
- phy_rx_activate_test_case(t);
- phy_rx_prepare_test_case(t);
- phy_rx_prepare_sound_test_case(t);
- maximus_phy_recv_mpdu_payload_sound_test_case(t);
- phy_rx_fc10_test_case(t);
- phy_rx_sysdate_test_case(t);
- phy_extra_timer_init_test_case(t);
- phy_extra_timer_program_test_case(t);
- phy_extra_timer_cancel_test_case(t);
- maximus_phy_schedule_tick_test_case(t);
-#if CONFIG_TRACE
- printf("BEGIN_TRACE\n");
- trace_buffer_dbg_dump(&ctx->trace);
- printf("END_TRACE\n");
-#endif
- phy_reset_test_case(t);
- phy_uninit_test_case(t);
- trace_uninit();
-
- station_down (&my_station);
-}
diff --git a/cesar/hal/phy/maximus/test/src/test_phy_maximus.c b/cesar/hal/phy/maximus/test/src/test_phy_maximus.c
deleted file mode 100644
index c898ecd70e..0000000000
--- a/cesar/hal/phy/maximus/test/src/test_phy_maximus.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/phy/maximus/test/src/test_phy_maximus.c
- * \brief HAL Phy main test function for Maximus.
- * \ingroup hal_phy_maximus
- */
-
-#include "common/std.h"
-#include "lib/test.h"
-#include "host/station/station.h"
-#include <unistd.h> // for 'open()' and 'close()'
-#include <fcntl.h> // for 'open()' and 'close()'
-
-void bridgedma_test_suite (test_t t);
-void pbdma_test_suite (test_t t);
-void phy_access_test_suite (test_t t);
-void phy_ctrl_test_suite (test_t t);
-void tmdma_test_suite (test_t t);
-void aes_test_suite (test_t t);
-
-uint32_t maximus_pending_isrs;
-station_ctx_t my_station;
-
-bool phy_rx_fc_cb (void *user, u32 rx_date, const u32 *fc_av)
-{
- return true;
-}
-
-bool phy_access_cb (void *user)
-{
- return true;
-}
-
-bool phy_access_conf_cb (void *user)
-{
- return true;
-}
-
-bool phy_pbdma_cb (void *user, u32 status_word)
-{
- return true;
-}
-
-bool phy_tx_false_alarm_cb (void *user)
-{
- return true;
-}
-
-bool phy_zero_cross_cb (void *user, const u32 zero_cross_date)
-{
- return true;
-}
-
-void phy_deferred_cb (void *user)
-{
- return;
-}
-
-bool phy_extra_timer_cb (void *user)
-{
- return true;
-}
-
-int
-maximus_phy_open (station_ctx_t *station)
-{
- int fd;
-
- #ifdef STATION_SOCK
- fd = station->sock_pair_fd;
- #else /* STATION_SOCK */
- fd = open(station->pipe_out_name, O_RDONLY);
- #endif /* STATION_SOCK */
-
- return fd;
-}
-
-void
-maximus_phy_close (int fd)
-{
- #ifndef STATION_SOCK
- close(fd);
- #endif /* !STATION_SOCK */
-}
-
-int
-main (int argc, char **argv)
-{
- test_t t;
- test_init(t, argc, argv);
-
- pbdma_test_suite(t);
- phy_access_test_suite(t);
- phy_ctrl_test_suite(t);
- tmdma_test_suite(t);
- aes_test_suite(t);
-
- test_result(t);
- return test_nb_failed(t) == 0 ? 0 : 1;
-}
diff --git a/cesar/hal/phy/maximus/test/src/test_tmdma.c b/cesar/hal/phy/maximus/test/src/test_tmdma.c
deleted file mode 100644
index d16220da36..0000000000
--- a/cesar/hal/phy/maximus/test/src/test_tmdma.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/phy/maximus/test/src/test_tmdma.c
- * \brief HAL Phy Tone Map DMA test functions for Maximus.
- * \ingroup hal_phy_maximus
- */
-
-#include "common/std.h"
-#include "lib/test.h"
-#include "lib/trace.h"
-#include "maximus/common/types/phy_types.h"
-#include "hal/phy/forward.h"
-#include "host/fwd.h"
-#include "hal/phy/maximus/inc/maximus_phy_ctx.h"
-#include "hal/phy/maximus/test/inc/test_phy_maximus.h"
-#include "mac/common/defs.h" // for 'MAC_PB520_BYTES'
-#include <stdio.h> // for 'printf'
-#include <string.h> // for 'memset'
-#include <unistd.h> // for 'read'
-#include <fcntl.h> // for 'read'
-#include <errno.h>
-
-phy_t *ctx;
-
-void phy_set_tonemask_test_case(test_t t)
-{
- printf("set tonemask\n");
- test_case_begin(t, "set tonemask");
-
- uint carrier_nb = PHY_CARRIER_NB;
- u8 tonemask[(PHY_CARRIER_NB+7)/8]; // 1 bit per carrier
- memset(tonemask, 'a', ((PHY_CARRIER_NB+7)/8)*sizeof(u8));
-
- test_begin(t, "set tonemask")
- {
- phy_set_tonemask(ctx, (u32 *)tonemask, carrier_nb);
- test_fail_unless ((EINVAL != errno)
- && (carrier_nb == ctx->tmdma.carrier_nb)
- && (0 == memcmp(tonemask, ctx->tmdma.tonemask, (PHY_CARRIER_NB+7)/8)));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "tonemask phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_TONEMASK == phy_hdr->type);
- test_fail_unless (0 == phy_hdr->tx_id);
-
- // read the remaining part of message
- test_fail_unless (sizeof(uint) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint)));
- test_fail_unless ((PHY_CARRIER_NB+7)/8 == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+sizeof(uint), (PHY_CARRIER_NB+7)/8));
-
- // check phy data
- test_fail_unless (0 == memcmp(&carrier_nb, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint)));
- test_fail_unless (0 == memcmp(tonemask, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+sizeof(uint), (PHY_CARRIER_NB+7)/8));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-}
-
-void phy_set_tonemap_test_case(test_t t)
-{
- printf("set tonemap\n");
- test_case_begin(t, "set tonemap");
-
- test_begin(t, "set tonemap")
- {
- blk_t tonemap1;
- blk_t tonemap2;
- u8 tonemap1_data[MAC_PB520_BYTES];
- u8 tonemap2_data[(PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES]; // 4 bits per carrier
- uint tonemap_index = 0;
-
- memset(tonemap1_data, 'b', MAC_PB520_BYTES*sizeof(u8));
- memset(tonemap2_data, 'c', ((PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES)*sizeof(u8));
- tonemap2.next = NULL;
- tonemap2.data = tonemap2_data;
- tonemap1.next = &tonemap2;
- tonemap1.data = tonemap1_data;
-
- phy_set_tonemap (ctx, &tonemap1);
- test_fail_unless ((EINVAL != errno)
- && (0 == memcmp(tonemap1.data, ctx->tmdma.tonemap[tonemap_index]->data, MAC_PB520_BYTES))
- && (0 == memcmp(tonemap2.data, ctx->tmdma.tonemap[tonemap_index]->next->data, (PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES)));
- } test_end;
-}
-
-void tmdma_test_suite(test_t t)
-{
- int user_data = 1234567890;
-
- // reset errno
- errno = 0;
-
- 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;
- trace_init();
- ctx = phy_init ((void*)&user_data,
- &phy_rx_fc_cb,
- &phy_access_cb,
- &phy_access_conf_cb,
- &phy_pbdma_cb,
- &phy_tx_false_alarm_cb,
- &phy_deferred_cb);
- ctx->warning_assert = true;
-
- test_suite_begin(t, "tonemap dma");
- phy_set_tonemask_test_case(t);
- phy_set_tonemap_test_case(t);
-
-#if CONFIG_TRACE
- printf("BEGIN_TRACE\n");
- trace_buffer_dbg_dump(&ctx->trace);
- printf("END_TRACE\n");
-#endif
- phy_uninit (ctx);
- trace_uninit();
- station_down (&my_station);
-}
diff --git a/cesar/hal/phy/test/phy/src/test_phy.c b/cesar/hal/phy/test/phy/src/test_phy.c
index 8e9012b454..5e7757580e 100644
--- a/cesar/hal/phy/test/phy/src/test_phy.c
+++ b/cesar/hal/phy/test/phy/src/test_phy.c
@@ -694,11 +694,6 @@ cyg_user_start (void)
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;
- //my_station.log_level = STATION_LOG_DEBUG;
- //my_station.log_mask = STATION_LOGTYPE_FCALL;
-#endif
trace_init ();
test_phy_init (&test_phy_global);
}