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 F353F425FC; Tue, 19 Sep 2023 10:13:00 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D936A402EA; Tue, 19 Sep 2023 10:13:00 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2043.outbound.protection.outlook.com [40.107.94.43]) by mails.dpdk.org (Postfix) with ESMTP id 0AB604027E for ; Tue, 19 Sep 2023 10:12:59 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IilNmN1Z7MYEXbjDVSfQ6DLAG/T2OPcpL7r5vdjI/KbS5kx6j8Crjox1L0Vng9FBMLWBQqGTyEm4xsDuV5F3pQsp1mbWMcXKh6ulBFmXJ+j8X57fBWu2LScUZUzdD9uglCXxO/PZgKDHcInskGe4Zw6+oQRysbHepVWxN7C1ULBd+H5/eNFoFK01TmpncvPlyhPOtGnXOei/WtQQNykKGXeS4dgqb3/LfIoDNMseWm9AYsiFaOwJIPQbgo1lWf0VgSSoZCIDREBa6MVO2rWATqe/1GPf9BWcPpfQyWMl+xsPRsXe3wViT7cpjroreW5FA8nx8b6GtIKba+dICX552w== 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=kvygzGEN9q1Vsg7rQ9MW1hDMODuCKt8MVXGAOWPcW+Q=; b=cCCoNlauRmLig/6WzMufI0G83IKaiC9lCMIqI1hhhWR71Zrve1VR6zMmU/Mt0djTYlQsfO/ArmPq3/C80kQHsx+Iigto+4CCehcvzL9N4asWw5rPD+JNyBOIdv6M056WhqwZ78ivAYUnnOFs80bYYJLl5rpDTWnnxYRtf1OMbqL7Kjzn0lZuJbjJvuzVYKIuHTreEIWRIdQ5MQQZa9pcJ5RDCAdFbFwI0ZF9R5CpFLWCi1cw2wpbrpnr2zH7EaJuK6yVexVbaO7oXfUKMgBoRdLQNqkES1IsMfKNP5Xk4TTRgHGj9nSGj/tgMmXZN9ehS6xYuDw2Cf7EBH9MqbRD0Q== 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=kvygzGEN9q1Vsg7rQ9MW1hDMODuCKt8MVXGAOWPcW+Q=; b=r81AYc68xNKrbcySTcwvRNmgi+K0OM0Zl+m/iN9CCVgPYH/54Q4OEVO87Z9qATL6qEfuX/4g1wWCcDnmBEMzIeYu/Y0+XYZqVjPHFgST83pT93T6X+Fmr3TJmhhWeNSmE7I83AMBuOsrm/5CwHgThL34JNtUyliZwbrJUM00Mg1Vlyy9JqXeGcAKWjuS+GyC0ELg5weP3Xp+qpEnLoXAZ4CtimgPI7PkpAwGU9PGlsigpHkcjWKbDzHjvKMqavkCS4WRVrFikyRRQ9Z0hJzYfkucrhdz4BS6Sec1EUSUNp53x4ZDrzxs2olC5l0ju7pkMQBAO79KB9OK+huylZWAgg== Received: from BL1PR13CA0133.namprd13.prod.outlook.com (2603:10b6:208:2bb::18) by BY5PR12MB4291.namprd12.prod.outlook.com (2603:10b6:a03:20c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.28; Tue, 19 Sep 2023 08:12:54 +0000 Received: from BL02EPF0001A102.namprd05.prod.outlook.com (2603:10b6:208:2bb:cafe::6c) by BL1PR13CA0133.outlook.office365.com (2603:10b6:208:2bb::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Tue, 19 Sep 2023 08:12:53 +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 BL02EPF0001A102.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20 via Frontend Transport; Tue, 19 Sep 2023 08:12:53 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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; Tue, 19 Sep 2023 01:12:40 -0700 Received: from nvidia.com (10.126.230.35) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 19 Sep 2023 01:12:38 -0700 From: Rongwei Liu To: , , , , , Subject: [PATCH v3] net/mlx5: add test for live migration Date: Tue, 19 Sep 2023 11:12:25 +0300 Message-ID: <20230919081225.480497-1-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <17253347.geO5KgaWL5@thomas> References: <17253347.geO5KgaWL5@thomas> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail202.nvidia.com (10.129.68.7) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A102:EE_|BY5PR12MB4291:EE_ X-MS-Office365-Filtering-Correlation-Id: da3aadf7-4fb2-492c-88a8-08dbb8e8396b 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: izxMiNwbOk8OCIoHfgJAuKemRYdns7EDfIpZz33bpmir/LRR66eho5P1SR/3/vYAZt7wQ5/w2DGXMll2j3DrF7xAWyq+/RYd0SuxxRjqBub//aTmVmXhtBPU3nrsMZDXJv3EWwCk1SuNsJZtt89hAHK4AhJOsndr/QmHJ9Q9/3ITiPWPreTfTKwygxT7upz8jq71UWhs0tBx+OEOaTHuNgVXlf/vPkXm6pSOh4u8T/XhsAvkqsoSMwKPc2+9LTzVz9BUZ61kkNvQz5c9a7cTh1NeEtc6fcSH6oAXttlQJubfhOujmeZfMNlrJBV1dZLnskux8R0Zfxxq7mfj9yYSTKzWOd1oVZxP2tnwrz1KAO1L8Sija5nWDpXOL6Znati2e4rWaW3RosFoZIFi85O8m5xfxvDGa5YgVPKWfHMZpePPPPj9OEEdi+5PdDYhnD2vhFO+b4J2MN0fFSuk9rHs0zMNbujiOGvDA8fpLwK0kedtzm2cHq6/xIC3EyOJ3G8O3qJcLobHIUDOS2+gmjQjDvfPEp+MYFq6sx1MOLZXdR5uRsxw/94A5miuUwFIyjfJmYjHkocjeLlUgiPxZhVdmK3xZUQzPNUbOu0QqHmRTstbaiET3MZCY9IziM35JSzbEXmlVoWb8wEUOQPgCbXm+NIofoDhhc9MhHbFQMPX1eKo73OYpQZmWVAm8VtBnYoguMBhn+5fbsAzEpkC//eMdIu1iKxfyn8GWOUU9EJw6V7s8jioavIb6626zH5+KF+k 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)(39860400002)(376002)(346002)(136003)(396003)(82310400011)(451199024)(186009)(1800799009)(40470700004)(46966006)(36840700001)(6286002)(26005)(1076003)(2616005)(36860700001)(47076005)(40460700003)(83380400001)(426003)(40480700001)(336012)(55016003)(16526019)(5660300002)(70586007)(70206006)(110136005)(8676002)(8936002)(41300700001)(2906002)(316002)(86362001)(478600001)(36756003)(7696005)(82740400003)(6666004)(7636003)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2023 08:12:53.6454 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: da3aadf7-4fb2-492c-88a8-08dbb8e8396b 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: BL02EPF0001A102.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4291 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 v3: Add missing --in-reply-to option. v2: Change the command prompt from integer to string. --- doc/guides/nics/mlx5.rst | 14 ++++ drivers/net/mlx5/mlx5_testpmd.c | 124 ++++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 7bee57d9dd..5726e497a8 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -2179,3 +2179,17 @@ 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(0) or standby(1) mode with specific flags:: + +.. 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