Lines Matching refs:mvdev

51 static int create_uctx(struct mlx5_vdpa_dev *mvdev, u16 *uid)  in create_uctx()  argument
58 if (MLX5_CAP_GEN(mvdev->mdev, umem_uid_0)) in create_uctx()
62 if (!MLX5_CAP_GEN(mvdev->mdev, log_max_uctx)) in create_uctx()
73 err = mlx5_cmd_exec(mvdev->mdev, in, inlen, out, sizeof(out)); in create_uctx()
81 static void destroy_uctx(struct mlx5_vdpa_dev *mvdev, u32 uid) in destroy_uctx() argument
92 mlx5_cmd_exec(mvdev->mdev, in, sizeof(in), out, sizeof(out)); in destroy_uctx()
95 int mlx5_vdpa_create_tis(struct mlx5_vdpa_dev *mvdev, void *in, u32 *tisn) in mlx5_vdpa_create_tis() argument
101 MLX5_SET(create_tis_in, in, uid, mvdev->res.uid); in mlx5_vdpa_create_tis()
102 err = mlx5_cmd_exec_inout(mvdev->mdev, create_tis, in, out); in mlx5_vdpa_create_tis()
109 void mlx5_vdpa_destroy_tis(struct mlx5_vdpa_dev *mvdev, u32 tisn) in mlx5_vdpa_destroy_tis() argument
114 MLX5_SET(destroy_tis_in, in, uid, mvdev->res.uid); in mlx5_vdpa_destroy_tis()
116 mlx5_cmd_exec_in(mvdev->mdev, destroy_tis, in); in mlx5_vdpa_destroy_tis()
119 int mlx5_vdpa_create_rqt(struct mlx5_vdpa_dev *mvdev, void *in, int inlen, u32 *rqtn) in mlx5_vdpa_create_rqt() argument
125 err = mlx5_cmd_exec(mvdev->mdev, in, inlen, out, sizeof(out)); in mlx5_vdpa_create_rqt()
132 int mlx5_vdpa_modify_rqt(struct mlx5_vdpa_dev *mvdev, void *in, int inlen, u32 rqtn) in mlx5_vdpa_modify_rqt() argument
136 MLX5_SET(modify_rqt_in, in, uid, mvdev->res.uid); in mlx5_vdpa_modify_rqt()
139 return mlx5_cmd_exec(mvdev->mdev, in, inlen, out, sizeof(out)); in mlx5_vdpa_modify_rqt()
142 void mlx5_vdpa_destroy_rqt(struct mlx5_vdpa_dev *mvdev, u32 rqtn) in mlx5_vdpa_destroy_rqt() argument
147 MLX5_SET(destroy_rqt_in, in, uid, mvdev->res.uid); in mlx5_vdpa_destroy_rqt()
149 mlx5_cmd_exec_in(mvdev->mdev, destroy_rqt, in); in mlx5_vdpa_destroy_rqt()
152 int mlx5_vdpa_create_tir(struct mlx5_vdpa_dev *mvdev, void *in, u32 *tirn) in mlx5_vdpa_create_tir() argument
158 err = mlx5_cmd_exec_inout(mvdev->mdev, create_tir, in, out); in mlx5_vdpa_create_tir()
165 void mlx5_vdpa_destroy_tir(struct mlx5_vdpa_dev *mvdev, u32 tirn) in mlx5_vdpa_destroy_tir() argument
170 MLX5_SET(destroy_tir_in, in, uid, mvdev->res.uid); in mlx5_vdpa_destroy_tir()
172 mlx5_cmd_exec_in(mvdev->mdev, destroy_tir, in); in mlx5_vdpa_destroy_tir()
175 int mlx5_vdpa_alloc_transport_domain(struct mlx5_vdpa_dev *mvdev, u32 *tdn) in mlx5_vdpa_alloc_transport_domain() argument
182 MLX5_SET(alloc_transport_domain_in, in, uid, mvdev->res.uid); in mlx5_vdpa_alloc_transport_domain()
184 err = mlx5_cmd_exec_inout(mvdev->mdev, alloc_transport_domain, in, out); in mlx5_vdpa_alloc_transport_domain()
191 void mlx5_vdpa_dealloc_transport_domain(struct mlx5_vdpa_dev *mvdev, u32 tdn) in mlx5_vdpa_dealloc_transport_domain() argument
196 MLX5_SET(dealloc_transport_domain_in, in, uid, mvdev->res.uid); in mlx5_vdpa_dealloc_transport_domain()
198 mlx5_cmd_exec_in(mvdev->mdev, dealloc_transport_domain, in); in mlx5_vdpa_dealloc_transport_domain()
201 int mlx5_vdpa_create_mkey(struct mlx5_vdpa_dev *mvdev, u32 *mkey, u32 *in, in mlx5_vdpa_create_mkey() argument
209 MLX5_SET(create_mkey_in, in, uid, mvdev->res.uid); in mlx5_vdpa_create_mkey()
211 err = mlx5_cmd_exec(mvdev->mdev, in, inlen, lout, sizeof(lout)); in mlx5_vdpa_create_mkey()
220 int mlx5_vdpa_destroy_mkey(struct mlx5_vdpa_dev *mvdev, u32 mkey) in mlx5_vdpa_destroy_mkey() argument
224 MLX5_SET(destroy_mkey_in, in, uid, mvdev->res.uid); in mlx5_vdpa_destroy_mkey()
227 return mlx5_cmd_exec_in(mvdev->mdev, destroy_mkey, in); in mlx5_vdpa_destroy_mkey()
230 static int init_ctrl_vq(struct mlx5_vdpa_dev *mvdev) in init_ctrl_vq() argument
232 mvdev->cvq.iotlb = vhost_iotlb_alloc(0, 0); in init_ctrl_vq()
233 if (!mvdev->cvq.iotlb) in init_ctrl_vq()
236 spin_lock_init(&mvdev->cvq.iommu_lock); in init_ctrl_vq()
237 vringh_set_iotlb(&mvdev->cvq.vring, mvdev->cvq.iotlb, &mvdev->cvq.iommu_lock); in init_ctrl_vq()
242 static void cleanup_ctrl_vq(struct mlx5_vdpa_dev *mvdev) in cleanup_ctrl_vq() argument
244 vhost_iotlb_free(mvdev->cvq.iotlb); in cleanup_ctrl_vq()
247 int mlx5_vdpa_alloc_resources(struct mlx5_vdpa_dev *mvdev) in mlx5_vdpa_alloc_resources() argument
249 u64 offset = MLX5_CAP64_DEV_VDPA_EMULATION(mvdev->mdev, doorbell_bar_offset); in mlx5_vdpa_alloc_resources()
250 struct mlx5_vdpa_resources *res = &mvdev->res; in mlx5_vdpa_alloc_resources()
251 struct mlx5_core_dev *mdev = mvdev->mdev; in mlx5_vdpa_alloc_resources()
256 mlx5_vdpa_warn(mvdev, "resources already allocated\n"); in mlx5_vdpa_alloc_resources()
259 mutex_init(&mvdev->mr.mkey_mtx); in mlx5_vdpa_alloc_resources()
266 err = create_uctx(mvdev, &res->uid); in mlx5_vdpa_alloc_resources()
270 err = alloc_pd(mvdev, &res->pdn, res->uid); in mlx5_vdpa_alloc_resources()
274 err = get_null_mkey(mvdev, &res->null_mkey); in mlx5_vdpa_alloc_resources()
287 err = init_ctrl_vq(mvdev); in mlx5_vdpa_alloc_resources()
298 dealloc_pd(mvdev, res->pdn, res->uid); in mlx5_vdpa_alloc_resources()
300 destroy_uctx(mvdev, res->uid); in mlx5_vdpa_alloc_resources()
304 mutex_destroy(&mvdev->mr.mkey_mtx); in mlx5_vdpa_alloc_resources()
308 void mlx5_vdpa_free_resources(struct mlx5_vdpa_dev *mvdev) in mlx5_vdpa_free_resources() argument
310 struct mlx5_vdpa_resources *res = &mvdev->res; in mlx5_vdpa_free_resources()
315 cleanup_ctrl_vq(mvdev); in mlx5_vdpa_free_resources()
318 dealloc_pd(mvdev, res->pdn, res->uid); in mlx5_vdpa_free_resources()
319 destroy_uctx(mvdev, res->uid); in mlx5_vdpa_free_resources()
320 mlx5_put_uars_page(mvdev->mdev, res->uar); in mlx5_vdpa_free_resources()
321 mutex_destroy(&mvdev->mr.mkey_mtx); in mlx5_vdpa_free_resources()