DPDK  17.05.2
Macros | Functions
rte_jhash.h File Reference
#include <stdint.h>
#include <string.h>
#include <limits.h>
#include <rte_log.h>
#include <rte_byteorder.h>

Go to the source code of this file.

Macros

#define RTE_JHASH_GOLDEN_RATIO   0xdeadbeef

Functions

static void rte_jhash_2hashes (const void *key, uint32_t length, uint32_t *pc, uint32_t *pb)
static void rte_jhash_32b_2hashes (const uint32_t *k, uint32_t length, uint32_t *pc, uint32_t *pb)
static uint32_t rte_jhash (const void *key, uint32_t length, uint32_t initval)
static uint32_t rte_jhash_32b (const uint32_t *k, uint32_t length, uint32_t initval)
static uint32_t rte_jhash_3words (uint32_t a, uint32_t b, uint32_t c, uint32_t initval)
static uint32_t rte_jhash_2words (uint32_t a, uint32_t b, uint32_t initval)
static uint32_t rte_jhash_1word (uint32_t a, uint32_t initval)

Detailed Description

jhash functions.

Definition in file rte_jhash.h.

Macro Definition Documentation

#define RTE_JHASH_GOLDEN_RATIO   0xdeadbeef

The golden ratio: an arbitrary value.

Definition at line 96 of file rte_jhash.h.

Function Documentation

static void rte_jhash_2hashes ( const void *  key,
uint32_t  length,
uint32_t *  pc,
uint32_t *  pb 
)
inlinestatic

Same as rte_jhash, but takes two seeds and return two uint32_ts. pc and pb must be non-null, and *pc and *pb must both be initialized with seeds. If you pass in (*pb)=0, the output (*pc) will be the same as the return value from rte_jhash.

Parameters
keyKey to calculate hash of.
lengthLength of key in bytes.
pcIN: seed OUT: primary hash value.
pbIN: second seed OUT: secondary hash value.

Definition at line 264 of file rte_jhash.h.

static void rte_jhash_32b_2hashes ( const uint32_t *  k,
uint32_t  length,
uint32_t *  pc,
uint32_t *  pb 
)
inlinestatic

Same as rte_jhash_32b, but takes two seeds and return two uint32_ts. pc and pb must be non-null, and *pc and *pb must both be initialized with seeds. If you pass in (*pb)=0, the output (*pc) will be the same as the return value from rte_jhash_32b.

Parameters
kKey to calculate hash of.
lengthLength of key in units of 4 bytes.
pcIN: seed OUT: primary hash value.
pbIN: second seed OUT: secondary hash value.

Definition at line 285 of file rte_jhash.h.

static uint32_t rte_jhash ( const void *  key,
uint32_t  length,
uint32_t  initval 
)
inlinestatic

The most generic version, hashes an arbitrary sequence of bytes. No alignment or length assumptions are made about the input key.

Parameters
keyKey to calculate hash of.
lengthLength of key in bytes.
initvalInitialising value of hash.
Returns
Calculated hash value.
Examples:
examples/ipsec-secgw/ipsec-secgw.c, examples/l3fwd/l3fwd_em.c, and examples/performance-thread/l3fwd-thread/main.c.

Definition at line 305 of file rte_jhash.h.

static uint32_t rte_jhash_32b ( const uint32_t *  k,
uint32_t  length,
uint32_t  initval 
)
inlinestatic

A special optimized version that handles 1 or more of uint32_ts. The length parameter here is the number of uint32_ts in the key.

Parameters
kKey to calculate hash of.
lengthLength of key in units of 4 bytes.
initvalInitialising value of hash.
Returns
Calculated hash value.

Definition at line 328 of file rte_jhash.h.

static uint32_t rte_jhash_3words ( uint32_t  a,
uint32_t  b,
uint32_t  c,
uint32_t  initval 
)
inlinestatic

A special ultra-optimized versions that knows it is hashing exactly 3 words.

Parameters
aFirst word to calculate hash of.
bSecond word to calculate hash of.
cThird word to calculate hash of.
initvalInitialising value of hash.
Returns
Calculated hash value.

Definition at line 365 of file rte_jhash.h.

static uint32_t rte_jhash_2words ( uint32_t  a,
uint32_t  b,
uint32_t  initval 
)
inlinestatic

A special ultra-optimized versions that knows it is hashing exactly 2 words.

Parameters
aFirst word to calculate hash of.
bSecond word to calculate hash of.
initvalInitialising value of hash.
Returns
Calculated hash value.

Definition at line 384 of file rte_jhash.h.

static uint32_t rte_jhash_1word ( uint32_t  a,
uint32_t  initval 
)
inlinestatic

A special ultra-optimized versions that knows it is hashing exactly 1 word.

Parameters
aWord to calculate hash of.
initvalInitialising value of hash.
Returns
Calculated hash value.
Examples:
examples/l3fwd/l3fwd_em.c, and examples/performance-thread/l3fwd-thread/main.c.

Definition at line 401 of file rte_jhash.h.