From: Jason Gunthorpe <jgg@nvidia.com>
To: <linux-rdma@vger.kernel.org>, Bob Pearson <rpearsonhpe@gmail.com>
Cc: Gal Pressman <galpress@amazon.com>
Subject: [PATCH 4/9] efa: Move the context intialization out of efa_query_device_ex()
Date: Mon, 16 Nov 2020 16:23:05 -0400 [thread overview]
Message-ID: <4-v1-34e141ddf17e+89-query_device_ex_jgg@nvidia.com> (raw)
In-Reply-To: <0-v1-34e141ddf17e+89-query_device_ex_jgg@nvidia.com>
When the user calls efa_query_device_ex() it should not cause the context
values to be mutated, only the attribute shuld be returned.
Move this code to a dedicated function that is only called during context
setup.
Cc: Gal Pressman <galpress@amazon.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
providers/efa/efa.c | 14 +------------
providers/efa/verbs.c | 46 +++++++++++++++++++++++++++++++++++--------
providers/efa/verbs.h | 1 +
3 files changed, 40 insertions(+), 21 deletions(-)
diff --git a/providers/efa/efa.c b/providers/efa/efa.c
index 35f9b246a711ec..b24c14f7fa1fe1 100644
--- a/providers/efa/efa.c
+++ b/providers/efa/efa.c
@@ -54,10 +54,7 @@ static struct verbs_context *efa_alloc_context(struct ibv_device *vdev,
{
struct efa_alloc_ucontext_resp resp = {};
struct efa_alloc_ucontext cmd = {};
- struct ibv_device_attr_ex attr;
- unsigned int qp_table_sz;
struct efa_context *ctx;
- int err;
cmd.comp_mask |= EFA_ALLOC_UCONTEXT_CMD_COMP_TX_BATCH;
cmd.comp_mask |= EFA_ALLOC_UCONTEXT_CMD_COMP_MIN_SQ_WR;
@@ -86,17 +83,8 @@ static struct verbs_context *efa_alloc_context(struct ibv_device *vdev,
verbs_set_ops(&ctx->ibvctx, &efa_ctx_ops);
- err = efa_query_device_ex(&ctx->ibvctx.context, NULL, &attr,
- sizeof(attr));
- if (err)
+ if (!efa_query_device_ctx(ctx))
goto err_free_spinlock;
-
- qp_table_sz = roundup_pow_of_two(attr.orig_attr.max_qp);
- ctx->qp_table_sz_m1 = qp_table_sz - 1;
- ctx->qp_table = calloc(qp_table_sz, sizeof(*ctx->qp_table));
- if (!ctx->qp_table)
- goto err_free_spinlock;
-
return &ctx->ibvctx;
err_free_spinlock:
diff --git a/providers/efa/verbs.c b/providers/efa/verbs.c
index 1a9633155c62f8..52d6285f1f409c 100644
--- a/providers/efa/verbs.c
+++ b/providers/efa/verbs.c
@@ -106,14 +106,6 @@ int efa_query_device_ex(struct ibv_context *context,
if (err)
return err;
- ctx->device_caps = resp.device_caps;
- ctx->max_sq_wr = resp.max_sq_wr;
- ctx->max_rq_wr = resp.max_rq_wr;
- ctx->max_sq_sge = resp.max_sq_sge;
- ctx->max_rq_sge = resp.max_rq_sge;
- ctx->max_rdma_size = resp.max_rdma_size;
- ctx->max_wr_rdma_sge = a->max_sge_rd;
-
a->max_qp_wr = min_t(int, a->max_qp_wr,
ctx->max_llq_size / sizeof(struct efa_io_tx_wqe));
snprintf(a->fw_ver, sizeof(a->fw_ver), "%u.%u.%u.%u",
@@ -122,6 +114,44 @@ int efa_query_device_ex(struct ibv_context *context,
return 0;
}
+int efa_query_device_ctx(struct efa_context *ctx)
+{
+ struct ibv_device_attr_ex attr;
+ struct efa_query_device_ex_resp resp;
+ size_t resp_size = sizeof(resp);
+ unsigned int qp_table_sz;
+ int err;
+
+ if (ctx->cmds_supp_udata_mask & EFA_USER_CMDS_SUPP_UDATA_QUERY_DEVICE) {
+ err = ibv_cmd_query_device_any(&ctx->ibvctx.context, NULL,
+ &attr, sizeof(attr),
+ &resp.ibv_resp, &resp_size);
+ if (err)
+ return err;
+
+ ctx->device_caps = resp.device_caps;
+ ctx->max_sq_wr = resp.max_sq_wr;
+ ctx->max_rq_wr = resp.max_rq_wr;
+ ctx->max_sq_sge = resp.max_sq_sge;
+ ctx->max_rq_sge = resp.max_rq_sge;
+ ctx->max_rdma_size = resp.max_rdma_size;
+ ctx->max_wr_rdma_sge = attr.orig_attr.max_sge_rd;
+ } else {
+ err = ibv_cmd_query_device_any(&ctx->ibvctx.context, NULL,
+ &attr, sizeof(attr.orig_attr),
+ NULL, NULL);
+ if (err)
+ return err;
+ }
+
+ qp_table_sz = roundup_pow_of_two(attr.orig_attr.max_qp);
+ ctx->qp_table_sz_m1 = qp_table_sz - 1;
+ ctx->qp_table = calloc(qp_table_sz, sizeof(*ctx->qp_table));
+ if (!ctx->qp_table)
+ return ENOMEM;
+ return 0;
+}
+
int efadv_query_device(struct ibv_context *ibvctx,
struct efadv_device_attr *attr,
uint32_t inlen)
diff --git a/providers/efa/verbs.h b/providers/efa/verbs.h
index da022e615af064..3b0e4e0d498761 100644
--- a/providers/efa/verbs.h
+++ b/providers/efa/verbs.h
@@ -9,6 +9,7 @@
#include <infiniband/driver.h>
#include <infiniband/verbs.h>
+int efa_query_device_ctx(struct efa_context *ctx);
int efa_query_device(struct ibv_context *uctx, struct ibv_device_attr *attr);
int efa_query_port(struct ibv_context *uctx, uint8_t port,
struct ibv_port_attr *attr);
--
2.29.2
next prev parent reply other threads:[~2020-11-16 20:23 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-16 20:23 [PATCH 0/9] Simplify query_device() in libibverbs Jason Gunthorpe
2020-11-16 20:23 ` [PATCH 1/9] verbs: Simplify query_device_ex Jason Gunthorpe
2020-11-16 20:23 ` [PATCH 2/9] verbs: Add ibv_cmd_query_device_any() Jason Gunthorpe
2020-11-18 12:43 ` Gal Pressman
2020-11-18 12:45 ` Jason Gunthorpe
2020-11-16 20:23 ` [PATCH 3/9] mlx5: Move context initialization out of mlx5_query_device_ex() Jason Gunthorpe
2020-11-17 17:24 ` Yishai Hadas
2020-11-17 19:08 ` Jason Gunthorpe
2020-11-16 20:23 ` Jason Gunthorpe [this message]
2020-11-18 7:39 ` [PATCH 4/9] efa: Move the context intialization out of efa_query_device_ex() Gal Pressman
2020-11-18 8:07 ` Gal Pressman
2020-11-18 12:45 ` Gal Pressman
2020-11-18 20:59 ` Jason Gunthorpe
2020-11-16 20:23 ` [PATCH 5/9] mlx4: Move the context intialization out of mlx4_query_device_ex() Jason Gunthorpe
2020-11-16 20:23 ` [PATCH 6/9] providers: Remove normal query_device() from providers that have _ex Jason Gunthorpe
2020-11-18 12:47 ` Gal Pressman
2020-11-16 20:23 ` [PATCH 7/9] providers: Convert all providers to implement query_device_ex Jason Gunthorpe
2020-11-16 20:23 ` [PATCH 8/9] verbs: Remove dead code Jason Gunthorpe
2020-11-18 12:46 ` Gal Pressman
2020-11-18 12:53 ` Jason Gunthorpe
2020-11-16 20:23 ` [PATCH 9/9] verbs: Delete query_device() internal support Jason Gunthorpe
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=4-v1-34e141ddf17e+89-query_device_ex_jgg@nvidia.com \
--to=jgg@nvidia.com \
--cc=galpress@amazon.com \
--cc=linux-rdma@vger.kernel.org \
--cc=rpearsonhpe@gmail.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 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).