From patchwork Fri Oct 16 08:55:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Etelson X-Patchwork-Id: 81064 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 312EFA04DB; Fri, 16 Oct 2020 10:56:39 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2DE7C1E9AD; Fri, 16 Oct 2020 10:56:28 +0200 (CEST) Received: from hqnvemgate26.nvidia.com (hqnvemgate26.nvidia.com [216.228.121.65]) by dpdk.org (Postfix) with ESMTP id C711C1E91C for ; Fri, 16 Oct 2020 10:56:25 +0200 (CEST) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Fri, 16 Oct 2020 01:56:11 -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; Fri, 16 Oct 2020 08:56:15 +0000 From: Gregory Etelson To: CC: , , , , , , , Ori Kam , Viacheslav Ovsiienko , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Date: Fri, 16 Oct 2020 11:55:55 +0300 Message-ID: <20201016085557.18884-2-getelson@nvidia.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201016085557.18884-1-getelson@nvidia.com> References: <20200625160348.26220-1-getelson@mellanox.com> <20201016085557.18884-1-getelson@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1602838571; bh=/6jVazrlMnsgAfIysc1U/qyvzCMaURzmwEdLNyZNK4s=; 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=YNMqiMu0foyXefAcojngGb7RR3XaevWpQvR05vH1GlzisT+5Z+bO/06GEsSTyxHea 8Nza9ZL1s+/B+Big5t5yADQJzwZMce+sfXkg7gja3K1dDCGKkC2czHi146iqIDV6zE 8nbwvgVzDiK1qoF5VgqvqD0051AQlOGXUV/mpKb7SWa68NT3PIfBVGafh/PawivAw6 +LvYjQKpGz96vYaaVWww1qrgJ6LhMUIi0VF7vb1bBwHx9ocl+tS4aj8fQq/a6X8scy cvrJdQh0JsDMLO5wko1nVbNlGElszLSA+p9joZNzdly33Ge/VEmQsWHh/9SJv+PtS3 OY77L54bbOo5Q== Subject: [dpdk-dev] [PATCH v6 1/3] 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" 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 item or action conversion library accepts positive known element types with predefined sizes only. Private PMD items and actions do not fit into this scheme because PMD type values are negative, each PMD has it's own types numeration and element types and their sizes are not visible at RTE level. To resolve these limitations the patch proposes this solution: 1. PMD can expose elements of pointer size only. RTE flow conversion functions will use pointer size for each configuration object in private PMD element it processes; 2. RTE flow verification will not reject elements with negative type. Signed-off-by: Gregory Etelson Acked-by: Ori Kam Acked-by: Viacheslav Ovsiienko --- v4: * update the 'Negative types' section in the rtre_flow.rst * update the patch comment v5: * rebase to next-net --- doc/guides/prog_guide/rte_flow.rst | 3 +++ doc/guides/rel_notes/release_20_11.rst | 5 +++++ lib/librte_ethdev/rte_flow.c | 28 ++++++++++++++++++++------ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 6ee0d3a10a..7fb5ec9059 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -2775,6 +2775,9 @@ identifiers they are not aware of. A method to generate them remains to be defined. +Application may use PMD dynamic items or actions in flow rules. In that case +size of configuration object in dynamic element must be a pointer size. + Planned types ~~~~~~~~~~~~~ diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst index 79d9ebac4e..9155b468d6 100644 --- a/doc/guides/rel_notes/release_20_11.rst +++ b/doc/guides/rel_notes/release_20_11.rst @@ -116,6 +116,11 @@ New Features * Updated HWRM structures to 1.10.1.70 version. * Added TRUFLOW support for Stingray devices. +* **Flow rules allowed to use private PMD items / actions.** + + * Flow rule verification was updated to accept private PMD + items and actions. + * **Updated Cisco enic driver.** * Added support for VF representors with single-queue Tx/Rx and flow API diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c index 686fe40eaa..b74ea5593a 100644 --- a/lib/librte_ethdev/rte_flow.c +++ b/lib/librte_ethdev/rte_flow.c @@ -518,7 +518,11 @@ 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 = (int)item->type >= 0 ? + rte_flow_desc_item[item->type].size : sizeof(void *); rte_memcpy(buf, data, (size > off ? off : size)); break; } @@ -621,7 +625,11 @@ 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 = (int)action->type >= 0 ? + rte_flow_desc_action[action->type].size : sizeof(void *); rte_memcpy(buf, action->conf, (size > off ? off : size)); break; } @@ -663,8 +671,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 (((int)src->type >= 0) && + ((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"); @@ -752,8 +764,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 (((int)src->type >= 0) && + ((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");