Commit 211cd945 authored by Maor Gottlieb's avatar Maor Gottlieb Committed by Jason Gunthorpe
Browse files

RDMA: Add dedicated CM_ID resource tracker function

In order to avoid double multiplexing of the resource when it is a cm id,
add a dedicated callback function. In addition remove fill_res_entry which
is not used anymore.

Link: https://lore.kernel.org/r/20200623113043.1228482-8-leon@kernel.org


Signed-off-by: default avatarMaor Gottlieb <maorg@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent 5cc34116
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2617,8 +2617,8 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)
	SET_DEVICE_OP(dev_ops, drain_rq);
	SET_DEVICE_OP(dev_ops, drain_sq);
	SET_DEVICE_OP(dev_ops, enable_driver);
	SET_DEVICE_OP(dev_ops, fill_res_cm_id_entry);
	SET_DEVICE_OP(dev_ops, fill_res_cq_entry);
	SET_DEVICE_OP(dev_ops, fill_res_entry);
	SET_DEVICE_OP(dev_ops, fill_res_mr_entry);
	SET_DEVICE_OP(dev_ops, fill_res_qp_entry);
	SET_DEVICE_OP(dev_ops, fill_stat_mr_entry);
+2 −11
Original line number Diff line number Diff line
@@ -446,14 +446,6 @@ static int fill_res_name_pid(struct sk_buff *msg,
	return err ? -EMSGSIZE : 0;
}

static bool fill_res_entry(struct ib_device *dev, struct sk_buff *msg,
			   struct rdma_restrack_entry *res)
{
	if (!dev->ops.fill_res_entry)
		return false;
	return dev->ops.fill_res_entry(msg, res);
}

static int fill_res_qp_entry(struct sk_buff *msg, bool has_cap_net_admin,
			     struct rdma_restrack_entry *res, uint32_t port)
{
@@ -559,9 +551,8 @@ static int fill_res_cm_id_entry(struct sk_buff *msg, bool has_cap_net_admin,
	if (fill_res_name_pid(msg, res))
		goto err;

	if (fill_res_entry(dev, msg, res))
		goto err;

	if (dev->ops.fill_res_cm_id_entry)
		return dev->ops.fill_res_cm_id_entry(msg, cm_id);
	return 0;

err: return -EMSGSIZE;
+1 −3
Original line number Diff line number Diff line
@@ -1053,11 +1053,9 @@ int c4iw_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
		       const struct ib_recv_wr **bad_wr);
struct c4iw_wr_wait *c4iw_alloc_wr_wait(gfp_t gfp);

typedef int c4iw_restrack_func(struct sk_buff *msg,
			       struct rdma_restrack_entry *res);
int c4iw_fill_res_mr_entry(struct sk_buff *msg, struct ib_mr *ibmr);
int c4iw_fill_res_cq_entry(struct sk_buff *msg, struct ib_cq *ibcq);
int c4iw_fill_res_qp_entry(struct sk_buff *msg, struct ib_qp *ibqp);
extern c4iw_restrack_func *c4iw_restrack_funcs[RDMA_RESTRACK_MAX];
int c4iw_fill_res_cm_id_entry(struct sk_buff *msg, struct rdma_cm_id *cm_id);

#endif
+1 −8
Original line number Diff line number Diff line
@@ -458,13 +458,6 @@ static void get_dev_fw_str(struct ib_device *dev, char *str)
		 FW_HDR_FW_VER_BUILD_G(c4iw_dev->rdev.lldi.fw_vers));
}

static int fill_res_entry(struct sk_buff *msg, struct rdma_restrack_entry *res)
{
	return (res->type < ARRAY_SIZE(c4iw_restrack_funcs) &&
		c4iw_restrack_funcs[res->type]) ?
		c4iw_restrack_funcs[res->type](msg, res) : 0;
}

static const struct ib_device_ops c4iw_dev_ops = {
	.owner = THIS_MODULE,
	.driver_id = RDMA_DRIVER_CXGB4,
@@ -486,7 +479,7 @@ static const struct ib_device_ops c4iw_dev_ops = {
	.destroy_qp = c4iw_destroy_qp,
	.destroy_srq = c4iw_destroy_srq,
	.fill_res_cq_entry = c4iw_fill_res_cq_entry,
	.fill_res_entry = fill_res_entry,
	.fill_res_cm_id_entry = c4iw_fill_res_cm_id_entry,
	.fill_res_mr_entry = c4iw_fill_res_mr_entry,
	.get_dev_fw_str = get_dev_fw_str,
	.get_dma_mr = c4iw_get_dma_mr,
+2 −7
Original line number Diff line number Diff line
@@ -193,10 +193,9 @@ union union_ep {
	struct c4iw_ep ep;
};

static int fill_res_ep_entry(struct sk_buff *msg,
			     struct rdma_restrack_entry *res)
int c4iw_fill_res_cm_id_entry(struct sk_buff *msg,
			      struct rdma_cm_id *cm_id)
{
	struct rdma_cm_id *cm_id = rdma_res_to_id(res);
	struct nlattr *table_attr;
	struct c4iw_ep_common *epcp;
	struct c4iw_listen_ep *listen_ep = NULL;
@@ -486,7 +485,3 @@ int c4iw_fill_res_mr_entry(struct sk_buff *msg, struct ib_mr *ibmr)
err:
	return -EMSGSIZE;
}

c4iw_restrack_func *c4iw_restrack_funcs[RDMA_RESTRACK_MAX] = {
	[RDMA_RESTRACK_CM_ID]	= fill_res_ep_entry,
};
Loading