162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/* Copyright (c) 2018, Intel Corporation. */
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci#ifndef _ICE_SRIOV_H_
562306a36Sopenharmony_ci#define _ICE_SRIOV_H_
662306a36Sopenharmony_ci#include "ice_virtchnl_fdir.h"
762306a36Sopenharmony_ci#include "ice_vf_lib.h"
862306a36Sopenharmony_ci#include "ice_virtchnl.h"
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci/* Static VF transaction/status register def */
1162306a36Sopenharmony_ci#define VF_DEVICE_STATUS		0xAA
1262306a36Sopenharmony_ci#define VF_TRANS_PENDING_M		0x20
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci/* wait defines for polling PF_PCI_CIAD register status */
1562306a36Sopenharmony_ci#define ICE_PCI_CIAD_WAIT_COUNT		100
1662306a36Sopenharmony_ci#define ICE_PCI_CIAD_WAIT_DELAY_US	1
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci/* VF resource constraints */
1962306a36Sopenharmony_ci#define ICE_MIN_QS_PER_VF		1
2062306a36Sopenharmony_ci#define ICE_NONQ_VECS_VF		1
2162306a36Sopenharmony_ci#define ICE_NUM_VF_MSIX_MED		17
2262306a36Sopenharmony_ci#define ICE_NUM_VF_MSIX_SMALL		5
2362306a36Sopenharmony_ci#define ICE_NUM_VF_MSIX_MULTIQ_MIN	3
2462306a36Sopenharmony_ci#define ICE_MIN_INTR_PER_VF		(ICE_MIN_QS_PER_VF + 1)
2562306a36Sopenharmony_ci#define ICE_MAX_VF_RESET_TRIES		40
2662306a36Sopenharmony_ci#define ICE_MAX_VF_RESET_SLEEP_MS	20
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci#ifdef CONFIG_PCI_IOV
2962306a36Sopenharmony_civoid ice_process_vflr_event(struct ice_pf *pf);
3062306a36Sopenharmony_ciint ice_sriov_configure(struct pci_dev *pdev, int num_vfs);
3162306a36Sopenharmony_ciint ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac);
3262306a36Sopenharmony_ciint
3362306a36Sopenharmony_ciice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi);
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_civoid ice_free_vfs(struct ice_pf *pf);
3662306a36Sopenharmony_civoid ice_restore_all_vfs_msi_state(struct pci_dev *pdev);
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ciint
3962306a36Sopenharmony_ciice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,
4062306a36Sopenharmony_ci		     __be16 vlan_proto);
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ciint
4362306a36Sopenharmony_ciice_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,
4462306a36Sopenharmony_ci	      int max_tx_rate);
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ciint ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted);
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ciint ice_set_vf_link_state(struct net_device *netdev, int vf_id, int link_state);
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ciint ice_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool ena);
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ciint ice_calc_vf_reg_idx(struct ice_vf *vf, struct ice_q_vector *q_vector);
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ciint
5562306a36Sopenharmony_ciice_get_vf_stats(struct net_device *netdev, int vf_id,
5662306a36Sopenharmony_ci		 struct ifla_vf_stats *vf_stats);
5762306a36Sopenharmony_civoid
5862306a36Sopenharmony_ciice_vf_lan_overflow_event(struct ice_pf *pf, struct ice_rq_event_info *event);
5962306a36Sopenharmony_civoid ice_print_vfs_mdd_events(struct ice_pf *pf);
6062306a36Sopenharmony_civoid ice_print_vf_rx_mdd_event(struct ice_vf *vf);
6162306a36Sopenharmony_cibool
6262306a36Sopenharmony_ciice_vc_validate_pattern(struct ice_vf *vf, struct virtchnl_proto_hdrs *proto);
6362306a36Sopenharmony_ci#else /* CONFIG_PCI_IOV */
6462306a36Sopenharmony_cistatic inline void ice_process_vflr_event(struct ice_pf *pf) { }
6562306a36Sopenharmony_cistatic inline void ice_free_vfs(struct ice_pf *pf) { }
6662306a36Sopenharmony_cistatic inline
6762306a36Sopenharmony_civoid ice_vf_lan_overflow_event(struct ice_pf *pf, struct ice_rq_event_info *event) { }
6862306a36Sopenharmony_cistatic inline void ice_print_vfs_mdd_events(struct ice_pf *pf) { }
6962306a36Sopenharmony_cistatic inline void ice_print_vf_rx_mdd_event(struct ice_vf *vf) { }
7062306a36Sopenharmony_cistatic inline void ice_restore_all_vfs_msi_state(struct pci_dev *pdev) { }
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_cistatic inline int
7362306a36Sopenharmony_ciice_sriov_configure(struct pci_dev __always_unused *pdev,
7462306a36Sopenharmony_ci		    int __always_unused num_vfs)
7562306a36Sopenharmony_ci{
7662306a36Sopenharmony_ci	return -EOPNOTSUPP;
7762306a36Sopenharmony_ci}
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_cistatic inline int
8062306a36Sopenharmony_ciice_set_vf_mac(struct net_device __always_unused *netdev,
8162306a36Sopenharmony_ci	       int __always_unused vf_id, u8 __always_unused *mac)
8262306a36Sopenharmony_ci{
8362306a36Sopenharmony_ci	return -EOPNOTSUPP;
8462306a36Sopenharmony_ci}
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_cistatic inline int
8762306a36Sopenharmony_ciice_get_vf_cfg(struct net_device __always_unused *netdev,
8862306a36Sopenharmony_ci	       int __always_unused vf_id,
8962306a36Sopenharmony_ci	       struct ifla_vf_info __always_unused *ivi)
9062306a36Sopenharmony_ci{
9162306a36Sopenharmony_ci	return -EOPNOTSUPP;
9262306a36Sopenharmony_ci}
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_cistatic inline int
9562306a36Sopenharmony_ciice_set_vf_trust(struct net_device __always_unused *netdev,
9662306a36Sopenharmony_ci		 int __always_unused vf_id, bool __always_unused trusted)
9762306a36Sopenharmony_ci{
9862306a36Sopenharmony_ci	return -EOPNOTSUPP;
9962306a36Sopenharmony_ci}
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_cistatic inline int
10262306a36Sopenharmony_ciice_set_vf_port_vlan(struct net_device __always_unused *netdev,
10362306a36Sopenharmony_ci		     int __always_unused vf_id, u16 __always_unused vid,
10462306a36Sopenharmony_ci		     u8 __always_unused qos, __be16 __always_unused v_proto)
10562306a36Sopenharmony_ci{
10662306a36Sopenharmony_ci	return -EOPNOTSUPP;
10762306a36Sopenharmony_ci}
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_cistatic inline int
11062306a36Sopenharmony_ciice_set_vf_spoofchk(struct net_device __always_unused *netdev,
11162306a36Sopenharmony_ci		    int __always_unused vf_id, bool __always_unused ena)
11262306a36Sopenharmony_ci{
11362306a36Sopenharmony_ci	return -EOPNOTSUPP;
11462306a36Sopenharmony_ci}
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_cistatic inline int
11762306a36Sopenharmony_ciice_set_vf_link_state(struct net_device __always_unused *netdev,
11862306a36Sopenharmony_ci		      int __always_unused vf_id, int __always_unused link_state)
11962306a36Sopenharmony_ci{
12062306a36Sopenharmony_ci	return -EOPNOTSUPP;
12162306a36Sopenharmony_ci}
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_cistatic inline int
12462306a36Sopenharmony_ciice_set_vf_bw(struct net_device __always_unused *netdev,
12562306a36Sopenharmony_ci	      int __always_unused vf_id, int __always_unused min_tx_rate,
12662306a36Sopenharmony_ci	      int __always_unused max_tx_rate)
12762306a36Sopenharmony_ci{
12862306a36Sopenharmony_ci	return -EOPNOTSUPP;
12962306a36Sopenharmony_ci}
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_cistatic inline int
13262306a36Sopenharmony_ciice_calc_vf_reg_idx(struct ice_vf __always_unused *vf,
13362306a36Sopenharmony_ci		    struct ice_q_vector __always_unused *q_vector)
13462306a36Sopenharmony_ci{
13562306a36Sopenharmony_ci	return 0;
13662306a36Sopenharmony_ci}
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_cistatic inline int
13962306a36Sopenharmony_ciice_get_vf_stats(struct net_device __always_unused *netdev,
14062306a36Sopenharmony_ci		 int __always_unused vf_id,
14162306a36Sopenharmony_ci		 struct ifla_vf_stats __always_unused *vf_stats)
14262306a36Sopenharmony_ci{
14362306a36Sopenharmony_ci	return -EOPNOTSUPP;
14462306a36Sopenharmony_ci}
14562306a36Sopenharmony_ci#endif /* CONFIG_PCI_IOV */
14662306a36Sopenharmony_ci#endif /* _ICE_SRIOV_H_ */
147