siw-abi.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) or BSD-3-Clause */
  2. /* Authors: Bernard Metzler <bmt@zurich.ibm.com> */
  3. /* Copyright (c) 2008-2019, IBM Corporation */
  4. #ifndef _SIW_USER_H
  5. #define _SIW_USER_H
  6. #include <linux/types.h>
  7. #define SIW_NODE_DESC_COMMON "Software iWARP stack"
  8. #define SIW_ABI_VERSION 1
  9. #define SIW_MAX_SGE 6
  10. #define SIW_UOBJ_MAX_KEY 0x08FFFF
  11. #define SIW_INVAL_UOBJ_KEY (SIW_UOBJ_MAX_KEY + 1)
  12. struct siw_uresp_create_cq {
  13. __u32 cq_id;
  14. __u32 num_cqe;
  15. __aligned_u64 cq_key;
  16. };
  17. struct siw_uresp_create_qp {
  18. __u32 qp_id;
  19. __u32 num_sqe;
  20. __u32 num_rqe;
  21. __u32 pad;
  22. __aligned_u64 sq_key;
  23. __aligned_u64 rq_key;
  24. };
  25. struct siw_ureq_reg_mr {
  26. __u8 stag_key;
  27. __u8 reserved[3];
  28. __u32 pad;
  29. };
  30. struct siw_uresp_reg_mr {
  31. __u32 stag;
  32. __u32 pad;
  33. };
  34. struct siw_uresp_create_srq {
  35. __u32 num_rqe;
  36. __u32 pad;
  37. __aligned_u64 srq_key;
  38. };
  39. struct siw_uresp_alloc_ctx {
  40. __u32 dev_id;
  41. __u32 pad;
  42. };
  43. enum siw_opcode {
  44. SIW_OP_WRITE,
  45. SIW_OP_READ,
  46. SIW_OP_READ_LOCAL_INV,
  47. SIW_OP_SEND,
  48. SIW_OP_SEND_WITH_IMM,
  49. SIW_OP_SEND_REMOTE_INV,
  50. /* Unsupported */
  51. SIW_OP_FETCH_AND_ADD,
  52. SIW_OP_COMP_AND_SWAP,
  53. SIW_OP_RECEIVE,
  54. /* provider internal SQE */
  55. SIW_OP_READ_RESPONSE,
  56. /*
  57. * below opcodes valid for
  58. * in-kernel clients only
  59. */
  60. SIW_OP_INVAL_STAG,
  61. SIW_OP_REG_MR,
  62. SIW_NUM_OPCODES
  63. };
  64. /* Keep it same as ibv_sge to allow for memcpy */
  65. struct siw_sge {
  66. __aligned_u64 laddr;
  67. __u32 length;
  68. __u32 lkey;
  69. };
  70. /*
  71. * Inline data are kept within the work request itself occupying
  72. * the space of sge[1] .. sge[n]. Therefore, __inline__ data cannot be
  73. * supported if SIW_MAX_SGE is below 2 elements.
  74. */
  75. #define SIW_MAX_INLINE (sizeof(struct siw_sge) * (SIW_MAX_SGE - 1))
  76. #if SIW_MAX_SGE < 2
  77. #error "SIW_MAX_SGE must be at least 2"
  78. #endif
  79. enum siw_wqe_flags {
  80. SIW_WQE_VALID = 1,
  81. SIW_WQE_INLINE = (1 << 1),
  82. SIW_WQE_SIGNALLED = (1 << 2),
  83. SIW_WQE_SOLICITED = (1 << 3),
  84. SIW_WQE_READ_FENCE = (1 << 4),
  85. SIW_WQE_REM_INVAL = (1 << 5),
  86. SIW_WQE_COMPLETED = (1 << 6)
  87. };
  88. /* Send Queue Element */
  89. struct siw_sqe {
  90. __aligned_u64 id;
  91. __u16 flags;
  92. __u8 num_sge;
  93. /* Contains enum siw_opcode values */
  94. __u8 opcode;
  95. __u32 rkey;
  96. union {
  97. __aligned_u64 raddr;
  98. __aligned_u64 base_mr;
  99. };
  100. union {
  101. struct siw_sge sge[SIW_MAX_SGE];
  102. __aligned_u64 access;
  103. };
  104. };
  105. /* Receive Queue Element */
  106. struct siw_rqe {
  107. __aligned_u64 id;
  108. __u16 flags;
  109. __u8 num_sge;
  110. /*
  111. * only used by kernel driver,
  112. * ignored if set by user
  113. */
  114. __u8 opcode;
  115. __u32 unused;
  116. struct siw_sge sge[SIW_MAX_SGE];
  117. };
  118. enum siw_notify_flags {
  119. SIW_NOTIFY_NOT = (0),
  120. SIW_NOTIFY_SOLICITED = (1 << 0),
  121. SIW_NOTIFY_NEXT_COMPLETION = (1 << 1),
  122. SIW_NOTIFY_MISSED_EVENTS = (1 << 2),
  123. SIW_NOTIFY_ALL = SIW_NOTIFY_SOLICITED | SIW_NOTIFY_NEXT_COMPLETION |
  124. SIW_NOTIFY_MISSED_EVENTS
  125. };
  126. enum siw_wc_status {
  127. SIW_WC_SUCCESS,
  128. SIW_WC_LOC_LEN_ERR,
  129. SIW_WC_LOC_PROT_ERR,
  130. SIW_WC_LOC_QP_OP_ERR,
  131. SIW_WC_WR_FLUSH_ERR,
  132. SIW_WC_BAD_RESP_ERR,
  133. SIW_WC_LOC_ACCESS_ERR,
  134. SIW_WC_REM_ACCESS_ERR,
  135. SIW_WC_REM_INV_REQ_ERR,
  136. SIW_WC_GENERAL_ERR,
  137. SIW_NUM_WC_STATUS
  138. };
  139. struct siw_cqe {
  140. __aligned_u64 id;
  141. __u8 flags;
  142. __u8 opcode;
  143. __u16 status;
  144. __u32 bytes;
  145. union {
  146. __aligned_u64 imm_data;
  147. __u32 inval_stag;
  148. };
  149. /* QP number or QP pointer */
  150. union {
  151. struct ib_qp *base_qp;
  152. __aligned_u64 qp_id;
  153. };
  154. };
  155. /*
  156. * Shared structure between user and kernel
  157. * to control CQ arming.
  158. */
  159. struct siw_cq_ctrl {
  160. __u32 flags;
  161. __u32 pad;
  162. };
  163. #endif