From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 79A6941B81; Mon, 30 Jan 2023 14:20:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DCDDB40EE2; Mon, 30 Jan 2023 14:20:35 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2080.outbound.protection.outlook.com [40.107.93.80]) by mails.dpdk.org (Postfix) with ESMTP id 55DF940C35 for ; Mon, 30 Jan 2023 14:20:32 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yg2JW2iswfF3lRPOnczhE67LpSCSQGPxJ4gVksnn6CvYZYMi31uQ1BHYM0DEM/hC4OQwYJCPMKOMl5QmuqW5lMcLbem8p5/OSLJvCpoIww/4Rb5/pGgrhFz4PZk7DgR1wXR8+iWP9Zj4a14cm5IAAuNF7HP/OinLR3ZRSXJVQukMkFveobT8gTKrErb6i3+zdbSIFv6OGmDlOgCl1X4nWasalCX/pktGwxsWst4Jvo2tbD9JkuwXepzPykF41abaFRcwgIIu7u/eMemv5DOk8mI4gyuXRnskeaM8zse8bnL0VeWpTeWABrbcNpx0lxm2e5YNj0sjLW/kwJJJK5CVYA== 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=zjcBBN9JnjnVL++Y6uGtR2606yzc6aIQEtoD/PCHMY0=; b=MSDecDM4UGZJjijgNz7mdShkhMLXamlCvEYX94h5Dk3+PGNPiTOYsoRsWCHGjk8Qe20lMns6SupO4bxEtYl8jvOdL+ZGARtObO3Mhl5sJg6BVmyyH2UmPsxcKeQUbrBxPa1E228JrWv1PFSUG+axiUf39rGMr6+UUd9tfJhZiEjHM79jyGzlCU877Fu2NiayA6sGMZ1QbM5L3+9ZiZiz8g4n6VIBR+Td0c056sUxjgo+5s3I5xrji1UNKVapjOQx/JZmWQOUfALmTAXCVEtbhWU5ifZesxn4O8ahkXIj/5Scmzx+0Bt6cl163kVk4xD/8fgsQe7/BbXQYCQ3KbgHdw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject 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=zjcBBN9JnjnVL++Y6uGtR2606yzc6aIQEtoD/PCHMY0=; b=aGMT4yWU8U/7YSWd48KGS0luN7sVgC0lNrAn+lHOjLyci0qlg00MQAlQFYWncIDYV3GGs5D8+ifBzlcqv3ghbAiZPzMXHlnQuLLhBpCzyqthlMAjBxGU7e9o5FutnNE2cLngXwxDhC2irUP9z01VCHcNklw6PGPa6H4Wler/geUDj0ZI258Sw0svNTA+sOEag7MN1ZjUvXOMG8dC0HnTSc/z6qi69NYzYmTcybDD7tfuy36X42TMiP/5ITju/wxYBm4qC/DaaQ+huXHWv/dWRByGO5ApXgjtSe72mrbU/SX7p75jDeNW0nG6u2rT/j9LikwND/njDUeRY1tvzRJ0Pw== Received: from BN9P221CA0030.NAMP221.PROD.OUTLOOK.COM (2603:10b6:408:10a::29) by PH7PR12MB6539.namprd12.prod.outlook.com (2603:10b6:510:1f0::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.33; Mon, 30 Jan 2023 13:20:30 +0000 Received: from BN8NAM11FT023.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10a:cafe::3c) by BN9P221CA0030.outlook.office365.com (2603:10b6:408:10a::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36 via Frontend Transport; Mon, 30 Jan 2023 13:20:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN8NAM11FT023.mail.protection.outlook.com (10.13.177.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36 via Frontend Transport; Mon, 30 Jan 2023 13:20:29 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 30 Jan 2023 05:20:18 -0800 Received: from nvidia.com (10.126.231.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 30 Jan 2023 05:20:15 -0800 From: Rongwei Liu To: , , , , Aman Singh , Yuying Zhang , Ferruh Yigit , "Andrew Rybchenko" CC: , Subject: [PATCH v3 01/11] ethdev: add flex item modify field support Date: Mon, 30 Jan 2023 15:19:50 +0200 Message-ID: <20230130132000.1715473-2-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230130132000.1715473-1-rongweil@nvidia.com> References: <3ba49f25-52d0-fe07-02e6-22a71e0fbe13@oktetlabs.ru> <20230130132000.1715473-1-rongweil@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT023:EE_|PH7PR12MB6539:EE_ X-MS-Office365-Filtering-Correlation-Id: 80d2c278-50cd-4b07-f3dd-08db02c4c1ef X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D5lFDrE5UazurXSqjoErptA0JII5cJUhTMR9h394o+dEaWwWnK4u6StCnOQlR61BZOgBiTlMIq6VaJKOIZopuuGOlgJ2SMPDxn3flHHUasFMZbKrmvqIKi6QFm/TvORLbHlTOvLMZ0st3zcyTPkASeUhhgZiEdBw5m7CPCdP7vmTBEpFWnD1tVaidT8ggzuN+BZemgs0jR0GWqlj0Qi7W/VvArgYL0bQaBHvW9bJK4gXLCyW9GCxoTvwjZtv59LKS78paoqbGsr7n6RloJJYwS3mPZe53CqTRt7CeSNyOsGgaLQhV7kq4F6a0vB4xePhUmol1a8OskZIGWPxveoHrdT005eAHyMdKWpUTGs51gMv9Oo+KpGri1v0cvEcvfuI9d0ZoP5PetOle5CVatCFlWs6C/gJb7trM8oHKDp4ekL+f2VPXzY1w4bjiM0oKK8e3RXHJRiGEK83tOugtgod3xIiWi9zWnUFnD9hfxLPgcDU38oKkK8x/e8XL7vaOmZBckOyoHTl7kg/y6sJbuE0hAJhURTECmObn2mecojJPEJl+CxR0r+sumHx13imozSP4hfd35AUcDrQhuImhYm5NQSFzAj7JwwqLZRCi9pepGT4KvNDQKlZ+ZkTBmSRX6JE/eOL6556n9M8cz6i0EYRV6u6N3Pw7Qos/3mhadhsxnJAyFurcoOjWYm1qdFG90HmliGe3GBMQLB/W0ZWqKeC+92Hjr87PoSruaVbECm4+f4= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(346002)(39860400002)(136003)(396003)(376002)(451199018)(36840700001)(40470700004)(46966006)(41300700001)(70586007)(70206006)(83380400001)(4326008)(8676002)(8936002)(36756003)(40460700003)(110136005)(30864003)(186003)(356005)(6286002)(26005)(16526019)(426003)(55016003)(36860700001)(40480700001)(2906002)(5660300002)(54906003)(47076005)(316002)(7696005)(107886003)(478600001)(6666004)(7636003)(82740400003)(1076003)(336012)(82310400005)(86362001)(2616005)(21314003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 13:20:29.1599 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 80d2c278-50cd-4b07-f3dd-08db02c4c1ef X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT023.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6539 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 Add flex item as modify field destination. Add "struct rte_flow_item_flex_handle *flex_handle" into "struct rte_flow_action_modify_data" as union with existed "level" member. This new member is dedicated for modifying flex item. Add flex item modify field cmdline support. Now user can use testpmd cli to specify which flex item to be modified, either source or destination. Syntax is as below: modify_field op set dst_type flex_item dst_level 0 dst_offset 16 src_type value src_value 0x123456781020 width 8 Signed-off-by: Rongwei Liu Acked-by: Ori Kam --- app/test-pmd/cmdline_flow.c | 89 ++++++++++++++++++++++++-- doc/guides/prog_guide/rte_flow.rst | 41 +++++++----- doc/guides/rel_notes/release_23_03.rst | 4 ++ lib/ethdev/rte_flow.h | 8 ++- 4 files changed, 116 insertions(+), 26 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 88108498e0..7c12d63cbc 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -601,10 +601,12 @@ enum index { ACTION_MODIFY_FIELD_DST_TYPE, ACTION_MODIFY_FIELD_DST_TYPE_VALUE, ACTION_MODIFY_FIELD_DST_LEVEL, + ACTION_MODIFY_FIELD_DST_LEVEL_VALUE, ACTION_MODIFY_FIELD_DST_OFFSET, ACTION_MODIFY_FIELD_SRC_TYPE, ACTION_MODIFY_FIELD_SRC_TYPE_VALUE, ACTION_MODIFY_FIELD_SRC_LEVEL, + ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE, ACTION_MODIFY_FIELD_SRC_OFFSET, ACTION_MODIFY_FIELD_SRC_VALUE, ACTION_MODIFY_FIELD_SRC_POINTER, @@ -807,7 +809,8 @@ static const char *const modify_field_ids[] = { "udp_port_src", "udp_port_dst", "vxlan_vni", "geneve_vni", "gtp_teid", "tag", "mark", "meta", "pointer", "value", - "ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color", NULL + "ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color", + "flex_item", NULL }; static const char *const meter_colors[] = { @@ -2282,6 +2285,10 @@ parse_vc_modify_field_id(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size); static int +parse_vc_modify_field_level(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size); +static int parse_vc_action_conntrack_update(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size); @@ -5976,11 +5983,15 @@ static const struct token token_list[] = { .name = "dst_level", .help = "destination field level", .next = NEXT(action_modify_field_dst, - NEXT_ENTRY(COMMON_UNSIGNED)), - .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, - dst.level)), + NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_LEVEL_VALUE)), .call = parse_vc_conf, }, + [ACTION_MODIFY_FIELD_DST_LEVEL_VALUE] = { + .name = "{dst_level}", + .help = "destination field level value", + .call = parse_vc_modify_field_level, + .comp = comp_none, + }, [ACTION_MODIFY_FIELD_DST_OFFSET] = { .name = "dst_offset", .help = "destination field bit offset", @@ -6007,11 +6018,15 @@ static const struct token token_list[] = { .name = "src_level", .help = "source field level", .next = NEXT(action_modify_field_src, - NEXT_ENTRY(COMMON_UNSIGNED)), - .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, - src.level)), + NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE)), .call = parse_vc_conf, }, + [ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE] = { + .name = "{src_level}", + .help = "source field level value", + .call = parse_vc_modify_field_level, + .comp = comp_none, + }, [ACTION_MODIFY_FIELD_SRC_OFFSET] = { .name = "src_offset", .help = "source field bit offset", @@ -8477,6 +8492,66 @@ parse_vc_modify_field_id(struct context *ctx, const struct token *token, return len; } +/** Parse level for modify_field command. */ +static int +parse_vc_modify_field_level(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size) +{ + struct rte_flow_action_modify_field *action; + struct flex_item *fp; + uint32_t val; + struct buffer *out = buf; + char *end; + + (void)token; + (void)size; + if (ctx->curr != ACTION_MODIFY_FIELD_DST_LEVEL_VALUE && + ctx->curr != ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE) + return -1; + if (!ctx->object) + return len; + action = ctx->object; + errno = 0; + val = strtoumax(str, &end, 0); + if (errno || (size_t)(end - str) != len) + return -1; + /* No need to validate action template mask value */ + if (out->args.vc.masks) { + if (ctx->curr == ACTION_MODIFY_FIELD_DST_LEVEL_VALUE) + action->dst.level = val; + else + action->src.level = val; + return len; + } + if ((ctx->curr == ACTION_MODIFY_FIELD_DST_LEVEL_VALUE && + action->dst.field == RTE_FLOW_FIELD_FLEX_ITEM) || + (ctx->curr == ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE && + action->src.field == RTE_FLOW_FIELD_FLEX_ITEM)) { + if (val >= FLEX_MAX_PARSERS_NUM) { + printf("Bad flex item handle\n"); + return -1; + } + fp = flex_items[ctx->port][val]; + if (!fp) { + printf("Bad flex item handle\n"); + return -1; + } + } + if (ctx->curr == ACTION_MODIFY_FIELD_DST_LEVEL_VALUE) { + if (action->dst.field != RTE_FLOW_FIELD_FLEX_ITEM) + action->dst.level = val; + else + action->dst.flex_handle = fp->flex_handle; + } else if (ctx->curr == ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE) { + if (action->src.field != RTE_FLOW_FIELD_FLEX_ITEM) + action->src.level = val; + else + action->src.flex_handle = fp->flex_handle; + } + return len; +} + /** Parse the conntrack update, not a rte_flow_action. */ static int parse_vc_action_conntrack_update(struct context *ctx, const struct token *token, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 3e6242803d..9ffd7baa7a 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -2905,6 +2905,9 @@ encapsulation level, from outermost to innermost (lower to higher values). For the tag array (in case of multiple tags are supported and present) ``level`` translates directly into the array index. +``flex_handle`` is used to specify the flex item pointer which is being +modified. ``flex_handle`` and ``level`` are mutually exclusive. + ``offset`` specifies the number of bits to skip from a field's start. That allows performing a partial copy of the needed part or to divide a big packet field into multiple smaller fields. Alternatively, ``offset`` allows @@ -2952,23 +2955,27 @@ value as sequence of bytes {xxx, xxx, 0x85, xxx, xxx, xxx}. .. table:: destination/source field definition - +---------------+----------------------------------------------------------+ - | Field | Value | - +===============+==========================================================+ - | ``field`` | ID: packet field, mark, meta, tag, immediate, pointer | - +---------------+----------------------------------------------------------+ - | ``level`` | encapsulation level of a packet field or tag array index | - +---------------+----------------------------------------------------------+ - | ``offset`` | number of bits to skip at the beginning | - +---------------+----------------------------------------------------------+ - | ``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 | - +---------------+----------------------------------------------------------+ + +-----------------+----------------------------------------------------------+ + | Field | Value | + +=================+==========================================================+ + | ``field`` | ID: packet field, mark, meta, tag, immediate, pointer | + +-----------------+----------------------------------------------------------+ + | ``level`` | encapsulation level of a packet field or tag array index | + +-----------------+----------------------------------------------------------+ + | ``flex_handle`` | flex item handle of a packet field | + +-----------------+----------------------------------------------------------+ + | ``offset`` | number of bits to skip at the beginning | + +-----------------+----------------------------------------------------------+ + | ``value`` | immediate value buffer (source field only, not | + | | applicable to destination) for RTE_FLOW_FIELD_VALUE | + | | field type | + | | This field is only 16 bytes, maybe not big enough for | + | | all NICs' flex item | + +-----------------+----------------------------------------------------------+ + | ``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/release_23_03.rst b/doc/guides/rel_notes/release_23_03.rst index c15f6fbb9f..3fb6e738e2 100644 --- a/doc/guides/rel_notes/release_23_03.rst +++ b/doc/guides/rel_notes/release_23_03.rst @@ -69,6 +69,10 @@ New Features ``rte_event_dev_config::nb_single_link_event_port_queues`` parameter required for eth_rx, eth_tx, crypto and timer eventdev adapters. +* ethdev: added a new field: + + - modify flex item: ``rte_flow_action_modify_data.flex_handle``. + Removed Items ------------- diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index b60987db4b..ba9f3d50a3 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -3528,6 +3528,7 @@ enum rte_flow_field_id { RTE_FLOW_FIELD_IPV6_ECN, /**< IPv6 ECN. */ RTE_FLOW_FIELD_GTP_PSC_QFI, /**< GTP QFI. */ RTE_FLOW_FIELD_METER_COLOR, /**< Meter color marker. */ + RTE_FLOW_FIELD_FLEX_ITEM, /**< Flex item. */ }; /** @@ -3541,8 +3542,11 @@ struct rte_flow_action_modify_data { RTE_STD_C11 union { struct { - /** Encapsulation level or tag index. */ - uint32_t level; + /** Encapsulation level or tag index or flex item handle. */ + union { + uint32_t level; + struct rte_flow_item_flex_handle *flex_handle; + }; /** Number of bits to skip from a field. */ uint32_t offset; }; -- 2.27.0