net/qede: fix VF reload
[dpdk.git] / drivers / net / qede / base / ecore_iov_api.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2016 - 2018 Cavium Inc.
3  * All rights reserved.
4  * www.cavium.com
5  */
6
7 #ifndef __ECORE_SRIOV_API_H__
8 #define __ECORE_SRIOV_API_H__
9
10 #include "common_hsi.h"
11 #include "ecore_status.h"
12
13 #define ECORE_ETH_VF_NUM_MAC_FILTERS 1
14 #define ECORE_ETH_VF_NUM_VLAN_FILTERS 2
15 #define ECORE_VF_ARRAY_LENGTH (3)
16
17 #define IS_VF(p_dev)            ((p_dev)->b_is_vf)
18 #define IS_PF(p_dev)            (!((p_dev)->b_is_vf))
19 #ifdef CONFIG_ECORE_SRIOV
20 #define IS_PF_SRIOV(p_hwfn)     (!!((p_hwfn)->p_dev->p_iov_info))
21 #else
22 #define IS_PF_SRIOV(p_hwfn)     (0)
23 #endif
24 #define IS_PF_SRIOV_ALLOC(p_hwfn)       (!!((p_hwfn)->pf_iov_info))
25 #define IS_PF_PDA(p_hwfn)       0 /* @@TBD Michalk */
26
27 /* @@@ TBD MichalK - what should this number be*/
28 #define ECORE_MAX_VF_CHAINS_PER_PF 16
29
30 /* vport update extended feature tlvs flags */
31 enum ecore_iov_vport_update_flag {
32         ECORE_IOV_VP_UPDATE_ACTIVATE            = 0,
33         ECORE_IOV_VP_UPDATE_VLAN_STRIP          = 1,
34         ECORE_IOV_VP_UPDATE_TX_SWITCH           = 2,
35         ECORE_IOV_VP_UPDATE_MCAST               = 3,
36         ECORE_IOV_VP_UPDATE_ACCEPT_PARAM        = 4,
37         ECORE_IOV_VP_UPDATE_RSS                 = 5,
38         ECORE_IOV_VP_UPDATE_ACCEPT_ANY_VLAN     = 6,
39         ECORE_IOV_VP_UPDATE_SGE_TPA             = 7,
40         ECORE_IOV_VP_UPDATE_MAX                 = 8,
41 };
42
43 /* PF to VF STATUS is part of vfpf-channel API
44  * and must be forward compatible
45 */
46 enum ecore_iov_pf_to_vf_status {
47         PFVF_STATUS_WAITING = 0,
48         PFVF_STATUS_SUCCESS,
49         PFVF_STATUS_FAILURE,
50         PFVF_STATUS_NOT_SUPPORTED,
51         PFVF_STATUS_NO_RESOURCE,
52         PFVF_STATUS_FORCED,
53         PFVF_STATUS_MALICIOUS,
54         PFVF_STATUS_ACQUIRED,
55 };
56
57 struct ecore_mcp_link_params;
58 struct ecore_mcp_link_state;
59 struct ecore_mcp_link_capabilities;
60
61 /* These defines are used by the hw-channel; should never change order */
62 #define VFPF_ACQUIRE_OS_LINUX (0)
63 #define VFPF_ACQUIRE_OS_WINDOWS (1)
64 #define VFPF_ACQUIRE_OS_ESX (2)
65 #define VFPF_ACQUIRE_OS_SOLARIS (3)
66 #define VFPF_ACQUIRE_OS_LINUX_USERSPACE (4)
67
68 struct ecore_vf_acquire_sw_info {
69         u32 driver_version;
70         u8 os_type;
71
72         /* We have several close releases that all use ~same FW with different
73          * versions [making it incompatible as the versioning scheme is still
74          * tied directly to FW version], allow to override the checking. Only
75          * those versions would actually support this feature [so it would not
76          * break forward compatibility with newer HV drivers that are no longer
77          * suited].
78          */
79         bool override_fw_version;
80 };
81
82 struct ecore_public_vf_info {
83         /* These copies will later be reflected in the bulletin board,
84          * but this copy should be newer.
85          */
86         u8 forced_mac[ETH_ALEN];
87         u16 forced_vlan;
88
89         /* Trusted VFs can configure promiscuous mode and
90          * set MAC address inspite PF has set forced MAC.
91          * Also store shadow promisc configuration if needed.
92          */
93         bool is_trusted_configured;
94         bool is_trusted_request;
95 };
96
97 struct ecore_iov_vf_init_params {
98         u16 rel_vf_id;
99
100         /* Number of requested Queues; Currently, don't support different
101          * number of Rx/Tx queues.
102          */
103         /* TODO - remove this limitation */
104         u16 num_queues;
105
106         /* Allow the client to choose which qzones to use for Rx/Tx,
107          * and which queue_base to use for Tx queues on a per-queue basis.
108          * Notice values should be relative to the PF resources.
109          */
110         u16 req_rx_queue[ECORE_MAX_VF_CHAINS_PER_PF];
111         u16 req_tx_queue[ECORE_MAX_VF_CHAINS_PER_PF];
112
113         u8 vport_id;
114
115         /* Should be set in case RSS is going to be used for VF */
116         u8 rss_eng_id;
117 };
118
119 #ifdef CONFIG_ECORE_SW_CHANNEL
120 /* This is SW channel related only... */
121 enum mbx_state {
122         VF_PF_UNKNOWN_STATE                     = 0,
123         VF_PF_WAIT_FOR_START_REQUEST            = 1,
124         VF_PF_WAIT_FOR_NEXT_CHUNK_OF_REQUEST    = 2,
125         VF_PF_REQUEST_IN_PROCESSING             = 3,
126         VF_PF_RESPONSE_READY                    = 4,
127 };
128
129 struct ecore_iov_sw_mbx {
130         enum mbx_state          mbx_state;
131
132         u32                     request_size;
133         u32                     request_offset;
134
135         u32                     response_size;
136         u32                     response_offset;
137 };
138
139 /**
140  * @brief Get the vf sw mailbox params
141  *
142  * @param p_hwfn
143  * @param rel_vf_id
144  *
145  * @return struct ecore_iov_sw_mbx*
146  */
147 struct ecore_iov_sw_mbx*
148 ecore_iov_get_vf_sw_mbx(struct ecore_hwfn *p_hwfn,
149                         u16 rel_vf_id);
150 #endif
151
152 /* This struct is part of ecore_dev and contains data relevant to all hwfns;
153  * Initialized only if SR-IOV cpabability is exposed in PCIe config space.
154  */
155 struct ecore_hw_sriov_info {
156         /* standard SRIOV capability fields, mostly for debugging */
157         int     pos;            /* capability position */
158         int     nres;           /* number of resources */
159         u32     cap;            /* SR-IOV Capabilities */
160         u16     ctrl;           /* SR-IOV Control */
161         u16     total_vfs;      /* total VFs associated with the PF */
162         u16     num_vfs;        /* number of vfs that have been started */
163         u16     initial_vfs;    /* initial VFs associated with the PF */
164         u16     nr_virtfn;      /* number of VFs available */
165         u16     offset;         /* first VF Routing ID offset */
166         u16     stride;         /* following VF stride */
167         u16     vf_device_id;   /* VF device id */
168         u32     pgsz;           /* page size for BAR alignment */
169         u8      link;           /* Function Dependency Link */
170
171         u32     first_vf_in_pf;
172 };
173
174 #ifdef CONFIG_ECORE_SRIOV
175 #ifndef LINUX_REMOVE
176 /**
177  * @brief mark/clear all VFs before/after an incoming PCIe sriov
178  *        disable.
179  *
180  * @param p_dev
181  * @param to_disable
182  */
183 void ecore_iov_set_vfs_to_disable(struct ecore_dev *p_dev,
184                                   u8 to_disable);
185
186 /**
187  * @brief mark/clear chosen VF before/after an incoming PCIe
188  *        sriov disable.
189  *
190  * @param p_dev
191  * @param rel_vf_id
192  * @param to_disable
193  */
194 void ecore_iov_set_vf_to_disable(struct ecore_dev *p_dev,
195                                  u16 rel_vf_id,
196                                  u8 to_disable);
197
198 /**
199  * @brief ecore_iov_init_hw_for_vf - initialize the HW for
200  *        enabling access of a VF. Also includes preparing the
201  *        IGU for VF access. This needs to be called AFTER hw is
202  *        initialized and BEFORE VF is loaded inside the VM.
203  *
204  * @param p_hwfn
205  * @param p_ptt
206  * @param p_params
207  *
208  * @return enum _ecore_status_t
209  */
210 enum _ecore_status_t ecore_iov_init_hw_for_vf(struct ecore_hwfn *p_hwfn,
211                                               struct ecore_ptt *p_ptt,
212                                               struct ecore_iov_vf_init_params
213                                                      *p_params);
214
215 /**
216  * @brief ecore_iov_process_mbx_req - process a request received
217  *        from the VF
218  *
219  * @param p_hwfn
220  * @param p_ptt
221  * @param vfid
222  */
223 void ecore_iov_process_mbx_req(struct ecore_hwfn *p_hwfn,
224                                struct ecore_ptt *p_ptt,
225                                int vfid);
226
227 /**
228  * @brief ecore_iov_release_hw_for_vf - called once upper layer
229  *        knows VF is done with - can release any resources
230  *        allocated for VF at this point. this must be done once
231  *        we know VF is no longer loaded in VM.
232  *
233  * @param p_hwfn
234  * @param p_ptt
235  * @param rel_vf_id
236  *
237  * @return enum _ecore_status_t
238  */
239 enum _ecore_status_t ecore_iov_release_hw_for_vf(struct ecore_hwfn *p_hwfn,
240                                                  struct ecore_ptt *p_ptt,
241                                                  u16 rel_vf_id);
242
243 /**
244  * @brief ecore_iov_set_vf_ctx - set a context for a given VF
245  *
246  * @param p_hwfn
247  * @param vf_id
248  * @param ctx
249  *
250  * @return enum _ecore_status_t
251  */
252 enum _ecore_status_t ecore_iov_set_vf_ctx(struct ecore_hwfn *p_hwfn,
253                                           u16 vf_id,
254                                           void *ctx);
255
256 /**
257  * @brief FLR cleanup for all VFs
258  *
259  * @param p_hwfn
260  * @param p_ptt
261  *
262  * @return enum _ecore_status_t
263  */
264 enum _ecore_status_t ecore_iov_vf_flr_cleanup(struct ecore_hwfn *p_hwfn,
265                                               struct ecore_ptt *p_ptt);
266
267 /**
268  * @brief FLR cleanup for single VF
269  *
270  * @param p_hwfn
271  * @param p_ptt
272  * @param rel_vf_id
273  *
274  * @return enum _ecore_status_t
275  */
276 enum _ecore_status_t
277 ecore_iov_single_vf_flr_cleanup(struct ecore_hwfn *p_hwfn,
278                                 struct ecore_ptt *p_ptt,
279                                 u16 rel_vf_id);
280
281 /**
282  * @brief Update the bulletin with link information. Notice this does NOT
283  *        send a bulletin update, only updates the PF's bulletin.
284  *
285  * @param p_hwfn
286  * @param p_vf
287  * @param params - the link params to use for the VF link configuration
288  * @param link - the link output to use for the VF link configuration
289  * @param p_caps - the link default capabilities.
290  */
291 void ecore_iov_set_link(struct ecore_hwfn *p_hwfn,
292                         u16 vfid,
293                         struct ecore_mcp_link_params *params,
294                         struct ecore_mcp_link_state *link,
295                         struct ecore_mcp_link_capabilities *p_caps);
296
297 /**
298  * @brief Returns link information as perceived by VF.
299  *
300  * @param p_hwfn
301  * @param p_vf
302  * @param p_params - the link params visible to vf.
303  * @param p_link - the link state visible to vf.
304  * @param p_caps - the link default capabilities visible to vf.
305  */
306 void ecore_iov_get_link(struct ecore_hwfn *p_hwfn,
307                         u16 vfid,
308                         struct ecore_mcp_link_params *params,
309                         struct ecore_mcp_link_state *link,
310                         struct ecore_mcp_link_capabilities *p_caps);
311
312 /**
313  * @brief return if the VF is pending FLR
314  *
315  * @param p_hwfn
316  * @param rel_vf_id
317  *
318  * @return bool
319  */
320 bool ecore_iov_is_vf_pending_flr(struct ecore_hwfn *p_hwfn,
321                                  u16 rel_vf_id);
322
323 /**
324  * @brief Check if given VF ID @vfid is valid
325  *        w.r.t. @b_enabled_only value
326  *        if b_enabled_only = true - only enabled VF id is valid
327  *        else any VF id less than max_vfs is valid
328  *
329  * @param p_hwfn
330  * @param rel_vf_id - Relative VF ID
331  * @param b_enabled_only - consider only enabled VF
332  * @param b_non_malicious - true iff we want to validate vf isn't malicious.
333  *
334  * @return bool - true for valid VF ID
335  */
336 bool ecore_iov_is_valid_vfid(struct ecore_hwfn *p_hwfn,
337                              int rel_vf_id,
338                              bool b_enabled_only, bool b_non_malicious);
339
340 /**
341  * @brief Get VF's public info structure
342  *
343  * @param p_hwfn
344  * @param vfid - Relative VF ID
345  * @param b_enabled_only - false if want to access even if vf is disabled
346  *
347  * @return struct ecore_public_vf_info *
348  */
349 struct ecore_public_vf_info*
350 ecore_iov_get_public_vf_info(struct ecore_hwfn *p_hwfn,
351                              u16 vfid, bool b_enabled_only);
352
353 /**
354  * @brief fills a bitmask of all VFs which have pending unhandled
355  *        messages.
356  *
357  * @param p_hwfn
358  */
359 void ecore_iov_pf_get_pending_events(struct ecore_hwfn *p_hwfn,
360                                      u64 *events);
361
362 /**
363  * @brief Copy VF's message to PF's buffer
364  *
365  * @param p_hwfn
366  * @param ptt
367  * @param vfid
368  *
369  * @return enum _ecore_status_t
370  */
371 enum _ecore_status_t ecore_iov_copy_vf_msg(struct ecore_hwfn *p_hwfn,
372                                            struct ecore_ptt *ptt,
373                                            int vfid);
374 /**
375  * @brief Set forced MAC address in PFs copy of bulletin board
376  *        and configures FW/HW to support the configuration.
377  *
378  * @param p_hwfn
379  * @param mac
380  * @param vfid
381  */
382 void ecore_iov_bulletin_set_forced_mac(struct ecore_hwfn *p_hwfn,
383                                        u8 *mac, int vfid);
384
385 /**
386  * @brief Set MAC address in PFs copy of bulletin board without
387  *        configuring FW/HW.
388  *
389  * @param p_hwfn
390  * @param mac
391  * @param vfid
392  */
393 enum _ecore_status_t ecore_iov_bulletin_set_mac(struct ecore_hwfn *p_hwfn,
394                                                 u8 *mac, int vfid);
395
396 /**
397  * @brief Set default behaviour of VF in case no vlans are configured for it
398  *        whether to accept only untagged traffic or all.
399  *        Must be called prior to the VF vport-start.
400  *
401  * @param p_hwfn
402  * @param b_untagged_only
403  * @param vfid
404  *
405  * @return ECORE_SUCCESS if configuration would stick.
406  */
407 enum _ecore_status_t
408 ecore_iov_bulletin_set_forced_untagged_default(struct ecore_hwfn *p_hwfn,
409                                                bool b_untagged_only,
410                                                int vfid);
411
412 /**
413  * @brief Get VFs opaque fid.
414  *
415  * @param p_hwfn
416  * @param vfid
417  * @param opaque_fid
418  */
419 void ecore_iov_get_vfs_opaque_fid(struct ecore_hwfn *p_hwfn, int vfid,
420                                   u16 *opaque_fid);
421
422 /**
423  * @brief Set forced VLAN [pvid] in PFs copy of bulletin board
424  *        and configures FW/HW to support the configuration.
425  *        Setting of pvid 0 would clear the feature.
426  * @param p_hwfn
427  * @param pvid
428  * @param vfid
429  */
430 void ecore_iov_bulletin_set_forced_vlan(struct ecore_hwfn *p_hwfn,
431                                         u16 pvid, int vfid);
432
433 /**
434  * @brief Check if VF has VPORT instance. This can be used
435  *        to check if VPORT is active.
436  *
437  * @param p_hwfn
438  */
439 bool ecore_iov_vf_has_vport_instance(struct ecore_hwfn *p_hwfn, int vfid);
440
441 /**
442  * @brief PF posts the bulletin to the VF
443  *
444  * @param p_hwfn
445  * @param p_vf
446  * @param p_ptt
447  *
448  * @return enum _ecore_status_t
449  */
450 enum _ecore_status_t ecore_iov_post_vf_bulletin(struct ecore_hwfn *p_hwfn,
451                                                 int vfid,
452                                                 struct ecore_ptt *p_ptt);
453
454 /**
455  * @brief Check if given VF (@vfid) is marked as stopped
456  *
457  * @param p_hwfn
458  * @param vfid
459  *
460  * @return bool : true if stopped
461  */
462 bool ecore_iov_is_vf_stopped(struct ecore_hwfn *p_hwfn, int vfid);
463
464 /**
465  * @brief Configure VF anti spoofing
466  *
467  * @param p_hwfn
468  * @param vfid
469  * @param val - spoofchk value - true/false
470  *
471  * @return enum _ecore_status_t
472  */
473 enum _ecore_status_t ecore_iov_spoofchk_set(struct ecore_hwfn *p_hwfn,
474                                             int vfid, bool val);
475
476 /**
477  * @brief Get VF's configured spoof value.
478  *
479  * @param p_hwfn
480  * @param vfid
481  *
482  * @return bool - spoofchk value - true/false
483  */
484 bool ecore_iov_spoofchk_get(struct ecore_hwfn *p_hwfn, int vfid);
485
486 /**
487  * @brief Check for SRIOV sanity by PF.
488  *
489  * @param p_hwfn
490  * @param vfid
491  *
492  * @return bool - true if sanity checks passes, else false
493  */
494 bool ecore_iov_pf_sanity_check(struct ecore_hwfn *p_hwfn, int vfid);
495
496 /**
497  * @brief Get the num of VF chains.
498  *
499  * @param p_hwfn
500  *
501  * @return u8
502  */
503 u8 ecore_iov_vf_chains_per_pf(struct ecore_hwfn *p_hwfn);
504
505 /**
506  * @brief Get vf request mailbox params
507  *
508  * @param p_hwfn
509  * @param rel_vf_id
510  * @param pp_req_virt_addr
511  * @param p_req_virt_size
512  */
513 void ecore_iov_get_vf_req_virt_mbx_params(struct ecore_hwfn *p_hwfn,
514                                           u16 rel_vf_id,
515                                           void **pp_req_virt_addr,
516                                           u16 *p_req_virt_size);
517
518 /**
519  * @brief Get vf mailbox params
520  *
521  * @param p_hwfn
522  * @param rel_vf_id
523  * @param pp_reply_virt_addr
524  * @param p_reply_virt_size
525  */
526 void ecore_iov_get_vf_reply_virt_mbx_params(struct ecore_hwfn *p_hwfn,
527                                             u16 rel_vf_id,
528                                             void **pp_reply_virt_addr,
529                                             u16 *p_reply_virt_size);
530
531 /**
532  * @brief Validate if the given length is a valid vfpf message
533  *        length
534  *
535  * @param length
536  *
537  * @return bool
538  */
539 bool ecore_iov_is_valid_vfpf_msg_length(u32 length);
540
541 /**
542  * @brief Return the max pfvf message length
543  *
544  * @return u32
545  */
546 u32 ecore_iov_pfvf_msg_length(void);
547
548 /**
549  * @brief Returns MAC address if one is configured
550  *
551  * @parm p_hwfn
552  * @parm rel_vf_id
553  *
554  * @return OSAL_NULL if mac isn't set; Otherwise, returns MAC.
555  */
556 u8 *ecore_iov_bulletin_get_mac(struct ecore_hwfn *p_hwfn,
557                                u16 rel_vf_id);
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 #endif
717
718 /**
719  * @brief ecore_pf_configure_vf_queue_coalesce - PF configure coalesce
720  *    parameters of VFs for Rx and Tx queue.
721  *    While the API allows setting coalescing per-qid, all queues sharing a SB
722  *    should be in same range [i.e., either 0-0x7f, 0x80-0xff or 0x100-0x1ff]
723  *    otherwise configuration would break.
724  *
725  * @param p_hwfn
726  * @param rx_coal - Rx Coalesce value in micro seconds.
727  * @param tx_coal - TX Coalesce value in micro seconds.
728  * @param vf_id
729  * @param qid
730  *
731  * @return int
732  **/
733 enum _ecore_status_t
734 ecore_iov_pf_configure_vf_queue_coalesce(struct ecore_hwfn *p_hwfn,
735                                          u16 rx_coal, u16 tx_coal,
736                                          u16 vf_id, u16 qid);
737
738 /**
739  * @brief - Given a VF index, return index of next [including that] active VF.
740  *
741  * @param p_hwfn
742  * @param rel_vf_id
743  *
744  * @return MAX_NUM_VFS_K2 in case no further active VFs, otherwise index.
745  */
746 u16 ecore_iov_get_next_active_vf(struct ecore_hwfn *p_hwfn, u16 rel_vf_id);
747
748 void ecore_iov_bulletin_set_udp_ports(struct ecore_hwfn *p_hwfn, int vfid,
749                                       u16 vxlan_port, u16 geneve_port);
750
751 #ifdef CONFIG_ECORE_SW_CHANNEL
752 /**
753  * @brief Set whether PF should communicate with VF using SW/HW channel
754  *        Needs to be called for an enabled VF before acquire is over
755  *        [latest good point for doing that is OSAL_IOV_VF_ACQUIRE()]
756  *
757  * @param p_hwfn
758  * @param vfid - relative vf index
759  * @param b_is_hw - true iff PF is to use HW channel for communication
760  */
761 void ecore_iov_set_vf_hw_channel(struct ecore_hwfn *p_hwfn, int vfid,
762                                  bool b_is_hw);
763 #endif
764 #endif /* CONFIG_ECORE_SRIOV */
765
766 #define ecore_for_each_vf(_p_hwfn, _i)                                  \
767         for (_i = ecore_iov_get_next_active_vf(_p_hwfn, 0);             \
768              _i < MAX_NUM_VFS_K2;                                       \
769              _i = ecore_iov_get_next_active_vf(_p_hwfn, _i + 1))
770
771 #endif