@@ -4207,13 +4207,12 @@ static struct devlink_resource_ops mlxsw_sp_resource_kvd_hash_double_ops = {
4207
4207
.size_validate = mlxsw_sp_resource_kvd_hash_double_size_validate ,
4208
4208
};
4209
4209
4210
- static struct devlink_resource_size_params mlxsw_sp_kvd_size_params ;
4211
- static struct devlink_resource_size_params mlxsw_sp_linear_size_params ;
4212
- static struct devlink_resource_size_params mlxsw_sp_hash_single_size_params ;
4213
- static struct devlink_resource_size_params mlxsw_sp_hash_double_size_params ;
4214
-
4215
4210
static void
4216
- mlxsw_sp_resource_size_params_prepare (struct mlxsw_core * mlxsw_core )
4211
+ mlxsw_sp_resource_size_params_prepare (struct mlxsw_core * mlxsw_core ,
4212
+ struct devlink_resource_size_params * kvd_size_params ,
4213
+ struct devlink_resource_size_params * linear_size_params ,
4214
+ struct devlink_resource_size_params * hash_double_size_params ,
4215
+ struct devlink_resource_size_params * hash_single_size_params )
4217
4216
{
4218
4217
u32 single_size_min = MLXSW_CORE_RES_GET (mlxsw_core ,
4219
4218
KVD_SINGLE_MIN_SIZE );
@@ -4222,37 +4221,35 @@ mlxsw_sp_resource_size_params_prepare(struct mlxsw_core *mlxsw_core)
4222
4221
u32 kvd_size = MLXSW_CORE_RES_GET (mlxsw_core , KVD_SIZE );
4223
4222
u32 linear_size_min = 0 ;
4224
4223
4225
- /* KVD top resource */
4226
- mlxsw_sp_kvd_size_params .size_min = kvd_size ;
4227
- mlxsw_sp_kvd_size_params .size_max = kvd_size ;
4228
- mlxsw_sp_kvd_size_params .size_granularity = MLXSW_SP_KVD_GRANULARITY ;
4229
- mlxsw_sp_kvd_size_params .unit = DEVLINK_RESOURCE_UNIT_ENTRY ;
4230
-
4231
- /* Linear part init */
4232
- mlxsw_sp_linear_size_params .size_min = linear_size_min ;
4233
- mlxsw_sp_linear_size_params .size_max = kvd_size - single_size_min -
4234
- double_size_min ;
4235
- mlxsw_sp_linear_size_params .size_granularity = MLXSW_SP_KVD_GRANULARITY ;
4236
- mlxsw_sp_linear_size_params .unit = DEVLINK_RESOURCE_UNIT_ENTRY ;
4237
-
4238
- /* Hash double part init */
4239
- mlxsw_sp_hash_double_size_params .size_min = double_size_min ;
4240
- mlxsw_sp_hash_double_size_params .size_max = kvd_size - single_size_min -
4241
- linear_size_min ;
4242
- mlxsw_sp_hash_double_size_params .size_granularity = MLXSW_SP_KVD_GRANULARITY ;
4243
- mlxsw_sp_hash_double_size_params .unit = DEVLINK_RESOURCE_UNIT_ENTRY ;
4244
-
4245
- /* Hash single part init */
4246
- mlxsw_sp_hash_single_size_params .size_min = single_size_min ;
4247
- mlxsw_sp_hash_single_size_params .size_max = kvd_size - double_size_min -
4248
- linear_size_min ;
4249
- mlxsw_sp_hash_single_size_params .size_granularity = MLXSW_SP_KVD_GRANULARITY ;
4250
- mlxsw_sp_hash_single_size_params .unit = DEVLINK_RESOURCE_UNIT_ENTRY ;
4224
+ devlink_resource_size_params_init (kvd_size_params , kvd_size , kvd_size ,
4225
+ MLXSW_SP_KVD_GRANULARITY ,
4226
+ DEVLINK_RESOURCE_UNIT_ENTRY );
4227
+ devlink_resource_size_params_init (linear_size_params , linear_size_min ,
4228
+ kvd_size - single_size_min -
4229
+ double_size_min ,
4230
+ MLXSW_SP_KVD_GRANULARITY ,
4231
+ DEVLINK_RESOURCE_UNIT_ENTRY );
4232
+ devlink_resource_size_params_init (hash_double_size_params ,
4233
+ double_size_min ,
4234
+ kvd_size - single_size_min -
4235
+ linear_size_min ,
4236
+ MLXSW_SP_KVD_GRANULARITY ,
4237
+ DEVLINK_RESOURCE_UNIT_ENTRY );
4238
+ devlink_resource_size_params_init (hash_single_size_params ,
4239
+ single_size_min ,
4240
+ kvd_size - double_size_min -
4241
+ linear_size_min ,
4242
+ MLXSW_SP_KVD_GRANULARITY ,
4243
+ DEVLINK_RESOURCE_UNIT_ENTRY );
4251
4244
}
4252
4245
4253
4246
static int mlxsw_sp_resources_register (struct mlxsw_core * mlxsw_core )
4254
4247
{
4255
4248
struct devlink * devlink = priv_to_devlink (mlxsw_core );
4249
+ struct devlink_resource_size_params hash_single_size_params ;
4250
+ struct devlink_resource_size_params hash_double_size_params ;
4251
+ struct devlink_resource_size_params linear_size_params ;
4252
+ struct devlink_resource_size_params kvd_size_params ;
4256
4253
u32 kvd_size , single_size , double_size , linear_size ;
4257
4254
const struct mlxsw_config_profile * profile ;
4258
4255
int err ;
@@ -4261,13 +4258,17 @@ static int mlxsw_sp_resources_register(struct mlxsw_core *mlxsw_core)
4261
4258
if (!MLXSW_CORE_RES_VALID (mlxsw_core , KVD_SIZE ))
4262
4259
return - EIO ;
4263
4260
4264
- mlxsw_sp_resource_size_params_prepare (mlxsw_core );
4261
+ mlxsw_sp_resource_size_params_prepare (mlxsw_core , & kvd_size_params ,
4262
+ & linear_size_params ,
4263
+ & hash_double_size_params ,
4264
+ & hash_single_size_params );
4265
+
4265
4266
kvd_size = MLXSW_CORE_RES_GET (mlxsw_core , KVD_SIZE );
4266
4267
err = devlink_resource_register (devlink , MLXSW_SP_RESOURCE_NAME_KVD ,
4267
4268
true, kvd_size ,
4268
4269
MLXSW_SP_RESOURCE_KVD ,
4269
4270
DEVLINK_RESOURCE_ID_PARENT_TOP ,
4270
- & mlxsw_sp_kvd_size_params ,
4271
+ & kvd_size_params ,
4271
4272
& mlxsw_sp_resource_kvd_ops );
4272
4273
if (err )
4273
4274
return err ;
@@ -4277,7 +4278,7 @@ static int mlxsw_sp_resources_register(struct mlxsw_core *mlxsw_core)
4277
4278
false, linear_size ,
4278
4279
MLXSW_SP_RESOURCE_KVD_LINEAR ,
4279
4280
MLXSW_SP_RESOURCE_KVD ,
4280
- & mlxsw_sp_linear_size_params ,
4281
+ & linear_size_params ,
4281
4282
& mlxsw_sp_resource_kvd_linear_ops );
4282
4283
if (err )
4283
4284
return err ;
@@ -4291,7 +4292,7 @@ static int mlxsw_sp_resources_register(struct mlxsw_core *mlxsw_core)
4291
4292
false, double_size ,
4292
4293
MLXSW_SP_RESOURCE_KVD_HASH_DOUBLE ,
4293
4294
MLXSW_SP_RESOURCE_KVD ,
4294
- & mlxsw_sp_hash_double_size_params ,
4295
+ & hash_double_size_params ,
4295
4296
& mlxsw_sp_resource_kvd_hash_double_ops );
4296
4297
if (err )
4297
4298
return err ;
@@ -4301,7 +4302,7 @@ static int mlxsw_sp_resources_register(struct mlxsw_core *mlxsw_core)
4301
4302
false, single_size ,
4302
4303
MLXSW_SP_RESOURCE_KVD_HASH_SINGLE ,
4303
4304
MLXSW_SP_RESOURCE_KVD ,
4304
- & mlxsw_sp_hash_single_size_params ,
4305
+ & hash_single_size_params ,
4305
4306
& mlxsw_sp_resource_kvd_hash_single_ops );
4306
4307
if (err )
4307
4308
return err ;
0 commit comments