#include <pthread.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <bsd/string.h>
#include <pmd_af_xdp.h>
#include <stdint.h>
#include <strings.h>
#include "dlb_test.h"
static int
{
struct fwd_info *f = arg;
uint32_t cache_sz;
char *umem_addr;
if (!_obj)
return -1;
switch (obj.
hdr->cbtype) {
break;
break;
if (!strcmp(obj.
opt->name,
"no-metrics")) {
}
else if (!strcmp(obj.
opt->name,
"no-restapi")) {
}
else if (!strcmp(obj.
opt->name,
"cli")) {
}
break;
CNE_ERR_RET(
"**** Failed to allocate mmap memory %ld\n",
cache_sz = MEMPOOL_CACHE_MAX_SIZE;
ri->addr = umem_addr;
if (!pi) {
CNE_ERR_RET(
"pktmbuf_pool_init() failed for region %d\n", i);
}
snprintf(name,
sizeof(name),
"%s-%d", obj.
umem->name, i);
ri->pool = pi;
}
break;
do {
struct fwd_port *pd;
struct lport_cfg pcfg = {0};
pd = calloc(1, sizeof(struct fwd_port));
if (!pd)
CNE_ERR_RET(
"Unable to allocate fwd_port structure\n");
lport->priv_ = pd;
pcfg.bufsz = umem->
bufsz;
pcfg.rx_nb_desc = umem->
rxdesc;
pcfg.tx_nb_desc = umem->
txdesc;
if (!pcfg.addr) {
free(pd);
CNE_ERR_RET(
"lport %s region index %d >= %d or not configured correctly\n",
}
strlcpy(pcfg.pmd_name, PMD_NET_AF_XDP_NAME, sizeof(pcfg.pmd_name));
strlcpy(pcfg.ifname, lport->
netdev,
sizeof(pcfg.ifname));
strlcpy(pcfg.name, lport->name, sizeof(pcfg.name));
if (pd->lport < 0) {
free(pd);
CNE_ERR_RET(
"Unable to setup port %s, pktdev_port_setup() failed\n", lport->name);
}
} while ((0));
break;
break;
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t),
CNE_ERR_RET(
"Unable to create thread %d (%s) or type %s\n", idx, obj.
thd->name,
CNE_ERR_RET(
"Unable to create thread %d (%s) or type %s\n", idx, obj.
thd->name,
CNE_ERR_RET(
"Not enough cores (group - %d) for worker threads (workers - %d)\n",
for (int i = 0, bit = 0; i < num_workers; i++, bit++) {
while (CPU_ISSET(bit, &worker_bitmap) == 0)
bit++;
work_args[i].lcore = bit;
CNE_ERR_RET(
"Unable to create thread %d (%s) or type %s\n", idx, obj.
thd->name,
}
} else
break;
break;
default:
return -1;
}
return 0;
}
static struct option long_options[] = {
{"-c", required_argument, NULL, 'c'},
{"dev-id", required_argument, 0, 'd'},
{"num-workers", required_argument, 0, 'w'},
{NULL, 0, 0, 0}
};
static void
print_usage(char *prog_name)
{
" Usage: %s [-h] [-c json_file] [options]\n"
" Options:\n"
" -c <json-file>, The JSON configuration file\n"
" -d, --dev-id=N Device ID (default: 0)\n"
" -w, --num-workers=N Number of 'worker' threads that forward events (default: 0)\n"
" -h Display the help information\n",
prog_name);
}
int
parse_args(int argc, char **argv)
{
int opt, option_index, flags = 0;
char json_file[1024] = {0};
for (;;) {
opt = getopt_long(argc, argv, "c:d:w:h", long_options, &option_index);
if (opt == -1)
break;
switch (opt) {
case 'c':
strlcpy(json_file, optarg, sizeof(json_file));
break;
case 'h':
print_usage(argv[0]);
return -1;
case 'd':
dev_id = atoi(optarg);
break;
case 'w':
num_workers = atoi(optarg);
break;
default:
CNE_ERR("Invalid command option\n");
print_usage(argv[0]);
return -1;
}
}
fwd->jinfo =
jcfg_parser(flags, (
const char *)json_file);
if (fwd->jinfo == NULL)
CNE_ERR_RET(
"*** Did not find any configuration to use ***\n");
fwd->flags = flags;
if (dlb_init() == -1)
CNE_ERR_RET(
"*** DLB Device configuration fail ***\n");
return 0;
}
CNDP_API void * mmap_addr(mmap_t *mm)
CNDP_API int mmap_free(mmap_t *mmap)
CNDP_API mmap_t * mmap_alloc(uint32_t bufcnt, uint32_t bufsz, mmap_type_t hugepage)
CNDP_API size_t mmap_size(mmap_t *mm, uint32_t *bufcnt, uint32_t *bufsz)
CNDP_API int cne_printf(const char *fmt,...)
CNDP_API int thread_create(const char *name, thd_func_t func, void *arg)
CNDP_API jcfg_info_t * jcfg_parser(int flags, const char *s)
static int jcfg_default_get_u32(jcfg_info_t *jinfo, const char *name, uint32_t *v)
CNDP_API char * jcfg_lport_region(jcfg_lport_t *lport, uint32_t *objcnt)
CNDP_API int jcfg_process(jcfg_info_t *jinfo, int flags, jcfg_parse_cb_t *cb, void *cb_arg)
CNDP_API int pktdev_port_setup(lport_cfg_t *c)
static void pktmbuf_info_name_set(pktmbuf_info_t *pi, const char *str)
CNDP_API pktmbuf_info_t * pktmbuf_pool_create(char *addr, uint32_t bufcnt, uint32_t bufsz, uint32_t cache_sz, mbuf_ops_t *ops)