#include <rte_random.h>
#include <rte_memory.h>
#include <rte_memzone.h>
-#include <rte_hash.h>
-#include <rte_hash_crc.h>
-#include <rte_jhash.h>
#include <rte_tailq.h>
#include <rte_eal.h>
-#include <rte_fbk_hash.h>
#include <rte_ip.h>
#include <rte_string_fns.h>
+#include <rte_hash.h>
+#include <rte_fbk_hash.h>
+#include <rte_jhash.h>
+
+#ifdef RTE_MACHINE_CPUFLAG_SSE4_2
+#include <rte_hash_crc.h>
+#endif
#include <cmdline_parse.h>
#include "test.h"
#if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH)
#include <rte_hash.h>
-#include <rte_hash_crc.h>
-#include <rte_jhash.h>
#elif (APP_LOOKUP_METHOD == APP_LOOKUP_LPM)
#include <rte_lpm.h>
#else
#if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH)
+
+#ifdef RTE_MACHINE_CPUFLAG_SSE4_2
+#include <rte_hash_crc.h>
+#define DEFAULT_HASH_FUNC rte_hash_crc
+#else
+#include <rte_jhash.h>
+#define DEFAULT_HASH_FUNC rte_jhash
+#endif
+
struct ipv4_5tuple {
uint32_t ip_dst;
uint32_t ip_src;
.entries = L3FWD_HASH_ENTRIES,
.bucket_entries = 4,
.key_len = sizeof(struct ipv4_5tuple),
- .hash_func = rte_hash_crc,
+ .hash_func = DEFAULT_HASH_FUNC,
.hash_func_init_val = 0,
.socket_id = SOCKET0,
};
#if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH)
#include <rte_hash.h>
-#include <rte_hash_crc.h>
-#include <rte_jhash.h>
#elif (APP_LOOKUP_METHOD == APP_LOOKUP_LPM)
#include <rte_lpm.h>
#else
#if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH)
+
+#ifdef RTE_MACHINE_CPUFLAG_SSE4_2
+#include <rte_hash_crc.h>
+#define DEFAULT_HASH_FUNC rte_hash_crc
+#else
+#include <rte_jhash.h>
+#define DEFAULT_HASH_FUNC rte_jhash
+#endif
+
struct ipv4_5tuple {
uint32_t ip_dst;
uint32_t ip_src;
#include <rte_memzone.h>
#include <rte_tailq.h>
#include <rte_eal.h>
-#include <rte_hash_crc.h>
#include <rte_eal_memconfig.h>
#include <rte_malloc.h>
#include <rte_common.h>
#include <rte_log.h>
#include "rte_fbk_hash.h"
-#include "rte_jhash.h"
-#include "rte_hash_crc.h"
TAILQ_HEAD(rte_fbk_hash_list, rte_fbk_hash_table);
ht->init_val = RTE_FBK_HASH_INIT_VAL_DEFAULT;
}
- if (ht->hash_func == rte_hash_crc_4byte &&
- !rte_cpu_get_flag_enabled(RTE_CPUFLAG_SSE4_2)) {
- RTE_LOG(WARNING, HASH, "CRC32 instruction requires SSE4.2, "
- "which is not supported on this system. "
- "Falling back to software hash\n.");
- ht->hash_func = rte_jhash_1word;
- }
-
TAILQ_INSERT_TAIL(fbk_hash_list, ht, next);
return ht;
}
#include <stdint.h>
#include <errno.h>
#include <sys/queue.h>
-#include <rte_hash_crc.h>
#ifdef __cplusplus
extern "C" {
#include <string.h>
#ifndef RTE_FBK_HASH_FUNC_DEFAULT
+#ifdef RTE_MACHINE_CPUFLAG_SSE4_2
+#include <rte_hash_crc.h>
/** Default four-byte key hash function if none is specified. */
#define RTE_FBK_HASH_FUNC_DEFAULT rte_hash_crc_4byte
+#else
+#include <rte_jhash.h>
+#define RTE_FBK_HASH_FUNC_DEFAULT rte_jhash_1word
+#endif
#endif
#ifndef RTE_FBK_HASH_INIT_VAL_DEFAULT
uint16_t value; /**< Value returned by lookup. */
uint32_t key; /**< Key used to find value. */
} entry; /**< For accessing each entry part. */
-} ;
+};
}
}
- return -ENOSPC; /* No space in bucket. */
+ return -ENOSPC; /* No space in bucket. */
}
/**
#include <rte_log.h>
#include "rte_hash.h"
-#include "rte_jhash.h"
-#include "rte_hash_crc.h"
TAILQ_HEAD(rte_hash_list, rte_hash);
#endif
/* Hash function used if none is specified */
+#ifdef RTE_MACHINE_CPUFLAG_SSE4_2
+#include <rte_hash_crc.h>
#define DEFAULT_HASH_FUNC rte_hash_crc
+#else
+#include <rte_jhash.h>
+#define DEFAULT_HASH_FUNC rte_jhash
+#endif
/* Signature bucket size is a multiple of this value */
#define SIG_BUCKET_ALIGNMENT 16
h->hash_func = (params->hash_func == NULL) ?
DEFAULT_HASH_FUNC : params->hash_func;
- if (h->hash_func == rte_hash_crc &&
- !rte_cpu_get_flag_enabled(RTE_CPUFLAG_SSE4_2)) {
- RTE_LOG(WARNING, HASH, "CRC32 instruction requires SSE4.2, "
- "which is not supported on this system. "
- "Falling back to software hash\n.");
- h->hash_func = rte_jhash;
- }
-
TAILQ_INSERT_TAIL(hash_list, h, next);
return h;
}