Skip to content

Commit 9e2a187

Browse files
Maor Gottliebjgunthorpe
authored andcommitted
RDMA: Add a dedicated CQ resource tracker function
In order to avoid double multiplexing of the resource when it is a CQ, add a dedicated callback function. Link: https://lore.kernel.org/r/20200623113043.1228482-6-leon@kernel.org Signed-off-by: Maor Gottlieb <maorg@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent f443452 commit 9e2a187

File tree

9 files changed

+12
-22
lines changed

9 files changed

+12
-22
lines changed

drivers/infiniband/core/device.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,6 +2617,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)
26172617
SET_DEVICE_OP(dev_ops, drain_rq);
26182618
SET_DEVICE_OP(dev_ops, drain_sq);
26192619
SET_DEVICE_OP(dev_ops, enable_driver);
2620+
SET_DEVICE_OP(dev_ops, fill_res_cq_entry);
26202621
SET_DEVICE_OP(dev_ops, fill_res_entry);
26212622
SET_DEVICE_OP(dev_ops, fill_res_mr_entry);
26222623
SET_DEVICE_OP(dev_ops, fill_stat_mr_entry);

drivers/infiniband/core/nldev.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,8 @@ static int fill_res_cq_entry(struct sk_buff *msg, bool has_cap_net_admin,
598598
if (fill_res_name_pid(msg, res))
599599
goto err;
600600

601-
if (fill_res_entry(dev, msg, res))
602-
goto err;
603-
601+
if (dev->ops.fill_res_cq_entry)
602+
return dev->ops.fill_res_cq_entry(msg, cq);
604603
return 0;
605604

606605
err: return -EMSGSIZE;

drivers/infiniband/hw/cxgb4/iw_cxgb4.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,7 @@ struct c4iw_wr_wait *c4iw_alloc_wr_wait(gfp_t gfp);
10561056
typedef int c4iw_restrack_func(struct sk_buff *msg,
10571057
struct rdma_restrack_entry *res);
10581058
int c4iw_fill_res_mr_entry(struct sk_buff *msg, struct ib_mr *ibmr);
1059+
int c4iw_fill_res_cq_entry(struct sk_buff *msg, struct ib_cq *ibcq);
10591060
extern c4iw_restrack_func *c4iw_restrack_funcs[RDMA_RESTRACK_MAX];
10601061

10611062
#endif

drivers/infiniband/hw/cxgb4/provider.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ static const struct ib_device_ops c4iw_dev_ops = {
485485
.destroy_cq = c4iw_destroy_cq,
486486
.destroy_qp = c4iw_destroy_qp,
487487
.destroy_srq = c4iw_destroy_srq,
488+
.fill_res_cq_entry = c4iw_fill_res_cq_entry,
488489
.fill_res_entry = fill_res_entry,
489490
.fill_res_mr_entry = c4iw_fill_res_mr_entry,
490491
.get_dev_fw_str = get_dev_fw_str,

drivers/infiniband/hw/cxgb4/restrack.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,8 @@ static int fill_swcqes(struct sk_buff *msg, struct t4_cq *cq,
372372
return -EMSGSIZE;
373373
}
374374

375-
static int fill_res_cq_entry(struct sk_buff *msg,
376-
struct rdma_restrack_entry *res)
375+
int c4iw_fill_res_cq_entry(struct sk_buff *msg, struct ib_cq *ibcq)
377376
{
378-
struct ib_cq *ibcq = container_of(res, struct ib_cq, res);
379377
struct c4iw_cq *chp = to_c4iw_cq(ibcq);
380378
struct nlattr *table_attr;
381379
struct t4_cqe hwcqes[2];
@@ -494,5 +492,4 @@ int c4iw_fill_res_mr_entry(struct sk_buff *msg, struct ib_mr *ibmr)
494492
c4iw_restrack_func *c4iw_restrack_funcs[RDMA_RESTRACK_MAX] = {
495493
[RDMA_RESTRACK_QP] = fill_res_qp_entry,
496494
[RDMA_RESTRACK_CM_ID] = fill_res_ep_entry,
497-
[RDMA_RESTRACK_CQ] = fill_res_cq_entry,
498495
};

drivers/infiniband/hw/hns/hns_roce_device.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,6 +1266,6 @@ void hns_roce_handle_device_err(struct hns_roce_dev *hr_dev);
12661266
int hns_roce_init(struct hns_roce_dev *hr_dev);
12671267
void hns_roce_exit(struct hns_roce_dev *hr_dev);
12681268

1269-
int hns_roce_fill_res_entry(struct sk_buff *msg,
1270-
struct rdma_restrack_entry *res);
1269+
int hns_roce_fill_res_cq_entry(struct sk_buff *msg,
1270+
struct ib_cq *ib_cq);
12711271
#endif /* _HNS_ROCE_DEVICE_H */

drivers/infiniband/hw/hns/hns_roce_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ static const struct ib_device_ops hns_roce_dev_ops = {
428428
.destroy_ah = hns_roce_destroy_ah,
429429
.destroy_cq = hns_roce_destroy_cq,
430430
.disassociate_ucontext = hns_roce_disassociate_ucontext,
431-
.fill_res_entry = hns_roce_fill_res_entry,
431+
.fill_res_cq_entry = hns_roce_fill_res_cq_entry,
432432
.get_dma_mr = hns_roce_get_dma_mr,
433433
.get_link_layer = hns_roce_get_link_layer,
434434
.get_port_immutable = hns_roce_port_immutable,

drivers/infiniband/hw/hns/hns_roce_restrack.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,9 @@ static int hns_roce_fill_cq(struct sk_buff *msg,
7676
return -EMSGSIZE;
7777
}
7878

79-
static int hns_roce_fill_res_cq_entry(struct sk_buff *msg,
80-
struct rdma_restrack_entry *res)
79+
int hns_roce_fill_res_cq_entry(struct sk_buff *msg,
80+
struct ib_cq *ib_cq)
8181
{
82-
struct ib_cq *ib_cq = container_of(res, struct ib_cq, res);
8382
struct hns_roce_dev *hr_dev = to_hr_dev(ib_cq->device);
8483
struct hns_roce_cq *hr_cq = to_hr_cq(ib_cq);
8584
struct hns_roce_v2_cq_context *context;
@@ -119,12 +118,3 @@ static int hns_roce_fill_res_cq_entry(struct sk_buff *msg,
119118
kfree(context);
120119
return ret;
121120
}
122-
123-
int hns_roce_fill_res_entry(struct sk_buff *msg,
124-
struct rdma_restrack_entry *res)
125-
{
126-
if (res->type == RDMA_RESTRACK_CQ)
127-
return hns_roce_fill_res_cq_entry(msg, res);
128-
129-
return 0;
130-
}

include/rdma/ib_verbs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2584,6 +2584,7 @@ struct ib_device_ops {
25842584
int (*fill_res_entry)(struct sk_buff *msg,
25852585
struct rdma_restrack_entry *entry);
25862586
int (*fill_res_mr_entry)(struct sk_buff *msg, struct ib_mr *ibmr);
2587+
int (*fill_res_cq_entry)(struct sk_buff *msg, struct ib_cq *ibcq);
25872588

25882589
/* Device lifecycle callbacks */
25892590
/*

0 commit comments

Comments
 (0)