@@ -14,6 +14,7 @@ enum accel_fs_tcp_type {
struct mlx5e_accel_fs_tcp {
struct mlx5e_flow_table tables[ACCEL_FS_TCP_NUM_TYPES];
struct mlx5_flow_handle *default_rules[ACCEL_FS_TCP_NUM_TYPES];
+ refcount_t user_count;
};
static enum mlx5_traffic_types fs_accel2tt(enum accel_fs_tcp_type i)
@@ -360,6 +361,9 @@ void mlx5e_accel_fs_tcp_destroy(struct mlx5e_flow_steering *fs)
if (!accel_tcp)
return;
+ if (!refcount_dec_and_test(&accel_tcp->user_count))
+ return;
+
accel_fs_tcp_disable(fs);
for (i = 0; i < ACCEL_FS_TCP_NUM_TYPES; i++)
@@ -371,12 +375,17 @@ void mlx5e_accel_fs_tcp_destroy(struct mlx5e_flow_steering *fs)
int mlx5e_accel_fs_tcp_create(struct mlx5e_flow_steering *fs)
{
- struct mlx5e_accel_fs_tcp *accel_tcp;
+ struct mlx5e_accel_fs_tcp *accel_tcp = mlx5e_fs_get_accel_tcp(fs);
int i, err;
if (!MLX5_CAP_FLOWTABLE_NIC_RX(mlx5e_fs_get_mdev(fs), ft_field_support.outer_ip_version))
return -EOPNOTSUPP;
+ if (accel_tcp) {
+ refcount_inc(&accel_tcp->user_count);
+ return 0;
+ }
+
accel_tcp = kzalloc(sizeof(*accel_tcp), GFP_KERNEL);
if (!accel_tcp)
return -ENOMEM;
@@ -392,6 +401,7 @@ int mlx5e_accel_fs_tcp_create(struct mlx5e_flow_steering *fs)
if (err)
goto err_destroy_tables;
+ refcount_set(&accel_tcp->user_count, 1);
return 0;
err_destroy_tables: