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