27 #include <sys/socket.h>
28 #include <netinet/in.h>
29 #include <arpa/inet.h>
50 DOCA_LOG_ERR(
"Entered device PCI address exceeding the maximum size of %d",
68 char *ip_addr_str = (
char *)param;
70 if (inet_pton(AF_INET, ip_addr_str, &
cfg->src_ip.s_addr) != 1) {
71 DOCA_LOG_ERR(
"Invalid source IP address: %s", ip_addr_str);
87 int port = *(
int *)param;
89 if (port <= 0 || port > 65535) {
107 char *ip_addr_str = (
char *)param;
109 if (inet_pton(AF_INET, ip_addr_str, &
cfg->dst_ip.s_addr) != 1) {
110 DOCA_LOG_ERR(
"Invalid destination IP address: %s", ip_addr_str);
119 struct doca_argp_param *pci_param;
120 struct doca_argp_param *src_ip_param;
121 struct doca_argp_param *dst_ip_param;
122 struct doca_argp_param *dst_port_param;
211 result = doca_rmax_flow_set_src_ip(flow, &config->
src_ip);
215 result = doca_rmax_flow_set_dst_ip(flow, &config->
dst_ip);
228 size_t num_buffers = (config->
hdr_size > 0) ? 2 : 1;
234 result = doca_rmax_in_stream_set_scatter_type_raw(stream);
236 result = doca_rmax_in_stream_set_scatter_type_ulp(stream);
244 if (num_buffers == 1)
252 result = doca_rmax_in_stream_set_memblks_count(stream, num_buffers);
256 result = doca_rmax_in_stream_memblk_desc_set_min_size(stream, pkt_size);
260 result = doca_rmax_in_stream_memblk_desc_set_max_size(stream, pkt_size);
285 struct doca_rmax_in_stream *stream,
287 struct doca_buf **buffer,
288 uint16_t *stride_size)
290 size_t page_size = sysconf(_SC_PAGESIZE);
291 size_t num_buffers = (config->
hdr_size > 0) ? 2 : 1;
293 char *ptr_memory =
NULL;
298 result = doca_rmax_in_stream_get_memblk_size(stream, size);
305 result = doca_rmax_in_stream_get_memblk_stride_size(stream, stride_size);
313 if (ptr_memory ==
NULL)
318 DOCA_LOG_ERR(
"Failed to set mmap memory range, ptr %p, size %zu: %s",
337 if (num_buffers == 1) {
341 ptr[1] = ptr_memory + size[0];
345 for (
size_t i = 0; i < num_buffers; ++i) {
346 struct doca_buf *buf;
366 result = doca_rmax_in_stream_set_memblk(stream, *buffer);
376 struct doca_rmax_in_stream *stream,
377 struct doca_rmax_flow *flow,
378 struct doca_buf *buf)
388 result = doca_rmax_flow_destroy(flow);
399 result = doca_rmax_in_stream_destroy(stream);
407 result = doca_rmax_release();
doca_error_t destroy_core_objects(struct program_core_objects *state)
DOCA_EXPERIMENTAL void doca_argp_param_set_description(struct doca_argp_param *param, const char *description)
Set the description of the program param, used during program usage.
DOCA_EXPERIMENTAL void doca_argp_param_set_long_name(struct doca_argp_param *param, const char *name)
Set the long name of the program param.
DOCA_EXPERIMENTAL void doca_argp_param_set_callback(struct doca_argp_param *param, doca_argp_param_cb_t callback)
Set the callback function of the program param.
DOCA_EXPERIMENTAL void doca_argp_param_set_mandatory(struct doca_argp_param *param)
Mark the program param as mandatory.
DOCA_EXPERIMENTAL doca_error_t doca_argp_param_create(struct doca_argp_param **param)
Create new program param.
DOCA_EXPERIMENTAL void doca_argp_param_set_type(struct doca_argp_param *param, enum doca_argp_type type)
Set the type of the param arguments.
DOCA_EXPERIMENTAL void doca_argp_param_set_short_name(struct doca_argp_param *param, const char *name)
Set the short name of the program param.
DOCA_EXPERIMENTAL doca_error_t doca_argp_register_param(struct doca_argp_param *input_param)
Register a program flag.
static doca_error_t doca_buf_inventory_buf_get_by_addr(struct doca_buf_inventory *inventory, struct doca_mmap *mmap, void *addr, size_t len, struct doca_buf **buf)
Allocate single element from buffer inventory and point it to the buffer defined by addr & len argume...
DOCA_STABLE doca_error_t doca_buf_dec_refcount(struct doca_buf *buf, uint16_t *refcount)
Decrease the object reference count by 1, if 0 reached, return the element back to the inventory.
DOCA_STABLE doca_error_t doca_buf_chain_list(struct doca_buf *list1, struct doca_buf *list2)
Append list2 to list1.
DOCA_STABLE doca_error_t doca_ctx_start(struct doca_ctx *ctx)
Finalizes all configurations, and starts the DOCA CTX.
DOCA_STABLE doca_error_t doca_ctx_stop(struct doca_ctx *ctx)
Stops the context allowing reconfiguration.
#define DOCA_DEVINFO_PCI_ADDR_SIZE
Buffer size to hold PCI BDF format: "XXXX:XX:XX.X". Including a null terminator.
enum doca_error doca_error_t
DOCA API return codes.
DOCA_STABLE const char * doca_error_get_descr(doca_error_t error)
Returns the description string of an error code.
@ DOCA_ERROR_INVALID_VALUE
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_WARN(format,...)
Generates a WARNING application log message.
DOCA_STABLE doca_error_t doca_mmap_set_memrange(struct doca_mmap *mmap, void *addr, size_t len)
Set the memory range of DOCA memory map.
DOCA_STABLE doca_error_t doca_mmap_start(struct doca_mmap *mmap)
Start DOCA Memory Map.
DOCA_STABLE doca_error_t doca_mmap_set_free_cb(struct doca_mmap *mmap, doca_mmap_memrange_free_cb_t *free_cb, void *opaque)
Set callback that will free the memory range when destroying DOCA memory map.
DOCA_STABLE doca_error_t doca_pe_connect_ctx(struct doca_pe *pe, struct doca_ctx *ctx)
This method connects a context to a progress engine.
const struct ip_frag_config * cfg
void * aligned_alloc(size_t alignment, size_t size)
void rmax_create_stream_cleanup(struct rmax_program_state *state, struct doca_rmax_in_stream *stream, struct doca_rmax_flow *flow, struct doca_buf *buf)
doca_error_t rmax_stream_allocate_buf(struct rmax_program_state *state, struct doca_rmax_in_stream *stream, struct rmax_stream_config *config, struct doca_buf **buffer, uint16_t *stride_size)
DOCA_LOG_REGISTER(rmax_common)
static doca_error_t pci_address_callback(void *param, void *config)
doca_error_t rmax_stream_set_attributes(struct doca_rmax_in_stream *stream, struct rmax_stream_config *config)
static doca_error_t src_ip_callback(void *param, void *config)
doca_error_t rmax_flow_set_attributes(struct rmax_stream_config *config, struct doca_rmax_flow *flow)
static doca_error_t dst_ip_callback(void *param, void *config)
doca_error_t register_create_stream_params(void)
doca_error_t rmax_stream_start(struct rmax_program_state *state)
static doca_error_t dst_port_callback(void *param, void *config)
static void free_callback(void *addr, size_t len, void *opaque)
struct doca_mmap * src_mmap
struct doca_buf_inventory * buf_inv
struct program_core_objects core_objects
char pci_address[DOCA_DEVINFO_PCI_ADDR_SIZE]