From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 73CAA2C4F for ; Thu, 29 Dec 2016 05:37:04 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 28 Dec 2016 20:37:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,425,1477983600"; d="scan'208";a="803185742" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by FMSMGA003.fm.intel.com with ESMTP; 28 Dec 2016 20:37:04 -0800 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 28 Dec 2016 20:37:03 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 28 Dec 2016 20:37:03 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.177]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.204]) with mapi id 14.03.0248.002; Thu, 29 Dec 2016 12:36:59 +0800 From: "Xing, Beilei" To: "Wu, Jingjing" , "Zhang, Helin" CC: "dev@dpdk.org" Thread-Topic: [PATCH v2 01/17] net/i40e: store ethertype filter Thread-Index: AQHSYLE0VrL9Eq8ceEeToRX4ydNG/aEeS8aAgAAMYLA= Date: Thu, 29 Dec 2016 04:36:59 +0000 Message-ID: <94479800C636CB44BD422CB454846E013158C42E@SHSMSX101.ccr.corp.intel.com> References: <1480679625-4157-1-git-send-email-beilei.xing@intel.com> <1482819984-14120-1-git-send-email-beilei.xing@intel.com> <1482819984-14120-2-git-send-email-beilei.xing@intel.com> <9BB6961774997848B5B42BEC655768F810CC003C@SHSMSX103.ccr.corp.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 01/17] net/i40e: store ethertype 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: Thu, 29 Dec 2016 04:37:06 -0000 > -----Original Message----- > From: Xing, Beilei > Sent: Thursday, December 29, 2016 12:03 PM > To: Wu, Jingjing ; Zhang, Helin > > Cc: dev@dpdk.org > Subject: RE: [PATCH v2 01/17] net/i40e: store ethertype filter >=20 > > -----Original Message----- > > From: Wu, Jingjing > > Sent: Wednesday, December 28, 2016 10:22 AM > > To: Xing, Beilei ; Zhang, Helin > > > > Cc: dev@dpdk.org > > Subject: RE: [PATCH v2 01/17] net/i40e: store ethertype filter > > > > > + > > > +/* Delete ethertype filter in SW list */ static int > > > +i40e_sw_ethertype_filter_del(struct i40e_pf *pf, > > > + struct i40e_ethertype_filter *filter) { > > > + struct i40e_ethertype_rule *ethertype_rule =3D &pf->ethertype; > > > + int ret =3D 0; > > > + > > > + ret =3D rte_hash_del_key(ethertype_rule->hash_table, > > > + &filter->input); > > > + if (ret < 0) > > > + PMD_DRV_LOG(ERR, > > > + "Failed to delete ethertype filter" > > > + " to hash table %d!", > > > + ret); > > > + ethertype_rule->hash_map[ret] =3D NULL; > > > + > > > + TAILQ_REMOVE(ðertype_rule->ethertype_list, filter, rules); > > > + rte_free(filter); > > > > It's better to free filter out of del function because the filter is > > also the input argument. > > Or you can define this function to use key as argument but not filter. >=20 > Thanks for the suggestion, I'll use the key as parameter in the next vers= ion. >=20 > > > > > /* > > > * Configure ethertype filter, which can director packet by filterin= g > > > * with mac address and ether_type or only ether_type @@ -7964,6 > > > +8099,8 @@ i40e_ethertype_filter_set(struct i40e_pf *pf, > > > bool add) > > > { > > > struct i40e_hw *hw =3D I40E_PF_TO_HW(pf); > > > + struct i40e_ethertype_rule *ethertype_rule =3D &pf->ethertype; > > > + struct i40e_ethertype_filter *ethertype_filter, *node; > > > struct i40e_control_filter_stats stats; > > > uint16_t flags =3D 0; > > > int ret; > > > @@ -7982,6 +8119,22 @@ i40e_ethertype_filter_set(struct i40e_pf *pf, > > > PMD_DRV_LOG(WARNING, "filter vlan ether_type in first tag > > is" > > > " not supported."); > > > > > > + /* Check if there is the filter in SW list */ > > > + ethertype_filter =3D rte_zmalloc("ethertype_filter", > > > + sizeof(*ethertype_filter), 0); > > > + i40e_ethertype_filter_convert(filter, ethertype_filter); > > > + node =3D i40e_sw_ethertype_filter_lookup(ethertype_rule, > > > + ðertype_filter->input); > > > + if (add && node) { > > > + PMD_DRV_LOG(ERR, "Conflict with existing ethertype > > rules!"); > > > + rte_free(ethertype_filter); > > > + return -EINVAL; > > > + } else if (!add && !node) { > > > + PMD_DRV_LOG(ERR, "There's no corresponding ethertype > > > filter!"); > > > + rte_free(ethertype_filter); > > > + return -EINVAL; > > > + } > > How about malloc ethertype_filter after check? Especially, no need to > > malloc it when delete a filter. >=20 > Malloc ethertype_filter because i40e_ethertype_filter_convert is involved > first, and then check if a rule exists with ethertype_filter->input. Sorry, you are right. In fact I needn't to malloc before convert. Will upda= te it in next version. >=20 > > > > Thanks > > Jingjing