1*e2be04c7SGreg 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. */ 5529c8d9ebSAdit Ranadive #define PVRDMA_UAR_QP_SEND BIT(30) /* Send bit. */ 5629c8d9ebSAdit Ranadive #define PVRDMA_UAR_QP_RECV BIT(31) /* Recv bit. */ 5729c8d9ebSAdit Ranadive #define PVRDMA_UAR_CQ_OFFSET 4 /* CQ doorbell. */ 5829c8d9ebSAdit Ranadive #define PVRDMA_UAR_CQ_ARM_SOL BIT(29) /* Arm solicited bit. */ 5929c8d9ebSAdit Ranadive #define PVRDMA_UAR_CQ_ARM BIT(30) /* Arm bit. */ 6029c8d9ebSAdit Ranadive #define PVRDMA_UAR_CQ_POLL BIT(31) /* Poll bit. */ 6129c8d9ebSAdit Ranadive 6229c8d9ebSAdit Ranadive enum pvrdma_wr_opcode { 6329c8d9ebSAdit Ranadive PVRDMA_WR_RDMA_WRITE, 6429c8d9ebSAdit Ranadive PVRDMA_WR_RDMA_WRITE_WITH_IMM, 6529c8d9ebSAdit Ranadive PVRDMA_WR_SEND, 6629c8d9ebSAdit Ranadive PVRDMA_WR_SEND_WITH_IMM, 6729c8d9ebSAdit Ranadive PVRDMA_WR_RDMA_READ, 6829c8d9ebSAdit Ranadive PVRDMA_WR_ATOMIC_CMP_AND_SWP, 6929c8d9ebSAdit Ranadive PVRDMA_WR_ATOMIC_FETCH_AND_ADD, 7029c8d9ebSAdit Ranadive PVRDMA_WR_LSO, 7129c8d9ebSAdit Ranadive PVRDMA_WR_SEND_WITH_INV, 7229c8d9ebSAdit Ranadive PVRDMA_WR_RDMA_READ_WITH_INV, 7329c8d9ebSAdit Ranadive PVRDMA_WR_LOCAL_INV, 7429c8d9ebSAdit Ranadive PVRDMA_WR_FAST_REG_MR, 7529c8d9ebSAdit Ranadive PVRDMA_WR_MASKED_ATOMIC_CMP_AND_SWP, 7629c8d9ebSAdit Ranadive PVRDMA_WR_MASKED_ATOMIC_FETCH_AND_ADD, 7729c8d9ebSAdit Ranadive PVRDMA_WR_BIND_MW, 7829c8d9ebSAdit Ranadive PVRDMA_WR_REG_SIG_MR, 7929c8d9ebSAdit Ranadive }; 8029c8d9ebSAdit Ranadive 8129c8d9ebSAdit Ranadive enum pvrdma_wc_status { 8229c8d9ebSAdit Ranadive PVRDMA_WC_SUCCESS, 8329c8d9ebSAdit Ranadive PVRDMA_WC_LOC_LEN_ERR, 8429c8d9ebSAdit Ranadive PVRDMA_WC_LOC_QP_OP_ERR, 8529c8d9ebSAdit Ranadive PVRDMA_WC_LOC_EEC_OP_ERR, 8629c8d9ebSAdit Ranadive PVRDMA_WC_LOC_PROT_ERR, 8729c8d9ebSAdit Ranadive PVRDMA_WC_WR_FLUSH_ERR, 8829c8d9ebSAdit Ranadive PVRDMA_WC_MW_BIND_ERR, 8929c8d9ebSAdit Ranadive PVRDMA_WC_BAD_RESP_ERR, 9029c8d9ebSAdit Ranadive PVRDMA_WC_LOC_ACCESS_ERR, 9129c8d9ebSAdit Ranadive PVRDMA_WC_REM_INV_REQ_ERR, 9229c8d9ebSAdit Ranadive PVRDMA_WC_REM_ACCESS_ERR, 9329c8d9ebSAdit Ranadive PVRDMA_WC_REM_OP_ERR, 9429c8d9ebSAdit Ranadive PVRDMA_WC_RETRY_EXC_ERR, 9529c8d9ebSAdit Ranadive PVRDMA_WC_RNR_RETRY_EXC_ERR, 9629c8d9ebSAdit Ranadive PVRDMA_WC_LOC_RDD_VIOL_ERR, 9729c8d9ebSAdit Ranadive PVRDMA_WC_REM_INV_RD_REQ_ERR, 9829c8d9ebSAdit Ranadive PVRDMA_WC_REM_ABORT_ERR, 9929c8d9ebSAdit Ranadive PVRDMA_WC_INV_EECN_ERR, 10029c8d9ebSAdit Ranadive PVRDMA_WC_INV_EEC_STATE_ERR, 10129c8d9ebSAdit Ranadive PVRDMA_WC_FATAL_ERR, 10229c8d9ebSAdit Ranadive PVRDMA_WC_RESP_TIMEOUT_ERR, 10329c8d9ebSAdit Ranadive PVRDMA_WC_GENERAL_ERR, 10429c8d9ebSAdit Ranadive }; 10529c8d9ebSAdit Ranadive 10629c8d9ebSAdit Ranadive enum pvrdma_wc_opcode { 10729c8d9ebSAdit Ranadive PVRDMA_WC_SEND, 10829c8d9ebSAdit Ranadive PVRDMA_WC_RDMA_WRITE, 10929c8d9ebSAdit Ranadive PVRDMA_WC_RDMA_READ, 11029c8d9ebSAdit Ranadive PVRDMA_WC_COMP_SWAP, 11129c8d9ebSAdit Ranadive PVRDMA_WC_FETCH_ADD, 11229c8d9ebSAdit Ranadive PVRDMA_WC_BIND_MW, 11329c8d9ebSAdit Ranadive PVRDMA_WC_LSO, 11429c8d9ebSAdit Ranadive PVRDMA_WC_LOCAL_INV, 11529c8d9ebSAdit Ranadive PVRDMA_WC_FAST_REG_MR, 11629c8d9ebSAdit Ranadive PVRDMA_WC_MASKED_COMP_SWAP, 11729c8d9ebSAdit Ranadive PVRDMA_WC_MASKED_FETCH_ADD, 11829c8d9ebSAdit Ranadive PVRDMA_WC_RECV = 1 << 7, 11929c8d9ebSAdit Ranadive PVRDMA_WC_RECV_RDMA_WITH_IMM, 12029c8d9ebSAdit Ranadive }; 12129c8d9ebSAdit Ranadive 12229c8d9ebSAdit Ranadive enum pvrdma_wc_flags { 12329c8d9ebSAdit Ranadive PVRDMA_WC_GRH = 1 << 0, 12429c8d9ebSAdit Ranadive PVRDMA_WC_WITH_IMM = 1 << 1, 12529c8d9ebSAdit Ranadive PVRDMA_WC_WITH_INVALIDATE = 1 << 2, 12629c8d9ebSAdit Ranadive PVRDMA_WC_IP_CSUM_OK = 1 << 3, 12729c8d9ebSAdit Ranadive PVRDMA_WC_WITH_SMAC = 1 << 4, 12829c8d9ebSAdit Ranadive PVRDMA_WC_WITH_VLAN = 1 << 5, 12972f9b089SAditya Sarwade PVRDMA_WC_WITH_NETWORK_HDR_TYPE = 1 << 6, 13072f9b089SAditya Sarwade PVRDMA_WC_FLAGS_MAX = PVRDMA_WC_WITH_NETWORK_HDR_TYPE, 13129c8d9ebSAdit Ranadive }; 13229c8d9ebSAdit Ranadive 13329c8d9ebSAdit Ranadive struct pvrdma_alloc_ucontext_resp { 13429c8d9ebSAdit Ranadive __u32 qp_tab_size; 13529c8d9ebSAdit Ranadive __u32 reserved; 13629c8d9ebSAdit Ranadive }; 13729c8d9ebSAdit Ranadive 13829c8d9ebSAdit Ranadive struct pvrdma_alloc_pd_resp { 13929c8d9ebSAdit Ranadive __u32 pdn; 14029c8d9ebSAdit Ranadive __u32 reserved; 14129c8d9ebSAdit Ranadive }; 14229c8d9ebSAdit Ranadive 14329c8d9ebSAdit Ranadive struct pvrdma_create_cq { 14429c8d9ebSAdit Ranadive __u64 buf_addr; 14529c8d9ebSAdit Ranadive __u32 buf_size; 14629c8d9ebSAdit Ranadive __u32 reserved; 14729c8d9ebSAdit Ranadive }; 14829c8d9ebSAdit Ranadive 14929c8d9ebSAdit Ranadive struct pvrdma_create_cq_resp { 15029c8d9ebSAdit Ranadive __u32 cqn; 15129c8d9ebSAdit Ranadive __u32 reserved; 15229c8d9ebSAdit Ranadive }; 15329c8d9ebSAdit Ranadive 15429c8d9ebSAdit Ranadive struct pvrdma_resize_cq { 15529c8d9ebSAdit Ranadive __u64 buf_addr; 15629c8d9ebSAdit Ranadive __u32 buf_size; 15729c8d9ebSAdit Ranadive __u32 reserved; 15829c8d9ebSAdit Ranadive }; 15929c8d9ebSAdit Ranadive 16029c8d9ebSAdit Ranadive struct pvrdma_create_srq { 16129c8d9ebSAdit Ranadive __u64 buf_addr; 16229c8d9ebSAdit Ranadive }; 16329c8d9ebSAdit Ranadive 16429c8d9ebSAdit Ranadive struct pvrdma_create_srq_resp { 16529c8d9ebSAdit Ranadive __u32 srqn; 16629c8d9ebSAdit Ranadive __u32 reserved; 16729c8d9ebSAdit Ranadive }; 16829c8d9ebSAdit Ranadive 16929c8d9ebSAdit Ranadive struct pvrdma_create_qp { 17029c8d9ebSAdit Ranadive __u64 rbuf_addr; 17129c8d9ebSAdit Ranadive __u64 sbuf_addr; 17229c8d9ebSAdit Ranadive __u32 rbuf_size; 17329c8d9ebSAdit Ranadive __u32 sbuf_size; 17429c8d9ebSAdit Ranadive __u64 qp_addr; 17529c8d9ebSAdit Ranadive }; 17629c8d9ebSAdit Ranadive 17729c8d9ebSAdit Ranadive /* PVRDMA masked atomic compare and swap */ 17829c8d9ebSAdit Ranadive struct pvrdma_ex_cmp_swap { 17929c8d9ebSAdit Ranadive __u64 swap_val; 18029c8d9ebSAdit Ranadive __u64 compare_val; 18129c8d9ebSAdit Ranadive __u64 swap_mask; 18229c8d9ebSAdit Ranadive __u64 compare_mask; 18329c8d9ebSAdit Ranadive }; 18429c8d9ebSAdit Ranadive 18529c8d9ebSAdit Ranadive /* PVRDMA masked atomic fetch and add */ 18629c8d9ebSAdit Ranadive struct pvrdma_ex_fetch_add { 18729c8d9ebSAdit Ranadive __u64 add_val; 18829c8d9ebSAdit Ranadive __u64 field_boundary; 18929c8d9ebSAdit Ranadive }; 19029c8d9ebSAdit Ranadive 19129c8d9ebSAdit Ranadive /* PVRDMA address vector. */ 19229c8d9ebSAdit Ranadive struct pvrdma_av { 19329c8d9ebSAdit Ranadive __u32 port_pd; 19429c8d9ebSAdit Ranadive __u32 sl_tclass_flowlabel; 19529c8d9ebSAdit Ranadive __u8 dgid[16]; 19629c8d9ebSAdit Ranadive __u8 src_path_bits; 19729c8d9ebSAdit Ranadive __u8 gid_index; 19829c8d9ebSAdit Ranadive __u8 stat_rate; 19929c8d9ebSAdit Ranadive __u8 hop_limit; 20029c8d9ebSAdit Ranadive __u8 dmac[6]; 20129c8d9ebSAdit Ranadive __u8 reserved[6]; 20229c8d9ebSAdit Ranadive }; 20329c8d9ebSAdit Ranadive 20429c8d9ebSAdit Ranadive /* PVRDMA scatter/gather entry */ 20529c8d9ebSAdit Ranadive struct pvrdma_sge { 20629c8d9ebSAdit Ranadive __u64 addr; 20729c8d9ebSAdit Ranadive __u32 length; 20829c8d9ebSAdit Ranadive __u32 lkey; 20929c8d9ebSAdit Ranadive }; 21029c8d9ebSAdit Ranadive 21129c8d9ebSAdit Ranadive /* PVRDMA receive queue work request */ 21229c8d9ebSAdit Ranadive struct pvrdma_rq_wqe_hdr { 21329c8d9ebSAdit Ranadive __u64 wr_id; /* wr id */ 21429c8d9ebSAdit Ranadive __u32 num_sge; /* size of s/g array */ 21529c8d9ebSAdit Ranadive __u32 total_len; /* reserved */ 21629c8d9ebSAdit Ranadive }; 21729c8d9ebSAdit Ranadive /* Use pvrdma_sge (ib_sge) for receive queue s/g array elements. */ 21829c8d9ebSAdit Ranadive 21929c8d9ebSAdit Ranadive /* PVRDMA send queue work request */ 22029c8d9ebSAdit Ranadive struct pvrdma_sq_wqe_hdr { 22129c8d9ebSAdit Ranadive __u64 wr_id; /* wr id */ 22229c8d9ebSAdit Ranadive __u32 num_sge; /* size of s/g array */ 22329c8d9ebSAdit Ranadive __u32 total_len; /* reserved */ 22429c8d9ebSAdit Ranadive __u32 opcode; /* operation type */ 22529c8d9ebSAdit Ranadive __u32 send_flags; /* wr flags */ 22629c8d9ebSAdit Ranadive union { 227cc47dd68SJason Gunthorpe __be32 imm_data; 22829c8d9ebSAdit Ranadive __u32 invalidate_rkey; 22929c8d9ebSAdit Ranadive } ex; 23029c8d9ebSAdit Ranadive __u32 reserved; 23129c8d9ebSAdit Ranadive union { 23229c8d9ebSAdit Ranadive struct { 23329c8d9ebSAdit Ranadive __u64 remote_addr; 23429c8d9ebSAdit Ranadive __u32 rkey; 23529c8d9ebSAdit Ranadive __u8 reserved[4]; 23629c8d9ebSAdit Ranadive } rdma; 23729c8d9ebSAdit Ranadive struct { 23829c8d9ebSAdit Ranadive __u64 remote_addr; 23929c8d9ebSAdit Ranadive __u64 compare_add; 24029c8d9ebSAdit Ranadive __u64 swap; 24129c8d9ebSAdit Ranadive __u32 rkey; 24229c8d9ebSAdit Ranadive __u32 reserved; 24329c8d9ebSAdit Ranadive } atomic; 24429c8d9ebSAdit Ranadive struct { 24529c8d9ebSAdit Ranadive __u64 remote_addr; 24629c8d9ebSAdit Ranadive __u32 log_arg_sz; 24729c8d9ebSAdit Ranadive __u32 rkey; 24829c8d9ebSAdit Ranadive union { 24929c8d9ebSAdit Ranadive struct pvrdma_ex_cmp_swap cmp_swap; 25029c8d9ebSAdit Ranadive struct pvrdma_ex_fetch_add fetch_add; 25129c8d9ebSAdit Ranadive } wr_data; 25229c8d9ebSAdit Ranadive } masked_atomics; 25329c8d9ebSAdit Ranadive struct { 25429c8d9ebSAdit Ranadive __u64 iova_start; 25529c8d9ebSAdit Ranadive __u64 pl_pdir_dma; 25629c8d9ebSAdit Ranadive __u32 page_shift; 25729c8d9ebSAdit Ranadive __u32 page_list_len; 25829c8d9ebSAdit Ranadive __u32 length; 25929c8d9ebSAdit Ranadive __u32 access_flags; 26029c8d9ebSAdit Ranadive __u32 rkey; 26129c8d9ebSAdit Ranadive } fast_reg; 26229c8d9ebSAdit Ranadive struct { 26329c8d9ebSAdit Ranadive __u32 remote_qpn; 26429c8d9ebSAdit Ranadive __u32 remote_qkey; 26529c8d9ebSAdit Ranadive struct pvrdma_av av; 26629c8d9ebSAdit Ranadive } ud; 26729c8d9ebSAdit Ranadive } wr; 26829c8d9ebSAdit Ranadive }; 26929c8d9ebSAdit Ranadive /* Use pvrdma_sge (ib_sge) for send queue s/g array elements. */ 27029c8d9ebSAdit Ranadive 27129c8d9ebSAdit Ranadive /* Completion queue element. */ 27229c8d9ebSAdit Ranadive struct pvrdma_cqe { 27329c8d9ebSAdit Ranadive __u64 wr_id; 27429c8d9ebSAdit Ranadive __u64 qp; 27529c8d9ebSAdit Ranadive __u32 opcode; 27629c8d9ebSAdit Ranadive __u32 status; 27729c8d9ebSAdit Ranadive __u32 byte_len; 278cc47dd68SJason Gunthorpe __be32 imm_data; 27929c8d9ebSAdit Ranadive __u32 src_qp; 28029c8d9ebSAdit Ranadive __u32 wc_flags; 28129c8d9ebSAdit Ranadive __u32 vendor_err; 28229c8d9ebSAdit Ranadive __u16 pkey_index; 28329c8d9ebSAdit Ranadive __u16 slid; 28429c8d9ebSAdit Ranadive __u8 sl; 28529c8d9ebSAdit Ranadive __u8 dlid_path_bits; 28629c8d9ebSAdit Ranadive __u8 port_num; 28729c8d9ebSAdit Ranadive __u8 smac[6]; 28872f9b089SAditya Sarwade __u8 network_hdr_type; 28972f9b089SAditya Sarwade __u8 reserved2[6]; /* Pad to next power of 2 (64). */ 29029c8d9ebSAdit Ranadive }; 29129c8d9ebSAdit Ranadive 29229c8d9ebSAdit Ranadive #endif /* __VMW_PVRDMA_ABI_H__ */ 293