Commit f164be8c authored by Yishai Hadas's avatar Yishai Hadas Committed by Jason Gunthorpe

IB/mlx5: Extend caps stage to handle VAR capabilities

Extend caps stage to handle VAR capabilities.

Link: https://lore.kernel.org/r/20191212110928.334995-4-leon@kernel.orgSigned-off-by: default avatarYishai Hadas <yishaih@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent aef5570e
...@@ -6335,6 +6335,35 @@ static const struct ib_device_ops mlx5_ib_dev_dm_ops = { ...@@ -6335,6 +6335,35 @@ static const struct ib_device_ops mlx5_ib_dev_dm_ops = {
.reg_dm_mr = mlx5_ib_reg_dm_mr, .reg_dm_mr = mlx5_ib_reg_dm_mr,
}; };
static int mlx5_ib_init_var_table(struct mlx5_ib_dev *dev)
{
struct mlx5_core_dev *mdev = dev->mdev;
struct mlx5_var_table *var_table = &dev->var_table;
u8 log_doorbell_bar_size;
u8 log_doorbell_stride;
u64 bar_size;
log_doorbell_bar_size = MLX5_CAP_DEV_VDPA_EMULATION(mdev,
log_doorbell_bar_size);
log_doorbell_stride = MLX5_CAP_DEV_VDPA_EMULATION(mdev,
log_doorbell_stride);
var_table->hw_start_addr = dev->mdev->bar_addr +
MLX5_CAP64_DEV_VDPA_EMULATION(mdev,
doorbell_bar_offset);
bar_size = (1ULL << log_doorbell_bar_size) * 4096;
var_table->stride_size = 1ULL << log_doorbell_stride;
var_table->num_var_hw_entries = bar_size / var_table->stride_size;
mutex_init(&var_table->bitmap_lock);
var_table->bitmap = bitmap_zalloc(var_table->num_var_hw_entries,
GFP_KERNEL);
return (var_table->bitmap) ? 0 : -ENOMEM;
}
static void mlx5_ib_stage_caps_cleanup(struct mlx5_ib_dev *dev)
{
bitmap_free(dev->var_table.bitmap);
}
static int mlx5_ib_stage_caps_init(struct mlx5_ib_dev *dev) static int mlx5_ib_stage_caps_init(struct mlx5_ib_dev *dev)
{ {
struct mlx5_core_dev *mdev = dev->mdev; struct mlx5_core_dev *mdev = dev->mdev;
...@@ -6422,6 +6451,13 @@ static int mlx5_ib_stage_caps_init(struct mlx5_ib_dev *dev) ...@@ -6422,6 +6451,13 @@ static int mlx5_ib_stage_caps_init(struct mlx5_ib_dev *dev)
MLX5_CAP_GEN(dev->mdev, disable_local_lb_mc))) MLX5_CAP_GEN(dev->mdev, disable_local_lb_mc)))
mutex_init(&dev->lb.mutex); mutex_init(&dev->lb.mutex);
if (MLX5_CAP_GEN_64(dev->mdev, general_obj_types) &
MLX5_GENERAL_OBJ_TYPES_CAP_VIRTIO_NET_Q) {
err = mlx5_ib_init_var_table(dev);
if (err)
return err;
}
dev->ib_dev.use_cq_dim = true; dev->ib_dev.use_cq_dim = true;
return 0; return 0;
...@@ -6772,7 +6808,7 @@ static const struct mlx5_ib_profile pf_profile = { ...@@ -6772,7 +6808,7 @@ static const struct mlx5_ib_profile pf_profile = {
mlx5_ib_stage_flow_db_cleanup), mlx5_ib_stage_flow_db_cleanup),
STAGE_CREATE(MLX5_IB_STAGE_CAPS, STAGE_CREATE(MLX5_IB_STAGE_CAPS,
mlx5_ib_stage_caps_init, mlx5_ib_stage_caps_init,
NULL), mlx5_ib_stage_caps_cleanup),
STAGE_CREATE(MLX5_IB_STAGE_NON_DEFAULT_CB, STAGE_CREATE(MLX5_IB_STAGE_NON_DEFAULT_CB,
mlx5_ib_stage_non_default_cb, mlx5_ib_stage_non_default_cb,
NULL), NULL),
...@@ -6829,7 +6865,7 @@ const struct mlx5_ib_profile raw_eth_profile = { ...@@ -6829,7 +6865,7 @@ const struct mlx5_ib_profile raw_eth_profile = {
mlx5_ib_stage_flow_db_cleanup), mlx5_ib_stage_flow_db_cleanup),
STAGE_CREATE(MLX5_IB_STAGE_CAPS, STAGE_CREATE(MLX5_IB_STAGE_CAPS,
mlx5_ib_stage_caps_init, mlx5_ib_stage_caps_init,
NULL), mlx5_ib_stage_caps_cleanup),
STAGE_CREATE(MLX5_IB_STAGE_NON_DEFAULT_CB, STAGE_CREATE(MLX5_IB_STAGE_NON_DEFAULT_CB,
mlx5_ib_stage_raw_eth_non_default_cb, mlx5_ib_stage_raw_eth_non_default_cb,
NULL), NULL),
......
...@@ -959,6 +959,15 @@ struct mlx5_devx_event_table { ...@@ -959,6 +959,15 @@ struct mlx5_devx_event_table {
struct xarray event_xa; struct xarray event_xa;
}; };
struct mlx5_var_table {
/* serialize updating the bitmap */
struct mutex bitmap_lock;
unsigned long *bitmap;
u64 hw_start_addr;
u32 stride_size;
u64 num_var_hw_entries;
};
struct mlx5_ib_dev { struct mlx5_ib_dev {
struct ib_device ib_dev; struct ib_device ib_dev;
struct mlx5_core_dev *mdev; struct mlx5_core_dev *mdev;
...@@ -1013,6 +1022,7 @@ struct mlx5_ib_dev { ...@@ -1013,6 +1022,7 @@ struct mlx5_ib_dev {
struct mlx5_srq_table srq_table; struct mlx5_srq_table srq_table;
struct mlx5_async_ctx async_ctx; struct mlx5_async_ctx async_ctx;
struct mlx5_devx_event_table devx_event_table; struct mlx5_devx_event_table devx_event_table;
struct mlx5_var_table var_table;
struct xarray sig_mrs; struct xarray sig_mrs;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment