13998e2a0SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
2*43f062acSBruce Richardson * Copyright(c) 2010-2023 Intel Corporation
3af75078fSIntel */
4af75078fSIntel #include <rte_ring.h>
5af75078fSIntel #include <rte_mempool.h>
6af75078fSIntel #include <rte_string_fns.h>
7af75078fSIntel
8af75078fSIntel #include "mp_commands.h"
9af75078fSIntel
10*43f062acSBruce Richardson void
cmd_send_parsed(void * parsed_result,__rte_unused struct cmdline * cl,__rte_unused void * data)11*43f062acSBruce Richardson cmd_send_parsed(void *parsed_result,
12f2fc83b4SThomas Monjalon __rte_unused struct cmdline *cl,
13f2fc83b4SThomas Monjalon __rte_unused void *data)
14af75078fSIntel {
15a974564bSIntel void *msg = NULL;
16af75078fSIntel struct cmd_send_result *res = parsed_result;
17af75078fSIntel
18af75078fSIntel if (rte_mempool_get(message_pool, &msg) < 0)
19af75078fSIntel rte_panic("Failed to get message buffer\n");
20f9acaf84SBruce Richardson strlcpy((char *)msg, res->message, STR_TOKEN_SIZE);
21af75078fSIntel if (rte_ring_enqueue(send_ring, msg) < 0) {
22af75078fSIntel printf("Failed to send message - message discarded\n");
23af75078fSIntel rte_mempool_put(message_pool, msg);
24af75078fSIntel }
25af75078fSIntel }
26af75078fSIntel
27*43f062acSBruce Richardson void
cmd_quit_parsed(__rte_unused void * parsed_result,struct cmdline * cl,__rte_unused void * data)28*43f062acSBruce Richardson cmd_quit_parsed(__rte_unused void *parsed_result,
29af75078fSIntel struct cmdline *cl,
30f2fc83b4SThomas Monjalon __rte_unused void *data)
31af75078fSIntel {
32af75078fSIntel quit = 1;
33af75078fSIntel cmdline_quit(cl);
34af75078fSIntel }
35af75078fSIntel
36*43f062acSBruce Richardson void
cmd_help_parsed(__rte_unused void * parsed_result,struct cmdline * cl,__rte_unused void * data)37*43f062acSBruce Richardson cmd_help_parsed(__rte_unused void *parsed_result,
38af75078fSIntel struct cmdline *cl,
39f2fc83b4SThomas Monjalon __rte_unused void *data)
40af75078fSIntel {
41af75078fSIntel cmdline_printf(cl, "Simple demo example of multi-process in RTE\n\n"
42af75078fSIntel "This is a readline-like interface that can be used to\n"
43af75078fSIntel "send commands to the simple app. Commands supported are:\n\n"
44af75078fSIntel "- send [string]\n" "- help\n" "- quit\n\n");
45af75078fSIntel }
46