All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cheng Xu <chengyou@linux.alibaba.com>
To: Wenpeng Liang <liangwenpeng@huawei.com>,
	jgg@ziepe.ca, dledford@redhat.com
Cc: leon@kernel.org, linux-rdma@vger.kernel.org,
	KaiShen@linux.alibaba.com, tonylu@linux.alibaba.com,
	BMT@zurich.ibm.com
Subject: Re: [PATCH for-next v4 06/12] RDMA/erdma: Add event queue implementation
Date: Sat, 19 Mar 2022 16:54:18 +0800	[thread overview]
Message-ID: <62e047db-41e6-4f36-4747-1fcbb593a09a@linux.alibaba.com> (raw)
In-Reply-To: <57cd0171-5964-228f-b004-06cec1e4daae@huawei.com>



On 3/18/22 7:43 PM, Wenpeng Liang wrote:
> On 2022/3/14 14:47, Cheng Xu wrote:
>> Event queue (EQ) is the main notifcaition way from erdma hardware to its
>> driver. Each erdma device contains 2 kinds EQs: asynchronous EQ (AEQ) and
>> completion EQ (CEQ). Per device has 1 AEQ, which used for RDMA async event
>> report, and max to 32 CEQs (numbered for CEQ0 to CEQ31). CEQ0 is used for
>> cmdq completion event report, and the rest CEQs are used for RDMA
>> completion event report.
>>
> 
> notifcaition -> notification.
> 

Sorry for these typos, will fix them.

> <...>
>> +static void *get_eq_entry(struct erdma_eq *eq, u16 idx)
>> +{
>> +	idx &= (eq->depth - 1);
>> +
>> +	return eq->qbuf + (idx << EQE_SHIFT);
>> +}
>> +
>> +void *get_next_valid_eqe(struct erdma_eq *eq)
>> +{
>> +	u64 *eqe = (u64 *)get_eq_entry(eq, eq->ci);
> 
> The pointer type returned by get_eq_entry is "void *",
> which does not need to be cast.
> 

OK, will fix.

> <...>
>> +void erdma_aeq_event_handler(struct erdma_dev *dev)
>> +{
>> +	struct erdma_aeqe *aeqe;
>> +	u32 cqn, qpn;
>> +	struct erdma_qp *qp;
>> +	struct erdma_cq *cq;
>> +	struct ib_event event;
>> +	u32 poll_cnt = 0;
>> +
>> +	memset(&event, 0, sizeof(event));
>> +
>> +	while (poll_cnt < MAX_POLL_CHUNK_SIZE) {
>> +		aeqe = (struct erdma_aeqe *)get_next_valid_eqe(&dev->aeq);
> 
> Ditto.
> 
>> +		if (!aeqe)
>> +			break;
>> +
>> +		poll_cnt++;
>> +
>> +		if (FIELD_GET(ERDMA_AEQE_HDR_TYPE_MASK, aeqe->hdr) ==
>> +		    ERDMA_AE_TYPE_CQ_ERR) {
>> +			cqn = aeqe->event_data0;
>> +			cq = find_cq_by_cqn(dev, cqn);
>> +			if (!cq)
>> +				continue;
> 
> As with the else branch, also having a blank line makes the code clearer.
> 

Will fix.

>> +			event.device = cq->ibcq.device;
>> +			event.element.cq = &cq->ibcq;
>> +			event.event = IB_EVENT_CQ_ERR;
>> +			if (cq->ibcq.event_handler)
>> +				cq->ibcq.event_handler(&event,
>> +						       cq->ibcq.cq_context);
>> +		} else {
>> +			qpn = aeqe->event_data0;
>> +			qp = find_qp_by_qpn(dev, qpn);
>> +			if (!qp)
>> +				continue;
>> +
>> +			event.device = qp->ibqp.device;
>> +			event.element.qp = &qp->ibqp;
> <...>
>> +void erdma_ceq_completion_handler(struct erdma_eq_cb *ceq_cb)
>> +{
>> +	int cqn;
>> +	struct erdma_cq *cq;
>> +	struct erdma_dev *dev = ceq_cb->dev;
>> +	u32 poll_cnt = 0;
>> +	u64 *hdr;
>> +
>> +	if (!ceq_cb->ready)
>> +		return;
>> +
>> +	while (poll_cnt < MAX_POLL_CHUNK_SIZE) {
>> +		hdr = (u64 *)get_next_valid_eqe(&ceq_cb->eq);
> 
> The pointer type returned by get_next_valid_eqe is "void *",
> which does not need to be cast.
> 

Will fix.

> <...>
>> +static int erdma_set_ceq_irq(struct erdma_dev *dev, u16 ceqn)
>> +{
>> +	struct erdma_eq_cb *eqc = &dev->ceqs[ceqn];
>> +	cpumask_t affinity_hint_mask;
>> +	u32 cpu;
>> +	int err;
>> +
>> +	snprintf(eqc->irq_name, ERDMA_IRQNAME_SIZE, "erdma-ceq%u@pci:%s",
>> +		ceqn, pci_name(dev->pdev));
> 
> Parameters in parentheses are not vertically aligned, a space is missing before "ceqn".
> 

Will fix.

> <...>
>> +static int create_eq_cmd(struct erdma_dev *dev, u32 eqn, struct erdma_eq *eq)
>> +{
>> +	struct erdma_cmdq_create_eq_req req;
>> +	dma_addr_t db_info_dma_addr;
>> +
>> +	erdma_cmdq_build_reqhdr(&req.hdr, CMDQ_SUBMOD_COMMON,
>> +				CMDQ_OPCODE_CREATE_EQ);
>> +	req.eqn = eqn;
>> +	req.depth = ilog2(eq->depth);
>> +	req.qbuf_addr = eq->qbuf_dma_addr;
>> +	req.qtype = 1; /* CEQ */
> 
> Use a macro to represent "1", so this comment is not needed.

Will fix.

> 
> <...>
>> +static int erdma_ceq_init_one(struct erdma_dev *dev, u16 ceqn)
>> +{
>> +	struct erdma_eq *eq = &dev->ceqs[ceqn].eq;
>> +	u32 buf_size = ERDMA_DEFAULT_EQ_DEPTH << EQE_SHIFT;
>> +	int ret;
>> +
>> +	eq->qbuf = dma_alloc_coherent(&dev->pdev->dev,
>> +				      WARPPED_BUFSIZE(buf_size),
>> +				      &eq->qbuf_dma_addr,
>> +				      GFP_KERNEL | __GFP_ZERO);
>> +	if (!eq->qbuf)
>> +		return -ENOMEM;
>> +
>> +	spin_lock_init(&eq->lock);
>> +	atomic64_set(&eq->event_num, 0);
>> +	atomic64_set(&eq->notify_num, 0);
>> +
>> +	eq->depth = ERDMA_DEFAULT_EQ_DEPTH;
>> +	eq->db_addr = (u64 __iomem *)(dev->func_bar +
>> +				      ERDMA_REGS_CEQ_DB_BASE_REG +
>> +				      (ceqn + 1) * 8);
> 
> Does this "8" represent the byte width of a "u64 __iomem*" type?
> 

Yes, each EQ's doorbell takes 8 Bytes, I will use a micro instead of
this magic number.

> <...>
>> +int erdma_ceqs_init(struct erdma_dev *dev)
>> +{
>> +	u32 i, j;
>> +	int err = 0;
> 
> The "err" does not need to be initialized to 0, it has been reassigned
> before the function returns.
> 

OK, will fix.

Thanks,
Cheng Xu

> Thanks,
> Wenpeng
>> +
>> +	for (i = 0; i < dev->attrs.irq_num - 1; i++) {
>> +		err = erdma_ceq_init_one(dev, i);
>> +		if (err)
>> +			goto out_err;
>> +
>> +		err = erdma_set_ceq_irq(dev, i);
>> +		if (err) {
>> +			erdma_ceq_uninit_one(dev, i);
>> +			goto out_err;
>> +		}
>> +	}
>> +
>> +	return 0;
>> +
>> +out_err:
>> +	for (j = 0; j < i; j++) {
>> +		erdma_free_ceq_irq(dev, j);
>> +		erdma_ceq_uninit_one(dev, j);
>> +	}
>> +
>> +	return err;
>> +}
>> +

  parent reply	other threads:[~2022-03-19  8:54 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14  6:47 [PATCH for-next v4 00/12] Elastic RDMA Adapter (ERDMA) driver Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 01/12] RDMA: Add ERDMA to rdma_driver_id definition Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 02/12] RDMA/core: Allow calling query_port when netdev isn't attached in iWarp Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 03/12] RDMA/erdma: Add the hardware related definitions Cheng Xu
2022-03-18 10:27   ` Wenpeng Liang
2022-03-19  7:53     ` Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 04/12] RDMA/erdma: Add main include file Cheng Xu
2022-03-18 10:35   ` Wenpeng Liang
2022-03-19  8:11     ` Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 05/12] RDMA/erdma: Add cmdq implementation Cheng Xu
2022-03-18 11:13   ` Wenpeng Liang
2022-03-19  8:38     ` Cheng Xu
2022-03-18 11:16   ` Wenpeng Liang
2022-03-18 18:17     ` Jason Gunthorpe
2022-03-19  1:26       ` Wenpeng Liang
2022-03-18 12:57   ` Wenpeng Liang
2022-03-19  9:18     ` Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 06/12] RDMA/erdma: Add event queue implementation Cheng Xu
2022-03-18 11:43   ` Wenpeng Liang
2022-03-18 18:18     ` Jason Gunthorpe
2022-03-19  9:43       ` Cheng Xu
2022-03-21 22:23         ` Jason Gunthorpe
2022-03-22  3:06           ` Cheng Xu
2022-03-19  8:54     ` Cheng Xu [this message]
2022-03-14  6:47 ` [PATCH for-next v4 07/12] RDMA/erdma: Add verbs header file Cheng Xu
2022-03-18 11:46   ` Wenpeng Liang
2022-03-19  8:55     ` Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 08/12] RDMA/erdma: Add verbs implementation Cheng Xu
2022-03-18 12:24   ` Wenpeng Liang
2022-03-19  9:06     ` Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 09/12] RDMA/erdma: Add connection management (CM) support Cheng Xu
2022-03-18 12:38   ` Wenpeng Liang
2022-03-19  9:10     ` Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 10/12] RDMA/erdma: Add the erdma module Cheng Xu
2022-03-18 12:46   ` Wenpeng Liang
2022-03-19  9:13     ` Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 11/12] RDMA/erdma: Add the ABI definitions Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 12/12] RDMA/erdma: Add driver to kernel build environment Cheng Xu
2022-03-17  3:14   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=62e047db-41e6-4f36-4747-1fcbb593a09a@linux.alibaba.com \
    --to=chengyou@linux.alibaba.com \
    --cc=BMT@zurich.ibm.com \
    --cc=KaiShen@linux.alibaba.com \
    --cc=dledford@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=liangwenpeng@huawei.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=tonylu@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.