0945522a63d871426239a99ead5234189fc5c126
[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 enum _ecore_status_t ecore_set_rxq_coalesce(struct ecore_hwfn *p_hwfn,
56                                             struct ecore_ptt *p_ptt,
57                                             u16 coalesce,
58                                             struct ecore_queue_cid *p_cid);
59 enum _ecore_status_t ecore_set_txq_coalesce(struct ecore_hwfn *p_hwfn,
60                                             struct ecore_ptt *p_ptt,
61                                             u16 coalesce,
62                                             struct ecore_queue_cid *p_cid);
63 /**
64  * @brief VF - Set Rx/Tx coalesce per VF's relative queue.
65  *      Coalesce value '0' will omit the configuration.
66  *
67  *      @param p_hwfn
68  *      @param rx_coal - coalesce value in micro second for rx queue
69  *      @param tx_coal - coalesce value in micro second for tx queue
70  *      @param queue_cid
71  *
72  **/
73 enum _ecore_status_t ecore_vf_pf_set_coalesce(struct ecore_hwfn *p_hwfn,
74                                               u16 rx_coal, u16 tx_coal,
75                                               struct ecore_queue_cid *p_cid);
76
77 #ifdef CONFIG_ECORE_SRIOV
78 /**
79  * @brief hw preparation for VF
80  *      sends ACQUIRE message
81  *
82  * @param p_hwfn
83  *
84  * @return enum _ecore_status_t
85  */
86 enum _ecore_status_t ecore_vf_hw_prepare(struct ecore_hwfn *p_hwfn);
87
88 /**
89  * @brief VF - start the RX Queue by sending a message to the PF
90  *
91  * @param p_hwfn
92  * @param p_cid                 - Only relative fields are relevant
93  * @param bd_max_bytes          - maximum number of bytes per bd
94  * @param bd_chain_phys_addr    - physical address of bd chain
95  * @param cqe_pbl_addr          - physical address of pbl
96  * @param cqe_pbl_size          - pbl size
97  * @param pp_prod               - pointer to the producer to be
98  *                                used in fasthpath
99  *
100  * @return enum _ecore_status_t
101  */
102 enum _ecore_status_t ecore_vf_pf_rxq_start(struct ecore_hwfn *p_hwfn,
103                                            struct ecore_queue_cid *p_cid,
104                                            u16 bd_max_bytes,
105                                            dma_addr_t bd_chain_phys_addr,
106                                            dma_addr_t cqe_pbl_addr,
107                                            u16 cqe_pbl_size,
108                                            void OSAL_IOMEM **pp_prod);
109
110 /**
111  * @brief VF - start the TX queue by sending a message to the
112  *        PF.
113  *
114  * @param p_hwfn
115  * @param p_cid
116  * @param bd_chain_phys_addr    - physical address of tx chain
117  * @param pp_doorbell           - pointer to address to which to
118  *                              write the doorbell too..
119  *
120  * @return enum _ecore_status_t
121  */
122 enum _ecore_status_t
123 ecore_vf_pf_txq_start(struct ecore_hwfn *p_hwfn,
124                       struct ecore_queue_cid *p_cid,
125                       dma_addr_t pbl_addr, u16 pbl_size,
126                       void OSAL_IOMEM **pp_doorbell);
127
128 /**
129  * @brief VF - stop the RX queue by sending a message to the PF
130  *
131  * @param p_hwfn
132  * @param p_cid
133  * @param cqe_completion
134  *
135  * @return enum _ecore_status_t
136  */
137 enum _ecore_status_t ecore_vf_pf_rxq_stop(struct ecore_hwfn *p_hwfn,
138                                           struct ecore_queue_cid *p_cid,
139                                           bool cqe_completion);
140
141 /**
142  * @brief VF - stop the TX queue by sending a message to the PF
143  *
144  * @param p_hwfn
145  * @param p_cid
146  *
147  * @return enum _ecore_status_t
148  */
149 enum _ecore_status_t ecore_vf_pf_txq_stop(struct ecore_hwfn *p_hwfn,
150                                           struct ecore_queue_cid *p_cid);
151
152 /* TODO - fix all the !SRIOV prototypes */
153
154 #ifndef LINUX_REMOVE
155 /**
156  * @brief VF - update the RX queue by sending a message to the
157  *        PF
158  *
159  * @param p_hwfn
160  * @param pp_cid - list of queue-cids which we want to update
161  * @param num_rxqs
162  * @param comp_cqe_flg
163  * @param comp_event_flg
164  *
165  * @return enum _ecore_status_t
166  */
167 enum _ecore_status_t ecore_vf_pf_rxqs_update(struct ecore_hwfn *p_hwfn,
168                                              struct ecore_queue_cid **pp_cid,
169                                              u8 num_rxqs,
170                                              u8 comp_cqe_flg,
171                                              u8 comp_event_flg);
172 #endif
173
174 /**
175  * @brief VF - send a vport update command
176  *
177  * @param p_hwfn
178  * @param params
179  *
180  * @return enum _ecore_status_t
181  */
182 enum _ecore_status_t
183 ecore_vf_pf_vport_update(struct ecore_hwfn *p_hwfn,
184                          struct ecore_sp_vport_update_params *p_params);
185
186 /**
187  * @brief VF - send a close message to PF
188  *
189  * @param p_hwfn
190  *
191  * @return enum _ecore_status
192  */
193 enum _ecore_status_t ecore_vf_pf_reset(struct ecore_hwfn *p_hwfn);
194
195 /**
196  * @brief VF - free vf`s memories
197  *
198  * @param p_hwfn
199  *
200  * @return enum _ecore_status
201  */
202 enum _ecore_status_t ecore_vf_pf_release(struct ecore_hwfn *p_hwfn);
203
204 /**
205  * @brief ecore_vf_get_igu_sb_id - Get the IGU SB ID for a given
206  *        sb_id. For VFs igu sbs don't have to be contiguous
207  *
208  * @param p_hwfn
209  * @param sb_id
210  *
211  * @return INLINE u16
212  */
213 u16 ecore_vf_get_igu_sb_id(struct ecore_hwfn *p_hwfn,
214                            u16               sb_id);
215
216 /**
217  * @brief Stores [or removes] a configured sb_info.
218  *
219  * @param p_hwfn
220  * @param sb_id - zero-based SB index [for fastpath]
221  * @param sb_info - may be OSAL_NULL [during removal].
222  */
223 void ecore_vf_set_sb_info(struct ecore_hwfn *p_hwfn,
224                           u16 sb_id, struct ecore_sb_info *p_sb);
225
226 /**
227  * @brief ecore_vf_pf_vport_start - perform vport start for VF.
228  *
229  * @param p_hwfn
230  * @param vport_id
231  * @param mtu
232  * @param inner_vlan_removal
233  * @param tpa_mode
234  * @param max_buffers_per_cqe,
235  * @param only_untagged - default behavior regarding vlan acceptance
236  *
237  * @return enum _ecore_status
238  */
239 enum _ecore_status_t ecore_vf_pf_vport_start(
240                         struct ecore_hwfn *p_hwfn,
241                         u8 vport_id,
242                         u16 mtu,
243                         u8 inner_vlan_removal,
244                         enum ecore_tpa_mode tpa_mode,
245                         u8 max_buffers_per_cqe,
246                         u8 only_untagged);
247
248 /**
249  * @brief ecore_vf_pf_vport_stop - stop the VF's vport
250  *
251  * @param p_hwfn
252  *
253  * @return enum _ecore_status
254  */
255 enum _ecore_status_t ecore_vf_pf_vport_stop(struct ecore_hwfn *p_hwfn);
256
257 enum _ecore_status_t ecore_vf_pf_filter_ucast(
258                         struct ecore_hwfn *p_hwfn,
259                         struct ecore_filter_ucast *p_param);
260
261 void ecore_vf_pf_filter_mcast(struct ecore_hwfn *p_hwfn,
262                               struct ecore_filter_mcast *p_filter_cmd);
263
264 /**
265  * @brief ecore_vf_pf_int_cleanup - clean the SB of the VF
266  *
267  * @param p_hwfn
268  *
269  * @return enum _ecore_status
270  */
271 enum _ecore_status_t ecore_vf_pf_int_cleanup(struct ecore_hwfn *p_hwfn);
272
273 /**
274  * @brief - return the link params in a given bulletin board
275  *
276  * @param p_params - pointer to a struct to fill with link params
277  * @param p_bulletin
278  */
279 void __ecore_vf_get_link_params(struct ecore_mcp_link_params *p_params,
280                                 struct ecore_bulletin_content *p_bulletin);
281
282 /**
283  * @brief - return the link state in a given bulletin board
284  *
285  * @param p_link - pointer to a struct to fill with link state
286  * @param p_bulletin
287  */
288 void __ecore_vf_get_link_state(struct ecore_mcp_link_state *p_link,
289                                struct ecore_bulletin_content *p_bulletin);
290
291 /**
292  * @brief - return the link capabilities in a given bulletin board
293  *
294  * @param p_link - pointer to a struct to fill with link capabilities
295  * @param p_bulletin
296  */
297 void __ecore_vf_get_link_caps(struct ecore_mcp_link_capabilities *p_link_caps,
298                               struct ecore_bulletin_content *p_bulletin);
299
300 enum _ecore_status_t
301 ecore_vf_pf_tunnel_param_update(struct ecore_hwfn *p_hwfn,
302                                 struct ecore_tunnel_info *p_tunn);
303
304 void ecore_vf_set_vf_start_tunn_update_param(struct ecore_tunnel_info *p_tun);
305 #endif
306 #endif /* __ECORE_VF_H__ */