0001
0002
0003
0004 #ifndef _ICE_SRIOV_H_
0005 #define _ICE_SRIOV_H_
0006 #include "ice_virtchnl_fdir.h"
0007 #include "ice_vf_lib.h"
0008 #include "ice_virtchnl.h"
0009
0010
0011 #define VF_DEVICE_STATUS 0xAA
0012 #define VF_TRANS_PENDING_M 0x20
0013
0014
0015 #define ICE_PCI_CIAD_WAIT_COUNT 100
0016 #define ICE_PCI_CIAD_WAIT_DELAY_US 1
0017
0018
0019 #define ICE_MIN_QS_PER_VF 1
0020 #define ICE_NONQ_VECS_VF 1
0021 #define ICE_NUM_VF_MSIX_MED 17
0022 #define ICE_NUM_VF_MSIX_SMALL 5
0023 #define ICE_NUM_VF_MSIX_MULTIQ_MIN 3
0024 #define ICE_MIN_INTR_PER_VF (ICE_MIN_QS_PER_VF + 1)
0025 #define ICE_MAX_VF_RESET_TRIES 40
0026 #define ICE_MAX_VF_RESET_SLEEP_MS 20
0027
0028 #ifdef CONFIG_PCI_IOV
0029 void ice_process_vflr_event(struct ice_pf *pf);
0030 int ice_sriov_configure(struct pci_dev *pdev, int num_vfs);
0031 int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac);
0032 int
0033 ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi);
0034
0035 void ice_free_vfs(struct ice_pf *pf);
0036 void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event);
0037 void ice_restore_all_vfs_msi_state(struct pci_dev *pdev);
0038 bool
0039 ice_is_malicious_vf(struct ice_pf *pf, struct ice_rq_event_info *event,
0040 u16 num_msg_proc, u16 num_msg_pending);
0041
0042 int
0043 ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,
0044 __be16 vlan_proto);
0045
0046 int
0047 ice_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,
0048 int max_tx_rate);
0049
0050 int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted);
0051
0052 int ice_set_vf_link_state(struct net_device *netdev, int vf_id, int link_state);
0053
0054 int ice_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool ena);
0055
0056 int ice_calc_vf_reg_idx(struct ice_vf *vf, struct ice_q_vector *q_vector);
0057
0058 int
0059 ice_get_vf_stats(struct net_device *netdev, int vf_id,
0060 struct ifla_vf_stats *vf_stats);
0061 void
0062 ice_vf_lan_overflow_event(struct ice_pf *pf, struct ice_rq_event_info *event);
0063 void ice_print_vfs_mdd_events(struct ice_pf *pf);
0064 void ice_print_vf_rx_mdd_event(struct ice_vf *vf);
0065 bool
0066 ice_vc_validate_pattern(struct ice_vf *vf, struct virtchnl_proto_hdrs *proto);
0067 #else
0068 static inline void ice_process_vflr_event(struct ice_pf *pf) { }
0069 static inline void ice_free_vfs(struct ice_pf *pf) { }
0070 static inline
0071 void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event) { }
0072 static inline
0073 void ice_vf_lan_overflow_event(struct ice_pf *pf, struct ice_rq_event_info *event) { }
0074 static inline void ice_print_vfs_mdd_events(struct ice_pf *pf) { }
0075 static inline void ice_print_vf_rx_mdd_event(struct ice_vf *vf) { }
0076 static inline void ice_restore_all_vfs_msi_state(struct pci_dev *pdev) { }
0077
0078 static inline bool
0079 ice_is_malicious_vf(struct ice_pf __always_unused *pf,
0080 struct ice_rq_event_info __always_unused *event,
0081 u16 __always_unused num_msg_proc,
0082 u16 __always_unused num_msg_pending)
0083 {
0084 return false;
0085 }
0086
0087 static inline int
0088 ice_sriov_configure(struct pci_dev __always_unused *pdev,
0089 int __always_unused num_vfs)
0090 {
0091 return -EOPNOTSUPP;
0092 }
0093
0094 static inline int
0095 ice_set_vf_mac(struct net_device __always_unused *netdev,
0096 int __always_unused vf_id, u8 __always_unused *mac)
0097 {
0098 return -EOPNOTSUPP;
0099 }
0100
0101 static inline int
0102 ice_get_vf_cfg(struct net_device __always_unused *netdev,
0103 int __always_unused vf_id,
0104 struct ifla_vf_info __always_unused *ivi)
0105 {
0106 return -EOPNOTSUPP;
0107 }
0108
0109 static inline int
0110 ice_set_vf_trust(struct net_device __always_unused *netdev,
0111 int __always_unused vf_id, bool __always_unused trusted)
0112 {
0113 return -EOPNOTSUPP;
0114 }
0115
0116 static inline int
0117 ice_set_vf_port_vlan(struct net_device __always_unused *netdev,
0118 int __always_unused vf_id, u16 __always_unused vid,
0119 u8 __always_unused qos, __be16 __always_unused v_proto)
0120 {
0121 return -EOPNOTSUPP;
0122 }
0123
0124 static inline int
0125 ice_set_vf_spoofchk(struct net_device __always_unused *netdev,
0126 int __always_unused vf_id, bool __always_unused ena)
0127 {
0128 return -EOPNOTSUPP;
0129 }
0130
0131 static inline int
0132 ice_set_vf_link_state(struct net_device __always_unused *netdev,
0133 int __always_unused vf_id, int __always_unused link_state)
0134 {
0135 return -EOPNOTSUPP;
0136 }
0137
0138 static inline int
0139 ice_set_vf_bw(struct net_device __always_unused *netdev,
0140 int __always_unused vf_id, int __always_unused min_tx_rate,
0141 int __always_unused max_tx_rate)
0142 {
0143 return -EOPNOTSUPP;
0144 }
0145
0146 static inline int
0147 ice_calc_vf_reg_idx(struct ice_vf __always_unused *vf,
0148 struct ice_q_vector __always_unused *q_vector)
0149 {
0150 return 0;
0151 }
0152
0153 static inline int
0154 ice_get_vf_stats(struct net_device __always_unused *netdev,
0155 int __always_unused vf_id,
0156 struct ifla_vf_stats __always_unused *vf_stats)
0157 {
0158 return -EOPNOTSUPP;
0159 }
0160 #endif
0161 #endif