f-stack/dpdk/examples/multi_process/simple_mp/mp_commands.c

46 lines
1.1 KiB
C
Raw Normal View History

2019-06-25 11:12:58 +00:00
/* SPDX-License-Identifier: BSD-3-Clause
2025-01-10 11:50:43 +00:00
* Copyright(c) 2010-2023 Intel Corporation
2017-04-21 10:43:26 +00:00
*/
#include <rte_ring.h>
#include <rte_mempool.h>
#include <rte_string_fns.h>
#include "mp_commands.h"
2025-01-10 11:50:43 +00:00
void
cmd_send_parsed(void *parsed_result,
2021-02-05 08:48:47 +00:00
__rte_unused struct cmdline *cl,
__rte_unused void *data)
2017-04-21 10:43:26 +00:00
{
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");
2020-06-18 16:55:50 +00:00
strlcpy((char *)msg, res->message, STR_TOKEN_SIZE);
2017-04-21 10:43:26 +00:00
if (rte_ring_enqueue(send_ring, msg) < 0) {
printf("Failed to send message - message discarded\n");
rte_mempool_put(message_pool, msg);
}
}
2025-01-10 11:50:43 +00:00
void
cmd_quit_parsed(__rte_unused void *parsed_result,
2017-04-21 10:43:26 +00:00
struct cmdline *cl,
2021-02-05 08:48:47 +00:00
__rte_unused void *data)
2017-04-21 10:43:26 +00:00
{
quit = 1;
cmdline_quit(cl);
}
2025-01-10 11:50:43 +00:00
void
cmd_help_parsed(__rte_unused void *parsed_result,
2017-04-21 10:43:26 +00:00
struct cmdline *cl,
2021-02-05 08:48:47 +00:00
__rte_unused void *data)
2017-04-21 10:43:26 +00:00
{
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");
}