18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) or BSD-3-Clause */ 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci/* Authors: Bernard Metzler <bmt@zurich.ibm.com> */ 48c2ecf20Sopenharmony_ci/* Copyright (c) 2008-2019, IBM Corporation */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef _SIW_USER_H 78c2ecf20Sopenharmony_ci#define _SIW_USER_H 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/types.h> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#define SIW_NODE_DESC_COMMON "Software iWARP stack" 128c2ecf20Sopenharmony_ci#define SIW_ABI_VERSION 1 138c2ecf20Sopenharmony_ci#define SIW_MAX_SGE 6 148c2ecf20Sopenharmony_ci#define SIW_UOBJ_MAX_KEY 0x08FFFF 158c2ecf20Sopenharmony_ci#define SIW_INVAL_UOBJ_KEY (SIW_UOBJ_MAX_KEY + 1) 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_cistruct siw_uresp_create_cq { 188c2ecf20Sopenharmony_ci __u32 cq_id; 198c2ecf20Sopenharmony_ci __u32 num_cqe; 208c2ecf20Sopenharmony_ci __aligned_u64 cq_key; 218c2ecf20Sopenharmony_ci}; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_cistruct siw_uresp_create_qp { 248c2ecf20Sopenharmony_ci __u32 qp_id; 258c2ecf20Sopenharmony_ci __u32 num_sqe; 268c2ecf20Sopenharmony_ci __u32 num_rqe; 278c2ecf20Sopenharmony_ci __u32 pad; 288c2ecf20Sopenharmony_ci __aligned_u64 sq_key; 298c2ecf20Sopenharmony_ci __aligned_u64 rq_key; 308c2ecf20Sopenharmony_ci}; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cistruct siw_ureq_reg_mr { 338c2ecf20Sopenharmony_ci __u8 stag_key; 348c2ecf20Sopenharmony_ci __u8 reserved[3]; 358c2ecf20Sopenharmony_ci __u32 pad; 368c2ecf20Sopenharmony_ci}; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_cistruct siw_uresp_reg_mr { 398c2ecf20Sopenharmony_ci __u32 stag; 408c2ecf20Sopenharmony_ci __u32 pad; 418c2ecf20Sopenharmony_ci}; 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_cistruct siw_uresp_create_srq { 448c2ecf20Sopenharmony_ci __u32 num_rqe; 458c2ecf20Sopenharmony_ci __u32 pad; 468c2ecf20Sopenharmony_ci __aligned_u64 srq_key; 478c2ecf20Sopenharmony_ci}; 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_cistruct siw_uresp_alloc_ctx { 508c2ecf20Sopenharmony_ci __u32 dev_id; 518c2ecf20Sopenharmony_ci __u32 pad; 528c2ecf20Sopenharmony_ci}; 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_cienum siw_opcode { 558c2ecf20Sopenharmony_ci SIW_OP_WRITE, 568c2ecf20Sopenharmony_ci SIW_OP_READ, 578c2ecf20Sopenharmony_ci SIW_OP_READ_LOCAL_INV, 588c2ecf20Sopenharmony_ci SIW_OP_SEND, 598c2ecf20Sopenharmony_ci SIW_OP_SEND_WITH_IMM, 608c2ecf20Sopenharmony_ci SIW_OP_SEND_REMOTE_INV, 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci /* Unsupported */ 638c2ecf20Sopenharmony_ci SIW_OP_FETCH_AND_ADD, 648c2ecf20Sopenharmony_ci SIW_OP_COMP_AND_SWAP, 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci SIW_OP_RECEIVE, 678c2ecf20Sopenharmony_ci /* provider internal SQE */ 688c2ecf20Sopenharmony_ci SIW_OP_READ_RESPONSE, 698c2ecf20Sopenharmony_ci /* 708c2ecf20Sopenharmony_ci * below opcodes valid for 718c2ecf20Sopenharmony_ci * in-kernel clients only 728c2ecf20Sopenharmony_ci */ 738c2ecf20Sopenharmony_ci SIW_OP_INVAL_STAG, 748c2ecf20Sopenharmony_ci SIW_OP_REG_MR, 758c2ecf20Sopenharmony_ci SIW_NUM_OPCODES 768c2ecf20Sopenharmony_ci}; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci/* Keep it same as ibv_sge to allow for memcpy */ 798c2ecf20Sopenharmony_cistruct siw_sge { 808c2ecf20Sopenharmony_ci __aligned_u64 laddr; 818c2ecf20Sopenharmony_ci __u32 length; 828c2ecf20Sopenharmony_ci __u32 lkey; 838c2ecf20Sopenharmony_ci}; 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci/* 868c2ecf20Sopenharmony_ci * Inline data are kept within the work request itself occupying 878c2ecf20Sopenharmony_ci * the space of sge[1] .. sge[n]. Therefore, inline data cannot be 888c2ecf20Sopenharmony_ci * supported if SIW_MAX_SGE is below 2 elements. 898c2ecf20Sopenharmony_ci */ 908c2ecf20Sopenharmony_ci#define SIW_MAX_INLINE (sizeof(struct siw_sge) * (SIW_MAX_SGE - 1)) 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#if SIW_MAX_SGE < 2 938c2ecf20Sopenharmony_ci#error "SIW_MAX_SGE must be at least 2" 948c2ecf20Sopenharmony_ci#endif 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_cienum siw_wqe_flags { 978c2ecf20Sopenharmony_ci SIW_WQE_VALID = 1, 988c2ecf20Sopenharmony_ci SIW_WQE_INLINE = (1 << 1), 998c2ecf20Sopenharmony_ci SIW_WQE_SIGNALLED = (1 << 2), 1008c2ecf20Sopenharmony_ci SIW_WQE_SOLICITED = (1 << 3), 1018c2ecf20Sopenharmony_ci SIW_WQE_READ_FENCE = (1 << 4), 1028c2ecf20Sopenharmony_ci SIW_WQE_REM_INVAL = (1 << 5), 1038c2ecf20Sopenharmony_ci SIW_WQE_COMPLETED = (1 << 6) 1048c2ecf20Sopenharmony_ci}; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci/* Send Queue Element */ 1078c2ecf20Sopenharmony_cistruct siw_sqe { 1088c2ecf20Sopenharmony_ci __aligned_u64 id; 1098c2ecf20Sopenharmony_ci __u16 flags; 1108c2ecf20Sopenharmony_ci __u8 num_sge; 1118c2ecf20Sopenharmony_ci /* Contains enum siw_opcode values */ 1128c2ecf20Sopenharmony_ci __u8 opcode; 1138c2ecf20Sopenharmony_ci __u32 rkey; 1148c2ecf20Sopenharmony_ci union { 1158c2ecf20Sopenharmony_ci __aligned_u64 raddr; 1168c2ecf20Sopenharmony_ci __aligned_u64 base_mr; 1178c2ecf20Sopenharmony_ci }; 1188c2ecf20Sopenharmony_ci union { 1198c2ecf20Sopenharmony_ci struct siw_sge sge[SIW_MAX_SGE]; 1208c2ecf20Sopenharmony_ci __aligned_u64 access; 1218c2ecf20Sopenharmony_ci }; 1228c2ecf20Sopenharmony_ci}; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci/* Receive Queue Element */ 1258c2ecf20Sopenharmony_cistruct siw_rqe { 1268c2ecf20Sopenharmony_ci __aligned_u64 id; 1278c2ecf20Sopenharmony_ci __u16 flags; 1288c2ecf20Sopenharmony_ci __u8 num_sge; 1298c2ecf20Sopenharmony_ci /* 1308c2ecf20Sopenharmony_ci * only used by kernel driver, 1318c2ecf20Sopenharmony_ci * ignored if set by user 1328c2ecf20Sopenharmony_ci */ 1338c2ecf20Sopenharmony_ci __u8 opcode; 1348c2ecf20Sopenharmony_ci __u32 unused; 1358c2ecf20Sopenharmony_ci struct siw_sge sge[SIW_MAX_SGE]; 1368c2ecf20Sopenharmony_ci}; 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_cienum siw_notify_flags { 1398c2ecf20Sopenharmony_ci SIW_NOTIFY_NOT = (0), 1408c2ecf20Sopenharmony_ci SIW_NOTIFY_SOLICITED = (1 << 0), 1418c2ecf20Sopenharmony_ci SIW_NOTIFY_NEXT_COMPLETION = (1 << 1), 1428c2ecf20Sopenharmony_ci SIW_NOTIFY_MISSED_EVENTS = (1 << 2), 1438c2ecf20Sopenharmony_ci SIW_NOTIFY_ALL = SIW_NOTIFY_SOLICITED | SIW_NOTIFY_NEXT_COMPLETION | 1448c2ecf20Sopenharmony_ci SIW_NOTIFY_MISSED_EVENTS 1458c2ecf20Sopenharmony_ci}; 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_cienum siw_wc_status { 1488c2ecf20Sopenharmony_ci SIW_WC_SUCCESS, 1498c2ecf20Sopenharmony_ci SIW_WC_LOC_LEN_ERR, 1508c2ecf20Sopenharmony_ci SIW_WC_LOC_PROT_ERR, 1518c2ecf20Sopenharmony_ci SIW_WC_LOC_QP_OP_ERR, 1528c2ecf20Sopenharmony_ci SIW_WC_WR_FLUSH_ERR, 1538c2ecf20Sopenharmony_ci SIW_WC_BAD_RESP_ERR, 1548c2ecf20Sopenharmony_ci SIW_WC_LOC_ACCESS_ERR, 1558c2ecf20Sopenharmony_ci SIW_WC_REM_ACCESS_ERR, 1568c2ecf20Sopenharmony_ci SIW_WC_REM_INV_REQ_ERR, 1578c2ecf20Sopenharmony_ci SIW_WC_GENERAL_ERR, 1588c2ecf20Sopenharmony_ci SIW_NUM_WC_STATUS 1598c2ecf20Sopenharmony_ci}; 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_cistruct siw_cqe { 1628c2ecf20Sopenharmony_ci __aligned_u64 id; 1638c2ecf20Sopenharmony_ci __u8 flags; 1648c2ecf20Sopenharmony_ci __u8 opcode; 1658c2ecf20Sopenharmony_ci __u16 status; 1668c2ecf20Sopenharmony_ci __u32 bytes; 1678c2ecf20Sopenharmony_ci union { 1688c2ecf20Sopenharmony_ci __aligned_u64 imm_data; 1698c2ecf20Sopenharmony_ci __u32 inval_stag; 1708c2ecf20Sopenharmony_ci }; 1718c2ecf20Sopenharmony_ci /* QP number or QP pointer */ 1728c2ecf20Sopenharmony_ci union { 1738c2ecf20Sopenharmony_ci struct ib_qp *base_qp; 1748c2ecf20Sopenharmony_ci __aligned_u64 qp_id; 1758c2ecf20Sopenharmony_ci }; 1768c2ecf20Sopenharmony_ci}; 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci/* 1798c2ecf20Sopenharmony_ci * Shared structure between user and kernel 1808c2ecf20Sopenharmony_ci * to control CQ arming. 1818c2ecf20Sopenharmony_ci */ 1828c2ecf20Sopenharmony_cistruct siw_cq_ctrl { 1838c2ecf20Sopenharmony_ci __u32 flags; 1848c2ecf20Sopenharmony_ci __u32 pad; 1858c2ecf20Sopenharmony_ci}; 1868c2ecf20Sopenharmony_ci#endif 187