i40iw_user.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. /*******************************************************************************
  2. *
  3. * Copyright (c) 2015-2016 Intel Corporation. All rights reserved.
  4. *
  5. * This software is available to you under a choice of one of two
  6. * licenses. You may choose to be licensed under the terms of the GNU
  7. * General Public License (GPL) Version 2, available from the file
  8. * COPYING in the main directory of this source tree, or the
  9. * OpenFabrics.org BSD license below:
  10. *
  11. * Redistribution and use in source and binary forms, with or
  12. * without modification, are permitted provided that the following
  13. * conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above
  16. * copyright notice, this list of conditions and the following
  17. * disclaimer.
  18. *
  19. * - Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials
  22. * provided with the distribution.
  23. *
  24. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  28. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  29. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  30. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  31. * SOFTWARE.
  32. *
  33. *******************************************************************************/
  34. #ifndef I40IW_USER_H
  35. #define I40IW_USER_H
  36. enum i40iw_device_capabilities_const {
  37. I40IW_WQE_SIZE = 4,
  38. I40IW_CQP_WQE_SIZE = 8,
  39. I40IW_CQE_SIZE = 4,
  40. I40IW_EXTENDED_CQE_SIZE = 8,
  41. I40IW_AEQE_SIZE = 2,
  42. I40IW_CEQE_SIZE = 1,
  43. I40IW_CQP_CTX_SIZE = 8,
  44. I40IW_SHADOW_AREA_SIZE = 8,
  45. I40IW_CEQ_MAX_COUNT = 256,
  46. I40IW_QUERY_FPM_BUF_SIZE = 128,
  47. I40IW_COMMIT_FPM_BUF_SIZE = 128,
  48. I40IW_MIN_IW_QP_ID = 1,
  49. I40IW_MAX_IW_QP_ID = 262143,
  50. I40IW_MIN_CEQID = 0,
  51. I40IW_MAX_CEQID = 256,
  52. I40IW_MIN_CQID = 0,
  53. I40IW_MAX_CQID = 131071,
  54. I40IW_MIN_AEQ_ENTRIES = 1,
  55. I40IW_MAX_AEQ_ENTRIES = 524287,
  56. I40IW_MIN_CEQ_ENTRIES = 1,
  57. I40IW_MAX_CEQ_ENTRIES = 131071,
  58. I40IW_MIN_CQ_SIZE = 1,
  59. I40IW_MAX_CQ_SIZE = 1048575,
  60. I40IW_DB_ID_ZERO = 0,
  61. I40IW_MAX_WQ_FRAGMENT_COUNT = 3,
  62. I40IW_MAX_SGE_RD = 1,
  63. I40IW_MAX_OUTBOUND_MESSAGE_SIZE = 2147483647,
  64. I40IW_MAX_INBOUND_MESSAGE_SIZE = 2147483647,
  65. I40IW_MAX_PUSH_PAGE_COUNT = 4096,
  66. I40IW_MAX_PE_ENABLED_VF_COUNT = 32,
  67. I40IW_MAX_VF_FPM_ID = 47,
  68. I40IW_MAX_VF_PER_PF = 127,
  69. I40IW_MAX_SQ_PAYLOAD_SIZE = 2145386496,
  70. I40IW_MAX_INLINE_DATA_SIZE = 48,
  71. I40IW_MAX_PUSHMODE_INLINE_DATA_SIZE = 48,
  72. I40IW_MAX_IRD_SIZE = 64,
  73. I40IW_MAX_ORD_SIZE = 127,
  74. I40IW_MAX_WQ_ENTRIES = 2048,
  75. I40IW_Q2_BUFFER_SIZE = (248 + 100),
  76. I40IW_MAX_WQE_SIZE_RQ = 128,
  77. I40IW_QP_CTX_SIZE = 248,
  78. I40IW_MAX_PDS = 32768
  79. };
  80. #define i40iw_handle void *
  81. #define i40iw_adapter_handle i40iw_handle
  82. #define i40iw_qp_handle i40iw_handle
  83. #define i40iw_cq_handle i40iw_handle
  84. #define i40iw_srq_handle i40iw_handle
  85. #define i40iw_pd_id i40iw_handle
  86. #define i40iw_stag_handle i40iw_handle
  87. #define i40iw_stag_index u32
  88. #define i40iw_stag u32
  89. #define i40iw_stag_key u8
  90. #define i40iw_tagged_offset u64
  91. #define i40iw_access_privileges u32
  92. #define i40iw_physical_fragment u64
  93. #define i40iw_address_list u64 *
  94. #define I40IW_MAX_MR_SIZE 0x10000000000L
  95. #define I40IW_MAX_RQ_WQE_SHIFT 2
  96. struct i40iw_qp_uk;
  97. struct i40iw_cq_uk;
  98. struct i40iw_srq_uk;
  99. struct i40iw_qp_uk_init_info;
  100. struct i40iw_cq_uk_init_info;
  101. struct i40iw_srq_uk_init_info;
  102. struct i40iw_sge {
  103. i40iw_tagged_offset tag_off;
  104. u32 len;
  105. i40iw_stag stag;
  106. };
  107. #define i40iw_sgl struct i40iw_sge *
  108. struct i40iw_ring {
  109. u32 head;
  110. u32 tail;
  111. u32 size;
  112. };
  113. struct i40iw_cqe {
  114. u64 buf[I40IW_CQE_SIZE];
  115. };
  116. struct i40iw_extended_cqe {
  117. u64 buf[I40IW_EXTENDED_CQE_SIZE];
  118. };
  119. struct i40iw_wqe {
  120. u64 buf[I40IW_WQE_SIZE];
  121. };
  122. struct i40iw_qp_uk_ops;
  123. enum i40iw_addressing_type {
  124. I40IW_ADDR_TYPE_ZERO_BASED = 0,
  125. I40IW_ADDR_TYPE_VA_BASED = 1,
  126. };
  127. #define I40IW_ACCESS_FLAGS_LOCALREAD 0x01
  128. #define I40IW_ACCESS_FLAGS_LOCALWRITE 0x02
  129. #define I40IW_ACCESS_FLAGS_REMOTEREAD_ONLY 0x04
  130. #define I40IW_ACCESS_FLAGS_REMOTEREAD 0x05
  131. #define I40IW_ACCESS_FLAGS_REMOTEWRITE_ONLY 0x08
  132. #define I40IW_ACCESS_FLAGS_REMOTEWRITE 0x0a
  133. #define I40IW_ACCESS_FLAGS_BIND_WINDOW 0x10
  134. #define I40IW_ACCESS_FLAGS_ALL 0x1F
  135. #define I40IW_OP_TYPE_RDMA_WRITE 0
  136. #define I40IW_OP_TYPE_RDMA_READ 1
  137. #define I40IW_OP_TYPE_SEND 3
  138. #define I40IW_OP_TYPE_SEND_INV 4
  139. #define I40IW_OP_TYPE_SEND_SOL 5
  140. #define I40IW_OP_TYPE_SEND_SOL_INV 6
  141. #define I40IW_OP_TYPE_REC 7
  142. #define I40IW_OP_TYPE_BIND_MW 8
  143. #define I40IW_OP_TYPE_FAST_REG_NSMR 9
  144. #define I40IW_OP_TYPE_INV_STAG 10
  145. #define I40IW_OP_TYPE_RDMA_READ_INV_STAG 11
  146. #define I40IW_OP_TYPE_NOP 12
  147. enum i40iw_completion_status {
  148. I40IW_COMPL_STATUS_SUCCESS = 0,
  149. I40IW_COMPL_STATUS_FLUSHED,
  150. I40IW_COMPL_STATUS_INVALID_WQE,
  151. I40IW_COMPL_STATUS_QP_CATASTROPHIC,
  152. I40IW_COMPL_STATUS_REMOTE_TERMINATION,
  153. I40IW_COMPL_STATUS_INVALID_STAG,
  154. I40IW_COMPL_STATUS_BASE_BOUND_VIOLATION,
  155. I40IW_COMPL_STATUS_ACCESS_VIOLATION,
  156. I40IW_COMPL_STATUS_INVALID_PD_ID,
  157. I40IW_COMPL_STATUS_WRAP_ERROR,
  158. I40IW_COMPL_STATUS_STAG_INVALID_PDID,
  159. I40IW_COMPL_STATUS_RDMA_READ_ZERO_ORD,
  160. I40IW_COMPL_STATUS_QP_NOT_PRIVLEDGED,
  161. I40IW_COMPL_STATUS_STAG_NOT_INVALID,
  162. I40IW_COMPL_STATUS_INVALID_PHYS_BUFFER_SIZE,
  163. I40IW_COMPL_STATUS_INVALID_PHYS_BUFFER_ENTRY,
  164. I40IW_COMPL_STATUS_INVALID_FBO,
  165. I40IW_COMPL_STATUS_INVALID_LENGTH,
  166. I40IW_COMPL_STATUS_INVALID_ACCESS,
  167. I40IW_COMPL_STATUS_PHYS_BUFFER_LIST_TOO_LONG,
  168. I40IW_COMPL_STATUS_INVALID_VIRT_ADDRESS,
  169. I40IW_COMPL_STATUS_INVALID_REGION,
  170. I40IW_COMPL_STATUS_INVALID_WINDOW,
  171. I40IW_COMPL_STATUS_INVALID_TOTAL_LENGTH
  172. };
  173. enum i40iw_completion_notify {
  174. IW_CQ_COMPL_EVENT = 0,
  175. IW_CQ_COMPL_SOLICITED = 1
  176. };
  177. struct i40iw_post_send {
  178. i40iw_sgl sg_list;
  179. u32 num_sges;
  180. };
  181. struct i40iw_post_inline_send {
  182. void *data;
  183. u32 len;
  184. };
  185. struct i40iw_rdma_write {
  186. i40iw_sgl lo_sg_list;
  187. u32 num_lo_sges;
  188. struct i40iw_sge rem_addr;
  189. };
  190. struct i40iw_inline_rdma_write {
  191. void *data;
  192. u32 len;
  193. struct i40iw_sge rem_addr;
  194. };
  195. struct i40iw_rdma_read {
  196. struct i40iw_sge lo_addr;
  197. struct i40iw_sge rem_addr;
  198. };
  199. struct i40iw_bind_window {
  200. i40iw_stag mr_stag;
  201. u64 bind_length;
  202. void *va;
  203. enum i40iw_addressing_type addressing_type;
  204. bool enable_reads;
  205. bool enable_writes;
  206. i40iw_stag mw_stag;
  207. };
  208. struct i40iw_inv_local_stag {
  209. i40iw_stag target_stag;
  210. };
  211. struct i40iw_post_sq_info {
  212. u64 wr_id;
  213. u8 op_type;
  214. bool signaled;
  215. bool read_fence;
  216. bool local_fence;
  217. bool inline_data;
  218. bool defer_flag;
  219. union {
  220. struct i40iw_post_send send;
  221. struct i40iw_rdma_write rdma_write;
  222. struct i40iw_rdma_read rdma_read;
  223. struct i40iw_rdma_read rdma_read_inv;
  224. struct i40iw_bind_window bind_window;
  225. struct i40iw_inv_local_stag inv_local_stag;
  226. struct i40iw_inline_rdma_write inline_rdma_write;
  227. struct i40iw_post_inline_send inline_send;
  228. } op;
  229. };
  230. struct i40iw_post_rq_info {
  231. u64 wr_id;
  232. i40iw_sgl sg_list;
  233. u32 num_sges;
  234. };
  235. struct i40iw_cq_poll_info {
  236. u64 wr_id;
  237. i40iw_qp_handle qp_handle;
  238. u32 bytes_xfered;
  239. u32 tcp_seq_num;
  240. u32 qp_id;
  241. i40iw_stag inv_stag;
  242. enum i40iw_completion_status comp_status;
  243. u16 major_err;
  244. u16 minor_err;
  245. u8 op_type;
  246. bool stag_invalid_set;
  247. bool push_dropped;
  248. bool error;
  249. bool is_srq;
  250. bool solicited_event;
  251. };
  252. struct i40iw_qp_uk_ops {
  253. void (*iw_qp_post_wr)(struct i40iw_qp_uk *);
  254. void (*iw_qp_ring_push_db)(struct i40iw_qp_uk *, u32);
  255. enum i40iw_status_code (*iw_rdma_write)(struct i40iw_qp_uk *,
  256. struct i40iw_post_sq_info *, bool);
  257. enum i40iw_status_code (*iw_rdma_read)(struct i40iw_qp_uk *,
  258. struct i40iw_post_sq_info *, bool, bool);
  259. enum i40iw_status_code (*iw_send)(struct i40iw_qp_uk *,
  260. struct i40iw_post_sq_info *, u32, bool);
  261. enum i40iw_status_code (*iw_inline_rdma_write)(struct i40iw_qp_uk *,
  262. struct i40iw_post_sq_info *, bool);
  263. enum i40iw_status_code (*iw_inline_send)(struct i40iw_qp_uk *,
  264. struct i40iw_post_sq_info *, u32, bool);
  265. enum i40iw_status_code (*iw_stag_local_invalidate)(struct i40iw_qp_uk *,
  266. struct i40iw_post_sq_info *, bool);
  267. enum i40iw_status_code (*iw_mw_bind)(struct i40iw_qp_uk *,
  268. struct i40iw_post_sq_info *, bool);
  269. enum i40iw_status_code (*iw_post_receive)(struct i40iw_qp_uk *,
  270. struct i40iw_post_rq_info *);
  271. enum i40iw_status_code (*iw_post_nop)(struct i40iw_qp_uk *, u64, bool, bool);
  272. };
  273. struct i40iw_cq_ops {
  274. void (*iw_cq_request_notification)(struct i40iw_cq_uk *,
  275. enum i40iw_completion_notify);
  276. enum i40iw_status_code (*iw_cq_poll_completion)(struct i40iw_cq_uk *,
  277. struct i40iw_cq_poll_info *);
  278. enum i40iw_status_code (*iw_cq_post_entries)(struct i40iw_cq_uk *, u8 count);
  279. void (*iw_cq_clean)(void *, struct i40iw_cq_uk *);
  280. };
  281. struct i40iw_dev_uk;
  282. struct i40iw_device_uk_ops {
  283. enum i40iw_status_code (*iwarp_cq_uk_init)(struct i40iw_cq_uk *,
  284. struct i40iw_cq_uk_init_info *);
  285. enum i40iw_status_code (*iwarp_qp_uk_init)(struct i40iw_qp_uk *,
  286. struct i40iw_qp_uk_init_info *);
  287. };
  288. struct i40iw_dev_uk {
  289. struct i40iw_device_uk_ops ops_uk;
  290. };
  291. struct i40iw_sq_uk_wr_trk_info {
  292. u64 wrid;
  293. u32 wr_len;
  294. u8 wqe_size;
  295. u8 reserved[3];
  296. };
  297. struct i40iw_qp_quanta {
  298. u64 elem[I40IW_WQE_SIZE];
  299. };
  300. struct i40iw_qp_uk {
  301. struct i40iw_qp_quanta *sq_base;
  302. struct i40iw_qp_quanta *rq_base;
  303. u32 __iomem *wqe_alloc_reg;
  304. struct i40iw_sq_uk_wr_trk_info *sq_wrtrk_array;
  305. u64 *rq_wrid_array;
  306. u64 *shadow_area;
  307. u32 *push_db;
  308. u64 *push_wqe;
  309. struct i40iw_ring sq_ring;
  310. struct i40iw_ring rq_ring;
  311. struct i40iw_ring initial_ring;
  312. u32 qp_id;
  313. u32 sq_size;
  314. u32 rq_size;
  315. u32 max_sq_frag_cnt;
  316. u32 max_rq_frag_cnt;
  317. struct i40iw_qp_uk_ops ops;
  318. bool use_srq;
  319. u8 swqe_polarity;
  320. u8 swqe_polarity_deferred;
  321. u8 rwqe_polarity;
  322. u8 rq_wqe_size;
  323. u8 rq_wqe_size_multiplier;
  324. bool first_sq_wq;
  325. bool deferred_flag;
  326. };
  327. struct i40iw_cq_uk {
  328. struct i40iw_cqe *cq_base;
  329. u32 __iomem *cqe_alloc_reg;
  330. u64 *shadow_area;
  331. u32 cq_id;
  332. u32 cq_size;
  333. struct i40iw_ring cq_ring;
  334. u8 polarity;
  335. bool avoid_mem_cflct;
  336. struct i40iw_cq_ops ops;
  337. };
  338. struct i40iw_qp_uk_init_info {
  339. struct i40iw_qp_quanta *sq;
  340. struct i40iw_qp_quanta *rq;
  341. u32 __iomem *wqe_alloc_reg;
  342. u64 *shadow_area;
  343. struct i40iw_sq_uk_wr_trk_info *sq_wrtrk_array;
  344. u64 *rq_wrid_array;
  345. u32 *push_db;
  346. u64 *push_wqe;
  347. u32 qp_id;
  348. u32 sq_size;
  349. u32 rq_size;
  350. u32 max_sq_frag_cnt;
  351. u32 max_rq_frag_cnt;
  352. u32 max_inline_data;
  353. int abi_ver;
  354. };
  355. struct i40iw_cq_uk_init_info {
  356. u32 __iomem *cqe_alloc_reg;
  357. struct i40iw_cqe *cq_base;
  358. u64 *shadow_area;
  359. u32 cq_size;
  360. u32 cq_id;
  361. bool avoid_mem_cflct;
  362. };
  363. void i40iw_device_init_uk(struct i40iw_dev_uk *dev);
  364. void i40iw_qp_post_wr(struct i40iw_qp_uk *qp);
  365. u64 *i40iw_qp_get_next_send_wqe(struct i40iw_qp_uk *qp, u32 *wqe_idx,
  366. u8 wqe_size,
  367. u32 total_size,
  368. u64 wr_id
  369. );
  370. u64 *i40iw_qp_get_next_recv_wqe(struct i40iw_qp_uk *qp, u32 *wqe_idx);
  371. u64 *i40iw_qp_get_next_srq_wqe(struct i40iw_srq_uk *srq, u32 *wqe_idx);
  372. enum i40iw_status_code i40iw_cq_uk_init(struct i40iw_cq_uk *cq,
  373. struct i40iw_cq_uk_init_info *info);
  374. enum i40iw_status_code i40iw_qp_uk_init(struct i40iw_qp_uk *qp,
  375. struct i40iw_qp_uk_init_info *info);
  376. void i40iw_clean_cq(void *queue, struct i40iw_cq_uk *cq);
  377. enum i40iw_status_code i40iw_nop(struct i40iw_qp_uk *qp, u64 wr_id,
  378. bool signaled, bool post_sq);
  379. enum i40iw_status_code i40iw_fragcnt_to_wqesize_sq(u32 frag_cnt, u8 *wqe_size);
  380. enum i40iw_status_code i40iw_fragcnt_to_wqesize_rq(u32 frag_cnt, u8 *wqe_size);
  381. enum i40iw_status_code i40iw_inline_data_size_to_wqesize(u32 data_size,
  382. u8 *wqe_size);
  383. void i40iw_get_wqe_shift(u32 sge, u32 inline_data, u8 *shift);
  384. enum i40iw_status_code i40iw_get_sqdepth(u32 sq_size, u8 shift, u32 *sqdepth);
  385. enum i40iw_status_code i40iw_get_rqdepth(u32 rq_size, u8 shift, u32 *rqdepth);
  386. #endif