From patchwork Wed Oct 13 18:45:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 101471 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E6EB4A0C55; Wed, 13 Oct 2021 20:45:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 83AEB411C6; Wed, 13 Oct 2021 20:45:39 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2059.outbound.protection.outlook.com [40.107.93.59]) by mails.dpdk.org (Postfix) with ESMTP id C1B184111B for ; Wed, 13 Oct 2021 20:45:37 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JVryAbt4XIoZeqIUvBadaKNz/oTvINVT1JWB7LlBcjgoW8Pfj6Ja66tbayzxfJMUkn/j5a/o/+G+5BLJaR3I4+zHc8SVhcHUrqc1x0n8VuogcdVaFfd6uKYfNlBhJ7veT44dXGLuXcwkFgEHMAQOODL5/A82f+bpF4AyVvCQ2gsseXYLJHnyBCXMmxdvAT2K3+Ky/TjGUZ3bMrPPHsG+ldsH8Tj7CUFJ/DZWFBoAJ5KPwG52D/h2U4upQTjHIQx7KrJsXKsWbJi1crnqQczvcbOLXQ8LvKBmbTx3RjdIqO2xn++nkovCOB27f6LzYOTUtOT0ebTgMe+vS8PxixB9jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fJQlXd4sWlmMAshUvDkUS8JWKCbLuTdzFTgDzj7TR6s=; b=nYjsXcmKSoY7QWQt/z4FTxhGNXNisgfiz9a4HEJKvbk/gt8CiCwX1QQ52TrGdsfGCo+EwM4u0R0mSsN6Gvk3gpFceC+ccXaeT1FR8MXmIer4LHmz8TNpCZPWcxJYPEbgFaw8bCm2wIYASjfIhuO17ME10HELG1YL05AzvGOkPjGdddPH8vcyD0TSDC9zsx4BjIAgWbNjYdPT5tkC2YI+9/Q9us4yGpO+scTNvsRKkzj/4wzR++lMwd3d4nNgznn/WhNO6yjQWFtyB+88HfCwtYBvpK40pSDbVgEs+M5y98G4Mw53Hc0oFA/RUQJ4xu3ruh3/5//NTVl7tjmQ6R6ZSQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fJQlXd4sWlmMAshUvDkUS8JWKCbLuTdzFTgDzj7TR6s=; b=D63PjVochEYIC0pY5nKEn1a2NmwFvqp8KZGWf9ZxP49e3ul6WrGplJ2DZk8zOfxYU+P9Z+pb7g2MgH+dshq6h1tqikc3aN9DeGMX4warqBuZ/1qLyfLbNoIVsOsx9lVCf3GGUEmL1buHjY9MXF7I/NL6sUDD5U7z+ZsEPtbZaOIiFyaS9LSxwFv25Qlf1u90na0+U3chQx59zI24J2h3YbVSZxMZ1RCvySsnMOilLlWxdOtulo8gf89vA4vPQOylTKPTlcJwICIJkEjw4hjd0yIPmrvCP2+zMroDn0Jf1yH1T2F+mOGplz0xk3otozZNc8LYLgYDgychcvnzKF5DaQ== Received: from MW3PR06CA0026.namprd06.prod.outlook.com (2603:10b6:303:2a::31) by SA0PR12MB4397.namprd12.prod.outlook.com (2603:10b6:806:93::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.19; Wed, 13 Oct 2021 18:45:36 +0000 Received: from CO1NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:303:2a:cafe::2c) by MW3PR06CA0026.outlook.office365.com (2603:10b6:303:2a::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.25 via Frontend Transport; Wed, 13 Oct 2021 18:45:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT058.mail.protection.outlook.com (10.13.174.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4608.15 via Frontend Transport; Wed, 13 Oct 2021 18:45:35 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 13 Oct 2021 18:45:33 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , Date: Wed, 13 Oct 2021 21:45:12 +0300 Message-ID: <20211013184516.25338-2-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20211013184516.25338-1-viacheslavo@nvidia.com> References: <20210910141609.8410-1-viacheslavo@nvidia.com> <20211013184516.25338-1-viacheslavo@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 02bb3969-3ae2-4270-cb68-08d98e79a4eb X-MS-TrafficTypeDiagnostic: SA0PR12MB4397: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MgRpYM8bY1UMQZw00sIl/skrYS9TO6udwvFE5M80K5+M9FO81jq2yVQ7isjEej5Lc0ArITdt6R+lkwLB4lw+CuMsG1LkKZ9Vu4i5bI3U6xLpuYP8FMmuW4PHaP0CkE7leZI0jNGrBdCpydLMHaQvUUrLCbZsWXvyzy9V3F6rBY/iRrVTgkBQ+A+gjjgPaQxACDHvLuNl6J2V6shkEQqeWqJsDnH9gYbn9AbHmjOTPzzzQDYHZ/kbVhNIG7W+3QUX83/KRFxKNGZWhqzzJlfclcBKC5ojPNtYf1fz84Hfeky7ErU5SuBCaZV1S+NiwV+0ePEJBKRDR7RrmrdzfSGorxtMm4nlIZcaNEpz2+luu9f01i+0C3wGy7ZbYEN5TVJ/vXfpf8nNClaAjWrxADlgOQ7TsmyQErNc1liULEfI+1LjAW/3DUXOKRYIvRkGLKtlE6o9tKvTbN6DjxauIR8XR59kD2nNUDZ/ucU8DepSgiUzXVNwU3IZZ3n/PXiDvGfWW8BK4p/RssoD6/q8U8xBEnk2wnFSrYeI54r4U1YcAMVQvSbqePUjD1TSuTFk6L4Kzlmkizi7ZTQBmr53ajLiEUlYNah5a+4SN3uweUGJpaTr5i9zsAPo+PACaWGBKpvKeOucMMHOxZWYZGjZdKUX6Lz4HIvq1Ci9zjHsdLGfgx3pQGNTrWE4y8n6xI3f4Yx95bhIgBs2wudrpJWpWFM8zR3Rkm93/Dm4BDQc4v2HTpI= X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(426003)(2616005)(16526019)(6666004)(8936002)(336012)(15650500001)(26005)(83380400001)(2906002)(82310400003)(36756003)(186003)(1076003)(70586007)(70206006)(55016002)(8676002)(54906003)(47076005)(36860700001)(6916009)(6286002)(4326008)(356005)(7636003)(5660300002)(508600001)(86362001)(7696005)(316002)(21314003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2021 18:45:35.7430 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02bb3969-3ae2-4270-cb68-08d98e79a4eb X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4397 Subject: [dpdk-dev] [PATCH v6 1/5] ethdev: update modify field flow action X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" The generic modify field flow action introduced in [1] has some issues related to the immediate source operand: - immediate source can be presented either as an unsigned 64-bit integer or pointer to data pattern in memory. There was no explicit pointer field defined in the union. - the byte ordering for 64-bit integer was not specified. Many fields have shorter lengths and byte ordering is crucial. - how the bit offset is applied to the immediate source field was not defined and documented. - 64-bit integer size is not enough to provide IPv6 addresses. In order to cover the issues and exclude any ambiguities the following is done: - introduce the explicit pointer field in rte_flow_action_modify_data structure - replace the 64-bit unsigned integer with 16-byte array - update the modify field flow action documentation Appropriate deprecation notice has been removed. [1] commit 73b68f4c54a0 ("ethdev: introduce generic modify flow action") Fixes: 2ba49b5f3721 ("doc: announce change to ethdev modify action data") Signed-off-by: Viacheslav Ovsiienko Acked-by: Ori Kam Acked-by: Andrew Rybchenko --- doc/guides/prog_guide/rte_flow.rst | 24 +++++++++++++++++++++++- doc/guides/rel_notes/deprecation.rst | 4 ---- doc/guides/rel_notes/release_21_11.rst | 7 +++++++ lib/ethdev/rte_flow.h | 16 ++++++++++++---- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 2b42d5ec8c..b08087511f 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -2835,6 +2835,22 @@ a packet to any other part of it. ``value`` sets an immediate value to be used as a source or points to a location of the value in memory. It is used instead of ``level`` and ``offset`` for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. +The data in memory should be presented exactly in the same byte order and +length as in the relevant flow item, i.e. data for field with type +``RTE_FLOW_FIELD_MAC_DST`` should follow the conventions of ``dst`` field +in ``rte_flow_item_eth`` structure, with type ``RTE_FLOW_FIELD_IPV6_SRC`` - +``rte_flow_item_ipv6`` conventions, and so on. If the field size is larger than +16 bytes the pattern can be provided as pointer only. + +The bitfield extracted from the memory being applied as second operation +parameter is defined by action width and by the destination field offset. +Application should provide the data in immediate value memory (either as +buffer or by pointer) exactly as item field without any applied explicit offset, +and destination packet field (with specified width and bit offset) will be +replaced by immediate source bits from the same bit offset. For example, +to replace the third byte of MAC address with value 0x85, application should +specify destination width as 8, destination offset as 16, and provide immediate +value as sequence of bytes {xxx, xxx, 0x85, xxx, xxx, xxx}. .. _table_rte_flow_action_modify_field: @@ -2865,7 +2881,13 @@ for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. +---------------+----------------------------------------------------------+ | ``offset`` | number of bits to skip at the beginning | +---------------+----------------------------------------------------------+ - | ``value`` | immediate value or a pointer to this value | + | ``value`` | immediate value buffer (source field only, not | + | | applicable to destination) for RTE_FLOW_FIELD_VALUE | + | | field type | + +---------------+----------------------------------------------------------+ + | ``pvalue`` | pointer to immediate value data (source field only, not | + | | applicable to destination) for RTE_FLOW_FIELD_POINTER | + | | field type | +---------------+----------------------------------------------------------+ Action: ``CONNTRACK`` diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index a2fe766d4b..dee14077a5 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -120,10 +120,6 @@ Deprecation Notices * ethdev: Announce moving from dedicated modify function for each field, to using the general ``rte_flow_modify_field`` action. -* ethdev: The struct ``rte_flow_action_modify_data`` will be modified - to support modifying fields larger than 64 bits. - In addition, documentation will be updated to clarify byte order. - * ethdev: Attribute ``shared`` of the ``struct rte_flow_action_count`` is deprecated and will be removed in DPDK 21.11. Shared counters should be managed using shared actions API (``rte_flow_shared_action_create`` etc). diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index dfc2cbdeed..578c1206e7 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -187,6 +187,13 @@ API Changes the crypto/security operation. This field will be used to communicate events such as soft expiry with IPsec in lookaside mode. +* ethdev: ``rte_flow_action_modify_data`` structure updated, immediate data + array is extended, data pointer field is explicitly added to union, the + action behavior is defined in more strict fashion and documentation updated. + The immediate value behavior has been changed, the entire immediate field + should be provided, and offset for immediate source bitfield is assigned + from destination one. + ABI Changes ----------- diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 7b1ed7f110..f14f77772b 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -3217,10 +3217,18 @@ struct rte_flow_action_modify_data { uint32_t offset; }; /** - * Immediate value for RTE_FLOW_FIELD_VALUE or - * memory address for RTE_FLOW_FIELD_POINTER. + * Immediate value for RTE_FLOW_FIELD_VALUE, presented in the + * same byte order and length as in relevant rte_flow_item_xxx. + * The immediate source bitfield offset is inherited from + * the destination's one. */ - uint64_t value; + uint8_t value[16]; + /** + * Memory address for RTE_FLOW_FIELD_POINTER, memory layout + * should be the same as for relevant field in the + * rte_flow_item_xxx structure. + */ + void *pvalue; }; }; @@ -3240,7 +3248,7 @@ enum rte_flow_modify_op { * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD * * Modify a destination header field according to the specified - * operation. Another packet field can be used as a source as well + * operation. Another field of the packet can be used as a source as well * as tag, mark, metadata, immediate value or a pointer to it. */ struct rte_flow_action_modify_field { From patchwork Wed Oct 13 18:45:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 101472 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7126BA0C55; Wed, 13 Oct 2021 20:45:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E8BF411E3; Wed, 13 Oct 2021 20:45:41 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2044.outbound.protection.outlook.com [40.107.96.44]) by mails.dpdk.org (Postfix) with ESMTP id C6691411D8; Wed, 13 Oct 2021 20:45:39 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZNgdYQWHYFL6/PCB1k66GrFN76evf+8iCiO2oPA+T2tejXTAmDrF8y8PY61Byww9leXpS+CqE0GrA2QtqW6+PtnTL2mPHRL6aOxhu/3Wtkk0KV/n5nrCldGXfr7u52Ndir7o7Xa3BNPdrguow9LWl2uwtTujOei+oJd8koeM91DnsXrJadFvfzdaUObC+lnYUhna9r7sD1Oph+t5xdkRnc6ioEkL+3Z/+B/72Fa/CyK9HmO3S88tGZQ2D/vdPM7NdmG6kqPInEskK8hFclgmlYomss+iaZ6iORQsEHDpxiUh/Rd98iBjaNkMbsRpw5HRykvuJvpVj6bX5o3U8QJUXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yGIXHE/BwsULhYMEb0LRwQJ+Pvb7WhfDtERcWiJQ/Dw=; b=m4q31pM7BEvJbZIUQo7GS5n0ztjxxcDEfV+lLSufmzm0wvYCwBSaONMHP6wMhvhlj+5h6gNtqP4y6tTvq0mPU58e/H4dJN/r0bRqpfkp9szJEL5fXSQ4EEq0ocVXA1uUJOtZTmwc14mM31DUgHQMaYyUJuc1NKYh7WiroD6XdsU+I96K9URY/1aYfaw2Brq11rn66O8iJbxBsr7D52YxjCBvc/WffsGaYFbI2xmZc/xTlkzRVIH8/GwDARJbQWNztQhclRdV9Nl2eFCPkdtv+6IynmUfm67naMT+CV+LrqKrKKFpLHmN6LYU+zzIfno0eylO2xUtrr4RytolDq4AeQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yGIXHE/BwsULhYMEb0LRwQJ+Pvb7WhfDtERcWiJQ/Dw=; b=Ja0juTkFl1Vt9Kk/qRHqJswcNvrf6Pe2uJNDU1yG+Z1F3d8KhzpuxhVruELcAxoOhgi3w9goXlUkaBOr4x01yCnY9CkuAyHeWwEaQws4FS3gihFLoCn7iIGIPyFobP3qkTt/OshRCsh7rkJm+jqCDgZQh4nszTdLfVZjm+DlAvTb/aw/feimhloXhojQ0NAWVtnzCageS5IMpWSdIdkuJOaH0J8KhQojMc0v/3sHQblgsI9P8GJd7IpHlqutUlOYQZ+EndmqsLdvUCO+fRCrx3iORYfp7yTlS8lKf+O9BVJ9S+19Z4KdwUeGt5DVd7d0L/NPeHuTHl8ZrxfWX+RnyQ== Received: from MWHPR12CA0059.namprd12.prod.outlook.com (2603:10b6:300:103::21) by MW3PR12MB4410.namprd12.prod.outlook.com (2603:10b6:303:5b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.20; Wed, 13 Oct 2021 18:45:38 +0000 Received: from CO1NAM11FT043.eop-nam11.prod.protection.outlook.com (2603:10b6:300:103:cafe::50) by MWHPR12CA0059.outlook.office365.com (2603:10b6:300:103::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Wed, 13 Oct 2021 18:45:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT043.mail.protection.outlook.com (10.13.174.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4608.15 via Frontend Transport; Wed, 13 Oct 2021 18:45:38 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 13 Oct 2021 18:45:35 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , , Date: Wed, 13 Oct 2021 21:45:13 +0300 Message-ID: <20211013184516.25338-3-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20211013184516.25338-1-viacheslavo@nvidia.com> References: <20210910141609.8410-1-viacheslavo@nvidia.com> <20211013184516.25338-1-viacheslavo@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0621cc67-fa6a-4b57-b4a7-08d98e79a659 X-MS-TrafficTypeDiagnostic: MW3PR12MB4410: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1443; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O+OZ2ZswxrfzN76qqAHoSgAzF64NRrNtWXKyhwsdj9ZDghABjp6ORaiafEicNitj832C/Aw9FNTzSf5Mp5dFHMZqCvnYnB6T9goPrwttQ2BIjZvQI4J75q3CTFTdvII59M+r6JWA9LcBj/HMVeqkTDN3QG6zZfLGiabLRPx8+HXHXzZsffPVGlrEtXDvbQ4Ajw7PoyQprU1BCtrfYgKwl8Mss8rfGVB3zj2PbtgoLhvGs/bI15ik1tFZeaSVe8CWexx7RLbI066WBT1PtkBhKbFpXnIBsLvz8iPPZgYk1nTwXbgPv6JnAtt1iaZr334gGJ7mkpkGze1BsAzh26ONiwLxoJYx23kEsSFwqBGchpl873/+AT6nYmH4EHdPAgGUTAfa/Kh+KnMpvK+dNTuNF2nT24j2eNM0CRuWSyeanvrOEHmtCfZNkedYxSyuEOVaUtkIvtD8fBJh7PY4FPyl2PV31PlEVaYk2hA0WMVbcns7/weev3sg/plbkvMjXafD/aHtEqyTulhClEmyOPdVjSHwlCKxfCChXyyXQu/ktF7dDqq4aK9NHQ4+EclxyeIhTOhwjLQA2Kkj7p5NRickU5L7NmQEf4nPXP48A5b6gqCp/4J1Ouq89EGwOGOxueL4n4qIm+f2FpSmbIMxupoElKFtTzwsGVALQmyHHSIt3uwndmJ1Q1Q+ngzrx6FBiCg0HcM2GdUdJBR1XM1pW5++yA== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(86362001)(508600001)(8936002)(316002)(16526019)(5660300002)(47076005)(70586007)(356005)(7636003)(6916009)(82310400003)(36860700001)(186003)(7696005)(70206006)(4744005)(336012)(55016002)(1076003)(4326008)(426003)(8676002)(6286002)(83380400001)(54906003)(6666004)(26005)(2616005)(36756003)(36906005)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2021 18:45:38.1510 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0621cc67-fa6a-4b57-b4a7-08d98e79a659 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT043.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4410 Subject: [dpdk-dev] [PATCH v6 2/5] ethdev: fix missed experimental tag for modify field action X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" EXPERIMENTAL tag was missed in rte_flow_action_modify_data structure description. Fixes: 73b68f4c54a0 ("ethdev: introduce generic modify flow action") Cc: stable@dpdk.org Signed-off-by: Viacheslav Ovsiienko Acked-by: Ori Kam Acked-by: Andrew Rybchenko --- lib/ethdev/rte_flow.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index f14f77772b..8a1eddd0b7 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -3204,6 +3204,9 @@ enum rte_flow_field_id { }; /** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * * Field description for MODIFY_FIELD action. */ struct rte_flow_action_modify_data { From patchwork Wed Oct 13 18:45:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 101473 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AF4B5A0C55; Wed, 13 Oct 2021 20:46:00 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E1A3741215; Wed, 13 Oct 2021 20:45:43 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2074.outbound.protection.outlook.com [40.107.237.74]) by mails.dpdk.org (Postfix) with ESMTP id 208F5411F6 for ; Wed, 13 Oct 2021 20:45:42 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mey3jYnBUxV0DcjTUobhgwTSlBPWfTj1qMVFFknzCOwA5hCeVZ6lhVxtBQcpe1vYFnxBIxIqDR+D2NKDt6tNU3pQfgoTEGpSSZH4TLCYMFAW+76W9pl3p49eyegWmwhjxrqC6+R0gtmXsXOwyx76zYlLLMe0eYofTzZYj6OHWQtVzEyJpvS1PHJRN0TNniFpD/ve78v2Vv3hHt7AXBjweMcToayX5GLhm1dB2DAM2ph75i0FOvbRA2EsOnxvu2ELHp2m7hl7yHlUOB7MbpBpYaxb81WGmcvCNAWAM19Ju81HqHcjb+MZA4vKB5HhYmPCXuzCWXALM3k+7k2XLdP33g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7dCXAxZpE5+0obHyfmSp680hj9gaTcERFOgjUbNe7MU=; b=h0uKuRypwVYeVW+64QTm0RsK4LCpH3LLDvPnU6rbJ8L8RbYg6F+CIqqshFRJ2kYngCGn1xoxFjLUcOsEpKbdB39ybICcdL6UHeEqMdjCH7/2oe6wh/0szLkNfXDXlZtLdoSslhQPgrd/HmfccjxJy9tiy6DmPVgOO2DV9WOWn/RrX6pefOAUEm1J6upPDR4yfCgiZu5heu+CiVI3x0InrCc1D2yyoAwvjmaCPWxNuqOTmMlZaxRQJNokzqaDv/oHbOUwT/0ujxR0U9THoGnieFldr6/sL0GbtvhpHZL4i6FSeNen1KOFNgDpl0SMt2q8fUkfXgkyhR4ZSUyLdsMWTQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7dCXAxZpE5+0obHyfmSp680hj9gaTcERFOgjUbNe7MU=; b=tlPJJQypjaklqE2S8je+CJgqYrdDSgrwY9lISL6F2peZ68oncbSpRk8ZBwQRrlTdMAK9KdJtSr0Z5cq/7fsxMq+VvpqDFNqVLecFUpz6LVrtVHwJJMJe+2/QQecqRtqd1UpVRIvuHoze2GRvE9H0G40tlZmqG3Qy7hsCvMhwziDulIPgClEoxR9z0+/C/FBd5blUZwCSgAXjOPpOmfUpmvkNyhQQoWuCpo8Hj62qFDbVtnX0pvVr5TZry/ZsnKJ5GTbDF1PzDRvETnDoHyQWP4r25cbjBDHsbhho/LOTssa+EFvE+1mqepRCvaAwc/77G7ZrOpI1ewpwiQ6FReykyQ== Received: from MWHPR14CA0057.namprd14.prod.outlook.com (2603:10b6:300:81::19) by MWHPR12MB1167.namprd12.prod.outlook.com (2603:10b6:300:8::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16; Wed, 13 Oct 2021 18:45:40 +0000 Received: from CO1NAM11FT016.eop-nam11.prod.protection.outlook.com (2603:10b6:300:81:cafe::f2) by MWHPR14CA0057.outlook.office365.com (2603:10b6:300:81::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Wed, 13 Oct 2021 18:45:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT016.mail.protection.outlook.com (10.13.175.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4608.15 via Frontend Transport; Wed, 13 Oct 2021 18:45:40 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 13 Oct 2021 18:45:38 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , Date: Wed, 13 Oct 2021 21:45:14 +0300 Message-ID: <20211013184516.25338-4-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20211013184516.25338-1-viacheslavo@nvidia.com> References: <20210910141609.8410-1-viacheslavo@nvidia.com> <20211013184516.25338-1-viacheslavo@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cffabcb9-7720-4b9c-b268-08d98e79a777 X-MS-TrafficTypeDiagnostic: MWHPR12MB1167: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X9jLCLzRDMro3Ovfd0CHObmLUad4fei6OHDkrZi1vTFKVTPurHIBP5SI9uowO2NtF7PqGDPFOwJgJa4ZawLU3K0Hr1Lkx2zQmwfQev7PRleidLgAl/1iyefSwin5MCKYV5AXbXMP96kaa4VYOU/8tvohjKA86cQs9ljyEj5+flsfULUIx0TFRJdvp7qXhP1+X3fz4HVKVGX1Z1HXzVIV7Srm5GxFB4oAW1fu9S2FWc9kY+G59089kU1YePoQiRYd5OJHGi/2UXEPXo70eUE5aLUkufJ3YyRFzuNvtLbkwcTqxfuupJ+JtIxZPUoJvINguyncgJVJnB07FkWHneGL+vlgtEAEhmo8xAytPrTMjiUt4AExzQrEZisK8JeVvtkdnrRNOfnBhwxOyPm9FoHXKKchYclbyeuSXB7dASR9iRc0do1BcOrWLQRb1r4TNA078cHuKXRh/91LdYj+UaSHiAo30BCqL6I4QmF+Mk8OwSK0V9xwT3DbHt7wm8IE/gvB80hqNDtsvyMIRMzOwZorZqIG6c4F9rm1hDnthaGGTZsMoko+GoF0Md6/Sohmr8jq9uU44fNEeIoLLJukNkwp9A9pQyPPnNzYXaHrio0UNr90QKxxuDBYrfqC+syMgQvsqtcNbDEzu4UV5UmYwvLp2u1cxyFjLxW/ofS/95t2qKCKRrMVvDJGWLR2zrZfJsh6rIAcKvUD0oNoecMPhHROcg== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(6916009)(55016002)(2616005)(1076003)(4326008)(82310400003)(83380400001)(508600001)(8676002)(426003)(356005)(36756003)(36906005)(7636003)(186003)(36860700001)(6286002)(26005)(16526019)(316002)(336012)(2906002)(6666004)(47076005)(70586007)(70206006)(7696005)(15650500001)(8936002)(54906003)(5660300002)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2021 18:45:40.0434 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cffabcb9-7720-4b9c-b268-08d98e79a777 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT016.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1167 Subject: [dpdk-dev] [PATCH v6 3/5] app/testpmd: update modify field flow action support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" The testpmd flow create command updates provided: - modify field action supports the updated actions - pointer type added for action source field - pointer and value source field takes hex string instead of unsigned int in host endianness There are some examples of flow with update modified field action: 1. IPv6 destination address bytes 4-7 assignment: 0000::1111 - > 0000:xxxx:4455:6677::1111 flow create 0 egress group 1 pattern eth / ipv6 dst is 0000::1111 / udp / end actions modify_field op set dst_type ipv6_dst dst_offset 32 src_type value src_value 0011223344556677 width 32 / end 2. Copy second byte of IPv4 destination address to the third byte of source address: 10.0.118.4 -> 192.168.100.1 10.0.168.4 -> 192.168.100.1 flow create 0 egress group 1 pattern eth / ipv4 / udp / end actions modify_field op set dst_type ipv4_src dst_offset 16 src_type ipv4_dst src_offset 8 width 8 / end 3. Assign METADATA value with 11223344 value from the hex string in the linear buffer. Please note, the value definition should follow host-endian, example is given for x86 (little-endian): flow create 0 egress group 1 pattern eth / ipv4 / end actions modify_field op set dst_type meta src_type pointer src_ptr 44332211 width 32 / end 4. Assign destination MAC with EA:11:0B:AD:0B:ED value: flow create 0 egress group 1 pattern eth / end actions modify_field op set dst_type mac_dst src_type value src_value EA110BAD0BED width 48 / end Signed-off-by: Viacheslav Ovsiienko Acked-by: Ori Kam --- app/test-pmd/cmdline_flow.c | 55 +++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index bb22294dd3..736029c4fd 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -448,6 +448,7 @@ enum index { ACTION_MODIFY_FIELD_SRC_LEVEL, ACTION_MODIFY_FIELD_SRC_OFFSET, ACTION_MODIFY_FIELD_SRC_VALUE, + ACTION_MODIFY_FIELD_SRC_POINTER, ACTION_MODIFY_FIELD_WIDTH, ACTION_CONNTRACK, ACTION_CONNTRACK_UPDATE, @@ -468,6 +469,14 @@ enum index { #define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) +/** Maximum size for external pattern in struct rte_flow_action_modify_data. */ +#define ACTION_MODIFY_PATTERN_SIZE 32 + +/** Storage size for struct rte_flow_action_modify_field including pattern. */ +#define ACTION_MODIFY_SIZE \ + (sizeof(struct rte_flow_action_modify_field) + \ + ACTION_MODIFY_PATTERN_SIZE) + /** Maximum number of queue indices in struct rte_flow_action_rss. */ #define ACTION_RSS_QUEUE_NUM 128 @@ -1704,6 +1713,7 @@ static const enum index action_modify_field_src[] = { ACTION_MODIFY_FIELD_SRC_LEVEL, ACTION_MODIFY_FIELD_SRC_OFFSET, ACTION_MODIFY_FIELD_SRC_VALUE, + ACTION_MODIFY_FIELD_SRC_POINTER, ACTION_MODIFY_FIELD_WIDTH, ZERO, }; @@ -4455,8 +4465,7 @@ static const struct token token_list[] = { [ACTION_MODIFY_FIELD] = { .name = "modify_field", .help = "modify destination field with data from source field", - .priv = PRIV_ACTION(MODIFY_FIELD, - sizeof(struct rte_flow_action_modify_field)), + .priv = PRIV_ACTION(MODIFY_FIELD, ACTION_MODIFY_SIZE), .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)), .call = parse_vc, }, @@ -4539,11 +4548,26 @@ static const struct token token_list[] = { .name = "src_value", .help = "source immediate value", .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH), - NEXT_ENTRY(COMMON_UNSIGNED)), - .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + NEXT_ENTRY(COMMON_HEX)), + .args = ARGS(ARGS_ENTRY_ARB(0, 0), + ARGS_ENTRY_ARB(0, 0), + ARGS_ENTRY(struct rte_flow_action_modify_field, src.value)), .call = parse_vc_conf, }, + [ACTION_MODIFY_FIELD_SRC_POINTER] = { + .name = "src_ptr", + .help = "pointer to source immediate value", + .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH), + NEXT_ENTRY(COMMON_HEX)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.pvalue), + ARGS_ENTRY_ARB(0, 0), + ARGS_ENTRY_ARB + (sizeof(struct rte_flow_action_modify_field), + ACTION_MODIFY_PATTERN_SIZE)), + .call = parse_vc_conf, + }, [ACTION_MODIFY_FIELD_WIDTH] = { .name = "width", .help = "number of bits to copy", @@ -7830,15 +7854,11 @@ static int comp_set_modify_field_op(struct context *ctx, const struct token *token, unsigned int ent, char *buf, unsigned int size) { - uint16_t idx = 0; - RTE_SET_USED(ctx); RTE_SET_USED(token); - for (idx = 0; modify_field_ops[idx]; ++idx) - ; if (!buf) - return idx + 1; - if (ent < idx) + return RTE_DIM(modify_field_ops); + if (ent < RTE_DIM(modify_field_ops) - 1) return strlcpy(buf, modify_field_ops[ent], size); return -1; } @@ -7848,16 +7868,17 @@ static int comp_set_modify_field_id(struct context *ctx, const struct token *token, unsigned int ent, char *buf, unsigned int size) { - uint16_t idx = 0; + const char *name; - RTE_SET_USED(ctx); RTE_SET_USED(token); - for (idx = 0; modify_field_ids[idx]; ++idx) - ; if (!buf) - return idx + 1; - if (ent < idx) - return strlcpy(buf, modify_field_ids[ent], size); + return RTE_DIM(modify_field_ids); + if (ent >= RTE_DIM(modify_field_ids) - 1) + return -1; + name = modify_field_ids[ent]; + if (ctx->curr == ACTION_MODIFY_FIELD_SRC_TYPE || + (strcmp(name, "pointer") && strcmp(name, "value"))) + return strlcpy(buf, name, size); return -1; } From patchwork Wed Oct 13 18:45:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 101474 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 06793A0C55; Wed, 13 Oct 2021 20:46:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ED917411FA; Wed, 13 Oct 2021 20:45:45 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2071.outbound.protection.outlook.com [40.107.94.71]) by mails.dpdk.org (Postfix) with ESMTP id 914DA4121D; Wed, 13 Oct 2021 20:45:44 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PoPdYjHGJ8S2XqwLq/GCLjGRDhqyIMrHc/1Rs32kwZFnfy87jUPyB9X5BnGECGCQWA6p9Wf8eANzFbJtNr6kWhhZiyB/+ha3b/mETu7qRBmCxqCZC45VE1Ljy06OZiOl2Maq2QOYPhy58vv4zKQzsLJ5fadEtVY9plKQVNxsS9ROP34VBDdEbLYfbDES5ldjPAMbuBvXj/zpVTDV4Bx0Ysvh06FwhYGL5mlD4NedrO2zjFnvotquPktipOSMxoWR751rtHQY7BB384FxlEtEZEMmq/wo+lOrtkKKb+w2rDRHoB8D5kD1xaY6hIc93nMTFDIj+OaGm6Tx4epkeOiUdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TJ3ma+w+SZM3lSH36wTvF3MwpDEU6LoJpX8Xc8eQXg8=; b=ZsPT6HHHOyubwERmQhr2n5cor95omuYn2/A1RPY+G3Gjh47yPzP8L4fVp5nbXJv+/nt0+NYuaeEmJwC2B1YjoVDm2BKPJMQ0Tz3eNQh7ufgo8UKpW4JPooM2guzK79dNctaevyxOqyIV9XKQuEdV5Mi1xE7T/+EiQ4g/ZMDIsRH0ZdUKPYCpWuRinkhprQrijL+kGYA5RSB38uPjitTi2gMHUiuA/QGnMUubM2Ct7ZBHl0Ck75sH0BkcDD6M4tkWPxJ35jOqphO9p8IbRORHe1AEwWZXK5a1KAmKPL3M+g7baiVv3QGN7Ll6kyCxjOBCiIciaFOhsFJOAYWzTzFTmQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TJ3ma+w+SZM3lSH36wTvF3MwpDEU6LoJpX8Xc8eQXg8=; b=tL5YINyGkFMnNK7rCZTkpD4a5sBz8RpK4KFoHp0iW6JLQF14VAUdgVmN3JQCm7bqx1VxJw2zOENxrRysi9RUdsFfcDjoPJetxU+S64dgd5V+plmp+Q8dF3Mwq7UWvpgqqLd1NRdCBrT92VnckZlbxN0Z0kO+nDWL+CQO36kHdQGu2et4seN0WTD93eVqjnlmtrZMScN/Q15o2H2rD1nnbYrqhfGUE9GjqUbFBXU1igz/F5SaUtBM1m/b5zotMJ7NJA5sOxp3BKxC+PvT5DPbl8F5UX7bmq+TsOTJM6efzMuYBzBG7jsBQgOz82AkW47nW8l4fG9XmsqRhDk1QDkbQw== Received: from MWHPR14CA0050.namprd14.prod.outlook.com (2603:10b6:300:81::12) by BL0PR12MB5540.namprd12.prod.outlook.com (2603:10b6:208:1cb::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15; Wed, 13 Oct 2021 18:45:43 +0000 Received: from CO1NAM11FT016.eop-nam11.prod.protection.outlook.com (2603:10b6:300:81:cafe::dc) by MWHPR14CA0050.outlook.office365.com (2603:10b6:300:81::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Wed, 13 Oct 2021 18:45:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT016.mail.protection.outlook.com (10.13.175.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4608.15 via Frontend Transport; Wed, 13 Oct 2021 18:45:42 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 13 Oct 2021 18:45:40 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , , Date: Wed, 13 Oct 2021 21:45:15 +0300 Message-ID: <20211013184516.25338-5-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20211013184516.25338-1-viacheslavo@nvidia.com> References: <20210910141609.8410-1-viacheslavo@nvidia.com> <20211013184516.25338-1-viacheslavo@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 73ed2ac9-b97f-45b7-ab08-08d98e79a8df X-MS-TrafficTypeDiagnostic: BL0PR12MB5540: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zEkZaJJBG2+Ui/9voSpzArhMdBQIsnksIiLfBRB+gIUn+SF+F35wDh5rjsAlz9CD/wEGOPOich2qymnZ2q2E9rEUSeyQq6HYqxDLKda0aGnawjHp14ds7e80He7Bt888XzI+WN+2X0NIBAp7FL2CGCJA4f6UQVfD2Q6N0JEf4FRwfU68N2oUHdk3npHutbqmne8akc7ZZa+OyLW43Ef4qN9OCpRWqTFQZnbGuiVyfyPmG3g7tkPnTUe9Ulx/nGJJpRYEO0AqPmuiV98lgtsseIgfoEsDh4LoNBf178lO3bZBB7mozTCwRKtMpO6BVTsacnTgkc0fnJuuL8LHoavppon5IXQ+5HZCCh0dwHfQgzAi9tyMAp5XTrD+fBhglMAWwor+gRcg95/IDWNVwFHMzal7wThfXE6KqK52TPpCQSHueMSXGXRdl8r8ESjZWp8CsnEkE9QR75JzWScz3znTcKpzg6x6vu2iXNCrCAxl0r2bVDf7l9b9rPWStrVOmMX74sUi4uJN82hVPx/sA3jdNNmZcy3EEXwbzWWX64kwNw5jCdnfo/eiVS5zL7Q8818XCzHeq+r7eRFAQ8554rMaSlwnoTjjT5bT5aVtta1KHi6PCkOnP9tDC+KzetG9kCHHTz6HGi194DULLGUkweqkfvF6v5b/ixgOSIy/Lr8UqtWiMoG8kFiXM9OBJYteyqsAo2IhtrG3Ld8tvcpu+0snNw== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(336012)(55016002)(83380400001)(70206006)(36756003)(8676002)(1076003)(36906005)(316002)(82310400003)(36860700001)(5660300002)(4326008)(47076005)(6916009)(2616005)(2906002)(26005)(16526019)(86362001)(6666004)(54906003)(8936002)(70586007)(7696005)(186003)(426003)(508600001)(7636003)(6286002)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2021 18:45:42.3940 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 73ed2ac9-b97f-45b7-ab08-08d98e79a8df X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT016.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB5540 Subject: [dpdk-dev] [PATCH v6 4/5] app/testpmd: fix hex string parser in flow commands X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" The hexadecimal string parser does not check the target field buffer size, buffer overflow happens and might cause the application failure (segmentation fault is observed usually). Fixes: 169a9fed1f4c ("app/testpmd: fix hex string parser support for flow API") Cc: stable@dpdk.org Signed-off-by: Viacheslav Ovsiienko Acked-by: Ori Kam --- app/test-pmd/cmdline_flow.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 736029c4fd..6827d9228f 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -7291,10 +7291,13 @@ parse_hex(struct context *ctx, const struct token *token, hexlen -= 2; } if (hexlen > length) - return -1; + goto error; ret = parse_hex_string(str, hex_tmp, &hexlen); if (ret < 0) goto error; + /* Check the converted binary fits into data buffer. */ + if (hexlen > size) + goto error; /* Let parse_int() fill length information first. */ ret = snprintf(tmp, sizeof(tmp), "%u", hexlen); if (ret < 0) From patchwork Wed Oct 13 18:45:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 101475 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D1232A0C55; Wed, 13 Oct 2021 20:46:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1017141226; Wed, 13 Oct 2021 20:45:49 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2070.outbound.protection.outlook.com [40.107.93.70]) by mails.dpdk.org (Postfix) with ESMTP id 1BA8C41226 for ; Wed, 13 Oct 2021 20:45:47 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ayCU00ytQCagBGLqClAPcIDvBy9Ur9T5zFSiNN/XSrA4F6vxudeBebqy3EWHphvH95dfYqnnFzF+/FmNTZyHsTRSOmpRMFwAlrBodOMl8VsQgAmN3om2r1lWiW/oxTV52LVRjySBh9UgFliTHLbvDjuiNQBhYyew26uP5qZSrvyg8gjP00CYRDyESQLlnnqMVc3DraLXTVR48q6/KsRC09TQqdJLVeGnL2UZGNzlTko1XbdUr6Saq6hPOiBP/I/asWobruFdAH/HllW3HbO2nG9p8ifldSf5BUwKmHyQX8k4AH9HjW3rSHJbvUlFqN5eCNwgAkvlDVB625yiSYWN7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ofVLDO0r4Tmvtchy2mYhNtvTxa5ZVSx3zG7JvGc3cNQ=; b=UZ9n7r6uNQq9xX8Da8G9Qgb5UuNxgLdfd9voP5SonRy7fvbGtwLT25YztzwKnd+pYSsrh0XaoyA0sbJ2o70Z5VwDBlv8XglslAB7v4qDaNYG91pJZQPwr/5ljolyIaoG+Qn9rpCW8ZJYZqCoOYXpeLjJsbdzRiufFi4ch2ngJWyAtdeWVqjm9oBVF2CGJOBmaO0T2qx2YQT+eZt3oSSW0mHfkTPvYg0R1JoM6wraPcy4gkKiXiV/N6iJPQ9Q3kb+EgbNjruQcqhyBC9bFVoRDfHzymDwtftmevwpSiymkt/cPr3M43yWPWi401yT41A+vbKoDyh/tS6SMk1iPsXlHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ofVLDO0r4Tmvtchy2mYhNtvTxa5ZVSx3zG7JvGc3cNQ=; b=NSGb85mwq3vEY4MELRRwvwEFQ4CzqAz7RLdtcIscqihMhzTB6d/673whiPliVrk1LsmoRr44R57QOADrM9l5KQMB79YC0L5Y1S1B1f9N1AlDXKS3gYgrJBWOGrykNppr4TruM7u9gQHBhDhvEzsRkTevBJjShYu5eK1FVvvIAn6Ny7YrBPy4p7uZ+zCnvMcnN7b3Dji+s0lak0dnQHHAbzK1VX89ypyl70oLAfOT637vQhxvUzg5liTsxUxU7MuEXc0fa6CS+bBWTLPXmactfRUwwf/C+je+Q9r5NRC7rmxv9+rHyJdrjaFoWlQX8BpWhus/kNfiVJmAa4byE6I0xg== Received: from MWHPR21CA0045.namprd21.prod.outlook.com (2603:10b6:300:129::31) by BY5PR12MB4033.namprd12.prod.outlook.com (2603:10b6:a03:213::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.22; Wed, 13 Oct 2021 18:45:45 +0000 Received: from CO1NAM11FT022.eop-nam11.prod.protection.outlook.com (2603:10b6:300:129:cafe::49) by MWHPR21CA0045.outlook.office365.com (2603:10b6:300:129::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.1 via Frontend Transport; Wed, 13 Oct 2021 18:45:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT022.mail.protection.outlook.com (10.13.175.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4608.15 via Frontend Transport; Wed, 13 Oct 2021 18:45:44 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 13 Oct 2021 18:45:42 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , Date: Wed, 13 Oct 2021 21:45:16 +0300 Message-ID: <20211013184516.25338-6-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20211013184516.25338-1-viacheslavo@nvidia.com> References: <20210910141609.8410-1-viacheslavo@nvidia.com> <20211013184516.25338-1-viacheslavo@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fc12b498-a0fd-4e8b-e980-08d98e79aa54 X-MS-TrafficTypeDiagnostic: BY5PR12MB4033: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vW3wLJiX1f5V7umubqC+9eihVfgMzr9hzupVZkIRgOy90EkkGxUHbqaNIe8Y1eTCtSd0FPeeimDbG/MG+A2HLxm9ybt3ErzyTzR7FjN4b/RPfnluiAj93hoPWETAE+h7Deo133tgv4DLkLCHpltmhJuSIXlLr8tpuq7fTeP0bpl0IB3r209+d2Ml3Gs0J6st1ym/c3k1jvozY4gvBKDqyGoYAHErIplikulP7z1kD7HLUjda0Wlq8pU9kX1YxHGfIZvkLoMqktEB5ITG2LVYC9O30VB7jA3B9rZfGxOzqE6ZBG0gRLUopk1v5eKZDpZfqBq4osS/P54CC16cV06XpJGMElVvE627YJmpxJqDYLH6MVd5BM4gflIog5XN7jJe7/E+uPeGAC2dCaL/1sw8QBdGwM08mKmZJtrGw3HxxHtctGogrW45WipKCO3OhuvqRLlqjToJg64ya0ExK2/WdFCL0/dLZC/9RT3wG1Ejh/dLVevs5Dp8CzGxU14u5MBCzTXK5A8ZqIl3msaLNu4efv3eWkwxR2Y9rehAsdh3sdiH5tIXoEXhmEhPnFh6YH4tBabb1hIIAP0PYgf/bUMh6qnV9Tat+plzTGOQ3wuxMWZu0/ygN4tTJQwo7TJk6gicb53Lekbp/nUO3l4Se8lW75mNrNsvFEwKaqts5iKSTZyXaOKfLRPj7tzHXXVuS+gSCiBSLF5eOteSUsUjuGmnnQ== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(6666004)(7696005)(86362001)(47076005)(30864003)(508600001)(8936002)(6286002)(6916009)(4326008)(2906002)(8676002)(83380400001)(36906005)(36860700001)(1076003)(2616005)(70586007)(82310400003)(55016002)(70206006)(7636003)(186003)(426003)(5660300002)(54906003)(36756003)(356005)(336012)(26005)(15650500001)(316002)(16526019); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2021 18:45:44.7415 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fc12b498-a0fd-4e8b-e980-08d98e79aa54 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT022.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4033 Subject: [dpdk-dev] [PATCH v6 5/5] net/mlx5: update modify field action X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Update immediate value/pointer source operand support for modify field RTE Flow action: - source operand data can be presented by byte buffer (instead of former uint64_t) or by pointer - no host byte ordering is assumed anymore for immediate data buffer (not uint64_t anymore) - no immediate value offset is expected (the source subfield is located at the same offset as in destination) Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow_dv.c | 128 +++++++++++--------------------- 1 file changed, 44 insertions(+), 84 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index c6370cd1d6..552b149041 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -1391,7 +1391,7 @@ flow_dv_convert_action_modify_ipv6_dscp static int mlx5_flow_item_field_width(struct mlx5_priv *priv, - enum rte_flow_field_id field) + enum rte_flow_field_id field, int inherit) { switch (field) { case RTE_FLOW_FIELD_START: @@ -1442,7 +1442,7 @@ mlx5_flow_item_field_width(struct mlx5_priv *priv, return __builtin_popcount(priv->sh->dv_meta_mask); case RTE_FLOW_FIELD_POINTER: case RTE_FLOW_FIELD_VALUE: - return 64; + return inherit < 0 ? 0 : inherit; default: MLX5_ASSERT(false); } @@ -1452,17 +1452,14 @@ mlx5_flow_item_field_width(struct mlx5_priv *priv, static void mlx5_flow_field_id_to_modify_info (const struct rte_flow_action_modify_data *data, - struct field_modify_info *info, - uint32_t *mask, uint32_t *value, - uint32_t width, uint32_t dst_width, - uint32_t *shift, struct rte_eth_dev *dev, - const struct rte_flow_attr *attr, - struct rte_flow_error *error) + struct field_modify_info *info, uint32_t *mask, + uint32_t width, uint32_t *shift, struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, struct rte_flow_error *error) { struct mlx5_priv *priv = dev->data->dev_private; uint32_t idx = 0; uint32_t off = 0; - uint64_t val = 0; + switch (data->field) { case RTE_FLOW_FIELD_START: /* not supported yet */ @@ -1472,7 +1469,7 @@ mlx5_flow_field_id_to_modify_info off = data->offset > 16 ? data->offset - 16 : 0; if (mask) { if (data->offset < 16) { - info[idx] = (struct field_modify_info){2, 0, + info[idx] = (struct field_modify_info){2, 4, MLX5_MODI_OUT_DMAC_15_0}; if (width < 16) { mask[idx] = rte_cpu_to_be_16(0xffff >> @@ -1486,15 +1483,15 @@ mlx5_flow_field_id_to_modify_info break; ++idx; } - info[idx] = (struct field_modify_info){4, 4 * idx, + info[idx] = (struct field_modify_info){4, 0, MLX5_MODI_OUT_DMAC_47_16}; mask[idx] = rte_cpu_to_be_32((0xffffffff >> (32 - width)) << off); } else { if (data->offset < 16) - info[idx++] = (struct field_modify_info){2, 0, + info[idx++] = (struct field_modify_info){2, 4, MLX5_MODI_OUT_DMAC_15_0}; - info[idx] = (struct field_modify_info){4, off, + info[idx] = (struct field_modify_info){4, 0, MLX5_MODI_OUT_DMAC_47_16}; } break; @@ -1502,7 +1499,7 @@ mlx5_flow_field_id_to_modify_info off = data->offset > 16 ? data->offset - 16 : 0; if (mask) { if (data->offset < 16) { - info[idx] = (struct field_modify_info){2, 0, + info[idx] = (struct field_modify_info){2, 4, MLX5_MODI_OUT_SMAC_15_0}; if (width < 16) { mask[idx] = rte_cpu_to_be_16(0xffff >> @@ -1516,15 +1513,15 @@ mlx5_flow_field_id_to_modify_info break; ++idx; } - info[idx] = (struct field_modify_info){4, 4 * idx, + info[idx] = (struct field_modify_info){4, 0, MLX5_MODI_OUT_SMAC_47_16}; mask[idx] = rte_cpu_to_be_32((0xffffffff >> (32 - width)) << off); } else { if (data->offset < 16) - info[idx++] = (struct field_modify_info){2, 0, + info[idx++] = (struct field_modify_info){2, 4, MLX5_MODI_OUT_SMAC_15_0}; - info[idx] = (struct field_modify_info){4, off, + info[idx] = (struct field_modify_info){4, 0, MLX5_MODI_OUT_SMAC_47_16}; } break; @@ -1584,8 +1581,7 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_IPV6_SRC: if (mask) { if (data->offset < 32) { - info[idx] = (struct field_modify_info){4, - 4 * idx, + info[idx] = (struct field_modify_info){4, 12, MLX5_MODI_OUT_SIPV6_31_0}; if (width < 32) { mask[idx] = @@ -1601,8 +1597,7 @@ mlx5_flow_field_id_to_modify_info ++idx; } if (data->offset < 64) { - info[idx] = (struct field_modify_info){4, - 4 * idx, + info[idx] = (struct field_modify_info){4, 8, MLX5_MODI_OUT_SIPV6_63_32}; if (width < 32) { mask[idx] = @@ -1618,8 +1613,7 @@ mlx5_flow_field_id_to_modify_info ++idx; } if (data->offset < 96) { - info[idx] = (struct field_modify_info){4, - 4 * idx, + info[idx] = (struct field_modify_info){4, 4, MLX5_MODI_OUT_SIPV6_95_64}; if (width < 32) { mask[idx] = @@ -1634,19 +1628,19 @@ mlx5_flow_field_id_to_modify_info break; ++idx; } - info[idx] = (struct field_modify_info){4, 4 * idx, + info[idx] = (struct field_modify_info){4, 0, MLX5_MODI_OUT_SIPV6_127_96}; mask[idx] = rte_cpu_to_be_32(0xffffffff >> (32 - width)); } else { if (data->offset < 32) - info[idx++] = (struct field_modify_info){4, 0, + info[idx++] = (struct field_modify_info){4, 12, MLX5_MODI_OUT_SIPV6_31_0}; if (data->offset < 64) - info[idx++] = (struct field_modify_info){4, 0, + info[idx++] = (struct field_modify_info){4, 8, MLX5_MODI_OUT_SIPV6_63_32}; if (data->offset < 96) - info[idx++] = (struct field_modify_info){4, 0, + info[idx++] = (struct field_modify_info){4, 4, MLX5_MODI_OUT_SIPV6_95_64}; if (data->offset < 128) info[idx++] = (struct field_modify_info){4, 0, @@ -1656,8 +1650,7 @@ mlx5_flow_field_id_to_modify_info case RTE_FLOW_FIELD_IPV6_DST: if (mask) { if (data->offset < 32) { - info[idx] = (struct field_modify_info){4, - 4 * idx, + info[idx] = (struct field_modify_info){4, 12, MLX5_MODI_OUT_DIPV6_31_0}; if (width < 32) { mask[idx] = @@ -1673,8 +1666,7 @@ mlx5_flow_field_id_to_modify_info ++idx; } if (data->offset < 64) { - info[idx] = (struct field_modify_info){4, - 4 * idx, + info[idx] = (struct field_modify_info){4, 8, MLX5_MODI_OUT_DIPV6_63_32}; if (width < 32) { mask[idx] = @@ -1690,8 +1682,7 @@ mlx5_flow_field_id_to_modify_info ++idx; } if (data->offset < 96) { - info[idx] = (struct field_modify_info){4, - 4 * idx, + info[idx] = (struct field_modify_info){4, 4, MLX5_MODI_OUT_DIPV6_95_64}; if (width < 32) { mask[idx] = @@ -1706,19 +1697,19 @@ mlx5_flow_field_id_to_modify_info break; ++idx; } - info[idx] = (struct field_modify_info){4, 4 * idx, + info[idx] = (struct field_modify_info){4, 0, MLX5_MODI_OUT_DIPV6_127_96}; mask[idx] = rte_cpu_to_be_32(0xffffffff >> (32 - width)); } else { if (data->offset < 32) - info[idx++] = (struct field_modify_info){4, 0, + info[idx++] = (struct field_modify_info){4, 12, MLX5_MODI_OUT_DIPV6_31_0}; if (data->offset < 64) - info[idx++] = (struct field_modify_info){4, 0, + info[idx++] = (struct field_modify_info){4, 8, MLX5_MODI_OUT_DIPV6_63_32}; if (data->offset < 96) - info[idx++] = (struct field_modify_info){4, 0, + info[idx++] = (struct field_modify_info){4, 4, MLX5_MODI_OUT_DIPV6_95_64}; if (data->offset < 128) info[idx++] = (struct field_modify_info){4, 0, @@ -1838,35 +1829,6 @@ mlx5_flow_field_id_to_modify_info break; case RTE_FLOW_FIELD_POINTER: case RTE_FLOW_FIELD_VALUE: - if (data->field == RTE_FLOW_FIELD_POINTER) - memcpy(&val, (void *)(uintptr_t)data->value, - sizeof(uint64_t)); - else - val = data->value; - for (idx = 0; idx < MLX5_ACT_MAX_MOD_FIELDS; idx++) { - if (mask[idx]) { - if (dst_width == 48) { - /*special case for MAC addresses */ - value[idx] = rte_cpu_to_be_16(val); - val >>= 16; - dst_width -= 16; - } else if (dst_width > 16) { - value[idx] = rte_cpu_to_be_32(val); - val >>= 32; - } else if (dst_width > 8) { - value[idx] = rte_cpu_to_be_16(val); - val >>= 16; - } else { - value[idx] = (uint8_t)val; - val >>= 8; - } - if (*shift) - value[idx] <<= *shift; - if (!val) - break; - } - } - break; default: MLX5_ASSERT(false); break; @@ -1898,42 +1860,40 @@ flow_dv_convert_action_modify_field const struct rte_flow_attr *attr, struct rte_flow_error *error) { - struct mlx5_priv *priv = dev->data->dev_private; const struct rte_flow_action_modify_field *conf = (const struct rte_flow_action_modify_field *)(action->conf); - struct rte_flow_item item; + struct rte_flow_item item = { + .spec = NULL, + .mask = NULL + }; struct field_modify_info field[MLX5_ACT_MAX_MOD_FIELDS] = { {0, 0, 0} }; struct field_modify_info dcopy[MLX5_ACT_MAX_MOD_FIELDS] = { {0, 0, 0} }; uint32_t mask[MLX5_ACT_MAX_MOD_FIELDS] = {0, 0, 0, 0, 0}; - uint32_t value[MLX5_ACT_MAX_MOD_FIELDS] = {0, 0, 0, 0, 0}; uint32_t type; uint32_t shift = 0; - uint32_t dst_width = mlx5_flow_item_field_width(priv, conf->dst.field); if (conf->src.field == RTE_FLOW_FIELD_POINTER || - conf->src.field == RTE_FLOW_FIELD_VALUE) { + conf->src.field == RTE_FLOW_FIELD_VALUE) { type = MLX5_MODIFICATION_TYPE_SET; /** For SET fill the destination field (field) first. */ mlx5_flow_field_id_to_modify_info(&conf->dst, field, mask, - value, conf->width, dst_width, - &shift, dev, attr, error); - /** Then copy immediate value from source as per mask. */ - mlx5_flow_field_id_to_modify_info(&conf->src, dcopy, mask, - value, conf->width, dst_width, - &shift, dev, attr, error); - item.spec = &value; + conf->width, &shift, dev, + attr, error); + item.spec = conf->src.field == RTE_FLOW_FIELD_POINTER ? + (void *)(uintptr_t)conf->src.pvalue : + (void *)(uintptr_t)&conf->src.value; } else { type = MLX5_MODIFICATION_TYPE_COPY; /** For COPY fill the destination field (dcopy) without mask. */ mlx5_flow_field_id_to_modify_info(&conf->dst, dcopy, NULL, - value, conf->width, dst_width, - &shift, dev, attr, error); + conf->width, &shift, dev, + attr, error); /** Then construct the source field (field) with mask. */ mlx5_flow_field_id_to_modify_info(&conf->src, field, mask, - value, conf->width, dst_width, - &shift, dev, attr, error); + conf->width, &shift, + dev, attr, error); } item.mask = &mask; return flow_dv_convert_modify_action(&item, @@ -4874,9 +4834,9 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev, const struct rte_flow_action_modify_field *action_modify_field = action->conf; uint32_t dst_width = mlx5_flow_item_field_width(priv, - action_modify_field->dst.field); + action_modify_field->dst.field, -1); uint32_t src_width = mlx5_flow_item_field_width(priv, - action_modify_field->src.field); + action_modify_field->src.field, dst_width); ret = flow_dv_validate_action_modify_hdr(action_flags, action, error); if (ret)