@@ -3535,35 +3535,42 @@ static int mlx5_fs_mode_validate(struct devlink *devlink, u32 id,
3535
3535
{
3536
3536
struct mlx5_core_dev * dev = devlink_priv (devlink );
3537
3537
char * value = val .vstr ;
3538
- int err = 0 ;
3538
+ u8 eswitch_mode ;
3539
3539
3540
- if (!strcmp (value , "dmfs" )) {
3540
+ if (!strcmp (value , "dmfs" ))
3541
3541
return 0 ;
3542
- } else if (!strcmp (value , "smfs" )) {
3543
- u8 eswitch_mode ;
3544
- bool smfs_cap ;
3545
3542
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 );
3548
3545
3549
3546
if (!smfs_cap ) {
3550
- err = - EOPNOTSUPP ;
3551
3547
NL_SET_ERR_MSG_MOD (extack ,
3552
3548
"Software managed steering is not supported by current device" );
3549
+ return - EOPNOTSUPP ;
3553
3550
}
3551
+ } else if (!strcmp (value , "hmfs" )) {
3552
+ bool hmfs_cap = mlx5_fs_hws_is_supported (dev );
3554
3553
3555
- else if (eswitch_mode == MLX5_ESWITCH_OFFLOADS ) {
3554
+ if (! hmfs_cap ) {
3556
3555
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 ;
3559
3558
}
3560
3559
} else {
3561
3560
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 ;
3564
3563
}
3565
3564
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 ;
3567
3574
}
3568
3575
3569
3576
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,
3575
3582
3576
3583
if (!strcmp (ctx -> val .vstr , "smfs" ))
3577
3584
mode = MLX5_FLOW_STEERING_MODE_SMFS ;
3585
+ else if (!strcmp (ctx -> val .vstr , "hmfs" ))
3586
+ mode = MLX5_FLOW_STEERING_MODE_HMFS ;
3578
3587
else
3579
3588
mode = MLX5_FLOW_STEERING_MODE_DMFS ;
3580
3589
dev -> priv .steering -> mode = mode ;
@@ -3587,10 +3596,17 @@ static int mlx5_fs_mode_get(struct devlink *devlink, u32 id,
3587
3596
{
3588
3597
struct mlx5_core_dev * dev = devlink_priv (devlink );
3589
3598
3590
- if (dev -> priv .steering -> mode == MLX5_FLOW_STEERING_MODE_SMFS )
3599
+ switch (dev -> priv .steering -> mode ) {
3600
+ case MLX5_FLOW_STEERING_MODE_SMFS :
3591
3601
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 :
3593
3607
strscpy (ctx -> val .vstr , "dmfs" , sizeof (ctx -> val .vstr ));
3608
+ }
3609
+
3594
3610
return 0 ;
3595
3611
}
3596
3612
@@ -4009,6 +4025,8 @@ int mlx5_flow_namespace_set_mode(struct mlx5_flow_namespace *ns,
4009
4025
4010
4026
if (mode == MLX5_FLOW_STEERING_MODE_SMFS )
4011
4027
cmds = mlx5_fs_cmd_get_dr_cmds ();
4028
+ else if (mode == MLX5_FLOW_STEERING_MODE_HMFS )
4029
+ cmds = mlx5_fs_cmd_get_hws_cmds ();
4012
4030
else
4013
4031
cmds = mlx5_fs_cmd_get_fw_cmds ();
4014
4032
if (!cmds )
0 commit comments