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 AB6B4A0C43; Mon, 11 Oct 2021 01:46:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E086B410E8; Mon, 11 Oct 2021 01:46:24 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2055.outbound.protection.outlook.com [40.107.223.55]) by mails.dpdk.org (Postfix) with ESMTP id C3BA4410E8 for ; Mon, 11 Oct 2021 01:46:23 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YdE/G+RO3npzXjJw9P2Y9mATLHykq3fCv1jfcmQZOWKrE2PeQKhGw3immb36A/9bqOSkKK7OjKGKbPLDeq+8BY6UPwhl+Wqv/WaSdrmwpC0IbvkKqCVNuzi1dIR7SNvcUJnCaoIRDmtM3wlu3SrLqGMAx+9v/WwX5XG5lq4/T8yW0RF3MXaKX6azVJMkf82wnTdm/uUMHFPlR37gVWNOhF6vIDgSn5F3b2lkbq76fzPXSuEFVl2OrIQZZFAjGHKJOnhAQVTuJ5ZUMJe14Exucjb7KPbmSwENFlFdI4u45BE5Wl5MjAUz5douIKaRvIjGfHNdASYvMfuT531qEUkbXQ== 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=DXPPM0eLi2MITTHjCW9Da8tNL0MK9PukOmy/z37k46QdGhUp7e5MgKIVp7f7S8b9gQo7rP0mfgNxiYi4SekB+98w/knk4rKk4iRHVmk9SsZBUuRtvE+Nf+/ez+wd5sN4/CfeOKjV389DUOQwxieVJofP2xw3brQwme8DEGGmqzgVc4HLrh4DWvAEMYrS9s9IR8ww83tTCVcRKMR63KWEIveL5nbLAxudGRBraz+eZiuNerjKOdsqtxQPY6jzvuBl0emw8cKSdb/PJhoiavW5e1EwwmubKSdhzm76FxU8BQYfeoC6DZfS6p404/v+SIE0FuAv/jEyKja7nlrsQucz4A== 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=tYHmBDqTh8k0JzhbmDpcX/4yr3oKDlCX3M8bdd3ws78S+p1mFUAAnejXjeZFMYIV//e1/J7cBymDgTSWVoIWh6TFfr2z74/vcm8IDrSxvEmbR0l7gm3zaXspgxtz6YXVRWg/aw2SOdp05IMoQXbnc2nVgGya4u/vtdICvFpepphkmBGntkOVLmlYGVCrY+8BEPBiai15PtYHLYackyomZDqrYVc0bE0kUGVQlh9YD56D3uxwMrl4CK2Y5rAJTxTzlrjT1Bj/2UZgkXwDbGnGp5DULLvO4YK37C0utMfDC2wtyXb6jAPgPlIx9hFESsbrRHzrjxApWxy/tsgGudO2ug== Received: from DM5PR15CA0053.namprd15.prod.outlook.com (2603:10b6:3:ae::15) by MN2PR12MB4814.namprd12.prod.outlook.com (2603:10b6:208:1b6::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Sun, 10 Oct 2021 23:46:19 +0000 Received: from DM6NAM11FT057.eop-nam11.prod.protection.outlook.com (2603:10b6:3:ae:cafe::72) by DM5PR15CA0053.outlook.office365.com (2603:10b6:3:ae::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18 via Frontend Transport; Sun, 10 Oct 2021 23:46: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 DM6NAM11FT057.mail.protection.outlook.com (10.13.172.252) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4587.18 via Frontend Transport; Sun, 10 Oct 2021 23:46:18 +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; Sun, 10 Oct 2021 23:46:16 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , Date: Mon, 11 Oct 2021 02:45:44 +0300 Message-ID: <20211010234547.1495-3-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20211010234547.1495-1-viacheslavo@nvidia.com> References: <20210910141609.8410-1-viacheslavo@nvidia.com> <20211010234547.1495-1-viacheslavo@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain 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: 35551c3b-2275-49c0-d4f6-08d98c48283e X-MS-TrafficTypeDiagnostic: MN2PR12MB4814: 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: soA+OIp499z7pVTd36Jx5i16KzD3qF5XzayJ0kL2HO6Elt6enhw3lSZNc+FWdd8XUEH34WOlEZSYxunI3R+hECc4heJPd4qkEWB0nvXoR0DfjEy6HkJYvzPmENMb6Mj6tu/frMP2nvHYwZGx2k0MyvCZd1wGKS6m5ttjH6d2LPKyPVN2Fu/OKj91yVZ//pcCivzNnJSR9oHz9zHJadIzH3noPKTnZGVgOH9Ym1/RfF92XckVuCq+qaSygW0rvREmvTR8M0DHR+qUak6iJytrpRsObtaKKRlekZE57cE+upp/5nxfP/FaSARDiP4ofIJfdE//nychFmA/vCxWMm/mTqeFshgejc4a0hRCNoxaBh5fbCJiq6cH10l4DVL59uUIeWPqLhc0kmlamzPy5XuxJMoV03n3WEDeQhUW4UN0NNM+OGfHIQVJ1LBx5ZYTc6U7JbAYgSO4N1S9UxJ3gY2vtwtBpmm1v8tJ6+/a7HvQh5E8Mib+7hNk/5NR25cuwgmIQAU1GvbCkPnOzlclte62R+QgZwiUsD0gO/PIVV6auHcS2BVV+fDsUcOBkg69k6immkfMkg5ykWzJ/a1BT/9JHXv0hV9Nj+mnmgf1Kg2mWxgZbINGX1Jfy/1LPnzl72qJkADIYJGUi/CbAB8B+zlqzaHio6OMCh8Xt+ls5/te5dGtr0tFiYMqabCgqXLfax/8K+UdefNpy4lfPHZ9DMfPug== 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)(2906002)(70206006)(7636003)(316002)(15650500001)(47076005)(6916009)(55016002)(336012)(4326008)(356005)(82310400003)(2616005)(426003)(54906003)(508600001)(36756003)(8676002)(36860700001)(26005)(16526019)(186003)(6286002)(70586007)(8936002)(86362001)(5660300002)(1076003)(6666004)(83380400001)(7696005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2021 23:46:18.9246 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 35551c3b-2275-49c0-d4f6-08d98c48283e 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: DM6NAM11FT057.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4814 Subject: [dpdk-dev] [PATCH v2 2/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 --- 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; } -- 2.18.1