[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <PH7PR21MB3263014FF20892B142886FD2CE06A@PH7PR21MB3263.namprd21.prod.outlook.com>
Date: Fri, 28 Jul 2023 22:52:48 +0000
From: Long Li <longli@...rosoft.com>
To: "sharmaajay@...uxonhyperv.com" <sharmaajay@...uxonhyperv.com>,
Jason Gunthorpe <jgg@...pe.ca>,
Leon Romanovsky <leon@...nel.org>,
Dexuan Cui <decui@...rosoft.com>, Wei Liu <wei.liu@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
CC: "linux-rdma@...r.kernel.org" <linux-rdma@...r.kernel.org>,
"linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Ajay Sharma <sharmaajay@...rosoft.com>
Subject: RE: [Patch v3 4/4] RDMA/mana_ib : Query adapter capabilities
> Subject: [Patch v3 4/4] RDMA/mana_ib : Query adapter capabilities
>
> From: Ajay Sharma <sharmaajay@...rosoft.com>
>
> Query the adapter capabilities to expose to other clients and VF. This checks
> against the user supplied values and protects against overflows.
>
> Signed-off-by: Ajay Sharma <sharmaajay@...rosoft.com>
> ---
> drivers/infiniband/hw/mana/device.c | 4 ++
> drivers/infiniband/hw/mana/main.c | 66 +++++++++++++++++++++++++-
> --
> drivers/infiniband/hw/mana/mana_ib.h | 53 +++++++++++++++++++++-
> 3 files changed, 115 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mana/device.c
> b/drivers/infiniband/hw/mana/device.c
> index 4077e440657a..e15da43c73a0 100644
> --- a/drivers/infiniband/hw/mana/device.c
> +++ b/drivers/infiniband/hw/mana/device.c
> @@ -97,6 +97,10 @@ static int mana_ib_probe(struct auxiliary_device *adev,
> goto free_error_eq;
> }
>
> + ret = mana_ib_query_adapter_caps(mib_dev);
> + if (ret)
> + ibdev_dbg(&mib_dev->ib_dev, "Failed to get caps, use
> defaults");
There is an ibdev_err() in mana_ib_query_adapter_caps(), how about merging this message with that?
And you can remove the return value of mana_ib_query_adapter_caps(), since it doesn't do something meaningful.
> +
> ret = ib_register_device(&mib_dev->ib_dev, "mana_%d",
> mdev->gdma_context->dev);
> if (ret)
> diff --git a/drivers/infiniband/hw/mana/main.c
> b/drivers/infiniband/hw/mana/main.c
> index 1b1a8670d0fa..512815e1e64d 100644
> --- a/drivers/infiniband/hw/mana/main.c
> +++ b/drivers/infiniband/hw/mana/main.c
> @@ -469,21 +469,27 @@ int mana_ib_get_port_immutable(struct ib_device
> *ibdev, u32 port_num, int mana_ib_query_device(struct ib_device *ibdev,
> struct ib_device_attr *props,
> struct ib_udata *uhw)
> {
> + struct mana_ib_dev *mib_dev = container_of(ibdev,
> + struct mana_ib_dev, ib_dev);
> +
> props->max_qp = MANA_MAX_NUM_QUEUES;
> props->max_qp_wr = MAX_SEND_BUFFERS_PER_QUEUE;
> -
> - /*
> - * max_cqe could be potentially much bigger.
> - * As this version of driver only support RAW QP, set it to the same
> - * value as max_qp_wr
> - */
> props->max_cqe = MAX_SEND_BUFFERS_PER_QUEUE;
> -
> props->max_mr_size = MANA_IB_MAX_MR_SIZE;
> props->max_mr = MANA_IB_MAX_MR;
> props->max_send_sge = MAX_TX_WQE_SGL_ENTRIES;
> props->max_recv_sge = MAX_RX_WQE_SGL_ENTRIES;
>
> + /* If the Management SW is updated and supports adapter creation */
> + if (mib_dev->adapter_handle) {
Does this mean mana_ib_query_adapter_caps() was a success?
> + props->max_qp = mib_dev->adapter_caps.max_qp_count;
> + props->max_qp_wr = mib_dev-
> >adapter_caps.max_requester_sq_size;
> + props->max_cqe = mib_dev-
> >adapter_caps.max_requester_sq_size;
> + props->max_mr = mib_dev->adapter_caps.max_mr_count;
> + props->max_send_sge = mib_dev-
> >adapter_caps.max_send_wqe_size;
> + props->max_recv_sge = mib_dev-
> >adapter_caps.max_recv_wqe_size;
> + }
> +
> return 0;
> }
>
> @@ -599,3 +605,49 @@ int mana_ib_create_error_eq(struct mana_ib_dev
> *mib_dev)
>
> return 0;
> }
> +
> +static void assign_caps(struct mana_ib_adapter_caps *caps,
> + struct mana_ib_query_adapter_caps_resp *resp) {
> + caps->max_sq_id = resp->max_sq_id;
> + caps->max_rq_id = resp->max_rq_id;
> + caps->max_cq_id = resp->max_cq_id;
> + caps->max_qp_count = resp->max_qp_count;
> + caps->max_cq_count = resp->max_cq_count;
> + caps->max_mr_count = resp->max_mr_count;
> + caps->max_pd_count = resp->max_pd_count;
> + caps->max_inbound_read_limit = resp->max_inbound_read_limit;
> + caps->max_outbound_read_limit = resp->max_outbound_read_limit;
> + caps->mw_count = resp->mw_count;
> + caps->max_srq_count = resp->max_srq_count;
> + caps->max_requester_sq_size = resp->max_requester_sq_size;
> + caps->max_responder_sq_size = resp->max_responder_sq_size;
> + caps->max_requester_rq_size = resp->max_requester_rq_size;
> + caps->max_responder_rq_size = resp->max_responder_rq_size;
> + caps->max_send_wqe_size = resp->max_send_wqe_size;
> + caps->max_recv_wqe_size = resp->max_recv_wqe_size;
> + caps->max_inline_data_size = resp->max_inline_data_size; }
> +
> +int mana_ib_query_adapter_caps(struct mana_ib_dev *mib_dev) {
> + struct mana_ib_query_adapter_caps_resp resp = {};
> + struct mana_ib_query_adapter_caps_req req = {};
> + int err;
> +
> + mana_gd_init_req_hdr(&req.hdr, MANA_IB_GET_ADAPTER_CAP,
> sizeof(req),
> + sizeof(resp));
> + req.hdr.resp.msg_version =
> MANA_IB__GET_ADAPTER_CAP_RESPONSE_V3;
> + req.hdr.dev_id = mib_dev->gc->mana_ib.dev_id;
> +
> + err = mana_gd_send_request(mib_dev->gc, sizeof(req), &req,
> + sizeof(resp), &resp);
> +
> + if (err) {
> + ibdev_err(&mib_dev->ib_dev, "Failed to query adapter caps
> err %d", err);
> + return err;
> + }
> +
> + assign_caps(&mib_dev->adapter_caps, &resp);
> + return 0;
> +}
> diff --git a/drivers/infiniband/hw/mana/mana_ib.h
> b/drivers/infiniband/hw/mana/mana_ib.h
> index 8a652bccd978..1044358230d3 100644
> --- a/drivers/infiniband/hw/mana/mana_ib.h
> +++ b/drivers/infiniband/hw/mana/mana_ib.h
> @@ -20,19 +20,41 @@
>
> /* MANA doesn't have any limit for MR size */
> #define MANA_IB_MAX_MR_SIZE U64_MAX
> -
> +#define MANA_IB__GET_ADAPTER_CAP_RESPONSE_V3 3
This value is used in GDMA header of the request message? If so, define GDMA_MESSAGE_V3 in "include/net/mana/gdma.h".
Powered by blists - more mailing lists