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

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.orgSigned-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
...@@ -2617,8 +2617,8 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops) ...@@ -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_rq);
SET_DEVICE_OP(dev_ops, drain_sq); SET_DEVICE_OP(dev_ops, drain_sq);
SET_DEVICE_OP(dev_ops, enable_driver); 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_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_mr_entry);
SET_DEVICE_OP(dev_ops, fill_res_qp_entry); SET_DEVICE_OP(dev_ops, fill_res_qp_entry);
SET_DEVICE_OP(dev_ops, fill_stat_mr_entry); SET_DEVICE_OP(dev_ops, fill_stat_mr_entry);
......
...@@ -446,14 +446,6 @@ static int fill_res_name_pid(struct sk_buff *msg, ...@@ -446,14 +446,6 @@ static int fill_res_name_pid(struct sk_buff *msg,
return err ? -EMSGSIZE : 0; 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, static int fill_res_qp_entry(struct sk_buff *msg, bool has_cap_net_admin,
struct rdma_restrack_entry *res, uint32_t port) 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, ...@@ -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)) if (fill_res_name_pid(msg, res))
goto err; goto err;
if (fill_res_entry(dev, msg, res)) if (dev->ops.fill_res_cm_id_entry)
goto err; return dev->ops.fill_res_cm_id_entry(msg, cm_id);
return 0; return 0;
err: return -EMSGSIZE; err: return -EMSGSIZE;
......
...@@ -1053,11 +1053,9 @@ int c4iw_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr, ...@@ -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); const struct ib_recv_wr **bad_wr);
struct c4iw_wr_wait *c4iw_alloc_wr_wait(gfp_t gfp); 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_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_cq_entry(struct sk_buff *msg, struct ib_cq *ibcq);
int c4iw_fill_res_qp_entry(struct sk_buff *msg, struct ib_qp *ibqp); 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 #endif
...@@ -458,13 +458,6 @@ static void get_dev_fw_str(struct ib_device *dev, char *str) ...@@ -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)); 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 = { static const struct ib_device_ops c4iw_dev_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.driver_id = RDMA_DRIVER_CXGB4, .driver_id = RDMA_DRIVER_CXGB4,
...@@ -486,7 +479,7 @@ static const struct ib_device_ops c4iw_dev_ops = { ...@@ -486,7 +479,7 @@ static const struct ib_device_ops c4iw_dev_ops = {
.destroy_qp = c4iw_destroy_qp, .destroy_qp = c4iw_destroy_qp,
.destroy_srq = c4iw_destroy_srq, .destroy_srq = c4iw_destroy_srq,
.fill_res_cq_entry = c4iw_fill_res_cq_entry, .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, .fill_res_mr_entry = c4iw_fill_res_mr_entry,
.get_dev_fw_str = get_dev_fw_str, .get_dev_fw_str = get_dev_fw_str,
.get_dma_mr = c4iw_get_dma_mr, .get_dma_mr = c4iw_get_dma_mr,
......
...@@ -193,10 +193,9 @@ union union_ep { ...@@ -193,10 +193,9 @@ union union_ep {
struct c4iw_ep ep; struct c4iw_ep ep;
}; };
static int fill_res_ep_entry(struct sk_buff *msg, int c4iw_fill_res_cm_id_entry(struct sk_buff *msg,
struct rdma_restrack_entry *res) struct rdma_cm_id *cm_id)
{ {
struct rdma_cm_id *cm_id = rdma_res_to_id(res);
struct nlattr *table_attr; struct nlattr *table_attr;
struct c4iw_ep_common *epcp; struct c4iw_ep_common *epcp;
struct c4iw_listen_ep *listen_ep = NULL; 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) ...@@ -486,7 +485,3 @@ int c4iw_fill_res_mr_entry(struct sk_buff *msg, struct ib_mr *ibmr)
err: err:
return -EMSGSIZE; return -EMSGSIZE;
} }
c4iw_restrack_func *c4iw_restrack_funcs[RDMA_RESTRACK_MAX] = {
[RDMA_RESTRACK_CM_ID] = fill_res_ep_entry,
};
...@@ -75,6 +75,7 @@ struct ib_umem_odp; ...@@ -75,6 +75,7 @@ struct ib_umem_odp;
struct ib_uqp_object; struct ib_uqp_object;
struct ib_usrq_object; struct ib_usrq_object;
struct ib_uwq_object; struct ib_uwq_object;
struct rdma_cm_id;
extern struct workqueue_struct *ib_wq; extern struct workqueue_struct *ib_wq;
extern struct workqueue_struct *ib_comp_wq; extern struct workqueue_struct *ib_comp_wq;
...@@ -2581,11 +2582,10 @@ struct ib_device_ops { ...@@ -2581,11 +2582,10 @@ struct ib_device_ops {
/** /**
* Allows rdma drivers to add their own restrack attributes. * Allows rdma drivers to add their own restrack attributes.
*/ */
int (*fill_res_entry)(struct sk_buff *msg,
struct rdma_restrack_entry *entry);
int (*fill_res_mr_entry)(struct sk_buff *msg, struct ib_mr *ibmr); int (*fill_res_mr_entry)(struct sk_buff *msg, struct ib_mr *ibmr);
int (*fill_res_cq_entry)(struct sk_buff *msg, struct ib_cq *ibcq); int (*fill_res_cq_entry)(struct sk_buff *msg, struct ib_cq *ibcq);
int (*fill_res_qp_entry)(struct sk_buff *msg, struct ib_qp *ibqp); int (*fill_res_qp_entry)(struct sk_buff *msg, struct ib_qp *ibqp);
int (*fill_res_cm_id_entry)(struct sk_buff *msg, struct rdma_cm_id *id);
/* Device lifecycle callbacks */ /* Device lifecycle callbacks */
/* /*
......
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