2016-06-14 01:19:17 +02:00
|
|
|
/** VILLASfpga utility for tests and benchmarks
|
|
|
|
*
|
|
|
|
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
|
|
|
* @copyright 2015-2016, Steffen Vogel
|
|
|
|
* This file is part of VILLASnode. All Rights Reserved. Proprietary and confidential.
|
|
|
|
* Unauthorized copying of this file, via any medium is strictly prohibited.
|
|
|
|
**********************************************************************************/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
2016-06-15 20:05:09 +02:00
|
|
|
#include <string.h>
|
2016-06-14 01:19:17 +02:00
|
|
|
#include <errno.h>
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <sched.h>
|
|
|
|
|
|
|
|
#include <villas/log.h>
|
2016-06-26 15:33:19 +02:00
|
|
|
#include <villas/cfg.h>
|
2016-06-14 01:19:17 +02:00
|
|
|
#include <villas/timing.h>
|
|
|
|
#include <villas/utils.h>
|
2016-06-19 19:23:19 +02:00
|
|
|
#include <villas/nodes/fpga.h>
|
2016-06-26 15:27:14 +02:00
|
|
|
#include <villas/kernel/rt.h>
|
2016-06-14 01:19:17 +02:00
|
|
|
#include <villas/kernel/pci.h>
|
|
|
|
#include <villas/kernel/kernel.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2016-06-15 20:05:09 +02:00
|
|
|
/* Declarations */
|
2016-06-26 15:33:19 +02:00
|
|
|
int fpga_benchmarks(int argc, char *argv[], struct fpga *f);
|
|
|
|
int fpga_tests(int argc, char *argv[], struct fpga *f);
|
|
|
|
|
|
|
|
struct settings settings;
|
2016-06-14 01:19:17 +02:00
|
|
|
|
|
|
|
void usage(char *name)
|
|
|
|
{
|
2016-06-15 20:05:09 +02:00
|
|
|
printf("Usage: %s CONFIGFILE CMD [OPTIONS]\n", name);
|
|
|
|
printf(" Commands:\n");
|
2016-06-26 15:33:19 +02:00
|
|
|
printf(" tests Test functionality of VILLASfpga card\n");
|
|
|
|
printf(" benchmarks Do benchmarks\n\n");
|
2016-06-15 20:05:09 +02:00
|
|
|
printf(" Options:\n");
|
|
|
|
printf(" -d Set log level\n\n");
|
|
|
|
|
|
|
|
print_copyright();
|
|
|
|
|
|
|
|
exit(EXIT_FAILURE);
|
2016-06-14 01:19:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int ret;
|
2016-06-19 19:23:19 +02:00
|
|
|
struct fpga *fpga;
|
2016-06-26 15:33:19 +02:00
|
|
|
config_t config;
|
|
|
|
|
2016-06-15 20:05:09 +02:00
|
|
|
enum {
|
|
|
|
FPGA_TESTS,
|
|
|
|
FPGA_BENCH
|
|
|
|
} subcommand;
|
2016-06-26 15:33:19 +02:00
|
|
|
|
2016-06-15 20:05:09 +02:00
|
|
|
if (argc < 3)
|
|
|
|
usage(argv[0]);
|
|
|
|
if (strcmp(argv[2], "tests") == 0)
|
|
|
|
subcommand = FPGA_TESTS;
|
2016-06-26 15:33:19 +02:00
|
|
|
else if (strcmp(argv[2], "benchmarks") == 0)
|
2016-06-15 20:05:09 +02:00
|
|
|
subcommand = FPGA_BENCH;
|
|
|
|
else
|
|
|
|
usage(argv[0]);
|
|
|
|
|
2016-06-14 01:19:17 +02:00
|
|
|
/* Parse arguments */
|
|
|
|
char c, *endptr;
|
2016-06-26 15:33:19 +02:00
|
|
|
while ((c = getopt(argc-1, argv+1, "d:")) != -1) {
|
2016-06-14 01:19:17 +02:00
|
|
|
switch (c) {
|
|
|
|
case 'd':
|
|
|
|
log_setlevel(strtoul(optarg, &endptr, 10), ~0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '?':
|
|
|
|
default:
|
|
|
|
usage(argv[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-26 15:33:19 +02:00
|
|
|
info("Parsing configuration");
|
2016-07-14 09:47:00 +02:00
|
|
|
cfg_parse(argv[1], &config, &settings, NULL, NULL);
|
2016-06-26 15:33:19 +02:00
|
|
|
|
2016-06-26 15:27:14 +02:00
|
|
|
info("Initialize real-time system");
|
|
|
|
rt_init(settings.affinity, settings.priority);
|
|
|
|
|
2016-06-15 20:05:09 +02:00
|
|
|
/* Initialize VILLASfpga card */
|
|
|
|
config_setting_t *cfg_root = config_root_setting(&config);
|
2016-06-19 19:23:19 +02:00
|
|
|
ret = fpga_init(argc, argv, cfg_root);
|
2016-06-14 01:19:17 +02:00
|
|
|
if (ret)
|
2016-06-26 15:33:19 +02:00
|
|
|
error("Failed to initialize FPGA card");
|
2016-06-15 20:05:09 +02:00
|
|
|
|
2016-06-19 19:23:19 +02:00
|
|
|
fpga = fpga_get();
|
|
|
|
fpga_dump(fpga);
|
2016-06-14 01:19:17 +02:00
|
|
|
|
2016-06-15 20:05:09 +02:00
|
|
|
/* Start subcommand */
|
|
|
|
switch (subcommand) {
|
2016-06-26 15:33:19 +02:00
|
|
|
case FPGA_TESTS: fpga_tests(argc-optind-1, argv+optind+1, fpga); break;
|
|
|
|
case FPGA_BENCH: fpga_benchmarks(argc-optind-1, argv+optind+1, fpga); break;
|
2016-06-15 20:05:09 +02:00
|
|
|
}
|
2016-06-14 01:19:17 +02:00
|
|
|
|
|
|
|
/* Shutdown */
|
2016-06-19 19:23:19 +02:00
|
|
|
ret = fpga_deinit(&fpga);
|
2016-06-14 01:19:17 +02:00
|
|
|
if (ret)
|
|
|
|
error("Failed to de-initialize fpga card");
|
2016-07-14 09:47:00 +02:00
|
|
|
|
|
|
|
cfg_destroy(&config);
|
2016-06-14 01:19:17 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|