@@ -1459,6 +1459,7 @@ mlxsw_sp_port_vlan_create(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid)
1459
1459
}
1460
1460
1461
1461
mlxsw_sp_port_vlan -> mlxsw_sp_port = mlxsw_sp_port ;
1462
+ mlxsw_sp_port_vlan -> ref_count = 1 ;
1462
1463
mlxsw_sp_port_vlan -> vid = vid ;
1463
1464
list_add (& mlxsw_sp_port_vlan -> list , & mlxsw_sp_port -> vlans_list );
1464
1465
@@ -1486,8 +1487,10 @@ mlxsw_sp_port_vlan_get(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid)
1486
1487
struct mlxsw_sp_port_vlan * mlxsw_sp_port_vlan ;
1487
1488
1488
1489
mlxsw_sp_port_vlan = mlxsw_sp_port_vlan_find_by_vid (mlxsw_sp_port , vid );
1489
- if (mlxsw_sp_port_vlan )
1490
+ if (mlxsw_sp_port_vlan ) {
1491
+ mlxsw_sp_port_vlan -> ref_count ++ ;
1490
1492
return mlxsw_sp_port_vlan ;
1493
+ }
1491
1494
1492
1495
return mlxsw_sp_port_vlan_create (mlxsw_sp_port , vid );
1493
1496
}
@@ -1496,6 +1499,9 @@ void mlxsw_sp_port_vlan_put(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan)
1496
1499
{
1497
1500
struct mlxsw_sp_fid * fid = mlxsw_sp_port_vlan -> fid ;
1498
1501
1502
+ if (-- mlxsw_sp_port_vlan -> ref_count != 0 )
1503
+ return ;
1504
+
1499
1505
if (mlxsw_sp_port_vlan -> bridge_port )
1500
1506
mlxsw_sp_port_vlan_bridge_leave (mlxsw_sp_port_vlan );
1501
1507
else if (fid )
@@ -4207,13 +4213,12 @@ static struct devlink_resource_ops mlxsw_sp_resource_kvd_hash_double_ops = {
4207
4213
.size_validate = mlxsw_sp_resource_kvd_hash_double_size_validate ,
4208
4214
};
4209
4215
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
4216
static void
4216
- mlxsw_sp_resource_size_params_prepare (struct mlxsw_core * mlxsw_core )
4217
+ mlxsw_sp_resource_size_params_prepare (struct mlxsw_core * mlxsw_core ,
4218
+ struct devlink_resource_size_params * kvd_size_params ,
4219
+ struct devlink_resource_size_params * linear_size_params ,
4220
+ struct devlink_resource_size_params * hash_double_size_params ,
4221
+ struct devlink_resource_size_params * hash_single_size_params )
4217
4222
{
4218
4223
u32 single_size_min = MLXSW_CORE_RES_GET (mlxsw_core ,
4219
4224
KVD_SINGLE_MIN_SIZE );
@@ -4222,37 +4227,35 @@ mlxsw_sp_resource_size_params_prepare(struct mlxsw_core *mlxsw_core)
4222
4227
u32 kvd_size = MLXSW_CORE_RES_GET (mlxsw_core , KVD_SIZE );
4223
4228
u32 linear_size_min = 0 ;
4224
4229
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 ;
4230
+ devlink_resource_size_params_init (kvd_size_params , kvd_size , kvd_size ,
4231
+ MLXSW_SP_KVD_GRANULARITY ,
4232
+ DEVLINK_RESOURCE_UNIT_ENTRY );
4233
+ devlink_resource_size_params_init (linear_size_params , linear_size_min ,
4234
+ kvd_size - single_size_min -
4235
+ double_size_min ,
4236
+ MLXSW_SP_KVD_GRANULARITY ,
4237
+ DEVLINK_RESOURCE_UNIT_ENTRY );
4238
+ devlink_resource_size_params_init (hash_double_size_params ,
4239
+ double_size_min ,
4240
+ kvd_size - single_size_min -
4241
+ linear_size_min ,
4242
+ MLXSW_SP_KVD_GRANULARITY ,
4243
+ DEVLINK_RESOURCE_UNIT_ENTRY );
4244
+ devlink_resource_size_params_init (hash_single_size_params ,
4245
+ single_size_min ,
4246
+ kvd_size - double_size_min -
4247
+ linear_size_min ,
4248
+ MLXSW_SP_KVD_GRANULARITY ,
4249
+ DEVLINK_RESOURCE_UNIT_ENTRY );
4251
4250
}
4252
4251
4253
4252
static int mlxsw_sp_resources_register (struct mlxsw_core * mlxsw_core )
4254
4253
{
4255
4254
struct devlink * devlink = priv_to_devlink (mlxsw_core );
4255
+ struct devlink_resource_size_params hash_single_size_params ;
4256
+ struct devlink_resource_size_params hash_double_size_params ;
4257
+ struct devlink_resource_size_params linear_size_params ;
4258
+ struct devlink_resource_size_params kvd_size_params ;
4256
4259
u32 kvd_size , single_size , double_size , linear_size ;
4257
4260
const struct mlxsw_config_profile * profile ;
4258
4261
int err ;
@@ -4261,13 +4264,17 @@ static int mlxsw_sp_resources_register(struct mlxsw_core *mlxsw_core)
4261
4264
if (!MLXSW_CORE_RES_VALID (mlxsw_core , KVD_SIZE ))
4262
4265
return - EIO ;
4263
4266
4264
- mlxsw_sp_resource_size_params_prepare (mlxsw_core );
4267
+ mlxsw_sp_resource_size_params_prepare (mlxsw_core , & kvd_size_params ,
4268
+ & linear_size_params ,
4269
+ & hash_double_size_params ,
4270
+ & hash_single_size_params );
4271
+
4265
4272
kvd_size = MLXSW_CORE_RES_GET (mlxsw_core , KVD_SIZE );
4266
4273
err = devlink_resource_register (devlink , MLXSW_SP_RESOURCE_NAME_KVD ,
4267
4274
true, kvd_size ,
4268
4275
MLXSW_SP_RESOURCE_KVD ,
4269
4276
DEVLINK_RESOURCE_ID_PARENT_TOP ,
4270
- & mlxsw_sp_kvd_size_params ,
4277
+ & kvd_size_params ,
4271
4278
& mlxsw_sp_resource_kvd_ops );
4272
4279
if (err )
4273
4280
return err ;
@@ -4277,7 +4284,7 @@ static int mlxsw_sp_resources_register(struct mlxsw_core *mlxsw_core)
4277
4284
false, linear_size ,
4278
4285
MLXSW_SP_RESOURCE_KVD_LINEAR ,
4279
4286
MLXSW_SP_RESOURCE_KVD ,
4280
- & mlxsw_sp_linear_size_params ,
4287
+ & linear_size_params ,
4281
4288
& mlxsw_sp_resource_kvd_linear_ops );
4282
4289
if (err )
4283
4290
return err ;
@@ -4291,7 +4298,7 @@ static int mlxsw_sp_resources_register(struct mlxsw_core *mlxsw_core)
4291
4298
false, double_size ,
4292
4299
MLXSW_SP_RESOURCE_KVD_HASH_DOUBLE ,
4293
4300
MLXSW_SP_RESOURCE_KVD ,
4294
- & mlxsw_sp_hash_double_size_params ,
4301
+ & hash_double_size_params ,
4295
4302
& mlxsw_sp_resource_kvd_hash_double_ops );
4296
4303
if (err )
4297
4304
return err ;
@@ -4301,7 +4308,7 @@ static int mlxsw_sp_resources_register(struct mlxsw_core *mlxsw_core)
4301
4308
false, single_size ,
4302
4309
MLXSW_SP_RESOURCE_KVD_HASH_SINGLE ,
4303
4310
MLXSW_SP_RESOURCE_KVD ,
4304
- & mlxsw_sp_hash_single_size_params ,
4311
+ & hash_single_size_params ,
4305
4312
& mlxsw_sp_resource_kvd_hash_single_ops );
4306
4313
if (err )
4307
4314
return err ;
0 commit comments