From patchwork Sat Sep 24 23:21:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adit Ranadive X-Patchwork-Id: 9349331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5775260B16 for ; Sat, 24 Sep 2016 23:22:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48565290C6 for ; Sat, 24 Sep 2016 23:22:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C7DF290D1; Sat, 24 Sep 2016 23:22:35 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 A547E290D0 for ; Sat, 24 Sep 2016 23:22:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965681AbcIXXWW (ORCPT ); Sat, 24 Sep 2016 19:22:22 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:3077 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965621AbcIXXWQ (ORCPT ); Sat, 24 Sep 2016 19:22:16 -0400 Received: from sc9-mailhost1.vmware.com (10.113.161.71) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Sat, 24 Sep 2016 16:21:51 -0700 Received: from EX13-CAS-004.vmware.com (smtp-inbound.vmware.com [10.113.191.54]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 12D4818445; Sat, 24 Sep 2016 16:22:15 -0700 (PDT) Received: from EX13-MBX-034.vmware.com (10.113.191.74) by EX13-MBX-023.vmware.com (10.113.191.43) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Sat, 24 Sep 2016 16:22:14 -0700 Received: from EX13-CAS-003.vmware.com (10.113.191.53) by EX13-MBX-034.vmware.com (10.113.191.74) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Sat, 24 Sep 2016 16:22:14 -0700 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (10.113.170.11) by EX13-CAS-003.vmware.com (10.113.191.53) with Microsoft SMTP Server (TLS) id 15.0.1156.6 via Frontend Transport; Sat, 24 Sep 2016 16:22:14 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=onevmw.onmicrosoft.com; s=selector1-vmware-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=tMQZNgbylzZIwhFuibI0o0gooV/BhL5pGnf8yAOhuzY=; b=kf0rnrejjvz+bsTX5dFGxvmmLUW+trExsKb4XnVlTYlJ8qlxYKFUUf9WG6Vd5CmQdlM2WeyZJYHVsw2oAJz+oaRxTq6wwE6PqiNKvnocmjBgwxgirxwMhBrxRFSi39BfxC/4/tMiSnFjh8J4L/hFDnYVMWSL/FuHw0CNb2sqmko= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aditr@vmware.com; Received: from promb-2s-dhcp95-136.eng.vmware.com (208.91.1.34) by CO2PR0501MB837.namprd05.prod.outlook.com (10.141.244.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.2; Sat, 24 Sep 2016 23:22:09 +0000 From: Adit Ranadive To: , , CC: Adit Ranadive , , , , , , Subject: [PATCH v5 02/16] IB/pvrdma: Add user-level shared functions Date: Sat, 24 Sep 2016 16:21:26 -0700 Message-ID: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [208.91.1.34] X-ClientProxiedBy: CY1PR18CA0027.namprd18.prod.outlook.com (10.163.31.37) To CO2PR0501MB837.namprd05.prod.outlook.com (10.141.244.147) X-MS-Office365-Filtering-Correlation-Id: 4f3512e6-4d37-4388-a61d-08d3e4d19c57 X-Microsoft-Exchange-Diagnostics: 1; CO2PR0501MB837; 2:57yHrXYfHYLigoP+fgIWYef5FEFdBAcQOTWxIYmVZGot2HJ2DxF86Fe1BDwnLk9O5L2rGl72ULWpIwrnqf7chotojLZjEfJ8q3WhnZks1aBpdklM0TdgbF9U+EUe77RPC2ZrP+P42Iz1SvwKR31fXtqxy9KIMvrilDHEZKd2QzQzJ/oPXXMmQhASwIn9Q1Tc; 3:4sLrmWHGqAkELxRS8ExZ79u1T1HKbm9yUb9pwk/7rzYg7mmkXF/TuXkA2n4Av+8Wrk7R4l7It+/0u5n+gARkGmw+KB6H8rPcCMWjmiRhvwSJHH/t4FZ+cPViohjOVWjk X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO2PR0501MB837; X-Microsoft-Exchange-Diagnostics: 1; CO2PR0501MB837; 25:Mjz0QRdHGMq8+A6RsManvlV0xDX2WDT7Tg9zXw0SdY7wf1uXF5DHt9ga4muyde68NxmnosVfdCDlO9uVfuavsQfSHWacj1ZU67av8CvsXMQh4jFlNaftc3/Q9rYVsvyEE4Yez6MdC9Db0DL/mvlDkN25dnNVXp4FIMFgMeEZeFwaRyKuhp+CLFxcUD5SdlXJj4haTsC4feV/hFUIVnhoyQpIq9uJmNGlVny6z3Tezsrw6TfaR2daewA5oGn6r3tejPJCbsIQdx2aG+w+uqSRpzNI8Mu1iTXVOwIByrjdTVU5OYkLbsc0WIoV4teJOIHyJycx7+tIqdj9R1svyrBjGUeoVOsWYeXE+ux5Cszpd2M6afTaJW+I4wHifA3ee33V1NzUuV/CDM9xgWRPt94K9HAk+Fze6t046d7mr6gK1ei2ars+HB60zY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7OpYbRPlWO0/u6ioUY67KzdAGe9hdamVLbjrjcT2VF9EVH9m/AJUeUYTx6GCh1d8M79wMtvI/lc97Jy1mfQ/SXpVmUOFKYB+qTOndKv0HCSBRPnPtIm345BlI0Rd6IoUZgMhu2TKMnBVsdLaKeQ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(61668805478150)(22074186197030)(146099531331640); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:CO2PR0501MB837; BCL:0; PCL:0; RULEID:; SRVR:CO2PR0501MB837; X-Microsoft-Exchange-Diagnostics: 1; CO2PR0501MB837; 4:c+Lok77Srr9i/xk6MGv9CrxXG5+OPNEH4lx1g1Hm8l65FITwLecNUvizo1xO3jflTBQvYg5JX24bnUgMuQwrJDBLhrEIC+nEqvifP23NhnKVoAvymY4E1Vf/Jj9y2HXtxr5g22wiaZp1tciTMUEYksSdh8yuquZhV79EaoP9dxITSo9+IxY5Ecd013MlKyU2e/MW7KhESQZGc+ELxO9Wn96HDYA+YvLCmSDoxZIRS+wx8gD90qytS2VHFq9xjnawClL9MObfAFkq/562v8i/N9c7CHORRELnskXdI/1ROYTj61/fw00bBGuaX//DC+gHO9K0szMZPTTVXpA9ROskrEFMcSyJEbnuxnoeGGcqFQm6Ne4Zv0/T6FhhOru1oIU7QmTZ4aMXNRu30vgI0Y9XgskdwVxkUrz06RnAmZULh+z9B6M1JRRVmbtOex965jsBOo1KJ9UIUWPqdhJwuccw7y57YekvwGVS46O6SRGhkWtQx4IrFUE9D6cNAtJxvXlGd/0vYq70WsMppFFy4grIUlIWXCI+c5zSJE+UbSpZKGE= X-Forefront-PRVS: 0075CB064E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(189002)(199003)(107886002)(77096005)(97736004)(4326007)(106356001)(105586002)(15975445007)(76176999)(586003)(6862003)(118296001)(50986999)(2950100002)(33646002)(6116002)(5001770100001)(19580395003)(5660300001)(19580405001)(92566002)(2906002)(3846002)(47776003)(189998001)(50466002)(86362001)(48376002)(575784001)(2201001)(81156014)(81166006)(101416001)(8676002)(50226002)(5003940100001)(36756003)(7736002)(7846002)(305945005)(229853001)(42186005)(68736007)(66066001)(4001430100002)(7099028)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR0501MB837; H:promb-2s-dhcp95-136.eng.vmware.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (EX13-EDG-OU-002.vmware.com: aditr@vmware.com does not designate permitted sender hosts) Received-SPF: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR0501MB837; 23:ffuSwsGMB0M54uyTUjRLUlBEELuZfsKa5ThtcfnW?= =?us-ascii?Q?em79kNhKpHTOVM9WPJnjNcazaBA23uCn5ToVwPKx5B6QlIYAUPWvDA6P6uyE?= =?us-ascii?Q?19U6O3Bxfkpy1qzBk6Yv912TU41hlsGd3+ZjdNR7I4eGYhU6LHVsmM8Hk0h1?= =?us-ascii?Q?rB96ch4LI0CslPYHtENUsG/6FWd123K+VZ+IE2z8kzsZ3MEIyCwT333QSs0K?= =?us-ascii?Q?WWwk8tp6U4i3JOLLaHoTXtlIdpaP0K6y6nXxaXPy1r9+AOP+mO8sS0yyN8AA?= =?us-ascii?Q?98SKXSIuVkSuIMHrM1d2zQlMBaQFxJm2w3EDfk3EjDD18j+euzuYhYI0tVcF?= =?us-ascii?Q?InyYngm95Tztr11mQKdX4yGoralgTZCHjs/D2ADeDAjo1b1Cby2x3lTeGDVh?= =?us-ascii?Q?hL63buuKnhjWV3CWR68ykrVGsf3RtJjmgoEBXJTKtir62Zj9ujJR+xCQDZJq?= =?us-ascii?Q?bHGnAw4ZtdHLpRnMTqT+Qr7C3EtgRw4gsipbCWnngafJTrKzFEhzzLnoRalz?= =?us-ascii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bhFUhVKxwHZUtz4WHSgshe0AqoQ4AfyQP/Av3JYa7Okk6yU4SKWIZ/0r/lGnj9Pt2559eSiXs6bvp5hKSi6rTymypHBbfr/9CK4m3FxSxGvh2lNkjgZHEHnvDgj/mWeATc+0rE4RlXUXLmEiV6k+UyY0SpG0FGl9TYgF/yOQaO5bDtxups9EakSmuRljs=; 5:mxY3xOFw818JAb8LBk02tQZUTmvVZoLZCbuc8HwUV3I8jcPns9cXGIGm7izyC9SVV4QgXh20rG5LLv8UM7g9CUBj/TpcQBYmalayD6UbQF/FGi0IEaC4gaeRiqk1iab5JPMgr1h2829fWnrFxoTZRQ==; 24:B1nfdnwJ5PVCsHhrO4WJJJe96Lg4HjJZjEACqDjOeXL7dsxbUivckVJtnSI73zZnkSUPQTM5OFRctf2DQdGSPfESpeaUMIc7FWrvRmOc+rE=; 7:8pHYCH0rax08Ud3I6uN0DwdEzfGAPpj2V5tMIonP3ueN46ZI6rLAQNHw+C2Sylo2matrPHuijPO29YzNalQVdgW3wnNnXB7QLRy43MP9TMv5vzEOVEKPfUV969dcWf8BO13MQJPn0vpjFFdP+BeOLPtiIcbr0ATB5Wiv4LdqndH0iQJ1SXsCseud2h1LnL66M0pa1Gl6pLU4t6Y5q/2UpCbysNXRXCokt0Dd6AI0fzHWcydstRv0Ukl8khvyPm2YHGD8wa/M3ia74pC9LH8otu1kNtCQGURiVSXRhQakSO4+nZXIFTus6rgGlIfj6ZL7 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CO2PR0501MB837; 20:QrW2UmlASWg8Rh3B1YmGkklhrG+m+cQMrtSsy9tldRBH2OQwgK6rpCn6qX7xkpzPPONod9hnPpEDocxMsyCR8nsNFvo+BByCEgZi8pLvYWUQg0Jffyvt9Nsn0RDLTyNcSKKP8R/dDBu5XDdeEJJastjEYAhM+uhFuJNAK0xnRXA= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2016 23:22:09.9169 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR0501MB837 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 We share some common structures with the user-level driver. This patch adds those structures and shared functions to traverse the QP/CQ rings. Reviewed-by: Yuval Shaia Reviewed-by: Jorgen Hansen Reviewed-by: George Zhang Reviewed-by: Aditya Sarwade Reviewed-by: Bryan Tan Signed-off-by: Adit Ranadive --- Changes v4->v5: - Moved pvrdma_uapi.h and pvrdma_user.h into common UAPI folder. - Renamed to pvrdma-uapi.h and pvrdma-abi.h respectively. - Prefixed unsigned vars with __. Changes v3->v4: - Moved pvrdma_sge into pvrdma_uapi.h --- include/uapi/rdma/Kbuild | 2 + include/uapi/rdma/pvrdma-abi.h | 99 ++++++++++++++++ include/uapi/rdma/pvrdma-uapi.h | 255 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 356 insertions(+) create mode 100644 include/uapi/rdma/pvrdma-abi.h create mode 100644 include/uapi/rdma/pvrdma-uapi.h diff --git a/include/uapi/rdma/Kbuild b/include/uapi/rdma/Kbuild index 4edb0f2..fc2b285 100644 --- a/include/uapi/rdma/Kbuild +++ b/include/uapi/rdma/Kbuild @@ -7,3 +7,5 @@ header-y += rdma_netlink.h header-y += rdma_user_cm.h header-y += hfi/ header-y += rdma_user_rxe.h +header-y += pvrdma-abi.h +header-y += pvrdma-uapi.h diff --git a/include/uapi/rdma/pvrdma-abi.h b/include/uapi/rdma/pvrdma-abi.h new file mode 100644 index 0000000..6fa0ab6 --- /dev/null +++ b/include/uapi/rdma/pvrdma-abi.h @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2012-2016 VMware, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of EITHER the GNU General Public License + * version 2 as published by the Free Software Foundation or the BSD + * 2-Clause License. This program is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License version 2 for more details at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html. + * + * You should have received a copy of the GNU General Public License + * along with this program available in the file COPYING in the main + * directory of this source tree. + * + * The BSD 2-Clause License + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __PVRDMA_USER_H__ +#define __PVRDMA_USER_H__ + +#include + +#define PVRDMA_UVERBS_ABI_VERSION 3 +#define PVRDMA_BOARD_ID 1 +#define PVRDMA_REV_ID 1 + +struct pvrdma_alloc_ucontext_resp { + __u32 qp_tab_size; + __u32 reserved; +}; + +struct pvrdma_alloc_pd_resp { + __u32 pdn; + __u32 reserved; +}; + +struct pvrdma_create_cq { + __u64 buf_addr; + __u32 buf_size; + __u32 reserved; +}; + +struct pvrdma_create_cq_resp { + __u32 cqn; + __u32 reserved; +}; + +struct pvrdma_resize_cq { + __u64 buf_addr; + __u32 buf_size; + __u32 reserved; +}; + +struct pvrdma_create_srq { + __u64 buf_addr; +}; + +struct pvrdma_create_srq_resp { + __u32 srqn; + __u32 reserved; +}; + +struct pvrdma_create_qp { + __u64 rbuf_addr; + __u64 sbuf_addr; + __u32 rbuf_size; + __u32 sbuf_size; + __u64 qp_addr; +}; + +#endif /* __PVRDMA_USER_H__ */ diff --git a/include/uapi/rdma/pvrdma-uapi.h b/include/uapi/rdma/pvrdma-uapi.h new file mode 100644 index 0000000..430d8a5 --- /dev/null +++ b/include/uapi/rdma/pvrdma-uapi.h @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2012-2016 VMware, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of EITHER the GNU General Public License + * version 2 as published by the Free Software Foundation or the BSD + * 2-Clause License. This program is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License version 2 for more details at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html. + * + * You should have received a copy of the GNU General Public License + * along with this program available in the file COPYING in the main + * directory of this source tree. + * + * The BSD 2-Clause License + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __PVRDMA_UAPI_H__ +#define __PVRDMA_UAPI_H__ + +#include + +#define PVRDMA_VERSION 17 + +#define PVRDMA_UAR_HANDLE_MASK 0x00FFFFFF /* Bottom 24 bits. */ +#define PVRDMA_UAR_QP_OFFSET 0 /* Offset of QP doorbell. */ +#define PVRDMA_UAR_QP_SEND BIT(30) /* Send bit. */ +#define PVRDMA_UAR_QP_RECV BIT(31) /* Recv bit. */ +#define PVRDMA_UAR_CQ_OFFSET 4 /* Offset of CQ doorbell. */ +#define PVRDMA_UAR_CQ_ARM_SOL BIT(29) /* Arm solicited bit. */ +#define PVRDMA_UAR_CQ_ARM BIT(30) /* Arm bit. */ +#define PVRDMA_UAR_CQ_POLL BIT(31) /* Poll bit. */ +#define PVRDMA_INVALID_IDX -1 /* Invalid index. */ + +/* PVRDMA atomic compare and swap */ +struct pvrdma_exp_cmp_swap { + __u64 swap_val; + __u64 compare_val; + __u64 swap_mask; + __u64 compare_mask; +}; + +/* PVRDMA atomic fetch and add */ +struct pvrdma_exp_fetch_add { + __u64 add_val; + __u64 field_boundary; +}; + +/* PVRDMA address vector. */ +struct pvrdma_av { + __u32 port_pd; + __u32 sl_tclass_flowlabel; + __u8 dgid[16]; + __u8 src_path_bits; + __u8 gid_index; + __u8 stat_rate; + __u8 hop_limit; + __u8 dmac[6]; + __u8 reserved[6]; +}; + +/* PVRDMA scatter/gather entry */ +struct pvrdma_sge { + __u64 addr; + __u32 length; + __u32 lkey; +}; + +/* PVRDMA receive queue work request */ +struct pvrdma_rq_wqe_hdr { + __u64 wr_id; /* wr id */ + __u32 num_sge; /* size of s/g array */ + __u32 total_len; /* reserved */ +}; +/* Use pvrdma_sge (ib_sge) for receive queue s/g array elements. */ + +/* PVRDMA send queue work request */ +struct pvrdma_sq_wqe_hdr { + __u64 wr_id; /* wr id */ + __u32 num_sge; /* size of s/g array */ + __u32 total_len; /* reserved */ + __u32 opcode; /* operation type */ + __u32 send_flags; /* wr flags */ + union { + __u32 imm_data; + __u32 invalidate_rkey; + } ex; + __u32 reserved; + union { + struct { + __u64 remote_addr; + __u32 rkey; + __u8 reserved[4]; + } rdma; + struct { + __u64 remote_addr; + __u64 compare_add; + __u64 swap; + __u32 rkey; + __u32 reserved; + } atomic; + struct { + __u64 remote_addr; + __u32 log_arg_sz; + __u32 rkey; + union { + struct pvrdma_exp_cmp_swap cmp_swap; + struct pvrdma_exp_fetch_add fetch_add; + } wr_data; + } masked_atomics; + struct { + __u64 iova_start; + __u64 pl_pdir_dma; + __u32 page_shift; + __u32 page_list_len; + __u32 length; + __u32 access_flags; + __u32 rkey; + } fast_reg; + struct { + __u32 remote_qpn; + __u32 remote_qkey; + struct pvrdma_av av; + } ud; + } wr; +}; +/* Use pvrdma_sge (ib_sge) for send queue s/g array elements. */ + +/* Completion queue element. */ +struct pvrdma_cqe { + __u64 wr_id; + __u64 qp; + __u32 opcode; + __u32 status; + __u32 byte_len; + __u32 imm_data; + __u32 src_qp; + __u32 wc_flags; + __u32 vendor_err; + __u16 pkey_index; + __u16 slid; + __u8 sl; + __u8 dlid_path_bits; + __u8 port_num; + __u8 smac[6]; + __u8 reserved2[7]; /* Pad to next power of 2 (64). */ +}; + +struct pvrdma_ring { + atomic_t prod_tail; /* Producer tail. */ + atomic_t cons_head; /* Consumer head. */ +}; + +struct pvrdma_ring_state { + struct pvrdma_ring tx; /* Tx ring. */ + struct pvrdma_ring rx; /* Rx ring. */ +}; + +static inline int pvrdma_idx_valid(__u32 idx, __u32 max_elems) +{ + /* Generates fewer instructions than a less-than. */ + return (idx & ~((max_elems << 1) - 1)) == 0; +} + +static inline __s32 pvrdma_idx(atomic_t *var, __u32 max_elems) +{ + const unsigned int idx = atomic_read(var); + + if (pvrdma_idx_valid(idx, max_elems)) + return idx & (max_elems - 1); + return PVRDMA_INVALID_IDX; +} + +static inline void pvrdma_idx_ring_inc(atomic_t *var, __u32 max_elems) +{ + __u32 idx = atomic_read(var) + 1; /* Increment. */ + + idx &= (max_elems << 1) - 1; /* Modulo size, flip gen. */ + atomic_set(var, idx); +} + +static inline __s32 pvrdma_idx_ring_has_space(const struct pvrdma_ring *r, + __u32 max_elems, __u32 *out_tail) +{ + const __u32 tail = atomic_read(&r->prod_tail); + const __u32 head = atomic_read(&r->cons_head); + + if (pvrdma_idx_valid(tail, max_elems) && + pvrdma_idx_valid(head, max_elems)) { + *out_tail = tail & (max_elems - 1); + return tail != (head ^ max_elems); + } + return PVRDMA_INVALID_IDX; +} + +static inline __s32 pvrdma_idx_ring_has_data(const struct pvrdma_ring *r, + __u32 max_elems, __u32 *out_head) +{ + const __u32 tail = atomic_read(&r->prod_tail); + const __u32 head = atomic_read(&r->cons_head); + + if (pvrdma_idx_valid(tail, max_elems) && + pvrdma_idx_valid(head, max_elems)) { + *out_head = head & (max_elems - 1); + return tail != head; + } + return PVRDMA_INVALID_IDX; +} + +static inline bool pvrdma_idx_ring_is_valid_idx(const struct pvrdma_ring *r, + __u32 max_elems, __u32 *idx) +{ + const __u32 tail = atomic_read(&r->prod_tail); + const __u32 head = atomic_read(&r->cons_head); + + if (pvrdma_idx_valid(tail, max_elems) && + pvrdma_idx_valid(head, max_elems) && + pvrdma_idx_valid(*idx, max_elems)) { + if (tail > head && (*idx < tail && *idx >= head)) + return true; + else if (head > tail && (*idx >= head || *idx < tail)) + return true; + } + return false; +} + +#endif /* __PVRDMA_UAPI_H__ */