RDMA/mana_ib: Add EQ interrupt support to mana ib driver.
Subsystems (5)
Wei Hu
maintainerPATCH 1/1 RDMA/mana_ib: Add EQ interrupt support to mana ib driver.
Add EQ interrupt support for mana ib driver. Allocate EQs per ucontext to receive interrupt. Attach EQ when CQ is created. Call CQ interrupt handler when completion interrupt happens. EQs are destroyed when ucontext is deallocated.
The change calls some public APIs in mana ethernet driver to allocate EQs and other resources. Ehe EQ process routine is also shared by mana ethernet and mana ib drivers.
--- drivers/infiniband/hw/mana/cq.c | 32 ++++- drivers/infiniband/hw/mana/main.c | 87 ++++++++++++ drivers/infiniband/hw/mana/mana_ib.h | 4 + drivers/infiniband/hw/mana/qp.c | 87 +++++++++++- .../net/ethernet/microsoft/mana/gdma_main.c | 131 ++++++++++-------- drivers/net/ethernet/microsoft/mana/mana_en.c | 1 + include/net/mana/gdma.h | 9 +- 7 files changed, 287 insertions(+), 64 deletions(-)
drivers/infiniband/hw/mana/cq.c +30 -2
@@ -12,13 +12,20 @@ int mana_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,struct ib_device *ibdev = ibcq->device;struct mana_ib_create_cq ucmd = {};struct mana_ib_dev *mdev; +struct gdma_context *gc; +struct gdma_dev *gd;int err; mdev = container_of(ibdev, struct mana_ib_dev, ib_dev); + gd = mdev->gdma_dev; + gc = gd->gdma_context;if (udata->inlen <sizeof (ucmd))return -EINVAL ; + cq->comp_vector = attr->comp_vector > gc->max_num_queues ? +0 : attr->comp_vector; + err =ib_copy_from_udata (&ucmd, udata,min (sizeof (ucmd), udata->inlen));if (err) { ibdev_dbg(ibdev,
@@ -69,11 +76,32 @@ int mana_ib_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) struct mana_ib_cq *cq = container_of(ibcq, struct mana_ib_cq, ibcq);struct ib_device *ibdev = ibcq->device;struct mana_ib_dev *mdev; +struct gdma_context *gc; +struct gdma_dev *gd; + mdev = container_of(ibdev, struct mana_ib_dev, ib_dev); + gd = mdev->gdma_dev; + gc = gd->gdma_context; -mana_ib_gd_destroy_dma_region (mdev, cq->gdma_region); -ib_umem_release (cq->umem); + + +if (atomic_read (&ibcq->usecnt) ==0 ) { +mana_ib_gd_destroy_dma_region (mdev, cq->gdma_region); +ibdev_dbg (ibdev,"freeing gdma cq %p\n" , gc->cq_table[cq->id]); +kfree (gc->cq_table[cq->id]); + gc->cq_table[cq->id] =NULL ; +ib_umem_release (cq->umem); + }return 0 ; } + +void mana_ib_cq_handler (void *ctx,struct gdma_queue *gdma_cq) +{ +struct mana_ib_cq *cq = ctx; +struct ib_device *ibdev = cq->ibcq.device; + +ibdev_dbg (ibdev,"Enter %s %d\n" , __func__, __LINE__); + cq->ibcq.comp_handler (&cq->ibcq, cq->ibcq.cq_context); +}
drivers/infiniband/hw/mana/main.c +87 -0
106 lines not on this page · raw message
drivers/infiniband/hw/mana/mana_ib.h +4 -0
@@ -67,6 +67,7 @@ struct mana_ib_cq {int cqe;u64 gdma_region;u64 id; +u32 comp_vector; };struct mana_ib_qp {
@@ -86,6 +87,7 @@ struct mana_ib_qp {struct mana_ib_ucontext {struct ib_ucontext ibucontext;u32 doorbell; +struct mana_eq *eqs; };struct mana_ib_rwq_ind_table {
@@ -159,4 +161,6 @@ int mana_ib_query_gid(struct ib_device *ibdev, u32 port, int index,void mana_ib_disassociate_ucontext (struct ib_ucontext *ibcontext); +void mana_ib_cq_handler (void *ctx,struct gdma_queue *gdma_cq); +#endif
drivers/infiniband/hw/mana/qp.c +81 -6
176 lines not on this page · raw message
drivers/net/ethernet/microsoft/mana/gdma_main.c +77 -54
227 lines not on this page · raw message
drivers/net/ethernet/microsoft/mana/mana_en.c +1 -0
@@ -1156,6 +1156,7 @@ static int mana_create_eq(struct mana_context *ac) spec.eq.callback =NULL ; spec.eq.context = ac->eqs; spec.eq.log2_throttle_limit =LOG2_EQ_THROTTLE ; + spec.eq.msix_allocated = false;for (i =0 ; i < gc->max_num_queues; i++) { err =mana_gd_create_mana_eq (gd, &spec, &ac->eqs[i].eq);
include/net/mana/gdma.h +7 -2
@@ -6,6 +6,7 @@#include <linux/dma-mapping.h> #include <linux/netdevice.h> +#include <linux/list.h> #include "shm_channel.h"
@@ -291,6 +292,8 @@ struct gdma_queue {u32 head;u32 tail; +struct list_head entry; +/* Extra fields specific to EQ/CQ. */ union { struct {
@@ -325,6 +328,8 @@ struct gdma_queue_spec {void *context;unsigned long log2_throttle_limit; +bool msix_allocated; +unsigned int msix_index; } eq;struct {
@@ -340,8 +345,8 @@ struct gdma_queue_spec {#define MANA_IRQ_NAME_SZ 32struct gdma_irq_context { -void (*handler)(void *arg); -void *arg; +void (*handler)(struct list_head *arg); +struct list_head eq_list;char name[MANA_IRQ_NAME_SZ ]; };
Signature · 1 line
2.25.1
Quoted 12 lines · Wei Hu
Add EQ interrupt support for mana ib driver. Allocate EQs per ucontext to receive interrupt. Attach EQ when CQ is created. Call CQ interrupt handler when completion interrupt happens. EQs are destroyed when ucontext is deallocated.
The change calls some public APIs in mana ethernet driver to allocate EQs and other resources. Ehe EQ process routine is also shared by mana ethernet and mana ib drivers.
Co-developed-by Ajay Sharma <[email protected]>Signed-off-by Ajay Sharma <[email protected]>Signed-off-by Wei Hu <[email protected]>
...
drivers/infiniband/hw/mana/qp.c static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd, · line 427
Quoted 9 lines
drivers/infiniband/hw/mana/qp.c +5
-0@@ -368,6 +420,24 @@ static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd, qp->sq_id = wq_spec.queue_index; send_cq->id = cq_spec.queue_index; +if (gd->gdma_context->cq_table[send_cq->id] ==NULL ) { + + gdma_cq =kzalloc (sizeof (*gdma_cq),GFP_KERNEL ); +if (!gdma_cq) { +pr_err ("failed to allocate gdma_cq\n" );
Hi wei Hu,
I think 'err = -ENOMEM' is needed here.
Quoted 15 lines
drivers/infiniband/hw/mana/qp.c +13
-0+ goto err_destroy_wqobj_and_cq; + } + +pr_debug ("gdma cq allocated %p\n" , gdma_cq); + gdma_cq->cq.context = send_cq; + gdma_cq->type =GDMA_CQ ; + gdma_cq->cq.callback = mana_ib_cq_handler; + gdma_cq->id = send_cq->id; + gd->gdma_context->cq_table[send_cq->id] = gdma_cq; + }else { + gdma_cq = gd->gdma_context->cq_table[send_cq->id]; + } + ibdev_dbg(&mdev->ib_dev, "ret %d qp->tx_object 0x%llx sq id %llu cq id %llu\n", err,
Quoted 28 lines · Simon Horman
Quoted 12 lines · Wei Hu
Add EQ interrupt support for mana ib driver. Allocate EQs per ucontext to receive interrupt. Attach EQ when CQ is created. Call CQ interrupt handler when completion interrupt happens. EQs are destroyed when ucontext is deallocated.
The change calls some public APIs in mana ethernet driver to allocate EQs and other resources. Ehe EQ process routine is also shared by mana ethernet and mana ib drivers.
Co-developed-by Ajay Sharma <[email protected]>Signed-off-by Ajay Sharma <[email protected]>Signed-off-by Wei Hu <[email protected]>...
drivers/infiniband/hw/mana/qp.c static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd, · line 427
Quoted 9 lines
drivers/infiniband/hw/mana/qp.c +5
-0@@ -368,6 +420,24 @@ static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd, qp->sq_id = wq_spec.queue_index; send_cq->id = cq_spec.queue_index; +if (gd->gdma_context->cq_table[send_cq->id] ==NULL ) { + + gdma_cq =kzalloc (sizeof (*gdma_cq),GFP_KERNEL ); +if (!gdma_cq) { +pr_err ("failed to allocate gdma_cq\n" );Hi wei Hu,
Quoted 1 line
I think 'err =
-ENOMEM' is needed here.
And no prints like that in drivers.
Jason
Wei Hu
maintainerQuoted 47 lines
-----Original Message-----
From: Jason Gunthorpe <[email protected]>
Sent: Monday, June 5, 2023 9:35 PM
To: Simon Horman <[email protected]>
Cc: Wei Hu <[email protected]>; [email protected]; linux- [email protected]; [email protected]; Long Li <[email protected]>; Ajay Sharma <[email protected]>; [email protected]; KY Srinivasan <[email protected]>; Haiyang Zhang <[email protected]>; [email protected]; Dexuan Cui <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/1] RDMA/mana_ib: Add EQ interrupt support to mana ib driver.Quoted 10 lines · Simon Horman
Quoted 9 lines · Wei Hu
Add EQ interrupt support for mana ib driver. Allocate EQs per ucontext to receive interrupt. Attach EQ when CQ is created. Call CQ interrupt handler when completion interrupt happens. EQs are destroyed when ucontext is deallocated.
The change calls some public APIs in mana ethernet driver to allocate EQs and other resources. Ehe EQ process routine is also shared by mana ethernet and mana ib drivers.
Quoted 7 lines
Quoted 3 lines
Co-developed-by Ajay Sharma <[email protected]>Signed-off-by Ajay Sharma <[email protected]>Signed-off-by Wei Hu <[email protected]>...
Review static int mana_ib_create_qp_raw(struct ib_qp
Quoted 1 line
(quoted diff) +0
-0@@ -368,6 +420,24 @@ static int mana_ib_create_qp_raw(struct ib_qp*ibqp, struct
ib_pd*ibpd,Quoted 11 lines
drivers/infiniband/hw/mana/qp.c static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd, · line 427
Quoted 8 lines
drivers/infiniband/hw/mana/qp.c +5
-0qp->sq_id = wq_spec.queue_index; send_cq->id = cq_spec.queue_index; +if (gd->gdma_context->cq_table[send_cq->id] ==NULL ) { + + gdma_cq =kzalloc (sizeof (*gdma_cq),GFP_KERNEL ); +if (!gdma_cq) { +pr_err ("failed to allocate gdma_cq\n" );Hi wei Hu,
Quoted 4 lines
Quoted 1 line
I think 'err =
-ENOMEM' is needed here.And no prints like that in drivers.
Thanks for your review, Simon and Jason. You are right. I have overlooked these. I will fix it and send a v2 shortly.
Wei