From patchwork Mon May 6 15:07:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noa Osherovich X-Patchwork-Id: 10931239 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A4EA912 for ; Mon, 6 May 2019 15:07:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 490492878F for ; Mon, 6 May 2019 15:07:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D502287C3; Mon, 6 May 2019 15:07:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE4DD2878F for ; Mon, 6 May 2019 15:07:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727391AbfEFPHr (ORCPT ); Mon, 6 May 2019 11:07:47 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:50132 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727531AbfEFPHr (ORCPT ); Mon, 6 May 2019 11:07:47 -0400 Received: from Internal Mail-Server by MTLPINE2 (envelope-from noaos@mellanox.com) with ESMTPS (AES256-SHA encrypted); 6 May 2019 18:07:41 +0300 Received: from reg-l-vrt-059-009.mtl.labs.mlnx (reg-l-vrt-059-009.mtl.labs.mlnx [10.135.59.9]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x46F7edf019922; Mon, 6 May 2019 18:07:41 +0300 From: Noa Osherovich To: leon@kernel.org, jgg@mellanox.com, dledford@redhat.com Cc: linux-rdma@vger.kernel.org, Noa Osherovich Subject: [PATCH rdma-core 09/11] Documentation: Document QP creation and basic usage with pyverbs Date: Mon, 6 May 2019 18:07:36 +0300 Message-Id: <20190506150738.19477-10-noaos@mellanox.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190506150738.19477-1-noaos@mellanox.com> References: <20190506150738.19477-1-noaos@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add code to show the needed steps for QP creation as well as a simple post_send. Signed-off-by: Noa Osherovich --- Documentation/pyverbs.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Documentation/pyverbs.md b/Documentation/pyverbs.md index 371fcd07b2cd..22c51868e025 100644 --- a/Documentation/pyverbs.md +++ b/Documentation/pyverbs.md @@ -307,3 +307,35 @@ sgid index : 0 hop limit : 1 traffic class : 0 ``` + +##### QP +The following snippets will demonstrate creation of a QP and a simple post_send +operation. For more complex examples, please see pyverbs/examples section. +```python +from pyverbs.qp import QPCap, QPInitAttr, QPAttr, QP +from pyverbs.addr import GlobalRoute +from pyverbs.addr import AH, AHAttr +import pyverbs.device as d +import pyverbs.enums as e +from pyverbs.pd import PD +from pyverbs.cq import CQ +import pyverbs.wr as pwr + + +ctx = d.Context(name='mlx5_0') +pd = PD(ctx) +cq = CQ(ctx, 100, None, None, 0) +cap = QPCap(100, 10, 1, 1, 0) +qia = QPInitAttr(cap=cap, qp_type = e.IBV_QPT_UD, scq=cq, rcq=cq) +# A UD QP will be in RTS if a QPAttr object is provided +udqp = QP(pd, qia, QPAttr()) +port_num = 1 +gid_index = 3 # Hard-coded for RoCE v2 interface +gid = ctx.query_gid(port_num, gid_index) +gr = GlobalRoute(dgid=gid, sgid_index=gid_index) +ah_attr = AHAttr(gr=gr, is_global=1, port_num=port_num) +ah=AH(pd, ah_attr) +wr = pwr.SendWR() +wr.set_wr_ud(ah, 0x1101, 0) # in real life, use real values +udqp.post_send(wr) +```