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