qplib_sp.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /*
  2. * Broadcom NetXtreme-E RoCE driver.
  3. *
  4. * Copyright (c) 2016 - 2017, Broadcom. All rights reserved. The term
  5. * Broadcom refers to Broadcom Limited and/or its subsidiaries.
  6. *
  7. * This software is available to you under a choice of one of two
  8. * licenses. You may choose to be licensed under the terms of the GNU
  9. * General Public License (GPL) Version 2, available from the file
  10. * COPYING in the main directory of this source tree, or the
  11. * BSD license below:
  12. *
  13. * Redistribution and use in source and binary forms, with or without
  14. * modification, are permitted provided that the following conditions
  15. * are met:
  16. *
  17. * 1. Redistributions of source code must retain the above copyright
  18. * notice, this list of conditions and the following disclaimer.
  19. * 2. Redistributions in binary form must reproduce the above copyright
  20. * notice, this list of conditions and the following disclaimer in
  21. * the documentation and/or other materials provided with the
  22. * distribution.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  26. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  27. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
  28. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  29. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  30. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  31. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  32. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  33. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  34. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. * Description: Slow Path Operators (header)
  37. *
  38. */
  39. #ifndef __BNXT_QPLIB_SP_H__
  40. #define __BNXT_QPLIB_SP_H__
  41. #define BNXT_QPLIB_RESERVED_QP_WRS 128
  42. #define PCI_EXP_DEVCTL2_ATOMIC_REQ 0x0040
  43. struct bnxt_qplib_dev_attr {
  44. #define FW_VER_ARR_LEN 4
  45. u8 fw_ver[FW_VER_ARR_LEN];
  46. u16 max_sgid;
  47. u16 max_mrw;
  48. u32 max_qp;
  49. #define BNXT_QPLIB_MAX_OUT_RD_ATOM 126
  50. u32 max_qp_rd_atom;
  51. u32 max_qp_init_rd_atom;
  52. u32 max_qp_wqes;
  53. u32 max_qp_sges;
  54. u32 max_cq;
  55. u32 max_cq_wqes;
  56. u32 max_cq_sges;
  57. u32 max_mr;
  58. u64 max_mr_size;
  59. u32 max_pd;
  60. u32 max_mw;
  61. u32 max_raw_ethy_qp;
  62. u32 max_ah;
  63. u32 max_fmr;
  64. u32 max_map_per_fmr;
  65. u32 max_srq;
  66. u32 max_srq_wqes;
  67. u32 max_srq_sges;
  68. u32 max_pkey;
  69. u32 max_inline_data;
  70. u32 l2_db_size;
  71. u8 tqm_alloc_reqs[MAX_TQM_ALLOC_REQ];
  72. bool is_atomic;
  73. };
  74. struct bnxt_qplib_pd {
  75. u32 id;
  76. };
  77. struct bnxt_qplib_gid {
  78. u8 data[16];
  79. };
  80. struct bnxt_qplib_ah {
  81. struct bnxt_qplib_gid dgid;
  82. struct bnxt_qplib_pd *pd;
  83. u32 id;
  84. u8 sgid_index;
  85. /* For Query AH if the hw table and SW table are differnt */
  86. u8 host_sgid_index;
  87. u8 traffic_class;
  88. u32 flow_label;
  89. u8 hop_limit;
  90. u8 sl;
  91. u8 dmac[6];
  92. u16 vlan_id;
  93. u8 nw_type;
  94. };
  95. struct bnxt_qplib_mrw {
  96. struct bnxt_qplib_pd *pd;
  97. int type;
  98. u32 flags;
  99. #define BNXT_QPLIB_FR_PMR 0x80000000
  100. u32 lkey;
  101. u32 rkey;
  102. #define BNXT_QPLIB_RSVD_LKEY 0xFFFFFFFF
  103. u64 va;
  104. u64 total_size;
  105. u32 npages;
  106. u64 mr_handle;
  107. struct bnxt_qplib_hwq hwq;
  108. };
  109. struct bnxt_qplib_frpl {
  110. int max_pg_ptrs;
  111. struct bnxt_qplib_hwq hwq;
  112. };
  113. #define BNXT_QPLIB_ACCESS_LOCAL_WRITE BIT(0)
  114. #define BNXT_QPLIB_ACCESS_REMOTE_READ BIT(1)
  115. #define BNXT_QPLIB_ACCESS_REMOTE_WRITE BIT(2)
  116. #define BNXT_QPLIB_ACCESS_REMOTE_ATOMIC BIT(3)
  117. #define BNXT_QPLIB_ACCESS_MW_BIND BIT(4)
  118. #define BNXT_QPLIB_ACCESS_ZERO_BASED BIT(5)
  119. #define BNXT_QPLIB_ACCESS_ON_DEMAND BIT(6)
  120. struct bnxt_qplib_roce_stats {
  121. u64 to_retransmits;
  122. u64 seq_err_naks_rcvd;
  123. /* seq_err_naks_rcvd is 64 b */
  124. u64 max_retry_exceeded;
  125. /* max_retry_exceeded is 64 b */
  126. u64 rnr_naks_rcvd;
  127. /* rnr_naks_rcvd is 64 b */
  128. u64 missing_resp;
  129. u64 unrecoverable_err;
  130. /* unrecoverable_err is 64 b */
  131. u64 bad_resp_err;
  132. /* bad_resp_err is 64 b */
  133. u64 local_qp_op_err;
  134. /* local_qp_op_err is 64 b */
  135. u64 local_protection_err;
  136. /* local_protection_err is 64 b */
  137. u64 mem_mgmt_op_err;
  138. /* mem_mgmt_op_err is 64 b */
  139. u64 remote_invalid_req_err;
  140. /* remote_invalid_req_err is 64 b */
  141. u64 remote_access_err;
  142. /* remote_access_err is 64 b */
  143. u64 remote_op_err;
  144. /* remote_op_err is 64 b */
  145. u64 dup_req;
  146. /* dup_req is 64 b */
  147. u64 res_exceed_max;
  148. /* res_exceed_max is 64 b */
  149. u64 res_length_mismatch;
  150. /* res_length_mismatch is 64 b */
  151. u64 res_exceeds_wqe;
  152. /* res_exceeds_wqe is 64 b */
  153. u64 res_opcode_err;
  154. /* res_opcode_err is 64 b */
  155. u64 res_rx_invalid_rkey;
  156. /* res_rx_invalid_rkey is 64 b */
  157. u64 res_rx_domain_err;
  158. /* res_rx_domain_err is 64 b */
  159. u64 res_rx_no_perm;
  160. /* res_rx_no_perm is 64 b */
  161. u64 res_rx_range_err;
  162. /* res_rx_range_err is 64 b */
  163. u64 res_tx_invalid_rkey;
  164. /* res_tx_invalid_rkey is 64 b */
  165. u64 res_tx_domain_err;
  166. /* res_tx_domain_err is 64 b */
  167. u64 res_tx_no_perm;
  168. /* res_tx_no_perm is 64 b */
  169. u64 res_tx_range_err;
  170. /* res_tx_range_err is 64 b */
  171. u64 res_irrq_oflow;
  172. /* res_irrq_oflow is 64 b */
  173. u64 res_unsup_opcode;
  174. /* res_unsup_opcode is 64 b */
  175. u64 res_unaligned_atomic;
  176. /* res_unaligned_atomic is 64 b */
  177. u64 res_rem_inv_err;
  178. /* res_rem_inv_err is 64 b */
  179. u64 res_mem_error;
  180. /* res_mem_error is 64 b */
  181. u64 res_srq_err;
  182. /* res_srq_err is 64 b */
  183. u64 res_cmp_err;
  184. /* res_cmp_err is 64 b */
  185. u64 res_invalid_dup_rkey;
  186. /* res_invalid_dup_rkey is 64 b */
  187. u64 res_wqe_format_err;
  188. /* res_wqe_format_err is 64 b */
  189. u64 res_cq_load_err;
  190. /* res_cq_load_err is 64 b */
  191. u64 res_srq_load_err;
  192. /* res_srq_load_err is 64 b */
  193. u64 res_tx_pci_err;
  194. /* res_tx_pci_err is 64 b */
  195. u64 res_rx_pci_err;
  196. /* res_rx_pci_err is 64 b */
  197. u64 res_oos_drop_count;
  198. /* res_oos_drop_count */
  199. u64 active_qp_count_p0;
  200. /* port 0 active qps */
  201. u64 active_qp_count_p1;
  202. /* port 1 active qps */
  203. u64 active_qp_count_p2;
  204. /* port 2 active qps */
  205. u64 active_qp_count_p3;
  206. /* port 3 active qps */
  207. };
  208. int bnxt_qplib_get_sgid(struct bnxt_qplib_res *res,
  209. struct bnxt_qplib_sgid_tbl *sgid_tbl, int index,
  210. struct bnxt_qplib_gid *gid);
  211. int bnxt_qplib_del_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
  212. struct bnxt_qplib_gid *gid, bool update);
  213. int bnxt_qplib_add_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
  214. struct bnxt_qplib_gid *gid, u8 *mac, u16 vlan_id,
  215. bool update, u32 *index);
  216. int bnxt_qplib_update_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
  217. struct bnxt_qplib_gid *gid, u16 gid_idx, u8 *smac);
  218. int bnxt_qplib_get_pkey(struct bnxt_qplib_res *res,
  219. struct bnxt_qplib_pkey_tbl *pkey_tbl, u16 index,
  220. u16 *pkey);
  221. int bnxt_qplib_del_pkey(struct bnxt_qplib_res *res,
  222. struct bnxt_qplib_pkey_tbl *pkey_tbl, u16 *pkey,
  223. bool update);
  224. int bnxt_qplib_add_pkey(struct bnxt_qplib_res *res,
  225. struct bnxt_qplib_pkey_tbl *pkey_tbl, u16 *pkey,
  226. bool update);
  227. int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw,
  228. struct bnxt_qplib_dev_attr *attr, bool vf);
  229. int bnxt_qplib_set_func_resources(struct bnxt_qplib_res *res,
  230. struct bnxt_qplib_rcfw *rcfw,
  231. struct bnxt_qplib_ctx *ctx);
  232. int bnxt_qplib_create_ah(struct bnxt_qplib_res *res, struct bnxt_qplib_ah *ah);
  233. int bnxt_qplib_destroy_ah(struct bnxt_qplib_res *res, struct bnxt_qplib_ah *ah);
  234. int bnxt_qplib_alloc_mrw(struct bnxt_qplib_res *res,
  235. struct bnxt_qplib_mrw *mrw);
  236. int bnxt_qplib_dereg_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mrw,
  237. bool block);
  238. int bnxt_qplib_reg_mr(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mr,
  239. u64 *pbl_tbl, int num_pbls, bool block, u32 buf_pg_size);
  240. int bnxt_qplib_free_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mr);
  241. int bnxt_qplib_alloc_fast_reg_mr(struct bnxt_qplib_res *res,
  242. struct bnxt_qplib_mrw *mr, int max);
  243. int bnxt_qplib_alloc_fast_reg_page_list(struct bnxt_qplib_res *res,
  244. struct bnxt_qplib_frpl *frpl, int max);
  245. int bnxt_qplib_free_fast_reg_page_list(struct bnxt_qplib_res *res,
  246. struct bnxt_qplib_frpl *frpl);
  247. int bnxt_qplib_map_tc2cos(struct bnxt_qplib_res *res, u16 *cids);
  248. int bnxt_qplib_get_roce_stats(struct bnxt_qplib_rcfw *rcfw,
  249. struct bnxt_qplib_roce_stats *stats);
  250. #endif /* __BNXT_QPLIB_SP_H__*/