summaryrefslogtreecommitdiff
path: root/ce/test/rx/maximus/src/test_rx.c
diff options
context:
space:
mode:
Diffstat (limited to 'ce/test/rx/maximus/src/test_rx.c')
-rw-r--r--ce/test/rx/maximus/src/test_rx.c188
1 files changed, 188 insertions, 0 deletions
diff --git a/ce/test/rx/maximus/src/test_rx.c b/ce/test/rx/maximus/src/test_rx.c
new file mode 100644
index 0000000000..6a5c82f6fd
--- /dev/null
+++ b/ce/test/rx/maximus/src/test_rx.c
@@ -0,0 +1,188 @@
+#include <cyg/infra/diag.h>
+#include "common/std.h"
+#include "host/station.h"
+#include "mac/pbproc/pbproc.h"
+#include "mac/sar/sar.h"
+#include "cyg/kernel/kapi.h"
+#include "cyg/hal/hal_arch.h"
+#include "ce/inc/rx.h"
+#include "ce/test/common/print_utils.h"
+#define TXCE
+#include "lib/test.h"
+#include "ce/test/common/tonemap_utils.h"
+
+extern station_ctx_t my_station;
+test_t test;
+
+#define SAR_PRIORITY 14
+cyg_thread sar_thread;
+cyg_handle_t sar_handle;
+unsigned char sar_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+#define RXCE_PRIORITY 15
+cyg_thread rxce_thread;
+cyg_handle_t rxce_handle;
+unsigned char rxce_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+mac_store_t *mac_store_ctx;
+mac_config_t mac_config_ctx;
+sar_t *sar_ctx;
+sta_t *sta;
+ca_t *ca;
+rxce_t *rxce_ctx;
+
+bool
+local_sar_mpdu_measurement_cb (void *user, pbproc_rx_params_t *rx_params,
+ uint pb_nb, blk_t **f, blk_t **l, pb_t *noise)
+{
+
+ uint i,j;
+ diag_printf ("pb_nb = %d\n",pb_nb);
+ diag_printf ("noise @Ox%x\n",(unsigned int) noise);
+ phy_chandata_t *chandata = (phy_chandata_t *) noise;
+ phy_noise_t *data_noise;
+ for (i=0; i<PHY_CHANDATA_BLK_NB; i++)
+ {
+ diag_printf ("chandata%d @0x%x : type=%d size=%d last=%d\n", i,
+ (uint) chandata,
+ chandata->type,
+ chandata->size,
+ chandata->last);
+ data_noise = (phy_noise_t *) chandata->blk.data;
+ for (j=0; j<BLK_SIZE/(sizeof(phy_noise_t)); j++)
+ {
+ diag_printf ("0x%x ",*data_noise);
+ data_noise++;
+ }
+ diag_printf ("\n");
+
+ chandata = (phy_chandata_t *) chandata->blk.next;
+ }
+
+ return true;
+}
+
+void
+sar_start (void)
+{
+ pbproc_t *pbproc_ctx = pbproc_init (&mac_config_ctx, mac_store_ctx);
+ ca = blk_alloc();
+ sar_ctx = sar_init (mac_store_ctx, pbproc_ctx, ca);
+ sar_init_measure_context (sar_ctx, rxce_ctx);
+ //sar_init_measurement_cb (sar_ctx, &local_sar_mpdu_measurement_cb);
+ sar_init_measurement_cb (sar_ctx, &sar_mpdu_measurement_cb);
+ mac_store_sta_add (mac_store_ctx, 1);
+ sta = mac_store_sta_get (mac_store_ctx, 1);
+ cyg_thread_create (SAR_PRIORITY, &sar_process, (cyg_addrword_t)sar_ctx, "sar_test",
+ sar_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &sar_handle, &sar_thread);
+ cyg_thread_resume (sar_handle);
+}
+
+void
+sar_end (void)
+{
+ blk_release (sta); // release reference to sta added by mac_store_mfs_get in START.
+ dbg_check (mac_store_sta_remove (mac_store_ctx, 1));
+ blk_release(ca);
+ sar_uninit (sar_ctx);
+}
+
+void
+ce_init (void)
+{
+ rxce_ctx = rxce_init (mac_store_ctx, &mac_config_ctx);
+ cyg_thread_create (RXCE_PRIORITY, &rxce_process, (cyg_addrword_t) rxce_ctx, "rxce",
+ rxce_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &rxce_handle, &rxce_thread);
+}
+
+void
+ce_check_stock (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ unsigned short pb_nb;
+ unsigned short fm_nb;
+ uint pb_ix, fm_ix;
+
+ fcall_param_bind_short(*param, *msg, "pb_nb", &pb_nb);
+ fcall_param_bind_short(*param, *msg, "frame_nb", &fm_nb);
+
+ test_begin (test, "check pb measurement")
+ {
+ dbg_assert (fm_number == fm_nb);
+ for (fm_ix=0; fm_ix<fm_nb; fm_ix++)
+ {
+ pb_measurement_list_t *ber_blk = fm_stock[fm_ix].ber_measurement;
+ for (pb_ix=0; pb_ix<pb_nb; pb_ix++)
+ {
+ if (pb_ix == BLK_SIZE/sizeof(pb_measurement_t))
+ {
+ ber_blk = ber_blk->next;
+ }
+ pb_measurement_t m = *(ber_blk->data+(pb_ix%(BLK_SIZE/sizeof(pb_measurement_t))));
+ test_fail_if (m.halfit != 0x04);
+ test_fail_if ( m.ber != (1<< (pb_ix%16)) );
+ test_fail_if ( m.crc_error != (pb_ix%2) );
+ }
+ }
+ } test_end;
+ fcall_param_reset(*param);
+ return;
+}
+
+void
+ce_check_computation (void)
+{
+ sta_t *sta = mac_store_sta_get (mac_store_ctx, 1);
+ ce_print_tonemaps (sta->rx_tonemaps);
+ ce_print_tonemaps (sta->tx_tonemaps);
+
+ compare_tonemaps (test, sta->rx_tonemaps, sta->tx_tonemaps,
+ (u8 *)(&(mac_config_ctx.tonemask_info.tonemask)));
+ test_result (test);
+ return;
+}
+
+void
+ce_start (void)
+{
+ cyg_thread_resume (rxce_handle);
+}
+
+int
+test_result_get (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ unsigned short result;
+ result = (test_nb_failed (test));
+ fcall_param_reset(*param);
+ fcall_param_add_short(*param, *msg, "test_result", &result);
+ return (result);
+}
+
+int main(void)
+{
+ trace_init();
+ test_init (test, 0, NULL);
+ test_case_begin (test, "RXCE-maximus");
+ station_log_set_level(&my_station, STATION_LOG_NONE);
+ station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
+ my_station.pipe_log_fd = 1;
+ diag_write_string(" hello by eCos in maximus test\n");
+ fcall_register(my_station.fcall, "sar_start", (void*)&sar_start, NULL);
+ fcall_register(my_station.fcall, "ce_init", (void*)&ce_init, NULL);
+ fcall_register(my_station.fcall, "ce_check_stock", (void*)&ce_check_stock, NULL);
+ fcall_register(my_station.fcall, "ce_start", (void*)&ce_start, NULL);
+ fcall_register(my_station.fcall, "ce_check_computation", (void*)&ce_check_computation, NULL);
+ fcall_register(my_station.fcall, "prepare_rx", (void*)&prepare_rx, NULL);
+ fcall_register(my_station.fcall, "test_result_get", (void*)&test_result_get, NULL);
+
+ tonemask_default ((u8 *)(&(mac_config_ctx.tonemask_info.tonemask)));
+ //int i;
+ //for (i=0; i<(PHY_CARRIER_NB+7)/8; i++) mac_config_ctx.tonemask_info.tonemask[i] = 0xFF;
+ //mac_config_ctx.tonemask_info.tonemask[i-1] = ((1<<(PHY_CARRIER_NB%8))-1);
+
+ mac_store_ctx = mac_store_init ();
+
+ return 0;
+}
+