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 5/5] Documentation: Document creation of CMID
Date: Mon, 4 Nov 2019 10:37:29 +0000	[thread overview]
Message-ID: <20191104103710.11196-6-noaos@mellanox.com> (raw)
In-Reply-To: <20191104103710.11196-1-noaos@mellanox.com>

From: Maxim Chicherin <maximc@mellanox.com>

Add code snippet to demonstrate creation of CMID and establish
connection (synchronous control path).

Signed-off-by: Maxim Chicherin <maximc@mellanox.com>
---
 Documentation/pyverbs.md | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/Documentation/pyverbs.md b/Documentation/pyverbs.md
index 29ab9592c53c..6ff6fc5bbc37 100755
--- a/Documentation/pyverbs.md
+++ b/Documentation/pyverbs.md
@@ -390,3 +390,33 @@ srq_attr.comp_mask = e.IBV_SRQ_INIT_ATTR_TYPE | e.IBV_SRQ_INIT_ATTR_PD | \
                      e.IBV_SRQ_INIT_ATTR_CQ | e.IBV_SRQ_INIT_ATTR_XRCD
 srq = SRQ(ctx, srq_attr)
 ```
+
+##### CMID
+The following code snippet will demonstrate creation of a CMID object, which
+represents rdma_cm_id C struct, and establish connection between two peers.
+Currently only synchronous control path is supported (rdma_create_ep).
+For more complex examples, please see tests/test_rdmacm.
+```python
+from pyverbs.qp import QPInitAttr, QPCap
+from pyverbs.cmid import CMID, AddrInfo
+import pyverbs.cm_enums as ce
+
+cap = QPCap(max_recv_wr=1)
+qp_init_attr = QPInitAttr(cap=cap)
+server = '11.137.14.124'
+port = '7471'
+
+# Active side
+
+cai = AddrInfo(server, port, ce.RDMA_PS_TCP)
+cid = CMID(creator=cai, qp_init_attr=qp_init_attr)
+cid.connect()  # send connection request to server
+
+# Passive side
+
+sai = AddrInfo(server, port, ce.RDMA_PS_TCP, ce.RAI_PASSIVE)
+sid = CMID(creator=sai, qp_init_attr=qp_init_attr)
+sid.listen()  # listen for incoming connection requests
+new_id = sid.get_request()  # check if there are any connection requests
+new_id.accept()  # new_id is connected to remote peer and ready to communicate
+```
-- 
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 ` [PATCH rdma-core 3/5] tests: New CMResources Class Noa Osherovich
2019-11-04 10:37 ` [PATCH rdma-core 4/5] tests: Add RDMACM synchronous traffic test Noa Osherovich
2019-11-04 10:37 ` Noa Osherovich [this message]

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-6-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).