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