From patchwork Fri Oct 1 19:52:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 100359 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 72DA3A0032; Fri, 1 Oct 2021 21:52:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4D8BC41206; Fri, 1 Oct 2021 21:52:53 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2053.outbound.protection.outlook.com [40.107.243.53]) by mails.dpdk.org (Postfix) with ESMTP id E818D411C1 for ; Fri, 1 Oct 2021 21:52:51 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L0urBMGfou9Gh2TbpW/w6C4Nw2ZDsh8hApqhvBcpSUYtST0yfVeZC1dOPZsD4p504uU/vtwjXhwpevNz4c4vEtlncxY6PFzs9gMQiUg2Ba7jxqgCA5FVWytl1IAhn0EDHQyStoDXHI/PbNdjAvKJkzuljaqPvYl/DXuHoX6tJlTIVF2Ia+aUj2yfENk7sO6s96uHuJXHf65g8e6s0hNgIS66V7k6d1CEV1kG8M/nBHZfPeSFv5eSsChqoa+8wikPsEU0oRwTkNsqJ/GGWR83DU4LQf6b/ygPD7NjZWJFggVlJrDa+HT8z/andIgz4ofv6oay+vcof2VRH7OjYqx0Tw== 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=r1VAVO0Qo3E8TuGdakkmVxva1n2sKVKepKfRmCn0lEw=; b=KeToesSXznzmopL5mgZPdl8lgt0MF1XtLmu9NBTbnBjDFcAHz7HpImfFQXrHoAV8D1np6WS+C1sZL59+LgYv8HtnkZhYTzIQhHtYUWTxRlMKWj1J8Bkfkgv8hjNv+CD14kI5P/EXRHJ/y5MMMq7eThxVKzS4t3nJK0crxNaLVaIFJ25iQH+28YT1UOTY8FZ9TuvLIwmwaMqspqc+Qs8ziYCI5Wfe7GP8JEJJ9OaNFjAIqRgJd5Ui6ZEJONB0y8cU6J64nZVou57Dkqe6ALkYXoMtWnAoth+8+5tmPe7dgEdOizPZ+9ecAu1uMYKdk8ofS1PrFfuacihGQXVnSRo6Aw== 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=none 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=r1VAVO0Qo3E8TuGdakkmVxva1n2sKVKepKfRmCn0lEw=; b=KsBWcAj5aelPRjeldXN19WL/yfTrsbFhHmt3VMGHS61eHXExc2IyfBVWE0I9u19W8LB9xiX1+Hkq2CzgAuEa1BnSLenKsXFu4x+b6j5ombWInfVz431MpXUezcIxr/WqsJUDgaoITgzm/1At+9tplE7yu6bKkgtrBbwL7GA6pJUZraAZGiyUlrJd606NlAwcN4PZqfNI8ggWOQTZ7BvexDuWBB0sBi7dqmNHwWj5nzNmg5A4LtugG7i5eqREWufkn74VHfgeqsP4v7dTx928p90SVUX783BirpCjHLr2GfPyIEXLGTQoPOxsoFRnj2U1lVZ7nRJzqzgedl3gp7mbbQ== Received: from CO1PR15CA0047.namprd15.prod.outlook.com (2603:10b6:101:1f::15) by BL1PR12MB5078.namprd12.prod.outlook.com (2603:10b6:208:313::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17; Fri, 1 Oct 2021 19:52:49 +0000 Received: from CO1NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:101:1f:cafe::6b) by CO1PR15CA0047.outlook.office365.com (2603:10b6:101:1f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Fri, 1 Oct 2021 19:52:49 +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 CO1NAM11FT050.mail.protection.outlook.com (10.13.174.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4566.14 via Frontend Transport; Fri, 1 Oct 2021 19:52:48 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 1 Oct 2021 19:52:46 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , Date: Fri, 1 Oct 2021 22:52:21 +0300 Message-ID: <20211001195223.31909-2-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20211001195223.31909-1-viacheslavo@nvidia.com> References: <20210910141609.8410-1-viacheslavo@nvidia.com> <20211001195223.31909-1-viacheslavo@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] 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: 3c71ba64-c801-4096-162a-08d985150bc6 X-MS-TrafficTypeDiagnostic: BL1PR12MB5078: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9z30IZTh/F2bVzqmWv11O8YBFP72Ww1ZoGD57gqmcf9Xa61VtGRLYyy96kxTEjjf8F3labCYzxC4V9S1M3fr/P7ce662N9qxeOXHBZ9zce4aBeLo8nFD7tgI18LiXutATeJV3K0t6Nr1gRPdvww93vQcusaOdtjxo5qK/1vbtYy5D1r+QCd/T/y9tw9yFgYh8X2cphqy9nclSqpMUxipP74wZOTPuhaozMFAjJYf402dYKgeFBE18GwI3PrEVvF8vEBQLkWKWbm8Jo2rFnumRP0bdedLCFYWiV+W/HcRqKTYkIMhVF2kEgK/FCSTiAf1nqkNK1K+Vd8GxCjvuV8Is1SfpCP8xCQwhSbOMkCvuEEonSd8o4KzVRPldTmThpvSS5Ap+ckRYGfxlsdm0jFsWct2clLJqk7VhV2MQ0dxlNVNSV9rD3oriAKC91oqLKmf04Eaa8g5oVK2F63dGcCZL5+V+hZgNc1pIHUK1FleXtaQvBV8EEEmYhjheqb1sgKS5J5kxUSwv41irKz+y+70MnctwRqgKpQvIxZphmiJ8N48BTKE6fNd3z5WgNHaYTdWm8AQKHkA+rU8LssAylBdw/VDZnLMDT/D/SZJNGOZO8gqExFdfgUXLM2HquG++Pivh7eHqns7JA4wFYhAv89Lgce18J9cUZCz/pJwgd3wdRXe5TF/b+UfrLGIH92pfC61cFeUUrLOqCQDiGppsd82kboOlo4229UcUM/b8/pvaWc= 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)(83380400001)(36756003)(8676002)(70586007)(508600001)(36860700001)(7636003)(8936002)(47076005)(336012)(6286002)(1076003)(316002)(2906002)(356005)(7696005)(426003)(2616005)(5660300002)(70206006)(26005)(186003)(6666004)(86362001)(54906003)(6916009)(4326008)(15650500001)(55016002)(16526019)(82310400003)(21314003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Oct 2021 19:52:48.7304 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3c71ba64-c801-4096-162a-08d985150bc6 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: CO1NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5078 Subject: [dpdk-dev] [PATCH 1/3] 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 lesser 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 MAC and 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 [1] commit 73b68f4c54a0 ("ethdev: introduce generic modify flow action") Signed-off-by: Viacheslav Ovsiienko --- doc/guides/prog_guide/rte_flow.rst | 8 ++++++++ doc/guides/rel_notes/release_21_11.rst | 7 +++++++ lib/ethdev/rte_flow.h | 15 ++++++++++++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 2b42d5ec8c..a54760a7b4 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -2835,6 +2835,14 @@ 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. The bitfield exatracted from the +memory being applied as second operation parameter is defined by width and +the destination field offset. If the field size is large than 16 bytes the +pattern can be provided as pointer only. .. _table_rte_flow_action_modify_field: diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index 73e377a007..7db6cccab0 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -170,6 +170,10 @@ 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 udpdated, immediate data + array is extended, data pointer field is explicitly added to union, the + action behavior is defined in more strict fashion and documentation uddated. + ABI Changes ----------- @@ -206,6 +210,9 @@ ABI Changes and hard expiry limits. Limits can be either in number of packets or bytes. +* ethdev: ``rte_flow_action_modify_data`` structure udpdated. + + Known Issues ------------ diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 7b1ed7f110..af4c693ead 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 { @@ -3217,10 +3220,16 @@ 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. */ - 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; }; }; From patchwork Fri Oct 1 19:52:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 100360 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 37346A0032; Fri, 1 Oct 2021 21:53:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 75BF641217; Fri, 1 Oct 2021 21:52:54 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2070.outbound.protection.outlook.com [40.107.237.70]) by mails.dpdk.org (Postfix) with ESMTP id 1CB6E411C9 for ; Fri, 1 Oct 2021 21:52:52 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mp5lZvHiyqx0L8vQwU4fDReZLNZl/0ezaVa9Dr2q5TlC+8MoxK9Chh7YoEA7sRJ1V/pPLkgEYFxxq7P4joxJHHHL3hoEsve/1zTUeMhMRsJgl4ol9oRWK1arbZjzKm2kcSqVKQtyKyYUQVw3xLKYRnKBmsWMWP23ZrMY0YXBx3CqTyc5ynD1m0h42Jaym7VrPwRIquUlraTCxeZ6RyC2QerNXynDoCFqJaxtSWRXJhyiFGA0ReFHkGB37TsJX+Zkc3vajCW7mq7QK7S+CWJf+9UauJ9RLNRVkRoReuAqPmZnIMneIAE7EyObxAWjbXqTmH/L+/M6SN0Eba0fj1DV7A== 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=KWGQlI+qNB4vNJXYnfNDrA8iA/1g5rWu0V/RJRVOFW0=; b=RX+oQ+oAmQSjddjCRs4hsUV5n60QSaNZYVvwpPgMyBLNXhnNpNJy2GHOQUuTC14+my9Z1FFFBa3drOJ+eGDrpDMsBlpfauGuVUp2eCIwemnLVpg9iub5ocoQAPbRvXUYEc/rC2iYk76M65ukMp4HmDFWOJ0JVhB/2GT2cFvg5h8otHPjX3jEy/SvvpuXcgTdfrDbqw3fVqKNPYEBDUUa0bFdrlOacHrEKRhJMzkOGOjECyw/uLAWmjP5EIccjacl3OBvvnnhfHvN3zO64x44zh3pal+gF5+yXpkqtvOHgllmsw8ysb8pYcteX005VfwfJbWxAayQOOAZbza7YdBFYg== 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=none 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=KWGQlI+qNB4vNJXYnfNDrA8iA/1g5rWu0V/RJRVOFW0=; b=XZtuXVpMbXCn847ssckJUP+jhduZiZOHdEMBqlc4VL1/nCYpD3ckUDtFMAH3tvJHTWUdt3V4r/95h4IyEy+Nm0Fj293ZSmZ3KD+Ya76b1quhUZgb5Q0gUgNPBJZamv49jhnIOzdSSPrywf18AHpvng1DwTOR24CuTns2fRo3GUiUMOs4zkL1kokbDoZn5GYO9IrobHiz4LOKeTPaWhZnFbx0JTC3DHPckFs+KxCa/TtMQsFHvL2AoV7Uag3dg9qE/YLOWfcMk/aeu0EMF1dxPwVWN73Wtg+McVl9O+H/owsVgmYZZdTyxf5w/rgbWxMwz3WHjACoZyjompc4D9UK2Q== Received: from CO1PR15CA0066.namprd15.prod.outlook.com (2603:10b6:101:1f::34) by DM4PR12MB5263.namprd12.prod.outlook.com (2603:10b6:5:39b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15; Fri, 1 Oct 2021 19:52:50 +0000 Received: from CO1NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:101:1f:cafe::f3) by CO1PR15CA0066.outlook.office365.com (2603:10b6:101:1f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.13 via Frontend Transport; Fri, 1 Oct 2021 19:52:50 +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 CO1NAM11FT050.mail.protection.outlook.com (10.13.174.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4566.14 via Frontend Transport; Fri, 1 Oct 2021 19:52:50 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 1 Oct 2021 19:52:48 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , Date: Fri, 1 Oct 2021 22:52:22 +0300 Message-ID: <20211001195223.31909-3-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20211001195223.31909-1-viacheslavo@nvidia.com> References: <20210910141609.8410-1-viacheslavo@nvidia.com> <20211001195223.31909-1-viacheslavo@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] 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: 1cf8e11e-00c1-4687-9971-08d985150cb4 X-MS-TrafficTypeDiagnostic: DM4PR12MB5263: 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: bjX28CheqVIsO/VeR1VoL/G+B+8nn//+Fxy81hMueXuDL+XfOEhTQ7knplCe0XdomnM1mmw3banYZ87krr7wvRg8+sEprn/U2cks4Vn8tdf8LYnSIdaQFBTxeYT+GOe6JHxP0K49XJjoo+LeGZfP7tih8z6Acyd5yVvXdZ1kExNyrw0OgHQj5a2l7xA440ceTJSlN6P+O56POxGFGyr7+zYTc723gCPYRFQoXzQh2w+y2XuiB/BURxa9Erm/Soy+w0uGdpwCKfRLtYNDG3O9xnz6KDuJP1834DLOtUcJUovSundKjq+KkiiOrcWhzsfwmP7Ze57ndCy7xVrhw6L8GMWwprJceZgRTNC4irHgdtA0XK7ZIAAfGnSc1UWcsH71GC4UcrQETYDqTg7uBanF1p+G8S7aO/BYot7pnlnLcbgFmzZDOpv339ISWvJRmin/pxSlKtXBouFQYYZl71hk6zfsI8r57hHfHzfU/lftWe6gVcmBt6DFunPpCldTDt+HfEolEbrb55BejNVt5zmVVjgYQStq2HJuMak9opv1F0XOv0gOOlSdpWXYAILy7/FjehL2PWcpgeY7qIk8DRWj2IPWFpW6nx3QxXSvh0uXhWzdLfAS/F8BKQnWIjLqhPi1mH3AU5oCYLKhXc6NLpkiMDUnRkxXlZJlxDQb0WDQ8jN78IIgAwiyRrm6/uSLR2GvZQ9COdFV6qBl7xs5+ptc6Q== 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)(5660300002)(82310400003)(47076005)(6916009)(36860700001)(2616005)(336012)(356005)(186003)(70586007)(16526019)(70206006)(55016002)(508600001)(83380400001)(6666004)(4326008)(7636003)(36756003)(426003)(86362001)(8676002)(316002)(15650500001)(26005)(2906002)(7696005)(8936002)(54906003)(1076003)(6286002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Oct 2021 19:52:50.2766 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1cf8e11e-00c1-4687-9971-08d985150cb4 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: CO1NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5263 Subject: [dpdk-dev] [PATCH 2/3] 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 --- 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 Fri Oct 1 19:52:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 100361 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 5359CA0032; Fri, 1 Oct 2021 21:53:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B3FC14122F; Fri, 1 Oct 2021 21:52:55 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2040.outbound.protection.outlook.com [40.107.237.40]) by mails.dpdk.org (Postfix) with ESMTP id D37CE411D9; Fri, 1 Oct 2021 21:52:54 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qg71F2ySGc1iR5vzdTeVMiTAc1uSTDoBFPLXxhSrTK89csfE5hUOR48aimuZp7yr14aIRGhUFTjW9CSugloYjNW8XXwLIyZ/tYB3xxSTIJdzU1zj4xXIP4JjG+y3klBpNumdOHNWHKG3d7HMbnbvPL+ZGdbCVwAulSJk1JIrISNircYoPTnE/hlIGcaQ5bWJINtlXfegZvotAEiSbLfYRdvo//fKpenr8hL++ktQMaIWzLtwJB0xL3/WKdxZPPqdhe7aUjNi6z2RAgpJ/uu4QwuEekaHWYPLkOOd2OTWUKgAwZygvbgmkf0PH5ylWmxCNP2wHhIAoUn4uHOoFoXD6A== 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=M4wHDtZDjG6Ie4BGB5/xbzPQBkcMMEKySVzzMHYQBMk=; b=VO4nsQQZBSl4EdBv9p7uOe6M+7oahAHJ1G7zcFFy+BFWR2h4u9EAjOolXRRZrpabVL0gPLMXHsUDP+soDs8R8r2m6vQ6lmxeOqOs4gXNI3cxdMJzdJqwHU4rzEJOeQKbi1e48TQUUJjlLUvWVKdVYZ37NBvW6UobrhArEvziL5uAfGSEGHG84vCaZy4nJDAAuyGBR39PwGL11ohnokBPcdyZuak2x4N1ZYZVHzBwKOnHJhQz20Ch7QrS+xW8F/dtZQPGqszNo9HsJ6Wycb5Oax0/4CnlgLUsjqa6ZAi4bE9tzl7Krc8oGWhaVvLVClxU6z0Igeim857uFcYSNnGogw== 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=none 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=M4wHDtZDjG6Ie4BGB5/xbzPQBkcMMEKySVzzMHYQBMk=; b=hzAUU/2ivxRQJSHhpOTf0+QOeSxNxS/B4tF7rkbAfRZB/FPg89xgSBxFTnXS99lk20VYFL+ws9tcfMSrWAQNWRk7RlFaazn2vf3+7VQGA2UF1LlbQC1ljltUAVxLhe8PLUJkzsoaYIySxmvtT93+VPjd6ZBLqavhgxENxy94mmqYqmJp/T+YeA3EMMyCqt6jCXaQEBtPVqGx0zztURxttqli3ATvKnaC12/pALDDuMbrYL6InuG2Zy29who0HPnxxUd5uh4zDBIYCtwX3m3POceP+wS/4d5RDTFKQ2X57ViycGO+iBKP065nx6jIQi/6fhyvzcvcJmx37zY/0kLmBA== Received: from CO2PR04CA0149.namprd04.prod.outlook.com (2603:10b6:104::27) by MN2PR12MB4255.namprd12.prod.outlook.com (2603:10b6:208:198::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.13; Fri, 1 Oct 2021 19:52:53 +0000 Received: from CO1NAM11FT060.eop-nam11.prod.protection.outlook.com (2603:10b6:104:0:cafe::b7) by CO2PR04CA0149.outlook.office365.com (2603:10b6:104::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17 via Frontend Transport; Fri, 1 Oct 2021 19:52:53 +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 CO1NAM11FT060.mail.protection.outlook.com (10.13.175.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4566.14 via Frontend Transport; Fri, 1 Oct 2021 19:52:52 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 1 Oct 2021 19:52:50 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , , Date: Fri, 1 Oct 2021 22:52:23 +0300 Message-ID: <20211001195223.31909-4-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20211001195223.31909-1-viacheslavo@nvidia.com> References: <20210910141609.8410-1-viacheslavo@nvidia.com> <20211001195223.31909-1-viacheslavo@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] 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: 5c6ea3cd-b664-4485-312d-08d985150e33 X-MS-TrafficTypeDiagnostic: MN2PR12MB4255: 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: 9zAm4Wd5RF/1XMf9GSVXoqGIb738LcnlZNibjPQqfiBs4De5UdswZ3+rXAuCKP1n1oePU74k++RH4dgj3PxJp8bryiNOW3Me9RaZ466/amJrzY9H30ftmbyDwtQOXOZzhDLJeIHEaxUIPcDScZyb0pBEbPBTctz1NLxIYFm8tP0ZnjZnNTXcWkXHsD+tUSal0K4gpO4c2OPEYkoX6oFK+PxhUAqT6/VMhO8zEy7f50j1PK3Q5OuWHGN8yoJt6Qn/S2EDH2BIxaYCsWQudiuxeaCmPaNlEiJE8qdri9mXvXlEkLYGhPnFgePeSEUM1t9zDG4xpL+HvF+fVz6W0E+zWp1xNQNXasY24+VmG/6e/jS1bi6OQTfEiICPKeUoZXjKeoQHZrqaFBCF/JEXa7SnJ12ZHqg6DLQols0TcDP+Hxk3VyLvewYJaFXBIcresi1hHxbGSycEy+r15Sx9q+/Xajz/qkk6eGRyKaa3BWUXLNZ+mEjadM6Q5oyehyrlHnLAGevreQ0hr4dk4xALhsDM/FedUg5qZu5v1cqzddbPG7G8v+YLdx4Gf4l4vTx6lHtqmPpQx+YqgLtB+joTjsgw3N2Z5wXMS0rk0Juycu7HyKjmffz7XNpMhphg5wR6VDLOe9xMXdm3xDnss+/bBQ8JIC2twcuBJG4gxSIOSNyFEnS8S8QRrpS/GLqoEEFJ6q16Ta5kxhHcQObhVU8sMOBE4g== 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)(508600001)(55016002)(2906002)(6916009)(186003)(1076003)(54906003)(8936002)(7696005)(16526019)(2616005)(426003)(336012)(4326008)(36906005)(316002)(26005)(8676002)(5660300002)(47076005)(86362001)(36756003)(70586007)(70206006)(83380400001)(36860700001)(82310400003)(7636003)(6666004)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Oct 2021 19:52:52.7469 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c6ea3cd-b664-4485-312d-08d985150e33 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: CO1NAM11FT060.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4255 Subject: [dpdk-dev] [PATCH 3/3] 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 --- 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)