NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
eth_l2_fwd_core.c File Reference
#include <inttypes.h>
#include <time.h>
#include <doca_buf.h>
#include <doca_common_defines.h>
#include <doca_ctx.h>
#include <doca_eth_rxq.h>
#include <doca_eth_rxq_cpu_data_path.h>
#include <doca_eth_txq.h>
#include <doca_eth_txq_cpu_data_path.h>
#include <doca_log.h>
#include <doca_pe.h>
#include <samples/common.h>
#include <samples/doca_eth/eth_rxq_common.h>
#include "eth_l2_fwd_core.h"
Include dependency graph for eth_l2_fwd_core.c:

Go to the source code of this file.

Data Structures

struct  eth_l2_fwd_dev_stats
 
struct  eth_l2_fwd_stats
 

Macros

#define NS_PER_SEC   1E9 /* Nano-seconds per second */
 
#define STATS_MAX_BUFF_SIZE   1024 /* Max buffer size to hold statistics string */
 

Functions

 DOCA_LOG_REGISTER (ETH_L2_FWD :Core)
 
static void eth_l2_fwd_show_stats (void)
 
static doca_error_t check_device_caps (struct doca_devinfo *devinfo)
 
static doca_error_t create_mmap (struct doca_dev *dev1, struct doca_dev *dev2, struct mmap_resources *mmap_res)
 
static void rx_success_cb1 (struct doca_eth_rxq_event_batch_managed_recv *event_batch_managed_recv, uint16_t events_number, union doca_data event_batch_user_data, doca_error_t status, struct doca_buf **pkt_array)
 
static void rx_success_cb2 (struct doca_eth_rxq_event_batch_managed_recv *event_batch_managed_recv, uint16_t events_number, union doca_data event_batch_user_data, doca_error_t status, struct doca_buf **pkt_array)
 
static void rx_error_cb (struct doca_eth_rxq_event_batch_managed_recv *event_batch_managed_recv, uint16_t events_number, union doca_data event_batch_user_data, doca_error_t status, struct doca_buf **pkt_array)
 
static void tx_success_cb1 (struct doca_task_batch *task_batch, uint16_t tasks_num, union doca_data ctx_user_data, union doca_data task_batch_user_data, union doca_data *task_user_data_array, struct doca_buf **pkt_array, doca_error_t *status_array)
 
static void tx_success_cb2 (struct doca_task_batch *task_batch, uint16_t tasks_num, union doca_data ctx_user_data, union doca_data task_batch_user_data, union doca_data *task_user_data_array, struct doca_buf **pkt_array, doca_error_t *status_array)
 
static void tx_error_cb (struct doca_task_batch *task_batch, uint16_t tasks_num, union doca_data ctx_user_data, union doca_data task_batch_user_data, union doca_data *task_user_data_array, struct doca_buf **pkt_array, doca_error_t *status_array)
 
static doca_error_t init_eth_rxq_ctx (struct eth_l2_fwd_cfg *cfg, struct eth_l2_fwd_dev_resources *dev_resrc, struct doca_pe *pe, doca_eth_rxq_event_batch_managed_recv_handler_cb_t rx_success_cb, void *data)
 
static doca_error_t init_eth_txq_ctx (struct eth_l2_fwd_cfg *cfg, struct eth_l2_fwd_dev_resources *dev_resrc, struct doca_pe *pe, doca_eth_txq_task_batch_send_completion_cb_t tx_success_cb)
 
static doca_error_t forward_pkts (struct doca_pe *pe)
 
doca_error_t eth_l2_fwd_execute (struct eth_l2_fwd_cfg *cfg, struct eth_l2_fwd_resources *state)
 
void eth_l2_fwd_force_stop (void)
 
doca_error_t eth_l2_fwd_cleanup (struct eth_l2_fwd_resources *state)
 

Variables

static bool force_app_stop = false
 
static uint32_t total_forwardings = 0
 
uint32_t max_forwardings = 0
 
static struct eth_l2_fwd_stats stats
 

Macro Definition Documentation

◆ NS_PER_SEC

#define NS_PER_SEC   1E9 /* Nano-seconds per second */

Definition at line 44 of file eth_l2_fwd_core.c.

◆ STATS_MAX_BUFF_SIZE

#define STATS_MAX_BUFF_SIZE   1024 /* Max buffer size to hold statistics string */

Definition at line 45 of file eth_l2_fwd_core.c.

Function Documentation

◆ check_device_caps()

static doca_error_t check_device_caps ( struct doca_devinfo *  devinfo)
static

Definition at line 202 of file eth_l2_fwd_core.c.

◆ create_mmap()

static doca_error_t create_mmap ( struct doca_dev *  dev1,
struct doca_dev *  dev2,
struct mmap_resources mmap_res 
)
static

Create a DOCA mmap, initialize and start it

@dev1 [in]: DOCA device to set to mmap @dev2 [in]: DOCA device to set to mmap @mmap_res [in/out]: DOCA mmap resources to use for mmap creation

Returns
: DOCA_SUCCESS on success and DOCA_ERROR_... otherwise

Definition at line 228 of file eth_l2_fwd_core.c.

◆ DOCA_LOG_REGISTER()

DOCA_LOG_REGISTER ( ETH_L2_FWD :Core  )

◆ eth_l2_fwd_cleanup()

doca_error_t eth_l2_fwd_cleanup ( struct eth_l2_fwd_resources state)

Definition at line 891 of file eth_l2_fwd_core.c.

◆ eth_l2_fwd_execute()

doca_error_t eth_l2_fwd_execute ( struct eth_l2_fwd_cfg cfg,
struct eth_l2_fwd_resources state 
)

Definition at line 736 of file eth_l2_fwd_core.c.

◆ eth_l2_fwd_force_stop()

void eth_l2_fwd_force_stop ( void  )

Definition at line 886 of file eth_l2_fwd_core.c.

◆ eth_l2_fwd_show_stats()

static void eth_l2_fwd_show_stats ( void  )
static

Definition at line 85 of file eth_l2_fwd_core.c.

◆ forward_pkts()

static doca_error_t forward_pkts ( struct doca_pe *  pe)
static

Definition at line 708 of file eth_l2_fwd_core.c.

◆ init_eth_rxq_ctx()

static doca_error_t init_eth_rxq_ctx ( struct eth_l2_fwd_cfg cfg,
struct eth_l2_fwd_dev_resources dev_resrc,
struct doca_pe *  pe,
doca_eth_rxq_event_batch_managed_recv_handler_cb_t  rx_success_cb,
void *  data 
)
static

Definition at line 537 of file eth_l2_fwd_core.c.

◆ init_eth_txq_ctx()

static doca_error_t init_eth_txq_ctx ( struct eth_l2_fwd_cfg cfg,
struct eth_l2_fwd_dev_resources dev_resrc,
struct doca_pe *  pe,
doca_eth_txq_task_batch_send_completion_cb_t  tx_success_cb 
)
static

Definition at line 639 of file eth_l2_fwd_core.c.

◆ rx_error_cb()

static void rx_error_cb ( struct doca_eth_rxq_event_batch_managed_recv *  event_batch_managed_recv,
uint16_t  events_number,
union doca_data  event_batch_user_data,
doca_error_t  status,
struct doca_buf **  pkt_array 
)
static

Definition at line 392 of file eth_l2_fwd_core.c.

◆ rx_success_cb1()

static void rx_success_cb1 ( struct doca_eth_rxq_event_batch_managed_recv *  event_batch_managed_recv,
uint16_t  events_number,
union doca_data  event_batch_user_data,
doca_error_t  status,
struct doca_buf **  pkt_array 
)
static

Definition at line 292 of file eth_l2_fwd_core.c.

◆ rx_success_cb2()

static void rx_success_cb2 ( struct doca_eth_rxq_event_batch_managed_recv *  event_batch_managed_recv,
uint16_t  events_number,
union doca_data  event_batch_user_data,
doca_error_t  status,
struct doca_buf **  pkt_array 
)
static

Definition at line 342 of file eth_l2_fwd_core.c.

◆ tx_error_cb()

static void tx_error_cb ( struct doca_task_batch *  task_batch,
uint16_t  tasks_num,
union doca_data  ctx_user_data,
union doca_data  task_batch_user_data,
union doca_data task_user_data_array,
struct doca_buf **  pkt_array,
doca_error_t status_array 
)
static

Definition at line 496 of file eth_l2_fwd_core.c.

◆ tx_success_cb1()

static void tx_success_cb1 ( struct doca_task_batch *  task_batch,
uint16_t  tasks_num,
union doca_data  ctx_user_data,
union doca_data  task_batch_user_data,
union doca_data task_user_data_array,
struct doca_buf **  pkt_array,
doca_error_t status_array 
)
static

Definition at line 426 of file eth_l2_fwd_core.c.

◆ tx_success_cb2()

static void tx_success_cb2 ( struct doca_task_batch *  task_batch,
uint16_t  tasks_num,
union doca_data  ctx_user_data,
union doca_data  task_batch_user_data,
union doca_data task_user_data_array,
struct doca_buf **  pkt_array,
doca_error_t status_array 
)
static

Definition at line 461 of file eth_l2_fwd_core.c.

Variable Documentation

◆ force_app_stop

bool force_app_stop = false
static

Definition at line 50 of file eth_l2_fwd_core.c.

◆ max_forwardings

uint32_t max_forwardings = 0

Definition at line 55 of file eth_l2_fwd_core.c.

◆ stats

struct eth_l2_fwd_stats stats
static
Initial value:
= {.dev1_stats.rx_pkts = 0,
.dev1_stats.rx_dropped = 0,
.dev1_stats.total_tx_pkts = 0,
.dev2_stats.rx_pkts = 0,
.dev2_stats.rx_dropped = 0,
.dev2_stats.total_tx_pkts = 0}

Definition at line 55 of file eth_l2_fwd_core.c.

◆ total_forwardings

uint32_t total_forwardings = 0
static

Definition at line 52 of file eth_l2_fwd_core.c.