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