Imported Upstream version 16.07-rc1
[deb_dpdk.git] / drivers / net / qede / base / ecore_int.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_INT_H__
10 #define __ECORE_INT_H__
11
12 #include "ecore.h"
13 #include "ecore_int_api.h"
14
15 #define ECORE_CAU_DEF_RX_TIMER_RES 0
16 #define ECORE_CAU_DEF_TX_TIMER_RES 0
17
18 #define ECORE_SB_ATT_IDX        0x0001
19 #define ECORE_SB_EVENT_MASK     0x0003
20
21 #define SB_ALIGNED_SIZE(p_hwfn)                                 \
22         ALIGNED_TYPE_SIZE(struct status_block, p_hwfn)
23
24 struct ecore_igu_block {
25         u8 status;
26 #define ECORE_IGU_STATUS_FREE   0x01
27 #define ECORE_IGU_STATUS_VALID  0x02
28 #define ECORE_IGU_STATUS_PF     0x04
29
30         u8 vector_number;
31         u8 function_id;
32         u8 is_pf;
33 };
34
35 struct ecore_igu_map {
36         struct ecore_igu_block igu_blocks[MAX_TOT_SB_PER_PATH];
37 };
38
39 struct ecore_igu_info {
40         struct ecore_igu_map igu_map;
41         u16 igu_dsb_id;
42         u16 igu_base_sb;
43         u16 igu_base_sb_iov;
44         u16 igu_sb_cnt;
45         u16 igu_sb_cnt_iov;
46         u16 free_blks;
47 };
48
49 /* TODO Names of function may change... */
50 void ecore_int_igu_init_pure_rt(struct ecore_hwfn *p_hwfn,
51                                 struct ecore_ptt *p_ptt,
52                                 bool b_set, bool b_slowpath);
53
54 void ecore_int_igu_init_rt(struct ecore_hwfn *p_hwfn);
55
56 /**
57  * @brief ecore_int_igu_read_cam - Reads the IGU CAM.
58  *      This function needs to be called during hardware
59  *      prepare. It reads the info from igu cam to know which
60  *      status block is the default / base status block etc.
61  *
62  * @param p_hwfn
63  * @param p_ptt
64  *
65  * @return enum _ecore_status_t
66  */
67 enum _ecore_status_t ecore_int_igu_read_cam(struct ecore_hwfn *p_hwfn,
68                                             struct ecore_ptt *p_ptt);
69
70 typedef enum _ecore_status_t (*ecore_int_comp_cb_t) (struct ecore_hwfn *p_hwfn,
71                                                      void *cookie);
72 /**
73  * @brief ecore_int_register_cb - Register callback func for
74  *      slowhwfn statusblock.
75  *
76  *      Every protocol that uses the slowhwfn status block
77  *      should register a callback function that will be called
78  *      once there is an update of the sp status block.
79  *
80  * @param p_hwfn
81  * @param comp_cb - function to be called when there is an
82  *                  interrupt on the sp sb
83  *
84  * @param cookie  - passed to the callback function
85  * @param sb_idx  - OUT parameter which gives the chosen index
86  *                  for this protocol.
87  * @param p_fw_cons  - pointer to the actual address of the
88  *                     consumer for this protocol.
89  *
90  * @return enum _ecore_status_t
91  */
92 enum _ecore_status_t ecore_int_register_cb(struct ecore_hwfn *p_hwfn,
93                                            ecore_int_comp_cb_t comp_cb,
94                                            void *cookie,
95                                            u8 *sb_idx, __le16 **p_fw_cons);
96 /**
97  * @brief ecore_int_unregister_cb - Unregisters callback
98  *      function from sp sb.
99  *      Partner of ecore_int_register_cb -> should be called
100  *      when no longer required.
101  *
102  * @param p_hwfn
103  * @param pi
104  *
105  * @return enum _ecore_status_t
106  */
107 enum _ecore_status_t ecore_int_unregister_cb(struct ecore_hwfn *p_hwfn, u8 pi);
108
109 /**
110  * @brief ecore_int_get_sp_sb_id - Get the slowhwfn sb id.
111  *
112  * @param p_hwfn
113  *
114  * @return u16
115  */
116 u16 ecore_int_get_sp_sb_id(struct ecore_hwfn *p_hwfn);
117
118 /**
119  * @brief Status block cleanup. Should be called for each status
120  *        block that will be used -> both PF / VF
121  *
122  * @param p_hwfn
123  * @param p_ptt
124  * @param sb_id         - igu status block id
125  * @param cleanup_set   - set(1) / clear(0)
126  * @param opaque_fid    - the function for which to perform
127  *                      cleanup, for example a PF on behalf of
128  *                      its VFs.
129  */
130 void ecore_int_igu_cleanup_sb(struct ecore_hwfn *p_hwfn,
131                               struct ecore_ptt *p_ptt,
132                               u32 sb_id, bool cleanup_set, u16 opaque_fid);
133
134 /**
135  * @brief Status block cleanup. Should be called for each status
136  *        block that will be used -> both PF / VF
137  *
138  * @param p_hwfn
139  * @param p_ptt
140  * @param sb_id         - igu status block id
141  * @param opaque        - opaque fid of the sb owner.
142  * @param cleanup_set   - set(1) / clear(0)
143  */
144 void ecore_int_igu_init_pure_rt_single(struct ecore_hwfn *p_hwfn,
145                                        struct ecore_ptt *p_ptt,
146                                        u32 sb_id, u16 opaque, bool b_set);
147
148 /**
149  * @brief ecore_int_cau_conf - configure cau for a given status
150  *        block
151  *
152  * @param p_hwfn
153  * @param ptt
154  * @param sb_phys
155  * @param igu_sb_id
156  * @param vf_number
157  * @param vf_valid
158  */
159 void ecore_int_cau_conf_sb(struct ecore_hwfn *p_hwfn,
160                            struct ecore_ptt *p_ptt,
161                            dma_addr_t sb_phys,
162                            u16 igu_sb_id, u16 vf_number, u8 vf_valid);
163
164 /**
165 * @brief ecore_int_alloc
166 *
167 * @param p_hwfn
168  * @param p_ptt
169 *
170 * @return enum _ecore_status_t
171 */
172 enum _ecore_status_t ecore_int_alloc(struct ecore_hwfn *p_hwfn,
173                                      struct ecore_ptt *p_ptt);
174
175 /**
176 * @brief ecore_int_free
177 *
178 * @param p_hwfn
179 */
180 void ecore_int_free(struct ecore_hwfn *p_hwfn);
181
182 /**
183 * @brief ecore_int_setup
184 *
185 * @param p_hwfn
186 * @param p_ptt
187 */
188 void ecore_int_setup(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt);
189
190 /**
191  * @brief - Returns an Rx queue index appropriate for usage with given SB.
192  *
193  * @param p_hwfn
194  * @param sb_id - absolute index of SB
195  *
196  * @return index of Rx queue
197  */
198 u16 ecore_int_queue_id_from_sb_id(struct ecore_hwfn *p_hwfn, u16 sb_id);
199
200 /**
201  * @brief - Enable Interrupt & Attention for hw function
202  *
203  * @param p_hwfn
204  * @param p_ptt
205  * @param int_mode
206  *
207 * @return enum _ecore_status_t
208  */
209 enum _ecore_status_t ecore_int_igu_enable(struct ecore_hwfn *p_hwfn,
210                                           struct ecore_ptt *p_ptt,
211                                           enum ecore_int_mode int_mode);
212
213 /**
214  * @brief - Initialize CAU status block entry
215  *
216  * @param p_hwfn
217  * @param p_sb_entry
218  * @param pf_id
219  * @param vf_number
220  * @param vf_valid
221  */
222 void ecore_init_cau_sb_entry(struct ecore_hwfn *p_hwfn,
223                              struct cau_sb_entry *p_sb_entry, u8 pf_id,
224                              u16 vf_number, u8 vf_valid);
225
226 #ifndef ASIC_ONLY
227 #define ECORE_MAPPING_MEMORY_SIZE(dev) \
228         ((CHIP_REV_IS_SLOW(dev) && (!(dev)->b_is_emul_full)) ? \
229          136 : NUM_OF_SBS(dev))
230 #else
231 #define ECORE_MAPPING_MEMORY_SIZE(dev) NUM_OF_SBS(dev)
232 #endif
233
234 #endif /* __ECORE_INT_H__ */