From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8641EA04B5; Wed, 30 Sep 2020 11:19:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 65BD41DAE4; Wed, 30 Sep 2020 11:19:44 +0200 (CEST) Received: from hqnvemgate26.nvidia.com (hqnvemgate26.nvidia.com [216.228.121.65]) by dpdk.org (Postfix) with ESMTP id 13CBB1DAE4 for ; Wed, 30 Sep 2020 11:19:42 +0200 (CEST) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Wed, 30 Sep 2020 02:19:28 -0700 Received: from nvidia.com (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 30 Sep 2020 09:19:23 +0000 From: Gregory Etelson To: CC: , , , "Gregory Etelson" , Ori Kam , "Viacheslav Ovsiienko" , Ori Kam , "Thomas Monjalon" , Ferruh Yigit , Andrew Rybchenko Date: Wed, 30 Sep 2020 12:18:50 +0300 Message-ID: <20200930091854.19768-2-getelson@nvidia.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200930091854.19768-1-getelson@nvidia.com> References: <20200625160348.26220-1-getelson@mellanox.com> <20200930091854.19768-1-getelson@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1601457568; bh=MOkSmkvwBPhrqOVQrv5ChJoWBWwFStB81sk70oyZ3X0=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:Content-Type: X-Originating-IP:X-ClientProxiedBy; b=S+WWVbMIfHe3Qyy+WLt75igSzZ34Q7cWPHL77kMosDB3SJTHVDD4YkbtKBwomWANH fbEBzJAxj0/tm8aGoU7KLJQ2K7TlsFmMAM6J8GCdfr++VrArf1IHB2lLib8v2VXNdd qoa//bL+ApqOH+04Y1Rzp6QQNevsB/2AMLN365e3RXnXU1KHaRmsBnOBY5bdJmdlw6 UIMnmMp7khXJE8hPWQ4tHQD19XojjFVUHOwS9VG4Z/adLpkmjLCWG/CRcsR4QIh/sR nX4wDBd64E3dh+7eP5DhNhWxv+VSARv3cFUj/u040x3r1LD+qfynfpmc/24tRpphqC c/xEODtR4nTKw== Subject: [dpdk-dev] [PATCH v3 1/4] ethdev: allow negative values in flow rule types 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Gregory Etelson RTE flow items & actions use positive values in item & action type. Negative values are reserved for PMD private types. PMD items & actions usually are not exposed to application and are not used to create RTE flows. The patch allows applications with access to PMD flow items & actions ability to integrate RTE and PMD items & actions and use them to create flow rule. RTE flow library functions cannot work with PMD private items and actions (elements) because RTE flow has no API to query PMD flow object size. In the patch, PMD flow elements use object pointer. RTE flow library functions handle PMD element object size as size of a pointer. PMD handles its objects internally. Signed-off-by: Gregory Etelson Acked-by: Ori Kam Acked-by: Viacheslav Ovsiienko --- lib/librte_ethdev/rte_flow.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c index f8fdd68fe9..c8c6d62a8b 100644 --- a/lib/librte_ethdev/rte_flow.c +++ b/lib/librte_ethdev/rte_flow.c @@ -564,7 +564,11 @@ rte_flow_conv_item_spec(void *buf, const size_t size, } break; default: - off =3D rte_flow_desc_item[item->type].size; + /** + * allow PMD private flow item + */ + off =3D (int)item->type >=3D 0 ? + rte_flow_desc_item[item->type].size : sizeof(void *); rte_memcpy(buf, data, (size > off ? off : size)); break; } @@ -667,7 +671,11 @@ rte_flow_conv_action_conf(void *buf, const size_t size= , } break; default: - off =3D rte_flow_desc_action[action->type].size; + /** + * allow PMD private flow action + */ + off =3D (int)action->type >=3D 0 ? + rte_flow_desc_action[action->type].size : sizeof(void *); rte_memcpy(buf, action->conf, (size > off ? off : size)); break; } @@ -709,8 +717,12 @@ rte_flow_conv_pattern(struct rte_flow_item *dst, unsigned int i; =20 for (i =3D 0, off =3D 0; !num || i !=3D num; ++i, ++src, ++dst) { - if ((size_t)src->type >=3D RTE_DIM(rte_flow_desc_item) || - !rte_flow_desc_item[src->type].name) + /** + * allow PMD private flow item + */ + if (((int)src->type >=3D 0) && + ((size_t)src->type >=3D RTE_DIM(rte_flow_desc_item) || + !rte_flow_desc_item[src->type].name)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, src, "cannot convert unknown item type"); @@ -798,8 +810,12 @@ rte_flow_conv_actions(struct rte_flow_action *dst, unsigned int i; =20 for (i =3D 0, off =3D 0; !num || i !=3D num; ++i, ++src, ++dst) { - if ((size_t)src->type >=3D RTE_DIM(rte_flow_desc_action) || - !rte_flow_desc_action[src->type].name) + /** + * allow PMD private flow action + */ + if (((int)src->type >=3D 0) && + ((size_t)src->type >=3D RTE_DIM(rte_flow_desc_action) || + !rte_flow_desc_action[src->type].name)) return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, src, "cannot convert unknown action type"); --=20 2.25.1