From patchwork Wed Aug 3 23:27:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adit Ranadive X-Patchwork-Id: 9262391 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 9E07A6048B for ; Wed, 3 Aug 2016 23:47:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E0D727FAB for ; Wed, 3 Aug 2016 23:47:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82A5E28068; Wed, 3 Aug 2016 23:47:06 +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=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 645A527FAB for ; Wed, 3 Aug 2016 23:47:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932669AbcHCXrB (ORCPT ); Wed, 3 Aug 2016 19:47:01 -0400 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:33503 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758477AbcHCXq7 (ORCPT ); Wed, 3 Aug 2016 19:46:59 -0400 Received: from sc9-mailhost1.vmware.com (10.113.161.71) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Wed, 3 Aug 2016 16:27:27 -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 6A71F18596; Wed, 3 Aug 2016 16:28:17 -0700 (PDT) Received: from EX13-CAS-001.vmware.com (10.113.191.51) by EX13-MBX-024.vmware.com (10.113.191.44) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Wed, 3 Aug 2016 16:28:17 -0700 Received: from NAM03-DM3-obe.outbound.protection.outlook.com (10.113.170.11) by EX13-CAS-001.vmware.com (10.113.191.51) with Microsoft SMTP Server (TLS) id 15.0.1156.6 via Frontend Transport; Wed, 3 Aug 2016 16:28:17 -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=1HxQobStMkyVDCjAeQWwhvMU/293eWsQy2igwAuPu+8=; b=TAhp6ezXFnNTXmWLJQgtY0S1brMlIRmqLhBn/H6FhzTsSbGSKA6gKrsxYcuJW4dqegQrZRisRfTFzAcEZzVQ14w6a1bgOeJVdw3F6yzumhGodgmG32VWSJNEDkyZw7odSZy8jhpMPEsBGWVVQ+wS7nkISGcOFJP+sdUgek7Fe90= 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 SN2PR0501MB847.namprd05.prod.outlook.com (10.160.14.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.549.15; Wed, 3 Aug 2016 23:28:08 +0000 From: Adit Ranadive To: , , CC: Adit Ranadive , , , , Subject: [PATCH v3 01/15] IB/pvrdma: Add user-level shared functions Date: Wed, 3 Aug 2016 16:27:30 -0700 Message-ID: <1470266864-16888-2-git-send-email-aditr@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1470266864-16888-1-git-send-email-aditr@vmware.com> References: <1470266864-16888-1-git-send-email-aditr@vmware.com> MIME-Version: 1.0 X-Originating-IP: [208.91.1.34] X-ClientProxiedBy: CY1PR12CA0084.namprd12.prod.outlook.com (10.163.230.52) To SN2PR0501MB847.namprd05.prod.outlook.com (10.160.14.145) X-MS-Office365-Filtering-Correlation-Id: 2a1577fc-0f9a-4c2a-62cd-08d3bbf5d4b8 X-Microsoft-Exchange-Diagnostics: 1; SN2PR0501MB847; 2:V902/EBqhgBqkBJqpn03LoQKugODdqMEFJb23UvaO4Qtf7+n2kRES6ieE0UdM2m/vFduzGTJDZRk5hgOwPASndajLGqnMX63T1Y+7nj0IVGw6+G0BVvfL6JTruhzz1js9DUmYgs0QRz4duRoFkruPGNEB8TRo3BwF7a2nDxqKtNAyEkYkN192qVp8gxh9cLX; 3:FIgZvpCAvVCGLWthIKg/W8vft/GKCwTk1nj9B+cIQXLDGy+oQ3x5imJbUoUOiMRWioxkYh3u/jwYCu2WAcGHHRS+qooBWXA83xF7XcU4dQErMyR61qpbqgmMPVLm0i50 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN2PR0501MB847; X-Microsoft-Exchange-Diagnostics: 1; SN2PR0501MB847; 25:Z/cGZwNKP3raA5rDYMibpWoMzcIkEt0CsSuSG9RaEVlkyu925IOxb21cbSw5gMkELU2Uph8oTvM+ax19QrQarlWfi7abT8n0xt6/xJ0h2VIwdhNTIppSg2E82y1xFRGjTXZuMK+dngbhjvwxgPJKNhRta6E+bqAO/0M6P4eMlCqokgVQgFPUfy+trS/kLULqH00dseqDlhvxi6sqEaqfXJty6G6gE5zcHTBRYAkyS0E6vtBkbV40OshJyDe4jdTEFLo1AhaJgWMen2bNGYZVXfGnIs4+ULrsMJOUbEkXAXCVZwQ+FVd0tJWluv4Ko/bxNDWQutJ4sMkiptD4jP57676Mk+ZBhNgsGi3LbWhxP0/pwpcmWNAauY10kdtJTbgxQJgI3QxsXkcoICWU6fgYM1w1T65rgZVvjkXDHUk9QML+t78kk28NuD3Ef1fzanPrVJc2XOvIfLkA6NeYP68tfwzehWaoWnM162+cWFlDppDtsJm1YWTRmofkYwhMmFFb3U7bmjn+1hI1VSpXoKX3UBvHjydH9ACgCdbLYx9osMy8ONye3uRvrFzZNuYqhAIQ4te7eaYjQoeewz7RvMEJamVy9GttsQ3ZyouL5RSwTj2I7b/YSZWvxRWrtg30iPfVsrxH2Z3qhlFsrczAvJc16qXMRcgs7pX4jMMIX4WQaYfGbVzvadcyDFwN1FJKuqyKxex2r9AKQBod/IMMqLpdypj5rmqjYbZcbt1P7gTT8KmUheXgGu8OTKw+dzswroOiGA77eu9QGqu0AYUhv5p+cYg8Indm4ySnya9Ws2fM6CE= X-Microsoft-Exchange-Diagnostics: 1; SN2PR0501MB847; 31:jlp+dDTJTliDF8r5n0NlPfMCh7gZbr7Nx3Juo2+IC680VuIm97O+0bz8baeudmLypSJW6ll8xu45Y0ZpW41weoJRMuWOIiUzMKNclOHNG74yBMakKLpdk01hGTCfqI8Nyyr1DfYqIcwPEL5WDdTYjRUkh2EKT0QjJnpkq66PcVLc8tkYALNPxRM0iIE7i7HZ1nUB6RfxyPmMmULsqVAGSa0YLwZjmy0up7C0cgAyGY0=; 20:m0xEtewObc91c4gguj4t07jbS835IcTKqhZvLIP/G6gpjA9gdaHUYd3D2WXiRYR7VJdVwjjUnG90OoeBqptdPqGHDihuhcEuJZbfaDoIGSDBz2vwpMBwRHH0UcKLcnQl3K0q1Je+YiFVRMCRRZ7V9LWPQM8eqxTJ2fgESVn1vSsH8sQKwgP2IwMcebAAtqx9qEUZ+fKCu32HfIC1FFmJSMCAyHvD4cE1zj+ldY+YJyuF6MAIuZyJRO1IK4nc0YYx X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(61668805478150)(22074186197030); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001); SRVR:SN2PR0501MB847; BCL:0; PCL:0; RULEID:; SRVR:SN2PR0501MB847; X-Microsoft-Exchange-Diagnostics: 1; SN2PR0501MB847; 4:EL7x5mEkKA8CTobUX9Fsi785t/gToCu20uxwlXTEXYXiuVSlSiC2/6yk1DZJh4hQEHDc2KWCjtHn1VgcofOZilTbvXIbif26wT3/4wsmGMrYZZ4GdHTsBbJoMko60n0czpQgq/mtPd6geSxOqqYV0iH+h+8wJsFBt2P9+a9g5Z0eG+1iypSerh8B5DqT4MMeCQsYZtN3tYRIXp7t0s9neUsehqQIB9QcisWxAg6vwO0AUKqrj0NSuQxQ+PsrWF+2Vu3UIImLi8Gziygj4aswxLF4W6mVkZEHo9HbvqUXCkr6jUA+sRGjtu76HzcCZsyXs4+BVniCWc1L3q8Md39ItkVMVKXjGUbW52gkoYy0uWza6eV48a0D9GstPhIryr1YM2Su1/zb2xxkMv++sCIt760ti5YH/9hrpEUiCodmobnAOvsE/PieycbxxUbta7+6JQgjzNJYl/pY4zixqilqoOp7mD+LwZJtz4igN7WyReE= X-Forefront-PRVS: 00235A1EEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(199003)(189002)(4001450100002)(66066001)(106356001)(189998001)(33646002)(92566002)(107886002)(5001770100001)(77096005)(15975445007)(229853001)(48376002)(50466002)(101416001)(97736004)(2950100001)(42186005)(586003)(47776003)(68736007)(76176999)(50986999)(4001430100002)(2906002)(105586002)(7846002)(7736002)(305945005)(81156014)(50226002)(86362001)(81166006)(8676002)(6116002)(36756003)(3846002)(5003940100001)(19580405001)(19580395003)(2201001)(4326007)(7099028)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR0501MB847; H:promb-2s-dhcp95-136.eng.vmware.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (EX13-EDG-OU-001.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; SN2PR0501MB847; 23:xwf6I9xU312ZRee6FVkXnf6v429YJ6f6bbApKvl5?= =?us-ascii?Q?2xqOi3qOk69H/JEt+PP+oVAoqV6oxLRKWuxBsDPOe3eIqpeqN/ItQCbE08Zp?= =?us-ascii?Q?QrFAx2GkFB26cV9ilVrbJMq4QZEX6N8jiBhh176G//29XVgO7SEqmc0CIW6R?= =?us-ascii?Q?zS8F42hGzGGURpDDQJFwXXRfO1DjAcCVI01P6xghEocwr72Oowu9ygxYLvYP?= =?us-ascii?Q?HKRezbQmIYxvZs9yLvrTbLbQG6CIgojUYnSuThsNFrLBvTbUv8z5KFthauX7?= =?us-ascii?Q?roTgov9VMsE+ea3+ipksvcWobC1D5YtpPRY7jr/VnimzRXp+9CwsFHslY0j+?= =?us-ascii?Q?1TlDnl+Vl97vn55TuhArpPSEZtbI1my42Of1/hVrnuYk1PjnVV3tLoJZtINf?= =?us-ascii?Q?hkkdHC7CSLRt27CI3bPo9xyVbfnfS0OHcym7t4AB3kp+nfTvsLz/T3xV1O6f?= =?us-ascii?Q?nHr/40BxE+yVOis0OSqcWKfEyOBlXD26AgTEufgoeTUGqQJcmZ6npHScbwCy?= =?us-ascii?Q?HWYIfpBuD7HJKcFf4caaLSP4woekpboZJ44OUPWeG66OzDdonMCv3FAQEABk?= =?us-ascii?Q?i4uoHld3djCF59TQWMaMSUDmNxahtmZODEHSAPgfUIOPzBBENXAZh+37fQqG?= =?us-ascii?Q?pwU10Lyetuu1oKy20qw+raJLvKtZHmfc1HTLI3Ob1FWw0nbrgY0W8WX/xQo0?= =?us-ascii?Q?dKxQkMB2ad6NyBBAFAcnK9YtLaLGnjwScpZhpzAqKFV0pcA3ey6BEaTyzvwt?= =?us-ascii?Q?+H4kyE4Cj2gNfSpoDfOlntPYLpA6c6ahzKN08TVB93zQzejmTR88YnDD7bFa?= =?us-ascii?Q?OgACccBvYkkT/xnMl6/eL2y5oopTP6YLtaW40ps/DGMq5mtP1wOTVIPbfZeF?= =?us-ascii?Q?s0FwzmPIcUit3VPWaP1ErFYOcU7883qRba5iT2snBopo4gWkJz7kjlIHl81m?= =?us-ascii?Q?OIaz69emoY9U6+U9NyJGfMZI+aOXBIhkt4fcS9EuOEqK8gZnfzcjZnpYesmb?= =?us-ascii?Q?MgzUGc/EjdLqdxxkgeDV7MbTxakfGIhbh0pK+lAtWa7zKrSGL/gl2jKLqr+F?= =?us-ascii?Q?Vpc/TqQqkzPOYaOAderatJv3eBbCKZZQ35H3KThMsEa8cTmSx0pJ6XlWBigS?= =?us-ascii?Q?Xigk+bjQbmOtZjnHmgPdmOd4B1/SoSn8crBfPY6/WbRNPvt4WgCUallnCwrh?= =?us-ascii?Q?v6eoV/eyNVvoNQFAKptzEPeX0yokzH3SvWkDgK3WFjucM/rQDjluVambZw?= =?us-ascii?Q?=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN2PR0501MB847; 6:CUswiEmvMjXmO6MSg/DZMLPXcEU4KIVrE7CuLkSXPkoCAEHjeybadf+0oVvhZQbNlPjTcYgHQ6j5gjSKlZfvVNzQIHazXU97GKC/3ncaek7ftsp41jZLk833RLEYh11TnUSNv0I414rgBeRzo6HODvpTXgIEMjXQKuV8+u5ZxN7i13x5lOSNBcwqK29lfDxrm+HdWhyoxiNst+0RAvPHy2um3bmk9+SJeqNVNu8Zit4HCC6i/UhRmdpIQuBE4/WTxt+a1vbGgVuUZI0xNzNapR9+Sy1plpn5gFuCGIfxzp4=; 5:zSU6c39F1iaBgO4XkjOgrs4PeULSi/i/iUcbOd1sAXKWJPnG9lWhIXiNwj0a7pcefKUepRwndADe6j9ivvKNgF3Z5rVz4muLuIF7hA6uC9RnqYpoln9DpuQEoydgCIaIhPsaZxFp3NlF2I40fetGqg==; 24:wRgEl3Us3SoFEruLIcepTmzJmUmM1Ncp2vQk7Sq9wAX9dDOx7aUrNiKLRNYLU08i1wUCCVVp9mMTEWRL6xEv419xqDRgKZ+Iej2zipgLO3U=; 7:OdP1CQ3QnrTb323QBhKd7xr+Ni+1U/yxRzGff5OYKbv0giDjm9j6OAvMhnBnHKXMryyU1oS52Mes/2TB3vzUeFQsdLaK2f20NrBcu9PObvoNcgdZ/5OMynTUgu9TD3BuYSRPja9uLqVHSBDx49WsRfx1ze54zwmC8kALF1XAYPqEeljlC+3At7sJsU5ajnIPReUeSIUHBzRCHII4apyQJcHOrA/7WH/pxdTg9B4iRMImLQhCMUz7HjzIdkob5DVl SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN2PR0501MB847; 20:f14/RxVKBHSSGDMBdJbUEvJCUuXljVcYunM+vakq1wH4zt9vbgrjy3xQic7mjrndH1SaVlUzGUc8MLD1iuzzKN5GMZ9VQykRShrMOW7ZQ+1p9yG4hkNu/vZmKzY9bIyB7JqMG8iaOcjbkqWrKK62btrL8cSJawz9s91DD7whjNI= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2016 23:28:08.8044 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR0501MB847 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. Changes from v2->v3: - Defined what -1 means for an index return value in pvrdma_uapi.h Reviewed-by: Jorgen Hansen Reviewed-by: George Zhang Reviewed-by: Aditya Sarwade Reviewed-by: Bryan Tan Signed-off-by: Adit Ranadive --- drivers/infiniband/hw/pvrdma/pvrdma_uapi.h | 248 +++++++++++++++++++++++++++++ drivers/infiniband/hw/pvrdma/pvrdma_user.h | 99 ++++++++++++ 2 files changed, 347 insertions(+) create mode 100644 drivers/infiniband/hw/pvrdma/pvrdma_uapi.h create mode 100644 drivers/infiniband/hw/pvrdma/pvrdma_user.h diff --git a/drivers/infiniband/hw/pvrdma/pvrdma_uapi.h b/drivers/infiniband/hw/pvrdma/pvrdma_uapi.h new file mode 100644 index 0000000..104ffca --- /dev/null +++ b/drivers/infiniband/hw/pvrdma/pvrdma_uapi.h @@ -0,0 +1,248 @@ +/* + * 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 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 receieve 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__ */ diff --git a/drivers/infiniband/hw/pvrdma/pvrdma_user.h b/drivers/infiniband/hw/pvrdma/pvrdma_user.h new file mode 100644 index 0000000..35f8c1e --- /dev/null +++ b/drivers/infiniband/hw/pvrdma/pvrdma_user.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__ */