Skip to content

Commit 0e53582

Browse files
Saeed MahameedPaolo Abeni
authored andcommitted
devlink: Introduce switchdev_inactive eswitch mode
Adds DEVLINK_ESWITCH_MODE_SWITCHDEV_INACTIVE attribute to UAPI and documentation. 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. switchdev modes transition semantics: legacy->switchdev_inactive: Create switchdev mode normally, traffic not allowed to flow yet. switchdev_inactive->switchdev: Enable traffic to flow. switchdev->switchdev_inactive: Block traffic on the FDB, FDB and representros state and content is preserved. When eswitch is configured to this mode, traffic is ignored/dropped on this eswitch FDB, while current configuration is kept, e.g FDB rules and netdev representros are kept available, FDB programming is allowed. Example: # start inactive switchdev devlink dev eswitch set pci/0000:08:00.1 mode switchdev_inactive # setup TC rules, representors etc .. # activate devlink dev eswitch set pci/0000:08:00.1 mode switchdev Signed-off-by: Saeed Mahameed <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 8180c4f commit 0e53582

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
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

include/uapi/linux/devlink.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ enum devlink_sb_threshold_type {
181181
enum devlink_eswitch_mode {
182182
DEVLINK_ESWITCH_MODE_LEGACY,
183183
DEVLINK_ESWITCH_MODE_SWITCHDEV,
184+
DEVLINK_ESWITCH_MODE_SWITCHDEV_INACTIVE,
184185
};
185186

186187
enum devlink_eswitch_inline_mode {

net/devlink/netlink_gen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ static const struct nla_policy devlink_eswitch_get_nl_policy[DEVLINK_ATTR_DEV_NA
229229
static const struct nla_policy devlink_eswitch_set_nl_policy[DEVLINK_ATTR_ESWITCH_ENCAP_MODE + 1] = {
230230
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
231231
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
232-
[DEVLINK_ATTR_ESWITCH_MODE] = NLA_POLICY_MAX(NLA_U16, 1),
232+
[DEVLINK_ATTR_ESWITCH_MODE] = NLA_POLICY_MAX(NLA_U16, 2),
233233
[DEVLINK_ATTR_ESWITCH_INLINE_MODE] = NLA_POLICY_MAX(NLA_U8, 3),
234234
[DEVLINK_ATTR_ESWITCH_ENCAP_MODE] = NLA_POLICY_MAX(NLA_U8, 1),
235235
};

0 commit comments

Comments
 (0)