IB/mlx4: Add mmap call to map the hardware clock
In order to read the HCA's cycle counter efficiently in user space, we need to map the HCA's register. This is done through mmap call. Signed-off-by: Matan Barak <matanb@mellanox.com> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
parent
2528e33e68
commit
52033cfb5a
|
@ -716,8 +716,24 @@ static int mlx4_ib_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
|
||||||
dev->dev->caps.num_uars,
|
dev->dev->caps.num_uars,
|
||||||
PAGE_SIZE, vma->vm_page_prot))
|
PAGE_SIZE, vma->vm_page_prot))
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
} else
|
} else if (vma->vm_pgoff == 3) {
|
||||||
|
struct mlx4_clock_params params;
|
||||||
|
int ret = mlx4_get_internal_clock_params(dev->dev, ¶ms);
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
|
||||||
|
if (io_remap_pfn_range(vma, vma->vm_start,
|
||||||
|
(pci_resource_start(dev->dev->persist->pdev,
|
||||||
|
params.bar) +
|
||||||
|
params.offset)
|
||||||
|
>> PAGE_SHIFT,
|
||||||
|
PAGE_SIZE, vma->vm_page_prot))
|
||||||
|
return -EAGAIN;
|
||||||
|
} else {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1674,6 +1674,25 @@ static int map_internal_clock(struct mlx4_dev *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mlx4_get_internal_clock_params(struct mlx4_dev *dev,
|
||||||
|
struct mlx4_clock_params *params)
|
||||||
|
{
|
||||||
|
struct mlx4_priv *priv = mlx4_priv(dev);
|
||||||
|
|
||||||
|
if (mlx4_is_slave(dev))
|
||||||
|
return -ENOTSUPP;
|
||||||
|
|
||||||
|
if (!params)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
params->bar = priv->fw.clock_bar;
|
||||||
|
params->offset = priv->fw.clock_offset;
|
||||||
|
params->size = MLX4_CLOCK_SIZE;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(mlx4_get_internal_clock_params);
|
||||||
|
|
||||||
static void unmap_internal_clock(struct mlx4_dev *dev)
|
static void unmap_internal_clock(struct mlx4_dev *dev)
|
||||||
{
|
{
|
||||||
struct mlx4_priv *priv = mlx4_priv(dev);
|
struct mlx4_priv *priv = mlx4_priv(dev);
|
||||||
|
|
|
@ -829,6 +829,12 @@ struct mlx4_dev {
|
||||||
struct mlx4_vf_dev *dev_vfs;
|
struct mlx4_vf_dev *dev_vfs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct mlx4_clock_params {
|
||||||
|
u64 offset;
|
||||||
|
u8 bar;
|
||||||
|
u8 size;
|
||||||
|
};
|
||||||
|
|
||||||
struct mlx4_eqe {
|
struct mlx4_eqe {
|
||||||
u8 reserved1;
|
u8 reserved1;
|
||||||
u8 type;
|
u8 type;
|
||||||
|
@ -1485,4 +1491,7 @@ int mlx4_ACCESS_PTYS_REG(struct mlx4_dev *dev,
|
||||||
enum mlx4_access_reg_method method,
|
enum mlx4_access_reg_method method,
|
||||||
struct mlx4_ptys_reg *ptys_reg);
|
struct mlx4_ptys_reg *ptys_reg);
|
||||||
|
|
||||||
|
int mlx4_get_internal_clock_params(struct mlx4_dev *dev,
|
||||||
|
struct mlx4_clock_params *params);
|
||||||
|
|
||||||
#endif /* MLX4_DEVICE_H */
|
#endif /* MLX4_DEVICE_H */
|
||||||
|
|
Loading…
Reference in New Issue