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 72448A00C3; Tue, 18 Jan 2022 06:09:38 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E887F426F1; Tue, 18 Jan 2022 06:09:30 +0100 (CET) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2067.outbound.protection.outlook.com [40.107.96.67]) by mails.dpdk.org (Postfix) with ESMTP id 23622426E2 for ; Tue, 18 Jan 2022 06:09:29 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JtUlvrsFRmnkgYRFdXCIdtqyluiYcHbleSECDgXMA2VDTp6KW8PbPbK+no1zFJ8RZ4ZBtAk0tIPWkZ1KQzNRpm1iPgw9W13qpFDV8T0FqqXzWUiDk/GxmhMk3+ll3f8FiPF2559CwteYi71cP9/vs3UNCosGc8YGACBbLtEm2edfIviWy0StdirING0XL428Mz4glgTvAXcPwc70IXEfsYkUMIoWfBo5o8MOwsJ+wi7cr4Pf5LK/V/Uikuc9Ud8v70DXrDDy3+CX5MjWgJI+NFWpoeJXu8HT8RJjvbo05DcOsggLVc2HNWHqruKmv0z0f+iY278pV9q+tJMtz/YI/Q== 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=MbCwJtq/8ubFYUL3cGU7m5AUbPSn8iwvEFjHojPUYWQ=; b=AZasQplfBdNEYtLIup7lJj3m3W9OhgQ/pD8YoiWQ+Gvp4ftOJgQizugwNEvfbREcdBlL8FU4eMa/2LDttqSvujvabAi5So2afbdI8q6pOBCNlS0EuNYR04fo4f54JQq1cfIKHMwAc2exjVALfFiPMu0MpYSMVSpN8Y3+6cK/9Ed3oT4h0ANNdtJvEEjRvjAHhZxOFNzxQVyV0j9+kYdctKkgwbDAJr9Z7ugB/+vptRPVIC3mODxpoXWxI5UUDmQoIUoMq9jt9CgnCPgkIxY6WsFkOpBavWDe0DOHwVfTS+hNrDYiLUk57yhYtzK0dTZsbRZnxNMFbvDJzH+pW9dZGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=intel.com 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=MbCwJtq/8ubFYUL3cGU7m5AUbPSn8iwvEFjHojPUYWQ=; b=pL2wa4nFw+PwwVsMnt9/pnquDL4O72CnQMkFC0bgS/7blyVs67efTguvG1Dva0ljv2x+xg7eqU2U1aIPoJ0F/kUDR0CHmKTHiqngnpjxKzjgAfkdbePQoix4aLcXtt5hPgbb/QKZ7nUv2bqo6+PEQ6JFrTQ+b7sqLmhnpRvvtXRup4MC9Ezm8IdJItbBWwsb9ExejRkNagia8HKto2AWgU0yxyqP0De+RxKGhkoc4NbSHRLCLbw34nJ+f6LV9/cNTJqQ9ABExgKK7HIwCIv8EFixb0pBtWgW549aa/Cbbe5On38MKsRif4XJFiY9mlwiIc0uLZe0MsHC8VyrDXESTg== Received: from PH0PR12MB5418.namprd12.prod.outlook.com (2603:10b6:510:e5::19) by BY5PR12MB4082.namprd12.prod.outlook.com (2603:10b6:a03:212::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.10; Tue, 18 Jan 2022 05:09:27 +0000 Received: from MW4PR03CA0316.namprd03.prod.outlook.com (2603:10b6:303:dd::21) by PH0PR12MB5418.namprd12.prod.outlook.com (2603:10b6:510:e5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.9; Tue, 18 Jan 2022 05:09:26 +0000 Received: from CO1NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dd:cafe::14) by MW4PR03CA0316.outlook.office365.com (2603:10b6:303:dd::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11 via Frontend Transport; Tue, 18 Jan 2022 05:09:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) 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 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.238) by CO1NAM11FT013.mail.protection.outlook.com (10.13.174.227) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4888.9 via Frontend Transport; Tue, 18 Jan 2022 05:09:25 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 18 Jan 2022 05:09:25 +0000 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.986.9; Mon, 17 Jan 2022 21:09:22 -0800 From: Alexander Kozyrev To: CC: , , , , , , , , Subject: [PATCH 09/10] app/testpmd: implement rte flow queue dequeue Date: Tue, 18 Jan 2022 07:08:01 +0200 Message-ID: <20220118050802.3915187-10-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220118050802.3915187-6-akozyrev@nvidia.com> References: <20220118050802.3915187-6-akozyrev@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 57e9a0d8-1cc1-43bc-4b58-08d9da40b2bf X-MS-TrafficTypeDiagnostic: PH0PR12MB5418:EE_|BY5PR12MB4082:EE_ X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr,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: mHefEXX8fIFRGRRp1hzIQAQXY4/sj6mL2Y3L2yNVdHKWRFmbNqrsUCiyChUJJuyr+LLHfMCEoWd9JFCxn3PUp0lcdVh2wMdd2ejpOTUGYfbJ8SsTYSEO4HnOyHL2adpGMWPb68/Pf56f/ezt4DiRXjr0cR5fSXWv5n3xzVlIx0bp2eohoiX7TsZqcUDBzhKVam6vt+1yd31329r9oj53gYY7Q9O5xPxU7vYKMq34s/oFiJZnlKFcFsWPB6YLzzo7E6UOwEDvHYgzXLWuwjPyCd1lzg+N0IgiAyPuq9LOte84vKPHAIRIsVeZvzoLxXZSTzU53V5KXsL13WNMZwWlQcfUmetF+qPa4wU6tTaxSawrm/pmhCoCp2KIEnrD9bz/ljTFd90hfUnNE2Nf/vpX3MYJD/O8sUmROx6SrrGYmo5zvTObXQmvSsAH1Og6rvmyjhOYtpbgQmUJqQJSYlTNf2IBJ9qDc8ICdQN2BXuyJevVukGaAdA1/Co5fTtKJiB4Q+Z5krPmr5MCLTx8Mi/A1Uqfa8KI7xXMYKM3ACCoNkfuMFrVb4S98BVpK3SsYVUoHAkGsHCgYsCZuOWOq9TFXLJE6JcYnou7AIMLPIaSk7C0sEwncCU1uN+6JZ/OFZ9PnPAcACxkEZMblR/ZFQqH1Cx+Z2wTYs29hrOwOj/coR0BoPQ55rw4nd1EI/II5w46lBG5k6GjgvD1MEit5uoUkAcoZcUgAlxKv0kSEBqQGGqrtgTSyhgxXBwdbkQoZQFiS9cqEyHW6gllZ96tUPGEaP587QKdRX2Qt8/4324bEAE= X-Forefront-Antispam-Report: CIP:12.22.5.238; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(4636009)(46966006)(40470700002)(36840700001)(316002)(70586007)(70206006)(6666004)(36756003)(16526019)(2616005)(81166007)(186003)(7696005)(26005)(36860700001)(426003)(336012)(6916009)(55016003)(83380400001)(54906003)(8676002)(356005)(4326008)(82310400004)(8936002)(508600001)(5660300002)(40460700001)(47076005)(1076003)(6286002)(2906002)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 05:09:25.9872 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 57e9a0d8-1cc1-43bc-4b58-08d9da40b2bf X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.238]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4082 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 support for the rte_flow_q_dequeue API. Provide the command line interface for operations dequeue. Usage example: flow dequeue 0 queue 0 Signed-off-by: Alexander Kozyrev --- app/test-pmd/cmdline_flow.c | 54 +++++++++++++++ app/test-pmd/config.c | 74 +++++++++++++-------- app/test-pmd/testpmd.h | 1 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 25 +++++++ 4 files changed, 126 insertions(+), 28 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index e94c01cf75..507eb87984 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -93,6 +93,7 @@ enum index { TUNNEL, FLEX, QUEUE, + DEQUEUE, DRAIN, /* Flex arguments */ @@ -132,6 +133,9 @@ enum index { QUEUE_DESTROY_ID, QUEUE_DESTROY_DRAIN, + /* Dequeue arguments. */ + DEQUEUE_QUEUE, + /* Drain arguments. */ DRAIN_QUEUE, @@ -2159,6 +2163,9 @@ static int parse_qo(struct context *, const struct token *, static int parse_qo_destroy(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); +static int parse_dequeue(struct context *, const struct token *, + const char *, unsigned int, + void *, unsigned int); static int parse_drain(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -2440,6 +2447,7 @@ static const struct token token_list[] = { TUNNEL, FLEX, QUEUE, + DEQUEUE, DRAIN)), .call = parse_init, }, @@ -2775,6 +2783,21 @@ static const struct token token_list[] = { .call = parse_qo_destroy, }, /* Top-level command. */ + [DEQUEUE] = { + .name = "dequeue", + .help = "dequeue flow operations", + .next = NEXT(NEXT_ENTRY(DEQUEUE_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_dequeue, + }, + /* Sub-level commands. */ + [DEQUEUE_QUEUE] = { + .name = "queue", + .help = "specify queue id", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + }, + /* Top-level command. */ [DRAIN] = { .name = "drain", .help = "drain a flow queue", @@ -8408,6 +8431,34 @@ parse_qo_destroy(struct context *ctx, const struct token *token, } } +/** Parse tokens for dequeue command. */ +static int +parse_dequeue(struct context *ctx, const struct token *token, + const char *str, unsigned int len, + void *buf, unsigned int size) +{ + struct buffer *out = buf; + + /* Token name must match. */ + if (parse_default(ctx, token, str, len, NULL, 0) < 0) + return -1; + /* Nothing else to do if there is no buffer. */ + if (!out) + return len; + if (!out->command) { + if (ctx->curr != DEQUEUE) + return -1; + if (sizeof(*out) > size) + return -1; + out->command = ctx->curr; + ctx->objdata = 0; + ctx->object = out; + ctx->objmask = NULL; + out->args.vc.data = (uint8_t *)out + size; + } + return len; +} + /** Parse tokens for drain queue command. */ static int parse_drain(struct context *ctx, const struct token *token, @@ -9800,6 +9851,9 @@ cmd_flow_parsed(const struct buffer *in) in->args.destroy.rule_n, in->args.destroy.rule); break; + case DEQUEUE: + port_queue_flow_dequeue(in->port, in->queue); + break; case DRAIN: port_queue_flow_drain(in->port, in->queue); break; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index c6469dd06f..5d23edf562 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2420,14 +2420,12 @@ port_queue_flow_create(portid_t port_id, queueid_t queue_id, const struct rte_flow_action *actions) { struct rte_flow_q_ops_attr ops_attr = { .drain = drain }; - struct rte_flow_q_op_res comp = { 0 }; struct rte_flow *flow; struct rte_port *port; struct port_flow *pf; struct port_table *pt; uint32_t id = 0; bool found; - int ret = 0; struct rte_flow_error error; struct rte_flow_action_age *age = age_action_get(actions); @@ -2477,16 +2475,6 @@ port_queue_flow_create(portid_t port_id, queueid_t queue_id, return port_flow_complain(&error); } - while (ret == 0) { - /* Poisoning to make sure PMDs update it in case of error. */ - memset(&error, 0x22, sizeof(error)); - ret = rte_flow_q_dequeue(port_id, queue_id, &comp, 1, &error); - if (ret < 0) { - printf("Failed to poll queue\n"); - return -EINVAL; - } - } - pf->next = port->flow_list; pf->id = id; pf->flow = flow; @@ -2501,7 +2489,6 @@ port_queue_flow_destroy(portid_t port_id, queueid_t queue_id, bool drain, uint32_t n, const uint32_t *rule) { struct rte_flow_q_ops_attr op_attr = { .drain = drain }; - struct rte_flow_q_op_res comp = { 0 }; struct rte_port *port; struct port_flow **tmp; uint32_t c = 0; @@ -2537,21 +2524,6 @@ port_queue_flow_destroy(portid_t port_id, queueid_t queue_id, ret = port_flow_complain(&error); continue; } - - while (ret == 0) { - /* - * Poisoning to make sure PMD - * update it in case of error. - */ - memset(&error, 0x44, sizeof(error)); - ret = rte_flow_q_dequeue(port_id, queue_id, - &comp, 1, &error); - if (ret < 0) { - printf("Failed to poll queue\n"); - return -EINVAL; - } - } - printf("Flow rule #%u destruction enqueued\n", pf->id); *tmp = pf->next; free(pf); @@ -2592,6 +2564,52 @@ port_queue_flow_drain(portid_t port_id, queueid_t queue_id) return ret; } +/** Dequeue a queue operation from the queue. */ +int +port_queue_flow_dequeue(portid_t port_id, queueid_t queue_id) +{ + struct rte_port *port; + struct rte_flow_q_op_res *res; + struct rte_flow_error error; + int ret = 0; + int success = 0; + int i; + + if (port_id_is_invalid(port_id, ENABLED_WARN) || + port_id == (portid_t)RTE_PORT_ALL) + return -EINVAL; + port = &ports[port_id]; + + if (queue_id >= port->queue_nb) { + printf("Queue #%u is invalid\n", queue_id); + return -EINVAL; + } + + res = malloc(sizeof(struct rte_flow_q_op_res) * port->queue_sz); + if (!res) { + printf("Failed to allocate memory for dequeue results\n"); + return -ENOMEM; + } + + memset(&error, 0x66, sizeof(error)); + ret = rte_flow_q_dequeue(port_id, queue_id, res, + port->queue_sz, &error); + if (ret < 0) { + printf("Failed to dequeue a queue\n"); + free(res); + return -EINVAL; + } + + for (i = 0; i < ret; i++) { + if (res[i].status == RTE_FLOW_Q_OP_SUCCESS) + success++; + } + printf("Queue #%u dequeued %u operations (%u failed, %u succeeded)\n", + queue_id, ret, ret - success, success); + free(res); + return ret; +} + /** Create flow rule. */ int port_flow_create(portid_t port_id, diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index bf4597e7ba..3cf336dbae 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -935,6 +935,7 @@ int port_queue_flow_create(portid_t port_id, queueid_t queue_id, int port_queue_flow_destroy(portid_t port_id, queueid_t queue_id, bool drain, uint32_t n, const uint32_t *rule); int port_queue_flow_drain(portid_t port_id, queueid_t queue_id); +int port_queue_flow_dequeue(portid_t port_id, queueid_t queue_id); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 2ff4e4aef1..fff4de8f00 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3372,6 +3372,10 @@ following sections. flow drain {port_id} queue {queue_id} +- Dequeue all operations from a queue:: + + flow dequeue {port_id} queue {queue_id} + - Create a flow rule:: flow create {port_id} @@ -3582,6 +3586,23 @@ The usual error message is shown when a queue cannot be drained:: Caught error type [...] ([...]): [...] +Dequeueing flow operations +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``flow dequeue`` asks the underlying device about flow queue operations +results and return all the processed (successfully or not) operations. +It is bound to ``rte_flow_q_dequeue()``:: + + flow dequeue {port_id} queue {queue_id} + +If successful, it will show:: + + Queue #[...] dequeued #[...] operations (#[...] failed, #[...] succeeded) + +The usual error message is shown when a queue cannot be drained:: + + Caught error type [...] ([...]): [...] + Creating a tunnel stub for offload ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -3711,6 +3732,8 @@ Otherwise it will show an error message of the form:: This command uses the same pattern items and actions as ``flow create``, their format is described in `Creating flow rules`_. +``flow queue dequeue`` must be called to retrieve the operation status. + Attributes ^^^^^^^^^^ @@ -4444,6 +4467,8 @@ message is shown when a rule cannot be destroyed:: Caught error type [...] ([...]): [...] +``flow queue dequeue`` must be called to retrieve the operation status. + Querying flow rules ~~~~~~~~~~~~~~~~~~~ -- 2.18.2