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 E23D2431FA; Wed, 25 Oct 2023 11:45:52 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B167340A6B; Wed, 25 Oct 2023 11:45:52 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2069.outbound.protection.outlook.com [40.107.94.69]) by mails.dpdk.org (Postfix) with ESMTP id 4CFA4402E8 for ; Wed, 25 Oct 2023 11:45:51 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LbnNWIsM13fwSiexqah31jAqPZq1YusWhJfOm0QltqGJmHGs85CBqYgXDS7zf9ZPXB50mXwUqBS8n/P8qx3s44EfroIGTQ9NbndRBLLQsvuwrz4Xiu3alReLFKArPZJ0qqG9FVEkx5vJn7ANbj3Dr2PQcFyv+5guWtXwj+bdfLeIaTbuakxd8OHPbDsqRLzgrRi0Ns2zwTogBYocDdxz9jn8xpAxmalMyxRMNek1pw2jHgaLDBLzo+Go9tr1XwPqik4IznaHtJq6ND7NK2MPhgZ46NuKXHE38MKrwMU25dL6gynjXmj03QACRvYY0Yxm2y3jGY9DJadbZgMU4NtWog== 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=4Kk+K6eJoWA2E3GDwqJHKwUPbIWs3rbtpsPW6rSR708=; b=S5BDFvpZmAG9o9uZNkSyjHZXttACZpyIRDI+0iKu3wNYLt9SFEQdKFUg0aFyUbidrALU6Ck4wXH+CT/CFUDa1V3XU/PNk56xflDAwkqTvYg20Q4o8oyyoyHba5N3KCTk4aIZPu/yyObSvkis5U4XFpk0o1yLwJzO3oJO+eJsc2N8oLBTa2lfXUZYrpzsbMDrCoQ9u26luzRyT1dh9eT2ouaUrUucg9/a3KVHYVkNwpgBzat+kyPYRQPNd9rLnhWiuz1QDJI2TddubN8YD1h2FCuLdD2S4D4n2rn2uXUt8Ax0dBtrHfj4E4PK/gdGv8lVyWhUnKLfLsmV+bFGrEOUyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=4Kk+K6eJoWA2E3GDwqJHKwUPbIWs3rbtpsPW6rSR708=; b=o6CDlIRW+XEJk6AOB6tLLa0hh5YqNW031GD2hRrqkLsgalYLM2Lnt0tJOnglLy4MrB9IEeUnapcNY3yaED581iE53ADp71NOUpkhJ8M+IpzAUnOF9q8p0d1LgazfsM5j+riaFqMCNgi67uTrO53KYIzFX+k3C13l1nE1RQwGJK0M4XhJVYBoQu6DPsd4CrSTvnVSEmtGc8zA0NjVr04/eSq4jh7JMv1txilVEnqyQZyS9O7WIPkLVZAZ2WQk5n74kaN56veT7AoGQwP4TZqqtEnI6pFdjlrziKTds5vniDLAqG/Kb1rsLGp6exG6LCtPF2Uiw/Msb/xtRWtugpjp3Q== Received: from MN2PR20CA0011.namprd20.prod.outlook.com (2603:10b6:208:e8::24) by CH0PR12MB8506.namprd12.prod.outlook.com (2603:10b6:610:18a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.33; Wed, 25 Oct 2023 09:45:49 +0000 Received: from BL02EPF0001A105.namprd05.prod.outlook.com (2603:10b6:208:e8:cafe::d8) by MN2PR20CA0011.outlook.office365.com (2603:10b6:208:e8::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.33 via Frontend Transport; Wed, 25 Oct 2023 09:45:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL02EPF0001A105.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.15 via Frontend Transport; Wed, 25 Oct 2023 09:45:48 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 25 Oct 2023 02:45:31 -0700 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; Wed, 25 Oct 2023 02:45:29 -0700 From: Rongwei Liu To: , , , , , Subject: [PATCH v6] net/mlx5: add test for live migration Date: Wed, 25 Oct 2023 12:45:16 +0300 Message-ID: <20231025094516.1344682-1-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <8285764.T7Z3S40VBb@thomas> References: <8285764.T7Z3S40VBb@thomas> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A105:EE_|CH0PR12MB8506:EE_ X-MS-Office365-Filtering-Correlation-Id: b7571491-c412-4120-e542-08dbd53f2b5c 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: PdR4G2VZXTnTgIlGLLCm2rdd9323W7zgOqapBEHorm1qQUc1z9SCdi2vM2M7QF7/IVXFSbxqAu8q33eh5SIzo/FEBMQ4YHtgTVzvnWWqzuMcrHEquuAGndBHoJmwuQZBmjFxvcIQuBAY4nQdfd3lvuZbW2pi4jOuYevicveaEVHYdvzrVoiecvHiGAcRWzwM5IyT+zO1vtDxIZei9+8rd754B49rAp17K9oNlpMCAY0Y3PRbzn5KKZq3MSZ0iHHdDPAFkmYAvr5NJvTwjpsoo064S5RoezV69LiezjFctqb4e3TXThn2xtoy8lkqgkBKWM6ZmRIFuodCRDXP/tGhdmFhWIMZn9ND4hkPWj+lNJ6H/Y0k99/SdLyj6meQYqT8Hrlsi/aD16Ir9qqYFhOMDEnAJ5SiY5Nnh+99lhIbX+9DhEWT7+vb7f4w+uzG5xmuMD3kn+HRFlFwhHy79iscDdNja9V3AQa1oS7/kkBwk08jWdTcU38exMgStZooqzs5+BHceG6YQ2hSDP1iUTvPv6yyNGROvEVG5cf8vhlxsiW3myUzMJvjUVaUegE9XvOSHV1YoLMf22VJ3LPbOlG7HznlBuThtJQoTjq6pu8m4Jwnz3ovIDKpehNjcthWjL86mL/SRdREgiZx12suQ26Ru3uvDwDZ74E7X3gItsGVhJiuDp4fTtpUSTqQVOW+y2kXFZ9GMQk4VlfA5nAxxbkcXs/e7zVtPfbrQG/kB1rDEVUPhm1n44dweI6QIZEtolP/ X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(376002)(396003)(346002)(136003)(39860400002)(230922051799003)(451199024)(64100799003)(1800799009)(186009)(82310400011)(36840700001)(40470700004)(46966006)(7636003)(356005)(36860700001)(36756003)(82740400003)(7696005)(6666004)(110136005)(26005)(478600001)(316002)(55016003)(16526019)(336012)(1076003)(426003)(70586007)(2616005)(6286002)(47076005)(83380400001)(70206006)(86362001)(41300700001)(8936002)(8676002)(40460700003)(2906002)(40480700001)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2023 09:45:48.8190 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b7571491-c412-4120-e542-08dbd53f2b5c 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.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A105.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB8506 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 This patch adds testpmd app a runtime function to test the live migration API. testpmd> mlx5 set flow_engine [] Flag is optional. Signed-off-by: Rongwei Liu Acked-by: Viacheslav Ovsiienko Acked-by: Ori Kam --- doc/guides/nics/mlx5.rst | 15 ++++ drivers/net/mlx5/mlx5_testpmd.c | 124 ++++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 9039b55c0b..aca51f0928 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -2187,3 +2187,18 @@ where: * ``sw_queue_id``: queue index in range [64536, 65535]. This range is the highest 1000 numbers. * ``hw_queue_id``: queue index given by HW in queue creation. + +Set Flow Engine Mode +~~~~~~~~~~~~~~~~~~~~ + +Set the flow engine to active or standby mode with specific flags (bitmap style):: +See MLX5_FLOW_ENGINE_FLAG_* for the flag definitions. + +.. code-block:: console + + testpmd> mlx5 set flow_engine [] + +This command is used for testing live migration and works for +software steering only. +Default FDB jump should be disabled if switchdev is enabled. +The mode will propagate to all the probed ports. diff --git a/drivers/net/mlx5/mlx5_testpmd.c b/drivers/net/mlx5/mlx5_testpmd.c index 879ea2826e..c70a10b3af 100644 --- a/drivers/net/mlx5/mlx5_testpmd.c +++ b/drivers/net/mlx5/mlx5_testpmd.c @@ -25,6 +25,29 @@ static uint8_t host_shaper_avail_thresh_triggered[RTE_MAX_ETHPORTS]; #define SHAPER_DISABLE_DELAY_US 100000 /* 100ms */ +#define PARSE_DELIMITER " \f\n\r\t\v" + +static int +parse_uint(uint64_t *value, const char *str) +{ + char *next = NULL; + uint64_t n; + + errno = 0; + /* Parse number string */ + if (!strncasecmp(str, "0x", 2)) { + str += 2; + n = strtol(str, &next, 16); + } else { + n = strtol(str, &next, 10); + } + if (errno != 0 || str == next || *next != '\0') + return -1; + + *value = n; + + return 0; +} /** * Disable the host shaper and re-arm available descriptor threshold event. @@ -561,6 +584,102 @@ cmdline_parse_inst_t mlx5_cmd_unmap_ext_rxq = { } }; +/* Set flow engine mode with flags command. */ +struct mlx5_cmd_set_flow_engine_mode { + cmdline_fixed_string_t mlx5; + cmdline_fixed_string_t set; + cmdline_fixed_string_t flow_engine; + cmdline_multi_string_t mode; +}; + +static int +parse_multi_token_flow_engine_mode(char *t_str, enum mlx5_flow_engine_mode *mode, + uint32_t *flag) +{ + uint64_t val; + char *token; + int ret; + + *flag = 0; + /* First token: mode string */ + token = strtok_r(t_str, PARSE_DELIMITER, &t_str); + if (token == NULL) + return -1; + + if (!strcmp(token, "active")) + *mode = MLX5_FLOW_ENGINE_MODE_ACTIVE; + else if (!strcmp(token, "standby")) + *mode = MLX5_FLOW_ENGINE_MODE_STANDBY; + else + return -1; + + /* Second token: flag */ + token = strtok_r(t_str, PARSE_DELIMITER, &t_str); + if (token == NULL) + return 0; + + ret = parse_uint(&val, token); + if (ret != 0 || val > UINT32_MAX) + return -1; + + *flag = val; + return 0; +} + +static void +mlx5_cmd_set_flow_engine_mode_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct mlx5_cmd_set_flow_engine_mode *res = parsed_result; + enum mlx5_flow_engine_mode mode; + uint32_t flag; + int ret; + + ret = parse_multi_token_flow_engine_mode(res->mode, &mode, &flag); + + if (ret < 0) { + fprintf(stderr, "Bad input\n"); + return; + } + + ret = rte_pmd_mlx5_flow_engine_set_mode(mode, flag); + + if (ret < 0) + fprintf(stderr, "Fail to set flow_engine to %s mode with flag 0x%x, error %s\n", + mode == MLX5_FLOW_ENGINE_MODE_ACTIVE ? "active" : "standby", flag, + strerror(-ret)); + else + TESTPMD_LOG(DEBUG, "Set %d ports flow_engine to %s mode with flag 0x%x\n", ret, + mode == MLX5_FLOW_ENGINE_MODE_ACTIVE ? "active" : "standby", flag); +} + +cmdline_parse_token_string_t mlx5_cmd_set_flow_engine_mode_mlx5 = + TOKEN_STRING_INITIALIZER(struct mlx5_cmd_set_flow_engine_mode, mlx5, + "mlx5"); +cmdline_parse_token_string_t mlx5_cmd_set_flow_engine_mode_set = + TOKEN_STRING_INITIALIZER(struct mlx5_cmd_set_flow_engine_mode, set, + "set"); +cmdline_parse_token_string_t mlx5_cmd_set_flow_engine_mode_flow_engine = + TOKEN_STRING_INITIALIZER(struct mlx5_cmd_set_flow_engine_mode, flow_engine, + "flow_engine"); +cmdline_parse_token_string_t mlx5_cmd_set_flow_engine_mode_mode = + TOKEN_STRING_INITIALIZER(struct mlx5_cmd_set_flow_engine_mode, mode, + TOKEN_STRING_MULTI); + +cmdline_parse_inst_t mlx5_cmd_set_flow_engine_mode = { + .f = &mlx5_cmd_set_flow_engine_mode_parsed, + .data = NULL, + .help_str = "mlx5 set flow_engine []", + .tokens = { + (void *)&mlx5_cmd_set_flow_engine_mode_mlx5, + (void *)&mlx5_cmd_set_flow_engine_mode_set, + (void *)&mlx5_cmd_set_flow_engine_mode_flow_engine, + (void *)&mlx5_cmd_set_flow_engine_mode_mode, + NULL, + } +}; + static struct testpmd_driver_commands mlx5_driver_cmds = { .commands = { { @@ -588,6 +707,11 @@ static struct testpmd_driver_commands mlx5_driver_cmds = { .help = "mlx5 port (port_id) ext_rxq unmap (sw_queue_id)\n" " Unmap external Rx queue ethdev index mapping\n\n", }, + { + .ctx = &mlx5_cmd_set_flow_engine_mode, + .help = "mlx5 set flow_engine (active|standby) [(flag)]\n" + " Set flow_engine to the specific mode with flag.\n\n" + }, { .ctx = NULL, }, -- 2.27.0