From patchwork Tue Oct 12 20:25:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 101267 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 C4606A0C4C; Tue, 12 Oct 2021 22:26:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 76DB241142; Tue, 12 Oct 2021 22:26:24 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2058.outbound.protection.outlook.com [40.107.94.58]) by mails.dpdk.org (Postfix) with ESMTP id 6C7D0410FA for ; Tue, 12 Oct 2021 22:26:22 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fMZtoZw48xqQI812kisWJtjD/f8Z0PIUz6weQMfcKlVwXqTVFtVLNcmYhyQKOJoMim4DlgH0RKRn1trFaSJk5mNJuyLk7yVDB5wEG+0icxht5s/DED5lr2xSBtTC30A2x+0rYsSfL2M2VvEPBNjulKD1mxLmfmqMWkwcfO+zjc4n3+0V3panlyyVxt1mCivTj5Qf4HFQ/inet8fsQ1UoctwaKCP7AWllzaJyBUQ/+4k1flZSUkOsHwNRwQHb7FlrMYdi/etjRw1mMznxlPHGWlSYrHTvX3xUHnBWhqLeFd41LphLdynol637n3X2wYN2AZvqW+N7P8skpbYyFhexyg== 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=f5K0CSZGnrOY4vKwFuZTT/5vR6xCi/aRIc3nfVKeT/G1zPxqcybgQu8hEUlqEefNoDSuLR9VkX8nwTaIteWXYc9r9E85RETbslCULDpDJFlCbBOU1Imu61G7Iqpscc9yDZcDZWdwq7l9OG30th3qUnog/xvTTKeDKfcp7mtqsHdh3EElmVabqxofFyAOE7sohAMh2Rf5AVBGS9y1UMNZBpoOgoEJ/E+m3TMXCFlidLEex8MkYeB+nPhSCNei0U9VDFYiR2z6gmzl4TV3/5OGI3IEw/C0Wow3xq2jVBPkzLhYLt2dGN4D5BXi19uQ0pPA6T4OjgvxOZ3nGRAjwtPtyg== 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=lMPC4ZTAQlRetoc1e6Dk+IJRTNVu9HLxWGlQZUcY3zEWUleIMB/2Z+Ai+c2ZyrP65LLv272MNF+J9bFnCvrCrQM8T5oGQwOjDb1uTdtUMkWf3pinHX880Mb9B4jzuSfN2LdBoAeUtH1DT3pISr/a63VTWMkuawL0MvktdtbF8M7WNCQNKwRp53K8UbusAKJI0XCwEz/Xy+ct3hjmwGFuZygtEqlMIiR6DCDcOZg46CpIK+rZgZe4Q5mc++HHkx9iLOdkyi/93y+198QMxrkSQ14cA795M8Em6x1YFdDX69NMTYUJrJ6LT//0/pgquL3NamgZnMat4BMDO0AfLTHOBQ== Received: from DM6PR13CA0067.namprd13.prod.outlook.com (2603:10b6:5:134::44) by MW2PR12MB2538.namprd12.prod.outlook.com (2603:10b6:907:5::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.22; Tue, 12 Oct 2021 20:26:19 +0000 Received: from DM6NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:5:134:cafe::6c) by DM6PR13CA0067.outlook.office365.com (2603:10b6:5:134::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Tue, 12 Oct 2021 20:26:19 +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 DM6NAM11FT013.mail.protection.outlook.com (10.13.173.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4587.18 via Frontend Transport; Tue, 12 Oct 2021 20:26:18 +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; Tue, 12 Oct 2021 20:26:13 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , Date: Tue, 12 Oct 2021 23:25:53 +0300 Message-ID: <20211012202557.30295-2-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20211012202557.30295-1-viacheslavo@nvidia.com> References: <20210910141609.8410-1-viacheslavo@nvidia.com> <20211012202557.30295-1-viacheslavo@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ee4b6680-a746-45d1-9d81-08d98dbe8c3f X-MS-TrafficTypeDiagnostic: MW2PR12MB2538: 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: 0rsyJMPIu1+i3fwKPyxzHIqpIvC2oyvHQLbMFrOAGj6GhGP9gdb7YhEhE6DlEyXaasKO5vmTlrYDBpGSfMQe1Z9uB6Y5fGzuyO9/Ar7s1eLaR+rhremIJ4D3O7gTLhByQqUHI1M8sVBdEk3VIwESttS0Sa5F6Z5EaD5VTnLfv8CZ3ODL/ZpAqKA0duRZgUzvl5B14ufVXkNQSnCOQxLCy/lXA/9f0DzSdhmsLuwf0lQYz8It3ZTRaRJSx6Su+rWL83C785oXJWmdSFpQpYu6fP6CQYU23OjTu18PPpffa5oAz+QWi3wFH5o8jiYyifI4Y8yto4i7ui7/QvMt+hZ2zfRHjpZMHHW23VP/zhck8oCSTNgTDtAZFrSR1I1k4R6ZLvYg8cfMAYiWR1FU0gMPMmZJdRQYxKYhryoQy0ESc4fAGhpKLyGSsu/ltsf/FjgYotWcAChezqtDyV0wDet08PADwWamGqoUTQz4ifmnacbd1ETrUhGsdmbdyxgJlzRt/QVwNGfzn6QpeTsCf/B0NE3An2I9M/sUJm4FzlZdF/jd9HmMwwxwa7g6FO5zk1EpB38q6lqee5om4C+7BInEXKEaMCRQK7zuErxAsvA4E6TstnN1oyeAWZKRNV/aEy5aTW/1Ku+k0qsG10osyv5wpzsFWgo5DjjgP154kBQ7FbFxAwqjgJyCbttdduoR5xLx8e6/6AA6f2ugKFLvcJcQN23mHTP9aPKUwlFaMeFaU1k= 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)(16526019)(7636003)(6286002)(8676002)(4326008)(47076005)(26005)(82310400003)(15650500001)(6916009)(54906003)(1076003)(36756003)(356005)(8936002)(426003)(316002)(83380400001)(70586007)(186003)(86362001)(55016002)(2906002)(508600001)(70206006)(2616005)(36860700001)(6666004)(336012)(7696005)(5660300002)(21314003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2021 20:26:18.4708 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ee4b6680-a746-45d1-9d81-08d98dbe8c3f 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: DM6NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR12MB2538 Subject: [dpdk-dev] [PATCH v5 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 Tue Oct 12 20:25:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 101266 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 B948BA0C4C; Tue, 12 Oct 2021 22:26:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4912641100; Tue, 12 Oct 2021 22:26:23 +0200 (CEST) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2087.outbound.protection.outlook.com [40.107.100.87]) by mails.dpdk.org (Postfix) with ESMTP id 13136410FA; Tue, 12 Oct 2021 22:26:22 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V144kW3Ud4VtwQvSxlfCEuqWdeF9TjX3e6eTVbVnWm6wmQoNwEl+1iUHqUso9tAga197cIbQF4y0qOmhlNPFQdT0WiP9TbFQ+04pcFjtJQL3KoMHJMs1foBWXoFAjg2qev3Sg6kfl8rRP7JjvCHfSDret4Z1zjbdjMUqXCV58bUrnU4WELlLlKFVXVT9MkLjieKrWzp/qTSsE5Fvlm11ZEpNbOOc4ePAUJD8xN1x3PMyCkuT7RiTr/oMkpvhj30eSrRoCgNZNeqQQIZficE9kq7e614nMTxBVDxKlHWRNY0jU3v01bt1m1IcrDj3oBhc27UpYYcGvYJ7dUSzd2GlZw== 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=ArFe/VaCp4cWurnmyHLShxqiNHqMxQPhsmIc0MmJ+AmqSjkMNgo6PQ3Mb17eCOG2Dp856W8Zsvv2jJ+11Ox/8YCqRYVR/GFOq5vsqHxbNBG+np5+QGGcJB9nyHy+7MK/H/o7WASTIKexx9Wk4pbJQVmXPb7jJZZqBIHAdfTQ0HYT60Dt4vQ/FZZGpT/WcrKe5xV0479Q6fwHSa1Dg7/i5tbsY2mYz4LG6TSjWmrFcbFlVik9Pmqt9RhzcBiLj2aN22ke4y+ZviVpJI+VejVSCSIuzn5Tee1kQPsB8qvQJprpp7GSE/U0NLmv9dLHZNrQ1qi0j8n91gLtaz0gM8O/ZA== 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=fwVN0hujTpgbPnK2wfiijstWl9WsHlfYXbZUOvJDt/fu0H5zpA44RMbNdjPXYD4gJzSCE/iUWzSreW0OPMwAb3dI/YqGgP28i8WI2/NbqFCUvyXyBnsKOz641OEqqWK6XHwoaslyD47zrmxahT5A/Brc6cJCQ43TO3bIVTula+w8dJIxI3hsRbUrX2IVRySzZfW9R5rU8ccYZef/+wlRWyGFy4arZrMrZIODOJwTNIF+ckqXCSkWZ9n9xaXtZyxN5sIDUYa2OA1i0DaOv5o6zTKrP18MMtsLtKOiS2bXUM4grDf25pBXDCp/QhWuI9hKeStMGfPeAf2RmgURyX0GJQ== Received: from DM6PR13CA0042.namprd13.prod.outlook.com (2603:10b6:5:134::19) by DM6PR12MB4028.namprd12.prod.outlook.com (2603:10b6:5:1ce::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.24; Tue, 12 Oct 2021 20:26:20 +0000 Received: from DM6NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:5:134:cafe::a5) by DM6PR13CA0042.outlook.office365.com (2603:10b6:5:134::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.12 via Frontend Transport; Tue, 12 Oct 2021 20:26:20 +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 DM6NAM11FT013.mail.protection.outlook.com (10.13.173.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4587.18 via Frontend Transport; Tue, 12 Oct 2021 20:26:20 +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; Tue, 12 Oct 2021 20:26:15 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , , Date: Tue, 12 Oct 2021 23:25:54 +0300 Message-ID: <20211012202557.30295-3-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20211012202557.30295-1-viacheslavo@nvidia.com> References: <20210910141609.8410-1-viacheslavo@nvidia.com> <20211012202557.30295-1-viacheslavo@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8c4e5cb4-ce9a-49c4-b40c-08d98dbe8d56 X-MS-TrafficTypeDiagnostic: DM6PR12MB4028: 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: gSyb/wD95JJAi5Es1b78fI2dmVdly0yaP9/TXviirg0s2Hz0pdtby9uxz5INvKNkJP2lSu5d9rL98dqTUpxsGwe4hupGrLp51udOp6ryd8/If/7eWEFqEK8zSmR2W5ONCJfQzxOD016RTeN6SyjJ0Zu+M6Z/fmtyW9E4A7doy0zK6Vaiu4YnpJnoFCYlpYzsfLfbmBrodqKCjSCcvCmpxnKC9DP8hknfg9vuVgFx+iW4YQD3awC52rni2lh8JaaK8ohgGNmQrGEUSzrtjrNTBNSnrPgQKra66+Gwn84F/F9NmDY4+lnjP4mmSszv0BQqB0i0tU6MpqThT3Ic96H8fbTG3oNkG0ip19Th6eJ8dqHwxq7KWTk5H9lEwM7SxSzdgNleApQtW4voCCfJjHm9QP87FzxYD4ZB+58IijT/8kMdfQvo47XT52fCZszppxON+B7ZSGA8bsxgDV8XUdeVmUbJ6/uXjme3OmwZzNTpCdbk4/tylqKeTmefPPhFgDcB9Mfdq5gF8Q7BOExRmg1B1tZttopkrsa8ueLrrcfTVPk2v6kIqp5iImmgdMAukT0NVUHJBV7AglUpUIly21+wKZQCalMWRzz5kDz4b9e+ODU/hvdTi2qo4/Fqkywr87xca0dhrGpMb6tGyakrq/WO4/qiQNpYdYimecla0j212DCZwSDw940JPf7jI0DopGRe0QnH711u5RoToKp8uo4G1g== 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)(1076003)(356005)(16526019)(8676002)(7696005)(55016002)(7636003)(86362001)(186003)(54906003)(70586007)(26005)(336012)(426003)(47076005)(6916009)(83380400001)(82310400003)(36756003)(8936002)(6286002)(4744005)(316002)(6666004)(36860700001)(2906002)(4326008)(70206006)(5660300002)(508600001)(2616005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2021 20:26:20.2978 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c4e5cb4-ce9a-49c4-b40c-08d98dbe8d56 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: DM6NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4028 Subject: [dpdk-dev] [PATCH v5 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 Tue Oct 12 20:25:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 101270 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 B3E71A0C4C; Tue, 12 Oct 2021 22:26:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 06C5141161; Tue, 12 Oct 2021 22:26:29 +0200 (CEST) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam08on2060.outbound.protection.outlook.com [40.107.102.60]) by mails.dpdk.org (Postfix) with ESMTP id 30C5B41157 for ; Tue, 12 Oct 2021 22:26:26 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jkImf1XedZS2Empq6rZPnHXDJH5AKRT3ki/53VcbtogqIv1Dpvf3DIRnbEiDQPY6unSDuelCfByf1XlwvqPboRa/6W9f6qCI3mdaviIdgkyA8nBHltLT5Qz8ACQJ+++vmza00jJVUL22u3PIAIW0nXY6pxrnU4YTztucoL7Xje19QxTkEdblKx7nS9zHQAU+N19XDgWh6K+8Ww6UYzMs3g2TEl45xnmvN/fsu2X+7v1Gkp2aZUdk5qQRm39sLLstStnHxbtv4ub6fN1f3bXRZJSFwlUcacTfbSI0BIEElumbcYL6KvUu7cseUEVOvZD1mMKsOlmboYSMSognz9jW4A== 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=gxnrT3Y8QHxg4Ka6xojtWxy4hwXL0S413YRtnvNjrEvf8D+tXvn7PffQ/F1kDPvZFIO86i+tqzFpcv0h6iKDySnYuikZsrZLhGqAZM/arw6K5Y05ZUgHPf2zLfRM80w6Ms73JowbO+EhImUn3oryaoHHvshVwDUJw9a0xy57rjjRlHEU0bBH5z7j74kT5FbnY6JFt4ej5MB0ikpu4/N+OQ9Jc6xLuGO0tH4E97PMUvoE9Lza9OGQAsRNHGNejj4f/uaKAKhUTyKVVMCvrjl4ew1EVH7ub41eP4Dp2gj66Bvee8d7xC+ft3lOW2yBDTUyyB04nRxliKX+44mfSUVdjA== 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=qOdYzC+PKI0v9bvFzK6L1V71echmmBXgs/PTFWi/XoCWqD4t630w872v0skWuAtpvIegHSwGe9ybT138T4d57ypin4dn+GxRLpWAO58Y9HqItt7ljo8cl69TmCJsaH6Q2OYlpHw54wdlyWcfSK4LXgzqvsJLBKYnStUSclhQKXbD7orD+9elVyulBgvJ11/pWiiLsELGVgHqBCY2jJ43I71Y0U0w4lkjeICmsJP/LKuRihk3sOFNs47+NnbETYHHETIVG3U7cuSmrT/Xx2h2HlHaIHcqR+RLMdRXHjK+PXtPvrmg6aId7Y6GXBPLOzjTRNfHlxGFPn2ac+puhrQv2g== Received: from DM6PR13CA0052.namprd13.prod.outlook.com (2603:10b6:5:134::29) by CY4PR12MB1816.namprd12.prod.outlook.com (2603:10b6:903:11c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.19; Tue, 12 Oct 2021 20:26:22 +0000 Received: from DM6NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:5:134:cafe::90) by DM6PR13CA0052.outlook.office365.com (2603:10b6:5:134::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.5 via Frontend Transport; Tue, 12 Oct 2021 20:26:22 +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 DM6NAM11FT013.mail.protection.outlook.com (10.13.173.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4587.18 via Frontend Transport; Tue, 12 Oct 2021 20:26:21 +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; Tue, 12 Oct 2021 20:26:17 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , Date: Tue, 12 Oct 2021 23:25:55 +0300 Message-ID: <20211012202557.30295-4-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20211012202557.30295-1-viacheslavo@nvidia.com> References: <20210910141609.8410-1-viacheslavo@nvidia.com> <20211012202557.30295-1-viacheslavo@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c978004e-c5d4-4441-022c-08d98dbe8e32 X-MS-TrafficTypeDiagnostic: CY4PR12MB1816: 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: MVVI4QsD8nVJhMIlyjGPxoRNdA50uK8vfCRJZrlgx6M4C9vwpXVXPlyFCEF0O83jlvvVkdjgDI3+IDKieqITx2V08PjV45UPDs7xMScfbaDaeNsA8MzAZXwfNk0CP5qCUBsOam1hHc9bLDCL3PDRKlt38zOhVdq82jYlB7ZJu5GL3Qppw8aod0t7VEGTb0rpfUNCLFTy2W2Ob+YoEJ6kwqgFiwehnp8N3d1ZOFBstIucao8OBhg6XvRxhz/hsPhmPLmIUCeey/Rm36dsA9YiziKMgHyU46HAnPaZ0XJ1iRQ5GDp+JMn58BwBDnzARZO2sivBCit1yb7JGQ3NWcg4PnxVnGSNfIMuBe0GEue3UVGhC57m/phLOIHZdt3ynSd2RbRikRwpEprjxXWmX480UveRiyCZTCGiGgnBqpDpziBabvFmBVySvG6QmmDjeP0jISRRICW2aX1I2OWJ6j7oXjcj8JoNdNeXNgJswq8Zm29IdzLiDPxdPr6LCTUcHQPO3a/aNyf+jHRORHNF2v6s6xc0R8OHaU+z+sCjCyEhGwNjw+svoHm3rO5NWS3Rne7S8WylW8cEwv46Y28wTmPKyvW9TQOgMuq6K+zJ62eMYu7UNuoidsmhSyZX3WWkrlWx/Q6a0lipxCLt+jGepz6KtWHK1zkeZEz7Jk70pEsE9oDTyTX9VQ5vcTpMu33jahmQhef5V6WO8bwek6VdRW64Rw== 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)(6286002)(26005)(8936002)(5660300002)(426003)(2616005)(4326008)(316002)(6916009)(8676002)(83380400001)(54906003)(15650500001)(16526019)(2906002)(508600001)(336012)(7696005)(6666004)(186003)(70586007)(86362001)(55016002)(7636003)(356005)(36860700001)(1076003)(82310400003)(47076005)(36756003)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2021 20:26:21.7301 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c978004e-c5d4-4441-022c-08d98dbe8e32 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: DM6NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1816 Subject: [dpdk-dev] [PATCH v5 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 Tue Oct 12 20:25:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 101268 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 B71D2A0C4C; Tue, 12 Oct 2021 22:26:39 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C8F974114D; Tue, 12 Oct 2021 22:26:26 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2050.outbound.protection.outlook.com [40.107.94.50]) by mails.dpdk.org (Postfix) with ESMTP id 0CDCD4114D; Tue, 12 Oct 2021 22:26:25 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SBvil9yuZJZl5v/GOajlwGX2MwWQdaeqbhLmN0u/asaPBGLSDBwCGNJNUaTjLwGmgkZEh4tvuhXFuJFVU/rWzN31pGM0uVyErO05CgYAKkSyU0vtxO5IkgikX/tjFlihYrYS81nCP8EVCqWq41avGfIs0N9d1E9y6mKScLYauUYQGNEulVADEG17jGyFBN5E2Zco2c8JWh/qPFncRsR9Zb6IA9tjsf80AZqv+FCgmgSnjDyqrv5rYebRIcF5cwWgktRKwsBO1bu52YnIHy+/7Yv6NhhvhFibm1FW1ZVbgveVicPjUCHlgoimloTO7xbJgxseO3AtMtmA5EVYImk5sQ== 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=jG9Fiw4UYZksM3I+W8MhUrkHef7kU15HWx37IES1KLADYup/nCvg14bUzuS7T5FgmcMFm4OpJGXcX9MxDGWi46pcNGo7S3SU5sDG9kyXWzTnse1NZzAUBKQKkyznNo8vZA8vhzrCDaU41UrdMho/OPE+dr5s16cgOP0/qCYHM5pXmHC0yw5q7N/zmEkFm70WXqZ9ojvPfDTCebmwOxaJme3tBDLmyKyvNVMWRhvzZf9IPIAwVNO3/EcR4mSmOrSfM9BnnrW8OVULZfI3EEXHnjTT4hCSJf0ujrMl4GMGQhOB5vLPMqx3tRGXn7H9x7rjo3LfYcssGF7+4m0RzY6M0Q== 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=JkFQAbKTXUgu1uap6MVf6L6PciSPtMf9e0WjsUGNzh/4qfvn7XjO6PA6f7hUdUR/31N3aiHp2V7Jcvk2QSMdx5o+gVDV9iF+pfQaC+E/AHjZNBk81DPlqhDlJBN0U/oiRLwkBORWAVz1ae8w+ogoZdl6PVJh6/IwqF9DHvTeDGVDuCEA1A3qbsLrqh4MQFkFw8iF1+8t/tT0jokfojB7U+N0QTdgvlrQpzb7adDmfhluzXWFoZmhcDiEYqLjZBKchgLwqOVhg2X/XtX01KPLN+kcR2tKQ0V8vPrwXgA/2VNwseWEp+dVb8Mfrj4jOk/iQR2THm/Dwn8QMicPBBgGbA== Received: from DM6PR13CA0043.namprd13.prod.outlook.com (2603:10b6:5:134::20) by CY4PR1201MB0040.namprd12.prod.outlook.com (2603:10b6:910:1b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Tue, 12 Oct 2021 20:26:23 +0000 Received: from DM6NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:5:134:cafe::38) by DM6PR13CA0043.outlook.office365.com (2603:10b6:5:134::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.14 via Frontend Transport; Tue, 12 Oct 2021 20:26:23 +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 DM6NAM11FT013.mail.protection.outlook.com (10.13.173.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4587.18 via Frontend Transport; Tue, 12 Oct 2021 20:26:22 +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; Tue, 12 Oct 2021 20:26:19 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , , Date: Tue, 12 Oct 2021 23:25:56 +0300 Message-ID: <20211012202557.30295-5-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20211012202557.30295-1-viacheslavo@nvidia.com> References: <20210910141609.8410-1-viacheslavo@nvidia.com> <20211012202557.30295-1-viacheslavo@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 68070fdd-c8b2-4589-3a56-08d98dbe8ec8 X-MS-TrafficTypeDiagnostic: CY4PR1201MB0040: 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: u0nIt9Ua8BYTijzyfb2qsc+IkaleivKf4GKowQdys43niNDgL4XT51DQtKEQ07HWp1q1U6LEVjNssP/hwlZIUBjN/a9otwCY3JJzL6gfstr4DV+A6Ye9f20jzgF8Besb8Prm02ZTJ78TaajjaxSeaXTVOJL86zKIvpIxG7hWq8d+BXUConDbq053MKdnNwt7L3PHtd+8dGGkLMmGVspfqsdLgjGVIAzNgpcG+ivwuQ87KnMD6b6zVqAo7qd/oPV440mkeX87RZhkoh+UqQKGgd4eXDxqrEDqcQPBa6vX7JA4H5YFI7v0bLxg3Ts4gRITaQu+/h9qH6FNS7PuILa5on2HaeAZG4BkQeXIYH+7UUCfdvs1YbTfk0cQqKJO53uNMJxmLwWpPhL4jO/HdrHlsvZqxchnk68KIkYEc6H3XhR4koBG7gevpYv+WtIGkVFz/pImPfwAYHGr3ykufhJforGyzCFEUl0QfGjwldjrH7CMkHcmDCwE0hMpFQzqdQy/9gcd+UiTDSkRpBYEF7bKHtzD/v9mliT4UP7hUgpel0GfPoF+Z67nf56xNoxjSAt7gtmrbvlLsBA+Z99pK35GW+VpMVqKswqP8vnvCWOHhpopUvWl0Trd6Ht5SALoO2ca2WBUsnSB8HFUszW4UCsenADK2irXWTZTqA64a415z1SARvDEXkjzBaoJT3YCMuU+E0hotuWl0AUTa/xQPIN17g== 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)(6916009)(36756003)(7636003)(356005)(186003)(4326008)(316002)(55016002)(54906003)(5660300002)(508600001)(16526019)(1076003)(26005)(8936002)(8676002)(6666004)(6286002)(70586007)(70206006)(426003)(7696005)(336012)(86362001)(2906002)(36860700001)(83380400001)(2616005)(82310400003)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2021 20:26:22.7305 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 68070fdd-c8b2-4589-3a56-08d98dbe8ec8 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: DM6NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB0040 Subject: [dpdk-dev] [PATCH v5 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 Tue Oct 12 20:25:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 101269 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 BAFF8A0C4C; Tue, 12 Oct 2021 22:26:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 045F74115B; Tue, 12 Oct 2021 22:26:28 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2069.outbound.protection.outlook.com [40.107.243.69]) by mails.dpdk.org (Postfix) with ESMTP id 162BD41156 for ; Tue, 12 Oct 2021 22:26:26 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=etxmng3SW4rKPj2dCt3pN0klM7it7WwXUEMxLsiKHnuFLbF+nX8s7js2b3xvDwR/QOOQ3ZIqe/I/9AJY3AgqtUWPlZd+CspFag3Lv7bf6aLCSFsHd8o8cwx08AI51DIIdSYKOMo+VG+IKWJ65lP2BYX1JWL5ysFRJzMg9Pp02pIHlHjPukgzfo4djAXF9gOHDmKVj27iwgkhH2LcGrH1rT81hZqKHSUhTIHdKqXuIoB3RWE05+8kKJG6GQpRxkaejuwaXwqUO74jmnss0Vi3J5wbDxAl6da6wTTuicRuPLgsvHSwf/o1kYbgiQ8VHa+GH3umwQ6YxUr/AtqDHyUAYw== 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=HAIn9/rlADbTi/aXYCbDjXaBZcQYL07LzNy0kRR/1qI=; b=Rw6xdJjIH0IPuSMRji8NQEw1neIrCIRqkQqZE6vovWJqdTa6HfF3HLPmI6zWIRjcBL1wqVl4Kx9xk4LGZM+Icb7empZsJQ8oVhaJIraNlLydKuA/C3Y4+EZGX45V9brTafy6lUg30Wyu5kNw221BlsJCPFTsCGxdo56a+oE7Qx0qQZx8boszsaDCAS0L2Ua/AujvZ7cZ8Qw5oUX1iKayRoU6oLI+130p3QktN5gTfPW+zKMJcds7Be4YHCiINV5dag3Vi/0Phr9dVmSHwdWOGKKBTlZtfzuzIxfym8d4meUzYF8p6t/2Uz1YFuRUhiB6mWAIt0v/tERxKRsMBicCIg== 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=HAIn9/rlADbTi/aXYCbDjXaBZcQYL07LzNy0kRR/1qI=; b=NZX9aSldGeGOzoGTYO/n9pEEo/en+z6gBwKvU+SBDJxZAbsGUXHfmMUmf/hEavLHyrKjUkYYkq/gubMBeCm+zYyxQrE5gbejw5V2+xeCgik5ViiK2f4kKfBCldREKJVfnOs1kU+65B4e2+AU+I2vJmM+tIGZP0qBv1AeIEy85C/wBJmhcaWB2CSZ5CSvr8iknZZmOE2ztrYs1Myo62fdyrN5rA7NQdMajvXiZjHuIKHQeSTM4m2NBe30go6zCjdG92YghvBVpasDQ3Ghpm2TBr6rejZzFkAKAtF/MgugL8rxEzCCO2nOSXzXgWTxgj5kaZrPtt9DWwEvx9SEq2rl+Q== Received: from DM6PR13CA0048.namprd13.prod.outlook.com (2603:10b6:5:134::25) by MN2PR12MB4565.namprd12.prod.outlook.com (2603:10b6:208:26b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.20; Tue, 12 Oct 2021 20:26:24 +0000 Received: from DM6NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:5:134:cafe::c0) by DM6PR13CA0048.outlook.office365.com (2603:10b6:5:134::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Tue, 12 Oct 2021 20:26:24 +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 DM6NAM11FT013.mail.protection.outlook.com (10.13.173.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4587.18 via Frontend Transport; Tue, 12 Oct 2021 20:26:24 +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; Tue, 12 Oct 2021 20:26:22 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , Date: Tue, 12 Oct 2021 23:25:57 +0300 Message-ID: <20211012202557.30295-6-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20211012202557.30295-1-viacheslavo@nvidia.com> References: <20210910141609.8410-1-viacheslavo@nvidia.com> <20211012202557.30295-1-viacheslavo@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a5c63a24-5d6b-4e0f-17c7-08d98dbe8fa1 X-MS-TrafficTypeDiagnostic: MN2PR12MB4565: 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: HCV2Si57h7SNu0g2icxmCwDkYKQDgaalShvUNDge95EGBEMAjKp81hxisOgYJSQVTRWCTwMy8OUApOOl3NCBBj6ei9iNyKumF287MldQYdlvj3oaG4r+TFMKidx5y5RUTCw2alfykgLEm742flyU9kwY6S6D+LxR2ZXuaGtpu+TJLwlSSEyROsGZWJEQQwQ3DOQ2NbIDkoYlHLEszq7i+HrDS17AQhFH+XfS2RdIgFGP6DbqR69fe91B1l+E5P6DSGRYuB1koxrz+JJWKHBSU0xeLXnaRBaBe+0wBGr01DzUFRiDhO17oanobB6LOkfVy3Np6etRkc9+J8k7a2kG1ptQtu9m6k2+To6KE1hjGKeMQWOLYptQFGxZx4w+OaLpJMqPF6UiavO+R/pzo84sF44E+PSAq+ttmf7rmfjDKgSoAm4QHJqVZxyMwns0oP+a+hU8CtutyEFIbTTawqp76kx25Ji3ouz4SfnYz6z5a9KRt6GGFo5mr9Y8kFk/b3dD0ONmtlIsI8od7XI3PWOcrMjq5rl/mTl9XwqzdUR0/xNS0Hfv5U1rIvLZdKwuZRSUZGtBRscaleFYy0AVIxnCy+5leiCQIg0Me0Ox7ad+1nqoHHRrXJzOHqxX3CVNWIFC5AL91zLoUPr520L3hO5JAD9JIe/shhA6keJ+yDboFwTnKyoRfVUebuyta7vFCKQD7wZ3GEibHB03h/mHZqzw4Q== 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)(70586007)(7636003)(7696005)(26005)(426003)(8676002)(2906002)(6666004)(6916009)(508600001)(336012)(54906003)(82310400003)(4326008)(55016002)(70206006)(1076003)(316002)(2616005)(5660300002)(15650500001)(83380400001)(356005)(47076005)(36860700001)(16526019)(186003)(36756003)(30864003)(86362001)(6286002)(8936002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2021 20:26:24.1538 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5c63a24-5d6b-4e0f-17c7-08d98dbe8fa1 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: DM6NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4565 Subject: [dpdk-dev] [PATCH v5 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 | 123 +++++++++++--------------------- 1 file changed, 40 insertions(+), 83 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index c6370cd1d6..673dfd53db 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,7 +1860,6 @@ 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; @@ -1907,33 +1868,29 @@ flow_dv_convert_action_modify_field 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 +4831,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)