From patchwork Tue Jul 12 19:36:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adit Ranadive X-Patchwork-Id: 9226077 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 DAC7460871 for ; Tue, 12 Jul 2016 19:38:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C884B27D85 for ; Tue, 12 Jul 2016 19:38:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCCF827DCD; Tue, 12 Jul 2016 19:38:02 +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 3EB3F27FA3 for ; Tue, 12 Jul 2016 19:38:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751681AbcGLTh6 (ORCPT ); Tue, 12 Jul 2016 15:37:58 -0400 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:4615 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751674AbcGLThz (ORCPT ); Tue, 12 Jul 2016 15:37:55 -0400 Received: from sc9-mailhost3.vmware.com (10.113.161.73) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Tue, 12 Jul 2016 12:37:26 -0700 Received: from EX13-CAS-007.vmware.com (smtp-inbound.vmware.com [10.113.191.57]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 2BB4A4045A; Tue, 12 Jul 2016 12:37:50 -0700 (PDT) Received: from EX13-MBX-031.vmware.com (10.113.191.71) by EX13-MBX-027.vmware.com (10.113.191.47) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Tue, 12 Jul 2016 12:37:50 -0700 Received: from EX13-CAS-003.vmware.com (10.113.191.53) by EX13-MBX-031.vmware.com (10.113.191.71) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Tue, 12 Jul 2016 12:37:49 -0700 Received: from NAM02-CY1-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; Tue, 12 Jul 2016 12:37:48 -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=OgK65DDeoUOnKJWHkGE1QXB7Ci3mk761OUNgHosW2W8=; b=Y3LVjU/LU5SZ8EU1XIh4zu5PGCJyz306IQzDF2jt/3U5aCvLGv1tmhzooODCBjAmTaXn/EdyOEM3DE3UIiSbZf4DntbRn3q3NHgEq+OEJgd2MOxkhIdI8xHC/RGMenk/aA5+Pnj8FoBZ0SYTKHYoNtxxeaOhjS9Ndq/HYIGZjTE= 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 BLUPR0501MB834.namprd05.prod.outlook.com (10.141.251.148) with Microsoft SMTP Server (TLS) id 15.1.539.14; Tue, 12 Jul 2016 19:37:41 +0000 From: Adit Ranadive To: , , CC: Adit Ranadive , , , , Subject: [PATCH v2 11/15] IB/pvrdma: Add user-level shared functions Date: Tue, 12 Jul 2016 12:36:41 -0700 Message-ID: <1468352205-9137-12-git-send-email-aditr@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468352205-9137-1-git-send-email-aditr@vmware.com> References: <1468352205-9137-1-git-send-email-aditr@vmware.com> MIME-Version: 1.0 X-Originating-IP: [208.91.1.34] X-ClientProxiedBy: SN1PR10CA0055.namprd10.prod.outlook.com (10.164.10.151) To BLUPR0501MB834.namprd05.prod.outlook.com (10.141.251.148) X-MS-Office365-Filtering-Correlation-Id: f24f04b7-3f62-4472-d491-08d3aa8bfdb3 X-Microsoft-Exchange-Diagnostics: 1; BLUPR0501MB834; 2:dney2ABJcjaMyMrW7khdOy5of8CBBHDZQjp80jj++1kl5ocaI1r57B9XokeJjSaggqpodjYuTDp7luUrHCgB3RwdRtPqCvk4dd5nWYQqiOla7ZSL30Xl7fqoOUrG0pirEN/4pJGkzptLTk1ihWJ1OqvnsNwm1SWTUNQ5j9Wk3ylKwKCdbnjwJuo2AC25NiG2; 3:DsnhZsKMZ2HF44MK2TtVkrOU/aUHOR5kSgzJHMyP5Qta3kfJMd7x5mYGZucJbJfwieAxr1rimmFuWws12dPbMNXrFfSTKqtOa7AKzy8kqv4cAZCRgTaCSXwWHnrrwv77 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0501MB834; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0501MB834; 25:cLRBEYHTHfAwaGpCCKd/wnt3RuNh/kWpZ+tSQJ7da1TMp5pCcEWG++KEv5OiDkuvFkaM5422UkWweTLW+CxQQtBWNITGvyf2a0VJdwoz5HV2rQzFd408V63go4ME9ykgq5svAlTgcLXPfxZYlxH4M6963Sc52/RLbkfpbB35WuBLvh9EnNFThO91/qfDU/SYLC9cgdTiZy/97nWCghGGGeRJkwOdh2nvIrZMUA8INcazSAWA70X6BWCIIcOiySFr6SXqHeZD7HZKHJ8gyQo6SdETxRC24O+R9exVvP9fIDzBkZIId4187EYjAovlP2PEhpaKYu+iR7zIKZnHSsJUQ5pn90rHJcyX1fu3uUx2+He6cOJ+GB6Ku+TiX7/ESUq27pAcHuZbqV3P0M52S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5FhKsdjqeIM7M+I1pIO9s2aTkboswGFG4QdHyFHoPRjO1dBj3H7cPwekpedMYR1X1VvGlt6tKI43ZQJYS7+JCduNtJl0egTGP9bDZkGNA4PQOwK/tY0+hhQ45u9Ut76lU5kgNaKZZ0DxIMFsAML+zZvCpE37REOL3xwVcbel/zQmMxo5qCGYAaIT4iPCHu1zbCSXPeOiSeyhS+OA7SIjqRa4EoPPlVxepHVnUwZ8UWa+uFi1laAUKl4V2VV+yOjkfEwQbEV/A8TxPzdgOYMFMQk7nkbm7n+TWrxN9MfdXOGNuEA1nnqMYl2T8q88ptkhqtgrfWiT2s 9trY6WhALVcXCDRh+VkDnp+sAc5xBcIEzY= 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)(5005006)(8121501046)(3002001)(10201501046); SRVR:BLUPR0501MB834; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0501MB834; X-Forefront-PRVS: 0001227049 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(199003)(189002)(305945005)(7736002)(50226002)(86362001)(4326007)(2906002)(42186005)(7846002)(68736007)(33646002)(229853001)(106356001)(50986999)(586003)(3846002)(2201001)(6116002)(15975445007)(97736004)(81166006)(81156014)(48376002)(36756003)(5003940100001)(19580395003)(19580405001)(47776003)(2950100001)(77096005)(66066001)(50466002)(4001450100002)(4001430100002)(101416001)(92566002)(189998001)(76176999)(105586002)(8676002)(107886002)(5001770100001)(7099028)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0501MB834; 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; BLUPR0501MB834; 23:TpD9DxL89/2ac456FoBgK2RKkZhSGDB+1kQjRq2s?= =?us-ascii?Q?3w2eEGhHBr4UK2pZu7iuvunSo5GqklptCbR018I10tDAGZ0ntn+gRQGFe45P?= =?us-ascii?Q?zgJFu+ywLl0XK6ucQsdp0ZoP/zG1evyzrxGbHQhbq3qtsxU0WybYaIngFDkf?= =?us-ascii?Q?M470DHKwKCYQs81JTz1Z/RHYB1la5UCUYMBgSSjjqQRUBnkE4elVtvRKHSvr?= =?us-ascii?Q?CnqQAZtlXaHtvhq+4+fLgGnXuz/vn0DUEZqgzsP6jcXpvScKdVhmFazlY1sM?= =?us-ascii?Q?eJPxZUabLgghqa0G2VYrwHz7bTFyWwOUrT9Dtq/EstRzSihRqdLYqmLQM1zi?= =?us-ascii?Q?xw+UcIIO15eHIdoiOkijsnbsq2XP0xdLvoj/Hgwai5PhputaN81DLi13Nk9T?= =?us-ascii?Q?93BObv4UK60AzdseYOF5k0Im6pbSGgTV6SMGyDNzR/fH3xu9/JkyXRPCbBY8?= =?us-ascii?Q?ZtADjJ+9vqrYiDLLaRu3m9pN6q/742ujCynr1C40iWgK+WLmAByl/nPKMo88?= =?us-ascii?Q?uI9UAvazZQ8FPLSU7DW/Dz8KlpE3FPGI90i8MPqiPHj0RgfnlhPLqWxL+TZy?= =?us-ascii?Q?kGuKXxQUZUpnlgJBbQ+U9sz15Jwvd5854ma16xbDg8M70M6KRaUmT4nn4BJd?= =?us-ascii?Q?FAIXnNAsjdenCg+4Mr//u426g2qFnlk67ZxSHpIVytE3v5LkeoB+PWgCRm9V?= =?us-ascii?Q?SKkX7Fpd2FnJ+gHtICVIaDQvWH5oO+izzDXJbPszQfThcSu3MUgyOlxvcisl?= =?us-ascii?Q?5+lO5J/usCVLYhBbk1os4Ye3uQhvEDrZXkNWtfeSCy0fSySQwva8VmchXQ4U?= =?us-ascii?Q?BpXr57dKk0paq2EAcpfk2W6Nl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fBmEFimpx4iypqiCy0k0N/AB7Lo=; 7:abetQZ+aMamIbz6INWY/GmtKNrsVybsl0Cu/9Ym8ns7IxJc+Y0HdMMXPYaFPcmhlnZlQYIyho0klFcne0YPMhU3qkh3p8G2JCo6/C5bHBI4HMCy/ma4L7BcocxN218eCl1NzYBIP2Y/jUAl+17SXEOoPsmBVjuRCLL9kDJKcCGTh3yLabBt4vlB295jha7zmox6WVX8JlQxLj4P8K5hC89aepW8OItCkw4TSbxZ/8ABRgJ19gRWBChIHPK0ebHrU SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR0501MB834; 20:6MBq0XVrE6LHwAGhCfNp0m49G2i6LZsSFJz/NiMoghK/VHOhPnFovH/BcHRw+GIv+eQRCZL3NKIMpNUyCUqE2wvS7z0zfwKDVUckQAYnkGnhTjeA96jzBJTh1vhO1pWH7Q3YrgRy3WoHGHSYN+WskaHH4a7BO2Y4Auqn3HL2Aaw= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2016 19:37:41.2430 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0501MB834 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: 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 | 247 +++++++++++++++++++++++++++++ drivers/infiniband/hw/pvrdma/pvrdma_user.h | 99 ++++++++++++ 2 files changed, 346 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..274328c --- /dev/null +++ b/drivers/infiniband/hw/pvrdma/pvrdma_uapi.h @@ -0,0 +1,247 @@ +/* + * 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. */ + +/* 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 -1; +} + +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 -1; +} + +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 -1; +} + +static inline __s32 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 1; + else if (head > tail && (*idx >= head || *idx < tail)) + return 1; + } + return 0; +} + +#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__ */