]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
devlink: pass param values by pointer
authorRatheesh Kannoth <rkannoth@marvell.com>
Thu, 21 May 2026 09:52:57 +0000 (15:22 +0530)
committerJakub Kicinski <kuba@kernel.org>
Mon, 25 May 2026 21:03:06 +0000 (14:03 -0700)
union devlink_param_value grows substantially once U64 array
parameters are added to devlink (from 32 bytes to over 264 bytes).
devlink_nl_param_value_fill_one() and devlink_nl_param_value_put()
copy the union by value in several places. Passing two instances as
value arguments alone consumes over 528 bytes of stack; combined with
deeper call chains the parameter stack can approach 800 bytes and trip
CONFIG_FRAME_WARN more easily.

Switch internal helpers and exported driver APIs to pass pointers to
union devlink_param_value rather than passing the union by value.

Reviewed-by: Petr Machata <petrm@nvidia.com> # for mlxsw
Acked-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Arthur Kiyanovski <akiyano@amazon.com> #for ena
Signed-off-by: Ratheesh Kannoth <rkannoth@marvell.com>
Link: https://patch.msgid.link/20260521095303.2395584-4-rkannoth@marvell.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
18 files changed:
drivers/dpll/zl3073x/devlink.c
drivers/net/ethernet/amazon/ena/ena_devlink.c
drivers/net/ethernet/amd/pds_core/core.h
drivers/net/ethernet/amd/pds_core/devlink.c
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
drivers/net/ethernet/intel/ice/devlink/devlink.c
drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c
drivers/net/ethernet/mellanox/mlx4/main.c
drivers/net/ethernet/mellanox/mlx5/core/devlink.c
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c
drivers/net/ethernet/mellanox/mlxsw/core.c
drivers/net/ethernet/netronome/nfp/devlink_param.c
drivers/net/netdevsim/dev.c
include/net/devlink.h
net/devlink/param.c

index ccc22332b3463b8e1ccc9d58ad57f479a1328758..218b08fd8a3065042578b7fb053208ac93457a0a 100644 (file)
@@ -315,10 +315,10 @@ EXPORT_SYMBOL_NS_GPL(zl3073x_devm_alloc, "ZL3073X");
 
 static int
 zl3073x_devlink_param_clock_id_validate(struct devlink *devlink, u32 id,
-                                       union devlink_param_value val,
+                                       union devlink_param_value *val,
                                        struct netlink_ext_ack *extack)
 {
-       if (!val.vu64) {
+       if (!val->vu64) {
                NL_SET_ERR_MSG_MOD(extack, "'clock_id' must be non-zero");
                return -EINVAL;
        }
@@ -377,7 +377,7 @@ int zl3073x_devlink_register(struct zl3073x_dev *zldev)
        value.vu64 = zldev->clock_id;
        devl_param_driverinit_value_set(devlink,
                                        DEVLINK_PARAM_GENERIC_ID_CLOCK_ID,
-                                       value);
+                                       &value);
 
        /* Register devlink instance */
        devl_register(devlink);
index 4772185e669d29806ee4dc38b88b6be40f6812fa..5ea9fef149aa7cee91721b267b2d6b955128702c 100644 (file)
@@ -8,12 +8,12 @@
 #include "ena_phc.h"
 
 static int ena_devlink_enable_phc_validate(struct devlink *devlink, u32 id,
-                                          union devlink_param_value val,
+                                          union devlink_param_value *val,
                                           struct netlink_ext_ack *extack)
 {
        struct ena_adapter *adapter = ENA_DEVLINK_PRIV(devlink);
 
-       if (!val.vbool)
+       if (!val->vbool)
                return 0;
 
        if (!ena_com_phc_supported(adapter->ena_dev)) {
@@ -57,7 +57,7 @@ void ena_devlink_disable_phc_param(struct devlink *devlink)
        value.vbool = false;
        devl_param_driverinit_value_set(devlink,
                                        DEVLINK_PARAM_GENERIC_ID_ENABLE_PHC,
-                                       value);
+                                       &value);
        devl_unlock(devlink);
 }
 
@@ -151,7 +151,7 @@ static int ena_devlink_configure_params(struct devlink *devlink)
        value.vbool = ena_phc_is_enabled(adapter);
        devl_param_driverinit_value_set(devlink,
                                        DEVLINK_PARAM_GENERIC_ID_ENABLE_PHC,
-                                       value);
+                                       &value);
        devl_unlock(devlink);
 
        return 0;
index 4a6b35c84dabebc18393a6876e819921eb6a2b6f..b7fe9ad733498fa06b62f4cde79db5f340f8292a 100644 (file)
@@ -261,7 +261,7 @@ int pdsc_dl_enable_set(struct devlink *dl, u32 id,
                       struct devlink_param_gset_ctx *ctx,
                       struct netlink_ext_ack *extack);
 int pdsc_dl_enable_validate(struct devlink *dl, u32 id,
-                           union devlink_param_value val,
+                           union devlink_param_value *val,
                            struct netlink_ext_ack *extack);
 
 void __iomem *pdsc_map_dbpage(struct pdsc *pdsc, int page_num);
index 3f0e56b951bf0b1c959cbdf5890cb48a1e073cf7..2ea97e1c5939c0669e8b65371789a8e60dc26cbc 100644 (file)
@@ -68,7 +68,7 @@ int pdsc_dl_enable_set(struct devlink *dl, u32 id,
 }
 
 int pdsc_dl_enable_validate(struct devlink *dl, u32 id,
-                           union devlink_param_value val,
+                           union devlink_param_value *val,
                            struct netlink_ext_ack *extack)
 {
        struct pdsc *pdsc = devlink_priv(dl);
index 835f2b413931c231dad20caee3312f12fb49ed79..eb17a3454b4c747b99d8b741c6213ccd30b034e0 100644 (file)
@@ -1123,7 +1123,7 @@ static int bnxt_dl_nvm_param_set(struct devlink *dl, u32 id,
 }
 
 static int bnxt_dl_roce_validate(struct devlink *dl, u32 id,
-                                union devlink_param_value val,
+                                union devlink_param_value *val,
                                 struct netlink_ext_ack *extack)
 {
        const struct bnxt_dl_nvm_param nvm_roce_cap = {0, NVM_OFF_RDMA_CAPABLE,
@@ -1149,7 +1149,7 @@ static int bnxt_dl_roce_validate(struct devlink *dl, u32 id,
 }
 
 static int bnxt_dl_msix_validate(struct devlink *dl, u32 id,
-                                union devlink_param_value val,
+                                union devlink_param_value *val,
                                 struct netlink_ext_ack *extack)
 {
        int max_val = -1;
@@ -1160,7 +1160,7 @@ static int bnxt_dl_msix_validate(struct devlink *dl, u32 id,
        if (id == DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN)
                max_val = BNXT_MSIX_VEC_MIN_MAX;
 
-       if (val.vu32 > max_val) {
+       if (val->vu32 > max_val) {
                NL_SET_ERR_MSG_MOD(extack, "MSIX value is exceeding the range");
                return -EINVAL;
        }
index 641d6e289d5ce6e5670758751618ae5e4a9791f7..22b7d8e6bd9e8fc6f40d443cc6556249fdd3ef53 100644 (file)
@@ -671,10 +671,10 @@ static int ice_devlink_tx_sched_layers_set(struct devlink *devlink, u32 id,
  * error.
  */
 static int ice_devlink_tx_sched_layers_validate(struct devlink *devlink, u32 id,
-                                               union devlink_param_value val,
+                                               union devlink_param_value *val,
                                                struct netlink_ext_ack *extack)
 {
-       if (val.vu8 != ICE_SCHED_5_LAYERS && val.vu8 != ICE_SCHED_9_LAYERS) {
+       if (val->vu8 != ICE_SCHED_5_LAYERS && val->vu8 != ICE_SCHED_9_LAYERS) {
                NL_SET_ERR_MSG_MOD(extack,
                                   "Wrong number of tx scheduler layers provided.");
                return -EINVAL;
@@ -1398,7 +1398,7 @@ static int ice_devlink_enable_roce_set(struct devlink *devlink, u32 id,
 
 static int
 ice_devlink_enable_roce_validate(struct devlink *devlink, u32 id,
-                                union devlink_param_value val,
+                                union devlink_param_value *val,
                                 struct netlink_ext_ack *extack)
 {
        struct ice_pf *pf = devlink_priv(devlink);
@@ -1465,7 +1465,7 @@ static int ice_devlink_enable_iw_set(struct devlink *devlink, u32 id,
 
 static int
 ice_devlink_enable_iw_validate(struct devlink *devlink, u32 id,
-                              union devlink_param_value val,
+                              union devlink_param_value *val,
                               struct netlink_ext_ack *extack)
 {
        struct ice_pf *pf = devlink_priv(devlink);
@@ -1591,10 +1591,10 @@ static int ice_devlink_local_fwd_set(struct devlink *devlink, u32 id,
  * error.
  */
 static int ice_devlink_local_fwd_validate(struct devlink *devlink, u32 id,
-                                         union devlink_param_value val,
+                                         union devlink_param_value *val,
                                          struct netlink_ext_ack *extack)
 {
-       if (ice_devlink_local_fwd_str_to_mode(val.vstr) < 0) {
+       if (ice_devlink_local_fwd_str_to_mode(val->vstr) < 0) {
                NL_SET_ERR_MSG_MOD(extack, "Error: Requested value is not supported.");
                return -EINVAL;
        }
@@ -1604,12 +1604,12 @@ static int ice_devlink_local_fwd_validate(struct devlink *devlink, u32 id,
 
 static int
 ice_devlink_msix_max_pf_validate(struct devlink *devlink, u32 id,
-                                union devlink_param_value val,
+                                union devlink_param_value *val,
                                 struct netlink_ext_ack *extack)
 {
        struct ice_pf *pf = devlink_priv(devlink);
 
-       if (val.vu32 > pf->hw.func_caps.common_cap.num_msix_vectors)
+       if (val->vu32 > pf->hw.func_caps.common_cap.num_msix_vectors)
                return -EINVAL;
 
        return 0;
@@ -1617,21 +1617,21 @@ ice_devlink_msix_max_pf_validate(struct devlink *devlink, u32 id,
 
 static int
 ice_devlink_msix_min_pf_validate(struct devlink *devlink, u32 id,
-                                union devlink_param_value val,
+                                union devlink_param_value *val,
                                 struct netlink_ext_ack *extack)
 {
-       if (val.vu32 < ICE_MIN_MSIX)
+       if (val->vu32 < ICE_MIN_MSIX)
                return -EINVAL;
 
        return 0;
 }
 
 static int ice_devlink_enable_rdma_validate(struct devlink *devlink, u32 id,
-                                           union devlink_param_value val,
+                                           union devlink_param_value *val,
                                            struct netlink_ext_ack *extack)
 {
        struct ice_pf *pf = devlink_priv(devlink);
-       bool new_state = val.vbool;
+       bool new_state = val->vbool;
 
        if (new_state && !test_bit(ICE_FLAG_RDMA_ENA, pf->flags))
                return -EOPNOTSUPP;
@@ -1791,16 +1791,16 @@ int ice_devlink_register_params(struct ice_pf *pf)
        value.vu32 = pf->msix.max;
        devl_param_driverinit_value_set(devlink,
                                        DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX,
-                                       value);
+                                       &value);
        value.vu32 = pf->msix.min;
        devl_param_driverinit_value_set(devlink,
                                        DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN,
-                                       value);
+                                       &value);
 
        value.vbool = test_bit(ICE_FLAG_RDMA_ENA, pf->flags);
        devl_param_driverinit_value_set(devlink,
                                        DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA,
-                                       value);
+                                       &value);
 
        return 0;
 
index 6494a9ee2f0ddefffd87351beb5db4006bfb40a5..a42404e6db7cc26df7c6726a892dfdecc7018fce 100644 (file)
@@ -1180,12 +1180,12 @@ static void rvu_health_reporters_destroy(struct rvu *rvu)
 
 /* Devlink Params APIs */
 static int rvu_af_dl_dwrr_mtu_validate(struct devlink *devlink, u32 id,
-                                      union devlink_param_value val,
+                                      union devlink_param_value *val,
                                       struct netlink_ext_ack *extack)
 {
        struct rvu_devlink *rvu_dl = devlink_priv(devlink);
        struct rvu *rvu = rvu_dl->rvu;
-       int dwrr_mtu = val.vu32;
+       int dwrr_mtu = val->vu32;
        struct nix_txsch *txsch;
        struct nix_hw *nix_hw;
 
@@ -1295,14 +1295,14 @@ static int rvu_af_npc_defrag(struct devlink *devlink, u32 id,
 }
 
 static int rvu_af_npc_defrag_feature_validate(struct devlink *devlink, u32 id,
-                                             union devlink_param_value val,
+                                             union devlink_param_value *val,
                                              struct netlink_ext_ack *extack)
 {
        struct rvu_devlink *rvu_dl = devlink_priv(devlink);
        struct rvu *rvu = rvu_dl->rvu;
        u64 enable;
 
-       if (kstrtoull(val.vstr, 10, &enable)) {
+       if (kstrtoull(val->vstr, 10, &enable)) {
                NL_SET_ERR_MSG_MOD(extack,
                                   "Only 1 value is supported");
                return -EINVAL;
@@ -1351,14 +1351,14 @@ static int rvu_af_npc_exact_feature_disable(struct devlink *devlink, u32 id,
 }
 
 static int rvu_af_npc_exact_feature_validate(struct devlink *devlink, u32 id,
-                                            union devlink_param_value val,
+                                            union devlink_param_value *val,
                                             struct netlink_ext_ack *extack)
 {
        struct rvu_devlink *rvu_dl = devlink_priv(devlink);
        struct rvu *rvu = rvu_dl->rvu;
        u64 enable;
 
-       if (kstrtoull(val.vstr, 10, &enable)) {
+       if (kstrtoull(val->vstr, 10, &enable)) {
                NL_SET_ERR_MSG_MOD(extack,
                                   "Only 1 value is supported");
                return -EINVAL;
@@ -1414,7 +1414,7 @@ static int rvu_af_dl_npc_mcam_high_zone_percent_set(struct devlink *devlink, u32
 }
 
 static int rvu_af_dl_npc_mcam_high_zone_percent_validate(struct devlink *devlink, u32 id,
-                                                        union devlink_param_value val,
+                                                        union devlink_param_value *val,
                                                         struct netlink_ext_ack *extack)
 {
        struct rvu_devlink *rvu_dl = devlink_priv(devlink);
@@ -1422,7 +1422,7 @@ static int rvu_af_dl_npc_mcam_high_zone_percent_validate(struct devlink *devlink
        struct npc_mcam *mcam;
 
        /* The percent of high prio zone must range from 12% to 100% of unreserved mcam space */
-       if (val.vu8 < 12 || val.vu8 > 100) {
+       if (val->vu8 < 12 || val->vu8 > 100) {
                NL_SET_ERR_MSG_MOD(extack,
                                   "mcam high zone percent must be between 12% to 100%");
                return -EINVAL;
@@ -1504,7 +1504,7 @@ static int rvu_af_dl_nix_maxlf_set(struct devlink *devlink, u32 id,
 }
 
 static int rvu_af_dl_nix_maxlf_validate(struct devlink *devlink, u32 id,
-                                       union devlink_param_value val,
+                                       union devlink_param_value *val,
                                        struct netlink_ext_ack *extack)
 {
        struct rvu_devlink *rvu_dl = devlink_priv(devlink);
@@ -1528,13 +1528,13 @@ static int rvu_af_dl_nix_maxlf_validate(struct devlink *devlink, u32 id,
                return -EPERM;
        }
 
-       if (max_nix0_lf && val.vu16 > max_nix0_lf) {
+       if (max_nix0_lf && val->vu16 > max_nix0_lf) {
                NL_SET_ERR_MSG_MOD(extack,
                                   "requested nixlf is greater than the max supported nix0_lf");
                return -EPERM;
        }
 
-       if (max_nix1_lf && val.vu16 > max_nix1_lf) {
+       if (max_nix1_lf && val->vu16 > max_nix1_lf) {
                NL_SET_ERR_MSG_MOD(extack,
                                   "requested nixlf is greater than the max supported nix1_lf");
                return -EINVAL;
index a72694219df49b2dac988c3fb05ca455f6675d86..4a5ce0e67dda8251dbc18794b0282c14c6cfb9ac 100644 (file)
@@ -8,7 +8,7 @@
 
 /* Devlink Params APIs */
 static int otx2_dl_mcam_count_validate(struct devlink *devlink, u32 id,
-                                      union devlink_param_value val,
+                                      union devlink_param_value *val,
                                       struct netlink_ext_ack *extack)
 {
        struct otx2_devlink *otx2_dl = devlink_priv(devlink);
@@ -97,7 +97,7 @@ static int otx2_dl_ucast_flt_cnt_get(struct devlink *devlink, u32 id,
 }
 
 static int otx2_dl_ucast_flt_cnt_validate(struct devlink *devlink, u32 id,
-                                         union devlink_param_value val,
+                                         union devlink_param_value *val,
                                          struct netlink_ext_ack *extack)
 {
        struct otx2_devlink *otx2_dl = devlink_priv(devlink);
index 4fe6dbf0942f1f530ff37b00648aea128ba2b7c3..c851daa5da9f5c48f8028e45d8e1ebf3348b50c4 100644 (file)
@@ -213,10 +213,10 @@ static int mlx4_devlink_crdump_snapshot_set(struct devlink *devlink, u32 id,
 
 static int
 mlx4_devlink_max_macs_validate(struct devlink *devlink, u32 id,
-                              union devlink_param_value val,
+                              union devlink_param_value *val,
                               struct netlink_ext_ack *extack)
 {
-       u32 value = val.vu32;
+       u32 value = val->vu32;
 
        if (value < 1 || value > 128)
                return -ERANGE;
@@ -266,27 +266,27 @@ static void mlx4_devlink_set_params_init_values(struct devlink *devlink)
        value.vbool = !!mlx4_internal_err_reset;
        devl_param_driverinit_value_set(devlink,
                                        DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET,
-                                       value);
+                                       &value);
 
        value.vu32 = 1UL << log_num_mac;
        devl_param_driverinit_value_set(devlink,
                                        DEVLINK_PARAM_GENERIC_ID_MAX_MACS,
-                                       value);
+                                       &value);
 
        value.vbool = enable_64b_cqe_eqe;
        devl_param_driverinit_value_set(devlink,
                                        MLX4_DEVLINK_PARAM_ID_ENABLE_64B_CQE_EQE,
-                                       value);
+                                       &value);
 
        value.vbool = enable_4k_uar;
        devl_param_driverinit_value_set(devlink,
                                        MLX4_DEVLINK_PARAM_ID_ENABLE_4K_UAR,
-                                       value);
+                                       &value);
 
        value.vbool = false;
        devl_param_driverinit_value_set(devlink,
                                        DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT,
-                                       value);
+                                       &value);
 }
 
 static inline void mlx4_set_num_reserved_uars(struct mlx4_dev *dev,
index 73cf0321bb86ba1b8dd750f45d1a950aa85c5743..c31e05529fc404836d5c2d824cfb2ed0a31bf71e 100644 (file)
@@ -459,11 +459,11 @@ void mlx5_devlink_free(struct devlink *devlink)
 }
 
 static int mlx5_devlink_enable_roce_validate(struct devlink *devlink, u32 id,
-                                            union devlink_param_value val,
+                                            union devlink_param_value *val,
                                             struct netlink_ext_ack *extack)
 {
        struct mlx5_core_dev *dev = devlink_priv(devlink);
-       bool new_state = val.vbool;
+       bool new_state = val->vbool;
 
        if (new_state && !MLX5_CAP_GEN(dev, roce) &&
            !(MLX5_CAP_GEN(dev, roce_rw_supported) && MLX5_CAP_GEN_MAX(dev, roce))) {
@@ -480,10 +480,10 @@ static int mlx5_devlink_enable_roce_validate(struct devlink *devlink, u32 id,
 
 #ifdef CONFIG_MLX5_ESWITCH
 static int mlx5_devlink_large_group_num_validate(struct devlink *devlink, u32 id,
-                                                union devlink_param_value val,
+                                                union devlink_param_value *val,
                                                 struct netlink_ext_ack *extack)
 {
-       int group_num = val.vu32;
+       int group_num = val->vu32;
 
        if (group_num < 1 || group_num > 1024) {
                NL_SET_ERR_MSG_MOD(extack,
@@ -496,27 +496,27 @@ static int mlx5_devlink_large_group_num_validate(struct devlink *devlink, u32 id
 #endif
 
 static int mlx5_devlink_eq_depth_validate(struct devlink *devlink, u32 id,
-                                         union devlink_param_value val,
+                                         union devlink_param_value *val,
                                          struct netlink_ext_ack *extack)
 {
-       return (val.vu32 >= 64 && val.vu32 <= 4096) ? 0 : -EINVAL;
+       return (val->vu32 >= 64 && val->vu32 <= 4096) ? 0 : -EINVAL;
 }
 
 static int
 mlx5_devlink_hairpin_num_queues_validate(struct devlink *devlink, u32 id,
-                                        union devlink_param_value val,
+                                        union devlink_param_value *val,
                                         struct netlink_ext_ack *extack)
 {
-       return val.vu32 ? 0 : -EINVAL;
+       return val->vu32 ? 0 : -EINVAL;
 }
 
 static int
 mlx5_devlink_hairpin_queue_size_validate(struct devlink *devlink, u32 id,
-                                        union devlink_param_value val,
+                                        union devlink_param_value *val,
                                         struct netlink_ext_ack *extack)
 {
        struct mlx5_core_dev *dev = devlink_priv(devlink);
-       u32 val32 = val.vu32;
+       u32 val32 = val->vu32;
 
        if (!is_power_of_2(val32)) {
                NL_SET_ERR_MSG_MOD(extack, "Value is not power of two");
@@ -534,11 +534,11 @@ mlx5_devlink_hairpin_queue_size_validate(struct devlink *devlink, u32 id,
 }
 
 static int mlx5_devlink_num_doorbells_validate(struct devlink *devlink, u32 id,
-                                              union devlink_param_value val,
+                                              union devlink_param_value *val,
                                               struct netlink_ext_ack *extack)
 {
        struct mlx5_core_dev *mdev = devlink_priv(devlink);
-       u32 val32 = val.vu32;
+       u32 val32 = val->vu32;
        u32 max_num_channels;
 
        max_num_channels = mlx5e_get_max_num_channels(mdev);
@@ -567,13 +567,13 @@ static void mlx5_devlink_hairpin_params_init_values(struct devlink *devlink)
 
        value.vu32 = link_speed64;
        devl_param_driverinit_value_set(
-               devlink, MLX5_DEVLINK_PARAM_ID_HAIRPIN_NUM_QUEUES, value);
+               devlink, MLX5_DEVLINK_PARAM_ID_HAIRPIN_NUM_QUEUES, &value);
 
        value.vu32 =
                BIT(min_t(u32, 16 - MLX5_MPWRQ_MIN_LOG_STRIDE_SZ(dev),
                          MLX5_CAP_GEN(dev, log_max_hairpin_num_packets)));
        devl_param_driverinit_value_set(
-               devlink, MLX5_DEVLINK_PARAM_ID_HAIRPIN_QUEUE_SIZE, value);
+               devlink, MLX5_DEVLINK_PARAM_ID_HAIRPIN_QUEUE_SIZE, &value);
 }
 
 static const struct devlink_param mlx5_devlink_params[] = {
@@ -600,24 +600,24 @@ static void mlx5_devlink_set_params_init_values(struct devlink *devlink)
        value.vbool = MLX5_CAP_GEN(dev, roce) && !mlx5_dev_is_lightweight(dev);
        devl_param_driverinit_value_set(devlink,
                                        DEVLINK_PARAM_GENERIC_ID_ENABLE_ROCE,
-                                       value);
+                                       &value);
 
 #ifdef CONFIG_MLX5_ESWITCH
        value.vu32 = ESW_OFFLOADS_DEFAULT_NUM_GROUPS;
        devl_param_driverinit_value_set(devlink,
                                        MLX5_DEVLINK_PARAM_ID_ESW_LARGE_GROUP_NUM,
-                                       value);
+                                       &value);
 #endif
 
        value.vu32 = MLX5_COMP_EQ_SIZE;
        devl_param_driverinit_value_set(devlink,
                                        DEVLINK_PARAM_GENERIC_ID_IO_EQ_SIZE,
-                                       value);
+                                       &value);
 
        value.vu32 = MLX5_NUM_ASYNC_EQE;
        devl_param_driverinit_value_set(devlink,
                                        DEVLINK_PARAM_GENERIC_ID_EVENT_EQ_SIZE,
-                                       value);
+                                       &value);
 }
 
 static const struct devlink_param mlx5_devlink_eth_params[] = {
@@ -653,14 +653,14 @@ static int mlx5_devlink_eth_params_register(struct devlink *devlink)
        value.vbool = !mlx5_dev_is_lightweight(dev);
        devl_param_driverinit_value_set(devlink,
                                        DEVLINK_PARAM_GENERIC_ID_ENABLE_ETH,
-                                       value);
+                                       &value);
 
        mlx5_devlink_hairpin_params_init_values(devlink);
 
        value.vu32 = MLX5_DEFAULT_NUM_DOORBELLS;
        devl_param_driverinit_value_set(devlink,
                                        DEVLINK_PARAM_GENERIC_ID_NUM_DOORBELLS,
-                                       value);
+                                       &value);
        return 0;
 }
 
@@ -681,12 +681,12 @@ static void mlx5_devlink_eth_params_unregister(struct devlink *devlink)
 
 static int
 mlx5_devlink_pcie_cong_thresh_validate(struct devlink *devl, u32 id,
-                                      union devlink_param_value val,
+                                      union devlink_param_value *val,
                                       struct netlink_ext_ack *extack)
 {
-       if (val.vu16 > MLX5_PCIE_CONG_THRESH_MAX) {
+       if (val->vu16 > MLX5_PCIE_CONG_THRESH_MAX) {
                NL_SET_ERR_MSG_FMT_MOD(extack, "Value %u > max supported (%u)",
-                                      val.vu16, MLX5_PCIE_CONG_THRESH_MAX);
+                                      val->vu16, MLX5_PCIE_CONG_THRESH_MAX);
 
                return -EINVAL;
        }
@@ -711,19 +711,19 @@ static void mlx5_devlink_pcie_cong_init_values(struct devlink *devlink)
 
        value.vu16 = MLX5_PCIE_CONG_THRESH_DEF_LOW;
        id = MLX5_DEVLINK_PARAM_ID_PCIE_CONG_IN_LOW;
-       devl_param_driverinit_value_set(devlink, id, value);
+       devl_param_driverinit_value_set(devlink, id, &value);
 
        value.vu16 = MLX5_PCIE_CONG_THRESH_DEF_HIGH;
        id = MLX5_DEVLINK_PARAM_ID_PCIE_CONG_IN_HIGH;
-       devl_param_driverinit_value_set(devlink, id, value);
+       devl_param_driverinit_value_set(devlink, id, &value);
 
        value.vu16 = MLX5_PCIE_CONG_THRESH_DEF_LOW;
        id = MLX5_DEVLINK_PARAM_ID_PCIE_CONG_OUT_LOW;
-       devl_param_driverinit_value_set(devlink, id, value);
+       devl_param_driverinit_value_set(devlink, id, &value);
 
        value.vu16 = MLX5_PCIE_CONG_THRESH_DEF_HIGH;
        id = MLX5_DEVLINK_PARAM_ID_PCIE_CONG_OUT_HIGH;
-       devl_param_driverinit_value_set(devlink, id, value);
+       devl_param_driverinit_value_set(devlink, id, &value);
 }
 
 static const struct devlink_param mlx5_devlink_pcie_cong_params[] = {
@@ -775,11 +775,11 @@ static void mlx5_devlink_pcie_cong_params_unregister(struct devlink *devlink)
 }
 
 static int mlx5_devlink_enable_rdma_validate(struct devlink *devlink, u32 id,
-                                            union devlink_param_value val,
+                                            union devlink_param_value *val,
                                             struct netlink_ext_ack *extack)
 {
        struct mlx5_core_dev *dev = devlink_priv(devlink);
-       bool new_state = val.vbool;
+       bool new_state = val->vbool;
 
        if (new_state && !mlx5_rdma_supported(dev))
                return -EOPNOTSUPP;
@@ -808,7 +808,7 @@ static int mlx5_devlink_rdma_params_register(struct devlink *devlink)
        value.vbool = !mlx5_dev_is_lightweight(dev);
        devl_param_driverinit_value_set(devlink,
                                        DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA,
-                                       value);
+                                       &value);
        return 0;
 }
 
@@ -843,7 +843,7 @@ static int mlx5_devlink_vnet_params_register(struct devlink *devlink)
        value.vbool = !mlx5_dev_is_lightweight(dev);
        devl_param_driverinit_value_set(devlink,
                                        DEVLINK_PARAM_GENERIC_ID_ENABLE_VNET,
-                                       value);
+                                       &value);
        return 0;
 }
 
@@ -890,22 +890,22 @@ static void mlx5_devlink_auxdev_params_unregister(struct devlink *devlink)
 }
 
 static int mlx5_devlink_max_uc_list_validate(struct devlink *devlink, u32 id,
-                                            union devlink_param_value val,
+                                            union devlink_param_value *val,
                                             struct netlink_ext_ack *extack)
 {
        struct mlx5_core_dev *dev = devlink_priv(devlink);
 
-       if (val.vu32 == 0) {
+       if (val->vu32 == 0) {
                NL_SET_ERR_MSG_MOD(extack, "max_macs value must be greater than 0");
                return -EINVAL;
        }
 
-       if (!is_power_of_2(val.vu32)) {
+       if (!is_power_of_2(val->vu32)) {
                NL_SET_ERR_MSG_MOD(extack, "Only power of 2 values are supported for max_macs");
                return -EINVAL;
        }
 
-       if (ilog2(val.vu32) >
+       if (ilog2(val->vu32) >
            MLX5_CAP_GEN_MAX(dev, log_max_current_uc_list)) {
                NL_SET_ERR_MSG_MOD(extack, "max_macs value is out of the supported range");
                return -EINVAL;
@@ -936,7 +936,7 @@ static int mlx5_devlink_max_uc_list_params_register(struct devlink *devlink)
        value.vu32 = 1 << MLX5_CAP_GEN(dev, log_max_current_uc_list);
        devl_param_driverinit_value_set(devlink,
                                        DEVLINK_PARAM_GENERIC_ID_MAX_MACS,
-                                       value);
+                                       &value);
        return 0;
 }
 
index 355d27934fb4ff6231a95c14559b0fb6b0b7e3ea..189be11c4c39d796c8401ec948a01349291a646e 100644 (file)
@@ -2748,7 +2748,7 @@ static int esw_port_metadata_get(struct devlink *devlink, u32 id,
 }
 
 static int esw_port_metadata_validate(struct devlink *devlink, u32 id,
-                                     union devlink_param_value val,
+                                     union devlink_param_value *val,
                                      struct netlink_ext_ack *extack)
 {
        struct mlx5_core_dev *dev = devlink_priv(devlink);
index 61a6ba1e49dda5f18e84d15d34e0c393a4e0a993..c8f6adae6f51a03d058e48aba376fa4cfbe263b9 100644 (file)
@@ -3765,11 +3765,11 @@ cleanup:
 }
 
 static int mlx5_fs_mode_validate(struct devlink *devlink, u32 id,
-                                union devlink_param_value val,
+                                union devlink_param_value *val,
                                 struct netlink_ext_ack *extack)
 {
        struct mlx5_core_dev *dev = devlink_priv(devlink);
-       char *value = val.vstr;
+       char *value = val->vstr;
        u8 eswitch_mode;
 
        eswitch_mode = mlx5_eswitch_mode(dev);
index 19bb620b7436d9fa9ead1fd2a1ca38f4760f1186..4a7275e8b62e3894b4e88886359d2b24ca5e1ad4 100644 (file)
@@ -270,13 +270,13 @@ mlx5_nv_param_devlink_cqe_compress_get(struct devlink *devlink, u32 id,
 
 static int
 mlx5_nv_param_devlink_cqe_compress_validate(struct devlink *devlink, u32 id,
-                                           union devlink_param_value val,
+                                           union devlink_param_value *val,
                                            struct netlink_ext_ack *extack)
 {
        int i;
 
        for (i = 0; i < ARRAY_SIZE(cqe_compress_str); i++) {
-               if (!strcmp(val.vstr, cqe_compress_str[i]))
+               if (!strcmp(val->vstr, cqe_compress_str[i]))
                        return 0;
        }
 
@@ -374,7 +374,7 @@ mlx5_devlink_swp_l4_csum_mode_get(struct devlink *devlink, u32 id,
 
 static int
 mlx5_devlink_swp_l4_csum_mode_validate(struct devlink *devlink, u32 id,
-                                      union devlink_param_value val,
+                                      union devlink_param_value *val,
                                       struct netlink_ext_ack *extack)
 {
        struct mlx5_core_dev *dev = devlink_priv(devlink);
@@ -383,7 +383,7 @@ mlx5_devlink_swp_l4_csum_mode_validate(struct devlink *devlink, u32 id,
        int err, i;
 
        for (i = 0; i < ARRAY_SIZE(swp_l4_csum_mode_str); i++) {
-               if (!strcmp(val.vstr, swp_l4_csum_mode_str[i]))
+               if (!strcmp(val->vstr, swp_l4_csum_mode_str[i]))
                        break;
        }
 
@@ -727,7 +727,7 @@ static int mlx5_devlink_total_vfs_set(struct devlink *devlink, u32 id,
 }
 
 static int mlx5_devlink_total_vfs_validate(struct devlink *devlink, u32 id,
-                                          union devlink_param_value val,
+                                          union devlink_param_value *val,
                                           struct netlink_ext_ack *extack)
 {
        struct mlx5_core_dev *dev = devlink_priv(devlink);
@@ -746,7 +746,7 @@ static int mlx5_devlink_total_vfs_validate(struct devlink *devlink, u32 id,
                return 0; /* optimistic, but set might fail later */
 
        max = MLX5_GET(nv_global_pci_cap, data, max_vfs_per_pf);
-       if (val.vu16 > max) {
+       if (val->vu16 > max) {
                NL_SET_ERR_MSG_FMT_MOD(extack,
                                       "Max allowed by device is %u", max);
                return -EINVAL;
index d76246301f67cd5e245084053953b341b4e5f44d..308d8a94865f888acf66554b235eb568f2dd0019 100644 (file)
@@ -1306,11 +1306,11 @@ static int mlxsw_core_fw_flash_update(struct mlxsw_core *mlxsw_core,
 }
 
 static int mlxsw_core_devlink_param_fw_load_policy_validate(struct devlink *devlink, u32 id,
-                                                           union devlink_param_value val,
+                                                           union devlink_param_value *val,
                                                            struct netlink_ext_ack *extack)
 {
-       if (val.vu8 != DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_DRIVER &&
-           val.vu8 != DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_FLASH) {
+       if (val->vu8 != DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_DRIVER &&
+           val->vu8 != DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_FLASH) {
                NL_SET_ERR_MSG_MOD(extack, "'fw_load_policy' must be 'driver' or 'flash'");
                return -EINVAL;
        }
@@ -1337,7 +1337,7 @@ static int mlxsw_core_fw_params_register(struct mlxsw_core *mlxsw_core)
        value.vu8 = DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_DRIVER;
        devl_param_driverinit_value_set(devlink,
                                        DEVLINK_PARAM_GENERIC_ID_FW_LOAD_POLICY,
-                                       value);
+                                       &value);
        return 0;
 }
 
index 85e3b19e6165b65ac011b28ed38ccd01b67e9a51..826527992e4ac539fbc29aa02ef766b5ae62b264 100644 (file)
@@ -170,7 +170,7 @@ exit_close_nsp:
 
 static int
 nfp_devlink_param_u8_validate(struct devlink *devlink, u32 id,
-                             union devlink_param_value val,
+                             union devlink_param_value *val,
                              struct netlink_ext_ack *extack)
 {
        const struct nfp_devlink_param_u8_arg *arg;
@@ -180,12 +180,12 @@ nfp_devlink_param_u8_validate(struct devlink *devlink, u32 id,
 
        arg = &nfp_devlink_u8_args[id];
 
-       if (val.vu8 > arg->max_dl_val) {
+       if (val->vu8 > arg->max_dl_val) {
                NL_SET_ERR_MSG_MOD(extack, "parameter out of range");
                return -EINVAL;
        }
 
-       if (val.vu8 == arg->invalid_dl_val) {
+       if (val->vu8 == arg->invalid_dl_val) {
                NL_SET_ERR_MSG_MOD(extack, "unknown/invalid value specified");
                return -EINVAL;
        }
index f00fc2f9ebdec7ea9a78353736f6c5bc9a5b36a6..aed9ad5f1b43afddffa239e7c8ac079a2e12cc9f 100644 (file)
@@ -597,11 +597,11 @@ static void nsim_devlink_set_params_init_values(struct nsim_dev *nsim_dev,
        value.vu32 = nsim_dev->max_macs;
        devl_param_driverinit_value_set(devlink,
                                        DEVLINK_PARAM_GENERIC_ID_MAX_MACS,
-                                       value);
+                                       &value);
        value.vbool = nsim_dev->test1;
        devl_param_driverinit_value_set(devlink,
                                        NSIM_DEVLINK_PARAM_ID_TEST1,
-                                       value);
+                                       &value);
 }
 
 static void nsim_devlink_param_load_driverinit_values(struct devlink *devlink)
index bcd31de1f890888996e99ff8a349602124fa897e..5f4083dc4345e9dc682cf01f471851e3d6edf9a7 100644 (file)
@@ -501,7 +501,7 @@ struct devlink_param {
                   struct devlink_param_gset_ctx *ctx,
                   struct netlink_ext_ack *extack);
        int (*validate)(struct devlink *devlink, u32 id,
-                       union devlink_param_value val,
+                       union devlink_param_value *val,
                        struct netlink_ext_ack *extack);
        int (*get_default)(struct devlink *devlink, u32 id,
                           struct devlink_param_gset_ctx *ctx,
@@ -1923,7 +1923,7 @@ void devlink_params_unregister(struct devlink *devlink,
 int devl_param_driverinit_value_get(struct devlink *devlink, u32 param_id,
                                    union devlink_param_value *val);
 void devl_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
-                                    union devlink_param_value init_val);
+                                    union devlink_param_value *init_val);
 void devl_param_value_changed(struct devlink *devlink, u32 param_id);
 struct devlink_region *devl_region_create(struct devlink *devlink,
                                          const struct devlink_region_ops *ops,
index cf95268da5b0b7879bfbe764e26ab3f7eac27017..1a196d3a843dbf341ad585cbea86af4e0dc15e77 100644 (file)
@@ -216,28 +216,28 @@ static int devlink_param_reset_default(struct devlink *devlink,
 
 static int
 devlink_nl_param_value_put(struct sk_buff *msg, enum devlink_param_type type,
-                          int nla_type, union devlink_param_value val,
+                          int nla_type, union devlink_param_value *val,
                           bool flag_as_u8)
 {
        switch (type) {
        case DEVLINK_PARAM_TYPE_U8:
-               if (nla_put_u8(msg, nla_type, val.vu8))
+               if (nla_put_u8(msg, nla_type, val->vu8))
                        return -EMSGSIZE;
                break;
        case DEVLINK_PARAM_TYPE_U16:
-               if (nla_put_u16(msg, nla_type, val.vu16))
+               if (nla_put_u16(msg, nla_type, val->vu16))
                        return -EMSGSIZE;
                break;
        case DEVLINK_PARAM_TYPE_U32:
-               if (nla_put_u32(msg, nla_type, val.vu32))
+               if (nla_put_u32(msg, nla_type, val->vu32))
                        return -EMSGSIZE;
                break;
        case DEVLINK_PARAM_TYPE_U64:
-               if (devlink_nl_put_u64(msg, nla_type, val.vu64))
+               if (devlink_nl_put_u64(msg, nla_type, val->vu64))
                        return -EMSGSIZE;
                break;
        case DEVLINK_PARAM_TYPE_STRING:
-               if (nla_put_string(msg, nla_type, val.vstr))
+               if (nla_put_string(msg, nla_type, val->vstr))
                        return -EMSGSIZE;
                break;
        case DEVLINK_PARAM_TYPE_BOOL:
@@ -245,10 +245,10 @@ devlink_nl_param_value_put(struct sk_buff *msg, enum devlink_param_type type,
                 * false can be distinguished from not present
                 */
                if (flag_as_u8) {
-                       if (nla_put_u8(msg, nla_type, val.vbool))
+                       if (nla_put_u8(msg, nla_type, val->vbool))
                                return -EMSGSIZE;
                } else {
-                       if (val.vbool && nla_put_flag(msg, nla_type))
+                       if (val->vbool && nla_put_flag(msg, nla_type))
                                return -EMSGSIZE;
                }
                break;
@@ -260,8 +260,8 @@ static int
 devlink_nl_param_value_fill_one(struct sk_buff *msg,
                                enum devlink_param_type type,
                                enum devlink_param_cmode cmode,
-                               union devlink_param_value val,
-                               union devlink_param_value default_val,
+                               union devlink_param_value *val,
+                               union devlink_param_value *default_val,
                                bool has_default)
 {
        struct nlattr *param_value_attr;
@@ -383,8 +383,8 @@ static int devlink_nl_param_fill(struct sk_buff *msg, struct devlink *devlink,
                if (!param_value_set[i])
                        continue;
                err = devlink_nl_param_value_fill_one(msg, param->type,
-                                                     i, param_value[i],
-                                                     default_value[i],
+                                                     i, &param_value[i],
+                                                     &default_value[i],
                                                      default_value_set[i]);
                if (err)
                        goto values_list_nest_cancel;
@@ -621,7 +621,7 @@ static int __devlink_nl_cmd_param_set_doit(struct devlink *devlink,
                if (err)
                        return err;
                if (param->validate) {
-                       err = param->validate(devlink, param->id, value,
+                       err = param->validate(devlink, param->id, &value,
                                              info->extack);
                        if (err)
                                return err;
@@ -888,7 +888,7 @@ EXPORT_SYMBOL_GPL(devl_param_driverinit_value_get);
  *     configuration mode default value.
  */
 void devl_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
-                                    union devlink_param_value init_val)
+                                    union devlink_param_value *init_val)
 {
        struct devlink_param_item *param_item;
 
@@ -902,9 +902,9 @@ void devl_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
                                                      DEVLINK_PARAM_CMODE_DRIVERINIT)))
                return;
 
-       param_item->driverinit_value = init_val;
+       param_item->driverinit_value = *init_val;
        param_item->driverinit_value_valid = true;
-       param_item->driverinit_default = init_val;
+       param_item->driverinit_default = *init_val;
 
        devlink_param_notify(devlink, 0, param_item, DEVLINK_CMD_PARAM_NEW);
 }