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 AC302201 for ; Wed, 28 Dec 2016 03:22:20 +0100 (CET) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP; 27 Dec 2016 18:22:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,419,1477983600"; d="scan'208";a="47301587" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga005.fm.intel.com with ESMTP; 27 Dec 2016 18:22:19 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 27 Dec 2016 18:22:18 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.20]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0248.002; Wed, 28 Dec 2016 10:22:15 +0800 From: "Wu, Jingjing" To: "Xing, Beilei" , "Zhang, Helin" CC: "dev@dpdk.org" Thread-Topic: [PATCH v2 01/17] net/i40e: store ethertype filter Thread-Index: AQHSYApC3mLMUNmtR0q8rT37mohqDqEcn+8Q Date: Wed, 28 Dec 2016 02:22:15 +0000 Message-ID: <9BB6961774997848B5B42BEC655768F810CC003C@SHSMSX103.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> In-Reply-To: <1482819984-14120-2-git-send-email-beilei.xing@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: Wed, 28 Dec 2016 02:22:21 -0000 > + > +/* 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 t= he input argument. Or you can define this function to use key as argument but not filter. > /* > * 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."); >=20 > + /* 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 mallo= c it when delete a filter. Thanks Jingjing