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 #define ICE_MAX_VLANID 4095
9 #define ICE_VLAN_PRIORITY_S 12
10 #define ICE_VLAN_M 0xFFF
11 #define ICE_PRIORITY_M 0x7000
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
17 /* Malicious Driver Detection */
18 #define ICE_DFLT_NUM_MDD_EVENTS_ALLOWED 3
19 #define ICE_DFLT_NUM_INVAL_MSGS_ALLOWED 10
21 /* Static VF transaction/status register def */
22 #define VF_DEVICE_STATUS 0xAA
23 #define VF_TRANS_PENDING_M 0x20
25 /* Specific VF states */
27 ICE_VF_STATE_INIT = 0,
31 ICE_VF_STATE_MC_PROMISC,
32 ICE_VF_STATE_UC_PROMISC,
33 /* state to indicate if PF needs to do vector assignment for VF.
34 * This needs to be set during first time VF initialization or later
35 * when VF asks for more Vectors through virtchnl OP.
37 ICE_VF_STATE_CFG_INTR,
42 enum ice_virtchnl_cap {
43 ICE_VIRTCHNL_VF_CAP_L2 = 0,
44 ICE_VIRTCHNL_VF_CAP_PRIVILEGE,
47 /* VF information structure */
51 s16 vf_id; /* VF id in the PF space */
52 u32 driver_caps; /* reported by VF driver */
53 int first_vector_idx; /* first vector index of this VF */
54 struct ice_sw *vf_sw_id; /* switch id the VF VSIs connect to */
55 struct virtchnl_version_info vf_ver;
56 struct virtchnl_ether_addr dflt_lan_addr;
58 u8 pf_set_mac; /* VF MAC address set by VMM admin */
60 u16 lan_vsi_idx; /* index into PF struct */
61 u16 lan_vsi_num; /* ID as used by firmware */
62 u64 num_mdd_events; /* number of mdd events detected */
63 u64 num_inval_msgs; /* number of continuous invalid msgs */
64 u64 num_valid_msgs; /* number of valid msgs detected */
65 unsigned long vf_caps; /* vf's adv. capabilities */
66 DECLARE_BITMAP(vf_states, ICE_VF_STATES_NBITS); /* VF runtime states */
67 unsigned int tx_rate; /* Tx bandwidth limit in Mbps */
69 u8 link_up; /* only valid if VF link is forced */
73 u8 num_req_qs; /* num of queue pairs requested by VF */
77 void ice_process_vflr_event(struct ice_pf *pf);
78 int ice_sriov_configure(struct pci_dev *pdev, int num_vfs);
79 int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac);
80 int ice_get_vf_cfg(struct net_device *netdev, int vf_id,
81 struct ifla_vf_info *ivi);
83 void ice_free_vfs(struct ice_pf *pf);
84 void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event);
85 void ice_vc_notify_link_state(struct ice_pf *pf);
86 void ice_vc_notify_reset(struct ice_pf *pf);
87 bool ice_reset_all_vfs(struct ice_pf *pf, bool is_vflr);
89 int ice_set_vf_port_vlan(struct net_device *netdev, int vf_id,
90 u16 vlan_id, u8 qos, __be16 vlan_proto);
92 int ice_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,
95 int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted);
97 int ice_set_vf_link_state(struct net_device *netdev, int vf_id, int link_state);
99 int ice_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool ena);
100 #else /* CONFIG_PCI_IOV */
101 #define ice_process_vflr_event(pf) do {} while (0)
102 #define ice_free_vfs(pf) do {} while (0)
103 #define ice_vc_process_vf_msg(pf, event) do {} while (0)
104 #define ice_vc_notify_link_state(pf) do {} while (0)
105 #define ice_vc_notify_reset(pf) do {} while (0)
108 ice_reset_all_vfs(struct ice_pf __always_unused *pf,
109 bool __always_unused is_vflr)
115 ice_sriov_configure(struct pci_dev __always_unused *pdev,
116 int __always_unused num_vfs)
122 ice_set_vf_mac(struct net_device __always_unused *netdev,
123 int __always_unused vf_id, u8 __always_unused *mac)
129 ice_get_vf_cfg(struct net_device __always_unused *netdev,
130 int __always_unused vf_id,
131 struct ifla_vf_info __always_unused *ivi)
137 ice_set_vf_trust(struct net_device __always_unused *netdev,
138 int __always_unused vf_id, bool __always_unused trusted)
144 ice_set_vf_port_vlan(struct net_device __always_unused *netdev,
145 int __always_unused vf_id, u16 __always_unused vid,
146 u8 __always_unused qos, __be16 __always_unused v_proto)
152 ice_set_vf_spoofchk(struct net_device __always_unused *netdev,
153 int __always_unused vf_id, bool __always_unused ena)
159 ice_set_vf_link_state(struct net_device __always_unused *netdev,
160 int __always_unused vf_id, int __always_unused link_state)
166 ice_set_vf_bw(struct net_device __always_unused *netdev,
167 int __always_unused vf_id, int __always_unused min_tx_rate,
168 int __always_unused max_tx_rate)
172 #endif /* CONFIG_PCI_IOV */
173 #endif /* _ICE_VIRTCHNL_PF_H_ */