summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Wiles <keith.wiles@intel.com>2017-10-30 13:23:54 -0500
committerKeith Wiles <keith.wiles@intel.com>2017-11-25 07:48:59 -0600
commitd23650740402c7f511e502acab3ab018163c4976 (patch)
tree8829c46071e56f36b2b45131e2558aaa38c9ce5c
parentb1316f99e07f4c2dd16d713bc9cca6ac40154913 (diff)
downloaddpdk-draft-cli-d23650740402c7f511e502acab3ab018163c4976.zip
dpdk-draft-cli-d23650740402c7f511e502acab3ab018163c4976.tar.gz
dpdk-draft-cli-d23650740402c7f511e502acab3ab018163c4976.tar.xz
merge from master tree
Signed-off-by: Keith Wiles <keith.wiles@intel.com>
-rw-r--r--examples/cli/main.c4
-rw-r--r--lib/librte_cli/cli.c53
-rw-r--r--lib/librte_cli/cli.h17
-rw-r--r--lib/librte_cli/cli_cmap.c38
-rw-r--r--lib/librte_cli/cli_cmap.h8
-rw-r--r--lib/librte_cli/cli_cmds.c1
-rw-r--r--lib/librte_cli/cli_scrn.c1
-rw-r--r--lib/librte_cli/cli_scrn.h14
8 files changed, 49 insertions, 87 deletions
diff --git a/examples/cli/main.c b/examples/cli/main.c
index fab4a4b..21945c8 100644
--- a/examples/cli/main.c
+++ b/examples/cli/main.c
@@ -116,8 +116,8 @@ static struct cli_map show_map[] = {
static const char *show_help[] = {
"show <portlist>",
- "show <portlist> mac <ether_addr>",
- "show <portlist> vlan <vlanid> mac <ether_addr>",
+ "show <portlist> mac",
+ "show <portlist> vlan",
"show <portlist> [vlan|mac]",
CLI_HELP_PAUSE,
NULL
diff --git a/lib/librte_cli/cli.c b/lib/librte_cli/cli.c
index f72f6e0..7edb5f7 100644
--- a/lib/librte_cli/cli.c
+++ b/lib/librte_cli/cli.c
@@ -761,9 +761,9 @@ __default_prompt(int cont)
if (strlen(str) > 1) /* trim the trailing '/' from string */
str[strlen(str) - 1] = '\0';
- vt100_color(SCRN_GREEN, SCRN_NO_CHANGE, SCRN_BOLD);
+ vt100_color(SCRN_GREEN, SCRN_NO_CHANGE, SCRN_OFF);
cli_printf("%s:", (cont) ? " >> " : "DPDK-cli");
- vt100_color(SCRN_BLUE, SCRN_NO_CHANGE, SCRN_BOLD);
+ vt100_color(SCRN_CYAN, SCRN_NO_CHANGE, SCRN_OFF);
cli_printf("%s", str);
vt100_color(SCRN_DEFAULT_FG, SCRN_DEFAULT_BG, SCRN_OFF);
cli_printf("> ");
@@ -771,8 +771,7 @@ __default_prompt(int cont)
/* Main entry point to create a CLI system */
int
-cli_create(cli_prompt_t prompt, cli_tree_t default_func,
- int nb_entries, uint32_t nb_hist)
+cli_create(int nb_entries, uint32_t nb_hist)
{
int i;
size_t size;
@@ -789,6 +788,8 @@ cli_create(cli_prompt_t prompt, cli_tree_t default_func,
this_cli = cli;
+ cli->prompt = __default_prompt;
+
if (nb_entries == 0)
nb_entries = CLI_DEFAULT_NB_NODES;
else if (nb_entries == -1) {
@@ -832,9 +833,6 @@ cli_create(cli_prompt_t prompt, cli_tree_t default_func,
if (!cli->argv)
goto error_exit;
- /* Set the user or default prompt routine */
- cli->prompt = (prompt == NULL) ? __default_prompt : prompt;
-
/* Create the pool for the number of nodes */
node = cli->node_mem;
for (i = 0; i < nb_entries; i++, node++)
@@ -866,14 +864,6 @@ cli_create(cli_prompt_t prompt, cli_tree_t default_func,
if (!cli->env)
goto error_exit;
- /* when null call our default tree setup routine */
- if (default_func == NULL)
- default_func = cli_default_tree_init;
-
- /* now call the user supplied func or ours if default_func was NULL */
- if (default_func())
- goto error_exit;
-
return 0;
error_exit:
@@ -881,6 +871,12 @@ error_exit:
return -1;
}
+int
+cli_create_with_defaults(void)
+{
+ return cli_create(CLI_DEFAULT_NODES, CLI_DEFAULT_HIST_LINES);
+}
+
/* Cleanup the CLI allocation of memory */
void
cli_destroy(void)
@@ -905,20 +901,35 @@ cli_destroy(void)
this_cli = NULL;
}
+int
+cli_setup(cli_prompt_t prompt, cli_tree_t default_func)
+{
+ if (!this_cli)
+ return -1;
+
+ /* Set the user or default prompt routine */
+ this_cli->prompt = (prompt == NULL) ? __default_prompt : prompt;
+
+ /* when null call our default tree setup routine */
+ if (default_func == NULL)
+ default_func = cli_default_tree_init;
+
+ /* now call the user supplied func or ours if default_func was NULL */
+ return default_func();
+}
+
/* Helper routine around the cli_create() routine */
int
-cli_create_with_defaults(void)
+cli_setup_with_defaults(void)
{
- return cli_create(NULL, NULL, CLI_DEFAULT_NODES,
- CLI_DEFAULT_HIST_LINES);
+ return cli_setup(NULL, NULL);
}
/* Helper routine around the cli_create() routine */
int
-cli_create_with_tree(cli_tree_t tree)
+cli_setup_with_tree(cli_tree_t tree)
{
- return cli_create(NULL, tree, CLI_DEFAULT_NODES,
- CLI_DEFAULT_HIST_LINES);
+ return cli_setup(NULL, tree);
}
/* Add a new prompt routine to the CLI system */
diff --git a/lib/librte_cli/cli.h b/lib/librte_cli/cli.h
index 09b9e49..5359316 100644
--- a/lib/librte_cli/cli.h
+++ b/lib/librte_cli/cli.h
@@ -794,17 +794,26 @@ void cli_input(char *str, int n);
* @return
* 0 on success or -1
*/
-int cli_create(cli_prompt_t prompt_func, cli_tree_t tree_func, int nb_entries,
- uint32_t nb_hist);
+int cli_create(int nb_entries, uint32_t nb_hist);
/**
- * Create the CLI engine using system defaults.
+ * Create the CLI engine with defaults
*
* @return
* 0 on success or -1
*/
int cli_create_with_defaults(void);
+int cli_setup(cli_prompt_t prompt, cli_tree_t default_func);
+
+/**
+ * Create the CLI engine using system defaults.
+ *
+ * @return
+ * 0 on success or -1
+ */
+int cli_setup_with_defaults(void);
+
/**
* Create the CLI engine using system defaults and supplied tree init function.
*
@@ -814,7 +823,7 @@ int cli_create_with_defaults(void);
* @return
* 0 on success or -1
*/
-int cli_create_with_tree(cli_tree_t tree);
+int cli_setup_with_tree(cli_tree_t tree);
/**
* Set the CLI prompt function pointer
diff --git a/lib/librte_cli/cli_cmap.c b/lib/librte_cli/cli_cmap.c
index 42a50f4..b289c6e 100644
--- a/lib/librte_cli/cli_cmap.c
+++ b/lib/librte_cli/cli_cmap.c
@@ -337,41 +337,3 @@ sct(struct cmap *cm, uint8_t s, uint8_t c, uint8_t t) {
return 0;
}
-
-void
-cmap_dump(FILE *f)
-{
- struct cmap *c = cmap_create();
- int i;
-
- if (!f)
- f = stdout;
-
- fprintf(f, "CPU : %s", c->model);
- fprintf(f, " %d lcores, %u socket%s, %u core%s per socket and "
- "%u thread%s per core\n",
- c->num_cores,
- c->sid_cnt, c->sid_cnt > 1 ? "s" : "",
- c->cid_cnt, c->cid_cnt > 1 ? "s" : "",
- c->tid_cnt, c->tid_cnt > 1 ? "s" : "");
-
- fprintf(f, "Socket : ");
- for (i = 0; i < c->sid_cnt; i++)
- fprintf(f, "%4d ", i);
-
- for (i = 0; i < c->cid_cnt; i++) {
- fprintf(f, " Core %3d : [%2d,%2d] ", i,
- sct(c, 0, i, 0), sct(c, 0, i, 1));
- if (c->sid_cnt > 1)
- fprintf(f, "[%2d,%2d] ",
- sct(c, 1, i, 0), sct(c, 1, i, 1));
- if (c->sid_cnt > 2)
- fprintf(f, "[%2d,%2d] ",
- sct(c, 2, i, 0), sct(c, 2, i, 1));
- if (c->sid_cnt > 3)
- fprintf(f, "[%2d,%2d] ",
- sct(c, 3, i, 0), sct(c, 3, i, 1));
- fprintf(f, "\n");
- }
- cmap_free(c);
-}
diff --git a/lib/librte_cli/cli_cmap.h b/lib/librte_cli/cli_cmap.h
index 034237a..d80ba17 100644
--- a/lib/librte_cli/cli_cmap.h
+++ b/lib/librte_cli/cli_cmap.h
@@ -196,12 +196,4 @@ cmap_cnt(lcore_t *lc, getter_fn get)
return cnt + 1;
}
-/**
- * Dump out the CMAP data
- *
- * @param f
- * The file descriptor for output
- */
-void cmap_dump(FILE *f);
-
#endif /*_CLI_CMAP_H */
diff --git a/lib/librte_cli/cli_cmds.c b/lib/librte_cli/cli_cmds.c
index 9e8ca55..54a1bac 100644
--- a/lib/librte_cli/cli_cmds.c
+++ b/lib/librte_cli/cli_cmds.c
@@ -388,6 +388,7 @@ core_cmd(int argc __rte_unused, char **argv __rte_unused)
cli_printf("Socket : ");
for (i = 0; i < c->sid_cnt; i++)
cli_printf("%4d ", i);
+ cli_printf("\n");
for (i = 0; i < c->cid_cnt; i++) {
cli_printf(" Core %3d : [%2d,%2d] ", i,
diff --git a/lib/librte_cli/cli_scrn.c b/lib/librte_cli/cli_scrn.c
index b8c1e9b..3c443eb 100644
--- a/lib/librte_cli/cli_scrn.c
+++ b/lib/librte_cli/cli_scrn.c
@@ -40,7 +40,6 @@
#include <stdarg.h>
#include <unistd.h>
-#include <rte_config.h>
#include <rte_atomic.h>
#include <rte_malloc.h>
#include <rte_spinlock.h>
diff --git a/lib/librte_cli/cli_scrn.h b/lib/librte_cli/cli_scrn.h
index 762f55a..1faa118 100644
--- a/lib/librte_cli/cli_scrn.h
+++ b/lib/librte_cli/cli_scrn.h
@@ -262,21 +262,9 @@ scrn_center_col(int16_t ncols, const char *msg)
static __inline__ void
scrn_erase(int16_t nrows)
{
- int16_t i, cnt;
- const char *nl = "\n\n\n\n\n\n\n\n";
- scrn_setw(1); /* Clear the window to full */
- /* screen. */
+ scrn_setw(1); /* Clear the window to full screen. */
scrn_pos(nrows + 1, 1); /* Put cursor on the last row. */
-
- /* Scroll the screen to clear the screen and keep the previous information */
- /* in scrollbar. */
- for (i = 0, cnt = 0; i < (nrows / (int16_t)strlen(nl)); i++, cnt += strlen(nl))
- scrn_printf(0, 0, "%s", nl);
-
- /* Scroll the last set of rows. */
- for (i = cnt; i < nrows; i++)
- scrn_printf(0, 0, "\n");
}
/** Output a string at a row/column for a number of times */