#include "bpf_cmd.h"
static struct cmdline *testpmd_cl;
+static cmdline_parse_ctx_t *main_ctx;
+static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head =
+ TAILQ_HEAD_INITIALIZER(driver_commands_head);
static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
" help registers : Reading and setting port registers.\n"
" help filters : Filters configuration help.\n"
" help traffic_management : Traffic Management commands.\n"
- " help devices : Device related cmds.\n"
+ " help devices : Device related commands.\n"
+ " help drivers : Driver specific commands.\n"
" help all : All of the above sections.\n\n"
);
);
}
+ if (show_all || !strcmp(res->section, "drivers")) {
+ struct testpmd_driver_commands *c;
+ unsigned int i;
+
+ cmdline_printf(
+ cl,
+ "\n"
+ "Driver specific:\n"
+ "----------------\n"
+ );
+ TAILQ_FOREACH(c, &driver_commands_head, next) {
+ for (i = 0; c->commands[i].ctx != NULL; i++)
+ cmdline_printf(cl, "%s\n", c->commands[i].help);
+ }
+ }
}
static cmdline_parse_token_string_t cmd_help_long_help =
static cmdline_parse_token_string_t cmd_help_long_section =
TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
- "all#control#display#config#"
- "ports#registers#filters#traffic_management#devices");
+ "all#control#display#config#ports#registers#"
+ "filters#traffic_management#devices#drivers");
static cmdline_parse_inst_t cmd_help_long = {
.f = cmd_help_long_parsed,
.data = NULL,
.help_str = "help all|control|display|config|ports|register|"
- "filters|traffic_management|devices: "
+ "filters|traffic_management|devices|drivers: "
"Show help",
.tokens = {
(void *)&cmd_help_long_help,
/* ******************************************************************************** */
/* list of instructions */
-static cmdline_parse_ctx_t main_ctx[] = {
+static cmdline_parse_ctx_t builtin_ctx[] = {
(cmdline_parse_inst_t *)&cmd_help_brief,
(cmdline_parse_inst_t *)&cmd_help_long,
(cmdline_parse_inst_t *)&cmd_quit,
NULL,
};
+void
+testpmd_add_driver_commands(struct testpmd_driver_commands *c)
+{
+ TAILQ_INSERT_TAIL(&driver_commands_head, c, next);
+}
+
+int
+init_cmdline(void)
+{
+ struct testpmd_driver_commands *c;
+ unsigned int count;
+ unsigned int i;
+
+ /* initialize non-constant commands */
+ cmd_set_fwd_mode_init();
+ cmd_set_fwd_retry_mode_init();
+
+ count = 0;
+ for (i = 0; builtin_ctx[i] != NULL; i++)
+ count++;
+ TAILQ_FOREACH(c, &driver_commands_head, next) {
+ for (i = 0; c->commands[i].ctx != NULL; i++)
+ count++;
+ }
+
+ /* cmdline expects a NULL terminated array */
+ main_ctx = calloc(count + 1, sizeof(main_ctx[0]));
+ if (main_ctx == NULL)
+ return -1;
+
+ count = 0;
+ for (i = 0; builtin_ctx[i] != NULL; i++, count++)
+ main_ctx[count] = builtin_ctx[i];
+ TAILQ_FOREACH(c, &driver_commands_head, next) {
+ for (i = 0; c->commands[i].ctx != NULL; i++, count++)
+ main_ctx[count] = c->commands[i].ctx;
+ }
+
+ return 0;
+}
+
/* read cmdline commands from file */
void
cmdline_read_from_file(const char *filename)
prompt(void)
{
int ret;
- /* initialize non-constant commands */
- cmd_set_fwd_mode_init();
- cmd_set_fwd_retry_mode_init();
testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
if (testpmd_cl == NULL)
#include <rte_gso.h>
#endif
#include <rte_os_shim.h>
+#include <rte_ethdev.h>
+#include <rte_flow.h>
+#include <rte_mbuf_dyn.h>
+
#include <cmdline.h>
+#include <cmdline_parse.h>
+
#include <sys/queue.h>
#ifdef RTE_HAS_JANSSON
#include <jansson.h>
unsigned int *parsed_items, int check_unique_values);
void launch_args_parse(int argc, char** argv);
void cmdline_read_from_file(const char *filename);
+int init_cmdline(void);
void prompt(void);
void prompt_exit(void);
void nic_stats_display(portid_t port_id);
struct rte_flow_item **pattern,
struct rte_flow_action **actions);
+/* For registering driver specific testpmd commands. */
+struct testpmd_driver_commands {
+ TAILQ_ENTRY(testpmd_driver_commands) next;
+ struct {
+ cmdline_parse_inst_t *ctx;
+ const char *help;
+ } commands[];
+};
+
+void testpmd_add_driver_commands(struct testpmd_driver_commands *c);
+#define TESTPMD_ADD_DRIVER_COMMANDS(c) \
+RTE_INIT(__##c) \
+{ \
+ testpmd_add_driver_commands(&c); \
+}
+
/*
* Work-around of a compilation error with ICC on invocations of the
* rte_be_to_cpu_16() function.
.. code-block:: console
testpmd> help
-
- help control : Start and stop forwarding.
- help display : Displaying port, stats and config information.
- help config : Configuration information.
- help ports : Configuring ports.
- help registers : Reading and setting port registers.
- help filters : Filters configuration help.
- help all : All of the above sections.
-
+ Help is available for the following sections:
+
+ help control : Start and stop forwarding.
+ help display : Displaying port, stats and config information.
+ help config : Configuration information.
+ help ports : Configuring ports.
+ help registers : Reading and setting port registers.
+ help filters : Filters configuration help.
+ help traffic_management : Traffic Management commands.
+ help devices : Device related commands.
+ help drivers : Driver specific commands.
+ help all : All of the above sections.
Command File Functions
----------------------
testpmd> flow create 0 ingress pattern eth / ipv4 / udp / flex item is 3 pattern is 2 / end actions mark id 1 / queue index 0 / end
Flow rule #0 created
+
+Driver specific commands
+------------------------
+
+Some drivers provide specific features.
+See: