xref: /freebsd/sys/dev/qlnx/qlnxe/ecore_cxt.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1 /*
2  * Copyright (c) 2017-2018 Cavium, Inc.
3  * All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions
7  *  are met:
8  *
9  *  1. Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  *  2. Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution.
14  *
15  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  *  POSSIBILITY OF SUCH DAMAGE.
26  *
27  */
28 
29 #ifndef _ECORE_CID_
30 #define _ECORE_CID_
31 
32 #include "ecore_hsi_common.h"
33 #include "ecore_proto_if.h"
34 #include "ecore_cxt_api.h"
35 
36 /* Tasks segments definitions  */
37 #define ECORE_CXT_ISCSI_TID_SEG			PROTOCOLID_ISCSI	/* 0 */
38 #define ECORE_CXT_FCOE_TID_SEG			PROTOCOLID_FCOE		/* 1 */
39 #define ECORE_CXT_ROCE_TID_SEG			PROTOCOLID_ROCE		/* 2 */
40 
41 enum ecore_cxt_elem_type {
42 	ECORE_ELEM_CXT,
43 	ECORE_ELEM_SRQ,
44 	ECORE_ELEM_TASK,
45 	ECORE_ELEM_XRC_SRQ,
46 };
47 
48 enum ilt_clients {
49 	ILT_CLI_CDUC,
50 	ILT_CLI_CDUT,
51 	ILT_CLI_QM,
52 	ILT_CLI_TM,
53 	ILT_CLI_SRC,
54 	ILT_CLI_TSDM,
55 	ILT_CLI_MAX
56 };
57 
58 u32 ecore_cxt_get_proto_cid_count(struct ecore_hwfn *p_hwfn,
59 				  enum protocol_type type,
60 				  u32 *vf_cid);
61 
62 u32 ecore_cxt_get_proto_tid_count(struct ecore_hwfn *p_hwfn,
63 				  enum protocol_type type);
64 
65 u32 ecore_cxt_get_proto_cid_start(struct ecore_hwfn *p_hwfn,
66 				  enum protocol_type type);
67 
68 u32 ecore_cxt_get_srq_count(struct ecore_hwfn *p_hwfn);
69 
70 u32 ecore_cxt_get_xrc_srq_count(struct ecore_hwfn *p_hwfn);
71 
72 /**
73  * @brief ecore_cxt_set_pf_params - Set the PF params for cxt init
74  *
75  * @param p_hwfn
76  *
77  * @return enum _ecore_status_t
78  */
79 enum _ecore_status_t ecore_cxt_set_pf_params(struct ecore_hwfn *p_hwfn,
80 					     u32 rdma_tasks);
81 
82 /**
83  * @brief ecore_cxt_cfg_ilt_compute - compute ILT init parameters
84  *
85  * @param p_hwfn
86  * @param last_line
87  *
88  * @return enum _ecore_status_t
89  */
90 enum _ecore_status_t ecore_cxt_cfg_ilt_compute(struct ecore_hwfn *p_hwfn,
91 					       u32 *last_line);
92 
93 /**
94  * @brief ecore_cxt_cfg_ilt_compute_excess - how many lines can be decreased
95  *
96  * @param p_hwfn
97  * @param used_lines
98  */
99 u32 ecore_cxt_cfg_ilt_compute_excess(struct ecore_hwfn *p_hwfn, u32 used_lines);
100 
101 /**
102  * @brief ecore_cxt_mngr_alloc - Allocate and init the context manager struct
103  *
104  * @param p_hwfn
105  *
106  * @return enum _ecore_status_t
107  */
108 enum _ecore_status_t ecore_cxt_mngr_alloc(struct ecore_hwfn *p_hwfn);
109 
110 /**
111  * @brief ecore_cxt_mngr_free
112  *
113  * @param p_hwfn
114  */
115 void ecore_cxt_mngr_free(struct ecore_hwfn *p_hwfn);
116 
117 /**
118  * @brief ecore_cxt_tables_alloc - Allocate ILT shadow, Searcher T2, acquired map
119  *
120  * @param p_hwfn
121  *
122  * @return enum _ecore_status_t
123  */
124 enum _ecore_status_t ecore_cxt_tables_alloc(struct ecore_hwfn *p_hwfn);
125 
126 /**
127  * @brief ecore_cxt_mngr_setup - Reset the acquired CIDs
128  *
129  * @param p_hwfn
130  */
131 void ecore_cxt_mngr_setup(struct ecore_hwfn *p_hwfn);
132 
133 /**
134  * @brief ecore_cxt_hw_init_common - Initailze ILT and DQ, common phase, per path.
135  *
136  * @param p_hwfn
137  */
138 void ecore_cxt_hw_init_common(struct ecore_hwfn *p_hwfn);
139 
140 /**
141  * @brief ecore_cxt_hw_init_pf - Initailze ILT and DQ, PF phase, per path.
142  *
143  * @param p_hwfn
144  * @param p_ptt
145  */
146 void ecore_cxt_hw_init_pf(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt);
147 
148 /**
149  * @brief ecore_qm_init_pf - Initailze the QM PF phase, per path
150  *
151  * @param p_hwfn
152  * @param p_ptt
153  * @param is_pf_loading
154  */
155 void ecore_qm_init_pf(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
156 		      bool is_pf_loading);
157 
158  /**
159  * @brief Reconfigures QM pf on the fly
160  *
161  * @param p_hwfn
162  * @param p_ptt
163  *
164  * @return enum _ecore_status_t
165  */
166 enum _ecore_status_t ecore_qm_reconf(struct ecore_hwfn *p_hwfn,
167 				     struct ecore_ptt *p_ptt);
168 
169 #define ECORE_CXT_PF_CID (0xff)
170 
171 /**
172  * @brief ecore_cxt_release - Release a cid
173  *
174  * @param p_hwfn
175  * @param cid
176  */
177 void ecore_cxt_release_cid(struct ecore_hwfn *p_hwfn, u32 cid);
178 
179 /**
180  * @brief ecore_cxt_release - Release a cid belonging to a vf-queue
181  *
182  * @param p_hwfn
183  * @param cid
184  * @param vfid - engine relative index. ECORE_CXT_PF_CID if belongs to PF
185  */
186 void _ecore_cxt_release_cid(struct ecore_hwfn *p_hwfn,
187 			    u32 cid, u8 vfid);
188 
189 /**
190  * @brief ecore_cxt_acquire - Acquire a new cid of a specific protocol type
191  *
192  * @param p_hwfn
193  * @param type
194  * @param p_cid
195  *
196  * @return enum _ecore_status_t
197  */
198 enum _ecore_status_t ecore_cxt_acquire_cid(struct ecore_hwfn *p_hwfn,
199 					   enum protocol_type type,
200 					   u32 *p_cid);
201 
202 /**
203  * @brief _ecore_cxt_acquire - Acquire a new cid of a specific protocol type
204  *                             for a vf-queue
205  *
206  * @param p_hwfn
207  * @param type
208  * @param p_cid
209  * @param vfid - engine relative index. ECORE_CXT_PF_CID if belongs to PF
210  *
211  * @return enum _ecore_status_t
212  */
213 enum _ecore_status_t _ecore_cxt_acquire_cid(struct ecore_hwfn *p_hwfn,
214 					    enum protocol_type type,
215 					    u32 *p_cid, u8 vfid);
216 
217 /**
218  * @brief ecore_cxt_get_tid_mem_info - function checks if the
219  *        page containing the iid in the ilt is already
220  *        allocated, if it is not it allocates the page.
221  *
222  * @param p_hwfn
223  * @param elem_type
224  * @param iid
225  *
226  * @return enum _ecore_status_t
227  */
228 enum _ecore_status_t
229 ecore_cxt_dynamic_ilt_alloc(struct ecore_hwfn *p_hwfn,
230 			    enum ecore_cxt_elem_type elem_type,
231 			    u32 iid);
232 
233 /**
234  * @brief ecore_cxt_free_ilt_range - function frees ilt pages
235  *        associated with the protocol and element type passed.
236  *
237  * @param p_hwfn
238  * @param proto
239  *
240  * @return enum _ecore_status_t
241  */
242 enum _ecore_status_t
243 ecore_cxt_free_ilt_range(struct ecore_hwfn *p_hwfn,
244 			 enum ecore_cxt_elem_type elem_type,
245 			 u32 start_iid, u32 count);
246 
247 #define ECORE_CTX_WORKING_MEM 0
248 #define ECORE_CTX_FL_MEM 1
249 enum _ecore_status_t ecore_cxt_get_task_ctx(struct ecore_hwfn *p_hwfn,
250 					    u32 tid,
251 					    u8 ctx_type,
252 					    void **task_ctx);
253 
254 u32 ecore_cxt_get_ilt_page_size(struct ecore_hwfn *p_hwfn,
255 				enum ilt_clients ilt_client);
256 
257 u32 ecore_cxt_get_total_srq_count(struct ecore_hwfn *p_hwfn);
258 
259 #endif /* _ECORE_CID_ */
260