xref: /linux/drivers/net/ethernet/intel/ice/ice_sriov.h (revision 8be4d31cb8aaeea27bde4b7ddb26e28a89062ebf)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2018, Intel Corporation. */
3 
4 #ifndef _ICE_SRIOV_H_
5 #define _ICE_SRIOV_H_
6 #include "ice_virtchnl_fdir.h"
7 #include "ice_vf_lib.h"
8 #include "ice_virtchnl.h"
9 
10 /* Static VF transaction/status register def */
11 #define VF_DEVICE_STATUS		0xAA
12 #define VF_TRANS_PENDING_M		0x20
13 
14 /* wait defines for polling PF_PCI_CIAD register status */
15 #define ICE_PCI_CIAD_WAIT_COUNT		100
16 #define ICE_PCI_CIAD_WAIT_DELAY_US	1
17 
18 /* VF resource constraints */
19 #define ICE_MIN_QS_PER_VF		1
20 #define ICE_NONQ_VECS_VF		1
21 #define ICE_NUM_VF_MSIX_MED		17
22 #define ICE_NUM_VF_MSIX_SMALL		5
23 #define ICE_NUM_VF_MSIX_MULTIQ_MIN	3
24 #define ICE_MIN_INTR_PER_VF		(ICE_MIN_QS_PER_VF + 1)
25 #define ICE_MAX_VF_RESET_TRIES		40
26 #define ICE_MAX_VF_RESET_SLEEP_MS	20
27 
28 #ifdef CONFIG_PCI_IOV
29 void ice_process_vflr_event(struct ice_pf *pf);
30 int ice_sriov_configure(struct pci_dev *pdev, int num_vfs);
31 int __ice_set_vf_mac(struct ice_pf *pf, u16 vf_id, const u8 *mac);
32 int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac);
33 int
34 ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi);
35 
36 void ice_free_vfs(struct ice_pf *pf);
37 void ice_restore_all_vfs_msi_state(struct ice_pf *pf);
38 
39 int
40 ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,
41 		     __be16 vlan_proto);
42 
43 int
44 ice_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,
45 	      int max_tx_rate);
46 
47 int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted);
48 
49 int ice_set_vf_link_state(struct net_device *netdev, int vf_id, int link_state);
50 
51 int ice_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool ena);
52 
53 void ice_calc_vf_reg_idx(struct ice_vf *vf, struct ice_q_vector *q_vector);
54 
55 int
56 ice_get_vf_stats(struct net_device *netdev, int vf_id,
57 		 struct ifla_vf_stats *vf_stats);
58 void
59 ice_vf_lan_overflow_event(struct ice_pf *pf, struct ice_rq_event_info *event);
60 void ice_print_vfs_mdd_events(struct ice_pf *pf);
61 void ice_print_vf_rx_mdd_event(struct ice_vf *vf);
62 void ice_print_vf_tx_mdd_event(struct ice_vf *vf);
63 bool
64 ice_vc_validate_pattern(struct ice_vf *vf, struct virtchnl_proto_hdrs *proto);
65 u32 ice_sriov_get_vf_total_msix(struct pci_dev *pdev);
66 int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count);
67 int ice_vf_vsi_dis_single_txq(struct ice_vf *vf, struct ice_vsi *vsi, u16 q_id);
68 #else /* CONFIG_PCI_IOV */
ice_process_vflr_event(struct ice_pf * pf)69 static inline void ice_process_vflr_event(struct ice_pf *pf) { }
ice_free_vfs(struct ice_pf * pf)70 static inline void ice_free_vfs(struct ice_pf *pf) { }
71 static inline
ice_vf_lan_overflow_event(struct ice_pf * pf,struct ice_rq_event_info * event)72 void ice_vf_lan_overflow_event(struct ice_pf *pf, struct ice_rq_event_info *event) { }
ice_print_vfs_mdd_events(struct ice_pf * pf)73 static inline void ice_print_vfs_mdd_events(struct ice_pf *pf) { }
ice_print_vf_rx_mdd_event(struct ice_vf * vf)74 static inline void ice_print_vf_rx_mdd_event(struct ice_vf *vf) { }
ice_print_vf_tx_mdd_event(struct ice_vf * vf)75 static inline void ice_print_vf_tx_mdd_event(struct ice_vf *vf) { }
ice_restore_all_vfs_msi_state(struct ice_pf * pf)76 static inline void ice_restore_all_vfs_msi_state(struct ice_pf *pf) { }
77 
78 static inline int
ice_sriov_configure(struct pci_dev __always_unused * pdev,int __always_unused num_vfs)79 ice_sriov_configure(struct pci_dev __always_unused *pdev,
80 		    int __always_unused num_vfs)
81 {
82 	return -EOPNOTSUPP;
83 }
84 
85 static inline int
__ice_set_vf_mac(struct ice_pf __always_unused * pf,u16 __always_unused vf_id,const u8 __always_unused * mac)86 __ice_set_vf_mac(struct ice_pf __always_unused *pf,
87 		 u16 __always_unused vf_id, const u8 __always_unused *mac)
88 {
89 	return -EOPNOTSUPP;
90 }
91 
92 static inline int
ice_set_vf_mac(struct net_device __always_unused * netdev,int __always_unused vf_id,u8 __always_unused * mac)93 ice_set_vf_mac(struct net_device __always_unused *netdev,
94 	       int __always_unused vf_id, u8 __always_unused *mac)
95 {
96 	return -EOPNOTSUPP;
97 }
98 
99 static inline int
ice_get_vf_cfg(struct net_device __always_unused * netdev,int __always_unused vf_id,struct ifla_vf_info __always_unused * ivi)100 ice_get_vf_cfg(struct net_device __always_unused *netdev,
101 	       int __always_unused vf_id,
102 	       struct ifla_vf_info __always_unused *ivi)
103 {
104 	return -EOPNOTSUPP;
105 }
106 
107 static inline int
ice_set_vf_trust(struct net_device __always_unused * netdev,int __always_unused vf_id,bool __always_unused trusted)108 ice_set_vf_trust(struct net_device __always_unused *netdev,
109 		 int __always_unused vf_id, bool __always_unused trusted)
110 {
111 	return -EOPNOTSUPP;
112 }
113 
114 static inline int
ice_set_vf_port_vlan(struct net_device __always_unused * netdev,int __always_unused vf_id,u16 __always_unused vid,u8 __always_unused qos,__be16 __always_unused v_proto)115 ice_set_vf_port_vlan(struct net_device __always_unused *netdev,
116 		     int __always_unused vf_id, u16 __always_unused vid,
117 		     u8 __always_unused qos, __be16 __always_unused v_proto)
118 {
119 	return -EOPNOTSUPP;
120 }
121 
122 static inline int
ice_set_vf_spoofchk(struct net_device __always_unused * netdev,int __always_unused vf_id,bool __always_unused ena)123 ice_set_vf_spoofchk(struct net_device __always_unused *netdev,
124 		    int __always_unused vf_id, bool __always_unused ena)
125 {
126 	return -EOPNOTSUPP;
127 }
128 
129 static inline int
ice_set_vf_link_state(struct net_device __always_unused * netdev,int __always_unused vf_id,int __always_unused link_state)130 ice_set_vf_link_state(struct net_device __always_unused *netdev,
131 		      int __always_unused vf_id, int __always_unused link_state)
132 {
133 	return -EOPNOTSUPP;
134 }
135 
136 static inline int
ice_set_vf_bw(struct net_device __always_unused * netdev,int __always_unused vf_id,int __always_unused min_tx_rate,int __always_unused max_tx_rate)137 ice_set_vf_bw(struct net_device __always_unused *netdev,
138 	      int __always_unused vf_id, int __always_unused min_tx_rate,
139 	      int __always_unused max_tx_rate)
140 {
141 	return -EOPNOTSUPP;
142 }
143 
144 static inline void
ice_calc_vf_reg_idx(struct ice_vf __always_unused * vf,struct ice_q_vector __always_unused * q_vector)145 ice_calc_vf_reg_idx(struct ice_vf __always_unused *vf,
146 		    struct ice_q_vector __always_unused *q_vector)
147 {
148 }
149 
150 static inline int
ice_get_vf_stats(struct net_device __always_unused * netdev,int __always_unused vf_id,struct ifla_vf_stats __always_unused * vf_stats)151 ice_get_vf_stats(struct net_device __always_unused *netdev,
152 		 int __always_unused vf_id,
153 		 struct ifla_vf_stats __always_unused *vf_stats)
154 {
155 	return -EOPNOTSUPP;
156 }
157 
ice_sriov_get_vf_total_msix(struct pci_dev * pdev)158 static inline u32 ice_sriov_get_vf_total_msix(struct pci_dev *pdev)
159 {
160 	return 0;
161 }
162 
163 static inline int
ice_sriov_set_msix_vec_count(struct pci_dev * vf_dev,int msix_vec_count)164 ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
165 {
166 	return -EOPNOTSUPP;
167 }
168 
ice_vf_vsi_dis_single_txq(struct ice_vf * vf,struct ice_vsi * vsi,u16 q_id)169 static inline int ice_vf_vsi_dis_single_txq(struct ice_vf *vf,
170 					    struct ice_vsi *vsi, u16 q_id)
171 {
172 	return -EOPNOTSUPP;
173 }
174 #endif /* CONFIG_PCI_IOV */
175 #endif /* _ICE_SRIOV_H_ */
176