#include "main.h"
static struct app_info app_info = {0};
struct app_info *app = &app_info;
static int tick;
uint64_t total_interrupts;
#define UIPI_BURST_COUNT 16
static int
{
ibroker_info_t info = {0};
CNE_ERR_RET(
"ibroker_dump() failed: %s\n", strerror(errno));
cne_printf(
"[yellow]%s[] ([magenta]%d[]): %8ld\n", info.name, info.tid, info.intrs);
struct service_info *sinfo = &info.services[i];
if (sinfo->valid)
cne_printf(
" [green]%-16s[] [magenta]%2d[]: [green]%8ld[] [red]%8ld[]\n", sinfo->name,
sinfo->uintr_fd, sinfo->call_cnt, sinfo->err_cnt);
}
return 0;
}
static void
page_stats(void)
{
cne_printf_pos(1, 1,
"[magenta]Running [green]%c[] [magenta]Total interrupts [green]%ld[]\n",
"|/-\\"[tick & 3], total_interrupts);
tick++;
CNE_ERR("Failed: %s\n", strerror(errno));
}
static void
thread_func(void *arg)
{
pthread_t *pid = arg;
char buff[128];
const char *name;
*pid = pthread_self();
if (!name)
CNE_RET(
"Not a value thread name\n");
if (bid < 0)
for (int i = 0; i < app->num_services; i++) {
snprintf(buff,
sizeof(buff),
"srv-%s-%d",
thread_name(-1), i);
buff);
}
if (pthread_barrier_wait(&app->barrier) > 0)
CNE_RET(
"Barrier wait failed: %s\n", strerror(errno));
while (app->quit == 0)
usleep(100);
}
static void
{
int id_cnt;
if (id_cnt <= 0)
else {
}
for (int i = 0; i < id_cnt; i++)
for (int j = 0; j < app->num_services; j++)
for (;;) {
usleep(1000);
if (app->quit)
break;
for (int i = 0; i < UIPI_BURST_COUNT; i++) {
}
}
for (int i = 0; i < id_cnt; i++) {
int bid = ids[i];
for (int j = 0; j < app->num_services; j++) {
CNE_ERR_GOTO(leave,
"Unable to delete service vector %2d to ibroker %-12s:%s\n", j,
}
}
leave:
free(ids);
}
static void
__on_exit(int val, void *arg, int exit_type)
{
struct app_info *a = arg;
switch (exit_type) {
if (val == SIGUSR1)
return;
cne_printf_pos(99, 1,
"\n>>> [cyan]Terminating with signal [green]%d[]\n", val);
if (a)
a->quit = 1;
break;
if (a)
a->quit = 1;
if (val)
cne_printf_pos(99, 1,
"\n>>> [cyan]Terminating with status [green]%d[]\n", val);
break;
break;
default:
break;
}
fflush(stdout);
}
int
main(int argc, char **argv)
{
char buff[128];
int tidx, signals[] = {SIGINT, SIGUSR1, SIGUSR2};
srand(0x20250630 + (getpid() * 333));
cne_on_exit(__on_exit, app, signals, cne_countof(signals));
if (parse_args(argc, argv))
vt_cls();
"[yellow]*** [magenta]iBroker[], [magenta]PID[]: [red]%d[], [magenta]Number of "
"brokers[]: [green]%d[], [magenta]Number of Services[]: [green]%d[]\n",
getpid(), app->num_brokers, app->num_services);
if (pthread_barrier_init(&app->barrier, NULL, app->num_brokers + 1))
CNE_ERR_GOTO(err,
"Barrier initialize failed: %s\n", strerror(errno));
if (app->num_brokers >= MAX_THREADS)
CNE_ERR_GOTO(leave,
"Number of brokers exceeds %d\n", MAX_THREADS);
for (int i = 0; i < app->num_brokers; i++) {
snprintf(buff, sizeof(buff), "Broker-%d", i);
}
cne_printf(
"Wait until [red]Ctrl-C[] is pressed\n");
sleep(1);
if (pthread_barrier_wait(&app->barrier) > 0)
CNE_ERR_GOTO(leave,
"Barrier wait failed: %s", strerror(errno));
for (;;) {
sleep(1);
if (app->quit)
break;
page_stats();
}
sleep(1);
pthread_barrier_destroy(&app->barrier);
return EXIT_SUCCESS;
leave:
pthread_barrier_destroy(&app->barrier);
err:
if (tidx >= 0)
return EXIT_FAILURE;
}
CNDP_API int cne_init(void)
CNDP_API int cne_unregister(int tidx)
CNDP_API int cne_on_exit(on_exit_fn_t exit_fn, void *arg, int *signals, int nb_signals)
#define CNE_ERR_GOTO(lbl,...)
CNDP_API int cne_printf_pos(int16_t r, int16_t c, const char *fmt,...)
CNDP_API int cne_printf(const char *fmt,...)
CNDP_API const char * thread_name(int tidx)
CNDP_API int thread_create(const char *name, thd_func_t func, void *arg)
IBROKER_API broker_id_t ibroker_create(const char *name)
IBROKER_API int ibroker_send(broker_id_t bid, service_id_t sid)
IBROKER_API int ibroker_info(broker_id_t bid, ibroker_info_t *info)
IBROKER_API int ibroker_register_sender(broker_id_t bid, service_id_t sid)
IBROKER_API service_id_t ibroker_add_service(broker_id_t id, const char *service, int vector, ibroker_func_t func, void *arg)
IBROKER_API int ibroker_del_service(broker_id_t bid, service_id_t sid)
IBROKER_API int ibroker_id_list(broker_id_t *ids, int len)
IBROKER_API int ibroker_walk(ibroker_walk_t func, void *arg)
#define IBROKER_MAX_SERVICES
IBROKER_API const char * ibroker_service_name(broker_id_t bid, service_id_t sid)