1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */ 229c8d9ebSAdit Ranadive /* 329c8d9ebSAdit Ranadive * Copyright (c) 2012-2016 VMware, Inc. All rights reserved. 429c8d9ebSAdit Ranadive * 529c8d9ebSAdit Ranadive * This program is free software; you can redistribute it and/or 629c8d9ebSAdit Ranadive * modify it under the terms of EITHER the GNU General Public License 729c8d9ebSAdit Ranadive * version 2 as published by the Free Software Foundation or the BSD 829c8d9ebSAdit Ranadive * 2-Clause License. This program is distributed in the hope that it 929c8d9ebSAdit Ranadive * will be useful, but WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED 1029c8d9ebSAdit Ranadive * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 1129c8d9ebSAdit Ranadive * See the GNU General Public License version 2 for more details at 1229c8d9ebSAdit Ranadive * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html. 1329c8d9ebSAdit Ranadive * 1429c8d9ebSAdit Ranadive * You should have received a copy of the GNU General Public License 1529c8d9ebSAdit Ranadive * along with this program available in the file COPYING in the main 1629c8d9ebSAdit Ranadive * directory of this source tree. 1729c8d9ebSAdit Ranadive * 1829c8d9ebSAdit Ranadive * The BSD 2-Clause License 1929c8d9ebSAdit Ranadive * 2029c8d9ebSAdit Ranadive * Redistribution and use in source and binary forms, with or 2129c8d9ebSAdit Ranadive * without modification, are permitted provided that the following 2229c8d9ebSAdit Ranadive * conditions are met: 2329c8d9ebSAdit Ranadive * 2429c8d9ebSAdit Ranadive * - Redistributions of source code must retain the above 2529c8d9ebSAdit Ranadive * copyright notice, this list of conditions and the following 2629c8d9ebSAdit Ranadive * disclaimer. 2729c8d9ebSAdit Ranadive * 2829c8d9ebSAdit Ranadive * - Redistributions in binary form must reproduce the above 2929c8d9ebSAdit Ranadive * copyright notice, this list of conditions and the following 3029c8d9ebSAdit Ranadive * disclaimer in the documentation and/or other materials 3129c8d9ebSAdit Ranadive * provided with the distribution. 3229c8d9ebSAdit Ranadive * 3329c8d9ebSAdit Ranadive * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 3429c8d9ebSAdit Ranadive * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3529c8d9ebSAdit Ranadive * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 3629c8d9ebSAdit Ranadive * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 3729c8d9ebSAdit Ranadive * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 3829c8d9ebSAdit Ranadive * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 3929c8d9ebSAdit Ranadive * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 4029c8d9ebSAdit Ranadive * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 4129c8d9ebSAdit Ranadive * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 4229c8d9ebSAdit Ranadive * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 4329c8d9ebSAdit Ranadive * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 4429c8d9ebSAdit Ranadive * OF THE POSSIBILITY OF SUCH DAMAGE. 4529c8d9ebSAdit Ranadive */ 4629c8d9ebSAdit Ranadive 4729c8d9ebSAdit Ranadive #ifndef __VMW_PVRDMA_ABI_H__ 4829c8d9ebSAdit Ranadive #define __VMW_PVRDMA_ABI_H__ 4929c8d9ebSAdit Ranadive 5029c8d9ebSAdit Ranadive #include <linux/types.h> 5129c8d9ebSAdit Ranadive 5229c8d9ebSAdit Ranadive #define PVRDMA_UVERBS_ABI_VERSION 3 /* ABI Version. */ 5329c8d9ebSAdit Ranadive #define PVRDMA_UAR_HANDLE_MASK 0x00FFFFFF /* Bottom 24 bits. */ 5429c8d9ebSAdit Ranadive #define PVRDMA_UAR_QP_OFFSET 0 /* QP doorbell. */ 55d2acafeaSBryan Tan #define PVRDMA_UAR_QP_SEND (1 << 30) /* Send bit. */ 56d2acafeaSBryan Tan #define PVRDMA_UAR_QP_RECV (1 << 31) /* Recv bit. */ 5729c8d9ebSAdit Ranadive #define PVRDMA_UAR_CQ_OFFSET 4 /* CQ doorbell. */ 58d2acafeaSBryan Tan #define PVRDMA_UAR_CQ_ARM_SOL (1 << 29) /* Arm solicited bit. */ 59d2acafeaSBryan Tan #define PVRDMA_UAR_CQ_ARM (1 << 30) /* Arm bit. */ 60d2acafeaSBryan Tan #define PVRDMA_UAR_CQ_POLL (1 << 31) /* Poll bit. */ 61926aae27SBryan Tan #define PVRDMA_UAR_SRQ_OFFSET 8 /* SRQ doorbell. */ 62d2acafeaSBryan Tan #define PVRDMA_UAR_SRQ_RECV (1 << 30) /* Recv bit. */ 6329c8d9ebSAdit Ranadive 6429c8d9ebSAdit Ranadive enum pvrdma_wr_opcode { 6529c8d9ebSAdit Ranadive PVRDMA_WR_RDMA_WRITE, 6629c8d9ebSAdit Ranadive PVRDMA_WR_RDMA_WRITE_WITH_IMM, 6729c8d9ebSAdit Ranadive PVRDMA_WR_SEND, 6829c8d9ebSAdit Ranadive PVRDMA_WR_SEND_WITH_IMM, 6929c8d9ebSAdit Ranadive PVRDMA_WR_RDMA_READ, 7029c8d9ebSAdit Ranadive PVRDMA_WR_ATOMIC_CMP_AND_SWP, 7129c8d9ebSAdit Ranadive PVRDMA_WR_ATOMIC_FETCH_AND_ADD, 7229c8d9ebSAdit Ranadive PVRDMA_WR_LSO, 7329c8d9ebSAdit Ranadive PVRDMA_WR_SEND_WITH_INV, 7429c8d9ebSAdit Ranadive PVRDMA_WR_RDMA_READ_WITH_INV, 7529c8d9ebSAdit Ranadive PVRDMA_WR_LOCAL_INV, 7629c8d9ebSAdit Ranadive PVRDMA_WR_FAST_REG_MR, 7729c8d9ebSAdit Ranadive PVRDMA_WR_MASKED_ATOMIC_CMP_AND_SWP, 7829c8d9ebSAdit Ranadive PVRDMA_WR_MASKED_ATOMIC_FETCH_AND_ADD, 7929c8d9ebSAdit Ranadive PVRDMA_WR_BIND_MW, 8029c8d9ebSAdit Ranadive PVRDMA_WR_REG_SIG_MR, 816325e01bSAdit Ranadive PVRDMA_WR_ERROR, 8229c8d9ebSAdit Ranadive }; 8329c8d9ebSAdit Ranadive 8429c8d9ebSAdit Ranadive enum pvrdma_wc_status { 8529c8d9ebSAdit Ranadive PVRDMA_WC_SUCCESS, 8629c8d9ebSAdit Ranadive PVRDMA_WC_LOC_LEN_ERR, 8729c8d9ebSAdit Ranadive PVRDMA_WC_LOC_QP_OP_ERR, 8829c8d9ebSAdit Ranadive PVRDMA_WC_LOC_EEC_OP_ERR, 8929c8d9ebSAdit Ranadive PVRDMA_WC_LOC_PROT_ERR, 9029c8d9ebSAdit Ranadive PVRDMA_WC_WR_FLUSH_ERR, 9129c8d9ebSAdit Ranadive PVRDMA_WC_MW_BIND_ERR, 9229c8d9ebSAdit Ranadive PVRDMA_WC_BAD_RESP_ERR, 9329c8d9ebSAdit Ranadive PVRDMA_WC_LOC_ACCESS_ERR, 9429c8d9ebSAdit Ranadive PVRDMA_WC_REM_INV_REQ_ERR, 9529c8d9ebSAdit Ranadive PVRDMA_WC_REM_ACCESS_ERR, 9629c8d9ebSAdit Ranadive PVRDMA_WC_REM_OP_ERR, 9729c8d9ebSAdit Ranadive PVRDMA_WC_RETRY_EXC_ERR, 9829c8d9ebSAdit Ranadive PVRDMA_WC_RNR_RETRY_EXC_ERR, 9929c8d9ebSAdit Ranadive PVRDMA_WC_LOC_RDD_VIOL_ERR, 10029c8d9ebSAdit Ranadive PVRDMA_WC_REM_INV_RD_REQ_ERR, 10129c8d9ebSAdit Ranadive PVRDMA_WC_REM_ABORT_ERR, 10229c8d9ebSAdit Ranadive PVRDMA_WC_INV_EECN_ERR, 10329c8d9ebSAdit Ranadive PVRDMA_WC_INV_EEC_STATE_ERR, 10429c8d9ebSAdit Ranadive PVRDMA_WC_FATAL_ERR, 10529c8d9ebSAdit Ranadive PVRDMA_WC_RESP_TIMEOUT_ERR, 10629c8d9ebSAdit Ranadive PVRDMA_WC_GENERAL_ERR, 10729c8d9ebSAdit Ranadive }; 10829c8d9ebSAdit Ranadive 10929c8d9ebSAdit Ranadive enum pvrdma_wc_opcode { 11029c8d9ebSAdit Ranadive PVRDMA_WC_SEND, 11129c8d9ebSAdit Ranadive PVRDMA_WC_RDMA_WRITE, 11229c8d9ebSAdit Ranadive PVRDMA_WC_RDMA_READ, 11329c8d9ebSAdit Ranadive PVRDMA_WC_COMP_SWAP, 11429c8d9ebSAdit Ranadive PVRDMA_WC_FETCH_ADD, 11529c8d9ebSAdit Ranadive PVRDMA_WC_BIND_MW, 11629c8d9ebSAdit Ranadive PVRDMA_WC_LSO, 11729c8d9ebSAdit Ranadive PVRDMA_WC_LOCAL_INV, 11829c8d9ebSAdit Ranadive PVRDMA_WC_FAST_REG_MR, 11929c8d9ebSAdit Ranadive PVRDMA_WC_MASKED_COMP_SWAP, 12029c8d9ebSAdit Ranadive PVRDMA_WC_MASKED_FETCH_ADD, 12129c8d9ebSAdit Ranadive PVRDMA_WC_RECV = 1 << 7, 12229c8d9ebSAdit Ranadive PVRDMA_WC_RECV_RDMA_WITH_IMM, 12329c8d9ebSAdit Ranadive }; 12429c8d9ebSAdit Ranadive 12529c8d9ebSAdit Ranadive enum pvrdma_wc_flags { 12629c8d9ebSAdit Ranadive PVRDMA_WC_GRH = 1 << 0, 12729c8d9ebSAdit Ranadive PVRDMA_WC_WITH_IMM = 1 << 1, 12829c8d9ebSAdit Ranadive PVRDMA_WC_WITH_INVALIDATE = 1 << 2, 12929c8d9ebSAdit Ranadive PVRDMA_WC_IP_CSUM_OK = 1 << 3, 13029c8d9ebSAdit Ranadive PVRDMA_WC_WITH_SMAC = 1 << 4, 13129c8d9ebSAdit Ranadive PVRDMA_WC_WITH_VLAN = 1 << 5, 13272f9b089SAditya Sarwade PVRDMA_WC_WITH_NETWORK_HDR_TYPE = 1 << 6, 13372f9b089SAditya Sarwade PVRDMA_WC_FLAGS_MAX = PVRDMA_WC_WITH_NETWORK_HDR_TYPE, 13429c8d9ebSAdit Ranadive }; 13529c8d9ebSAdit Ranadive 136*9f206f73SBryan Tan enum pvrdma_network_type { 137*9f206f73SBryan Tan PVRDMA_NETWORK_IB, 138*9f206f73SBryan Tan PVRDMA_NETWORK_ROCE_V1 = PVRDMA_NETWORK_IB, 139*9f206f73SBryan Tan PVRDMA_NETWORK_IPV4, 140*9f206f73SBryan Tan PVRDMA_NETWORK_IPV6 141*9f206f73SBryan Tan }; 142*9f206f73SBryan Tan 14329c8d9ebSAdit Ranadive struct pvrdma_alloc_ucontext_resp { 14429c8d9ebSAdit Ranadive __u32 qp_tab_size; 14529c8d9ebSAdit Ranadive __u32 reserved; 14629c8d9ebSAdit Ranadive }; 14729c8d9ebSAdit Ranadive 14829c8d9ebSAdit Ranadive struct pvrdma_alloc_pd_resp { 14929c8d9ebSAdit Ranadive __u32 pdn; 15029c8d9ebSAdit Ranadive __u32 reserved; 15129c8d9ebSAdit Ranadive }; 15229c8d9ebSAdit Ranadive 15329c8d9ebSAdit Ranadive struct pvrdma_create_cq { 15426b99066SJason Gunthorpe __aligned_u64 buf_addr; 15529c8d9ebSAdit Ranadive __u32 buf_size; 15629c8d9ebSAdit Ranadive __u32 reserved; 15729c8d9ebSAdit Ranadive }; 15829c8d9ebSAdit Ranadive 15929c8d9ebSAdit Ranadive struct pvrdma_create_cq_resp { 16029c8d9ebSAdit Ranadive __u32 cqn; 16129c8d9ebSAdit Ranadive __u32 reserved; 16229c8d9ebSAdit Ranadive }; 16329c8d9ebSAdit Ranadive 16429c8d9ebSAdit Ranadive struct pvrdma_resize_cq { 16526b99066SJason Gunthorpe __aligned_u64 buf_addr; 16629c8d9ebSAdit Ranadive __u32 buf_size; 16729c8d9ebSAdit Ranadive __u32 reserved; 16829c8d9ebSAdit Ranadive }; 16929c8d9ebSAdit Ranadive 17029c8d9ebSAdit Ranadive struct pvrdma_create_srq { 17126b99066SJason Gunthorpe __aligned_u64 buf_addr; 1728b10ba78SBryan Tan __u32 buf_size; 1738b10ba78SBryan Tan __u32 reserved; 17429c8d9ebSAdit Ranadive }; 17529c8d9ebSAdit Ranadive 17629c8d9ebSAdit Ranadive struct pvrdma_create_srq_resp { 17729c8d9ebSAdit Ranadive __u32 srqn; 17829c8d9ebSAdit Ranadive __u32 reserved; 17929c8d9ebSAdit Ranadive }; 18029c8d9ebSAdit Ranadive 18129c8d9ebSAdit Ranadive struct pvrdma_create_qp { 18226b99066SJason Gunthorpe __aligned_u64 rbuf_addr; 18326b99066SJason Gunthorpe __aligned_u64 sbuf_addr; 18429c8d9ebSAdit Ranadive __u32 rbuf_size; 18529c8d9ebSAdit Ranadive __u32 sbuf_size; 18626b99066SJason Gunthorpe __aligned_u64 qp_addr; 18729c8d9ebSAdit Ranadive }; 18829c8d9ebSAdit Ranadive 189a52dc3a1SBryan Tan struct pvrdma_create_qp_resp { 190a52dc3a1SBryan Tan __u32 qpn; 191a52dc3a1SBryan Tan __u32 qp_handle; 192a52dc3a1SBryan Tan }; 193a52dc3a1SBryan Tan 19429c8d9ebSAdit Ranadive /* PVRDMA masked atomic compare and swap */ 19529c8d9ebSAdit Ranadive struct pvrdma_ex_cmp_swap { 19626b99066SJason Gunthorpe __aligned_u64 swap_val; 19726b99066SJason Gunthorpe __aligned_u64 compare_val; 19826b99066SJason Gunthorpe __aligned_u64 swap_mask; 19926b99066SJason Gunthorpe __aligned_u64 compare_mask; 20029c8d9ebSAdit Ranadive }; 20129c8d9ebSAdit Ranadive 20229c8d9ebSAdit Ranadive /* PVRDMA masked atomic fetch and add */ 20329c8d9ebSAdit Ranadive struct pvrdma_ex_fetch_add { 20426b99066SJason Gunthorpe __aligned_u64 add_val; 20526b99066SJason Gunthorpe __aligned_u64 field_boundary; 20629c8d9ebSAdit Ranadive }; 20729c8d9ebSAdit Ranadive 20829c8d9ebSAdit Ranadive /* PVRDMA address vector. */ 20929c8d9ebSAdit Ranadive struct pvrdma_av { 21029c8d9ebSAdit Ranadive __u32 port_pd; 21129c8d9ebSAdit Ranadive __u32 sl_tclass_flowlabel; 21229c8d9ebSAdit Ranadive __u8 dgid[16]; 21329c8d9ebSAdit Ranadive __u8 src_path_bits; 21429c8d9ebSAdit Ranadive __u8 gid_index; 21529c8d9ebSAdit Ranadive __u8 stat_rate; 21629c8d9ebSAdit Ranadive __u8 hop_limit; 21729c8d9ebSAdit Ranadive __u8 dmac[6]; 21829c8d9ebSAdit Ranadive __u8 reserved[6]; 21929c8d9ebSAdit Ranadive }; 22029c8d9ebSAdit Ranadive 22129c8d9ebSAdit Ranadive /* PVRDMA scatter/gather entry */ 22229c8d9ebSAdit Ranadive struct pvrdma_sge { 22326b99066SJason Gunthorpe __aligned_u64 addr; 22429c8d9ebSAdit Ranadive __u32 length; 22529c8d9ebSAdit Ranadive __u32 lkey; 22629c8d9ebSAdit Ranadive }; 22729c8d9ebSAdit Ranadive 22829c8d9ebSAdit Ranadive /* PVRDMA receive queue work request */ 22929c8d9ebSAdit Ranadive struct pvrdma_rq_wqe_hdr { 23026b99066SJason Gunthorpe __aligned_u64 wr_id; /* wr id */ 23129c8d9ebSAdit Ranadive __u32 num_sge; /* size of s/g array */ 23229c8d9ebSAdit Ranadive __u32 total_len; /* reserved */ 23329c8d9ebSAdit Ranadive }; 23429c8d9ebSAdit Ranadive /* Use pvrdma_sge (ib_sge) for receive queue s/g array elements. */ 23529c8d9ebSAdit Ranadive 23629c8d9ebSAdit Ranadive /* PVRDMA send queue work request */ 23729c8d9ebSAdit Ranadive struct pvrdma_sq_wqe_hdr { 23826b99066SJason Gunthorpe __aligned_u64 wr_id; /* wr id */ 23929c8d9ebSAdit Ranadive __u32 num_sge; /* size of s/g array */ 24029c8d9ebSAdit Ranadive __u32 total_len; /* reserved */ 24129c8d9ebSAdit Ranadive __u32 opcode; /* operation type */ 24229c8d9ebSAdit Ranadive __u32 send_flags; /* wr flags */ 24329c8d9ebSAdit Ranadive union { 244cc47dd68SJason Gunthorpe __be32 imm_data; 24529c8d9ebSAdit Ranadive __u32 invalidate_rkey; 24629c8d9ebSAdit Ranadive } ex; 24729c8d9ebSAdit Ranadive __u32 reserved; 24829c8d9ebSAdit Ranadive union { 24929c8d9ebSAdit Ranadive struct { 25026b99066SJason Gunthorpe __aligned_u64 remote_addr; 25129c8d9ebSAdit Ranadive __u32 rkey; 25229c8d9ebSAdit Ranadive __u8 reserved[4]; 25329c8d9ebSAdit Ranadive } rdma; 25429c8d9ebSAdit Ranadive struct { 25526b99066SJason Gunthorpe __aligned_u64 remote_addr; 25626b99066SJason Gunthorpe __aligned_u64 compare_add; 25726b99066SJason Gunthorpe __aligned_u64 swap; 25829c8d9ebSAdit Ranadive __u32 rkey; 25929c8d9ebSAdit Ranadive __u32 reserved; 26029c8d9ebSAdit Ranadive } atomic; 26129c8d9ebSAdit Ranadive struct { 26226b99066SJason Gunthorpe __aligned_u64 remote_addr; 26329c8d9ebSAdit Ranadive __u32 log_arg_sz; 26429c8d9ebSAdit Ranadive __u32 rkey; 26529c8d9ebSAdit Ranadive union { 26629c8d9ebSAdit Ranadive struct pvrdma_ex_cmp_swap cmp_swap; 26729c8d9ebSAdit Ranadive struct pvrdma_ex_fetch_add fetch_add; 26829c8d9ebSAdit Ranadive } wr_data; 26929c8d9ebSAdit Ranadive } masked_atomics; 27029c8d9ebSAdit Ranadive struct { 27126b99066SJason Gunthorpe __aligned_u64 iova_start; 27226b99066SJason Gunthorpe __aligned_u64 pl_pdir_dma; 27329c8d9ebSAdit Ranadive __u32 page_shift; 27429c8d9ebSAdit Ranadive __u32 page_list_len; 27529c8d9ebSAdit Ranadive __u32 length; 27629c8d9ebSAdit Ranadive __u32 access_flags; 27729c8d9ebSAdit Ranadive __u32 rkey; 27838b48808SJason Gunthorpe __u32 reserved; 27929c8d9ebSAdit Ranadive } fast_reg; 28029c8d9ebSAdit Ranadive struct { 28129c8d9ebSAdit Ranadive __u32 remote_qpn; 28229c8d9ebSAdit Ranadive __u32 remote_qkey; 28329c8d9ebSAdit Ranadive struct pvrdma_av av; 28429c8d9ebSAdit Ranadive } ud; 28529c8d9ebSAdit Ranadive } wr; 28629c8d9ebSAdit Ranadive }; 28729c8d9ebSAdit Ranadive /* Use pvrdma_sge (ib_sge) for send queue s/g array elements. */ 28829c8d9ebSAdit Ranadive 28929c8d9ebSAdit Ranadive /* Completion queue element. */ 29029c8d9ebSAdit Ranadive struct pvrdma_cqe { 29126b99066SJason Gunthorpe __aligned_u64 wr_id; 29226b99066SJason Gunthorpe __aligned_u64 qp; 29329c8d9ebSAdit Ranadive __u32 opcode; 29429c8d9ebSAdit Ranadive __u32 status; 29529c8d9ebSAdit Ranadive __u32 byte_len; 296cc47dd68SJason Gunthorpe __be32 imm_data; 29729c8d9ebSAdit Ranadive __u32 src_qp; 29829c8d9ebSAdit Ranadive __u32 wc_flags; 29929c8d9ebSAdit Ranadive __u32 vendor_err; 30029c8d9ebSAdit Ranadive __u16 pkey_index; 30129c8d9ebSAdit Ranadive __u16 slid; 30229c8d9ebSAdit Ranadive __u8 sl; 30329c8d9ebSAdit Ranadive __u8 dlid_path_bits; 30429c8d9ebSAdit Ranadive __u8 port_num; 30529c8d9ebSAdit Ranadive __u8 smac[6]; 30672f9b089SAditya Sarwade __u8 network_hdr_type; 30772f9b089SAditya Sarwade __u8 reserved2[6]; /* Pad to next power of 2 (64). */ 30829c8d9ebSAdit Ranadive }; 30929c8d9ebSAdit Ranadive 31029c8d9ebSAdit Ranadive #endif /* __VMW_PVRDMA_ABI_H__ */ 311