1*14b24e2bSVaishali Kulkarni /*
2*14b24e2bSVaishali Kulkarni * CDDL HEADER START
3*14b24e2bSVaishali Kulkarni *
4*14b24e2bSVaishali Kulkarni * The contents of this file are subject to the terms of the
5*14b24e2bSVaishali Kulkarni * Common Development and Distribution License, v.1,  (the "License").
6*14b24e2bSVaishali Kulkarni * You may not use this file except in compliance with the License.
7*14b24e2bSVaishali Kulkarni *
8*14b24e2bSVaishali Kulkarni * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*14b24e2bSVaishali Kulkarni * or http://opensource.org/licenses/CDDL-1.0.
10*14b24e2bSVaishali Kulkarni * See the License for the specific language governing permissions
11*14b24e2bSVaishali Kulkarni * and limitations under the License.
12*14b24e2bSVaishali Kulkarni *
13*14b24e2bSVaishali Kulkarni * When distributing Covered Code, include this CDDL HEADER in each
14*14b24e2bSVaishali Kulkarni * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*14b24e2bSVaishali Kulkarni * If applicable, add the following below this CDDL HEADER, with the
16*14b24e2bSVaishali Kulkarni * fields enclosed by brackets "[]" replaced with your own identifying
17*14b24e2bSVaishali Kulkarni * information: Portions Copyright [yyyy] [name of copyright owner]
18*14b24e2bSVaishali Kulkarni *
19*14b24e2bSVaishali Kulkarni * CDDL HEADER END
20*14b24e2bSVaishali Kulkarni */
21*14b24e2bSVaishali Kulkarni 
22*14b24e2bSVaishali Kulkarni /*
23*14b24e2bSVaishali Kulkarni * Copyright 2014-2017 Cavium, Inc.
24*14b24e2bSVaishali Kulkarni * The contents of this file are subject to the terms of the Common Development
25*14b24e2bSVaishali Kulkarni * and Distribution License, v.1,  (the "License").
26*14b24e2bSVaishali Kulkarni 
27*14b24e2bSVaishali Kulkarni * You may not use this file except in compliance with the License.
28*14b24e2bSVaishali Kulkarni 
29*14b24e2bSVaishali Kulkarni * You can obtain a copy of the License at available
30*14b24e2bSVaishali Kulkarni * at http://opensource.org/licenses/CDDL-1.0
31*14b24e2bSVaishali Kulkarni 
32*14b24e2bSVaishali Kulkarni * See the License for the specific language governing permissions and
33*14b24e2bSVaishali Kulkarni * limitations under the License.
34*14b24e2bSVaishali Kulkarni */
35*14b24e2bSVaishali Kulkarni 
36*14b24e2bSVaishali Kulkarni #ifndef _ECORE_CID_
37*14b24e2bSVaishali Kulkarni #define _ECORE_CID_
38*14b24e2bSVaishali Kulkarni 
39*14b24e2bSVaishali Kulkarni #include "ecore_hsi_common.h"
40*14b24e2bSVaishali Kulkarni #include "ecore_proto_if.h"
41*14b24e2bSVaishali Kulkarni #include "ecore_cxt_api.h"
42*14b24e2bSVaishali Kulkarni 
43*14b24e2bSVaishali Kulkarni /* Tasks segments definitions  */
44*14b24e2bSVaishali Kulkarni #define ECORE_CXT_ISCSI_TID_SEG			PROTOCOLID_ISCSI	/* 0 */
45*14b24e2bSVaishali Kulkarni #define ECORE_CXT_FCOE_TID_SEG			PROTOCOLID_FCOE		/* 1 */
46*14b24e2bSVaishali Kulkarni #define ECORE_CXT_ROCE_TID_SEG			PROTOCOLID_ROCE		/* 2 */
47*14b24e2bSVaishali Kulkarni 
48*14b24e2bSVaishali Kulkarni enum ecore_cxt_elem_type {
49*14b24e2bSVaishali Kulkarni 	ECORE_ELEM_CXT,
50*14b24e2bSVaishali Kulkarni 	ECORE_ELEM_SRQ,
51*14b24e2bSVaishali Kulkarni 	ECORE_ELEM_TASK
52*14b24e2bSVaishali Kulkarni };
53*14b24e2bSVaishali Kulkarni 
54*14b24e2bSVaishali Kulkarni u32 ecore_cxt_get_proto_cid_count(struct ecore_hwfn *p_hwfn,
55*14b24e2bSVaishali Kulkarni 				  enum protocol_type type,
56*14b24e2bSVaishali Kulkarni 				  u32 *vf_cid);
57*14b24e2bSVaishali Kulkarni 
58*14b24e2bSVaishali Kulkarni u32 ecore_cxt_get_proto_tid_count(struct ecore_hwfn *p_hwfn,
59*14b24e2bSVaishali Kulkarni 				  enum protocol_type type);
60*14b24e2bSVaishali Kulkarni 
61*14b24e2bSVaishali Kulkarni u32 ecore_cxt_get_proto_cid_start(struct ecore_hwfn *p_hwfn,
62*14b24e2bSVaishali Kulkarni 				  enum protocol_type type);
63*14b24e2bSVaishali Kulkarni u32 ecore_cxt_get_srq_count(struct ecore_hwfn *p_hwfn);
64*14b24e2bSVaishali Kulkarni 
65*14b24e2bSVaishali Kulkarni /**
66*14b24e2bSVaishali Kulkarni  * @brief ecore_cxt_set_pf_params - Set the PF params for cxt init
67*14b24e2bSVaishali Kulkarni  *
68*14b24e2bSVaishali Kulkarni  * @param p_hwfn
69*14b24e2bSVaishali Kulkarni  *
70*14b24e2bSVaishali Kulkarni  * @return enum _ecore_status_t
71*14b24e2bSVaishali Kulkarni  */
72*14b24e2bSVaishali Kulkarni enum _ecore_status_t ecore_cxt_set_pf_params(struct ecore_hwfn *p_hwfn,
73*14b24e2bSVaishali Kulkarni 					     u32 rdma_tasks);
74*14b24e2bSVaishali Kulkarni 
75*14b24e2bSVaishali Kulkarni /**
76*14b24e2bSVaishali Kulkarni  * @brief ecore_cxt_cfg_ilt_compute - compute ILT init parameters
77*14b24e2bSVaishali Kulkarni  *
78*14b24e2bSVaishali Kulkarni  * @param p_hwfn
79*14b24e2bSVaishali Kulkarni  * @param last_line
80*14b24e2bSVaishali Kulkarni  *
81*14b24e2bSVaishali Kulkarni  * @return enum _ecore_status_t
82*14b24e2bSVaishali Kulkarni  */
83*14b24e2bSVaishali Kulkarni enum _ecore_status_t ecore_cxt_cfg_ilt_compute(struct ecore_hwfn *p_hwfn,
84*14b24e2bSVaishali Kulkarni 					       u32 *last_line);
85*14b24e2bSVaishali Kulkarni 
86*14b24e2bSVaishali Kulkarni /**
87*14b24e2bSVaishali Kulkarni  * @brief ecore_cxt_cfg_ilt_compute_excess - how many lines can be decreased
88*14b24e2bSVaishali Kulkarni  *
89*14b24e2bSVaishali Kulkarni  * @param p_hwfn
90*14b24e2bSVaishali Kulkarni  * @param used_lines
91*14b24e2bSVaishali Kulkarni  */
92*14b24e2bSVaishali Kulkarni u32 ecore_cxt_cfg_ilt_compute_excess(struct ecore_hwfn *p_hwfn, u32 used_lines);
93*14b24e2bSVaishali Kulkarni 
94*14b24e2bSVaishali Kulkarni /**
95*14b24e2bSVaishali Kulkarni  * @brief ecore_cxt_mngr_alloc - Allocate and init the context manager struct
96*14b24e2bSVaishali Kulkarni  *
97*14b24e2bSVaishali Kulkarni  * @param p_hwfn
98*14b24e2bSVaishali Kulkarni  *
99*14b24e2bSVaishali Kulkarni  * @return enum _ecore_status_t
100*14b24e2bSVaishali Kulkarni  */
101*14b24e2bSVaishali Kulkarni enum _ecore_status_t ecore_cxt_mngr_alloc(struct ecore_hwfn *p_hwfn);
102*14b24e2bSVaishali Kulkarni 
103*14b24e2bSVaishali Kulkarni /**
104*14b24e2bSVaishali Kulkarni  * @brief ecore_cxt_mngr_free
105*14b24e2bSVaishali Kulkarni  *
106*14b24e2bSVaishali Kulkarni  * @param p_hwfn
107*14b24e2bSVaishali Kulkarni  */
108*14b24e2bSVaishali Kulkarni void ecore_cxt_mngr_free(struct ecore_hwfn *p_hwfn);
109*14b24e2bSVaishali Kulkarni 
110*14b24e2bSVaishali Kulkarni /**
111*14b24e2bSVaishali Kulkarni  * @brief ecore_cxt_tables_alloc - Allocate ILT shadow, Searcher T2, acquired map
112*14b24e2bSVaishali Kulkarni  *
113*14b24e2bSVaishali Kulkarni  * @param p_hwfn
114*14b24e2bSVaishali Kulkarni  *
115*14b24e2bSVaishali Kulkarni  * @return enum _ecore_status_t
116*14b24e2bSVaishali Kulkarni  */
117*14b24e2bSVaishali Kulkarni enum _ecore_status_t ecore_cxt_tables_alloc(struct ecore_hwfn *p_hwfn);
118*14b24e2bSVaishali Kulkarni 
119*14b24e2bSVaishali Kulkarni /**
120*14b24e2bSVaishali Kulkarni  * @brief ecore_cxt_mngr_setup - Reset the acquired CIDs
121*14b24e2bSVaishali Kulkarni  *
122*14b24e2bSVaishali Kulkarni  * @param p_hwfn
123*14b24e2bSVaishali Kulkarni  */
124*14b24e2bSVaishali Kulkarni void ecore_cxt_mngr_setup(struct ecore_hwfn *p_hwfn);
125*14b24e2bSVaishali Kulkarni 
126*14b24e2bSVaishali Kulkarni /**
127*14b24e2bSVaishali Kulkarni  * @brief ecore_cxt_hw_init_common - Initailze ILT and DQ, common phase, per path.
128*14b24e2bSVaishali Kulkarni  *
129*14b24e2bSVaishali Kulkarni  * @param p_hwfn
130*14b24e2bSVaishali Kulkarni  */
131*14b24e2bSVaishali Kulkarni void ecore_cxt_hw_init_common(struct ecore_hwfn *p_hwfn);
132*14b24e2bSVaishali Kulkarni 
133*14b24e2bSVaishali Kulkarni /**
134*14b24e2bSVaishali Kulkarni  * @brief ecore_cxt_hw_init_pf - Initailze ILT and DQ, PF phase, per path.
135*14b24e2bSVaishali Kulkarni  *
136*14b24e2bSVaishali Kulkarni  * @param p_hwfn
137*14b24e2bSVaishali Kulkarni  */
138*14b24e2bSVaishali Kulkarni void ecore_cxt_hw_init_pf(struct ecore_hwfn *p_hwfn);
139*14b24e2bSVaishali Kulkarni 
140*14b24e2bSVaishali Kulkarni /**
141*14b24e2bSVaishali Kulkarni  * @brief ecore_qm_init_pf - Initailze the QM PF phase, per path
142*14b24e2bSVaishali Kulkarni  *
143*14b24e2bSVaishali Kulkarni  * @param p_hwfn
144*14b24e2bSVaishali Kulkarni  */
145*14b24e2bSVaishali Kulkarni void ecore_qm_init_pf(struct ecore_hwfn *p_hwfn);
146*14b24e2bSVaishali Kulkarni 
147*14b24e2bSVaishali Kulkarni  /**
148*14b24e2bSVaishali Kulkarni  * @brief Reconfigures QM pf on the fly
149*14b24e2bSVaishali Kulkarni  *
150*14b24e2bSVaishali Kulkarni  * @param p_hwfn
151*14b24e2bSVaishali Kulkarni  * @param p_ptt
152*14b24e2bSVaishali Kulkarni  *
153*14b24e2bSVaishali Kulkarni  * @return enum _ecore_status_t
154*14b24e2bSVaishali Kulkarni  */
155*14b24e2bSVaishali Kulkarni enum _ecore_status_t ecore_qm_reconf(struct ecore_hwfn *p_hwfn,
156*14b24e2bSVaishali Kulkarni 				     struct ecore_ptt *p_ptt);
157*14b24e2bSVaishali Kulkarni 
158*14b24e2bSVaishali Kulkarni #define ECORE_CXT_PF_CID (0xff)
159*14b24e2bSVaishali Kulkarni 
160*14b24e2bSVaishali Kulkarni /**
161*14b24e2bSVaishali Kulkarni  * @brief ecore_cxt_release - Release a cid
162*14b24e2bSVaishali Kulkarni  *
163*14b24e2bSVaishali Kulkarni  * @param p_hwfn
164*14b24e2bSVaishali Kulkarni  * @param cid
165*14b24e2bSVaishali Kulkarni  */
166*14b24e2bSVaishali Kulkarni void ecore_cxt_release_cid(struct ecore_hwfn *p_hwfn, u32 cid);
167*14b24e2bSVaishali Kulkarni 
168*14b24e2bSVaishali Kulkarni /**
169*14b24e2bSVaishali Kulkarni  * @brief ecore_cxt_release - Release a cid belonging to a vf-queue
170*14b24e2bSVaishali Kulkarni  *
171*14b24e2bSVaishali Kulkarni  * @param p_hwfn
172*14b24e2bSVaishali Kulkarni  * @param cid
173*14b24e2bSVaishali Kulkarni  * @param vfid - engine relative index. ECORE_CXT_PF_CID if belongs to PF
174*14b24e2bSVaishali Kulkarni  */
175*14b24e2bSVaishali Kulkarni void _ecore_cxt_release_cid(struct ecore_hwfn *p_hwfn,
176*14b24e2bSVaishali Kulkarni 			    u32 cid, u8 vfid);
177*14b24e2bSVaishali Kulkarni 
178*14b24e2bSVaishali Kulkarni /**
179*14b24e2bSVaishali Kulkarni  * @brief ecore_cxt_acquire - Acquire a new cid of a specific protocol type
180*14b24e2bSVaishali Kulkarni  *
181*14b24e2bSVaishali Kulkarni  * @param p_hwfn
182*14b24e2bSVaishali Kulkarni  * @param type
183*14b24e2bSVaishali Kulkarni  * @param p_cid
184*14b24e2bSVaishali Kulkarni  *
185*14b24e2bSVaishali Kulkarni  * @return enum _ecore_status_t
186*14b24e2bSVaishali Kulkarni  */
187*14b24e2bSVaishali Kulkarni enum _ecore_status_t ecore_cxt_acquire_cid(struct ecore_hwfn *p_hwfn,
188*14b24e2bSVaishali Kulkarni 					   enum protocol_type type,
189*14b24e2bSVaishali Kulkarni 					   u32 *p_cid);
190*14b24e2bSVaishali Kulkarni 
191*14b24e2bSVaishali Kulkarni /**
192*14b24e2bSVaishali Kulkarni  * @brief _ecore_cxt_acquire - Acquire a new cid of a specific protocol type
193*14b24e2bSVaishali Kulkarni  *                             for a vf-queue
194*14b24e2bSVaishali Kulkarni  *
195*14b24e2bSVaishali Kulkarni  * @param p_hwfn
196*14b24e2bSVaishali Kulkarni  * @param type
197*14b24e2bSVaishali Kulkarni  * @param p_cid
198*14b24e2bSVaishali Kulkarni  * @param vfid - engine relative index. ECORE_CXT_PF_CID if belongs to PF
199*14b24e2bSVaishali Kulkarni  *
200*14b24e2bSVaishali Kulkarni  * @return enum _ecore_status_t
201*14b24e2bSVaishali Kulkarni  */
202*14b24e2bSVaishali Kulkarni enum _ecore_status_t _ecore_cxt_acquire_cid(struct ecore_hwfn *p_hwfn,
203*14b24e2bSVaishali Kulkarni 					    enum protocol_type type,
204*14b24e2bSVaishali Kulkarni 					    u32 *p_cid, u8 vfid);
205*14b24e2bSVaishali Kulkarni 
206*14b24e2bSVaishali Kulkarni /**
207*14b24e2bSVaishali Kulkarni  * @brief ecore_cxt_get_tid_mem_info - function checks if the
208*14b24e2bSVaishali Kulkarni  *        page containing the iid in the ilt is already
209*14b24e2bSVaishali Kulkarni  *        allocated, if it is not it allocates the page.
210*14b24e2bSVaishali Kulkarni  *
211*14b24e2bSVaishali Kulkarni  * @param p_hwfn
212*14b24e2bSVaishali Kulkarni  * @param elem_type
213*14b24e2bSVaishali Kulkarni  * @param iid
214*14b24e2bSVaishali Kulkarni  *
215*14b24e2bSVaishali Kulkarni  * @return enum _ecore_status_t
216*14b24e2bSVaishali Kulkarni  */
217*14b24e2bSVaishali Kulkarni enum _ecore_status_t
218*14b24e2bSVaishali Kulkarni ecore_cxt_dynamic_ilt_alloc(struct ecore_hwfn *p_hwfn,
219*14b24e2bSVaishali Kulkarni 			    enum ecore_cxt_elem_type elem_type,
220*14b24e2bSVaishali Kulkarni 			    u32 iid);
221*14b24e2bSVaishali Kulkarni 
222*14b24e2bSVaishali Kulkarni /**
223*14b24e2bSVaishali Kulkarni  * @brief ecore_cxt_free_ilt_range - function frees ilt pages
224*14b24e2bSVaishali Kulkarni  *        associated with the protocol and element type passed.
225*14b24e2bSVaishali Kulkarni  *
226*14b24e2bSVaishali Kulkarni  * @param p_hwfn
227*14b24e2bSVaishali Kulkarni  * @param proto
228*14b24e2bSVaishali Kulkarni  *
229*14b24e2bSVaishali Kulkarni  * @return enum _ecore_status_t
230*14b24e2bSVaishali Kulkarni  */
231*14b24e2bSVaishali Kulkarni enum _ecore_status_t
232*14b24e2bSVaishali Kulkarni ecore_cxt_free_ilt_range(struct ecore_hwfn *p_hwfn,
233*14b24e2bSVaishali Kulkarni 			 enum ecore_cxt_elem_type elem_type,
234*14b24e2bSVaishali Kulkarni 			 u32 start_iid, u32 count);
235*14b24e2bSVaishali Kulkarni 
236*14b24e2bSVaishali Kulkarni #define ECORE_CTX_WORKING_MEM 0
237*14b24e2bSVaishali Kulkarni #define ECORE_CTX_FL_MEM 1
238*14b24e2bSVaishali Kulkarni enum _ecore_status_t ecore_cxt_get_task_ctx(struct ecore_hwfn *p_hwfn,
239*14b24e2bSVaishali Kulkarni 					    u32 tid,
240*14b24e2bSVaishali Kulkarni 					    u8 ctx_type,
241*14b24e2bSVaishali Kulkarni 					    void **task_ctx);
242*14b24e2bSVaishali Kulkarni 
243*14b24e2bSVaishali Kulkarni #endif /* _ECORE_CID_ */