]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blob - drivers/net/ethernet/intel/ixgbevf/vf.h
ixgbevf: Use mac_ops instead of trying to identify NIC type
[mirror_ubuntu-hirsute-kernel.git] / drivers / net / ethernet / intel / ixgbevf / vf.h
1 /*******************************************************************************
2
3 Intel 82599 Virtual Function driver
4 Copyright(c) 1999 - 2015 Intel Corporation.
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
9
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 more details.
14
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, see <http://www.gnu.org/licenses/>.
17
18 The full GNU General Public License is included in this distribution in
19 the file called "COPYING".
20
21 Contact Information:
22 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
23 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24
25 *******************************************************************************/
26
27 #ifndef __IXGBE_VF_H__
28 #define __IXGBE_VF_H__
29
30 #include <linux/pci.h>
31 #include <linux/delay.h>
32 #include <linux/interrupt.h>
33 #include <linux/if_ether.h>
34 #include <linux/netdevice.h>
35
36 #include "defines.h"
37 #include "regs.h"
38 #include "mbx.h"
39
40 struct ixgbe_hw;
41
42 /* iterator type for walking multicast address lists */
43 typedef u8* (*ixgbe_mc_addr_itr) (struct ixgbe_hw *hw, u8 **mc_addr_ptr,
44 u32 *vmdq);
45 struct ixgbe_mac_operations {
46 s32 (*init_hw)(struct ixgbe_hw *);
47 s32 (*reset_hw)(struct ixgbe_hw *);
48 s32 (*start_hw)(struct ixgbe_hw *);
49 s32 (*clear_hw_cntrs)(struct ixgbe_hw *);
50 enum ixgbe_media_type (*get_media_type)(struct ixgbe_hw *);
51 s32 (*get_mac_addr)(struct ixgbe_hw *, u8 *);
52 s32 (*stop_adapter)(struct ixgbe_hw *);
53 s32 (*get_bus_info)(struct ixgbe_hw *);
54 s32 (*negotiate_api_version)(struct ixgbe_hw *hw, int api);
55
56 /* Link */
57 s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool, bool);
58 s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *, bool);
59 s32 (*get_link_capabilities)(struct ixgbe_hw *, ixgbe_link_speed *,
60 bool *);
61
62 /* RAR, Multicast, VLAN */
63 s32 (*set_rar)(struct ixgbe_hw *, u32, u8 *, u32);
64 s32 (*set_uc_addr)(struct ixgbe_hw *, u32, u8 *);
65 s32 (*init_rx_addrs)(struct ixgbe_hw *);
66 s32 (*update_mc_addr_list)(struct ixgbe_hw *, struct net_device *);
67 s32 (*update_xcast_mode)(struct ixgbe_hw *, struct net_device *, int);
68 s32 (*enable_mc)(struct ixgbe_hw *);
69 s32 (*disable_mc)(struct ixgbe_hw *);
70 s32 (*clear_vfta)(struct ixgbe_hw *);
71 s32 (*set_vfta)(struct ixgbe_hw *, u32, u32, bool);
72 void (*set_rlpml)(struct ixgbe_hw *, u16);
73 };
74
75 enum ixgbe_mac_type {
76 ixgbe_mac_unknown = 0,
77 ixgbe_mac_82599_vf,
78 ixgbe_mac_X540_vf,
79 ixgbe_mac_X550_vf,
80 ixgbe_mac_X550EM_x_vf,
81 ixgbe_num_macs
82 };
83
84 struct ixgbe_mac_info {
85 struct ixgbe_mac_operations ops;
86 u8 addr[6];
87 u8 perm_addr[6];
88
89 enum ixgbe_mac_type type;
90
91 s32 mc_filter_type;
92
93 bool get_link_status;
94 u32 max_tx_queues;
95 u32 max_rx_queues;
96 u32 max_msix_vectors;
97 };
98
99 struct ixgbe_mbx_operations {
100 s32 (*init_params)(struct ixgbe_hw *hw);
101 s32 (*read)(struct ixgbe_hw *, u32 *, u16);
102 s32 (*write)(struct ixgbe_hw *, u32 *, u16);
103 s32 (*read_posted)(struct ixgbe_hw *, u32 *, u16);
104 s32 (*write_posted)(struct ixgbe_hw *, u32 *, u16);
105 s32 (*check_for_msg)(struct ixgbe_hw *);
106 s32 (*check_for_ack)(struct ixgbe_hw *);
107 s32 (*check_for_rst)(struct ixgbe_hw *);
108 };
109
110 struct ixgbe_mbx_stats {
111 u32 msgs_tx;
112 u32 msgs_rx;
113
114 u32 acks;
115 u32 reqs;
116 u32 rsts;
117 };
118
119 struct ixgbe_mbx_info {
120 struct ixgbe_mbx_operations ops;
121 struct ixgbe_mbx_stats stats;
122 u32 timeout;
123 u32 udelay;
124 u32 v2p_mailbox;
125 u16 size;
126 };
127
128 struct ixgbe_hw {
129 void *back;
130
131 u8 __iomem *hw_addr;
132
133 struct ixgbe_mac_info mac;
134 struct ixgbe_mbx_info mbx;
135
136 u16 device_id;
137 u16 subsystem_vendor_id;
138 u16 subsystem_device_id;
139 u16 vendor_id;
140
141 u8 revision_id;
142 bool adapter_stopped;
143
144 int api_version;
145 };
146
147 struct ixgbevf_hw_stats {
148 u64 base_vfgprc;
149 u64 base_vfgptc;
150 u64 base_vfgorc;
151 u64 base_vfgotc;
152 u64 base_vfmprc;
153
154 u64 last_vfgprc;
155 u64 last_vfgptc;
156 u64 last_vfgorc;
157 u64 last_vfgotc;
158 u64 last_vfmprc;
159
160 u64 vfgprc;
161 u64 vfgptc;
162 u64 vfgorc;
163 u64 vfgotc;
164 u64 vfmprc;
165
166 u64 saved_reset_vfgprc;
167 u64 saved_reset_vfgptc;
168 u64 saved_reset_vfgorc;
169 u64 saved_reset_vfgotc;
170 u64 saved_reset_vfmprc;
171 };
172
173 struct ixgbevf_info {
174 enum ixgbe_mac_type mac;
175 const struct ixgbe_mac_operations *mac_ops;
176 };
177
178 #define IXGBE_FAILED_READ_REG 0xffffffffU
179
180 #define IXGBE_REMOVED(a) unlikely(!(a))
181
182 static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value)
183 {
184 u8 __iomem *reg_addr = ACCESS_ONCE(hw->hw_addr);
185
186 if (IXGBE_REMOVED(reg_addr))
187 return;
188 writel(value, reg_addr + reg);
189 }
190
191 #define IXGBE_WRITE_REG(h, r, v) ixgbe_write_reg(h, r, v)
192
193 u32 ixgbevf_read_reg(struct ixgbe_hw *hw, u32 reg);
194 #define IXGBE_READ_REG(h, r) ixgbevf_read_reg(h, r)
195
196 static inline void ixgbe_write_reg_array(struct ixgbe_hw *hw, u32 reg,
197 u32 offset, u32 value)
198 {
199 ixgbe_write_reg(hw, reg + (offset << 2), value);
200 }
201
202 #define IXGBE_WRITE_REG_ARRAY(h, r, o, v) ixgbe_write_reg_array(h, r, o, v)
203
204 static inline u32 ixgbe_read_reg_array(struct ixgbe_hw *hw, u32 reg,
205 u32 offset)
206 {
207 return ixgbevf_read_reg(hw, reg + (offset << 2));
208 }
209
210 #define IXGBE_READ_REG_ARRAY(h, r, o) ixgbe_read_reg_array(h, r, o)
211
212 int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int *num_tcs,
213 unsigned int *default_tc);
214 int ixgbevf_get_reta_locked(struct ixgbe_hw *hw, u32 *reta, int num_rx_queues);
215 int ixgbevf_get_rss_key_locked(struct ixgbe_hw *hw, u8 *rss_key);
216 #endif /* __IXGBE_VF_H__ */