i40iw_user.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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_MAX_AEQ_ALLOCATE_COUNT = 255,
  61. I40IW_DB_ID_ZERO = 0,
  62. I40IW_MAX_WQ_FRAGMENT_COUNT = 3,
  63. I40IW_MAX_SGE_RD = 1,
  64. I40IW_MAX_OUTBOUND_MESSAGE_SIZE = 2147483647,
  65. I40IW_MAX_INBOUND_MESSAGE_SIZE = 2147483647,
  66. I40IW_MAX_PUSH_PAGE_COUNT = 4096,
  67. I40IW_MAX_PE_ENABLED_VF_COUNT = 32,
  68. I40IW_MAX_VF_FPM_ID = 47,
  69. I40IW_MAX_VF_PER_PF = 127,
  70. I40IW_MAX_SQ_PAYLOAD_SIZE = 2145386496,
  71. I40IW_MAX_INLINE_DATA_SIZE = 48,
  72. I40IW_MAX_PUSHMODE_INLINE_DATA_SIZE = 48,
  73. I40IW_MAX_IRD_SIZE = 63,
  74. I40IW_MAX_ORD_SIZE = 127,
  75. I40IW_MAX_WQ_ENTRIES = 2048,
  76. I40IW_Q2_BUFFER_SIZE = (248 + 100),
  77. I40IW_MAX_WQE_SIZE_RQ = 128,
  78. I40IW_QP_CTX_SIZE = 248,
  79. I40IW_MAX_PDS = 32768
  80. };
  81. #define i40iw_handle void *
  82. #define i40iw_adapter_handle i40iw_handle
  83. #define i40iw_qp_handle i40iw_handle
  84. #define i40iw_cq_handle i40iw_handle
  85. #define i40iw_srq_handle i40iw_handle
  86. #define i40iw_pd_id i40iw_handle
  87. #define i40iw_stag_handle i40iw_handle
  88. #define i40iw_stag_index u32
  89. #define i40iw_stag u32
  90. #define i40iw_stag_key u8
  91. #define i40iw_tagged_offset u64
  92. #define i40iw_access_privileges u32
  93. #define i40iw_physical_fragment u64
  94. #define i40iw_address_list u64 *
  95. #define I40IW_MAX_MR_SIZE 0x10000000000L
  96. #define I40IW_MAX_RQ_WQE_SHIFT 2
  97. struct i40iw_qp_uk;
  98. struct i40iw_cq_uk;
  99. struct i40iw_srq_uk;
  100. struct i40iw_qp_uk_init_info;
  101. struct i40iw_cq_uk_init_info;
  102. struct i40iw_srq_uk_init_info;
  103. struct i40iw_sge {
  104. i40iw_tagged_offset tag_off;
  105. u32 len;
  106. i40iw_stag stag;
  107. };
  108. #define i40iw_sgl struct i40iw_sge *
  109. struct i40iw_ring {
  110. u32 head;
  111. u32 tail;
  112. u32 size;
  113. };
  114. struct i40iw_cqe {
  115. u64 buf[I40IW_CQE_SIZE];
  116. };
  117. struct i40iw_extended_cqe {
  118. u64 buf[I40IW_EXTENDED_CQE_SIZE];
  119. };
  120. struct i40iw_wqe {
  121. u64 buf[I40IW_WQE_SIZE];
  122. };
  123. struct i40iw_qp_uk_ops;
  124. enum i40iw_addressing_type {
  125. I40IW_ADDR_TYPE_ZERO_BASED = 0,
  126. I40IW_ADDR_TYPE_VA_BASED = 1,
  127. };
  128. #define I40IW_ACCESS_FLAGS_LOCALREAD 0x01
  129. #define I40IW_ACCESS_FLAGS_LOCALWRITE 0x02
  130. #define I40IW_ACCESS_FLAGS_REMOTEREAD_ONLY 0x04
  131. #define I40IW_ACCESS_FLAGS_REMOTEREAD 0x05
  132. #define I40IW_ACCESS_FLAGS_REMOTEWRITE_ONLY 0x08
  133. #define I40IW_ACCESS_FLAGS_REMOTEWRITE 0x0a
  134. #define I40IW_ACCESS_FLAGS_BIND_WINDOW 0x10
  135. #define I40IW_ACCESS_FLAGS_ALL 0x1F
  136. #define I40IW_OP_TYPE_RDMA_WRITE 0
  137. #define I40IW_OP_TYPE_RDMA_READ 1
  138. #define I40IW_OP_TYPE_SEND 3
  139. #define I40IW_OP_TYPE_SEND_INV 4
  140. #define I40IW_OP_TYPE_SEND_SOL 5
  141. #define I40IW_OP_TYPE_SEND_SOL_INV 6
  142. #define I40IW_OP_TYPE_REC 7
  143. #define I40IW_OP_TYPE_BIND_MW 8
  144. #define I40IW_OP_TYPE_FAST_REG_NSMR 9
  145. #define I40IW_OP_TYPE_INV_STAG 10
  146. #define I40IW_OP_TYPE_RDMA_READ_INV_STAG 11
  147. #define I40IW_OP_TYPE_NOP 12
  148. enum i40iw_completion_status {
  149. I40IW_COMPL_STATUS_SUCCESS = 0,
  150. I40IW_COMPL_STATUS_FLUSHED,
  151. I40IW_COMPL_STATUS_INVALID_WQE,
  152. I40IW_COMPL_STATUS_QP_CATASTROPHIC,
  153. I40IW_COMPL_STATUS_REMOTE_TERMINATION,
  154. I40IW_COMPL_STATUS_INVALID_STAG,
  155. I40IW_COMPL_STATUS_BASE_BOUND_VIOLATION,
  156. I40IW_COMPL_STATUS_ACCESS_VIOLATION,
  157. I40IW_COMPL_STATUS_INVALID_PD_ID,
  158. I40IW_COMPL_STATUS_WRAP_ERROR,
  159. I40IW_COMPL_STATUS_STAG_INVALID_PDID,
  160. I40IW_COMPL_STATUS_RDMA_READ_ZERO_ORD,
  161. I40IW_COMPL_STATUS_QP_NOT_PRIVLEDGED,
  162. I40IW_COMPL_STATUS_STAG_NOT_INVALID,
  163. I40IW_COMPL_STATUS_INVALID_PHYS_BUFFER_SIZE,
  164. I40IW_COMPL_STATUS_INVALID_PHYS_BUFFER_ENTRY,
  165. I40IW_COMPL_STATUS_INVALID_FBO,
  166. I40IW_COMPL_STATUS_INVALID_LENGTH,
  167. I40IW_COMPL_STATUS_INVALID_ACCESS,
  168. I40IW_COMPL_STATUS_PHYS_BUFFER_LIST_TOO_LONG,
  169. I40IW_COMPL_STATUS_INVALID_VIRT_ADDRESS,
  170. I40IW_COMPL_STATUS_INVALID_REGION,
  171. I40IW_COMPL_STATUS_INVALID_WINDOW,
  172. I40IW_COMPL_STATUS_INVALID_TOTAL_LENGTH
  173. };
  174. enum i40iw_completion_notify {
  175. IW_CQ_COMPL_EVENT = 0,
  176. IW_CQ_COMPL_SOLICITED = 1
  177. };
  178. struct i40iw_post_send {
  179. i40iw_sgl sg_list;
  180. u32 num_sges;
  181. };
  182. struct i40iw_post_inline_send {
  183. void *data;
  184. u32 len;
  185. };
  186. struct i40iw_post_send_w_inv {
  187. i40iw_sgl sg_list;
  188. u32 num_sges;
  189. i40iw_stag remote_stag_to_inv;
  190. };
  191. struct i40iw_post_inline_send_w_inv {
  192. void *data;
  193. u32 len;
  194. i40iw_stag remote_stag_to_inv;
  195. };
  196. struct i40iw_rdma_write {
  197. i40iw_sgl lo_sg_list;
  198. u32 num_lo_sges;
  199. struct i40iw_sge rem_addr;
  200. };
  201. struct i40iw_inline_rdma_write {
  202. void *data;
  203. u32 len;
  204. struct i40iw_sge rem_addr;
  205. };
  206. struct i40iw_rdma_read {
  207. struct i40iw_sge lo_addr;
  208. struct i40iw_sge rem_addr;
  209. };
  210. struct i40iw_bind_window {
  211. i40iw_stag mr_stag;
  212. u64 bind_length;
  213. void *va;
  214. enum i40iw_addressing_type addressing_type;
  215. bool enable_reads;
  216. bool enable_writes;
  217. i40iw_stag mw_stag;
  218. };
  219. struct i40iw_inv_local_stag {
  220. i40iw_stag target_stag;
  221. };
  222. struct i40iw_post_sq_info {
  223. u64 wr_id;
  224. u8 op_type;
  225. bool signaled;
  226. bool read_fence;
  227. bool local_fence;
  228. bool inline_data;
  229. bool defer_flag;
  230. union {
  231. struct i40iw_post_send send;
  232. struct i40iw_post_send send_w_sol;
  233. struct i40iw_post_send_w_inv send_w_inv;
  234. struct i40iw_post_send_w_inv send_w_sol_inv;
  235. struct i40iw_rdma_write rdma_write;
  236. struct i40iw_rdma_read rdma_read;
  237. struct i40iw_rdma_read rdma_read_inv;
  238. struct i40iw_bind_window bind_window;
  239. struct i40iw_inv_local_stag inv_local_stag;
  240. struct i40iw_inline_rdma_write inline_rdma_write;
  241. struct i40iw_post_inline_send inline_send;
  242. struct i40iw_post_inline_send inline_send_w_sol;
  243. struct i40iw_post_inline_send_w_inv inline_send_w_inv;
  244. struct i40iw_post_inline_send_w_inv inline_send_w_sol_inv;
  245. } op;
  246. };
  247. struct i40iw_post_rq_info {
  248. u64 wr_id;
  249. i40iw_sgl sg_list;
  250. u32 num_sges;
  251. };
  252. struct i40iw_cq_poll_info {
  253. u64 wr_id;
  254. i40iw_qp_handle qp_handle;
  255. u32 bytes_xfered;
  256. u32 tcp_seq_num;
  257. u32 qp_id;
  258. i40iw_stag inv_stag;
  259. enum i40iw_completion_status comp_status;
  260. u16 major_err;
  261. u16 minor_err;
  262. u8 op_type;
  263. bool stag_invalid_set;
  264. bool push_dropped;
  265. bool error;
  266. bool is_srq;
  267. bool solicited_event;
  268. };
  269. struct i40iw_qp_uk_ops {
  270. void (*iw_qp_post_wr)(struct i40iw_qp_uk *);
  271. void (*iw_qp_ring_push_db)(struct i40iw_qp_uk *, u32);
  272. enum i40iw_status_code (*iw_rdma_write)(struct i40iw_qp_uk *,
  273. struct i40iw_post_sq_info *, bool);
  274. enum i40iw_status_code (*iw_rdma_read)(struct i40iw_qp_uk *,
  275. struct i40iw_post_sq_info *, bool, bool);
  276. enum i40iw_status_code (*iw_send)(struct i40iw_qp_uk *,
  277. struct i40iw_post_sq_info *, u32, bool);
  278. enum i40iw_status_code (*iw_inline_rdma_write)(struct i40iw_qp_uk *,
  279. struct i40iw_post_sq_info *, bool);
  280. enum i40iw_status_code (*iw_inline_send)(struct i40iw_qp_uk *,
  281. struct i40iw_post_sq_info *, u32, bool);
  282. enum i40iw_status_code (*iw_stag_local_invalidate)(struct i40iw_qp_uk *,
  283. struct i40iw_post_sq_info *, bool);
  284. enum i40iw_status_code (*iw_mw_bind)(struct i40iw_qp_uk *,
  285. struct i40iw_post_sq_info *, bool);
  286. enum i40iw_status_code (*iw_post_receive)(struct i40iw_qp_uk *,
  287. struct i40iw_post_rq_info *);
  288. enum i40iw_status_code (*iw_post_nop)(struct i40iw_qp_uk *, u64, bool, bool);
  289. };
  290. struct i40iw_cq_ops {
  291. void (*iw_cq_request_notification)(struct i40iw_cq_uk *,
  292. enum i40iw_completion_notify);
  293. enum i40iw_status_code (*iw_cq_poll_completion)(struct i40iw_cq_uk *,
  294. struct i40iw_cq_poll_info *);
  295. enum i40iw_status_code (*iw_cq_post_entries)(struct i40iw_cq_uk *, u8 count);
  296. void (*iw_cq_clean)(void *, struct i40iw_cq_uk *);
  297. };
  298. struct i40iw_dev_uk;
  299. struct i40iw_device_uk_ops {
  300. enum i40iw_status_code (*iwarp_cq_uk_init)(struct i40iw_cq_uk *,
  301. struct i40iw_cq_uk_init_info *);
  302. enum i40iw_status_code (*iwarp_qp_uk_init)(struct i40iw_qp_uk *,
  303. struct i40iw_qp_uk_init_info *);
  304. };
  305. struct i40iw_dev_uk {
  306. struct i40iw_device_uk_ops ops_uk;
  307. };
  308. struct i40iw_sq_uk_wr_trk_info {
  309. u64 wrid;
  310. u32 wr_len;
  311. u8 wqe_size;
  312. u8 reserved[3];
  313. };
  314. struct i40iw_qp_quanta {
  315. u64 elem[I40IW_WQE_SIZE];
  316. };
  317. struct i40iw_qp_uk {
  318. struct i40iw_qp_quanta *sq_base;
  319. struct i40iw_qp_quanta *rq_base;
  320. u32 __iomem *wqe_alloc_reg;
  321. struct i40iw_sq_uk_wr_trk_info *sq_wrtrk_array;
  322. u64 *rq_wrid_array;
  323. u64 *shadow_area;
  324. u32 *push_db;
  325. u64 *push_wqe;
  326. struct i40iw_ring sq_ring;
  327. struct i40iw_ring rq_ring;
  328. struct i40iw_ring initial_ring;
  329. u32 qp_id;
  330. u32 sq_size;
  331. u32 rq_size;
  332. u32 max_sq_frag_cnt;
  333. u32 max_rq_frag_cnt;
  334. struct i40iw_qp_uk_ops ops;
  335. bool use_srq;
  336. u8 swqe_polarity;
  337. u8 swqe_polarity_deferred;
  338. u8 rwqe_polarity;
  339. u8 rq_wqe_size;
  340. u8 rq_wqe_size_multiplier;
  341. bool deferred_flag;
  342. };
  343. struct i40iw_cq_uk {
  344. struct i40iw_cqe *cq_base;
  345. u32 __iomem *cqe_alloc_reg;
  346. u64 *shadow_area;
  347. u32 cq_id;
  348. u32 cq_size;
  349. struct i40iw_ring cq_ring;
  350. u8 polarity;
  351. bool avoid_mem_cflct;
  352. struct i40iw_cq_ops ops;
  353. };
  354. struct i40iw_qp_uk_init_info {
  355. struct i40iw_qp_quanta *sq;
  356. struct i40iw_qp_quanta *rq;
  357. u32 __iomem *wqe_alloc_reg;
  358. u64 *shadow_area;
  359. struct i40iw_sq_uk_wr_trk_info *sq_wrtrk_array;
  360. u64 *rq_wrid_array;
  361. u32 *push_db;
  362. u64 *push_wqe;
  363. u32 qp_id;
  364. u32 sq_size;
  365. u32 rq_size;
  366. u32 max_sq_frag_cnt;
  367. u32 max_rq_frag_cnt;
  368. u32 max_inline_data;
  369. int abi_ver;
  370. };
  371. struct i40iw_cq_uk_init_info {
  372. u32 __iomem *cqe_alloc_reg;
  373. struct i40iw_cqe *cq_base;
  374. u64 *shadow_area;
  375. u32 cq_size;
  376. u32 cq_id;
  377. bool avoid_mem_cflct;
  378. };
  379. void i40iw_device_init_uk(struct i40iw_dev_uk *dev);
  380. void i40iw_qp_post_wr(struct i40iw_qp_uk *qp);
  381. u64 *i40iw_qp_get_next_send_wqe(struct i40iw_qp_uk *qp, u32 *wqe_idx,
  382. u8 wqe_size,
  383. u32 total_size,
  384. u64 wr_id
  385. );
  386. u64 *i40iw_qp_get_next_recv_wqe(struct i40iw_qp_uk *qp, u32 *wqe_idx);
  387. u64 *i40iw_qp_get_next_srq_wqe(struct i40iw_srq_uk *srq, u32 *wqe_idx);
  388. enum i40iw_status_code i40iw_cq_uk_init(struct i40iw_cq_uk *cq,
  389. struct i40iw_cq_uk_init_info *info);
  390. enum i40iw_status_code i40iw_qp_uk_init(struct i40iw_qp_uk *qp,
  391. struct i40iw_qp_uk_init_info *info);
  392. void i40iw_clean_cq(void *queue, struct i40iw_cq_uk *cq);
  393. enum i40iw_status_code i40iw_nop(struct i40iw_qp_uk *qp, u64 wr_id,
  394. bool signaled, bool post_sq);
  395. enum i40iw_status_code i40iw_fragcnt_to_wqesize_sq(u32 frag_cnt, u8 *wqe_size);
  396. enum i40iw_status_code i40iw_fragcnt_to_wqesize_rq(u32 frag_cnt, u8 *wqe_size);
  397. enum i40iw_status_code i40iw_inline_data_size_to_wqesize(u32 data_size,
  398. u8 *wqe_size);
  399. enum i40iw_status_code i40iw_get_wqe_shift(u32 wqdepth, u32 sge, u32 inline_data, u8 *shift);
  400. #endif