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_SRIOV_API_H__
37 #define __ECORE_SRIOV_API_H__
38 
39 #include "common_hsi.h"
40 #include "ecore_status.h"
41 
42 #define ECORE_ETH_VF_NUM_MAC_FILTERS 1
43 #define ECORE_ETH_VF_NUM_VLAN_FILTERS 2
44 #define ECORE_VF_ARRAY_LENGTH (3)
45 
46 #define IS_VF(p_dev)		((p_dev)->b_is_vf)
47 #define IS_PF(p_dev)		(!((p_dev)->b_is_vf))
48 #ifdef CONFIG_ECORE_SRIOV
49 #define IS_PF_SRIOV(p_hwfn)	(!!((p_hwfn)->p_dev->p_iov_info))
50 #else
51 #define IS_PF_SRIOV(p_hwfn)	(0)
52 #endif
53 #define IS_PF_SRIOV_ALLOC(p_hwfn)	(!!((p_hwfn)->pf_iov_info))
54 #define IS_PF_PDA(p_hwfn)	0 /* @@TBD Michalk */
55 
56 /* @@@ TBD MichalK - what should this number be*/
57 #define ECORE_MAX_VF_CHAINS_PER_PF 16
58 
59 /* vport update extended feature tlvs flags */
60 enum ecore_iov_vport_update_flag {
61 	ECORE_IOV_VP_UPDATE_ACTIVATE		= 0,
62 	ECORE_IOV_VP_UPDATE_VLAN_STRIP		= 1,
63 	ECORE_IOV_VP_UPDATE_TX_SWITCH		= 2,
64 	ECORE_IOV_VP_UPDATE_MCAST		= 3,
65 	ECORE_IOV_VP_UPDATE_ACCEPT_PARAM	= 4,
66 	ECORE_IOV_VP_UPDATE_RSS			= 5,
67 	ECORE_IOV_VP_UPDATE_ACCEPT_ANY_VLAN	= 6,
68 	ECORE_IOV_VP_UPDATE_SGE_TPA		= 7,
69 	ECORE_IOV_VP_UPDATE_MAX			= 8,
70 };
71 
72 /*PF to VF STATUS is part of vfpf-channel API
73 and must be forward compatible */
74 enum ecore_iov_pf_to_vf_status {
75         PFVF_STATUS_WAITING = 0,
76         PFVF_STATUS_SUCCESS,
77         PFVF_STATUS_FAILURE,
78         PFVF_STATUS_NOT_SUPPORTED,
79         PFVF_STATUS_NO_RESOURCE,
80         PFVF_STATUS_FORCED,
81 	PFVF_STATUS_MALICIOUS,
82 };
83 
84 struct ecore_mcp_link_params;
85 struct ecore_mcp_link_state;
86 struct ecore_mcp_link_capabilities;
87 
88 /* These defines are used by the hw-channel; should never change order */
89 #define VFPF_ACQUIRE_OS_LINUX (0)
90 #define VFPF_ACQUIRE_OS_WINDOWS (1)
91 #define VFPF_ACQUIRE_OS_ESX (2)
92 #define VFPF_ACQUIRE_OS_SOLARIS (3)
93 #define VFPF_ACQUIRE_OS_LINUX_USERSPACE (4)
94 
95 struct ecore_vf_acquire_sw_info {
96 	u32 driver_version;
97 	u8 os_type;
98 };
99 
100 struct ecore_public_vf_info {
101 	/* These copies will later be reflected in the bulletin board,
102 	 * but this copy should be newer.
103 	 */
104 	u8 forced_mac[ETH_ALEN];
105 	u16 forced_vlan;
106 };
107 
108 struct ecore_iov_vf_init_params {
109 	u16 rel_vf_id;
110 
111 	/* Number of requested Queues; Currently, don't support different
112 	 * number of Rx/Tx queues.
113 	 */
114 	/* TODO - remove this limitation */
115 	u16 num_queues;
116 
117 	/* Allow the client to choose which qzones to use for Rx/Tx,
118 	 * and which queue_base to use for Tx queues on a per-queue basis.
119 	 * Notice values should be relative to the PF resources.
120 	 */
121 	u16 req_rx_queue[ECORE_MAX_VF_CHAINS_PER_PF];
122 	u16 req_tx_queue[ECORE_MAX_VF_CHAINS_PER_PF];
123 
124 	u8 vport_id;
125 
126 	/* Should be set in case RSS is going to be used for VF */
127 	u8 rss_eng_id;
128 };
129 
130 #ifdef CONFIG_ECORE_SW_CHANNEL
131 /* This is SW channel related only... */
132 enum mbx_state {
133 	VF_PF_UNKNOWN_STATE			= 0,
134 	VF_PF_WAIT_FOR_START_REQUEST		= 1,
135 	VF_PF_WAIT_FOR_NEXT_CHUNK_OF_REQUEST	= 2,
136 	VF_PF_REQUEST_IN_PROCESSING		= 3,
137 	VF_PF_RESPONSE_READY			= 4,
138 };
139 
140 struct ecore_iov_sw_mbx {
141 	enum mbx_state		mbx_state;
142 
143 	u32			request_size;
144 	u32			request_offset;
145 
146 	u32			response_size;
147 	u32			response_offset;
148 };
149 
150 /**
151  * @brief Get the vf sw mailbox params
152  *
153  * @param p_hwfn
154  * @param rel_vf_id
155  *
156  * @return struct ecore_iov_sw_mbx*
157  */
158 struct ecore_iov_sw_mbx*
159 ecore_iov_get_vf_sw_mbx(struct ecore_hwfn *p_hwfn,
160 			u16 rel_vf_id);
161 #endif
162 
163 /* This struct is part of ecore_dev and contains data relevant to all hwfns;
164  * Initialized only if SR-IOV cpabability is exposed in PCIe config space.
165  */
166 struct ecore_hw_sriov_info {
167 	/* standard SRIOV capability fields, mostly for debugging */
168 	int	pos;		/* capability position */
169 	int	nres;		/* number of resources */
170 	u32	cap;		/* SR-IOV Capabilities */
171 	u16	ctrl;		/* SR-IOV Control */
172 	u16	total_vfs;	/* total VFs associated with the PF */
173 	u16	num_vfs;        /* number of vfs that have been started */
174 	u16	initial_vfs;    /* initial VFs associated with the PF */
175 	u16	nr_virtfn;	/* number of VFs available */
176 	u16	offset;		/* first VF Routing ID offset */
177 	u16	stride;		/* following VF stride */
178 	u16	vf_device_id;	/* VF device id */
179 	u32	pgsz;		/* page size for BAR alignment */
180 	u8	link;		/* Function Dependency Link */
181 
182 	u32	first_vf_in_pf;
183 };
184 
185 #ifdef CONFIG_ECORE_SRIOV
186 #ifndef LINUX_REMOVE
187 /**
188  * @brief mark/clear all VFs before/after an incoming PCIe sriov
189  *        disable.
190  *
191  * @param p_dev
192  * @param to_disable
193  */
194 void ecore_iov_set_vfs_to_disable(struct ecore_dev *p_dev,
195 				  u8 to_disable);
196 
197 /**
198  * @brief mark/clear chosen VF before/after an incoming PCIe
199  *        sriov disable.
200  *
201  * @param p_dev
202  * @param rel_vf_id
203  * @param to_disable
204  */
205 void ecore_iov_set_vf_to_disable(struct ecore_dev *p_dev,
206 				 u16 rel_vf_id,
207 				 u8 to_disable);
208 
209 /**
210  * @brief ecore_iov_init_hw_for_vf - initialize the HW for
211  *        enabling access of a VF. Also includes preparing the
212  *        IGU for VF access. This needs to be called AFTER hw is
213  *        initialized and BEFORE VF is loaded inside the VM.
214  *
215  * @param p_hwfn
216  * @param p_ptt
217  * @param p_params
218  *
219  * @return enum _ecore_status_t
220  */
221 enum _ecore_status_t
222 ecore_iov_init_hw_for_vf(struct ecore_hwfn *p_hwfn,
223 			 struct ecore_ptt *p_ptt,
224 			 struct ecore_iov_vf_init_params *p_params);
225 
226 /**
227  * @brief ecore_iov_process_mbx_req - process a request received
228  *        from the VF
229  *
230  * @param p_hwfn
231  * @param p_ptt
232  * @param vfid
233  */
234 void ecore_iov_process_mbx_req(struct ecore_hwfn *p_hwfn,
235 			       struct ecore_ptt *p_ptt,
236 			       int vfid);
237 
238 /**
239  * @brief ecore_iov_release_hw_for_vf - called once upper layer
240  *        knows VF is done with - can release any resources
241  *        allocated for VF at this point. this must be done once
242  *        we know VF is no longer loaded in VM.
243  *
244  * @param p_hwfn
245  * @param p_ptt
246  * @param rel_vf_id
247  *
248  * @return enum _ecore_status_t
249  */
250 enum _ecore_status_t ecore_iov_release_hw_for_vf(struct ecore_hwfn *p_hwfn,
251 						 struct ecore_ptt *p_ptt,
252 						 u16 rel_vf_id);
253 
254 /**
255  * @brief ecore_iov_set_vf_ctx - set a context for a given VF
256  *
257  * @param p_hwfn
258  * @param vf_id
259  * @param ctx
260  *
261  * @return enum _ecore_status_t
262  */
263 enum _ecore_status_t ecore_iov_set_vf_ctx(struct ecore_hwfn *p_hwfn,
264 					  u16 vf_id,
265 					  void *ctx);
266 
267 /**
268  * @brief FLR cleanup for all VFs
269  *
270  * @param p_hwfn
271  * @param p_ptt
272  *
273  * @return enum _ecore_status_t
274  */
275 enum _ecore_status_t ecore_iov_vf_flr_cleanup(struct ecore_hwfn *p_hwfn,
276 					      struct ecore_ptt *p_ptt);
277 
278 /**
279  * @brief FLR cleanup for single VF
280  *
281  * @param p_hwfn
282  * @param p_ptt
283  * @param rel_vf_id
284  *
285  * @return enum _ecore_status_t
286  */
287 enum _ecore_status_t
288 ecore_iov_single_vf_flr_cleanup(struct ecore_hwfn *p_hwfn,
289 				struct ecore_ptt *p_ptt,
290 				u16 rel_vf_id);
291 
292 /**
293  * @brief Update the bulletin with link information. Notice this does NOT
294  *        send a bulletin update, only updates the PF's bulletin.
295  *
296  * @param p_hwfn
297  * @param p_vf
298  * @param params - the link params to use for the VF link configuration
299  * @param link - the link output to use for the VF link configuration
300  * @param p_caps - the link default capabilities.
301  */
302 void ecore_iov_set_link(struct ecore_hwfn *p_hwfn,
303 			u16 vfid,
304 			struct ecore_mcp_link_params *params,
305 			struct ecore_mcp_link_state *link,
306 			struct ecore_mcp_link_capabilities *p_caps);
307 
308 /**
309  * @brief Returns link information as perceived by VF.
310  *
311  * @param p_hwfn
312  * @param p_vf
313  * @param p_params - the link params visible to vf.
314  * @param p_link - the link state visible to vf.
315  * @param p_caps - the link default capabilities visible to vf.
316  */
317 void ecore_iov_get_link(struct ecore_hwfn *p_hwfn,
318 			u16 vfid,
319 			struct ecore_mcp_link_params *params,
320 			struct ecore_mcp_link_state *link,
321 			struct ecore_mcp_link_capabilities *p_caps);
322 
323 /**
324  * @brief return if the VF is pending FLR
325  *
326  * @param p_hwfn
327  * @param rel_vf_id
328  *
329  * @return bool
330  */
331 bool ecore_iov_is_vf_pending_flr(struct ecore_hwfn *p_hwfn,
332 				 u16 rel_vf_id);
333 
334 /**
335  * @brief Check if given VF ID @vfid is valid
336  *        w.r.t. @b_enabled_only value
337  *        if b_enabled_only = true - only enabled VF id is valid
338  *        else any VF id less than max_vfs is valid
339  *
340  * @param p_hwfn
341  * @param rel_vf_id - Relative VF ID
342  * @param b_enabled_only - consider only enabled VF
343  * @param b_non_malicious - true iff we want to validate vf isn't malicious.
344  *
345  * @return bool - true for valid VF ID
346  */
347 bool ecore_iov_is_valid_vfid(struct ecore_hwfn *p_hwfn,
348 			     int rel_vf_id,
349 			     bool b_enabled_only, bool b_non_malicious);
350 
351 /**
352  * @brief Get VF's public info structure
353  *
354  * @param p_hwfn
355  * @param vfid - Relative VF ID
356  * @param b_enabled_only - false if want to access even if vf is disabled
357  *
358  * @return struct ecore_public_vf_info *
359  */
360 struct ecore_public_vf_info*
361 ecore_iov_get_public_vf_info(struct ecore_hwfn *p_hwfn,
362 			     u16 vfid, bool b_enabled_only);
363 
364 /**
365  * @brief fills a bitmask of all VFs which have pending unhandled
366  *        messages.
367  *
368  * @param p_hwfn
369  */
370 void ecore_iov_pf_get_pending_events(struct ecore_hwfn *p_hwfn,
371 				     u64 *events);
372 
373 /**
374  * @brief Copy VF's message to PF's buffer
375  *
376  * @param p_hwfn
377  * @param ptt
378  * @param vfid
379  *
380  * @return enum _ecore_status_t
381  */
382 enum _ecore_status_t ecore_iov_copy_vf_msg(struct ecore_hwfn *p_hwfn,
383 					   struct ecore_ptt *ptt,
384 					   int vfid);
385 /**
386  * @brief Set forced MAC address in PFs copy of bulletin board
387  *        and configures FW/HW to support the configuration.
388  *
389  * @param p_hwfn
390  * @param mac
391  * @param vfid
392  */
393 void ecore_iov_bulletin_set_forced_mac(struct ecore_hwfn *p_hwfn,
394 				       u8 *mac, int vfid);
395 
396 /**
397  * @brief Set MAC address in PFs copy of bulletin board without
398  *        configuring FW/HW.
399  *
400  * @param p_hwfn
401  * @param mac
402  * @param vfid
403  */
404 enum _ecore_status_t ecore_iov_bulletin_set_mac(struct ecore_hwfn *p_hwfn,
405 						u8 *mac, int vfid);
406 
407 /**
408  * @brief Set default behaviour of VF in case no vlans are configured for it
409  *        whether to accept only untagged traffic or all.
410  *        Must be called prior to the VF vport-start.
411  *
412  * @param p_hwfn
413  * @param b_untagged_only
414  * @param vfid
415  *
416  * @return ECORE_SUCCESS if configuration would stick.
417  */
418 enum _ecore_status_t
419 ecore_iov_bulletin_set_forced_untagged_default(struct ecore_hwfn *p_hwfn,
420 					       bool b_untagged_only,
421 					       int vfid);
422 
423 /**
424  * @brief Get VFs opaque fid.
425  *
426  * @param p_hwfn
427  * @param vfid
428  * @param opaque_fid
429  */
430 void ecore_iov_get_vfs_opaque_fid(struct ecore_hwfn *p_hwfn, int vfid,
431 				  u16 *opaque_fid);
432 
433 /**
434  * @brief Set forced VLAN [pvid] in PFs copy of bulletin board
435  *        and configures FW/HW to support the configuration.
436  *        Setting of pvid 0 would clear the feature.
437  * @param p_hwfn
438  * @param pvid
439  * @param vfid
440  */
441 void ecore_iov_bulletin_set_forced_vlan(struct ecore_hwfn *p_hwfn,
442 					u16 pvid, int vfid);
443 
444 /**
445  * @brief Check if VF has VPORT instance. This can be used
446  *	  to check if VPORT is active.
447  *
448  * @param p_hwfn
449  */
450 bool ecore_iov_vf_has_vport_instance(struct ecore_hwfn *p_hwfn, int vfid);
451 
452 /**
453  * @brief PF posts the bulletin to the VF
454  *
455  * @param p_hwfn
456  * @param p_vf
457  * @param p_ptt
458  *
459  * @return enum _ecore_status_t
460  */
461 enum _ecore_status_t ecore_iov_post_vf_bulletin(struct ecore_hwfn *p_hwfn,
462 						int vfid,
463 						struct ecore_ptt *p_ptt);
464 
465 /**
466  * @brief Check if given VF (@vfid) is marked as stopped
467  *
468  * @param p_hwfn
469  * @param vfid
470  *
471  * @return bool : true if stopped
472  */
473 bool ecore_iov_is_vf_stopped(struct ecore_hwfn *p_hwfn, int vfid);
474 
475 /**
476  * @brief Configure VF anti spoofing
477  *
478  * @param p_hwfn
479  * @param vfid
480  * @param val - spoofchk value - true/false
481  *
482  * @return enum _ecore_status_t
483  */
484 enum _ecore_status_t ecore_iov_spoofchk_set(struct ecore_hwfn *p_hwfn,
485 					    int vfid, bool val);
486 
487 /**
488  * @brief Get VF's configured spoof value.
489  *
490  * @param p_hwfn
491  * @param vfid
492  *
493  * @return bool - spoofchk value - true/false
494  */
495 bool ecore_iov_spoofchk_get(struct ecore_hwfn *p_hwfn, int vfid);
496 
497 /**
498  * @brief Check for SRIOV sanity by PF.
499  *
500  * @param p_hwfn
501  * @param vfid
502  *
503  * @return bool - true if sanity checks passes, else false
504  */
505 bool ecore_iov_pf_sanity_check(struct ecore_hwfn *p_hwfn, int vfid);
506 
507 /**
508  * @brief Get the num of VF chains.
509  *
510  * @param p_hwfn
511  *
512  * @return u8
513  */
514 u8 ecore_iov_vf_chains_per_pf(struct ecore_hwfn *p_hwfn);
515 
516 /**
517  * @brief Get vf request mailbox params
518  *
519  * @param p_hwfn
520  * @param rel_vf_id
521  * @param pp_req_virt_addr
522  * @param p_req_virt_size
523  */
524 void ecore_iov_get_vf_req_virt_mbx_params(struct ecore_hwfn *p_hwfn,
525 					  u16 rel_vf_id,
526 					  void **pp_req_virt_addr,
527 					  u16 *p_req_virt_size);
528 
529 /**
530  * @brief Get vf mailbox params
531  *
532  * @param p_hwfn
533  * @param rel_vf_id
534  * @param pp_reply_virt_addr
535  * @param p_reply_virt_size
536  */
537 void ecore_iov_get_vf_reply_virt_mbx_params(struct ecore_hwfn *p_hwfn,
538 					    u16	rel_vf_id,
539 					    void **pp_reply_virt_addr,
540 					    u16	*p_reply_virt_size);
541 
542 /**
543  * @brief Validate if the given length is a valid vfpf message
544  *        length
545  *
546  * @param length
547  *
548  * @return bool
549  */
550 bool ecore_iov_is_valid_vfpf_msg_length(u32 length);
551 
552 /**
553  * @brief Return the max pfvf message length
554  *
555  * @return u32
556  */
557 u32 ecore_iov_pfvf_msg_length(void);
558 
559 /**
560  * @brief Returns forced MAC address if one is configured
561  *
562  * @parm p_hwfn
563  * @parm rel_vf_id
564  *
565  * @return OSAL_NULL if mac isn't forced; Otherwise, returns MAC.
566  */
567 u8 *ecore_iov_bulletin_get_forced_mac(struct ecore_hwfn *p_hwfn,
568 				      u16 rel_vf_id);
569 
570 /**
571  * @brief Returns pvid if one is configured
572  *
573  * @parm p_hwfn
574  * @parm rel_vf_id
575  *
576  * @return 0 if no pvid is configured, otherwise the pvid.
577  */
578 u16 ecore_iov_bulletin_get_forced_vlan(struct ecore_hwfn *p_hwfn,
579 				       u16 rel_vf_id);
580 /**
581  * @brief Configure VFs tx rate
582  *
583  * @param p_hwfn
584  * @param p_ptt
585  * @param vfid
586  * @param val - tx rate value in Mb/sec.
587  *
588  * @return enum _ecore_status_t
589  */
590 enum _ecore_status_t ecore_iov_configure_tx_rate(struct ecore_hwfn *p_hwfn,
591 						 struct ecore_ptt *p_ptt,
592 						 int vfid, int val);
593 
594 /**
595  * @brief - Retrieves the statistics associated with a VF
596  *
597  * @param p_hwfn
598  * @param p_ptt
599  * @param vfid
600  * @param p_stats - this will be filled with the VF statistics
601  *
602  * @return ECORE_SUCCESS iff statistics were retrieved. Error otherwise.
603  */
604 enum _ecore_status_t ecore_iov_get_vf_stats(struct ecore_hwfn *p_hwfn,
605 					    struct ecore_ptt *p_ptt,
606 					    int vfid,
607 					    struct ecore_eth_stats *p_stats);
608 
609 /**
610  * @brief - Retrieves num of rxqs chains
611  *
612  * @param p_hwfn
613  * @param rel_vf_id
614  *
615  * @return num of rxqs chains.
616  */
617 u8 ecore_iov_get_vf_num_rxqs(struct ecore_hwfn *p_hwfn,
618 			     u16 rel_vf_id);
619 
620 /**
621  * @brief - Retrieves num of active rxqs chains
622  *
623  * @param p_hwfn
624  * @param rel_vf_id
625  *
626  * @return
627  */
628 u8 ecore_iov_get_vf_num_active_rxqs(struct ecore_hwfn *p_hwfn,
629 				    u16 rel_vf_id);
630 
631 /**
632  * @brief - Retrieves ctx pointer
633  *
634  * @param p_hwfn
635  * @param rel_vf_id
636  *
637  * @return
638  */
639 void *ecore_iov_get_vf_ctx(struct ecore_hwfn *p_hwfn,
640 			   u16 rel_vf_id);
641 
642 /**
643  * @brief - Retrieves VF`s num sbs
644  *
645  * @param p_hwfn
646  * @param rel_vf_id
647  *
648  * @return
649  */
650 u8 ecore_iov_get_vf_num_sbs(struct ecore_hwfn *p_hwfn,
651 			    u16 rel_vf_id);
652 
653 /**
654  * @brief - Returm true if VF is waiting for acquire
655  *
656  * @param p_hwfn
657  * @param rel_vf_id
658  *
659  * @return
660  */
661 bool ecore_iov_is_vf_wait_for_acquire(struct ecore_hwfn *p_hwfn,
662 				      u16 rel_vf_id);
663 
664 /**
665  * @brief - Returm true if VF is acquired but not initialized
666  *
667  * @param p_hwfn
668  * @param rel_vf_id
669  *
670  * @return
671  */
672 bool ecore_iov_is_vf_acquired_not_initialized(struct ecore_hwfn *p_hwfn,
673 					      u16 rel_vf_id);
674 
675 /**
676  * @brief - Returm true if VF is acquired and initialized
677  *
678  * @param p_hwfn
679  * @param rel_vf_id
680  *
681  * @return
682  */
683 bool ecore_iov_is_vf_initialized(struct ecore_hwfn *p_hwfn,
684 				 u16 rel_vf_id);
685 
686 /**
687  * @brief - Returm true if VF has started in FW
688  *
689  * @param p_hwfn
690  * @param rel_vf_id
691  *
692  * @return
693  */
694 bool ecore_iov_is_vf_started(struct ecore_hwfn *p_hwfn,
695 			     u16 rel_vf_id);
696 
697 /**
698  * @brief - Get VF's vport min rate configured.
699  * @param p_hwfn
700  * @param rel_vf_id
701  *
702  * @return - rate in Mbps
703  */
704 int ecore_iov_get_vf_min_rate(struct ecore_hwfn *p_hwfn, int vfid);
705 
706 /**
707  * @brief - Configure min rate for VF's vport.
708  * @param p_dev
709  * @param vfid
710  * @param - rate in Mbps
711  *
712  * @return
713  */
714 enum _ecore_status_t ecore_iov_configure_min_tx_rate(struct ecore_dev *p_dev,
715 						     int vfid, u32 rate);
716 
717 #endif
718 
719 /**
720  * @brief ecore_pf_configure_vf_queue_coalesce - PF configure coalesce parameters
721  *    of VFs for Rx and Tx queue.
722  *    While the API allows setting coalescing per-qid, all queues sharing a SB
723  *    should be in same range [i.e., either 0-0x7f, 0x80-0xff or 0x100-0x1ff]
724  *    otherwise configuration would break.
725  *
726  * @param p_hwfn
727  * @param rx_coal - Rx Coalesce value in micro seconds.
728  * @param tx_coal - TX Coalesce value in micro seconds.
729  * @param vf_id
730  * @param qid
731  *
732  * @return int
733  **/
734 enum _ecore_status_t
735 ecore_iov_pf_configure_vf_queue_coalesce(struct ecore_hwfn *p_hwfn,
736 					 u16 rx_coal, u16 tx_coal,
737 					 u16 vf_id, u16 qid);
738 
739 /**
740  * @brief - Given a VF index, return index of next [including that] active VF.
741  *
742  * @param p_hwfn
743  * @param rel_vf_id
744  *
745  * @return E4_MAX_NUM_VFS in case no further active VFs, otherwise index.
746  */
747 u16 ecore_iov_get_next_active_vf(struct ecore_hwfn *p_hwfn, u16 rel_vf_id);
748 void ecore_iov_bulletin_set_udp_ports(struct ecore_hwfn *p_hwfn, int vfid,
749 				      u16 vxlan_port, u16 geneve_port);
750 #else
751 #ifndef LINUX_REMOVE
ecore_iov_set_vfs_to_disable(struct ecore_dev * p_dev,u8 to_disable)752 static OSAL_INLINE void ecore_iov_set_vfs_to_disable(struct ecore_dev *p_dev, u8 to_disable) {}
ecore_iov_set_vf_to_disable(struct ecore_dev * p_dev,u16 rel_vf_id,u8 to_disable)753 static OSAL_INLINE void ecore_iov_set_vf_to_disable(struct ecore_dev *p_dev, u16 rel_vf_id, u8 to_disable) {}
ecore_iov_init_hw_for_vf(struct ecore_hwfn * p_hwfn,struct ecore_ptt * p_ptt,struct ecore_iov_vf_init_params * p_params)754 static OSAL_INLINE enum _ecore_status_t ecore_iov_init_hw_for_vf(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt, struct ecore_iov_vf_init_params *p_params) {return ECORE_INVAL;}
ecore_iov_process_mbx_req(struct ecore_hwfn * p_hwfn,struct ecore_ptt * p_ptt,int vfid)755 static OSAL_INLINE void ecore_iov_process_mbx_req(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt, int vfid) {}
ecore_iov_release_hw_for_vf(struct ecore_hwfn * p_hwfn,struct ecore_ptt * p_ptt,u16 rel_vf_id)756 static OSAL_INLINE enum _ecore_status_t ecore_iov_release_hw_for_vf(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt, u16 rel_vf_id) {return ECORE_SUCCESS;}
ecore_iov_set_vf_ctx(struct ecore_hwfn * p_hwfn,u16 vf_id,void * ctx)757 static OSAL_INLINE enum _ecore_status_t ecore_iov_set_vf_ctx(struct ecore_hwfn *p_hwfn, u16 vf_id, void *ctx) {return ECORE_INVAL;}
ecore_iov_vf_flr_cleanup(struct ecore_hwfn * p_hwfn,struct ecore_ptt * p_ptt)758 static OSAL_INLINE enum _ecore_status_t ecore_iov_vf_flr_cleanup(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt) {return ECORE_INVAL;}
ecore_iov_single_vf_flr_cleanup(struct ecore_hwfn * p_hwfn,struct ecore_ptt * p_ptt,u16 rel_vf_id)759 static OSAL_INLINE enum _ecore_status_t ecore_iov_single_vf_flr_cleanup(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt, u16 rel_vf_id) {return ECORE_INVAL;}
ecore_iov_set_link(struct ecore_hwfn * p_hwfn,u16 vfid,struct ecore_mcp_link_params * params,struct ecore_mcp_link_state * link,struct ecore_mcp_link_capabilities * p_caps)760 static OSAL_INLINE void ecore_iov_set_link(struct ecore_hwfn *p_hwfn, u16 vfid, struct ecore_mcp_link_params *params, struct ecore_mcp_link_state *link, struct ecore_mcp_link_capabilities *p_caps) {}
ecore_iov_get_link(struct ecore_hwfn * p_hwfn,u16 vfid,struct ecore_mcp_link_params * params,struct ecore_mcp_link_state * link,struct ecore_mcp_link_capabilities * p_caps)761 static OSAL_INLINE void ecore_iov_get_link(struct ecore_hwfn *p_hwfn, u16 vfid, struct ecore_mcp_link_params *params, struct ecore_mcp_link_state *link, struct ecore_mcp_link_capabilities *p_caps) {}
ecore_iov_is_vf_pending_flr(struct ecore_hwfn * p_hwfn,u16 rel_vf_id)762 static OSAL_INLINE bool ecore_iov_is_vf_pending_flr(struct ecore_hwfn *p_hwfn, u16 rel_vf_id) {return false;}
ecore_iov_is_valid_vfid(struct ecore_hwfn * p_hwfn,int rel_vf_id,bool b_enabled_only)763 static OSAL_INLINE bool ecore_iov_is_valid_vfid(struct ecore_hwfn *p_hwfn, int rel_vf_id, bool b_enabled_only) {return false;}
ecore_iov_get_public_vf_info(struct ecore_hwfn * p_hwfn,u16 vfid,bool b_enabled_only)764 static OSAL_INLINE struct ecore_public_vf_info* ecore_iov_get_public_vf_info(struct ecore_hwfn *p_hwfn, u16 vfid, bool b_enabled_only) {return OSAL_NULL;}
ecore_iov_pf_add_pending_events(struct ecore_hwfn * p_hwfn,u8 vfid)765 static OSAL_INLINE void ecore_iov_pf_add_pending_events(struct ecore_hwfn *p_hwfn, u8 vfid) {}
ecore_iov_pf_get_and_clear_pending_events(struct ecore_hwfn * p_hwfn,u64 * events)766 static OSAL_INLINE void ecore_iov_pf_get_and_clear_pending_events(struct ecore_hwfn *p_hwfn, u64 *events) {}
ecore_iov_copy_vf_msg(struct ecore_hwfn * p_hwfn,struct ecore_ptt * ptt,int vfid)767 static OSAL_INLINE enum _ecore_status_t ecore_iov_copy_vf_msg(struct ecore_hwfn *p_hwfn, struct ecore_ptt *ptt, int vfid) {return ECORE_INVAL;}
ecore_iov_bulletin_set_forced_mac(struct ecore_hwfn * p_hwfn,u8 * mac,int vfid)768 static OSAL_INLINE void ecore_iov_bulletin_set_forced_mac(struct ecore_hwfn *p_hwfn, u8 *mac, int vfid) {}
ecore_iov_bulletin_set_mac(struct ecore_hwfn * p_hwfn,u8 * mac,int vfid)769 static OSAL_INLINE enum _ecore_status_t ecore_iov_bulletin_set_mac(struct ecore_hwfn *p_hwfn, u8 *mac, int vfid) {return ECORE_INVAL;}
ecore_iov_bulletin_set_forced_untagged_default(struct ecore_hwfn * p_hwfn,bool b_untagged_only,int vfid)770 static OSAL_INLINE enum _ecore_status_t ecore_iov_bulletin_set_forced_untagged_default(struct ecore_hwfn *p_hwfn, bool b_untagged_only, int vfid) {return ECORE_INVAL;}
ecore_iov_get_vfs_opaque_fid(struct ecore_hwfn * p_hwfn,int vfid,u16 * opaque_fid)771 static OSAL_INLINE void ecore_iov_get_vfs_opaque_fid(struct ecore_hwfn *p_hwfn, int vfid, u16 *opaque_fid) {}
ecore_iov_bulletin_set_forced_vlan(struct ecore_hwfn p_hwfn,u16 pvid,int vfid)772 static OSAL_INLINE void ecore_iov_bulletin_set_forced_vlan(struct ecore_hwfn p_hwfn, u16 pvid, int vfid) {}
773 
ecore_iov_vf_has_vport_instance(struct ecore_hwfn * p_hwfn,int vfid)774 static OSAL_INLINE bool ecore_iov_vf_has_vport_instance(struct ecore_hwfn *p_hwfn, int vfid) {return false;}
ecore_iov_post_vf_bulletin(struct ecore_hwfn * p_hwfn,int vfid,struct ecore_ptt * p_ptt)775 static OSAL_INLINE enum _ecore_status_t ecore_iov_post_vf_bulletin(struct ecore_hwfn *p_hwfn, int vfid, struct ecore_ptt *p_ptt) {return ECORE_INVAL;}
ecore_iov_is_vf_stopped(struct ecore_hwfn * p_hwfn,int vfid)776 static OSAL_INLINE bool ecore_iov_is_vf_stopped(struct ecore_hwfn *p_hwfn, int vfid) {return false;}
ecore_iov_spoofchk_set(struct ecore_hwfn * p_hwfn,int vfid,bool val)777 static OSAL_INLINE enum _ecore_status_t ecore_iov_spoofchk_set(struct ecore_hwfn *p_hwfn, int vfid, bool val) {return ECORE_INVAL;}
ecore_iov_spoofchk_get(struct ecore_hwfn * p_hwfn,int vfid)778 static OSAL_INLINE bool ecore_iov_spoofchk_get(struct ecore_hwfn *p_hwfn, int vfid) {return false;}
ecore_iov_pf_sanity_check(struct ecore_hwfn * p_hwfn,int vfid)779 static OSAL_INLINE bool ecore_iov_pf_sanity_check(struct ecore_hwfn *p_hwfn, int vfid) {return false;}
ecore_iov_vf_chains_per_pf(struct ecore_hwfn * p_hwfn)780 static OSAL_INLINE u8 ecore_iov_vf_chains_per_pf(struct ecore_hwfn *p_hwfn) {return 0;}
ecore_iov_get_vf_req_virt_mbx_params(struct ecore_hwfn * p_hwfn,u16 rel_vf_id,void ** pp_req_virt_addr,u16 * p_req_virt_size)781 static OSAL_INLINE void ecore_iov_get_vf_req_virt_mbx_params(struct ecore_hwfn *p_hwfn, u16 rel_vf_id, void **pp_req_virt_addr, u16 *p_req_virt_size) {}
ecore_iov_get_vf_reply_virt_mbx_params(struct ecore_hwfn * p_hwfn,u16 rel_vf_id,void ** pp_reply_virt_addr,u16 * p_reply_virt_size)782 static OSAL_INLINE void ecore_iov_get_vf_reply_virt_mbx_params(struct ecore_hwfn *p_hwfn, u16 rel_vf_id, void **pp_reply_virt_addr, u16 *p_reply_virt_size) {}
ecore_iov_is_valid_vfpf_msg_length(u32 length)783 static OSAL_INLINE bool ecore_iov_is_valid_vfpf_msg_length(u32 length) {return false;}
ecore_iov_pfvf_msg_length(void)784 static OSAL_INLINE u32 ecore_iov_pfvf_msg_length(void) {return 0;}
ecore_iov_bulletin_get_forced_mac(struct ecore_hwfn * p_hwfn,u16 rel_vf_id)785 static OSAL_INLINE u8 *ecore_iov_bulletin_get_forced_mac(struct ecore_hwfn *p_hwfn, u16 rel_vf_id) {return OSAL_NULL;}
ecore_iov_bulletin_get_forced_vlan(struct ecore_hwfn * p_hwfn,u16 rel_vf_id)786 static OSAL_INLINE u16 ecore_iov_bulletin_get_forced_vlan(struct ecore_hwfn *p_hwfn, u16 rel_vf_id) {return 0;}
ecore_iov_configure_tx_rate(struct ecore_hwfn * p_hwfn,struct ecore_ptt * p_ptt,int vfid,int val)787 static OSAL_INLINE enum _ecore_status_t ecore_iov_configure_tx_rate(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt, int vfid, int val) { return ECORE_INVAL; }
ecore_iov_get_vf_stats(struct ecore_hwfn * p_hwfn,struct ecore_ptt * p_ptt,int vfid,struct ecore_eth_stats * p_stats)788 static OSAL_INLINE enum _ecore_status_t ecore_iov_get_vf_stats(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt, int vfid, struct ecore_eth_stats *p_stats) { return ECORE_INVAL; }
789 
ecore_iov_get_vf_num_rxqs(struct ecore_hwfn * p_hwfn,u16 rel_vf_id)790 static OSAL_INLINE u8 ecore_iov_get_vf_num_rxqs(struct ecore_hwfn *p_hwfn, u16 rel_vf_id) {return 0;}
ecore_iov_get_vf_num_active_rxqs(struct ecore_hwfn * p_hwfn,u16 rel_vf_id)791 static OSAL_INLINE u8 ecore_iov_get_vf_num_active_rxqs(struct ecore_hwfn *p_hwfn, u16 rel_vf_id) {return 0;}
ecore_iov_get_vf_ctx(struct ecore_hwfn * p_hwfn,u16 rel_vf_id)792 static OSAL_INLINE void *ecore_iov_get_vf_ctx(struct ecore_hwfn *p_hwfn, u16 rel_vf_id) {return OSAL_NULL;}
ecore_iov_get_vf_num_sbs(struct ecore_hwfn * p_hwfn,u16 rel_vf_id)793 static OSAL_INLINE u8 ecore_iov_get_vf_num_sbs(struct ecore_hwfn *p_hwfn, u16 rel_vf_id) {return 0;}
ecore_iov_is_vf_wait_for_acquire(struct ecore_hwfn * p_hwfn,u16 rel_vf_id)794 static OSAL_INLINE bool ecore_iov_is_vf_wait_for_acquire(struct ecore_hwfn *p_hwfn, u16 rel_vf_id) {return false;}
ecore_iov_is_vf_acquired_not_initialized(struct ecore_hwfn * p_hwfn,u16 rel_vf_id)795 static OSAL_INLINE bool ecore_iov_is_vf_acquired_not_initialized(struct ecore_hwfn *p_hwfn, u16 rel_vf_id) {return false;}
ecore_iov_is_vf_initialized(struct ecore_hwfn * p_hwfn,u16 rel_vf_id)796 static OSAL_INLINE bool ecore_iov_is_vf_initialized(struct ecore_hwfn *p_hwfn, u16 rel_vf_id) {return false;}
ecore_iov_get_vf_min_rate(struct ecore_hwfn * p_hwfn,int vfid)797 static OSAL_INLINE int ecore_iov_get_vf_min_rate(struct ecore_hwfn *p_hwfn, int vfid) { return 0; }
ecore_iov_configure_min_tx_rate(struct ecore_dev * p_dev,int vfid,u32 rate)798 static OSAL_INLINE enum _ecore_status_t ecore_iov_configure_min_tx_rate(struct ecore_dev *p_dev, int vfid, u32 rate) { return ECORE_INVAL; }
799 #endif
ecore_iov_bulletin_set_udp_ports(struct ecore_hwfn * p_hwfn,int vfid,u16 vxlan_port,u16 geneve_port)800 static OSAL_INLINE void ecore_iov_bulletin_set_udp_ports(struct ecore_hwfn *p_hwfn, int vfid, u16 vxlan_port, u16 geneve_port) { return; }
ecore_iov_get_next_active_vf(struct ecore_hwfn * p_hwfn,u16 rel_vf_id)801 static OSAL_INLINE u16 ecore_iov_get_next_active_vf(struct ecore_hwfn *p_hwfn, u16 rel_vf_id) { return E4_MAX_NUM_VFS; }
802 #endif
803 
804 #define ecore_for_each_vf(_p_hwfn, _i)					\
805 	for (_i = ecore_iov_get_next_active_vf(_p_hwfn, 0);		\
806 	     _i < E4_MAX_NUM_VFS;					\
807 	     _i = ecore_iov_get_next_active_vf(_p_hwfn, _i + 1))
808 
809 #endif
810