DPDK  20.08.0
Data Structures | Macros | Typedefs | Functions
rte_event_eth_tx_adapter.h File Reference
#include <stdint.h>
#include <rte_mbuf.h>
#include "rte_eventdev.h"

Go to the source code of this file.

Data Structures

struct  rte_event_eth_tx_adapter_conf
 
struct  rte_event_eth_tx_adapter_stats
 

Macros

#define RTE_EVENT_ETH_TX_ADAPTER_ENQUEUE_SAME_DEST   0x1
 

Typedefs

typedef int(* rte_event_eth_tx_adapter_conf_cb) (uint8_t id, uint8_t dev_id, struct rte_event_eth_tx_adapter_conf *conf, void *arg)
 

Functions

int rte_event_eth_tx_adapter_create (uint8_t id, uint8_t dev_id, struct rte_event_port_conf *port_config)
 
int rte_event_eth_tx_adapter_create_ext (uint8_t id, uint8_t dev_id, rte_event_eth_tx_adapter_conf_cb conf_cb, void *conf_arg)
 
int rte_event_eth_tx_adapter_free (uint8_t id)
 
int rte_event_eth_tx_adapter_start (uint8_t id)
 
int rte_event_eth_tx_adapter_stop (uint8_t id)
 
int rte_event_eth_tx_adapter_queue_add (uint8_t id, uint16_t eth_dev_id, int32_t queue)
 
int rte_event_eth_tx_adapter_queue_del (uint8_t id, uint16_t eth_dev_id, int32_t queue)
 
static __rte_always_inline void rte_event_eth_tx_adapter_txq_set (struct rte_mbuf *pkt, uint16_t queue)
 
static __rte_always_inline uint16_t rte_event_eth_tx_adapter_txq_get (struct rte_mbuf *pkt)
 
int rte_event_eth_tx_adapter_event_port_get (uint8_t id, uint8_t *event_port_id)
 
static uint16_t rte_event_eth_tx_adapter_enqueue (uint8_t dev_id, uint8_t port_id, struct rte_event ev[], uint16_t nb_events, const uint8_t flags)
 
int rte_event_eth_tx_adapter_stats_get (uint8_t id, struct rte_event_eth_tx_adapter_stats *stats)
 
int rte_event_eth_tx_adapter_stats_reset (uint8_t id)
 
int rte_event_eth_tx_adapter_service_id_get (uint8_t id, uint32_t *service_id)
 

Detailed Description

RTE Event Ethernet Tx Adapter

The event ethernet Tx adapter provides configuration and data path APIs for the ethernet transmit stage of an event driven packet processing application. These APIs abstract the implementation of the transmit stage and allow the application to use eventdev PMD support or a common implementation.

In the common implementation, the application enqueues mbufs to the adapter which runs as a rte_service function. The service function dequeues events from its event port and transmits the mbufs referenced by these events.

The ethernet Tx event adapter APIs are:

The application creates the adapter using rte_event_eth_tx_adapter_create() or rte_event_eth_tx_adapter_create_ext().

The adapter will use the common implementation when the eventdev PMD does not have the RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT capability. The common implementation uses an event port that is created using the port configuration parameter passed to rte_event_eth_tx_adapter_create(). The application can get the port identifier using rte_event_eth_tx_adapter_event_port_get() and must link an event queue to this port.

If the eventdev PMD has the RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT flags set, Tx adapter events should be enqueued using the rte_event_eth_tx_adapter_enqueue() function, else the application should use rte_event_enqueue_burst().

Transmit queues can be added and deleted from the adapter using rte_event_eth_tx_adapter_queue_add()/del() APIs respectively.

The application can start and stop the adapter using the rte_event_eth_tx_adapter_start/stop() calls.

The common adapter implementation uses an EAL service function as described before and its execution is controlled using the rte_service APIs. The rte_event_eth_tx_adapter_service_id_get() function can be used to retrieve the adapter's service function ID.

The ethernet port and transmit queue index to transmit the mbuf on are specified using the mbuf port struct rte_mbuf::hash::txadapter:txq. The application should use the rte_event_eth_tx_adapter_txq_set() and rte_event_eth_tx_adapter_txq_get() functions to access the transmit queue index, using these macros will help with minimizing application impact due to a change in how the transmit queue index is specified.

Definition in file rte_event_eth_tx_adapter.h.

Macro Definition Documentation

#define RTE_EVENT_ETH_TX_ADAPTER_ENQUEUE_SAME_DEST   0x1

This flag is used when all the packets enqueued in the tx adapter are destined for the same Ethernet port & Tx queue.

Definition at line 303 of file rte_event_eth_tx_adapter.h.

Typedef Documentation

typedef int(* rte_event_eth_tx_adapter_conf_cb) (uint8_t id, uint8_t dev_id, struct rte_event_eth_tx_adapter_conf *conf, void *arg)

Function type used for adapter configuration callback. The callback is used to fill in members of the struct rte_event_eth_tx_adapter_conf, this callback is invoked when creating a RTE service function based adapter implementation.

Parameters
idAdapter identifier.
dev_idEvent device identifier.
[out]confStructure that needs to be populated by this callback.
argArgument to the callback. This is the same as the conf_arg passed to the rte_event_eth_tx_adapter_create_ext().
Returns
  • 0: Success
  • <0: Error code on failure

Definition at line 122 of file rte_event_eth_tx_adapter.h.

Function Documentation

int rte_event_eth_tx_adapter_create ( uint8_t  id,
uint8_t  dev_id,
struct rte_event_port_conf port_config 
)

Create a new ethernet Tx adapter with the specified identifier.

Parameters
idThe identifier of the ethernet Tx adapter.
dev_idThe event device identifier.
port_configEvent port configuration, the adapter uses this configuration to create an event port if needed.
Returns
  • 0: Success
  • <0: Error code on failure
Examples:
examples/eventdev_pipeline/pipeline_worker_generic.c, examples/eventdev_pipeline/pipeline_worker_tx.c, examples/ipsec-secgw/event_helper.c, examples/l2fwd-event/l2fwd_event_generic.c, examples/l2fwd-event/l2fwd_event_internal_port.c, examples/l3fwd/l3fwd_event_generic.c, and examples/l3fwd/l3fwd_event_internal_port.c.
int rte_event_eth_tx_adapter_create_ext ( uint8_t  id,
uint8_t  dev_id,
rte_event_eth_tx_adapter_conf_cb  conf_cb,
void *  conf_arg 
)

Create a new ethernet Tx adapter with the specified identifier.

Parameters
idThe identifier of the ethernet Tx adapter.
dev_idThe event device identifier.
conf_cbCallback function that initializes members of the struct rte_event_eth_tx_adapter_conf struct passed into it.
conf_argArgument that is passed to the conf_cb function.
Returns
  • 0: Success
  • <0: Error code on failure
int rte_event_eth_tx_adapter_free ( uint8_t  id)

Free an ethernet Tx adapter

Parameters
idAdapter identifier.
Returns
  • 0: Success
  • <0: Error code on failure, If the adapter still has Tx queues added to it, the function returns -EBUSY.
Examples:
examples/ipsec-secgw/event_helper.c.
int rte_event_eth_tx_adapter_start ( uint8_t  id)
int rte_event_eth_tx_adapter_stop ( uint8_t  id)

Stop ethernet Tx adapter

Parameters
idAdapter identifier.
Returns
  • 0: Success.
  • <0: Error code on failure.
Examples:
examples/eventdev_pipeline/main.c, examples/ipsec-secgw/event_helper.c, examples/l2fwd-event/main.c, and examples/l3fwd/main.c.
int rte_event_eth_tx_adapter_queue_add ( uint8_t  id,
uint16_t  eth_dev_id,
int32_t  queue 
)

Add a Tx queue to the adapter. A queue value of -1 is used to indicate all queues within the device.

Parameters
idAdapter identifier.
eth_dev_idEthernet Port Identifier.
queueTx queue index.
Returns
  • 0: Success, Queues added successfully.
  • <0: Error code on failure.
Examples:
examples/eventdev_pipeline/pipeline_worker_generic.c, examples/eventdev_pipeline/pipeline_worker_tx.c, examples/ipsec-secgw/event_helper.c, examples/l2fwd-event/l2fwd_event_generic.c, examples/l2fwd-event/l2fwd_event_internal_port.c, examples/l3fwd/l3fwd_event_generic.c, and examples/l3fwd/l3fwd_event_internal_port.c.
int rte_event_eth_tx_adapter_queue_del ( uint8_t  id,
uint16_t  eth_dev_id,
int32_t  queue 
)

Delete a Tx queue from the adapter. A queue value of -1 is used to indicate all queues within the device, that have been added to this adapter.

Parameters
idAdapter identifier.
eth_dev_idEthernet Port Identifier.
queueTx queue index.
Returns
  • 0: Success, Queues deleted successfully.
  • <0: Error code on failure.
Examples:
examples/ipsec-secgw/event_helper.c.
static __rte_always_inline void rte_event_eth_tx_adapter_txq_set ( struct rte_mbuf pkt,
uint16_t  queue 
)
static

Set Tx queue in the mbuf. This queue is used by the adapter to transmit the mbuf.

Parameters
pktPointer to the mbuf.
queueTx queue index.
Examples:
examples/eventdev_pipeline/pipeline_worker_tx.c, examples/ipsec-secgw/ipsec_worker.c, examples/l2fwd-event/l2fwd_event.c, examples/l3fwd/l3fwd_em.c, and examples/l3fwd/l3fwd_lpm.c.

Definition at line 266 of file rte_event_eth_tx_adapter.h.

static __rte_always_inline uint16_t rte_event_eth_tx_adapter_txq_get ( struct rte_mbuf pkt)
static

Retrieve Tx queue from the mbuf.

Parameters
pktPointer to the mbuf.
Returns
Tx queue identifier.
See also
rte_event_eth_tx_adapter_txq_set()

Definition at line 282 of file rte_event_eth_tx_adapter.h.

int rte_event_eth_tx_adapter_event_port_get ( uint8_t  id,
uint8_t *  event_port_id 
)

Retrieve the adapter event port. The adapter creates an event port if the RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT is not set in the ethernet Tx capabilities of the event device.

Parameters
idAdapter Identifier.
[out]event_port_idEvent port pointer.
Returns
  • 0: Success.
  • <0: Error code on failure.
Examples:
examples/eventdev_pipeline/pipeline_worker_generic.c, examples/ipsec-secgw/event_helper.c, examples/l2fwd-event/l2fwd_event_generic.c, and examples/l3fwd/l3fwd_event_generic.c.
static uint16_t rte_event_eth_tx_adapter_enqueue ( uint8_t  dev_id,
uint8_t  port_id,
struct rte_event  ev[],
uint16_t  nb_events,
const uint8_t  flags 
)
inlinestatic

Enqueue a burst of events objects or an event object supplied in rte_event structure on an event device designated by its dev_id through the event port specified by port_id. This function is supported if the eventdev PMD has the RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT capability flag set.

The nb_events parameter is the number of event objects to enqueue which are supplied in the ev array of rte_event structure.

The rte_event_eth_tx_adapter_enqueue() function returns the number of events objects it actually enqueued. A return value equal to nb_events means that all event objects have been enqueued.

Parameters
dev_idThe identifier of the device.
port_idThe identifier of the event port.
evPoints to an array of nb_events objects of type rte_event structure which contain the event object enqueue operations to be processed.
nb_eventsThe number of event objects to enqueue, typically number of rte_event_port_attr_get(...RTE_EVENT_PORT_ATTR_ENQ_DEPTH...) available for this port.
flagsRTE_EVENT_ETH_TX_ADAPTER_ENQUEUE_ flags. RTE_EVENT_ETH_TX_ADAPTER_ENQUEUE_SAME_DEST signifies that all the packets which are enqueued are destined for the same Ethernet port & Tx queue.
Returns
The number of event objects actually enqueued on the event device. The return value can be less than the value of the nb_events parameter when the event devices queue is full or if invalid parameters are specified in a rte_event. If the return value is less than nb_events, the remaining events at the end of ev[] are not consumed and the caller has to take care of them, and rte_errno is set accordingly. Possible errno values include:
  • EINVAL The port ID is invalid, device ID is invalid, an event's queue ID is invalid, or an event's sched type doesn't match the capabilities of the destination queue.
  • ENOSPC The event port was backpressured and unable to enqueue one or more events. This error code is only applicable to closed systems.
Examples:
examples/eventdev_pipeline/pipeline_worker_tx.c, examples/ipsec-secgw/ipsec_worker.c, examples/l2fwd-event/l2fwd_event.c, examples/l3fwd/l3fwd_em.c, and examples/l3fwd/l3fwd_lpm.c.

Definition at line 352 of file rte_event_eth_tx_adapter.h.

int rte_event_eth_tx_adapter_stats_get ( uint8_t  id,
struct rte_event_eth_tx_adapter_stats stats 
)

Retrieve statistics for an adapter

Parameters
idAdapter identifier.
[out]statsA pointer to structure used to retrieve statistics for an adapter.
Returns
  • 0: Success, statistics retrieved successfully.
  • <0: Error code on failure.
Examples:
examples/l2fwd-event/main.c.
int rte_event_eth_tx_adapter_stats_reset ( uint8_t  id)

Reset statistics for an adapter.

Parameters
idAdapter identifier.
Returns
  • 0: Success, statistics reset successfully.
  • <0: Error code on failure.
int rte_event_eth_tx_adapter_service_id_get ( uint8_t  id,
uint32_t *  service_id 
)

Retrieve the service ID of an adapter. If the adapter doesn't use a rte_service function, this function returns -ESRCH.

Parameters
idAdapter identifier.
[out]service_idA pointer to a uint32_t, to be filled in with the service id.
Returns
  • 0: Success
  • <0: Error code on failure, if the adapter doesn't use a rte_service function, this function returns -ESRCH.
Examples:
examples/eventdev_pipeline/pipeline_worker_generic.c, examples/ipsec-secgw/event_helper.c, examples/l2fwd-event/l2fwd_event.c, examples/l2fwd-event/l2fwd_event_generic.c, examples/l3fwd/l3fwd_event_generic.c, and examples/l3fwd/main.c.