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 11366431FA; Wed, 25 Oct 2023 11:50:39 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 003A640DDE; Wed, 25 Oct 2023 11:50:38 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2068.outbound.protection.outlook.com [40.107.237.68]) by mails.dpdk.org (Postfix) with ESMTP id A278B402E8 for ; Wed, 25 Oct 2023 11:50:37 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TRQcI82915JhIrTekhJYe2ImvTHYvp9TiUalqLlwGH0NhPmAKsSWgio2p+kkaoMSxYL9+rLM+ruEjoBqD0RV0Mgs6h4Tq+0QKdw8STvmkSe42zs/zG2mPhXHOMirw9VJg14+vMC+LMv/1k4HgVBMgMrTB8WsjSW9j69J5/1gU8m6uYgZPNvDxLD2xGVKnZzr2PgAvjCQu/1YbfiosaTenOC5UlB05EPy7nxOkoe4KS/iQWLSHYDmoolBrcUa3sI9h3mTKF5OKYpswoJDUocFuNlqbYowJVFiZGXyXsuQl0/iJGW5j9Xuhn0ILs3PBWJybbciAIJtYCBbNnJW/ULMPg== 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=edMHAWyQzjT+UrVKcBcHR0zwLXPV5f2aU2QI0nnetKs=; b=ZiHO+OHzTViVrsOqn5Dk97LONe85hChJD1w+vGBAI41TLoz9PujLYCZPS72X9AX18UIu2i1HF4Kaxdq6pbn2sbbB/ZIHUuEpKthux5TsxOeVDHYAgFaU7zm+WmvgJxVU7zOFBKnqktJPNS7nQ6QFBd6P0E5PyQS8nbm3hvsaCINKbOZxqNM81CwIZqEqTpOeGVWt/aeWyRw1j8j/LqOlv1CKh3WbxXbc6943EEoSu3goy+9YEFmIdY3afec56J4Huv2xqLfJ+XKq0SUr3KCHcgF+ilma5Dx0jVsRhZWZmDWmB9txYKQlF0aI72csCy0VkMQi8xnQ4nReefv8LghlFA== 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=edMHAWyQzjT+UrVKcBcHR0zwLXPV5f2aU2QI0nnetKs=; b=qzPuiSFtuJD81JCvP0hdNkeqGhwxH+FgFE+cKPsJeGjqX/Tk/ktk9F0yV1hcQd7/IOv4u0jHzpozeqcEhFRrKgfz2DzE6JRUTc6R6TdYGLvTCPUOa0hdrA/BVk0hKB9iFsJgeZzPsFPkgQq8MLSY4YyhTbJg2C+dysmYg+1rvSVNpBpcWKX4qNDqASL2eRDWMSDCRuuDCX6ks56f7F4PYOWHTA8AyGw1xiNtjkMiJi9pu3Ii7yePlxGbp5a1vhlj3oj7vZcCfsIer9ZKq7FqtCweF8R0JoiUfPccpbytMU1TihUytVRAd3dI2NEo8QEWeKgkkInydayrIHqjWfQuoQ== Received: from DM5PR08CA0044.namprd08.prod.outlook.com (2603:10b6:4:60::33) by MN2PR12MB4336.namprd12.prod.outlook.com (2603:10b6:208:1df::9) 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:50:36 +0000 Received: from DS2PEPF00003442.namprd04.prod.outlook.com (2603:10b6:4:60:cafe::cc) by DM5PR08CA0044.outlook.office365.com (2603:10b6:4:60::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.19 via Frontend Transport; Wed, 25 Oct 2023 09:50:35 +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 DS2PEPF00003442.mail.protection.outlook.com (10.167.17.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.18 via Frontend Transport; Wed, 25 Oct 2023 09:50:35 +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:50:23 -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:50:21 -0700 From: Rongwei Liu To: , , , , , Subject: [PATCH v7] net/mlx5: add test for live migration Date: Wed, 25 Oct 2023 12:50:04 +0300 Message-ID: <20231025095004.1345157-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: DS2PEPF00003442:EE_|MN2PR12MB4336:EE_ X-MS-Office365-Filtering-Correlation-Id: febebe46-36d5-4b08-a475-08dbd53fd641 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: iXUn2mKSL/AdwFcluw5Ltv03KYsI0mlFYFba9ee7zPAl3DwdtaaSoGhKZrAbZnKAUo61lWz2lpU8lYuy0NTpBTH1ldxtWrpMKKdZYassxcKQ6Xt6Vx9vbKCPvInWk38TGW7Ef4pvbq2IhOeatarkoYhhoOv6/fFsAQpgs8Ff1X8/m7BjI4/nxxUND9N2b/Zuh9MO2/I7YlefN8gajS4qyWDlN8Fdp1Gdf2tsCGoD/blWIDXjR8BHJgoZyZ2iXhMIandQLqRHQgZFObM0ToxKpO8xiiHhk97pY/F4mhZQK0tzxKmq9FDK+jrEkQG2AO+P6BY7mfez3XLD7uTGByj6SaCuMaaZiPBuY5LXMWtttEFTlhhVlZo6aXTzEHZz4SvyyUc04bzWvgjjIhRwH0uWJTpWdxGth7lvOHAS/s0i5XcwgCpi0xp9r0xYQEeczxD5waNld1bGwT6bVItgokqT4u/pD8Yhd/s+yEhvfNG1uVGahVx5jvNLRQnse6GaDAIcRRDcTDSpa6I8E+GMWpOEb8sJv6pRC8kboHCJBTunrBCnE1BebnadYU2IGMhKRmXJQNttM3QzLbmGa3I9TDtejn4o2AN/Gz/J95SsNev98qEYu84xpXX68DVU4HZlyG14UNvc7+lxQEjs6fRSGlMVLUw3AQjucWq9BGkyNvkwmezbnmfD/1QsBkC60JXBt44p3f2yO8lLDFX94Sls0eNRPZEJ+p4rdx2pQzJa5++cWfGbiTHZ21K58tLcyc3jx5u2 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)(396003)(39860400002)(346002)(376002)(136003)(230922051799003)(451199024)(186009)(1800799009)(82310400011)(64100799003)(36840700001)(40470700004)(46966006)(16526019)(26005)(426003)(6286002)(336012)(1076003)(2616005)(40460700003)(40480700001)(47076005)(316002)(2906002)(86362001)(478600001)(70586007)(110136005)(7636003)(356005)(8676002)(82740400003)(8936002)(70206006)(5660300002)(36860700001)(41300700001)(83380400001)(36756003)(7696005)(6666004)(55016003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2023 09:50:35.5776 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: febebe46-36d5-4b08-a475-08dbd53fd641 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: DS2PEPF00003442.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4336 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..8bfe1e6efd 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