CNDP  22.08.0
cne_thash.h File Reference
#include <stdint.h>
#include <cne_byteorder.h>
#include <cne_common.h>
#include <cne_vect.h>
#include <net/cne_ip.h>

Go to the source code of this file.

Data Structures

struct  cne_ipv4_tuple
 
struct  cne_ipv6_tuple
 

Macros

#define CNE_THASH_V4_L3_LEN    ((sizeof(struct cne_ipv4_tuple) - sizeof(((struct cne_ipv4_tuple *)0)->sctp_tag)) / 4)
 
#define CNE_THASH_V4_L4_LEN   ((sizeof(struct cne_ipv4_tuple)) / 4)
 
#define CNE_THASH_V6_L3_LEN    ((sizeof(struct cne_ipv6_tuple) - sizeof(((struct cne_ipv6_tuple *)0)->sctp_tag)) / 4)
 
#define CNE_THASH_V6_L4_LEN   ((sizeof(struct cne_ipv6_tuple)) / 4)
 

Functions

static void cne_convert_rss_key (const uint32_t *orig, uint32_t *targ, int len)
 
static void cne_thash_load_v6_addrs (const struct cne_ipv6_hdr *orig, union cne_thash_tuple *targ)
 
static uint32_t cne_softrss (uint32_t *input_tuple, uint32_t input_len, const uint8_t *rss_key)
 
static uint32_t cne_softrss_be (uint32_t *input_tuple, uint32_t input_len, const uint8_t *rss_key)
 

Variables

static const __m128i cne_thash_ipv6_bswap_mask = {0x0405060700010203ULL, 0x0C0D0E0F08090A0BULL}
 

Detailed Description

toeplitz hash functions.

Definition in file cne_thash.h.

Macro Definition Documentation

◆ CNE_THASH_V4_L3_LEN

#define CNE_THASH_V4_L3_LEN    ((sizeof(struct cne_ipv4_tuple) - sizeof(((struct cne_ipv4_tuple *)0)->sctp_tag)) / 4)

length in dwords of input tuple to calculate hash of ipv4 header only

Definition at line 40 of file cne_thash.h.

◆ CNE_THASH_V4_L4_LEN

#define CNE_THASH_V4_L4_LEN   ((sizeof(struct cne_ipv4_tuple)) / 4)

length in dwords of input tuple to calculate hash of ipv4 header + transport header

Definition at line 48 of file cne_thash.h.

◆ CNE_THASH_V6_L3_LEN

#define CNE_THASH_V6_L3_LEN    ((sizeof(struct cne_ipv6_tuple) - sizeof(((struct cne_ipv6_tuple *)0)->sctp_tag)) / 4)

length in dwords of input tuple to calculate hash of ipv6 header only

Definition at line 54 of file cne_thash.h.

◆ CNE_THASH_V6_L4_LEN

#define CNE_THASH_V6_L4_LEN   ((sizeof(struct cne_ipv6_tuple)) / 4)

length in dwords of input tuple to calculate hash of ipv6 header + transport header

Definition at line 62 of file cne_thash.h.

Function Documentation

◆ cne_convert_rss_key()

static void cne_convert_rss_key ( const uint32_t *  orig,
uint32_t *  targ,
int  len 
)
inlinestatic

Prepare special converted key to use with cne_softrss_be()

Parameters
origpointer to original RSS key
targpointer to target RSS key
lenRSS key length

Definition at line 114 of file cne_thash.h.

◆ cne_thash_load_v6_addrs()

static void cne_thash_load_v6_addrs ( const struct cne_ipv6_hdr orig,
union cne_thash_tuple *  targ 
)
inlinestatic

Prepare and load IPv6 addresses (src and dst) into target tuple

Parameters
origPointer to ipv6 header of the original packet
targPointer to cne_ipv6_tuple structure

Definition at line 131 of file cne_thash.h.

◆ cne_softrss()

static uint32_t cne_softrss ( uint32_t *  input_tuple,
uint32_t  input_len,
const uint8_t *  rss_key 
)
inlinestatic

Generic implementation. Can be used with original rss_key

Parameters
input_tuplePointer to input tuple
input_lenLength of input_tuple in 4-bytes chunks
rss_keyPointer to RSS hash key.
Returns
Calculated hash value.

Definition at line 151 of file cne_thash.h.

◆ cne_softrss_be()

static uint32_t cne_softrss_be ( uint32_t *  input_tuple,
uint32_t  input_len,
const uint8_t *  rss_key 
)
inlinestatic

Optimized implementation. If you want the calculated hash value matches NIC RSS value you have to use special converted key with cne_convert_rss_key() fn.

Parameters
input_tuplePointer to input tuple
input_lenLength of input_tuple in 4-bytes chunks
*rss_keyPointer to RSS hash key.
Returns
Calculated hash value.

Definition at line 179 of file cne_thash.h.

Variable Documentation

◆ cne_thash_ipv6_bswap_mask

const __m128i cne_thash_ipv6_bswap_mask = {0x0405060700010203ULL, 0x0C0D0E0F08090A0BULL}
static

Software implementation of the Toeplitz hash function used by RSS. Can be used either for packet distribution on single queue NIC or for simulating of RSS computation on specific NIC (for example after GRE header decapsulating)

Definition at line 34 of file cne_thash.h.