rte_distributor.h(3)

✨ rte_distributor.h ✨

okay so bestie, you're reading the manual page for rte_distributor.h β€” yes, THAT one, the DPDK header that's out here doing dynamic load balancing like it's the main character. Library Functions Manual energy. Let's get into it πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

functions (the whole squad)

struct rte_distributor * rte_distributor_create (const char *name,
    unsigned int socket_id, unsigned int num_workers, unsigned int alg_type)
int rte_distributor_process (struct rte_distributor *d, struct rte_mbuf **mbufs, unsigned int num_mbufs)
int rte_distributor_returned_pkts (struct rte_distributor *d, struct rte_mbuf **mbufs, unsigned int max_mbufs)
int rte_distributor_flush (struct rte_distributor *d)
void rte_distributor_clear_returns (struct rte_distributor *d)
int rte_distributor_get_pkt (struct rte_distributor *d, unsigned int worker_id, struct rte_mbuf **pkts, struct rte_mbuf **oldpkt, unsigned int retcount)
int rte_distributor_return_pkt (struct rte_distributor *d, unsigned int worker_id, struct rte_mbuf **oldpkt, int num)
void rte_distributor_request_pkt (struct rte_distributor *d, unsigned int worker_id, struct rte_mbuf **oldpkt, unsigned int count)
int rte_distributor_poll_pkt (struct rte_distributor *d, unsigned int worker_id, struct rte_mbuf **mbufs)

🌸 Detailed Description 🌸

RTE distributor πŸ’–

So the distributor is literally this component designed to pass packets one-at-a-time to workers, and it's doing dynamic load balancing while it's at it. No cap. It's out here keeping the vibes balanced so no worker is doing overtime while another one's on their phone.

Definition in file rte_distributor.h.

πŸ¦‹ Function Documentation πŸ¦‹

πŸ‘‘ rte_distributor_create

struct rte_distributor * rte_distributor_create (const char * name, unsigned int socket_id, unsigned int num_workers, unsigned int alg_type)

The function that creates a brand new distributor instance, periodt. ✨

It reserves all the memory needed for distributor operations and initializes the distributor so it's ready to work with however many workers you configured.

Parameters

  • name β€” the name you're giving to this distributor instance, bestie.
  • socket_id β€” the NUMA node where the memory gets allocated.
  • num_workers β€” the maximum number of workers that will be requesting packets from this distributor.
  • alg_type β€” call the legacy API, or use the new burst API. legacy uses a 32-bit flow ID and works on a single packet at a time. Latest uses a 15-bit flow ID and works on up to 8 packets at a time to workers.

Returns

The newly created distributor instance 🫢


πŸ”₯ rte_distributor_process

int rte_distributor_process (struct rte_distributor * d, struct rte_mbuf ** mbufs, unsigned int num_mbufs)

This one processes a set of packets by distributing them among the workers that request packets. And here's the iconic part: the distributor makes sure that no two packets with the same flow id, or tag, in the mbuf get processed on different cores at the same time. Vibe-locked, fr fr.

The user is advocated to set the tag for each mbuf before calling this function. If you don't set the tag, the tag value can be various values depending on driver implementation and configuration. πŸ™ˆ

not multi-thread safe!! This should only be called on a single lcore. Do not be out here calling it from everywhere, that's giving chaos.

Parameters

  • d β€” the distributor instance to be used.
  • mbufs β€” the mbufs to be distributed.
  • num_mbufs β€” the number of mbufs in the mbufs array.

Returns

The number of mbufs processed.


🧚 rte_distributor_returned_pkts

int rte_distributor_returned_pkts (struct rte_distributor * d, struct rte_mbuf ** mbufs, unsigned int max_mbufs)

Gets you a set of mbufs that have been returned to the distributor by the workers. It's giving "give me back my stuff" πŸ’…

This should only be called on the same lcore as rte_distributor_process().

Parameters

  • d β€” the distributor instance to be used.
  • mbufs β€” the mbufs pointer array to be filled in.
  • max_mbufs β€” the size of the mbufs array.

Returns

The number of mbufs returned in the mbufs array.


πŸ’€ rte_distributor_flush

int rte_distributor_flush (struct rte_distributor * d)

Flushes the distributor component so that there are no in-flight or backlogged packets awaiting processing. Clean sweep, no crumbs left behind. ✨

This should only be called on the same lcore as rte_distributor_process().

Parameters

  • d β€” the distributor instance to be used.

Returns

The number of queued/in-flight packets that were completed by this call.


πŸŽ€ rte_distributor_clear_returns

void rte_distributor_clear_returns (struct rte_distributor * d)

Clears the array of returned packets β€” the one that's used as the source for the rte_distributor_returned_pkts() API call. Basically emptying the returns bin. πŸ—‘οΈ

This should only be called on the same lcore as rte_distributor_process().

Parameters

  • d β€” the distributor instance to be used.

🫢 rte_distributor_get_pkt

int rte_distributor_get_pkt (struct rte_distributor * d, unsigned int worker_id, struct rte_mbuf ** pkts, struct rte_mbuf ** oldpkt, unsigned int retcount)

API called by a worker to get new packets to process. Any previous packets given to the worker are assumed to have completed processing, and may be optionally returned to the distributor via the oldpkt parameter. So like, optionally. Your call, bestie. πŸ’–

Parameters

  • d β€” the distributor instance to be used.
  • worker_id β€” the worker instance number to use β€” must be less than num_workers passed at distributor creation time. (yes, it says "less that" in the source, we all saw it, moving on 😭)
  • pkts β€” the mbufs pointer array to be filled in (up to 8 packets).
  • oldpkt β€” the previous packets, if any, being processed by the worker.
  • retcount β€” the number of packets being returned.

Returns

The number of packets in the pkts array.


🌈 rte_distributor_return_pkt

int rte_distributor_return_pkt (struct rte_distributor * d, unsigned int worker_id, struct rte_mbuf ** oldpkt, int num)

API called by a worker to return a completed packet without requesting a new packet β€” for example, because a worker thread is shutting down. It's the "I'm leaving, here's your stuff back" move. πŸ‘‹

Parameters

  • d β€” the distributor instance to be used.
  • worker_id β€” the worker instance number to use β€” must be less than num_workers passed at distributor creation time.
  • oldpkt β€” the previous packets being processed by the worker.
  • num β€” the number of packets in the oldpkt array.

⭐ rte_distributor_request_pkt

void rte_distributor_request_pkt (struct rte_distributor * d, unsigned int worker_id, struct rte_mbuf ** oldpkt, unsigned int count)

API called by a worker to request a new packet to process. Any previous packets given to the worker are assumed to have completed processing, and may be optionally returned to the distributor via the oldpkt parameter. And here's the plot twist: unlike rte_distributor_get_pkt(), this function does not wait for new packets to be provided by the distributor. It's non-blocking, it has places to be. πŸƒβ€β™€οΈ

NOTE: after calling this function, rte_distributor_poll_pkt() should be used to poll for the packets requested. The rte_distributor_get_pkt() API should not be used to try and retrieve the new packets. Mixing those two up is not it, bestie.

Parameters

  • d β€” the distributor instance to be used.
  • worker_id β€” the worker instance number to use β€” must be less than num_workers passed at distributor creation time.
  • oldpkt β€” the returning packets, if any, processed by the worker.
  • count β€” the number of returning packets.

πŸ’œ rte_distributor_poll_pkt

int rte_distributor_poll_pkt (struct rte_distributor * d, unsigned int worker_id, struct rte_mbuf ** mbufs)

API called by a worker to check for new packets that were previously requested by a call to rte_distributor_request_pkt(). It does not wait for the new packets to be available β€” it just returns if the request hasn't yet been fulfilled by the distributor. Patience is not its thing. πŸ™ˆ

Parameters

  • d β€” the distributor instance to be used.
  • worker_id β€” the worker instance number to use β€” must be less than num_workers passed at distributor creation time.
  • mbufs β€” the array of mbufs being given to the worker.

Returns

The number of packets being given to the worker thread, -1 if no packets are yet available (burst API β€” RTE_DIST_ALG_BURST), 0 if no packets are yet available (legacy single API β€” RTE_DIST_ALG_SINGLE).


🌟 Author 🌟

Generated automatically by Doxygen for DPDK from the source code. (the robots wrote it, we just made it cute πŸ’–)


okay and that's the whole page bestie, you ate that 🫢 this manual page came from DPDK, Version 25.11.3, and it's the rte_distributor.h(3) page, slay πŸ’…βœ¨ no cap, go balance those packets 🌸

πŸ“¦ where this page comes from