mempool: introduce helpers for populate and required size
[dpdk.git] / drivers / net / qede / base / ecore_cxt.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2016 - 2018 Cavium Inc.
3  * All rights reserved.
4  * www.cavium.com
5  */
6
7 #ifndef _ECORE_CID_
8 #define _ECORE_CID_
9
10 #include "ecore_hsi_common.h"
11 #include "ecore_proto_if.h"
12 #include "ecore_cxt_api.h"
13
14 /* Tasks segments definitions  */
15 #define ECORE_CXT_ISCSI_TID_SEG                 PROTOCOLID_ISCSI        /* 0 */
16 #define ECORE_CXT_FCOE_TID_SEG                  PROTOCOLID_FCOE         /* 1 */
17 #define ECORE_CXT_ROCE_TID_SEG                  PROTOCOLID_ROCE         /* 2 */
18
19 enum ecore_cxt_elem_type {
20         ECORE_ELEM_CXT,
21         ECORE_ELEM_SRQ,
22         ECORE_ELEM_TASK
23 };
24
25 enum ilt_clients {
26         ILT_CLI_CDUC,
27         ILT_CLI_CDUT,
28         ILT_CLI_QM,
29         ILT_CLI_TM,
30         ILT_CLI_SRC,
31         ILT_CLI_TSDM,
32         ILT_CLI_RGFS,
33         ILT_CLI_TGFS,
34         ILT_CLI_MAX
35 };
36
37 u32 ecore_cxt_get_proto_cid_count(struct ecore_hwfn *p_hwfn,
38                                   enum protocol_type type,
39                                   u32 *vf_cid);
40
41 u32 ecore_cxt_get_proto_tid_count(struct ecore_hwfn *p_hwfn,
42                                   enum protocol_type type);
43
44 u32 ecore_cxt_get_proto_cid_start(struct ecore_hwfn *p_hwfn,
45                                   enum protocol_type type);
46 u32 ecore_cxt_get_srq_count(struct ecore_hwfn *p_hwfn);
47
48 /**
49  * @brief ecore_cxt_set_pf_params - Set the PF params for cxt init
50  *
51  * @param p_hwfn
52  *
53  * @return enum _ecore_status_t
54  */
55 enum _ecore_status_t ecore_cxt_set_pf_params(struct ecore_hwfn *p_hwfn);
56
57 /**
58  * @brief ecore_cxt_cfg_ilt_compute - compute ILT init parameters
59  *
60  * @param p_hwfn
61  *
62  * @return enum _ecore_status_t
63  */
64 enum _ecore_status_t ecore_cxt_cfg_ilt_compute(struct ecore_hwfn *p_hwfn);
65
66 /**
67  * @brief ecore_cxt_mngr_alloc - Allocate and init the context manager struct
68  *
69  * @param p_hwfn
70  *
71  * @return enum _ecore_status_t
72  */
73 enum _ecore_status_t ecore_cxt_mngr_alloc(struct ecore_hwfn *p_hwfn);
74
75 /**
76  * @brief ecore_cxt_mngr_free
77  *
78  * @param p_hwfn
79  */
80 void ecore_cxt_mngr_free(struct ecore_hwfn *p_hwfn);
81
82 /**
83  * @brief ecore_cxt_tables_alloc - Allocate ILT shadow, Searcher T2, acquired
84  *        map
85  *
86  * @param p_hwfn
87  *
88  * @return enum _ecore_status_t
89  */
90 enum _ecore_status_t ecore_cxt_tables_alloc(struct ecore_hwfn *p_hwfn);
91
92 /**
93  * @brief ecore_cxt_mngr_setup - Reset the acquired CIDs
94  *
95  * @param p_hwfn
96  */
97 void ecore_cxt_mngr_setup(struct ecore_hwfn *p_hwfn);
98
99 /**
100  * @brief ecore_cxt_hw_init_common - Initailze ILT and DQ, common phase, per
101  *        path.
102  *
103  * @param p_hwfn
104  */
105 void ecore_cxt_hw_init_common(struct ecore_hwfn *p_hwfn);
106
107 /**
108  * @brief ecore_cxt_hw_init_pf - Initailze ILT and DQ, PF phase, per path.
109  *
110  * @param p_hwfn
111  * @param p_ptt
112  */
113 void ecore_cxt_hw_init_pf(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt);
114
115 /**
116  * @brief ecore_qm_init_pf - Initailze the QM PF phase, per path
117  *
118  * @param p_hwfn
119  * @param p_ptt
120  * @param is_pf_loading
121  */
122 void ecore_qm_init_pf(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
123                       bool is_pf_loading);
124
125  /**
126  * @brief Reconfigures QM pf on the fly
127  *
128  * @param p_hwfn
129  * @param p_ptt
130  *
131  * @return enum _ecore_status_t
132  */
133 enum _ecore_status_t ecore_qm_reconf(struct ecore_hwfn *p_hwfn,
134                                      struct ecore_ptt *p_ptt);
135
136 #define ECORE_CXT_PF_CID (0xff)
137
138 /**
139  * @brief ecore_cxt_release - Release a cid
140  *
141  * @param p_hwfn
142  * @param cid
143  */
144 void ecore_cxt_release_cid(struct ecore_hwfn *p_hwfn, u32 cid);
145
146 /**
147  * @brief ecore_cxt_release - Release a cid belonging to a vf-queue
148  *
149  * @param p_hwfn
150  * @param cid
151  * @param vfid - engine relative index. ECORE_CXT_PF_CID if belongs to PF
152  */
153 void _ecore_cxt_release_cid(struct ecore_hwfn *p_hwfn,
154                             u32 cid, u8 vfid);
155
156 /**
157  * @brief ecore_cxt_acquire - Acquire a new cid of a specific protocol type
158  *
159  * @param p_hwfn
160  * @param type
161  * @param p_cid
162  *
163  * @return enum _ecore_status_t
164  */
165 enum _ecore_status_t ecore_cxt_acquire_cid(struct ecore_hwfn *p_hwfn,
166                                            enum protocol_type type,
167                                            u32 *p_cid);
168
169 /**
170  * @brief _ecore_cxt_acquire - Acquire a new cid of a specific protocol type
171  *                             for a vf-queue
172  *
173  * @param p_hwfn
174  * @param type
175  * @param p_cid
176  * @param vfid - engine relative index. ECORE_CXT_PF_CID if belongs to PF
177  *
178  * @return enum _ecore_status_t
179  */
180 enum _ecore_status_t _ecore_cxt_acquire_cid(struct ecore_hwfn *p_hwfn,
181                                             enum protocol_type type,
182                                             u32 *p_cid, u8 vfid);
183
184 /**
185  * @brief ecore_cxt_get_tid_mem_info - function checks if the
186  *        page containing the iid in the ilt is already
187  *        allocated, if it is not it allocates the page.
188  *
189  * @param p_hwfn
190  * @param elem_type
191  * @param iid
192  *
193  * @return enum _ecore_status_t
194  */
195 enum _ecore_status_t
196 ecore_cxt_dynamic_ilt_alloc(struct ecore_hwfn *p_hwfn,
197                             enum ecore_cxt_elem_type elem_type,
198                             u32 iid);
199
200 /**
201  * @brief ecore_cxt_free_proto_ilt - function frees ilt pages
202  *        associated with the protocol passed.
203  *
204  * @param p_hwfn
205  * @param proto
206  *
207  * @return enum _ecore_status_t
208  */
209 enum _ecore_status_t ecore_cxt_free_proto_ilt(struct ecore_hwfn *p_hwfn,
210                                               enum protocol_type proto);
211
212 #define ECORE_CTX_WORKING_MEM 0
213 #define ECORE_CTX_FL_MEM 1
214
215 #endif /* _ECORE_CID_ */