Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/mlx5: Handle "enable_roce" devlink param

Register "enable_roce" param, default value is RoCE enabled.
Current configuration is stored on mlx5_core_dev and exposed to user
through the cmode runtime devlink param.
Changing configuration requires changing the cmode driverinit devlink
param and calling devlink reload.

Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>

authored by

Michael Guralnik and committed by
Saeed Mahameed
cc9defcb e90cde0d

+59
+21
Documentation/networking/device_drivers/mellanox/mlx5.rst
··· 154 154 values: 155 155 cmode runtime value smfs 156 156 157 + enable_roce: RoCE enablement state 158 + ---------------------------------- 159 + RoCE enablement state controls driver support for RoCE traffic. 160 + When RoCE is disabled, there is no gid table, only raw ethernet QPs are supported and traffic on the well known UDP RoCE port is handled as raw ethernet traffic. 161 + 162 + To change RoCE enablement state a user must change the driverinit cmode value and run devlink reload. 163 + 164 + User command examples: 165 + 166 + - Disable RoCE:: 167 + 168 + $ devlink dev param set pci/0000:06:00.0 name enable_roce value false cmode driverinit 169 + $ devlink dev reload pci/0000:06:00.0 170 + 171 + - Read RoCE enablement state:: 172 + 173 + $ devlink dev param show pci/0000:06:00.0 name enable_roce 174 + pci/0000:06:00.0: 175 + name enable_roce type generic 176 + values: 177 + cmode driverinit value true 157 178 158 179 Devlink health reporters 159 180 ========================
+22
drivers/net/ethernet/mellanox/mlx5/core/devlink.c
··· 177 177 MLX5_DEVLINK_PARAM_FLOW_STEERING_MODE, 178 178 }; 179 179 180 + static int mlx5_devlink_enable_roce_validate(struct devlink *devlink, u32 id, 181 + union devlink_param_value val, 182 + struct netlink_ext_ack *extack) 183 + { 184 + struct mlx5_core_dev *dev = devlink_priv(devlink); 185 + bool new_state = val.vbool; 186 + 187 + if (new_state && !MLX5_CAP_GEN(dev, roce)) { 188 + NL_SET_ERR_MSG_MOD(extack, "Device doesn't support RoCE"); 189 + return -EOPNOTSUPP; 190 + } 191 + 192 + return 0; 193 + } 194 + 180 195 static const struct devlink_param mlx5_devlink_params[] = { 181 196 DEVLINK_PARAM_DRIVER(MLX5_DEVLINK_PARAM_FLOW_STEERING_MODE, 182 197 "flow_steering_mode", DEVLINK_PARAM_TYPE_STRING, 183 198 BIT(DEVLINK_PARAM_CMODE_RUNTIME), 184 199 mlx5_devlink_fs_mode_get, mlx5_devlink_fs_mode_set, 185 200 mlx5_devlink_fs_mode_validate), 201 + DEVLINK_PARAM_GENERIC(ENABLE_ROCE, BIT(DEVLINK_PARAM_CMODE_DRIVERINIT), 202 + NULL, NULL, mlx5_devlink_enable_roce_validate), 186 203 }; 187 204 188 205 static void mlx5_devlink_set_params_init_values(struct devlink *devlink) ··· 213 196 strcpy(value.vstr, "smfs"); 214 197 devlink_param_driverinit_value_set(devlink, 215 198 MLX5_DEVLINK_PARAM_FLOW_STEERING_MODE, 199 + value); 200 + 201 + value.vbool = MLX5_CAP_GEN(dev, roce); 202 + devlink_param_driverinit_value_set(devlink, 203 + DEVLINK_PARAM_GENERIC_ID_ENABLE_ROCE, 216 204 value); 217 205 } 218 206
+11
include/linux/mlx5/driver.h
··· 1191 1191 MLX5_TRIGGERED_CMD_COMP = (u64)1 << 32, 1192 1192 }; 1193 1193 1194 + static inline bool mlx5_is_roce_enabled(struct mlx5_core_dev *dev) 1195 + { 1196 + struct devlink *devlink = priv_to_devlink(dev); 1197 + union devlink_param_value val; 1198 + 1199 + devlink_param_driverinit_value_get(devlink, 1200 + DEVLINK_PARAM_GENERIC_ID_ENABLE_ROCE, 1201 + &val); 1202 + return val.vbool; 1203 + } 1204 + 1194 1205 #endif /* MLX5_DRIVER_H */