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 073B0A00C3; Tue, 18 Jan 2022 06:03:15 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 884F14270B; Tue, 18 Jan 2022 06:02:55 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2082.outbound.protection.outlook.com [40.107.223.82]) by mails.dpdk.org (Postfix) with ESMTP id 5369142701 for ; Tue, 18 Jan 2022 06:02:54 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IQl7OaB4NT8exqUY5E0KC/8nuJfCdgEc6IB2kS+iiKJkf74w82Ic6vJGok9c8LMBz2vs1lBVgPf9zO6UPJRd4LiQXte/aHnK5L3fhxlzxfZH32sJ8kT7Z7AAx9f++ImwQ27/jEvz+J0V5Sn+ol9Jw2EV6dahTkfkwJpY7gXBkS0VjjSddJeMlVOl4+LqtW7B/QbuicV23b7GRxiBud78vH5fZcA1RJ3vaF6WmpYXz37DJ38+2sMiTdk4sT+qwpIJjNpE2eliAdXZxsyIEqOxgTkQpR2qXPWDLi0weKbPY8cwbQ6jluOk2mlX6wNSn3lHKoOTZRXVFwaqWuHtTJ3bSQ== 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=uOH7d1j6yX9kMUyeKIl+eFx8/NCACHWUPGVI3BjFti0=; b=WHjKRZfTkhTFzkBqYMwzNz07g/SDwWZaoIaa2VE0V0WOMUj9m4zYKLSgcmZKef0qnJazBjy+oQaSZkzAG5acVkKnUIXAD5zPNmsWo8o3ThWnYTbUkd7bVIFGBvmhndXtc/01X5tXCYN2tmmakXqxx5y5UQ6n50A9LpppWh5/tXz6Feo/4VFpgQC8Ny8Dr0J3N4WxM4bTmmfSAPjvjOPlYrb31mYi+GGqBmUN3cECdURh54rU1gIajHhhzsHbk/aCshVS34jcJREgXb1Uy04ULXBw+/P9kTPg7uV4nKDgxa10stnkkS3Ma+G6v6juPZlEXifUAzhwtAymJbgp6g2udA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) 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=uOH7d1j6yX9kMUyeKIl+eFx8/NCACHWUPGVI3BjFti0=; b=gNtPPr8YMvXrkHd0KBCKi+0VCtKcNNO7mmhPVQekUHoBwhCYulM2r7CMxOUQjoNpA6nSxdK/nwO+bQWqZB/seCpnp3CktrmxNloJsRw0b+kuO+Nuhl7bYH3IBmedLc9o/4Pi5QENsec8atwjAXsL9DQWByXHD1CmtMjpeFNn8p/uf7wFDNWCvc+f0oGNS6UT269INZ5OUWl3Ga0YyKn3dv7SzoMGuZ0pZSSKQeewCg0Tug4r8TM1lTO6OG0gikBOrFFmUDJrujgHRbcJGlWI7w4yrVDV6uVQMS1pYbM3XUdgLTh+gQdTuom9XS+qSuZPLILXrGvgWrVJGYQkorzJJg== Received: from CH2PR12MB4940.namprd12.prod.outlook.com (2603:10b6:610:65::10) by DM5PR12MB1369.namprd12.prod.outlook.com (2603:10b6:3:6f::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:02:52 +0000 Received: from DM5PR21CA0015.namprd21.prod.outlook.com (2603:10b6:3:ac::25) by CH2PR12MB4940.namprd12.prod.outlook.com (2603:10b6:610:65::10) 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:02:51 +0000 Received: from DM6NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:3:ac:cafe::b2) by DM5PR21CA0015.outlook.office365.com (2603:10b6:3:ac::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.3 via Frontend Transport; Tue, 18 Jan 2022 05:02:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) 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.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by DM6NAM11FT058.mail.protection.outlook.com (10.13.172.216) 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:02:51 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 18 Jan 2022 05:02:50 +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:02:47 -0800 From: Alexander Kozyrev To: CC: , , , , , , , , Subject: [PATCH 04/10] app/testpmd: implement rte flow configure Date: Tue, 18 Jan 2022 07:02:15 +0200 Message-ID: <20220118050221.3914960-5-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220118050221.3914960-1-akozyrev@nvidia.com> References: <20220118050221.3914960-1-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: 5e7cf78b-c4b5-4666-01b7-08d9da3fc79b X-MS-TrafficTypeDiagnostic: CH2PR12MB4940:EE_|DM5PR12MB1369:EE_ X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HQqgMh9nDceO4Al1/UB0p55mHnE+979Y8N8G5R3LWOfVHJTWSONC/iN6IpLoKwPwiA2hLK6tjjoshBiuL1pntkCjbu1z5+PKuycgy0GRuocQ7sVcvjC58vRNEDpcs5yHZAE27kefDLyntBZqThQQeWiwpKpI7rZGwK4vT+X/w/SD1Uow8EeBSGhd9X3jvgcE6bQVfVAzYrHHnnd2wwUXNe4PifV0kRuxnb44tjTcJOrAIvWB+srrbVsNoe1ECJ28hxZCMswjkH4G2XGn62frtoFHFIp2z5YYBqTEjzsCvy2Fq/UO8d3pMv3qQ0yUuOPzIeDgbQvZl0sw16c0Uu2b7Wv3zbBEkDX7iM8LAuX01i7ksUd85uEXJmr2NOe3IUdN9a7myVoR0sAA2vfyBobK5tiJI2ibkMpqd+E0OWRvoS7RR+/uLBZaoWPUrSjiMmhPcxPVoAQKrTitVi5scs6tK9xBBPl/uP4UrO6CLBGPGTkaP0qHWs7/2H1bQhBiCm9m71smHKzTr3IXauv8SrhPZXztsNQVgrpqxoOhUCHZWXtQglJHFQwCn0zV6ATThM43weqzhs6kuEFOSa/PykYAoW5Of7q6LXa25F2dJJ3+pki8b+wOmX2mmrz6kGwfUxxZ5r/4zfv4MnwMQL89zI3Ml/RtmNr56he58/LgrgiclDIcYwtKhyJ6ZK4ndfFjPDIhEZ6c72yFbbmlLYMiK+Cxjb/sWYmH4GJsYswLxGUntZaVdYctkqkdLciw82ZK8k7jG7HvXiVXpRYO2CBRatYiq3b6uKtRXiscIChlL9cZgpI= X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(4636009)(46966006)(40470700002)(36840700001)(81166007)(2616005)(6666004)(426003)(86362001)(186003)(16526019)(336012)(26005)(356005)(83380400001)(5660300002)(8936002)(36756003)(54906003)(6286002)(36860700001)(6916009)(2906002)(4326008)(47076005)(1076003)(7696005)(508600001)(70586007)(70206006)(316002)(82310400004)(8676002)(55016003)(40460700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 05:02:51.4536 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5e7cf78b-c4b5-4666-01b7-08d9da3fc79b 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.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1369 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_configure API. Provide the command line interface for the Flow management. Usage example: flow configure 0 queues_number 8 queues_size 256 Signed-off-by: Alexander Kozyrev --- app/test-pmd/cmdline_flow.c | 109 +++++++++++++++++++- app/test-pmd/config.c | 29 ++++++ app/test-pmd/testpmd.h | 5 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 34 +++++- 4 files changed, 174 insertions(+), 3 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 5c2bba48ad..ea4af8dd45 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -72,6 +72,7 @@ enum index { /* Top-level command. */ FLOW, /* Sub-level commands. */ + CONFIGURE, INDIRECT_ACTION, VALIDATE, CREATE, @@ -122,6 +123,13 @@ enum index { DUMP_ALL, DUMP_ONE, + /* Configure arguments */ + CONFIG_QUEUES_NUMBER, + CONFIG_QUEUES_SIZE, + CONFIG_COUNTERS_NUMBER, + CONFIG_AGING_COUNTERS_NUMBER, + CONFIG_METERS_NUMBER, + /* Indirect action arguments */ INDIRECT_ACTION_CREATE, INDIRECT_ACTION_UPDATE, @@ -846,6 +854,10 @@ struct buffer { enum index command; /**< Flow command. */ portid_t port; /**< Affected port ID. */ union { + struct { + struct rte_flow_port_attr port_attr; + struct rte_flow_queue_attr queue_attr; + } configure; /**< Configuration arguments. */ struct { uint32_t *action_id; uint32_t action_id_n; @@ -927,6 +939,16 @@ static const enum index next_flex_item[] = { ZERO, }; +static const enum index next_config_attr[] = { + CONFIG_QUEUES_NUMBER, + CONFIG_QUEUES_SIZE, + CONFIG_COUNTERS_NUMBER, + CONFIG_AGING_COUNTERS_NUMBER, + CONFIG_METERS_NUMBER, + END, + ZERO, +}; + static const enum index next_ia_create_attr[] = { INDIRECT_ACTION_CREATE_ID, INDIRECT_ACTION_INGRESS, @@ -1962,6 +1984,9 @@ static int parse_aged(struct context *, const struct token *, static int parse_isolate(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); +static int parse_configure(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); @@ -2187,7 +2212,8 @@ static const struct token token_list[] = { .type = "{command} {port_id} [{arg} [...]]", .help = "manage ingress/egress flow rules", .next = NEXT(NEXT_ENTRY - (INDIRECT_ACTION, + (CONFIGURE, + INDIRECT_ACTION, VALIDATE, CREATE, DESTROY, @@ -2202,6 +2228,56 @@ static const struct token token_list[] = { .call = parse_init, }, /* Top-level command. */ + [CONFIGURE] = { + .name = "configure", + .help = "configure flow rules", + .next = NEXT(next_config_attr, + NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_configure, + }, + /* Configure arguments. */ + [CONFIG_QUEUES_NUMBER] = { + .name = "queues_number", + .help = "number of queues", + .next = NEXT(next_config_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.configure.port_attr.nb_queues)), + }, + [CONFIG_QUEUES_SIZE] = { + .name = "queues_size", + .help = "number of elements in queues", + .next = NEXT(next_config_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.configure.queue_attr.size)), + }, + [CONFIG_COUNTERS_NUMBER] = { + .name = "counters_number", + .help = "number of counters", + .next = NEXT(next_config_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.configure.port_attr.nb_counters)), + }, + [CONFIG_AGING_COUNTERS_NUMBER] = { + .name = "aging_counters_number", + .help = "number of aging counters", + .next = NEXT(next_config_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.configure.port_attr.nb_aging)), + }, + [CONFIG_METERS_NUMBER] = { + .name = "meters_number", + .help = "number of meters", + .next = NEXT(next_config_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.configure.port_attr.nb_meters)), + }, + /* Top-level command. */ [INDIRECT_ACTION] = { .name = "indirect_action", .type = "{command} {port_id} [{arg} [...]]", @@ -7465,6 +7541,33 @@ parse_isolate(struct context *ctx, const struct token *token, return len; } +/** Parse tokens for configure command. */ +static int +parse_configure(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 != CONFIGURE) + return -1; + if (sizeof(*out) > size) + return -1; + out->command = ctx->curr; + ctx->objdata = 0; + ctx->object = out; + ctx->objmask = NULL; + } + return len; +} + static int parse_flex(struct context *ctx, const struct token *token, const char *str, unsigned int len, @@ -8691,6 +8794,10 @@ static void cmd_flow_parsed(const struct buffer *in) { switch (in->command) { + case CONFIGURE: + port_flow_configure(in->port, &in->args.configure.port_attr, + &in->args.configure.queue_attr); + 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 1722d6c8f8..85d31de7f7 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1595,6 +1595,35 @@ action_alloc(portid_t port_id, uint32_t id, return 0; } +/** Configure flow management resources. */ +int +port_flow_configure(portid_t port_id, + const struct rte_flow_port_attr *port_attr, + const struct rte_flow_queue_attr *queue_attr) +{ + struct rte_port *port; + struct rte_flow_error error; + const struct rte_flow_queue_attr *attr_list[port_attr->nb_queues]; + int std_queue; + + if (port_id_is_invalid(port_id, ENABLED_WARN) || + port_id == (portid_t)RTE_PORT_ALL) + return -EINVAL; + port = &ports[port_id]; + port->queue_nb = port_attr->nb_queues; + port->queue_sz = queue_attr->size; + for (std_queue = 0; std_queue < port_attr->nb_queues; std_queue++) + attr_list[std_queue] = queue_attr; + /* Poisoning to make sure PMDs update it in case of error. */ + memset(&error, 0x66, sizeof(error)); + if (rte_flow_configure(port_id, port_attr, attr_list, &error)) + return port_flow_complain(&error); + printf("Configure flows on port %u: " + "number of queues %d with %d elements\n", + port_id, port_attr->nb_queues, queue_attr->size); + return 0; +} + /** Create indirect action */ int port_action_handle_create(portid_t port_id, uint32_t id, diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 9967825044..ce80a00193 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -243,6 +243,8 @@ struct rte_port { struct rte_eth_txconf tx_conf[RTE_MAX_QUEUES_PER_PORT+1]; /**< per queue tx configuration */ struct rte_ether_addr *mc_addr_pool; /**< pool of multicast addrs */ uint32_t mc_addr_nb; /**< nb. of addr. in mc_addr_pool */ + queueid_t queue_nb; /**< nb. of queues for flow rules */ + uint32_t queue_sz; /**< size of a queue for flow rules */ uint8_t slave_flag; /**< bonding slave port */ struct port_flow *flow_list; /**< Associated flows. */ struct port_indirect_action *actions_list; @@ -885,6 +887,9 @@ struct rte_flow_action_handle *port_action_handle_get_by_id(portid_t port_id, uint32_t id); int port_action_handle_update(portid_t port_id, uint32_t id, const struct rte_flow_action *action); +int port_flow_configure(portid_t port_id, + const struct rte_flow_port_attr *port_attr, + const struct rte_flow_queue_attr *queue_attr); 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 94792d88cc..8af28bd3b3 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3285,8 +3285,8 @@ Flow rules management --------------------- Control of the generic flow API (*rte_flow*) is fully exposed through the -``flow`` command (validation, creation, destruction, queries and operation -modes). +``flow`` command (configuration, validation, creation, destruction, queries +and operation modes). Considering *rte_flow* overlaps with all `Filter Functions`_, using both features simultaneously may cause undefined side-effects and is therefore @@ -3309,6 +3309,14 @@ The first parameter stands for the operation mode. Possible operations and their general syntax are described below. They are covered in detail in the following sections. +- Configure flow management:: + + flow configure {port_id} + [queues_number {number}] [queues_size {size}] + [counters_number {number}] + [aging_counters_number {number}] + [meters_number {number}] + - Check whether a flow rule can be created:: flow validate {port_id} @@ -3368,6 +3376,28 @@ following sections. flow tunnel list {port_id} +Configuring flow management library +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``flow configure`` pre-allocates all the needed resources in the underlying +device to be used later at the flow creation. Flow queues are allocated as well +for asynchronous flow creation/destruction operations. It is bound to +``rte_flow_configure()``:: + + flow configure {port_id} + [queues_number {number}] [queues_size {size}] + [counters_number {number}] + [aging_counters_number {number}] + [meters_number {number}] + +If successful, it will show:: + + Configure flows on port #[...]: number of queues #[...] with #[...] elements + +Otherwise it will show an error message of the form:: + + Caught error type [...] ([...]): [...] + Creating a tunnel stub for offload ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- 2.18.2