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