app/testpmd: add flow flush command
Syntax: flow flush {port_id} Destroy all flow rules on a port. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Olga Shern <olgas@mellanox.com>
This commit is contained in:
parent
311569ab1b
commit
6ae4abac55
@ -811,6 +811,9 @@ static void cmd_help_long_parsed(void *parsed_result,
|
|||||||
" (select|add)\n"
|
" (select|add)\n"
|
||||||
" Set the input set for FDir.\n\n"
|
" Set the input set for FDir.\n\n"
|
||||||
|
|
||||||
|
"flow flush {port_id}\n"
|
||||||
|
" Destroy all flow rules.\n\n"
|
||||||
|
|
||||||
"flow list {port_id} [group {group_id}] [...]\n"
|
"flow list {port_id} [group {group_id}] [...]\n"
|
||||||
" List existing flow rules sorted by priority,"
|
" List existing flow rules sorted by priority,"
|
||||||
" filtered by group identifiers.\n\n"
|
" filtered by group identifiers.\n\n"
|
||||||
|
@ -63,6 +63,7 @@ enum index {
|
|||||||
FLOW,
|
FLOW,
|
||||||
|
|
||||||
/* Sub-level commands. */
|
/* Sub-level commands. */
|
||||||
|
FLUSH,
|
||||||
LIST,
|
LIST,
|
||||||
|
|
||||||
/* List arguments. */
|
/* List arguments. */
|
||||||
@ -179,6 +180,9 @@ static const enum index next_list_attr[] = {
|
|||||||
static int parse_init(struct context *, const struct token *,
|
static int parse_init(struct context *, const struct token *,
|
||||||
const char *, unsigned int,
|
const char *, unsigned int,
|
||||||
void *, unsigned int);
|
void *, unsigned int);
|
||||||
|
static int parse_flush(struct context *, const struct token *,
|
||||||
|
const char *, unsigned int,
|
||||||
|
void *, unsigned int);
|
||||||
static int parse_list(struct context *, const struct token *,
|
static int parse_list(struct context *, const struct token *,
|
||||||
const char *, unsigned int,
|
const char *, unsigned int,
|
||||||
void *, unsigned int);
|
void *, unsigned int);
|
||||||
@ -240,10 +244,19 @@ static const struct token token_list[] = {
|
|||||||
.name = "flow",
|
.name = "flow",
|
||||||
.type = "{command} {port_id} [{arg} [...]]",
|
.type = "{command} {port_id} [{arg} [...]]",
|
||||||
.help = "manage ingress/egress flow rules",
|
.help = "manage ingress/egress flow rules",
|
||||||
.next = NEXT(NEXT_ENTRY(LIST)),
|
.next = NEXT(NEXT_ENTRY
|
||||||
|
(FLUSH,
|
||||||
|
LIST)),
|
||||||
.call = parse_init,
|
.call = parse_init,
|
||||||
},
|
},
|
||||||
/* Sub-level commands. */
|
/* Sub-level commands. */
|
||||||
|
[FLUSH] = {
|
||||||
|
.name = "flush",
|
||||||
|
.help = "destroy all flow rules",
|
||||||
|
.next = NEXT(NEXT_ENTRY(PORT_ID)),
|
||||||
|
.args = ARGS(ARGS_ENTRY(struct buffer, port)),
|
||||||
|
.call = parse_flush,
|
||||||
|
},
|
||||||
[LIST] = {
|
[LIST] = {
|
||||||
.name = "list",
|
.name = "list",
|
||||||
.help = "list existing flow rules",
|
.help = "list existing flow rules",
|
||||||
@ -316,6 +329,31 @@ parse_init(struct context *ctx, const struct token *token,
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Parse tokens for flush command. */
|
||||||
|
static int
|
||||||
|
parse_flush(struct context *ctx, const struct token *token,
|
||||||
|
const char *str, unsigned int len,
|
||||||
|
void *buf, unsigned int size)
|
||||||
|
{
|
||||||
|
struct buffer *out = buf;
|
||||||
|
|
||||||
|
/* Token name must match. */
|
||||||
|
if (parse_default(ctx, token, str, len, NULL, 0) < 0)
|
||||||
|
return -1;
|
||||||
|
/* Nothing else to do if there is no buffer. */
|
||||||
|
if (!out)
|
||||||
|
return len;
|
||||||
|
if (!out->command) {
|
||||||
|
if (ctx->curr != FLUSH)
|
||||||
|
return -1;
|
||||||
|
if (sizeof(*out) > size)
|
||||||
|
return -1;
|
||||||
|
out->command = ctx->curr;
|
||||||
|
ctx->object = out;
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
/** Parse tokens for list command. */
|
/** Parse tokens for list command. */
|
||||||
static int
|
static int
|
||||||
parse_list(struct context *ctx, const struct token *token,
|
parse_list(struct context *ctx, const struct token *token,
|
||||||
@ -698,6 +736,9 @@ static void
|
|||||||
cmd_flow_parsed(const struct buffer *in)
|
cmd_flow_parsed(const struct buffer *in)
|
||||||
{
|
{
|
||||||
switch (in->command) {
|
switch (in->command) {
|
||||||
|
case FLUSH:
|
||||||
|
port_flow_flush(in->port);
|
||||||
|
break;
|
||||||
case LIST:
|
case LIST:
|
||||||
port_flow_list(in->port, in->args.list.group_n,
|
port_flow_list(in->port, in->args.list.group_n,
|
||||||
in->args.list.group);
|
in->args.list.group);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user