<commit_before>/*
 * Copyright 2015, International Business Machines
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @file	genwqe_echo.c
 * @brief	FPGA accelerator SW utility.
 *
 * This utility sends ECHO-DDCBs to the Service Layer Unit (SLU) or an
 * chip application unit (or AFU), waits for completion and checks if
 * the teststring is correctly returned.
 */

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <time.h>
#include <signal.h>
#include <sys/time.h>
#include <asm/byteorder.h>

#include <sched.h>

#include "genwqe_tools.h"
#include "force_cpu.h"
#include "libddcb.h"

#define timediff_usec(t0, t1)						\
	((double)(((t0)->tv_sec * 1000000 + (t0)->tv_usec) -		\
		  ((t1)->tv_sec * 1000000 + (t1)->tv_usec)))

int verbose_flag = 0;

static const char *version = GIT_VERSION;
const char *tstring_default = "ABCDEF_echo test [123456789abcde]";

/**
 * @brief	prints valid command line options
 *
 * @param prog	current program's name
 */
static void usage(const char *prog)
{
	printf("Usage: %s [OPTIONS]\n"
	       "  -h, --help\n"
	       "  -v, --verbose\n"
	       "  -C, --card=CARDNO|RED  Note: RED is for Card Redundant mode\n"
	       "  -A, --accelerator-type=GENWQE|CAPI CAPI is only available "
	       "for System p\n"
	       "  -q, --quiet            quiece output\n"
	       "  -V, --version\n"
	       "  -H, --hardware-version\n"
	       "  -c, --count=COUNT\n"
	       "  -X, --cpu=CPU          only run on this CPU number\n"
	       "  -D, --debug            create extended debug data on failure\n"
#if defined (CONFIG_BUILD_4TEST)
	       "  -u, --unitid=0:service layer|1:APP\n"
#endif
	       "  -e, --exit-on-err      exit program when seeing an error\n"
	       "  -f, --flood\n"
	       "  -l, --preload=1..N     N <= 64\n"
	       "  -i, --interval=INTERVAL_USEC\n"
	       "  -s, --string=TESTSTRING\n"
	       "  -p, --polling          use DDCB polling mode.\n"
	       "  -q, --quiet            only summary output\n"
	       "\n"
	       "This utility sends echo DDCBs either to the service layer\n"
	       "or other chip units. It can be used to check the cards\n"
	       "health and/or to produce stress on the card to verify its\n"
	       "correct function.\n\n", prog);
}

static void INT_handler(int sig);
static int stop_echoing = 0;

static void INT_handler(int sig)
{
	signal(sig, SIG_IGN);
	stop_echoing = 1;
	/* signal(SIGINT, INT_handler); *//* Try again */
}

/**
 * @brief		prepare data to be send via ECHO-DDCB.
 *			clear receive part.
 *			SLU allows 64 bytes to be echoed.
 *
 * @param tstring	test string to be send to SLU
 * @param acfunc	Unit-ID in HW: 0=SLU, 1=APP
 * @param cmd		command definitions and return values<commit_msg>Bug 155158 Remove double option -q from Help.<commit_after>/*
 * Copyright 2015, International Business Machines
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @file	genwqe_echo.c
 * @brief	FPGA accelerator SW utility.
 *
 * This utility sends ECHO-DDCBs to the Service Layer Unit (SLU) or an
 * chip application unit (or AFU), waits for completion and checks if
 * the teststring is correctly returned.
 */

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <time.h>
#include <signal.h>
#include <sys/time.h>
#include <asm/byteorder.h>

#include <sched.h>

#include "genwqe_tools.h"
#include "force_cpu.h"
#include "libddcb.h"

#define timediff_usec(t0, t1)						\
	((double)(((t0)->tv_sec * 1000000 + (t0)->tv_usec) -		\
		  ((t1)->tv_sec * 1000000 + (t1)->tv_usec)))

int verbose_flag = 0;

static const char *version = GIT_VERSION;
const char *tstring_default = "ABCDEF_echo test [123456789abcde]";

/**
 * @brief	prints valid command line options
 *
 * @param prog	current program's name
 */
static void usage(const char *prog)
{
	printf("Usage: %s [OPTIONS]\n"
	       "  -h, --help\n"
	       "  -v, --verbose\n"
	       "  -C, --card=CARDNO|RED  Note: RED is for Card Redundant mode\n"
	       "  -A, --accelerator-type=GENWQE|CAPI CAPI is only available "
	       "for System p\n"
	       "  -q, --quiet            quiece output\n"
	       "  -V, --version\n"
	       "  -H, --hardware-version\n"
	       "  -c, --count=COUNT\n"
	       "  -X, --cpu=CPU          only run on this CPU number\n"
	       "  -D, --debug            create extended debug data on failure\n"
#if defined (CONFIG_BUILD_4TEST)
	       "  -u, --unitid=0:service layer|1:APP\n"
#endif
	       "  -e, --exit-on-err      exit program when seeing an error\n"
	       "  -f, --flood\n"
	       "  -l, --preload=1..N     N <= 64\n"
	       "  -i, --interval=INTERVAL_USEC\n"
	       "  -s, --string=TESTSTRING\n"
	       "  -p, --polling          use DDCB polling mode.\n"
	       "\n"
	       "This utility sends echo DDCBs either to the service layer\n"
	       "or other chip units. It can be used to check the cards\n"
	       "health and/or to produce stress on the card to verify its\n"
	       "correct function.\n\n", prog);
}

static void INT_handler(int sig);
static int stop_echoing = 0;

static void INT_handler(int sig)
{
	signal(sig, SIG_IGN);
	stop_echoing = 1;
	/* signal(SIGINT, INT_handler); *//* Try again */
}

/**
 * @brief		prepare data to be send via ECHO-DDCB.
 *			clear receive part.
 *			SLU allows 64 bytes to be echoed.
 *
 * @param tstring	test string to be send to SLU
 * @param acfunc	Unit-ID in HW: 0=SLU, 1=APP
 * @param cmd		command definitions and return values
{'fraction_non_alphanumeric': 0.12759735262428815, 'fraction_numerical': 0.016315222410343236, 'mean_word_length': 2.566410537870472, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3176303', 'n_tokens_mistral': 2376, 'n_tokens_neox': 2193, 'n_words': 735}