From: Leon Romanovsky <leon@kernel.org>
To: Doug Ledford <dledford@redhat.com>, Jason Gunthorpe <jgg@mellanox.com>
Cc: Ido Kalir <idok@mellanox.com>,
Leon Romanovsky <leonro@mellanox.com>,
linux-rdma@vger.kernel.org
Subject: [PATCH rdma-core 11/12] pyverbs: Add support for ECE
Date: Mon, 20 Apr 2020 17:06:47 +0300 [thread overview]
Message-ID: <20200420140648.275554-12-leon@kernel.org> (raw)
In-Reply-To: <20200420140648.275554-1-leon@kernel.org>
From: Ido Kalir <idok@mellanox.com>
ECE (enhanced connection establishment) is a mechanism that gives an
option to different libibverbs providers to advertise and use various
provider-specific QP configuration options.
Add those verbs:
ibv_query_ece - get QPs ece.
ibv_set_ece - set the QPs ece.
rdma_set_local_ece - set the local CMs ece.
rdma_get_remote_ece - get the remote CM ece from the connection request.
Signed-off-by: Maxim Chicherin <maximc@mellanox.com>
Signed-off-by: Ido Kalir <idok@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
pyverbs/cmid.pyx | 23 ++++++++++++++++++++-
pyverbs/libibverbs.pxd | 7 +++++++
pyverbs/librdmacm.pxd | 2 ++
pyverbs/qp.pxd | 3 +++
pyverbs/qp.pyx | 45 ++++++++++++++++++++++++++++++++++++++++--
5 files changed, 77 insertions(+), 3 deletions(-)
diff --git a/pyverbs/cmid.pyx b/pyverbs/cmid.pyx
index 66d73268..2505ec70 100755
--- a/pyverbs/cmid.pyx
+++ b/pyverbs/cmid.pyx
@@ -1,7 +1,7 @@
from libc.string cimport memset
from pyverbs.pyverbs_error import PyverbsUserError
-from pyverbs.qp cimport QPInitAttr, QPAttr
+from pyverbs.qp cimport QPInitAttr, QPAttr, ECE
from pyverbs.base import PyverbsRDMAErrno
cimport pyverbs.libibverbs_enums as e
cimport pyverbs.librdmacm_enums as ce
@@ -424,6 +424,27 @@ cdef class CMID(PyverbsCM):
if ret != 0:
raise PyverbsRDMAErrno('Failed to Complete an active connection request')
+ def set_local_ece(self, ECE ece):
+ """
+ Set local ECE paraemters to be used for REQ/REP communication.
+ :param ece: ECE object with the requested configuration
+ :return: None
+ """
+ rc = cm.rdma_set_local_ece(self.id, &ece.ece)
+ if rc != 0:
+ raise PyverbsRDMAErrno('Failed to set local ECE')
+
+ def get_remote_ece(self):
+ """
+ Get ECE parameters as were received from the communication peer.
+ :return: ECE object with the ece configuration
+ """
+ ece = ECE()
+ rc = cm.rdma_get_remote_ece(self.id, &ece.ece)
+ if rc != 0:
+ raise PyverbsRDMAErrno('Failed to get remote ECE')
+ return ece
+
def create_qp(self, QPInitAttr qp_init not None):
"""
Create a QP, which is associated with CMID.
diff --git a/pyverbs/libibverbs.pxd b/pyverbs/libibverbs.pxd
index 6ffa303c..52f51f07 100755
--- a/pyverbs/libibverbs.pxd
+++ b/pyverbs/libibverbs.pxd
@@ -475,6 +475,11 @@ cdef extern from 'infiniband/verbs.h':
uint64_t wr_id
unsigned int wr_flags
+ cdef struct ibv_ece:
+ uint32_t vendor_id
+ uint32_t options
+ uint32_t comp_mask
+
ibv_device **ibv_get_device_list(int *n)
void ibv_free_device_list(ibv_device **list)
ibv_context *ibv_open_device(ibv_device *device)
@@ -599,3 +604,5 @@ cdef extern from 'infiniband/verbs.h':
cdef extern from 'infiniband/driver.h':
int ibv_query_gid_type(ibv_context *context, uint8_t port_num,
unsigned int index, ibv_gid_type *type)
+ int ibv_set_ece(ibv_qp *qp, ibv_ece *ece)
+ int ibv_query_ece(ibv_qp *qp, ibv_ece *ece)
diff --git a/pyverbs/librdmacm.pxd b/pyverbs/librdmacm.pxd
index 03c0cddc..ff579205 100755
--- a/pyverbs/librdmacm.pxd
+++ b/pyverbs/librdmacm.pxd
@@ -97,6 +97,8 @@ cdef extern from '<rdma/rdma_cma.h>':
int rdma_create_id(rdma_event_channel *channel, rdma_cm_id **id,
void *context, rdma_port_space ps)
int rdma_destroy_id(rdma_cm_id *id)
+ int rdma_get_remote_ece(rdma_cm_id *id, ibv_ece *ece)
+ int rdma_set_local_ece(rdma_cm_id *id, ibv_ece *ece)
int rdma_get_request(rdma_cm_id *listen, rdma_cm_id **id)
int rdma_bind_addr(rdma_cm_id *id, sockaddr *addr)
int rdma_resolve_addr(rdma_cm_id *id, sockaddr *src_addr,
diff --git a/pyverbs/qp.pxd b/pyverbs/qp.pxd
index 209a2438..1294560a 100644
--- a/pyverbs/qp.pxd
+++ b/pyverbs/qp.pxd
@@ -43,3 +43,6 @@ cdef class DataBuffer(PyverbsCM):
cdef class QPEx(QP):
cdef v.ibv_qp_ex *qp_ex
+
+cdef class ECE(PyverbsCM):
+ cdef v.ibv_ece ece
diff --git a/pyverbs/qp.pyx b/pyverbs/qp.pyx
index 95ef554c..fd851443 100755
--- a/pyverbs/qp.pyx
+++ b/pyverbs/qp.pyx
@@ -4,9 +4,8 @@
from libc.stdlib cimport malloc, free
from libc.string cimport memcpy
+from pyverbs.pyverbs_error import PyverbsUserError, PyverbsError, PyverbsRDMAError
from pyverbs.utils import gid_str, qp_type_to_str, qp_state_to_str, mtu_to_str
-from pyverbs.pyverbs_error import PyverbsUserError, PyverbsError, \
- PyverbsRDMAError
from pyverbs.utils import access_flags_to_str, mig_state_to_str
from pyverbs.base import PyverbsRDMAErrno
from pyverbs.wr cimport RecvWR, SendWR, SGE
@@ -871,6 +870,27 @@ cdef class QPAttr(PyverbsObject):
print_format.format('Rate limit', self.attr.rate_limit)
+cdef class ECE(PyverbsCM):
+ def __init__(self, vendor_id=0, options=0, comp_mask=0):
+ """
+ :param vendor_id: Unique identifier of the provider vendor.
+ :param options: Provider specific attributes which are supported or
+ needed to be enabled by ECE users.
+ :param comp_mask: A bitmask specifying which ECE options should be
+ valid.
+ """
+ super().__init__()
+ self.ece.vendor_id = vendor_id
+ self.ece.options = options
+ self.ece.comp_mask = comp_mask
+
+ def __str__(self):
+ print_format = '{:22}: {:<20}\n'
+ print_format.format('Vendor ID', self.ece.vendor_id) +\
+ print_format.format('Options', self.ece.options) +\
+ print_format.format('Comp Mask', self.ece.comp_mask)
+
+
cdef class QP(PyverbsCM):
def __init__(self, object creator not None, object init_attr not None,
QPAttr qp_attr=None):
@@ -1133,6 +1153,27 @@ cdef class QP(PyverbsCM):
memcpy(&bad_wr.send_wr, my_bad_wr, sizeof(bad_wr.send_wr))
raise PyverbsRDMAError('Failed to post send', rc)
+ def set_ece(self, ECE ece):
+ """
+ Set ECE options and use them for QP configuration stage
+ :param ece: The requested ECE values.
+ :return: None
+ """
+ rc = v.ibv_set_ece(self.qp, &ece.ece)
+ if rc != 0:
+ raise PyverbsRDMAError('Failed to set ECE', rc)
+
+ def query_ece(self):
+ """
+ Query QPs ECE options
+ :return: ECE object with this QP ece configuration.
+ """
+ ece = ECE()
+ rc = v.ibv_query_ece(self.qp, &ece.ece)
+ if rc != 0:
+ raise PyverbsRDMAError('Failed to query ECE', rc)
+ return ece
+
@property
def qp_type(self):
return self.qp.qp_type
--
2.25.2
next prev parent reply other threads:[~2020-04-20 14:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-20 14:06 [PATCH rdma-core 00/12] Add Enhanced Connection Established (ECE) APIs Leon Romanovsky
2020-04-20 14:06 ` [PATCH rdma-core 01/12] Update kernel headers Leon Romanovsky
2020-04-20 14:06 ` [PATCH rdma-core 02/12] libibverbs: Add interfaces to configure and use ECE Leon Romanovsky
2020-04-20 14:06 ` [PATCH rdma-core 03/12] libibverbs: Document ECE API Leon Romanovsky
2020-04-20 14:06 ` [PATCH rdma-core 04/12] debian: Install all available librdmacm man pages Leon Romanovsky
2020-04-20 14:06 ` [PATCH rdma-core 05/12] librdmacm: Provide interface to use ECE for external QPs Leon Romanovsky
2020-04-20 14:06 ` [PATCH rdma-core 06/12] librdmacm: Connect rdma_connect to the ECE Leon Romanovsky
2020-04-20 14:06 ` [PATCH rdma-core 07/12] librdmacm: Return ECE results through rdma_accept Leon Romanovsky
2020-04-20 14:06 ` [PATCH rdma-core 08/12] librdmacm: Add an option to reject ECE request Leon Romanovsky
2020-04-20 14:06 ` [PATCH rdma-core 09/12] librdmacm: Implement ECE handshake logic Leon Romanovsky
2020-04-20 14:06 ` [PATCH rdma-core 10/12] librdmacm: Document ECE API Leon Romanovsky
2020-04-20 14:06 ` Leon Romanovsky [this message]
2020-04-20 14:06 ` [PATCH rdma-core 12/12] tests: Add test for rdmacm ECE mechanism 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=20200420140648.275554-12-leon@kernel.org \
--to=leon@kernel.org \
--cc=dledford@redhat.com \
--cc=idok@mellanox.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 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.