CNDP  22.08.0
cne_fib.h File Reference
#include <stdint.h>
#include <cne_common.h>

Go to the source code of this file.

Data Structures

struct  cne_fib_conf
 

Macros

#define CNE_FIB_MAXDEPTH   32
 

Typedefs

typedef int(* cne_fib_modify_fn_t) (struct cne_fib *fib, uint32_t ip, uint8_t depth, uint64_t next_hop, int op)
 
typedef void(* cne_fib_lookup_fn_t) (void *fib, const uint32_t *ips, uint64_t *next_hops, const unsigned int n)
 

Enumerations

enum  cne_fib_type { CNE_FIB_DUMMY , CNE_FIB_DIR24_8 }
 
enum  cne_fib_dir24_8_nh_sz
 
enum  cne_fib_lookup_type {
  CNE_FIB_LOOKUP_DEFAULT , CNE_FIB_LOOKUP_DIR24_8_SCALAR_MACRO , CNE_FIB_LOOKUP_DIR24_8_SCALAR_INLINE , CNE_FIB_LOOKUP_DIR24_8_SCALAR_UNI ,
  CNE_FIB_LOOKUP_DIR24_8_VECTOR_AVX512
}
 

Functions

struct cne_fib * cne_fib_create (const char *name, struct cne_fib_conf *conf)
 
void cne_fib_free (struct cne_fib *fib)
 
int cne_fib_add (struct cne_fib *fib, uint32_t ip, uint8_t depth, uint64_t next_hop)
 
int cne_fib_delete (struct cne_fib *fib, uint32_t ip, uint8_t depth)
 
int cne_fib_lookup_bulk (struct cne_fib *fib, uint32_t *ips, uint64_t *next_hops, int n)
 
void * cne_fib_get_dp (struct cne_fib *fib)
 
struct cne_rib * cne_fib_get_rib (struct cne_fib *fib)
 
int cne_fib_select_lookup (struct cne_fib *fib, enum cne_fib_lookup_type type)
 

Detailed Description

CNE FIB library.

FIB (Forwarding information base) implementation for IPv4 Longest Prefix Match

Definition in file cne_fib.h.

Macro Definition Documentation

◆ CNE_FIB_MAXDEPTH

#define CNE_FIB_MAXDEPTH   32

Maximum depth value possible for IPv4 FIB.

Definition at line 29 of file cne_fib.h.

Typedef Documentation

◆ cne_fib_modify_fn_t

typedef int(* cne_fib_modify_fn_t) (struct cne_fib *fib, uint32_t ip, uint8_t depth, uint64_t next_hop, int op)

Modify FIB function

Definition at line 38 of file cne_fib.h.

◆ cne_fib_lookup_fn_t

typedef void(* cne_fib_lookup_fn_t) (void *fib, const uint32_t *ips, uint64_t *next_hops, const unsigned int n)

FIB bulk lookup function

Definition at line 41 of file cne_fib.h.

Enumeration Type Documentation

◆ cne_fib_type

Type of FIB struct

Enumerator
CNE_FIB_DUMMY 

RIB tree based FIB

CNE_FIB_DIR24_8 

DIR24_8 based FIB

Definition at line 32 of file cne_fib.h.

◆ cne_fib_dir24_8_nh_sz

Size of nexthop (1 << nh_sz) bits for DIR24_8 based FIB

Definition at line 50 of file cne_fib.h.

◆ cne_fib_lookup_type

Type of lookup function implementation

Enumerator
CNE_FIB_LOOKUP_DEFAULT 

Selects the best implementation based on the max simd bitwidth

CNE_FIB_LOOKUP_DIR24_8_SCALAR_MACRO 

Macro based lookup function

CNE_FIB_LOOKUP_DIR24_8_SCALAR_INLINE 

Lookup implementation using inlined functions for different next hop sizes

CNE_FIB_LOOKUP_DIR24_8_SCALAR_UNI 

Unified lookup function for all next hop sizes

CNE_FIB_LOOKUP_DIR24_8_VECTOR_AVX512 

Vector implementation using AVX512

Definition at line 58 of file cne_fib.h.

Function Documentation

◆ cne_fib_create()

struct cne_fib* cne_fib_create ( const char *  name,
struct cne_fib_conf conf 
)

Create a FIB structure using the configuration specified.

Parameters
nameFIB name
confStructure containing the configuration
Returns
Pointer to the FIB object on success or NULL on error

◆ cne_fib_free()

void cne_fib_free ( struct cne_fib *  fib)

Free an FIB object.

Parameters
fibFIB object handle
Returns
None

◆ cne_fib_add()

int cne_fib_add ( struct cne_fib *  fib,
uint32_t  ip,
uint8_t  depth,
uint64_t  next_hop 
)

Add a route to the FIB.

Parameters
fibFIB object handle
ipIPv4 prefix address to be added to the FIB
depthPrefix length
next_hopNext hop to be added to the FIB
Returns
0 on success, negative value otherwise

◆ cne_fib_delete()

int cne_fib_delete ( struct cne_fib *  fib,
uint32_t  ip,
uint8_t  depth 
)

Delete a rule from the FIB.

Parameters
fibFIB object handle
ipIPv4 prefix address to be deleted from the FIB
depthPrefix length
Returns
0 on success, negative value otherwise

◆ cne_fib_lookup_bulk()

int cne_fib_lookup_bulk ( struct cne_fib *  fib,
uint32_t *  ips,
uint64_t *  next_hops,
int  n 
)

Lookup multiple IP addresses in the FIB.

Parameters
fibFIB object handle
ipsArray of IPs to be looked up in the FIB
next_hopsNext hop of the most specific rule found for IP. This is an array of eight byte values. If the lookup for the given IP failed, then corresponding element would contain default nexthop value configured for a FIB.
nNumber of elements in ips (and next_hops) array to lookup.
Returns
-EINVAL for incorrect arguments, otherwise 0

◆ cne_fib_get_dp()

void* cne_fib_get_dp ( struct cne_fib *  fib)

Get pointer to the dataplane specific struct

Parameters
fibFIB object handle
Returns
Pointer to the dataplane structure on success NULL otherwise

◆ cne_fib_get_rib()

struct cne_rib* cne_fib_get_rib ( struct cne_fib *  fib)

Get pointer to the RIB

Parameters
fibFIB object handle
Returns
Pointer to the RIB structure on success or NULL on error

◆ cne_fib_select_lookup()

int cne_fib_select_lookup ( struct cne_fib *  fib,
enum cne_fib_lookup_type  type 
)

Set lookup function based on type

Parameters
fibFIB object handle
typetype of lookup function
Returns
0 on success -EINVAL on failure