From: Anurup M <anurup.m-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
To: Salil Mehta <salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>,
<dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: <linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
<netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
<mehta.salil.lnk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
<linuxarm-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH for-next 01/11] IB/hns: Add the interface for querying QP1
Date: Mon, 7 Nov 2016 11:15:35 +0530 [thread overview]
Message-ID: <582014FF.3070600@huawei.com> (raw)
In-Reply-To: <20161104163633.141880-2-salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
On 11/4/2016 10:06 PM, Salil Mehta wrote:
> From: Lijun Ou <oulijun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
>
> In old code, It only added the interface for querying non-specific
> QP. This patch mainly adds an interface for querying QP1.
>
> Signed-off-by: Lijun Ou <oulijun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> Reviewed-by: Wei Hu (Xavier) <xavier.huwei-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Salil Mehta <salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> ---
> drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 87 +++++++++++++++++++++++++++-
> drivers/infiniband/hw/hns/hns_roce_hw_v1.h | 6 +-
> 2 files changed, 90 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
> index 71232e5..ca8b784 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
> @@ -2630,8 +2630,82 @@ static int hns_roce_v1_query_qpc(struct hns_roce_dev *hr_dev,
> return ret;
> }
>
> -int hns_roce_v1_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
> - int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr)
> +static int hns_roce_v1_q_sqp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
> + int qp_attr_mask,
> + struct ib_qp_init_attr *qp_init_attr)
> +{
> + struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
> + struct hns_roce_qp *hr_qp = to_hr_qp(ibqp);
> + struct hns_roce_sqp_context *context;
> + u32 addr;
> +
> + context = kzalloc(sizeof(*context), GFP_KERNEL);
> + if (!context)
> + return -ENOMEM;
> +
Do we really need dynamic alloc here as the size is fixed and this memory scope is
only inside this function. I think better to use a static allocation.
> + mutex_lock(&hr_qp->mutex);
> +
> + if (hr_qp->state == IB_QPS_RESET) {
I think alloc can be moved after this check (if dynamic alloc is really needed).
> + qp_attr->qp_state = IB_QPS_RESET;
> + goto done;
> + }
> +
> + addr = ROCEE_QP1C_CFG0_0_REG + hr_qp->port * sizeof(*context);
> + context->qp1c_bytes_4 = roce_read(hr_dev, addr);
> + context->sq_rq_bt_l = roce_read(hr_dev, addr + 1);
> + context->qp1c_bytes_12 = roce_read(hr_dev, addr + 2);
> + context->qp1c_bytes_16 = roce_read(hr_dev, addr + 3);
> + context->qp1c_bytes_20 = roce_read(hr_dev, addr + 4);
> + context->cur_rq_wqe_ba_l = roce_read(hr_dev, addr + 5);
> + context->qp1c_bytes_28 = roce_read(hr_dev, addr + 6);
> + context->qp1c_bytes_32 = roce_read(hr_dev, addr + 7);
> + context->cur_sq_wqe_ba_l = roce_read(hr_dev, addr + 8);
> + context->qp1c_bytes_40 = roce_read(hr_dev, addr + 9);
> +
> + hr_qp->state = roce_get_field(context->qp1c_bytes_4,
> + QP1C_BYTES_4_QP_STATE_M,
> + QP1C_BYTES_4_QP_STATE_S);
> + qp_attr->qp_state = hr_qp->state;
> + qp_attr->path_mtu = IB_MTU_256;
> + qp_attr->path_mig_state = IB_MIG_ARMED;
> + qp_attr->qkey = QKEY_VAL;
> + qp_attr->rq_psn = 0;
> + qp_attr->sq_psn = 0;
> + qp_attr->dest_qp_num = 1;
> + qp_attr->qp_access_flags = 6;
> +
> + qp_attr->pkey_index = roce_get_field(context->qp1c_bytes_20,
> + QP1C_BYTES_20_PKEY_IDX_M,
> + QP1C_BYTES_20_PKEY_IDX_S);
> + qp_attr->port_num = hr_qp->port + 1;
> + qp_attr->sq_draining = 0;
> + qp_attr->max_rd_atomic = 0;
> + qp_attr->max_dest_rd_atomic = 0;
> + qp_attr->min_rnr_timer = 0;
> + qp_attr->timeout = 0;
> + qp_attr->retry_cnt = 0;
> + qp_attr->rnr_retry = 0;
> + qp_attr->alt_timeout = 0;
> +
> +done:
> + qp_attr->cur_qp_state = qp_attr->qp_state;
> + qp_attr->cap.max_recv_wr = hr_qp->rq.wqe_cnt;
> + qp_attr->cap.max_recv_sge = hr_qp->rq.max_gs;
> + qp_attr->cap.max_send_wr = hr_qp->sq.wqe_cnt;
> + qp_attr->cap.max_send_sge = hr_qp->sq.max_gs;
> + qp_attr->cap.max_inline_data = 0;
> + qp_init_attr->cap = qp_attr->cap;
> + qp_init_attr->create_flags = 0;
> +
> + mutex_unlock(&hr_qp->mutex);
> + kfree(context);
> +
> + return 0;
> +}
> +
> +static int hns_roce_v1_q_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
> + int qp_attr_mask,
> + struct ib_qp_init_attr *qp_init_attr)
> {
> struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
> struct hns_roce_qp *hr_qp = to_hr_qp(ibqp);
> @@ -2767,6 +2841,15 @@ int hns_roce_v1_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
> return ret;
> }
>
> +int hns_roce_v1_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
> + int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr)
> +{
> + struct hns_roce_qp *hr_qp = to_hr_qp(ibqp);
> +
> + return hr_qp->doorbell_qpn <= 1 ?
> + hns_roce_v1_q_sqp(ibqp, qp_attr, qp_attr_mask, qp_init_attr) :
> + hns_roce_v1_q_qp(ibqp, qp_attr, qp_attr_mask, qp_init_attr);
> +}
> static void hns_roce_v1_destroy_qp_common(struct hns_roce_dev *hr_dev,
> struct hns_roce_qp *hr_qp,
> int is_user)
> diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.h b/drivers/infiniband/hw/hns/hns_roce_hw_v1.h
> index 539b0a3b..2e1878b 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.h
> +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.h
> @@ -480,13 +480,17 @@ struct hns_roce_sqp_context {
> u32 qp1c_bytes_12;
> u32 qp1c_bytes_16;
> u32 qp1c_bytes_20;
> - u32 qp1c_bytes_28;
> u32 cur_rq_wqe_ba_l;
> + u32 qp1c_bytes_28;
> u32 qp1c_bytes_32;
> u32 cur_sq_wqe_ba_l;
> u32 qp1c_bytes_40;
> };
>
> +#define QP1C_BYTES_4_QP_STATE_S 0
> +#define QP1C_BYTES_4_QP_STATE_M \
> + (((1UL << 3) - 1) << QP1C_BYTES_4_QP_STATE_S)
> +
> #define QP1C_BYTES_4_SQ_WQE_SHIFT_S 8
> #define QP1C_BYTES_4_SQ_WQE_SHIFT_M \
> (((1UL << 4) - 1) << QP1C_BYTES_4_SQ_WQE_SHIFT_S)
>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-11-07 5:45 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-04 16:36 [PATCH for-next 00/11] Code improvements & fixes for HNS RoCE driver Salil Mehta
2016-11-04 16:36 ` [PATCH for-next 01/11] IB/hns: Add the interface for querying QP1 Salil Mehta
[not found] ` <20161104163633.141880-2-salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-11-07 5:45 ` Anurup M [this message]
2016-11-07 11:45 ` Salil Mehta
2016-11-04 16:36 ` [PATCH for-next 02/11] IB/hns: Add code for refreshing CQ CI using TPTR Salil Mehta
2016-11-04 16:36 ` [PATCH for-next 03/11] IB/hns: Optimize the logic of allocating memory using APIs Salil Mehta
2016-11-09 7:21 ` Leon Romanovsky
2016-11-15 15:52 ` Salil Mehta
2016-11-16 8:36 ` Leon Romanovsky
2016-11-21 16:12 ` Salil Mehta
2016-11-21 17:14 ` Leon Romanovsky
[not found] ` <20161121171423.GA23083-2ukJVAZIZ/Y@public.gmane.org>
2016-11-21 20:20 ` Salil Mehta
2016-11-04 16:36 ` [PATCH for-next 04/11] IB/hns: add self loopback for CM Salil Mehta
2016-11-04 16:36 ` [PATCH for-next 05/11] IB/hns: Modify the condition of notifying hardware loopback Salil Mehta
2016-11-04 16:36 ` [PATCH for-next 06/11] IB/hns: Fix the bug for qp state in hns_roce_v1_m_qp() Salil Mehta
2016-11-04 16:36 ` [PATCH for-next 08/11] IB/hns: Modify query info named port_num when querying RC QP Salil Mehta
[not found] ` <20161104163633.141880-1-salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-11-04 16:36 ` [PATCH for-next 07/11] IB/hns: Modify the macro for the timeout when cmd process Salil Mehta
2016-11-04 16:36 ` [PATCH for-next 09/11] IB/hns: Change qpn allocation to round-robin mode Salil Mehta
2016-11-09 7:24 ` Leon Romanovsky
2016-11-04 16:36 ` [PATCH for-next 11/11] IB/hns: Fix for Checkpatch.pl comment style errors Salil Mehta
2016-11-04 16:36 ` [PATCH for-next 10/11] IB/hns: Implement the add_gid/del_gid and optimize the GIDs management Salil Mehta
2016-11-07 8:17 ` Anurup M
[not found] ` <58203884.6040808-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-11-07 10:04 ` Shaobo 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=582014FF.3070600@huawei.com \
--to=anurup.m-hv44wf8li93qt0dzr+alfa@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linuxarm-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=mehta.salil.lnk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).