From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id C69542C4F for ; Thu, 29 Dec 2016 05:03:29 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 28 Dec 2016 20:03:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,425,1477983600"; d="scan'208";a="1087683071" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga001.fm.intel.com with ESMTP; 28 Dec 2016 20:03:28 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 28 Dec 2016 20:03:28 -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; Thu, 29 Dec 2016 12:03:24 +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/aEeS8aA Date: Thu, 29 Dec 2016 04:03:24 +0000 Message-ID: <94479800C636CB44BD422CB454846E013158C410@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> In-Reply-To: <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:03:30 -0000 > -----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 >=20 > > + > > +/* 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); >=20 > 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. Thanks for the suggestion, I'll use the key as parameter in the next versio= n. >=20 > > /* > > * Configure ethertype filter, which can director packet by filtering > > * 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 mal= loc > it when delete a filter. Malloc ethertype_filter because i40e_ethertype_filter_convert is involved f= irst, and then check if a rule exists with ethertype_filter->input. >=20 > Thanks > Jingjing