---
name: "rte_distributor_get_pkt_single"
section: "3"
platform: "linux"
package: "dpdk-doc"
version: "24.11.4-0+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rte_distributor_single.h"
---

# rte\_distributor\_get\_pkt\_single(3)

Part of [rte\_distributor\_single.h(3)](/rte_distributor_single.h/3.md).

## NAME

rte\_distributor\_single.h

## SYNOPSIS

### Macros

\#define **RTE\_DISTRIBUTOR\_NAMESIZE**   32\

### Functions

struct rte\_distributor\_single \* **rte\_distributor\_create\_single** (const char \*name, unsigned int socket\_id, unsigned int num\_workers)\
 int **rte\_distributor\_process\_single** (struct rte\_distributor\_single \*d, struct **rte\_mbuf** \*\*mbufs, unsigned int num\_mbufs)\
 int **rte\_distributor\_returned\_pkts\_single** (struct rte\_distributor\_single \*d, struct **rte\_mbuf** \*\*mbufs, unsigned int max\_mbufs)\
 int **rte\_distributor\_flush\_single** (struct rte\_distributor\_single \*d)\
 void **rte\_distributor\_clear\_returns\_single** (struct rte\_distributor\_single \*d)\
 struct **rte\_mbuf** \* **rte\_distributor\_get\_pkt\_single** (struct rte\_distributor\_single \*d, unsigned int worker\_id, struct **rte\_mbuf** \*oldpkt)\
 int **rte\_distributor\_return\_pkt\_single** (struct rte\_distributor\_single \*d, unsigned int worker\_id, struct **rte\_mbuf** \*mbuf)\
 void **rte\_distributor\_request\_pkt\_single** (struct rte\_distributor\_single \*d, unsigned int worker\_id, struct **rte\_mbuf** \*oldpkt)\
 struct **rte\_mbuf** \* **rte\_distributor\_poll\_pkt\_single** (struct rte\_distributor\_single \*d, unsigned int worker\_id)\

## Detailed Description

RTE distributor

The distributor is a component which is designed to pass packets one-at-a-time to workers, with dynamic load balancing.

Definition in file **rte\_distributor\_single.h**.

## Macro Definition Documentation

### #define RTE\_DISTRIBUTOR\_NAMESIZE 32

Length of name for instance

Definition at line **20** of file **rte\_distributor\_single.h**.

## Function Documentation

### struct rte\_distributor\_single \* rte\_distributor\_create\_single (const char \* name, unsigned int socket\_id, unsigned int num\_workers)

Function to create a new distributor instance

Reserves the memory needed for the distributor operation and initializes the distributor to work with the configured number of workers.

**Parameters**

*name* The name to be given to the distributor instance. \
 *socket\_id* The NUMA node on which the memory is to be allocated \
 *num\_workers* The maximum number of workers that will request packets from this distributor

**Returns**

The newly created distributor instance

### int rte\_distributor\_process\_single (struct rte\_distributor\_single \* d, struct rte\_mbuf \*\* mbufs, unsigned int num\_mbufs)

Process a set of packets by distributing them among workers that request packets. The distributor will ensure that no two packets that have the same flow id, or tag, in the mbuf will be processed at the same time.

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

This is not multi-thread safe and should only be called on a single lcore.

**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.

### int rte\_distributor\_returned\_pkts\_single (struct rte\_distributor\_single \* d, struct rte\_mbuf \*\* mbufs, unsigned int max\_mbufs)

Get a set of mbufs that have been returned to the distributor by workers

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.

### int rte\_distributor\_flush\_single (struct rte\_distributor\_single \* d)

Flush the distributor component, so that there are no in-flight or backlogged packets awaiting processing

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.

### void rte\_distributor\_clear\_returns\_single (struct rte\_distributor\_single \* d)

Clears the array of returned packets used as the source for the **rte\_distributor\_returned\_pkts()** API call.

This should only be called on the same lcore as **rte\_distributor\_process()**

**Parameters**

*d* The distributor instance to be used

### struct rte\_mbuf \* rte\_distributor\_get\_pkt\_single (struct rte\_distributor\_single \* d, unsigned int worker\_id, struct rte\_mbuf \* oldpkt)

API called by a worker to get a new packet to process. Any previous packet given to the worker is assumed to have completed processing, and may be optionally returned to the distributor via the oldpkt parameter.

**Parameters**

*d* The distributor instance to be used \
 *worker\_id* The worker instance number to use - must be less that num\_workers passed at distributor creation time. \
 *oldpkt* The previous packet, if any, being processed by the worker

**Returns**

A new packet to be processed by the worker thread.

### int rte\_distributor\_return\_pkt\_single (struct rte\_distributor\_single \* d, unsigned int worker\_id, struct rte\_mbuf \* mbuf)

API called by a worker to return a completed packet without requesting a new packet, for example, because a worker thread is shutting down

**Parameters**

*d* The distributor instance to be used \
 *worker\_id* The worker instance number to use - must be less that num\_workers passed at distributor creation time. \
 *mbuf* The previous packet being processed by the worker

### void rte\_distributor\_request\_pkt\_single (struct rte\_distributor\_single \* d, unsigned int worker\_id, struct rte\_mbuf \* oldpkt)

API called by a worker to request a new packet to process. Any previous packet given to the worker is assumed to have completed processing, and may be optionally returned to the distributor via the oldpkt parameter. Unlike **rte\_distributor\_get\_pkt()**, this function does not wait for a new packet to be provided by the distributor.

NOTE: after calling this function, **rte\_distributor\_poll\_pkt()** should be used to poll for the packet requested. The **rte\_distributor\_get\_pkt()** API should *not* be used to try and retrieve the new packet.

**Parameters**

*d* The distributor instance to be used \
 *worker\_id* The worker instance number to use - must be less that num\_workers passed at distributor creation time. \
 *oldpkt* The previous packet, if any, being processed by the worker

### struct rte\_mbuf \* rte\_distributor\_poll\_pkt\_single (struct rte\_distributor\_single \* d, unsigned int worker\_id)

API called by a worker to check for a new packet that was previously requested by a call to **rte\_distributor\_request\_pkt()**. It does not wait for the new packet to be available, but returns NULL if the request has not yet been fulfilled by the distributor.

**Parameters**

*d* The distributor instance to be used \
 *worker\_id* The worker instance number to use - must be less that num\_workers passed at distributor creation time.

**Returns**

A new packet to be processed by the worker thread, or NULL if no packet is yet available.

## Author

Generated automatically by Doxygen for DPDK from the source code.
