23 #include <rte_thash_gfni.h> 25 #if defined(RTE_ARCH_X86) || defined(__ARM_NEON) 37 static const __m128i rte_thash_ipv6_bswap_mask = {
38 0x0405060700010203ULL, 0x0C0D0E0F08090A0BULL};
45 #define RTE_THASH_V4_L3_LEN ((sizeof(struct rte_ipv4_tuple) - \ 46 sizeof(((struct rte_ipv4_tuple *)0)->sctp_tag)) / 4) 53 #define RTE_THASH_V4_L4_LEN ((sizeof(struct rte_ipv4_tuple)) / 4) 59 #define RTE_THASH_V6_L3_LEN ((sizeof(struct rte_ipv6_tuple) - \ 60 sizeof(((struct rte_ipv6_tuple *)0)->sctp_tag)) / 4) 67 #define RTE_THASH_V6_L4_LEN ((sizeof(struct rte_ipv6_tuple)) / 4) 103 union __rte_aligned(XMM_SIZE) rte_thash_tuple {
105 union rte_thash_tuple {
122 thash_get_rand_poly(uint32_t poly_degree);
138 for (i = 0; i < (len >> 2); i++)
152 union rte_thash_tuple *targ)
155 __m128i ipv6 = _mm_loadu_si128((
const __m128i *)&orig->src_addr);
156 *(__m128i *)&targ->v6.src_addr =
157 _mm_shuffle_epi8(ipv6, rte_thash_ipv6_bswap_mask);
158 ipv6 = _mm_loadu_si128((
const __m128i *)&orig->dst_addr);
159 *(__m128i *)&targ->v6.dst_addr =
160 _mm_shuffle_epi8(ipv6, rte_thash_ipv6_bswap_mask);
161 #elif defined(__ARM_NEON) 162 uint8x16_t ipv6 = vld1q_u8(orig->src_addr.a);
163 vst1q_u8(targ->v6.src_addr.a, vrev32q_u8(ipv6));
164 ipv6 = vld1q_u8(orig->dst_addr.a);
165 vst1q_u8(targ->v6.dst_addr.a, vrev32q_u8(ipv6));
168 for (i = 0; i < 4; i++) {
169 *((uint32_t *)&targ->v6.src_addr + i) =
171 *((uint32_t *)&targ->v6.dst_addr + i) =
188 static inline uint32_t
190 const uint8_t *rss_key)
192 uint32_t i, j, map, ret = 0;
194 for (j = 0; j < input_len; j++) {
195 for (map = input_tuple[j]; map; map &= (map - 1)) {
198 (uint32_t)((uint64_t)(
rte_cpu_to_be_32(((
const uint32_t *)rss_key)[j + 1])) >>
218 static inline uint32_t
220 const uint8_t *rss_key)
222 uint32_t i, j, map, ret = 0;
224 for (j = 0; j < input_len; j++) {
225 for (map = input_tuple[j]; map; map &= (map - 1)) {
227 ret ^= ((
const uint32_t *)rss_key)[j] << (31 - i) |
228 (uint32_t)((uint64_t)(((
const uint32_t *)rss_key)[j + 1]) >> (i + 1));
261 #define RTE_THASH_RETA_SZ_MIN 2U 263 #define RTE_THASH_RETA_SZ_MAX 16U 269 #define RTE_THASH_IGNORE_PERIOD_OVERFLOW 0x1 274 #define RTE_THASH_MINIMAL_SEQ 0x2 277 struct rte_thash_ctx;
279 struct rte_thash_subtuple_helper;
303 struct rte_thash_ctx *
305 uint8_t *key, uint32_t flags);
317 struct rte_thash_ctx *
362 struct rte_thash_subtuple_helper *
382 uint32_t hash, uint32_t desired_hash);
458 struct rte_thash_subtuple_helper *h,
459 uint8_t *tuple,
unsigned int tuple_len,
460 uint32_t desired_value,
unsigned int attempts,
490 uint32_t entropy_start,
size_t entropy_sz);
int rte_thash_add_helper(struct rte_thash_ctx *ctx, const char *name, uint32_t len, uint32_t offset)
int(* rte_thash_check_tuple_t)(void *userdata, uint8_t *tuple)
int rte_thash_gfni_supported(void)
const uint64_t * rte_thash_get_gfni_matrices(struct rte_thash_ctx *ctx)
static rte_be32_t rte_cpu_to_be_32(uint32_t x)
static uint32_t rte_bsf32(uint32_t v)
static void rte_convert_rss_key(const uint32_t *orig, uint32_t *targ, int len)
uint32_t rte_thash_get_complement(struct rte_thash_subtuple_helper *h, uint32_t hash, uint32_t desired_hash)
static void rte_thash_load_v6_addrs(const struct rte_ipv6_hdr *orig, union rte_thash_tuple *targ)
static uint32_t rte_softrss(uint32_t *input_tuple, uint32_t input_len, const uint8_t *rss_key)
void rte_thash_complete_matrix(uint64_t *matrixes, const uint8_t *rss_key, int size)
void rte_thash_free_ctx(struct rte_thash_ctx *ctx)
struct rte_thash_subtuple_helper * rte_thash_get_helper(struct rte_thash_ctx *ctx, const char *name)
int rte_thash_adjust_tuple(struct rte_thash_ctx *ctx, struct rte_thash_subtuple_helper *h, uint8_t *tuple, unsigned int tuple_len, uint32_t desired_value, unsigned int attempts, rte_thash_check_tuple_t fn, void *userdata)
struct rte_thash_ctx * rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz, uint8_t *key, uint32_t flags)
struct rte_thash_ctx * rte_thash_find_existing(const char *name)
static uint32_t rte_be_to_cpu_32(rte_be32_t x)
__rte_experimental int rte_thash_gen_key(uint8_t *key, size_t key_len, size_t reta_sz_log, uint32_t entropy_start, size_t entropy_sz)
static uint32_t rte_softrss_be(uint32_t *input_tuple, uint32_t input_len, const uint8_t *rss_key)
const uint8_t * rte_thash_get_key(struct rte_thash_ctx *ctx)