#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"
);
" Set the queue priority flow control parameter on a"
" given Rx and Tx queues of a port.\n\n"
+ "set port (port_id) rxq (queue_id) avail_thresh (0..99)>\n "
+ " set available descriptors threshold for Rx queue\n\n"
+
"set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
" Set statistics mapping (qmapping 0..15) for RX/TX"
" queue on port.\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,
},
};
+/* *** set available descriptors threshold for an RxQ of a port *** */
+struct cmd_set_rxq_avail_thresh_result {
+ cmdline_fixed_string_t set;
+ cmdline_fixed_string_t port;
+ uint16_t port_num;
+ cmdline_fixed_string_t rxq;
+ uint16_t rxq_num;
+ cmdline_fixed_string_t avail_thresh;
+ uint8_t avail_thresh_num;
+};
+
+static void cmd_set_rxq_avail_thresh_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_set_rxq_avail_thresh_result *res = parsed_result;
+ int ret = 0;
+
+ if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
+ && (strcmp(res->rxq, "rxq") == 0)
+ && (strcmp(res->avail_thresh, "avail_thresh") == 0))
+ ret = set_rxq_avail_thresh(res->port_num, res->rxq_num,
+ res->avail_thresh_num);
+ if (ret < 0)
+ printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret));
+
+}
+
+static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
+ set, "set");
+static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
+ port, "port");
+static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum =
+ TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
+ port_num, RTE_UINT16);
+static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
+ rxq, "rxq");
+static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum =
+ TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
+ rxq_num, RTE_UINT16);
+static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
+ avail_thresh, "avail_thresh");
+static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum =
+ TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
+ avail_thresh_num, RTE_UINT8);
+
+static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = {
+ .f = cmd_set_rxq_avail_thresh_parsed,
+ .data = (void *)0,
+ .help_str =
+ "set port <port_id> rxq <queue_id> avail_thresh <0..99>: "
+ "Set available descriptors threshold for Rx queue",
+ .tokens = {
+ (void *)&cmd_set_rxq_avail_thresh_set,
+ (void *)&cmd_set_rxq_avail_thresh_port,
+ (void *)&cmd_set_rxq_avail_thresh_portnum,
+ (void *)&cmd_set_rxq_avail_thresh_rxq,
+ (void *)&cmd_set_rxq_avail_thresh_rxqnum,
+ (void *)&cmd_set_rxq_avail_thresh_avail_thresh,
+ (void *)&cmd_set_rxq_avail_thresh_avail_threshnum,
+ NULL,
+ },
+};
+
/* show port supported ptypes */
/* Common result structure for show port ptypes */
/* ******************************************************************************** */
/* 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,
(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
(cmdline_parse_inst_t *)&cmd_show_fec_mode,
(cmdline_parse_inst_t *)&cmd_set_fec_mode,
+ (cmdline_parse_inst_t *)&cmd_set_rxq_avail_thresh,
(cmdline_parse_inst_t *)&cmd_show_capability,
(cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
(cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
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)