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 73374A0350; Sat, 12 Feb 2022 05:20:44 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1AF9C411ED; Sat, 12 Feb 2022 05:20:27 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2058.outbound.protection.outlook.com [40.107.244.58]) by mails.dpdk.org (Postfix) with ESMTP id BD893411E6 for ; Sat, 12 Feb 2022 05:20:25 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SjVSR73oXGsSNSLqhVLpzqiDsMR2eOSs+Nk3Gn96sXozvXLxrjTfxgl7VWYM/HqjmQCN2PUzsYI3priYCPV5aBp60mPD26uDAI2RYBxdAZs81c3g/yB5fAWBHXUNRoucC19Avbsry/AfZaDYun7oqAJ4us5EFQ+hA5RUIayOLVN5QMPIaE4dA9aC53C6Txh3ElfaJREk7WoZckALvNiY8Mh6TAlZBUJxOOiLVdfiQ7EDFgMCY75ITDawmjiKoWv/fS1THbTkR1eJF2BK74r0YFcEIhSD06V9JQXKEmhGdmLXAaEW2hP8phD0zebag/RQo69zutD4j3HizRUNOA3dgw== 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=9X4ddDdNVkp7d17MLV1otDtJswJWapzTPGC1J2CYsIk=; b=ZwPMld+fw9iKAnQeioyW/11pc7PwhjiUlir+sHK9Z5TT2x+LKAv+Kp1GfozIvt4kI6CHX7p8wKq6xMb88Wq8XIqhFPcOZfJVi35ciTEqdGSE8UW0/keRiNWGElo6TIe+QkVS1r3XHkUI+al7gef0Kqr/LHa+smXxIxqEhv0ayZHsOYm8e5DZlQNcu0awnMXgeorlJB1t3zORGYV2UngiY5QCbjmL2D+P8/8a2XPRLkPoA3oBJrB81yz5SPNKrnWs6ruy6BrBJOieU99RtJdnEkB8jhOoyHV6r29MiYFR9gAb5lpDTznS/o6cB4S7Oh0QiT/daVtju1vm55YuqRf/1w== 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=9X4ddDdNVkp7d17MLV1otDtJswJWapzTPGC1J2CYsIk=; b=luoLnNmaMpRP+RLfwKLP+yj5fkbGzD99KVfkHVllng8aMlMpSB9T6M6v6bJS/2vx0GTi2XdMvHVwQgtKeb+1E0PUc4RqvsY3kShtkFXmhHXi21in6b8vbwAtEVjDeiMTVujVK5nNKSTux4hZ5JMN9oDvzPBZ+4s4U7geWc57w5XrThyI6YoFzCrn4kOCALeH3m6RO9sD6kY7P1oMZUd/rJHD9Jbo7u/L4Y8AZ1wZ7BrqtYSiaWSRCf89TavWn04rHtYNliShu3qEtLXaOlOs6jClMXGFJ0UFw2+i54aat5EJUhXOhKbiojlXQKQGFsfg5oEILuLc9sI9DhtbfHr5RA== Received: from DM5PR12MB1737.namprd12.prod.outlook.com (2603:10b6:3:10e::15) by BN8PR12MB3012.namprd12.prod.outlook.com (2603:10b6:408:64::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Sat, 12 Feb 2022 04:20:23 +0000 Received: from DS7PR03CA0157.namprd03.prod.outlook.com (2603:10b6:5:3b2::12) by DM5PR12MB1737.namprd12.prod.outlook.com (2603:10b6:3:10e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Sat, 12 Feb 2022 04:20:21 +0000 Received: from DM6NAM11FT060.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b2:cafe::d4) by DS7PR03CA0157.outlook.office365.com (2603:10b6:5:3b2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.13 via Frontend Transport; Sat, 12 Feb 2022 04:20: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 DM6NAM11FT060.mail.protection.outlook.com (10.13.173.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Sat, 12 Feb 2022 04:20: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; Sat, 12 Feb 2022 04:20:20 +0000 Received: from pegasus01.mtr.labs.mlnx (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_GCM_SHA384) id 15.2.986.9; Fri, 11 Feb 2022 20:20:17 -0800 From: Alexander Kozyrev To: CC: , , , , , , , , , Subject: [PATCH v6 09/10] app/testpmd: add flow queue pull operation Date: Sat, 12 Feb 2022 06:19:29 +0200 Message-ID: <20220212041930.1516767-10-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220212041930.1516767-1-akozyrev@nvidia.com> References: <20220211022653.1372318-1-akozyrev@nvidia.com> <20220212041930.1516767-1-akozyrev@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 47b045c5-8981-4f2e-c182-08d9eddefbc3 X-MS-TrafficTypeDiagnostic: DM5PR12MB1737:EE_|BN8PR12MB3012:EE_ X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H5kftnMOh0vcc+GNj2O29wy4pZsnBoW7DkBOoE6l+YMnegYGdTin69uwX0OIZlxHA8xMJ8O9kHwhWmHIjVg8R8j3aAI+iUefCkRFatNrT1sY1tce4Us6t7sGBvty1vTFPh9S4W4Byo6S66jTMhxNkmWAKNBlXpbS6nVErm4j/P5QxgkoCCVqsPeZ7nSXgEMbw865sBcD5YdNNWd+btYq9SWPcILz3TTu4eCABSpvDnjVwTT6eHvR/h19PdnhE5Z9INR3tvPVAWDovLpOeeGtfg50gEkr7dI8t2xnb+0cucJy9MmHTAoOXxx353qReby22s4K/uA467yH//8iHiNvxUmIaXksfccNWdUmTyKMc6bd49M6r1XlxpVX/rY2ykSPhkHP6VNDlgcZgXbYEhDM/k4XQRitBxFlnqxUXv8CTq6A9sUGtczP9cjQnHQ6ZAEFbHP0iW0p6hueAOHJ5Ja5Z7ML4I/dlsu9UWgiduTlEm7tpxcIFYGdQG3ifqA9K+Qii7F10lP7EWw+ZVa/Y19qLGiXH16iGZeSobR8vGqjUdK+LBKLA8KIr9Sdmnc5IPsfchgGOUawTG3Ed/p2zekihW6dsUHo9naWz/sWIZhXHKJuqK3iugQHxrcozEfZ0S94OIIa32Wp6fUsSTk3Cv2QxmZPi2DmNT+EKg8ltHWKwDuvFMzytd1fSNrCciz5RDkqhbxNJtfIaTbRO6JC3PrVAA== 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:(13230001)(4636009)(36840700001)(40470700004)(46966006)(16526019)(40460700003)(1076003)(26005)(83380400001)(186003)(36756003)(2616005)(336012)(426003)(36860700001)(508600001)(2906002)(70206006)(7416002)(5660300002)(82310400004)(86362001)(8676002)(81166007)(356005)(4326008)(54906003)(70586007)(6666004)(47076005)(6916009)(8936002)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2022 04:20:21.0506 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 47b045c5-8981-4f2e-c182-08d9eddefbc3 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: DM6NAM11FT060.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3012 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_pull API. Provide the command line interface for pulling operations results. Usage example: flow pull 0 queue 0 Signed-off-by: Alexander Kozyrev Acked-by: Ori Kam --- app/test-pmd/cmdline_flow.c | 56 +++++++++++++++- app/test-pmd/config.c | 74 +++++++++++++-------- app/test-pmd/testpmd.h | 1 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 25 +++++++ 4 files changed, 127 insertions(+), 29 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 62eca1271f..5aeb2d1dce 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -95,6 +95,7 @@ enum index { FLEX, QUEUE, PUSH, + PULL, /* Flex arguments */ FLEX_ITEM_INIT, @@ -136,6 +137,9 @@ enum index { /* Push arguments. */ PUSH_QUEUE, + /* Pull arguments. */ + PULL_QUEUE, + /* Table arguments. */ TABLE_CREATE, TABLE_DESTROY, @@ -2166,6 +2170,9 @@ static int parse_qo_destroy(struct context *, const struct token *, static int parse_push(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); +static int parse_pull(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); @@ -2445,7 +2452,8 @@ static const struct token token_list[] = { TUNNEL, FLEX, QUEUE, - PUSH)), + PUSH, + PULL)), .call = parse_init, }, /* Top-level command. */ @@ -2805,6 +2813,21 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, queue)), }, /* Top-level command. */ + [PULL] = { + .name = "pull", + .help = "pull flow operations results", + .next = NEXT(NEXT_ENTRY(PULL_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_pull, + }, + /* Sub-level commands. */ + [PULL_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} [...]]", @@ -8464,6 +8487,34 @@ parse_push(struct context *ctx, const struct token *token, return len; } +/** Parse tokens for pull command. */ +static int +parse_pull(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 != PULL) + 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, @@ -9838,6 +9889,9 @@ cmd_flow_parsed(const struct buffer *in) case PUSH: port_queue_flow_push(in->port, in->queue); break; + case PULL: + port_queue_flow_pull(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 05cb7cbe83..e49b171086 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2468,14 +2468,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 = { .postpone = postpone }; - 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 = { RTE_FLOW_ERROR_TYPE_NONE, NULL, NULL }; struct rte_flow_action_age *age = age_action_get(actions); @@ -2538,16 +2536,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_pull(port_id, queue_id, &comp, 1, &error); - if (ret < 0) { - printf("Failed to pull queue\n"); - return -EINVAL; - } - } - pf->next = port->flow_list; pf->id = id; pf->flow = flow; @@ -2562,7 +2550,6 @@ port_queue_flow_destroy(portid_t port_id, queueid_t queue_id, bool postpone, uint32_t n, const uint32_t *rule) { struct rte_flow_q_ops_attr op_attr = { .postpone = postpone }; - struct rte_flow_q_op_res comp = { 0 }; struct rte_port *port; struct port_flow **tmp; uint32_t c = 0; @@ -2598,21 +2585,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_pull(port_id, queue_id, - &comp, 1, &error); - if (ret < 0) { - printf("Failed to pull queue\n"); - return -EINVAL; - } - } - printf("Flow rule #%u destruction enqueued\n", pf->id); *tmp = pf->next; free(pf); @@ -2653,6 +2625,52 @@ port_queue_flow_push(portid_t port_id, queueid_t queue_id) return ret; } +/** Pull queue operation results from the queue. */ +int +port_queue_flow_pull(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 = calloc(port->queue_sz, sizeof(struct rte_flow_q_op_res)); + if (!res) { + printf("Failed to allocate memory for pulled results\n"); + return -ENOMEM; + } + + memset(&error, 0x66, sizeof(error)); + ret = rte_flow_q_pull(port_id, queue_id, res, + port->queue_sz, &error); + if (ret < 0) { + printf("Failed to pull a operation results\n"); + free(res); + return -EINVAL; + } + + for (i = 0; i < ret; i++) { + if (res[i].status == RTE_FLOW_Q_OP_SUCCESS) + success++; + } + printf("Queue #%u pulled %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 03f135ff46..6fe829edab 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -940,6 +940,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 postpone, uint32_t n, const uint32_t *rule); int port_queue_flow_push(portid_t port_id, queueid_t queue_id); +int port_queue_flow_pull(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 bcd8fd43b5..81d1b464b3 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3400,6 +3400,10 @@ following sections. flow push {port_id} queue {queue_id} +- Pull all operations results from a queue:: + + flow pull {port_id} queue {queue_id} + - Create a flow rule:: flow create {port_id} @@ -3633,6 +3637,23 @@ The usual error message is shown when operations cannot be pushed:: Caught error type [...] ([...]): [...] +Pulling flow operations results +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``flow pull`` 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_pull()``:: + + flow pull {port_id} queue {queue_id} + +If successful, it will show:: + + Queue #[...] pulled #[...] operations (#[...] failed, #[...] succeeded) + +The usual error message is shown when operations results cannot be pulled:: + + Caught error type [...] ([...]): [...] + Creating a tunnel stub for offload ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -3763,6 +3784,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 pull`` must be called to retrieve the operation status. + Attributes ^^^^^^^^^^ @@ -4497,6 +4520,8 @@ message is shown when a rule cannot be destroyed:: Caught error type [...] ([...]): [...] +``flow queue pull`` must be called to retrieve the operation status. + Querying flow rules ~~~~~~~~~~~~~~~~~~~ -- 2.18.2