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 C6920A00C3; Tue, 18 Jan 2022 06:09:26 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B8D5A426E4; Tue, 18 Jan 2022 06:09:26 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2050.outbound.protection.outlook.com [40.107.236.50]) by mails.dpdk.org (Postfix) with ESMTP id 0697B426E2 for ; Tue, 18 Jan 2022 06:09:25 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UxfQ3pXQGdkvUH0Qreyv3BIbTFMeyrRjntqAleNQf8hrPhwGxohANrf9JDVfS+9FYobrBDRTEkjl+ik8bKP5cebueFBL5GCi9rshdX0N++lC3wN9hyZ+VAvHvPaNV3XVgyASaYV9Yo4rWULVbMREsxTH39ZqmBLOCMkbiuKJw0TWhAtaWWNqS/Az4Qb/OW+lZMTckD4U9Ebb9Gvzd2EoITuSlx29Tm+rooGEnssRTmVjVlAZLNFoXtjbJYwieM0kU+EXMQE8wq+w7hffPpopZDxCNRoZsHPbyn1biC+q/7/cv1FHs84AUirJfpMo49169JsfJq1Uv8duEf/PQwPUvw== 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=WFYJYE0MrAKuURCewd7XT4l+MGQFIk2u24xvOj/T8K0wICylmBdu7UciPTkHk/5uU2eTqVPB2zNsTVjeSTuIjrMH4pxSVvrpVGnnSLCFymJmIKocjzZ72Zt8wzpM4Moyfx2f4Bg08l5xTxCPiDqLEw1WrzWHAMdDZDO4G/RJA1g7AITpUKXctG58MTpLJqj2g7e2hfD673DlJCMqrREYyzttcFSsX0dRFUEAOksWOZvvrA62K0AblK49Y1jeAwDXNRtJHIh6/YMCNBbZWgS7Hb0IQ5JaBZodYFJ79MYdXU4OLTh7zaxQgV1t04mJJmB2R6wv+hDXADseyz11SpWUMw== 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=GSu9/Gr9AiCcWBIKQXQI1dPTIhbXRZgPchuk2iPhFQDK1Q1kkiXIJ52TnGN2N6fycFu64MS6269PBZZW7ykpUKmWR0SapON8I+Xj6yMmLGqZkn1QJ6dax7KPzy2/p43u8OysexWXTZzGmkbymPbeDeLKlSFdbsFp3WpvVtn/O6UpcMbd8Amui+e+8hDMx+Oh0pYYATYv9wBCqy9ieiHk1qaP3czZ3XbMdoo1h0L6iXvca7lTXZOugVRtG5kyxBwkF8Gnf5GsMGM44ZEj7dJZZWghSSoyQTSYhzO5uyijW6Vk6BuEE8aO57n86k11mTpjM87D0fXm+/8MkxaptmQTRA== Received: from CH0PR12MB5138.namprd12.prod.outlook.com (2603:10b6:610:bd::17) by BN6PR1201MB0227.namprd12.prod.outlook.com (2603:10b6:405:4e::7) 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 05:09:23 +0000 Received: from MWHPR14CA0047.namprd14.prod.outlook.com (2603:10b6:300:12b::33) by CH0PR12MB5138.namprd12.prod.outlook.com (2603:10b6:610:bd::17) 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:21 +0000 Received: from CO1NAM11FT067.eop-nam11.prod.protection.outlook.com (2603:10b6:300:12b:cafe::20) by MWHPR14CA0047.outlook.office365.com (2603:10b6:300:12b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.10 via Frontend Transport; Tue, 18 Jan 2022 05:09:21 +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 CO1NAM11FT067.mail.protection.outlook.com (10.13.174.212) 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:21 +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 05:09:20 +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:17 -0800 From: Alexander Kozyrev To: CC: , , , , , , , , Subject: [PATCH 08/10] app/testpmd: implement rte flow queue drain Date: Tue, 18 Jan 2022 07:08:00 +0200 Message-ID: <20220118050802.3915187-9-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: 35edd853-9f8c-4c36-f661-08d9da40afd5 X-MS-TrafficTypeDiagnostic: CH0PR12MB5138:EE_|BN6PR1201MB0227: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: P5V2uq7yk+w6K1Z8sH97lLTlzGypfEZOlBF997Fnw8rMVN3fYcx5bS7ecVcxBQSexO69FJXKqPwZyInJ5SAXWfwhVYPweyqc2byy5fBxF8fxPrkdmRQ2yI/tUGYyp27F3xYsKZugsHCDWxsCE0yXZWhi6AmHc2AxZmCdbF+D1A8Y163AEk+GRAdZbFqHm9Kwi8mbOB+usSGU+f7gXOWkT90YX9C4TZpU6dEbZhBob8mw/XDGXlhNrewh/t5lQ/7SorwXTK6nT4QF7BSAOes3QYCLRBTxuVnV1eIz/bcC2ge71LyKXNWvvpkaPw8oc0423LXPgbp5bbAPweMDzty2Dxn3CThPgVmEXgqcNaw4YEihsYoB0cVzotGMZdnhOBPo2slZVVQbN7fdlzn7jsuLtGyTz7IJcjJIzKxzVG0bffwi/cY+HSTW5xI31tyawvkvnNfgxgL5DmCALdOAbBsxcCnGECrD6UhG9/y0NARb3VgScmIDH49epdPNj4B4D8UyWcq5SeExLWzuF8BWFZxoEtoIghJ1h54onfJ8zSh3GJzoPPyP1MnAimax1d8mbc5349XQNgq58yp8wh/oGuHjTsBw3EXb2WyCkl3ncRMW9mcftc/Qj9fGjYf1WlpyRt3LKo9uOSGeYkFCz5c8blewXNpIeuYcd0xn7/NeriRr29Sv6NODmZgUVbcRuJNHfjP6/8i6T4KUj4smas8r+uFJq6RWdTlRAUJX4NREkBPpdkHGM9gDtxSRSwALpNrmvBFu+oRAoS94pmRFDOlivj4asZSrLYXkX5C+pcNtpbm3wL0= 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)(83380400001)(70206006)(70586007)(36860700001)(8936002)(1076003)(4326008)(6666004)(508600001)(426003)(6286002)(82310400004)(2906002)(5660300002)(7696005)(55016003)(6916009)(81166007)(8676002)(40460700001)(356005)(36756003)(47076005)(2616005)(54906003)(316002)(336012)(86362001)(26005)(186003)(16526019)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 05:09:21.1339 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 35edd853-9f8c-4c36-f661-08d9da40afd5 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: CO1NAM11FT067.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1201MB0227 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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- 2.18.2