]> asedeno.scripts.mit.edu Git - linux.git/blob - drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h
Merge tag 'for-linus-5.1-2' of git://github.com/cminyard/linux-ipmi
[linux.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_MDD_EVENTS_ALLOWED         3
19 #define ICE_DFLT_NUM_INVAL_MSGS_ALLOWED         10
20
21 /* Static VF transaction/status register def */
22 #define VF_DEVICE_STATUS                0xAA
23 #define VF_TRANS_PENDING_M              0x20
24
25 /* Specific VF states */
26 enum ice_vf_states {
27         ICE_VF_STATE_INIT = 0,
28         ICE_VF_STATE_ACTIVE,
29         ICE_VF_STATE_ENA,
30         ICE_VF_STATE_DIS,
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.
36          */
37         ICE_VF_STATE_CFG_INTR,
38         ICE_VF_STATES_NBITS
39 };
40
41 /* VF capabilities */
42 enum ice_virtchnl_cap {
43         ICE_VIRTCHNL_VF_CAP_L2 = 0,
44         ICE_VIRTCHNL_VF_CAP_PRIVILEGE,
45 };
46
47 /* VF information structure */
48 struct ice_vf {
49         struct ice_pf *pf;
50
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;
57         u16 port_vlan_id;
58         u8 pf_set_mac;                  /* VF MAC address set by VMM admin */
59         u8 trusted;
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 */
68         u8 link_forced;
69         u8 link_up;                     /* only valid if VF link is forced */
70         u8 spoofchk;
71         u16 num_mac;
72         u16 num_vlan;
73         u8 num_req_qs;                  /* num of queue pairs requested by VF */
74 };
75
76 #ifdef CONFIG_PCI_IOV
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);
82
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);
88
89 int ice_set_vf_port_vlan(struct net_device *netdev, int vf_id,
90                          u16 vlan_id, u8 qos, __be16 vlan_proto);
91
92 int ice_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,
93                   int max_tx_rate);
94
95 int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted);
96
97 int ice_set_vf_link_state(struct net_device *netdev, int vf_id, int link_state);
98
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)
106
107 static inline bool
108 ice_reset_all_vfs(struct ice_pf __always_unused *pf,
109                   bool __always_unused is_vflr)
110 {
111         return true;
112 }
113
114 static inline int
115 ice_sriov_configure(struct pci_dev __always_unused *pdev,
116                     int __always_unused num_vfs)
117 {
118         return -EOPNOTSUPP;
119 }
120
121 static inline int
122 ice_set_vf_mac(struct net_device __always_unused *netdev,
123                int __always_unused vf_id, u8 __always_unused *mac)
124 {
125         return -EOPNOTSUPP;
126 }
127
128 static inline int
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)
132 {
133         return -EOPNOTSUPP;
134 }
135
136 static inline int
137 ice_set_vf_trust(struct net_device __always_unused *netdev,
138                  int __always_unused vf_id, bool __always_unused trusted)
139 {
140         return -EOPNOTSUPP;
141 }
142
143 static inline int
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)
147 {
148         return -EOPNOTSUPP;
149 }
150
151 static inline int
152 ice_set_vf_spoofchk(struct net_device __always_unused *netdev,
153                     int __always_unused vf_id, bool __always_unused ena)
154 {
155         return -EOPNOTSUPP;
156 }
157
158 static inline int
159 ice_set_vf_link_state(struct net_device __always_unused *netdev,
160                       int __always_unused vf_id, int __always_unused link_state)
161 {
162         return -EOPNOTSUPP;
163 }
164
165 static inline int
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)
169 {
170         return -EOPNOTSUPP;
171 }
172 #endif /* CONFIG_PCI_IOV */
173 #endif /* _ICE_VIRTCHNL_PF_H_ */