NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
flow_sampling_sample.c File Reference
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <rte_ethdev.h>
#include <doca_log.h>
#include <doca_flow.h>
#include <doca_bitfield.h>
#include "doca_error.h"
#include "flow_common.h"
#include "flow_switch_common.h"
Include dependency graph for flow_sampling_sample.c:

Go to the source code of this file.

Macros

#define RANDOM_WIDTH   16
 
#define RANDOM_TOTAL_RANGE   (1 << RANDOM_WIDTH)
 
#define GET_PERCENTAGE(part, total)   (((double)part / (double)total) * 100)
 
#define WAITING_TIME   15
 

Functions

 DOCA_LOG_REGISTER (FLOW_SAMPLING)
 
static doca_error_t create_root_pipe (struct doca_flow_port *port, struct doca_flow_pipe *next_pipe, struct doca_flow_pipe **pipe)
 
static doca_error_t add_root_pipe_entry (struct doca_flow_pipe *pipe, struct entries_status *status, struct doca_flow_pipe_entry **entry)
 
static uint16_t get_random_value (double percentage)
 
static doca_error_t create_random_sampling_pipe (struct doca_flow_port *port, struct doca_flow_pipe **pipe)
 
static doca_error_t add_random_sampling_pipe_entry (struct doca_flow_pipe *pipe, struct entries_status *status, double percentage, struct doca_flow_pipe_entry **entry)
 
static doca_error_t random_sampling_results (struct doca_flow_pipe_entry *root_entry, struct doca_flow_pipe_entry *random_entry, double requested_percentage)
 
doca_error_t flow_sampling (int nb_queues, struct flow_switch_ctx *ctx)
 

Macro Definition Documentation

◆ GET_PERCENTAGE

#define GET_PERCENTAGE (   part,
  total 
)    (((double)part / (double)total) * 100)

Definition at line 49 of file flow_sampling_sample.c.

◆ RANDOM_TOTAL_RANGE

#define RANDOM_TOTAL_RANGE   (1 << RANDOM_WIDTH)

Definition at line 46 of file flow_sampling_sample.c.

◆ RANDOM_WIDTH

#define RANDOM_WIDTH   16

Definition at line 43 of file flow_sampling_sample.c.

◆ WAITING_TIME

#define WAITING_TIME   15

Definition at line 52 of file flow_sampling_sample.c.

Function Documentation

◆ add_random_sampling_pipe_entry()

static doca_error_t add_random_sampling_pipe_entry ( struct doca_flow_pipe *  pipe,
struct entries_status status,
double  percentage,
struct doca_flow_pipe_entry **  entry 
)
static

Definition at line 215 of file flow_sampling_sample.c.

◆ add_root_pipe_entry()

static doca_error_t add_root_pipe_entry ( struct doca_flow_pipe *  pipe,
struct entries_status status,
struct doca_flow_pipe_entry **  entry 
)
static

Definition at line 133 of file flow_sampling_sample.c.

◆ create_random_sampling_pipe()

static doca_error_t create_random_sampling_pipe ( struct doca_flow_port *  port,
struct doca_flow_pipe **  pipe 
)
static

Definition at line 183 of file flow_sampling_sample.c.

◆ create_root_pipe()

static doca_error_t create_root_pipe ( struct doca_flow_port *  port,
struct doca_flow_pipe *  next_pipe,
struct doca_flow_pipe **  pipe 
)
static

Definition at line 62 of file flow_sampling_sample.c.

◆ DOCA_LOG_REGISTER()

DOCA_LOG_REGISTER ( FLOW_SAMPLING  )

◆ flow_sampling()

doca_error_t flow_sampling ( int  nb_queues,
struct flow_switch_ctx ctx 
)

Definition at line 323 of file flow_sampling_sample.c.

◆ get_random_value()

static uint16_t get_random_value ( double  percentage)
static

Definition at line 159 of file flow_sampling_sample.c.

◆ random_sampling_results()

static doca_error_t random_sampling_results ( struct doca_flow_pipe_entry *  root_entry,
struct doca_flow_pipe_entry *  random_entry,
double  requested_percentage 
)
static

Definition at line 274 of file flow_sampling_sample.c.