From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Xing, Beilei" Subject: Re: [PATCH v2 06/25] app/testpmd: implement basic support for rte_flow Date: Tue, 20 Dec 2016 01:57:46 +0000 Message-ID: <94479800C636CB44BD422CB454846E0131574785@SHSMSX101.ccr.corp.intel.com> References: <3318a43c9e105caaf4d5b13d6e4fcce774fb522f.1481903839.git.adrien.mazarguil@6wind.com> <94479800C636CB44BD422CB454846E013157433C@SHSMSX101.ccr.corp.intel.com> <20161219101943.GJ10340@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "dev@dpdk.org" , "Pei, Yulong" To: Adrien Mazarguil Return-path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 3F5D9F962 for ; Tue, 20 Dec 2016 02:57:50 +0100 (CET) In-Reply-To: <20161219101943.GJ10340@6wind.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com] > Sent: Monday, December 19, 2016 6:20 PM > To: Xing, Beilei > Cc: dev@dpdk.org; Pei, Yulong > Subject: Re: [dpdk-dev] [PATCH v2 06/25] app/testpmd: implement basic > support for rte_flow >=20 > Hi Beilei, >=20 > On Mon, Dec 19, 2016 at 08:37:20AM +0000, Xing, Beilei wrote: > > Hi Adrien, > > > > > -----Original Message----- > > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Adrien > > > Mazarguil > > > Sent: Saturday, December 17, 2016 12:25 AM > > > To: dev@dpdk.org > > > Subject: [dpdk-dev] [PATCH v2 06/25] app/testpmd: implement basic > > > support for rte_flow > > > > > > Add basic management functions for the generic flow API (validate, > > > create, destroy, flush, query and list). Flow rule objects and > > > properties are arranged in lists associated with each port. > > > > > > Signed-off-by: Adrien Mazarguil > > > +/** Create flow rule. */ > > > +int > > > +port_flow_create(portid_t port_id, > > > + const struct rte_flow_attr *attr, > > > + const struct rte_flow_item *pattern, > > > + const struct rte_flow_action *actions) { > > > + struct rte_flow *flow; > > > + struct rte_port *port; > > > + struct port_flow *pf; > > > + uint32_t id; > > > + struct rte_flow_error error; > > > + > > > > I think there should be memset for error here, e.g. memset(&error, 0, > > sizeof(struct rte_flow_error)); Since both cause and message may be NUL= L > regardless of the error type, if there's no error.cause and error.message > returned from PMD, Segmentation fault will happen in port_flow_complain. > > PS: This issue doesn't happen if add "export EXTRA_CFLAGS=3D' -g O0'" w= hen > compiling. >=20 > Actually, PMDs must fill the error structure only in case of error if the > application provides one, it's not optional. I didn't initialize this str= ucture for > this reason. >=20 > I suggest we initialize it with a known poisoning value for debugging pur= poses > though, to make it fail every time. Does it sound reasonable? OK, I see. Do you want PMD to allocate the memory for cause and message of = error, and must fill the cause and message if error exists, right? So is it possible to set NULL for pointers of cause and message in applicat= ion? then PMD can judge if it's need to allocate or overlap memory. >=20 > > > + flow =3D rte_flow_create(port_id, attr, pattern, actions, &error); > > > + if (!flow) > > > + return port_flow_complain(&error); > > > + port =3D &ports[port_id]; > > > + if (port->flow_list) { > > > + if (port->flow_list->id =3D=3D UINT32_MAX) { > > > + printf("Highest rule ID is already assigned, delete" > > > + " it first"); > > > + rte_flow_destroy(port_id, flow, NULL); > > > + return -ENOMEM; > > > + } > > > + id =3D port->flow_list->id + 1; > > > + } else > > > + id =3D 0; > > > + pf =3D port_flow_new(attr, pattern, actions); > > > + if (!pf) { > > > + int err =3D rte_errno; > > > + > > > + printf("Cannot allocate flow: %s\n", rte_strerror(err)); > > > + rte_flow_destroy(port_id, flow, NULL); > > > + return -err; > > > + } > > > + pf->next =3D port->flow_list; > > > + pf->id =3D id; > > > + pf->flow =3D flow; > > > + port->flow_list =3D pf; > > > + printf("Flow rule #%u created\n", pf->id); > > > + return 0; > > > +} > > > + >=20 > -- > Adrien Mazarguil > 6WIND