<commit_before>/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright(c) 2016-2017 Intel Corporation
 */

#include <rte_memcpy.h>
#include <rte_malloc.h>
#include <rte_efd.h>
#include <rte_byteorder.h>
#include <rte_random.h>
#include <rte_debug.h>
#include <rte_ip.h>

#include "test.h"

#define EFD_TEST_KEY_LEN 8
#define TABLE_SIZE (1 << 21)
#define ITERATIONS 3

#if RTE_EFD_VALUE_NUM_BITS == 32
#define VALUE_BITMASK 0xffffffff
#else
#define VALUE_BITMASK ((1 << RTE_EFD_VALUE_NUM_BITS) - 1)
#endif
static unsigned int test_socket_id;

/* 5-tuple key type */
struct flow_key {
	uint32_t ip_src;
	uint32_t ip_dst;
	uint16_t port_src;
	uint16_t port_dst;
	uint8_t proto;
} __attribute__((packed));
/*
 * Print out result of unit test efd operation.
 */
#if defined(UNIT_TEST_EFD_VERBOSE)

static void print_key_info(const char *msg, const struct flow_key *key,
		efd_value_t val)
{
	const uint8_t *p = (const uint8_t *) key;
	unsigned int i;

	printf("%s key:0x", msg);
	for (i = 0; i < sizeof(struct flow_key); i++)
		printf("%02X", p[i]);

	printf(" @ val %d\n", val);
}
#else

static void print_key_info(__attribute__((unused)) const char *msg,
		__attribute__((unused)) const struct flow_key *key,
		__attribute__((unused)) efd_value_t val)
{
}
#endif

/* Keys used by unit test functions */
static struct flow_key keys[5] = {
	{
		.ip_src = IPv4(0x03, 0x02, 0x01, 0x00),
		.ip_dst = IPv4(0x07, 0x06, 0x05, 0x04),
		.port_src = 0x0908,
		.port_dst = 0x0b0a,<commit_msg>test/efd: replace config macro with runtime log level<commit_after>/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright(c) 2016-2017 Intel Corporation
 */

#include <rte_memcpy.h>
#include <rte_malloc.h>
#include <rte_efd.h>
#include <rte_byteorder.h>
#include <rte_random.h>
#include <rte_debug.h>
#include <rte_ip.h>

#include "test.h"

#define EFD_TEST_KEY_LEN 8
#define TABLE_SIZE (1 << 21)
#define ITERATIONS 3

#if RTE_EFD_VALUE_NUM_BITS == 32
#define VALUE_BITMASK 0xffffffff
#else
#define VALUE_BITMASK ((1 << RTE_EFD_VALUE_NUM_BITS) - 1)
#endif
static unsigned int test_socket_id;

/* 5-tuple key type */
struct flow_key {
	uint32_t ip_src;
	uint32_t ip_dst;
	uint16_t port_src;
	uint16_t port_dst;
	uint8_t proto;
} __attribute__((packed));

int efd_logtype_test;

RTE_INIT(test_efd_init_log)
{
	efd_logtype_test = rte_log_register("test.efd");
}

/*
 * Print out result of unit test efd operation.
 */
static void print_key_info(const char *msg, const struct flow_key *key,
		efd_value_t val)
{
	const uint8_t *p = (const uint8_t *) key;
	unsigned int i;

	rte_log(RTE_LOG_DEBUG, efd_logtype_test, "%s key:0x", msg);
	for (i = 0; i < sizeof(struct flow_key); i++)
		rte_log(RTE_LOG_DEBUG, efd_logtype_test, "%02X", p[i]);

	rte_log(RTE_LOG_DEBUG, efd_logtype_test, " @ val %d\n", val);
}

/* Keys used by unit test functions */
static struct flow_key keys[5] = {
	{
		.ip_src = IPv4(0x03, 0x02, 0x01, 0x00),
		.ip_dst = IPv4(0x07, 0x06, 0x05, 0x04),
		.port_src = 0x0908,
		.port_dst = 0x0b0a,
{'fraction_non_alphanumeric': 0.1325503355704698, 'fraction_numerical': 0.04697986577181208, 'mean_word_length': 4.891304347826087, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '2441443', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1264, 'n_words': 302}