qed_cxt.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /* QLogic qed NIC Driver
  2. * Copyright (c) 2015-2017 QLogic Corporation
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * OpenIB.org BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and /or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. */
  32. #ifndef _QED_CXT_H
  33. #define _QED_CXT_H
  34. #include <linux/types.h>
  35. #include <linux/slab.h>
  36. #include <linux/qed/qed_if.h>
  37. #include "qed_hsi.h"
  38. #include "qed.h"
  39. struct qed_cxt_info {
  40. void *p_cxt;
  41. u32 iid;
  42. enum protocol_type type;
  43. };
  44. #define MAX_TID_BLOCKS 512
  45. struct qed_tid_mem {
  46. u32 tid_size;
  47. u32 num_tids_per_block;
  48. u32 waste;
  49. u8 *blocks[MAX_TID_BLOCKS]; /* 4K */
  50. };
  51. /**
  52. * @brief qedo_cid_get_cxt_info - Returns the context info for a specific cid
  53. *
  54. *
  55. * @param p_hwfn
  56. * @param p_info in/out
  57. *
  58. * @return int
  59. */
  60. int qed_cxt_get_cid_info(struct qed_hwfn *p_hwfn,
  61. struct qed_cxt_info *p_info);
  62. /**
  63. * @brief qed_cxt_get_tid_mem_info
  64. *
  65. * @param p_hwfn
  66. * @param p_info
  67. *
  68. * @return int
  69. */
  70. int qed_cxt_get_tid_mem_info(struct qed_hwfn *p_hwfn,
  71. struct qed_tid_mem *p_info);
  72. #define QED_CXT_ISCSI_TID_SEG PROTOCOLID_ISCSI
  73. #define QED_CXT_ROCE_TID_SEG PROTOCOLID_ROCE
  74. #define QED_CXT_FCOE_TID_SEG PROTOCOLID_FCOE
  75. enum qed_cxt_elem_type {
  76. QED_ELEM_CXT,
  77. QED_ELEM_SRQ,
  78. QED_ELEM_TASK
  79. };
  80. u32 qed_cxt_get_proto_cid_count(struct qed_hwfn *p_hwfn,
  81. enum protocol_type type, u32 *vf_cid);
  82. /**
  83. * @brief qed_cxt_set_pf_params - Set the PF params for cxt init
  84. *
  85. * @param p_hwfn
  86. * @param rdma_tasks - requested maximum
  87. * @return int
  88. */
  89. int qed_cxt_set_pf_params(struct qed_hwfn *p_hwfn, u32 rdma_tasks);
  90. /**
  91. * @brief qed_cxt_cfg_ilt_compute - compute ILT init parameters
  92. *
  93. * @param p_hwfn
  94. * @param last_line
  95. *
  96. * @return int
  97. */
  98. int qed_cxt_cfg_ilt_compute(struct qed_hwfn *p_hwfn, u32 *last_line);
  99. /**
  100. * @brief qed_cxt_cfg_ilt_compute_excess - how many lines can be decreased
  101. *
  102. * @param p_hwfn
  103. * @param used_lines
  104. */
  105. u32 qed_cxt_cfg_ilt_compute_excess(struct qed_hwfn *p_hwfn, u32 used_lines);
  106. /**
  107. * @brief qed_cxt_mngr_alloc - Allocate and init the context manager struct
  108. *
  109. * @param p_hwfn
  110. *
  111. * @return int
  112. */
  113. int qed_cxt_mngr_alloc(struct qed_hwfn *p_hwfn);
  114. /**
  115. * @brief qed_cxt_mngr_free
  116. *
  117. * @param p_hwfn
  118. */
  119. void qed_cxt_mngr_free(struct qed_hwfn *p_hwfn);
  120. /**
  121. * @brief qed_cxt_tables_alloc - Allocate ILT shadow, Searcher T2, acquired map
  122. *
  123. * @param p_hwfn
  124. *
  125. * @return int
  126. */
  127. int qed_cxt_tables_alloc(struct qed_hwfn *p_hwfn);
  128. /**
  129. * @brief qed_cxt_mngr_setup - Reset the acquired CIDs
  130. *
  131. * @param p_hwfn
  132. */
  133. void qed_cxt_mngr_setup(struct qed_hwfn *p_hwfn);
  134. /**
  135. * @brief qed_cxt_hw_init_common - Initailze ILT and DQ, common phase, per path.
  136. *
  137. *
  138. *
  139. * @param p_hwfn
  140. */
  141. void qed_cxt_hw_init_common(struct qed_hwfn *p_hwfn);
  142. /**
  143. * @brief qed_cxt_hw_init_pf - Initailze ILT and DQ, PF phase, per path.
  144. *
  145. * @param p_hwfn
  146. * @param p_ptt
  147. */
  148. void qed_cxt_hw_init_pf(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
  149. /**
  150. * @brief qed_qm_init_pf - Initailze the QM PF phase, per path
  151. *
  152. * @param p_hwfn
  153. * @param p_ptt
  154. * @param is_pf_loading
  155. */
  156. void qed_qm_init_pf(struct qed_hwfn *p_hwfn,
  157. struct qed_ptt *p_ptt, bool is_pf_loading);
  158. /**
  159. * @brief Reconfigures QM pf on the fly
  160. *
  161. * @param p_hwfn
  162. * @param p_ptt
  163. *
  164. * @return int
  165. */
  166. int qed_qm_reconf(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
  167. #define QED_CXT_PF_CID (0xff)
  168. /**
  169. * @brief qed_cxt_release - Release a cid
  170. *
  171. * @param p_hwfn
  172. * @param cid
  173. */
  174. void qed_cxt_release_cid(struct qed_hwfn *p_hwfn, u32 cid);
  175. /**
  176. * @brief qed_cxt_release - Release a cid belonging to a vf-queue
  177. *
  178. * @param p_hwfn
  179. * @param cid
  180. * @param vfid - engine relative index. QED_CXT_PF_CID if belongs to PF
  181. */
  182. void _qed_cxt_release_cid(struct qed_hwfn *p_hwfn, u32 cid, u8 vfid);
  183. /**
  184. * @brief qed_cxt_acquire - Acquire a new cid of a specific protocol type
  185. *
  186. * @param p_hwfn
  187. * @param type
  188. * @param p_cid
  189. *
  190. * @return int
  191. */
  192. int qed_cxt_acquire_cid(struct qed_hwfn *p_hwfn,
  193. enum protocol_type type, u32 *p_cid);
  194. /**
  195. * @brief _qed_cxt_acquire - Acquire a new cid of a specific protocol type
  196. * for a vf-queue
  197. *
  198. * @param p_hwfn
  199. * @param type
  200. * @param p_cid
  201. * @param vfid - engine relative index. QED_CXT_PF_CID if belongs to PF
  202. *
  203. * @return int
  204. */
  205. int _qed_cxt_acquire_cid(struct qed_hwfn *p_hwfn,
  206. enum protocol_type type, u32 *p_cid, u8 vfid);
  207. int qed_cxt_dynamic_ilt_alloc(struct qed_hwfn *p_hwfn,
  208. enum qed_cxt_elem_type elem_type, u32 iid);
  209. u32 qed_cxt_get_proto_tid_count(struct qed_hwfn *p_hwfn,
  210. enum protocol_type type);
  211. u32 qed_cxt_get_proto_cid_start(struct qed_hwfn *p_hwfn,
  212. enum protocol_type type);
  213. u32 qed_cxt_get_srq_count(struct qed_hwfn *p_hwfn);
  214. int qed_cxt_free_proto_ilt(struct qed_hwfn *p_hwfn, enum protocol_type proto);
  215. #define QED_CTX_WORKING_MEM 0
  216. #define QED_CTX_FL_MEM 1
  217. int qed_cxt_get_task_ctx(struct qed_hwfn *p_hwfn,
  218. u32 tid, u8 ctx_type, void **task_ctx);
  219. #endif