1 /*
2 * Copyright (c) 2017-2018 Cavium, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 *
27 */
28
29 #ifndef __ECORE_VF_H__
30 #define __ECORE_VF_H__
31
32 #include "ecore_status.h"
33 #include "ecore_vf_api.h"
34 #include "ecore_l2_api.h"
35 #include "ecore_vfpf_if.h"
36
37 /* Default number of CIDs [total of both Rx and Tx] to be requested
38 * by default, and maximum possible number.
39 */
40 #define ECORE_ETH_VF_DEFAULT_NUM_CIDS (32)
41 #define ECORE_ETH_VF_MAX_NUM_CIDS (255)
42
43 /* This data is held in the ecore_hwfn structure for VFs only. */
44 struct ecore_vf_iov {
45 union vfpf_tlvs *vf2pf_request;
46 dma_addr_t vf2pf_request_phys;
47 union pfvf_tlvs *pf2vf_reply;
48 dma_addr_t pf2vf_reply_phys;
49
50 /* Should be taken whenever the mailbox buffers are accessed */
51 osal_mutex_t mutex;
52 u8 *offset;
53
54 /* Bulletin Board */
55 struct ecore_bulletin bulletin;
56 struct ecore_bulletin_content bulletin_shadow;
57
58 /* we set aside a copy of the acquire response */
59 struct pfvf_acquire_resp_tlv acquire_resp;
60
61 /* In case PF originates prior to the fp-hsi version comparison,
62 * this has to be propagated as it affects the fastpath.
63 */
64 bool b_pre_fp_hsi;
65
66 /* Current day VFs are passing the SBs physical address on vport
67 * start, and as they lack an IGU mapping they need to store the
68 * addresses of previously registered SBs.
69 * Even if we were to change configuration flow, due to backward
70 * compatability [with older PFs] we'd still need to store these.
71 */
72 struct ecore_sb_info *sbs_info[PFVF_MAX_SBS_PER_VF];
73
74 #ifdef CONFIG_ECORE_SW_CHANNEL
75 /* Would be set if the VF is to try communicating with it PF
76 * using a hw channel.
77 */
78 bool b_hw_channel;
79 #endif
80
81 /* Determines whether VF utilizes doorbells via limited register
82 * bar or via the doorbell bar.
83 */
84 bool b_doorbell_bar;
85
86 /* FreeBSD RSS queries require the RSS TLV itself to be accepted. */
87 bool rss_configured;
88 };
89
90 /**
91 * @brief VF - Get coalesce per VF's relative queue.
92 *
93 * @param p_hwfn
94 * @param p_coal - coalesce value in micro second for VF queues.
95 * @param p_cid - queue cid
96 *
97 **/
98 enum _ecore_status_t ecore_vf_pf_get_coalesce(struct ecore_hwfn *p_hwfn,
99 u16 *p_coal,
100 struct ecore_queue_cid *p_cid);
101 /**
102 * @brief VF - Set Rx/Tx coalesce per VF's relative queue.
103 * Coalesce value '0' will omit the configuration.
104 *
105 * @param p_hwfn
106 * @param rx_coal - coalesce value in micro second for rx queue
107 * @param tx_coal - coalesce value in micro second for tx queue
108 * @param p_cid - queue cid
109 *
110 **/
111 enum _ecore_status_t ecore_vf_pf_set_coalesce(struct ecore_hwfn *p_hwfn,
112 u16 rx_coal, u16 tx_coal,
113 struct ecore_queue_cid *p_cid);
114
115 #ifdef CONFIG_ECORE_SRIOV
116 /**
117 * @brief hw preparation for VF
118 * sends ACQUIRE message
119 *
120 * @param p_hwfn
121 *
122 * @return enum _ecore_status_t
123 */
124 enum _ecore_status_t ecore_vf_hw_prepare(struct ecore_hwfn *p_hwfn);
125
126 /**
127 * @brief VF - start the RX Queue by sending a message to the PF
128 *
129 * @param p_hwfn
130 * @param p_cid - Only relative fields are relevant
131 * @param bd_max_bytes - maximum number of bytes per bd
132 * @param bd_chain_phys_addr - physical address of bd chain
133 * @param cqe_pbl_addr - physical address of pbl
134 * @param cqe_pbl_size - pbl size
135 * @param pp_prod - pointer to the producer to be
136 * used in fasthpath
137 *
138 * @return enum _ecore_status_t
139 */
140 enum _ecore_status_t ecore_vf_pf_rxq_start(struct ecore_hwfn *p_hwfn,
141 struct ecore_queue_cid *p_cid,
142 u16 bd_max_bytes,
143 dma_addr_t bd_chain_phys_addr,
144 dma_addr_t cqe_pbl_addr,
145 u16 cqe_pbl_size,
146 void OSAL_IOMEM **pp_prod);
147
148 /**
149 * @brief VF - start the TX queue by sending a message to the
150 * PF.
151 *
152 * @param p_hwfn
153 * @param p_cid
154 * @param bd_chain_phys_addr - physical address of tx chain
155 * @param pp_doorbell - pointer to address to which to
156 * write the doorbell too..
157 *
158 * @return enum _ecore_status_t
159 */
160 enum _ecore_status_t
161 ecore_vf_pf_txq_start(struct ecore_hwfn *p_hwfn,
162 struct ecore_queue_cid *p_cid,
163 dma_addr_t pbl_addr, u16 pbl_size,
164 void OSAL_IOMEM **pp_doorbell);
165
166 /**
167 * @brief VF - stop the RX queue by sending a message to the PF
168 *
169 * @param p_hwfn
170 * @param p_cid
171 * @param cqe_completion
172 *
173 * @return enum _ecore_status_t
174 */
175 enum _ecore_status_t ecore_vf_pf_rxq_stop(struct ecore_hwfn *p_hwfn,
176 struct ecore_queue_cid *p_cid,
177 bool cqe_completion);
178
179 /**
180 * @brief VF - stop the TX queue by sending a message to the PF
181 *
182 * @param p_hwfn
183 * @param p_cid
184 *
185 * @return enum _ecore_status_t
186 */
187 enum _ecore_status_t ecore_vf_pf_txq_stop(struct ecore_hwfn *p_hwfn,
188 struct ecore_queue_cid *p_cid);
189
190 /* TODO - fix all the !SRIOV prototypes */
191
192 #ifndef LINUX_REMOVE
193 /**
194 * @brief VF - update the RX queue by sending a message to the
195 * PF
196 *
197 * @param p_hwfn
198 * @param pp_cid - list of queue-cids which we want to update
199 * @param num_rxqs
200 * @param comp_cqe_flg
201 * @param comp_event_flg
202 *
203 * @return enum _ecore_status_t
204 */
205 enum _ecore_status_t ecore_vf_pf_rxqs_update(struct ecore_hwfn *p_hwfn,
206 struct ecore_queue_cid **pp_cid,
207 u8 num_rxqs,
208 u8 comp_cqe_flg,
209 u8 comp_event_flg);
210 #endif
211
212 /**
213 * @brief VF - send a vport update command
214 *
215 * @param p_hwfn
216 * @param params
217 *
218 * @return enum _ecore_status_t
219 */
220 enum _ecore_status_t ecore_vf_pf_vport_update(struct ecore_hwfn *p_hwfn,
221 struct ecore_sp_vport_update_params *p_params);
222
223 /**
224 * @brief VF - send a close message to PF
225 *
226 * @param p_hwfn
227 *
228 * @return enum _ecore_status
229 */
230 enum _ecore_status_t ecore_vf_pf_reset(struct ecore_hwfn *p_hwfn);
231
232 /**
233 * @brief VF - free vf`s memories
234 *
235 * @param p_hwfn
236 *
237 * @return enum _ecore_status
238 */
239 enum _ecore_status_t ecore_vf_pf_release(struct ecore_hwfn *p_hwfn);
240
241 /**
242 * @brief ecore_vf_get_igu_sb_id - Get the IGU SB ID for a given
243 * sb_id. For VFs igu sbs don't have to be contiguous
244 *
245 * @param p_hwfn
246 * @param sb_id
247 *
248 * @return INLINE u16
249 */
250 u16 ecore_vf_get_igu_sb_id(struct ecore_hwfn *p_hwfn,
251 u16 sb_id);
252
253 /**
254 * @brief Stores [or removes] a configured sb_info.
255 *
256 * @param p_hwfn
257 * @param sb_id - zero-based SB index [for fastpath]
258 * @param sb_info - may be OSAL_NULL [during removal].
259 */
260 void ecore_vf_set_sb_info(struct ecore_hwfn *p_hwfn,
261 u16 sb_id, struct ecore_sb_info *p_sb);
262
263 /**
264 * @brief ecore_vf_pf_vport_start - perform vport start for VF.
265 *
266 * @param p_hwfn
267 * @param vport_id
268 * @param mtu
269 * @param inner_vlan_removal
270 * @param tpa_mode
271 * @param max_buffers_per_cqe,
272 * @param only_untagged - default behavior regarding vlan acceptance
273 * @param zero_placement_offset - if set, zero padding will be inserted
274 *
275 * @return enum _ecore_status
276 */
277 enum _ecore_status_t ecore_vf_pf_vport_start(
278 struct ecore_hwfn *p_hwfn,
279 u8 vport_id,
280 u16 mtu,
281 u8 inner_vlan_removal,
282 enum ecore_tpa_mode tpa_mode,
283 u8 max_buffers_per_cqe,
284 u8 only_untagged,
285 u8 zero_placement_offset);
286
287 /**
288 * @brief ecore_vf_pf_vport_stop - stop the VF's vport
289 *
290 * @param p_hwfn
291 *
292 * @return enum _ecore_status
293 */
294 enum _ecore_status_t ecore_vf_pf_vport_stop(struct ecore_hwfn *p_hwfn);
295
296 enum _ecore_status_t ecore_vf_pf_filter_ucast(
297 struct ecore_hwfn *p_hwfn,
298 struct ecore_filter_ucast *p_param);
299
300 void ecore_vf_pf_filter_mcast(struct ecore_hwfn *p_hwfn,
301 struct ecore_filter_mcast *p_filter_cmd);
302
303 /**
304 * @brief ecore_vf_pf_int_cleanup - clean the SB of the VF
305 *
306 * @param p_hwfn
307 *
308 * @return enum _ecore_status
309 */
310 enum _ecore_status_t ecore_vf_pf_int_cleanup(struct ecore_hwfn *p_hwfn);
311
312 /**
313 * @brief - return the link params in a given bulletin board
314 *
315 * @param p_params - pointer to a struct to fill with link params
316 * @param p_bulletin
317 */
318 void __ecore_vf_get_link_params(struct ecore_mcp_link_params *p_params,
319 struct ecore_bulletin_content *p_bulletin);
320
321 /**
322 * @brief - return the link state in a given bulletin board
323 *
324 * @param p_link - pointer to a struct to fill with link state
325 * @param p_bulletin
326 */
327 void __ecore_vf_get_link_state(struct ecore_mcp_link_state *p_link,
328 struct ecore_bulletin_content *p_bulletin);
329
330 /**
331 * @brief - return the link capabilities in a given bulletin board
332 *
333 * @param p_link - pointer to a struct to fill with link capabilities
334 * @param p_bulletin
335 */
336 void __ecore_vf_get_link_caps(struct ecore_mcp_link_capabilities *p_link_caps,
337 struct ecore_bulletin_content *p_bulletin);
338 enum _ecore_status_t
339 ecore_vf_pf_tunnel_param_update(struct ecore_hwfn *p_hwfn,
340 struct ecore_tunnel_info *p_tunn);
341 void ecore_vf_set_vf_start_tunn_update_param(struct ecore_tunnel_info *p_tun);
342
343 u32 ecore_vf_hw_bar_size(struct ecore_hwfn *p_hwfn, enum BAR_ID bar_id);
344 #else
ecore_vf_hw_prepare(struct ecore_hwfn OSAL_UNUSED * p_hwfn)345 static OSAL_INLINE enum _ecore_status_t ecore_vf_hw_prepare(struct ecore_hwfn OSAL_UNUSED *p_hwfn) {return ECORE_INVAL;}
ecore_vf_pf_rxq_start(struct ecore_hwfn OSAL_UNUSED * p_hwfn,struct ecore_queue_cid OSAL_UNUSED * p_cid,u16 OSAL_UNUSED bd_max_bytes,dma_addr_t OSAL_UNUSED bd_chain_phys_addr,dma_addr_t OSAL_UNUSED cqe_pbl_addr,u16 OSAL_UNUSED cqe_pbl_size,void OSAL_IOMEM OSAL_UNUSED ** pp_prod)346 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_rxq_start(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_queue_cid OSAL_UNUSED *p_cid, u16 OSAL_UNUSED bd_max_bytes, dma_addr_t OSAL_UNUSED bd_chain_phys_addr, dma_addr_t OSAL_UNUSED cqe_pbl_addr, u16 OSAL_UNUSED cqe_pbl_size, void OSAL_IOMEM OSAL_UNUSED **pp_prod) {return ECORE_INVAL;}
ecore_vf_pf_txq_start(struct ecore_hwfn OSAL_UNUSED * p_hwfn,struct ecore_queue_cid OSAL_UNUSED * p_cid,dma_addr_t OSAL_UNUSED pbl_addr,u16 OSAL_UNUSED pbl_size,void OSAL_IOMEM OSAL_UNUSED ** pp_doorbell)347 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_txq_start(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_queue_cid OSAL_UNUSED *p_cid, dma_addr_t OSAL_UNUSED pbl_addr, u16 OSAL_UNUSED pbl_size, void OSAL_IOMEM OSAL_UNUSED **pp_doorbell) {return ECORE_INVAL;}
ecore_vf_pf_rxq_stop(struct ecore_hwfn OSAL_UNUSED * p_hwfn,struct ecore_queue_cid OSAL_UNUSED * p_cid,bool OSAL_UNUSED cqe_completion)348 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_rxq_stop(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_queue_cid OSAL_UNUSED *p_cid, bool OSAL_UNUSED cqe_completion) {return ECORE_INVAL;}
ecore_vf_pf_txq_stop(struct ecore_hwfn OSAL_UNUSED * p_hwfn,struct ecore_queue_cid OSAL_UNUSED * p_cid)349 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_txq_stop(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_queue_cid OSAL_UNUSED *p_cid) {return ECORE_INVAL;}
350 #ifndef LINUX_REMOVE
ecore_vf_pf_rxqs_update(struct ecore_hwfn OSAL_UNUSED * p_hwfn,struct ecore_queue_cid OSAL_UNUSED ** pp_cid,u8 OSAL_UNUSED num_rxqs,u8 OSAL_UNUSED comp_cqe_flg,u8 OSAL_UNUSED comp_event_flg)351 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_rxqs_update(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_queue_cid OSAL_UNUSED **pp_cid, u8 OSAL_UNUSED num_rxqs, u8 OSAL_UNUSED comp_cqe_flg, u8 OSAL_UNUSED comp_event_flg) {return ECORE_INVAL;}
352 #endif
ecore_vf_pf_vport_update(struct ecore_hwfn OSAL_UNUSED * p_hwfn,struct ecore_sp_vport_update_params OSAL_UNUSED * p_params)353 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_vport_update(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_sp_vport_update_params OSAL_UNUSED *p_params) {return ECORE_INVAL;}
ecore_vf_pf_reset(struct ecore_hwfn OSAL_UNUSED * p_hwfn)354 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_reset(struct ecore_hwfn OSAL_UNUSED *p_hwfn) {return ECORE_INVAL;}
ecore_vf_pf_release(struct ecore_hwfn OSAL_UNUSED * p_hwfn)355 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_release(struct ecore_hwfn OSAL_UNUSED *p_hwfn) {return ECORE_INVAL;}
ecore_vf_get_igu_sb_id(struct ecore_hwfn OSAL_UNUSED * p_hwfn,u16 OSAL_UNUSED sb_id)356 static OSAL_INLINE u16 ecore_vf_get_igu_sb_id(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED sb_id) {return 0;}
ecore_vf_set_sb_info(struct ecore_hwfn OSAL_UNUSED * p_hwfn,u16 OSAL_UNUSED sb_id,struct ecore_sb_info OSAL_UNUSED * p_sb)357 static OSAL_INLINE void ecore_vf_set_sb_info(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED sb_id, struct ecore_sb_info OSAL_UNUSED *p_sb) {}
ecore_vf_pf_vport_start(struct ecore_hwfn OSAL_UNUSED * p_hwfn,u8 OSAL_UNUSED vport_id,u16 OSAL_UNUSED mtu,u8 OSAL_UNUSED inner_vlan_removal,enum ecore_tpa_mode OSAL_UNUSED tpa_mode,u8 OSAL_UNUSED max_buffers_per_cqe,u8 OSAL_UNUSED only_untagged,u8 OSAL_UNUSED zero_placement_offset)358 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_vport_start(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED vport_id, u16 OSAL_UNUSED mtu, u8 OSAL_UNUSED inner_vlan_removal, enum ecore_tpa_mode OSAL_UNUSED tpa_mode, u8 OSAL_UNUSED max_buffers_per_cqe, u8 OSAL_UNUSED only_untagged, u8 OSAL_UNUSED zero_placement_offset) {return ECORE_INVAL;}
ecore_vf_pf_vport_stop(struct ecore_hwfn OSAL_UNUSED * p_hwfn)359 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_vport_stop(struct ecore_hwfn OSAL_UNUSED *p_hwfn) {return ECORE_INVAL;}
ecore_vf_pf_filter_ucast(struct ecore_hwfn OSAL_UNUSED * p_hwfn,struct ecore_filter_ucast OSAL_UNUSED * p_param)360 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_filter_ucast(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_filter_ucast OSAL_UNUSED *p_param) {return ECORE_INVAL;}
ecore_vf_pf_filter_mcast(struct ecore_hwfn OSAL_UNUSED * p_hwfn,struct ecore_filter_mcast OSAL_UNUSED * p_filter_cmd)361 static OSAL_INLINE void ecore_vf_pf_filter_mcast(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_filter_mcast OSAL_UNUSED *p_filter_cmd) {}
ecore_vf_pf_int_cleanup(struct ecore_hwfn OSAL_UNUSED * p_hwfn)362 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_int_cleanup(struct ecore_hwfn OSAL_UNUSED *p_hwfn) {return ECORE_INVAL;}
__ecore_vf_get_link_params(struct ecore_mcp_link_params OSAL_UNUSED * p_params,struct ecore_bulletin_content OSAL_UNUSED * p_bulletin)363 static OSAL_INLINE void __ecore_vf_get_link_params(struct ecore_mcp_link_params OSAL_UNUSED *p_params, struct ecore_bulletin_content OSAL_UNUSED *p_bulletin) {}
__ecore_vf_get_link_state(struct ecore_mcp_link_state OSAL_UNUSED * p_link,struct ecore_bulletin_content OSAL_UNUSED * p_bulletin)364 static OSAL_INLINE void __ecore_vf_get_link_state(struct ecore_mcp_link_state OSAL_UNUSED *p_link, struct ecore_bulletin_content OSAL_UNUSED *p_bulletin) {}
__ecore_vf_get_link_caps(struct ecore_mcp_link_capabilities OSAL_UNUSED * p_link_caps,struct ecore_bulletin_content OSAL_UNUSED * p_bulletin)365 static OSAL_INLINE void __ecore_vf_get_link_caps(struct ecore_mcp_link_capabilities OSAL_UNUSED *p_link_caps, struct ecore_bulletin_content OSAL_UNUSED *p_bulletin) {}
ecore_vf_pf_tunnel_param_update(struct ecore_hwfn OSAL_UNUSED * p_hwfn,struct ecore_tunnel_info OSAL_UNUSED * p_tunn)366 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_tunnel_param_update(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_tunnel_info OSAL_UNUSED *p_tunn) { return ECORE_INVAL; }
ecore_vf_set_vf_start_tunn_update_param(struct ecore_tunnel_info OSAL_UNUSED * p_tun)367 static OSAL_INLINE void ecore_vf_set_vf_start_tunn_update_param(struct ecore_tunnel_info OSAL_UNUSED *p_tun) { return; }
368
369 static OSAL_INLINE u32
ecore_vf_hw_bar_size(struct ecore_hwfn OSAL_UNUSED * p_hwfn,enum BAR_ID OSAL_UNUSED bar_id)370 ecore_vf_hw_bar_size(struct ecore_hwfn OSAL_UNUSED *p_hwfn,
371 enum BAR_ID OSAL_UNUSED bar_id)
372 {
373 return 0;
374 }
375 #endif
376
377 #endif /* __ECORE_VF_H__ */
378