From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by dpdk.org (Postfix) with ESMTP id 26A7C567E for ; Wed, 16 Nov 2016 17:24:23 +0100 (CET) Received: by mail-wm0-f44.google.com with SMTP id g23so250208308wme.1 for ; Wed, 16 Nov 2016 08:24:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sCC9giF78jSCc0KM6aytc+dDIeRhXxOIarEcVbS82Fw=; b=Rn2maFq3n1JYNybyee8/AF8B4mOuo7PAIRwTV6ZyFUS1oYPyA3wnJJXQsRzi6P4Xw8 HW1ChhSUnMcZyiNSiPJFE37ld36SFpJtF2RxYm7W4+rZtvhbyeoDatLxQWpixCqP6hO/ Qd4vmf7KKSyNErludoujl1f+StsqPWDQJkecWOIwkWztW7ugX1i3bRIkb2VG2j2bTqoi Y5l1TqFqmMNgIX8NA1qfTjL5IiEGxkbTsDRmTmgoTRj6E7v6fqCzO/HddIU8Vl0ijKTp nGF3YzTlMnbVan6C3zhgItjxlSr/f0Y1oTT4dc2KHyiSMt9QvQ3u4qfcrq/cLI9iEggK D0Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sCC9giF78jSCc0KM6aytc+dDIeRhXxOIarEcVbS82Fw=; b=f9YRB0k4hTwLHUXxJj8d5u2jp23xIla2r3U/jnlrMMHjdEYfTkdb368yCgKzBQn+PP r+J/1yB5RjdbSIdAM6T3MUJO0ypM/crKxVPzZ2zUOYXm0CE8PnXPupZFO/qaSbB6xgkC IbSgEGcTQKiEdR6C4euBMXX3KN+F2OyzVF+1lnHUUjWShXpk1MmQxzfZsaL2jV0u7XOF Wh81geh60HiqGQZoD4GrUQPgB0XkuCmLK4ZkotDUKLK7JgOwOv/r4+Ps82mPcWNMebPY tDuy4ATG4RrzDIgNudTdGgwSlDmXaIDU0B/5g8D9lhIKt6f2Hg9ZzYSCWEm1K4/iHRfy 8z/Q== X-Gm-Message-State: ABUngvd+1NaW86s9pnnpaVNX5vWkP2kwIZTIAzmFBPnhZuguX7j2cNbMQZ+I9QgJ7Xxz5E2D X-Received: by 10.194.114.100 with SMTP id jf4mr2427965wjb.135.1479313462716; Wed, 16 Nov 2016 08:24: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 js10sm41319931wjb.19.2016.11.16.08.24.21 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 16 Nov 2016 08:24:22 -0800 (PST) From: Adrien Mazarguil To: dev@dpdk.org Cc: Thomas Monjalon , Pablo de Lara , Olivier Matz Date: Wed, 16 Nov 2016 17:23:34 +0100 Message-Id: <9c511c4db9a3ef27cfa421b4a4951192e652fab9.1479309720.git.adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH 08/22] app/testpmd: add flow flush command X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Nov 2016 16:24:23 -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 09357c0..9f124fc 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 727fe78..414bacc 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