From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 4A6FEA04DB;
	Thu, 15 Oct 2020 14:42:33 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 0FA951E53E;
	Thu, 15 Oct 2020 14:42:24 +0200 (CEST)
Received: from hqnvemgate25.nvidia.com (hqnvemgate25.nvidia.com
 [216.228.121.64]) by dpdk.org (Postfix) with ESMTP id 71A1B1DF96
 for <dev@dpdk.org>; Thu, 15 Oct 2020 14:42:22 +0200 (CEST)
Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by
 hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA)
 id <B5f8843800000>; Thu, 15 Oct 2020 05:41:36 -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;
 Thu, 15 Oct 2020 12:42:12 +0000
From: Gregory Etelson <getelson@nvidia.com>
To: <dev@dpdk.org>
CC: <getelson@nvidia.com>, <matan@nvidia.com>, <rasland@nvidia.com>,
 <elibr@nvidia.com>, <ozsh@nvidia.com>, Ori Kam <orika@nvidia.com>, Viacheslav
 Ovsiienko <viacheslavo@nvidia.com>, Thomas Monjalon <thomas@monjalon.net>,
 Ferruh Yigit <ferruh.yigit@intel.com>, "Andrew Rybchenko"
 <andrew.rybchenko@oktetlabs.ru>
Date: Thu, 15 Oct 2020 15:41:52 +0300
Message-ID: <20201015124154.13357-2-getelson@nvidia.com>
X-Mailer: git-send-email 2.28.0
In-Reply-To: <20201015124154.13357-1-getelson@nvidia.com>
References: <20200625160348.26220-1-getelson@mellanox.com>
 <20201015124154.13357-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: 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=1602765696; bh=BYgtzkn5IPTpFN2k7SA3aHtBop/z+AF8oZGoNSx5p2I=;
 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=Ycn42B3VJbjw+2kSoWFN7sYTLYdq9dWaJl5Lp0VJdEsJA57azOvtCENnxgvGTCERC
 7LYe3mRPdaDOg/Xd08Oe88EmfksWcvs5h4qXoExW08QSoUayJ1GZJhfcmAHQqm+kEg
 1nXwbzLUPRqk+KsLu+FulLwV4y0sjMfjCD24efQCZWOMuSYfBd4YSp+ujaSX7/0b1B
 yYj68rC5LmcsBpLJKRVis7TDU6ItwmNIGQujRAJO3LPCw8DeZureTs3FbXK4dFNRRR
 XLW2rPHw60X1WOEH5AS9rE/qDT0ckMBta7zlLMyoE7fMghlb8ZWU4yjTdmJUXEIvh4
 tEwf9vpMi6OfA==
Subject: [dpdk-dev] [PATCH v5 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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

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 becase 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 <getelson@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>

---
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 55497c9033..d0dd7a00f1 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -2765,6 +2765,9 @@ identifiers they are not aware of.
=20
 A method to generate them remains to be defined.
=20
+Application may use PMD dynamic items or actions in flow rules. In that ca=
se
+size of configuration object in dynamic element must be a pointer size.
+
 Planned types
 ~~~~~~~~~~~~~
=20
diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/=
release_20_11.rst
index 3181fdb6a7..55bcb5e91f 100644
--- a/doc/guides/rel_notes/release_20_11.rst
+++ b/doc/guides/rel_notes/release_20_11.rst
@@ -92,6 +92,11 @@ New Features
   * Updated HWRM structures to 1.10.1.70 version.
   * Added TRUFLOW support for Stingray devices.
=20
+* **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.**
=20
   * 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 ee4f3464fe..411da1940e 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -480,7 +480,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;
 	}
@@ -583,7 +587,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;
 	}
@@ -625,8 +633,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");
@@ -714,8 +726,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.28.0