New upstream version 18.08
[deb_dpdk.git] / drivers / net / qede / base / ecore_vf.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_VF_H__
8 #define __ECORE_VF_H__
9
10 #include "ecore_status.h"
11 #include "ecore_vf_api.h"
12 #include "ecore_l2_api.h"
13 #include "ecore_vfpf_if.h"
14
15 /* Default number of CIDs [total of both Rx and Tx] to be requested
16  * by default.
17  */
18 #define ECORE_ETH_VF_DEFAULT_NUM_CIDS   (32)
19
20 /* This data is held in the ecore_hwfn structure for VFs only. */
21 struct ecore_vf_iov {
22         union vfpf_tlvs                 *vf2pf_request;
23         dma_addr_t                      vf2pf_request_phys;
24         union pfvf_tlvs                 *pf2vf_reply;
25         dma_addr_t                      pf2vf_reply_phys;
26
27         /* Should be taken whenever the mailbox buffers are accessed */
28         osal_mutex_t                    mutex;
29         u8                              *offset;
30
31         /* Bulletin Board */
32         struct ecore_bulletin           bulletin;
33         struct ecore_bulletin_content   bulletin_shadow;
34
35         /* we set aside a copy of the acquire response */
36         struct pfvf_acquire_resp_tlv    acquire_resp;
37
38         /* In case PF originates prior to the fp-hsi version comparison,
39          * this has to be propagated as it affects the fastpath.
40          */
41         bool b_pre_fp_hsi;
42
43         /* Current day VFs are passing the SBs physical address on vport
44          * start, and as they lack an IGU mapping they need to store the
45          * addresses of previously registered SBs.
46          * Even if we were to change configuration flow, due to backward
47          * compatibility [with older PFs] we'd still need to store these.
48          */
49         struct ecore_sb_info *sbs_info[PFVF_MAX_SBS_PER_VF];
50
51 #ifdef CONFIG_ECORE_SW_CHANNEL
52         /* Would be set if the VF is to try communicating with it PF
53          * using a hw channel.
54          */
55         bool b_hw_channel;
56 #endif
57
58         /* Determines whether VF utilizes doorbells via limited register
59          * bar or via the doorbell bar.
60          */
61         bool b_doorbell_bar;
62 };
63
64 /**
65  * @brief VF - Get coalesce per VF's relative queue.
66  *
67  * @param p_hwfn
68  * @param p_coal - coalesce value in micro second for VF queues.
69  * @param p_cid  - queue cid
70  *
71  **/
72 enum _ecore_status_t ecore_vf_pf_get_coalesce(struct ecore_hwfn *p_hwfn,
73                                               u16 *p_coal,
74                                               struct ecore_queue_cid *p_cid);
75 /**
76  * @brief VF - Set Rx/Tx coalesce per VF's relative queue.
77  *             Coalesce value '0' will omit the configuration.
78  *
79  * @param p_hwfn
80  * @param rx_coal - coalesce value in micro second for rx queue
81  * @param tx_coal - coalesce value in micro second for tx queue
82  * @param p_cid   - queue cid
83  *
84  **/
85 enum _ecore_status_t ecore_vf_pf_set_coalesce(struct ecore_hwfn *p_hwfn,
86                                               u16 rx_coal, u16 tx_coal,
87                                               struct ecore_queue_cid *p_cid);
88
89 #ifdef CONFIG_ECORE_SRIOV
90 /**
91  * @brief hw preparation for VF
92  *      sends ACQUIRE message
93  *
94  * @param p_hwfn
95  *
96  * @return enum _ecore_status_t
97  */
98 enum _ecore_status_t ecore_vf_hw_prepare(struct ecore_hwfn *p_hwfn);
99
100 /**
101  * @brief VF - start the RX Queue by sending a message to the PF
102  *
103  * @param p_hwfn
104  * @param p_cid                 - Only relative fields are relevant
105  * @param bd_max_bytes          - maximum number of bytes per bd
106  * @param bd_chain_phys_addr    - physical address of bd chain
107  * @param cqe_pbl_addr          - physical address of pbl
108  * @param cqe_pbl_size          - pbl size
109  * @param pp_prod               - pointer to the producer to be
110  *                                used in fasthpath
111  *
112  * @return enum _ecore_status_t
113  */
114 enum _ecore_status_t ecore_vf_pf_rxq_start(struct ecore_hwfn *p_hwfn,
115                                            struct ecore_queue_cid *p_cid,
116                                            u16 bd_max_bytes,
117                                            dma_addr_t bd_chain_phys_addr,
118                                            dma_addr_t cqe_pbl_addr,
119                                            u16 cqe_pbl_size,
120                                            void OSAL_IOMEM **pp_prod);
121
122 /**
123  * @brief VF - start the TX queue by sending a message to the
124  *        PF.
125  *
126  * @param p_hwfn
127  * @param p_cid
128  * @param bd_chain_phys_addr    - physical address of tx chain
129  * @param pp_doorbell           - pointer to address to which to
130  *                              write the doorbell too..
131  *
132  * @return enum _ecore_status_t
133  */
134 enum _ecore_status_t
135 ecore_vf_pf_txq_start(struct ecore_hwfn *p_hwfn,
136                       struct ecore_queue_cid *p_cid,
137                       dma_addr_t pbl_addr, u16 pbl_size,
138                       void OSAL_IOMEM **pp_doorbell);
139
140 /**
141  * @brief VF - stop the RX queue by sending a message to the PF
142  *
143  * @param p_hwfn
144  * @param p_cid
145  * @param cqe_completion
146  *
147  * @return enum _ecore_status_t
148  */
149 enum _ecore_status_t ecore_vf_pf_rxq_stop(struct ecore_hwfn *p_hwfn,
150                                           struct ecore_queue_cid *p_cid,
151                                           bool cqe_completion);
152
153 /**
154  * @brief VF - stop the TX queue by sending a message to the PF
155  *
156  * @param p_hwfn
157  * @param p_cid
158  *
159  * @return enum _ecore_status_t
160  */
161 enum _ecore_status_t ecore_vf_pf_txq_stop(struct ecore_hwfn *p_hwfn,
162                                           struct ecore_queue_cid *p_cid);
163
164 /* TODO - fix all the !SRIOV prototypes */
165
166 #ifndef LINUX_REMOVE
167 /**
168  * @brief VF - update the RX queue by sending a message to the
169  *        PF
170  *
171  * @param p_hwfn
172  * @param pp_cid - list of queue-cids which we want to update
173  * @param num_rxqs
174  * @param comp_cqe_flg
175  * @param comp_event_flg
176  *
177  * @return enum _ecore_status_t
178  */
179 enum _ecore_status_t ecore_vf_pf_rxqs_update(struct ecore_hwfn *p_hwfn,
180                                              struct ecore_queue_cid **pp_cid,
181                                              u8 num_rxqs,
182                                              u8 comp_cqe_flg,
183                                              u8 comp_event_flg);
184 #endif
185
186 /**
187  * @brief VF - send a vport update command
188  *
189  * @param p_hwfn
190  * @param params
191  *
192  * @return enum _ecore_status_t
193  */
194 enum _ecore_status_t
195 ecore_vf_pf_vport_update(struct ecore_hwfn *p_hwfn,
196                          struct ecore_sp_vport_update_params *p_params);
197
198 /**
199  * @brief VF - send a close message to PF
200  *
201  * @param p_hwfn
202  *
203  * @return enum _ecore_status
204  */
205 enum _ecore_status_t ecore_vf_pf_reset(struct ecore_hwfn *p_hwfn);
206
207 /**
208  * @brief VF - free vf`s memories
209  *
210  * @param p_hwfn
211  *
212  * @return enum _ecore_status
213  */
214 enum _ecore_status_t ecore_vf_pf_release(struct ecore_hwfn *p_hwfn);
215
216 /**
217  * @brief ecore_vf_get_igu_sb_id - Get the IGU SB ID for a given
218  *        sb_id. For VFs igu sbs don't have to be contiguous
219  *
220  * @param p_hwfn
221  * @param sb_id
222  *
223  * @return INLINE u16
224  */
225 u16 ecore_vf_get_igu_sb_id(struct ecore_hwfn *p_hwfn,
226                            u16               sb_id);
227
228 /**
229  * @brief Stores [or removes] a configured sb_info.
230  *
231  * @param p_hwfn
232  * @param sb_id - zero-based SB index [for fastpath]
233  * @param sb_info - may be OSAL_NULL [during removal].
234  */
235 void ecore_vf_set_sb_info(struct ecore_hwfn *p_hwfn,
236                           u16 sb_id, struct ecore_sb_info *p_sb);
237
238 /**
239  * @brief ecore_vf_pf_vport_start - perform vport start for VF.
240  *
241  * @param p_hwfn
242  * @param vport_id
243  * @param mtu
244  * @param inner_vlan_removal
245  * @param tpa_mode
246  * @param max_buffers_per_cqe,
247  * @param only_untagged - default behavior regarding vlan acceptance
248  *
249  * @return enum _ecore_status
250  */
251 enum _ecore_status_t ecore_vf_pf_vport_start(
252                         struct ecore_hwfn *p_hwfn,
253                         u8 vport_id,
254                         u16 mtu,
255                         u8 inner_vlan_removal,
256                         enum ecore_tpa_mode tpa_mode,
257                         u8 max_buffers_per_cqe,
258                         u8 only_untagged);
259
260 /**
261  * @brief ecore_vf_pf_vport_stop - stop the VF's vport
262  *
263  * @param p_hwfn
264  *
265  * @return enum _ecore_status
266  */
267 enum _ecore_status_t ecore_vf_pf_vport_stop(struct ecore_hwfn *p_hwfn);
268
269 enum _ecore_status_t ecore_vf_pf_filter_ucast(
270                         struct ecore_hwfn *p_hwfn,
271                         struct ecore_filter_ucast *p_param);
272
273 void ecore_vf_pf_filter_mcast(struct ecore_hwfn *p_hwfn,
274                               struct ecore_filter_mcast *p_filter_cmd);
275
276 /**
277  * @brief ecore_vf_pf_int_cleanup - clean the SB of the VF
278  *
279  * @param p_hwfn
280  *
281  * @return enum _ecore_status
282  */
283 enum _ecore_status_t ecore_vf_pf_int_cleanup(struct ecore_hwfn *p_hwfn);
284
285 /**
286  * @brief - return the link params in a given bulletin board
287  *
288  * @param p_params - pointer to a struct to fill with link params
289  * @param p_bulletin
290  */
291 void __ecore_vf_get_link_params(struct ecore_mcp_link_params *p_params,
292                                 struct ecore_bulletin_content *p_bulletin);
293
294 /**
295  * @brief - return the link state in a given bulletin board
296  *
297  * @param p_link - pointer to a struct to fill with link state
298  * @param p_bulletin
299  */
300 void __ecore_vf_get_link_state(struct ecore_mcp_link_state *p_link,
301                                struct ecore_bulletin_content *p_bulletin);
302
303 /**
304  * @brief - return the link capabilities in a given bulletin board
305  *
306  * @param p_link - pointer to a struct to fill with link capabilities
307  * @param p_bulletin
308  */
309 void __ecore_vf_get_link_caps(struct ecore_mcp_link_capabilities *p_link_caps,
310                               struct ecore_bulletin_content *p_bulletin);
311
312 enum _ecore_status_t
313 ecore_vf_pf_tunnel_param_update(struct ecore_hwfn *p_hwfn,
314                                 struct ecore_tunnel_info *p_tunn);
315
316 void ecore_vf_set_vf_start_tunn_update_param(struct ecore_tunnel_info *p_tun);
317
318 u32 ecore_vf_hw_bar_size(struct ecore_hwfn *p_hwfn,
319                      enum BAR_ID bar_id);
320
321 /**
322  * @brief - ecore_vf_pf_update_mtu Update MTU for VF.
323  *
324  * @param p_hwfn
325  * @param - mtu
326  */
327 enum _ecore_status_t
328 ecore_vf_pf_update_mtu(struct ecore_hwfn *p_hwfn, u16 mtu);
329 #endif
330 #endif /* __ECORE_VF_H__ */