rte_fbk_hash.h(3)

πŸ’– rte_fbk_hash.h β€” Library Functions Manual πŸ’–

okay so bestie, welcome to rte_fbk_hash.h(3) β€” a whole icon, no notes. this is the four-byte-key hash table era of DPDK and it's giving speed. 🌸


✨ NAME ✨

rte_fbk_hash.h β€” the header for the four byte key (fbk) hash table. yes that's literally it, she's mysterious like that πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

lowkey the whole vibe starts with these includes, bestie:

#include <stdint.h>
#include <errno.h>
#include <string.h>
#include <rte_common.h>
#include <rte_hash_crc.h>
#include <rte_jhash.h>

πŸŽ€ Data Structures πŸŽ€

  • struct rte_fbk_hash_params
  • union rte_fbk_hash_entry
  • struct rte_fbk_hash_table

πŸŽ€ Macros πŸŽ€

#define RTE_FBK_HASH_INIT_VAL_DEFAULT   0xFFFFFFFF
#define RTE_FBK_HASH_ENTRIES_MAX   (1 << 20)
#define RTE_FBK_HASH_ENTRIES_PER_BUCKET_MAX   256
#define RTE_FBK_HASH_NAMESIZE   32

πŸŽ€ Typedefs πŸŽ€

typedef uint32_t(* rte_fbk_hash_fn) (uint32_t key, uint32_t init_val)

πŸŽ€ Functions πŸŽ€

static uint32_t rte_fbk_hash_get_bucket (const struct rte_fbk_hash_table
    *ht, uint32_t key)
static int rte_fbk_hash_add_key_with_bucket (struct rte_fbk_hash_table
    *ht, uint32_t key, uint16_t value, uint32_t bucket)
static int rte_fbk_hash_add_key (struct rte_fbk_hash_table *ht, uint32_t
    key, uint16_t value)
static int rte_fbk_hash_delete_key_with_bucket (struct
    rte_fbk_hash_table *ht, uint32_t key, uint32_t bucket)
static int rte_fbk_hash_delete_key (struct rte_fbk_hash_table *ht,
    uint32_t key)
static int rte_fbk_hash_lookup_with_bucket (const struct
    rte_fbk_hash_table *ht, uint32_t key, uint32_t bucket)
static int rte_fbk_hash_lookup (const struct rte_fbk_hash_table *ht,
    uint32_t key)
static void rte_fbk_hash_clear_all (struct rte_fbk_hash_table *ht)
static double rte_fbk_hash_get_load_factor (struct rte_fbk_hash_table
    *ht)
struct rte_fbk_hash_table * rte_fbk_hash_find_existing (const char
    *name)
void rte_fbk_hash_free (struct rte_fbk_hash_table *ht)
struct rte_fbk_hash_table * rte_fbk_hash_create (const struct
    rte_fbk_hash_params *params) __rte_malloc
    __rte_dealloc(rte_fbk_hash_free

🌈 Detailed Description 🌈

so this is a hash table implementation for four byte keys (fbk). that's the whole personality. πŸ’–

⚠️ bestie listen up β€” the return value of the add function should always be checked, because if a bucket is full, the key is not added, even if there's space in other buckets. no cap. this is what keeps the lookup function super simple and therefore fast. she chose speed over convenience and honestly? respect. 🫢

Definition in file rte_fbk_hash.h.


πŸ’œ Macro Definition Documentation πŸ’œ

#define RTE_FBK_HASH_INIT_VAL_DEFAULT 0xFFFFFFFF

the initialising value used when calculating the hash. her starting point, her origin story ✨

Definition at line 33 of file rte_fbk_hash.h.


#define RTE_FBK_HASH_ENTRIES_MAX (1 << 20)

the maximum number of entries in the hash table that is supported. that's the ceiling, the limit, the "don't test me" number πŸ‘‘

Definition at line 37 of file rte_fbk_hash.h.


#define RTE_FBK_HASH_ENTRIES_PER_BUCKET_MAX 256

the maximum number of entries in each bucket that is supported. per bucket, bestie. 256 of them. that's it, that's the cap πŸ’…

Definition at line 40 of file rte_fbk_hash.h.


#define RTE_FBK_HASH_NAMESIZE 32

max size of string for naming the hash. thirty-two characters to name your child, choose wisely πŸŽ€

Definition at line 43 of file rte_fbk_hash.h.


🧚 Typedef Documentation 🧚

typedef uint32_t(* rte_fbk_hash_fn) (uint32_t key, uint32_t init_val)

the type of function that can be used for calculating the hash value. plug in your own hash girlie, it's a whole build-your-own-adventure situation 🌸

Definition at line 46 of file rte_fbk_hash.h.


πŸ”₯ Function Documentation πŸ”₯

uint32_t rte_fbk_hash_get_bucket (const struct rte_fbk_hash_table * ht, uint32_t key) β€” [inline], [static]

find the offset into the hash table of the bucket containing a particular key. it's a little "where does this key live" moment 🏠

Parameters

  • ht β€” pointer to hash table.
  • key β€” key to calculate bucket for.

Returns

offset into hash table.

Definition at line 95 of file rte_fbk_hash.h.


int rte_fbk_hash_add_key_with_bucket (struct rte_fbk_hash_table * ht, uint32_t key, uint16_t value, uint32_t bucket) β€” [inline], [static]

add a key to an existing hash table with a bucket id. this operation is not multi-thread safe and should only be called from one thread. one thread, bestie, don't share her around 😭

Parameters

  • ht β€” hash table to add the key to.
  • key β€” key to add to the hash table.
  • value β€” value to associate with key.
  • bucket β€” bucket to associate with key.

Returns

0 if ok, or negative value on error.

Definition at line 118 of file rte_fbk_hash.h.


int rte_fbk_hash_add_key (struct rte_fbk_hash_table * ht, uint32_t key, uint16_t value) β€” [inline], [static]

add a key to an existing hash table. this operation is not multi-thread safe and should only be called from one thread. yes we're saying it twice, it matters βœ‹

Parameters

  • ht β€” hash table to add the key to.
  • key β€” key to add to the hash table.
  • value β€” value to associate with key.

Returns

0 if ok, or negative value on error.

Definition at line 163 of file rte_fbk_hash.h.


int rte_fbk_hash_delete_key_with_bucket (struct rte_fbk_hash_table * ht, uint32_t key, uint32_t bucket) β€” [inline], [static]

remove a key with a given bucket id from an existing hash table. this operation is not multi-thread safe and should only be called from one thread. bye bye key, we hardly knew ye πŸ‘‹

Parameters

  • ht β€” hash table to remove the key from.
  • key β€” key to remove from the hash table.
  • bucket β€” bucket id associate with key.

Returns

0 if ok, or negative value on error.

Definition at line 185 of file rte_fbk_hash.h.


int rte_fbk_hash_delete_key (struct rte_fbk_hash_table * ht, uint32_t key) β€” [inline], [static]

remove a key from an existing hash table. this operation is not multi-thread safe and should only be called from one thread. the single-thread rule is the whole plot of this manpage fr fr πŸ’€

Parameters

  • ht β€” hash table to remove the key from.
  • key β€” key to remove from the hash table.

Returns

0 if ok, or negative value on error.

Definition at line 228 of file rte_fbk_hash.h.


int rte_fbk_hash_lookup_with_bucket (const struct rte_fbk_hash_table * ht, uint32_t key, uint32_t bucket) β€” [inline], [static]

find a key in the hash table with a given bucketid. this operation is multi-thread safe. okay look at her being all thread-friendly, main character energy ✨

Parameters

  • ht β€” hash table to look in.
  • key β€” key to find.
  • bucket β€” bucket associate to the key.

Returns

the value that was associated with the key, or negative value on error.

Definition at line 248 of file rte_fbk_hash.h.


int rte_fbk_hash_lookup (const struct rte_fbk_hash_table * ht, uint32_t key) β€” [inline], [static]

find a key in the hash table. this operation is multi-thread safe. no bucket arg needed, she's self-sufficient πŸ’…

Parameters

  • ht β€” hash table to look in.
  • key β€” key to find.

Returns

the value that was associated with the key, or negative value on error.

Definition at line 278 of file rte_fbk_hash.h.


void rte_fbk_hash_clear_all (struct rte_fbk_hash_table * ht) β€” [inline], [static]

delete all entries in a hash table. this operation is not multi-thread safe and should only be called from one thread. it's giving spring cleaning but make it chaotic 🧹

Parameters

  • ht β€” hash table to delete entries in.

Definition at line 292 of file rte_fbk_hash.h.


double rte_fbk_hash_get_load_factor (struct rte_fbk_hash_table * ht) β€” [inline], [static]

find what fraction of entries are being used. vibe check on your table's fullness basically πŸ¦‹

Parameters

  • ht β€” hash table to find how many entries are being used in.

Returns

load factor of the hash table, or negative value on error.

Definition at line 307 of file rte_fbk_hash.h.


struct rte_fbk_hash_table * rte_fbk_hash_find_existing (const char * name)

performs a lookup for an existing hash table, and returns a pointer to the table if found. like checking if your friend is already at the party 🌸

Parameters

  • name β€” name of the hash table to find

Returns

pointer to hash table structure or NULL on error with rte_errno set appropriately. possible rte_errno values include:

  • ENOENT β€” required entry not available to return.

void rte_fbk_hash_free (struct rte_fbk_hash_table * ht)

free all memory used by a hash table. has no effect on hash tables allocated in memory zones. read that again bestie, if it lives in a memzone this does nothing to it πŸ™ˆ

Parameters

  • ht β€” hash table to deallocate.

struct rte_fbk_hash_table * rte_fbk_hash_create (const struct rte_fbk_hash_params * params)

create a new hash table for use with four byte keys. brand new table, brand new era, slay πŸŽ€

Parameters

  • params β€” parameters used in creation of hash table.

Returns

pointer to hash table structure that is used in future hash table operations, or NULL on error with rte_errno set appropriately. possible rte_errno error values include:

  • E_RTE_NO_CONFIG β€” function could not get pointer to rte_config structure
  • E_RTE_SECONDARY β€” function was called from a secondary process instance
  • EINVAL β€” invalid parameter value passed to function
  • ENOSPC β€” the maximum number of memzones has already been allocated
  • EEXIST β€” a memzone with the same name already exists
  • ENOMEM β€” no appropriate memory area found in which to create memzone

πŸ‘‘ Author πŸ‘‘

generated automatically by Doxygen for DPDK from the source code. she wrote herself, honestly iconic ✨


and that's the whole page bestie, thanks for reading my essay πŸ’–

DPDK β€” Version 25.11.3 β€” rte_fbk_hash.h(3) πŸ¦‹πŸŒΈπŸ’…

okay bye ily, go check your add() return values 🫢

πŸ“¦ where this page comes from