linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Noa Osherovich <noaos@mellanox.com>
To: "dledford@redhat.com" <dledford@redhat.com>,
	Jason Gunthorpe <jgg@mellanox.com>,
	Leon Romanovsky <leonro@mellanox.com>
Cc: "linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	Maxim Chicherin <maximc@mellanox.com>
Subject: [PATCH rdma-core 3/5] tests: New CMResources Class
Date: Mon, 4 Nov 2019 10:37:27 +0000	[thread overview]
Message-ID: <20191104103710.11196-4-noaos@mellanox.com> (raw)
In-Reply-To: <20191104103710.11196-1-noaos@mellanox.com>

From: Maxim Chicherin <maximc@mellanox.com>

A base aggregation object for RDMACM. Currently only synchronous data
path flow is supported.

Signed-off-by: Maxim Chicherin <maximc@mellanox.com>
---
 tests/base.py | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/tests/base.py b/tests/base.py
index e4e92fa2a35f..54bfc42ffe4c 100755
--- a/tests/base.py
+++ b/tests/base.py
@@ -11,13 +11,16 @@ from pyverbs.qp import QPCap, QPInitAttrEx, QPInitAttr, QPAttr, QP
 from pyverbs.addr import AHAttr, GlobalRoute
 from pyverbs.xrcd import XRCD, XRCDInitAttr
 from pyverbs.srq import SRQ, SrqInitAttrEx
+from pyverbs.cmid import CMID, AddrInfo
 from pyverbs.device import Context
+import pyverbs.cm_enums as ce
 import pyverbs.device as d
 import pyverbs.enums as e
 from pyverbs.pd import PD
 from pyverbs.cq import CQ
 from pyverbs.mr import MR
 
+
 PATH_MTU = e.IBV_MTU_1024
 MAX_DEST_RD_ATOMIC = 1
 MAX_RD_ATOMIC = 1
@@ -26,6 +29,10 @@ RETRY_CNT = 7
 RNR_RETRY = 7
 TIMEOUT = 14
 
+# for rdmacm
+PORT = '7471'
+ZERO_ADDR = '0.0.0.0'
+
 
 class PyverbsAPITestCase(unittest.TestCase):
     def setUp(self):
@@ -144,6 +151,51 @@ class RDMATestCase(unittest.TestCase):
             self._add_gids_per_port(ctx, dev, port+1)
 
 
+class CMResources:
+    """
+    CMResources class is a base aggregator object which contains basic
+    resources for RDMA CM communication.
+    """
+    def __init__(self, src=ZERO_ADDR, dst=ZERO_ADDR, port=PORT):
+        """
+        :param src: Local address to bind to (for passive side)
+        :param dst: Destination address to connect (for active side)
+        :param port: Port number of the address
+        """
+        self.is_server = True if dst == ZERO_ADDR else False
+        self.qp_init_attr = None
+        self.msg_size = 1024
+        self.num_msgs = 100
+        self.new_id = None
+        self.port = port
+        self.mr = None
+        if self.is_server:
+            self.ai = AddrInfo(src, self.port, ce.RDMA_PS_TCP,
+                               ce.RAI_PASSIVE)
+        else:
+            self.ai = AddrInfo(dst, self.port, ce.RDMA_PS_TCP)
+        self.create_qp_init_attr()
+        self.cmid = CMID(creator=self.ai, qp_init_attr=self.qp_init_attr)
+
+    def create_mr(self, cmid):
+        self.mr = cmid.reg_msgs(self.msg_size)
+
+    def create_qp_init_attr(self):
+        self.qp_init_attr = QPInitAttr(cap=QPCap(max_recv_wr=1))
+
+    def listen(self):
+        self.cmid.listen()
+        self.new_id = self.cmid.get_request()
+        self.new_id.accept()
+
+    def pre_run(self):
+        if self.is_server:
+            self.listen()
+        else:
+            self.cmid.connect()
+        self.create_mr(self.new_id if self.is_server else self.cmid)
+
+
 class BaseResources(object):
     """
     BaseResources class is a base aggregator object which contains basic
-- 
2.21.0


  parent reply	other threads:[~2019-11-04 10:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-04 10:37 [PATCH rdma-core 0/5] Introducing RDMACM support in pyverbs Noa Osherovich
2019-11-04 10:37 ` [PATCH rdma-core 1/5] pyverbs: New CMID class Noa Osherovich
2019-11-04 11:09   ` Benjamin Drung
2019-11-05 14:46     ` Leon Romanovsky
2019-11-04 10:37 ` [PATCH rdma-core 2/5] tests: Fix PD API test Noa Osherovich
2019-11-04 10:37 ` Noa Osherovich [this message]
2019-11-04 10:37 ` [PATCH rdma-core 4/5] tests: Add RDMACM synchronous traffic test Noa Osherovich
2019-11-04 10:37 ` [PATCH rdma-core 5/5] Documentation: Document creation of CMID Noa Osherovich

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=20191104103710.11196-4-noaos@mellanox.com \
    --to=noaos@mellanox.com \
    --cc=dledford@redhat.com \
    --cc=jgg@mellanox.com \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=maximc@mellanox.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).