Commit 4123bfb0 authored by Aharon Landau's avatar Aharon Landau Committed by Leon Romanovsky
Browse files

RDMA/mlx5: Move struct mlx5_core_mkey to mlx5_ib



Move mlx5_core_mkey struct to mlx5_ib, as the mlx5_core doesn't use it
at this point.

Signed-off-by: default avatarAharon Landau <aharonl@nvidia.com>
Reviewed-by: default avatarShay Drory <shayd@nvidia.com>
Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
parent 83fec3f1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1293,7 +1293,7 @@ static int devx_handle_mkey_indirect(struct devx_obj *obj,
				     void *in, void *out)
{
	struct mlx5_ib_devx_mr *devx_mr = &obj->devx_mr;
	struct mlx5_core_mkey *mkey;
	struct mlx5_ib_mkey *mkey;
	void *mkc;
	u8 key;

+19 −6
Original line number Diff line number Diff line
@@ -619,6 +619,19 @@ struct mlx5_user_mmap_entry {
	u32 page_idx;
};

enum mlx5_mkey_type {
	MLX5_MKEY_MR = 1,
	MLX5_MKEY_MW,
	MLX5_MKEY_INDIRECT_DEVX,
};

struct mlx5_ib_mkey {
	u32 key;
	enum mlx5_mkey_type type;
	struct wait_queue_head wait;
	refcount_t usecount;
};

#define MLX5_IB_MTT_PRESENT (MLX5_IB_MTT_READ | MLX5_IB_MTT_WRITE)

#define MLX5_IB_DM_MEMIC_ALLOWED_ACCESS (IB_ACCESS_LOCAL_WRITE   |\
@@ -637,7 +650,7 @@ struct mlx5_user_mmap_entry {

struct mlx5_ib_mr {
	struct ib_mr ibmr;
	struct mlx5_core_mkey mmkey;
	struct mlx5_ib_mkey mmkey;

	/* User MR data */
	struct mlx5_cache_ent *cache_ent;
@@ -713,12 +726,12 @@ static inline bool is_dmabuf_mr(struct mlx5_ib_mr *mr)

struct mlx5_ib_mw {
	struct ib_mw		ibmw;
	struct mlx5_core_mkey	mmkey;
	struct mlx5_ib_mkey	mmkey;
	int			ndescs;
};

struct mlx5_ib_devx_mr {
	struct mlx5_core_mkey	mmkey;
	struct mlx5_ib_mkey	mmkey;
	int			ndescs;
};

@@ -1579,7 +1592,7 @@ static inline bool mlx5_ib_can_reconfig_with_umr(struct mlx5_ib_dev *dev,
}

static inline int mlx5r_store_odp_mkey(struct mlx5_ib_dev *dev,
				       struct mlx5_core_mkey *mmkey)
				       struct mlx5_ib_mkey *mmkey)
{
	refcount_set(&mmkey->usecount, 1);

@@ -1588,14 +1601,14 @@ static inline int mlx5r_store_odp_mkey(struct mlx5_ib_dev *dev,
}

/* deref an mkey that can participate in ODP flow */
static inline void mlx5r_deref_odp_mkey(struct mlx5_core_mkey *mmkey)
static inline void mlx5r_deref_odp_mkey(struct mlx5_ib_mkey *mmkey)
{
	if (refcount_dec_and_test(&mmkey->usecount))
		wake_up(&mmkey->wait);
}

/* deref an mkey that can participate in ODP flow and wait for relese */
static inline void mlx5r_deref_wait_odp_mkey(struct mlx5_core_mkey *mmkey)
static inline void mlx5r_deref_wait_odp_mkey(struct mlx5_ib_mkey *mmkey)
{
	mlx5r_deref_odp_mkey(mmkey);
	wait_event(mmkey->wait, refcount_read(&mmkey->usecount) == 0);
+5 −7
Original line number Diff line number Diff line
@@ -88,9 +88,8 @@ static void set_mkc_access_pd_addr_fields(void *mkc, int acc, u64 start_addr,
	MLX5_SET64(mkc, mkc, start_addr, start_addr);
}

static void
assign_mkey_variant(struct mlx5_ib_dev *dev, struct mlx5_core_mkey *mkey,
		    u32 *in)
static void assign_mkey_variant(struct mlx5_ib_dev *dev,
				struct mlx5_ib_mkey *mkey, u32 *in)
{
	u8 key = atomic_inc_return(&dev->mkey_var);
	void *mkc;
@@ -100,9 +99,8 @@ assign_mkey_variant(struct mlx5_ib_dev *dev, struct mlx5_core_mkey *mkey,
	mkey->key = key;
}

static int
mlx5_ib_create_mkey(struct mlx5_ib_dev *dev, struct mlx5_core_mkey *mkey,
		    u32 *in, int inlen)
static int mlx5_ib_create_mkey(struct mlx5_ib_dev *dev,
			       struct mlx5_ib_mkey *mkey, u32 *in, int inlen)
{
	int ret;

@@ -116,7 +114,7 @@ mlx5_ib_create_mkey(struct mlx5_ib_dev *dev, struct mlx5_core_mkey *mkey,

static int
mlx5_ib_create_mkey_cb(struct mlx5_ib_dev *dev,
		       struct mlx5_core_mkey *mkey,
		       struct mlx5_ib_mkey *mkey,
		       struct mlx5_async_ctx *async_ctx,
		       u32 *in, int inlen, u32 *out, int outlen,
		       struct mlx5_async_work *context)
+4 −4
Original line number Diff line number Diff line
@@ -788,7 +788,7 @@ struct pf_frame {
	int depth;
};

static bool mkey_is_eq(struct mlx5_core_mkey *mmkey, u32 key)
static bool mkey_is_eq(struct mlx5_ib_mkey *mmkey, u32 key)
{
	if (!mmkey)
		return false;
@@ -797,7 +797,7 @@ static bool mkey_is_eq(struct mlx5_core_mkey *mmkey, u32 key)
	return mmkey->key == key;
}

static int get_indirect_num_descs(struct mlx5_core_mkey *mmkey)
static int get_indirect_num_descs(struct mlx5_ib_mkey *mmkey)
{
	struct mlx5_ib_mw *mw;
	struct mlx5_ib_devx_mr *devx_mr;
@@ -831,7 +831,7 @@ static int pagefault_single_data_segment(struct mlx5_ib_dev *dev,
{
	int npages = 0, ret, i, outlen, cur_outlen = 0, depth = 0;
	struct pf_frame *head = NULL, *frame;
	struct mlx5_core_mkey *mmkey;
	struct mlx5_ib_mkey *mmkey;
	struct mlx5_ib_mr *mr;
	struct mlx5_klm *pklm;
	u32 *out = NULL;
@@ -1703,8 +1703,8 @@ get_prefetchable_mr(struct ib_pd *pd, enum ib_uverbs_advise_mr_advice advice,
		    u32 lkey)
{
	struct mlx5_ib_dev *dev = to_mdev(pd->device);
	struct mlx5_core_mkey *mmkey;
	struct mlx5_ib_mr *mr = NULL;
	struct mlx5_ib_mkey *mmkey;

	xa_lock(&dev->odp_mkeys);
	mmkey = xa_load(&dev->odp_mkeys, mlx5_base_mkey(lkey));
+0 −13
Original line number Diff line number Diff line
@@ -357,19 +357,6 @@ struct mlx5_core_sig_ctx {
	u32			sigerr_count;
};

enum {
	MLX5_MKEY_MR = 1,
	MLX5_MKEY_MW,
	MLX5_MKEY_INDIRECT_DEVX,
};

struct mlx5_core_mkey {
	u32			key;
	u32			type;
	struct wait_queue_head wait;
	refcount_t usecount;
};

#define MLX5_24BIT_MASK		((1 << 24) - 1)

enum mlx5_res_type {