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 AA47543716; Sun, 17 Dec 2023 10:32:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 248824026C; Sun, 17 Dec 2023 10:32:41 +0100 (CET) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2081.outbound.protection.outlook.com [40.107.95.81]) by mails.dpdk.org (Postfix) with ESMTP id 0F3A640042 for ; Sun, 17 Dec 2023 10:32:39 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=duJuxrokaWl74uorKN6EpwRP806tG0AU6/BwKZ8NAZfwfljKUx9fuy+N9PfsYjksA/TZt90ftBbL2LAwY+VdwkuQLfk/bccg8YzWQxF698A2sY72AT5rFgqPsNu3mjNWB9Q3p64kWbLKJvgOQiSFcQfoVNciyHd/Fvy2uprlfcvL1GZ8Um75b+WLuLASCrD43kRRkeQepUsMrzwRYQljifV4wF6niX0RaTdhZ2tkctIElZGeZrlFJGjE9N3eKYRDKSiBCtnuQUlVH+N5dQcN01OC1ybBeAKF5dvKLtN0yoHIRS8X+kWG+HZBiXzHsWjQoh8B9IGRwDffcTIqRvBbCA== 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=0XWPVIEBSZznoBl95tgqXxZr/PhNBSj4PEeGvi6jOV0=; b=nw6dUOmm+i0byQB0LFmv8T0yhBhK4PcNpP2FrqNQy8+9bjxpb4BZdHcH2zayo69eh5i+88+MZJfbNsaWuEytC1Ku+alF2u8qZB0KXs5P9IYqFVu6HRmW+ehriEKt4rNSWxUzpj3mkTlKYO5iOg9vPmh3Lqn/SJFZX+f3kM2MFxNE4rvB9sC9eQ1H6RagaKETwsZ7AKJ217aYl4i8/pYLaFej3/R3Suo+rt2/qAey0YDPnnTspubqK6vtdE/FYP43Y+CAcflj32U2sFCYS7udPR3I19/+GrGqNbhGdyIlPAVSSBG4NUORYA4bniJkWNbXDTnALWx+KdCA3ib7V0ovXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org 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 (0) 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=0XWPVIEBSZznoBl95tgqXxZr/PhNBSj4PEeGvi6jOV0=; b=ELrm6fBb8k8JVST60g+bXnCHfA0BqmtNQn3pI2m043BY50lPjbonNDjS/6QBeLXN7hpzaB7DqWpqzAHk213X/+X94l0x4Q+wfOyxyFS7BnHVcbe60OG8YXjnrDiOwrKTpXoo6En6LsrFC4cuJlk04VCtxFt9VLwxwvz/UDcGFlMKbztfyXWiOxlTRMm6PFM2cYY+j0YneEJs4CNttmw9DS+tJMcMRJUiaDv8pS4cM7t4m6ln0yg1Jg5CK5joVAZP/R8E9A9zt4tPcTtVt7obEdHHl6cmEK/sVVoLG+agVJYVqoD9KMGznkcyitH4meHqJRYqDxtEAF4m2Rfu26yrBw== Received: from DS7P222CA0029.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::28) by CH3PR12MB7761.namprd12.prod.outlook.com (2603:10b6:610:14e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.37; Sun, 17 Dec 2023 09:32:34 +0000 Received: from CY4PEPF0000EE35.namprd05.prod.outlook.com (2603:10b6:8:2e:cafe::36) by DS7P222CA0029.outlook.office365.com (2603:10b6:8:2e::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.37 via Frontend Transport; Sun, 17 Dec 2023 09:32:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000EE35.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.14 via Frontend Transport; Sun, 17 Dec 2023 09:32:34 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Sun, 17 Dec 2023 01:32:23 -0800 Received: from nvidia.com (10.126.231.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.41; Sun, 17 Dec 2023 01:32:19 -0800 From: Gregory Etelson To: CC: , , Ori Kam , Aman Singh , Yuying Zhang , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Subject: [PATCH] ethdev: add template table resize API Date: Sun, 17 Dec 2023 11:32:04 +0200 Message-ID: <20231217093205.321082-1-getelson@nvidia.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE35:EE_|CH3PR12MB7761:EE_ X-MS-Office365-Filtering-Correlation-Id: 708931de-61b1-4499-9cff-08dbfee319ab X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ni59BUcE1bJhy42tp6JIQJS3aPeVXcv9bzCYtIOSA8Ov3qgw3Tm+xbvZl4zwFxSRkk/yKQtqaAvCMjHpfC5jpEKlIzkURkF2TDjjJx2SxjRtqIh7RPLGWVhKhCguDNUyZFTcA8/Cu2fzbko/0h+3S5dvc2VLUPDsmLRLQ7ktzs4MbowXpk7Xx96Jex/Hcc6XL3hVFPqwnskX5KTDaTP+IFr5KpguqobiCVCttW0Zqs6e+3PFirysEgULEu671K0U2LwcZg5I1uI6KPLJxqMc/RkVMrC6Nf1gINJk6rubI6mbIbLM+Nl4hU5OID5JJvXgfajayaJ79ysvFVg4TbWIbDJKIKFOm37JDB7zljDtO0bJakx6FBXXPhlobLmpLQABpk1IgC1XZh3Zw9kyc5TKy+EaNQt2YinEREVNM0GGippYFWB2SgYWPARH4dPmyYkuC4EngGHsgZH1+m0frdUSKWzgfKNtuERVzr/2cJlwGe9bpDlDcnCeFynoDuzN3Dtoyz/xCDg7aUuuX9pH8TF7Dj5YjxId9r+1krtaaAakdtgYGyfwdueAX3vYsZezF97IAUr7GhCQvhzIXP3AQcmGSpZdyskG8T9QBMaIjCptSfYI0hT+MftgA8wLGMz1U+SNFqR4e44rhZ5dslCcH4GQx8nq8WTEGIQn278dcqNMQXttm1GStAFMGjJewr7FLrkyUedKhexFdHWuM6OWNJ5TtR8mzRt6qW5IVaduI53JnTiO1byu7s60//xacrjW1ohjVO4I7cP4Us0M18AG8otRpboFVTqasWfXQtyaRE9FSwk= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(136003)(39860400002)(376002)(396003)(346002)(230922051799003)(230173577357003)(230273577357003)(64100799003)(186009)(82310400011)(451199024)(1800799012)(46966006)(36840700001)(40470700004)(55016003)(40480700001)(1076003)(426003)(16526019)(336012)(26005)(6286002)(2616005)(40460700003)(82740400003)(356005)(36756003)(86362001)(7636003)(47076005)(83380400001)(5660300002)(30864003)(7696005)(6666004)(36860700001)(8936002)(8676002)(4326008)(70586007)(70206006)(316002)(6916009)(54906003)(41300700001)(2906002)(478600001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2023 09:32:34.3359 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 708931de-61b1-4499-9cff-08dbfee319ab X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE35.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7761 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 Template table creation API sets table flows capacity. If application needs more flows then the table was designed for, the following procedures must be completed: 1. Create a new template table with larger flows capacity. 2. Re-create existing flows in the new table and delete flows from the original table. 3. Destroy original table. Application cannot always execute that procedure: * Port may not have sufficient resources to allocate a new table while maintaining original table. * Application may not have existing flows "recipes" to re-create flows in a new table. The patch defines a new API that allows application to resize existing template table: * Resizable template table must be created with the RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE bit set. * Application resizes existing table with the `rte_flow_template_table_resize()` function call. The table resize procedure updates the table maximal flow number only. Other table attributes are not affected by the table resize. ** The table resize procedure must not interrupt existing table flows operations in hardware. ** The table resize procedure must not alter flow handlers held by application. * After `rte_flow_template_table_resize()` returned, application must update all existing table flow rules by calling `rte_flow_async_update_resized()`. The table resize procedure does not change application flow handler. However, flow object can reference internal PMD resources that are obsolete after table resize. `rte_flow_async_update_resized()` moves internal flow references to the updated table resources. The flow update must not interrupt hardware flow operations. * When all table flow were updated, application must call `rte_flow_template_table_resize_complete()`. The function releases PMD resources related to the original table. Application can start new table resize after `rte_flow_template_table_resize_complete()` returned. Signed-off-by: Gregory Etelson Acked-by: Ori Kam --- app/test-pmd/cmdline_flow.c | 86 +++++++++++++++++++-- app/test-pmd/config.c | 102 +++++++++++++++++++++++++ app/test-pmd/testpmd.h | 6 ++ doc/guides/rel_notes/release_24_03.rst | 2 + lib/ethdev/ethdev_trace.h | 33 ++++++++ lib/ethdev/ethdev_trace_points.c | 9 +++ lib/ethdev/rte_flow.c | 69 +++++++++++++++++ lib/ethdev/rte_flow.h | 97 +++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 15 ++++ lib/ethdev/version.map | 3 + 10 files changed, 417 insertions(+), 5 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index ce71818705..a34757a13e 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -134,6 +134,7 @@ enum index { /* Queue arguments. */ QUEUE_CREATE, QUEUE_DESTROY, + QUEUE_FLOW_UPDATE_RESIZED, QUEUE_UPDATE, QUEUE_AGED, QUEUE_INDIRECT_ACTION, @@ -191,8 +192,12 @@ enum index { /* Table arguments. */ TABLE_CREATE, TABLE_DESTROY, + TABLE_RESIZE, + TABLE_RESIZE_COMPLETE, TABLE_CREATE_ID, TABLE_DESTROY_ID, + TABLE_RESIZE_ID, + TABLE_RESIZE_RULES_NUMBER, TABLE_INSERTION_TYPE, TABLE_INSERTION_TYPE_NAME, TABLE_HASH_FUNC, @@ -204,6 +209,7 @@ enum index { TABLE_TRANSFER, TABLE_TRANSFER_WIRE_ORIG, TABLE_TRANSFER_VPORT_ORIG, + TABLE_RESIZABLE, TABLE_RULES_NUMBER, TABLE_PATTERN_TEMPLATE, TABLE_ACTIONS_TEMPLATE, @@ -1323,6 +1329,8 @@ static const enum index next_group_attr[] = { static const enum index next_table_subcmd[] = { TABLE_CREATE, TABLE_DESTROY, + TABLE_RESIZE, + TABLE_RESIZE_COMPLETE, ZERO, }; @@ -1337,6 +1345,7 @@ static const enum index next_table_attr[] = { TABLE_TRANSFER, TABLE_TRANSFER_WIRE_ORIG, TABLE_TRANSFER_VPORT_ORIG, + TABLE_RESIZABLE, TABLE_RULES_NUMBER, TABLE_PATTERN_TEMPLATE, TABLE_ACTIONS_TEMPLATE, @@ -1353,6 +1362,7 @@ static const enum index next_table_destroy_attr[] = { static const enum index next_queue_subcmd[] = { QUEUE_CREATE, QUEUE_DESTROY, + QUEUE_FLOW_UPDATE_RESIZED, QUEUE_UPDATE, QUEUE_AGED, QUEUE_INDIRECT_ACTION, @@ -3344,6 +3354,19 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, port)), .call = parse_table_destroy, }, + [TABLE_RESIZE] = { + .name = "resize", + .help = "resize template table", + .next = NEXT(NEXT_ENTRY(TABLE_RESIZE_ID)), + .call = parse_table + }, + [TABLE_RESIZE_COMPLETE] = { + .name = "resize_complete", + .help = "complete table resize", + .next = NEXT(NEXT_ENTRY(TABLE_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_table_destroy, + }, /* Table arguments. */ [TABLE_CREATE_ID] = { .name = "table_id", @@ -3354,13 +3377,29 @@ static const struct token token_list[] = { }, [TABLE_DESTROY_ID] = { .name = "table", - .help = "specify table id to destroy", + .help = "table id", .next = NEXT(next_table_destroy_attr, NEXT_ENTRY(COMMON_TABLE_ID)), .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.table_destroy.table_id)), .call = parse_table_destroy, }, + [TABLE_RESIZE_ID] = { + .name = "table_resize_id", + .help = "table resize id", + .next = NEXT(NEXT_ENTRY(TABLE_RESIZE_RULES_NUMBER), + NEXT_ENTRY(COMMON_TABLE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.table.id)), + .call = parse_table + }, + [TABLE_RESIZE_RULES_NUMBER] = { + .name = "table_resize_rules_num", + .help = "table resize rules number", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.nb_flows)), + .call = parse_table + }, [TABLE_INSERTION_TYPE] = { .name = "insertion_type", .help = "specify insertion type", @@ -3433,6 +3472,12 @@ static const struct token token_list[] = { .next = NEXT(next_table_attr), .call = parse_table, }, + [TABLE_RESIZABLE] = { + .name = "resizable", + .help = "set resizable attribute", + .next = NEXT(next_table_attr), + .call = parse_table, + }, [TABLE_RULES_NUMBER] = { .name = "rules_number", .help = "number of rules in table", @@ -3525,6 +3570,14 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, queue)), .call = parse_qo_destroy, }, + [QUEUE_FLOW_UPDATE_RESIZED] = { + .name = "update_resized", + .help = "update a flow after table resize", + .next = NEXT(NEXT_ENTRY(QUEUE_DESTROY_ID), + NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + .call = parse_qo_destroy, + }, [QUEUE_UPDATE] = { .name = "update", .help = "update a flow rule", @@ -10334,6 +10387,7 @@ parse_table(struct context *ctx, const struct token *token, } switch (ctx->curr) { case TABLE_CREATE: + case TABLE_RESIZE: out->command = ctx->curr; ctx->objdata = 0; ctx->object = out; @@ -10378,18 +10432,25 @@ parse_table(struct context *ctx, const struct token *token, case TABLE_TRANSFER_WIRE_ORIG: if (!out->args.table.attr.flow_attr.transfer) return -1; - out->args.table.attr.specialize = RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG; + out->args.table.attr.specialize |= RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG; return len; case TABLE_TRANSFER_VPORT_ORIG: if (!out->args.table.attr.flow_attr.transfer) return -1; - out->args.table.attr.specialize = RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG; + out->args.table.attr.specialize |= RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG; + return len; + case TABLE_RESIZABLE: + out->args.table.attr.specialize |= + RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE; return len; case TABLE_RULES_NUMBER: ctx->objdata = 0; ctx->object = out; ctx->objmask = NULL; return len; + case TABLE_RESIZE_ID: + case TABLE_RESIZE_RULES_NUMBER: + return len; default: return -1; } @@ -10411,7 +10472,8 @@ parse_table_destroy(struct context *ctx, const struct token *token, if (!out) return len; if (!out->command || out->command == TABLE) { - if (ctx->curr != TABLE_DESTROY) + if (ctx->curr != TABLE_DESTROY && + ctx->curr != TABLE_RESIZE_COMPLETE) return -1; if (sizeof(*out) > size) return -1; @@ -10513,7 +10575,8 @@ parse_qo_destroy(struct context *ctx, const struct token *token, if (!out) return len; if (!out->command || out->command == QUEUE) { - if (ctx->curr != QUEUE_DESTROY) + if (ctx->curr != QUEUE_DESTROY && + ctx->curr != QUEUE_FLOW_UPDATE_RESIZED) return -1; if (sizeof(*out) > size) return -1; @@ -12569,10 +12632,18 @@ cmd_flow_parsed(const struct buffer *in) in->args.table_destroy.table_id_n, in->args.table_destroy.table_id); break; + case TABLE_RESIZE_COMPLETE: + port_flow_template_table_resize_complete + (in->port, in->args.table_destroy.table_id[0]); + break; case GROUP_SET_MISS_ACTIONS: port_queue_group_set_miss_actions(in->port, &in->args.vc.attr, in->args.vc.actions); break; + case TABLE_RESIZE: + port_flow_template_table_resize(in->port, in->args.table.id, + in->args.table.attr.nb_flows); + break; case QUEUE_CREATE: port_queue_flow_create(in->port, in->queue, in->postpone, in->args.vc.table_id, in->args.vc.rule_id, @@ -12584,6 +12655,11 @@ cmd_flow_parsed(const struct buffer *in) in->args.destroy.rule_n, in->args.destroy.rule); break; + case QUEUE_FLOW_UPDATE_RESIZED: + port_queue_flow_update_resized(in->port, in->queue, + in->postpone, + in->args.destroy.rule[0]); + break; case QUEUE_UPDATE: port_queue_flow_update(in->port, in->queue, in->postpone, in->args.vc.rule_id, in->args.vc.act_templ_id, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index cad7537bc6..e589ac614b 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1403,6 +1403,19 @@ port_flow_new(const struct rte_flow_attr *attr, return NULL; } +static struct port_flow * +port_flow_locate(struct port_flow *flows_list, uint32_t flow_id) +{ + struct port_flow *pf = flows_list; + + while (pf) { + if (pf->id == flow_id) + break; + pf = pf->next; + } + return pf; +} + /** Print a message out of a flow error. */ static int port_flow_complain(struct rte_flow_error *error) @@ -1693,6 +1706,19 @@ table_alloc(uint32_t id, struct port_table **table, return 0; } +static struct port_table * +port_table_locate(struct port_table *tables_list, uint32_t table_id) +{ + struct port_table *pt = tables_list; + + while (pt) { + if (pt->id == table_id) + break; + pt = pt->next; + } + return pt; +} + /** Get info about flow management resources. */ int port_flow_get_info(portid_t port_id) @@ -2665,6 +2691,46 @@ port_flow_template_table_destroy(portid_t port_id, return ret; } +int +port_flow_template_table_resize_complete(portid_t port_id, uint32_t table_id) +{ + struct rte_port *port; + struct port_table *pt; + struct rte_flow_error error = { 0, }; + int ret; + + if (port_id_is_invalid(port_id, ENABLED_WARN)) + return -EINVAL; + port = &ports[port_id]; + pt = port_table_locate(port->table_list, table_id); + if (!pt) + return -EINVAL; + ret = rte_flow_template_table_resize_complete(port_id, + pt->table, &error); + return !ret ? 0 : port_flow_complain(&error); +} + +int +port_flow_template_table_resize(portid_t port_id, + uint32_t table_id, uint32_t flows_num) +{ + struct rte_port *port; + struct port_table *pt; + struct rte_flow_error error = { 0, }; + int ret; + + if (port_id_is_invalid(port_id, ENABLED_WARN)) + return -EINVAL; + port = &ports[port_id]; + pt = port_table_locate(port->table_list, table_id); + if (!pt) + return -EINVAL; + ret = rte_flow_template_table_resize(port_id, pt->table, flows_num, &error); + if (ret) + return port_flow_complain(&error); + return 0; +} + /** Flush table */ int port_flow_template_table_flush(portid_t port_id) @@ -2805,6 +2871,42 @@ port_queue_flow_create(portid_t port_id, queueid_t queue_id, return 0; } +int +port_queue_flow_update_resized(portid_t port_id, queueid_t queue_id, + bool postpone, uint32_t flow_id) +{ + const struct rte_flow_op_attr op_attr = { .postpone = postpone }; + struct rte_flow_error error = { 0, }; + struct port_flow *pf; + struct rte_port *port; + struct queue_job *job; + int ret; + + 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; + } + pf = port_flow_locate(port->flow_list, flow_id); + if (!pf) + return -EINVAL; + job = calloc(1, sizeof(*job)); + if (!job) + return -ENOMEM; + job->type = QUEUE_JOB_TYPE_FLOW_TRANSFER; + job->pf = pf; + ret = rte_flow_async_update_resized(port_id, queue_id, &op_attr, + pf->flow, job, &error); + if (ret) { + free(job); + return port_flow_complain(&error); + } + return 0; +} + /** Enqueue number of destroy flow rules operations. */ int port_queue_flow_destroy(portid_t port_id, queueid_t queue_id, diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 9b10a9ea1c..92f21e7776 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -110,6 +110,7 @@ enum { enum { QUEUE_JOB_TYPE_FLOW_CREATE, QUEUE_JOB_TYPE_FLOW_DESTROY, + QUEUE_JOB_TYPE_FLOW_TRANSFER, QUEUE_JOB_TYPE_FLOW_UPDATE, QUEUE_JOB_TYPE_ACTION_CREATE, QUEUE_JOB_TYPE_ACTION_DESTROY, @@ -981,7 +982,12 @@ int port_flow_template_table_create(portid_t port_id, uint32_t id, uint32_t nb_actions_templates, uint32_t *actions_templates); int port_flow_template_table_destroy(portid_t port_id, uint32_t n, const uint32_t *table); +int port_queue_flow_update_resized(portid_t port_id, queueid_t queue_id, + bool postpone, uint32_t flow_id); int port_flow_template_table_flush(portid_t port_id); +int port_flow_template_table_resize_complete(portid_t port_id, uint32_t table_id); +int port_flow_template_table_resize(portid_t port_id, + uint32_t table_id, uint32_t flows_num); int port_queue_group_set_miss_actions(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_action *actions); int port_queue_flow_create(portid_t port_id, queueid_t queue_id, diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst index e9c9717706..8ad1891396 100644 --- a/doc/guides/rel_notes/release_24_03.rst +++ b/doc/guides/rel_notes/release_24_03.rst @@ -55,6 +55,8 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added support for template API table resize.** + Removed Items ------------- diff --git a/lib/ethdev/ethdev_trace.h b/lib/ethdev/ethdev_trace.h index 1b1ae0cfe8..cd3327a619 100644 --- a/lib/ethdev/ethdev_trace.h +++ b/lib/ethdev/ethdev_trace.h @@ -2572,6 +2572,39 @@ RTE_TRACE_POINT_FP( rte_trace_point_emit_ptr(user_data); rte_trace_point_emit_int(ret); ) + +RTE_TRACE_POINT_FP( + rte_flow_trace_template_table_resize, + RTE_TRACE_POINT_ARGS(uint16_t port_id, + struct rte_flow_template_table *table, + uint32_t nb_rules, int ret), + rte_trace_point_emit_u16(port_id); + rte_trace_point_emit_ptr(table); + rte_trace_point_emit_u32(nb_rules); + rte_trace_point_emit_int(ret); +) + +RTE_TRACE_POINT_FP( + rte_flow_trace_async_update_resized, + RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t queue, + const struct rte_flow_op_attr *attr, + struct rte_flow *rule, void *user_data, int ret), + rte_trace_point_emit_u16(port_id); + rte_trace_point_emit_u32(queue); + rte_trace_point_emit_ptr(attr); + rte_trace_point_emit_ptr(rule); + rte_trace_point_emit_ptr(user_data); + rte_trace_point_emit_int(ret); +) + +RTE_TRACE_POINT_FP( + rte_flow_trace_table_resize_complete, + RTE_TRACE_POINT_ARGS(uint16_t port_id, + struct rte_flow_template_table *table, int ret), + rte_trace_point_emit_u16(port_id); + rte_trace_point_emit_ptr(table); + rte_trace_point_emit_int(ret); +) #ifdef __cplusplus } #endif diff --git a/lib/ethdev/ethdev_trace_points.c b/lib/ethdev/ethdev_trace_points.c index 91f71d868b..1a1f685daa 100644 --- a/lib/ethdev/ethdev_trace_points.c +++ b/lib/ethdev/ethdev_trace_points.c @@ -774,3 +774,12 @@ RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_action_list_handle_destroy, RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_action_list_handle_query_update, lib.ethdev.flow.async_action_list_handle_query_update) + +RTE_TRACE_POINT_REGISTER(rte_flow_trace_template_table_resize, + lib.ethdev.flow.template_table_resize) + +RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_update_resized, + lib.ethdev.flow.async_update_resized) + +RTE_TRACE_POINT_REGISTER(rte_flow_trace_table_resize_complete, + lib.ethdev.flow.table_resize_complete) diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 549e329558..3a46a81f44 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -2479,3 +2479,72 @@ rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table hash, error); return flow_err(port_id, ret, error); } + +int +rte_flow_template_table_resize(uint16_t port_id, + struct rte_flow_template_table *table, + uint32_t nb_rules, + struct rte_flow_error *error) +{ + int ret; + struct rte_eth_dev *dev; + const struct rte_flow_ops *ops; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + ops = rte_flow_ops_get(port_id, error); + if (!ops || !ops->flow_template_table_resize) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "flow_template_table_resize not supported"); + dev = &rte_eth_devices[port_id]; + ret = ops->flow_template_table_resize(dev, table, nb_rules, error); + ret = flow_err(port_id, ret, error); + rte_flow_trace_template_table_resize(port_id, table, nb_rules, ret); + return ret; +} + +int +rte_flow_async_update_resized(uint16_t port_id, uint32_t queue, + const struct rte_flow_op_attr *attr, + struct rte_flow *rule, void *user_data, + struct rte_flow_error *error) +{ + int ret; + struct rte_eth_dev *dev; + const struct rte_flow_ops *ops; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + ops = rte_flow_ops_get(port_id, error); + if (!ops || !ops->flow_update_resized) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "async_flow_async_transfer not supported"); + dev = &rte_eth_devices[port_id]; + ret = ops->flow_update_resized(dev, queue, attr, rule, user_data, error); + ret = flow_err(port_id, ret, error); + rte_flow_trace_async_update_resized(port_id, queue, attr, + rule, user_data, ret); + return ret; +} + +int +rte_flow_template_table_resize_complete(uint16_t port_id, + struct rte_flow_template_table *table, + struct rte_flow_error *error) +{ + int ret; + struct rte_eth_dev *dev; + const struct rte_flow_ops *ops; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + ops = rte_flow_ops_get(port_id, error); + if (!ops || !ops->flow_template_table_resize_complete) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "flow_template_table_transfer_complete not supported"); + dev = &rte_eth_devices[port_id]; + ret = ops->flow_template_table_resize_complete(dev, table, error); + ret = flow_err(port_id, ret, error); + rte_flow_trace_table_resize_complete(port_id, table, ret); + return ret; +} diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index affdc8121b..0b5de9b20b 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -5749,6 +5749,10 @@ struct rte_flow_template_table; * if the hint is supported. */ #define RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG RTE_BIT32(1) +/** + * Specialize table for resize. + */ +#define RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE RTE_BIT32(2) /**@}*/ /** @@ -5827,6 +5831,13 @@ struct rte_flow_template_table_attr { enum rte_flow_table_hash_func hash_func; }; +static __rte_always_inline bool +rte_flow_table_resizable(const struct rte_flow_template_table_attr *tbl_attr) +{ + return (tbl_attr->specialize & + RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE) != 0; +} + /** * @warning * @b EXPERIMENTAL: this API may change without prior notice. @@ -6753,6 +6764,92 @@ rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table const struct rte_flow_item pattern[], uint8_t pattern_template_index, uint32_t *hash, struct rte_flow_error *error); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Change template table flow rules capacity. + * + * @param port_id + * Port identifier of Ethernet device. + * @param table + * Template table to modify. + * @param nb_rules + * New flow rules capacity. + * @param error + * Perform verbose error reporting if not NULL. + * PMDs initialize this structure in case of error only. + * + * @return + * - (0) if success. + * - (-ENODEV) if *port_id* invalid. + * - (-ENOTSUP) if underlying device does not support this functionality. + * - (-EINVAL) if *table* cannot be resized or invalid *nb_rules* + */ +__rte_experimental +int +rte_flow_template_table_resize(uint16_t port_id, + struct rte_flow_template_table *table, + uint32_t nb_rules, + struct rte_flow_error *error); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Following table resize, update flow resources in port. + * + * @param port_id + * Port identifier of Ethernet device. + * @param queue + * Flow queue for async operation. + * @param attr + * Async operation attributes. + * @param rule + * Flow rule to update. + * @param user_data + * The user data that will be returned on async completion event. + * @param error + * Perform verbose error reporting if not NULL. + * PMDs initialize this structure in case of error only. + * + * @return + * - (0) if success. + * - (-ENODEV) if *port_id* invalid. + * - (-ENOTSUP) if underlying device does not support this functionality. + * - (-EINVAL) if *rule* cannot be updated. + */ +__rte_experimental +int +rte_flow_async_update_resized(uint16_t port_id, uint32_t queue, + const struct rte_flow_op_attr *attr, + struct rte_flow *rule, void *user_data, + struct rte_flow_error *error); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Following table resize, notify port that all table flows were updated. + * + * @param port_id + * Port identifier of Ethernet device. + * @param table + * Template table that undergoing resize operation. + * @param error + * Perform verbose error reporting if not NULL. + * PMDs initialize this structure in case of error only. + * + * @return + * - (0) if success. + * - (-ENODEV) if *port_id* invalid. + * - (-ENOTSUP) if underlying device does not support this functionality. + * - (-EINVAL) PMD cannot complete table resize. + */ +__rte_experimental +int +rte_flow_template_table_resize_complete(uint16_t port_id, + struct rte_flow_template_table *table, + struct rte_flow_error *error); #ifdef __cplusplus } #endif diff --git a/lib/ethdev/rte_flow_driver.h b/lib/ethdev/rte_flow_driver.h index f35f659503..53d9393575 100644 --- a/lib/ethdev/rte_flow_driver.h +++ b/lib/ethdev/rte_flow_driver.h @@ -370,6 +370,21 @@ struct rte_flow_ops { (struct rte_eth_dev *dev, const struct rte_flow_template_table *table, const struct rte_flow_item pattern[], uint8_t pattern_template_index, uint32_t *hash, struct rte_flow_error *error); + /** @see rte_flow_template_table_resize() */ + int (*flow_template_table_resize)(struct rte_eth_dev *dev, + struct rte_flow_template_table *table, + uint32_t nb_rules, + struct rte_flow_error *error); + /** @see rte_flow_async_update_resized() */ + int (*flow_update_resized)(struct rte_eth_dev *dev, uint32_t queue, + const struct rte_flow_op_attr *attr, + struct rte_flow *rule, void *user_data, + struct rte_flow_error *error); + /** @see rte_flow_template_table_resize_complete() */ + int (*flow_template_table_resize_complete) + (struct rte_eth_dev *dev, + struct rte_flow_template_table *table, + struct rte_flow_error *error); }; /** diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index 5c4917c020..e37bab9b81 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -316,6 +316,9 @@ EXPERIMENTAL { rte_eth_recycle_rx_queue_info_get; rte_flow_group_set_miss_actions; rte_flow_calc_table_hash; + rte_flow_template_table_resize; + rte_flow_async_update_resized; + rte_flow_template_table_resize_complete; }; INTERNAL { -- 2.39.2