Skip to content

Commit e890acd

Browse files
Maor GottliebSaeed Mahameed
Maor Gottlieb
authored and
Saeed Mahameed
committed
net/mlx5: Add devlink flow_steering_mode parameter
Add new parameter (flow_steering_mode) to control the flow steering mode of the driver. Two modes are supported: 1. DMFS - Device managed flow steering 2. SMFS - Software/Driver managed flow steering. In the DMFS mode, the HW steering entities are created through the FW. In the SMFS mode this entities are created though the driver directly. The driver will use the devlink steering mode only if the steering domain supports it, for now SMFS will manages only the switchdev eswitch steering domain. User command examples: - Set SMFS flow steering mode:: $ devlink dev param set pci/0000:06:00.0 name flow_steering_mode value "smfs" cmode runtime - Read device flow steering mode:: $ devlink dev param show pci/0000:06:00.0 name flow_steering_mode pci/0000:06:00.0: name flow_steering_mode type driver-specific values: cmode runtime value smfs Signed-off-by: Maor Gottlieb <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 8463daf commit e890acd

File tree

2 files changed

+144
-1
lines changed
  • Documentation/networking/device_drivers/mellanox
  • drivers/net/ethernet/mellanox/mlx5/core

2 files changed

+144
-1
lines changed

Documentation/networking/device_drivers/mellanox/mlx5.rst

+33
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Contents
1111

1212
- `Enabling the driver and kconfig options`_
1313
- `Devlink info`_
14+
- `Devlink parameters`_
1415
- `Devlink health reporters`_
1516
- `mlx5 tracepoints`_
1617

@@ -122,6 +123,38 @@ User command example::
122123
stored:
123124
fw.version 16.26.0100
124125

126+
Devlink parameters
127+
==================
128+
129+
flow_steering_mode: Device flow steering mode
130+
---------------------------------------------
131+
The flow steering mode parameter controls the flow steering mode of the driver.
132+
Two modes are supported:
133+
1. 'dmfs' - Device managed flow steering.
134+
2. 'smfs - Software/Driver managed flow steering.
135+
136+
In DMFS mode, the HW steering entities are created and managed through the
137+
Firmware.
138+
In SMFS mode, the HW steering entities are created and managed though by
139+
the driver directly into Hardware without firmware intervention.
140+
141+
SMFS mode is faster and provides better rule inserstion rate compared to default DMFS mode.
142+
143+
User command examples:
144+
145+
- Set SMFS flow steering mode::
146+
147+
$ devlink dev param set pci/0000:06:00.0 name flow_steering_mode value "smfs" cmode runtime
148+
149+
- Read device flow steering mode::
150+
151+
$ devlink dev param show pci/0000:06:00.0 name flow_steering_mode
152+
pci/0000:06:00.0:
153+
name flow_steering_mode type driver-specific
154+
values:
155+
cmode runtime value smfs
156+
157+
125158
Devlink health reporters
126159
========================
127160

drivers/net/ethernet/mellanox/mlx5/core/devlink.c

+111-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <devlink.h>
55

66
#include "mlx5_core.h"
7+
#include "fs_core.h"
78
#include "eswitch.h"
89

910
static int mlx5_devlink_flash_update(struct devlink *devlink,
@@ -107,12 +108,121 @@ void mlx5_devlink_free(struct devlink *devlink)
107108
devlink_free(devlink);
108109
}
109110

111+
static int mlx5_devlink_fs_mode_validate(struct devlink *devlink, u32 id,
112+
union devlink_param_value val,
113+
struct netlink_ext_ack *extack)
114+
{
115+
struct mlx5_core_dev *dev = devlink_priv(devlink);
116+
char *value = val.vstr;
117+
int err = 0;
118+
119+
if (!strcmp(value, "dmfs")) {
120+
return 0;
121+
} else if (!strcmp(value, "smfs")) {
122+
u8 eswitch_mode;
123+
bool smfs_cap;
124+
125+
eswitch_mode = mlx5_eswitch_mode(dev->priv.eswitch);
126+
smfs_cap = mlx5_fs_dr_is_supported(dev);
127+
128+
if (!smfs_cap) {
129+
err = -EOPNOTSUPP;
130+
NL_SET_ERR_MSG_MOD(extack,
131+
"Software managed steering is not supported by current device");
132+
}
133+
134+
else if (eswitch_mode == MLX5_ESWITCH_OFFLOADS) {
135+
NL_SET_ERR_MSG_MOD(extack,
136+
"Software managed steering is not supported when eswitch offlaods enabled.");
137+
err = -EOPNOTSUPP;
138+
}
139+
} else {
140+
NL_SET_ERR_MSG_MOD(extack,
141+
"Bad parameter: supported values are [\"dmfs\", \"smfs\"]");
142+
err = -EINVAL;
143+
}
144+
145+
return err;
146+
}
147+
148+
static int mlx5_devlink_fs_mode_set(struct devlink *devlink, u32 id,
149+
struct devlink_param_gset_ctx *ctx)
150+
{
151+
struct mlx5_core_dev *dev = devlink_priv(devlink);
152+
enum mlx5_flow_steering_mode mode;
153+
154+
if (!strcmp(ctx->val.vstr, "smfs"))
155+
mode = MLX5_FLOW_STEERING_MODE_SMFS;
156+
else
157+
mode = MLX5_FLOW_STEERING_MODE_DMFS;
158+
dev->priv.steering->mode = mode;
159+
160+
return 0;
161+
}
162+
163+
static int mlx5_devlink_fs_mode_get(struct devlink *devlink, u32 id,
164+
struct devlink_param_gset_ctx *ctx)
165+
{
166+
struct mlx5_core_dev *dev = devlink_priv(devlink);
167+
168+
if (dev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_SMFS)
169+
strcpy(ctx->val.vstr, "smfs");
170+
else
171+
strcpy(ctx->val.vstr, "dmfs");
172+
return 0;
173+
}
174+
175+
enum mlx5_devlink_param_id {
176+
MLX5_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
177+
MLX5_DEVLINK_PARAM_FLOW_STEERING_MODE,
178+
};
179+
180+
static const struct devlink_param mlx5_devlink_params[] = {
181+
DEVLINK_PARAM_DRIVER(MLX5_DEVLINK_PARAM_FLOW_STEERING_MODE,
182+
"flow_steering_mode", DEVLINK_PARAM_TYPE_STRING,
183+
BIT(DEVLINK_PARAM_CMODE_RUNTIME),
184+
mlx5_devlink_fs_mode_get, mlx5_devlink_fs_mode_set,
185+
mlx5_devlink_fs_mode_validate),
186+
};
187+
188+
static void mlx5_devlink_set_params_init_values(struct devlink *devlink)
189+
{
190+
struct mlx5_core_dev *dev = devlink_priv(devlink);
191+
union devlink_param_value value;
192+
193+
if (dev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_DMFS)
194+
strcpy(value.vstr, "dmfs");
195+
else
196+
strcpy(value.vstr, "smfs");
197+
devlink_param_driverinit_value_set(devlink,
198+
MLX5_DEVLINK_PARAM_FLOW_STEERING_MODE,
199+
value);
200+
}
201+
110202
int mlx5_devlink_register(struct devlink *devlink, struct device *dev)
111203
{
112-
return devlink_register(devlink, dev);
204+
int err;
205+
206+
err = devlink_register(devlink, dev);
207+
if (err)
208+
return err;
209+
210+
err = devlink_params_register(devlink, mlx5_devlink_params,
211+
ARRAY_SIZE(mlx5_devlink_params));
212+
if (err)
213+
goto params_reg_err;
214+
mlx5_devlink_set_params_init_values(devlink);
215+
devlink_params_publish(devlink);
216+
return 0;
217+
218+
params_reg_err:
219+
devlink_unregister(devlink);
220+
return err;
113221
}
114222

115223
void mlx5_devlink_unregister(struct devlink *devlink)
116224
{
225+
devlink_params_unregister(devlink, mlx5_devlink_params,
226+
ARRAY_SIZE(mlx5_devlink_params));
117227
devlink_unregister(devlink);
118228
}

0 commit comments

Comments
 (0)