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 3698041EB1; Thu, 16 Mar 2023 15:20:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2FE8042D47; Thu, 16 Mar 2023 15:20:11 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2047.outbound.protection.outlook.com [40.107.243.47]) by mails.dpdk.org (Postfix) with ESMTP id B721742D44 for ; Thu, 16 Mar 2023 15:20:09 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VHrkxg/ji/UaGw9suv45u/bQlyOwa1nkZtmytWh7wdMJIdTpvywNxyZ6hL4/udDFUOC5Tz3bCmxh4Pj3EuKEA0SaJOdv0pJf+1YwA61PkzYG5h1tf79vb6TA3AoAbp0NCH3VF1FCJi/TcPqwR8Iq0V75kal8i6oONIwPCsiNIobiOewbMmGMt8QfdUmLXLMvn6hqj9e2vo/NFv40sXZN2eQEZIByisRiVIQxBUMoLnOhRMhwRnz7+YgC8MR2ZDrvY3qI4EGd+3pbgddilbk1o8UXrS7R8g/Y9RgqwkFOoPVsh1kqauXgTYg4gBrCiAgY217BHCYmjTJKjErV0CBDMQ== 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=ja2gSiTMSOb2sksnDMFjVP4yJvM3sm47q2CXGzknINk=; b=Tqf8qarexuf7eUqAo45DMPteOvrCVN2LKaSfjklPO/UiyWIzwTwYb6bcYYo6dnNJj0LvFpKNDEe9DCYYulfUWZPh229NkbsP9FRYa7cDaU5oDeRDMtK8jYoDJyn+XTJ0Sou9bfw4o6m7UwuBNzGh2SN1Uxxv8X9HJvWdjt0KRTEjVMptFhI1zLS3h0gvuWw+8ta/OTSwEkcVZxIwDhONVuXPcEU/JE0sKMadJOvT6QpaVk5IHCOZABifBopeaxhkMchW0KsxppWh4i5zd8j5oDu4FFm5n1g+2FR4C75bls27Vzi8Ux4xJGkY5RjOH1VEWkhRU8m69AAZG9G2Qs8DQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=ja2gSiTMSOb2sksnDMFjVP4yJvM3sm47q2CXGzknINk=; b=GMnVDtMlOHaIZ9qulWWsiMOYCu3Vnm+FZhk9jd7z4VQgcDhbGfpftwFyKYxzkWd1YME4stEGfwg7UXU119K5apQmk+XPn6qx4rccYqnEkRHceYmdZc5deIicUNIEYYg/VYFDC7HgvnQZh9n8bkCRsQI7+y7cjPF3t7hi8ZQImxY8I3oLrKNhpPGFvr6MoYLu9hOiI4HPUfAeAnOXa26bYJe1DbetIhr3YbmmplkvpjRj5WXPlOkzx306kVJNKBfdjgjoT7YmwQ9RqIo4kJJLhj64pLi9d1mQMHP/ahSz1Ek7ew9qAG5MV7aC4TX+eYwgIqgYa3FU31Pt5vBSBMBn8A== Received: from MN2PR14CA0026.namprd14.prod.outlook.com (2603:10b6:208:23e::31) by PH7PR12MB6719.namprd12.prod.outlook.com (2603:10b6:510:1b2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.26; Thu, 16 Mar 2023 14:20:07 +0000 Received: from BL02EPF00010209.namprd05.prod.outlook.com (2603:10b6:208:23e:cafe::b2) by MN2PR14CA0026.outlook.office365.com (2603:10b6:208:23e::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.31 via Frontend Transport; Thu, 16 Mar 2023 14:20:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL02EPF00010209.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.13 via Frontend Transport; Thu, 16 Mar 2023 14:20:06 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 16 Mar 2023 07:19:53 -0700 Received: from nvidia.com (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.37; Thu, 16 Mar 2023 07:19:51 -0700 From: Gregory Etelson To: CC: , , , Ori Kam , Aman Singh , Yuying Zhang Subject: [PATCH V2 2/2] app/testpmd: assign custom ID to flow rules Date: Thu, 16 Mar 2023 16:19:34 +0200 Message-ID: <20230316141934.23181-2-getelson@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230316141934.23181-1-getelson@nvidia.com> References: <20230222141139.3233715-2-elibr@nvidia.com> <20230316141934.23181-1-getelson@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00010209:EE_|PH7PR12MB6719:EE_ X-MS-Office365-Filtering-Correlation-Id: e6a12217-3d28-4d1d-b048-08db26298b08 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HXLso7cD7uCY5f1zRXqwKfrl2gjClDuNrdsL02Tcvos/12Evb0Q+EGRcJ7uKut07G6EWew8PhqrH2QjLIclJ3pjMuTVTHbuoVTQ6bW4e7dhyiV8KHmGzwchduR2E/gcoOAeuJ5jfFYqQkjSRQLHcNgJHetXFRYxelSJYEByvg76h9/x5wfnhmkr3BjEsjLPxLdDYrx5zxCNZ4KMokMt1NihWCPPciPVN7JYhuphP+wbN2xDMlNOTwGnp9YHgFMVOKKlf3Z3DNyP4QlTONMIxbpGdETsQhm+myRCgwaB4EwI3PHNcM3oCDy/3wF+cBub+PI/0gD0WfxmTcb22NlShsU9rP69GEfQmgtydEQc1P6u2fIsASqCHCTglZBXquU4NeDRvxsmBsWFkoUuIS/n5Tjb/hO6KVj3uLOvGmAhVlq8qfT4cNI0gq/rlCYhjCc2hmlSacIMXZLbnUxNystL/bp3WwAlzG0U5I/wJppv6izovxcwqljNCEGXEpEZ5l1vb8rt0SyA7jORVo+TD1P2BMAf0FCM5QtVxAn3LGuEpUkFSYNMgUGumBjLSBwyxx4RSj3wI9UKEVImMHISU+Q971il0/2GZ2e+rJ5SbrYU2Jf1rdrRfRXiLblul6FO6lHTXMHe/YE1EwRaedq2cBTOg70Qtt1UtrDDN6V0dFV6LDwAgQBMWQIgzKESpfpap+WFIIVrWnFUlxGDkqCE8TJ7IIoJtH6ySumvJugF+nnrfGdr/IS13DoS11+CT+fnAnxda X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(376002)(39860400002)(136003)(396003)(346002)(451199018)(36840700001)(46966006)(40470700004)(40460700003)(36756003)(5660300002)(30864003)(83380400001)(16526019)(47076005)(82310400005)(2616005)(426003)(7696005)(478600001)(70206006)(26005)(1076003)(6286002)(336012)(6666004)(40480700001)(356005)(4326008)(55016003)(6916009)(70586007)(36860700001)(8936002)(186003)(86362001)(54906003)(316002)(41300700001)(7636003)(8676002)(2906002)(82740400003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Mar 2023 14:20:06.9142 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e6a12217-3d28-4d1d-b048-08db26298b08 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.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00010209.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6719 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 From: Eli Britstein Upon creation of a flow, testpmd assigns it a flow ID. Later, the flow ID is used for flow operations (query, destroy, dump). The testpmd application allows to manage flow rules with its IDs. The flow ID is known only when the flow is created. In order to prepare a complete sequence of testpmd commands to copy/paste, the flow IDs must be predictable. Allow the user to provide an assigned ID. Example: testpmd> flow create 0 ingress user_id 0x1234 pattern eth / end actions count / drop / end Flow rule #0 created, user-id 0x1234 testpmd> flow query 0 0x1234 count user_id testpmd> flow dump 0 user_id rule 0x1234 testpmd> flow destroy 0 rule 0x1234 user_id Flow rule #0 destroyed, user-id 0x1234 Here, "user_id" is a flag that signifies the "rule" ID is the user-id. The motivation is from OVS. OVS dumps its "rte_flow_create" calls to the log in testpmd commands syntax. As the flow ID testpmd would assign is unkwon, it cannot log valid "flow destroy" commands. With this enhancement, valid testpmd commands can be created in a log to copy/paste to testpmd. The application's flows sequence can then be played back in testpmd, to enable enhanced dpdk debug capabilities of the applications's flows in a controlled environment of testpmd rather than a dynamic, more difficult to debug environment of the application. Signed-off-by: Eli Britstein --- app/test-pmd/cmdline_flow.c | 72 +++++++++++++++++++-- app/test-pmd/config.c | 34 +++++++--- app/test-pmd/testpmd.h | 12 ++-- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 33 +++++++--- 4 files changed, 121 insertions(+), 30 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index aab0df91c2..669da31e5d 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -206,9 +206,11 @@ enum index { /* Destroy arguments. */ DESTROY_RULE, + DESTROY_IS_USER_ID, /* Query arguments. */ QUERY_ACTION, + QUERY_IS_USER_ID, /* List arguments. */ LIST_GROUP, @@ -224,10 +226,12 @@ enum index { VC_TRANSFER, VC_TUNNEL_SET, VC_TUNNEL_MATCH, + VC_USER_ID, /* Dump arguments */ DUMP_ALL, DUMP_ONE, + DUMP_IS_USER_ID, /* Configure arguments */ CONFIG_QUEUES_NUMBER, @@ -1077,6 +1081,7 @@ struct buffer { uint32_t act_templ_id; struct rte_flow_attr attr; struct tunnel_ops tunnel_ops; + uintptr_t user_id; struct rte_flow_item *pattern; struct rte_flow_action *actions; struct rte_flow_action *masks; @@ -1087,15 +1092,18 @@ struct buffer { struct { uint64_t *rule; uint64_t rule_n; + bool is_user_id; } destroy; /**< Destroy arguments. */ struct { char file[128]; bool mode; uint64_t rule; + bool is_user_id; } dump; /**< Dump arguments. */ struct { uint64_t rule; struct rte_flow_action action; + bool is_user_id; } query; /**< Query arguments. */ struct { uint32_t *group; @@ -1319,6 +1327,7 @@ static const enum index next_ia_qu_attr[] = { static const enum index next_dump_subcmd[] = { DUMP_ALL, DUMP_ONE, + DUMP_IS_USER_ID, ZERO, }; @@ -1339,12 +1348,14 @@ static const enum index next_vc_attr[] = { VC_TRANSFER, VC_TUNNEL_SET, VC_TUNNEL_MATCH, + VC_USER_ID, ITEM_PATTERN, ZERO, }; static const enum index next_destroy_attr[] = { DESTROY_RULE, + DESTROY_IS_USER_ID, END, ZERO, }; @@ -1355,6 +1366,12 @@ static const enum index next_dump_attr[] = { ZERO, }; +static const enum index next_query_attr[] = { + QUERY_IS_USER_ID, + END, + ZERO, +}; + static const enum index next_list_attr[] = { LIST_GROUP, END, @@ -3533,7 +3550,7 @@ static const struct token token_list[] = { [DESTROY] = { .name = "destroy", .help = "destroy specific flow rules", - .next = NEXT(NEXT_ENTRY(DESTROY_RULE), + .next = NEXT(next_destroy_attr, NEXT_ENTRY(COMMON_PORT_ID)), .args = ARGS(ARGS_ENTRY(struct buffer, port)), .call = parse_destroy, @@ -3555,7 +3572,7 @@ static const struct token token_list[] = { [QUERY] = { .name = "query", .help = "query an existing flow rule", - .next = NEXT(NEXT_ENTRY(QUERY_ACTION), + .next = NEXT(next_query_attr, NEXT_ENTRY(QUERY_ACTION), NEXT_ENTRY(COMMON_RULE_ID), NEXT_ENTRY(COMMON_PORT_ID)), .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type), @@ -3674,6 +3691,12 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)), .call = parse_destroy, }, + [DESTROY_IS_USER_ID] = { + .name = "user_id", + .help = "rule identifier is user-id", + .next = NEXT(next_destroy_attr), + .call = parse_destroy, + }, /* Dump arguments. */ [DUMP_ALL] = { .name = "all", @@ -3690,6 +3713,12 @@ static const struct token token_list[] = { ARGS_ENTRY(struct buffer, args.dump.rule)), .call = parse_dump, }, + [DUMP_IS_USER_ID] = { + .name = "user_id", + .help = "rule identifier is user-id", + .next = NEXT(next_dump_subcmd), + .call = parse_dump, + }, /* Query arguments. */ [QUERY_ACTION] = { .name = "{action}", @@ -3698,6 +3727,12 @@ static const struct token token_list[] = { .call = parse_action, .comp = comp_action, }, + [QUERY_IS_USER_ID] = { + .name = "user_id", + .help = "rule identifier is user-id", + .next = NEXT(next_query_attr), + .call = parse_query, + }, /* List arguments. */ [LIST_GROUP] = { .name = "group", @@ -3759,6 +3794,13 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)), .call = parse_vc, }, + [VC_USER_ID] = { + .name = "user_id", + .help = "specify a user id to create", + .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.user_id)), + .call = parse_vc, + }, /* Validate/create pattern. */ [ITEM_PATTERN] = { .name = "pattern", @@ -7415,11 +7457,15 @@ parse_vc(struct context *ctx, const struct token *token, case VC_TUNNEL_MATCH: ctx->object = &out->args.vc.tunnel_ops; break; + case VC_USER_ID: + ctx->object = out; + break; } ctx->objmask = NULL; switch (ctx->curr) { case VC_GROUP: case VC_PRIORITY: + case VC_USER_ID: return len; case VC_TUNNEL_SET: out->args.vc.tunnel_ops.enabled = 1; @@ -9109,6 +9155,10 @@ parse_destroy(struct context *ctx, const struct token *token, sizeof(double)); return len; } + if (ctx->curr == DESTROY_IS_USER_ID) { + out->args.destroy.is_user_id = true; + return len; + } if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) + sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size) return -1; @@ -9179,6 +9229,9 @@ parse_dump(struct context *ctx, const struct token *token, ctx->object = out; ctx->objmask = NULL; return len; + case DUMP_IS_USER_ID: + out->args.dump.is_user_id = true; + return len; default: return -1; } @@ -9208,6 +9261,10 @@ parse_query(struct context *ctx, const struct token *token, ctx->object = out; ctx->objmask = NULL; } + if (ctx->curr == QUERY_IS_USER_ID) { + out->args.query.is_user_id = true; + return len; + } return len; } @@ -11602,11 +11659,12 @@ cmd_flow_parsed(const struct buffer *in) case CREATE: port_flow_create(in->port, &in->args.vc.attr, in->args.vc.pattern, in->args.vc.actions, - &in->args.vc.tunnel_ops); + &in->args.vc.tunnel_ops, in->args.vc.user_id); break; case DESTROY: port_flow_destroy(in->port, in->args.destroy.rule_n, - in->args.destroy.rule); + in->args.destroy.rule, + in->args.destroy.is_user_id); break; case FLUSH: port_flow_flush(in->port); @@ -11614,11 +11672,13 @@ cmd_flow_parsed(const struct buffer *in) case DUMP_ONE: case DUMP_ALL: port_flow_dump(in->port, in->args.dump.mode, - in->args.dump.rule, in->args.dump.file); + in->args.dump.rule, in->args.dump.file, + in->args.dump.is_user_id); break; case QUERY: port_flow_query(in->port, in->args.query.rule, - &in->args.query.action); + &in->args.query.action, + in->args.query.is_user_id); break; case LIST: port_flow_list(in->port, in->args.list.group_n, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 804af98c0e..c3aaeaed6b 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -3305,7 +3305,8 @@ port_flow_create(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, const struct rte_flow_action *actions, - const struct tunnel_ops *tunnel_ops) + const struct tunnel_ops *tunnel_ops, + uintptr_t user_id) { struct rte_flow *flow; struct rte_port *port; @@ -3353,17 +3354,23 @@ port_flow_create(portid_t port_id, } pf->next = port->flow_list; pf->id = id; + pf->user_id = user_id; pf->flow = flow; port->flow_list = pf; if (tunnel_ops->enabled) port_flow_tunnel_offload_cmd_release(port_id, tunnel_ops, pft); - printf("Flow rule #%"PRIu64" created\n", pf->id); + if (user_id) + printf("Flow rule #%"PRIu64" created, user-id 0x%"PRIx64"\n", + pf->id, pf->user_id); + else + printf("Flow rule #%"PRIu64" created\n", pf->id); return 0; } /** Destroy a number of flow rules. */ int -port_flow_destroy(portid_t port_id, uint32_t n, const uint64_t *rule) +port_flow_destroy(portid_t port_id, uint32_t n, const uint64_t *rule, + bool is_user_id) { struct rte_port *port; struct port_flow **tmp; @@ -3381,7 +3388,7 @@ port_flow_destroy(portid_t port_id, uint32_t n, const uint64_t *rule) struct rte_flow_error error; struct port_flow *pf = *tmp; - if (rule[i] != pf->id) + if (rule[i] != (is_user_id ? pf->user_id : pf->id)) continue; /* * Poisoning to make sure PMDs update it in case @@ -3392,7 +3399,13 @@ port_flow_destroy(portid_t port_id, uint32_t n, const uint64_t *rule) ret = port_flow_complain(&error); continue; } - printf("Flow rule #%"PRIu64" destroyed\n", pf->id); + if (is_user_id) + printf("Flow rule #%"PRIu64" destroyed, " + "user-id 0x%"PRIx64"\n", + pf->id, pf->user_id); + else + printf("Flow rule #%"PRIu64" destroyed\n", + pf->id); *tmp = pf->next; free(pf); break; @@ -3438,7 +3451,7 @@ port_flow_flush(portid_t port_id) /** Dump flow rules. */ int port_flow_dump(portid_t port_id, bool dump_all, uint64_t rule_id, - const char *file_name) + const char *file_name, bool is_user_id) { int ret = 0; FILE *file = stdout; @@ -3456,7 +3469,8 @@ port_flow_dump(portid_t port_id, bool dump_all, uint64_t rule_id, port = &ports[port_id]; pflow = port->flow_list; while (pflow) { - if (rule_id != pflow->id) { + if (rule_id != + (is_user_id ? pflow->user_id : pflow->id)) { pflow = pflow->next; } else { tmpFlow = pflow->flow; @@ -3498,7 +3512,7 @@ port_flow_dump(portid_t port_id, bool dump_all, uint64_t rule_id, /** Query a flow rule. */ int port_flow_query(portid_t port_id, uint64_t rule, - const struct rte_flow_action *action) + const struct rte_flow_action *action, bool is_user_id) { struct rte_flow_error error; struct rte_port *port; @@ -3516,7 +3530,7 @@ port_flow_query(portid_t port_id, uint64_t rule, return -EINVAL; port = &ports[port_id]; for (pf = port->flow_list; pf; pf = pf->next) - if (pf->id == rule) + if ((is_user_id ? pf->user_id : pf->id) == rule) break; if (!pf) { fprintf(stderr, "Flow rule #%"PRIu64" not found\n", rule); @@ -3636,7 +3650,7 @@ port_flow_aged(portid_t port_id, uint8_t destroy) ctx.pf->rule.attr->egress ? 'e' : '-', ctx.pf->rule.attr->transfer ? 't' : '-'); if (destroy && !port_flow_destroy(port_id, 1, - &ctx.pf->id)) + &ctx.pf->id, false)) total++; break; case ACTION_AGE_CONTEXT_TYPE_INDIRECT_ACTION: diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index c2b0a0a48b..454f2b0c50 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -217,6 +217,7 @@ struct port_flow { struct port_flow *next; /**< Next flow in list. */ struct port_flow *tmp; /**< Temporary linking. */ uint64_t id; /**< Flow rule ID. */ + uint64_t user_id; /**< User rule ID. */ struct rte_flow *flow; /**< Opaque flow object returned by PMD. */ struct rte_flow_conv_rule rule; /**< Saved flow rule description. */ enum age_action_context_type age_type; /**< Age action context type. */ @@ -997,17 +998,20 @@ int port_flow_create(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, const struct rte_flow_action *actions, - const struct tunnel_ops *tunnel_ops); + const struct tunnel_ops *tunnel_ops, + uintptr_t user_id); int port_action_handle_query(portid_t port_id, uint32_t id); void update_age_action_context(const struct rte_flow_action *actions, struct port_flow *pf); int mcast_addr_pool_destroy(portid_t port_id); -int port_flow_destroy(portid_t port_id, uint32_t n, const uint64_t *rule); +int port_flow_destroy(portid_t port_id, uint32_t n, const uint64_t *rule, + bool is_user_id); int port_flow_flush(portid_t port_id); int port_flow_dump(portid_t port_id, bool dump_all, - uint64_t rule, const char *file_name); + uint64_t rule, const char *file_name, + bool is_user_id); int port_flow_query(portid_t port_id, uint64_t rule, - const struct rte_flow_action *action); + const struct rte_flow_action *action, bool is_user_id); void port_flow_list(portid_t port_id, uint32_t n, const uint32_t *group); void port_flow_aged(portid_t port_id, uint8_t destroy); const char *port_flow_tunnel_type(struct rte_flow_tunnel *tunnel); diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 8f23847859..1b2991d94a 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3009,13 +3009,14 @@ following sections. - Create a flow rule:: flow create {port_id} - [group {group_id}] [priority {level}] [ingress] [egress] [transfer] - pattern {item} [/ {item} [...]] / end + [group {group_id}] [priority {level}] [ingress] [egress] + [transfer] [tunnel_set {tunnel_id}] [tunnel_match {tunnel_id}] + [user_id {user_id}] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end - Destroy specific flow rules:: - flow destroy {port_id} rule {rule_id} [...] + flow destroy {port_id} rule {rule_id} [...] [user_id] - Destroy all flow rules:: @@ -3023,7 +3024,7 @@ following sections. - Query an existing flow rule:: - flow query {port_id} {rule_id} {action} + flow query {port_id} {rule_id} {action} [user_id] - List existing flow rules sorted by priority, filtered by group identifiers:: @@ -3036,11 +3037,11 @@ following sections. - Dump internal representation information of all flows in hardware:: - flow dump {port_id} all {output_file} + flow dump {port_id} all {output_file} [user_id] for one flow:: - flow dump {port_id} rule {rule_id} {output_file} + flow dump {port_id} rule {rule_id} {output_file} [user_id] - List and destroy aged flow rules:: @@ -3339,12 +3340,14 @@ to ``rte_flow_create()``:: flow create {port_id} [group {group_id}] [priority {level}] [ingress] [egress] [transfer] [tunnel_set {tunnel_id}] [tunnel_match {tunnel_id}] - pattern {item} [/ {item} [...]] / end + [user_id {user_id}] pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end If successful, it will return a flow rule ID usable with other commands:: Flow rule #[...] created + Or if user_id is provided: + Flow rule #[...] created, user-id [...] Otherwise it will show an error message of the form:: @@ -3354,6 +3357,7 @@ Parameters describe in the following order: - Attributes (*group*, *priority*, *ingress*, *egress*, *transfer* tokens). - Tunnel offload specification (tunnel_set, tunnel_match) +- User identifier for the flow. - A matching pattern, starting with the *pattern* token and terminated by an *end* pattern item. - Actions, starting with the *actions* token and terminated by an *end* @@ -4077,12 +4081,16 @@ Destroying flow rules by ``flow create``), this command calls ``rte_flow_destroy()`` as many times as necessary:: - flow destroy {port_id} rule {rule_id} [...] + flow destroy {port_id} rule {rule_id} [...] [user_id] If successful, it will show:: Flow rule #[...] destroyed + Or if user_id flag is provided: + Flow rule #[...] destroyed, user-id [...] +Optional [user_id] is a flag that signifies the "rule" ID is the one +provided by the user at creation. It does not report anything for rule IDs that do not exist. The usual error message is shown when a rule cannot be destroyed:: @@ -4161,8 +4169,10 @@ Querying flow rules ability. Such actions collect information that can be reported using this command. It is bound to ``rte_flow_query()``:: - flow query {port_id} {rule_id} {action} + flow query {port_id} {rule_id} {action} [user_id] +Optional [user_id] is a flag that signifies the "rule" ID is the one +provided by the user at creation. If successful, it will display either the retrieved data for known actions or the following message:: @@ -4313,7 +4323,7 @@ Dumping HW internal information ``flow dump`` dumps the hardware's internal representation information of all flows. It is bound to ``rte_flow_dev_dump()``:: - flow dump {port_id} {output_file} + flow dump {port_id} {output_file} [user_id] If successful, it will show:: @@ -4323,6 +4333,9 @@ Otherwise, it will complain error occurred:: Caught error type [...] ([...]): [...] +Optional [user_id] is a flag that signifies the "rule" ID is the one +provided by the user at creation. + Listing and destroying aged flow rules ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- 2.25.1