1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2018, Intel Corporation. */
4 #ifndef _ICE_VIRTCHNL_PF_H_
5 #define _ICE_VIRTCHNL_PF_H_
8 /* Restrict number of MAC Addr and VLAN that non-trusted VF can programmed */
9 #define ICE_MAX_VLAN_PER_VF 8
10 #define ICE_MAX_MACADDR_PER_VF 12
12 /* Malicious Driver Detection */
13 #define ICE_DFLT_NUM_INVAL_MSGS_ALLOWED 10
14 #define ICE_MDD_EVENTS_THRESHOLD 30
16 /* Static VF transaction/status register def */
17 #define VF_DEVICE_STATUS 0xAA
18 #define VF_TRANS_PENDING_M 0x20
20 /* wait defines for polling PF_PCI_CIAD register status */
21 #define ICE_PCI_CIAD_WAIT_COUNT 100
22 #define ICE_PCI_CIAD_WAIT_DELAY_US 1
24 /* VF resource constraints */
25 #define ICE_MAX_VF_COUNT 256
26 #define ICE_MIN_QS_PER_VF 1
27 #define ICE_NONQ_VECS_VF 1
28 #define ICE_MAX_SCATTER_QS_PER_VF 16
29 #define ICE_MAX_RSS_QS_PER_VF 16
30 #define ICE_NUM_VF_MSIX_MED 17
31 #define ICE_NUM_VF_MSIX_SMALL 5
32 #define ICE_MIN_INTR_PER_VF (ICE_MIN_QS_PER_VF + 1)
33 #define ICE_MAX_VF_RESET_TRIES 40
34 #define ICE_MAX_VF_RESET_SLEEP_MS 20
36 #define ice_for_each_vf(pf, i) \
37 for ((i) = 0; (i) < (pf)->num_alloc_vfs; (i)++)
39 /* Specific VF states */
41 ICE_VF_STATE_INIT
= 0, /* PF is initializing VF */
42 ICE_VF_STATE_ACTIVE
, /* VF resources are allocated for use */
43 ICE_VF_STATE_QS_ENA
, /* VF queue(s) enabled */
45 ICE_VF_STATE_MC_PROMISC
,
46 ICE_VF_STATE_UC_PROMISC
,
51 enum ice_virtchnl_cap
{
52 ICE_VIRTCHNL_VF_CAP_L2
= 0,
53 ICE_VIRTCHNL_VF_CAP_PRIVILEGE
,
56 /* VF MDD events print structure */
57 struct ice_mdd_vf_events
{
58 u16 count
; /* total count of Rx|Tx events */
59 /* count number of the last printed event */
63 /* VF information structure */
67 s16 vf_id
; /* VF ID in the PF space */
68 u16 lan_vsi_idx
; /* index into PF struct */
69 /* first vector index of this VF in the PF space */
71 struct ice_sw
*vf_sw_id
; /* switch ID the VF VSIs connect to */
72 struct virtchnl_version_info vf_ver
;
73 u32 driver_caps
; /* reported by VF driver */
74 struct virtchnl_ether_addr dflt_lan_addr
;
75 DECLARE_BITMAP(txq_ena
, ICE_MAX_RSS_QS_PER_VF
);
76 DECLARE_BITMAP(rxq_ena
, ICE_MAX_RSS_QS_PER_VF
);
77 u16 port_vlan_info
; /* Port VLAN ID and QoS */
78 u8 pf_set_mac
:1; /* VF MAC address set by VMM admin */
82 u8 link_up
:1; /* only valid if VF link is forced */
83 /* VSI indices - actual VSI pointers are maintained in the PF structure
84 * When assigned, these will be non-zero, because VSI 0 is always
85 * the main LAN VSI for the PF.
87 u16 lan_vsi_num
; /* ID as used by firmware */
88 unsigned int tx_rate
; /* Tx bandwidth limit in Mbps */
89 DECLARE_BITMAP(vf_states
, ICE_VF_STATES_NBITS
); /* VF runtime states */
91 u64 num_inval_msgs
; /* number of continuous invalid msgs */
92 u64 num_valid_msgs
; /* number of valid msgs detected */
93 unsigned long vf_caps
; /* VF's adv. capabilities */
94 u8 num_req_qs
; /* num of queue pairs requested by VF */
96 u16 num_vf_qs
; /* num of queue configured per VF */
97 struct ice_mdd_vf_events mdd_rx_events
;
98 struct ice_mdd_vf_events mdd_tx_events
;
101 #ifdef CONFIG_PCI_IOV
102 void ice_process_vflr_event(struct ice_pf
*pf
);
103 int ice_sriov_configure(struct pci_dev
*pdev
, int num_vfs
);
104 int ice_set_vf_mac(struct net_device
*netdev
, int vf_id
, u8
*mac
);
106 ice_get_vf_cfg(struct net_device
*netdev
, int vf_id
, struct ifla_vf_info
*ivi
);
108 void ice_free_vfs(struct ice_pf
*pf
);
109 void ice_vc_process_vf_msg(struct ice_pf
*pf
, struct ice_rq_event_info
*event
);
110 void ice_vc_notify_link_state(struct ice_pf
*pf
);
111 void ice_vc_notify_reset(struct ice_pf
*pf
);
112 bool ice_reset_all_vfs(struct ice_pf
*pf
, bool is_vflr
);
113 bool ice_reset_vf(struct ice_vf
*vf
, bool is_vflr
);
116 ice_set_vf_port_vlan(struct net_device
*netdev
, int vf_id
, u16 vlan_id
, u8 qos
,
119 int ice_set_vf_trust(struct net_device
*netdev
, int vf_id
, bool trusted
);
121 int ice_set_vf_link_state(struct net_device
*netdev
, int vf_id
, int link_state
);
123 int ice_set_vf_spoofchk(struct net_device
*netdev
, int vf_id
, bool ena
);
125 int ice_calc_vf_reg_idx(struct ice_vf
*vf
, struct ice_q_vector
*q_vector
);
127 void ice_set_vf_state_qs_dis(struct ice_vf
*vf
);
129 ice_get_vf_stats(struct net_device
*netdev
, int vf_id
,
130 struct ifla_vf_stats
*vf_stats
);
132 ice_vf_lan_overflow_event(struct ice_pf
*pf
, struct ice_rq_event_info
*event
);
133 void ice_print_vfs_mdd_events(struct ice_pf
*pf
);
134 #else /* CONFIG_PCI_IOV */
135 #define ice_process_vflr_event(pf) do {} while (0)
136 #define ice_free_vfs(pf) do {} while (0)
137 #define ice_vc_process_vf_msg(pf, event) do {} while (0)
138 #define ice_vc_notify_link_state(pf) do {} while (0)
139 #define ice_vc_notify_reset(pf) do {} while (0)
140 #define ice_set_vf_state_qs_dis(vf) do {} while (0)
141 #define ice_vf_lan_overflow_event(pf, event) do {} while (0)
142 #define ice_print_vfs_mdd_events(pf) do {} while (0)
145 ice_reset_all_vfs(struct ice_pf __always_unused
*pf
,
146 bool __always_unused is_vflr
)
152 ice_reset_vf(struct ice_vf __always_unused
*vf
, bool __always_unused is_vflr
)
158 ice_sriov_configure(struct pci_dev __always_unused
*pdev
,
159 int __always_unused num_vfs
)
165 ice_set_vf_mac(struct net_device __always_unused
*netdev
,
166 int __always_unused vf_id
, u8 __always_unused
*mac
)
172 ice_get_vf_cfg(struct net_device __always_unused
*netdev
,
173 int __always_unused vf_id
,
174 struct ifla_vf_info __always_unused
*ivi
)
180 ice_set_vf_trust(struct net_device __always_unused
*netdev
,
181 int __always_unused vf_id
, bool __always_unused trusted
)
187 ice_set_vf_port_vlan(struct net_device __always_unused
*netdev
,
188 int __always_unused vf_id
, u16 __always_unused vid
,
189 u8 __always_unused qos
, __be16 __always_unused v_proto
)
195 ice_set_vf_spoofchk(struct net_device __always_unused
*netdev
,
196 int __always_unused vf_id
, bool __always_unused ena
)
202 ice_set_vf_link_state(struct net_device __always_unused
*netdev
,
203 int __always_unused vf_id
, int __always_unused link_state
)
209 ice_calc_vf_reg_idx(struct ice_vf __always_unused
*vf
,
210 struct ice_q_vector __always_unused
*q_vector
)
216 ice_get_vf_stats(struct net_device __always_unused
*netdev
,
217 int __always_unused vf_id
,
218 struct ifla_vf_stats __always_unused
*vf_stats
)
222 #endif /* CONFIG_PCI_IOV */
223 #endif /* _ICE_VIRTCHNL_PF_H_ */