diff mbox series

[rdma-core,4/7] pyverbs: Add support for provider extended CQ

Message ID 20191117133030.10784-5-noaos@mellanox.com (mailing list archive)
State Not Applicable
Headers show
Series pyverbs/mlx5: Support mlx5 CQ and QP | expand

Commit Message

Noa Osherovich Nov. 17, 2019, 1:30 p.m. UTC
An extended CQ can be created using either the generic interface or a
provider specific interface.
Provider CQs extend the legacy extended CQ, which in Cython means that
the legacy CQEX's __cinit__ will be called automatically. To avoid
initialization via legacy interface, add **kwargs to CQEX's
__cinit__(). If kwargs is not empty, the CQEX's __cinit__ will return
without creating the CQ, leaving the initialization to the provider.

Signed-off-by: Noa Osherovich <noaos@mellanox.com>
---
 pyverbs/cq.pyx | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/pyverbs/cq.pyx b/pyverbs/cq.pyx
index ecfef6d7fdb9..ac6baa618c3d 100755
--- a/pyverbs/cq.pyx
+++ b/pyverbs/cq.pyx
@@ -254,7 +254,8 @@  cdef class CqInitAttrEx(PyverbsObject):
 
 
 cdef class CQEX(PyverbsCM):
-    def __cinit__(self, Context context not None, CqInitAttrEx init_attr):
+    def __cinit__(self, Context context not None, CqInitAttrEx init_attr,
+                  **kwargs):
         """
         Initializes a CQEX object on the given device's context with the given
         attributes.
@@ -262,6 +263,11 @@  cdef class CQEX(PyverbsCM):
         :param init_attr: Initial attributes that describe the CQ
         :return: The newly created CQEX on success
         """
+        self.qps = weakref.WeakSet()
+        self.srqs = weakref.WeakSet()
+        if len(kwargs) > 0:
+            # Leave CQ initialization to the provider
+            return
         if init_attr is None:
             init_attr = CqInitAttrEx()
         self.cq = v.ibv_create_cq_ex(context.context, &init_attr.attr)
@@ -272,8 +278,6 @@  cdef class CQEX(PyverbsCM):
         self.ibv_cq = v.ibv_cq_ex_to_cq(self.cq)
         self.context = context
         context.add_ref(self)
-        self.qps = weakref.WeakSet()
-        self.srqs = weakref.WeakSet()
 
     cdef add_ref(self, obj):
         if isinstance(obj, QP):