From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 486122B8B for ; Mon, 2 Jan 2017 11:06:04 +0100 (CET) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP; 02 Jan 2017 02:06:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,432,1477983600"; d="scan'208";a="48480031" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga005.jf.intel.com with ESMTP; 02 Jan 2017 02:06:03 -0800 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 2 Jan 2017 02:06:03 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 2 Jan 2017 02:06:03 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.177]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0248.002; Mon, 2 Jan 2017 18:06:01 +0800 From: "Xing, Beilei" To: "Zhao1, Wei" , "dev@dpdk.org" CC: "Lu, Wenzhuo" , "Zhao1, Wei" Thread-Topic: [dpdk-dev] [PATCH v2 03/18] net/ixgbe: store L2 tunnel filter Thread-Index: AQHSYnKnY2RYJEV5CE+J/ZUANG1tbKEk9NwA Date: Mon, 2 Jan 2017 10:06:00 +0000 Message-ID: <94479800C636CB44BD422CB454846E013158CE2B@SHSMSX101.ccr.corp.intel.com> References: <1483084390-53159-1-git-send-email-wei.zhao1@intel.com> <1483084390-53159-4-git-send-email-wei.zhao1@intel.com> In-Reply-To: <1483084390-53159-4-git-send-email-wei.zhao1@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiODg0MGU1YjEtZTg5Ny00YzExLWJiMDMtYjBjZjczNTI2N2I2IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX1BVQkxJQyJ9XX1dfSwiU3ViamVjdExhYmVscyI6W10sIlRNQ1ZlcnNpb24iOiIxNS45LjYuNiIsIlRydXN0ZWRMYWJlbEhhc2giOiJFXC8xd0NwTTFpcWhPalJsbGYreHZRaktuaDBscHNMcjh6U2phWVpXK1JwOD0ifQ== x-ctpclassification: CTP_PUBLIC 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 03/18] net/ixgbe: store L2 tunnel 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: Mon, 02 Jan 2017 10:06:05 -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: Lu, Wenzhuo ; Zhao1, Wei > Subject: [dpdk-dev] [PATCH v2 03/18] net/ixgbe: store L2 tunnel filter >=20 > Add support for storing L2 tunnel filter in SW. >=20 > Signed-off-by: Wenzhuo Lu > Signed-off-by: Wei Zhao > --- >=20 >=20 > +static inline struct ixgbe_l2_tn_filter * > +ixgbe_l2_tn_filter_lookup(struct ixgbe_l2_tn_info *l2_tn_info, > + struct ixgbe_l2_tn_key *key) > +{ > + int ret =3D 0; Needles initialization since ret will be set bellow, it can be removed. And this initialization can be removed in other filter lookup/insert/delete= functions, either. > + > + ret =3D rte_hash_lookup(l2_tn_info->hash_handle, (const void *)key); > + if (ret < 0) > + return NULL; > + > + return l2_tn_info->hash_map[ret]; > +} > + > +static inline int > +ixgbe_insert_l2_tn_filter(struct ixgbe_l2_tn_info *l2_tn_info, > + struct ixgbe_l2_tn_filter *l2_tn_filter) { > + int ret =3D 0; > + > + ret =3D rte_hash_add_key(l2_tn_info->hash_handle, > + &l2_tn_filter->key); > + > + if (ret < 0) { > + PMD_DRV_LOG(ERR, > + "Failed to insert L2 tunnel filter" > + " to hash table %d!", > + ret); > + return ret; > + } > + > + l2_tn_info->hash_map[ret] =3D l2_tn_filter; > + > + TAILQ_INSERT_TAIL(&l2_tn_info->l2_tn_list, l2_tn_filter, entries); > + > + return 0; > +} > /* Add l2 tunnel filter */ > static int > ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev, > struct rte_eth_l2_tunnel_conf *l2_tunnel) { > int ret =3D 0; > + struct ixgbe_l2_tn_info *l2_tn_info =3D > + IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private); > + struct ixgbe_l2_tn_key key; > + struct ixgbe_l2_tn_filter *node; > + > + key.l2_tn_type =3D l2_tunnel->l2_tunnel_type; > + key.tn_id =3D l2_tunnel->tunnel_id; > + > + node =3D ixgbe_l2_tn_filter_lookup(l2_tn_info, &key); > + > + if (node) { > + PMD_DRV_LOG(ERR, "The L2 tunnel filter already exists!"); > + return -EINVAL; > + } > + > + node =3D rte_zmalloc("ixgbe_l2_tn", > + sizeof(struct ixgbe_l2_tn_filter), > + 0); > + if (!node) > + return -ENOMEM; > + > + (void)rte_memcpy(&node->key, > + &key, > + sizeof(struct ixgbe_l2_tn_key)); > + node->pool =3D l2_tunnel->pool; > + ret =3D ixgbe_insert_l2_tn_filter(l2_tn_info, node); > + if (ret < 0) { > + rte_free(node); > + return ret; > + } >=20 > switch (l2_tunnel->l2_tunnel_type) { > case RTE_L2_TUNNEL_TYPE_E_TAG: > @@ -7195,6 +7340,9 @@ ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev > *dev, > break; > } >=20 > + if (ret < 0) > + (void)ixgbe_remove_l2_tn_filter(l2_tn_info, &key); Some confusion, why remove l2_tn_filter here? Can this check be moved befor= e ixgbe_insert_l2_tn_filter? > + > return ret; > } >=20 > @@ -7204,6 +7352,15 @@ ixgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev > *dev, > struct rte_eth_l2_tunnel_conf *l2_tunnel) { > int ret =3D 0; > + struct ixgbe_l2_tn_info *l2_tn_info =3D > + IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private); > + struct ixgbe_l2_tn_key key; > + > + key.l2_tn_type =3D l2_tunnel->l2_tunnel_type; > + key.tn_id =3D l2_tunnel->tunnel_id; > + ret =3D ixgbe_remove_l2_tn_filter(l2_tn_info, &key); > + if (ret < 0) > + return ret; >=20 > switch (l2_tunnel->l2_tunnel_type) { > case RTE_L2_TUNNEL_TYPE_E_TAG: > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h > b/drivers/net/ixgbe/ixgbe_ethdev.h > index 8310220..6663fc9 100644 > --- a/drivers/net/ixgbe/ixgbe_ethdev.h > +++ b/drivers/net/ixgbe/ixgbe_ethdev.h > @@ -132,6 +132,7 @@ > #define IXGBE_RX_VEC_START > RTE_INTR_VEC_RXTX_OFFSET >=20 > #define IXGBE_MAX_FDIR_FILTER_NUM (1024 * 32) > +#define IXGBE_MAX_L2_TN_FILTER_NUM 128 >=20 > /* > * Information about the fdir mode. > @@ -283,6 +284,25 @@ struct ixgbe_filter_info { > uint32_t syn_info; > }; >=20 > +struct ixgbe_l2_tn_key { > + enum rte_eth_tunnel_type l2_tn_type; > + uint32_t tn_id; > +}; > + > +struct ixgbe_l2_tn_filter { > + TAILQ_ENTRY(ixgbe_l2_tn_filter) entries; > + struct ixgbe_l2_tn_key key; > + uint32_t pool; Maybe more comments here will be helpful. > +}; > +