Skip to contentSkip to conversation

net/mlx5: support live migration

PATCH In review Rongwei Liu 2 participants 2 messages Feb 15, 2023 – Feb 26, 2023 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 net/mlx5: support live migration

When a DPDK application must be upgraded,
the traffic downtime should be shortened as much as possible. During the migration time, the old application may stay alive while the new application is starting and being configured.

In order to optimize the switch to the new application, the old application may need to be aware of the presence of the new application being prepared.
This is achieved with a new API allowing the user to change the new application state to standby and active later.

The added function is trying to apply the new mode to all probed mlx5 ports. To make this API simple and easy to use, the same flags have to be accepted by all devices.

This is the scenario of operations in the old and new applications:

.       device: already configured by the old application
.       new:    start as active
.       new:    probe the same device
.       new:    set as standby
.       new:    configure the device
.       device: has configurations from old and new applications
.       old:    clear its device configuration
.       device: has only 1 configuration from new application
.       new:    set as active
.       device: downtime for connecting all to the new application
.       old:    shutdown

The active mode means network handling configurations are programmed to the HW immediately, and no behavior changed. This is the default state. The standby mode means configurations are queued in the HW.
If there is no application with active mode,
any configuration is effective immediately.

---
 doc/guides/nics/mlx5.rst        |   8 +
 drivers/net/mlx5/mlx5.h         |  24 +++
 drivers/net/mlx5/mlx5_flow.c    | 315 +++++++++++++++++++++++++++++++-
 drivers/net/mlx5/rte_pmd_mlx5.h |  66 +++++++
 drivers/net/mlx5/version.map    |   2 +
 5 files changed, 411 insertions(+), 4 deletions(-)
doc/guides/nics/mlx5.rst +8 -0
index ee2df66e77..f232efad36 100644
@@ -612,6 +612,14 @@ Limitations
 - When using DV/verbs flow engine (``dv_flow_en`` = 1/0 respectively), Match on SPI field
   in ESP header for group 0 needs MLNX_OFED 5.6+.
 
+- During live migration to a new process set its flow engine as standby mode,
+  the user should only program flow rules in group 0 (``fdb_def_rule_en=0``).
+  Live migration is only supported under SWS (``dv_flow_en=1``).
+  The flow group 0 is shared between DPDK processes
+  while the other flow groups are limited to the current process.
+  The flow engine of a process cannot move from active to standby mode
+  if preceding active application rules are still present and vice versa.
+
 
 Statistics
 ----------
drivers/net/mlx5/mlx5.h +24 -0
index bea1f62ea8..e16ff288af 100644
@@ -33,6 +33,7 @@
 #include "mlx5_utils.h"
 #include "mlx5_os.h"
 #include "mlx5_autoconf.h"
+#include "rte_pmd_mlx5.h"
 #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
 #ifndef RTE_EXEC_ENV_WINDOWS
 #define HAVE_MLX5_HWS_SUPPORT 1
@@ -1656,6 +1657,28 @@ struct mlx5_hw_ctrl_flow {
 	struct rte_flow *flow;
 };
 
+/*
+ * Flow rule structure for flow engine mode control, focus on group 0.
+ * Apply to all supported domains.
+ */
+struct mlx5_dv_flow_info {
+	LIST_ENTRY(mlx5_dv_flow_info) next;
+	uint32_t orig_prio; /* prio set by user */
+	uint32_t flow_idx_high_prio;
+	/* flow index owned by standby mode. priority is lower unless DUP flags. */
+	uint32_t flow_idx_low_prio;
+	struct rte_flow_item *items;
+	struct rte_flow_action *actions;
+	struct rte_flow_attr attr;
+};
+
+struct mlx5_flow_engine_mode_info {
+	enum mlx5_flow_engine_mode mode;
+	uint32_t mode_flag;
+	/* The list is maintained in insertion order. */
+	LIST_HEAD(hot_up_info, mlx5_dv_flow_info) hot_upgrade;
+};
+
 struct mlx5_flow_hw_ctrl_rx;
 
 struct mlx5_priv {
@@ -1763,6 +1786,7 @@ struct mlx5_priv {
 	uint32_t nb_queue; /* HW steering queue number. */
 	struct mlx5_hws_cnt_pool *hws_cpool; /* HW steering's counter pool. */
 	uint32_t hws_mark_refcnt; /* HWS mark action reference counter. */
+	struct mlx5_flow_engine_mode_info mode_info; /* Process set flow engine info. */
 #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
 	/* Item template list. */
 	LIST_HEAD(flow_hw_itt, rte_flow_pattern_template) flow_hw_itt;
drivers/net/mlx5/mlx5_flow.c +311 -4

363 lines not on this page · raw message

drivers/net/mlx5/rte_pmd_mlx5.h +66 -0

72 lines not on this page · raw message

drivers/net/mlx5/version.map +2 -0
index 848270da13..7ef598027b 100644
@@ -15,4 +15,6 @@ EXPERIMENTAL {
 	# added in 22.07
 	rte_pmd_mlx5_host_shaper_config;
 	rte_pmd_mlx5_external_sq_enable;
+	# added in 23.03
+	rte_pmd_mlx5_flow_engine_set_mode;
 };
Signature · 1 line
2.27.0
#1 lore raw

Hi,

Quoted 37 lines

-----Original Message-----
From: Rongwei Liu <[email protected]>
Sent: Wednesday, February 15, 2023 2:04 PM
To: [email protected]; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact- Thomas Monjalon (EXTERNAL) <[email protected]>
Cc: Raslan Darawsheh <[email protected]>
Subject: [PATCH v3] net/mlx5: support live migration

When a DPDK application must be upgraded, the traffic downtime should be shortened as much as possible.
During the migration time, the old application may stay alive while the new application is starting and being configured.

In order to optimize the switch to the new application, the old application may need to be aware of the presence of the new application being prepared.
This is achieved with a new API allowing the user to change the new application state to standby and active later.

The added function is trying to apply the new mode to all probed mlx5 ports. To make this API simple and easy to use, the same flags have to be accepted by all devices.

This is the scenario of operations in the old and new applications:

.       device: already configured by the old application
.       new:    start as active
.       new:    probe the same device
.       new:    set as standby
.       new:    configure the device
.       device: has configurations from old and new applications
.       old:    clear its device configuration
.       device: has only 1 configuration from new application
.       new:    set as active
.       device: downtime for connecting all to the new application
.       old:    shutdown
Quoted 8 lines

The active mode means network handling configurations are programmed to the HW immediately, and no behavior changed. This is the default state. The standby mode means configurations are queued in the HW.
If there is no application with active mode, any configuration is effective immediately.

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh