Skip to content

Commit 9fc43b5

Browse files
mosheshemesh2kuba-moo
authored andcommitted
net/mlx5: fs, add HWS to steering mode options
Add HW Steering mode to mlx5 devlink param of steering mode options. Signed-off-by: Moshe Shemesh <[email protected]> Reviewed-by: Yevgeny Kliteynik <[email protected]> Reviewed-by: Mark Bloch <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent c09cf80 commit 9fc43b5

File tree

4 files changed

+49
-16
lines changed

4 files changed

+49
-16
lines changed

Documentation/networking/devlink/mlx5.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ parameters.
5353
* ``smfs`` Software managed flow steering. In SMFS mode, the HW
5454
steering entities are created and manage through the driver without
5555
firmware intervention.
56+
* ``hmfs`` Hardware managed flow steering. In HMFS mode, the driver
57+
is configuring steering rules directly to the HW using Work Queues with
58+
a special new type of WQE (Work Queue Element).
5659

5760
SMFS mode is faster and provides better rule insertion rate compared to
5861
default DMFS mode.

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

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3535,35 +3535,42 @@ static int mlx5_fs_mode_validate(struct devlink *devlink, u32 id,
35353535
{
35363536
struct mlx5_core_dev *dev = devlink_priv(devlink);
35373537
char *value = val.vstr;
3538-
int err = 0;
3538+
u8 eswitch_mode;
35393539

3540-
if (!strcmp(value, "dmfs")) {
3540+
if (!strcmp(value, "dmfs"))
35413541
return 0;
3542-
} else if (!strcmp(value, "smfs")) {
3543-
u8 eswitch_mode;
3544-
bool smfs_cap;
35453542

3546-
eswitch_mode = mlx5_eswitch_mode(dev);
3547-
smfs_cap = mlx5_fs_dr_is_supported(dev);
3543+
if (!strcmp(value, "smfs")) {
3544+
bool smfs_cap = mlx5_fs_dr_is_supported(dev);
35483545

35493546
if (!smfs_cap) {
3550-
err = -EOPNOTSUPP;
35513547
NL_SET_ERR_MSG_MOD(extack,
35523548
"Software managed steering is not supported by current device");
3549+
return -EOPNOTSUPP;
35533550
}
3551+
} else if (!strcmp(value, "hmfs")) {
3552+
bool hmfs_cap = mlx5_fs_hws_is_supported(dev);
35543553

3555-
else if (eswitch_mode == MLX5_ESWITCH_OFFLOADS) {
3554+
if (!hmfs_cap) {
35563555
NL_SET_ERR_MSG_MOD(extack,
3557-
"Software managed steering is not supported when eswitch offloads enabled.");
3558-
err = -EOPNOTSUPP;
3556+
"Hardware steering is not supported by current device");
3557+
return -EOPNOTSUPP;
35593558
}
35603559
} else {
35613560
NL_SET_ERR_MSG_MOD(extack,
3562-
"Bad parameter: supported values are [\"dmfs\", \"smfs\"]");
3563-
err = -EINVAL;
3561+
"Bad parameter: supported values are [\"dmfs\", \"smfs\", \"hmfs\"]");
3562+
return -EINVAL;
35643563
}
35653564

3566-
return err;
3565+
eswitch_mode = mlx5_eswitch_mode(dev);
3566+
if (eswitch_mode == MLX5_ESWITCH_OFFLOADS) {
3567+
NL_SET_ERR_MSG_FMT_MOD(extack,
3568+
"Moving to %s is not supported when eswitch offloads enabled.",
3569+
value);
3570+
return -EOPNOTSUPP;
3571+
}
3572+
3573+
return 0;
35673574
}
35683575

35693576
static int mlx5_fs_mode_set(struct devlink *devlink, u32 id,
@@ -3575,6 +3582,8 @@ static int mlx5_fs_mode_set(struct devlink *devlink, u32 id,
35753582

35763583
if (!strcmp(ctx->val.vstr, "smfs"))
35773584
mode = MLX5_FLOW_STEERING_MODE_SMFS;
3585+
else if (!strcmp(ctx->val.vstr, "hmfs"))
3586+
mode = MLX5_FLOW_STEERING_MODE_HMFS;
35783587
else
35793588
mode = MLX5_FLOW_STEERING_MODE_DMFS;
35803589
dev->priv.steering->mode = mode;
@@ -3587,10 +3596,17 @@ static int mlx5_fs_mode_get(struct devlink *devlink, u32 id,
35873596
{
35883597
struct mlx5_core_dev *dev = devlink_priv(devlink);
35893598

3590-
if (dev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_SMFS)
3599+
switch (dev->priv.steering->mode) {
3600+
case MLX5_FLOW_STEERING_MODE_SMFS:
35913601
strscpy(ctx->val.vstr, "smfs", sizeof(ctx->val.vstr));
3592-
else
3602+
break;
3603+
case MLX5_FLOW_STEERING_MODE_HMFS:
3604+
strscpy(ctx->val.vstr, "hmfs", sizeof(ctx->val.vstr));
3605+
break;
3606+
default:
35933607
strscpy(ctx->val.vstr, "dmfs", sizeof(ctx->val.vstr));
3608+
}
3609+
35943610
return 0;
35953611
}
35963612

@@ -4009,6 +4025,8 @@ int mlx5_flow_namespace_set_mode(struct mlx5_flow_namespace *ns,
40094025

40104026
if (mode == MLX5_FLOW_STEERING_MODE_SMFS)
40114027
cmds = mlx5_fs_cmd_get_dr_cmds();
4028+
else if (mode == MLX5_FLOW_STEERING_MODE_HMFS)
4029+
cmds = mlx5_fs_cmd_get_hws_cmds();
40124030
else
40134031
cmds = mlx5_fs_cmd_get_fw_cmds();
40144032
if (!cmds)

drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,11 @@ static u32 mlx5_cmd_hws_get_capabilities(struct mlx5_flow_root_namespace *ns,
13441344
MLX5_FLOW_STEERING_CAP_MATCH_RANGES;
13451345
}
13461346

1347+
bool mlx5_fs_hws_is_supported(struct mlx5_core_dev *dev)
1348+
{
1349+
return mlx5hws_is_supported(dev);
1350+
}
1351+
13471352
static const struct mlx5_flow_cmds mlx5_flow_cmds_hws = {
13481353
.create_flow_table = mlx5_cmd_hws_create_flow_table,
13491354
.destroy_flow_table = mlx5_cmd_hws_destroy_flow_table,

drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,17 @@ struct mlx5_fs_hws_rule {
6060

6161
#ifdef CONFIG_MLX5_HW_STEERING
6262

63+
bool mlx5_fs_hws_is_supported(struct mlx5_core_dev *dev);
64+
6365
const struct mlx5_flow_cmds *mlx5_fs_cmd_get_hws_cmds(void);
6466

6567
#else
6668

69+
static inline bool mlx5_fs_hws_is_supported(struct mlx5_core_dev *dev)
70+
{
71+
return false;
72+
}
73+
6774
static inline const struct mlx5_flow_cmds *mlx5_fs_cmd_get_hws_cmds(void)
6875
{
6976
return NULL;

0 commit comments

Comments
 (0)