]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blob - drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h
Merge tag 'asoc-v5.7' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie...
[mirror_ubuntu-hirsute-kernel.git] / drivers / net / ethernet / intel / ice / ice_virtchnl_pf.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2018, Intel Corporation. */
3
4 #ifndef _ICE_VIRTCHNL_PF_H_
5 #define _ICE_VIRTCHNL_PF_H_
6 #include "ice.h"
7
8 #define ICE_MAX_VLANID 4095
9 #define ICE_VLAN_PRIORITY_S 12
10 #define ICE_VLAN_M 0xFFF
11 #define ICE_PRIORITY_M 0x7000
12
13 /* Restrict number of MAC Addr and VLAN that non-trusted VF can programmed */
14 #define ICE_MAX_VLAN_PER_VF 8
15 #define ICE_MAX_MACADDR_PER_VF 12
16
17 /* Malicious Driver Detection */
18 #define ICE_DFLT_NUM_INVAL_MSGS_ALLOWED 10
19 #define ICE_MDD_EVENTS_THRESHOLD 30
20
21 /* Static VF transaction/status register def */
22 #define VF_DEVICE_STATUS 0xAA
23 #define VF_TRANS_PENDING_M 0x20
24
25 /* wait defines for polling PF_PCI_CIAD register status */
26 #define ICE_PCI_CIAD_WAIT_COUNT 100
27 #define ICE_PCI_CIAD_WAIT_DELAY_US 1
28
29 /* VF resources default values and limitation */
30 #define ICE_MAX_VF_COUNT 256
31 #define ICE_MAX_QS_PER_VF 256
32 #define ICE_MIN_QS_PER_VF 1
33 #define ICE_DFLT_QS_PER_VF 4
34 #define ICE_NONQ_VECS_VF 1
35 #define ICE_MAX_SCATTER_QS_PER_VF 16
36 #define ICE_MAX_BASE_QS_PER_VF 16
37 #define ICE_MAX_INTR_PER_VF 65
38 #define ICE_MAX_POLICY_INTR_PER_VF 33
39 #define ICE_MIN_INTR_PER_VF (ICE_MIN_QS_PER_VF + 1)
40 #define ICE_DFLT_INTR_PER_VF (ICE_DFLT_QS_PER_VF + 1)
41 #define ICE_MAX_VF_RESET_TRIES 40
42 #define ICE_MAX_VF_RESET_SLEEP_MS 20
43
44 #define ice_for_each_vf(pf, i) \
45 for ((i) = 0; (i) < (pf)->num_alloc_vfs; (i)++)
46
47 /* Specific VF states */
48 enum ice_vf_states {
49 ICE_VF_STATE_INIT = 0, /* PF is initializing VF */
50 ICE_VF_STATE_ACTIVE, /* VF resources are allocated for use */
51 ICE_VF_STATE_QS_ENA, /* VF queue(s) enabled */
52 ICE_VF_STATE_DIS,
53 ICE_VF_STATE_MC_PROMISC,
54 ICE_VF_STATE_UC_PROMISC,
55 ICE_VF_STATES_NBITS
56 };
57
58 /* VF capabilities */
59 enum ice_virtchnl_cap {
60 ICE_VIRTCHNL_VF_CAP_L2 = 0,
61 ICE_VIRTCHNL_VF_CAP_PRIVILEGE,
62 };
63
64 /* VF information structure */
65 struct ice_vf {
66 struct ice_pf *pf;
67
68 s16 vf_id; /* VF ID in the PF space */
69 u16 lan_vsi_idx; /* index into PF struct */
70 /* first vector index of this VF in the PF space */
71 int first_vector_idx;
72 struct ice_sw *vf_sw_id; /* switch ID the VF VSIs connect to */
73 struct virtchnl_version_info vf_ver;
74 u32 driver_caps; /* reported by VF driver */
75 struct virtchnl_ether_addr dflt_lan_addr;
76 DECLARE_BITMAP(txq_ena, ICE_MAX_BASE_QS_PER_VF);
77 DECLARE_BITMAP(rxq_ena, ICE_MAX_BASE_QS_PER_VF);
78 u16 port_vlan_id;
79 u8 pf_set_mac:1; /* VF MAC address set by VMM admin */
80 u8 trusted:1;
81 u8 spoofchk:1;
82 u8 link_forced:1;
83 u8 link_up:1; /* only valid if VF link is forced */
84 /* VSI indices - actual VSI pointers are maintained in the PF structure
85 * When assigned, these will be non-zero, because VSI 0 is always
86 * the main LAN VSI for the PF.
87 */
88 u16 lan_vsi_num; /* ID as used by firmware */
89 unsigned int tx_rate; /* Tx bandwidth limit in Mbps */
90 DECLARE_BITMAP(vf_states, ICE_VF_STATES_NBITS); /* VF runtime states */
91
92 u64 num_mdd_events; /* number of MDD events detected */
93 u64 num_inval_msgs; /* number of continuous invalid msgs */
94 u64 num_valid_msgs; /* number of valid msgs detected */
95 unsigned long vf_caps; /* VF's adv. capabilities */
96 u8 num_req_qs; /* num of queue pairs requested by VF */
97 u16 num_mac;
98 u16 num_vf_qs; /* num of queue configured per VF */
99 u16 num_qs_ena; /* total num of Tx/Rx queue enabled */
100 };
101
102 #ifdef CONFIG_PCI_IOV
103 void ice_process_vflr_event(struct ice_pf *pf);
104 int ice_sriov_configure(struct pci_dev *pdev, int num_vfs);
105 int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac);
106 int
107 ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi);
108
109 void ice_free_vfs(struct ice_pf *pf);
110 void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event);
111 void ice_vc_notify_link_state(struct ice_pf *pf);
112 void ice_vc_notify_reset(struct ice_pf *pf);
113 bool ice_reset_all_vfs(struct ice_pf *pf, bool is_vflr);
114
115 int
116 ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,
117 __be16 vlan_proto);
118
119 int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted);
120
121 int ice_set_vf_link_state(struct net_device *netdev, int vf_id, int link_state);
122
123 int ice_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool ena);
124
125 int ice_calc_vf_reg_idx(struct ice_vf *vf, struct ice_q_vector *q_vector);
126
127 void ice_set_vf_state_qs_dis(struct ice_vf *vf);
128 int
129 ice_get_vf_stats(struct net_device *netdev, int vf_id,
130 struct ifla_vf_stats *vf_stats);
131 #else /* CONFIG_PCI_IOV */
132 #define ice_process_vflr_event(pf) do {} while (0)
133 #define ice_free_vfs(pf) do {} while (0)
134 #define ice_vc_process_vf_msg(pf, event) do {} while (0)
135 #define ice_vc_notify_link_state(pf) do {} while (0)
136 #define ice_vc_notify_reset(pf) do {} while (0)
137 #define ice_set_vf_state_qs_dis(vf) do {} while (0)
138
139 static inline bool
140 ice_reset_all_vfs(struct ice_pf __always_unused *pf,
141 bool __always_unused is_vflr)
142 {
143 return true;
144 }
145
146 static inline int
147 ice_sriov_configure(struct pci_dev __always_unused *pdev,
148 int __always_unused num_vfs)
149 {
150 return -EOPNOTSUPP;
151 }
152
153 static inline int
154 ice_set_vf_mac(struct net_device __always_unused *netdev,
155 int __always_unused vf_id, u8 __always_unused *mac)
156 {
157 return -EOPNOTSUPP;
158 }
159
160 static inline int
161 ice_get_vf_cfg(struct net_device __always_unused *netdev,
162 int __always_unused vf_id,
163 struct ifla_vf_info __always_unused *ivi)
164 {
165 return -EOPNOTSUPP;
166 }
167
168 static inline int
169 ice_set_vf_trust(struct net_device __always_unused *netdev,
170 int __always_unused vf_id, bool __always_unused trusted)
171 {
172 return -EOPNOTSUPP;
173 }
174
175 static inline int
176 ice_set_vf_port_vlan(struct net_device __always_unused *netdev,
177 int __always_unused vf_id, u16 __always_unused vid,
178 u8 __always_unused qos, __be16 __always_unused v_proto)
179 {
180 return -EOPNOTSUPP;
181 }
182
183 static inline int
184 ice_set_vf_spoofchk(struct net_device __always_unused *netdev,
185 int __always_unused vf_id, bool __always_unused ena)
186 {
187 return -EOPNOTSUPP;
188 }
189
190 static inline int
191 ice_set_vf_link_state(struct net_device __always_unused *netdev,
192 int __always_unused vf_id, int __always_unused link_state)
193 {
194 return -EOPNOTSUPP;
195 }
196
197 static inline int
198 ice_calc_vf_reg_idx(struct ice_vf __always_unused *vf,
199 struct ice_q_vector __always_unused *q_vector)
200 {
201 return 0;
202 }
203
204 static inline int
205 ice_get_vf_stats(struct net_device __always_unused *netdev,
206 int __always_unused vf_id,
207 struct ifla_vf_stats __always_unused *vf_stats)
208 {
209 return -EOPNOTSUPP;
210 }
211 #endif /* CONFIG_PCI_IOV */
212 #endif /* _ICE_VIRTCHNL_PF_H_ */