i40iw_user.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  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 = 32,
  74. I40IW_QPCTX_ENCD_MAXIRD = 3,
  75. I40IW_MAX_WQ_ENTRIES = 2048,
  76. I40IW_MAX_ORD_SIZE = 32,
  77. I40IW_Q2_BUFFER_SIZE = (248 + 100),
  78. I40IW_QP_CTX_SIZE = 248
  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_CREATE_STAG(index, key) (((index) << 8) + (key))
  95. #define I40IW_STAG_KEY_FROM_STAG(stag) ((stag) && 0x000000FF)
  96. #define I40IW_STAG_INDEX_FROM_STAG(stag) (((stag) && 0xFFFFFF00) >> 8)
  97. #define I40IW_MAX_MR_SIZE 0x10000000000L
  98. struct i40iw_qp_uk;
  99. struct i40iw_cq_uk;
  100. struct i40iw_srq_uk;
  101. struct i40iw_qp_uk_init_info;
  102. struct i40iw_cq_uk_init_info;
  103. struct i40iw_srq_uk_init_info;
  104. struct i40iw_sge {
  105. i40iw_tagged_offset tag_off;
  106. u32 len;
  107. i40iw_stag stag;
  108. };
  109. #define i40iw_sgl struct i40iw_sge *
  110. struct i40iw_ring {
  111. u32 head;
  112. u32 tail;
  113. u32 size;
  114. };
  115. struct i40iw_cqe {
  116. u64 buf[I40IW_CQE_SIZE];
  117. };
  118. struct i40iw_extended_cqe {
  119. u64 buf[I40IW_EXTENDED_CQE_SIZE];
  120. };
  121. struct i40iw_wqe {
  122. u64 buf[I40IW_WQE_SIZE];
  123. };
  124. struct i40iw_qp_uk_ops;
  125. enum i40iw_addressing_type {
  126. I40IW_ADDR_TYPE_ZERO_BASED = 0,
  127. I40IW_ADDR_TYPE_VA_BASED = 1,
  128. };
  129. #define I40IW_ACCESS_FLAGS_LOCALREAD 0x01
  130. #define I40IW_ACCESS_FLAGS_LOCALWRITE 0x02
  131. #define I40IW_ACCESS_FLAGS_REMOTEREAD_ONLY 0x04
  132. #define I40IW_ACCESS_FLAGS_REMOTEREAD 0x05
  133. #define I40IW_ACCESS_FLAGS_REMOTEWRITE_ONLY 0x08
  134. #define I40IW_ACCESS_FLAGS_REMOTEWRITE 0x0a
  135. #define I40IW_ACCESS_FLAGS_BIND_WINDOW 0x10
  136. #define I40IW_ACCESS_FLAGS_ALL 0x1F
  137. #define I40IW_OP_TYPE_RDMA_WRITE 0
  138. #define I40IW_OP_TYPE_RDMA_READ 1
  139. #define I40IW_OP_TYPE_SEND 3
  140. #define I40IW_OP_TYPE_SEND_INV 4
  141. #define I40IW_OP_TYPE_SEND_SOL 5
  142. #define I40IW_OP_TYPE_SEND_SOL_INV 6
  143. #define I40IW_OP_TYPE_REC 7
  144. #define I40IW_OP_TYPE_BIND_MW 8
  145. #define I40IW_OP_TYPE_FAST_REG_NSMR 9
  146. #define I40IW_OP_TYPE_INV_STAG 10
  147. #define I40IW_OP_TYPE_RDMA_READ_INV_STAG 11
  148. #define I40IW_OP_TYPE_NOP 12
  149. enum i40iw_completion_status {
  150. I40IW_COMPL_STATUS_SUCCESS = 0,
  151. I40IW_COMPL_STATUS_FLUSHED,
  152. I40IW_COMPL_STATUS_INVALID_WQE,
  153. I40IW_COMPL_STATUS_QP_CATASTROPHIC,
  154. I40IW_COMPL_STATUS_REMOTE_TERMINATION,
  155. I40IW_COMPL_STATUS_INVALID_STAG,
  156. I40IW_COMPL_STATUS_BASE_BOUND_VIOLATION,
  157. I40IW_COMPL_STATUS_ACCESS_VIOLATION,
  158. I40IW_COMPL_STATUS_INVALID_PD_ID,
  159. I40IW_COMPL_STATUS_WRAP_ERROR,
  160. I40IW_COMPL_STATUS_STAG_INVALID_PDID,
  161. I40IW_COMPL_STATUS_RDMA_READ_ZERO_ORD,
  162. I40IW_COMPL_STATUS_QP_NOT_PRIVLEDGED,
  163. I40IW_COMPL_STATUS_STAG_NOT_INVALID,
  164. I40IW_COMPL_STATUS_INVALID_PHYS_BUFFER_SIZE,
  165. I40IW_COMPL_STATUS_INVALID_PHYS_BUFFER_ENTRY,
  166. I40IW_COMPL_STATUS_INVALID_FBO,
  167. I40IW_COMPL_STATUS_INVALID_LENGTH,
  168. I40IW_COMPL_STATUS_INVALID_ACCESS,
  169. I40IW_COMPL_STATUS_PHYS_BUFFER_LIST_TOO_LONG,
  170. I40IW_COMPL_STATUS_INVALID_VIRT_ADDRESS,
  171. I40IW_COMPL_STATUS_INVALID_REGION,
  172. I40IW_COMPL_STATUS_INVALID_WINDOW,
  173. I40IW_COMPL_STATUS_INVALID_TOTAL_LENGTH
  174. };
  175. enum i40iw_completion_notify {
  176. IW_CQ_COMPL_EVENT = 0,
  177. IW_CQ_COMPL_SOLICITED = 1
  178. };
  179. struct i40iw_post_send {
  180. i40iw_sgl sg_list;
  181. u32 num_sges;
  182. };
  183. struct i40iw_post_inline_send {
  184. void *data;
  185. u32 len;
  186. };
  187. struct i40iw_post_send_w_inv {
  188. i40iw_sgl sg_list;
  189. u32 num_sges;
  190. i40iw_stag remote_stag_to_inv;
  191. };
  192. struct i40iw_post_inline_send_w_inv {
  193. void *data;
  194. u32 len;
  195. i40iw_stag remote_stag_to_inv;
  196. };
  197. struct i40iw_rdma_write {
  198. i40iw_sgl lo_sg_list;
  199. u32 num_lo_sges;
  200. struct i40iw_sge rem_addr;
  201. };
  202. struct i40iw_inline_rdma_write {
  203. void *data;
  204. u32 len;
  205. struct i40iw_sge rem_addr;
  206. };
  207. struct i40iw_rdma_read {
  208. struct i40iw_sge lo_addr;
  209. struct i40iw_sge rem_addr;
  210. };
  211. struct i40iw_bind_window {
  212. i40iw_stag mr_stag;
  213. u64 bind_length;
  214. void *va;
  215. enum i40iw_addressing_type addressing_type;
  216. bool enable_reads;
  217. bool enable_writes;
  218. i40iw_stag mw_stag;
  219. };
  220. struct i40iw_inv_local_stag {
  221. i40iw_stag target_stag;
  222. };
  223. struct i40iw_post_sq_info {
  224. u64 wr_id;
  225. u8 op_type;
  226. bool signaled;
  227. bool read_fence;
  228. bool local_fence;
  229. bool inline_data;
  230. bool defer_flag;
  231. union {
  232. struct i40iw_post_send send;
  233. struct i40iw_post_send send_w_sol;
  234. struct i40iw_post_send_w_inv send_w_inv;
  235. struct i40iw_post_send_w_inv send_w_sol_inv;
  236. struct i40iw_rdma_write rdma_write;
  237. struct i40iw_rdma_read rdma_read;
  238. struct i40iw_rdma_read rdma_read_inv;
  239. struct i40iw_bind_window bind_window;
  240. struct i40iw_inv_local_stag inv_local_stag;
  241. struct i40iw_inline_rdma_write inline_rdma_write;
  242. struct i40iw_post_inline_send inline_send;
  243. struct i40iw_post_inline_send inline_send_w_sol;
  244. struct i40iw_post_inline_send_w_inv inline_send_w_inv;
  245. struct i40iw_post_inline_send_w_inv inline_send_w_sol_inv;
  246. } op;
  247. };
  248. struct i40iw_post_rq_info {
  249. u64 wr_id;
  250. i40iw_sgl sg_list;
  251. u32 num_sges;
  252. };
  253. struct i40iw_cq_poll_info {
  254. u64 wr_id;
  255. i40iw_qp_handle qp_handle;
  256. u32 bytes_xfered;
  257. u32 tcp_seq_num;
  258. u32 qp_id;
  259. i40iw_stag inv_stag;
  260. enum i40iw_completion_status comp_status;
  261. u16 major_err;
  262. u16 minor_err;
  263. u8 op_type;
  264. bool stag_invalid_set;
  265. bool push_dropped;
  266. bool error;
  267. bool is_srq;
  268. bool solicited_event;
  269. };
  270. struct i40iw_qp_uk_ops {
  271. void (*iw_qp_post_wr)(struct i40iw_qp_uk *);
  272. void (*iw_qp_ring_push_db)(struct i40iw_qp_uk *, u32);
  273. enum i40iw_status_code (*iw_rdma_write)(struct i40iw_qp_uk *,
  274. struct i40iw_post_sq_info *, bool);
  275. enum i40iw_status_code (*iw_rdma_read)(struct i40iw_qp_uk *,
  276. struct i40iw_post_sq_info *, bool, bool);
  277. enum i40iw_status_code (*iw_send)(struct i40iw_qp_uk *,
  278. struct i40iw_post_sq_info *, u32, bool);
  279. enum i40iw_status_code (*iw_inline_rdma_write)(struct i40iw_qp_uk *,
  280. struct i40iw_post_sq_info *, bool);
  281. enum i40iw_status_code (*iw_inline_send)(struct i40iw_qp_uk *,
  282. struct i40iw_post_sq_info *, u32, bool);
  283. enum i40iw_status_code (*iw_stag_local_invalidate)(struct i40iw_qp_uk *,
  284. struct i40iw_post_sq_info *, bool);
  285. enum i40iw_status_code (*iw_mw_bind)(struct i40iw_qp_uk *,
  286. struct i40iw_post_sq_info *, bool);
  287. enum i40iw_status_code (*iw_post_receive)(struct i40iw_qp_uk *,
  288. struct i40iw_post_rq_info *);
  289. enum i40iw_status_code (*iw_post_nop)(struct i40iw_qp_uk *, u64, bool, bool);
  290. };
  291. struct i40iw_cq_ops {
  292. void (*iw_cq_request_notification)(struct i40iw_cq_uk *,
  293. enum i40iw_completion_notify);
  294. enum i40iw_status_code (*iw_cq_poll_completion)(struct i40iw_cq_uk *,
  295. struct i40iw_cq_poll_info *);
  296. enum i40iw_status_code (*iw_cq_post_entries)(struct i40iw_cq_uk *, u8 count);
  297. void (*iw_cq_clean)(void *, struct i40iw_cq_uk *);
  298. };
  299. struct i40iw_dev_uk;
  300. struct i40iw_device_uk_ops {
  301. enum i40iw_status_code (*iwarp_cq_uk_init)(struct i40iw_cq_uk *,
  302. struct i40iw_cq_uk_init_info *);
  303. enum i40iw_status_code (*iwarp_qp_uk_init)(struct i40iw_qp_uk *,
  304. struct i40iw_qp_uk_init_info *);
  305. };
  306. struct i40iw_dev_uk {
  307. struct i40iw_device_uk_ops ops_uk;
  308. };
  309. struct i40iw_sq_uk_wr_trk_info {
  310. u64 wrid;
  311. u32 wr_len;
  312. u8 wqe_size;
  313. u8 reserved[3];
  314. };
  315. struct i40iw_qp_quanta {
  316. u64 elem[I40IW_WQE_SIZE];
  317. };
  318. struct i40iw_qp_uk {
  319. struct i40iw_qp_quanta *sq_base;
  320. struct i40iw_qp_quanta *rq_base;
  321. u32 __iomem *wqe_alloc_reg;
  322. struct i40iw_sq_uk_wr_trk_info *sq_wrtrk_array;
  323. u64 *rq_wrid_array;
  324. u64 *shadow_area;
  325. u32 *push_db;
  326. u64 *push_wqe;
  327. struct i40iw_ring sq_ring;
  328. struct i40iw_ring rq_ring;
  329. struct i40iw_ring initial_ring;
  330. u32 qp_id;
  331. u32 sq_size;
  332. u32 rq_size;
  333. u32 max_sq_frag_cnt;
  334. u32 max_rq_frag_cnt;
  335. struct i40iw_qp_uk_ops ops;
  336. bool use_srq;
  337. u8 swqe_polarity;
  338. u8 swqe_polarity_deferred;
  339. u8 rwqe_polarity;
  340. u8 rq_wqe_size;
  341. u8 rq_wqe_size_multiplier;
  342. bool deferred_flag;
  343. };
  344. struct i40iw_cq_uk {
  345. struct i40iw_cqe *cq_base;
  346. u32 __iomem *cqe_alloc_reg;
  347. u64 *shadow_area;
  348. u32 cq_id;
  349. u32 cq_size;
  350. struct i40iw_ring cq_ring;
  351. u8 polarity;
  352. bool avoid_mem_cflct;
  353. struct i40iw_cq_ops ops;
  354. };
  355. struct i40iw_qp_uk_init_info {
  356. struct i40iw_qp_quanta *sq;
  357. struct i40iw_qp_quanta *rq;
  358. u32 __iomem *wqe_alloc_reg;
  359. u64 *shadow_area;
  360. struct i40iw_sq_uk_wr_trk_info *sq_wrtrk_array;
  361. u64 *rq_wrid_array;
  362. u32 *push_db;
  363. u64 *push_wqe;
  364. u32 qp_id;
  365. u32 sq_size;
  366. u32 rq_size;
  367. u32 max_sq_frag_cnt;
  368. u32 max_rq_frag_cnt;
  369. u32 max_inline_data;
  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