From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wj0-f181.google.com (mail-wj0-f181.google.com [209.85.210.181]) by dpdk.org (Postfix) with ESMTP id DDE3CFAE8 for ; Tue, 20 Dec 2016 10:45:11 +0100 (CET) Received: by mail-wj0-f181.google.com with SMTP id xy5so170924549wjc.0 for ; Tue, 20 Dec 2016 01:45:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8g7JUCL3oDYSsFc0aT7qV+QbMMW9OZf/IjKt3zqRe9c=; b=pIykVkA0OXQPL+dslPfXsNyyV9jNOl/6/vNk5eTvgJQSfCxsv5gP5r2emLiKjvtUAe oao3ngSQUdqn2IwDtRGtxOOADNr5E6mzrl0OciXiEQdP5/fkFXcbkVHX742s0Mu6CyaB AmF8AisRydsnInBQUg1WZGwmYdU1YQbE6lIk39vPtUOASkWd7bJO/y8eUYhPwswZUz9w HoTPrpQMFU7AEVho3/8eeRz9u2d31Ukg5gEeS2Aue8+BpIOoDoJPzM+cHojppQf5d86o y7nnkHePFld5M2F6t6hEtDllv1nUtd5sPEqSVwVoHYwFWmPfndNJklr4e6iWkLGFRUPm JpbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8g7JUCL3oDYSsFc0aT7qV+QbMMW9OZf/IjKt3zqRe9c=; b=hlRW0WplOZ/+mgrRn8XK877JgQ3KhaEqwfnDVICHs9Q6GhEByqHmVeoI77lT9IwiEK jNox5/ZcWtFZWN2TsHNymjCFLTFHuXVjdTvo7h4di23jOUr5nHR533+k7qL2flZ3l+lu eYZkojGB7Nl9RJyvdm4huXOpvNsi/g3TKj+UWrNPG5uTLwrr1AQaEKy9lx3EJ8aYYB8Z PKRMePoaxx8hmzG1+v/auqk7MXuT+bk6LBmal6l/1M1feAWr2P4RUxYlO2dqzK85NIdG yVzCD1aNfD9TLIKK5PbbNd2JtmzCbIu2+8HFe9b/bCl249TBs4hSmj31yV53voK99mfb Rg7w== X-Gm-Message-State: AIkVDXLzTBG0UUINzTw9kguhg/GLobSgwpAQFrMJdyGNq/OsD7OPQ/1d0ANrJMACTIRSymPp X-Received: by 10.194.86.165 with SMTP id q5mr17049615wjz.178.1482227111634; Tue, 20 Dec 2016 01:45:11 -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 b3sm24673489wjy.40.2016.12.20.01.45.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Dec 2016 01:45:11 -0800 (PST) Date: Tue, 20 Dec 2016 10:45:03 +0100 From: Adrien Mazarguil To: "Zhao1, Wei" Cc: "dev@dpdk.org" Message-ID: <20161220094503.GP10340@6wind.com> References: <8a8d3efbf0258cc3afa5b334b180e049ce2f9ee3.1482168851.git.adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [dpdk-dev] [PATCH v3 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: Tue, 20 Dec 2016 09:45:12 -0000 Hi Wei, On Tue, Dec 20, 2016 at 07:32:29AM +0000, Zhao1, Wei wrote: > Hi, Adrien > > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Adrien Mazarguil > > Sent: Tuesday, December 20, 2016 1:49 AM > > To: dev@dpdk.org > > Subject: [dpdk-dev] [PATCH v3 10/25] app/testpmd: add flow flush > > command > > > > 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 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 > > When user flow flush cmd, PMD will flush all the rule on the specific port, and the memory of which rte_flow point to must be flushed. Right. > This memory is returned when flow create, will rte layer flush this memory or PMD is responsible for that memory flush? All handles are considered destroyed and their memory freed, i.e. no rte_flow object remains valid after flush. Applications still need to clean up the memory they allocated to manage these objects, but that's their problem. > BTW, there is no argument about rte_flow in flush function pass into PMD layer. Right, that's because flush does not request the destruction of a specific rule. PMDs that allocate memory for rte_flow objects must link them together somehow to retrieve them during a flush event. Note this is likely already necessary to clean up the memory allocated for flow rules during dev_close(). -- Adrien Mazarguil 6WIND