mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-30 14:40:20 -04:00
net/mlx5: Expose max possible SFs via devlink resource
Introduce devlink resource for exposing max possible SFs on mlx5 devices. For example: $ devlink resource show pci/0000:00:0b.0 pci/0000:00:0b.0: name max_local_SFs size 5 unit entry dpipe_tables none name max_external_SFs size 0 unit entry dpipe_tables none Signed-off-by: Shay Drory <shayd@nvidia.com> Reviewed-by: Moshe Shemesh <moshe@nvidia.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
This commit is contained in:
committed by
Saeed Mahameed
parent
53b836a44d
commit
6486c0f44e
@@ -6,6 +6,14 @@
|
||||
|
||||
#include <net/devlink.h>
|
||||
|
||||
enum mlx5_devlink_resource_id {
|
||||
MLX5_DL_RES_MAX_LOCAL_SFS = 1,
|
||||
MLX5_DL_RES_MAX_EXTERNAL_SFS,
|
||||
|
||||
__MLX5_ID_RES_MAX,
|
||||
MLX5_ID_RES_MAX = __MLX5_ID_RES_MAX - 1,
|
||||
};
|
||||
|
||||
enum mlx5_devlink_param_id {
|
||||
MLX5_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
|
||||
MLX5_DEVLINK_PARAM_ID_FLOW_STEERING_MODE,
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "mlx5_core.h"
|
||||
#include "eswitch.h"
|
||||
#include "diag/sf_tracepoint.h"
|
||||
#include "devlink.h"
|
||||
|
||||
struct mlx5_sf_hw {
|
||||
u32 usr_sfnum;
|
||||
@@ -243,6 +244,32 @@ static void mlx5_sf_hw_table_hwc_cleanup(struct mlx5_sf_hwc_table *hwc)
|
||||
kfree(hwc->sfs);
|
||||
}
|
||||
|
||||
static void mlx5_sf_hw_table_res_unregister(struct mlx5_core_dev *dev)
|
||||
{
|
||||
devl_resources_unregister(priv_to_devlink(dev));
|
||||
}
|
||||
|
||||
static int mlx5_sf_hw_table_res_register(struct mlx5_core_dev *dev, u16 max_fn,
|
||||
u16 max_ext_fn)
|
||||
{
|
||||
struct devlink_resource_size_params size_params;
|
||||
struct devlink *devlink = priv_to_devlink(dev);
|
||||
int err;
|
||||
|
||||
devlink_resource_size_params_init(&size_params, max_fn, max_fn, 1,
|
||||
DEVLINK_RESOURCE_UNIT_ENTRY);
|
||||
err = devl_resource_register(devlink, "max_local_SFs", max_fn, MLX5_DL_RES_MAX_LOCAL_SFS,
|
||||
DEVLINK_RESOURCE_ID_PARENT_TOP, &size_params);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
devlink_resource_size_params_init(&size_params, max_ext_fn, max_ext_fn, 1,
|
||||
DEVLINK_RESOURCE_UNIT_ENTRY);
|
||||
return devl_resource_register(devlink, "max_external_SFs", max_ext_fn,
|
||||
MLX5_DL_RES_MAX_EXTERNAL_SFS, DEVLINK_RESOURCE_ID_PARENT_TOP,
|
||||
&size_params);
|
||||
}
|
||||
|
||||
int mlx5_sf_hw_table_init(struct mlx5_core_dev *dev)
|
||||
{
|
||||
struct mlx5_sf_hw_table *table;
|
||||
@@ -262,12 +289,17 @@ int mlx5_sf_hw_table_init(struct mlx5_core_dev *dev)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (mlx5_sf_hw_table_res_register(dev, max_fn, max_ext_fn))
|
||||
mlx5_core_dbg(dev, "failed to register max SFs resources");
|
||||
|
||||
if (!max_fn && !max_ext_fn)
|
||||
return 0;
|
||||
|
||||
table = kzalloc(sizeof(*table), GFP_KERNEL);
|
||||
if (!table)
|
||||
return -ENOMEM;
|
||||
if (!table) {
|
||||
err = -ENOMEM;
|
||||
goto alloc_err;
|
||||
}
|
||||
|
||||
mutex_init(&table->table_lock);
|
||||
table->dev = dev;
|
||||
@@ -291,6 +323,8 @@ int mlx5_sf_hw_table_init(struct mlx5_core_dev *dev)
|
||||
table_err:
|
||||
mutex_destroy(&table->table_lock);
|
||||
kfree(table);
|
||||
alloc_err:
|
||||
mlx5_sf_hw_table_res_unregister(dev);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -299,12 +333,14 @@ void mlx5_sf_hw_table_cleanup(struct mlx5_core_dev *dev)
|
||||
struct mlx5_sf_hw_table *table = dev->priv.sf_hw_table;
|
||||
|
||||
if (!table)
|
||||
return;
|
||||
goto res_unregister;
|
||||
|
||||
mutex_destroy(&table->table_lock);
|
||||
mlx5_sf_hw_table_hwc_cleanup(&table->hwc[MLX5_SF_HWC_EXTERNAL]);
|
||||
mlx5_sf_hw_table_hwc_cleanup(&table->hwc[MLX5_SF_HWC_LOCAL]);
|
||||
mutex_destroy(&table->table_lock);
|
||||
kfree(table);
|
||||
res_unregister:
|
||||
mlx5_sf_hw_table_res_unregister(dev);
|
||||
}
|
||||
|
||||
static int mlx5_sf_hw_vhca_event(struct notifier_block *nb, unsigned long opcode, void *data)
|
||||
|
||||
Reference in New Issue
Block a user