From: Cheng Xu <chengyou@linux.alibaba.com>
To: Bernard Metzler <BMT@zurich.ibm.com>,
Cheng Xu <chengyou.xc@alibaba-inc.com>,
"jgg@ziepe.ca" <jgg@ziepe.ca>,
"dledford@redhat.com" <dledford@redhat.com>
Cc: "leon@kernel.org" <leon@kernel.org>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
"KaiShen@linux.alibaba.com" <KaiShen@linux.alibaba.com>,
"tonylu@linux.alibaba.com" <tonylu@linux.alibaba.com>
Subject: Re: [PATCH for-next v3 08/12] RDMA/erdma: Add verbs implementation
Date: Mon, 14 Mar 2022 09:58:46 +0800 [thread overview]
Message-ID: <e2cc05cb-0ea9-6c36-40dd-84ee846f9dad@linux.alibaba.com> (raw)
In-Reply-To: <BYAPR15MB26319BECD6F5455FAEDE9A6B990B9@BYAPR15MB2631.namprd15.prod.outlook.com>
On 3/10/22 11:21 PM, Bernard Metzler wrote:
>
<...>
>> +
>> +int erdma_query_port(struct ib_device *ibdev, u32 port,
>> + struct ib_port_attr *attr)
>> +{
>> + struct erdma_dev *dev = to_edev(ibdev);
>> + int ret = 0;
>
> not needed. just return 0.
>
Will fix it.
>> +
>> + memset(attr, 0, sizeof(*attr));
>> +
>> + attr->state = dev->state;
>> + if (dev->netdev) {
>> + ret = ib_get_eth_speed(ibdev, port, &attr->active_speed,
>> + &attr->active_width);
>> + attr->max_mtu = ib_mtu_int_to_enum(dev->netdev->mtu);
>> + attr->active_mtu = ib_mtu_int_to_enum(dev->netdev->mtu);
>> + }
>> +
>> + attr->gid_tbl_len = 1;
>> + attr->port_cap_flags = IB_PORT_CM_SUP | IB_PORT_DEVICE_MGMT_SUP;
>> + attr->max_msg_sz = -1;
>> + if (dev->state == IB_PORT_ACTIVE)
>> + attr->phys_state = IB_PORT_PHYS_STATE_LINK_UP;
>> + else
>> + attr->phys_state = IB_PORT_PHYS_STATE_DISABLED;
>> +
>> + return ret;
>> +}
>> +
>> +int erdma_get_port_immutable(struct ib_device *ibdev, u32 port,
>> + struct ib_port_immutable *port_immutable)
>> +{
>> + port_immutable->gid_tbl_len = 1;
>> + port_immutable->core_cap_flags = RDMA_CORE_PORT_IWARP;
>> +
>> + return 0;
>> +}
>> +
>> +int erdma_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
>> +{
>> + struct erdma_pd *pd = to_epd(ibpd);
>> + struct erdma_dev *dev = to_edev(ibpd->device);
>> + int pdn;
>> +
>> + pdn = erdma_alloc_idx(&dev->res_cb[ERDMA_RES_TYPE_PD]);
>> + if (pdn < 0)
>> + return pdn;
>> +
>> + pd->pdn = pdn;
>> +
>> + return 0;
>> +}
>> +
>> +int erdma_dealloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
>> +{
>> + struct erdma_pd *pd = to_epd(ibpd);
>> + struct erdma_dev *dev = to_edev(ibpd->device);
>> +
>> + erdma_free_idx(&dev->res_cb[ERDMA_RES_TYPE_PD], pd->pdn);
>> +
>> + return 0;
>> +}
>> +
>> +static int erdma_qp_validate_cap(struct erdma_dev *dev,
>> + struct ib_qp_init_attr *attrs)
>> +{
>> + if ((attrs->cap.max_send_wr > dev->attrs.max_send_wr) ||
>> + (attrs->cap.max_recv_wr > dev->attrs.max_recv_wr) ||
>> + (attrs->cap.max_send_sge > dev->attrs.max_send_sge) ||
>> + (attrs->cap.max_recv_sge > dev->attrs.max_recv_sge) ||
>> + (attrs->cap.max_inline_data > ERDMA_MAX_INLINE) ||
>> + !attrs->cap.max_send_wr || !attrs->cap.max_recv_wr) {
>> + return -EINVAL;
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +static int erdma_qp_validate_attr(struct erdma_dev *dev,
>> + struct ib_qp_init_attr *attrs)
>> +{
>> + if (attrs->qp_type != IB_QPT_RC)
>> + return -EOPNOTSUPP;
>> +
>> + if (attrs->srq)
>> + return -EOPNOTSUPP;
>> +
>> + if (!attrs->send_cq || !attrs->recv_cq)
>> + return -EOPNOTSUPP;
>> +
>> + return 0;
>> +}
>> +
>> +static void free_kernel_qp(struct erdma_qp *qp)
>> +{
>> + struct erdma_dev *dev = qp->dev;
>> +
>> + vfree(qp->kern_qp.swr_tbl);
>> + vfree(qp->kern_qp.rwr_tbl);
>> +
>> + if (qp->kern_qp.sq_buf)
>> + dma_free_coherent(
>> + &dev->pdev->dev,
>> + WARPPED_BUFSIZE(qp->attrs.sq_size << SQEBB_SHIFT),
>> + qp->kern_qp.sq_buf, qp->kern_qp.sq_buf_dma_addr);
>> +
>> + if (qp->kern_qp.rq_buf)
>> + dma_free_coherent(
>> + &dev->pdev->dev,
>> + WARPPED_BUFSIZE(qp->attrs.rq_size << RQE_SHIFT),
>> + qp->kern_qp.rq_buf, qp->kern_qp.rq_buf_dma_addr);
>> +}
>> +
>> +static int init_kernel_qp(struct erdma_dev *dev, struct erdma_qp *qp,
>> + struct ib_qp_init_attr *attrs)
>> +{
>> + struct erdma_kqp *kqp = &qp->kern_qp;
>> + int ret = -ENOMEM;
>
> not needed. jut return -ENOMEM at the one possible
> place.
>
Sure, will fix it.
Thanks,
Cheng Xu
>> + int size;
>> +
>> + if (attrs->sq_sig_type == IB_SIGNAL_ALL_WR)
>> + kqp->sig_all = 1;
>> +
>> + kqp->sq_pi = 0;
>> + kqp->sq_ci = 0;
>> + kqp->rq_pi = 0;
>> + kqp->rq_ci = 0;
>> + kqp->hw_sq_db =
>> + dev->func_bar + (ERDMA_SDB_SHARED_PAGE_INDEX << PAGE_SHIFT);
>> + kqp->hw_rq_db = dev->func_bar + ERDMA_BAR_RQDB_SPACE_OFFSET;
>> +
>> + kqp->swr_tbl = vmalloc(qp->attrs.sq_size * sizeof(u64));
>> + kqp->rwr_tbl = vmalloc(qp->attrs.rq_size * sizeof(u64));
>> +
>> + size = (qp->attrs.sq_size << SQEBB_SHIFT) + ERDMA_EXTRA_BUFFER_SIZE;
>> + kqp->sq_buf = dma_alloc_coherent(&dev->pdev->dev, size,
>> + &kqp->sq_buf_dma_addr, GFP_KERNEL);
>> + if (!kqp->sq_buf)
>> + goto err_out;
>> +
>> + size = (qp->attrs.rq_size << RQE_SHIFT) + ERDMA_EXTRA_BUFFER_SIZE;
>> + kqp->rq_buf = dma_alloc_coherent(&dev->pdev->dev, size,
>> + &kqp->rq_buf_dma_addr, GFP_KERNEL);
>> + if (!kqp->rq_buf)
>> + goto err_out;
>> +
>> + kqp->sq_db_info = kqp->sq_buf + (qp->attrs.sq_size << SQEBB_SHIFT);
>> + kqp->rq_db_info = kqp->rq_buf + (qp->attrs.rq_size << RQE_SHIFT);
>> +
>> + return 0;
>> +
>> +err_out:
>> + free_kernel_qp(qp);
>> + return ret;
>> +}
>> +
<...>
next prev parent reply other threads:[~2022-03-14 1:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-10 15:21 RE:[PATCH for-next v3 08/12] RDMA/erdma: Add verbs implementation Bernard Metzler
2022-03-14 1:58 ` Cheng Xu [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-02-17 3:01 [PATCH for-next v3 00/12] Elastic RDMA Adapter (ERDMA) driver Cheng Xu
2022-02-17 3:01 ` [PATCH for-next v3 08/12] RDMA/erdma: Add verbs implementation Cheng Xu
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=e2cc05cb-0ea9-6c36-40dd-84ee846f9dad@linux.alibaba.com \
--to=chengyou@linux.alibaba.com \
--cc=BMT@zurich.ibm.com \
--cc=KaiShen@linux.alibaba.com \
--cc=chengyou.xc@alibaba-inc.com \
--cc=dledford@redhat.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--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.