Skip to content

Commit f4fd0b2

Browse files
Michael S. TsirkinRoland Dreier
authored andcommitted
IB: Add CQ comp_vector support
Add a num_comp_vectors member to struct ib_device and extend ib_create_cq() to pass in a comp_vector parameter -- this parallels the userspace libibverbs API. Update all hardware drivers to set num_comp_vectors to 1 and have all ULPs pass 0 for the comp_vector value. Pass the value of num_comp_vectors to userspace rather than hard-coding a value of 1. We want multiple CQ event vector support (via MSI-X or similar for adapters that can generate multiple interrupts), but it's not clear how many vectors we want, or how we want to deal with policy issues such as how to decide which vector to use or how to set up interrupt affinity. This patch is useful for experimenting, since no core changes will be necessary when updating a driver to support multiple vectors, and we know that we want to make at least these changes anyway. Signed-off-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Roland Dreier <[email protected]>
1 parent 154257f commit f4fd0b2

File tree

18 files changed

+28
-16
lines changed

18 files changed

+28
-16
lines changed

drivers/infiniband/core/mad.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2771,7 +2771,7 @@ static int ib_mad_port_open(struct ib_device *device,
27712771
cq_size = (IB_MAD_QP_SEND_SIZE + IB_MAD_QP_RECV_SIZE) * 2;
27722772
port_priv->cq = ib_create_cq(port_priv->device,
27732773
ib_mad_thread_completion_handler,
2774-
NULL, port_priv, cq_size);
2774+
NULL, port_priv, cq_size, 0);
27752775
if (IS_ERR(port_priv->cq)) {
27762776
printk(KERN_ERR PFX "Couldn't create ib_mad CQ\n");
27772777
ret = PTR_ERR(port_priv->cq);

drivers/infiniband/core/uverbs_cmd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,7 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file,
802802
INIT_LIST_HEAD(&obj->async_list);
803803

804804
cq = file->device->ib_dev->create_cq(file->device->ib_dev, cmd.cqe,
805+
cmd.comp_vector,
805806
file->ucontext, &udata);
806807
if (IS_ERR(cq)) {
807808
ret = PTR_ERR(cq);

drivers/infiniband/core/uverbs_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ static void ib_uverbs_add_one(struct ib_device *device)
752752
spin_unlock(&map_lock);
753753

754754
uverbs_dev->ib_dev = device;
755-
uverbs_dev->num_comp_vectors = 1;
755+
uverbs_dev->num_comp_vectors = device->num_comp_vectors;
756756

757757
uverbs_dev->dev = cdev_alloc();
758758
if (!uverbs_dev->dev)

drivers/infiniband/core/verbs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,11 +609,11 @@ EXPORT_SYMBOL(ib_destroy_qp);
609609
struct ib_cq *ib_create_cq(struct ib_device *device,
610610
ib_comp_handler comp_handler,
611611
void (*event_handler)(struct ib_event *, void *),
612-
void *cq_context, int cqe)
612+
void *cq_context, int cqe, int comp_vector)
613613
{
614614
struct ib_cq *cq;
615615

616-
cq = device->create_cq(device, cqe, NULL, NULL);
616+
cq = device->create_cq(device, cqe, comp_vector, NULL, NULL);
617617

618618
if (!IS_ERR(cq)) {
619619
cq->device = device;

drivers/infiniband/hw/amso1100/c2_provider.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static int c2_destroy_qp(struct ib_qp *ib_qp)
290290
return 0;
291291
}
292292

293-
static struct ib_cq *c2_create_cq(struct ib_device *ibdev, int entries,
293+
static struct ib_cq *c2_create_cq(struct ib_device *ibdev, int entries, int vector,
294294
struct ib_ucontext *context,
295295
struct ib_udata *udata)
296296
{
@@ -795,6 +795,7 @@ int c2_register_device(struct c2_dev *dev)
795795
memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid));
796796
memcpy(&dev->ibdev.node_guid, dev->pseudo_netdev->dev_addr, 6);
797797
dev->ibdev.phys_port_cnt = 1;
798+
dev->ibdev.num_comp_vectors = 1;
798799
dev->ibdev.dma_device = &dev->pcidev->dev;
799800
dev->ibdev.query_device = c2_query_device;
800801
dev->ibdev.query_port = c2_query_port;

drivers/infiniband/hw/cxgb3/iwch_provider.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static int iwch_destroy_cq(struct ib_cq *ib_cq)
139139
return 0;
140140
}
141141

142-
static struct ib_cq *iwch_create_cq(struct ib_device *ibdev, int entries,
142+
static struct ib_cq *iwch_create_cq(struct ib_device *ibdev, int entries, int vector,
143143
struct ib_ucontext *ib_context,
144144
struct ib_udata *udata)
145145
{
@@ -1110,6 +1110,7 @@ int iwch_register_device(struct iwch_dev *dev)
11101110
dev->ibdev.node_type = RDMA_NODE_RNIC;
11111111
memcpy(dev->ibdev.node_desc, IWCH_NODE_DESC, sizeof(IWCH_NODE_DESC));
11121112
dev->ibdev.phys_port_cnt = dev->rdev.port_info.nports;
1113+
dev->ibdev.num_comp_vectors = 1;
11131114
dev->ibdev.dma_device = &(dev->rdev.rnic_info.pdev->dev);
11141115
dev->ibdev.query_device = iwch_query_device;
11151116
dev->ibdev.query_port = iwch_query_port;

drivers/infiniband/hw/ehca/ehca_cq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ struct ehca_qp* ehca_cq_get_qp(struct ehca_cq *cq, int real_qp_num)
113113
return ret;
114114
}
115115

116-
struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe,
116+
struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
117117
struct ib_ucontext *context,
118118
struct ib_udata *udata)
119119
{

drivers/infiniband/hw/ehca/ehca_iverbs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ int ehca_destroy_eq(struct ehca_shca *shca, struct ehca_eq *eq);
123123
void *ehca_poll_eq(struct ehca_shca *shca, struct ehca_eq *eq);
124124

125125

126-
struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe,
126+
struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
127127
struct ib_ucontext *context,
128128
struct ib_udata *udata);
129129

drivers/infiniband/hw/ehca/ehca_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ int ehca_init_device(struct ehca_shca *shca)
313313

314314
shca->ib_device.node_type = RDMA_NODE_IB_CA;
315315
shca->ib_device.phys_port_cnt = shca->num_ports;
316+
shca->ib_device.num_comp_vectors = 1;
316317
shca->ib_device.dma_device = &shca->ibmebus_dev->ofdev.dev;
317318
shca->ib_device.query_device = ehca_query_device;
318319
shca->ib_device.query_port = ehca_query_port;
@@ -375,7 +376,7 @@ static int ehca_create_aqp1(struct ehca_shca *shca, u32 port)
375376
return -EPERM;
376377
}
377378

378-
ibcq = ib_create_cq(&shca->ib_device, NULL, NULL, (void*)(-1), 10);
379+
ibcq = ib_create_cq(&shca->ib_device, NULL, NULL, (void*)(-1), 10, 0);
379380
if (IS_ERR(ibcq)) {
380381
ehca_err(&shca->ib_device, "Cannot create AQP1 CQ.");
381382
return PTR_ERR(ibcq);

drivers/infiniband/hw/ipath/ipath_cq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static void send_complete(unsigned long data)
204204
*
205205
* Called by ib_create_cq() in the generic verbs code.
206206
*/
207-
struct ib_cq *ipath_create_cq(struct ib_device *ibdev, int entries,
207+
struct ib_cq *ipath_create_cq(struct ib_device *ibdev, int entries, int comp_vector,
208208
struct ib_ucontext *context,
209209
struct ib_udata *udata)
210210
{

drivers/infiniband/hw/ipath/ipath_verbs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,7 @@ int ipath_register_ib_device(struct ipath_devdata *dd)
15611561
(1ull << IB_USER_VERBS_CMD_POST_SRQ_RECV);
15621562
dev->node_type = RDMA_NODE_IB_CA;
15631563
dev->phys_port_cnt = 1;
1564+
dev->num_comp_vectors = 1;
15641565
dev->dma_device = &dd->pcidev->dev;
15651566
dev->query_device = ipath_query_device;
15661567
dev->modify_device = ipath_modify_device;

drivers/infiniband/hw/ipath/ipath_verbs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ int ipath_destroy_srq(struct ib_srq *ibsrq);
735735

736736
int ipath_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *entry);
737737

738-
struct ib_cq *ipath_create_cq(struct ib_device *ibdev, int entries,
738+
struct ib_cq *ipath_create_cq(struct ib_device *ibdev, int entries, int comp_vector,
739739
struct ib_ucontext *context,
740740
struct ib_udata *udata);
741741

drivers/infiniband/hw/mthca/mthca_provider.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ static int mthca_destroy_qp(struct ib_qp *qp)
663663
}
664664

665665
static struct ib_cq *mthca_create_cq(struct ib_device *ibdev, int entries,
666+
int comp_vector,
666667
struct ib_ucontext *context,
667668
struct ib_udata *udata)
668669
{
@@ -1292,6 +1293,7 @@ int mthca_register_device(struct mthca_dev *dev)
12921293
(1ull << IB_USER_VERBS_CMD_DETACH_MCAST);
12931294
dev->ib_dev.node_type = RDMA_NODE_IB_CA;
12941295
dev->ib_dev.phys_port_cnt = dev->limits.num_ports;
1296+
dev->ib_dev.num_comp_vectors = 1;
12951297
dev->ib_dev.dma_device = &dev->pdev->dev;
12961298
dev->ib_dev.query_device = mthca_query_device;
12971299
dev->ib_dev.query_port = mthca_query_port;

drivers/infiniband/ulp/ipoib/ipoib_cm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ static int ipoib_cm_tx_init(struct ipoib_cm_tx *p, u32 qpn,
793793
}
794794

795795
p->cq = ib_create_cq(priv->ca, ipoib_cm_tx_completion, NULL, p,
796-
ipoib_sendq_size + 1);
796+
ipoib_sendq_size + 1, 0);
797797
if (IS_ERR(p->cq)) {
798798
ret = PTR_ERR(p->cq);
799799
ipoib_warn(priv, "failed to allocate tx cq: %d\n", ret);

drivers/infiniband/ulp/ipoib/ipoib_verbs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca)
187187
if (!ret)
188188
size += ipoib_recvq_size;
189189

190-
priv->cq = ib_create_cq(priv->ca, ipoib_ib_completion, NULL, dev, size);
190+
priv->cq = ib_create_cq(priv->ca, ipoib_ib_completion, NULL, dev, size, 0);
191191
if (IS_ERR(priv->cq)) {
192192
printk(KERN_WARNING "%s: failed to create CQ\n", ca->name);
193193
goto out_free_mr;

drivers/infiniband/ulp/iser/iser_verbs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ static int iser_create_device_ib_res(struct iser_device *device)
7676
iser_cq_callback,
7777
iser_cq_event_callback,
7878
(void *)device,
79-
ISER_MAX_CQ_LEN);
79+
ISER_MAX_CQ_LEN, 0);
8080
if (IS_ERR(device->cq))
8181
goto cq_err;
8282

drivers/infiniband/ulp/srp/ib_srp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ static int srp_create_target_ib(struct srp_target_port *target)
197197
return -ENOMEM;
198198

199199
target->cq = ib_create_cq(target->srp_host->dev->dev, srp_completion,
200-
NULL, target, SRP_CQ_SIZE);
200+
NULL, target, SRP_CQ_SIZE, 0);
201201
if (IS_ERR(target->cq)) {
202202
ret = PTR_ERR(target->cq);
203203
goto out;

include/rdma/ib_verbs.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,8 @@ struct ib_device {
912912

913913
u32 flags;
914914

915+
int num_comp_vectors;
916+
915917
struct iw_cm_verbs *iwcm;
916918

917919
int (*query_device)(struct ib_device *device,
@@ -978,6 +980,7 @@ struct ib_device {
978980
struct ib_recv_wr *recv_wr,
979981
struct ib_recv_wr **bad_recv_wr);
980982
struct ib_cq * (*create_cq)(struct ib_device *device, int cqe,
983+
int comp_vector,
981984
struct ib_ucontext *context,
982985
struct ib_udata *udata);
983986
int (*destroy_cq)(struct ib_cq *cq);
@@ -1358,13 +1361,15 @@ static inline int ib_post_recv(struct ib_qp *qp,
13581361
* @cq_context: Context associated with the CQ returned to the user via
13591362
* the associated completion and event handlers.
13601363
* @cqe: The minimum size of the CQ.
1364+
* @comp_vector - Completion vector used to signal completion events.
1365+
* Must be >= 0 and < context->num_comp_vectors.
13611366
*
13621367
* Users can examine the cq structure to determine the actual CQ size.
13631368
*/
13641369
struct ib_cq *ib_create_cq(struct ib_device *device,
13651370
ib_comp_handler comp_handler,
13661371
void (*event_handler)(struct ib_event *, void *),
1367-
void *cq_context, int cqe);
1372+
void *cq_context, int cqe, int comp_vector);
13681373

13691374
/**
13701375
* ib_resize_cq - Modifies the capacity of the CQ.

0 commit comments

Comments
 (0)