From patchwork Wed Feb 8 02:47:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 123409 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 BDFC641C35; Wed, 8 Feb 2023 03:48:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A92E842C4D; Wed, 8 Feb 2023 03:48:30 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2087.outbound.protection.outlook.com [40.107.223.87]) by mails.dpdk.org (Postfix) with ESMTP id CFF29410EE for ; Wed, 8 Feb 2023 03:48:28 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lC+JAebILC764IwnV90zRtyE9YzPsfBPrCssfmxxfA8ol4wzssNH4DMUA8PdMiCz9WZajc0ovo2IA04alOcjwvHUASwU5xEIixYvUWPcCkOk1qQp1iJkZyO89LWrAld4fOnZOWSDG5XvKooIgkv0s7JtoGP0kAhaaD5VX4TYqlby3OCV/h84HROphcZOYt+fgfW5xrSMbivAfdLvmUUAvgTODk9YAYeb8dKDOmDEec3uRtbiGNtYy2MCOTwPUFHCFL0e1RNr0ag7ogzBFtfd1UDhotz5oFtBgxdjLHhzluwu37K4bPJSRhQhRU5Fq9Szy9BF2oTvpUAH+mp8axE+XQ== 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=GelJ1nuhvqrn9p+RpgUtTZZp1RFvJ8PBtkHX1F43tyE=; b=DcHLe+WT2moKyexnyFm56lhZZ/jYBLSrSNOLJe7ZpIMRbRVh9VWKeAgHokpb3E0jjfffjZg3Kjk7+3Wjwx0DsG5uoJ1T0FVOwdLqhphhYXGHi8lj6FOGyZw3NjX0cJjWKo9LaAIj8pzWfBwFOazVVxCPWUYRaKkWK9rTm5Hc2cP92lilf1XvaA3Wy3BNNW2qe2z0RI/+LEYarMTP7nArUCpARMFaRjQQ3o3bRh7Gpv910pjom1iwprhRL2SRw2G2smz90hmtr+cyCYCj+fGANT70QB4RaIWnKzHs36FelAXajt9edrP9MjIaWJcwRvc6AMN8AHuKIhk8XGMIExhQUw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org 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=GelJ1nuhvqrn9p+RpgUtTZZp1RFvJ8PBtkHX1F43tyE=; b=p7NQ3Yw7kbLWkMExZkQ5EJG6qjF857I4CvOPlEyh/3zLsKGy+CIJ4d3uudX3+7gcTioq9D8/p6rkS92vDBkP2C7fuJw9BRjDDHuveZ3lIf5tWa3gSwThfYZqNmiNtOZ83oqfVuogdOtijnrSn9veFvMX1qqmnzdpNKzAPs3L7wU+BdMpio2zziEhQVJ5Q4I5p6Zu3O+hS5STfjhoodobzrBf4OthH0eqPpc6x76lb49X+4KbapeTq5JfMmjgx91jYT6DIdaxQqJbUgXDaociCalegZpXa17pJ3X/q0SdlXhrn/8r69wOM2KOVKYAh3gixsLlBdWWf3iJ+N7BaoQ1eg== Received: from DS7PR03CA0170.namprd03.prod.outlook.com (2603:10b6:5:3b2::25) by DM4PR12MB7693.namprd12.prod.outlook.com (2603:10b6:8:103::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Wed, 8 Feb 2023 02:48:26 +0000 Received: from DS1PEPF0000E653.namprd02.prod.outlook.com (2603:10b6:5:3b2:cafe::9c) by DS7PR03CA0170.outlook.office365.com (2603:10b6:5:3b2::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36 via Frontend Transport; Wed, 8 Feb 2023 02:48:26 +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 DS1PEPF0000E653.mail.protection.outlook.com (10.167.18.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.16 via Frontend Transport; Wed, 8 Feb 2023 02:48:26 +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; Tue, 7 Feb 2023 18:48:18 -0800 Received: from pegasus01.mtr.labs.mlnx (10.126.230.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; Tue, 7 Feb 2023 18:48:15 -0800 From: Alexander Kozyrev To: CC: , , , Subject: [PATCH v3 3/4] app/testpmd: add template table insertion type Date: Wed, 8 Feb 2023 04:47:54 +0200 Message-ID: <20230208024755.72743-4-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20230208024755.72743-1-akozyrev@nvidia.com> References: <20230126232802.3960109-1-akozyrev@nvidia.com> <20230208024755.72743-1-akozyrev@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E653:EE_|DM4PR12MB7693:EE_ X-MS-Office365-Filtering-Correlation-Id: 9467bf6c-6bb2-44c4-6b21-08db097ef401 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: O3GQPTIvMb7k0s2XhzO6+ydpxdKDeJ6rHOjSjDCDpUHIUztHsNvN3Iz0OG3bDMJRghe/ZNjLX5JyuCSHpsmFVLpTcyXnK4Tqn7xbx6zR0MhbuJivihcLgt1/sxhgSGOp8SeumjYODdCCTK5KVXM4JIrLokQrfj2tDva+lnXvr3p7vO5doTYgd2axQWbj9SycaixIBctcg3Yf2SETtaOll6eMTJqg0PWqPA+byHSOkxgCvlMChUjY5Q5xnOHbr9LSKCyFwzfnODEPvRwBK3XvHW7xh5FYSVR33JOc02+lwjE5RRoj29FSOrree+lNiggdgNdZ4pArt3xwLdbuGN2Rnqol8ercXHfhWgmAlEqGv2W/vFZtKM1SLaRM+fYIJvOcxIzWsI81ttV83uWMRM2xDsD5lCjvF8uEkr4WJ8CRlQeYJ+2/LWgylk/OH5J5F/p6Ritd107s68N8DFDQOWcp3wGFGmQZyh1doyLdObA2wasQt+Y4CZGugy9YNd6MhsWQcjazyrGP3p8lx8xK093GLvrM/aP5o66gCTi33dmiHkj7Xc98vR2SCq4QUSPuLlQ1SRS1V5niHiBsbTMuaEjJb3thnXBZGR3B1PVTwBH2SjKydCXbNJIDyE380cAyYFeUgK/iyzarpNKTjB/F/xcOoXW215fUHbLZAy+puPuut0vGiA3pKHkPuSjKFCw7XBsmaCbQj0Y00C7fGCtWGa9sPA== 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)(39860400002)(396003)(136003)(376002)(346002)(451199018)(46966006)(36840700001)(40470700004)(2906002)(36860700001)(82310400005)(86362001)(7636003)(82740400003)(40460700003)(336012)(47076005)(426003)(2616005)(16526019)(186003)(26005)(36756003)(40480700001)(356005)(70206006)(70586007)(54906003)(316002)(83380400001)(41300700001)(4326008)(6916009)(478600001)(1076003)(6666004)(107886003)(8676002)(8936002)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2023 02:48:26.5757 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9467bf6c-6bb2-44c4-6b21-08db097ef401 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: DS1PEPF0000E653.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7693 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 testpmd CLI interface for specifying a template table insertion type. Available types are: pattern and index. flow template_table 0 create table_id 0 insertion_type index ... Allow specifying the rule index instead of the pattern template index: flow queue 0 create 0 template_table 0 rule_index 5 actions_template 0 ... Signed-off-by: Alexander Kozyrev --- app/test-pmd/cmdline_flow.c | 97 ++++++++++++++++++++++++++++++++++--- app/test-pmd/config.c | 10 ++-- app/test-pmd/testpmd.h | 2 +- 3 files changed, 99 insertions(+), 10 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 88108498e0..f1d6813baa 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -133,12 +133,11 @@ enum index { QUEUE_INDIRECT_ACTION, /* Queue create arguments. */ - QUEUE_CREATE_ID, QUEUE_CREATE_POSTPONE, QUEUE_TEMPLATE_TABLE, QUEUE_PATTERN_TEMPLATE, QUEUE_ACTIONS_TEMPLATE, - QUEUE_SPEC, + QUEUE_RULE_ID, /* Queue destroy arguments. */ QUEUE_DESTROY_ID, @@ -179,6 +178,8 @@ enum index { TABLE_DESTROY, TABLE_CREATE_ID, TABLE_DESTROY_ID, + TABLE_INSERTION_TYPE, + TABLE_INSERTION_TYPE_NAME, TABLE_GROUP, TABLE_PRIORITY, TABLE_INGRESS, @@ -814,6 +815,12 @@ static const char *const meter_colors[] = { "green", "yellow", "red", "all", NULL }; +static const char *const table_insertion_types[] = { + "pattern", "index", NULL +}; + +#define RAW_IPSEC_CONFS_MAX_NUM 8 + /** Maximum number of subsequent tokens and arguments on the stack. */ #define CTX_STACK_SIZE 16 @@ -1015,6 +1022,7 @@ struct buffer { struct { uint32_t table_id; uint32_t pat_templ_id; + uint32_t rule_id; uint32_t act_templ_id; struct rte_flow_attr attr; struct tunnel_ops tunnel_ops; @@ -1154,6 +1162,7 @@ static const enum index next_table_subcmd[] = { static const enum index next_table_attr[] = { TABLE_CREATE_ID, TABLE_GROUP, + TABLE_INSERTION_TYPE, TABLE_PRIORITY, TABLE_INGRESS, TABLE_EGRESS, @@ -1287,6 +1296,12 @@ static const enum index next_ia_destroy_attr[] = { ZERO, }; +static const enum index next_async_insert_subcmd[] = { + QUEUE_PATTERN_TEMPLATE, + QUEUE_RULE_ID, + ZERO, +}; + static const enum index item_param[] = { ITEM_PARAM_IS, ITEM_PARAM_SPEC, @@ -2399,6 +2414,9 @@ static int parse_meter_policy_id2ptr(struct context *ctx, static int parse_meter_color(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size); +static int parse_insertion_table_type(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size); static int comp_none(struct context *, const struct token *, unsigned int, char *, unsigned int); static int comp_boolean(struct context *, const struct token *, @@ -2431,6 +2449,8 @@ static int comp_queue_id(struct context *, const struct token *, unsigned int, char *, unsigned int); static int comp_meter_color(struct context *, const struct token *, unsigned int, char *, unsigned int); +static int comp_insertion_table_type(struct context *, const struct token *, + unsigned int, char *, unsigned int); /** Token definitions. */ static const struct token token_list[] = { @@ -2901,6 +2921,20 @@ static const struct token token_list[] = { args.table_destroy.table_id)), .call = parse_table_destroy, }, + [TABLE_INSERTION_TYPE] = { + .name = "insertion_type", + .help = "specify insertion type", + .next = NEXT(next_table_attr, + NEXT_ENTRY(TABLE_INSERTION_TYPE_NAME)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.insertion_type)), + }, + [TABLE_INSERTION_TYPE_NAME] = { + .name = "insertion_type_name", + .help = "insertion type name", + .call = parse_insertion_table_type, + .comp = comp_insertion_table_type, + }, [TABLE_GROUP] = { .name = "group", .help = "specify a group", @@ -3002,7 +3036,7 @@ static const struct token token_list[] = { [QUEUE_TEMPLATE_TABLE] = { .name = "template_table", .help = "specify table id", - .next = NEXT(NEXT_ENTRY(QUEUE_PATTERN_TEMPLATE), + .next = NEXT(next_async_insert_subcmd, NEXT_ENTRY(COMMON_TABLE_ID)), .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.table_id)), @@ -3026,6 +3060,15 @@ static const struct token token_list[] = { args.vc.act_templ_id)), .call = parse_qo, }, + [QUEUE_RULE_ID] = { + .name = "rule_index", + .help = "specify flow rule index", + .next = NEXT(NEXT_ENTRY(QUEUE_ACTIONS_TEMPLATE), + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.vc.rule_id)), + .call = parse_qo, + }, [QUEUE_CREATE_POSTPONE] = { .name = "postpone", .help = "postpone create operation", @@ -9069,11 +9112,13 @@ parse_qo(struct context *ctx, const struct token *token, ctx->objdata = 0; ctx->object = out; ctx->objmask = NULL; + out->args.vc.rule_id = UINT32_MAX; return len; case QUEUE_TEMPLATE_TABLE: case QUEUE_PATTERN_TEMPLATE: case QUEUE_ACTIONS_TEMPLATE: case QUEUE_CREATE_POSTPONE: + case QUEUE_RULE_ID: return len; case ITEM_PATTERN: out->args.vc.pattern = @@ -10052,6 +10097,32 @@ parse_meter_color(struct context *ctx, const struct token *token, return len; } +/** Parse Insertion Table Type name */ +static int +parse_insertion_table_type(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size) +{ + const struct arg *arg = pop_args(ctx); + unsigned int i; + char tmp[2]; + int ret; + + (void)size; + /* Argument is expected. */ + if (!arg) + return -1; + for (i = 0; table_insertion_types[i]; ++i) + if (!strcmp_partial(table_insertion_types[i], str, len)) + break; + if (!table_insertion_types[i]) + return -1; + push_args(ctx, arg); + snprintf(tmp, sizeof(tmp), "%u", i); + ret = parse_int(ctx, token, tmp, strlen(tmp), buf, sizeof(i)); + return ret > 0 ? (int)len : ret; +} + /** No completion. */ static int comp_none(struct context *ctx, const struct token *token, @@ -10357,6 +10428,20 @@ comp_meter_color(struct context *ctx, const struct token *token, return -1; } +/** Complete available Insertion Table types. */ +static int +comp_insertion_table_type(struct context *ctx, const struct token *token, + unsigned int ent, char *buf, unsigned int size) +{ + RTE_SET_USED(ctx); + RTE_SET_USED(token); + if (!buf) + return RTE_DIM(table_insertion_types); + if (ent < RTE_DIM(table_insertion_types) - 1) + return rte_strscpy(buf, table_insertion_types[ent], size); + return -1; +} + /** Internal context. */ static struct context cmd_flow_context; @@ -10670,9 +10755,9 @@ cmd_flow_parsed(const struct buffer *in) break; case QUEUE_CREATE: port_queue_flow_create(in->port, in->queue, in->postpone, - in->args.vc.table_id, in->args.vc.pat_templ_id, - in->args.vc.act_templ_id, in->args.vc.pattern, - in->args.vc.actions); + in->args.vc.table_id, in->args.vc.rule_id, + in->args.vc.pat_templ_id, in->args.vc.act_templ_id, + in->args.vc.pattern, in->args.vc.actions); break; case QUEUE_DESTROY: port_queue_flow_destroy(in->port, in->queue, in->postpone, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index acccb6b035..41484c3dde 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2609,7 +2609,7 @@ port_flow_template_table_flush(portid_t port_id) /** Enqueue create flow rule operation. */ int port_queue_flow_create(portid_t port_id, queueid_t queue_id, - bool postpone, uint32_t table_id, + bool postpone, uint32_t table_id, uint32_t rule_idx, uint32_t pattern_idx, uint32_t actions_idx, const struct rte_flow_item *pattern, const struct rte_flow_action *actions) @@ -2685,8 +2685,12 @@ port_queue_flow_create(portid_t port_id, queueid_t queue_id, } /* Poisoning to make sure PMDs update it in case of error. */ memset(&error, 0x11, sizeof(error)); - flow = rte_flow_async_create(port_id, queue_id, &op_attr, pt->table, - pattern, pattern_idx, actions, actions_idx, job, &error); + if (rule_idx == UINT32_MAX) + flow = rte_flow_async_create(port_id, queue_id, &op_attr, pt->table, + pattern, pattern_idx, actions, actions_idx, job, &error); + else + flow = rte_flow_async_create_by_index(port_id, queue_id, &op_attr, pt->table, + rule_idx, actions, actions_idx, job, &error); if (!flow) { uint32_t flow_id = pf->id; port_queue_flow_destroy(port_id, queue_id, true, 1, &flow_id); diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 7d24d25970..22d02a742c 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -930,7 +930,7 @@ int port_flow_template_table_destroy(portid_t port_id, uint32_t n, const uint32_t *table); int port_flow_template_table_flush(portid_t port_id); int port_queue_flow_create(portid_t port_id, queueid_t queue_id, - bool postpone, uint32_t table_id, + bool postpone, uint32_t table_id, uint32_t rule_idx, uint32_t pattern_idx, uint32_t actions_idx, const struct rte_flow_item *pattern, const struct rte_flow_action *actions);