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 EA61E431FA; Wed, 25 Oct 2023 11:37:24 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AE060402E8; Wed, 25 Oct 2023 11:37:24 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2054.outbound.protection.outlook.com [40.107.220.54]) by mails.dpdk.org (Postfix) with ESMTP id 9CEB4402C5 for ; Wed, 25 Oct 2023 11:37:22 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y0lAgESE9mI6+7/5FxGLdBis1JWRiGCPZdQ8dVtYNH0y1fdwptDdLdfgC8znw1SGsTh1R1/rOEqeC8lxSBBytQXNjJ56hYCmnDU19/ckYdd+dHAcov/AI2pAwRlxRfkXuIdJWgIYqnohZxvIjE7Amf2U1QV/0aUNsceo2+Fs76ZJHIu3pJq1LXSJ+9foFCVmSjN6l63M4n2v4hB64+TGc74GtenFXAYOoXRC0sbvYjd4mj+JP1+1GhcVQ4wUeLizeQu3dI+A2+FsRJB1qIZf+FtIdJXWNsmsDzZP/c+3/AueK1O9g8uz6V+rZ9ComyBOEGFxUKc3EJvzr6sp27o3Jg== 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=mCdkJcRcAJZn66x19B+JsTuWHqDs4G7j6cg4etMKErc=; b=PkcFh32RYnejJi+2SI7mw2oVzWbp1SGtXpAolQmeWuv6N9qAPazqmUJkoX03OQkMkv0VLQ8jRXCJ2eDPygmDMzakfuiuoV/idyYkkiZLoXvpXyrPICVRJ6YmAfrmEQlbwXybeCt+wUWisrY5ay16WsgEIQxAOvv49hBIymIWNOFJxYzyQK7llmHh07fXLUBEb5+uHYuPITh4LLqlpoRfKaLouonVAK/Z3XvJijEM5Rztx/82DF4bwUd18nrW3YpGHbZxBCAYfVc+FIM2l8IpxgZN0h62E2uHrmY1QjZgSJ/Rl/pgWVqAEEjEXQ5Fq7oIP/SgIdGxfgw81U+6vcENwg== 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=mCdkJcRcAJZn66x19B+JsTuWHqDs4G7j6cg4etMKErc=; b=d5J8Bb3DqFu2BO4Ntv7yb+3PAgdccbrd9/LCj8WkCZ2trtVke79kZVJmuMyfzQQe97jjOAcgxlCblLUC7o8h8FtdjVwkQVvxtu5x3WVuHn3Ac/PwIfcdL4QKmmAgn2DaphnYeRlz4dC6fxXq7u1WuQtvvccpKkVw/0q3LHSdJg3JBvRmIlvssbVo0gvLArT0xRyL8+yEoserTt1t2VfRu2n76S8Q8adP0ZBCOxSrj74mbEFVO/oZsB4w5oGKpMDvAFsU0kHXDhVSZi/7ck5xFC50kaX3W/g9Vs9XEtfPIKkruMzb0Ng/CPaYRyC7acM7xyBAdsCBWCXr+IrKEBjjbg== Received: from BLAPR03CA0117.namprd03.prod.outlook.com (2603:10b6:208:32a::32) by SA3PR12MB7859.namprd12.prod.outlook.com (2603:10b6:806:305::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Wed, 25 Oct 2023 09:37:20 +0000 Received: from MN1PEPF0000ECD9.namprd02.prod.outlook.com (2603:10b6:208:32a:cafe::70) by BLAPR03CA0117.outlook.office365.com (2603:10b6:208:32a::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.34 via Frontend Transport; Wed, 25 Oct 2023 09:37:20 +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 MN1PEPF0000ECD9.mail.protection.outlook.com (10.167.242.138) 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:37:20 +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; Wed, 25 Oct 2023 02:37:07 -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:37:05 -0700 From: Rongwei Liu To: , , , , , Subject: [PATCH v5] net/mlx5: add test for live migration Date: Wed, 25 Oct 2023 12:36:53 +0300 Message-ID: <20231025093653.1343875-1-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231016092212.366889-1-rongweil@nvidia.com> References: <20231016092212.366889-1-rongweil@nvidia.com> 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: MN1PEPF0000ECD9:EE_|SA3PR12MB7859:EE_ X-MS-Office365-Filtering-Correlation-Id: b76fb74e-40f1-40da-e385-08dbd53dfc34 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: I4V3u9RTasGZmsuJeoX3+9Eu8W0AAYTmGFHcIPzjFfM7dBi6qswEUphcpTZjo7l2vvuafQ3pDsqXXQdCwm1HUyuQ6GBsDayy3GjRGEJuckP7nNximVzx/lDdYnj/WL+xFsrQfNaa6l4WO1Mb4rr0bdl6grWD7AO722OS+nqAsUlkOh7Zej0PBrKNWcKSDUxF7JF/V2OJ0mfu6JGTOCgHKFyWJrvVRB/hcSLKM/frhW1dRCtYIaEdnEU/dfPMUKdFp8LFlk3WSWZpULDbGpX3XSFI4ZmCfdhbPWxt++pPCXtxDbXG7ZzUCJWf7COyncopJDkm0IbXl2QhY0cNVwhW2eikU/CPkBiODonVHBboW9UORtjO2WwilCxaVVaQsGbFnWlwEDyvhUusLC9C7D0OPF0wHJQoC40p4V7wpSxwRv4Pg2IE6sHJLlo4UWkAOt27zyf1ykBJNpC+mWJiO/UlwAIyfzOVax2ZRJ1fNDa6p6cqvhNbSiApoqGKK7CIfU6GFCZBP53COqrpFwS2smeAe3JLIPo1rcwbSuNvmHe1yC2tfEurpX7V1tHOjASQDQNP/vWKGp0AshVIPs9pBRn1eWT9e0jycB3KmBP7/9S5/w2yHZMxoC2VNgyk5xqrxexgf8KCZPNOjSX+imOk7MA72EqhnWBoGTNzlJAhbgC89a56eEQjata3SI3dMMW1wR1OlPSFwJu0h5cBmnNLTlFwnfViW/y77H07GgijeveIygDlStxGPJEBD+Ny/hd9Exfq 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)(346002)(396003)(376002)(230922051799003)(82310400011)(186009)(1800799009)(451199024)(64100799003)(46966006)(36840700001)(40470700004)(1076003)(40460700003)(55016003)(82740400003)(7636003)(8936002)(316002)(36860700001)(47076005)(26005)(110136005)(8676002)(83380400001)(70206006)(70586007)(2906002)(6666004)(7696005)(5660300002)(478600001)(41300700001)(16526019)(356005)(36756003)(86362001)(336012)(426003)(40480700001)(6286002)(2616005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2023 09:37:20.2071 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b76fb74e-40f1-40da-e385-08dbd53dfc34 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: MN1PEPF0000ECD9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7859 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..412a967c68 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 detailed flags 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