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 ED5334317C; Mon, 16 Oct 2023 11:23:23 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8959D402D6; Mon, 16 Oct 2023 11:23:23 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2047.outbound.protection.outlook.com [40.107.223.47]) by mails.dpdk.org (Postfix) with ESMTP id 6CA59402BD for ; Mon, 16 Oct 2023 11:23:21 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EK+0oWhQExctpqnJrXIop9iVg0h7fcqZrKDZYcnB0OsP6rtvM9dl7Tif/w+RGHnbNqBmWMA24ee5zDD7tXQfAAGh168dM6z/BNzuwz1xTtIiX7+VynS+4Kw6+0bcUjkgoj/raIqVgU7AmudWu8mZ++vfJihjS57beoAaMvkgCO2WD31RwF0/6aDy9qNTW0pgi8TiWCr8zxUG/8UOwinZGLoDdAF/Eu4va6+NXgl2ILsEvhS2CiCW0F5Y294yBtAuzRJ9GLHRjyzSC+OKnU1LxBke2T/pqePdGka1IgRVR40dClAcuKM0s8Xa+nbvF+wzlIsmyeR+RvScgttgezwm9A== 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=Dc8qvgxeJHccqxWSfZJ2rbfK8c05P89w2GYBHJvZU2g=; b=Uz5WnTkgcckPeRfPO69Y1TdpiY4xvzV2+1/5gVLDvMFsvi2746Pq52iUGT15SWl4fof7f+f9fl25mYXnB4MflHZtRlVsGmDZvMCwnqbjidT+MuhchpxWFpo/Dp5gLsSkJXjaN90I/j3FiSzf/ye0ccXGyX0AmaT94JAutDfGmynDuIqOdfwS9ODJbqtqQ247Vt1jGkNqqlOGvKI82aS6htf9vfPKkyohgrkcEU8ctllUx46VQGm+TpXP91VHDVUPdes/XwsmKEPcLRUXelz/zzgnVCfncAkgsxWEZgznEcWMxS4CMQT0U2Y1LaD1yXNVGASYAmz1n3VwSAujRepkOw== 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=Dc8qvgxeJHccqxWSfZJ2rbfK8c05P89w2GYBHJvZU2g=; b=f9p/kJ7DKukO1hp7G1bOt55q7R34AFig734jijxQ+dhiCY76ujQuYqcyFToa2YZA7Lg5cqXBpMi+xhjtrScsI3QH5FDOZutrCRRwya5FLT5fzq35dc8oqDL881IRWPpt3GWKREiofi8ax4S21HoB2fQrdYyp/AppK/TnbNGInOOhBdJk27luIh5oM510RRZDk/nyao2ggTmCa2Vn5a/a4CmfojZjvm/XXj4U1shqJ6GlR3vLTsCmzvPfs8WglOQlK1TTGsHCEfkMwCSDLX1EKqsbC+d/Ps/COjWDW1bFndSq85xRp3EWB0/OWyLU/zxxtgIe9zwUPXUGJIzTsRma3Q== Received: from DM6PR03CA0056.namprd03.prod.outlook.com (2603:10b6:5:100::33) by BL1PR12MB5159.namprd12.prod.outlook.com (2603:10b6:208:318::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Mon, 16 Oct 2023 09:23:18 +0000 Received: from DS1PEPF0001708F.namprd03.prod.outlook.com (2603:10b6:5:100:cafe::c5) by DM6PR03CA0056.outlook.office365.com (2603:10b6:5:100::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.35 via Frontend Transport; Mon, 16 Oct 2023 09:23:18 +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 DS1PEPF0001708F.mail.protection.outlook.com (10.167.17.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.22 via Frontend Transport; Mon, 16 Oct 2023 09:23:18 +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; Mon, 16 Oct 2023 02:22:53 -0700 Received: from nvidia.com (10.126.230.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; Mon, 16 Oct 2023 02:22:50 -0700 From: Rongwei Liu To: , , , , , Subject: [PATCH v4] net/mlx5: add test for live migration Date: Mon, 16 Oct 2023 12:22:12 +0300 Message-ID: <20231016092212.366889-1-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <2649876.Isy0gbHreE@thomas> References: <2649876.Isy0gbHreE@thomas> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] 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: DS1PEPF0001708F:EE_|BL1PR12MB5159:EE_ X-MS-Office365-Filtering-Correlation-Id: 17c3cf92-8297-4da7-2b25-08dbce2988be 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: WyoKyLrQDMdE+E+3JgB90Z9iSY6WsNKPe3caBed/ReyRnEXw/ivBjU81JTtzzRWovGW6YHRfpzqB4Wsgp84FYyLkPhbC1o3oDGnkphb2O/7WrKKj18DpW4h1IvHY4V6NrP4RLPCSmXZ2sYxt0oMmL1cUlcc3g8ezBTxhBiIXSuNXsQ68Ir7ifkpL8Idx8CeC45fRz5mjf0aZ20dNA7t+B42mwZhNIXSqE04mS8/sOqLjA6imPgPnSYRzHKASK2NbXOyYNgn5erxGHB2KjZ7QtKO7npLFCK4mVUmNG6EWS5/FgchXPs7wPA257K4nQOT0Lhl1IqtJBRN088BoxgqmjAz3fFjAk3lvpNMwbMOMZnqnik5GZwlcBxxovoZDL3hn4uIO1TMQ/Q118fNKEbUk1aorvBswBQiNYFuHSxUCUeYDEyUXmE1x7UFtas0LgdG9g5hIUSNs8dq+Sejj6uXSJzQu8sn1XdxZf3q5AoYnFH6IF4geNrfVCeFEXTsC9tepWJ4jwTYE5z3DKtv2oeexrYM//CWHrOUY0TGi0eJEU3WBsC3yNahOXSlqN4delggay4xPN9+f1frBBjeAkvlB8IIoE4xtWxkONSQps+1yjKFKJlJvGQMWF/XbBTARtOlAgW13YC+qYCr8MXjCKuogIPyhRrWGAIGO8k5k436rC84G7pV4oS9r/LJB5mAhiNgnXroKBbvYRqk1AexqRsvpK4SilFr6dosxOrM9mq3ExarRappjL8KOMQyprJclhuGR 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)(1800799009)(186009)(82310400011)(451199024)(64100799003)(46966006)(36840700001)(40470700004)(40460700003)(55016003)(426003)(336012)(16526019)(6286002)(26005)(1076003)(2616005)(36860700001)(83380400001)(47076005)(110136005)(70206006)(70586007)(8676002)(8936002)(316002)(6666004)(41300700001)(7696005)(5660300002)(478600001)(2906002)(82740400003)(356005)(7636003)(40480700001)(86362001)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2023 09:23:18.4796 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 17c3cf92-8297-4da7-2b25-08dbce2988be 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: DS1PEPF0001708F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5159 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 and in bitmap style. Signed-off-by: Rongwei Liu Acked-by: Viacheslav Ovsiienko Acked-by: Ori Kam --- 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..5921d40e17 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 or standby mode with specific flags (bitmap style):: + +.. 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