Skip to content

Commit 21f43f4

Browse files
author
Paolo Abeni
committed
Merge branch 'devlink-eswitch-inactive-mode'
Saeed Mahameed says: ==================== devlink eswitch inactive mode Before having traffic flow through an eswitch, a user may want to have the ability to block traffic towards the FDB until FDB is fully programmed and the user is ready to send traffic to it. For example: when two eswitches are present for vports in a multi-PF setup, one eswitch may take over the traffic from the other when the user chooses. Before this take over, a user may want to first program the inactive eswitch and then once ready redirect traffic to this new eswitch. This series introduces a user-configurable mode for an eswitch that allows dynamically switching between active and inactive modes. When inactive, traffic does not flow through the eswitch. While inactive, steering pipeline configuration can be done (e.g. adding TC rules, discovering representors, enabling the desired SDN modes such as bridge/OVS/DPDK/etc). Once configuration is completed, a user can set the eswitch mode to active and have traffic flow through. This allows admins to upgrade forwarding pipeline rules with very minimal downtime and packet drops. A user can start the eswitch in switchdev or switchdev_inactive mode. Active: Traffic is enabled on this eswitch FDB. Inactive: Traffic is ignored/dropped on this eswitch FDB. An example use case: $ devlink dev eswitch set pci/0000:08:00.1 mode switchdev_inactive Setup FDB pipeline and netdev representors ... Once ready to start receiving traffic $ devlink dev eswitch set pci/0000:08:00.1 mode switchdev v2: https://lore.kernel.org/all/[email protected]/ v1: https://lore.kernel.org/all/[email protected]/ ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 8180c4f + 9da611d commit 21f43f4

File tree

11 files changed

+338
-39
lines changed

11 files changed

+338
-39
lines changed

Documentation/netlink/specs/devlink.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ definitions:
9999
name: legacy
100100
-
101101
name: switchdev
102+
-
103+
name: switchdev-inactive
102104
-
103105
type: enum
104106
name: eswitch-inline-mode

Documentation/networking/devlink/devlink-eswitch-attr.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ The following is a list of E-Switch attributes.
3939
rules.
4040
* ``switchdev`` allows for more advanced offloading capabilities of
4141
the E-Switch to hardware.
42+
* ``switchdev_inactive`` switchdev mode but starts inactive, doesn't allow traffic
43+
until explicitly activated. This mode is useful for orchestrators that
44+
want to prepare the device in switchdev mode but only activate it when
45+
all configurations are done.
4246
* - ``inline-mode``
4347
- enum
4448
- Some HWs need the VF driver to put part of the packet
@@ -74,3 +78,12 @@ Example Usage
7478
7579
# enable encap-mode with legacy mode
7680
$ devlink dev eswitch set pci/0000:08:00.0 mode legacy inline-mode none encap-mode basic
81+
82+
# start switchdev mode in inactive state
83+
$ devlink dev eswitch set pci/0000:08:00.0 mode switchdev_inactive
84+
85+
# setup switchdev configurations, representors, FDB entries, etc..
86+
...
87+
88+
# activate switchdev mode to allow traffic
89+
$ devlink dev eswitch set pci/0000:08:00.0 mode switchdev

drivers/net/ethernet/mellanox/mlx5/core/esw/adj_vport.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,8 @@
44
#include "fs_core.h"
55
#include "eswitch.h"
66

7-
enum {
8-
MLX5_ADJ_VPORT_DISCONNECT = 0x0,
9-
MLX5_ADJ_VPORT_CONNECT = 0x1,
10-
};
11-
12-
static int mlx5_esw_adj_vport_modify(struct mlx5_core_dev *dev,
13-
u16 vport, bool connect)
7+
int mlx5_esw_adj_vport_modify(struct mlx5_core_dev *dev, u16 vport,
8+
bool connect)
149
{
1510
u32 in[MLX5_ST_SZ_DW(modify_vport_state_in)] = {};
1611

@@ -24,7 +19,7 @@ static int mlx5_esw_adj_vport_modify(struct mlx5_core_dev *dev,
2419
MLX5_SET(modify_vport_state_in, in, egress_connect_valid, 1);
2520
MLX5_SET(modify_vport_state_in, in, ingress_connect, connect);
2621
MLX5_SET(modify_vport_state_in, in, egress_connect, connect);
27-
22+
MLX5_SET(modify_vport_state_in, in, admin_state, connect);
2823
return mlx5_cmd_exec_in(dev, modify_vport_state, in);
2924
}
3025

@@ -96,7 +91,6 @@ static int mlx5_esw_adj_vport_create(struct mlx5_eswitch *esw, u16 vhca_id,
9691
if (err)
9792
goto acl_ns_remove;
9893

99-
mlx5_esw_adj_vport_modify(esw->dev, vport_num, MLX5_ADJ_VPORT_CONNECT);
10094
return 0;
10195

10296
acl_ns_remove:
@@ -117,8 +111,7 @@ static void mlx5_esw_adj_vport_destroy(struct mlx5_eswitch *esw,
117111

118112
esw_debug(esw->dev, "Destroying adjacent vport %d for vhca_id 0x%x\n",
119113
vport_num, vport->vhca_id);
120-
mlx5_esw_adj_vport_modify(esw->dev, vport_num,
121-
MLX5_ADJ_VPORT_DISCONNECT);
114+
122115
mlx5_esw_offloads_rep_remove(esw, vport);
123116
mlx5_fs_vport_egress_acl_ns_remove(esw->dev->priv.steering,
124117
vport->index);

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ struct mlx5_eswitch_fdb {
264264

265265
struct offloads_fdb {
266266
struct mlx5_flow_namespace *ns;
267+
struct mlx5_flow_table *drop_root;
268+
struct mlx5_flow_handle *drop_root_rule;
269+
struct mlx5_fc *drop_root_fc;
267270
struct mlx5_flow_table *tc_miss_table;
268271
struct mlx5_flow_table *slow_fdb;
269272
struct mlx5_flow_group *send_to_vport_grp;
@@ -392,6 +395,7 @@ struct mlx5_eswitch {
392395
struct mlx5_esw_offload offloads;
393396
u32 last_vport_idx;
394397
int mode;
398+
bool offloads_inactive;
395399
u16 manager_vport;
396400
u16 first_host_vport;
397401
u8 num_peers;
@@ -634,6 +638,8 @@ const u32 *mlx5_esw_query_functions(struct mlx5_core_dev *dev);
634638

635639
void mlx5_esw_adjacent_vhcas_setup(struct mlx5_eswitch *esw);
636640
void mlx5_esw_adjacent_vhcas_cleanup(struct mlx5_eswitch *esw);
641+
int mlx5_esw_adj_vport_modify(struct mlx5_core_dev *dev, u16 vport,
642+
bool connect);
637643

638644
#define MLX5_DEBUG_ESWITCH_MASK BIT(3)
639645

0 commit comments

Comments
 (0)