From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by dpdk.org (Postfix) with ESMTP id 2BF2CF91F for ; Fri, 16 Dec 2016 17:25:57 +0100 (CET) Received: by mail-wm0-f42.google.com with SMTP id g23so38760930wme.1 for ; Fri, 16 Dec 2016 08:25:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=8JcEe8d0XlOvEKC4UURP3sr0rQDphAIizndBk16YUyU=; b=gb8b+0wZy//qOhFKWXiZ7E8UDstbF/tgWKeze3cIiixLbqDkXuErQL/ESnTgJ+zRNr lgv/fvJkJ0m8VI7oZSXARpEwNYQUeGUblICQgtrHPpRHUdCegJByi5ZLcMWtdDnYWKPK cuqZH3KS9pMZY9HqNA6Paw3Bep3NJ1x/mj1wNwa5S/EPT/X+39kHuJghINhmaZZYtezp +jQ2O6NlEdQXW6TYYE9WprzL/PTBAVJyf/ssfXi31O/vpHp/CMv1aVsxXVisoce5CtKh a2Sh6PhvsRotp8e5bMmbTKN3b/Gx8XxjlvsGmqPA7Pt+DkTwy4eHN5TFqHCDOjSaZR/5 Q7bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=8JcEe8d0XlOvEKC4UURP3sr0rQDphAIizndBk16YUyU=; b=EiQGyywDfs1dxhcX9CwcLZAeZRAPLEguuYwTryb2jypLta3Q9jvq7VZyIPKiBIgow+ ntnF2F9RCandIFEVSgRRQuxSppmZOl77r3vCa2GZF2uxIt4xAxvShJIF4AYZlXXffCP7 jS+uJzt5mPl57nrnEe401cEV09xrAvI3vZcRje49OFrkxo+qAx1EypDLpktVFctV5GP9 f7jZB2eeSIBCU5id0hOMJljQQTUtKb+UbhKQumb1weoaeH4XcBGKQEdEoBGBcCmK87gm DG3zdgzz2JqnB7fPmK4aOjQzVZTRuvBRMwC4Q0L1OdlTVUm2FQTe3rGwkD/eKLmi47QS UXAw== X-Gm-Message-State: AIkVDXLNZwIiitlfZ4fa7mKYohbKX4WU7Kt/q4xOIhksXUw6x45MlNOgZ9UleV2/7p2tQ6BZ X-Received: by 10.28.142.5 with SMTP id q5mr3805665wmd.78.1481905556583; Fri, 16 Dec 2016 08:25:56 -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 o132sm4016614wmo.17.2016.12.16.08.25.55 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 16 Dec 2016 08:25:55 -0800 (PST) From: Adrien Mazarguil To: dev@dpdk.org Date: Fri, 16 Dec 2016 17:25:07 +0100 Message-Id: <9d51ff1f1844a058e3e88430a01b9524ca61af8c.1481903839.git.adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 10/25] app/testpmd: add flow flush command X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2016 16:25:57 -0000 Syntax: flow flush {port_id} Destroy all flow rules on a port. Signed-off-by: Adrien Mazarguil --- 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 bd3da38..49578eb 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