xref: /linux/include/uapi/rdma/vmw_pvrdma-abi.h (revision 72f9b089ecd2cc2194d27cbb14fd80a0b1472e89)
129c8d9ebSAdit Ranadive /*
229c8d9ebSAdit Ranadive  * Copyright (c) 2012-2016 VMware, Inc.  All rights reserved.
329c8d9ebSAdit Ranadive  *
429c8d9ebSAdit Ranadive  * This program is free software; you can redistribute it and/or
529c8d9ebSAdit Ranadive  * modify it under the terms of EITHER the GNU General Public License
629c8d9ebSAdit Ranadive  * version 2 as published by the Free Software Foundation or the BSD
729c8d9ebSAdit Ranadive  * 2-Clause License. This program is distributed in the hope that it
829c8d9ebSAdit Ranadive  * will be useful, but WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED
929c8d9ebSAdit Ranadive  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
1029c8d9ebSAdit Ranadive  * See the GNU General Public License version 2 for more details at
1129c8d9ebSAdit Ranadive  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html.
1229c8d9ebSAdit Ranadive  *
1329c8d9ebSAdit Ranadive  * You should have received a copy of the GNU General Public License
1429c8d9ebSAdit Ranadive  * along with this program available in the file COPYING in the main
1529c8d9ebSAdit Ranadive  * directory of this source tree.
1629c8d9ebSAdit Ranadive  *
1729c8d9ebSAdit Ranadive  * The BSD 2-Clause License
1829c8d9ebSAdit Ranadive  *
1929c8d9ebSAdit Ranadive  *     Redistribution and use in source and binary forms, with or
2029c8d9ebSAdit Ranadive  *     without modification, are permitted provided that the following
2129c8d9ebSAdit Ranadive  *     conditions are met:
2229c8d9ebSAdit Ranadive  *
2329c8d9ebSAdit Ranadive  *      - Redistributions of source code must retain the above
2429c8d9ebSAdit Ranadive  *        copyright notice, this list of conditions and the following
2529c8d9ebSAdit Ranadive  *        disclaimer.
2629c8d9ebSAdit Ranadive  *
2729c8d9ebSAdit Ranadive  *      - Redistributions in binary form must reproduce the above
2829c8d9ebSAdit Ranadive  *        copyright notice, this list of conditions and the following
2929c8d9ebSAdit Ranadive  *        disclaimer in the documentation and/or other materials
3029c8d9ebSAdit Ranadive  *        provided with the distribution.
3129c8d9ebSAdit Ranadive  *
3229c8d9ebSAdit Ranadive  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3329c8d9ebSAdit Ranadive  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3429c8d9ebSAdit Ranadive  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
3529c8d9ebSAdit Ranadive  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
3629c8d9ebSAdit Ranadive  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
3729c8d9ebSAdit Ranadive  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
3829c8d9ebSAdit Ranadive  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
3929c8d9ebSAdit Ranadive  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4029c8d9ebSAdit Ranadive  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
4129c8d9ebSAdit Ranadive  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
4229c8d9ebSAdit Ranadive  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
4329c8d9ebSAdit Ranadive  * OF THE POSSIBILITY OF SUCH DAMAGE.
4429c8d9ebSAdit Ranadive  */
4529c8d9ebSAdit Ranadive 
4629c8d9ebSAdit Ranadive #ifndef __VMW_PVRDMA_ABI_H__
4729c8d9ebSAdit Ranadive #define __VMW_PVRDMA_ABI_H__
4829c8d9ebSAdit Ranadive 
4929c8d9ebSAdit Ranadive #include <linux/types.h>
5029c8d9ebSAdit Ranadive 
5129c8d9ebSAdit Ranadive #define PVRDMA_UVERBS_ABI_VERSION	3		/* ABI Version. */
5229c8d9ebSAdit Ranadive #define PVRDMA_UAR_HANDLE_MASK		0x00FFFFFF	/* Bottom 24 bits. */
5329c8d9ebSAdit Ranadive #define PVRDMA_UAR_QP_OFFSET		0		/* QP doorbell. */
5429c8d9ebSAdit Ranadive #define PVRDMA_UAR_QP_SEND		BIT(30)		/* Send bit. */
5529c8d9ebSAdit Ranadive #define PVRDMA_UAR_QP_RECV		BIT(31)		/* Recv bit. */
5629c8d9ebSAdit Ranadive #define PVRDMA_UAR_CQ_OFFSET		4		/* CQ doorbell. */
5729c8d9ebSAdit Ranadive #define PVRDMA_UAR_CQ_ARM_SOL		BIT(29)		/* Arm solicited bit. */
5829c8d9ebSAdit Ranadive #define PVRDMA_UAR_CQ_ARM		BIT(30)		/* Arm bit. */
5929c8d9ebSAdit Ranadive #define PVRDMA_UAR_CQ_POLL		BIT(31)		/* Poll bit. */
6029c8d9ebSAdit Ranadive 
6129c8d9ebSAdit Ranadive enum pvrdma_wr_opcode {
6229c8d9ebSAdit Ranadive 	PVRDMA_WR_RDMA_WRITE,
6329c8d9ebSAdit Ranadive 	PVRDMA_WR_RDMA_WRITE_WITH_IMM,
6429c8d9ebSAdit Ranadive 	PVRDMA_WR_SEND,
6529c8d9ebSAdit Ranadive 	PVRDMA_WR_SEND_WITH_IMM,
6629c8d9ebSAdit Ranadive 	PVRDMA_WR_RDMA_READ,
6729c8d9ebSAdit Ranadive 	PVRDMA_WR_ATOMIC_CMP_AND_SWP,
6829c8d9ebSAdit Ranadive 	PVRDMA_WR_ATOMIC_FETCH_AND_ADD,
6929c8d9ebSAdit Ranadive 	PVRDMA_WR_LSO,
7029c8d9ebSAdit Ranadive 	PVRDMA_WR_SEND_WITH_INV,
7129c8d9ebSAdit Ranadive 	PVRDMA_WR_RDMA_READ_WITH_INV,
7229c8d9ebSAdit Ranadive 	PVRDMA_WR_LOCAL_INV,
7329c8d9ebSAdit Ranadive 	PVRDMA_WR_FAST_REG_MR,
7429c8d9ebSAdit Ranadive 	PVRDMA_WR_MASKED_ATOMIC_CMP_AND_SWP,
7529c8d9ebSAdit Ranadive 	PVRDMA_WR_MASKED_ATOMIC_FETCH_AND_ADD,
7629c8d9ebSAdit Ranadive 	PVRDMA_WR_BIND_MW,
7729c8d9ebSAdit Ranadive 	PVRDMA_WR_REG_SIG_MR,
7829c8d9ebSAdit Ranadive };
7929c8d9ebSAdit Ranadive 
8029c8d9ebSAdit Ranadive enum pvrdma_wc_status {
8129c8d9ebSAdit Ranadive 	PVRDMA_WC_SUCCESS,
8229c8d9ebSAdit Ranadive 	PVRDMA_WC_LOC_LEN_ERR,
8329c8d9ebSAdit Ranadive 	PVRDMA_WC_LOC_QP_OP_ERR,
8429c8d9ebSAdit Ranadive 	PVRDMA_WC_LOC_EEC_OP_ERR,
8529c8d9ebSAdit Ranadive 	PVRDMA_WC_LOC_PROT_ERR,
8629c8d9ebSAdit Ranadive 	PVRDMA_WC_WR_FLUSH_ERR,
8729c8d9ebSAdit Ranadive 	PVRDMA_WC_MW_BIND_ERR,
8829c8d9ebSAdit Ranadive 	PVRDMA_WC_BAD_RESP_ERR,
8929c8d9ebSAdit Ranadive 	PVRDMA_WC_LOC_ACCESS_ERR,
9029c8d9ebSAdit Ranadive 	PVRDMA_WC_REM_INV_REQ_ERR,
9129c8d9ebSAdit Ranadive 	PVRDMA_WC_REM_ACCESS_ERR,
9229c8d9ebSAdit Ranadive 	PVRDMA_WC_REM_OP_ERR,
9329c8d9ebSAdit Ranadive 	PVRDMA_WC_RETRY_EXC_ERR,
9429c8d9ebSAdit Ranadive 	PVRDMA_WC_RNR_RETRY_EXC_ERR,
9529c8d9ebSAdit Ranadive 	PVRDMA_WC_LOC_RDD_VIOL_ERR,
9629c8d9ebSAdit Ranadive 	PVRDMA_WC_REM_INV_RD_REQ_ERR,
9729c8d9ebSAdit Ranadive 	PVRDMA_WC_REM_ABORT_ERR,
9829c8d9ebSAdit Ranadive 	PVRDMA_WC_INV_EECN_ERR,
9929c8d9ebSAdit Ranadive 	PVRDMA_WC_INV_EEC_STATE_ERR,
10029c8d9ebSAdit Ranadive 	PVRDMA_WC_FATAL_ERR,
10129c8d9ebSAdit Ranadive 	PVRDMA_WC_RESP_TIMEOUT_ERR,
10229c8d9ebSAdit Ranadive 	PVRDMA_WC_GENERAL_ERR,
10329c8d9ebSAdit Ranadive };
10429c8d9ebSAdit Ranadive 
10529c8d9ebSAdit Ranadive enum pvrdma_wc_opcode {
10629c8d9ebSAdit Ranadive 	PVRDMA_WC_SEND,
10729c8d9ebSAdit Ranadive 	PVRDMA_WC_RDMA_WRITE,
10829c8d9ebSAdit Ranadive 	PVRDMA_WC_RDMA_READ,
10929c8d9ebSAdit Ranadive 	PVRDMA_WC_COMP_SWAP,
11029c8d9ebSAdit Ranadive 	PVRDMA_WC_FETCH_ADD,
11129c8d9ebSAdit Ranadive 	PVRDMA_WC_BIND_MW,
11229c8d9ebSAdit Ranadive 	PVRDMA_WC_LSO,
11329c8d9ebSAdit Ranadive 	PVRDMA_WC_LOCAL_INV,
11429c8d9ebSAdit Ranadive 	PVRDMA_WC_FAST_REG_MR,
11529c8d9ebSAdit Ranadive 	PVRDMA_WC_MASKED_COMP_SWAP,
11629c8d9ebSAdit Ranadive 	PVRDMA_WC_MASKED_FETCH_ADD,
11729c8d9ebSAdit Ranadive 	PVRDMA_WC_RECV = 1 << 7,
11829c8d9ebSAdit Ranadive 	PVRDMA_WC_RECV_RDMA_WITH_IMM,
11929c8d9ebSAdit Ranadive };
12029c8d9ebSAdit Ranadive 
12129c8d9ebSAdit Ranadive enum pvrdma_wc_flags {
12229c8d9ebSAdit Ranadive 	PVRDMA_WC_GRH			= 1 << 0,
12329c8d9ebSAdit Ranadive 	PVRDMA_WC_WITH_IMM		= 1 << 1,
12429c8d9ebSAdit Ranadive 	PVRDMA_WC_WITH_INVALIDATE	= 1 << 2,
12529c8d9ebSAdit Ranadive 	PVRDMA_WC_IP_CSUM_OK		= 1 << 3,
12629c8d9ebSAdit Ranadive 	PVRDMA_WC_WITH_SMAC		= 1 << 4,
12729c8d9ebSAdit Ranadive 	PVRDMA_WC_WITH_VLAN		= 1 << 5,
128*72f9b089SAditya Sarwade 	PVRDMA_WC_WITH_NETWORK_HDR_TYPE	= 1 << 6,
129*72f9b089SAditya Sarwade 	PVRDMA_WC_FLAGS_MAX		= PVRDMA_WC_WITH_NETWORK_HDR_TYPE,
13029c8d9ebSAdit Ranadive };
13129c8d9ebSAdit Ranadive 
13229c8d9ebSAdit Ranadive struct pvrdma_alloc_ucontext_resp {
13329c8d9ebSAdit Ranadive 	__u32 qp_tab_size;
13429c8d9ebSAdit Ranadive 	__u32 reserved;
13529c8d9ebSAdit Ranadive };
13629c8d9ebSAdit Ranadive 
13729c8d9ebSAdit Ranadive struct pvrdma_alloc_pd_resp {
13829c8d9ebSAdit Ranadive 	__u32 pdn;
13929c8d9ebSAdit Ranadive 	__u32 reserved;
14029c8d9ebSAdit Ranadive };
14129c8d9ebSAdit Ranadive 
14229c8d9ebSAdit Ranadive struct pvrdma_create_cq {
14329c8d9ebSAdit Ranadive 	__u64 buf_addr;
14429c8d9ebSAdit Ranadive 	__u32 buf_size;
14529c8d9ebSAdit Ranadive 	__u32 reserved;
14629c8d9ebSAdit Ranadive };
14729c8d9ebSAdit Ranadive 
14829c8d9ebSAdit Ranadive struct pvrdma_create_cq_resp {
14929c8d9ebSAdit Ranadive 	__u32 cqn;
15029c8d9ebSAdit Ranadive 	__u32 reserved;
15129c8d9ebSAdit Ranadive };
15229c8d9ebSAdit Ranadive 
15329c8d9ebSAdit Ranadive struct pvrdma_resize_cq {
15429c8d9ebSAdit Ranadive 	__u64 buf_addr;
15529c8d9ebSAdit Ranadive 	__u32 buf_size;
15629c8d9ebSAdit Ranadive 	__u32 reserved;
15729c8d9ebSAdit Ranadive };
15829c8d9ebSAdit Ranadive 
15929c8d9ebSAdit Ranadive struct pvrdma_create_srq {
16029c8d9ebSAdit Ranadive 	__u64 buf_addr;
16129c8d9ebSAdit Ranadive };
16229c8d9ebSAdit Ranadive 
16329c8d9ebSAdit Ranadive struct pvrdma_create_srq_resp {
16429c8d9ebSAdit Ranadive 	__u32 srqn;
16529c8d9ebSAdit Ranadive 	__u32 reserved;
16629c8d9ebSAdit Ranadive };
16729c8d9ebSAdit Ranadive 
16829c8d9ebSAdit Ranadive struct pvrdma_create_qp {
16929c8d9ebSAdit Ranadive 	__u64 rbuf_addr;
17029c8d9ebSAdit Ranadive 	__u64 sbuf_addr;
17129c8d9ebSAdit Ranadive 	__u32 rbuf_size;
17229c8d9ebSAdit Ranadive 	__u32 sbuf_size;
17329c8d9ebSAdit Ranadive 	__u64 qp_addr;
17429c8d9ebSAdit Ranadive };
17529c8d9ebSAdit Ranadive 
17629c8d9ebSAdit Ranadive /* PVRDMA masked atomic compare and swap */
17729c8d9ebSAdit Ranadive struct pvrdma_ex_cmp_swap {
17829c8d9ebSAdit Ranadive 	__u64 swap_val;
17929c8d9ebSAdit Ranadive 	__u64 compare_val;
18029c8d9ebSAdit Ranadive 	__u64 swap_mask;
18129c8d9ebSAdit Ranadive 	__u64 compare_mask;
18229c8d9ebSAdit Ranadive };
18329c8d9ebSAdit Ranadive 
18429c8d9ebSAdit Ranadive /* PVRDMA masked atomic fetch and add */
18529c8d9ebSAdit Ranadive struct pvrdma_ex_fetch_add {
18629c8d9ebSAdit Ranadive 	__u64 add_val;
18729c8d9ebSAdit Ranadive 	__u64 field_boundary;
18829c8d9ebSAdit Ranadive };
18929c8d9ebSAdit Ranadive 
19029c8d9ebSAdit Ranadive /* PVRDMA address vector. */
19129c8d9ebSAdit Ranadive struct pvrdma_av {
19229c8d9ebSAdit Ranadive 	__u32 port_pd;
19329c8d9ebSAdit Ranadive 	__u32 sl_tclass_flowlabel;
19429c8d9ebSAdit Ranadive 	__u8 dgid[16];
19529c8d9ebSAdit Ranadive 	__u8 src_path_bits;
19629c8d9ebSAdit Ranadive 	__u8 gid_index;
19729c8d9ebSAdit Ranadive 	__u8 stat_rate;
19829c8d9ebSAdit Ranadive 	__u8 hop_limit;
19929c8d9ebSAdit Ranadive 	__u8 dmac[6];
20029c8d9ebSAdit Ranadive 	__u8 reserved[6];
20129c8d9ebSAdit Ranadive };
20229c8d9ebSAdit Ranadive 
20329c8d9ebSAdit Ranadive /* PVRDMA scatter/gather entry */
20429c8d9ebSAdit Ranadive struct pvrdma_sge {
20529c8d9ebSAdit Ranadive 	__u64   addr;
20629c8d9ebSAdit Ranadive 	__u32   length;
20729c8d9ebSAdit Ranadive 	__u32   lkey;
20829c8d9ebSAdit Ranadive };
20929c8d9ebSAdit Ranadive 
21029c8d9ebSAdit Ranadive /* PVRDMA receive queue work request */
21129c8d9ebSAdit Ranadive struct pvrdma_rq_wqe_hdr {
21229c8d9ebSAdit Ranadive 	__u64 wr_id;		/* wr id */
21329c8d9ebSAdit Ranadive 	__u32 num_sge;		/* size of s/g array */
21429c8d9ebSAdit Ranadive 	__u32 total_len;	/* reserved */
21529c8d9ebSAdit Ranadive };
21629c8d9ebSAdit Ranadive /* Use pvrdma_sge (ib_sge) for receive queue s/g array elements. */
21729c8d9ebSAdit Ranadive 
21829c8d9ebSAdit Ranadive /* PVRDMA send queue work request */
21929c8d9ebSAdit Ranadive struct pvrdma_sq_wqe_hdr {
22029c8d9ebSAdit Ranadive 	__u64 wr_id;		/* wr id */
22129c8d9ebSAdit Ranadive 	__u32 num_sge;		/* size of s/g array */
22229c8d9ebSAdit Ranadive 	__u32 total_len;	/* reserved */
22329c8d9ebSAdit Ranadive 	__u32 opcode;		/* operation type */
22429c8d9ebSAdit Ranadive 	__u32 send_flags;	/* wr flags */
22529c8d9ebSAdit Ranadive 	union {
226cc47dd68SJason Gunthorpe 		__be32 imm_data;
22729c8d9ebSAdit Ranadive 		__u32 invalidate_rkey;
22829c8d9ebSAdit Ranadive 	} ex;
22929c8d9ebSAdit Ranadive 	__u32 reserved;
23029c8d9ebSAdit Ranadive 	union {
23129c8d9ebSAdit Ranadive 		struct {
23229c8d9ebSAdit Ranadive 			__u64 remote_addr;
23329c8d9ebSAdit Ranadive 			__u32 rkey;
23429c8d9ebSAdit Ranadive 			__u8 reserved[4];
23529c8d9ebSAdit Ranadive 		} rdma;
23629c8d9ebSAdit Ranadive 		struct {
23729c8d9ebSAdit Ranadive 			__u64 remote_addr;
23829c8d9ebSAdit Ranadive 			__u64 compare_add;
23929c8d9ebSAdit Ranadive 			__u64 swap;
24029c8d9ebSAdit Ranadive 			__u32 rkey;
24129c8d9ebSAdit Ranadive 			__u32 reserved;
24229c8d9ebSAdit Ranadive 		} atomic;
24329c8d9ebSAdit Ranadive 		struct {
24429c8d9ebSAdit Ranadive 			__u64 remote_addr;
24529c8d9ebSAdit Ranadive 			__u32 log_arg_sz;
24629c8d9ebSAdit Ranadive 			__u32 rkey;
24729c8d9ebSAdit Ranadive 			union {
24829c8d9ebSAdit Ranadive 				struct pvrdma_ex_cmp_swap  cmp_swap;
24929c8d9ebSAdit Ranadive 				struct pvrdma_ex_fetch_add fetch_add;
25029c8d9ebSAdit Ranadive 			} wr_data;
25129c8d9ebSAdit Ranadive 		} masked_atomics;
25229c8d9ebSAdit Ranadive 		struct {
25329c8d9ebSAdit Ranadive 			__u64 iova_start;
25429c8d9ebSAdit Ranadive 			__u64 pl_pdir_dma;
25529c8d9ebSAdit Ranadive 			__u32 page_shift;
25629c8d9ebSAdit Ranadive 			__u32 page_list_len;
25729c8d9ebSAdit Ranadive 			__u32 length;
25829c8d9ebSAdit Ranadive 			__u32 access_flags;
25929c8d9ebSAdit Ranadive 			__u32 rkey;
26029c8d9ebSAdit Ranadive 		} fast_reg;
26129c8d9ebSAdit Ranadive 		struct {
26229c8d9ebSAdit Ranadive 			__u32 remote_qpn;
26329c8d9ebSAdit Ranadive 			__u32 remote_qkey;
26429c8d9ebSAdit Ranadive 			struct pvrdma_av av;
26529c8d9ebSAdit Ranadive 		} ud;
26629c8d9ebSAdit Ranadive 	} wr;
26729c8d9ebSAdit Ranadive };
26829c8d9ebSAdit Ranadive /* Use pvrdma_sge (ib_sge) for send queue s/g array elements. */
26929c8d9ebSAdit Ranadive 
27029c8d9ebSAdit Ranadive /* Completion queue element. */
27129c8d9ebSAdit Ranadive struct pvrdma_cqe {
27229c8d9ebSAdit Ranadive 	__u64 wr_id;
27329c8d9ebSAdit Ranadive 	__u64 qp;
27429c8d9ebSAdit Ranadive 	__u32 opcode;
27529c8d9ebSAdit Ranadive 	__u32 status;
27629c8d9ebSAdit Ranadive 	__u32 byte_len;
277cc47dd68SJason Gunthorpe 	__be32 imm_data;
27829c8d9ebSAdit Ranadive 	__u32 src_qp;
27929c8d9ebSAdit Ranadive 	__u32 wc_flags;
28029c8d9ebSAdit Ranadive 	__u32 vendor_err;
28129c8d9ebSAdit Ranadive 	__u16 pkey_index;
28229c8d9ebSAdit Ranadive 	__u16 slid;
28329c8d9ebSAdit Ranadive 	__u8 sl;
28429c8d9ebSAdit Ranadive 	__u8 dlid_path_bits;
28529c8d9ebSAdit Ranadive 	__u8 port_num;
28629c8d9ebSAdit Ranadive 	__u8 smac[6];
287*72f9b089SAditya Sarwade 	__u8 network_hdr_type;
288*72f9b089SAditya Sarwade 	__u8 reserved2[6]; /* Pad to next power of 2 (64). */
28929c8d9ebSAdit Ranadive };
29029c8d9ebSAdit Ranadive 
29129c8d9ebSAdit Ranadive #endif /* __VMW_PVRDMA_ABI_H__ */
292