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