From patchwork Tue Sep 8 20:15:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Etelson X-Patchwork-Id: 76929 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C626FA04B1; Tue, 8 Sep 2020 22:16:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9A0DB1BF7E; Tue, 8 Sep 2020 22:16:34 +0200 (CEST) Received: from hqnvemgate26.nvidia.com (hqnvemgate26.nvidia.com [216.228.121.65]) by dpdk.org (Postfix) with ESMTP id 435DD2BAB for ; Tue, 8 Sep 2020 22:16:32 +0200 (CEST) Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 08 Sep 2020 13:16:18 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Tue, 08 Sep 2020 13:16:31 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Tue, 08 Sep 2020 13:16:31 -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; Tue, 8 Sep 2020 20:16:14 +0000 From: Gregory Etelson To: CC: , , , "Gregory Etelson" , Ori Kam , "Thomas Monjalon" , Ferruh Yigit , Andrew Rybchenko Date: Tue, 8 Sep 2020 23:15:48 +0300 Message-ID: <20200908201552.14423-2-getelson@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200908201552.14423-1-getelson@nvidia.com> References: <20200625160348.26220-1-getelson@mellanox.com> <20200908201552.14423-1-getelson@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1599596178; bh=ev4lGSMU0wUgibmkYve5wBiF5NX8m5AH1TmsZIS+GgM=; h=X-PGP-Universal: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=do2AkGmGCt40k4WJC9uBagDJt3YkK4WQewy1kNoQwGbHDZJsvRZ4TknrtKIQTcBiY UmDnui7HtRhviRsvYdfS2r0lnRc/HT5cCKQU8c8FimXRM5otm8H33XhL6KtJSBXpDD WbGsXr1zUvBxgWOdreNSfc116cQgXDqljVkM/57MMSxuKtSmZrLTfjjAxIszx4Qvvn BpT4LQtnpxR6jnt3p6Eto/b7VzLyDgcmip4TdUbt4oNOzMez18c8Xqd04pow3AmmwQ WcD2rEwuGkUO4ZA5GrWF+utQpLoU+klYBo+CeFebOrCSE925lQLoNL0YAyte6+Gq/A QmRCWTqbdKUXw== Subject: [dpdk-dev] [PATCH v2 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 --- v2: * Update commit log --- lib/librte_ethdev/rte_flow.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c index f8fdd68fe9..9905426bc9 100644 --- a/lib/librte_ethdev/rte_flow.c +++ b/lib/librte_ethdev/rte_flow.c @@ -564,7 +564,12 @@ rte_flow_conv_item_spec(void *buf, const size_t size, } break; default: - off = rte_flow_desc_item[item->type].size; + /** + * allow PMD private flow item + */ + off = (uint32_t)item->type <= INT_MAX ? + rte_flow_desc_item[item->type].size : + sizeof(void *); rte_memcpy(buf, data, (size > off ? off : size)); break; } @@ -667,7 +672,12 @@ rte_flow_conv_action_conf(void *buf, const size_t size, } break; default: - off = rte_flow_desc_action[action->type].size; + /** + * allow PMD private flow action + */ + off = (uint32_t)action->type <= INT_MAX ? + rte_flow_desc_action[action->type].size : + sizeof(void *); rte_memcpy(buf, action->conf, (size > off ? off : size)); break; } @@ -709,8 +719,12 @@ rte_flow_conv_pattern(struct rte_flow_item *dst, unsigned int i; for (i = 0, off = 0; !num || i != num; ++i, ++src, ++dst) { - if ((size_t)src->type >= RTE_DIM(rte_flow_desc_item) || - !rte_flow_desc_item[src->type].name) + /** + * allow PMD private flow item + */ + if (((uint32_t)src->type <= INT_MAX) && + ((size_t)src->type >= 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 +812,12 @@ rte_flow_conv_actions(struct rte_flow_action *dst, unsigned int i; for (i = 0, off = 0; !num || i != num; ++i, ++src, ++dst) { - if ((size_t)src->type >= RTE_DIM(rte_flow_desc_action) || - !rte_flow_desc_action[src->type].name) + /** + * allow PMD private flow action + */ + if (((uint32_t)src->type <= INT_MAX) && + ((size_t)src->type >= 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");