From patchwork Mon Sep 12 04:49:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adit Ranadive X-Patchwork-Id: 9325665 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 A074D6048B for ; Mon, 12 Sep 2016 04:50:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95C4828ACC for ; Mon, 12 Sep 2016 04:50:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A97C28B16; Mon, 12 Sep 2016 04:50:37 +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 A0EAD28ACC for ; Mon, 12 Sep 2016 04:50:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756515AbcILEuc (ORCPT ); Mon, 12 Sep 2016 00:50:32 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:34207 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756241AbcILEu2 (ORCPT ); Mon, 12 Sep 2016 00:50:28 -0400 Received: from sc9-mailhost2.vmware.com (10.113.161.72) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Sun, 11 Sep 2016 21:50:17 -0700 Received: from EX13-CAS-005.vmware.com (ex13-cas-005.vmware.com [10.113.191.55]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id E4F43B04DB; Sun, 11 Sep 2016 21:50:26 -0700 (PDT) Received: from EX13-CAS-003.vmware.com (10.113.191.53) by EX13-MBX-021.vmware.com (10.113.191.41) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Sun, 11 Sep 2016 21:50:26 -0700 Received: from NAM03-BY2-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; Sun, 11 Sep 2016 21:50:26 -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=2CFnyQPgmGTOTWsISPiSPxKTqEGEiie8cY3mQbe/wEA=; b=UJnOeedSmH5IVWitNZdM4nf0TzdefeNSvJ/8d63tTJzJxtw4NnQrK3er0Fz1quD1Bo1SJ1vwbl/W13qLT1msnyBRy+n4Wm69oybAGV0G/NnlJPi1K6m0oKul1pT1lLKWE6RmIhEs8NnQ+tPS9DDANaF+C8iVyvZl3NWC+a1B0ZI= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none; redhat.com; dmarc=none action=none header.from=vmware.com; Received: from promb-2s-dhcp95-136.eng.vmware.com (208.91.1.34) by BLUPR0501MB836.namprd05.prod.outlook.com (10.141.251.150) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.619.3; Mon, 12 Sep 2016 04:50:20 +0000 From: Adit Ranadive To: , , CC: Adit Ranadive , , , , , , Subject: [PATCH v4 02/16] IB/pvrdma: Add user-level shared functions Date: Sun, 11 Sep 2016 21:49:12 -0700 Message-ID: <1473655766-31628-3-git-send-email-aditr@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473655766-31628-1-git-send-email-aditr@vmware.com> References: <1473655766-31628-1-git-send-email-aditr@vmware.com> MIME-Version: 1.0 X-Originating-IP: [208.91.1.34] X-ClientProxiedBy: BY2PR04CA052.namprd04.prod.outlook.com (10.141.249.170) To BLUPR0501MB836.namprd05.prod.outlook.com (10.141.251.150) X-MS-Office365-Filtering-Correlation-Id: 125679c7-50e6-44cb-4751-08d3dac84d57 X-Microsoft-Exchange-Diagnostics: 1; BLUPR0501MB836; 2:MMyfhfJ8u6SS7y2IecyEflXDTvn2yujQYmKBLmjdq9HZD/6jhQLq4VnRj5PxBK0FLU0655jo46O5tkcA/e8bklgT6B6M63asiFaMz7gpjdB0c7DM0HP634tmDkiaOwAp9yIWet3HAOvwVOBoGx+UMhlyxqhRi6dFKvEi2sBvbqTqjc7xoiPrGdiBOgTv8gKo; 3:xh6EE1z3ZUJX6/8wLmvuhRB/3DvwyAqh1WGKdUSg9U03ZFTTX9k4Q0xRSTTPWKT1d3bOHt/lddGSRgYqpSW5No79h2oXX53R6XLcPgXYiODinF5k0cqcKiBsqPwCwl4P; 25:WOJSrCFhV/ub60OjaxKCIAB8vpZhjT673FM/qhWYpk54Q/b1y0zDhKSz1yGfIP5t4wyDQVM/Kv2P2tT0MUlrNuLfVXr0HOKVArFisAabJOmw84qgjtdiNSSz2LtoTXQDXOgOWCT39IJFNnPU5amavX+iRV5GM4HP683BLQUjpmerEqnt3YAoGTHGkKntAK5t5aOU3w6lDW5kuEFE7ys4CumxholgtMxe5a76LG11RNp8djQ++4cyb7+jf/gNtLrmLd8jWbQzRg11l+ZBoSQ4ljls9DB4s7WTco2K0QIDzXc/UdorXaAGf6hdlguiOCc0/Ce/Vny6YMxOlIx2WIVxiWkuJ2ggEX/UiEzIar1r2gV6bRV78pL6KilGQHhCK9ay+VbNRutt5BM8t9tTsm+jkYLpUB5AhReHSF8MYY/IeAw= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0501MB836; X-LD-Processed: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; BLUPR0501MB836; 31:iNimPbePryvRscy6gy++VVRKIxVU1eMG4tKe+m5tk2dfHai5Fgq9FC2XZXQ0OnKQGQ5K+l81FyRLw7h7IfX0R/9Igc03rnl3MfKGjK/6fhJ48N0/IKHT/sMZZ2psXYCsY7OBGFReIXaw3GEayPpMfYmsDY0lygv6DI/8hZf0qz4Y0N7qkzqAhAeHIsa8vG36Fxp8jaS4zVo08ILM9cvPj6CMsRDcBlUhsVSeZXu12Dw=; 20:niNj0Et/yHp4822oQH8UEEfnJ52OhvIKWUZQitjyORRYUebP5H744Bbb2Pv8xztQ8yVALBk6icLW3lG2LfviBqyuInYLZccOTTngpnjmUiMOkGZ+nBA94qExwhoGiGELHvxwvDZtx8Ol1GkuPLOib6ztEcXjxSwmNuLy8yQlFyLbCCEL8rEEfZLg0rUMYVVmTmkUl9ohGNqGrDfJahPIfS0ighFZoJaOueEbyh/CNDem0ATGuZWRX5p2ACefLk2TZ1L+tcJRc+FB8b9NFgO0tyeyIH10p+6xiqIC05+YDwl9lihL+G5sSOgRqHW+2ab0PY5to+JSjZveAfyj+k7asQjC9V+v8y5/vXDSIMzgg4UTLqOMGszAUatVN4/4p1FXF7hHmGv7e/hJSwvEBC5vgodWSy/gJE6mc64RBrbrfOCsZ0ZbW9GAUhNy0uzWtJNx/e7zDidzoUye1TqlZ30ZqQ2Kv0I+QcydL5QvBiVQfB3uN5kviypkSyPWb6a+as96 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)(5005006)(8121501046)(3002001)(10201501046); SRVR:BLUPR0501MB836; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0501MB836; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0501MB836; 4:gc0Dwu9DJvRVGnzKMfi9wl8qRWncbD+VQW6hrI2WG727Vwzd3lEwigPiDI0Vvy1sjF3O/4TsPxi56fqECSQJvgPJ/ws24sIth1Kn4+wMatMAGLn7Zjth/rrf/jHQ+/mpsXAYuRw78SBademUwySfEU/+dMSorBlg8xx9OfPy0lKDPX27iBqNhZ1MfCErugdRyxZbCVjaR4Ir820TQtGUg6f112JwS8cTFcE0ATgb8HMWAzXLjLabcUrDo7lwgIqrEsL8OFayUcSirrTaO9p6naWDtYvPI8J10DqUdLsDgADEcpvYhfat3TxGpYpYtT2mgynCBTv29uO83E/LhqLDF7Y5r0z8ESvutWy+XWaOnNR96jgXDP1KEx+wjr3p5s1jVcSh/kW+hIbp1W4OSs96Kb5jZyFUzf4tRyifMeLzaHCnI8jAZ05/oj2BtL4LPVbrQKbSlsOcA11ikmhEOVcSFp5eJxJf4YNf7iLuW1HnsgCydHW+KG4Xq5jzhX9wedMNFxTvVJxbPtndtzSPvKTuIPDCisbp6UHQK76veSpmuOM= X-Forefront-PRVS: 006339698F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(66066001)(107886002)(4001430100002)(5003940100001)(36756003)(47776003)(189998001)(4001450100002)(87386001)(86362001)(48376002)(2201001)(50466002)(2906002)(50226002)(8676002)(81166006)(586003)(4326007)(7846002)(5660300001)(305945005)(42186005)(76176999)(7736002)(50986999)(6116002)(3846002)(15975445007)(4001520100001)(5001770100001)(19580405001)(33646002)(92566002)(19580395003)(2950100001)(77096005)(229853001)(7099028)(5001760100003)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0501MB836; H:promb-2s-dhcp95-136.eng.vmware.com; FPR:; SPF:None; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0501MB836; 23:uGeYIq++b/4Eu3erbZ1l1dk4mvyB2bDgfZ/xzQDS?= =?us-ascii?Q?Yf5cKQwPikBI4znqT92Z/3yGMZtB/4DI1WPiL0kHQuX4IegyTFOPwZ6RcEnb?= =?us-ascii?Q?7k+hJljowRoE/F9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utput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR0501MB836; 20:a+QTtlie8UyWSAUb6cl3e/2NmH5Bk3TovMbjERHnsSPnLGz62bM7pk+wqlqj9l4OWEeYup094CLrhJ9GVm7mwRKV0P3oJF3JNoy90Rx1RLHsnZUUWwG/ENk9j5VB7LL1piBJoyOqfWNimTG5fIVlzjn7oQw8jPj36ViHNvam0pQ= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2016 04:50:20.2851 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0501MB836 Received-SPF: None (EX13-EDG-OU-002.vmware.com: aditr@vmware.com does not designate permitted sender hosts) 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 v3->v4: - Moved pvrdma_sge into pvrdma_uapi.h --- drivers/infiniband/hw/pvrdma/pvrdma_uapi.h | 255 +++++++++++++++++++++++++++++ drivers/infiniband/hw/pvrdma/pvrdma_user.h | 99 +++++++++++ 2 files changed, 354 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..430d8a5 --- /dev/null +++ b/drivers/infiniband/hw/pvrdma/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__ */ 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__ */