From patchwork Tue Jan 18 15:36:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 106039 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 B8D8FA034C; Tue, 18 Jan 2022 16:36:59 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A445C42735; Tue, 18 Jan 2022 16:36:59 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2085.outbound.protection.outlook.com [40.107.236.85]) by mails.dpdk.org (Postfix) with ESMTP id CD5B94068E for ; Tue, 18 Jan 2022 16:36:57 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QzR9njrDt8wC/HlWuQWpIEcqsSZtKXfSWB6ljhT3czglFY/0mYcpWrRWwOzxQPtWWl8/T7n+BMmPt8BeMc/vmrO327T6fjaEpQnnrdeV1E1J5Vap2VWHS/lb1bDB9XReXM4hx7XWl6eNyIrQ/OONQSlLOPvZCBh8cucvQjUV1oT8J0kdffoKClEWi0KRXcn7JdI+aKxd+7aruhdN5dDVHBfhex5BvyglnbfGQulq5gouFsz3BJGSRTBLRcGyEB1CUVqO6aBnb3mM4CN8k/8jX3QjPPeb5TVzzLMVP+6WLT/sQpR/8AmtJK1cfmBWDEIqW7yNSRztu4e2QKSzr5ItUg== 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=cD3E/kdYjOrAa8aSzNPyGfJpZo0tSIUwSiBwJLwaJbabIOJZTUUjkDDO5jv849aUXqvhSTog/8H0dMY9eu5kZUtuWqMQ9Bm191wpj71aNc/2jCHgiaCAoWE5D8HFmkDGaAGcJHNsMj1tVaph28uZ/3zgpW6vje+8QRh4CRZzcEmmFZR9XSxK4xpHnUQXPXxoIlwSNdmRYYYeqHP5xNVvq8opvk40nk4lUTEhwpBM/v2qLhCrjk4iqyvuoYvgupTMYr8RZZ+KnzVLqs7rd7hXXLQzcQxlZcHOrSBS0q089dQGSAiBh++NnweyT4a10WsjDAH9W43Lf9E/WvdT9RKx3w== 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=APpSiNLncUmbhw9tBMtV6+XsJW3jkI7oQfUYWoTTyd+kJniTMUSriyt7XJXGXX4f0AayN55x5riV+eSBVuZ4pMBceKjS4TM0FoHzMQsYdkFqysRR4eOggJXzV4PrMtVAFsGb2gI9E4LyWVLMGfMqAAlTczApq7T9Y6wg4N+UQFLVL9ueSdOPpdjre8m04IlyAZslykJtU83hCkzXV6zHl0otrpyzXveC3z3BS+PSBD/nFnO6NqoCrcQ3KH9dpbPHlUKllyoB7YvBTgY8inlm2UzDqOgUnaPL00DU07tmw6qb1iSy3jPgI7M++PEBES9USs6TqcieokZAm5P3r12NqA== Received: from PH0PR12MB5497.namprd12.prod.outlook.com (2603:10b6:510:eb::22) by MN2PR12MB3696.namprd12.prod.outlook.com (2603:10b6:208:169::27) 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 15:36:56 +0000 Received: from BN9PR03CA0045.namprd03.prod.outlook.com (2603:10b6:408:fb::20) by PH0PR12MB5497.namprd12.prod.outlook.com (2603:10b6:510:eb::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Tue, 18 Jan 2022 15:36:54 +0000 Received: from BN8NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fb:cafe::96) by BN9PR03CA0045.outlook.office365.com (2603:10b6:408:fb::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7 via Frontend Transport; Tue, 18 Jan 2022 15:36:54 +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 BN8NAM11FT003.mail.protection.outlook.com (10.13.177.90) 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 15:36:54 +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 15:36:53 +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; Tue, 18 Jan 2022 07:36:50 -0800 From: Alexander Kozyrev To: CC: , , , , , , , , Subject: [v2,09/10] app/testpmd: implement rte flow queue dequeue Date: Tue, 18 Jan 2022 17:36:37 +0200 Message-ID: <20220118153637.3947925-1-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220118153027.3947448-1-akozyrev@nvidia.com> References: <20220118153027.3947448-1-akozyrev@nvidia.com> MIME-Version: 1.0 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: 59d30e83-ed67-4460-f55c-08d9da985adf X-MS-TrafficTypeDiagnostic: PH0PR12MB5497:EE_|MN2PR12MB3696: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: a+I8CnHQrOT4gI7aeu19pY95EhjDTkqJkBYGDQ/HpjfCWik5mnw07UBQhNnicf02eZBH1XeYXBjWfJAR6tjTtuR4S3V1pZJYYQIoZgrI3H8Od7wvfuD/7uXEnS7zB23D4LID03SBE8zLdnY3hHSiMLCDW17Blwks9L24LEQcsnrgrMMaLG9LbhzgU1yNeZa4U1jJjfZhAFpRxreLGgE9eCydC9JVw3WXM2THJ0OVXX6hi1ddGh4aszyOmG2hE6RhGGtakOJSQRkTAmLhje65J2bRV5WyGq9/dfj+tyK25stFgWcJLYtIlGwmiKHYd0pppMQbwKBHhyScG2y7p54fiWq7TUS2IVdCHd+9STZXfj3FL6pI4qBOAi0MbcuM2mz70saAAJJdc9sGCDjJXA4c5ZP6WpiBCRghyL1ali1f7J/S0tFgoJWtFL5yCdZHYPUvs1i1+gCJ0hOHI9fmUorrShn6CP8EkoI2l3Gxc9/NS2Cgjp+YJj0IQsz8AvBTVbh0MBVObIHMk11P9aSlxjlKV+mymn8MJoBmnPSzJ1wVg5/TrKSnhdKXMhtmBWlV8lYsZ/f7HK6yrhbTwjtd8LJrC+z0ErHUuQAji8kHxkL5m3B0Spx/GjD7bbGCv1nttrJhjbk1wqwQTtCsqD5rIakCmtQW9eoiIZ3RX2/PS7CaoH7yEryiYomkQaxWS019dkCyvCUDQkMN3CNcIQTWnGK/UysvKHbQWAPQedBK767cm9ndBl9qhVnmqXSui5vLS6z0dni3zdxRShut1jHQiFZVJftZH0W7YyUUlFR0cZlVr0w= 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)(40470700002)(46966006)(36840700001)(8676002)(83380400001)(8936002)(1076003)(356005)(2906002)(4326008)(81166007)(70206006)(36860700001)(5660300002)(6916009)(70586007)(316002)(54906003)(336012)(6666004)(26005)(36756003)(47076005)(6286002)(16526019)(7696005)(86362001)(82310400004)(186003)(508600001)(426003)(2616005)(55016003)(40460700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 15:36:54.2428 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 59d30e83-ed67-4460-f55c-08d9da985adf 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: BN8NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3696 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 ~~~~~~~~~~~~~~~~~~~