Lines Matching refs:nhct
3167 struct mlxsw_sp_nexthop_counter *nhct; in mlxsw_sp_nexthop_counter_alloc() local
3170 nhct = kzalloc(sizeof(*nhct), GFP_KERNEL); in mlxsw_sp_nexthop_counter_alloc()
3171 if (!nhct) in mlxsw_sp_nexthop_counter_alloc()
3174 err = mlxsw_sp_flow_counter_alloc(mlxsw_sp, &nhct->counter_index); in mlxsw_sp_nexthop_counter_alloc()
3178 refcount_set(&nhct->ref_count, 1); in mlxsw_sp_nexthop_counter_alloc()
3179 return nhct; in mlxsw_sp_nexthop_counter_alloc()
3182 kfree(nhct); in mlxsw_sp_nexthop_counter_alloc()
3188 struct mlxsw_sp_nexthop_counter *nhct) in mlxsw_sp_nexthop_counter_free() argument
3190 mlxsw_sp_flow_counter_free(mlxsw_sp, nhct->counter_index); in mlxsw_sp_nexthop_counter_free()
3191 kfree(nhct); in mlxsw_sp_nexthop_counter_free()
3199 struct mlxsw_sp_nexthop_counter *nhct; in mlxsw_sp_nexthop_sh_counter_get() local
3202 nhct = xa_load(&nh_grp->nhgi->nexthop_counters, nh->id); in mlxsw_sp_nexthop_sh_counter_get()
3203 if (nhct) { in mlxsw_sp_nexthop_sh_counter_get()
3204 refcount_inc(&nhct->ref_count); in mlxsw_sp_nexthop_sh_counter_get()
3205 return nhct; in mlxsw_sp_nexthop_sh_counter_get()
3208 nhct = mlxsw_sp_nexthop_counter_alloc(mlxsw_sp); in mlxsw_sp_nexthop_sh_counter_get()
3209 if (IS_ERR(nhct)) in mlxsw_sp_nexthop_sh_counter_get()
3210 return nhct; in mlxsw_sp_nexthop_sh_counter_get()
3212 err = xa_err(xa_store(&nh_grp->nhgi->nexthop_counters, nh->id, nhct, in mlxsw_sp_nexthop_sh_counter_get()
3217 return nhct; in mlxsw_sp_nexthop_sh_counter_get()
3220 mlxsw_sp_nexthop_counter_free(mlxsw_sp, nhct); in mlxsw_sp_nexthop_sh_counter_get()
3228 struct mlxsw_sp_nexthop_counter *nhct; in mlxsw_sp_nexthop_sh_counter_put() local
3230 nhct = xa_load(&nh_grp->nhgi->nexthop_counters, nh->id); in mlxsw_sp_nexthop_sh_counter_put()
3231 if (WARN_ON(!nhct)) in mlxsw_sp_nexthop_sh_counter_put()
3234 if (!refcount_dec_and_test(&nhct->ref_count)) in mlxsw_sp_nexthop_sh_counter_put()
3238 mlxsw_sp_nexthop_counter_free(mlxsw_sp, nhct); in mlxsw_sp_nexthop_sh_counter_put()
3245 struct mlxsw_sp_nexthop_counter *nhct; in mlxsw_sp_nexthop_counter_enable() local
3258 nhct = mlxsw_sp_nexthop_sh_counter_get(mlxsw_sp, nh); in mlxsw_sp_nexthop_counter_enable()
3260 nhct = mlxsw_sp_nexthop_counter_alloc(mlxsw_sp); in mlxsw_sp_nexthop_counter_enable()
3261 if (IS_ERR(nhct)) in mlxsw_sp_nexthop_counter_enable()
3262 return PTR_ERR(nhct); in mlxsw_sp_nexthop_counter_enable()
3264 nh->counter = nhct; in mlxsw_sp_nexthop_counter_enable()