From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adrien Mazarguil Subject: [PATCH v5 10/26] app/testpmd: add flow flush command Date: Wed, 21 Dec 2016 15:51:26 +0100 Message-ID: <2693be7a62da38b5059006fd1b9144e68054f280.1482331076.git.adrien.mazarguil@6wind.com> References: To: dev@dpdk.org Return-path: Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) by dpdk.org (Postfix) with ESMTP id 6E02E10C6C for ; Wed, 21 Dec 2016 15:52:22 +0100 (CET) Received: by mail-wm0-f41.google.com with SMTP id a197so150358184wmd.0 for ; Wed, 21 Dec 2016 06:52:22 -0800 (PST) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id s20sm3745662wmb.9.2016.12.21.06.52.20 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 21 Dec 2016 06:52:21 -0800 (PST) In-Reply-To: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Syntax: flow flush {port_id} Destroy all flow rules on a port. Signed-off-by: Adrien Mazarguil Acked-by: Olga Shern --- app/test-pmd/cmdline.c | 3 +++ app/test-pmd/cmdline_flow.c | 43 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 0dc6c63..6e2b289 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -811,6 +811,9 @@ static void cmd_help_long_parsed(void *parsed_result, " (select|add)\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" " List existing flow rules sorted by priority," " filtered by group identifiers.\n\n" diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 7a2aaa4..5972b80 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -63,6 +63,7 @@ enum index { FLOW, /* Sub-level commands. */ + FLUSH, LIST, /* List arguments. */ @@ -179,6 +180,9 @@ static const enum index next_list_attr[] = { static int parse_init(struct context *, const struct token *, const char *, 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 *, const char *, unsigned int, void *, unsigned int); @@ -240,10 +244,19 @@ static const struct token token_list[] = { .name = "flow", .type = "{command} {port_id} [{arg} [...]]", .help = "manage ingress/egress flow rules", - .next = NEXT(NEXT_ENTRY(LIST)), + .next = NEXT(NEXT_ENTRY + (FLUSH, + LIST)), .call = parse_init, }, /* 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] = { .name = "list", .help = "list existing flow rules", @@ -316,6 +329,31 @@ parse_init(struct context *ctx, const struct token *token, 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. */ static int parse_list(struct context *ctx, const struct token *token, @@ -698,6 +736,9 @@ static void cmd_flow_parsed(const struct buffer *in) { switch (in->command) { + case FLUSH: + port_flow_flush(in->port); + break; case LIST: port_flow_list(in->port, in->args.list.group_n, in->args.list.group); -- 2.1.4