From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id C05E22BC3 for ; Tue, 3 Jan 2017 06:25:01 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 02 Jan 2017 21:25:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,451,1477983600"; d="scan'208";a="25429557" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga002.jf.intel.com with ESMTP; 02 Jan 2017 21:25:00 -0800 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 2 Jan 2017 21:25:00 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 2 Jan 2017 21:24:59 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.177]) by shsmsx102.ccr.corp.intel.com ([169.254.2.88]) with mapi id 14.03.0248.002; Tue, 3 Jan 2017 13:24:56 +0800 From: "Xing, Beilei" To: "Zhao1, Wei" , "dev@dpdk.org" CC: "Zhao1, Wei" , "Lu, Wenzhuo" Thread-Topic: [dpdk-dev] [PATCH v2 16/18] net/ixgbe: create consistent filter Thread-Index: AQHSYnMQNjxhnzbfYUaEiGrf2/7hn6EmOUHA Date: Tue, 3 Jan 2017 05:24:56 +0000 Message-ID: <94479800C636CB44BD422CB454846E013158D2E1@SHSMSX101.ccr.corp.intel.com> References: <1483084390-53159-1-git-send-email-wei.zhao1@intel.com> <1483084390-53159-17-git-send-email-wei.zhao1@intel.com> In-Reply-To: <1483084390-53159-17-git-send-email-wei.zhao1@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2 16/18] net/ixgbe: create consistent filter 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, 03 Jan 2017 05:25:03 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wei Zhao > Sent: Friday, December 30, 2016 3:53 PM > To: dev@dpdk.org > Cc: Zhao1, Wei ; Lu, Wenzhuo > > Subject: [dpdk-dev] [PATCH v2 16/18] net/ixgbe: create consistent filter >=20 > This patch adds a function to create the flow directory filter. >=20 > Signed-off-by: Wei Zhao > Signed-off-by: Wenzhuo Lu >=20 > --- >=20 >=20 > +/** > + * Create or destroy a flow rule. > + * Theorically one rule can match more than one filters. > + * We will let it use the filter which it hitt first. > + * So, the sequence matters. > + */ > +static struct rte_flow * > +ixgbe_flow_create(struct rte_eth_dev *dev, > + const struct rte_flow_attr *attr, > + const struct rte_flow_item pattern[], > + const struct rte_flow_action actions[], > + struct rte_flow_error *error) > +{ > + int ret; > + struct rte_eth_ntuple_filter ntuple_filter; > + struct rte_eth_ethertype_filter ethertype_filter; > + struct rte_eth_syn_filter syn_filter; > + struct ixgbe_fdir_rule fdir_rule; > + struct rte_eth_l2_tunnel_conf l2_tn_filter; > + struct ixgbe_hw_fdir_info *fdir_info =3D > + IXGBE_DEV_PRIVATE_TO_FDIR_INFO(dev->data- > >dev_private); > + struct ixgbe_flow *flow =3D NULL; > + struct ixgbe_ntuple_filter_ele *ntuple_filter_ptr; > + struct ixgbe_ethertype_filter_ele *ethertype_filter_ptr; > + struct ixgbe_eth_syn_filter_ele *syn_filter_ptr; > + struct ixgbe_eth_l2_tunnel_conf_ele *l2_tn_filter_ptr; > + struct ixgbe_fdir_rule_ele *fdir_rule_ptr; > + struct ixgbe_flow_mem *ixgbe_flow_mem_ptr; > + > + flow =3D rte_zmalloc("ixgbe_flow", sizeof(struct ixgbe_flow), 0); > + if (!flow) { > + PMD_DRV_LOG(ERR, "failed to allocate memory"); > + return (struct rte_flow *)flow; > + } > + ixgbe_flow_mem_ptr =3D rte_zmalloc("ixgbe_flow_mem", > + sizeof(struct ixgbe_flow_mem), 0); > + if (!ixgbe_flow_mem_ptr) { > + PMD_DRV_LOG(ERR, "failed to allocate memory"); > + return NULL; > + } > + ixgbe_flow_mem_ptr->flow =3D flow; > + TAILQ_INSERT_TAIL(&ixgbe_flow_list, > + ixgbe_flow_mem_ptr, entries); > + > + memset(&ntuple_filter, 0, sizeof(struct rte_eth_ntuple_filter)); > + ret =3D ixgbe_parse_ntuple_filter(attr, pattern, > + actions, &ntuple_filter, error); > + if (!ret) { > + ret =3D ixgbe_add_del_ntuple_filter(dev, &ntuple_filter, TRUE); > + if (!ret) { > + ntuple_filter_ptr =3D rte_zmalloc("ixgbe_ntuple_filter", > + sizeof(struct ixgbe_ntuple_filter_ele), 0); > + (void)rte_memcpy(&ntuple_filter_ptr->filter_info, > + &ntuple_filter, > + sizeof(struct rte_eth_ntuple_filter)); > + TAILQ_INSERT_TAIL(&filter_ntuple_list, > + ntuple_filter_ptr, entries); > + flow->rule =3D ntuple_filter_ptr; > + flow->filter_type =3D RTE_ETH_FILTER_NTUPLE; > + } > + return (struct rte_flow *)flow; Should the return statement be in the parantheses above? And is there any process if (ret<0) ? > + } > + > + memset(ðertype_filter, 0, sizeof(struct > rte_eth_ethertype_filter)); > + ret =3D ixgbe_parse_ethertype_filter(attr, pattern, > + actions, ðertype_filter, error); > + if (!ret) { > + ret =3D ixgbe_add_del_ethertype_filter(dev, > + ðertype_filter, TRUE); > + if (!ret) { > + ethertype_filter_ptr =3D rte_zmalloc( > + "ixgbe_ethertype_filter", > + sizeof(struct ixgbe_ethertype_filter_ele), 0); > + (void)rte_memcpy(ðertype_filter_ptr- > >filter_info, > + ðertype_filter, > + sizeof(struct rte_eth_ethertype_filter)); > + TAILQ_INSERT_TAIL(&filter_ethertype_list, > + ethertype_filter_ptr, entries); > + flow->rule =3D ethertype_filter_ptr; > + flow->filter_type =3D RTE_ETH_FILTER_ETHERTYPE; > + } > + return (struct rte_flow *)flow; Same above. > + } > + > + memset(&syn_filter, 0, sizeof(struct rte_eth_syn_filter)); > + ret =3D cons_parse_syn_filter(attr, pattern, actions, &syn_filter, erro= r); > + if (!ret) { > + ret =3D ixgbe_syn_filter_set(dev, &syn_filter, TRUE); > + if (!ret) { > + syn_filter_ptr =3D rte_zmalloc("ixgbe_syn_filter", > + sizeof(struct ixgbe_eth_syn_filter_ele), 0); > + (void)rte_memcpy(&syn_filter_ptr->filter_info, > + &syn_filter, > + sizeof(struct rte_eth_syn_filter)); > + TAILQ_INSERT_TAIL(&filter_syn_list, > + syn_filter_ptr, > + entries); > + flow->rule =3D syn_filter_ptr; > + flow->filter_type =3D RTE_ETH_FILTER_SYN; > + } > + return (struct rte_flow *)flow; Same above. > + } > + > + memset(&fdir_rule, 0, sizeof(struct ixgbe_fdir_rule)); > + ret =3D ixgbe_parse_fdir_filter(attr, pattern, > + actions, &fdir_rule, error); > + if (!ret) { > + /* A mask cannot be deleted. */ > + if (fdir_rule.b_mask) { > + if (!fdir_info->mask_added) { > + /* It's the first time the mask is set. */ > + rte_memcpy(&fdir_info->mask, > + &fdir_rule.mask, > + sizeof(struct ixgbe_hw_fdir_mask)); > + ret =3D ixgbe_fdir_set_input_mask(dev); > + if (ret) > + return NULL; Before return NULL, ixgbe_flow_mem_ptr and flow should be freed, right? And ixgbe_flow_mem_ptr should be removed from ixgbe_flow_list. Or you can m= ove TAILQ_INSERT_TAIL(&ixgbe_flow_list, ixgbe_flow_mem_ptr, entries) after = a flow is added successfully. Same comments for "return NULL" below. > + > + fdir_info->mask_added =3D TRUE; > + } else { > + /** > + * Only support one global mask, > + * all the masks should be the same. > + */ > + ret =3D memcmp(&fdir_info->mask, > + &fdir_rule.mask, > + sizeof(struct ixgbe_hw_fdir_mask)); > + if (ret) > + return NULL; > + } > + } > + > + if (fdir_rule.b_spec) { > + ret =3D ixgbe_fdir_filter_program(dev, &fdir_rule, > + FALSE, FALSE); > + if (!ret) { > + fdir_rule_ptr =3D > rte_zmalloc("ixgbe_fdir_filter", > + sizeof(struct ixgbe_fdir_rule_ele), 0); > + (void)rte_memcpy(&fdir_rule_ptr- > >filter_info, > + &fdir_rule, > + sizeof(struct ixgbe_fdir_rule)); > + TAILQ_INSERT_TAIL(&filter_fdir_list, > + fdir_rule_ptr, entries); > + flow->rule =3D fdir_rule_ptr; > + flow->filter_type =3D RTE_ETH_FILTER_FDIR; > + > + return (struct rte_flow *)flow; > + } > + > + if (ret) > + return NULL; > + } > + > + return NULL; Why to return NULL here?=20 > + } > + > + memset(&l2_tn_filter, 0, sizeof(struct rte_eth_l2_tunnel_conf)); > + ret =3D cons_parse_l2_tn_filter(attr, pattern, > + actions, &l2_tn_filter, error); > + if (!ret) { > + ret =3D ixgbe_dev_l2_tunnel_filter_add(dev, &l2_tn_filter, > FALSE); > + if (!ret) { > + l2_tn_filter_ptr =3D rte_zmalloc("ixgbe_l2_tn_filter", > + sizeof(struct ixgbe_eth_l2_tunnel_conf_ele), > 0); > + (void)rte_memcpy(&l2_tn_filter_ptr->filter_info, > + &l2_tn_filter, > + sizeof(struct rte_eth_l2_tunnel_conf)); > + TAILQ_INSERT_TAIL(&filter_l2_tunnel_list, > + l2_tn_filter_ptr, entries); > + flow->rule =3D l2_tn_filter_ptr; > + flow->filter_type =3D RTE_ETH_FILTER_L2_TUNNEL; > + > + return (struct rte_flow *)flow; > + } is there any process if (ret<0) ? > + } > + > + rte_free(ixgbe_flow_mem_ptr); > + rte_free(flow); > + return NULL; > +} > +