DPDK 25.03.0-rc0
examples/multi_process/simple_mp/mp_commands.c
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2010-2023 Intel Corporation
*/
#include <rte_ring.h>
#include <rte_mempool.h>
#include <rte_string_fns.h>
#include "mp_commands.h"
void
cmd_send_parsed(void *parsed_result,
__rte_unused struct cmdline *cl,
__rte_unused void *data)
{
void *msg = NULL;
struct cmd_send_result *res = parsed_result;
if (rte_mempool_get(message_pool, &msg) < 0)
rte_panic("Failed to get message buffer\n");
strlcpy((char *)msg, res->message, STR_TOKEN_SIZE);
if (rte_ring_enqueue(send_ring, msg) < 0) {
printf("Failed to send message - message discarded\n");
rte_mempool_put(message_pool, msg);
}
}
void
cmd_quit_parsed(__rte_unused void *parsed_result,
struct cmdline *cl,
__rte_unused void *data)
{
quit = 1;
cmdline_quit(cl);
}
void
cmd_help_parsed(__rte_unused void *parsed_result,
struct cmdline *cl,
__rte_unused void *data)
{
cmdline_printf(cl, "Simple demo example of multi-process in RTE\n\n"
"This is a readline-like interface that can be used to\n"
"send commands to the simple app. Commands supported are:\n\n"
"- send [string]\n" "- help\n" "- quit\n\n");
}
#define __rte_unused
Definition: rte_common.h:171
#define rte_panic(...)
Definition: rte_debug.h:43
static __rte_always_inline int rte_mempool_get(struct rte_mempool *mp, void **obj_p)
Definition: rte_mempool.h:1708
static __rte_always_inline void rte_mempool_put(struct rte_mempool *mp, void *obj)
Definition: rte_mempool.h:1487
static __rte_always_inline int rte_ring_enqueue(struct rte_ring *r, void *obj)
Definition: rte_ring.h:336