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