From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 744662BA5 for ; Mon, 2 Jan 2017 10:59:07 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP; 02 Jan 2017 01:59:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,432,1477983600"; d="scan'208";a="25142700" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga002.jf.intel.com with ESMTP; 02 Jan 2017 01:59:05 -0800 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 2 Jan 2017 01:59:05 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 2 Jan 2017 01:59:04 -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; Mon, 2 Jan 2017 17:59:01 +0800 From: "Xing, Beilei" To: "Zhao1, Wei" , "dev@dpdk.org" CC: "Lu, Wenzhuo" , "Zhao1, Wei" Thread-Topic: [dpdk-dev] [PATCH v2 02/18] net/ixgbe: store flow director filter Thread-Index: AQHSYnKMGhSZ24dEUkemGDirI/bPDKEk999w Date: Mon, 2 Jan 2017 09:59:01 +0000 Message-ID: <94479800C636CB44BD422CB454846E013158CE0E@SHSMSX101.ccr.corp.intel.com> References: <1483084390-53159-1-git-send-email-wei.zhao1@intel.com> <1483084390-53159-3-git-send-email-wei.zhao1@intel.com> In-Reply-To: <1483084390-53159-3-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: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiODIxOTQzMzAtYWVhYy00NzcwLWE1YmUtZTIxZjc1ODAwYTQwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IjBFZmhHZEtMb2lBb2wwa3RucEd2M28yeG11VlkyS3RKbENwMXlaYnB4RFk9In0= x-ctpclassification: CTP_IC 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 02/18] net/ixgbe: store flow director 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 09:59:08 -0000 > 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 02/18] net/ixgbe: store flow director filte= r >=20 > Add support for storing flow director filter in SW. >=20 > Signed-off-by: Wenzhuo Lu > Signed-off-by: Wei Zhao > --- >=20 > v2: > --add a fdir initialization function in device start process > --- >=20 > +static inline struct ixgbe_fdir_filter * > +ixgbe_fdir_filter_lookup(struct ixgbe_hw_fdir_info *fdir_info, > + union ixgbe_atr_input *key) > +{ > + int ret =3D 0; Needless initialization here since ret will be set below. > + ret =3D rte_hash_lookup(fdir_info->hash_handle, (const void *)key); > + if (ret < 0) > + return NULL; > + > + return fdir_info->hash_map[ret]; > +} > + > +static inline int > +ixgbe_insert_fdir_filter(struct ixgbe_hw_fdir_info *fdir_info, > + struct ixgbe_fdir_filter *fdir_filter) { > + int ret =3D 0; Same above. > + > + ret =3D rte_hash_add_key(fdir_info->hash_handle, > + &fdir_filter->ixgbe_fdir); > + > + if (ret < 0) { > + PMD_DRV_LOG(ERR, > + "Failed to insert fdir filter to hash table %d!", > + ret); > + return ret; > + } > + > + fdir_info->hash_map[ret] =3D fdir_filter; > + > + TAILQ_INSERT_TAIL(&fdir_info->fdir_list, fdir_filter, entries); > + > + return 0; > +} > + > +static inline int > +ixgbe_remove_fdir_filter(struct ixgbe_hw_fdir_info *fdir_info, > + union ixgbe_atr_input *key) > +{ > + int ret =3D 0; Same above. > + struct ixgbe_fdir_filter *fdir_filter; > + > + ret =3D rte_hash_del_key(fdir_info->hash_handle, key); > + > + if (ret < 0) { > + PMD_DRV_LOG(ERR, "No such fdir filter to delete %d!", ret); > + return ret; > + } > + > + fdir_filter =3D fdir_info->hash_map[ret]; > + fdir_info->hash_map[ret] =3D NULL; > + > + TAILQ_REMOVE(&fdir_info->fdir_list, fdir_filter, entries); > + rte_free(fdir_filter); > + > + return 0; > +} > + > /* > * ixgbe_add_del_fdir_filter - add or remove a flow diretor filter. > * @dev: pointer to the structure rte_eth_dev @@ -1098,6 +1158,8 @@ > ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev, > struct ixgbe_hw_fdir_info *info =3D > IXGBE_DEV_PRIVATE_TO_FDIR_INFO(dev->data->dev_private); > enum rte_fdir_mode fdir_mode =3D dev->data->dev_conf.fdir_conf.mode; > + struct ixgbe_fdir_filter *node; > + bool add_node =3D FALSE; >=20 > if (fdir_mode =3D=3D RTE_FDIR_MODE_NONE) > return -ENOTSUP; > @@ -1148,6 +1210,10 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev, > dev->data->dev_conf.fdir_conf.pballoc); >=20 > if (del) { > + err =3D ixgbe_remove_fdir_filter(info, &input); > + if (err < 0) > + return err; > + > err =3D fdir_erase_filter_82599(hw, fdirhash); > if (err < 0) > PMD_DRV_LOG(ERR, "Fail to delete FDIR filter!"); @@ -1172,6 > +1238,37 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev, > else > return -EINVAL; >=20 > + node =3D ixgbe_fdir_filter_lookup(info, &input); > + if (node) { > + if (update) { > + node->fdirflags =3D fdircmd_flags; > + node->fdirhash =3D fdirhash; > + node->queue =3D queue; > + } else { > + PMD_DRV_LOG(ERR, "Conflict with existing fdir filter!"); > + return -EINVAL; > + } > + } else { > + add_node =3D TRUE; > + node =3D rte_zmalloc("ixgbe_fdir", > + sizeof(struct ixgbe_fdir_filter), > + 0); > + if (!node) > + return -ENOMEM; > + (void)rte_memcpy(&node->ixgbe_fdir, > + &input, > + sizeof(union ixgbe_atr_input)); > + node->fdirflags =3D fdircmd_flags; > + node->fdirhash =3D fdirhash; > + node->queue =3D queue; > + > + err =3D ixgbe_insert_fdir_filter(info, node); > + if (err < 0) { > + rte_free(node); > + return err; > + } > + } > + > if (is_perfect) { > err =3D fdir_write_perfect_filter_82599(hw, &input, queue, > fdircmd_flags, fdirhash, > @@ -1180,10 +1277,14 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev > *dev, > err =3D fdir_add_signature_filter_82599(hw, &input, queue, > fdircmd_flags, fdirhash); > } > - if (err < 0) > + if (err < 0) { > PMD_DRV_LOG(ERR, "Fail to add FDIR filter!"); > - else > + > + if (add_node) > + (void)ixgbe_remove_fdir_filter(info, &input); > + } else { > PMD_DRV_LOG(DEBUG, "Success to add FDIR filter"); > + } >=20 > return err; > } > -- > 2.5.5