From patchwork Wed Feb 8 03:06:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 123416 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 A559841C37; Wed, 8 Feb 2023 04:07:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 119E442D16; Wed, 8 Feb 2023 04:07:16 +0100 (CET) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2066.outbound.protection.outlook.com [40.107.102.66]) by mails.dpdk.org (Postfix) with ESMTP id 51AD942BC9 for ; Wed, 8 Feb 2023 04:07:14 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LWRzUk4o1uNNM9ESDp4MsNTkiJJ0HfG300zsbe4pgANBnqYmjniCLQdgc8ds/EXH+Mxx5yj+mFjPEl/SRFHcEo22VRg2qSXpl3cGYOUpyYVoPkW2R6Pf5FNNad2BFRUaoqlODTP0tFJU2vpva8PX+G6Jj1AOiab/xJM12pcn5+0jS3F5hK+n3Ld5j8UYlA34rq2UBXynFbtlm62TCfhhECX5zvkgwR+UaBWtumJcgQG+5/gLEri3Dsc/npkG7lMBJ5Abkd2qtoP5qIPK7SzjRfQYW/SqUnyDHabBbKB1SUfGtumlIP5aZHiFlAzXRwqPN5MxlBRAhZo4fMsAooFH4w== 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=iYZMtTDg56l+/XXxXlQ0dmmRZhKgO2DmYs3VJ4Q+6/4=; b=Ps/Mvbj68ZAfiW2vBgIFrNz+dPFcGzGF3/Icqp7LQysHrJbkxP7B/VGBnUMNyQbZbhczUFQki9qAJ4Q3ZD1UXnE9f1fW8R8KJ6lG6Rqyz4Zm2P/JmafwoO8rmRSD7E1NFqYcX7swTooo/7CX8f8WKOYMBaj01IWkKCsWhDXsv3WPyoWUSf/lUXkV3jDqXoguoDlmC64rWTXfgbpEsI8vD0tF8ih7rUReVNjhYxmOtkclfNQS9DnK0x8uGh7CSjasEgF50U2mo5o84Z5tvar0LEL0cKM4Nar0RnYkQXd5aQ6EwP0GT5cXa2B2YzD+23DT9HI0agItlcUFHVkD1Idd7Q== 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 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=iYZMtTDg56l+/XXxXlQ0dmmRZhKgO2DmYs3VJ4Q+6/4=; b=sywwzdruVQALqYXKuaEICBkvFcqzCezNKK3zizkQigRUxmupLoyN2nOvqSlPyBYCoZIDg9iUF4PNKCWLBgV8XBPV1/2Sh2+tDzLLo49GxotcHdMONp0pHpp2079tWqCjAm0jrzdkDagGcw2dSvBXIODyanbvJDWEhmj+j9MzWHdm3orgsTKVykKHR7eRWyr5tunmA5B/rzWXQT1lyfsLL0JCL1F1qOiXybvKA/7ud1sFn7Qz9DF4/TnxUsiSl1uIO6g4QI7yUiVFn0x1Cm2iwcYDB1+xnO5eZW/Cy/Ky8Ho1y+4sWtGUES2d+ZGV0gcVx5JqjvvkF31NuoTFBSTqLw== Received: from MW4PR04CA0128.namprd04.prod.outlook.com (2603:10b6:303:84::13) by CH3PR12MB8353.namprd12.prod.outlook.com (2603:10b6:610:12c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.17; Wed, 8 Feb 2023 03:07:04 +0000 Received: from CO1NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:303:84:cafe::df) by MW4PR04CA0128.outlook.office365.com (2603:10b6:303:84::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36 via Frontend Transport; Wed, 8 Feb 2023 03:07:04 +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 CO1NAM11FT066.mail.protection.outlook.com (10.13.175.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.17 via Frontend Transport; Wed, 8 Feb 2023 03:07:04 +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.36; Tue, 7 Feb 2023 19:06:54 -0800 Received: from pegasus01.mtr.labs.mlnx (10.126.230.37) 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.36; Tue, 7 Feb 2023 19:06:52 -0800 From: Alexander Kozyrev To: CC: , , , Subject: [PATCH v4 4/4] app/testpmd: add template table hash calculation function Date: Wed, 8 Feb 2023 05:06:24 +0200 Message-ID: <20230208030624.78465-5-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20230208030624.78465-1-akozyrev@nvidia.com> References: <20230208024755.72743-1-akozyrev@nvidia.com> <20230208030624.78465-1-akozyrev@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.37] 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-TrafficTypeDiagnostic: CO1NAM11FT066:EE_|CH3PR12MB8353:EE_ X-MS-Office365-Filtering-Correlation-Id: 797f9ff7-7721-4eac-c39c-08db09818e34 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: n+EfRa84D5uzeeuANqFN7k9n1SSPyeyoiD2cYjaJBhl5hzvCHM5rhCfKvi9+EE06SU4XqyZ/E+dgKwnaGjdtQv/WBgoLPkXzMToyGGJhxF8H+65N9E0fVLqhqi8ATE3ZYtvxXu1fsuiwnWGCC7xncAwhdGrz3SjpK1qGCeSL7xaNCuR1qTf86tNLCx1qYjCXs2w97FoE8pIvs290gG6BMeC2MoY+nIkJ1+HwAQXKe7X+jL03LpHZxS/zTd6L1r2KXt9f8uBTsxrZ5Mj0oKrB9hROTbrMAnAUMTTuoCpS0uEo/DPh0PzjPewlrlYmGRUL1CXSTeuoSpisfokwlHtf5PdQuuZXZn4afWeN57WfiTphwzwdiOTIgu2l8cnYi2OxKrN+76Y9B14D6Y2YUJMLtD0CYrrDCCBt2KwX8n9eVtdQ4GhxPVuhVAKIVUSvtiBGLC9whJAUZTw9C61gJ5V7YVBRyYFyHTNgmbjYT3gOW7dfqMeqIpbxfbzGL9plA8jCqs8OSv79zBbgmA9tuyMc+R3GwlnMV9JpJ4xF2xqWwWekxI1vmfu7nCXnJZxFTUpC7hLjTPMyc5ueW1RqJyoVWBWnlBEw/4RmVDo4alvGUOwxmwQzaJJIdXgJVa+ET4kJKh/d4Y1W7mQ/k8/vYNPZJhKkm7hu7u0dhXns8hBtAEGEMMAFRbArzoMLXgxHazxm8g18/PpbDCkC6UJ0JoBPkg== 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:(13230025)(4636009)(39860400002)(396003)(136003)(346002)(376002)(451199018)(36840700001)(40470700004)(46966006)(40460700003)(16526019)(82740400003)(7636003)(83380400001)(356005)(316002)(8936002)(4326008)(6916009)(41300700001)(70586007)(2906002)(36860700001)(70206006)(5660300002)(107886003)(2616005)(6666004)(1076003)(478600001)(8676002)(336012)(186003)(26005)(82310400005)(86362001)(54906003)(426003)(47076005)(36756003)(40480700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2023 03:07:04.3217 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 797f9ff7-7721-4eac-c39c-08db09818e34 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: CO1NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8353 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 CLI interface for a template table hash function. Available types are: default, linear, crc32 and crc16. flow template_table 0 create table_id 0 hash_func linear ... Signed-off-by: Alexander Kozyrev --- app/test-pmd/cmdline_flow.c | 69 ++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index f1d6813baa..007d31c5cf 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -180,6 +180,8 @@ enum index { TABLE_DESTROY_ID, TABLE_INSERTION_TYPE, TABLE_INSERTION_TYPE_NAME, + TABLE_HASH_FUNC, + TABLE_HASH_FUNC_NAME, TABLE_GROUP, TABLE_PRIORITY, TABLE_INGRESS, @@ -808,7 +810,8 @@ static const char *const modify_field_ids[] = { "udp_port_src", "udp_port_dst", "vxlan_vni", "geneve_vni", "gtp_teid", "tag", "mark", "meta", "pointer", "value", - "ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color", NULL + "ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color", + "hash_result", NULL }; static const char *const meter_colors[] = { @@ -819,6 +822,10 @@ static const char *const table_insertion_types[] = { "pattern", "index", NULL }; +static const char *const table_hash_funcs[] = { + "default", "linear", "crc32", "crc16", NULL +}; + #define RAW_IPSEC_CONFS_MAX_NUM 8 /** Maximum number of subsequent tokens and arguments on the stack. */ @@ -1163,6 +1170,7 @@ static const enum index next_table_attr[] = { TABLE_CREATE_ID, TABLE_GROUP, TABLE_INSERTION_TYPE, + TABLE_HASH_FUNC, TABLE_PRIORITY, TABLE_INGRESS, TABLE_EGRESS, @@ -2417,6 +2425,9 @@ static int parse_meter_color(struct context *ctx, const struct token *token, static int parse_insertion_table_type(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size); +static int parse_hash_table_type(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size); static int comp_none(struct context *, const struct token *, unsigned int, char *, unsigned int); static int comp_boolean(struct context *, const struct token *, @@ -2451,6 +2462,8 @@ static int comp_meter_color(struct context *, const struct token *, unsigned int, char *, unsigned int); static int comp_insertion_table_type(struct context *, const struct token *, unsigned int, char *, unsigned int); +static int comp_hash_table_type(struct context *, const struct token *, + unsigned int, char *, unsigned int); /** Token definitions. */ static const struct token token_list[] = { @@ -2935,6 +2948,20 @@ static const struct token token_list[] = { .call = parse_insertion_table_type, .comp = comp_insertion_table_type, }, + [TABLE_HASH_FUNC] = { + .name = "hash_func", + .help = "specify hash calculation function", + .next = NEXT(next_table_attr, + NEXT_ENTRY(TABLE_HASH_FUNC_NAME)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.hash_func)), + }, + [TABLE_HASH_FUNC_NAME] = { + .name = "hash_func_name", + .help = "hash calculation function name", + .call = parse_hash_table_type, + .comp = comp_hash_table_type, + }, [TABLE_GROUP] = { .name = "group", .help = "specify a group", @@ -10123,6 +10150,32 @@ parse_insertion_table_type(struct context *ctx, const struct token *token, return ret > 0 ? (int)len : ret; } +/** Parse Hash Calculation Table Type name */ +static int +parse_hash_table_type(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size) +{ + const struct arg *arg = pop_args(ctx); + unsigned int i; + char tmp[2]; + int ret; + + (void)size; + /* Argument is expected. */ + if (!arg) + return -1; + for (i = 0; table_hash_funcs[i]; ++i) + if (!strcmp_partial(table_hash_funcs[i], str, len)) + break; + if (!table_hash_funcs[i]) + return -1; + push_args(ctx, arg); + snprintf(tmp, sizeof(tmp), "%u", i); + ret = parse_int(ctx, token, tmp, strlen(tmp), buf, sizeof(i)); + return ret > 0 ? (int)len : ret; +} + /** No completion. */ static int comp_none(struct context *ctx, const struct token *token, @@ -10442,6 +10495,20 @@ comp_insertion_table_type(struct context *ctx, const struct token *token, return -1; } +/** Complete available Hash Calculation Table types. */ +static int +comp_hash_table_type(struct context *ctx, const struct token *token, + unsigned int ent, char *buf, unsigned int size) +{ + RTE_SET_USED(ctx); + RTE_SET_USED(token); + if (!buf) + return RTE_DIM(table_hash_funcs); + if (ent < RTE_DIM(table_hash_funcs) - 1) + return rte_strscpy(buf, table_hash_funcs[ent], size); + return -1; +} + /** Internal context. */ static struct context cmd_flow_context;