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

net/mlx5: Let user configure io_eq_size param

Currently, each I/O EQ is taking 128KB of memory. This size
is not needed in all use cases, and is critical with large scale.
Hence, allow user to configure the size of I/O EQs.

For example, to reduce I/O EQ size to 64, execute:
$ devlink dev param set pci/0000:00:0b.0 name io_eq_size value 64 \
cmode driverinit
$ devlink dev reload pci/0000:00:0b.0

Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>

authored by

Shay Drory and committed by
Saeed Mahameed
0844fa5f 47402385

+35 -1
+4
Documentation/networking/devlink/mlx5.rst
··· 14 14 15 15 * - Name 16 16 - Mode 17 + - Validation 17 18 * - ``enable_roce`` 18 19 - driverinit 20 + * - ``io_eq_size`` 21 + - driverinit 22 + - The range is between 64 and 4096. 19 23 20 24 The ``mlx5`` driver also implements the following driver-specific 21 25 parameters.
+14
drivers/net/ethernet/mellanox/mlx5/core/devlink.c
··· 546 546 return 0; 547 547 } 548 548 549 + static int mlx5_devlink_eq_depth_validate(struct devlink *devlink, u32 id, 550 + union devlink_param_value val, 551 + struct netlink_ext_ack *extack) 552 + { 553 + return (val.vu16 >= 64 && val.vu16 <= 4096) ? 0 : -EINVAL; 554 + } 555 + 549 556 static const struct devlink_param mlx5_devlink_params[] = { 550 557 DEVLINK_PARAM_DRIVER(MLX5_DEVLINK_PARAM_ID_FLOW_STEERING_MODE, 551 558 "flow_steering_mode", DEVLINK_PARAM_TYPE_STRING, ··· 577 570 DEVLINK_PARAM_GENERIC(ENABLE_REMOTE_DEV_RESET, BIT(DEVLINK_PARAM_CMODE_RUNTIME), 578 571 mlx5_devlink_enable_remote_dev_reset_get, 579 572 mlx5_devlink_enable_remote_dev_reset_set, NULL), 573 + DEVLINK_PARAM_GENERIC(IO_EQ_SIZE, BIT(DEVLINK_PARAM_CMODE_DRIVERINIT), 574 + NULL, NULL, mlx5_devlink_eq_depth_validate), 580 575 }; 581 576 582 577 static void mlx5_devlink_set_params_init_values(struct devlink *devlink) ··· 617 608 value); 618 609 } 619 610 #endif 611 + 612 + value.vu32 = MLX5_COMP_EQ_SIZE; 613 + devlink_param_driverinit_value_set(devlink, 614 + DEVLINK_PARAM_GENERIC_ID_IO_EQ_SIZE, 615 + value); 620 616 } 621 617 622 618 static const struct devlink_param enable_eth_param =
+17 -1
drivers/net/ethernet/mellanox/mlx5/core/eq.c
··· 19 19 #include "lib/clock.h" 20 20 #include "diag/fw_tracer.h" 21 21 #include "mlx5_irq.h" 22 + #include "devlink.h" 22 23 23 24 enum { 24 25 MLX5_EQE_OWNER_INIT_VAL = 0x1, ··· 797 796 } 798 797 } 799 798 799 + static u16 comp_eq_depth_devlink_param_get(struct mlx5_core_dev *dev) 800 + { 801 + struct devlink *devlink = priv_to_devlink(dev); 802 + union devlink_param_value val; 803 + int err; 804 + 805 + err = devlink_param_driverinit_value_get(devlink, 806 + DEVLINK_PARAM_GENERIC_ID_IO_EQ_SIZE, 807 + &val); 808 + if (!err) 809 + return val.vu32; 810 + mlx5_core_dbg(dev, "Failed to get param. using default. err = %d\n", err); 811 + return MLX5_COMP_EQ_SIZE; 812 + } 813 + 800 814 static int create_comp_eqs(struct mlx5_core_dev *dev) 801 815 { 802 816 struct mlx5_eq_table *table = dev->priv.eq_table; ··· 823 807 824 808 INIT_LIST_HEAD(&table->comp_eqs_list); 825 809 ncomp_eqs = table->num_comp_eqs; 826 - nent = MLX5_COMP_EQ_SIZE; 810 + nent = comp_eq_depth_devlink_param_get(dev); 827 811 for (i = 0; i < ncomp_eqs; i++) { 828 812 struct mlx5_eq_param param = {}; 829 813 int vecidx = i;