From patchwork Tue Jan 18 15:35:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 106038 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 793D2A034C; Tue, 18 Jan 2022 16:36:19 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 62DC84273B; Tue, 18 Jan 2022 16:36:19 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2075.outbound.protection.outlook.com [40.107.93.75]) by mails.dpdk.org (Postfix) with ESMTP id 9FCFA4068E for ; Tue, 18 Jan 2022 16:36:18 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jUkiUlER/MZW4iHkxkwLCCcbjRC9zvAfGuByBRllFlUSErLebeHsG/TZTsHUL1XPxHpzbu0HTllwmWsunx/6qhNCGhq7YVNPvotWBQW62YToDQfBvfsdUeZ6kjQaF03FCfE57+Y7JyIVnqwJNGerrPomsuWcRufW6e++LHMD5mKM5gdfxcIwgAIo08SJoZ0xcYkrbAwOskjAdag/YtoO+6RP8X/4FE2VTOW5wn0t38wZ5xMDxojsWA+l6NP4X0k1z4xL/si62+MaDLmqcN1pawBIEC0/2k4wYk13nmvchPGOMWnJ1DKaGbfgAFncBBXE4qczXw3h0LdQalSwJYLxXQ== 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=y+LSKXYCkmmWKSy3X5QJ7e0bRzJRUbY04qmSXgW7SCA=; b=Jx0B8JfwsVHEHJum98eGSaz5NwBp97JEoRRjpToE8kz8Ovkd64Yul/9V4jDPr5czYtcBWwXeOxLHNW2LIDTffNhGupW2Ae1aauMt23Wx3xXIkQhB5NO8twu9XtoOQojmfM+96qNGPFN/rzEoJezCe/I9ZYJFIOctwYgTkClJerNB5JPd499fPV2IEj77gfS+KYJ+klJFexo9gzREvWHb9vDVzA11z4eObwmQCVigMmYw0KE0m4sYio7hQRJkAqhCHRKOHXfuF5hbOHCC44Z5l4mNcr8rrffVET4/lYX08iVQhp1JoGQOkvg0nJmpomr9bLRuKJFKBaw6Eg747Ep4yA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) 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=y+LSKXYCkmmWKSy3X5QJ7e0bRzJRUbY04qmSXgW7SCA=; b=QrqUX85y/SY0B4s51pcQ7ja698OR+ULovXz3U16XpSgazDy745ES6kZHGxTR6KP4U1uekpvVhy/Y0o9Un5g/nj14CDpN7WmvfpBsRrAKeSEs5oWGWbMTK80SSILU7rQgjzdWUckx0iP10a8CutNHJ3aLcjjoy39uu5njTxvR0aEDLQVvGQSrqE3FflxL0X7LexRR9DpHtpamuT0yRGzjCRDhmcXXvRvp6b1g9VkYETm4ry5uDCAxQ5tv9ywp9bnKaWqBmvXuy6T0EJ8HD9nylA7h625RCHd+66YHcYEP+0WPW6IwRKPsIrRwapvwDzzk43TgoV2Vg3C53YPl7GuQPA== Received: from MWHPR1201MB0078.namprd12.prod.outlook.com (2603:10b6:301:56::20) by CY4PR12MB1128.namprd12.prod.outlook.com (2603:10b6:903:3e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Tue, 18 Jan 2022 15:36:16 +0000 Received: from DM5PR15CA0068.namprd15.prod.outlook.com (2603:10b6:3:ae::30) by MWHPR1201MB0078.namprd12.prod.outlook.com (2603:10b6:301:56::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.12; Tue, 18 Jan 2022 15:36:15 +0000 Received: from DM6NAM11FT021.eop-nam11.prod.protection.outlook.com (2603:10b6:3:ae:cafe::4b) by DM5PR15CA0068.outlook.office365.com (2603:10b6:3:ae::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.12 via Frontend Transport; Tue, 18 Jan 2022 15:36:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) 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.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.235) by DM6NAM11FT021.mail.protection.outlook.com (10.13.173.76) 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:14 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 18 Jan 2022 15:36:14 +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:10 -0800 From: Alexander Kozyrev To: CC: , , , , , , , , Subject: [v2,08/10] app/testpmd: implement rte flow queue drain Date: Tue, 18 Jan 2022 17:35:57 +0200 Message-ID: <20220118153557.3947859-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: cc9c0063-fe8e-4e30-6391-08d9da98434a X-MS-TrafficTypeDiagnostic: MWHPR1201MB0078:EE_|CY4PR12MB1128:EE_ X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H8g1ta4Sw04AVdwZHx3uM3LM70NDluBgrQkdo/UikUj8WB4Q6Ji72nNxcoHq9STLkc1Sf+Por7dKPNvahltZgIXN5YLjiTrbsyrj3MWhr+8YegEynhz69vl7IEMw+BE6fpvgFD5yxE2FU6TX9enNCelvSz4GLDtkpSoQKSSlL6xs6/QenN6FuNbCxRBzkIcKjRJ+KNjnmTUmK7B3Saxs13bw6cDQLiiumTNMXe1Y20G6p4vMGfNodULNyZcLIrkpk747GH/lgp7X4qJtEOipsIaQ+4xcMpGwp++8H+8IRpycJ17grCyEvR5GHd2vjKZ/2N8VbYZV99nmP0TG7oFCQ2sYj2AwBJVMi7F1cmJNd0WOX2lBtZgSAn2q+dP079rx0GnnqP/t5zHhlcp6n9Oprcyu+ioXfhuWA33SecJvUfKOrJmeDfpxCYMf7rtAvYjZo+nCUIhBr8cPQ0ZZwM120NrodvJiKovGTTnMtK65PiHd0UNaakf6stjknQCFh4j9H7ekHF5iYHX+ITYpaki97mwRDzWTMQSTFXNZrjWBncLHyrD9tylEGrUdi6yFi0RsCd+SErdPH1MY7/F2zQSgSSQvV6xmWdyMjbp7nwkRxG5zfvYjA4iuJwFxlaUGEdMi2ofrCGQXSEqLkxEsfmvJX2plMLv45kdL+Yoqf2ef6SspSXK8oGtB4fwIrV7o/YRzfYlXofJdV3soWTx0D2RbOBwj9Y0LiSI3Nu9Ni78tNQZQ+Hyk5+Ta++fWp+tleL43150tGlFWYXUM1Q3GMK/um04lcE4hahqr2/46Of4qx8E= X-Forefront-Antispam-Report: CIP:12.22.5.235; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(4636009)(40470700002)(36840700001)(46966006)(6666004)(8936002)(40460700001)(26005)(16526019)(426003)(1076003)(55016003)(82310400004)(6916009)(36756003)(8676002)(5660300002)(508600001)(4326008)(2616005)(70206006)(70586007)(86362001)(2906002)(6286002)(336012)(81166007)(356005)(83380400001)(54906003)(47076005)(7696005)(316002)(36860700001)(186003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 15:36:14.7374 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc9c0063-fe8e-4e30-6391-08d9da98434a 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.235]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT021.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1128 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_drain API. Provide the command line interface for the queue draining. Usage example: flow queue 0 drain 0 Signed-off-by: Alexander Kozyrev --- app/test-pmd/cmdline_flow.c | 56 ++++++++++++++++++++- app/test-pmd/config.c | 28 +++++++++++ app/test-pmd/testpmd.h | 1 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 21 ++++++++ 4 files changed, 105 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 6a8e6fc683..e94c01cf75 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -93,6 +93,7 @@ enum index { TUNNEL, FLEX, QUEUE, + DRAIN, /* Flex arguments */ FLEX_ITEM_INIT, @@ -131,6 +132,9 @@ enum index { QUEUE_DESTROY_ID, QUEUE_DESTROY_DRAIN, + /* Drain arguments. */ + DRAIN_QUEUE, + /* Table arguments. */ TABLE_CREATE, TABLE_DESTROY, @@ -2155,6 +2159,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_drain(struct context *, const struct token *, + const char *, unsigned int, + void *, unsigned int); static int parse_tunnel(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -2432,7 +2439,8 @@ static const struct token token_list[] = { ISOLATE, TUNNEL, FLEX, - QUEUE)), + QUEUE, + DRAIN)), .call = parse_init, }, /* Top-level command. */ @@ -2767,6 +2775,21 @@ static const struct token token_list[] = { .call = parse_qo_destroy, }, /* Top-level command. */ + [DRAIN] = { + .name = "drain", + .help = "drain a flow queue", + .next = NEXT(NEXT_ENTRY(DRAIN_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_drain, + }, + /* Sub-level commands. */ + [DRAIN_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. */ [INDIRECT_ACTION] = { .name = "indirect_action", .type = "{command} {port_id} [{arg} [...]]", @@ -8385,6 +8408,34 @@ parse_qo_destroy(struct context *ctx, const struct token *token, } } +/** Parse tokens for drain queue command. */ +static int +parse_drain(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 != DRAIN) + 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; +} + static int parse_flex(struct context *ctx, const struct token *token, const char *str, unsigned int len, @@ -9749,6 +9800,9 @@ cmd_flow_parsed(const struct buffer *in) in->args.destroy.rule_n, in->args.destroy.rule); break; + case DRAIN: + port_queue_flow_drain(in->port, in->queue); + break; case INDIRECT_ACTION_CREATE: port_action_handle_create( in->port, in->args.vc.attr.group, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 31164d6bf6..c6469dd06f 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2564,6 +2564,34 @@ port_queue_flow_destroy(portid_t port_id, queueid_t queue_id, return ret; } +/** Drain all the queue operations down the queue. */ +int +port_queue_flow_drain(portid_t port_id, queueid_t queue_id) +{ + struct rte_port *port; + struct rte_flow_error error; + int ret = 0; + + 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; + } + + memset(&error, 0x55, sizeof(error)); + ret = rte_flow_q_drain(port_id, queue_id, &error); + if (ret < 0) { + printf("Failed to drain queue\n"); + return -EINVAL; + } + printf("Queue #%u drained\n", queue_id); + 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 99845b9e2f..bf4597e7ba 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -934,6 +934,7 @@ int port_queue_flow_create(portid_t port_id, queueid_t queue_id, const struct rte_flow_action *actions); 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_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 eb9dff7221..2ff4e4aef1 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3368,6 +3368,10 @@ following sections. flow queue {port_id} destroy {queue_id} [drain {boolean}] rule {rule_id} [...] +- Drain a queue:: + + flow drain {port_id} queue {queue_id} + - Create a flow rule:: flow create {port_id} @@ -3561,6 +3565,23 @@ The usual error message is shown when a table cannot be destroyed:: Caught error type [...] ([...]): [...] +Draining a flow queue +~~~~~~~~~~~~~~~~~~~~~ + +``flow drain`` drains the specific queue to push all the +outstanding queued operations to the underlying device immediately. +It is bound to ``rte_flow_q_drain()``:: + + flow drain {port_id} queue {queue_id} + +If successful, it will show:: + + Queue #[...] drained + +The usual error message is shown when a queue cannot be drained:: + + Caught error type [...] ([...]): [...] + Creating a tunnel stub for offload ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~