Linux Audio

Check our new training course

Loading...
Note: File does not exist in v6.8.
  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/* Restrict number of MAC Addr and VLAN that non-trusted VF can programmed */
  9#define ICE_MAX_VLAN_PER_VF		8
 10/* MAC filters: 1 is reserved for the VF's default/perm_addr/LAA MAC, 1 for
 11 * broadcast, and 16 for additional unicast/multicast filters
 12 */
 13#define ICE_MAX_MACADDR_PER_VF		18
 14
 15/* Malicious Driver Detection */
 16#define ICE_DFLT_NUM_INVAL_MSGS_ALLOWED		10
 17#define ICE_MDD_EVENTS_THRESHOLD		30
 18
 19/* Static VF transaction/status register def */
 20#define VF_DEVICE_STATUS		0xAA
 21#define VF_TRANS_PENDING_M		0x20
 22
 23/* wait defines for polling PF_PCI_CIAD register status */
 24#define ICE_PCI_CIAD_WAIT_COUNT		100
 25#define ICE_PCI_CIAD_WAIT_DELAY_US	1
 26
 27/* VF resource constraints */
 28#define ICE_MAX_VF_COUNT		256
 29#define ICE_MIN_QS_PER_VF		1
 30#define ICE_NONQ_VECS_VF		1
 31#define ICE_MAX_SCATTER_QS_PER_VF	16
 32#define ICE_MAX_RSS_QS_PER_VF		16
 33#define ICE_NUM_VF_MSIX_MED		17
 34#define ICE_NUM_VF_MSIX_SMALL		5
 35#define ICE_NUM_VF_MSIX_MULTIQ_MIN	3
 36#define ICE_MIN_INTR_PER_VF		(ICE_MIN_QS_PER_VF + 1)
 37#define ICE_MAX_VF_RESET_TRIES		40
 38#define ICE_MAX_VF_RESET_SLEEP_MS	20
 39
 40#define ice_for_each_vf(pf, i) \
 41	for ((i) = 0; (i) < (pf)->num_alloc_vfs; (i)++)
 42
 43/* Specific VF states */
 44enum ice_vf_states {
 45	ICE_VF_STATE_INIT = 0,		/* PF is initializing VF */
 46	ICE_VF_STATE_ACTIVE,		/* VF resources are allocated for use */
 47	ICE_VF_STATE_QS_ENA,		/* VF queue(s) enabled */
 48	ICE_VF_STATE_DIS,
 49	ICE_VF_STATE_MC_PROMISC,
 50	ICE_VF_STATE_UC_PROMISC,
 51	ICE_VF_STATES_NBITS
 52};
 53
 54/* VF capabilities */
 55enum ice_virtchnl_cap {
 56	ICE_VIRTCHNL_VF_CAP_L2 = 0,
 57	ICE_VIRTCHNL_VF_CAP_PRIVILEGE,
 58};
 59
 60/* VF MDD events print structure */
 61struct ice_mdd_vf_events {
 62	u16 count;			/* total count of Rx|Tx events */
 63	/* count number of the last printed event */
 64	u16 last_printed;
 65};
 66
 67/* VF information structure */
 68struct ice_vf {
 69	struct ice_pf *pf;
 70
 71	u16 vf_id;			/* VF ID in the PF space */
 72	u16 lan_vsi_idx;		/* index into PF struct */
 73	/* first vector index of this VF in the PF space */
 74	int first_vector_idx;
 75	struct ice_sw *vf_sw_id;	/* switch ID the VF VSIs connect to */
 76	struct virtchnl_version_info vf_ver;
 77	u32 driver_caps;		/* reported by VF driver */
 78	struct virtchnl_ether_addr dflt_lan_addr;
 79	DECLARE_BITMAP(txq_ena, ICE_MAX_RSS_QS_PER_VF);
 80	DECLARE_BITMAP(rxq_ena, ICE_MAX_RSS_QS_PER_VF);
 81	u16 port_vlan_info;		/* Port VLAN ID and QoS */
 82	u8 pf_set_mac:1;		/* VF MAC address set by VMM admin */
 83	u8 trusted:1;
 84	u8 spoofchk:1;
 85	u8 link_forced:1;
 86	u8 link_up:1;			/* only valid if VF link is forced */
 87	/* VSI indices - actual VSI pointers are maintained in the PF structure
 88	 * When assigned, these will be non-zero, because VSI 0 is always
 89	 * the main LAN VSI for the PF.
 90	 */
 91	u16 lan_vsi_num;		/* ID as used by firmware */
 92	unsigned int tx_rate;		/* Tx bandwidth limit in Mbps */
 93	DECLARE_BITMAP(vf_states, ICE_VF_STATES_NBITS);	/* VF runtime states */
 94
 95	u64 num_inval_msgs;		/* number of continuous invalid msgs */
 96	u64 num_valid_msgs;		/* number of valid msgs detected */
 97	unsigned long vf_caps;		/* VF's adv. capabilities */
 98	u8 num_req_qs;			/* num of queue pairs requested by VF */
 99	u16 num_mac;
100	u16 num_vf_qs;			/* num of queue configured per VF */
101	struct ice_mdd_vf_events mdd_rx_events;
102	struct ice_mdd_vf_events mdd_tx_events;
103};
104
105#ifdef CONFIG_PCI_IOV
106void ice_process_vflr_event(struct ice_pf *pf);
107int ice_sriov_configure(struct pci_dev *pdev, int num_vfs);
108int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac);
109int
110ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi);
111
112void ice_free_vfs(struct ice_pf *pf);
113void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event);
114void ice_vc_notify_link_state(struct ice_pf *pf);
115void ice_vc_notify_reset(struct ice_pf *pf);
116bool ice_reset_all_vfs(struct ice_pf *pf, bool is_vflr);
117bool ice_reset_vf(struct ice_vf *vf, bool is_vflr);
118void ice_restore_all_vfs_msi_state(struct pci_dev *pdev);
119
120int
121ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,
122		     __be16 vlan_proto);
123
124int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted);
125
126int ice_set_vf_link_state(struct net_device *netdev, int vf_id, int link_state);
127
128int ice_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool ena);
129
130int ice_calc_vf_reg_idx(struct ice_vf *vf, struct ice_q_vector *q_vector);
131
132void ice_set_vf_state_qs_dis(struct ice_vf *vf);
133int
134ice_get_vf_stats(struct net_device *netdev, int vf_id,
135		 struct ifla_vf_stats *vf_stats);
136bool ice_is_any_vf_in_promisc(struct ice_pf *pf);
137void
138ice_vf_lan_overflow_event(struct ice_pf *pf, struct ice_rq_event_info *event);
139void ice_print_vfs_mdd_events(struct ice_pf *pf);
140void ice_print_vf_rx_mdd_event(struct ice_vf *vf);
141#else /* CONFIG_PCI_IOV */
142#define ice_process_vflr_event(pf) do {} while (0)
143#define ice_free_vfs(pf) do {} while (0)
144#define ice_vc_process_vf_msg(pf, event) do {} while (0)
145#define ice_vc_notify_link_state(pf) do {} while (0)
146#define ice_vc_notify_reset(pf) do {} while (0)
147#define ice_set_vf_state_qs_dis(vf) do {} while (0)
148#define ice_vf_lan_overflow_event(pf, event) do {} while (0)
149#define ice_print_vfs_mdd_events(pf) do {} while (0)
150#define ice_print_vf_rx_mdd_event(vf) do {} while (0)
151#define ice_restore_all_vfs_msi_state(pdev) do {} while (0)
152
153static inline bool
154ice_reset_all_vfs(struct ice_pf __always_unused *pf,
155		  bool __always_unused is_vflr)
156{
157	return true;
158}
159
160static inline bool
161ice_reset_vf(struct ice_vf __always_unused *vf, bool __always_unused is_vflr)
162{
163	return true;
164}
165
166static inline int
167ice_sriov_configure(struct pci_dev __always_unused *pdev,
168		    int __always_unused num_vfs)
169{
170	return -EOPNOTSUPP;
171}
172
173static inline int
174ice_set_vf_mac(struct net_device __always_unused *netdev,
175	       int __always_unused vf_id, u8 __always_unused *mac)
176{
177	return -EOPNOTSUPP;
178}
179
180static inline int
181ice_get_vf_cfg(struct net_device __always_unused *netdev,
182	       int __always_unused vf_id,
183	       struct ifla_vf_info __always_unused *ivi)
184{
185	return -EOPNOTSUPP;
186}
187
188static inline int
189ice_set_vf_trust(struct net_device __always_unused *netdev,
190		 int __always_unused vf_id, bool __always_unused trusted)
191{
192	return -EOPNOTSUPP;
193}
194
195static inline int
196ice_set_vf_port_vlan(struct net_device __always_unused *netdev,
197		     int __always_unused vf_id, u16 __always_unused vid,
198		     u8 __always_unused qos, __be16 __always_unused v_proto)
199{
200	return -EOPNOTSUPP;
201}
202
203static inline int
204ice_set_vf_spoofchk(struct net_device __always_unused *netdev,
205		    int __always_unused vf_id, bool __always_unused ena)
206{
207	return -EOPNOTSUPP;
208}
209
210static inline int
211ice_set_vf_link_state(struct net_device __always_unused *netdev,
212		      int __always_unused vf_id, int __always_unused link_state)
213{
214	return -EOPNOTSUPP;
215}
216
217static inline int
218ice_calc_vf_reg_idx(struct ice_vf __always_unused *vf,
219		    struct ice_q_vector __always_unused *q_vector)
220{
221	return 0;
222}
223
224static inline int
225ice_get_vf_stats(struct net_device __always_unused *netdev,
226		 int __always_unused vf_id,
227		 struct ifla_vf_stats __always_unused *vf_stats)
228{
229	return -EOPNOTSUPP;
230}
231
232static inline bool ice_is_any_vf_in_promisc(struct ice_pf __always_unused *pf)
233{
234	return false;
235}
236#endif /* CONFIG_PCI_IOV */
237#endif /* _ICE_VIRTCHNL_PF_H_ */