Imported Upstream version 16.07-rc1
[deb_dpdk.git] / drivers / net / qede / base / ecore_vf.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_VF_H__
10 #define __ECORE_VF_H__
11
12 #include "ecore_status.h"
13 #include "ecore_vf_api.h"
14 #include "ecore_l2_api.h"
15 #include "ecore_vfpf_if.h"
16
17 #ifdef CONFIG_ECORE_SRIOV
18 /**
19  *
20  * @brief hw preparation for VF
21  *      sends ACQUIRE message
22  *
23  * @param p_dev
24  *
25  * @return enum _ecore_status_t
26  */
27 enum _ecore_status_t ecore_vf_hw_prepare(struct ecore_dev *p_dev);
28
29 /**
30  *
31  * @brief VF init in hw (equivalent to hw_init in PF)
32  *      mark interrupts as enabled
33  *
34  * @param p_hwfn
35  *
36  * @return enum _ecore_status_t
37  */
38 enum _ecore_status_t ecore_vf_pf_init(struct ecore_hwfn *p_hwfn);
39
40 /**
41  *
42  * @brief VF - start the RX Queue by sending a message to the PF
43  *
44  * @param p_hwfn
45  * @param cid                   - zero based within the VF
46  * @param rx_queue_id           - zero based within the VF
47  * @param sb                    - VF status block for this queue
48  * @param sb_index              - Index within the status block
49  * @param bd_max_bytes          - maximum number of bytes per bd
50  * @param bd_chain_phys_addr    - physical address of bd chain
51  * @param cqe_pbl_addr          - physical address of pbl
52  * @param cqe_pbl_size          - pbl size
53  * @param pp_prod               - pointer to the producer to be
54  *          used in fasthwfn
55  *
56  * @return enum _ecore_status_t
57  */
58 enum _ecore_status_t ecore_vf_pf_rxq_start(struct ecore_hwfn *p_hwfn,
59                                            u8 rx_queue_id,
60                                            u16 sb,
61                                            u8 sb_index,
62                                            u16 bd_max_bytes,
63                                            dma_addr_t bd_chain_phys_addr,
64                                            dma_addr_t cqe_pbl_addr,
65                                            u16 cqe_pbl_size,
66                                            void OSAL_IOMEM * *pp_prod);
67
68 /**
69  *
70  * @brief VF - start the TX queue by sending a message to the
71  *        PF.
72  *
73  * @param p_hwfn
74  * @param tx_queue_id           - zero based within the VF
75  * @param sb                    - status block for this queue
76  * @param sb_index              - index within the status block
77  * @param bd_chain_phys_addr    - physical address of tx chain
78  * @param pp_doorbell           - pointer to address to which to
79  *              write the doorbell too..
80  *
81  * @return enum _ecore_status_t
82  */
83 enum _ecore_status_t ecore_vf_pf_txq_start(struct ecore_hwfn *p_hwfn,
84                                            u16 tx_queue_id,
85                                            u16 sb,
86                                            u8 sb_index,
87                                            dma_addr_t pbl_addr,
88                                            u16 pbl_size,
89                                            void OSAL_IOMEM * *pp_doorbell);
90
91 /**
92  *
93  * @brief VF - stop the RX queue by sending a message to the PF
94  *
95  * @param p_hwfn
96  * @param rx_qid
97  * @param cqe_completion
98  *
99  * @return enum _ecore_status_t
100  */
101 enum _ecore_status_t ecore_vf_pf_rxq_stop(struct ecore_hwfn *p_hwfn,
102                                           u16 rx_qid, bool cqe_completion);
103
104 /**
105  *
106  * @brief VF - stop the TX queue by sending a message to the PF
107  *
108  * @param p_hwfn
109  * @param tx_qid
110  *
111  * @return enum _ecore_status_t
112  */
113 enum _ecore_status_t ecore_vf_pf_txq_stop(struct ecore_hwfn *p_hwfn,
114                                           u16 tx_qid);
115
116 /**
117  * @brief VF - update the RX queue by sending a message to the
118  *        PF
119  *
120  * @param p_hwfn
121  * @param rx_queue_id
122  * @param num_rxqs
123  * @param init_sge_ring
124  * @param comp_cqe_flg
125  * @param comp_event_flg
126  *
127  * @return enum _ecore_status_t
128  */
129 enum _ecore_status_t ecore_vf_pf_rxqs_update(struct ecore_hwfn *p_hwfn,
130                                              u16 rx_queue_id,
131                                              u8 num_rxqs,
132                                              u8 comp_cqe_flg,
133                                              u8 comp_event_flg);
134
135 /**
136  *
137  * @brief VF - send a vport update command
138  *
139  * @param p_hwfn
140  * @param params
141  *
142  * @return enum _ecore_status_t
143  */
144 enum _ecore_status_t
145 ecore_vf_pf_vport_update(struct ecore_hwfn *p_hwfn,
146                          struct ecore_sp_vport_update_params *p_params);
147
148 /**
149  *
150  * @brief VF - send a close message to PF
151  *
152  * @param p_hwfn
153  *
154  * @return enum _ecore_status
155  */
156 enum _ecore_status_t ecore_vf_pf_reset(struct ecore_hwfn *p_hwfn);
157
158 /**
159  *
160  * @brief VF - free vf`s memories
161  *
162  * @param p_hwfn
163  *
164  * @return enum _ecore_status
165  */
166 enum _ecore_status_t ecore_vf_pf_release(struct ecore_hwfn *p_hwfn);
167
168 /**
169  *
170  * @brief ecore_vf_get_igu_sb_id - Get the IGU SB ID for a given
171  *        sb_id. For VFs igu sbs don't have to be contiguous
172  *
173  * @param p_hwfn
174  * @param sb_id
175  *
176  * @return INLINE u16
177  */
178 u16 ecore_vf_get_igu_sb_id(struct ecore_hwfn *p_hwfn, u16 sb_id);
179
180 /**
181  * @brief ecore_vf_pf_vport_start - perform vport start for VF.
182  *
183  * @param p_hwfn
184  * @param vport_id
185  * @param mtu
186  * @param inner_vlan_removal
187  * @param tpa_mode
188  * @param max_buffers_per_cqe,
189  * @param only_untagged - default behavior regarding vlan acceptance
190  *
191  * @return enum _ecore_status
192  */
193 enum _ecore_status_t ecore_vf_pf_vport_start(struct ecore_hwfn *p_hwfn,
194                                              u8 vport_id,
195                                              u16 mtu,
196                                              u8 inner_vlan_removal,
197                                              enum ecore_tpa_mode tpa_mode,
198                                              u8 max_buffers_per_cqe,
199                                              u8 only_untagged);
200
201 /**
202  * @brief ecore_vf_pf_vport_stop - stop the VF's vport
203  *
204  * @param p_hwfn
205  *
206  * @return enum _ecore_status
207  */
208 enum _ecore_status_t ecore_vf_pf_vport_stop(struct ecore_hwfn *p_hwfn);
209
210 enum _ecore_status_t ecore_vf_pf_filter_ucast(struct ecore_hwfn *p_hwfn,
211                                               struct ecore_filter_ucast
212                                               *p_param);
213
214 void ecore_vf_pf_filter_mcast(struct ecore_hwfn *p_hwfn,
215                               struct ecore_filter_mcast *p_filter_cmd);
216
217 /**
218  * @brief ecore_vf_pf_int_cleanup - clean the SB of the VF
219  *
220  * @param p_hwfn
221  *
222  * @return enum _ecore_status
223  */
224 enum _ecore_status_t ecore_vf_pf_int_cleanup(struct ecore_hwfn *p_hwfn);
225
226 /**
227  * @brief - return the link params in a given bulletin board
228  *
229  * @param p_hwfn
230  * @param p_params - pointer to a struct to fill with link params
231  * @param p_bulletin
232  */
233 void __ecore_vf_get_link_params(struct ecore_hwfn *p_hwfn,
234                                 struct ecore_mcp_link_params *p_params,
235                                 struct ecore_bulletin_content *p_bulletin);
236
237 /**
238  * @brief - return the link state in a given bulletin board
239  *
240  * @param p_hwfn
241  * @param p_link - pointer to a struct to fill with link state
242  * @param p_bulletin
243  */
244 void __ecore_vf_get_link_state(struct ecore_hwfn *p_hwfn,
245                                struct ecore_mcp_link_state *p_link,
246                                struct ecore_bulletin_content *p_bulletin);
247
248 /**
249  * @brief - return the link capabilities in a given bulletin board
250  *
251  * @param p_hwfn
252  * @param p_link - pointer to a struct to fill with link capabilities
253  * @param p_bulletin
254  */
255 void __ecore_vf_get_link_caps(struct ecore_hwfn *p_hwfn,
256                               struct ecore_mcp_link_capabilities *p_link_caps,
257                               struct ecore_bulletin_content *p_bulletin);
258
259 #else
260 static OSAL_INLINE enum _ecore_status_t ecore_vf_hw_prepare(struct ecore_dev
261                                                             *p_dev)
262 {
263         return ECORE_INVAL;
264 }
265
266 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_init(struct ecore_hwfn
267                                                          *p_hwfn)
268 {
269         return ECORE_INVAL;
270 }
271
272 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_rxq_start(struct ecore_hwfn
273                                                               *p_hwfn,
274                                                               u8 rx_queue_id,
275                                                               u16 sb,
276                                                               u8 sb_index,
277                                                               u16 bd_max_bytes,
278                                                               dma_addr_t
279                                                               bd_chain_phys_adr,
280                                                               dma_addr_t
281                                                               cqe_pbl_addr,
282                                                               u16 cqe_pbl_size,
283                                                               void OSAL_IOMEM *
284                                                               *pp_prod)
285 {
286         return ECORE_INVAL;
287 }
288
289 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_txq_start(struct ecore_hwfn
290                                                               *p_hwfn,
291                                                               u16 tx_queue_id,
292                                                               u16 sb,
293                                                               u8 sb_index,
294                                                               dma_addr_t
295                                                               pbl_addr,
296                                                               u16 pbl_size,
297                                                               void OSAL_IOMEM *
298                                                               *pp_doorbell)
299 {
300         return ECORE_INVAL;
301 }
302
303 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_rxq_stop(struct ecore_hwfn
304                                                              *p_hwfn,
305                                                              u16 rx_qid,
306                                                              bool
307                                                              cqe_completion)
308 {
309         return ECORE_INVAL;
310 }
311
312 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_txq_stop(struct ecore_hwfn
313                                                              *p_hwfn,
314                                                              u16 tx_qid)
315 {
316         return ECORE_INVAL;
317 }
318
319 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_rxqs_update(struct
320                                                                 ecore_hwfn
321                                                                 * p_hwfn,
322                                                                 u16 rx_queue_id,
323                                                                 u8 num_rxqs,
324                                                                 u8 comp_cqe_flg,
325                                                                 u8
326                                                                 comp_event_flg)
327 {
328         return ECORE_INVAL;
329 }
330
331 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_vport_update(
332         struct ecore_hwfn *p_hwfn,
333         struct ecore_sp_vport_update_params *p_params)
334 {
335         return ECORE_INVAL;
336 }
337
338 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_reset(struct ecore_hwfn
339                                                           *p_hwfn)
340 {
341         return ECORE_INVAL;
342 }
343
344 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_release(struct ecore_hwfn
345                                                             *p_hwfn)
346 {
347         return ECORE_INVAL;
348 }
349
350 static OSAL_INLINE u16 ecore_vf_get_igu_sb_id(struct ecore_hwfn *p_hwfn,
351                                               u16 sb_id)
352 {
353         return 0;
354 }
355
356 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_vport_start(
357         struct ecore_hwfn *p_hwfn, u8 vport_id, u16 mtu,
358         u8 inner_vlan_removal, enum ecore_tpa_mode tpa_mode,
359         u8 max_buffers_per_cqe, u8 only_untagged)
360 {
361         return ECORE_INVAL;
362 }
363
364 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_vport_stop(
365         struct ecore_hwfn *p_hwfn)
366 {
367         return ECORE_INVAL;
368 }
369
370 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_filter_ucast(
371          struct ecore_hwfn *p_hwfn, struct ecore_filter_ucast *p_param)
372 {
373         return ECORE_INVAL;
374 }
375
376 static OSAL_INLINE void ecore_vf_pf_filter_mcast(struct ecore_hwfn *p_hwfn,
377                                                  struct ecore_filter_mcast
378                                                  *p_filter_cmd)
379 {
380 }
381
382 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_int_cleanup(struct
383                                                                 ecore_hwfn
384                                                                 * p_hwfn)
385 {
386         return ECORE_INVAL;
387 }
388
389 static OSAL_INLINE void __ecore_vf_get_link_params(struct ecore_hwfn *p_hwfn,
390                                                    struct ecore_mcp_link_params
391                                                    *p_params,
392                                                    struct ecore_bulletin_content
393                                                    *p_bulletin)
394 {
395 }
396
397 static OSAL_INLINE void __ecore_vf_get_link_state(struct ecore_hwfn *p_hwfn,
398                                                   struct ecore_mcp_link_state
399                                                   *p_link,
400                                                   struct ecore_bulletin_content
401                                                   *p_bulletin)
402 {
403 }
404
405 static OSAL_INLINE void __ecore_vf_get_link_caps(struct ecore_hwfn *p_hwfn,
406                                                  struct
407                                                  ecore_mcp_link_capabilities
408                                                  * p_link_caps,
409                                                  struct ecore_bulletin_content
410                                                  *p_bulletin)
411 {
412 }
413 #endif
414
415 #endif /* __ECORE_VF_H__ */