From: Leon Romanovsky <leon@kernel.org>
To: Doug Ledford <dledford@redhat.com>, Jason Gunthorpe <jgg@mellanox.com>
Cc: Leon Romanovsky <leonro@mellanox.com>, linux-rdma@vger.kernel.org
Subject: [RFC PATCH rdma-core 10/11] librdmacm: Implement ECE handshake logic
Date: Thu, 5 Mar 2020 17:03:55 +0200 [thread overview]
Message-ID: <20200305150356.208843-11-leon@kernel.org> (raw)
In-Reply-To: <20200305150356.208843-1-leon@kernel.org>
From: Leon Romanovsky <leonro@mellanox.com>
Perform ECE handshake through REQ/REP messages. The REQ message
initiated by active side towards passive side and carries the
ECE data. The passive side returns its decision in REP message.
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
librdmacm/cma.c | 46 ++++++++++++++++++++++++++++++++++------
librdmacm/rdma_cma_abi.h | 1 +
2 files changed, 40 insertions(+), 7 deletions(-)
diff --git a/librdmacm/cma.c b/librdmacm/cma.c
index ba8a9a57..af3c7041 100644
--- a/librdmacm/cma.c
+++ b/librdmacm/cma.c
@@ -1398,10 +1398,20 @@ static int init_ece(struct rdma_cm_id *id, struct ibv_qp *qp)
id_priv->local_ece.vendor_id = ece.vendor_id;
id_priv->local_ece.options = ece.options;
+ if (!id_priv->remote_ece.vendor_id)
+ return 0;
+
+ /* This QP was created due to REQ event */
+ ece.vendor_id = id_priv->remote_ece.vendor_id;
+ ece.options = id_priv->remote_ece.options;
+ ret = ibv_set_ece(qp, &ece);
+ if (ret)
+ return (errno == ECONNREFUSED) ? errno : 0;
+
+ id_priv->local_ece.options = ece.options;
return 0;
}
-
int rdma_create_qp_ex(struct rdma_cm_id *id,
struct ibv_qp_init_attr_ex *attr)
{
@@ -2074,8 +2084,8 @@ static int ucma_query_req_info(struct rdma_cm_id *id)
return 0;
}
-static int ucma_process_conn_req(struct cma_event *evt,
- uint32_t handle)
+static int ucma_process_conn_req(struct cma_event *evt, uint32_t handle,
+ struct ucma_abi_ece *ece)
{
struct cma_id_private *id_priv;
int ret;
@@ -2095,6 +2105,8 @@ static int ucma_process_conn_req(struct cma_event *evt,
ucma_insert_id(id_priv);
id_priv->initiator_depth = evt->event.param.conn.initiator_depth;
id_priv->responder_resources = evt->event.param.conn.responder_resources;
+ id_priv->remote_ece.vendor_id = ece->vendor_id;
+ id_priv->remote_ece.options = ece->attr_mod;
if (evt->id_priv->sync) {
ret = rdma_migrate_id(&id_priv->id, NULL);
@@ -2143,6 +2155,26 @@ err:
return ret;
}
+static int ucma_process_conn_resp_ece(struct cma_id_private *id_priv,
+ struct ucma_abi_ece *ece)
+{
+ struct ibv_ece ibv_ece = { .vendor_id = ece->vendor_id,
+ .options = ece->attr_mod };
+ int ret;
+
+ ret = ibv_set_ece(id_priv->id.qp, &ibv_ece);
+ if (ret && errno == EOPNOTSUPP)
+ goto out;
+
+ if (ret && errno == ECONNREFUSED)
+ /* libibverbs provider asked to reject connection */
+ return -1;
+
+ id_priv->local_ece.options = ibv_ece.options;
+out:
+ return ucma_process_conn_resp(id_priv);
+}
+
static int ucma_process_join(struct cma_event *evt)
{
evt->mc->mgid = evt->event.param.ud.ah_attr.grh.dgid;
@@ -2279,7 +2311,7 @@ retry:
else
ucma_copy_conn_event(evt, &resp.param.conn);
- ret = ucma_process_conn_req(evt, resp.id);
+ ret = ucma_process_conn_req(evt, resp.id, &resp.ece);
if (ret)
goto retry;
break;
@@ -2288,8 +2320,8 @@ retry:
if (!evt->id_priv->id.qp) {
evt->event.event = RDMA_CM_EVENT_CONNECT_RESPONSE;
} else {
- evt->event.status =
- ucma_process_conn_resp(evt->id_priv);
+ evt->event.status = ucma_process_conn_resp_ece(
+ evt->id_priv, &resp.ece);
if (!evt->event.status)
evt->event.event = RDMA_CM_EVENT_ESTABLISHED;
else {
@@ -2639,7 +2671,7 @@ int rdma_get_remote_ece(struct rdma_cm_id *id, struct ibv_ece *ece)
{
struct cma_id_private *id_priv;
- if (id->qp || !ece)
+ if (!id || id->qp || !ece)
return ERR(EINVAL);
id_priv = container_of(id, struct cma_id_private, id);
diff --git a/librdmacm/rdma_cma_abi.h b/librdmacm/rdma_cma_abi.h
index 911863cc..f24417dd 100644
--- a/librdmacm/rdma_cma_abi.h
+++ b/librdmacm/rdma_cma_abi.h
@@ -334,6 +334,7 @@ struct ucma_abi_event_resp {
struct ucma_abi_conn_param conn;
struct ucma_abi_ud_param ud;
} param;
+ struct ucma_abi_ece ece;
};
struct ucma_abi_set_option {
--
2.24.1
next prev parent reply other threads:[~2020-03-05 15:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-05 15:03 [RFC PATCH rdma-core 00/11] Add Enhanced Connection Established (ECE) APIs Leon Romanovsky
2020-03-05 15:03 ` [RFC PATCH rdma-core 01/11] Update kernel headers Leon Romanovsky
2020-03-05 15:03 ` [RFC PATCH rdma-core 02/11] libibverbs: Add interfaces to configure and use ECE Leon Romanovsky
2020-03-05 15:03 ` [RFC PATCH rdma-core 03/11] mlx5: Implement ECE callbacks Leon Romanovsky
2020-03-05 15:03 ` [RFC PATCH rdma-core 04/11] libibverbs: Document ECE API Leon Romanovsky
2020-03-05 15:03 ` [RFC PATCH rdma-core 05/11] debian: Install all available librdmacm man pages Leon Romanovsky
2020-03-05 15:03 ` [RFC PATCH rdma-core 06/11] librdmacm: Provide interface to use ECE for external QPs Leon Romanovsky
2020-03-05 15:03 ` [RFC PATCH rdma-core 07/11] librdmacm: Connect rdma_connect to the ECE Leon Romanovsky
2020-03-05 15:03 ` [RFC PATCH rdma-core 08/11] librdmacm: Return ECE results through rdma_accept Leon Romanovsky
2020-03-05 15:03 ` [RFC PATCH rdma-core 09/11] librdmacm: Add an option to reject ECE request Leon Romanovsky
2020-03-05 15:03 ` Leon Romanovsky [this message]
2020-03-05 15:03 ` [RFC PATCH rdma-core 11/11] librdmacm: Document ECE API Leon Romanovsky
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=20200305150356.208843-11-leon@kernel.org \
--to=leon@kernel.org \
--cc=dledford@redhat.com \
--cc=jgg@mellanox.com \
--cc=leonro@mellanox.com \
--cc=linux-rdma@vger.kernel.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).